Added device paramter to 6526 callbacks

This commit is contained in:
Nathan Woods 2008-12-05 12:09:35 +00:00
parent 3125b5e60e
commit b7da4d6684
7 changed files with 57 additions and 61 deletions

View File

@ -58,8 +58,8 @@ struct _cia_port
UINT8 latch;
UINT8 in;
UINT8 out;
UINT8 (*read)(void);
void (*write)(UINT8);
UINT8 (*read)(const device_config *);
void (*write)(const device_config *, UINT8);
UINT8 mask_value; /* in READ operation the value can be forced by a extern electric circuit */
};
@ -612,7 +612,7 @@ READ8_DEVICE_HANDLER( cia_r )
case CIA_PRA:
case CIA_PRB:
port = &cia->port[offset & 1];
data = port->read ? (*port->read)() : 0;
data = port->read ? (*port->read)(device) : 0;
data = ((data & ~port->ddr) | (port->latch & port->ddr)) & port->mask_value;
port->in = data;
@ -727,8 +727,8 @@ WRITE8_DEVICE_HANDLER( cia_w )
port = &cia->port[offset & 1];
port->latch = data;
port->out = (data & port->ddr) | (port->in & ~port->ddr);
if (port->write)
(*port->write)(port->out);
if (port->write != NULL)
(*port->write)(device, port->out);
break;
/* port A/B direction */

View File

@ -32,8 +32,9 @@ struct _cia6526_interface
struct
{
UINT8 (*read)(void);
void (*write)(UINT8);
UINT8 (*read)(const device_config *);
void (*write)(const device_config *, UINT8);
} port[2];
};

View File

