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
88 dmclrt: ;clear ram per dma
91 dw nullbyte ;src (fixed)
94 dw romend ;dst (inc), start after "rom" code
96 dw 0-romend ;count (64k)
106 in0 a,(itc) ;Illegal opcode trap?
108 ld a,i ;I register == 0 ?
109 jr z,hw_reset ; yes, harware reset
115 pop af ;restore registers
121 out0 (rcr),a ; configure DRAM refresh
123 out0 (dcntl),a ; wait states
125 ld a,M_NCD ;No Clock Divide
127 ; ld a,M_X2CM ;X2 Clock Multiplier
135 ; check warm start mark
137 ld ix,mark_55AA ; top of common area
148 ld sp,$stack ; mark found, check
149 jp z,wstart ; check ok,
151 ; ram not ok, initialize -- kstart --
163 ; Clear RAM using DMA0
168 ld hl,dmclrt ;load DMA registers
170 ld a,0cbh ;01ef dst +1, src fixed, burst
174 ld a,062h ;01f4 enable dma0,
176 out0 (dstat),a ;01f9 clear (up to) 64k
177 djnz ??cl_1 ; end of RAM?
182 ld hl,055AAh ;set warm start mark
203 ld a,INIDONEVAL ;tell others (CP/M) that hardware and fifos
204 ld (INIDONE),a ; are allready initialized
228 ;----------------------------------------------------------------------
245 push hl ;save fifo_list
253 ; TODO: address translation
257 pop hl ;get fifo_list back
276 ;----------------------------------------------------------------------
278 extrn msginit,msg.sout
279 extrn mtx.fifo,mrx.fifo
280 extrn co.fifo,ci.fifo
367 buftablen equ ($ - buffers)/3
382 ;----------------------------------------------------------------------
388 ld bc,sysrame-sysramw
393 ;----------------------------------------------------------------------
403 ; Let all vectors point to spurious int routines.
417 ;----------------------------------------------------------------------
419 ; Reload value for 10 ms Int. (0.1KHz):
420 ; tc10ms = phi/prescale/0.1KHz = phi / (prescale/10)
422 PRT_TC10MS equ 18432 / (PRT_PRE/10)
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 ;----------------------------------------------------------------------
551 ;--------------------------------------------------------------------
552 ; Return the BBR value for the given bank number
559 ret z ; Bank 0 is at physical address 0
570 ;--------------------------------------------------------------
575 ;out ahl: Phys. (linear) Address
582 ;--------------------------------------------------------------
589 ; hl hhhhhhhhllllllll
592 ; OP: ahl = (a<<12) + (h<<8) + l
594 ;out ahl: Phys. (linear) Address
610 ;--------------------------------------------------------------
615 ; OP: ahl = (bankbase<<12) + (d<<8) + e
617 ;out ahl: Phys. (linear) Address
624 or 00fh ; log. addr in common1?
628 in0 a,(cbr) ; yes, cbr is address base
631 ld b,16 ; log. address in baked area?
636 in0 a,(bbr) ; yes, bbr is address base
643 pop bc ; bank part is 0, no translation
650 ;----------------------------------------------------------------------
655 jr nc,b2p_1 ;A15=1 --> common
664 ;--------------------------------------------------------------
678 ; ---------------------------------------------------------
685 ; Trampoline for interrupt routines in banked ram.
686 ; Switch stack pointer to "system" stack in top ram
690 ex (sp),hl ;save hl, 'return adr' in hl
693 ex de,hl ;'return address' in de
698 jr nc,isw_1 ;stack allready in top ram
701 push hl ;save user stack pointer
727 ; ---------------------------------------------------------
754 ; ---------------------------------------------------------
759 sp.int.len equ $-sp.int0
779 ; ---------------------------------------------------------
784 ; This routine may not be loaded in page zero
786 ; return Carry clear, if INTs are enabled.
790 xor a ;clear accu and carry
791 push af ;stack bottom := 00xxh
793 ld a,i ;P flag := IFF2
794 ret pe ;exit carry clear, if enabled
796 dec sp ;has stack bottom been overwritten?
798 and a ;if not 00xxh, INTs were
799 ret nz ;actually enabled
800 scf ;Otherwise, they really are disabled
803 ;----------------------------------------------------------------------
837 ret c ;INTs were disabled
841 ;----------------------------------------------------------------------
876 ret nc ;INTs were disabled
882 ;----------------------------------------------------------------------
920 global mm_sio0, mm_sio1
922 @cbnk: db 0 ; current bank (0..2)
931 ;----------------------------------------------------------------------
941 ;-----------------------------------------------------
947 ;ivtab equ 0ffc0h ; 0ffc0h ;int vector table
951 mark_55AA equ 0 - 2 - 4 ;2 byte for trap stack