Initial commit - http://sourceforge.net/p/fceumm/code/160/
This commit is contained in:
106
src/input/arkanoid.c
Normal file
106
src/input/arkanoid.c
Normal file
@@ -0,0 +1,106 @@
|
||||
/* 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 {
|
||||
uint32 mzx, mzb;
|
||||
uint32 readbit;
|
||||
} ARK;
|
||||
|
||||
static ARK NESArk[2];
|
||||
static ARK FCArk;
|
||||
|
||||
static void StrobeARKFC(void) {
|
||||
FCArk.readbit = 0;
|
||||
}
|
||||
|
||||
static uint8 FP_FASTAPASS(2) ReadARKFC(int w, uint8 ret) {
|
||||
ret &= ~2;
|
||||
if (w) {
|
||||
if (FCArk.readbit >= 8)
|
||||
ret |= 2;
|
||||
else {
|
||||
ret |= ((FCArk.mzx >> (7 - FCArk.readbit)) & 1) << 1;
|
||||
#ifdef FCEUDEF_DEBUGGER
|
||||
if (!fceuindbg)
|
||||
#endif
|
||||
FCArk.readbit++;
|
||||
}
|
||||
} else
|
||||
ret |= FCArk.mzb << 1;
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static uint32 FixX(uint32 x) {
|
||||
x = 98 + x * 144 / 240;
|
||||
if (x > 242) x = 242;
|
||||
x = ~x;
|
||||
return(x);
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(2) UpdateARKFC(void *data, int arg) {
|
||||
uint32 *ptr = (uint32*)data;
|
||||
FCArk.mzx = FixX(ptr[0]);
|
||||
FCArk.mzb = ptr[2] ? 1 : 0;
|
||||
}
|
||||
|
||||
static INPUTCFC ARKCFC = { ReadARKFC, 0, StrobeARKFC, UpdateARKFC, 0, 0 };
|
||||
|
||||
INPUTCFC *FCEU_InitArkanoidFC(void) {
|
||||
FCArk.mzx = 98;
|
||||
FCArk.mzb = 0;
|
||||
return(&ARKCFC);
|
||||
}
|
||||
|
||||
static uint8 FP_FASTAPASS(1) ReadARK(int w) {
|
||||
uint8 ret = 0;
|
||||
if (NESArk[w].readbit >= 8)
|
||||
ret |= 1 << 4;
|
||||
else {
|
||||
ret |= ((NESArk[w].mzx >> (7 - NESArk[w].readbit)) & 1) << 4;
|
||||
#ifdef FCEUDEF_DEBUGGER
|
||||
if (!fceuindbg)
|
||||
#endif
|
||||
NESArk[w].readbit++;
|
||||
}
|
||||
ret |= (NESArk[w].mzb & 1) << 3;
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(1) StrobeARK(int w) {
|
||||
NESArk[w].readbit = 0;
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(3) UpdateARK(int w, void *data, int arg) {
|
||||
uint32 *ptr = (uint32*)data;
|
||||
NESArk[w].mzx = FixX(ptr[0]);
|
||||
NESArk[w].mzb = ptr[2] ? 1 : 0;
|
||||
}
|
||||
|
||||
static INPUTC ARKC = { ReadARK, 0, StrobeARK, UpdateARK, 0, 0 };
|
||||
|
||||
INPUTC *FCEU_InitArkanoid(int w) {
|
||||
NESArk[w].mzx = 98;
|
||||
NESArk[w].mzb = 0;
|
||||
return(&ARKC);
|
||||
}
|
||||
194
src/input/bbox.c
Normal file
194
src/input/bbox.c
Normal file
@@ -0,0 +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);
|
||||
}
|
||||
|
||||
*/
|
||||
65
src/input/bworld.c
Normal file
65
src/input/bworld.c
Normal file
@@ -0,0 +1,65 @@
|
||||
/* FCE Ultra - NES/Famicom Emulator
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2003 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"
|
||||
|
||||
static int seq, ptr, bit, cnt, have;
|
||||
static uint8 bdata[20];
|
||||
|
||||
|
||||
static uint8 FP_FASTAPASS(2) Read(int w, uint8 ret) {
|
||||
if (w && have) {
|
||||
switch (seq) {
|
||||
case 0: seq++; ptr = 0; ret |= 0x4; break;
|
||||
case 1: seq++; bit = bdata[ptr]; cnt = 0; ret |= 0x4; break;
|
||||
case 2: ret |= ((bit & 0x01) ^ 0x01) << 2; bit >>= 1; if (++cnt > 7) seq++;
|
||||
break;
|
||||
case 3: if (++ptr > 19) {
|
||||
seq = -1;
|
||||
have = 0;
|
||||
} else
|
||||
seq = 1;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(1) Write(uint8 V) {
|
||||
//printf("%02x\n",V);
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(2) Update(void *data, int arg) {
|
||||
if (*(uint8*)data) {
|
||||
*(uint8*)data = 0;
|
||||
seq = ptr = 0;
|
||||
have = 1;
|
||||
strcpy(bdata, (uint8*)data + 1);
|
||||
strcpy(&bdata[13], "SUNSOFT");
|
||||
}
|
||||
}
|
||||
|
||||
static INPUTCFC BarcodeWorld = { Read, Write, 0, Update, 0, 0 };
|
||||
|
||||
INPUTCFC *FCEU_InitBarcodeWorld(void) {
|
||||
return(&BarcodeWorld);
|
||||
}
|
||||
|
||||
79
src/input/cursor.c
Normal file
79
src/input/cursor.c
Normal file
@@ -0,0 +1,79 @@
|
||||
#include "share.h"
|
||||
|
||||
static uint8 GunSight[] = {
|
||||
0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0,
|
||||
1, 2, 1, 2, 0, 3, 3, 3, 0, 2, 1, 2, 1,
|
||||
0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
|
||||
};
|
||||
static uint8 FCEUcursor[11 * 19] =
|
||||
{
|
||||
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
1, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0,
|
||||
1, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0,
|
||||
1, 2, 2, 2, 2, 1, 0, 0, 0, 0, 0,
|
||||
1, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0,
|
||||
1, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0,
|
||||
1, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0,
|
||||
1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0,
|
||||
1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1,
|
||||
1, 2, 2, 1, 2, 2, 1, 0, 0, 0, 0,
|
||||
1, 2, 1, 0, 1, 2, 2, 1, 0, 0, 0,
|
||||
1, 1, 0, 0, 1, 2, 2, 1, 0, 0, 0,
|
||||
1, 0, 0, 0, 0, 1, 2, 2, 1, 0, 0,
|
||||
0, 0, 0, 0, 0, 1, 2, 2, 1, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 1, 2, 2, 1, 0,
|
||||
0, 0, 0, 0, 0, 0, 1, 2, 2, 1, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0,
|
||||
};
|
||||
|
||||
void FCEU_DrawGunSight(uint8 *buf, int xc, int yc) {
|
||||
int x, y;
|
||||
int c, d;
|
||||
|
||||
for (y = 0; y < 13; y++)
|
||||
for (x = 0; x < 13; x++) {
|
||||
uint8 a;
|
||||
a = GunSight[y * 13 + x];
|
||||
if (a) {
|
||||
c = (yc + y - 7);
|
||||
d = (xc + x - 7);
|
||||
if (c >= 0 && d >= 0 && d < 256 && c < 240) {
|
||||
if (a == 3)
|
||||
buf[c * 256 + d] = 0xBF - (buf[c * 256 + d] & 0x3F);
|
||||
else
|
||||
buf[c * 256 + d] = a - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FCEU_DrawCursor(uint8 *buf, int xc, int yc) {
|
||||
int x, y;
|
||||
int c, d;
|
||||
|
||||
if (xc < 256 && yc < 240)
|
||||
for (y = 0; y < 19; y++)
|
||||
for (x = 0; x < 11; x++) {
|
||||
uint8 a;
|
||||
a = FCEUcursor[y * 11 + x];
|
||||
if (a) {
|
||||
c = (yc + y);
|
||||
d = (xc + x);
|
||||
if (d < 256 && c < 240)
|
||||
buf[c * 256 + d] = a + 127;
|
||||
}
|
||||
}
|
||||
}
|
||||
89
src/input/fkb.c
Normal file
89
src/input/fkb.c
Normal file
@@ -0,0 +1,89 @@
|
||||
/* 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 "fkb.h"
|
||||
#define AK(x) FKB_ ## x
|
||||
|
||||
static uint8 bufit[0x49];
|
||||
static uint8 ksmode;
|
||||
static uint8 ksindex;
|
||||
|
||||
static uint16 matrix[9][2][4] =
|
||||
{
|
||||
{ { AK(F8), AK(RETURN), AK(BRACKETLEFT), AK(BRACKETRIGHT) },
|
||||
{ AK(KANA), AK(RIGHTSHIFT), AK(BACKSLASH), AK(STOP) } },
|
||||
{ { AK(F7), AK(AT), AK(COLON), AK(SEMICOLON) },
|
||||
{ AK(UNDERSCORE), AK(SLASH), AK(MINUS), AK(CARET) } },
|
||||
{ { AK(F6), AK(O), AK(L), AK(K) },
|
||||
{ AK(PERIOD), AK(COMMA), AK(P), AK(0) } },
|
||||
{ { AK(F5), AK(I), AK(U), AK(J) },
|
||||
{ AK(M), AK(N), AK(9), AK(8) } },
|
||||
{ { AK(F4), AK(Y), AK(G), AK(H) },
|
||||
{ AK(B), AK(V), AK(7), AK(6) } },
|
||||
{ { AK(F3), AK(T), AK(R), AK(D) },
|
||||
{ AK(F), AK(C), AK(5), AK(4) } },
|
||||
{ { AK(F2), AK(W), AK(S), AK(A) },
|
||||
{ AK(X), AK(Z), AK(E), AK(3) } },
|
||||
{ { AK(F1), AK(ESCAPE), AK(Q), AK(CONTROL) },
|
||||
{ AK(LEFTSHIFT), AK(GRAPH), AK(1), AK(2) } },
|
||||
{ { AK(CLEAR), AK(UP), AK(RIGHT), AK(LEFT) },
|
||||
{ AK(DOWN), AK(SPACE), AK(DELETE), AK(INSERT) } },
|
||||
};
|
||||
|
||||
static void FP_FASTAPASS(1) FKB_Write(uint8 v) {
|
||||
v >>= 1;
|
||||
if (v & 2) {
|
||||
if ((ksmode & 1) && !(v & 1))
|
||||
ksindex = (ksindex + 1) % 9;
|
||||
}
|
||||
ksmode = v;
|
||||
}
|
||||
|
||||
static uint8 FP_FASTAPASS(2) FKB_Read(int w, uint8 ret) {
|
||||
if (w) {
|
||||
int x;
|
||||
|
||||
ret &= ~0x1E;
|
||||
for (x = 0; x < 4; x++)
|
||||
if (bufit[ matrix[ksindex][ksmode & 1][x] & 0xFF ] || bufit[ matrix[ksindex][ksmode & 1][x] >> 8])
|
||||
ret |= 1 << (x + 1);
|
||||
ret ^= 0x1E;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static void FKB_Strobe(void) {
|
||||
ksmode = 0;
|
||||
ksindex = 0;
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(2) FKB_Update(void *data, int arg) {
|
||||
memcpy(bufit + 1, data, sizeof(bufit) - 1);
|
||||
}
|
||||
|
||||
static INPUTCFC FKB = { FKB_Read, FKB_Write, FKB_Strobe, FKB_Update, 0, 0 };
|
||||
|
||||
INPUTCFC *FCEU_InitFKB(void) {
|
||||
memset(bufit, 0, sizeof(bufit));
|
||||
ksmode = ksindex = 0;
|
||||
return(&FKB);
|
||||
}
|
||||
72
src/input/fkb.h
Normal file
72
src/input/fkb.h
Normal file
@@ -0,0 +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
|
||||
69
src/input/ftrainer.c
Normal file
69
src/input/ftrainer.c
Normal file
@@ -0,0 +1,69 @@
|
||||
/* FCE Ultra - NES/Famicom Emulator
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2003 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"
|
||||
|
||||
static uint32 FTVal, FTValR;
|
||||
static char side;
|
||||
|
||||
static uint8 FP_FASTAPASS(2) FT_Read(int w, uint8 ret) {
|
||||
if (w) {
|
||||
ret |= FTValR;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(1) FT_Write(uint8 V) {
|
||||
FTValR = 0;
|
||||
|
||||
//printf("%08x\n",FTVal);
|
||||
if (!(V & 0x1))
|
||||
FTValR = (FTVal >> 8);
|
||||
else if (!(V & 0x2))
|
||||
FTValR = (FTVal >> 4);
|
||||
else if (!(V & 0x4))
|
||||
FTValR = FTVal;
|
||||
|
||||
FTValR = (~FTValR) & 0xF;
|
||||
if (side == 'B')
|
||||
FTValR = ((FTValR & 0x8) >> 3) | ((FTValR & 0x4) >> 1) | ((FTValR & 0x2) << 1) | ((FTValR & 0x1) << 3);
|
||||
FTValR <<= 1;
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(2) FT_Update(void *data, int arg) {
|
||||
FTVal = *(uint32*)data;
|
||||
}
|
||||
|
||||
static INPUTCFC FamilyTrainer = { FT_Read, FT_Write, 0, FT_Update, 0, 0 };
|
||||
|
||||
INPUTCFC *FCEU_InitFamilyTrainerA(void) {
|
||||
side = 'A';
|
||||
FTVal = FTValR = 0;
|
||||
return(&FamilyTrainer);
|
||||
}
|
||||
|
||||
INPUTCFC *FCEU_InitFamilyTrainerB(void) {
|
||||
side = 'B';
|
||||
FTVal = FTValR = 0;
|
||||
return(&FamilyTrainer);
|
||||
}
|
||||
|
||||
46
src/input/hypershot.c
Normal file
46
src/input/hypershot.c
Normal file
@@ -0,0 +1,46 @@
|
||||
/* FCE Ultra - NES/Famicom Emulator
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2003 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"
|
||||
|
||||
static uint8 HSVal, HSValR;
|
||||
|
||||
|
||||
static uint8 FP_FASTAPASS(2) HS_Read(int w, uint8 ret) {
|
||||
if (w) ret |= HSValR;
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static void HS_Strobe(void) {
|
||||
HSValR = HSVal << 1;
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(2) HS_Update(void *data, int arg) {
|
||||
HSVal = *(uint8*)data;
|
||||
}
|
||||
|
||||
static INPUTCFC HyperShot = { HS_Read, 0, HS_Strobe, HS_Update, 0, 0 };
|
||||
|
||||
INPUTCFC *FCEU_InitHS(void) {
|
||||
HSVal = HSValR = 0;
|
||||
return(&HyperShot);
|
||||
}
|
||||
71
src/input/mahjong.c
Normal file
71
src/input/mahjong.c
Normal file
@@ -0,0 +1,71 @@
|
||||
/* FCE Ultra - NES/Famicom Emulator
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2003 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"
|
||||
|
||||
static uint32 MReal, MRet;
|
||||
|
||||
static uint8 FP_FASTAPASS(2) MJ_Read(int w, uint8 ret) {
|
||||
if (w) {
|
||||
// ret|=(MRet&1)<<1;
|
||||
ret |= ((MRet & 0x80) >> 6) & 2;
|
||||
// MRet>>=1;
|
||||
#ifdef FCEUDEF_DEBUGGER
|
||||
if (!fceuindbg)
|
||||
#endif
|
||||
MRet <<= 1;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(1) MJ_Write(uint8 v) {
|
||||
/* 1: I-D7, J-D6, K-D5, L-D4, M-D3, Big Red-D2
|
||||
2: A-D7, B-D6, C-D5, D-D4, E-D3, F-D2, G-D1, H-D0
|
||||
3: Sel-D6, Start-D7, D5, D4, D3, D2, D1
|
||||
*/
|
||||
MRet = 0;
|
||||
|
||||
v >>= 1;
|
||||
v &= 3;
|
||||
|
||||
if (v == 3) {
|
||||
MRet = (MReal >> 14) & 0x7F;
|
||||
//MRet=((MRet&0x1F) |((MRet&0x40)>>1)|((MRet&0x20)<<1)) <<1; //(MReal>>13)&0x7F;
|
||||
} else if (v == 2) {
|
||||
MRet = MReal & 0xFF;
|
||||
} else if (v == 1) {
|
||||
MRet = (MReal >> 8) & 0x3F;
|
||||
}
|
||||
// HSValR=HSVal<<1;
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(2) MJ_Update(void *data, int arg) {
|
||||
MReal = *(uint32*)data;
|
||||
//printf("%08x\n",MReal>>13);
|
||||
//HSVal=*(uint8*)data;
|
||||
}
|
||||
|
||||
static INPUTCFC Mahjong = { MJ_Read, MJ_Write, 0, MJ_Update, 0, 0 };
|
||||
|
||||
INPUTCFC *FCEU_InitMahjong(void) {
|
||||
MReal = MRet = 0;
|
||||
return(&Mahjong);
|
||||
}
|
||||
86
src/input/mouse.c
Normal file
86
src/input/mouse.c
Normal file
@@ -0,0 +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);
|
||||
}
|
||||
85
src/input/oekakids.c
Normal file
85
src/input/oekakids.c
Normal file
@@ -0,0 +1,85 @@
|
||||
/* FCE Ultra - NES/Famicom Emulator
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2003 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"
|
||||
|
||||
static uint8 OKValR, LastWR;
|
||||
static uint32 OKData;
|
||||
static uint32 OKX, OKY, OKB;
|
||||
|
||||
static uint8 FP_FASTAPASS(2) OK_Read(int w, uint8 ret) {
|
||||
if (w) {
|
||||
ret |= OKValR;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(1) OK_Write(uint8 V) {
|
||||
if (!(V & 0x1)) {
|
||||
int32 vx, vy;
|
||||
|
||||
//puts("Redo");
|
||||
OKValR = OKData = 0;
|
||||
|
||||
if (OKB) OKData |= 1;
|
||||
|
||||
if (OKY >= 48)
|
||||
OKData |= 2;
|
||||
else if (OKB) OKData |= 3;
|
||||
|
||||
vx = OKX * 240 / 256 + 8;
|
||||
vy = OKY * 256 / 240 - 12;
|
||||
if (vy < 0) vy = 0;
|
||||
if (vy > 255) vy = 255;
|
||||
if (vx < 0) vx = 0;
|
||||
if (vx > 255) vx = 255;
|
||||
OKData |= (vx << 10) | (vy << 2);
|
||||
} else {
|
||||
if ((~LastWR) & V & 0x02)
|
||||
OKData <<= 1;
|
||||
|
||||
if (!(V & 0x2)) OKValR = 0x4;
|
||||
else {
|
||||
if (OKData & 0x40000) OKValR = 0;
|
||||
else OKValR = 0x8;
|
||||
}
|
||||
}
|
||||
LastWR = V;
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(2) OK_Update(void *data, int arg) {
|
||||
//puts("Sync");
|
||||
OKX = ((uint32*)data)[0];
|
||||
OKY = ((uint32*)data)[1];
|
||||
OKB = ((uint32*)data)[2];
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(2) DrawOeka(uint8 * buf, int arg) {
|
||||
if (arg && OKY < 44)
|
||||
FCEU_DrawCursor(buf, OKX, OKY);
|
||||
}
|
||||
|
||||
static INPUTCFC OekaKids = { OK_Read, OK_Write, 0, OK_Update, 0, DrawOeka };
|
||||
|
||||
INPUTCFC *FCEU_InitOekaKids(void) {
|
||||
OKValR = 0;
|
||||
return(&OekaKids);
|
||||
}
|
||||
136
src/input/pads.c
Normal file
136
src/input/pads.c
Normal file
@@ -0,0 +1,136 @@
|
||||
/* 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 "../movie.h"
|
||||
#include "../vsuni.h"
|
||||
|
||||
static uint8 joy_readbit[2];
|
||||
static uint8 joy[4] = { 0, 0, 0, 0 };
|
||||
|
||||
static int FSDisable = 0; /* Set to 1 if NES-style four-player adapter is disabled. */
|
||||
void FCEUI_DisableFourScore(int s) {
|
||||
FSDisable = s;
|
||||
}
|
||||
|
||||
extern uint8 LastStrobe;
|
||||
|
||||
SFORMAT FCEUCTRL_STATEINFO[] = {
|
||||
{ joy_readbit, 2, "JYRB" },
|
||||
{ joy, 4, "JOYS" },
|
||||
{ &LastStrobe, 1, "LSTS" },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
/* This function is a quick hack to get the NSF player to use emulated gamepad
|
||||
input.
|
||||
*/
|
||||
uint8 FCEU_GetJoyJoy(void) {
|
||||
return(joy[0] | joy[1] | joy[2] | joy[3]);
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(1) StrobeGP(int w) {
|
||||
joy_readbit[w] = 0;
|
||||
}
|
||||
|
||||
static uint8 FP_FASTAPASS(1) ReadGPVS(int w) {
|
||||
uint8 ret = 0;
|
||||
if (joy_readbit[w] >= 8)
|
||||
ret = 1;
|
||||
else {
|
||||
ret = ((joy[w] >> (joy_readbit[w])) & 1);
|
||||
#ifdef FCEUDEF_DEBUGGER
|
||||
if (!fceuindbg)
|
||||
#endif
|
||||
joy_readbit[w]++;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static uint8 FP_FASTAPASS(1) ReadGP(int w) {
|
||||
uint8 ret;
|
||||
if (joy_readbit[w] >= 8)
|
||||
ret = ((joy[2 + w] >> (joy_readbit[w] & 7)) & 1);
|
||||
else
|
||||
ret = ((joy[w] >> (joy_readbit[w])) & 1);
|
||||
if (joy_readbit[w] >= 16) ret = 0;
|
||||
if (FSDisable) {
|
||||
if (joy_readbit[w] >= 8)
|
||||
ret |= 1;
|
||||
} else {
|
||||
if (joy_readbit[w] == 19 - w)
|
||||
ret |= 1;
|
||||
}
|
||||
#ifdef FCEUDEF_DEBUGGER
|
||||
if (!fceuindbg)
|
||||
#endif
|
||||
joy_readbit[w]++;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(3) UpdateGP(int w, void *data, int arg) {
|
||||
uint32 *ptr = (uint32*)data;
|
||||
if (!w) {
|
||||
joy[0] = *(uint32*)ptr;
|
||||
joy[2] = *(uint32*)ptr >> 16;
|
||||
} else {
|
||||
joy[1] = *(uint32*)ptr >> 8;
|
||||
joy[3] = *(uint32*)ptr >> 24;
|
||||
}
|
||||
#ifdef NETWORK
|
||||
if (FCEUnetplay) NetplayUpdate(joy);
|
||||
#endif
|
||||
FCEUMOV_AddJoy(joy);
|
||||
if (GameInfo->type == GIT_VSUNI)
|
||||
FCEU_VSUniSwap(&joy[0], &joy[1]);
|
||||
}
|
||||
|
||||
static INPUTC GPC = { ReadGP, 0, StrobeGP, UpdateGP, 0, 0 };
|
||||
static INPUTC GPCVS = { ReadGPVS, 0, StrobeGP, UpdateGP, 0, 0 };
|
||||
|
||||
INPUTC *FCEU_InitJoyPad(int w) {
|
||||
joy_readbit[w] = 0;
|
||||
joy[w] = 0;
|
||||
joy[w + 2] = 0;
|
||||
if (GameInfo->type == GIT_VSUNI)
|
||||
return(&GPCVS);
|
||||
else
|
||||
return(&GPC);
|
||||
}
|
||||
|
||||
static uint8 F4ReadBit[2];
|
||||
static void StrobeFami4(void) {
|
||||
F4ReadBit[0] = F4ReadBit[1] = 0;
|
||||
}
|
||||
|
||||
static uint8 FP_FASTAPASS(2) ReadFami4(int w, uint8 ret) {
|
||||
ret &= 1;
|
||||
ret |= ((joy[2 + w] >> (F4ReadBit[w])) & 1) << 1;
|
||||
if (F4ReadBit[w] >= 8) ret |= 2;
|
||||
else F4ReadBit[w]++;
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static INPUTCFC FAMI4C = { ReadFami4, 0, StrobeFami4, 0, 0, 0 };
|
||||
INPUTCFC *FCEU_InitFami4(int w) {
|
||||
memset(&F4ReadBit, 0, sizeof(F4ReadBit));
|
||||
return(&FAMI4C);
|
||||
}
|
||||
96
src/input/pec586kb.c
Normal file
96
src/input/pec586kb.c
Normal file
@@ -0,0 +1,96 @@
|
||||
/* 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);
|
||||
}
|
||||
80
src/input/powerpad.c
Normal file
80
src/input/powerpad.c
Normal file
@@ -0,0 +1,80 @@
|
||||
/* 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"
|
||||
|
||||
|
||||
static char side;
|
||||
static uint32 pprsb[2];
|
||||
static uint32 pprdata[2];
|
||||
|
||||
static uint8 FP_FASTAPASS(1) ReadPP(int w) {
|
||||
uint8 ret = 0;
|
||||
ret |= ((pprdata[w] >> pprsb[w]) & 1) << 3;
|
||||
ret |= ((pprdata[w] >> (pprsb[w] + 8)) & 1) << 4;
|
||||
if (pprsb[w] >= 4) {
|
||||
ret |= 0x10;
|
||||
if (pprsb[w] >= 8)
|
||||
ret |= 0x08;
|
||||
}
|
||||
#ifdef FCEUDEF_DEBUGGER
|
||||
if (!fceuindbg)
|
||||
#endif
|
||||
pprsb[w]++;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(1) StrobePP(int w) {
|
||||
pprsb[w] = 0;
|
||||
}
|
||||
|
||||
void FP_FASTAPASS(3) UpdatePP(int w, void *data, int arg) {
|
||||
static const char shifttableA[12] = { 8, 9, 0, 1, 11, 7, 4, 2, 10, 6, 5, 3 };
|
||||
static const char shifttableB[12] = { 1, 0, 9, 8, 2, 4, 7, 11, 3, 5, 6, 10 };
|
||||
int x;
|
||||
|
||||
pprdata[w] = 0;
|
||||
|
||||
if (side == 'A')
|
||||
for (x = 0; x < 12; x++)
|
||||
pprdata[w] |= (((*(uint32*)data) >> x) & 1) << shifttableA[x];
|
||||
else
|
||||
for (x = 0; x < 12; x++)
|
||||
pprdata[w] |= (((*(uint32*)data) >> x) & 1) << shifttableB[x];
|
||||
}
|
||||
|
||||
static INPUTC PwrPadCtrl = { ReadPP, 0, StrobePP, UpdatePP, 0, 0 };
|
||||
|
||||
static INPUTC *FCEU_InitPowerpad(int w) {
|
||||
pprsb[w] = pprdata[w] = 0;
|
||||
return(&PwrPadCtrl);
|
||||
}
|
||||
|
||||
INPUTC *FCEU_InitPowerpadA(int w) {
|
||||
side = 'A';
|
||||
return(FCEU_InitPowerpad(w));
|
||||
}
|
||||
|
||||
INPUTC *FCEU_InitPowerpadB(int w) {
|
||||
side = 'B';
|
||||
return(FCEU_InitPowerpad(w));
|
||||
}
|
||||
66
src/input/quiz.c
Normal file
66
src/input/quiz.c
Normal file
@@ -0,0 +1,66 @@
|
||||
/* FCE Ultra - NES/Famicom Emulator
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2003 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"
|
||||
|
||||
static uint8 QZVal, QZValR;
|
||||
static uint8 FunkyMode;
|
||||
|
||||
static uint8 FP_FASTAPASS(2) QZ_Read(int w, uint8 ret) {
|
||||
if (w) {
|
||||
//if(X.PC==0xdc7d) return(0xFF);
|
||||
//printf("Blah: %04x\n",X.PC);
|
||||
//FCEUI_DumpMem("dmp2",0xc000,0xffff);
|
||||
|
||||
ret |= (QZValR & 0x7) << 2;
|
||||
QZValR = QZValR >> 3;
|
||||
|
||||
if (FunkyMode) {
|
||||
//ret=0x14;
|
||||
//puts("Funky");
|
||||
QZValR |= 0x28;
|
||||
} else {
|
||||
QZValR |= 0x38;
|
||||
}
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static void QZ_Strobe(void) {
|
||||
QZValR = QZVal;
|
||||
//puts("Strobe");
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(1) QZ_Write(uint8 V) {
|
||||
//printf("Wr: %02x\n",V);
|
||||
FunkyMode = V & 4;
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(2) QZ_Update(void *data, int arg) {
|
||||
QZVal = *(uint8*)data;
|
||||
}
|
||||
|
||||
static INPUTCFC QuizKing = { QZ_Read, QZ_Write, QZ_Strobe, QZ_Update, 0, 0 };
|
||||
|
||||
INPUTCFC *FCEU_InitQuizKing(void) {
|
||||
QZVal = QZValR = 0;
|
||||
return(&QuizKing);
|
||||
}
|
||||
136
src/input/shadow.c
Normal file
136
src/input/shadow.c
Normal file
@@ -0,0 +1,136 @@
|
||||
/* 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 {
|
||||
uint32 mzx, mzy, mzb;
|
||||
int zap_readbit;
|
||||
int bogo;
|
||||
int zappo;
|
||||
uint64 zaphit;
|
||||
} ZAPPER;
|
||||
|
||||
static ZAPPER ZD;
|
||||
|
||||
static void FP_FASTAPASS(3) ZapperFrapper(uint8 * bg, uint8 * spr, uint32 linets, int final) {
|
||||
int xs, xe;
|
||||
int zx, zy;
|
||||
|
||||
if (!bg) { // New line, so reset stuff.
|
||||
ZD.zappo = 0;
|
||||
return;
|
||||
}
|
||||
xs = ZD.zappo;
|
||||
xe = final;
|
||||
|
||||
zx = ZD.mzx;
|
||||
zy = ZD.mzy;
|
||||
|
||||
if (xe > 256) xe = 256;
|
||||
|
||||
if (scanline >= (zy - 4) && scanline <= (zy + 4)) {
|
||||
while (xs < xe) {
|
||||
uint8 a1, a2;
|
||||
uint32 sum;
|
||||
if (xs <= (zx + 4) && xs >= (zx - 4)) {
|
||||
a1 = bg[xs];
|
||||
if (spr) {
|
||||
a2 = spr[xs];
|
||||
|
||||
if (!(a2 & 0x80))
|
||||
if (!(a2 & 0x40) || (a1 & 64))
|
||||
a1 = a2;
|
||||
}
|
||||
a1 &= 63;
|
||||
|
||||
sum = palo[a1].r + palo[a1].g + palo[a1].b;
|
||||
if (sum >= 100 * 3) {
|
||||
ZD.zaphit = ((uint64)linets + (xs + 16) * (PAL ? 15 : 16)) / 48 + timestampbase;
|
||||
goto endo;
|
||||
}
|
||||
}
|
||||
xs++;
|
||||
}
|
||||
}
|
||||
endo:
|
||||
ZD.zappo = final;
|
||||
}
|
||||
|
||||
static INLINE int CheckColor(void) {
|
||||
FCEUPPU_LineUpdate();
|
||||
|
||||
if ((ZD.zaphit + 10) >= (timestampbase + timestamp)) return(0);
|
||||
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
static uint8 FP_FASTAPASS(2) ReadZapper(int w, uint8 ret) {
|
||||
if (w) {
|
||||
ret &= ~0x18;
|
||||
if (ZD.bogo)
|
||||
ret |= 0x10;
|
||||
if (CheckColor())
|
||||
ret |= 0x8;
|
||||
} else {
|
||||
if (ZD.zap_readbit == 1) {
|
||||
ret &= ~2;
|
||||
ret |= ZD.mzb & 2;
|
||||
}
|
||||
ret |= (ret & 1) << 1;
|
||||
ZD.zap_readbit++;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(2) DrawZapper(uint8 * buf, int arg) {
|
||||
if (arg)
|
||||
FCEU_DrawGunSight(buf, ZD.mzx, ZD.mzy);
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(2) UpdateZapper(void *data, int arg) {
|
||||
uint32 *ptr = (uint32*)data;
|
||||
|
||||
if (ZD.bogo)
|
||||
ZD.bogo--;
|
||||
if (ptr[2] & 1 && (!(ZD.mzb & 1)))
|
||||
ZD.bogo = 5;
|
||||
|
||||
ZD.mzx = ptr[0];
|
||||
ZD.mzy = ptr[1];
|
||||
ZD.mzb = ptr[2];
|
||||
}
|
||||
|
||||
static void StrobeShadow(void) {
|
||||
ZD.zap_readbit = 0;
|
||||
}
|
||||
|
||||
static INPUTCFC SHADOWC = { ReadZapper, 0, StrobeShadow, UpdateZapper, ZapperFrapper, DrawZapper };
|
||||
|
||||
INPUTCFC *FCEU_InitSpaceShadow(void) {
|
||||
memset(&ZD, 0, sizeof(ZAPPER));
|
||||
return(&SHADOWC);
|
||||
}
|
||||
|
||||
|
||||
12
src/input/share.h
Normal file
12
src/input/share.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#include "../fceu-types.h"
|
||||
#include "../input.h"
|
||||
#include "../fceu.h"
|
||||
#include "../ppu.h"
|
||||
#include "../x6502.h"
|
||||
#include "../palette.h"
|
||||
#include "../state.h"
|
||||
#include "../netplay.h"
|
||||
|
||||
|
||||
void FCEU_DrawCursor(uint8 *buf, int xc, int yc);
|
||||
void FCEU_DrawGunSight(uint8 *buf, int xc, int yc);
|
||||
84
src/input/suborkb.c
Normal file
84
src/input/suborkb.c
Normal file
@@ -0,0 +1,84 @@
|
||||
/* 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 ksmode;
|
||||
static uint8 ksindex;
|
||||
|
||||
static uint16 matrix[13][2][4] =
|
||||
{
|
||||
{ { AK(4), AK(G), AK(F), AK(C) }, { AK(F2), AK(E), AK(5), AK(V) } },
|
||||
{ { AK(2), AK(D), AK(S), AK(END) }, { AK(F1), AK(W), AK(3), AK(X) } },
|
||||
{ { AK(INSERT), AK(BACK), AK(NEXT), AK(RIGHT) }, { AK(F8), AK(PRIOR), AK(DELETE), AK(HOME) } },
|
||||
{ { AK(9), AK(I), AK(L), AK(COMMA) }, { AK(F5), AK(O), AK(0), AK(PERIOD) } },
|
||||
{ { AK(RBRACKET), AK(RETURN), AK(UP), AK(LEFT) }, { AK(F7), AK(LBRACKET), AK(BACKSLASH), AK(DOWN) } },
|
||||
{ { AK(Q), AK(CAPITAL), AK(Z), AK(TAB) }, { AK(ESCAPE), AK(A), AK(1), AK(LCONTROL) } },
|
||||
{ { AK(7), AK(Y), AK(K), AK(M) }, { AK(F4), AK(U), AK(8), AK(J) } },
|
||||
{ { AK(MINUS), AK(SEMICOLON), AK(APOSTROPHE), AK(SLASH) }, { AK(F6), AK(P), AK(EQUALS), AK(LSHIFT) } },
|
||||
{ { AK(T), AK(H), AK(N), AK(SPACE) }, { AK(F3), AK(R), AK(6), AK(B) } },
|
||||
{ { AK(NUMPAD6), AK(GRETURN), AK(NUMPAD4), AK(NUMPAD8) }, { AK(NUMPAD2), 0, 0, 0 } }, // baibaidino actually uses diferent layot
|
||||
{ { AK(LMENU), AK(NUMPAD4), AK(NUMPAD7), AK(F11) }, { AK(F12), AK(NUMPAD1), AK(NUMPAD2), AK(NUMPAD8) } },
|
||||
{ { AK(SUBTRACT), AK(ADD), AK(MULTIPLY), AK(NUMPAD9) }, { AK(F10), AK(NUMPAD5), AK(DIVIDE), AK(NUMLOCK) } },
|
||||
{ { AK(GRAVE), AK(NUMPAD6), AK(PAUSE), AK(SPACE) }, { AK(F9), AK(NUMPAD3), AK(DECIMAL), AK(NUMPAD0) } },
|
||||
};
|
||||
|
||||
static void FP_FASTAPASS(1) SuborKB_Write(uint8 v) {
|
||||
v >>= 1;
|
||||
if (v & 2) {
|
||||
if ((ksmode & 1) && !(v & 1))
|
||||
ksindex = (ksindex + 1) % 13;
|
||||
}
|
||||
ksmode = v;
|
||||
}
|
||||
|
||||
static uint8 FP_FASTAPASS(2) SuborKB_Read(int w, uint8 ret) {
|
||||
if (w) {
|
||||
int x;
|
||||
|
||||
ret &= ~0x1E;
|
||||
for (x = 0; x < 4; x++)
|
||||
if (bufit[matrix[ksindex][ksmode & 1][x]])
|
||||
ret |= 1 << (x + 1);
|
||||
ret ^= 0x1E;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static void SuborKB_Strobe(void) {
|
||||
ksmode = 0;
|
||||
ksindex = 0;
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(2) SuborKB_Update(void *data, int arg) {
|
||||
memcpy(bufit + 1, data, sizeof(bufit) - 1);
|
||||
}
|
||||
|
||||
static INPUTCFC SuborKB = { SuborKB_Read, SuborKB_Write, SuborKB_Strobe, SuborKB_Update, 0, 0 };
|
||||
|
||||
INPUTCFC *FCEU_InitSuborKB(void) {
|
||||
memset(bufit, 0, sizeof(bufit));
|
||||
ksmode = ksindex = 0;
|
||||
return(&SuborKB);
|
||||
}
|
||||
102
src/input/suborkb.h
Normal file
102
src/input/suborkb.h
Normal file
@@ -0,0 +1,102 @@
|
||||
#define FKB_ESCAPE 0x01
|
||||
#define FKB_F1 0x02
|
||||
#define FKB_F2 0x03
|
||||
#define FKB_F3 0x04
|
||||
#define FKB_F4 0x05
|
||||
#define FKB_F5 0x06
|
||||
#define FKB_F6 0x07
|
||||
#define FKB_F7 0x08
|
||||
#define FKB_F8 0x09
|
||||
#define FKB_F9 0x0A
|
||||
#define FKB_F10 0x0B
|
||||
#define FKB_F11 0x0C
|
||||
#define FKB_F12 0x0D
|
||||
#define FKB_PAUSE 0x0E
|
||||
#define FKB_GRAVE 0x0F
|
||||
#define FKB_1 0x10
|
||||
#define FKB_2 0x11
|
||||
#define FKB_3 0x12
|
||||
#define FKB_4 0x13
|
||||
#define FKB_5 0x14
|
||||
#define FKB_6 0x15
|
||||
#define FKB_7 0x16
|
||||
#define FKB_8 0x17
|
||||
#define FKB_9 0x18
|
||||
#define FKB_0 0x19
|
||||
#define FKB_MINUS 0x1A
|
||||
#define FKB_EQUALS 0x1B
|
||||
#define FKB_BACK 0x1C
|
||||
#define FKB_INSERT 0x1D
|
||||
#define FKB_HOME 0x1E
|
||||
#define FKB_PRIOR 0x1F
|
||||
#define FKB_NUMLOCK 0x20
|
||||
#define FKB_DIVIDE 0x21
|
||||
#define FKB_MULTIPLY 0x22
|
||||
#define FKB_SUBTRACT 0x23
|
||||
#define FKB_TAB 0x24
|
||||
#define FKB_Q 0x25
|
||||
#define FKB_W 0x26
|
||||
#define FKB_E 0x27
|
||||
#define FKB_R 0x28
|
||||
#define FKB_T 0x29
|
||||
#define FKB_Y 0x2A
|
||||
#define FKB_U 0x2B
|
||||
#define FKB_I 0x2C
|
||||
#define FKB_O 0x2D
|
||||
#define FKB_P 0x2E
|
||||
#define FKB_LBRACKET 0x2F
|
||||
#define FKB_RBRACKET 0x30
|
||||
#define FKB_RETURN 0x31
|
||||
#define FKB_DELETE 0x32
|
||||
#define FKB_END 0x33
|
||||
#define FKB_NEXT 0x34
|
||||
#define FKB_NUMPAD7 0x35
|
||||
#define FKB_NUMPAD8 0x36
|
||||
#define FKB_NUMPAD9 0x37
|
||||
#define FKB_ADD 0x38
|
||||
#define FKB_CAPITAL 0x39
|
||||
#define FKB_A 0x3A
|
||||
#define FKB_S 0x3B
|
||||
#define FKB_D 0x3C
|
||||
#define FKB_F 0x3D
|
||||
#define FKB_G 0x3E
|
||||
#define FKB_H 0x3F
|
||||
#define FKB_J 0x40
|
||||
#define FKB_K 0x41
|
||||
#define FKB_L 0x42
|
||||
#define FKB_SEMICOLON 0x43
|
||||
#define FKB_APOSTROPHE 0x44
|
||||
#define FKB_NUMPAD4 0x45
|
||||
#define FKB_NUMPAD5 0x46
|
||||
#define FKB_NUMPAD6 0x47
|
||||
#define FKB_LSHIFT 0x48
|
||||
#define FKB_Z 0x49
|
||||
#define FKB_X 0x4A
|
||||
#define FKB_C 0x4B
|
||||
#define FKB_V 0x4C
|
||||
#define FKB_B 0x4D
|
||||
#define FKB_N 0x4E
|
||||
#define FKB_M 0x4F
|
||||
#define FKB_COMMA 0x50
|
||||
#define FKB_PERIOD 0x51
|
||||
#define FKB_SLASH 0x52
|
||||
#define FKB_BACKSLASH 0x53
|
||||
#define FKB_UP 0x54
|
||||
#define FKB_NUMPAD1 0x55
|
||||
#define FKB_NUMPAD2 0x56
|
||||
#define FKB_NUMPAD3 0x57
|
||||
#define FKB_LCONTROL 0x58
|
||||
#define FKB_LMENU 0x59
|
||||
#define FKB_SPACE 0x5A
|
||||
#define FKB_LEFT 0x5B
|
||||
#define FKB_DOWN 0x5C
|
||||
#define FKB_RIGHT 0x5D
|
||||
#define FKB_NUMPAD0 0x5E
|
||||
#define FKB_DECIMAL 0x5F
|
||||
#define FKB_RSHIFT 0x60
|
||||
#define FKB_RMENU 0x61
|
||||
#define FKB_RCONTROL 0x62
|
||||
#define FKB_BREAK 0x63
|
||||
#define FKB_RESET 0x64
|
||||
#define FKB_GRETURN 0x65
|
||||
|
||||
52
src/input/toprider.c
Normal file
52
src/input/toprider.c
Normal file
@@ -0,0 +1,52 @@
|
||||
/* FCE Ultra - NES/Famicom Emulator
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2003 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"
|
||||
|
||||
static uint32 bs, bss;
|
||||
static uint32 boop;
|
||||
|
||||
static uint8 FP_FASTAPASS(2) Read(int w, uint8 ret) {
|
||||
if (w) {
|
||||
ret |= (bs & 1) << 3;
|
||||
ret |= (boop & 1) << 4;
|
||||
bs >>= 1;
|
||||
boop >>= 1;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(1) Write(uint8 V) {
|
||||
bs = bss;
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(2) Update(void *data, int arg) {
|
||||
bss = *(uint8*)data;
|
||||
bss |= bss << 8;
|
||||
bss |= bss << 8;
|
||||
}
|
||||
|
||||
static INPUTCFC TopRider = { Read, Write, 0, Update, 0, 0 };
|
||||
|
||||
INPUTCFC *FCEU_InitTopRider(void) {
|
||||
return(&TopRider);
|
||||
}
|
||||
|
||||
151
src/input/zapper.c
Normal file
151
src/input/zapper.c
Normal file
@@ -0,0 +1,151 @@
|
||||
/* 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 {
|
||||
uint32 mzx, mzy, mzb;
|
||||
int zap_readbit;
|
||||
int bogo;
|
||||
int zappo;
|
||||
uint64 zaphit;
|
||||
} ZAPPER;
|
||||
|
||||
static ZAPPER ZD[2];
|
||||
|
||||
static void FP_FASTAPASS(3) ZapperFrapper(int w, uint8 * bg, uint8 * spr, uint32 linets, int final) {
|
||||
int xs, xe;
|
||||
int zx, zy;
|
||||
|
||||
if (!bg) { // New line, so reset stuff.
|
||||
ZD[w].zappo = 0;
|
||||
return;
|
||||
}
|
||||
xs = ZD[w].zappo;
|
||||
xe = final;
|
||||
|
||||
zx = ZD[w].mzx;
|
||||
zy = ZD[w].mzy;
|
||||
|
||||
if (xe > 256) xe = 256;
|
||||
|
||||
if (scanline >= (zy - 4) && scanline <= (zy + 4)) {
|
||||
while (xs < xe) {
|
||||
uint8 a1, a2;
|
||||
uint32 sum;
|
||||
if (xs <= (zx + 4) && xs >= (zx - 4)) {
|
||||
a1 = bg[xs];
|
||||
if (spr) {
|
||||
a2 = spr[xs];
|
||||
|
||||
if (!(a2 & 0x80))
|
||||
if (!(a2 & 0x40) || (a1 & 64))
|
||||
a1 = a2;
|
||||
}
|
||||
a1 &= 63;
|
||||
|
||||
sum = palo[a1].r + palo[a1].g + palo[a1].b;
|
||||
if (sum >= 100 * 3) {
|
||||
ZD[w].zaphit = ((uint64)linets + (xs + 16) * (PAL ? 15 : 16)) / 48 + timestampbase;
|
||||
goto endo;
|
||||
}
|
||||
}
|
||||
xs++;
|
||||
}
|
||||
}
|
||||
endo:
|
||||
ZD[w].zappo = final;
|
||||
}
|
||||
|
||||
static INLINE int CheckColor(int w) {
|
||||
FCEUPPU_LineUpdate();
|
||||
|
||||
if ((ZD[w].zaphit + 100) >= (timestampbase + timestamp)
|
||||
&& !(ZD[w].mzb & 2)) return(0);
|
||||
|
||||
return(1);
|
||||
}
|
||||
|
||||
static uint8 FP_FASTAPASS(1) ReadZapperVS(int w) {
|
||||
uint8 ret = 0;
|
||||
|
||||
if (ZD[w].zap_readbit == 4) ret = 1;
|
||||
|
||||
if (ZD[w].zap_readbit == 7) {
|
||||
if (ZD[w].bogo)
|
||||
ret |= 0x1;
|
||||
}
|
||||
if (ZD[w].zap_readbit == 6) {
|
||||
if (!CheckColor(w))
|
||||
ret |= 0x1;
|
||||
}
|
||||
#ifdef FCEUDEF_DEBUGGER
|
||||
if (!fceuindbg)
|
||||
#endif
|
||||
ZD[w].zap_readbit++;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(1) StrobeZapperVS(int w) {
|
||||
ZD[w].zap_readbit = 0;
|
||||
}
|
||||
|
||||
static uint8 FP_FASTAPASS(1) ReadZapper(int w) {
|
||||
uint8 ret = 0;
|
||||
if (ZD[w].bogo)
|
||||
ret |= 0x10;
|
||||
if (CheckColor(w))
|
||||
ret |= 0x8;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void FASTAPASS(3) DrawZapper(int w, uint8 * buf, int arg) {
|
||||
if (arg)
|
||||
FCEU_DrawGunSight(buf, ZD[w].mzx, ZD[w].mzy);
|
||||
}
|
||||
|
||||
static void FP_FASTAPASS(3) UpdateZapper(int w, void *data, int arg) {
|
||||
uint32 *ptr = (uint32*)data;
|
||||
|
||||
if (ZD[w].bogo)
|
||||
ZD[w].bogo--;
|
||||
if (ptr[2] & 3 && (!(ZD[w].mzb & 3)))
|
||||
ZD[w].bogo = 5;
|
||||
|
||||
ZD[w].mzx = ptr[0];
|
||||
ZD[w].mzy = ptr[1];
|
||||
ZD[w].mzb = ptr[2];
|
||||
}
|
||||
|
||||
static INPUTC ZAPC = { ReadZapper, 0, 0, UpdateZapper, ZapperFrapper, DrawZapper };
|
||||
static INPUTC ZAPVSC = { ReadZapperVS, 0, StrobeZapperVS, UpdateZapper, ZapperFrapper, DrawZapper };
|
||||
|
||||
INPUTC *FCEU_InitZapper(int w) {
|
||||
memset(&ZD[w], 0, sizeof(ZAPPER));
|
||||
if (GameInfo->type == GIT_VSUNI)
|
||||
return(&ZAPVSC);
|
||||
else
|
||||
return(&ZAPC);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user