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)
255 ; delay ~8ms @ 18.432MHz --> 147456 clock cycles
256 ; delay ~10ms @ 18.432MHz --> 184320 clock cycles
259 ; ld hl,8192 ; 147456/18
260 ld hl,10240 ; 184320/18
265 jr nz,dly_lp ; 6/8 -> 18
283 ld hl,00119h ;18432000/(2**16)
284 ld de,04000h ;18432000%(2**16)
297 ;--------------------------------------------------------------------
306 ld b,tmr_rcv_msg_len ; max receive message len
311 db 3 ; timer/clock command
312 db 1 ; subcommand (get timer)
313 timer_msg_len equ $ - timer_msg
322 tmr_rcv_msg_len equ $ - tmr_rcv_msg_1
332 ;--------------------------------------------------------------------
342 ;--------------------------------------------------------------------
368 ; TODO: address translation
377 ; TODO: address translation
390 ld (ix+o.in_idx),0 ;reset pointers
392 ld (ix+o.mask),c ;reset "size"
394 push ix ;get phys. address of fifo
399 ld a,(ix+o.id) ;fifo id
422 db 0 ;subfunc: gets overwritten with buf id
425 bfi_msg_len equ $ - bfi_msg
426 bfi_msg_end equ $ - 1
428 ;----------------------------------------------------------------------