Removed hack for setting mcs51 serial callbacks. Updated micro3d to use

new functions. Fixes regression.
This commit is contained in:
Aaron Giles 2008-12-14 23:47:30 +00:00
parent 04fbf4f825
commit 60b43c1d69
3 changed files with 21 additions and 30 deletions

View File

@ -290,8 +290,8 @@ struct _mcs51_state_t
/* Serial Port TX/RX Callbacks */
// TODO: Move to special port r/w
void (*serial_tx_callback)(int data); //Call back funciton when sending data out of serial port
int (*serial_rx_callback)(void); //Call back function to retrieve data when receiving serial port data
mcs51_serial_tx_func serial_tx_callback; //Call back funciton when sending data out of serial port
mcs51_serial_rx_func serial_rx_callback; //Call back function to retrieve data when receiving serial port data
/* DS5002FP */
struct {
@ -631,13 +631,6 @@ struct _mcs51_state_t
/* Clear Current IRQ */
#define CLEAR_CURRENT_IRQ() clear_current_irq(mcs51_state)
/***************************************************************************
GLOBAL VARIABLES
***************************************************************************/
static void (*hold_serial_tx_callback)(int data);
static int (*hold_serial_rx_callback)(void);
/***************************************************************************
FUNCTION PROTOTYPES
***************************************************************************/
@ -910,7 +903,7 @@ INLINE void transmit_receive(mcs51_state_t *mcs51_state, int source)
if(mcs51_state->uart.bits_to_send == 0) {
//Call the callback function
if(mcs51_state->serial_tx_callback)
mcs51_state->serial_tx_callback(mcs51_state->uart.data_out);
mcs51_state->serial_tx_callback(mcs51_state->device, mcs51_state->uart.data_out);
//Set Interrupt Flag
SET_TI(1);
}
@ -929,7 +922,7 @@ INLINE void transmit_receive(mcs51_state_t *mcs51_state, int source)
int data = 0;
//Call our callball function to retrieve the data
if(mcs51_state->serial_rx_callback)
data = mcs51_state->serial_rx_callback();
data = mcs51_state->serial_rx_callback(mcs51_state->device);
LOG(("RX Deliver %d\n", data));
SET_SBUF(data);
//Flag the IRQ
@ -1264,16 +1257,16 @@ INLINE void update_irq_prio(mcs51_state_t *mcs51_state, UINT8 ipl, UINT8 iph)
***************************************************************************/
void i8051_set_serial_tx_callback(void (*callback)(int data))
void i8051_set_serial_tx_callback(const device_config *device, mcs51_serial_tx_func tx_func)
{
//Hold in static variable since this function can get called before reset has run, which wipes i8051 memory clean
hold_serial_tx_callback = callback;
mcs51_state_t *mcs51_state = device->token;
mcs51_state->serial_tx_callback = tx_func;
}
void i8051_set_serial_rx_callback(int (*callback)(void))
void i8051_set_serial_rx_callback(const device_config *device, mcs51_serial_rx_func rx_func)
{
//Hold in static variable since this function can get called before reset has run, which wipes i8051 memory clean
hold_serial_rx_callback = callback;
mcs51_state_t *mcs51_state = device->token;
mcs51_state->serial_rx_callback = rx_func;
}
/***************************************************************************
@ -2099,11 +2092,6 @@ static CPU_RESET( mcs51 )
mcs51_state_t *mcs51_state = device->token;
update_ptrs(mcs51_state);
//Set up serial call back handlers
mcs51_state->serial_tx_callback = hold_serial_tx_callback;
hold_serial_tx_callback = NULL;
mcs51_state->serial_rx_callback = hold_serial_rx_callback;
hold_serial_rx_callback = NULL;
mcs51_state->last_line_state = 0;
mcs51_state->t0_cnt = 0;

View File

@ -90,8 +90,11 @@ struct _ds5002fp_config
FUNCTION PROTOTYPES
***************************************************************************/
extern void i8051_set_serial_tx_callback(void (*callback)(int data));
extern void i8051_set_serial_rx_callback(int (*callback)(void));
typedef void (*mcs51_serial_tx_func)(const device_config *device, int data);
typedef int (*mcs51_serial_rx_func)(const device_config *device);
extern void i8051_set_serial_tx_callback(const device_config *device, mcs51_serial_tx_func tx_func);
extern void i8051_set_serial_rx_callback(const device_config *device, mcs51_serial_rx_func rx_func);
/* variants with no internal rom and 128 byte internal memory */
CPU_GET_INFO( i8031 );

View File

@ -105,25 +105,25 @@ enum{ RX=0,TX,STATUS,SYN1,SYN2,DLE,MODE1,MODE2,COMMAND
/* Probably wrong and a bit crap */
static int data_to_i8031(void)
static int data_to_i8031(const device_config *device)
{
mame_printf_debug("68k sent data: %x\n",M68681.TBB);
M68681.SRB |=0x0400; // Data has been sent - TX ready for more.
// Write to sound board
if(M68681.IMR & 0x1000)
{
cpu_set_input_line_and_vector(Machine->cpu[0],3, HOLD_LINE, M68681.IVR); // Generate an interrupt, if allowed.
cpu_set_input_line_and_vector(device->machine->cpu[0],3, HOLD_LINE, M68681.IVR); // Generate an interrupt, if allowed.
}
return M68681.TBB;
}
static void data_from_i8031(int data)
static void data_from_i8031(const device_config *device, int data)
{
M68681.RBB = data<<8; // Put into receive buffer.
M68681.SRB |= 0x0100; // Set Receiver B ready.
if(M68681.IMR & 0x1000)
{
cpu_set_input_line_and_vector(Machine->cpu[0],3, HOLD_LINE, M68681.IVR); // Generate a receiver interrupt.
cpu_set_input_line_and_vector(device->machine->cpu[0],3, HOLD_LINE, M68681.IVR); // Generate a receiver interrupt.
mame_printf_debug("INTERRUPT!!!\n");
}
mame_printf_debug("8031 sent data: %x\n",data);
@ -169,8 +169,8 @@ static void micro3d_scanline_update(const device_config *screen, bitmap_t *bitma
static MACHINE_RESET( micro3d )
{
i8051_set_serial_tx_callback(data_from_i8031);
i8051_set_serial_rx_callback(data_to_i8031);
i8051_set_serial_tx_callback(machine->cpu[2], data_from_i8031);
i8051_set_serial_rx_callback(machine->cpu[2], data_to_i8031);
ti_uart[STATUS]=1;
M68681.SRA=0x0500;
M68681.SRB=0x0500;