mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-06-25 09:29:30 +00:00
Fixed mem coalesce bug, and made return to wilderness resume the old position.
This commit is contained in:
parent
e849051afd
commit
760cccbb80
|
@ -664,6 +664,10 @@ shared_alloc:
|
|||
; at the same time to guarantee that we never have the main part of a module
|
||||
; without its aux part, or vice versa.
|
||||
reclaim: !zone
|
||||
bit $C051
|
||||
+prStr : !text "Reclaim before:",0
|
||||
jsr printMem
|
||||
+waitKey
|
||||
lda isAuxCmd ; save whether current command is aux or not
|
||||
pha
|
||||
lda #1 ; we do aux bank first
|
||||
|
@ -671,8 +675,8 @@ reclaim: !zone
|
|||
.outer ldx isAuxCmd ; grab correct starting segment (0=main mem, 1=aux)
|
||||
.loop: ldy tSegLink,x ; grab link to next segment, which we'll need regardless
|
||||
lda tSegType,x ; check flag and type of this seg
|
||||
bmi .next
|
||||
lda #0
|
||||
bmi .next ; active? Skip it.
|
||||
lda #0 ; clear all flags and type for this seg
|
||||
sta tSegType,x
|
||||
.next: tya ; next in chain
|
||||
tax ; to X reg index
|
||||
|
@ -682,6 +686,9 @@ reclaim: !zone
|
|||
bpl .outer ; back around for that bank
|
||||
pla
|
||||
sta isAuxCmd ; restore aux mode
|
||||
+prStr : !text "Reclaim after:",0
|
||||
jsr printMem
|
||||
+waitKey
|
||||
rts ; all done
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
@ -694,7 +701,7 @@ coalesce: !zone
|
|||
beq .done ; no next segment, nothing to join to ==> done
|
||||
lda tSegType,x ; check flag and type of this seg
|
||||
ora tSegType,y ; and next seg
|
||||
bmi .next ; if either is active or has a type, can't combine
|
||||
bne .next ; if either is active or has a type, can't combine
|
||||
; we can combine the next segment into this one.
|
||||
!if DEBUG { jsr .debug }
|
||||
lda tSegLink,y
|
||||
|
|
|
@ -57,6 +57,8 @@ const FATAL_ERROR = $1F
|
|||
|
||||
const callbacks = $300
|
||||
|
||||
const OVERMAP = 11
|
||||
|
||||
;==================================================================================================
|
||||
; Predefined functions, for circular calls
|
||||
predef moveBackward, setWindow2
|
||||
|
@ -90,21 +92,25 @@ byte tooManyTriggers[] = "Too many triggers"
|
|||
|
||||
;==================================================================================================
|
||||
; Global variables
|
||||
word mapNum = 1
|
||||
byte mapNum = OVERMAP
|
||||
word pFont
|
||||
word pMap
|
||||
word pScripts
|
||||
word cmdTbl[64]
|
||||
word nLocTrig
|
||||
word locTrig_x[MAX_LOC_TRIG]
|
||||
word locTrig_y[MAX_LOC_TRIG]
|
||||
byte nLocTrig
|
||||
byte locTrig_x[MAX_LOC_TRIG]
|
||||
byte locTrig_y[MAX_LOC_TRIG]
|
||||
word locTrig_func[MAX_LOC_TRIG]
|
||||
word prevX
|
||||
word prevY
|
||||
byte prevX
|
||||
byte prevY
|
||||
word prevScript
|
||||
word prevMapNum
|
||||
word redraw
|
||||
byte prevMapNum
|
||||
byte redraw
|
||||
byte titleLoaded = FALSE
|
||||
byte cacheSky, cacheGround
|
||||
word cacheX, cacheY
|
||||
byte cacheDir
|
||||
byte resetLocFromCache = FALSE
|
||||
|
||||
; Movement amounts when walking at each angle
|
||||
; Each entry consists of an X bump and a Y bump, in 8.8 fixed point
|
||||
|
@ -451,6 +457,26 @@ def getUpperKey()
|
|||
return key
|
||||
end
|
||||
|
||||
def setSky(num)
|
||||
skyNum = num
|
||||
setColor(0<<8 | skyGndTbl1[skyNum])
|
||||
setColor(1<<8 | skyGndTbl2[skyNum])
|
||||
end
|
||||
|
||||
def nextSky()
|
||||
setSky((skyNum + 1) & $F)
|
||||
end
|
||||
|
||||
def setGround(num)
|
||||
groundNum = num
|
||||
setColor(2<<8 | skyGndTbl1[groundNum])
|
||||
setColor(3<<8 | skyGndTbl2[groundNum])
|
||||
end
|
||||
|
||||
def nextGround()
|
||||
setGround((groundNum + 1) & $F)
|
||||
end
|
||||
|
||||
def initMap()
|
||||
word scriptModule
|
||||
|
||||
|
@ -498,10 +524,7 @@ def initMap()
|
|||
; Start up the font engine
|
||||
initFontEngine(pFont)
|
||||
|
||||
; Start up the raycaster
|
||||
initRaycaster(pMap)
|
||||
|
||||
; Set initial player position
|
||||
; Set initial player position in case the init script doesn't do it
|
||||
^playerDir = 1
|
||||
*playerX = $280
|
||||
*playerY = $380
|
||||
|
@ -517,7 +540,23 @@ def initMap()
|
|||
if pScripts
|
||||
*pScripts()
|
||||
fin
|
||||
|
||||
; If we're returning to a map, resume from where the player left off
|
||||
if resetLocFromCache
|
||||
*playerX = cacheX
|
||||
*playerY = cacheY
|
||||
^playerDir = cacheDir
|
||||
prevX = playerX.1 - 1
|
||||
prevY = playerY.1 - 1
|
||||
setSky(cacheSky)
|
||||
setGround(cacheGround)
|
||||
resetLocFromCache = FALSE
|
||||
fin
|
||||
|
||||
; Start up the raycaster
|
||||
initRaycaster(pMap)
|
||||
setWindow2()
|
||||
|
||||
; Draw the first frame
|
||||
renderFrame()
|
||||
redraw = FALSE
|
||||
|
@ -640,6 +679,16 @@ def strafeLeft()
|
|||
end
|
||||
|
||||
def setMap(is3d, num)
|
||||
; save player state if we're coming *from* the over-map
|
||||
if mapNum == OVERMAP
|
||||
cacheX = *playerX
|
||||
cacheY = *playerY
|
||||
cacheDir = ^playerDir
|
||||
cacheSky = skyNum
|
||||
cacheGround = groundNum
|
||||
else
|
||||
resetLocFromCache = TRUE
|
||||
fin
|
||||
mapNum = num
|
||||
end
|
||||
|
||||
|
@ -651,26 +700,6 @@ def nextMap()
|
|||
setMap(1, mapNum)
|
||||
end
|
||||
|
||||
def setSky(num)
|
||||
skyNum = num
|
||||
setColor(0<<8 | skyGndTbl1[skyNum])
|
||||
setColor(1<<8 | skyGndTbl2[skyNum])
|
||||
end
|
||||
|
||||
def nextSky()
|
||||
setSky((skyNum + 1) & $F)
|
||||
end
|
||||
|
||||
def setGround(num)
|
||||
groundNum = num
|
||||
setColor(2<<8 | skyGndTbl1[groundNum])
|
||||
setColor(3<<8 | skyGndTbl2[groundNum])
|
||||
end
|
||||
|
||||
def nextGround()
|
||||
setGround((groundNum + 1) & $F)
|
||||
end
|
||||
|
||||
def teleport(x, y, dir)
|
||||
*playerX = ((x+1)<<8) | $80
|
||||
*playerY = ((y+1)<<8) | $80
|
||||
|
@ -785,6 +814,10 @@ titleLoaded = TRUE
|
|||
^$c057
|
||||
^$c054
|
||||
^$c052
|
||||
; Hack for real (not emulated) IIc: sometimes displays only lo-bit graphics
|
||||
; unless we do this. *HUGE* thanks to Brendan Robert for the fix!
|
||||
^$C07E=0 ; disable double-hi-res
|
||||
^$C05F ; disable double-hi-res
|
||||
|
||||
initMap()
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@ mapName: !word 0 ; pointer to map name
|
|||
mapNameLen: !byte 0 ; length of map name
|
||||
nMapSprites: !byte 0 ; number of sprite entries on map to fix up
|
||||
nextLink: !byte 0 ; next link to allocate
|
||||
tablesInitted: !byte 0 ; 1 after init
|
||||
|
||||
skyColorEven: !byte $20
|
||||
skyColorOdd: !byte $22
|
||||
|
@ -1542,21 +1543,6 @@ expanderJmp:
|
|||
}
|
||||
.callEnd:
|
||||
|
||||
;-------------------------------------------------------------------------------
|
||||
; Establish the initial player position and direction [ref BigBlue3_10]
|
||||
setPlayerPos: !zone
|
||||
lda #>PLAYER_START_X
|
||||
sta playerX+1
|
||||
lda #<PLAYER_START_X
|
||||
sta playerX
|
||||
lda #>PLAYER_START_Y
|
||||
sta playerY+1
|
||||
lda #<PLAYER_START_Y
|
||||
sta playerY
|
||||
lda #PLAYER_START_DIR
|
||||
sta playerDir
|
||||
rts
|
||||
|
||||
;-------------------------------------------------------------------------------
|
||||
getTileFlags: !zone
|
||||
dex ; because tile numbers start at 1 but list at 0
|
||||
|
@ -1911,15 +1897,18 @@ initMap: !zone
|
|||
; Record the address of the map
|
||||
sta mapHeader
|
||||
sty mapHeader+1
|
||||
jsr setPlayerPos
|
||||
jsr loadTextures
|
||||
jsr copyScreen
|
||||
lda tablesInitted
|
||||
bne +
|
||||
; Build all the unrolls and tables
|
||||
!if DEBUG { +prStr : !text "Making tables.",0 }
|
||||
jsr makeBlit
|
||||
jsr makeClrBlit
|
||||
jsr makeDecodeTbls
|
||||
jsr makeLines
|
||||
+ lda #1
|
||||
sta tablesInitted
|
||||
jsr setExpansionCaller
|
||||
jsr graphInit
|
||||
bit clrMixed
|
||||
|
|
Loading…
Reference in New Issue
Block a user