@ -22,7 +22,6 @@
#include "driver.h"
#include "render.h"
#include "deprecat.h"
#include "includes/amiga.h"
#include "machine/laserdsc.h"
#include "machine/6526cia.h"
@ -196,52 +195,52 @@ static CUSTOM_INPUT( lightgun_holster_r )
*
*************************************/
static void alg_cia_0_porta_w(UINT8 data)
static void alg_cia_0_porta_w(const device_config *device, UINT8 data)
{
/* switch banks as appropriate */
memory_set_bank(Machine, 1, data & 1);
memory_set_bank(device->machine, 1, data & 1);
/* swap the write handlers between ROM and bank 1 based on the bit */
if ((data & 1) == 0)
/* overlay disabled, map RAM on 0x000000 */
memory_install_write16_handler(cpu_get_address_space(Machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x000000, 0x07ffff, 0, 0, SMH_BANK1);
memory_install_write16_handler(cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x000000, 0x07ffff, 0, 0, SMH_BANK1);
else
/* overlay enabled, map Amiga system ROM on 0x000000 */
memory_install_write16_handler(cpu_get_address_space(Machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x000000, 0x07ffff, 0, 0, SMH_UNMAP);
memory_install_write16_handler(cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x000000, 0x07ffff, 0, 0, SMH_UNMAP);
}
static UINT8 alg_cia_0_porta_r(void)
static UINT8 alg_cia_0_porta_r(const device_config *device)
{
return input_port_read(Machine, "FIRE") | 0x3f;
return input_port_read(device->machine, "FIRE") | 0x3f;
}
static UINT8 alg_cia_0_portb_r(void)
static UINT8 alg_cia_0_portb_r(const device_config *device)
{
logerror("%06x:alg_cia_0_portb_r\n", cpu_get_pc(Machine->activecpu));
logerror("%06x:alg_cia_0_portb_r\n", cpu_get_pc(device->machine->activecpu));
return 0xff;
}
static void alg_cia_0_portb_w(UINT8 data)
static void alg_cia_0_portb_w(const device_config *device, UINT8 data)
{
/* parallel port */
logerror("%06x:alg_cia_0_portb_w(%02x)\n", cpu_get_pc(Machine->activecpu), data);
logerror("%06x:alg_cia_0_portb_w(%02x)\n", cpu_get_pc(device->machine->activecpu), data);
}
static UINT8 alg_cia_1_porta_r(void)
static UINT8 alg_cia_1_porta_r(const device_config *device)
{
logerror("%06x:alg_cia_1_porta_r\n", cpu_get_pc(Machine->activecpu));
logerror("%06x:alg_cia_1_porta_r\n", cpu_get_pc(device->machine->activecpu));
return 0xff;
}
static void alg_cia_1_porta_w(UINT8 data)
static void alg_cia_1_porta_w(const device_config *device, UINT8 data)
{
logerror("%06x:alg_cia_1_porta_w(%02x)\n", cpu_get_pc(Machine->activecpu), data);
logerror("%06x:alg_cia_1_porta_w(%02x)\n", cpu_get_pc(device->machine->activecpu), data);
}

View File

@ -48,7 +48,6 @@
***************************************************************************/
#include "driver.h"
#include "deprecat.h"
#include "sound/custom.h"
#include "includes/amiga.h"
#include "machine/6526cia.h"
@ -93,24 +92,24 @@ static WRITE16_HANDLER( arcadia_multibios_change_game )
*
*************************************/
static UINT8 arcadia_cia_0_porta_r(void)
static UINT8 arcadia_cia_0_porta_r(const device_config *device)
{
return input_port_read(Machine, "CIA0PORTA");
return input_port_read(device->machine, "CIA0PORTA");
}
static void arcadia_cia_0_porta_w(UINT8 data)
static void arcadia_cia_0_porta_w(const device_config *device, UINT8 data)
{
/* switch banks as appropriate */
memory_set_bank(Machine, 1, data & 1);
memory_set_bank(device->machine, 1, data & 1);
/* swap the write handlers between ROM and bank 1 based on the bit */
if ((data & 1) == 0)
/* overlay disabled, map RAM on 0x000000 */
memory_install_write16_handler(cpu_get_address_space(Machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x000000, 0x07ffff, 0, 0, SMH_BANK1);
memory_install_write16_handler(cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x000000, 0x07ffff, 0, 0, SMH_BANK1);
else
/* overlay enabled, map Amiga system ROM on 0x000000 */
memory_install_write16_handler(cpu_get_address_space(Machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x000000, 0x07ffff, 0, 0, SMH_UNMAP);
memory_install_write16_handler(cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x000000, 0x07ffff, 0, 0, SMH_UNMAP);
/* bit 2 = Power Led on Amiga */
set_led_status(0, (data & 2) ? 0 : 1);
@ -133,12 +132,12 @@ static void arcadia_cia_0_porta_w(UINT8 data)
*
*************************************/
static UINT8 arcadia_cia_0_portb_r(void)
static UINT8 arcadia_cia_0_portb_r(const device_config *device)
{
return input_port_read(Machine, "CIA0PORTB");
return input_port_read(device->machine, "CIA0PORTB");
}
static void arcadia_cia_0_portb_w(UINT8 data)
static void arcadia_cia_0_portb_w(const device_config *device, UINT8 data)
{
/* writing a 0 in the low bit clears one of the coins */
if ((data & 1) == 0)

View File

@ -45,7 +45,6 @@
*/
#include "driver.h"
#include "deprecat.h"
#include "sound/custom.h"
#include "includes/amiga.h"
#include "includes/cubocd32.h"
@ -85,12 +84,12 @@ static WRITE32_HANDLER( aga_overlay_w )
*
*************************************/
static UINT8 cd32_cia_0_porta_r(void)
static UINT8 cd32_cia_0_porta_r(const device_config *device)
{
return input_port_read(Machine, "CIA0PORTA");
return input_port_read(device->machine, "CIA0PORTA");
}
static void cd32_cia_0_porta_w(UINT8 data)
static void cd32_cia_0_porta_w(const device_config *device, UINT8 data)
{
/* bit 1 = cd audio mute */
sndti_set_output_gain(SOUND_CDDA, 0, 0, ( data & 1 ) ? 0.0 : 1.0 );
@ -114,17 +113,17 @@ static void cd32_cia_0_porta_w(UINT8 data)
*
*************************************/
static UINT8 cd32_cia_0_portb_r(void)
static UINT8 cd32_cia_0_portb_r(const device_config *device)
{
/* parallel port */
logerror("%06x:CIA0_portb_r\n", cpu_get_pc(Machine->activecpu));
logerror("%06x:CIA0_portb_r\n", cpu_get_pc(device->machine->activecpu));
return 0xff;
}
static void cd32_cia_0_portb_w(UINT8 data)
static void cd32_cia_0_portb_w(const device_config *device, UINT8 data)
{
/* parallel port */
logerror("%06x:CIA0_portb_w(%02x)\n", cpu_get_pc(Machine->activecpu), data);
logerror("%06x:CIA0_portb_w(%02x)\n", cpu_get_pc(device->machine->activecpu), data);
}
static ADDRESS_MAP_START( cd32_map, ADDRESS_SPACE_PROGRAM, 32 )

View File

@ -8,7 +8,6 @@
#include "driver.h"
#include "deprecat.h"
#include "includes/amiga.h"
#include "sound/es5503.h"
#include "machine/6526cia.h"
@ -30,24 +29,24 @@
*
*************************************/
static UINT8 mquake_cia_0_porta_r(void)
static UINT8 mquake_cia_0_porta_r(const device_config *device)
{
return input_port_read(Machine, "CIA0PORTA");
return input_port_read(device->machine, "CIA0PORTA");
}
static void mquake_cia_0_porta_w(UINT8 data)
static void mquake_cia_0_porta_w(const device_config *device, UINT8 data)
{
/* switch banks as appropriate */
memory_set_bank(Machine, 1, data & 1);
memory_set_bank(device->machine, 1, data & 1);
/* swap the write handlers between ROM and bank 1 based on the bit */
if ((data & 1) == 0)
/* overlay disabled, map RAM on 0x000000 */
memory_install_write16_handler(cpu_get_address_space(Machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x000000, 0x07ffff, 0, 0, SMH_BANK1);
memory_install_write16_handler(cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x000000, 0x07ffff, 0, 0, SMH_BANK1);
else
/* overlay enabled, map Amiga system ROM on 0x000000 */
memory_install_write16_handler(cpu_get_address_space(Machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x000000, 0x07ffff, 0, 0, SMH_UNMAP);
memory_install_write16_handler(cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x000000, 0x07ffff, 0, 0, SMH_UNMAP);
}
@ -67,17 +66,17 @@ static void mquake_cia_0_porta_w(UINT8 data)
*
*************************************/
static UINT8 mquake_cia_0_portb_r(void)
static UINT8 mquake_cia_0_portb_r(const device_config *device)
{
/* parallel port */
logerror("%06x:CIA0_portb_r\n", cpu_get_pc(Machine->activecpu));
logerror("%06x:CIA0_portb_r\n", cpu_get_pc(device->machine->activecpu));
return 0xff;
}
static void mquake_cia_0_portb_w(UINT8 data)
static void mquake_cia_0_portb_w(const device_config *device, UINT8 data)
{
/* parallel port */
logerror("%06x:CIA0_portb_w(%02x)\n", cpu_get_pc(Machine->activecpu), data);
logerror("%06x:CIA0_portb_w(%02x)\n", cpu_get_pc(device->machine->activecpu), data);
}

View File

@ -24,7 +24,6 @@
**********************************************************************************/
#include "driver.h"
#include "deprecat.h"
#include "includes/amiga.h"
#include "machine/6526cia.h"
@ -81,19 +80,19 @@ static void upscope_reset(void)
*
*************************************/
static void upscope_cia_0_porta_w(UINT8 data)
static void upscope_cia_0_porta_w(const device_config *device, UINT8 data)
{
/* switch banks as appropriate */
memory_set_bank(Machine, 1, data & 1);
memory_set_bank(device->machine, 1, data & 1);
/* swap the write handlers between ROM and bank 1 based on the bit */
if ((data & 1) == 0)
/* overlay disabled, map RAM on 0x000000 */
memory_install_write16_handler(cpu_get_address_space(Machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x000000, 0x07ffff, 0, 0, SMH_BANK1);
memory_install_write16_handler(cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x000000, 0x07ffff, 0, 0, SMH_BANK1);
else
/* overlay enabled, map Amiga system ROM on 0x000000 */
memory_install_write16_handler(cpu_get_address_space(Machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x000000, 0x07ffff, 0, 0, SMH_UNMAP);
memory_install_write16_handler(cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x000000, 0x07ffff, 0, 0, SMH_UNMAP);
}
@ -113,12 +112,12 @@ static void upscope_cia_0_porta_w(UINT8 data)
*
*************************************/
static void upscope_cia_0_portb_w(UINT8 data)
static void upscope_cia_0_portb_w(const device_config *device, UINT8 data)
{
parallel_data = data;
}
static UINT8 upscope_cia_0_portb_r(void)
static UINT8 upscope_cia_0_portb_r(const device_config *device)
{
return nvram_data_latch;
}
@ -140,12 +139,12 @@ static UINT8 upscope_cia_0_portb_r(void)
*
*************************************/
static UINT8 upscope_cia_1_porta_r(void)
static UINT8 upscope_cia_1_porta_r(const device_config *device)
{
return 0xf8 | (prev_cia1_porta & 0x07);
}
static void upscope_cia_1_porta_w(UINT8 data)
static void upscope_cia_1_porta_w(const device_config *device, UINT8 data)
{
/* on a low transition of POUT, we latch stuff for the NVRAM */
if ((prev_cia1_porta & 2) && !(data & 2))
@ -211,7 +210,7 @@ static void upscope_cia_1_porta_w(UINT8 data)
if (data & 4)
{
if (LOG_IO) logerror("Internal register (%d) read\n", nvram_address_latch);
nvram_data_latch = (nvram_address_latch == 0) ? input_port_read(Machine, "IO0") : 0xff;
nvram_data_latch = (nvram_address_latch == 0) ? input_port_read(device->machine, "IO0") : 0xff;
}
/* if SEL == 0, we read NVRAM */