1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-04 20:05:57 +00:00

ecs: playfield decoder

This commit is contained in:
Steven Hugg 2022-02-14 18:09:14 -06:00
parent e461ae41d9
commit fbe07c33d2
2 changed files with 25 additions and 0 deletions

View File

@ -63,6 +63,27 @@ export class VCSSpriteDecoder extends LineDecoder {
}
}
export class VCSPlayfieldDecoder extends LineDecoder {
parse() {
let height = this.lines.length;
let pf = new Uint32Array(height);
for (let i=0; i<height; i++) {
let toks = this.lines[height - 1 - i];
this.assertTokens(toks, 1);
let pf0 = this.decodeBits(toks[0].substring(0,4), 4, false) << 4;
let pf1 = this.decodeBits(toks[0].substring(4,12), 8, true);
let pf2 = this.decodeBits(toks[0].substring(12,20), 8, false);
pf[i] = (pf0 << 0) | (pf1 << 8) | (pf2 << 16);
}
return {
properties: {
pf
}
}
}
}
export class VCSVersatilePlayfieldDecoder extends LineDecoder {
parse() {
let height = this.lines.length;
@ -138,6 +159,7 @@ export function newDecoder(name: string, text: string) : LineDecoder | undefined
const DECODERS = {
'vcs_sprite': VCSSpriteDecoder,
'vcs_playfield': VCSPlayfieldDecoder,
'vcs_versatile': VCSVersatilePlayfieldDecoder,
'vcs_bitmap48': VCSBitmap48Decoder,
}

View File

@ -1055,6 +1055,9 @@ export class EntityScope implements SourceLocated {
for (let a of range.access) {
segment.allocateBytes(a.symbol, entcount);
let ofs = segment.getByteOffset(range, a, e.id);
// TODO: this happens if you forget a const field on an object?
if (e.id < range.elo) throw new ECSError(c.name + ' ' + f.name);
if (typeof segment.initdata[ofs] !== 'undefined') throw new ECSError(ofs+"");
segment.initdata[ofs] = (v >> a.bit) & 0xff;
}
}