Points of Required Attention™
Please chime in on a proposed restructuring of the ROM hacking sections.
Views: 88,434,290
Main | FAQ | Uploader | IRC chat | Radio | Memberlist | Active users | Latest posts | Calendar | Stats | Online users | Search 04-19-24 04:18 AM
Guest: Register | Login

0 users currently in ROM Hacking | 1 guest

Main - ROM Hacking - If you've ever programmed the NES... New thread | New reply


RetroRain
Posted on 03-08-11 04:39 AM Link | Quote | ID: 140050


Fuzz Ball
Level: 66

Posts: 551/994
EXP: 2436723
Next: 25128

Since: 09-30-07

Last post: 1927 days
Last view: 950 days
NOTE: I posted this in ROM hacking instead of Programming because I believe it relates more to the NES and ROMs


A question for those who have ever programmed the NES. Do you need to look at NES documents, or are you able to just program without looking at anything else?

I find that I have to look at a the document nestech.txt, because I can't remember everything, but I was just wondering for those of you who have made small NES demos or homebrews, or have done any kind of NES programming from scratch, who are experienced programmers, if you can program the NES without looking at the specs. It wouldn't be considered "amateur-ish" to have to look right?

What made me ask this question?

Just looking at the asm code from programmers who made small NES demos. I feel like that maybe I'm not experienced enough because I have to always look at certain documentation.

For example, while I am familiar with how the NES operates, and I know the basics of C, when I was following a NES tutorial to make a demo, there were commands that I never recognized, like:

.org
.dw
.bank

Are these considered ASM or NES-specific commands?

And I never used the stack. Is it possible to get by without it? Probably because I think documentation on it doesn't answer my questions.

How many set of numbers can you place on a stack, or is it unlimited, because the stack is not a RAM address right? I've seen no indication that it is. All I know is that it allows you to place numbers on it temporarily so you can quickly use them again.

____________________
My YouTube Channel

NovaYoshi
Posted on 03-08-11 04:50 AM Link | Quote | ID: 140051


Red Goomba
Level: 15

Posts: 2/35
EXP: 14350
Next: 2034

Since: 02-24-11

Last post: 4191 days
Last view: 1280 days

Just skimming over the original post, and I probably did a terrible job at explaining stuff, but...

Posted by RetroRain
NOTE: I posted this in ROM hacking instead of Programming because I believe it relates more to the NES and ROMs


A question for those who have ever programmed the NES. Do you need to look at NES documents, or are you able to just program without looking at anything else?
I find that I have to look at a the document nestech.txt, because I can't remember everything, but I was just wondering for those of you who have made small NES demos or homebrews, or have done any kind of NES programming from scratch, who are experienced programmers, if you can program the NES without looking at the specs. It wouldn't be considered "amateur-ish" to have to look right?

I look all the time, but decreasingly so. I started to remember the register names (Easier than memorizing addresses) instead of having to look them up each time, but I still have to look up the PPUCTRL flags, PPUMASK flags, and OAM flags each time I deal with them.

Posted by RetroRain

For example, while I am familiar with how the NES operates, and I know the basics of C, when I was following a NES tutorial to make a demo, there were commands that I never recognized, like:

.org
.dw
.bank

Are these considered ASM or NES-specific commands?


As far as I can tell they're quite common in 6502 assemblers. In the one I use (ca65), .dw is called .addr (sticks an address directly into the ROM), and .org doesn't even exist at all. (normally says "this code starts at this address" )

Posted by RetroRain

And I never used the stack. Is it possible to get by without it? Probably because I think documentation on it doesn't answer my questions.

How many set of numbers can you place on a stack, or is it unlimited, because the stack is not a RAM address right? I've seen no indication that it is. All I know is that it allows you to place numbers on it temporarily so you can quickly use them again.

The stack's 256 bytes big, and it resides in RAM from $100 to $1ff.


____________________


blackhole89
Posted on 03-08-11 04:53 AM Link | Quote | ID: 140052


The Guardian
Moloch whose eyes are a thousand blind windows!
Level: 124

Posts: 3593/4196
EXP: 21520458
Next: 316143

Since: 02-19-07
From: Ithaca, NY, US

Last post: 464 days
Last view: 77 days



Anything prefixed with a dots is macros for the assembler; they don't get translated to an opcode and therefore aren't NES-specific.

Also, I did SNES (rather than NES), but I found I almost never had to look at manuals because it was mostly trivial to infer from the command names, format of the arguments and the way they were used what the commands were supposed to do.

You can't entirely get around using the stack, simply because there are some special registers you can only access through it. Either way, it's a trivial data structure that every self-respecting programmer should understand; read up the wikipedia article.

Data on the stack is stored in the RAM. There is an address associated with the stack in the processor, the stack pointer, and the whole thing basically works like
push x = decrement stack pointer by size of x and write x to the address pointed at by the stack pointer
pop(pull) x = set x to the data at the stack pointer and increment stack pointer by size of x

with the stack pointer initially pointing at something like $0200 for the NES (I think); note that it grows down. (Note: I might have the order of decrementing/incrementing the wrong way around; it depends on the system.)

____________________



NovaYoshi
Posted on 03-08-11 05:19 AM Link | Quote | ID: 140053


Red Goomba
Level: 15

Posts: 3/35
EXP: 14350
Next: 2034

Since: 02-24-11

