mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-12-25 15:30:03 +00:00
ecs: playfield decoder
This commit is contained in:
parent
e461ae41d9
commit
fbe07c33d2
@ -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,
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user