6 global bnk2log,bnk2phy,hwl2phy
12 ;----------------------------------------------------------------------
15 ; Common CAStart ... 0FFFF
16 ; Bank 0 00000 ... CAStart-1
20 ;----------------------------------------------------------------------
29 ;--------------------------------------------------------------------
30 ; Return the BBR value for the given bank number
37 ret z ; Bank 0 is at physical address 0
43 mlt bc ; bank size * bank number
45 add a,10h ; add bank0 + common
49 ;--------------------------------------------------------------
54 ;out ahl: Phys. (linear) Address
67 xor a ; address is in common
68 jr b2b_cont ; base is 0
70 call bnk2log ; get address base
75 ;--------------------------------------------------------------
85 ; OP: ahl = (a<<12) + (h<<8) + l
87 ;out ahl: Phys. (linear) Address
103 ;--------------------------------------------------------------
108 ; OP: ahl = (bankbase<<12) + (d<<8) + e
110 ;out ahl: Phys. (linear) Address
117 or 00fh ; log. addr in common1?
121 in0 a,(cbr) ; yes, cbr is address base
124 ld b,16 ; log. address in baked area?
129 in0 a,(bbr) ; yes, bbr is address base
136 pop bc ; bank part is 0, no translation
140 ;--------------------------------------------------------------
141 ; Trampoline for routines in banked ram.
142 ; Switch stack pointer to "system" stack in top ram
158 pop de ;get ptr to 'function address' in de
161 push hl ;put return address on stack
168 cp high (bs$stack-bs$stack$size) ;link80 can't process this
169 jr nc,$ + 5 ;skip if stack allready in common bios ram
173 ld hl,bs$stack-bs$stack$size
179 jr c,$ + 5 ;skip if stack allready in common bios ram
183 push hl ;save user stack pointer
191 ld e,(hl) ;get 'function address'
194 push de ;put on (switched) stack
196 ld hl,(b0_save_af) ;get back users registers
219 ;====================================================================
223 ;--------------------------------------------------------------------
224 ; Return the BBR value for the given bank number
240 ld ix,bnktbl ;4 / 12 | 14
241 ld ($+3+2),a ;3 / 15 | 19
242 ld a,(ix+0) ;3 / 14 | 19
244 ret ;1 / 9 | 10 15 / 76|91
247 ld hl,bnktbl ;3 / 9 | 10
255 ret ;1 / 9 | 10 12 / 66|71
258 add a,low bnktbl ;2 / 6 | 7
261 adc a,high bnktbl ;2 / 6 | 7
265 ret ;1 / 9 | 10 11 / 61|67