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)
57 INIWAITS defl INIWAITS+CWAITROM
62 db rcr,CREFSH ;configure DRAM refresh
63 db dcntl,INIWAITS ;wait states
66 ;----------------------------------------------------------------------
70 in0 a,(itc) ;003d Illegal opcode trap?
73 jp bpent ;0044 yes, handle
76 ld a,i ;0047 I register == 0 ?
77 jr z,??st02 ;004b yes, harware reset
79 jp bpent ;004e no, allready set up
84 out0 (rcr),a ; configure DRAM refresh
86 out0 (dcntl),a ; wait states
88 ; search warm start mark
90 ld ix,mark_55AA ;00b8 ; top of common area
94 ex af,af' ;00be ;for cbr = 0x70 downto 0x40
99 jr z,kstart ;00c3 ; break (mark not found)
112 ld sp,$stack ;00e0 mark found, check
113 call checkcrc_alv ;00e3
114 jp z,wstart ;00e6 check ok,
117 ; ram not ok, initialize -- kstart --
121 ld a,088h ;00e9 0000-7fff: common 0
122 out0 (cbar),a ;00eb 8000-ffff: common 1
124 ld a,0 ;00f1 start at 008000 (2. phys. 32k block)
132 add a,8 ;010a next 'bank'
133 cp 078h ;010c stop at 078000
136 ld de,8000h ;0114 first block not tested, but mark as ok
137 ld a,0 ;00f1 start at 008000 (2. phys. 32k block)
154 cp 078h ; stop at 078000
158 ; ram test found 1 or more error free blocks (32k)
166 ld c,070h ;01ce highest block
170 jr c,alloc ;01d4 highest "error free" block
176 slp ;01dc should never be reached
182 ; Clear RAM using DMA0
184 ld hl,dmclrt ;load DMA registers
186 ld a,0cbh ;01ef dst +1, src fixed, burst
190 ld a,062h ;01f4 enable dma0,
192 out0 (dstat),a ;01f9 clear (up to) 64k
193 djnz ??cl_1 ; end of RAM?
197 ld hl,banktabsys ;020f
198 ld (hl),c ; Common area
200 ld (hl),c ; System work area
201 inc hl ;0215 Point to bank 0 entry
204 ld (hl),0ffh ;0218 Mark all banks as unassigned
209 ld b,8 ; 8*4k ie. first 32k
211 ld (hl),0e0h ; mark as sys ("rom"/monitor)
215 rr d ; shift out bit for block 0
217 ld c,15 ;022c 15*32k remaining blocks
219 ld a,0feh ; 0xfe == block with error(s)
222 adc a,0 ; ==> 0xff : block ok
223 ld b,32/4 ; 32k == 8 * 4k
229 jr nz,l022eh ;next 32k block
231 ld hl,memalv+0ch ;memalv+0ch
236 ld (hl),0ech ;alloc system ram
239 ld (hl),0efh ;alloc common
243 ld bc,0f0fh ; size (?) (4k blocks)
245 call sub_0420h ;alloc mem for bank 0
258 ld hl,055AAh ;set warm start mark
263 ; crc ok -- wstart --
266 call sysram_init ;027f
294 ;----------------------------------------------------------------------
297 ;TODO: Make a ringbuffer module.
307 ;----------------------------------------------------------------------
311 extrn msginit,msg.sout,msg_fifo
363 ;----------------------------------------------------------------------
369 ld bc,sysrame-sysramw
374 ;----------------------------------------------------------------------
382 ; Let all vectors point to spurious int routines.
396 ;----------------------------------------------------------------------
413 db prt0it_e-prt0itab-2
417 db M_TIE0+M_TDE0 ;enable timer 0 interrupt and down count.
422 ;----------------------------------------------------------------------
427 ld b,0 ;high byte port adress
431 ld c,(hl) ;port address
434 inc b ;outi decrements b
453 ;----------------------------------------------------------------------
503 ld hl,banktabsys ;03f9
519 ld hl,banktabsys ;040d
520 ld bc,crc_len+2 ;0410
527 ;----------------------------------------------------------------------
540 ; 2 == no bank # in requested range
545 call checkcrc_alv ;0420
546 jr nz,l049ch ;0424 crc error, tables corrupt
548 call sub_049dh ;0427 bank # in req. range available?
565 inc a ;043e free blocks are marked 0ffh
573 pop ix ;0447 free blocks start here
576 l044dh: ; count free blocks
586 ; end of free blocks run.
590 cp e ;0458 nr of blocks >= requested ?
631 call gencrc_alv ;048e
646 ; search a free bank number in range
650 ; l: bank number available
651 ; nc, if found, bank nr. in l
660 inc e ;04a1 test next #
667 cpir ;04ad bank# allready allocated?
668 jr z,l04a1h ;04af if yes, search for next
685 call gencrc_alv ;04c4
687 or a ;04c8 clear carry
691 ;--------------------------------------------------------------
696 ;out ahl: Phys. (linear) Address
707 ;--------------------------------------------------------------
712 ; OP: ahl = (a<<12) + (d<<8) + e
714 ;out ahl: Phys. (linear) Address
724 add hl,bc ;bc + d == a<<4 + d
732 ;--------------------------------------------------------------
746 ; ---------------------------------------------------------
753 ; Trampoline for interrupt routines in banked ram.
754 ; Switch stack pointer to "system" stack in top ram
758 ex (sp),hl ; save hl, return adr in hl
795 ; ---------------------------------------------------------
819 ; ---------------------------------------------------------
824 sp.int.len equ $-sp.int0
852 ;-----------------------------------------------------
863 ds 512/4 ;Number of 4k blocks
865 crc_len equ $-banktabsys
873 ;ivtab equ 0ffc0h ; 0ffc0h ;int vector table