1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2026-04-23 21:17:09 +00:00

Break DCGR Toolit out into own project

This commit is contained in:
David Schmenk
2024-11-26 20:22:29 -08:00
parent f592edeb8a
commit f9dd7b5417
19 changed files with 77 additions and 53 deletions
File diff suppressed because it is too large Load Diff
-266
View File
@@ -1,266 +0,0 @@
include "inc/cmdsys.plh"
include "inc/fileio.plh"
include "inc/dcgrlib.plh"
const page1m = $C054
const page1x = $C055
//
// Color -> DHGR pixel
//
byte[] dhgrPix = 2, 4, 8, 1
byte[] dhgrMask = 13, 12, 7, 14
//
// Apple //e hires character font
//
byte fontWide[]
byte = $00,$00,$00,$00,$00,$00,$00,$00,$08,$08,$08,$08,$08,$00,$08,$00
byte = $14,$14,$14,$00,$00,$00,$00,$00,$14,$14,$3E,$14,$3E,$14,$14,$00
byte = $08,$3C,$0A,$1C,$28,$1E,$08,$00,$06,$26,$10,$08,$04,$32,$30,$00
byte = $04,$0A,$0A,$04,$2A,$12,$2C,$00,$08,$08,$08,$00,$00,$00,$00,$00
byte = $08,$04,$02,$02,$02,$04,$08,$00,$08,$10,$20,$20,$20,$10,$08,$00
byte = $08,$2A,$1C,$08,$1C,$2A,$08,$00,$00,$08,$08,$3E,$08,$08,$00,$00
byte = $00,$00,$00,$00,$08,$08,$04,$00,$00,$00,$00,$3E,$00,$00,$00,$00
byte = $00,$00,$00,$00,$00,$00,$08,$00,$00,$20,$10,$08,$04,$02,$00,$00
byte = $1C,$22,$32,$2A,$26,$22,$1C,$00,$08,$0C,$08,$08,$08,$08,$1C,$00
byte = $1C,$22,$20,$18,$04,$02,$3E,$00,$3E,$20,$10,$18,$20,$22,$1C,$00
byte = $10,$18,$14,$12,$3E,$10,$10,$00,$3E,$02,$1E,$20,$20,$22,$1C,$00
byte = $38,$04,$02,$1E,$22,$22,$1C,$00,$3E,$20,$10,$08,$04,$04,$04,$00
byte = $1C,$22,$22,$1C,$22,$22,$1C,$00,$1C,$22,$22,$3C,$20,$10,$0E,$00
byte = $00,$00,$08,$00,$08,$00,$00,$00,$00,$00,$08,$00,$08,$08,$04,$00
byte = $10,$08,$04,$02,$04,$08,$10,$00,$00,$00,$3E,$00,$3E,$00,$00,$00
byte = $04,$08,$10,$20,$10,$08,$04,$00,$1C,$22,$10,$08,$08,$00,$08,$00
byte = $1C,$22,$2A,$3A,$1A,$02,$3C,$00,$08,$14,$22,$22,$3E,$22,$22,$00
byte = $1E,$22,$22,$1E,$22,$22,$1E,$00,$1C,$22,$02,$02,$02,$22,$1C,$00
byte = $1E,$22,$22,$22,$22,$22,$1E,$00,$3E,$02,$02,$1E,$02,$02,$3E,$00
byte = $3E,$02,$02,$1E,$02,$02,$02,$00,$3C,$02,$02,$02,$32,$22,$3C,$00
byte = $22,$22,$22,$3E,$22,$22,$22,$00,$1C,$08,$08,$08,$08,$08,$1C,$00
byte = $20,$20,$20,$20,$20,$22,$1C,$00,$22,$12,$0A,$06,$0A,$12,$22,$00
byte = $02,$02,$02,$02,$02,$02,$3E,$00,$22,$36,$2A,$2A,$22,$22,$22,$00
byte = $22,$22,$26,$2A,$32,$22,$22,$00,$1C,$22,$22,$22,$22,$22,$1C,$00
byte = $1E,$22,$22,$1E,$02,$02,$02,$00,$1C,$22,$22,$22,$2A,$12,$2C,$00
byte = $1E,$22,$22,$1E,$0A,$12,$22,$00,$1C,$22,$02,$1C,$20,$22,$1C,$00
byte = $3E,$08,$08,$08,$08,$08,$08,$00,$22,$22,$22,$22,$22,$22,$1C,$00
byte = $22,$22,$22,$22,$22,$14,$08,$00,$22,$22,$22,$2A,$2A,$36,$22,$00
byte = $22,$22,$14,$08,$14,$22,$22,$00,$22,$22,$14,$08,$08,$08,$08,$00
byte = $3E,$20,$10,$08,$04,$02,$3E,$00,$3E,$06,$06,$06,$06,$06,$3E,$00
byte = $00,$02,$04,$08,$10,$20,$00,$00,$3E,$30,$30,$30,$30,$30,$3E,$00
byte = $00,$00,$08,$14,$22,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$7F
byte = $04,$08,$10,$00,$00,$00,$00,$00,$00,$00,$1C,$20,$3C,$22,$3C,$00
byte = $02,$02,$1E,$22,$22,$22,$1E,$00,$00,$00,$3C,$02,$02,$02,$3C,$00
byte = $20,$20,$3C,$22,$22,$22,$3C,$00,$00,$00,$1C,$22,$3E,$02,$3C,$00
byte = $18,$24,$04,$1E,$04,$04,$04,$00,$00,$00,$1C,$22,$22,$3C,$20,$1C
byte = $02,$02,$1E,$22,$22,$22,$22,$00,$08,$00,$0C,$08,$08,$08,$1C,$00
byte = $10,$00,$18,$10,$10,$10,$12,$0C,$02,$02,$22,$12,$0E,$12,$22,$00
byte = $0C,$08,$08,$08,$08,$08,$1C,$00,$00,$00,$36,$2A,$2A,$22,$22,$00
byte = $00,$00,$1E,$22,$22,$22,$22,$00,$00,$00,$1C,$22,$22,$22,$1C,$00
byte = $00,$00,$1E,$22,$22,$1E,$02,$02,$00,$00,$3C,$22,$22,$3C,$20,$20
byte = $00,$00,$3A,$06,$02,$02,$02,$00,$00,$00,$3C,$02,$1C,$20,$1E,$00
byte = $04,$04,$1E,$04,$04,$24,$18,$00,$00,$00,$22,$22,$22,$32,$2C,$00
byte = $00,$00,$22,$22,$22,$14,$08,$00,$00,$00,$22,$22,$2A,$2A,$36,$00
byte = $00,$00,$22,$14,$08,$14,$22,$00,$00,$00,$22,$22,$22,$3C,$20,$1C
byte = $00,$00,$3E,$10,$08,$04,$3E,$00,$38,$0C,$0C,$06,$0C,$0C,$38,$00
byte = $08,$08,$08,$08,$08,$08,$08,$08,$0E,$18,$18,$30,$18,$18,$0E,$00
byte = $00,$2C,$1A,$00,$00,$00,$00,$00,$00,$2A,$14,$2A,$14,$2A,$00,$00
var fontThin = NULL
var fontPtr = @fontWide
var fontWidth = 7
//
// Utility functions
//
export def dcgrAllocBl7Mem(w, h)#2
word memblk, span
span = (w+13)/7 << 2
memblk = heapalloc(span * h)
return memblk, span
end
export def dcgrStr(x, y, strptr)#0
byte i
for i = 1 to ^strptr
dcgrBitmap(x, y, fontWidth, 8, fontPtr + (^(strptr + i) - 32) * 8)
x = x + fontWidth
next
end
export def dcgrBoldStr(clr, x, y, strptr)#0
byte h, v
for v = y - 1 to y + 1
for h = x - 1 to x + 1
dcgrStr(h, v, strptr)
next
next
dcgrColor(clr)
dcgrStr(x, y, strptr)
end
export def dcgrFont(font)#0
var rows, pWide, pThin
byte bits
if font
if not fontThin
fontThin = heapalloc(96*8)
pThin = fontThin
pWide = @fontWide
for rows = 0 to 96*8
bits = (^pWide ) & $02
bits = bits | (^pWide | ^pWide >> 1 | ^pWide >> 2) & $04
bits = bits | ( ^pWide >> 2) & $08
^pThin = bits
pThin++
pWide++
next
fin
fontPtr = fontThin
fontWidth = 4
else
fontPtr = @fontWide
fontWidth = 7
fin
end
export def dcgrRect(x, y, w, h)#0
byte x2, y2, v
x2 = x + w - 1
y2 = y + h - 1
for v = y to y2
dcgrHLin(x, x2, v)
next
end
export def dcgrGetPixMap(x, y, w, h)#1
var pixmap, pixptr
byte i, j
pixmap = heapalloc((w + 1)/2 * h)
pixptr = pixmap
w--; h--
for j = 0 to h
for i = 0 to w step 2
^pixptr = dcgrGetPixel(i+x,j+y)|(dcgrGetPixel(i+x+1,j+y)<<4)
pixptr++
next
next
return pixmap
end
export def dcgrEncPixMap(w, h, pixmap, rlemap)#1
var rleptr
byte i, j, run, pixrun
rleptr = rlemap
w--; h--
for j = 0 to h
run = 0
for i = 0 to w step 2
if run and ^pixmap == pixrun
run++
else
if run
*rleptr = run*2 | (pixrun << 8)
//puth(*rleptr); putc(',')
rleptr = rleptr + 2
fin
run = 1
pixrun = ^pixmap
fin
pixmap++
next
*rleptr = run*2 | (pixrun << 8)
//puth(*rleptr); putln
rleptr = rleptr + 2
next
return rleptr - rlemap
end
export def dhgrSet(dhx, y)#0
dcgrColor(dhgrPix[dhx & $03])
dcgrOp(OP_OR)
dcgrPixel(dhx >> 2, y)
end
export def dhgrUnset(dhx, y)#0
dcgrColor(dhgrMask[dhx & $03])
dcgrOp(OP_AND)
dcgrPixel(dhx >> 2, y)
end
export def spriteRead(filestr)#5
var sprptr, sprsize, xorg, yorg
byte refnum, width, height
width = 0
height = 0
sprptr = 0
refnum = fileio:open(filestr)
if refnum
fileio:read(refnum, @xorg, 1); xorg = sext(xorg)
fileio:read(refnum, @yorg, 1); yorg = sext(yorg)
fileio:read(refnum, @width, 1)
fileio:read(refnum, @height, 1)
if width <= 40 and height <= 48
sprsize = (width + 1) / 2 * height
sprptr = heapalloc(sprsize)
if sprptr
if fileio:read(refnum, sprptr, sprsize) <> sprsize
heaprelease(sprptr)
sprptr = NULL
fin
fin
fin
fileio:close(refnum)
fin
return xorg, yorg, width, height, sprptr
end
export def spriteWrite(filestr, xorg, yorg, width, height, sprptr)#1
var sprsize
byte refnum, i, result
sprsize = (width + 1) / 2 * height
fileio:destroy(filestr)
result = fileio:create(filestr, $06, $0000)
if result == FILE_ERR_OK
refnum = fileio:open(filestr)
if refnum
fileio:write(refnum, @xorg, 1)
fileio:write(refnum, @yorg, 1)
fileio:write(refnum, @width, 1)
fileio:write(refnum, @height, 1)
sprsize = (width + 1) / 2 * height
fileio:write(refnum, sprptr, sprsize)
result = perr
fileio:close(refnum)
else
result = perr
fin
fin
return result
end
export def screenRead(filestr)#1
byte refnum
refnum = fileio:open(filestr)
if refnum
^page1x // Read AUX bytes
fileio:read(refnum, $2000, $2000)
^page1m // Read MAIN bytes
fileio:read(refnum, $2000, $2000)
fileio:close(refnum)
fin
return perr
end
export def screenWrite(filestr)#1
byte refnum, result
fileio:destroy(filestr)
result = fileio:create(filestr, $06, $2000)
if result == FILE_ERR_OK
refnum = fileio:open(filestr)
if refnum
^page1x // Write AUX bytes
if fileio:write(refnum, $2000, $2000) == $2000
^page1m // Write MAIN bytes
fileio:write(refnum, $2000, $2000)
fin
result = perr
fileio:close(refnum)
else
result = perr
fin
fin
return result
end