mirror of
https://github.com/86Box/86Box.git
synced 2026-02-25 04:45:31 -07:00
Merge branch 'master' into pc98x1
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
*
|
||||
* 3M MicroTouch SMT3 emulation.
|
||||
* 3M MicroTouch Serial emulation.
|
||||
*
|
||||
*
|
||||
*
|
||||
@@ -19,10 +19,8 @@
|
||||
|
||||
/* TODO:
|
||||
- Properly implement GP/SP commands (formats are not documented at all, like anywhere; no dumps yet).
|
||||
- Decouple serial packet generation from mouse poll rate.
|
||||
- Dynamic baud rate selection from software following this.
|
||||
- Add additional SMT2/3 formats as we currently only support Tablet, Hex and Dec.
|
||||
- Add additional SMT2/3 modes as we currently hardcode Mode Stream.
|
||||
- Mode Polled.
|
||||
*/
|
||||
#include <ctype.h>
|
||||
#include <stdint.h>
|
||||
@@ -47,6 +45,13 @@ enum mtouch_formats {
|
||||
FORMAT_TABLET = 4
|
||||
};
|
||||
|
||||
enum mtouch_modes {
|
||||
MODE_DOWNUP = 1,
|
||||
MODE_INACTIVE = 2,
|
||||
MODE_POINT = 3,
|
||||
MODE_STREAM = 4,
|
||||
};
|
||||
|
||||
const char* mtouch_identity[] = {
|
||||
"A30100", /* SMT2 Serial / SMT3(R)V */
|
||||
"A40100", /* SMT2 PCBus */
|
||||
@@ -55,16 +60,15 @@ const char* mtouch_identity[] = {
|
||||
};
|
||||
|
||||
typedef struct mouse_microtouch_t {
|
||||
double baud_rate;
|
||||
unsigned int abs_x_int, abs_y_int;
|
||||
int b;
|
||||
double baud_rate, abs_x, abs_x_old, abs_y, abs_y_old;
|
||||
int but, but_old;
|
||||
char cmd[256];
|
||||
int cmd_pos;
|
||||
uint8_t format;
|
||||
uint8_t format, mode;
|
||||
bool mode_status;
|
||||
uint8_t id, cal_cntr, pen_mode;
|
||||
bool soh;
|
||||
bool in_reset;
|
||||
bool in_reset, reset;
|
||||
serial_t *serial;
|
||||
Fifo8 resp;
|
||||
pc_timer_t host_to_serial_timer;
|
||||
@@ -78,6 +82,7 @@ microtouch_reset_complete(void *priv)
|
||||
{
|
||||
mouse_microtouch_t *mtouch = (mouse_microtouch_t *) priv;
|
||||
|
||||
mtouch->reset = true;
|
||||
mtouch->in_reset = false;
|
||||
fifo8_push_all(&mtouch->resp, (uint8_t *) "\x01\x30\x0D", 3); /* <SOH>0<CR> */
|
||||
}
|
||||
@@ -102,65 +107,98 @@ microtouch_process_commands(mouse_microtouch_t *mtouch)
|
||||
if (mtouch->cmd[0] == 'C' && (mtouch->cmd[1] == 'N' || mtouch->cmd[1] == 'X')) { /* Calibrate New/Extended */
|
||||
mtouch->cal_cntr = 2;
|
||||
}
|
||||
if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'D') { /* Format Decimal */
|
||||
mouse_set_sample_rate(106);
|
||||
else if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'D') { /* Format Decimal */
|
||||
mtouch->format = FORMAT_DEC;
|
||||
mtouch->mode_status = false;
|
||||
}
|
||||
if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'O') { /* Finger Only */
|
||||
else if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'O') { /* Finger Only */
|
||||
mtouch->pen_mode = 1;
|
||||
}
|
||||
if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'H') { /* Format Hexadecimal */
|
||||
mouse_set_sample_rate(106);
|
||||
else if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'H') { /* Format Hexadecimal */
|
||||
mtouch->format = FORMAT_HEX;
|
||||
mtouch->mode_status = false;
|
||||
}
|
||||
if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'R') { /* Format Raw */
|
||||
mouse_set_sample_rate(106);
|
||||
else if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'R') { /* Format Raw */
|
||||
mtouch->format = FORMAT_RAW;
|
||||
mtouch->mode = MODE_INACTIVE;
|
||||
mtouch->cal_cntr = 0;
|
||||
}
|
||||
if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'T') { /* Format Tablet */
|
||||
mouse_set_sample_rate(192);
|
||||
else if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'T') { /* Format Tablet */
|
||||
mtouch->format = FORMAT_TABLET;
|
||||
}
|
||||
if (mtouch->cmd[0] == 'G' && mtouch->cmd[1] == 'P' && mtouch->cmd[2] == '1') { /* Get Parameter Block 1 */
|
||||
else if (mtouch->cmd[0] == 'G' && mtouch->cmd[1] == 'P' && mtouch->cmd[2] == '1') { /* Get Parameter Block 1 */
|
||||
fifo8_push_all(&mtouch->resp, (uint8_t *) "\x01\x41\x0D", 3); /* <SOH>A<CR> */
|
||||
fifo8_push_all(&mtouch->resp, (uint8_t *) "0000000000000000000000000\r", 26);
|
||||
}
|
||||
if (mtouch->cmd[0] == 'M' && mtouch->cmd[1] == 'T') { /* Mode Status */
|
||||
else if (mtouch->cmd[0] == 'M' && mtouch->cmd[1] == 'D' && mtouch->cmd[2] == 'U') { /* Mode Down/Up */
|
||||
mtouch->mode = MODE_DOWNUP;
|
||||
}
|
||||
else if (mtouch->cmd[0] == 'M' && mtouch->cmd[1] == 'I') { /* Mode Inactive */
|
||||
mtouch->mode = MODE_INACTIVE;
|
||||
}
|
||||
else if (mtouch->cmd[0] == 'M' && mtouch->cmd[1] == 'P') { /* Mode Point */
|
||||
mtouch->mode = MODE_POINT;
|
||||
}
|
||||
else if (mtouch->cmd[0] == 'M' && mtouch->cmd[1] == 'T') { /* Mode Status */
|
||||
mtouch->mode_status = true;
|
||||
}
|
||||
if (mtouch->cmd[0] == 'O' && mtouch->cmd[1] == 'I') { /* Output Identity */
|
||||
else if (mtouch->cmd[0] == 'M' && mtouch->cmd[1] == 'S') { /* Mode Stream */
|
||||
mtouch->mode = MODE_STREAM;
|
||||
}
|
||||
else if (mtouch->cmd[0] == 'O' && mtouch->cmd[1] == 'I') { /* Output Identity */
|
||||
fifo8_push(&mtouch->resp, 0x01);
|
||||
fifo8_push_all(&mtouch->resp, (uint8_t *) mtouch_identity[mtouch->id], 6);
|
||||
fifo8_push(&mtouch->resp, 0x0D);
|
||||
return;
|
||||
}
|
||||
if (mtouch->cmd[0] == 'P') {
|
||||
if (mtouch->cmd[1] == 'F') mtouch->pen_mode = 3; /* Pen or Finger */
|
||||
else if (mtouch->cmd[1] == 'O') mtouch->pen_mode = 2; /* Pen Only */
|
||||
else if (mtouch->cmd[0] == 'O' && mtouch->cmd[1] == 'S') { /* Output Status */
|
||||
if (mtouch->reset) {
|
||||
fifo8_push_all(&mtouch->resp, (uint8_t *) "\x01\x40\x60\x0D", 4);
|
||||
} else {
|
||||
fifo8_push_all(&mtouch->resp, (uint8_t *) "\x01\x40\x40\x0D", 4);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (mtouch->cmd[0] == 'R') { /* Reset */
|
||||
else if (mtouch->cmd[0] == 'P') {
|
||||
if (strlen(mtouch->cmd) == 2) { /* Pen */
|
||||
if (mtouch->cmd[1] == 'F') mtouch->pen_mode = 3; /* Pen or Finger */
|
||||
else if (mtouch->cmd[1] == 'O') mtouch->pen_mode = 2; /* Pen Only */
|
||||
}
|
||||
else if (strlen(mtouch->cmd) == 5) { /* Serial Options */
|
||||
if (mtouch->cmd[4] == 1) mtouch->baud_rate = 19200;
|
||||
else if (mtouch->cmd[4] == 2) mtouch->baud_rate = 9600;
|
||||
else if (mtouch->cmd[4] == 3) mtouch->baud_rate = 4600;
|
||||
else if (mtouch->cmd[4] == 4) mtouch->baud_rate = 2400;
|
||||
else if (mtouch->cmd[4] == 5) mtouch->baud_rate = 1200;
|
||||
|
||||
timer_stop(&mtouch->host_to_serial_timer);
|
||||
timer_on_auto(&mtouch->host_to_serial_timer, (1000000. / mtouch->baud_rate) * 10);
|
||||
}
|
||||
}
|
||||
else if (mtouch->cmd[0] == 'R') { /* Reset */
|
||||
mtouch->in_reset = true;
|
||||
mtouch->cal_cntr = 0;
|
||||
mtouch->pen_mode = 3;
|
||||
mtouch->mode_status = false;
|
||||
|
||||
if (mtouch->id < 2) {
|
||||
mouse_set_sample_rate(106);
|
||||
mtouch->format = FORMAT_DEC;
|
||||
} else {
|
||||
mouse_set_sample_rate(192);
|
||||
mtouch->format = FORMAT_TABLET;
|
||||
if (mtouch->cmd[0] == 'D') { /* Restore Defaults */
|
||||
mtouch->mode = MODE_STREAM;
|
||||
mtouch->mode_status = false;
|
||||
|
||||
if (mtouch->id < 2) {
|
||||
mtouch->format = FORMAT_DEC;
|
||||
} else {
|
||||
mtouch->format = FORMAT_TABLET;
|
||||
}
|
||||
}
|
||||
|
||||
timer_on_auto(&mtouch->reset_timer, 500. * 1000.);
|
||||
return;
|
||||
}
|
||||
if (mtouch->cmd[0] == 'S' && mtouch->cmd[1] == 'P' && mtouch->cmd[2] == '1') { /* Set Parameter Block 1 */
|
||||
else if (mtouch->cmd[0] == 'S' && mtouch->cmd[1] == 'P' && mtouch->cmd[2] == '1') { /* Set Parameter Block 1 */
|
||||
fifo8_push_all(&mtouch->resp, (uint8_t *) "\x01\x41\x0D", 3); /* <SOH>A<CR> */
|
||||
return;
|
||||
}
|
||||
if (mtouch->cmd[0] == 'U' && mtouch->cmd[1] == 'T') { /* Unit Type */
|
||||
else if (mtouch->cmd[0] == 'U' && mtouch->cmd[1] == 'T') { /* Unit Type */
|
||||
fifo8_push(&mtouch->resp, 0x01);
|
||||
|
||||
if (mtouch->id == 2) {
|
||||
@@ -175,6 +213,111 @@ microtouch_process_commands(mouse_microtouch_t *mtouch)
|
||||
fifo8_push_all(&mtouch->resp, (uint8_t *) "\x01\x30\x0D", 3); /* <SOH>0<CR> */
|
||||
}
|
||||
|
||||
void
|
||||
mtouch_write(serial_t *serial, void *priv, uint8_t data)
|
||||
{
|
||||
mouse_microtouch_t *dev = (mouse_microtouch_t *) priv;
|
||||
if (data == '\x1') {
|
||||
dev->soh = 1;
|
||||
}
|
||||
else if (dev->soh) {
|
||||
if (data != '\r') {
|
||||
dev->cmd[dev->cmd_pos++] = data;
|
||||
} else {
|
||||
dev->soh = 0;
|
||||
|
||||
if (!dev->cmd_pos) {
|
||||
return;
|
||||
}
|
||||
|
||||
dev->cmd[dev->cmd_pos++] = data;
|
||||
dev->cmd_pos = 0;
|
||||
microtouch_process_commands(dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
mtouch_prepare_transmit(void *priv)
|
||||
{
|
||||
char buffer[10];
|
||||
mouse_microtouch_t *dev = (mouse_microtouch_t *) priv;
|
||||
|
||||
double abs_x = dev->abs_x;
|
||||
double abs_y = dev->abs_y;
|
||||
int but = dev->but;
|
||||
|
||||
if (dev->mode == MODE_INACTIVE) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (dev->cal_cntr || (!dev->but && !dev->but_old)) { /* Calibration or no buttonpress */
|
||||
if (!dev->but && dev->but_old) {
|
||||
microtouch_calibrate_timer(dev);
|
||||
}
|
||||
dev->but_old = but; /* Save buttonpress */
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (dev->format == FORMAT_TABLET) {
|
||||
if (but) { /* Touchdown/Continuation */
|
||||
fifo8_push(&dev->resp, 0b11000000 | ((dev->pen_mode == 2) ? ((1 << 5) | ((but & 3))) : 0));
|
||||
fifo8_push(&dev->resp, (uint16_t)(16383 * abs_x) & 0b1111111);
|
||||
fifo8_push(&dev->resp, ((uint16_t)(16383 * abs_x) >> 7) & 0b1111111);
|
||||
fifo8_push(&dev->resp, (uint16_t)(16383 * (1 - abs_y)) & 0b1111111);
|
||||
fifo8_push(&dev->resp, ((uint16_t)(16383 * (1 - abs_y)) >> 7) & 0b1111111);
|
||||
}
|
||||
else if (dev->but_old) { /* Liftoff */
|
||||
fifo8_push(&dev->resp, 0b10000000 | ((dev->pen_mode == 2) ? ((1 << 5)) : 0));
|
||||
fifo8_push(&dev->resp, (uint16_t)(16383 * dev->abs_x_old) & 0b1111111);
|
||||
fifo8_push(&dev->resp, ((uint16_t)(16383 * dev->abs_x_old) >> 7) & 0b1111111);
|
||||
fifo8_push(&dev->resp, (uint16_t)(16383 * (1 - dev->abs_y_old))& 0b1111111);
|
||||
fifo8_push(&dev->resp, ((uint16_t)(16383 * (1 - dev->abs_y_old)) >> 7) & 0b1111111);
|
||||
}
|
||||
}
|
||||
|
||||
else if (dev->format == FORMAT_DEC || dev->format == FORMAT_HEX) {
|
||||
if (but) {
|
||||
if (!dev->but_old) { /* Touchdown (MS, MP, MDU) */
|
||||
fifo8_push(&dev->resp, (dev->mode_status) ? 0x19 : 0x01);
|
||||
if (dev->format == FORMAT_DEC){
|
||||
snprintf(buffer, sizeof(buffer), "%03d,%03d\r", (uint16_t)(999 * abs_x), (uint16_t)(999 * (1 - abs_y)));
|
||||
}
|
||||
else if (dev->format == FORMAT_HEX) {
|
||||
snprintf(buffer, sizeof(buffer), "%03X,%03X\r", (uint16_t)(1023 * abs_x), (uint16_t)(1023 * (1 - abs_y)));
|
||||
}
|
||||
fifo8_push_all(&dev->resp, (uint8_t *)buffer, strlen(buffer));
|
||||
}
|
||||
else if (dev->mode == MODE_STREAM){ /* Touch Continuation (MS) */
|
||||
fifo8_push(&dev->resp, (dev->mode_status) ? 0x1c : 0x01);
|
||||
if (dev->format == FORMAT_DEC){
|
||||
snprintf(buffer, sizeof(buffer), "%03d,%03d\r", (uint16_t)(999 * abs_x), (uint16_t)(999 * (1 - abs_y)));
|
||||
}
|
||||
else if (dev->format == FORMAT_HEX) {
|
||||
snprintf(buffer, sizeof(buffer), "%03X,%03X\r", (uint16_t)(1023 * abs_x), (uint16_t)(1023 * (1 - abs_y)));
|
||||
}
|
||||
fifo8_push_all(&dev->resp, (uint8_t *)buffer, strlen(buffer));
|
||||
}
|
||||
}
|
||||
else if (dev->but_old && dev->mode != MODE_POINT) { /* Touch Liftoff (MS, MDU) */
|
||||
fifo8_push(&dev->resp, (dev->mode_status) ? 0x18 : 0x01);
|
||||
if (dev->format == FORMAT_DEC) {
|
||||
snprintf(buffer, sizeof(buffer), "%03d,%03d\r", (uint16_t)(999 * dev->abs_x_old), (uint16_t)(999 * (1 - dev->abs_y_old)));
|
||||
}
|
||||
else if (dev->format == FORMAT_HEX) {
|
||||
snprintf(buffer, sizeof(buffer), "%03X,%03X\r", (uint16_t)(1023 * dev->abs_x_old), (uint16_t)(1023 * (1 - dev->abs_y_old)));
|
||||
}
|
||||
fifo8_push_all(&dev->resp, (uint8_t *)buffer, strlen(buffer));
|
||||
}
|
||||
}
|
||||
|
||||
/* Save old states*/
|
||||
dev->abs_x_old = abs_x;
|
||||
dev->abs_y_old = abs_y;
|
||||
dev->but_old = but;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
mtouch_write_to_host(void *priv)
|
||||
{
|
||||
@@ -194,162 +337,48 @@ mtouch_write_to_host(void *priv)
|
||||
if (fifo8_num_used(&dev->resp)) {
|
||||
serial_write_fifo(dev->serial, fifo8_pop(&dev->resp));
|
||||
}
|
||||
else {
|
||||
mtouch_prepare_transmit(dev);
|
||||
}
|
||||
|
||||
no_write_to_machine:
|
||||
timer_on_auto(&dev->host_to_serial_timer, (1000000.0 / (double) dev->baud_rate) * (double) (1 + 8 + 1));
|
||||
}
|
||||
|
||||
void
|
||||
mtouch_write(serial_t *serial, void *priv, uint8_t data)
|
||||
{
|
||||
mouse_microtouch_t *dev = (mouse_microtouch_t *) priv;
|
||||
if (data == '\x1') {
|
||||
dev->soh = 1;
|
||||
} else if (dev->soh) {
|
||||
if (data != '\r') {
|
||||
dev->cmd[dev->cmd_pos++] = data;
|
||||
} else {
|
||||
dev->soh = 0;
|
||||
|
||||
if (!dev->cmd_pos) {
|
||||
return;
|
||||
}
|
||||
|
||||
dev->cmd[dev->cmd_pos++] = data;
|
||||
dev->cmd_pos = 0;
|
||||
microtouch_process_commands(dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
mtouch_poll(void *priv)
|
||||
{
|
||||
mouse_microtouch_t *dev = (mouse_microtouch_t *) priv;
|
||||
|
||||
if (fifo8_num_free(&dev->resp) <= 256 - 10 || dev->format == FORMAT_RAW) {
|
||||
return 0;
|
||||
}
|
||||
dev->but = mouse_get_buttons_ex();
|
||||
mouse_get_abs_coords(&dev->abs_x, &dev->abs_y);
|
||||
|
||||
unsigned int abs_x_int = 0, abs_y_int = 0;
|
||||
double abs_x;
|
||||
double abs_y;
|
||||
int b = mouse_get_buttons_ex();
|
||||
|
||||
mouse_get_abs_coords(&abs_x, &abs_y);
|
||||
|
||||
if (abs_x >= 1.0)
|
||||
abs_x = 1.0;
|
||||
if (abs_y >= 1.0)
|
||||
abs_y = 1.0;
|
||||
if (abs_x <= 0.0)
|
||||
abs_x = 0.0;
|
||||
if (abs_y <= 0.0)
|
||||
abs_y = 0.0;
|
||||
if (enable_overscan) {
|
||||
int index = mouse_tablet_in_proximity - 1;
|
||||
if (mouse_tablet_in_proximity == -1) {
|
||||
mouse_tablet_in_proximity = 0;
|
||||
}
|
||||
|
||||
abs_x *= monitors[index].mon_unscaled_size_x - 1;
|
||||
abs_y *= monitors[index].mon_efscrnsz_y - 1;
|
||||
dev->abs_x *= monitors[index].mon_unscaled_size_x - 1;
|
||||
dev->abs_y *= monitors[index].mon_efscrnsz_y - 1;
|
||||
|
||||
if (abs_x <= (monitors[index].mon_overscan_x / 2.)) {
|
||||
abs_x = (monitors[index].mon_overscan_x / 2.);
|
||||
if (dev->abs_x <= (monitors[index].mon_overscan_x / 2.)) {
|
||||
dev->abs_x = (monitors[index].mon_overscan_x / 2.);
|
||||
}
|
||||
if (abs_y <= (monitors[index].mon_overscan_y / 2.)) {
|
||||
abs_y = (monitors[index].mon_overscan_y / 2.);
|
||||
if (dev->abs_y <= (monitors[index].mon_overscan_y / 2.)) {
|
||||
dev->abs_y = (monitors[index].mon_overscan_y / 2.);
|
||||
}
|
||||
abs_x -= (monitors[index].mon_overscan_x / 2.);
|
||||
abs_y -= (monitors[index].mon_overscan_y / 2.);
|
||||
abs_x = abs_x / (double) monitors[index].mon_xsize;
|
||||
abs_y = abs_y / (double) monitors[index].mon_ysize;
|
||||
if (abs_x >= 1.0)
|
||||
abs_x = 1.0;
|
||||
if (abs_y >= 1.0)
|
||||
abs_y = 1.0;
|
||||
dev->abs_x -= (monitors[index].mon_overscan_x / 2.);
|
||||
dev->abs_y -= (monitors[index].mon_overscan_y / 2.);
|
||||
dev->abs_x = dev->abs_x / (double) monitors[index].mon_xsize;
|
||||
dev->abs_y = dev->abs_y / (double) monitors[index].mon_ysize;
|
||||
}
|
||||
|
||||
if (dev->cal_cntr || (!b && !dev->b)) { /* Calibration or no buttonpress */
|
||||
if (!b && dev->b) {
|
||||
microtouch_calibrate_timer(dev);
|
||||
}
|
||||
dev->b = b; /* Save buttonpress */
|
||||
return 0;
|
||||
}
|
||||
if (dev->abs_x >= 1.0) dev->abs_x = 1.0;
|
||||
if (dev->abs_y >= 1.0) dev->abs_y = 1.0;
|
||||
if (dev->abs_x <= 0.0) dev->abs_x = 0.0;
|
||||
if (dev->abs_y <= 0.0) dev->abs_y = 0.0;
|
||||
|
||||
if (dev->format == FORMAT_DEC) {
|
||||
abs_x_int = abs_x * 999;
|
||||
abs_y_int = 999 - (abs_y * 999);
|
||||
char buffer[10];
|
||||
|
||||
if (!dev->mode_status) {
|
||||
if (b) { // Touch
|
||||
snprintf(buffer, sizeof(buffer), "\x1%03d,%03d\r", abs_x_int, abs_y_int);
|
||||
fifo8_push_all(&dev->resp, (uint8_t *)buffer, strlen(buffer));
|
||||
}
|
||||
} else {
|
||||
if (b) {
|
||||
if (!dev->b) { /* Touchdown Status */
|
||||
snprintf(buffer, sizeof(buffer), "\x19%03d,%03d\r", abs_x_int, abs_y_int);
|
||||
} else { /* Touch Continuation Status */
|
||||
snprintf(buffer, sizeof(buffer), "\x1c%03d,%03d\r", abs_x_int, abs_y_int);
|
||||
}
|
||||
} else if (dev->b) { /* Liftoff Status */
|
||||
snprintf(buffer, sizeof(buffer), "\x18%03d,%03d\r", dev->abs_x_int, dev->abs_y_int);
|
||||
}
|
||||
fifo8_push_all(&dev->resp, (uint8_t *)buffer, strlen(buffer));
|
||||
}
|
||||
}
|
||||
|
||||
else if (dev->format == FORMAT_HEX) {
|
||||
abs_x_int = abs_x * 1023;
|
||||
abs_y_int = 1023 - (abs_y * 1023);
|
||||
char buffer[10];
|
||||
|
||||
if (!dev->mode_status) {
|
||||
if (b) { // Touch
|
||||
snprintf(buffer, sizeof(buffer), "\x1%03X,%03X\r", abs_x_int, abs_y_int);
|
||||
fifo8_push_all(&dev->resp, (uint8_t *)buffer, strlen(buffer));
|
||||
}
|
||||
} else {
|
||||
if (b) {
|
||||
if (!dev->b) { /* Touchdown Status */
|
||||
snprintf(buffer, sizeof(buffer), "\x19%03X,%03X\r", abs_x_int, abs_y_int);
|
||||
} else { /* Touch Continuation Status */
|
||||
snprintf(buffer, sizeof(buffer), "\x1c%03X,%03X\r", abs_x_int, abs_y_int);
|
||||
}
|
||||
} else if (dev->b) { /* Liftoff Status */
|
||||
snprintf(buffer, sizeof(buffer), "\x18%03X,%03X\r", dev->abs_x_int, dev->abs_y_int);
|
||||
}
|
||||
fifo8_push_all(&dev->resp, (uint8_t *)buffer, strlen(buffer));
|
||||
}
|
||||
}
|
||||
|
||||
else if (dev->format == FORMAT_TABLET) {
|
||||
abs_x_int = abs_x * 16383;
|
||||
abs_y_int = 16383 - abs_y * 16383;
|
||||
|
||||
if (b) { /* Touchdown/Continuation */
|
||||
fifo8_push(&dev->resp, 0b11000000 | ((dev->pen_mode == 2) ? ((1 << 5) | ((b & 3))) : 0));
|
||||
fifo8_push(&dev->resp, abs_x_int & 0b1111111);
|
||||
fifo8_push(&dev->resp, (abs_x_int >> 7) & 0b1111111);
|
||||
fifo8_push(&dev->resp, abs_y_int & 0b1111111);
|
||||
fifo8_push(&dev->resp, (abs_y_int >> 7) & 0b1111111);
|
||||
} else if (dev->b) { /* Liftoff */
|
||||
fifo8_push(&dev->resp, 0b10000000 | ((dev->pen_mode == 2) ? ((1 << 5)) : 0));
|
||||
fifo8_push(&dev->resp, dev->abs_x_int & 0b1111111);
|
||||
fifo8_push(&dev->resp, (dev->abs_x_int >> 7) & 0b1111111);
|
||||
fifo8_push(&dev->resp, dev->abs_y_int & 0b1111111);
|
||||
fifo8_push(&dev->resp, (dev->abs_y_int >> 7) & 0b1111111);
|
||||
}
|
||||
}
|
||||
|
||||
/* Save old states*/
|
||||
dev->abs_x_int = abs_x_int;
|
||||
dev->abs_y_int = abs_y_int;
|
||||
dev->b = b;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -365,7 +394,7 @@ mtouch_init(const device_t *info)
|
||||
mouse_microtouch_t *dev = calloc(1, sizeof(mouse_microtouch_t));
|
||||
|
||||
dev->serial = serial_attach(device_get_config_int("port"), NULL, mtouch_write, dev);
|
||||
dev->baud_rate = device_get_config_int("baudrate");
|
||||
dev->baud_rate = 9600;
|
||||
serial_set_cts(dev->serial, 1);
|
||||
serial_set_dsr(dev->serial, 1);
|
||||
serial_set_dcd(dev->serial, 1);
|
||||
@@ -376,21 +405,17 @@ mtouch_init(const device_t *info)
|
||||
timer_on_auto(&dev->host_to_serial_timer, (1000000. / dev->baud_rate) * 10);
|
||||
dev->id = device_get_config_int("identity");
|
||||
dev->pen_mode = 3;
|
||||
dev->mode_status = false;
|
||||
dev->mode = MODE_STREAM;
|
||||
|
||||
if (dev->id < 2) { /* legacy controllers */
|
||||
dev->format = FORMAT_DEC;
|
||||
mouse_set_sample_rate(106);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
dev->format = FORMAT_TABLET;
|
||||
mouse_set_sample_rate(192);
|
||||
}
|
||||
|
||||
mouse_input_mode = device_get_config_int("crosshair") + 1;
|
||||
mouse_set_buttons(2);
|
||||
mouse_set_poll_ex(mtouch_poll_global);
|
||||
|
||||
mtouch_inst = dev;
|
||||
|
||||
return dev;
|
||||
@@ -403,8 +428,9 @@ mtouch_close(void *priv)
|
||||
|
||||
fifo8_destroy(&dev->resp);
|
||||
/* Detach serial port from the mouse. */
|
||||
if (dev && dev->serial && dev->serial->sd)
|
||||
if (dev && dev->serial && dev->serial->sd) {
|
||||
memset(dev->serial->sd, 0, sizeof(serial_device_t));
|
||||
}
|
||||
|
||||
free(dev);
|
||||
mtouch_inst = NULL;
|
||||
@@ -428,22 +454,6 @@ static const device_config_t mtouch_config[] = {
|
||||
{ .description = "" }
|
||||
}
|
||||
},
|
||||
{
|
||||
.name = "baudrate",
|
||||
.description = "Baud Rate",
|
||||
.type = CONFIG_SELECTION,
|
||||
.default_string = "",
|
||||
.default_int = 9600,
|
||||
.file_filter = NULL,
|
||||
.spinner = { 0 },
|
||||
.selection = {
|
||||
{ .description = "19200", .value = 19200 },
|
||||
{ .description = "9600", .value = 9600 },
|
||||
{ .description = "4800", .value = 4800 },
|
||||
{ .description = "2400", .value = 2400 },
|
||||
{ .description = "1200", .value = 1200 }
|
||||
}
|
||||
},
|
||||
{
|
||||
.name = "identity",
|
||||
.description = "Controller",
|
||||
@@ -482,4 +492,4 @@ const device_t mouse_mtouch_device = {
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = mtouch_config
|
||||
};
|
||||
};
|
||||
@@ -188,6 +188,7 @@ typedef struct esdi_t {
|
||||
#define CMD_READ_VERIFY 0x03
|
||||
#define CMD_WRITE_VERIFY 0x04
|
||||
#define CMD_SEEK 0x05
|
||||
#define CMD_PARK_HEADS 0x06
|
||||
#define CMD_GET_DEV_STATUS 0x08
|
||||
#define CMD_GET_DEV_CONFIG 0x09
|
||||
#define CMD_GET_POS_INFO 0x0a
|
||||
@@ -605,6 +606,35 @@ esdi_callback(void *priv)
|
||||
}
|
||||
break;
|
||||
|
||||
case CMD_PARK_HEADS:
|
||||
ESDI_DRIVE_ONLY();
|
||||
|
||||
if (!drive->present) {
|
||||
device_not_present(dev);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (dev->cmd_state) {
|
||||
case 0:
|
||||
dev->rba = 0x00000000;
|
||||
cmd_time = hdd_seek_get_time(&hdd[drive->hdd_num], dev->rba, HDD_OP_SEEK, 0, 0.0);
|
||||
esdi_mca_set_callback(dev, ESDI_TIME + cmd_time);
|
||||
dev->cmd_state = 1;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
complete_command_status(dev);
|
||||
dev->status = STATUS_IRQ | STATUS_STATUS_OUT_FULL;
|
||||
dev->irq_status = dev->cmd_dev | IRQ_CMD_COMPLETE_SUCCESS;
|
||||
dev->irq_in_progress = 1;
|
||||
set_irq(dev);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case CMD_GET_DEV_STATUS:
|
||||
ESDI_DRIVE_ONLY();
|
||||
|
||||
|
||||
@@ -326,6 +326,7 @@ extern const device_t ati18800_device;
|
||||
|
||||
/* ATi 28800 */
|
||||
extern const device_t ati28800_device;
|
||||
extern const device_t ati28800_wonder1024d_xl_plus_device;
|
||||
extern const device_t ati28800k_device;
|
||||
extern const device_t ati28800k_spc4620p_device;
|
||||
extern const device_t ati28800k_spc6033p_device;
|
||||
|
||||
@@ -36,9 +36,10 @@
|
||||
#include <86box/vid_svga.h>
|
||||
#include <86box/vid_svga_render.h>
|
||||
|
||||
#define VGAWONDERXL 1
|
||||
#define VGAWONDERXL 1
|
||||
#define VGAWONDERXLPLUS 2
|
||||
#ifdef USE_XL24
|
||||
# define VGAWONDERXL24 2
|
||||
# define VGAWONDERXL24 3
|
||||
#endif /* USE_XL24 */
|
||||
|
||||
#define BIOS_ATIKOR_PATH "roms/video/ati28800/atikorvga.bin"
|
||||
@@ -57,8 +58,9 @@
|
||||
# define BIOS_XL24_ODD_PATH "roms/video/ati28800/112-14319-102.bin"
|
||||
#endif /* USE_XL24 */
|
||||
|
||||
#define BIOS_ROM_PATH "roms/video/ati28800/bios.bin"
|
||||
#define BIOS_VGAXL_ROM_PATH "roms/video/ati28800/ATI_VGAWonder_XL.bin"
|
||||
#define BIOS_ROM_PATH "roms/video/ati28800/bios.bin"
|
||||
#define BIOS_VGAXL_ROM_PATH "roms/video/ati28800/ATI_VGAWonder_XL.bin"
|
||||
#define BIOS_VGAXL_PLUS_ROM_PATH "roms/video/ati28800/VGAWonder1024D_XL_Plus_VGABIOS_U19.BIN"
|
||||
|
||||
typedef struct ati28800_t {
|
||||
svga_t svga;
|
||||
@@ -183,7 +185,7 @@ ati28800_out(uint16_t addr, uint8_t val, void *priv)
|
||||
case 0x3C7:
|
||||
case 0x3C8:
|
||||
case 0x3C9:
|
||||
if (ati28800->type == 1)
|
||||
if ((ati28800->type == VGAWONDERXL) || (ati28800->type == VGAWONDERXLPLUS))
|
||||
sc1148x_ramdac_out(addr, 0, val, svga->ramdac, svga);
|
||||
else
|
||||
svga_out(addr, val, svga);
|
||||
@@ -339,7 +341,7 @@ ati28800_in(uint16_t addr, void *priv)
|
||||
case 0x3C7:
|
||||
case 0x3C8:
|
||||
case 0x3C9:
|
||||
if (ati28800->type == 1)
|
||||
if ((ati28800->type == VGAWONDERXL) || (ati28800->type == VGAWONDERXLPLUS))
|
||||
return sc1148x_ramdac_in(addr, 0, svga->ramdac, svga);
|
||||
return svga_in(addr, svga);
|
||||
|
||||
@@ -609,6 +611,16 @@ ati28800_init(const device_t *info)
|
||||
ati28800->svga.ramdac = device_add(&sc11486_ramdac_device);
|
||||
break;
|
||||
|
||||
case VGAWONDERXLPLUS:
|
||||
ati28800->id = 6;
|
||||
rom_init(&ati28800->bios_rom,
|
||||
BIOS_VGAXL_PLUS_ROM_PATH,
|
||||
0xc0000, 0x8000, 0x7fff,
|
||||
0, MEM_MAPPING_EXTERNAL);
|
||||
ati28800->svga.ramdac = device_add(&sc11483_ramdac_device);
|
||||
ati28800->memory = 1024;
|
||||
break;
|
||||
|
||||
#ifdef USE_XL24
|
||||
case VGAWONDERXL24:
|
||||
ati28800->id = 6;
|
||||
@@ -653,6 +665,10 @@ ati28800_init(const device_t *info)
|
||||
ati_eeprom_load(&ati28800->eeprom, "ati28800xl.nvr", 0);
|
||||
break;
|
||||
|
||||
case VGAWONDERXLPLUS:
|
||||
ati_eeprom_load(&ati28800->eeprom, "ati28800_wonder1024d_xl_plus.nvr", 0);
|
||||
break;
|
||||
|
||||
#ifdef USE_XL24
|
||||
case VGAWONDERXL24:
|
||||
ati_eeprom_load(&ati28800->eeprom, "ati28800xl24.nvr", 0);
|
||||
@@ -685,6 +701,12 @@ compaq_ati28800_available(void)
|
||||
return (rom_present(BIOS_VGAXL_ROM_PATH));
|
||||
}
|
||||
|
||||
static int
|
||||
ati28800_wonder1024d_xl_plus_available(void)
|
||||
{
|
||||
return (rom_present(BIOS_VGAXL_PLUS_ROM_PATH));
|
||||
}
|
||||
|
||||
#ifdef USE_XL24
|
||||
static int
|
||||
ati28800_wonderxl24_available(void)
|
||||
@@ -851,6 +873,20 @@ const device_t compaq_ati28800_device = {
|
||||
.config = ati28800_config
|
||||
};
|
||||
|
||||
const device_t ati28800_wonder1024d_xl_plus_device = {
|
||||
.name = "ATI 28800-6 (ATI VGA Wonder 1024D XL Plus)",
|
||||
.internal_name = "ati28800_wonder1024d_xl_plus",
|
||||
.flags = DEVICE_ISA,
|
||||
.local = VGAWONDERXLPLUS,
|
||||
.init = ati28800_init,
|
||||
.close = ati28800_close,
|
||||
.reset = NULL,
|
||||
{ .available = ati28800_wonder1024d_xl_plus_available },
|
||||
.speed_changed = ati28800_speed_changed,
|
||||
.force_redraw = ati28800_force_redraw,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
#ifdef USE_XL24
|
||||
const device_t ati28800_wonderxl24_device = {
|
||||
.name = "ATI-28800 (VGA Wonder XL24)",
|
||||
|
||||
@@ -333,7 +333,8 @@ enum {
|
||||
enum {
|
||||
SRC_PATT_EN = 1,
|
||||
SRC_PATT_ROT_EN = 2,
|
||||
SRC_LINEAR_EN = 4
|
||||
SRC_LINEAR_EN = 4,
|
||||
SRC_BYTE_ALIGN = 8
|
||||
};
|
||||
|
||||
enum {
|
||||
@@ -1280,6 +1281,14 @@ mach64_queue(mach64_t *mach64, uint32_t addr, uint32_t val, uint32_t type)
|
||||
void
|
||||
mach64_start_fill(mach64_t *mach64)
|
||||
{
|
||||
mach64->accel.dst_pix_width = mach64->dp_pix_width & 7;
|
||||
mach64->accel.src_pix_width = (mach64->dp_pix_width >> 8) & 7;
|
||||
mach64->accel.host_pix_width = (mach64->dp_pix_width >> 16) & 7;
|
||||
|
||||
mach64->accel.dst_size = mach64_width[mach64->accel.dst_pix_width];
|
||||
mach64->accel.src_size = mach64_width[mach64->accel.src_pix_width];
|
||||
mach64->accel.host_size = mach64_width[mach64->accel.host_pix_width];
|
||||
|
||||
mach64->accel.dst_x = 0;
|
||||
mach64->accel.dst_y = 0;
|
||||
|
||||
@@ -1293,7 +1302,8 @@ mach64_start_fill(mach64_t *mach64)
|
||||
mach64->accel.dst_width = (mach64->dst_height_width >> 16) & 0x1fff;
|
||||
mach64->accel.dst_height = mach64->dst_height_width & 0x1fff;
|
||||
|
||||
if (((mach64->dp_src >> 16) & 7) == MONO_SRC_BLITSRC) {
|
||||
if ((((mach64->dp_src >> 16) & 7) == MONO_SRC_BLITSRC) &&
|
||||
((mach64->src_cntl & (SRC_LINEAR_EN | SRC_BYTE_ALIGN)) == (SRC_LINEAR_EN | SRC_BYTE_ALIGN))) {
|
||||
if (mach64->accel.dst_width & 7)
|
||||
mach64->accel.dst_width = (mach64->accel.dst_width & ~7) + 8;
|
||||
}
|
||||
@@ -1345,14 +1355,6 @@ mach64_start_fill(mach64_t *mach64)
|
||||
mach64->accel.source_fg = (mach64->dp_src >> 8) & 7;
|
||||
mach64->accel.source_mix = (mach64->dp_src >> 16) & 7;
|
||||
|
||||
mach64->accel.dst_pix_width = mach64->dp_pix_width & 7;
|
||||
mach64->accel.src_pix_width = (mach64->dp_pix_width >> 8) & 7;
|
||||
mach64->accel.host_pix_width = (mach64->dp_pix_width >> 16) & 7;
|
||||
|
||||
mach64->accel.dst_size = mach64_width[mach64->accel.dst_pix_width];
|
||||
mach64->accel.src_size = mach64_width[mach64->accel.src_pix_width];
|
||||
mach64->accel.host_size = mach64_width[mach64->accel.host_pix_width];
|
||||
|
||||
if (mach64->accel.src_size == WIDTH_1BIT)
|
||||
mach64->accel.src_offset <<= 3;
|
||||
else
|
||||
@@ -1861,6 +1863,7 @@ mach64_blit(uint32_t cpu_dat, int count, mach64_t *mach64)
|
||||
cpu_dat >>= (count & 7);
|
||||
else
|
||||
cpu_dat <<= (count & 7);
|
||||
|
||||
count &= ~7;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ video_cards[] = {
|
||||
{ &ati18800_vga88_device },
|
||||
{ &ati28800_device },
|
||||
{ &compaq_ati28800_device },
|
||||
{ &ati28800_wonder1024d_xl_plus_device },
|
||||
#ifdef USE_XL24
|
||||
{ &ati28800_wonderxl24_device },
|
||||
#endif /* USE_XL24 */
|
||||
|
||||
Reference in New Issue
Block a user