mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-12-26 04:32:05 +00:00
More work on 2D script triggers.
This commit is contained in:
parent
152fa2bd8b
commit
315c6b6936
@ -32,7 +32,7 @@
|
||||
<!-- Build sub-projects -->
|
||||
<echo>Building core.</echo>
|
||||
<ant dir="${src.dir}/core" target="build" useNativeBasedir="true" inheritAll="false"/>
|
||||
<echo>Building PLASMA.</echo>
|
||||
<echo>Building game loop.</echo>
|
||||
<ant dir="${src.dir}/plasma" target="build" useNativeBasedir="true" inheritAll="false"/>
|
||||
<echo>Building raycast.</echo>
|
||||
<ant dir="${src.dir}/raycast" target="build" useNativeBasedir="true" inheritAll="false"/>
|
||||
|
@ -88,7 +88,7 @@ partFileRef: !byte 0
|
||||
fixupHint: !word 0
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
!source "../include/debug.i"
|
||||
!if DEBUG { !source "../include/debug.i" }
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
grabSegment: !zone
|
||||
@ -238,9 +238,11 @@ main_dispatch: !zone
|
||||
+ cmp #FREE_MEMORY
|
||||
bne +
|
||||
jmp main_free
|
||||
!if DEBUG {
|
||||
+ cmp #DEBUG_MEM
|
||||
bne +
|
||||
jmp main_debug
|
||||
}
|
||||
+ cmp #CALC_FREE
|
||||
bne shared_dispatch
|
||||
jmp main_calcFree
|
||||
@ -276,9 +278,11 @@ aux_dispatch: !zone
|
||||
+ cmp #FREE_MEMORY
|
||||
bne +
|
||||
jmp aux_free
|
||||
!if DEBUG {
|
||||
+ cmp #DEBUG_MEM
|
||||
bne +
|
||||
jmp aux_debug
|
||||
}
|
||||
+ cmp #CALC_FREE
|
||||
bne +
|
||||
jmp aux_calcFree
|
||||
@ -287,7 +291,7 @@ aux_dispatch: !zone
|
||||
;------------------------------------------------------------------------------
|
||||
; Sanity check mode
|
||||
!if SANITY_CHECK {
|
||||
saneStart: !zone
|
||||
saneStart: !zone {
|
||||
pha
|
||||
tya
|
||||
pha
|
||||
@ -298,23 +302,33 @@ saneStart: !zone
|
||||
tax
|
||||
pla
|
||||
tay
|
||||
+prChr 'M'+$80
|
||||
+prChr 'M'
|
||||
pla : pha : +prA
|
||||
+prX : +prY
|
||||
pla
|
||||
rts
|
||||
}
|
||||
|
||||
saneCheck: !zone
|
||||
rts
|
||||
saneCheck: !zone {
|
||||
lda $BF00
|
||||
cmp #$4C
|
||||
beq +
|
||||
brk
|
||||
+ lda $E1
|
||||
cmp #$BE
|
||||
bcc +
|
||||
brk
|
||||
+ rts
|
||||
}
|
||||
|
||||
saneEnd: !zone
|
||||
saneEnd: !zone {
|
||||
pha
|
||||
tya
|
||||
pha
|
||||
txa
|
||||
pha
|
||||
jsr saneCheck
|
||||
+prChr 'm'+$80
|
||||
+prChr 'm'
|
||||
+crout
|
||||
pla
|
||||
tax
|
||||
@ -323,6 +337,7 @@ saneEnd: !zone
|
||||
pla
|
||||
rts
|
||||
}
|
||||
}
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Print fatal error message (custom or predefined) and print the
|
||||
@ -397,7 +412,13 @@ fatalError: !zone
|
||||
init: !zone
|
||||
; put something interesting on the screen :)
|
||||
jsr home
|
||||
+prStr : !text "Welcome to MythOS.",0
|
||||
ldx #0
|
||||
- lda .welcomeStr,x
|
||||
beq +
|
||||
jsr cout
|
||||
inx
|
||||
bne -
|
||||
+
|
||||
; close all files
|
||||
lda #0
|
||||
jsr closeFile
|
||||
@ -489,14 +510,20 @@ init: !zone
|
||||
cpy #MAX_SEGS ; did all segments yet?
|
||||
bne .loop ; no, loop again
|
||||
; Allocate space for the PLASMA frame stack
|
||||
!if SANITY_CHECK {
|
||||
lda #$20
|
||||
sta framePtr+1 ; because sanity check verifies it's not $BE or $BF
|
||||
}
|
||||
ldx #0
|
||||
ldy #2 ; 2 pages
|
||||
lda #REQUEST_MEMORY
|
||||
jsr mainLoader
|
||||
stx framePtr
|
||||
stx outerFramePtr
|
||||
iny ; twice for 2 pages: initial pointer at top of new space
|
||||
iny
|
||||
sty framePtr+1
|
||||
sty outerFramePtr+1
|
||||
dey
|
||||
dey
|
||||
lda #LOCK_MEMORY ; lock it in place forever
|
||||
@ -518,8 +545,10 @@ init: !zone
|
||||
jsr mainLoader
|
||||
ldx #$10 ; initial eval stack index
|
||||
.gomod: jmp $1111 ; jump to module for further bootstrapping
|
||||
.welcomeStr !text "Welcome to MythOS.",$8D,0
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
!if DEBUG {
|
||||
printMem: !zone
|
||||
jsr main_debug
|
||||
jmp aux_debug
|
||||
@ -561,6 +590,7 @@ aux_debug:
|
||||
jsr cout
|
||||
txa
|
||||
jmp prbyte
|
||||
}
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
reset: !zone
|
||||
|
@ -2,3 +2,4 @@
|
||||
evalStkL = $C0
|
||||
evalStkH = $D0
|
||||
framePtr = $E0
|
||||
outerFramePtr = $E2
|
@ -98,10 +98,6 @@ const wndbtm = $73 // bottom+1 of text window
|
||||
const cursh = $74 // Cursor H-pos 0-39
|
||||
const cursv = $75 // Cursor V-pos 0-23
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Strings.
|
||||
byte helloStr[] = "Loading Lawless Legends.\n"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Global variables
|
||||
byte mapNum = OVERMAP_NUM
|
||||
@ -121,7 +117,7 @@ byte cacheSky, cacheGround
|
||||
word cacheX, cacheY
|
||||
byte cacheDir
|
||||
byte resetLocFromCache = FALSE
|
||||
byte anyText = FALSE
|
||||
byte textDrawn = FALSE
|
||||
|
||||
// Movement amounts when walking at each angle
|
||||
// Each entry consists of an X bump and a Y bump, in 8.8 fixed point
|
||||
@ -448,6 +444,14 @@ asm goMon
|
||||
jmp $FF69
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Jump straight to the system monitor
|
||||
// Params: None
|
||||
asm brk
|
||||
bit setROM
|
||||
brk
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Use the font engine to clear the current text window
|
||||
// Params: None
|
||||
@ -470,9 +474,6 @@ asm displayStr
|
||||
bit setROM
|
||||
txa
|
||||
pha
|
||||
; record that text was drawn - for clear window on next script phase
|
||||
lda #1
|
||||
sta textDrawn
|
||||
lda evalStkL,x
|
||||
sta pTmp
|
||||
lda evalStkH,x
|
||||
@ -569,6 +570,9 @@ end
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Is there a script attached to the player's current position?
|
||||
def isScripted()
|
||||
puts("avatarTile=")
|
||||
printHex(^avatarTile)
|
||||
crout()
|
||||
return ^avatarTile & $20
|
||||
end
|
||||
|
||||
@ -700,7 +704,7 @@ def initMap3D()
|
||||
// Initialize the map scripts
|
||||
setWindow2()
|
||||
clearWindow()
|
||||
anyText = FALSE
|
||||
textDrawn = FALSE
|
||||
|
||||
prevX = -1
|
||||
prevY = -1
|
||||
@ -760,16 +764,17 @@ def initMap2D()
|
||||
// Start up the font engine
|
||||
initFontEngine(pFont)
|
||||
|
||||
// Start up the tile engine
|
||||
initDisplayEngine(mapNum)
|
||||
|
||||
// For now
|
||||
prevX = -1
|
||||
prevY = -1
|
||||
triggerTbl = NULL
|
||||
prevMapNum = mapNum
|
||||
prevMapIs3D = mapIs3D
|
||||
pScripts = NULL
|
||||
|
||||
// Start up the tile engine
|
||||
initDisplayEngine(mapNum)
|
||||
|
||||
// And do the first draw.
|
||||
renderFrame()
|
||||
redraw = FALSE
|
||||
end
|
||||
@ -833,14 +838,16 @@ def callScripts(x, y)
|
||||
word pNext
|
||||
word script
|
||||
|
||||
printHex($1001)
|
||||
puts("callScripts: x=")
|
||||
printHex(x)
|
||||
crout()
|
||||
|
||||
p = triggerTbl
|
||||
while TRUE
|
||||
printHex($1002)
|
||||
^$c051
|
||||
puts("y loop, p=")
|
||||
printHex(p)
|
||||
puts("^p=")
|
||||
printHex(^p)
|
||||
crout()
|
||||
getUpperKey
|
||||
@ -848,22 +855,33 @@ def callScripts(x, y)
|
||||
if ^p == $FF
|
||||
return
|
||||
fin
|
||||
pNext = p + p.1
|
||||
pNext = p + p->1
|
||||
puts("p->1=")
|
||||
printHex(p->1)
|
||||
crout()
|
||||
puts("pNext=")
|
||||
printHex(pNext)
|
||||
crout()
|
||||
if ^p == y
|
||||
p = p + 2
|
||||
while p < pNext
|
||||
printHex($1003)
|
||||
puts(" x loop, p=")
|
||||
printHex(p)
|
||||
puts("^p=")
|
||||
printHex(^p)
|
||||
puts("x=")
|
||||
printHex(x)
|
||||
crout()
|
||||
|
||||
if ^p == x
|
||||
script = p:1
|
||||
printHex($1004)
|
||||
if x == ^p
|
||||
script = p->>x
|
||||
puts(" script=")
|
||||
printHex(script)
|
||||
crout()
|
||||
*script
|
||||
fin
|
||||
p = p + 3
|
||||
getUpperKey
|
||||
loop
|
||||
fin
|
||||
p = pNext
|
||||
@ -875,6 +893,9 @@ end
|
||||
def checkScripts()
|
||||
word x
|
||||
word y
|
||||
puts("checkScripts: triggerTbl=")
|
||||
printHex(triggerTbl)
|
||||
crout()
|
||||
if !triggerTbl
|
||||
return
|
||||
fin
|
||||
@ -885,17 +906,20 @@ def checkScripts()
|
||||
x = ^avatarX
|
||||
y = ^avatarY
|
||||
fin
|
||||
puts("x=")
|
||||
printHex(x)
|
||||
puts(", y=")
|
||||
printHex(y)
|
||||
crout()
|
||||
if x <> prevX or y <> prevY
|
||||
prevX = x
|
||||
prevY = y
|
||||
if anyText
|
||||
if textDrawn
|
||||
clearWindow()
|
||||
anyText = FALSE
|
||||
textDrawn = FALSE
|
||||
fin
|
||||
if isScripted()
|
||||
textDrawn = FALSE
|
||||
callScripts(x, y)
|
||||
anyText = ^textDrawn
|
||||
fin
|
||||
fin
|
||||
if (mapNum <> prevMapNum) or (mapIs3D <> prevMapIs3D)
|
||||
@ -1018,7 +1042,7 @@ def teleport(x, y, dir)
|
||||
prevX = x
|
||||
prevY = y
|
||||
clearWindow()
|
||||
anyText = FALSE
|
||||
textDrawn = FALSE
|
||||
^playerDir = dir
|
||||
redraw = TRUE
|
||||
end
|
||||
@ -1056,7 +1080,7 @@ end
|
||||
// Called by scripts to display a string. We set the flag noting that something has been
|
||||
// displayed, then use an assembly routine to do the work.
|
||||
def scriptDisplayStr(str)
|
||||
anyText = TRUE
|
||||
textDrawn = TRUE
|
||||
displayStr(str)
|
||||
end
|
||||
|
||||
@ -1070,7 +1094,7 @@ def getYN()
|
||||
return 1
|
||||
elsif key == 'N'
|
||||
clearWindow()
|
||||
anyText = FALSE
|
||||
textDrawn = FALSE
|
||||
return 0
|
||||
fin
|
||||
beep()
|
||||
@ -1119,14 +1143,16 @@ end
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Load and display the title screen.
|
||||
def loadTitle()
|
||||
puts(@helloStr)
|
||||
puts("Loading Lawless Legends.\n")
|
||||
|
||||
// Load the title screen
|
||||
puts("Loading title screen.\n")
|
||||
loader(SET_MEM_TARGET, MAIN_MEM, $2000)
|
||||
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
|
||||
puts("Title loaded.\n")
|
||||
^$c050
|
||||
^$c057
|
||||
^$c054
|
||||
|
Loading…
Reference in New Issue
Block a user