ecs: automatically init bss when 'start' event
This commit is contained in:
parent
d96296675b
commit
eb30e5cf85
|
@ -865,9 +865,6 @@ class ActionEval {
|
||||||
//this.used.add(`arg_${argindex}_${argvalue}`);
|
//this.used.add(`arg_${argindex}_${argvalue}`);
|
||||||
return argvalue;
|
return argvalue;
|
||||||
}
|
}
|
||||||
__bss_init(args: string[]) {
|
|
||||||
return this.scope.allocateInitData(this.scope.bss);
|
|
||||||
}
|
|
||||||
wrapCodeInLoop(code: string, action: ActionWithQuery, ents: Entity[], joinfield?: ComponentFieldPair): string {
|
wrapCodeInLoop(code: string, action: ActionWithQuery, ents: Entity[], joinfield?: ComponentFieldPair): string {
|
||||||
// TODO: check ents
|
// TODO: check ents
|
||||||
// TODO: check segment bounds
|
// TODO: check segment bounds
|
||||||
|
@ -1317,7 +1314,13 @@ export class EntityScope implements SourceLocated {
|
||||||
this.eventSeq++;
|
this.eventSeq++;
|
||||||
// generate code
|
// generate code
|
||||||
let code = '';
|
let code = '';
|
||||||
|
// is there a label? generate it first
|
||||||
if (codelabel) { code += this.dialect.label(codelabel) + '\n'; }
|
if (codelabel) { code += this.dialect.label(codelabel) + '\n'; }
|
||||||
|
// if "start" event, initialize data segment
|
||||||
|
if (event == 'start') {
|
||||||
|
code += this.allocateInitData(this.bss);
|
||||||
|
}
|
||||||
|
// iterate all instances and generate matching events
|
||||||
let eventCount = 0;
|
let eventCount = 0;
|
||||||
let instances = this.instances.filter(inst => systems.includes(inst.system));
|
let instances = this.instances.filter(inst => systems.includes(inst.system));
|
||||||
for (let inst of instances) {
|
for (let inst of instances) {
|
||||||
|
@ -1446,6 +1449,7 @@ export class EntityScope implements SourceLocated {
|
||||||
replaceSubroutines(code: string) {
|
replaceSubroutines(code: string) {
|
||||||
// TODO: bin-packing for critical code
|
// TODO: bin-packing for critical code
|
||||||
// TODO: doesn't work with nested subroutines?
|
// TODO: doesn't work with nested subroutines?
|
||||||
|
// TODO: doesn't work between scopes
|
||||||
let allsubs : string[] = [];
|
let allsubs : string[] = [];
|
||||||
for (let stats of Object.values(this.eventStats)) {
|
for (let stats of Object.values(this.eventStats)) {
|
||||||
if (stats.count > 1) {
|
if (stats.count > 1) {
|
||||||
|
|
|
@ -6,8 +6,19 @@ Xpos_x_b0:
|
||||||
.res 1
|
.res 1
|
||||||
.res 1
|
.res 1
|
||||||
.code
|
.code
|
||||||
|
Main__INITDATA:
|
||||||
|
.byte 0
|
||||||
|
.byte 50
|
||||||
|
.byte 100
|
||||||
|
.byte 150
|
||||||
__Start:
|
__Start:
|
||||||
|
|
||||||
|
ldy #4
|
||||||
|
: lda Main__INITDATA-1,y
|
||||||
|
sta Xpos_x_b0-1,y
|
||||||
|
dey
|
||||||
|
bne :-
|
||||||
|
|
||||||
;;; start action move 1 start
|
;;; start action move 1 start
|
||||||
|
|
||||||
ldx #0
|
ldx #0
|
||||||
|
|
|
@ -64,7 +64,6 @@ __BRK:
|
||||||
sta BCDScore6_digits_b0-1,y
|
sta BCDScore6_digits_b0-1,y
|
||||||
dey
|
dey
|
||||||
bne :-
|
bne :-
|
||||||
; initialize data segment
|
|
||||||
|
|
||||||
;;; start action FrameLoop 1 start
|
;;; start action FrameLoop 1 start
|
||||||
|
|
||||||
|
|
|
@ -131,7 +131,6 @@ __BRK:
|
||||||
sta HasBitmap_bitmap_b0-1,y
|
sta HasBitmap_bitmap_b0-1,y
|
||||||
dey
|
dey
|
||||||
bne :-
|
bne :-
|
||||||
; initialize data segment
|
|
||||||
|
|
||||||
;;; start action FrameLoop 1 start
|
;;; start action FrameLoop 1 start
|
||||||
|
|
||||||
|
|
|
@ -131,7 +131,6 @@ __BRK:
|
||||||
sta HasBitmap_bitmap_b0-1,y
|
sta HasBitmap_bitmap_b0-1,y
|
||||||
dey
|
dey
|
||||||
bne :-
|
bne :-
|
||||||
; initialize data segment
|
|
||||||
|
|
||||||
;;; start action FrameLoop 1 start
|
;;; start action FrameLoop 1 start
|
||||||
|
|
||||||
|
|
|
@ -643,7 +643,6 @@ __BRK:
|
||||||
sta Location_room_b0-1,y
|
sta Location_room_b0-1,y
|
||||||
dey
|
dey
|
||||||
bne :-
|
bne :-
|
||||||
; initialize data segment
|
|
||||||
|
|
||||||
;;; start action FrameLoop 1 start
|
;;; start action FrameLoop 1 start
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,6 @@ demo TitleDemo
|
||||||
system Advance
|
system Advance
|
||||||
on joybutton do once
|
on joybutton do once
|
||||||
---
|
---
|
||||||
FRAME_END
|
|
||||||
jmp Title2__Start
|
jmp Title2__Start
|
||||||
---
|
---
|
||||||
end
|
end
|
||||||
|
@ -166,19 +165,19 @@ demo TitleDemo
|
||||||
|
|
||||||
entity [KernelSection, BGColor]
|
entity [KernelSection, BGColor]
|
||||||
const lines = 60
|
const lines = 60
|
||||||
const bgcolor = $50
|
var bgcolor = 0x10
|
||||||
end
|
end
|
||||||
|
|
||||||
entity [KernelSection, BGColor]
|
entity [KernelSection, BGColor]
|
||||||
const lines = 10
|
const lines = 10
|
||||||
const bgcolor = $52
|
var bgcolor = 0x30
|
||||||
end
|
end
|
||||||
|
|
||||||
// convert -size 48x -gravity center label:"6502\nECS" pbm: | pnmtopnm -plain
|
// convert -size 48x -gravity center label:"6502\nECS" pbm: | pnmtopnm -plain
|
||||||
entity [KernelSection, BGColor, PFColor, Bitmap48]
|
entity [KernelSection, BGColor, PFColor, Bitmap48]
|
||||||
const lines = 2
|
const lines = 2
|
||||||
const bgcolor = 0x54
|
var pfcolor = 0xec
|
||||||
const pfcolor = 0xec
|
var bgcolor = 0x30
|
||||||
decode vcs_bitmap48 ---
|
decode vcs_bitmap48 ---
|
||||||
000000000000000000000000000000000000000000011000
|
000000000000000000000000000000000000000000011000
|
||||||
000000000000000000000000000000000000000000011000
|
000000000000000000000000000000000000000000011000
|
||||||
|
@ -229,14 +228,25 @@ demo TitleDemo
|
||||||
|
|
||||||
entity [KernelSection, BGColor]
|
entity [KernelSection, BGColor]
|
||||||
const lines = 10
|
const lines = 10
|
||||||
const bgcolor = $52
|
var bgcolor = 0x30
|
||||||
end
|
end
|
||||||
|
|
||||||
entity [KernelSection, BGColor]
|
entity [KernelSection, BGColor]
|
||||||
const lines = 10
|
const lines = 10
|
||||||
const bgcolor = $50
|
var bgcolor = 0x50
|
||||||
end
|
end
|
||||||
|
|
||||||
|
system Colors
|
||||||
|
on postframe do foreach [PFColor]
|
||||||
|
---
|
||||||
|
inc {{set pfcolor}}
|
||||||
|
bne :+
|
||||||
|
inc {{set bgcolor}}
|
||||||
|
inc {{set bgcolor}}
|
||||||
|
:
|
||||||
|
---
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
system Demo
|
system Demo
|
||||||
|
|
|
@ -12,7 +12,6 @@ __NMI:
|
||||||
__Reset:
|
__Reset:
|
||||||
__BRK:
|
__BRK:
|
||||||
CLEAN_START
|
CLEAN_START
|
||||||
; initialize data segment
|
|
||||||
|
|
||||||
;;; start action Demo 1 start
|
;;; start action Demo 1 start
|
||||||
|
|
||||||
|
@ -500,7 +499,6 @@ StaticKernel__kernel__10____exit:
|
||||||
|
|
||||||
;;; start action Advance 5 joybutton
|
;;; start action Advance 5 joybutton
|
||||||
|
|
||||||
FRAME_END
|
|
||||||
jmp Title2__Start
|
jmp Title2__Start
|
||||||
|
|
||||||
;;; end action Advance 5 joybutton
|
;;; end action Advance 5 joybutton
|
||||||
|
@ -519,6 +517,14 @@ JoyButton__postframe__18__NotPressed:
|
||||||
Title__Start = Title::__Start
|
Title__Start = Title::__Start
|
||||||
.scope Title2
|
.scope Title2
|
||||||
.zeropage
|
.zeropage
|
||||||
|
BGColor_bgcolor_b0:
|
||||||
|
.res 1
|
||||||
|
.res 1
|
||||||
|
.res 1
|
||||||
|
.res 1
|
||||||
|
.res 1
|
||||||
|
PFColor_pfcolor_b0:
|
||||||
|
.res 1
|
||||||
TEMP:
|
TEMP:
|
||||||
Kernel48Pixel__2__tmp:
|
Kernel48Pixel__2__tmp:
|
||||||
.res 1
|
.res 1
|
||||||
|
@ -530,14 +536,6 @@ KernelSection_lines_b0:
|
||||||
.byte 2
|
.byte 2
|
||||||
.byte 10
|
.byte 10
|
||||||
.byte 10
|
.byte 10
|
||||||
BGColor_bgcolor_b0:
|
|
||||||
.byte 80
|
|
||||||
.byte 82
|
|
||||||
.byte 84
|
|
||||||
.byte 82
|
|
||||||
.byte 80
|
|
||||||
PFColor_pfcolor_b0:
|
|
||||||
.byte 236
|
|
||||||
Bitmap48_bitmap0_b0:
|
Bitmap48_bitmap0_b0:
|
||||||
.byte <Bitmap48_bitmap0_e2_b0
|
.byte <Bitmap48_bitmap0_e2_b0
|
||||||
Bitmap48_bitmap0_b8:
|
Bitmap48_bitmap0_b8:
|
||||||
|
@ -834,8 +832,21 @@ Bitmap48_bitmap5_e2_b0:
|
||||||
.byte 24
|
.byte 24
|
||||||
Bitmap48_height_b0:
|
Bitmap48_height_b0:
|
||||||
.byte 43
|
.byte 43
|
||||||
|
Title2__INITDATA:
|
||||||
|
.byte 16
|
||||||
|
.byte 48
|
||||||
|
.byte 48
|
||||||
|
.byte 48
|
||||||
|
.byte 80
|
||||||
|
.byte 236
|
||||||
__Start:
|
__Start:
|
||||||
|
|
||||||
|
ldy #6
|
||||||
|
: lda Title2__INITDATA-1,y
|
||||||
|
sta BGColor_bgcolor_b0-1,y
|
||||||
|
dey
|
||||||
|
bne :-
|
||||||
|
|
||||||
;;; start action FrameLoop 1 start
|
;;; start action FrameLoop 1 start
|
||||||
|
|
||||||
FrameLoop__start__20__NextFrame:
|
FrameLoop__start__20__NextFrame:
|
||||||
|
@ -854,7 +865,7 @@ FrameLoop__start__20__NextFrame:
|
||||||
|
|
||||||
;;; start action StaticKernel 3 kernelsetup
|
;;; start action StaticKernel 3 kernelsetup
|
||||||
|
|
||||||
lda #80
|
lda BGColor_bgcolor_b0
|
||||||
sta COLUBK
|
sta COLUBK
|
||||||
|
|
||||||
;;; end action StaticKernel 3 kernelsetup
|
;;; end action StaticKernel 3 kernelsetup
|
||||||
|
@ -924,7 +935,7 @@ Kernel48Pixel__kernelsetup__28____skipxhi:
|
||||||
cpx #2
|
cpx #2
|
||||||
jcc Kernel48Pixel__kernelsetup__29____skipxlo
|
jcc Kernel48Pixel__kernelsetup__29____skipxlo
|
||||||
|
|
||||||
lda #236
|
lda PFColor_pfcolor_b0
|
||||||
sta COLUP0
|
sta COLUP0
|
||||||
sta COLUP1
|
sta COLUP1
|
||||||
|
|
||||||
|
@ -949,7 +960,7 @@ Kernel48Pixel__kernelsetup__29____skipxhi:
|
||||||
cpx #2
|
cpx #2
|
||||||
jcc StaticKernel__kernelsetup__31____skipxlo
|
jcc StaticKernel__kernelsetup__31____skipxlo
|
||||||
|
|
||||||
lda #236
|
lda PFColor_pfcolor_b0
|
||||||
sta COLUPF
|
sta COLUPF
|
||||||
|
|
||||||
StaticKernel__kernelsetup__31____skipxlo:
|
StaticKernel__kernelsetup__31____skipxlo:
|
||||||
|
@ -1024,6 +1035,16 @@ StaticKernel__kernel__27____exit:
|
||||||
|
|
||||||
KERNEL_END
|
KERNEL_END
|
||||||
|
|
||||||
|
;;; start action Colors 4 postframe
|
||||||
|
|
||||||
|
inc PFColor_pfcolor_b0
|
||||||
|
bne :+
|
||||||
|
inc BGColor_bgcolor_b0+2
|
||||||
|
inc BGColor_bgcolor_b0+2
|
||||||
|
:
|
||||||
|
|
||||||
|
;;; end action Colors 4 postframe
|
||||||
|
|
||||||
FRAME_END
|
FRAME_END
|
||||||
|
|
||||||
jmp FrameLoop__start__20__NextFrame ; loop to next frame
|
jmp FrameLoop__start__20__NextFrame ; loop to next frame
|
||||||
|
|
|
@ -10,7 +10,6 @@ __NMI:
|
||||||
__Reset:
|
__Reset:
|
||||||
__BRK:
|
__BRK:
|
||||||
CLEAN_START
|
CLEAN_START
|
||||||
{{bss_init}} ; initialize data segment
|
|
||||||
{{!start}} ; start main routine
|
{{!start}} ; start main routine
|
||||||
.segment "VECTORS"
|
.segment "VECTORS"
|
||||||
Return: .word $6060
|
Return: .word $6060
|
||||||
|
|
|
@ -59,7 +59,6 @@ __BRK:
|
||||||
sta PFColor_pfcolor_b0-1,y
|
sta PFColor_pfcolor_b0-1,y
|
||||||
dey
|
dey
|
||||||
bne :-
|
bne :-
|
||||||
; initialize data segment
|
|
||||||
|
|
||||||
;;; start action FrameLoop 1 start
|
;;; start action FrameLoop 1 start
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ __NMI:
|
||||||
__Reset:
|
__Reset:
|
||||||
__BRK:
|
__BRK:
|
||||||
CLEAN_START
|
CLEAN_START
|
||||||
{{bss_init}} ; initialize data segment
|
|
||||||
{{!start}} ; start main routine
|
{{!start}} ; start main routine
|
||||||
.segment "VECTORS"
|
.segment "VECTORS"
|
||||||
Return: .word $6060
|
Return: .word $6060
|
||||||
|
|
|
@ -60,7 +60,6 @@ __BRK:
|
||||||
sta PFColor_pfcolor_b0-1,y
|
sta PFColor_pfcolor_b0-1,y
|
||||||
dey
|
dey
|
||||||
bne :-
|
bne :-
|
||||||
; initialize data segment
|
|
||||||
|
|
||||||
;;; start action FrameLoop 1 start
|
;;; start action FrameLoop 1 start
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue