Looking for DC optimization experts to help on emu port

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
miker00lz
DCEmu Cool Newbie
DCEmu Cool Newbie
Posts: 16
Joined: Sat Mar 02, 2013 7:47 pm
Has liked: 0
Been liked: 0

Re: Looking for DC optimization experts to help on emu port

Post by miker00lz » Wed Mar 13, 2013 7:22 pm

Great stuff, thanks for that! Yes, some video modes on the PC are interleaved. CGA graphics modes are, as well as EGA and some VGA modes. That's a really clever little hack with the packed pixel modes though. Good idea there.

I also got a small bost by using RGB565 for the video output. It also boosts 256-color emulation speeds just slightly because the MCGA/VGA 8-bit palette mode actual color values are stored in the VGA DAC as 5-bit values. I don't have to bitshift red and blue at all anymore.
miker00lz
DCEmu Cool Newbie
DCEmu Cool Newbie
Posts: 16
Joined: Sat Mar 02, 2013 7:47 pm
Has liked: 0
Been liked: 0

Re: Looking for DC optimization experts to help on emu port

Post by miker00lz » Sat Mar 16, 2013 12:36 am

I've been working on this more, and I'd like to share what I've got so far. Here's a self-boot CDI image that comes with a 50 MB MS-DOS disk image with a selection of very, very old games and apps (nothing from after 1991 or so).

http://rubbermallet.org/fake86-0.13.3.15-dreamcast.rar

It requires that you have a DC keyboard. There are some annoying bugs in my virtual keyboard stuff so I just decided to disable that for this demo version. It also uses the regular DC controller for mouse emulation. Use the analog stick to move a mouse cursor, and button A = left click, B = right click.

Still no sound, and it's still pretty slow. It's about on par with a turbo 8088 system. I did add code to generate the sound, but there's just not enough horsepower in that SH4 to do everything at the same time so it couldn't fill the sample buffer quick enough.

What I really want to do is completely get rid of CPU-wasting polls of the KOS microsecond timer which I'm using now for handling timing, and move over to an IRQ-based callback from TMU1 at high speeds but I couldn't really figure out how to do that properly after spending at least an hour looking through the KOS documentation and code. What's the best way to set something like that up?

That should provide a drastic speed increase, and I'm also planning on setting up an instruction flow cache system. Like as in generating lists of function pointers for each opcode every time it runs into a new chunk of code to emulate, so that the next time that chunk is run it doesn't have to parse all the bytecode anymore as long as it hasn't been changed. With any luck I could get this thing to crank out high-end 286 performance using this method. At least, I hope. :)

Anyway, some of the games on this demo CD still run a bit too slow to enjoy. The older ones tend to work at full speed. I'd love comments and suggestions on this! Have fun.

Important notes:
- I've run into a few odd situations where the ctrl and alt keys didn't seem to register every time. It usually worked, but if you run into that problem... F11 is an alias for ctrl, F12 for alt.
- If a game you try to run asks you which video card is in the system, NEVER answer EGA! It's not supported yet. You can safely use CGA, Hercules, and MCGA video modes.
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5383
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has liked: 1 time
Been liked: 11 times
Contact:

Re: Looking for DC optimization experts to help on emu port

Post by BlueCrab » Sat Mar 16, 2013 1:18 am

About the simplest TMU1 code ever:

Code: Select all

    irq_set_handler(EXC_TMU1_TUNI1, irq_handler);
    timer_prime(TMU1, tps, 1);
    timer_clear(TMU1);
    timer_start(TMU1);
Where irq_handler is prototyped as follows:

Code: Select all

static void irq_handler(irq_t source, irq_context_t *context);
And tps is the number of ticks you want per second.
miker00lz
DCEmu Cool Newbie
DCEmu Cool Newbie
Posts: 16
Joined: Sat Mar 02, 2013 7:47 pm
Has liked: 0
Been liked: 0

Re: Looking for DC optimization experts to help on emu port

Post by miker00lz » Sat Mar 16, 2013 4:03 pm

BlueCrab wrote:About the simplest TMU1 code ever:

Code: Select all

    irq_set_handler(EXC_TMU1_TUNI1, irq_handler);
    timer_prime(TMU1, tps, 1);
    timer_clear(TMU1);
    timer_start(TMU1);
Where irq_handler is prototyped as follows:

Code: Select all

