6 extrn $coninit,$cists,$ci
21 ;----------------------------------------------------------------------
37 ;----------------------------------------------------------------------
51 dmclrt: ;clear ram per dma
54 dw nullbyte ;src (fixed)
57 dw romend ;dst (inc), start after "rom" code
59 dw 0-romend ;count (64k)
64 INIWAITS defl INIWAITS+CWAITROM
69 db rcr,CREFSH ;configure DRAM refresh
70 db dcntl,INIWAITS ;wait states
73 ;----------------------------------------------------------------------
77 in0 a,(itc) ;003d Illegal opcode trap?
80 jp bpent ;0044 yes, handle
83 ld a,i ;0047 I register == 0 ?
84 jr z,??st02 ;004b yes, harware reset
86 jp bpent ;004e no, allready set up
91 out0 (rcr),a ; configure DRAM refresh
93 out0 (dcntl),a ; wait states
95 ld a,M_NCD ;No Clock Divide
97 ld a,M_X2CM ;X2 Clock Multiplier
100 ; search warm start mark
102 ld ix,mark_55AA ;00b8 ; top of common area
106 ex af,af' ;00be ;for cbr = 0x70 downto 0x40
111 jr z,kstart ;00c3 ; break (mark not found)
124 ld sp,$stack ;00e0 mark found, check
125 call checkcrc_alv ;00e3
126 jp z,wstart ;00e6 check ok,
129 ; ram not ok, initialize -- kstart --
133 ld a,088h ;00e9 0000-7fff: common 0
134 out0 (cbar),a ;00eb 8000-ffff: common 1
136 ld a,0 ;00f1 start at 008000 (2. phys. 32k block)
144 add a,8 ;010a next 'bank'
145 cp 078h ;010c stop at 078000
148 ld de,8000h ;0114 first block not tested, but mark as ok
149 ld a,0 ;00f1 start at 008000 (2. phys. 32k block)
166 cp 078h ; stop at 078000
170 ; ram test found 1 or more error free blocks (32k)
178 ld c,070h ;01ce highest block
182 jr c,alloc ;01d4 highest "error free" block
188 slp ;01dc should never be reached
194 ; Clear RAM using DMA0
196 ld hl,dmclrt ;load DMA registers
198 ld a,0cbh ;01ef dst +1, src fixed, burst
202 ld a,062h ;01f4 enable dma0,
204 out0 (dstat),a ;01f9 clear (up to) 64k
205 djnz ??cl_1 ; end of RAM?
209 ld hl,banktabsys ;020f
210 ld (hl),c ; Common area
212 ld (hl),c ; System work area
213 inc hl ;0215 Point to bank 0 entry
216 ld (hl),0ffh ;0218 Mark all banks as unassigned
221 ld b,8 ; 8*4k ie. first 32k
223 ld (hl),0e0h ; mark as sys ("rom"/monitor)
227 rr d ; shift out bit for block 0
229 ld c,15 ;022c 15*32k remaining blocks
231 ld a,0feh ; 0xfe == block with error(s)
234 adc a,0 ; ==> 0xff : block ok
235 ld b,32/4 ; 32k == 8 * 4k
241 jr nz,l022eh ;next 32k block
243 ld hl,memalv+0ch ;memalv+0ch
248 ld (hl),0ech ;alloc system ram
251 ld (hl),0efh ;alloc common
255 ld bc,0f0fh ; size (?) (4k blocks)
257 call sub_0420h ;alloc mem for bank 0
270 ld hl,055AAh ;set warm start mark
275 ; crc ok -- wstart --
278 call sysram_init ;027f
306 ;----------------------------------------------------------------------
309 ;TODO: Make a ringbuffer module.
319 ;----------------------------------------------------------------------
321 extrn msginit,msg.sout,msg_fifo
370 ;----------------------------------------------------------------------
374 extrn msginit,msg.sout,msg_fifo
426 ;----------------------------------------------------------------------
432 ld bc,sysrame-sysramw
437 ;----------------------------------------------------------------------
445 ; Let all vectors point to spurious int routines.
459 ;----------------------------------------------------------------------
476 db prt0it_e-prt0itab-2
480 db M_TIE0+M_TDE0 ;enable timer 0 interrupt and down count.
485 ;----------------------------------------------------------------------
490 ld b,0 ;high byte port adress
494 ld c,(hl) ;port address
497 inc b ;outi decrements b
516 ;----------------------------------------------------------------------
566 ld hl,banktabsys ;03f9
582 ld hl,banktabsys ;040d
583 ld bc,crc_len+2 ;0410
590 ;----------------------------------------------------------------------
603 ; 2 == no bank # in requested range
608 call checkcrc_alv ;0420
609 jr nz,l049ch ;0424 crc error, tables corrupt
611 call sub_049dh ;0427 bank # in req. range available?
628 inc a ;043e free blocks are marked 0ffh
636 pop ix ;0447 free blocks start here
639 l044dh: ; count free blocks
649 ; end of free blocks run.
653 cp e ;0458 nr of blocks >= requested ?
694 call gencrc_alv ;048e
709 ; search a free bank number in range
713 ; l: bank number available
714 ; nc, if found, bank nr. in l
723 inc e ;04a1 test next #
730 cpir ;04ad bank# allready allocated?
731 jr z,l04a1h ;04af if yes, search for next
748 call gencrc_alv ;04c4
750 or a ;04c8 clear carry
754 ;--------------------------------------------------------------
759 ;out ahl: Phys. (linear) Address
770 ;--------------------------------------------------------------
775 ; OP: ahl = (a<<12) + (d<<8) + e
777 ;out ahl: Phys. (linear) Address
787 add hl,bc ;bc + d == a<<4 + d
795 ;--------------------------------------------------------------
809 ; ---------------------------------------------------------
816 ; Trampoline for interrupt routines in banked ram.
817 ; Switch stack pointer to "system" stack in top ram
821 ex (sp),hl ; save hl, return adr in hl
858 ; ---------------------------------------------------------
882 ; ---------------------------------------------------------
887 sp.int.len equ $-sp.int0
915 ;-----------------------------------------------------
926 ds 512/4 ;Number of 4k blocks
928 crc_len equ $-banktabsys
936 ;ivtab equ 0ffc0h ; 0ffc0h ;int vector table