MAMEWorld >> Programming
View all threads Index   Threaded Mode Threaded  

Pages: 1

CrazyMonkey
MAME Fan
Reged: 02/05/16
Posts: 6
Send PM


MegaPlay Programming
#349911 - 02/05/16 05:49 PM


Hello everybody.
Thanks to a MAME disc I got around 2005 on my hands, I finally decided that I want to study computer programming and overall videogame creation, in depth.
Oddly enough, I have two "dreams" with this: One is to create a pirate cartridge (XD), and the other is to be involved with an Arcade videogame in one or another way. Most probably it's "too late" for it (considering the gaming status nowadays) and I'm not gonna get any of my games exported to work in a real hardware, but if I can do something that works properly in the platforms I think is enough =)

I have worked for a couple of years on the Sega Genesis, as a hobby. And I'm getting started with my final and first serious open-source project for it, Sonic Crackers (here's a longer thread about it: http://assemblergames.com/l/threads/sonic-crackers.59925/).
As you can see I'm going with a very arcade-ish style for it. The good news are that the Sega Genesis have a "specialized" adaption for the Arcade world, and that is the Sega Megaplay. In an attempt of finding out information about this platform (of which there's not much), I tried to inspect a few things within the Megaplay version of Sonic the Hedgehog. There are three ROMs: ep15176.ic1, ep15177.ic2 and ep15175-01.ic3. The first two seem pretty similar to the Sega Genesis ROM, just that bytes are split or "crossed" (ep15176.ic1 holds what would be at address 0x000000, 0x000002, 0x000004, etc., and ep15177.ic2 holds what would be at address 0x000001, 0x000003, 0x000005, etc.). And finally there's ep15175-01.ic3, which seem to hold all strings the Megaplay displays, and perhaps some other misc config.
Right now, I only know some basics of C/C++, and so far I have made very primitive and simple programs with it. I'm not too experimented with it, so I barely understand what MAME does to emulate the Megaplay. So, my question is: How does the Megaplay work? What considerations do I need to have with the system? Do the Megaplay have the TMSS lockup system just like the Sega Genesis 2 and up? How does the game know about MegaPlay-specific values, such as quantity of credits, or difficulty mode specified on the DIP Switches? Is the ROM header/structure much different than the standard of Sega Genesis ROMs? http://pastebin.com/4fDyHMZc (Wow, how have the tabulation messed up so bad? :V)

Now, about MAME itself, how do I add my game to the built-in list in the source code? you know, specifying the ZIP's file name, the filenames within the ZIP, the driver required... Also, if on the future I manage to finish my game, may it be supported in further official versions of MAME, just like a new "bootleg" would be?

And finally a less technical question: What you think are the main differences between an Arcade and a home-console game? It seems like 16-bit and up Arcade games tend to focus much more on the variety, throws more stuff on screen at once, but because of the extra effort required from the dev team, Arcade games tend to be a bit shorter. Arcade games seem to be made to be understood as soon as you start the game, and its gameplay seem to be more towards the player's reflexes. Is there anything else I should note?

Thank you!



Haze
Reged: 09/23/03
Posts: 5245
Send PM


Re: MegaPlay Programming new [Re: CrazyMonkey]
#349914 - 02/05/16 06:21 PM


The megatech has an extra Z80 and an extra SMS video chip that acts as an overlay, there's also a bios rom on the motherboard for this.

The MAME emulation of Megaplay actually isn't very good right now, the extra Z80 which is typically handled to program the credits etc. often ends up desyncing with the game logic, allowing you to start the game without that cpu realising, so you end up with problems like 'press start to play' flashing even after starting. A lot of the port behaviors are guessed.

I believe (but have no proof) that the extra instruction rom (read by the extra Z80) actually can be seen in the 68k map at the 3Meg mark too, which would limit the size of the games.

In terms of game code the 68k side isn't plain MD games either, because it had a bunch of extra code to communicate with the extra Z80.

As for lockouts and stuff, people would really need to test it.

