I mostly used this page to know what’s possible, and occasionally reinvented the wheel. Conditional jumps are still arcane and fragile in my hands. But I benchmarked all kinds of sequential memory access patterns before realizing the 6502 does not give a dang about reusing the same address.
On Z80, you want to load two registers, use them as a pointer, and tweak the low byte. The 6502 can just take an address and an offset in four cycles. So if you want to access $3000 as an array and read index 4, 5, 6, 7, you don’t LDX 4 and INC X, you LDX 4 and then LDA $3000,X, LDA $3001,X, LDA $3002,X, LDA $3004,X. For e.g. controller reads, you can hardcode bare addresses and it’s twice as fast.
I mostly used this page to know what’s possible, and occasionally reinvented the wheel. Conditional jumps are still arcane and fragile in my hands. But I benchmarked all kinds of sequential memory access patterns before realizing the 6502 does not give a dang about reusing the same address.
On Z80, you want to load two registers, use them as a pointer, and tweak the low byte. The 6502 can just take an address and an offset in four cycles. So if you want to access $3000 as an array and read index 4, 5, 6, 7, you don’t LDX 4 and INC X, you LDX 4 and then LDA $3000,X, LDA $3001,X, LDA $3002,X, LDA $3004,X. For e.g. controller reads, you can hardcode bare addresses and it’s twice as fast.