1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2025-01-02 12:33:07 +00:00

Avoid reading pixel back from screen - just track it

This commit is contained in:
David Schmenk 2024-12-14 12:45:16 -08:00
parent f3089caba6
commit 512c307531

View File

@ -13,6 +13,7 @@ const BLU = 2
const RED_ANGLE = 104
const GREEN_ANGLE = 241
const BLUE_ANGLE = 347
const GREY_CHROMA = 32 * 4 / 3
var sin90[] // first 90 degrees of sin in fixed s.15 format
var = 0, 571, 1143, 1714, 2285, 2855, 3425, 3993
@ -33,6 +34,7 @@ byte[256] gamma = 0, 2, 0 // Gamma correction
var brightness = 0
var contrast = 0
var tint = 20
var greyChroma = GREY_CHROMA
byte errDiv = 3
var rgbErr // Running color error array
var arg
@ -197,7 +199,7 @@ def rgbInit#0
puti(ntscChroma[i*3 + BLU]); putln
next
fin
// Make up for additional 1/4 chroma cycle
// Make up for additional 1/4 chroma cycle in color match
for i = 0 to 11
ntscChroma[i] = (ntscChroma[i] * 4) / 3
next
@ -277,7 +279,7 @@ def rgbExit#0
end
def rgbImportExport(rgbfile, dhgrfile)#0
byte refnum
byte refnum, chromabits
var i, j
var rgbScanline, rgbptr, errptr
@ -289,24 +291,26 @@ def rgbImportExport(rgbfile, dhgrfile)#0
rgbInit
for j = 0 to 191
fileio:read(refnum, rgbScanline, 560 * 3)
memset(@ntscCycle, 72, 24) // Reset chroma cycle
memset(@ntscCycle, greyChroma, 24) // Reset chroma cycle
rgbptr = rgbScanline
errptr = rgbErr
for i = 0 to 559
// Calc best match
chromabits = chromabits >> 1
if rgbPix(rgbptr, errptr, i & 3)
dhgrSet(i, j)
chromabits = chromabits | $08
fin
// Map GREY1 -> GREY2
if (i & 3) == 3 and dcgrGetPixel(i >> 2, j) == 5
dhgrOp(OP_SRC)
dcgrColor(10)
dcgrPixel(i >> 2, j)
memset(@ntscCycle, 0, 24)
memcpy(@ntscCycle + 0, @ntscChroma + 0, 6)
//memcpy(@ntscCycle + 6, @ntscChroma + 6, 6)
memcpy(@ntscCycle + 12, @ntscChroma + 12, 6)
//memcpy(@ntscCycle + 18, @ntscChroma + 18, 6)
if (i & 3) == 3
if chromabits == $0A // Bits are in reverse order from DCGR color value
dhgrOp(OP_SRC)
dcgrColor(CLR_GREY2)
dcgrPixel(i >> 2, j)
memset(@ntscCycle, greyChroma, 24) // Grey chroma cycle
elsif chromabits == $05
memset(@ntscCycle, greyChroma, 24) // Grey chroma cycle
fin
fin
rgbptr = rgbptr + 3
errptr = errptr + 3 * 2
@ -380,6 +384,12 @@ if ^arg
gamma[1] = atoi(arg + 2)
fin
break
is 'N' // Set neutral chroma value
if ^arg > 2
^(arg + 2) = ^arg - 2
greyChroma = atoi(arg + 2)
fin
break
is 'T' // Adjust tint
if ^arg > 2
^(arg + 2) = ^arg - 2