diff options
author | B. Watson <urchlay@slackware.uk> | 2022-11-05 01:43:36 -0400 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2022-11-05 01:43:36 -0400 |
commit | 7746f34350e46f6d508aac3f99d47d8f232c42f2 (patch) | |
tree | ccab0c04865ab61cee4c24fda89c3420d888b732 | |
parent | 530856dd404bea232f560ec82fa956649e7bf688 (diff) | |
download | dla-asm-7746f34350e46f6d508aac3f99d47d8f232c42f2.tar.gz |
Save ~15 cycles in drunkwalk.
-rw-r--r-- | dla.s | 29 |
1 files changed, 13 insertions, 16 deletions
@@ -511,41 +511,38 @@ drunkwalk: ldx part_x ;3 ; using bit/bmi/bvc saves 5.25 cycles on average, compared to ; immediate cmp and bne. - ; 4 code paths: up=16, down=17, left=15, right=13, avg=15.25. + ; 4 code paths: up=15, down=18, left=19, right=17, avg=17.25. ; note that part_x and part_y are *never* zero; all the bne's here ; are "branch always". + ; all the "cmp #0" here get their operands modified by set_limits. dwloop: ldy part_y bit RANDOM ;4 ; use top 2 bits (probably more random, definitely faster) bmi lr ;2/3 bvc down ;2/3 dey ;2 ; N=1 V=1 up - bne checkbounds ;3 +selfmod_ymin = * + 1 + cpy #0 ; 2 + beq oob ; 2 + bne checkneigh ;3 down: iny ;2 ; N=1 V=0 down - bne checkbounds ;3 +selfmod_ymax = * + 1 + cpy #0 ; 2 + beq oob ; 2 + bne checkneigh ;3 lr: bvc right ;2/3 dex ;3 ; N=0 V=1 left - bne checkbounds ;3 -right: - inx ;3 ; N=0 V=0 right - -checkbounds: - ; all the "cmp #0" here get their operands modified by set_limits. selfmod_xmin = * + 1 cpx #0 ; 2 beq oob ; 2 + bne checkneigh ;3 +right: + inx ;3 ; N=0 V=0 right selfmod_xmax = * + 1 cpx #0 ; 2 beq oob ; 2 -selfmod_ymin = * + 1 - cpy #0 ; 2 - beq oob ; 2 -selfmod_ymax = * + 1 - cpy #0 ; 2 - beq oob ; 2 - ; checkbounds is 16 cycles when the pixel is in bounds. checkneigh: ; check neighbors. used to be a subroutine, inlined it. |