Adding a new set in MAME is pretty simple, copy the ROM definition for another game in the megaplay driver, put in a new GAME macro at the bottom, and add the entry to arcade.lst, then recompile.

As I said tho, nobody has done EXTENSIVE research on the platform yet, so working with the original hardware, running test code, and creating your own document (with which MAME could be improved too) would be a wise thing to do; drivers tend to only reach 'suitable for development of games on the real system' level once somebody does that.


> Hello everybody.
> Thanks to a MAME disc I got around 2005 on my hands, I finally decided that I want to
> study computer programming and overall videogame creation, in depth.
> Oddly enough, I have two "dreams" with this: One is to create a pirate cartridge
> (XD), and the other is to be involved with an Arcade videogame in one or another way.
> Most probably it's "too late" for it (considering the gaming status nowadays) and I'm
> not gonna get any of my games exported to work in a real hardware, but if I can do
> something that works properly in the platforms I think is enough =)
>
> I have worked for a couple of years on the Sega Genesis, as a hobby. And I'm getting
> started with my final and first serious open-source project for it, Sonic Crackers
> (here's a longer thread about it:
> http://assemblergames.com/l/threads/sonic-crackers.59925/).
> As you can see I'm going with a very arcade-ish style for it. The good news are that
> the Sega Genesis have a "specialized" adaption for the Arcade world, and that is the
> Sega Megaplay. In an attempt of finding out information about this platform (of which
> there's not much), I tried to inspect a few things within the Megaplay version of
> Sonic the Hedgehog. There are three ROMs: ep15176.ic1, ep15177.ic2 and
> ep15175-01.ic3. The first two seem pretty similar to the Sega Genesis ROM, just that
> bytes are split or "crossed" (ep15176.ic1 holds what would be at address 0x000000,
> 0x000002, 0x000004, etc., and ep15177.ic2 holds what would be at address 0x000001,
> 0x000003, 0x000005, etc.). And finally there's ep15175-01.ic3, which seem to hold all
> strings the Megaplay displays, and perhaps some other misc config.
> Right now, I only know some basics of C/C++, and so far I have made very primitive
> and simple programs with it. I'm not too experimented with it, so I barely understand
> what MAME does to emulate the Megaplay. So, my question is: How does the Megaplay
> work? What considerations do I need to have with the system? Do the Megaplay have the
> TMSS lockup system just like the Sega Genesis 2 and up? How does the game know about
> MegaPlay-specific values, such as quantity of credits, or difficulty mode specified
> on the DIP Switches? Is the ROM header/structure much different than the standard of
> Sega Genesis ROMs? http://pastebin.com/4fDyHMZc (Wow, how have the tabulation messed
> up so bad? :V)
>
> Now, about MAME itself, how do I add my game to the built-in list in the source code?
> you know, specifying the ZIP's file name, the filenames within the ZIP, the driver
> required... Also, if on the future I manage to finish my game, may it be supported in
> further official versions of MAME, just like a new "bootleg" would be?
>
> And finally a less technical question: What you think are the main differences
> between an Arcade and a home-console game? It seems like 16-bit and up Arcade games
> tend to focus much more on the variety, throws more stuff on screen at once, but
> because of the extra effort required from the dev team, Arcade games tend to be a bit
> shorter. Arcade games seem to be made to be understood as soon as you start the game,
> and its gameplay seem to be more towards the player's reflexes. Is there anything
> else I should note?
>
> Thank you!



CrazyMonkey
MAME Fan
Reged: 02/05/16
Posts: 6
Send PM


Re: MegaPlay Programming new [Re: Haze]
#349915 - 02/05/16 06:29 PM


I suposse I could re-join both 68k ROMs and try make a comparison/quick disassembly and check for any differences against the Sonic 1 Rev01's disassembly. But where can I find the code that deals with the extra z80 ROM within MAME's source code? This might give me an insight on the "minimals" for booting the game, strict paddings, etc...

Edited by CrazyMonkey (02/05/16 06:34 PM)



Haze
Reged: 09/23/03
Posts: 5245
Send PM


Re: MegaPlay Programming new [Re: CrazyMonkey]
#349916 - 02/05/16 06:35 PM


> I suposse I could re-join both 68k ROMs and try make a comparison/quick disassembly
> and check for any differences against the Sonic 1 Rev01's disassembly. But where can
> I find the code that deals with the extra z80 ROM within MAME's source code? This
> might give me an insight on the "minimals" for booting the game.

all the handling for the extra hardware is in drivers/megaplay.cpp but as I said, I don't really trust it to be correct tho, it just kind of works right now, there are some bits that are clearly not right (and there's absolutely no understanding / support for having more than 1 cartridge inserted right now, the real hardware could cycle games like NeoGeo MVS)

