From 5fca563dd08cddd49457d0fb01aac9f9ed2d261b Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 16 Jun 2017 22:54:08 +0200 Subject: [PATCH 1/5] Changed type of string literals in all (I hope) structs to const char *, reduces .EXE file size by about 200 kB. --- src/CPU/cpu.h | 2 +- src/NETWORK/network.c | 4 ++-- src/NETWORK/network.h | 4 ++-- src/SOUND/sound.c | 8 ++++---- src/VIDEO/video.c | 8 ++++---- src/WIN/win_deviceconfig.c | 24 ++++++++++++------------ src/WIN/win_settings.c | 6 +++--- src/device.c | 24 ++++++++++++------------ src/device.h | 10 +++++----- src/gameport.c | 12 ++++++------ src/gameport.h | 8 ++++---- src/hdd.c | 8 ++++---- src/model.c | 6 +++--- src/model.h | 6 +++--- src/mouse.c | 4 ++-- src/mouse.h | 4 ++-- src/scsi.c | 8 ++++---- 17 files changed, 73 insertions(+), 73 deletions(-) diff --git a/src/CPU/cpu.h b/src/CPU/cpu.h index b792b36b8..39ff3153f 100644 --- a/src/CPU/cpu.h +++ b/src/CPU/cpu.h @@ -87,7 +87,7 @@ extern int timing_misaligned; typedef struct { - char name[32]; + const char *name; int cpu_type; int speed; int rspeed; diff --git a/src/NETWORK/network.c b/src/NETWORK/network.c index 87d2613ac..79bb4ac13 100644 --- a/src/NETWORK/network.c +++ b/src/NETWORK/network.c @@ -207,7 +207,7 @@ network_card_available(int card) char * network_card_getname(int card) { - return(net_cards[card].name); + return((char *) net_cards[card].name); } @@ -233,7 +233,7 @@ network_card_has_config(int card) char * network_card_get_internal_name(int card) { - return(net_cards[card].internal_name); + return((char *) net_cards[card].internal_name); } diff --git a/src/NETWORK/network.h b/src/NETWORK/network.h index 1c3e748a1..df2241822 100644 --- a/src/NETWORK/network.h +++ b/src/NETWORK/network.h @@ -32,8 +32,8 @@ typedef void (*NETRXCB)(void *, uint8_t *, int); typedef struct { - char name[64]; - char internal_name[32]; + const char *name; + const char *internal_name; device_t *device; void *private; int (*poll)(void *); diff --git a/src/SOUND/sound.c b/src/SOUND/sound.c index 369065411..5487a4f5c 100644 --- a/src/SOUND/sound.c +++ b/src/SOUND/sound.c @@ -42,8 +42,8 @@ static int sound_card_last = 0; typedef struct { - char name[64]; - char internal_name[24]; + const char *name; + const char *internal_name; device_t *device; } SOUND_CARD; @@ -80,7 +80,7 @@ int sound_card_available(int card) char *sound_card_getname(int card) { - return sound_cards[card].name; + return (char *) sound_cards[card].name; } device_t *sound_card_getdevice(int card) @@ -97,7 +97,7 @@ int sound_card_has_config(int card) char *sound_card_get_internal_name(int card) { - return sound_cards[card].internal_name; + return (char *) sound_cards[card].internal_name; } int sound_card_get_from_internal_name(char *s) diff --git a/src/VIDEO/video.c b/src/VIDEO/video.c index fa541958c..aad86f57c 100644 --- a/src/VIDEO/video.c +++ b/src/VIDEO/video.c @@ -64,8 +64,8 @@ int cga_palette = 0; typedef struct { - char name[64]; - char internal_name[24]; + const char *name; + const char *internal_name; device_t *device; int legacy_id; } VIDEO_CARD; @@ -120,7 +120,7 @@ int video_card_available(int card) char *video_card_getname(int card) { - return video_cards[card].name; + return (char *) video_cards[card].name; } device_t *video_card_getdevice(int card) @@ -168,7 +168,7 @@ int video_new_to_old(int card) char *video_get_internal_name(int card) { - return video_cards[card].internal_name; + return (char *) video_cards[card].internal_name; } int video_get_video_from_internal_name(char *s) diff --git a/src/WIN/win_deviceconfig.c b/src/WIN/win_deviceconfig.c index cf0474c16..200f579fd 100644 --- a/src/WIN/win_deviceconfig.c +++ b/src/WIN/win_deviceconfig.c @@ -47,7 +47,7 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam switch (config->type) { case CONFIG_BINARY: - val_int = config_get_int(config_device->name, config->name, config->default_int); + val_int = config_get_int((char *) config_device->name, (char *) config->name, config->default_int); SendMessage(h, BM_SETCHECK, val_int, 0); @@ -55,7 +55,7 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam break; case CONFIG_SELECTION: - val_int = config_get_int(config_device->name, config->name, config->default_int); + val_int = config_get_int((char *) config_device->name, (char *) config->name, config->default_int); c = 0; while (selection->description[0]) @@ -71,7 +71,7 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam break; case CONFIG_HEX16: - val_int = config_get_hex16(config_device->name, config->name, config->default_int); + val_int = config_get_hex16((char *) config_device->name, (char *) config->name, config->default_int); c = 0; while (selection->description[0]) @@ -87,7 +87,7 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam break; case CONFIG_HEX20: - val_int = config_get_hex20(config_device->name, config->name, config->default_int); + val_int = config_get_hex20((char *) config_device->name, (char *) config->name, config->default_int); c = 0; while (selection->description[0]) @@ -125,7 +125,7 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam switch (config->type) { case CONFIG_BINARY: - val_int = config_get_int(config_device->name, config->name, config->default_int); + val_int = config_get_int((char *) config_device->name, (char *) config->name, config->default_int); if (val_int != SendMessage(h, BM_GETCHECK, 0, 0)) changed = 1; @@ -134,7 +134,7 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam break; case CONFIG_SELECTION: - val_int = config_get_int(config_device->name, config->name, config->default_int); + val_int = config_get_int((char *) config_device->name, (char *) config->name, config->default_int); c = SendMessage(h, CB_GETCURSEL, 0, 0); @@ -148,7 +148,7 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam break; case CONFIG_HEX16: - val_int = config_get_hex16(config_device->name, config->name, config->default_int); + val_int = config_get_hex16((char *) config_device->name, (char *) config->name, config->default_int); c = SendMessage(h, CB_GETCURSEL, 0, 0); @@ -162,7 +162,7 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam break; case CONFIG_HEX20: - val_int = config_get_hex20(config_device->name, config->name, config->default_int); + val_int = config_get_hex20((char *) config_device->name, (char *) config->name, config->default_int); c = SendMessage(h, CB_GETCURSEL, 0, 0); @@ -201,7 +201,7 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam switch (config->type) { case CONFIG_BINARY: - config_set_int(config_device->name, config->name, SendMessage(h, BM_GETCHECK, 0, 0)); + config_set_int((char *) config_device->name, (char *) config->name, SendMessage(h, BM_GETCHECK, 0, 0)); id++; break; @@ -210,7 +210,7 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam c = SendMessage(h, CB_GETCURSEL, 0, 0); for (; c > 0; c--) selection++; - config_set_int(config_device->name, config->name, selection->value); + config_set_int((char *) config_device->name, (char *) config->name, selection->value); id += 2; break; @@ -219,7 +219,7 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam c = SendMessage(h, CB_GETCURSEL, 0, 0); for (; c > 0; c--) selection++; - config_set_hex16(config_device->name, config->name, selection->value); + config_set_hex16((char *) config_device->name, (char *) config->name, selection->value); id += 2; break; @@ -228,7 +228,7 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam c = SendMessage(h, CB_GETCURSEL, 0, 0); for (; c > 0; c--) selection++; - config_set_hex20(config_device->name, config->name, selection->value); + config_set_hex20((char *) config_device->name, (char *) config->name, selection->value); id += 2; break; diff --git a/src/WIN/win_settings.c b/src/WIN/win_settings.c index d16435b22..9e2ec7281 100644 --- a/src/WIN/win_settings.c +++ b/src/WIN/win_settings.c @@ -421,7 +421,7 @@ static void win_settings_machine_recalc_cpu_m(HWND hdlg) c = 0; while (models[romstomodel[temp_romset]].cpu[temp_cpu_m].cpus[c].cpu_type != -1) { - stransi = models[romstomodel[temp_romset]].cpu[temp_cpu_m].cpus[c].name; + stransi = (char *) models[romstomodel[temp_romset]].cpu[temp_cpu_m].cpus[c].name; mbstowcs(lptsTemp, stransi, strlen(stransi) + 1); SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)lptsTemp); c++; @@ -466,7 +466,7 @@ static void win_settings_machine_recalc_model(HWND hdlg) c = 0; while (models[romstomodel[temp_romset]].cpu[c].cpus != NULL && c < 4) { - stransi = models[romstomodel[temp_romset]].cpu[c].name; + stransi = (char *) models[romstomodel[temp_romset]].cpu[c].name; mbstowcs(lptsTemp, stransi, strlen(stransi) + 1); SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)lptsTemp); c++; @@ -533,7 +533,7 @@ static BOOL CALLBACK win_settings_machine_proc(HWND hdlg, UINT message, WPARAM w { if (romspresent[models[c].id]) { - stransi = models[c].name; + stransi = (char *) models[c].name; mbstowcs(lptsTemp, stransi, strlen(stransi) + 1); SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp); modeltolist[c] = d; diff --git a/src/device.c b/src/device.c index 9d8968f82..876c400ad 100644 --- a/src/device.c +++ b/src/device.c @@ -158,7 +158,7 @@ int device_get_config_int(char *s) while (config->type != -1) { if (!strcmp(s, config->name)) - return config_get_int(current_device->name, s, config->default_int); + return config_get_int((char *) current_device->name, s, config->default_int); config++; } @@ -172,7 +172,7 @@ int device_get_config_int_ex(char *s, int default_int) while (config->type != -1) { if (!strcmp(s, config->name)) - return config_get_int(current_device->name, s, default_int); + return config_get_int((char *) current_device->name, s, default_int); config++; } @@ -186,7 +186,7 @@ int device_get_config_hex16(char *s) while (config->type != -1) { if (!strcmp(s, config->name)) - return config_get_hex16(current_device->name, s, config->default_int); + return config_get_hex16((char *) current_device->name, s, config->default_int); config++; } @@ -200,7 +200,7 @@ int device_get_config_hex20(char *s) while (config->type != -1) { if (!strcmp(s, config->name)) - return config_get_hex20(current_device->name, s, config->default_int); + return config_get_hex20((char *) current_device->name, s, config->default_int); config++; } @@ -214,7 +214,7 @@ int device_get_config_mac(char *s, int default_int) while (config->type != -1) { if (!strcmp(s, config->name)) - return config_get_mac(current_device->name, s, default_int); + return config_get_mac((char *) current_device->name, s, default_int); config++; } @@ -229,7 +229,7 @@ void device_set_config_int(char *s, int val) { if (!strcmp(s, config->name)) { - config_set_int(current_device->name, s, val); + config_set_int((char *) current_device->name, s, val); return; } @@ -246,7 +246,7 @@ void device_set_config_hex16(char *s, int val) { if (!strcmp(s, config->name)) { - config_set_hex16(current_device->name, s, val); + config_set_hex16((char *) current_device->name, s, val); return; } @@ -263,7 +263,7 @@ void device_set_config_hex20(char *s, int val) { if (!strcmp(s, config->name)) { - config_set_hex20(current_device->name, s, val); + config_set_hex20((char *) current_device->name, s, val); return; } @@ -280,7 +280,7 @@ void device_set_config_mac(char *s, int val) { if (!strcmp(s, config->name)) { - config_set_mac(current_device->name, s, val); + config_set_mac((char *) current_device->name, s, val); return; } @@ -296,7 +296,7 @@ char *device_get_config_string(char *s) while (config->type != -1) { if (!strcmp(s, config->name)) - return config_get_string(current_device->name, s, config->default_string); + return config_get_string((char *) current_device->name, s, (char *) config->default_string); config++; } @@ -316,7 +316,7 @@ int model_get_config_int(char *s) while (config->type != -1) { if (!strcmp(s, config->name)) - return config_get_int(device->name, s, config->default_int); + return config_get_int((char *) device->name, s, config->default_int); config++; } @@ -336,7 +336,7 @@ char *model_get_config_string(char *s) while (config->type != -1) { if (!strcmp(s, config->name)) - return config_get_string(device->name, s, config->default_string); + return config_get_string((char *) device->name, s, (char *) config->default_string); config++; } diff --git a/src/device.h b/src/device.h index e5613f836..35c842479 100644 --- a/src/device.h +++ b/src/device.h @@ -41,23 +41,23 @@ enum typedef struct device_config_selection_t { - char description[256]; + const char *description; int value; } device_config_selection_t; typedef struct device_config_t { - char name[256]; - char description[256]; + const char *name; + const char *description; int type; - char default_string[256]; + const char *default_string; int default_int; device_config_selection_t selection[16]; } device_config_t; typedef struct device_t { - char name[50]; + const char *name; uint32_t flags; void *(*init)(); void (*close)(void *p); diff --git a/src/gameport.c b/src/gameport.c index a80d962b7..310954103 100644 --- a/src/gameport.c +++ b/src/gameport.c @@ -37,7 +37,7 @@ static joystick_if_t *joystick_list[] = { &joystick_standard, &joystick_standard_4button, - &joystick_standard_6button, + &joystick_standard_6button, &joystick_standard_8button, &joystick_ch_flightstick_pro, &joystick_sw_pad, @@ -50,7 +50,7 @@ char *joystick_get_name(int joystick) { if (!joystick_list[joystick]) return NULL; - return joystick_list[joystick]->name; + return (char *) joystick_list[joystick]->name; } int joystick_get_max_joysticks(int joystick) @@ -73,19 +73,19 @@ int joystick_get_pov_count(int joystick) return joystick_list[joystick]->pov_count; } - char *joystick_get_axis_name(int joystick, int id) +char *joystick_get_axis_name(int joystick, int id) { - return joystick_list[joystick]->axis_names[id]; + return (char *) joystick_list[joystick]->axis_names[id]; } char *joystick_get_button_name(int joystick, int id) { - return joystick_list[joystick]->button_names[id]; + return (char *) joystick_list[joystick]->button_names[id]; } char *joystick_get_pov_name(int joystick, int id) { - return joystick_list[joystick]->pov_names[id]; + return (char *) joystick_list[joystick]->pov_names[id]; } typedef struct gameport_axis_t diff --git a/src/gameport.h b/src/gameport.h index dbe01246a..4765c479a 100644 --- a/src/gameport.h +++ b/src/gameport.h @@ -6,7 +6,7 @@ extern device_t gameport_201_device; typedef struct { - char name[80]; + const char *name; void *(*init)(); void (*close)(void *p); uint8_t (*read)(void *p); @@ -15,9 +15,9 @@ typedef struct void (*a0_over)(void *p); int axis_count, button_count, pov_count; int max_joysticks; - char axis_names[8][32]; - char button_names[32][32]; - char pov_names[4][32]; + const char *axis_names[8]; + const char *button_names[32]; + const char *pov_names[4]; } joystick_if_t; extern int joystick_type; diff --git a/src/hdd.c b/src/hdd.c index 7fdb21d95..ab167c1ee 100644 --- a/src/hdd.c +++ b/src/hdd.c @@ -19,8 +19,8 @@ hard_disk_t hdc[HDC_NUM]; static struct { - char name[50]; - char internal_name[16]; + const char *name; + const char *internal_name; device_t *device; int is_mfm; } hdd_controllers[] = @@ -39,12 +39,12 @@ static struct char *hdd_controller_get_name(int hdd) { - return hdd_controllers[hdd].name; + return (char *) hdd_controllers[hdd].name; } char *hdd_controller_get_internal_name(int hdd) { - return hdd_controllers[hdd].internal_name; + return (char *) hdd_controllers[hdd].internal_name; } int hdd_controller_get_flags(int hdd) diff --git a/src/model.c b/src/model.c index 7645ae58e..4303bf005 100644 --- a/src/model.c +++ b/src/model.c @@ -244,7 +244,7 @@ int model_getmodel(int romset) char *model_getname() { - return models[model].name; + return (char *) models[model].name; } @@ -255,12 +255,12 @@ device_t *model_getdevice(int model) char *model_get_internal_name(void) { - return models[model].internal_name; + return (char *) models[model].internal_name; } char *model_get_internal_name_ex(int m) { - return models[m].internal_name; + return (char *) models[m].internal_name; } int model_get_nvrmask(int m) diff --git a/src/model.h b/src/model.h index 02b8ddcb8..5dfda40ce 100644 --- a/src/model.h +++ b/src/model.h @@ -33,11 +33,11 @@ typedef struct { - char name[32]; + const char *name; int id; - char internal_name[24]; + const char *internal_name; struct { - char name[16]; + const char *name; CPU *cpus; } cpu[5]; int fixed_gfxcard; diff --git a/src/mouse.c b/src/mouse.c index 85075d40b..19c0240d7 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -58,14 +58,14 @@ mouse_get_name(int mouse) { if (!mouse_list[mouse]) return(NULL); - return(mouse_list[mouse]->name); + return((char *) mouse_list[mouse]->name); } char * mouse_get_internal_name(int mouse) { - return(mouse_list[mouse]->internal_name); + return((char *) mouse_list[mouse]->internal_name); } diff --git a/src/mouse.h b/src/mouse.h index 25aa07888..4ba694906 100644 --- a/src/mouse.h +++ b/src/mouse.h @@ -16,8 +16,8 @@ typedef struct { - char name[80]; - char internal_name[24]; + const char *name; + const char *internal_name; int type; void *(*init)(void); void (*close)(void *p); diff --git a/src/scsi.c b/src/scsi.c index 186a2495a..c296429a2 100644 --- a/src/scsi.c +++ b/src/scsi.c @@ -39,8 +39,8 @@ int scsi_card_last = 0; typedef struct { - char name[64]; - char internal_name[32]; + const char *name; + const char *internal_name; device_t *device; void (*reset)(void *p); } SCSI_CARD; @@ -68,7 +68,7 @@ int scsi_card_available(int card) char *scsi_card_getname(int card) { - return(scsi_cards[card].name); + return((char *) scsi_cards[card].name); } @@ -88,7 +88,7 @@ int scsi_card_has_config(int card) char *scsi_card_get_internal_name(int card) { - return(scsi_cards[card].internal_name); + return((char *) scsi_cards[card].internal_name); } From c9aac82b9451f32233aa25051af1984a0573c40c Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 16 Jun 2017 23:30:42 +0200 Subject: [PATCH 2/5] Changed all instances of pclog to serial_log in the serial code. --- src/serial.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/serial.c b/src/serial.c index c02ef6dae..8cb4b43b5 100644 --- a/src/serial.c +++ b/src/serial.c @@ -188,7 +188,7 @@ update_ints(SERIAL *sp) sp->iir = IID_IDMDM; } -pclog("Serial%d: intr, IIR=%02X, type=%d, mcr=%02X\n",sp->port, sp->iir, sp->type, sp->mctrl); +serial_log(0, "Serial%d: intr, IIR=%02X, type=%d, mcr=%02X\n",sp->port, sp->iir, sp->type, sp->mctrl); if (sp->type < UART_TYPE_16450) { /* Edge-triggered, so always send a pulse. */ // if ((sp->mctrl & MCR_OUT2) || PCJR) @@ -492,7 +492,7 @@ serial_read(uint16_t addr, void *priv) /* If there is data in the RX FIFO, grab it. */ ret = serial_read_fifo(sp); -pclog("Serial%d: read RBR: %02X\n",sp->port, ret); +serial_log(0, "Serial%d: read RBR: %02X\n",sp->port, ret); } break; @@ -508,7 +508,7 @@ pclog("Serial%d: read RBR: %02X\n",sp->port, ret); case 2: /* IIR */ ret = sp->iir; -pclog("Serial%d: read IIR: %02X\n",sp->port, sp->iir); +serial_log(0, "Serial%d: read IIR: %02X\n",sp->port, sp->iir); if ((ret & IIR_IID) == IID_IDTX) { /* Transmit is done. */ From 20178cb1bbf9af7aa9af6438e972cff3eac5467c Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 16 Jun 2017 23:47:08 +0200 Subject: [PATCH 3/5] Reversed serial port and serial mouse code to the old ones. --- src/mouse_serial.c | 177 +++++++++++++++++----------------- src/serial.c | 236 +++++++++++++++------------------------------ src/serial.h | 20 +--- 3 files changed, 172 insertions(+), 261 deletions(-) diff --git a/src/mouse_serial.c b/src/mouse_serial.c index fdda61e13..bb855ecc0 100644 --- a/src/mouse_serial.c +++ b/src/mouse_serial.c @@ -10,7 +10,7 @@ * * Based on the 86Box Serial Mouse driver as a framework. * - * Version: @(#)mouse_serial.c 1.0.4 2017/06/11 + * Version: @(#)mouse_serial.c 1.0.3 2017/05/07 * * Author: Fred N. van Kempen, */ @@ -22,18 +22,13 @@ #include "mouse_serial.h" -#define SERMOUSE_TYPE_MSYSTEMS 1 /* Mouse Systems */ -#define SERMOUSE_TYPE_MICROSOFT 2 /* Microsoft */ -#define SERMOUSE_TYPE_LOGITECH 3 /* Logitech */ - - typedef struct mouse_serial_t { - int8_t port, - type; + int port; int pos, delay; int oldb; SERIAL *serial; + int is_ms_format; } mouse_serial_t; @@ -56,16 +51,12 @@ sermouse_timer(void *priv) mouse_serial_t *ms = (mouse_serial_t *)priv; ms->delay = 0; + if (ms->pos == -1) + { + ms->pos = 0; - switch(ms->type) { - case SERMOUSE_TYPE_MICROSOFT: /* This identifies a two-button Microsoft Serial mouse. */ - serial_write_fifo(ms->serial, 'M', 1); - break; - - default: - /* No action needed. */ - break; + serial_write_fifo(ms->serial, 'M'); } } @@ -74,63 +65,53 @@ static uint8_t sermouse_poll(int x, int y, int z, int b, void *priv) { mouse_serial_t *ms = (mouse_serial_t *)priv; - uint8_t buff[16]; - int len; + uint8_t data[3]; if (!x && !y && b == ms->oldb) return(1); ms->oldb = b; - - if (ms->type == SERMOUSE_TYPE_MSYSTEMS) y = -y; - if (x>127) x = 127; if (y>127) y = 127; if (x<-128) x = -128; if (y<-128) y = -128; - len = 0; - switch(ms->type) { - case SERMOUSE_TYPE_MSYSTEMS: - buff[0] = 0x80; - buff[0] |= (b&0x01) ? 0x00 : 0x04; /* left button */ - buff[0] |= (b&0x02) ? 0x00 : 0x01; /* middle button */ - buff[0] |= (b&0x04) ? 0x00 : 0x02; /* right button */ - buff[1] = x; - buff[2] = y; - buff[3] = x; /* same as byte 1 */ - buff[4] = y; /* same as byte 2 */ - len = 5; - break; - - case SERMOUSE_TYPE_MICROSOFT: - buff[0] = 0x40; - buff[0] |= (((y>>6)&03)<<2); - buff[0] |= ((x>>6)&03); - if (b&0x01) buff[0] |= 0x20; - if (b&0x02) buff[0] |= 0x10; - buff[1] = x & 0x3F; - buff[2] = y & 0x3F; - len = 3; - break; - - case SERMOUSE_TYPE_LOGITECH: - break; - } - -#if 0 - pclog("Mouse_Serial(%d): [", ms->type); - for (b=0; b>6)&3)<<2); + data[0] |= ((x>>6)&3); + if (b&1) data[0] |= 0x20; + if (b&2) data[0] |= 0x10; + data[1] = x & 0x3F; + data[2] = y & 0x3F; /* Send the packet to the bottom-half of the attached port. */ - for (b=0; bserial, buff[b], 1); +#if 0 + pclog("Mouse_Serial: data %02X %02X %02X\n", data[0], data[1], data[2]); +#endif + serial_write_fifo(ms->serial, data[0]); + serial_write_fifo(ms->serial, data[1]); + serial_write_fifo(ms->serial, data[2]); return(0); } +static void * +sermouse_init(void) +{ + mouse_serial_t *ms = (mouse_serial_t *)malloc(sizeof(mouse_serial_t)); + memset(ms, 0x00, sizeof(mouse_serial_t)); + ms->port = SERMOUSE_PORT; + + /* Attach a serial port to the mouse. */ + ms->serial = serial_attach(ms->port, sermouse_callback, ms); + + timer_add(sermouse_timer, &ms->delay, &ms->delay, ms); + + return(ms); +} + + static void sermouse_close(void *priv) { @@ -143,14 +124,59 @@ sermouse_close(void *priv) } +mouse_t mouse_serial_microsoft = { + "Microsoft 2-button mouse (serial)", + "msserial", + MOUSE_TYPE_SERIAL, + sermouse_init, + sermouse_close, + sermouse_poll +}; + +static uint8_t +mssystems_mouse_poll(int x, int y, int z, int b, void *priv) +{ + mouse_serial_t *ms = (mouse_serial_t *)priv; + uint8_t data[5]; + + if (!x && !y && b == ms->oldb) return(1); + + ms->oldb = b; + + y=-y; + + if (x>127) x = 127; + if (y>127) y = 127; + if (x<-128) x = -128; + if (y<-128) y = -128; + + data[0] = 0x80; + data[0] |= (b & 0x01 ? 0x00 : 0x04); /*Left button*/ + data[0] |= (b & 0x02 ? 0x00 : 0x01); /*Middle button*/ + data[0] |= (b & 0x04 ? 0x00 : 0x02); /*Right button*/ + data[1] = x; + data[2] = y; + data[3] = x;/*Same as byte 1*/ + data[4] = y;/*Same as byte 2*/ + + pclog("Mouse_Systems_Serial: data %02X %02X %02X\n", data[0], data[1], data[2]); + + serial_write_fifo(ms->serial, data[0]); + serial_write_fifo(ms->serial, data[1]); + serial_write_fifo(ms->serial, data[2]); + serial_write_fifo(ms->serial, data[3]); + serial_write_fifo(ms->serial, data[4]); + + return(0); +} + static void * -sermouse_init(int type) +mssystems_mouse_init(void) { mouse_serial_t *ms = (mouse_serial_t *)malloc(sizeof(mouse_serial_t)); memset(ms, 0x00, sizeof(mouse_serial_t)); ms->port = SERMOUSE_PORT; - ms->type = type; - + /* Attach a serial port to the mouse. */ ms->serial = serial_attach(ms->port, sermouse_callback, ms); @@ -159,36 +185,11 @@ sermouse_init(int type) return(ms); } - -static void * -sermouse_init_microsoft(void) -{ - return(sermouse_init(SERMOUSE_TYPE_MICROSOFT)); -} - - -static void * -sermouse_init_msystems(void) -{ - return(sermouse_init(SERMOUSE_TYPE_MSYSTEMS)); -} - - mouse_t mouse_msystems = { "Mouse Systems Mouse (serial)", "mssystems", MOUSE_TYPE_MSYSTEMS, - sermouse_init_msystems, + mssystems_mouse_init, sermouse_close, - sermouse_poll -}; - - -mouse_t mouse_serial_microsoft = { - "Microsoft 2-button mouse (serial)", - "msserial", - MOUSE_TYPE_SERIAL, - sermouse_init_microsoft, - sermouse_close, - sermouse_poll -}; + mssystems_mouse_poll +}; \ No newline at end of file diff --git a/src/serial.c b/src/serial.c index 8cb4b43b5..ae33dc16d 100644 --- a/src/serial.c +++ b/src/serial.c @@ -15,29 +15,25 @@ * * So, for the PC, the offerings were for an IBM Asynchronous * Communications Adapter, and, later, a model for synchronous - * communications. The "Async Adapter" was based on the NS8250 - * UART chip, and is what we now call the "com" port of the PC. + * communications. + * + * The "Async Adapter" was based on the NS8250 UART chip, and + * is what we now call the "serial" or "com" port of the PC. * * Of course, many system builders came up with similar boards, * and even more boards were designed where several I/O functions - * were combined into a single "multi-I/O" board, as that saved - * space and buts slots. Initially, these had the chips as-is, - * but later many of these functions were integrated into a - * single "super-I/O" chip. + * were combined into a single board: the Multi-I/O adapters. + * Initially, these had all the chips as-is, but later many of + * these functions were integrated into a single MIO chip. * - * This file implements the standard NS8250, as well as the later - * 16450 and 16550 series, which fixed bugs and added features - * like FIFO buffers, higher line speeds and DMA transfers. - * - * On the lower half of the driver we interface to the host - * system's serial ports for real-world access. + * This file implements the standard NS8250 series of chips, with + * support for the later (16450 and 16550) FIFO additions. On the + * lower half of the driver, we interface to the host system's + * serial ports for real-world access. * * Based on the 86Box serial port driver as a framework. * - * **NOTE** This module is currently UNDER CONSTRUCTION, do not mess - * with it please! - * - * Version: @(#)serial.c 1.0.8 2017/06/17 + * Version: @(#)serial.c 1.0.7 2017/06/04 * * Author: Fred N. van Kempen, * Copyright 2017 Fred N. van Kempen. @@ -78,10 +74,10 @@ enum { # define IID_IDTX (0x02) # define IID_IDRX (0x04) # define IID_IDERR (0x06) -# define IID_IDTMO (0x0c) /* 16550+ */ -#define IIR_IIRFE (0xc0) /* 16550+ */ +# define IID_IDTMO (0x0c) +#define IIR_IIRFE (0xc0) # define IIR_FIFO64 (0x20) -# define IIR_FIFOBAD (0x80) +# define IIR_FIFOBAD (0x80) /* 16550 */ # define IIR_FIFOENB (0xc0) /* FCR register bits. */ @@ -148,6 +144,7 @@ static SERIAL ports[NUM_SERIAL]; /* serial port data */ int serial_do_log; +#if 0 static void serial_log(int lvl, const char *fmt, ...) { @@ -162,6 +159,7 @@ serial_log(int lvl, const char *fmt, ...) } #endif } +#endif static void @@ -188,20 +186,11 @@ update_ints(SERIAL *sp) sp->iir = IID_IDMDM; } -serial_log(0, "Serial%d: intr, IIR=%02X, type=%d, mcr=%02X\n",sp->port, sp->iir, sp->type, sp->mctrl); - if (sp->type < UART_TYPE_16450) { - /* Edge-triggered, so always send a pulse. */ -// if ((sp->mctrl & MCR_OUT2) || PCJR) - picint(1 << sp->irq); - } else { - /* Raise or clear the level-based IRQ. */ - if ((sp->mctrl & MCR_OUT2) || PCJR) { - if (stat) - picintlevel(1 << sp->irq); - else - picintc(1 << sp->irq); - } - } + /* Raise or clear the level-based IRQ. */ + if (stat && ((sp->mctrl & MCR_OUT2) || PCJR)) + picintlevel(1 << sp->irq); + else + picintc(1 << sp->irq); } @@ -223,14 +212,13 @@ serial_timer(void *priv) /* Write data to the (input) FIFO. Used by MOUSE driver. */ void -serial_write_fifo(SERIAL *sp, uint8_t dat, int intr) +serial_write_fifo(SERIAL *sp, uint8_t dat) { - /* Stuff data into RX FIFO. */ + /* Stuff data into FIFO. */ sp->fifo[sp->fifo_write] = dat; sp->fifo_write = (sp->fifo_write + 1) & 0xFF; - /* If requested, generate interrupt. */ - if (intr && !(sp->lsr & LSR_DR)) { + if (! (sp->lsr & LSR_DR)) { sp->lsr |= LSR_DR; sp->int_status |= SERINT_RECEIVE; update_ints(sp); @@ -238,31 +226,12 @@ serial_write_fifo(SERIAL *sp, uint8_t dat, int intr) } -/* Grab data from the RX fifo. */ static uint8_t -serial_read_fifo(SERIAL *sp) +read_fifo(SERIAL *sp) { - if (sp->fifo_read != sp->fifo_write) { - /* Grab data from the fifo. */ + if (sp->fifo_read != sp->fifo_write) { sp->dat = sp->fifo[sp->fifo_read]; - sp->fifo_read = (sp->fifo_read+1) & 0xFF; - - /* If we have more, generate (new) int. */ - if (sp->fifo_read != sp->fifo_write) { -#if 1 - sp->receive_delay = 1000*TIMER_USEC; -#else - if (sp->bh != NULL) { - sp->int_status |= SERINT_RECEIVE; - sp->lsr |= LSR_DR; - - /* Update interrupt state. */ - update_ints(sp); - } else { - sp->receive_delay = 1000*TIMER_USEC; - } -#endif - } + sp->fifo_read = (sp->fifo_read + 1) & 0xFF; } return(sp->dat); @@ -284,46 +253,41 @@ serial_write(uint16_t addr, uint8_t val, void *priv) switch (addr & 0x07) { case 0: /* DATA / DLAB1 */ if (sp->lcr & LCR_DLAB) { - /* DLAB set, set DLAB low byte. */ sp->dlab1 = val; - } else { - /* DLAB clear, regular data write. */ - sp->thr = val; - if (sp->bh != NULL) { - /* We are linked, so send to BH layer. */ - bhtty_write((BHTTY *)sp->bh, sp->thr); - } + return; + } + sp->thr = val; + if (sp->bh != NULL) { + /* We are linked, so send to BH layer. */ + bhtty_write((BHTTY *)sp->bh, sp->thr); - /* WRITE completed, we are ready for more. */ + /* The WRITE completed, we are ready for more. */ sp->lsr |= LSR_THRE; sp->int_status |= SERINT_TRANSMIT; update_ints(sp); + } else { + /* Not linked. Just fake LOOPBACK mode. */ + if (! (sp->mctrl & MCR_LMS)) + serial_write_fifo(sp, val); + } - if (sp->mctrl & MCR_LMS) { - /* Echo data back to RX. */ - serial_write_fifo(sp, val, 1); - } + if (sp->mctrl & MCR_LMS) { + /* Echo data back to RX. */ + serial_write_fifo(sp, val); } break; case 1: /* IER / DLAB2 */ if (sp->lcr & LCR_DLAB) { - /* DLAB set, set DLAB high byte. */ sp->dlab2 = val; - } else { - /* DLAB clear, set IER register bits. */ - sp->ier = (val & IER_MASK); - - /* Generate interrupt if needed. */ - update_ints(sp); + return; } + sp->ier = (val & IER_MASK); + update_ints(sp); break; case 2: /* FCR */ - if (sp->type >= UART_TYPE_16550A) { -serial_log(0, "Serial%d: tried to enable FIFO (%02x), type %d!\n", sp->port, val, sp->type); - sp->fcr = val; - } + sp->fcr = val; break; case 3: /* LCR */ @@ -351,17 +315,12 @@ serial_log(0, "Serial%d: tried to enable FIFO (%02x), type %d!\n", sp->port, val #ifdef ENABLE_SERIAL_LOG serial_log(2, "Serial%d: WL=%d SB=%d PA=%d\n", sp->port, wl, sb, pa); #endif - sp->lcr = val; if (sp->bh != NULL) bhtty_params((BHTTY *)sp->bh, wl, pa, sb); + sp->lcr = val; break; - case 4: /*MCR*/ - if (sp->bh == NULL) { - /* Not linked, force LOOPBACK mode. */ - val |= MCR_LMS; - } - + case 4: if ((val & MCR_RTS) && !(sp->mctrl & MCR_RTS)) { /* * This is old code for use by the Serial Mouse @@ -396,28 +355,28 @@ serial_log(0, "Serial%d: tried to enable FIFO (%02x), type %d!\n", sp->port, val } } sp->mctrl = val; - if (val & MCR_LMS) { /* loopback mode */ uint8_t new_msr; + /*FIXME: WTF does this do?? --FvK */ new_msr = (val & 0x0c) << 4; new_msr |= (val & MCR_RTS) ? MCR_LMS : 0; new_msr |= (val & MCR_DTR) ? MCR_AUTOFLOW : 0; - if ((sp->msr ^ new_msr) & MSR_CTS) - new_msr |= MSR_DCTS; - if ((sp->msr ^ new_msr) & MSR_DSR) - new_msr |= MSR_DDSR; - if ((sp->msr ^ new_msr) & MSR_DCD) - new_msr |= MSR_DDCD; - if ((sp->msr & MSR_TERI) && !(new_msr & MSR_RI)) - new_msr |= MSR_TERI; + if ((sp->msr ^ new_msr) & 0x10) + new_msr |= MCR_DTR; + if ((sp->msr ^ new_msr) & 0x20) + new_msr |= MCR_RTS; + if ((sp->msr ^ new_msr) & 0x80) + new_msr |= 0x08; + if ((sp->msr & 0x40) && !(new_msr & 0x40)) + new_msr |= 0x04; sp->msr = new_msr; } break; - case 5: /*LSR*/ + case 5: sp->lsr = val; if (sp->lsr & LSR_DR) sp->int_status |= SERINT_RECEIVE; @@ -428,7 +387,7 @@ serial_log(0, "Serial%d: tried to enable FIFO (%02x), type %d!\n", sp->port, val update_ints(sp); break; - case 6: /*MSR*/ + case 6: sp->msr = val; if (sp->msr & MSR_MASK) sp->int_status |= SERINT_MSR; @@ -436,9 +395,7 @@ serial_log(0, "Serial%d: tried to enable FIFO (%02x), type %d!\n", sp->port, val break; case 7: - if (sp->type > UART_TYPE_8250) { - sp->scratch = val; - } + sp->scratch = val; break; } } @@ -456,17 +413,8 @@ serial_rd_done(void *arg, int num) if (bhtty_read(sp->bh, &sp->hold, 1) < 0) break; /* Stuff it into the FIFO and set intr. */ -#if 1 - serial_write_fifo(sp, sp->hold, 0); -#else - serial_write_fifo(sp, sp->hold, 1); -#endif + serial_write_fifo(sp, sp->hold); } - -#if 1 - /* We have data waiting for us.. delay a little, and then read it. */ - timer_add(serial_timer, &sp->receive_delay, &sp->receive_delay, sp); -#endif } @@ -480,48 +428,30 @@ serial_read(uint16_t addr, void *priv) switch (addr&0x07) { case 0: /* DATA / DLAB1 */ if (sp->lcr & LCR_DLAB) { - /* DLAB set, read DLAB low byte. */ ret = sp->dlab1; } else { - /* - * DLAB clear, regular data read. - * First, clear the RXDATA interrupt. - */ - sp->int_status &= ~SERINT_RECEIVE; sp->lsr &= ~LSR_DR; - - /* If there is data in the RX FIFO, grab it. */ - ret = serial_read_fifo(sp); -serial_log(0, "Serial%d: read RBR: %02X\n",sp->port, ret); + sp->int_status &= ~SERINT_RECEIVE; + update_ints(sp); + ret = read_fifo(sp); + if ((sp->bh == NULL) && + (sp->fifo_read != sp->fifo_write)) + sp->receive_delay = 1000 * TIMER_USEC; } break; case 1: /* LCR / DLAB2 */ - if (sp->lcr & LCR_DLAB) { - /* DLAB set, read DLAB high byte. */ - ret = sp->dlab2; - } else { - /* DLAB clear, read IER register bits. */ - ret = sp->ier; - } + ret = (sp->lcr & LCR_DLAB) ? sp->dlab2 : sp->ier; break; case 2: /* IIR */ ret = sp->iir; -serial_log(0, "Serial%d: read IIR: %02X\n",sp->port, sp->iir); - if ((ret & IIR_IID) == IID_IDTX) { - /* Transmit is done. */ sp->int_status &= ~SERINT_TRANSMIT; update_ints(sp); } - - if (sp->type >= UART_TYPE_16550A) { - /* If FIFO enabled.. */ - if (sp->fcr & 0x01) - /* Report FIFO active. */ - ret |= 0xc0; - } + if (sp->fcr & 0x01) + ret |= 0xc0; break; case 3: /* LCR */ @@ -533,10 +463,6 @@ serial_log(0, "Serial%d: read IIR: %02X\n",sp->port, sp->iir); break; case 5: /* LSR */ - /* Clear interrupt state. */ - sp->int_status &= ~SERINT_LSR; - update_ints(sp); - if (sp->lsr & LSR_THRE) sp->lsr |= LSR_TEMT; sp->lsr |= LSR_THRE; @@ -546,24 +472,19 @@ serial_log(0, "Serial%d: read IIR: %02X\n",sp->port, sp->iir); #if 0 sp->lsr |= (LSR_THRE | LSR_TEMT); #endif + sp->int_status &= ~SERINT_LSR; + update_ints(sp); break; case 6: - /* Clear MSR interrupt status. */ + ret = sp->msr; + sp->msr &= ~0x0f; sp->int_status &= ~SERINT_MSR; update_ints(sp); - - /* Grab current modem status. */ - ret = sp->msr; - - /* Reset the delta bits. */ - sp->msr &= ~0x0f; break; case 7: - if (sp->type > UART_TYPE_8250) { - ret = sp->scratch; - } + ret = sp->scratch; break; } @@ -642,7 +563,6 @@ serial_init(void) sp = &ports[i]; memset(sp, 0x00, sizeof(SERIAL)); sp->port = (i+1); - sp->type = UART_TYPE_8250; if (i == 0) serial_setup(sp->port, SERIAL1_ADDR, SERIAL1_IRQ); @@ -650,9 +570,9 @@ serial_init(void) serial_setup(sp->port, SERIAL2_ADDR, SERIAL2_IRQ); } - /* Link to host port. */ #ifdef WALTJE -// serial_link(1, "COM1"); + /* Link to host port. */ + serial_link(1, "COM1"); serial_link(2, "COM2"); #endif } diff --git a/src/serial.h b/src/serial.h index 09b1b24e6..4602429f0 100644 --- a/src/serial.h +++ b/src/serial.h @@ -8,7 +8,7 @@ * * Definitions for the SERIAL card. * - * Version: @(#)serial.h 1.0.5 2017/06/07 + * Version: @(#)serial.h 1.0.4 2017/06/03 * * Author: Fred N. van Kempen, * Copyright 2017 Fred N. van Kempen. @@ -24,27 +24,16 @@ #define SERIAL2_IRQ 3 -/* Supported UART types. */ -#define UART_TYPE_8250 0 /* standard NS8250 */ -#define UART_TYPE_8250A 1 /* updated NS8250(A) */ -#define UART_TYPE_16450 2 /* 16450 */ -#define UART_TYPE_16550 3 /* 16550 (broken fifo) */ -#define UART_TYPE_16550A 4 /* 16550a (working fifo) */ -#define UART_TYPE_16670 5 /* 64b fifo */ - - typedef struct _serial_ { int8_t port; /* port number (1,2,..) */ int8_t irq; /* IRQ channel used */ uint16_t addr; /* I/O address used */ - int8_t type; /* UART type */ - uint8_t int_status; uint8_t lsr, thr, mctrl, rcr, /* UART registers */ iir, ier, lcr, msr; uint8_t dlab1, dlab2; - uint8_t dat, - hold; + uint8_t dat; + uint8_t int_status; uint8_t scratch; uint8_t fcr; @@ -52,6 +41,7 @@ typedef struct _serial_ { void (*rts_callback)(void *); void *rts_callback_p; + uint8_t hold; uint8_t fifo[256]; int fifo_read, fifo_write; @@ -68,7 +58,7 @@ extern void serial_setup(int port, uint16_t addr, int irq); extern void serial_remove(int port); extern SERIAL *serial_attach(int, void *, void *); extern int serial_link(int, char *); -extern void serial_write_fifo(SERIAL *, uint8_t, int); +extern void serial_write_fifo(SERIAL *, uint8_t); #endif /*EMU_SERIAL_H*/ From 66ff71ca554c878c3a5901b4a47805eb50ef4bb0 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 17 Jun 2017 00:50:51 +0200 Subject: [PATCH 4/5] Applied the latest mainline PCem commits. --- src/CPU/codegen_timing_pentium.c | 185 +++++++++++++++++++++++++------ src/SOUND/snd_gus.c | 60 ++++++---- src/dma.c | 3 +- 3 files changed, 197 insertions(+), 51 deletions(-) diff --git a/src/CPU/codegen_timing_pentium.c b/src/CPU/codegen_timing_pentium.c index e5e4ed13d..9533027f4 100644 --- a/src/CPU/codegen_timing_pentium.c +++ b/src/CPU/codegen_timing_pentium.c @@ -42,6 +42,11 @@ static int pair_timings[4][4] = #define CYCLES_RMW (2 << 0) #define CYCLES_BRANCH (3 << 0) +/*Instruction has immediate data. Can only be used with PAIR_U/PAIR_V/PAIR_UV*/ +#define CYCLES_HASIMM (3 << 2) +#define CYCLES_IMM8 (1 << 2) +#define CYCLES_IMM1632 (2 << 2) + #define CYCLES_MASK ((1 << 7) - 1) /*Instruction is MMX shift or pack/unpack instruction*/ @@ -62,6 +67,8 @@ static int pair_timings[4][4] = /*Instruction is FXCH and only pairs in V pipe with FX pairable instruction*/ #define PAIR_FXCH (6 << 29) +#define PAIR_FPU (4 << 29) + #define PAIR_MASK (7 << 29) /*Instruction has input dependency on register in REG field*/ @@ -296,38 +303,38 @@ static uint32_t opcode_timings_mod3[256] = /* ADD ADD ADD ADD*/ /*00*/ PAIR_UV | CYCLES_REG | SRCDEP_REG | SRCDEP_RM | DSTDEP_REG, PAIR_UV | CYCLES_REG | SRCDEP_REG | SRCDEP_RM | DSTDEP_REG, PAIR_UV | CYCLES_REG | SRCDEP_REG | SRCDEP_RM | DSTDEP_REG, PAIR_UV | CYCLES_REG | SRCDEP_REG | SRCDEP_RM | DSTDEP_REG, /* ADD ADD PUSH ES POP ES*/ - PAIR_UV | CYCLES_REG | SRCDEP_EAX | SRCDEP_RM | DSTDEP_EAX, PAIR_UV | CYCLES_REG | SRCDEP_EAX | SRCDEP_RM | DSTDEP_EAX, PAIR_NP | CYCLES(1), PAIR_NP | CYCLES(3), + PAIR_UV | CYCLES_REG | SRCDEP_EAX | DSTDEP_EAX, PAIR_UV | CYCLES_REG | SRCDEP_EAX | DSTDEP_EAX, PAIR_NP | CYCLES(1), PAIR_NP | CYCLES(3), /* OR OR OR OR*/ PAIR_UV | CYCLES_REG | SRCDEP_REG | SRCDEP_RM | DSTDEP_REG, PAIR_UV | CYCLES_REG | SRCDEP_REG | SRCDEP_RM | DSTDEP_REG, PAIR_UV | CYCLES_REG | SRCDEP_REG | SRCDEP_RM | DSTDEP_REG, PAIR_UV | CYCLES_REG | SRCDEP_REG | SRCDEP_RM | DSTDEP_REG, /* OR OR PUSH CS */ - PAIR_UV | CYCLES_REG | SRCDEP_EAX | SRCDEP_RM | DSTDEP_EAX, PAIR_UV | CYCLES_REG | SRCDEP_EAX | SRCDEP_RM | DSTDEP_EAX, PAIR_NP | CYCLES(1), INVALID, + PAIR_UV | CYCLES_REG | SRCDEP_EAX | DSTDEP_EAX, PAIR_UV | CYCLES_REG | SRCDEP_EAX | DSTDEP_EAX, PAIR_NP | CYCLES(1), INVALID, /* ADC ADC ADC ADC*/ /*10*/ PAIR_U | CYCLES_REG | SRCDEP_REG | SRCDEP_RM | DSTDEP_REG, PAIR_U | CYCLES_REG | SRCDEP_REG | SRCDEP_RM | DSTDEP_REG, PAIR_U | CYCLES_REG | SRCDEP_REG | SRCDEP_RM | DSTDEP_REG, PAIR_U | CYCLES_REG | SRCDEP_REG | SRCDEP_RM | DSTDEP_REG, /* ADC ADC PUSH SS POP SS*/ - PAIR_U | CYCLES_REG | SRCDEP_EAX | SRCDEP_RM | DSTDEP_EAX, PAIR_U | CYCLES_REG | SRCDEP_EAX | SRCDEP_RM | DSTDEP_EAX, PAIR_NP | CYCLES(1), PAIR_NP | CYCLES(3), + PAIR_U | CYCLES_REG | SRCDEP_EAX | DSTDEP_EAX, PAIR_U | CYCLES_REG | SRCDEP_EAX | DSTDEP_EAX, PAIR_NP | CYCLES(1), PAIR_NP | CYCLES(3), /* SBB SBB SBB SBB*/ PAIR_U | CYCLES_REG | SRCDEP_REG | SRCDEP_RM | DSTDEP_REG, PAIR_U | CYCLES_REG | SRCDEP_REG | SRCDEP_RM | DSTDEP_REG, PAIR_U | CYCLES_REG | SRCDEP_REG | SRCDEP_RM | DSTDEP_REG, PAIR_U | CYCLES_REG | SRCDEP_REG | SRCDEP_RM | DSTDEP_REG, /* SBB SBB PUSH DS POP DS*/ - PAIR_U | CYCLES_REG | SRCDEP_EAX | SRCDEP_RM | DSTDEP_EAX, PAIR_U | CYCLES_REG | SRCDEP_EAX | SRCDEP_RM | DSTDEP_EAX, PAIR_NP | CYCLES(1), PAIR_NP | CYCLES(3), + PAIR_U | CYCLES_REG | SRCDEP_EAX | DSTDEP_EAX, PAIR_U | CYCLES_REG | SRCDEP_EAX | DSTDEP_EAX, PAIR_NP | CYCLES(1), PAIR_NP | CYCLES(3), /* AND AND AND AND*/ /*20*/ PAIR_UV | CYCLES_REG | SRCDEP_REG | SRCDEP_RM | DSTDEP_REG, PAIR_UV | CYCLES_REG | SRCDEP_REG | SRCDEP_RM | DSTDEP_REG, PAIR_UV | CYCLES_REG | SRCDEP_REG | SRCDEP_RM | DSTDEP_REG, PAIR_UV | CYCLES_REG | SRCDEP_REG | SRCDEP_RM | DSTDEP_REG, /* AND AND DAA*/ - PAIR_UV | CYCLES_REG | SRCDEP_EAX | SRCDEP_RM | DSTDEP_EAX, PAIR_UV | CYCLES_REG | SRCDEP_EAX | SRCDEP_RM | DSTDEP_EAX, INVALID, PAIR_NP | CYCLES(3), + PAIR_UV | CYCLES_REG | SRCDEP_EAX | DSTDEP_EAX, PAIR_UV | CYCLES_REG | SRCDEP_EAX | DSTDEP_EAX, INVALID, PAIR_NP | CYCLES(3), /* SUB SUB SUB SUB*/ PAIR_UV | CYCLES_REG | SRCDEP_REG | SRCDEP_RM | DSTDEP_REG, PAIR_UV | CYCLES_REG | SRCDEP_REG | SRCDEP_RM | DSTDEP_REG, PAIR_UV | CYCLES_REG | SRCDEP_REG | SRCDEP_RM | DSTDEP_REG, PAIR_UV | CYCLES_REG | SRCDEP_REG | SRCDEP_RM | DSTDEP_REG, /* SUB SUB DAS*/ - PAIR_UV | CYCLES_REG | SRCDEP_EAX | SRCDEP_RM | DSTDEP_EAX, PAIR_UV | CYCLES_REG | SRCDEP_EAX | SRCDEP_RM | DSTDEP_EAX, INVALID, PAIR_NP | CYCLES(3), + PAIR_UV | CYCLES_REG | SRCDEP_EAX | DSTDEP_EAX, PAIR_UV | CYCLES_REG | SRCDEP_EAX | DSTDEP_EAX, INVALID, PAIR_NP | CYCLES(3), /* XOR XOR XOR XOR*/ /*30*/ PAIR_UV | CYCLES_REG | SRCDEP_REG | SRCDEP_RM | DSTDEP_REG, PAIR_UV | CYCLES_REG | SRCDEP_REG | SRCDEP_RM | DSTDEP_REG, PAIR_UV | CYCLES_REG | SRCDEP_REG | SRCDEP_RM | DSTDEP_REG, PAIR_UV | CYCLES_REG | SRCDEP_REG | SRCDEP_RM | DSTDEP_REG, /* XOR XOR AAA*/ - PAIR_UV | CYCLES_REG | SRCDEP_EAX | SRCDEP_RM | DSTDEP_EAX, PAIR_UV | CYCLES_REG | SRCDEP_EAX | SRCDEP_RM | DSTDEP_EAX, INVALID, PAIR_NP | CYCLES(3), + PAIR_UV | CYCLES_REG | SRCDEP_EAX | DSTDEP_EAX, PAIR_UV | CYCLES_REG | SRCDEP_EAX | DSTDEP_EAX, INVALID, PAIR_NP | CYCLES(3), /* CMP CMP CMP CMP*/ PAIR_UV | CYCLES_REG | SRCDEP_REG | SRCDEP_RM, PAIR_UV | CYCLES_REG | SRCDEP_REG | SRCDEP_RM, PAIR_UV | CYCLES_REG | SRCDEP_REG | SRCDEP_RM, PAIR_UV | CYCLES_REG | SRCDEP_RM | SRCDEP_REG, /* CMP CMP AAS*/ - PAIR_UV | CYCLES_REG | SRCDEP_EAX | SRCDEP_RM, PAIR_UV | CYCLES_REG | SRCDEP_EAX, INVALID, PAIR_NP | CYCLES(3), + PAIR_UV | CYCLES_REG | SRCDEP_EAX, PAIR_UV | CYCLES_REG | SRCDEP_EAX, INVALID, PAIR_NP | CYCLES(3), /* INC EAX INC ECX INC EDX INC EBX*/ /*40*/ PAIR_UV | CYCLES_REG | SRCDEP_EAX | DSTDEP_EAX, PAIR_UV | CYCLES_REG | SRCDEP_ECX | DSTDEP_ECX, PAIR_UV | CYCLES_REG | SRCDEP_EDX | DSTDEP_EDX, PAIR_UV | CYCLES_REG | SRCDEP_EBX | DSTDEP_EBX, @@ -810,14 +817,20 @@ static uint32_t opcode_timings_df_mod3[8] = PAIR_NP | CYCLES(2), INVALID, INVALID, INVALID }; +static uint32_t opcode_timings_81[8] = +{ + PAIR_UV | CYCLES_RMW | SRCDEP_REG | CYCLES_IMM1632, PAIR_UV | CYCLES_RMW | SRCDEP_REG | CYCLES_IMM1632, PAIR_UV | CYCLES_RMW | SRCDEP_REG | CYCLES_IMM1632, PAIR_UV | CYCLES_RMW | SRCDEP_REG | CYCLES_IMM1632, + PAIR_UV | CYCLES_RMW | SRCDEP_REG | CYCLES_IMM1632, PAIR_UV | CYCLES_RMW | SRCDEP_REG | CYCLES_IMM1632, PAIR_UV | CYCLES_RMW | SRCDEP_REG | CYCLES_IMM1632, PAIR_UV | CYCLES_RM | SRCDEP_REG | CYCLES_IMM1632 +}; static uint32_t opcode_timings_8x[8] = { - PAIR_UV | CYCLES_RMW | SRCDEP_REG, PAIR_UV | CYCLES_RMW | SRCDEP_REG, PAIR_UV | CYCLES_RMW | SRCDEP_REG, PAIR_UV | CYCLES_RMW | SRCDEP_REG, - PAIR_UV | CYCLES_RMW | SRCDEP_REG, PAIR_UV | CYCLES_RMW | SRCDEP_REG, PAIR_UV | CYCLES_RMW | SRCDEP_REG, PAIR_UV | CYCLES_RM | SRCDEP_REG + PAIR_UV | CYCLES_RMW | SRCDEP_REG | CYCLES_IMM8, PAIR_UV | CYCLES_RMW | SRCDEP_REG | CYCLES_IMM8, PAIR_UV | CYCLES_RMW | SRCDEP_REG | CYCLES_IMM8, PAIR_UV | CYCLES_RMW | SRCDEP_REG | CYCLES_IMM8, + PAIR_UV | CYCLES_RMW | SRCDEP_REG | CYCLES_IMM8, PAIR_UV | CYCLES_RMW | SRCDEP_REG | CYCLES_IMM8, PAIR_UV | CYCLES_RMW | SRCDEP_REG | CYCLES_IMM8, PAIR_UV | CYCLES_RM | SRCDEP_REG | CYCLES_IMM8 }; static int decode_delay; static uint8_t last_prefix; +static int prefixes; static inline int COUNT(uint32_t c, int op_32) { @@ -831,6 +844,10 @@ static inline int COUNT(uint32_t c, int op_32) return c & 0xffff; if ((c & PAIR_MASK) == PAIR_FX) return c & 0xffff; + if ((c & PAIR_MASK) == PAIR_FXCH) + return c & 0xffff; + if ((c & PAIR_UV) && !(c & PAIR_FPU)) + c &= 3; switch (c & CYCLES_MASK) { case CYCLES_REG: @@ -848,6 +865,80 @@ static inline int COUNT(uint32_t c, int op_32) return c; } +static inline int codegen_timing_has_displacement(uint32_t fetchdat, int op_32) +{ + if (op_32 & 0x200) + { + if ((fetchdat & 7) == 4 && (fetchdat & 0xc0) != 0xc0) + { + /*Has SIB*/ + if ((fetchdat & 0xc0) == 0x40 || (fetchdat & 0xc0) == 0x80 || (fetchdat & 0x700) == 0x500) + return 1; + } + else + { + if ((fetchdat & 0xc0) == 0x40 || (fetchdat & 0xc0) == 0x80 || (fetchdat & 0xc7) == 0x05) + return 1; + } + } + else + { + if ((fetchdat & 0xc0) == 0x40 || (fetchdat & 0xc0) == 0x80 || (fetchdat & 0xc7) == 0x06) + return 1; + } + return 0; +} + +/*The instruction is only of interest here if it's longer than 7 bytes, as that's the + limit on Pentium MMX parallel decoding*/ +static inline int codegen_timing_instr_length(uint32_t timing, uint32_t fetchdat, int op_32) +{ + int len = prefixes; + if ((timing & CYCLES_MASK) == CYCLES_RM || (timing & CYCLES_MASK) == CYCLES_RMW) + { + len += 2; /*Opcode + ModR/M*/ + if ((timing & CYCLES_HASIMM) == CYCLES_IMM8) + len++; + if ((timing & CYCLES_HASIMM) == CYCLES_IMM1632) + len += (op_32 & 0x100) ? 4 : 2; + + if (op_32 & 0x200) + { + if ((fetchdat & 7) == 4 && (fetchdat & 0xc0) != 0xc0) + { + /* Has SIB*/ + len++; + if ((fetchdat & 0xc0) == 0x40) + len++; + else if ((fetchdat & 0xc0) == 0x80) + len += 4; + else if ((fetchdat & 0x700) == 0x500) + len += 4; + } + else + { + if ((fetchdat & 0xc0) == 0x40) + len++; + else if ((fetchdat & 0xc0) == 0x80) + len += 4; + else if ((fetchdat & 0xc7) == 0x05) + len += 4; + } + } + else + { + if ((fetchdat & 0xc0) == 0x40) + len++; + else if ((fetchdat & 0xc0) == 0x80) + len += 2; + else if ((fetchdat & 0xc7) == 0x06) + len += 2; + } + } + + return len; +} + void codegen_timing_pentium_block_start() { u_pipe_full = decode_delay = 0; @@ -856,10 +947,12 @@ void codegen_timing_pentium_block_start() void codegen_timing_pentium_start() { last_prefix = 0; + prefixes = 0; } void codegen_timing_pentium_prefix(uint8_t prefix, uint32_t fetchdat) { + prefixes++; if (cpu_hasMMX && prefix == 0x0f) { /*On Pentium MMX 0fh prefix is 'free'*/ @@ -933,11 +1026,16 @@ void codegen_timing_pentium_opcode(uint8_t opcode, uint32_t fetchdat, int op_32) default: switch (opcode) { - case 0x80: case 0x81: case 0x82: case 0x83: + case 0x80: case 0x82: case 0x83: timings = mod3 ? opcode_timings_mod3 : opcode_timings_8x; if (!mod3) opcode = (fetchdat >> 3) & 7; break; + case 0x81: + timings = mod3 ? opcode_timings_mod3 : opcode_timings_81; + if (!mod3) + opcode = (fetchdat >> 3) & 7; + break; case 0xc0: case 0xc1: case 0xd0: case 0xd1: case 0xd2: case 0xd3: timings = mod3 ? opcode_timings_shift_mod3 : opcode_timings_shift; @@ -980,23 +1078,38 @@ void codegen_timing_pentium_opcode(uint8_t opcode, uint32_t fetchdat, int op_32) if ((timings[opcode] & PAIR_V) && !(u_pipe_regmask & regmask) && !decode_delay) { - int t1 = u_pipe_timings[u_pipe_opcode] & CYCLES_MASK; - int t2 = timings[opcode] & CYCLES_MASK; - int t_pair; + int has_displacement; - if (t1 < 0 || t2 < 0 || t1 > CYCLES_BRANCH || t2 > CYCLES_BRANCH) - fatal("Pair out of range\n"); + if (timings[opcode] & CYCLES_HASIMM) + has_displacement = codegen_timing_has_displacement(fetchdat, op_32); + else + has_displacement = 0; + + if (!has_displacement && (!cpu_hasMMX || codegen_timing_instr_length(timings[opcode], fetchdat, op_32) <= 7)) + { + int t1 = u_pipe_timings[u_pipe_opcode] & CYCLES_MASK; + int t2 = timings[opcode] & CYCLES_MASK; + int t_pair; - t_pair = pair_timings[t1][t2]; - if (t_pair < 1) - fatal("Illegal pair timings : t1=%i t2=%i u_opcode=%02x v_opcode=%02x\n", t1, t2, u_pipe_opcode, opcode); + if (!(u_pipe_timings[u_pipe_opcode] & PAIR_FPU)) + t1 &= 3; + if (!(timings[opcode] & PAIR_FPU)) + t2 &= 3; + + if (t1 < 0 || t2 < 0 || t1 > CYCLES_BRANCH || t2 > CYCLES_BRANCH) + fatal("Pair out of range\n"); + + t_pair = pair_timings[t1][t2]; + if (t_pair < 1) + fatal("Illegal pair timings : t1=%i t2=%i u_opcode=%02x v_opcode=%02x\n", t1, t2, u_pipe_opcode, opcode); - codegen_block_cycles += t_pair; - decode_delay = (-t_pair) + 1; + codegen_block_cycles += t_pair; + decode_delay = (-t_pair) + 1; - /*Instruction can pair with previous*/ - u_pipe_full = 0; - return; + /*Instruction can pair with previous*/ + u_pipe_full = 0; + return; + } } nopair: /*Instruction can not pair with previous*/ @@ -1008,13 +1121,23 @@ nopair: if ((timings[opcode] & PAIR_U) && !decode_delay) { - /*Instruction might pair with next*/ - u_pipe_full = 1; - u_pipe_opcode = opcode; - u_pipe_timings = timings; - u_pipe_op_32 = op_32; - u_pipe_regmask = get_dstdep_mask(timings[opcode], fetchdat, bit8); - return; + int has_displacement; + + if (timings[opcode] & CYCLES_HASIMM) + has_displacement = codegen_timing_has_displacement(fetchdat, op_32); + else + has_displacement = 0; + + if ((!has_displacement || cpu_hasMMX) && (!cpu_hasMMX || codegen_timing_instr_length(timings[opcode], fetchdat, op_32) <= 7)) + { + /*Instruction might pair with next*/ + u_pipe_full = 1; + u_pipe_opcode = opcode; + u_pipe_timings = timings; + u_pipe_op_32 = op_32; + u_pipe_regmask = get_dstdep_mask(timings[opcode], fetchdat, bit8); + return; + } } /*Instruction can not pair and must run now*/ diff --git a/src/SOUND/snd_gus.c b/src/SOUND/snd_gus.c index bf625dfb2..3981b4960 100644 --- a/src/SOUND/snd_gus.c +++ b/src/SOUND/snd_gus.c @@ -2,14 +2,14 @@ #include #include #include "../ibm.h" + +#include "../device.h" +#include "../dma.h" #include "../io.h" #include "../pic.h" -#include "../dma.h" -#include "../timer.h" -#include "../device.h" #include "sound.h" #include "snd_gus.h" - +#include "../timer.h" typedef struct gus_t { @@ -235,7 +235,7 @@ void writegus(uint16_t addr, uint8_t val, void *p) case 0xA: /*Current addr high*/ gus->cur[gus->voice]=(gus->cur[gus->voice]&0x1F00FFFF)|(val<<16); -gus->curx[gus->voice]=(gus->curx[gus->voice]&0xF807F00)|((val<<7)<<8); + gus->curx[gus->voice]=(gus->curx[gus->voice]&0xF807F00)|((val<<7)<<8); break; case 0xB: /*Current addr low*/ gus->cur[gus->voice]=(gus->cur[gus->voice]&0x1FFFFF00)|val; @@ -257,10 +257,6 @@ gus->curx[gus->voice]=(gus->curx[gus->voice]&0xF807F00)|((val<<7)<<8); switch (gus->global) { case 0: /*Voice control*/ - if (!(val&1) && gus->ctrl[gus->voice]&1) - { - } - gus->ctrl[gus->voice] = val & 0x7f; old = gus->waveirqs[gus->voice]; @@ -307,7 +303,7 @@ gus->curx[gus->voice]=(gus->curx[gus->voice]&0xF807F00)|((val<<7)<<8); break; case 0xB: /*Current addr low*/ gus->cur[gus->voice]=(gus->cur[gus->voice]&0x1FFF00FF)|(val<<8); -gus->curx[gus->voice]=(gus->curx[gus->voice]&0xFFF8000)|((val&0x7F)<<8); + gus->curx[gus->voice]=(gus->curx[gus->voice]&0xFFF8000)|((val&0x7F)<<8); break; case 0xC: /*Pan*/ gus->pan_l[gus->voice] = 15 - (val & 0xf); @@ -341,13 +337,27 @@ gus->curx[gus->voice]=(gus->curx[gus->voice]&0xFFF8000)|((val&0x7F)<<8); while (c<65536) { int dma_result; - d = gus->ram[gus->dmaaddr]; - if (val & 0x80) d ^= 0x80; - dma_result = dma_channel_write(gus->dma, d); - if (dma_result == DMA_NODATA) - break; + if (val & 0x04) + { + uint32_t gus_addr = (gus->dmaaddr & 0xc0000) | ((gus->dmaaddr & 0x1ffff) << 1); + d = gus->ram[gus_addr] | (gus->ram[gus_addr + 1] << 8); + if (val & 0x80) + d ^= 0x8080; + dma_result = dma_channel_write(gus->dma, d); + if (dma_result == DMA_NODATA) + break; + } + else + { + d = gus->ram[gus->dmaaddr]; + if (val & 0x80) + d ^= 0x80; + dma_result = dma_channel_write(gus->dma, d); + if (dma_result == DMA_NODATA) + break; + } gus->dmaaddr++; - gus->dmaaddr&=0xFFFFF; + gus->dmaaddr &= 0xFFFFF; c++; if (dma_result & DMA_OVER) break; @@ -363,10 +373,22 @@ gus->curx[gus->voice]=(gus->curx[gus->voice]&0xFFF8000)|((val&0x7F)<<8); d = dma_channel_read(gus->dma); if (d == DMA_NODATA) break; - if (val&0x80) d^=0x80; - gus->ram[gus->dmaaddr]=d; + if (val & 0x04) + { + uint32_t gus_addr = (gus->dmaaddr & 0xc0000) | ((gus->dmaaddr & 0x1ffff) << 1); + if (val & 0x80) + d ^= 0x8080; + gus->ram[gus_addr] = d & 0xff; + gus->ram[gus_addr +1] = (d >> 8) & 0xff; + } + else + { + if (val & 0x80) + d ^= 0x80; + gus->ram[gus->dmaaddr] = d; + } gus->dmaaddr++; - gus->dmaaddr&=0xFFFFF; + gus->dmaaddr &= 0xFFFFF; c++; if (d & DMA_OVER) break; diff --git a/src/dma.c b/src/dma.c index 96f98bd96..ae95ffafa 100644 --- a/src/dma.c +++ b/src/dma.c @@ -705,11 +705,12 @@ int dma_channel_write(int channel, uint16_t val) dma16.cc[channel] = dma16.cb[channel] + 1; dma16.ac[channel] = dma16.ab[channel]; } + else dma16.m |= (1 << channel); dma16.stat |= (1 << channel); } - if (dma.m & (1 << channel)) + if (dma16.m & (1 << channel)) return DMA_OVER; } return 0; From c68b460b53e0f95dc00d06bb1d4b1973afb9c1ce Mon Sep 17 00:00:00 2001 From: TC1995 Date: Sat, 17 Jun 2017 01:01:40 +0200 Subject: [PATCH 5/5] Fixed (again) massive OS/2 S3 Trio64 driver spam and MIX + src_dat variable initialized properly + warning gone. --- src/VIDEO/vid_s3.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/src/VIDEO/vid_s3.c b/src/VIDEO/vid_s3.c index 61a24ce64..3079eec9b 100644 --- a/src/VIDEO/vid_s3.c +++ b/src/VIDEO/vid_s3.c @@ -1444,7 +1444,6 @@ uint8_t s3_accel_read(uint32_t addr, void *p) case 0xf: dest_dat = ~(src_dat | dest_dat); break; \ } - #define WRITE(addr) if (s3->bpp == 0) \ { \ svga->vram[(addr) & s3->vram_mask] = dest_dat; \ @@ -1660,6 +1659,15 @@ void s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat s3->accel.dest = s3->accel.cy * s3->width; } + + s3->status_9ae9 = 4; /*To avoid the spam from OS/2's drivers*/ + + if ((s3->accel.cmd & 0x100) && !cpu_input) + { + s3->status_9ae9 = 2; /*To avoid the spam from OS/2's drivers*/ + return; /*Wait for data from CPU*/ + } + if ((s3->accel.cmd & 0x100) && !cpu_input) return; /*Wait for data from CPU*/ frgd_mix = (s3->accel.frgd_mix >> 5) & 3; @@ -1685,7 +1693,7 @@ void s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat READ(s3->accel.dest + s3->accel.cx, dest_dat); MIX - + WRITE(s3->accel.dest + s3->accel.cx); } } @@ -1703,7 +1711,7 @@ void s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat if (s3->accel.cmd & 0x20) s3->accel.cx -= (s3->accel.maj_axis_pcnt & 0xfff) + 1; else s3->accel.cx += (s3->accel.maj_axis_pcnt & 0xfff) + 1; s3->accel.sx = s3->accel.maj_axis_pcnt & 0xfff; - + if (s3->accel.cmd & 0x80) s3->accel.cy++; else s3->accel.cy--; @@ -1747,19 +1755,19 @@ void s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat frgd_mix = (s3->accel.frgd_mix >> 5) & 3; bkgd_mix = (s3->accel.bkgd_mix >> 5) & 3; - + if (!cpu_input && frgd_mix == 3 && !vram_mask && !compare_mode && - (s3->accel.cmd & 0xa0) == 0xa0 && (s3->accel.frgd_mix & 0xf) == 7) + (s3->accel.cmd & 0xa0) == 0xa0 && (s3->accel.frgd_mix & 0xf) == 7 && (s3->accel.bkgd_mix & 0xf) == 7) { - while (1) - { + while (count-- && s3->accel.sy >= 0) + { if (s3->accel.dx >= clip_l && s3->accel.dx <= clip_r && s3->accel.dy >= clip_t && s3->accel.dy <= clip_b) { READ(s3->accel.src + s3->accel.cx, src_dat); - - dest_dat = src_dat; - + + dest_dat = src_dat; + WRITE(s3->accel.dest + s3->accel.dx); } @@ -1782,15 +1790,13 @@ void s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat if (s3->accel.sy < 0) { - s3->accel.cur_x = s3->accel.cx; - s3->accel.cur_y = s3->accel.cy; return; } } } } else - { + { while (count-- && s3->accel.sy >= 0) { if (s3->accel.dx >= clip_l && s3->accel.dx <= clip_r && @@ -1798,8 +1804,8 @@ void s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat { if (vram_mask) { - READ(s3->accel.src + s3->accel.cx, mix_dat) - mix_dat = mix_dat ? mix_mask : 0; + READ(s3->accel.src + s3->accel.cx, mix_dat) + mix_dat = mix_dat ? mix_mask : 0; } switch ((mix_dat & mix_mask) ? frgd_mix : bkgd_mix) { @@ -1814,7 +1820,7 @@ void s3_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat compare_mode < 2) { READ(s3->accel.dest + s3->accel.dx, dest_dat); - + MIX WRITE(s3->accel.dest + s3->accel.dx);