NESASM - table with pre-computed values

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

Post Reply
stenlik
Posts: 3
Joined: Sun Dec 11, 2016 1:43 am

NESASM - table with pre-computed values

Post by stenlik »

Hello,

I wanted to create a simple table with pre-computed values with use of NESASM, but when I run the program and I check the RAM values are not there. Am I doing something wrongly?

Thanks
STeN

Code: Select all

; -------------- Pre-computed table
    .bank 2
    .org  $0011
table:
    .dw   $0
    .dw   $9
    .dw   $18
    .dw   $27
    .dw   $36
    .dw   $45
    .dw   $54
    .dw   $63
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: NESASM - table with pre-computed values

Post by tokumaru »

A ROM file contains the information that's mapped to the ROM area of the system, and can't possibly contain any RAM information. The table you have there is not saved anywhere in the resulting ROM, it's completely lost when you assemble the program. RAM is always "empty" when programs start on the NES, and you have to manually copy any data you need to be available in there. What you need to do is define that table in ROM (i.e. loose the .org $0011) and write a loop to copy the data to RAM.

EDIT: A simple loop like this will do:

Code: Select all

	ldx #$07
loop:
	lda table, x
	sta $11, x
	dex
	bpl loop
Revenant
Posts: 462
Joined: Sat Apr 25, 2015 1:47 pm
Location: FL

Re: NESASM - table with pre-computed values

Post by Revenant »

Let me guess, somebody read gbaguy's "tutorial" again...
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: NESASM - table with pre-computed values

Post by tokumaru »

Revenant wrote:gbaguy's "tutorial"
Really? I know GBAGuy wrote really questionable code, but this is not just questionable, it doesn't do anything at all. The fact that someone would put something like this in a tutorial without even testing is unbelievable.
User avatar
koitsu
Posts: 4201
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: NESASM - table with pre-computed values

Post by koitsu »

tokumaru wrote:Really? I know GBAGuy wrote really questionable code, but this is not just questionable, it doesn't do anything at all. The fact that someone would put something like this in a tutorial without even testing is unbelievable.
Real high quality stuff: http://patater.com/gbaguy/day7n.htm
Compare that to http://patater.com/gbaguy/day2n.htm (re: what "bank 0" is used for)
User avatar
dougeff
Posts: 3078
Joined: Fri May 08, 2015 7:17 pm

Re: NESASM - table with pre-computed values

Post by dougeff »

I see comments going back to 2004 on this 'tutorial'. Whoever is hosting such a thing for 12+ years, you think they could have found the time to correct the errors. I mean, they're not long pages. I could probably fix them all in one evening.
nesdoug.com -- blog/tutorial on programming for the NES
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: NESASM - table with pre-computed values

Post by tepples »

The official fix is Nerdy Nights. From the tutorial index:
Webmaster's Note

This tutorial sucks. Don't read it. Please read a real tutorial like Nerdy Nights, instead. This tutorial is hosted for archival purposes and shouldn't be trusted for anything.
User avatar
dougeff
Posts: 3078
Joined: Fri May 08, 2015 7:17 pm

Re: NESASM - table with pre-computed values

Post by dougeff »

A Google search doesn't take you to THAT page, which says it sucks, it takes you to this page...

http://patater.com/gbaguy/nesasm.htm
nesdoug.com -- blog/tutorial on programming for the NES
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: NESASM - table with pre-computed values

Post by tepples »

But on http://patater.com/gbaguy/nesasm.htm, clicking Back and then NES ASM Tutorials goes to THAT page.
Post Reply