summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2008-12-21 03:07:52 +0000
committer Aaron Giles <aaron@aarongiles.com>2008-12-21 03:07:52 +0000
commitdc63238265c4befa115ef60a05c509e226e5cb43 (patch)
treec28e1b95a33a7f8225bf1947770532112a1fd2c6
parentd617d4369da72f43817072440db34a5d057caa3f (diff)
From: Atari Ace [mailto:atari_ace@verizon.net]
Sent: Friday, December 19, 2008 8:50 PM To: submit@mamedev.org Cc: atariace@hotmail.com Subject: [patch] Add machine/space to some callbacks Hi mamedev, This patch widens some machine callbacks to include an object (either machine or space). I didn't convert these earlier since MAME didn't explicitly need them, but some of these will be needed by MESS now that Machine is gone and in general all callbacks need to pass an object. ~aa
-rw-r--r--src/emu/machine/74153.c9
-rw-r--r--src/emu/machine/74153.h4
-rw-r--r--src/emu/machine/microtch.c9
-rw-r--r--src/emu/machine/microtch.h5
-rw-r--r--src/emu/machine/pcshare.h4
-rw-r--r--src/emu/machine/rtc65271.c11
-rw-r--r--src/emu/machine/rtc65271.h2
-rw-r--r--src/mame/drivers/gamecstl.c2
-rw-r--r--src/mame/drivers/mediagx.c2
-rw-r--r--src/mame/drivers/meritm.c2
-rw-r--r--src/mame/drivers/taitowlf.c2
-rw-r--r--src/mame/machine/carpolo.c2
-rw-r--r--src/mame/machine/pcshare.c61
13 files changed, 63 insertions, 52 deletions
diff --git a/src/emu/machine/74153.c b/src/emu/machine/74153.c
index b8f1109d830..4cc3fb046cd 100644
--- a/src/emu/machine/74153.c
+++ b/src/emu/machine/74153.c
@@ -41,8 +41,10 @@
struct TTL74153
{
+ running_machine *machine;
+
/* callback */
- void (*output_cb)(void);
+ void (*output_cb)(running_machine *machine);
/* inputs */
int a; /* pin 14 */
@@ -87,7 +89,7 @@ void TTL74153_update(int which)
chips[which].last_output[0] = chips[which].output[0];
chips[which].last_output[1] = chips[which].output[1];
- chips[which].output_cb();
+ chips[which].output_cb(chips[which].machine);
}
}
@@ -123,7 +125,7 @@ int TTL74153_output_r(int which, int section)
-void TTL74153_config(int which, const struct TTL74153_interface *intf)
+void TTL74153_config(running_machine *machine, int which, const struct TTL74153_interface *intf)
{
if (which >= MAX_TTL74153)
{
@@ -132,6 +134,7 @@ void TTL74153_config(int which, const struct TTL74153_interface *intf)
}
+ chips[which].machine = machine;
chips[which].output_cb = (intf ? intf->output_cb : 0);
chips[which].a = 1;
chips[which].b = 1;
diff --git a/src/emu/machine/74153.h b/src/emu/machine/74153.h
index 2e7d9bdb487..b70d8e2a555 100644
--- a/src/emu/machine/74153.h
+++ b/src/emu/machine/74153.h
@@ -40,11 +40,11 @@
/* The interface structure */
struct TTL74153_interface
{
- void (*output_cb)(void);
+ void (*output_cb)(running_machine *machine);
};
-void TTL74153_config(int which, const struct TTL74153_interface *intf);
+void TTL74153_config(running_machine *machine, int which, const struct TTL74153_interface *intf);
/* must call TTL74153_update() after setting the inputs */
void TTL74153_update(int which);
diff --git a/src/emu/machine/microtch.c b/src/emu/machine/microtch.c
index ac9bd01a0ee..59f076d9633 100644
--- a/src/emu/machine/microtch.c
+++ b/src/emu/machine/microtch.c
@@ -27,8 +27,8 @@ static struct
int last_touch_state;
int last_x;
int last_y;
- void (*tx_callback)(running_machine *machine, UINT8 data);
- int (*touch_callback)(int *touch_x, int *touch_y);
+ microtouch_tx_func tx_callback;
+ microtouch_touch_func touch_callback;
} microtouch;
@@ -87,7 +87,7 @@ static TIMER_CALLBACK(microtouch_timer_callback)
int ty = input_port_read(machine, "TOUCH_Y");
if ( microtouch.touch_callback == NULL ||
- microtouch.touch_callback( &tx, &ty ) != 0 )
+ microtouch.touch_callback( machine, &tx, &ty ) != 0 )
{
ty = 0x4000 - ty;
@@ -107,8 +107,7 @@ static TIMER_CALLBACK(microtouch_timer_callback)
}
};
-void microtouch_init(running_machine *machine, void (*tx_cb)(running_machine *machine, UINT8 data),
- int (*touch_cb)(int *touch_x, int *touch_y))
+void microtouch_init(running_machine *machine, microtouch_tx_func tx_cb, microtouch_touch_func touch_cb)
{
memset(&microtouch, 0, sizeof(microtouch));
diff --git a/src/emu/machine/microtch.h b/src/emu/machine/microtch.h
index 012194aac65..efa6c2a4f12 100644
--- a/src/emu/machine/microtch.h
+++ b/src/emu/machine/microtch.h
@@ -3,7 +3,10 @@
INPUT_PORTS_EXTERN(microtouch);
-void microtouch_init(running_machine *machine, void (*tx_cb)(running_machine *machine, UINT8 data), int (*touch_cb)(int *touch_x, int *touch_y));
+typedef void (*microtouch_tx_func)(running_machine *machine, UINT8 data);
+typedef int (*microtouch_touch_func)(running_machine *machine, int *touch_x, int *touch_y);
+
+void microtouch_init(running_machine *machine, microtouch_tx_func tx_cb, microtouch_touch_func touch_cb);
void microtouch_rx(int count, UINT8* data);
#endif //_MICROTOUCH_H
diff --git a/src/emu/machine/pcshare.h b/src/emu/machine/pcshare.h
index 546953d2bb8..cb877e2777e 100644
--- a/src/emu/machine/pcshare.h
+++ b/src/emu/machine/pcshare.h
@@ -4,9 +4,9 @@
#define PCCOMMON_KEYBOARD_PC 0
#define PCCOMMON_KEYBOARD_AT 1
-void init_pc_common(running_machine *machine, UINT32 flags, void (*set_keyb_int_func)(int));
+void init_pc_common(running_machine *machine, UINT32 flags, void (*set_keyb_int_func)(running_machine *, int));
-void pc_keyboard(running_machine *machine);
+void pc_keyboard(void);
UINT8 pc_keyb_read(void);
void pc_keyb_set_clock(int on);
void pc_keyb_clear(void);
diff --git a/src/emu/machine/rtc65271.c b/src/emu/machine/rtc65271.c
index d595c936fb8..dab37a68d51 100644
--- a/src/emu/machine/rtc65271.c
+++ b/src/emu/machine/rtc65271.c
@@ -32,6 +32,8 @@ cycle */
static struct
{
+ running_machine *machine;
+
/* 64 8-bit registers (10 clock registers, 4 control/status registers, and
50 bytes of user RAM) */
UINT8 regs[64];
@@ -49,7 +51,7 @@ static struct
int SQW_internal_state;
/* callback called when interrupt pin state changes (may be NULL) */
- void (*interrupt_callback)(int state);
+ void (*interrupt_callback)(running_machine *machine, int state);
} rtc;
enum
@@ -310,10 +312,11 @@ int rtc65271_file_save(mame_file *file)
interrupt_callback: callback called when interrupt pin state changes (may
be NULL)
*/
-void rtc65271_init(running_machine *machine, UINT8 *xram, void (*interrupt_callback)(int state))
+void rtc65271_init(running_machine *machine, UINT8 *xram, void (*interrupt_callback)(running_machine *machine, int state))
{
memset(&rtc, 0, sizeof(rtc));
+ rtc.machine = machine;
rtc.xram = xram;
rtc.update_timer = timer_alloc(machine, rtc_begin_update_callback, NULL);
@@ -456,13 +459,13 @@ static void field_interrupts(void)
{
rtc.regs[reg_C] |= reg_C_IRQF;
if (rtc.interrupt_callback)
- rtc.interrupt_callback(1);
+ rtc.interrupt_callback(rtc.machine, 1);
}
else
{
rtc.regs[reg_C] &= ~reg_C_IRQF;
if (rtc.interrupt_callback)
- rtc.interrupt_callback(0);
+ rtc.interrupt_callback(rtc.machine, 0);
}
}
diff --git a/src/emu/machine/rtc65271.h b/src/emu/machine/rtc65271.h
index 5bae6e13169..56a76427318 100644
--- a/src/emu/machine/rtc65271.h
+++ b/src/emu/machine/rtc65271.h
@@ -4,6 +4,6 @@
extern int rtc65271_file_load(running_machine *machine, mame_file *file);
extern int rtc65271_file_save(mame_file *file);
-extern void rtc65271_init(running_machine *machine, UINT8 *xram, void (*interrupt_callback)(int state));
+extern void rtc65271_init(running_machine *machine, UINT8 *xram, void (*interrupt_callback)(running_machine *machine, int state));
extern UINT8 rtc65271_r(int xramsel, offs_t offset);
extern void rtc65271_w(int xramsel, offs_t offset, UINT8 data);
diff --git a/src/mame/drivers/gamecstl.c b/src/mame/drivers/gamecstl.c
index 6a7df3aa0be..d73ef380dce 100644
--- a/src/mame/drivers/gamecstl.c
+++ b/src/mame/drivers/gamecstl.c
@@ -712,7 +712,7 @@ static const struct kbdc8042_interface at8042 =
KBDC8042_AT386, set_gate_a20, keyboard_interrupt, gamecstl_get_out2
};
-static void gamecstl_set_keyb_int(int state) {
+static void gamecstl_set_keyb_int(running_machine *machine, int state) {
pic8259_set_irq_line(gamecstl_devices.pic8259_1, 1, state);
}
diff --git a/src/mame/drivers/mediagx.c b/src/mame/drivers/mediagx.c
index 3575995b21b..15267624593 100644
--- a/src/mame/drivers/mediagx.c
+++ b/src/mame/drivers/mediagx.c
@@ -1097,7 +1097,7 @@ static const struct kbdc8042_interface at8042 =
KBDC8042_AT386, set_gate_a20, keyboard_interrupt, mediagx_get_out2
};
-static void mediagx_set_keyb_int(int state) {
+static void mediagx_set_keyb_int(running_machine *machine, int state) {
pic8259_set_irq_line(mediagx_devices.pic8259_1, 1, state);
}
diff --git a/src/mame/drivers/meritm.c b/src/mame/drivers/meritm.c
index ad92f868dc5..efa7e5e081e 100644
--- a/src/mame/drivers/meritm.c
+++ b/src/mame/drivers/meritm.c
@@ -241,7 +241,7 @@ static void meritm_microtouch_tx_callback(running_machine *machine, UINT8 data)
* Microtouch touch coordinate transformation
*
*************************************/
-static int meritm_touch_coord_transform(int *touch_x, int *touch_y)
+static int meritm_touch_coord_transform(running_machine *machine, int *touch_x, int *touch_y)
{
int xscr = (int)((double)(*touch_x)/0x4000*544);
int yscr = (int)((double)(*touch_y)/0x4000*480);
diff --git a/src/mame/drivers/taitowlf.c b/src/mame/drivers/taitowlf.c
index 6426c6e6578..d1b84183175 100644
--- a/src/mame/drivers/taitowlf.c
+++ b/src/mame/drivers/taitowlf.c
@@ -661,7 +661,7 @@ static const struct kbdc8042_interface at8042 =
KBDC8042_AT386, set_gate_a20, keyboard_interrupt, taitowlf_get_out2
};
-static void taitowlf_set_keyb_int(int state) {
+static void taitowlf_set_keyb_int(running_machine *machine, int state) {
pic8259_set_irq_line(taitowlf_devices.pic8259_1, 1, state);
}
diff --git a/src/mame/machine/carpolo.c b/src/mame/machine/carpolo.c
index 84a1e182968..640c23e7348 100644
--- a/src/mame/machine/carpolo.c
+++ b/src/mame/machine/carpolo.c
@@ -578,7 +578,7 @@ MACHINE_RESET( carpolo )
/* set up the pedal handling chips */
- TTL74153_config(TTL74153_1K, 0);
+ TTL74153_config(machine, TTL74153_1K, 0);
TTL74153_enable_w(TTL74153_1K, 0, 0);
TTL74153_enable_w(TTL74153_1K, 1, 0);
diff --git a/src/mame/machine/pcshare.c b/src/mame/machine/pcshare.c
index d29e4fa0c71..d17b905ae04 100644
--- a/src/mame/machine/pcshare.c
+++ b/src/mame/machine/pcshare.c
@@ -26,32 +26,15 @@
#define VERBOSE_DBG 0 /* general debug messages */
#define DBG_LOG(N,M,A) \
- if(VERBOSE_DBG>=N){ if( M )logerror("%11.6f: %-24s",attotime_to_double(timer_get_time(machine)),(char*)M ); logerror A; }
+ if(VERBOSE_DBG>=N){ if( M )logerror("%11.6f: %-24s",attotime_to_double(timer_get_time(pc_keyb.machine)),(char*)M ); logerror A; }
#define VERBOSE_JOY 0 /* JOY (joystick port) */
#define JOY_LOG(N,M,A) \
- if(VERBOSE_JOY>=N){ if( M )logerror("%11.6f: %-24s",attotime_to_double(timer_get_time(machine)),(char*)M ); logerror A; }
+ if(VERBOSE_JOY>=N){ if( M )logerror("%11.6f: %-24s",attotime_to_double(timer_get_time(pc_keyb.machine)),(char*)M ); logerror A; }
-static emu_timer *pc_keyboard_timer;
-static void (*set_keyb_int)(int);
static TIMER_CALLBACK( pc_keyb_timer );
-
-void init_pc_common(running_machine *machine, UINT32 flags, void (*set_keyb_int_func)(int))
-{
- /* PC-XT keyboard */
- if (flags & PCCOMMON_KEYBOARD_AT)
- at_keyboard_init(machine, AT_KEYBOARD_TYPE_AT);
- else
- at_keyboard_init(machine, AT_KEYBOARD_TYPE_PC);
- at_keyboard_set_scan_code_set(1);
-
- set_keyb_int = set_keyb_int_func;
-
- pc_keyboard_timer = timer_alloc(machine, pc_keyb_timer, NULL);
-}
-
/*
keyboard seams to permanently sent data clocked by the mainboard
clock line low for longer means "resync", keyboard sends 0xaa as answer
@@ -59,10 +42,30 @@ void init_pc_common(running_machine *machine, UINT32 flags, void (*set_keyb_int_
*/
static struct {
+ running_machine *machine;
+ void (*int_cb)(running_machine *, int);
+ emu_timer *timer;
UINT8 data;
int on;
int self_test;
-} pc_keyb= { 0 };
+} pc_keyb;
+
+
+
+void init_pc_common(running_machine *machine, UINT32 flags, void (*set_keyb_int_func)(running_machine *, int))
+{
+ /* PC-XT keyboard */
+ if (flags & PCCOMMON_KEYBOARD_AT)
+ at_keyboard_init(machine, AT_KEYBOARD_TYPE_AT);
+ else
+ at_keyboard_init(machine, AT_KEYBOARD_TYPE_PC);
+ at_keyboard_set_scan_code_set(1);
+
+ memset(&pc_keyb, 0, sizeof(pc_keyb));
+ pc_keyb.machine = machine;
+ pc_keyb.int_cb = set_keyb_int_func;
+ pc_keyb.timer = timer_alloc(machine, pc_keyb_timer, NULL);
+}
UINT8 pc_keyb_read(void)
{
@@ -74,7 +77,7 @@ UINT8 pc_keyb_read(void)
static TIMER_CALLBACK( pc_keyb_timer )
{
if ( pc_keyb.on ) {
- pc_keyboard(machine);
+ pc_keyboard();
} else {
/* Clock has been low for more than 5 msec, start diagnostic test */
at_keyboard_reset();
@@ -91,14 +94,14 @@ void pc_keyb_set_clock(int on)
if (pc_keyb.on != on)
{
if (!on)
- timer_adjust_oneshot(pc_keyboard_timer, ATTOTIME_IN_MSEC(5), 0);
+ timer_adjust_oneshot(pc_keyb.timer, ATTOTIME_IN_MSEC(5), 0);
else {
if ( pc_keyb.self_test ) {
/* The self test of the keyboard takes some time. 2 msec seems to work. */
/* This still needs to verified against a real keyboard. */
- timer_adjust_oneshot(pc_keyboard_timer, ATTOTIME_IN_MSEC( 2 ), 0);
+ timer_adjust_oneshot(pc_keyb.timer, ATTOTIME_IN_MSEC( 2 ), 0);
} else {
- timer_reset(pc_keyboard_timer, attotime_never);
+ timer_reset(pc_keyb.timer, attotime_never);
pc_keyb.self_test = 0;
}
}
@@ -110,12 +113,12 @@ void pc_keyb_set_clock(int on)
void pc_keyb_clear(void)
{
pc_keyb.data = 0;
- if ( set_keyb_int ) {
- set_keyb_int(0);
+ if ( pc_keyb.int_cb ) {
+ pc_keyb.int_cb(pc_keyb.machine, 0);
}
}
-void pc_keyboard(running_machine *machine)
+void pc_keyboard(void)
{
int data;
@@ -126,8 +129,8 @@ void pc_keyboard(running_machine *machine)
if ( (data=at_keyboard_read())!=-1) {
pc_keyb.data = data;
DBG_LOG(1,"KB_scancode",("$%02x\n", pc_keyb.data));
- if ( set_keyb_int ) {
- set_keyb_int(1);
+ if ( pc_keyb.int_cb ) {
+ pc_keyb.int_cb(pc_keyb.machine, 1);
}
pc_keyb.self_test = 0;
}