From e5ee5be9c5031dcd39f3234f744c34e4df34823d Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sat, 10 Oct 2020 04:37:12 +0200 Subject: [PATCH] textelite --- docs/source/todo.rst | 4 +--- examples/test.p8 | 34 ---------------------------------- examples/textelite.p8 | 37 +++++++++---------------------------- 3 files changed, 10 insertions(+), 65 deletions(-) diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 0fbdae9b4..ec1fd333b 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -3,8 +3,6 @@ TODO ==== - get rid of all other TODO's in the code ;-) -- make it possible for array literals to not only contain compile time constants? -- allow assignment of all elements of an array at once via new array literal assignment (flatten, like with struct) - implement @stack for asmsub parameters - make it possible to use cpu opcodes such as 'nop' as variable names by prefixing all asm vars with something such as '_' - option to load the built-in library files from a directory instead of the embedded ones (for easier library development/debugging) @@ -20,7 +18,7 @@ Add more compiler optimizations to the existing ones. - further optimize assignment codegeneration, such as the following: - binexpr splitting (beware self-referencing expressions and asm code ballooning though) -- subroutine calling convention? like: 1 byte arg -> pass in A, 2 bytes -> pass in A+Y, return value likewise. +- subroutine calling convention? like: 1 byte arg -> pass in A, 2 bytes -> pass in A+Y, return value likewise. Especially for built-in functions! - can such parameter passing to subroutines be optimized to avoid copying? - more optimizations on the language AST level - more optimizations on the final assembly source level diff --git a/examples/test.p8 b/examples/test.p8 index f8c1ab6a9..e5ca95d4a 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -7,40 +7,6 @@ main { sub start() { - const ubyte c1 = 111 - const ubyte c2 = 122 - const ubyte c3 = 133 - ubyte ii - - - for ii in [c1, c2, c3] { - txt.print_ub(ii) - } - -; ubyte[3] numbers -; -; for ii in [55,44,33] { -; txt.print_ub(ii) -; } - -; ubyte a = 99 -; ubyte b = 88 -; ubyte c = 77 -; -; ;numbers = numbers ; TODO optimize away -; -; numbers = [c1,c2,c3] -; numbers = [1,2,3] -; numbers = [a,b,c] -; -; ubyte[] a1 = [c1,c2,c3] -; ubyte[3] a2 -; -; a2 = [a,b,c] -; -; txt.print_ub(a) -; txt.print_ub(b) -; txt.print_ub(c) } asmsub testX() { diff --git a/examples/textelite.p8 b/examples/textelite.p8 index 85a425729..ee5b91064 100644 --- a/examples/textelite.p8 +++ b/examples/textelite.p8 @@ -13,20 +13,13 @@ main { txt.print("\n--> TextElite conversion to Prog8 <--\n") ubyte systemNr - ; for systemNr in [galaxy.numforLave, galaxy.numforZaonce, galaxy.numforDiso] { ; TODO fix compiler crash, should be able to iterate over array literal - - - galaxy.init(1) - repeat galaxy.numforLave+1 { - galaxy.generate_next_planet() + for systemNr in [galaxy.numforLave, galaxy.numforZaonce, galaxy.numforDiso] { + galaxy.init(1) + repeat systemNr+1 { + galaxy.generate_next_planet() + } + planet.display(false) } - planet.display(false) - - galaxy.init(1) - repeat galaxy.numforZaonce+1 { - galaxy.generate_next_planet() - } - planet.display(false) repeat { str input = "????????" @@ -80,11 +73,7 @@ galaxy { sub init(ubyte galaxynum) { number = galaxynum planet.number = 255 - ; TODO make this work: seed = [base0, base1, base2] - seed[0] = base0 - seed[1] = base1 - seed[2] = base2 - + seed = [base0, base1, base2] repeat galaxynum-1 { nextgalaxy() } @@ -95,9 +84,7 @@ galaxy { ; Apply to base seed; once for galaxy 2 ; twice for galaxy 3, etc. ; Eighth application gives galaxy 1 again - seed[0] = twist(seed[0]) - seed[1] = twist(seed[1]) - seed[2] = twist(seed[2]) + seed = [twist(seed[0]), twist(seed[1]), twist(seed[2])] planet.number = 255 } @@ -177,8 +164,6 @@ galaxy { planet.productivity *= planet.population * 8 ubyte seed2_msb = msb(seed[2]) planet.radius = mkword((seed2_msb & 15) + 11, planet.x) - ;planet.radius = 256 * (((seed[2] >> 8) & 15) + 11) + planet.x ; TODO why not the same answer?? - planet.species_is_alien = lsb(seed[2]) & 128 ; bit 7 of w2_lo if planet.species_is_alien { planet.species_size = (seed2_msb >> 2) & 7 ; bits 2-4 of w2_hi @@ -187,11 +172,7 @@ galaxy { planet.species_kind = (planet.species_look + (seed2_msb & 3)) & 7 ;Add bits 0-1 of w2_hi to A from previous step, and take bits 0-2 of the result } - ; TODO make this work: planet.goatsoup_seed = [seed[1] & $FF, seed[1] >> 8, seed[2] & $FF, seed[2] >> 8] - planet.goatsoup_seed[0] = lsb(seed[1]) - planet.goatsoup_seed[1] = msb(seed[1]) - planet.goatsoup_seed[2] = lsb(seed[2]) - planet.goatsoup_seed[3] = seed2_msb + planet.goatsoup_seed = [lsb(seed[1]), msb(seed[1]), lsb(seed[2]), seed2_msb] } sub tweakseed() {