Skip navigation
NintendoAge
Welcome, Guest! Please Login or Join
Loading...

NES Programming Organized - Nerdy Nights

Jan 4, 2010 at 3:38:46 AM
NESHomebrew (21)
avatar
(Brad Bateman - Strange Brew Games) < King Solomon >
Posts: 4264 - Joined: 04/28/2008
Saskatchewan
Profile
Regarding sound, a new tool was release recently called Nijuu that can make amazing music, however I don't believe it is very simple to incorporate it into a game.

http://dutycyclegenerator.com/nij...

The site seems to be down for me right now, but I'm guessing he is giving the site a major facelift as the layout was pretty crappy previously. He is also working on a native tracker for the NES that seems to be coming along nicely.

Jan 4, 2010 at 8:01:51 PM
KHAN Games (89)
avatar
(Kevin Hanley) < Master Higgins >
Posts: 8124 - Joined: 06/21/2007
Florida
Profile
Other than the Nerdy Nights Sound Tutorials, there really isn't much out there for music. Famitracker is very easy to implement into a game, but you won't be able to use sound effects or anything in addition to music.

As for Tile Editors, I personally use Tile Layer Pro. It does what I want it to pretty well. Also, Al Bailey has a tool that is very useful for converting 32x30 bitmaps you draw in MS Paint into CHR tiles. I'm living off of it right now.

-------------------------

gauauu: look, we all paid $10K at some point in our lives for the privilege of hanging out with Kevin


Jan 4, 2010 at 8:21:36 PM
udisi (88)
avatar
< King Solomon >
Posts: 3270 - Joined: 11/15/2006
United States
Profile
Famitracker is pretty easy to implement into a game from what I've heard. There are some drawbacks in that I don't think anyone has igured out how to have both sound and sound FX in a game using famitracker. I'm sure mewithoutyou52 could show how to use fami in a game.

As for tile editing, I like tile molester.

The sound engine tutorials here aren't quite done yet, but I'm using it in my game and I must say it's pretty spiffy.

Jan 9, 2010 at 12:56:36 AM
NESHomebrew (21)
avatar
(Brad Bateman - Strange Brew Games) < King Solomon >
Posts: 4264 - Joined: 04/28/2008
Saskatchewan
Profile
I just noticed that http://www.nintendoage.com/faq/ne... isn't up to date with the new sound tutorials. I'm not sure who updates it but just pointing this out.

May 10, 2010 at 9:58:06 AM
DoctorMikeReddy (0)

(Mike Reddy) < Cherub >
Posts: 5 - Joined: 04/27/2010
United Kingdom
Profile
Will there be a DMC tutorial? Or have I missed it?

Jan 7, 2011 at 11:16:00 AM
thebmxeur (0)

(Simon Anciaux) < Cherub >
Posts: 5 - Joined: 01/04/2011
Belgium
Profile
Hi, I'm new to NES programming and I'm following those tutorials.

I asked a few questions in the week 6 tutorial and as it doesn't show in the main forum 'recent posts' I'll try here.
(original post)

When I set a color in the first byte of the sprites palette, the fist bytes of each "group" of background palette changes. I tried with both the file I was working on and the file provided and it does the same. I'm missing something ?

