SMS Power!

Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats
Music - Videos - Development - Translations - Homebrew
Sega8bit & SMS Power! 2013 Event - 10th August

View topic - new sms emulator: twoMbit

Reply to topic
Author Message
  • Joined: 05 Jun 2011
  • Posts: 36
Reply with quote
new sms emulator: twoMbit
Post Posted: Sun Nov 20, 2011 9:24 pm
I woud like to go public with my cycle accurate, open source SMS emulator TwoMbit.

TwoMbit is affected by bsnes and uses the libco threading module. One thread for each core.
The Gui is programmed in C# / WPF (compiled for .Net 4.0). The emulation core is a unmanaged c++ dll. I am using directx only, so the core depends on Windows.

The cpu can sync each Master to the vdp or apu, of course if it's needed only. for example before register writes.
The vdp can sync to the cpu each 2 Master.
The emulator itsself is not very speed optimized at time but I think the code readability is good.

What is emulated?
- bus hold times
- interrupt recognition one cpu cycle before opcode edge.
- sprite preprocessing during active display
- background display generation is parted and timed in name, color and pattern address select and ram load
- VDP delay
- cpu access window for active display
- emulating port 3e, can load bios or combine bios with game
- switchable between SMS 1 and 2

What is missing
- Lightgun support (input is already configurable in GUI)
- savestate support
- cheat support

- SG-1000, SC-3000 emulation (vdp mode 0 and 2 are already supported)
- game gear emulation
- additional yamaha sound chip

I would like to thank following people and groups:

- blargg for his blip_buffer and ntsc filter
- byuu for bsnes, which has inspired me
- Charles MacDonald for his docs and infos
- the people from smspower.org for the countless usefull discussions about the hardware

you can find the sources and a 32 or 64 bit binary at sourceforge
http://sourceforge.net/projects/twombit/
  View user's profile Send private message
  • Joined: 14 Oct 2006
  • Posts: 156
  • Location: US
Reply with quote
Post Posted: Sun Nov 20, 2011 9:30 pm
aww yeeeee, i love new emulators of my favorite consoles. i'll have to check it out, maybe it'll inspire me to work on vbsms+ some more.

downloadin' now.
  View user's profile Send private message Visit poster's website
  • Joined: 06 Feb 2009
  • Posts: 82
  • Location: Toulouse, France
Reply with quote
Post Posted: Mon Nov 21, 2011 9:29 pm
Sweet project, using threads should definitively make things closer to how hardware parts are really running, which is nice.

However, from reading the code, I would say there is room for improvement (which is normal off course): some implementation choices are very dispatched/complex and most likely very far from how hardware is working internally, making the whole thing quite difficult to follow. It sometime feels like as if you started with a good idea (make the design simple & logic) but it ended utterly complicated because you kept adding new stuff to get things working. I don't know if I'm very clear but that's how i feel :-)

