mirror of
https://github.com/dschmenk/PLASMA.git
synced 2026-04-27 03:18:02 +00:00
Many font fixes (and mem dest y clipping for neg y)
This commit is contained in:
1 parent
218eb6fcb1
commit
95a30fb13a
4 files changed
+117
-54
No files matched your search
@@ -1,11 +1,20 @@
|
||||
import dhgrutils
|
||||
//
|
||||
// Font type bits
|
||||
//
|
||||
const FONT_MONO = $00
|
||||
const FONT_PROP = $80
|
||||
const FONT_BITMAP = $00
|
||||
const FONT_PIXMAP = $40
|
||||
byte fontDefWide
|
||||
byte fontDefThin
|
||||
predef dhgrAllocBl7Mem(w, h)#2
|
||||
predef dcgrStr(x, y, strptr)#2
|
||||
predef dcgrBoldStr(clr, x, y, strptr)#2
|
||||
predef dcgrFont(font)#0
|
||||
predef dcgrFont(font)#1
|
||||
predef fontRead(filename)#1
|
||||
predef fontGlyphDim#2
|
||||
predef fontType#1
|
||||
predef dcgrRect(x, y, w, h)#0
|
||||
predef dcgrGetPixMap(x, y, w, h)#1
|
||||
predef dcgrEncPixMap(w, h, pixmap, rlemap)#1
|
||||
|
||||
@@ -1049,7 +1049,7 @@ asm _dcgrVLinMemB
|
||||
INC ESTKL-1,X ; Y1++
|
||||
CMP ESTKL-2,X ; Y2 COORD
|
||||
BNE YVM
|
||||
+ RTS
|
||||
RETVLM RTS
|
||||
end
|
||||
asm dcgrBitMapMem(x, y, bitw, bith, bitptr, memw, memh, memptr, memspan)#0
|
||||
TXA
|
||||
@@ -1061,7 +1061,26 @@ asm dcgrBitMapMem(x, y, bitw, bith, bitptr, memw, memh, memptr, memspan)#0
|
||||
STA DSTL
|
||||
LDA ESTKH-8,X
|
||||
STA DSTH
|
||||
LDY ESTKL-2,X ; Y COORD
|
||||
- LDY ESTKH-2,X ; MSB YCOORD
|
||||
BPL ++
|
||||
LDA ESTKL-3,X ; WIDTH
|
||||
CLC
|
||||
ADC #$07
|
||||
LSR ; WIDTH/8
|
||||
LSR
|
||||
LSR
|
||||
CLC
|
||||
ADC ESTKL-5,X ; PIXPTR += SPAN
|
||||
STA ESTKL-5,X
|
||||
BCC +
|
||||
INC ESTKH-5,X
|
||||
+ DEC ESTKL-4,X ; HEIGHT
|
||||
BEQ RETVLM
|
||||
INC ESTKL-2,X
|
||||
BNE -
|
||||
INC ESTKH-2,X
|
||||
BMI -
|
||||
++ LDY ESTKL-2,X ; Y COORD
|
||||
BEQ +
|
||||
;CLC ; ADVANCE TO Y SCANLINE
|
||||
- LDA ESTKL-9,X ; SPAN
|
||||
@@ -1142,7 +1161,21 @@ asm dcgrPixMapMem(x, y, pixw, pixh, pixptr, memw, memh, memptr, memspan)#0
|
||||
STA DSTL
|
||||
LDA ESTKH-8,X
|
||||
STA DSTH
|
||||
LDY ESTKL-2,X ; Y COORD
|
||||
- LDY ESTKH-2,X ; MSB YCOORD
|
||||
BPL ++
|
||||
LDA ESTKL-3,X ; WIDTH
|
||||
LSR ; WIDTH/2
|
||||
ADC ESTKL-5,X ; PIXPTR += SPAN
|
||||
STA ESTKL-5,X
|
||||
BCC +
|
||||
INC ESTKH-5,X
|
||||
+ DEC ESTKL-4,X ; HEIGHT
|
||||
BEQ RETBITM
|
||||
INC ESTKL-2,X
|
||||
BNE -
|
||||
INC ESTKH-2,X
|
||||
BMI -
|
||||
++ LDY ESTKL-2,X ; Y COORD
|
||||
BEQ +
|
||||
- CLC ; ADVANCE TO Y SCANLINE
|
||||
LDA ESTKL-9,X ; SPAN
|
||||
|
||||
@@ -6,13 +6,6 @@ include "dhgr.tk/inc/dhgrutils.plh"
|
||||
const page1m = $C054
|
||||
const page1x = $C055
|
||||
//
|
||||
// Font type bits
|
||||
//
|
||||
const FONT_MONO = $00
|
||||
const FONT_PROP = $80
|
||||
const FONT_BITMAP = $00
|
||||
const FONT_PIXMAP = $40
|
||||
//
|
||||
// Font header
|
||||
//
|
||||
struc t_font
|
||||
@@ -123,6 +116,30 @@ export def dhgrAllocBl7Mem(w, h)#2
|
||||
memblk = heapalloc(span * h)
|
||||
return memblk, span
|
||||
end
|
||||
def bitCtrlGlyph(x, y, c)#2
|
||||
when c
|
||||
is '\n'
|
||||
x = 0
|
||||
y = y + fontPtr->fnt_height
|
||||
break
|
||||
is '\t'
|
||||
x = x + (fontPtr->fnt_width * 8)
|
||||
break
|
||||
wend
|
||||
return x, y
|
||||
end
|
||||
def pixCtrlGlyph(x, y, c)#2
|
||||
when c
|
||||
is '\n'
|
||||
x = 0
|
||||
y = y + fontPtr->fnt_height
|
||||
break
|
||||
is '\t'
|
||||
x = x + (fontPtr->fnt_width * 4)
|
||||
break
|
||||
wend
|
||||
return x, y
|
||||
end
|
||||
def bitMonoGlyphStr(x, y, strptr)#2
|
||||
byte first, last, width, height, size, i, ch
|
||||
var strikes
|
||||
@@ -136,18 +153,11 @@ def bitMonoGlyphStr(x, y, strptr)#2
|
||||
for i = 1 to ^strptr
|
||||
ch = ^(strptr + i)
|
||||
if ch >= first and ch <= last
|
||||
dcgrBitmap(x, y, width, height, strikes + (^(strptr + i) - first) * size)
|
||||
dcgrBitmap(x, y - height, width, height, \
|
||||
strikes + (^(strptr + i) - first) * size)
|
||||
x = x + width
|
||||
else
|
||||
when ch
|
||||
is '\n'
|
||||
x = 0
|
||||
y = y + fontPtr->fnt_height
|
||||
break
|
||||
is '\t'
|
||||
x = x + (fontPtr->fnt_width * 8)
|
||||
break
|
||||
wend
|
||||
x, y = bitCtrlGlyph(x, y, ch)
|
||||
fin
|
||||
next
|
||||
return x, y
|
||||
@@ -156,10 +166,10 @@ def pixPropGlyphStr(x, y, strptr)#2
|
||||
var glyptrs, glyph
|
||||
byte first, last, i, ch
|
||||
|
||||
dhgrOp(OP_XOR)
|
||||
first = fontPtr->fnt_first
|
||||
last = fontPtr->fnt_last
|
||||
glyptrs = fontPtr + fnt_glyptrs
|
||||
x = x * 4
|
||||
for i = 1 to ^strptr
|
||||
ch = ^(strptr + i)
|
||||
if ch >= first and ch <= last
|
||||
@@ -171,25 +181,15 @@ def pixPropGlyphStr(x, y, strptr)#2
|
||||
glyph + gly_strike)
|
||||
x = x + glyph->gly_adv
|
||||
else
|
||||
when ch
|
||||
is '\n'
|
||||
x = 0
|
||||
y = y + fontPtr->fnt_height
|
||||
break
|
||||
is '\t'
|
||||
x = x + (fontPtr->fnt_width * 8)
|
||||
break
|
||||
wend
|
||||
x, y = pixCtrlGlyph(x, y, ch)
|
||||
fin
|
||||
next
|
||||
return x, y
|
||||
return x / 4, y
|
||||
end
|
||||
|
||||
def bitPropGlyphStr(x, y, strptr)#2
|
||||
var glyptrs, glyph
|
||||
byte first, last, i, ch
|
||||
|
||||
dhgrOp(OP_SRC)
|
||||
first = fontPtr->fnt_first
|
||||
last = fontPtr->fnt_last
|
||||
glyptrs = fontPtr + fnt_glyptrs
|
||||
@@ -204,15 +204,7 @@ def bitPropGlyphStr(x, y, strptr)#2
|
||||
glyph + gly_strike)
|
||||
x = x + glyph->gly_adv
|
||||
else
|
||||
when ch
|
||||
is '\n'
|
||||
x = 0
|
||||
y = y + fontPtr->fnt_height
|
||||
break
|
||||
is '\t'
|
||||
x = x + (fontPtr->fnt_width * 4)
|
||||
break
|
||||
wend
|
||||
x, y = bitCtrlGlyph(x, y, ch)
|
||||
fin
|
||||
next
|
||||
return x, y
|
||||
@@ -228,9 +220,10 @@ export def dcgrBoldStr(clr, x, y, strptr)#2
|
||||
dcgrColor(clr)
|
||||
return dcgrStr(x, y, strptr)
|
||||
end
|
||||
export def dcgrFont(font)#0
|
||||
var rows, pWide, pThin
|
||||
export def dcgrFont(font)#1
|
||||
var rows, pWide, pThin, prevFont
|
||||
|
||||
prevFont = fontPtr
|
||||
if font
|
||||
if font == @fontDefThin
|
||||
if not fontDefThin:fnt_glyptrs
|
||||
@@ -257,6 +250,7 @@ export def dcgrFont(font)#0
|
||||
dcgrStr:1 = @bitMonoGlyphStr
|
||||
fin
|
||||
fin
|
||||
return prevFont
|
||||
end
|
||||
export def fontRead(filename)#1
|
||||
var glyph, strksize, left, top
|
||||
@@ -312,6 +306,12 @@ export def fontRead(filename)#1
|
||||
fin
|
||||
return font_header
|
||||
end
|
||||
export def fontGlyphDim#2
|
||||
return fontPtr->fnt_width, fontPtr->fnt_height
|
||||
end
|
||||
export def fontType#1
|
||||
return ^fontPtr & $F0
|
||||
end
|
||||
export def dcgrRect(x, y, w, h)#0
|
||||
byte x2, y2, v
|
||||
|
||||
|
||||
@@ -8,20 +8,41 @@ include "dhgr.tk/inc/dhgrutils.plh"
|
||||
sysflags resxtxt1|reshgr1|resxhgr1
|
||||
|
||||
var arg
|
||||
var xPen = 0
|
||||
var yPen = 16
|
||||
var xPen = 58
|
||||
var yPen = 30
|
||||
var fontWidth, fontHeight
|
||||
var surf, span
|
||||
char msg = "Hello, world"
|
||||
|
||||
arg = argNext(argFirst)
|
||||
dhgrMode(DHGR_COLOR_MODE)
|
||||
dcgrColor(CLR_WHITE)
|
||||
dhgrClearBl7(0, 0, SCR_WIDTH7, SCR_HEIGHT)
|
||||
dcgrColor(CLR_BLACK)
|
||||
dcgrStr(0, 0, "Wide Default Font Test")
|
||||
dcgrFont(@fontDefThin)
|
||||
dcgrStr(0, 8, "Thin Default Font Test")
|
||||
screenRead("scroll.dhgr")
|
||||
//dcgrColor(CLR_WHITE)
|
||||
//dhgrClearBl7(0, 0, SCR_WIDTH7, SCR_HEIGHT)
|
||||
//dcgrColor(CLR_BLACK)
|
||||
//xPen, yPen = dcgrStr(xPen, yPen, @msg)
|
||||
//dcgrFont(@fontDefThin)
|
||||
//xPen, yPen = dcgrStr(xPen, yPen, @msg)
|
||||
while arg and ^arg
|
||||
dcgrFont(fontRead(arg))
|
||||
xPen, yPen = dcgrStr(xPen, yPen, "\nHello, world")
|
||||
fontWidth, fontHeight = fontGlyphDim
|
||||
fontHeight++
|
||||
yPen = yPen + fontHeight
|
||||
if fontType & FONT_PIXMAP
|
||||
surf, span = dhgrAllocBl7Mem(fontWidth * msg, fontHeight)
|
||||
dhgrSurfMem(OP_SRC, fontHeight, surf, span)
|
||||
dcgrColor(CLR_WHITE)
|
||||
dhgrClearBl7(0, 0, span>>2, fontHeight)
|
||||
dhgrOp(OP_XOR)
|
||||
dcgrStr(0, (fontHeight * 3) / 4, @msg)
|
||||
dhgrSurfScr(OP_AND)
|
||||
dhgrMemBl7(xPen/7, yPen, span >> 2, fontHeight, surf, span)
|
||||
heaprelease(surf)
|
||||
else
|
||||
dhgrOp(OP_SRC)
|
||||
dcgrColor(CLR_BLACK)
|
||||
dcgrStr(xPen, yPen, @msg)
|
||||
fin
|
||||
arg = argNext(arg)
|
||||
loop
|
||||
getc
|
||||
|
||||
Reference in new issue
Block a user