It is currently Tue Nov 21, 2017 4:21 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Simple table read...
PostPosted: Fri Apr 10, 2015 10:22 am 
Offline

Joined: Tue Jul 01, 2014 4:02 pm
Posts: 257
Alright, so this should work based on my understanding and other similar examples I have tried.

If I have a table that is simply this:

Code:

 DataTable:
    .db $0A, $0B, $0C, $0D



...and, want to call and store the appropriate value...

Code:

    LDY $02
    LDA DataTable,y
    STA someAddress



...shouldn't the value $0C now be stored in someAddress?

And if I want to store a value to a higher address...

Code:

    LDY $00
    LDA DataTable,y
    STA someAddress+2



...shouldn't the value $0A now be stored in the address that is two more from someAddress?


If I'm missing something, please let me know. Thanks!


Top
 Profile  
 
 Post subject: Re: Simple table read...
PostPosted: Fri Apr 10, 2015 10:26 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5824
Location: Canada
The code provided isn't enough context. Edit: 43110 spotted the problem, see below.

The first question I'd ask is whether someAddress is in RAM?

The second question I'd ask is whether you've tried using a debugger? I highly suspect that this code itself does exactly what you think it does, and your problem lies elsewhere. Put a breakpoint on writes to someAddress or someAddress+2 and see if something else is messing with it.


Last edited by rainwarrior on Fri Apr 10, 2015 11:15 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Simple table read...
PostPosted: Fri Apr 10, 2015 10:44 am 
Offline

Joined: Tue Jul 01, 2014 4:02 pm
Posts: 257
What's frustrating is it's pretty simple. Just trying to draw to the spriteRam I set up (constant...spriteRam = $0200). I've done this a dozen times or more. There's a table which contains four bytes of tile data followed by four bytes of attribute data. I find the tile data (0-3), write it to spriteRam+1, and then add four to that value to get the address of the attribute data, which I write to spriteRam+2 (where spriteRam and spriteRam+3 are set to arbitrary x and y values).

so something like...

Code:

    LDY $00
    LDA spriteGroup,y  ;; gives me the tile: y offset of the table with the label *spriteGroup*
    STA spriteRam+1

    LDY $04
    LDA spriteGroup,y  ;; gives me the attribute: again, y offset of the table
    STA spriteRam+2




I'll run it through a debugger, but there's nothing present that would mess with this...it's just a tester file, and there is nothing else writing to the addresses. If I just put in values for spriteRam+1 and spriteRam+2 (like if I skip pulling from the spriteGroup table and just put the values in instead), they work fine, so it's definitely something to do with my table read?


Top
 Profile  
 
 Post subject: Re: Simple table read...
PostPosted: Fri Apr 10, 2015 11:04 am 
Offline
Formerly 43110
User avatar

Joined: Wed Feb 05, 2014 7:01 am
Posts: 313
Location: us-east
JoeGtake2 wrote:
Code:
DataTable:
    .db $0A, $0B, $0C, $0D

Code:
    LDY $02
    LDA DataTable,y
    STA someAddress

...shouldn't the value $0C now be stored in someAddress?

Without a '#' for loading a immediate value, that ldy is loading from the unlabeled variable $02

This happens to me way too many times.


Top
 Profile  
 
 Post subject: Re: Simple table read...
PostPosted: Fri Apr 10, 2015 11:24 am 
Offline

Joined: Tue Jul 01, 2014 4:02 pm
Posts: 257
Ugh....disregard this entire thread. I might just delete it. I'm both not crazy and also completely careless. In my testing ground here, I was loading 'test' hex values to the attributes...not at all correlating to what they should have been in binary. There was nothing wrong with my table read, apparently. Just a stupid mistake in the tables themselves leftover from 'the old way' i was doing it.

What a waste of a morning teching THAT. ha!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: Google [Bot] and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group