Also can someone explain a little the DMA part when loading sprites ? I'm not sure why we don't use 2 STA $2003 (one with #$00 and one with #$02) and then "call" $4014. ( so the question can be :how does DMA work ?)

A last question : in the first part of the tutorial (making a blueish background), during the clrmen: part you put #$FE at $0300 ($03xx). Why ?

Thanks, bye

-------------------------


Jan 7, 2011 at 11:26:04 AM
KHAN Games (89)
avatar
(Kevin Hanley) < Master Higgins >
Posts: 8124 - Joined: 06/21/2007
Florida
Profile
The first byte of the sprite palette is the transparent color for everything. When you change the first one, they all change. This is intended.

Your second question, I have no idea.

Your third question, I believe he is moving the sprites ($0300) to #$FE (off the screen).

-------------------------

gauauu: look, we all paid $10K at some point in our lives for the privilege of hanging out with Kevin


Jan 7, 2011 at 12:30:52 PM
Mario's Right Nut (352)
avatar
(Cunt Punch) < Bowser >
Posts: 6634 - Joined: 11/21/2008
Texas
Profile
2nd question. The

LDA #$02
STA #2003

means store send the $0200-$02FF group of RAM to the PPU. So, if you put $01, it would transfer $0100-01FF, and so on. The $4014 part doesn't really need to be in NMI, if I remember correctly.

-------------------------

This is my shiny thing, and if you try to take it off me, I may have to eat you.

Check out my dev blog.


Jan 7, 2011 at 6:20:59 PM
thebmxeur (0)

(Simon Anciaux) < Cherub >
Posts: 5 - Joined: 01/04/2011
Belgium
Profile
Thank you for the answers.

For the second question, my question was not to use $01. I understand that the sprites datas (y, tile, palette, x) are store in the ram at $0200. The part I don't understand is the DMA transfer.

When you setup the palette you do something like :

  LDA $2002    ; read PPU status to reset the high/low latch to high
  LDA #$3F
  STA $2006    ; write the high byte of $3F10 address
  LDA #$10
  STA $2006    ; write the low byte of $3F10 address

and then you "write" at $2007 the values.

For the DMA transfer, to copy the sprites datas to the ppu the code is :
  LDA #$00
STA $2003 ; set the low byte (00) of the RAM address
LDA #$02
STA $4014 ; set the high byte (02) of the RAM address, start the transfer

Why don't we do
  LDA #$00
STA $2003
LDA #$02
STA $2003

STA $4014
In other words what happens when you do "STA $4014" ?

I think that part must be in the NMI as it updates sprites datas in the PPU and it has to be done during VBlank (not sure, I do nes programming for a few days). And in the original post I asked if the DMA transfer must be in the beginning of NMI and it was answered in the tutorial 7 : as VBlank is very short we must first make sure that the sprites datas update is finished before doing anything else.

For the third question, in that script we didn't use any sprites, plus sprites are generally at $0200 and not $0300. Maybe it's just a typo (nesdev wikithey says that $0300 is use by sounds)

Another question : while I was doing the pong game, at one point when I compiled I got that error :

NES Assembler (v3.00)

pass 1
pass 2
#[1]   pong.asm
  197  00:C114                    BEQ logicGameOver
       Branch address out of range!
# 1 error(s)

I fixed this by moving the logicGameOver part (that was an empty "function") earlier in the code. What was the problem ?

-------------------------


Jan 7, 2011 at 7:26:43 PM
bunnyboy (81)
avatar
(Funktastic B) < Master Higgins >
Posts: 7704 - Joined: 02/28/2007
California
Profile
Originally posted by: thebmxeur

For the DMA transfer, to copy the sprites datas to the ppu the code is :
  LDA #$00
STA $2003 ; set the low byte (00) of the RAM address
LDA #$02
STA $4014 ; set the high byte (02) of the RAM address, start the transfer
In other words what happens when you do "STA $4014" ?

The STA $2003 sets the destination sprite address to $00.  You could set it to anything $00-7F and shift your sprites, but that will mess up sprite rendering in "weird" ways.

The STA $4014 sets the source sprite address high byte (always $00 for the low byte).  It is also the signal to start the DMA transfer.  The processor stops running code and transfers all 256 bytes of sprite data from the source address (console RAM) to the destination (sprite RAM inside the PPU chip).  This doesn't have to be in NMI, but must be during vblank.  Putting it at the beginning of NMI ensures it will happen during vblank.




Originally posted by: thebmxeur

Another question : while I was doing the pong game, at one point when I compiled I got that error :

  197  00:C114                    BEQ logicGameOver
       Branch address out of range!

Branches can only go +/- 127 bytes, so you code was too far away.  Need to rearrange it in the file, or change to a BNE/JMP sequence instead.




Originally posted by: thebmxeur

A last question : in the first part of the tutorial (making a blueish background), during the clrmen: part you put #$FE at $0300 ($03xx). Why ?

As KHAN said that is just to make sure all sprites are off screen.  Y position = $FE is off the bottom of the screen.  Even though sprites aren't used its just a typical part of memory clearing.  If your sprites are in a different block of RAM you would change the address.



Edited: 01/07/2011 at 07:27 PM by bunnyboy

Jan 8, 2011 at 9:57:10 AM
thebmxeur (0)

(Simon Anciaux) < Cherub >
Posts: 5 - Joined: 01/04/2011
Belgium
Profile
Thanks a lot. It really helps me to understand what I do.
Maybe you should explain that in the tutorials.

Thanks again


-------------------------


Jan 9, 2011 at 3:21:44 PM
KHAN Games (89)
avatar
(Kevin Hanley) < Master Higgins >
Posts: 8124 - Joined: 06/21/2007
Florida
Profile
He only explains things in the tutorials that aren't confusing.

-------------------------

gauauu: look, we all paid $10K at some point in our lives for the privilege of hanging out with Kevin


Jan 9, 2011 at 3:47:36 PM
removed04092017 (0)
This user has been banned -- click for more information.
< Bowser >
Posts: 7316 - Joined: 12/04/2010
Other
Profile
Ah, good thing I check this. I always thought $00 was the low address of the RAM you want it to use in the game and that $02 was the high byte, never thinking that you could actually change the sprites one by one and you can't edit that RAM on the screen! So it is actually setting the internal register of sprite data in the PPU to $00 and then using $4014 to run the hardware RAM copier and setting it to the high byte of the RAM it wants to then writer it to the PPU's internal RAM for the spirtes? I hope this is how it works, I don't want to have to rewrite my game now!


Originally posted by: bunnyboy

The STA $2003 sets the destination sprite address to $00.  You could set it to anything $00-7F and shift your sprites, but that will mess up sprite rendering in "weird" ways.


I can see if it was $00-$40 or $00 to $255, But why $00-$7F? 


Edited: 01/09/2011 at 03:49 PM by removed04092017

Jan 10, 2011 at 8:24:54 PM
KHAN Games (89)
avatar
(Kevin Hanley) < Master Higgins >
Posts: 8124 - Joined: 06/21/2007
Florida
Profile
Because $0800 is where the 2KB internal RAM ends?

-------------------------

gauauu: look, we all paid $10K at some point in our lives for the privilege of hanging out with Kevin


Jan 10, 2011 at 8:52:05 PM
removed04092017 (0)
This user has been banned -- click for more information.
< Bowser >
Posts: 7316 - Joined: 12/04/2010
Other
Profile
Oh, okay. I misunderstood. So you could go $00 to $FF, And put sprites from the ROM to the screen?

Jan 11, 2011 at 1:27:19 PM
thebmxeur (0)

(Simon Anciaux) < Cherub >
Posts: 5 - Joined: 01/04/2011
Belgium
Profile
After reading it a few time I'm still a little confuse.

So to be sure :

in console ram ($0000 - $0800) at $0200 we've got our sprites datas ( y, tile, flags, x) (that's OAM, right?).
The ppu has a separate memory (separate from pattern table, name table, ...)  of 256 bytes called SPR-Ram in which we have to copy our sprites datas.
To do that we do :

