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

Clamp code if needed

This commit is contained in:
David Schmenk
2024-11-20 11:00:51 -08:00
parent 5d90bd94b2
commit 995ea5f1cf
+14 -9
View File
@@ -10,8 +10,9 @@ const RED_MSK = $7C00
const BLU = 0
const GRN = 1
const RED = 2
const ERR_MAX = 32
const ERR_DIV = 2
const RGB_MAX = 63
const ERR_MAX = 64
const ERR_DIV = 3
byte[12] ntscCycle
byte[] ntscChroma
@@ -21,10 +22,10 @@ byte[] ntscChroma
//byte[] = 1, 77, 64 // BROWN
//byte[] = 64, 20, 128 // RED
// Imperical 0-63 B G R
byte[] = 31, 13, 16 // BLUE
byte[] = 16, 27, 0 // GREEN
byte[] = 1, 19, 16 // BROWN
byte[] = 16, 5, 32 // RED
byte[] = 32, 12, 16 // BLUE
byte[] = 16, 28, 0 // GREEN
byte[] = 0, 20, 16 // BROWN
byte[] = 16, 4, 32 // RED
// Ideal/simplified 0-63 B G R
//byte[] = 32, 16, 16 // BLUE
//byte[] = 16, 32, 0 // GREEN
@@ -47,6 +48,7 @@ byte[] = 16, 5, 32 // RED
//byte[] = 20, 40, 0 // GREEN
//byte[] = 0, 16, 16 // BROWN
//byte[] = 20, 0, 40 // RED
var rgberr // Running color error
def packrgb24(r, g, b)#1
@@ -95,6 +97,9 @@ def rgbpix(r, g, b, x, y)#0
r = r + errptr=>[RED] / ERR_DIV
g = g + errptr=>[GRN] / ERR_DIV
b = b + errptr=>[BLU] / ERR_DIV
//r = min(RGB_MAX, max(-RGB_MAX, r))
//g = min(RGB_MAX, max(-RGB_MAX, g))
//b = min(RGB_MAX, max(-RGB_MAX, b))
pr = 0
pg = 0
pb = 0
@@ -137,9 +142,9 @@ def rgbpix(r, g, b, x, y)#0
ntscCycle[i+BLU] = 0
fin
// Propogate error down and forward
r = min(ERR_MAX, max(-ERR_MAX, r))
g = min(ERR_MAX, max(-ERR_MAX, g))
b = min(ERR_MAX, max(-ERR_MAX, b))
//r = min(ERR_MAX, max(-ERR_MAX, r))
//g = min(ERR_MAX, max(-ERR_MAX, g))
//b = min(ERR_MAX, max(-ERR_MAX, b))
errptr=>[RED] = r
errptr=>[GRN] = g
errptr=>[BLU] = b