Last post: 4191 days
Last view: 1280 days

Posted by blackhole89

You can't entirely get around using the stack, simply because there are some special registers you can only access through it.



Special registers? wut
You'll need the stack for subroutine calls and interrupts. It's not really THAT scary... ( it scares me in x86 more )

____________________


RetroRain
Posted on 03-08-11 05:32 AM Link | Quote | ID: 140054


Fuzz Ball
Level: 66

Posts: 552/994
EXP: 2436723
Next: 25128

Since: 09-30-07

Last post: 1927 days
Last view: 950 days
Posted by blackhole89
Also, I did SNES (rather than NES), but I found I almost never had to look at manuals because it was mostly trivial to infer from the command names, format of the arguments and the way they were used what the commands were supposed to do.
I'm sorry, I should have been more specific. I meant registers, like $4014 (Sprite DMA Register), $2000 (PPU Control Register 1), etc. Wouldn't it be pretty hard to remember every register for a specific system without having to look it up? I was just wondering if experienced NES programmers had these memorized by heart, and didn't have to refer to a document?

____________________
My YouTube Channel

Matrixz
Posted on 03-08-11 06:16 AM Link | Quote | ID: 140055


Ninji
Level: 35

Posts: 159/225
EXP: 266219
Next: 13717

Since: 04-07-07
From: Norway

Last post: 3099 days
Last view: 1776 days
When i started to look at NES asm, i looked up the documentation all of the time, especially to know the details about those registers which contain bits, like $2000 and $2001.
Don't worry about it.

also, stack example:
	lda #$01
pha ;push
lda #$02
sta somewhere
pla ;pull
;Accumulator is 01

kuja killer
Posted on 03-08-11 07:21 AM Link | Quote | ID: 140056


Level: 55

Posts: 223/628
EXP: 1243151
Next: 71038

Since: 03-20-07
From: Lake Havasu City, Arizona

Last post: 274 days
Last view: 42 min.
yea for me, i look at documents when i need to, specifically when i dont remember what something does. Cause you cant just memorize everything obviously. Goes for all my megaman 3 stuff. I got 2 main notepad documents for megaman-odyssey i need open whenever im doing coding on stuff, so i can remember what commands and jumps and stuff to do for...whatever. Sorry if im not making much sense.

everything i do for odyssey is 100% pure custom in terms of programming for NES.

blackhole89
Posted on 03-08-11 02:37 PM (rev. 2 of 03-08-11 02:37 PM) Link | Quote | ID: 140061


The Guardian
Moloch whose eyes are a thousand blind windows!
Level: 124

Posts: 3594/4196
EXP: 21520458
Next: 316143

Since: 02-19-07
From: Ithaca, NY, US

Last post: 464 days
Last view: 77 days



Posted by NovaYoshi
Special registers? wut

Ah, the NES only really has one of those (the processor flags are only directly accessible through by e.g. PHA, PLP to write and PHP, PLA to read). The SNES does the same thing for a couple more.

also,
> 04:11:20 <NovaYoshi> blackhole89 got the stack address wrong
No, note that the semantics for the stack pointer I've written down assume that it moves first, then writes; i.e. if it starts at $0200 for an empty stack (or $00 if SP is only 8-bit), the first byte to be pushed would occupy $01FF ($FF). This assumption may be wrong, but I made that explicit and if it was the other way around, the stack pointer indeed should start at $01FF.

____________________



Ailure
Posted on 03-08-11 03:04 PM (rev. 3 of 03-08-11 03:09 PM) Link | Quote | ID: 140062

Hats
Steam Board2 group
Level: 121

Posts: 3856/3965
EXP: 19767645
Next: 289051

Since: 02-19-07
From: Sweden, Skåne

Last post: 3294 days
Last view: 2045 days
As long you remember to have a equal numbers of push and pull in your code, the stack shouldn't really be that scary to use. If you manage to run out of stack space, that's probably a sign that your code is nested too deep anyway. I can't personally think of any examples of where that can easily happen on NES, but then most of the coding I done on the NES is rather simple.

For the most part you can get away with generic 6502 documentation, especially when it comes to opcodes and such (and I generally find it better than NES-spefic documentation). I used NES spefic documentation for the location of registers and such, and generic 6502 for opcodes (the biggest difference between a generic 6502 and the NES 2A03 opcode-wise is the lack of decimal mode as far I saw. Someone more experienced probably can point out way more differences.).

____________________
AIM: gamefreak1337, MSN: Emil_sim@spray.se, XMPP: ailure@xmpp.kafuka.org


never-obsolete
Posted on 03-08-11 11:15 PM Link | Quote | ID: 140073


Rat
Level: 24

Posts: 73/96
EXP: 74452
Next: 3673

Since: 02-22-07
From: Phoenix, AZ

Last post: 2589 days
Last view: 2589 days
After awhile you'll have it memorized. Especially for the NES, which only has a handful of registers compared to some of the other systems. I mostly need to reference cycle counts nowadays, but in the beginning I couldn't go more than 20 minutes without having to page through a document.

Main - ROM Hacking - If you've ever programmed the NES... New thread | New reply

Acmlmboard 2.1+4δ (2023-01-15)
© 2005-2023 Acmlm, blackhole89, Xkeeper et al.

Page rendered in 0.023 seconds. (341KB of memory used)
MySQL - queries: 62, rows: 91/92, time: 0.016 seconds.