mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-10 23:04:04 +09:00
bias lighting (wut?) on playmov; gpu background is now 8bpp
This commit is contained in:
@@ -16,7 +16,7 @@ let o=[];for(let y=0;y<164;y++){
|
|||||||
let k=Math.round(r()*560/m)|0;
|
let k=Math.round(r()*560/m)|0;
|
||||||
o.push(k);graphics.setLineOffset(95+y,k*m);}
|
o.push(k);graphics.setLineOffset(95+y,k*m);}
|
||||||
// unhide screen
|
// unhide screen
|
||||||
graphics.setBackground(0,4,15);con.color_pair(239,255);
|
graphics.setBackground(0,68,255);con.color_pair(239,255);
|
||||||
for(let i=0;i<2560;i++)graphics.putSymbolAt(1+(i/80)|0,1+(i%80),0);
|
for(let i=0;i<2560;i++)graphics.putSymbolAt(1+(i/80)|0,1+(i%80),0);
|
||||||
// unscramble
|
// unscramble
|
||||||
let tmr=0;let n=560*2;while(n>0){
|
let tmr=0;let n=560*2;while(n>0){
|
||||||
@@ -36,7 +36,7 @@ for(let i=0;i<2560;i++)graphics.putSymbolAt(1+(i/80)|0,1+(i%80),239);
|
|||||||
// draw logo
|
// draw logo
|
||||||
for(let i=0;i<logo.length;i++){graphics.plotPixel(i%560,95+(i/560)|0,logo[i])}
|
for(let i=0;i<logo.length;i++){graphics.plotPixel(i%560,95+(i/560)|0,logo[i])}
|
||||||
// cover up bottom part with text characters (!)
|
// cover up bottom part with text characters (!)
|
||||||
graphics.setBackground(0,4,15);con.color_pair(14,255);
|
graphics.setBackground(0,68,255);con.color_pair(14,255);
|
||||||
for(let y=1;y<19;y++)for(let x=1;x<81;x++)graphics.putSymbolAt(y,x,32);
|
for(let y=1;y<19;y++)for(let x=1;x<81;x++)graphics.putSymbolAt(y,x,32);
|
||||||
for(let x=1;x<81;x++)graphics.putSymbolAt(19,x,220);
|
for(let x=1;x<81;x++)graphics.putSymbolAt(19,x,220);
|
||||||
for(let y=20;y<33;y++)for(let x=1;x<81;x++)graphics.putSymbolAt(y,x,219);
|
for(let y=20;y<33;y++)for(let x=1;x<81;x++)graphics.putSymbolAt(y,x,219);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ if (exec_args[1]) {
|
|||||||
|
|
||||||
serial.println(fo)
|
serial.println(fo)
|
||||||
|
|
||||||
graphics.setBackground(ba[0], ba[1], ba[2])
|
graphics.setBackground(ba[0]*16+ba[0], ba[1]*16+ba[1], ba[2]*16+ba[2])
|
||||||
_G.shell.usrcfg.textCol = fo
|
_G.shell.usrcfg.textCol = fo
|
||||||
con.color_pair(fo, 255)
|
con.color_pair(fo, 255)
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
|
|
||||||
const FBUF_SIZE = 560*448
|
const WIDTH = 560
|
||||||
|
const HEIGHT = 448
|
||||||
|
const FBUF_SIZE = WIDTH * HEIGHT
|
||||||
|
const AUTO_BGCOLOUR_CHANGE = true
|
||||||
const MAGIC = [0x1F, 0x54, 0x53, 0x56, 0x4D, 0x4D, 0x4F, 0x56]
|
const MAGIC = [0x1F, 0x54, 0x53, 0x56, 0x4D, 0x4D, 0x4F, 0x56]
|
||||||
|
|
||||||
|
|
||||||
@@ -68,6 +71,16 @@ audio.purgeQueue(0)
|
|||||||
audio.setPcmMode(0)
|
audio.setPcmMode(0)
|
||||||
audio.setMasterVolume(0, 255)
|
audio.setMasterVolume(0, 255)
|
||||||
|
|
||||||
|
function getRGBfromScr(x, y) {
|
||||||
|
let offset = y * WIDTH + x
|
||||||
|
let rg = sys.peek(-1048577 - offset)
|
||||||
|
let ba = sys.peek(-1310721 - offset)
|
||||||
|
|
||||||
|
return [(rg >>> 4) / 15.0, (rg & 15) / 15.0, (ba >>> 4) / 15.0]
|
||||||
|
}
|
||||||
|
|
||||||
|
let oldBgcol = [0.0, 0.0, 0.0]
|
||||||
|
|
||||||
renderLoop:
|
renderLoop:
|
||||||
while (seqread.getReadCount() < FILE_LENGTH) {
|
while (seqread.getReadCount() < FILE_LENGTH) {
|
||||||
let t1 = sys.nanoTime()
|
let t1 = sys.nanoTime()
|
||||||
@@ -94,6 +107,7 @@ while (seqread.getReadCount() < FILE_LENGTH) {
|
|||||||
}
|
}
|
||||||
// background colour packets
|
// background colour packets
|
||||||
else if (65279 == packetType) {
|
else if (65279 == packetType) {
|
||||||
|
AUTO_BGCOLOUR_CHANGE = false
|
||||||
let rgbx = seqread.readInt()
|
let rgbx = seqread.readInt()
|
||||||
graphics.setBackground(
|
graphics.setBackground(
|
||||||
(rgbx & 0xFF000000) >>> 24,
|
(rgbx & 0xFF000000) >>> 24,
|
||||||
@@ -120,6 +134,39 @@ while (seqread.getReadCount() < FILE_LENGTH) {
|
|||||||
gzip.decompFromTo(gzippedPtr, payloadLen, ipfbuf) // should return FBUF_SIZE
|
gzip.decompFromTo(gzippedPtr, payloadLen, ipfbuf) // should return FBUF_SIZE
|
||||||
decodefun(ipfbuf, -1048577, -1310721, width, height, (packetType & 255) == 5)
|
decodefun(ipfbuf, -1048577, -1310721, width, height, (packetType & 255) == 5)
|
||||||
|
|
||||||
|
|
||||||
|
// calculate bgcolour from the edges of the screen
|
||||||
|
if (AUTO_BGCOLOUR_CHANGE) {
|
||||||
|
let samples = []
|
||||||
|
for (let x = 8; x < 560; x+=32) {
|
||||||
|
samples.push(getRGBfromScr(x, 3))
|
||||||
|
samples.push(getRGBfromScr(x, 445))
|
||||||
|
}
|
||||||
|
for (let y = 29; y < 448; y+=26) {
|
||||||
|
samples.push(getRGBfromScr(8, y))
|
||||||
|
samples.push(getRGBfromScr(552, y))
|
||||||
|
}
|
||||||
|
|
||||||
|
let out = [0.0, 0.0, 0.0]
|
||||||
|
samples.forEach(rgb=>{
|
||||||
|
out[0] += rgb[0]
|
||||||
|
out[1] += rgb[1]
|
||||||
|
out[2] += rgb[2]
|
||||||
|
})
|
||||||
|
out[0] = out[0] / samples.length / 2.0 // darken a bit
|
||||||
|
out[1] = out[1] / samples.length / 2.0
|
||||||
|
out[2] = out[2] / samples.length / 2.0
|
||||||
|
|
||||||
|
let bgr = (oldBgcol[0]*5 + out[0]) / 6.0
|
||||||
|
let bgg = (oldBgcol[1]*5 + out[1]) / 6.0
|
||||||
|
let bgb = (oldBgcol[2]*5 + out[2]) / 6.0
|
||||||
|
|
||||||
|
oldBgcol = [bgr, bgg, bgb]
|
||||||
|
|
||||||
|
graphics.setBackground(Math.round(bgr * 255), Math.round(bgg * 255), Math.round(bgb * 255))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// defer audio playback until a first frame is sent
|
// defer audio playback until a first frame is sent
|
||||||
if (!audioFired) {
|
if (!audioFired) {
|
||||||
audio.play(0)
|
audio.play(0)
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ From the start of the memory space:
|
|||||||
250880 bytes
|
250880 bytes
|
||||||
Framebuffer
|
Framebuffer
|
||||||
3 bytes
|
3 bytes
|
||||||
Initial background (and the border) colour RGB, of which only the lower 4 bits per each channel are used
|
Initial background (and the border) colour RGB, 8 bits per channel
|
||||||
1 byte
|
1 byte
|
||||||
command (writing to this memory address changes the status)
|
command (writing to this memory address changes the status)
|
||||||
1: reset palette to default
|
1: reset palette to default
|
||||||
|
|||||||
@@ -190,6 +190,9 @@ class VM(
|
|||||||
|
|
||||||
fun peek(addr:Long): Byte? {
|
fun peek(addr:Long): Byte? {
|
||||||
val (memspace, offset) = translateAddr(addr)
|
val (memspace, offset) = translateAddr(addr)
|
||||||
|
|
||||||
|
// println("peek $addr -> ${offset}@${memspace?.javaClass?.canonicalName}")
|
||||||
|
|
||||||
return if (memspace == null)
|
return if (memspace == null)
|
||||||
null
|
null
|
||||||
else if (memspace is UnsafePtr) {
|
else if (memspace is UnsafePtr) {
|
||||||
|
|||||||
@@ -192,9 +192,9 @@ open class GraphicsAdapter(private val assetsRoot: String, val vm: VM, val confi
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (theme.contains("color")) {
|
if (theme.contains("color")) {
|
||||||
unusedArea[0] = 2
|
unusedArea[0] = 32
|
||||||
unusedArea[1] = 3
|
unusedArea[1] = 48
|
||||||
unusedArea[2] = 4
|
unusedArea[2] = 64
|
||||||
}
|
}
|
||||||
|
|
||||||
setCursorPos(0, 0)
|
setCursorPos(0, 0)
|
||||||
@@ -202,7 +202,7 @@ open class GraphicsAdapter(private val assetsRoot: String, val vm: VM, val confi
|
|||||||
|
|
||||||
override fun peek(addr: Long): Byte? {
|
override fun peek(addr: Long): Byte? {
|
||||||
val adi = addr.toInt()
|
val adi = addr.toInt()
|
||||||
if (framebuffer2 != null) {
|
if (framebuffer2 != null && addr >= 262144) {
|
||||||
return when (addr - 262144) {
|
return when (addr - 262144) {
|
||||||
in 0 until 250880 -> framebuffer2[addr - 262144]
|
in 0 until 250880 -> framebuffer2[addr - 262144]
|
||||||
else -> null
|
else -> null
|
||||||
@@ -982,9 +982,10 @@ open class GraphicsAdapter(private val assetsRoot: String, val vm: VM, val confi
|
|||||||
private var glowDecay = config.decay
|
private var glowDecay = config.decay
|
||||||
private var decayColor = Color(1f, 1f, 1f, 1f - glowDecay)
|
private var decayColor = Color(1f, 1f, 1f, 1f - glowDecay)
|
||||||
|
|
||||||
fun getBackgroundColour() = Color(unusedArea[0].toInt().and(15).toFloat() / 15f,
|
fun getBackgroundColour() = Color(
|
||||||
unusedArea[1].toInt().and(15).toFloat() / 15f,
|
unusedArea[0].toUint() / 255f,
|
||||||
unusedArea[2].toInt().and(15).toFloat() / 15f, 1f)
|
unusedArea[1].toUint() / 255f,
|
||||||
|
unusedArea[2].toUint() / 255f, 1f)
|
||||||
|
|
||||||
private val isRefSize = (WIDTH == 560 && HEIGHT == 448)
|
private val isRefSize = (WIDTH == 560 && HEIGHT == 448)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user