Register | Login
Views: 19364387
Main | Memberlist | Active users | ACS | Commons | Calendar | Online users
Ranks | FAQ | Color Chart | Photo album | IRC Chat
11-02-05 12:59 PM
0 user currently in Programming. | 3 guests
Acmlm's Board - I2 Archive - Programming - Doing tables in 65816
  
User name:
Password:
Reply:
 

UserPost
Sukasa
Posts: 990/1981
OK, thanks. Now I only need to get a way to fit that into SMW, since that was a table I'm placing into it.
beneficii
Posts: 200/567
Originally posted by Euclid
Originally posted by beneficii

ldy #$00
lookup:
lda startingaddress, y
(do your stuff with it here)
iny
tya
cmp #$04
bne lookup


you can replace the tya and cmp with a single cpy instruction.

or if you're really tight on bytes, you can do it in reverse...
ldy #whatever maximum value
loop:
lda addr,y
(stuff)
dey
bne loop

Can't believe I missed that.



Duh...
Euclid
Posts: 174/193
Originally posted by beneficii

ldy #$00
lookup:
lda startingaddress, y
(do your stuff with it here)
iny
tya
cmp #$04
bne lookup


you can replace the tya and cmp with a single cpy instruction.

or if you're really tight on bytes, you can do it in reverse...
ldy #whatever maximum value
loop:
lda addr,y
(stuff)
dey
bne loop
Sukasa
Posts: 965/1981
OK, thanks, because what happens is that once every frame, the table is read and the values resulting from it are multiplied by 16 in a custom loop and fed to the sprite X/Y location tables.
beneficii
Posts: 196/567
I don't have as much experience with 65816 as I do with 6502, but typically you'd use either y or x. This is assuming you're trying to read one byte at a time.

Something like:

ldy #$00
lookup:
lda startingaddress, y
(do your stuff with it here)
iny
tya
cmp #$04
bne lookup

I think there should be asm very similar to this in 65816.

Load 0 to y, then read the starting address + current value of y, then do your stuff with it, then increase y by one, transfer y to accumulator to check to see if y has reached 4 yet, and if not, then it should go back to lookup to do it again. Essentially, this is just like a for loop in C:

for(int y = 0; y < 4; y++)
{
accumulator = variable[startingaddress + y];
(do your stuff here)
}
Sukasa
Posts: 959/1981
I'm doing a bit of SNES coding, and I need to know how to do a lookup table, sort of like this:

03 26 95 48

Where I would have the SNES read those sequentially when I want to.

Now, If I wanted some sort of ASM that would let me put those into a table and read from it, how would I do that? I'm trying to reduce ASM size and simplify the coding, because the values are for a sprite's X and Y values, updated once each frame, and there are at least 50 different locations I'll need to hardcode.
Acmlm's Board - I2 Archive - Programming - Doing tables in 65816


ABII


AcmlmBoard vl.ol (11-01-05)
© 2000-2005 Acmlm, Emuz, et al



Page rendered in 0.002 seconds.