Skip navigation
Welcome, Guest! Please Login or Join

Loading...

NES Programming Organized - Nerdy Nights

Mar 7, 2014 at 10:18:53 AM
QuickThumbs (3)
avatar
< Eggplant Wizard >
Posts: 423 - Joined: 08/05/2013
Profile
This has been nagging me for awhile. Is the NES's graphics capabilities limited to tile-sets, or can it draw lines, plot pixels or produce text as the average home computer of the era was able?

Mar 7, 2014 at 10:24:25 AM
SUBSCRIBER
GradualGames (39)
avatar
(Derek Andrews) < El Ripper >
Posts: 1013 - Joined: 10/09/2009
Pennsylvania
Profile
The easiest thing to do on the NES is to draw background and sprite tiles. However, some mappers such as UnROM allow you to modify the contents of these tiles on the fly (i.e. mappers which provide CHR-RAM). So, it is possible to draw lines as well, but only within a certain area as only 256 unique tiles can be loaded in the background at any given time. As for text, these are no different from the background and sprite tiles. All you need to do is load a set of CHR data that represents a font and then plot each character accordingly. There are a multitude of more advanced approaches as well that I won't go into here.

-------------------------
Creators of: Nomolos: Storming the CATsle, and The Legends of Owlia.


Edited: 03/07/2014 at 10:25 AM by GradualGames

Mar 7, 2014 at 10:27:12 AM
QuickThumbs (3)
avatar
< Eggplant Wizard >
Posts: 423 - Joined: 08/05/2013
Profile
Thanks a lot. ^^

Mar 7, 2014 at 10:29:14 AM
bunnyboy (81)
avatar
(Funktastic B) < Bowser >
Posts: 7474 - Joined: 02/28/2007
California
Profile
Glider uses 4x chr ram to do a bitmapped display, but the attribute tables mean you don't get many colors. Also can only draw during vblank or when the screen is off so updates are slow. Read/modify/write for drawing 1 pixel takes a long time!

Mar 18, 2014 at 5:25:15 PM
Mega Mario Man (58)
avatar
(Tim ) < Kraid Killer >
Posts: 2251 - Joined: 02/13/2014
Nebraska
Profile
Just pounded through Nerdy Nights 3-5! I have my sprites moving all around the screen! I'm hooked. Can't wait to learn more. Learning the controls was pretty cool.

-------------------------
Current Project
Isometric Survival Horror

Older Projects
Tailgate Party, Power Pad Demo, Happy Hour

Links
Store, Facebook, Twitter

Mar 25, 2014 at 4:33:00 PM
abyssdoor (0)

< Cherub >
Posts: 4 - Joined: 01/30/2013
Mexico
Profile
Don't know if anyone has noticed, but the link to Disch's "The Frames and NMIs" in the "Sound 4" section is broken...

Mar 28, 2014 at 1:43:16 AM
gomygomy (0)
This user has been banned -- click for more information.
< Cherub >
Posts: 9 - Joined: 03/26/2014
Profile
Good and nice thread. Thanks for sharing.

All Games Free
www.zeeshankhanworld.in...

Jul 9, 2014 at 3:24:02 PM
MadnessVX (1)
avatar
< Tourian Tourist >
Posts: 39 - Joined: 07/12/2013
Texas
Profile
Does anyone have the sample files for the sound tutorials? Seems the domain name expired.

EDIT: Actually, just part 4 & 5 is needed. Thanks in advance!

-------------------------
Checkout my NES development blog!
http://facility15.blogspot.com/...


Edited: 07/12/2014 at 10:07 PM by MadnessVX

Jul 29, 2014 at 11:59:13 PM
fusion (0)

< Cherub >
Posts: 2 - Joined: 07/29/2014
Profile
Where could I download the .zip files that used to be available on "metal slimes" website, I'm looking specifically for the files (complete code for each tutorial) pertaining to his nes audio tutorials.

Thanks very much,
TA

