Mega Mouse Usage

For anything related to IO (joypad, serial, XE...)

Moderator: BigEvilCorporation

Chilly Willy
Very interested
Posts: 2587
Joined: Fri Aug 17, 2007 9:33 pm

Re: Mega Mouse Usage

Post by Chilly Willy » Mon Jul 10, 2017 2:30 pm

I see, you're trying to improve your emulator to get those weird games that didn't follow the rules to work by finding all the edge cases for incorrect usage. Those can be kinda fun to get working without breaking everything else. :D

Eke
Very interested
Posts: 821
Joined: Wed Feb 28, 2007 2:57 pm
Contact:

Re: Mega Mouse Usage

Post by Eke » Tue Jul 11, 2017 10:18 pm

Yes, that's pretty much it :wink:

elfor
Newbie
Posts: 1
Joined: Sat Sep 08, 2018 1:30 am

Re: Mega Mouse Usage

Post by elfor » Sun Sep 16, 2018 3:18 pm

Hi, sorry to bother, but i don't know where else to ask about Genesis assembler...

The Russian hacker "Ti" made an almost complete mouse patch for Dune, but lost interest.
It already works well except building placement has problems, sometimes it drifts a bit.

Could anyone else please take a quick look, perhaps (i hope) it's a quick fix?

I ask because there's a whole Russian Genesis Dune romhacking community out here.
And all these giant romhacks would benefit immensely from actual mouse support:
https://www.emu-land.net/forum/index.php?topic=16864

They even have 480x464 hacks of Dune, using a modded Mednafen, it's amazing:
Image

The goal is to play those 480x464 hacks with the mouse.

Attached is the .asm patch i received from Ti, it's for: Dune - The Battle for Arrakis (USA).md CRC 4DEA40BA

Any thoughts or comments? Thanks & cheers
Attachments
dunemouse.rar
(2.32 KiB) Downloaded 2 times

Chilly Willy
Very interested
Posts: 2587
Joined: Fri Aug 17, 2007 9:33 pm

Re: Mega Mouse Usage

Post by Chilly Willy » Mon Sep 17, 2018 5:53 pm

It drifts because it doesn't handle the sign bits for the mouse. It also doesn't check for overflow, but that's probably not an issue most of the time. Here's how it handles x and y

Code: Select all

		move.w	($FFFFBF14).w,d1
		move.b	d0,d2
		ext.w	d2
		asr.w	#1,d2
		sub.w	d2,d1
		cmpi.w	#$D0,d1
		ble.s	*+6
		move.w	#$D0,d1
		cmpi.w	#$10,d1
		bge.s	*+6
		move.w	#$10,d1
		move.w	d1,($FFFFBF14).w		

		lsr.l	#8,d0
		move.w	($FFFFBF12).w,d1
		move.b	d0,d2
		ext.w	d2
		asr.w	#1,d2
		add.w	d2,d1
		cmpi.w	#$130,d1
		ble.s	*+6
		move.w	#$130,d1
		cmpi.w	#$10,d1
		bge.s	*+6
		move.w	#$10,d1	
		move.w	d1,($FFFFBF12).w
Note that all it does is simply use the raw x and y values from the mouse, sign extended to a word and divided by two. That may work some of the time, but isn't correct and will drift under the wrong conditions. The proper way to handle it is like this

Code: Select all

            if (md[0] & 0x04)
                mx = 256; /* x overflow */
            else
                mx = md[2]<<4 | md[3];
            if (md[0] & 0x01)
                mx |= mx ? 0xFF00 : 0xFFFF; /* x sign extend */
            if (md[0] & 0x08)
                my = 256; /* y overflow */
            else
                my = md[4]<<4 | md[5];
            if (md[0] & 0x02)
                my |= my ? 0xFF00 : 0xFFFF; /* y sign extend */
            joyAxisX[port] += (s16)mx;
            joyAxisY[port] += (s16)my;
Here we check for overflow, and then we properly sign extend the value using the sign bits. See how the extension is done? "mx |= mx ? 0xFF00 : 0xFFFF;" That prevents the drift you see in the game.

cero
Very interested
Posts: 226
Joined: Mon Nov 30, 2015 1:55 pm

Re: Mega Mouse Usage

Post by cero » Tue Sep 18, 2018 11:00 am

If you're going as far as hacked emulators to use a resolution it wasn't designed for, is that really worth playing vs just running the PC version?

User avatar
Sik
Very interested
Posts: 705
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: Mega Mouse Usage

Post by Sik » Tue Sep 18, 2018 3:00 pm

The drift issue would still happen without the hacked resolution (you can get the mouse to report a large enough motion to trigger the bug).
Sik is pronounced as "seek", not as "sick".

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests