HD61700 ASSEMBLER Rev 0.45 - ASSEMBLY LIST OF [ch14p2.s]
00001:0000            ; CS617 Chapter 14 R002 - Seven-Segment Light Show
00002:0000            ; Derived from Piotr Piatek cmd31a.s (2026-11-06).
00003:0000            ; R001 is preserved unchanged. This file is a new experimental derivative.
00004:0000            ; Diagnostic 31h: exactly one session, one 00h terminator, one ACK/restart.
00005:0000            ; 3 perimeter revolutions (150 ms/frame), cumulative buildup (150 ms/frame),
00006:0000            ; full-on extra hold (~500 ms), then original CASIO (500 ms/letter).
00007:0000            ; Segment glyphs beyond CASIO: inferred, NOT YET hardware validated.
00008:0000            ; Requires 64-KB VX-4 usable RAM at 0000h and same SB-5 / MD-120 setup.
00009:0000            ; Machine code must be built with real HD61; no ROM image required.
00010:0000            
00011:0000                         org     0
00012:0000                         start   0
00013:0000            
00014:0000  420005                 ld      $0,&H05               ; enter MD-120 diagnostic mode
00015:0003  77BD00                 cal     cm1
00016:0006  420031                 ld      $0,&H31               ; LED pattern command
00017:0009  77BD00                 cal     cm1
00018:000C            
00019:000C            ; IZ points to table; $4 is offset, $5 is remaining frame count.
00020:000C            ; wr1/delay use only $0-$2 and IX, preserving IZ / $4 / $5.
00021:000C  D6406C00               pre     iz,animtab
00022:0010  420400                 ld      $4,0
00023:0013  420519                 ld      $5,25
00024:0016  296004    animlp:      ld      $0,(iz+$4)
00025:0019  77A300                 cal     wr1
00026:001C  775A00                 cal     dly150
00027:001F  480401                 ad      $4,1
00028:0022  490501                 sb      $5,1
00029:0025  B490                   jr      nz,animlp
00030:0027            
00031:0027            ; Last animation byte is 7Fh; hold all segments before CASIO.
00032:0027  776300                 cal     dly500
00033:002A  D6408500               pre     iz,casiotb
00034:002E  420400                 ld      $4,0
00035:0031  420505                 ld      $5,5
00036:0034  296004    caslp:       ld      $0,(iz+$4)
00037:0037  77A300                 cal     wr1
00038:003A  776300                 cal     dly500
00039:003D  480401                 ad      $4,1
00040:0040  490501                 sb      $5,1
00041:0043  B490                   jr      nz,caslp
00042:0045            
00043:0045            ; Original Piotr command termination / response / restart sequence.
00044:0045  0200                   ld      $0,$sx
00045:0047  77A300                 cal     wr1
00046:004A  776300                 cal     dly500
00047:004D  778A00                 cal     rd1
00048:0050  420021                 ld      $0,&H21
00049:0053  77BD00                 cal     cm1
00050:0056  566054                 pst     ua,&H54
00051:0059  F7                     rtn     
00052:005A            
00053:005A            ; Short delay (~150ms) scaled from Piotr's original 500ms calibration.
00054:005A            ; Physical timing must be measured; this is not a guaranteed duration.
00055:005A  D1002917  dly150:      ldw     $0,5929
00056:005E  8920      dly15a:      sbw     $0,$sy
00057:0060  B483                   jr      nz,dly15a
00058:0062  F7                     rtn     
00059:0063            
00060:0063            ; Original Piotr 500ms nominal delay, preserved arithmetically.
00061:0063  D100324D  dly500:      ldw     $0,19762
00062:0067  8920      dly50a:      sbw     $0,$sy
00063:0069  B483                   jr      nz,dly50a
00064:006B  F7                     rtn     
00065:006C            
00066:006C            ; Table: clockwise a,b,c,d,e,f (g omitted from perimeter).
00067:006C            ; 18 chase frames + 7 buildup frames; no zero terminator within table.
00068:006C  40201008  animtab:     db      &H40,&H20,&H10,&H08,&H04,&H02,&H40,&H20,&H10,&H08,&H04,&H02,&H40,&H20,&H10,&H08,&H04,&H02
            04024020
            10080402
            40201008
            0402    
