It is currently Thu Sep 21, 2017 10:51 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 52 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
PostPosted: Wed Feb 22, 2017 8:19 pm 
Offline

Joined: Mon Jan 30, 2017 5:20 pm
Posts: 282
Location: Colorado USA
Yeah, my title pretty much says everything. Thanks!


Top
 Profile  
 
PostPosted: Wed Feb 22, 2017 8:23 pm 
Online

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 18993
Location: NE Indiana, USA (NTSC)
https://wiki.nesdev.com/w/index.php/NES ... r_for_ca65


Top
 Profile  
 
PostPosted: Thu Feb 23, 2017 12:49 am 
Online

Joined: Tue May 28, 2013 5:49 am
Posts: 750
Location: Sweden
The simplest way to make a header is to just use .db/.byte directives (depending of the assembler) to enter the bytes that forms the header at the start of the ROM.

Simple example of iNES header for NROM:
Code:
PRG_COUNT = $01 ;$01 = 16 kB ROM, $02 = 32 kB ROM
SCROLL    = $01 ;$01 = Horizontal Nametable Arrangement, $00 = Vertical Nametable Arrangement, $08 = Four-Screen
TVSYSTEM  = $00 ;$00 = NTSC, $01 = PAL

  .db "NES", $1a ;identification of the iNES header
  .db PRG_COUNT  ;number of 16 kB PRG-ROM pages
  .db $01        ;number of 8 kB CHR-ROM pages (0 = CHR-RAM)
  .db $00|SCROLL ;mapper 0 and scroll setting
  .db %00000000  ;mapper 0, iNES header, no arcade
  .db $00        ;no PRG-RAM
  .db TVSYSTEM   ;NTSC or PAL
  .dsb 6, $00    ;reserved bytes in the header


Using macros like Tepples' makes it easy to make any kind of header.


Top
 Profile  
 
PostPosted: Thu Feb 23, 2017 6:19 am 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1730
Location: DIGDUG
Ca65 doesn't have a .dsb directive. It does have .repeat and .res directives (either would do the same), but that's unnecessary. Just indicate fill = yes in the cfg definition of the header "segment", and it will pad up to the "size".

The size of the header needs to be exactly 16 bytes, and that is external to the PRG-ROM. It is metadata for the emulator, telling it how big the ROMs are and what map to use.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Thu Feb 23, 2017 8:25 am 
Online

Joined: Tue May 28, 2013 5:49 am
Posts: 750
Location: Sweden
dougeff wrote:
Ca65 doesn't have a .dsb directive.

Ah yes sorry, I forgot to say my example is using Asm6 syntax.

Also Ca65 would use .byte instead of .db to define bytes. Nesasm uses .db, but it has special directives for defining the header. Manually defining the iNES header using .db in Nesasm might mess with its annoying banking system I guess.


Top
 Profile  
 
PostPosted: Thu Feb 23, 2017 11:30 am 
Offline

Joined: Mon Jan 30, 2017 5:20 pm
Posts: 282
Location: Colorado USA
So, if I were to have the iNES header in the text file, then have a hexdump file and write that to an EPROM to use it on a real NES, would it work? Even though I could probably use a simple JMP to get the the section that has all of the code. Also kind of unrelated but I find it funny how this websites spellcheck doesn't count NES as a real word as well as Nintendo.


Top
 Profile  
 
PostPosted: Thu Feb 23, 2017 11:31 am 
Offline

Joined: Mon Jan 30, 2017 5:20 pm
Posts: 282
Location: Colorado USA
DementedPurple wrote:
So, if I were to have the iNES header in the text file, then have a hexdump file and write that to an EPROM to use it on a real NES, would it work? Even though I could probably use a simple JMP to get the the section that has all of the code. Also kind of unrelated but I find it funny how this websites spellcheck doesn't count NES as a real word as well as Nintendo.

