Adding global stat names to save space. Adjusted indenting of asm code in gameloop so Sublime Text correctly figures out the default tab size.

This commit is contained in:
Martin Haye 2016-07-07 14:22:48 -07:00
parent f37f3db60d
commit 2eff48233f
2 changed files with 407 additions and 378 deletions

View File

@ -8,10 +8,9 @@
// governing permissions and limitations under the License.
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
// Shared library routines
import gamelib
// Shared library routines
predef setScriptInfo, scriptDisplayStr, scriptDisplayStrNL, getYN, queue_setMap
predef setSky, setGround, queue_teleport, setPortrait, clearPortrait, moveWayBackward
predef getUpperKey, clearWindow, getGlobals, rand16, printf1, printf2, printf3
@ -25,4 +24,9 @@ import gamelib
predef addGold, countGold, payGold
predef calcPlayerArmor, diskActivity, rdkey, initHeap, scriptCombat
predef giveItemToPlayer, takeItemFromPlayer, playerHasItem, changePlayerStat
// Shared string constants
byte[] S_INTELLIGENCE, S_STRENGTH, S_AGILITY, S_STAMINA, S_CHARISMA, S_SPIRIT, S_LUCK
byte[] S_HEALTH, S_AIMING, S_HAND_TO_HAND, S_DODGING, S_GOLD
end

View File

@ -98,6 +98,20 @@ byte animNumFrames
byte animFrame
word animPauseCt
// Shared string constants
export byte[] S_INTELLIGENCE = "intelligence"
export byte[] S_STRENGTH = "strength"
export byte[] S_AGILITY = "agility"
export byte[] S_STAMINA = "stamina"
export byte[] S_CHARISMA = "charisma"
export byte[] S_SPIRIT = "spirit"
export byte[] S_LUCK = "luck"
export byte[] S_HEALTH = "health"
export byte[] S_AIMING = "aiming"
export byte[] S_HAND_TO_HAND = "hand-to-hand"
export byte[] S_DODGING = "dodging"
export byte[] S_GOLD = "gold"
///////////////////////////////////////////////////////////////////////////////////////////////////
// Definitions used by assembly code
asm _defs
@ -189,11 +203,6 @@ asm getMapScript // params: none
jmp $601E
end
///////////////////////////////////////////////////////////////////////////////////////////////////
asm setAuxCopy
rts
end
///////////////////////////////////////////////////////////////////////////////////////////////////
asm readAuxByte // params: ptr; ret: char
+asmPlasm 1
@ -259,7 +268,8 @@ export asm finishString
beq + ; only process if string has at least 1 char
bcs .done
+ sty tmp+1 ; offset of last punctuation
.fetch lda inbuf,x
.fetch
lda inbuf,x
cmp #"("
bne .notpar
bvs .notpar ; skip paren processing right punctuation
@ -272,7 +282,8 @@ export asm finishString
cpx inbuf
bne -
beq .done ; handle missing trailing paren
.plurpr inx ; it's plural, so copy everything within the parens
.plurpr
inx ; it's plural, so copy everything within the parens
lda inbuf,x ; copy characters
cpx inbuf ; handle missing trailing paren
beq .store
@ -282,7 +293,8 @@ export asm finishString
iny
bne .plurpr ; always taken
.notpar cmp #"/"
.notpar
cmp #"/"
bne .notsl
bvs .notsl ; skip slash processing right after punctuation
lda tmp ; check isPlural flag
@ -295,26 +307,31 @@ export asm finishString
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
.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
.notsl
cmp #"A" ; if <= ASCII "A", consider it punctuation
bcc +
clv ; clear last-is-punc flag
bvc .store ; always taken
+ bit monrts ; set prev-is-punc flag
sty tmp+1 ; save dest offset of last punctuation
.store sta inbuf,y ; save to dest
.store
sta inbuf,y ; save to dest
iny
.next inx
.next
inx
cpx inbuf ; compare src offset to length
bcc .fetch ; loop while less than
beq .fetch ; or equal
.done dey
.done
dey
sty inbuf ; save new length
lda #<inbuf
ldy #>inbuf
@ -372,7 +389,8 @@ asm blitPortrait // params: srcData, dstScreenPtr
; Outer copy loop
ldx #128 ; line count
.loop ldy #17 ; byte count minus 1. There are 18 bytes per line
.loop
ldy #17 ; byte count minus 1. There are 18 bytes per line
jsr $10 ; copy pixel bytes
; Advance to next row of data
@ -382,8 +400,7 @@ asm blitPortrait // params: srcData, dstScreenPtr
sta tmp
bcc +
inc tmp+1
+
; Fun code to advance to the next hi-res line
+ ; Fun code to advance to the next hi-res line
ldy pTmp+1
iny
iny
@ -402,13 +419,13 @@ asm blitPortrait // params: srcData, dstScreenPtr
bcc .ok
ldy #$20
adc #$27 ; carry was set, so actually adding $28
.ok sta pTmp
.ok2 sty pTmp+1
.ok
sta pTmp
.ok2
sty pTmp+1
; Loop until we've done all rows.
dex
bne .loop
rts
end
@ -509,7 +526,8 @@ asm partialPrintf
iny
dec tmp ; otherwise go until end of string
bne -
.eos ldy #$FF ; if we hit end of string, return -1
.eos
ldy #$FF ; if we hit end of string, return -1
tya
rts
+ dey ; adjust back for length byte
@ -622,7 +640,8 @@ export asm diskActivity
lda #0 ; last line
beq ++ ; always taken
+ lda (pTmp),y ; hide mode
++ sta (pTmp,x)
++
sta (pTmp,x)
lda pTmp+1
clc
adc #4
@ -2256,6 +2275,12 @@ export def playerHasItem(itemName)
end
export def changePlayerStat(statName, add)
when statName
is @S_STRENGTH
global=>p_players->b_strength = max(0, min(255, global=>p_players->b_strength + add))
otherwise
puts(statName); fatal("Unknown attr to incr/decr")
wend
end
///////////////////////////////////////////////////////////////////////////////////////////////////