zxdiv: re-arrange video memory to 0x4000
authorAlan Cox <alan@linux.intel.com>
Sun, 25 Nov 2018 17:17:44 +0000 (17:17 +0000)
committerAlan Cox <alan@linux.intel.com>
Sun, 25 Nov 2018 17:17:44 +0000 (17:17 +0000)
We now have the video memory mappable.

Extract the bank bits from hardcoding so we can later share code better
between related ZX ports

Kernel/platform-zxdiv/README
Kernel/platform-zxdiv/kernel.def
Kernel/platform-zxdiv/tricks.s
Kernel/platform-zxdiv/zx128.s
Kernel/platform-zxdiv/zxvideo.s

index 43659ca..65ea71b 100644 (file)
@@ -38,7 +38,8 @@ We run with the following mapping
                (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
@@ -52,7 +53,7 @@ C000-FFFF
        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
@@ -71,7 +72,6 @@ To Do:
        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
@@ -91,7 +91,6 @@ To Do:
 -      SpectraNet (W5100)
 
 
-
 Devices To Look At:
 
 DIVIDE:                These have at least 32K of 8K banks. They are awkward to use
@@ -176,3 +175,6 @@ DONE        -       Debug crash on swapping
 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
index e6c34ca..eb78b32 100644 (file)
@@ -12,3 +12,6 @@ PROGBASE                  .equ 0x8000
 PROGLOAD                   .equ 0x8000
 
 NBUFS                      .equ 5
+
+BANK_BITS                  .equ 0x10           ; Spectrum ROM select
+                                               ; Doesn't really matter!
\ No newline at end of file
index 3e11c9f..7b259ac 100644 (file)
@@ -62,7 +62,7 @@ _platform_switchout:
        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
@@ -71,7 +71,7 @@ _platform_switchout:
        ld bc, #U_DATA__TOTALSIZE
        ldir
        ld a, (current_map)
-       or #0x18
+       or #BANK_BITS
        ld bc, #0x7ffd
        out (c), a
 
@@ -149,7 +149,7 @@ not_swapped:
 
        ; 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
@@ -171,7 +171,7 @@ not_swapped:
        ;
 
        ld a, (current_map)
-       or #0x18
+       or #BANK_BITS
        ld bc, #0x7ffd
        out (c), a
         
@@ -190,7 +190,7 @@ fliplow:
        exx
        ld hl, #0x8000
        ld de, #0xc000
-       ld a, #6 + 0x18
+       ld a, #6 + BANK_BITS
        ld bc, #0x7ffd
        out (c), a
 flip2:
@@ -209,7 +209,7 @@ flip1:
        jr nz, flip1
 
        ld a, (current_map)
-       or #0x18
+       or #BANK_BITS
        ld bc, #0x7ffd
        out (c), a
        exx
@@ -270,7 +270,7 @@ switchinfail:
 ; 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
 
@@ -280,7 +280,7 @@ _dup_low_page:
        ldir
 
        ld a, (current_map)             ; restore mapping
-       or #0x18                        ; ROM bits
+       or #BANK_BITS                   ; ROM bits
        ld bc, #0x7ffd
        out (c), a
        ret
@@ -353,7 +353,7 @@ _dofork:
        ; 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
 
@@ -365,7 +365,7 @@ _dofork:
        ; 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+
 
@@ -382,7 +382,7 @@ _dofork:
        ;
        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.
@@ -423,7 +423,7 @@ _dofork:
 ;      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:
@@ -442,7 +442,7 @@ 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
index 11e2b02..605368b 100644 (file)
@@ -123,8 +123,8 @@ init_hardware:
 
         ; 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
@@ -164,7 +164,7 @@ switch_bank:
         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
index fce7baf..b978e5c 100644 (file)
@@ -32,7 +32,7 @@ videopos:
         ld e,a
         ld a,d
         and #0x18
-        or #0xC0           ; not 0x40 as in screen 7
+        or #0x40           ; Standard screen
         ld d,a
         ret