ecs: temp symbols, not equates

This commit is contained in:
Steven Hugg 2022-02-17 09:58:13 -06:00
parent 75f36d95dc
commit b4dbcb83eb
8 changed files with 32 additions and 28 deletions

View File

@ -386,14 +386,17 @@ class DataSegment {
let ofs = this.symbols[name];
if (ofs == null) {
ofs = this.size;
this.symbols[name] = ofs;
if (!this.ofs2sym.has(ofs))
this.ofs2sym.set(ofs, []);
this.ofs2sym.get(ofs)?.push(name);
this.declareSymbol(name, ofs);
this.size += bytes;
}
return ofs;
}
declareSymbol(name: string, ofs: number) {
this.symbols[name] = ofs;
if (!this.ofs2sym.has(ofs))
this.ofs2sym.set(ofs, []);
this.ofs2sym.get(ofs)?.push(name);
}
// TODO: optimize shared data
allocateInitData(name: string, bytes: Uint8Array) {
let ofs = this.allocateBytes(name, bytes.length);
@ -1311,11 +1314,12 @@ export class EntityScope implements SourceLocated {
if (!pack.pack()) console.log('cannot pack temporary local vars'); // TODO
//console.log('tempvars', pack);
if (bssbin.extents.right > 0) {
this.bss.allocateBytes('TEMP', bssbin.extents.right);
let tempofs = this.bss.allocateBytes('TEMP', bssbin.extents.right);
for (let b of pack.boxes) {
let inst : SystemInstance = (b as any).inst;
//console.log(inst.system.name, b.box?.left);
this.bss.equates[this.dialect.tempLabel(inst)] = `TEMP+${b.box?.left}`;
if (b.box) this.bss.declareSymbol(this.dialect.tempLabel(inst), tempofs + b.box.left);
//this.bss.equates[this.dialect.tempLabel(inst)] = `TEMP+${b.box?.left}`;
}
}
}

View File

@ -16,6 +16,7 @@ BCDScore2_digits_b0:
.res 1
.res 1
TEMP:
Kernel6Digit__2__tmp:
.res 1
.res 1
.res 1
@ -31,11 +32,10 @@ TEMP:
.res 1
.res 1
.res 1
Kernel2Digit__4__tmp:
.res 1
.res 1
.res 1
Kernel6Digit__2__tmp = TEMP+0
Kernel2Digit__4__tmp = TEMP+15
.code
Main__INITDATA:
.byte 86

View File

@ -26,6 +26,13 @@ SpriteSlot_sprite_b0:
.res 1
.res 1
TEMP:
Kernel2Sprite__2__tmp:
Joystick__3__tmp:
.res 1
SpriteShuffler__8__tmp:
.res 1
.res 1
SpriteHider__9__tmp:
.res 1
.res 1
.res 1
@ -36,13 +43,6 @@ TEMP:
.res 1
.res 1
.res 1
.res 1
.res 1
.res 1
Kernel2Sprite__2__tmp = TEMP+0
Joystick__3__tmp = TEMP+0
SpriteShuffler__8__tmp = TEMP+1
SpriteHider__9__tmp = TEMP+3
.code
KernelSection_lines_b0:
.byte 192

View File

@ -26,6 +26,13 @@ HasColormap_colormap_b0:
.res 1
.res 1
TEMP:
Kernel2Sprite__2__tmp:
Joystick__3__tmp:
.res 1
SpriteShuffler__8__tmp:
.res 1
.res 1
SpriteHider__9__tmp:
.res 1
.res 1
.res 1
@ -36,13 +43,6 @@ TEMP:
.res 1
.res 1
.res 1
.res 1
.res 1
.res 1
Kernel2Sprite__2__tmp = TEMP+0
Joystick__3__tmp = TEMP+0
SpriteShuffler__8__tmp = TEMP+1
SpriteHider__9__tmp = TEMP+3
.code
KernelSection_lines_b0:
.byte 192

View File

@ -28,6 +28,8 @@ Room_gfx_b0:
.res 1
.res 1
TEMP:
Kernel2Sprite__2__tmp:
Joystick__3__tmp:
.res 1
.res 1
.res 1
@ -41,11 +43,9 @@ TEMP:
.res 1
.res 1
.res 1
VersatilePlayfield__10__tmp:
.res 1
.res 1
Kernel2Sprite__2__tmp = TEMP+0
Joystick__3__tmp = TEMP+0
VersatilePlayfield__10__tmp = TEMP+13
.code
KernelSection_lines_b0:
.byte 192

View File

@ -1,9 +1,9 @@
.scope Main
.zeropage
TEMP:
Kernel48Pixel__2__tmp:
.res 1
.res 1
Kernel48Pixel__2__tmp = TEMP+0
.code
KernelSection_lines_b0:
.byte 10

View File

@ -4,8 +4,8 @@ PFColor_pfcolor_b0:
.res 1
.res 1
TEMP:
Local__6__tmp:
.res 1
Local__6__tmp = TEMP+0
.code
KernelSection_lines_b0:
.byte 2

View File

@ -4,8 +4,8 @@ PFColor_pfcolor_b0:
.res 1
.res 1
TEMP:
Local__6__tmp:
.res 1
Local__6__tmp = TEMP+0
.code
KernelSection_lines_b0:
.byte 2