Arrays in ASM question

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Post Reply
User avatar
sempressimo
Posts: 46
Joined: Wed Nov 04, 2015 7:13 am

Arrays in ASM question

Post by sempressimo »

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.
User avatar
Dwedit
Posts: 4470
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: Arrays in ASM question

Post by Dwedit »

It is exactly the same.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
User avatar
rainwarrior
Posts: 8062
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Arrays in ASM question

Post by rainwarrior »

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.
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Arrays in ASM question

Post by tepples »

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
furrykef
Posts: 35
Joined: Fri Mar 02, 2012 11:10 pm

Re: Arrays in ASM question

Post by furrykef »

sempressimo wrote:I thought is was the same, but I am having some bug related to this.
What's your bug, exactly?
User avatar
sempressimo
Posts: 46
Joined: Wed Nov 04, 2015 7:13 am

Re: Arrays in ASM question

Post by sempressimo »

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.
Post Reply