libretro / mame2003-plus-libretro

Updated 2018 version of MAME (0.78) for libretro. with added game support plus many fixes and improvements
Other
194 stars 110 forks source link

Asteroids missing cocktail implementation #1669

Closed rdagger closed 10 months ago

rdagger commented 10 months ago

Asteroids and Asteroids Deluxe are missing the cabinet dip switch for cocktail mode and the player 2 controls. I believe this was fixed in mame v0.198.

image

image

image

image

image

mahoneyt944 commented 10 months ago

Here's the relevant commit https://github.com/mamedev/mame/commit/7a0645cfdd01fa136353117a78d3188ed253e84c

I'm not familiar with PORT_CONFNAME, I assume this might be a physical jumper on the board (Inverter circuit) and not necessarily a dip switch. We could probably set this up with a fake dip though and install a write handler.

mahoneyt944 commented 10 months ago

Found this info as well.

The cocktail model uses the same PCB as the upright model.

The cocktail harness has a jumper wire from J20 Pin7 to Pin 19 that controls the video inverter circuit.

Source: https://www.arcade-history.com/?n=asteroids-cocktail-model&page=detail&id=36869

arcadez2003 commented 10 months ago

Here's the relevant commit mamedev/mame@7a0645c

I'm not familiar with PORT_CONFNAME, I assume this might be a physical jumper on the board (Inverter circuit) and not necessarily a dip switch. We could probably set this up with a fake dip though and install a write handler.

Yeah i've not bumped into code such as this before either "just as well likely" as you said fake ports with a trampoline which hooks to the video code to allow the flip or not toggle is what ya need most likely.

Easier said than done though eh maybe another driver with a similar scheme might point you in the correct direction.?? certainly after searching the MAME src i see no other drivers as yet using this exact same hookup style.

EDIT Sometimes FBN can help give some pointers if this fix has been added there.?? as like us they'd have to rework the same code to fit within their structure.

mahoneyt944 commented 10 months ago

Made a little progress on this. It seems we need to setup flipping for dvg. Avg already has flipping so I hung off of some of that code.... It's hotwired as of now for testing that is. I installed a write handler to catch the player selection bit and read a fake dip switch to enable the flip. As a concept, this is working but the flip from top to bottom is off, cutting off the score header. Just need to figure why it's getting offset then hook up the controller ports and this should be good. Any help on the flip alignment issue would be appreciated.

https://github.com/libretro/mame2003-plus-libretro/compare/master...Roid

grant2258 commented 10 months ago

fix is here https://github.com/grant2258/mame2003-plus-libretro/tree/ast

The reason for the offset was here just wasn't calculating the visible area properly.

https://github.com/libretro/mame2003-plus-libretro/blob/aed76b26ccf915a3350acc68f78415d3267328a3/src/drivers/asteroid.c#L670

mahoneyt944 commented 10 months ago

Thanks I'll give it a go, do you think we should change the avg code like you have for all games or just this one case? Not sure if it will impact any other games

grant2258 commented 10 months ago

wont break anything just cuts off the invisible area was just done wrong.

mahoneyt944 commented 10 months ago

Sounds like a win win then 👍

mahoneyt944 commented 10 months ago

Btw does current mame even have cocktail controls or are they still sharing the p1 set?

grant2258 commented 10 months ago

no sure youll probably need to tie in with @rdagger for the details

mahoneyt944 commented 10 months ago

Added screen flipping for asteroids, not deluxe cab though..haven't found the player selection bit for that one yet. Still sharing one input set, though I think current mame shares too. https://github.com/libretro/mame2003-plus-libretro/commit/d850ce57880291775ea976303b242e8567f8da4e

mahoneyt944 commented 10 months ago

@rdagger can you confirm if current mame has separate controls for cocktail mode? Or did they just enable screen flipping?

rdagger commented 10 months ago

@mahoneyt944 as far as I know mame currently doesn't implement separate controls, but it should because the cocktail cabinets had separate controls.

rdagger commented 10 months ago

@mahoneyt944 there is a lot of information on this thread: https://forum.arcadecontrols.com/index.php/topic,168028.0.html

mahoneyt944 commented 10 months ago

Interesting read, yeah it appears that they are sharing a port and using grounding tricks to get the extra buttons or something to that effect. I'll look into hooking up a p2 set.

