From b4dbcb83eb537b95f212dd3cce7b2e66758ff0e9 Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Thu, 17 Feb 2022 09:58:13 -0600 Subject: [PATCH] ecs: temp symbols, not equates --- src/common/ecs/ecs.ts | 16 ++++++++++------ test/ecs/score.txt | 4 ++-- test/ecs/sprites.txt | 14 +++++++------- test/ecs/sprites1.txt | 14 +++++++------- test/ecs/superman.txt | 6 +++--- test/ecs/titles.txt | 2 +- test/ecs/vcs1.txt | 2 +- test/ecs/vcslib.txt | 2 +- 8 files changed, 32 insertions(+), 28 deletions(-) diff --git a/src/common/ecs/ecs.ts b/src/common/ecs/ecs.ts index 1129251f..974778f2 100644 --- a/src/common/ecs/ecs.ts +++ b/src/common/ecs/ecs.ts @@ -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}`; } } } diff --git a/test/ecs/score.txt b/test/ecs/score.txt index 173c7927..8bd03d7f 100644 --- a/test/ecs/score.txt +++ b/test/ecs/score.txt @@ -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 diff --git a/test/ecs/sprites.txt b/test/ecs/sprites.txt index d9f5d0b8..7b49ceef 100644 --- a/test/ecs/sprites.txt +++ b/test/ecs/sprites.txt @@ -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 diff --git a/test/ecs/sprites1.txt b/test/ecs/sprites1.txt index 5d8a5ac2..d67ece2f 100644 --- a/test/ecs/sprites1.txt +++ b/test/ecs/sprites1.txt @@ -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 diff --git a/test/ecs/superman.txt b/test/ecs/superman.txt index d3a6d9c1..af4c5257 100644 --- a/test/ecs/superman.txt +++ b/test/ecs/superman.txt @@ -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 diff --git a/test/ecs/titles.txt b/test/ecs/titles.txt index 7e030e86..67482d52 100644 --- a/test/ecs/titles.txt +++ b/test/ecs/titles.txt @@ -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 diff --git a/test/ecs/vcs1.txt b/test/ecs/vcs1.txt index 2f038c3f..d5908d83 100644 --- a/test/ecs/vcs1.txt +++ b/test/ecs/vcs1.txt @@ -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 diff --git a/test/ecs/vcslib.txt b/test/ecs/vcslib.txt index c317ee78..9a7c50e6 100644 --- a/test/ecs/vcslib.txt +++ b/test/ecs/vcslib.txt @@ -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