mirror of
https://github.com/dschmenk/PLASMA.git
synced 2025-01-07 00:29:34 +00:00
Add pixel read routine
This commit is contained in:
parent
27da5dca92
commit
50a4fbc230
Binary file not shown.
@ -28,6 +28,7 @@ import dcgrlib
|
||||
|
||||
predef dcgrColor(c)#0
|
||||
predef dcgrPlot(x, y)#0
|
||||
predef dcgrPixel(x, y)#1
|
||||
predef dcgrHLin(x1, x2, y)#0
|
||||
predef dcgrVLin(y1, y2, x)#0
|
||||
predef dcgrBitMap(x, y, bitw, bith, bitptr)#0
|
||||
|
@ -6,6 +6,7 @@ import dcgrutils
|
||||
predef dcgrBoldStr(clr, x, y, strptr)#0
|
||||
predef dcgrFont(font)#0
|
||||
predef dcgrRect(x, y, w, h)#0
|
||||
predef dcgrGetPixMap(x, y, w, h)#1
|
||||
predef dhgrSet(dhx, y)#0
|
||||
predef dhgrUnset(dhx, y)#0
|
||||
predef spriteRead(filestr)#5
|
||||
|
@ -2122,6 +2122,38 @@ export def dcgrMemBl7Tile(x7, y, memptr, memspan, tileptr)#0
|
||||
next
|
||||
end
|
||||
//
|
||||
// Read pixel and return color
|
||||
//
|
||||
export def dcgrPixel(x, y)#1
|
||||
byte x7, m7, i
|
||||
word[2] pix7, clr7
|
||||
word amask, mmask
|
||||
|
||||
x7 = divmod7[x] >> 3
|
||||
if dcgrSurface // Memory
|
||||
dcgrMemBl7Mem(x7, y, surfWidth, surfHeight, surfPtr, surfSpan, 1, 1, @pix7)
|
||||
else // Screen
|
||||
dcgrScrBl7Mem(x7, y, 1, 1, @pix7, 4)
|
||||
fin
|
||||
m7 = divmod7[x] & $07
|
||||
amask = auxclrmsk[m7]
|
||||
if amask & $80; amask = (amask & $7F) << 8; fin
|
||||
mmask = memclrmsk[m7]
|
||||
if mmask & $80; mmask = (mmask & $7F) << 8; fin
|
||||
pix7[0] = pix7[0] & amask
|
||||
pix7[1] = pix7[1] & mmask
|
||||
for i = 0 to 15
|
||||
// clr7[0] = (auxclrsl[i] | (auxclrsh[i] << 8)) & amask
|
||||
// clr7[1] = (memclrsl[i] | (memclrsh[i] << 8)) & mmask
|
||||
// if pix7[0] == clr7[0] and pix7[1] == clr7[1]
|
||||
if pix7[0] == (auxclrsl[i] | (auxclrsh[i] << 8)) & amask
|
||||
if pix7[1] == (memclrsl[i] | (memclrsh[i] << 8)) & mmask
|
||||
return i // Color match
|
||||
fin; fin
|
||||
next
|
||||
return 15
|
||||
end
|
||||
//
|
||||
// Hack to extend parameters for memory functions
|
||||
//
|
||||
def extPlotMem#0
|
||||
|
@ -126,6 +126,21 @@ export def dcgrRect(x, y, w, h)#0
|
||||
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 = dcgrPixel(i+x, j+y) | (dcgrPixel(i+x+1, j+y) << 4)
|
||||
pixptr++
|
||||
next
|
||||
next
|
||||
return pixmap
|
||||
end
|
||||
export def dhgrSet(dhx, y)#0
|
||||
dcgrColor(dhgrPix[dhx & $03])
|
||||
dcgrOp(OP_OR)
|
||||
|
@ -112,6 +112,7 @@ cp rel/apple/DGRTEST#FE1000 prodos/demos/apple2/DGRTEST.REL
|
||||
mkdir prodos/demos/apple2/dcgr
|
||||
cp rel/apple/DCGRTEST#FE1000 prodos/demos/apple2/dcgr/DCGRTEST.REL
|
||||
cp samplesrc/ENT.* prodos/demos/apple2/dcgr
|
||||
cp samplesrc/MONARCH.BIN prodos/demos/apple2/dcgr
|
||||
|
||||
mkdir prodos/demos/apple2/spiders
|
||||
cp rel/apple/SFM#FE1000 prodos/demos/apple2/spiders/SFM.REL
|
||||
|
BIN
src/samplesrc/MONARCH.BIN
Normal file
BIN
src/samplesrc/MONARCH.BIN
Normal file
Binary file not shown.
@ -122,7 +122,6 @@ def dcgrCompMask(offset)#0
|
||||
dcgrMemBl7(sprite7w, i * SPR_H, sprite7w, SPR_H, sprite7msk[i], sprite7span)
|
||||
next
|
||||
end
|
||||
|
||||
def readEnterprise#0
|
||||
var xorg, yorg, width, height, pixptr, t_ptr, f_ptr
|
||||
byte i
|
||||
@ -145,7 +144,6 @@ def readEnterprise#0
|
||||
f_ptr = f_ptr + 12
|
||||
next
|
||||
end
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// Test Harness //
|
||||
@ -159,10 +157,7 @@ def dhgrTest#0
|
||||
//
|
||||
dcgrSurfScr(OP_OR)
|
||||
setlineplot(@dhgrSet)
|
||||
for i = 0 to 191 step 4
|
||||
line(0, 0, 559, i)
|
||||
next
|
||||
for i = 559 downto 0 step 7
|
||||
for i = 559 downto 0 step 20
|
||||
line(0, 0, i, 191)
|
||||
next
|
||||
getc
|
||||
@ -441,6 +436,9 @@ end
|
||||
dcgrMode(0)
|
||||
dhgrTest
|
||||
screenRead("monarch")
|
||||
dcgrOp(OP_SRC)
|
||||
dcgrPixMap(10, 10, 20, 20, dcgrGetPixMap(60, 66, 20, 20))
|
||||
getc
|
||||
readEnterprise
|
||||
dcgrCompSprite(2)
|
||||
dcgrCompMask(2)
|
||||
|
Loading…
Reference in New Issue
Block a user