So just trying to condense down some code and stumbled on a little issue with a carry value not working like i though it should. Thoughts on this?
;; a 16 bit variable for tileAddress - this is the address at which a tile will change
;; an 8 bit variable tileStartAddress that correlates with the low byte of the tile address
;...at inception of code run - keeps the 'left position', essentially
;; an 8 bit variable tileRow, which will be used to count the rows.
LDA tileRow
CLC
ADC #$20
STA tileRow ;; now this should 'jump down' a row.
CLC
ADC tileStartAddress ;; however far the left was over, it is again
;; started a new line, back to first column
STA tileAddress
;; at this point, there may be a carry flag, and if so, should
;; pass on to the high byte if not cleared?
LDA tileAddress+1
ADC #$00
STA tileAddress+1
;;; my thought is that when the low byte reaches #$FF,
;;; it should increase back to zero, and the high byte
;;; should increase by one since the flag is never cleared. However, the high byte is
;; never increasing, and the update jumps back up...
;; so if the original high byte was 20 and the low E0,
;; when the low increased to FF, it should become
;; 21 00, but instead it becomes 20 00.
Hope I was able to explain that alright. Any thoughts on this, or a better method?
Thanks!
Code:
;; a 16 bit variable for tileAddress - this is the address at which a tile will change
;; an 8 bit variable tileStartAddress that correlates with the low byte of the tile address
;...at inception of code run - keeps the 'left position', essentially
;; an 8 bit variable tileRow, which will be used to count the rows.
LDA tileRow
CLC
ADC #$20
STA tileRow ;; now this should 'jump down' a row.
CLC
ADC tileStartAddress ;; however far the left was over, it is again
;; started a new line, back to first column
STA tileAddress
;; at this point, there may be a carry flag, and if so, should
;; pass on to the high byte if not cleared?
LDA tileAddress+1
ADC #$00
STA tileAddress+1
;;; my thought is that when the low byte reaches #$FF,
;;; it should increase back to zero, and the high byte
;;; should increase by one since the flag is never cleared. However, the high byte is
;; never increasing, and the update jumps back up...
;; so if the original high byte was 20 and the low E0,
;; when the low increased to FF, it should become
;; 21 00, but instead it becomes 20 00.
Hope I was able to explain that alright. Any thoughts on this, or a better method?
Thanks!