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.sout
240 extrn mtx.fifo,mrx.fifo
241 extrn co.fifo,ci.fifo
328 buftablen equ ($ - buffers)/3
343 ;----------------------------------------------------------------------
349 ld bc,sysrame-sysramw
354 ;----------------------------------------------------------------------
364 ; Let all vectors point to spurious int routines.
378 ;----------------------------------------------------------------------
396 db prt0it_e-prt0itab-2
400 db M_TIE0+M_TDE0 ;enable timer 0 interrupt and down count.
407 ;----------------------------------------------------------------------
414 ld b,0 ;high byte port adress
421 ld c,(hl) ;port address
425 inc b ;outi decrements b
438 ld c,(hl) ;port address
442 dec c ;otim increments c
448 inc b ;stop if count == 0
461 ld c,(hl) ;port address
473 ;----------------------------------------------------------------------
502 ;----------------------------------------------------------------------
506 ;--------------------------------------------------------------------
507 ; Return the BBR value for the given bank number
514 ret z ; Bank 0 is at physical address 0
525 ;--------------------------------------------------------------
530 ;out ahl: Phys. (linear) Address
537 ;--------------------------------------------------------------
544 ; hl hhhhhhhhllllllll
547 ; OP: ahl = (a<<12) + (h<<8) + l
549 ;out ahl: Phys. (linear) Address
565 ;--------------------------------------------------------------
570 ; OP: ahl = (bankbase<<12) + (d<<8) + e
572 ;out ahl: Phys. (linear) Address
579 or 00fh ; log. addr in common1?
583 in0 a,(cbr) ; yes, cbr is address base
586 ld b,16 ; log. address in baked area?
591 in0 a,(bbr) ; yes, bbr is address base
598 pop bc ; bank part is 0, no translation
605 ;----------------------------------------------------------------------
610 jr nc,b2p_1 ;A15=1 --> common
619 ;--------------------------------------------------------------
633 ; ---------------------------------------------------------
640 ; Trampoline for interrupt routines in banked ram.
641 ; Switch stack pointer to "system" stack in top ram
645 ex (sp),hl ;save hl, 'return adr' in hl
648 ex de,hl ;'return address' in de
653 jr nc,isw_1 ;stack allready in top ram
656 push hl ;save user stack pointer
682 ; ---------------------------------------------------------
709 ; ---------------------------------------------------------
714 sp.int.len equ $-sp.int0
734 ; ---------------------------------------------------------
739 ; This routine may not be loaded in page zero
741 ; return Carry clear, if INTs are enabled.
745 xor a ;clear accu and carry
746 push af ;stack bottom := 00xxh
748 ld a,i ;P flag := IFF2
749 ret pe ;exit carry clear, if enabled
751 dec sp ;has stack bottom been overwritten?
753 and a ;if not 00xxh, INTs were
754 ret nz ;actually enabled
755 scf ;Otherwise, they really are disabled
758 ;----------------------------------------------------------------------
792 ret c ;INTs were disabled
796 ;----------------------------------------------------------------------
831 ret nc ;INTs were disabled
837 ;----------------------------------------------------------------------
875 global mm_sio0, mm_sio1
877 @cbnk: db 0 ; current bank (0..2)
886 ;----------------------------------------------------------------------
896 ;-----------------------------------------------------
902 ;ivtab equ 0ffc0h ; 0ffc0h ;int vector table
906 mark_55AA equ 0 - 2 - 4 ;2 byte for trap stack