Working on 2D to 3D transition.

This commit is contained in:
Martin Haye 2015-05-07 09:12:52 -07:00
parent d4a550f760
commit 64870ea6a8
4 changed files with 65 additions and 35 deletions

View File

@ -20,7 +20,7 @@ MAX_SEGS = 96
DO_COMP_CHECKSUMS = 0 ; during compression debugging
DEBUG_DECOMP = 0
DEBUG = 0
SANITY_CHECK = 0
SANITY_CHECK = 0 ; also prints out request data
; Zero page temporary variables
tmp = $2 ; len 2
@ -652,7 +652,7 @@ shared_alloc:
jsr scanForAvail ; scan for an available block
bne .noSplitStart ; if found, go into normal split checking
; failed to find a block. If we haven't tried reclaiming, do so now
dec .reclaimFlg ; first time: 1 -> 0, second time 0 -> $FF
.recl dec .reclaimFlg ; first time: 1 -> 0, second time 0 -> $FF
bmi outOfMemErr ; so if it's second time, give up
jsr reclaim ; first time, do a reclaim pass
jmp .chooseAddr ; and try again
@ -700,7 +700,7 @@ shared_alloc:
sbc tSegAdrHi,y
.cmpLo ora #$11 ; self-modified a few lines ago
beq .noSplitEnd
bcs .needJoin ; req end > start of next block, need to join
bcs .recl ; req end > start of next block, need to reclaim
; need to split current segment into (cur..reqEnd) and (reqEnd..next)
.splitEnd:
jsr grabSegment ; get a new segment, index in Y (doesn't disturb X)
@ -726,11 +726,6 @@ shared_alloc:
stx segNum ; save seg num in case internal caller routine needs it
tax ; adr lo to proper register
rts ; all done!
.needJoin:
ldx #<+
ldy #>+
jmp fatalError
+ !text "Join not impl yet", 0
.reqEnd: !word 0
.reclaimFlg: !byte 0

View File

@ -61,11 +61,11 @@ const FATAL_ERROR = $1F
const callbacks = $300
// 3D mode
//const OVERMAP_NUM = 11
//const OVERMAP_IS_3D = 1
const OVERMAP_NUM = 11
const OVERMAP_IS_3D = 1
// 2D mode
const OVERMAP_NUM = 1
const OVERMAP_IS_3D = 0
//const OVERMAP_NUM = 1
//const OVERMAP_IS_3D = 0
///////////////////////////////////////////////////////////////////////////////////////////////////
// Predefined functions, for circular calls or out-of-order calls
@ -89,7 +89,7 @@ word pMap
word cmdTbl[64]
word triggerTbl
byte redraw
byte titleLoaded = FALSE
byte frameLoaded = 0
byte textDrawn = FALSE
word skyNum = 9
@ -250,7 +250,7 @@ end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Read a string from the keyboard, turn it into a PLASMA string and return a pointer to the string.
asm getstr
asm readStr
+asmPlasm 0
jsr getln1
txa
@ -567,14 +567,17 @@ end
// Load the Frame Image, and lock it.
def loadFrameImg()
byte img
if titleLoaded
loader(UNLOCK_MEMORY,MAIN_MEM, $2000)
loader(FREE_MEMORY, MAIN_MEM, $2000)
titleLoaded = FALSE
img = mapIs3D+2
if frameLoaded <> img
if frameLoaded
loader(UNLOCK_MEMORY,MAIN_MEM, $2000)
loader(FREE_MEMORY, MAIN_MEM, $2000)
fin
loader(SET_MEM_TARGET, MAIN_MEM, $2000)
loader(QUEUE_LOAD, MAIN_MEM, img<<8 | RES_TYPE_SCREEN)
loader(LOCK_MEMORY, MAIN_MEM, $2000)
frameLoaded = img
fin
loader(SET_MEM_TARGET, MAIN_MEM, $2000)
loader(QUEUE_LOAD, MAIN_MEM, (mapIs3D+2)<<8 | RES_TYPE_SCREEN)
loader(LOCK_MEMORY, MAIN_MEM, $2000)
end
///////////////////////////////////////////////////////////////////////////////////////////////////
@ -618,7 +621,10 @@ def initMap(x, y, dir)
// Start up the display engine with map data and starting position. This will also load and
// init the script module, if any, which will end up calling us back at the setScriptInfo
triggerTbl = NULL
setWindow2()
puts("Calling initDisplay.\n")
initDisplay(mapNum, pMap, x, y, dir)
puts("Back from initDisplay.\n")
end
///////////////////////////////////////////////////////////////////////////////////////////////////
@ -776,16 +782,33 @@ end
///////////////////////////////////////////////////////////////////////////////////////////////////
def teleport()
word x, y
byte dir
^$c053
if ^$25 < 23; ^$25 = 23; fin
getPos(@x, @y)
printf2("\nCurrent location: X=%d Y=%d\n", x, y)
printf4("\nCurrent: 3D=%d Map=%d X=%d Y=%d ", mapIs3D, mapNum, x, y)
printf1(" Dir=%d\n", getDir())
puts("New 3D: ")
mapIs3D = parseDec(readStr())
puts("New Map: ")
mapNum = parseDec(readStr())
puts("New X: ")
x = parseDec(getstr())
x = parseDec(readStr())
puts("New Y: ")
y = parseDec(getstr())
y = parseDec(readStr())
puts("New Dir: ")
dir = parseDec(readStr())
^$c052
setMap(mapIs3D, mapNum, x, y, 0)
setMap(mapIs3D, mapNum, x, y, dir)
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def oldTeleport(x, y, dir)
printf3("Old teleport: x=%d y=%d dir=%d\n", x, y, dir)
end
///////////////////////////////////////////////////////////////////////////////////////////////////
@ -814,6 +837,8 @@ end
// is called by the init function for the scripts.
def setScriptInfo(mapName, trigTbl)
puts("In setScriptInfo\n")
// Record the trigger table pointer
triggerTbl = trigTbl
@ -911,7 +936,7 @@ def loadTitle()
loader(QUEUE_LOAD, MAIN_MEM, 1<<8 | RES_TYPE_SCREEN) // title screen is fixed at #1
loader(LOCK_MEMORY, MAIN_MEM, $2000)
loader(FINISH_LOAD, MAIN_MEM, 1) // 1 = keep open
titleLoaded = TRUE
frameLoaded = 1
puts("Title loaded.\n")
^$c050
^$c057
@ -950,6 +975,10 @@ def setCallbacks()
// $30F
callbacks.15 = $4c
callbacks:16 = @setGround
// $312
callbacks.18 = $4c
callbacks:19 = @oldTeleport
end
///////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -64,6 +64,7 @@ mapNum: !byte 1
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
plasmaStk: !byte 0
skyColorEven: !byte $20
skyColorOdd: !byte $22
@ -1613,7 +1614,12 @@ loadTextures: !zone
ldx #0
jsr mainLoader
; finally, init the scripts.
.scInit jmp $1111
!if DEBUG { +prStr : !text "Calling script init ",0 : +prWord .scInit+1 : +crout }
ldx plasmaStk
bit setLcRW+lcBank2 ; switch PLASMA runtime back in
.scInit jsr $1111 ; self-modified earlier
bit setROM ; back to ROM so we can work normally
rts
.get: lda $1111
inc .get+1
bne +
@ -1989,7 +1995,9 @@ pl_setColor: !zone
; The real action
pl_initMap: !zone
txa
pha ; save PLASMA's eval stack pos
clc
adc #5 ; 5 params
sta plasmaStk ; save PLASMA's eval stack pos, without our params
; Record the address of the map
lda evalStkL+3,x
sta mapHeader
@ -2015,13 +2023,10 @@ pl_initMap: !zone
sta tablesInitted
jsr setExpansionCaller
jsr graphInit
jsr renderFrame
bit setLcRW+lcBank2 ; switch PLASMA runtime back in
pla ; restore PLASMA's eval stk pos
tax
inx
inx ; toss 4 slots (params=5, ret=1, diff=4)
inx
inx
ldx plasmaStk ; restore PLASMA's eval stk pos
dex ; make room for dummy return (inc'd over params earlier)
rts
; Following are log/pow lookup tables. For speed, align them on a page boundary.

View File

@ -1215,7 +1215,8 @@ pl_getDir:
LDA AVATAR_DIR ; take our 0..3
ASL ; and translate
ASL ; to 0..15
STA evalStkL,X
DEX ; make a place for it on eval stk
STA evalStkL,X ; and save it
LDA #0
STA evalStkH,X
RTS