mirror of
https://github.com/badvision/lawless-legends.git
synced 2025-02-20 21:29:13 +00:00
Fixed font engine's center mode for oversize window. Sped up center mode. Added more capabilities to store buy.
This commit is contained in:
parent
3f9377088b
commit
8b488e4e1b
@ -19,7 +19,7 @@
|
||||
;developed 5/2014. These routines have been tailored
|
||||
;for the Lawless Legends project.
|
||||
|
||||
;RevCursColHsion list:
|
||||
;Revision list:
|
||||
|
||||
;8/08 v.01 original concept w/self contained demo
|
||||
;9/29 v.05 8-bit BMP code for M, m, W, w
|
||||
@ -72,7 +72,7 @@
|
||||
;Ctrl-I n/a Inverse (swap foregnd/bkgnd colors)
|
||||
;Ctrl-Y n/a center justify
|
||||
|
||||
DEBUG = 0 ; 1=some logging, 2=lots of logging
|
||||
DEBUG = 0 ;1=some logging, 2=lots of logging
|
||||
|
||||
pTmp = $4 ;zero page Temporary variables
|
||||
T1_Val = $D
|
||||
@ -918,18 +918,11 @@ CtrJstfy CLC
|
||||
TAX ;Delta = WrdScrl - TtlScrl
|
||||
CLC
|
||||
ADC TtlScrl
|
||||
LDY Flg2px ;2-pixel shifting?
|
||||
BEQ CtrSTs ;if not, Save TtlScrl
|
||||
LSR ;else divide by 2
|
||||
ASL ;then x 2 (to make even #)
|
||||
CtrSTs STA TtlScrl ;Save TtlScrl
|
||||
STA TtlScrl ;Save TtlScrl
|
||||
TXA ;Get Delta
|
||||
CLC
|
||||
ADC LtrScrl
|
||||
LDY Flg2px ;2-pixel shifting?
|
||||
BEQ CtrSLps ;if not, Save LpNScrl
|
||||
LSR
|
||||
CtrSLps STA LpNScrl ;Save # of scroll loops
|
||||
STA LpNScrl ;Save # of scroll loops
|
||||
LDA CursColL ;get current column LoByte
|
||||
SEC ;(CLC is intentional, here)
|
||||
SBC LpNScrl ;bump it back
|
||||
@ -948,9 +941,8 @@ Tikr_Flg !byte 0 ;ticker flag
|
||||
NoBf_Flg !byte 0 ;no-buffer-use flag
|
||||
Sc1_Tkr RTS
|
||||
|
||||
;Routine: shift one line of text left by 2 pixels
|
||||
;Using a buffer of unshifted and preshifted pixel
|
||||
;bytes, this routine uses ASLs and ROLs to shift
|
||||
;Routine: shift one line of text left by 1 pixel.
|
||||
;This routine uses ASLs and ROLs to shift
|
||||
;8 consecutive lines
|
||||
Sc1_Bgn LDX #0
|
||||
STX Sc1LpC
|
||||
@ -967,59 +959,28 @@ Sc1_LpM JSR GetBase
|
||||
ADC LfMrgn
|
||||
STA GBasL
|
||||
|
||||
Sc1_LpS LDA GBasL
|
||||
STA Sc1_Ld2+1
|
||||
STA Sc1_St1+1
|
||||
ADC #1
|
||||
STA Sc1_Ld1+1
|
||||
LDA GBasH
|
||||
STA Sc1_Ld1+2
|
||||
STA Sc1_Ld2+2
|
||||
STA Sc1_St1+2
|
||||
Sc1_Lp0 LDY #0
|
||||
Sc1_Lp1 LDA (GBasL),Y ;get pixel byte
|
||||
STA Ary1,Y ;save unaltered pixels
|
||||
TAX
|
||||
AND #$80
|
||||
STA AryHB,Y ;save High (color) bit
|
||||
TXA
|
||||
ASL ;shift pixels right
|
||||
STA Ary2,Y ;save shifted pixels
|
||||
LDX MrgnVl
|
||||
Sc1_Ld1 LDA $1101,Y ;self-modified above
|
||||
LSR ;save low pixel of next byte
|
||||
Sc1_Ld2 LDA $1100,Y ;work on current byte (self-modified above)
|
||||
BCS + ;if next pix is set, just shift our hi bit (always set)
|
||||
AND #$7F ;else clr hi bit so it shifts down to hi pix
|
||||
SEC ;set new hi bit
|
||||
+ ROR ;shift in new pixel and hi bit
|
||||
Sc1_St1 STA $1100,Y ;save our work (self-modified above)
|
||||
INY
|
||||
CPY MrgnVl
|
||||
BNE Sc1_Lp1
|
||||
LDA #0
|
||||
STA Ary1,Y ;Clear buffer byte
|
||||
|
||||
LDX Flg2px
|
||||
BNE Sc1_2px
|
||||
|
||||
TAX
|
||||
TAY
|
||||
Sc1_LpS INX
|
||||
LDA Ary1,X ;Get unaltered pixels
|
||||
DEX
|
||||
LSR ;shift them left
|
||||
LDA Ary2,X ;get shifted pixels
|
||||
ROR ;roll them left
|
||||
LSR ;1-more left to get past high bit
|
||||
ORA AryHB,X ;put high bit back into byte
|
||||
STA (GBasL),Y ;plot on screen
|
||||
INY
|
||||
INX
|
||||
CPX MrgnVl
|
||||
BNE Sc1_LpS
|
||||
BEQ Sc1_Nxt
|
||||
|
||||
Sc1_2px TAX
|
||||
TAY
|
||||
Sc1_Lp2 INX
|
||||
LDA Ary1,X ;Get unaltered pixels
|
||||
DEX
|
||||
LSR ;shift them left
|
||||
ROR Ary2,X ;ROL them into right shifted pixels
|
||||
LSR ;shift them left again
|
||||
LDA Ary2,X ;get shifted pixels
|
||||
ROR ;roll them left
|
||||
LSR ;1-more left to get past high bit
|
||||
ORA AryHB,X ;put high bit back into byte
|
||||
STA (GBasL),Y ;plot on screen
|
||||
INY
|
||||
INX
|
||||
CPX MrgnVl
|
||||
BNE Sc1_Lp2
|
||||
|
||||
BNE Sc1_Ld1
|
||||
Sc1_Nxt INC Sc1LpC
|
||||
LDA Sc1LpC
|
||||
CMP #9
|
||||
@ -1032,20 +993,13 @@ Sc1_Nxt INC Sc1LpC
|
||||
;; CLC ;(line position is ABCDEFGH bit pattern)
|
||||
ADC #$04 ;increment the FGH bit pattern
|
||||
STA GBasH ;and save the result. This is faster
|
||||
JMP Sc1_Lp0 ;than using the GetBase routine every time.
|
||||
JMP Sc1_LpS ;than using the GetBase routine every time.
|
||||
Sc1_Dn PLA ;restore vertical position
|
||||
STA CursRow
|
||||
RTS
|
||||
|
||||
MrgnVl !byte 0 ;Margin Value
|
||||
Sc1LpC !byte 0 ;Loop count
|
||||
Flg2px !byte 0 ;Flag: shift two pixels (vs. one)
|
||||
Ary1 !fill 21,0 ;unshifted pixel bytes
|
||||
Ary2 !fill 21,0 ;shifted pixel bytes
|
||||
AryHB !fill 21,0 ;high bits
|
||||
|
||||
LdSvFlg !byte $00
|
||||
BmpBkp !fill 16,$0 ;Define Storage: 16 bytes preset to 0
|
||||
|
||||
;Routine: Get Char
|
||||
;Input a single character using flashing cursor.
|
||||
|
@ -11,27 +11,121 @@
|
||||
import gamelib
|
||||
|
||||
//////////// Shared library routines ////////////
|
||||
predef setScriptInfo, scriptDisplayStr, scriptDisplayStrNL, getYN, queue_setMap
|
||||
predef setSky, setGround, queue_teleport, setPortrait, clearPortrait, moveWayBackward
|
||||
predef flipToPage1, textHome, calcWidth, getPos, getDir, setMap, setCmd
|
||||
predef getUpperKey, clearWindow, rand16, printf1, printf2, printf3
|
||||
predef displayf1, displayf2, displayf3, buildString, addToString, finishString, printHex
|
||||
predef displayChar, rawDisplayStr, displayStr, rightJustifyStr, rightJustifyNum, puts
|
||||
predef min, max, randomFromListFiltered, randomFromArray, scanForNamedObj
|
||||
predef countList, countListFiltered, addToList, removeFromList
|
||||
predef beep, showParty, mmgr, auxMmgr, setWindow, setWindow1, setWindow2, setWindow3, reboot, brk
|
||||
predef encodeDice, rollDice, setPlural, getStringResponse
|
||||
predef streqi, strncpy, fatal, pause, tossStrings, charToUpper
|
||||
predef addEncounterZone, clearEncounterZones, showMapName, setMapWindow, getMapWindow
|
||||
predef addGold, countGold, payGold, scriptEvent
|
||||
predef calcPlayerArmor, rdkey, initHeap, scriptCombat, makeModifier
|
||||
predef giveItemToPlayer, takeItemFromPlayer, playerHasItem, getStat, setStat
|
||||
predef setGameFlag, getGameFlag, scriptSetAvatar, parseDecWithDefault, readStr
|
||||
predef addPlayerToParty, removePlayerFromParty, partyHasPlayer, loadFrameImg, loadMainFrameImg
|
||||
predef scriptSwapTile, setIntimateMode, fontCmd, setIntimateMode
|
||||
predef callGlobalFunc, getCharResponse, memcpy, checkEncounter, finalWin, addUnique
|
||||
predef benchPlayer, unbenchPlayer, buyFromStore, sellToStore, setOversizeWindow
|
||||
predef rawDisplayf1, rawDisplayf2, rawDisplayf3
|
||||
// Let's try to keep these predef's in lexical order
|
||||
predef addEncounterZone
|
||||
predef addGold
|
||||
predef addPlayerToParty
|
||||
predef addToList
|
||||
predef addToString
|
||||
predef addUnique
|
||||
predef auxMmgr
|
||||
predef beep
|
||||
predef benchPlayer
|
||||
predef brk
|
||||
predef buildString
|
||||
predef buyFromStore
|
||||
predef calcPlayerArmor
|
||||
predef calcWidth
|
||||
predef callGlobalFunc
|
||||
predef charToUpper
|
||||
predef checkEncounter
|
||||
predef clearEncounterZones
|
||||
predef clearPortrait
|
||||
predef clearWindow
|
||||
predef countArray
|
||||
predef countGold
|
||||
predef countList
|
||||
predef countListFiltered
|
||||
predef displayChar
|
||||
predef displayf1
|
||||
predef displayf2
|
||||
predef displayf3
|
||||
predef displayStr
|
||||
predef encodeDice
|
||||
predef fatal
|
||||
predef finalWin
|
||||
predef finishString
|
||||
predef flipToPage1
|
||||
predef fontCmd
|
||||
predef getCharResponse
|
||||
predef getDir
|
||||
predef getGameFlag
|
||||
predef getMapWindow
|
||||
predef getPos
|
||||
predef getStat
|
||||
predef getStringResponse
|
||||
predef getUpperKey
|
||||
predef getYN
|
||||
predef giveItemToPlayer
|
||||
predef initHeap
|
||||
predef loadFrameImg
|
||||
predef loadMainFrameImg
|
||||
predef makeModifier
|
||||
predef max
|
||||
predef memcpy
|
||||
predef min
|
||||
predef mmgr
|
||||
predef moveWayBackward
|
||||
predef parseDecWithDefault
|
||||
predef partyHasPlayer
|
||||
predef pause
|
||||
predef payGold
|
||||
predef playerHasItem
|
||||
predef printf1
|
||||
predef printf2
|
||||
predef printf3
|
||||
predef printHex
|
||||
predef puts
|
||||
predef queue_setMap
|
||||
predef queue_teleport
|
||||
predef rand16
|
||||
predef randomFromArray
|
||||
predef randomFromListFiltered
|
||||
predef rawDisplayf1
|
||||
predef rawDisplayf2
|
||||
predef rawDisplayf3
|
||||
predef rawDisplayStr
|
||||
predef rdkey
|
||||
predef readStr
|
||||
predef reboot
|
||||
predef removeFromList
|
||||
predef removePlayerFromParty
|
||||
predef rightJustifyNum
|
||||
predef rightJustifyStr
|
||||
predef rollDice
|
||||
predef scanForNamedObj
|
||||
predef scriptCombat
|
||||
predef scriptDisplayStr
|
||||
predef scriptDisplayStrNL
|
||||
predef scriptEvent
|
||||
predef scriptSetAvatar
|
||||
predef scriptSwapTile
|
||||
predef sellToStore
|
||||
predef setCmd
|
||||
predef setGameFlag
|
||||
predef setGround
|
||||
predef setIntimateMode
|
||||
predef setIntimateMode
|
||||
predef setMap
|
||||
predef setMapWindow
|
||||
predef setOversizeWindow
|
||||
predef setPlural
|
||||
predef setPortrait
|
||||
predef setScriptInfo
|
||||
predef setSky
|
||||
predef setStat
|
||||
predef setWindow
|
||||
predef setWindow1
|
||||
predef setWindow2
|
||||
predef setWindow3
|
||||
predef showMapName
|
||||
predef showParty
|
||||
predef streqi
|
||||
predef strncpy
|
||||
predef takeItemFromPlayer
|
||||
predef textHome
|
||||
predef tossStrings
|
||||
predef unbenchPlayer
|
||||
|
||||
// This pointer is the root of all heap-tracked (and garbage collected) objects.
|
||||
// See playtype.plh for definitions of all the datastructures and how they interconnect.
|
||||
|
@ -20,9 +20,7 @@ const fontDataLen = $4FA // really only $474, but we need to fill all gaps
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Other constants
|
||||
const CHAR_WND_GOLD_X = 83
|
||||
const CHAR_WND_WEAPON_X = 83
|
||||
const CHAR_WND_LIFE_X = 112
|
||||
const CHAR_WND_HEALTH_X = 66
|
||||
|
||||
const ANIM_PAUSE_MAX = 300
|
||||
|
||||
@ -1026,6 +1024,17 @@ def convertDec(n)
|
||||
return @decimalBuf
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Convert byte to 3-char string in decimalBuf, suitable for font engine, e.g. ^T065
|
||||
// (@decimalBuf returned)
|
||||
def convert3Dec(n)
|
||||
decimalBuf[0] = 3
|
||||
decimalBuf[1] = '0' + (n / 100); n = n%100
|
||||
decimalBuf[2] = '0' + (n / 10); n = n%10
|
||||
decimalBuf[3] = '0' + n
|
||||
return @decimalBuf
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Print a formatted string a'la C printf, with up to three parameters.
|
||||
export def printf3(str, arg1, arg2, arg3)
|
||||
@ -1041,15 +1050,17 @@ export def printf3(str, arg1, arg2, arg3)
|
||||
fin
|
||||
p = str + pos + 2
|
||||
when ^p
|
||||
is 'c'
|
||||
printChar(*curArg); break
|
||||
is 'd'
|
||||
is 'd' // %d = decimal
|
||||
puts(convertDec(*curArg)); break
|
||||
is 's'
|
||||
is 's' // %s = string
|
||||
puts(*curArg); break
|
||||
is 'x'
|
||||
is 'D' // %D = 3-char decimal suitable for font engine ctrl codes
|
||||
puts(convert3Dec(*curArg)); break
|
||||
is 'c' // %c = character
|
||||
printChar(*curArg); break
|
||||
is 'x' // %x = hex with '$'
|
||||
printHex(*curArg); break
|
||||
is '%'
|
||||
is '%' // %% = perfect
|
||||
printChar('%'); break
|
||||
otherwise
|
||||
printHex(^p); fatal("Unknown % code")
|
||||
@ -1365,22 +1376,15 @@ export def showParty()
|
||||
clearWindow()
|
||||
|
||||
// Display header
|
||||
rawDisplayStr("^LName^T066Health^L\n") // begin underline mode
|
||||
// rightJustifyStr("Health", CHAR_WND_LIFE_X)
|
||||
// rawDisplayStr("^L\n") // end underline mode
|
||||
rawDisplayf1("^LName^T%DHealth^L\n", CHAR_WND_HEALTH_X) // begin underline mode
|
||||
|
||||
// Display each character
|
||||
// Display each character's name and health
|
||||
p = global=>p_players
|
||||
while p
|
||||
// Display the player's name and health
|
||||
if p <> global=>p_players; displayChar('\n'); fin
|
||||
displayStr(p=>s_name)
|
||||
rawDisplayStr("^T066")
|
||||
displayStr(convertDec(p=>w_health))
|
||||
displayChar('/')
|
||||
displayStr(convertDec(p=>w_maxHealth))
|
||||
rawDisplayf3("^T%D%d/%d", CHAR_WND_HEALTH_X, p=>w_health, p=>w_maxHealth)
|
||||
p = p=>p_nextObj
|
||||
// Newline after data, except last character
|
||||
if p; displayChar('\n'); fin
|
||||
loop
|
||||
|
||||
// Finish up
|
||||
@ -2020,6 +2024,16 @@ export def countListFiltered(p, offset, filterFunc)
|
||||
return n
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Find the end of a null-terminated array
|
||||
export def countArray(arr)
|
||||
byte count
|
||||
for count = 0 to 127
|
||||
if !*arr; return count; fin
|
||||
arr = arr + 2
|
||||
next
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
export def randomFromListFiltered(p, offset, filterFunc)
|
||||
byte n
|
||||
|
@ -14,7 +14,7 @@ include "globalDefs.plh"
|
||||
include "gen_modules.plh"
|
||||
include "gen_items.plh"
|
||||
|
||||
const PAGE_SIZE = 14 // (183-10)/9 - 5
|
||||
const PAGE_SIZE = 14 // (183-10)/9 lines, minus 5 lines for header/footer
|
||||
|
||||
// Exported functions go here. First a predef for each one, then a table with function pointers
|
||||
// in the same order as the constants are defined in the header.
|
||||
@ -114,17 +114,24 @@ end
|
||||
def displayBuyTitle(pageNum, nPages)
|
||||
clearWindow()
|
||||
// Can't use centering mode on oversize window - font engine can't handle width > 255
|
||||
rawDisplayStr("^YBuying")
|
||||
if (nPages > 0)
|
||||
rawDisplayf2("^T073Buying (page %d of %d)", pageNum+1, nPages)
|
||||
else
|
||||
rawDisplayStr("^T108Buying")
|
||||
rawDisplayf2(" - pg %d/%d", pageNum+1, nPages)
|
||||
fin
|
||||
rawDisplayStr("\n\n^LSel^T025Price^T060Item^L")
|
||||
rawDisplayStr("^N\n\n^LSel^T025Price^T060Item^L")
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
def displayBuyLine(num, price, name)
|
||||
rawDisplayf3("\n%c.^T025%d^T060%s", num + 'A', price, name)
|
||||
def displayItemName(pItem)
|
||||
setPlural(FALSE)
|
||||
if pItem->t_type == TYPE_STUFF; setPlural(TRUE); fin
|
||||
rawDisplayf1("%s", pItem=>s_name) // use displayf to get proper plural processing
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
def displayBuyLine(num)
|
||||
rawDisplayf2("\n%c.^T025%d^T060", num + 'A', pagePrices[num])
|
||||
displayItemName(pageItems[num])
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -141,9 +148,7 @@ def displayBuyPage(pItemTbl, markupRatio, pageNum, nPages)
|
||||
pItem = (*pFunc)()
|
||||
pageItems[itemNum] = pItem
|
||||
pagePrices[itemNum] = max(1, pItem=>w_price + calcMarkup(pItem=>w_price, markupRatio))
|
||||
setPlural(FALSE)
|
||||
if pItem->t_type == TYPE_STUFF; setPlural(TRUE); fin
|
||||
displayBuyLine(itemNum, pagePrices[itemNum], pItem=>s_name)
|
||||
displayBuyLine(itemNum)
|
||||
pFunc = pFunc + 2
|
||||
next
|
||||
|
||||
@ -156,12 +161,16 @@ def displayBuyPage(pItemTbl, markupRatio, pageNum, nPages)
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
def countArray(arr)
|
||||
byte count
|
||||
for count = 0 to 127
|
||||
if !*arr; return count; fin
|
||||
arr = arr + 2
|
||||
next
|
||||
def browseItem(num)
|
||||
word pItem, price
|
||||
pItem = pageItems[num]
|
||||
price = pagePrices[num]
|
||||
|
||||
clearWindow()
|
||||
rawDisplayStr("^T108Browse\n\nItem:^T040")
|
||||
displayItemName(pItem)
|
||||
rawDisplayf1("\nPrice:^T040%d", price)
|
||||
getUpperKey()
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -187,8 +196,7 @@ def _buyFromStore(storeCode, markupRatio)
|
||||
if choice >= '1' and (choice-'1') < nPages
|
||||
pageNum = choice - '1'
|
||||
elsif choice >= 'A' and (choice-'A' < nItemsOnPage)
|
||||
rawDisplayf1("\nTODO: browse it, maybe buy\n")
|
||||
getUpperKey()
|
||||
browseItem(choice-'A')
|
||||
elsif choice == $1B // Esc
|
||||
break
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user