It is currently Wed Sep 20, 2017 6:15 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 26 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Tue Jul 22, 2008 1:16 pm 
Offline
User avatar

Joined: Wed Dec 06, 2006 8:18 pm
Posts: 2799
Simple question I think. If you set EXRAM to mode 2 where the CPU can read and write to it from $5C00 to $5FFF, can you copy code there and execute it?

I'm trying to do this but Nestopia and Nintendulator seem to say I can't do that. When the CPU try to execute at $5C00 range it seems to get all FFs. However when I copy my routine there, and then read it back I can see in the debugger that each byte was written correctly to EXRAM. To be clear, I copy each byte to EXRAM, then I just loaded each byte from EXRAM back into Reg-A and so through the debugger I could see it was written correctly. But the CPU when watched in the debugger will jump to $5C00 and read FF through the whole region.

So can the CPU for some reason not execute from EXRAM? The reason I'm doing this is I wanted to avoid using PRG-RAM so I could use the MMC-5 board without any.

I hope someone knows the answer to this or can do their own test.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 22, 2008 2:44 pm 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7202
Location: Chexbres, VD, Switzerland
Well, if you can read it then definitely you should be able to execute code from it (but I never tried). Definitely the emulators should be wrong on this point. After all executing code is a particular case of reading !

_________________
Life is complex: it has both real and imaginary components.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 22, 2008 5:09 pm 
Offline
User avatar

Joined: Wed Dec 06, 2006 8:18 pm
Posts: 2799
Well, if someone doesn't beat me to it first, I'll put together a decent test ROM or someone could modify a demo of theirs to use MMC5 and store a routine in EXRAM and see what happens on the NES. If you try it on Nestopia or Nintendulator it should crash (the NES program) though.

I agree with you, I think this is the emulator at fault as I don't see why EXRAM shouldn't be able to hold code. But the real hardware will have to be tested unless someone else has already tried this.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 22, 2008 6:02 pm 
Offline
User avatar

Joined: Mon Sep 27, 2004 8:33 am
Posts: 3715
Location: Central Texas, USA
Does the NES cartridge connector expose any signals which the MMC5 could use to differentiate opcode from data memory accesses? I couldn't find much information about M2.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 22, 2008 9:36 pm 
Offline
User avatar

Joined: Mon Sep 27, 2004 2:13 pm
Posts: 1667
Location: .ma.us
Not only is there no signal to detect opcode reads (called SYNC) on the connector but the signal isn't available on the 2A03 at all, so without a doubt you can execute from any memory on any mapper.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 22, 2008 10:43 pm 
Offline
User avatar

Joined: Wed Dec 06, 2006 8:18 pm
Posts: 2799
Well then, Nintendulator and Nestopia both fail to emulate execution from EXRAM. Anyone interested in fixing either? Preferably Nintendulator for it's debugger but either would be useful to me. I'd try to do it myself but I rarely have much luck compiling other people's projects. That and I don't know why they are broken.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 23, 2008 9:40 am 
Offline

Joined: Wed Mar 22, 2006 8:00 am
Posts: 354
There's no reason I can think of why EXRAM cannot be used for code execution. The fact that Nestopia fails is likely due to optimizations designed at fetching instructions as quickly as possible. Those optimizations may not account for the possibility of special memory such as EXRAM. Nintendulator might have a similar problem - don't know what kinds of optimizations that emu uses.

If I get around to it, I will get the latest Nestopia source and see what I can find.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 27, 2011 10:03 pm 
Offline
Formerly 65024U

Joined: Sat Mar 27, 2010 12:57 pm
Posts: 2257
I saw in the MMC5 EXRam thing that you can only read/write to EXRam during rendering, is that right or a typo? Maybe that has something to do with it. And if that's true, you you have to make the next screen for your game in EXRam during the frame outside of vblank?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 28, 2011 5:32 am 
Online
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10010
Location: Rio de Janeiro - Brazil
3gengames wrote:
I saw in the MMC5 EXRam thing that you can only read/write to EXRam during rendering

It depends on the settings you choose. There's a mode that behaves like that, yes, but you can also make it behave just like regular RAM.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 28, 2011 9:35 am 
Offline
Formerly 65024U

Joined: Sat Mar 27, 2010 12:57 pm
Posts: 2257
So I take it the mode that you can only write during rendering is the mode where you extend the table attributes?.....Why must you write during rendering? Wouldn't that cause the PPU and CPU be trying to use both at the same time, so shouldn't you be trying to change it during VBlank?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 28, 2011 8:26 pm 
Offline

Joined: Mon Sep 27, 2004 2:57 pm
Posts: 1246
3gengames wrote:
So I take it the mode that you can only write during rendering is the mode where you extend the table attributes?.....Why must you write during rendering? Wouldn't that cause the PPU and CPU be trying to use both at the same time, so shouldn't you be trying to change it during VBlank?

You write to it directly via the CPU, instead of using 2006/2007 like when you're trying to access the internal PPU ram. However, we don't actually understand the MMC5 very well at all to know how exactly this is able to work. The MMC5 must do something to allow simultaneous accesses to the ExRAM though, since Nintendo made the decision to only allow writes (in mode 0 and mode 1) during rendering, which is when the PPU is constantly fetching bytes, meaning the MMC5 would need to also be constantly accessing its ExRAM.

My hypothesis is that there's a pipeline, much like the read-pipeline in the PPU when you read 2007. When you write to ExRAM, the MMC5 stores it in the pipeline until the PPU is in between ExRAM accesses, during which it commits the write the CPU made. There are 3 PPU cycles for each CPU cycle, and when the PPU is fetching BG tiles, it spends two of its cycles fetching the bitmap data from the pattern table, so the MMC5 probably commits ExRAM writes during this time. There's a LOT of time in between sequential CPU accesses in which the MMC5 can commit writes, so this would work out flawlessly. This is just a hypothesis though, so don't take this to heart. :P


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 29, 2011 1:05 pm 
Offline
Formerly 65024U

Joined: Sat Mar 27, 2010 12:57 pm
Posts: 2257
But outside of rendering, wouldn't the pipeline just be more efficient and still work?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 29, 2011 2:55 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 18989
Location: NE Indiana, USA (NTSC)
Maybe after someone decaps the PPU to get a good set of micrographs, someone might decap an MMC5.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 29, 2011 3:00 pm 
Offline
Formerly 65024U

Joined: Sat Mar 27, 2010 12:57 pm
Posts: 2257
tepples wrote:
Maybe after someone decaps the PPU to get a good set of micrographs, someone might decap an MMC5.


We can hope, we'll need to find a couple of Castlevania 3's though....


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 29, 2011 5:48 pm 
Offline
User avatar

Joined: Wed Dec 06, 2006 8:18 pm
Posts: 2799
CV3 isn't the only MMC5 game. Many MMC5 games exist, much less desirable than CV3.


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

All times are UTC - 7 hours


Who is online

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