Progress on intimate mode - text display now mostly working.

This commit is contained in:
Martin Haye 2016-11-08 08:39:18 -08:00
parent e6bcc747bd
commit 0313db8d1a
5 changed files with 87 additions and 71 deletions

View File

@ -1632,6 +1632,7 @@ class A2PackPartitions
compileModule("combat", "src/plasma/")
compileModule("party", "src/plasma/")
compileModule("diskops", "src/plasma/")
compileModule("intimate", "src/plasma/")
compileModule("gen_globalScripts", "src/plasma/")
compileModule("gen_enemies", "src/plasma/")
compileModule("gen_items", "src/plasma/")
@ -3119,7 +3120,7 @@ end
{
def num = getSingle(blk.field, 'NUM').text()
assert num.toFloat() > 0
def factor = 500 // approx counts per second
def factor = 1200 // approx counts per second
def time = (int)(num.toFloat() * factor)
if (time > 32767)
time = 32767

View File

@ -1,11 +1,11 @@
;@com.wudsn.ide.asm.hardware=APPLE2
;****************************************************************************************
; Copyright (C) 2015 The 8-Bit Bunch. Licensed under the Apache License, Version 1.1
; Copyright (C) 2015 The 8-Bit Bunch. Licensed under the Apache License, Version 1.1
; (the "License"); you may not use this file except in compliance with the License.
; You may obtain a copy of the License at <http://www.apache.org/licenses/LICENSE-1.1>.
; Unless required by applicable law or agreed to in writing, software distributed under
; the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
; ANY KIND, either express or implied. See the License for the specific language
; Unless required by applicable law or agreed to in writing, software distributed under
; the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
; ANY KIND, either express or implied. See the License for the specific language
; governing permissions and limitations under the License.
;****************************************************************************************
@ -16,7 +16,7 @@
;borrow heavily from code developed 3/2014 used to plot
;2240 digits of pi on HGR screen using 3x5 pixel font.
;And, proportional font plottong app for Dbl-Lo-Res
;developed 5/2014. These routines have been tailored
;developed 5/2014. These routines have been tailored
;for the Lawless Legends project.
;RevCursColHsion list:
@ -78,7 +78,7 @@ Kbd_Clr = $C010 ;clear keyboard strobe
SetFont JMP DoSetFont ;API call address
;Set the window boundaries (byte-oriented bounds)
SetWindow JMP SetWnd ;API call address
SetWindow JMP SetWnd ;API call address
;Clear the window
ClearWindow JMP ClrHome ;API call address
@ -108,7 +108,7 @@ RestCursor JMP RsCurs
GetStr JMP In_Str
;If you know which of the {0..110} bitmapped characters
;you want plotted, you can bypass testing for control
;you want plotted, you can bypass testing for control
;codes, making this a faster way to plot.
PlotBmp JMP PlotFnt ;API call address
@ -132,7 +132,7 @@ UndTx_Flg !byte 0 ;flag: Underline text
CtrJs_Flg !byte 0 ;flag: center justify
BkgColor !byte 0 ;color byte {0,80=blk,FF=wht,etc}
FrgColor !byte $7F ;color byte
CursColL !byte 0 ;Lo-byte of 16-bit horz X-pos value
CursColL !byte 0 ;Lo-byte of 16-bit horz X-pos value
CursColH !byte 0 ;Hi-byte X-position {0..279}
CursRow !byte 0 ;vertical Y-position {0..191}
ChrWdth !byte 0 ;character width (number of pixels)
@ -144,9 +144,9 @@ DoSetFont STA Font0
STY Font0+1
RTS
;This routine converts (x,y) {0..279,0..191} to HGR address
;This routine converts (x,y) {0..279,0..191} to HGR address
;{$2000..$3FFF} and an offset bit (for the pixel within the
;byte) using a lookup table and integer division.
;byte) using a lookup table and integer division.
;Then, it loops and stores the HGR addresses (2-byte) for
;9 consecutive lines in an array.
;For HPplot (x,y) y={0..191} represented by bits y=ABCDEFGH
@ -170,7 +170,7 @@ GA_Lp2 LDY zTmp3 ;Get index into stored addresses
ADC HgrHrz ;add the horizontal position offset byte
STA GA_Ary,Y ;store the composite address in the array
INY
LDA GBasH ;load the hi-byte of HGR address; store
LDA GBasH ;load the hi-byte of HGR address; store
STA GA_Ary,Y ;that also (each array element is 2-bytes)
INY
STY zTmp3 ;save the index value of the array
@ -187,7 +187,7 @@ GA_Lp2 LDY zTmp3 ;Get index into stored addresses
STA GBasH ;and save the result. This is faster
BNE GA_Lp2 ;than using the GetBase routine every time.
GA_Done PLA ;restore vertical position
STA CursRow
STA CursRow
RTS
GetBase LDX CursRow ;Look-up the base HGR memory location
GetBasX LDA HgrTbHi,X ;(ie. the mem address of the left edge
@ -214,9 +214,9 @@ D16x8L3 ROL HgrHrz ;8-bit quotient (offset byte)
RTS
H_Bit !byte 0 ;offset bit - pixels {0..7}
GA_Ary !fill 18,$0 ;Define Storage: 16 bytes preset to 0
;
;
;This routine plots the bitmap patters on the HGR screen
;using indirect addressing based on the array of 2-byte
;using indirect addressing based on the array of 2-byte
;address words generated by the prior code.
ChrX10L !byte $00 ;char val x9 offset into bitmap table
@ -242,14 +242,14 @@ GetWdth LDA #0
TAY
STA ChrX10H ;clear HI byte of x10 multiplier
LDA PltChar ;load the font char {0..110}
ASL
ASL
STA ChrX10L ;multiply it by 10 to get an index value
ASL ;into the array of bytes that make-up the
ROL ChrX10H ;1-byte (wide) by 10-byte (long) block of
ASL
ROL ChrX10H
ADC ChrX10L
STA ChrX10L
ADC ChrX10L
STA ChrX10L
BCC +
INC ChrX10H ;save index value {0..990}
+
@ -258,7 +258,7 @@ GetWdth LDA #0
ADC ChrX10L ;and add the PlotChar x10 offset to it
STA L_Adr
LDA Font0+1
ADC ChrX10H
ADC ChrX10H
STA H_Adr
STY MlpIdx ;clear Main Loop index
@ -336,7 +336,7 @@ No8Ulin LDX H_Bit
BNE No8th ;H_Bit (offset) is max
STX Flg8xcp ;then set 8 pixel exception flag
No8th LDX H_Bit ;get pixel offset {0..7}
No8th LDX H_Bit ;get pixel offset {0..7}
BEQ NoAdj ;if 0, bitmap in array needs no adjustmt
LDA zTmp3 ;get the pixel pattern to be shifted
; because HGR doesn't display 8th bit
@ -432,14 +432,14 @@ NoBchrP LDA (zTmp1),Y ;get HGR pixels
BNE DoAgnNM ;go plot the 2nd half of the pixel pattern
SkpLine INX ;increment the array index
STX MlpIdx
STX MlpIdx
CPX #$12 ;if > 18 then we're done
BEQ DonePlot
LDY ChrX10i ;else get the index into the bitmap array
INY ;advanc indx to nxt pixl pattern in array
JMP LpPlot ;loop thru all 9 pixl patrns in the bitmap
DonePlot
LDX CtrJs_Flg
LDX CtrJs_Flg
BEQ MvCurs
JSR CtrJstfy
MvCurs JMP AdvCurs
@ -454,7 +454,7 @@ MskTblC !byte $01 ;Mask Table for Chars
!byte $FF
;This section advances the character cursor to the right n pixels.
;If the cursor gets to the right side of the screen then it
;If the cursor gets to the right side of the screen then it
;returns to the left, 0, and advances, vertically, 9 lines.
CursY !byte 24 ;Cursor home position - Y vert
@ -472,7 +472,7 @@ AdvCurs LDA CursColL ;get lo-byte of {0..279}
LDA CursColH ;get hi-byte of {0..279}
ADC #0
STA CursColH
CMP CursXrh ;if pixel position {0..255}
CMP CursXrh ;if pixel position {0..255}
BMI DoneCurs ;then done
LDA CursColL ;else check if past 263
CMP CursXrl
@ -517,7 +517,7 @@ WtL_Prs LDA #0 ; if wait interrupted then do
RTS
;Routine: Save the cursor position. There is exactly one save slot.
BCursColL !byte 0 ;Saved Lo-byte of 16-bit horz X-pos value
BCursColL !byte 0 ;Saved Lo-byte of 16-bit horz X-pos value
BCursColH !byte 0 ;Saved Hi-byte X-position {0..279}
BCursRow !byte 0 ;Saved vertical Y-position {0..191}
SvCurs LDA CursColL
@ -594,7 +594,7 @@ SetWnd LDA evalStkL+SW_TOP,X ;get top coord
RTS
;Routine: Scroll screen up 1 character line
;This routine scrolls a window defined by
;This routine scrolls a window defined by
;Left, Right, Top, Bottom - Margin parameters.
;It scrolls using by moving bytes (so scrolling
;only works along 7-pixel boundaries of HGR).
@ -605,7 +605,7 @@ LfMrgn !byte 22 ;left margin (byte #)
RtMrgn !byte 38 ;right margin (byte #)
TpMrgn !byte 23 ;top margin (v-line)
BtMrgn !byte 135 ;bottom margin (v-line)
ScrlTxt LDX TpMrgn
ScrlTxt LDX TpMrgn
STX zTmp3 ;Duplicate top margin val in zero-pg
ScrLp1 LDX zTmp3
INX ;go thru each line 1 by 1
@ -644,7 +644,7 @@ ClrFlpF !byte 0
ClrHome LDA CursXl ;home the cursor
STA CursColL ;{0..279} lo byte
LDA CursXh
STA CursColH ;{0..279} hi byte
STA CursColH ;{0..279} hi byte
LDA CursY
STA CursRow ;{0..191}
JSR ClrChkF ;check if B/W or Color
@ -673,7 +673,7 @@ ClrColr LDA BkgColor
AND #1
BEQ ClrSlp3
TYA
STA ClrFlip
STA ClrFlip
ClrSlp3 JSR GetBasX ;to get the base address
LDY LfMrgn
LDA ClrFlip
@ -727,7 +727,7 @@ DoParse STA PrsAdrL
LDA (PrsAdrL),Y ;Get the length
STA Pa_Len
INY
Pa_Lp0 STY Pa_iBgn
Pa_Lp0 STY Pa_iBgn
Pa_Lp1 STY Pa_iSv
LDA (PrsAdrL),Y ;Get the character
STA AscChar
@ -764,7 +764,7 @@ Pa_ToFr !if DEBUG { +prChr '+' }
;BEQ Pa_Spc ; then split the word
LDA #$8D
STA AscChar
!if DEBUG { +prChr '!' : ora #$80 : jsr cout }
!if DEBUG { +prChr '!' : ora #$80 : +safeCout }
JSR TestChr
LDY Pa_iBgn
LDA #0
@ -779,7 +779,7 @@ Pa_Spc LDY Pa_iSv
Pa_Lp2 STY Pa_iSv
LDA (PrsAdrL),Y ;Get the character
STA AscChar ;**add code
!if DEBUG { ora #$80 : jsr cout }
!if DEBUG { ora #$80 : +safeCout }
JSR TestChr ;if space & at left then don't plot
LDY Pa_iSv
INY
@ -796,8 +796,8 @@ Pa_Dn2b LDA TtlWdth
CMP #$8D
BEQ Pa_Dn3
STA AscChar
!if DEBUG { +prChr '>' : ora #$80 : jsr cout }
JSR TestChr
!if DEBUG { +prChr '>' : ora #$80 : +safeCout }
JSR TestChr
JMP Pa_Dn4
Pa_Dn3 LDY Pa_iSv
INY
@ -850,8 +850,8 @@ Pa_iSv !byte $00 ;Save Msg Y index
Pa_Len !byte $00 ;length of string
;Center Justify
;Start with the cursor in the center column,
;Get width of letter to be plotted, use ticker scrolling
;Start with the cursor in the center column,
;Get width of letter to be plotted, use ticker scrolling
;to shift the line half the char width prior to plotting it.
WrdWdth !byte 0 ;sum of char widths
WrdScrl !byte 0 ;half of word width
@ -865,7 +865,7 @@ CtrJstfy CLC
STA WrdWdth ;WrdWdth = WrdWdth + ChrWdth
TAX
LDA ChrWdth
LSR
LSR
STA LtrScrl ;LtrScrl = ChrWdth / 2
CLC
LDA TtlScrl
@ -887,7 +887,7 @@ CtrSTs STA TtlScrl ;Save TtlScrl
TXA ;Get Delta
CLC
ADC LtrScrl
LDY Flg2px ;2-pixel shifting?
LDY Flg2px ;2-pixel shifting?
BEQ CtrSLps ;if not, Save LpNScrl
LSR
CtrSLps STA LpNScrl ;Save # of scroll loops
@ -911,17 +911,17 @@ 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
;bytes, this routine uses ASLs and ROLs to shift
;8 consecutive lines
Sc1_Bgn LDX #0
STX Sc1LpC
LDA CursRow
LDA CursRow
PHA
SEC
LDA RtMrgn
SBC LfMrgn
STA MrgnVl
;
;
Sc1_LpM JSR GetBase
CLC
LDA GBasL
@ -995,7 +995,7 @@ Sc1_Nxt INC Sc1LpC
STA GBasH ;and save the result. This is faster
JMP Sc1_Lp0 ;than using the GetBase routine every time.
Sc1_Dn PLA ;restore vertical position
STA CursRow
STA CursRow
RTS
MrgnVl !byte 0 ;Margin Value
@ -1010,7 +1010,7 @@ BmpBkp !fill 16,$0 ;Define Storage: 16 bytes preset to 0
;Routine: Get Char
;Input a single character using flashing cursor.
;Control characters are captured except for
;Control characters are captured except for
;Ctrl-E which is used to enter extended chars.
Get_Chr LDA #0 ;clear
STA InBfrX ;index into input buffer
@ -1043,7 +1043,7 @@ Get_Wdt LDX #1
STX NoPlt_Flg
Get_tYN LDX GetYN_Flg ;test for Y/N
BEQ Get_Dn ;if no test, then done
LDA AscChar
LDA AscChar
AND #$5F ;force upper case
ORA #$80 ;force hi-bit
CMP #'Y'
@ -1078,7 +1078,7 @@ SndLp1 SBC #$01 ;Subtract from Acc with carry
;Routine: Input string (simple, one-line)
;Input a line of characters keeping track of cursor
;positions by way of character widths, allowing use
;of delete key; ignore control keys except Escape,
;of delete key; ignore control keys except Escape,
;Return, and Delete; treat left arrow like Delete.
;The ASCII string is stored in the input buffer at
;$200 followed by $00 delimiter & the length of the
@ -1098,7 +1098,7 @@ In_Key JSR CurPlot ;start with cursor initially displaying
BEQ In_cTst ;if none then test ctrl chars
JSR In_eChP ;else, get extended char
JMP In_Plt
In_cTst CMP #$85
In_cTst CMP #$85
BNE In_cTs3 ;Ctrl-E (extended char)
LDA #3 ;set wait state for extended char
STA WaitStat
@ -1143,7 +1143,7 @@ In_Plt LDX #1
BMI In_Bchk ;wait for different key press
LDA CursColL ;allow 2 more pixels for cursor
ADC #1
CMP CursXrl
CMP CursXrl
BPL In_Err
In_Bchk LDX InBfrMx
CPX InBfrX ;check for buffer overflow
@ -1161,7 +1161,7 @@ In_Bfr LDX InBfrX
LDX #0
STX ChBflip ;reset cursor sequence
JMP CurBplt ;erase cursor
In_SvCh JSR In_Bfr
In_SvCh JSR In_Bfr
LDA NwPChar ;restore new plot char
STA PltChar
JSR PlotFnt ;plot it
@ -1258,17 +1258,17 @@ TestChr LDX #0
JMP PlotFnt ;else done
WaitPrm JMP GetParm
;This section tests for control characters.
;This section tests for control characters.
;The following control-codes are used. Those that
;require a paramter to follow will set a wait state
;CODE__STATE__DESCRIPTION___
;Ctrl-A (1) foreground/character color (not implemented)
;Ctrl-B (2) background color
;Ctrl-E (3) extended character {A..I}
;Ctrl-A (1) foreground/character color
;Ctrl-B (2) background color
;Ctrl-E (3) extended character {A..I}
;Ctrl-F (4) font {0,1,2} (not implemented)
;Ctrl-T (5) horizonTal position {000..279} base-10
;Ctrl-V (6) vertical position {000..191}
;Ctrl-R (7) character/ticker rate {00..FF} (not used)
;Ctrl-R (7) character/ticker rate {00..FF}
;Ctrl-L n/a toggle underLine mode
;Ctrl-M n/a Carriage return w/line feed
;Ctrl-N n/a Normal mode (un-toggle special modes)
@ -1281,7 +1281,7 @@ WaitPrm JMP GetParm
;Ctrl-J n/a (down arrow) move +1 row
;Ctrl-K n/a (up arrow) move -1 row
;Ctrl-I n/a Inverse (swap foregnd/bkgnd colors)
;Ctrl-Y n/a center justify
;Ctrl-Y n/a center justify
TestCtl TXA ;restore character
CMP #$0D ;Ctrl-M?
BNE TCl_01 ;no - keep testing
@ -1473,26 +1473,26 @@ Wp_Dig3 !byte $00 ;3rd digit of parameter
GetParm LDA WaitStat ;Get the Wait State
CMP #1 ;1=Foreground color
BNE WPr_01 ;no - keep looking
LDA #0 ;yes -
LDA #0 ;yes -
STA Flg_FBc ;clear Fore/Bkgnd clr flag
JMP Wp_StClr ;set color
WPr_01 CMP #2 ;2=Background color
BNE Wpr_02
LDA #1 ;yes -
LDA #1 ;yes -
STA Flg_FBc ;set Fore/Bkgnd clr flag
JMP Wp_StClr
Wpr_02 CMP #3 ;3=Special Character
BNE Wpr_03
JMP Wp_eChar
JMP Wp_eChar
Wpr_03 CMP #4 ;4=Change Font
BNE Wpr_04
JMP Wp_CFnt
JMP Wp_CFnt
Wpr_04 CMP #5 ;5=HTAB
BNE Wpr_05
JMP Wp_Tab
JMP Wp_Tab
Wpr_05 CMP #6 ;6=VTAB
BNE Wpr_06
JMP Wp_Tab
JMP Wp_Tab
Wpr_06 CMP #7 ;7=Change Char/Ticker Rate
BNE Wpr_Clr
JMP Wp_cRate
@ -1500,7 +1500,7 @@ Wpr_06 CMP #7 ;7=Change Char/Ticker Rate
Wpr_Clr LDX #0 ;clear the wait parameter flags
STX Flg_Prm2
STX Wp_Dig1
STX WaitStat
STX WaitStat
RTS ;restore alpha char
;Chage Color
@ -1641,12 +1641,12 @@ Wp_CfHtVt STA Flg_PsC ;set Plot Separator flag
BNE Wp_VtVal ;no - then go do vTab
LDA T1_vLo ;yes - then hTab
;
CLC ;hTAB: get param add it to
CLC ;hTAB: get param add it to
ADC CursXl ;left window margin {0..278}
STA CursColL ;move plot cursor from the
LDA T1_vHi ;left margin to the tab value
ADC CursXh
STA CursColH
STA CursColH
SEC ;Check to make sure the tab
LDA CursXrl ;didn't put the plot cursor
SBC #1 ;beyond the right margin.
@ -1660,7 +1660,7 @@ Wp_CfHtVt STA Flg_PsC ;set Plot Separator flag
STA CursColH
JMP Wp_TbOk
;
Wp_VtVal LDA T1_vLo ;vTAB: get param & add it to
Wp_VtVal LDA T1_vLo ;vTAB: get param & add it to
CLC ;botm window margin {0..190}
ADC CursY ;Move plot cursor from the
STA CursRow ;top margin to the tab value

View File

@ -13,7 +13,7 @@ import gamelib
//////////// Shared library routines ////////////
predef setScriptInfo, scriptDisplayStr, scriptDisplayStrNL, getYN, queue_setMap
predef setSky, setGround, queue_teleport, setPortrait, clearPortrait, moveWayBackward
predef flipToPage1, textHome
predef flipToPage1, textHome, calcWidth
predef getUpperKey, clearWindow, getGlobals, rand16, printf1, printf2, printf3
predef displayf1, displayf2, displayf3, buildString, addToString, finishString, printHex
predef displayChar, rawDisplayStr, displayStr, rightJustifyStr, rightJustifyNum, puts

View File

@ -742,7 +742,7 @@ end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Calculate string width using the font engine.
// Params: pStr
asm calcWidth
export asm calcWidth
+asmPlasm_bank2 1
jmp CalcWidth
end
@ -1025,6 +1025,7 @@ end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Pause for a specified count period, advancing the animation periodically.
export def pause(count)
printf1("pause %d\n", count)
while count >= 0
animPauseCt = animPauseCt - 1
if animPauseCt < 0
@ -1767,7 +1768,7 @@ def nextAnimFrame()
animDirCt = (rand16() % 5) + 3
fin
// Advance animations.
// Advance animations.
// First part is whether to switch directions on fwd/back anims.
// Second part is how many frames to advance random anims.
flags = auxMmgr(ADVANCE_ANIMS, ((animDirCt==1) & 1) | (((rand16() % 10)+1)<<8))
@ -2519,7 +2520,7 @@ end
///////////////////////////////////////////////////////////////////////////////////////////////////
export def setIntimateMode(enable)
if enable
pIntimate = loadEngine(MODULE_PARTY)
pIntimate = loadEngine(MODULE_INTIMATE)
pIntimate=>intimate_setMode(enable)
else
pIntimate=>intimate_setMode(enable)

View File

@ -21,6 +21,7 @@ word global
predef _intimate_setMode, _intimate_displayStr, _intimate_swipeImg
word[] funcTbl = @_intimate_setMode, @_intimate_displayStr, @_intimate_swipeImg
byte spaceWidth
///////////////////////////////////////////////////////////////////////////////////////////////////
// Definitions used by assembly code
@ -89,19 +90,32 @@ def _intimate_setMode(enable)
displayChar('N'-$40) // Set normal mode - clear all special modes (like underline, etc.)
setWindow(0, 192, 0, 280) // Top, Bottom, Left, Right
clearWindow()
rawDisplayStr("\$1270") // Set character rate to somewhat slow
spaceWidth = calcWidth(" ") // used to calc # of spaces to erase with
else
loadMainFrameImg()
fontCmd(18, 0) // 18 = ctrl-R = ticker rate. 0=fastest
rawDisplayStr("\$1200") // Set character rate - 0=fastest
fin
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Display string on a blank screen, with blanking follow-up
def _intimate_displayStr(str)
word width, i
fontCmd(20, 0) // 20 = ctrl-T = horizontal position
fontCmd(22, 50) // 22 = ctrl-V = vertical position
fontCmd(18, 20) // 18 = ctrl-R = ticker rate
displayStr(str)
width = calcWidth(str)
rawDisplayStr(str)
fontCmd(20, 0) // 20 = ctrl-T = horizontal position
fontCmd(22, 50) // 22 = ctrl-V = vertical position
rawDisplayStr("\$014") // ctrl-A = foreground color, 4=hi-bit-black
for i = (width+spaceWidth-1)/spaceWidth downto 0
displayChar(' ')
next
rawDisplayStr("\$017") // ctrl-A = foreground color, 7=hi-bit-white
end
def _intimate_swipeImg() // FIXME
end
///////////////////////////////////////////////////////////////////////////////////////////////////