mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-10-05 03:57:52 +00:00
Working on code to set font window boundaries. Also ported Andrew's word-break parser.
This commit is contained in:
parent
9991cc1dc4
commit
0077d9ea05
@ -36,6 +36,7 @@
|
||||
; Global definitions
|
||||
!source "../include/global.i"
|
||||
!source "../include/mem.i"
|
||||
!source "../include/plasma.i"
|
||||
|
||||
DEBUG = 0 ; 1=some logging, 2=lots of logging
|
||||
|
||||
@ -48,6 +49,9 @@ H_Adr = $15 ;for general indrct adrs indexing
|
||||
MskBytL = $16 ;Mask byte 1st
|
||||
MskBytH = $17 ;Mask byte 2nd
|
||||
MskByte = $18 ;Mask byte
|
||||
unused19 = $19
|
||||
PrsAdrL = $1A ;pointer for string parsing (lo)
|
||||
PrsAdrH = $1B ; (hi)
|
||||
GBasL = $26 ;LoByte HGR mem pg base adr EABABxxx
|
||||
GBasH = $27 ;HiByte PPPFGHCD for Y=ABCDEFGH P=page
|
||||
|
||||
@ -57,17 +61,23 @@ InBufrX = $2FF ;Input Buffer index (length)
|
||||
Kbd_Rd = $C000 ;read keyboard
|
||||
Kbd_Clr = $C010 ;clear keyboard strobe
|
||||
|
||||
;Initialize the font engine. Address of font in X=lo/Y=hi.
|
||||
Init JMP DoInit ;API call address
|
||||
;Set the address of the font
|
||||
SetFont JMP SetFont ;API call address
|
||||
|
||||
;Set the window boundaries (byte-oriented bounds)
|
||||
SetWindow JMP SetWnd ;API call address
|
||||
|
||||
;Clear the window
|
||||
ClearWindow JMP ClrHome ;API call address
|
||||
|
||||
;Display a string, with proper word wrapping
|
||||
DisplayStr JMP DoParse ; API call address
|
||||
|
||||
;When using ASCii character values, the values must be
|
||||
;tested for control codes before they can be plotted
|
||||
;using the plot character routine.
|
||||
PlotAsc JMP TestChr ;API call address
|
||||
|
||||
; Clear the window
|
||||
ClearWindow JMP ClrHome
|
||||
|
||||
;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.
|
||||
@ -105,8 +115,8 @@ ChrWdth !byte 0 ;character width (number of pixels)
|
||||
PltChar !byte 0 ;character to be plotted {0..110}
|
||||
AscChar !byte 0 ;Ascii Char value {$80..$FF}
|
||||
|
||||
;Simple init routine. Just records the font address.
|
||||
DoInit STX Font0
|
||||
;Just record the font address.
|
||||
DoSetFont STA Font0
|
||||
STY Font0+1
|
||||
RTS
|
||||
|
||||
@ -193,9 +203,6 @@ Flg2nd !byte $00 ;flag indicating 2nd byte is needed
|
||||
MlpIdx !byte $00 ;Main loop index into address table
|
||||
Flg8xcp !byte $00 ;flag: 8-pixel char exception
|
||||
FlgBchr !byte $00 ;flag: black character
|
||||
RtMrgnL !byte $00 ;
|
||||
RtMrgnH !byte $00 ;
|
||||
SvY !byte $00 ;
|
||||
|
||||
PlotFnt LDX NoPlt_Flg
|
||||
BNE GetWdth
|
||||
@ -495,6 +502,60 @@ WtL_Prs LDA #0 ; if wait interrupted then do
|
||||
STA ChBflip
|
||||
RTS
|
||||
|
||||
;Routine: Set window boundaries. Paramaters are pushed on the PLASMA
|
||||
;stack in the order Top, Bottom, Left, Right. But because that stack
|
||||
;grows downward, we see them in this order:
|
||||
SW_RT = 0
|
||||
SW_LT = 1
|
||||
SW_BTM = 2
|
||||
SW_TOP = 3
|
||||
SetWnd LDA evalStkL+SW_TOP,X ;get top coord (in units of 8-pixel lins)
|
||||
ASL ;multiply by 8
|
||||
ASL
|
||||
ASL
|
||||
STA CursY ;save the top Y coord
|
||||
STA TpMrgn ;also as the margin
|
||||
LDA evalStkL+SW_BTM,X ;get bottom coord (again in 8-pixel lines)
|
||||
ASL
|
||||
ASL ;multiply by 8
|
||||
ASL
|
||||
STA CursYb ;save the bottom Y coord
|
||||
STA BtMrgn ;also as the margin
|
||||
LDA evalStkL+SW_LT,X ;lo byte of left X
|
||||
STA CursXl
|
||||
LDA evalStkH+SW_LT,X ;hi byte of left X
|
||||
STA CursXh
|
||||
LDA evalStkL+SW_RT,X ;lo byte of right X
|
||||
STA CursXrl
|
||||
LDA evalStkH+SW_RT,X ;hi byte of right X
|
||||
STA CursXrh
|
||||
LDA CursXl ;sum the left X and right X
|
||||
CLC
|
||||
ADC CursXrl
|
||||
TAY ;save lo byte
|
||||
LDA CursXh ;sum the hi byte
|
||||
ADC CursXrh
|
||||
LSR ;divide by 2 to find the midpoint
|
||||
STA CursXmh ;save midpoint lo byte
|
||||
TYA
|
||||
ROR ;divide lo byte by 2, with bit from hi byte
|
||||
STA CursXml ;save midpoint hi byte
|
||||
LDA CursXrl ;need to figure out byte number of right side
|
||||
STA CursColL
|
||||
LDA CursXrh
|
||||
STA CursColH
|
||||
JSR GetOfst ;we have a routine for that
|
||||
LDA HgrHrz
|
||||
STA RtMrgn ;that's the right margin for scrolling
|
||||
LDA CursXl ;similarly we need to figure out the byte number of the left side
|
||||
STA CursColL
|
||||
LDA CursXh
|
||||
STA CursColH
|
||||
JSR GetOfst
|
||||
LDA HgrHrz
|
||||
STA LfMrgn ;that's the left margin for scrolling
|
||||
RTS
|
||||
|
||||
;Routine: Scroll screen up 1 character line
|
||||
;This routine scrolls a window defined by
|
||||
;Left, Right, Top, Bottom - Margin parameters.
|
||||
@ -597,6 +658,98 @@ ClrChkF LDA BkgColor
|
||||
ClrChk1 STA ClrFlpF
|
||||
RTS
|
||||
|
||||
;Routine: parser w/auto line break
|
||||
DoParse STA PrsAdrL
|
||||
STY PrsAdrH
|
||||
LDA CursXrl ;right coord
|
||||
SEC
|
||||
SBC CursXl ;minus left coord
|
||||
STA LinWdth ;equals line width (max of 255 for now)
|
||||
LDY #0 ;parse starting at beginning
|
||||
STY TtlWdth
|
||||
LDA (PrsAdrL),Y ;Get the length
|
||||
STA Pa_Len
|
||||
INY
|
||||
Pa_Lp0 STY Pa_iBgn
|
||||
Pa_Lp1 STY Pa_iSv
|
||||
LDA (PrsAdrL),Y ;Get the character
|
||||
STA AscChar
|
||||
CPY Pa_Len ;reached end of string?
|
||||
BCC Pa_Go
|
||||
BEQ Pa_Go
|
||||
JMP ParsDn
|
||||
Pa_Go ORA #$80 ;set hi bit in case
|
||||
CMP #$8D
|
||||
BEQ Pa_Spc
|
||||
LDX #1
|
||||
STX NoPlt_Flg ;set NO PLOT flag
|
||||
JSR PlotAsc ;do plot routine to strip off Ctrl
|
||||
LDX #0 ;codes & get char width
|
||||
STX NoPlt_Flg ;clear NO PLOT flag
|
||||
LDA ChrWdth
|
||||
BEQ Pa_Tskp
|
||||
SEC ;use SEC to always 'add 1'
|
||||
ADC TtlWdth
|
||||
STA TtlWdth
|
||||
Pa_Tskp LDA AscChar
|
||||
CMP #' '
|
||||
BEQ Pa_Spc
|
||||
LDA TtlWdth
|
||||
CMP LinWdth
|
||||
BPL Pa_ToFr ;too far! force CR/LF
|
||||
LDY Pa_iSv
|
||||
INY
|
||||
JMP Pa_Lp1
|
||||
Pa_ToFr LDA #$8D
|
||||
STA AscChar
|
||||
JSR PlotAsc
|
||||
LDY #0
|
||||
STY TtlWdth
|
||||
LDY Pa_iBgn
|
||||
JMP Pa_Lp0
|
||||
;
|
||||
Pa_Spc LDY Pa_iSv
|
||||
STY Pa_iEnd
|
||||
LDY Pa_iBgn
|
||||
CPY Pa_iEnd
|
||||
BEQ Pa_Dn2
|
||||
Pa_Lp2 STY Pa_iSv
|
||||
LDA (PrsAdrL),Y ;Get the character
|
||||
STA AscChar ;**add code
|
||||
JSR PlotAsc ;if space & at left then don't plot
|
||||
LDY Pa_iSv
|
||||
INY
|
||||
CPY Pa_iEnd
|
||||
BEQ Pa_Dn2
|
||||
BNE Pa_Lp2
|
||||
Pa_Dn2 STY Pa_iSv
|
||||
LDA TtlWdth
|
||||
CMP LinWdth
|
||||
BPL Pa_Dn3
|
||||
LDA (PrsAdrL),Y ;Get the character
|
||||
CMP #$8D
|
||||
BEQ Pa_Dn3
|
||||
STA AscChar
|
||||
JSR PlotAsc
|
||||
JMP Pa_Dn4
|
||||
Pa_Dn3 LDY Pa_iSv
|
||||
INY
|
||||
STY Pa_iBgn
|
||||
JMP Pa_ToFr
|
||||
Pa_Dn4 LDY Pa_iSv
|
||||
INY
|
||||
JMP Pa_Lp0
|
||||
ParsDn LDY #7
|
||||
STY CursXrl
|
||||
RTS
|
||||
;
|
||||
LinWdth !byte 112 ;max line width
|
||||
TtlWdth !byte $00 ;total word width
|
||||
Pa_iBgn !byte $00 ;parser indx begin
|
||||
Pa_iEnd !byte $00 ;parser indx end
|
||||
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
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
fontEngine = $E000
|
||||
|
||||
SetFont = fontEngine
|
||||
PlotAsc = SetFont+3
|
||||
ClearWindow = PlotAsc+3
|
||||
SetFont = fontEngine
|
||||
SetWindow = SetFont+3
|
||||
ClearWindow = SetWindow+3
|
||||
DisplayStr = ClearWindow+3
|
||||
|
@ -457,17 +457,6 @@ asm loader
|
||||
rts
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Set up the font engine
|
||||
// Params: pFont
|
||||
asm initFontEngine
|
||||
+asmPlasm 1
|
||||
ldy evalStkH,x ; hi byte in Y
|
||||
lda evalStkL,x ; lo byte in X
|
||||
tax
|
||||
jmp SetFont
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Jump straight to the system monitor
|
||||
// Params: None
|
||||
@ -484,12 +473,34 @@ asm brk
|
||||
brk
|
||||
end
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Set up the font engine
|
||||
// Params: pFont
|
||||
asm setFont
|
||||
+asmPlasm 1
|
||||
bit setLcRW+lcBank2
|
||||
bit setLcRW+lcBank2
|
||||
jmp SetFont
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Use the font engine to clear the current text window
|
||||
asm setWindow
|
||||
+asmPlasm 4
|
||||
bit setLcRW+lcBank2
|
||||
bit setLcRW+lcBank2
|
||||
jmp SetWindow
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Use the font engine to clear the current text window
|
||||
// Params: None
|
||||
asm clearWindow
|
||||
+asmPlasm 0
|
||||
jmp ClearWindow
|
||||
+asmPlasm 0
|
||||
bit setLcRW+lcBank2
|
||||
bit setLcRW+lcBank2
|
||||
jmp ClearWindow
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -499,24 +510,7 @@ asm displayStr
|
||||
+asmPlasm 1
|
||||
bit setLcRW+lcBank2
|
||||
bit setLcRW+lcBank2
|
||||
sta pTmp ; save string pointer lo
|
||||
sty pTmp+1 ; and hi
|
||||
ldy #0
|
||||
lda (pTmp),y ; get length
|
||||
beq ++ ; if zero, get out
|
||||
- pha ; save length counter
|
||||
inc pTmp ; bump to next char
|
||||
bne +
|
||||
inc pTmp+1 ; page bump
|
||||
+ ldy #0
|
||||
lda (pTmp),y ; fetch character
|
||||
jsr PlotAsc ; and plot it
|
||||
pla ; retrieve length counter
|
||||
sec
|
||||
sbc #1 ; decrement
|
||||
bne - ; go until it hits zero
|
||||
++ ; all done
|
||||
rts
|
||||
jmp DisplayStr
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -706,15 +700,6 @@ def loadFrameImg()
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
def setWindow(top, btm, lft, rt)
|
||||
^wndtop = top
|
||||
^wndbtm = btm
|
||||
^wndleft = lft
|
||||
^wndwdth = rt
|
||||
^cursv = ^wndtop
|
||||
^cursh = ^wndleft
|
||||
end
|
||||
|
||||
// Window for the map name bar
|
||||
def setWindow1()
|
||||
setWindow(1, 2, 5, 17)
|
||||
@ -789,8 +774,8 @@ def initMap(x, y, dir)
|
||||
loadFrameImg()
|
||||
loader(FINISH_LOAD, MAIN_MEM, 1) // 1 = keep open
|
||||
|
||||
// Start up the font engine
|
||||
initFontEngine(pFont)
|
||||
// Tell the font engine where to find its font
|
||||
setFont(pFont)
|
||||
|
||||
// Start up the display engine with map data and starting position. This will also load and
|
||||
// init the script module, if any, which will end up calling us back at the setScriptInfo
|
||||
|
Loading…
Reference in New Issue
Block a user