PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Cyclone 68000 and PicoDrive at www.finalburn.com

Hello folks,

If you check out http://www.finalburn.com/ there is some stuff, including a 68000 emulator for ARM and a Megadrive emulator.

Both are very early prototypes and don't run games yet, but worth a glance.

As always beta-testing reports, or reports as to whether it works on anything other than Pocket PC (other WinCE devices?) are welcome.

Also if you find any games which work, send us an e-mail at
dev (at) finalburn.com


Dave.
I don't get something, is this a 68000 core in ARM ASM? Can we expect a good speed emulator that can play 68000 games sometime in the future (Street Fighter, other Capcom arcade games?) Looks quite cool otherwise, quite a bit of potential I can imagine. Maybe I'm just tired.
sponge wrote:I don't get something, is this a 68000 core in ARM ASM? Can we expect a good speed emulator that can play 68000 games sometime in the future (Street Fighter, other Capcom arcade games?) Looks quite cool otherwise, quite a bit of potential I can imagine. Maybe I'm just tired.


That's exactly right, PCs have had a number of fast Intel ASM cores for a long time (Starscream and A68K, the MAME core, plus the closed source Callus/Genecyst ones) which enabled 68000-based games to run fullspeed on 100-150Mhz machines.

However there hasn't up until now been a ARM assembler core, which was something that bugged me - all the emu ports which just didn't quite run fullspeed because of the C 68000 cores, even though Pocket PCs are 205Mhz-400Mhz now.
So that's what Cyclone is trying to be, an ARM version of Starscream and A68K.

However that's a way off, first I have to figure out why in Sonic 2 Sonic goes shooting off the side of the screen when you jump ;)
Must be some obscure 68000 arithmetic bug in Cyclone, but I just can't track it down! :P
Awesome, we really need some good ARM optimized emulators (just look at the current state of GBA!) Would you mind if I threw this up on PocketGamer?
sponge wrote:Awesome, we really need some good ARM optimized emulators (just look at the current state of GBA!) Would you mind if I threw this up on PocketGamer?


No, that's fine, the more the merrier ;)

About the GBA thing though, I don't think even the most optimised interpreting emu could run 68000 code (without static recompilation of course). :(

Initial tests indicated about 74mhz on a 205mhz StrongARM, and I think ARM7/9 is even less. So max 68000 speed = probably about 1/4 of ARM mhz at the end of the day, which would mean 16.78/4 = about 4mhz which isn't enough to run a megadrive cpu sadly. (Plus it's 32-bit ARM assembler and the GBA only has a 16-bit bus.)

GP32's a good target though, it could enable some interesting stuff on there hopefully :)
I misspoke, I should've said the current state of GBA emulation on the PPC. They're emulating the ARM chip from a desktop emu!!
Don't forget the Amiga (and older Macs) used the Motorola 68000 too.

Dan East
(Plus it's 32-bit ARM assembler and the GBA only has a 16-bit bus.)


That doesn't matter - the GBA can still run 32-bit code... the 16-bit bus just means you have two (implicit) load cycles per instruction if it's not in the 4KB "cache" (that term used very loosely in the GBA context). But still, I'd agree that the puny little 16MHz ARM7TDMI and small amount of memory in there doesn't give it much of a chance of doing any "decent" emulation..

<Nerdy>If one of the other emulators is called Starscream (a Transformer) then you might call yours Cyclonus (another Transformer) ;)</Nerdy>
Dave Johnston · 13 Apr 2004, 08:15 UTC
Dan East wrote:Don't forget the Amiga (and older Macs) used the Motorola 68000 too.


...and the superior Atari STE/STFM series :)
refractor wrote:
(Plus it's 32-bit ARM assembler and the GBA only has a 16-bit bus.)


That doesn't matter - the GBA can still run 32-bit code... the 16-bit bus just means you have two (implicit) load cycles per instruction if it's not in the 4KB "cache" (that term used very loosely in the GBA context). But still, I'd agree that the puny little 16MHz ARM7TDMI and small amount of memory in there doesn't give it much of a chance of doing any "decent" emulation..

<Nerdy>If one of the other emulators is called Starscream (a Transformer) then you might call yours Cyclonus (another Transformer) ;)</Nerdy>



<Even more Nerdy!>Yes! In fact that is where Cyclone comes from - it was originally going to be Cyclonus 68000, but that just didn't sound right, so I shortened it to Cyclone 68000<Even more Nerdy!>

I never quite figured out why Neill named his 68000 core after Megatron's sidekick, but there must have been a good reason, so I will too ;)
Also, I quite like the 'Cycle' + 'Clone' reference to copying the original CPU cycle emulation (now I just have to get the cycles right ;)
Dave:

I guess you would be "The Dave". I am "RCP" of TRWin (N64) and U64Emu (KillerInstinct). :)
Nice to see someone from the emu scene here. I guess this is where old emu coders go after (or as) they recover from the RomzBeggarz in the emu scene.

You should do a DynaRec engine for the 68K on the ARM. You could have it compile in Sleep() at sync points (MMIO access, INTs etc) and that should really help the power draw.

