6 extrn $coninit,$cists,$ci
21 ;----------------------------------------------------------------------
36 ;----------------------------------------------------------------------
44 dmclrt: ;clear ram per dma
47 dw nullbyte ;src (fixed)
50 dw romend ;dst (inc), start after "rom" code
52 dw 0-romend ;count (64k)
58 INIWAITS defl INIWAITS+CWAITROM
63 db rcr,CREFSH ;configure DRAM refresh
64 db dcntl,INIWAITS ;wait states
67 ;----------------------------------------------------------------------
71 in0 a,(itc) ;003d Illegal opcode trap?
74 jp bpent ;0044 yes, handle
77 ld a,i ;0047 I register == 0 ?
78 jr z,??st02 ;004b yes, harware reset
80 jp bpent ;004e no, allready set up
85 out0 (rcr),a ; configure DRAM refresh
87 out0 (dcntl),a ; wait states
89 ; search warm start mark
91 ld ix,mark_55AA ;00b8 ; top of common area
95 ex af,af' ;00be ;for cbr = 0x70 downto 0x40
100 jr z,kstart ;00c3 ; break (mark not found)
113 ld sp,$stack ;00e0 mark found, check
114 call checkcrc_alv ;00e3
115 jp z,wstart ;00e6 check ok,
118 ; ram not ok, initialize -- kstart --
122 ld a,088h ;00e9 0000-7fff: common 0
123 out0 (cbar),a ;00eb 8000-ffff: common 1
125 ld a,0 ;00f1 start at 008000 (2. phys. 32k block)
133 add a,8 ;010a next 'bank'
134 cp 078h ;010c stop at 078000
137 ld de,8000h ;0114 first block not tested, but mark as ok
138 ld a,0 ;00f1 start at 008000 (2. phys. 32k block)
155 cp 078h ; stop at 078000
159 ; ram test found 1 or more error free blocks (32k)
167 ld c,070h ;01ce highest block
171 jr c,alloc ;01d4 highest "error free" block
177 slp ;01dc should never be reached
183 ; Clear RAM using DMA0
185 ld hl,dmclrt ;load DMA registers
187 ld a,0cbh ;01ef dst +1, src fixed, burst
191 ld a,062h ;01f4 enable dma0,
193 out0 (dstat),a ;01f9 clear (up to) 64k
194 djnz ??cl_1 ; end of RAM?
198 ld hl,banktabsys ;020f
199 ld (hl),c ; Common area
201 ld (hl),c ; System work area
202 inc hl ;0215 Point to bank 0 entry
205 ld (hl),0ffh ;0218 Mark all banks as unassigned
210 ld b,8 ; 8*4k ie. first 32k
212 ld (hl),0e0h ; mark as sys ("rom"/monitor)
216 rr d ; shift out bit for block 0
218 ld c,15 ;022c 15*32k remaining blocks
220 ld a,0feh ; 0xfe == block with error(s)
223 adc a,0 ; ==> 0xff : block ok
224 ld b,32/4 ; 32k == 8 * 4k
230 jr nz,l022eh ;next 32k block
232 ld hl,memalv+0ch ;memalv+0ch
237 ld (hl),0ech ;alloc system ram
240 ld (hl),0efh ;alloc common
244 ld bc,0f0fh ; size (?) (4k blocks)
246 call sub_0420h ;alloc mem for bank 0
259 ld hl,055AAh ;set warm start mark
264 ; crc ok -- wstart --
267 call sysram_init ;027f
295 ;----------------------------------------------------------------------
298 extrn msginit,msg.sout,msg_fifo
302 ;TODO: Make a ringbuffer module.
312 ;----------------------------------------------------------------------
360 ;----------------------------------------------------------------------
366 ld bc,sysrame-sysramw
371 ;----------------------------------------------------------------------
379 ; Let all vectors point to spurious int routines.
409 db prt0it_e-prt0itab-2
413 db M_TIE0+M_TDE0 ;enable timer 0 interrupt and down count.
417 ;----------------------------------------------------------------------
422 ld b,0 ;high byte port adress
426 ld c,(hl) ;port address
429 inc b ;outi decrements b
448 ;----------------------------------------------------------------------
498 ld hl,banktabsys ;03f9
514 ld hl,banktabsys ;040d
515 ld bc,crc_len+2 ;0410
533 ; 2 == no bank # in requested range
538 call checkcrc_alv ;0420
539 jr nz,l049ch ;0424 crc error, tables corrupt
541 call sub_049dh ;0427 bank # in req. range available?
558 inc a ;043e free blocks are marked 0ffh
566 pop ix ;0447 free blocks start here
569 l044dh: ; count free blocks
579 ; end of free blocks run.
583 cp e ;0458 nr of blocks >= requested ?
624 call gencrc_alv ;048e
639 ; search a free bank number in range
643 ; l: bank number available
644 ; nc, if found, bank nr. in l
653 inc e ;04a1 test next #
660 cpir ;04ad bank# allready allocated?
661 jr z,l04a1h ;04af if yes, search for next
678 call gencrc_alv ;04c4
680 or a ;04c8 clear carry
684 ;--------------------------------------------------------------
689 ;out ahl: Phys. (linear) Address
700 ;--------------------------------------------------------------
705 ; OP: ahl = (a<<12) + (d<<8) + e
707 ;out ehl: Phys. (linear) Address
717 add hl,bc ;bc + d == a<<4 + d
725 ;--------------------------------------------------------------
739 ; ---------------------------------------------------------
746 ; Trampoline for interrupt routines in banked ram.
747 ; Switch stack pointer to "system" stack in top ram
751 ex (sp),hl ; save hl, return adr in hl
788 ; ---------------------------------------------------------
811 ; ---------------------------------------------------------
816 sp.int.len equ $-sp.int0
844 ;-----------------------------------------------------
855 ds 512/4 ;Number of 4k blocks
857 crc_len equ $-banktabsys
865 ;ivtab equ 0ffc0h ; 0ffc0h ;int vector table