diff options
author | B. Watson <urchlay@slackware.uk> | 2022-11-04 00:40:43 -0400 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2022-11-04 00:40:43 -0400 |
commit | c8d7d6039963ca84d74a42233a1524d1a98836f7 (patch) | |
tree | 47bd5914ccb0f49a0355e2521f36f432f8915412 | |
parent | 8d7e5662f08dada2f88fa03b6129fb0eb3119de0 (diff) | |
download | dla-asm-c8d7d6039963ca84d74a42233a1524d1a98836f7.tar.gz |
Micro-optimization: Self-modifying code!
-rw-r--r-- | dla.s | 34 |
1 files changed, 25 insertions, 9 deletions
@@ -380,13 +380,13 @@ jsaveimage: set_limits: ldx circlesize lda xmin,x - sta min_x + sta selfmod_xmin lda ymin,x - sta min_y + sta selfmod_ymin lda xmax,x - sta max_x + sta selfmod_xmax lda ymax,x - sta max_y + sta selfmod_ymax rts ;;; Subroutine: initscreen @@ -526,16 +526,21 @@ right: inc part_x ;3 checkbounds: + ; all the "cmp #0" here get their operands modified by set_limits. lda part_x - cmp min_x +selfmod_xmin = * + 1 + cmp #0 beq oob - cmp max_x +selfmod_xmax = * + 1 + cmp #0 beq oob ;sta cursor_x lda part_y - cmp min_y +selfmod_ymin = * + 1 + cmp #0 beq oob - cmp max_y +selfmod_ymax = * + 1 + cmp #0 beq oob ;sta cursor_y ; checkbounds is 30 cycles when the pixel is in bounds. @@ -573,12 +578,23 @@ slow_x: bne stick check_y: ; (0,-1) +.if 0 ldx part_y ;3 lda lineaddrs_l-1,x ;5 sta pixptr ;3 lda lineaddrs_h-1,x ;5 sta pixptr+1 ;3 ;=19 +.else + lda pixptr ; 3 + sec ; 2 + sbc #$20 ; 2 + sta pixptr ; 3 + bcs pp1ok ; 3|2 + dec pixptr+1 ; 0|5 + ; =13|17 (avg closer to 13) +pp1ok: +.endif ldx part_x ldy xoffsets,x lda xmasks,x @@ -594,7 +610,7 @@ check_y: bne stick jmp drunkwalk ; too far for a branch -stick: +stick: ; we always get here with Z flag clear rts ;;; Subroutine: drawseed |