Jul 30, 2014 at 7:15:52 AM
SoleGooseProductions (120)
avatar
(Beau ) < Ridley Wrangler >
Posts: 2738 - Joined: 04/22/2013
Indiana
Profile
Originally posted by: fusion

Where could I download the .zip files that used to be available on "metal slimes" website, I'm looking specifically for the files (complete code for each tutorial) pertaining to his nes audio tutorials.

Thanks very much,
TA

For MetalSlime's stuff, archive.org is your friend. Use the WayBack Machine, just make sure that you use the address for the specific file you want (i.e. not simply http://www.tummaigames.com..., but http://www.tummaigames.com/skelet....)


-------------------------
"The light that burns twice as bright burns half as long..." ~ Blade Runner

SoleGooseProductions.com



Edited: 07/30/2014 at 07:24 AM by SoleGooseProductions

Aug 1, 2014 at 11:40:50 PM
fusion (0)

< Cherub >
Posts: 2 - Joined: 07/29/2014
Profile
Hello,

Thanks very much for the info. Will check the archive.org/wayback.

Thanks again,
TA

Sep 18, 2014 at 2:55:20 PM
Mega Mario Man (58)
avatar
(Tim ) < Kraid Killer >
Posts: 2251 - Joined: 02/13/2014
Nebraska
Profile
I wasn't for sure if this was good enough for its own thread or not, so I just posted it here.

I thinking of writing a game using the Power Pad, so, I did some research and got the controller working. My question is, is there a better way to write ReadController1 subroutine or did I pretty much nail it first try? Mostly, I'm look at a better way to read bits 3 and 4 from $4016 and store them into variables. Any other suggestions are welcome.

ReadController1:
  LDA #$01
  STA $4016
  LDA #$00
  STA $4016
  LDX #$08
ReadController1Loop:
  LDA $4016
  LSR A            ; bit0 -> Carry
  LSR A            ; bit1 -> Carry
  LSR A            ; bit2 -> Carry
  LSR A            ; bit3 -> Carry
  ROL buttons1Lo     ; bit3 <- Carry
  LSR A            ; bit4 -> Carry
  ROL buttons2Hi     ; bit4 <- Carry   
  DEX
  BNE ReadController1Loop
  RTS



handle_input:
Read2:
  LDA buttons1Lo      ; power pad button 2
  AND #%10000000
  BEQ Read2Done
 
Read2Done:
 
 
Read1:
  LDA buttons1Lo     ; power pad button 1
  AND #%01000000
  BEQ Read1Done
 
Read1Done:


Read5:
  LDA buttons1Lo     ; power pad button 5
  AND #%00100000
  BEQ Read5Done
 
Read5Done:


Read9:
  LDA buttons1Lo     ; power pad button 9
  AND #%00010000
  BEQ Read9Done
 
Read9Done:


Read6:
  LDA buttons1Lo     ; power pad button 6
  AND #%00001000
  BEQ Read6Done
 
Read6Done:


Read10:
  LDA buttons1Lo     ; power pad button 10
  AND #%00000100
  BEQ Read10Done
 
Read10Done:


Read11:
  LDA buttons1Lo     ; power pad button 11
  AND #%00000010
  BEQ Read11Done
 
Read11Done:


Read7:
  LDA buttons1Lo     ; power pad button 7
  AND #%00000001
  BEQ Read7Done
 
Read7Done:


Read4:
  LDA buttons1Hi     ; power pad button 4
  AND #%10000000
  BEQ Read4Done
 
Read4Done:


Read3:
  LDA buttons1Hi     ; power pad button 3
  AND #%01000000
  BEQ Read3Done
 
Read3Done:


Read12:
  LDA buttons1Hi     ; power pad button 12
  AND #%00100000
  BEQ Read12Done
 
Read12Done:


Read8:
  LDA buttons1Hi     ; power pad button 8
  AND #%00010000
  BEQ Read8Done
 
Read8Done:
RTS

-------------------------
Current Project
Isometric Survival Horror

Older Projects
Tailgate Party, Power Pad Demo, Happy Hour

Links
Store, Facebook, Twitter

