Can a Commodore VIC 20 ASM Guide be used w/ a NES Assembler?

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

User avatar
wyatt8740
Posts: 78
Joined: Sun Jun 05, 2011 8:03 pm
Location: Fort Wayne, Indiana, USA (NTSC)

Can a Commodore VIC 20 ASM Guide be used w/ a NES Assembler?

Post by wyatt8740 » Mon Apr 29, 2013 8:08 am

Hi,
This weekend i found an old Commodore VIC 20 in a warehouse while volunteering for a 'rummage sale'. I grabbed it and a Tandy 1400 LT. The VIC still had the box and was missing a key, but i replaced it.

The roof of the warehouse was leaky, and the VIC was submerged in water that smelled like sulphur. I have yet to turn it on. But I dried out the manuals and I learned that the 'Programmer's Reference Guide' has a section on Assembly with the MOS 6502.

The 'Programmer's Reference Guide' has about half the book dedicated to 6502 Assembly; A complete list of opcodes is included, with tutorials. and further explanation.

So this is my question:
Since the RP2A023 is a 6502 without decimal mode, would I be able to use it to program a NES? I have a powerpak and a Toaster Nintendo with the 10NES chip disabled and grounded, as well as a battered AV-Modded Top Loader.

User avatar
Movax12
Posts: 522
Joined: Sun Jan 02, 2011 11:50 am

Re: Can a Commodore VIC 20 ASM Guide be used w/ a NES Assemb

Post by Movax12 » Mon Apr 29, 2013 8:23 am

It may help you to learn about 6502 assembly language, but it isn't going to teach you anything about the NES specifically: If you wish to target the NES you are going to have to learn about the PPU and/or APU and controller input.

User avatar
rainwarrior
Posts: 7680
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Can a Commodore VIC 20 ASM Guide be used w/ a NES Assemb

Post by rainwarrior » Mon Apr 29, 2013 8:24 am

Aside from anything to do with graphics, sound, or input, and of course decimal mode, any 6502 assembly should work on NES.

User avatar
tokumaru
Posts: 11469
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Can a Commodore VIC 20 ASM Guide be used w/ a NES Assemb

Post by tokumaru » Mon Apr 29, 2013 4:28 pm

Assembly is not of much use if you don't know to interface with the hardware, and each platform has RAM/ROM/video/audio/input implemented differently. You can probably learn useful things about the 6502 with this VIC 20 book, but it will probably use a lot of platform specific code for input and output, and that won't help you on the NES at all.

tepples
Posts: 21755
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Can a Commodore VIC 20 ASM Guide be used w/ a NES Assemb

Post by tepples » Mon Apr 29, 2013 5:04 pm

Once you have key presses (platform specific), you move the critters (not platform specific) and draw them in new positions (platform specific). Acceleration, collision detection, aiming, and the like are the same on all platforms that use 6502.

User avatar
wyatt8740
Posts: 78
Joined: Sun Jun 05, 2011 8:03 pm
Location: Fort Wayne, Indiana, USA (NTSC)

Re: Can a Commodore VIC 20 ASM Guide be used w/ a NES Assemb

Post by wyatt8740 » Tue Apr 30, 2013 8:16 am

so does anyone here know a guide to help me out? just a description of how to write 'hello world' or something? I am extremely new to Assembly and I have no idea how to address the PPU.

tepples
Posts: 21755
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Can a Commodore VIC 20 ASM Guide be used w/ a NES Assemb

Post by tepples » Tue Apr 30, 2013 8:29 am

Did you try looking through the Nerdy Nights tutorial?

User avatar
tokumaru
Posts: 11469
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Can a Commodore VIC 20 ASM Guide be used w/ a NES Assemb

Post by tokumaru » Tue Apr 30, 2013 11:09 am

wyatt8740 wrote:so does anyone here know a guide to help me out? just a description of how to write 'hello world' or something?
"Hello World" isn't typically the first NES program people make, because the NES doesn't have a built-in font or a BIOS with a routine to print text to the screen, so "Hello World" gets quite more complex than in any modern programming language.

People often show colors or sounds in their first programs, because that's a lot easier. People who want to jump right into the interesting stuff start with the Nerdy Nights tutorials, like tepples suggested.
I am extremely new to Assembly and I have no idea how to address the PPU.
The CPU and the PPU run in parallel. While the CPU runs the program you coded, the PPU renders pictures to the TV. In order to change this picture, the CPU has to feed the PPU with new information. The PPU has its own memory, not directly accessible to the CPU, where the pattern tables, name tables, attribute tables, OAM and palletes (i.e. everything necessary to generate pictures - if you don't know what these are, read the wiki and play with FCEUX's PPU debugger) stay. Since this memory is not directly accessible to the CPU, there is an address port and a data port which are accessible to the CPU, and this is how the program writes to and reads from PPU memory (it first tells the PPU which address is to be accessed and then writes to / reads from the data port - the address auto increments, so that you don't have to specify an address for every byte). There are also other PPU registers that affect how the image is rendered, such as the scroll registers, which can be changed by the CPU. Most of these PPU updates must happen when the PPU is "resting" between frames (otherwise the picture gets all messed up), a period called VBlank.

User avatar
wyatt8740
Posts: 78
Joined: Sun Jun 05, 2011 8:03 pm
Location: Fort Wayne, Indiana, USA (NTSC)

Re: Can a Commodore VIC 20 ASM Guide be used w/ a NES Assemb

Post by wyatt8740 » Fri May 03, 2013 8:24 am

tokumaru wrote:"Hello World" isn't typically the first NES program people make, because the NES doesn't have a built-in font or a BIOS with a routine to print text to the screen, so "Hello World" gets quite more complex than in any modern programming language.

People often show colors or sounds in their first programs, because that's a lot easier. People who want to jump right into the interesting stuff start with the Nerdy Nights tutorials, like tepples suggested.
Alright. :P I've done enough ram editing and rom hacking to understand that that can get complex.
So, since i don't need to get right to the intresting stuff, how would I color the screen? I seem to recall from the rick astley demo ROM that the PCM sound register is at... $0x4011 or something. Is that right?
tokumaru wrote: The CPU and the PPU run in parallel. While the CPU runs the program you coded, the PPU renders pictures to the TV. In order to change this picture, the CPU has to feed the PPU with new information. The PPU has its own memory, not directly accessible to the CPU, where the pattern tables, name tables, attribute tables, OAM and palletes (i.e. everything necessary to generate pictures - if you don't know what these are, read the wiki and play with FCEUX's PPU debugger) stay. Since this memory is not directly accessible to the CPU, there is an address port and a data port which are accessible to the CPU, and this is how the program writes to and reads from PPU memory (it first tells the PPU which address is to be accessed and then writes to / reads from the data port - the address auto increments, so that you don't have to specify an address for every byte). There are also other PPU registers that affect how the image is rendered, such as the scroll registers, which can be changed by the CPU. Most of these PPU updates must happen when the PPU is "resting" between frames (otherwise the picture gets all messed up), a period called VBlank.
Thanks for the... Pointers! :D
(pun intended)
Thank you for the information; I will try that. And would you say it's easier to get into assembly with something like, say, a Z80 than a 6502 variant like the 2A03?
tepples wrote:Did you try looking through the Nerdy Nights tutorial?
I started to; I will continue to now.
Last edited by wyatt8740 on Fri May 03, 2013 9:34 am, edited 2 times in total.

User avatar
tokumaru
Posts: 11469
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Can a Commodore VIC 20 ASM Guide be used w/ a NES Assemb

Post by tokumaru » Fri May 03, 2013 8:40 am

wyatt8740 wrote:And would you say it's easier to get into assembly with something like, say, a Z80 than a 6502 variant like the 2A03?
Personally, I find 6502 a bit easier. Maybe because it was the first assembly language I learned, but objectively speaking, the design of the 6502 is simpler. This means that the Z80 can do more with less instructions in most cases, but the instructions are more complex. In the end, because of this inversely proportional relationship, the complexity of coding for each CPU doesn't vary much. The same can be said about the speed of both CPUs... The 6502 needs lower clock speeds to perform as well as a Z80, because even though instructions on the Z80 do more, they take longer to execute.

User avatar
wyatt8740
Posts: 78
Joined: Sun Jun 05, 2011 8:03 pm
Location: Fort Wayne, Indiana, USA (NTSC)

Re: Can a Commodore VIC 20 ASM Guide be used w/ a NES Assemb

Post by wyatt8740 » Fri May 03, 2013 9:54 am

tokumaru wrote:...play with FCEUX's PPU debugger...
I do play with the FCEUX Debugger. I did a simple hack to disable piracy protection in the EarthBound Zero Rom:
http://forum.starmen.net/forum/Communit ... ingle-byte

Also, I modded the title screen of the same game in a hex editor.
http://forum.starmen.net/forum/Communit ... le-screen/

Image
This is the english game with the original title screen. Done with a hex editor.

Is this knowledge of any real use? on the links i have info on how I did all of this stuff with the debugger and hex editor.

... Since i don't need to get right to the intresting stuff, how would I color the screen? I seem to recall from the Rick Rolling PCM demo ROM that the PCM sound register is at... $0x4011 or something. Is that right?

3gengames
Formerly 65024U
Posts: 2269
Joined: Sat Mar 27, 2010 12:57 pm

Re: Can a Commodore VIC 20 ASM Guide be used w/ a NES Assemb

Post by 3gengames » Fri May 03, 2013 6:58 pm

It's good for creating data later, as hacking shows you have somewhat of an understanding how data is stored and read. :) Still, just look at a page like http://www.obelisk.demon.co.uk/6502/index.html to learn 6502. It explains instruction, addressing modes, registers, all of it. :)

User avatar
tokumaru
Posts: 11469
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Can a Commodore VIC 20 ASM Guide be used w/ a NES Assemb

Post by tokumaru » Fri May 03, 2013 7:08 pm

3gengames wrote:Still, just look at a page like http://www.obelisk.demon.co.uk/6502/index.html to learn 6502. It explains instruction, addressing modes, registers, all of it. :)
And then use this 6502 simulator to try stuff out. This is the best way to study how the instructions work. Better than using some old machine with no debugging features, specially if it's not the one you're ultimately targeting.

User avatar
wyatt8740
Posts: 78
Joined: Sun Jun 05, 2011 8:03 pm
Location: Fort Wayne, Indiana, USA (NTSC)

Re: Can a Commodore VIC 20 ASM Guide be used w/ a NES Assemb

Post by wyatt8740 » Tue May 14, 2013 9:55 am

3gengames wrote:It's good for creating data later, as hacking shows you have somewhat of an understanding how data is stored and read. :) Still, just look at a page like http://www.obelisk.demon.co.uk/6502/index.html to learn 6502. It explains instruction, addressing modes, registers, all of it. :)
That page is down.

tepples
Posts: 21755
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Can a Commodore VIC 20 ASM Guide be used w/ a NES Assemb

Post by tepples » Tue May 14, 2013 10:09 am

It was up for me 20 seconds ago. Where do you live?

Post Reply