6 extrn charini,?const,?conin
23 ;----------------------------------------------------------------------
42 ;----------------------------------------------------------------------
60 INIWAITS defl INIWAITS+CWAITROM
63 ;----------------------------------------------------------------------
75 ;----------------------------------------------------------------------
80 db rcr,CREFSH ;configure DRAM refresh
81 db dcntl,INIWAITS ;wait states
87 dmclrt: ;clear ram per dma
90 dw nullbyte ;src (fixed)
93 dw romend ;dst (inc), start after "rom" code
95 dw 0-romend ;count (64k)
105 in0 a,(itc) ;Illegal opcode trap?
107 ld a,i ;I register == 0 ?
108 jr z,hw_reset ; yes, harware reset
114 pop af ;restore registers
120 out0 (rcr),a ; configure DRAM refresh
122 out0 (dcntl),a ; wait states
124 ld a,M_NCD ;No Clock Divide
126 ; ld a,M_X2CM ;X2 Clock Multiplier
134 ; check warm start mark
136 ld ix,mark_55AA ; top of common area
147 ld sp,$stack ; mark found, check
148 jp z,wstart ; check ok,
150 ; ram not ok, initialize -- kstart --
162 ; Clear RAM using DMA0
167 ld hl,dmclrt ;load DMA registers
169 ld a,0cbh ;01ef dst +1, src fixed, burst
173 ld a,062h ;01f4 enable dma0,
175 out0 (dstat),a ;01f9 clear (up to) 64k
176 djnz ??cl_1 ; end of RAM?
181 ld hl,055AAh ;set warm start mark
188 call sysram_init ;027f
224 ;----------------------------------------------------------------------
227 ;TODO: Make a ringbuffer module.
237 ;----------------------------------------------------------------------
239 extrn msginit,msg_tx_fifo,msg_rx_fifo
282 ;----------------------------------------------------------------------
284 extrn msginit,msg.sout
285 extrn mtx.fifo,mrx.fifo
286 extrn co.fifo,ci.fifo
373 buftablen equ ($ - buffers)/3
388 ;----------------------------------------------------------------------
394 ld bc,sysrame-sysramw
399 ;----------------------------------------------------------------------
409 ; Let all vectors point to spurious int routines.
423 ;----------------------------------------------------------------------
441 db prt0it_e-prt0itab-2
445 db M_TIE0+M_TDE0 ;enable timer 0 interrupt and down count.
452 ;----------------------------------------------------------------------
459 ld b,0 ;high byte port adress
466 ld c,(hl) ;port address
470 inc b ;outi decrements b
483 ld c,(hl) ;port address
487 dec c ;otim increments c
493 inc b ;stop if count == 0
506 ld c,(hl) ;port address
518 ;----------------------------------------------------------------------
547 ;----------------------------------------------------------------------
567 ;out ahl: Phys. (linear) Address
574 ;--------------------------------------------------------------
579 ; OP: ahl = (a<<12) + (d<<8) + e
581 ;out ahl: Phys. (linear) Address
591 add hl,bc ;7 bc + d == a<<4 + d
614 ;--------------------------------------------------------------
619 ; OP: ahl = (bankbase<<12) + (d<<8) + e
621 ;out ahl: Phys. (linear) Address
646 add hl,bc ;bc + d == a<<4 + d
656 ;----------------------------------------------------------------------
661 jr nc,b2p_1 ;A15=1 --> common
670 ;--------------------------------------------------------------
684 ; ---------------------------------------------------------
691 ; Trampoline for interrupt routines in banked ram.
692 ; Switch stack pointer to "system" stack in top ram
696 ex (sp),hl ; save hl, return adr in hl
733 ; ---------------------------------------------------------
760 ; ---------------------------------------------------------
765 sp.int.len equ $-sp.int0
785 ; ---------------------------------------------------------
790 ; This routine may not be loaded in page zero
792 ; return Carry clear, if INTs are enabled.
796 xor a ;clear accu and carry
797 push af ;stack bottom := 00xxh
799 ld a,i ;P flag := IFF2
800 ret pe ;exit carry clear, if enabled
802 dec sp ;has stack bottom been overwritten?
804 and a ;if not 00xxh, INTs were
805 ret nz ;actually enabled
806 scf ;Otherwise, they really are disabled
809 ;----------------------------------------------------------------------
843 ret c ;INTs were disabled
847 ;----------------------------------------------------------------------
882 ret nc ;INTs were disabled
888 ;----------------------------------------------------------------------
926 global mm_sio0, mm_sio1
928 @cbnk: db 0 ; current bank (0..2)
937 ;----------------------------------------------------------------------
947 ;-----------------------------------------------------
953 ;ivtab equ 0ffc0h ; 0ffc0h ;int vector table
957 mark_55AA equ 0 - 2 - 4 ;2 byte for trap stack