connected_type[1] = 0xffffffff;
stat_com[0] = stat_com[1] = false;
-// register_frame_event(this);
}
void JOYSTICK::release()
{
}
-void JOYSTICK::event_pre_frame()
-{
- for(int i = 0; i < 2; i++) {
- if(connected_type[i] == SIG_JOYPORT_TYPE_2BUTTONS) {
- write_signals(&outputs_query, 1 << i);
- }
- }
-}
-
void JOYSTICK::write_io8(uint32_t address, uint32_t data)
{
// ToDo: Mouse
}
//if(type != connected_type[num]) return;
}
+uint32_t JOYSTICK::read_signal(int id)
+{
+ int ch = (id >> 24) & 1;
+ int bustype = id & 0x300;
+ int num = id & 0xff;
+ uint32_t data = 0;
+ switch(bustype) {
+ case SIG_JOYPORT_DATA:
+ data = joydata[ch];
+ break;
+ case SIG_JOYPORT_COM:
+ data = (stat_com[ch]) ? 0xffffffff : 0;
+ break;
+ case SIG_JOYPORT_MASK:
+ data = mouse_mask;
+ break;
+ }
+ return data;
+}
void JOYSTICK::update_config(void)
{
#define SIG_JOYPORT_CH1 (65536 * 256)
#define SIG_JOYPORT_DATA 256
#define SIG_JOYPORT_COM 512
+#define SIG_JOYPORT_MASK 768
#define SIG_JOYPORT_TYPE_NULL 0
#define SIG_JOYPORT_TYPE_2BUTTONS 1
void initialize(void);
void release();
void reset();
- void event_pre_frame();
void __FASTCALL write_io8(uint32_t addr, uint32_t data);
uint32_t __FASTCALL read_io8(uint32_t addr);
void __FASTCALL write_signal(int id, uint32_t data, uint32_t mask);
+ uint32_t __FASTCALL read_signal(int id);
+
void update_config();
bool process_state(FILEIO* state_fio, bool loading);
lx = ly = 0;
event_timeout = -1;
event_sampling = -1;
- axisdata = 0x0f;
+ axisdata = 0x00;
-// register_frame_event(this);
}
void MOUSE::release()
{
}
-void MOUSE::event_pre_frame()
-{
-// event_callback(EVENT_MOUSE_SAMPLING, 0);
-}
void MOUSE::reset()
{
void MOUSE::update_strobe()
{
-
bool _bak = strobe;
uint8_t _mask = ((port_num & 1) != 0) ? 0x20 : 0x10;
strobe = ((mouse_mask & _mask) != 0) ? true : false;
- uint32_t com_d = SIG_JOYPORT_TYPE_MOUSE;
+ int com_d = SIG_JOYPORT_TYPE_MOUSE;
if(port_num != 0) {
com_d |= SIG_JOYPORT_CH1;
}
- if(strobe) {
- com_d |= SIG_JOYPORT_COM;
- }
+ com_d |= SIG_JOYPORT_COM;
if((_bak != strobe)/* && (flag)*/) {
if(phase == 0) {
if(strobe) {
force_register_event(this, EVENT_MOUSE_TIMEOUT, 2000.0, false, event_timeout);
phase = 2; // SYNC from MAME 0.225. 20201126 K.O
}
- if(d_joyport != nullptr) {
- d_joyport->write_signal(com_d, 0xffffffff, 0xffffffff);
- }
- return;
+ } else {
+ phase++;
}
- phase++;
if(d_joyport != nullptr) {
- d_joyport->write_signal(com_d, 0xffffffff, 0xffffffff);
+ d_joyport->write_signal(com_d, !(strobe) ? 0x00000000 : 0xffffffff, 0xffffffff);
}
}
}
lx = ly = 0;
sample_mouse_xy();
strobe = false;
+ axisdata = 0x00;
clear_event(this, event_timeout);
-// force_register_event(this, EVENT_MOUSE_SAMPLING,
-// 4.0e3, true, event_sampling);
+
+// sample_mouse_xy(); // Sample next value.
+ if(d_joyport != nullptr) {
+ int com_d = SIG_JOYPORT_TYPE_MOUSE;
+ if(port_num != 0) {
+ com_d |= SIG_JOYPORT_CH1;
+ }
+ // First, Set 0 to port
+ d_joyport->write_signal(com_d | SIG_JOYPORT_COM, 0x00000000, 0xffffffff);
+ d_joyport->write_signal(com_d | SIG_JOYPORT_DATA, 0xffffffff, 0xffffffff);
+ // Second, read port value.
+ mouse_mask = d_joyport->read_signal(com_d | SIG_JOYPORT_MASK);
+
+ update_strobe();
+ axisdata = ~(update_mouse());
+ check_mouse_data(true);
+ }
} else { // on -> off
+ phase = 0;
+ dx = dy = 0;
+ lx = ly = 0;
+ strobe = false;
+ axisdata = 0x0f;
+ mouse_mask = 0xff;
clear_event(this, event_timeout);
-// clear_event(this, event_sampling);
}
}
}