1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2024-06-01 03:41:34 +00:00
PLASMA/src/libsrc/apple/dhgrlib.pla
2024-02-28 13:32:08 -08:00

278 lines
7.2 KiB
Plaintext

include "inc/cmdsys.plh"
include "inc/lines.plh"
sysflags resxtxt1|reshgr1|resxhgr1
//
// Apple II graphics soft switches
//
const store80dis = $C000
const store80ena = $C001
const show40col = $C00C
const show80col = $C00D
const showgraphics = $C050
const showtext = $C051
const showfull = $C052
const showmix = $C053
const page1m = $C054
const page1x = $C055
const showhires = $C057
const dhresena = $C05E
const dhresdis = $C05F
const IOUdis = $C07E
const IOUena = $C07F
//
// HiRes scanline addresses
//
word hgrscan[] = $2000,$2400,$2800,$2C00,$3000,$3400,$3800,$3C00
word = $2080,$2480,$2880,$2C80,$3080,$3480,$3880,$3C80
word = $2100,$2500,$2900,$2D00,$3100,$3500,$3900,$3D00
word = $2180,$2580,$2980,$2D80,$3180,$3580,$3980,$3D80
word = $2200,$2600,$2A00,$2E00,$3200,$3600,$3A00,$3E00
word = $2280,$2680,$2A80,$2E80,$3280,$3680,$3A80,$3E80
word = $2300,$2700,$2B00,$2F00,$3300,$3700,$3B00,$3F00
word = $2380,$2780,$2B80,$2F80,$3380,$3780,$3B80,$3F80
word = $2028,$2428,$2828,$2C28,$3028,$3428,$3828,$3C28
word = $20A8,$24A8,$28A8,$2CA8,$30A8,$34A8,$38A8,$3CA8
word = $2128,$2528,$2928,$2D28,$3128,$3528,$3928,$3D28
word = $21A8,$25A8,$29A8,$2DA8,$31A8,$35A8,$39A8,$3DA8
word = $2228,$2628,$2A28,$2E28,$3228,$3628,$3A28,$3E28
word = $22A8,$26A8,$2AA8,$2EA8,$32A8,$36A8,$3AA8,$3EA8
word = $2328,$2728,$2B28,$2F28,$3328,$3728,$3B28,$3F28
word = $23A8,$27A8,$2BA8,$2FA8,$33A8,$37A8,$3BA8,$3FA8
word = $2050,$2450,$2850,$2C50,$3050,$3450,$3850,$3C50
word = $20D0,$24D0,$28D0,$2CD0,$30D0,$34D0,$38D0,$3CD0
word = $2150,$2550,$2950,$2D50,$3150,$3550,$3950,$3D50
word = $21D0,$25D0,$29D0,$2DD0,$31D0,$35D0,$39D0,$3DD0
word = $2250,$2650,$2A50,$2E50,$3250,$3650,$3A50,$3E50
word = $22D0,$26D0,$2AD0,$2ED0,$32D0,$36D0,$3AD0,$3ED0
word = $2350,$2750,$2B50,$2F50,$3350,$3750,$3B50,$3F50
word = $23D0,$27D0,$2BD0,$2FD0,$33D0,$37D0,$3BD0,$3FD0
//
// Pixel masks for 7 contiguous pixels
//
word auxmask[] = $000F
word = $0070
word = $0000
word = $0300
word = $3C00
word = $4000
word = $0000
word memmask[] = $0000
word = $0001
word = $001E
word = $0060
word = $0000
word = $0700
word = $7800
//
// Solid colors
//
word auxclrs[] = $0000 // black
word = $2208 // magenta
word = $1144 // brown
word = $334C // orange
word = $0822 // dark green
word = $2A2A // gray 1
word = $1966 // green
word = $3B6E // yellow
word = $4411 // dark blue
word = $6619 // purple
word = $5555 // gray 2
word = $775D // pink
word = $4C33 // medium blue
word = $6E3B // light blue
word = $5D77 // aqua
word = $7F7F // white
word memclrs[] = $0000 // black
word = $4411 // magenta
word = $2208 // brown
word = $6619 // orange
word = $1144 // dark green
word = $5555 // gray 1
word = $334C // green
word = $775D // yellow
word = $0822 // dark blue
word = $4C33 // purple
word = $2A2A // gray 2
word = $6E3B // pink
word = $1966 // medium blue
word = $5D77 // light blue
word = $3B6E // aqua
word = $7F7F // white
word auxclr, memclr
//
// Modulo 7
//
byte mod7[] = 0, 1, 2, 3, 4, 5, 6
byte = 0, 1, 2, 3, 4, 5, 6
byte = 0, 1, 2, 3, 4, 5, 6
byte = 0, 1, 2, 3, 4, 5, 6
byte = 0, 1, 2, 3, 4, 5, 6
byte = 0, 1, 2, 3, 4, 5, 6
byte = 0, 1, 2, 3, 4, 5, 6
byte = 0, 1, 2, 3, 4, 5, 6
byte = 0, 1, 2, 3, 4, 5, 6
byte = 0, 1, 2, 3, 4, 5, 6
byte = 0, 1, 2, 3, 4, 5, 6
byte = 0, 1, 2, 3, 4, 5, 6
byte = 0, 1, 2, 3, 4, 5, 6
byte = 0, 1, 2, 3, 4, 5, 6
byte = 0, 1, 2, 3, 4, 5, 6
byte = 0, 1, 2, 3, 4, 5, 6
byte = 0, 1, 2, 3, 4, 5, 6
byte = 0, 1, 2, 3, 4, 5, 6
byte = 0, 1, 2, 3, 4, 5, 6
byte = 0, 1, 2, 3, 4, 5, 6
//
// Divide 7
//
byte div7x2[] = 0, 0, 0, 0, 0, 0, 0
byte = 2, 2, 2, 2, 2, 2, 2
byte = 4, 4, 4, 4, 4, 4, 4
byte = 6, 6, 6, 6, 6, 6, 6
byte = 8, 8, 8, 8, 8, 8, 8
byte =10,10,10,10,10,10,10
byte =12,12,12,12,12,12,12
byte =14,14,14,14,14,14,14
byte =16,16,16,16,16,16,16
byte =18,18,18,18,18,18,18
byte =20,20,20,20,20,20,20
byte =22,22,22,22,22,22,22
byte =24,24,24,24,24,24,24
byte =26,26,26,26,26,26,26
byte =28,28,28,28,28,28,28
byte =30,30,30,30,30,30,30
byte =32,32,32,32,32,32,32
byte =34,34,34,34,34,34,34
byte =36,36,36,36,36,36,36
byte =38,38,38,38,38,38,38
def dhgrColor(c)#0
auxclr = auxclrs[c & $0F]
memclr = memclrs[c & $0F]
end
def dhgrPlot(x, y)#0
byte pix7
word pix7addr, mask
pix7addr = hgrscan[y] + div7x2[x]
pix7 = mod7[x]
mask = auxmask[pix7]
if mask
^page1x
*pix7addr = (*pix7addr & ~mask) | (mask & auxclr)
fin
mask = memmask[pix7]
if mask
^page1m
*pix7addr = (*pix7addr & ~mask) | (mask & memclr)
fin
end
def dhgrTile(x7, y8, tileptr)#0
word tileaddr
byte scan
tileaddr = hgrscan[y8 * 8] + x7 * 2
for scan = 0 to 7
^page1x
*tileaddr = *tileptr
tileptr = tileptr + 2
^page1m
*tileaddr = *tileptr
tileptr = tileptr + 2
tileaddr = tileaddr + $0400
next
end
def dhgrDst(x7, y, w7, h, dstptr)#0
word pix7addr
byte scan, b
for scan = y to y+h-1
pix7addr = hgrscan[scan] + x7 * 2
for b = 1 to w7
^page1x
*dstptr = *pix7addr
dstptr = dstptr + 2
^page1m
*dstptr = *pix7addr
dstptr = dstptr + 2
pix7addr = pix7addr + 2
next
next
end
def dhgrSrc(x7, y, w7, h, srcptr)#0
word pix7addr
byte scan, b
for scan = y to y+h-1
pix7addr = hgrscan[scan] + x7 * 2
for b = 1 to w7
^page1x
*pix7addr = *srcptr
srcptr = srcptr + 2
^page1m
*pix7addr = *srcptr
srcptr = srcptr + 2
pix7addr = pix7addr + 2
next
next
end
def dhgrMode(mode)
if mode == 0
^page1m
^showfull
^showhires
^showgraphics
^IOUdis = 0
^show80col = 0
^dhresena
^store80ena = 0
^page1m
memset($2000, 0, $2000)
^page1x
memset($2000, 0, $2000)
else
^store80dis = 0
^dhresdis
^show40col = 0
^showtext
^page1m
fin
return mode
end
def dhgrTest#0
byte i, j
word pixblk
setlineplot(@dhgrPlot)
for i = 0 to 191 step 4
dhgrColor(i)
line(0, 0, 139, i)
next
for i = 139 downto 0 step 4
dhgrColor(i)
line(0, 0, i, 191)
next
pixblk = heapalloc(16/2*20)
dhgrDst(0, 0, 2, 20, pixblk)
for i = 1 to 170
dhgrSrc(0, i, 2, 20, pixblk)
next
dhgrDst(0, 0, 1, 8, pixblk) // Create tile
for j = 0 to 19
for i = 0 to 19
dhgrTile(i, j, pixblk)
next
next
while ^$C000 < 128
loop
^$C010
end
dhgrmode(0)
dhgrtest
dhgrmode(-1)
done