Page 1 of 1

NESASM - table with pre-computed values

Posted: Mon Dec 12, 2016 8:52 am
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

Re: NESASM - table with pre-computed values

Posted: Mon Dec 12, 2016 9:08 am
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

Re: NESASM - table with pre-computed values

Posted: Mon Dec 12, 2016 10:02 am
by Revenant
Let me guess, somebody read gbaguy's "tutorial" again...

Re: NESASM - table with pre-computed values

Posted: Mon Dec 12, 2016 5:51 pm
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.

Re: NESASM - table with pre-computed values

Posted: Mon Dec 12, 2016 6:35 pm
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)

Re: NESASM - table with pre-computed values

Posted: Mon Dec 12, 2016 7:08 pm
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.

Re: NESASM - table with pre-computed values

Posted: Mon Dec 12, 2016 7:20 pm
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.

Re: NESASM - table with pre-computed values

Posted: Mon Dec 12, 2016 8:06 pm
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

Re: NESASM - table with pre-computed values

Posted: Mon Dec 12, 2016 8:15 pm
by tepples
But on http://patater.com/gbaguy/nesasm.htm, clicking Back and then NES ASM Tutorials goes to THAT page.