Oldschool noob with questions

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Post Reply
daggaz
Posts: 7
Joined: Mon Jul 15, 2019 11:56 am

Oldschool noob with questions

Post by daggaz »

Hey guys,

Ok I'm 40whatever years old, bought my first NES when I was 8 right when they came out, and now I'm a MSc in Nanotech PhD in ChemEng, and I bought the NES classic mini for my kids (hahahah yeah for my kids... no seriously they love it so far) and of course now I am thinking of making my own games for them (hahahah yeah for them).

I can fart around in C++ and python, I can write scripts in dosshell and a bunch of other languages, I have zero assembly experience, but I'm rocking a high-end wetware processor and can generally pick up any kind of logic orientated language in very short time. I understand computer hardware at a reasonably solid but not expert level (I know more about how the chips work physically at the atomic level than I do about how they are put together in a machine), I've programmed some "simplistic" monte-carlo molecular simulators, and I even used to write zones for MUDS online.

Luckily, I also love to read, so I am going to be reading a lot here, I can see. But right off the bat, I can see this new crazy hobby of mine is going to be way more complex than I had first supposed. There are already an overwhelming number of options in the stickies... If I want to spend some extra time learning to do something "right" (or more complete ie at a higher level) rather than starting with a training-wheels kind of setup, but at the same time am not a professional coder, what is a good option for getting into assembly?

And as I cannot find anything in my precursory search of the forums, are there any important differences from the orginal NES system and the new mini-classic, with respect to programming your own games? I am aware that the mini has far more memory and assume this is an open resource, but are there any more differences? I have a sneaking suspicion that the mini is probably an emulator, so there might be I guess some things one can do differently if one is not working with an actual 1986 era CPU/PPU/APU network, yes?


Thanks for your time,
-daggaz
User avatar
koitsu
Posts: 4201
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: Oldschool noob with questions

Post by koitsu »

Nerdy Nights tutorial.
User avatar
Drew Sebastino
Formerly Espozo
Posts: 3496
Joined: Mon Sep 15, 2014 4:35 pm
Location: Richmond, Virginia

Re: Oldschool noob with questions

Post by Drew Sebastino »

The mini is most certainly running an emulator; I'm pretty sure it just uses some generic ARM SoC. However, it seems reasonably accurate, so it will probably run most homebrew games.

I'll start by saying that if you can memorize all the mess in C++, you should have no problem with the 6502's instruction set. I would look up 6502 specific tutorials before looking at anything NES specific. I haven't coded for the NES, but it appears to be incredibly simple in comparison to other systems.
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: Oldschool noob with questions

Post by dougeff »

are there any important differences from the orginal NES system and the new mini-classic
the mini/classic is an emulator. It doesn't matter if the mini/classic has a TB of memory, the game it is emulating needs to conform to a real NES cartridge.

The NES, originally, has 2048 bytes of RAM and can address 32k of ROM.

Because this was too limited, they created mappers (extra chips on the cartridge) to expand that ability. Potentially adding another 8k of RAM and up to 256k of ROM space.

But that ROM space isn't 1 contiguous program. It is smaller chunks that are swapped in and out as needed into the standard 32k address space.

Many of the mappers actually have much less capability. Try making some very small sized game or demo before working on anything bigger.

And check out the wiki

http://wiki.nesdev.com/w/index.php/Nesdev_Wiki

search for words like registers, apu, ppu, vectors, mappers, controllers.
nesdoug.com -- blog/tutorial on programming for the NES
daggaz
Posts: 7
Joined: Mon Jul 15, 2019 11:56 am

Re: Oldschool noob with questions

Post by daggaz »

dougeff wrote:
Try making some very small sized game or demo before working on anything bigger.
Lol yeah definitely, I think I will be happy if I can get "hello world" rocking on this system, as a starter. I'm surprised to hear that the emulators confined themselves to the original limitations so stringently, but I guess it makes sense if you are just trying to "copy" the original machine and get it to work without introducing any new bugs. Shame tho. I could dig a 8 gigabyte 8-bit world of Hyrule.
User avatar
Drew Sebastino
Formerly Espozo
Posts: 3496
Joined: Mon Sep 15, 2014 4:35 pm
Location: Richmond, Virginia

Re: Oldschool noob with questions

Post by Drew Sebastino »

Any sort of difference like that could break compatibility in some way if even possible to implement, and if you're trying to emulate these old games, just unnecessary. However, as said, there exist mappers can expand memory, and while I don't know a lot about the NES, probably to any size you could reasonably want. NES game assets will take hardly any memory whatsoever; 8GB would be the entire NES and FC library several times over.
daggaz
Posts: 7
Joined: Mon Jul 15, 2019 11:56 am

Re: Oldschool noob with questions

Post by daggaz »

Yeah, when I was reading about the mini, I found out that while it can easily contain the entire NES library, it depended on what kind of cover-art you downloaded with the roms, as more modern, high-res images could easily be orders of magnitude larger files than the game they are portraying. That's hillarious. And then you start thinking about the computers we used to land men on the moon....
User avatar
koitsu
Posts: 4201
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: Oldschool noob with questions

Post by koitsu »

The least of your concerns at this stage is NES Mini vs. emulator vs. anything else, I assure you.

Reminder for folks already: the guts of what the OP wants to do is disclosed at the end of the first paragraph: "now I am thinking of making my own games for them [kids]".

Use emulators like Mesen and FCEUX to help with development, as their debuggers will help you tremendously.
Start with the Nerdy Nights tutorial as said.
Use asm6 (easy) or ca65 (advanced) or NESASM3 (easy but uses sub-par operand syntax that is unlike other assemblers) as your assembler (not going to discuss this here).
Us easy6502 to help learn 6502 (note that this environment is not the NES, NES is different, this will just help you learn nuances of 6502).
Expect to be confused. Expect nothing to make sense. Expect the system to be very very complex, more than you thought possible.

Good luck!
daggaz
Posts: 7
Joined: Mon Jul 15, 2019 11:56 am

Re: Oldschool noob with questions

Post by daggaz »

koitsu wrote:The least of your concerns at this stage is NES Mini vs. emulator vs. anything else, I assure you.

Reminder for folks already: the guts of what the OP wants to do is disclosed at the end of the first paragraph: "now I am thinking of making my own games for them [kids]".

Use emulators like Mesen and FCEUX to help with development, as their debuggers will help you tremendously.
Start with the Nerdy Nights tutorial as said.
Use asm6 (easy) or ca65 (advanced) or NESASM3 (easy but uses sub-par operand syntax that is unlike other assemblers) as your assembler (not going to discuss this here).
Us easy6502 to help learn 6502 (note that this environment is not the NES, NES is different, this will just help you learn nuances of 6502).
Expect to be confused. Expect nothing to make sense. Expect the system to be very very complex, more than you thought possible.

Good luck!
Perfect, thanks. And yeah, I just didn't want to start down the wrong road regarding the mini, so figured I would ask at the get-go.

I finished the wiki glossary and am moving into the rest of the reference guide there, after that I will check out Nerdy Nights and set up my programs (ca65 looked good also from some other threads on the subject), and then before I do anything really, I will start reading 6502. Looking forward to nuanced complexity, thanks again!
daggaz
Posts: 7
Joined: Mon Jul 15, 2019 11:56 am

Re: Oldschool noob with questions

Post by daggaz »

dougeff wrote:
are there any important differences from the orginal NES system and the new mini-classic
It doesn't matter if the mini/classic has a TB of memory, the game it is emulating needs to conform to a real NES cartridge.

The NES, originally, has 2048 bytes of RAM and can address 32k of ROM.

Because this was too limited, they created mappers (extra chips on the cartridge) to expand that ability. Potentially adding another 8k of RAM and up to 256k of ROM space.

But that ROM space isn't 1 contiguous program. It is smaller chunks that are swapped in and out as needed into the standard 32k address space.

Many of the mappers actually have much less capability.
Ok this is the part I don't get, Mapper is just a name for the cartridge hardware architecture, which is totally dependent on the various cartridges. I understand that 6502 builds directly on the functionality of the processor chip itself, and so cartridge manufacturers would obviously be constrained in mapper design by the limitation of that chip, but here it should clearly be the chip limitations that constrain new NES programs, and not any existing mapper design, or am I missing something?

