This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

Arrays in ASM question

Arrays in ASM question
by on (#159024)
Lets say I have declared:

enemy_collided .rs 4

is it the same to refer to element zero as;

(a) STA enemy_collided

(b) STA enemy_collided, x (when x is 0)

I thought is was the same, but I am having some bug related to this.
Re: Arrays in ASM question
by on (#159027)
It is exactly the same.
Re: Arrays in ASM question
by on (#159033)
Not exactly the same. The finished result should be the same, but the indexed instructions take slightly longer to execute, and there are other obscure differences.
Re: Arrays in ASM question
by on (#159039)
If X = 0, absolute indexed loads take exactly as long as absolute loads. Stores take longer because the CPU is busy double-checking the carry from the low byte of the address to the high byte before it does anything permanent
Re: Arrays in ASM question
by on (#159059)
sempressimo wrote:
I thought is was the same, but I am having some bug related to this.


What's your bug, exactly?
Re: Arrays in ASM question
by on (#159190)
furrykef wrote:
sempressimo wrote:
I thought is was the same, but I am having some bug related to this.


What's your bug, exactly?


Cant tell know as I opted to rewrite most of the affected logic anyhow. Before I was treating the player as one object, enemeies as its own object array but then decided to just have them all as one object array and share background collision logic among others. Still keeping items as a separate objects.