Banner
Views: 291,046,384
Time: 2014-04-25 01:20:52 AM
3 users online: Blittle McNilsen, GrandChaos9000, XerX - Guests: 18 - Bots: 66Users: 24,816 (1,109 active)
Latest: megamario x
Tip: If you plan on making long levels, be sure to include multiple midway points. A patch for this can be found in the Patches section.
confusion O.o
Forum Index - SMW Hacking - General SMW Hacking Help - ASM & Related Topics - confusion O.o
Pages: « 1 »
whenever I try to use Y as an index for something it won't work right.
example:

Code
shellpos: db $ff,$f8,$f8,$f8,		;small,big,cape,flower

adjustshell:
ldy $19			;index = current powerup			
lda shellpos,y
CLC                       
ADC $02                   
STA $d8,x
... 


But when I use X, there's no problem at all:

Code
phx
ldx $19			;index = current powerup			
lda shellpos,x
CLC                       
ADC $02
plx                   
STA $d8,x 


is there anything that I should know about using Y as an index?
Last edited on 2007-09-21 08:47:03 AM by ghettoyouth.
are you sure it could be used as an index?
The code looks fine, ghetto. What goes wrong when you're using Y? Depending on where the code is, you might need to be preserving the value of Y with phy/ply. My only other thought is that something isn't getting assembled properly. What assembler are you using and what is the resulting hex for the code you posted?
Are you sure this isn't because the 65816 don't have long adressing indexed with Y, only indexed with X, try adding:
Code
 PHK 
 PLB

before attempting to load the data at shellpos
Last edited on 2007-09-21 10:53:41 AM by Bio.
Bio is right. xkas defaults to using long addressing which is valiable for LDA indexed by X but not Y, so it doesn't include the full 24bits. Unless the DB was in the right spot at the time it would've failed, but the code above would do just that.
Originally posted by mikeyk
What goes wrong when you're using Y? Depending on where the code is, you might need to be preserving the value of Y with phy/ply. My only other thought is that something isn't getting assembled properly. What assembler are you using and what is the resulting hex for the code you posted?


It looks like it load the wrong adress (but it loads the correct one), the values are not correct.
I did phy/ply, I just posted a shorter version of the code. Here's the full part:

Code
adjustshell:

phy
lda $73
cmp #$04
beq ducking

ldy $19			;index = current powerup			
lda shellpos,y
CLC                       
ADC $02
                   
STA $d8,x 

LDA $03                   
ADC #$FF 		;ypos highbyte               
STA $14d4,X   
ply  
rtl


I'm using Xkas and this is the hexcode:

$1a:ce75 = f8 ff ff ff

a4 19 b9 75 ce 18 65 02 95 d8 ..

Originally posted by Bio
Are you sure this isn't because the 65816 don't have long adressing indexed with Y, only indexed with X, try adding:

PHK PLB

before attempting to load the data at shellpos


I tried that, but it causes graphical glitches and the shell is still in the wrong position.

Last edited on 2007-09-22 01:59:55 AM by ghettoyouth.
I believe bio was right -- you're loading from the wrong bank if you don't do what he suggested. Be sure to restore the original bank when you are done.

For nearly everything I do I wrap my routines like so:

PHB ; save original data bank
PHK ; \ data bank = code bank
PLB ; /
JSR MySubroutine
PLB ; restore original data bank
RTL
ok, it works now. thanks for all the help :)
Pages: « 1 »
Forum Index - SMW Hacking - General SMW Hacking Help - ASM & Related Topics - confusion O.o

The purpose of this site is not to distribute copyrighted material, but to honor one of our favourite games.

Copyright © 2005 - 2014 - SMW Central
Legal Information - Link To Us


Total queries: 29

Menu

Affiliates

  • Talkhaus
  • SMBX Community