faulks78 / genplus-gx

Automatically exported from code.google.com/p/genplus-gx
Other
0 stars 0 forks source link

Mega-CD support #29

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It would be cool to have mega CD suppot to play game like Dune, Road
Avenger... Maybe look at the code used by Notaz for his emulator Picodrive

http://notaz.gp2x.de/

Thanks for your hard work on this emulator ;)  

Original issue reported on code.google.com by Yod4zM...@gmail.com on 29 May 2009 at 7:10

GoogleCodeExporter commented 9 years ago
I know about Picodrive, it uses Gens assembly code rewritten to C and could 
indeed be
implemented in Genesis Plus (still require lot of work though, don't think it's 
easy
to add segaCD support, it's far more than a "simple" extension).

However, I'm more interested in writing my own original core from scratch (one 
day...
maybe)

I leave this "issue" as an enhancement request here since it seems to pop-up
periodically but if it ever happen, it won't happen until a while (at least 
from me).

Original comment by ekeeke31@gmail.com on 29 May 2009 at 9:00

GoogleCodeExporter commented 9 years ago
I don't expected it soon, I would see more the new interface version with the 
very
good genesis compatibility ;)

Original comment by Yod4zM...@gmail.com on 30 May 2009 at 9:51

GoogleCodeExporter commented 9 years ago
I'd just like to add how much I'd love to see this too. When the Sega CD came 
out the
Genesis really hit its stride with a lot of amazing games I'd love to be able 
to play
again on my Wii. I still have my original Dune and Ground Zero Texas CDs! 

Original comment by timw...@gmail.com on 14 Jun 2009 at 1:22

GoogleCodeExporter commented 9 years ago
ok, I think I got it guys, no need to flood this, remember this is not a 
discussion
forum ;-)

Original comment by ekeeke31@gmail.com on 15 Jun 2009 at 6:52

GoogleCodeExporter commented 9 years ago
Issue 34 has been merged into this issue.

Original comment by ekeeke31@gmail.com on 14 Jul 2009 at 8:28

GoogleCodeExporter commented 9 years ago
ekeeke, could you possibly let me know if you ever do get this worked on? i 
usually
check up on things, but im sure just as you are, i am also very busy @times and 
may
not be up to speed when you do this (if you do). thanks.

Original comment by bNoc0...@gmail.com on 14 Jul 2009 at 8:45

GoogleCodeExporter commented 9 years ago
Issue 21 has been merged into this issue.

Original comment by ekeeke31@gmail.com on 15 Sep 2009 at 2:29

GoogleCodeExporter commented 9 years ago

Original comment by ekeeke31@gmail.com on 22 Oct 2009 at 9:27

GoogleCodeExporter commented 9 years ago
I know this is not a discussion forum, and that this is irrelevant to the 
subject,
and that this might be a waste of time, but it had to be said, and I don't know 
where
else I can do it.

You (eke-eke) are a cool guy! So nice, so pleasant. I've been reading around 
here,
and you just made my day! I feel so comfortable and happy now. Thanks for being 
awesome!

Original comment by hellohol...@gmail.com on 25 Feb 2010 at 10:12

GoogleCodeExporter commented 9 years ago
Agreed :)

Original comment by joelwhyb...@googlemail.com on 15 Apr 2010 at 6:10

GoogleCodeExporter commented 9 years ago

Original comment by ekeeke31@gmail.com on 25 May 2010 at 6:51

GoogleCodeExporter commented 9 years ago

Original comment by ekeeke31@gmail.com on 4 Dec 2010 at 5:25

GoogleCodeExporter commented 9 years ago
Yo man Cmon I know you guys are badass all you got to do is what you do to make 
the sega cd games to work I know it can be done what you say?please

Original comment by marksave...@gmail.com on 26 Sep 2011 at 11:26

GoogleCodeExporter commented 9 years ago
>Yo man Cmon I know you guys are badass all you got to do is what you do to 
make the >sega cd games to work I know it can be done what you say?please

