We now have the video memory mappable.
Extract the bank bits from hardcoding so we can later share code better
between related ZX ports
(we have 2 spare banks here but it's not clear what use they
actually are).
-4000-7FFF Kernel data continued (lots of space)
+4000-5FFF Spectrum screen memory and system variables
+6000-7FFF Kernel data
8000-83FF Needed to create the exec of init
8400-BFFF _DISCARD area - blown away when we exec init
4: User process
5: Mapped at 0x4000-0x7FFF (Kernel data/common)
6: User process (holds the 0x8000-BFFF of the other task)
- 7: CODE3, Display + Video (some room)
+ 7: CODE3, Video (lots of room)
We can move some stuff down into the low 16K (especially once we move the
common space) We do need to do sort things out a bit and stuff commonmem etc
Right now we ldir in one case (could be faster abusing stack), and
the exchange case could be made much much faster using registers
and stack tricks not bounce buffers
-- Set video space in CODE3 bank to 0 not 0xFF for neatness
- Look at what is needed for other suitable interfaces. DIVMMC would
in particular be good to support but that means another harder
bootloader hack
- SpectraNet (W5100)
-
Devices To Look At:
DIVIDE: These have at least 32K of 8K banks. They are awkward to use
DONE - Hangs on pause(). Review p->p_timeout behaviour
DONE - Crash on pre-emption, appears to be a bug in fuse-1.5.4
(moved code/consts to avoid Fuse bug, filed Fuse bug)
+DONE - Move video to 4000 and data to 6000 so that we have video
+ direct mappable by user space and also make it easier if we
+ have to work via ROMs that want spectrum system variable stuff
PROGLOAD .equ 0x8000
NBUFS .equ 5
+
+BANK_BITS .equ 0x10 ; Spectrum ROM select
+ ; Doesn't really matter!
\ No newline at end of file
ld hl, (U_DATA__U_PAGE)
ld a, l
ld bc, #0x7ffd
- or #0x18
+ or #BANK_BITS
out (c), a
; This includes the stacks, so be careful on restore
ld bc, #U_DATA__TOTALSIZE
ldir
ld a, (current_map)
- or #0x18
+ or #BANK_BITS
ld bc, #0x7ffd
out (c), a
; We are in DI so we can poke these directly but must not invoke
; any code outside of common
- or #0x18 ; ROM
+ or #BANK_BITS ; ROM
; Pages please !
ld bc, #0x7ffd
out (c), a
;
ld a, (current_map)
- or #0x18
+ or #BANK_BITS
ld bc, #0x7ffd
out (c), a
exx
ld hl, #0x8000
ld de, #0xc000
- ld a, #6 + 0x18
+ ld a, #6 + BANK_BITS
ld bc, #0x7ffd
out (c), a
flip2:
jr nz, flip1
ld a, (current_map)
- or #0x18
+ or #BANK_BITS
ld bc, #0x7ffd
out (c), a
exx
; Interrupts should be off when this is called
_dup_low_page:
di ; FIXME: check callers properly
- ld a, #0x06 + 0x18 ; low page alternate
+ ld a, #0x06 + BANK_BITS ; low page alternate
ld bc, #0x7ffd
out (c), a
ldir
ld a, (current_map) ; restore mapping
- or #0x18 ; ROM bits
+ or #BANK_BITS ; ROM bits
ld bc, #0x7ffd
out (c), a
ret
; FIXME: if we support small apps at C000-FBFF we need to tweak this
; Now copy the 0x8000-0xBFFF area directly
- ld a, #0x06 + 0x18 ; low page alternate
+ ld a, #0x06 + BANK_BITS ; low page alternate
ld bc, #0x7ffd
out (c), a
; Copy done
ld a, (U_DATA__U_PAGE) ; parent memory
- or #0x18 ; get the right ROMs
+ or #BANK_BITS ; get the right ROMs
ld bc, #0x7ffd
out (c), a ; Switch context to parent in 0xC000+
;
ld bc, #0x7ffd
ld a, (current_map)
- or #0x18
+ or #BANK_BITS
out (c), a
; now the copy operation is complete we can get rid of the stuff
; _switchin will be expecting from our copy of the stack.
; we can use with a lazy copying model
;
bankfork:
- or #0x18 ; ROM bits for the bank
+ or #BANK_BITS ; ROM bits for the bank
ld b, #0x3E ; 64 x 256 minus 2 sets for the uarea stash/irqs
ld hl, #0xC000 ; base of memory to fork (vectors included)
bankfork_1:
ld a, c ; switch to the child
push bc ; save the bank pointers
ld bc, #0x7ffd
- or #0x18 ; ROM bits
+ or #BANK_BITS ; ROM bits
out (c), a
ld hl, #bouncebuffer
ld bc, #256
; screen initialization
; clear
- ld hl, #0xC000
- ld de, #0xC001
+ ld hl, #0x4000
+ ld de, #0x4001
ld bc, #0x1800 ; There should be 0x17FF, but we are going
xor a ; to copy additional byte to avoid need of
ld (hl), a ; DE and HL increment before attribute
ld (current_map), a
push bc
ld bc, #0x7ffd
- or #0x18 ; Spectrum 48K ROM, Screen in Bank 7
+ or #BANK_BITS ; Spectrum 48K ROM, Screen in Bank 7
out (c), a
pop bc
ret
ld e,a
ld a,d
and #0x18
- or #0xC0 ; not 0x40 as in screen 7
+ or #0x40 ; Standard screen
ld d,a
ret