From c9e75ae77d26d802e408c6a137cf4d5764ae593c Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Wed, 23 Feb 2022 11:16:47 -0600 Subject: [PATCH] ecs: EVENT__xxx defines --- src/common/ecs/ecs.ts | 8 ++++++++ test/ecs/narrow1.txt | 1 + test/ecs/score.txt | 17 +++++++++++++++++ test/ecs/sprites.txt | 16 ++++++++++++++++ test/ecs/sprites1.txt | 17 +++++++++++++++++ test/ecs/superman.txt | 20 ++++++++++++++++++++ test/ecs/titles.txt | 11 +++++++++++ test/ecs/vcs1.txt | 10 ++++++++++ test/ecs/vcslib.txt | 11 +++++++++++ 9 files changed, 111 insertions(+) diff --git a/src/common/ecs/ecs.ts b/src/common/ecs/ecs.ts index 038685f3..8c3b0fef 100644 --- a/src/common/ecs/ecs.ts +++ b/src/common/ecs/ecs.ts @@ -353,6 +353,10 @@ export class Dialect_CA65 { equate(symbol: string, value: string): string { return `${symbol} = ${value}`; } + define(symbol: string, value?: string): string { + if (value) return `.define ${symbol} ${value}`; + else return `.define ${symbol}`; + } call(symbol: string) { return ` jsr ${symbol}`; } @@ -1008,6 +1012,7 @@ class ActionEval { //eidofs -= xreg.offset(); //eidofs -= int.entities[0].id - xreg.elo; eidofs = xreg.elo - range.elo; + // TODO? if (xreg.ehi > range.ehi) throw new ECSError(`field "${field.name}" could overflow`, action); } else if (yreg && (int = yreg.eset?.intersection(qr))) { ir = yreg.eset; //eidofs -= yreg.offset(); @@ -1716,6 +1721,9 @@ export class EntityManager { }) } exportToFile(file: SourceFileExport) { + for (let event of Object.keys(this.event2systems)) { + file.line(this.dialect.equate(`EVENT__${event}`, '1')) + } for (let scope of Object.values(this.topScopes)) { if (!scope.isDemo || scope.filePath == this.mainPath) { scope.dump(file); diff --git a/test/ecs/narrow1.txt b/test/ecs/narrow1.txt index f21762c1..b7f3c3c9 100644 --- a/test/ecs/narrow1.txt +++ b/test/ecs/narrow1.txt @@ -1,3 +1,4 @@ +EVENT__start = 1 .scope Main .zeropage Xpos_x_b0: diff --git a/test/ecs/score.txt b/test/ecs/score.txt index 9a90a1a1..e9dea9b1 100644 --- a/test/ecs/score.txt +++ b/test/ecs/score.txt @@ -1,3 +1,20 @@ +EVENT__main_init = 1 +EVENT__start = 1 +EVENT__nextframe = 1 +EVENT__resetswitch = 1 +EVENT__postframe = 1 +EVENT__SetHorizPos = 1 +EVENT__preframe = 1 +EVENT__kernel = 1 +EVENT__kerneldraw = 1 +EVENT__kernelsetup = 1 +EVENT__joybutton = 1 +EVENT__FontTable = 1 +EVENT__compute2digit = 1 +EVENT__fetchdigit = 1 +EVENT__FontTablePF = 1 +EVENT__FontTablePFFancy = 1 +EVENT__AddBCD4 = 1 .scope Main .zeropage BCDScore6_digits_b0: diff --git a/test/ecs/sprites.txt b/test/ecs/sprites.txt index 6095ad23..4f96cf7b 100644 --- a/test/ecs/sprites.txt +++ b/test/ecs/sprites.txt @@ -1,3 +1,19 @@ +EVENT__main_init = 1 +EVENT__start = 1 +EVENT__nextframe = 1 +EVENT__resetswitch = 1 +EVENT__postframe = 1 +EVENT__SetHorizPos = 1 +EVENT__preframe = 1 +EVENT__kernel = 1 +EVENT__kerneldraw = 1 +EVENT__kernelsetup = 1 +EVENT__joybutton = 1 +EVENT__scanline = 1 +EVENT__joyleft = 1 +EVENT__joyright = 1 +EVENT__joyup = 1 +EVENT__joydown = 1 .scope Main .zeropage HasBitmap_bitmap_b0: diff --git a/test/ecs/sprites1.txt b/test/ecs/sprites1.txt index fb6ce8c8..9ab7c0fe 100644 --- a/test/ecs/sprites1.txt +++ b/test/ecs/sprites1.txt @@ -1,3 +1,20 @@ +EVENT__main_init = 1 +EVENT__start = 1 +EVENT__nextframe = 1 +EVENT__resetswitch = 1 +EVENT__postframe = 1 +EVENT__SetHorizPos = 1 +EVENT__preframe = 1 +EVENT__kernel = 1 +EVENT__kerneldraw = 1 +EVENT__kernelsetup = 1 +EVENT__joybutton = 1 +EVENT__scanline1 = 1 +EVENT__scanline2 = 1 +EVENT__joyleft = 1 +EVENT__joyright = 1 +EVENT__joyup = 1 +EVENT__joydown = 1 .scope Main .zeropage HasBitmap_bitmap_b0: diff --git a/test/ecs/superman.txt b/test/ecs/superman.txt index 07f8b8e4..0e136420 100644 --- a/test/ecs/superman.txt +++ b/test/ecs/superman.txt @@ -1,3 +1,23 @@ +EVENT__main_init = 1 +EVENT__start = 1 +EVENT__nextframe = 1 +EVENT__resetswitch = 1 +EVENT__postframe = 1 +EVENT__SetHorizPos = 1 +EVENT__preframe = 1 +EVENT__kernel = 1 +EVENT__kerneldraw = 1 +EVENT__kernelsetup = 1 +EVENT__joybutton = 1 +EVENT__scanline = 1 +EVENT__joyleft = 1 +EVENT__joyright = 1 +EVENT__joyup = 1 +EVENT__joydown = 1 +EVENT__gowest = 1 +EVENT__goeast = 1 +EVENT__gonorth = 1 +EVENT__gosouth = 1 .scope Main .zeropage Location_room_b0: diff --git a/test/ecs/titles.txt b/test/ecs/titles.txt index 6083a1ad..d5748492 100644 --- a/test/ecs/titles.txt +++ b/test/ecs/titles.txt @@ -1,3 +1,14 @@ +EVENT__main_init = 1 +EVENT__start = 1 +EVENT__nextframe = 1 +EVENT__resetswitch = 1 +EVENT__postframe = 1 +EVENT__SetHorizPos = 1 +EVENT__preframe = 1 +EVENT__kernel = 1 +EVENT__kerneldraw = 1 +EVENT__kernelsetup = 1 +EVENT__joybutton = 1 .scope TitleDemo .zeropage .code diff --git a/test/ecs/vcs1.txt b/test/ecs/vcs1.txt index 6208b667..d0e5da45 100644 --- a/test/ecs/vcs1.txt +++ b/test/ecs/vcs1.txt @@ -1,3 +1,13 @@ +EVENT__main_init = 1 +EVENT__start = 1 +EVENT__nextframe = 1 +EVENT__resetswitch = 1 +EVENT__postframe = 1 +EVENT__SetHorizPos = 1 +EVENT__preframe = 1 +EVENT__kernel = 1 +EVENT__kernelsetup = 1 +EVENT__joybutton = 1 .scope Main .zeropage PFColor_pfcolor_b0: diff --git a/test/ecs/vcslib.txt b/test/ecs/vcslib.txt index 301c3e39..84657a50 100644 --- a/test/ecs/vcslib.txt +++ b/test/ecs/vcslib.txt @@ -1,3 +1,14 @@ +EVENT__main_init = 1 +EVENT__start = 1 +EVENT__nextframe = 1 +EVENT__resetswitch = 1 +EVENT__postframe = 1 +EVENT__SetHorizPos = 1 +EVENT__preframe = 1 +EVENT__kernel = 1 +EVENT__kerneldraw = 1 +EVENT__kernelsetup = 1 +EVENT__joybutton = 1 .scope Main .zeropage PFColor_pfcolor_b0: