Arcade versions of Dr Mario (Pill Dropper MD) and MegaTris

Use this forum to share and discuss Uzebox games and demos.
User avatar
mapes
Posts: 174
Joined: Sun Feb 13, 2011 7:04 am
Location: Seattle

Arcade versions of Dr Mario (Pill Dropper MD) and MegaTris

Post by mapes »

*** UPDATED WITH LATEST VERSION OF DR MARIO CODE ***

A long time ago I updated the code for Megatris and Dr Mario for the Uzebox Jamma. I recently found a backup flash drive that had the code on it.

I believe I posted UZE file for the Uzebox Jamma Arcade version I did, but I did make a minor update to make sure that both players always had the same pieces in the exact same order to ensure a balanced game. One problem I couldn't figure out is an audio glitch that occurs while playing the game when a block drops, or is eliminated, occasionally a continually garbled sound is heard until either another block is landed, or some other event occurs.

Regarding Dr. Mario (rebranded as PillDropper MD), I fixed alot of bugs in Dr Mario and brought it more inline with the original game, but never could figure one strange bug where the last virus in the bottom right corner of the bottle would not die when 4 or more pills of the same color were on it. I think there is still a bug with the high score times too. I did update the intro graphic to save space needed for the new graphics and code.

If you compile and run the game, remember that it is set up for Uzebox Jamma controls, so Player 2 start is not controller 2 Start. I'm sure it would be easy to comment the code to work for the standard Uzebox though.

These 2 games are usually the big hits (as well as Donkey Kong) when there is a party at my house and we play the Uzebox Jamma. :mrgreen:
Attachments
PillDropperMD.zip
(320.51 KiB) Downloaded 504 times
Arcade MegaTris.zip
(493.04 KiB) Downloaded 509 times
Last edited by mapes on Wed Jan 15, 2020 3:54 am, edited 2 times in total.
User avatar
Jubatian
Posts: 1563
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: Arcade versions of Dr Mario (Pill Dropper MD) and MegaTris

Post by Jubatian »

I have a thought why you could have that occasional glitching audio, something I experienced and "fixed" in my game ("fixed", well, did sort of a ground-up new kernel to the end, which naturally eliminated it).

The problem is that the audio mixer is not quite interrupt-safe, if it interrupts the game while it is trying to modify one of the channels, it will pick up corrupted state. You have some 11000-12000 cycles on a full-height display before the VSync interrupt when the problematic processing runs. After that, you still have a lot of cycles within the VBlank (you have VSync mixer in the game, and no sprites as it is Mode 1, should be something around 30000 cycles).

So the game keeps running smooth until you used up all the VBlank time (then it would start missing frames), but you can hit the audio problem a lot earlier!

How it can be avoided with the unmodified kernel is trying to get effects done early to fit in that 11000 clocks, or alternatively you could buffer it to pass it to the mixer (calling the appropriate kernel functions) on the beginning of the next frame (once you passed the VSync interrupt, any audio effect will be processed on the next Vsync anyway, so you wouldn't add latency by doing that). It seems to me you still have RAM left in the game, so you could probably try fixing it this way (Wherever TriggerFx() and likes are called, you rather buffer that you need to call this or that effect next time. Then on the beginning of the next frame, like after a WaitVsync() or a GetVsyncFlag() returning true, you process the buffer).

Back then I tried to look into ways to patch the kernel so it didn't have this problem, but I couldn't find any reasonably feasible solution then.
User avatar
mapes
Posts: 174
Joined: Sun Feb 13, 2011 7:04 am
Location: Seattle

Re: Arcade versions of Dr Mario (Pill Dropper MD) and MegaTris

Post by mapes »

I tried the buffer technique and called a new soundfx function to play the buffer after waitvsync. It seemed to do the trick on a quick play, but I noticed I wasn't playing all the audio either.

In the mainmenu, the sounds do not play because there is no waitvsync function in the loop, it just queues the buffer. Once I get the rest of the bugs worked out, I'll post an updated version of it.

Thanks for the tip Jubatian. :mrgreen:
User avatar
mapes
Posts: 174
Joined: Sun Feb 13, 2011 7:04 am
Location: Seattle

Re: Arcade versions of Dr Mario (Pill Dropper MD) and MegaTris

Post by mapes »

Looks like the Megatris sound issue is fixed now for all of the sound effects.

I have attached the latest version of the code.

If anyone has any ideas on the Dr. Mario bug. I'd be open to suggestions. It always seems to be the virus on the bottom right corner, and it doesn't always happen.
Attachments
Arcade MegaTris.zip
(488 KiB) Downloaded 503 times
User avatar
Jubatian
Posts: 1563
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: Arcade versions of Dr Mario (Pill Dropper MD) and MegaTris

Post by Jubatian »

Nice, glad it seemingly worked out OK to fix the problem!

I might try to take a look at that code, maybe there is something there reasonably easy spot by another pair of eyes.
User avatar
Jubatian
Posts: 1563
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: Arcade versions of Dr Mario (Pill Dropper MD) and MegaTris

Post by Jubatian »

In DrMario.c (from the top post), why the lines 1266, 1267, 1317 and 1318 are commented out? Even as they written now, they appear incorrect to me as the relation should be ">=" in them to avoid out-of-bound access. As the code is now, it would read past the array's bounds during attempting to match, which could cause trouble.

Since it reads only when there are items there (color matching to a prior used color), it would likely not cause problems too often, but due to how it ends up being compiled into AVR assembly, it would pick up things from the next column / row. In the bottom right it would proceed to access out of the entire array, which could end up causing things.

Those conditions seem quite necessary, corrected to a ">=" check. What happens if they are active that way?
User avatar
mapes
Posts: 174
Joined: Sun Feb 13, 2011 7:04 am
Location: Seattle

Re: Arcade versions of Dr Mario (Pill Dropper MD) and MegaTris

Post by mapes »

I remember trying to modify the checkmatching4 function to see if it was going out of bounds for some reason. I must have left it in that state when I quit working on it due to frustration.

I will try building and testing the game again with your recommended changes. I thought what you are recommending was how it originally was written by Codecrank.

I'll try to fix my other bug too with the high scores. I can solve that one since I know why it is doing that.

*** UPDATE ***

While looking at the code I realized it was not the latest version of the code like I thought it was. :oops: I did a little more looking around and found the latest version and have now posted it on the first post.

The latest version removed the white disappearing animation and added colored disappearing animation (yellow, blue, red) and extra code to handle criss-crossing horizontal and vertical lines at the same time that were the same color. I felt it was a significant enough improvement that I wanted to make sure it was posted.

I updated the code in attempt to fix the bugs as you pointed out but have not tested out the game enough to see if the problem has been remedied.
User avatar
mapes
Posts: 174
Joined: Sun Feb 13, 2011 7:04 am
Location: Seattle

Re: Arcade versions of Dr Mario (Pill Dropper MD) and MegaTris

Post by mapes »

The corner bug is still present... but a strange thing happened on one iteration of testing; while dropping a different piece (several pieces later) the corner spot cleared.

One other thing that should be pointed out. I can stack 5 or 6 or more of the same color on top of each other on the corner and it still will not clear the line.

Here are some things I'm wondering what it could be.

1) An incorrect line of code in a for statement.

This seems the most likely, but I thought I looked this over.

2) An incorrect way of checking 4 matches.

It could be possible that it hits the 'end' and automatically stops without clearing the line. Perhaps the 'byte' isn't right for the check? Seems strange since I can put a single pill piece down there and it still won't zap the line.

4) Out of cycles before video sync?

I'm no expert on the video mode, but could the game be out of available cycles on the very last row? It seems odd and unlikely to be CONSISTENTLY the bottom right corner last row. This seems extremely unlikely, but don't want to rule it out.

---

I've thought about doing the soundfX buffer, like I did for Arcade Megatris, but I'm not sure that would fix the issue at all if it was the 'out of cycles' issue.
User avatar
Jubatian
Posts: 1563
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: Arcade versions of Dr Mario (Pill Dropper MD) and MegaTris

Post by Jubatian »

mapes wrote: Sun Jan 19, 2020 4:01 am The corner bug is still present... but a strange thing happened on one iteration of testing; while dropping a different piece (several pieces later) the corner spot cleared.
Did you try it with the code as it was (by re-enabling those checks), or did you also correct them like I suggested? Like for example:

Code: Select all

if ((y+j+1) >= BOTTLE_DEPTH) break;
If you don't correct them like this (from ">" to ">="), I feel it likely that the problem would just remain present, coming from that in the lower-right corner, without the check, the compiled code would start reading (and potentially manipulating) outside the bounds of the "space" member, picking up whatever is after it as playfield data (and potentially manipulating it if it detects a match). It is undefined behaviour by C standard, but the actual assembly this case most likely does something alike.

This being caused by exhausting the CPU cycles in VBlank feels extremely unlikely, the symptoms of that would be halved speed and potentially messy screen, without affecting the logic. It definitely looks like to be a problem in the code doing the matching.
User avatar
mapes
Posts: 174
Joined: Sun Feb 13, 2011 7:04 am
Location: Seattle

Re: Arcade versions of Dr Mario (Pill Dropper MD) and MegaTris

Post by mapes »

I think I may have been playing a wrong version of the game which still had the bug with the virus not zapping on the bottom right.

But I did notice soundfx glitching out once. I will put the same audio buffer I made for megatris for dr.mario.

One thing I thought I would mention for anyone trying the game. Make sure you move the PLevel to 3 , 4 or 5 when playing. It changes the time when the pills speed up. The higher the number the easier. There is no way to beat surgeon difficulty with PLevel 1 or 2. It's hard to beat student with PLevel 1.

To access the adjustable options, push the service button. Should be p1 LButton.
Post Reply