From 6b3b0372fd78b19577a5808fb09abe991fe672fa Mon Sep 17 00:00:00 2001 From: Martin Haye Date: Thu, 5 Nov 2015 09:09:45 -0800 Subject: [PATCH] Now showing Hue's real data. --- Platform/Apple/virtual/src/font/fontEngine.s | 37 ++++++ .../Apple/virtual/src/include/fontEngine.i | 1 + .../Apple/virtual/src/plasma/gameloop.pla | 113 +++++++++++++++--- .../Apple/virtual/src/plasma/playtype.pla | 4 + 4 files changed, 136 insertions(+), 19 deletions(-) diff --git a/Platform/Apple/virtual/src/font/fontEngine.s b/Platform/Apple/virtual/src/font/fontEngine.s index 62dec60c..3dab4654 100644 --- a/Platform/Apple/virtual/src/font/fontEngine.s +++ b/Platform/Apple/virtual/src/font/fontEngine.s @@ -92,6 +92,10 @@ DisplayChar JMP DoPlAsc ;Display a string, with proper word wrapping DisplayStr JMP DoParse ; API call address +;Calculate width of a string without plotting it. +;Does not do line breaking +CalcWidth JMP DoCWdth + ;If you know which of the {0..110} bitmapped characters ;you want plotted, you can bypass testing for control ;codes, making this a faster way to plot. @@ -789,6 +793,39 @@ Pa_Dn4 LDY Pa_iSv ParsDn !if DEBUG { +prChr '<' : +crout : BIT $C053 } RTS ; +;Routine: Calculate width of string without plotting it +DoCWdth STA PrsAdrL + STY PrsAdrH + LDY #0 ;parse starting at beginning + STY TtlWdth + LDA (PrsAdrL),Y ;Get the length + STA Pa_Len + INY +Cw_Lp LDA (PrsAdrL),Y ;Get the character + STA AscChar + CPY Pa_Len ;reached end of string? + BCC Cw_Go + BEQ Cw_Go + LDA TtlWdth ;return width in A=lo/Y=hi + LDY #0 + RTS +Cw_Go ORA #$80 ;set hi bit for consistent tests + STA AscChar + STY Pa_iSv + LDX #1 + STX NoPlt_Flg ;set NO PLOT flag + JSR TestChr ;do plot routine to strip off Ctrl + LDX #0 ;codes & get char width + STX NoPlt_Flg ;clear NO PLOT flag + LDA ChrWdth + BEQ Cw_Tskp + SEC ;use SEC to always 'add 1' + ADC TtlWdth + STA TtlWdth +Cw_Tskp LDY Pa_iSv + INY + JMP Cw_Lp +; LinWdth !byte 112 ;max line width TtlWdth !byte $00 ;total word width Pa_iBgn !byte $00 ;parser indx begin diff --git a/Platform/Apple/virtual/src/include/fontEngine.i b/Platform/Apple/virtual/src/include/fontEngine.i index 73f3981e..669f57ad 100644 --- a/Platform/Apple/virtual/src/include/fontEngine.i +++ b/Platform/Apple/virtual/src/include/fontEngine.i @@ -20,3 +20,4 @@ ClearWindow = SetWindow+3 CopyWindow = ClearWindow+3 DisplayChar = CopyWindow+3 DisplayStr = DisplayChar+3 +CalcWidth = DisplayStr+3 diff --git a/Platform/Apple/virtual/src/plasma/gameloop.pla b/Platform/Apple/virtual/src/plasma/gameloop.pla index 79a8a8bb..4d450c14 100644 --- a/Platform/Apple/virtual/src/plasma/gameloop.pla +++ b/Platform/Apple/virtual/src/plasma/gameloop.pla @@ -72,6 +72,9 @@ const HEAP_COLLECT = $24 // Other constants const callbacks = $300 +const CHAR_WND_LIFE_X = 91 +const CHAR_WND_GUN_X = 114 + include "playtype.plh" //include "heaptest.plh" @@ -108,6 +111,10 @@ word q_x word q_y byte q_dir +// For decimal conversion and display tabbing +byte decimalBuf[7] +byte tabBuf[5] + /////////////////////////////////////////////////////////////////////////////////////////////////// // Definitions used by assembly code asm __defs @@ -594,6 +601,16 @@ asm displayStr jmp DisplayStr end +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Calculate string width using the font engine. +// Params: pStr +asm calcWidth + +asmPlasm 1 + bit setLcRW+lcBank2 + bit setLcRW+lcBank2 + jmp CalcWidth +end + /////////////////////////////////////////////////////////////////////////////////////////////////// // Display a string using the font engine but not its parser. // Params: pStr @@ -678,16 +695,20 @@ def fatal(msg) end /////////////////////////////////////////////////////////////////////////////////////////////////// -// Print a signed decimal word -def printDec(n) +// Convert signed decimal to string in decimalBuf +def convertDec(n) word n0 - if n < 0; printChar('-'); n = -n; fin + word p + p = @decimalBuf + 1 + if n < 0; ^p = '-'; p=p+1; n = -n; fin n0 = n - if n0 > 9999; printChar('0' + n/10000); n = n%10000; fin - if n0 > 999; printChar('0' + n/1000); n = n%1000; fin - if n0 > 99; printChar('0' + n/100); n = n%100; fin - if n0 > 9; printChar('0' + n/10); n = n%10; fin - printChar('0' + n) + if n0 > 9999; ^p = '0' + n/10000; p=p+1; n = n%10000; fin + if n0 > 999; ^p = '0' + n/1000; p=p+1; n = n%1000; fin + if n0 > 99; ^p = '0' + n/100; p=p+1; n = n%100; fin + if n0 > 9; ^p = '0' + n/10; p=p+1; n = n%10; fin + ^p = '0' + n; p=p+1 + decimalBuf[0] = p - @decimalBuf - 1 // record final length of string + return @decimalBuf end /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -708,7 +729,7 @@ def printf4(str, arg1, arg2, arg3, arg4) is 'c' printChar(*curArg); break is 'd' - printDec(*curArg); break + puts(convertDec(*curArg)); break is 's' puts(*curArg); break is 'x' @@ -837,14 +858,14 @@ end /////////////////////////////////////////////////////////////////////////////////////////////////// // Window for the large upper right bar def setWindow2() - setWindow(24, 136, 154, 266) + setWindow(24, 136, 154, 269) displayChar('N'-$40) // Set normal mode - clear all special modes end /////////////////////////////////////////////////////////////////////////////////////////////////// // Window for the mid-size lower right bar def setWindow3() - setWindow(144, 184, 154, 266) + setWindow(144, 184, 154, 269) end /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -858,13 +879,67 @@ def setMapWindow() end /////////////////////////////////////////////////////////////////////////////////////////////////// -// Show some faked-up data for player characters -def fakeChars() +def rightJustifyStr(str, rightX) + word x + x = rightX - calcWidth(str) + tabBuf[0] = 4 // length + tabBuf[1] = 20 // Ctrl-T + tabBuf[2] = (x / 100) + '0' + tabBuf[3] = ((x / 10) % 10) + '0' + tabBuf[4] = (x % 10) + '0' + rawDisplayStr(@tabBuf) + rawDisplayStr(str) +end + +/////////////////////////////////////////////////////////////////////////////////////////////////// +def rightJustifyNum(num, rightX) + rightJustifyStr(convertDec(num), rightX) +end + +/////////////////////////////////////////////////////////////////////////////////////////////////// +def displayPlayerData(player) + word pi + + // Display the player's name and health + printf1("player=$%x\n", player) + rawDisplayStr(player=>s_name) + puts("Going to show health\n") + rightJustifyNum(player=>w_health, CHAR_WND_LIFE_X) + + // Locate the first weapon, and display it's clip + puts("Going to show items\n") + pi = player=>p_items + while pi and pi->t_type <> TYPE_WEAPON; pi = pi=>p_nextObj; loop + if pi + rightJustifyNum(pi->b_clipCurrent, CHAR_WND_GUN_X) + else + rightJustifyStr("---", CHAR_WND_GUN_X) + fin + + // All done. + rawDisplayStr("\n") +end + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Display the party data on the screen +def showParty() + word p setWindow3() - rawDisplayStr("^LName^T065Life^T090Gun^L\n") - rawDisplayStr("Black Bart^T06512^T0904\n") - rawDisplayStr("Wyld Bill^T0658^T0902\n") - rawDisplayStr("Lucy Lawls^T0659^T0906") + + // Display header + rawDisplayStr("^LName") // begin underline mode + rightJustifyStr("Life", CHAR_WND_LIFE_X) + rightJustifyStr("Gun", CHAR_WND_GUN_X) + rawDisplayStr("^L\n") // end underline mode + + // Display each character + p = global=>p_players + while p + displayPlayerData(p) + p = p=>p_nextObj + loop + + // Finish up if mapIs3D; copyWindow(); fin setWindow2() end @@ -917,8 +992,8 @@ def initMap(x, y, dir) initDisplay(mapNum, pMap, x, y, dir) needRender = FALSE - // Display some fake character data. - fakeChars() + // Display the party characters + showParty() end /////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/Platform/Apple/virtual/src/plasma/playtype.pla b/Platform/Apple/virtual/src/plasma/playtype.pla index 0ef86aff..7a602250 100644 --- a/Platform/Apple/virtual/src/plasma/playtype.pla +++ b/Platform/Apple/virtual/src/plasma/playtype.pla @@ -64,6 +64,7 @@ def new_Weapon_Handgun // no modifiers, max uses, etc. for now p->b_ammoKind = KIND_BULLET p->b_clipSize = 6 + p->b_clipCurrent = p->b_clipSize p->r_meleeDmg = encodeDice(1, 6, 0) // 1d6 p->r_projectileDmg = encodeDice(1, 6, 0) // 1d6 p->ba_attacks[0] = 1 // single attack @@ -98,6 +99,9 @@ def new_Player_Hue_Hauser p->b_charisma = 7 p->b_spirit = 5 + p->w_maxHealth = 12 + p->w_health = 12 + // Basic skills p->b_aiming = 2 p->b_dodging = 3