.dw 0,0,0,0,0,0
.globl enaslt
- .globl slotrom
- .globl slotram
+ .globl _slotrom
+ .globl _slotram
.globl find_ram
+ .globl kstack_top
+
; At this point the BIOS has detected the cartridge AB signature and
; jumped here; we have the rom bios in bank 0, ram in bank 3, and rom
ld ix,#0x00d5
call #0x015f
+ ; read slot registers from bios before overwritting them
+ call find_ram
+ ld hl,#0x8000
+ call enaslt ; set bank 2 to ram
+
+ ld a, #4
+ out (0xFE),a
+
call find_ram
- ld (slotram),a
+ ld d,a
call find_rom
- ld (slotrom),a
+ ld e,a
+ exx
- ; set cartridge rom in bank 0 and ram in bank 2
- ld hl,#0
+ ld hl,#0xc000
+ ld sp,#0xa000 ; keep stack in ram
+ call enaslt ; set bank 3 to rom
+
+ ; copy kernel page 0 from bank 3 to ram in bank 2
+ ; it contains the common area if the rom > 48Kb
+ ld hl, #0xc000
+ ld de, #0x8000
+ ld bc, #0x4000
+ ldir
+ exx
+
+ push de
+ ld hl,#0xc000 ; set bank 3 back to ram
+ ld a,d
call enaslt
- ld a,(slotram)
- ld hl,#0x8000
+ pop de ; store slot data in ram now
+ ld a, #4
+ out (0xFF),a
+ ld a,d
+ ld (_slotram),a
+ ld a,e
+ ld (_slotrom),a
+
+ ld sp, #kstack_top ; move stack to final location
+
+ ; set cartridge rom in bank 0
+ ld hl,#0
call enaslt
- ld a, #3
- out (0xFE),a
; copy kernel page 3 to ram
+ ld a, #3
+ out (0xFE),a
ld hl, #0x0
ld de, #0x8000
ld bc, #0x4000
ldir
; set ram in bank 0 and cartridge rom in bank 2
- ld a,(slotram)
+ ld a,(_slotram)
ld hl,#0
call enaslt
- ld a,(slotrom)
+ ld a,(_slotrom)
ld hl,#0x8000
call enaslt
out (0xFD), a
ld a, #1
out (0xFE), a
+ ld a, #4
+ out (0xFF),a
; set bank 2 to ram
- ld a,(slotram)
+ ld a,(_slotram)
ld hl,#0x8000
call enaslt
; Just for the benefit of the map file
.globl start
.globl enaslt
- .globl slotram
+ .globl _slotram
+ .globl _slotrom
.globl find_ram
; startup code @0x100
out (0x2f), a
; read slot before switching ram page
- ld a,(slotram)
+ ld a,(_slotram)
ld hl,#0x4000
call enaslt
- ld a, #4 ; 0 holds 8K of stuff we might want
- out (0xff), a ; if we go the OS route, so use 4
- ; plus "0" is magic so this saves
- ; shifting them all by one.
-
-
- ld sp, #kstack_top
-
+ ld a,(_slotram)
+ ld d,a
+ ld a,(_slotrom)
+ ld e,a
+ exx
; move the common memory where it belongs
ld hl, #s__INITIALIZER
ld de, #s__COMMONMEM
ld bc, #l__COMMONMEM
ldir
- ; move the discardable memory where it belongs
+ ; move the discardable memory where it belongs
ld de, #s__DISCARD
ld bc, #l__DISCARD
ldir
+ exx
+ ; restore slot data
+ ld a,d
+ ld (_slotram),a
+ ld a,e
+ ld (_slotrom),a
+
+
; then zero the data area
ld hl, #s__DATA
ld de, #s__DATA + 1
; stuff to save
.globl _vdpport
.globl _infobits
- .globl slotrom
- .globl slotram
+ .globl _slotrom
+ .globl _slotram
;
; vdp - we must initialize this bit early for the vt
_kernel_flag:
.db 1
-
-slotrom:
- .db 0
-slotram:
- .db 0
-
; -----------------------------------------------------------------------------
; KERNEL MEMORY BANK (below 0xF000, only accessible when the kernel is mapped)
; -----------------------------------------------------------------------------
call map_process_2
pop hl
ret
+
map_process_2:
push de
push af
.db 0,0,0,0
map_kernel_data:
.db 3,2,1,4
+_slotrom:
+ .db 0
+_slotram:
+ .db 0
; emulator debug port for now
outchar:
push af
out (0x2F), a
pop af
- ret
+ ret