static void irq_handler(irq_t source, irq_context_t *context);
And tps is the number of ticks you want per second.
Awesome, thanks. I did see those timer functions in the docs but I was confused on what I would need to do with "irq_t source, irq_context_t *context" input arguments. I guess nothing in my case, right? Anyway, I added that and got rid of the timer polling. It makes a much smaller difference that I thought it would, but it's noticeable. I guess I really just need to work on optimizing the CPU core itself. I updated the download link in my last post to a new build with the timer callbacks.
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5383
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has liked: 1 time
Been liked: 11 times
Contact:

Re: Looking for DC optimization experts to help on emu port

Post by BlueCrab » Sat Mar 16, 2013 4:07 pm

miker00lz wrote:Awesome, thanks. I did see those timer functions in the docs but I was confused on what I would need to do with "irq_t source, irq_context_t *context" input arguments. I guess nothing in my case, right?
Pretty much. The first argument just tells you why you're getting the interrupt (in case you have multiple things going into the same function). The second one is the state of the registers when the interrupt happened.
histat
DCEmu Newbie
DCEmu Newbie
Posts: 6
Joined: Sat Mar 16, 2013 2:28 pm
Has liked: 0
Been liked: 0

Re: Looking for DC optimization experts to help on emu port

Post by histat » Wed Apr 10, 2013 4:14 pm

To TapamN
thanks
helped me to support indexed 8bpp.

to miker00lz
I ported PC-9801 emulator to Dreamcast before .

http://neko.sourceforge.net

I had released new update.
it is running at decent speed (6Mhz - 9Mhz).
but frame rate is 10 - 12.
User avatar
SiZiOUS
DC Developer
DC Developer
Posts: 381
Joined: Fri Mar 05, 2004 2:22 pm
Location: France
Has liked: 11 times
Been liked: 9 times
Contact:

Re: Looking for DC optimization experts to help on emu port

Post by SiZiOUS » Sun Apr 14, 2013 2:53 pm

miker00lz, I tested your emulator today on the real hardware, it's pretty slow but sounds good!
I made two videos on Youtube, here and here.
User avatar
Bouz
DCEmu Junior
DCEmu Junior
Posts: 46
Joined: Mon May 10, 2010 3:42 pm
Location: St. Bauzille de Putois (France)
Has liked: 0
Been liked: 0

Re: Looking for DC optimization experts to help on emu port

Post by Bouz » Mon Apr 15, 2013 2:33 pm

Thanks for this, Sizious. Impressive how you manage to type on your keyboard and point the camera to the screen at the same time!
Really cool to see Windows run on a DC. One or to more optimizations and miker00lz will run Windows Vista!
User avatar
SiZiOUS
DC Developer
DC Developer
Posts: 381
Joined: Fri Mar 05, 2004 2:22 pm
Location: France
Has liked: 11 times
Been liked: 9 times
Contact:

Re: Looking for DC optimization experts to help on emu port

Post by SiZiOUS » Mon Apr 15, 2013 3:23 pm

Yeah, I know, my vids suc*s, it's just for showing some applications running with Fake86 :mrgreen:
User avatar
RyoDC
Mental DCEmu
Mental DCEmu
Posts: 353
Joined: Wed Mar 30, 2011 12:13 pm
Has liked: 0
Been liked: 0

Re: Looking for DC optimization experts to help on emu port

Post by RyoDC » Tue Apr 16, 2013 10:39 am

i enjoyed mad gansta music on the back
How do I try to build a Dreamcast toolchain:
Image
User avatar
SiZiOUS
DC Developer
DC Developer
Posts: 381
Joined: Fri Mar 05, 2004 2:22 pm
Location: France
Has liked: 11 times
Been liked: 9 times
Contact:

Re: Looking for DC optimization experts to help on emu port

Post by SiZiOUS » Wed Apr 24, 2013 1:01 pm

Oh, I forgot to remove the audio from one video...
I was listening to the new Tyga :mrgreen:
User avatar
Anthony817
Insane DCEmu
Insane DCEmu
Posts: 127
Joined: Wed Mar 10, 2010 1:29 am
Location: Fort Worth, Texas
Has liked: 9 times
Been liked: 2 times

Re: Looking for DC optimization experts to help on emu port

Post by Anthony817 » Mon Sep 21, 2015 1:14 am

Hi. I wanted to ask if you were still working on this or had any updates to it? I can't believe I haven't found this sooner. Really awesome to see windows running on the DC!
Post Reply