diff --git a/codeGenCpu6502/src/prog8/codegen/cpu6502/AsmGen.kt b/codeGenCpu6502/src/prog8/codegen/cpu6502/AsmGen.kt index fdbbcfd2c..c313b119b 100644 --- a/codeGenCpu6502/src/prog8/codegen/cpu6502/AsmGen.kt +++ b/codeGenCpu6502/src/prog8/codegen/cpu6502/AsmGen.kt @@ -813,6 +813,9 @@ class AsmGen6502Internal ( } internal fun assignExpressionTo(value: PtExpression, target: AsmAssignTarget) { + + // this is basically the fallback assignment routine, it is RARELY called + when { target.datatype.isByteOrBool -> { if (value.asConstInteger()==0) { diff --git a/docs/source/structpointers.rst b/docs/source/structpointers.rst index 6137af127..caea0f6dc 100644 --- a/docs/source/structpointers.rst +++ b/docs/source/structpointers.rst @@ -132,7 +132,7 @@ dealing with all of them separately. You first define the struct type like so:: You can use boolean fields, numeric fields (byte, word, float), and pointer fields (including str, which is translated into ^^ubyte). You cannot nest struct types nor put arrays in them as a field. Fields in a struct are 'packed' (meaning the values are placed back-to-back in memory), and placed in memory in order of declaration. This guarantees exact size and place of the fields. -``sizeof()`` knows how to calculate the size of a struct. +``sizeof()`` knows how to calculate the combined size of a struct, and ``offsetof()`` can be used to get the byte offset of a given field in the struct. The size of a struct cannot exceed 1 memory page (256 bytes). You can copy the whole contents of a struct to another one by assigning the dereferenced pointers:: diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 51c1d91c5..9d749365f 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -170,6 +170,7 @@ Libraries Optimizations ------------- +- check that expressions such as targetvar = value1 + value2 , targetvar = value1 ^ value2 etc. use the target variable directly and not use needless temp var / registers - Port benchmarks from https://thred.github.io/c-bench-64/ to prog8 and see how it stacks up. - Since fixing the missing zp-var initialization, programs grew in size again because STZ's reappered. Can we add more intelligent (and correct!) optimizations to remove those STZs that might be redundant again? - in Identifier: use typedarray of strings instead of listOf? Other places? diff --git a/examples/c64/sprites.p8 b/examples/c64/sprites.p8 index 98a83f6be..127c805ea 100644 --- a/examples/c64/sprites.p8 +++ b/examples/c64/sprites.p8 @@ -7,17 +7,17 @@ main { sub start() { - txt.print("balloon sprites!\n...we are all floating...\n") + txt.print("balloon sprites!\n...we are all floating...\nborders are open too\n") ubyte @zp i for i in 0 to 7 { c64.set_sprite_ptr(i, &spritedata.balloonsprite) ; alternatively, set directly: c64.SPRPTR[i] = $0a00 / 64 - c64.SPXY[i*2] = 50+25*i + c64.SPXY[i*2] = 60+22*i c64.SPXY[i*2+1] = math.rnd() } - c64.SPENA = 255 ; enable all sprites - sys.set_rasterirq(&irq.irqhandler, 255) ; enable animation + c64.SPENA = 255 ; enable all sprites + sys.set_rasterirq(&irq.irqhandler, 248) ; trigger irq just above bottom border line } } @@ -25,6 +25,7 @@ main { irq { sub irqhandler() -> bool { + c64.SCROLY = 19 ; 24 row mode, preparing for border opening c64.EXTCOL-- ; float up & wobble horizontally @@ -39,6 +40,7 @@ irq { } c64.EXTCOL++ + c64.SCROLY = 27 ; 25 row mode, border is open return true }