mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-07 19:51:51 +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;
|
||||
o.push(k);graphics.setLineOffset(95+y,k*m);}
|
||||
// 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);
|
||||
// unscramble
|
||||
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
|
||||
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 (!)
|
||||
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 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);
|
||||
|
||||
@@ -38,7 +38,7 @@ if (exec_args[1]) {
|
||||
|
||||
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
|
||||
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]
|
||||
|
||||
|
||||
@@ -68,6 +71,16 @@ audio.purgeQueue(0)
|
||||
audio.setPcmMode(0)
|
||||
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:
|
||||
while (seqread.getReadCount() < FILE_LENGTH) {
|
||||
let t1 = sys.nanoTime()
|
||||
@@ -94,6 +107,7 @@ while (seqread.getReadCount() < FILE_LENGTH) {
|
||||
}
|
||||
// background colour packets
|
||||
else if (65279 == packetType) {
|
||||
AUTO_BGCOLOUR_CHANGE = false
|
||||
let rgbx = seqread.readInt()
|
||||
graphics.setBackground(
|
||||
(rgbx & 0xFF000000) >>> 24,
|
||||
@@ -120,6 +134,39 @@ while (seqread.getReadCount() < FILE_LENGTH) {
|
||||
gzip.decompFromTo(gzippedPtr, payloadLen, ipfbuf) // should return FBUF_SIZE
|
||||
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
|
||||
if (!audioFired) {
|
||||
audio.play(0)
|
||||
|
||||
Reference in New Issue
Block a user