I'm still learning how to wrap my head around handling High Bytes and Low Bytes. I swear, making 16-bit values with only 8-bit registers is like trying to drive a car that can only turn right. If you want to turn left, you need to find away to safely turn the car right three times without crashing.
I'm working with a generic virtual machine and the memory addresses for the display data is between $0200 and $05ff.
My plan is to make an incrementing 16 bit number starting at 0200 and increments until it hits 05ff. Every time it increments, the high byte and low byte will be stored in the zero page and the program will read the high and low bytes to see where the display data needs to be written in that loop. Basically, I want to use this pointer to "sweep the display" with a single color.
This program is designed to be run in the dirt simple Easy6502 Virtual Machine
https://skilldrick.github.io/easy6502/
LDA #$01 ;Initial values
LDX #$00
LDY #$02
STX $00 ;low byte
STY $01 ;high byte
mainloop: ;placeholder program loop
JSR counter ;increment pointer
LDY $01 ;checking high byte
CPY #$05
BNE mainloop ;loop again
LDX $00 ;checking low byte
CPX #$ff
BNE mainloop ;loop again
BRK ;when value is 05ff, end
counter: ;incrementing subroutine
l_up: ;increment low byte
LDX $00
INC $00
CPX #$ff ;check if high byte needs to be incremented
BEQ h_up
RTS ;if not, return to main loop
h_up: ;increment high byte and return to main loop
INC $01
RTS
The snag I'm getting into is how to get the program to read the recorded values. Then treating it as a display data pointer, so I can load color values onto the display.
I feel like it involves Indexed Indirect Addressing somehow, but I for the life of me can't figure it out. Can someone here please tell me the super simple and obvious thing im completely over looking? Because I'm stumped.
Thanks for humoring me.