mahoneyt944 commented 10 months ago

I hooked up cocktail controls for asteroids. Let me know how it works for you. https://github.com/libretro/mame2003-plus-libretro/commit/ee4c13520c80884324364d5d70c3c4c9fe0d4567

Deluxe still not implemented though.

rdagger commented 10 months ago

@mahoneyt944 it works, great job! The screen flips. The player 2 controls work as expected and don't interfere with the other player's ship.

There is 1 very small bug. The start button LEDs no longer function properly. Before when you insert a coin the player 1 LED would blink and if you inserted a second coin the player 2 LED would also blink. Now both LEDs are constantly illuminated.

mahoneyt944 commented 10 months ago

Interesting, that might be the bit I'm hooked onto...though I'm not sure what the actual machine does in this odd configuration. I think once i get deluxe working I might have a better method for hooking .

Edit: yes my hook is essentially unhooking the original write after init which is what handles the LEDs. I'll fix that soon.

mahoneyt944 commented 10 months ago

https://github.com/libretro/mame2003-plus-libretro/commit/c7bcc47d11c9c0a94d810f84d0b9d825b44cd65b this should fix the leds

rdagger commented 10 months ago

@mahoneyt944 you fixed the LED bug! 🚀 Your contribution made my day. Thanks a ton!

mahoneyt944 commented 10 months ago

No problem, I will try to get the deluxe working as well. Still need to figure out the bits for that cab though to hook properly.

mahoneyt944 commented 10 months ago

For asteroids, I simply found a bit that seems to follow which players turns it is, then used a little logic to read our fake dip switch. For astroids deluxe, it should follow this same method and all the code should pretty much drop in. Problem is I haven't been able to find a bit that toggles with the players turn, there's probably an easy way to find such a bit...maybe in debug, hex editor or cheat engine. @grant2258 , @arcadez2003 do either of you have any ideas to find this bit for deluxe? Maybe we can dump the memory before and after a player turn changes or something?

grant2258 commented 10 months ago

looking at the latest mame source its offset 4 bit 7 so address 0x3c04 bit 7 so data & 128 at that address should get you what your looking for.

mahoneyt944 commented 10 months ago

Thanks I'll try it out

mahoneyt944 commented 10 months ago

On a second look I think I tried 0x80 already, it's the LED light which flashes when coins go in. I'll plug in everything and retest though since I may not have been in the right port.

mahoneyt944 commented 10 months ago

@grant2258 yup that did the trick, deluxe is now working too 😄 https://github.com/libretro/mame2003-plus-libretro/commit/25f3e820111e1ff0c51eb220fd7aa52f5dca70d4

mahoneyt944 commented 10 months ago

Asteroids is "data&0x04" correct? I found this bit without using documentation. I was just looking at deluxe in current mame and I see this:

https://github.com/mamedev/mame/blob/d750435f57639e6e5ed314793595853c2d975b86/src/mame/atari/asteroid.cpp#L908

The <4> is the offset, but how did you get bit 7?

Asteroids would be this:

https://github.com/mamedev/mame/blob/d750435f57639e6e5ed314793595853c2d975b86/src/mame/atari/asteroid.cpp#L850

So 3202? But again how did you verify the bit? I guess 4 since it works.

rdagger commented 10 months ago

@mahoneyt944 Asteroids Deluxe works, thanks again!

grant2258 commented 10 months ago

I only looked what deluxe is doing bit seven is set here https://github.com/mamedev/mame/blob/d750435f57639e6e5ed314793595853c2d975b86/src/mame/atari/asteroid.cpp#L457.

mahoneyt944 commented 10 months ago

Well I think it's safe to close this, as both games are now fully supported in cocktail mode 👍

arcadez2003 commented 9 months ago

@mahoneyt944 i've been back working with the advanceMAME core again of late and whatya know...... https://github.com/amadvance/advancemame/commit/321fb1ac82b49c678481ef297a0581ca36239bc7 Wish i'd spotted that earlier as maybe it would have given some pointers and saved ya some time anyway you got it sorted in the end so no harm done.

mahoneyt944 commented 9 months ago

@arcadez2003 lol thanks. Yeah many ways to get there. But if it works it works . It was fun to figure it out anyhow.