I think you should also take care of commenting your code, this kind of project is generally much more interesting for hardware documentation, but code only is not very readable by humans (yes, we all think good & simple code is readable, but from an external point of view, it's rarely the case), so please, comment it :-)

Otherwise, I like the overall object-oriented design and the (really !) insane granularity.
  View user's profile Send private message
  • Joined: 28 Sep 1999
  • Posts: 1012
Reply with quote
Post Posted: Tue Nov 22, 2011 3:30 am
PiCiJi wrote
I woud like to go public with my cycle accurate, open source SMS emulator TwoMbit.


Great work! I'm glad we finally have an emulator that takes accuracy seriously. Thanks for sharing TwoMbit with the rest of us. :)
  View user's profile Send private message Visit poster's website
  • Joined: 04 Nov 2011
  • Posts: 74
  • Location: Scotland
Reply with quote
Post Posted: Tue Nov 22, 2011 11:23 am
I just tried it and unfortunately I can't get it to load a game. The emu loads up fine but when I choose a game to load it crashes with a C++ runtime error (program asked to close in an unusual way).

EDIT: Forgot to say I'm using Win XP SP3 on a dual core (T5600) laptop.
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 8982
  • Location: London
Reply with quote
Post Posted: Tue Nov 22, 2011 12:04 pm
All I ever get is:

Quote
---------------------------
Error
---------------------------
Sega Master System Emulation Core is missing, make sure the SmsCore.dll is in the same path as your application
---------------------------
OK
---------------------------

...when it is there.
  View user's profile Send private message Visit poster's website
  • Joined: 05 Jun 2011
  • Posts: 36
Reply with quote
Post Posted: Tue Nov 22, 2011 2:27 pm
Quote
Sega Master System Emulation Core is missing, make sure the SmsCore.dll is in the same path as your application


I had the problem on my old XP machine too. A program called Dependency Walker find out that a directx dll was missing. I have updated directx and it works.
For programming I have used the latest directx SDK from June 2010.

Quote
I just tried it and unfortunately I can't get it to load a game. The emu loads up fine but when I choose a game to load it crashes with a C++ runtime error (program asked to close in an unusual way).


hmm...hard to find out whats going wrong here. What OS you are using? You are using the 32 or 64 bit version of TwoMbit ? Maybe a directx update can solve the problem.
Are you trying to load a compressed file? If so, could you please try to load a uncompressed one.
  View user's profile Send private message
  • Joined: 04 Nov 2011
  • Posts: 74
  • Location: Scotland
Reply with quote
Post Posted: Tue Nov 22, 2011 3:04 pm
I'm using 32 bit Win XP SP3 fully updated. My Direct X is up to date too. I was also using uncompressed ROMs (all (!) versions - good dumps).

I used th 32bit version of your emu. :)
  View user's profile Send private message
  • Joined: 05 Jun 2011
  • Posts: 36
Reply with quote
Post Posted: Tue Nov 22, 2011 4:22 pm
Quote
My Direct X is up to date too.


directx 9.0c? After the update the version doesn't change. So are you sure you have the latest update ?

If you have the time, you could use Dependency Walker and load the SmsCore.dll
Then send me the red marked entries.

http://www.dependencywalker.com/
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 8982
  • Location: London
Reply with quote
Post Posted: Tue Nov 22, 2011 5:15 pm
On this machine, it's missing D3DX9_43.DLL which is from the Feb 2010 DirectX refresh. I guess you need at least that version, but this is my work PC so I can't just install it :)
  View user's profile Send private message Visit poster's website
  • Joined: 04 Nov 2011
  • Posts: 74
  • Location: Scotland
Reply with quote
Post Posted: Tue Nov 22, 2011 6:17 pm
No problem. I used Dependancy Walker and have attached the dwi file. Hope this helps.

I also decided to re-install the latest version of DX just in case but the web installer said I was up to date. :)
SmsCore.zip (626.7 KB)
DWI File

  View user's profile Send private message
  • Joined: 05 Jun 2011
  • Posts: 36
Reply with quote
Post Posted: Tue Nov 22, 2011 8:00 pm
Quote
On this machine, it's missing D3DX9_43.DLL which is from the Feb 2010 DirectX refresh. I guess you need at least that version, but this is my work PC so I can't just install it :)


Yes this dll was missing before updating directx.
Maybe an older directx SDK is a better choice. I will definitely throw better error messages, so the user find out what to do.

Quote
No problem. I used Dependancy Walker and have attached the dwi file. Hope this helps.


there is nothing wrong. It have to be some other problem. Are you able to configure the input (config / input) without crash?
  View user's profile Send private message
  • Joined: 04 Nov 2011
  • Posts: 74
  • Location: Scotland
Reply with quote
Post Posted: Tue Nov 22, 2011 8:31 pm
Yeah, I can configure anything. All seems to work fine though it's kinda hard to tell sometimes with no 'Apply' button. It just crashes when I load any game.
  View user's profile Send private message
  • Joined: 05 Jun 2011
  • Posts: 36
Reply with quote
Post Posted: Tue Nov 22, 2011 9:14 pm
Quote
some implementation choices are very dispatched/complex and most likely very far from how hardware is working internally


I am trying to see it more the way, what options has the software under a given hardware, no matter how it works internally. How could software find out it runs on a emulated system?

Quote
Yeah, I can configure anything. All seems to work fine though it's kinda hard to tell sometimes with no 'Apply' button. It just crashes when I load any game.


