Change *.c and *.h end-of-line character to LF
change eol char to LF using dos2unix
This commit is contained in:
388
src/input/bbox.c
388
src/input/bbox.c
@@ -1,194 +1,194 @@
|
||||
/* FCE Ultra - NES/Famicom Emulator
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2006 CaH4e3
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "share.h"
|
||||
|
||||
#define DI 01
|
||||
#define CLK 02
|
||||
#define CS 04
|
||||
#define OUT0 01
|
||||
#define D3 01
|
||||
#define D4 02
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8 state;
|
||||
uint8 cmd;
|
||||
uint8 addr;
|
||||
uint8 iswritable;
|
||||
uint16 acc;
|
||||
uint16 data[128];
|
||||
} EEPROM;
|
||||
|
||||
EEPROM serialROM[2];
|
||||
uint8 oldCLK, bankFlip, DIFlip, OUT0state;
|
||||
|
||||
uint8 serialROMautomat(uint8 chip, uint16 data)
|
||||
{
|
||||
uint8 resp = 1;
|
||||
chip &= 1;
|
||||
if(!(data & CS))
|
||||
{
|
||||
if(!(data & CLK))
|
||||
{
|
||||
uint8 state = serialROM[chip].state;
|
||||
uint8 mask, i;
|
||||
switch (serialROM[chip].cmd)
|
||||
{
|
||||
case 0x00:
|
||||
mask = ~(1<<(state&7));
|
||||
if(state<8)
|
||||
{
|
||||
serialROM[chip].addr &= mask;
|
||||
serialROM[chip].addr |= ((data&1)<<(state&7));
|
||||
}
|
||||
else if(state<15)
|
||||
{
|
||||
serialROM[chip].acc &= mask;
|
||||
serialROM[chip].acc |= ((data&1)<<(state&7));
|
||||
}
|
||||
else
|
||||
{
|
||||
serialROM[chip].acc &= mask;
|
||||
serialROM[chip].acc |= ((data&1)<<(state&7));
|
||||
serialROM[chip].cmd = serialROM[chip].acc;
|
||||
}
|
||||
break;
|
||||
case 0x01:
|
||||
if(state<30)
|
||||
resp = (serialROM[chip].data[serialROM[chip].addr]>>(state&15))&1;
|
||||
else
|
||||
{
|
||||
resp = (serialROM[chip].data[serialROM[chip].addr]>>(state&15))&1;
|
||||
serialROM[chip].cmd = 0;
|
||||
}
|
||||
break;
|
||||
case 0x06:
|
||||
mask = ~(1<<(state&15));
|
||||
if(state<30)
|
||||
{
|
||||
serialROM[chip].acc &= mask;
|
||||
serialROM[chip].acc |= ((data&1)<<(state&15));
|
||||
}
|
||||
else
|
||||
{
|
||||
serialROM[chip].acc &= mask;
|
||||
serialROM[chip].acc |= ((data&1)<<(state&15));
|
||||
if(serialROM[chip].iswritable)
|
||||
serialROM[chip].data[serialROM[chip].addr] = serialROM[chip].acc;
|
||||
serialROM[chip].cmd = 0;
|
||||
}
|
||||
break;
|
||||
case 0x0C:
|
||||
for(i=0;i<128;i++)
|
||||
serialROM[chip].data[i] = 0xFFFF;
|
||||
serialROM[chip].cmd = 0;
|
||||
resp = 1;
|
||||
break;
|
||||
case 0x0D:
|
||||
serialROM[chip].cmd = 0;
|
||||
resp = 1;
|
||||
break;
|
||||
case 0x09:
|
||||
serialROM[chip].cmd = 0;
|
||||
serialROM[chip].iswritable = 1;
|
||||
break;
|
||||
case 0x0B:
|
||||
serialROM[chip].cmd = 0;
|
||||
serialROM[chip].iswritable = 0;
|
||||
break;
|
||||
default:
|
||||
serialROM[chip].cmd = 0;
|
||||
serialROM[chip].state = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(serialROM[chip].cmd == 0)
|
||||
{
|
||||
if(serialROM[chip].state>15)
|
||||
serialROM[chip].state = 0;
|
||||
}
|
||||
else
|
||||
serialROM[chip].cmd++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
serialROM[chip].cmd = 0;
|
||||
serialROM[chip].state = 0;
|
||||
}
|
||||
return resp;
|
||||
}
|
||||
|
||||
uint8 serialROMstate(uint8 linestate)
|
||||
{
|
||||
uint8 answ = 0, newCLK = linestate & CLK;
|
||||
if((!oldCLK)&&newCLK)
|
||||
{
|
||||
DIFlip^=1;
|
||||
if(linestate&&OUT0)
|
||||
{
|
||||
serialROMautomat(bankFlip, 04+DIFlip);
|
||||
bankFlip^=1;
|
||||
serialROMautomat(bankFlip, 02+DIFlip);
|
||||
}
|
||||
}
|
||||
answ = DIFlip^1;
|
||||
answ |= (serialROMautomat(bankFlip, newCLK+DIFlip)<<1);
|
||||
oldCLK = newCLK;
|
||||
return answ;
|
||||
}
|
||||
|
||||
static uint8 FP_FASTAPASS(2) BBRead(int w, uint8 ret)
|
||||
{
|
||||
if(w)
|
||||
{
|
||||
serialROMstate(OUT0);
|
||||
ret |= serialROMstate(OUT0|CLK);
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(1) BBWrite(uint8 V)
|
||||
{
|
||||
OUT0state = V;
|
||||
serialROMstate(OUT0state?OUT0:0);
|
||||
}
|
||||
|
||||
static INPUTCFC BattleBox={BBRead,BBWrite,0,0,0,0};
|
||||
|
||||
INPUTCFC *FCEU_InitBattleBox(void)
|
||||
{
|
||||
oldCLK = 1;
|
||||
bankFlip = 0;
|
||||
DIFlip = 0;
|
||||
serialROM[0].iswritable = 1;
|
||||
serialROMautomat(0, 4);
|
||||
serialROM[1].iswritable = 1;
|
||||
serialROMautomat(1, 4);
|
||||
serialROMautomat(bankFlip, 02+DIFlip);
|
||||
return(&BattleBox);
|
||||
}
|
||||
|
||||
*/
|
||||
/* FCE Ultra - NES/Famicom Emulator
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2006 CaH4e3
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "share.h"
|
||||
|
||||
#define DI 01
|
||||
#define CLK 02
|
||||
#define CS 04
|
||||
#define OUT0 01
|
||||
#define D3 01
|
||||
#define D4 02
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8 state;
|
||||
uint8 cmd;
|
||||
uint8 addr;
|
||||
uint8 iswritable;
|
||||
uint16 acc;
|
||||
uint16 data[128];
|
||||
} EEPROM;
|
||||
|
||||
EEPROM serialROM[2];
|
||||
uint8 oldCLK, bankFlip, DIFlip, OUT0state;
|
||||
|
||||
uint8 serialROMautomat(uint8 chip, uint16 data)
|
||||
{
|
||||
uint8 resp = 1;
|
||||
chip &= 1;
|
||||
if(!(data & CS))
|
||||
{
|
||||
if(!(data & CLK))
|
||||
{
|
||||
uint8 state = serialROM[chip].state;
|
||||
uint8 mask, i;
|
||||
switch (serialROM[chip].cmd)
|
||||
{
|
||||
case 0x00:
|
||||
mask = ~(1<<(state&7));
|
||||
if(state<8)
|
||||
{
|
||||
serialROM[chip].addr &= mask;
|
||||
serialROM[chip].addr |= ((data&1)<<(state&7));
|
||||
}
|
||||
else if(state<15)
|
||||
{
|
||||
serialROM[chip].acc &= mask;
|
||||
serialROM[chip].acc |= ((data&1)<<(state&7));
|
||||
}
|
||||
else
|
||||
{
|
||||
serialROM[chip].acc &= mask;
|
||||
serialROM[chip].acc |= ((data&1)<<(state&7));
|
||||
serialROM[chip].cmd = serialROM[chip].acc;
|
||||
}
|
||||
break;
|
||||
case 0x01:
|
||||
if(state<30)
|
||||
resp = (serialROM[chip].data[serialROM[chip].addr]>>(state&15))&1;
|
||||
else
|
||||
{
|
||||
resp = (serialROM[chip].data[serialROM[chip].addr]>>(state&15))&1;
|
||||
serialROM[chip].cmd = 0;
|
||||
}
|
||||
break;
|
||||
case 0x06:
|
||||
mask = ~(1<<(state&15));
|
||||
if(state<30)
|
||||
{
|
||||
serialROM[chip].acc &= mask;
|
||||
serialROM[chip].acc |= ((data&1)<<(state&15));
|
||||
}
|
||||
else
|
||||
{
|
||||
serialROM[chip].acc &= mask;
|
||||
serialROM[chip].acc |= ((data&1)<<(state&15));
|
||||
if(serialROM[chip].iswritable)
|
||||
serialROM[chip].data[serialROM[chip].addr] = serialROM[chip].acc;
|
||||
serialROM[chip].cmd = 0;
|
||||
}
|
||||
break;
|
||||
case 0x0C:
|
||||
for(i=0;i<128;i++)
|
||||
serialROM[chip].data[i] = 0xFFFF;
|
||||
serialROM[chip].cmd = 0;
|
||||
resp = 1;
|
||||
break;
|
||||
case 0x0D:
|
||||
serialROM[chip].cmd = 0;
|
||||
resp = 1;
|
||||
break;
|
||||
case 0x09:
|
||||
serialROM[chip].cmd = 0;
|
||||
serialROM[chip].iswritable = 1;
|
||||
break;
|
||||
case 0x0B:
|
||||
serialROM[chip].cmd = 0;
|
||||
serialROM[chip].iswritable = 0;
|
||||
break;
|
||||
default:
|
||||
serialROM[chip].cmd = 0;
|
||||
serialROM[chip].state = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(serialROM[chip].cmd == 0)
|
||||
{
|
||||
if(serialROM[chip].state>15)
|
||||
serialROM[chip].state = 0;
|
||||
}
|
||||
else
|
||||
serialROM[chip].cmd++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
serialROM[chip].cmd = 0;
|
||||
serialROM[chip].state = 0;
|
||||
}
|
||||
return resp;
|
||||
}
|
||||
|
||||
uint8 serialROMstate(uint8 linestate)
|
||||
{
|
||||
uint8 answ = 0, newCLK = linestate & CLK;
|
||||
if((!oldCLK)&&newCLK)
|
||||
{
|
||||
DIFlip^=1;
|
||||
if(linestate&&OUT0)
|
||||
{
|
||||
serialROMautomat(bankFlip, 04+DIFlip);
|
||||
bankFlip^=1;
|
||||
serialROMautomat(bankFlip, 02+DIFlip);
|
||||
}
|
||||
}
|
||||
answ = DIFlip^1;
|
||||
answ |= (serialROMautomat(bankFlip, newCLK+DIFlip)<<1);
|
||||
oldCLK = newCLK;
|
||||
return answ;
|
||||
}
|
||||
|
||||
static uint8 FP_FASTAPASS(2) BBRead(int w, uint8 ret)
|
||||
{
|
||||
if(w)
|
||||
{
|
||||
serialROMstate(OUT0);
|
||||
ret |= serialROMstate(OUT0|CLK);
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(1) BBWrite(uint8 V)
|
||||
{
|
||||
OUT0state = V;
|
||||
serialROMstate(OUT0state?OUT0:0);
|
||||
}
|
||||
|
||||
static INPUTCFC BattleBox={BBRead,BBWrite,0,0,0,0};
|
||||
|
||||
INPUTCFC *FCEU_InitBattleBox(void)
|
||||
{
|
||||
oldCLK = 1;
|
||||
bankFlip = 0;
|
||||
DIFlip = 0;
|
||||
serialROM[0].iswritable = 1;
|
||||
serialROMautomat(0, 4);
|
||||
serialROM[1].iswritable = 1;
|
||||
serialROMautomat(1, 4);
|
||||
serialROMautomat(bankFlip, 02+DIFlip);
|
||||
return(&BattleBox);
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
144
src/input/fkb.h
144
src/input/fkb.h
@@ -1,72 +1,72 @@
|
||||
#define FKB_F1 0x01
|
||||
#define FKB_F2 0x02
|
||||
#define FKB_F3 0x03
|
||||
#define FKB_F4 0x04
|
||||
#define FKB_F5 0x05
|
||||
#define FKB_F6 0x06
|
||||
#define FKB_F7 0x07
|
||||
#define FKB_F8 0x08
|
||||
#define FKB_1 0x09
|
||||
#define FKB_2 0x0A
|
||||
#define FKB_3 0x0B
|
||||
#define FKB_4 0x0C
|
||||
#define FKB_5 0x0D
|
||||
#define FKB_6 0x0E
|
||||
#define FKB_7 0x0F
|
||||
#define FKB_8 0x10
|
||||
#define FKB_9 0x11
|
||||
#define FKB_0 0x12
|
||||
#define FKB_MINUS 0x13
|
||||
#define FKB_CARET 0x14
|
||||
#define FKB_BACKSLASH 0x15
|
||||
#define FKB_STOP 0x16
|
||||
#define FKB_ESCAPE 0x17
|
||||
#define FKB_Q 0x18
|
||||
#define FKB_W 0x19
|
||||
#define FKB_E 0x1A
|
||||
#define FKB_R 0x1B
|
||||
#define FKB_T 0x1C
|
||||
#define FKB_Y 0x1D
|
||||
#define FKB_U 0x1E
|
||||
#define FKB_I 0x1F
|
||||
#define FKB_O 0x20
|
||||
#define FKB_P 0x21
|
||||
#define FKB_AT 0x22
|
||||
#define FKB_BRACKETLEFT 0x23
|
||||
#define FKB_RETURN 0x24
|
||||
#define FKB_CONTROL 0x25
|
||||
#define FKB_A 0x26
|
||||
#define FKB_S 0x27
|
||||
#define FKB_D 0x28
|
||||
#define FKB_F 0x29
|
||||
#define FKB_G 0x2A
|
||||
#define FKB_H 0x2B
|
||||
#define FKB_J 0x2C
|
||||
#define FKB_K 0x2D
|
||||
#define FKB_L 0x2E
|
||||
#define FKB_SEMICOLON 0x2F
|
||||
#define FKB_COLON 0x30
|
||||
#define FKB_BRACKETRIGHT 0x31
|
||||
#define FKB_KANA 0x32
|
||||
#define FKB_LEFTSHIFT 0x33
|
||||
#define FKB_Z 0x34
|
||||
#define FKB_X 0x35
|
||||
#define FKB_C 0x36
|
||||
#define FKB_V 0x37
|
||||
#define FKB_B 0x38
|
||||
#define FKB_N 0x39
|
||||
#define FKB_M 0x3A
|
||||
#define FKB_COMMA 0x3B
|
||||
#define FKB_PERIOD 0x3C
|
||||
#define FKB_SLASH 0x3D
|
||||
#define FKB_UNDERSCORE 0x3E
|
||||
#define FKB_RIGHTSHIFT 0x3F
|
||||
#define FKB_GRAPH 0x40
|
||||
#define FKB_SPACE 0x41
|
||||
#define FKB_CLEAR 0x42
|
||||
#define FKB_INSERT 0x43
|
||||
#define FKB_DELETE 0x44
|
||||
#define FKB_UP 0x45
|
||||
#define FKB_LEFT 0x46
|
||||
#define FKB_RIGHT 0x47
|
||||
#define FKB_DOWN 0x48
|
||||
#define FKB_F1 0x01
|
||||
#define FKB_F2 0x02
|
||||
#define FKB_F3 0x03
|
||||
#define FKB_F4 0x04
|
||||
#define FKB_F5 0x05
|
||||
#define FKB_F6 0x06
|
||||
#define FKB_F7 0x07
|
||||
#define FKB_F8 0x08
|
||||
#define FKB_1 0x09
|
||||
#define FKB_2 0x0A
|
||||
#define FKB_3 0x0B
|
||||
#define FKB_4 0x0C
|
||||
#define FKB_5 0x0D
|
||||
#define FKB_6 0x0E
|
||||
#define FKB_7 0x0F
|
||||
#define FKB_8 0x10
|
||||
#define FKB_9 0x11
|
||||
#define FKB_0 0x12
|
||||
#define FKB_MINUS 0x13
|
||||
#define FKB_CARET 0x14
|
||||
#define FKB_BACKSLASH 0x15
|
||||
#define FKB_STOP 0x16
|
||||
#define FKB_ESCAPE 0x17
|
||||
#define FKB_Q 0x18
|
||||
#define FKB_W 0x19
|
||||
#define FKB_E 0x1A
|
||||
#define FKB_R 0x1B
|
||||
#define FKB_T 0x1C
|
||||
#define FKB_Y 0x1D
|
||||
#define FKB_U 0x1E
|
||||
#define FKB_I 0x1F
|
||||
#define FKB_O 0x20
|
||||
#define FKB_P 0x21
|
||||
#define FKB_AT 0x22
|
||||
#define FKB_BRACKETLEFT 0x23
|
||||
#define FKB_RETURN 0x24
|
||||
#define FKB_CONTROL 0x25
|
||||
#define FKB_A 0x26
|
||||
#define FKB_S 0x27
|
||||
#define FKB_D 0x28
|
||||
#define FKB_F 0x29
|
||||
#define FKB_G 0x2A
|
||||
#define FKB_H 0x2B
|
||||
#define FKB_J 0x2C
|
||||
#define FKB_K 0x2D
|
||||
#define FKB_L 0x2E
|
||||
#define FKB_SEMICOLON 0x2F
|
||||
#define FKB_COLON 0x30
|
||||
#define FKB_BRACKETRIGHT 0x31
|
||||
#define FKB_KANA 0x32
|
||||
#define FKB_LEFTSHIFT 0x33
|
||||
#define FKB_Z 0x34
|
||||
#define FKB_X 0x35
|
||||
#define FKB_C 0x36
|
||||
#define FKB_V 0x37
|
||||
#define FKB_B 0x38
|
||||
#define FKB_N 0x39
|
||||
#define FKB_M 0x3A
|
||||
#define FKB_COMMA 0x3B
|
||||
#define FKB_PERIOD 0x3C
|
||||
#define FKB_SLASH 0x3D
|
||||
#define FKB_UNDERSCORE 0x3E
|
||||
#define FKB_RIGHTSHIFT 0x3F
|
||||
#define FKB_GRAPH 0x40
|
||||
#define FKB_SPACE 0x41
|
||||
#define FKB_CLEAR 0x42
|
||||
#define FKB_INSERT 0x43
|
||||
#define FKB_DELETE 0x44
|
||||
#define FKB_UP 0x45
|
||||
#define FKB_LEFT 0x46
|
||||
#define FKB_RIGHT 0x47
|
||||
#define FKB_DOWN 0x48
|
||||
|
||||
@@ -1,86 +1,86 @@
|
||||
/* FCE Ultra - NES/Famicom Emulator
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2002 Xodnizel
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "share.h"
|
||||
|
||||
typedef struct {
|
||||
int32 mzx, mzy, mzxold, mzyold;
|
||||
uint32 readbit;
|
||||
uint32 data;
|
||||
} MOUSE;
|
||||
|
||||
static MOUSE Mouse;
|
||||
|
||||
static void FP_FASTAPASS(1) StrobeMOUSE(int w) {
|
||||
Mouse.readbit = 0;
|
||||
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 uint8 FP_FASTAPASS(1) ReadMOUSE(int w) {
|
||||
uint8 ret = 0;
|
||||
if (Mouse.readbit >= 8)
|
||||
ret |= 1;
|
||||
else {
|
||||
ret |= (Mouse.data >> Mouse.readbit) & 1;
|
||||
#ifdef FCEUDEF_DEBUGGER
|
||||
if (!fceuindbg)
|
||||
#endif
|
||||
Mouse.readbit++;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(3) UpdateMOUSE(int w, void *data, int arg) {
|
||||
uint32 *ptr = (uint32*)data;
|
||||
Mouse.data = 0;
|
||||
Mouse.mzxold = Mouse.mzx;
|
||||
Mouse.mzyold = Mouse.mzy;
|
||||
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 };
|
||||
|
||||
INPUTC *FCEU_InitMouse(int w) {
|
||||
Mouse.mzx = 0;
|
||||
Mouse.mzy = 0;
|
||||
Mouse.mzxold = 0;
|
||||
Mouse.mzyold = 0;
|
||||
Mouse.data = 0;
|
||||
return(&MOUSEC);
|
||||
}
|
||||
/* FCE Ultra - NES/Famicom Emulator
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2002 Xodnizel
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "share.h"
|
||||
|
||||
typedef struct {
|
||||
int32 mzx, mzy, mzxold, mzyold;
|
||||
uint32 readbit;
|
||||
uint32 data;
|
||||
} MOUSE;
|
||||
|
||||
static MOUSE Mouse;
|
||||
|
||||
static void FP_FASTAPASS(1) StrobeMOUSE(int w) {
|
||||
Mouse.readbit = 0;
|
||||
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 uint8 FP_FASTAPASS(1) ReadMOUSE(int w) {
|
||||
uint8 ret = 0;
|
||||
if (Mouse.readbit >= 8)
|
||||
ret |= 1;
|
||||
else {
|
||||
ret |= (Mouse.data >> Mouse.readbit) & 1;
|
||||
#ifdef FCEUDEF_DEBUGGER
|
||||
if (!fceuindbg)
|
||||
#endif
|
||||
Mouse.readbit++;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(3) UpdateMOUSE(int w, void *data, int arg) {
|
||||
uint32 *ptr = (uint32*)data;
|
||||
Mouse.data = 0;
|
||||
Mouse.mzxold = Mouse.mzx;
|
||||
Mouse.mzyold = Mouse.mzy;
|
||||
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 };
|
||||
|
||||
INPUTC *FCEU_InitMouse(int w) {
|
||||
Mouse.mzx = 0;
|
||||
Mouse.mzy = 0;
|
||||
Mouse.mzxold = 0;
|
||||
Mouse.mzyold = 0;
|
||||
Mouse.data = 0;
|
||||
return(&MOUSEC);
|
||||
}
|
||||
|
||||
@@ -1,97 +1,97 @@
|
||||
/* FCE Ultra - NES/Famicom Emulator
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2002 Xodnizel
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "share.h"
|
||||
#include "suborkb.h"
|
||||
|
||||
#define AK(x) FKB_ ## x
|
||||
|
||||
static uint8 bufit[0x66];
|
||||
static uint8 kspos, kstrobe;
|
||||
static uint8 ksindex;
|
||||
|
||||
/* TODO: check all keys, some of the are wrong */
|
||||
|
||||
static uint16 matrix[13][8] =
|
||||
{
|
||||
{ AK(ESCAPE),AK(SPACE),AK(LMENU),AK(LCONTROL),AK(LSHIFT),AK(GRAVE),AK(TAB),AK(CAPITAL) },
|
||||
{ AK(F6),AK(F7),AK(F5),AK(F4),AK(F8),AK(F2),AK(F1),AK(F3) },
|
||||
{ AK(EQUALS), AK(NUMPAD0),AK(PERIOD),AK(A),AK(RETURN),AK(1),AK(Q),AK(Z) },
|
||||
{ 0, AK(NUMPAD3),AK(NUMPAD6),AK(S),AK(NUMPAD9),AK(2),AK(W),AK(X) },
|
||||
{ AK(SLASH), AK(NUMPAD2),AK(NUMPAD5),AK(D),AK(NUMPAD8),AK(3),AK(E),AK(C) },
|
||||
{ AK(BREAK), AK(NUMPAD1),AK(NUMPAD4),AK(F),AK(NUMPAD7),AK(4),AK(R),AK(V) },
|
||||
{ AK(BACK),AK(BACKSLASH),AK(GRETURN),AK(G),AK(RBRACKET),AK(5),AK(T),AK(B) },
|
||||
{ AK(9),AK(PERIOD),AK(L),AK(K),AK(O),AK(8),AK(I),AK(COMMA) },
|
||||
{ AK(0),AK(SLASH),AK(SEMICOLON),AK(J),AK(P),AK(7),AK(U),AK(M) },
|
||||
{ AK(MINUS),AK(MINUS),AK(APOSTROPHE),AK(H),AK(LBRACKET),AK(6),AK(Y),AK(N) },
|
||||
{ AK(F11),AK(F12),AK(F10),0,AK(MINUS),AK(F9),0,0 },
|
||||
{ AK(UP),AK(RIGHT),AK(DOWN),AK(DIVIDE),AK(LEFT),AK(MULTIPLY),AK(SUBTRACT),AK(ADD) },
|
||||
{ AK(INSERT),AK(NUMPAD1),AK(HOME),AK(PRIOR),AK(DELETE),AK(END),AK(NEXT),AK(NUMLOCK) },
|
||||
};
|
||||
|
||||
static void FP_FASTAPASS(1) PEC586KB_Write(uint8 v) {
|
||||
if (!(kstrobe & 2) && (v & 2)) {
|
||||
kspos = 0;
|
||||
}
|
||||
if ((kstrobe & 1) && !(v & 1)) {
|
||||
ksindex = 0;
|
||||
}
|
||||
if ((kstrobe & 4) && !(v & 4)) {
|
||||
kspos++;
|
||||
kspos %= 13;
|
||||
}
|
||||
kstrobe = v;
|
||||
}
|
||||
|
||||
static uint8 FP_FASTAPASS(2) PEC586KB_Read(int w, uint8 ret) {
|
||||
#ifdef FCEUDEF_DEBUGGER
|
||||
if (!fceuindbg) {
|
||||
#endif
|
||||
if (w) {
|
||||
ret &= ~2;
|
||||
if(bufit[matrix[kspos][7-ksindex]])
|
||||
ret |= 2;
|
||||
ksindex++;
|
||||
ksindex&=7;
|
||||
}
|
||||
#ifdef FCEUDEF_DEBUGGER
|
||||
}
|
||||
#endif
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static void PEC586KB_Strobe(void) {
|
||||
/* kstrobe = 0;
|
||||
ksindex = 0;
|
||||
*/
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(2) PEC586KB_Update(void *data, int arg) {
|
||||
memcpy(bufit + 1, data, sizeof(bufit) - 1);
|
||||
}
|
||||
|
||||
static INPUTCFC PEC586KB = { PEC586KB_Read, PEC586KB_Write, PEC586KB_Strobe, PEC586KB_Update, 0, 0 };
|
||||
|
||||
INPUTCFC *FCEU_InitPEC586KB(void) {
|
||||
memset(bufit, 0, sizeof(bufit));
|
||||
kspos = ksindex = kstrobe = 0;
|
||||
return(&PEC586KB);
|
||||
}
|
||||
/* FCE Ultra - NES/Famicom Emulator
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2002 Xodnizel
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "share.h"
|
||||
#include "suborkb.h"
|
||||
|
||||
#define AK(x) FKB_ ## x
|
||||
|
||||
static uint8 bufit[0x66];
|
||||
static uint8 kspos, kstrobe;
|
||||
static uint8 ksindex;
|
||||
|
||||
/* TODO: check all keys, some of the are wrong */
|
||||
|
||||
static uint16 matrix[13][8] =
|
||||
{
|
||||
{ AK(ESCAPE),AK(SPACE),AK(LMENU),AK(LCONTROL),AK(LSHIFT),AK(GRAVE),AK(TAB),AK(CAPITAL) },
|
||||
{ AK(F6),AK(F7),AK(F5),AK(F4),AK(F8),AK(F2),AK(F1),AK(F3) },
|
||||
{ AK(EQUALS), AK(NUMPAD0),AK(PERIOD),AK(A),AK(RETURN),AK(1),AK(Q),AK(Z) },
|
||||
{ 0, AK(NUMPAD3),AK(NUMPAD6),AK(S),AK(NUMPAD9),AK(2),AK(W),AK(X) },
|
||||
{ AK(SLASH), AK(NUMPAD2),AK(NUMPAD5),AK(D),AK(NUMPAD8),AK(3),AK(E),AK(C) },
|
||||
{ AK(BREAK), AK(NUMPAD1),AK(NUMPAD4),AK(F),AK(NUMPAD7),AK(4),AK(R),AK(V) },
|
||||
{ AK(BACK),AK(BACKSLASH),AK(GRETURN),AK(G),AK(RBRACKET),AK(5),AK(T),AK(B) },
|
||||
{ AK(9),AK(PERIOD),AK(L),AK(K),AK(O),AK(8),AK(I),AK(COMMA) },
|
||||
{ AK(0),AK(SLASH),AK(SEMICOLON),AK(J),AK(P),AK(7),AK(U),AK(M) },
|
||||
{ AK(MINUS),AK(MINUS),AK(APOSTROPHE),AK(H),AK(LBRACKET),AK(6),AK(Y),AK(N) },
|
||||
{ AK(F11),AK(F12),AK(F10),0,AK(MINUS),AK(F9),0,0 },
|
||||
{ AK(UP),AK(RIGHT),AK(DOWN),AK(DIVIDE),AK(LEFT),AK(MULTIPLY),AK(SUBTRACT),AK(ADD) },
|
||||
{ AK(INSERT),AK(NUMPAD1),AK(HOME),AK(PRIOR),AK(DELETE),AK(END),AK(NEXT),AK(NUMLOCK) },
|
||||
};
|
||||
|
||||
static void FP_FASTAPASS(1) PEC586KB_Write(uint8 v) {
|
||||
if (!(kstrobe & 2) && (v & 2)) {
|
||||
kspos = 0;
|
||||
}
|
||||
if ((kstrobe & 1) && !(v & 1)) {
|
||||
ksindex = 0;
|
||||
}
|
||||
if ((kstrobe & 4) && !(v & 4)) {
|
||||
kspos++;
|
||||
kspos %= 13;
|
||||
}
|
||||
kstrobe = v;
|
||||
}
|
||||
|
||||
static uint8 FP_FASTAPASS(2) PEC586KB_Read(int w, uint8 ret) {
|
||||
#ifdef FCEUDEF_DEBUGGER
|
||||
if (!fceuindbg) {
|
||||
#endif
|
||||
if (w) {
|
||||
ret &= ~2;
|
||||
if(bufit[matrix[kspos][7-ksindex]])
|
||||
ret |= 2;
|
||||
ksindex++;
|
||||
ksindex&=7;
|
||||
}
|
||||
#ifdef FCEUDEF_DEBUGGER
|
||||
}
|
||||
#endif
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static void PEC586KB_Strobe(void) {
|
||||
/* kstrobe = 0;
|
||||
ksindex = 0;
|
||||
*/
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(2) PEC586KB_Update(void *data, int arg) {
|
||||
memcpy(bufit + 1, data, sizeof(bufit) - 1);
|
||||
}
|
||||
|
||||
static INPUTCFC PEC586KB = { PEC586KB_Read, PEC586KB_Write, PEC586KB_Strobe, PEC586KB_Update, 0, 0 };
|
||||
|
||||
INPUTCFC *FCEU_InitPEC586KB(void) {
|
||||
memset(bufit, 0, sizeof(bufit));
|
||||
kspos = ksindex = kstrobe = 0;
|
||||
return(&PEC586KB);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user