Removed old kludged finalWin() logic. Moved a couple of functions to godmode.pla that were only used there anyway.

This commit is contained in:
Martin Haye 2017-08-15 10:01:28 -07:00
parent be58f38628
commit ffa1bb9afe
4 changed files with 101 additions and 108 deletions

View File

@ -1583,7 +1583,7 @@ class A2PackPartitions
month == 9 ? 'o' :
month == 10 ? 'n' :
'd'
def hourCode = (char) (65 + hour)
def hourCode = (char) (97 + hour) // 'a'=0, 'b'=1, etc.
def engineCode = String.format("%d%c%02d%c", yearCode, monthCode, day, hourCode)
def offset = (int) ((scenarioStamp - engineStamp) / (1000 * 60 * 60))

View File

@ -47,7 +47,6 @@ import gamelib
predef displayStr(str)#0
predef encodeDice(nDice, dieSize, add)#1
predef fatal(msg)#1
predef finalWin()#0
predef finishString(isPlural)#1
predef flipToPage1()#0
predef getCharResponse()#1
@ -74,7 +73,6 @@ import gamelib
predef mmgr(cmd, wordParam)#1
predef moveWayBackward()#1
predef parseDec(str)#1
predef parseDecWithDefault(str, default)#1
predef partyHasPlayer(playerName)#1
predef pause(count)#0
predef payGold(amount)#1
@ -95,7 +93,6 @@ import gamelib
predef rawDisplayf3(fmt, arg1, arg2, arg3)#0
predef rawDisplayStr(str)#0
predef rdkey()#1
predef readStr()#1
predef removeFromList(pList, toRemove)#0
predef removePlayerFromParty(playerName)#0
predef rightJustifyNum(num, rightX)#0

View File