you could compare a disassembly of the 2 versions (the actual binary will be significantly different, it's not a hack of the game, it's a complete recompile, doesn't have any of the 'slower' levels, has strict time limits, takes out 1-ups, takes out special stages etc)

you're pretty much on your own with this kind of thing beyond what i've pointed out tho.



R. Belmont
Cuckoo for IGAvania
Reged: 09/21/03
Posts: 9716
Loc: ECV-197 The Orville
Send PM


Re: MegaPlay Programming new [Re: CrazyMonkey]
#350182 - 02/11/16 06:00 PM


You might have an easier time targeting the real arcade Genesis board, the Sega C/C2 system. It's basically a Genesis minus the Z80 (the 68k does the sound).



Haze
Reged: 09/23/03
Posts: 5245
Send PM


Re: MegaPlay Programming new [Re: R. Belmont]
#350186 - 02/11/16 07:54 PM


> You might have an easier time targeting the real arcade Genesis board, the Sega C/C2
> system. It's basically a Genesis minus the Z80 (the 68k does the sound).

also has different palette hardware, rather than relying on the VDP CRAM (which is why the games tend to look a bit nicer)

and some weird vblank interrupt hookup, NOT coming from the vdp for whatever reason..

and a sample rom, as part of the new sound system.

but yeah, it's probably a more fun thing to target than the Megaplay, which is pretty gross in all honesty.



CrazyMonkey
MAME Fan
Reged: 02/05/16
Posts: 6
Send PM


Re: MegaPlay Programming new [Re: Haze]
#350294 - 02/15/16 01:48 PM


Sega System C... why haven't you mentioned it early? just gave a little check, and wow, seems like a much cleaner approach, actually :P.

I may try to look up both in the driver code and in one of available ROMs in C2, to see how different the address map is or anything necessary. How much research has been done to it though? As in, does it have less "guess" work than the MegaPlay?

My only concern is now the sound driver for my game... I have worked a lot since my first post, and I got a very processor-intensive task for a game settings screen with a fine-timing visual distortion code running at Horizontal Interrupt (4th). The original first game of Sonic the Hedgehog had indeed a 68k-based sound driver (with the Z80 to handle the DAC), but not too long ago I replaced with a fully Z80-based version of it... and honestly.. I'm not really sure if 8.94Mhz would be enough to overcome the situation.
If I recall correctly, the 68k version of this sound driver may take up to 40% of the processing time. And both drivers handle the music tempos differently too. But I don't want lag!...

How differently does the V-Int work on this system? In STH, the "main" code section stays waiting for a flag that the V-Int should set in RAM, and only then follows with the rest of the execution (processing objects, the scroll engine..). V-Int is triggered at either 60 or 50 times per second (or more clearly, when it's about to work on a frame), and it requires a special flag to be set within VDP, and the SR register set to a specific value...

And finally, how different the color system is? Graphics keep being 4bpp but supporting more color tones? Or is it improved the "good" way and maybe give more color depth? segac2.cpp seems a bit confusing to me yet :P

I haven't gone much further with the MegaPlay yet; I don't know the Z80 instruction set too well yet, I have merely edited the description ROM with a hex editor so the strings look appealing to my game, and I only got to build my custom ROM just yesterday before going to sleep.
But, overall, the specially the C2, seems like a much better approach than the MegaPlay, but the lack of Z80 is my only drawback. I don't know if keeping everything at 68k side is going to make my game a bit slower, but everything else seems like great improvements. Anybody has a different opinion in this regard? What are your reasons?

Edited by CrazyMonkey (02/15/16 02:12 PM)



Haze
Reged: 09/23/03
Posts: 5245
Send PM


Re: MegaPlay Programming new [Re: CrazyMonkey]
#350296 - 02/15/16 07:11 PM


>
> How differently does the V-Int work on this system? In STH, the "main" code section
> stays waiting for a flag that the V-Int should set in RAM, and only then follows with
> the rest of the execution (processing objects, the scroll engine..). V-Int is
> triggered at either 60 or 50 times per second (or more clearly, when it's about to
> work on a frame), and it requires a special flag to be set within VDP, and the SR
> register set to a specific value...
>

the Vint isn't tied to the VDP, it seems to be once every 1/60th of a second all the same tho, you just can't enable/disable it with the VDP registers.

> And finally, how different the color system is? Graphics keep being 4bpp but
> supporting more color tones? Or is it improved the "good" way and maybe give more
> color depth? segac2.cpp seems a bit confusing to me yet :P
>

you have more colour tones (it's 5bits for each pen instead of 3), and IIRC separate palettes for sprites/bgs. There's also some colour banking involving the protection, but you can mostly ignore it for your own development. Basically everything is the same as far as the video goes (it's the same VDP) it just ignores the internal CRAM and uses the external Palette RAM.

> I haven't gone much further with the MegaPlay yet; I don't know the Z80 instruction
> set too well yet, I have merely edited the description ROM with a hex editor so the
> strings look appealing to my game, and I only got to build my custom ROM just
> yesterday before going to sleep.
> But, overall, the specially the C2, seems like a much better approach than the
> MegaPlay, but the lack of Z80 is my only drawback. I don't know if keeping everything
> at 68k side is going to make my game a bit slower, but everything else seems like
> great improvements. Anybody has a different opinion in this regard? What are your
> reasons?

I'd suggest you optimize your code better, even a complex sound driver shouldn't be eating too much time up on a 68k.



R. Belmont
Cuckoo for IGAvania
Reged: 09/21/03
Posts: 9716
Loc: ECV-197 The Orville
Send PM


Re: MegaPlay Programming new [Re: Haze]
#350326 - 02/16/16 08:50 PM


> I'd suggest you optimize your code better, even a complex sound driver shouldn't be
> eating too much time up on a 68k.

IIRC the YM2612 "sample playback" is just a dumb DAC that you have to poke at the sample rate, so that would be why the sound driver takes a lot of CPU. On C2 you could offload the samples to the uPD7759 (which plays samples by DMA from the ROM, so no CPU intervention) and gain a lot of CPU time back. That's likely why they tacked on the 7759 in the first place.

Edited by R. Belmont (02/16/16 08:53 PM)



CrazyMonkey
MAME Fan
Reged: 02/05/16
Posts: 6
Send PM


Re: MegaPlay Programming new [Re: R. Belmont]
#350329 - 02/16/16 10:53 PM


Well, most of the time, we have two kinds of sound drivers on the Sega Genesis:

1- 68k-based driver, that handle the FM and PSG channels, and run a mini-driver on Z80 to play and handle the DAC channel. And yes, this is the driver that takes that high 68k CPU percentage I mentioned earlier. The pro of it is a higher possiblity of DAC sample rate (because Z80 process is very light and clean), and better versatility, especially considering it doesn't need any kind of ROM padding at all.

2- Z80-based driver, that handle the full sound process, FM, PSG and DAC outside the 68k, almost always at the cost of some sample rate. The pro of it is that 68k gets totally free of the sound process, so I get an extra chunk of RAM available, and I can take approach of those extra cycles for other more tasks without dropping frames.

For my game, I have changed to a Z80-based driver. This could me allow to achieve more "fancy" stuff without lagging, maybe more objects on the screen, more screen effects, and such. With C2 I'd have to revert to the 68k driver; and although the 68k is clocked to work on a higher speed, I can't avoid feeling a bit more nervous about this. Effects that use the Horizontal Interrupt are very likely to break upon the slightest lag, for example.

Edited by CrazyMonkey (02/16/16 10:54 PM)



MooglyGuy
Renegade MAME Dev
Reged: 09/01/05
Posts: 2261
Send PM


Re: MegaPlay Programming new [Re: CrazyMonkey]
#350337 - 02/17/16 02:12 AM


> For my game, I have changed to a Z80-based driver. This could me allow to achieve
> more "fancy" stuff without lagging, maybe more objects on the screen, more screen
> effects, and such. With C2 I'd have to revert to the 68k driver; and although the 68k
> is clocked to work on a higher speed, I can't avoid feeling a bit more nervous about
> this. Effects that use the Horizontal Interrupt are very likely to break upon the
> slightest lag, for example.

You don't understand. The sound driver on 68k takes so much time on Genesis because it has to handle the DAC itself. Even though the C2 board does not have a Z80, it DOES have a separate chip for DAC playback that does not cost anything on the 68k.

So the only issues are playing back the music track and triggering samples, which takes almost no time.



CrazyMonkey
MAME Fan
Reged: 02/05/16
Posts: 6
Send PM


Re: MegaPlay Programming new [Re: MooglyGuy]
#350344 - 02/17/16 04:39 AM


Impossible. To play DAC it requires either processor to write the decibel byte to a port, and thus the output frequency is directly linked to the processor cycles; it's all of a "manual" work, and that's why fully Z80-based drivers usually play DAC with a bad quality. Since 68k is already too busy with the game engine itself, the 68k-based sound driver sends playback requests to a mini-player at z80, meant to handle the DAC channel. That's right, the 68k doesn't waste any time with DAC, but it's the 68k sequence playback mechanism in itself who takes that high CPU percentage.

I have decided that I'll reserve some more time and focus on optimizing the 68k driver, and use this one for the arcade builds only (the Genesis version could still use the z80-based driver). And so far I have figured most of what necessary to work with this platform (for now on the palettes; the rest is all the same as the Genesis).

Thank you anyways =)

Edited by CrazyMonkey (02/17/16 04:42 AM)



MooglyGuy
Renegade MAME Dev
Reged: 09/01/05
Posts: 2261
Send PM


Re: MegaPlay Programming new [Re: CrazyMonkey]
#350367 - 02/17/16 10:45 PM


If you don't understand why a dedicated sample playback chip solves the issue of 68k load, there's no helping you.



CrazyMonkey
MAME Fan
Reged: 02/05/16
Posts: 6
Send PM


Re: MegaPlay Programming new [Re: MooglyGuy]
#350374 - 02/18/16 02:36 AM


Heeeeeeey!!, chill out, I was trying to be cool here, I don't treat anybody like that..

> If you don't understand why a dedicated sample playback chip solves the issue of 68k
> load, there's no helping you.

And you failed twice to understand my issue: Not the DAC, the sequence player (that handle all the channels and sends the commands, by the way).

So by pointing out what you think I don't understand because of your own misunderstandment, there's no help either.

Edited by CrazyMonkey (02/18/16 02:49 AM)



R. Belmont
Cuckoo for IGAvania
Reged: 09/21/03
Posts: 9716
Loc: ECV-197 The Orville
Send PM


Re: MegaPlay Programming new [Re: CrazyMonkey]
#350390 - 02/18/16 08:32 PM


> And you failed twice to understand my issue: Not the DAC, the sequence player (that
> handle all the channels and sends the commands, by the way).

I wrote a sequence player on the Apple IIgs that takes about 2% of CPU at 2.8 MHz for 14 channels of sound. We're saying that on the C2, sample playback is free for the CPU, so if your sequence player takes any measurable amount of time on a 7 MHz 68000 without DAC servicing you're doing it wrong :-)


Pages: 1

MAMEWorld >> Programming
View all threads Index   Threaded Mode Threaded  

Extra information Permissions
Moderator:  Pi 
0 registered and 48 anonymous users are browsing this forum.
You cannot start new topics
You cannot reply to topics
HTML is enabled
UBBCode is enabled
Thread views: 4308