mirror of
https://github.com/badvision/lawless-legends.git
synced 2025-02-08 03:30:51 +00:00
Moved more of expander into aux LC to take advantage of space freed up by ProRWTS. Now expander is loaded at startup and remains locked in memory, rather than swapping in and out.
This commit is contained in:
parent
4b9f2c9a85
commit
2f8de46d0e
@ -46,13 +46,13 @@
|
||||
;
|
||||
; MAIN 64K MEMORY
|
||||
; :::::::::::::::
|
||||
; 0000.01FF 6502 zero page and stack
|
||||
; 0000.01FF 6502 zero page and stack (main)
|
||||
; 0200.03FF input buffer, misc vecs
|
||||
; 0400.07FF text screen (used for debugging)
|
||||
; 0800.0Dxx memory manager part 1
|
||||
; 0Exx.0Fxx PLASMA locals storage
|
||||
; 10xx.18xx gameloop asm, data and stubs
|
||||
; 19xx.1FFF (free)
|
||||
; 0800.0Cxx memory manager part 1
|
||||
; 0Cxx.0Exx PLASMA locals storage (length $200)
|
||||
; 0Exx.17xx gameloop asm, data and stubs
|
||||
; 17xx.1FFF (free)
|
||||
; 2000.3FFF hi-res page 1
|
||||
; 4000.5FFF hi-res page 2 /
|
||||
; memory manager work space
|
||||
@ -70,18 +70,18 @@
|
||||
;
|
||||
; AUX 64K MEMORY
|
||||
; ::::::::::::::
|
||||
; 0000.01FF 6502 zero page and stack
|
||||
; 0000.01FF 6502 zero page and stack (aux)
|
||||
; 0200.03FF (currently unused)
|
||||
; 0400.07FF (unused, but screen holes overwritten by hard-disk C7xx ROM)
|
||||
; 0800.2xxx expander part 1 (if 3D map is running)
|
||||
; 3000.9xxx (free)
|
||||
; Axxx.BFFF gameloop PLASMA code (loaded as high as possible)
|
||||
; 0400.07FF (unused, but screen holes overwritten by hard drive C7xx ROM)
|
||||
; 0800.0D7A texture expander part 1 (used by 3D renderer)
|
||||
; 0D7B.9xxx (free)
|
||||
; A0xx.BFFF gameloop PLASMA code (loaded as high as possible)
|
||||
; C000.CFFF I/O
|
||||
; (bank 1) D000.DAFF ProRWTS runtime
|
||||
; (bank 1) DB00.DFFF (unused)
|
||||
; (bank 2) D000.DFFF expander part 2
|
||||
; E000.FFF9 (free)
|
||||
; FFFA.FFFF 6502 vectors
|
||||
; (bank 2) D000.DFFF texture expander part 2
|
||||
; E000.FFF9 texture expander part 3
|
||||
; FFFA.FFFF 6502 vectors
|
||||
;
|
||||
; ----------------------------
|
||||
; Segment table format in memory:
|
||||
|
@ -297,6 +297,29 @@ asm readAuxByte // params: ptr; ret: char
|
||||
jmp $10
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
asm splitExpander // param: expandVec; returns: remaining lo-aux size
|
||||
+asmPlasm 1
|
||||
|
||||
; assumes readAuxByte has just been called, which puts a little routine at $10.
|
||||
; Adjust that routine to call expander instead of reading a byte.
|
||||
sta $1B
|
||||
sty $1C
|
||||
lda #$6C
|
||||
sta $1A
|
||||
lda #$20
|
||||
sta $13
|
||||
|
||||
lda #$60
|
||||
sta 2
|
||||
jsr 2
|
||||
|
||||
sei ; prevent interrupts while in aux mem
|
||||
jsr $10
|
||||
cli
|
||||
rts
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// String building for display with the font engine. Includes plurality processing to handily
|
||||
// handle things like "Dirt bag(s)" and "his/their"
|
||||
@ -1158,6 +1181,9 @@ export def loadFrameImg(img)
|
||||
// Load the image data into aux mem
|
||||
if img
|
||||
auxMmgr(START_LOAD, 1) // partition 1 is where full screen images live
|
||||
if img == 1
|
||||
auxMmgr(SET_MEM_TARGET, $4000) // well above where expander loads at startup
|
||||
fin
|
||||
curFullscreenImg = auxMmgr(QUEUE_LOAD, img<<8 | RES_TYPE_SCREEN)
|
||||
auxMmgr(FINISH_LOAD, 0)
|
||||
|
||||
@ -1376,8 +1402,6 @@ def initMap(x, y, dir)
|
||||
mmgr(SET_MEM_TARGET, displayEngine)
|
||||
if mapIs3D
|
||||
mmgr(QUEUE_LOAD, CODE_RENDER<<8 | RES_TYPE_CODE)
|
||||
auxMmgr(SET_MEM_TARGET, expandVec)
|
||||
auxMmgr(QUEUE_LOAD, CODE_EXPAND<<8 | RES_TYPE_CODE)
|
||||
else
|
||||
mmgr(QUEUE_LOAD, CODE_TILE_ENGINE<<8 | RES_TYPE_CODE)
|
||||
fin
|
||||
@ -2305,7 +2329,7 @@ end
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Load and display the title screen.
|
||||
def loadTitle()
|
||||
word pEngine, pFont
|
||||
word pEngine, pFont, expanderSize
|
||||
|
||||
puts("Loading game.\n")
|
||||
|
||||
@ -2320,7 +2344,7 @@ def loadTitle()
|
||||
^$C07E=0 // disable double-hi-res
|
||||
^$C05F // disable double-hi-res
|
||||
|
||||
// Allocate and permanently lock mem for the font engine and its font
|
||||
// Allocate and permanently lock mem for the font engine and its font (up in LC ram)
|
||||
mmgr(SET_MEM_TARGET, fontEngine)
|
||||
mmgr(REQUEST_MEMORY, fontEngineLen)
|
||||
mmgr(LOCK_MEMORY, fontEngine)
|
||||
@ -2332,18 +2356,33 @@ def loadTitle()
|
||||
// Load them into lo mem
|
||||
pEngine = mmgr(QUEUE_LOAD, CODE_FONT_ENGINE<<8 | RES_TYPE_CODE)
|
||||
pFont = mmgr(QUEUE_LOAD, 1<<8 | RES_TYPE_FONT)
|
||||
|
||||
// While we're loading, let's get the expander into aux RAM.
|
||||
auxMmgr(SET_MEM_TARGET, expandVec)
|
||||
auxMmgr(QUEUE_LOAD, CODE_EXPAND<<8 | RES_TYPE_CODE)
|
||||
|
||||
mmgr(FINISH_LOAD, 0)
|
||||
|
||||
// Relocate them to their final spots
|
||||
// Relocate font engine and font data to their final spots up in the language card
|
||||
memcpy(pEngine, fontEngine, fontEngineLen)
|
||||
memcpy(pFont, fontData, fontDataLen)
|
||||
|
||||
// And free up the low mem
|
||||
// Tell the font engine where to find its font
|
||||
setFont(fontData)
|
||||
|
||||
// And free up the font low mem
|
||||
mmgr(FREE_MEMORY, pEngine)
|
||||
mmgr(FREE_MEMORY, pFont)
|
||||
|
||||
// Tell the font engine where to find its font
|
||||
setFont(fontData)
|
||||
// Split the expander (relocating most of it to aux LC ram)
|
||||
readAuxByte($1A) // sets up aux routine
|
||||
expanderSize = splitExpander(expandVec)
|
||||
|
||||
// Lock in the part of the expander that remains in low aux mem.
|
||||
auxMmgr(FREE_MEMORY, expandVec)
|
||||
auxMmgr(SET_MEM_TARGET, expandVec)
|
||||
auxMmgr(REQUEST_MEMORY, expanderSize)
|
||||
auxMmgr(LOCK_MEMORY, expandVec)
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -851,6 +851,9 @@ e_t96rooto:
|
||||
sta 97*BLIT_STRIDE + blitRoll,x
|
||||
+ bvc e_98to
|
||||
|
||||
!source "expand_split.i"
|
||||
!pseudopc $D000 {
|
||||
reloc_dst = *
|
||||
e_32tooro:
|
||||
bmi +
|
||||
sta 32*BLIT_STRIDE + blitRoll,x
|
||||
@ -5776,8 +5779,6 @@ expand_102:
|
||||
+
|
||||
rts
|
||||
|
||||
!source "expand_split.i"
|
||||
!pseudopc $D000 {
|
||||
; Produce 104 rows from 64 rows
|
||||
expand_104:
|
||||
jsr selectMip0
|
||||
@ -7374,5 +7375,6 @@ e_t64oroo:
|
||||
sta 66*BLIT_STRIDE + blitRoll,x
|
||||
sta 67*BLIT_STRIDE + blitRoll,x
|
||||
+ rts
|
||||
lc_end = *
|
||||
} ; end of pseudopc
|
||||
expand_end = *
|
||||
|
@ -9,18 +9,20 @@
|
||||
;****************************************************************************************
|
||||
|
||||
expand_split:
|
||||
; relocate the last $1000 bytes of the expander to the hard-to-get area of
|
||||
; relocate the last $2FFA bytes of the expander to the hard-to-get area of
|
||||
; aux langauge card.
|
||||
lda #<to_reloc
|
||||
sta setAuxZP
|
||||
sta setAuxWr
|
||||
lda #<reloc_src
|
||||
sta tmp
|
||||
lda #>to_reloc
|
||||
lda #>reloc_src
|
||||
sta tmp+1
|
||||
lda #<expand_104
|
||||
lda #<reloc_dst
|
||||
sta pTmp
|
||||
lda #>expand_104
|
||||
lda #>reloc_dst
|
||||
sta pTmp+1
|
||||
ldy #0
|
||||
ldx #$10
|
||||
ldx #$2F
|
||||
- lda (tmp),y
|
||||
sta (pTmp),y
|
||||
iny
|
||||
@ -29,6 +31,11 @@ expand_split:
|
||||
inc pTmp+1
|
||||
dex
|
||||
bne -
|
||||
- lda (tmp),y ; last pg only partial
|
||||
sta (pTmp),y
|
||||
iny
|
||||
cpy #$FA
|
||||
bne -
|
||||
; restore vector to first expander now that we've split and relocated
|
||||
lda #<expand_0
|
||||
sta expand_vec
|
||||
@ -36,7 +43,9 @@ expand_split:
|
||||
sta expand_vec+1
|
||||
; and length to which the main segment has been truncated
|
||||
lda #<(expand_split-expand_vec)
|
||||
ldx #>(expand_split-expand_vec)
|
||||
ldy #>(expand_split-expand_vec)
|
||||
sta clrAuxZP
|
||||
sta clrAuxWr
|
||||
rts
|
||||
|
||||
to_reloc = *
|
||||
reloc_src = *
|
||||
|
@ -2163,8 +2163,6 @@ pl_initMap: !zone
|
||||
ldx #<(tableEnd-tableStart)
|
||||
ldy #>(tableEnd-tableStart)
|
||||
jsr mainLoader
|
||||
; If expander hasn't been split and relocated yet, do so now
|
||||
jsr splitExpander
|
||||
; Proceed with loading
|
||||
lda #1 ; non-zero to init scripts also
|
||||
jsr loadTextures
|
||||
@ -2179,41 +2177,6 @@ pl_initMap: !zone
|
||||
jsr graphInit
|
||||
jmp renderFrame
|
||||
|
||||
;-------------------------------------------------------------------------------
|
||||
; Split part of the expander off into a hard-to-use area in the aux LC.
|
||||
; NOTE: It's safe to do this more than once, and is in fact necessary in case
|
||||
; the expander gets reloaded without the main engine being reloaded. It's safe
|
||||
; to call expand_0 since it's just an RTS.
|
||||
splitExpander:
|
||||
jsr setExpansionCaller
|
||||
sei ; prevent interrupts while in aux mem
|
||||
sta setAuxZP
|
||||
sta setAuxWr
|
||||
lda setLcRW+lcBank2 ; reloc to bank 2 in aux mem (unused by anything else)
|
||||
lda setLcRW+lcBank2 ; second access to make it read/write
|
||||
jsr callExpander ; was copied from .callIt to $100 at init time
|
||||
sta clrAuxWr
|
||||
sta clrAuxZP
|
||||
cli ; interrupts ok after we get back from aux
|
||||
pha ; save new seg length
|
||||
txa
|
||||
pha
|
||||
; Now truncate the main segment of the expander, freeing up the
|
||||
; split space for textures and other resources.
|
||||
lda #FREE_MEMORY
|
||||
jsr .memexp
|
||||
lda #SET_MEM_TARGET
|
||||
jsr .memexp
|
||||
pla
|
||||
tay
|
||||
pla
|
||||
tax
|
||||
lda #REQUEST_MEMORY
|
||||
jmp auxLoader
|
||||
.memexp ldx #<expandVec
|
||||
ldy #>expandVec
|
||||
jmp auxLoader
|
||||
|
||||
; Following are log/pow lookup tables. For speed, align them on a page boundary.
|
||||
!align 255,0
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user