mirror of
https://github.com/ekeeke/Genesis-Plus-GX.git
synced 2024-11-04 18:05:06 +01:00
removed unused files
This commit is contained in:
parent
ab4638144c
commit
cb7990cc3f
File diff suppressed because it is too large
Load Diff
@ -1,72 +0,0 @@
|
||||
/****************************************************************************
|
||||
* Genesis Plus
|
||||
* Cartridge Hardware support
|
||||
*
|
||||
* Copyright (C) 2007, 2008, 2009, 2010 Eke-Eke (GCN/Wii port)
|
||||
*
|
||||
* Lots of protection mechanism have been discovered by Haze
|
||||
* (http://haze.mameworld.info/)
|
||||
*
|
||||
* Realtec mapper has been figured out by TascoDeluxe
|
||||
*
|
||||
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef _CART_HW_H_
|
||||
#define _CART_HW_H_
|
||||
|
||||
/* Lock-ON cartridge type */
|
||||
#define TYPE_GG 0x01 /* Game Genie */
|
||||
#define TYPE_AR 0x02 /* Action Replay (Pro) */
|
||||
#define TYPE_SK 0x03 /* Sonic & Knuckles */
|
||||
|
||||
/* Cartridge extra hardware */
|
||||
typedef struct
|
||||
{
|
||||
uint8 regs[4]; /* internal registers (R/W) */
|
||||
uint32 mask[4]; /* registers address mask */
|
||||
uint32 addr[4]; /* registers address */
|
||||
uint16 realtec; /* realtec mapper */
|
||||
uint16 bankshift; /* cartridge with bankshift mecanism reseted on soft-reset */
|
||||
unsigned int (*time_r)(unsigned int address); /* !TIME signal ($a130xx) read handler */
|
||||
void (*time_w)(unsigned int address, unsigned int data); /* !TIME signal ($a130xx) write handler */
|
||||
unsigned int (*regs_r)(unsigned int address); /* cart hardware registers read handler */
|
||||
void (*regs_w)(unsigned int address, unsigned int data); /* cart hardware registers write handler */
|
||||
} T_CART_HW;
|
||||
|
||||
/* Cartridge type */
|
||||
typedef struct
|
||||
{
|
||||
uint8 *rom; /* ROM data */
|
||||
uint8 *base; /* ROM base (slot 0) */
|
||||
uint32 romsize; /* ROM size */
|
||||
uint32 mask; /* ROM mask */
|
||||
uint8 lock_on; /* 1: Lock-On port */
|
||||
uint8 jcart; /* 1: J-CART port */
|
||||
T_CART_HW hw; /* Extra hardware */
|
||||
} T_CART;
|
||||
|
||||
/* global variables */
|
||||
extern T_CART cart;
|
||||
|
||||
/* Function prototypes */
|
||||
extern void cart_hw_init();
|
||||
extern void cart_hw_reset(int hard);
|
||||
extern int cart_hw_context_save(uint8 *state);
|
||||
extern int cart_hw_context_load(uint8 *state, char *version);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,894 +0,0 @@
|
||||
/***************************************************************************************
|
||||
* Genesis Plus
|
||||
* Peripheral Input Support
|
||||
*
|
||||
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code)
|
||||
* Eke-Eke (2007,2008,2009), additional code & fixes for the GCN/Wii port
|
||||
*
|
||||
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
****************************************************************************************/
|
||||
|
||||
#include "shared.h"
|
||||
|
||||
t_input input;
|
||||
int old_system[2] = {-1,-1};
|
||||
|
||||
/************************************************************************************/
|
||||
/* */
|
||||
/* H-counter values returned in H40 & H32 modes */
|
||||
/* */
|
||||
/* Inside VDP, dot counter register is 9-bit, with only upper 8 bits being returned */
|
||||
/* */
|
||||
/* The number of dots per raster line is 342 in H32 mode and 420 in H40 mode */
|
||||
/* */
|
||||
/************************************************************************************/
|
||||
static const uint8 hc_320[210] =
|
||||
{
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
|
||||
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
|
||||
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F,
|
||||
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
|
||||
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
|
||||
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,
|
||||
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F,
|
||||
0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,
|
||||
0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6,
|
||||
0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED,
|
||||
0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD,
|
||||
0xFE, 0xFF
|
||||
};
|
||||
|
||||
static const uint8 hc_256[171] =
|
||||
{
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
|
||||
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
|
||||
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F,
|
||||
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
|
||||
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
|
||||
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,
|
||||
0x90, 0x91, 0x92, 0x93,
|
||||
0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
|
||||
0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF
|
||||
};
|
||||
|
||||
/*****************************************************************************
|
||||
* LIGHTGUN support
|
||||
*
|
||||
*****************************************************************************/
|
||||
static int x_offset;
|
||||
static int y_offset;
|
||||
|
||||
static void lightgun_reset(int num)
|
||||
{
|
||||
input.analog[num][0] = bitmap.viewport.w >> 1;
|
||||
input.analog[num][1] = bitmap.viewport.h >> 1;
|
||||
}
|
||||
|
||||
static void lightgun_update(int num)
|
||||
{
|
||||
/* update only one justifier at once */
|
||||
if (input.system[1] == SYSTEM_JUSTIFIER)
|
||||
{
|
||||
if ((io_reg[2] & 0x30) != (num << 5))
|
||||
return;
|
||||
}
|
||||
|
||||
if ((input.analog[num][1] == v_counter + y_offset))
|
||||
{
|
||||
/* HL enabled ? */
|
||||
if (io_reg[5] & 0x80)
|
||||
{
|
||||
/* External Interrupt ? */
|
||||
if (reg[11] & 0x08)
|
||||
{
|
||||
irq_status = (irq_status & 4) | 0x12;
|
||||
}
|
||||
|
||||
/* HV Counter Latch:
|
||||
1) some games does not enable HVC latch but instead use bigger X offset
|
||||
--> we force the HV counter value read by the gun routine
|
||||
2) for games using H40 mode, the gun routine scales up the Hcounter value
|
||||
--> H-Counter range is approx. 290 dot clocks
|
||||
*/
|
||||
hvc_latch = 0x10000 | (v_counter << 8);
|
||||
if (reg[12] & 1)
|
||||
{
|
||||
hvc_latch |= hc_320[((input.analog[num][0] * 290) / (2 * 320) + x_offset) % 210];
|
||||
}
|
||||
else
|
||||
{
|
||||
hvc_latch |= hc_256[(input.analog[num][0] / 2 + x_offset) % 171];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Sega Menacer specific */
|
||||
unsigned int menacer_read(void)
|
||||
{
|
||||
/* pins should return 0 by default (fix Body Count when mouse is enabled) */
|
||||
unsigned int retval = 0x00;
|
||||
if (input.pad[4] & INPUT_B) retval |= 0x01;
|
||||
if (input.pad[4] & INPUT_A) retval |= 0x02;
|
||||
if (input.pad[4] & INPUT_C) retval |= 0x04;
|
||||
if (input.pad[4] & INPUT_START) retval |= 0x08;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* Konami Justifier specific */
|
||||
unsigned int justifier_read(void)
|
||||
{
|
||||
/* TL & TR pins should always return 1 (write only) */
|
||||
/* LEFT & RIGHT pins should always return 0 (needed during gun detection) */
|
||||
unsigned int retval = 0x73;
|
||||
|
||||
switch (io_reg[2])
|
||||
{
|
||||
case 0x40: /* gun detection */
|
||||
return 0x30;
|
||||
|
||||
case 0x00: /* gun #1 enabled */
|
||||
if (input.pad[4] & INPUT_A) retval &= ~0x01;
|
||||
if (input.pad[4] & INPUT_START) retval &= ~0x02;
|
||||
return retval;
|
||||
|
||||
case 0x20: /* gun #2 enabled */
|
||||
if (input.pad[5] & INPUT_A) retval &= ~0x01;
|
||||
if (input.pad[5] & INPUT_START) retval &= ~0x02;
|
||||
return retval;
|
||||
|
||||
default: /* guns disabled */
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* SEGA MOUSE support
|
||||
*
|
||||
*****************************************************************************/
|
||||
static struct mega_mouse
|
||||
{
|
||||
uint8 State;
|
||||
uint8 Counter;
|
||||
uint8 Wait;
|
||||
uint8 Port;
|
||||
} mouse;
|
||||
|
||||
static inline void mouse_reset(void)
|
||||
{
|
||||
mouse.State = 0x60;
|
||||
mouse.Counter = 0;
|
||||
mouse.Wait = 0;
|
||||
mouse.Port = (input.system[0] == SYSTEM_MOUSE) ? 0 : 4;
|
||||
}
|
||||
|
||||
void mouse_write(unsigned int data)
|
||||
{
|
||||
if (mouse.Counter == 0)
|
||||
{
|
||||
/* TH 1->0 transition */
|
||||
if ((mouse.State&0x40) && !(data&0x40))
|
||||
{
|
||||
/* start acquisition */
|
||||
mouse.Counter = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* TR transition */
|
||||
if ((mouse.State&0x20) != (data&0x20))
|
||||
{
|
||||
mouse.Counter ++; /* increment phase */
|
||||
mouse.Wait = 1; /* mouse latency */
|
||||
|
||||
if (mouse.Counter > 9) mouse.Counter = 9;
|
||||
}
|
||||
}
|
||||
|
||||
/* end of acquisition (TH=1) */
|
||||
if (data&0x40) mouse.Counter = 0;
|
||||
|
||||
/* update internal state */
|
||||
mouse.State = data;
|
||||
}
|
||||
|
||||
unsigned int mouse_read()
|
||||
{
|
||||
unsigned int temp = 0x00;
|
||||
|
||||
switch (mouse.Counter)
|
||||
{
|
||||
case 0: /* initial */
|
||||
temp = 0x00;
|
||||
break;
|
||||
|
||||
case 1: /* xxxx1011 */
|
||||
temp = 0x0B;
|
||||
break;
|
||||
|
||||
case 2: /* xxxx1111 */
|
||||
temp = 0x0F;
|
||||
break;
|
||||
|
||||
case 3: /* xxxx1111 */
|
||||
temp = 0x0F;
|
||||
break;
|
||||
|
||||
case 4: /* Axis sign and overflow */
|
||||
if (input.analog[2][0] < 0) temp |= 0x01;
|
||||
if (input.analog[2][1] < 0) temp |= 0x02;
|
||||
if (abs(input.analog[2][0]) > 255) temp |= 0x04;
|
||||
if (abs(input.analog[2][1]) > 255) temp |= 0x08;
|
||||
break;
|
||||
|
||||
case 5: /* Buttons state */
|
||||
if (input.pad[mouse.Port] & INPUT_A) temp |= 0x01;
|
||||
if (input.pad[mouse.Port] & INPUT_C) temp |= 0x02;
|
||||
if (input.pad[mouse.Port] & INPUT_B) temp |= 0x04;
|
||||
if (input.pad[mouse.Port] & INPUT_START) temp |= 0x08;
|
||||
break;
|
||||
|
||||
case 6: /* X Axis MSB */
|
||||
temp = (input.analog[2][0] >> 4) & 0x0f;
|
||||
break;
|
||||
|
||||
case 7: /* X Axis LSB */
|
||||
temp = (input.analog[2][0] & 0x0f);
|
||||
break;
|
||||
|
||||
case 8: /* Y Axis MSB */
|
||||
temp = (input.analog[2][1] >> 4) & 0x0f;
|
||||
break;
|
||||
|
||||
case 9: /* Y Axis LSB */
|
||||
temp = (input.analog[2][1] & 0x0f);
|
||||
break;
|
||||
}
|
||||
|
||||
/* TR-TL handshaking */
|
||||
if (mouse.Wait)
|
||||
{
|
||||
/* wait before ACK, fix some buggy mouse routine (Shangai 2, Wack World,...) */
|
||||
mouse.Wait = 0;
|
||||
|
||||
/* TL = !TR */
|
||||
temp |= (~mouse.State & 0x20) >> 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* TL = TR */
|
||||
temp |= (mouse.State & 0x20) >> 1;
|
||||
}
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* GAMEPAD support (2PLAYERS/4WAYPLAY)
|
||||
*
|
||||
*****************************************************************************/
|
||||
static struct pad
|
||||
{
|
||||
uint8 State;
|
||||
uint8 Counter;
|
||||
uint8 Delay;
|
||||
} gamepad[MAX_DEVICES];
|
||||
|
||||
static inline void gamepad_raz(int i)
|
||||
{
|
||||
gamepad[i].Counter = 0;
|
||||
gamepad[i].Delay = 0;
|
||||
}
|
||||
|
||||
static inline void gamepad_reset(int i)
|
||||
{
|
||||
/* initial state (Gouketsuji Ichizoku / Power Instinct, Samurai Spirits / Samurai Shodown) */
|
||||
gamepad[i].State = 0x40;
|
||||
if (input.dev[i] == DEVICE_6BUTTON) gamepad_raz(i);
|
||||
}
|
||||
|
||||
static inline void gamepad_update(int i)
|
||||
{
|
||||
if (gamepad[i].Delay++ > 25) gamepad_raz(i);
|
||||
}
|
||||
|
||||
static inline unsigned int gamepad_read(int i)
|
||||
{
|
||||
/* bit 7 is latched, TH returns current state */
|
||||
unsigned int retval = (gamepad[i].State & 0x40) | 0x3F;
|
||||
|
||||
/* pad status */
|
||||
unsigned int pad = input.pad[i];
|
||||
|
||||
/* get current step */
|
||||
unsigned int step = retval >> 6;
|
||||
|
||||
/* add TH transitions counter */
|
||||
if (input.dev[i] == DEVICE_6BUTTON)
|
||||
{
|
||||
step += (gamepad[i].Counter & 3) << 1;
|
||||
}
|
||||
|
||||
switch (step)
|
||||
{
|
||||
case 1: /*** First High ***/
|
||||
case 3: /*** Second High ***/
|
||||
case 5: /*** Third High ***/
|
||||
|
||||
/* TH = 1 : ?1CBRLDU */
|
||||
retval &= ~(pad & 0x3F);
|
||||
break;
|
||||
|
||||
case 0: /*** First low ***/
|
||||
case 2: /*** Second low ***/
|
||||
|
||||
/* TH = 0 : ?0SA00DU */
|
||||
retval &= ~(pad & 0x03);
|
||||
retval &= ~((pad >> 2) & 0x30);
|
||||
retval &= ~0x0C;
|
||||
break;
|
||||
|
||||
/* 6buttons specific (taken from gen-hw.txt) */
|
||||
/* A 6-button gamepad allows the extra buttons to be read based on how */
|
||||
/* many times TH is switched from 1 to 0 (and not 0 to 1). Observe the */
|
||||
/* following sequence */
|
||||
/*
|
||||
TH = 1 : ?1CBRLDU 3-button pad return value
|
||||
TH = 0 : ?0SA00DU 3-button pad return value
|
||||
TH = 1 : ?1CBRLDU 3-button pad return value
|
||||
TH = 0 : ?0SA0000 D3-0 are forced to '0'
|
||||
TH = 1 : ?1CBMXYZ Extra buttons returned in D3-0
|
||||
TH = 0 : ?0SA1111 D3-0 are forced to '1'
|
||||
*/
|
||||
case 4: /*** Third Low ***/
|
||||
|
||||
/* TH = 0 : ?0SA0000 D3-0 are forced to '0'*/
|
||||
retval &= ~((pad >> 2) & 0x30);
|
||||
retval &= ~0x0F;
|
||||
break;
|
||||
|
||||
case 6: /*** Fourth Low ***/
|
||||
|
||||
/* TH = 0 : ?0SA1111 D3-0 are forced to '1'*/
|
||||
retval &= ~((pad >> 2) & 0x30);
|
||||
break;
|
||||
|
||||
case 7: /*** Fourth High ***/
|
||||
|
||||
/* TH = 1 : ?1CBMXYZ Extra buttons returned in D3-0*/
|
||||
retval &= ~(pad & 0x30);
|
||||
retval &= ~((pad >> 8) & 0x0F);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static inline void gamepad_write(int i, unsigned int data)
|
||||
{
|
||||
if (input.dev[i] == DEVICE_6BUTTON)
|
||||
{
|
||||
/* TH=0 to TH=1 transition */
|
||||
if (!(gamepad[i].State & 0x40) && (data & 0x40))
|
||||
{
|
||||
gamepad[i].Counter++;
|
||||
gamepad[i].Delay = 0;
|
||||
}
|
||||
}
|
||||
gamepad[i].State = data;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* TEAMPLAYER adapter support
|
||||
*
|
||||
*****************************************************************************/
|
||||
static struct teamplayer
|
||||
{
|
||||
uint8 State;
|
||||
uint8 Counter;
|
||||
uint8 Table[12];
|
||||
} teamplayer[2];
|
||||
|
||||
static inline void teamplayer_init(int port)
|
||||
{
|
||||
int i,padnum;
|
||||
int index = 0;
|
||||
|
||||
/* this table determines which gamepad input should be returned during acquisition sequence
|
||||
index = teamplayer read table index: 0=1st read, 1=2nd read, ...
|
||||
table = high bits are pad index, low bits are pad input shift: 0=RLDU, 4=SABC, 8=MXYZ
|
||||
*/
|
||||
for (i=0; i<4; i++)
|
||||
{
|
||||
padnum = (4 * port) + i;
|
||||
if (input.dev[padnum] == DEVICE_3BUTTON)
|
||||
{
|
||||
padnum = padnum << 4;
|
||||
teamplayer[port].Table[index++] = padnum;
|
||||
teamplayer[port].Table[index++] = padnum | 4;
|
||||
}
|
||||
else if (input.dev[(4*port) + i] == DEVICE_6BUTTON)
|
||||
{
|
||||
padnum = padnum << 4;
|
||||
teamplayer[port].Table[index++] = padnum;
|
||||
teamplayer[port].Table[index++] = padnum | 4;
|
||||
teamplayer[port].Table[index++] = padnum | 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void teamplayer_reset(int port)
|
||||
{
|
||||
teamplayer[port].State = 0x60; /* TH = 1, TR = 1 */
|
||||
teamplayer[port].Counter = 0;
|
||||
}
|
||||
|
||||
static inline unsigned int teamplayer_read(int port)
|
||||
{
|
||||
unsigned int counter = teamplayer[port].Counter;
|
||||
|
||||
/* acquisition sequence */
|
||||
switch (counter)
|
||||
{
|
||||
case 0: /* initial state: TH = 1, TR = 1 -> RLDU = 0011 */
|
||||
{
|
||||
return 0x73;
|
||||
}
|
||||
|
||||
case 1: /* start request: TH = 0, TR = 1 -> RLDU = 1111 */
|
||||
{
|
||||
return 0x3F;
|
||||
}
|
||||
|
||||
case 2:
|
||||
case 3: /* ack request: TH=0, TR=0/1 -> RLDU = 0000 */
|
||||
{
|
||||
/* TL should match TR */
|
||||
return ((teamplayer[port].State & 0x20) >> 1);
|
||||
}
|
||||
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7: /* PAD type */
|
||||
{
|
||||
unsigned int retval = input.dev[(port << 2) + (counter - 4)];
|
||||
|
||||
/* TL should match TR */
|
||||
return (((teamplayer[port].State & 0x20) >> 1) | retval);
|
||||
}
|
||||
|
||||
default: /* PAD status */
|
||||
{
|
||||
unsigned int retval = 0x0F;
|
||||
|
||||
/* SEGA teamplayer returns successively PAD1 -> PAD2 -> PAD3 -> PAD4 inputs */
|
||||
unsigned int padnum = teamplayer[port].Table[counter - 8] >> 4;
|
||||
|
||||
/* Each PAD inputs is obtained through 2 or 3 sequential reads: RLDU -> SACB -> MXYZ */
|
||||
retval &= ~(input.pad[padnum] >> (teamplayer[port].Table[counter - 8] & 0x0F));
|
||||
|
||||
/* TL should match TR */
|
||||
return (((teamplayer[port].State & 0x20) >> 1) | retval);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void teamplayer_write(int port, unsigned int data)
|
||||
{
|
||||
/* update output bits only */
|
||||
unsigned int state = (teamplayer[port].State & ~io_reg[port + 4]) | (data & io_reg[port + 4]);
|
||||
|
||||
/* TH & TR handshaking */
|
||||
if ((teamplayer[port].State ^ state) & 0x60)
|
||||
{
|
||||
if (state & 0x40)
|
||||
{
|
||||
/* TH high -> reset counter */
|
||||
teamplayer[port].Counter = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* increment counter */
|
||||
teamplayer[port].Counter ++;
|
||||
}
|
||||
|
||||
/* update internal state */
|
||||
teamplayer[port].State = state;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* 4-WAYPLAY adapter support
|
||||
*
|
||||
*****************************************************************************/
|
||||
static struct wayplay
|
||||
{
|
||||
uint8 current;
|
||||
} wayplay;
|
||||
|
||||
static inline void wayplay_write(int port, unsigned int data)
|
||||
{
|
||||
if (!port && (io_reg[4] & 0x40)) gamepad_write(wayplay.current, data);
|
||||
else wayplay.current = (data >> 4) & 0x07;
|
||||
}
|
||||
|
||||
static inline unsigned int wayplay_read(int port)
|
||||
{
|
||||
if (port) return 0x7F;
|
||||
if (wayplay.current >= 4) return 0x70; /* multitap detection (TH2 = 1) */
|
||||
return gamepad_read(wayplay.current); /* 0x0C = Pad1, 0x1C = Pad2, ... */
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* I/O wrappers
|
||||
*
|
||||
*****************************************************************************/
|
||||
unsigned int gamepad_1_read (void)
|
||||
{
|
||||
return gamepad_read(0);
|
||||
}
|
||||
|
||||
unsigned int gamepad_2_read (void)
|
||||
{
|
||||
return gamepad_read(4);
|
||||
}
|
||||
|
||||
void gamepad_1_write (unsigned int data)
|
||||
{
|
||||
if (io_reg[4] & 0x40) gamepad_write(0, data);
|
||||
}
|
||||
|
||||
void gamepad_2_write (unsigned int data)
|
||||
{
|
||||
if (io_reg[5] & 0x40) gamepad_write(4, data);
|
||||
}
|
||||
|
||||
unsigned int wayplay_1_read (void)
|
||||
{
|
||||
return wayplay_read(0);
|
||||
}
|
||||
|
||||
unsigned int wayplay_2_read (void)
|
||||
{
|
||||
return wayplay_read(1);
|
||||
}
|
||||
|
||||
void wayplay_1_write (unsigned int data)
|
||||
{
|
||||
wayplay_write(0, data);
|
||||
}
|
||||
|
||||
void wayplay_2_write (unsigned int data)
|
||||
{
|
||||
wayplay_write(1, data);
|
||||
}
|
||||
|
||||
unsigned int teamplayer_1_read (void)
|
||||
{
|
||||
return teamplayer_read(0);
|
||||
}
|
||||
|
||||
unsigned int teamplayer_2_read (void)
|
||||
{
|
||||
return teamplayer_read(1);
|
||||
}
|
||||
|
||||
void teamplayer_1_write (unsigned int data)
|
||||
{
|
||||
teamplayer_write(0, data);
|
||||
}
|
||||
|
||||
void teamplayer_2_write (unsigned int data)
|
||||
{
|
||||
teamplayer_write(1, data);
|
||||
}
|
||||
|
||||
unsigned int jcart_read(unsigned int address)
|
||||
{
|
||||
/* TH2 (output) fixed to 0 on read (fixes Micro Machines 2) */
|
||||
return ((gamepad[5].State & 0x40) | (gamepad_read(5) & 0x3f) | ((gamepad_read(6) & 0x3f) << 8));
|
||||
}
|
||||
|
||||
void jcart_write(unsigned int address, unsigned int data)
|
||||
{
|
||||
gamepad_write(5, (data & 1) << 6);
|
||||
gamepad_write(6, (data & 1) << 6);
|
||||
return;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* Generic INPUTS Control
|
||||
*
|
||||
*****************************************************************************/
|
||||
void input_init(void)
|
||||
{
|
||||
int i,j;
|
||||
int player = 0;
|
||||
|
||||
for (i=0; i<MAX_DEVICES; i++)
|
||||
{
|
||||
input.dev[i] = NO_DEVICE;
|
||||
input.pad[i] = 0;
|
||||
}
|
||||
|
||||
switch (input.system[0])
|
||||
{
|
||||
case SYSTEM_GAMEPAD:
|
||||
if (player == MAX_INPUTS) return;
|
||||
input.dev[0] = config.input[player].padtype;
|
||||
player ++;
|
||||
break;
|
||||
|
||||
case SYSTEM_MOUSE:
|
||||
if (player == MAX_INPUTS) return;
|
||||
input.dev[0] = DEVICE_MOUSE;
|
||||
player ++;
|
||||
break;
|
||||
|
||||
case SYSTEM_WAYPLAY:
|
||||
for (j=0; j< 4; j++)
|
||||
{
|
||||
if (player == MAX_INPUTS) return;
|
||||
input.dev[j] = config.input[player].padtype;
|
||||
player ++;
|
||||
}
|
||||
break;
|
||||
|
||||
case SYSTEM_TEAMPLAYER:
|
||||
for (j=0; j<4; j++)
|
||||
{
|
||||
if (player == MAX_INPUTS) return;
|
||||
input.dev[j] = config.input[player].padtype;
|
||||
player ++;
|
||||
}
|
||||
teamplayer_init(0);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (input.system[1])
|
||||
{
|
||||
case SYSTEM_GAMEPAD:
|
||||
if (player == MAX_INPUTS) return;
|
||||
input.dev[4] = config.input[player].padtype;
|
||||
player ++;
|
||||
break;
|
||||
|
||||
case SYSTEM_MOUSE:
|
||||
if (player == MAX_INPUTS) return;
|
||||
input.dev[4] = DEVICE_MOUSE;
|
||||
player ++;
|
||||
break;
|
||||
|
||||
case SYSTEM_MENACER:
|
||||
if (player == MAX_INPUTS) return;
|
||||
input.dev[4] = DEVICE_LIGHTGUN;
|
||||
player ++;
|
||||
break;
|
||||
|
||||
case SYSTEM_JUSTIFIER:
|
||||
for (j=4; j<6; j++)
|
||||
{
|
||||
if (player == MAX_INPUTS) return;
|
||||
input.dev[j] = DEVICE_LIGHTGUN;
|
||||
player ++;
|
||||
}
|
||||
break;
|
||||
|
||||
case SYSTEM_TEAMPLAYER:
|
||||
for (j=4; j<8; j++)
|
||||
{
|
||||
if (player == MAX_INPUTS) return;
|
||||
input.dev[j] = config.input[player].padtype;
|
||||
player ++;
|
||||
}
|
||||
teamplayer_init(1);
|
||||
break;
|
||||
}
|
||||
|
||||
/* J-CART: add two gamepad inputs */
|
||||
if (cart.jcart)
|
||||
{
|
||||
if (player == MAX_INPUTS) return;
|
||||
input.dev[5] = config.input[player].padtype;
|
||||
player ++;
|
||||
if (player == MAX_INPUTS) return;
|
||||
input.dev[6] = config.input[player].padtype;
|
||||
player ++;
|
||||
}
|
||||
}
|
||||
|
||||
void input_reset(void)
|
||||
{
|
||||
/* Reset Controller device */
|
||||
int i;
|
||||
for (i=0; i<MAX_DEVICES; i++)
|
||||
{
|
||||
switch (input.dev[i])
|
||||
{
|
||||
case DEVICE_3BUTTON:
|
||||
case DEVICE_6BUTTON:
|
||||
gamepad_reset(i);
|
||||
break;
|
||||
|
||||
case DEVICE_LIGHTGUN:
|
||||
lightgun_reset(i%2);
|
||||
break;
|
||||
|
||||
case DEVICE_MOUSE:
|
||||
mouse_reset();
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Team Player */
|
||||
if (input.system[0] == SYSTEM_TEAMPLAYER)
|
||||
teamplayer_reset(0);
|
||||
if (input.system[1] == SYSTEM_TEAMPLAYER)
|
||||
teamplayer_reset(1);
|
||||
|
||||
/* 4-Way Play */
|
||||
wayplay.current = 0;
|
||||
}
|
||||
|
||||
void input_refresh(void)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<MAX_DEVICES; i++)
|
||||
{
|
||||
switch (input.dev[i])
|
||||
{
|
||||
case DEVICE_6BUTTON:
|
||||
{
|
||||
gamepad_update(i);
|
||||
break;
|
||||
}
|
||||
|
||||
case DEVICE_LIGHTGUN:
|
||||
{
|
||||
lightgun_update(i%2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void input_autodetect(void)
|
||||
{
|
||||
/* restore previous settings */
|
||||
if (old_system[0] != -1)
|
||||
input.system[0] = old_system[0];
|
||||
if (old_system[1] != -1)
|
||||
input.system[1] = old_system[1];
|
||||
|
||||
/* initialize default GUN settings */
|
||||
x_offset = 0x00;
|
||||
y_offset = 0x00;
|
||||
|
||||
/**********************************************
|
||||
SEGA MENACER
|
||||
***********************************************/
|
||||
if (strstr(rominfo.international,"MENACER") != NULL)
|
||||
{
|
||||
/* save current setting */
|
||||
if (old_system[0] == -1)
|
||||
old_system[0] = input.system[0];
|
||||
if (old_system[1] == -1)
|
||||
old_system[1] = input.system[1];
|
||||
|
||||
input.system[0] = NO_SYSTEM;
|
||||
input.system[1] = SYSTEM_MENACER;
|
||||
x_offset = 0x52;
|
||||
y_offset = 0x00;
|
||||
}
|
||||
else if (strstr(rominfo.international,"T2 ; THE ARCADE GAME") != NULL)
|
||||
{
|
||||
/* save current setting */
|
||||
if (old_system[0] == -1)
|
||||
old_system[0] = input.system[0];
|
||||
if (old_system[1] == -1)
|
||||
old_system[1] = input.system[1];
|
||||
|
||||
input.system[0] = SYSTEM_GAMEPAD;
|
||||
input.system[1] = SYSTEM_MENACER;
|
||||
x_offset = 0x84;
|
||||
y_offset = 0x08;
|
||||
}
|
||||
else if (strstr(rominfo.international,"BODY COUNT") != NULL)
|
||||
{
|
||||
/* save current setting */
|
||||
if (old_system[0] == -1)
|
||||
old_system[0] = input.system[0];
|
||||
if (old_system[1] == -1)
|
||||
old_system[1] = input.system[1];
|
||||
|
||||
input.system[0] = SYSTEM_MOUSE;
|
||||
input.system[1] = SYSTEM_MENACER;
|
||||
x_offset = 0x44;
|
||||
y_offset = 0x18;
|
||||
}
|
||||
|
||||
/**********************************************
|
||||
KONAMI JUSTIFIER
|
||||
***********************************************/
|
||||
else if (strstr(rominfo.international,"LETHAL ENFORCERSII") != NULL)
|
||||
{
|
||||
/* save current setting */
|
||||
if (old_system[0] == -1)
|
||||
old_system[0] = input.system[0];
|
||||
if (old_system[1] == -1)
|
||||
old_system[1] = input.system[1];
|
||||
|
||||
input.system[0] = SYSTEM_GAMEPAD;
|
||||
input.system[1] = SYSTEM_JUSTIFIER;
|
||||
x_offset = 0x18;
|
||||
y_offset = 0x00;
|
||||
}
|
||||
else if (strstr(rominfo.international,"LETHAL ENFORCERS") != NULL)
|
||||
{
|
||||
/* save current setting */
|
||||
if (old_system[0] == -1)
|
||||
old_system[0] = input.system[0];
|
||||
if (old_system[1] == -1)
|
||||
old_system[1] = input.system[1];
|
||||
|
||||
input.system[0] = SYSTEM_GAMEPAD;
|
||||
input.system[1] = SYSTEM_JUSTIFIER;
|
||||
x_offset = 0x00;
|
||||
y_offset = 0x00;
|
||||
}
|
||||
|
||||
/**********************************************
|
||||
J-CART
|
||||
***********************************************/
|
||||
cart.jcart = 0;
|
||||
if (((strstr(rominfo.product,"00000000") != NULL) && (rominfo.checksum == 0x168b)) || /* Super Skidmarks, Micro Machines Military*/
|
||||
((strstr(rominfo.product,"00000000") != NULL) && (rominfo.checksum == 0x165e)) || /* Pete Sampras Tennis (1991), Micro Machines 96 */
|
||||
((strstr(rominfo.product,"00000000") != NULL) && (rominfo.checksum == 0xcee0)) || /* Micro Machines Military (bad) */
|
||||
((strstr(rominfo.product,"00000000") != NULL) && (rominfo.checksum == 0x2c41)) || /* Micro Machines 96 (bad) */
|
||||
((strstr(rominfo.product,"XXXXXXXX") != NULL) && (rominfo.checksum == 0xdf39)) || /* Sampras Tennis 96 */
|
||||
((strstr(rominfo.product,"T-123456") != NULL) && (rominfo.checksum == 0x1eae)) || /* Sampras Tennis 96 */
|
||||
((strstr(rominfo.product,"T-120066") != NULL) && (rominfo.checksum == 0x16a4)) || /* Pete Sampras Tennis (1994)*/
|
||||
(strstr(rominfo.product,"T-120096") != NULL)) /* Micro Machines 2 */
|
||||
{
|
||||
if (cart.romsize <= 0x380000) /* just to be sure (checksum might not be enough) */
|
||||
{
|
||||
cart.jcart = 1;
|
||||
|
||||
/* set default port 1 setting */
|
||||
if (input.system[1] != SYSTEM_WAYPLAY)
|
||||
{
|
||||
old_system[1] = input.system[1];
|
||||
input.system[1] = SYSTEM_GAMEPAD;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,98 +0,0 @@
|
||||
/***************************************************************************************
|
||||
* Genesis Plus
|
||||
* Peripheral Input Support
|
||||
*
|
||||
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code)
|
||||
* Eke-Eke (2007,2008,2009), additional code & fixes for the GCN/Wii port
|
||||
*
|
||||
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef _GEN_INPUT_H_
|
||||
#define _GEN_INPUT_H_
|
||||
|
||||
/* Max. number of devices */
|
||||
#define MAX_DEVICES (8)
|
||||
|
||||
/* Device types */
|
||||
#define DEVICE_3BUTTON (0x00) /* 3-button gamepad */
|
||||
#define DEVICE_6BUTTON (0x01) /* 6-button gamepad */
|
||||
#define DEVICE_LIGHTGUN (0x02) /* Sega Menacer or Konami Justifier */
|
||||
#define DEVICE_MOUSE (0x03) /* Sega Mouse */
|
||||
#define DEVICE_2BUTTON (0x04) /* 2-button gamepad (not supported) */
|
||||
#define NO_DEVICE (0x0F) /* unconnected */
|
||||
|
||||
/* Input bitmasks */
|
||||
#define INPUT_MODE (0x0800)
|
||||
#define INPUT_X (0x0400)
|
||||
#define INPUT_Y (0x0200)
|
||||
#define INPUT_Z (0x0100)
|
||||
#define INPUT_START (0x0080)
|
||||
#define INPUT_A (0x0040)
|
||||
#define INPUT_C (0x0020)
|
||||
#define INPUT_B (0x0010)
|
||||
#define INPUT_RIGHT (0x0008)
|
||||
#define INPUT_LEFT (0x0004)
|
||||
#define INPUT_DOWN (0x0002)
|
||||
#define INPUT_UP (0x0001)
|
||||
|
||||
/* System IO ports */
|
||||
#define NO_SYSTEM (0) /* Unconnected Port*/
|
||||
#define SYSTEM_GAMEPAD (1) /* Single Gamepad */
|
||||
#define SYSTEM_MOUSE (2) /* Sega Mouse */
|
||||
#define SYSTEM_MENACER (3) /* Sega Menacer (port 2) */
|
||||
#define SYSTEM_JUSTIFIER (4) /* Konami Justifier (port 2) */
|
||||
#define SYSTEM_TEAMPLAYER (5) /* Sega TeamPlayer */
|
||||
#define SYSTEM_WAYPLAY (6) /* EA 4-Way Play (use both ports) */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8 dev[MAX_DEVICES]; /* Can be one of the DEVICE_* values */
|
||||
uint16 pad[MAX_DEVICES]; /* Can be any of the INPUT_* bitmasks */
|
||||
uint8 system[2]; /* Can be one of the SYSTEM_* values */
|
||||
int analog[3][2]; /* Analog devices */
|
||||
} t_input;
|
||||
|
||||
/* Global variables */
|
||||
extern t_input input;
|
||||
|
||||
/* Function prototypes */
|
||||
extern void input_init(void);
|
||||
extern void input_reset(void);
|
||||
extern void input_refresh(void);
|
||||
extern void input_autodetect(void);
|
||||
|
||||
/* Peripherals specific */
|
||||
extern void mouse_write(uint32 data);
|
||||
extern uint32 mouse_read(void);
|
||||
extern uint32 menacer_read (void);
|
||||
extern uint32 justifier_read (void);
|
||||
extern uint32 gamepad_1_read (void);
|
||||
extern uint32 gamepad_2_read (void);
|
||||
extern void gamepad_1_write (uint32 data);
|
||||
extern void gamepad_2_write (uint32 data);
|
||||
extern uint32 wayplay_1_read (void);
|
||||
extern uint32 wayplay_2_read (void);
|
||||
extern void wayplay_1_write (uint32 data);
|
||||
extern void wayplay_2_write (uint32 data);
|
||||
extern uint32 teamplayer_1_read (void);
|
||||
extern uint32 teamplayer_2_read (void);
|
||||
extern void teamplayer_1_write (uint32 data);
|
||||
extern void teamplayer_2_write (uint32 data);
|
||||
extern uint32 jcart_read(uint32 address);
|
||||
extern void jcart_write(uint32 address, uint32 data);
|
||||
|
||||
#endif
|
204
source/gen_io.c
204
source/gen_io.c
@ -1,204 +0,0 @@
|
||||
/***************************************************************************************
|
||||
* Genesis Plus
|
||||
* I/O Chip
|
||||
*
|
||||
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code)
|
||||
* Eke-Eke (2007,2008,2009), additional code & fixes for the GCN/Wii port
|
||||
*
|
||||
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
****************************************************************************************/
|
||||
|
||||
#include "shared.h"
|
||||
|
||||
uint8 io_reg[0x10];
|
||||
uint8 region_code = REGION_USA;
|
||||
|
||||
static struct port_t
|
||||
{
|
||||
void (*data_w)(unsigned int data);
|
||||
unsigned int (*data_r)(void);
|
||||
} port[3];
|
||||
|
||||
static void dummy_write(unsigned int data)
|
||||
{
|
||||
}
|
||||
|
||||
static unsigned int dummy_read(void)
|
||||
{
|
||||
return 0x7F;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* I/O chip functions *
|
||||
* *
|
||||
*****************************************************************************/
|
||||
void io_init(void)
|
||||
{
|
||||
/* Initialize IO Ports handlers */
|
||||
switch (input.system[0])
|
||||
{
|
||||
case SYSTEM_GAMEPAD:
|
||||
port[0].data_w = gamepad_1_write;
|
||||
port[0].data_r = gamepad_1_read;
|
||||
break;
|
||||
|
||||
case SYSTEM_MOUSE:
|
||||
port[0].data_w = mouse_write;
|
||||
port[0].data_r = mouse_read;
|
||||
break;
|
||||
|
||||
case SYSTEM_WAYPLAY:
|
||||
port[0].data_w = wayplay_1_write;
|
||||
port[0].data_r = wayplay_1_read;
|
||||
break;
|
||||
|
||||
case SYSTEM_TEAMPLAYER:
|
||||
port[0].data_w = teamplayer_1_write;
|
||||
port[0].data_r = teamplayer_1_read;
|
||||
break;
|
||||
|
||||
default:
|
||||
port[0].data_w = dummy_write;
|
||||
port[0].data_r = dummy_read;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (input.system[1])
|
||||
{
|
||||
case SYSTEM_GAMEPAD:
|
||||
port[1].data_w = gamepad_2_write;
|
||||
port[1].data_r = gamepad_2_read;
|
||||
break;
|
||||
|
||||
case SYSTEM_MOUSE:
|
||||
port[1].data_w = mouse_write;
|
||||
port[1].data_r = mouse_read;
|
||||
break;
|
||||
|
||||
case SYSTEM_MENACER:
|
||||
port[1].data_w = dummy_write;
|
||||
port[1].data_r = menacer_read;
|
||||
break;
|
||||
|
||||
case SYSTEM_JUSTIFIER:
|
||||
port[1].data_w = dummy_write;
|
||||
port[1].data_r = justifier_read;
|
||||
break;
|
||||
|
||||
case SYSTEM_WAYPLAY:
|
||||
port[1].data_w = wayplay_2_write;
|
||||
port[1].data_r = wayplay_2_read;
|
||||
break;
|
||||
|
||||
case SYSTEM_TEAMPLAYER:
|
||||
port[1].data_w = teamplayer_2_write;
|
||||
port[1].data_r = teamplayer_2_read;
|
||||
break;
|
||||
|
||||
default:
|
||||
port[1].data_w = dummy_write;
|
||||
port[1].data_r = dummy_read;
|
||||
break;
|
||||
}
|
||||
|
||||
/* External Port (unconnected) */
|
||||
port[2].data_w = dummy_write;
|
||||
port[2].data_r = dummy_read;
|
||||
|
||||
/* Initialize connected input devices */
|
||||
input_init();
|
||||
}
|
||||
|
||||
|
||||
void io_reset(void)
|
||||
{
|
||||
/* Reset I/O registers */
|
||||
io_reg[0x00] = region_code | 0x20 | (config.tmss & 1);
|
||||
io_reg[0x01] = 0x00;
|
||||
io_reg[0x02] = 0x00;
|
||||
io_reg[0x03] = 0x00;
|
||||
io_reg[0x04] = 0x00;
|
||||
io_reg[0x05] = 0x00;
|
||||
io_reg[0x06] = 0x00;
|
||||
io_reg[0x07] = 0xFF;
|
||||
io_reg[0x08] = 0x00;
|
||||
io_reg[0x09] = 0x00;
|
||||
io_reg[0x0A] = 0xFF;
|
||||
io_reg[0x0B] = 0x00;
|
||||
io_reg[0x0C] = 0x00;
|
||||
io_reg[0x0D] = 0xFB;
|
||||
io_reg[0x0E] = 0x00;
|
||||
io_reg[0x0F] = 0x00;
|
||||
|
||||
/* Reset connected input devices */
|
||||
input_reset();
|
||||
}
|
||||
|
||||
void io_write(unsigned int offset, unsigned int data)
|
||||
{
|
||||
switch (offset)
|
||||
{
|
||||
case 0x01: /* Port A Data */
|
||||
case 0x02: /* Port B Data */
|
||||
case 0x03: /* Port C Data */
|
||||
io_reg[offset] = data;
|
||||
port[offset-1].data_w(data);
|
||||
return;
|
||||
|
||||
case 0x04: /* Port A Ctrl */
|
||||
case 0x05: /* Port B Ctrl */
|
||||
case 0x06: /* Port C Ctrl */
|
||||
if (data != io_reg[offset])
|
||||
{
|
||||
io_reg[offset] = data;
|
||||
port[offset-4].data_w(io_reg[offset-3]);
|
||||
}
|
||||
return;
|
||||
|
||||
case 0x07: /* Port A TxData */
|
||||
case 0x0A: /* Port B TxData */
|
||||
case 0x0D: /* Port C TxData */
|
||||
io_reg[offset] = data;
|
||||
return;
|
||||
|
||||
case 0x09: /* Port A S-Ctrl */
|
||||
case 0x0C: /* Port B S-Ctrl */
|
||||
case 0x0F: /* Port C S-Ctrl */
|
||||
io_reg[offset] = data & 0xF8;
|
||||
return;
|
||||
|
||||
default: /* Read-only ports */
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int io_read(unsigned int offset)
|
||||
{
|
||||
switch(offset)
|
||||
{
|
||||
case 0x01: /* Port A Data */
|
||||
case 0x02: /* Port B Data */
|
||||
case 0x03: /* Port C Data */
|
||||
{
|
||||
unsigned int mask = 0x80 | io_reg[offset + 3];
|
||||
unsigned int data = port[offset-1].data_r();
|
||||
return (io_reg[offset] & mask) | (data & ~mask);
|
||||
}
|
||||
|
||||
default: /* return register value */
|
||||
return io_reg[offset];
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
/***************************************************************************************
|
||||
* Genesis Plus
|
||||
* I/O Chip
|
||||
*
|
||||
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code)
|
||||
* Eke-Eke (2007,2008,2009), additional code & fixes for the GCN/Wii port
|
||||
*
|
||||
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef _GEN_IO_H_
|
||||
#define _GEN_IO_H_
|
||||
|
||||
#define REGION_JAPAN_NTSC 0x00
|
||||
#define REGION_JAPAN_PAL 0x40
|
||||
#define REGION_USA 0x80
|
||||
#define REGION_EUROPE 0xC0
|
||||
|
||||
/* Global variables */
|
||||
extern uint8 io_reg[0x10];
|
||||
extern uint8 region_code;
|
||||
extern int old_system[2];
|
||||
|
||||
/* Function prototypes */
|
||||
extern void io_init(void);
|
||||
extern void io_reset(void);
|
||||
extern void io_write(unsigned int offset, unsigned int data);
|
||||
extern unsigned int io_read(unsigned int offset);
|
||||
|
||||
#endif /* _IO_H_ */
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 5.1 KiB |
1977
source/render.c
1977
source/render.c
File diff suppressed because it is too large
Load Diff
@ -1,44 +0,0 @@
|
||||
/***************************************************************************************
|
||||
* Genesis Plus
|
||||
* Video Display Processor (Rendering)
|
||||
*
|
||||
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code)
|
||||
* Eke-Eke (2007,2008,2009), additional code & fixes for the GCN/Wii port
|
||||
*
|
||||
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef _RENDER_H_
|
||||
#define _RENDER_H_
|
||||
|
||||
/* Global variables */
|
||||
extern uint8 object_count[2];
|
||||
extern uint8 object_which;
|
||||
|
||||
/* Function prototypes */
|
||||
extern void render_init(void);
|
||||
extern void render_reset(void);
|
||||
extern void render_shutdown(void);
|
||||
extern void render_line(int line);
|
||||
extern void remap_buffer(int line);
|
||||
extern void blank_line(int line, int offset, int width);
|
||||
extern void window_clip(void);
|
||||
extern void parse_satb(int line);
|
||||
|
||||
void (*color_update)(int index, uint16 data);
|
||||
|
||||
#endif /* _RENDER_H_ */
|
||||
|
1324
source/vdp.c
1324
source/vdp.c
File diff suppressed because it is too large
Load Diff
79
source/vdp.h
79
source/vdp.h
@ -1,79 +0,0 @@
|
||||
/***************************************************************************************
|
||||
* Genesis Plus
|
||||
* Video Display Processor (memory handlers)
|
||||
*
|
||||
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code)
|
||||
* Eke-Eke (2007,2008,2009), additional code & fixes for the GCN/Wii port
|
||||
*
|
||||
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef _VDP_H_
|
||||
#define _VDP_H_
|
||||
|
||||
/* VDP context */
|
||||
extern uint8 sat[0x400];
|
||||
extern uint8 vram[0x10000];
|
||||
extern uint8 cram[0x80];
|
||||
extern uint8 vsram[0x80];
|
||||
extern uint8 reg[0x20];
|
||||
extern uint8 hint_pending;
|
||||
extern uint8 vint_pending;
|
||||
extern uint8 irq_status;
|
||||
extern uint16 status;
|
||||
extern uint32 dma_length;
|
||||
|
||||
/* Global variables */
|
||||
extern uint16 ntab;
|
||||
extern uint16 ntbb;
|
||||
extern uint16 ntwb;
|
||||
extern uint16 satb;
|
||||
extern uint16 hscb;
|
||||
|
||||
extern uint8 bg_name_dirty[0x800];
|
||||
extern uint16 bg_name_list[0x800];
|
||||
extern uint16 bg_list_index;
|
||||
extern uint8 bg_pattern_cache[0x80000];
|
||||
extern uint8 playfield_shift;
|
||||
extern uint8 playfield_col_mask;
|
||||
extern uint16 playfield_row_mask;
|
||||
extern uint16 v_counter;
|
||||
extern int32 fifo_write_cnt;
|
||||
extern uint32 fifo_lastwrite;
|
||||
extern uint8 im2_flag;
|
||||
extern uint8 interlaced;
|
||||
extern uint8 odd_frame;
|
||||
extern uint8 vdp_pal;
|
||||
extern uint16 lines_per_frame;
|
||||
extern uint32 hvc_latch;
|
||||
extern uint32 vc_max;
|
||||
|
||||
/* Function prototypes */
|
||||
extern void vdp_init(void);
|
||||
extern void vdp_reset(void);
|
||||
extern void vdp_shutdown(void);
|
||||
extern int vdp_context_save(uint8 *state);
|
||||
extern int vdp_context_load(uint8 *state, char *version);
|
||||
extern void vdp_update_dma(unsigned int cycles);
|
||||
extern void vdp_ctrl_w(unsigned int data);
|
||||
extern unsigned int vdp_ctrl_r(unsigned int cycles);
|
||||
extern void vdp_data_w(unsigned int data);
|
||||
extern unsigned int vdp_data_r(void);
|
||||
extern unsigned int vdp_hvc_r(unsigned int cycles);
|
||||
extern void vdp_test_w(unsigned int data);
|
||||
extern int vdp_int_ack_callback(int int_level);
|
||||
|
||||
#endif /* _VDP_H_ */
|
@ -1,59 +0,0 @@
|
||||
|
||||
#ifndef CPUINTRF_H
|
||||
#define CPUINTRF_H
|
||||
|
||||
#include "osd_cpu.h"
|
||||
|
||||
/* Interrupt line constants */
|
||||
enum
|
||||
{
|
||||
/* line states */
|
||||
CLEAR_LINE = 0, /* clear (a fired, held or pulsed) line */
|
||||
ASSERT_LINE, /* assert an interrupt immediately */
|
||||
HOLD_LINE, /* hold interrupt line until acknowledged */
|
||||
PULSE_LINE, /* pulse interrupt line for one instruction */
|
||||
|
||||
/* internal flags (not for use by drivers!) */
|
||||
INTERNAL_CLEAR_LINE = 100 + CLEAR_LINE,
|
||||
INTERNAL_ASSERT_LINE = 100 + ASSERT_LINE,
|
||||
|
||||
/* input lines */
|
||||
MAX_INPUT_LINES = 32+3,
|
||||
INPUT_LINE_IRQ0 = 0,
|
||||
INPUT_LINE_IRQ1 = 1,
|
||||
INPUT_LINE_IRQ2 = 2,
|
||||
INPUT_LINE_IRQ3 = 3,
|
||||
INPUT_LINE_IRQ4 = 4,
|
||||
INPUT_LINE_IRQ5 = 5,
|
||||
INPUT_LINE_IRQ6 = 6,
|
||||
INPUT_LINE_IRQ7 = 7,
|
||||
INPUT_LINE_IRQ8 = 8,
|
||||
INPUT_LINE_IRQ9 = 9,
|
||||
INPUT_LINE_NMI = MAX_INPUT_LINES - 3,
|
||||
|
||||
/* special input lines that are implemented in the core */
|
||||
INPUT_LINE_RESET = MAX_INPUT_LINES - 2,
|
||||
INPUT_LINE_HALT = MAX_INPUT_LINES - 1,
|
||||
|
||||
/* output lines */
|
||||
MAX_OUTPUT_LINES = 32
|
||||
};
|
||||
|
||||
|
||||
/* daisy-chain link */
|
||||
typedef struct {
|
||||
void (*reset)(int); /* reset callback */
|
||||
int (*interrupt_entry)(int); /* entry callback */
|
||||
void (*interrupt_reti)(int); /* reti callback */
|
||||
int irq_param; /* callback paramater */
|
||||
} Z80_DaisyChain;
|
||||
|
||||
#define Z80_MAXDAISY 4 /* maximum of daisy chan device */
|
||||
|
||||
#define Z80_INT_REQ 0x01 /* interrupt request mask */
|
||||
#define Z80_INT_IEO 0x02 /* interrupt disable mask(IEO) */
|
||||
|
||||
#define Z80_VECTOR(device,state) (((device)<<8)|(state))
|
||||
|
||||
|
||||
#endif /* CPUINTRF_H */
|
Loading…
Reference in New Issue
Block a user