00069:007E  40607078               db      &H40,&H60,&H70,&H78,&H7C,&H7E,&H7F
            7C7E7F  
00070:0085            
00071:0085            ; Exact five working Piotr glyph bytes, in original order.
00072:0085  4E775B30  casiotb:     db      &H4E,&H77,&H5B,&H30,&H7E
            7E      
00073:008A            
00074:008A            ; read a byte from the FDD to $0
00075:008A  1E61      rd1:         gst     ua,$1
00076:008C  026201                 ld      $2,$1
00077:008F  4E0230                 or      $2,&H30
00078:0092  1662                   pst     ua,$2
00079:0094  D600FFFF               pre     ix,&HFFFF
00080:0098  2800      rd2:         ld      $0,(ix+$sx)           ;FDD status
00081:009A  0420                   anc     $0,$sy
00082:009C  B485                   jr      nz,rd2                ;wait until the FDD sends the data byte
00083:009E  28A0                   ld      $0,(ix-$sy)           ;FDD data
00084:00A0  1661                   pst     ua,$1
00085:00A2  F7                     rtn     
00086:00A3            
00087:00A3            ; write a byte $0 to the FDD
00088:00A3  1E61      wr1:         gst     ua,$1
00089:00A5  026201                 ld      $2,$1
00090:00A8  4E0230                 or      $2,&H30
00091:00AB  1662                   pst     ua,$2
00092:00AD  D600FFFF               pre     ix,&HFFFF
00093:00B1  20A0                   st      $0,(ix-$sy)           ;FDD data
00094:00B3  2800      wr2:         ld      $0,(ix+$sx)           ;FDD status
00095:00B5  440002                 anc     $0,&H02
00096:00B8  B086                   jr      z,wr2                 ;wait until the FDD reads the data byte
00097:00BA  1661                   pst     ua,$1
00098:00BC  F7                     rtn     
00099:00BD            
00100:00BD            ; write a command $0 to the FDD
00101:00BD  1E61      cm1:         gst     ua,$1
00102:00BF  026201                 ld      $2,$1
00103:00C2  4E0230                 or      $2,&H30
00104:00C5  1662                   pst     ua,$2
00105:00C7  D600FFFF               pre     ix,&HFFFF
00106:00CB  2000                   st      $0,(ix+$sx)           ;FDD command
00107:00CD  2800      cm2:         ld      $0,(ix+$sx)           ;FDD status
00108:00CF  440004                 anc     $0,&H04
00109:00D2  B086                   jr      z,cm2                 ;wait until the FDD reads the command byte
00110:00D4  1661                   pst     ua,$1
00111:00D6  F7                     rtn     
00112:00D7            
00113:00D7            

ASSEMBLY COMPLETE, NO ERRORS FOUND

HD61700 ASSEMBLER Rev 0.45 - MAP LIST OF [ch14p2.s]
 LABEL           : ADDRESS(hex)  | LABEL           : ADDRESS(hex)
-------------------------------------------------------------------
 animlp          :   0016h     A | caslp           :   0034h      A
 dly150          :   005Ah     A | dly15a          :   005Eh      A
 dly500          :   0063h     A | dly50a          :   0067h      A
 animtab         :   006Ch     A | casiotb         :   0085h      A
 rd1             :   008Ah     A | rd2             :   0098h      A
 wr1             :   00A3h     A | wr2             :   00B3h      A
 cm1             :   00BDh     A | cm2             :   00CDh      A

 START ADDRESS   = 0000h
 END ADDRESS     = 00D6h
 EXECUTE ADDRESS = 0000h
