uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit 93a48027821c92cfc20de587f312afc50ed5461b
parent c6c31aa81546ac2348efd4031e3130ca22e9d9a0
Author: Andrew Alderwick <andrew@alderwick.co.uk>
Date:   Thu, 26 Aug 2021 23:27:18 +0100

Lots of INC optimisations

Diffstat:
Mprojects/examples/blank.tal | 18+++++++++---------
Mprojects/examples/demos/automata.tal | 4++--
Mprojects/examples/demos/bifurcan.tal | 6+++---
Mprojects/examples/demos/darena.tal | 12++++++------
Mprojects/examples/demos/font.tal | 8++++----
Mprojects/examples/demos/move.tal | 2+-
Mprojects/examples/demos/neralie.tal | 10+++++-----
Mprojects/examples/demos/theme.tal | 18+++++++++---------
Mprojects/examples/devices/console.lib.tal | 2+-
Mprojects/examples/devices/file.load.tal | 2+-
Mprojects/examples/devices/file.tal | 2+-
Mprojects/examples/gui/proportional-font.tal | 2+-
Mprojects/examples/gui/wallpaper.tal | 6+++---
Mprojects/software/asma.tal | 46+++++++++++++++++++++++-----------------------
Mprojects/software/repl.tal | 10+++++-----
15 files changed, 74 insertions(+), 74 deletions(-)

