| confusion O.o |
|
Forum Index - SMW Hacking - General SMW Hacking Help - ASM & Related Topics - confusion O.o |
|
Pages: 1  |
|
|
|
| Posted on 2007-09-21 08:45:52 AM |
Link | Quote |
|
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. |
|
| Posted on 2007-09-21 09:35:59 AM |
Link | Quote |
|
|
are you sure it could be used as an index?
|
|
| Posted on 2007-09-21 10:45:52 AM |
Link | Quote |
|
|
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?
|
|
| Posted on 2007-09-21 10:53:07 AM |
Link | Quote |
|
Are you sure this isn't because the 65816 don't have long adressing indexed with Y, only indexed with X, try adding:
before attempting to load the data at shellpos
|
| Last edited on 2007-09-21 10:53:41 AM by Bio. |
|
| Posted on 2007-09-21 08:39:19 PM |
Link | Quote |
|
|
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.
|
|
| Posted on 2007-09-22 01:56:54 AM |
Link | Quote |
|
Originally posted by mikeykWhat 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:
Codeadjustshell:
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 BioAre 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. |
|
| Posted on 2007-09-24 02:16:08 PM |
Link | Quote |
|
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
|
|
| Posted on 2007-09-25 01:50:01 AM |
Link | Quote |
|
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 |