2 global add_hla,div32_16
11 extrn msg.sm,msg.recv,hwl2phy
16 ;--------------------------------------------------------------
24 cseg ; (common. TODO: check for banked)
33 ;--------------------------------------------------------------------
46 push de ;save alternate registers (de,bc)
51 ld bc,0 ;bc = high y = 0
52 ld d,b ;de = high r = 0
54 ex de,hl ;de = x, hl = r
57 ex (sp),hl ;hl' = low x, save alternate hl
58 ld de,0 ;de' = low r = 0
59 ex de,hl ;de = x, hl = r
97 jr nz,div_lp ;while (--count)
110 pop bc ;restore alternate registers
115 ;----------------------------------------------------------------------
117 ; output bytes to consecutive portaddresses
119 ; hl: table with following structure:
120 ; db n, port1, val1, val2,... valn
121 ; db m, port1, val1, val2,... valm
123 ; db 0 ; Terminate table
126 cseg ; (common for now)
145 ;----------------------------------------------------------------------
147 ; output bytes to ports
149 ; hl: tables of port,value pairs:
150 ; db n, port1,val1, port2,val2,... portn,valn
152 ; db 0 ; Terminate table
154 cseg ; (common for now)
160 ld c,(hl) ;port address
173 ;----------------------------------------------------------------------
184 ; Let all vectors point to spurious int routines.
202 ;--------------------------------------------------------------------
203 ; Spurious interrupt handler
209 sp.int.len equ $-sp.int0
237 db 13,10,'Spurious Int: '
241 ;--------------------------------------------------------------------
243 ; Get/compute CPU clock
246 ; hlde: CPU frequency (Hz)
259 ; delay ~8ms @ 18.432MHz --> 147456 clock cycles
260 ; delay ~10ms @ 18.432MHz --> 184320 clock cycles
263 ; ld hl,8192 ; 147456/18
264 ld hl,10240 ; 184320/18
269 jr nz,dly_lp ; 6/8 -> 18
284 ld hl,00119h ;18432000/(2**16)
285 ld de,04000h ;18432000%(2**16)
298 ;--------------------------------------------------------------------
303 ld hl,1*256 + 3 ; d = subcommand, e = command
313 ld b,7 ; max receive message len
322 ;--------------------------------------------------------------------
332 ;--------------------------------------------------------------------
358 ; TODO: address translation
367 ; TODO: address translation
380 ld (ix+o.in_idx),0 ;reset pointers
382 ld (ix+o.mask),c ;reset "size"
384 push ix ;get phys. address of fifo
389 ld a,(ix+o.id) ;fifo id
412 db 0 ;subfunc: gets overwritten with buf id
415 bfi_msg_len equ $ - bfi_msg
416 bfi_msg_end equ $ - 1
418 ;----------------------------------------------------------------------