diff --git a/projects/examples/blank.tal b/projects/examples/blank.tal @@ -41,18 +41,18 @@ #0fc5 .System/g DEO2 #0f25 .System/b DEO2 - #01 .lista #00 + STZ - #02 .lista #01 + STZ + #01 .lista STZ + #02 .lista INC STZ #03 .lista #02 + STZ - #10 .listb #00 + STZ - #20 .listb #01 + STZ + #10 .listb STZ + #20 .listb INC STZ #30 .listb #02 + STZ .lista .listb .listc ;add-lists-loop JSR2 - .listc LDZ DEBUG - .listc #01 + LDZ DEBUG + .listc LDZ DEBUG + .listc INC LDZ DEBUG .listc #02 + LDZ DEBUG BRK @@ -64,8 +64,8 @@ vectors (a.k.a. arrays) of three elements each. ) STH ( a[0] b[0] + ) LDZk STH SWP LDZk STHr + STHkr STZ - ( a[1] b[1] + ) #01 + LDZk STH SWP #01 + LDZk STHr + STHkr #01 + STZ - ( a[2] b[2] + ) #01 + LDZ SWP #01 + LDZ + STHr #02 + STZ + ( a[1] b[1] + ) INC LDZk STH SWP INC LDZk STHr + STHkr INC STZ + ( a[2] b[2] + ) INC LDZ SWP INC LDZ + STHr #02 + STZ RTN @@ -78,7 +78,7 @@ RTN ( get a[x] ) OVR2 STHkr ADD LDZ ( get b[x] ) SWP STHkr ADD LDZ ( set c[x] ) ADD STHr STHkr ADD STZ - ( incr ) SWP #01 ADD SWP + ( incr ) SWP INC SWP LTHk ,&loop JCN POP2 POP2 POPr diff --git a/projects/examples/demos/automata.tal b/projects/examples/demos/automata.tal @@ -1,7 +1,7 @@ ( Project by Alex Schroeder - https://alexschroeder.ch ) %RTN { JMP2r } -%INCR { SWP #01 ADD SWP } +%INCR { SWP INC SWP } %CELL { #1000 } %NEXT { #2000 } @@ -62,7 +62,7 @@ RTN OVR DUP DUP ( three copies of the counter ) #01 SUB #00 SWP CELL ADD2 LDA SWP - #01 ADD #00 SWP CELL ADD2 LDA + INC #00 SWP CELL ADD2 LDA ( the cell dies if the neighbors are either both dead or both alive, i.e. Rule 90 ) NEQ ( one copy of the counter and the life value ) diff --git a/projects/examples/demos/bifurcan.tal b/projects/examples/demos/bifurcan.tal @@ -66,7 +66,7 @@ BRK ;draw-cursor JSR2 .Mouse/state DEI #00 EQU ,&no-touch JCN - ( incr ) .style LDZ #01 ADD #03 MOD .style STZ + ( incr ) .style LDZ INC #03 MOD .style STZ ( bg ) ;tiles .style LDZ #40 SFT TOS ADD2 ;cover-pattern JSR2 ( fg ) ;redraw JSR2 ( release ) #00 .Mouse/state DEO @@ -77,7 +77,7 @@ BRK @on-button ( -> ) .Controller/button DEI #00 EQU ,&no-touch JCN - ( incr ) .style LDZ #01 ADD #03 MOD .style STZ + ( incr ) .style LDZ INC #03 MOD .style STZ ( bg ) ;tiles .style LDZ #40 SFT TOS ADD2 ;cover-pattern JSR2 ( fg ) ;redraw JSR2 ( release ) #00 .Mouse/state DEO @@ -127,7 +127,7 @@ RTN ( set style ) .style LDZ #40 SFT TOS ADD2 .Screen/addr DEO2 ( draw ) #01 .Screen/sprite DEO - ( incr ) SWP #01 ADD SWP + ( incr ) SWP INC SWP LTHk ,&loop JCN POP2 POPr diff --git a/projects/examples/demos/darena.tal b/projects/examples/demos/darena.tal @@ -87,7 +87,7 @@ BRK @on_frame ( -> ) - ;f_count LDA #01 ADD DUP ;f_count STA ( increase frame counter ) + ;f_count LDA INC DUP ;f_count STA ( increase frame counter ) ;ani_speedmask LDA ( mask with animation speed mask ) AND #00 EQU ,update_frame JCN ( jump to update if it's time ) BRK @@ -127,7 +127,7 @@ BRK #40 .Screen/sprite DEO - #01 ADD + INC DUP2 NEQ ,&rocks_loop JCN POP2 @@ -162,7 +162,7 @@ JMP2r DUP ;r_color ROT #00 SWP ADD2 LDA #41 ADD .Screen/sprite DEO - #01 ADD + INC DUP2 NEQ ,&rocks_loop JCN @@ -239,7 +239,7 @@ JMP2r ( check collision with rocks ) ( nrocks #00 ) - ,&src_i LDR nrocks_mask AND DUP #01 ADD nrocks_mask AND + ,&src_i LDR nrocks_mask AND DUP INC nrocks_mask AND &rocks_loop DUP ( get rocks_x[i] ) @@ -254,7 +254,7 @@ JMP2r ,&src_y LDR ,&rock_y LDR ,&range_y LDR ADD LTH ( if sy < ry + 8 ) ADD ADD ADD #04 EQU ,&found JCN - #01 ADD nrocks_mask AND + INC nrocks_mask AND DUP2 NEQ ,&rocks_loop JCN POP2 @@ -426,7 +426,7 @@ JMP2r ( increment and save animation pointer ) &s_animate DUP - get_nibble_h #01 ADD #03 AND #40 SFT + get_nibble_h INC #03 AND #40 SFT SWP get_nibble_l ORA ;c_state STA JMP2r diff --git a/projects/examples/demos/font.tal b/projects/examples/demos/font.tal @@ -7,7 +7,7 @@ %RTN { JMP2r } %TOS { #00 SWP } -%INCR { SWP #01 ADD SWP } +%INCR { SWP INC SWP } ( devices ) @@ -67,7 +67,7 @@ BRK ( draw ) STHkr .Screen/sprite DEO ( use width ) .Screen/x DEI2 ++ .Screen/x DEO2 &continue - ( incr addr ) #0001 ++ + ( incr addr ) INC2 LDAk ,&loop JCN POP2 POP2 POPr @@ -86,7 +86,7 @@ RTN POP ,&continue JMP &no-linebreak STHkr ,&sprite JSR &continue - ( incr addr ) #0001 ++ + ( incr addr ) INC2 LDAk ,&loop JCN POP2 POP2 POPr RTN @@ -129,7 +129,7 @@ RTN POP ,&continue JMP &no-linebreak STHkr ,&sprite JSR &continue - ( incr addr ) #0001 ++ + ( incr addr ) INC2 LDAk ,&loop JCN POP2 POP2 POPr RTN diff --git a/projects/examples/demos/move.tal b/projects/examples/demos/move.tal @@ -1,6 +1,6 @@ ( dev/controller/buttons ) -%++ { #0001 ADD2 } +%++ { INC2 } %-- { #0001 SUB2 } %2// { #01 SFT2 } diff --git a/projects/examples/demos/neralie.tal b/projects/examples/demos/neralie.tal @@ -44,7 +44,7 @@ .lines/x1 LDZ2 .lines/x2 LDZ2 OVR2 OVR2 .lines/y1 LDZ2 ;h JSR2 .lines/y2 LDZ2 ;h JSR2 - .lines/y1 LDZ2 #0001 SUB2 .lines/y2 LDZ2 #0001 ADD2 + .lines/y1 LDZ2 #0001 SUB2 .lines/y2 LDZ2 INC2 OVR2 OVR2 .lines/x1 LDZ2 ;v JSR2 .lines/x2 LDZ2 ;v JSR2 @@ -61,7 +61,7 @@ #01 .Screen/sprite DEO #0000 #00 .number/count LDZ DUP2 ;h JSR2 - .number/count LDZ #01 ADD .number/count STZ + .number/count LDZ INC .number/count STZ @neralie-calc ( -- ) ( add up fractions of a pulse, store tenths in n6 ) @@ -143,7 +143,7 @@ &next ( digit-addr number* -- next-digit-addr next-number* prev-digit* ) #03e8 ;modf JSR2 STH2 #000a MUL2 - ROT DUP STH #01 ADD ROT ROT + ROT DUP STH INC ROT ROT #00 STHr LDZ ADD2 STH2r JMP2r @@ -194,7 +194,7 @@ ,&loop JMP @update-fps ( -- ) - .fps/next LDZ #01 ADD .fps/next STZ + .fps/next LDZ INC .fps/next STZ s .fps/second LDZ NEQ JMP JMP2r s .fps/second STZ .fps/next LDZ .fps/current STZ @@ -242,7 +242,7 @@ GTH2 ,&carry JCN JMP2r &carry - ROT #01 ADD ROT ROT + ROT INC ROT ROT JMP2r @font-numbers diff --git a/projects/examples/demos/theme.tal b/projects/examples/demos/theme.tal @@ -1,7 +1,7 @@ ( Dev/Screen ) %RTN { JMP2r } -%++ { #0001 ADD2 } +%++ { INC2 } %2// { #01 SFT2 } %4// { #02 SFT2 } %4** { #20 SFT2 } @@ -149,7 +149,7 @@ RTN &draw-pixel1 ( move ) OVR #30 SFT #00 SWP #0010 ADD2 .Screen/x DEO2 ( draw ) OVR .Screen/pixel DEO - ( incr ) SWP #01 ADD SWP + ( incr ) SWP INC SWP LTHk ,&draw-pixel1 JCN POP POP #0018 .Screen/y DEO2 @@ -157,7 +157,7 @@ RTN &draw-pixel2 ( move ) OVR #30 SFT #00 SWP #0010 ADD2 .Screen/x DEO2 ( draw ) OVR #08 ADD .Screen/pixel DEO - ( incr ) SWP #01 ADD SWP + ( incr ) SWP INC SWP LTHk ,&draw-pixel2 JCN POP POP #0020 .Screen/y DEO2 @@ -165,7 +165,7 @@ RTN &draw-icn1 ( move ) OVR #30 SFT #00 SWP #0010 ADD2 .Screen/x DEO2 ( draw ) OVR #00 ADD .Screen/sprite DEO - ( incr ) SWP #01 ADD SWP + ( incr ) SWP INC SWP LTHk ,&draw-icn1 JCN POP POP #0028 .Screen/y DEO2 @@ -173,7 +173,7 @@ RTN &draw-icn2 ( move ) OVR #30 SFT #00 SWP #0010 ADD2 .Screen/x DEO2 ( draw ) OVR #08 ADD .Screen/sprite DEO - ( incr ) SWP #01 ADD SWP + ( incr ) SWP INC SWP LTHk ,&draw-icn2 JCN POP POP #0030 .Screen/y DEO2 @@ -181,7 +181,7 @@ RTN &draw-chr1 ( move ) OVR #30 SFT #00 SWP #0010 ADD2 .Screen/x DEO2 ( draw ) OVR #80 ADD .Screen/sprite DEO - ( incr ) SWP #01 ADD SWP + ( incr ) SWP INC SWP LTHk ,&draw-chr1 JCN POP POP #0038 .Screen/y DEO2 @@ -189,7 +189,7 @@ RTN &draw-chr2 ( move ) OVR #30 SFT #00 SWP #0010 ADD2 .Screen/x DEO2 ( draw ) OVR #88 ADD .Screen/sprite DEO - ( incr ) SWP #01 ADD SWP + ( incr ) SWP INC SWP LTHk ,&draw-chr2 JCN POP POP @@ -294,10 +294,10 @@ RTN &hor ( save ) OVR2 .Screen/x DEO2 ( draw ) .color LDZ .Screen/pixel DEO - ( incr ) SWP2 #0001 ADD2 SWP2 + ( incr ) SWP2 INC2 SWP2 LTH2k ,&hor JCN POP2 POP2 STH2r STH2r - ( incr ) SWP2 #0001 ADD2 SWP2 + ( incr ) SWP2 INC2 SWP2 LTH2k ,&ver JCN POP2 POP2 POP2 POP2 diff --git a/projects/examples/devices/console.lib.tal b/projects/examples/devices/console.lib.tal @@ -34,7 +34,7 @@ BRK &loop ( send ) LDAk .Console/write DEO - ( incr ) #0001 ADD2 + ( incr ) INC2 ( loop ) LDAk ,&loop JCN POP2 diff --git a/projects/examples/devices/file.load.tal b/projects/examples/devices/file.load.tal @@ -46,7 +46,7 @@ #09 .Screen/sprite DEO .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2 &next - #0001 ADD2 + INC2 ,draw JMP &linefeed diff --git a/projects/examples/devices/file.tal b/projects/examples/devices/file.tal @@ -68,7 +68,7 @@ BRK &keep-going .Console/write DEO - #0001 ADD2 + INC2 ,print-string JMP @successtxt "Success! 09 $1 diff --git a/projects/examples/gui/proportional-font.tal b/projects/examples/gui/proportional-font.tal @@ -33,7 +33,7 @@ BRK #09 .Screen/sprite DEO ,get-x-advance JSR .Screen/x DEI2 ADD2 STH2kr ADD2 .Screen/x DEO2 &next - #0001 ADD2 + INC2 ,&loop JMP &linefeed diff --git a/projects/examples/gui/wallpaper.tal b/projects/examples/gui/wallpaper.tal @@ -21,11 +21,11 @@ #ffff &loop DUP2 ,row JSR - #0001 ADD2 + INC2 DUP2 .Screen/height DEI2 LTH2 ,&loop JCN POP2 .scroll/wait LDZ ,&noscroll JCN - .scroll/y LDZ2 #0001 ADD2 .scroll/y STZ2 + .scroll/y LDZ2 INC2 .scroll/y STZ2 BRK &noscroll @@ -55,7 +55,7 @@ OVR2 .Screen/x DEO2 #05 ADD .Screen/pixel DEO .Screen/y DEI2 - DUP2 #0001 ADD2 .Screen/y DEO2 + DUP2 INC2 .Screen/y DEO2 #00 .Screen/pixel DEO .Screen/y DEO2 POP diff --git a/projects/software/asma.tal b/projects/software/asma.tal @@ -162,7 +162,7 @@ #09 .Console/write DEO DUP2 #0004 ADD2 &loop - DUP2 #0001 ADD2 SWP2 LDA + DUP2 INC2 SWP2 LDA DUP #00 EQU ,&end JCN .Console/write DEO ,&loop JMP @@ -189,7 +189,7 @@ ( here ) DUP2 #0004 ADD2 &loop - DUP2 #0001 ADD2 SWP2 LDA + DUP2 INC2 SWP2 LDA DUP #00 EQU ,&end JCN .Console/write DEO ,&loop JMP @@ -211,7 +211,7 @@ &keep-going .Console/write DEO - #0001 ADD2 + INC2 ,asma-print-string JMP @asma-print-short ( short* -- ) @@ -244,7 +244,7 @@ ( fall through ) @asma-init-next-pass ( -- ) - ;asma/pass LDA #01 ADD ;asma/pass STA + ;asma/pass LDA INC ;asma/pass STA ;asma-write-buffer ;asma-output/ptr STA2 #0000 DUP2k ;asma-output/offset STA2 @@ -280,7 +280,7 @@ &last-one ADD2k #00 ROT ROT STA - #0001 ADD2 + INC2 ,asma-assemble-chunk JSR asma-IF-ERROR ,&error JCN ( flush output buffer ) @@ -307,7 +307,7 @@ &next-char-pop POP &next-char - #0001 ADD2 + INC2 &loop ( last-ptr* ptr* / start-of-token* ) OVR2 OVR2 LTH2 ,&end JCN LDAk ( last-ptr* ptr* char / start-of-token* ) @@ -318,10 +318,10 @@ STH2r ,asma-assemble-token JSR asma-IF-ERROR ,&error JCN #0a NEQ ,&not-newline JCN - ;asma/line LDA2 #0001 ADD2 ;asma/line STA2 + ;asma/line LDA2 INC2 ;asma/line STA2 &not-newline - DUP2 #0001 ADD2 STH2 ,&next-char JMP + DUP2 INC2 STH2 ,&next-char JMP &end POP2 POP2 STH2r @@ -361,7 +361,7 @@ &not-empty ( token* / ) ( truncate to one char long ) - #0001 ADD2 ( end* / ) + INC2 ( end* / ) STH2k LDAkr ( end* / end* char ) STH2k ( end* / end* char end* ) LITr 00 STH2 ( / end* char end* 00 end* ) @@ -420,7 +420,7 @@ LDAk DUP ,&not-end JCN POP POP2 - STH2r ROT #01 ADD DUPk ADD ADD + STH2r ROT INC DUPk ADD ADD JMP2r &not-end @@ -428,7 +428,7 @@ DUP #f0 AND ,&fail JCN LITr 40 SFT2r #00 STH STH ADD2r - #0001 ADD2 + INC2 ,&loop JMP &fail @@ -447,7 +447,7 @@ &not-end LITr 01 ADDr - #0001 ADD2 + INC2 ,&loop JMP %asma-SHORT-FLAG { #20 } @@ -510,7 +510,7 @@ &loop EQU2k ,&ready JCN #00 ,&write JSR - #0001 ADD2 + INC2 ,&loop JMP &rewound @@ -518,7 +518,7 @@ POP2 POP2 POP JMP2r &ready - POP2 #0001 ADD2 + POP2 INC2 DUP2 ;asma/addr STA2 ;asma/written-addr STA2 @@ -527,7 +527,7 @@ DUP2 ;asma-write-buffer/end EQU2 ,&flush JCN &after-flush STH2k STA - STH2r #0001 ADD2 ,asma-output/ptr STR2 + STH2r INC2 ,asma-output/ptr STR2 JMP2r &flush ( ptr* -- start-of-buffer* ) @@ -552,7 +552,7 @@ @asma-append-heap-byte ( dummy byte -- dummy ) ;asma/heap LDA2 OVR2 OVR2 STA POP - #0001 ADD2 ;asma/heap STA2 + INC2 ;asma/heap STA2 POP JMP2r @@ -568,7 +568,7 @@ POP2 JMP2r &keep-going - #0001 ADD2 + INC2 ,asma-append-heap-string JMP @asma-traverse-tree ( incoming-ptr* -- binary-ptr* 00 if key found @@ -595,7 +595,7 @@ ;asma/token LDA2 STH2 &loop ( node-key* / token* ) - DUP2 #0001 ADD2 SWP2 LDA LDAkr STHr + DUP2 INC2 SWP2 LDA LDAkr STHr ORAk ,&not-end JCN ( end of C strings, match found ) @@ -734,7 +734,7 @@ &not-end ;asma-write-byte JSR2 - #0001 ADD2 + INC2 ,&loop JMP @asma-literal-abs-addr @@ -775,7 +775,7 @@ @asma-addr-helper ( -- addr* ) ;asma/token LDA2 LDAk #26 NEQ ,&not-local JCN - #0001 ADD2 ;asma/token STA2 + INC2 ;asma/token STA2 ;asma-trees/scope LDA2 ,&final-lookup JMP @@ -788,7 +788,7 @@ &not-end ( token* char ) #2f EQU ,&found-slash JCN - #0001 ADD2 + INC2 ,&not-local JMP &found-slash ( token* ) @@ -797,7 +797,7 @@ SWP2 DUP2 #2f ROT ROT STA STHr ,&not-found2 JCN ( token* binary-ptr* ) - #0001 ADD2 ;asma/token STA2 + INC2 ;asma/token STA2 #0002 ADD2 &final-lookup ( addr-offset* incoming-ptr* ) @@ -861,7 +861,7 @@ JMP2r &keep-going - DUP2k ;asma-strlen JSR2 #00 SWP #0001 ADD2 ADD2 + DUP2k ;asma-strlen JSR2 #00 SWP INC2 ADD2 SWP2 ;asma-assemble-token JSR2 asma-IF-ERROR ,&error JCN ,&macro-loop JMP diff --git a/projects/software/repl.tal b/projects/software/repl.tal @@ -71,7 +71,7 @@ &append ;buffer/cursor LDA2 STH2k STA - STH2r #0001 ADD2 ;ring-buffer ORA2 ;buffer/cursor STA2 + STH2r INC2 ;ring-buffer ORA2 ;buffer/cursor STA2 ,&draw JMP &backspace @@ -92,7 +92,7 @@ DUP2 .File/name DEO2 ( find end of string for suffix ) &loop - #0001 ADD2 + INC2 LDAk ,&loop JCN ( suffix is cell size ) #0001 SUB2 LDAk #0f AND ;repl/font-cells STA @@ -112,7 +112,7 @@ POP POP2 - ;repl/font-cells LDA DUP MUL #08 MUL #01 ADD #00 .File/length DEO2 + ;repl/font-cells LDA DUP MUL #08 MUL INC #00 .File/length DEO2 ;font-data .File/load DEO2 JMP2r @@ -128,7 +128,7 @@ &not-end #00 SWP ;font-data ADD2 LDA LITr 00 STH ADD2r - #0001 ADD2 + INC2 ,&loop JMP @wrapped-write ( string* -- ) @@ -160,7 +160,7 @@ #00 ;repl/font-cells LDA #fff8 MUL2 .Screen/y DEI2 ADD2 .Screen/y DEO2 ;font-data ADD2 LDA #00 SWP .Screen/x DEI2 ADD2 .Screen/x DEO2 LDAk STH - #0001 ADD2 + INC2 STHr #20 GTH ;write JCN2 JMP2r