I'd love to help out but I just don't have any time anymore. I miss emulation a TON and if I ever get rich, it will be all emu all the time for me! Feel free to PM me if you have any questions on DynaRec.

Cheers,

rpc
rcp wrote:Dave:

I guess you would be "The Dave". I am "RCP" of TRWin (N64) and U64Emu (KillerInstinct). :)
Nice to see someone from the emu scene here. I guess this is where old emu coders go after (or as) they recover from the RomzBeggarz in the emu scene.

You should do a DynaRec engine for the 68K on the ARM. You could have it compile in Sleep() at sync points (MMIO access, INTs etc) and that should really help the power draw.

I'd love to help out but I just don't have any time anymore. I miss emulation a TON and if I ever get rich, it will be all emu all the time for me! Feel free to PM me if you have any questions on DynaRec.

Cheers,

rpc


Hello!

Heh - very true about recovering from the rom beggars!!!

About doing a dynarec, it's an interesting idea, but I think a lot of work. though I am interested in static recompilation. right now though, i felt the ARM was really lacking a 68000 interpreter, so that was a good initial target.

one area which leads on from the plain interpreter is some kind of ever-so-slightly higher code analysis, specifically idle loops. In FB I just hacked them in per game, but I'm wondering if on the Megadrive I can detect them. Loops like this seems to be used a lot for waitvbl type stuff:
40e4:tst #$ff1234
beq 40e4

For example step the 68000 two instructions (counting the cycles), and see if the cpu is in the same state.

If it is, instantly skip forward cycles * n where cycles * n <= time of next interrupt.


Or the other alternative would be to spot the patterns in the code, e.g. tst #nnnnn, b??
and try to do something based on that. Not sure really - any thoughts?
oh yeah... the old vtrace speedup ;)

First, without a very good interp core, dynarec is next to impossible. When I do a core, the first thing I do is have the dynarec put in calls to the interp core for every instruction. Obviously, this should work perfectly (and it never does, so you get the basic compiler bugs out of the way). Then (using #ifdefs) I work on sections at a time... starting with the easiest possible instructions. This way you can get, all the logic instructions, then memory, then conditionals etc running little bit by little bit.

Another easy approach is just to decode all of the instructions and build an array of functions pointers. This can give you a pretty big speed improvement over the interp core.... but yields big arrays and is still a good bit slower than a full dynarec engine.

To rehash... building a very solid interp core, with a good debugger is a critical first step. Try to think about how you would do the dynarec core so that you can best reuse your interp core when you get ready. Write the interp core in C and don't worry about speed. You will never gain much speed by optimizing or writting in ASM. The sheer number of cycles needed to decode instructions, jump off to a routine, execute the code, update registers and flags and then get the next instruction is too big 'tighten up'. Think of the ratio of native instructions to target instructions... it gets huge. With dynarec, you see ratios on the low end of 1:1 to 12:1 (memory accesses). You don't get anywhere near that with an optimized interp core.

The real key to dynarec is memory instructions. Determining what memory is being accessed is key. You'd like to get basic memory accesses down to a 1:1 or 3:1 ratio. Memory mapped IO (MMIO) is of course a little more difficult. The trick is to have the dynarec core understand memory loads from a register. My later cores would compile a 'sniffer' routine for memory accesses. The first time the sniffer runs, it looks at the address and determines if it could recompile the recompiled code better or if it is a MMIO access or such. In the MIPS cores, you often saw this...

LUI a0,0x4000
ADI a0,0x3ff0
STW a0,b0

which is the long way of saying
Code:

*(DWORD *)0x40003ff0=b0;


if that address (0x40003ff0) is a 'safe' address, then this is just one x86 instructions. If 0x40003ff0 is a MMIO address, then the proper MMIO routine call is compiled in.

I also did some more advanced stuff that basically took the target ASM, upcompiled to a 'C' like langauge (I called it 'B') and then compiled that to x86 ASM. This is the way the real dynarec engines out there work and it yields amazing results. If you don't have to worry about virtual memory (MMU) then you can get an average of 1.5 native instructions per target instructions. This was, of course, with a RISC target, so it might not do as good when going CISC to CISC. ie; several RISC instructions are sometimes required for one 'C' statement that can often compile into one CICS instruction... thus a big savings that helps cover up the memory instructions poor ratio.

Anyway... as you correctly see, looking for branches back an instruction or two is a really good idea. The simple case is one instruction back and a test. Often this test is of a memory location, which is usually MMIO. Thus call a mmioSkip(DWORD address) function and let that function determine what should be done. You've already picked out VBLANK, other might be the results of DMA or and ISR. The usually approach is just to see if you have set an INT and jump to the ISR if so, or inc the cycles and trigger VBLANK and jump to the ISR.

The basic premise is that if the CPU is looping and NO computational instructions are in the loop, then it is waiting on something and (with an interp core...) you best have your core figure out what it is and trigger it right then and there.

Damn, I really wish I had time to work on this with you. Maybe when you get the interp core 100% I might have some time to help on the dynarec. If you want some source code to my old dynarec engines, PM me and I'll send it on your way.

Cheers,

rcp