| @@ -22,23 +22,30 @@ I64 selected; |
| 22 | 22 | U0 Verify() |
| 23 | 23 | { |
| 24 | 24 | I64 i,j,size,total=0; |
| 25 | | - U8 *code,path[64]; |
| 26 | | - U64 *rows; |
| 27 | | - for (i=0;i<3;i++) { |
| 28 | | - StrPrint(path,"C:/%s.BIN",names[i]); |
| 29 | | - code=FileRead(path,&size); |
| 30 | | - if (!code) throw('Code'); |
| 31 | | - "%-6s %d bytes ",names[i],size; |
| 32 | | - StrPrint(path,"C:/%s.DAT",names[i]); |
| 33 | | - rows=FileRead(path,&size); |
| 34 | | - if (!rows || size!=16384) throw('Vectors'); |
| 35 | | - for (j=0;j<size/32;j++) { |
| 36 | | - if (Pixel(code,rows[4*j],rows[4*j+1],rows[4*j+2])!=rows[4*j+3]) { |
| 37 | | - throw('Mismatch'); |
| 25 | + U8 *code=NULL,path[64]; |
| 26 | + U64 *rows=NULL; |
| 27 | + try { |
| 28 | + for (i=0;i<3;i++) { |
| 29 | + StrPrint(path,"C:/%s.BIN",names[i]); |
| 30 | + code=FileRead(path,&size); |
| 31 | + if (!code) throw('Code'); |
| 32 | + "%-6s %d bytes ",names[i],size; |
| 33 | + StrPrint(path,"C:/%s.DAT",names[i]); |
| 34 | + rows=FileRead(path,&size); |
| 35 | + if (!rows || size!=16384) throw('Vectors'); |
| 36 | + for (j=0;j<size/32;j++) { |
| 37 | + if (Pixel(code,rows[4*j],rows[4*j+1],rows[4*j+2])!=rows[4*j+3]) { |
| 38 | + throw('Mismatch'); |
| 39 | + } |
| 40 | + total++; |
| 38 | 41 | } |
| 39 | | - total++; |
| 42 | + "%d comparisons passed\n",size/32; |
| 43 | + Free(rows); |
| 44 | + rows=NULL; |
| 45 | + Free(code); |
| 46 | + code=NULL; |
| 40 | 47 | } |
| 41 | | - "%d comparisons passed\n",size/32; |
| 48 | + } catch { |
| 42 | 49 | Free(rows); |
| 43 | 50 | Free(code); |
| 44 | 51 | } |
| @@ -54,40 +61,54 @@ U0 Draw(CTask *,CDC *dc) |
| 54 | 61 | GrPrint(dc,80,416,"%s",program); |
| 55 | 62 | } |
| 56 | 63 | |
| 64 | +U0 Release(Bool restore) |
| 65 | +{ |
| 66 | + Fs->draw_it=NULL; |
| 67 | + if (restore) SettingsPop; |
| 68 | + DCDel(image); |
| 69 | + image=NULL; |
| 70 | + Free(shader); |
| 71 | + shader=NULL; |
| 72 | + Free(program); |
| 73 | + program=NULL; |
| 74 | +} |
| 75 | + |
| 57 | 76 | U0 Show(I64 which=0) |
| 58 | 77 | { |
| 59 | 78 | I64 x,y,dy,t=0; |
| 60 | 79 | U8 color,path[64]; |
| 80 | + Bool restore=FALSE; |
| 61 | 81 | if (!(0<=which<3)) return; |
| 62 | | - selected=which; |
| 63 | | - StrPrint(path,"C:/%s.BIN",names[which]); |
| 64 | | - shader=FileRead(path); |
| 65 | | - if (!shader) throw('Code'); |
| 66 | | - StrPrint(path,"C:/%s.TXT",names[which]); |
| 67 | | - program=FileRead(path); |
| 68 | | - if (!program) throw('Source'); |
| 69 | | - image=DCNew(480,336); |
| 70 | | - SettingsPush; |
| 71 | | - AutoComplete(OFF); |
| 72 | | - WinMax; |
| 73 | | - DocClear; |
| 74 | | - Fs->draw_it=&Draw; |
| 75 | | - while (!ScanChar) { |
| 76 | | - for (y=0;y<112;y++) { |
| 77 | | - for (x=0;x<160;x++) { |
| 78 | | - color=Pixel(shader,x,y,t)&15; |
| 79 | | - for (dy=0;dy<3;dy++) |
| 80 | | - MemSet(image->body+(3*y+dy)*480+3*x,color,3); |
| 82 | + try { |
| 83 | + selected=which; |
| 84 | + StrPrint(path,"C:/%s.BIN",names[which]); |
| 85 | + shader=FileRead(path); |
| 86 | + if (!shader) throw('Code'); |
| 87 | + StrPrint(path,"C:/%s.TXT",names[which]); |
| 88 | + program=FileRead(path); |
| 89 | + if (!program) throw('Source'); |
| 90 | + image=DCNew(480,336); |
| 91 | + SettingsPush; |
| 92 | + restore=TRUE; |
| 93 | + AutoComplete(OFF); |
| 94 | + WinMax; |
| 95 | + DocClear; |
| 96 | + Fs->draw_it=&Draw; |
| 97 | + while (!ScanChar) { |
| 98 | + for (y=0;y<112;y++) { |
| 99 | + for (x=0;x<160;x++) { |
| 100 | + color=Pixel(shader,x,y,t)&15; |
| 101 | + for (dy=0;dy<3;dy++) |
| 102 | + MemSet(image->body+(3*y+dy)*480+3*x,color,3); |
| 103 | + } |
| 81 | 104 | } |
| 105 | + t+=2; |
| 106 | + Refresh; |
| 107 | + Sleep(20); |
| 82 | 108 | } |
| 83 | | - t+=2; |
| 84 | | - Refresh; |
| 85 | | - Sleep(20); |
| 109 | + } catch { |
| 110 | + Release(restore); |
| 86 | 111 | } |
| 87 | | - Fs->draw_it=NULL; |
| 88 | | - SettingsPop; |
| 89 | | - DCDel(image); |
| 90 | | - Free(shader); |
| 91 | | - Free(program); |
| 112 | + Release(restore); |
| 92 | 113 | DocClear; |
| 93 | 114 | } |