Skip to content

Commit

Permalink
Introduce inxy macro, which increments as a 16-bit value
Browse files Browse the repository at this point in the history
This pattern is one byte shorter than CLC / ADC #1, and is used
in a handful of places already. Introduce a macro so it's clearer
what is going on.

No functional changes.
  • Loading branch information
inexorabletash committed Oct 2, 2023
1 parent a059ecc commit 585328e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 43 deletions.
9 changes: 9 additions & 0 deletions inc/macros.inc
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,15 @@ end:
sty arg+1
.endmacro

;;; Increment X,Y as a 16-bit number (x lo, y hi)
.macro inxy
.local skip
inx
bne skip
iny
skip:
.endmacro

;;; Core for add16/sub16
.macro _addsub16 op, opc, arg1, arg2, arg3, arg4, arg5, arg6
.if _is_register {arg2} && _is_register {arg4} && _is_register {arg6}
Expand Down
10 changes: 3 additions & 7 deletions lib/alert_dialog.s
Original file line number Diff line number Diff line change
Expand Up @@ -342,13 +342,9 @@ done_buttons:
.ifdef AD_WRAP
.scope
;; Measure for splitting
ldx alert_params::text
ldy alert_params::text + 1
inx
bne :+
iny
: stx textwidth_params::data
sty textwidth_params::data + 1
ldxy alert_params::text
inxy
stxy textwidth_params::data

ptr := $06
copy16 alert_params::text, ptr
Expand Down
53 changes: 17 additions & 36 deletions toolkits/icontk.s
Original file line number Diff line number Diff line change
Expand Up @@ -2111,15 +2111,10 @@ start: lda more_drawing_needed_flag

;; cr_l = cr_r + 1
;; vx = cr_r + 1
ldx cr_r
ldy cr_r+1
inx
stx cr_l
stx vx
bne :+
iny
: sty cr_l+1
sty vx+1
ldxy cr_r
inxy
stxy cr_l
stxy vx

;; cr_t = clip_bounds::y1
;; cr_r = clip_bounds::x2
Expand Down Expand Up @@ -2277,20 +2272,15 @@ vert: scmp16 cr_t, win_t

;; Cases 1/4 (and done)
;; if (win_b < cr_b)
;; . cr_t = win_b + 2
;; . vy = win_b + 2
;; . cr_t = win_b + 1
;; . vy = win_b + 1
: scmp16 win_b, cr_b
bpl case2

ldx win_b
ldy win_b+1
inx
stx cr_t
stx vy
bne :+
iny
: sty cr_t+1
sty vy+1
ldxy win_b
inxy
stxy cr_t
stxy vy
jmp reclip

;; Case 2
Expand All @@ -2302,27 +2292,18 @@ case2:
scmp16 stash_r, win_r
bmi :+

lda win_r
clc
adc #1
sta cr_l
sta vx
lda win_r+1
adc #0
sta cr_l+1
sta vx+1
ldxy win_r
inxy
stxy cr_l
stxy vx
add16 stash_r, #2, cr_r
jmp reclip

;; Case 5 - done!
: copy16 clip_bounds::x2, cr_r
ldx clip_bounds::x2
ldy clip_bounds::x2 + 1
inx
bne :+
iny
: stx cr_l
sty cr_l + 1
ldxy clip_bounds::x2
inxy
stxy cr_l
jmp set_bits
.endproc ; CalcWindowIntersections

Expand Down

0 comments on commit 585328e

Please sign in to comment.