welshy
Posts: 1667
Joined: Mon Oct 29, 2012 2:07 pm

Re: Emulation on the Raspberry Pi (Updated 01/12/2013)

Fri Dec 20, 2013 7:24 am

hskaratekid
That's a tough question to answer simply! How proficient is your programming? It would have to be written it in a lower level language like C (Python isn't going to cut it!) and you would be looking at including modules such as a CPU simulator (many of these already exist and are incorporated into PiMAME4ALL for instance See Here - http://code.google.com/p/mame4all-pi/) and I/O simulators, looking at existing emulator code may be a good place to start. Which machine/system were you looking at writing an emulator for specifically?
"The list of things I have heard now contains everything!"

ric_rpi
Posts: 206
Joined: Thu Jul 11, 2013 2:33 pm
Location: Bedford, UK

Re: Emulation on the Raspberry Pi (Updated 01/12/2013)

Fri Dec 20, 2013 10:31 am

hskaratekid

It is a mammoth task to do and is very dependant on the target system you wish to emulate.

I would suggest you read up on High Level Emulation as a starting point. You may (or may not) already know this but the following functionality would need to be built into most, if not all, emulators:
  • Interrupts
  • DMA (usually implemented in s/w as opposed to using host platforms h/w - better for portability/permissions)
  • unusual h/w features - N64 has one w.r.t branching and executing instruction after branch
  • bootloading/startup
  • FLASH, EEPROM or 'Memory packs/cards'
  • target system instruction Interpreter/ dynamic re-compiler
  • The target SDK libraries
  • The OS, if one exists and you don't want to or can't emulate the original (e.g. PlayStation BIOS)

Other things to consider
  • Endianness of host and target platforms
  • Available host system hardware e.g. GLES2
  • Can the host system do Page File execution (required for dynamic recompiling)
  • How to handle a target system with multiple CPU/GPUs and their synchronization
  • Use of plug-ins (e.g. video, audio, input, front-end, ...) or standalone program
  • Optimizations are done for the target system but these may not be appropriate for the host. e.g. PS2 only has 4MB for GPU but it can do fast texture loading. One could try to reverse that optimization (and cache textures for longer) to increase performance on the host.
The largest hurdle is that you can't test very much until the majority of the system has been coded up. If you can get hold of a compiler for the target then you could experiment with some very basic programs first.

You would also need to decide how portable you want the emulator to be. You could use SDL with some custom OS specific code for full portability between windows or linux. Or you could decide to target very specifically e.g. the Raspberry Pi running Raspian to squeeze more performance though better optimization.

The general rule of thumb for emulation is the host system should be >10x faster than the target. With host specific optimizations one should be able to get away with ~7-8x. I wonder though if an emulator coded for an embedded system largely in assembler could get away with 4x...

What system did you want to emulate?

User avatar
DougieLawson
Posts: 32687
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Emulation on the Raspberry Pi (Updated 20/12/2013)

Sat Dec 21, 2013 9:43 am

A good example of doing all of that stuff is Hercules the S/360 emulator.

Big endian.
Emulated disks.
Timers.
Interrupts.
Strange instructions like SIE.
Strange operating system - MVS 3.8
etc.

The whole shebang.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

cacophony555
Posts: 140
Joined: Sat Jan 18, 2014 5:54 pm

Re: Emulation on the Raspberry Pi (Updated 09/01/2014)

Sat Jan 18, 2014 6:07 pm

Great thread and it's been very helpful. I started with the Retropie bundle, but am slowly trying to replace individual emulators with the best versions. I can't believe how much faster Pudding's PiMame4All is than the RetroArch version that was bundled with RetroPie! I had a little bit of difficulty integrating it with emulationstation, though, because it doesn't like full rom paths. Instead you of "./mame /home/pi/blah/blah/pacman.zip" you need to say "./mame pacman". I ended up writing a 2 line bash script that did the argument conversion on the fly when a selection occurred in emulationstation. Seems to work well, though I wonder if there's an easier way.

I've also replaced the nes emulator with Andrey's Fceux, but I can't figure out how to quit without using a keyboard. Any way to assign controller keys to quit?

I plan on looking at Pudding's PiSNES next, so any advice on configuring the controller would be helpful.

welshy
Posts: 1667
Joined: Mon Oct 29, 2012 2:07 pm

Re: Emulation on the Raspberry Pi (Updated 09/01/2014)

Sat Jan 18, 2014 8:19 pm

cacophony555
Welcome to the Forum! Thank you for the endorsement of the Thread!

'I started with the Retropie bundle, but am slowly trying to replace individual emulators with the best versions'
That's definitely the way to go, RetroArch is a great all rounder but many systems can be emulated better in Binaries that have appeared recently that are 'Optimised' especially for the RPi. As well as PiSNES (which is better than either RetroArch Core available) puddings PiFBA is also superior to the RA Core.

'Instead you of "./mame /home/pi/blah/blah/pacman.zip" you need to say "./mame pacman'
That's because it a not a RetroArch Core and running MAME from a command line would be -
./mame (run executable) then the code for the game title WITHOUT the file extension, i.e

./mame dkong
NOT
./mame dkong.zip

'I've also replaced the nes emulator with Andrey's Fceux, but I can't figure out how to quit without using a keyboard'
I'm not sure about exit but I did write up an explanation on how to configure a joypad
Here - http://www.raspberrypi.org/forums/viewt ... ux#p406208

'I plan on looking at Pudding's PiSNES next, so any advice on configuring the controller would be helpful'

It should work independently of RetroPie (it has its own config file) button settings can be changed from there if required.
"The list of things I have heard now contains everything!"

StrawberryDorbs
Posts: 13
Joined: Sun Jan 19, 2014 8:00 pm

Re: Emulation on the Raspberry Pi (Updated 23/01/2014)

Thu Feb 06, 2014 9:37 am

Does anyone have a list of compatible games with pisnes? I've tried a few now with no joy -

Super Mario World
Super Mario Kart
Alladin
Street Fighter Alpha

I can open pisnes fine, but when it comes to loading the games when i press enter the screen flashes black then comes back to the menu and does nothing.

welshy
Posts: 1667
Joined: Mon Oct 29, 2012 2:07 pm

Re: Emulation on the Raspberry Pi (Updated 23/01/2014)

Thu Feb 06, 2014 1:34 pm

StrawberryDorbs
They should all work fine, I haven't found much it doesn't emulate excluding SuperFX powered Titles and certain Acceleration Chips (if by Street Fighter Alpha you mean Street Fighter Alpha 2 this would be one as it included an S-DD1 AC which many emulators cannot replicate). What format are the ROMS in, compressed .zip/.rar/.7z or uncompressed .smc/.sfc?. Perhaps the ROM files you have are bad dumps/corrupted, try another Website to source them.
"The list of things I have heard now contains everything!"

StrawberryDorbs
Posts: 13
Joined: Sun Jan 19, 2014 8:00 pm

Re: Emulation on the Raspberry Pi (Updated 23/01/2014)

Thu Feb 06, 2014 5:06 pm

I've tried both, .smc and also zipped .smc. I've got them from a reputable website that i've used for other roms without failure before.

I've tried with overclocking turned off and on, without success.

welshy
Posts: 1667
Joined: Mon Oct 29, 2012 2:07 pm

Re: Emulation on the Raspberry Pi (Updated 23/01/2014)

Thu Feb 06, 2014 5:13 pm

StrawberryDorbs
Are you running the Command Line (snes9x) or GUI (snes9x.gui) version?
"The list of things I have heard now contains everything!"


welshy
Posts: 1667
Joined: Mon Oct 29, 2012 2:07 pm

Re: Emulation on the Raspberry Pi (Updated 23/01/2014)

Thu Feb 06, 2014 5:53 pm

StrawberryDorbs
I have found the GUI causes some issues with certain monitors. Try the Command Line version to see if this is causing the problem (don't forget, Linux doesn't like spaces in the file name so remove them e.g. change mario kart.zip to mariokart.zip).
"The list of things I have heard now contains everything!"

StrawberryDorbs
Posts: 13
Joined: Sun Jan 19, 2014 8:00 pm

Re: Emulation on the Raspberry Pi (Updated 23/01/2014)

Thu Feb 06, 2014 5:55 pm

Ok, I tried from the command line and got this error when trying to play a game -

snes9x: unix/graphics.cpp:266: void S9xInitDisplay(int): Assertion 'surface != (EGLSurface)0)' failed. Aborted.

cacophony555
Posts: 140
Joined: Sat Jan 18, 2014 5:54 pm

Re: Emulation on the Raspberry Pi (Updated 23/01/2014)

Thu Feb 06, 2014 6:00 pm

What memory split are you using?

StrawberryDorbs
Posts: 13
Joined: Sun Jan 19, 2014 8:00 pm

Re: Emulation on the Raspberry Pi (Updated 23/01/2014)

Thu Feb 06, 2014 6:04 pm

It was just on 16, I tried upping it to 128 and rebooted and now my mouse doesn't work!

welshy
Posts: 1667
Joined: Mon Oct 29, 2012 2:07 pm

Re: Emulation on the Raspberry Pi (Updated 23/01/2014)

Thu Feb 06, 2014 6:05 pm

cacophony555 wrote:What memory split are you using?
Yup, that was my next suggestion! lol you need at least 64MEG applied to the GPU.
"The list of things I have heard now contains everything!"

StrawberryDorbs
Posts: 13
Joined: Sun Jan 19, 2014 8:00 pm

Re: Emulation on the Raspberry Pi (Updated 23/01/2014)

Thu Feb 06, 2014 6:09 pm

Ah, sorted! i'm on a 64 split now.

User avatar
mrpi64
Posts: 931
Joined: Sat Feb 16, 2013 5:13 pm

Re: Emulation on the Raspberry Pi (Updated 16/10/2013)

Mon Feb 10, 2014 8:40 am

welshy wrote:mrpi64
The keyboard 'Maps' to the keys in the Config file for the individual emulators. Changing the SDL code alters the Map for a specific Key, the Codes are listed

Here - http://forum.fobby.net/index.php?t=msg&th=7&start=0& (Approx 1/2 way down the page)

i.e if a Key is mapped to code 122 (z on the Keyboard), changing to 120 it's then x
ACII codes.

Anyway, I installed DOSBox through apt-get, and it runs things like Doom 2 and MFS3.0 slowly while in XWindows. Is this normal, when it's meant to be emulating a 5-10mhz computer? Also, out of XWindows (AKA - in the text console), it registers the key presses wrongly - 'J' is 'Return', 'F1' makes it freeze, ETC. How do I fix the keyboard problem? Cave Story runs fine as a DOS(ish) program in retropi, so why doesn't DOSBox run nice and smooth too? I have tried changing frameskip, CPU speed, ETC. Even my Android tablet (Quad core 1.5ghz proc, quad code Mali-400) won't run it at full speed? Is it DOSbox that is the problem?
I'm happy to help.
https://www.raspberrypi.org/forums/viewtopic.php?f=78&t=51794 - List of games that work on the Pi.

Vanfanel
Posts: 423
Joined: Sat Aug 18, 2012 5:58 pm

Re: Emulation on the Raspberry Pi (Updated 16/10/2013)

Mon Feb 10, 2014 9:11 am

mrpi64 wrote:
welshy wrote:mrpi64
The keyboard 'Maps' to the keys in the Config file for the individual emulators. Changing the SDL code alters the Map for a specific Key, the Codes are listed

Here - http://forum.fobby.net/index.php?t=msg&th=7&start=0& (Approx 1/2 way down the page)

i.e if a Key is mapped to code 122 (z on the Keyboard), changing to 120 it's then x
ACII codes.

Anyway, I installed DOSBox through apt-get, and it runs things like Doom 2 and MFS3.0 slowly while in XWindows. Is this normal, when it's meant to be emulating a 5-10mhz computer? Also, out of XWindows (AKA - in the text console), it registers the key presses wrongly - 'J' is 'Return', 'F1' makes it freeze, ETC. How do I fix the keyboard problem? Cave Story runs fine as a DOS(ish) program in retropi, so why doesn't DOSBox run nice and smooth too? I have tried changing frameskip, CPU speed, ETC. Even my Android tablet (Quad core 1.5ghz proc, quad code Mali-400) won't run it at full speed? Is it DOSbox that is the problem?
DOSBox is VERY cpu-demanding, and for emulating something able to run DOOM2 at a playable speed, you'll need a computer WAY more powerful than the Pi. Forget about DOXBox on the Pi.
DOOM2 ran fine on a 486@66Mhz computer: it was FAR from playable in a ~10Mhz IBM PC.

...But even so, if you insist on using it, you can set raw keycodes in the config file you're using. Keypresses are handled by SDL, not directly by DOSbox.
But do yourself a favor and use RpiX86 instead....

User avatar
mrpi64
Posts: 931
Joined: Sat Feb 16, 2013 5:13 pm

Re: Emulation on the Raspberry Pi (Updated 23/01/2014)

Mon Feb 10, 2014 2:04 pm

I tried 8086tiny - it froze. Might try Rpi86. Hang on - if <strike>I were to</strike> someone were to port a DOS operating system to the 700mhz Pi, and run DOOM2, it would work (probably). Anyway, tried using chocolate-pi, and it ran fine. At first it kept on crashing due to it "not supporting 320Xsomething" graphics, but then after some careful persuasion... ("WORK! WORK!!!!!!") it works! yay!
I'm happy to help.
https://www.raspberrypi.org/forums/viewtopic.php?f=78&t=51794 - List of games that work on the Pi.

User avatar
Jessie
Posts: 1754
Joined: Fri Nov 04, 2011 7:40 pm
Location: C/S CO USA

Re: Emulation on the Raspberry Pi (Updated 13/02/2014)

Thu Feb 13, 2014 5:21 pm

Rpix86 is the most useable x86 emulator atm. It is limited but it gets 486 66mhz level of performance.

I'm not sure what all the buzz over 8086tiny was about maybe I missed something, but it didn't seem front-page worthy.

welshy
Posts: 1667
Joined: Mon Oct 29, 2012 2:07 pm

Re: Emulation on the Raspberry Pi (Updated 13/02/2014)

Thu Feb 13, 2014 5:25 pm

Jessie wrote:I'm not sure what all the buzz over 8086tiny was about maybe I missed something, but it didn't seem front-page worthy.
Agreed, very odd...
"The list of things I have heard now contains everything!"

User avatar
mrpi64
Posts: 931
Joined: Sat Feb 16, 2013 5:13 pm

Re: Emulation on the Raspberry Pi (Updated 13/02/2014)

Fri Feb 14, 2014 1:16 pm

welshy wrote:
Jessie wrote:I'm not sure what all the buzz over 8086tiny was about maybe I missed something, but it didn't seem front-page worthy.
Agreed, very odd...
The fact that it is, well, literally a tiny program makes up for it. Also, it is still fully functional.
I'm happy to help.
https://www.raspberrypi.org/forums/viewtopic.php?f=78&t=51794 - List of games that work on the Pi.

mob-i-l
Posts: 210
Joined: Sat Dec 29, 2012 2:45 am
Location: Lund, Skåne/Scania, Sweden
Contact: Website Facebook Google+ Twitter YouTube

Re: Emulation on the Raspberry Pi (Updated 18/02/2014)

Thu Mar 06, 2014 12:02 pm

There is a new ZX81-emulator that can run in xterm in Raspbian if you get the new xterm and compile it with Sixel-graphics. (I think it would be good if the standard xterm in Raspbian had Sixel-graphics support built-in.)

Instructions on how to install the emulator in Raspbian on Raspberry Pi is here:
http://www.sinclairzxworld.com/viewtopic.php?f=3&t=1292
Raspberry Pi0&1A&1B2&1B+&2B&3B w/ Raspbian. Started w/ BASIC on ABC80&ZX81 then Forth, Z80… https://scratch.mit.edu/users/mobluse/ https://github.com/mobluse/ https://twitter.com/mobluse/ https://YouTube.com/MOBiL4u/

welshy
Posts: 1667
Joined: Mon Oct 29, 2012 2:07 pm

Re: Emulation on the Raspberry Pi (Updated 18/02/2014)

Thu Mar 06, 2014 4:34 pm

mob-i-l
Or you could just simply compile sz81 which emulates the ZX80 & ZX81!

Link - http://sz81.sourceforge.net/
"The list of things I have heard now contains everything!"

mob-i-l
Posts: 210
Joined: Sat Dec 29, 2012 2:45 am
Location: Lund, Skåne/Scania, Sweden
Contact: Website Facebook Google+ Twitter YouTube

Re: Emulation on the Raspberry Pi (Updated 18/02/2014)

Fri Mar 07, 2014 11:30 pm

welshy wrote:mob-i-l
Or you could just simply compile sz81 which emulates the ZX80 & ZX81!

Link - http://sz81.sourceforge.net/
I think zce is a useful emulator since it can also be used remote for e.g. adventure games and to run ZX81 BASIC-scripts like other Linux-script-languages such as Bash and Perl. It also seems to be in active development.

I first installed sz81 in 2012, see http://www.raspberrypi.org/phpBB3/viewt ... 42#p252342

Now I reinstalled it after installing Raspbian with NOOBS. I wrote down how I did this to help others getting started with ZX80- and ZX81-emulation. I had to do this before make of sz81:
sudo apt-get install libsdl1.2-dev

I could get ZonX sound to work in sz81!

I had to do this before make of xz81:
sudo apt-get install libsvga1-dev

Then I had to do this because there is something wrong with the Makefile.z81 or the source-files:
sudo ln -s /usr/local/lib/z81/zx80kybd.pbm /
sudo ln -s /usr/local/lib/z81/zx81kybd.pbm /
sudo ln -s /usr/local/share/sz81/zx80.rom /
sudo ln -s /usr/local/share/sz81/zx81.rom /

I couldn't get ZonX sound to work in xz81.
Raspberry Pi0&1A&1B2&1B+&2B&3B w/ Raspbian. Started w/ BASIC on ABC80&ZX81 then Forth, Z80… https://scratch.mit.edu/users/mobluse/ https://github.com/mobluse/ https://twitter.com/mobluse/ https://YouTube.com/MOBiL4u/

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 12 guests