;
; Boot block, loaded at 0x8000 in the top bank that is free (varies)
+; but this works so long as we are above bank 7. If that becomes
+; an issue then instead of flipping banks we can always ldir ourself
+; into bank 0 and run from there.
;
; The boot block is trivial but it gets a bit fun once we've loaded
; our 14 tracks
; We then run from 0x8000 in bank 6, which will untangle everything
; for us shuffling the kernel so that 0/1 is the low kernel in RAM
; 2/3 is the high kernel in RAM and 4/5 is the video
-; (or maybe it'll be saner to use 4/5 for kernel 2/3 video..)
;
.area BOOT(ABS)
.org 0x0000
rst 0 ; bang
; -----------------------------------------------------------------------------
-; KERNEL MEMORY BANK (below common, only accessible when the kernel is mapped)
+; We have discard mapped high up so we can map stuff under it
+; during setup. All of discard gets reclaimed when init is run
; -----------------------------------------------------------------------------
.area _DISCARD
init_hardware:
; set system RAM size (FIXME - check for 512/1M)
+ ld a,#0x10 ; Upper 256K
+ call map_page_low
+ ld hl,#0x0000
+ ld (hl),#0xff
+ ld a,(hl)
+ inc a
+ jr nz, is256k
+ ld (hl),a
+ ld a,(hl)
+ or a
+ ld hl,#512
+ jr z, is512k
+is256k:
ld hl, #256
+is512k:
ld (_ramsize), hl
- ld hl, #(256-96) ; 64K for kernel, 32K for video/font/etc
+ ld de,#96 ; 64K for kernel, 32K for video etc
+ sbc hl,de ; C is always clear here
ld (_procmem), hl
+ ld a,#VIDEO_LOW
+ call map_page_low ; Map the video in the low 32K
+
+ ; Place a copy of the high stubs into the video bank so that we
+ ; can in future field interrupts with video mapped. Quite a bit
+ ; of other work is needed for this due to the stack situation.
+ ld hl,#0xFF00
+ ld de,#0x7F00
+ ld bc,#0x100
+ ldir
+
+ call map_kernel_low
+
+ ; Make a copy of the low page somewhere accessible. This may
+ ; change if we decide to make the kernel low page different - eg
+ ; to fast path interrupts in kernel mode. FIXME
+ ld hl,#0x0000
+ ld de,#lowstubs
+ ld bc,#0x0068
+ ldir
+
im 1 ; set CPU interrupt mode
; interrupt mask
exx
; Copy the stub page into place
- ; FIXME: doesn't work because our stubs are at 0000. Maybe put
- ; a copy somewhere else ?
- ld hl, #stub_page_1 - 1
+ ld hl, #lowstubs
ld de, #0x0000
- ld bc, #0x0100
+ ld bc, #0x0068
ldir
exx
pop hl
ld h,#0 ; clear signal bit
ret
+
+ .area _DATA
+lowstubs:
+ .ds 0x68
call map_video
ld bc,#0x04FF ; it gets decremented by DJNZ while the FF
; ensures the ldi never decrements B
+;
+; Need to add a slow path version that does colour and effects. Colour
+; is a matter of masking with FF, CC, 33 or 00.
+;
plot_loop:
- ; FIXME: this trick doesn't work on the last row - need a better way
ldi ; copy expanded char
- ldi
- dec e
+ ld a,(hl)
+ ld (de),a
+ inc hl
dec e
set 7,e ; de += 126
ldi ; copy second char row
- ldi
- dec e ; Similar idea
+ ld a,(hl)
+ ld (de),a
+ inc hl
dec e ; toggle the bit back and gives us
res 7,e
inc d ; de += 126
djnz plot_loop
jr pop_unmap
+;
+; We will need this once we wire in colour support
+;
+plot_slow:
+ ld a,#4
+ exx
+ ld de,(colours)
+ exx
+plot_loop_slow:
+ ex af,af'
+ ld a,(hl)
+ exx
+ ld b,a
+ cpl ; background bits
+ and d ; to background colour
+ ld c,a
+ ld a,e ; foreground bits
+ and b ; to foreground colour
+ or c ; plus background
+ exx
+ ld (de),a
+ ld a,(hl)
+ inc de
+ inc hl
+ exx
+ ld b,a
+ cpl ; background bits
+ and d ; to background colour
+ ld c,a
+ ld a,e ; foreground bits
+ and b ; to foreground colour
+ or c ; plus background
+ exx
+ ld (de),a
+ add hl,bc
+ ex af,af'
+ dec a
+ jr nz, plot_loop_slow
+ jr pop_unmap
+
_clear_lines:
pop hl
pop de
inc de
dec bc
ld (hl),#0
- jr ldir_pop
+ jp ldir_pop
_clear_across:
pop hl
_cursor_disable:
_vtattr_notify:
ret
+
+colours:
+ .word 0