Sep 18, 2014 at 4:10:30 PM
Mario's Right Nut (350)
avatar
(Cunt Punch) < Bowser >
Posts: 6574 - Joined: 11/21/2008
Texas
Profile
I stole this from someone, and it works pretty universally and has all the controller info you'll need...ever.  It is pretty close to what you're using.  After that, I'd just do:

LDA joypad1_pressed
AND #%00001000  ;assuming that I have right bits
STA bitchinvarible

LDA joypad1_pressed
AND #%00000100
STA lamevariable

And set the variables to whatever you want them to be.

; read_joypad will capture the current button state and store it in joypad1.  
;       Off-to-on transitions will be stored in joypad1_pressed
strobe_controllers:
    lda joypad1
    sta joypad1_old ;save last frame's joypad button states
 
    lda joypad2
    sta joypad2_old ;save last frame's joypad button states
    
    lda #$01
    sta $4016
    lda #$00
    sta $4016
    
    ldx #$08
.loop:    
    lda $4016
    lsr a
    rol joypad1  ;A, B, select, start, up, down, left, right
    dex
    bne .loop
    
    lda joypad1_old ;what was pressed last frame.  EOR to flip all the bits to find ...
    eor #$FF    ;what was not pressed last frame
    and joypad1 ;what is pressed this frame
    sta joypad1_pressed ;stores off-to-on transitions
 
    ldx #$08
.loop2:    
    lda $4017
    lsr a
    rol joypad2  ;A, B, select, start, up, down, left, right
    dex
    bne .loop2
    
    lda joypad2_old ;what was pressed last frame.  EOR to flip all the bits to find ...
    eor #$FF    ;what was not pressed last frame
    and joypad2 ;what is pressed this frame
    sta joypad2_pressed ;stores off-to-on transitions
    
    rts

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

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.


Sep 18, 2014 at 5:35:27 PM
Mega Mario Man (58)
avatar
(Tim ) < Kraid Killer >
Posts: 2251 - Joined: 02/13/2014
Nebraska
Profile
Not sure I understand. That looks like the code I normally use. What part is checking bits 3 and 4 of #4016 for the Power Pad? It looks like it you are just checking bit 0, like you would on a standard controller.

Sorry, if its all there. I'm trying to see it. If you are just refering to the joypad1_pressed part, I am planning on adding that as well.

-------------------------
Current Project
Isometric Survival Horror

Older Projects
Tailgate Party, Power Pad Demo, Happy Hour

Links
Store, Facebook, Twitter

Sep 23, 2014 at 10:04:59 AM
Mega Mario Man (58)
avatar
(Tim ) < Kraid Killer >
Posts: 2251 - Joined: 02/13/2014
Nebraska
Profile
Crap. I just realized I posted this in the wrong thread. I meant to post the question in the Ask All Programming Questions Here thread. Would it be ok to move it?

-------------------------
Current Project
Isometric Survival Horror

Older Projects
Tailgate Party, Power Pad Demo, Happy Hour

Links
Store, Facebook, Twitter

Feb 18, 2015 at 1:00:26 PM
Mega Mario Man (58)
avatar
(Tim ) < Kraid Killer >
Posts: 2251 - Joined: 02/13/2014
Nebraska
Profile
Originally posted by: Roth

Nerdy Nights - Week 9 Dec)
 
There seems to be a bit of truncating going on with this line in the OP.

-------------------------
Current Project
Isometric Survival Horror

Older Projects
Tailgate Party, Power Pad Demo, Happy Hour

Links
Store, Facebook, Twitter

Feb 18, 2015 at 2:14:55 PM
Roth (66)
avatar
(Rob Bryant) < Lolo Lord >
Posts: 1733 - Joined: 09/14/2006
Illinois
Profile
Originally posted by: Mega Mario Man
 
Originally posted by: Roth

Nerdy Nights - Week 9 Dec)
 
There seems to be a bit of truncating going on with this line in the OP.

Fixed! Thanks!

-------------------------
http://slydogstudios.org...

Sep 21, 2015 at 3:32:08 AM
user (6)

