From af90a910f2e0934c16dfeb115b47e118b2648405 Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Sun, 17 May 2020 23:52:58 +0200 Subject: [PATCH] Added a sinus movement to the Atari 2600 raster bars. Separated Vars and Data fragments in the Atari 2600 target platform linker file. Moved atari 2600 demo to /examples/. Closes #445 --- src/main/kc/target/atari2600.ld | 5 +- .../dk/camelot64/kickc/test/TestPrograms.java | 4 +- .../atari2600/atari2600-demo.c} | 14 +- .../atari2600/atari2600-demo.asm} | 23 +- .../atari2600/atari2600-demo.cfg} | 6 +- .../atari2600/atari2600-demo.log} | 295 ++++++++++-------- .../atari2600/atari2600-demo.sym} | 10 +- 7 files changed, 200 insertions(+), 157 deletions(-) rename src/test/kc/{atari2600-min.c => examples/atari2600/atari2600-demo.c} (87%) rename src/test/ref/{atari2600-min.asm => examples/atari2600/atari2600-demo.asm} (88%) rename src/test/ref/{atari2600-min.cfg => examples/atari2600/atari2600-demo.cfg} (94%) rename src/test/ref/{atari2600-min.log => examples/atari2600/atari2600-demo.log} (88%) rename src/test/ref/{atari2600-min.sym => examples/atari2600/atari2600-demo.sym} (92%) diff --git a/src/main/kc/target/atari2600.ld b/src/main/kc/target/atari2600.ld index 79760201b..930bc3767 100644 --- a/src/main/kc/target/atari2600.ld +++ b/src/main/kc/target/atari2600.ld @@ -1,7 +1,8 @@ // Atari 2600 VCS 4K ROM -.file [name="%O", type="bin", segments="Code, Vectors"] +.file [name="%O", type="bin", segments="Code, Data, Vectors"] .segmentdef Code [start=$f800,min=$f800,max=$fff9] -.segmentdef Data [start=$80,max=$ff, virtual] +.segmentdef Data [startAfter="Code",max=$fff9] +.segmentdef Vars [start=$80,max=$ff, virtual] .segmentdef Vectors [start=$fffa,max=$ffff] .segment Vectors .word %E // NMI diff --git a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java index 8845ddb4c..bba0064c3 100644 --- a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java +++ b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java @@ -45,8 +45,8 @@ public class TestPrograms { } @Test - public void testAtari2600Min() throws IOException, URISyntaxException { - compileAndCompare("atari2600-min.c"); + public void testAtari2600Demo() throws IOException, URISyntaxException { + compileAndCompare("examples/atari2600/atari2600-demo.c"); } @Test diff --git a/src/test/kc/atari2600-min.c b/src/test/kc/examples/atari2600/atari2600-demo.c similarity index 87% rename from src/test/kc/atari2600-min.c rename to src/test/kc/examples/atari2600/atari2600-demo.c index eb62e8943..1eaee4251 100644 --- a/src/test/kc/atari2600-min.c +++ b/src/test/kc/examples/atari2600/atari2600-demo.c @@ -1,9 +1,17 @@ -// Minimal Atari 2600 VCS Program +// Demonstration Atari 2600 VCS Program // Source: https://atariage.com/forums/blogs/entry/11109-step-1-generate-a-stable-display/ #pragma target(atari2600) #include -char __mem col=0; +// Variables +#pragma data_seg(Vars) +char __mem idx=0; + +// Data +#pragma data_seg(Data) +const char align(0x100) SINTABLE[0x100] = kickasm {{ + .fill $100, round(127.5+127.5*sin(2*PI*i/256)) +}}; void main() { while(1) { @@ -28,7 +36,7 @@ void main() { // Update the registers in TIA (the video chip) in order to generate what the player sees. // For now we're just going to output 192 colored scanlines lines so we have something to see. TIA->VBLANK = 0; // D1=1, turns off Vertical Blank signal (image output on) - char c = col++; + char c = SINTABLE[idx++]; for(char i=0;i<192;i++) { TIA->WSYNC = 0; // Wait for SYNC (halts CPU until end of scanline) TIA->COLUBK = c++; // Set background color diff --git a/src/test/ref/atari2600-min.asm b/src/test/ref/examples/atari2600/atari2600-demo.asm similarity index 88% rename from src/test/ref/atari2600-min.asm rename to src/test/ref/examples/atari2600/atari2600-demo.asm index 0c38528f2..c5bb17eee 100644 --- a/src/test/ref/atari2600-min.asm +++ b/src/test/ref/examples/atari2600/atari2600-demo.asm @@ -1,9 +1,10 @@ -// Minimal Atari 2600 VCS Program +// Demonstration Atari 2600 VCS Program // Source: https://atariage.com/forums/blogs/entry/11109-step-1-generate-a-stable-display/ // Atari 2600 VCS 4K ROM -.file [name="atari2600-min.a26", type="bin", segments="Code, Vectors"] +.file [name="atari2600-demo.a26", type="bin", segments="Code, Data, Vectors"] .segmentdef Code [start=$f800,min=$f800,max=$fff9] -.segmentdef Data [start=$80,max=$ff, virtual] +.segmentdef Data [startAfter="Code",max=$fff9] +.segmentdef Vars [start=$80,max=$ff, virtual] .segmentdef Vectors [start=$fffa,max=$ffff] .segment Vectors .word main // NMI @@ -19,7 +20,7 @@ .segment Code main: { lda #0 - sta col + sta idx __b2: // TIA->VSYNC = 2 // Vertical Sync @@ -52,10 +53,11 @@ main: { // For now we're just going to output 192 colored scanlines lines so we have something to see. lda #0 sta TIA+OFFSET_STRUCT_ATARI_TIA_WRITE_VBLANK - // c = col++ + // c = SINTABLE[idx++] // D1=1, turns off Vertical Blank signal (image output on) - ldx col - inc col + ldy idx + ldx SINTABLE,y + inc idx tay __b6: // for(char i=0;i<192;i++) @@ -108,4 +110,9 @@ main: { jmp __b3 } .segment Data - col: .byte 0 + .align $100 +SINTABLE: +.fill $100, round(127.5+127.5*sin(2*PI*i/256)) + +.segment Vars + idx: .byte 0 diff --git a/src/test/ref/atari2600-min.cfg b/src/test/ref/examples/atari2600/atari2600-demo.cfg similarity index 94% rename from src/test/ref/atari2600-min.cfg rename to src/test/ref/examples/atari2600/atari2600-demo.cfg index 6f201e239..b9395c569 100644 --- a/src/test/ref/atari2600-min.cfg +++ b/src/test/ref/examples/atari2600/atari2600-demo.cfg @@ -13,7 +13,7 @@ main: scope:[main] from @1 [4] phi() to:main::@1 main::@1: scope:[main] from main main::@9 - [5] (byte) col#12 ← phi( main/(byte) 0 main::@9/(byte) col#1 ) + [5] (byte) idx#12 ← phi( main/(byte) 0 main::@9/(byte) idx#1 ) to:main::@2 main::@2: scope:[main] from main::@1 [6] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA) ← (byte) 2 @@ -28,8 +28,8 @@ main::@3: scope:[main] from main::@2 main::@4 to:main::@5 main::@5: scope:[main] from main::@3 [13] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_VBLANK) ← (byte) 0 - [14] (byte) main::c#0 ← (byte) col#12 - [15] (byte) col#1 ← ++ (byte) col#12 + [14] (byte) main::c#0 ← *((const to_nomodify byte*) SINTABLE + (byte) idx#12) + [15] (byte) idx#1 ← ++ (byte) idx#12 to:main::@6 main::@6: scope:[main] from main::@5 main::@7 [16] (byte) main::c#2 ← phi( main::@5/(byte) main::c#0 main::@7/(byte) main::c#1 ) diff --git a/src/test/ref/atari2600-min.log b/src/test/ref/examples/atari2600/atari2600-demo.log similarity index 88% rename from src/test/ref/atari2600-min.log rename to src/test/ref/examples/atari2600/atari2600-demo.log index f482f8f42..552d37413 100644 --- a/src/test/ref/atari2600-min.log +++ b/src/test/ref/examples/atari2600/atari2600-demo.log @@ -4,20 +4,20 @@ Fixing struct type SIZE_OF struct MOS6532_RIOT to 24 CONTROL FLOW GRAPH SSA @begin: scope:[] from - (byte) col#0 ← (byte) 0 + (byte) idx#0 ← (byte) 0 to:@1 (void()) main() main: scope:[main] from @1 - (byte) col#10 ← phi( @1/(byte) col#9 ) + (byte) idx#10 ← phi( @1/(byte) idx#9 ) to:main::@1 main::@1: scope:[main] from main main::@9 - (byte) col#8 ← phi( main/(byte) col#10 main::@9/(byte) col#11 ) + (byte) idx#8 ← phi( main/(byte) idx#10 main::@9/(byte) idx#11 ) (bool~) main::$3 ← (number) 0 != (number) 1 if((bool~) main::$3) goto main::@2 to:main::@return main::@2: scope:[main] from main::@1 - (byte) col#12 ← phi( main::@1/(byte) col#8 ) + (byte) idx#12 ← phi( main::@1/(byte) idx#8 ) *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_VSYNC) ← (number) 2 *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC) ← (number) 0 *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC) ← (number) 0 @@ -26,33 +26,33 @@ main::@2: scope:[main] from main::@1 (byte) main::i#0 ← (byte) 0 to:main::@3 main::@3: scope:[main] from main::@2 main::@4 - (byte) col#7 ← phi( main::@2/(byte) col#12 main::@4/(byte) col#13 ) + (byte) idx#7 ← phi( main::@2/(byte) idx#12 main::@4/(byte) idx#13 ) (byte) main::i#2 ← phi( main::@2/(byte) main::i#0 main::@4/(byte) main::i#1 ) (bool~) main::$0 ← (byte) main::i#2 < (number) $25 if((bool~) main::$0) goto main::@4 to:main::@5 main::@4: scope:[main] from main::@3 - (byte) col#13 ← phi( main::@3/(byte) col#7 ) + (byte) idx#13 ← phi( main::@3/(byte) idx#7 ) (byte) main::i#3 ← phi( main::@3/(byte) main::i#2 ) *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC) ← (number) 0 (byte) main::i#1 ← ++ (byte) main::i#3 to:main::@3 main::@5: scope:[main] from main::@3 - (byte) col#4 ← phi( main::@3/(byte) col#7 ) + (byte) idx#4 ← phi( main::@3/(byte) idx#7 ) *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_VBLANK) ← (number) 0 - (byte) main::c#0 ← (byte) col#4 - (byte) col#1 ← ++ (byte) col#4 + (byte) main::c#0 ← *((const to_nomodify byte*) SINTABLE + (byte) idx#4) + (byte) idx#1 ← ++ (byte) idx#4 (byte) main::i1#0 ← (byte) 0 to:main::@6 main::@6: scope:[main] from main::@5 main::@7 - (byte) col#16 ← phi( main::@5/(byte) col#1 main::@7/(byte) col#17 ) + (byte) idx#16 ← phi( main::@5/(byte) idx#1 main::@7/(byte) idx#17 ) (byte) main::c#3 ← phi( main::@5/(byte) main::c#0 main::@7/(byte) main::c#1 ) (byte) main::i1#2 ← phi( main::@5/(byte) main::i1#0 main::@7/(byte) main::i1#1 ) (bool~) main::$1 ← (byte) main::i1#2 < (number) $c0 if((bool~) main::$1) goto main::@7 to:main::@8 main::@7: scope:[main] from main::@6 - (byte) col#17 ← phi( main::@6/(byte) col#16 ) + (byte) idx#17 ← phi( main::@6/(byte) idx#16 ) (byte) main::i1#3 ← phi( main::@6/(byte) main::i1#2 ) (byte) main::c#2 ← phi( main::@6/(byte) main::c#3 ) *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC) ← (number) 0 @@ -61,36 +61,36 @@ main::@7: scope:[main] from main::@6 (byte) main::i1#1 ← ++ (byte) main::i1#3 to:main::@6 main::@8: scope:[main] from main::@6 - (byte) col#15 ← phi( main::@6/(byte) col#16 ) + (byte) idx#15 ← phi( main::@6/(byte) idx#16 ) *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC) ← (number) 0 *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_VBLANK) ← (number) 2 *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_COLUBK) ← (number) 0 (byte) main::i2#0 ← (byte) 0 to:main::@9 main::@9: scope:[main] from main::@10 main::@8 - (byte) col#11 ← phi( main::@10/(byte) col#14 main::@8/(byte) col#15 ) + (byte) idx#11 ← phi( main::@10/(byte) idx#14 main::@8/(byte) idx#15 ) (byte) main::i2#2 ← phi( main::@10/(byte) main::i2#1 main::@8/(byte) main::i2#0 ) (bool~) main::$2 ← (byte) main::i2#2 < (number) $1e if((bool~) main::$2) goto main::@10 to:main::@1 main::@10: scope:[main] from main::@9 - (byte) col#14 ← phi( main::@9/(byte) col#11 ) + (byte) idx#14 ← phi( main::@9/(byte) idx#11 ) (byte) main::i2#3 ← phi( main::@9/(byte) main::i2#2 ) *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC) ← (number) 0 (byte) main::i2#1 ← ++ (byte) main::i2#3 to:main::@9 main::@return: scope:[main] from main::@1 - (byte) col#5 ← phi( main::@1/(byte) col#8 ) - (byte) col#2 ← (byte) col#5 + (byte) idx#5 ← phi( main::@1/(byte) idx#8 ) + (byte) idx#2 ← (byte) idx#5 return to:@return @1: scope:[] from @begin - (byte) col#9 ← phi( @begin/(byte) col#0 ) + (byte) idx#9 ← phi( @begin/(byte) idx#0 ) call main to:@2 @2: scope:[] from @1 - (byte) col#6 ← phi( @1/(byte) col#2 ) - (byte) col#3 ← (byte) col#6 + (byte) idx#6 ← phi( @1/(byte) idx#2 ) + (byte) idx#3 ← (byte) idx#6 to:@end @end: scope:[] from @2 @@ -172,26 +172,28 @@ SYMBOL TABLE SSA (const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_VBLANK = (byte) 1 (const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_VSYNC = (byte) 0 (const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC = (byte) 2 +(const to_nomodify byte*) SINTABLE[(number) $100] = kickasm {{ .fill $100, round(127.5+127.5*sin(2*PI*i/256)) + }} (const nomodify struct ATARI_TIA_WRITE*) TIA = (struct ATARI_TIA_WRITE*)(number) 0 -(byte) col -(byte) col#0 -(byte) col#1 -(byte) col#10 -(byte) col#11 -(byte) col#12 -(byte) col#13 -(byte) col#14 -(byte) col#15 -(byte) col#16 -(byte) col#17 -(byte) col#2 -(byte) col#3 -(byte) col#4 -(byte) col#5 -(byte) col#6 -(byte) col#7 -(byte) col#8 -(byte) col#9 +(byte) idx +(byte) idx#0 +(byte) idx#1 +(byte) idx#10 +(byte) idx#11 +(byte) idx#12 +(byte) idx#13 +(byte) idx#14 +(byte) idx#15 +(byte) idx#16 +(byte) idx#17 +(byte) idx#2 +(byte) idx#3 +(byte) idx#4 +(byte) idx#5 +(byte) idx#6 +(byte) idx#7 +(byte) idx#8 +(byte) idx#9 (void()) main() (bool~) main::$0 (bool~) main::$1 @@ -291,29 +293,29 @@ Finalized unsigned number type (byte) 0 Finalized unsigned number type (byte) $1e Finalized unsigned number type (byte) 0 Successful SSA optimization PassNFinalizeNumberTypeConversions -Alias col#12 = col#8 col#5 col#2 +Alias idx#12 = idx#8 idx#5 idx#2 Alias main::i#2 = main::i#3 -Alias col#13 = col#7 col#4 +Alias idx#13 = idx#7 idx#4 Alias main::c#2 = main::c#3 Alias main::i1#2 = main::i1#3 -Alias col#15 = col#17 col#16 +Alias idx#15 = idx#17 idx#16 Alias main::i2#2 = main::i2#3 -Alias col#11 = col#14 -Alias col#0 = col#9 -Alias col#3 = col#6 +Alias idx#11 = idx#14 +Alias idx#0 = idx#9 +Alias idx#3 = idx#6 Successful SSA optimization Pass2AliasElimination -Identical Phi Values (byte) col#10 (byte) col#0 -Identical Phi Values (byte) col#13 (byte) col#12 -Identical Phi Values (byte) col#15 (byte) col#1 -Identical Phi Values (byte) col#11 (byte) col#15 -Identical Phi Values (byte) col#3 (byte) col#12 +Identical Phi Values (byte) idx#10 (byte) idx#0 +Identical Phi Values (byte) idx#13 (byte) idx#12 +Identical Phi Values (byte) idx#15 (byte) idx#1 +Identical Phi Values (byte) idx#11 (byte) idx#15 +Identical Phi Values (byte) idx#3 (byte) idx#12 Successful SSA optimization Pass2IdenticalPhiElimination Simple Condition (bool~) main::$3 [4] if((number) 0!=(number) 1) goto main::@2 Simple Condition (bool~) main::$0 [13] if((byte) main::i#2<(byte) $25) goto main::@4 Simple Condition (bool~) main::$1 [22] if((byte) main::i1#2<(byte) $c0) goto main::@7 Simple Condition (bool~) main::$2 [33] if((byte) main::i2#2<(byte) $1e) goto main::@10 Successful SSA optimization Pass2ConditionalJumpSimplification -Constant (const byte) col#0 = 0 +Constant (const byte) idx#0 = 0 Constant (const byte) main::i#0 = 0 Constant (const byte) main::i1#0 = 0 Constant (const byte) main::i2#0 = 0 @@ -330,11 +332,11 @@ Successful SSA optimization Pass2EliminateUnusedBlocks Inlining constant with var siblings (const byte) main::i#0 Inlining constant with var siblings (const byte) main::i1#0 Inlining constant with var siblings (const byte) main::i2#0 -Inlining constant with var siblings (const byte) col#0 +Inlining constant with var siblings (const byte) idx#0 Constant inlined main::i#0 = (byte) 0 Constant inlined main::i1#0 = (byte) 0 Constant inlined main::i2#0 = (byte) 0 -Constant inlined col#0 = (byte) 0 +Constant inlined idx#0 = (byte) 0 Successful SSA optimization Pass2ConstantInlining Added new block during phi lifting main::@11(between main::@9 and main::@1) Adding NOP phi() at start of @begin @@ -347,7 +349,7 @@ Calls in [] to main:2 Created 5 initial phi equivalence classes Coalesced [17] main::c#4 ← main::c#0 -Coalesced [25] col#18 ← col#1 +Coalesced [25] idx#18 ← idx#1 Coalesced [28] main::i2#4 ← main::i2#1 Coalesced [33] main::i1#4 ← main::i1#1 Coalesced [34] main::c#5 ← main::c#1 @@ -376,7 +378,7 @@ main: scope:[main] from @1 [4] phi() to:main::@1 main::@1: scope:[main] from main main::@9 - [5] (byte) col#12 ← phi( main/(byte) 0 main::@9/(byte) col#1 ) + [5] (byte) idx#12 ← phi( main/(byte) 0 main::@9/(byte) idx#1 ) to:main::@2 main::@2: scope:[main] from main::@1 [6] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA) ← (byte) 2 @@ -391,8 +393,8 @@ main::@3: scope:[main] from main::@2 main::@4 to:main::@5 main::@5: scope:[main] from main::@3 [13] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_VBLANK) ← (byte) 0 - [14] (byte) main::c#0 ← (byte) col#12 - [15] (byte) col#1 ← ++ (byte) col#12 + [14] (byte) main::c#0 ← *((const to_nomodify byte*) SINTABLE + (byte) idx#12) + [15] (byte) idx#1 ← ++ (byte) idx#12 to:main::@6 main::@6: scope:[main] from main::@5 main::@7 [16] (byte) main::c#2 ← phi( main::@5/(byte) main::c#0 main::@7/(byte) main::c#1 ) @@ -493,9 +495,9 @@ VARIABLE REGISTER WEIGHTS (byte) MOS6532_RIOT::TIM1T (byte) MOS6532_RIOT::TIM64T (byte) MOS6532_RIOT::TIM8T -(byte) col -(byte) col#1 78.71428571428571 -(byte) col#12 100.25000000000001 +(byte) idx +(byte) idx#1 78.71428571428571 +(byte) idx#12 100.25000000000001 (void()) main() (byte) main::c (byte) main::c#0 101.0 @@ -512,18 +514,18 @@ VARIABLE REGISTER WEIGHTS (byte) main::i2#2 1001.0 Initial phi equivalence classes -[ col#12 col#1 ] +[ idx#12 idx#1 ] [ main::i#2 main::i#1 ] [ main::i1#2 main::i1#1 ] [ main::c#2 main::c#0 main::c#1 ] [ main::i2#2 main::i2#1 ] Complete equivalence classes -[ col#12 col#1 ] +[ idx#12 idx#1 ] [ main::i#2 main::i#1 ] [ main::i1#2 main::i1#1 ] [ main::c#2 main::c#0 main::c#1 ] [ main::i2#2 main::i2#1 ] -Allocated mem[1] [ col#12 col#1 ] +Allocated mem[1] [ idx#12 idx#1 ] Allocated zp[1]:2 [ main::i#2 main::i#1 ] Allocated zp[1]:3 [ main::i1#2 main::i1#1 ] Allocated zp[1]:4 [ main::c#2 main::c#0 main::c#1 ] @@ -532,13 +534,14 @@ Allocated zp[1]:5 [ main::i2#2 main::i2#1 ] INITIAL ASM Target platform is atari2600 / MOS6502X // File Comments -// Minimal Atari 2600 VCS Program +// Demonstration Atari 2600 VCS Program // Source: https://atariage.com/forums/blogs/entry/11109-step-1-generate-a-stable-display/ // Upstart // Atari 2600 VCS 4K ROM -.file [name="atari2600-min.a26", type="bin", segments="Code, Vectors"] +.file [name="atari2600-demo.a26", type="bin", segments="Code, Data, Vectors"] .segmentdef Code [start=$f800,min=$f800,max=$fff9] -.segmentdef Data [start=$80,max=$ff, virtual] +.segmentdef Data [startAfter="Code",max=$fff9] +.segmentdef Vars [start=$80,max=$ff, virtual] .segmentdef Vectors [start=$fffa,max=$ffff] .segment Vectors .word main // NMI @@ -577,9 +580,9 @@ main: { .label i2 = 5 // [5] phi from main to main::@1 [phi:main->main::@1] __b1_from_main: - // [5] phi (byte) col#12 = (byte) 0 [phi:main->main::@1#0] -- vbum1=vbuc1 + // [5] phi (byte) idx#12 = (byte) 0 [phi:main->main::@1#0] -- vbum1=vbuc1 lda #0 - sta col + sta idx jmp __b1 // main::@1 __b1: @@ -632,12 +635,13 @@ main: { // For now we're just going to output 192 colored scanlines lines so we have something to see. lda #0 sta TIA+OFFSET_STRUCT_ATARI_TIA_WRITE_VBLANK - // [14] (byte) main::c#0 ← (byte) col#12 -- vbuz1=vbum2 + // [14] (byte) main::c#0 ← *((const to_nomodify byte*) SINTABLE + (byte) idx#12) -- vbuz1=pbuc1_derefidx_vbum2 // D1=1, turns off Vertical Blank signal (image output on) - lda col + ldy idx + lda SINTABLE,y sta.z c - // [15] (byte) col#1 ← ++ (byte) col#12 -- vbum1=_inc_vbum1 - inc col + // [15] (byte) idx#1 ← ++ (byte) idx#12 -- vbum1=_inc_vbum1 + inc idx // [16] phi from main::@5 to main::@6 [phi:main::@5->main::@6] __b6_from___b5: // [16] phi (byte) main::c#2 = (byte) main::c#0 [phi:main::@5->main::@6#0] -- register_copy @@ -681,7 +685,7 @@ main: { bcc __b10 // [5] phi from main::@9 to main::@1 [phi:main::@9->main::@1] __b1_from___b9: - // [5] phi (byte) col#12 = (byte) col#1 [phi:main::@9->main::@1#0] -- register_copy + // [5] phi (byte) idx#12 = (byte) idx#1 [phi:main::@9->main::@1#0] -- register_copy jmp __b1 // main::@10 __b10: @@ -726,39 +730,44 @@ main: { } // File Data .segment Data - col: .byte 0 + .align $100 +SINTABLE: +.fill $100, round(127.5+127.5*sin(2*PI*i/256)) + +.segment Vars + idx: .byte 0 REGISTER UPLIFT POTENTIAL REGISTERS -Statement [6] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA) ← (byte) 2 [ col#12 ] ( main:2 [ col#12 ] { } ) always clobbers reg byte a -Removing always clobbered register reg byte a as potential for mem[1] [ col#12 col#1 ] -Statement [7] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC) ← (byte) 0 [ col#12 ] ( main:2 [ col#12 ] { } ) always clobbers reg byte a -Statement [8] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC) ← (byte) 0 [ col#12 ] ( main:2 [ col#12 ] { } ) always clobbers reg byte a -Statement [9] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC) ← (byte) 0 [ col#12 ] ( main:2 [ col#12 ] { } ) always clobbers reg byte a -Statement [10] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA) ← (byte) 0 [ col#12 ] ( main:2 [ col#12 ] { } ) always clobbers reg byte a -Statement [13] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_VBLANK) ← (byte) 0 [ col#12 ] ( main:2 [ col#12 ] { } ) always clobbers reg byte a -Statement [18] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC) ← (byte) 0 [ col#1 ] ( main:2 [ col#1 ] { } ) always clobbers reg byte a -Statement [19] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_VBLANK) ← (byte) 2 [ col#1 ] ( main:2 [ col#1 ] { } ) always clobbers reg byte a -Statement [20] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_COLUBK) ← (byte) 0 [ col#1 ] ( main:2 [ col#1 ] { } ) always clobbers reg byte a -Statement [23] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC) ← (byte) 0 [ col#1 main::i2#2 ] ( main:2 [ col#1 main::i2#2 ] { } ) always clobbers reg byte a +Statement [6] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA) ← (byte) 2 [ idx#12 ] ( main:2 [ idx#12 ] { } ) always clobbers reg byte a +Removing always clobbered register reg byte a as potential for mem[1] [ idx#12 idx#1 ] +Statement [7] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC) ← (byte) 0 [ idx#12 ] ( main:2 [ idx#12 ] { } ) always clobbers reg byte a +Statement [8] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC) ← (byte) 0 [ idx#12 ] ( main:2 [ idx#12 ] { } ) always clobbers reg byte a +Statement [9] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC) ← (byte) 0 [ idx#12 ] ( main:2 [ idx#12 ] { } ) always clobbers reg byte a +Statement [10] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA) ← (byte) 0 [ idx#12 ] ( main:2 [ idx#12 ] { } ) always clobbers reg byte a +Statement [13] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_VBLANK) ← (byte) 0 [ idx#12 ] ( main:2 [ idx#12 ] { } ) always clobbers reg byte a +Statement [18] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC) ← (byte) 0 [ idx#1 ] ( main:2 [ idx#1 ] { } ) always clobbers reg byte a +Statement [19] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_VBLANK) ← (byte) 2 [ idx#1 ] ( main:2 [ idx#1 ] { } ) always clobbers reg byte a +Statement [20] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_COLUBK) ← (byte) 0 [ idx#1 ] ( main:2 [ idx#1 ] { } ) always clobbers reg byte a +Statement [23] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC) ← (byte) 0 [ idx#1 main::i2#2 ] ( main:2 [ idx#1 main::i2#2 ] { } ) always clobbers reg byte a Removing always clobbered register reg byte a as potential for zp[1]:5 [ main::i2#2 main::i2#1 ] -Statement [25] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC) ← (byte) 0 [ col#1 main::i1#2 main::c#2 ] ( main:2 [ col#1 main::i1#2 main::c#2 ] { } ) always clobbers reg byte a +Statement [25] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC) ← (byte) 0 [ idx#1 main::i1#2 main::c#2 ] ( main:2 [ idx#1 main::i1#2 main::c#2 ] { } ) always clobbers reg byte a Removing always clobbered register reg byte a as potential for zp[1]:3 [ main::i1#2 main::i1#1 ] Removing always clobbered register reg byte a as potential for zp[1]:4 [ main::c#2 main::c#0 main::c#1 ] -Statement [29] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC) ← (byte) 0 [ col#12 main::i#2 ] ( main:2 [ col#12 main::i#2 ] { } ) always clobbers reg byte a +Statement [29] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC) ← (byte) 0 [ idx#12 main::i#2 ] ( main:2 [ idx#12 main::i#2 ] { } ) always clobbers reg byte a Removing always clobbered register reg byte a as potential for zp[1]:2 [ main::i#2 main::i#1 ] -Statement [6] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA) ← (byte) 2 [ col#12 ] ( main:2 [ col#12 ] { } ) always clobbers reg byte a -Statement [7] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC) ← (byte) 0 [ col#12 ] ( main:2 [ col#12 ] { } ) always clobbers reg byte a -Statement [8] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC) ← (byte) 0 [ col#12 ] ( main:2 [ col#12 ] { } ) always clobbers reg byte a -Statement [9] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC) ← (byte) 0 [ col#12 ] ( main:2 [ col#12 ] { } ) always clobbers reg byte a -Statement [10] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA) ← (byte) 0 [ col#12 ] ( main:2 [ col#12 ] { } ) always clobbers reg byte a -Statement [13] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_VBLANK) ← (byte) 0 [ col#12 ] ( main:2 [ col#12 ] { } ) always clobbers reg byte a -Statement [18] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC) ← (byte) 0 [ col#1 ] ( main:2 [ col#1 ] { } ) always clobbers reg byte a -Statement [19] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_VBLANK) ← (byte) 2 [ col#1 ] ( main:2 [ col#1 ] { } ) always clobbers reg byte a -Statement [20] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_COLUBK) ← (byte) 0 [ col#1 ] ( main:2 [ col#1 ] { } ) always clobbers reg byte a -Statement [23] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC) ← (byte) 0 [ col#1 main::i2#2 ] ( main:2 [ col#1 main::i2#2 ] { } ) always clobbers reg byte a -Statement [25] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC) ← (byte) 0 [ col#1 main::i1#2 main::c#2 ] ( main:2 [ col#1 main::i1#2 main::c#2 ] { } ) always clobbers reg byte a -Statement [29] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC) ← (byte) 0 [ col#12 main::i#2 ] ( main:2 [ col#12 main::i#2 ] { } ) always clobbers reg byte a -Potential registers mem[1] [ col#12 col#1 ] : mem[1] , reg byte x , reg byte y , +Statement [6] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA) ← (byte) 2 [ idx#12 ] ( main:2 [ idx#12 ] { } ) always clobbers reg byte a +Statement [7] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC) ← (byte) 0 [ idx#12 ] ( main:2 [ idx#12 ] { } ) always clobbers reg byte a +Statement [8] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC) ← (byte) 0 [ idx#12 ] ( main:2 [ idx#12 ] { } ) always clobbers reg byte a +Statement [9] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC) ← (byte) 0 [ idx#12 ] ( main:2 [ idx#12 ] { } ) always clobbers reg byte a +Statement [10] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA) ← (byte) 0 [ idx#12 ] ( main:2 [ idx#12 ] { } ) always clobbers reg byte a +Statement [13] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_VBLANK) ← (byte) 0 [ idx#12 ] ( main:2 [ idx#12 ] { } ) always clobbers reg byte a +Statement [18] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC) ← (byte) 0 [ idx#1 ] ( main:2 [ idx#1 ] { } ) always clobbers reg byte a +Statement [19] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_VBLANK) ← (byte) 2 [ idx#1 ] ( main:2 [ idx#1 ] { } ) always clobbers reg byte a +Statement [20] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_COLUBK) ← (byte) 0 [ idx#1 ] ( main:2 [ idx#1 ] { } ) always clobbers reg byte a +Statement [23] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC) ← (byte) 0 [ idx#1 main::i2#2 ] ( main:2 [ idx#1 main::i2#2 ] { } ) always clobbers reg byte a +Statement [25] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC) ← (byte) 0 [ idx#1 main::i1#2 main::c#2 ] ( main:2 [ idx#1 main::i1#2 main::c#2 ] { } ) always clobbers reg byte a +Statement [29] *((byte*)(const nomodify struct ATARI_TIA_WRITE*) TIA+(const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC) ← (byte) 0 [ idx#12 main::i#2 ] ( main:2 [ idx#12 main::i#2 ] { } ) always clobbers reg byte a +Potential registers mem[1] [ idx#12 idx#1 ] : mem[1] , reg byte x , reg byte y , Potential registers zp[1]:2 [ main::i#2 main::i#1 ] : zp[1]:2 , reg byte x , reg byte y , Potential registers zp[1]:3 [ main::i1#2 main::i1#1 ] : zp[1]:3 , reg byte x , reg byte y , Potential registers zp[1]:4 [ main::c#2 main::c#0 main::c#1 ] : zp[1]:4 , reg byte x , reg byte y , @@ -766,28 +775,29 @@ Potential registers zp[1]:5 [ main::i2#2 main::i2#1 ] : zp[1]:5 , reg byte x , r REGISTER UPLIFT SCOPES Uplift Scope [main] 3,003: zp[1]:2 [ main::i#2 main::i#1 ] 3,003: zp[1]:5 [ main::i2#2 main::i2#1 ] 2,602.6: zp[1]:3 [ main::i1#2 main::i1#1 ] 1,878: zp[1]:4 [ main::c#2 main::c#0 main::c#1 ] -Uplift Scope [] 178.96: mem[1] [ col#12 col#1 ] +Uplift Scope [] 178.96: mem[1] [ idx#12 idx#1 ] Uplift Scope [ATARI_TIA_WRITE] Uplift Scope [ATARI_TIA_READ] Uplift Scope [MOS6532_RIOT] -Uplifting [main] best 8152 combination reg byte x [ main::i#2 main::i#1 ] reg byte x [ main::i2#2 main::i2#1 ] reg byte y [ main::i1#2 main::i1#1 ] reg byte x [ main::c#2 main::c#0 main::c#1 ] -Uplifting [] best 8152 combination mem[1] [ col#12 col#1 ] -Uplifting [ATARI_TIA_WRITE] best 8152 combination -Uplifting [ATARI_TIA_READ] best 8152 combination -Uplifting [MOS6532_RIOT] best 8152 combination -Attempting to uplift remaining variables inmem[1] [ col#12 col#1 ] -Uplifting [] best 8152 combination mem[1] [ col#12 col#1 ] +Uplifting [main] best 8197 combination reg byte x [ main::i#2 main::i#1 ] reg byte x [ main::i2#2 main::i2#1 ] reg byte y [ main::i1#2 main::i1#1 ] reg byte x [ main::c#2 main::c#0 main::c#1 ] +Uplifting [] best 8197 combination mem[1] [ idx#12 idx#1 ] +Uplifting [ATARI_TIA_WRITE] best 8197 combination +Uplifting [ATARI_TIA_READ] best 8197 combination +Uplifting [MOS6532_RIOT] best 8197 combination +Attempting to uplift remaining variables inmem[1] [ idx#12 idx#1 ] +Uplifting [] best 8197 combination mem[1] [ idx#12 idx#1 ] ASSEMBLER BEFORE OPTIMIZATION // File Comments -// Minimal Atari 2600 VCS Program +// Demonstration Atari 2600 VCS Program // Source: https://atariage.com/forums/blogs/entry/11109-step-1-generate-a-stable-display/ // Upstart // Atari 2600 VCS 4K ROM -.file [name="atari2600-min.a26", type="bin", segments="Code, Vectors"] +.file [name="atari2600-demo.a26", type="bin", segments="Code, Data, Vectors"] .segmentdef Code [start=$f800,min=$f800,max=$fff9] -.segmentdef Data [start=$80,max=$ff, virtual] +.segmentdef Data [startAfter="Code",max=$fff9] +.segmentdef Vars [start=$80,max=$ff, virtual] .segmentdef Vectors [start=$fffa,max=$ffff] .segment Vectors .word main // NMI @@ -822,9 +832,9 @@ __bend: main: { // [5] phi from main to main::@1 [phi:main->main::@1] __b1_from_main: - // [5] phi (byte) col#12 = (byte) 0 [phi:main->main::@1#0] -- vbum1=vbuc1 + // [5] phi (byte) idx#12 = (byte) 0 [phi:main->main::@1#0] -- vbum1=vbuc1 lda #0 - sta col + sta idx jmp __b1 // main::@1 __b1: @@ -875,11 +885,12 @@ main: { // For now we're just going to output 192 colored scanlines lines so we have something to see. lda #0 sta TIA+OFFSET_STRUCT_ATARI_TIA_WRITE_VBLANK - // [14] (byte) main::c#0 ← (byte) col#12 -- vbuxx=vbum1 + // [14] (byte) main::c#0 ← *((const to_nomodify byte*) SINTABLE + (byte) idx#12) -- vbuxx=pbuc1_derefidx_vbum1 // D1=1, turns off Vertical Blank signal (image output on) - ldx col - // [15] (byte) col#1 ← ++ (byte) col#12 -- vbum1=_inc_vbum1 - inc col + ldy idx + ldx SINTABLE,y + // [15] (byte) idx#1 ← ++ (byte) idx#12 -- vbum1=_inc_vbum1 + inc idx // [16] phi from main::@5 to main::@6 [phi:main::@5->main::@6] __b6_from___b5: // [16] phi (byte) main::c#2 = (byte) main::c#0 [phi:main::@5->main::@6#0] -- register_copy @@ -919,7 +930,7 @@ main: { bcc __b10 // [5] phi from main::@9 to main::@1 [phi:main::@9->main::@1] __b1_from___b9: - // [5] phi (byte) col#12 = (byte) col#1 [phi:main::@9->main::@1#0] -- register_copy + // [5] phi (byte) idx#12 = (byte) idx#1 [phi:main::@9->main::@1#0] -- register_copy jmp __b1 // main::@10 __b10: @@ -963,7 +974,12 @@ main: { } // File Data .segment Data - col: .byte 0 + .align $100 +SINTABLE: +.fill $100, round(127.5+127.5*sin(2*PI*i/256)) + +.segment Vars + idx: .byte 0 ASSEMBLER OPTIMIZATIONS Removing instruction jmp __b1 @@ -1082,10 +1098,12 @@ FINAL SYMBOL TABLE (const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_COLUBK = (byte) 9 (const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_VBLANK = (byte) 1 (const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC = (byte) 2 +(const to_nomodify byte*) SINTABLE[(number) $100] = kickasm {{ .fill $100, round(127.5+127.5*sin(2*PI*i/256)) + }} (const nomodify struct ATARI_TIA_WRITE*) TIA = (struct ATARI_TIA_WRITE*) 0 -(byte) col -(byte) col#1 col mem[1] 78.71428571428571 -(byte) col#12 col mem[1] 100.25000000000001 +(byte) idx +(byte) idx#1 idx mem[1] 78.71428571428571 +(byte) idx#12 idx mem[1] 100.25000000000001 (void()) main() (label) main::@1 (label) main::@10 @@ -1111,7 +1129,7 @@ FINAL SYMBOL TABLE (byte) main::i2#1 reg byte x 2002.0 (byte) main::i2#2 reg byte x 1001.0 -mem[1] [ col#12 col#1 ] +mem[1] [ idx#12 idx#1 ] reg byte x [ main::i#2 main::i#1 ] reg byte y [ main::i1#2 main::i1#1 ] reg byte x [ main::c#2 main::c#0 main::c#1 ] @@ -1119,16 +1137,17 @@ reg byte x [ main::i2#2 main::i2#1 ] FINAL ASSEMBLER -Score: 6520 +Score: 6565 // File Comments -// Minimal Atari 2600 VCS Program +// Demonstration Atari 2600 VCS Program // Source: https://atariage.com/forums/blogs/entry/11109-step-1-generate-a-stable-display/ // Upstart // Atari 2600 VCS 4K ROM -.file [name="atari2600-min.a26", type="bin", segments="Code, Vectors"] +.file [name="atari2600-demo.a26", type="bin", segments="Code, Data, Vectors"] .segmentdef Code [start=$f800,min=$f800,max=$fff9] -.segmentdef Data [start=$80,max=$ff, virtual] +.segmentdef Data [startAfter="Code",max=$fff9] +.segmentdef Vars [start=$80,max=$ff, virtual] .segmentdef Vectors [start=$fffa,max=$ffff] .segment Vectors .word main // NMI @@ -1153,9 +1172,9 @@ Score: 6520 // main main: { // [5] phi from main to main::@1 [phi:main->main::@1] - // [5] phi (byte) col#12 = (byte) 0 [phi:main->main::@1#0] -- vbum1=vbuc1 + // [5] phi (byte) idx#12 = (byte) 0 [phi:main->main::@1#0] -- vbum1=vbuc1 lda #0 - sta col + sta idx // main::@1 // main::@2 __b2: @@ -1201,12 +1220,13 @@ main: { // For now we're just going to output 192 colored scanlines lines so we have something to see. lda #0 sta TIA+OFFSET_STRUCT_ATARI_TIA_WRITE_VBLANK - // c = col++ - // [14] (byte) main::c#0 ← (byte) col#12 -- vbuxx=vbum1 + // c = SINTABLE[idx++] + // [14] (byte) main::c#0 ← *((const to_nomodify byte*) SINTABLE + (byte) idx#12) -- vbuxx=pbuc1_derefidx_vbum1 // D1=1, turns off Vertical Blank signal (image output on) - ldx col - // [15] (byte) col#1 ← ++ (byte) col#12 -- vbum1=_inc_vbum1 - inc col + ldy idx + ldx SINTABLE,y + // [15] (byte) idx#1 ← ++ (byte) idx#12 -- vbum1=_inc_vbum1 + inc idx // [16] phi from main::@5 to main::@6 [phi:main::@5->main::@6] // [16] phi (byte) main::c#2 = (byte) main::c#0 [phi:main::@5->main::@6#0] -- register_copy // [16] phi (byte) main::i1#2 = (byte) 0 [phi:main::@5->main::@6#1] -- vbuyy=vbuc1 @@ -1244,7 +1264,7 @@ main: { cpx #$1e bcc __b10 // [5] phi from main::@9 to main::@1 [phi:main::@9->main::@1] - // [5] phi (byte) col#12 = (byte) col#1 [phi:main::@9->main::@1#0] -- register_copy + // [5] phi (byte) idx#12 = (byte) idx#1 [phi:main::@9->main::@1#0] -- register_copy jmp __b2 // main::@10 __b10: @@ -1293,5 +1313,10 @@ main: { } // File Data .segment Data - col: .byte 0 + .align $100 +SINTABLE: +.fill $100, round(127.5+127.5*sin(2*PI*i/256)) + +.segment Vars + idx: .byte 0 diff --git a/src/test/ref/atari2600-min.sym b/src/test/ref/examples/atari2600/atari2600-demo.sym similarity index 92% rename from src/test/ref/atari2600-min.sym rename to src/test/ref/examples/atari2600/atari2600-demo.sym index 4b6afb5f8..7a9b23ed1 100644 --- a/src/test/ref/atari2600-min.sym +++ b/src/test/ref/examples/atari2600/atari2600-demo.sym @@ -73,10 +73,12 @@ (const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_COLUBK = (byte) 9 (const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_VBLANK = (byte) 1 (const byte) OFFSET_STRUCT_ATARI_TIA_WRITE_WSYNC = (byte) 2 +(const to_nomodify byte*) SINTABLE[(number) $100] = kickasm {{ .fill $100, round(127.5+127.5*sin(2*PI*i/256)) + }} (const nomodify struct ATARI_TIA_WRITE*) TIA = (struct ATARI_TIA_WRITE*) 0 -(byte) col -(byte) col#1 col mem[1] 78.71428571428571 -(byte) col#12 col mem[1] 100.25000000000001 +(byte) idx +(byte) idx#1 idx mem[1] 78.71428571428571 +(byte) idx#12 idx mem[1] 100.25000000000001 (void()) main() (label) main::@1 (label) main::@10 @@ -102,7 +104,7 @@ (byte) main::i2#1 reg byte x 2002.0 (byte) main::i2#2 reg byte x 1001.0 -mem[1] [ col#12 col#1 ] +mem[1] [ idx#12 idx#1 ] reg byte x [ main::i#2 main::i#1 ] reg byte y [ main::i1#2 main::i1#1 ] reg byte x [ main::c#2 main::c#0 main::c#1 ]