If you donate 1000 € to ekeeke to pay the typing monkeys I am sure that will 
add MEGA CD for tomorrow I think the monkeys are hungry now (just joking) 
;))))) I think this needs time and a lot optimization with WII procesor. I love 
to play Dune with Genplus gx If you have developing knowledge you can try to 
add MESS/MAME code to Gensplus gx this can be doable I think.

Original comment by ferran...@hotmail.com on 27 Sep 2011 at 3:28

GoogleCodeExporter commented 9 years ago

Original comment by ekeeke31@gmail.com on 17 Jan 2012 at 9:41

GoogleCodeExporter commented 9 years ago

Original comment by ekeeke31@gmail.com on 17 Jan 2012 at 9:41

GoogleCodeExporter commented 9 years ago
Mega CD status changed to medium, something is cooking at Ekeeke's kitchen and 
smells very well ;) I am ansious to taste this cake.Thank yo for your time and 
job =)

Original comment by ferran...@hotmail.com on 20 Jan 2012 at 11:33

GoogleCodeExporter commented 9 years ago
Well, Mega/Sega CD is potentially possible on the Wii's hardware. 32X on the 
other hand, may not be.

Original comment by kingofch...@gmail.com on 21 Jan 2012 at 4:35

GoogleCodeExporter commented 9 years ago
nick to see this is still bieng worked on. im hoping to play some puggsy CD and 
original sonic cd sometime in the future.

Original comment by cheatfreak47 on 3 Feb 2012 at 8:29

GoogleCodeExporter commented 9 years ago
been waiting for this for years! i got my sega cd, but if the wii could emulate 
it, it would be one step close to the perfect console xD

BTW thank for the hard work i really apreciate it

Original comment by curseoft...@gmail.com on 22 Mar 2012 at 4:43

GoogleCodeExporter commented 9 years ago
I think I will be using this entry to keep some traces of my progress.

I got some time to work on it today and basically have the SUB-CPU integrated 
in genesis plus core and running, as well as basic memory mapping for both 
sides and CD registers on MAIN-CPU side.

Here is a picture of the Sega CD BIOS running. Not much for a beginning, it's 
still missing a lot (registers on SUB-CPU side need to be completed, GFX 
rotation/scaling & PCM emulation is done but need to be integrated, no CDD/CDC 
emulation yet, etc) but this is a start ;-)

Original comment by ekeeke31@gmail.com on 9 Apr 2012 at 3:35

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by ekeeke31@gmail.com on 9 Apr 2012 at 3:36

GoogleCodeExporter commented 9 years ago
PROGRESS! yay. i want this soo bad! Sega CD was fun. I really wanna emulate 
Sonic CD and Puggsy CD on my wii.

Original comment by cheatfreak47 on 10 Apr 2012 at 7:51

GoogleCodeExporter commented 9 years ago
Mega-CD support is  a feature I was hoping for years. I am utterly impressed 
and touched that this time has finally came.Congratulations eke-eke and I wish 
you the best!Thank you so much!!!

Original comment by pantasda...@gmail.com on 11 Apr 2012 at 12:41

GoogleCodeExporter commented 9 years ago
A little bit more of progress:

- CD registers are now properly emulated on both sides, including Work-RAM 
switching and interrupts (level4, level 2 and level 1), which make the BIOS 
going a little bit further

- GFX chip is emulated and rotation/scaling running but my code obviously needs 
some rework as the sega logo effects are not displayed at all and BIOS menu is 
corrupted if you try to enter it. 

Original comment by ekeeke31@gmail.com on 11 Apr 2012 at 11:11

Attachments:

GoogleCodeExporter commented 9 years ago
Also note the sensitive speed penalty (~25%) that results of GFX chip emulation 
running in backbround. And that's without PCM chip being running for now, no 
CDC transfers and no CD-DA track playback.

