It is currently Sun Dec 17, 2017 12:50 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Megaman 2
PostPosted: Thu Oct 25, 2012 10:28 am 
Offline

Joined: Thu Aug 28, 2008 1:17 am
Posts: 591
Got megaman 2 up and running. Love this game...

https://www.youtube.com/watch?v=ljtxuk9KDCg


Top
 Profile  
 
 Post subject: Re: Megaman 2
PostPosted: Thu Oct 25, 2012 10:40 am 
Offline

Joined: Thu Oct 05, 2006 6:29 am
Posts: 911
Cool. Though the music at the "weapon equip" sequence after the boss fight sounds messed up :P

How do you map the NES RAM and I/O areas to TG16 RAM btw? I'd expect clashes between zeropage RAM, PPU I/O and APU I/O due to the amount of RAM available on the TG16 and how the 6280's paging works. Or do you rely on BRAM or some other kind of expansion RAM (Arcade Card)?


Top
 Profile  
 
 Post subject: Re: Megaman 2
PostPosted: Thu Oct 25, 2012 10:42 am 
Offline
User avatar

Joined: Fri Jul 13, 2012 2:06 am
Posts: 66
Location: Greece
awesome work! :shock:


Top
 Profile  
 
 Post subject: Re: Megaman 2
PostPosted: Thu Oct 25, 2012 10:51 am 
Offline
User avatar

Joined: Wed Dec 06, 2006 8:18 pm
Posts: 2806
TG16 lets you remap address space. You can move WRAM, I/O, etc.

Awesome work. What an amazing game to get running on the PCE.


Top
 Profile  
 
 Post subject: Re: Megaman 2
PostPosted: Thu Oct 25, 2012 10:56 am 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6535
Location: Seattle
That's awesome! Do you have any documentation on the tool you used for the conversion? Or a description of the process?


Top
 Profile  
 
 Post subject: Re: Megaman 2
PostPosted: Thu Oct 25, 2012 11:02 am 
Offline

Joined: Thu Aug 28, 2008 1:17 am
Posts: 591
mic_ wrote:
Cool. Though the music at the "weapon equip" sequence after the boss fight sounds messed up :P

How do you map the NES RAM and I/O areas to TG16 RAM btw? I'd expect clashes between zeropage RAM, PPU I/O and APU I/O due to the amount of RAM available on the TG16 and how the 6280's paging works. Or do you rely on BRAM or some other kind of expansion RAM (Arcade Card)?


I believe that part of the audio is due to sweep emulation not being right. Heh, I was actually gonna look at your source so see how you handled the audio emulation in your nsf TG16 player.

The game doesn't use any additional ram, so I'm safe with with getting by with the 8k scratch pad ram of hucard setup (though this runs on CD 3.0 too, so I have access to more ram if needed by such NES games). Anyway, I map the 8k ram bank to both MPR0 and MPR1. This takes care of ZP and stack access since it's locked to $2000-21fff logic address range (isn't this what you do with your NSF player on the tg16?). I map the hardware bank ($ff) of the PCE to MPR3 (video ports become $6000,$6002/$6003) since the current NES game has open bus there, but for other games that have expanded ram (like Dragon Warrior which I have running on the PCE CD as well) - I use self modifying code and use the ST0/ST1/ST2 opcodes to write directly to vram and VDC regs without having any hardware bank mapped. The only time I map it in on vblank interrupt call, cause I need to read the status port of the VDC to acknowledge the interrupt. Else, I'm good to go. My backend emulation code (APU/PPU/game/internal) is mapped to MPR2/$4000-$5fff range.

As far as port read and writes, I replace them with JSRs to the backend emulation. I wrote a tool that scans the rom for specific opcodes for those I/O port writes. It only took 4 hours to get Megaman 2 up and running with the existing backend emulation and that including playing and beating the game.


Top
 Profile  
 
 Post subject: Re: Megaman 2
PostPosted: Thu Oct 25, 2012 11:10 am 
Offline

Joined: Thu Oct 05, 2006 6:29 am
Posts: 911
Quote:
TG16 lets you remap address space.

Yes, I'm aware of that ;)
But those three regions all need to be writeable at the same time unless you modify the 6502 code of the NES game, and there's only one physical page of RAM on an unexpanded TG16 regardless of how many logical pages you might've mirrored it to.


Top
 Profile  
 
 Post subject: Re: Megaman 2
PostPosted: Thu Oct 25, 2012 11:25 am 
Offline

Joined: Thu Oct 05, 2006 6:29 am
Posts: 911
Quote:
I believe that part of the audio is due to sweep emulation not being right. Heh, I was actually gonna look at your source so see how you handled the audio emulation in your nsf TG16 player.


I implemented it as it was described on the nesdev wiki. IIRC, something like this (pseudo code):

Code:
wPeriod = [0x4002] & 0x7FF
bShift = [0x4001] & 7
bNeg = [0x4001] & 8
[0x4002] = bNeg ? (wPeriod - (wPeriod>>bShift)) : (wPeriod + (wPeriod>>bShift))


And similarly for square 2. This is updated twice per frame (120 times/second for NTSC).


Top
 Profile  
 
 Post subject: Re: Megaman 2
PostPosted: Thu Oct 25, 2012 11:28 am 
Offline

Joined: Thu Aug 28, 2008 1:17 am
Posts: 591
mic_ wrote:
Quote:
TG16 lets you remap address space.

Yes, I'm aware of that ;)
But those three regions all need to be writeable at the same time unless you modify the 6502 code of the NES game, and there's only one physical page of RAM on an unexpanded TG16 regardless of how many logical pages you might've mirrored it to.


Mapping ram to MPR0 and MPR1 takes care of all ZP and stack related issues (since ZP and stack will go to $2000 range, but since ram is mirrored to $0000 range - regular access to ram is fine as well). If you replace the port read/writes with JSRs (I've yet to see port access that isn't full 16bit address; i.e. lda 2007 or sta $4000,x), the perfect length for a JSR replacement. But yeah, WRAM presents a problem for hucard projects, unless you use the Populous rom layout which gives you an additional 32k of ram after the 4megabit rom address range or you just limit your project to CD (Tailchao made a new hucard mapper for PCE with expand ram and rom, but no emulator supports it yet that I know of).


Top
 Profile  
 
 Post subject: Re: Megaman 2
PostPosted: Thu Oct 25, 2012 11:29 am 
Offline

Joined: Thu Aug 28, 2008 1:17 am
Posts: 591
mic_ wrote:
Quote:
I believe that part of the audio is due to sweep emulation not being right. Heh, I was actually gonna look at your source so see how you handled the audio emulation in your nsf TG16 player.


I implemented it as it was described on the nesdev wiki. IIRC, something like this (pseudo code):

Code:
wPeriod = [0x4002] & 0x7FF
bShift = [0x4001] & 7
bNeg = [0x4001] & 8
[0x4002] = bNeg ? (wPeriod - (wPeriod>>bShift)) : (wPeriod + (wPeriod>>bShift))


And similarly for square 2. This is updated twice per frame (120 times/second for NTSC).


I probably have some $4015 behavior incorrect as well. I need to re-go over my audio emulation code.


Top
 Profile  
 
 Post subject: Re: Megaman 2
PostPosted: Thu Oct 25, 2012 5:41 pm 
Offline
User avatar

Joined: Sat Oct 20, 2012 9:44 am
Posts: 6
Location: United States
tomaitheous wrote:
(Tailchao made a new hucard mapper for PCE with expand ram and rom, but no emulator supports it yet that I know of).

Actually it's partially supported in newer builds of Mednafen. I didn't even find this out until upgrading to 0.9.26 awhile ago, and my builds stopped working.
Reads from any address just return $FF, so if it finds an MCGenjin header in your ROM you're kind of hosed. I think it's just some missing break; statements in ReadTP of mcgenjin.h, but I'll have to test it out later.


Top
 Profile  
 
 Post subject: Re: Megaman 2
PostPosted: Fri Oct 26, 2012 5:53 am 
Offline
User avatar

Joined: Wed Oct 15, 2008 11:50 am
Posts: 939
:shock:

Damn...


Top
 Profile  
 
 Post subject: Re: Megaman 2
PostPosted: Fri Oct 26, 2012 6:38 am 
Offline

Joined: Sun Mar 19, 2006 9:44 pm
Posts: 924
Location: Japan
Interesting... Mic_ I didn't know you made your own PCE NSF player too.

I made up one back in 2006 just for fun, but didn't develop it too far because I was working on Tongueman's Logic more earnestly. You can check out how I did the MPR voodoo in the source code.

http://www.chrismcovell.com/data/PCE_NES_Player.zip

Okay, since you posted on your blog about this too, Tomaitheous: Is there any way to eliminate the nasty popping on real PCE hardware when you write new waveforms into WSG RAM? The only thing that doesn't cause popping are waveforms that are 32 bytes of value $10. Even changing the volume registers on the PCE causes popping.

_________________
http://www.chrismcovell.com


Top
 Profile  
 
 Post subject: Re: Megaman 2
PostPosted: Fri Oct 26, 2012 7:17 am 
Offline

Joined: Thu Oct 05, 2006 6:29 am
Posts: 911
Quote:
Is there any way to eliminate the nasty popping on real PCE hardware when you write new waveforms into WSG RAM?

They don't seem all that noticeable on my TG16. But how about dynamically moving channels around? The TG16 has 6 channels, and the NES only has 4 if you ignore any expansion audio (or 5 if you emulate DMC). So if the duty cycle of Pulse1 or Pulse2 changes, load the waveform that matches the new duty cycle into a currently unused HuC6280 channel (channel 4 or 5), then deactivate the HuC6280 channel currently used and start the new channel. That should at least get rid of any gaps that result from halting the channel while loading the new waveform.


Top
 Profile  
 
 Post subject: Re: Megaman 2
PostPosted: Fri Oct 26, 2012 11:50 am 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3969
Will the 50% duty cycle square wave get fixed?

_________________
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!


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

All times are UTC - 7 hours


Who is online

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