ch14p2.s
Original bytes preserved. This is a browser-readable view.
; CS617 Chapter 14 R002 - Seven-Segment Light Show ; Derived from Piotr Piatek cmd31a.s (2026-11-06). ; R001 is preserved unchanged. This file is a new experimental derivative. ; Diagnostic 31h: exactly one session, one 00h terminator, one ACK/restart. ; 3 perimeter revolutions (150 ms/frame), cumulative buildup (150 ms/frame), ; full-on extra hold (~500 ms), then original CASIO (500 ms/letter). ; Segment glyphs beyond CASIO: inferred, NOT YET hardware validated. ; Requires 64-KB VX-4 usable RAM at 0000h and same SB-5 / MD-120 setup. ; Machine code must be built with real HD61; no ROM image required. org 0 start 0 ld $0,&H05 ; enter MD-120 diagnostic mode cal cm1 ld $0,&H31 ; LED pattern command cal cm1 ; IZ points to table; $4 is offset, $5 is remaining frame count. ; wr1/delay use only $0-$2 and IX, preserving IZ / $4 / $5. pre iz,animtab ld $4,0 ld $5,25 animlp: ld $0,(iz+$4) cal wr1 cal dly150 ad $4,1 sb $5,1 jr nz,animlp ; Last animation byte is 7Fh; hold all segments before CASIO. cal dly500 pre iz,casiotb ld $4,0 ld $5,5 caslp: ld $0,(iz+$4) cal wr1 cal dly500 ad $4,1 sb $5,1 jr nz,caslp ; Original Piotr command termination / response / restart sequence. ld $0,$sx cal wr1 cal dly500 cal rd1 ld $0,&H21 cal cm1 pst ua,&H54 rtn ; Short delay (~150ms) scaled from Piotr's original 500ms calibration. ; Physical timing must be measured; this is not a guaranteed duration. dly150: ldw $0,5929 dly15a: sbw $0,$sy jr nz,dly15a rtn ; Original Piotr 500ms nominal delay, preserved arithmetically. dly500: ldw $0,19762 dly50a: sbw $0,$sy jr nz,dly50a rtn ; Table: clockwise a,b,c,d,e,f (g omitted from perimeter). ; 18 chase frames + 7 buildup frames; no zero terminator within table. animtab: db &H40,&H20,&H10,&H08,&H04,&H02,&H40,&H20,&H10,&H08,&H04,&H02,&H40,&H20,&H10,&H08,&H04,&H02 db &H40,&H60,&H70,&H78,&H7C,&H7E,&H7F ; Exact five working Piotr glyph bytes, in original order. casiotb: db &H4E,&H77,&H5B,&H30,&H7E ; read a byte from the FDD to $0 rd1: gst ua,$1 ld $2,$1 or $2,&H30 pst ua,$2 pre ix,&HFFFF rd2: ld $0,(ix+$sx) ;FDD status anc $0,$sy jr nz,rd2 ;wait until the FDD sends the data byte ld $0,(ix-$sy) ;FDD data pst ua,$1 rtn ; write a byte $0 to the FDD wr1: gst ua,$1 ld $2,$1 or $2,&H30 pst ua,$2 pre ix,&HFFFF st $0,(ix-$sy) ;FDD data wr2: ld $0,(ix+$sx) ;FDD status anc $0,&H02 jr z,wr2 ;wait until the FDD reads the data byte pst ua,$1 rtn ; write a command $0 to the FDD cm1: gst ua,$1 ld $2,$1 or $2,&H30 pst ua,$2 pre ix,&HFFFF st $0,(ix+$sx) ;FDD command cm2: ld $0,(ix+$sx) ;FDD status anc $0,&H04 jr z,cm2 ;wait until the FDD reads the command byte pst ua,$1 rtn