For reference, Virtua Racing (which is reaching the limit of what can be 
emulated fullspeed on Wii) is running at ~220fps on this setup so there is 
still some room (even if performances on PC vs Wii can not be directly 
compared/scaled).

Original comment by ekeeke31@gmail.com on 11 Apr 2012 at 11:19

GoogleCodeExporter commented 9 years ago
Thank you :) 

One question : Will it be compatible with iso + wav dumps ?

When it will be released the first game that I'll try is Dune and the second 
Sim Earth, I never played it on Mega CD....

Original comment by ferran...@hotmail.com on 12 Apr 2012 at 9:50

GoogleCodeExporter commented 9 years ago
ISO & CUE/BIN support are coming next but it requires emulation of CDD/CDC 
first.
wav files are probably going to be supported as I assume it would be faster to 
use PCM format for audio rather than having to decode OGG or MP3 files. Having 
audio tracks already converted to Wii audio format (16bit stereo @48khz) should 
also help.

Anyway, great progress today: I fixed a few bugs in my graphics chip 
implementation and I got rotation/scaling effects working now ! Timings 
probably need some adjustments to match the speed of actual console but it 
looks good.

I also fixed a nasty bug with memory masking, which was the cause of garbled 
graphics in BIOS menu. This is now also fixed.

Next step would be integrating my PCM core and listen how it sounds (not much 
to show) then moving on into serious stuff with CDD/CDC emulation and trying to 
play with a CD image.

Original comment by ekeeke31@gmail.com on 12 Apr 2012 at 6:54

Attachments:

GoogleCodeExporter commented 9 years ago
very thanks for your work, your progress are impressive

Original comment by mrdeathj...@gmail.com on 13 Apr 2012 at 3:54

GoogleCodeExporter commented 9 years ago
looks as though progress is blowing up! Thanks ekeeke! 

Original comment by cheatfreak47 on 13 Apr 2012 at 6:38

GoogleCodeExporter commented 9 years ago
Tnank you, your progress is impressive & fast...

about ogg and mp3 and wav i think wav it's the best option, it takes more space 
but more quality and TOSEC it's iso+wav (TOSEC has more titles than other 
SEGACD collections).
I think that SEGACD music tracks are 16bit stereo @44.1 khz I hope this will 
not be a problem for wii.

I am a wav fan I always prefer it than mp3 or ogg.On players, pdas Wav files 
take more space but exetends the battery live.

Original comment by ferran...@hotmail.com on 13 Apr 2012 at 9:47

GoogleCodeExporter commented 9 years ago
Re Comment 31 - I agree that supporting WAV would be good but if you're 
suggesting that it should be exclusively supported then I don't think that 
makes any sense. For lossless audio support, FLAC would be *far* more 
practical. Also, the effect of lossy formats upon the battery life of portable 
players has no bearing on a Wii-based emulator (not to mention that portable 
players usually decode formats such as AAC with a low power draw due to 
hardware acceleration).

I think Ogg Vorbis is a good choice as a lossy format. The results with the 
aoTuV patched encoder are outstanding, easily on a par with the best AAC 
encoders. I use it for my PC Engine CD rips in wii-mednafen.

Original comment by kerfra...@gmail.com on 13 Apr 2012 at 11:33

GoogleCodeExporter commented 9 years ago
For resampling, here's the FIR filter from mednafen:

http://code.google.com/p/wii-mednafen/source/browse/tags/0.1.1/mednafen/src/soun
d/Fir_Resampler.cpp

I have no idea how fast this is but it all works well.

Original comment by kerfra...@gmail.com on 13 Apr 2012 at 11:49

GoogleCodeExporter commented 9 years ago
That's the resampler i already use for FM chip, it was actually written by Shai 
Green, author of NTSC filters. I actually think it will be way more optimized 
to manually resample tracks to wii output samplerate (48hz). Indeed, it's not 
as if CD hardware was needing cycle-accurate audio, it does not modify the 
tracks, it's basically just a bunch of command that do PLAY, STOP or SEEK, in 
regard to time unit, not cycles or stream byte position like data tracks. As 
long as the audio track length is the same, it will play the same.

