Rewrite Subor Mouse code, fixed latch updating outside of strobe.
This commit is contained in:
parent
ce4221c425
commit
9d9eb868bc
|
@ -18,64 +18,59 @@
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// implementation of Subor Mouse
|
||||||
|
// used in Educational Computer 2000
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "share.h"
|
#include "share.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32 mzx, mzy, mzxold, mzyold;
|
uint8 latch;
|
||||||
uint32 readbit;
|
int32 mx,my;
|
||||||
uint32 data;
|
int32 lmx,lmy;
|
||||||
|
uint32 mb;
|
||||||
} MOUSE;
|
} MOUSE;
|
||||||
|
|
||||||
static MOUSE Mouse;
|
static MOUSE Mouse;
|
||||||
|
|
||||||
static void StrobeMOUSE(int w)
|
static void StrobeMOUSE(int w)
|
||||||
{
|
{
|
||||||
Mouse.readbit=0;
|
Mouse.latch = Mouse.mb & 0x03;
|
||||||
|
|
||||||
|
int32 dx = Mouse.mx - Mouse.lmx;
|
||||||
|
int32 dy = Mouse.my - Mouse.lmy;
|
||||||
|
|
||||||
|
Mouse.lmx = Mouse.mx;
|
||||||
|
Mouse.lmy = Mouse.my;
|
||||||
|
|
||||||
|
if (dx > 0) Mouse.latch |= (0x2 << 2);
|
||||||
|
else if (dx < 0) Mouse.latch |= (0x3 << 2);
|
||||||
|
if (dy > 0) Mouse.latch |= (0x2 << 4);
|
||||||
|
else if (dy < 0) Mouse.latch |= (0x3 << 4);
|
||||||
|
|
||||||
|
//FCEU_printf("Subor Mouse: %02X\n",Mouse.latch);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8 ReadMOUSE(int w)
|
static uint8 ReadMOUSE(int w)
|
||||||
{
|
{
|
||||||
uint8 ret=0;
|
uint8 result = Mouse.latch & 0x01;
|
||||||
if(Mouse.readbit>=8)
|
Mouse.latch = (Mouse.latch >> 1) | 0x80;
|
||||||
ret|=1;
|
return result;
|
||||||
else
|
|
||||||
{
|
|
||||||
ret|=(Mouse.data>>Mouse.readbit)&1;
|
|
||||||
if(!fceuindbg)
|
|
||||||
Mouse.readbit++;
|
|
||||||
}
|
|
||||||
return(ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void UpdateMOUSE(int w, void *data, int arg)
|
static void UpdateMOUSE(int w, void *data, int arg)
|
||||||
{
|
{
|
||||||
uint32 *ptr=(uint32*)data;
|
uint32 *ptr=(uint32*)data;
|
||||||
Mouse.data=0;
|
Mouse.mx = ptr[0];
|
||||||
Mouse.mzxold=Mouse.mzx;
|
Mouse.my = ptr[1];
|
||||||
Mouse.mzyold=Mouse.mzy;
|
Mouse.mb = ptr[2];
|
||||||
Mouse.mzx=ptr[0];
|
|
||||||
Mouse.mzy=ptr[1];
|
|
||||||
Mouse.data|=ptr[2];
|
|
||||||
if((Mouse.mzxold-Mouse.mzx)>0)
|
|
||||||
Mouse.data|=0x0C;
|
|
||||||
else if((Mouse.mzxold-Mouse.mzx)<0)
|
|
||||||
Mouse.data|=0x04;
|
|
||||||
if((Mouse.mzyold-Mouse.mzy)>0)
|
|
||||||
Mouse.data|=0x30;
|
|
||||||
else if((Mouse.mzyold-Mouse.mzy)<0)
|
|
||||||
Mouse.data|=0x10;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static INPUTC MOUSEC={ReadMOUSE,0,StrobeMOUSE,UpdateMOUSE,0,0};
|
static INPUTC MOUSEC={ReadMOUSE,0,StrobeMOUSE,UpdateMOUSE,0,0};
|
||||||
|
|
||||||
INPUTC *FCEU_InitMouse(int w)
|
INPUTC *FCEU_InitMouse(int w)
|
||||||
{
|
{
|
||||||
Mouse.mzx=0;
|
memset(&Mouse,0,sizeof(Mouse));
|
||||||
Mouse.mzy=0;
|
return(&MOUSEC);
|
||||||
Mouse.mzxold=0;
|
|
||||||
Mouse.mzyold=0;
|
|
||||||
Mouse.data=0;
|
|
||||||
return(&MOUSEC);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue