Experiments in emulator porting.

The place to share and discuss your Ultibo projects.
NoshBar
Posts: 20
Joined: Thu Mar 23, 2017 8:58 pm
Location: Stockholm
Contact:

Experiments in emulator porting.

Postby NoshBar » Fri Aug 31, 2018 9:56 pm

Hello!

So I have a weekend between jobs, meaning I'm lawyer-free for 72 hours and don't need to fill out any conflict-of-interest forms.
As such, I finally have time and freedom to experiment with Ultibo.

I found a ColecoVision in a bin a few years back, but it was beyond repair.
So I thought I'd use a Raspberry Pi in the case, and use the ColEm emulator to make it act like a real ColecoVision.

But the long boot time of Linux has always bugged me for specific-purpose emulators like this.

So tonight I gave it a shot, went looking for C-based emulators, using SDL (easy to search for, easy to replace).
I replaced the SDL calls with my own Ultibo-equivilent forward-declarations, changed main() into an exported call, then linked the resulting lib in my Ultibo project, fulfilling all the required functions.

8086tiny is one I'd been eyeing for a while, and at ~760 lines, was super easier to port.
I've always loved DOS, too.
It ended up being a terrible port, because I messed up the key API, and I got the colour conversion wrong, and the screen scaling, and...
But it's not a very complete emulator, and was just to get me into it:
https://www.youtube.com/watch?v=TMNoba17FXc

After that, I wanted something more involved and gave Mini vMac a go:
https://www.youtube.com/watch?v=7l2lzfapa88
https://github.com/noshbar/minivmac_sdl2

With these under my belt, I'm starting to narrow down common code required in ports, and a mini-SDL.
So when I eventually get to ColEm, it should be a piece of cake.

I'm just having so much fun, THIS is the kind of coding I enjoy, thank you!
Gavinmc42
Posts: 1399
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: Experiments in emulator porting.

Postby Gavinmc42 » Sat Sep 01, 2018 1:35 am

Wonder what you could do with month off :o

I kept running across games that use SDL when I was looking at game engines etc.
Making a Ultibo equivalent SDL and with C linking baremetal games ;)
Wish I knew what I just said, this level of software stuff is still new to me :oops:

But I agree, Ultibo does make coding fun again.
User avatar
Ultibo
Site Admin
Posts: 2040
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: Experiments in emulator porting.

Postby Ultibo » Wed Sep 05, 2018 12:28 am

Finally found a moment to check out your videos, very nicely done and we'll really look forward to seeing more.

NoshBar wrote:I'm just having so much fun, THIS is the kind of coding I enjoy, thank you!

And thank you, now if we can just get enough people to see the possibilities we can turn this into something really amazing.
Ultibo.org | Make something amazing
https://ultibo.org
pik33
Posts: 769
Joined: Fri Sep 30, 2016 6:30 pm
Location: Poland
Contact:

Re: Experiments in emulator porting.

Postby pik33 » Fri Sep 07, 2018 9:14 am

Forked :) To be tested :)

Beautiful work.
blueicaro
Posts: 23
Joined: Sun Nov 19, 2017 11:13 am
Location: Spain
Contact:

Re: Experiments in emulator porting.

Postby blueicaro » Sun Sep 09, 2018 10:23 am

:o
Great job!
/BlueIcaro
http://wiki.teisrobotics.org
pik33
Posts: 769
Joined: Fri Sep 30, 2016 6:30 pm
Location: Poland
Contact:

Re: Experiments in emulator porting.

Postby pik33 » Tue Sep 11, 2018 6:36 am

8086tiny worked until I tried to run Alleycat. The Alleycat displayed its title screen and then the screen went blank.

The 8086tiny is tiny :) so I will try to get rid of C code by translating it to Pascal. This is also the best way to learn how it is done.
NoshBar
Posts: 20
Joined: Thu Mar 23, 2017 8:58 pm
Location: Stockholm
Contact:

Re: Experiments in emulator porting.

Postby NoshBar » Wed Sep 12, 2018 7:44 pm

Thanks for the encouraging words, everyone!

pik, the problem with Alleycat is that it's asking you if you want to use (k)eyboard/(j)oystick, and what difficulty you want, (k)itten/(a)lleycat, etc.

Now the problem is that I didn't have time to add support for graphical fonts, so it's simply printing them in text "behind" the framebuffer.
If you stab "k" a few times and push enter, you'll get in game.
But then arrow keys won't work.

Like I said, I just wanted to test my theory about "porting" emulators.

If you ARE going to translate 8086tiny to Pascal (which I got around ~80% through myself before doing this), then check out some of the forks from the GitHub page.
One or two of them have added better compatibility and run things like Prince of Persia just fine, with EGA support, that kind of thing.

I just opened every single fork on the GitHub page and looked for the most commits ahead... but then I decided to just port the basics.

Good luck, and have fun!

EDIT: P.S. my new job have far fewer sticks up places, and I've got permission to work on this stuff.
So I actually ported a much better emulator this past weekend, but haven't had time to clean it up yet.
More coming soon...
NoshBar
Posts: 20
Joined: Thu Mar 23, 2017 8:58 pm
Location: Stockholm
Contact:

Re: Experiments in emulator porting.

Postby NoshBar » Wed Sep 19, 2018 7:59 pm

Alrighty, so I tackled the PCEmulator next.

The nice part is that once I get my head around how it all works, I get a few emulators for the price of one (Atari ST, Mac Plus,IBM PC), although I focused only on IBM PC for now.
https://github.com/noshbar/Ultibo-PCE

pik, this is definitely more worth putting time into than 8086tiny, I think.

Instead of me saying, "this was another rush job", maybe always assume I hack things together.

There's some horrible flickering when in console mode.
But this only happens when I change framebuffer pages. If I leave CurrentPage=0, then it's fine, so will need to look at that.

There's terrible stuttering.
I was wondering if this was emulator side, or perhaps from the framebuffer and syncing, but haven't narrowed it down yet.

The palette is messed up, but should be an easy fix.

Anyway, it's interesting trying these different emulators, I hadn't even heard of this one until I started looking for C-only emulators.
PCEm looks very interesting too, and I got quite far with converting it, but it's a messy one... and that's ME thinking it's messy...
Gavinmc42
Posts: 1399
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: Experiments in emulator porting.

Postby Gavinmc42 » Thu Sep 20, 2018 2:00 am

Noshbar, if that's what you call hacking things together, please do more :D
pik33
Posts: 769
Joined: Fri Sep 30, 2016 6:30 pm
Location: Poland
Contact:

Re: Experiments in emulator porting.

Postby pik33 » Thu Sep 20, 2018 8:42 am

NoshBar wrote:
There's terrible stuttering.
I was wondering if this was emulator side, or perhaps from the framebuffer and syncing, but haven't narrowed it down yet.

The palette is messed up, but should be an easy fix.



The first thing I will do with it while having some free time for the project is running it in the my Retromachine environment. I have vbl synchronized 8-bit framebuffer with sprites and pallette registers. I have also graphics functions type putpixel, box, line, circle, putchar and outtextxy - the latest can put a string on the screen starting at x,y using 8x16 bitmap font resized by x,y. I use an Atari ST mono font for it but I have PC DOS font definition too, so I can use it for a DOS screen.This environment should be suitable to put the tiny PC in it... maybe even in a window

You can find the framebuffer stuff in Retromalina unit here https://github.com/pik33/ultibo_retro_gui

There are also a 6502 emulator (Pascal! I translated this from C) and a Commodore SID emulator (my own stuff in asm) there

NOw, THIS is a bunch of messy code :)

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 0 guests