But please don't derail this into a discussion about audio format, there are 
already many places on internet for you to discuss that. I already know about 
all these stuff and there is still a lot to do before arguing what is the best, 
etc...

Also, to be clear, my goal is not to support all existing or possibly best 
lossless audio format, it's to find the most optimized way to play audio tracks 
on Wii. It will be a compromise between decompression processing time  and slow 
access time bound to external device if the track cannot fit in wii memory. If 
it appears that the fastest is to have every tracks to be converted (by user, 
by emulator on startup or by an external app) in wii native format then so be 
it...

Original comment by ekeeke31@gmail.com on 13 Apr 2012 at 12:40

GoogleCodeExporter commented 9 years ago
Sorry, you're right. At this early stage, it's of scant concern at best and a 
distration at worst. I hope it all works out.

Original comment by kerfra...@gmail.com on 13 Apr 2012 at 6:15

GoogleCodeExporter commented 9 years ago
Some more progress, still on getting BIOS running correctly. I added proper 
Timer interrupt, implemented better interrupt handling in general and fixed 
timings, required to get European & Japanese BIOS working fine.

I also got PCM chip running at original frequency & resampled to 48Hz using 
Blip Buffer, which is nice.

Finally, I quickly added support for backup RAM cartridge (up to 512K) and 
emulated CDC registers. Next step now that BIOS are working fine will be 
completing CDC emulation with decoding interrupts and data transfer from CD 
images, as well as CDD emulation to handle all CD commands properly.

Original comment by ekeeke31@gmail.com on 15 Apr 2012 at 6:19

Attachments:

GoogleCodeExporter commented 9 years ago
your work appears big footsteps this days, many thanks for your work

Original comment by mrdeathj...@gmail.com on 15 Apr 2012 at 10:49

GoogleCodeExporter commented 9 years ago
Not sure how much time this project will remain available here but I wanted to 
post some of the progress I recently made last weeks: after a lot of bug fixing 
and trace analyzing, I finally completed CDC and CDD emulation up to the point 
where CD image loading and data transfer are working fine ! Without any CD-DA 
track support for now off course...

There are obviously still some bugs in my code as there are still some 
graphical glitches and the two games I tried (Sonic CD and Shining FOrce) hangs 
on a black screen when starting a new game, but it's probably some stupid error 
that will soon be fixed.

Original comment by ekeeke31@gmail.com on 1 May 2012 at 9:07

Attachments:

GoogleCodeExporter commented 9 years ago
Thnaks for your work, next version is a big deal

Original comment by mrdeathj...@gmail.com on 2 May 2012 at 1:57

GoogleCodeExporter commented 9 years ago
Thank you :) the progress is very fast.... I hope you solve the problems with 
google code, I've read about them on other forum.I agree with you and your 
wishes. Googlecode's administrators are a bit squareheads but they enabled the 
project again..... 

Original comment by ferran...@hotmail.com on 3 May 2012 at 9:04

GoogleCodeExporter commented 9 years ago
I fixed another stupid bug with CD buffer writes. Interestingly, it seems that 
Gens/Picodrive are cheating with the CD buffer size by increasing it to 64k 
when it's only 16k in reality, so buffer overrun never occurs. On real 
hardware, once the limit is reached, data coming from CD drive is written to 
the beginning of the buffer.

Anyway, I think I reached the point where games are running fine and everything 
important is emulated. Graphics remaining bug are now fixed and games do not 
hangs anymore, which is good :-)

I thought I should list here all the things that needed to be emulated as many 
people think that Mega CD is, well, just a CD. This might be interesting to a 
few people.

SUB-CPU: an additional 68000 CPU, similar to the one used in Mega Drive 
hardware but running slightly faster, at 12.5 Mhz

Backup RAM: 8k of battery RAM used to store game data, accessible only from 
SUB-CPU

