6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Nov 22, 2024 8:40 pm

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Sat Aug 23, 2008 10:53 pm 
Offline

Joined: Fri Jul 18, 2008 11:01 am
Posts: 8
hi there,
i am in the process of completing the cpu side of a nes emulator i am programming.
The current problem i have is that the ram is loaded with no data - i understand that when loading the rom file the nes gets the program rom from the 10th element in the rom file, and the vrom comes after that. But where can i get the RAM data from??
any help would greatly be appreicated
many thanks


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Aug 24, 2008 6:24 am 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
The RAM contains random values at power on. The code in the ROM should initialise it.

_________________
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Aug 24, 2008 11:46 am 
Offline

Joined: Fri Jul 18, 2008 11:01 am
Posts: 8
hi there, thanks for your reply,
can you elaborate on this for me please? , i understand that the rom data is retrieved at startup (assuming this is programmable rom we are talking about),
which part of the rom gets stored in the ram? at what offset? and how large? assuming we are using the fread function in C:

startup()
{
fseek(FILE_PTR,0x10,SEEK_SET);
fread(rom,sixteen_kb,numROM,FILE_PTR);

//which part of rom gets stored in ram?
}

any help you can give would be greatly appreciated
many thanks


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Aug 24, 2008 1:02 pm 
Offline

Joined: Fri Aug 30, 2002 2:05 pm
Posts: 347
Location: UK
Quote:
which part of the rom gets stored in the ram?

None of it, the RAM contents are irrelevant at startup.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Aug 24, 2008 5:35 pm 
Offline

Joined: Sat Jan 04, 2003 10:03 pm
Posts: 1706
If the NES is architected like most other computers, the program code stored in the ROM is wholly responsible for configuring the I/O and RAM variables it needs to function. Thus, you needn't concern yourself with the contents of RAM -- the game ROMs should take care of that for you.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Aug 24, 2008 10:03 pm 
Offline

Joined: Sun Nov 05, 2006 8:57 pm
Posts: 7
There are NES carts which contain RAM chips as well and is accessed via bank switching. I don't remember mapper number.

_________________
Slogan: Everything or nothing


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Aug 25, 2008 7:25 am 
Offline

Joined: Sat Sep 22, 2007 1:31 am
Posts: 24
http://nesdevwiki.org/index.php/NESdevWiki

The rom header will indicate if the game (not just the mapper) supports additional SRAM (mapped to $6000-$7fff). Be careful, some older iNES formats have incorrect headers. You can tell by search for 4 different identifiers in the second half of the $10 byte header. Look at Mednafen's source to see (I don't remember off hand what they were). If the RAM is battery backed, then I'm not entirely sure how to treat the ram when the rom is first ran/encountered. Probably just clear it out. Most(all?) games with battery backed SRAM do a CRC check on power/reset. Dragon Warrior reinitializes SRAM on CRC fail for example.

Also, not all games use VROM. Some games use VRAM (CHR RAM) with MMC and other mappers.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 10 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: