DHGR test lib

This commit is contained in:
David Schmenk 2024-02-28 13:32:08 -08:00
parent 0ab16d4877
commit 2eea9e585c
1 changed files with 155 additions and 63 deletions

View File

@ -1,6 +1,7 @@
include "inc/cmdsys.plh"
include "inc/lines.plh"
sysflags restxt1|reshgr1|resxhgr1
sysflags resxtxt1|reshgr1|resxhgr1
//
// Apple II graphics soft switches
@ -49,34 +50,57 @@ word = $2350,$2750,$2B50,$2F50,$3350,$3750,$3B50,$3F50
word = $23D0,$27D0,$2BD0,$2FD0,$33D0,$37D0,$3BD0,$3FD0
//
// Pixel masks for 7 contiguous pixels
// AUXL AUXH MEML MEMH
byte masks[] = $0F, $00, $00, $00
byte = $70, $00, $01, $00
byte = $00, $00, $1E ,$00
byte = $00, $03, $60, $00
byte = $00, $3C, $00, $00
byte = $00, $40, $00, $07
byte = $00, $00, $00, $78
//
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
// AUXL AUXH MEML MEMH
byte colors[] = $00, $00, $00, $00 // black
byte = $08, $22, $11, $44 // magenta
byte = $44, $11, $08, $22 // brown
byte = $4C, $33, $19, $66 // orange
byte = $22, $08, $44, $11 // dark green
byte = $2A, $2A, $55, $55 // gray 1
byte = $66, $19, $4C, $33 // green
byte = $6E, $3B, $5D, $77 // yellow
byte = $11, $44, $22, $08 // dark blue
byte = $19, $66, $33, $4C // purple
byte = $55, $55, $2A, $2A // gray 2
byte = $5D, $77, $3B, $6E // pink
byte = $33, $4C, $66, $19 // medium blue
byte = $3B, $6E, $77, $5D // light blue
byte = $77, $5D, $6E, $3B // aqua
byte = $7F, $7F, $7F, $7F // white
word clr = @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
//
@ -103,47 +127,98 @@ byte = 0, 1, 2, 3, 4, 5, 6
//
// Divide 7
//
byte div7[] = 0, 0, 0, 0, 0, 0, 0
byte = 1, 1, 1, 1, 1, 1, 1
byte = 2, 2, 2, 2, 2, 2, 2
byte = 3, 3, 3, 3, 3, 3, 3
byte = 4, 4, 4, 4, 4, 4, 4
byte = 5, 5, 5, 5, 5, 5, 5
byte = 6, 6, 6, 6, 6, 6, 6
byte = 7, 7, 7, 7, 7, 7, 7
byte = 8, 8, 8, 8, 8, 8, 8
byte = 9, 9, 9, 9, 9, 9, 9
byte =10,10,10,10,10,10,10
byte =11,11,11,11,11,11,11
byte =12,12,12,12,12,12,12
byte =13,13,13,13,13,13,13
byte =14,14,14,14,14,14,14
byte =15,15,15,15,15,15,15
byte =16,16,16,16,16,16,16
byte =17,17,17,17,17,17,17
byte =18,18,18,18,18,18,18
byte =19,19,19,19,19,19,19
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
clr = @colors + ((c & $0F) << 2)
def dhgrColor(c)#0
auxclr = auxclrs[c & $0F]
memclr = memclrs[c & $0F]
end
def dhgrplot(x, y)#0
word pixaddr, maskblk, mask
def dhgrPlot(x, y)#0
byte pix7
word pix7addr, mask
pixaddr = hgrscan[y] + div7[x] * 2
maskblk = @masks + mod7[x] * 4
mask = *maskblk
pix7addr = hgrscan[y] + div7x2[x]
pix7 = mod7[x]
mask = auxmask[pix7]
if mask
^page1x
*pixaddr = (*pixaddr & ~mask) | (mask & *clr)
*pix7addr = (*pix7addr & ~mask) | (mask & auxclr)
fin
mask = *(maskblk + 2)
mask = memmask[pix7]
if mask
^page1m
*pixaddr = (*pixaddr & ~mask) | (mask & *(clr + 2))
*pix7addr = (*pix7addr & ~mask) | (mask & memclr)
fin
end
def dhgrmode(mode)
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
@ -167,12 +242,29 @@ def dhgrmode(mode)
return mode
end
def dhgrtest#0
byte i
def dhgrTest#0
byte i, j
word pixblk
dhgrcolor(15)
for i = 0 to 139
dhgrplot(i, i)
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