Cartridge RAM: up to 512K of battery RAM used to store game data, accessible 
only from cartridge port by MAIN-CPU

Work RAM: 512K Prg-RAM which is used to hold SUB-CPU side program and data. 
Mega Drive MAIN CPU can access this RAM using banks-witching, for example, in 
order to copy SUB-CPU program & data on startup. There is also 2 banks of 128K 
Word-RAM  which can either be split to each CPU side or assigned entirely (256K 
total) to one CPU or another, depending on the mode. This is generally used to 
make graphics data from the CD or from the Graphics Chip available to the MAIN 
CPU side, since only Mega Drive VDP can display stuff. But this can also be 
used to run code for any of the two CPUs.

Graphics Chip: Mega CD ASIC can perform rotation & scaling operations in its 
Word-RAM when configured to full size mode. From a source screen map in memory, 
the chip transform graphics and make them available in Mega Drive sprite 
format, so they can be displayed by Mega Drive VDP. It is fully configurable 
through a set of internal registers.

PCM Chip: this is a configurable sound chip which is able to render up to 8 
stereo channels of PCM data. The chip includes 64k of external RAM for storing 
waveform data and a set of registers to configure panning, volume, output 
frequency, etc...

CDD: this is CD Drive processor which receives command from SUB-CPU BIOS, such 
as reading TOC, open tray, start playing a track, pause, etc. The chip 
understands a limited set of commands, from which all are not documented 
completely but the most important are known. When an audio track is played, it 
is sent to CD DAC & Fader unit at the rate of 44100hz. When a data track is 
played, it is sent to CDC unit for error correction and transfer to the SUB-CPU.

CDC: this is CD Data Controller, which performs decoding of data received from 
CDD, error correction and data blocks transfer to the host, which is SUB-CPU 
side. It uses 16k of external RAM buffer to store CD data blocks (2352 
bytes/blocks) and is able to read a new block each 1/75s (CD drive speed is 
1x). It can be configured by BIOS through a large set of internal registers, is 
able to interrupt SUB-CPU in order to signal a new incoming data block or end 
of data transfer.

ASIC registers: approximately 256 16-bit registers which are used to configure 
each part of Sega CD hardware, interrupts, timers, memory mode, etc and 
communicate with other controllers, including communication between the two 
CPUs . They all needed to be emulated in order to get past the BIOS.

Original comment by ekeeke31@gmail.com on 3 May 2012 at 9:46

Attachments:

GoogleCodeExporter commented 9 years ago
I am speechless!I could not imagine in my wildest dreams that you could 
actually finish a fully working Sega CD emulator in such a little time!I am 
impressed for your unparallel skills and talent!Any idea when you will let us 
try it? :-)

Original comment by pantasda...@gmail.com on 4 May 2012 at 8:06

GoogleCodeExporter commented 9 years ago
To be fair, it would not have been possible without the technical documentation 
which has been made available by other people and that i've studied quite a lot 
in my spare time during last years, in order to think about possible 
implementations before actually coding them. Picodrive sourcecode (which is 
more or less a rewrite of Gens SCD implementation in more readable C language) 
helped a lot also when trying to figure bugs in my initial implementation. I 
wish i still had my Mega CD to run some test on real hardware as there are 
still a lot of undocumented stuff...

As for a release, I want to test more games before backporting this to Wii as 
i'm sure there are still bugs left and that I did not cover all possible test 
cases or emulated features.
For convenience, I've only tested win32 port right now but i'm pretty confident 
it will run fine on Wii, regarding the relatively limited speed loss (~10%) 
that can be observed in fps when scd is fully emulated.

Original comment by ekeeke31@gmail.com on 4 May 2012 at 10:44

GoogleCodeExporter commented 9 years ago
Congratulations!
It is nice to hear all these detailed things about the development progress.I 
suspect that the hard part of your work is nearly done,as porting to Wii and 
ironing some bugs would be far easier in this phase of your work compared to 
what you have already accomplished!
I want to ask you if the Sega CD BIOS would be required in order to run the 
isos or not.