* To the (Somehow spellcheck didn't notice that) :roll:


Top
 Profile  
 
PostPosted: Thu Feb 23, 2017 11:46 am 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1730
Location: DIGDUG
Quote:
So, if I were to have the iNES header in the text file, then have a hexdump file and write that to an EPROM to use it on a real NES, would it work? Even though I could probably use a simple JMP to get the the section that has all of the code. Also kind of unrelated but I find it funny how this websites spellcheck doesn't count NES as a real word as well as Nintendo.


Let's break this down line by line...

Quote:
iNES header in the text file


The header, is the first 16 bytes of a .NES file. It is binary. You can assemble a header, from a text file, if that's what you mean.

Quote:
hexdump file


A dump is a term refferring to...when there is a fatal crash of a program, a dump is the contents of RAM at the time of crash, saved to a file, for debugging purposes. I think you mean some other term.

Quote:
EPROM to use it on a real NES


No. You will never write a header in any ROM. It is just for emulation purposes. You would strip the header off if you wanted to burn it to a file an play in on real hardware. (Unless you mean on a flash cartridge designed to play .NES files, then you would leave the original .NES file intact with the header).

Code:
JMP to get the the section


header has no code.

EDIT: The last 6 bytes of the PRG ROM, has address for important things, the middle 2 bytes of that is the location of the start of the program. It's called the 'reset vector', and needs to be at address $FFFC-$FFFD. It points to the start address. When you press power or reset, the NES gets its program counter from here.


Finally. I still don't know what you are attempting to do.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Thu Feb 23, 2017 12:29 pm 
Offline

Joined: Mon Jan 30, 2017 5:20 pm
Posts: 282
Location: Colorado USA
So, if I can assemble a header, then how would I assemble with a CHR bank? Would I just make a simple .BIN file with the two files merged and change the extension or is it more complicated than that?


Top
 Profile  
 
PostPosted: Thu Feb 23, 2017 12:39 pm 
Offline

Joined: Mon Jan 30, 2017 5:20 pm
Posts: 282
Location: Colorado USA
dougeff wrote:
Quote:

Finally. I still don't know what you are attempting to do.

I'm attempting to make an NES ROM to test my game.


Top
 Profile  
 
PostPosted: Thu Feb 23, 2017 12:42 pm 
Offline

Joined: Mon Jan 30, 2017 5:20 pm
Posts: 282
Location: Colorado USA
And also, buy hexdump I meant a file with my codes OpCodes, not actually the hex values typed out, but the hex values characters.


Top
 Profile  
 
PostPosted: Thu Feb 23, 2017 12:45 pm 
Offline
User avatar

Joined: Wed Oct 16, 2013 7:55 am
Posts: 130
DementedPurple wrote:
And also, buy hexdump I meant a file with my codes OpCodes, not actually the hex values typed out, but the hex values characters.


This is not what hexdump means. If you say "an object file" (the .o extension) or "a binary file" (the general term), people will understand what you are referring to.


Top
 Profile  
 
PostPosted: Thu Feb 23, 2017 12:47 pm 
Online

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 18993
Location: NE Indiana, USA (NTSC)
DementedPurple wrote:
this websites spellcheck doesn't count NES as a real word as well as Nintendo.

That's your browser's spell check.

DementedPurple wrote:
I'm attempting to make an NES ROM to test my game.

The cc65 toolchain is a bit more flexible than other toolchains, but this also makes it somewhat more complicated to set up. You need to make these:

  • An iNES header
  • Code and data to put in PRG ROM
  • Tile data to put in CHR ROM (optional, required if not using CHR RAM)
  • Linker script to tell ld65 in what order to put all the above

One thing you could try is getting nrom-template to build. Then you can replace various pieces of it with your program.


Top
 Profile  
 
PostPosted: Thu Feb 23, 2017 7:34 pm 
Offline

Joined: Mon Jan 30, 2017 5:20 pm
Posts: 282
Location: Colorado USA
Pokun wrote:
The simplest way to make a header is to just use .db/.byte directives (depending of the assembler) to enter the bytes that forms the header at the start of the ROM.

Simple example of iNES header for NROM:
Code:
PRG_COUNT = $01 ;$01 = 16 kB ROM, $02 = 32 kB ROM
SCROLL    = $01 ;$01 = Horizontal Nametable Arrangement, $00 = Vertical Nametable Arrangement, $08 = Four-Screen
TVSYSTEM  = $00 ;$00 = NTSC, $01 = PAL

  .db "NES", $1a ;identification of the iNES header
  .db PRG_COUNT  ;number of 16 kB PRG-ROM pages
  .db $01        ;number of 8 kB CHR-ROM pages (0 = CHR-RAM)
  .db $00|SCROLL ;mapper 0 and scroll setting
  .db %00000000  ;mapper 0, iNES header, no arcade
  .db $00        ;no PRG-RAM
  .db TVSYSTEM   ;NTSC or PAL
  .dsb 6, $00    ;reserved bytes in the header


Using macros like Tepples' makes it easy to make any kind of header.

So how would I tell it what TV System, would I just give the name, would I have to use some quotation marks, would I just give it the name with no quotation marks, or does a number stand for that.


Top
 Profile  
 
PostPosted: Thu Feb 23, 2017 7:37 pm 
Offline
User avatar

Joined: Wed Oct 16, 2013 7:55 am
Posts: 130
What tutorial have you been following? I know that at least the Nerdy Nights tutorial covers this topic, and should help you understand what to do.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 52 posts ]  Go to page 1, 2, 3, 4  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group