Sorry, at the moment I don't have an idea whats going wrong.
  View user's profile Send private message
  • Joined: 25 Jul 2007
  • Posts: 512
  • Location: Melbourne, Australia
Reply with quote
Post Posted: Wed Nov 23, 2011 9:55 am
Worked fine on my Windows 7 machine once I d/l .net 4 framework and latest DX.
  View user's profile Send private message
  • Joined: 08 Nov 2011
  • Posts: 67
  • Location: United Kingdom
Reply with quote
Good stuff :-)
Post Posted: Mon Dec 12, 2011 10:56 am
Always nice to see another new emulator - shall try this out tonight when I get home from work. I'm working on an SMS emulator of my own at the moment, but not striving for cycle-accuracy, as it is the first emulation project I've ever tried my hands at :-p

In your experience, how difficult was it to emulate everything to this degree of granularity? I've not looked at your source code yet, but I'm assuming as it's cycle-accurate it runs at the granularity of a machine click? To keep things simpler my Z80 core is only granular at the opcode level. Anyhow, good work, and this design interests me for future projects, I've done a great deal of reading on bsnes, and I agree it is inspiring :-)
  View user's profile Send private message
  • Joined: 27 Nov 2011
  • Posts: 20
Reply with quote
Post Posted: Tue Dec 13, 2011 12:30 pm
nothing beats my master system though
  View user's profile Send private message
  • Joined: 05 Jun 2011
  • Posts: 36
Reply with quote
Post Posted: Wed Dec 14, 2011 5:52 pm
Quote
how difficult was it to emulate everything to this degree of granularity?


with the threading library libco it's not much harder than an opcode based emulator to program. The challenge is to find out what is done each cycle, not to sync between the emulated processors.

Quote
I've done a great deal of reading on bsnes, and I agree it is inspiring :-)
same for me, I am reading bsnes for years.

At time I am leaving C# and Visual Studio in general. I give QT and gcc a try to get platform independence.
  View user's profile Send private message
  • Joined: 08 Nov 2011
  • Posts: 67
  • Location: United Kingdom
Reply with quote
Cool :-)
Post Posted: Wed Dec 14, 2011 9:13 pm
Good news for me as a Linux user then ;-) I'm using Java + Swing/Java2D for mine - nowhere near as quick as Qt, but quicker than people give it credit for and plenty fast enough for this :-)
  View user's profile Send private message
  • Joined: 05 Jun 2011
  • Posts: 36
Reply with quote
update
Post Posted: Sat Mar 31, 2012 12:20 pm
v 1.0 beta -> v 1.0.1
[general]
- switched to gcc for compiler
- switched to QT 4.8 for Gui ( c# / .net is no more )
- build libsms (a cross-platform emulation library, so someone could build a gui without having to know the sms internals )

[emulation]
- gamegear emulation
- sg-1000 emulation
- emulating additional cart work ram (Ernie Els Golf, the castle, Othello)
- emulating bus contention
- emulating game gear bios
- emulating custom sram sizes (Shining force)
- emulating eeprom of the baseball series games
- emulating lightpahser, paddle (japanese and export), sportspad (japanese and export), 3d glasses, Terebi Oekaki
- emulating gear-2-gear at cycle level
- parallel communication (Squinky Tennis in micro machines, Primal Rage, ...)
- serial communication
- different baud rate settings
- emulating backward compatibillity of gamegear(mastergear) and sms
- emulating yamaha2413
- fex(zip, 7z, rar, gzip), bzip2, untar for compressed roms

https://sourceforge.net/projects/twombit/

[bugfixes]
- removed cache for irq detection, now irqs will be detected one cpu cycle before opcode edge ( simplified the overall process)
- fixed sample playback
- differentiate between sg and sms/gg vdp delay and access window behavior.

to do:

feature doings
- cheats
- savestates
- replace directx to make TwoMbit platform independant

accuracy doings
- sn76489: writing to regs will not processed without delay
- vdp: accurate access windows during sprite processing
- vdp: split sprite subprocessing in timed steps (like bg processing) and not one sprite at a time
- yamaha2413: sub sample accuracy
  View user's profile Send private message
Reply to topic



Back to the top of this page

Back to SMS Power!