With regards to memory limitations, I am going to hazard a guess that the chip has a hard limit on the bit-length of a given memory address, but if you have extra memory, what is stopping you from using some of the memory to create an address library? Or is this where a bit-limit will come bite you in the ass?
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Oldschool noob with questions

Post by tepples »

To run a game in existing emulators or on existing reflashable cartridges, it needs to use an existing mapper design. If you have a special need, you can create a new mapper design with the cooperation of an emulator developer and a cartridge hardware manufacturer, as I did with the Action 53 mapper. It's a roughly MMC1-class mapper intended to behave as a compatible superset of CNROM, UNROM, BNROM, and AOROM, for a multicart containing games using those mappers.

A lot of it is the cost of making mapper hardware with a lot of changeable bits of state. Usually, a mapper too big to fit in three 7400-series discrete logic chips is realized as a program for a complex programmable logic device (CPLD), and these have a finite size. Xilinx CPLDs, for example, are sized in "macrocells," where one macrocell can hold one bit of state or calculate one multiplexed output. MMC3's CHR side alone, for example, contains 47 bits of state: 46 for bank numbers plus 1 for whether the $0000 and $1000 windows are swapped. The MMC3's timer (used for IRQs) is about 20: 8 for the current value, 8 for the reload value, 1 for the enable, and maybe 3 for the PA12 watching mechanism. A "multiplexed output" means the output doesn't exactly copy a single bit of state but instead depends on other state or other inputs, such as a bank output depending on both high bits of the address bus and previously written bank numbers. All MMC3 CHR bank outputs (CHR A17-10) are multiplexed based on PA12-10, for another 8 macrocells, a total of 55 for CHR alone.

And this is where you hit bit count limits. The Action 53 mapper is 27 macrocells and fits comfortably in a 36-cell Xilinx CPLD. A full MMC3, on the other hand, is probably over 100 macrocells and needs two 72-cell CPLDs. One game I worked on had to be shipped with a CPLD implementing a reduced MMC3 with some bank number bits given fixed values so that it could fit in one 72-cell CPLD.
daggaz
Posts: 7
Joined: Mon Jul 15, 2019 11:56 am

Re: Oldschool noob with questions

Post by daggaz »

Ok, so the mapper is a bit more than the glossary definition would indicate... If I get this right, the [NES + cartridge (mapper)] is the hardware environment which the emulator software is trying to reproduce, and here the cartridges have more effect on the system than simple additions of memory (my first misconception, I think). That said, if somebody wanted to, they could code and load an emulator onto the NES mini which took advantage of the modern hardware, and allowed 8-bit game simulation with access to several gigs of memory, yeah?

Not that anybody would ever want to commit that kind of heresy, of course..
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: Oldschool noob with questions

Post by dougeff »

emulator onto the NES mini which took advantage of the modern hardware
Personally, I think the size limit of NES games is the LEAST important thing to make a game a NES game.

As long as it runs on a simulated 6502 and has square+triangle chiptune music, and keeps honestly to the color limits, it's still a NES game, in my mind.

If people are talking about coprocessors or streaming PCM music through the (never used) port at the bottom of the NES, it stops feeling like a NES game. IMHO.
nesdoug.com -- blog/tutorial on programming for the NES
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Oldschool noob with questions

Post by tokumaru »

I think that when you start to customize an emulator to make modern hardware in the host machine accessible to the emulated machine, you really start to decharacterize the emulated system. At this point you're better off making a legitimate piece of modern software (that faithfully or loosely respects the visual/audible characteristics of a retro system, your call) using a framework that allows you to easily port the game to any modern platform than making something that only works on your Frankenstein emulator, or going through the trouble of porting said emulator to multiple platforms yourself.

If you want to go modern, just go modern all the way. There's no point in restrictions yourself to several of the limitations of a 1983 machine if the final product won't even run on that actual machine due to arbitrary modern "enhancements".
Post Reply