LDA #$00
STA $2003

to set the destination address ($0000) in the SPR-Ram

LDA #$02
STA $4014

to set the high byte of the source address, and start transferring 256 bytes to the SPR-Ram.

If the above is correct, destination should always be $00 ? Because if it's anything else there is no room for 256 bytes ?

I don't really understand what you mean by

"You could set it to anything $00-7F and shift your sprites, but that will mess up sprite rendering in "weird" ways."

Does it mean that source should be between $00 and $07 (to be in console ram $0000 to $0800) ?





-------------------------


Jan 11, 2011 at 2:19:56 PM
bunnyboy (81)
avatar
(Funktastic B) < Master Higgins >
Posts: 7704 - Joined: 02/28/2007
California
Profile
Doh my typo confuses everyone! $7F is wrong. There are 256 bytes in sprite RAM (aka OAM) inside the PPU, so that should be $00-FF. When you set it to something other than $00, the address will wrap. That means if you set $2003 = $04, the first sprite in your console ram will show up in the second position of sprite ram. After the 63rd sprite the sprite ram address will wrap to $00. Then your last sprite will show up in the first sprite position of sprite ram.

Games will almost always just set $2003 = $00. The source ($4014) should be $00-07. $00xx is zero page and useful for other variables, $01xx is the stack, Famitracker uses the $02xx block for variables, so $03xx is typical for sprites.

Jan 11, 2011 at 2:24:36 PM
Mario's Right Nut (352)
avatar
(Cunt Punch) < Bowser >
Posts: 6634 - Joined: 11/21/2008
Texas
Profile

^^ Beat me to it.

Originally posted by: thebmxeur

After reading it a few time I'm still a little confuse.

So to be sure :

in console ram ($0000 - $0800) at $0200 we've got our sprites datas ( y, tile, flags, x) (that's OAM, right?).  OR any place you specify, but yes.


