diff --git a/Platform/Apple/virtual/src/font/pfontEngine.s b/Platform/Apple/virtual/src/font/fontEngine.s similarity index 98% rename from Platform/Apple/virtual/src/font/pfontEngine.s rename to Platform/Apple/virtual/src/font/fontEngine.s index 677e69ad..65365c39 100644 --- a/Platform/Apple/virtual/src/font/pfontEngine.s +++ b/Platform/Apple/virtual/src/font/fontEngine.s @@ -39,15 +39,15 @@ DEBUG = 0 ; 1=some logging, 2=lots of logging -zTmp1 = $2 ;zero page Temporary variables -zTmp2 = $3 -zTmp3 = $4 -HgrHrz = $5 ;horizontal index added to base adr -L_Adr = $6 ;Zero page address variable -H_Adr = $7 ;for general indrct adrs indexing -MskBytL = $8 ;Mask byte 1st -MskBytH = $9 ;Mask byte 2nd -MskByte = $A ;Mask byte +zTmp1 = $10 ;zero page Temporary variables +zTmp2 = $11 +zTmp3 = $12 +HgrHrz = $13 ;horizontal index added to base adr +L_Adr = $14 ;Zero page address variable +H_Adr = $15 ;for general indrct adrs indexing +MskBytL = $16 ;Mask byte 1st +MskBytH = $17 ;Mask byte 2nd +MskByte = $18 ;Mask byte GBasL = $26 ;LoByte HGR mem pg base adr EABABxxx GBasH = $27 ;HiByte PPPFGHCD for Y=ABCDEFGH P=page @@ -57,23 +57,6 @@ InBufrX = $2FF ;Input Buffer index (length) Kbd_Rd = $C000 ;read keyboard Kbd_Clr = $C010 ;clear keyboard strobe -Font0 !word 0 ;address of font -CharRate !byte $80 ;plot rate {0..FF} 0=fastest -WaitStat !byte 0 ;Wait State {0,1,2,3,4,5,6,7} -NoPlt_Flg !byte 0 ;flag: NO PLOT - only get width -InvTx_Flg !byte 0 ;flag: Inverse (black on white) text -MskTx_Flg !byte 0 ;flag: mask HGR before plotting text -UndTx_Flg !byte 0 ;flag: Underline text -CtrJs_Flg !byte 0 ;flag: center justify -BkgColor !byte $80 ;color byte {0,80=blk,FF=wht,etc} -FrgColor !byte $FF ;color byte -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) -PltChar !byte 0 ;character to be plotted {0..110} -AscChar !byte 0 ;Ascii Char value {$80..$FF} - ;Initialize the font engine. Address of font in X=lo/Y=hi. Init JMP DoInit ;API call address @@ -82,6 +65,9 @@ Init JMP DoInit ;API call address ;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. @@ -102,6 +88,23 @@ GetAsc JMP Get_Chr ;API call address ;left arrow or delete key to backspace. GetStr JMP In_Str +Font0 !word 0 ;address of font +CharRate !byte $80 ;plot rate {0..FF} 0=fastest +WaitStat !byte 0 ;Wait State {0,1,2,3,4,5,6,7} +NoPlt_Flg !byte 0 ;flag: NO PLOT - only get width +InvTx_Flg !byte 0 ;flag: Inverse (black on white) text +MskTx_Flg !byte 0 ;flag: mask HGR before plotting text +UndTx_Flg !byte 0 ;flag: Underline text +CtrJs_Flg !byte 0 ;flag: center justify +BkgColor !byte $80 ;color byte {0,80=blk,FF=wht,etc} +FrgColor !byte $FF ;color byte +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) +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 STY Font0+1 @@ -993,9 +996,9 @@ ChBufr !fill 40,0 ;input buffer ($200 not used) CwBufr !fill 40,0 ;Char Width Buffer ;Test for Control Keys when using ASCII characters -TestChr LDA #0 - STA ChrWdth - LDA AscChar ;get the ASCII character +TestChr STA AscChar ;store the ASCII character + LDX #0 + STX ChrWdth AND #$7F ;strip off HiBit TAX ;save it AND #$E0 ;check for Ctrl-character diff --git a/Platform/Apple/virtual/src/include/fontEngine.i b/Platform/Apple/virtual/src/include/fontEngine.i index 2349a004..49fc1275 100644 --- a/Platform/Apple/virtual/src/include/fontEngine.i +++ b/Platform/Apple/virtual/src/include/fontEngine.i @@ -1,52 +1,10 @@ ; -; Font Engine -; -; (c) 2013, Brutal Deluxe Software +; Proportional Font Engine +; by Andrew Hogan ; -; Equates -pHGR1 = $20 -pHGR2 = $40 -pHGR3 = $60 +fontEngine = $E000 -pNORMAL = $00 -pINVERSE = $FF - -charNULL = $00 -charRET = $0d -charSPACE = $20 -charCMD = $80 - -; -; Zero page usage -; -wndleft = $70 ; left edge of the window -wndwdth = wndleft+1 ; width of text window -wndtop = wndwdth+1 ; top of text window -wndbtm = wndtop+1 ; bottom+1 of text window - -cursh = wndbtm+1 ; Cursor H-pos 0-39 -cursv = cursh+1 ; Cursor V-pos 0-23 => 0-191 - - -;--------------------------- -; -; STR: draws a Pascal string -; CSTR: draws a C string (null terminated) -; CHAR: draws a single char -; - -;--------------------------- - -fontEngine = $BA00 -printSTR = fontEngine -printSSTR = printSTR+3 -printCSTR = printSSTR+3 -printSCSTR = printCSTR+3 -printCHAR = printSCSTR+3 -tabXY = printCHAR+3 -setFONT = tabXY+3 -displayMODE = setFONT+3 -drawMODE = displayMODE+3 -scrollWINDOW = drawMODE+3 -clearWINDOW = scrollWINDOW+3 +SetFont = fontEngine +PlotAsc = SetFont+3 +ClearWindow = PlotAsc+3 \ No newline at end of file diff --git a/Platform/Apple/virtual/src/plasma/gameloop.pla b/Platform/Apple/virtual/src/plasma/gameloop.pla index bb6e0a24..572cf13c 100644 --- a/Platform/Apple/virtual/src/plasma/gameloop.pla +++ b/Platform/Apple/virtual/src/plasma/gameloop.pla @@ -8,7 +8,7 @@ const NULL = 0 // Fixed memory locations const displayEngine = $6000 // main mem (raycaster and tile engine at same location) const expandVec = $2000 // aux mem (only for raycaster) -const fontEngine = $BA00 // main mem +const fontEngine = $E000 // main mem /////////////////////////////////////////////////////////////////////////////////////////////////// // Resource numbers @@ -462,16 +462,10 @@ end // Params: pFont asm initFontEngine +asmPlasm 1 - ldy evalStkL,x ; font engine likes *lo* byte in Y - lda evalStkH,x ; hi byte in X + ldy evalStkH,x ; hi byte in Y + lda evalStkL,x ; lo byte in X tax - jsr setFONT - ; Set to write text on both hi-res pages at the same time - lda #pHGR3 - jsr displayMODE - ; Set to normal (non-inverse) text - lda #pNORMAL - jmp drawMODE + jmp SetFont end /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -495,86 +489,34 @@ end // Params: None asm clearWindow +asmPlasm 0 - jmp clearWINDOW + jmp ClearWindow end /////////////////////////////////////////////////////////////////////////////////////////////////// -// Display a string using the font engine, but without any break checking. -// Params: pStr -asm rawDisplayStr - +asmPlasm 1 - pha - tya - tax ; hi byte of addr to X - pla - tay ; lo byte of addr to Y - jmp printSTR -end - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Display a string using the font engine. Automatically splits lines to keep words from breaking. +// Display a string using the font engine. // Params: pStr asm displayStr - +asmPlasm 1 - sta pTmp - sty pTmp+1 - ldy #0 - lda (pTmp),y ; get string length - beq .done ; if zero, get out. - inc pTmp ; advance past string len - bne + - inc pTmp+1 -+ --- tax ; length will be tracked in X reg - ldy #0 -- lda (pTmp),y ; next character - cmp #$20 ; check for invalid control chars - bcc + - cmp #$80 ; check for invalid hi-bit chars - bcc ++ -+ lda #$C4 ; failure path - jsr $fded - brk -++ dex ; used a char - cmp #$20 ; is the char a space? - beq + - sta $2E1,y ; no, save to word buffer - iny - cpx #0 ; last char? - bne - -+ sty $2E0 ; found a word break; save word length. - tya - sec - adc pTmp ; advance main pointer over word - sta pTmp - bcc + - inc pTmp+1 -+ txa ; save X reg - pha - tya ; string length - clc - adc cursh ; ...plus cursor pos - sec - sbc #2 - cmp wndwdth ; ...vs. window width - bcc + - lda #$D ; force a line break - jsr printCHAR -+ tya ; if zero length (e.g. string starts with space), just print the space - beq + - ldy #$E0 ; now display string at $2E0 (word buf) - ldx #2 - jsr printSTR - lda cursh - cmp wndleft - beq ++ -+ lda #$20 - jsr printCHAR -++ pla ; restore string length - bne -- -.done: - lda #$d - jmp printCHAR + +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 end /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -804,11 +746,11 @@ end // Show some faked-up data for player characters def fakeChars() setWindow3() - rawDisplayStr("Name Lif Gun") - rawDisplayStr("-------- --- ---") - rawDisplayStr("Blak Bart 12 4 ") - rawDisplayStr("Wyld Bill 8 2 ") - rawDisplayStr("LucyLwls 9 6") + displayStr("Name Lif Gun") + displayStr("-------- --- ---") + displayStr("Blak Bart 12 4 ") + displayStr("Wyld Bill 8 2 ") + displayStr("LucyLwls 9 6") setWindow2() end @@ -998,7 +940,7 @@ def setMap(is3D, num, x, y, dir) else flipToPage1() setWindow1(); clearWindow() - rawDisplayStr("Traveling...") + displayStr("Traveling...") setMapWindow(); clearWindow() setWindow2(); clearWindow() mapIs3D = is3D @@ -1112,7 +1054,7 @@ def setScriptInfo(mapName, trigTbl) // Display map name setWindow1() clearWindow() - rawDisplayStr(mapName) + displayStr(mapName) // Back to the main text window. setWindow2()