1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2025-01-21 17:31:31 +00:00

Rename RACECAR to reflect RGB

This commit is contained in:
David Schmenk 2024-11-20 14:55:08 -08:00
parent 995ea5f1cf
commit dd8e38a692
3 changed files with 161 additions and 52 deletions

View File

@ -113,6 +113,7 @@ 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
cp samplesrc/RACECAR.RGB.BIN prodos/demos/apple2/dcgr
cp rel/apple/DCGRRGB#FE1000 prodos/demos/apple2/dcgr/DCGRRGB.REL
mkdir prodos/demos/apple2/spiders

File diff suppressed because one or more lines are too long

View File

@ -1,55 +1,57 @@
include "inc/cmdsys.plh"
include "inc/dcgrlib.plh"
include "inc/dcgrutils.plh"
include "inc/args.plh"
include "inc/fileio.plh"
sysflags resxtxt1|reshgr1|resxhgr1
const BLU_MSK = $001F
const GRN_MSK = $03E0
const RED_MSK = $7C00
const BLU = 0
const RED = 0
const GRN = 1
const RED = 2
const BLU = 2
const RGB_MAX = 63
const ERR_MAX = 64
const ERR_DIV = 3
byte[12] ntscCycle
const ERR_DIV = 2
byte[] ntscChroma
// Imperical 0-255 B G R
//byte[] = 127, 51, 64 // BLUE
//byte[] = 64, 108, 0 // GREEN
//byte[] = 1, 77, 64 // BROWN
//byte[] = 64, 20, 128 // RED
// Imperical 0-63 B G R
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
//byte[] = 0, 16, 16 // BROWN
//byte[] = 16, 0, 32 // RED
// Test 0-63 B G R
//byte[] = 63, 0, 0 // BLUE
// Imperical 0-255 R G B
//byte[] = 64, 51, 127 // BLUE
//byte[] = 0, 108, 64 // GREEN
//byte[] = 64, 77, 1 // BROWN
//byte[] = 128, 20, 64 // RED
// Imperical 0-63 R G B
byte[] = 16, 12, 32 // BLUE
byte[] = 0, 28, 16 // GREEN
byte[] = 16, 20, 0 // BROWN
byte[] = 32, 4, 16 // RED
// Ideal/simplified 0-63 R G B
//byte[] = 16, 16, 32 // BLUE
//byte[] = 0, 32, 16 // GREEN
//byte[] = 16, 16, 0 // BROWN
//byte[] = 32, 0, 16 // RED
// Test 0-63 R G B
//byte[] = 0, 0, 63 // BLUE
//byte[] = 0, 63, 0 // GREEN
//byte[] = 0, 16, 16 // BROWN
//byte[] = 0, 0, 63 // RED
//byte[] = 63, 28, 32 // BLUE
//byte[] = 31, 56, 0 // GREEN
//byte[] = 0, 35, 31 // BROWN
//byte[] = 32, 7, 63 // RED
//byte[] = 63, 31, 32 // BLUE
//byte[] = 31, 63, 0 // GREEN
//byte[] = 0, 32, 31 // BROWN
//byte[] = 32, 0, 63 // RED
//byte[] = 40, 24, 24 // BLUE
//byte[] = 20, 40, 0 // GREEN
//byte[] = 0, 16, 16 // BROWN
//byte[] = 20, 0, 40 // RED
var rgberr // Running color error
//byte[] = 16, 16, 0 // BROWN
//byte[] = 63, 0, 0 // RED
//byte[] = 32, 28, 63 // BLUE
//byte[] = 0, 56, 31 // GREEN
//byte[] = 31, 35, 0 // BROWN
//byte[] = 63, 7, 32 // RED
//byte[] = 32, 31, 63 // BLUE
//byte[] = 0, 63, 31 // GREEN
//byte[] = 31, 32, 0 // BROWN
//byte[] = 63, 0, 32 // RED
//byte[] = 24, 24, 40 // BLUE
//byte[] = 0, 40, 20 // GREEN
//byte[] = 16, 16, 20 // BROWN
//byte[] = 40, 0, 20 // RED
byte[12] ntscCycle
var rgbErr // Running color error array
var arg
def packrgb24(r, g, b)#1
return (b >> 2) | ((g & $F8) << 2) | ((r & $F8) << 7)
@ -84,7 +86,7 @@ def dotprod(x1, y1, z1, x2, y2, z2)
return x1*x2 + y1*y2 + z1*z2
end
def rgbpix(r, g, b, x, y)#0
def rgbPix(r, g, b, x, y)#0
var errptr
var pr, pg, pb
var nr, ng, nb
@ -93,7 +95,7 @@ def rgbpix(r, g, b, x, y)#0
byte i
// Error propogation
errptr = rgberr + x * 3 * 2
errptr = rgbErr + x * 3 * 2
r = r + errptr=>[RED] / ERR_DIV
g = g + errptr=>[GRN] / ERR_DIV
b = b + errptr=>[BLU] / ERR_DIV
@ -154,16 +156,30 @@ def rgbpix(r, g, b, x, y)#0
errptr=>[BLU] = b + errptr=>[BLU]
end
def rgbInit#0
dcgrMode(0)
// Init error propogation array
rgbErr = heapalloc(561 * 3 * 2)
memset(rgberr, 0, 560 * 3 * 2)
rgberr=>[RED] = -1
rgberr=>[GRN] = -1
rgberr=>[BLU] = -1
end
def rgbExit#0
dcgrMode(-1)
end
def rgb3Spans(rs, gs, bs, re, ge, be, rm, gm, bm, y)#0
var i, j
memset(@ntscCycle, 0, 12)
for j = y to y + 2
for i = 0 to 63
rgbpix((i>>rs)|re, (i>>gs)|ge, (i>>bs)|be, i, j)
rgbPix((i>>rs)|re, (i>>gs)|ge, (i>>bs)|be, i, j)
next
for i = 64 to 127
rgbpix(rm, gm, bm, i, j)
rgbPix(rm, gm, bm, i, j)
next
next
end
@ -171,13 +187,7 @@ end
def rgbTest#0
var i
// Init error propogation array
rgberr = heapalloc(561 * 3 * 2)
memset(rgberr, 0, 560 * 3 * 2)
rgberr=>[RED] = -1
rgberr=>[GRN] = -1
rgberr=>[BLU] = -1
rgbInit
rgb3Spans(0,5,5, 0, 0, 0, 63, 0, 0, 0)
rgb3Spans(5,0,5, 0, 0, 0, 0,63, 0, 3)
rgb3Spans(5,5,0, 0, 0, 0, 0, 0,63, 6)
@ -189,10 +199,59 @@ def rgbTest#0
rgb3Spans(5,5,5, 32,32,32, 32,32,32, 24)
rgb3Spans(5,5,5, 48,48,48, 48,48,48, 27)
rgb3Spans(5,5,5, 63,63,63, 63,63,63, 30)
getc
rgbExit
end
dcgrMode(0)
def rgbImport(filestr)#0
byte refnum, r, g, b
var i, j
var rgbScanline, rgbptr
refnum = fileio:open(filestr)
if refnum
rgbScanline = heapalloc(560 * 3)
if rgbScanline
rgbInit
for j = 0 to 191
fileio:read(refnum, rgbScanline, 560 * 3)
rgbptr = rgbScanline
for i = 0 to 559
r = rgbptr->RED >> 3
g = rgbptr->GRN >> 3
b = rgbptr->BLU >> 3
rgbptr = rgbptr + 3
rgbPix(r, g, b, i, j)
next
next
fileio:close(refnum)
getc
rgbExit
fin
else
puts("Unable to read: "); puts(arg); putln
fin
end
arg = argNext(argFirst)
if ^arg
if ^(arg + 1) == '-'
if toupper(^(arg + 2)) == 'T'
rgbTest
fin
arg = argNext(arg)
fin
if ^arg
rgbImport(arg)
arg = argNext(arg)
if ^arg
if screenWrite(arg)
puts("Unable to write: "); puts(arg); putln
fin
fin
return 0
fin
fin
puts("Usage: DCGRRGB [-T] RGBFILE [DHGRFILE]\n")
rgbTest
getc
dcgrMode(-1)
done