The ppu has a separate memory (separate from pattern table, name table, ...)  of 256 bytes called SPR-Ram in which we have to copy our sprites datas.
To do that we do :

LDA #$00
STA $2003 - I had it backwards.  You can move this out of the loop.  The $4014 needs to be in NMI.

to set the destination address ($0000) in the SPR-Ram

LDA #$02
STA $4014

to set the high byte of the source address, and start transferring 256 bytes to the SPR-Ram.  Start the transfer from $0200.  If you used

LDA #$03
STA $4014

it would start the transfer from $0300, etc.

If the above is correct, destination should always be $00 ? Because if it's anything else there is no room for 256 bytes ?

I don't really understand what you mean by

"You could set it to anything $00-7F and shift your sprites, but that will mess up sprite rendering in "weird" ways." 

-I don't know specifically, but I'd imagine it would run out of space or once it got to the end, it would loop around and finish from "$00".

Does it mean that source should be between $00 and $07 (to be in console ram $0000 to $0800) ? 

-$0000 is your zero space, don't put it here
-$0100 is the stack, don't put it here.
-$02-$07 would be where they go.  You just need to make sure that you actually put the sprite variables here and not at $0200 if you're not using $02. 


I think that made more sense in my head.


-------------------------

This is my shiny thing, and if you try to take it off me, I may have to eat you.

Check out my dev blog.



Edited: 01/11/2011 at 02:26 PM by Mario's Right Nut

Jan 11, 2011 at 2:30:55 PM
removed04092017 (0)
This user has been banned -- click for more information.
< Bowser >
Posts: 7316 - Joined: 12/04/2010
Other
Profile
Okay, I thought it might be a mistake, and it makes sense now. You can also set $4014 to lets say $60 to use a sprite table from $60 for WRAM sprites or even $80-FF for ROM sprites?


Edited: 01/11/2011 at 02:31 PM by removed04092017

Jan 13, 2011 at 2:47:43 PM
thebmxeur (0)

(Simon Anciaux) < Cherub >
Posts: 5 - Joined: 01/04/2011
Belgium
Profile
Thanks again. I hope I'll get some time this week end to continue the tutorials.

-------------------------


Mar 1, 2011 at 8:18:07 AM
Segertar (125)
avatar
(T. F.) < Ridley Wrangler >
Posts: 2967 - Joined: 05/19/2010
Wisconsin
Profile
I think its fantastic that you guys have this resource organized here.

Has anyone considered producing a youtube video to work in conjunction with your tutorials?

Mar 4, 2011 at 2:11:36 PM
TaylorRingo (0)

(Taylor Ringo) < Cherub >
Posts: 1 - Joined: 03/04/2011
United States
Profile
Does anyone know where I could get the CNROM or NROM mappers?

Mar 4, 2011 at 2:48:23 PM
Mario's Right Nut (352)
avatar
(Cunt Punch) < Bowser >
Posts: 6634 - Joined: 11/21/2008
Texas
Profile
I think that I speak for everyone when I say, "Huh?"

-------------------------

This is my shiny thing, and if you try to take it off me, I may have to eat you.

Check out my dev blog.


Mar 4, 2011 at 2:53:27 PM
NewUser123456789 (226)

(New User) < Bonk >
Posts: 17574 - Joined: 07/02/2007
Other
Profile
I think Taylor wants to know what games use the CNROM or NROM mappers..

Is that right Taylor?

Dec 5, 2011 at 9:51:56 AM
JKeefe56 (55)
avatar
(Jim K) < Meka Chicken >
Posts: 883 - Joined: 12/05/2011
New York
Profile
Wow. Once upon a time (last week) I thought I was pretty computer-savvy. Thank all of you for all of the information you've shared. I am trying to get started with 6502 assembly, because I've wanted to make a NES game for about 20 years. I'm just now realizing all this info has been available for years. I'm really struggling with step one though. I can't get NBASIC, NESASM, ASM6 or anything like that to run on my outdated Win XP laptop. Every time I try to open one of them, A DOS window opens up for about half a second and closes. Then I tried to run it out of the command directory and got this far:
Is that right? I feel like it can't be.
What I want to do is run right through making a ROM that just displays my name or something stupid. That's what I've done with HTML and VB (the two languages I am best at), and then at least I have a reference and some confidence that I am doing things correctly.



Any help would be appreciated, and thank you all again for everything.

-------------------------
This space intentionally left mostly blank.