@ -60,7 +60,6 @@ predef doRender()#0
predef playerDeath()#0
predef startGame(ask)#0
predef showAnimFrame()#0
predef finalWin()#0
predef showParty()#0
///////////////////////////////////////////////////////////////////////////////////////////////////
@ -77,7 +76,7 @@ byte renderLoaded = FALSE
byte texturesLoaded = FALSE
byte textDrawn = FALSE
byte textClearCountdown = 0
byte isPlural = FALSE
byte isPlural = 0 // valid values: 0 or $40
byte inScript = FALSE
export word skyNum = 9
@ -406,78 +405,73 @@ export asm finishString(isPlural)#1
sta cswl
lda #$FD
sta cswh
bit fixedRTS; V flag for prev-is-punctuation
ldy #1 ; dest offset in Y
ldx #1 ; source offset in X
clv ; V flag for prev-is-alpha
ldy #0 ; dest offset in Y (will be incremented before store)
ldx #0 ; source offset in X (will be incremented before load)
cpx inbuf
beq + ; only process if string has at least 1 char
bcs .done
+ sty tmp+1 ; offset of last punctuation
beq .done ; failsafe: handle zero-length string
.fetch
lda inbuf,x
cmp #"("
inx
lda inbuf,x ; get next input char
iny
sta inbuf,y ; by default copy the char to output
cmp #"(" ; plural processing triggered by parentheses
bne .notpar
bvs .notpar ; skip paren processing right punctuation
lda tmp ; check isPlural flag
bne .plurpr
- lda inbuf,x ; it's singular, so skip everything in parens
cmp #")"
beq .next
bvc .notpar ; but only parens directly after alpha char, e.g. preserving "Happy (and safe)."
dey ; undo copy of the paren
stx tmp+1 ; save position in input
bit tmp ; set copy flag (V) initially to same as isPlural flag
dex ; needed for failsafe operation
.findsl ; see if there's a slash within the parens
inx
cpx inbuf
bne -
beq .done ; handle missing trailing paren
.plurpr
inx ; it's plural, so copy everything within the parens
lda inbuf,x ; copy characters
cpx inbuf ; handle missing trailing paren
lda inbuf,x
cmp #"/"
bne +
php
pla
eor #$40 ; flip V flag, meaning singular text is before slash, plural after.
pha
plp
+ cmp #")" ; scan until ending paren
beq +
bcs .store
+ cmp #")" ; go until we reach ending paren
beq .next
sta inbuf,y
cpx inbuf
bcc .findsl ; loop to scan next char
bcs .done ; failsafe: handle missing end-paren (always taken)
+ ldx tmp+1 ; get back to start of parens
; copy mode flag is now in V: if slash present, single=copy, plural=nocopy
; if no slash: single=nocopy, plural=copy
.plup
inx
lda inbuf,x
cmp #"/"
bne +
php
pla
eor #$40 ; flip from copying to not-copying, or vice-versa
pha
plp
bcs .plup ; always taken
+ cmp #")"
beq + ; stop at closing paren
bvc .plup ; if not in copy mode, skip copy
iny
bne .plurpr ; always taken
sta inbuf,y ; else do copy
bne .plup ; always taken
+ dey ; to offset upcoming iny, since we already copied
.notpar
cmp #"/"
bne .notsl
bvs .notsl ; skip slash processing right after punctuation
lda tmp ; check isPlural flag
bne .plursl
- inx ; loop that skips plural form
cpx inbuf
beq +
bcs .done ; handle end of string
+ lda inbuf,x
cmp #"A" ; eat letters (and stop when we hit punctuation)
bcs -
bcc .store ; copy the ending punctuation and continue normal processing
.plursl
ldy tmp+1 ; erase singular form by backing up to prev punc
iny ; plus 1 to retain prev punc
bne .next ; resume regular copying of the plural form
.notsl
cmp #"A" ; if <= ASCII "A", consider it punctuation
bcc +
clv ; clear last-is-punc flag
bvc .store ; always taken
+ bit fixedRTS; set prev-is-punc flag
sty tmp+1 ; save dest offset of last punctuation
.store
sta inbuf,y ; save to dest
iny
bit fixedRTS; set prev-is-alpha flag
cmp #"A" ; if >= ASCII "A", consider it alpha
bcc .next
clv ; clear prev-is-alpha flag
.next
inx
cpx inbuf ; compare src offset to length
bcc .fetch ; loop while less than
beq .fetch ; or equal
.done
dey
sty inbuf ; save new length
lda #<inbuf ; return pointer to string
ldy #>inbuf
@ -744,28 +738,6 @@ export asm beep()#0
rts
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Read a string from the keyboard, turn it into a PLASMA string and return a pointer to the string.
export asm readStr()#1
+asmPlasmRet 0
bit setROM
jsr ROM_getln1
bit setLcRW+lcBank2
txa
pha
beq +
- lda inbuf-1,x
and #$7F
sta inbuf,x
dex
bne -
+ pla
sta inbuf,x
lda #<inbuf
ldy #>inbuf
rts
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Send a command to the memory manager
export asm mmgr(cmd, wordParam)#1
@ -1102,7 +1074,11 @@ end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Setter functions for library use
export def setPlural(flg)#0
isPlural = flg
if flg
isPlural = $40
else
isPlural = 0
fin
end
///////////////////////////////////////////////////////////////////////////////////////////////////
@ -1231,14 +1207,6 @@ export def parseDec(str)#1
return n
end
///////////////////////////////////////////////////////////////////////////////////////////////////
export def parseDecWithDefault(str, default)#1
if ^str == 0
return default
fin
return parseDec(str)
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Get a keystroke and convert it to upper case
export def getUpperKey()#1
@ -1389,10 +1357,6 @@ end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Set the sky color (relevant to 3D display only)
export def setSky(num)#0
// hack for end-game screen
if num == 99
finalWin()
fin
skyNum = num
setColor(0, skyNum)
needRender = TRUE
@ -2577,15 +2541,6 @@ def toggleGodMode()#1
return 0
end
///////////////////////////////////////////////////////////////////////////////////////////////////
export def finalWin()#0
flipToPage1()
loadFrameImg(4) // total hack
while 1 // 1 infinite loop
getUpperKey()
loop
end
///////////////////////////////////////////////////////////////////////////////////////////////////
export def setCmd(key, func)#0
cmdTbl[key] = func

View File

@ -24,6 +24,48 @@ predef _addItem(player)#1
predef _addPlayer()#1
word[] funcTbl = @_setCheatCmds, @_addItem, @_addPlayer
asm _defs
; Use hi-bit ASCII for Apple II
!convtab "../../include/hiBitAscii.ct"
; Headers
!source "../../include/global.i"
!source "../../include/plasma.i"
!source "../../include/mem.i"
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Read a string from the keyboard, turn it into a PLASMA string and return a pointer to the string.
asm readStr()#1
+asmPlasmRet 0
bit setROM
jsr ROM_getln1
bit setLcRW+lcBank2
txa
pha
beq +
- lda inbuf-1,x
and #$7F
sta inbuf,x
dex
bne -
+ pla
sta inbuf,x
lda #<inbuf
ldy #>inbuf
rts
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def parseDecWithDefault(str, default)#1
if ^str == 0
return default
fin
return parseDec(str)
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def splitScreenMode()#0
flipToPage1()
@ -150,7 +192,6 @@ def _setCheatCmds()#1
setCmd('Y', @nextSky)
setCmd('G', @nextGround)
setCmd('&', @printMem)
setCmd('_', @finalWin)
return 0
end