2IMGCdrP@(@P8L xC)pJJJJ IH(ȱH:=IH[H`@H^H 2 9 @   I/H`JLNGȄBȄF aK ' faaFF  RJm# KKJ qJ )J ۈJJm  JFȱJGJKaȄM ' 5aaNNJFLGJ`a  XL LG &PRODOS`DaElH$?EGvѶK+`L XX LU ŠϠĠӥS)*+,+`F)) (*=GJFjJJA QE'+ '== `@ STSP8QSS8 m P o R(8RBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHBHSECONDSIGHT' ('INSTALL  5/FIRM LIBjMISCSVIEW@ZMACA Installation Notes ------------ ----- lib/vga.h and lib/vgalib.h need to go in the directory 2/ORCADEFS. lib/lvga needs to go in the directory 2/ (ORCA's LIBRARIES folder). And that's about it. Documentation is where you can find it, and also in the two Microsoft Word documents. We'll include Teach versions here soon. To join an Internet mailing list of Second Sight developers, send email to majordomo@hypermall.com with the following in the body (_not_ the subject): subscribe ss-devel bazyar@hypermall.com FIRMv' '%CFONT -5% 'CFONT.C%5 +DHIRES.ALGO( 5# (FONT.TAB2 #5 )FONT8.TAB<5 *HIRES.ALGOB 5־6 +HIRES.ALGO2I 5׾ )INTL.FONTP5# (MKCTAB.C_:5 'MKTAB.Ce5ܾ  RC.TXTi5'  !"#$U,C ~ExpressLoadU (),E ,(0E (":%""";8 [dںw"x!ee HH"hH  hhIں PH"hHhhh)HHں"ohH8hh" hchchh  )"x!Hhchch).A"x!Hhchch)o8pI0ʊ_ H"x!Hhchch).芢H"x!Hhchchhںy"hں"x!HhchchH}"h8pI0ʊIں"x!HhchchH"hں"h  +;ikr%s db 0%02Xh,0%02Xh ;8 [H H" H H"Xdd7d 0 H H"0dd    ֦ +;i k;8 [Kdd)awr  HH"f   ȷ   " =r  ^  "  "   2w" BX=a6" Xе" "U"U  HH"' kmkmȥ ȩ)+bȷ)+arQI ȗ H H"'+;ik)+8`b8``;8 [ )   2   7 H"F  H"H H L  )    H H"~ i ȷ i  8  ȷ :      )  ) H H"~  +;i kF`a;iDH" 8hDiDhz;mDZګ{kiHgHH"zhZګk; [  +hhkH 2 h\$KzZڭHH; [ " ]i # " Ȁ " Ȁ  0 Z8czHHH H "* Out of memory/ "/$\$h h  , . m0   Ȁ  . , )s  "   i  ")0"!)    . , +hhkK H H ;[$ [hHHhk֯mk "+hh`km   H"ice  H"igiiHgH"  H"i_aH" 0 kraa, "7 * . `  i "9 g !s م " }   `q  .CONSOLEH; [' HJ e effff`  Fe jf +;ikKmHkH; [   8+hhzhhZګk; [  +hzzH`;8 [ H H"oH"U  H H HiH"K  +;i kK ;[{)%H"\  +kseoqi mkuc e).q o)li Lh )@ Y |)-k,0m"+ u+u #c8``)*`)0:)H mc%n9s7bXpcXxohudifcePEUg&G+{\;8 [KH H" -H H"~dkm  k m'    )\ "U_aieg  P["9 Y" U" cHH"'!    W" U )@ H H"'H H"' ii d  +;i k;8 [Kdd)awr  OH ȷ   -w8" 6?X:a3&." $Xз*4(2" ,"U"U  HH"' kmkmȥ ȩ)+bȷ)+arQIH ȗ+;ik)+8`bH8``; [HH" )+hhk;8 [KHH" p)d " $8"&$( &"  HH L HH" )d+;ik;8 [K c eiHgH"~aH_H"~ ) ) )   H H L    ,  c v{itxz  t v x z r  K" p?L | ~    ) tm| vm~    | ~   | ~ U i  i )8   :  )    I   )   +;i k ". " p"- 0 &  |0  Ȍ| "` ` . (I; [HH J     z +;i k;8 [KHH"   ) w  HH"U  _ @@ HH"'7 ȥ  ȥȗd+;ike 7%"\ 5 i5u }Q}~Tyiywg0RNznynxnwjJJJJ 0:i 5}z y x w˭c X 5h0g0 HH ȷ  HH ) qoow8ewe 7wZ)H"\zwhih xe 7H"\di!8  I-ugiHH}Si '" &"qoo 0/ ' }S} So 8eoeuegeeR } 8eIem0 7uH"\g H"\hH"\m0e0 mH"\eo 0"\oȹ}) SZ})H"\zȀi HH {ihih `u }Q}~Tyiyw0Rz y x w!NznynxnwjJJJJJ 0}Rc0}0gQ; [ ȊwHwhȷ+;ikk`ke0 "\e`$$o $ I-uq 8o HH "} "0}{e}}~0}0s $0}}eE}0~) }P~T6c10}}0 :}}.}} 蘼}}0ue})8eIem0 7uH"\m0e0 0"\e})}Z)H"\zi Y0~.}#} ~e}0 8. 0`} ~}}`q oqo HH "cIsc)m:ooo8oL; [C!" +;ikL; [%A!" +;ik%; [8""+hhk "=""T#hhkHHH8H; [  "M! % Q8  0 "$ "$ "M!e i @< "$ "$   "M!Z "$"+;i kHH8H; [R%ȷT%ȷ HH"+hhhhkH; ["'V%ȿX%V%X%+hhk ;8[IȅIdFejfFejfFejfFejfFEejfFejfFejfFejf2-I;i+ke &****;i+@kHiH;8  [  "' V%X%O$>"T#z%|%ȩȗ na i  U GEX%V% "$F e i  "M! "M!8  0 E V%X% "$) i+;iki+$-$)$HH-$H+$H H-$@@)$H "hh)$) )$kHH; [R%ȗT%ȗȥȥȩR%T% R%T%i+zzzzk; [  )8 I"x( )L  ! )H"  ( " )H"   " +;i kH"~%"&"&h") $HHHHH; ["'V%X%  ȷݠV%ȷX% ȷ+;i kHZ"&"|&"&"S&"%kKE!?!%" %G!A!%" %I!C!%" %kK9 9!;!=! "'?!K!?!-&"9 +&!7&I&" A&G&K! "'A! "'C!k5& I&.CONSOLEK kHH;H" ;[+hhk"c( H"kH "hHi "k "kKzhhh  Zګk:JJJJk;8  [d 1!'"7 ' 'HH HHH'"0" "zj '(('( ( '" '$"8 ((" ( (HH"  +;i k(KR%T%&V%kH ;[ " "+hk 2S 5yA}4Q ,L !-7Pqv,C !'/@GLTNUkq"?Zm :]u '-DJ!3ELV\djbR^>=A"G?Fjp =GaT[ckq Xbfw}#/\ahnsx} If{ #>BFJN #1C0&w)EQtz1N EHcfiGkP9 Bgjn#6: '147ILad !$7:=Jm{ "&*.26:>BFJNRVZ]  >EJNVZ $,/4^aρ &).v{-58=HTaoux{~ *LQioux~28=KQY\_gj|! "%+07 #include #include char line[80]; int arr[20]; int main(int argc, char *argv[]) { FILE *fin,*fout; int ind,val; int i,donefl = 0; fin = fopen(argv[1],"r"); ind = 0; while (!donefl) { val = 0; if (fgets(line,80,fin) == NULL) donefl = 1; line[strlen(line)-1] = '\0'; if ((line[0] == '.') || (line[0] == 'o')) { /*printf("* %s\n",line);*/ for (i = 0; i < 8; i++) val = (val << 1) | ((line[i] == '.') ? 0 : 1); arr[ind++] = val; } else { printf("%s\n",line); if (ind != 0) { printf(" db 0%02Xh",arr[0]); for (i = 1; i < ind; i++) printf(",0%02Xh",arr[i]); printf("\n"); } ind = 0; } } } )*+,-./01 ------------------------------------------------------------------ Double Hi-Res, Monochrome Use 640x200x16, planar mode $0E 00000000 11111111 22222222 33333333 44444444 55555555 66666666 VGA Byte AAAAAAAB BBBBBBCC CCCCCDDD DDDDEEEE EEEFFFFF FFGGGGGG GHHHHHHH Palette switch 77777777 77777777 77777777 77777777 77777777 77777777 77777777 AAAAAABB BBBBBCCC CCCCDDDD DDDEEEEE EEFFFFFF FGGGGGGG HHHHHHH0 Next Bit 54321065 43210654 32106543 21065432 10654321 06543210 65432100 0AAAAAAA BBBBBBBC CCCCCCDD DDDDDEEE EEEEFFFF FFFGGGGG GGHHHHHH Prev Bit 06543210 65432106 54321065 43210654 32106543 21065432 10654321 AAAAAAAB BBBBBBCC CCCCCDDD DDDDEEEE EEEFFFFF FFGGGGGG GHHHHHHH On/Off 01234560 12345601 23456012 34560123 45601234 56012345 60123456 6 5 4 3 2 1 7 1 7 6 5 4 3 2 7 6 5 4 3 2 1 ABBBBBBB 1 AAABBBBB 3 AAAAABBB 5 AAAAAAAB 7 60123456 45601234 23456012 01234560 AABBBBBB 2 AAAABBBB 4 AAAAAABB 6 56012345 34560123 12345601 We need 14 tables: (@ operator is "reverse bit order") A7 = (@A & 0xFE) << 0 B7 = (@B & 0xFE) >> 7 A6 = (@A & 0xFE) << 1 B6 = (@B & 0xFE) >> 6 A5 = (@A & 0xFE) << 2 B5 = (@B & 0xFE) >> 5 A4 = (@A & 0xFE) << 3 B4 = (@B & 0xFE) >> 4 A3 = (@A & 0xFE) << 4 B3 = (@B & 0xFE) >> 3 A2 = (@A & 0xFE) << 5 B2 = (@B & 0xFE) >> 2 A1 = (@A & 0xFE) << 6 B1 = (@B & 0xFE) >> 1 IX = Aux IY = Main bc = table A hl = table B Memory Map: $0000 - $A000 (normal) $A000 - $C000 ($012000) $C000 - $FFFF ($0A0000) dhires_row ld a,0 ld (var),a rowloop call dhires_scan ld hl,80 add hl,de push hl pop de add $0800 - 40 to IX add $0800 - 40 to IY ld a,(var) dec a ld (var),a jr nz,rowloop ret dhires_scan ld c,8 push de exx pop de exx loopit exx ld b,T_A7 ; 6 ld h,T_B7 ; 6 ld c,(IX+0) ; 14 ld l,(IY+0) ; 14 ld a,(bc) ; 6 or (hl) ; 6 ld (de),a ; 7 inc de ; 4 dec b ; 4 dec h ; 4 ld c,l ; 4 ld l,(IX+1) ; 14 ld a,(bc) ; 6 or (hl) ; 6 ld (de),a ; 6 ; output byte 1 inc de ; 4 dec b ; 4 dec h ; 4 ld c,l ; 4 ld l,(IY+1) ; 14 ld a,(bc) ; 6 or (hl) ; 6 ld (de),a ; 6 ; 2 inc de ; 4 dec b ; 4 dec h ; 4 ld c,l ; 4 ld l,(IX+2) ; 14 ld a,(bc) ; 6 or (hl) ; 6 ld (de),a ; 6 ; 3 inc de ; 4 dec b ; 4 dec h ; 4 ld c,l ; 4 ld l,(IY+2) ; 14 ld a,(bc) ; 6 or (hl) ; 6 ld (de),a ; 6 ; 4 inc de ; 4 dec b ; 4 dec h ; 4 ld c,l ; 4 ld l,(IX+3) ; 14 ld a,(bc) ; 6 or (hl) ; 6 ld (de),a ; 6 ; 5 inc de ; 4 dec b ; 4 dec h ; 4 ld c,l ; 4 ld l,(IY+3) ; 14 ld a,(bc) ; 6 or (hl) ; 6 ld (de),a ; 6 ; 6 inc de ; 4 dec b ; 4 dec h ; 4 ld c,l ; 4 add 4,ix add 4,iy loop 8 times exx ld hl,4 add hl,IX push hl pop IX ld hl,4 add hl,IY push hl pop IY dec c jr nz,loopit ret * Using the VGA chip's 32-bit "copy" mode, set up a table that * is mapped in at $C000. A 1024-byte table... exx ld e,a ld a,(de) ; do the table lookup exx 0000 black 0001 magenta 0010 brown 0011 orange 0100 dark green 0101 gray 1 0110 green 0111 yellow 1000 dark blue 1001 purple 1010 gray 2 1011 pink 1100 medium blue 1101 light blue 1110 aqua 1111 white 3456789:;* A Sample font file hex81 ..oooo.. .oooooo. .o....o. .o....o. .o...... .o...... ooo..... ooo..... .o...... .o...... .o...... .oo..... o.ooo... o..oooo. ........ ........ ........ ...o.... ....o... .....o.. ........ .oooo... ....oo.. .ooooo.. oo..oo.. oo..oo.. oo..oo.. .ooo.oo. ........ ........ ........ ........ ...o.... ..ooo... .oo.oo.. ..ooo... ...o.... ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ .ooooo.. oo...... oo...... oo...... oo...... .ooooo.. ...oo... ..oo.... .oo..... ........ ........ ..ooooo. .oooooo. .o...... .o...... .ooooo.. ..ooooo. .o....o. .o....o. .oooooo. ..oooo.. ......o. ......o. .oooooo. .ooooo.. ........ ........ ........ .....o.. ....o... ...o.... ........ .ooooo.. oo...oo. ooooooo. oo...... oo...... oo...oo. .ooooo.. ........ ........ ........ ........ ........ ..o..... ...o.... ....o... ........ oo..oo.. oo..oo.. oo..oo.. oo..oo.. oo..oo.. oo..oo.. .ooo.oo. ........ ........ ........ ........ ........ ..o..... ...o.... ....o... ........ .ooooo.. oo...oo. ooooooo. oo...... oo...... oo...oo. .ooooo.. ........ ........ ........ ........ .oo..oo. .oo..oo. ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ..ooooo. .o.oo... o..oo... o..oo... o..oo... o..oo... ooooooo. o..oo... o..oo... o..oo... o..oo... o..oo... o..oooo. ........ ........ .......o ......o. ..oooo.. .oooooo. .o...oo. .o..o.o. .o..o.o. .o..o.o. .o.o..o. .o.o..o. .o.o..o. .oo...o. .oooooo. ..oooo.. .o...... o....... ..ooo... ..ooo... ........ ..ooo... .ooooo.. oo...oo. oo...oo. oo...oo. ooooooo. oo...oo. oo...oo. oo...oo. oo...oo. ........ ........ ........ ........ ........ ........ ........ ........ .oo.oo.. ..oo..o. .oooooo. o.o..... o.o..... o.o...o. .ooooo.. ........ ........ ........ ........ ........ ........ .....o.. .....o.. ..ooo... ..ooo... .o..oo.. .o..oo.. .o.o.o.. .o.o.o.. .oo..o.. .oo..o.. ..ooo... ..ooo... .o...... .o...... ........ ...o.... ..o.o... ...o.... ........ .oooo... ....oo.. .ooooo.. oo..oo.. oo..oo.. oo..oo.. .ooo.oo. ........ ........ ........ ........ ........ ...oo... ...oo... ........ ...oo... ...oo... ...oo... ...oo... ...oo... ...oo... ...oo... ...oo... ...oo... ...oo... ........ ........ ..oo.oo. .oo.oo.. ........ oo...oo. oo...oo. ooo..oo. ooo..oo. oo.o.oo. oo.o.oo. oo..ooo. oo..ooo. oo...oo. oo...oo. ........ ........ ........ ........ ........ ...o.... ..ooo... ...o.... ........ ...o.... ...o.... ...o.... ...o.... ..o..... .o...... .o...o.. .o...o.. ..ooo... ........ ........ ..oo.oo. .oo.oo.. ........ ........ o.oooo.. .oo..oo. .oo..oo. .oo..oo. .oo..oo. .oo..oo. .oo..oo. ........ ........ ........ ........ ........ ..o..... ...o.... ....o... ........ .ooooo.. oo...oo. oo...oo. oo...oo. oo...oo. oo...oo. .ooooo.. ........ ........ ........ ........ ........ ..o..... ...o.... ....o... ........ ..ooo... ...oo... ...oo... ...oo... ...oo... ...oo... ..oooo.. ........ ........ ........ ........ oo...oo. oo...oo. ........ ..ooo... .ooooo.. oo...oo. oo...oo. oo...oo. oo...oo. ooooooo. oo...oo. oo...oo. oo...oo. oo...oo. ........ ........ oo...oo. oo...oo. ........ .ooooo.. oo...oo. oo...oo. oo...oo. oo...oo. oo...oo. oo...oo. oo...oo. oo...oo. .ooooo.. ........ ........ ........ oo...oo. oo...oo. ........ oo...oo. oo...oo. oo...oo. oo...oo. oo...oo. oo...oo. oo...oo. oo...oo. oo...oo. .ooooo.. ........ ........ ........ ........ .oo..oo. .oo..oo. ........ ........ .oooo... ....oo.. .ooooo.. oo..oo.. oo..oo.. oo..oo.. .ooo.oo. ........ ........ ........ ........ ........ oo...oo. oo...oo. ........ .ooooo.. oo...oo. oo...oo. oo...oo. oo...oo. oo...oo. oo...oo. oo...oo. oo...oo. .ooooo.. ........ ........ ........ ........ oo..oo.. oo..oo.. ........ ........ oo..oo.. oo..oo.. oo..oo.. oo..oo.. oo..oo.. oo..oo.. .ooo.oo. ........ ........ ........ ........ ........ .ooooo.. oo...oo. oo...oo. oo...oo. oo...oo. oooooo.. oooooo.. oo...oo. oo...oo. oo...oo. oo...oo. oo...oo. oo.ooo.. o....... o....... ........ .ooooo.. oo...oo. ..ooo... .ooooo.. oo...oo. oo...oo. oo...oo. oo...oo. ooooooo. oo...oo. oo...oo. oo...oo. oo...oo. ........ ........ ........ ..oo.... .o..o... o....o.. ........ .oooo... ....oo.. .ooooo.. oo..oo.. oo..oo.. oo..oo.. .ooo.oo. ........ ........ ........ ........ =>?@A* A Sample font file hex81 ..oooo.. .o....o. .o...... ooo..... .o...... .o...... o.ooooo. ........ .....o.. ......o. ..oooo.o ......o. ..ooooo. .o....o. ..ooooo. ........ ...o.... ..o.o... ...o.... ........ ........ ........ ........ ........ ........ ........ ..oooo.. .o...... .o...... ..oooo.. ...o.... ..o..... ..ooooo. .o...... ..oooo.. .o....o. ..oooo.. ......o. .ooooo.. ........ .....o.. ....o... ..oooo.. .o....o. .oooooo. .o...... ..ooooo. ........ ..o..... ...o.... .o....o. .o....o. .o....o. .o...oo. ..ooo.o. ........ ..o..... ...o.... ..oooo.. .o....o. .oooooo. .o...... ..ooooo. ........ .o....o. ........ ........ ........ ........ ........ ........ ........ ..ooooo. .o..o... .o..o... .oooooo. .o..o... .o..o... .o..ooo. ........ ......o. ..oooo.. .o...oo. .o..o.o. .o.o..o. .oo...o. ..oooo.. .o...... ...o.... ........ ..ooo... .o...o.. .ooooo.. .o...o.. .o...o.. ........ ........ .ooooo.. ...o..o. ..oo..o. .o.oooo. .o.o.... ..ooooo. ........ ........ .....o.. ..ooo... .o..oo.. .o.o.o.. .oo..o.. ..ooo... .o...... ....o... ........ ..oooo.. ......o. ..ooooo. .o....o. ..ooooo. ........ ........ ...o.... ........ ...o.... ...o.... ...o.... ...o.... ...o.... ...o.o.. ..o.o... ........ .o...o.. .oo..o.. .o.o.o.. .o..oo.. .o...o.. ...o.... ........ ...o.... ...o.... ..o..... .o...... .o...o.. ..ooo... ...o.o.. ..o.o... ........ .ooooo.. .o....o. .o....o. .o....o. ........ ....o... .....o.. ..oooo.. .o....o. .o....o. .o....o. ..oooo.. ........ ..o..... ...o.... ........ ..oo.... ...o.... ...o.... ..ooo... ........ .o...o.. ........ ..ooo... .o...o.. .ooooo.. .o...o.. .o...o.. ........ .o....o. ..oooo.. .o....o. .o....o. .o....o. .o....o. ..oooo.. ........ .o....o. ........ .o....o. .o....o. .o....o. .o....o. ..oooo.. ........ .o....o. ........ ..oooo.. ......o. ..ooooo. .o....o. ..ooooo. ........ ..o..o.. ........ ..oooo.. .o....o. .o....o. .o....o. ..oooo.. ........ ..o..o.. ........ .o....o. .o....o. .o....o. .o...oo. ..ooo.o. ........ .ooooo.. .o....o. .o....o. .ooooo.. .o....o. .o....o. .o.ooo.. .o...... .ooooo.. o.....o. ..ooo... .o...o.. .ooooo.. .o...o.. .o...o.. ........ ...o.... ..o.o... ..oooo.. ......o. ..ooooo. .o....o. ..ooooo. ........ CDEFGH ------------------------------------------------------------------ 00000000 11111111 22222222 33333333 44444444 55555555 66666666 VGA Byte AAAAAAAB BBBBBBCC CCCCCDDD DDDDEEEE EEEFFFFF FFGGGGGG GHHHHHHH Palette switch 77777777 77777777 77777777 77777777 77777777 77777777 77777777 AAAAAABB BBBBBCCC CCCCDDDD DDDEEEEE EEFFFFFF FGGGGGGG HHHHHHH0 Next Bit 54321065 43210654 32106543 21065432 10654321 06543210 65432100 0AAAAAAA BBBBBBBC CCCCCCDD DDDDDEEE EEEEFFFF FFFGGGGG GGHHHHHH Prev Bit 06543210 65432106 54321065 43210654 32106543 21065432 10654321 AAAAAAAB BBBBBBCC CCCCCDDD DDDDEEEE EEEFFFFF FFGGGGGG GHHHHHHH On/Off 65432106 54321065 43210654 32106543 21065432 10654321 06543210 6 5 4 3 2 1 7 1 7 6 5 4 3 2 7 6 5 4 3 2 1 AABBBBBB 2 AAABBBBB 3 AAAAABBB 5 AAAAAAAB 7 10654321 21065432 43210654 65432106 ABBBBBBB 1 AAAABBBB 4 AAAAAABB 6 06543210 32106543 54321065 We need 14 tables: A1 = A << 7 B1 = (B & 0x7F) >> 0 A2 = A << 6 B2 = (B & 0x7F) >> 1 A3 = A << 5 B3 = (B & 0x7F) >> 2 A4 = A << 4 B4 = (B & 0x7F) >> 3 A5 = A << 3 B5 = (B & 0x7F) >> 4 A6 = A << 2 B6 = (B & 0x7F) >> 5 A7 = A << 1 B7 = (B & 0x7F) >> 6 bc = table A hl = table B ld b,T_A7 ; 6 ld h,T_B7 ; 6 ld e,(IX+0) ; 14 ld l,(IX+1) ; 14 ld a,(bc) ; 6 or (hl) ; 6 ld (de),a ; 7 inc de ; 4 dec b ; 4 dec h ; 4 ld c,l ; 4 ld l,(IX+2) ; 14 ld a,(bc) ; 6 or (hl) ; 6 ld (de),a ; 6 ; output byte 1 inc de ; 4 dec b ; 4 dec h ; 4 ld c,l ; 4 ld l,(IX+3) ; 14 ld a,(bc) ; 6 or (hl) ; 6 ld (de),a ; 6 ; 2 inc de ; 4 dec b ; 4 dec h ; 4 ld c,l ; 4 ld l,(IX+4) ; 14 ld a,(bc) ; 6 or (hl) ; 6 ld (de),a ; 6 ; 3 inc de ; 4 dec b ; 4 dec h ; 4 ld c,l ; 4 ld l,(IX+5) ; 14 ld a,(bc) ; 6 or (hl) ; 6 ld (de),a ; 6 ; 4 inc de ; 4 dec b ; 4 dec h ; 4 ld c,l ; 4 ld l,(IX+6) ; 14 ld a,(bc) ; 6 or (hl) ; 6 ld (de),a ; 6 ; 5 inc de ; 4 dec b ; 4 dec h ; 4 ld c,l ; 4 ld l,(IX+7) ; 14 ld a,(bc) ; 6 or (hl) ; 6 ld (de),a ; 6 ; 6 inc de ; 4 dec b ; 4 dec h ; 4 ld c,l ; 4 ld hl,8 add hl,IX push hl pop ix * loop 4 times. JKLMNO ------------------------------------------------------------------ 00000000 11111111 22222222 33333333 44444444 55555555 66666666 VGA Byte AAAAAAAB BBBBBBCC CCCCCDDD DDDDEEEE EEEFFFFF FFGGGGGG GHHHHHHH Palette switch 77777777 77777777 77777777 77777777 77777777 77777777 77777777 AAAAAABB BBBBBCCC CCCCDDDD DDDEEEEE EEFFFFFF FGGGGGGG HHHHHHH0 Next Bit 54321065 43210654 32106543 21065432 10654321 06543210 65432100 0AAAAAAA BBBBBBBC CCCCCCDD DDDDDEEE EEEEFFFF FFFGGGGG GGHHHHHH Prev Bit 06543210 65432106 54321065 43210654 32106543 21065432 10654321 AAAAAAAB BBBBBBCC CCCCCDDD DDDDEEEE EEEFFFFF FFGGGGGG GHHHHHHH On/Off 01234560 12345601 23456012 34560123 45601234 56012345 60123456 6 5 4 3 2 1 7 1 7 6 5 4 3 2 7 6 5 4 3 2 1 ABBBBBBB 1 AAABBBBB 3 AAAAABBB 5 AAAAAAAB 7 60123456 45601234 23456012 01234560 AABBBBBB 2 AAAABBBB 4 AAAAAABB 6 56012345 34560123 12345601 We need 14 tables: (@ operator is "reverse bit order") A7 = (@A & 0xFE) << 0 B7 = (@B & 0xFE) >> 7 A6 = (@A & 0xFE) << 1 B6 = (@B & 0xFE) >> 6 A5 = (@A & 0xFE) << 2 B5 = (@B & 0xFE) >> 5 A4 = (@A & 0xFE) << 3 B4 = (@B & 0xFE) >> 4 A3 = (@A & 0xFE) << 4 B3 = (@B & 0xFE) >> 3 A2 = (@A & 0xFE) << 5 B2 = (@B & 0xFE) >> 2 A1 = (@A & 0xFE) << 6 B1 = (@B & 0xFE) >> 1 bc = table A hl = table B ld b,T_A7 ; 6 ld h,T_B7 ; 6 ld e,(IX+0) ; 14 ld l,(IX+1) ; 14 ld a,(bc) ; 6 or (hl) ; 6 ld (de),a ; 7 inc de ; 4 dec b ; 4 dec h ; 4 ld c,l ; 4 ld l,(IX+2) ; 14 ld a,(bc) ; 6 or (hl) ; 6 ld (de),a ; 6 ; output byte 1 inc de ; 4 dec b ; 4 dec h ; 4 ld c,l ; 4 ld l,(IX+3) ; 14 ld a,(bc) ; 6 or (hl) ; 6 ld (de),a ; 6 ; 2 inc de ; 4 dec b ; 4 dec h ; 4 ld c,l ; 4 ld l,(IX+4) ; 14 ld a,(bc) ; 6 or (hl) ; 6 ld (de),a ; 6 ; 3 inc de ; 4 dec b ; 4 dec h ; 4 ld c,l ; 4 ld l,(IX+5) ; 14 ld a,(bc) ; 6 or (hl) ; 6 ld (de),a ; 6 ; 4 inc de ; 4 dec b ; 4 dec h ; 4 ld c,l ; 4 ld l,(IX+6) ; 14 ld a,(bc) ; 6 or (hl) ; 6 ld (de),a ; 6 ; 5 inc de ; 4 dec b ; 4 dec h ; 4 ld c,l ; 4 ld l,(IX+7) ; 14 ld a,(bc) ; 6 or (hl) ; 6 ld (de),a ; 6 ; 6 inc de ; 4 dec b ; 4 dec h ; 4 ld c,l ; 4 ld hl,8 add hl,IX push hl pop ix * loop 4 times. QRSTUVWXYZ[\]^#################################################################### # @ [ \ ] ` { | } ~ $23 $40 $5B $5C $5D $60 $7B $7C $7D $7E --- --- --- --- --- --- --- --- --- --- US $23 $40 $5B $5C $5D $60 $7B $7C $7D $7E UK $81 $40 $5B $5C $5D $60 $7B $7C $7D $7E French $81 $82 $83 $84 $85 $60 $86 $87 $88 $89 Danish $23 $40 $8A $8B $8C $60 $8D $8E $8F $7E Span $81 $85 $90 $91 $92 $60 $83 $93 $84 $7E Itali $81 $85 $83 $84 $86 $87 $82 $94 $88 $95 German $23 $85 $96 $97 $98 $60 $99 $9A $9B $9C Swede $23 $40 $96 $97 $8C $60 $99 $9A $8F $7E $81 ..oooo.. .o....o. .o...... ooo..... .o...... .o...... o.ooooo. ........ ..oooo.. .oooooo. .o....o. .o....o. .o...... .o...... ooo..... ooo..... .o...... .o...... .o...... .oo..... o.ooo... o..oooo. ........ ........ $82 .....o.. ......o. ..oooo.o ......o. ..ooooo. .o....o. ..ooooo. ........ .....o.. .....o.. ......o. ......o. ..oooo.o .oooooo. ......o. ......o. ..ooooo. .oooooo. .o....o. .o....o. .oooooo. ..ooooo. ........ ........ $83 ...o.... ..o.o... ...o.... ........ ........ ........ ........ ........ ...o.... ..ooo... .oo.oo.. .oo.oo.. ..ooo... ...o.... ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ $84 ........ ........ ..oooo.. .o...... .o...... ..oooo.. ...o.... ..o..... ........ ........ ........ ........ ...oo... ..oooo.. .o...... .o...... .o...... .o...... ..oooo.. ...oo... ...o.... .oo..... ........ ........ $85 ..oooo.. .o...... ..oooo.. .o....o. ..oooo.. ......o. ..oooo.. ........ ..oooo.. .ooooo.. .o...... .o...... .ooooo.. ..ooooo. .o....o. .o....o. .oooooo. ..oooo.. ......o. ......o. ..ooooo. ..oooo.. ........ ........ $86 .....o.. ....o... ..oooo.. .o....o. .oooooo. .o...... ..ooooo. ........ ........ .....o.. ....o... ....o... ..oooo.. .oo..oo. .o....o. .o....o. .oo..oo. .oooooo. .o...... .o...... .oo...o. ..ooooo. ........ ........ $87 ..o..... ...o.... .o....o. .o....o. .o....o. .o...oo. ..ooo.o. ........ ..o..... ..oo.... ...o.... ........ ........ .o....o. .o....o. .o....o. .o....o. .o...oo. .o...oo. .o...oo. .oooooo. ..ooo.o. ........ ........ $88 ..o..... ...o.... ..oooo.. .o....o. .oooooo. .o...... ..ooooo. ........ ........ ..o..... ...o.... ...o.... ..oooo.. .oo..oo. .o....o. .o....o. .oo..oo. .oooooo. .o...... .o...... .oo...o. ..ooooo. ........ ........ $89 .o....o. ........ ........ ........ ........ ........ ........ ........ .oo..oo. .oo..oo. ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ $8A ..ooooo. .o..o... .o..o... .oooooo. .o..o... .o..o... .o..ooo. ........ ...ooo.. .oooooo. .o..o... .o..o... .o..o... .o..o... .oooooo. .oooooo. .o..o... .o..o... .o..o... .o..o... .o..ooo. .o..ooo. ........ ........ $8B ......o. ..oooo.. .o...oo. .o..o.o. .o.o..o. .oo...o. ..oooo.. .o...... .......o ......o. ..oooo.. .oooooo. .o...oo. .o..o.o. .o..o.o. .o..o.o. .o.o..o. .o.o..o. .o.o..o. .oo...o. .oooooo. ..oooo.. .o...... o....... $8C ...o.... ........ ..ooo... .o...o.. .ooooo.. .o...o.. .o...o.. ........ ...oo... ...oo... ........ ...oo... ..oooo.. .oo..oo. .o....o. .o....o. .oooooo. .oooooo. .o....o. .o....o. .o....o. .o....o. ........ ........ $8D ........ .ooooo.. ...o..o. ..oo..o. .o.oooo. .o.o.... ..ooooo. ........ ........ ........ .oooo... .ooooo.. ...o..o. ...o..o. ..oo..o. ..oo..o. .o.oooo. .o.ooo.. .o.o.... .o.o.... ..oooo.. ..ooooo. ........ ........ $8E ........ .....o.. ..ooo... .o..oo.. .o.o.o.. .oo..o.. ..ooo... .o...... ........ ........ .....o.. .....o.. ..ooo... ..ooo... .o..oo.. .o..oo.. .o.o.o.. .o.o.o.. .oo..o.. .oo..o.. ..ooo... ..ooo... .o...... .o...... $8F ....o... ........ ..oooo.. ......o. ..ooooo. .o....o. ..ooooo. ........ ....o... ...o.o.. ....o... ........ ..oooo.. .oooooo. ......o. ......o. ..ooooo. .oooooo. .o....o. .o....o. .oooooo. ..ooooo. ........ ........ $90 ........ ...o.... ........ ...o.... ...o.... ..ooo... ..ooo... ...o.... ........ ...o.... ..o.o... ...o.... ........ ...o.... ...o.... ...o.... ...o.... ...o.... ...o.... ..ooo... ..ooo... ..ooo... ...o.... ........ $91 ...o.o.. ..o.o... ........ .o...o.. .oo..o.. .o.o.o.. .o..oo.. .o...o.. ..oo.oo. .oo.oo.. ........ .o...o.. .o...o.. .oo..o.. .oo..o.. .oo..o.. .o.o.o.. .o.o.o.. .o..oo.. .o..oo.. .o...o.. .o...o.. ........ ........ $92 ...o.... ........ ...o.... ...o.... ..o..... .o...... .o...o.. ..ooo... ........ ........ ...o.... ..ooo... ...o.... ........ ...o.... ...o.... ...o.... ...o.... ..o..... .o...... .o...o.. .o...o.. ..ooo... ........ $93 ...o.o.. ..o.o... ........ .ooooo.. .o....o. .o....o. .o....o. ........ ........ ........ ..oo..o. .o..oo.. ........ ........ .o...... .ooooo.. .o....o. .o....o. .o....o. .o....o. .o....o. .o....o. ........ ........ $94 ....o... .....o.. ..oooo.. .o....o. .o....o. .o....o. ..oooo.. ........ ...o.... ....o... .....o.. ........ ..oooo.. .oooooo. .o....o. .o....o. .o....o. .o....o. .o....o. .o....o. .o....o. .oooooo. ..oooo.. ........ ........ $95 ..o..... ...o.... ........ ..oo.... ...o.... ...o.... ..ooo... ........ ..o..... ...o.... ....o... ........ ...o.... ...o.... ..oo.... ..oo.... ...o.... ...o.... ...o.... ...o.... ..ooo... .ooooo.. ........ ........ $96 .o...o.. ........ ..ooo... .o...o.. .ooooo.. .o...o.. .o...o.. ........ .oo..oo. .oo..oo. ........ ...oo... ..oooo.. .oo..oo. .o....o. .o....o. .oooooo. .oooooo. .o....o. .o....o. .o....o. .o....o. ........ ........ $97 .o....o. ..oooo.. .o....o. .o....o. .o....o. .o....o. ..oooo.. ........ .oo..oo. .oo..oo. ........ ..oooo.. .oooooo. .o....o. .o....o. .o....o. .o....o. .o....o. .o....o. .o....o. .oooooo. ..oooo.. ........ ........ $98 .o....o. ........ .o....o. .o....o. .o....o. .o....o. ..oooo.. ........ .oo..oo. .oo..oo. ........ .o....o. .o....o. .o....o. .o....o. .o....o. .o....o. .o....o. .o....o. .o....o. .oo..oo. ..oooo.. ........ ........ $99 .o....o. ........ ..oooo.. ......o. ..ooooo. .o....o. ..ooooo. ........ ........ .oo..oo. .oo..oo. ........ ..oooo.. .oooooo. ......o. ......o. ..ooooo. .oooooo. .o....o. .o....o. .oooooo. ..ooooo. ........ ........ $9A ..o..o.. ........ ..oooo.. .o....o. .o....o. .o....o. ..oooo.. ........ ........ .oo..oo. .oo..oo. ........ ..oooo.. .oooooo. .o....o. .o....o. .o....o. .o....o. .o....o. .o....o. .o....o. .oooooo. ..oooo.. ........ ........ $9B ..o..o.. ........ .o....o. .o....o. .o....o. .o...oo. ..ooo.o. ........ ........ .oo..oo. .oo..oo. ........ ........ .o....o. .o....o. .o....o. .o....o. .o...oo. .o...oo. .o...oo. .oooooo. ..ooo.o. ........ ........ $9C .ooooo.. .o....o. .o....o. .ooooo.. .o....o. .o....o. .o.ooo.. .o...... ..ooo... .ooooo.. .o....o. .o....o. .o....o. .o....o. .ooooo.. .ooooo.. .o....o. .o....o. .o....o. .o....o. .o...oo. .o.ooo.. .o...... .o...... `abcd/* * mkctab.c * Generate a lookup table for color double-hires */ #include #include #include #include /* Palette settings 0000 black 0001 magenta 0010 brown 0011 orange 0100 dark green 0101 gray 1 0110 green 0111 yellow 1000 dark blue 1001 purple 1010 gray 2 1011 pink 1100 medium blue 1101 light blue 1110 aqua 1111 white */ byte tables[256][4]; byte pixels[8]; byte planes[4]; int genflatpixels(byte val) { int i; /* solid pixels */ if ((val & 0x0F) == ((val & 0xF0) >> 4)) { for (i = 0; i < 8; i++) pixels[i] = val & 0x0F; return; } /* not-so-solid pixels */ for (i = 0; i < 4; i++) { if (val & (1 << i)) pixels[i] = val & 0x0F; else pixels[i] = 0; } for (i = 4; i < 8; i++) { if (val & (1 << i)) pixels[i] = ((val & 0xF0) >> 4); else pixels[i] = 0; } /* "On" pixels next to white */ if ((val & 0x0F) == 0x0F) { /* Check higher bits */ for (i = 4; i < 8; i++) { if (!(val & (1 << i))) break; pixels[i] = 0x0F; /* set it to white!! */ } } else if ((val & 0xF0) == 0xF0) { for (i = 3; i > 0; i--) { if (!(val & (1 << i))) break; pixels[i] = 0x0F; /* set it to white!! */ } } } int genplanes(void) { int i; for (i = 0; i < 4; i++) { int j; byte bit; planes[i] = 0; for (j = 0; j < 8; j++) { bit = (pixels[j] & (1 << i)) >> i; planes[i] |= (bit << j); } } } int main(int argc, char *argv[]) { int i,j; for (i = 0; i < 256; i++) { genflatpixels(i); genplanes(); for (j = 0; j < 4; j++) tables[i][j] = planes[j]; } for (j = 0; j < 4; j++) { for (i = 0; i < 256; i++) { if (!(i % 8)) printf(" db 0%02Xh",tables[i][j]); else printf(",0%02Xh",tables[i][j]); if ((i % 8) == 7) printf("\n"); } } } fgh#include #include #include #include /* A7 = (@A & 0xFE) << 0 B7 = (@B & 0xFE) >> 7 A6 = (@A & 0xFE) << 1 B6 = (@B & 0xFE) >> 6 A5 = (@A & 0xFE) << 2 B5 = (@B & 0xFE) >> 5 A4 = (@A & 0xFE) << 3 B4 = (@B & 0xFE) >> 4 A3 = (@A & 0xFE) << 4 B3 = (@B & 0xFE) >> 3 A2 = (@A & 0xFE) << 5 B2 = (@B & 0xFE) >> 2 A1 = (@A & 0xFE) << 6 B1 = (@B & 0xFE) >> 1 */ byte revbits(byte a) { int i; byte t; byte bitval; t = 0; for (i = 0; i < 8; i++) { bitval = (a >> i) & 0x1; t = t | (bitval << (7-i)); } return t; } int main(int argc, char *argv[]) { int i,j; byte val; /* Do the 'A' tables */ for (i = 1; i < 8; i ++) { printf("T_A%d\n",i); for (j = 0; j < 256; j++) { if (!(j % 16)) printf(" db "); val = (revbits(j) & 0xFE) << (7-i); printf("0%02Xh",val & 0xFF); if ((j%16) == 15) printf("\n"); else printf(","); } } for (i = 1; i < 8; i ++) { printf("T_B%d\n",i); for (j = 0; j < 256; j++) { if (!(j % 16)) printf(" db "); val = (revbits(j) & 0xFE) >> (i); printf("0%02Xh",(val & 0xFF)); if ((j%16) == 15) printf("\n"); else printf(","); } } } $00: $09 Command Code $01: $AA Value of CBR Register $02: $BB Value of CBAR register $03: $CC Value of BBR register $04: $0ABBCC Address in Z180 memory to CALL to. ld a,(_command_area+4) ld (_jmpto+1),a ld a,(_command_area+5) ld (_jmpto+2),a ld a,(_command_area+2) z180_out a,(CBAR) ld a,(_command_area+3) z180_out a,(BBR) ld a,(_command_area+1) z180_out a,(CBR) _jmpto call $0000 z180_out 0F2h,(CBAR) z180_out 00h,(BBR) z180_out etc ret LIBv' '$LVGAk-5) jMAKEFILE5: j'MODES.H 5: j%NOTES^5 jOLDj(SS.MODES56j%VGA.H5 "j(VGALIB.C 5( j(VGALIB.H5& j*VGALOW.ASM25 3j*VGALOW.MAC5 jlmnopqrstuvwxyz{|}~,>LIBRARY$VGALIB.AVGALOW.A VGALOW.ROOT( )l()(95#'@,K0#V`_$jJ$t]!o 5"%s''(k) %%%*8%>9NUW `t)%%% WaitHSDone WaitHSOffWaitHSOn WritePage _ClearScreen _FalseRead _GetStatus _GetVGAReg_RunCode _ScreenOff _ScreenOn _ScrollScreen _SetBorder_SetMode _SetPalette_SetPaletteEntry _SetShadow _SetUserMode _SetVGAReg _UploadData _WriteByte _WriteCmd _WriteData longdelaymodes rgb_mode_5B rgb_mode_70 scanlineWidthstrecvgaCopyPixelMapvgaErr vgaSetModevgaSetScanlineWidth vgaStartupvgaUploadVideoData vga_mode_5C vga_mode_70~ARRAYS~GLOBALS8q0Evgalib vgaStartup;8 [ںstrecstrec" _GetStatush)/7^ ں+strecstrec "memcpy hd^  +;ik0JvgalibvgaCopyPixelMap.;8 [i")Hh&H&8Hh scanlineWidth9?MvgaErr YZ`qvgaErr i"~UDIV2"~UMUL2$i"H"H  hh&Hi"H"~MUL4H"~MUL4"~MUL4he He   hh& HH"~MUL4"~MUL4he He   hh,H"~UMUL4 @H scanlineWidthL"~UMUL4"hchc hhHt"~UMUL4&H&8"~UMUL4hhi"H8I scanlineWidth H8I &  >ں  "vgaUploadVideoData hd&H&8XY_hHhhں  "vgaUploadVideoData h scanlineWidth&Hhe He hhi""~UMUL2e H  hhc('+;i&kX0Evgalib vgaSetMode;8  [8ںH`H"_SetMode hd "~MUL2MHmodesmodeshchchqw "~MUL2HmodesmodeshchchH8I ~ "~MUL2HmodesmodeshchchvgaErrstrec ))3 "~MUL2%Hmodesmodeshchch)LITbvgaErr "~MUL2rHmodesmodes)hchchHHhh ںHH"_SetMode h0 ں "~MUL2HmodesmodeshchchHH" _SetUserModehںHH"_SetModeh "~MUL2CHmodesmodeshchch)jIrvgaErr "~MUL2Hmodesmodes)hchch HHhh ںHH"_SetModeh "~MUL2Hmodesmodeshchch  scanlineWidth ں "~MUL25Hmodesmodeshchch HH" _SetUserModehںHH"_SetModeh "~MUL2Hmodesmodeshchch  scanlineWidthd  +;ikz0NvgalibvgaSetScanlineWidthH; [ scanlineWidth+;ike0MvgalibvgaUploadVideoDataC;8 [h h " he He h h&$hh GKLhhTyں&$" H" _UploadData hM" e e hh+28h H hhں&$H" _UploadDatahں"~UMUL4'heHe 8hHH" _UploadData hMں&$" H" _UploadDatahdR&%+;i$kk@0C ~GLOBALS scanlineWidthNvgaErrNe@0B ~ARRAYSstrecN+ rgb_mode_70Noc) sOV]@F(@   vga_mode_70Noc! `OPT(@  modesN@(P@S[ rgb_mode_5B\ vga_mode_5Cap vga_mode_70 rgb_mode_70 rgb_mode_5BNoc) sOV]@FP@  Ȁ vga_mode_5CNoß >@P@  'H0G _ClearScreen ; [x  _WriteCmd WaitHSOn  _WriteData  _WriteData  _WriteData  _WriteData  _WriteData  _WriteData  _WriteData  WaitHSOff  WaitHSDone(  +;i k>0C _RunCode ; [x  _WriteCmd WaitHSOn  _WriteData  _WriteData  _WriteData  _WriteData  _WriteData  WaitHSOff  WaitHSDone(  +;ikNR0H _ScrollScreen ; [x  _WriteCmd WaitHSOn  _WriteData  _WriteData  _WriteData  _WriteData  _WriteData  _WriteData  _WriteData  _WriteData  _WriteData(  WaitHSOff  WaitHSDone +;i k/0C _SetMode ; [x  _WriteCmd WaitHSOn  _WriteData  _WriteData  WaitHSOff  WaitHSDone(+;ik'0E _SetShadow ; [x  _WriteCmd WaitHSOn  _WriteData  WaitHSOff(+;ik60K _SetPaletteEntry ; [x  _WriteCmd WaitHSOn  _WriteData  _WriteData  _WriteData  _WriteData  WaitHSOff(+;ikE0F _SetPalette ; [x  _WriteCmd WaitHSOn  _WriteCmd  _WriteCmd  _WriteCmd  WaitHSOff WaitHSOn  _WriteData  WaitHSOff(+;ik20G _SetUserMode ; [x  _WriteCmd WaitHSOnT  WaitHSOff(+;ik'0E _SetBorder ; [x  _WriteCmd WaitHSOn  _WriteCmd  WaitHSOff(+;ik@0E _SetVGAReg ; [x  _WriteCmd WaitHSOn  _WriteCmd  _WriteCmd  _WriteCmd  _WriteCmd  _WriteCmd  _WriteCmd  WaitHSOff(  +;ikS0E _GetVGAReg;8 [x  _WriteCmd WaitHSOn  _WriteCmd  _WriteCmd  _WriteCmd  _WriteCmd  _WriteCmd  WaitHSOff WaitHSOn ௲  WaitHSOff(  +;ikg0D _ScreenOn ; [x  _WriteCmd (+;ike0E _ScreenOff; [  _WriteCmd+;ik 0F _UploadData;8 [dx  _WriteCmd WaitHSOn  _WriteData  _WriteData  _WriteData  _WriteData  _WriteData  _WriteData  _WriteData  _WriteData  _WriteData  _WriteData  WaitHSOff ) WaitHSOn  WritePage  WaitHSOff WaitHSOn))d  WritePage)d   WaitHSOff(+;ikP 0E _FalseRead 00`Z0E _WriteByte0ϸ0`O 0D _WriteCmd `P 0E _WriteData `S0C WaitHSOn ϸ `X0E WaitHSDone ɥɦ `T0D WaitHSOff ϸ `M0D longdelay`0D WritePageߋ H [  "$&(*,.02468:<>@BDFHJLNPRTVXZ\^`bdfhjlnprtvxz|~ѱ+`0E _GetStatus;8 [x    c௲  GSȷVȷGȷA믲ઇ   (  +;i k# 2/orcacdefs/vga.h: vga.h cp vga.h 2/orcacdefs 2/orcacdefs/vgalib.h: vgalib.h cp vgalib.h 2/orcacdefs o/vgalow.root: vgalow.asm vgalow.mac compile vgalow.asm keep=o/vgalow o/vgalib.a: vgalib.c vgalib.h modes.h compile vgalib.c keep=o/vgalib lvga: o/vgalow.root o/vgalib.a rm -f lvga makelib lvga +o/vgalow.root +o/vgalow.a makelib lvga +o/vgalib.a cp lvga 2/ vga_mode_rec vga_mode_5C = { 0xEF, /* misc out reg */ 0x01, /* ; clocking mode reg */ 0xA0, /* ; feature ctl */ 0x0F,0x00,0x0E, /* Sequencer regs */ 0xC3,0x9F,0xA1,0x85,0xA7,0x1F,0x0B,0x3E, /*; Sequencer regs */ 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, /* ; Sequencer regs */ 0xEA,0x8C,0xDF,0x50,0x00,0xE7,0x04,0xC3, /* ; Sequencer regs */ 0xFF, 0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0F, /* ; Graphics Regs */ 0xFF, 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, /* ; $00 - $07 Attribute regs*/ 0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F, /* ; $08 - $0F*/ 0x01,0x00,0x0F,0x00,0x00, /* ; $10 - $14*/ 0x05,0x10,0x07,0x00,0x0F, /* ; $02 - $06 Extended regs*/ 0xC8,0x00,0x00,0x00,0x0F, /* ; $13..$15,$17, & $19*/ 0x05,0x04,0x0C,0x00, /* ; $30..$22, $25*/ 0x00,0x00,0x00,0x00,0x00,0x00 /* ; $30..$35 */ }; /* Here begin some Apple II-specific modes */ /* 320x200x32768 */ vga_mode_rec vga_mode_70 = { 0x63, 0x21, 0xA0, 0x0F,0x00,0x0A, 0x60,0x4F,0x50,0x83,0x54,0x80,0xBF,0x1F, 0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00, 0x9F,0x81,0x8F,0x28,0x00,0x96,0xB9,0xC3, 0xFF, 0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0F, 0xFF, 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, 0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F, 0x01,0x00,0x0F,0x00,0x00, 0x05,0x10,0x07,0x00,0x00, 0xC8,0x00,0x00,0x00,0x0F, 0x05,0x04,0x0C,0x00, 0x00,0x00,0x00,0x00,0x00 }; vga_mode_rec rgb_mode_70 = { 0x63, /* misc out reg */ 0x29, /* ; clocking mode reg */ 0xA1, /* ; feature ctl */ 0x0F,0x00,0x0A, /* Sequencer regs */ 0x73,0x4F,0x56,0x91,0x5D,0x8B,0x06,0x11, /*; Sequencer regs */ 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, /* ; Sequencer regs */ 0xDE,0x46,0xC7,0x28,0x00,0xD5,0xD8,0xC3, /* ; Sequencer regs */ 0xFF, 0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0F, /* ; Graphics Regs */ 0xFF, 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, /* ; $00 - $07 Attribute regs*/ 0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F, /* ; $08 - $0F*/ 0x01,0x00,0x0F,0x00,0x00, /* ; $10 - $14*/ 0x05,0x10,0x07,0x00,0x0C, /* ; $02 - $06 Extended regs*/ 0xC8,0x00,0x00,0x00,0x0F, /* ; $13..$15,$17, & $19*/ 0x05,0x04,0x08,0x00, /* ; $30..$22, $25*/ 0x00,0x00,0x00,0x00,0x00,0x00 /* ; $30..$35 */ }; vga_mode_rec rgb_mode_5B = { 0x63, /* misc out reg */ 0x29, /* ; clocking mode reg */ 0xA0, /* ; feature ctl */ 0x0F,0x00,0x0A, /* Sequencer regs */ 0x73,0x4F,0x56,0x91,0x5D,0x8B,0x06,0x11, /*; Sequencer regs */ 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, /* ; Sequencer regs */ 0xDE,0x46,0xC7,0x50,0x00,0xD5,0xD8,0xC3, /* ; Sequencer regs */ 0xFF, 0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0F, /* ; Graphics Regs */ 0xFF, 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, /* ; $00 - $07 Attribute regs*/ 0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F, /* ; $08 - $0F*/ 0x01,0x00,0x0F,0x00,0x00, /* ; $10 - $14*/ 0x05,0x10,0x07,0x00,0x0C, /* ; $02 - $06 Extended regs*/ 0xC8,0x80,0x00,0x00,0x0F, /* ; $13..$15,$17, & $19*/ 0x05,0x05,0x08,0x00, /* ; $30..$22, $25*/ 0x00,0x00,0x00,0x00,0x00,0x00 /* ; $30..$35 */ }; *********************************************************** 8/23/95 vgalib.c vgaSetMode now sets an internal variable with the width of a display scanline in bytes. vgaCopyPixelMap now uses this to do the right thing. Previously, the library assumed a 640-pixel wide display. Added a new library call, "vgaSetScanlineWidth". This call can be used to set the library's scanline width variable in the event a user mode is set (in which case the scanline width may be invalid). 8/16/95 vgalow.asm Fixed a bug that would cause _UploadData to transfer an entire 64K chunk in the event there was a single byte left to transfer (thanks to James Smith for finding this and pointing to a fix). 7/14/95 vgalib.c Added modes 0x5B, 0x70 for AppleColor RGB. 7/10/95 vgalib.c Fixed an incorrect memcpy that was trashing the lib's local copy of the vga status record. 7/7/95 Modified vga.h and vgalib.h made #define names of error codes consistent vgalib.c Now uses the term 'emulate' instead of 'shadow' to refer to emulating Apple II video modes. SS.Modes Added this List of supported video mode numbers OLDv' j'(VGALIB.C 5 /* * vgalib.c * higher level functions for manipulating the GS/VGA card */ static int vgaErr = 0; typedef struct modeDescriptor { int modeNum; /* VGA BIOS display mode number */ int modeFlag; /* 0 = text, 1 = graphics */ int displayWidth; /* # of horz pixels (or characters) */ int displayHeight; /* # of vert pixels (or characters) */ int colorDepth; /* # of colors in palette */ } modeDescriptor; modeDescriptor curMode = {0,0,0,0}; modeDescriptor modes = { { 0x00, 0, 40, 25, 16 }, { 0x02, 0, 80, 25, 16 }, { 0x51, 0, 132, 43, 16 }, { 0x4F, 0, 132, 60, 16 }, { 0x53, 1, 640, 480, 256 }, { 0x54, 1, 800, 600, 256 }, { 0x56, 1, 1024, 768, 256 }, { 0x61, 1, 640, 400, 256 }}; typedef struct vgaPixelMap { word width; word height; word colorDepth; byte *pMap; } vgaPixelMap; typedef struct vgaPaletteEntry { byte r; byte g; byte b; }; typedef vgaPaletteEntry vgaPalette[256]; int vgaStartup(void) { } int vgaLastError(void) { return vgaErr; } int __set_err(word errnum) { vgaErr = errnum; return -1; } int vgaCopyPixelMap(word x,word y,word rows,word cols,vgaPixelMap *pMap) { unsigned long leng; unsigned long offset; word cury; /* just preliminary */ if (cols > curMode.displayWidth) return __set_err(ERR_invalid_param); if (rows > curMode.displayHeight) return __set_err(ERR_invalid_param); #if 0 /* Not quite right yet, so don't compile in */ /* perform basic clipping */ if (x + cols > curMode.displayWidth) cols = curMode.displayWidth - x; if (y + rows > curMode.displayHeight) rows = curMode.displayHeight - y; #endif if ((x == 0) && (cols == curMode.displayWidth) && (pMap->width == curMode.displayWidth)) { /* we can simplify this to one call */ leng = rows * cols; offset = y * curMode.displayWidth; _UploadData(FL_VGA,offset,leng,addr); return 0; } offset = y * curMode.displayWidth + x; for (cury = y; rows > 0; rows ++) { leng = cols; _UploadData(FL_VGA,offset,leng,addr); offset += curMode.displayWidth; addr += pMap->width; } } int vgaSetPaletteEntry(int num, byte r, byte g, byte b) { vgaPaletteEntry p; p.r = r; p.g = g; p.b = b; _SetPaletteEntry(num,p); } Supported Second Sight Video Modes This is the list of supported Second Sight video modes (as of the next general ROM release - the 32K color modes weren't supported by the first EPROM Rev.) This table assumes you're using the VGALib 'vgaSetMode' command, since some of these mode tables are only in the library, and not in ROM. 0x01 40x25 Text VGA, RGB 0x03 80x25 Text VGA, RGB 0x13 320x200x256 VGA, RGB 0x53 640x480x256 VGA 0x5C 640x480x32K VGA 0x61 640x400x256 VGA, RGB 0x70 320x200x32K VGA (The following modes are on supported on VGA and RGV monitors) 0xFA 560x192x16 (DHires) 0xFB 280x192x16 (Hires) 0xFC 40x24 0xFD 80x24 0xFE 640x200 (SHR, LoRes) /* * VGA.h * * GS/VGA */ #ifndef __VGA_H__ #define __VGA_H__ /* Video Modes built-into the card */ #define VM_640x480x256 0x53 /* The 'GS Emulation' video mode - 640x200 w/ scanline doubling */ #define VM_640x200x256 0xFE /* scanline doubled on VGA */ #define VM_640x400x256 0x61 /* on an ACRGB, 640x400 modes are */ #define VM_USER 0xFF /* User-defined video mode */ /* Emulation flag passed to _SetMode command */ #define FL_EMULATE 0x00 #define FL_NOEMULATE 0x01 #define FL_CODE 0x00 #define FL_DATA 0x01 struct rgb_32 { unsigned char r; unsigned char g; unsigned char b; char x; }; #define IS_VGA 0x10 typedef struct vga_status_rec { char id_str[5]; /* Contains ASCII "GSVGA" */ unsigned char size_rec; /* number of bytes of record data that follow */ unsigned char version; /* hi nibble is major revsn, lo nibble is minor revsn */ unsigned char shadow_status; /* 0 = shadowing, !0 = not shadowing */ unsigned char vga_mode; /* if not shadowing, this is the video mode we're in */ unsigned char video_ram; /* Video RAM installed - 0 = 512K, 1 = 1MB */ unsigned char monitor_type; /* 0x10 = VGA monitor, 0x00 = IIGS monitor */ unsigned char bits; /* 0 = 8-bit card, 1 = 24-bit card */ unsigned char expansion[31]; } vga_status_rec; typedef struct vga_mode_rec { unsigned char misc; unsigned char clockMode; unsigned char featureCtl; unsigned char seq02, seq03, seq04; unsigned char crt_regs[0x19]; unsigned char graph_regs[0x09]; unsigned char attr_regs[0x15]; unsigned char ext_regs[20]; /* NOT linearly mapped - see examples */ unsigned char unused[30]; } vga_mode_rec; int _GetStatus(vga_status_rec *); void _SetMode(int,int); void _SetPalette(void *palette); void _SetPaletteEntry(int, struct rgb_32); void _UploadData(int,void *,unsigned long, void *); void _ClearScreen(int,void *,unsigned long); void _ScrollScreen(void *,void *, unsigned long); void _ScreenOff(void); void _ScreenOn(void); void _SetBorder(int); void _SetVGAReg(int,int,int,int); int _GetVGAReg(int,int,int); void _SetUserMode(vga_mode_rec *); void _SetStatus(int); void _RunCode(int,int,int,int); #endif /* __VGA_H__ */ /* * vgalib.c * Copyright 1995, Sequential Systems Inc. * * Implementation in C of VGA Library Routines */ #include #include #include #include #include #include #include "vgalib.h" #include "modes.h" segment "vgalib"; #pragma noroot /*#pragma databank 1*/ /*#pragma optimize -1*/ int vgaErr = 0; static vga_status_rec strec; static scanlineWidth = 0; int vgaStartup(vga_status_rec *vr) { if (_GetStatus(&strec) == -1) { return -1; } memcpy(vr,&strec,sizeof(vga_status_rec)); return 0; } int vgaCopyPixelMap(int x, int y, LocInfo2 *loc, Rect *mapRect) { byte *lsrc; longword vsrc; word pixdepth = loc->info.li2.pixDepth; int width = mapRect->h2 - mapRect->h1; /* width of rect in pixels */ longword vnum; word py; if (scanlineWidth == 0) { vgaErr = vgaINCOMPATIBLE_PIXMAPS; return -1; } if (pixdepth < 8) { vgaErr = vgaINCOMPATIBLE_PIXMAPS; return -1; } else pixdepth = (pixdepth + 7) / 8; /* round up to next byte width */ width *= pixdepth; /* if (loc->portSCB != 0x5A5A) { vgaErr = VGA_INCOMPATIBLE_PIXMAPS; return -1; } */ /* Locate start of image */ lsrc = ((byte *) loc->info.li2.ptrToPixImage); /* Locate appropriate scanline */ lsrc += ((long)mapRect->v1 * loc->info.li2.width * pixdepth); /* Locate appropriate pixel */ lsrc += ((long)mapRect->h1 * pixdepth); #define BOTTOM_512K 524288l vsrc = (longword) y * scanlineWidth + (longword) x * pixdepth; vnum = (longword) pixdepth * width * (mapRect->v2 - mapRect->v1); /* Check to see if their image width is the same as the display width */ if ((loc->info.li2.width == width) && (width == scanlineWidth) && (mapRect->h1 == 0) && (x == 0)) { vgaUploadVideoData((void*)vsrc,vnum,(void *)lsrc); return 0; } else { for (py = 0; py < (mapRect->v2 - mapRect->v1); py++) { vnum = width; vgaUploadVideoData((void *)vsrc, (longword)vnum,(void *)lsrc); vsrc += scanlineWidth; /* next line of VGA screen */ lsrc += loc->info.li2.width; } } } /* bit 0 = VGA compatible bit 1 = RGB compatible bit 2 = mode table on card */ #define M_VGA 1 #define M_RGB 2 typedef struct modelist { int modeNum; int flags; vga_mode_rec *vga_mode; /* if M_VGA and NULL, mode on board */ vga_mode_rec *rgb_mode; /* if M_RGB and NULL, mode on board */ int scanWidth; /* width of a scanline in bytes */ } modelist; /* { 0x50, M_VGA, NULL, NULL, }, */ modelist modes[] = { /* 40x25 16 color text */ { 0x01, M_VGA | M_RGB, NULL, NULL, 40 }, /* 80x25 16 color text */ { 0x03, M_VGA | M_RGB, NULL, NULL, 80 }, /* 320x200x256 */ { 0x13, M_VGA | M_RGB, NULL, NULL, 320 }, /* 640x480x256 */ { 0x53, M_VGA, NULL, NULL, 640 }, /* 800x600x256 */ /*{ 0x54, M_VGA, &vga_mode_54, NULL, 800 }, /* 640x400x32K */ { 0x5B, M_RGB, NULL, &rgb_mode_5B, 1280}, /* 640x480x32K */ { 0x5C, M_VGA, &vga_mode_5C, NULL, 1280}, /* 640x400x256 */ { 0x61, M_VGA | M_RGB, NULL, NULL, 640}, /* 320x200x32K */ { 0x70, M_VGA | M_RGB, &vga_mode_70, &rgb_mode_70, 640}, { 0x00, 0, NULL, NULL, 0 } }; int vgaSetMode(int vgaMode, int emulFlag) { int i; if (emulFlag == FL_EMULATE) { _SetMode(0x60,FL_EMULATE); return 0; } /* Locate the entry for the requested video mode */ i = 0; while (modes[i].modeNum != 0) { if (vgaMode == modes[i].modeNum) break; i++; } if (modes[i].modeNum == 0) { vgaErr = vgaINVALID_MODE_NUM; return -1; } if (strec.monitor_type & IS_VGA) { if (!(modes[i].flags & M_VGA)) { vgaErr = vgaUNSUPPORTED_MODE; return -1; } if (modes[i].vga_mode == NULL) _SetMode(vgaMode,emulFlag); else { _SetUserMode(modes[i].vga_mode); _SetMode(0xFF,emulFlag); } } else { if (!(modes[i].flags & M_RGB)) { vgaErr = vgaUNSUPPORTED_MODE; return -1; } if (modes[i].rgb_mode == NULL) { _SetMode(vgaMode,emulFlag); scanlineWidth = modes[i].scanWidth; } else { _SetUserMode(modes[i].rgb_mode); _SetMode(0xFF,emulFlag); scanlineWidth = modes[i].scanWidth; } } return 0; } void vgaSetScanlineWidth ( int sWidth ) { scanlineWidth = sWidth; } /* Breaks a data transfer request into two pieces if necessary */ int vgaUploadVideoData(void *dest_adr, unsigned long num, void *gs_adr) { unsigned long d = (unsigned long) dest_adr; unsigned long dd = d + num; unsigned long lower_len; byte *g = gs_adr; if (d > BOTTOM_512K) { _UploadData(FL_DATA, dest_adr, num, gs_adr); } else if (d+num > BOTTOM_512K) { lower_len = BOTTOM_512K - d; _UploadData(FL_DATA, dest_adr, lower_len, gs_adr); _UploadData(FL_DATA, (void *)BOTTOM_512K, dd - BOTTOM_512K, g + lower_len); } else { _UploadData(FL_DATA, dest_adr, num, gs_adr); } return 0; } #include #include typedef struct LocInfo2 { word portSCB; /* $5A5A to indicate a LocInfo2 record */ union { struct { Pointer ptrToPixImage; Word width; Rect boundsRect; } li1; struct { Byte flags; Pointer ptrToPixImage; Word width; Byte pixDepth; Rect boundsRect; } li2; } info; } LocInfo2; #define vgaINVALID_MODE_NUM 0x01 #define vgaUNSUPPORTED_MODE 0x02 #define vgaINCOMPATIBLE_PIXMAPS 0x03 /* Video Modes supported by VGALib. */ #define VM_640x400x32K 0x5B /* interlaced */ #define VM_640x480x32K 0x5C int vgaStartup( vga_status_rec * ); int vgaSetMode( int,int ); int vgaCopyPixelMap( int x, int y, LocInfo2 *loc, Rect *mapRect ); int vgaUploadVideoData( void *, unsigned long, void * ); void vgaSetScanlineWidth ( int ); * Low-level VGA Board Interface Routines * Copyright 1994, Sequential Systems * Written by Jawaid Bazyar * mcopy vgalow.mac case on WR_CMD gequ $E0C0B0 WR_DATA gequ $E0C0B1 RD_DATA gequ $E0C0B2 HANDSHAKE gequ $E0C0B8 VM_40x25 gequ $00 ; GS RGB compatible modes VM_80x25 gequ $02 VM_320x200 gequ $13 VM_640x400 gequ $61 VM_800x600 gequ $54 ; VGA/SVGA-only modes VM_1024x768 gequ $56 VM_132x60 gequ $4F VM_132x43 gequ $51 VM_640x480 gequ $53 SH_NONE gequ %00000000 SH_SHR gequ %00000001 SH_HIRES gequ %00000010 SH_TEXT gequ %00000100 SH_DBL_HIRES gequ %00001000 SH_TEXT_80 gequ %00010000 * Command byte codes CMD_Status gequ $00 CMD_SetMode gequ $01 CMD_UploadData gequ $02 CMD_ScrollScreen gequ $03 CMD_ScreenOff gequ $04 CMD_ScreenOn gequ $05 CMD_SetPalette gequ $06 CMD_SetPaletteEntry gequ $07 CMD_SetBorder gequ $08 CMD_RunCode gequ $09 CMD_ClearScreen gequ $0A CMD_SetShadow gequ $0B CMD_SetVGAReg gequ $0C CMD_GetVGAReg gequ $0D CMD_SetUserMode gequ $0E * Upload code/data flags FL_Z180 gequ $00 FL_VGA gequ $01 * Get VGA Status / Existence _GetStatus START retv equ 1 tptr equ retv+2 sub (4:status_rec),6 php sei lda WR_CMD ldx #$FFFF lp1 lda >HANDSHAKE cmp #$01 ; are they ready yet? beq gothshake dex bne lp1 long m lda #-1 sta RD_DATA ; dummy read lp2 lda >RD_DATA sta [RD_DATA tax sta [RD_DATA sta [WR_DATA iny iny cpy #84 bcc lp jsr WaitHSOff plp ret END _SetBorder START sub (2:color),0 php sei lda #CMD_SetBorder jsr _WriteCmd jsr WaitHSOn lda RD_DATA ; dummy read lda >RD_DATA sta WR_DATA iny iny cpy WR_DATA long m doneit jsr WaitHSOff plp ret END * Mega-low-level routines. Byte-wise I/O to/from the VGA card * takes byte to write in accumulator * does not return until the Z180 has modified the data status latch * The Z180 operates in three possible polled I/O data modes. * a) The Z180 has INT1 turned on. This is used for command block data. * each byte in a command block will interrupt the Z180. * b) The Z180 has INT1 turned off. This is used for large data uploads; * each byte in a data block will simply set the CTS1 pin on the Z180 * and the Z180 will know from reading the CTS1 pin that data is present * in the latch. * c) The Z180 will have a DMA transfer set up for large block transfers. * The IIGS simply stuffs data into WR_DATA as fast as possible, and * the Z180 goes SLAM SLAM SLAM. _FalseRead START sep #$30 longa off longi off lda >WR_CMD rep #$30 longa on longi on rts END _WriteByte START tax sep #$30 longa off longi off ; lda >HANDSHAKE tay txa sta >WR_DATA * this interfaces with the routine send_handshake in the Z180 code. * file interp_a.a. When the RDY support in the PAL is done, remove this * code and remove calls to send_handshake tya lp cmp >HANDSHAKE beq lp rep #$30 longa on longi on rts END _WriteCmd START short m sta >WR_CMD long m rts END _WriteData START short m sta >WR_DATA long m rts END WaitHSOn START lda #1 short m lp cmp >HANDSHAKE bne lp long m rts END WaitHSDone START short m lp lda >HANDSHAKE cmp #$A5 beq goner cmp #$A6 bne lp goner long m rts END WaitHSOff START lda #0 short m lp cmp >HANDSHAKE bne lp long m rts END longdelay START ldx #$100 lp dex bne lp rts END * A = source bank, X = starting offset in source bank WritePage START phb short m pha plb long m phd lda #$C000 tcd lda |$00,x sta 2,.d ldy &r ago .h .d aif &len<>4,.e ldx &r+2 ldy &r ago .h .e aif &len<>10,.g ldy #&r ldx #^&r ago .h .g mnote 'Not a valid return length',16 mexit .h aif &totallen=0,.i lda &worklen+2 sta &worklen+&totallen+2 lda &worklen+1 sta &worklen+&totallen+1 .i pld tsc clc adc #&worklen+&totallen tcs aif &len=0,.j tya .j rtl mend macro &l sub &parms,&work &l anop aif c:&work,.a lclc &work &work setc 0 .a gbla &totallen gbla &worklen &worklen seta &work &totallen seta 0 aif c:&parms=0,.e lclc &len lclc &p lcla &i &i seta c:&parms .b &p setc &parms(&i) &len amid &p,2,1 aif "&len"=":",.c &len amid &p,1,2 &p amid &p,4,l:&p-3 ago .d .c &len amid &p,1,1 &p amid &p,3,l:&p-2 .d &p equ &totallen+4+&work &totallen seta &totallen+&len &i seta &i-1 aif &i,^b .e tsc aif &work=0,.f sec sbc #&work tcs .f phd tcd mend macro &l long &a,&b lclb &i lclb &m &a amid &a,1,1 &m setb ("&a"="M").or.("&a"="m") &i setb ("&a"="I").or.("&a"="i") aif c:&b=0,.a &b amid &b,1,1 &m setb ("&b"="M").or.("&b"="m").or.&m &i setb ("&b"="I").or.("&b"="i").or.&i .a &l rep #&m*32+&i*16 aif .not.&m,.b longa on .b aif .not.&i,.c longi on .c mend macro &l short &a,&b lclb &i lclb &m &a amid &a,1,1 &m setb ("&a"="M").or.("&a"="m") &i setb ("&a"="I").or.("&a"="i") aif c:&b=0,.a &b amid &b,1,1 &m setb ("&b"="M").or.("&b"="m").or.&m &i setb ("&b"="I").or.("&b"="i").or.&i .a &l sep #&m*32+&i*16 aif .not.&m,.b longa off .b aif .not.&i,.c longi off .c mend MISCv' '*COLORMGR.H'53FUNKY.MODESLL{53 M280X192o5' M320X200o5 #M405M40X24o5M40X24.9Mo59M40X25.9Mo52M80X24.1o5$M8X65;MAKEFILE5ξ/* * QuickDraw III Color Manager * for GS/VGA Card * C Interface file */ /* Color Conversion */ /* Color2Index Finds the best available approximation to a given absolute color, using a simplified Octree method. Rather than taking the Macintosh approach of using a giant inverse lookup table, we will instead use an unweighted Octree to lookup colors. This not only improves memory usage, but speed of building the lookup table as well */ word Color2Index(rgbColor rgb); /* Grabs the rgb triplet value of the specified color index straight out of the linear palette */ rgbColor Index2Color(word index); /* finds the complement of an absolute color, by applying a 1's complement to each component in the triplet */ rgbColor InvertColor(rgbColor theColor); /* tells whether a given absolute color actually exists in the current color table. RealColor returns true if the given color exactly matches an existing palette entry */ int RealColor(rgbColor color); /* takes a ColorTable pointed to by myColors, and maps each RGB value into its nearest available match for the target table. These best matches are returned in the colorSpec.value fields of mycolors. Best matches are calculated with Color2Index. */ GetSubTable(CTabHandle myColors, CTabHandle targetTbl); FUNKY.MODESv' 'M108X25.20MQ5 M120X25.22MQ5% M132X25.25MQ5: M80X25.18MQ5M96X25.18MQ5 g)lls G-L(ף  g)ww G-L(ף  gG-L(ף  g)OWeG-L(ף  g)``jG-L(ף  0x43,0x27,0x28,0x88,0x35,0x1A,0x04,0x01, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xE4,0x38,0xC0,0x00,0x00,0xC0,0x06,0x00, g)4"%-@8 g)?'.3@:  db 067h ; misc out reg db 028h ; clocking mode reg db 001h ; feature ctl db 003h,000h,002h ; Sequencer regs db 03Ah,027h,031h,09Ah,032h,09Ah,006h,011h ; Sequencer regs db 000h,047h,008h,009h,000h,000h,000h,000h ; Sequencer regs db 0DAh,046h,0BFh,028h,01Fh,0D5h,0D8h,0A3h ; Sequencer regs db 0FFh db 000h,000h,000h,000h,000h,010h,00Eh,000h ; Graphics Regs db 0FFh db 000h,001h,002h,003h,004h,005h,006h,007h ; $00 - $07 Attribute regs db 008h,009h,00Ah,00Bh,00Ch,00Dh,00Eh,00Fh ; $08 - $0F db 00Ch,000h,00Fh,008h,000h ; $10 - $14 db 005h,010h,007h,000h,005h ; $02 - $06 Extended regs db 0C8h,000h,000h,000h,00Fh ; $13..$15,$17, & $19 db 001h,000h,008h,000h ; $30..$22, $25 db 000h,000h,000h,000h,000h,000h ; $30..$35 g(:'12G F(أ  c)B'15:G F(أ c)B'15:GF(أ c 3'*-GL(ɣ  0xEB, /* misc out register */ 0x01, /* clocking mode register */ 0xF0, /* feature control */ /* Sequencer Registers */ 0x0F,0x00,0x0E, /* 02 - 04 */ /* CRT Registers */ 0x62,0x4E,0x50,0x85,0x54,0x80,0x0B,0x3E, /* 00 - 07 */ 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, /* 08 - 0F */ 0xEA,0x8C,0xDF,0x78,0x00,0xE7,0x04,0xC3, /* 10 - 17 */ 0xFF, /* Graphic Controller registers */ 0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0F, /* 00 - 07 */ 0xFF, /* Attribute controller regs */ 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, /* 00 - 07 */ 0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F, /* 08 - 0F */ 0x01,0x00,0x0F,0x00,0x00, /* 10 - 14 */ /* Oak Extended Registers */ 0x05,0x10,0x07,0x00,0x0A, /* 02..06 */ 0xC8,0x00,0x00,0x00,0x0F, /* 13..15, 17, and 19 */ 0x05,0x06,0x0C,0x00, /* 20..22, 25 */ 0x00,0x00,0x00,0x00,0x00,0x00 /* 30..35 */ # setreg: setreg.c vga.h cmpl setreg.c keep=setreg printreg: printreg.c cmpl printreg keep=printreg t1: t1.c cmpl t1.c keep=t1 MLLLLo5'MODES.S&H5(PRINTREG6h5 *PRINTREG.CG5 RGBXSAMPLE1.BINc55&SETREGd6i5(SETREG.C 5*SETTINGVGA5$SREGg-53 &SREG.C 52 "T1+S5 $T1.C #5 g)B''5@8  ** ** modes.a ** Video Mode Tables ** (From the Second Sight firmware) ** These are basically in "VGA Mode Number" format, ** referenced by numbers down in the lower part of the ** ROM. These register settings are copied from EPROM ** down to RAM for normal use. defseg modes_seg,start=0C000h seg modes_seg ********************************************************************** ** 40 column text 16, color mode 01h register definitions ** public vga_regs_01 vga_regs_01 db 67h ; misc out reg db 08h ; clocking mode reg db 00h ; feature ctrl * sequencer_regs db 03h,00h,02h ; 02h..04h * CRT_regs db 2dh,27h,28h,90h,2bh,0a0h,0bfh,1fh ; +00h..07h db 00h,4fh,2dh,0eh,00h,00h,00h,00h ; +08h..0fh db 9Ch,8eh,8fh,14h,1fh,96h,0b9h,0a3h ; +10h..17h db 0ffh ; +18h * graph_regs db 00h,00h,00h,00h,00h,10h,0eh,00h ; +00h..07h db 0ffh ; +08h * attr_regs db 00h,01h,02h,03h,04h,05h,06h,07h ; +00h..07h db 08h,09h,0ah,0bh,0ch,0dh,0eh,0fh ; +08h..0fh db 0ch,10h,0Fh,08h,00h ; +10h..14h * extended_regs db 05h,10h,07h,00h,01h ; 02h..06h db 0c8h,00h,00h,00h,0fh ; 13h..15h, 17h & 19h db 01h,00h,08h,00h ; 20h..22h, 25h db 00h,00h,00h,00h,00h,00h ; 30h..35h ** 80 column text 16, color mode 03h register definitions ** * Standard VGA 80 column text mode, modified slightly (CRT-$12) * for 24 lines of text instead of 25. (Need to adjust the vertical * position by a few pixels as well) public vga_regs_03 vga_regs_03 db 67h ; misc out reg db 00h ; clocking mode reg db 00h ; feature ctrl * sequencer_regs db 03h,00h,02h ; 02h..04h ; 02h..04h * CRT_regs db 5fh,4fh,50h,82h,55h,81h,0bfh,1fh ; 00h..07h db 00h,4fh,2dh,0eh,00h,00h,00h,00h ; 08h..0fh db 9Ch,8eh,8fh,28h,1fh,96h,0b9h,0a3h ; 10h..17h db 0ffh ; 18h * graph_regs db 00h,00h,00h,00h,00h,10h,0eh,00h ; 00h..07h db 0ffh ; 08h * attr_regs db 00h,01h,02h,03h,04h,05h,06h,07h ; 00h..07h db 08h,09h,0ah,0bh,0ch,0dh,0eh,0fh ; 08h..0fh db 0Ch,10h,0fh,08h,00h ; 10h..14h * extended_regs db 05h,10h,07h,00h,01h ; 02h..06h db 0c8h,00h,00h,00h,0fh ; 13h..15h, 17h & 19h db 01h,00h,08h,00h ; 20h..22h, 25h db 00h,00h,00h,00h,00h,00h ; 30h..35h ** 320x200, 256 color mode 13h register definitions ** public vga_regs_13 vga_regs_13 db 63h ; misc out reg db 01h ; clocking mode reg db 00h ; feature ctrl * sequencer_regs db 0fh,00h,0eh ; 02h..04h * CRT_regs db 5fh,4fh,50h,82h,54h,80h,0bfh,1fh ; 00h..07h db 00h,41h,00h,00h,00h,00h,00h,00h ; 08h..0fh db 9ch,8eh,8fh,28h,40h,96h,0b9h,0a3h ; 10h..17h db 0ffh ; 18h * graph_regs db 00h,00h,00h,00h,00h,40h,05h,0fh ; 00h..07h db 0ffh ; 08h * attr_regs db 00h,01h,02h,03h,04h,05h,06h,07h ; 00h..07h db 08h,09h,0ah,0bh,0ch,0dh,0eh,0fh ; 08h..0fh db 41h,00h,0fh,00h,00h ; 10h..14h * extended_regs db 05h,10h,07h,00h,00h ; 02h..06h db 0c8h,00h,00h,00h,0fh ; 13h..15h, 17h & 19h db 01h,04h,08h,00h ; 20h..22h, 25h db 00h,00h,00h,00h,00h,00h ; 30h..35h ** 640x480, 256 color mode 53h register definitions ** public vga_regs_53 vga_regs_53 db 0e3h ; misc out reg db 01h ; clocking mode reg db 00h ; feature ctrl * sequencer_regs db 0fh,00h,0eh ; 02h..04h * CRT_regs db 5fh,4fh,50h,82h,54h,80h,0bh,3eh ; 00h..07h db 00h,040h,00h,00h,00h,00h,00h,00h ; 08h..07h db 0eah,8ch,0dfh,28h,0,0e7h,04h,0c3h ; 10h..07h db 0ffh ; 18h * graph_regs db 00h,00h,00h,00h,00h,40h,05h,0fh ; 00h..07h db 0ffh ; 08h * attr_regs db 00h,01h,02h,03h,04h,05h,06h,07h ; 00h..07h db 08h,09h,0ah,0bh,0ch,0dh,0eh,0fh ; 08h..0fh db 01h,00h,0Fh,00h,00h ; 10h..14h * extended_regs db 05h,10h,07h,00h,00h ; 02h..06h db 0c8h,00h,00h,00h,0fh ; 13h..15h, 17h & 19h db 05h,04h,0ch,00h ; 20h..22h, 25h db 00h,00h,00h,00h,00h,00h ; 30h..35h public vga_regs_61 vga_regs_61 db 063h ; misc out reg db 21h ; clocking mode reg db 00h ; feature ctrl *sequencer_regs ; db 0fh,00h,0ah ; 02h..04h db 0fh,00h,0ah ; 02h..04h *CRT_regs ; Original! db 60h,4fh,50h,83h,54h,80h, 0bfh,1fh ; 00h..07h db 00h,040h,00h,00h,00h,00h,00h,00h ; 08h..0fh db 9fh,81h,8fh,28h,00h,96h,0b9h,0c3h ; 10h..17h db 0ffh ; 18h *graph_regs db 00h,00h,00h,00h,00h,40h,05h,0fh ; 00h..07h db 0ffh ; 08h *attr_regs db 00h,01h,02h,03h,04h,05h,06h,07h ; 00h..07h db 08h,09h,0ah,0bh,0ch,0dh,0eh,0fh ; 08h..0fh db 01h,00h,0Fh,00h,00h ; 10h..14h *extended_regs db 05h,10h,07h,00h,00h ; 02h..06h db 0c8h,00h,00h,00h,0fh ; 13h..15h, 17h & 19h db 05h,04h,08h,00h ; 20h..22h, 25h db 00h,00h,00h,00h,00h,00h ; 30h..35h ********************************************************************** ** 280x192, 16 color mode 0eh register definitions ** public vga_regs_FB vga_regs_FB db 63h ; misc out reg db 09h ; clocking mode reg db 00h ; feature ctrl *sequencer_regs db 0fh,00h,06h ; 02h..04h *CRT_regs db 2Dh,27h,28h,90h,2Ah,90h,0BFh,1Fh ; 00h..07h db 00h,0C0h,00h,00h,00h,00h,00h,00h ; 08h..0fh db 9Ch,8Eh,8Fh,14h,00h,096h,0B9h,0e3h ; 10h..17h db 0ffh ; 18h *graph_regs db 00h,00h,00h,00h,00h,00h,05h,0Fh ; 00h..07h db 0ffh ; 08h *attr_regs db 00h,01h,02h,03h,04h,05h,06h,07h ; 00h..07h db 08h,09h,0Ah,0Bh,0Ch,0Dh,0Eh,0Fh ; 08h..0fh db 01h,00h,0Fh,00h,00h ; 10h..14h *extended_regs db 05h,10h,07h,00h,00h ; 02h..06h db 0c8h,00h,00h,00h,0fh ; 13h..15h, 17h & 19h db 01h,00h,08h,00h ; 20h..22h, 25h db 00h,00h,00h,00h,00h,00h ; 30h..35h ** Mode FC (40-column Emulation mode) ** public vga_regs_FC vga_regs_FC db 67h ; misc out reg db 08h ; clocking mode reg db 00h ; feature ctrl * sequencer_regs db 03h,00h,02h ; 02h..04h * CRT_regs db 2dh,27h,28h,90h,2bh,0a0h,0bfh,1fh ; +00h..07h db 00h,4fh,2dh,0eh,00h,00h,00h,00h ; +08h..0fh db 97h,8eh,7fh,14h,1fh,87h,0b9h,0a3h ; +10h..17h db 0ffh ; +18h * graph_regs db 00h,00h,00h,00h,00h,10h,0eh,00h ; +00h..07h db 0ffh ; +08h * attr_regs db 00h,01h,02h,03h,04h,05h,06h,07h ; +00h..07h db 08h,09h,0ah,0bh,0ch,0dh,0eh,0fh ; +08h..0fh db 0ch,10h,0Fh,08h,00h ; +10h..14h * extended_regs db 05h,10h,07h,00h,01h ; 02h..06h db 0c8h,00h,00h,00h,0fh ; 13h..15h, 17h & 19h db 01h,00h,08h,00h ; 20h..22h, 25h db 00h,00h,00h,00h,00h,00h ; 30h..35h ** Mode FD (80-column Emulation mode) ** public vga_regs_FD vga_regs_FD db 67h ; misc out reg db 00h ; clocking mode reg db 00h ; feature ctrl * sequencer_regs + $03 db 03h,00h,02h ; 02h..04h ; 02h..04h * CRT_regs + $06 db 5fh,4fh,50h,82h,55h,81h,0bfh,1fh ; 00h..07h db 00h,4fh,2dh,0eh,00h,00h,00h,00h ; 08h..0fh db 97h,8eh,7fh,28h,1fh,87h,0b9h,0a3h ; 10h..17h db 0ffh ; 18h * graph_regs + $1F db 00h,00h,00h,00h,00h,10h,0eh,00h ; 00h..07h db 0ffh ; 08h * attr_regs + $28 db 00h,01h,02h,03h,04h,05h,06h,07h ; 00h..07h db 08h,09h,0ah,0bh,0ch,0dh,0eh,0fh ; 08h..0fh db 0Ch,10h,0fh,08h,00h ; 10h..14h * Reg 6 is offset $41 * Reg 21 is offset $48 * extended_regs + $3D db 05h,10h,07h,00h,01h ; 02h..06h db 0c8h,00h,00h,00h,0fh ; 13h..15h, 17h & 19h db 01h,00h,08h,00h ; 20h..22h, 25h db 00h,00h,00h,00h,00h,00h ; 30h..35h ** 640x400, 256 color mode 61h register definitions ** public vga_regs_FE vga_regs_FE db 063h ; misc out reg db 21h ; clocking mode reg db 00h ; feature ctrl *sequencer_regs ; db 0fh,00h,0ah ; 02h..04h db 0fh,00h,0ah ; 02h..04h *CRT_regs ; Original! db 60h,4fh,50h,83h,54h,80h, 0bfh,1fh ; 00h..07h db 00h,0c0h,00h,00h,00h,00h,00h,00h ; 08h..0fh db 9fh,81h,8fh,28h,00h,96h,0b9h,0c3h ; 10h..17h db 0ffh ; 18h *graph_regs db 00h,00h,00h,00h,00h,40h,05h,0fh ; 00h..07h db 0ffh ; 08h *attr_regs db 00h,01h,02h,03h,04h,05h,06h,07h ; 00h..07h db 08h,09h,0ah,0bh,0ch,0dh,0eh,0fh ; 08h..0fh db 01h,00h,0Fh,00h,00h ; 10h..14h *extended_regs db 05h,10h,07h,00h,00h ; 02h..06h db 0c8h,00h,00h,00h,0fh ; 13h..15h, 17h & 19h db 05h,04h,08h,00h ; 20h..22h, 25h db 00h,00h,00h,00h,00h,00h ; 30h..35h *********************************************************************** ** IIGS AppleColor RGB VIDEO MODE SETTINGS *********************************************************************** public gs_regs_01 public gs_regs_03 public gs_regs_FD gs_regs_03 db 063h ; misc out reg db 029h ; clocking mode reg db 001h ; feature ctl db 003h,000h,002h ; Sequencer regs db 073h,04Fh,056h,091h,05Eh,08Bh,006h,011h ; Sequencer regs db 000h,047h,02Dh,00Eh,000h,000h,000h,000h ; Sequencer regs db 0DEh,046h,0C7h,028h,01Fh,0D5h,0D8h,0A3h ; Sequencer regs db 0FFh db 000h,000h,000h,000h,000h,010h,00Eh,000h ; Graphics Regs db 0FFh db 000h,001h,002h,003h,004h,005h,006h,007h ; $00 - $07 Attribute regs db 008h,009h,00Ah,00Bh,00Ch,00Dh,00Eh,00Fh ; $08 - $0F db 00Ch,010h,00Fh,008h,000h ; $10 - $14 db 005h,010h,007h,000h,00Ch ; $02 - $06 Extended regs db 0C8h,000h,000h,000h,00Fh ; $13..$15,$17, & $19 db 001h,000h,008h,000h ; $30..$22, $25 db 000h,000h,000h,000h,000h,000h ; $30..$35 * This is a 40-column by 24-row at 9MHz. That's quite a bit too fast * (8MHz would have been perfect) but it will have to suffice. gs_regs_01 db 067h ; misc out reg db 029h ; clocking mode reg db 001h ; feature ctl db 003h,000h,002h ; Sequencer regs db 042h,027h,031h,081h,035h,03Ah,006h,011h ; Sequencer regs db 000h,047h,008h,009h,000h,000h,000h,000h ; Sequencer regs db 0DEh,046h,0C7h,014h,01Fh,0D5h,0D8h,0A3h ; Sequencer regs db 0FFh db 000h,000h,000h,000h,000h,010h,00Eh,000h ; Graphics Regs db 0FFh db 000h,001h,002h,003h,004h,005h,006h,007h ; $00 - $07 Attribute regs db 008h,009h,00Ah,00Bh,00Ch,00Dh,00Eh,00Fh ; $08 - $0F db 008h,000h,00Fh,000h,000h ; $10 - $14 db 005h,010h,007h,000h,005h ; $02 - $06 Extended regs db 0C8h,000h,000h,000h,00Fh ; $13..$15,$17, & $19 db 001h,000h,008h,000h ; $30..$22, $25 db 000h,000h,000h,000h,000h,000h ; $30..$35 public gs_regs_FC gs_regs_FC db 067h ; misc out reg db 029h ; clocking mode reg db 001h ; feature ctl db 003h,000h,002h ; Sequencer regs db 042h,027h,031h,081h,035h,03Ah,006h,011h ; Sequencer regs db 000h,047h,008h,009h,000h,000h,000h,000h ; Sequencer regs db 0DAh,046h,0BFh,014h,01Fh,0D5h,0D8h,0A3h ; Sequencer regs db 0FFh db 000h,000h,000h,000h,000h,010h,00Eh,000h ; Graphics Regs db 0FFh db 000h,001h,002h,003h,004h,005h,006h,007h ; $00 - $07 Attribute regs db 008h,009h,00Ah,00Bh,00Ch,00Dh,00Eh,00Fh ; $08 - $0F db 008h,000h,00Fh,000h,000h ; $10 - $14 db 005h,010h,007h,000h,005h ; $02 - $06 Extended regs db 0C8h,000h,000h,000h,00Fh ; $13..$15,$17, & $19 db 001h,000h,008h,000h ; $30..$22, $25 db 000h,000h,000h,000h,000h,000h ; $30..$35 gs_regs_FD db 063h ; misc out reg db 029h ; clocking mode reg db 001h ; feature ctl db 003h,000h,002h ; Sequencer regs db 073h,04Fh,056h,091h,05Eh,08Bh,006h,011h ; Sequencer regs db 000h,047h,02Dh,00Eh,000h,000h,000h,000h ; Sequencer regs db 0DBh,046h,0BFh,028h,01Fh,0D5h,0D8h,0A3h ; Sequencer regs db 0FFh db 000h,000h,000h,000h,000h,010h,00Eh,000h ; Graphics Regs db 0FFh db 000h,001h,002h,003h,004h,005h,006h,007h ; $00 - $07 Attribute regs db 008h,009h,00Ah,00Bh,00Ch,00Dh,00Eh,00Fh ; $08 - $0F db 00Ch,010h,00Fh,008h,000h ; $10 - $14 db 005h,010h,007h,000h,00Ch ; $02 - $06 Extended regs db 0C8h,000h,000h,000h,00Fh ; $13..$15,$17, & $19 db 001h,000h,008h,000h ; $30..$22, $25 db 000h,000h,000h,000h,000h,000h ; $30..$35 public gs_regs_FE gs_regs_FE db 063h ; misc out reg db 029h ; clocking mode reg db 001h ; feature ctl db 00Fh,000h,00Ah ; Sequencer regs db 073h,04Fh,056h,091h,05Dh,08Bh,006h,011h ; Sequencer regs db 000h,040h,000h,000h,000h,000h,000h,000h ; Sequencer regs db 0DEh,046h,0C7h,028h,000h,0D5h,0D8h,0C3h ; Sequencer regs db 0FFh db 000h,000h,000h,000h,000h,040h,005h,00Fh ; Graphics Regs db 0FFh db 000h,001h,002h,003h,004h,005h,006h,007h ; $00 - $07 Attribute regs db 008h,009h,00Ah,00Bh,00Ch,00Dh,00Eh,00Fh ; $08 - $0F db 001h,000h,00Fh,000h,000h ; $10 - $14 db 005h,010h,007h,000h,00Ch ; $02 - $06 Extended regs db 0C8h,000h,000h,000h,00Fh ; $13..$15,$17, & $19 db 005h,004h,008h,000h ; $30..$22, $25 db 000h,000h,000h,000h,000h,000h ; $30..$35 public gs_regs_61 gs_regs_61 db 063h ; misc out reg db 029h ; clocking mode reg db 001h ; feature ctl db 00Fh,000h,00Ah ; Sequencer regs db 073h,04Fh,056h,091h,05Dh,08Bh,006h,011h ; Sequencer regs db 000h,040h,000h,000h,000h,000h,000h,000h ; Sequencer regs db 0DEh,046h,0C7h,028h,000h,0D5h,0D8h,0C3h ; Sequencer regs db 0FFh db 000h,000h,000h,000h,000h,040h,005h,00Fh ; Graphics Regs db 0FFh db 000h,001h,002h,003h,004h,005h,006h,007h ; $00 - $07 Attribute regs db 008h,009h,00Ah,00Bh,00Ch,00Dh,00Eh,00Fh ; $08 - $0F db 001h,000h,00Fh,000h,000h ; $10 - $14 db 005h,010h,007h,000h,00Ch ; $02 - $06 Extended regs db 0C8h,080h,030h,000h,00Fh ; $13..$15,$17, & $19 db 005h,004h,008h,000h ; $30..$22, $25 db 000h,000h,000h,000h,000h,000h ; $30..$35 END  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEF,C ~ExpressLoadQ7TV ,E .b hx,E gnolib `T0E T"Q""."".;8 [d ںH"m,h8pI0ʊuںH"Mee!HH"Whںo#H"hںH"h "MH#hiHhchch) HH ""፜%h)) ) )H "MH#hiHhchchh  )O )H "MH#hiHhchchh  ) 8 pI0ʊ   ں'"m,hں{i HF")-h )H"MH#hi=Hhchchh  )[ںK"m,hں{i Hh")-h )H#h  )ںm"m,hں{i H")-h )H"MH#hi(Hhchchh  )"MH#hi=Hhchchh)I)Hh  )2ں"m,hں{i H")-h )H#ih  ) "MH#hiHhchchh)I)Hh  )#i)I)Hh  )]#)I)Hh  )#))ں"m,hں"m,h#))@ں"m,hں"m,h#)I@)Hh  )#))ں"m,hں"m,h#))@ں"m,hں"m,hں{i H")-h )H "MH#hiHhchchh  ) "MH#hi=Hhchchh)I)Hh  )]ں"m,hں""+hں"",hںH"H""Wh8pI0ʊں"hںo#H"hںH"hں"m,hں{i H")-h )H"MH#hi=Hhchchh  )ں"m,hں""+hںH""Wh8pI0ʊں,"hںo#H"hںH"hJں?"m,hں""+hںS""'hHhhں#)HV".*hں#)Hz".*hں#)H".*hں#)H#)H#)H".*hں"MH#hiHhchch)H"MH#hiHhchch)H"MH#hiHhchch)H"MH#hiHhchch)H"MH#hiHhchch)H"MH#hiHhchch)H"MH#hiHhchch)H"MH#hiHhchch)H".*hں"MH#hiHhchch)H"MH#hiHhchch)H "MH#hiHhchch)H "MH#hiHhchch)H "MH#hiHhchch)H "MH#hiHhchch)H "MH#hiHhchch)H"MH#hiHhchch)HZ".*hں"MH#hiHhchch)H"MH#hiHhchch)H"MH#hiHhchch)H"MH#hiHhchch)H"MH#hiHhchch)H"MH#hiHhchch)H"MH#hiHhchch)H"MH#hiHhchch)H".*hں ".*hں"MH#hiHhchch)H"MH#hiHhchch)H"MH#hiHhchch)H"MH#hiHhchch)H"MH#hiHhchch)H"MH#hiHhchch)H"MH#hiHhchch)H"MH#hiHhchch)H ".*hںt ".*hں"MH#hi(Hhchch)H"MH#hi(Hhchch)H"MH#hi(Hhchch)H"MH#hi(Hhchch)H"MH#hi(Hhchch)H"MH#hi(Hhchch)H"MH#hi(Hhchch)H"MH#hi(Hhchch)H ".*hں"MH#hi(Hhchch)H"MH#hi(Hhchch)H "MH#hi(Hhchch)H "MH#hi(Hhchch)H "MH#hi(Hhchch)H "MH#hi(Hhchch)H "MH#hi(Hhchch)H"MH#hi(Hhchch)H ".*hں"MH#hi(Hhchch)H"MH#hi(Hhchch)H"MH#hi(Hhchch)H"MH#hi(Hhchch)H"MH#hi(Hhchch)H9!".*hں"MH#hi=Hhchch)H"MH#hi=Hhchch)H"MH#hi=Hhchch)H"MH#hi=Hhchch)H"MH#hi=Hhchch)H!".*hں "MH#hi=Hhchch)H"MH#hi=Hhchch)H"MH#hi=Hhchch)H"MH#hi=Hhchch)H"MH#hi=Hhchch)H!".*hں "MH#hi=Hhchch)H "MH#hi=Hhchch)H "MH#hi=Hhchch)H "MH#hi=Hhchch)H2"".*hں"MH#hi=Hhchch)H"MH#hi=Hhchch)H"MH#hi=Hhchch)H"MH#hi=Hhchch)H"MH#hi=Hhchch)H"MH#hi=Hhchch)H{"".*hں"%h28pp H`3|KnpDE nn "MH#hiHhchch) ! +;ikargc: %d Set Oak Clock Speed Register: %02XSet Clocking Mode Register: %02XSet Overscan color register: %02XSet Feature Ctl %02XV-V+H- H+ V-V+H- H+ %02Xfilename (write): couldn't open fileSet HSYNC Divided by two (interlace) %02Xfilename (read): couldn't open filefilename (print): w+ 0x%02X, /* misc out reg */ 0x%02X, /* ; clocking mode reg */ 0x%02X, /* ; feature ctl */ 0x%02X,0x%02X,0x%02X, /* Sequencer regs */ 0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X, /*; Sequencer regs */ 0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X, /* ; Sequencer regs */ 0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X, /* ; Sequencer regs */ 0xFF, 0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X, /* ; Graphics Regs */ 0xFF, 0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X, /* ; $00 - $07 Attribute regs*/ 0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X, /* ; $08 - $0F*/ 0x%02X,0x%02X,0x%02X,0x%02X,0x%02X, /* ; $10 - $14*/ 0x%02X,0x%02X,0x%02X,0x%02X,0x%02X, /* ; $02 - $06 Extended regs*/ 0x%02X,0x%02X,0x%02X,0x%02X,0x%02X, /* ; $13..$15,$17, & $19*/ 0x%02X,0x%02X,0x%02X,0x%02X, /* ; $20..$22, $25*/ 0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X, /* ; $30..$35 */ {cdko`XW2Xo@  ###$$3$=$N$^$r$$$$$$$$$%%#%2%>%K%unknown errorDomain errorRange errorNot enough memoryNo such file or directoryI/O errorInvalid argumentBad file numberToo many open filesPermission deniedFile existsFile too largeNot ownerNo such processInterrupted system callArg list too longExec format errorNo childrenNo more processesNot a directoryNot a terminalBroken pipeIllegal seekNo space left on device; [|%~%%"%+;ik;8 [KH H"g1-H H"'de-g-  e- g-'    )\ "J' 'i''  P'"9 '" &" 'HH"tJ! 00 '" & )@ H H"tJH H"tJ ii d  +;i k;8 [KHH"g1p)d'' '8'''' '" ' HH 1HH"0 )d+;ik;8 [Kdd)awr %)HH"1  * )ȷ ) ) )" )=r %^ * *" * " ) %2w)*" *BX=a6))*" )Xе* *)*" *"J"J  HH"tJ%e-g-e-g-ȥ ȩ)+bȷ)+arQI* ȗ) H H"tJ+;ik)+)8`b*8``Kzh*h*Zګ*H*H"g1 %V*3*3;i*H"+28h*i*hz;o*Zګ3kKhzHګ*H*HZ"*k;8 [ )   2   7 H",  H"IH H 1  )    H H"' i ȷ i  8  ȷ :      )  ) H H"'  +;i k;8 ["T<dd +;ik; [HH J     z +;i k,3,3;i,H"+28h,i,hz;m,Zګ3kc-Ha-HH"*zhZګk;8 [KHH"1%-'- '-!" #-%'-H%-H"tJ+;ikT<+6<,6H-:6-;6_-H]-H"-k; [  +hhk;8 [# ȗd   +;ik ;[8.eʧ8;ID;o.+zhhZګkH /h\PKzZڭJHJH; [ 0 0"e0]i # " Ȁ " Ȁ  /Z8czHHH%H "* Out of memory."|P\Ph h  //m/  Ȁ  / / )s  "   i  ")0"!)    / / +hhkK 0H 0H ;[$/݋hHHhk֯g-e- "%+hh`; [ ȊwHwhȷ+;ike-g-0 00H"J7]-_-0 0H"J7a-c-c-Ha-H"c<0 0H"J7Y-[-H"c< 1kraa1"7 11`00A1"9 ?1!K1]1" U1[10`I1 ]1.CONSOLEKg-He-H; [  %8+hhzhhZګk; [ %+hzzH`;8 [ H H"i-H"J %H H HiH" ,  +;i kK ;[3)%H"3  +k33333 3333 2 +33).3 +33)l3 Lh )@y3 Y32|y3)-3,03"+ 3+3 #38``w3)*w3w3`)0:)Hw3w3 mw3cw3%N=n?s=b>pf=cp>Xl=x^=o@u>d>i>fEe|EEEgRGGWG3\K ;[=6A6C66"!66".6C6[)J6) - )J6) "!6J6) ".6%u6 "!66".6)A%4 )/%"*[ )] @  +hh6=6k =6?6G6)* ?6=6 5E6)lG6h ) D5 w4|55)0":)H55 m5c5 ԭ5`dAiAuCoCxCXCpCczAs@b@nCfGeGEGgGGG%D[BA6A6\HA6:A6h\(((((‚Ą;8 [Kdd)awr %O)9 8ȷ 8 %-w9" 9?X:a399" 9Xз 99 99" 9"J"J  HH"tJ%e-g-e-g-ȥ ȩ)+bȷ)+arQI)9 ȗ+;ik)+8`b)98``;8 [K ]- _-c-Ha-H"'[-HY-H"' ) ) )   H H 1   ,  c ;{i};;;  }; ; ; ; {;0 ;K" y;?L ; ;    ) };m; ;m;    ; ;   ; ; U i  i )8   :  )    I   )   +;i k0;!<". ;" y;"- <9< &  ;9<  Ȍ; "7J` `; . 1<R<_-H]-H"99k;8 [KHH"g1  ) w  HH"J  _ @@ HH"tJ7 ȥ  ȥȗd+;ik3 @%"34 = 3=3 3Q33T333330RN3n3n3n3jJJJJ 0:i =33 3 3 3˭3 X =3030 HH ȷ  HH ) 33338333 @3Z)H"3z3hih "3 @H"33!8  I-333HH3S3 '" &"333/4 0/ /4' 3S3 S3 833333333R 3 83I330 @3H"33 H"33H"33030 3H"333 0"33ȹ3) SZ3)H"3zȀ3 HH 33hih `3 3Q33T33330R3 3 3 3!N3n3n3n3jJJJJJ 03R30303Q3`330 "33`   h{[` vA tA  xAxA"!6C6=6hJ6) 抮?6  E6E6"!6)J6) ϊ".6?6$ xA8 tA:tA vA ?6 @`E6E6"!6?6  E6?6 @`BBB BBB"!6J6) BB+- B"!6BB=08BE6E6"!6BXxBE6zE6"!6B0e8"BX:N)AFGA)HBHBHB" EhBhBhmBBBE6E6"!6B".6BC6=6/?65B8BBBBB G60B ?6 @` 333TC)^ ΫC )] C33 3MC3"!6-H Cz=3?6  E6 ԜE6Ϙ".6?6  @`CC:JJJC`?6A6 =6 @` D Z DRG6 D"!6DD00E6E6"!6DDxXE6 E6".6DD"!6DD0^8"DQ:G)A?G:)HDHDHDD" EhDhDhmDDDE6E6D".6DDC6=6?6D G60D ?6 @`DDD"!6J6) ".6` "!6% ".6C6=6`H; [' $EHJ e effff` $E Fe jf +;ikPGPG143 14PG I-33 81433414 HH54 "14543 "14033e3330303 GPG033eE303) 3P33T346310330 :33.33 蘼330333)83I330 @3H"33030 0"333)3Z)H"3zi 03.3#3 3e30 >G8. >G0`3 333`GG3 3333414 HH54 "3I3394)m74:G333G83G IIE6E6"!6J6) E6+- H H]0H0 Hh I HE. H H8 H3eE% H H!+- H H I H".6 IC6=6Q?6WI3)0:0 H3" IH H HG6  "  "?6 @`E6 "!6 IE6`8`I3I`0: H H I`; [KHHIIII "II9:6II "I( "኉II%I ZIeiz  +;ikhf<~@LI; [5JM'J" %J+;ik5JL:J; [rJMdJ" bJ+;ikrJ; [8"L"%K+hhk "N"OhhkJJJHHH8H; [  "M % Q8  0 "Q "Q "Me i @< "Q "Q   "MZ "Q"L+;i kHH8H; [QȷQȷ HH"+hhhhkH; ["PSQȿQQQ+hhk ;8[IȅIdFejfFejfFejfFejfFEejfFejfFejfFejf2-I;i+ke &****;i+@kHiH;8  [  "PS QQO$>"OQQȩȗ na i  U GEQQ "QF e i  "M "M8  0 E QQ "Q) i+;ikixPzPvPHHzPHxPH%HzP@@vPH "hhvP) vPkHH; [QȗQȗȥȥȩQQ QQi+zzzzk; [  )8 I"T )L  ! )H"I  ( "I )H"7J   "7J +;i kH"Q""S"Rh") QHHHHH; ["PSQQ  ȷݠQȷQ ȷ+;i kHZ"7S"R"R"R"RkKMMR" RMMR" RMMR" RkKLMMM "aSMMMzR"9 xR!RٖR" RRM "aSM "aSMkR R.CONSOLEK JJJKKJKJJJJkHH;H" ;[+Jhhk"T%H"kJH "hJHiJ "JkJ "JkKzhJhJh %Zګk:JJJJk;8  [d ~MJT"7 HT LTHH HHHaS"0" "zj FTRT\TDTPTZT BT" @T$"8 NTTT" VTXTHH"  +;i k(KQQ&QkH ;[ "I "7J+hk /dB6~SOj(|St:k4o _w(cSkWGc{,gWs@BDFHJLNPRTVXZ\^`bdfhjlnprtvxz|~܂8;EHW >FNWZbeh (-2TY59[n*8 /3:=fioux !$9<2_behkqtwz} ,AH_bgm{ ]`cfry>ADQT]`m  GNSW_c %-58=gj؁ORbjmpv|-27:>ADGJ_qt &,/25:=BER_fiqt~ &,/58BGNQTW`cfiw #3@MUY^iq{" !(/IO_w 8@CF *-03EH]`jt pu #8;_t##O##'FC#xKh#m#`## #F#u##Id#5#v"""#Mn#""5,V#?"S"V z0 a  # # #A #| # # #- #U  # # #5 #p # # #! #I Zx # # #)#d####=Y ###9#t###%#M it ###I####5#] ###=#x###)#Q ###1#l#9!##9#t##!#A#|###!I####"2"Q####=#x#{"########$#$#3$#=$#N$#^$#r$#$#$#$#$#$#$#$#$#%#%##%#2%#>%#K%b**u,,1-T<?-H-..////l000000=3=3>32@33@3C3C3E14E54E14E54E3TF3UF3rG14~G54H3II II&IIFIILII\IItII|IISaS0E gnolib ;8  [  H{iH"c%%H"  % +;ik;8z [{iHhchc{iHhchchhhh) X{iHhhHHhchchhch~H"i- H"J    H~H hiH" , h#h% EG)3)!))' H{iH"c%%H"  ) ~Y h[h]_)a H{iYH"c%%H"  H{iH"c%%H"  %{iH"-!  %{iH"-))IMq{isH!uIKHhwhy H{iqH"c%%H"  H"tJ{iH"-!! H"tJ %{iH"-|{+;ik;8 [%8pI0ʊ% ##H H[-Y-H".*  +;ik%s: %s ;8 [ $"hh(&Hhh H{i H"c%%L *%H"  %('+;i&k;8 [ $"hh(&Hhh H{i H"c%%H"  %('+;i&k;8 [ I P | tld\ TLD8C H`6>>>FNNV^~~n^~~~^f~~~v~ +;i k&UDh #include #include #include #include #include vga_mode_rec md = { 0xEF, /* misc out register */ 0x01, /* clocking mode register */ 0x00, /* feature control */ /* Sequencer Registers */ 0x0F,0x00,0x0E, /* 02 - 04 */ /* CRT Registers */ 0x7B,0x63,0x64,0x9E,0x6B,0x92,0x6F,0xF0, /* 00 - 07 */ 0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00, /* 08 - 0F */ 0x58,0x8A,0x57,0x32,0x0F,0x58,0x6F,0xE3, /* 10 - 17 */ 0xFF, /* Graphic Controller registers */ 0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0F, /* 00 - 07 */ 0xFF, /* Attribute controller regs */ 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, /* 00 - 07 */ 0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F, /* 08 - 0F */ 0x01,0x00,0x0F,0x00,0x00, /* 10 - 14 */ /* Oak Extended Registers */ 0x05,0x10,0x07,0x00,0x07, /* 02..06 */ 0xC8,0x00,0x00,0x00,0x0F, /* 13..15, 17, and 19 */ 0x05,0x04,0x0C,0x00, /* 20..22, 25 */ 0x00,0x00,0x00,0x00,0x00,0x00 /* 30..35 */ }; char fn[80]; int main(int argc, char *argv[]) { char c; int val; int regnum = 0; int fd; FILE *fh; printf ("argc: %d\n",argc); if (argc > 1) { fd = open(argv[1],O_RDONLY); read(fd,&md,sizeof(md)); close(fd); } val = md.crt_regs[regnum]; while (1) { c = ReadChar(0) & 0x7F; switch (c) { case 8: val--; md.crt_regs[regnum] = val; break; case 21: val++; md.crt_regs[regnum] = val; break; case 10: if (regnum < 0x20) { regnum++; } break; case 11: if (regnum) { regnum--; } break; case 'C': printf("Set Oak Clock Speed Register:\n"); scanf("%02X",&val); md.ext_regs[4] = val; break; case 'c': printf("Set Clocking Mode Register:\n"); scanf("%02X",&val); md.clockMode = val; break; case 'b': printf("Set Overscan color register:\n"); scanf("%02X",&val); md.attr_regs[0x11] = val; break; case ' ': md.ext_regs[6] ^= 0x80; break; case 'f': printf("Set Feature Ctl\n"); scanf("%02X",&val); md.featureCtl = val; break; case 'D': md.crt_regs[9] ^= 0x80; break; case 'd': md.featureCtl ^= 0x01; break; case 'v': md.misc ^= 0x80; if (md.misc & 0x80) printf("V-"); else printf("V+"); if (md.misc & 0x40) printf("H-\n"); else printf("H+\n"); break; /* Flip vertical polarity */ case 'h': md.misc ^= 0x40; /* Flip horz polarity */ if (md.misc & 0x80) printf("V-"); else printf("V+"); if (md.misc & 0x40) printf("H-\n"); else printf("H+\n"); break; case '=': scanf("%02X",&val); md.crt_regs[regnum] = val; break; case 't': md.ext_regs[11] ^= 1; break; case 'w': case 'W': printf("filename (write): \n"); gets(fn); remove(fn); fd = open(fn,O_CREAT|O_WRONLY,0666); if (fd < 0) { perror("couldn't open file"); continue; } write(fd,&md,sizeof(vga_mode_rec)); close(fd); break; case 'i': printf("Set HSYNC Divided by two (interlace)\n"); scanf("%02X",&val); md.ext_regs[7] = val; break; case 'r': case 'R': printf("filename (read): \n"); gets(fn); fd = open(fn,O_RDONLY); if (fd < 0) { perror("couldn't open file"); continue; } read(fd,&md,sizeof(vga_mode_rec)); close(fd); break; case 'P': printf("filename (print): \n"); gets(fn); fh = fopen(fn,"w+"); fprintf(fh," 0x%02X, /* misc out reg */\n",md.misc); fprintf(fh," 0x%02X, /* ; clocking mode reg */\n",md.clockMode); fprintf(fh," 0x%02X, /* ; feature ctl */\n\n",md.featureCtl); fprintf(fh," 0x%02X,0x%02X,0x%02X, /* Sequencer regs */\n\n", md.seq02,md.seq03,md.seq04); fprintf(fh," 0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X, /*; Sequencer regs */\n", md.crt_regs[0],md.crt_regs[1],md.crt_regs[2],md.crt_regs[3], md.crt_regs[4],md.crt_regs[5],md.crt_regs[6],md.crt_regs[7]); fprintf(fh," 0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X, /* ; Sequencer regs */\n", md.crt_regs[8],md.crt_regs[9],md.crt_regs[10],md.crt_regs[11], md.crt_regs[12],md.crt_regs[13],md.crt_regs[14],md.crt_regs[15]); fprintf(fh," 0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X, /* ; Sequencer regs */\n", md.crt_regs[16],md.crt_regs[17],md.crt_regs[18],md.crt_regs[19], md.crt_regs[20],md.crt_regs[21],md.crt_regs[22],md.crt_regs[23]); fprintf(fh," 0xFF,\n\n"); fprintf(fh," 0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X, /* ; Graphics Regs */\n", md.graph_regs[0],md.graph_regs[1],md.graph_regs[2],md.graph_regs[3], md.graph_regs[4],md.graph_regs[5],md.graph_regs[6],md.graph_regs[7]); fprintf(fh," 0xFF,\n\n"); fprintf(fh," 0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X, /* ; $00 - $07 Attribute regs*/\n", md.attr_regs[0],md.attr_regs[1],md.attr_regs[2],md.attr_regs[3], md.attr_regs[4],md.attr_regs[5],md.attr_regs[6],md.attr_regs[7]); fprintf(fh," 0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X, /* ; $08 - $0F*/\n", md.attr_regs[8],md.attr_regs[9],md.attr_regs[10],md.attr_regs[11], md.attr_regs[12],md.attr_regs[13],md.attr_regs[14],md.attr_regs[15]); fprintf(fh," 0x%02X,0x%02X,0x%02X,0x%02X,0x%02X, /* ; $10 - $14*/\n\n", md.attr_regs[16],md.attr_regs[17],md.attr_regs[18],md.attr_regs[19], md.attr_regs[20]); fprintf(fh," 0x%02X,0x%02X,0x%02X,0x%02X,0x%02X, /* ; $02 - $06 Extended regs*/\n", md.ext_regs[0],md.ext_regs[1],md.ext_regs[2],md.ext_regs[3], md.ext_regs[4]); fprintf(fh," 0x%02X,0x%02X,0x%02X,0x%02X,0x%02X, /* ; $13..$15,$17, & $19*/\n", md.ext_regs[5],md.ext_regs[6],md.ext_regs[7],md.ext_regs[8], md.ext_regs[9]); fprintf(fh," 0x%02X,0x%02X,0x%02X,0x%02X, /* ; $20..$22, $25*/\n", md.ext_regs[10],md.ext_regs[11],md.ext_regs[12],md.ext_regs[13]); fprintf(fh," 0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X, /* ; $30..$35 */\n", md.ext_regs[14],md.ext_regs[15],md.ext_regs[16],md.ext_regs[17], md.ext_regs[18],md.ext_regs[19]); fclose(fh); break; default: continue; } val = md.crt_regs[regnum]; } } RGBv' 'M320X200X32KYo5 XM560X192Zo5XM640X200.14M[Q5'XM640X200.1575M\o54 XM640X200.18M]Q5)XM640X400.1575M^o5$ XM640X400X32K_o58 XM80X24.1575M`o5XM80X25.1575Mao57 XREADMEbI5Xc) sOV]@F(@  g)fETR@J( c) bOPT@L(@ Ȁc) sOV]@F(@  c) OWe@L(@ Ȁc) sOV]@F(@  Ȁc) sOV]@FP@  Ȁg)sOV^G-F(أ   g)sOV^G-F(أ   The 15.75MHz modes are derived from a 63 MHz dot clock, divided by four. : efghijklmnopqrstuvwxyz{|}~,C ~ExpressLoadQ7(V_W ,E csix,E gnolib ^b(V0E (V"(R#"."".;8 [d ںH"-h8pI0ʊuںH"fNe!e#HH"Whںo#H"hںH"hں#"UhںHH"Uh "fNH#hiHhchch) kHH ""=&h)) ) )H "fNH#hiHhchchh  )Y )H "fNH#hiHhchchh  ) 8 pI0ʊ   ں"-hں{i H"-h )H"fNH#hi=Hhchchh  )[ں"-hں{i H "-h )H#h  )ں"-hں{i H,"-h )H"fNH#hi(Hhchchh  )"fNH#hi=Hhchchh)I)Hh  )2ں1"-hں{i HB"-h )H#ih  ) "fNH#hiHhchchh)I)Hh  )#i)I)Hh  )]#)I)Hh  )#))ںG"-hںJ"-h#))@ںM"-hںQ"-h#)I@)Hh  )#))ںU"-hںX"-h#))@ں["-hں_"-hں{i Hc"-h )H "fNH#hiHhchchh  ) "fNH#hi=Hhchchh)I)Hh  )]ںh"-hںb#"o,hںb#"h-hںH"Hb#"Wh8pI0ʊں|"hںo#H"hںH"hں"-hں{i H"-h )H"fNH#hi=Hhchchh  )ں"-hںb#"o,hںHb#"Wh8pI0ʊں"hںo#H"hںH"hJں"-hںb#"o,hںb#"e(hHhhں#)H"*hں#)H"*hں#)HB"*hں#)H#)H#)He"*hں"fNH#hiHhchch)H"fNH#hiHhchch)H"fNH#hiHhchch)H"fNH#hiHhchch)H"fNH#hiHhchch)H"fNH#hiHhchch)H"fNH#hiHhchch)H"fNH#hiHhchch)H"*hں"fNH#hiHhchch)H"fNH#hiHhchch)H "fNH#hiHhchch)H "fNH#hiHhchch)H "fNH#hiHhchch)H "fNH#hiHhchch)H "fNH#hiHhchch)H"fNH#hiHhchch)H"*hں"fNH#hiHhchch)H"fNH#hiHhchch)H"fNH#hiHhchch)H"fNH#hiHhchch)H"fNH#hiHhchch)H"fNH#hiHhchch)H"fNH#hiHhchch)H"fNH#hiHhchch)HH "*hں "*hں"fNH#hiHhchch)H"fNH#hiHhchch)H"fNH#hiHhchch)H"fNH#hiHhchch)H"fNH#hiHhchch)H"fNH#hiHhchch)H"fNH#hiHhchch)H"fNH#hiHhchch)H "*hں!"*hں"fNH#hi(Hhchch)H"fNH#hi(Hhchch)H"fNH#hi(Hhchch)H"fNH#hi(Hhchch)H"fNH#hi(Hhchch)H"fNH#hi(Hhchch)H"fNH#hi(Hhchch)H"fNH#hi(Hhchch)H!"*hں"fNH#hi(Hhchch)H"fNH#hi(Hhchch)H "fNH#hi(Hhchch)H "fNH#hi(Hhchch)H "fNH#hi(Hhchch)H "fNH#hi(Hhchch)H "fNH#hi(Hhchch)H"fNH#hi(Hhchch)H|!"*hں"fNH#hi(Hhchch)H"fNH#hi(Hhchch)H"fNH#hi(Hhchch)H"fNH#hi(Hhchch)H"fNH#hi(Hhchch)H!"*hں"fNH#hi=Hhchch)H"fNH#hi=Hhchch)H"fNH#hi=Hhchch)H"fNH#hi=Hhchch)H"fNH#hi=Hhchch)H!""*hں "fNH#hi=Hhchch)H"fNH#hi=Hhchch)H"fNH#hi=Hhchch)H"fNH#hi=Hhchch)H"fNH#hi=Hhchch)Hu""*hں "fNH#hi=Hhchch)H "fNH#hi=Hhchch)H "fNH#hi=Hhchch)H "fNH#hi=Hhchch)H""*hں"fNH#hi=Hhchch)H"fNH#hi=Hhchch)H"fNH#hi=Hhchch)H"fNH#hi=Hhchch)H"fNH#hi=Hhchch)H"fNH#hi=Hhchch)H #"*hں"?&h(8pp &H`e                                                     +2                            O         \   "fNH#hiHhchch) ں H HQ#"-hI2ں#"UhںHH"Uh#"+;i!kargc: %d Set Oak Clock Speed Register: %02XSet Clocking Mode Register: %02XSet Overscan color register: %02XSet Feature Ctl %02XV-V+H- H+ V-V+H- H+ %02Xfilename (write): couldn't open fileSet HSYNC Divided by two (interlace) %02Xfilename (read): couldn't open filefilename (print): w+ db 0%02Xh ; misc out reg db 0%02Xh ; clocking mode reg db 0%02Xh ; feature ctl db 0%02Xh,0%02Xh,0%02Xh ; Sequencer regs db 0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh ; Sequencer regs db 0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh ; Sequencer regs db 0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh ; Sequencer regs db 0FFh db 0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh ; Graphics Regs db 0FFh db 0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh ; $00 - $07 Attribute regs db 0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh ; $08 - $0F db 0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh ; $10 - $14 db 0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh ; $02 - $06 Extended regs db 0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh ; $13..$15,$17, & $19 db 0%02Xh,0%02Xh,0%02Xh,0%02Xh ; $30..$22, $25 db 0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh ; $30..$35 Reg#%02X: %02X g(:'12G F(أ  $$$$$$$$$%%%1%@%J%Z%r%%%%%%%%%unknown errorDomain errorRange errorNot enough memoryNo such file or directoryI/O errorInvalid argumentBad file numberToo many open filesPermission deniedFile existsFile too largeNot ownerNo such processInterrupted system callArg list too longExec format errorNo childrenNo more processesNot a directoryNot a terminalBroken pipeIllegal seekNo space left on device; [&&!&"=&+;ik;8 [KH H"2-H H"'d..  . .'    )\ "CK''i药''  P'"9 '" '" 'HH"K! 1͐1 '" ' )@ H H"KH H"K ii d  +;i k;8 [KHH"2p)dU(W( Y(8W([(Y(]( [(" S( HH N2HH"0 )d+;ik;8 [Kdd)awr 7&*HH"h2  * p*ȷ p* * *" *=r 7&^ * *" * " * 7&2w**" *BX=a6***" *Xе****" *"CK"CK  HH"K7&....ȥ ȩ)+bȷ)+arQI* ȗ* H H"K+;ik)+*8`b*8``KzhT+hV+ZګV+HT+H"2 7&V;+b4+c4;iR+H"28hR+iR+hz;oR+Zګ}4kKhzHګV+HT+HZ"X+k;8 [ )   2   7 H"O-  H"JH H N2  )    H H"' i ȷ i  8  ȷ :      )  ) H H"'  +;i k;8 ["<dd +;ik; [HH J     z +;i kO-b4-c4;iM-H"28hM-iM-hz;mM-Zګ}4k.H.HH"X+zhZګk;8 [KHH"h2-- -!" -7&-H-H"K+;ik<6<6-6-6.H-H"..k; [  +hhk;8 [# ȗd   +;ik ;[8.eʧ8;ID;o.+zhhZګkH U0h\QKzZڭpKHnKH; [00"1]i # " Ȁ " Ȁ  S0Z8czHHH9&H "* Out of memoryR/"Q\Qh h  O0Q0mS0  Ȁ  Q0 O0 )s  "   i  ")0"!)    Q0 O0 +hhkK0H0H ;[$0~hHHhk֯.. "?&+hh`; [ ȊwHwhȷ+;ik..1 11H"7-.1 1H"7...H.H"=1 1H"7--H"= 1kraa1"7 11`111"9 1!11" 111`1 1.CONSOLEK.H.H; [  7&8+hhzhhZګk; [ 7&+hzzH`;8 [ H H" .H"CK 7&H H HiH",  +;i kK ;[}4)%H"^4  +ku4g4q4s4k4 o4m4w4e4 3 3g4).s4 3q4)lk4 Lh )@4 Y2|4)-m4,0o4"+ w4+w4 #e48``4)*44`)0:)H44 m4c4%=n@s>b>p>c?X >x=o@uR?d%?i%?f0FeFE"FgGGG}4\K ;[6666"66"66[)6) - )6) "66) "6%u6 "6;6"6)A%4 )/%"*[ )] RA  +hh66k 666)* 66 A66)l6h ) Dv6 5|v6t6)0":)Ht6t6 mt6ct6 ԭt6`dNBiSBudDolDxzDXzDptDcBsAbuAnPDfzHezHEzHgzHGzH%E[C66\H6:6h\(((((‚Ą;8 [Kdd)awr 7&O9 9ȷ 9 7&-w9" 9?X:a399" 9Xз9999" 9"CK"CK  HH"K7&....ȥ ȩ)+bȷ)+arQI9 ȗ+;ik)+8`b98``;8 [K - ..H.H"'-H-H"' ) ) )   H H N2   ,  c  <{i<"<$<  < < "< $< <1 . k4>w4 4Q44T{4k4{4y4i40RN|4n{4nz4ny4jJJJJ 0:i >4|4 {4 z4 y4˭e4 X >j40i40 HH ȷ  HH ) s4q4q4y48g4y4g4 9Ay4Z)H"^4zy4hih "g4 9AH"^4k4!8  I-w4i4k4HH4Sk4 '" &"s4q4q44 0/ 4' 4S4 Sq4 8g4q4g4w4g4i4g4g4R 4 8g4Ig4o40 9Aw4H"^4i4 H"^4j4H"^4o40g40 o4H"^4g4q4 0"^4q4ȹ4) SZ4)H"^4zȀk4 HH }4k4hih `w4 4Q44T{4k4{4y40R|4 {4 z4 y4!N|4n{4nz4ny4jJJJJJ 04Re4040i4Qm4`m4g40 "^4g4`   h{[` B B  BB"666h6) 抮6  66"6)6) ϊ"66$ B8 B:B B 6 RA`66"66  66 RA`CCC CCC"66) CC+- C"6CC=08C66"6CXxC6z6"6C0e8"CX:N)AFGA)HCHCHC"EhChChmCCC66"6C"6C66/65C8CCCCC 60C 6 RA` 444TLD)^ LD )] 3D44 4MLD4"6-H 3Dz=46  6 Ԝ6Ϙ"66  RA`NDND:JJJND`66 6 RA` pE Z pER6 pE"6EE0066"6EExX6 6"6ΘEE"6EE0^8"EQ:G)A?G:)HEHEHEE"EhEhEhmEEE66E"6ΘEE666E 60E 6 RA`EEE"66) "6` "6% "666`H; [' EHJ e effff` E Fe jf +;ikGG4q4 4G I-w4s4 84q444 HH4 "444 "404}4e444040u4 GG044eE404) 4P44T46e410440 :44.44 蘼440w4g44)8g4Ig4o40 9Aw4H"^4o40g40 0"^4g44)4Z)H"^4zi 04.4#4 4e40 G8. G0`4 444`vHvHs4 q4s4q444 HH4 "e4Iu4e44)m4:xHq4q4q4vH8q4xHII66"66) 6+- I rI]0H0 IhI IE. I rI8 I3eE% I rI!+- I rII I"6I66Q6WI~4)0:0 I4"IH H H6  "  "6 RA`6 "6I6`8`I4I`0: I rIΪI`; [KHHyJXJ{JyJ "{JyJ9:6XJJ "J( "኉J}J7&yJ ZyJeiz  +;ikhf<~@LJ; [J1NJ" J+;ikJLJ; [K/NK" K+;ikK; [8"L"K+hhk "+O"BPhhkzKKKHHH8H; [  ";N % Q8  0 "Q "Q ";Ne i @< "Q "Q   ";NZ "Q"L+;i kHH8H; [@RȷBRȷ HH"+hhhhkH; ["SDRȿFRDRFR+hhk ;8[IȅIdFejfFejfFejfFejfFEejfFejfFejfFejf2-I;i+ke &****;i+@kHiH;8  [  "S DRFRO$>"BPhRjRȩȗ na i  U GEFRDR "QF e i  ";N ";N8  0 E DRFR "Q) i+;ikiQQQHHQHQH9&HQ@@QH "hhQ) QkHH; [@RȗBRȗȥȥȩ@RBR @RBRi+zzzzk; [  )8 I"fU )L  ! )H"J  ( "J )H"J   "J +;i kH"lR"S"Sh") QHHHHH; ["SDRFR  ȷݠDRȷFR ȷ+;i kHZ"S"jS"S"AS"RkK3N-NR" R5N/NR" R7N1NR" RkK'M'N)N+N "T-N9N-NS"9 S!%S7S" /S5S9N "T/N "T1Nk#S 7S.CONSOLEK KtKrKKKKKKKKKkHH;H" ;[+Khhk"QU9&H"kKH "hKHiK "KkK "KkKzhnKhpKh 9&Zګk:JJJJk;8  [d NT"7 T THH HHHT"0" "zj TTTTTT T" T$"8 TT" TTHH"  +;i k(K@RBR&DRkH ;[ "J "J+hk; [x U V U U V U(+;ik; [x U VT V(+;ik ` ` ɥɦ ` ϸ ` ϸ ` /dt9Zr5M:'B "d(0Sv5p!\)dPX D-hT=x)d1lX%`-h5p!`x)h1l!V~ $Veqw !C]g+ 1RsW %/7NY"*08IPU]z;qx 4Uf <_w FYmvց ?Ww=GQq%-DUzI$i4=~:z]s@x&-4X^v| +5Ov؁BIQY_ FPTekr JOV\afky 7Tiu ,048<1q~a#)),M6W2]J $?Qq2t8Y %At )BLeo E1l9t%`-hT|=x)dM9tA|-h5p=xE1Y9aA|l&(*,.02468:<>@BDFHJLNPRTVXZ\^`bdfhjlnprtvxz|~S{!%)-159=AEIMQUY]aeimquy},1;  &)DGJbehk(L~EIB~-eAFY] !$*08;MQ\bjm #&9Pdq,:?BX[`fqx| '/7OloK G  ?BJMks/25Vloy"  &)38;FILObeilorw~&PSVgp )19@HMYbs ").4:?Mx} !->CKOWZ`cfnvz& "'*18AFINS\_ehkpx} 07?IQV[aemx{  #(+27>AFINSX`emqtw"&),47ILUZ]co" "),38;BILTWaiw|$ "/5;>EISZ_bnq{~ 1=Lgos|  *8pux HKNQTWZ]`cf %@psv} UX^;_tDw## ###3T# #/,Z##1B#G###GJ!M<QV#UX[_c/#q#hb#b#b#5|V## "b#>b#q#b#b#& I l B e # #B #} # # #. #i #  # #6 #q # # #" #] #  # #*#e####Q#yH  ##:#u###&#a# !##J####6#q#!##>#y###*#e#|!##2#m##!#:#u###!"B#}###.#Vu"###6#^"###>#y## ##PQ#x##$$'$$+$$/$$3$$7$$;$$?$$C$$G$%K$%%O$1%S$@%W$J%[$Z%_$r%c$%g$%k$%o$%s$%w$%{$%$%+;+-O--<--b/R/j0~0m0~0 11'11Y11#>4$>4d?4@4@4C4C4`F4lF4|F4F4F4F4F4H4H4:I4IyJIXJI{JIXJIJIJJJJ}J=TT0E gnolib ;8  [  H{iH"&=&H"  7& +;ik;8z [{iHhchc{iHhchchhhh) X{iHhhHHhchchhch~H" . H"CK    H~H hiH", h#h% EG)3)!))' H{iH"&=&H"  ) ~Y h[h]_)a H{iYH"&=&H"  H{iH"&=&H"  7&{iH"}.!  7&{iH"}.))IMq{isH!uIKHhwhy H{iqH"&=&H"  H"K{iH"}.!! H"K 7&{iH"}.|{+;ik;8 [7&8pI0ʊ7& #$!$H H--H"*  +;ik%s: %s ;8 [ $"hh(&Hhh H{i H"&=&L *=&H"  7&('+;i&k;8 [ $"hh(&Hhh H{i H"&=&H"  7&('+;i&k;8 [ I P | tld\ TLD8C H`6>>>FNNV^~~n^~~~^f~~~v~ +;i k&UDh #include #include #include #include #include vga_mode_rec md = { 0x67, /* misc out reg */ 0x28, /* ; clocking mode reg */ 0x01, /* ; feature ctl */ 0x03,0x00,0x02, /* Sequencer regs */ 0x3A,0x27,0x31,0x9A,0x32,0x9A,0x06,0x11, /*; Sequencer regs */ 0x00,0x47,0x08,0x09,0x00,0x00,0x00,0x00, /* ; Sequencer regs */ 0xDA,0x46,0xBF,0x28,0x1F,0xD5,0xD8,0xA3, /* ; Sequencer regs */ 0xFF, 0x00,0x00,0x00,0x00,0x00,0x10,0x0E,0x00, /* ; Graphics Regs */ 0xFF, 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, /* ; $00 - $07 Attribute regs*/ 0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F, /* ; $08 - $0F*/ 0x0C,0x00,0x0F,0x08,0x00, /* ; $10 - $14*/ 0x05,0x10,0x07,0x00,0x05, /* ; $02 - $06 Extended regs*/ 0xC8,0x00,0x00,0x00,0x0F, /* ; $13..$15,$17, & $19*/ 0x01,0x00,0x08,0x00, /* ; $20..$22, $25*/ 0x00,0x00,0x00,0x00,0x00,0x00, /* ; $30..$35 */ }; char fn[80]; int main(int argc, char *argv[]) { char c; int val; int regnum = 0; int fd; FILE *fh; int noreset; printf ("argc: %d\n",argc); if (argc > 1) { fd = open(argv[1],O_RDONLY); read(fd,&md,sizeof(md)); close(fd); } _SetUserMode(&md); _SetMode(0xFF,1); val = md.crt_regs[regnum]; while (1) { c = ReadChar(0) & 0x7F; switch (c) { case 8: val--; md.crt_regs[regnum] = val; break; case 21: val++; md.crt_regs[regnum] = val; break; case 10: if (regnum < 0x20) { regnum++; } noreset=1; break; case 11: if (regnum) { regnum--; } noreset=1; break; case 'C': printf("Set Oak Clock Speed Register:\n"); scanf("%02X",&val); md.ext_regs[4] = val; break; case 'c': printf("Set Clocking Mode Register:\n"); scanf("%02X",&val); md.clockMode = val; break; case 'b': printf("Set Overscan color register:\n"); scanf("%02X",&val); md.attr_regs[0x11] = val; break; case ' ': md.ext_regs[6] ^= 0x80; break; case 'f': printf("Set Feature Ctl\n"); scanf("%02X",&val); md.featureCtl = val; break; case 'D': md.crt_regs[9] ^= 0x80; break; case 'd': md.featureCtl ^= 0x01; break; case 'v': md.misc ^= 0x80; if (md.misc & 0x80) printf("V-"); else printf("V+"); if (md.misc & 0x40) printf("H-\n"); else printf("H+\n"); break; /* Flip vertical polarity */ case 'h': md.misc ^= 0x40; /* Flip horz polarity */ if (md.misc & 0x80) printf("V-"); else printf("V+"); if (md.misc & 0x40) printf("H-\n"); else printf("H+\n"); break; case '=': scanf("%02X",&val); md.crt_regs[regnum] = val; break; case 't': md.ext_regs[11] ^= 1; break; case 'w': case 'W': printf("filename (write): \n"); gets(fn); remove(fn); fd = open(fn,O_CREAT|O_WRONLY,0666); if (fd < 0) { perror("couldn't open file"); continue; } write(fd,&md,sizeof(vga_mode_rec)); close(fd); break; case 'i': printf("Set HSYNC Divided by two (interlace)\n"); scanf("%02X",&val); md.ext_regs[7] = val; break; case 'r': case 'R': printf("filename (read): \n"); gets(fn); fd = open(fn,O_RDONLY); if (fd < 0) { perror("couldn't open file"); continue; } read(fd,&md,sizeof(vga_mode_rec)); close(fd); break; case 'P': printf("filename (print): \n"); gets(fn); fh = fopen(fn,"w+"); fprintf(fh," db 0%02Xh ; misc out reg\n",md.misc); fprintf(fh," db 0%02Xh ; clocking mode reg\n",md.clockMode); fprintf(fh," db 0%02Xh ; feature ctl\n\n",md.featureCtl); fprintf(fh," db 0%02Xh,0%02Xh,0%02Xh ; Sequencer regs\n\n", md.seq02,md.seq03,md.seq04); fprintf(fh," db 0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh ; Sequencer regs\n", md.crt_regs[0],md.crt_regs[1],md.crt_regs[2],md.crt_regs[3], md.crt_regs[4],md.crt_regs[5],md.crt_regs[6],md.crt_regs[7]); fprintf(fh," db 0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh ; Sequencer regs\n", md.crt_regs[8],md.crt_regs[9],md.crt_regs[10],md.crt_regs[11], md.crt_regs[12],md.crt_regs[13],md.crt_regs[14],md.crt_regs[15]); fprintf(fh," db 0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh ; Sequencer regs\n", md.crt_regs[16],md.crt_regs[17],md.crt_regs[18],md.crt_regs[19], md.crt_regs[20],md.crt_regs[21],md.crt_regs[22],md.crt_regs[23]); fprintf(fh," db 0FFh\n\n"); fprintf(fh," db 0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh ; Graphics Regs\n", md.graph_regs[0],md.graph_regs[1],md.graph_regs[2],md.graph_regs[3], md.graph_regs[4],md.graph_regs[5],md.graph_regs[6],md.graph_regs[7]); fprintf(fh," db 0FFh\n\n"); fprintf(fh," db 0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh ; $00 - $07 Attribute regs\n", md.attr_regs[0],md.attr_regs[1],md.attr_regs[2],md.attr_regs[3], md.attr_regs[4],md.attr_regs[5],md.attr_regs[6],md.attr_regs[7]); fprintf(fh," db 0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh ; $08 - $0F\n", md.attr_regs[8],md.attr_regs[9],md.attr_regs[10],md.attr_regs[11], md.attr_regs[12],md.attr_regs[13],md.attr_regs[14],md.attr_regs[15]); fprintf(fh," db 0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh ; $10 - $14\n\n", md.attr_regs[16],md.attr_regs[17],md.attr_regs[18],md.attr_regs[19], md.attr_regs[20]); fprintf(fh," db 0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh ; $02 - $06 Extended regs\n", md.ext_regs[0],md.ext_regs[1],md.ext_regs[2],md.ext_regs[3], md.ext_regs[4]); fprintf(fh," db 0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh ; $13..$15,$17, & $19\n", md.ext_regs[5],md.ext_regs[6],md.ext_regs[7],md.ext_regs[8], md.ext_regs[9]); fprintf(fh," db 0%02Xh,0%02Xh,0%02Xh,0%02Xh ; $30..$22, $25\n", md.ext_regs[10],md.ext_regs[11],md.ext_regs[12],md.ext_regs[13]); fprintf(fh," db 0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh,0%02Xh ; $30..$35\n", md.ext_regs[14],md.ext_regs[15],md.ext_regs[16],md.ext_regs[17], md.ext_regs[18],md.ext_regs[19]); fclose(fh); break; default: continue; } val = md.crt_regs[regnum]; printf("Reg#%02X: %02X\n",regnum,val); if (!noreset) { _SetUserMode(&md); _SetMode(0xFF,1); } noreset = 0; } }  int HT, /* Horizontal Total */ HDE, /* Horizontal Display End */ SHB, EHB, /* Start/End Horizontal Blank */ SHR, EHR, /* Start/End Horizontal retrace */ VT, /* Vertical Total */ VDE, /* Vertical Display End */ VBS, EVB, /* Vertical Blank Start/End */ VRS, EVR; /* Vertical Retrace Start/End */ #define HRW 3 /* 3 character positions should suffice */ ----------------------------------------------------------------------- The following example assumes fixed-vertical-scan monitors such as the AppleColor RGB (200 scanlines), or traditional non-multisync VGA monitors (which support 350,400,or 480 scanlines) S = # of scanlines per second (scanlines/frame * number of frames) For AppleColor RGB, this is 15750 For VGA in 480 line mode, this is 480 * 60 (28800?) Fp = pixel clock frequency in Hz Pp = 1 / Fp (period of a single pixel) Ps = 1 / S (period of a scanline) DPS = Ps / Pp (number of dots per scanline) PPS = # (e.g. 640 - number of display pixels per scanline) HT = DPS / 8 HBW = DPS - PPS (width of the horizontal blanking period) /* This centers the horizontal retrace signal in the horizontal blanking interval */ Horizontal retrace start - adjust via horizontal retrace width HRS = PPS + (HBW / 2) - (HRW / 2) EHR = PPS + (HBW / 2) + (HRW / 2) HBS = PPS; /* Start blanking after data */ HBE = DPS; /* End blanking just before data */ U,C ~ExpressLoadU ()_,E ,(0E ("$"d""[;8 [H((H5:8)H" Hhchchh  )8)H" Hhchchh  ))H" Hhchchh  )) )H" Hhchchh  )) )H" Hhchchh  ))H" Hhchchh  )" Hhchch h )H))Hh )8)H" Hhchchh  )" Hhchch h )H) )Hh )" Hhchch h )H))Hh )" Hhchch h )H))Hh )" Hhchch h )H)@)Hh )))H" Hhchchh  )0)H" Hhchchh  )" Hhchch h )H))Hh )" Hhchch h )H)@)Hh )" Hhchch h )H))Hh )))H" Hhchchh  ) " Hhchch h )H) )Hh )" Hhchch h )H))Hh )))H" Hhchchh  ))?)H" Hhchchh  ) 8 pI0ʊ 8 pI0ʊVں " e " Hhchch)H"h ں"h V+;ik0x%02X, 2  ;i0H"_ 8h0i0hz;m0Zګ kUHSHH"zhZګkH h\4$KzZڭHH; [Q S "U ]i # " Ȁ " Ȁ  Z8czHHHY H "* Out of memory"#\4$h h  m   Ȁ   )s  "   i  ")0"!)    +hhkKS HQ H ;[$ #hHHhk֯YW "Y+hh`WY H" OQ H" SUUHSH" H" KMH" kraa "7 ` 1 "9 / !; M " E K `9 M .CONSOLEK ;[ )%H"   +k     _ ). _  )l Lh )@ݭ Yg | )- ,0 "+ + # 8`` )*  `)0:)H m c %n8s6bWpcXxogudifeEgG \;8 [Kdd)awr W Oi 'ȷ ' W -wY" W?X:a3GO" EXзKUIS" M""  HH"W WYWYȥ ȩ)+bȷ)+arQIi ȗ+;ik)+8`bi8``;8 [K O QUHSH"MHKH" ) ) )   H H ?   ,  c {i        K" ?L      ) m m          U i  i )8   :  )    I   )   +;i k /a". -" "- _y &  y  Ȍ "o` `? . q;8 [ )   2   7 H"2  H"2H H ?  )    H H" i ȷ i  8  ȷ :      )  ) H H"  +;i k;8 [KHH"  ) w  HH"  _ @@ HH"7 ȥ  ȥȗd+;ik %" 4 4  4  Q  T   0RN n n n jJJJJ 0:i 4   ˭ X 4 0 0 HH ȷ  HH )    8  Z)H" z hih " H"  !8  I- HH S '" &"   c 0/ c '  S S 8    R   8 I  0  H" H" H"  0 0  H"  0"  ȹ ) SZ )H" zȀ  HH   hih `  Q  T   0R  !N n n n jJJJJJ 0 R 0 0 Q ` 0 " `KYHWH; [  W 8+hhzhhZګk; [ W +hzzH`;8 [KH H"-H H"dWY  W Y'    )\ "i  P"9 " " HH"!   "  )@ H H"H H" ii d  +;i k;8 [KHH"p)doq s8qusw u" m HH ?HH" )d+;ik; [ ȊwHwhȷ+;ike  e  I-  8e  g e HHi "e i   "e 0  e   0 0  ]0  eE 0 )  P  Tg 6 10  0 :  .  蘼  0   )8 I  0  H"  0 0 0"  ) Z)H" zi }0 . #  e 0 8. 0`    `..    g e HHi " I  m )mk :0   .8 0L5; [m _" ]+;ikmLr; [ " +;ik; [8"J"]+hhk "!""hhkHHH8H; [  " % Q8  0 "T$ "T$ " e i @< "T$ "T$   " Z "T$"J+;i kHH8H; [$ȷ$ȷ HH"+hhhhkH; ["&$ȿ$$$+hhk ;8[IȅIdFejfFejfFejfFejfFEejfFejfFejfFejf2-I;i+ke &****;i+@kHiH;8  [  "& $$O$>""$%ȩȗ na i  U GE$$ "T$F e i  " " 8  0 E $$ "T$) i+;iki菰###HH#H#HY H#@@#H "hh#) #kHH; [$ȗ$ȗȥȥȩ$$ $$i+zzzzk; [  )8 I"' )L  ! )H"2  ( "2 )H"o   "o +;i kH"%"Z&"&h") L$HHHHH; ["&$$  ȷݠ$ȷ$ ȷ+;i kHZ"o&"&"-&"%"K%kK  I%" G%  I%" G%  I%" G%kK "& %"9 %!%%" %% "& "& k% %.CONSOLEK   ;=7913-/kHH;H" ;[+hhk"'Y H"k+H "hHi "+k+ "+kKzhhh Y Zګk:JJJJk;8  [d '"7 ' 'HH HHH&"0" "zj ~'''|''' z'" x'$"8 ''" ''HH"  +;i k(K$$&$kH ;[ "2 "o+hk  w2r4h(-a sq$.^{  ,38@a39Gl"5Gv 5BTfmw}3e,@! -Pp&0;]w-E+IIa  *7?go HNX &2T\w} !6:>Hbfl ,A^s !1@V[kty.:M!'-39?EKQW]cfB` #Dx8R=q3c1a>[x%]uy /26X]VY_ehpsy),f %/>FS`u| $'*-?7?EKU]emux} !$  %(-uz,47Apx{~! !$169ORUXbehk}I  &AT?Au5:n~;Xu2  #  # \ v      z { e $i 4e :i @   e i && #include #include #include #include #define BIT0 0x1 #define BIT1 0x2 #define BIT2 0x4 #define BIT3 0x8 #define BIT4 0x10 #define BIT5 0x20 #define BIT6 0x40 #define BIT7 0x80 byte crt[0x30]; int HT, /* Horizontal Total */ HDE, /* Horizontal Display End */ SHB, EHB, /* Start/End Horizontal Blank */ SHR, EHR, /* Start/End Horizontal retrace */ VT, /* Vertical Total */ VDE, /* Vertical Display End */ VBS, EVB, /* Vertical Blank Start/End */ VRS, EVR; /* Vertical Retrace Start/End */ int main(int argc, char *argv[]) { int i,j; HT = 72; HDE = 40; SHB = 40; EHB = 72; SHR = 53; EHR = 58; VT = 262; VDE = 192; VBS = 192; EVB = 262; VRS = 228; EVR = 232; /* $00 Horizontal Total = 8 bits T-5 */ crt[0x00] = HT - 5; /* $01 Horizontal Display Enable = 8 bits T-1 */ crt[0x01] = HDE - 1; /* $02 Start Horz Blank = 8 bits */ crt[0x02] = SHB; /* $03 End Horz Blank = 6 bits Character posn from end horz blank: EHB = (R03 & 0x1F) | ((R05 >> 2) & 0x20) (R02 & 0xC0) & (EHB & 0x3F) EHB from end character position. EHB = CPsn[5..0]; R03[4..0] = EHB[4..0]; R05[7] = EHB[5]; */ crt[0x03] = 0x80 | (EHB & 0x1F); /* first set */ crt[0x05] = (EHB & 0x20) << 2; /* first set - Shift bit 5 to bit 7 */ /* $04 Start Horz Retrace = 8 bits */ crt[0x04] = SHR; /* $05 End Horz Retrace = 5 bits EHR = R05[4..0] */ crt[0x05] |= (EHR & 0x1F); /*$06 Vertical Total = 10 bits VT[9] = R07[5] VT[8] = R07[0] VT[7..0] = R06[7..0] VT = vertical retrace + # scanlines - 2 */ crt[0x06] = VT - 2; crt[0x07] |= (VT & 0x200) ? BIT5 : 0; crt[0x07] |= (VT & 0x100) ? BIT0 : 0; /* $07 = misc extension bits */ /* $10 = Vertical Retrace Start VRS[9] = R07[7]; VRS[8] = R07[2]; VRS[7..0] = R10[7..0]; */ crt[0x07] |= (VRS & 0x200) ? BIT7 : 0; crt[0x07] |= (VRS & 0x100) ? BIT6 : 0; crt[0x10] = VRS & 0xFF; /* $11 = End Vertical Retrace EVR = R11[3..0]; */ crt[0x11] = (BIT5 | BIT4); crt[0x11] |= (EVR & 0x0F); /* $12 = Vertical Display End VDE[9] = R07[6]; VDE[8] = R07[1]; VDE[7..0] = R12[7..0]; */ crt[0x07] |= (VDE & 0x200) ? BIT6 : 0; crt[0x07] |= (VDE & 0x100) ? BIT1 : 0; crt[0x12] = VDE & 0xFF; /* $15 = Start Vertical Blank VBS[9] = R09[5]; VBS[8] = R07[3]; VBS[7..0] = R15[7..0]; */ crt[0x09] |= (VBS & 0x200) ? BIT5 : 0; crt[0x07] |= (VBS & 0x100) ? BIT3 : 0; crt[0x15] = VBS & 0xFF; /* $16 = End Vertical Blank EVB[6..0] = R16[6..0]; */ crt[0x16] = EVB & 0x3F; for (j = 0; j < 3; j++) { for (i = 0; i < 8; i++) { printf("0x%02X,",crt[j*8+i]); } printf("\n"); } } <,C ~ExpressLoad['AB,E IN`,E gnolib jOASJ,E vgalibHH'A0E 'A"= """|;8/ [dںo "fh ںHz "hں "hHH ""፱h) ))ںH"h )H "፱0Hں )H"h8(IںH"hPں"6hHhhںH":e5e7HH"WhںH"hںH"hںH"hںH"[hں"6h[ں/ "hں{i H8 "vhں= "hں{i"HF "vhںK "hں{i$HQ "vhں$H"H H" h&ں&HV "huںa "hں{i(Hj "vhںo "hں{i*Hx "vhں} "hں{i,H "vhں "hں{i.H "vhں.H,H*H(H "hں.H,H*H(H"hLںHH"h/ںo " hں "hںt )H "hںu )H "hںv )H "hںw )H "hںx )H "hںy )H6 "hںz )HJ "hHH ""፱hںHaH"hں"hں"hں{iHT "vhںHH"h,ں5HW "hHH ""፱h*8pI0ʊ&ںH" hںHH"hں"6hH hhںH":e5e7HH"Whں H"hںH"hں "hں "6hں"6hH hhں"6hHhhںH":e5e7HH"Whں H"hںH"hںH"hںH"[hں "6hں"6hں" hں" h8pI0ʊںH"Yhoں-H" hJG: 0 H`c9c c c c c c c |_4c 1706+;i5k Shadow flag: %02X choose command: 1) Set Mode 2) Set Palette 3) Upload data 4) Screen off 5) Screen on 6) Set Border 7) Set text mode 8) Clear Screen 9) Rotate clearscreen A) Scroll up 10 pixels B) Scroll down 10 pixels C) Set Mode for Apple monitor D) Get Status E) Set User Mode F) Set VGA Register G) Get VGA Register H) Upload TARGA I) Shadow On/Off ^C) Quit idxreg: %04Xidxval: %02Xreg: %04Xval: %02X idxreg: %04Xidxval: %02Xreg: %04Xval: %02X%04X %02X %04X %02X Could not locate Second Sight # of status bytes: %d Version: $%02X Shadow status: %d VGA Mode: $%02X Video Ram (0 = 512, 1 = 1MB): %d Monitor type :%02X Bits: %d %Xerror! hit return: %d ; [x " V + + + + + + + H 7(  +;i k;8 [x    c௲  GSȷVȷGȷA믲ઇ   (  +;i k;8 [x " V " " " " " H V௲ H(  +;ik; [ "+;ik; [x "(+;ik; [x " V + + + + + + + + +( H 7 +;i k; [x " V " H(+;ik; [x " V + + H 7(+;ik; [x " V " " " H V + H(+;ik; [x " V + H(+;ik; [x " V " " " " " " H(  +;ik;8 [dx " V + + + + + + + + + + H) V d H V))d dd  H(+;ik ` ` ɥɦ ` ϸ ` ϸ ` H [  "$&(*,.02468:<>@BDFHJLNPRTVXZ\^`bdfhjlnprtvxz|~+`; [x " VT H(+;ikc) sOV]@F(@  c! `OPT(@  S[\ apPc) sOV]@FP@  Ȁß >@P@  ; ["+;ik L<=; [HH J     z +;i k];i[H"x8h[i[hz;m[Zګ)kHHH"$zhZګk%x%yHH"k; [  +hhkh))_kk;8 [# ȗd   +;ik ;[8zeʧ8;ID;oz+zhhZګkH h\<=KzZڭ7H 7H; [rt"v]i # " Ȁ " Ȁ  Z8czHHHH "* Out of memory"<\<=h h  m  Ȁ    )s  "   i  ")0"!)      +hhkKtHrH ;[$DhHHhk֯ "@/+hh` H" H"HH"% H"H"% kraa"7 `R"9 P!\n" fl`Z n.CONSOLEK ;[))%H"   +k! # 0 x). x)l Lh )@ Y|)-,0"+ #+# #8``)*`)0:)H mc%&nT)sR'bs'p&c'X&x&o)u(d'i'f1e1E1g3G3)\K ;[l"nl"{[)) - )) "n) "{%uj "nj"{)A%4 )/%"*[ )] *  +hhlk )* Ί )lh ) D" |" )0":)H   m c  ԭ `d+i+u'-o/-x=-X=-p7-c*sP*b8*n-f4e4E4g4G4%].[Y,\H:h\(((((‚Ą;8 [Kdd)awr Ov! 4!ȷ 4! -wf!" d!?X:a3T!\!" R!XзX!b!V!`!" Z!"6"6  HH"6ȥ ȩ)+bȷ)+arQIv! ȗ+;ik)+8`bv!8``;8 [K ͪ ͬHH"0HH"0 ) ) )   H H &/   ,  c #{i###  # # # # # #K" #?L # #    ) #m# #m#    # #   # # U i  i )8   :  )    I   )   +;i k<$n$". :$" #"- l$$ &  #$  Ȍ# "w6` `L$ . ~$$;8 [ )   2   7 H"]  H":6H H &/  )    H H"0 i ȷ i  8  ȷ :      )  ) H H"0  +;i kHH"!k;8 [KHH".  ) w  HH"6  _ @@ HH"67 ȥ  ȥȗd+;ik )%" 4 P' P'# +Q+,T''%0RN(n'n&n%jJJJJ 0:i P'+( ' & %˭ X P'00 HH ȷ  HH ) %8% )%Z)H" z%hih " )H" !8  I-#HH+S '" &"| 0/ |' +S+ S 8#R + 8I0 )#H"  H" H" 00 H"  0" ȹ+) SZ+)H" zȀ HH )hih `# +Q+,T''%0R( ' & %!N(n'n&n%jJJJJJ 0+R0+0Q`0 " `   h{[` * *  **"nΊh) 抮  Β"n)) ϊ"{$ *8 *:* *  *`"n  Βᭌ *`S,S,W, O,K,M,"n) W,U,+- U,"nW,S,=08O,Β"nW,XxO,Βz"nW,0e8"O,X:N)AFGA)HM,HK,HO,"q.hK,hM,hmK,K,M,Β"nW,"{W,Ί/5U,8K,K,M,M,K, Δ0M,  *` ++,T-)^ - )] ,++ +M-+"n-H ,z=+  Β ԜϘ"{  *`--:JJJ-` Ί *` 3. Z 3.R 3."n[.O.00Β"n[.O.xXΒ "{[.U."n[.O.0^8"U.Q:G)A?G:)HS.HQ.HU.W."q.hQ.hS.hmQ.Q.S.ΒO."{[.[.ΊQ. Δ0S.  *`[.Q.S."n) "{` "n% "{Ί`H; [' .HJ e effff` . Fe jf +;ikKHH; [  8+hhzhhZګk; [ +hzzH`;8 [KH H".-H H"0d   '    )\ "600i荰00  P0"9 0" 0" 0HH"6!  0" 0 )@ H H"6H H"6 ii d  +;i k;8 [KHH".p)dV1X1 Z18X1\1Z1^1 \1" T1 HH &/HH"f1 )d+;ik; [ ȊwHwhȷ+;ik33~ ~3 I-# 8~~ HH "~+ "~0+)e++,0+0! D330++eE+0,) +P-,T610++0 :++.++ 蘼++0#+)8I0 )#H" 00 0" +)+Z)H" zi 0,.+#+ ,e+0 ~38. ~30`+ ,++`44 ~ HH "I!)m:4484K5G5Β"n) Β+- $5 5]0H0 $5hI5 .5E. $5 58 .53eE% $5 5!+- $5 5I5 .5"{K5ΊQWG5*)0:0 $5+"M5H H HΔ  "  "ᭌ *` "nK5Β`8`G5+G5`0: $5 5I5`; [KHH6566 "669:6506 "06( "኉&666 Z6eiz  +;ikhf<~@L=6; [u69g6" e6+;iku6Lz6; [696" 6+;ik6; [8"R8"e7+hhk ":";hhk77'7HHH8H; [  "9 % Q8  0 "\= "\= "9e i @< "\= "\=   "9Z "\="R8+;i kHH8H; [=ȷ=ȷ HH"+hhhhkH; ["?=ȿ===+hhk ;8[IȅIdFejfFejfFejfFejfFEejfFejfFejfFejf2-I;i+ke &****;i+@kHiH;8  [  "? ==O$>";> >ȩȗ na i  U GE== "\=F e i  "9 "98  0 E == "\=) i+;iki菸<<<HH<H<HH<@@<H "hh<) <kHH; [=ȗ=ȗȥȥȩ== ==i+zzzzk; [  )8 I"A )L  ! )H":6  ( ":6 )H"w6   "w6 +;i kH" >"b?"$?h") T=HHHHH; ["?==  ȷݠ=ȷ= ȷ+;i kHZ"w?" ?"5?">"S>kK99Q>" O>99Q>" O>99Q>" O>kK8999 "?999>"9 >!>>" >>9 "?9 "?9k> >.CONSOLEK 777C7E7?7A797;75777kHH;H" ;[+!7hhk"@H"k37H "h!7Hi!7 "37k37 "37kKzh 7h7h Zګk:JJJJk;8  [d 9@"7 @ @HH HHH?"0" "zj @@@@@@ @" @$"8 @@" @@HH"  +;i k(K==&=kH ;[ ":6 "w6+hkz Wo!I7Op5Vn 'Bi#Bon@VqYo +fn~ '08>FW^ckzPm7>TZh (CVh"zot} #BOasz+@r94\= T,MqA]=K^g7Wfrx "D^h,0(Qi#2?Gow PV`  .:\d)>BFPjnt 4If{ %)9H^cs|6BUn +o j.Tl΁4Lm2Sk ?f{ 5?Z402468:<>@BDFHJLNPRTVXZ\^`b "',16;@DGbejm$',16;@EHknsx}Pw~+PSWy~ #wz 25JM).>HW_ly  c $(,048<@DHLPTX\`dh147:LDLRXbjrz.1%  %(,/25:ADI*3HPSXco| %6Egl;@LQ]`fo"#&)19=JQTadnu  "(+.3;@H]cfly" $(0;>EHPZadq{ #(047:Bkn-2< !'$*7>AHKNSX]bilx}!'IQX]gnx  %-6CFT[^hkp%(+9AWZ]`jmpsQ !$.I\1j*3Qz i / 18 I= jF K Q V a j /o Px h}     <o c      6 <J T W $]~%(0D3D}&,&+'(+),)+i,+j,+1~ 22~!2'2+2,2-3~34+Z56`55f56555065065&656??0E gnolib ;8  [  H{iH"xH"#   +;ik;8z [{iHhchc{iHhchchhhh) X{iHhhHHhchchhch~H" H"6    H~H hiH" h#h% EG)3)!))' H{iH"xH"#  ) ~Y h[h]_)a H{iYH"xH"#  H{iH"xH"#  {iH"C!  {iH"C))IMq{isH!uIKHhwhy H{iqH"xH"#  H"6{iH"C!! H"6 {iH"C|{+;ik;8 [ $"hh(&Hhh H{i H"xL *H"#  ('+;i&k;8 [ I P | tld\ TLD8C H`IQQQYaaiqqqy +;i k&UDh #include #include #include #include #include #include #include vga_status_rec vs; extern int vgaErr; int main(int argc, char *argv[]) { char x; int val; char *pal,*buf; int fd; int bord = 1; int i; int shfl = 0; int modenum; vgaStartup(&vs); while (1) { printf("\014Shadow flag: %02X\n",shfl); printf("choose command:\n" "1) Set Mode 2) Set Palette\n" "3) Upload data 4) Screen off\n" "5) Screen on 6) Set Border\n" "7) Set text mode 8) Clear Screen\n" "9) Rotate clearscreen A) Scroll up 10 pixels\n" "B) Scroll down 10 pixels C) Set Mode for Apple monitor\n" "D) Get Status E) Set User Mode\n" "F) Set VGA Register G) Get VGA Register\n" "H) Upload TARGA I) Shadow On/Off\n" "^C) Quit\n" ); x = ReadChar(0); if ((x & 0x7F) == 3) exit(0); WriteChar(x); switch (toupper(x)-'0') { case 0x19: shfl ^= 4; _SetShadow(shfl); break; case 0x18: buf = malloc(512l*1024); fd = open(argv[1],O_RDONLY); read(fd,buf,0x12l); read(fd,buf,512l*1024); close(fd); _UploadData(FL_DATA,0l,512l*1024-2,buf); free(buf); break; case 0x17: { int idxreg,idxval,reg,val; printf("idxreg:\n"); scanf("%04X",&idxreg); printf("idxval:\n"); scanf("%02X",&idxval); printf("reg:\n"); scanf("%04X",®); val = _GetVGAReg(idxreg,idxval,reg); printf("val: %02X\n",val); } break; case 0x16: { int idxreg,idxval,reg,val; printf("idxreg:\n"); scanf("%04X",&idxreg); printf("idxval:\n"); scanf("%02X",&idxval); printf("reg:\n"); scanf("%04X",®); printf("val:\n"); scanf("%02X",&val); printf("%04X %02X %04X %02X\n",idxreg,idxval,reg,val); _SetVGAReg(idxreg,idxval,reg,val); } break; case 0x15: _SetMode(0xFF,1); break; case 0x14: if (_GetStatus(&vs) == -1) printf("\nCould not locate Second Sight\n"); printf("# of status bytes: %d\n",vs.size_rec); printf("\nVersion: $%02X\n",vs.version); printf("Shadow status: %d\n",vs.shadow_status); printf("VGA Mode: $%02X\n",vs.vga_mode); printf("Video Ram (0 = 512, 1 = 1MB): %d\n",vs.video_ram); printf("Monitor type :%02X\n",vs.monitor_type); printf("Bits: %d\n",vs.bits); ReadChar(0); break; case 0x13: _SetMode(0x61,1); break; case 0x12: _ScrollScreen((void *)0l,(void *)6400l,307200l-6400l); break; case 0x11: _ScrollScreen((void *)6400l,(void *)0l,307200l-6400l); break; case 1: scanf("%X",&modenum); if (vgaSetMode(modenum,1)) { printf("error! hit return: %d\n",vgaErr); ReadChar(0); } break; case 9: for (fd = 0; fd < 256; fd++) _ClearScreen(fd,00000l,307200l); break; case 7: _SetMode(0x03,0); break; case 2: pal = malloc(768l); fd = open(argv[1],O_RDONLY); read(fd,pal,768l); close(fd); _SetPalette(pal); free(pal); break; case 3: pal = malloc(768l); buf = malloc(512*1024l); fd = open(argv[1],O_RDONLY); read(fd,pal,768l); read(fd,buf,512*1024l); close(fd); _UploadData(FL_DATA,0l,512*1024l-1,buf); free(pal); free(buf); break; case 4: _ScreenOff(); break; case 5: _ScreenOn(); break; case 6: bord ++; if (bord > 15) bord = 0; _SetBorder(bord); break; case 8: _ClearScreen(45,00000l,307200l); break; } } } 'TSCROLL5)TSCROLL.CT5Ӿ "UP:'53UP.C.53VGA/"XX:5.#XXX=58 U,C ~ExpressLoadU ,E -0E ""4""+;8  [ں"hںHH"Sh 8 pI0ʊ)ں"h ںHH"Sh+;i kc! `OPT(@  H h\KzZڭHH; [!#"%]i # " Ȁ " Ȁ  Z8czHHH)H "* Out of memory"\h h  m  Ȁ    )s  "   i  ")0"!)      +hhkK#H!H ;[$hHHhk֯I G  " +hh`G I  H"/? A  H"/C E E HC H"P  H"/; = H"P kraa"7 `"9 ! " `  .CONSOLE;8 [Kdd)awr 'O ȷ  '-w" ?X:a3" Xз" ""  HH"S'G I G I ȥ ȩ)+bȷ)+arQI ȗ+;ik)+8`b8``;8 [K ?  A E HC H"8 = H; H"8  ) ) )   H H    ,  c d{ibfh  b d f h ` rK" ^?L j l    ) bmj dml    j l   j l U i  i )8   :  )    I   )   +;i k ". " ^"-   &  j  Ȍj "` ` .  7 ;8 [ )   2   7 H"   H"H H  )    H H"8  i ȷ i  8  ȷ :      )  ) H H"8  +;i k;8 [KHH"K   ) w  HH"  _ @@ HH"S7 ȥ  ȥȗd+;ikKI HG H; [  '8+hhzhhZګk; [ '+hzzH`E HC HH"9 zhZګk;8 [KH H"K -H H"8 dG I   G I '    )\ ". 0 i4 6  P* "9 ( " $ " 2 HH"S! ͯ & " $  )@ H H"SH H"S ii d  +;i k;8 [KHH"K p)d   8  " HH HH"  )d+;ik; [ ȊwHwhȷ+;ik_\L; [o" +;ikL; [QmC" A+;ikQ; [8""+hhk ""hhkHHH8H; [  "y % Q8  0 "6 "6 "ye i @< "6 "6   "yZ "6"+;i kHH8H; [ȷȷ HH"+hhhhkH; ["jȿ+hhkHiH;8  [  "j O$>"ȩȗ na i  U GE "6F e i  "y "y8  0 E  "6) i+;iki菒HHHH)H@@H "hh) kHH; [ȗȗȥȥȩ i+zzzzk; [  )8 I" )L  ! )H"  ( " )H"   " +;i kH""<"h") .HHHHH; ["j  ȷݠȷ ȷ+;i kHZ"Q""""-kKqk+" )sm+" )uo+" )kKeegi "{kwk"9 !ٰ" w "{m "{ok .CONSOLEK kHH;H" ;[+hhk")H"kH "hHi "k "kKzhhh )Zګk:JJJJk;8  [d ]d"7 b fHH HHH{"0" "zj `lv^jt \" Z$"8 hn" prHH"  +;i k(K&kH ;[ " "+hk; [x           (   +;i k; [x      (+;ik; [x  T (+;ik ` ` ɥɦ ` ϸ ` ϸ ` *D1V  Y_v| *DHN #@Up "8=MV[c/$'-EIPS(-&)/58@CIOWZlp{ ks{ ,38A\_dilo,Fx{#include #include #include #include #include /* E$22:$08: 3.45 8.69fps E$22:$0C: 2.00 15 fps No caching: 3.45 */ vga_mode_rec vga_regs_61 = { 0x63, 0x21, 0x00, 0x0f,0x00,0x0A, 0x60,0x4f,0x50,0x83,0x54,0x80,0xbf,0x1f, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x9f,0x81,0x8f,0x28,0x00,0x96,0xb9,0xc3, 0x0ff, 0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0f, 0xff, 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f, 0x01,0x00,0x0F,0x00,0x00, 0x05,0x10,0x07,0x00,0x00, /*0xc8,0x00,0x00,0x00,0x0f,*/ 0x08,0x00,0x00,0x00,0x0f, 0x05,0x04,0x0C,0x00, 0x00,0x00,0x00,0x00,0x00,0x00 }; int main() { int i; _SetUserMode(&vga_regs_61); _SetMode(0xFF,1); for (i = 0; i < 30; i++) { _ScrollScreen((void *)0l,(void *)6400l,128000l-6400l); } _SetMode(0x00,0); }  !"#$%&'()*+,-,C ~ExpressLoadQ7,E C"&\,E gnolib !0E "Y"/""&;8 [ںH"qhں"thH  hhںH"eeHH"h ں H"0hHhhں H H"hں HHHH"3hںH"qh+;ik; [x _  h h h h h  q(  +;ik; [x _  h (+;ik;8 [dx _  h h h h h h h h h h )    ))d d  (+;ik ` ` ɥɦ ` ϸ ` ϸ ` H [  "$&(*,.02468:<>@BDFHJLNPRTVXZ\^`bdfhjlnprtvxz|~+`; [FHJ"f+;ik; [HH J     z +;i k; [  +hhk ;[8$eʧ8;ID;o$+zhhZګkH h\KzZڭHH; [" ]i # " Ȁ " Ȁ  Z8czHHHbH "* Out of memory"N\h h  m  Ȁ    )s  "   i  ")0"!)      +hhkKHH ;[$hHHhk֯<: "+hh`:< H"" 24 H"" 688H6H"C H"" .0H"C kraa"7 `"9 !  "   `  .CONSOLE;8 [Kdd)awr `O  ȷ `-w " ?X:a3 " Xз " "t"t  HH"F`:<:<ȥ ȩ)+bȷ)+arQI  ȗ+;ik)+8`b 8``;8 [K 2 48H6H"+0H.H"+ ) ) )   H H    ,  c W {iU Y [  U W  Y  [  S  e K" Q ?L ] _    ) U m] W m_    ] _   ] _  U i  i )8   :  )    I   )   +;i k ". " Q "-  &  ]   Ȍ] " ` ` .  *;8 [ )   2   7 H"  H"H H   )    H H"+ i ȷ i  8  ȷ :      )  ) H H"+  +;i k;8 [KHH">  ) w  HH"t  _ @@ HH"F7 ȥ  ȥȗd+;ikK<H:H; [  `8+hhzhhZګk; [ `+hzzH`8H6HH",zhZګk;8 [KH H">-H H"+d:<  : <'    )\ "t!#i')  P"9 " " %HH"F! ͪ "  )@ H H"FH H"F ii d  +;i k;8 [KHH">p)d 8 "  HH HH" )d+;ik; [ ȊwHwhȷ+;ikR\L; [b" +;ikL ; [D`6" 4+;ikD; [8""+hhk "\"shhkHHH8H; [  "l % Q8  0 " " "le i @< " "   "lZ ""+;i kHH8H; [qȷsȷ HH"+hhhhkH; [""uȿwuw+hhk ;8[IȅIdFejfFejfFejfFejfFEejfFejfFejfFejf2-I;i+ke &****;i+@kHiH;8  [  "" uwO$>"sȩȗ na i  U GEwu "F e i  "l "l8  0 E uw ") i+;ikiJLHHHLHJHbHL@@HH "hhH) HkHH; [qȗsȗȥȥȩqs qsi+zzzzk; [  )8 I" )L  ! )H"  ( " )H"    "  +;i kH"""h") HHHHH; [""uw  ȷݠuȷw ȷ+;i kHZ" """r"kKd^" f`" hb" kKXXZ\ "3^j^L"9 J!Vh" `fj "3` "3bkT h.CONSOLEK kHH;H" ;[+hhk"bH"kH "hHi "k "kKzhhh bZګk:JJJJk;8  [d P"7  HH HHH3"0" "zj $.", " $"8 &" (*HH"  +;i k(Kqs&ukH ;[ " " +hk (@h39?M,Q 7No Tv#3?t~j-Z BGr  IxB 8^e!\f szw#DJRUgkv| ^fn &+/7;~  ?BvyfilQT^apW_gps{~4 /2 #include #include #include #include #include int main(int argc, char *argv[]) { byte *data; int fd; long sz; /* So the hires area won't be overwritten by shadowing */ _SetShadow(4); data = malloc(32768l); fd = open(argv[1],O_RDONLY); sz = read(fd,data,32768l); _UploadData(FL_CODE,(void*)0x002000l,sz,data); _RunCode(0x00,0xF2,0x00,0x2000); _SetShadow(0); } VGAv' 'M1280X480.50M0o5ƾ /M320X40032K1o5;" /M40X24.VGA2o5/M560X192.VGA3o5/M640X40032K.50M4o5Ǿ1/M640X48016M5o5ɾ /M640X48032K.50M6o5Ǿ/,M800X600.36M75ɾ" /ß >@P@  c) sOV]@F(@  Ȁg-'(+O-  c!_EFO( ß@ P@  bNPT >@x@   ß >@P@  89 db 0EFh ; misc out reg db 001h ; clocking mode reg db 000h ; feature ctl db 00Fh,000h,00Eh ; Sequencer regs db 07Bh,063h,064h,09Eh,06Bh,092h,06Fh,0F0h ; Sequencer regs db 000h,060h,000h,000h,000h,000h,000h,000h ; Sequencer regs db 058h,08Ah,057h,032h,00Fh,058h,06Fh,0E3h ; Sequencer regs db 0FFh db 000h,000h,000h,000h,000h,040h,005h,00Fh ; Graphics Regs db 0FFh db 000h,001h,002h,003h,004h,005h,006h,007h ; $00 - $07 Attribute regs db 008h,009h,00Ah,00Bh,00Ch,00Dh,00Eh,00Fh ; $08 - $0F db 001h,000h,00Fh,000h,000h ; $10 - $14 db 005h,010h,007h,000h,007h ; $02 - $06 Extended regs db 0C8h,000h,000h,000h,00Fh ; $13..$15,$17, & $19 db 005h,004h,00Ch,000h ; $30..$22, $25 db 000h,000h,000h,000h,000h,000h ; $30..$35 ;< db 067h ; misc out reg db 029h ; clocking mode reg db 001h ; feature ctl db 00Fh,000h,006h ; Sequencer regs db 03Fh,027h,02Eh,09Ah,033h,09Ah,000h,001h ; Sequencer regs db 000h,040h,000h,000h,000h,000h,000h,000h ; Sequencer regs db 0DAh,03Ah,0C0h,014h,01Fh,0E1h,0E7h,0E3h ; Sequencer regs db 0FFh db 000h,000h,000h,000h,000h,000h,005h,00Fh ; Graphics Regs db 0FFh db 000h,001h,002h,003h,004h,005h,006h,007h ; $00 - $07 Attribute regs db 008h,009h,00Ah,00Bh,00Ch,00Dh,00Eh,00Fh ; $08 - $0F db 001h,000h,00Fh,000h,000h ; $10 - $14 db 005h,010h,007h,000h,005h ; $02 - $06 Extended regs db 0C8h,000h,000h,000h,00Fh ; $13..$15,$17, & $19 db 005h,000h,008h,000h ; $30..$22, $25 db 000h,000h,000h,000h,000h,000h ; $30..$35 >? db 067h ; misc out reg db 028h ; clocking mode reg db 001h ; feature ctl db 00Fh,000h,006h ; Sequencer regs db 039h,027h,02Bh,09Ah,031h,09Ah,000h,001h ; Sequencer regs db 000h,040h,000h,000h,000h,000h,000h,000h ; Sequencer regs db 0DAh,03Ah,0C0h,014h,01Fh,0E1h,0E7h,0E3h ; Sequencer regs db 0FFh db 000h,000h,000h,000h,000h,000h,005h,00Fh ; Graphics Regs db 0FFh db 000h,001h,002h,003h,004h,005h,006h,007h ; $00 - $07 Attribute regs db 008h,009h,00Ah,00Bh,00Ch,00Dh,00Eh,00Fh ; $08 - $0F db 001h,000h,00Fh,000h,000h ; $10 - $14 db 005h,010h,007h,000h,005h ; $02 - $06 Extended regs db 0C8h,000h,000h,000h,00Fh ; $13..$15,$17, & $19 db 005h,000h,008h,000h ; $30..$22, $25 db 000h,000h,000h,000h,000h,000h ; $30..$35 SVIEWv' ''A3200.CA5ξ3@.ADDING.MODULESE5ET-@BERKEKJ5@BUGSL58 @DEBUGM5ž@)IQGIF.ASMN6Ch5@)IQGIF.MAC 5ž@LINKSCRP5 ξ@LS2`5 8@(MAKEFILE5ξ@'OCT24.C5;7@(OCTREE.C3c5þ5 @BCD#include #include #include #include #include #include #include #include "pic.h" #pragma noroot segment "a3200"; #pragma lint -1 typedef word colorTable[16]; typedef struct raw_3200 { byte pix_data[32000]; colorTable tables[200]; } raw_3200; word conv4bitTo5(word x) { word r,g,b; r = (x & 0x0F00) << 3; g = (x & 0x00F0) << 2; b = (x & 0x000F) << 1; return (r | g | b); } static word loctab[16]; int load_raw3200(int fd, image *rec) { raw_3200 *rw; word i,j,x; byte *buf; word *outbuf; handle bufhndl,outhndl; byte p; bufhndl = NewHandle(sizeof(raw_3200),userid(),0,0l); HLock(bufhndl); rw = (raw_3200 *) *bufhndl; read(fd,rw,sizeof(raw_3200)); buf = rw->pix_data; outhndl = NewHandle(128000l,userid(),0,0l); HLock(outhndl); outbuf = (word *) *outhndl; for (i = 0; i < 200; i++) { for (j = 0; j < 16; j++) { loctab[j] = conv4bitTo5(rw->tables[i][15-j]); } for (j = 0; j < 160; j++) { p = *buf++; *outbuf++ = loctab[(p & 0xF0) >> 4]; *outbuf++ = loctab[p & 0x0F]; } } HUnlock(bufhndl); DisposeHandle(bufhndl); rec->height = 200; rec->width = 320; rec->depth = 15; rec->type = IMAGE_3200; rec->palette_size = 0; rec->palette = NULL; rec->map = (void *) *outhndl; rec->mapHandle = outhndl; return 0; } FGHIJIf you'd like to add a module to Second View (I have other things to do :-) there are a couple things you need to know. Also be sure to send new modules you write my way so I can put them in the regular distribution! -- /* This is an example of a picture load module */ int load_picture(int fd, image *rec) 'fd' is a GS/OS refnum of the open picture file. Simple enough. 'rec' is a pointer to an "image" structure. This structure describes the picture bitmap in detail. typedef struct image { word height; /* height of image in scanlines */ word width; /* width of image in pixels/bytes */ int depth; /* pixel depth - 1, 2, 4, 8, 16, or 24 */ int type; /* image type - see above defines */ int palette_size; /* number of palette entries */ struct rgb_24 *palette; void *map; /* pointer to the pixel map */ char *fname; /* filename of image file */ char *pathname; /* full pathname of image file */ void *mapHandle; /* Handle of the pixel map */ } image; You should allocate a Memory Manager handle to store the pixel map in. Put the handle in mapHandle, and a pointer to the pixelMap in 'map'. 'Height' is the height of the pixelMap in pixels. 'width' is the width of the pixelMap in pixels. 'depth' is the bit-depth of the image; 8 for pseudo-color (256 color palette), 15 or 16 for TARGA/High-Color, or 24 for true color. This will tell SecondView's display routines which video mode would be the best to use. The image 'type' field is one of the following: #define IMAGE_GIF 1 #define IMAGE_TIFF 2 #define IMAGE_PICT2 3 #define IMAGE_TARGA 4 #define IMAGE_3200 5 When you add image types, you'll want to add 'type' definitions to this list. Thermometer ----------- If you'd like to use a load thermometer, it's all ready for your use. Call init_thermo(value) to put up the thermometer window (value is the thermo's full-scale value). Call advance_thermo each time you complete a scanline or block. advance_thermo increments the thermo value by one. Call kill_thermo when you're done loading the image. You should have set the "pathname" and "fname" fields of the image structure before you call init_thermo. Dan Berke c/o Alfred Schimmel 250 West 57th Street, Ste 2318 NY NY 10107 TIFF support is flaky! DebugSymbols gequ 1 OPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~************************************************************************** * * ImageQuant * by Tim Meekins * * Copyright (c) 1994 by Tim Meekins * ************************************************************************** * * iqgif.asm * * ImageQuant GIF loading routines * ************************************************************************** case on mcopy iqgif.mac copy debug ;------------------------------------------------------------------------- ; LoadGIF ; Load a GIF ;------------------------------------------------------------------------- _MapPtr gequ 14 _MapHandle gequ 26 LoadGIF START ptr equ 1 colormap equ ptr+4 giftype equ colormap+4 row equ giftype+2 image equ row+4 bitpixel equ image+4 rcmnum equ bitpixel+2 globcolortab equ rcmnum+2 c equ globcolortab+4 lbitpixel equ c+2 loccolortab equ lbitpixel+2 bitres equ loccolortab+4 height equ bitres+2 width equ height+2 img_h equ width+2 sp equ img_h+2 cmap equ sp+2 fresh equ cmap+4 incode equ fresh+2 code_size equ incode+2 set_code_size equ code_size+2 max_code equ set_code_size+2 max_code_size equ max_code+2 firstcode equ max_code_size+2 oldcode equ firstcode+2 clear_code equ oldcode+2 end_code equ clear_code+2 curbit equ end_code+2 lastbit equ curbit+2 curbyte equ lastbit+2 doneflag equ curbyte+2 last_byte equ doneflag+2 count equ last_byte+2 ret equ count+2 j equ ret+2 rowind equ j+2 result equ rowind+2 outbuf equ result+2 hndl equ outbuf+4 space equ hndl+4 sub (4:rec,4:raw),space ; ; Check for AOL GIF header by seeing if the GIF header is at +$20 ; stz result ldy #$20 lda [userid pha pea 0 pea 0 pea 0 _NewHandle pla plx sta userid pha pea 0 pea 0 pea 0 _NewHandle pla plx sta "{",.chk2 &char amid &parm,l:&parm,1 aif "&char"<>"}",.error &parm amid &parm,2,l:&parm-2 ldy #2 lda (&parm),y pha lda (&parm) pha ago .shorten .chk2 aif "&char"<>"[",.absolute ldy #2 lda &parm,y pha lda &parm pha ago .shorten .absolute lda &parm+2 pha lda &parm pha ago .shorten .directpage &char setc t: aif &char&parm<>"G",.chk0 pei (&parm+2) pei (&parm) ago .done .at &char1 amid &parm,2,1 &char2 setc &char1 ph&char1 aif l:&parm<3,.chk2a &char2 amid &parm,3,1 .chk2a ph&char2 ago .shorten .immediate &parm amid &parm,2,l:&parm-1 pea +(&parm)|-16 pea &parm ago .done .shorten aif s:longa=1,.done sep #%00100000 .done mexit .error mnote "Missing closing '}'",16 mend macro &lab long &stat &lab anop lcla &t lcla &len lclc &ch &t seta 0 &len seta l:&stat .a aif &len=0,.b &ch amid &stat,&len,1 aif ("&ch"="x").or.("&ch"="y").or.("&ch"="i"),.i aif ("&ch"="a").or.("&ch"="m"),.m .c &len seta &len-1 ago ^a .i longi on &t seta &t+16 ago ^c .m longa on &t seta &t+32 ago ^c .b aif &t=0,.d rep #&t .d mend macro &lab short &stat &lab anop lcla &t lcla &len lclc &ch &t seta 0 &len seta l:&stat .a aif &len=0,.b &ch amid &stat,&len,1 aif ("&ch"="x").or.("&ch"="y").or.("&ch"="i"),.i aif ("&ch"="a").or.("&ch"="m"),.m aif ("&ch"="t"),.t .c &len seta &len-1 ago ^a .i longi off &t seta &t+16 ago ^c .m longa off &t seta &t+32 ago ^c .t &t seta &t+4 ago ^c .b aif &t=0,.d sep #&t .d mend macro &l sub &parms,&work &l anop aif c:&work,.a lclc &work &work setc 0 .a gbla &totallen gbla &worklen &worklen seta &work &totallen seta 0 aif c:&parms=0,.e lclc &len lclc &p lcla &i &i seta c:&parms .b &p setc &parms(&i) &len amid &p,2,1 aif "&len"=":",.c &len amid &p,1,2 &p amid &p,4,l:&p-3 ago .d .c &len amid &p,1,1 &p amid &p,3,l:&p-2 .d &p equ &totallen+4+&work &totallen seta &totallen+&len &i seta &i-1 aif &i,^b .e tsc aif &work=0,.f sec sbc #&work tcs .f phd tcd mend macro &l ret &r &l anop lclc &len aif c:&r,.a lclc &r &r setc 0 &len setc 0 ago .h .a &len amid &r,2,1 aif "&len"=":",.b &len amid &r,1,2 &r amid &r,4,l:&r-3 ago .c .b &len amid &r,1,1 &r amid &r,3,l:&r-2 .c aif &len<>2,.d ldy &r ago .h .d aif &len<>4,.e ldx &r+2 ldy &r ago .h .e aif &len<>10,.g ldy #&r ldx #^&r ago .h .g mnote 'Not a valid return length',16 mexit .h aif &totallen=0,.i lda &worklen+2 sta &worklen+&totallen+2 lda &worklen+1 sta &worklen+&totallen+1 .i pld tsc clc adc #&worklen+&totallen tcs aif &len=0,.j tya .j rtl mend MACRO &lab _LongMul &lab ldx #$0C0B jsl $E10000 MEND MACRO &lab _NewHandle &lab ldx #$0902 jsl $E10000 MEND MACRO &lab name &lab anop aif DebugSymbols=0,.pastName brl pastName&SYSCNT dc i'$7771' dc i1'L:&lab',c'&lab' pastName&SYSCNT anop .pastName MEND o/ssv o/picview o/iqgif o/tiff o/pict o/targa o/a3200 o/query o/oct24 o/octreea o/ssv o/picview o/iqgif o/tiff o/pict o/targa o/a3200 o/query o/oct24 o/octreea ../lib/o/vgalib # 2/orcacdefs/vgalib.h: vgalib.h cp vgalib.h 2/orcacdefs o/ssv.root: ssv.c ssv.h compile +w +e ssv.c keep=o/ssv o/picview.a: picview.c compile +w +e picview.c keep=o/picview #o/pich.root: pich.asm # compile +w pich.asm keep=o/pich o/oct24.a: oct24.c compile +w +e oct24.c keep=o/oct24 o/octreea.root: octreea.asm compile +w octreea.asm keep=o/octreea o/iqgif.root: iqgif.asm compile iqgif.asm keep=o/iqgif o/tiff.a: tiff.c compile tiff.c keep=o/tiff o/pict.a: pict.c compile pict.c keep=o/pict o/a3200.a: a3200.c compile a3200.c keep=o/a3200 o/targa.a: targa.c compile targa.c keep=o/targa o/query.a: query.c compile query.c keep=o/query #vgaview: o/picview.a o/pich.root o/octree.root o/iqgif.root # link o/picview o/pich o/octree o/iqgif ../gsvga/lvga keep=vgaview ssview: o/ssv.root ssv.tmp o/picview.a o/iqgif.root o/tiff.a o/query.a \ o/octreea.root o/oct24.a o/pict.a o/targa.a o/a3200.a compile linkscr keep=ssview duplicate -R ssv.tmp ssview chtyp -t s16 -a \$DB07 ssview /* * octree.c * * This is the octree quantization method. Pulled from discQuest * and modified for use with 24-bit images. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "ssv.h" #include "pic.h" #pragma noroot #pragma optimize 15 #pragma lint -1 #undef tree extern struct prefs dqPrefs; byte newpal[256]; /* original 256 palette entries mapped to our 16-color pal */ /* This code implements the alogrithm described in: * Graphic Gems edited by Andrew Glassner * Article: A Simple Method for Color Quantisation: * Octree Quantisation, pg. 287 ff * by: Michael Gervautz, Werner Purgathofer * Technical University Vienna * Vienna, Austria */ /* Written by wRZL (Wolfgang Stuerzlinger) */ /* This code is hereby placed in public domain */ UINT bittbl[16] = {0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080, 0x0100,0x0200,0x0400,0x0800,0x1000,0x2000,0x4000,0x8000}; #define RGB(r,g,b) ((ULONG)(r) << 16 | (g) << 8 | (b)) /*#define TESTBIT(a,i) (((a)&(1<<(i)))>>(i))*/ #define TESTBIT(a,i) (((a)&(bittbl[(i)]))>>(i)) #define MAXCOLOR 256 #define MAXDEPTH 7 struct color { UCHAR b; UCHAR g; UCHAR r; }; struct colorsum { ULONG b; ULONG g; ULONG r; }; typedef struct node { UINT leaf; UINT level; UINT colorindex; UINT children; ULONG colorcount; struct colorsum rgbsum; struct node * nextreduceable; /* OCTREE */ struct node * next[8]; /* octree */ } node, *OCTREE; UINT size; UINT reducelevel; UINT leaflevel; ULONG colortable[MAXCOLOR]; FILE *file; OCTREE tree = NULL; OCTREE reducelist[MAXDEPTH + 1]; rgb_24 quant_256[256]; UINT quant(OCTREE, struct color); #if 0 UINT quant(OCTREE tree,struct color orig) { if (tree->leaf) return(tree->colorindex); else return(quant(tree->next[ TESTBIT(orig.r,MAXDEPTH - tree->level) * 4 + TESTBIT(orig.g,MAXDEPTH - tree->level) * 2 + TESTBIT(orig.b,MAXDEPTH - tree->level)],orig)); } #endif void initcolortable(OCTREE tree,UINT *index) { UINT i,r,g,b; if (tree != NULL) { if (tree->leaf || tree->level == leaflevel) { colortable[*index] = RGB(tree->rgbsum.r / tree->colorcount, tree->rgbsum.g / tree->colorcount, tree->rgbsum.b / tree->colorcount); tree->colorindex = *index; tree->leaf = 1; b = (colortable[*index]>>16) & 0xFF; g = (colortable[*index]>>8) & 0xFF; r = (colortable[*index]) & 0xFF; quant_256[*index].r_val = r; quant_256[*index].g_val = g; quant_256[*index].b_val = b; *index = *index + 1; } else { for (i = 0; i < 8; i++) initcolortable(tree->next[i],index); } } } OCTREE nodes = NULL; unsigned node_alloc_ind; /* In our use, we will never get more than about 300 of these things, worst case */ #if 0 void newandinit(OCTREE *tree,UINT depth) { int i; if (nodes == NULL) { nodes = malloc(sizeof(struct node)*500); node_alloc_ind = 0; } if (node_alloc_ind == 500) { printf("out of memory"); exit(1); } else *tree = nodes+(node_alloc_ind++); /**tree = (struct node *) malloc(sizeof(struct node)); if (*tree == NULL) { printf("out of memory"); exit(1); }*/ (*tree)->colorindex = 0; (*tree)->children = 0; (*tree)->colorcount = 0L; (*tree)->rgbsum.r = 0L; (*tree)->rgbsum.g = 0L; (*tree)->rgbsum.b = 0L; (*tree)->nextreduceable = NULL; for (i=0; i<8; i++) (*tree)->next[i] = NULL; (*tree)->level = depth; if (depth >= leaflevel) { (*tree)->leaf = 1; size++; } else (*tree)->leaf = 0; } #endif void getreduceable(OCTREE *node) { UINT newreducelevel; longword max = 0x0; OCTREE nn,nfound,np; newreducelevel = reducelevel; while (reducelist[newreducelevel] == NULL) newreducelevel--; np = nn = reducelist[newreducelevel]; while (nn != NULL) { if (nn->colorcount > max) { max = nn->colorcount; nfound = nn; } nn = nn->nextreduceable; } *node = nfound; if (nfound == np) { reducelist[newreducelevel] = nfound->nextreduceable; } else { nn = np; while (nn->nextreduceable != nfound) nn = nn->nextreduceable; nn->nextreduceable = nfound->nextreduceable; } } void makereduceable(UINT level,OCTREE node) { node->nextreduceable = reducelist[level]; reducelist[level] = node; } void reducetree(OCTREE tree) { OCTREE node; UINT depth; getreduceable(&node); node->leaf = 1; size = size - node->children + 1; depth = node->level; if (depth < reducelevel) { reducelevel = depth; leaflevel = reducelevel + 1; } } void inserttree(OCTREE *,struct color,UINT,long); #if 0 void inserttree(OCTREE *tree,struct color rgb,UINT depth,long weight) { UINT i,branch; if (*tree == NULL) newandinit(tree,depth); (*tree)->colorcount += weight; (*tree)->rgbsum.r += ((ULONG) rgb.r) * weight; (*tree)->rgbsum.g += ((ULONG) rgb.g) * weight; (*tree)->rgbsum.b += ((ULONG) rgb.b) * weight; if ((*tree)->leaf!=1 && depth < leaflevel) { branch = TESTBIT(rgb.r,MAXDEPTH - depth) * 4 + TESTBIT(rgb.g,MAXDEPTH - depth) * 2 + TESTBIT(rgb.b,MAXDEPTH - depth); if ((*tree)->next[branch] == NULL) { (*tree)->children++; if ((*tree)->children == 2) makereduceable(depth,*tree); } inserttree(&((*tree)->next[branch]),rgb,depth + 1,weight); } } #endif void generateoctree(OCTREE *tree, image *imrec) { extern void count_pixels(byte *,unsigned long cnt); struct color rgb; char *buf = imrec->map; byte *sbuf; int x,y,i; unsigned j; unsigned long pp,pc; UINT c; unsigned long numpix; numpix = (long) imrec->width * (long) imrec->height; size = 0; reducelevel = MAXDEPTH; leaflevel = reducelevel + 1; for (; numpix > 0; numpix--) { rgb.r = *buf++; rgb.g = *buf++; rgb.b = *buf++; inserttree(tree,rgb,0,pc); if (size > MAXCOLOR) /* max number of colors ! */ reducetree(*tree); } } /* example function using the above routines */ int quantize(image *imrec) { UINT i,j,l,colorindex; /* temporary */ FILE *fp; int x,y; struct color rgb; UINT r,g,b; UINT tempvar; byte *buf = imrec->map; unsigned long numpix; numpix = (long) imrec->width * (long) imrec->height; /* reset octree node allocator */ node_alloc_ind = 0; for (i = 0; i < MAXCOLOR; i++) /* init colortable */ colortable[i] = 0L; /* 0 usually is black ! */ for (i = 0; i <= MAXDEPTH; i++) reducelist[i] = NULL; tree = NULL; generateoctree(&tree,imrec); /* read the file through */ i = 0; /* entry 0 is left black here ! */ initcolortable(tree,&i); /* afterwards i contains number of used colors */ for (; numpix > 0; numpix--) { rgb.r = *buf++; rgb.g = *buf++; rgb.b = *buf++; newpal[j] = quant(tree,rgb); /* which color is best ? */ } printf("\n"); WriteChar(10); } /* * octree.c * * This is the octree quantization method. Pulled from discQuest * and modified for use with 24-bit images. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "print.h" #include "pic.h" #include "xmalloc.h" #include "audio.h" #include "../gsvga/vga.h" #pragma lint -1 segment "picview "; #pragma noroot #pragma optimize 15 #define USEMOUSE #define T_BYTE 1 #define T_ASCII 2 #define T_SHORT 3 #define T_LONG 4 #define T_RATIONAL 5 #define RIGHT_SIDE_UP 0 #define UPSIDE_DOWN 1 #define SWITCH_GRAY 2 #define SWITCH_COLOR 3 extern struct prefs dqPrefs; #include "ssv.h" unsigned quant_palette_16[16]; struct rgb_24 orig_palette_256[256]; byte newpal[256]; /* original 256 palette entries mapped to our 16-color pal */ longword pix_count[256]; char *pic_and_audio = NULL; /* This code implements the alogrithm described in: * Graphic Gems edited by Andrew Glassner * Article: A Simple Method for Color Quantisation: * Octree Quantisation, pg. 287 ff * by: Michael Gervautz, Werner Purgathofer * Technical University Vienna * Vienna, Austria */ /* Written by wRZL (Wolfgang Stuerzlinger) */ /* This code is hereby placed in public domain */ UINT bittbl[16] = {0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080, 0x0100,0x0200,0x0400,0x0800,0x1000,0x2000,0x4000,0x8000}; #define RGB(r,g,b) ((ULONG)(r) << 16 | (g) << 8 | (b)) /*#define TESTBIT(a,i) (((a)&(1<<(i)))>>(i))*/ #define TESTBIT(a,i) (((a)&(bittbl[(i)]))>>(i)) #define MAXCOLOR 256 #define MAXDEPTH 7 struct color { UCHAR b; UCHAR g; UCHAR r; }; struct colorsum { ULONG b; ULONG g; ULONG r; }; typedef struct node * OCTREE; struct node { UINT leaf; UINT level; UINT colorindex; UINT children; ULONG colorcount; struct colorsum rgbsum; OCTREE nextreduceable; OCTREE next[8]; }; UINT size; UINT reducelevel; UINT leaflevel; ULONG colortable[MAXCOLOR]; FILE *file; OCTREE tree = NULL; OCTREE reducelist[MAXDEPTH + 1]; UINT quant(OCTREE, struct color); #if 0 UINT quant(OCTREE tree,struct color orig) { if (tree->leaf) return(tree->colorindex); else return(quant(tree->next[ TESTBIT(orig.r,MAXDEPTH - tree->level) * 4 + TESTBIT(orig.g,MAXDEPTH - tree->level) * 2 + TESTBIT(orig.b,MAXDEPTH - tree->level)],orig)); } #endif void initcolortable(OCTREE tree,UINT *index) { UINT i,r,g,b; if (tree != NULL) { if (tree->leaf || tree->level == leaflevel) { colortable[*index] = RGB(tree->rgbsum.r / tree->colorcount, tree->rgbsum.g / tree->colorcount, tree->rgbsum.b / tree->colorcount); tree->colorindex = *index; tree->leaf = 1; b = (colortable[*index]>>20) & 0x0f; g = (colortable[*index]>>12) & 0x0f; r = (colortable[*index]>>4) & 0x0f; quant_palette_16[*index] = ((r << 8) | (g << 4) | b); *index = *index + 1; } else { for (i = 0; i < 8; i++) initcolortable(tree->next[i],index); } } } OCTREE nodes = NULL; unsigned node_alloc_ind; /* In our use, we will never get more than about 300 of these things, worst case */ #if 0 void newandinit(OCTREE *tree,UINT depth) { int i; if (nodes == NULL) { nodes = xmalloc(sizeof(struct node)*300); node_alloc_ind = 0; } if (node_alloc_ind == 300) { printf("out of memory"); exit(1); } else *tree = nodes+(node_alloc_ind++); /**tree = (struct node *) xmalloc(sizeof(struct node)); if (*tree == NULL) { printf("out of memory"); exit(1); }*/ (*tree)->colorindex = 0; (*tree)->children = 0; (*tree)->colorcount = 0L; (*tree)->rgbsum.r = 0L; (*tree)->rgbsum.g = 0L; (*tree)->rgbsum.b = 0L; (*tree)->nextreduceable = NULL; for (i=0; i<8; i++) (*tree)->next[i] = NULL; (*tree)->level = depth; if (depth >= leaflevel) { (*tree)->leaf = 1; size++; } else (*tree)->leaf = 0; } #endif void getreduceable(OCTREE *node) { UINT newreducelevel; longword max = 0x0; OCTREE nn,nfound,np; newreducelevel = reducelevel; while (reducelist[newreducelevel] == NULL) newreducelevel--; np = nn = reducelist[newreducelevel]; while (nn != NULL) { if (nn->colorcount > max) { max = nn->colorcount; nfound = nn; } nn = nn->nextreduceable; } *node = nfound; if (nfound == np) { reducelist[newreducelevel] = nfound->nextreduceable; } else { nn = np; while (nn->nextreduceable != nfound) nn = nn->nextreduceable; nn->nextreduceable = nfound->nextreduceable; } } void makereduceable(UINT level,OCTREE node) { node->nextreduceable = reducelist[level]; reducelist[level] = node; } void reducetree(OCTREE tree) { OCTREE node; UINT depth; getreduceable(&node); node->leaf = 1; size = size - node->children + 1; depth = node->level; if (depth < reducelevel) { reducelevel = depth; leaflevel = reducelevel + 1; } } void inserttree(OCTREE *,struct color,UINT,long); #if 0 void inserttree(OCTREE *tree,struct color rgb,UINT depth,long weight) { UINT i,branch; if (*tree == NULL) newandinit(tree,depth); (*tree)->colorcount += weight; (*tree)->rgbsum.r += ((ULONG) rgb.r) * weight; (*tree)->rgbsum.g += ((ULONG) rgb.g) * weight; (*tree)->rgbsum.b += ((ULONG) rgb.b) * weight; if ((*tree)->leaf!=1 && depth < leaflevel) { branch = TESTBIT(rgb.r,MAXDEPTH - depth) * 4 + TESTBIT(rgb.g,MAXDEPTH - depth) * 2 + TESTBIT(rgb.b,MAXDEPTH - depth); if ((*tree)->next[branch] == NULL) { (*tree)->children++; if ((*tree)->children == 2) makereduceable(depth,*tree); } inserttree(&((*tree)->next[branch]),rgb,depth + 1,weight); } } #endif void generateoctree(OCTREE *tree,struct rgb_24 *pal, byte *buf) { extern void count_pixels(byte *,unsigned long cnt); struct color rgb; byte *bufx = buf; byte *sbuf; int x,y,i; unsigned j; unsigned long pp,pc; UINT c; size = 0; reducelevel = MAXDEPTH; leaflevel = reducelevel + 1; memset(pix_count,0,sizeof(longword)*256); /* Make sure for an odd-sized tiff we only count actual picture pixels, not pixels we stuffed to blank the edges */ if (picture_valid == 2) { sbuf = buf; for (j = 0; j < image_v; j++) { count_pixels(sbuf,image_h); sbuf += image_h_buf; } } else count_pixels(buf,((long)image_h_buf*image_v)); for (j=0; j < 256; j++) { printf("[%d]\n",j); rgb.r = pal[j].r_val; rgb.g = pal[j].g_val; rgb.b = pal[j].b_val; if (pc = pix_count[j]) { inserttree(tree,rgb,0,pc); } if (size > MAXCOLOR) /* max number of colors ! */ reducetree(*tree); } } /* example function using the above routines */ int quantize(struct rgb_24 *pal,byte *buf) { UINT i,j,l,colorindex; /* temporary */ FILE *fp; int x,y; struct color rgb; UINT r,g,b; UINT tempvar; /* reset octree node allocator */ node_alloc_ind = 0; for (i = 0; i < MAXCOLOR; i++) /* init colortable */ colortable[i] = 0L; /* 0 usually is black ! */ for (i = 0; i <= MAXDEPTH; i++) reducelist[i] = NULL; tree = NULL; generateoctree(&tree,pal,buf); /* read the file through */ i = 0; /* entry 0 is left black here ! */ initcolortable(tree,&i); /* afterwards i contains number of used colors */ for (j=0; j < 256; j++) { rgb.r = pal[j].r_val; rgb.g = pal[j].g_val; rgb.b = pal[j].b_val; /*asm { lda rgb+2 pha lda rgb pha lda tree+2 pha lda tree pha jsl quant sta tempvar }*/ newpal[j] = quant(tree,rgb); /* which color is best ? */ } for (i = 0; i < 16; i++) { printf("%04X ",quant_palette_16[i]); } printf("\n"); WriteChar(10); } handle orig_pichandle,remap_pichandle; byte *orig_ptr, *remap_ptr; unsigned init_picview(void) { orig_pichandle = NewHandle(307201l, userid(), 0x4008,0l); if (orig_pichandle == 0l) return 1; remap_pichandle = NewHandle(153601l, userid(), 0x4008,0l); if (remap_pichandle == 0l) { DisposeHandle(orig_pichandle); return 1; } orig_ptr = (byte *) *orig_pichandle; remap_ptr = (byte *) *remap_pichandle; return 0; } int DoAlertC(long alertID, ...) { long str; /* Pointer to input C strings */ long MsgArray[10] ; /* Array of pointers to C strings */ int i; /* Array index */ va_list ap; /* List of elements passed to function */ i=0; /* Init index */ va_start(ap, alertID); /* Init vararg processing */ while ( (str = va_arg(ap,long)) && (i<10) ) { /* List ends w/NULL */ MsgArray[i++] = str ; /* Point to string */ } va_end(ap); /* Got all the strings */ /* Ref is resource w/C substitution strings */ return AlertWindow(4, (Pointer) MsgArray, (Ref) alertID) ; } void ErrDialog(char *f) { InitCursor(); DoAlertC(4l,f,NULL); } unsigned long swap_orderl(unsigned long x) { unsigned long y; asm { lda x xba sta y+2 lda x+2 xba sta y } return y; } unsigned swap_orders(unsigned x) { unsigned y; asm { lda x xba sta y } return y; } unsigned display_squished(byte *bitmap, void *palette) { int x; unsigned f; EventRecord ev; char c; shrinkpic(bitmap); /* small event loop to wait for mouse click or "space" pressed */ memset(&ev,0,sizeof(EventRecord)); while (1) { f = GetNextEvent(0x040A, &ev); if (f) { if (ev.what == mouseDownEvt) return 0; if (ev.what == keyDownEvt) { c = ev.message & 0x7F; if (c == 0x20) return 1; else if (toupper(c) == 'C') return SWITCH_COLOR; else if (toupper(c) == 'G') return SWITCH_GRAY; } } } } unsigned display_reg(byte *bitmap, void *palette, int orient, int xsize, int ysize) { int line; int top = 280; int left = 0; byte *shr; byte *bitptr; int x; unsigned l1,t1,oldl1 = 0xFFFF,oldt1 = 0xFFFF,f; EventRecord ev; char c; word ximgwidth = image_h_buf/2; extern drawimageru(int,int,void *); extern drawimageud(int,int,void *); ysize -= 200; if (ysize < 0) ysize = 0; /* i.e., picture smaller than one screen */ xsize = (xsize / 2) - 160; if (xsize < 0) xsize = 0; /* pic is smaller than screen this way, too! */ while (1) { f = GetNextEvent(0x040A, &ev); if (f) { if (ev.what == mouseDownEvt) return 0; if (ev.what == keyDownEvt) { c = ev.message & 0x7F; if (c == 0x20) return 1; else if (toupper(c) == 'C') return SWITCH_COLOR; else if (toupper(c) == 'G') return SWITCH_GRAY; } } else { if (orient) top = ysize - ev.where.v; else top = ev.where.v; left = ev.where.h; if (top > ysize) top = ysize; if (top < 0) top = 0; if (left > xsize) left = xsize; if (dqPrefs.mouse) { top = ysize - top; left = xsize - left; } l1 = left; /* no divide by ten */ t1 = top; /* no divide by ten */ if ((oldl1 != l1) || (oldt1 != t1)) { if (orient) bitptr = bitmap + ((long)ximgwidth * (top + 199) + left); else bitptr = bitmap + ((long)ximgwidth * top + left); if (orient) drawimageud(ximgwidth,160, bitptr); else drawimageru(ximgwidth /* 320*/,160,bitptr); oldl1 = l1; oldt1 = t1; } } } } int waitForMouse(void) { EventRecord ev; unsigned f; while (1) { /* Don't let them into the Control Panel! */ f = GetNextEvent(0x000A, &ev); if (f) if (ev.what == mouseDownEvt) return 0; } } void drive_display(byte *bitmap, void *palette, unsigned orient, int xsize, int ysize) { static unsigned oldpal[16]; ClampRec oldcl; unsigned tt = dqPrefs.size; unsigned done = 0; unsigned did_quant = dqPrefs.render; unsigned rendering = SWITCH_GRAY+dqPrefs.render; unsigned cmd; GetColorTable(0,oldpal); oldcl = GetMouseClamp(); ClampMouse(0,160,0,280); if (dqPrefs.mouse) FakeMouse(1,0,xsize,ysize,0); else FakeMouse(1,0,0,0,0); HideMenuBar(); HideCursor(); SetAllSCBs(0); do { if (palette != NULL) SetColorTable(0,palette); switch (tt) { case 0: cmd = display_reg(bitmap,palette,orient,xsize,ysize); break; case 1: cmd = display_squished(bitmap,palette); break; } switch (cmd) { case 0: done = 1; /* terminate the picture view */ break; case 1: tt = !tt; break; case SWITCH_GRAY: if (rendering == SWITCH_GRAY) break; remap_image((long)image_v*image_h_buf/2,orig_ptr,bitmap, gray_palette); tt = 0; palette = gs_gray; rendering = SWITCH_GRAY; break; case SWITCH_COLOR: if (rendering == SWITCH_COLOR) break; if (!did_quant) { quantize(orig_palette_256,orig_ptr); did_quant = 1; } remap_image((long)image_v*image_h_buf/2,orig_ptr,bitmap, newpal); rendering = SWITCH_COLOR; palette = quant_palette_16; tt = 0; break; } } while (!done); ClampMouse(oldcl.xMinClamp,oldcl.xMaxClamp,oldcl.yMinClamp,oldcl.yMaxClamp); /* restore default color palette */ SetAllSCBs(0x80); RefreshDesktop(NULL); SetColorTable(0,oldpal); InitPalette(); ShowMenuBar(); ShowCursor(); } int read_tiff(int fd_img, int scale) { int fd; tiff_header th; unsigned long ifd; unsigned dir_num_ent; dir_entry *directory; unsigned i,numpal; word *r_pal,*g_pal,*b_pal; size_t imgoff; unsigned order; unsigned long j; unsigned long tmp; unsigned StripOffsets,PhotoInterp; unsigned ImageLength,ImageWidth; unsigned ColorMap; picture_valid = 0; picture_orient = RIGHT_SIDE_UP; read(fd_img,&th,sizeof(th)); ifd = th.ifd_offset; if (th.byte_order[0] == 'M') order = 1; else order = 0; if ((th.tiff_ident != 0x2A) && (th.tiff_ident != 0x2A00)) { printf("Not a TIFF file or TIFF file does not have Intel byte ordering\n"); return(1); } if (order) ifd = swap_orderl(ifd); printf("Byte ordering: %s\n",(th.byte_order[0] == 'I') ? "Intel" : "Motorola"); WriteChar(10); printf("IFD offset: %06lX\n",ifd); WriteChar(10); lseek(fd_img,ifd,0); read(fd_img,&dir_num_ent,2); if (order) dir_num_ent = swap_orders(dir_num_ent); printf("# dir entries: %04X\n",dir_num_ent); WriteChar(10); directory = xmalloc(dir_num_ent * 12l); read(fd_img,directory,dir_num_ent * 12l); ColorMap = 0xFFFF; for (i = 0; i < dir_num_ent; i++) { /*printField(directory+i);*/ if (order) { directory[i].tag = swap_orders(directory[i].tag); directory[i].type = swap_orders(directory[i].type); directory[i].count = swap_orderl(directory[i].count); if ((directory[i].type == T_SHORT) && (directory[i].count < 3)) directory[i].value = swap_orders(directory[i].value); else directory[i].value = swap_orderl(directory[i].value); } switch (directory[i].tag) { case 0x0106: PhotoInterp = directory[i].value; break; case 0x0111: StripOffsets = i; break; case 0x0100: ImageWidth = directory[i].value; break; case 0x0101: ImageLength = directory[i].value; break; case 0x0140: ColorMap = i; break; } } /* Read in the color map */ if (ColorMap == 0xFFFF) { printf ("No color map to read!!!, we will probably have to build one\n"); } numpal = directory[ColorMap].count; r_pal = xmalloc(512l); g_pal = xmalloc(512l); b_pal = xmalloc(512l); if (PhotoInterp == 3) { lseek(fd_img,directory[ColorMap].value,0); read(fd_img,b_pal,512l); read(fd_img,g_pal,512l); read(fd_img,r_pal,512l); } else { /* assume it's greyscale, and create a greyscale palette */ for (i = 0; i < 256; i++) { r_pal[i] = g_pal[i] = b_pal[i] = (i << 8); } } for (i = 0; i < 256; i++) { orig_palette_256[i].r_val = r_pal[i] >> 8; orig_palette_256[i].g_val = g_pal[i] >> 8; orig_palette_256[i].b_val = b_pal[i] >> 8; r_pal[i] >>= 10; g_pal[i] >>= 10; b_pal[i] >>= 10; tmp = ((long)r_pal[i]*19 + (long)g_pal[i]*37 + (long)b_pal[i]*7) * 15; tmp = (tmp+3000) / 3969; if (tmp > 15) tmp = 15; gray_palette[i] = (byte) tmp; } j = 0; lseek(fd_img,directory[StripOffsets].value,0); image_h_buf = 640; image_h = ImageWidth; image_v = ImageLength; printf("Image Offset: %06lX\n",directory[StripOffsets].value); WriteChar(10); /* lseek(fd_img,imgoff,0); */ /* read in the image, setting border stuff to black as necessary */ for (i = 0; i < ImageLength; i++) { read(fd_img,orig_ptr+j,ImageWidth); if (ImageWidth != 640) memset(orig_ptr+j+ImageWidth,0,640-ImageWidth); j+=640; } picture_valid = 2; /* indicate a TIFF image :-O */ xfree(r_pal); xfree(g_pal); xfree(b_pal); xfree(directory); } int read_scf(int fd_img,int scale) { size_t sizeb; struct scf_header head; int i, num_col; unsigned long tmp; unsigned x_size,y_size; picture_valid = 0; picture_orient = RIGHT_SIDE_UP; read(fd_img, &head, sizeof(head)); if (strncmp(head.magic,"RIX3",4)) { ErrDialog("File does not have the proper SCF magic header"); return; } if ((head.width != 640) || (head.height != 480)) { ErrDialog("File is not 640x480"); return; } num_col = 256; read(fd_img,orig_palette_256,num_col*sizeof(struct rgb_24)); /* Calculate a grayscale palette (256 entry) for this picture for possible grayscale remapping */ for (i = 0; i < num_col; i++) { tmp = ((long)orig_palette_256[i].r_val*19 + (long)orig_palette_256[i].g_val*37 + (long)orig_palette_256[i].b_val*7) * 15; tmp = (tmp+3000) / 3969; if (tmp > 15) tmp = 15; gray_palette[i] = (byte) tmp; /* scale the color map for the quantization algorithm */ orig_palette_256[i].r_val <<= 2; orig_palette_256[i].g_val <<= 2; orig_palette_256[i].b_val <<= 2; } sizeb = ((size_t)head.height) * head.width; image_h_buf = image_h = head.width; image_v = head.height; if (head.packed_flag == 0x80) unpack_rix(fd_img,orig_ptr); else read(fd_img,orig_ptr,sizeb); picture_valid = 1; } int read_bmp(int fd) { unsigned long sizeb; struct rgb_32_rev *palette; struct bmp_header1 head1; struct bmp_header2 head2; int i, num_col; longword tmp; byte *xptr; picture_valid = 0; /*picture_orient = UPSIDE_DOWN;*/ picture_orient = RIGHT_SIDE_UP; read(fd, &head1, sizeof(head1)); if ((head1.magic[0] != 'B') || (head1.magic[1] != 'M')) { close(fd); printf("File does not have the proper BMP magic header\n"); return; } printf("File size: %ld\n",head1.file_size); printf("Res1: %d Res2: %d\n",head1.res1,head1.res2); printf("Offset to bitmap bits: %ld\n",head1.bmap_offset); read(fd, &head2, head1.h2_size-4); printf("Width: %ld Height: %ld\n",head2.width,head2.height); printf("No. bitplanes: %d\n",head2.bitplanes); printf("Bits/pixel: %d\n",head2.bits_per_pixel); printf("No. Colors used: %ld\n",head2.num_colors); printf("No. Important colors: %ld\n",head2.imp_colors); num_col = 1 << head2.bits_per_pixel; palette = xmalloc(num_col*sizeof(struct rgb_32_rev)); read(fd,palette,num_col*sizeof(struct rgb_32_rev)); for (i = 0; i < num_col; i++) { orig_palette_256[i].r_val = palette[i].b_val; orig_palette_256[i].g_val = palette[i].g_val; orig_palette_256[i].b_val = palette[i].r_val; palette[i].r_val >>= 2; palette[i].g_val >>= 2; palette[i].b_val >>= 2; tmp = ((long)palette[i].r_val*19 + (long)palette[i].g_val*37 + (long)palette[i].b_val*7) * 15; tmp = (tmp+3000) / 3969; if (tmp > 15) tmp = 15; gray_palette[i] = (byte) tmp; } lseek(fd,head1.bmap_offset,0); /*sizeb = head2.height * head2.width; read(fd,orig_ptr,sizeb); */ image_h_buf = 640; image_h = head2.width; image_v = head2.height; xptr = orig_ptr + (long)image_v * 640; for (i = 0; i < image_v; i++) { xptr -= 640; read(fd,xptr,image_h); } xfree(palette); picture_valid = 1; } void doGrayConvForPrint(void) { remap_image((long)image_v*image_h_buf/2,orig_ptr,remap_ptr,gray_palette); doPrintPic(remap_ptr,image_h,image_v,gs_gray); } /* Filename of the last picture, for use in 'caching' */ char lastpic[80] = "\0"; /* initialize to null string */ int display_picture(char *fname, unsigned file_num) { int fd_img, x; unsigned l1; static char fle[7]; static char picname[128]; extern char *cd_name; if (fname[0] == 'P') /* picture is in the current directory! */ { sprintf(fle,"%05d",file_num); sprintf(picname,"%s:dp:%s",cd_name,fle); picname[strlen(picname)-1] = 0; strcat(picname,":"); strcat(picname,fname); strcat(picname,";1"); } else { sprintf(picname,"%s:dp:",cd_name); l1 = strlen(picname); picname[l1+4] = 0; memcpy(picname+l1,fname,4l); strcat(picname,":"); strcat(picname,fname); strcat(picname,";1"); } WriteChar(10); printf("picname: %s\n",picname); WriteChar(10); /* Check to see if this is a different pic than last time; if so, then we load it (duh), but if it's the same pic, then we don't reload, and thus save major time!! */ WaitCursor(); if (strcmp(picname,lastpic)) { fd_img = open(picname,O_RDONLY); if (fd_img < 0) { /* if we were unable to open the picture, change the suffix to .BMP and try again! (for stupid new FamDoc) */ x = strlen(picname); if (picname[x-2] == ';') x-= 2; picname[x-3] = 'b'; picname[x-2] = 'm'; picname[x-1] = 'p'; x = strlen(fname); if (fname[x-2] == ';') x-=2; fname[x-3] = 'b'; fname[x-2] = 'm'; fname[x-1] = 'p'; fd_img = open(picname,O_RDONLY); if (fd_img < 0) { InitCursor(); ErrDialog("Couldn't open picture file"); return; } } x = strlen(fname); if (fname[x-2] == ';') x-=2; if (1) { /* if (second_sight) { */ memset(orig_ptr,0,307200l); } if (!strincmp(fname+x-3,"bmp",3)) read_bmp(fd_img); else if (!strincmp(fname+x-3,"scf",3)) read_scf(fd_img,0); else if (!strincmp(fname+x-3,"tif",3)) read_tiff(fd_img,0); else ErrDialog("Cannot view that type of picture"); strcpy(lastpic,picname); } if (1) { /* if (second_sight) { */ _SetMode(0x53,1); _SetPalette(orig_palette_256); _UploadData(FL_VGA,0l,307200l,orig_ptr); waitForMouse(); _SetMode(0x60,0); /* Put it back in SHR shadowing mode */ RefreshDesktop(NULL); } else { if (dqPrefs.render) { quantize(orig_palette_256,orig_ptr); remap_image((long)image_v*image_h_buf/2,orig_ptr,remap_ptr,newpal); } else { memcpy(quant_palette_16,gs_gray,sizeof(gs_gray)); remap_image((long)image_v*image_h_buf/2,orig_ptr,remap_ptr,gray_palette); } if (picture_valid) { if (pic_and_audio != NULL) playAudioFile(pic_and_audio); drive_display(remap_ptr,quant_palette_16,picture_orient,image_h,image_v); conditionalAudioStop(); SetMItemFlag(enableItem,0x0109); } else { SetMItemFlag(disableItem,0x0109); } } InitCursor(); close(fd_img); } @+OCTREEA.ASM 5þ5 @+OCTREEA.MAC5J @*OIQGIF.ASM-5ž @%PIC.H5; @(PICH.ASM5þ5 @(PICH.MAC5$@&PICT.C ,5ƾ&@)PICVIEW.C0!5 @^PINCUSHION.GIFD58 @'QUERY.CV5ξ @-RELEASE.NOTESZ5,@(SS.NOTES^51@%SSV.Cb=v5þ5 @* assembly Octree routines for simple efficiency over C code * Quick'n'Dirty(tm) mcopy octreea.mac case on * The octree data structure MAXDEPTH gequ 7 o_leaf gequ 0 o_level gequ 2 o_colorindex gequ 4 o_children gequ 6 o_colorcount gequ 8 o_bsum gequ 12 o_gsum gequ 16 o_rsum gequ 20 o_nextreduce gequ 24 o_next gequ 28 * 'i' is in X * 'a' is in A * if the specified bit (i) in 'a' is set, return 1, else return 0 TESTBITa start ldy #1 ; assume the bit is set pha txa asl a tax pla and >bittbl,X bne byebye ldy #0 byebye tya rts END quant START res equ 1 maxsublevel equ 3 sum equ 5 sub (3:orig,4:tree),8 phb phk plb ; ldy #o_leaf loop lda [tree] beq notleaf ldy #o_colorindex lda [tree],y sta res bra goaway notleaf lda #MAXDEPTH ldy #o_level sec sbc [tree],y sta maxsublevel tax lda orig+2 ; do red and #$FF jsr TESTBITa asl a asl a sta sum ldx maxsublevel lda orig+1 ; do green and #$FF jsr TESTBITa asl a ora sum sta sum ldx maxsublevel lda orig ; do blue and #$FF jsr TESTBITa ora sum asl a asl a ; multiply by four clc adc #o_next tay lda [tree],y tax iny iny lda [tree],y sta tree+2 stx tree bra loop goaway plb ret 2:res END inserttree START tree equ 1 branch equ 5 maxsublevel equ 7 sub (4:weight,2:depth,3:rgb,4:treep),8 loop lda [treep] sta tree ldy #2 lda [treep],y sta tree+2 lda tree ora tree+2 bne is_alloced pei (depth) pei (treep+2) pei (treep) jsl newandinit lda [treep] ; re-dereference the pointer sta tree ldy #2 lda [treep],y sta tree+2 is_alloced anop ; (*tree)->colorcount += weight; ldy #o_colorcount lda [tree],y clc adc weight sta [tree],y ldy #o_colorcount+2 lda [tree],y adc weight+2 sta [tree],y ; (*tree)->rgbsum.r += Ulong(rgb.r) * weight; pei (weight+2) pei (weight) ldx #0 lda rgb+2 and #$FF jsl ~UMUL4 ldy #o_rsum pla clc adc [tree],y sta [tree],y ldy #o_rsum+2 pla adc [tree],y sta [tree],y pei (weight+2) pei (weight) ldx #0 lda rgb+1 and #$FF jsl ~UMUL4 ldy #o_gsum pla clc adc [tree],y sta [tree],y ldy #o_gsum+2 pla adc [tree],y sta [tree],y pei (weight+2) pei (weight) ldx #0 lda rgb and #$FF jsl ~UMUL4 ldy #o_bsum pla clc adc [tree],y sta [tree],y ldy #o_bsum+2 pla adc [tree],y sta [tree],y lda [tree] ; o_leaf jne goaway ; we're done lda depth cmp >leaflevel jcs goaway ; * calculate the branch we need to follow lda #MAXDEPTH sec sbc depth sta maxsublevel tax lda rgb+2 ; do red and #$FF jsr TESTBITa asl a asl a sta branch ldx maxsublevel lda rgb+1 ; do green and #$FF jsr TESTBITa asl a ora branch sta branch ldx maxsublevel lda rgb ; do blue and #$FF jsr TESTBITa ora branch asl a asl a ; multiply by four clc adc #o_next tay sty branch lda [tree],y iny iny ora [tree],y bne doloopagain ldy #o_children lda [tree],y inc a sta [tree],y cmp #2 bne doloopagain pei (tree+2) pei (tree) pei (depth) jsl makereduceable doloopagain inc depth lda tree clc adc branch sta treep lda tree+2 adc #0 sta treep+2 jmp loop goaway ret END newandinit START tree equ 1 sub (2:depth,4:treep),4 lda >nodes ora >nodes+2 bne nodes_alloced ph4 #60*500 ; nodes are 60 bytes, get 300 of 'em jsl malloc sta >nodes txa sta >nodes+2 lda #0 sta >node_alloc_ind nodes_alloced anop lda >node_alloc_ind cmp #500 bne gotit pea 1 jsl exit gotit pea 0 pea 60 ldx #0 lda >node_alloc_ind jsl ~UMUL4 pla clc adc >nodes sta tree sta [treep] pla adc >nodes+2 sta tree+2 ldy #2 sta [treep],y lda >node_alloc_ind inc a sta >node_alloc_ind ldy #o_colorindex lda #0 lp sta [tree],y iny iny cpy #60 bcc lp ldy #o_level lda depth sta [tree],y cmp >leaflevel bcc notleaf lda #1 sta [tree] lda >size inc a sta >size bra goaway notleaf lda #0 sta [tree] goaway ret END  macro &l sub &parms,&work &l anop aif c:&work,.a lclc &work &work setc 0 .a gbla &totallen gbla &worklen &worklen seta &work &totallen seta 0 aif c:&parms=0,.e lclc &len lclc &p lcla &i &i seta c:&parms .b &p setc &parms(&i) &len amid &p,2,1 aif "&len"=":",.c &len amid &p,1,2 &p amid &p,4,l:&p-3 ago .d .c &len amid &p,1,1 &p amid &p,3,l:&p-2 .d &p equ &totallen+4+&work &totallen seta &totallen+&len &i seta &i-1 aif &i,^b .e tsc aif &work=0,.f sec sbc #&work tcs .f phd tcd mend macro &l ret &r &l anop lclc &len aif c:&r,.a lclc &r &r setc 0 &len setc 0 ago .h .a &len amid &r,2,1 aif "&len"=":",.b &len amid &r,1,2 &r amid &r,4,l:&r-3 ago .c .b &len amid &r,1,1 &r amid &r,3,l:&r-2 .c aif &len<>2,.d ldy &r ago .h .d aif &len<>4,.e ldx &r+2 ldy &r ago .h .e aif &len<>10,.g ldy #&r ldx #^&r ago .h .g mnote 'Not a valid return length',16 mexit .h aif &totallen=0,.i lda &worklen+2 sta &worklen+&totallen+2 lda &worklen+1 sta &worklen+&totallen+1 .i pld tsc clc adc #&worklen+&totallen tcs aif &len=0,.j tya .j rtl mend macro &l ph4 &n1 aif "&n1"="*",.f lclc &c &l anop &c amid &n1,1,1 aif "&c"="#",.d aif s:longa=1,.a rep #%00100000 .a aif "&c"<>"{",.b &c amid &n1,l:&n1,1 aif "&c"<>"}",.g &n1 amid &n1,2,l:&n1-2 ldy #2 lda (&n1),y pha lda (&n1) pha ago .e .b aif "&c"<>"[",.c ldy #2 lda &n1,y pha lda &n1 pha ago .e .c aif "&c"<>"<",.c1 &n1 amid &n1,2,l:&n1-1 pei &n1+2 pei &n1 ago .e .c1 lda &n1+2 pha lda &n1 pha ago .e .d &n1 amid &n1,2,l:&n1-1 pea +(&n1)|-16 pea &n1 ago .f .e aif s:longa=1,.f sep #%00100000 .f mexit .g mnote "Missing closing '}'",16 mend macro &lab jcs &loc &lab bcc *+5 jmp &loc mend macro &lab jne &loc &lab beq *+5 jmp &loc mend ************************************************************************** * * ImageQuant * by Tim Meekins * * Copyright (c) 1994 by Tim Meekins * ************************************************************************** * * iqgif.asm * * ImageQuant GIF loading routines * ************************************************************************** case on mcopy iqgif.mac copy debug ;------------------------------------------------------------------------- ; LoadGIF ; Load a GIF ;------------------------------------------------------------------------- _MapPtr gequ 14 _MapHandle gequ 26 LoadGIF START ptr equ 1 colormap equ ptr+4 giftype equ colormap+4 row equ giftype+2 image equ row+4 bitpixel equ image+4 rcmnum equ bitpixel+2 globcolortab equ rcmnum+2 c equ globcolortab+4 lbitpixel equ c+2 loccolortab equ lbitpixel+2 bitres equ loccolortab+4 height equ bitres+2 width equ height+2 img_h equ width+2 table1 equ img_h+2 table2 equ table1+4 sp equ table2+4 stack equ sp+4 cmap equ stack+4 fresh equ cmap+4 incode equ fresh+2 code_size equ incode+2 set_code_size equ code_size+2 max_code equ set_code_size+2 max_code_size equ max_code+2 firstcode equ max_code_size+2 oldcode equ firstcode+2 clear_code equ oldcode+2 end_code equ clear_code+2 curbit equ end_code+2 lastbit equ curbit+2 doneflag equ lastbit+2 last_byte equ doneflag+2 count equ last_byte+2 ret equ count+2 j equ ret+2 rowind equ j+2 result equ rowind+2 outbuf equ result+2 hndl equ outbuf+4 space equ hndl+4 sub (4:rec,4:raw),space ; ; Check for AOL GIF header by seeing if the GIF header is at +$20 ; stz result ldy #$20 lda [userid pha pea 0 pea 0 pea 0 _NewHandle pla plx sta userid pha pea 0 pea 0 pea 0 _NewHandle pla plx sta /* Image File types */ #define IMAGE_GIF 1 #define IMAGE_TIFF 2 #define IMAGE_PICT2 3 #define IMAGE_TARGA 4 #define IMAGE_3200 5 typedef struct image { word height; /* height of image in scanlines */ word width; /* width of image in pixels/bytes */ int depth; /* pixel depth - 1, 2, 4, 8, 16, or 24 */ int type; /* image type - see above defines */ int palette_size; /* number of palette entries */ struct rgb_24 *palette; void *map; /* pointer to the pixel map */ char *fname; /* filename of image file */ char *pathname; /* full pathname of image file */ void *mapHandle; } image; struct rgb_32_rev { byte b_val; byte g_val; byte r_val; byte reserved; }; typedef struct rgb_24 { byte b_val; byte g_val; byte r_val; } rgb_24; typedef unsigned char UCHAR; /* 8 bits */ typedef unsigned short int UINT; /* 16 bits */ typedef unsigned long int ULONG; /* 32 bits */ int determinePicType(char *buf,GSString255Ptr); int load_tiff(int fd_img, image *rec); int load_pict(int, image *); int load_targa(int, image *); int load_raw3200(int, image *); unsigned long swap_orderl(unsigned long x); unsigned swap_orders(unsigned x); void advance_thermo(void); void kill_thermo(void); void init_thermo(word height); /* picview.c */ int display_picture(char *fname,unsigned file_num); int read_bmp(int fd); int read_scf(int fd_img,int scale); void display(byte *bitmap, void *palette, int orient); void ErrDialog(char *f); int DoAlertC(long alertID, ...); void shrinkpic(void *); void remap_image(unsigned long, byte *, byte *, void *); void unpack_rix(int,void *); int identify_targa(char *);   mcopy pich.mac case on * ptr is the pointer to the bitmap * linewid is how many bytes across the IIGS screen the image takes; * the max is 160 bytes. * linesize is the number of bytes the actual image scanlines take drawimageud START e1ptr equ 1 sub (4:ptr,2:linewid,2:linesize),4 phb lda #$E1 sta e1ptr+2 ldy #$2000 lp cpy #$9D00 bcs done ldx ptr ; clc ;TLM - bcs does it txa adc moveit1+2 long m lda moveit1+2 long m lda $000000,x asl a asl a asl a asl a sta tmp0 lda [bitmap0],y tax pal2 lda >$000000,x ; cycles of AL,X == A,X ora tmp0 sta [outbitmap0] long m inc outbitmap0 beq foobie ; save a cycle!!! noinc iny beq foobie2 ; save another cycle! ; this code is big and hideous noinc2 dec cnt0 ; this isn't proper technique, bne lp3 ; but we can deal with it dec cnt0+2 bpl lp3 pld done ret foobie inc outbitmap0+2 bra noinc foobie2 inc bitmap0+2 bra noinc2 END boo START dc c'7ek!Z7t*.' ds 6 END * display the (640x480) 4-bit picture pointed to by bitmap in * half-size, statically on the SHR screen. shrinkpic START ptr equ 1 pix0 equ 5 p0 equ 7 colcnt equ 9 rowcnt equ 11 sub (4:bitmap),12 lda bitmap sta ptr lda bitmap+2 sta ptr+2 ldx #0 ; super hi-res screen offset lda #99 sta rowcnt colloop lda #319 sta colcnt loop phx lda #0 short m ldy #0 lda [ptr],y ; grab two pixels tax lda avg2,x ; average the two pixels w/lookup sta p0 ldy #320 lda [ptr],y tax lda avg2,x clc adc p0 asl a asl a asl a and #$F0 sta pix0 long m inc ptr bne x1 inc ptr+2 x1 lda #0 short m ldy #0 lda [ptr],y ; grab two pixels tax lda avg2,x ; average the two pixels w/lookup sta p0 ldy #320 lda [ptr],y tax lda avg2,x clc adc p0 lsr a and #$0F ora pix0 plx sta >$E12000,X long m inc ptr bne x2 inc ptr+2 x2 inx dec colcnt bpl loop lda ptr clc adc #640 sta ptr lda ptr+2 adc #0 sta ptr+2 dec rowcnt bpl colloop ret avg2 anop dc i1'0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7' dc i1'0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8' dc i1'1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8' dc i1'1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9' dc i1'2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9' dc i1'2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10' dc i1'3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10' dc i1'3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11' dc i1'4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11' dc i1'4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12' dc i1'5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12' dc i1'5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13' dc i1'6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13' dc i1'6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,14' dc i1'7,7,8,8,9,9,10,10,11,11,12,12,13,13,14,14' dc i1'7,8,8,9,9,10,10,11,11,12,12,13,13,14,14,15' END unpack_rix START c equ 1 color equ c+2 displayed equ color+2 image_buf equ displayed+4 huff_color equ image_buf+4 huff_delta equ huff_color+2 huff_size equ huff_delta+2 i equ huff_size+2 j equ i+2 image_codes equ j+2 locals equ image_codes+2 sub (4:bitmap,2:fd),locals ph4 #50000 jsl malloc sta image_buf stx image_buf+2 ; READ the size of the Huffman code table ph4 #2 pea 0 tdc clc adc #huff_size pha pei (fd) jsl read ; read in the actual huffman table lda huff_size asl a ; huff_size is in words pea 0 pha ph4 #huff_codes pei (fd) jsl read stz j bra mainloop2 mainloop inc j mainloop2 lda j cmp #8 bcc okay1 jmp doneloop okay1 anop ; read the # of bytes in this chunk ph4 #2 pea 0 tdc clc adc #image_codes pha pei (fd) jsl read pea 0 pei (image_codes) pei (image_buf+2) pei (image_buf) pei (fd) jsl read ldy #0 sty color lda #huff80 sta !code1+1 sta !code2+1 ldx #20480 lda j cmp #7 beq okay2 ldx #40960 okay2 stx displayed okay3 ldx #2 lda !huff_codes sta huff_delta clc code1 jsr $ffff cmp #4096 bcc code1 and #$FF sta huff_color beq doneloop3 cmp #$FF beq doneloop3 eor color sta color sta [bitmap] inc bitmap bne okay5 inc bitmap+2 okay5 dec displayed bne okay3 bra mainloop ; extract the repeat count from the bit stream doneloop3 ldx #2 lda !huff_codes sta huff_delta clc code2 jsr $ffff cmp #4096 bcc code2 and #$FF tax lda color ; keep this in A thru the loop loop5 eor huff_color sta [bitmap] inc bitmap bne lp5a inc bitmap+2 lp5a dec displayed dex bpl loop5 sta color lda displayed bne okay3 jmp mainloop doneloop pei (image_buf+2) pei (image_buf) jsl free ret huff80 lda #huff40 sta !code1+1 sta !code2+1 lda [image_buf],y iny sta c bit #$80 bne bp2_80 txa adc huff_delta tax bp2_80 lda !huff_codes,x inx inx sta huff_delta rts huff40 lda #huff20 sta !code1+1 sta !code2+1 lda c bit #$40 bne bp2_40 txa adc huff_delta tax bp2_40 lda !huff_codes,x inx inx sta huff_delta rts huff20 lda #huff10 sta !code1+1 sta !code2+1 lda c bit #$20 bne bp2_20 txa adc huff_delta tax bp2_20 lda !huff_codes,x inx inx sta huff_delta rts huff10 lda #huff08 sta !code1+1 sta !code2+1 lda c bit #$10 bne bp2_10 txa adc huff_delta tax bp2_10 lda !huff_codes,x inx inx sta huff_delta rts huff08 lda #huff04 sta !code1+1 sta !code2+1 lda c bit #$08 bne bp2_08 txa adc huff_delta tax bp2_08 lda !huff_codes,x inx inx sta huff_delta rts huff04 lda #huff02 sta !code1+1 sta !code2+1 lda c bit #$04 bne bp2_04 txa adc huff_delta tax bp2_04 lda !huff_codes,x inx inx sta huff_delta rts huff02 lda #huff01 sta !code1+1 sta !code2+1 lda c bit #$02 bne bp2_02 txa adc huff_delta tax bp2_02 lda !huff_codes,x inx inx sta huff_delta rts huff01 lda #huff80 sta !code1+1 sta !code2+1 lda c lsr a bcs bp2_01 txa adc huff_delta tax bp2_01 lda !huff_codes,x inx inx sta huff_delta rts huff_codes ds 3000 END  macro &l sub &parms,&work &l anop aif c:&work,.a lclc &work &work setc 0 .a gbla &totallen gbla &worklen &worklen seta &work &totallen seta 0 aif c:&parms=0,.e lclc &len lclc &p lcla &i &i seta c:&parms .b &p setc &parms(&i) &len amid &p,2,1 aif "&len"=":",.c &len amid &p,1,2 &p amid &p,4,l:&p-3 ago .d .c &len amid &p,1,1 &p amid &p,3,l:&p-2 .d &p equ &totallen+4+&work &totallen seta &totallen+&len &i seta &i-1 aif &i,^b .e tsc aif &work=0,.f sec sbc #&work tcs .f phd tcd mend macro &l long &a,&b lclb &i lclb &m &a amid &a,1,1 &m setb ("&a"="M").or.("&a"="m") &i setb ("&a"="I").or.("&a"="i") aif c:&b=0,.a &b amid &b,1,1 &m setb ("&b"="M").or.("&b"="m").or.&m &i setb ("&b"="I").or.("&b"="i").or.&i .a &l rep #&m*32+&i*16 aif .not.&m,.b longa on .b aif .not.&i,.c longi on .c mend macro &l short &a,&b lclb &i lclb &m &a amid &a,1,1 &m setb ("&a"="M").or.("&a"="m") &i setb ("&a"="I").or.("&a"="i") aif c:&b=0,.a &b amid &b,1,1 &m setb ("&b"="M").or.("&b"="m").or.&m &i setb ("&b"="I").or.("&b"="i").or.&i .a &l sep #&m*32+&i*16 aif .not.&m,.b longa off .b aif .not.&i,.c longi off .c mend macro &l ret &r &l anop lclc &len aif c:&r,.a lclc &r &r setc 0 &len setc 0 ago .h .a &len amid &r,2,1 aif "&len"=":",.b &len amid &r,1,2 &r amid &r,4,l:&r-3 ago .c .b &len amid &r,1,1 &r amid &r,3,l:&r-2 .c aif &len<>2,.d ldy &r ago .h .d aif &len<>4,.e ldx &r+2 ldy &r ago .h .e aif &len<>10,.g ldy #&r ldx #^&r ago .h .g mnote 'Not a valid return length',16 mexit .h aif &totallen=0,.i lda &worklen+2 sta &worklen+&totallen+2 lda &worklen+1 sta &worklen+&totallen+1 .i pld tsc clc adc #&worklen+&totallen tcs aif &len=0,.j tya .j rtl mend macro &l ph4 &n1 aif "&n1"="*",.f lclc &c &l anop &c amid &n1,1,1 aif "&c"="#",.d aif s:longa=1,.a rep #%00100000 .a aif "&c"<>"{",.b &c amid &n1,l:&n1,1 aif "&c"<>"}",.g &n1 amid &n1,2,l:&n1-2 ldy #2 lda (&n1),y pha lda (&n1) pha ago .e .b aif "&c"<>"[",.c ldy #2 lda &n1,y pha lda &n1 pha ago .e .c aif "&c"<>"<",.c1 &n1 amid &n1,2,l:&n1-1 pei &n1+2 pei &n1 ago .e .c1 lda &n1+2 pha lda &n1 pha ago .e .d &n1 amid &n1,2,l:&n1-1 pea +(&n1)|-16 pea &n1 ago .f .e aif s:longa=1,.f sep #%00100000 .f mexit .g mnote "Missing closing '}'",16 mend  !"#$%&'()*+,-.//* * pict.c * Support for Macintosh PICT pixmaps in the data form. */ #include #include #include #include #include #include #include "pic.h" #pragma pack(1) extern char pictitle[]; segment "pict"; /*#define STANDALONE */ /*unsigned long swap_orderl(unsigned long x); unsigned short swap_orders(unsigned x); */ typedef unsigned long MFixed; typedef short int Int; typedef unsigned short UInt; typedef long int LongInt; typedef short int Mode; typedef struct MRect { Int v1,h1,v2,h2; } MRect; typedef unsigned long mHandle; typedef struct PixMap { /* void *baseAddr;*/ Int rowBytes; MRect bounds; /*Int pmVersion; */ Int packType; LongInt packSize; MFixed hRes; MFixed vRes; Int dummy; Int pixelType; /* 0 = indexed, 16 = direct */ Int pixelSize; /* 1,2,4,8 (indexed) 16, 32 (direct) */ Int cmpCount; Int cmpSize; mHandle pmTable; LongInt pmReserved; } PixMap; typedef struct ctSpec { Int index; UInt red; UInt green; UInt blue; } ctSpec; typedef struct ColorTable { LongInt ctSeed; Int ctFlags; Int ctSize; ctSpec ctTable[0x100]; /* Assume */ } ColorTable; typedef struct DirectBitsRectS { PixMap pMap; int dummy3; int dummy4; ColorTable cTable; Rect srcRect; Rect dstRect; Int srcCopy; } DirectBitsRectS; DirectBitsRectS db; #ifdef STANDALONE unsigned long swap_orderl(unsigned long x) { unsigned long y; char *lx = (char *) &x; char *ly = (char *) &y; ly[0] = lx[3]; ly[1] = lx[2]; ly[2] = lx[1]; ly[3] = lx[0]; return y; } unsigned swap_orders(unsigned x) { unsigned short y; char *lx = (char *) &x; char *ly = (char *) &y; ly[1] = lx[0]; ly[0] = lx[1]; return y; } #endif void massagePixMap(PixMap *pm) { /* pm->baseAddr = (void *)swap_orderl((int)pm->baseAddr);*/ pm->rowBytes = swap_orders(pm->rowBytes); pm->bounds.v1 = swap_orders(pm->bounds.v1); pm->bounds.v2 = swap_orders(pm->bounds.v2); pm->bounds.h1 = swap_orders(pm->bounds.h1); pm->bounds.h2 = swap_orders(pm->bounds.h2); /*pm->pmVersion = swap_orders(pm->pmVersion);*/ pm->packType = swap_orders(pm->packType); pm->packSize = swap_orderl(pm->packSize); pm->hRes = swap_orderl(pm->hRes); pm->vRes = swap_orderl(pm->vRes); pm->pixelType = swap_orders(pm->pixelType); pm->pixelSize = swap_orders(pm->pixelSize); pm->cmpCount = swap_orders(pm->cmpCount); pm->cmpSize = swap_orders(pm->cmpSize); #ifdef STANDALONE /* printf("baseAddr: %08lX\n",pm->baseAddr);*/ printf("rowBytes: %d\n",pm->rowBytes & 0x7FFF); if (pm->rowBytes & 0x8000) printf(" pixMap record\n"); else printf(" bitMap record\n"); printf("bounds: [%d,%d %d,%d]\n",pm->bounds.v1,pm->bounds.h1,pm->bounds.v2,pm->bounds.h2); /*printf("pmVersion: %d\n",pm->pmVersion);*/ printf("packType: %d packSize: %ld\n",pm->packType,pm->packSize); printf("hRes: %ld, vRes: %ld\n",pm->hRes,pm->vRes); printf("pixelType: %d pixelSize: %d cmpCount: %d cmpSize: %d\n", pm->pixelType,pm->pixelSize,pm->cmpCount,pm->cmpSize); #endif } void massageColorTable(ColorTable *cT) { int i; cT->ctSize = swap_orders(cT->ctSize); cT->ctSeed = swap_orderl(cT->ctSeed); for (i = 0; i < cT->ctSize; i++) { cT->ctTable[i].index = swap_orders(cT->ctTable[i].index); cT->ctTable[i].red = swap_orders(cT->ctTable[i].red); cT->ctTable[i].green = swap_orders(cT->ctTable[i].green); cT->ctTable[i].blue = swap_orders(cT->ctTable[i].blue); } #ifdef STANDALONE printf("ctSize: %d [%d]\n",cT->ctSize,cT->ctSize+1); printf("ctSeed: %08lX\n",cT->ctSeed); #endif } unsigned char buf[1024]; struct opcodes { char *name; int size; }; struct opcodes opc[] = { "NOP", 0, /* 0 */ "Clip", -1, /* 1 */ "BkPat", 8, "TxFont", 2, "TxFace", 1, "TxMode", 2, /* 5 */ "SpExtra", 4, "PnSize", 4, "PnMode", 2, "PnPat", 8, "FillPat", 8, "OvSize", 4, "Origin", 4, "TxSize", 2, "FgColor", 4, "BkColor", 4, "TxRatio", 8, "VersionOp", 2, "BkPixPat", -1, "PnPixPat", -1, "FillPixPat", -1, "PnLocHFrac", 2, /* 0x15 */ "ChExtra", 2, "", 0, "", 0, "", 0, "RGBFgCol", 6, "RGBBkCol", 6, "HiliteMode", 0, "HiliteColor", 6, "DefHilite", 0, "OpColor", 6, "Line", 8, "LineFrom", 4, "ShortLine", 6, "ShortLineFrom", 2, "",0, "",0, "",0, "",0, "LongText", -1, "DHText", -1, "DVText", -1, "DHDVText", -1, "fontName", -1, "lineJustify", 10, "glyphState", 8, "", -1, "frameRect", 8, /* $0030 */ "paintRect", 8, "eraseRect", 8, "invertRect", 8, "fillRect", 8, "", 8, "", 8, "", 8, "frameSameRect", 0, /* $0038 */ "paintSameRect", 0, "eraseSameRect", 0, "invertSameRect", 0, "fillSameRect", 0, "", 0, "", 0, "", 0, "frameRRect", 8, /* $0040 */ "paintRRect", 8, "eraseRRect", 8, "invertRRect", 8, "fillRRect", 8, "", 8, "", 8, "", 8, "frameSameRRect", 0, /* $0048 */ "paintSameRRect", 0, "eraseSameRRect", 0, "invertSameRRect", 0, "fillSameRRect", 0, "", 0, "", 0, "", 0, "frameOval", 8, /* $0050 */ "paintOval", 8, "eraseOval", 8, "invertOval", 8, "fillOval", 8, "", 8, "", 8, "", 8, "frameSameOval", 0, /* $0058 */ "paintSameOval", 0, "eraseSameOval", 0, "invertSameOval", 0, "fillSameOval", 0, "", 0, "", 0, "", 0, "frameArc", 12, /* $0060 */ "paintArc", 12, "eraseArc", 12, "invertArc", 12, "fillArc", 12, "", 12, "", 12, "", 12, "frameSameArc", 0, /* $0068 */ "paintSameArc", 0, "eraseSameArc", 0, "invertSameArc",0, "fillSameArc", 0, "", 0, "", 0, "", 0, "framePoly", -1, "paintPoly", -1, "erasePoly", -1, "invertPoly", -1, "fillPoly", -1, "", -1, "", -1, "", -1, "frameSamePoly", 0, "paintSamePoly", 0, "eraseSamePoly", 0, "invertSamePoly",0, "fillSamePoly", 0, "", 0, "", 0, "", 0, "frameRgn", -1, /* $0080 */ "paintRgn", -1, "eraseRgn", -1, "invertRgn", -1, "fillRgn", -1, "", -1, "", -1, "", -1, "frameSameRgn", 0, /* $0088 */ "paintSameRgn", 0, "eraseSameRgn", 0, "invertSameRgn",0, "fillSameRgn", 0, "", 0, "", 0, "", 0, "BitsRect", -1, /* $0090 */ "BitsRgn", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "PackBitsRect", -1, "PackBitsRgn", -1, "DirectBitsRect", -1, "DirectBitsRgn", -1, "", -1, "", -1, "", -1, "", -1, "ShortComment", 2, /* $00A0 */ "LongComment", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1 }; /* Eventually use faster replacements for memset and memcpy */ void readScanLine(int fd, byte *out, int width, byte *tempBuf) { byte code; byte *sc; int scanLen; int len; static int sl=0; scanLen = 0; if (width > 250) { read(fd,&scanLen,2); scanLen = swap_orders(scanLen); } else read(fd,&scanLen,1); read(fd,tempBuf,scanLen); sc = tempBuf; #ifdef STANDALONE printf("Scanline: %d Length: %d [%04X]\n",sl++,scanLen,scanLen); #endif while (sc < tempBuf+scanLen) { code = *sc++; if (code > 0x80) { /* Packed Data */ len = 257 - code; memset(out,*sc++,len); out += len; } else { /* Unpacked Data */ len = code + 1; memcpy(out,sc,len); out += len; sc += len; } } } int walkPICT(int fd, long off, image *rec) { unsigned int opcode; unsigned anint; LongInt mapLen; handle xhndl; byte *xptr; struct rgb_24 *palette; int i; byte *map,*tempBuf; int done = 0; /* Read Opcode */ while (!done) { if (lseek(fd,off,0) < 0) break; if (read(fd,&opcode,2l) < 2) break; opcode = swap_orders(opcode); printf("[%08lX] ",off); if (opcode < 0x00B0) { if (opc[opcode].size >= 0) { off += opc[opcode].size + 2; printf("[%04X]: %s ",opcode,opc[opcode].name); read(fd,buf,opc[opcode].size); switch (opcode) { case 0x0011: printf("%02X\n",buf[0]); break; default: printf("\n"); break; } } else { printf("[%04X]: %s ",opcode,opc[opcode].name); switch (opcode) { case 0x0001: /* Various region-based opcodes */ case 0x0080: case 0x0081: case 0x0082: case 0x0083: case 0x0084: case 0x0085: case 0x0086: case 0x0087: read(fd,&anint,2); anint = swap_orders(anint); off += anint + 2; anint-=2; read(fd,buf,anint); /* read the region data */ break; case 0x0098:/* PackBitsRect */ case 0x009A:/* BitsRect */ read(fd,&db.pMap,sizeof(PixMap)+4); read(fd,&db.cTable.ctSeed,4 + 2 + 2l); read(fd,&db.cTable.ctTable[0], sizeof(ctSpec) * ((long)swap_orders(db.cTable.ctSize)+1)); read(fd,&db.srcRect,18l); massagePixMap(&db.pMap); massageColorTable(&db.cTable); mapLen = (db.pMap.rowBytes&0x7FFF) * (long)db.pMap.bounds.v2; printf("mapLen: %ld\n",mapLen); xhndl = (handle)NewHandle(mapLen,userid(),0,0l); HLock(xhndl); map = xptr = (byte *) *xhndl; tempBuf = malloc(db.pMap.bounds.h2+5); #ifndef STANDALONE sprintf(pictitle,"Loading PICT file %s",rec->fname); init_thermo(db.pMap.bounds.v2-db.pMap.bounds.v1); #endif for (i = db.pMap.bounds.v1; i < db.pMap.bounds.v2; i++) { readScanLine(fd,map,db.pMap.rowBytes&0x7FFF,tempBuf); map += db.pMap.bounds.h2; #ifndef STANDALONE advance_thermo(); #endif } HUnlock(xhndl); free(tempBuf); #ifndef STANDALONE kill_thermo(); #endif off += mapLen; off += sizeof(db); done = 1; continue; default: return -1; } printf("\n"); } } else { printf("[%04X]: ",opcode); switch (opcode) { case 0x0C00: printf("HeaderOp\n"); read(fd,buf,24l); off += 24; break; default: printf("\n"); } off += 2; } } rec->height = db.pMap.bounds.v2; rec->width = db.pMap.bounds.h2; rec->depth = db.pMap.pixelSize; rec->palette_size = db.cTable.ctSize+1; palette = rec->palette = calloc(sizeof(struct rgb_24),256); for (i = 0; i < 256; i++) { int ind; ind = db.cTable.ctTable[i].index; palette[ind].b_val = db.cTable.ctTable[i].red >> 8; palette[ind].g_val = db.cTable.ctTable[i].green >> 8; palette[ind].r_val = db.cTable.ctTable[i].blue >> 8; } rec->type = IMAGE_PICT2; rec->mapHandle = xhndl; rec->map = xptr; return 0; } int load_pict(int fd, image *rec) { return walkPICT(fd,522l,rec); } #ifdef STANDALONE int main(int argc, char *argv[]) { int fd; image rr; fd = open(argv[1],O_RDONLY); load_pict(fd,&rr); close(fd); } #endif 123456789:;<=>?@A/* * picview.c * * This module loads in Windows .BMP, .SCF, and TIFF format files, * renders them either in 16 colors or grayscale, and views them * on the IIGS screen. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "pic.h" #include "ssv.h" segment "picview"; #pragma lint -1 struct rgb_24 orig_palette_256[256]; static unsigned gs_gray[] = {0, 0x111, 0x222, 0x333, 0x444, 0x555, 0x666, 0x777,0x888,0x999,0xAAA,0xBBB,0xCCC,0xDDD,0xEEE, 0xFFF}; byte gray_palette[256]; word image_h,image_v,image_h_buf,true_image_v,PaletteSize; word picture_valid = 0; #define RGB(r,g,b) ((ULONG)(r) << 16 | (g) << 8 | (b)) /*#define TESTBIT(a,i) (((a)&(1<<(i)))>>(i))*/ #define TESTBIT(a,i) (((a)&(bittbl[(i)]))>>(i)) handle orig_pichandle,remap_pichandle; byte *remap_ptr; vga_status_rec strec; int dispHeight,baseViewMode; int init_picview(void) { if (vgaStartup(&strec) == -1) { DoSimpleAlert(10l); return -1; } if (strec.monitor_type & IS_VGA) { /* VGA monitor */ dispHeight = 480; baseViewMode = 0x53; /* 640x480 noninterlace */ } else { dispHeight = 400; baseViewMode = 0x61; /* 640x400 interlaced */ } return 0; } unsigned long swap_orderl(unsigned long x) { unsigned long y; asm { lda x xba sta y+2 lda x+2 xba sta y } return y; } unsigned swap_orders(unsigned x) { unsigned y; asm { lda x xba sta y } return y; } unsigned long get_eof(int fd) { EOFRecGS e; e.pCount = 2; e.refNum = fd; GetEOFGS(&e); return e.eof; } struct rgb_24 *gif_palette; WindowPtr therm_win; CtlRecHndl thermctl; word thermpos; char pictitle[128]; void init_thermo(word height) { ThermometerTemplate tt = {8,1l,{22,25,32,325},0x87FF0002l,1,0x1000,0l,0,0}; therm_win = DoNewWindow(0xFF9l); thermctl = NewControl2(therm_win,0,&tt); thermpos = 0; SetCtlTitle((longword) height, thermctl); MoveTo(25,15); DrawCString(pictitle); } void advance_thermo(void) { thermpos++; SetCtlValue(thermpos,thermctl); } void kill_thermo(void) { CloseWindow(therm_win); } int OldwaitForMouse(void) { EventRecord ev; unsigned f; while (1) { /* Don't let them into the Control Panel! */ f = GetNextEvent(0x000A, &ev); if (f) if (ev.what == mouseDownEvt) return 0; } } void SetScreenBaseAddr(longword x) { byte x1,x2; x1 = (x >> 8) & 0xFF; x2 = x & 0xFF; _SetVGAReg(0x3D4,0x0D,0x3D5,x2); _SetVGAReg(0x3D4,0x0C,0x3D5,x1); } int waitForMouse(int ysize, int pixelWidth) { int top = 0; longword offset; unsigned t1,oldt1 = 0xFFFF,f; EventRecord ev; ysize -= dispHeight; if (ysize < 0) ysize = 0; /* i.e., picture smaller than one screen */ while (1) { f = GetNextEvent(0x0A, &ev); if (f) { if (ev.what == mouseDownEvt) return 0; } else { top = ev.where.v; if (top > ysize) top = ysize; if (top < 0) top = 0; t1 = top; /* no divide by ten */ if (oldt1 != t1) { /*offset = 640l * top;*/ offset = 80l * top * pixelWidth; SetScreenBaseAddr(offset); oldt1 = t1; } } } } int read_gif(int fd, image *rec) { handle pichndl; extern int LoadGIF(byte *, image *); long len; word i; longword tmp; byte *picsource; int result; len = get_eof(fd); pichndl = NewHandle(len,userid(),0x4008,0l); if (pichndl == 0l) { DoSimpleAlert(3l); return -1; } /* Don't set rec->map here. Allow LoadGIF to allocate the uncompressed data handle */ picsource = (byte *) *pichndl; read(fd,picsource,len); result = LoadGIF(picsource,rec); kill_thermo(); if (result == -2) { DoSimpleAlert(4l); DisposeHandle(pichndl); return -1; } DisposeHandle(pichndl); return 0; } int load_gif(int fd_img, image *rec) { extern char *__GS2CMALLOC(GSString255Ptr); rgb_24 *pal; int i; WaitCursor(); sprintf(pictitle,"Loading GIF file %s",rec->fname); if (read_gif(fd_img,rec) < 0) { InitCursor(); DoSimpleAlert(5l); close(fd_img); return -1; } close(fd_img); InitCursor(); rec->depth = 8; return 0; } static char test_buffer[1024]; static image imrec; int show_picture(GSString255Ptr fname_in, GSString255Ptr path_in) { extern char *__GS2CMALLOC(GSString255Ptr); int fd_img; char *fname,*path; int type; LocInfo2 li; Rect mr; int xcoord, ycoord; int i; unsigned int ymax; word recMode = 0; int dHeight = dispHeight,dWidth = 640; fname = __GS2CMALLOC(fname_in); path = __GS2CMALLOC(path_in); fd_img = open(path,O_RDONLY); if (fd_img < 0) { InitCursor(); DoSimpleAlert(2l); xfree(fname); xfree(path); return -1; } imrec.fname = fname; imrec.pathname = path; /* The image load routines are responsible for setting this */ read(fd_img,test_buffer,1024l); lseek(fd_img,0l,0); type = determinePicType(test_buffer,path_in); if (type == -1) { close(fd_img); DoSimpleAlert(8l); return -1; } switch (type) { case IMAGE_GIF: if (load_gif(fd_img,&imrec)) { DoSimpleAlert(9l); return -1; } break; case IMAGE_TIFF: if (load_tiff(fd_img,&imrec)) { DoSimpleAlert(9l); return -1; } break; case IMAGE_PICT2: if (load_pict(fd_img,&imrec)) { DoSimpleAlert(9l); return -1; } break; case IMAGE_TARGA: if (load_targa(fd_img,&imrec)) { DoSimpleAlert(9l); return -1; } break; case IMAGE_3200: if (load_raw3200(fd_img,&imrec)) { DoSimpleAlert(9l); return -1; } break; } if (type == IMAGE_3200) { vgaSetMode(0x70,FL_NOEMULATE); li.portSCB = 0x5A5A; li.info.li2.ptrToPixImage = (Pointer) imrec.map; li.info.li2.width = imrec.width * 2; /* # of bytes = 2 * # of pixels */ li.info.li2.pixDepth = 15; dHeight = 200; dWidth = 320; } else if ((imrec.depth == 15) || (imrec.depth == 16)) { if (strec.monitor_type & IS_VGA) { vgaSetMode(0x5C,FL_NOEMULATE); /* 640x480x32K */ dHeight = 480; dWidth = 640; } else { vgaSetMode(0x5B,FL_NOEMULATE); /* 640x400x32K */ dHeight = 400; dWidth = 640; } li.portSCB = 0x5A5A; li.info.li2.ptrToPixImage = (Pointer) imrec.map; li.info.li2.width = imrec.width * 2; /* # of bytes = 2 * # of pixels */ li.info.li2.pixDepth = 15; } else { vgaSetMode(baseViewMode,FL_NOEMULATE); _SetPalette(imrec.palette); li.portSCB = 0x5A5A; li.info.li2.ptrToPixImage = (Pointer) imrec.map; li.info.li2.width = imrec.width; li.info.li2.pixDepth = 8; } if (li.info.li2.pixDepth > 8) { if (strec.bits == 8) { vgaSetMode(0x60,FL_EMULATE); DoSimpleAlert(0x0Bl); xfree(fname); xfree(path); if (imrec.palette != NULL) xfree(imrec.palette); DisposeHandle(FindHandle(imrec.map)); InitCursor(); return -1; } } SetRect(&li.info.li2.boundsRect,0,0,imrec.width,imrec.height); SetRect(&mr,0,0,imrec.width,imrec.height); if (imrec.width < dWidth) xcoord = (dWidth - imrec.width) / 2; else xcoord = 0; if (imrec.height < dHeight) ycoord = (dHeight - imrec.height) / 2; else ycoord = 0; /* Calculate 'ymax', which will tell us how much of the screen buffer to clear */ ymax = imrec.height; if (ymax > 817) ymax = 817; if (ymax < dHeight) ymax = dHeight; if ((li.info.li2.width < dWidth) || (imrec.height < dHeight)) _ClearScreen(0,(void *)0l,(long)dWidth * ymax); vgaCopyPixelMap(xcoord,ycoord,&li,&mr); waitForMouse(imrec.height,(li.info.li2.pixDepth + 7) / 8); vgaSetMode(0x60,FL_EMULATE); xfree(fname); xfree(path); if (imrec.palette != NULL) xfree(imrec.palette); DisposeHandle(FindHandle(imrec.map)); InitCursor(); } EFGHIJKLMNOPQRSTUB =C[ GIF87a,Z 6F8zy 컸LCw^x:"Gʥ|n Zb'mË1lEkj[Fsr=|ou{J~X5(Utշ萸$DYd) 3YvPj : ;T{k 2$|YL̄,|b =5M-[)Vn>w<Uxhj < 4sHa} XF=QI4]=UmlSI8+GnjIBDKJ;0\BqڴWPҡĖj<΄ڏ$ZV . (˱*U$[nE%urK˯f fyX OLUnj/-%&e+ t:E{k鴫zZilCzHuW}7lQo_367ƒ/' \-W~6tonv?{o@G|[|ͿG|_7Ox R37 f(OI8ڃQxZYaSl%6"cʁHOθx\bo'Vcq22xo92p?` I))4>9 "I$0f:L~'eX^)mi^#ff—kIVYQ9e-ɞ}ٛ:i!::Y 'Orfi:i JꢄNʨ~鄭VꇩWZj"(s KkDvw8mrZmَl6_r:nFߪᲹ-Sbn \ .Ɖ/Y /p? qOLq_qoq r"Lr&r*q2/?z/'Y)P733A #Ҡ\),nϷ:}.AͮҮj +իb"ZM.^˳z-kF3fvu w6{{7 9}=zxօˋxؓx&m-yF޴肛^z zڗHWU;߹;{sέ?ǫ'|'}ҷ]E{ۋZ|۪ϻp\7@%H@EI _YC`6A)nuܠLH Mg` CFi d8։t< Oī x: *s(>ZN2O8IQo$~mtcXFۥwTHD{s Fzu%G]{+&2b"(@o$ >$Gy(OPH1$\?He)R2|. Kͱr\a1=EK^&e0gHf>3!hfrimA ͙cP ]5[MGsL;Nk8ְU1{5U(hQN-jZִfiMfvV+ck▶iqs*6bjusy.\TmeyX E.y]WnuSս]N ]Ԟ*|jju%M\{T5oO͒da{Y wV/};jx|Kx&~숣bƘ/֯J?, 1CZeM\Y?V $w2kR+SQήmd8X6nX# =.Kyov{s;f2p\.1N6S#2]HwwsTLS63AЃt5-QT ISֳ̳[Nǫt}QIW1֠6u\j1[Եt==e] 6KykDO8}QMco;5{-S3:۬.jYnw_ٻL|'1 q p;k+-;`66M>zf£lZ$o3Gr;]EHǝ24:ЭtS3:e}s~gcq'`V}lo}(֡c:<:>Y8:dc7|^s /v_[|[ϏWv.sWq>}zq_gMcPomU?M͛޷Ǿ?yC__ϼ~_?^6!}8}u~:WBdɔ(uiGwq)sIuiwjgw" ~(A 8q(| +=ݘ%yFIHظ}阆yG=xyji4Y? Yi9 9ٛc90Yö,)ye9`Yɜyɛ ⩜ : މ x)쉟ɟṝ֩ɓbʝTzj4K yYh`lM4I (:ٖhɠX1z6z:8Zɚ!ʙDiB 9ɢ#DZiz/J@ڢ W٥]ٙ"*XXa _g:lZd:' tڣ(I03ڧ uʣ 㹧YGJiCʤZ&:wJ>ڤnjNꅢT꧛:ZJz:IJzW*z jJJ:Zڬj|ڨAZdʡjڦ檚*Tꚭzj[:Ev4zQZ|X kZ{ZZߺy*Sʫ Ժʮʪ&꥓%벣:aʱ:4ZH9˳!K #P{ʭLzxXRJ;[c۩d˩Byk˶mo qT\V۵*e˷g fk{"kڷ 0A˯Ht;K?봉ڳ"Oʸ-10Ⱥ wk3{ ˲bB;*y+۸){;G;ҹ6D{z:8[ڼU뵆۰x+˻E;Kk9J[k[;Vq{+k̋+{;닿,˽ k,{[0켳(l$|F떽>l‘ۿ K [Q y+\1-/T~R{Mnm;iF^ -ӱ}> ]?^=C.Z=o6n8[\wN۝-愎}Ý茮n]N.J; pincushion.gifpGIFf8BIMGIFf8BIM^x= [Adobe Photoshop 3.0xHH(EG(HH(d'hHH H/fflff/ff2Z5-pTp HHTp TpTpHHEUTpTp^~PICT9 ;%STR 28BIM>PICTpnoticl8ICN#p0'|9oڀWXY#include #include #include #include #include #include #include #include "ssv.h" #include "pic.h" #pragma noroot #pragma lint -1 /* buf is a pointer to the first 1024 bytes of the file. */ int determinePicType(char *buf, GSString255Ptr pathname) { static FileInfoRecGS fi; fi.pCount = 9; fi.optionList = NULL; fi.pathname = pathname; GetFileInfoGS(&fi); if ((fi.fileType == 0xC1) && (fi.auxType == 0x2l)) return IMAGE_3200; /* Check for TIFF */ if ((buf[0] == 'I') && (buf[1] == 'I')) { /* check for "intel TIFF" */ if ((buf[2] == 42) && (buf[3] == 0)) return IMAGE_TIFF; } if ((buf[0] == 'M') && (buf[1] == 'M')) { /* check for "Motorola TIFF" */ if ((buf[2] == 0) && (buf[3] == 42)) return IMAGE_TIFF; } /* Check for regular GIF files */ if ((!strncmp("GIF87a",buf,6)) || (!strncmp("GIF89a",buf,6))) return IMAGE_GIF; /* Check for America Online Header */ if ((!strncmp("GIF87a",buf+20,6)) || (!strncmp("GIF89a",buf+20,6))) return IMAGE_GIF; /* Check for Macintosh PICT2 file */ if ((buf[512+10] == 0) && (buf[512+11] == 0x11) && (buf[512+12] == 0x02) && (buf[512+13] == 0xFF)) return IMAGE_PICT2; if (identify_targa(buf) == 0) return IMAGE_TARGA; if (fi.eof == 38400l) return IMAGE_3200; return -1; /* Unknown image type */ } [\]SecondView Release Notes 1.0a5 - July 14, 1995 [7/14/95] Added 15/16 bit support for RGB monitors by linking with new library (means you can view '3200' pics on the RGB monitor - if you have the new ROM). [7/11/95] Relinked with the vgalib memcpy bug fix. 1.0a4 - July 10, 1995 [7/7/95] Fixed a bug in iqgif.asm that caused SView to crash whenever a GIF comment extension was present. [6/14/95] Added support for "RAW" 3200 color image files; i.e., uncompressed 3200's. Someone who cares can add support for APF 3200's. 1.0a3 - June 9, 1995 Added support for basic TARGA 15/16 bit files. Waiting for the specification document to complete this. 1.0a2 - June 5, 1995 Pictures that were larger than 512K uncompressed were overwriting the VGA firmware and causing the board to crash. Images are now truncated (until the firmware supports uploading data to the upper 512K). Interlaced GIF image support fixed. Memory management revamped - image modules are now responsible for allocating their own image buffer memory (via NewHandle). This will make memory management much more stable and flexible. Some PICT support. Only PICT's that have a single, 8-bit pixel map in them will display properly (and only the bitmap will show). Full PICT object-based art is complex and will take a while to do. A sample PICT file is included for your enjoyment. 1.0a Initial Version. Pretty buggy, and the GIF loader is slow. It _is_ the first attempt, after all :-) _`aSecond Sight Firmware Update v1.1 --------------------------------- The IIe Double Hires mode is now supported in both color and monochrome modes. You can turn on the monochrome mode via the 'Display' control panel's "Display Type" setting (Color/Monochrome). Only the Double Hires mode is currently affected by this switch. There were numerous problems with IIGS SHR programs that used multiple palettes, in both 320 and 640 modes. An incomplete list of programs reported to have problems is below: DuelTris Easy Eyes (Softdisk) HyperStudio These palette problems have been fixed. The foreign language characters that the IIGS supports are now supported by Second Sight as well. Misc. PC character set characters that had different looks from their GS counterparts have been modified (the vertical bar character is now solid, etc). Care is now taken to prevent the GS from overwriting softswitch data when a video write takes place. This used to cause problems with certain programs that would not switch into (or out of) Super Hires mode [ For instance, when returning to Finder from BASIC.SYSTEM, the 80-column text mode is supposed to be active, but Super Hires mode was turned on by error ] The "solid apple" mouse-text character was inadvertantly left out of the Apple RGB font. This was fixed. Shadowing of Apple II video data can now be entirely disabled so application authors have more than 64K of Z180 memory to upload code/data to. cdefghijklmnopqrstuvwxyz{|}~/************************************************************************ Genesys created ORCA/C program code - REQUIRES ORCA/C V1.1 or later Translator by Doni G. Grande ORCAC.SCG 1.2.1 NOTE: Only routines which have resources are generated. ************************************************************************/ /* Default optimization options for program ...set to what you want */ #define DEFOPTIMIZE 0 #pragma optimize DEFOPTIMIZE /* Add/delete the tools you need for your program */ #include /* Orca/C definitions */ #include /* Control manager */ #include /* Desk manager */ #include /* Event manager */ #include /* GS/OS */ #include /* Line Edit Tool set */ #include /* Tool locator */ #include /* Menu manager */ #include /* Miscellaneous Tool set */ #include /* QuickDraw II */ #include /* Integer math */ #include /* QuickDraw Auxiliary */ #include /* Resource manager */ #include /* Scrap manager */ #include /* Window manager */ #include /* Font manager */ #include #include "ssv.h" /************************************************************************ Menu item numbers for standard DA menu items ************************************************************************/ #define UndoItem 250 #define CutItem 251 #define CopyItem 252 #define PasteItem 253 #define ClearItem 254 #define CloseItem 255 #define AboutItem 256 #define QuitItem 257 #define NewItem 258 #define OpenItem 259 #define SaveItem 260 #define SaveAsItem 261 #define RevertToSavedItem 262 /************************************************************************ Use Generate Equates... from Genesys and Paste them here! ************************************************************************/ /************************************************************************ Standard global data ************************************************************************/ long startStopAddr ; /* Space for StartStopRec from Tool Locator */ int QuitFlag ; /* Set to true when time to quit program */ /* Flag telling if the system window is the top window or not. This is set to the output of a GetWKind call. */ int WindType ; WindowPtr WindowPointer; /* space for window pointer */ Handle TargetCtl ; /* Handle of current target control */ /************************************************************************ Resource locking flag. If you want locked memory handles on resources you load this flag should be 1. If 0, your handles mat move around. ************************************************************************/ #define LOCKRESHANDLES 1 /************************************************************************ LoadRes used to load resources and optionally lock the handle based on value of LOCKRESHANDLES. The Handle is returned. ************************************************************************/ Handle LastResHNDL ; /* For LoadRes macro */ #if LOCKRESHANDLES /* Setup our LoadRes macro */ #define LoadRes(type,num) (LastResHNDL=LoadResource((word)type,(long)num), \ HLock(LastResHNDL), LastResHNDL) #else #define LoadRes(type,num) (LastResHNDL=LoadResource((word)type,(long)num) #endif /************************************************************************* Most resources in your resource fork are called by Tool calls. If you want to access some directly, call this routine. Handle to the resource is returned. **************************************************************************/ /**************************** Pascal Strings ***************************** Prototypes and descriptions of defined macros: char *GetRPString(long yourString) This macro returns a pointer to a PString in a resource. **************************************************************************/ #define GetRPString(yourString) ((char *)(*LoadRes(rPString,yourString))) #define FIRSTMENUBAR 1 /* First menu bar defined in resource fork */ /****************************** Menu Bars ******************************** Prototypes and descriptions of defined macros: MenuBarRecHndl DoRMenuBar(long menuBarRef, WindowPtr wPtr) This routine gives your your choice of creating your program's menu bar or a menu bar in a window. Just pass a NULL for your program's menu bar, or a window pointer. Returns menu bar handle. **************************************************************************/ MenuBarRecHndl DoRMenuBar(long menuBarRef, WindowPtr wPtr) { MenuBarRecHndl MyMenuBarRecHndl ; MyMenuBarRecHndl = NewMenuBar2((word) 2, menuBarRef, wPtr); if (wPtr == NULL) { /* create program menu bar */ SetSysBar(MyMenuBarRecHndl); SetMenuBar(NULL); RefreshDesktop(0L); /* Refresh the whole desktop */ FixAppleMenu(1); /* change if apple menu not 1 */ FixMenuBar(); } DrawMenuBar(); return MyMenuBarRecHndl ; /* Return handle to menu bar record */ } /********************************* Menus ********************************* Prototypes and descriptions of defined macros: Handle DoRMenu(long menuRef) This routine allocates a single menu from a resource and returns a handle to the menu created. Note that the menu is created in memory only; if you want it to appear in some menu bar, call the InsertMenu toolbox call. **************************************************************************/ #define DoRMenu(menuRef) NewMenu2((word) 2, (long) menuRef) /****************************** Menu Items ******************************* Prototypes and descriptions of defined macros: void InsertRMItem( long menuItemRef,int insertAfter,int menuNum) Insert a menu item from a resource into an existing menu using the InsertMItem2 tool call. "insertAfter" is 0 for top of menu, -1 for the bottom). "menuNum" which menu item goes into **************************************************************************/ #define InsertRMItem(menuItemRef,insertAfter,menuNum) \ InsertMItem2(2, (long)menuItemRef, (int)insertAfter, (int)menuNum) #define FIRSTWINDOW 4090 /* First window defined in resources */ /************************* DrawContent Routine *************************** Prototype and description of defined routine: void DrawContent(void) This is a generic TaskMaster drawing procedure that can be used by your NewWindow2 calls. Modify this routine as needed, or copy it for specialized cases for window drawing. This routine is called by TaskMaster automatically when you specify it as the window's draw content procedure. Whenever your window needs to be redrawn by TaskMaster, the window manager will call it. **************************************************************************/ #pragma databank 1 #pragma toolparms 1 void DrawContent(void) { DrawControls(GetPort()); /* Draw controls in current window */ } #pragma toolparms 0 #pragma databank 0 /************************ DoNewWindow Window Routine ********************* This is a generic function that will allow you to pass the resource ID of your window, and will open your window, as well as set it's grafport for you. It returns the window pointer of the window opened. **************************************************************************/ WindowPtr DoNewWindow(long windowID ) { WindowPtr wPtr; /* Pointer to window's GrafPort */ Handle wHandle ; /* Handle to window's resource template */ Handle colorsH ; /* Handle to window's color resource template */ struct wTemplate { /* Kludgy way to get at the data we need */ char stuff1[0x14]; long p1Color ; char stuff2[0x32]; long ControlList ; word p1InVerb ; } *wTemplatePtr; /* Apply fix for system software window color table bug */ wHandle = LoadRes(rWindParam1, windowID); /* Get handle to resource */ HLock(wHandle); /* Lock it, no matter what! */ DetachResource(0x800E, windowID); /* now its ours */ wTemplatePtr = (void *) *wHandle ; /* ref by pointer */ /* load in color table */ colorsH = LoadResource(0x8010, wTemplatePtr->p1Color); /* If no color table or error, clear ref to color resource and color ref */ if (toolerror()) { if (wTemplatePtr->p1InVerb & 0x0800) { wTemplatePtr->p1InVerb != 0x0800; } wTemplatePtr->p1Color = 0L; } /* Color table loaded ok, so lock the handle and set refs to handle */ else { DetachResource(0x8010, wTemplatePtr->p1Color); HLock(colorsH); if (wTemplatePtr->p1InVerb & 0x0800) { wTemplatePtr->p1InVerb ^= 0x0800; } wTemplatePtr->p1InVerb |= 0x0400; wTemplatePtr->p1Color = (long) colorsH; }; /* Call NewWindow2 with patched color table */ wPtr = NewWindow2(NULL, /* desired window title */ 0x00000000L, /* refcon for the window */ (VoidProcPtr)DrawContent, /* routine to draw it */ (LongProcPtr) NULL, /* info draw routine */ 0x0001, /* use the handle */ (long) wHandle, /* modified handle */ rWindParam1); /* standard type window */ /* Set the port */ SetPort(wPtr); return wPtr; } /**************************** Window Color ******************************* Prototypes and descriptions of defined macros: WindColorPtr GetRWindColor(long colorNum) Load and return a pointer to a window color resource. **************************************************************************/ #define GetRWindColor(colorNum) (WindColorPtr) *(LoadRes(0x8010,colorNum)) #define TOOLSTARTRES 1 /* First Tool startup defined in resources */ /**************************** Tool Startup ******************************* Prototype and description of defined routine: int StartUpMyTools(void) This routine starts up your tools. NOTE that although you may have more than one tool startup table defined with Genesys, this routine uses the first one it encounters (you should only have one tool startup table defined anyway). If tools started, 0 returned, else -1 for error. returned for an error. **************************************************************************/ #define Tool_Startup_Table 1 int StartUpMyTools(void) { int returncode ; startStopAddr = StartUpTools(userid(), 2, (long) Tool_Startup_Table); if (toolerror()) { returncode = -1; } else { returncode = 0; } return returncode ; } /************************************************************************* Prototype and description of defined routine: void ShutDownMyTools(void) Shut down the tools started by the procedure StartUpMyTools. **************************************************************************/ void ShutDownMyTools(void) { ShutDownTools(1, startStopAddr); /* Note that Orca/C will call MMShutDown and TLShutDown on exit */ } #define FIRSTALERT 1 /* First alert defined in resources */ /******************************* Alerts ********************************** Prototypes and descriptions of defined routines: int DoSimpleAlert(long alertID) Call an alert from a resource and return the number of button pressed (0 for leftmost, 1 for next, 2 for last. int DoAlertC(long alertID, char *S0, char *S1, ..., char *S9, NULL) Call an alert and pass up to ten C substitution strings. The string list must end with a NULL. int DoAlertP(long alertID, char *S0, char *S1, ..., char *S9) Call an alert and pass up to ten Pascal sub strings. The string list must end with a NULL. NOTE: The alertID passed to DoAlertC and DoAlertP MUST BE A LONG!!! Orca C stack fixup is turned off for these routines so that a variable number of arguments may be passed, so you must behave yourself when using these calls! **************************************************************************/ #pragma optimize 8 #include int DoAlertC(long alertID, ...) { long str; /* Pointer to input C strings */ long MsgArray[10] ; /* Array of pointers to C strings */ int i; /* Array index */ va_list ap; /* List of elements passed to function */ i=0; /* Init index */ va_start(ap, alertID); /* Init vararg processing */ while ( (str = va_arg(ap,long)) && (i<10) ) { /* List ends w/NULL */ MsgArray[i++] = str ; /* Point to string */ } va_end(ap); /* Got all the strings */ /* Ref is resource w/C substitution strings */ return AlertWindow(4, (Pointer) MsgArray, (Ref) alertID) ; } int DoAlertP(long alertID, ...) { long str; /* Pointer to input P strings */ long MsgArray[10] ; /* Array of pointers to P strings */ int i; /* Array index */ va_list ap; /* List of elements passed to function */ i=0; /* Init index */ va_start(ap, alertID); /* Init vararg processing */ while ( (str = va_arg(ap,long)) && (i<10) ) { /* List ends w/NULL */ MsgArray[i++] = str ; /* Point to string */ } va_end(ap); /* Got all the strings */ /* Ref is resource w/P substitution strings */ return AlertWindow(5, (Pointer) MsgArray, (Ref) alertID) ; } #pragma optimize DEFOPTIMIZE /************************************************************************** The following is generated by Genesys in case you forgot to add a tool table as a resource. Once added, delete eveything from #ifndef TOOLSTARTRES to the #endif. **************************************************************************/ #ifndef TOOLSTARTRES typedef struct MyToolSpec { word toolNumber; word minVersion; }; typedef struct ToolStartupRec { word flags; word videoMode; word resFileID; long dPageHandle; word numTools; struct MyToolSpec toolArray[]; } ; struct ToolStartupRec TSTART = { 0x0000, /* flags */ 0xC080, /* videoMode */ 0, 0L, /* resFileID & dPageHandle are set by the StartUpTools call */ 0x0014, /* numTools */ 1, 0x0300, /* Tool Locator */ 2, 0x0300, /* Memory Manager */ 3, 0x0300, /* Miscellaneous Tools */ 4, 0x0301, /* QuickDraw II */ 5, 0x0302, /* Desk Manager */ 6, 0x0300, /* Event Manager */ 11, 0x0200, /* Integer Math */ 14, 0x0301, /* Window Manager */ 15, 0x0301, /* Menu Manager */ 16, 0x0301, /* Control Manager */ 18, 0x0301, /* QuickDraw II Aux. */ 19, 0x0300, /* Print Manager */ 20, 0x0301, /* LineEdit Tools */ 21, 0x0301, /* Dialog Manager */ 22, 0x0300, /* Scrap Manager */ 23, 0x0301, /* Standard File Tools */ 27, 0x0301, /* Font Manager */ 28, 0x0301, /* List Manager */ 30, 0x0100, /* Resource Manager */ 34, 0x0101 /* TextEdit Manager */ }; int StartUpMyTools(void) { int returncode ; startStopAddr = StartUpTools(userid(), 0, (long) &TSTART); if (toolerror()) { returncode = -1; } else { returncode = 0; } return returncode ; } void ShutDownMyTools(void) { ShutDownTools(0, startStopAddr); } #endif #if 0 /************************************************************************ * Determines if the current target control is a LineEdit control or not. * Returns a handle to the LE data if the current target is an editLine * control, NULL if not. ************************************************************************/ Handle IsItLineEdit(void) { CtlRecHndl LECtlRecHandle ; /* Handle to LE control record */ LECtlRecHandle = (void *) FindTargetCtl(); /* Get handle of target ctrl*/ if (toolerror()) return NULL ; /* No control, so return */ /* if bit 12 of control's MoreFlags is set, then it may be a LE control*/ if ( GetCtlMoreFlags(LECtlRecHandle) & 0x1000 ) { /* Check for Control proc pointer = $83000000 == LE control */ if ( (long) (*LECtlRecHandle)->ctlProc == editLineControl ) { /* Got LE control! */ return (Handle) (*LECtlRecHandle)->ctlData ; /* So return handle to data */ } } /* If we make it here, then we don't have a LE control */ return NULL ; } #endif /************************************************************************ * Generic error handling routine. Pass the error number. ************************************************************************/ void FatalError(void) { GrafOff(); /* Turn off graphics display */ puts("A fatal error has occurred. Press any key to exit."); getchar(); /* Wait for a keystroke */ ShutDownMyTools(); /* Close any tools started */ exit(1); /* Exit with an error */ } /************************************************************************ * Load and init the tools, handle any errors, create the menu bar. ************************************************************************/ void InitTools(void) { #ifndef FIRSTMENUBAR char DEFMSG[] = "72~I'm sorry, but you did not define a menu bar " "within Genesys. Without a menu bar, there is no " "way for you to exit your application. Please " "quit now and add a menu bar.~^#5"; #endif /* Startup all tools from resource. */ if (StartUpMyTools()) FatalError(); /* Now create the system menu bar if possible */ #ifndef FIRSTMENUBAR InitCursor(); AlertWindow(0, 0L, DEFMSG); ShutDownMyTools(); /* Close any tools started */ exit(1); /* Exit with an error */ #else DoRMenuBar(FIRSTMENUBAR,NULL); #endif } /************************************************************************ * * Perform any application specific initialization. * All we do is initialize QuitFlag to zero and create our window. * ************************************************************************/ void InitApp(void) { QuitFlag = 0 ; /* Zero QuitFlag */ WindType = 0x8000 ; /* and set WindType for system window */ /* WindowPointer = DoNewWindow(FIRSTWINDOW); if(toolerror()) FatalError(); ShowWindow(WindowPointer); */ SetMenuBar(0L); /* Set system menu bar */ InitCursor(); } /************************************************************************ * Close down things. Usually undoes what was done in InitApp. Kill memory. ************************************************************************/ void CloseApp(void) { /* We don't close our window since Orca/C does it for us. */ } /************************************************************************ * * Routines for Menu selection * ************************************************************************/ /************************************************************************ * * Quit routine. Set the QuitFlag to TRUE for the EventLoop. * ************************************************************************/ void doQuit() { QuitFlag = -1 ; /* Set flag to exit event loop */ } /************************************************************************ * * Bring up an Alert Dailog box with our name in it. * ************************************************************************/ void doAbout() { #ifndef FIRSTALERT char DEFALERT[] = "73~This program was generated by Genesys, " "using the Orca C Template developed by " "Doni G. Grande. To put your About... " "message here, just add an Alert resource " "using Genesys.~^#0"; AlertWindow(0, 0L, DEFALERT); #else DoSimpleAlert(FIRSTALERT); #endif } /************************************************************************ * * Called by the MenuSelect routine to handle the * "cut" standard menu item. * ************************************************************************/ void doCut(void) { #if 0 Handle leDataHandle ; /* Handle to Line Edit data */ WindowPtr CurrentGrafPortPtr ; /* Current GrafPort pointer */ /* Check to see if we were in an LE control when the menu was selected */ leDataHandle = IsItLineEdit() ; if (leDataHandle == NULL ) return ; /* Exit if not LE control */ CurrentGrafPortPtr = GetPort() ; /* Save current GrafPort pointer */ StartDrawing(FrontWindow()) ; /* Start drawing in our window */ LECut(leDataHandle); /* Cut date to LE scrap */ SetOrigin(0,0); /* Set port origin to 0,0 */ SetPort(CurrentGrafPortPtr) ; /* Switch back to original GrafPort */ ZeroScrap() ; /* Zero out any old desk scrap */ if ( LEGetScrapLen() != 0 ) /* If there is LE scrap ... */ LEToScrap() ; /* copy it to the desk scrap */ #endif } /************************************************************************ * * Called by the MenuSelect routine to handle the "copy" standard menu item. * ************************************************************************/ void doCopy(void) { #if 0 Handle leDataHandle ; /* Handle to Line Edit data */ WindowPtr CurrentGrafPortPtr ; /* Current GrafPort pointer */ /* Check to see if we were in an LE control when the menu was selected */ leDataHandle = IsItLineEdit() ; if (leDataHandle == NULL ) return ; /* Exit if not LE control */ CurrentGrafPortPtr = GetPort() ; /* Save current GrafPort pointer */ StartDrawing(FrontWindow()) ; /* Start drawing in our window */ LECopy(leDataHandle); /* Cut date to LE scrap */ SetOrigin(0,0); /* Set port origin to 0,0 */ SetPort(CurrentGrafPortPtr) ; /* Switch back to original GrafPort */ ZeroScrap() ; /* Zero out any old desk scrap */ if ( LEGetScrapLen() != 0 ) /* If there is LE scrap ... */ LEToScrap() ; /* copy it to the desk scrap */ #endif } /************************************************************************ * * Called by the MenuSelect routine to handle the "paste" standard menu item. * ************************************************************************/ void doPaste() { #if 0 Handle leDataHandle ; /* Handle to Line Edit data */ WindowPtr CurrentGrafPortPtr ; /* Current GrafPort pointer */ /* Check to see if we were in an LE control when the menu was selected */ leDataHandle = IsItLineEdit() ; if (leDataHandle == NULL ) return ; /* Exit if not LE control */ LEFromScrap() ; /* Get LE scrap from desk scrap */ CurrentGrafPortPtr = GetPort() ; /* Save current GrafPort pointer */ StartDrawing(FrontWindow()) ; /* Start drawing in our window */ LEPaste(leDataHandle); /* Paste from LE scrap */ SetOrigin(0,0); /* Set port origin to 0,0 */ SetPort(CurrentGrafPortPtr) ; /* Switch back to original GrafPort */ #endif } /************************************************************************ * * Called by the MenuSelect routine to handle the "clear" standard menu item. * ************************************************************************/ void doClear(void) { #if 0 Handle leDataHandle ; /* Handle to Line Edit data */ WindowPtr CurrentGrafPortPtr ; /* Current GrafPort pointer */ /* Check to see if we were in an LE control when the menu was selected */ leDataHandle = IsItLineEdit() ; if (leDataHandle == NULL ) return ; /* Exit if not LE control */ CurrentGrafPortPtr = GetPort() ; /* Save current GrafPort pointer */ StartDrawing(FrontWindow()) ; /* Start drawing in our window */ LEDelete(); /* Delete from LE window */ SetOrigin(0,0); /* Set port origin to 0,0 */ SetPort(CurrentGrafPortPtr) ; /* Switch back to original GrafPort */ #endif } void open_files(void) { extern int show_gif(GSString255Ptr); SFReplyRec2 repl = {0,0,0l,3,0l,3,0l}; ResultBuf255Ptr rf,rp; SFGetFile2(50,50,0,"\pSelect a picture file to view",NULL,NULL,&repl); if (!repl.good) return; rp = (ResultBuf255Ptr) *((ResultBuf255Hndl) repl.pathRef); rf = (ResultBuf255Ptr) *((ResultBuf255Hndl) repl.nameRef); show_picture((GSString255Ptr) &rf->bufString, (GSString255Ptr) &rp->bufString); } /************************************************************************ * Menu event handling. ************************************************************************/ void MenuSelect(long menuID) { switch (menuID & 0x0000FFFFL) { case UndoItem : /* Add in whatever your application does for Undo */ break ; case CutItem : doCut() ; break ; case CopyItem : doCopy() ; break ; case PasteItem : doPaste() ; break ; case ClearItem : doClear() ; break ; case CloseItem : /* Add in whatever your application does for Close */ break ; case AboutItem : /* About item */ doAbout(); break ; case QuitItem : /* Quit item */ doQuit() ; break ; case NewItem : /* New item */ break ; case OpenItem : /* Open item */ open_files(); break ; case SaveItem : /* Save item */ break ; case SaveAsItem : /* Save As... item */ break ; case RevertToSavedItem : /* Revert to Saved item */ break ; } HiliteMenu(0,(int) (menuID >> 16)) ; /* Un-hilite menu title */ } /************************************************************************ * * Main event loop * ************************************************************************/ /************************************************************************ * * This routine is called on every NULL event. It checks the type of the top * window, and enables the system menus if necessary. * ************************************************************************/ void testTopWindow(void) { WindowPtr ThisWindow; /* Used to test which window is in front */ ThisWindow = FrontWindow(); /* Get pointer to the front window */ if (GetWKind(ThisWindow) != WindType ) { /* The window kind has changed, so have to change menus */ WindType ^= 0x8000 ; /* Flip high bit of WindType */ if (WindType & 0x8000 ) { /* If high bit is set, then system window */ /* Enable Edit menu if system menu is active */ EnableMItem(UndoItem); EnableMItem(CutItem); EnableMItem(CopyItem); EnableMItem(PasteItem); EnableMItem(ClearItem); EnableMItem(CloseItem); } else { /* Disable Edit menu if application menu is active */ /* You can leave some of these if your application uses them */ DisableMItem(UndoItem); DisableMItem(CutItem); DisableMItem(CopyItem); DisableMItem(PasteItem); DisableMItem(ClearItem); DisableMItem(CloseItem); } } } /*********************************************************************** * * Called to handle clicks in a window's contents. * ************************************************************************/ void InContent(void) { /* Add in whatever your application needs to do */ } /************************************************************************ * * Called to handle clicks in a window's controls. * ************************************************************************/ void InControls(void) { /* Add in whatever your application needs to do */ } /************************************************************************ * * Main Event Loop. Handle things until user selects Quit. * This represents a typical event loop. Just place the routine calls you * will be using here depending on the action that occurs. * ************************************************************************/ void EventLoop(void) { EventRecord MyEventRecord ; /* Setup an event record for my use */ int Event ; /* Event number returned by TaskMaster */ MyEventRecord.wmTaskMask = 0x001FFFFFL ; /* Handle all events possible */ QuitFlag = 0 ; /* Clear quit flag */ do { testTopWindow(); /* Check top window for DA and setup if needed */ /* Get next event, letting TaskMaster handle everything it can */ Event = TaskMaster(everyEvent , &MyEventRecord ) ; switch (Event) { case wInSpecial: /* Handle undo, cut, copy, paste, close cmd*/ case wInMenuBar: /* Handle menu events */ MenuSelect((long) MyEventRecord.wmTaskData ) ; break ; case wInContent: /* In the content region */ InContent(); break ; case wInControl : /* In a control */ InControls(); break ; case wInGoAway : /* In window's close box */ CloseWindow((WindowPtr) MyEventRecord.wmTaskData ) ; break ; } } while (!QuitFlag); /* Keep going until quitflag is set */ } /************************************************************************ * * This is the main routine. It calls all routines needed to run * the application. * ************************************************************************/ void main(void) { extern int init_picview(void); InitTools(); /* Initialize tools */ InitApp(); /* Init Application specific info */ if (init_picview() == 0) { ShowCursor(); /* Display cursor */ EventLoop(); /* Do user events */ } CloseApp(); /* Shutdown application */ ShutDownMyTools(); /* Shutdown tools */ } %SSV.H 5ž" @WSSV.TMP^ 5 @VSSVIEWv5 @'TARGA.C* 5ɾ @&TIFF.C2 5;@-TRUE2HIGH.ASM=5þ5 @/* Genesys created ORCA/C resource equate generation. */ /* Paste these into your code to reference resources. */ /* ORCACPROG.SCG 1.2.1 */ /************************************************************************* These are the defines that should be placed before your code **************************************************************************/ #define Apple_pString 1 #define File_pString 2 #define Edit_pString 3 #define Undo_pString 250 #define Cut_pString 251 #define Copy_pString 252 #define Paste_pString 253 #define Clear_pString 254 #define Close_pString 255 #define About_pString 256 #define Quit_pString 257 #define New_pString 258 #define Open_pString 259 #define Save_pString 260 #define SaveAs_pString 261 #define Revert_pString 262 #define PSTR_00010005 65541 /************************************************************************* These are the defines that should be placed before your code **************************************************************************/ #define Application_Menu_Bar 1 /************************************************************************* These are the defines that should be placed before your code **************************************************************************/ #define Apple_Menu 1 #define File_Menu 2 #define Edit_Menu 3 /************************************************************************* These are the defines that should be placed before your code **************************************************************************/ #define Undo_Menu_Item 250 #define Cut_Menu_Item 251 #define Copy_Menu_Item 252 #define Paste_Menu_Item 253 #define Clear_Menu_Item 254 #define Close_Menu_Item 255 #define About_Menu_Item 256 #define Quit_Menu_Item 257 #define New_Menu_Item 258 #define Open_Menu_Item 259 #define Save_Menu_Item 260 #define SaveAs_Menu_Item 261 #define Revert_Menu_Item 262 /************************************************************************* These are the defines that should be placed before your code **************************************************************************/ #define WPARAM1_00000FFA 4090 /************************************************************************* These are the defines that should be placed before your code **************************************************************************/ #define WCOLOR_00000001 1 /************************************************************************* These are the defines that should be placed before your code **************************************************************************/ #define Tool_Startup_Table 1 /************************************************************************* These are the defines that should be placed before your code **************************************************************************/ #define ALERT_00000001 1 /* --- end Genesys equates --- */ WindowPtr DoNewWindow(long windowID ); #define DoSimpleAlert(alertID) (AlertWindow(5, 0L, (Ref) alertID)) #define xmalloc(a) malloc(a) /*#define xfree(a) free(a)*/ #define xfree(a)   ssv.tmpp^pdos- p^pdos OoOpen...Ww@CloseSsSave Save as...@Revert to savedQqQuit Edit Zz@UndoXxCutCcCopyVvPasteClearApplication Menu Bar "@??@ File NnNew54~Error opening image file.~^#052~Not enough memory to view this picture.~#052~This file is not a GIF image.~^#0PV~52~Some fatal error occurred trying to load the GIF file.~On no!52~Not a proper TIFF file.~^#052~SecondView does not support 24-bit TIFF files yet.~^#052~Unknown file type - not a TIFF or GIF.~^#052~Unknown error loading picture. ~#073~Your Second Sight is only an 8-bit model, and you need 24-bit capability to view this picture. ~^#0#2#2~^Cool!Cool!52~No Second Sight video adaptor detected in your system.~I'd Better Buy One!43~Second View v1.0a6 Second Sight Image Viewer By Tim Meekins and Jawaid Bazyar Copyright 1995, Sequential Systems~^Cool!73~Your Second Sight is only an 8-bit model, and you need 24-bit capability to view this picture. Call Sequential at 800-759-4549 to inquire about the 24-bit Upgrade. ~^#0s W Apple Menu File Menu Edit Menu About pString Apple pString Clear pString Close pString Copy pString Cut pString Edit pString File pString New pString Open pStringRevert pString Paste pString Quit pString Save pStringSaveAs pString Undo pStringAbout SecondView "Picture Name" e.~#1~#3~^#2tring namesTool Startup TableMenu Bar names  Menu Names Menu Item namesTool Table names pString names rName names About Menu ItemClear Menu ItemClose Menu ItemCopy Menu Item Cut Menu ItemRevert Menu Item New Menu ItemOpen Menu ItemPaste Menu ItemQuit Menu ItemSave Menu ItemSaveAs Menu ItemUndo Menu Item63~Second GIF Second Sight GIF Image Viewer Copyright 1995, Sequential Systems~^Cool!P,6 73~Second View Second Sight 8-bit Image Viewer Copyright 1995, Sequential Systems~^Cool!P  F8U{Gr W ZSD 5 L_qN _ 2 T" " > Q c v   F      Pt P v T1 1  s| !.%fA;. /& O   !"#$%&'()k*F x/,C ~ExpressLoad/F:wu7A ,E {>,E picviewl *_,E pict+j2?,E targa25,,E a32006<|,E gnolib =Eo,E vgalibu0E u"""$";8  [HHHC"ͣ hhH "9"9"ͩH"H"h*"ͥ   +;ik;8 [hHH"͢"ͥH+;ik;8 [HHH$""ͣhhH "ͮHhh "ͩH$""͠HHhhHHHHH"ͣhh ں "f h .N)N芠ȩzHHH" "͠N)iNIHhiN HhHȣhhHHHHHa"ͣ  hh "ͥ  $#+;i"k;8 [HHں"khHH"ͣhhں"fh+;ikH; [HH"+zk;8@ [ "H{iDHhchc"H{i9Hhchchh"H{i9Hhchchhhh"H"H{i9Hhchch h" H Hhchc  hchchHH hh$ 8 pI0ʊʆB  "H{iHhchchhhh{i9H"pHH{iHFDY"hBFAE+;iDk;8@ [ "H{iDHhchc"H{i9Hhchchh"H{i9Hhchchhhh"H"H{i9Hhchch h" H Hhchc  hchchHH hh$ 8 pI0ʊʆB  "H{iHhchchhhh{i9H"pHH{iHFDY"hBFAE+;iDkH; [ "ͦں"hں"hں"<hںH"h+zkA fatal error has occurred. Press any key to exit.H; [ں"hں"9hںH"h+zkH; [9"͢"+zkH; [+zkH; [+zkH; [HHY"h+zkH; [+zkH; [+zkH; [+zkH; [+zk;8" [d{ii{iHhiHhh{ii{iHhi Hhh{ii{iHhiHhh2H2HH {iH"ͥIf!HH  hhHH hhں hiH hiH"ch+;i"kSelect a picture file to view;8 [ h)H)hhbں"hMں"h8ں"h#ں"h ں"ehں"Xhں"hhh6hhhh hhhhhhhhhhhhhhhh~hh_hh@H H"hH,"ͥ  +;i k;8 [HH"ͣhhH+"hH8I)WH0"ͩH0"ͩH0"ͩH0"ͩH0"ͩH0"͂TH1"ͩH1"ͩH1"ͩH1"ͩH1"ͩH1"+;ikH; [+zkH; [+zk;88 [{i HhiHhhں" hHH{i H"h [ںH"< hzں" heں"hPH "͂=: 8 H`u     u        I&+;i8kH; [ں"hں"$hں"h"ͦں" hں"Qhں"<h+zk"3DUfw ;8a [dW eGI"e)Fei egigeGIFe)F9d e87980e)a# e)a WL;eiegige) 牅ddeeiegig( 3-/e)eg;L;! hL,נei')eie) 牅dd!eH)ei egig( 3-!/h)@LL\ eH"~ e!eiegig`ege)8eeeeggeg`HHHHiHiH ""kH "h]_ii]Yi][ie)eiegigi%H"a Y [ dUi' U ȄU' e) i "m%Ӡ i iWckbj+;iikHHHHiHiH ""kH "h]_ii]Yi][iiH"ae)eiegig i%Y [ qwyloop0dUi' qwxloop0 U ȄU') e i "m%8%0аqwdone0i8%) eY [i qwyloop1dUi' qwxloop1 U ȄU') e i "m%8%0аqwdone1i::%) eY [i qwyloop2dUi' qwxloop2 U ȄU') e i "m%8%0бqwdone2i:%)eY [i qwyloop3dUi' qwxloop3 U ȄU') e i "m%::%0дqwdone3L;75 剅AȄCȄ9 ; t =?Ai+A: I:`+ ʆ+i)` `A.: I:ʝI:75A ;Ai9d+ ?=`C h`3+9=i?A Ii) I=i9! ?)=I99; ; ;53?+LEdIdMdK`85EiJJJeIMIM((eeg)K!Je(ȷe(eeegeIMIȄM5 |(((" !"#$&L'(((E |7RbbbbbI () (^(^( IE`I () (^( IE`I()IE`I ()(JJJ(!EE`E |    I () ((JJJ( IE`I () (^(^( IE`I () (^( IE`I()IE`I ()(JJJJ(!EE`E |' 9 \  I () ((JJJJ( IE`I () ((JJJ( IE`I () (^(^( IE`I () (^( IE`I()IE`I ()(JJJJJ(!EE`E | !&!J!n!!!!!I () ((JJJJJ( IE`I () ((JJJJ( IE`I () ((JJJ( IE`I () (^(^( IE`I ()Jjjj(^( IE`I()IE`I ()?( **)(!EE`E |!!"8"Z"|""""I ()? (( **)( IE`I () ((JJJJJ( IE`I () ((JJJJ( IE`I () ((JJJ( IE`I ()Jjjj(^(^( IE`I ()Jjj(^( IE`I()IE`I ()( *)( E`E |""#1#R#s####I () (( *)( I`I ()? (( **)( I`I () ((JJJJJ( I`I () ((JJJJ( I`I ()Jjjj((JJJ( I`I ()Jjj(^(^( I`I ()Jj(^( I`I()I`E |###$B$g$$$$I(J()*IE`I() ( *)(( IE`I()? ( **)(( IE`I() (JJJJJ(( IE`I() (JJJJ(( IE`I() (JJJ(( IE`I() ^(^(( IE`I() ^( IE`E |$$%5%[%%%%%I() ^(( IE`I() ( IE`I() ( *)(( IE`I()? ( **)(( IE`I() (JJJJJ(( IE`I() (JJJJ(( IE`I() (JJJ(( IE`I() ^(^( IE`E |&/&O&m&&&&'-'I() ^(^(( IE`I() ^(( IE`I() ( IE`I() ( *)(( IE`I()? ( **)(( IE`I() (JJJJJ(( IE`I() (JJJJ(( IE`I() (JJJ( IE`E |Q'c''''' (7(b(I() (JJJ(( IE`I() ^(^(( IE`I() ^(( IE`I() ( IE`I() ( *)(( IE`I()? ( **)(( IE`I() (JJJJJ(( IE`I() (JJJJ(( IE`5I ^( jE EIII5J`The picture is not a GIF. @ @Loading GIF Image...;8R [ں{iKHVH"vhOQH  hh"H{iKHhchch)M))M*M*$HHY"ho )"ں "hH  hhں"H{iKHhchch)I芢 z"h H "ͦں "h H "ͦںH HVH"WhںH{iHVH"vh)ںH"hںH"h H "ͦںH ""~hHhhںH "VH"vh;8pI0ʊ)ں "eeH"hH "eehں "eeH"hH "eeihں "eeHH"hH "HheHehiHhhhh "eeO "eeHHʨhhں "ee H"hH "HheHehiHhhhhxں "ee HH"hH "HheHehiHhhhh "eeI "ee 53 "ee 9 "ee 7ںH"ah?;85I|II4IWI@*;ںė"h; "eeں"~hHhhں"~hHhhں"~hH!#hh5ںH; "ee HVH"Whں#!VH"vhںVH"vhںVH"vh85pI0ʊOHH Y"h58pI0ʊn)H"e!e#hH"eehH"eehy8pI0ʊr8)H"e!e#hH"eehH"eehufHHY"hں"Phں"Phں#!"PhںH"hH=?hhHhX?= XȣXhh8pI0ʊ"ee))H"e=e?ih  )"ee))H"e=e?h  )"e!e#))H"e=e?h  )H+-hhںH3 "ee HVH"Wh9HhX7HhXHhXں3 "ee HH"h H "ͦںXHXH[YH"UhHH9H7H" "ͣEGhhEGEHEHAChhCAXȣXhhGEXȣXhhں9H7H"CAVH"vhں"mhں"Phں"Phں#!"Phں"Phں"hdTZSY+;iXkMotorolaIntelByte ordering: %s IFD offset: %06lX # dir entries: %04X No color map to read!!!, we will probably have to build one Image Offset: %06lX Loading TIFF file %sgkpv}Į̃Ԩܨ"+6BLTYblz{|}~ ɩөݩ-:;<=HS^jtuvwªêĪŪϪ٪$3@ABC L U ^ h p q r s˫ի%2345>GPZbcderͬ٬NOPClipBkPatTxFontTxFaceTxModeSpExtraPnSizePnModePnPatFillPatOvSizeOriginTxSizeFgColorBkColorTxRatioVersionOpBkPixPatPnPixPatFillPixPatPnLocHFracChExtraRGBFgColRGBBkColHiliteModeHiliteColorDefHiliteOpColorLineLineFromShortLineShortLineFromLongTextDHTextDVTextDHDVTextfontNamelineJustifyglyphStateframeRectpaintRecteraseRectinvertRectfillRectframeSameRectpaintSameRecteraseSameRectinvertSameRectfillSameRectframeRRectpaintRRecteraseRRectinvertRRectfillRRectframeSameRRectpaintSameRRecteraseSameRRectinvertSameRRectfillSameRRectframeOvalpaintOvaleraseOvalinvertOvalfillOvalframeSameOvalpaintSameOvaleraseSameOvalinvertSameOvalfillSameOvalframeArcpaintArceraseArcinvertArcfillArcframeSameArcpaintSameArceraseSameArcinvertSameArcfillSameArcframePolypaintPolyerasePolyinvertPolyfillPolyframeSamePolypaintSamePolyeraseSamePolyinvertSamePolyfillSamePolyframeRgnpaintRgneraseRgninvertRgnfillRgnframeSameRgnpaintSameRgneraseSameRgninvertSameRgnfillSameRgnBitsRectBitsRgnPackBitsRectPackBitsRgnDirectBitsRectDirectBitsRgnShortCommentLongComment;8 [ Hhhi HhhhiHhhhhں H"h)Hhh_"e e)I5"e e)Ix"e e)*5"e e)w"e e)M5"e e)Mx"e e)5"e e)*ںH q"hI9ںH x"hI ںH"Hhe He"hISںH"Hhe He"hIU "e e)5 "e e)5 "e e)5 "e e)cں "h6Hhh  +;ikGIF87aGIF89aGIF87aGIF89a;8  [ ͵f i HH ""0 iHH ""0hh ȷHH "hh h h Hh ZH",h)H)h  ZH",h)H)h  Z)H)h"i   "i    " -d$Z czȷHH"´ե +;ik;8 [  뻽ZHhh֥ 뻽ZH  hh  M   hh     hHH hh뻀@     ܠHHh h +;ik;8 [ 뻽ZHh h  hh뻥  +;i k;8  [{iH"I8mǺǺ    +;ik;8% [-- -H-H"h"h$Ǻ$"hh  h)   h)   h)  {iH"+)"Ǻ )H)H""$"I'/&.+;i-k;8) [--$"-H-H"h&h(d d 黝眻/-"Ld{iHH"´(&hh$""$h)  $""$h)  $""$h)  {iH"H" ɺ &(&\" "ͥ+/*.+;i-k  @ @H h?ɻ`;8 [K  G8 ) ) )  i ȷ    +;ik;8 [   "  e e)"hwhw)"hwhw)" hwhwLĥϵLĩ8) ) )  i "e iLå  +;ik;8 [0u"~"<"hoho< ϵǺǺ  +;i k;8 [ H"~ HhiH H" ch)  +;ik; [x ƥ ƥ ƥ ƥ ƥ ƥ ƥ (  +;i k; [x ƥ ƥ ƥ Ơ  (+;ik; [x ƥ ƥ ƥ ƥ ƥ ƥ (  +;ik ` ` ɥɦ ` ϸ ` ϸ `;8 [x    c௲  GSȷVȷGȷA믲ઇ   (  +;i k; [x ƥ ƥ (+;ik; [x ƠT (+;ik;8 [dx ƥ ƥ ƥ ƥ ƥ ƥ ƥ ƥ ƥ ƥ ƥ) Ơ %  ƥ))d %d  (+;ikc) sOV]@F(@  c! `OPT(@  S[G\aplc) sOV]@FP@  Ȁß >@P@  H [  "$&(*,.02468:<>@BDFHJLNPRTVXZ\^`bdfhjlnprtvxz|~+`; ["+;ik ңLHH"k; [HH J     z +;i k; [HH J    z  +;i kϏ ;iH"v8hihz;mZګ'kHHH"zhZګk;8 [d) H" "+;ikKzhhZګϏ ;iH"v8hihz;mZګ'khzHګڮ ;[)+hhKϫk; [  +hhk;8 [00*  #   +;ikkk ;[8eʧ8;ID;o+zhhZګk; [ & dd ! f f+hhkH h\KzZڭHH; [Ҝ"]i # " Ȁ " Ȁ  Z8czHHHH "* Out of memory"%\h h  ҎmҐ  Ȁ  ҅ ҅ )s  "   i  ")0"!)    ҅ ҅ +hhkKHH ;[$hHHhk֯ "p+hh`Ϝhө rӍpH"ώjө rH"ώHH"lө rH"ώH" kraa"7 `nӭpӍ"9 !" Ӎn` .CONSOLEh(h*h hJ H 0H*H(Hk; [ & dd  !F f+hhk'H; [*8e쪥+zzkh@k H H; [ L" &&&8 *8 e  +;ikH; [' ՂHJ e effff` ե Fe jf +;ikK ;['ק)%H"  +kללללש לל!ל .ְ v֍ק). v֍ק)l׀ Lh )@ Y~|֧)-׀,0׀"+ !+!׀ #8``֧)*`)0:)H֭ mc%nOsMbnpcXxo~udifeEgG'\;8 [Kdd)awr O٠ >ِȷ >ـ -wp" n?X:a3^ٍf" \Xзbٍl٭`ٍj" d"~"~  HH"Pȥ ȩ)+bȷ)+arQI ȗ+;ik)+8`b8``;8 [K  HH"HH" ) ) )   H H V   ,  c {i۩۩ۀ  ۠ ۠ ۠ ۠ ۭn ۀK" ?L     ) mۗ mۗ    ۗ ۗ    U i  i )8   :  )    I   )   +;i knӍF܍x". D" "- v &  ۭ  Ȍ "` `V . ;8 [ )   2   7 H"  H"IH H V  )    H H" i ȷ i  8  ȷ :      )  ) H H"  +;i k;8 [KHH"  ) w  HH"~  _ @@ HH"P7 ȥ  ȥȗd+;ik %"4 K߀ לKߜ!ש )שQ)נ*T%׭%ק#ל0RN&n%n$n#jJJJJ 0:i Kߙ)׈& % $ #˭ X Kߍש00 HH ȷ  HH ) א׍#8#׍ #Z)H"z#hih " H"!8  I-!ל׭HH)S '" &"׮z 0/ z׀' )S) S 8׍׭!׭עR ) 8I׭0 !H" H"H"00 H" 0"ȹ)) SZ))H"zȀ HH 'ׇhih `!ש )שQ)נ*T%׭%ק#0R& % $ #!N&n%n$n#jJJJJJ 0)׈R0)0ׂQ`0 "`KHH; [  8+hhzhhZګk; [ +hzzH`;8 [KH H"-H H"d  '    )\ "~i  P"9 " " HH"P! np "  )@ H H"PH H"P ii d  +;i k;8 [KHH"p)d 8䍌䍎 " HH VHH" )d+;ik; [ ȊwHwhȷ+;ik|׀ |ל I-!׭ 8|׀׍~|ץ HH "|) "|0)׽'e)׽)ם*ש0)0 t0)׽)eE)0*) )שP+נ*T~610)ע)0 :))ש.)) 蘼)ם)׀0!׭))8I׭0 !H"00 0")))Z)H"zi }0*.)#) *e)0 8. 0`) *ם))`EE ׭׍~|ץ HH "Iש׭)m:Gא׭E8G為LL; [策v" t+;ikL; [答덳" +;ik; [HH HH"hhN"3"J  <ڥHJ      h +;ik; [8""+hhk "3"JhhkHHH8H; [  " % Q8  0 " " "e i @< " "   "Z ""+;i kHH8H; [-ȷ/ȷ HH"+hhhhk C hhhhkH; ["1ȿ313+hhk ;8[IȅIdFejfFejfFejfFejfFEejfFejfFejfFejf2-I;i+ke &****;i+@k;8  ["s' OJ  e e f f ff`   d Fejf)  @8 +;ikHiH;8  [  " 13O$>"JUWȩȗ na i  U GE31 "F e i  " "8  0 E 13 ") i+;iki!#HH#H!HH#@@H "hh) kHH; [-ȗ/ȗȥȥȩ-/ -/i+zzzzk; [  )8 I"S )L  ! )H"I  ( "I )H"   " +;i kH"Y""rh") HHHHH; ["13  ȷݠ1ȷ3 ȷ+;i k; [ f fdd  !& +hhkd8d d 8kH ;[FeFeFeF/eFeFeFeFe+ke+kHZ""W""."kK덟" 덟" 덟" kK꜌뜎뜐 "뜞뭒"9 !$" " " "k $.CONSOLEK 蜯蜭kHH;H" ;[+hhk">H"kH "hHi "k "kKzhhh Zګk:JJJJk;8  [d "7 HH HHH"0" "zj  " $"8 " HH"  +;i k(K-/&1kH ;[ "I "+hk  mL] <Tfxg|ׁI/A~?w_.BswDtG$[ D|4UNuh$H/E;v#^(kE +5[6p s2weq =  $)CNS37  0?ipygl}q 5Fa{" -LYk}5J|C/W8 Dg1=GRtD\,B``xho+fp  NX\msz%RW^dins  ?\q} !%)m lsw ^k&3^n~ "%147Qc pEHT.EQ,2BL`{ "'9?BXft@j u\y~.1t Q!-04;@OTr) %(+DHOahlr" +26=OW[as|# #+=EIP_hlr% !)6>BJW`dkx! !-59ERZ^jx '8DKO^ksw  !#%')+-2;>AR\_p{!09?QSUWY[]_afpvz '+:JRVenuyv?YAS"/5;AGMSY_ekqw}* %+17=CIOU[agmsy* !'-39?EKQW]ciou{) #)/5;AGMSY_ekqw} IOẃ%܁),os?^b)6:} ilyFTc8CTbq  #?BGLQTW_h#(-27ADVNV\blt|!)8; "%/  #'*-05NTZgnqx{~! #&08FKWy ").1=@JRUXτ]berwz 58;>ADGJMPS -]`cjor|BEKmNx  8 S4 n=  % bHJWsz|𬋜<ė1g7k=pCvI}OU[agmsyĮ̃Ԩܨǘ͘Ә"٘+ߘ6BLTYbl z{|}!~'-39?EKQWɩ]өcݩiou{-:;<=HSÙ^əjϙtՙuۙvw癆확󙤪ªê ĪŪϪ٪#)/5;AGMS$Y3_@eAkBqCwL}U^hpqrs𧚀𭚍𳚚𹚨𿚴Ś˚њךݚ˫ի %2%3+4157>=GCPIZObUc[daegrmsy𑛩𗛲𝛺𣛻𩛼𯛽𵛾𻛿Ǜͬ͛٬ӛٛߛ Lt𢯎q"xٲ  ĹmϤшҴҴhj9l*)")*)/|;K|QW)*+|*{0E picview{"""$";8 [ں.."<h$HH Y"h.8))S ad+;ik;8  [    +;ik;8 [   +;ik;8 [Hh H{i ih ں  H{i H" h +;ik;8( [{iHhiHhh{ii{ii{ii  {ii E{iHhiHhh{ii{ii{iHhiHhh{ii{iiH{iHhiHhhhhں"hHHHH{iH1"ͣhh,HH "ͩHH:"YY"ͥ*,)++;i*kH; [HH"+zkH; [H "+zk;88 [;H H{i H "h  d+;i8k;8 [ H",Hh#h#h)  Hh#h#h)  ں)HH HH"{hں)HH HH"{h  +;ik;8B [d F8F8FpI0ʊFH H{iH "hd{ii  8FpI0ʊF 8 pI0ʊ H8HP H"HH"  hhں "hDHCG+;iFk;8 [ں H"hH hhHH ں"khH@H "ͣ  hh  $HHY"h H Hhhں H H"vhں$""hں"h2HHY"h "ͩ "d$#+;i"k;8 [ "ͦںHHOYY"UhںH"h8pI0ʊC"HHY"hںH"h.ںH"h"ͩHhd+;ikLoading GIF file %s;8> [d!ںDB"mhH  hhںHF"mhHhhںH"Fh 8 pI0ʊ."HHY"hJ hiHhhhhhiHhhhhںYY H"vhںH H"WhںHFYY";h9ں H"hHHY"hR#kں H"[h$HH Y"hBں H"h$HH Y"hں H"-h$HH Y"hvں H"h$HH Y"h.jں H"Ah$HH Y"h"#: H` d < ںHpH"hZZHh%H{i%HhiHhHhhhh"H{i%iih)H{i%iih  )@!8))'ںH\H"h!$ںH[H"h!ZZHh%H{i%HhiHhHhhhh"H{i%iih)H{i%iih  )ںHH"hںH"6hZZHh%H{i%HhiHhHhhhhH{i%iih)H{i%iih  ){i%i)9)ںH`H"hHH Y"hHhhhIHHH"͢"͢"ͩH{i%HhiHhiHHHHHJ"{i7HHHHHJ"ͭ!ʊI8e!"lʊI8e"l11ʊ{i%i!ʊʊ1ں!HH"H"hں{i7H{i%HHH"hں{i%i)i"lHH"hںH`H"hHhhhIHHH"͢"͢"ͥ@H?G+;iFk? *6߁z1uMA{ $N#K{$lD{']iz!*-9KQ[ruy|O+Ak+n&N~ 'Wo/Gwq;{  HLWkoz}DCFR\f -O l0E pictl",""$";8 [ں H"hHh ں H"hHh ںi H"hHh ںi H"hHh ںi H"hHih ں H"hH h ں H"hH  ȣ hhں H H"hH ȣ hhں H H"hH ȣ hhں H"hHh ں H"hHh ں H"hHh ں H"hH h   +;i k;8 [ں H"hHh ں H"hH  hh 8pI0ʊ#ں"H hiHhchchH"hH"H hiHhchchhں"H hiHhchchH"hH"H hiHhchchiHhhں"H hiHhchchH"hH"H hiHhchchiHhhں"H hiHhchchH"hH"H hiHhchchiHhh  +;i k;8 [ 8pI0ʊDںH{i HH"vhں H"h *ںH{i HH"vhں HH"vh hh  "eehh!  h)  )ɀo)I8iںH  h)H"gh"HheHehh~)iںH "h"HheHehh"HheHe  hh+;ik;8, [d''I#HںH420H"WhH"bں{i H0H"vhHʨhhں H"h ں42"h ʊ "38pI0ʊ "3iHhe2He424hhں "1/H H"hں "3H0H"vh )iں"Hhchch)H"h8ں"h)8 H`tBں "1/H H"h )ںH{i H0H"vhں H"h iHhe2He424hh 8 ں H0H"vh_ں.0H"vhںhi.H0H"vhںHںi.H"hHhchc""Hhi.HhiHhchc0H"vhںhi6H0H"vhں"hںhi.H" h)HiH" hhں "hHH ں"khHH "ͣhh "͠HH!hhںiiH"~hH#%hhں6H6HYY"UhںiHi8H"ahii8pI0ʊvں%#)H!0H"hi"HheHe!!hhں"mh^""ͦں%#"Phں"h he2He424hhHhe2He424hh'<q)r)ɀh)Ɂ^)ɂT)ɃJ)Ʉ@)Ʌ6)Ɇ,)ɇ")ɘ)ɚں"hں H"h )xں!"hں0H"vhHhe2He424hh5ں+"h)8  H`aHhe2He424hhiHh6iHh6;Hh6i.iHh6ںH"hH 6ȣ6hh8pI0ʊ"Hhi.HhiHhchch+"Hhi.HhiHhchch))H+"eeh  )"Hhi.HhiHhchch))H+"eeh  )"Hhi.HhiHhchch))H+"eeih  );Hh66ȣ6hh6ȣ6hhd.8-7+;i6k[%08lX] [%04X]: %s %02X [%04X]: %s mapLen: %ld Loading PICT file %s [%04X]: HeaderOp ;8 [ں H"h  +;i km  'Ch2aA7IM_7[~&o!E2IcOdIisKi4u'Pb2PojT,/f+/Ml4 #N] 5/1I]C6P].,&Z2,.FZ3Z+ځI c ( ,Ji!+j0E targaj;8 [hh)) ))JJJJ )) JJJJJ ))JJJJJJ))))) ) ) ) ) )! ))) ))))) )))d+;ik;8: [ں{i)H>H"vh))$ں))H>H"vh:)) :))JJJJ :)) JJJJJ :))JJJJJJ+)5H9)i"lH"!#hh9)'&7H#!"hh''8 H`zzHHں"khHH "ͣhh "͠HHhh hh4#!H78""heHehh%7%ʊvں#!>H"vh &#!"heHehh'#!"8hhhh%x7Hh@5Hh@9)Hh@Hh@ @ȩ@Hh@@ȣ@hh@ȣ@hhd\Q i&`KiK ssv.tmpp^pdos- p^pdos OoOpen...Ww@CloseSsSave Save as...@Revert to savedQqQuit Edit Zz@UndoXxCutCcCopyVvPasteClearApplication Menu Bar "@??@ File NnNew54~Error opening image file.~^#052~Not enough memory to view this picture.~#052~This file is not a GIF image.~^#0PV~52~Some fatal error occurred trying to load the GIF file.~On no!52~Not a proper TIFF file.~^#052~SecondView does not support 24-bit TIFF files yet.~^#052~Unknown file type - not a TIFF or GIF.~^#052~Unknown error loading picture. ~#073~Your Second Sight is only an 8-bit model, and you need 24-bit capability to view this picture. ~^#0#2#2~^Cool!Cool!52~No Second Sight video adaptor detected in your system.~I'd Better Buy One!43~Second View v1.0a6 Second Sight Image Viewer By Tim Meekins and Jawaid Bazyar Copyright 1995, Sequential Systems~^Cool!73~Your Second Sight is only an 8-bit model, and you need 24-bit capability to view this picture. Call Sequential at 800-759-4549 to inquire about the 24-bit Upgrade. ~^#0s W Apple Menu File Menu Edit Menu About pString Apple pString Clear pString Close pString Copy pString Cut pString Edit pString File pString New pString Open pStringRevert pString Paste pString Quit pString Save pStringSaveAs pString Undo pStringAbout SecondView "Picture Name" e.~#1~#3~^#2tring namesTool Startup TableMenu Bar names  Menu Names Menu Item namesTool Table names pString names rName names About Menu ItemClear Menu ItemClose Menu ItemCopy Menu Item Cut Menu ItemRevert Menu Item New Menu ItemOpen Menu ItemPaste Menu ItemQuit Menu ItemSave Menu ItemSaveAs Menu ItemUndo Menu Item63~Second GIF Second Sight GIF Image Viewer Copyright 1995, Sequential Systems~^Cool!P,6 73~Second View Second Sight 8-bit Image Viewer Copyright 1995, Sequential Systems~^Cool!P  F8U{Gr W ZSD 5 L_qN _ 2 T" " > Q c v   F      Pt P v T1 1  s| !.%fA;. /& O +,-./01/* * targa.c */ #include #include #include #include #include #include #include "pic.h" #pragma noroot segment "targa"; typedef struct tga_header { byte IDLength; byte CoMapType; /* Color Map Type */ byte ImgType; word Index; /* index of first colormap entry */ word Length; /* number of entries in color map */ byte CoSize; /* size of colormap entry 15, 16, 24, 32 */ word X_Origin; /* X origin of image */ word Y_Origin; /* Y origin of image */ word Width; word Height; byte PixelSize; byte flags; } tga_header; /* Definitions for image types */ #define TGA_NULL 0 #define TGA_Map 1 #define TGA_RGB 2 #define TGA_Mono 3 #define TGA_RLEMap 9 #define TGA_RLERGB 10 #define TGA_RLEMono 11 #define TGA_CompMap 32 #define TGA_CompMap4 33 /* Definitions for Interleave flag */ #define TGA_IL_None 0 #define TGA_IL_Two 1 #define TGA_IL_Four 2 int identify_targa(char *buf) { int AttBits,Reserved,OriginBit,Interleave; tga_header *th; th = (tga_header *) buf; AttBits = th->flags & 0xF; Reserved = (th->flags & 0x10) >> 4; OriginBit = (th->flags & 0x20) >> 5; Interleave = (th->flags & 0xC0) >> 6; /* Determine if we're a TARGA file by validating a number of fields in the supposed TARGA header */ if ((th->ImgType == 0) || (th->ImgType == 1) || (th->ImgType == 2) || (th->ImgType == 3) || (th->ImgType == 9) || (th->ImgType == 10) || (th->ImgType == 10) || (th->ImgType == 11) || (th->ImgType == 32) || (th->ImgType == 33)) ; else return -1; if (Interleave == 3) return -1; if (Reserved) return -1; if ((th->PixelSize == 8) || (th->PixelSize == 24) || (th->PixelSize == 32) || (th->PixelSize == 15) || (th->PixelSize == 16)) ; else return -1; if ((th->CoSize == 8) || (th->CoSize == 24) || (th->CoSize == 32) || (th->CoSize == 15) || (th->CoSize == 16) || (th->CoSize == 0)) ; else return -1; return 0; } char dummybuf[512]; int load_targa(int fd, image *rec) { tga_header th; int AttBits,Reserved,OriginBit,Interleave; handle xhndl; byte *xptr,*scanPtr; unsigned long mapLen; unsigned long scanLen; int i; read(fd,&th,sizeof(th)); if (th.IDLength) read(fd,dummybuf,th.IDLength); AttBits = th.flags & 0xF; Reserved = (th.flags & 0x10) >> 4; OriginBit = (th.flags & 0x20) >> 5; Interleave = (th.flags & 0xC0) >> 6; if (th.ImgType != TGA_RGB) return -1; scanLen = (long)th.Width * ((th.PixelSize + 7) / 8); switch (th.PixelSize) { case 15: case 16: /* # of bytes per pixel, rounded up to nearest byte */ mapLen = th.Height * scanLen; break; default: return -1; } xhndl = (handle)NewHandle(mapLen,userid(),0,0l); HLock(xhndl); xptr = (byte *) *xhndl; if (OriginBit) { scanPtr = xptr; } else { scanPtr = xptr + scanLen * (th.Height-1); } for (i = 0; i < th.Height; i++) { read(fd,scanPtr,scanLen); if (OriginBit) scanPtr += scanLen; else scanPtr -= scanLen; } rec->height = th.Height; rec->width = th.Width; rec->depth = th.PixelSize; rec->palette_size = 0; rec->palette = NULL; rec->type = IMAGE_TARGA; rec->mapHandle = xhndl; rec->map = xptr; return 0; } 3456789:;<#include #include #include #include #include #include #include #include #include #include #include #include "ssv.h" #include "pic.h" #pragma noroot #pragma lint -1 #define T_BYTE 1 #define T_ASCII 2 #define T_SHORT 3 #define T_LONG 4 #define T_RATIONAL 5 typedef struct tiff_header { char byte_order[2]; unsigned tiff_ident; unsigned long ifd_offset; } tiff_header; typedef struct dir_entry { unsigned tag; unsigned type; unsigned long count; unsigned long value; } dir_entry; extern char *pictitle; extern word ImageH; extern word ImageV; int load_tiff(int fd_img, image *rec) { int fd; tiff_header th; unsigned long ifd; unsigned dir_num_ent; dir_entry *directory; unsigned i,numpal; word *r_pal,*g_pal,*b_pal; size_t imgoff; unsigned order; unsigned long j; unsigned long tmp; unsigned StripOffsets,PhotoInterp; unsigned ImageLength,ImageWidth; unsigned ColorMap; struct rgb_24 *palette; char *buf_ptr; handle bufhndl; read(fd_img,&th,sizeof(th)); ifd = th.ifd_offset; if (th.byte_order[0] == 'M') order = 1; else order = 0; if ((th.tiff_ident != 0x2A) && (th.tiff_ident != 0x2A00)) { DoSimpleAlert(6l); return -1; } if (order) ifd = swap_orderl(ifd); printf("Byte ordering: %s\n",(th.byte_order[0] == 'I') ? "Intel" : "Motorola"); WriteChar(10); printf("IFD offset: %06lX\n",ifd); WriteChar(10); lseek(fd_img,ifd,0); read(fd_img,&dir_num_ent,2); if (order) dir_num_ent = swap_orders(dir_num_ent); printf("# dir entries: %04X\n",dir_num_ent); WriteChar(10); directory = malloc(dir_num_ent * 12l); read(fd_img,directory,dir_num_ent * 12l); ColorMap = 0xFFFF; for (i = 0; i < dir_num_ent; i++) { /*printField(directory+i);*/ if (order) { directory[i].tag = swap_orders(directory[i].tag); directory[i].type = swap_orders(directory[i].type); directory[i].count = swap_orderl(directory[i].count); if ((directory[i].type == T_SHORT) && (directory[i].count < 3)) directory[i].value = swap_orders(directory[i].value); else directory[i].value = swap_orderl(directory[i].value); } switch (directory[i].tag) { case 0x0106: PhotoInterp = directory[i].value; break; case 0x0111: StripOffsets = i; break; case 0x0100: ImageWidth = directory[i].value; break; case 0x0101: ImageLength = directory[i].value; init_thermo(1); /* used to be ImageLength */ break; case 0x0140: ColorMap = i; break; } } /* Read in the color map */ if (ColorMap == 0xFFFF) { printf ("No color map to read!!!, we will probably have to build one\n"); } numpal = directory[ColorMap].count; r_pal = malloc(512l); g_pal = malloc(512l); b_pal = malloc(512l); if (PhotoInterp == 3) { lseek(fd_img,directory[ColorMap].value,0); read(fd_img,b_pal,512l); read(fd_img,g_pal,512l); read(fd_img,r_pal,512l); } else if (PhotoInterp < 2) { /* assume it's greyscale, and create a greyscale palette */ DoSimpleAlert(10l); if (PhotoInterp == 1) { for (i = 0; i < 256; i++) { r_pal[i] = g_pal[i] = b_pal[i] = (i << 8); } } else { for (i = 0; i < 256; i++) { r_pal[i] = g_pal[i] = b_pal[i] = ((256-i) << 8); } } } else { /* only one option left - #2- RGB */ DoSimpleAlert(7l); free(r_pal); free(g_pal); free(b_pal); return -1; } palette = calloc(sizeof(struct rgb_24),256); rec->palette_size = 256; rec->palette = palette; for (i = 0; i < 256; i++) { palette[i].r_val = r_pal[i] >> 8; palette[i].g_val = g_pal[i] >> 8; palette[i].b_val = b_pal[i] >> 8; } j = 0; lseek(fd_img,directory[StripOffsets].value,0); rec->width = ImageWidth; rec->height = ImageLength; rec->type = IMAGE_TIFF; printf("Image Offset: %06lX\n",directory[StripOffsets].value); WriteChar(10); /* lseek(fd_img,imgoff,0); */ sprintf(pictitle,"Loading TIFF file %s",rec->fname); bufhndl = NewHandle(ImageWidth * (long) ImageLength); if (bufhndl == 0l) return -1; buf_ptr = (byte *) *bufhndl; rec->map = buf_ptr; rec->mapHandle = bufhndl; read(fd_img,buf_ptr,ImageWidth*(long)ImageLength); advance_thermo(); free(r_pal); free(g_pal); free(b_pal); free(directory); kill_thermo(); return 0; } >?@* Whatever 'size' is, it should be a multiple of 3, or the output * buffer may be overrun true2high START numbytes equ 1 sub (4:inptr,4:size,4:outptr),space ldy #0 bankloop anop ldy #65535 lda size+2 bne *+5 ldy size sta numbytes loop anop lda [inptr],y and #$FF asl a tax lda |r_table,x sta tmp0 iny lda [inptr],y and #$FF asl a tax lda |g_table,x ora tmp0 sta tmp0 iny lda [inptr],y and #$FF asl a tax lda |b_table,x ora tmp0 iny sta [outptr],y lda outptr clc adc #2 sta outptr bcc *+4 inc outptr+2 cpy output.hex ;8  [d ں"hں"!h  "qI"ں "Hi"0hں Hs"0h "qں )H"qh S +;ik:1%04X000%02X 9LKzhhZګHH" V;iH"8hihz;oZګkKhzHګHHZ" k;8 [ )   2   7 H"q  H"ZH H   )    H H"  i ȷ i  8  ȷ :      )  ) H H"  +;i kHH" kq;ioH"8hoiohz;moZګkHHH" zhZګkH 9h\KzZڭ/H-H; ["]i # " Ȁ " Ȁ  7Z8czHHHH "* Out of memory6"\h h  35m7  Ȁ  5 3 )s  "   i  ")0"!)    5 3 +hhkKHH ;[$bhHHhk֯ "+hh` H")  H") HH" H") H" 7kraa3"7 15`p"9 n!zٌ" `x .CONSOLEKHH; [  8+hhzhhZګk; [ +hzzH`K ;[)%H"  +k   ). )l Lh )@L Y|L)-,0"+ + #8``J)*JJ`)0:)HJJ mJcJ%nrspbpcXxou3difeEgG\;8 [Kdd)awr O  ȷ -w " ?X:a3 " Xз " ""  HH"ȥ ȩ)+bȷ)+arQI  ȗ+;ik)+8`b 8``;8 [KHH"p)d   8  " HH HH" )d+;ik;8 [K ͎ ͐HH" HH"  ) ) )   H H    ,  c {i       K" ?L      ) m m          U i  i )8   :  )    I   )   +;i k". ~" "-  &    Ȍ "` ` . ;8 [KHH"  ) w  HH"  _ @@ HH"7 ȥ  ȥȗd+;ikΙ p%" n n QT0RNnnnjJJJJ 0:i n   ˭ X n00 HH ȷ  HH ) ͣ8 pZ)H"zΫhih xΙ pH"d!8  I-HHS '" &"᭥ 0/  ' ٱSٱ S 8ΙΙΙR ٱ 8I0 pH" H"H"00 H"Ι 0"Σȹ) SZ)H"zȀ뭝 HH hih ` QT0R   !NnnnjJJJJJ 0R00Q; [ ȊwHwhȷ+;ik`0 "Ι`;8 [KH H"-H H" d   '    )\ "i  P"9 " " HH"!  "  )@ H H"H H" ii d  +;i k    I- 8   HH "   " 0e00 0eE0) αPT 6100 :Q. 蘼0Ι)8I0 pH"00 0"Ι)Z)H"zi 0.# e0 8. 0` α`VV   HH "᭗I )m :XͣΣV8XL]; [<" +;ikL; [:" +;ik; [8"r"+hhk ""hhk9?GHHH8H; [  "F % Q8  0 "2 "2 "Fe i @< "2 "2   "FZ "2"r+;i kHH8H; [ȷȷ HH"+hhhhkIH7IHZ; [*8e쪥I+zzzkh@kH; ["f ȿ+hhkK"p 8Ik@kHiH;8  [  "f O$>"ȩȗ na i  U GE "2F e i  "F "F8  0 E  "2) i+;iki菎HHHHH@@H "hh) kHH; [ȗȗȥȥȩ i+zzzzk; [  )8 I"! )L  ! )H"Z  ( "Z )H"   " +;i kH""8 "h") *HHHHH; ["f   ȷݠȷ ȷ+;i kHZ"M "" "")kK>8'" %@:'" %B<'" %kK2246 "w 8D8"9 !٬" D "w : "w <k .CONSOLEK ?31ce_aY[UWkHH;H" ;[+Ahhk"!H"kSH "hAHiA "SkS "SkKzh-h/h Zګk:JJJJk;8  [d *`!"7 ^! b!HH HHHw "0" "zj \!h!r!Z!f!p! X!" V!$"8 d!j!" l!n!HH"  +;i k(K&kH ;[ "Z "+hk  .D&FH_ "',4;DLRZkrwU\rx )Fat[} $*/x؁-7AoRz%6[JV`k=Sqq5;C5?R_g MT\dj&,6]g 2:U[rx&@DJ~ PShk258;>DGJMPUXknq~25:@NRVZ^bfjnrvz~ emuDLT]`hkn 7/2:=[cru"%F\_i '*-0CFJMPSX_bg147HQfnqv !).:CTc kqv#&03Bv{& ),5:=CO_ekx" "),47AIW\h%)3:?BNQ[cfiz}-036@CFI[^sv '2is8qF6NbQbE@ L \ b h   w XY/* * bin2hex.c * * To use the disassembler, you must feed it an Intel Hex-format * file. This will convert any file to Intel hex format. */ #include #include #include void usage(void) { fprintf(stderr, "usage: bin2hex < binaryfile > output.hex\n"); exit(1); } int main(int argc, char *argv[]) { int off = 0; int c; if (argc != 1) usage(); while ((c = getchar()) != EOF) { if (!(off % 16)) { printf(":1%04X000",off/16); } printf("%02X",c); if ((off % 16) == 15) putchar('\n'); off++; } } [\]^_`ab ZMac Command Line Options -b No binary -d Debug (only if #DEBUG defined at compile time) -e Error list only -f Print if skipped lines -g Do not list extra code -i Do not list include files -l No listing -L Force listing of everything -m Print macro expansions -n Put line numbers off -o List to standard output -p Four linefeeds for eject -s Don't produce a symbol list -t Don't print errors ZMac Syntax: Labels A non-'EQU' label is a sequence of alphanumeric characters followed by a colon (:). Example: RAM_START: Comments Anything on a line after a semicolon (;) is considered a comment. Constants Character constants are denoted with the use of single-quote marks. (e.g., 'c' 'r' '1') (hi bit off) Hexadecimal constants are suffixed by the letter 'h', and if the first digit is A through F, must be prefixed with a '0'. (e.g., 50h, 0C0h, 008H) ZMac Pseudo-Ops --------------------------------------------------------------------- EJECT Syntax: eject X Eject X number of pages. Example: eject 1 --------------------------------------------------------------------- END Syntax: END All Z180 assembly language source files must be terminated with an END directive. This should be the last directive in the file; further directives or opcodes will either be ignored or generate errors. --------------------------------------------------------------------- EQU Syntax: label equ value Equates the label with the specified value. Example: ; Serial port equates. Serial equ 00H ; base address of 8250 controller. Ier equ 01H ; Interrupt Enable Reg Iir equ 02H ; Interrupt Ident Reg Lcr equ 03H ; Line Control Reg --------------------------------------------------------------------- ORG Syntax: ORG address Set the current program counter to "address". This allows you to specify the exact location at which code will be assembled to run. Example: ORG 0FC00H --------------------------------------------------------------------- DEFS (BLOCK) Syntax: DEFS size BLOCK size Reserve a block of contiguous space of 'size' bytes. Example: OUTBUF: defs 16 ; input buffer, using regular name INBUF: block 256 ; output buffer (alternate name) (See 'Labels' above) --------------------------------------------------------------------- ASCII Syntax: ascii 'text or ascii data to assemble' Assembles the text between single quote marks and inserts in the executable as high-bit-off ASCII data. Example: ascii 'serial.z 1.8' ; this module name and version number --------------------------------------------------------------------- DEFB (BYTE) Define bytes DEFW (WORD) Define words (2 bytes) DEFL Define longs (4 bytes) Syntax: byte const [,const]... Assembles the constant(s) as single bytes. Example: byte 02H,04H,06H,08H,10H,12H,14H ; hexadecimal defb 10,20,30,40,50 ; decimal byte 'a','z','A','Z' ; ascii defb 'This is a test' ; (same as ASCII pseudo-op) --------------------------------------------------------------------- "include", 3, ARGPSEUDO, 0, "list", 0, LIST, 0, "mlist",6, LIST, 0, "elist",3, LIST, 0, "flist",4, LIST, 0, "glist",5, LIST, 0, "space",2, LIST, 0, "macro",0, MACRO, 0, "endm", 0, ENDM, 0, "if", 0, IF, 0, "endif",0, ENDIF, 0, "phase", 0, PHASE, 0, "dephase", 0, DEPHASE, 0, "rsym", 1, ARGPSEUDO, 0, "title",0, ARGPSEUDO, 0, "wsym", 2, ARGPSEUDO, 0, Numerical Operators "max", 1, MINMAX, 0, "min", 0, MINMAX, 0, "mod", 0, MOD, 0, "not", 0, NOT, 0, "nolist",-1, LIST, 0, defghijklmnopqrstuvwxyzU,C ~ExpressLoadU 334,E S6330E 33"/"%"";8 [ں"*eeHH"ghں!"*eeHH"ghں"$h #ںH )H"hںH"h+;ikrwb;8 [ںHH"hHhhh)HHں"hH8hh"nhchchh  )ں"hH ʨhhں"*Hhchc"uhʎں"*Hhchc"uh)Hں"*Hhchc"uh8ʎHH"c)ںHH"+"+ "*Hhchchchc"uhHH"+ hchchhLʎ$;;H"+ hchch+;ik;8 ["*e e)09"*e e)9ʊd"*e e)a9"*e e)fʊ"*e e)A9"*e e)Fʊ/AH"*e e)8i /aH"*e e)8i +0H"*e e)8"j/H"*e e)09"*e e)9ʊd"*e e)a9"*e e)fʊ"*e e)A9"*e e)Fʊ/AH"*e e)8i /aH"*e e)8i +0H"*e e)8c  +;i k;8 [KH H"-H H"Bd   '    )\ "'8:i>@  P4"9 2" ." <HH"Q'!  0" . )@ H H"Q'H H"Q' ii d  +;i k;8 [KHH"p)d 8 "  HH +HH" )d+;ik;8 [H H" H H"!dd7d 0 H H"!dd    ֦ +;i k;8 [Kdd)awr HH"E   rȷ r  " =r ^  "  "  2w" BX=a6" Xе" "'"'  HH"Q'ȥ ȩ)+bȷ)+arQI ȗ H H"Q'+;ik)+8`b8``;8 [ )   2   7 H"  H"&H H +  )    H H"B i ȷ i  8  ȷ :      )  ) H H"B  +;i k; [  +hhkH h\.KzZڭ'H'H; ["l]i # " Ȁ " Ȁ  Z8czHHHH "* Out of memory"&.\.h h  m  Ȁ    )s  "   i  ")0"!)      +hhkKHH ;[$hHHhk֯ "+hh`; [ ȊwHwhȷ+;ik H" H"HH"S% H"H"S% kraa "7  `H"9 F!Rd" \b`P d.CONSOLEH; [' HJ e effff`  Fe jf +;ikKHH; [  8+hhzhhZګk; [ +hzzH`;8 [ H H"H"' H H HiH"$  +;i kHHH"zhZګk;8 [Kdd)awr O! _!ȷ _! -w!" !?X:a3!!" }!Xз!!!!" !"'"'  HH"Q'ȥ ȩ)+bȷ)+arQI! ȗ+;ik)+8`b!8``; [HH" )+hhk;8 [K  HH"BHH"B ) ) )   H H +   ,  c ${i$$!$  $ $ $ !$ $ +$K" $?L #$ %$    ) $m#$ $m%$    #$ %$   #$ %$ U i  i )8   :  )    I   )   +;i k$$". $" $"- $$ &  #$$  Ȍ#$ "'` `$ . $$; [HH J     z +;i k;8 [KHH"  ) w  HH"'  _ @@ HH"Q'7 ȥ  ȥȗd+;ik]&\L&; ['*'" '+;ik'L'; [O'*A'" ?'+;ikO'; [8"("(+hhk "4,"K-hhk'''HHH8H; [  "* % Q8  0 ". ". "*e i @< ". ".   "*Z "."(+;i kHH8H; [/ȷ/ȷ HH"+hhhhk C hhhhkH; ["1/ȿ///+hhk ;8[IȅIdFejfFejfFejfFejfFEejfFejfFejfFejf2-I;i+ke &****;i+@k;8  ["1/' +OJ  e e f f ff` +  d Fejf)  @8 +;ikHiH;8  [  "1 //O$>"K-00ȩȗ na i  U GE// ".F e i  "* "*8  0 E // ".) i+;iki".$. .HH$.H".HH$.@@ .H "hh .) .kHH; [/ȗ/ȗȥȥȩ// //i+zzzzk; [  )8 I"3 )L  ! )H"&  ( "& )H"'   "' +;i kH"0"n1"01h") .HHHHH; ["1//  ȷݠ/ȷ/ ȷ+;i kd8d d 8kH ;[FeFeFeF/eFeFeFeFe+ke+kHZ"1"1"A1"0"_0kK**]0" [0**]0" [0**]0" [0kK)*** "1***0"9 0!00" 00* "1* "1*k0 0.CONSOLEK '''''''''''kHH;H" ;[+'hhk"2H"k'H "h'Hi' "'k' "'kKzh'h'h Zګk:JJJJk;8  [d *2"7 2 2HH HHH1"0" "zj 222222 2" 2$"8 22" 22HH"  +;i k(K//&/kH ;[ "& "'+hk%  0QubGe&IS]I6~7iJK} #`Y/ 3TuY&i"G9L^  #include #include #include #include int curaddr = 0; long int inline1; long int index1; int xind; char linebuf[1024]; FILE *filein,*fileout; int hexbuf[1024]; int main (int argc, char *argv[]) { int i, j, arg1, arg2; struct opcode *code; int addr; filein = fopen(argv[1],"r"); fileout = fopen(argv[2],"wb"); for (;;) { i = gethex(); if (i == EOF) break; fputc(i,fileout); } fclose(filein); } int gethex (void) { if (index1 == inline1) { again: ; if (fgets(linebuf,1024,filein) == NULL) return -1; linebuf[strlen(linebuf)-1] = 0; if (strlen (linebuf) < 9) goto again; inline1 = fromhex (linebuf+1); xind = fromhex(linebuf+3); xind = (xind << 8) | fromhex(linebuf+5); curaddr = xind-1; for (index1 = 0; index1 < inline1; index1++) hexbuf[index1] = fromhex (linebuf+9 + 2 * index1); index1 = 0; if ((index1 == 0) && (inline1 == 0)) return -1; } ++curaddr; return hexbuf[index1++]; } #define hexval(c) (('0' <= (c) && (c) <= '9') ? (c) - '0' :\ (('a' <= (c) && (c) <= 'f') ? (c) - 'a' + 10 :\ (('A' <= (c) && (c) <= 'F') ? (c) - 'A' + 10 :\ -1 ))) int fromhex (char *c) { return hexval(c[0]) * 16 + hexval(c[1]); } :100000003A0420C900# Makefile to make z80 macro assembler. CFLAGS = all: zmac zdis zmac: y.tab.o mio.o cc $(CFLAGS) -o zmac y.tab.o mio.o #-lsx y.tab.c: zmac.y yacc zmac.y zdis: zdis.o cc $(CFLAGS) -o zdis zdis.o install: install -s zmac /usr/local/bin install -s zdis /usr/local/bin install_man: cp zmac.1 /usr/man/manl/zmac.l cp zdis.1 /usr/man/manl/zdis.l clean: rm -f zdis.o zmac.o mio.o y.tab.c y.tab.o a.out core shar: zmac.shar.1 zmac.shar.2 zmac.shar.1: Makefile zmac.y mio.c zmac.1 zdis.1 shar -vc Makefile zmac.y mio.c zmac.1 zdis.1 > zmac.shar.1 zmac.shar.2: zdis.c serial.z serial.hex shar -vc zdis.c serial.z serial.hex > zmac.shar.2 /* * memcpy - copy bytes */ int * memcpy(dst, src, size) int * dst; int * src; int size; { register char *d; register char *s; register int n; if (size <= 0) return(dst); s = src; d = dst; if (s <= d && s + (size-1) >= d) { /* Overlap, must copy right-to-left. */ s += size-1; d += size-1; for (n = size; n > 0; n--) *d-- = *s--; } else for (n = size; n > 0; n--) *d++ = *s++; return(dst); } /* * mio.c - Colin Kelley 1-18-87 * routines to emulate temporary file handling with memory instead * */ #include #include #include #pragma lint -1 #define MALLOC_SIZE 10000 static unsigned char *mhead; /* pointer to start of malloc()d area */ static unsigned char *mend; /* pointer to current (just beyond) EOF*/ static unsigned char *mptr; /* pointer to current position */ static unsigned int msize; /* size of chunk mhead points to */ FILE *mfopen(char *filename,char *mode) { if ((mhead = malloc(MALLOC_SIZE)) == 0) { msize = 0; return (0); } msize = MALLOC_SIZE; mend = mptr = mhead; return ((FILE *)1); /* not used */ } int mfclose(FILE *f) { if (mhead) { free(mhead); return (0); } else return (-1); } unsigned int mfputc(int c,FILE *f) { register unsigned char *p; while (mptr >= mhead + msize) { if ((p = realloc(mhead,msize+MALLOC_SIZE)) == (unsigned char *)-1) { fputs("mio: out of memory\n",stderr); return (-1); } else { msize += MALLOC_SIZE; mptr = (unsigned char *) (p + (unsigned int)(mptr - mhead)); mhead = p; } } *mptr = c & 255; mend = ++mptr; return c; } unsigned int mfgetc(FILE *f) { if (mptr >= mend) /* no characters left */ return (-1); else return (*mptr++); } int mfseek(FILE *f, long loc,int origin) { if (origin != 0) { fputs("mseek() only implemented with 0 origin",stderr); return (-1); } mptr = mhead + loc; return (0); } int mfread(char *ptr, unsigned int size, unsigned int nitems, FILE *f) { register unsigned int i = 0; while (i < nitems) { if ((mptr + size) > mend) break; bcopy(mptr,ptr,size); ptr += size; mptr += size; i++; } return (i); } int mfwrite(char *ptr, int size, int nitems, FILE *f) { register unsigned int i = 0; register unsigned char *p; while (i < nitems) { while (mptr + size >= mhead + msize) { if ((p = realloc(mhead,msize+MALLOC_SIZE)) == (unsigned char *)-1){ fputs("mio: out of memory\n",stderr); return (-1); } else { msize += MALLOC_SIZE; mptr = (unsigned char *) (p + (unsigned int)(mptr - mhead)); mhead = p; } } if ((mptr + size) > mhead + msize) break; bcopy(ptr,mend,size); ptr += size; mend += size; mptr = mend; } return (i); } void copyname(char *, char *); FILE *mfopen(char *filename, char *mode); int mfclose(FILE *f); unsigned int mfputc(int c,FILE *f); unsigned int mfgetc(FILE *f); int mfseek(FILE *f,long loc,int origin); int mfread(char *ptr, unsigned int size, unsigned int nitems, FILE *f); int mfwrite(char *ptr, int size, int nitems, FILE *f); int iflist(void); int list1(void); int errorprt(int errnum); int lsterr2(int lst); int lsterr1(void); int space(int n); int eject(void); int lineout(void); int flushbin(void); int putbin(int v); int emit1(int opcode,int regvalh,int data16,int type); int addtoline(int ac); int emit(int bytes, ...); int emitdad(int rp1,int rp2); int emitjr(int opcode,int expr); int putbin(int v); int puthex(char byte, FILE *buf); int list(int optarg); int mlex(void); int outsymtab(char *name); void popsi(void); int putm(char c); int putsymtab(void); int error(char *as); int getarg(void); int nextchar(void); int tokenofitem(int deftoken); int skipline(int ac); char *getlocal(int c, int n); int getm(void); int suffix(char *str,char *suff); int setvars(void); int yyparse(void); int erreport(void); : :052000003A0420C900B4 :0000000000 ASAMPLE1.LST5 ASAMPLE1.ZQ5 A*SERIAL.HEXx55A(SERIAL.Z'qK5C*A'Y.TAB.CZ5EA$ZDISoE53A&ZDIS.15C*A&ZDIS.CLv52A$ZMACpC)5EA&ZMAC.1s15C*A&ZMAC.Ywd5EA Jul 30 04:12 1995 sample1.z Page 1 1: ;** 2: 3: 2000 org 2000h 4: 5: 2000 mytestcode: 6: 2000 3A0420 ld a,(a_label) 7: 2003 C9 ret 8: 9: 2004 a_label: 10: 2004 00 byte 0 11: 12: 2005 END Statistics: 2 symbols 5 bytes Symbol Table: a_label 2004 mytestcode 2000+ ;** org 2000h mytestcode: ld a,(a_label) ret a_label: byte 0 END :10000000C30F0073657269616C2E7A20312E38310E :10001000FFFFCD1001CD7F01CD9801DD210BFF3A0F :1000200000FFE6803E11C4F901DB054FDB0647CB3C :10003000612808CD7102CD980118EECD4900CDB0F0 :1000400000CDDB00CDEB0018E0CB41C8DD2105FF82 :100050003A00FF67E640DB002806CDF901C3E20263 :10006000E67FFE20301DFE0D20063E013201FFC955 :10007000CB7CC8210FFFFE132003CBC6C9FE11C0E5 :10008000CB86C9CBEFFE6C200ACD40023202FF3294 :1000900003FFC9FE6D2007CD40023204FFC9FE7385 :1000A0002008CD40022F3200FFC9CD0A02C3E20270 :1000B000CB70C0DD210BFFDD7E02C603D83A00FF06 :1000C000E620DB80C2F901CD20023A02FFA7C82159 :1000D00003FF35C0773A04FFC3F901CB78C8DD21AF :1000E00005FFCDDD01D8D380C3B402CB69C8DD21C3 :1000F0000BFF3A00FFE6802005CB60C8180B3A10D2 :10010000FFA72005DDCB0446C0CDDD01D8D300C953 :10011000DB4047DB40B820FED12100FC06FF4870E1 :1001200005237CB520F92100FC7EA9280C47E60FA9 :1001300028FE78E6F028FE18FE0D237CB520EAD5CF :10014000DB03A720FE3E80D303DB03FE8020FE3EC0 :1001500003D300DB00D60320FED301DB01A720FE82 :10016000DB03D68020FED303DB03A720FE3E07D3AC :1001700003DB03D60720FED301DB01A720FEC9CD98 :1001800071023E07D303AFD3013E03D304DB06CB9A :100190007720FADB80D380C9AFDD2105FFDD770052 :1001A000DD7701DD77022100FCDD7403DD7704DDFE :1001B0007705DD210BFFDD7700DD7701DD7702219B :1001C00000FDDD7403DD7704DD77053E013201FFBC :1001D0003E0D3204FFAF3202FF3203FFC9DD7E0560 :1001E000DD360500A7C0DDBE0237C8DD3502DD6E95 :1001F00001DD6603DD3401B6C9DD340228FEDD66AB :1002000003DD6E0077DD3400A7C9CD5D022101FF5B :10021000CB4628068787878777C9B63601C3F90199 :100220005F1F1F1F1FE60FFE0A3802C607C630CD2C :10023000F9017BE60FFE0A3802C607C630C3F90192 :10024000DB05CB4728FADB00CD5D02878787876710 :10025000DB05CB4728FADB00CD5D02B4C9CBEFD676 :1002600030380CFE0AD8D627FE0A3803FE10D8AF65 :10027000C9DB03F680D303DB403200FFE60F8721A2 :1002800094025F1600197ED300237ED301DB03E6C0 :100290007FD303C905000A0014001B0028003500A5 :1002A00050006B00A0004001800200059405D106BB :1002B000000A000FDD2105FFDDCB0446C83E28DD26 :1002C000BE02D83A00FFCB7F280DCB6FC02110FFB4 :1002D0007EA7C036111806DB04CBC7D304DDCB04E0 :1002E00086C9DD2105FFDDCB0446C03ED8DDBE0258 :1002F000D03A00FFCB7F280DCB6FC02110FF7EA727 :10030000C036131806DB04CB87D304DDCB04C6C983 :0000000000  ; SCCS flags: serial.z 1.8 9/21/82 ; ; This program is a quick and dirty controller program ; for the simple Z80 serial interface card for the Red ; display controller. ; ; It uses two 256 byte buffers to buffer data to and from the ; host. This helps make up for the obnoxiously slow rs232. ; ; History: ; jrp 3-18-82 v1.0 Initial version by John Providenza. ; ; jrp 3-22-82 v1.1 Added code to send a Xon (Cntrlq) at reset ; if the dip switch is set to Xon/Xoff mode. ; ; jrp 4-20-82 v1.2 Added SCCS flags as comment in header and ; as a "ascii" block after a reset jmp. ; ; jrp 4-20-82 v1.3 Changed crt modem flags to RLSD = Out Buf Full, ; RI = In Buf Full. ; ; jrp 4-21-82 v1.4 Added diagnostic code to test ram, switches, and ; uart. ; ; jrp 4-30-82 v1.5 Cleaned up some code, added some more comments. ; ; jrp 5-27-82 v1.6 Fixed bug that caused output buffer to overflow ; in Hex mode. ; ; jrp 6-22-82 v1.7 Added 'end of message' command in hex mode. ; This is active only in hex mode and only if a ; non 0 byte count is specified (0 is default) ; 'l' is used to specify byte count, 'm' specifies ; the eom char. Both expect 2 hex digits following ; to specify the apropriate parameter. ; ; jrp 8-23-82 v1.8 Added code to allow send/recv in different modes. ; Thus the host can send in raw mode and receive in hex ; mode, allowing CntrlS/Q flow control. ; Also added 's' command in 'hex' mode to reset the SWTCH ; settings. ; Also added break detect to reset the mode/baud to the ; switch settings. ; switch dIN dOUT Flow Control. ; 7 6 5 ; 0 0 0 raw raw No flow control. ; 0 0 1 raw hex Xon/Xoff sent to host. ; 0 1 0 hex raw Xon/Xoff received from host. ; 0 1 1 hex hex Full Xon/Xoff. ; 1 0 0 raw raw Full modem flow control. ; 1 0 1 raw hex Full modem flow control. ; 1 1 0 hex raw Full modem flow control. ; 1 1 1 hex hex Full modem flow control. ; ; SCCS flags: serial.z 1.8 9/21/82 eject 1 ; Serial port equates. Serial equ 00H ; base address of 8250 controller. Ier equ 01H ; Interrupt Enable Reg Iir equ 02H ; Interrupt Ident Reg Lcr equ 03H ; Line Control Reg Mcr equ 04H ; Modem Control Reg Lsr equ 05H ; Line Status Reg Msr equ 06H ; Modem Status Reg ; These equates define bits in the Msr. DsrIn equ 05 ; Data Set Ready input CtsIn equ 04 ; Clear to Send input InMt equ 06 ; No data from display controller = 1 (Ring In) OutMt equ 07 ; Crt ready for next byte = 1 (Rcvd Line Signal Detct) ; These equates define bits in the Lsr DataRdy equ 00 ; Input data ready. Break equ 04 ; Break condition. XmitMt equ 05 ; Xmitter buffer empty. ; These equates define bits in the Mcr DtrOut equ 00 ; Data terminal ready output. RtsOut equ 01 ; Request to send output. ; Misc definitions. Crt equ 80H ; Parallel port to display controller. Baud equ 40H ; Switches port. Stack equ 0FFFFH ; Mailbox equates. Head equ 0 Tail equ 1 Count equ 2 Base equ 3 Status equ 4 UnChar equ 5 ; Should be used only for CntrlS and CntrlQ ; Equates for the Queue status byte XmitOff equ 00 ; xmitter is disabled. ; Baud/Switch equates. Bmask equ 0FH Rawout equ 020H RObit equ 5 Rawin equ 040H RIbit equ 6 Xon equ 080H Xonbit equ 7 ; Some ASCII character equates. CntrlS equ 19 ; Xoff CntrlQ equ 17 ; Xon Cr equ 13 ; Carriage return. eject 1 ORG 0FC00H RAM_START: ; Variable declarations ; Ram is in the top 1K of memory. ; Queues. ; These are the actual data buffers. The only routine that should use ; these labels re INIT_V to set the mailbox data pointers up. ; All I/O is via GETQ and PUTQ routines. INBUF: block 256 ; input buffer q. OUTBUF: block 256 ; output buffer q. UNUSED: block 256 ; unused ram ; Now the ram for variables and stack. SWTCH: block 1 ; Current baud/switches ; Variable for the H_to_Q routine ; It holds the upper nibble of hex until the lower one arrives. ; Bit 0 = 1 for empty, 0 for upper nibble full. H_to_QV: block 1 ; End of message variables. MESS_LEN: block 1 ; How long messages are. MESS_CNT: block 1 ; Number of chars in current message. EOM_CHAR: block 1 ; The end of message char. ; In and Out queues variables. INBOX: block 6 OUTBOX: block 6 eject 1 ; Mainline loop. ORG 0 JP RESET ; Jmp to the code ; Put in ID string ascii 'serial.z 1.8' RESET: LD SP, Stack CALL CHECK ; Check the hardware out. CALL INIT_HW ; Init the hardware devices. CALL INIT_V ; Init the variables. LD IX,OUTBOX ; Point to the outbox. LD A,(SWTCH) ; Check if we're in Xon/Xoff mode. AND Xon LD A,Cntrlq ; Send a Xon to host if we're in that mode CALL NZ,PUTQ ; Now loop checking for data available from host or display controller. ; Also check if we can send data to them. LOOP: IN A,(Lsr) ; Get the line status. LD C,A IN A,(Msr) ; Get the modem status. LD B,A ; and save it ; B = Msr, C = Lsr. ; Check for break condition. BIT Break,C ; test the bit in the Lsr JR Z,LOOP1 CALL SETBAUD ; reset the SWTCH variable. CALL INIT_V ; reset all the variables JR LOOP LOOP1: CALL HOST_IN CALL DISP_IN CALL DISP_OUT CALL HOST_OUT JR LOOP eject 1 ; Check if data is ready from host. HOST_IN: BIT DataRdy,C ; Data ready? RET Z ; Ret if no. ; Handle a byte from the Host. LD IX,INBOX ; data will go into the Input Q. LD A,(SWTCH) ; check for Raw or encoded mode. LD H,A AND Rawin ; NZ for Raw mode IN A,(Serial) ; get the data byte. JR Z,HEX_IN ; Jmp if hex data in. RAW_IN: ; Process Raw data CALL PUTQ JP STOP_IN ; stop the input if needed. HEX_IN: AND 7FH ; Kill any parity bit. CP ' ' ; Printable ASCII? JR NC,PRINT ; Jmp if yes ; Control character. CP Cr ; Carriage Ret? JR NZ,IN_FLOW ; Jp if no. LD A,1 ; Set the H_to_Q variable to empty. LD (H_to_QV),A ; This flushes any partially assembled byte. RET ; Done ; Test for Xon/Xoff commands. IN_FLOW: BIT Xonbit,H ; Are we sensitive to them? RET Z ; Ret if no. LD HL,OUTBOX+Status ; Get a pointer to our outbox status. CP CntrlS ; Xoff our transmitter? JR NZ,NOT_XOFF ; Jmp if no. OFF: SET XmitOff,(HL) RET NOT_XOFF: CP CntrlQ ; Xon our xmitter? RET NZ ; ret if no. ON: RES XmitOff,(HL) RET ; Printable char received from host. PRINT: ; Printable character received in hex mode. SET 5,A ; Convert to lower case. CP 'l' ; Message length command? JR NZ,PRINT1 ; Jmp if no. CALL GET_HEX ; Get byte from UART LD (MESS_LEN),A ; Set the message length. LD (MESS_CNT),A ; Reset the number of chars sent so far. RET PRINT1: CP 'm' ; EOM char set command? JR NZ,PRINT2 CALL GET_HEX ; Get byte from UART LD (EOM_CHAR),A RET PRINT2: CP 's' ; change SWTCH command? JR NZ,PRINT3 CALL GET_HEX ; Get byte from UART CPL ; Toggle them. LD (SWTCH),A RET PRINT3: CALL H_to_Q ; Pack the encoded data into bytes. JP STOP_IN ; stop the input if needed. eject 1 ; Data ready from controller? DISP_IN: BIT InMt,B ; data from controller? RET NZ ; ret if no. LD IX,OUTBOX LD A,(IX+Count) ; Get the Q count. ADD A,3 ; Check if Q has room for 3 more bytes. RET C ; ret if no LD A,(SWTCH) ; check if we need to encode the data. AND Rawout IN A,(Crt) ; get the data from the crt. JP NZ,PUTQ ; send the raw data and return. ; hex data out to host. CALL B_to_H ; convert byte to hex format and stick in Q. ; Check if we need to stick an EOM char in. LD A,(MESS_LEN) ; Get the length. AND A RET Z ; Zero means no EOM character to be sent. LD HL,MESS_CNT ; Point to the counter. DEC (HL) ; Time to send a EOM char? RET NZ ; Ret if no. LD (HL),A ; reset the length. LD A,(EOM_CHAR) ; Get the char and stick it in the Q. JP PUTQ ; and return when done eject 1 ; Controller ready for data? DISP_OUT: BIT OutMt,B ; controller ready for data? RET Z ; Jmp if no LD IX,INBOX CALL GETQ ; get a byte for controller. RET C ; ret if no byte available. OUT (Crt),A ; send char to display. JP STRT_IN ; re-enable host xmitter if needed. eject 1 ; Host ready for data? HOST_OUT: BIT XmitMt,C ; Uart xmitter empty? RET Z ; ret if no. LD IX,OUTBOX ; Get OutBox pointer. LD A,(SWTCH) ; Check for Xon mode AND Xon JR NZ,H_O_Xon ; Jp if Xon mode. BIT CtsIn,B ; Clear to send? RET Z ; ret if no. JR H_O_Send ; We are clear to send. H_O_Xon: LD A,(OUTBOX+UnChar) AND A JR NZ,H_O_Send ; Always send an 'UnChar' BIT XmitOff,(IX+Status) RET NZ ; ret if xmitter is disabled. H_O_Send: CALL GETQ RET C ; Ret if no character available. OUT (Serial),A RET eject 1 ; Check the hardware out. ; Call this routine only after a external reset!!!! CHECK: ; Check the baud switch (really crude). IN A,(BAUD) ; Get the baud switch. LD B,A ; Save it. IN A,(BAUD) CP B ; Same as last time? BAD_B: ; Switch ERROR - Can't read switches twice in a row. JR NZ,BAD_B ; Loop if no. ; Check the ram. ; Write the complement of the low byte of address out to all ram, ; then check if it stayed the same. ; Note that this destroys all ram contents. POP DE ; Save the return address in a register. LD HL,RAM_START ; Get the first address of ram. LD B, NOT [RAM_START & 0FFH] LD C,B ; Get complement of low address byte. ; Load the ram with the pattern. RAM1: LD (HL),B DEC B INC HL LD A,H ; Test for done. OR L JR NZ,RAM1 ; Loop till all locations written. LD HL,RAM_START ; Get the first address of ram. ; Check if ram agrees with what should be there. RAM2: LD A,(HL) ; Get the byte. XOR C ; Same as its low address byte? JR Z,RAM6 ; Jmp if yes. ; Ram error. We have three loops: low bad, high bad, both bad. LD B,A ; Save the symptom. AND 0FH ; Low nibble bad? RAM3: ; Ram ERROR - bad high nibble. JR Z,RAM3 ; Jmp if no. LD A,B ; get the symptom back. AND 0F0H ; High nibble bad too? RAM4: ; Ram ERROR - bad low nibble. JR Z,RAM4 ; Loop if error. RAM5: ; Ram ERROR - both nibbles bad. JR RAM5 RAM6: DEC C INC HL LD A,H ; Done? OR L JR NZ,RAM2 ; Jmp if no. PUSH DE ; Fix the stack back up. ; Check out the National Semi INS8250 Uart. ; Since we were reset, Lcr should be zero. IN A,(Lcr) ; Get the Line Control reg AND A U0: ; Uart ERROR - Lcr not reset properly. JR NZ,U0 ; Loop if error. LD A,80H OUT (Lcr),A ; And set the Divisor access bit. IN A,(Lcr) ; Check that it got set. CP 80H ; Still set? U1: ; Uart ERROR - Lcr won't hold divisor access bit. JR NZ,U1 ; Loop if error. LD A,3 ; Try to set 38.4K baud OUT (Serial),A ; Ld the divisor. IN A,(Serial) ; Test that it loaded OK. SUB 3 ; Check if same (also set A to zero) U2: ; Uart ERROR - unexpected low divisor. JR NZ,U2 ; Loop if error. OUT (Ier),A ; Set high byte to zero IN A,(Ier) AND A ; Still zero? U3: ; Uart ERROR - unexpected high divisor. JR NZ,U3 ; Loop if no (ie, error). IN A,(Lcr) ; Get the Line reg back. SUB 80H ; Is it the same as before? U4: ; Uart ERROR - unexpected Lcr value after setting divisor. JR NZ,U4 ; loop if error. OUT (Lcr),A ; Turn off divisor access bit. IN A,(Lcr) ; Check it. AND A U5: ; Uart ERROR - Lcr won't reset after setting divisor. JR NZ,U5 LD A,7 OUT (Lcr),A ; 8 bits, no parity, 2 stop bits IN A,(Lcr) SUB 7 ; Test if the same (also set A to zero) U6: ; Uart ERROR - Can't set proper operating Lcr. JR NZ,U6 ; If we succeed, assume Lcr is Ok. OUT (Ier),A ; Disable all 8250 interrupt conditions (set to 0). IN A,(Ier) AND A U7: ; Uart ERROR - Can't reset Ier. JR NZ,U7 RET eject 1 ; Init the hardware. INIT_HW: CALL SETBAUD ; Set the Uart baud LD A,7 OUT (Lcr),A ; 8 bits, no parity, 2 stop bits XOR A ; Disable all 8250 interrupt conditions. OUT (Ier),A LD A,3 ; Dtr, Rts on. OUT (Mcr),A ; Perform the I/O diagnostic with the controller. ; Wait for data from controller, then echo it back. INITH1: IN A,(Msr) ; Check if controller data ready. BIT InMt,A ; Ready? JR NZ,INITH1 ; Jmp if no. IN A,(Crt) ; Get the data. OUT (Crt),A ; And send it back to controller. RET ; Init the variables. INIT_V: XOR A ; zero A ; Init the Q's LD IX,INBOX ; Init the inbox. LD (IX + Head),A LD (IX + Tail),A LD (IX + Count),A LD HL,INBUF LD (IX + Base),H LD (IX + Status),A LD (IX + UnChar),A LD IX,OUTBOX ; Init the outbox. LD (IX + Head),A LD (IX + Tail),A LD (IX + Count),A LD HL,OUTBUF LD (IX + Base),H LD (IX + Status),A LD (IX + UnChar),A ; Init the H_to_Q variable. LD A,1 LD (H_to_QV),A ; init the 'end of message' stuff LD A,Cr ; default r is a carriage return. LD (EOM_CHAR),A XOR A LD (MESS_LEN),A LD (MESS_CNT),A RET eject 1 ; These routines handle the input and output queues. ; The Q pointer is passed in IX, result/source in A. ; Queues must be 256 bytes long. We use only 8 bit ; arithmetic for Q manipulation. ; A Q is defined as 6 bytes of status: ; Tail Offset for getting next char ; Head Offset for putting next char ; Count Number of chars in q ; Base High byte of the q origin ; Status Status of Q ; UnChar The 'un_get' char if non-zero ; and 256 bytes of storage. ; GETQ: ; Get an element from the Q. ; entry ix = Q pointer ; exit a = result ; ca = set for empty Q, cleared for full Q. ; bc & de are unchanged. ; hl = garbage ; LD A,(IX + UnChar) ; Get the unget char LD (IX + UnChar),0 ; Set the byte to 0 (empty). AND A RET NZ ; Ret if we got an unget char. ; A == 0 here. CP (IX + Count) ; Get the q count SCF RET Z ; empty Q return (Count == 0). DEC (IX + Count) ; one less item in the Q. LD L,(IX + Tail) ; get a pointer to the element in the Q. LD H,(IX + Base) INC (IX + Tail) ; bump the pointer to the next char. OR (HL) ; Get the element, and clear the carry. RET PUTQ: ; Routine to put a char in a Q. ;entry ix = pointer to Q structure. ; a = char to put. ;exit hl = garbage ; a, bc & de unchanged. ; Ca = 1 for Q full, character discarded. ; INC (IX + Count) ; Bump the Q count. QPUT_ERR: JR Z,QPUT_ERR QPUT1: LD H,(IX + Base) LD L,(IX + Head) LD (HL),A ; Put the char in the Q INC (IX + Head) AND A ; Clear the carry bit RET eject 1 ; These routines pack and unpack bytes into Hex ; suitable for sending as ASCII over a serial line. ; H_to_Q takes Hex characters ; and packs them into 8 bit bytes to send to the display. ; B_to_H takes bytes from the display and converts them into ; the Hex character stream. ; ; Both routines use Q calls. IX must be set up with the proper ; Q address. ; ; H_to_Q: ; ; entry A = Ascii Hex char (0-9, a-f) ; IX = Q pointer ; exit A, Hl = Garbage ; bc, de = unchanged. ; Ca = 1 if Q too full. ; CALL H_to_B ; convert the character to binary. LD HL,H_to_QV ; Point hl to our variable BIT 0,(HL) ; check if the upper nibble is full. JR Z,H_SEND ; Jmp if yes. ADD A,A ; Move the nibble to the high 4 bits. ADD A,A ADD A,A ADD A,A LD (HL),A ; Save away the high nibble with low nibble = 0. RET H_SEND: OR (HL) ; Merge in the upper nibble from ram. LD (HL),1 ; Set the variable to empty. JP PUTQ ; Send the byte and return. eject 1 B_to_H: ; B_to_H takes the byte in A and splits it into two hex characters ; to be sent to the Q specified in IX. ; ; Entry A = byte of data to convert to Hex. ; IX = Q address. ; Exit A E Hl = garbage ; D Bc Ix = unchanged. ; LD E,A ; Save the byte RRA ; Move the upper nibble to low nibble. RRA RRA RRA AND 0Fh ; Get only the upper nibble. CP 10 ; 0 thru 9? JR C,B_to_H1 ; Jmp if yes. ADD A,'A'-'0'-10 B_to_H1: ADD A,'0' CALL PUTQ LD A,E ; Get the byte back AND 0Fh ; Mask for only low nibble. CP 10 ; 0 thru 9? JR C,B_to_H2 ; Jmp if yes. ADD A,'A'-'0'-10 B_to_H2: ADD A,'0' JP PUTQ ; Send and return. eject 1 GET_HEX: ; This routine gets two hex characters from the UART and ; munches them into a byte in A. ; Entry: No Params. ; Exit: A=byte H = trash ; all others unchanged (except for flags) IN A,(Lsr) ; Get the line status BIT DataRdy,A ; Data ready from host? JR Z,GET_HEX ; Jmp if no. IN A,(Serial) ; get the data. CALL H_to_B ; convert to binary. ADD A,A ; Shift up 4 bits ADD A,A ADD A,A ADD A,A LD H,A ; Save in B GET_HX1: IN A,(Lsr) ; Get the line status BIT DataRdy,A ; Data ready from host? JR Z,GET_HX1 ; Jmp if no. IN A,(Serial) ; get the data. CALL H_to_B ; convert to binary. OR H RET ; A = 2 input chars munched together. ; Convert hex char to binary. H_to_B: SET 5,A ; convert to lower case. SUB '0' ; less than 0? JR C,HB_ERR ; Jmp if out of bounds. CP 10 ; bigger than 9? RET C ; Ret if no (0..9) SUB 'a'-'0'-10 ; try to make it range 10-15 CP 10 JR C,HB_ERR ; Jmp if out of bounds. CP 16 RET C ; Ret if hex. HB_ERR: XOR A ; Set to zero. RET eject 1 SETBAUD: ; This routine reads the BAUD switches and looks the code ; up in the BTABLE to set the baudrate of the 8250 serial chip. ; ; Entry No parameters ; exit A Hl De = garbage. IN A,(Lcr) ; Set the divisor access bit on OR 80H OUT (Lcr),A IN A,(Baud) ; Get the baud rate code LD (SWTCH),A AND Bmask ; Get only the baud specifier bits. ADD A,A ; Double it to index into table. LD HL,BTABLE ; Index into table to get the divisor LD E,A LD D,0 ADD HL,DE LD A,(HL) ; Get the low order divisor byte OUT (Serial),A INC HL LD A,(HL) ; Get the high divisor byte OUT (Serial+1),A IN A,(Lcr) ; Set the divisor access bit off AND 7FH OUT (Lcr),A RET ; Baud rate look up table ; Only allow 16 entries. BTABLE: WORD 5 ; 38.4 Kbaud WORD 10 ; 19.2 WORD 20 ; 9600 WORD 27 ; 7200 WORD 40 ; 4800 WORD 53 ; 3600 WORD 80 ; 2400 WORD 107 ; 1800 WORD 160 ; 1200 WORD 320 ; 600 WORD 640 ; 300 WORD 1280 ; 150 WORD 1428 ; 134.5 WORD 1745 ; 110 WORD 2560 ; 75 WORD 3840 ; 50 eject 1 ; STRT_IN and STOP_IN are called when the Input Q is may be too full/empty. ; They check and enable/disable the host xmitter apropriately. ; STRT_IN: ; Entry No registers set. ; Exit A Ix Hl = garbage. ; Bc De = unchanged. ; LD IX,INBOX ; Point to the Q. BIT XmitOff,(IX + Status) ; Is it off? RET Z ; ret if no. LD A,40 ; Check if we've gone below low water mark. CP (IX + Count) RET C ; Ret if no, Q still too full. LD A,(SWTCH) ; get the switch settings. BIT Xonbit,A JR Z,STRT_DTR ; Jmp if rs232 modem mode flow control. ; Try to use Xon/Xoff control flow methods. BIT RObit,A ; Raw Output mode? RET NZ ; No way to start/stop host xmitter. LD HL,OUTBOX+UnChar LD A,(HL) ; Anything in unget spot? AND A RET NZ ; Ret if yes. LD (HL),CntrlQ ; 'unget' a control Q. JR STRT_END ; Set DTR bit on. STRT_DTR: IN A,(Mcr) ; get the modem controls. SET DtrOut,A OUT (Mcr),A STRT_END: RES XmitOff,(IX + Status) ; Mark as enabled. RET STOP_IN: ; Entry No registers set. ; Exit A Ix Hl = garbage. ; Bc De = unchanged. ; LD IX,INBOX ; Point to the Q. BIT XmitOff,(IX + Status) ; Already disabled? RET NZ ; ret if yes. LD A,256-40 ; Check if we've gone above high water mark. CP (IX + Count) RET NC ; Ret if no, Q still too empty. LD A,(SWTCH) BIT Xonbit,A ; test for Xon/Xoff vs. modem flow cntrl. JR Z,STP_DTR ; jmp if rs232 modem mode ; try to send an Xoff to the host. BIT RObit,A ; Are we in raw out? RET NZ ; Can't control the host xmitter. LD HL,OUTBOX+UnChar LD A,(HL) ; Anything in unget spot? AND A RET NZ ; Ret if yes. LD (HL),CntrlS ; 'unget' a control S. JR STP_END ; Modem mode flow control, set DTR bit off. STP_DTR: IN A,(Mcr) ; get the modem controls. RES DtrOut,A OUT (Mcr),A STP_END: SET XmitOff,(IX + Status) ; Mark as disabled. RET END   !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmn#include #include #include #include #include #include "proto.h" #pragma optimize 15 #pragma lint -1 # line 2 "zmac.y" /* * zmac -- macro cross-assembler for the Zilog Z80 microprocessor * * Bruce Norskog 4/78 * * Last modification 1-18-87 by cdk * This assembler is modeled after the Intel 8080 macro cross-assembler * for the Intel 8080 by Ken Borgendale. The major features are: * 1. Full macro capabilities * 2. Conditional assembly * 3. A very flexible set of listing options and pseudo-ops * 4. Symbol table output * 5. Error report * 6. Elimination of sequential searching * 7. Commenting of source * 8. Facilities for system definiton files * * Revision History: * * jrp 3-8-82 Converted to run on Vax, updated syntax to conform better * to the Zilog standard. * * jrp 3-15-82 Added underscore as a character type in the lex table * 'numpart' (0x5F). * * Changed maximum number of characters in a label to 15 * from 7. Note that 'putsymtab' uses this value inside * of a quoted string, so we use 15. * * jrp 2-15-83 Fixed 'getlocal' to return better local labels. It used * to crash after 6 invocations. * * jrp 6-7-83 Fixed bug in the ADD IX,... instruction. * * jrp 5-11-84 Added code to print unused labels out with the symbol table * Also sped up the macro processor by using stdio. * * jrp 5-22-84 Added include files ala ormac * * jrp 8-27-84 Added PHASE/DEPHASE commands * * cdk 9-20-86 Converted to run on a Pyramid. This meant changing yylval * to be a %union, and then putting in the appropriate * typecasts where ints are pointers are used interchangeably. * The current version still probably won't run on machines where * sizeof(int) != sizeof(char *). * Also changed emit() to use varargs, and got rid of the * old style = in front of yacc action code. * -Colin Kelley vu-vlsi!colin * * cdk 10-2-86 Added some more typecasts to keep lint a little happier. * Removed several unused variables. Changed most vars * declared as char to int, since many of them were being * compared with -1! I still don't know what's going on with * est[][] being malloc'd and free'd everywhere...it looks pretty * fishy... * * cdk 1-18-87 Added MIO code to emulate 'mfile' using malloc()'d memory. * This was needed to get the code to work when compiled under * MSC 4.0 on a PC, and it's probably faster anyway. * * cdk 2-5-87 Added 'cmp' as a synonym for 'cp', 'jmp' as a synonym for * 'jp', and added tolerance of accumulator specification for arithmetic * and logical instructions. (For example, 'or a,12' is now accepted, * same as 'or 12'.) */ #define MIO /* use emulation routines from mio.c */ #include #ifdef MSDOS #include #else #include /* for open() calls */ #endif #ifdef vax11c #define unlink(filename) delete(filename) #endif #ifndef MIO #define mfopen(filename,mode) fopen(filename,mode) #define mfclose(filename,mode) fclose(filename,mode) #define mfputc(c,f) putc(c,f) #define mfgetc(f) getc(f) #define mfseek(f,loc,origin) fseek(f,loc,origin) #define mfread(ptr,size,nitems,f) fread(ptr,size,nitems,f) #define mfwrite(ptr,size,nitems,f) fread(ptr,size,nitems,f) #endif /* MIO */ /* * DEBUG turns on pass reporting. * Macro debug and Token debug enables. #define T_DEBUG #define DEBUG #define M_DEBUG */ #define ITEMTABLESIZE 2000 #define TEMPBUFSIZE 200 #define LINEBUFFERSIZE 200 #define EMITBUFFERSIZE 200 #define MAXSYMBOLSIZE 15 #define IFSTACKSIZE 20 #define MAXIFS 150 #define TITLELEN 50 #define BINPERLINE 16 #define PARMMAX 25 #define MAXEXP 25 #define SYMMAJIC 07203 #define NEST_IN 8 #define loop for(;;) int yyerror(char *err) {} /* we will do our own error printing */ struct item { char *i_string; int i_value; int i_token; int i_uses; }; FILE *fout, *fbuf, *fin[NEST_IN], *now_file ; int pass2; /*set when pass one completed*/ int dollarsign ; /* location counter */ int olddollar ; /* kept to put out binary */ /* program counter save for PHASE/DEPHASE */ int phdollar, phbegin, phaseflag ; char *src_name[NEST_IN] ; int linein[NEST_IN] ; int now_in ; #define bflag 0 /* balance error */ #define eflag 1 /* expression error */ #define fflag 2 /* format error */ #define iflag 3 /* bad digits */ #define mflag 4 /* multiply defined */ #define pflag 5 /* phase error */ #define uflag 6 /* undeclared used */ #define vflag 7 /* value out of range */ #define oflag 8 /* phase/dephase error */ #define FLAGS 9 /* number of flags */ char err[FLAGS]; int keeperr[FLAGS]; char errlet[]="BEFIMPUVO"; char *errname[]={ "Balance", "Expression", "Format", "Digit", "Mult. def.", "Phase", "Undeclared", "Value", "Phase/Dephase", }; char linebuf[LINEBUFFERSIZE]; char *lineptr; char *linemax = &linebuf[LINEBUFFERSIZE]; char outbin[BINPERLINE]; char *outbinp = outbin; char *outbinm = &outbin[BINPERLINE]; char emitbuf[EMITBUFFERSIZE]; char *emitptr; char ifstack[IFSTACKSIZE]; char *ifptr; char *ifstmax = &ifstack[IFSTACKSIZE-1]; char expif[MAXIFS]; char *expifp; char *expifmax = &expif[MAXIFS]; char hexadec[] = "0123456789ABCDEF" ; char *expstack[MAXEXP]; int expptr; int nitems; int linecnt; int nbytes; int invented; char tempbuf[TEMPBUFSIZE]; char *tempmax = &tempbuf[TEMPBUFSIZE-1]; char inmlex; char arg_flag; char quoteflag; int parm_number; int exp_number; char symlong[] = "Symbol too long"; int disp; #define FLOC PARMMAX #define TEMPNUM PARMMAX+1 char **est; char **est2; char *floc; int mfptr; FILE *mfile; char *writesyms; char *title; char titlespace[TITLELEN]; char *timp; char *sourcef; char src[15]; char bin[15]; char mtmp[15]; char listf[15]; char bopt = 1, edef = 1, eopt = 1, fdef = 0, fopt = 0, gdef = 1, gopt = 1, iopt = 0 , /* list include files */ lstoff = 0, lston = 0, /* flag to force listing on */ lopt = 0, mdef = 0, mopt = 0, nopt = 1 , /* line numbers on as default */ oopt = 0, popt = 1, /* form feed as default page eject */ sopt = 0, /* turn on symbol table listing */ topt = 1; int saveopt; char xeq_flag = 0; int xeq; time_t now; int line; int page = 1; struct stab { char t_name[MAXSYMBOLSIZE+1]; int t_value; int t_token; }; /* * push back character */ int peekc; /* * add a character to the output line buffer */ int addtoline(int ac) { /* check for EOF from stdio */ if (ac == -1) ac = 0 ; if (inmlex) return(ac); if (lineptr >= linemax) error("line buffer overflow"); *lineptr++ = ac; return(ac); } #include /* * put values in buffer for outputing */ /*VARARGS*/ /*ARGSUSED*/ int emit(int bytes, ...) { va_list ap; va_start(ap,bytes); while (--bytes >= 0) if (emitptr >= &emitbuf[EMITBUFFERSIZE]) error("emit buffer overflow"); else { *emitptr++ = va_arg(ap,int); } va_end(ap); } int emit1(int opcode,int regvalh,int data16,int type) { if (regvalh & 0x8000) { if (type & 1 == 0 && (disp > 127 || disp < -128)) err[vflag]++; switch(type) { case 0: if (opcode & 0x8000) emit(4, regvalh >> 8, opcode >> 8, disp, opcode); else emit(3, regvalh >> 8, opcode, disp); break; case 1: emit(2, regvalh >> 8, opcode); break; case 2: if (data16 > 255 || data16 < -128) err[vflag]++; emit(4, regvalh >> 8, opcode, disp, data16); break; case 5: emit(4, regvalh >> 8, opcode, data16, data16 >> 8); } } else switch(type) { case 0: if (opcode & 0100000) emit(2, opcode >> 8, opcode); else emit(1, opcode); break; case 1: if (opcode & 0100000) emit(2, opcode >> 8, opcode); else emit(1, opcode); break; case 2: if (data16 > 255 || data16 < -128) err[vflag]++; emit(2, opcode, data16); break; case 3: if (data16 >255 || data16 < -128) err[vflag]++; emit(2, opcode, data16); break; case 5: if (opcode & 0100000) emit(4, opcode >> 8, opcode, data16, data16 >> 8); else emit(3, opcode, data16, data16 >> 8); } } int emitdad(int rp1,int rp2) { if (rp1 & 0x8000) emit(2,rp1 >> 8, rp2 + 9); else emit(1,rp2 + 9); } int emitjr(int opcode,int expr) { disp = expr - dollarsign - 2; if (disp > 127 || disp < -128) err[vflag]++; emit(2, opcode, disp); } /* * put out a byte of binary */ int putbin(int v) { if(!pass2 || !bopt) return; *outbinp++ = v; if (outbinp >= outbinm) flushbin(); } /* * output one line of binary in INTEL standard form */ int flushbin(void) { register char *p; register check; if (!pass2 || !bopt) return; nbytes += outbinp-outbin; if (check = outbinp-outbin) { putc(':', fbuf); puthex(check, fbuf); puthex(olddollar>>8, fbuf); puthex(olddollar, fbuf); puthex(0, fbuf); check += (olddollar >> 8) + olddollar; olddollar += (outbinp-outbin); for (p=outbin; p> 4) & 017], buf); putc(hexadec[byte & 017], buf); } /* * put out a line of output -- also put out binary */ int list(int optarg) { register char * p; register int i; int lst; if (!expptr) linecnt++; addtoline('\0'); if (pass2) { lst = iflist(); if (lst) { lineout(); if (nopt) fprintf(fout, "%4d:\t", linein[now_in]); puthex(optarg >> 8, fout); puthex(optarg, fout); fputs(" ", fout); for (p = emitbuf; (p < emitptr) && (p - emitbuf < 4); p++) { puthex(*p, fout); } for (i = 4 - (p-emitbuf); i > 0; i--) fputs(" ", fout); putc('\t', fout); fputs(linebuf, fout); } if (bopt) { for (p = emitbuf; p < emitptr; p++) putbin(*p); } p = emitbuf+4; while (lst && gopt && p < emitptr) { lineout(); if (nopt) putc('\t', fout); fputs(" ", fout); for (i = 0; (i < 4) && (p < emitptr);i++) { puthex(*p, fout); p++; } putc('\n', fout); } lsterr2(lst); } else lsterr1(); dollarsign += emitptr - emitbuf; emitptr = emitbuf; lineptr = linebuf; } /* * keep track of line numbers and put out headers as necessary */ int lineout(void) { if (line == 60) { if (popt) putc('\014', fout); /* send the form feed */ else fputs("\n\n\n\n\n", fout); line = 0; } if (line == 0) { fprintf(fout, "\n\n%s %s\t%s\t Page %d\n\n\n", &timp[4], &timp[20], title, page++); line = 4; } line++; } /* * cause a page eject */ int eject(void) { if (pass2 && iflist()) { if (popt) { putc('\014', fout); /* send the form feed */ } else { while (line < 65) { line++; putc('\n', fout); } } } line = 0; } /* * space n lines on the list file */ int space(int n) { int i ; if (pass2 && iflist()) for (i = 0; i 4 && topt) errorprt(i); } fflush(fout); /*to avoid putc(har) mix bug*/ } /* * print diagnostic to error terminal */ int errorprt(int errnum) { fprintf(stderr,"%d: %s error\n%s\n", linecnt, errname[errnum], linebuf) ; fflush(stderr) ; return ; } /* * list without address -- for comments and if skipped lines */ int list1(void) { int lst; addtoline('\0'); lineptr = linebuf; if (!expptr) linecnt++; if (pass2) if (lst = iflist()) { lineout(); if (nopt) fprintf(fout, "%4d:\t", linein[now_in]); fprintf(fout, "\t\t%s", linebuf); lsterr2(lst); } else lsterr1(); } /* * see if listing is desired */ int iflist(void) { register i, j; if (lston) return(1) ; if (lopt) return(0); if (*ifptr && !fopt) return(0); if (!lstoff && !expptr) return(1); j = 0; for (i=0; i= tempmax) error(symlong); *p++ = (c >= 'A' && c <= 'Z') ? c + 'a' - 'A' : c; while ((c = nextchar()) == '$') ; } while (charclass[c]==LETTER || charclass[c]==DIGIT); if (p - tempbuf > MAXSYMBOLSIZE) p = tempbuf + MAXSYMBOLSIZE; *p++ = '\0'; peekc = c; return(tokenofitem(UNDECLARED)); case DIGIT: if (*ifptr) return(skipline(c)); p = tempbuf; do { if (p >= tempmax) error(symlong); *p++ = tolower(c); while ((c = nextchar()) == '$'); } while(numpart[c]); peekc = c; *p-- = '\0'; switch(*p) { case 'o': case 'q': radix = 8; limit = 020000; *p = '\0'; break; case 'd': radix = 10; limit = 3276; *p = '\0'; break; case 'h': radix = 16; limit = 010000; *p = '\0'; break; case 'b': radix = 2; limit = 077777; *p = '\0'; break; default: radix = 10; limit = 3276; p++; break; } /* * tempbuf now points to the number, null terminated * with radix 'radix'. */ value = 0l; p = tempbuf; do { c = *p - (*p > '9' ? ('a' - 10) : '0'); if (c >= radix) { err[iflag]++; yylval.ival = 0; break; } if (value < limit || (radix == 10 && yylval.ival == 3276 && c < 8) || (radix == 2 && yylval.ival == limit)) value = value * radix + c; else { err[vflag]++; yylval.ival = 0; break; } } while(*++p != '\0'); yylval.ival = value; return(NUMBER); default: if (*ifptr) return(skipline(c)); switch(c) { case ';': return(skipline(c)); case '\'': if (quoteflag) return('\''); p = tempbuf; p[1] = 0; do switch(c = nextchar()) { case '\0': case '\n': err[bflag]++; goto retstring; case '\'': if ((c = nextchar()) != '\'') { retstring: peekc = c; *p = '\0'; if ((p-tempbuf) >2) { yylval.cval = tempbuf; return(STRING); } else if (p-tempbuf == 2) { p = tempbuf; yylval.ival = *p++ ; yylval.ival |= *p<<8; return(TWOCHAR); } else { p = tempbuf; yylval.ival = *p++; return(ONECHAR); } } default: *p++ = c; } while (p < tempmax); /* * if we break out here, our string is longer than * our input line */ error("string buffer overflow"); default: return(c); } } } /* * return the token associated with the string pointed to by * tempbuf. if no token is associated with the string, associate * deftoken with the string and return deftoken. * in either case, cause yylval to point to the relevant * symbol table entry. */ int tokenofitem(int deftoken) { register char *p; register struct item * ip; register i; int r, l, u, hash; #ifdef T_DEBUG fputs("'tokenofitem entry' ", stderr) ; fputs(tempbuf, stderr) ; #endif /* * binary search */ l = 0; u = (sizeof keytab/sizeof keytab[0])-1; while (l <= u) { i = (l+u)/2; ip = &keytab[i]; if ((r = strcmp(tempbuf, ip->i_string)) == 0) goto found; if (r < 0) u = i-1; else l = i+1; } /* * hash into item table */ hash = 0; p = tempbuf; while (*p) hash += *p++; hash %= ITEMTABLESIZE; ip = &itemtab[hash]; loop { if (ip->i_token == 0) break; if (strcmp(tempbuf, ip->i_string) == 0) goto found; if (++ip >= itemmax) ip = itemtab; } if (!deftoken) { i = 0 ; goto token_done ; } if (++nitems > ITEMTABLESIZE-20) error("item table overflow"); ip->i_string = malloc(strlen(tempbuf)+1); ip->i_token = deftoken; ip->i_uses = 0 ; strcpy(ip->i_string, tempbuf); found: if (*ifptr) { if (ip->i_token == ENDIF) { i = ENDIF ; goto token_done ; } if (ip->i_token == IF) { if (ifptr >= ifstmax) error("Too many ifs"); else *++ifptr = 1; } i = skipline(' '); goto token_done ; } yylval.itemptr = ip; i = ip->i_token; token_done: #ifdef T_DEBUG fputs("\t'tokenofitem exit'\n", stderr) ; #endif return(i) ; } /* * interchange two entries in the item table -- used by nqsort */ int interchange(int i, int j) { register struct item *fp, *tp; struct item temp; fp = &itemtab[i]; tp = &itemtab[j]; temp.i_string = fp->i_string; temp.i_value = fp->i_value; temp.i_token = fp->i_token; temp.i_uses = fp->i_uses; fp->i_string = tp->i_string; fp->i_value = tp->i_value; fp->i_token = tp->i_token; fp->i_uses = tp->i_uses; tp->i_string = temp.i_string; tp->i_value = temp.i_value; tp->i_token = temp.i_token; tp->i_uses = temp.i_uses; } /* * quick sort -- used by putsymtab to sort the symbol table */ int nqsort(int m, int n) { register i, j; if (m < n) { i = m; j = n+1; loop { do i++; while(strcmp(itemtab[i].i_string, itemtab[m].i_string) < 0); do j--; while(strcmp(itemtab[j].i_string, itemtab[m].i_string) > 0); if (i < j) interchange(i, j); else break; } interchange(m, j); nqsort(m, j-1); nqsort(j+1, n); } } /* * get the next character */ int nextchar(void) { register int c, ch; static char *earg; if (peekc != -1) { c = peekc; peekc = -1; return(c); } start: if (earg) { if (*earg) return(addtoline(*earg++)); earg = 0; } if (expptr) { if ((ch = getm()) == '\1') { /* expand argument */ ch = getm() - 'A'; if (ch >= 0 && ch < PARMMAX && est[ch]) earg = est[ch]; goto start; } if (ch == '\2') { /* local symbol */ ch = getm() - 'A'; if (ch >= 0 && ch < PARMMAX && est[ch]) { earg = est[ch]; goto start; } earg = getlocal(ch, (int)est[TEMPNUM]); goto start; } return(addtoline(ch)); } ch = getc(now_file) ; /* if EOF, check for include file */ if (ch == EOF) { while (ch == EOF && now_in) { fclose(fin[now_in]) ; free(src_name[now_in]) ; now_file = fin[--now_in] ; ch = getc(now_file) ; } if (linein[now_in] < 0) { lstoff = 1 ; linein[now_in] = -linein[now_in] ; } else { lstoff = 0 ; } if (pass2 && iflist()) { lineout() ; fprintf(fout, "**** %s ****\n", src_name[now_in]) ; } } if (ch == '\n') linein[now_in]++ ; return(addtoline(ch)) ; } /* * skip to rest of the line -- comments and if skipped lines */ int skipline(int ac) { register c; c = ac; while (c != '\n' && c != '\0') c = nextchar(); return('\n'); } int main(int argc, char **argv) { register struct item *ip; register i; int files; #ifdef DBUG extern yydebug; #endif fout = stdout ; fin[0] = stdin ; now_file = stdin ; files = 0; for (i=1; ii_uses = 0 ; /* set macro names, equated and defined names */ switch (ip->i_token) { case MNAME: ip->i_token = OLDMNAME; break; case EQUATED: ip->i_token = WASEQUATED; break; case DEFLED: ip->i_token = UNDECLARED; break; } } setvars(); fseek(now_file, (long)0, 0); #ifdef DEBUG fputs("DEBUG- pass 2\n", stderr) ; #endif yyparse(); if (bopt) { flushbin(); putc(':', fbuf); if (xeq_flag) { puthex(0, fbuf); puthex(xeq >> 8, fbuf); puthex(xeq, fbuf); puthex(1, fbuf); puthex(255-(xeq >> 8)-xeq, fbuf); } else for (i = 0; i < 10; i++) putc('0', fbuf); putc('\n', fbuf); fflush(fbuf); } if (!lopt) fflush(fout); if (writesyms) outsymtab(writesyms); if (eopt) erreport(); if (!lopt && !sopt) putsymtab(); if (!lopt) { eject(); fflush(fout); } exit(0); } /* * set some data values before each pass */ int setvars(void) { register i; peekc = -1; linein[now_in] = linecnt = 0; exp_number = 0; emitptr = emitbuf; lineptr = linebuf; ifptr = ifstack; expifp = expif; *ifptr = 0; dollarsign = 0; olddollar = 0; phaseflag = 0; for (i=0; ii_token == UNDECLARED) { nitems--; continue; } if (fp->i_token == 0) continue; tp++; if (tp != fp) { tp->i_string = fp->i_string; tp->i_value = fp->i_value; tp->i_token = fp->i_token; tp->i_uses = fp->i_uses ; } } tp++; tp->i_string = "{"; /* sort the table */ nqsort(0, nitems-1); title = "** Symbol Table **"; rows = (nitems+3) / 4; if (rows+5+line > 60) eject(); lineout(); fprintf(fout,"\n\n\nSymbol Table:\n\n") ; line += 4; for (i=0; ii_token; c = ' ' ; if (t == EQUATED || t == DEFLED) c = '=' ; if (tp->i_uses == 0) c1 = '+' ; else c1 = ' ' ; fprintf(fout, "%-15s%c%4x%c ", tp->i_string, c, tp->i_value & 0xffff, c1); } } lineout(); putc('\n', fout); } } /* * put out error report */ int erreport(void) { register i, numerr; if (line > 50) eject(); lineout(); numerr = 0; for (i=0; i 55) eject(); lineout(); fprintf(fout, "\n%6d\tsymbols\n", nitems); fprintf(fout, "%6d\tbytes\n", nbytes); line += 2; if (mfptr) { if (line > 53) eject(); lineout(); fprintf(fout, "\n%6d\tmacro calls\n", exp_number); fprintf(fout, "%6d\tmacro bytes\n", mfptr); fprintf(fout, "%6d\tinvented symbols\n", invented/2); line += 3; } } /* * lexical analyser for macro definition */ int mlex(void) { register char *p; register c; int t; /* * move text onto macro file, changing formal parameters */ #ifdef M_DEBUG fprintf(stderr,"enter 'mlex'\t") ; #endif inmlex++; c = nextchar(); loop { switch(charclass[c]) { case DIGIT: while (numpart[c]) { putm(c); c = nextchar(); } continue; case STARTER: case LETTER: t = 0; p = tempbuf+MAXSYMBOLSIZE+2; do { if (p >= tempmax) error(symlong); *p++ = c; if (t < MAXSYMBOLSIZE) tempbuf[t++] = (c >= 'A' && c <= 'Z') ? c+'a'-'A' : c; c = nextchar(); } while (charclass[c]==LETTER || charclass[c]==DIGIT); tempbuf[t] = 0; *p++ = '\0'; p = tempbuf+MAXSYMBOLSIZE+2; t = tokenofitem(0); if (t != MPARM) while (*p) putm(*p++); else { if (*(yylval.itemptr->i_string) == '?') putm('\2'); else putm('\1'); putm(yylval.itemptr->i_value + 'A'); } if (t == ENDM) goto done; continue; case F_END: if (expptr) { popsi(); c = nextchar(); continue; } goto done; default: if (c == '\n') { linecnt++; } if (c != '\1') putm(c); c = nextchar(); } } /* * finish off the file entry */ done: while(c != EOF && c != '\n' && c != '\0') c = nextchar(); linecnt++; putm('\n'); putm('\n'); putm(0); for (c=0; c linebuf) lineptr--; } /* * return a unique name for a local symbol * c is the parameter number, n is the macro number. */ char *getlocal(int c, int n) { static char local_label[10]; invented++; if (c >= 26) c += 'a' - '0'; sprintf(local_label, "?%c%04d", c+'a', n) ; return(local_label); } /* * read in a symbol table */ void insymtab(char *name) { register struct stab *t; int s, i, sfile; t = (struct stab *) tempbuf; #ifdef MSDOS if ((sfile = open(name, O_RDONLY | O_BINARY)) < 0) #else if ((sfile = open(name, O_RDONLY)) < 0) #endif return; read(sfile, (char *)t, sizeof *t); if (t->t_value != SYMMAJIC) return; s = t->t_token; for (i=0; ii_token = t->t_token; yylval.itemptr->i_value = t->t_value; if (t->t_token == MACRO) yylval.itemptr->i_value += mfptr; } while ((s = read(sfile, tempbuf, TEMPBUFSIZE)) > 0) { mfptr += s; mfwrite(tempbuf, 1, s, mfile) ; } } /* * write out symbol table */ int outsymtab(char *name) { register struct stab *t; register struct item *ip; int i, sfile; t = (struct stab *) tempbuf; if ((sfile = creat(name, 0644)) < 0) return; for (ip=itemtab; ipi_token == UNDECLARED) { ip->i_token = 0; nitems--; } } copyname(title, (char *)t); t->t_value = SYMMAJIC; t->t_token = nitems; write(sfile, (char *)t, sizeof *t); for (ip=itemtab; ipi_token != 0) { t->t_token = ip->i_token; t->t_value = ip->i_value; copyname(ip->i_string, (char *)t); write(sfile, (char *)t, sizeof *t); } } mfseek(mfile, (long)0, 0); while((i = mfread(tempbuf, 1, TEMPBUFSIZE, mfile) ) > 0) write(sfile, tempbuf, i); } /* * copy a name into the symbol file */ void copyname(char *st1, char *st2) { register char *s1, *s2; register i; i = (MAXSYMBOLSIZE+2) & ~01; s1 = st1; s2 = st2; while(*s2++ = *s1++) i--; while(--i > 0) *s2++ = '\0'; } /* get the next source file */ int next_source(char *sp) { if(now_in == NEST_IN -1) error("Too many nested includes") ; if ((now_file = fopen(sp, "r")) == NULL) { char ebuf[100] ; sprintf(ebuf,"Can't open include file: %s", sp) ; error(ebuf) ; } if (pass2 && iflist()) { lineout() ; fprintf(fout, "**** %s ****\n",sp) ; } /* save the list control flag with the current line number */ if (lstoff) linein[now_in] = - linein[now_in] ; /* no list if include files are turned off */ lstoff |= iopt ; /* save the new file descriptor. */ fin[++now_in] = now_file ; /* start with line 0 */ linein[now_in] = 0 ; /* save away the file name */ src_name[now_in] = malloc(strlen(sp)+1) ; strcpy(src_name[now_in],sp) ; } int yyexca[] ={ -1, 0, 258, 23, 259, 23, 260, 23, 261, 23, 262, 23, 263, 23, 264, 23, 265, 23, 266, 23, 267, 23, 268, 23, 269, 23, 270, 23, 271, 23, 272, 23, 273, 23, 274, 23, 275, 23, 276, 23, 277, 23, 278, 23, 293, 23, 294, 23, 295, 23, 296, 23, 297, 23, 315, 23, 318, 23, 10, 23, -2, 0, -1, 1, 0, -1, -2, 0, -1, 2, 0, 1, 258, 23, 259, 23, 260, 23, 261, 23, 262, 23, 263, 23, 264, 23, 265, 23, 266, 23, 267, 23, 268, 23, 269, 23, 270, 23, 271, 23, 272, 23, 273, 23, 274, 23, 275, 23, 276, 23, 277, 23, 278, 23, 293, 23, 294, 23, 295, 23, 296, 23, 297, 23, 315, 23, 318, 23, 10, 23, -2, 0, }; # define YYNPROD 157 # define YYLAST 1138 int yyact[]={ 20, 172, 74, 277, 163, 73, 167, 193, 256, 153, 255, 86, 94, 151, 148, 95, 149, 19, 150, 84, 85, 101, 105, 102, 90, 62, 275, 92, 93, 254, 130, 153, 67, 279, 68, 151, 148, 128, 149, 246, 150, 110, 92, 93, 99, 111, 110, 231, 3, 261, 111, 62, 248, 11, 171, 241, 92, 93, 67, 108, 68, 13, 15, 16, 17, 14, 113, 92, 93, 114, 7, 8, 9, 10, 181, 182, 214, 12, 276, 218, 65, 62, 273, 271, 11, 103, 129, 155, 67, 53, 68, 199, 13, 15, 16, 17, 14, 101, 105, 102, 198, 7, 8, 9, 10, 137, 65, 62, 12, 196, 166, 103, 142, 219, 67, 103, 68, 154, 195, 283, 153, 194, 216, 269, 151, 148, 282, 149, 192, 150, 110, 92, 93, 151, 111, 278, 65, 191, 150, 62, 190, 189, 107, 82, 188, 185, 67, 280, 68, 184, 180, 179, 151, 148, 262, 149, 217, 150, 178, 177, 176, 175, 65, 173, 257, 244, 62, 234, 221, 260, 81, 259, 132, 67, 83, 68, 155, 266, 75, 69, 62, 4, 125, 141, 18, 136, 285, 67, 272, 68, 170, 79, 165, 70, 65, 21, 2, 1, 88, 249, 229, 112, 100, 6, 5, 0, 154, 0, 0, 120, 0, 118, 0, 0, 0, 0, 0, 0, 0, 0, 62, 65, 0, 0, 0, 0, 0, 67, 0, 68, 0, 0, 0, 0, 0, 65, 0, 225, 0, 230, 215, 0, 0, 0, 0, 55, 0, 0, 25, 30, 29, 31, 35, 27, 33, 37, 40, 43, 44, 45, 41, 26, 36, 39, 42, 34, 38, 32, 28, 0, 0, 55, 92, 93, 268, 65, 152, 156, 157, 126, 57, 63, 127, 22, 46, 47, 23, 48, 0, 56, 59, 60, 61, 64, 101, 105, 102, 66, 152, 156, 157, 55, 243, 0, 263, 24, 57, 63, 49, 58, 253, 162, 264, 62, 0, 56, 59, 60, 61, 64, 67, 284, 68, 66, 101, 105, 102, 55, 267, 50, 51, 247, 0, 0, 153, 58, 57, 63, 151, 148, 202, 149, 0, 150, 52, 56, 59, 60, 61, 64, 101, 97, 102, 66, 101, 105, 102, 0, 0, 55, 0, 0, 57, 63, 0, 58, 0, 0, 65, 62, 0, 56, 59, 60, 61, 64, 67, 0, 68, 66, 0, 0, 0, 0, 86, 0, 55, 152, 156, 157, 155, 58, 84, 85, 57, 63, 152, 156, 157, 0, 55, 139, 0, 56, 59, 60, 61, 64, 0, 0, 0, 66, 270, 181, 182, 152, 156, 157, 62, 0, 154, 57, 63, 58, 65, 67, 0, 68, 0, 0, 56, 59, 60, 61, 64, 57, 63, 0, 66, 0, 55, 0, 0, 0, 56, 59, 60, 61, 64, 0, 58, 62, 66, 0, 123, 0, 236, 0, 67, 0, 68, 0, 0, 0, 58, 138, 186, 181, 182, 0, 0, 0, 0, 65, 62, 57, 63, 0, 0, 0, 0, 67, 0, 68, 56, 59, 60, 61, 64, 62, 76, 0, 66, 0, 0, 0, 67, 131, 68, 0, 0, 0, 0, 0, 58, 71, 65, 0, 153, 0, 0, 245, 151, 148, 0, 149, 62, 150, 0, 0, 0, 0, 0, 67, 0, 68, 0, 0, 201, 65, 0, 62, 0, 55, 0, 0, 0, 0, 67, 0, 68, 0, 0, 153, 65, 0, 0, 151, 148, 0, 149, 0, 150, 0, 0, 200, 153, 0, 86, 0, 151, 148, 0, 149, 155, 150, 84, 85, 57, 63, 0, 65, 0, 0, 0, 0, 0, 56, 59, 60, 61, 64, 0, 153, 0, 66, 65, 151, 148, 55, 149, 0, 150, 0, 154, 0, 0, 58, 213, 155, 0, 152, 156, 157, 0, 0, 0, 0, 0, 0, 0, 153, 155, 0, 86, 151, 148, 183, 149, 169, 150, 122, 0, 85, 57, 63, 0, 0, 0, 154, 0, 103, 0, 56, 59, 60, 61, 64, 55, 155, 242, 66, 154, 0, 0, 250, 0, 153, 0, 258, 0, 151, 148, 58, 149, 0, 150, 153, 0, 0, 0, 151, 148, 274, 149, 109, 150, 155, 0, 154, 0, 55, 0, 57, 63, 0, 0, 0, 0, 0, 0, 0, 56, 59, 60, 61, 64, 0, 0, 0, 66, 0, 0, 0, 55, 91, 0, 154, 0, 0, 115, 0, 58, 155, 0, 0, 57, 63, 0, 55, 0, 0, 0, 155, 0, 56, 59, 60, 61, 64, 0, 0, 0, 66, 0, 0, 0, 0, 0, 57, 63, 0, 168, 154, 197, 58, 55, 0, 56, 59, 60, 61, 64, 154, 57, 63, 66, 0, 174, 0, 0, 55, 0, 56, 59, 60, 61, 64, 58, 0, 153, 66, 0, 0, 151, 148, 0, 149, 0, 150, 0, 57, 63, 58, 0, 152, 156, 157, 0, 0, 56, 59, 60, 61, 64, 164, 57, 63, 66, 0, 0, 0, 0, 0, 0, 56, 59, 60, 61, 64, 58, 0, 0, 66, 147, 0, 0, 0, 0, 0, 152, 156, 157, 153, 0, 58, 155, 151, 148, 0, 149, 0, 150, 152, 156, 157, 0, 0, 0, 0, 0, 0, 153, 0, 0, 0, 151, 148, 0, 149, 0, 150, 0, 226, 0, 0, 154, 0, 0, 0, 152, 156, 157, 98, 0, 0, 251, 0, 0, 0, 101, 105, 102, 110, 92, 93, 0, 111, 124, 155, 101, 105, 102, 110, 92, 93, 0, 111, 152, 156, 157, 0, 0, 0, 0, 0, 104, 106, 155, 0, 0, 0, 0, 121, 0, 0, 0, 0, 0, 154, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 156, 157, 0, 154, 0, 0, 0, 0, 0, 152, 156, 157, 0, 0, 0, 0, 0, 0, 0, 187, 0, 0, 0, 0, 281, 0, 0, 54, 0, 0, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 77, 78, 0, 0, 80, 87, 89, 0, 0, 96, 0, 0, 0, 116, 117, 119, 0, 0, 0, 0, 0, 133, 134, 0, 135, 140, 143, 0, 144, 145, 146, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 158, 159, 160, 161, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 156, 157, 224, 0, 228, 0, 233, 0, 0, 237, 0, 239, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 156, 157, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 0, 0, 0, 0, 0, 0, 152, 156, 157, 0, 0, 0, 0, 0, 0, 220, 0, 222, 223, 0, 227, 0, 232, 0, 235, 0, 238, 240, 0, 0, 0, 0, 252, 0, 0, 0, 0, 0, 0, 0, 140, 143, 0, 0, 265 }; int yypact[]={ -208, -1000, -239, -1000, -1000, -10, 31, 438, 169, -1000, 495, -309, -312, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, 168, 480, 438, -1000, -1000, 103, 277, 438, -256, -268, 71, 75, 591, -216, 438, 333, 438, -270, 581, -3, -258, 132, 438, 438, -1000, 438, 144, 438, -1000, 438, 438, 438, -1000, 794, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, 438, 438, 438, 438, -1000, -6, -1000, 775, -286, -1000, -1000, -1000, 722, 609, -316, 619, 119, -227, -1000, -1000, -1000, -1000, 619, 117, 619, 116, 115, -1000, -1000, 114, 107, 619, 106, -1000, -1000, -1000, -1000, -1000, -209, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, 573, 619, 105, 619, -1000, 101, 184, 100, 97, 96, 93, 84, -279, 77, 74, 65, 453, 619, 619, 619, 56, -1000, -1000, -1000, 619, 47, -1000, 619, 545, 518, 296, -1000, 438, 438, 438, 438, 438, 438, 438, 438, 438, 438, 505, 110, -1000, -1000, -1000, -1000, -1000, 112, -1000, -1000, -1000, -1000, 69, -1000, -1000, 438, 127, 438, 45, -152, 45, -236, 45, 126, 415, 75, 438, 15, 124, 470, -241, -228, -11, -273, -277, 123, 131, 129, -231, 113, 144, 438, -1000, -1000, 438, 91, 91, -1000, -1000, -1000, 110, -29, -29, -1000, -1000, -1000, 167, -1000, -1000, -286, -1000, -316, 619, -1000, 619, 619, -1000, -1000, -1000, 619, -1000, -1000, -1000, -1000, 619, -1000, -1000, 82, -1000, -1000, 619, -1000, 619, 130, -1000, -1000, 39, -1000, -1000, -1000, -1000, -1000, -1000, -1000, 619, -1000, 438, -1000, -1000, 38, -1000, 382, -255, -1000, 34, -1000, -1000, -7, -1000, -1000, -1000, -1000, 94, -247, 108, -227, 85, 78, -182, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000 }; int yypgo[]={ 0, 204, 203, 853, 142, 44, 202, 201, 59, 200, 665, 170, 174, 454, 934, 199, 197, 196, 181, 195, 193, 76, 192, 191, 190, 188, 186, 185, 183, 110, 54, 105, 112 }; int yyr1[]={ 0, 16, 16, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 1, 1, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 22, 22, 22, 29, 24, 24, 24, 30, 3, 3, 5, 5, 5, 6, 6, 6, 4, 4, 7, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 27, 27, 31, 31, 31, 28, 28, 32, 15, 15, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 2, 2, 2, 2, 2, 2, 23, 20, 21, 25, 26 }; int yyr2[]={ 0, 2, 3, 2, 4, 5, 5, 7, 9, 9, 13, 7, 5, 7, 9, 9, 11, 9, 5, 7, 9, 5, 11, 1, 5, 3, 5, 5, 5, 9, 9, 5, 9, 9, 9, 5, 9, 5, 5, 9, 9, 9, 5, 5, 9, 9, 9, 9, 5, 9, 5, 3, 5, 9, 9, 13, 9, 13, 9, 9, 9, 9, 9, 9, 9, 9, 15, 13, 9, 13, 13, 9, 13, 5, 5, 3, 5, 4, 4, 2, 0, 2, 6, 3, 0, 2, 6, 3, 2, 2, 3, 3, 3, 7, 9, 7, 2, 2, 3, 3, 2, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 2, 6, 3, 3, 3, 2, 6, 3, 2, 2, 7, 3, 3, 2, 2, 3, 3, 3, 3, 3, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 5, 5, 5, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1 }; int yychk[]={ -1000, -16, -17, 256, -18, -1, -2, 309, 310, 311, 312, 292, 316, 300, 304, 301, 302, 303, -18, 256, 10, -19, 293, 296, 315, 258, 271, 263, 278, 260, 259, 261, 277, 264, 275, 262, 272, 265, 276, 273, 266, 270, 274, 267, 268, 269, 294, 295, 297, 318, 298, 299, 313, 58, -14, 256, 300, 291, 320, 301, 302, 303, 36, 292, 304, 91, 308, 43, 45, 10, -20, 10, -14, 314, 314, 10, 10, -14, -14, -23, -14, -11, 40, -12, 289, 290, 281, -14, -11, -14, 280, -10, 283, 284, 280, 283, -14, 280, -3, -5, -6, 279, 281, 40, -3, 280, -3, -4, -8, -10, 282, 286, -7, 282, 285, -10, -14, -14, -12, -14, -11, -3, 40, -13, 287, -4, 282, 285, 40, -5, 288, -13, 40, -14, -14, -14, -27, -31, 321, 257, -14, -28, -32, -14, -14, -14, -14, 10, 43, 45, 47, 42, 305, 38, 124, 94, 306, 307, -14, -14, -14, -14, 317, 10, 10, -22, -29, 292, 10, 10, -24, -30, 317, 44, -10, 44, 44, 44, 44, 44, 44, 283, 284, 44, 44, 44, 282, -14, 44, 44, 44, 44, 44, 286, 44, 44, 44, 281, 44, 44, 10, 10, 44, -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, 93, -21, -21, 10, 44, 10, 44, -14, 41, -14, -14, -3, -8, -10, -14, -3, -9, -8, 283, -14, -3, 41, -14, 41, -3, -14, -3, -14, 40, -13, 287, 41, 41, 280, -4, 280, -15, -13, -10, -14, 321, 40, 283, 285, 41, -13, 40, 40, 280, 41, -31, -32, -14, 10, -29, -30, 41, 282, 44, -25, 44, 281, 281, 44, 10, 41, 280, 39, -10, 41, 41, -5, -26 }; int yydef[]={ -2, -2, -2, 2, 3, 0, 0, 0, 0, 153, 0, 146, 0, 147, 148, 149, 150, 151, 4, 5, 6, 0, 0, 0, 152, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 0, 0, 0, 0, 0, 0, 75, 0, 0, 0, 79, 0, 0, 0, 24, 0, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 0, 0, 0, 0, 12, 0, 18, 0, 80, 21, 7, 13, 0, 0, 84, 26, 0, 0, 107, 108, 109, 110, 27, 0, 28, 0, 0, 105, 106, 0, 0, 31, 91, 35, 88, 89, 90, 92, 0, 37, 91, 38, 42, 96, 97, 101, 102, 43, 98, 99, 100, 0, 48, 0, 50, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 73, 74, 76, 77, 111, 113, 114, 115, 78, 116, 118, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 143, 144, 145, 154, 154, 19, 0, 81, 83, 14, 15, 0, 85, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 9, 0, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 0, 17, 20, 0, 22, 0, 45, 46, 47, 29, 33, 40, 41, 30, 34, 39, 103, 104, 32, 36, 93, 0, 95, 44, 49, 53, 54, 0, 56, 59, 0, 121, 58, 63, 60, 61, 62, 64, 119, 120, 0, 65, 155, 0, 68, 0, 0, 71, 0, 112, 117, 0, 16, 82, 86, 94, 0, 0, 0, 0, 0, 0, 0, 10, 55, 57, 156, 67, 69, 70, 72, 66 }; typedef struct { char *t_name; int t_val; } yytoktype; #ifndef YYDEBUG # define YYDEBUG 0 /* don't allow debugging */ #endif #if YYDEBUG yytoktype yytoks[] = { "STRING", 257, "NOOPERAND", 258, "ARITHC", 259, "ADD", 260, "LOGICAL", 261, "BIT", 262, "CALL", 263, "INCDEC", 264, "DJNZ", 265, "EX", 266, "IM", 267, "PHASE", 268, "DEPHASE", 269, "IN", 270, "JP", 271, "JR", 272, "LD", 273, "OUT", 274, "PUSHPOP", 275, "RET", 276, "SHIFT", 277, "RST", 278, "REGNAME", 279, "ACC", 280, "C", 281, "RP", 282, "HL", 283, "INDEX", 284, "AF", 285, "SP", 286, "MISCREG", 287, "F", 288, "COND", 289, "SPCOND", 290, "NUMBER", 291, "UNDECLARED", 292, "END", 293, "ORG", 294, "DEFB", 295, "DEFS", 296, "DEFW", 297, "EQU", 298, "DEFL", 299, "LABEL", 300, "EQUATED", 301, "WASEQUATED", 302, "DEFLED", 303, "MULTDEF", 304, "MOD", 305, "SHL", 306, "SHR", 307, "NOT", 308, "IF", 309, "ENDIF", 310, "ARGPSEUDO", 311, "LIST", 312, "MINMAX", 313, "MACRO", 314, "MNAME", 315, "OLDMNAME", 316, "ARG", 317, "ENDM", 318, "MPARM", 319, "ONECHAR", 320, "TWOCHAR", 321, "|", 124, "^", 94, "&", 38, "+", 43, "-", 45, "*", 42, "/", 47, "UNARY", 322, "-unknown-", -1 /* ends search */ }; char * yyreds[] = { "-no such reduction-", "program : statements", "program : error", "statements : statement", "statements : statements statement", "statements : statements error", "statement : label.part '\n'", "statement : label.part operation '\n'", "statement : symbol EQU expression '\n'", "statement : symbol DEFL expression '\n'", "statement : symbol MINMAX expression ',' expression '\n'", "statement : IF expression '\n'", "statement : ENDIF '\n'", "statement : label.part END '\n'", "statement : label.part END expression '\n'", "statement : label.part DEFS expression '\n'", "statement : ARGPSEUDO arg_on ARG arg_off '\n'", "statement : ARGPSEUDO arg_on '\n' arg_off", "statement : LIST '\n'", "statement : LIST expression '\n'", "statement : UNDECLARED MACRO parm.list '\n'", "statement : OLDMNAME MACRO", "statement : label.part MNAME al arg.list '\n'", "label.part : /* empty */", "label.part : symbol ':'", "operation : NOOPERAND", "operation : JP expression", "operation : CALL expression", "operation : RST expression", "operation : ADD ACC ',' expression", "operation : ARITHC ACC ',' expression", "operation : LOGICAL expression", "operation : LOGICAL ACC ',' expression", "operation : ADD ACC ',' reg", "operation : ARITHC ACC ',' reg", "operation : LOGICAL reg", "operation : LOGICAL ACC ',' reg", "operation : SHIFT reg", "operation : INCDEC reg", "operation : ARITHC HL ',' bcdehlsp", "operation : ADD mar ',' bcdesp", "operation : ADD mar ',' mar", "operation : INCDEC evenreg", "operation : PUSHPOP pushable", "operation : BIT expression ',' reg", "operation : JP condition ',' expression", "operation : JP '(' mar ')'", "operation : CALL condition ',' expression", "operation : JR expression", "operation : JR spcondition ',' expression", "operation : DJNZ expression", "operation : RET", "operation : RET condition", "operation : LD reg ',' reg", "operation : LD reg ',' expression", "operation : LD reg ',' '(' RP ')'", "operation : LD reg ',' parenexpr", "operation : LD '(' RP ')' ',' ACC", "operation : LD parenexpr ',' ACC", "operation : LD reg ',' MISCREG", "operation : LD MISCREG ',' ACC", "operation : LD evenreg ',' lxexpression", "operation : LD evenreg ',' parenexpr", "operation : LD parenexpr ',' evenreg", "operation : LD evenreg ',' mar", "operation : EX RP ',' HL", "operation : EX AF ',' AF setqf '\'' clrqf", "operation : EX '(' SP ')' ',' mar", "operation : IN realreg ',' parenexpr", "operation : IN realreg ',' '(' C ')'", "operation : IN F ',' '(' C ')'", "operation : OUT parenexpr ',' ACC", "operation : OUT '(' C ')' ',' realreg", "operation : IM expression", "operation : PHASE expression", "operation : DEPHASE", "operation : ORG expression", "operation : DEFB db.list", "operation : DEFW dw.list", "operation : ENDM", "parm.list : /* empty */", "parm.list : parm.element", "parm.list : parm.list ',' parm.element", "parm.element : UNDECLARED", "arg.list : /* empty */", "arg.list : arg.element", "arg.list : arg.list ',' arg.element", "arg.element : ARG", "reg : realreg", "reg : mem", "realreg : REGNAME", "realreg : ACC", "realreg : C", "mem : '(' HL ')'", "mem : '(' INDEX expression ')'", "mem : '(' INDEX ')'", "evenreg : bcdesp", "evenreg : mar", "pushable : RP", "pushable : AF", "pushable : mar", "bcdesp : RP", "bcdesp : SP", "bcdehlsp : bcdesp", "bcdehlsp : HL", "mar : HL", "mar : INDEX", "condition : spcondition", "condition : COND", "spcondition : SPCOND", "spcondition : C", "db.list : db.list.element", "db.list : db.list ',' db.list.element", "db.list.element : TWOCHAR", "db.list.element : STRING", "db.list.element : expression", "dw.list : dw.list.element", "dw.list : dw.list ',' dw.list.element", "dw.list.element : expression", "lxexpression : expression", "lxexpression : TWOCHAR", "parenexpr : '(' expression ')'", "expression : error", "expression : LABEL", "expression : NUMBER", "expression : ONECHAR", "expression : EQUATED", "expression : WASEQUATED", "expression : DEFLED", "expression : '$'", "expression : UNDECLARED", "expression : MULTDEF", "expression : expression '+' expression", "expression : expression '-' expression", "expression : expression '/' expression", "expression : expression '*' expression", "expression : expression MOD expression", "expression : expression '&' expression", "expression : expression '|' expression", "expression : expression '^' expression", "expression : expression SHL expression", "expression : expression SHR expression", "expression : '[' expression ']'", "expression : NOT expression", "expression : '+' expression", "expression : '-' expression", "symbol : UNDECLARED", "symbol : LABEL", "symbol : MULTDEF", "symbol : EQUATED", "symbol : WASEQUATED", "symbol : DEFLED", "al : /* empty */", "arg_on : /* empty */", "arg_off : /* empty */", "setqf : /* empty */", "clrqf : /* empty */", }; #endif /* YYDEBUG */ #line 1 "/usr/lib/yaccpar" /* @(#)yaccpar 1.10 89/04/04 SMI; from S5R3 1.10 */ /* ** Skeleton parser driver for yacc output */ /* ** yacc user known macros and defines */ #define YYERROR goto yyerrlab #define YYACCEPT { free(yys); free(yyv); return(0); } #define YYABORT { free(yys); free(yyv); return(1); } #define YYBACKUP( newtoken, newvalue )\ {\ if ( yychar >= 0 || ( yyr2[ yytmp ] >> 1 ) != 1 )\ {\ yyerror( "syntax error - cannot backup" );\ goto yyerrlab;\ }\ yychar = newtoken;\ yystate = *yyps;\ yylval = newvalue;\ goto yynewstate;\ } #define YYRECOVERING() (!!yyerrflag) #ifndef YYDEBUG # define YYDEBUG 1 /* make debugging available */ #endif /* ** user known globals */ int yydebug; /* set to 1 to get debugging */ /* ** driver internal defines */ #define YYFLAG (-1000) /* ** static variables used by the parser */ static YYSTYPE *yyv; /* value stack */ static int *yys; /* state stack */ static YYSTYPE *yypv; /* top of value stack */ static int *yyps; /* top of state stack */ static int yystate; /* current state */ static int yytmp; /* extra var (lasts between blocks) */ int yynerrs; /* number of errors */ int yyerrflag; /* error recovery flag */ int yychar; /* current input token number */ /* ** yyparse - return 0 if worked, 1 if syntax error not recovered from */ int yyparse(void) { register YYSTYPE *yypvt; /* top of value stack for $vars */ unsigned yymaxdepth = YYMAXDEPTH; /* ** Initialize externals - yyparse may be called more than once */ yyv = (YYSTYPE*)malloc(yymaxdepth*sizeof(YYSTYPE)); yys = (int*)malloc(yymaxdepth*sizeof(int)); if (!yyv || !yys) { yyerror( "out of memory" ); return(1); } yypv = &yyv[-1]; yyps = &yys[-1]; yystate = 0; yytmp = 0; yynerrs = 0; yyerrflag = 0; yychar = -1; goto yystack; { register YYSTYPE *yy_pv; /* top of value stack */ register int *yy_ps; /* top of state stack */ register int yy_state; /* current state */ register int yy_n; /* internal state number info */ /* ** get globals into registers. ** branch to here only if YYBACKUP was called. */ yynewstate: yy_pv = yypv; yy_ps = yyps; yy_state = yystate; goto yy_newstate; /* ** get globals into registers. ** either we just started, or we just finished a reduction */ yystack: yy_pv = yypv; yy_ps = yyps; yy_state = yystate; /* ** top of for (;;) loop while no reductions done */ yy_stack: /* ** put a state and value onto the stacks */ #if YYDEBUG /* ** if debugging, look up token value in list of value vs. ** name pairs. 0 and negative (-1) are special values. ** Note: linear search is used since time is not a real ** consideration while debugging. */ if ( yydebug ) { register int yy_i; (void)printf( "State %d, token ", yy_state ); if ( yychar == 0 ) (void)printf( "end-of-file\n" ); else if ( yychar < 0 ) (void)printf( "-none-\n" ); else { for ( yy_i = 0; yytoks[yy_i].t_val >= 0; yy_i++ ) { if ( yytoks[yy_i].t_val == yychar ) break; } (void)printf( "%s\n", yytoks[yy_i].t_name ); } } #endif /* YYDEBUG */ if ( ++yy_ps >= &yys[ yymaxdepth ] ) /* room on stack? */ { /* ** reallocate and recover. Note that pointers ** have to be reset, or bad things will happen */ int yyps_index = (yy_ps - yys); int yypv_index = (yy_pv - yyv); int yypvt_index = (yypvt - yyv); yymaxdepth += YYMAXDEPTH; yyv = (YYSTYPE*)realloc((char*)yyv, yymaxdepth * sizeof(YYSTYPE)); yys = (int*)realloc((char*)yys, yymaxdepth * sizeof(int)); if (!yyv || !yys) { yyerror( "yacc stack overflow" ); return(1); } yy_ps = yys + yyps_index; yy_pv = yyv + yypv_index; yypvt = yyv + yypvt_index; } *yy_ps = yy_state; *++yy_pv = yyval; /* ** we have a new state - find out what to do */ yy_newstate: if ( ( yy_n = yypact[ yy_state ] ) <= YYFLAG ) goto yydefault; /* simple state */ #if YYDEBUG /* ** if debugging, need to mark whether new token grabbed */ yytmp = yychar < 0; #endif if ( ( yychar < 0 ) && ( ( yychar = yylex() ) < 0 ) ) yychar = 0; /* reached EOF */ #if YYDEBUG if ( yydebug && yytmp ) { register int yy_i; (void)printf( "Received token " ); if ( yychar == 0 ) (void)printf( "end-of-file\n" ); else if ( yychar < 0 ) (void)printf( "-none-\n" ); else { for ( yy_i = 0; yytoks[yy_i].t_val >= 0; yy_i++ ) { if ( yytoks[yy_i].t_val == yychar ) break; } (void)printf( "%s\n", yytoks[yy_i].t_name ); } } #endif /* YYDEBUG */ if ( ( ( yy_n += yychar ) < 0 ) || ( yy_n >= YYLAST ) ) goto yydefault; if ( yychk[ yy_n = yyact[ yy_n ] ] == yychar ) /*valid shift*/ { yychar = -1; yyval = yylval; yy_state = yy_n; if ( yyerrflag > 0 ) yyerrflag--; goto yy_stack; } yydefault: if ( ( yy_n = yydef[ yy_state ] ) == -2 ) { #if YYDEBUG yytmp = yychar < 0; #endif if ( ( yychar < 0 ) && ( ( yychar = yylex() ) < 0 ) ) yychar = 0; /* reached EOF */ #if YYDEBUG if ( yydebug && yytmp ) { register int yy_i; (void)printf( "Received token " ); if ( yychar == 0 ) (void)printf( "end-of-file\n" ); else if ( yychar < 0 ) (void)printf( "-none-\n" ); else { for ( yy_i = 0; yytoks[yy_i].t_val >= 0; yy_i++ ) { if ( yytoks[yy_i].t_val == yychar ) { break; } } (void)printf( "%s\n", yytoks[yy_i].t_name ); } } #endif /* YYDEBUG */ /* ** look through exception table */ { register int *yyxi = yyexca; while ( ( *yyxi != -1 ) || ( yyxi[1] != yy_state ) ) { yyxi += 2; } while ( ( *(yyxi += 2) >= 0 ) && ( *yyxi != yychar ) ) ; if ( ( yy_n = yyxi[1] ) < 0 ) YYACCEPT; } } /* ** check for syntax error */ if ( yy_n == 0 ) /* have an error */ { /* no worry about speed here! */ switch ( yyerrflag ) { case 0: /* new error */ yyerror( "syntax error" ); goto skip_init; yyerrlab: /* ** get globals into registers. ** we have a user generated syntax type error */ yy_pv = yypv; yy_ps = yyps; yy_state = yystate; yynerrs++; skip_init: case 1: case 2: /* incompletely recovered error */ /* try again... */ yyerrflag = 3; /* ** find state where "error" is a legal ** shift action */ while ( yy_ps >= yys ) { yy_n = yypact[ *yy_ps ] + YYERRCODE; if ( yy_n >= 0 && yy_n < YYLAST && yychk[yyact[yy_n]] == YYERRCODE) { /* ** simulate shift of "error" */ yy_state = yyact[ yy_n ]; goto yy_stack; } /* ** current state has no shift on ** "error", pop stack */ #if YYDEBUG # define _POP_ "Error recovery pops state %d, uncovers state %d\n" if ( yydebug ) (void)printf( _POP_, *yy_ps, yy_ps[-1] ); # undef _POP_ #endif yy_ps--; yy_pv--; } /* ** there is no state on stack with "error" as ** a valid shift. give up. */ YYABORT; case 3: /* no shift yet; eat a token */ #if YYDEBUG /* ** if debugging, look up token in list of ** pairs. 0 and negative shouldn't occur, ** but since timing doesn't matter when ** debugging, it doesn't hurt to leave the ** tests here. */ if ( yydebug ) { register int yy_i; (void)printf( "Error recovery discards " ); if ( yychar == 0 ) (void)printf( "token end-of-file\n" ); else if ( yychar < 0 ) (void)printf( "token -none-\n" ); else { for ( yy_i = 0; yytoks[yy_i].t_val >= 0; yy_i++ ) { if ( yytoks[yy_i].t_val == yychar ) { break; } } (void)printf( "token %s\n", yytoks[yy_i].t_name ); } } #endif /* YYDEBUG */ if ( yychar == 0 ) /* reached EOF. quit */ YYABORT; yychar = -1; goto yy_newstate; } }/* end if ( yy_n == 0 ) */ /* ** reduction by production yy_n ** put stack tops, etc. so things right after switch */ #if YYDEBUG /* ** if debugging, print the string that is the user's ** specification of the reduction which is just about ** to be done. */ if ( yydebug ) (void)printf( "Reduce by (%d) \"%s\"\n", yy_n, yyreds[ yy_n ] ); #endif yytmp = yy_n; /* value to switch over */ yypvt = yy_pv; /* $vars top of value stack */ /* ** Look in goto table for next state ** Sorry about using yy_state here as temporary ** register variable, but why not, if it works... ** If yyr2[ yy_n ] doesn't have the low order bit ** set, then there is no action to be done for ** this reduction. So, no saving & unsaving of ** registers done. The only difference between the ** code just after the if and the body of the if is ** the goto yy_stack in the body. This way the test ** can be made before the choice of what to do is needed. */ { /* length of production doubled with extra bit */ register int yy_len = yyr2[ yy_n ]; if ( !( yy_len & 01 ) ) { yy_len >>= 1; yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */ yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] + *( yy_ps -= yy_len ) + 1; if ( yy_state >= YYLAST || yychk[ yy_state = yyact[ yy_state ] ] != -yy_n ) { yy_state = yyact[ yypgo[ yy_n ] ]; } goto yy_stack; } yy_len >>= 1; yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */ yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] + *( yy_ps -= yy_len ) + 1; if ( yy_state >= YYLAST || yychk[ yy_state = yyact[ yy_state ] ] != -yy_n ) { yy_state = yyact[ yypgo[ yy_n ] ]; } } /* save until reenter driver code */ yystate = yy_state; yyps = yy_ps; yypv = yy_pv; } /* ** code supplied by user is placed in this switch */ switch( yytmp ) { case 2: # line 768 "zmac.y" { error("file bad"); } break; case 5: # line 777 "zmac.y" { fprintf(stderr,"statement error\n"); err[fflag]++; quoteflag = 0; while(yychar != '\n' && yychar != '\0') yychar = yylex(); list(dollarsign); yyclearin;yyerrok; } break; case 6: # line 789 "zmac.y" { if (yypvt[-1].itemptr) list(dollarsign); else list1(); } break; case 7: # line 794 "zmac.y" { list(dollarsign); } break; case 8: # line 798 "zmac.y" { switch(yypvt[-3].itemptr->i_token) { case UNDECLARED: case WASEQUATED: yypvt[-3].itemptr->i_token = EQUATED; yypvt[-3].itemptr->i_value = yypvt[-1].ival; break; default: err[mflag]++; yypvt[-3].itemptr->i_token = MULTDEF; } list(yypvt[-1].ival); } break; case 9: # line 811 "zmac.y" { switch(yypvt[-3].itemptr->i_token) { case UNDECLARED: case DEFLED: yypvt[-3].itemptr->i_token = DEFLED; yypvt[-3].itemptr->i_value = yypvt[-1].ival; break; default: err[mflag]++; yypvt[-3].itemptr->i_token = MULTDEF; } list(yypvt[-1].ival); } break; case 10: # line 824 "zmac.y" { switch (yypvt[-5].itemptr->i_token) { case UNDECLARED: case DEFLED: yypvt[-5].itemptr->i_token = DEFLED; if (yypvt[-4].itemptr->i_value) /* max */ list(yypvt[-5].itemptr->i_value = (yypvt[-3].ival > yypvt[-1].ival? yypvt[-3].ival:yypvt[-1].ival)); else list(yypvt[-5].itemptr->i_value = (yypvt[-3].ival < yypvt[-1].ival? yypvt[-3].ival:yypvt[-1].ival)); break; default: err[mflag]++; yypvt[-5].itemptr->i_token = MULTDEF; list(yypvt[-5].itemptr->i_value); } } break; case 11: # line 839 "zmac.y" { if (ifptr >= ifstmax) error("Too many ifs"); else { if (pass2) { *++ifptr = *expifp++; if (*ifptr != !(yypv[2].ival)) err[pflag]++; } else { if (expifp >= expifmax) error("Too many ifs!"); *expifp++ = !(yypv[2].ival); *++ifptr = !(yypv[2].ival); } } saveopt = fopt; fopt = 1; list(yypv[2].ival); fopt = saveopt; } break; case 12: # line 859 "zmac.y" { if (ifptr == ifstack) err[bflag]++; else --ifptr; list1(); } break; case 13: # line 865 "zmac.y" { list(dollarsign); peekc = 0; } break; case 14: # line 870 "zmac.y" { xeq_flag++; xeq = yypvt[-1].ival; list(yypvt[-1].ival); peekc = 0; } break; case 15: # line 877 "zmac.y" { if (yypvt[-1].ival < 0) err[vflag]++; list(dollarsign); if (yypvt[-1].ival) { flushbin(); dollarsign += yypvt[-1].ival; olddollar = dollarsign; } } break; case 16: # line 887 "zmac.y" { list1(); switch (yypvt[-4].itemptr->i_value) { case 0: /* title */ lineptr = linebuf; cp = tempbuf; title = titlespace; while ((*title++ = *cp++) && (title < &titlespace[TITLELEN])); *title = 0; title = titlespace; break; case 1: /* rsym */ if (pass2) break; insymtab(tempbuf); break; case 2: /* wsym */ writesyms = malloc(strlen(tempbuf)+1); strcpy(writesyms, tempbuf); break; case 3: /* include file */ next_source(tempbuf) ; break ; } } break; case 17: # line 915 "zmac.y" { fprintf(stderr,"ARGPSEUDO error\n"); err[fflag]++; list(dollarsign); } break; case 18: # line 921 "zmac.y" { if (yypvt[-1].itemptr != (struct item *) -1) yypvt[-0].ival = 1; goto dolopt; } break; case 19: # line 925 "zmac.y" { dolopt: linecnt++; if (pass2) { lineptr = linebuf; switch (yypvt[-2].itemptr->i_value) { case 0: /* list */ if (yypvt[-1].ival < 0) lstoff = 1; if (yypvt[-1].ival > 0) lstoff = 0; break; case 1: /* eject */ if (yypvt[-1].ival) eject(); break; case 2: /* space */ if ((line + yypvt[-1].ival) > 60) eject(); else space(yypvt[-1].ival); break; case 3: /* elist */ eopt = edef; if (yypvt[-1].ival < 0) eopt = 0; if (yypvt[-1].ival > 0) eopt = 1; break; case 4: /* fopt */ fopt = fdef; if (yypvt[-1].ival < 0) fopt = 0; if (yypvt[-1].ival > 0) fopt = 1; break; case 5: /* gopt */ gopt = gdef; if (yypvt[-1].ival < 0) gopt = 1; if (yypvt[-1].ival > 0) gopt = 0; break; case 6: /* mopt */ mopt = mdef; if (yypvt[-1].ival < 0) mopt = 0; if (yypvt[-1].ival > 0) mopt = 1; } } } break; case 20: # line 971 "zmac.y" { yypvt[-3].itemptr->i_token = MNAME; yypvt[-3].itemptr->i_value = mfptr; mfseek(mfile, (long)mfptr, 0); list1(); mlex() ; parm_number = 0; } break; case 21: # line 980 "zmac.y" { yypvt[-1].itemptr->i_token = MNAME; while (yychar != ENDM && yychar) { while (yychar != '\n' && yychar) yychar = yylex(); list1(); yychar = yylex(); } while (yychar != '\n' && yychar) yychar = yylex(); list1(); yychar = yylex(); } break; case 22: # line 993 "zmac.y" { expand: yypvt[-3].itemptr->i_uses++ ; arg_flag = 0; parm_number = 0; list(dollarsign); expptr++; est = est2; est[FLOC] = floc; est[TEMPNUM] = (char *)exp_number++; floc = (char *)(yypvt[-3].itemptr->i_value); mfseek(mfile, (long)floc, 0); } break; case 23: # line 1011 "zmac.y" { yyval.itemptr = NULL; } break; case 24: # line 1013 "zmac.y" { switch(yypvt[-1].itemptr->i_token) { case UNDECLARED: if (pass2) err[pflag]++; else { yypvt[-1].itemptr->i_token = LABEL; yypvt[-1].itemptr->i_value = dollarsign; } break; case LABEL: if (!pass2) { yypvt[-1].itemptr->i_token = MULTDEF; err[mflag]++; } else if (yypvt[-1].itemptr->i_value != dollarsign) err[pflag]++; break; default: err[mflag]++; yypvt[-1].itemptr->i_token = MULTDEF; } } break; case 25: # line 1040 "zmac.y" { emit1(yypvt[-0].itemptr->i_value, 0, 0, 1); } break; case 26: # line 1043 "zmac.y" { emit(3, 0303, yypvt[-0].ival, yypvt[-0].ival >> 8); } break; case 27: # line 1046 "zmac.y" { emit(3, 0315, yypvt[-0].ival, yypvt[-0].ival >> 8); } break; case 28: # line 1049 "zmac.y" { if (yypvt[-0].ival > 7 || yypvt[-0].ival < 0) err[vflag]++; emit(1, yypvt[-1].itemptr->i_value + ((yypvt[-0].ival & 7) << 3)); } break; case 29: # line 1055 "zmac.y" { emit1(0306, 0, yypvt[-0].ival, 3); } break; case 30: # line 1058 "zmac.y" { emit1(0306 + (yypvt[-3].itemptr->i_value << 3), 0, yypvt[-0].ival, 3); } break; case 31: # line 1061 "zmac.y" { emit1(0306 | (yypvt[-1].itemptr->i_value << 3), 0, yypvt[-0].ival, 3); } break; case 32: # line 1064 "zmac.y" { emit1(0306 | (yypvt[-3].itemptr->i_value << 3), 0, yypvt[-0].ival, 3); } break; case 33: # line 1067 "zmac.y" { emit1(0200 + (yypvt[-0].ival & 0377), yypvt[-0].ival, 0, 0); } break; case 34: # line 1070 "zmac.y" { emit1(0200 + (yypvt[-3].itemptr->i_value << 3) + (yypvt[-0].ival & 0377), yypvt[-0].ival, 0, 0); } break; case 35: # line 1073 "zmac.y" { emit1(0200 + (yypvt[-1].itemptr->i_value << 3) + (yypvt[-0].ival & 0377), yypvt[-0].ival, 0, 0); } break; case 36: # line 1076 "zmac.y" { emit1(0200 + (yypvt[-3].itemptr->i_value << 3) + (yypvt[-0].ival & 0377), yypvt[-0].ival, 0, 0); } break; case 37: # line 1079 "zmac.y" { emit1(0145400 + (yypvt[-1].itemptr->i_value << 3) + (yypvt[-0].ival & 0377), yypvt[-0].ival, 0, 0); } break; case 38: # line 1082 "zmac.y" { emit1(yypvt[-1].itemptr->i_value + ((yypvt[-0].ival & 0377) << 3) + 4, yypvt[-0].ival, 0, 0); } break; case 39: # line 1085 "zmac.y" { if (yypvt[-3].itemptr->i_value == 1) emit(2,0355,0112+yypvt[-0].ival); else emit(2,0355,0102+yypvt[-0].ival); } break; case 40: # line 1092 "zmac.y" { emitdad(yypvt[-2].ival,yypvt[-0].ival); } break; case 41: # line 1095 "zmac.y" { if (yypvt[-2].ival != yypvt[-0].ival) { fprintf(stderr,"ADD mar, mar error\n"); err[fflag]++; } emitdad(yypvt[-2].ival,yypvt[-0].ival); } break; case 42: # line 1104 "zmac.y" { emit1((yypvt[-1].itemptr->i_value << 3) + (yypvt[-0].ival & 0377) + 3, yypvt[-0].ival, 0, 1); } break; case 43: # line 1107 "zmac.y" { emit1(yypvt[-1].itemptr->i_value + (yypvt[-0].ival & 0377), yypvt[-0].ival, 0, 1); } break; case 44: # line 1110 "zmac.y" { if (yypvt[-2].ival < 0 || yypvt[-2].ival > 7) err[vflag]++; emit1(yypvt[-3].itemptr->i_value + ((yypvt[-2].ival & 7) << 3) + (yypvt[-0].ival & 0377), yypvt[-0].ival, 0, 0); } break; case 45: # line 1117 "zmac.y" { emit(3, 0302 + yypvt[-2].ival, yypvt[-0].ival, yypvt[-0].ival >> 8); } break; case 46: # line 1120 "zmac.y" { emit1(0351, yypvt[-1].ival, 0, 1); } break; case 47: # line 1123 "zmac.y" { emit(3, 0304 + yypvt[-2].ival, yypvt[-0].ival, yypvt[-0].ival >> 8); } break; case 48: # line 1126 "zmac.y" { emitjr(030,yypvt[-0].ival); } break; case 49: # line 1129 "zmac.y" { emitjr(yypvt[-3].itemptr->i_value + yypvt[-2].ival, yypvt[-0].ival); } break; case 50: # line 1132 "zmac.y" { emitjr(yypvt[-1].itemptr->i_value, yypvt[-0].ival); } break; case 51: # line 1135 "zmac.y" { emit(1, yypvt[-0].itemptr->i_value); } break; case 52: # line 1138 "zmac.y" { emit(1, 0300 + yypvt[-0].ival); } break; case 53: # line 1141 "zmac.y" { if ((yypvt[-2].ival & 0377) == 6 && (yypvt[-0].ival & 0377) == 6) { fprintf(stderr,"LD reg, reg error\n"); err[fflag]++; } emit1(0100 + ((yypvt[-2].ival & 7) << 3) + (yypvt[-0].ival & 7),yypvt[-2].ival | yypvt[-0].ival, 0, 0); } break; case 54: # line 1150 "zmac.y" { emit1(6 + ((yypvt[-2].ival & 0377) << 3), yypvt[-2].ival, yypvt[-0].ival, 2); } break; case 55: # line 1153 "zmac.y" { if (yypvt[-4].ival != 7) { fprintf(stderr,"LD reg, (RP) error\n"); err[fflag]++; } else emit(1, 012 + yypvt[-1].itemptr->i_value); } break; case 56: # line 1161 "zmac.y" { if (yypvt[-2].ival != 7) { fprintf(stderr,"LD reg, (expr) error\n"); err[fflag]++; } else emit(3, 072, yypvt[-0].ival, yypvt[-0].ival >> 8); } break; case 57: # line 1170 "zmac.y" { emit(1, 2 + yypvt[-3].itemptr->i_value); } break; case 58: # line 1173 "zmac.y" { emit(3, 062, yypvt[-2].ival, yypvt[-2].ival >> 8); } break; case 59: # line 1176 "zmac.y" { if (yypvt[-2].ival != 7) { fprintf(stderr,"LD reg, MISCREG error\n"); err[fflag]++; } else emit(2, 0355, 0127 + yypvt[-0].itemptr->i_value); } break; case 60: # line 1185 "zmac.y" { emit(2, 0355, 0107 + yypvt[-2].itemptr->i_value); } break; case 61: # line 1188 "zmac.y" { emit1(1 + (yypvt[-2].ival & 060), yypvt[-2].ival, yypvt[-0].ival, 5); } break; case 62: # line 1191 "zmac.y" { if ((yypvt[-2].ival & 060) == 040) emit1(052, yypvt[-2].ival, yypvt[-0].ival, 5); else emit(4, 0355, 0113 + yypvt[-2].ival, yypvt[-0].ival, yypvt[-0].ival >> 8); } break; case 63: # line 1199 "zmac.y" { if ((yypvt[-0].ival & 060) == 040) emit1(042, yypvt[-0].ival, yypvt[-2].ival, 5); else emit(4, 0355, 0103 + yypvt[-0].ival, yypvt[-2].ival, yypvt[-2].ival >> 8); } break; case 64: # line 1207 "zmac.y" { if (yypvt[-2].ival != 060) { fprintf(stderr,"LD evenreg error\n"); err[fflag]++; } else emit1(0371, yypvt[-0].ival, 0, 1); } break; case 65: # line 1217 "zmac.y" { if (yypvt[-2].itemptr->i_value != 020) { fprintf(stderr,"EX RP, HL error\n"); err[fflag]++; } else emit(1, 0353); } break; case 66: # line 1227 "zmac.y" { emit(1, 010); } break; case 67: # line 1230 "zmac.y" { emit1(0343, yypvt[-0].ival, 0, 1); } break; case 68: # line 1233 "zmac.y" { if (yypvt[-2].ival != 7) { fprintf(stderr,"IN reg, (expr) error\n"); err[fflag]++; } else { if (yypvt[-0].ival < 0 || yypvt[-0].ival > 255) err[vflag]++; emit(2, yypvt[-3].itemptr->i_value, yypvt[-0].ival); } } break; case 69: # line 1246 "zmac.y" { emit(2, 0355, 0100 + (yypvt[-4].ival << 3)); } break; case 70: # line 1249 "zmac.y" { emit(2, 0355, 0160); } break; case 71: # line 1252 "zmac.y" { if (yypvt[-2].ival < 0 || yypvt[-2].ival > 255) err[vflag]++; emit(2, yypvt[-3].itemptr->i_value, yypvt[-2].ival); } break; case 72: # line 1259 "zmac.y" { emit(2, 0355, 0101 + (yypvt[-0].ival << 3)); } break; case 73: # line 1262 "zmac.y" { if (yypvt[-0].ival > 2 || yypvt[-0].ival < 0) err[vflag]++; else emit(2, yypvt[-1].itemptr->i_value >> 8, yypvt[-1].itemptr->i_value + ((yypvt[-0].ival + (yypvt[-0].ival > 0)) << 3)); } break; case 74: # line 1270 "zmac.y" { if (phaseflag) { err[oflag]++; } else { phaseflag = 1; phdollar = dollarsign; dollarsign = yypvt[-0].ival; phbegin = dollarsign; } } break; case 75: # line 1282 "zmac.y" { if (!phaseflag) { err[oflag]++; } else { phaseflag = 0; dollarsign = phdollar + dollarsign - phbegin; } } break; case 76: # line 1292 "zmac.y" { if (phaseflag) { err[oflag]++; dollarsign = phdollar + dollarsign - phbegin; phaseflag = 0; } if (yypvt[-0].ival-dollarsign) { flushbin(); olddollar = yypvt[-0].ival; dollarsign = yypvt[-0].ival; } } break; case 83: # line 1323 "zmac.y" { yypvt[-0].itemptr->i_token = MPARM; if (parm_number >= PARMMAX) error("Too many parameters"); yypvt[-0].itemptr->i_value = parm_number++; } break; case 87: # line 1343 "zmac.y" { cp = malloc(strlen(tempbuf)+1); est2[parm_number++] = cp; strcpy(cp, tempbuf); } break; case 90: # line 1356 "zmac.y" { yyval.ival = yypvt[-0].itemptr->i_value; } break; case 91: # line 1361 "zmac.y" { yyval.ival = yypvt[-0].itemptr->i_value; } break; case 92: # line 1366 "zmac.y" { yyval.ival = yypvt[-0].itemptr->i_value; } break; case 93: # line 1372 "zmac.y" { yyval.ival = 6; } break; case 94: # line 1377 "zmac.y" { disp = yypvt[-1].ival; yyval.ival = (yypvt[-2].itemptr->i_value & 0177400) | 6; } break; case 95: # line 1383 "zmac.y" { disp = 0; yyval.ival = (yypvt[-1].itemptr->i_value & 0177400) | 6; } break; case 98: # line 1395 "zmac.y" { yyval.ival = yypvt[-0].itemptr->i_value; } break; case 99: # line 1400 "zmac.y" { yyval.ival = yypvt[-0].itemptr->i_value; } break; case 101: # line 1408 "zmac.y" { yyval.ival = yypvt[-0].itemptr->i_value; } break; case 102: # line 1413 "zmac.y" { yyval.ival = yypvt[-0].itemptr->i_value; } break; case 104: # line 1421 "zmac.y" { yyval.ival = yypvt[-0].itemptr->i_value; } break; case 105: # line 1427 "zmac.y" { yyval.ival = yypvt[-0].itemptr->i_value; } break; case 106: # line 1432 "zmac.y" { yyval.ival = yypvt[-0].itemptr->i_value; } break; case 108: # line 1440 "zmac.y" { yyval.ival = yypvt[-0].itemptr->i_value; } break; case 109: # line 1446 "zmac.y" { yyval.ival = yypvt[-0].itemptr->i_value; } break; case 110: # line 1451 "zmac.y" { yyval.ival = 030; } break; case 113: # line 1460 "zmac.y" { emit(2, yypvt[-0].ival, yypvt[-0].ival>>8); } break; case 114: # line 1465 "zmac.y" { cp = yypvt[-0].cval; while (*cp != '\0') emit(1,*cp++); } break; case 115: # line 1472 "zmac.y" { if (yypvt[-0].ival < -128 || yypvt[-0].ival > 255) err[vflag]++; emit(1, yypvt[-0].ival & 0377); } break; case 118: # line 1489 "zmac.y" { emit(2, yypvt[-0].ival, yypvt[-0].ival>>8); } break; case 121: # line 1504 "zmac.y" { yyval.ival = yypvt[-1].ival; } break; case 122: # line 1509 "zmac.y" { err[eflag]++; yyval.ival = 0; } break; case 123: # line 1515 "zmac.y" { yyval.ival = yypvt[-0].itemptr->i_value; yypvt[-0].itemptr->i_uses++ ; } break; case 126: # line 1522 "zmac.y" { yyval.ival = yypvt[-0].itemptr->i_value; } break; case 127: # line 1525 "zmac.y" { yyval.ival = yypvt[-0].itemptr->i_value; } break; case 128: # line 1528 "zmac.y" { yyval.ival = yypvt[-0].itemptr->i_value; } break; case 129: # line 1531 "zmac.y" { yyval.ival = dollarsign; } break; case 130: # line 1534 "zmac.y" { err[uflag]++; yyval.ival = 0; } break; case 131: # line 1540 "zmac.y" { yyval.ival = yypvt[-0].itemptr->i_value; } break; case 132: # line 1543 "zmac.y" { yyval.ival = yypvt[-2].ival + yypvt[-0].ival; } break; case 133: # line 1546 "zmac.y" { yyval.ival = yypvt[-2].ival - yypvt[-0].ival; } break; case 134: # line 1549 "zmac.y" { yyval.ival = yypvt[-2].ival / yypvt[-0].ival; } break; case 135: # line 1552 "zmac.y" { yyval.ival = yypvt[-2].ival * yypvt[-0].ival; } break; case 136: # line 1555 "zmac.y" { yyval.ival = yypvt[-2].ival % yypvt[-0].ival; } break; case 137: # line 1558 "zmac.y" { yyval.ival = yypvt[-2].ival & yypvt[-0].ival; } break; case 138: # line 1561 "zmac.y" { yyval.ival = yypvt[-2].ival | yypvt[-0].ival; } break; case 139: # line 1564 "zmac.y" { yyval.ival = yypvt[-2].ival ^ yypvt[-0].ival; } break; case 140: # line 1567 "zmac.y" { yyval.ival = yypvt[-2].ival << yypvt[-0].ival; } break; case 141: # line 1570 "zmac.y" { yyval.ival = ((yypvt[-2].ival >> 1) & 077777) >> (yypvt[-0].ival - 1); } break; case 142: # line 1573 "zmac.y" { yyval.ival = yypvt[-1].ival; } break; case 143: # line 1576 "zmac.y" { yyval.ival = ~yypvt[-0].ival; } break; case 144: # line 1579 "zmac.y" { yyval.ival = yypvt[-0].ival; } break; case 145: # line 1582 "zmac.y" { yyval.ival = -yypvt[-0].ival; } break; case 152: # line 1601 "zmac.y" { if (expptr >= MAXEXP) error("Macro expansion level"); est2 = (char **) malloc((PARMMAX +4) * sizeof(char *)); expstack[expptr] = (char *)est2 ; for (i=0; i;P;X;d;j;p;t;;;;;;;;;;;;< <<<&<3<D<P<X<_<f<v<<<<<<<<<<<<<<===)=1=:=B=H=Q=`=c=t=}======================> >>>> >%>*>/>4><>A>G>M>S>Y>_>e>n>t>z>>>>>>>( ( ( ( ( ( ( ( >>>>>>>>>>>>>? ???%?-?5?=?E?M?X?`?h?p?x?????????????????@@@!@)@1@9@A@I@Q@Y@d@l@t@|@@@@@@@@@@@@@@@@A AAA"A-A5A=AEAMAUA]AeApAxAAAAAAAAAAAAAAAAABBBB&B.B9BABIBQBYBaBiBqB|BBBBBBBBBBBBBBBBC CCC"C*C2C:CECMCUC]CeCmCuC}CCCCCCCCCCCCCCCCDDDD&D.D6D>DFDQDYDaDiDqDyDDDDDDDDDDDDDDDDDEEE( ( ( ( ( ( ( ( ( "E( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ,E( ( ( ( ( ( ( 6EFEXE( ( ( ( ( _EiE{E( ( ( ( ( ( ( ( EEE( ( E( ( ( ( ( ( ( ( ( ( ( ( E( ( ( ( ( ( ( E( ( ( ( ( ( ( E( ( ( ( ( ( ( E( ( ( ( ( ( ( E( ( ( ( ( ( ( F( F.F>FNF^FnF( ~F( ( ( ( ( ( F( ( ( ( ( ( ( F( ( ( ( ( ( ( F( ( ( ( ( ( ( F( ( ( ( ( ( ( F( ( ( ( ( ( ( F( ( ( ( ( ( ( F( ( ( ( ( ( ( F( ( ( ( ( ( ( G( ( ( ( ( ( ( ( ( ( ( ( G( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( *G( 1G( "looȩȗ na i  U GEoo "nnF e i  "Ij "Ij8  0 E oo "nn) i+;ikimmmHHmHmHTHm@@mH "hhm) mkHH; [oȗoȗȥȥȩoo ooi+zzzzk; [  )8 I"r )L  ! )H"f  ( "f )H"f   "f +;i kH"o"q"ph") fnHHHHH; ["Dqoo  ȷݠoȷo ȷ+;i kd8d d 8kH ;[FeFeFeF/eFeFeFeFe+ke+kHZ"+q"p"p"p"pkKAj;jp" pCj=jp" pEj?jp" pkK5i5j7j9j "Uq;jGj;jnp"9 lp!xpيp" ppGj "Uq=j "Uq?jkvp p.CONSOLEK dgXgVggggg~ggzg|gkHH;H" ;[+fghhk"rTH"kxgH "hfgHifg "xgkxg "xgkKzhRghTgh TZګk:JJJJk;8  [d -j>r"7 DJPV\bntz ":@FLRX^d| $*0DJP\bhntz$ "(.4:@LRX^djp|& $*06DPV\nt.4@FL^dpv| *0` &28>JPV\bhnz :@FLjpv|* $*06DJPV\bntz ":@FLRX^d| $*0DJP\bhntz$ "(.4:@LRX^djp|& $*06DJPV\bhntz) "(.4:@FLRX^djpv|* $*06DJPV\bhntz( "(.4:@FLRX^djpv|( $*06DJPV\bhntz! "(.4:@FL* $*06DJPV\bhntz) "(.4:@FLRX^djpv|* $*06 8D $8J +8P 28V 98\ @8b G8h N8n X8t _8z f8 m8 t8 {8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 9 9 9 9 '9.959<9"C9(J9.T94[9:c9@k9Fs9L{9R9X9^9d9j9p9v9|9999999999::::$:,:4:<:D:O:W:]:c:i: o:u:{::$:*:0:6:<:B:H:N:T:Z:`:f:l:r:x:~::::::;;;;;!;1;>;P;X;d;j;p;t;;;;;;; ;&;,;2;8;><D <J<P<V&<\3<hD<nP<tX<z_<f<v<<<<<<<<<<<<<<===)=1=:=B= H=Q=`=c=(t=.}=4=:=@=F=L=R=X=^=d=j=p=v=|=========> >>>> >%>*>/>4><>A>G>M>S> Y>_>e>n>$t>*z>0>6><>B>H>N>>>>>>>>>>>>>>? ???%?-?5?=?E?M?X?`?h? p?&x?,?2?8?>?D?J?P?V?\?b?h?n?t?z???@@@!@)@1@9@A@I@Q@Y@d@l@t@|@@@@@@@ @@@@"@(@.@4@:@@AF ALARAX"A^-Ad5Aj=ApEAvMA|UA]AeApAxAAAAAAAAAAAAAAAAABBB B&B.B9B$AB*IB0QB6YB<aBBiBHqBN|BTBZB`BfBlBrBxB~BBBBBBBBC CCC"C*C2C:CECMCUC]CeCmCuC}CCCC C&C,C2C8C>CDCJCPCVC\CbChDnDtDzD&D.D6D>DFDQDYDaDiDqDyDDDDDDDDDDDDD DDDD"E(E.Ej"E,E6EFEXE*_E0iE6{ElErExEEEE8EhEEFF.F>FNF^FnF~F(FXFFFFFHFxF GGz *G 1G #*ID#1IJ#:IP#DIV#NI\#`Ih#gIn#lIt#sIz#|I#I#I#I#I#I#I#I#I#I#I#I#I#J#J$J $J$(J$2J.$DJF$HJv$MJ$RJ$XJ$^J$bJ%fJ%jJ$%oJ*%sJ0%wJ6%{JT%JZ%J`%Jf%J%J%J%J%Jj'J'J'J(J(J*(J0(J6(Kl(Kr(Kx(&K(:K(DK)TK8)dKh)tK)K)K)K)K)K)K)K)K)L(*LX*$L*5L*FL*UL+fLH+uLx+L+L+Lz,L,L,L,L -LPQRRS-SS-SfSSSSSS`PW`OWaOWMcPWNcOWedWqdWdWdWdOWdPWdQWfW$fWqUq.TH ZDIS l .SH NAME zdis \- disassembler for Z80 cross-assembler .SH SYNOPSIS zdis < infile.hex .SH DESCRIPTION .I Zdis reads a hex file created by .I zmac and produces a disassembly on stdout. .SH SEE ALSO zmac(l) .SH FILES Source is in /usr/local/src/zmac directory. .SH BUGS Zdis ignores the program counter field in the hex file. Instead it assumes that the hex file has an ORG of 0. .sp The man page is incomplete. If anyone discovers more information about using zdis, please consider helping to update the man page. #include #include #include #include #include char undefined[] = "undefined"; struct opcode { char *name; int args; }; int xind; struct opcode major[256] = { "nop", 0, /* 00 */ "ld bc,%02x%02xh", 2, /* 01 */ "ld bc,a", 0, /* 02 */ "inc bc", 0, /* 03 */ "inc b", 0, /* 04 */ "dec b", 0, /* 05 */ "ld b,%02xh", 1, /* 06 */ "rlc a", 0, /* 07 */ "ex af,af'", 0, /* 08 */ "add hl,bc", 0, /* 09 */ "ld a,(bc)", 0, /* 0a */ "dec bc", 0, /* 0b */ "inc c", 0, /* 0c */ "dec c", 0, /* 0d */ "ld c,%02xh", 1, /* 0e */ "rrc a", 0, /* 0f */ "djnz %02xh", 1, /* 10 */ "ld de,%02x%02xh", 2, /* 11 */ "ld (de),a", 0, /* 12 */ "inc de", 0, /* 13 */ "inc d", 0, /* 14 */ "dec d", 0, /* 15 */ "ld d,%02xh", 1, /* 16 */ "rla", 0, /* 17 */ "jr %02xh", 1, /* 18 */ "add hl,de", 0, /* 19 */ "ld a,(de)", 0, /* 1a */ "dec de", 0, /* 1b */ "inc e", 0, /* 1c */ "dec e", 0, /* 1d */ "ld e,%02xh", 1, /* 1e */ "rra", 0, /* 1f */ "jr nz,%02xh", 1, /* 20 */ "ld hl,%02x%02xh", 2, /* 21 */ "ld (%02x%02xh),hl",2, /* 22 */ "inc hl", 0, /* 23 */ "inc h", 0, /* 24 */ "dec h", 0, /* 25 */ "ld h,%02xh", 1, /* 26 */ "daa", 0, /* 27 */ "jr z,%02xh", 1, /* 28 */ "add hl,hl", 0, /* 29 */ "ld hl,(%02x%02xh)",2, /* 2a */ "dec hl", 0, /* 2b */ "inc l", 0, /* 2c */ "dec l", 0, /* 2d */ "ld l,%02xh", 1, /* 2e */ "cpl", 0, /* 2f */ "jr nc,%02xh", 1, /* 30 */ "ld sp,%02x%02xh", 2, /* 31 */ "ld (%02x%02xh),a", 2, /* 32 */ "inc sp", 0, /* 33 */ "inc (hl)", 0, /* 34 */ "dec (hl)", 0, /* 35 */ "ld (hl),%02xh", 1, /* 36 */ "scf", 0, /* 37 */ "jr c,%02xh", 1, /* 38 */ "add hl,sp", 0, /* 39 */ "ld a,(%02x%02xh)", 2, /* 3a */ "dec sp", 0, /* 3b */ "inc a", 0, /* 3c */ "dec a", 0, /* 3d */ "ld a,%02xh", 1, /* 3e */ "ccf", 0, /* 3f */ "ld b,b", 0, /* 40 */ "ld b,c", 0, /* 41 */ "ld b,d", 0, /* 42 */ "ld b,e", 0, /* 43 */ "ld b,h", 0, /* 44 */ "ld b,l", 0, /* 45 */ "ld b,(hl)", 0, /* 46 */ "ld b,a", 0, /* 47 */ "ld c,b", 0, /* 48 */ "ld c,c", 0, /* 49 */ "ld c,d", 0, /* 4a */ "ld c,e", 0, /* 4b */ "ld c,h", 0, /* 4c */ "ld c,l", 0, /* 4d */ "ld c,(hl)", 0, /* 4e */ "ld c,a", 0, /* 4f */ "ld d,b", 0, /* 50 */ "ld d,c", 0, /* 51 */ "ld d,d", 0, /* 52 */ "ld d,e", 0, /* 53 */ "ld d,h", 0, /* 54 */ "ld d,l", 0, /* 55 */ "ld d,(hl)", 0, /* 56 */ "ld d,a", 0, /* 57 */ "ld e,b", 0, /* 58 */ "ld e,c", 0, /* 59 */ "ld e,d", 0, /* 5a */ "ld e,e", 0, /* 5b */ "ld e,h", 0, /* 5c */ "ld e,l", 0, /* 5d */ "ld e,(hl)", 0, /* 5e */ "ld e,a", 0, /* 5f */ "ld h,b", 0, /* 60 */ "ld h,c", 0, /* 61 */ "ld h,d", 0, /* 62 */ "ld h,e", 0, /* 63 */ "ld h,h", 0, /* 64 */ "ld h,l", 0, /* 65 */ "ld h,(hl)", 0, /* 66 */ "ld h,a", 0, /* 67 */ "ld l,b", 0, /* 68 */ "ld l,c", 0, /* 69 */ "ld l,d", 0, /* 6a */ "ld l,e", 0, /* 6b */ "ld l,h", 0, /* 6c */ "ld l,l", 0, /* 6d */ "ld l,(hl)", 0, /* 6e */ "ld l,a", 0, /* 6f */ "ld (hl),b", 0, /* 70 */ "ld (hl),c", 0, /* 71 */ "ld (hl),d", 0, /* 72 */ "ld (hl),e", 0, /* 73 */ "ld (hl),h", 0, /* 74 */ "ld (hl),l", 0, /* 75 */ "halt", 0, /* 76 */ "ld (hl),a", 0, /* 77 */ "ld a,b", 0, /* 78 */ "ld a,c", 0, /* 79 */ "ld a,d", 0, /* 7a */ "ld a,e", 0, /* 7b */ "ld a,h", 0, /* 7c */ "ld a,l", 0, /* 7d */ "ld a,(hl)", 0, /* 7e */ "ld a,a", 0, /* 7f */ "add a,b", 0, /* 80 */ "add a,c", 0, /* 81 */ "add a,d", 0, /* 82 */ "add a,e", 0, /* 83 */ "add a,h", 0, /* 84 */ "add a,l", 0, /* 85 */ "add a,(hl)", 0, /* 86 */ "add a,a", 0, /* 87 */ "adc a,b", 0, /* 88 */ "adc a,c", 0, /* 89 */ "adc a,d", 0, /* 8a */ "adc a,e", 0, /* 8b */ "adc a,h", 0, /* 8c */ "adc a,l", 0, /* 8d */ "adc a,(hl)", 0, /* 8e */ "adc a,a", 0, /* 8f */ "sub b", 0, /* 90 */ "sub c", 0, /* 91 */ "sub d", 0, /* 92 */ "sub e", 0, /* 93 */ "sub h", 0, /* 94 */ "sub l", 0, /* 95 */ "sub (hl)", 0, /* 96 */ "sub a", 0, /* 97 */ "sbc a,b", 0, /* 98 */ "sbc a,c", 0, /* 99 */ "sbc a,d", 0, /* 9a */ "sbc a,e", 0, /* 9b */ "sbc a,h", 0, /* 9c */ "sbc a,l", 0, /* 9d */ "sbc a,(hl)", 0, /* 9e */ "sbc a,a", 0, /* 9f */ "and b", 0, /* a0 */ "and c", 0, /* a1 */ "and d", 0, /* a2 */ "and e", 0, /* a3 */ "and h", 0, /* a4 */ "and l", 0, /* a5 */ "and (hl)", 0, /* a6 */ "and a", 0, /* a7 */ "xor b", 0, /* a8 */ "xor c", 0, /* a9 */ "xor d", 0, /* aa */ "xor e", 0, /* ab */ "xor h", 0, /* ac */ "xor l", 0, /* ad */ "xor (hl)", 0, /* ae */ "xor a", 0, /* af */ "or b", 0, /* b0 */ "or c", 0, /* b1 */ "or d", 0, /* b2 */ "or e", 0, /* b3 */ "or h", 0, /* b4 */ "or l", 0, /* b5 */ "or (hl)", 0, /* b6 */ "or a", 0, /* b7 */ "cp b", 0, /* b8 */ "cp c", 0, /* b9 */ "cp d", 0, /* ba */ "cp e", 0, /* bb */ "cp h", 0, /* bc */ "cp l", 0, /* bd */ "cp (hl)", 0, /* be */ "cp a", 0, /* bf */ "ret nz", 0, /* c0 */ "pop bc", 0, /* c1 */ "jp nz,%02x%02xh", 2, /* c2 */ "jp %02x%02xh", 2, /* c3 */ "call nz,%02x%02xh", 2, /* c4 */ "push bc", 0, /* c5 */ "add a,%02xh", 1, /* c6 */ "rst 0", 0, /* c7 */ "ret z", 0, /* c8 */ "ret", 0, /* c9 */ "jp z,%02x%02xh", 2, /* ca */ 0, 0, /* cb */ "call z,%02x%02xh", 2, /* cc */ "call %02x%02xh", 2, /* cd */ "adc a,%02xh", 1, /* ce */ "rst 8", 0, /* cf */ "ret nc", 0, /* d0 */ "pop de", 0, /* d1 */ "jp nc,%02x%02xh", 2, /* d2 */ "out (%02xh),a", 1, /* d3 */ "call nc,%02x%02xh", 2, /* d4 */ "push de", 0, /* d5 */ "sub %02xh", 1, /* d6 */ "rst 10h", 0, /* d7 */ "ret c", 0, /* d8 */ "exx", 0, /* d9 */ "jp c,%02x%02xh", 2, /* da */ "in a,(%02xh)", 1, /* db */ "call c,%02x%02xh", 2, /* dc */ 0, 1, /* dd */ "sbc a,%02xh", 1, /* de */ "rst 18h", 0, /* df */ "ret po", 0, /* e0 */ "pop hl", 0, /* e1 */ "jp po,%02x%02xh", 2, /* e2 */ "ex (sp),hl", 0, /* e3 */ "call po,%02x%02xh", 2, /* e4 */ "push hl", 0, /* e5 */ "and %02xh", 1, /* e6 */ "rst 20h", 0, /* e7 */ "ret pe", 0, /* e8 */ "jp (hl)", 0, /* e9 */ "jp pe,%02x%02xh", 2, /* ea */ "ex de,hl", 0, /* eb */ "call pe,%02x%02xh", 2, /* ec */ 0, 2, /* ed */ "xor %02xh", 1, /* ee */ "rst 28h", 0, /* ef */ "ret p", 0, /* f0 */ "pop af", 0, /* f1 */ "jp p,%02x%02xh", 2, /* f2 */ "di", 0, /* f3 */ "call p,%02x%02xh", 2, /* f4 */ "push af", 0, /* f5 */ "or %02xh", 1, /* f6 */ "rst 30h", 0, /* f7 */ "ret m", 0, /* f8 */ "ld sp,hl", 0, /* f9 */ "jp m,%02x%02xh", 2, /* fa */ "ei", 0, /* fb */ "call m,%02x%02xh", 2, /* fc */ 0, 3, /* fd */ "cp %02xh", 1, /* fe */ "rst 38h", 0, /* ff */ }; struct opcode minor[4][256] = { /* cb */ "rlc b", 0, /* cb00 */ "rlc c", 0, /* cb01 */ "rlc d", 0, /* cb02 */ "rlc e", 0, /* cb03 */ "rlc h", 0, /* cb04 */ "rlc l", 0, /* cb05 */ "rlc (hl)", 0, /* cb06 */ "rlc a", 0, /* cb07 */ "rrc b", 0, /* cb08 */ "rrc c", 0, /* cb09 */ "rrc d", 0, /* cb0a */ "rrc e", 0, /* cb0b */ "rrc h", 0, /* cb0c */ "rrc l", 0, /* cb0d */ "rrc (hl)", 0, /* cb0e */ "rrc a", 0, /* cb0f */ "rl b", 0, /* cb10 */ "rl c", 0, /* cb11 */ "rl d", 0, /* cb12 */ "rl e", 0, /* cb13 */ "rl h", 0, /* cb14 */ "rl l", 0, /* cb15 */ "rl (hl)", 0, /* cb16 */ "rl a", 0, /* cb17 */ "rr b", 0, /* cb18 */ "rr c", 0, /* cb19 */ "rr d", 0, /* cb1a */ "rr e", 0, /* cb1b */ "rr h", 0, /* cb1c */ "rr l", 0, /* cb1d */ "rr (hl)", 0, /* cb1e */ "rr a", 0, /* cb1f */ "sla b", 0, /* cb20 */ "sla c", 0, /* cb21 */ "sla d", 0, /* cb22 */ "sla e", 0, /* cb23 */ "sla h", 0, /* cb24 */ "sla l", 0, /* cb25 */ "sla (hl)", 0, /* cb26 */ "sla a", 0, /* cb27 */ "sra b", 0, /* cb28 */ "sra c", 0, /* cb29 */ "sra d", 0, /* cb2a */ "sra e", 0, /* cb2b */ "sra h", 0, /* cb2c */ "sra l", 0, /* cb2d */ "sra (hl)", 0, /* cb2e */ "sra a", 0, /* cb2f */ undefined, 0, /* cb30 */ undefined, 0, /* cb31 */ undefined, 0, /* cb32 */ undefined, 0, /* cb33 */ undefined, 0, /* cb34 */ undefined, 0, /* cb35 */ undefined, 0, /* cb36 */ undefined, 0, /* cb37 */ "srl b", 0, /* cb38 */ "srl c", 0, /* cb39 */ "srl d", 0, /* cb3a */ "srl e", 0, /* cb3b */ "srl h", 0, /* cb3c */ "srl l", 0, /* cb3d */ "srl (hl)", 0, /* cb3e */ "srl a", 0, /* cb3f */ "bit 0,b", 0, /* cb40 */ "bit 0,c", 0, /* cb41 */ "bit 0,d", 0, /* cb42 */ "bit 0,e", 0, /* cb43 */ "bit 0,h", 0, /* cb44 */ "bit 0,l", 0, /* cb45 */ "bit 0,(hl)", 0, /* cb46 */ "bit 0,a", 0, /* cb47 */ "bit 1,b", 0, /* cb48 */ "bit 1,c", 0, /* cb49 */ "bit 1,d", 0, /* cb4a */ "bit 1,e", 0, /* cb4b */ "bit 1,h", 0, /* cb4c */ "bit 1,l", 0, /* cb4d */ "bit 1,(hl)", 0, /* cb4e */ "bit 1,a", 0, /* cb4f */ "bit 2,b", 0, /* cb50 */ "bit 2,c", 0, /* cb51 */ "bit 2,d", 0, /* cb52 */ "bit 2,e", 0, /* cb53 */ "bit 2,h", 0, /* cb54 */ "bit 2,l", 0, /* cb55 */ "bit 2,(hl)", 0, /* cb56 */ "bit 2,a", 0, /* cb57 */ "bit 3,b", 0, /* cb58 */ "bit 3,c", 0, /* cb59 */ "bit 3,d", 0, /* cb5a */ "bit 3,e", 0, /* cb5b */ "bit 3,h", 0, /* cb5c */ "bit 3,l", 0, /* cb5d */ "bit 3,(hl)", 0, /* cb5e */ "bit 3,a", 0, /* cb5f */ "bit 4,b", 0, /* cb60 */ "bit 4,c", 0, /* cb61 */ "bit 4,d", 0, /* cb62 */ "bit 4,e", 0, /* cb63 */ "bit 4,h", 0, /* cb64 */ "bit 4,l", 0, /* cb65 */ "bit 4,(hl)", 0, /* cb66 */ "bit 4,a", 0, /* cb67 */ "bit 5,b", 0, /* cb68 */ "bit 5,c", 0, /* cb69 */ "bit 5,d", 0, /* cb6a */ "bit 5,e", 0, /* cb6b */ "bit 5,h", 0, /* cb6c */ "bit 5,l", 0, /* cb6d */ "bit 5,(hl)", 0, /* cb6e */ "bit 5,a", 0, /* cb6f */ "bit 6,b", 0, /* cb70 */ "bit 6,c", 0, /* cb71 */ "bit 6,d", 0, /* cb72 */ "bit 6,e", 0, /* cb73 */ "bit 6,h", 0, /* cb74 */ "bit 6,l", 0, /* cb75 */ "bit 6,(hl)", 0, /* cb76 */ "bit 6,a", 0, /* cb77 */ "bit 7,b", 0, /* cb78 */ "bit 7,c", 0, /* cb79 */ "bit 7,d", 0, /* cb7a */ "bit 7,e", 0, /* cb7b */ "bit 7,h", 0, /* cb7c */ "bit 7,l", 0, /* cb7d */ "bit 7,(hl)", 0, /* cb7e */ "bit 7,a", 0, /* cb7f */ "res 0,b", 0, /* cb80 */ "res 0,c", 0, /* cb81 */ "res 0,d", 0, /* cb82 */ "res 0,e", 0, /* cb83 */ "res 0,h", 0, /* cb84 */ "res 0,l", 0, /* cb85 */ "res 0,(hl)", 0, /* cb86 */ "res 0,a", 0, /* cb87 */ "res 1,b", 0, /* cb88 */ "res 1,c", 0, /* cb89 */ "res 1,d", 0, /* cb8a */ "res 1,e", 0, /* cb8b */ "res 1,h", 0, /* cb8c */ "res 1,l", 0, /* cb8d */ "res 1,(hl)", 0, /* cb8e */ "res 1,a", 0, /* cb8f */ "res 2,b", 0, /* cb90 */ "res 2,c", 0, /* cb91 */ "res 2,d", 0, /* cb92 */ "res 2,e", 0, /* cb93 */ "res 2,h", 0, /* cb94 */ "res 2,l", 0, /* cb95 */ "res 2,(hl)", 0, /* cb96 */ "res 2,a", 0, /* cb97 */ "res 3,b", 0, /* cb98 */ "res 3,c", 0, /* cb99 */ "res 3,d", 0, /* cb9a */ "res 3,e", 0, /* cb9b */ "res 3,h", 0, /* cb9c */ "res 3,l", 0, /* cb9d */ "res 3,(hl)", 0, /* cb9e */ "res 3,a", 0, /* cb9f */ "res 4,b", 0, /* cba0 */ "res 4,c", 0, /* cba1 */ "res 4,d", 0, /* cba2 */ "res 4,e", 0, /* cba3 */ "res 4,h", 0, /* cba4 */ "res 4,l", 0, /* cba5 */ "res 4,(hl)", 0, /* cba6 */ "res 4,a", 0, /* cba7 */ "res 5,b", 0, /* cba8 */ "res 5,c", 0, /* cba9 */ "res 5,d", 0, /* cbaa */ "res 5,e", 0, /* cbab */ "res 5,h", 0, /* cbac */ "res 5,l", 0, /* cbad */ "res 5,(hl)", 0, /* cbae */ "res 5,a", 0, /* cbaf */ "res 6,b", 0, /* cbb0 */ "res 6,c", 0, /* cbb1 */ "res 6,d", 0, /* cbb2 */ "res 6,e", 0, /* cbb3 */ "res 6,h", 0, /* cbb4 */ "res 6,l", 0, /* cbb5 */ "res 6,(hl)", 0, /* cbb6 */ "res 6,a", 0, /* cbb7 */ "res 7,b", 0, /* cbb8 */ "res 7,c", 0, /* cbb9 */ "res 7,d", 0, /* cbba */ "res 7,e", 0, /* cbbb */ "res 7,h", 0, /* cbbc */ "res 7,l", 0, /* cbbd */ "res 7,(hl)", 0, /* cbbe */ "res 7,a", 0, /* cbbf */ "set 0,b", 0, /* cbc0 */ "set 0,c", 0, /* cbc1 */ "set 0,d", 0, /* cbc2 */ "set 0,e", 0, /* cbc3 */ "set 0,h", 0, /* cbc4 */ "set 0,l", 0, /* cbc5 */ "set 0,(hl)", 0, /* cbc6 */ "set 0,a", 0, /* cbc7 */ "set 1,b", 0, /* cbc8 */ "set 1,c", 0, /* cbc9 */ "set 1,d", 0, /* cbca */ "set 1,e", 0, /* cbcb */ "set 1,h", 0, /* cbcc */ "set 1,l", 0, /* cbcd */ "set 1,(hl)", 0, /* cbce */ "set 1,a", 0, /* cbcf */ "set 2,b", 0, /* cbd0 */ "set 2,c", 0, /* cbd1 */ "set 2,d", 0, /* cbd2 */ "set 2,e", 0, /* cbd3 */ "set 2,h", 0, /* cbd4 */ "set 2,l", 0, /* cbd5 */ "set 2,(hl)", 0, /* cbd6 */ "set 2,a", 0, /* cbd7 */ "set 3,b", 0, /* cbd8 */ "set 3,c", 0, /* cbd9 */ "set 3,d", 0, /* cbda */ "set 3,e", 0, /* cbdb */ "set 3,h", 0, /* cbdc */ "set 3,l", 0, /* cbdd */ "set 3,(hl)", 0, /* cbde */ "set 3,a", 0, /* cbdf */ "set 4,b", 0, /* cbe0 */ "set 4,c", 0, /* cbe1 */ "set 4,d", 0, /* cbe2 */ "set 4,e", 0, /* cbe3 */ "set 4,h", 0, /* cbe4 */ "set 4,l", 0, /* cbe5 */ "set 4,(hl)", 0, /* cbe6 */ "set 4,a", 0, /* cbe7 */ "set 5,b", 0, /* cbe8 */ "set 5,c", 0, /* cbe9 */ "set 5,d", 0, /* cbea */ "set 5,e", 0, /* cbeb */ "set 5,h", 0, /* cbec */ "set 5,l", 0, /* cbed */ "set 5,(hl)", 0, /* cbee */ "set 5,a", 0, /* cbef */ "set 6,b", 0, /* cbf0 */ "set 6,c", 0, /* cbf1 */ "set 6,d", 0, /* cbf2 */ "set 6,e", 0, /* cbf3 */ "set 6,h", 0, /* cbf4 */ "set 6,l", 0, /* cbf5 */ "set 6,(hl)", 0, /* cbf6 */ "set 6,a", 0, /* cbf7 */ "set 7,b", 0, /* cbf8 */ "set 7,c", 0, /* cbf9 */ "set 7,d", 0, /* cbfa */ "set 7,e", 0, /* cbfb */ "set 7,h", 0, /* cbfc */ "set 7,l", 0, /* cbfd */ "set 7,(hl)", 0, /* cbfe */ "set 7,a", 0, /* cbff */ /* dd */ undefined, 0, /* dd00 */ undefined, 0, /* dd01 */ undefined, 0, /* dd02 */ undefined, 0, /* dd03 */ undefined, 0, /* dd04 */ undefined, 0, /* dd05 */ undefined, 0, /* dd06 */ undefined, 0, /* dd07 */ undefined, 0, /* dd08 */ "add ix,bc", 0, /* dd09 */ undefined, 0, /* dd0a */ undefined, 0, /* dd0b */ undefined, 0, /* dd0c */ undefined, 0, /* dd0d */ undefined, 0, /* dd0e */ undefined, 0, /* dd0f */ undefined, 0, /* dd10 */ undefined, 0, /* dd11 */ undefined, 0, /* dd12 */ undefined, 0, /* dd13 */ undefined, 0, /* dd14 */ undefined, 0, /* dd15 */ undefined, 0, /* dd16 */ undefined, 0, /* dd17 */ undefined, 0, /* dd18 */ "add ix,de", 0, /* dd19 */ undefined, 0, /* dd1a */ undefined, 0, /* dd1b */ undefined, 0, /* dd1c */ undefined, 0, /* dd1d */ undefined, 0, /* dd1e */ undefined, 0, /* dd1f */ undefined, 0, /* dd20 */ "ld ix,%02x%02xh", 2, /* dd21 */ "ld (%02x%02xh),ix",2, /* dd22 */ "inc ix", 0, /* dd23 */ undefined, 0, /* dd24 */ undefined, 0, /* dd25 */ undefined, 0, /* dd26 */ undefined, 0, /* dd27 */ undefined, 0, /* dd28 */ "add ix,ix", 0, /* dd29 */ "ld ix,(%02x%02xh)",2, /* dd2a */ "dec ix", 0, /* dd2b */ undefined, 0, /* dd2c */ undefined, 0, /* dd2d */ undefined, 0, /* dd2e */ undefined, 0, /* dd2f */ undefined, 0, /* dd30 */ undefined, 0, /* dd31 */ undefined, 0, /* dd32 */ undefined, 0, /* dd33 */ "inc (ix+%02xh)", 1, /* dd34 */ "dec (ix+%02xh)", 1, /* dd35 */ "ld (ix+%02xh),%02xh",2, /* dd36 */ undefined, 0, /* dd37 */ undefined, 0, /* dd38 */ "add ix,sp", 0, /* dd39 */ undefined, 0, /* dd3a */ undefined, 0, /* dd3b */ undefined, 0, /* dd3c */ undefined, 0, /* dd3d */ undefined, 0, /* dd3e */ undefined, 0, /* dd3f */ undefined, 0, /* dd40 */ undefined, 0, /* dd41 */ undefined, 0, /* dd42 */ undefined, 0, /* dd43 */ undefined, 0, /* dd44 */ undefined, 0, /* dd45 */ "ld b,(ix+%02xh)", 1, /* dd46 */ undefined, 0, /* dd47 */ undefined, 0, /* dd48 */ undefined, 0, /* dd49 */ undefined, 0, /* dd4a */ undefined, 0, /* dd4b */ undefined, 0, /* dd4c */ undefined, 0, /* dd4d */ "ld c,(ix+%02xh)", 1, /* dd4e */ undefined, 0, /* dd4f */ undefined, 0, /* dd50 */ undefined, 0, /* dd51 */ undefined, 0, /* dd52 */ undefined, 0, /* dd53 */ undefined, 0, /* dd54 */ undefined, 0, /* dd55 */ "ld d,(ix+%02xh)", 1, /* dd56 */ undefined, 0, /* dd57 */ undefined, 0, /* dd58 */ undefined, 0, /* dd59 */ undefined, 0, /* dd5a */ undefined, 0, /* dd5b */ undefined, 0, /* dd5c */ undefined, 0, /* dd5d */ "ld e,(ix+%02xh)", 1, /* dd5e */ undefined, 0, /* dd5f */ undefined, 0, /* dd60 */ undefined, 0, /* dd61 */ undefined, 0, /* dd62 */ undefined, 0, /* dd63 */ undefined, 0, /* dd64 */ undefined, 0, /* dd65 */ "ld h,(ix+%02xh)", 1, /* dd66 */ undefined, 0, /* dd67 */ undefined, 0, /* dd68 */ undefined, 0, /* dd69 */ undefined, 0, /* dd6a */ undefined, 0, /* dd6b */ undefined, 0, /* dd6c */ undefined, 0, /* dd6d */ "ld l,(ix+%02xh)", 1, /* dd6e */ undefined, 0, /* dd6f */ "ld (ix+%02xh),b", 1, /* dd70 */ "ld (ix+%02xh),c", 1, /* dd71 */ "ld (ix+%02xh),d", 1, /* dd72 */ "ld (ix+%02xh),e", 1, /* dd73 */ "ld (ix+%02xh),h", 1, /* dd74 */ "ld (ix+%02xh),l", 1, /* dd75 */ undefined, 0, /* dd76 */ "ld (ix+%02xh),a", 1, /* dd77 */ undefined, 0, /* dd78 */ undefined, 0, /* dd79 */ undefined, 0, /* dd7a */ undefined, 0, /* dd7b */ undefined, 0, /* dd7c */ undefined, 0, /* dd7d */ "ld a,(ix+%02xh)", 1, /* dd7e */ undefined, 0, /* dd7f */ undefined, 0, /* dd80 */ undefined, 0, /* dd81 */ undefined, 0, /* dd82 */ undefined, 0, /* dd83 */ undefined, 0, /* dd84 */ undefined, 0, /* dd85 */ "add a,(ix+%02xh)", 1, /* dd86 */ undefined, 0, /* dd87 */ undefined, 0, /* dd88 */ undefined, 0, /* dd89 */ undefined, 0, /* dd8a */ undefined, 0, /* dd8b */ undefined, 0, /* dd8c */ undefined, 0, /* dd8d */ "adc a,(ix+%02xh)", 1, /* dd8e */ undefined, 0, /* dd8f */ undefined, 0, /* dd90 */ undefined, 0, /* dd91 */ undefined, 0, /* dd92 */ undefined, 0, /* dd93 */ undefined, 0, /* dd94 */ undefined, 0, /* dd95 */ "sub (ix+%02xh)", 1, /* dd96 */ undefined, 0, /* dd97 */ undefined, 0, /* dd98 */ undefined, 0, /* dd99 */ undefined, 0, /* dd9a */ undefined, 0, /* dd9b */ undefined, 0, /* dd9c */ undefined, 0, /* dd9d */ "sbc a,(ix+%02xh)", 1, /* dd9e */ undefined, 0, /* dd9f */ undefined, 0, /* dda0 */ undefined, 0, /* dda1 */ undefined, 0, /* dda2 */ undefined, 0, /* dda3 */ undefined, 0, /* dda4 */ undefined, 0, /* dda5 */ "and (ix+%02xh)", 1, /* dda6 */ undefined, 0, /* dda7 */ undefined, 0, /* dda8 */ undefined, 0, /* dda9 */ undefined, 0, /* ddaa */ undefined, 0, /* ddab */ undefined, 0, /* ddac */ undefined, 0, /* ddad */ "xor (ix+%02xh)", 1, /* ddae */ undefined, 0, /* ddaf */ undefined, 0, /* ddb0 */ undefined, 0, /* ddb1 */ undefined, 0, /* ddb2 */ undefined, 0, /* ddb3 */ undefined, 0, /* ddb4 */ undefined, 0, /* ddb5 */ "or (ix+%02xh)", 1, /* ddb6 */ undefined, 0, /* ddb7 */ undefined, 0, /* ddb8 */ undefined, 0, /* ddb9 */ undefined, 0, /* ddba */ undefined, 0, /* ddbb */ undefined, 0, /* ddbc */ undefined, 0, /* ddbd */ "cp (ix+%02xh)", 1, /* ddbe */ undefined, 0, /* ddbf */ undefined, 0, /* ddc0 */ undefined, 0, /* ddc1 */ undefined, 0, /* ddc2 */ undefined, 0, /* ddc3 */ undefined, 0, /* ddc4 */ undefined, 0, /* ddc5 */ undefined, 0, /* ddc6 */ undefined, 0, /* ddc7 */ undefined, 0, /* ddc8 */ undefined, 0, /* ddc9 */ undefined, 0, /* ddca */ "dd cb %02x,%02x", 2, /* ddcb */ undefined, 0, /* ddcc */ undefined, 0, /* ddcd */ undefined, 0, /* ddce */ undefined, 0, /* ddcf */ undefined, 0, /* ddd0 */ undefined, 0, /* ddd1 */ undefined, 0, /* ddd2 */ undefined, 0, /* ddd3 */ undefined, 0, /* ddd4 */ undefined, 0, /* ddd5 */ undefined, 0, /* ddd6 */ undefined, 0, /* ddd7 */ undefined, 0, /* ddd8 */ undefined, 0, /* ddd9 */ undefined, 0, /* ddda */ undefined, 0, /* dddb */ undefined, 0, /* dddc */ undefined, 0, /* dddd */ undefined, 0, /* ddde */ undefined, 0, /* dddf */ undefined, 0, /* dde0 */ "pop ix", 0, /* dde1 */ undefined, 0, /* dde2 */ "ex (sp),ix", 0, /* dde3 */ undefined, 0, /* dde4 */ "push ix", 0, /* dde5 */ undefined, 0, /* dde6 */ undefined, 0, /* dde7 */ undefined, 0, /* dde8 */ "jp (ix)", 0, /* dde9 */ undefined, 0, /* ddea */ undefined, 0, /* ddeb */ undefined, 0, /* ddec */ undefined, 0, /* dded */ undefined, 0, /* ddee */ undefined, 0, /* ddef */ undefined, 0, /* ddf0 */ undefined, 0, /* ddf1 */ undefined, 0, /* ddf2 */ undefined, 0, /* ddf3 */ undefined, 0, /* ddf4 */ undefined, 0, /* ddf5 */ undefined, 0, /* ddf6 */ undefined, 0, /* ddf7 */ undefined, 0, /* ddf8 */ "ld sp,ix", 0, /* ddf9 */ undefined, 0, /* ddfa */ undefined, 0, /* ddfb */ undefined, 0, /* ddfc */ undefined, 0, /* ddfd */ undefined, 0, /* ddfe */ undefined, 0, /* ddff */ /* ed */ "in0 b,(%02Xh)", 1, /* ed00 */ "out0 (%02Xh),b", 1, /* ed01 */ undefined, 0, /* ed02 */ undefined, 0, /* ed03 */ "tst b", 0, /* ed04 */ undefined, 0, /* ed05 */ undefined, 0, /* ed06 */ undefined, 0, /* ed07 */ "in0 b,(%02Xh)", 1, /* ed08 */ "out0 (%02Xh),b", 1, /* ed09 */ undefined, 0, /* ed0A */ undefined, 0, /* ed0B */ "tst b", 0, /* ed0C */ undefined, 0, /* ed0D */ undefined, 0, /* ed0E */ undefined, 0, /* ed0F */ "in0 d,(%02Xh)", 1, /* ed10 */ "out0 (%02Xh),d", 1, /* ed11 */ undefined, 0, /* ed12 */ undefined, 0, /* ed13 */ "tst d", 0, /* ed14 */ undefined, 0, /* ed15 */ undefined, 0, /* ed16 */ undefined, 0, /* ed17 */ "in0 d,(%02Xh)", 1, /* ed18 */ "out0 (%02Xh),d", 1, /* ed19 */ undefined, 0, /* ed1A */ undefined, 0, /* ed1B */ "tst d", 0, /* ed1C */ undefined, 0, /* ed1D */ undefined, 0, /* ed1E */ undefined, 0, /* ed1F */ "in0 h,(%02Xh)", 1, /* ed20 */ "out0 (%02Xh),h", 1, /* ed21 */ undefined, 0, /* ed22 */ undefined, 0, /* ed23 */ "tst h", 0, /* ed24 */ undefined, 0, /* ed25 */ undefined, 0, /* ed26 */ undefined, 0, /* ed27 */ "in0 h,(%02Xh)", 1, /* ed28 */ "out0 (%02Xh),h", 1, /* ed29 */ undefined, 0, /* ed2A */ undefined, 0, /* ed2B */ "tst h", 0, /* ed2C */ undefined, 0, /* ed2D */ undefined, 0, /* ed2E */ undefined, 0, /* ed2F */ "in0 h,(%02Xh)", 1, /* ed30 */ "out0 (%02Xh),h", 1, /* ed31 */ undefined, 0, /* ed32 */ undefined, 0, /* ed33 */ "tst (hl)", 0, /* ed34 */ undefined, 0, /* ed35 */ undefined, 0, /* ed36 */ undefined, 0, /* ed37 */ "in0 h,(%02Xh)", 1, /* ed38 */ "out0 (%02Xh),h", 1, /* ed39 */ undefined, 0, /* ed3A */ undefined, 0, /* ed3B */ "tst h", 0, /* ed3C */ undefined, 0, /* ed3D */ undefined, 0, /* ed3E */ undefined, 0, /* ed3F */ "in b,(c)", 0, /* ed40 */ "out (c),b", 0, /* ed41 */ "sbc hl,bc", 0, /* ed42 */ "ld (%02x%02xh),bc",2, /* ed43 */ "neg", 0, /* ed44 */ "retn", 0, /* ed45 */ "im 0", 0, /* ed46 */ "ld i,a", 0, /* ed47 */ "in c,(c)", 0, /* ed48 */ "out (c),c", 0, /* ed49 */ "adc hl,bc", 0, /* ed4a */ "ld bc,(%02x%02xh)",2, /* ed4b */ "mlt bc", 0, /* ed4c */ "reti", 0, /* ed4d */ undefined, 0, /* ed4e */ "ld r,a", 0, /* ed4f */ "in d,(c)", 0, /* ed50 */ "out (c),d", 0, /* ed51 */ "sbc hl,de", 0, /* ed52 */ "ld (%02x%02xh),de",2, /* ed53 */ undefined, 0, /* ed54 */ undefined, 0, /* ed55 */ "im 1", 0, /* ed56 */ "ld a,i", 0, /* ed57 */ "in e,(c)", 0, /* ed58 */ "out (c),e", 0, /* ed59 */ "adc hl,de", 0, /* ed5a */ "ld de,(%02x%02xh)",2, /* ed5b */ "mlt de", 0, /* ed5c */ undefined, 0, /* ed5d */ "im 2", 0, /* ed5e */ "ld a,r", 0, /* ed5f */ "in h,(c)", 0, /* ed60 */ "out (c),h", 0, /* ed61 */ "sbc hl,hl", 0, /* ed62 */ "ld (%02x%02xh),hl",2, /* ed63 */ "tst %02x", 1, /* ed64 */ undefined, 0, /* ed65 */ undefined, 0, /* ed66 */ "rrd", 0, /* ed67 */ "in l,(c)", 0, /* ed68 */ "out (c),l", 0, /* ed69 */ "adc hl,hl", 0, /* ed6a */ "ld hl,(%02x%02xh)",2, /* ed6b */ "mlt hl", 0, /* ed6c */ undefined, 0, /* ed6d */ undefined, 0, /* ed6e */ "rld", 0, /* ed6f */ undefined, 0, /* ed70 */ undefined, 0, /* ed71 */ "sbc hl,sp", 0, /* ed72 */ "ld (%02x%02xh),sp",2, /* ed73 */ "tstio %02xh", 1, /* ed74 */ undefined, 0, /* ed75 */ "slp", 0, /* ed76 */ undefined, 0, /* ed77 */ "in a,(c)", 0, /* ed78 */ "out (c),a", 0, /* ed79 */ "adc hl,sp", 0, /* ed7a */ "ld sp,(%02x%02xh)",2, /* ed7b */ undefined, 0, /* ed7c */ undefined, 0, /* ed7d */ undefined, 0, /* ed7e */ "rld", 0, /* ed7f */ undefined, 0, /* ed80 */ undefined, 0, /* ed81 */ undefined, 0, /* ed82 */ "otim", 0, /* ed83 */ undefined, 0, /* ed84 */ undefined, 0, /* ed85 */ undefined, 0, /* ed86 */ undefined, 0, /* ed87 */ undefined, 0, /* ed88 */ undefined, 0, /* ed89 */ undefined, 0, /* ed8a */ "otdm", 0, /* ed8b */ undefined, 0, /* ed8c */ undefined, 0, /* ed8d */ undefined, 0, /* ed8e */ undefined, 0, /* ed8f */ undefined, 0, /* ed90 */ undefined, 0, /* ed91 */ undefined, 0, /* ed92 */ "otimr", 0, /* ed93 */ undefined, 0, /* ed94 */ undefined, 0, /* ed95 */ undefined, 0, /* ed96 */ undefined, 0, /* ed97 */ undefined, 0, /* ed98 */ undefined, 0, /* ed99 */ undefined, 0, /* ed9a */ "otidr", 0, /* ed9b */ undefined, 0, /* ed9c */ undefined, 0, /* ed9d */ undefined, 0, /* ed9e */ undefined, 0, /* ed9f */ "ldi", 0, /* eda0 */ "cpi", 0, /* eda1 */ "ini", 0, /* eda2 */ "outi", 0, /* eda3 */ undefined, 0, /* eda4 */ undefined, 0, /* eda5 */ undefined, 0, /* eda6 */ undefined, 0, /* eda7 */ "ldd", 0, /* eda8 */ "cpd", 0, /* eda9 */ "ind", 0, /* edaa */ "outd", 0, /* edab */ undefined, 0, /* edac */ undefined, 0, /* edad */ undefined, 0, /* edae */ undefined, 0, /* edaf */ "ldir", 0, /* edb0 */ "cpir", 0, /* edb1 */ "inir", 0, /* edb2 */ "otir", 0, /* edb3 */ undefined, 0, /* edb4 */ undefined, 0, /* edb5 */ undefined, 0, /* edb6 */ undefined, 0, /* edb7 */ "lddr", 0, /* edb8 */ "cpdr", 0, /* edb9 */ "indr", 0, /* edba */ "otdr", 0, /* edbb */ undefined, 0, /* edbc */ undefined, 0, /* edbd */ undefined, 0, /* edbe */ undefined, 0, /* edbf */ undefined, 0, /* edc0 */ undefined, 0, /* edc1 */ undefined, 0, /* edc2 */ undefined, 0, /* edc3 */ undefined, 0, /* edc4 */ undefined, 0, /* edc5 */ undefined, 0, /* edc6 */ undefined, 0, /* edc7 */ undefined, 0, /* edc8 */ undefined, 0, /* edc9 */ undefined, 0, /* edca */ undefined, 0, /* edcb */ undefined, 0, /* edcc */ undefined, 0, /* edcd */ undefined, 0, /* edce */ undefined, 0, /* edcf */ undefined, 0, /* edd0 */ undefined, 0, /* edd1 */ undefined, 0, /* edd2 */ undefined, 0, /* edd3 */ undefined, 0, /* edd4 */ undefined, 0, /* edd5 */ undefined, 0, /* edd6 */ undefined, 0, /* edd7 */ undefined, 0, /* edd8 */ undefined, 0, /* edd9 */ undefined, 0, /* edda */ undefined, 0, /* eddb */ undefined, 0, /* eddc */ undefined, 0, /* eddd */ undefined, 0, /* edde */ undefined, 0, /* eddf */ undefined, 0, /* ede0 */ undefined, 0, /* ede1 */ undefined, 0, /* ede2 */ undefined, 0, /* ede3 */ undefined, 0, /* ede4 */ undefined, 0, /* ede5 */ undefined, 0, /* ede6 */ undefined, 0, /* ede7 */ undefined, 0, /* ede8 */ undefined, 0, /* ede9 */ undefined, 0, /* edea */ undefined, 0, /* edeb */ undefined, 0, /* edec */ undefined, 0, /* eded */ undefined, 0, /* edee */ undefined, 0, /* edef */ undefined, 0, /* edf0 */ undefined, 0, /* edf1 */ undefined, 0, /* edf2 */ undefined, 0, /* edf3 */ undefined, 0, /* edf4 */ undefined, 0, /* edf5 */ undefined, 0, /* edf6 */ undefined, 0, /* edf7 */ undefined, 0, /* edf8 */ undefined, 0, /* edf9 */ undefined, 0, /* edfa */ undefined, 0, /* edfb */ undefined, 0, /* edfc */ undefined, 0, /* edfd */ undefined, 0, /* edfe */ undefined, 0, /* edff */ /* fd */ undefined, 0, /* fd00 */ undefined, 0, /* fd01 */ undefined, 0, /* fd02 */ undefined, 0, /* fd03 */ undefined, 0, /* fd04 */ undefined, 0, /* fd05 */ undefined, 0, /* fd06 */ undefined, 0, /* fd07 */ undefined, 0, /* fd08 */ "add iy,bc", 0, /* fd09 */ undefined, 0, /* fd0a */ undefined, 0, /* fd0b */ undefined, 0, /* fd0c */ undefined, 0, /* fd0d */ undefined, 0, /* fd0e */ undefined, 0, /* fd0f */ undefined, 0, /* fd10 */ undefined, 0, /* fd11 */ undefined, 0, /* fd12 */ undefined, 0, /* fd13 */ undefined, 0, /* fd14 */ undefined, 0, /* fd15 */ undefined, 0, /* fd16 */ undefined, 0, /* fd17 */ undefined, 0, /* fd18 */ "add iy,de", 0, /* fd19 */ undefined, 0, /* fd1a */ undefined, 0, /* fd1b */ undefined, 0, /* fd1c */ undefined, 0, /* fd1d */ undefined, 0, /* fd1e */ undefined, 0, /* fd1f */ undefined, 0, /* fd20 */ "ld iy,%02x%02xh", 2, /* fd21 */ "ld (%02x%02xh),iy",2, /* fd22 */ "inc iy", 0, /* fd23 */ undefined, 0, /* fd24 */ undefined, 0, /* fd25 */ undefined, 0, /* fd26 */ undefined, 0, /* fd27 */ undefined, 0, /* fd28 */ "add iy,iy", 0, /* fd29 */ "ld iy,(%02x%02xh)",2, /* fd2a */ "dec iy", 0, /* fd2b */ undefined, 0, /* fd2c */ undefined, 0, /* fd2d */ undefined, 0, /* fd2e */ undefined, 0, /* fd2f */ undefined, 0, /* fd30 */ undefined, 0, /* fd31 */ undefined, 0, /* fd32 */ undefined, 0, /* fd33 */ "inc (iy+%02xh)", 1, /* fd34 */ "dec (iy+%02xh)", 1, /* fd35 */ "ld (iy+%02xh),%02xh",2, /* fd36 */ undefined, 0, /* fd37 */ undefined, 0, /* fd38 */ "add iy,sp", 0, /* fd39 */ undefined, 0, /* fd3a */ undefined, 0, /* fd3b */ undefined, 0, /* fd3c */ undefined, 0, /* fd3d */ undefined, 0, /* fd3e */ undefined, 0, /* fd3f */ undefined, 0, /* fd40 */ undefined, 0, /* fd41 */ undefined, 0, /* fd42 */ undefined, 0, /* fd43 */ undefined, 0, /* fd44 */ undefined, 0, /* fd45 */ "ld b,(iy+%02xh)", 1, /* fd46 */ undefined, 0, /* fd47 */ undefined, 0, /* fd48 */ undefined, 0, /* fd49 */ undefined, 0, /* fd4a */ undefined, 0, /* fd4b */ undefined, 0, /* fd4c */ undefined, 0, /* fd4d */ "ld c,(iy+%02xh)", 1, /* fd4e */ undefined, 0, /* fd4f */ undefined, 0, /* fd50 */ undefined, 0, /* fd51 */ undefined, 0, /* fd52 */ undefined, 0, /* fd53 */ undefined, 0, /* fd54 */ undefined, 0, /* fd55 */ "ld d,(iy+%02xh)", 1, /* fd56 */ undefined, 0, /* fd57 */ undefined, 0, /* fd58 */ undefined, 0, /* fd59 */ undefined, 0, /* fd5a */ undefined, 0, /* fd5b */ undefined, 0, /* fd5c */ undefined, 0, /* fd5d */ "ld e,(iy+%02xh)", 1, /* fd5e */ undefined, 0, /* fd5f */ undefined, 0, /* fd60 */ undefined, 0, /* fd61 */ undefined, 0, /* fd62 */ undefined, 0, /* fd63 */ undefined, 0, /* fd64 */ undefined, 0, /* fd65 */ "ld h,(iy+%02xh)", 1, /* fd66 */ undefined, 0, /* fd67 */ undefined, 0, /* fd68 */ undefined, 0, /* fd69 */ undefined, 0, /* fd6a */ undefined, 0, /* fd6b */ undefined, 0, /* fd6c */ undefined, 0, /* fd6d */ "ld l,(iy+%02xh)", 1, /* fd6e */ undefined, 0, /* fd6f */ "ld (iy+%02xh),b", 1, /* fd70 */ "ld (iy+%02xh),c", 1, /* fd71 */ "ld (iy+%02xh),d", 1, /* fd72 */ "ld (iy+%02xh),e", 1, /* fd73 */ "ld (iy+%02xh),h", 1, /* fd74 */ "ld (iy+%02xh),l", 1, /* fd75 */ undefined, 0, /* fd76 */ "ld (iy+%02xh),a", 1, /* fd77 */ undefined, 0, /* fd78 */ undefined, 0, /* fd79 */ undefined, 0, /* fd7a */ undefined, 0, /* fd7b */ undefined, 0, /* fd7c */ undefined, 0, /* fd7d */ "ld a,(iy+%02xh)", 1, /* fd7e */ undefined, 0, /* fd7f */ undefined, 0, /* fd80 */ undefined, 0, /* fd81 */ undefined, 0, /* fd82 */ undefined, 0, /* fd83 */ undefined, 0, /* fd84 */ undefined, 0, /* fd85 */ "add a,(iy+%02xh)", 1, /* fd86 */ undefined, 0, /* fd87 */ undefined, 0, /* fd88 */ undefined, 0, /* fd89 */ undefined, 0, /* fd8a */ undefined, 0, /* fd8b */ undefined, 0, /* fd8c */ undefined, 0, /* fd8d */ "adc a,(iy+%02xh)", 1, /* fd8e */ undefined, 0, /* fd8f */ undefined, 0, /* fd90 */ undefined, 0, /* fd91 */ undefined, 0, /* fd92 */ undefined, 0, /* fd93 */ undefined, 0, /* fd94 */ undefined, 0, /* fd95 */ "sub (iy+%02xh)", 1, /* fd96 */ undefined, 0, /* fd97 */ undefined, 0, /* fd98 */ undefined, 0, /* fd99 */ undefined, 0, /* fd9a */ undefined, 0, /* fd9b */ undefined, 0, /* fd9c */ undefined, 0, /* fd9d */ "sbc a,(iy+%02xh)", 1, /* fd9e */ undefined, 0, /* fd9f */ undefined, 0, /* fda0 */ undefined, 0, /* fda1 */ undefined, 0, /* fda2 */ undefined, 0, /* fda3 */ undefined, 0, /* fda4 */ undefined, 0, /* fda5 */ "and (iy+%02xh)", 1, /* fda6 */ undefined, 0, /* fda7 */ undefined, 0, /* fda8 */ undefined, 0, /* fda9 */ undefined, 0, /* fdaa */ undefined, 0, /* fdab */ undefined, 0, /* fdac */ undefined, 0, /* fdad */ "xor (iy+%02xh)", 1, /* fdae */ undefined, 0, /* fdaf */ undefined, 0, /* fdb0 */ undefined, 0, /* fdb1 */ undefined, 0, /* fdb2 */ undefined, 0, /* fdb3 */ undefined, 0, /* fdb4 */ undefined, 0, /* fdb5 */ "or (iy+%02xh)", 1, /* fdb6 */ undefined, 0, /* fdb7 */ undefined, 0, /* fdb8 */ undefined, 0, /* fdb9 */ undefined, 0, /* fdba */ undefined, 0, /* fdbb */ undefined, 0, /* fdbc */ undefined, 0, /* fdbd */ "cp (iy+%02xh)", 1, /* fdbe */ undefined, 0, /* fdbf */ undefined, 0, /* fdc0 */ undefined, 0, /* fdc1 */ undefined, 0, /* fdc2 */ undefined, 0, /* fdc3 */ undefined, 0, /* fdc4 */ undefined, 0, /* fdc5 */ undefined, 0, /* fdc6 */ undefined, 0, /* fdc7 */ undefined, 0, /* fdc8 */ undefined, 0, /* fdc9 */ undefined, 0, /* fdca */ "fd cb %02x,%02x", 2, /* fdcb */ undefined, 0, /* fdcc */ undefined, 0, /* fdcd */ undefined, 0, /* fdce */ undefined, 0, /* fdcf */ undefined, 0, /* fdd0 */ undefined, 0, /* fdd1 */ undefined, 0, /* fdd2 */ undefined, 0, /* fdd3 */ undefined, 0, /* fdd4 */ undefined, 0, /* fdd5 */ undefined, 0, /* fdd6 */ undefined, 0, /* fdd7 */ undefined, 0, /* fdd8 */ undefined, 0, /* fdd9 */ undefined, 0, /* fdda */ undefined, 0, /* fddb */ undefined, 0, /* fddc */ undefined, 0, /* fddd */ undefined, 0, /* fdde */ undefined, 0, /* fddf */ undefined, 0, /* fde0 */ "pop iy", 0, /* fde1 */ undefined, 0, /* fde2 */ "ex (sp),iy", 0, /* fde3 */ undefined, 0, /* fde4 */ "push iy", 0, /* fde5 */ undefined, 0, /* fde6 */ undefined, 0, /* fde7 */ undefined, 0, /* fde8 */ "jp (iy)", 0, /* fde9 */ undefined, 0, /* fdea */ undefined, 0, /* fdeb */ undefined, 0, /* fdec */ undefined, 0, /* fded */ undefined, 0, /* fdee */ undefined, 0, /* fdef */ undefined, 0, /* fdf0 */ undefined, 0, /* fdf1 */ undefined, 0, /* fdf2 */ undefined, 0, /* fdf3 */ undefined, 0, /* fdf4 */ undefined, 0, /* fdf5 */ undefined, 0, /* fdf6 */ undefined, 0, /* fdf7 */ undefined, 0, /* fdf8 */ "ld sp,iy", 0, /* fdf9 */ undefined, 0, /* fdfa */ undefined, 0, /* fdfb */ undefined, 0, /* fdfc */ undefined, 0, /* fdfd */ undefined, 0, /* fdfe */ undefined, 0, /* fdff */ }; int curaddr = 0; long int inline1; long int index1; char linebuf[1024]; FILE *filein; int hexbuf[1024]; int main (int argc, char *argv[]) { int i, j, arg1, arg2; struct opcode *code; int addr; filein = fopen(argv[1],"r"); for (;;) { i = gethex(); addr = curaddr; if (!major[i].name) { j = major[i].args; i = gethex(); while (!minor[j][i].name) { j = minor[j][i].args; i = gethex (); } code = &minor[j][i]; } else code = &major[i]; printf ("%04x\t", addr); switch (code->args) { case 2: printf (code->name, gethex(), gethex()); break; case 1: printf (code->name, gethex()); break; case 0: printf (code->name); break; } putchar ('\n'); } } int gethex (void) { if (index1 == inline1) { again: ; if (fgets(linebuf,1024,filein) == NULL) exit(0); /*if (gets (linebuf) == NULL) exit (0);*/ linebuf[strlen(linebuf)-1] = 0; if (strlen (linebuf) < 9) goto again; inline1 = fromhex (linebuf+1); xind = fromhex(linebuf+3); xind = (xind << 8) | fromhex(linebuf+5); curaddr = xind-1; for (index1 = 0; index1 < inline1; index1++) hexbuf[index1] = fromhex (linebuf+9 + 2 * index1); index1 = 0; if ((index1 == 0) && (inline1 == 0)) exit(0); } ++curaddr; return hexbuf[index1++]; } #define hexval(c) (('0' <= (c) && (c) <= '9') ? (c) - '0' :\ (('a' <= (c) && (c) <= 'f') ? (c) - 'a' + 10 :\ (('A' <= (c) && (c) <= 'F') ? (c) - 'A' + 10 :\ -1 ))) int fromhex (char *c) { return hexval(c[0]) * 16 + hexval(c[1]); }   !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrB,C ~ExpressLoadB(e,E X1q,E yyparseO!@!,E lbsd !(t,E gnolib 0E ")"/""&H; [+;ik;8 [ d a)) J))H))hh "!))))    +;ikline buffer overflow;8 [{iHh h 0x;**hh {"!J iH  8:h)H****h  {i H"+;ikemit buffer overflow;8 [) )# n)H "xH"xH"n)H "xH" "xH"y0 ɀ n)H "xH"A"xH "xH"  mH`zz9z  ) "xH" " ) "xH" "0 ɀ  "0 ɀ  "_ )!"xH "xH""xH "  {H`)  +;ikH; [)i H"xH"i H"+;ik;8 [ 8h)::n)n)0 n)ɀ n)H "  +;i k;8 [)*)@))))  ))H))hh"  +;ik;8  [)*)z;))H8hh)Hhchch);))H8hhh #|)z)H:"|)z)H )H";|)z)H)"x)H";|)z)H))H";|)z)H";)"xm)e ;))H8hh)Hhchch); ))hh$|)z)H)H";)e  |)z)H8 )H";|)z)H ";))+;i k;8 [ )JJJJ)D)H" )D)H" +;i k;8 [))",)Q" 3"m X))) ;HZ T)R)H"nT)R)H"x)H";T)R)H)H";T)R)H` ": **hh;: 8hh"nT)R)H)H"; : 8hh8hhh 0:T)R)Hc " T)R)H "T)R)H"*)<: **hh)H"4 Ω: *) **hh"m X))T)R)H "T)R)Hf "d 0< **hhT)R)H)H"; T)R)H "E " " :**H8hhh)Hhchchh):**))+;ik%4d: H; [)<.Z))T)R)H "T)R)H "))I))H **Hr)p)iHr)p)iH T)R)H"n))+zk %s %s %s Page %d ;8 [)>" 7Z))T)R)H ")0A)T)R)H ")+;ik;8 [)0" )d 8pI0"m T)R)H "٥ +;i k;8 [\)))d0)"   ٤+;ik;8 [d0 g)W ("m T)R)H2)H"T)R)H "   0\))" T)R)H"7 +;i k;8 [ ZH)H H"nH"7  +;ik%d: %s error %s ;8 [",)))))T" G"m X))) ;H T)R)H"n T)R)H"n" " +;ik%4d: %s;8  [))V))d))) *)dj~)) )Vd d0 ) 止)W)) *) d+;i k;8 [)) "")  +)l)"d~x֒ ))H hh ="!)A)[ʊ) )i H  hh  ")  $)+)R)+)>֒ 8hh"n 咅  h  ))$".X))))H"7֒ ))H hh ="!)H"ӰH  hh  ")  $))Б))  h  )c     r   ^   J  88b H`xx֒ )90WH)8  )  ޑH"n' ޑ ) 5ޑ.)H H"ihchchh ޑ )0ޑ# ))))H"))H"))'֒  ")     ")  '))  ֒ 8hh"n֒ޑ6֒ 8hhhh6֒  h)ޑ)) ޑA֒  h)ޑ@  h   ' ))hh"!)9'_;F H`|   X+;ikstring buffer overflow;8 [d8pIRe" "i 4 i  H H֒"$0:d֒ )  h)eܥ" "i$= i  Q H H֒"))H i  zhhh $= dt)t)0ɼ S"!֒"1H"ڇ h   ֒ H H")))n 66n 5H))H))hh g"!))))  " ޑ +;ikitem table overflowToo many ifs;8 [ "i$=i  "i$= i  H h Hh Hh Hh h    +;ik;8  [8pI0  "&=$=ZH "&=$=ZH"0  "&=$=ZH "&=$=ZH"ѥ 8pI0 "t "t :H"' H"'  +;ik;8  [)))v) x)9x)v))!x)v)v)x))H",yv)x))"V "V8A 8pI0ʊ8 pI0ʊʆ* m *m*' m *m*x)v) "V8A 8pI0ʊ8 pI0ʊʆ* m *m** m *m*x)v)a* *ihH "x)v)> ",_)])H"  O)J) j:h:ZH"à) .,ZH"Ξ)) j:h:_)])_)])H" ) ;0! ~) ) ;IH) h; ~) )+" $"m ) .,ZHT)R)H"n ) ; ",+;i k**** %s **** ;8 [ " +;ik;8 [T)R)j:h:_)])d  8 pI0z ee)-x eeHHh)5 ee) * *) } *) p *) c Q) W V) M ) C )W) 6 X) , Y) " Z)  [)  \) ~ "!j8L)) H`8".BOYcmw  ee))))H" " "H])_)hh "!)_)])H) hh:hj:) h,h. "! u "!))H9" 9"*)? 9"Hz)|)hh "!V))kY))c))H;" ;" ;"HR)T)hh "! T)R)))H;" !;"!;"ǘl)j) l) !"!)"U)"r)p)r)p)i  r)p)i  )) **",!")$=8 ʅ i  ))hhh<J.@$68- H`l",!_)])H"a"*)"|)z)H:"))s|)z)H";|)z)H)"x)H";|)z)H))H";|)z)H";|)z)H)H"xI8i8)H";d 0 |)z)H0" |)z)H "|)z)H"7V)) T)R)H"7) ) ))H"A*)"$V)) [))"/"V))" T)R)H"7"+;ikUnknown option.zrCannot open source fileToo many argumentsNo source file.hexwCannot create binary file.lstwCannot create list file.tmpw+Cannot create temp file;8 [))H) h;):**))③))Y))))  h)))d0   +;ik;8 [))  '"T)R)H"nT)R)H"7 +"H"n"  +;i k%s %s ;8 [t)$=8 ʅ $= ))hhg $t)I @i   ( H h Hh Hh Hh i  yi  F$ht):H"'H$*h *t)i"im)0<" "m ]$T)R)H"n)i)d8pI0d0"et)8pI0 "i$=i   -/ =  +   )HH)HHHp$T)R)H"nN"m T)R)H "#+;ik{** Symbol Table ** Symbol Table: %-15s%c%4x%c ;8  [)02" "m d d0  e  2T)R)H&" /&T)R)H"n)i)T)R)H;&")i)d0 @ 3"m  ZH2)H HK&T)R)H"n)07" "m t)H_&T)R)H"n)Hm&T)R)H"n)))i)05" "m )Hx&T)R)H"n)H&T)R)H"n)"H&T)R)H"n)i)+;i k Error report: %6d errors Statistics: %6d %c -- %s error %6d symbols %6d bytes %6d macro calls %6d macro bytes %6d invented symbols ;8 [ a) " +) ) )H"*" d 璅 ))H hh ="!  h  0N 8ApI0ʊ[8 pI0ʊ  i H h ֒ " +)Q +)A ֒  h  璅 ". ?&)  h)H"*܀Kޑ)? "*"*ޑiA)H"* >[V) "" EF )  )H"*"  (H`r(((&&&(  " ) "* "*"*d 05 "*=? "i$=$ a) +;ik;;D֒JIV^_TUeifZ>\]CDn\]cono> \]ClD q\]r A> gC5D eif A> gCgD n\]oA>kRCDA>QCSD KE>}CDOFAXpdxv>ACDA7#!%(+,-)$'*"& 7\] A~9?./08;<=@eifB79?1:>8;<=@CDBeif7 23:9?48;<=@eafBeif79?:A>8;<=@CDBV7:TU9?78;<=@B>9?:ACD8;<=@9?B78;<=@:>B{CD:A>9?CD8;<=@>LBCD:GA>CDA>7CDAVTU9?A8;<=@BA7:VzU9?g8;<=@7B:m79?8;<=@B7[s:9?78;<=@B9?:78;<=@9?B78;<=@:B9?:8;<=@9?B8;<=@:B:beifn\]o|eifn\]ohjy6HMNPWY`tuw BEFIMPUVO     %&'();>      %&'();> PRVZ0]a'gil@p(v'{}?/''+()Ė ̖ϖ Ԗ֖ٖ8ߖ8%6>*  88 v 5F "&7.27;@ C FJM PRUY^bg8l8!n:t9x9|81"D84 !"&0!×(!Ɨ ̗ !ϗӗؗڗޗMEo g7!7%)2-315088>BFJ7P(!R)W7\`"   U,;Ln6ip             Symbol too long0123456789ABCDEF5678$<,0-./ %(;     &')>*+9:,#@-./$$0[4+- :: (!"((( (A +-/*1&|^23= $ =,,,,,,,,,,,,,,,,,,,, ,] , ,)))())A()(() ),,, )'))0123456789ABCDEFHOQabcdefhoq3KOz{|}~ P Tklmnij[#XYZ\%[&*`aef+bcd024IJLMoqrsNtv QSUW -./!()"'gh $]_,1568;y:?<=>@wxADGpuRV^ 79CEFHBbju|0gGKO(MEakwkuktsrkkj/=kikeda`]TMJAkkk8k/k!(npE-h--~K|{q[[nkkkkkRkk'k&~"^ lUNJaadcaddafandasciibbcbitblockbyteccallccfcmpcpcpdcpdrcpicpircplddaadedecdefbdefldefsdefwdephasedidjnzeeiejectelistendendifendmequexexxfflistglisthhalthliifiminincincludeindindriniinirixiyjmpjpjrlldlddlddrldildirlistmmacromaxminmlistmodncnegnolistnopnotnvnzororgotdrotiroutoutdoutippephasepopoppushrresretretiretnrlrlarlcrlcarldrrrrarrcrrcarrdrstrsymsbcscfsetshlshrslaspspacesrasrlsubtitlevwordwsymxorzBalanceExpressionFormatDigitMult. def.PhaseUndeclaredValuePhase/Dephase""/""&;8 [ں'H"hHRTʠhhZʆ)'ZTRXVPNʆ+;ik;8 [R T"ںTRH"hd   +;ik;8  [TRHZ"!cXVhhںZi'HTRH"+hH  ʠhh+ںH"hDZi'ZXV8RT"!e HVXhh TR))HXVh  )VXXVPN +;ikmio: out of memory ;8 [PNHXVhh XVVX)  +;i k;8 [(ںH "h, "ihmRHmTVXhhd+;ikmseek() only implemented with 0 origin;8  [d  ʊPNHXVH"!czhhhqںHXVH"h"!eHhhXVH"!cVXhh <   +;ik;8 [d  ʊTRHZ"!c"mVmXhhںZi'HTRH"+hH  ʠhh+ںH9"h&DZi'ZXV8RT"!e HVXhh TRTRHZ"!c"mVmXhhںHPNH"h"HheHehh"mNmPPNPNXV +;ikmio: out of memory ; [uwy"+;ik; [KHH"-  ?@ Z[    19d 208d +;ikSun Mon Tue Wed Thu Fri SatJan Feb Mar Apr May Jun Jul Aug Sep Oct Nov DecSun Jan 00 00:00:00 1900 8 i H 00` ŲL ;8 [KH H"-H H"7d  '    )\ "-/i35  P)"9 '" #" 1HH"!  %" # )@ H H"H H" ii d  +;i k;8 [KHH"p)d٢ۢ ݢ8ۢߢݢ ߢ" ע HH ٴHH"  )d+;ik;8 [K ʹ ͶHH"7HH"7 ) ) )   H H ٴ   ,  c /{i-13  - / 1 3 + =K" )?L 5 7    ) -m5 /m7    5 7   5 7 U i  i )8   :  )    I   )   +;i kѥ". " )"- ϥ &  5  Ȍ5 "` ` . ;8 [Kdd)awr 8HH"  ^ ȷ  6 4" 0=r ^ Z X" V " 0 2w2N" LBX=a62H" B""  HH"ȥ ȩ)+bȷ)+arQI^ ȗ2 H H"+;ik)+88`b^8``KzhhZګHH" Vڨ;iH"W8hihz;oZګkKhzHګHHZ"k;8 [ )   2   7 H"  H"XH H ٴ  )    H H"7 i ȷ i  8  ȷ :      )  ) H H"7  +;i k;8 [ H H"'d H H)H"hh  +;i k;8 [KHH"HH"7} " { m m HH"e e " { ́  " a " Kg7ȗ Ȋd +;i kHH ٴ;8 [K HH"d HH"7W'" % HH ٴ8+)$8ȥ)  +;ik; [KE Λ Ο ۭ:٭8HH<"hhhhHH<"ihh8ѭHH<"hhhhHH<"ihh8ӭHH"hhhhHH"ihh8խ׭ѭ"Dѭ+;ik; [HH J     z +;i k;8 [K F   8HHQ"hhhh HHQ"hhhhiHH"hhhh   +;i kKzhhZګ;iH"W8h絛ihz;mZګkhzHګڮ ;[)+hhKk; [       +;ikHH; [    +;i k; [  +hhk; [KHHHH ")))덛))h)hhh  +;ikh) kk ;[8$eʧ8;ID;o$+zhhZګkH Ųh\ KzZڭHH; ["v]i # " Ȁ " Ȁ  òZ8czHHHH "* Out of memory±"\ h h  mò  Ȁ   )s  "   i  ")0"!)    +hhkKHH ;[$hHHhk֯ "à+hh`; [ ȊwHwhȷ+;ik H" H"HH" H"H" kraa"7 `R"9 P!\n" fl`Z n.CONSOLE Jk8jkKHH; [  8+hhzhhZګk; [ +hzzH`;8 [ H H"1H" H H HiH"  +;i kK ;[)%H"  +k   W). W)l Lh )@ݥ Y_|)-,0"+ + #8``)*`)0:)H mc%n:s8bYpcXxoiudξiξfeEgG\HHH"zhZګk(((((‚ĄHHm"ihhmmHH"ihhmm8ελXHH"ihhiHH "hhhh8JJmi,HHd"hhhhHH"ihhHH"hhhh88cεHHQ"ihhHH"ihhmmHH<"ihhmmmm`;8 [Kdd)awr O [ȷ [ -w" ?X:a3{" yXз}" ""  HH"ȥ ȩ)+bȷ)+arQI ȗ+;ik)+8`b8``;8 [KHH"  ) w  HH"  _ @@ HH"7 ȥ  ȥȗd+;ik %"4 6 6 Q T0RNnnnjJJJJ 0:i 6    ˭ X 600 HH ȷ  HH ) 8 Z)H"zhih " H"!8  I-HH S '" &"[ 0/ [' S S 8R  8I0 H" H"H"00 H" 0"ȹ ) SZ )H"zȀ HH hih ` Q T0R   !NnnnjJJJJJ 0 R0 0Q`0 "`€œ] ]  I- 8]_] HHa "]a  "]0 e 0 0 °0 eE 0 )  P T_610  0 : . 蘼 0 )8I0 H"00 0" ) Z)H"zi Y0 . # e 0 8. 0` `TÀTí _] HHa "Ie)mc:VT8VÂL[; [íȍ" +;ikL; [íȍ" +;ik; [8","?+hhk " "#hhkHH; [KĜĥ  HH"zH H"Ďĥ `Z Ďĥ J      HH" +;i kHHH8H; [  " % Q8  0 "* "* "e i @< "* "*   "Z "*",+;i kHH8H; [ȷȷ HH"+hhhhkIH7IHZ; [*8e쪥I+zzzkh@k;8  [@g"" && & 8   *8e 8+;i k C hhhhkH; ["ȿ+hhkKɍ"p 8Ik@kK0?RɣPɣ ThVhX"XHVHpT  8P R k@k{;8[:ڥJ       {i +k ;8[IȅIdFejfFejfFejfFejfFEejfFejfFejfFejf2-I;i+ke &****;i+@k;8  ["' ʂOJ  e e f f ff` ʥ  d Fejf)  @8 +;ikHiH;8  [  " O$>"#ȩȗ na i  U GE "*F e i  " "8  0 E  "*) i+;ikiHHHHH@@H "hh) kHH; [ȗȗȥȥȩ i+zzzzk;8  [ "["" && & 8   *8e 8 +;ik; [  )8 I"@ )L  ! )H"X  ( "X )H"   " +;i kH""""h") "HHHHH; ["  ȷݠȷ ȷ+;i k 0 Jk; [ f fdd  !& +hhkd8d d 8kH ;[FeFeFeF/eFeFeFeFe+ke+kHZ"""p""kKȍ" ȍ" ȍ" kKǜȜȜ "Ȝȭȍ}"9 {!ٙ" Ѝ " "ȫk .CONSOLEK ĜĜĜŜŜŜŜŜŜŜūkH"3\K Error occurred at line "H"b in procedure """  "X "X Line Namet" ---- ----" BH"b """HH;H" ;[+hhk"+H"k e;[ 8)e"+hkSubrange exceededFile is not openRead while at end of file I/O error Out of memoryEOLN while at end of file Set overflow&Jump to undefined case statement labelInteger math errorReal math error UnderflowOverflowDivide by zeroInexactStack overflow Stack error H "hHiĢ " k  " kKzhhh Zګk:JJJJk;8  [d ȥ"7 HH HHHӢ"0" "zj ԍԍԧԍԩ " $"8 ԅ" ԅHH"  +;i k(KϜϢ&kH ;[ "X "+hk; [ԥ "ԥHHH" +hhhhkKHH; [$ňHH"+hhkH( &"L ;[  8(I ȗ(  @+hhk t e -5@NVh %7EMXdv+=EXgq !\q]qj(B`*?Ny *3Vntze"y,u4b}R[|gq}$ Qcp~G$F<\Df f +>Mdv~5IUah 9=O$3 #Rhl&}!ieF["Ynbhn| UN LV`6Fz 1CJTZbh 5L@x *e} GNW_em~,Q (CVh?nQzE_ *JivB#;Qoo FRi !IQ#r '15FLS+07=BGLZp| 8Yis @SWip#'Ytq}KXnP)+ >LOTWqx{~ADGL "moqsuwy {}=BLORWfinq /27ILQ\_kv%+.Uj &)Kcf+ANS^chpv} !$'*-0369<9 (2ADe{~ =X`hmr *uyYw#CILORUX[^enqtw~/37:=@CFILQV_ov}:>Dw mw(@DKN#(wz 25JM^ '6>KXmt 4 "'*-036>CGVZ^dilp) "%)/47;JNQUdhlorux{~ "?BX[^as  '*/w|.69>IUbpvy| +MRjpvy& '*38;AM]civ}"  '*25?GUZf #'18=@LOYadg47Z]ps  '+1=D} #-036HK`cmw 4G[^8 JMPW\_i /28iun;{;;~;;(;Z ` :H:}:c :0:f :3 :?       H Z ` -\^lʃLvj/)AJey ֒ =^֒֒=!֒R֒֒֒֒ ֒B֒e 4v֒֒$=֒?$=aSk֒֒g$=$=~ 6@ FP V   9 9  9> `;j p;z ; ; !;!;!))q$=O!:[!g!s!Y!!'"!+"@"$=V"$="F$#H$A#]$#$= $p$$&$/&$;&D%K&t%_&%m&%x&%&%&& '='+)$= 4P4R!4V+4Z54]?4aI4gS4i]4lg4pq4v{4{4}444444444444555%5/5Ė95̖C5ϖM5ԖW5֖a5ٖk5ߖu5555555555 55556 66"6&)6.362=67G6;Q6@[6Ce6Fo6Jy6M6P6R6U6Y6^6b6g6l6n6t6x6|6777#7-777A7K7U7_7i7s7}7777×7Ɨ7̗7ϗ7ӗ7ؗ7ڗ7ޗ777 888'818;8E8O8 Y8c8m8w88!8%8)8-8185888>8B8F8J8P8R9W 9\9`bju|𚑂𞑍𢑓𦑞𪑤Mc 9%ڨѭѭKұ±ڲݲ}ɳ̽ ͽ  | } >]JaZ]`af   ]a1 Dtі5efr610E yyparse1;8 [ ֒ ֒֒ޑ"+) f" *" * *,v *=k֒ ֒ "U)  =?"') *=  h   ' ))hhj=="!֒ ֒ )"2) *=  h  "ʥ å  , ))hhЂ2   ' , ;o?+;ik;8 [ )" ).  h) "+;ikH; [)l)j)H)H"+;ik;8 [))l)j)H"%dH"n+;ikbad macro read ;8 [d0d m *m*HHhh& m *m*HH"* *id))* *H"΢)): ZHh *h*))Hl)j)H"))hh )ζ)δ)+;ik;8 [) 0 i1  iaH = ="3 = =  +;i k?%c%04d;8 [֒֒" 0 "Ƀ d 8 pI0z "$".$WHޑihHޑih:ޑim) v֒֒ " 0:")e )l)j)H ֒֒"¥+;ik;8 [֒֒ "0D$= $= ))hh# $  t) i   **H"t) "$= $= ))hhN 9 Hh Hh  H H" " i  l)j)H"l)j)H֒֒"30:H֒֒"ƥ+;ik;8 [  h)H  hh  ) 0:  h  ڥ+;ik;8j [) "!pn"H])_)hh$pn{iH"3{iH"!)!" "m pnT)R)H"n~))) ;IH) h;~))HQ)) ~) _)])H)) hh:hj:) ;pn"1H"H) h,h.pn) .,ZH"lpko+;inkToo many nested includesrCan't open include file: %s**** %s **** ;8( [ H"")) H""))) )) )/"&))8ʍ))))8ʍ)))*))))) ))))) ))) Hhm)Hm)izhhh8h)H)"h 8h)H)"h 8h)H)"h i H"))H"+)) H"))H"+))) )) )/"% m)m) m) m) m)m)  i  UU"Z i)0"K )0)m)0 0r; * ͖)()UޑTUޫ)0:μ)  L)0"K )0)33! i!!iH!h0 ͖)נ0))H"))H"d#)#/")))HhhQ i0&0r *   *88  ))H"))H"") ))H"))H"")# ( H`F P P 1 *   ;%)%"x%UU% H 8hh hiH"Z .9 :H% H8hhhc0r * HI8 : *%"x%UU% H 8hh hiH"Z .9 :H% H8hhhc0r * HI8 : *))) ))*#0"! 0H"n ) ) ) "K )h)H")) 8ʅHHhh h)H"" N h)H"C 8 ʅ' 8 ʅi- 8ʅH 8 ʅih^ 8 ʅi0.'8$  SH`           8ʅH"G 8 ʅ' 8 ʅi/ 8ʅH 8 ʅih` 8 ʅi00'8$  OH` 8ʅH"I 8ʅ' 8ʅi/ 8ʅ 8ʅH 8 ʅz8pI0ʊ 8ʅ 8 ʅH 8ʅihH" 8 ʅH 8ʅz8pI0ʊ 8ʅ 8 ʅH 8ʅihH" 8ʅi0 8ʅH"0'8$  tH`:))H))hh "0"! )n)))))H))))h  )))H))iI8 ))H))hh /0"!))iIH))))h  ))iIH))))h  *)) * ))iH")) * ⑩ͮ))  )ΰ)ή)" h)H") ) 8ʅ) 8ʅH")V 8ʅ0 h)H" 8ʅ" 8ʅmh)h))"  8ʅ'))֒֒f)d) **f)d)d)f))H *** *h  )& **Hޑޑhh **  **k)d֒֒"X֒֒"1H"))֒֒))H"(֒֒"I' H`=0H"n  h)H" 8ʅHHhh)))) 8ʅ' 8ʅ0 ~) 8ʅ0: ~)  8ʅ"  8ʅm)0<"  8ʅH"s T)) * 8ʅ0 * 8ʅ0: * )) * 8ʅ0 * 8ʅ0: * )) * 8ʅ0 * 8ʅ0: * n)) W) 8ʅ0 W) 8ʅ0: W) "' xH`3@ 8 ʅi; 8 ʅi)Hl)j)H"" "&) 8ʅi;)>()#) ) "K )" "K )Э) ) "K )" "K )R 8 ʅi ) )h)H")))* *))H* *idڅhhh))H* *ihڅhhh 8 ʅʎ))))Hl)j)H"pUWg 8ʅ') N 8ʅi, 8ʅih))0 8ʅi0 , 8ʅh) Z 8ʅi0*'8$  H`JJJJJJJJ#H""xHH""xHH"00 8ʅH) c"}H"jH 8 ʅ iH"2H 8ʅ H"H 8 ʅ H"H)iH"H 8 ʅ iH)c"hH 8ʅ iH)c"&H 8 ʅ iH)c"H 8ʅ 85H)c"H 8ʅH) ciH"` 8 ʅiJH"iBH"H 8ʅH" 8ʅH8N0H"n  H 8ʅH"H 8ʅ H)ciH"fH 8ʅH)c"+ 8ʅ0 8ʅ0 H 8 ʅH 8ʅ) c)c""xHH 8ʅiH"q 8ʅH"O"xHH 8ʅiH""H"H 8 ʅH 8ʅc" H 8ʅH" H" iH"| 8ʅ)#)b0H"n  8ʅHH 8ʅ) i@H)c" H 8ʅH 8ʅ) iH" 8ʅu0H"n  , 8ʅi H"Y 8ʅ0H"n  "xHH:" 8 ʅH" 8ʅ"xH 8ʅH2" 8ʅ0H"n  iWH"U 8ʅiGH"# H 8ʅH 8ʅ)0H" 8ʅ)0 !H 8ʅH*"-"xHH 8ʅiKH" )0 ! 8ʅHH""< 8ʅ"xH 8ʅHiCH" 8ʅ00H"n  H" 8ʅ0H"n  " "| H"i 8ʅ0H"n  C0 0 H 8 ʅH" 8ʅ i@H"p" 8ʅ0 8ʅ0 8ʅH 8 ʅH"I iAH"20:::0 s 8ʅHH8pI0ʊc c 8ʅ"xH") )h))h))) ))H)mh)8h)Y) )H)mh)8h))h)H8")h)i?)0 0"!))Hih֒֒"1H"f)d)f)d)H)) Hhm)Hm)hhhh֒֒f)d)H"fUOU8U!U 8ʅn) 8ʅ) Un) 8ʅ) UUU{UdUMU6UUUUU"xHH"f)d)f)d))!f)d)d)f))H"͂vɀ 0 )H"G"xHH"0 8ʅU  U UiUUUh)U UUk 8ʅHcUMH 8ʅ8U/H 8ʅ"U 8ʅH"UH 8ʅ"U 8ʅH#U 8ʅHU 8ʅHCUx 8ʅHh"UX 8ʅ"x)H:h"xU- 8ʅUIU UIU)0 1"!t"))))H) hhb)b)00b) Hhm)Hm)hhb) ) t ) j ) ` ) V ) L#::ɛ .H`//<|/=t)]xZcM` b(j" d ,!Y!{!!!!!"="N""#q###!$u$$$F%%%A&N&a&&&'''&(K(q(//////(///(//d){)))))//!*8*/O*f*/}***/***//*+T+//+//+++//+,,2,;,H,_,},,,,,-4-R-r-----//////-V.`.j.t./٤+;i(kout of memoryyacc stack overflowsyntax errorfile badstatement error Too many ifsToo many ifs!ARGPSEUDO error ADD mar, mar error LD reg, reg error LD reg, (RP) error LD reg, (expr) error LD reg, MISCREG error LD evenreg error EX RP, HL error IN reg, (expr) error Too many parametersMacro expansion levelb #;INYdz)4 /25_dgj $'=@CFO\cflpvy~%)Jiwzgjsv Rv{")-05NUY`fi 47ADGJTWZ]`cinqx{'-[^gj/:BHahksvy (+@UX[|5D_Za  %*58m~   ,47ENҁy|/2=?BM!$/A(/9 #ifdef MSDOS #include #else #include /* for open() calls */ #endif #ifdef vax11c #define unlink(filename) delete(filename) #endif #ifdef MIO FILE *mfopen(); #else #define mfopen(filename,mode) fopen(filename,mode) #define mfclose(filename,mode) fclose(filename,mode) #define mfputc(c,f) putc(c,f) #define mfgetc(f) getc(f) #define mfseek(f,loc,origin) fseek(f,loc,origin) #define mfread(ptr,size,nitems,f) fread(ptr,size,nitems,f) #define mfwrite(ptr,size,nitems,f) fread(ptr,size,nitems,f) #endif /* MIO */ /* * DEBUG turns on pass reporting. * Macro debug and Token debug enables. #define DEBUG #define M_DEBUG #define T_DEBUG */ #define ITEMTABLESIZE 2000 #define TEMPBUFSIZE 200 #define LINEBUFFERSIZE 200 #define EMITBUFFERSIZE 200 #define MAXSYMBOLSIZE 15 #define IFSTACKSIZE 20 #define MAXIFS 150 #define TITLELEN 50 #define BINPERLINE 16 #define PARMMAX 25 #define MAXEXP 25 #define SYMMAJIC 07203 #define NEST_IN 8 #define loop for(;;) yyerror(err) char *err; {} /* we will do our own error printing */ struct item { char *i_string; int i_value; int i_token; int i_uses; }; FILE *fout, *fbuf, *fin[NEST_IN], *now_file ; char *malloc() ; int pass2; /*set when pass one completed*/ int dollarsign ; /* location counter */ int olddollar ; /* kept to put out binary */ /* program counter save for PHASE/DEPHASE */ int phdollar, phbegin, phaseflag ; char *src_name[NEST_IN] ; int linein[NEST_IN] ; int now_in ; #define bflag 0 /* balance error */ #define eflag 1 /* expression error */ #define fflag 2 /* format error */ #define iflag 3 /* bad digits */ #define mflag 4 /* multiply defined */ #define pflag 5 /* phase error */ #define uflag 6 /* undeclared used */ #define vflag 7 /* value out of range */ #define oflag 8 /* phase/dephase error */ #define FLAGS 9 /* number of flags */ char err[FLAGS]; int keeperr[FLAGS]; char errlet[]="BEFIMPUVO"; char *errname[]={ "Balance", "Expression", "Format", "Digit", "Mult. def.", "Phase", "Undeclared", "Value", "Phase/Dephase", }; char linebuf[LINEBUFFERSIZE]; char *lineptr; char *linemax = &linebuf[LINEBUFFERSIZE]; char outbin[BINPERLINE]; char *outbinp = outbin; char *outbinm = &outbin[BINPERLINE]; char emitbuf[EMITBUFFERSIZE]; char *emitptr; char ifstack[IFSTACKSIZE]; char *ifptr; char *ifstmax = &ifstack[IFSTACKSIZE-1]; char expif[MAXIFS]; char *expifp; char *expifmax = &expif[MAXIFS]; char hexadec[] = "0123456789ABCDEF" ; char *expstack[MAXEXP]; int expptr; int nitems; int linecnt; int nbytes; int invented; char tempbuf[TEMPBUFSIZE]; char *tempmax = &tempbuf[TEMPBUFSIZE-1]; char inmlex; char arg_flag; char quoteflag; int parm_number; int exp_number; char symlong[] = "Symbol too long"; int disp; #define FLOC PARMMAX #define TEMPNUM PARMMAX+1 char **est; char **est2; char *floc; int mfptr; FILE *mfile; char *writesyms; char *title; char titlespace[TITLELEN]; char *timp,*ctime(); char *sourcef; char src[15]; char bin[15]; char mtmp[15]; char listf[15]; char bopt = 1, edef = 1, eopt = 1, fdef = 0, fopt = 0, gdef = 1, gopt = 1, iopt = 0 , /* list include files */ lstoff = 0, lston = 0, /* flag to force listing on */ lopt = 0, mdef = 0, mopt = 0, nopt = 1 , /* line numbers on as default */ oopt = 0, popt = 1, /* form feed as default page eject */ sopt = 0, /* turn on symbol table listing */ topt = 1; saveopt; char xeq_flag = 0; int xeq; long now; int line; int page = 1; struct stab { char t_name[MAXSYMBOLSIZE+1]; int t_value; int t_token; }; /* * push back character */ int peekc; /* * add a character to the output line buffer */ addtoline(ac) int ac; { /* check for EOF from stdio */ if (ac == -1) ac = 0 ; if (inmlex) return(ac); if (lineptr >= linemax) error("line buffer overflow"); *lineptr++ = ac; return(ac); } #include /* * put values in buffer for outputing */ /*VARARGS*/ /*ARGSUSED*/ emit(va_alist) va_dcl { register int bytes; va_list ap; va_start(ap); bytes = va_arg(ap,int); while (--bytes >= 0) if (emitptr >= &emitbuf[EMITBUFFERSIZE]) error("emit buffer overflow"); else { *emitptr++ = va_arg(ap,int); } va_end(ap); } emit1(opcode,regvalh,data16,type) int opcode,regvalh,data16,type; { if (regvalh & 0x8000) { if (type & 1 == 0 && (disp > 127 || disp < -128)) err[vflag]++; switch(type) { case 0: if (opcode & 0x8000) emit(4, regvalh >> 8, opcode >> 8, disp, opcode); else emit(3, regvalh >> 8, opcode, disp); break; case 1: emit(2, regvalh >> 8, opcode); break; case 2: if (data16 > 255 || data16 < -128) err[vflag]++; emit(4, regvalh >> 8, opcode, disp, data16); break; case 5: emit(4, regvalh >> 8, opcode, data16, data16 >> 8); } } else switch(type) { case 0: if (opcode & 0100000) emit(2, opcode >> 8, opcode); else emit(1, opcode); break; case 1: if (opcode & 0100000) emit(2, opcode >> 8, opcode); else emit(1, opcode); break; case 2: if (data16 > 255 || data16 < -128) err[vflag]++; emit(2, opcode, data16); break; case 3: if (data16 >255 || data16 < -128) err[vflag]++; emit(2, opcode, data16); break; case 5: if (opcode & 0100000) emit(4, opcode >> 8, opcode, data16, data16 >> 8); else emit(3, opcode, data16, data16 >> 8); } } emitdad(rp1,rp2) int rp1,rp2; { if (rp1 & 0x8000) emit(2,rp1 >> 8, rp2 + 9); else emit(1,rp2 + 9); } emitjr(opcode,expr) int opcode,expr; { disp = expr - dollarsign - 2; if (disp > 127 || disp < -128) err[vflag]++; emit(2, opcode, disp); } /* * put out a byte of binary */ putbin(v) { if(!pass2 || !bopt) return; *outbinp++ = v; if (outbinp >= outbinm) flushbin(); } /* * output one line of binary in INTEL standard form */ flushbin() { register char *p; register check; if (!pass2 || !bopt) return; nbytes += outbinp-outbin; if (check = outbinp-outbin) { putc(':', fbuf); puthex(check, fbuf); puthex(olddollar>>8, fbuf); puthex(olddollar, fbuf); puthex(0, fbuf); check += (olddollar >> 8) + olddollar; olddollar += (outbinp-outbin); for (p=outbin; p> 4) & 017], buf); putc(hexadec[byte & 017], buf); } /* * put out a line of output -- also put out binary */ list(optarg) int optarg; { register char * p; register int i; int lst; if (!expptr) linecnt++; addtoline('\0'); if (pass2) { lst = iflist(); if (lst) { lineout(); if (nopt) fprintf(fout, "%4d:\t", linein[now_in]); puthex(optarg >> 8, fout); puthex(optarg, fout); fputs(" ", fout); for (p = emitbuf; (p < emitptr) && (p - emitbuf < 4); p++) { puthex(*p, fout); } for (i = 4 - (p-emitbuf); i > 0; i--) fputs(" ", fout); putc('\t', fout); fputs(linebuf, fout); } if (bopt) { for (p = emitbuf; p < emitptr; p++) putbin(*p); } p = emitbuf+4; while (lst && gopt && p < emitptr) { lineout(); if (nopt) putc('\t', fout); fputs(" ", fout); for (i = 0; (i < 4) && (p < emitptr);i++) { puthex(*p, fout); p++; } putc('\n', fout); } lsterr2(lst); } else lsterr1(); dollarsign += emitptr - emitbuf; emitptr = emitbuf; lineptr = linebuf; } /* * keep track of line numbers and put out headers as necessary */ lineout() { if (line == 60) { if (popt) putc('\014', fout); /* send the form feed */ else fputs("\n\n\n\n\n", fout); line = 0; } if (line == 0) { fprintf(fout, "\n\n%s %s\t%s\t Page %d\n\n\n", &timp[4], &timp[20], title, page++); line = 4; } line++; } /* * cause a page eject */ eject() { if (pass2 && iflist()) { if (popt) { putc('\014', fout); /* send the form feed */ } else { while (line < 65) { line++; putc('\n', fout); } } } line = 0; } /* * space n lines on the list file */ space(n) { int i ; if (pass2 && iflist()) for (i = 0; i 4 && topt) errorprt(i); } fflush(fout); /*to avoid putc(har) mix bug*/ } /* * print diagnostic to error terminal */ errorprt(errnum) int errnum; { fprintf(stderr,"%d: %s error\n%s\n", linecnt, errname[errnum], linebuf) ; fflush(stderr) ; return ; } /* * list without address -- for comments and if skipped lines */ list1() { int lst; addtoline('\0'); lineptr = linebuf; if (!expptr) linecnt++; if (pass2) if (lst = iflist()) { lineout(); if (nopt) fprintf(fout, "%4d:\t", linein[now_in]); fprintf(fout, "\t\t%s", linebuf); lsterr2(lst); } else lsterr1(); } /* * see if listing is desired */ iflist() { register i, j; if (lston) return(1) ; if (lopt) return(0); if (*ifptr && !fopt) return(0); if (!lstoff && !expptr) return(1); j = 0; for (i=0; i STRING %token NOOPERAND %token ARITHC %token ADD %token LOGICAL %token BIT %token CALL %token INCDEC %token DJNZ %token EX %token IM %token PHASE %token DEPHASE %token IN %token JP %token JR %token LD %token OUT %token PUSHPOP %token RET %token SHIFT %token RST %token REGNAME %token ACC %token C %token RP %token HL %token INDEX %token AF %token SP %token MISCREG %token F %token COND %token SPCOND %token NUMBER %token UNDECLARED %token END %token ORG %token DEFB %token DEFS %token DEFW %token EQU %token DEFL %token LABEL %token EQUATED %token WASEQUATED %token DEFLED %token MULTDEF %token MOD %token SHL %token SHR %token NOT %token IF %token ENDIF %token ARGPSEUDO %token LIST %token MINMAX %token MACRO %token MNAME %token OLDMNAME %token ARG %token ENDM %token MPARM %token ONECHAR %token TWOCHAR %type label.part symbol %type reg evenreg realreg mem pushable bcdesp bcdehlsp mar condition %type spcondition parenexpr expression lxexpression %left '|' '^' %left '&' %nonassoc NOT %left '+' '-' %left '*' '/' MOD SHL SHR %left UNARY %% %{ char *cp; int i; %} program: statements | error { error("file bad"); } ; statements: statement | statements statement | statements error { fprintf(stderr,"statement error\n"); err[fflag]++; quoteflag = 0; while(yychar != '\n' && yychar != '\0') yychar = yylex(); list(dollarsign); yyclearin;yyerrok; } ; statement: label.part '\n' { if ($1) list(dollarsign); else list1(); } | label.part operation '\n' { list(dollarsign); } | symbol EQU expression '\n' { switch($1->i_token) { case UNDECLARED: case WASEQUATED: $1->i_token = EQUATED; $1->i_value = $3; break; default: err[mflag]++; $1->i_token = MULTDEF; } list($3); } | symbol DEFL expression '\n' { switch($1->i_token) { case UNDECLARED: case DEFLED: $1->i_token = DEFLED; $1->i_value = $3; break; default: err[mflag]++; $1->i_token = MULTDEF; } list($3); } | symbol MINMAX expression ',' expression '\n' { switch ($1->i_token) { case UNDECLARED: case DEFLED: $1->i_token = DEFLED; if ($2->i_value) /* max */ list($1->i_value = ($3 > $5? $3:$5)); else list($1->i_value = ($3 < $5? $3:$5)); break; default: err[mflag]++; $1->i_token = MULTDEF; list($1->i_value); } } | IF expression '\n' { if (ifptr >= ifstmax) error("Too many ifs"); else { if (pass2) { *++ifptr = *expifp++; if (*ifptr != !(yypv[2].ival)) err[pflag]++; } else { if (expifp >= expifmax) error("Too many ifs!"); *expifp++ = !(yypv[2].ival); *++ifptr = !(yypv[2].ival); } } saveopt = fopt; fopt = 1; list(yypv[2].ival); fopt = saveopt; } | ENDIF '\n' { if (ifptr == ifstack) err[bflag]++; else --ifptr; list1(); } | label.part END '\n' { list(dollarsign); peekc = 0; } | label.part END expression '\n' { xeq_flag++; xeq = $3; list($3); peekc = 0; } | label.part DEFS expression '\n' { if ($3 < 0) err[vflag]++; list(dollarsign); if ($3) { flushbin(); dollarsign += $3; olddollar = dollarsign; } } | ARGPSEUDO arg_on ARG arg_off '\n' { list1(); switch ($1->i_value) { case 0: /* title */ lineptr = linebuf; cp = tempbuf; title = titlespace; while ((*title++ = *cp++) && (title < &titlespace[TITLELEN])); *title = 0; title = titlespace; break; case 1: /* rsym */ if (pass2) break; insymtab(tempbuf); break; case 2: /* wsym */ writesyms = malloc(strlen(tempbuf)+1); strcpy(writesyms, tempbuf); break; case 3: /* include file */ next_source(tempbuf) ; break ; } } | ARGPSEUDO arg_on '\n' arg_off { fprintf(stderr,"ARGPSEUDO error\n"); err[fflag]++; list(dollarsign); } | LIST '\n' { if ($1 != (struct item *) -1) $2 = 1; goto dolopt; } | LIST expression '\n' { dolopt: linecnt++; if (pass2) { lineptr = linebuf; switch ($1->i_value) { case 0: /* list */ if ($2 < 0) lstoff = 1; if ($2 > 0) lstoff = 0; break; case 1: /* eject */ if ($2) eject(); break; case 2: /* space */ if ((line + $2) > 60) eject(); else space($2); break; case 3: /* elist */ eopt = edef; if ($2 < 0) eopt = 0; if ($2 > 0) eopt = 1; break; case 4: /* fopt */ fopt = fdef; if ($2 < 0) fopt = 0; if ($2 > 0) fopt = 1; break; case 5: /* gopt */ gopt = gdef; if ($2 < 0) gopt = 1; if ($2 > 0) gopt = 0; break; case 6: /* mopt */ mopt = mdef; if ($2 < 0) mopt = 0; if ($2 > 0) mopt = 1; } } } | UNDECLARED MACRO parm.list '\n' { $1->i_token = MNAME; $1->i_value = mfptr; mfseek(mfile, (long)mfptr, 0); list1(); mlex() ; parm_number = 0; } | OLDMNAME MACRO { $1->i_token = MNAME; while (yychar != ENDM && yychar) { while (yychar != '\n' && yychar) yychar = yylex(); list1(); yychar = yylex(); } while (yychar != '\n' && yychar) yychar = yylex(); list1(); yychar = yylex(); } | label.part MNAME al arg.list '\n' { expand: $2->i_uses++ ; arg_flag = 0; parm_number = 0; list(dollarsign); expptr++; est = est2; est[FLOC] = floc; est[TEMPNUM] = (char *)exp_number++; floc = (char *)($2->i_value); mfseek(mfile, (long)floc, 0); } ; label.part: /*empty*/ { $$ = NULL; } | symbol ':' { switch($1->i_token) { case UNDECLARED: if (pass2) err[pflag]++; else { $1->i_token = LABEL; $1->i_value = dollarsign; } break; case LABEL: if (!pass2) { $1->i_token = MULTDEF; err[mflag]++; } else if ($1->i_value != dollarsign) err[pflag]++; break; default: err[mflag]++; $1->i_token = MULTDEF; } } ; operation: NOOPERAND { emit1($1->i_value, 0, 0, 1); } | JP expression { emit(3, 0303, $2, $2 >> 8); } | CALL expression { emit(3, 0315, $2, $2 >> 8); } | RST expression { if ($2 > 7 || $2 < 0) err[vflag]++; emit(1, $1->i_value + (($2 & 7) << 3)); } | ADD ACC ',' expression { emit1(0306, 0, $4, 3); } | ARITHC ACC ',' expression { emit1(0306 + ($1->i_value << 3), 0, $4, 3); } | LOGICAL expression { emit1(0306 | ($1->i_value << 3), 0, $2, 3); } | LOGICAL ACC ',' expression /* -cdk */ { emit1(0306 | ($1->i_value << 3), 0, $4, 3); } | ADD ACC ',' reg { emit1(0200 + ($4 & 0377), $4, 0, 0); } | ARITHC ACC ',' reg { emit1(0200 + ($1->i_value << 3) + ($4 & 0377), $4, 0, 0); } | LOGICAL reg { emit1(0200 + ($1->i_value << 3) + ($2 & 0377), $2, 0, 0); } | LOGICAL ACC ',' reg /* -cdk */ { emit1(0200 + ($1->i_value << 3) + ($4 & 0377), $4, 0, 0); } | SHIFT reg { emit1(0145400 + ($1->i_value << 3) + ($2 & 0377), $2, 0, 0); } | INCDEC reg { emit1($1->i_value + (($2 & 0377) << 3) + 4, $2, 0, 0); } | ARITHC HL ',' bcdehlsp { if ($1->i_value == 1) emit(2,0355,0112+$4); else emit(2,0355,0102+$4); } | ADD mar ',' bcdesp { emitdad($2,$4); } | ADD mar ',' mar { if ($2 != $4) { fprintf(stderr,"ADD mar, mar error\n"); err[fflag]++; } emitdad($2,$4); } | INCDEC evenreg { emit1(($1->i_value << 3) + ($2 & 0377) + 3, $2, 0, 1); } | PUSHPOP pushable { emit1($1->i_value + ($2 & 0377), $2, 0, 1); } | BIT expression ',' reg { if ($2 < 0 || $2 > 7) err[vflag]++; emit1($1->i_value + (($2 & 7) << 3) + ($4 & 0377), $4, 0, 0); } | JP condition ',' expression { emit(3, 0302 + $2, $4, $4 >> 8); } | JP '(' mar ')' { emit1(0351, $3, 0, 1); } | CALL condition ',' expression { emit(3, 0304 + $2, $4, $4 >> 8); } | JR expression { emitjr(030,$2); } | JR spcondition ',' expression { emitjr($1->i_value + $2, $4); } | DJNZ expression { emitjr($1->i_value, $2); } | RET { emit(1, $1->i_value); } | RET condition { emit(1, 0300 + $2); } | LD reg ',' reg { if (($2 & 0377) == 6 && ($4 & 0377) == 6) { fprintf(stderr,"LD reg, reg error\n"); err[fflag]++; } emit1(0100 + (($2 & 7) << 3) + ($4 & 7),$2 | $4, 0, 0); } | LD reg ',' expression { fprintf(stderr,"ld reg, %04X\n",$4); emit1(6 + (($2 & 0377) << 3), $2, $4, 2); } | LD reg ',' '(' RP ')' { if ($2 != 7) { fprintf(stderr,"LD reg, (RP) error\n"); err[fflag]++; } else emit(1, 012 + $5->i_value); } | LD reg ',' parenexpr { if ($2 != 7) { fprintf(stderr,"LD reg, (expr) error\n"); err[fflag]++; } else emit(3, 072, $4, $4 >> 8); } | LD '(' RP ')' ',' ACC { emit(1, 2 + $3->i_value); } | LD parenexpr ',' ACC { emit(3, 062, $2, $2 >> 8); } | LD reg ',' MISCREG { if ($2 != 7) { fprintf(stderr,"LD reg, MISCREG error\n"); err[fflag]++; } else emit(2, 0355, 0127 + $4->i_value); } | LD MISCREG ',' ACC { emit(2, 0355, 0107 + $2->i_value); } | LD evenreg ',' lxexpression { fprintf(stderr,"ld evenreg, %04X\n",'$4); emit1(1 + ($2 & 060), $2, $4, 5); } | LD evenreg ',' parenexpr { if (($2 & 060) == 040) emit1(052, $2, $4, 5); else emit(4, 0355, 0113 + $2, $4, $4 >> 8); } | LD parenexpr ',' evenreg { if (($4 & 060) == 040) emit1(042, $4, $2, 5); else emit(4, 0355, 0103 + $4, $2, $2 >> 8); } | LD evenreg ',' mar { if ($2 != 060) { fprintf(stderr,"LD evenreg error\n"); err[fflag]++; } else emit1(0371, $4, 0, 1); } | EX RP ',' HL { if ($2->i_value != 020) { fprintf(stderr,"EX RP, HL error\n"); err[fflag]++; } else emit(1, 0353); } | EX AF ',' AF setqf '\'' clrqf { emit(1, 010); } | EX '(' SP ')' ',' mar { emit1(0343, $6, 0, 1); } | IN realreg ',' parenexpr { if ($2 != 7) { fprintf(stderr,"IN reg, (expr) error\n"); err[fflag]++; } else { if ($4 < 0 || $4 > 255) err[vflag]++; emit(2, $1->i_value, $4); } } | IN realreg ',' '(' C ')' { emit(2, 0355, 0100 + ($2 << 3)); } | IN F ',' '(' C ')' { emit(2, 0355, 0160); } | OUT parenexpr ',' ACC { if ($2 < 0 || $2 > 255) err[vflag]++; emit(2, $1->i_value, $2); } | OUT '(' C ')' ',' realreg { emit(2, 0355, 0101 + ($6 << 3)); } | IM expression { if ($2 > 2 || $2 < 0) err[vflag]++; else emit(2, $1->i_value >> 8, $1->i_value + (($2 + ($2 > 0)) << 3)); } | PHASE expression { if (phaseflag) { err[oflag]++; } else { phaseflag = 1; phdollar = dollarsign; dollarsign = $2; phbegin = dollarsign; } } | DEPHASE { if (!phaseflag) { err[oflag]++; } else { phaseflag = 0; dollarsign = phdollar + dollarsign - phbegin; } } | ORG expression { if (phaseflag) { err[oflag]++; dollarsign = phdollar + dollarsign - phbegin; phaseflag = 0; } if ($2-dollarsign) { flushbin(); olddollar = $2; dollarsign = $2; } } | DEFB db.list | DEFW dw.list | ENDM ; parm.list: | parm.element | parm.list ',' parm.element ; parm.element: UNDECLARED { $1->i_token = MPARM; if (parm_number >= PARMMAX) error("Too many parameters"); $1->i_value = parm_number++; } ; arg.list: /* empty */ | arg.element | arg.list ',' arg.element ; arg.element: ARG { cp = malloc(strlen(tempbuf)+1); est2[parm_number++] = cp; strcpy(cp, tempbuf); } ; reg: realreg | mem ; realreg: REGNAME { $$ = $1->i_value; } | ACC { $$ = $1->i_value; } | C { $$ = $1->i_value; } ; mem: '(' HL ')' { $$ = 6; } | '(' INDEX expression ')' { disp = $3; $$ = ($2->i_value & 0177400) | 6; } | '(' INDEX ')' { disp = 0; $$ = ($2->i_value & 0177400) | 6; } ; evenreg: bcdesp | mar ; pushable: RP { $$ = $1->i_value; } | AF { $$ = $1->i_value; } | mar ; bcdesp: RP { $$ = $1->i_value; } | SP { $$ = $1->i_value; } ; bcdehlsp: bcdesp | HL { $$ = $1->i_value; } ; mar: HL { $$ = $1->i_value; } | INDEX { $$ = $1->i_value; } ; condition: spcondition | COND { $$ = $1->i_value; } ; spcondition: SPCOND { $$ = $1->i_value; } | C { $$ = 030; } ; db.list: db.list.element | db.list ',' db.list.element ; db.list.element: TWOCHAR { emit(2, $1, $1>>8); } | STRING { cp = $1; while (*cp != '\0') emit(1,*cp++); } | expression { if ($1 < -128 || $1 > 255) err[vflag]++; emit(1, $1 & 0377); } ; dw.list: dw.list.element | dw.list ',' dw.list.element ; dw.list.element: expression { emit(2, $1, $1>>8); } ; lxexpression: expression | TWOCHAR ; parenexpr: '(' expression ')' { $$ = $2; } ; expression: error { err[eflag]++; $$ = 0; } | LABEL { $$ = $1->i_value; $1->i_uses++ ; } | NUMBER | ONECHAR | EQUATED { $$ = $1->i_value; } | WASEQUATED { $$ = $1->i_value; } | DEFLED { $$ = $1->i_value; } | '$' { $$ = dollarsign; } | UNDECLARED { err[uflag]++; $$ = 0; } | MULTDEF { $$ = $1->i_value; } | expression '+' expression { $$ = $1 + $3; } | expression '-' expression { $$ = $1 - $3; } | expression '/' expression { $$ = $1 / $3; } | expression '*' expression { $$ = $1 * $3; } | expression MOD expression { $$ = $1 % $3; } | expression '&' expression { $$ = $1 & $3; } | expression '|' expression { $$ = $1 | $3; } | expression '^' expression { $$ = $1 ^ $3; } | expression SHL expression { $$ = $1 << $3; } | expression SHR expression { $$ = (($1 >> 1) & 077777) >> ($3 - 1); } | '[' expression ']' { $$ = $2; } | NOT expression { $$ = ~$2; } | '+' expression %prec UNARY { $$ = $2; } | '-' expression %prec UNARY { $$ = -$2; } ; symbol: UNDECLARED | LABEL | MULTDEF | EQUATED | WASEQUATED | DEFLED ; al: { if (expptr >= MAXEXP) error("Macro expansion level"); est2 = (char **) malloc((PARMMAX +4) * sizeof(char *)); expstack[expptr] = (char *)est2 ; for (i=0; i= tempmax) error(symlong); *p++ = (c >= 'A' && c <= 'Z') ? c + 'a' - 'A' : c; while ((c = nextchar()) == '$') ; } while (charclass[c]==LETTER || charclass[c]==DIGIT); if (p - tempbuf > MAXSYMBOLSIZE) p = tempbuf + MAXSYMBOLSIZE; *p++ = '\0'; peekc = c; return(tokenofitem(UNDECLARED)); case DIGIT: if (*ifptr) return(skipline(c)); p = tempbuf; do { if (p >= tempmax) error(symlong); *p++ = tolower(c); while ((c = nextchar()) == '$'); } while(numpart[c]); peekc = c; *p-- = '\0'; switch(*p) { case 'o': case 'q': radix = 8; limit = 020000; *p = '\0'; break; case 'd': radix = 10; limit = 3276; *p = '\0'; break; case 'h': radix = 16; limit = 010000; *p = '\0'; break; case 'b': radix = 2; limit = 077777; *p = '\0'; break; default: radix = 10; limit = 3276; p++; break; } /* * tempbuf now points to the number, null terminated * with radix 'radix'. */ yylval.ival = 0; p = tempbuf; do { c = *p - (*p > '9' ? ('a' - 10) : '0'); if (c >= radix) { err[iflag]++; yylval.ival = 0; break; } if (yylval.ival < limit || (radix == 10 && yylval.ival == 3276 && c < 8) || (radix == 2 && yylval.ival == limit)) yylval.ival = yylval.ival * radix + c; else { err[vflag]++; yylval.ival = 0; break; } } while(*++p != '\0'); return(NUMBER); default: if (*ifptr) return(skipline(c)); switch(c) { case ';': return(skipline(c)); case '\'': if (quoteflag) return('\''); p = tempbuf; p[1] = 0; do switch(c = nextchar()) { case '\0': case '\n': err[bflag]++; goto retstring; case '\'': if ((c = nextchar()) != '\'') { retstring: peekc = c; *p = '\0'; if ((p-tempbuf) >2) { yylval.cval = tempbuf; return(STRING); } else if (p-tempbuf == 2) { p = tempbuf; yylval.ival = *p++ ; yylval.ival |= *p<<8; return(TWOCHAR); } else { p = tempbuf; yylval.ival = *p++; return(ONECHAR); } } default: *p++ = c; } while (p < tempmax); /* * if we break out here, our string is longer than * our input line */ error("string buffer overflow"); default: return(c); } } } /* * return the token associated with the string pointed to by * tempbuf. if no token is associated with the string, associate * deftoken with the string and return deftoken. * in either case, cause yylval to point to the relevant * symbol table entry. */ tokenofitem(deftoken) int deftoken; { register char *p; register struct item * ip; register i; int r, l, u, hash; #ifdef T_DEBUG fputs("'tokenofitem entry' ", stderr) ; fputs(tempbuf, stderr) ; #endif /* * binary search */ l = 0; u = (sizeof keytab/sizeof keytab[0])-1; while (l <= u) { i = (l+u)/2; ip = &keytab[i]; if ((r = strcmp(tempbuf, ip->i_string)) == 0) goto found; if (r < 0) u = i-1; else l = i+1; } /* * hash into item table */ hash = 0; p = tempbuf; while (*p) hash += *p++; hash %= ITEMTABLESIZE; ip = &itemtab[hash]; loop { if (ip->i_token == 0) break; if (strcmp(tempbuf, ip->i_string) == 0) goto found; if (++ip >= itemmax) ip = itemtab; } if (!deftoken) { i = 0 ; goto token_done ; } if (++nitems > ITEMTABLESIZE-20) error("item table overflow"); ip->i_string = malloc(strlen(tempbuf)+1); ip->i_token = deftoken; ip->i_uses = 0 ; strcpy(ip->i_string, tempbuf); found: if (*ifptr) { if (ip->i_token == ENDIF) { i = ENDIF ; goto token_done ; } if (ip->i_token == IF) { if (ifptr >= ifstmax) error("Too many ifs"); else *++ifptr = 1; } i = skipline(' '); goto token_done ; } yylval.itemptr = ip; i = ip->i_token; token_done: #ifdef T_DEBUG fputs("\t'tokenofitem exit'\n", stderr) ; #endif return(i) ; } /* * interchange two entries in the item table -- used by qsort */ interchange(i, j) { register struct item *fp, *tp; struct item temp; fp = &itemtab[i]; tp = &itemtab[j]; temp.i_string = fp->i_string; temp.i_value = fp->i_value; temp.i_token = fp->i_token; temp.i_uses = fp->i_uses; fp->i_string = tp->i_string; fp->i_value = tp->i_value; fp->i_token = tp->i_token; fp->i_uses = tp->i_uses; tp->i_string = temp.i_string; tp->i_value = temp.i_value; tp->i_token = temp.i_token; tp->i_uses = temp.i_uses; } /* * quick sort -- used by putsymtab to sort the symbol table */ qsort(m, n) { register i, j; if (m < n) { i = m; j = n+1; loop { do i++; while(strcmp(itemtab[i].i_string, itemtab[m].i_string) < 0); do j--; while(strcmp(itemtab[j].i_string, itemtab[m].i_string) > 0); if (i < j) interchange(i, j); else break; } interchange(m, j); qsort(m, j-1); qsort(j+1, n); } } /* * get the next character */ nextchar() { register int c, ch; static char *earg; char *getlocal(); if (peekc != -1) { c = peekc; peekc = -1; return(c); } start: if (earg) { if (*earg) return(addtoline(*earg++)); earg = 0; } if (expptr) { if ((ch = getm()) == '\1') { /* expand argument */ ch = getm() - 'A'; if (ch >= 0 && ch < PARMMAX && est[ch]) earg = est[ch]; goto start; } if (ch == '\2') { /* local symbol */ ch = getm() - 'A'; if (ch >= 0 && ch < PARMMAX && est[ch]) { earg = est[ch]; goto start; } earg = getlocal(ch, (int)est[TEMPNUM]); goto start; } return(addtoline(ch)); } ch = getc(now_file) ; /* if EOF, check for include file */ if (ch == EOF) { while (ch == EOF && now_in) { fclose(fin[now_in]) ; free(src_name[now_in]) ; now_file = fin[--now_in] ; ch = getc(now_file) ; } if (linein[now_in] < 0) { lstoff = 1 ; linein[now_in] = -linein[now_in] ; } else { lstoff = 0 ; } if (pass2 && iflist()) { lineout() ; fprintf(fout, "**** %s ****\n", src_name[now_in]) ; } } if (ch == '\n') linein[now_in]++ ; return(addtoline(ch)) ; } /* * skip to rest of the line -- comments and if skipped lines */ skipline(ac) { register c; c = ac; while (c != '\n' && c != '\0') c = nextchar(); return('\n'); } main(argc, argv) char **argv; { register struct item *ip; register i; int files; #ifdef DBUG extern yydebug; #endif fout = stdout ; fin[0] = stdin ; now_file = stdin ; files = 0; for (i=1; ii_uses = 0 ; /* set macro names, equated and defined names */ switch (ip->i_token) { case MNAME: ip->i_token = OLDMNAME; break; case EQUATED: ip->i_token = WASEQUATED; break; case DEFLED: ip->i_token = UNDECLARED; break; } } setvars(); fseek(now_file, (long)0, 0); #ifdef DEBUG fputs("DEBUG- pass 2\n", stderr) ; #endif yyparse(); if (bopt) { flushbin(); putc(':', fbuf); if (xeq_flag) { puthex(0, fbuf); puthex(xeq >> 8, fbuf); puthex(xeq, fbuf); puthex(1, fbuf); puthex(255-(xeq >> 8)-xeq, fbuf); } else for (i = 0; i < 10; i++) putc('0', fbuf); putc('\n', fbuf); fflush(fbuf); } if (!lopt) fflush(fout); if (writesyms) outsymtab(writesyms); if (eopt) erreport(); if (!lopt && !sopt) putsymtab(); if (!lopt) { eject(); fflush(fout); } exit(0); } /* * set some data values before each pass */ setvars() { register i; peekc = -1; linein[now_in] = linecnt = 0; exp_number = 0; emitptr = emitbuf; lineptr = linebuf; ifptr = ifstack; expifp = expif; *ifptr = 0; dollarsign = 0; olddollar = 0; phaseflag = 0; for (i=0; ii_token == UNDECLARED) { nitems--; continue; } if (fp->i_token == 0) continue; tp++; if (tp != fp) { tp->i_string = fp->i_string; tp->i_value = fp->i_value; tp->i_token = fp->i_token; tp->i_uses = fp->i_uses ; } } tp++; tp->i_string = "{"; /* sort the table */ qsort(0, nitems-1); title = "** Symbol Table **"; rows = (nitems+3) / 4; if (rows+5+line > 60) eject(); lineout(); fprintf(fout,"\n\n\nSymbol Table:\n\n") ; line += 4; for (i=0; ii_token; c = ' ' ; if (t == EQUATED || t == DEFLED) c = '=' ; if (tp->i_uses == 0) c1 = '+' ; else c1 = ' ' ; fprintf(fout, "%-15s%c%4x%c ", tp->i_string, c, tp->i_value & 0xffff, c1); } } lineout(); putc('\n', fout); } } /* * put out error report */ erreport() { register i, numerr; if (line > 50) eject(); lineout(); numerr = 0; for (i=0; i 55) eject(); lineout(); fprintf(fout, "\n%6d\tsymbols\n", nitems); fprintf(fout, "%6d\tbytes\n", nbytes); line += 2; if (mfptr) { if (line > 53) eject(); lineout(); fprintf(fout, "\n%6d\tmacro calls\n", exp_number); fprintf(fout, "%6d\tmacro bytes\n", mfptr); fprintf(fout, "%6d\tinvented symbols\n", invented/2); line += 3; } } /* * lexical analyser for macro definition */ mlex() { register char *p; register c; int t; /* * move text onto macro file, changing formal parameters */ #ifdef M_DEBUG fprintf(stderr,"enter 'mlex'\t") ; #endif inmlex++; c = nextchar(); loop { switch(charclass[c]) { case DIGIT: while (numpart[c]) { putm(c); c = nextchar(); } continue; case STARTER: case LETTER: t = 0; p = tempbuf+MAXSYMBOLSIZE+2; do { if (p >= tempmax) error(symlong); *p++ = c; if (t < MAXSYMBOLSIZE) tempbuf[t++] = (c >= 'A' && c <= 'Z') ? c+'a'-'A' : c; c = nextchar(); } while (charclass[c]==LETTER || charclass[c]==DIGIT); tempbuf[t] = 0; *p++ = '\0'; p = tempbuf+MAXSYMBOLSIZE+2; t = tokenofitem(0); if (t != MPARM) while (*p) putm(*p++); else { if (*(yylval.itemptr->i_string) == '?') putm('\2'); else putm('\1'); putm(yylval.itemptr->i_value + 'A'); } if (t == ENDM) goto done; continue; case F_END: if (expptr) { popsi(); c = nextchar(); continue; } goto done; default: if (c == '\n') { linecnt++; } if (c != '\1') putm(c); c = nextchar(); } } /* * finish off the file entry */ done: while(c != EOF && c != '\n' && c != '\0') c = nextchar(); linecnt++; putm('\n'); putm('\n'); putm(0); for (c=0; c linebuf) lineptr--; } /* * return a unique name for a local symbol * c is the parameter number, n is the macro number. */ char * getlocal(c, n) int c,n; { static char local_label[10]; invented++; if (c >= 26) c += 'a' - '0'; sprintf(local_label, "?%c%04d", c+'a', n) ; return(local_label); } /* * read in a symbol table */ insymtab(name) char *name; { register struct stab *t; int s, i, sfile; t = (struct stab *) tempbuf; #ifdef MSDOS if ((sfile = open(name, O_RDONLY | O_BINARY)) < 0) #else if ((sfile = open(name, O_RDONLY)) < 0) #endif return; read(sfile, (char *)t, sizeof *t); if (t->t_value != SYMMAJIC) return; s = t->t_token; for (i=0; ii_token = t->t_token; yylval.itemptr->i_value = t->t_value; if (t->t_token == MACRO) yylval.itemptr->i_value += mfptr; } while ((s = read(sfile, tempbuf, TEMPBUFSIZE)) > 0) { mfptr += s; mfwrite(tempbuf, 1, s, mfile) ; } } /* * write out symbol table */ outsymtab(name) char *name; { register struct stab *t; register struct item *ip; int i, sfile; t = (struct stab *) tempbuf; if ((sfile = creat(name, 0644)) < 0) return; for (ip=itemtab; ipi_token == UNDECLARED) { ip->i_token = 0; nitems--; } } copyname(title, (char *)t); t->t_value = SYMMAJIC; t->t_token = nitems; write(sfile, (char *)t, sizeof *t); for (ip=itemtab; ipi_token != 0) { t->t_token = ip->i_token; t->t_value = ip->i_value; copyname(ip->i_string, (char *)t); write(sfile, (char *)t, sizeof *t); } } mfseek(mfile, (long)0, 0); while((i = mfread(tempbuf, 1, TEMPBUFSIZE, mfile) ) > 0) write(sfile, tempbuf, i); } /* * copy a name into the symbol file */ copyname(st1, st2) char *st1, *st2; { register char *s1, *s2; register i; i = (MAXSYMBOLSIZE+2) & ~01; s1 = st1; s2 = st2; while(*s2++ = *s1++) i--; while(--i > 0) *s2++ = '\0'; } /* get the next source file */ next_source(sp) char *sp ; { if(now_in == NEST_IN -1) error("Too many nested includes") ; if ((now_file = fopen(sp, "r")) == NULL) { char ebuf[100] ; sprintf(ebuf,"Can't open include file: %s", sp) ; error(ebuf) ; } if (pass2 && iflist()) { lineout() ; fprintf(fout, "**** %s ****\n",sp) ; } /* save the list control flag with the current line number */ if (lstoff) linein[now_in] = - linein[now_in] ; /* no list if include files are turned off */ lstoff |= iopt ; /* save the new file descriptor. */ fin[++now_in] = now_file ; /* start with line 0 */ linein[now_in] = 0 ; /* save away the file name */ src_name[now_in] = malloc(strlen(sp)+1) ; strcpy(src_name[now_in],sp) ; }