To be honest, it was about 30 minutes worth of work to jump from Allegro 2.11 to Allegro 4.2. Â I’ve never used it before, but the only ‘gotcha’ was how they handle the main to WinMain for linking.
At the end of your main procedure, you need to place the following code:
And that is it! No semicolon either!
Last night I was playing with Musashi, and actually had the ‘demo’ program loading up the Altered Beast program, and running. Â I just put in the memory areas to let it have read only to the ROM space, read write to the memory addresses, and write only to the IO ports. Â It was enough for it to lock upÂ in an endless loop like this:
E 3990: 4a38 f01c : tst.b $f01c.w E 3994: 67fa : beq 3990
Well some digging around and I found these vague hints:
Some special bytes:
F018: if bit5 is set 1, the screen is not updated
F01C: Timer ?
So it looks like it’s waiting for a shared memory value to be set to a ‘1’, so I setup the IRQ to include this nice hack:
And we were away.
So I thought I’d try to make the big step, as System16 v0.53 uses an ancient version of the UAE Amiga emulator, somewhere between 0.4 and 0.6, I think. Â Anyways I was hoping to expand more and more functionality, and one thing SEGA did love to do was add more and more processors into their designs with some boards sporting up to three 68000 processors. Â And Musashi can support multiple processors so, it seemed like a good fit.
So I amputated the UAE code, and tried to see how many functions System16 calls out from UAE, and it isn’t that much. Â Most calls involve setting up emulation, and executing a single instruction. System16 handles all the memory access, Interrupts, and I/O. Â So a few hours of bashing away I got it to link, and was greeted with a nice black screen. Â I did remember that when I was first playing with the code, that even though the CPU was executing instructions nothing would be drawn without the external interrupt. Â So I googled around and found another emulator, Virtual Jaguar, that also uses the Musashi 68000 CPU core.
So I could take the old UAE way of executing an interrupt from this:
void inline Exception(int nr, CPTR oldpc)
printf("Exception %0x, valeur = %0x, pc = %0x\n", nr, oldpc, m68k_getpc());
printf("Valeur de rï¿½gistre SR = 0x%0x\n", regs.sr);
regs.a -= 4;
put_long (regs.a, m68k_getpc ());
regs.a -= 2;
put_word (regs.a, regs.sr);
m68k_setpc(get_long(regs.vbr + 4*nr));
printf("VBR=%08x , NR=%d , I=%04x \n", regs.vbr, nr, regs.vbr+4*nr);
if (strace) printf("int jump 0x%0x\n", regs.pc);
regs.t1 = regs.t0 = regs.m = 0;
void inline Exception(int nr, CPTR oldpc)
unsigned int sr = m68ki_init_exception();
unsigned int newPC = cpu_read_long(nr<<2);
A quick recompile, and it was running!
Now with that in play, I went ahead and dumped all the old code, and the old Allegro, and went through re-building with Allegro 4.2 on Windows. Â It didn’t take that long, I was really impressed! Â At the same time I didn’t improve on anything in the slightest.
This is only a proof of concept, the fun hasn’t even started yet. Â If you want a ‘solid’ emulator, go with MAME. Â This isn’t anywhere near ready but it is interesting that it is running. Â There is much more work to do with this, especially adding a Z80, and YM2151.
You can download the Win32 executable here. Â You’ll need your own Altered Beast ROMs, it’s an ancient set, nothing that any recent download will map to.
Is there any advantage to Musashi? Is it worth hacking into say Cockatrice (albeit limited to 020 emulation)?
Right now it’s just more so to know that I can, and what is involved. Cockatrice is more involved as it also needs to catch exceptions and pass data in and out….
The mame fork does 040, without fpu and mpu, but it is slower. It may be worth looking how hatari uses uae.
Gotcha! Good work none-the-less.
I thought UAE’s implementation of MMU emulation came from Hatari (or another Falcon emulator)? Previous’ emulation is from Hatari at least.
they share code back and forth, much how Previous used Hatari’s code, but had help from Toni From WinUAE regarding the MMU, and that was then rolled back into WinUAE, which then goes down to Hatari.
hanging on a timer reminded me of this creative protection scheme
I think it’s vbl in this case, but I expect to fight that soon enough!!
Apologies for the off-topic comment.
I used to get a notice everytime a new post (any topic) was posted. How do I re-enable that?
I would use the RSS feed.
Any chance of posting the source for “test1” release to sourceforge?
Would love to see the Allegro 4.2 glue, haven’t looked at system16 in over a decade. Have some Mac System 7 sources for it somewhere.
It’s in the source tree on sourceforge. I’ve kept all the changes I’ve made in there. I need to start doing the z80 and sound stuff, I just haven’t had time.
The 4 commits are just importing 0.53, my fix to load tile sprites, changing the CPU core from UAE to Musashi, and the Windows port.
MacOS 7? I guess for the PowerPC, but a 68000 based port would be pretty cool, since under emulation it should be easily fast enough.