Original comment by pantasda...@gmail.com on 4 May 2012 at 4:43

GoogleCodeExporter commented 9 years ago
Off course it is required, CD games cannot run without the BIOS, it's vital 
part of the system since games generally don't know how to use hardware at 
low-level and need to call hard-coded BIOS subroutines.

Original comment by ekeeke31@gmail.com on 4 May 2012 at 8:02

GoogleCodeExporter commented 9 years ago
I managed to get one the few Mega CD game I liked to work, which is Popful Mail.
As seen in screenshots, there is still a graphic glitch in the menu screen 
which I have to find the cause of but the game plays fine (and it's one of the 
few that does not use CD audio tracks or quite)

For the record, this is one of the several games that need "perfect" 
synchronization between MAIN-CPU and SUB-CPU to boot. Mega CD emulators 
generally made "perfect sync" optional as it eats up a lot of resources 
(basically they make each CPU run a few cycles simultaneously to keep them "in 
sync") but I think I found a better solution: the "sync" issue comes from the 
fact that the slowest CPU (i.e MAIN CPU) is writing two consecutive values in 
the communication buffers and expect the SUB-CPU to read the first written 
value before the second one is written. Since emulators generally don't run at 
a cycle-based granularity level but more like a line-based one, at the time you 
start running the next chunk of SUB-CPU instructions, the two writes have 
always been executed by MAIN-CPU and you end up in a dead-lock (i.e the two 
CPUs waiting for each other to write something in communication buffers to 
continue).

What I did, instead of having both CPU always running at a lower granularity 
level, was to keep a set of flags (one for each communication words between 
MAIN and SUB CPU), flags that are set each time MAIN-CPU writes a value to 
communication buffer and cleared each time SUB-CPU read it. This way, when 
MAIN-CPU attempts to write communication buffer, if it appears SUB-CPU still 
not has read the previously written value, i know i need to resynchronize both 
CPU and run SUB-CPU for a few cycles.

Good thing is this works fine for this game and a few others I've tried and 
this has barely any performance hits.

Original comment by ekeeke31@gmail.com on 5 May 2012 at 3:59

Attachments:

GoogleCodeExporter commented 9 years ago
This is pretty freakin amazing! 
I salute you ekeeke! Your knowledge of the inner machinations of the Genesis 
and Sega CD’s hardware is unprecedented! 
This was literally one of the only things I felt the Wii was missing and I'm 
glad you’re the one sailing its ship!  

Original comment by TheRealB...@gmail.com on 5 May 2012 at 4:39

GoogleCodeExporter commented 9 years ago
Thanks ekeeke! Very impressive work, as always. 

Original comment by thiagoalvesdealmeida@gmail.com on 6 May 2012 at 4:15

GoogleCodeExporter commented 9 years ago
Fixed a few bugs with VDP DMA from Word-RAM that were the causes of graphics 
corruption in Popful Mail and also Sonic CD FMV.

I also fixed a bug in graphics operation on 32x32 pixels stamp, clouds in Sonic 
CD title screen are now properly displayed.

Since those games now appear to run fine, I tried a few other and next one to 
fix appears to be Snatcher. It hangs when the game start for an unknown reason.

http://genplus-gx.googlecode.com/files/scd_sonic_title_good.png
http://genplus-gx.googlecode.com/files/scd_wonderdog_title.png
http://genplus-gx.googlecode.com/files/scd_wonderdog_ingame.png
http://genplus-gx.googlecode.com/files/scd_snatcher_title.png

Original comment by ekeeke31@gmail.com on 6 May 2012 at 2:00

GoogleCodeExporter commented 9 years ago
Your work with emulators is awesome. Only a week or so and a near perfect SCD 
emulator. You sure are gr8 ekeeke!

Original comment by cheatfreak47 on 6 May 2012 at 11:16