< El Ripper >
Posts: 1462 - Joined: 05/30/2014
Profile
This threas still have the sticky icon but it is not on the top of the page anymore.

Sep 24, 2015 at 6:48:43 PM
MODERATOR
KHAN Games (88)
avatar
(Kevin Hanley) < Master Higgins >
Posts: 7760 - Joined: 06/21/2007
Florida
Profile
Originally posted by: user

This threas still have the sticky icon but it is not on the top of the page anymore.

I'm pretty good about catching them in this subforum.
 

Feb 8, 2016 at 3:12:54 AM
RockyHardwood (0)
avatar
< Tourian Tourist >
Posts: 37 - Joined: 02/03/2016
South Carolina
Profile
I'm pretty new to NES coding and NintendoAge in general, and I see that a bit of the conversation isn't too recent... but if anyone is still listening to this and knows where I can still find the example files for the music coding weeks, I'd really appreciate the help!

-------------------------
SMB Palette editor: https://github.com/johnwelter/Sup...
NES Text Engine (WIP): https://github.com/johnwelter/Roc...

 

Feb 8, 2016 at 7:21:26 AM
Mog (140)
avatar
(Mr Mog) < King Solomon >
Posts: 4584 - Joined: 05/02/2009
New York
Profile
Originally posted by: RockyHardwood

I'm pretty new to NES coding and NintendoAge in general, and I see that a bit of the conversation isn't too recent... but if anyone is still listening to this and knows where I can still find the example files for the music coding weeks, I'd really appreciate the help!


Here are most of the zip files. The ones that are missing don't contain any new/different info.



Edited: 02/08/2016 at 07:22 AM by Mog

Feb 8, 2016 at 9:26:23 AM
RockyHardwood (0)
avatar
< Tourian Tourist >
Posts: 37 - Joined: 02/03/2016
South Carolina
Profile
Thanks a lot! Really helps. Wasn't expecting code includes, this just keeps getting deeper and deeper...

-------------------------
SMB Palette editor: https://github.com/johnwelter/Sup...
NES Text Engine (WIP): https://github.com/johnwelter/Roc...

 

May 25, 2016 at 1:38:37 PM
QuickThumbs (3)
avatar
< Eggplant Wizard >
Posts: 423 - Joined: 08/05/2013
Profile
Been doing a little Apple II programming, and was surprised to find the addresses for the screen are not sequential. Does the NES suffer from this also?
What about built-in subroutines?

May 25, 2016 at 8:02:50 PM
SUBSCRIBER
GradualGames (39)
avatar
(Derek Andrews) < El Ripper >
Posts: 1013 - Joined: 10/09/2009
Pennsylvania
Profile
Not sure what you mean. NES video ram is completely sequential in so far as if you want to copy some screen data into a nametable, you tell the ppu what address to start writing at, then you keep hitting $2007 with each byte from your screen data til you're done. So I'd call that sequential. The way the video data is organized though could be said to not be sequential. The first 960 bytes of each of the two nametables say which tiles to show, the following 64 bytes (attribute table) say how to color those tiles, in chunks of 4 tiles each (arranged as larger squares. Most games are built around these larger squares on scrolling backgrounds).

As for built in subroutines, the NES doesn't have anything like a bios or something like that if that's what you mean. The only things that are built in are hardware functions, which are activated by reading and writing to specific locations on the memory bus. All subroutines have to be written by you or otherwise supplied by some library or other. Not sure if that helps  

-------------------------
Creators of: Nomolos: Storming the CATsle, and The Legends of Owlia.

May 25, 2016 at 8:52:49 PM
bunnyboy (81)
avatar
(Funktastic B) < Bowser >
Posts: 7474 - Joined: 02/28/2007
California
Profile
Apple II and NES have completely different ways of doing graphics, mostly because of the amount/cost of RAM. Apple is bitmap based. You write to an address and get some pixels on the screen. NES is tile based. You write to an address and it displays a tile that was already drawn on a grid. So tile locations are sequential (the nametable) but screen pixels are not.