It is currently Sat Nov 18, 2017 12:47 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Sun Jun 25, 2017 3:48 pm 
Offline

Joined: Sun Jun 25, 2017 3:32 pm
Posts: 10
Hello all, noob here.

I've been working on a program (which hopefully will be a game someday) in NESASM3 and I'm running into a problem. I'm trying to load new data into the nametable while scrolling vertically (with vertical mirroring, which may be part of the problem, but the idea is to be able to load a new nametable during the scroll so something different will show up).

I'm able to do this loading from a known address. But I am trying to index into the map stored in the program ROM indirectly and having no luck. Here's what it looks like:

Code:
  .rsset $0000
index_low  .rs 1
index_high .rs 1

...

  .org $8000
story:
  .incbin "story.txt"

...

  clc
  lda #LOW(story)
  adc index_low
  sta index_high
  lda #HIGH(story)
  adc index_high
  sta index_high

...

  ldx #0
draw_next_row:
  lda (index_low), x
  sta $2007
  inx
  cpx #32
  bne draw_next_row

...


The screen scrolls but comes up with garbage, as if it's not indexing into the data properly. Like I said, I can change "lda (index_low), x" to load from something like "lda story + $60, x" and it will work (except that it just loads the same row of data over and over and doesn't go to the next row). Is this an issue with the syntax? What am I missing?

Appreciate the help!


Top
 Profile  
 
PostPosted: Sun Jun 25, 2017 3:49 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5822
Location: Canada
NESASM3 uses different syntax, square brackets instead of parentheses:

Code:
LDA [zp], Y


Top
 Profile  
 
PostPosted: Sun Jun 25, 2017 3:53 pm 
Offline

Joined: Sun Jun 25, 2017 3:32 pm
Posts: 10
Thanks for the prompt reply! I guess I should have mentioned that I did some searching for an answer and came across the square bracket thing. But if I do

Code:
  lda [index_low], x


the assembler throws an error. "Incorrect addressing mode!"

So I'm still not sure how to go about this. Is there something I'm missing?


Top
 Profile  
 
PostPosted: Sun Jun 25, 2017 4:04 pm 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 2981
Location: Tampere, Finland
Nate5700 wrote:
Code:
  lda [index_low], x

the assembler throws an error. "Incorrect addressing mode!"

You can only index with Y like this: lda [index_low], y. There's an alternative mode that uses X, but it does not do the same thing: lda [index_low, x].

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: kkfos.aspekt.fi


Top
 Profile  
 
PostPosted: Sun Jun 25, 2017 4:09 pm 
Offline

Joined: Sun Jun 25, 2017 3:32 pm
Posts: 10
Holy crap, it totally worked. Screen scrolls and the story message comes up!

Thanks a ton! I wouldn't have even thought of trying to use Y instead. Is that a 6502 thing or just a NESASM3 peculiarity?


Top
 Profile  
 
PostPosted: Sun Jun 25, 2017 4:14 pm 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 2981
Location: Tampere, Finland
Nate5700 wrote:
Holy crap, it totally worked. Screen scrolls and the story message comes up!

Thanks a ton! I wouldn't have even thought of trying to use Y instead. Is that a 6502 thing or just a NESASM3 peculiarity?

It's a 6502 limitation.

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: kkfos.aspekt.fi


Top
 Profile  
 
PostPosted: Sun Jun 25, 2017 6:15 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10112
Location: Rio de Janeiro - Brazil
Nate5700 wrote:
Is that a 6502 thing or just a NESASM3 peculiarity?

It may seem unintuitive for us humans who're used to programming using text, but only some combinations of registers and addressing modes are programmed into the chip, so even though some instructions look correct as far as syntax goes, the CPU doesn't really support them. This is my favorite reference document for 6502 instructions, and it includes 2 very useful tables for each instruction: one shows how the various flags are affected by the instruction, and the other shows which addressing modes are supported for the instruction.


Top
 Profile  
 
PostPosted: Fri Jun 30, 2017 2:02 pm 
Offline
User avatar

Joined: Thu Apr 23, 2009 11:21 pm
Posts: 803
Location: cypress, texas
If you wanted something to print out you could print the appendices of this pdf:
msc6500_family_programming_manuel. If you flip to Appendix B and find lda p.219 it lists everything from tokumaru's suggested site, I think. This manuel's appendix B seems to be more correct and will print out better than the one I use. :)


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users 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