mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-09-29 11:55:21 +00:00
Centralized all shared function vectors for efficiency; made mem debug printout fit on screen; use better notation for pointer-to-pointer; fixed bug causing combat to fail on 3D map.
This commit is contained in:
parent
12a1427af6
commit
c4e46238cd
@ -1637,20 +1637,20 @@ class PackPartitions
|
|||||||
|
|
||||||
def locationsWithTriggers = [] as Set
|
def locationsWithTriggers = [] as Set
|
||||||
|
|
||||||
def vec_setScriptInfo = 0x300
|
def vec_setScriptInfo = 0x1F00
|
||||||
def vec_pushAuxStr = 0x303
|
def vec_pushAuxStr = 0x1F03
|
||||||
def vec_displayStr = 0x306
|
def vec_displayStr = 0x1F06
|
||||||
def vec_displayStrNL = 0x309
|
def vec_displayStrNL = 0x1F09
|
||||||
def vec_getYN = 0x30C
|
def vec_getYN = 0x1F0C
|
||||||
def vec_setMap = 0x30F
|
def vec_setMap = 0x1F0F
|
||||||
def vec_setSky = 0x312
|
def vec_setSky = 0x1F12
|
||||||
def vec_setGround = 0x315
|
def vec_setGround = 0x1F15
|
||||||
def vec_teleport = 0x318
|
def vec_teleport = 0x1F18
|
||||||
def vec_setPortrait = 0x31B
|
def vec_setPortrait = 0x1F1B
|
||||||
def vec_clrPortrait = 0x31E
|
def vec_clrPortrait = 0x1F1E
|
||||||
def vec_moveBackward = 0x321
|
def vec_moveBackward = 0x1F21
|
||||||
def vec_getCharacter = 0x324
|
def vec_getCharacter = 0x1F24
|
||||||
def vec_clrTextWindow = 0x327
|
def vec_clrTextWindow = 0x1F27
|
||||||
|
|
||||||
def emitAuxString(inStr)
|
def emitAuxString(inStr)
|
||||||
{
|
{
|
||||||
|
@ -1525,46 +1525,76 @@ saneEnd: !zone {
|
|||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
!if DEBUG {
|
!if DEBUG {
|
||||||
printMem: !zone
|
printMem: !zone
|
||||||
jsr main_debug
|
lda $24 ; check if we're already at start of screen line
|
||||||
jmp aux_debug
|
beq + ; no, no need for CR
|
||||||
main_debug:
|
jsr crout ; carriage return to get to start of screen line
|
||||||
|
+ lda isAuxCmd
|
||||||
|
bne aux_printMem
|
||||||
|
main_printMem:
|
||||||
+prStr : !text "MainMem:",0
|
+prStr : !text "MainMem:",0
|
||||||
ldy #0
|
ldy #0
|
||||||
jmp .printSegs
|
beq +
|
||||||
aux_debug:
|
aux_printMem:
|
||||||
+prStr : !text "AuxMem: ",0
|
+prStr : !text "AuxMem: ",0
|
||||||
ldy #1
|
ldy #1
|
||||||
|
+ ldx #14
|
||||||
.printSegs:
|
.printSegs:
|
||||||
tya
|
- +prSpace
|
||||||
tax
|
dex
|
||||||
lda #'s'
|
bne -
|
||||||
jsr .prChrEq
|
lda #'$'
|
||||||
lda #'t'
|
jsr cout
|
||||||
ldx tSegType,y
|
lda tSegAdrHi,y
|
||||||
jsr .prChrEq
|
jsr prbyte
|
||||||
lda #'n'
|
|
||||||
ldx tSegRes,y
|
|
||||||
jsr .prChrEq
|
|
||||||
lda #'a'
|
|
||||||
ldx tSegAdrHi,y
|
|
||||||
jsr .prChrEq
|
|
||||||
lda tSegAdrLo,y
|
lda tSegAdrLo,y
|
||||||
jsr prbyte
|
jsr prbyte
|
||||||
jsr crout
|
lda #','
|
||||||
.next: lda tSegLink,y
|
jsr cout
|
||||||
tay
|
lda #'L'
|
||||||
bne .printSegs
|
jsr cout
|
||||||
rts
|
lda tSegLink,y
|
||||||
.prChrEq:
|
tax
|
||||||
|
lda tSegAdrLo,x
|
||||||
|
sec
|
||||||
|
sbc tSegAdrLo,y
|
||||||
pha
|
pha
|
||||||
lda #$A0
|
lda tSegAdrHi,x
|
||||||
jsr cout
|
sbc tSegAdrHi,y
|
||||||
|
jsr prbyte
|
||||||
pla
|
pla
|
||||||
jsr cout
|
jsr prbyte
|
||||||
lda #'='
|
lda tSegType,y
|
||||||
jsr cout
|
tax
|
||||||
|
and #$40
|
||||||
|
beq +
|
||||||
|
lda #'*'
|
||||||
|
bne ++
|
||||||
|
+ lda #'+'
|
||||||
|
cpx #0
|
||||||
|
bmi ++
|
||||||
|
lda #'-'
|
||||||
|
++ jsr cout
|
||||||
txa
|
txa
|
||||||
jmp prbyte
|
and #$F
|
||||||
|
tax
|
||||||
|
jsr prhex
|
||||||
|
txa
|
||||||
|
beq +
|
||||||
|
lda #':'
|
||||||
|
jsr cout
|
||||||
|
lda tSegRes,y
|
||||||
|
+prA
|
||||||
|
jmp .next
|
||||||
|
+ ldx #4
|
||||||
|
- +prSpace
|
||||||
|
dex
|
||||||
|
bne -
|
||||||
|
.next: ldx #3 ; 2 spaces before next entry
|
||||||
|
lda tSegLink,y
|
||||||
|
tay
|
||||||
|
beq +
|
||||||
|
jmp .printSegs
|
||||||
|
+ jmp crout
|
||||||
}
|
}
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
@ -1594,14 +1624,7 @@ reset: !zone
|
|||||||
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
outOfMemErr: !zone
|
outOfMemErr: !zone
|
||||||
!if DEBUG {
|
!if DEBUG { jsr printMem }
|
||||||
lda isAuxCmd
|
|
||||||
bne +
|
|
||||||
jsr main_debug
|
|
||||||
jmp ++
|
|
||||||
+ jsr aux_debug
|
|
||||||
++
|
|
||||||
}
|
|
||||||
jsr inlineFatal : !text "OutOfMem", 0
|
jsr inlineFatal : !text "OutOfMem", 0
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
@ -1776,6 +1799,7 @@ shared_scan: !zone
|
|||||||
+ rts
|
+ rts
|
||||||
|
|
||||||
invalParam: !zone
|
invalParam: !zone
|
||||||
|
!if DEBUG { jsr printMem }
|
||||||
jsr inlineFatal : !text "InvalParam", 0
|
jsr inlineFatal : !text "InvalParam", 0
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
|
@ -190,7 +190,7 @@ def playerCombatChoose(pl)
|
|||||||
loop
|
loop
|
||||||
|
|
||||||
// NPCs always melee for now
|
// NPCs always melee for now
|
||||||
if pl=>b_playerFlags & PLAYER_FLAG_NPC
|
if pl->b_playerFlags & PLAYER_FLAG_NPC
|
||||||
pl->b_combatChoice = 'M'
|
pl->b_combatChoice = 'M'
|
||||||
return
|
return
|
||||||
fin
|
fin
|
||||||
@ -301,7 +301,7 @@ def enemyCombatTurn(pe)
|
|||||||
|
|
||||||
// Choose a target
|
// Choose a target
|
||||||
pl = randomFromListFiltered(global=>p_players, p_nextObj, @canFight)
|
pl = randomFromListFiltered(global=>p_players, p_nextObj, @canFight)
|
||||||
if !pl; return; fin
|
if !pl; return FALSE; fin
|
||||||
|
|
||||||
buildString(@addToString)
|
buildString(@addToString)
|
||||||
printf3("\n%s %s %s ", pe=>s_name, pe=>s_attackText, pl=>s_name)
|
printf3("\n%s %s %s ", pe=>s_name, pe=>s_attackText, pl=>s_name)
|
||||||
@ -322,6 +322,7 @@ def enemyCombatTurn(pe)
|
|||||||
puts("\n")
|
puts("\n")
|
||||||
|
|
||||||
displayStr(finishString(0))
|
displayStr(finishString(0))
|
||||||
|
return TRUE
|
||||||
end
|
end
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -329,7 +330,7 @@ def combatInsert(toAdd)
|
|||||||
word p, pPrev
|
word p, pPrev
|
||||||
|
|
||||||
// Find the proper position based on combat order number (keep largest first in the list)
|
// Find the proper position based on combat order number (keep largest first in the list)
|
||||||
pPrev = global + p_combatFirst
|
pPrev = @global=>p_combatFirst
|
||||||
while TRUE
|
while TRUE
|
||||||
p = *pPrev
|
p = *pPrev
|
||||||
if !p or p->b_combatOrder < toAdd->b_combatOrder
|
if !p or p->b_combatOrder < toAdd->b_combatOrder
|
||||||
@ -458,7 +459,7 @@ def doCombat()
|
|||||||
while TRUE
|
while TRUE
|
||||||
p = global=>p_players
|
p = global=>p_players
|
||||||
while p
|
while p
|
||||||
if canFight(p)
|
if canFight(p) and nEnemiesFighting
|
||||||
playerCombatChoose(p)
|
playerCombatChoose(p)
|
||||||
fin
|
fin
|
||||||
p = p=>p_nextObj
|
p = p=>p_nextObj
|
||||||
@ -502,13 +503,15 @@ def doCombat()
|
|||||||
if canFight(p)
|
if canFight(p)
|
||||||
when p->t_type
|
when p->t_type
|
||||||
is TYPE_PLAYER
|
is TYPE_PLAYER
|
||||||
playerCombatTurn(p); break
|
playerCombatTurn(p)
|
||||||
|
combatPause()
|
||||||
|
break
|
||||||
is TYPE_ENEMY
|
is TYPE_ENEMY
|
||||||
enemyCombatTurn(p); break
|
if enemyCombatTurn(p); combatPause(); fin
|
||||||
|
break
|
||||||
otherwise
|
otherwise
|
||||||
brk()
|
brk()
|
||||||
wend
|
wend
|
||||||
combatPause()
|
|
||||||
fin
|
fin
|
||||||
p = p=>p_combatNext
|
p = p=>p_combatNext
|
||||||
loop
|
loop
|
||||||
|
@ -55,53 +55,67 @@ const HEAP_COLLECT = $24
|
|||||||
// Shared library routines
|
// Shared library routines
|
||||||
const gameLibVecs = $1F00
|
const gameLibVecs = $1F00
|
||||||
|
|
||||||
const getGlobals = gameLibVecs + 3*0
|
// The first set of functions are used by scripts generated by the packer
|
||||||
const rand16 = gameLibVecs + 3*1
|
const setScriptInfo = gameLibVecs + 3*0
|
||||||
const printf1 = gameLibVecs + 3*2
|
const pushAuxStr = gameLibVecs + 3*1
|
||||||
const printf2 = gameLibVecs + 3*3
|
const scriptDisplayStr = gameLibVecs + 3*2
|
||||||
const printf3 = gameLibVecs + 3*4
|
const scriptDisplayStrNL = gameLibVecs + 3*3
|
||||||
const printf4 = gameLibVecs + 3*5
|
const getYN = gameLibVecs + 3*4
|
||||||
const displayf1 = gameLibVecs + 3*6
|
const queue_setMap = gameLibVecs + 3*5
|
||||||
const displayf2 = gameLibVecs + 3*7
|
const setSky = gameLibVecs + 3*6
|
||||||
const displayf3 = gameLibVecs + 3*8
|
const setGround = gameLibVecs + 3*7
|
||||||
const displayf4 = gameLibVecs + 3*9
|
const queue_teleport = gameLibVecs + 3*8
|
||||||
const buildString = gameLibVecs + 3*10
|
const setPortrait = gameLibVecs + 3*9
|
||||||
const addToString = gameLibVecs + 3*11
|
const clearPortrait = gameLibVecs + 3*10
|
||||||
const finishString = gameLibVecs + 3*12
|
const moveBackward = gameLibVecs + 3*11
|
||||||
const rawDisplayStr = gameLibVecs + 3*13
|
const getUpperKey = gameLibVecs + 3*12
|
||||||
const displayStr = gameLibVecs + 3*14
|
const clearWindow = gameLibVecs + 3*13
|
||||||
const puts = gameLibVecs + 3*15
|
|
||||||
const min = gameLibVecs + 3*16
|
const FUNCN14 = gameLibVecs + 3*14
|
||||||
const max = gameLibVecs + 3*17
|
const FUNCN15 = gameLibVecs + 3*15
|
||||||
const countList = gameLibVecs + 3*18
|
const FUNCN16 = gameLibVecs + 3*16
|
||||||
const countListFiltered = gameLibVecs + 3*19
|
const FUNCN17 = gameLibVecs + 3*17
|
||||||
const randomFromListFiltered = gameLibVecs + 3*20
|
const FUNCN18 = gameLibVecs + 3*18
|
||||||
const addToList = gameLibVecs + 3*21
|
const FUNCN19 = gameLibVecs + 3*19
|
||||||
const getUpperKey = gameLibVecs + 3*22
|
|
||||||
const beep = gameLibVecs + 3*23
|
// The second set of functions are used by PLASMA code modules
|
||||||
const showParty = gameLibVecs + 3*24
|
const getGlobals = gameLibVecs + 3*20
|
||||||
const mmgr = gameLibVecs + 3*25
|
const rand16 = gameLibVecs + 3*21
|
||||||
const setPortrait = gameLibVecs + 3*26
|
const printf1 = gameLibVecs + 3*22
|
||||||
const setWindow1 = gameLibVecs + 3*27
|
const printf2 = gameLibVecs + 3*23
|
||||||
const setWindow2 = gameLibVecs + 3*28
|
const printf3 = gameLibVecs + 3*24
|
||||||
const setWindow3 = gameLibVecs + 3*29
|
const displayf1 = gameLibVecs + 3*25
|
||||||
const clearWindow = gameLibVecs + 3*30
|
const displayf2 = gameLibVecs + 3*26
|
||||||
const getYN = gameLibVecs + 3*31
|
const displayf3 = gameLibVecs + 3*27
|
||||||
const reboot = gameLibVecs + 3*32
|
const buildString = gameLibVecs + 3*28
|
||||||
const brk = gameLibVecs + 3*33
|
const addToString = gameLibVecs + 3*29
|
||||||
const encodeDice = gameLibVecs + 3*34
|
const finishString = gameLibVecs + 3*30
|
||||||
const rollDice = gameLibVecs + 3*35
|
const rawDisplayStr = gameLibVecs + 3*31
|
||||||
const setPlural = gameLibVecs + 3*36
|
const displayStr = gameLibVecs + 3*32
|
||||||
const FUNCN37 = gameLibVecs + 3*37
|
const puts = gameLibVecs + 3*33
|
||||||
const FUNCN38 = gameLibVecs + 3*38
|
const min = gameLibVecs + 3*34
|
||||||
const FUNCN39 = gameLibVecs + 3*39
|
const max = gameLibVecs + 3*35
|
||||||
const FUNCN40 = gameLibVecs + 3*40
|
const countList = gameLibVecs + 3*36
|
||||||
const FUNCN41 = gameLibVecs + 3*41
|
const countListFiltered = gameLibVecs + 3*37
|
||||||
const FUNCN42 = gameLibVecs + 3*42
|
const randomFromListFiltered = gameLibVecs + 3*38
|
||||||
const FUNCN43 = gameLibVecs + 3*43
|
const addToList = gameLibVecs + 3*39
|
||||||
const FUNCN44 = gameLibVecs + 3*44
|
const beep = gameLibVecs + 3*40
|
||||||
const FUNCN45 = gameLibVecs + 3*45
|
const showParty = gameLibVecs + 3*41
|
||||||
const FUNCN46 = gameLibVecs + 3*46
|
const mmgr = gameLibVecs + 3*42
|
||||||
const FUNCN47 = gameLibVecs + 3*47
|
const setWindow1 = gameLibVecs + 3*43
|
||||||
const FUNCN48 = gameLibVecs + 3*48
|
const setWindow2 = gameLibVecs + 3*44
|
||||||
const FUNCN49 = gameLibVecs + 3*49
|
const setWindow3 = gameLibVecs + 3*45
|
||||||
|
const reboot = gameLibVecs + 3*46
|
||||||
|
const brk = gameLibVecs + 3*47
|
||||||
|
const encodeDice = gameLibVecs + 3*48
|
||||||
|
const rollDice = gameLibVecs + 3*49
|
||||||
|
const setPlural = gameLibVecs + 3*50
|
||||||
|
const FUNCN51 = gameLibVecs + 3*51
|
||||||
|
const FUNCN52 = gameLibVecs + 3*52
|
||||||
|
const FUNCN53 = gameLibVecs + 3*53
|
||||||
|
const FUNCN54 = gameLibVecs + 3*54
|
||||||
|
const FUNCN55 = gameLibVecs + 3*55
|
||||||
|
const FUNCN56 = gameLibVecs + 3*56
|
||||||
|
const FUNCN57 = gameLibVecs + 3*57
|
||||||
|
const FUNCN58 = gameLibVecs + 3*58
|
||||||
|
const FUNCN59 = gameLibVecs + 3*59
|
||||||
|
@ -22,8 +22,6 @@ const heapSize = $800
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Other constants
|
// Other constants
|
||||||
const callbacks = $300
|
|
||||||
|
|
||||||
const kbd = $C000
|
const kbd = $C000
|
||||||
const kbdStrobe = $C010
|
const kbdStrobe = $C010
|
||||||
|
|
||||||
@ -55,6 +53,7 @@ word totalMapWidth
|
|||||||
word totalMapHeight
|
word totalMapHeight
|
||||||
|
|
||||||
byte needRender = FALSE
|
byte needRender = FALSE
|
||||||
|
byte renderLoaded = FALSE
|
||||||
byte textDrawn = FALSE
|
byte textDrawn = FALSE
|
||||||
byte isPlural = FALSE
|
byte isPlural = FALSE
|
||||||
|
|
||||||
@ -89,24 +88,33 @@ byte animFrame
|
|||||||
word animPauseCt
|
word animPauseCt
|
||||||
|
|
||||||
// Game library functions
|
// Game library functions
|
||||||
|
predef _setScriptInfo, _pushAuxStr, _scriptDisplayStr, _scriptDisplayStrNL, _getYN
|
||||||
|
predef _queue_setMap, _setSky, _setGround, _queue_teleport, _setPortrait, _clearPortrait
|
||||||
|
predef _moveBackward, _getUpperKey, _clearWindow, _setPortrait
|
||||||
|
|
||||||
predef _getGlobals, _rand16
|
predef _getGlobals, _rand16
|
||||||
predef _printf1, _printf2, _printf3, _printf4
|
predef _printf1, _printf2, _printf3
|
||||||
predef _displayf1, _displayf2, _displayf3, _displayf4
|
predef _displayf1, _displayf2, _displayf3
|
||||||
predef _buildString, _addToString, _finishString, _rawDisplayStr, _displayStr
|
predef _buildString, _addToString, _finishString, _rawDisplayStr, _displayStr
|
||||||
predef _puts, _min, _max
|
predef _puts, _min, _max
|
||||||
predef _countList, _countListFiltered, _randomFromListFiltered, _addToList, _getUpperKey, _beep
|
predef _countList, _countListFiltered, _randomFromListFiltered, _addToList, _beep
|
||||||
predef _showParty, _mmgr, _setPortrait, _setWindow1, _setWindow2, _setWindow3, _clearWindow
|
predef _showParty, _mmgr, _setWindow1, _setWindow2, _setWindow3
|
||||||
predef _getYN, _reboot, _brk, _encodeDice, _rollDice
|
predef _reboot, _brk, _encodeDice, _rollDice
|
||||||
predef _setPlural
|
predef _setPlural
|
||||||
|
|
||||||
word gameLib_addrs = @_getGlobals, @_rand16
|
word gameLib_addrs = @_setScriptInfo, @_pushAuxStr, @_scriptDisplayStr, @_scriptDisplayStrNL, @_getYN
|
||||||
word = @_printf1, @_printf2, @_printf3, @_printf4
|
word = @_queue_setMap, @_setSky, @_setGround, @_queue_teleport, @_setPortrait, @_clearPortrait
|
||||||
word = @_displayf1, @_displayf2, @_displayf3, @_displayf4
|
word = @_moveBackward, @_getUpperKey, @_clearWindow
|
||||||
|
word = 14,15,16,17,18,19
|
||||||
|
|
||||||
|
word = @_getGlobals, @_rand16
|
||||||
|
word = @_printf1, @_printf2, @_printf3
|
||||||
|
word = @_displayf1, @_displayf2, @_displayf3
|
||||||
word = @_buildString, @_addToString, @_finishString, @_rawDisplayStr, @_displayStr
|
word = @_buildString, @_addToString, @_finishString, @_rawDisplayStr, @_displayStr
|
||||||
word = @_puts, @_min, @_max
|
word = @_puts, @_min, @_max
|
||||||
word = @_countList, @_countListFiltered, @_randomFromListFiltered, @_addToList, @_getUpperKey, @_beep
|
word = @_countList, @_countListFiltered, @_randomFromListFiltered, @_addToList, @_beep
|
||||||
word = @_showParty, @_mmgr, @_setPortrait, @_setWindow1, @_setWindow2, @_setWindow3, @_clearWindow
|
word = @_showParty, @_mmgr, @_setWindow1, @_setWindow2, @_setWindow3
|
||||||
word = @_getYN, @_reboot, @_brk, @_encodeDice, @_rollDice
|
word = @_reboot, @_brk, @_encodeDice, @_rollDice
|
||||||
word = @_setPlural
|
word = @_setPlural
|
||||||
|
|
||||||
word = 0 // end of library functions
|
word = 0 // end of library functions
|
||||||
@ -137,9 +145,9 @@ ysav1 = $35
|
|||||||
seed = $4E
|
seed = $4E
|
||||||
magic = $2227 ; there are 2048 magic values that work; this one caught my eye. - MH
|
magic = $2227 ; there are 2048 magic values that work; this one caught my eye. - MH
|
||||||
|
|
||||||
; NOTE ABOUT ABSOLUTE ADDRESSES
|
; NOTE ABOUT ABSOLUTE CODE ADDRESSING (e.g. STA .var, JMP .label, etc.)
|
||||||
; You cannot use them: this code, including variable space, can be loaded *anywhere*.
|
; We cannot use it: this code, including variable space, can be loaded *anywhere*.
|
||||||
; So don't declare any variables as !byte or !word here.
|
; So don't JMP to labels, declare any variables as !byte or !word here, etc.
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -224,7 +232,7 @@ asm readAuxByte // params: ptr; ret: char
|
|||||||
end
|
end
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
asm pushAuxStr // params: none; ret: $200 (inbuf)
|
asm _pushAuxStr // params: none; ret: $200 (inbuf)
|
||||||
stx tmp ; save PLASMA's X reg eval stack index
|
stx tmp ; save PLASMA's X reg eval stack index
|
||||||
tsx
|
tsx
|
||||||
lda $103,x ; get PLASMA's Y-reg value from its place in the stack
|
lda $103,x ; get PLASMA's Y-reg value from its place in the stack
|
||||||
@ -910,8 +918,8 @@ def convertDec(n)
|
|||||||
end
|
end
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Print a formatted string a'la C printf, with up to four parameters.
|
// Print a formatted string a'la C printf, with up to three parameters.
|
||||||
def _printf4(str, arg1, arg2, arg3, arg4)
|
def _printf3(str, arg1, arg2, arg3)
|
||||||
word pos
|
word pos
|
||||||
word curArg
|
word curArg
|
||||||
word p
|
word p
|
||||||
@ -942,20 +950,18 @@ def _printf4(str, arg1, arg2, arg3, arg4)
|
|||||||
loop
|
loop
|
||||||
end
|
end
|
||||||
|
|
||||||
def _printf1(str, arg1); printf4(str, arg1, 0, 0, 0); end
|
def _printf1(str, arg1); printf3(str, arg1, 0, 0); end
|
||||||
def _printf2(str, arg1, arg2); printf4(str, arg1, arg2, 0, 0); end
|
def _printf2(str, arg1, arg2); printf3(str, arg1, arg2, 0); end
|
||||||
def _printf3(str, arg1, arg2, arg3); printf4(str, arg1, arg2, arg3, 0); end
|
|
||||||
|
|
||||||
// Like printf, but displays text using font engine
|
// Like printf, but displays text using font engine
|
||||||
def _displayf4(str, arg1, arg2, arg3, arg4)
|
def _displayf3(str, arg1, arg2, arg3)
|
||||||
buildString(@addToString)
|
buildString(@addToString)
|
||||||
printf4(str, arg1, arg2, arg3, arg4)
|
printf3(str, arg1, arg2, arg3)
|
||||||
displayStr(finishString(isPlural))
|
displayStr(finishString(isPlural))
|
||||||
end
|
end
|
||||||
|
|
||||||
def _displayf1(str, arg1); displayf4(str, arg1, 0, 0, 0); end
|
def _displayf1(str, arg1); displayf3(str, arg1, 0, 0); end
|
||||||
def _displayf2(str, arg1, arg2); displayf4(str, arg1, arg2, 0, 0); end
|
def _displayf2(str, arg1, arg2); displayf3(str, arg1, arg2, 0); end
|
||||||
def _displayf3(str, arg1, arg2, arg3); displayf4(str, arg1, arg2, arg3, 0); end
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
def parseDec(str)
|
def parseDec(str)
|
||||||
@ -1034,7 +1040,7 @@ end
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Set the sky color (relevant to 3D display only)
|
// Set the sky color (relevant to 3D display only)
|
||||||
def setSky(num)
|
def _setSky(num)
|
||||||
skyNum = num
|
skyNum = num
|
||||||
setColor(0, skyNum)
|
setColor(0, skyNum)
|
||||||
needRender = TRUE
|
needRender = TRUE
|
||||||
@ -1048,7 +1054,7 @@ end
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Set the ground color (relevant to 3D display only)
|
// Set the ground color (relevant to 3D display only)
|
||||||
def setGround(num)
|
def _setGround(num)
|
||||||
groundNum = num
|
groundNum = num
|
||||||
setColor(1, groundNum)
|
setColor(1, groundNum)
|
||||||
needRender = TRUE
|
needRender = TRUE
|
||||||
@ -1204,6 +1210,7 @@ def initMap(x, y, dir)
|
|||||||
mmgr(QUEUE_LOAD, CODE_TILE_ENGINE<<8 | RES_TYPE_CODE)
|
mmgr(QUEUE_LOAD, CODE_TILE_ENGINE<<8 | RES_TYPE_CODE)
|
||||||
pMap = mmgr(QUEUE_LOAD, mapNum<<8 | RES_TYPE_2D_MAP)
|
pMap = mmgr(QUEUE_LOAD, mapNum<<8 | RES_TYPE_2D_MAP)
|
||||||
fin
|
fin
|
||||||
|
renderLoaded = TRUE
|
||||||
|
|
||||||
// Load everything that we just queued
|
// Load everything that we just queued
|
||||||
mmgr(FINISH_LOAD, 1) // 1 = keep open
|
mmgr(FINISH_LOAD, 1) // 1 = keep open
|
||||||
@ -1259,11 +1266,13 @@ end
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Display a portrait drawing (typically called from scripts)
|
// Display a portrait drawing (typically called from scripts)
|
||||||
def clearPortrait()
|
def _clearPortrait()
|
||||||
if curPortrait
|
if curPortrait
|
||||||
auxMmgr(FREE_MEMORY, curPortrait)
|
auxMmgr(FREE_MEMORY, curPortrait)
|
||||||
curPortrait = 0
|
curPortrait = 0
|
||||||
|
if renderLoaded
|
||||||
texControl(1) // 1=load
|
texControl(1) // 1=load
|
||||||
|
fin
|
||||||
needRender = TRUE
|
needRender = TRUE
|
||||||
fin
|
fin
|
||||||
end
|
end
|
||||||
@ -1313,7 +1322,7 @@ end
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Move backward one step (3D mode)
|
// Move backward one step (3D mode)
|
||||||
def moveBackward()
|
def _moveBackward()
|
||||||
adjustDir(8)
|
adjustDir(8)
|
||||||
moveForward()
|
moveForward()
|
||||||
adjustDir(8)
|
adjustDir(8)
|
||||||
@ -1466,7 +1475,7 @@ def showPos()
|
|||||||
end
|
end
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
def queue_setMap(is3D, num, x, y, dir)
|
def _queue_setMap(is3D, num, x, y, dir)
|
||||||
q_mapIs3D = is3D
|
q_mapIs3D = is3D
|
||||||
q_mapNum = num
|
q_mapNum = num
|
||||||
q_x = x
|
q_x = x
|
||||||
@ -1475,7 +1484,7 @@ def queue_setMap(is3D, num, x, y, dir)
|
|||||||
end
|
end
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
def queue_teleport(x, y, dir)
|
def _queue_teleport(x, y, dir)
|
||||||
queue_setMap(mapIs3D, mapNum, x, y, dir)
|
queue_setMap(mapIs3D, mapNum, x, y, dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1528,7 +1537,7 @@ end
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Set initial info for the scripts on this map: the name of the map, its trigger table, and the
|
// Set initial info for the scripts on this map: the name of the map, its trigger table, and the
|
||||||
// maximum extent (width, height). This is called by the init function for the scripts.
|
// maximum extent (width, height). This is called by the init function for the scripts.
|
||||||
def setScriptInfo(mapName, trigTbl, wdt, hgt)
|
def _setScriptInfo(mapName, trigTbl, wdt, hgt)
|
||||||
|
|
||||||
// Grab the trigger table origins (used so the table can be more compact)
|
// Grab the trigger table origins (used so the table can be more compact)
|
||||||
triggerOriginX = trigTbl=>0
|
triggerOriginX = trigTbl=>0
|
||||||
@ -1551,13 +1560,13 @@ end
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Called by scripts to display a string. We set the flag noting that something has been
|
// 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.
|
// displayed, then use an assembly routine to do the work.
|
||||||
def scriptDisplayStr(str)
|
def _scriptDisplayStr(str)
|
||||||
textDrawn = TRUE
|
textDrawn = TRUE
|
||||||
flipToPage1()
|
flipToPage1()
|
||||||
displayStr(str)
|
displayStr(str)
|
||||||
end
|
end
|
||||||
|
|
||||||
def scriptDisplayStrNL(str)
|
def _scriptDisplayStrNL(str)
|
||||||
scriptDisplayStr(str)
|
scriptDisplayStr(str)
|
||||||
displayStr("\n")
|
displayStr("\n")
|
||||||
end
|
end
|
||||||
@ -1663,8 +1672,10 @@ def _setPortrait(portraitNum)
|
|||||||
// We're going to switch windows. Save the cursor pos in the text window.
|
// We're going to switch windows. Save the cursor pos in the text window.
|
||||||
saveCursor()
|
saveCursor()
|
||||||
|
|
||||||
// Make room by unloading the textures
|
// Make room by unloading the textures (only if renderer is loaded)
|
||||||
|
if renderLoaded
|
||||||
texControl(0)
|
texControl(0)
|
||||||
|
fin
|
||||||
|
|
||||||
// Now clear out the map area
|
// Now clear out the map area
|
||||||
setMapWindow()
|
setMapWindow()
|
||||||
@ -1746,7 +1757,7 @@ def _randomFromListFiltered(p, offset, filterFunc)
|
|||||||
end
|
end
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Call like this: addToList(player + items, itemToAdd)
|
// Call like this: addToList(@player=>p_items, itemToAdd)
|
||||||
def _addToList(addTo, p)
|
def _addToList(addTo, p)
|
||||||
// Get to the end of the list
|
// Get to the end of the list
|
||||||
while *addTo
|
while *addTo
|
||||||
@ -1826,7 +1837,7 @@ end
|
|||||||
def saveMapPos()
|
def saveMapPos()
|
||||||
global->b_mapIs3D = mapIs3D
|
global->b_mapIs3D = mapIs3D
|
||||||
global->b_mapNum = mapNum
|
global->b_mapNum = mapNum
|
||||||
getPos(global + w_mapX, global + w_mapY)
|
getPos(@global=>w_mapX, @global=>w_mapY)
|
||||||
global->b_mapDir = getDir()
|
global->b_mapDir = getDir()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1848,6 +1859,7 @@ def testCombat()
|
|||||||
// Load the combat engine
|
// Load the combat engine
|
||||||
flipToPage1()
|
flipToPage1()
|
||||||
mmgr(RESET_MEMORY, 0)
|
mmgr(RESET_MEMORY, 0)
|
||||||
|
renderLoaded = FALSE
|
||||||
combatEngine = mmgr(QUEUE_LOAD, MODULE_COMBAT<<8 | RES_TYPE_MODULE)
|
combatEngine = mmgr(QUEUE_LOAD, MODULE_COMBAT<<8 | RES_TYPE_MODULE)
|
||||||
mmgr(FINISH_LOAD, 1) // 0 = close
|
mmgr(FINISH_LOAD, 1) // 0 = close
|
||||||
|
|
||||||
@ -1855,10 +1867,10 @@ def testCombat()
|
|||||||
global=>p_enemyGroups = NULL
|
global=>p_enemyGroups = NULL
|
||||||
when rand16() % 2
|
when rand16() % 2
|
||||||
is 0
|
is 0
|
||||||
addToList(global + p_enemyGroups, new_EnemyGroup_Dirt_Bags())
|
addToList(@global=>p_enemyGroups, new_EnemyGroup_Dirt_Bags())
|
||||||
break
|
break
|
||||||
otherwise
|
otherwise
|
||||||
addToList(global + p_enemyGroups, new_EnemyGroup_Flesh_Feeders())
|
addToList(@global=>p_enemyGroups, new_EnemyGroup_Flesh_Feeders())
|
||||||
break
|
break
|
||||||
wend
|
wend
|
||||||
|
|
||||||
@ -1972,67 +1984,6 @@ def loadTitle()
|
|||||||
getUpperKey()
|
getUpperKey()
|
||||||
end
|
end
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Set vectors so that scripts in PLASMA can call back to do things with this engine.
|
|
||||||
def setCallbacks()
|
|
||||||
|
|
||||||
// $300
|
|
||||||
callbacks.0 = $4c
|
|
||||||
callbacks:1 = @setScriptInfo
|
|
||||||
|
|
||||||
// $303
|
|
||||||
callbacks.3 = $4c
|
|
||||||
callbacks:4 = @pushAuxStr
|
|
||||||
|
|
||||||
// $306
|
|
||||||
callbacks.6 = $4c
|
|
||||||
callbacks:7 = @scriptDisplayStr
|
|
||||||
|
|
||||||
// $309
|
|
||||||
callbacks.9 = $4c
|
|
||||||
callbacks:10 = @scriptDisplayStrNL
|
|
||||||
|
|
||||||
// $30C
|
|
||||||
callbacks.12 = $4c
|
|
||||||
callbacks:13 = @getYN
|
|
||||||
|
|
||||||
// $30F
|
|
||||||
callbacks.15 = $4c
|
|
||||||
callbacks:16 = @queue_setMap
|
|
||||||
|
|
||||||
// $312
|
|
||||||
callbacks.18 = $4c
|
|
||||||
callbacks:19 = @setSky
|
|
||||||
|
|
||||||
// $315
|
|
||||||
callbacks.21 = $4c
|
|
||||||
callbacks:22 = @setGround
|
|
||||||
|
|
||||||
// $318
|
|
||||||
callbacks.24 = $4c
|
|
||||||
callbacks:25 = @queue_teleport
|
|
||||||
|
|
||||||
// $31B
|
|
||||||
callbacks.27 = $4c
|
|
||||||
callbacks:28 = @setPortrait
|
|
||||||
|
|
||||||
// $31E
|
|
||||||
callbacks.30 = $4c
|
|
||||||
callbacks:31 = @clearPortrait
|
|
||||||
|
|
||||||
// $321
|
|
||||||
callbacks.33 = $4c
|
|
||||||
callbacks:34 = @moveBackward
|
|
||||||
|
|
||||||
// $324
|
|
||||||
callbacks.36 = $4c
|
|
||||||
callbacks:37 = @getUpperKey
|
|
||||||
|
|
||||||
// $327
|
|
||||||
callbacks.39 = $4c
|
|
||||||
callbacks:40 = @clearWindow
|
|
||||||
end
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Set up the small-object heap
|
// Set up the small-object heap
|
||||||
def initHeap()
|
def initHeap()
|
||||||
@ -2073,14 +2024,11 @@ end
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Main code.
|
// Main code.
|
||||||
//
|
//
|
||||||
textDrawn = FALSE
|
|
||||||
needRender = TRUE
|
|
||||||
setLibVecs()
|
setLibVecs()
|
||||||
initHeap()
|
initHeap()
|
||||||
addToList(global + p_players, new_Player_Hue_Hauser())
|
addToList(@global=>p_players, new_Player_Hue_Hauser())
|
||||||
addToList(global + p_players, new_Player_Mokahnu())
|
addToList(@global=>p_players, new_Player_Mokahnu())
|
||||||
loadTitle()
|
loadTitle()
|
||||||
setCallbacks()
|
|
||||||
// Start map/loc per Seth. Need to have this in a script in the futurecheckScripts()
|
// Start map/loc per Seth. Need to have this in a script in the futurecheckScripts()
|
||||||
mapIs3D = 0
|
mapIs3D = 0
|
||||||
mapNum = 1
|
mapNum = 1
|
||||||
|
@ -1652,12 +1652,6 @@ pl_texControl: !zone {
|
|||||||
pha
|
pha
|
||||||
ldy texAddrHi,x
|
ldy texAddrHi,x
|
||||||
lda texAddrLo,x
|
lda texAddrLo,x
|
||||||
|
|
||||||
+prStr : !text "tex ",0
|
|
||||||
+prX
|
|
||||||
+prYA
|
|
||||||
+crout
|
|
||||||
|
|
||||||
tax
|
tax
|
||||||
lda #FREE_MEMORY
|
lda #FREE_MEMORY
|
||||||
jsr auxLoader
|
jsr auxLoader
|
||||||
|
Loading…
Reference in New Issue
Block a user