6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Sep 29, 2024 5:32 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: nes emulation problem
PostPosted: Fri Sep 12, 2008 6:46 pm 
Offline

Joined: Fri Jul 18, 2008 11:01 am
Posts: 8
hi there,
i have so far completed all addressing modes, instructions, the routine of fetching opcodes, push/ pop. So in short if i load a game into my emulator, it verifies the nes format, then fetches code and executes instructions etc.
The problem is that upon fetching the first instruction which reads data from RAM area (which contains nothing at this time) the program just loops into BRK (simply because the opcode for BRK is 0x00) . The question i have is - has anyone else faced this problem?
i have been looking into this problem for weeks now and not found any solution :(
any help you guys can give would greatly be appreciated
many thanks


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Sep 12, 2008 9:35 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8521
Location: Southern California
To start from the beginning-- When the computer starts up, it will always have the reset routine in memory, normally in ROM. The ROM-resident code may load an operating system of some sort from mass storage, or it may already have it so it doesn't have to go get it. That code, in turn, will give the means to load your application (if indeed that is not also already ROM-resident) and jump into it to run it. You say you loaded the game, but then you say there's nothing in RAM where the computer jumps in expecting to find instructions. Perhaps it's not really loading, or you're not jumping into the right address.

On a slightly different subject, but one you or someone else asked about before, if it were data, it should be clear that no program should ever depend on valid data being in unitialized variables or arrays or other data structures. BTW, uninitialized RAM is not normally all 0's. It could be anything.

I think I understand your purpose in this project; but if someone just wants to learn 6502 programming, I do not really encourage starting with a simulator. It temps the newbie with faster initial progress, but IMO, it gives too much insulation from the essentials, such that the student may feel he's progressing nicely when in fact there are certain rudiments he has never conquered. Further down the road, when he has put too much confidence in simulators, his programming is more buggy and less dependable in the long run. He may also run into simple problems that he just does not have the answers to. An emulator BTW includes hardware and can be plugged into your board's processor socket. It is more than a simulator, and can be used to debug the hardware. A simulator is software only. I don't harp on it too much though because the mistake has been made so much that the erroneous terminology is beginning to stick.


Top
 Profile  
Reply with quote  
PostPosted: Sun Sep 14, 2008 6:50 pm 
Offline

Joined: Sat Sep 22, 2007 1:31 am
Posts: 24
bruce_lee wrote:
hi there,
i have so far completed all addressing modes, instructions, the routine of fetching opcodes, push/ pop. So in short if i load a game into my emulator, it verifies the nes format, then fetches code and executes instructions etc.
The problem is that upon fetching the first instruction which reads data from RAM area (which contains nothing at this time) the program just loops into BRK (simply because the opcode for BRK is 0x00) . The question i have is - has anyone else faced this problem?
i have been looking into this problem for weeks now and not found any solution :(
any help you guys can give would greatly be appreciated
many thanks


Which rom are you having this problem with? Have you emulated any of the mappers? Some games have different revisions and thus have a different starting point for mapping the last 16k address range. These roms are usually labeled PRG 1 or PRG 0.

Anyway, if you can give some details I can help you out (been doing a lot of NES emulation and programming stuff lately).


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Dec 12, 2008 9:51 pm 
Offline

Joined: Sun Sep 15, 2002 10:42 pm
Posts: 214
Sounds like the emulator isn't properly initializing the PC from the reset vector.

Toshi


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

All times are UTC


Who is online

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