Note: This is MAJOR API CHANGE around mouse and joystick.
See DIFFs of this commit.
#ifdef USE_JOYSTICK
void EMU::update_joystick()
{
- uint32_t *joy_buffer = osd->get_joy_buffer();
uint8_t *key_buffer = osd->get_key_buffer();
+ uint32_t *joyp = osd->get_joy_buffer();
+ uint32_t joy_buffer[4];
memset(joy_status, 0, sizeof(joy_status));
+ for(int i = 0; i < 4; i++) {
+ joy_buffer[i] = joyp[i];
+ }
+ osd->release_joy_buffer(joyp);
for(int i = 0; i < 4; i++) {
for(int j = 0; j < 16; j++) {
#ifdef USE_JOYSTICK
const uint32_t* EMU::get_joy_buffer()
{
+ // Update joystick data per query joystick buffer.
+ update_joystick();
return (const uint32_t*)joy_status;
}
+void EMU::release_joy_buffer(const uint32_t* ptr)
+{
+ // ToDo: Unlock buffer.
+}
#endif
#ifdef USE_MOUSE
{
return (const int32_t*)osd->get_mouse_buffer();
}
+void EMU::release_mouse_buffer(const int32_t* ptr)
+{
+ // ToDo: Unlock buffer.
+ osd->release_mouse_buffer(ptr);
+}
+const int32_t EMU::get_mouse_button()
+{
+ return (const int32_t)osd->get_mouse_button();
+}
+
#endif
// ----------------------------------------------------------------------------
const uint8_t* get_key_buffer();
#ifdef USE_JOYSTICK
+ // Joystick buffer should be with locking and sampling.
const uint32_t* get_joy_buffer();
+ void release_joy_buffer(const uint32_t* ptr);
#endif
#ifdef USE_MOUSE
- const int* get_mouse_buffer();
+ // Mouse buffer should be with locking and sampling.
+ const int32_t* get_mouse_buffer();
+ const int32_t get_mouse_button();
+ void release_mouse_buffer(const uint32_t* ptr);
void enable_mouse();
void disable_mouse();
void toggle_mouse();
virtual void stop_auto_key() {}
virtual bool is_auto_key_running() { return false; }
virtual FIFO* get_auto_key_buffer() { return NULL; }
- // Mouse
+ // Keyboard
virtual const uint8_t* get_key_buffer() { return dummy_key_buffer; }
+ // Joystick buffer should be with locking and sampling.
virtual const uint32_t* get_joy_buffer() { return dummy_joy_buffer; }
- virtual const int* get_mouse_buffer() { return dummy_mouse_buffer; }
+ virtual void release_joy_buffer(const uint32_t* ptr) { };
+
+ // Mouse buffer should be with locking and sampling.
+ virtual const int32_t* get_mouse_buffer() { return dummy_mouse_buffer; }
+ virtual const int32_t get_mouse_button() { return 0; }
+ virtual void release_mouse_buffer(const int* ptr) { };
virtual void enable_mouse() {}
virtual void disable_mouse() {}
virtual void toggle_mouse() {}
message("* qt/osd")
-SET(THIS_LIB_VERSION 3.5.0)
+SET(THIS_LIB_VERSION 3.6.0)
set(s_qt_osd_headers
osd_base.h
message("* qt/avio")
-SET(THIS_LIB_VERSION 3.2.3)
+SET(THIS_LIB_VERSION 3.3.0)
set(s_qt_avio_headers
movie_saver.h
movie_loader.h
message("* qt/emuutils")
-SET(THIS_LIB_VERSION 2.22.5)
+SET(THIS_LIB_VERSION 3.0.0)
set(s_qt_emuutils_headers
../gui/csp_logger.h
message("* qt/gui")
-set(THIS_LIB_VERSION 3.5.1)
+set(THIS_LIB_VERSION 3.6.0)
set(s_qt_gui_headers
qt_dialogs.h
break;
}
}
+ p_osd->release_joy_buffer(joy_status);
p_osd->unlock_vm();
}
if((true_index < 0) || (true_index >= 4)) return;
p_osd->lock_vm();
uint32_t *joy_status = p_osd->get_joy_buffer();
-
//debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_JOYSTICK, "Y AXIS Changed #%d/%d, TYPE=%d VAL=%d", idx, true_index, type, value);
if(joy_status != NULL) {
switch(type) {
break;
}
}
+ p_osd->release_joy_buffer(joy_status);
p_osd->unlock_vm();
}
break;
}
}
+ p_osd->release_joy_buffer(joy_status);
p_osd->unlock_vm();
}
break;
}
}
+ p_osd->release_joy_buffer(joy_status);
p_osd->unlock_vm();
}
break;
}
}
+ p_osd->release_joy_buffer(joy_status);
p_osd->unlock_vm();
}
break;
}
}
+ p_osd->release_joy_buffer(joy_status);
p_osd->unlock_vm();
}
vm_mutex = new QMutex(QMutex::Recursive);
locked_vm = false;
screen_mutex = new QMutex(QMutex::Recursive);
+ joystick_mutex = new QMutex(QMutex::Recursive);
mouse_mutex = new QMutex(QMutex::Recursive);
log_mutex = new QMutex(QMutex::Recursive);
QMutexLocker l(log_mutex);
p_logger->set_osd(NULL);
}
+ delete joystick_mutex;
delete mouse_mutex;
delete vm_mutex;
delete screen_mutex;
QMutex *screen_mutex;
QMutex *vm_mutex;
QMutex *debug_mutex;
+ QMutex *joystick_mutex;
QMutex *mouse_mutex;
QMutex *log_mutex;
//QImage *getPseudoVramClass(void) { return pPseudoVram;}
void set_mouse_pointer(int x, int y);
void set_mouse_button(int button);
- int get_mouse_button();
void modify_key_buffer(int code, uint8_t val);
uint8_t* get_key_buffer();
uint32_t* get_joy_buffer();
+ void release_joy_buffer(uint32_t* ptr);
+ int32_t get_mouse_button();
int32_t* get_mouse_buffer();
+ void release_mouse_buffer(int32_t* ptr);
// common printer
void reset_printer();
void update_printer();
{
// initialize status
memset(key_status, 0, sizeof(key_status));
- memset(joy_status, 0, sizeof(joy_status));
- memset(mouse_status, 0, sizeof(mouse_status));
- // mouse emulation is disenabled
- mouse_enabled = false;
+ {
+ QMutexLocker n(joystick_mutex);
+ memset(joy_status, 0, sizeof(joy_status));
+ }
+ {
+ QMutexLocker n(mouse_mutex);
+ memset(mouse_status, 0, sizeof(mouse_status));
+ // mouse emulation is disenabled
+ mouse_enabled = false;
+ }
mouse_ptrx = mouse_oldx = get_screen_width() / 2;
mouse_ptry = mouse_oldy = get_screen_height() / 2;
if((jsnum < 0) || (jsnum >= 4)) return;
if((axis_idx < 0) || (axis_idx >= 16)) return;
if((assigned_value < -256) || (assigned_value >= 0x10000)) return;
+
+ QMutexLocker n(joystick_mutex);
p_config->joy_buttons[jsnum][axis_idx] = assigned_value;
}
+void OSD_BASE::update_input_mouse()
+{
+ QMutexLocker n(mouse_mutex);
+ memset(mouse_status, 0, sizeof(mouse_status));
+ //bool hid = false;
+ if(mouse_enabled) {
+ int xx = mouse_ptrx;
+ int yy = mouse_ptry;
+ mouse_status[0] = xx - mouse_oldx;
+ mouse_status[1] = yy - mouse_oldy;
+ mouse_status[2] = mouse_button;
+ //printf("Mouse delta(%d, %d)\n", delta_x, delta_y);
+ mouse_oldx = xx;
+ mouse_oldy = yy;
+ }
+
+}
+
void OSD_BASE::update_input()
{
bool press_flag = false;
if(p_config->use_joy_to_key) {
int status[256] = {0};
if(p_config->joy_to_key_type == 0) { // Cursor
+ QMutexLocker n(joystick_mutex);
static const int vk[] = {VK_UP, VK_DOWN, VK_LEFT, VK_RIGHT};
for(int i = 0; i < 4; i++) {
if(joy_status[0] & (1 << i)) {
}
}
} else if(p_config->joy_to_key_type == 1) { // 2468
+ QMutexLocker n(joystick_mutex);
static const int vk[] = {VK_NUMPAD8, VK_NUMPAD2, VK_NUMPAD4, VK_NUMPAD6};
for(int i = 0; i < 4; i++) {
if(joy_status[0] & (1 << i)) {
}
} else if(p_config->joy_to_key_type == 2) { // 24681379
// numpad key (8-directions)
+ QMutexLocker n(joystick_mutex);
switch(joy_status[0] & 0x0f) {
case 0x02 + 0x04: status[VK_NUMPAD1] = 1; break; // down-left
case 0x02 : status[VK_NUMPAD2] = 1; break; // down
}
} else if(p_config->joy_to_key_type == 3) { // 1235
static const int vk[] = {VK_NUMPAD5, VK_NUMPAD2, VK_NUMPAD1, VK_NUMPAD3};
+ QMutexLocker n(joystick_mutex);
for(int i = 0; i < 4; i++) {
if(joy_status[0] & (1 << i)) {
status[vk[i]] = 1;
}
if(p_config->joy_to_key_type == 1 || p_config->joy_to_key_type == 2) {
// numpad key
+ QMutexLocker n(joystick_mutex);
if(p_config->joy_to_key_numpad5 && !(joy_status[0] & 0x0f)) {
if(!numpad_5_pressed) {
status[VK_NUMPAD5] = 1;
}
} else if(p_config->joy_to_key_type == 3) {
// numpad key
+ QMutexLocker n(joystick_mutex);
if(p_config->joy_to_key_numpad5 && !(joy_status[0] & 0x0f)) {
if(!numpad_5_pressed) {
status[VK_NUMPAD8] = 1;
}
for(int i = 0; i < 16; i++) {
+ QMutexLocker n(joystick_mutex);
if(joy_status[0] & (1 << (i + 4))) {
if(p_config->joy_to_key_buttons[i] < 0 && -p_config->joy_to_key_buttons[i] < 256) {
status[-p_config->joy_to_key_buttons[i]] = 1;
}
lost_focus = false;
-
// update mouse status
-
- //if(mouse_enabled) {
- memset(mouse_status, 0, sizeof(mouse_status));
- //bool hid = false;
- if(mouse_enabled) {
- QMutexLocker n(mouse_mutex);
- int xx = mouse_ptrx;
- int yy = mouse_ptry;
- mouse_status[0] = xx - mouse_oldx;
- mouse_status[1] = yy - mouse_oldy;
- mouse_status[2] = mouse_button;
- //printf("Mouse delta(%d, %d)\n", delta_x, delta_y);
- mouse_oldx = xx;
- mouse_oldy = yy;
- }
- //}
- // move mouse cursor to the center of window
+ update_input_mouse();
}
uint32_t* OSD_BASE::get_joy_buffer()
{
+ if(joystick_mutex != NULL) {
+ joystick_mutex->lock();
+ }
return joy_status;
}
+void OSD_BASE::release_joy_buffer(uint32_t* ptr)
+{
+// if(ptr != nullptr) {
+ if(joystick_mutex != NULL) {
+ joystick_mutex->unlock();
+ }
+// }
+}
+
int32_t* OSD_BASE::get_mouse_buffer()
{
- QMutexLocker n(mouse_mutex);
+ update_input_mouse();
return mouse_status;
}
+void OSD_BASE::release_mouse_buffer(int32_t* ptr)
+{
+}
void OSD_BASE::press_button(int num)
{
mouse_button = button;
}
-int OSD_BASE::get_mouse_button()
+int32_t OSD_BASE::get_mouse_button()
{
QMutexLocker n(mouse_mutex);
return mouse_button;
void KEYBOARD::initialize()
{
key_stat = emu->get_key_buffer();
- joy_stat = emu->get_joy_buffer();
+// joy_stat = emu->get_joy_buffer();
}
uint32_t KEYBOARD::read_io8(uint32_t addr)
{
+ joy_stat = emu->get_joy_buffer();
+ uint32_t __joy_stat[2];
+ __joy_stat[0] = joy_stat[0];
+ __joy_stat[1] = joy_stat[1];
+ emu->release_joy_buffer(joy_stat);
+
switch(addr & 0x7f) {
case 0x70:
case 0x71:
case 0x72:
case 0x73:
case 0x74:
- if(joy_stat[0] & joy_bits[addr - 0x70]) {
+ if(__joy_stat[0] & joy_bits[addr - 0x70]) {
return 0xff;
}
break;
case 0x77:
case 0x78:
case 0x79:
- if(joy_stat[1] & joy_bits[addr - 0x75]) {
+ if(__joy_stat[1] & joy_bits[addr - 0x75]) {
return 0xff;
}
break;
}
key_status[i] = val;
}
- d_psg->write_signal(SIG_AY_3_891X_PORT_A, ~(joy_stat[0] & 0x1f), 0xff);
- d_psg->write_signal(SIG_AY_3_891X_PORT_B, ~(joy_stat[1] & 0x1f), 0xff);
+ uint32_t _n[2];
+ _n[0] = joy_stat[0];
+ _n[1] = joy_stat[1];
+ emu->release_joy_buffer(joy_stat);
+ d_psg->write_signal(SIG_AY_3_891X_PORT_A, ~(_n[0] & 0x1f), 0xff);
+ d_psg->write_signal(SIG_AY_3_891X_PORT_B, ~(_n[1] & 0x1f), 0xff);
}
void MCU::write_signal(int id, uint32_t data, uint32_t mask)
void KEYBOARD::initialize()
{
key_stat = emu->get_key_buffer();
- joy_stat = emu->get_joy_buffer();
+// joy_stat = emu->get_joy_buffer();
// register event to update the key status
// register_frame_event(this); // is this needed?
}
void KEYBOARD::event_frame()
{
- if (joy_stat[0] & 0x04 || joy_stat[0] & 0x08) {
+ joy_stat = emu->get_joy_buffer();
+ uint32_t _n[2];
+ _n[0] = joy_stat[0];
+ _n[1] = joy_stat[1];
+ emu->release_joy_buffer(joy_stat);
+ if (_n[0] & 0x04 || _n[0] & 0x08) {
d_cpu->write_signal(SIG_CPU_IRQ, 1, 1);
}
+
}
void KEYBOARD::write_io8(uint32_t addr, uint32_t data)
uint32_t KEYBOARD::read_io8(uint32_t addr)
{
// Controller 1
+ joy_stat = emu->get_joy_buffer();
+ uint32_t __joy_stat[2];
+ __joy_stat[0] = joy_stat[0];
+ __joy_stat[1] = joy_stat[1];
+ emu->release_joy_buffer(joy_stat);
if ((addr & 0x000000ff)==0xfc) {
uint32_t button=0x70;//0xf0;
if (!tenkey) {
uint32_t joystick=0x7f;//0xff;
- if (joy_stat[0] & 0x01) joystick &= 0xfe; // U
- if (joy_stat[0] & 0x02) joystick &= 0xfb; // D
- if (joy_stat[0] & 0x04) joystick &= 0xf7; // L
- if (joy_stat[0] & 0x08) joystick &= 0xfd; // R
- if (joy_stat[0] & 0x20) joystick &= 0xbf; // F1
+ if (__joy_stat[0] & 0x01) joystick &= 0xfe; // U
+ if (__joy_stat[0] & 0x02) joystick &= 0xfb; // D
+ if (__joy_stat[0] & 0x04) joystick &= 0xf7; // L
+ if (__joy_stat[0] & 0x08) joystick &= 0xfd; // R
+ if (__joy_stat[0] & 0x20) joystick &= 0xbf; // F1
return joystick;
}
- if (joy_stat[0] & 0x10)
+ if (__joy_stat[0] & 0x10)
button &= 0xbf; // F2
if ((key_stat[0x31] & 0x80) || (key_stat[0x61] & 0x80))
return (button | 0x0d); // 1
uint32_t button=0x70;//0xf0;
if (!tenkey) {
uint32_t joystick=0x7f;//0xff;
- if (joy_stat[1] & 0x01) joystick &= 0xfe; // U
- if (joy_stat[1] & 0x02) joystick &= 0xfb; // D
- if (joy_stat[1] & 0x04) joystick &= 0xf7; // L
- if (joy_stat[1] & 0x08) joystick &= 0xfd; // R
- if (joy_stat[1] & 0x20) joystick &= 0xbf; // F1
+ if (__joy_stat[1] & 0x01) joystick &= 0xfe; // U
+ if (__joy_stat[1] & 0x02) joystick &= 0xfb; // D
+ if (__joy_stat[1] & 0x04) joystick &= 0xf7; // L
+ if (__joy_stat[1] & 0x08) joystick &= 0xfd; // R
+ if (__joy_stat[1] & 0x20) joystick &= 0xbf; // F1
return joystick;
}
- if (joy_stat[1] & 0x10)
+ if (__joy_stat[1] & 0x10)
button &= 0xbf; // F2
if (key_stat[0x51] & 0x80)
return (button | 0x0d); // 1 'q'
message("* vm/common_vm")
-SET(THIS_LIB_VERSION 3.7.0)
+SET(THIS_LIB_VERSION 3.8.0)
#include(cotire)
set(s_vm_common_vm_srcs
void MEMORY::initialize()
{
key_stat = emu->get_key_buffer();
- joy_stat = emu->get_joy_buffer();
+// joy_stat = emu->get_joy_buffer();
// register event
register_vline_event(this);
pad_strobe = false;
// joypad #1
pad1_bits = 0;
+ joy_stat = emu->get_joy_buffer();
if(joy_stat[0] & 0x10) pad1_bits |= 0x01; // A
if(joy_stat[0] & 0x20) pad1_bits |= 0x02; // B
if(joy_stat[0] & 0x40) pad1_bits |= 0x04; // SEL
if(joy_stat[1] & 0x02) pad2_bits |= 0x20; // DOWN
if(joy_stat[1] & 0x04) pad2_bits |= 0x40; // LEFT
if(joy_stat[1] & 0x08) pad2_bits |= 0x80; // RIGHT
+ emu->release_joy_buffer(joy_stat);
}
// keyboard
if((data & 0x07) == 0x04) {
void JOYSTICK::initialize()
{
- rawdata = emu->get_joy_buffer();
- mouse_state = emu->get_mouse_buffer();
+// rawdata = emu->get_joy_buffer();
+// mouse_state = emu->get_mouse_buffer();
emulate_mouse[0] = emulate_mouse[1] = false;
joydata[0] = joydata[1] = 0xff;
dx = dy = 0;
emulate_mouse[1] = false;
break;
}
- mouse_state = emu->get_mouse_buffer();
+
#endif
if(opn != NULL) {
opn->write_signal(SIG_YM2203_PORT_A, 0xff, 0xff);
dy = 127;
}
}
- if(mouse_state != NULL) {
- stat = mouse_state[2];
- mouse_button = 0x00;
- if((stat & 0x01) == 0) mouse_button |= 0x10; // left
- if((stat & 0x02) == 0) mouse_button |= 0x20; // right
- }
-#endif
+ emu->release_mouse_buffer(mouse_state);
+#endif
rawdata = emu->get_joy_buffer();
- if(rawdata == NULL) return;
-
for(ch = 0; ch < 2; ch++) {
if(!emulate_mouse[ch]) { // Joystick
val = rawdata[ch];
} else { // MOUSE
}
}
+ emu->release_joy_buffer(rawdata);
}
uint32_t JOYSTICK::update_mouse(uint32_t mask)
{
#if !defined(_FM8)
+ int stat = emu->get_mouse_button();
+ mouse_button = 0x00;
+ if((stat & 0x01) == 0) mouse_button |= 0x10; // left
+ if((stat & 0x02) == 0) mouse_button |= 0x20; // right
uint32_t button = mouse_button;
+
switch(mouse_phase) {
case 1:
mouse_data = lx & 0x0f;
case 3: // Get Printer Joystick (CH1)
int ch = addr - 1;
if(lpt_type == ch) {
+ rawdata = emu->get_joy_buffer();
uint8_t raw = rawdata[ch - 1];
+ emu->release_joy_buffer(rawdata);
bool f = false;
f |= ((raw & 0x08) && !(lpmask & 0x01));
f |= ((raw & 0x04) && !(lpmask & 0x02));
void JOYPAD::query_joystick(void)
{
// enabled
+ bool __sigf = false;
rawdata = emu->get_joy_buffer();
uint32_t stat = 0;
if((rawdata != NULL) && (enabled)) {
+ __sigf = true;
uint32_t d = rawdata[pad_num];
// out_debug_log(_T("DATA: %08X"), d);
if((type_6buttons) && (sel_line)) { // 6Buttons Multiplied
// None Connected
stat = 0x00;
}
- write_signals(&line_dat, stat);
+ emu->release_joy_buffer(rawdata);
+ if(__sigf) {
+ write_signals(&line_dat, stat);
+ }
}
void JOYPAD::write_signal(int id, uint32_t data, uint32_t mask)
void JOYSTICK::initialize()
{
- rawdata = emu->get_joy_buffer();
joydata[0] = joydata[1] = 0x00;
// Force reset pads.
uint32_t joydata[2];
bool stat_com[2];
- const uint32_t *rawdata;
-
uint8_t mouse_mask;
uint32_t connected_type[2];
void MOUSE::event_pre_frame()
{
- event_callback(EVENT_MOUSE_SAMPLING, 0);
+// event_callback(EVENT_MOUSE_SAMPLING, 0);
}
void MOUSE::reset()
if(phase == 0) {
if(strobe) {
// Sample data from MOUSE to registers.
+ sample_mouse_xy(); // Sample next value.
lx = -dx;
ly = -dy;
dx = 0;
uint8_t rval = 0xf0;
rval |= (update_mouse() & 0x0f);
- mouse_state = emu->get_mouse_buffer();
if((trig & 0x01) == 0) {
rval &= ~0x10; // Button LEFT
}
rval &= ~0x20; // Button RIGHT
}
if(mouse_state != NULL) {
- uint32_t stat = mouse_state[2];
+ int32_t stat = emu->get_mouse_button();
if((stat & 0x01) == 0) {
rval &= ~0x10; // Button LEFT
}
phase = 0;
dx = dy = 0;
lx = ly = 0;
+ sample_mouse_xy();
strobe = false;
clear_event(this, event_timeout);
// force_register_event(this, EVENT_MOUSE_SAMPLING,
}
}
+void MOUSE::sample_mouse_xy()
+{
+ mouse_state = emu->get_mouse_buffer();
+ if(mouse_state != NULL) {
+ dx += mouse_state[0];
+ dy += mouse_state[1];
+ if(dx < -127) {
+ dx += 128;
+ } else if(dx > 127) {
+ dx -= 128;
+ }
+ if(dy < -127) {
+ dy += 128;
+ } else if(dy > 127) {
+ dy -= 128;
+ }
+ }
+ emu->release_mouse_buffer(mouse_state);
+}
void MOUSE::event_callback(int event_id, int err)
{
switch(event_id) {
lx = ly = 0;
break;
case EVENT_MOUSE_SAMPLING:
- mouse_state = emu->get_mouse_buffer();
- if(mouse_state != NULL) {
- dx += mouse_state[0];
- dy += mouse_state[1];
- if(dx < -127) {
- dx += 128;
- } else if(dx > 127) {
- dx -= 128;
- }
- if(dy < -127) {
- dy += 128;
- } else if(dy > 127) {
- dy -= 128;
- }
- }
+ sample_mouse_xy();
break;
}
}
void KEYBOARD::initialize()
{
key_stat = emu->get_key_buffer();
- joy_stat = emu->get_joy_buffer();
+// joy_stat = emu->get_joy_buffer();
column = 0;
break_pressed = false;
}
} else {
// joystick
+ joy_stat = emu->get_joy_buffer();
for(int i = 0; i < 12; i++) {
uint8_t map = key_map[7][i];
uint8_t stat = (map & 0x80) ? joy_stat[1] : joy_stat[0];
} else {
start_pressed=false;
}
+ emu->release_joy_buffer(joy_stat);
}
d_pio->write_signal(SIG_I8255_PORT_A, ~data, 0xff);
data >>= 8;
if ((addr & 0x000000ff)==0xfc) {
const uint8_t *ten=emu->get_key_buffer();
const uint32_t *joy=emu->get_joy_buffer();
+ uint32_t __joy[2];
+ __joy[0] = joy[0];
+ __joy[1] = joy[1];
+ emu->release_joy_buffer(joy);
+
uint8_t button=0xf0;
- if (joy[0] & 0x10) button=0xb0; // B2
+ if (__joy[0] & 0x10) button=0xb0; // B2
// Bit 7: 0\81i\8ag\92£\92[\8eq\82P\82O\83s\83\93\82Ì\93à \97e\81j
// Bit 6: 1=Off/0=On \83g\83\8a\83K\81[\82P\81i\8d¶\81j
// Bit 5: 1\81i\82i\82n\82x\92[\8eq\82V\83s\83\93\81@\96¢\8eg\97p\81j
// Bit 0: 1=Off/0=On UP
if (!tenkey) {
uint32_t joystick=0xff;
- if (joy[0] & 0x01) joystick &= 0xfe; // U
- if (joy[0] & 0x02) joystick &= 0xfb; // D
- if (joy[0] & 0x04) joystick &= 0xf7; // L
- if (joy[0] & 0x08) joystick &= 0xfd; // R
- if (joy[0] & 0x20) joystick &= 0xbf; // B1
+ if (__joy[0] & 0x01) joystick &= 0xfe; // U
+ if (__joy[0] & 0x02) joystick &= 0xfb; // D
+ if (__joy[0] & 0x04) joystick &= 0xf7; // L
+ if (__joy[0] & 0x08) joystick &= 0xfd; // R
+ if (__joy[0] & 0x20) joystick &= 0xbf; // B1
return joystick;
}
+
// \83L\81[\83p\83b\83h\83}\83g\83\8a\83b\83N\83X\81i\82j\82l\82R\81|\82O\82Ì\82S\82a\82\89\82\94\82È\82Ì\82Å\82O\81|\82e\81j
// 0=\96¢\8eg\97p 1='8' 2='4' 3='5'
// 4=\96¢\8eg\97p 5='7' 6='#' 7='2'
return (button | 0x06); // #
if (ten[0xde] & 0x80)
return (button | 0x08); // *
+
return (button | 0x0f);
}
if (((KEYBOARD *)d_key)->is_start()) {
// initialize inputs
key_stat = emu->get_key_buffer();
- joy_stat = emu->get_joy_buffer();
+// joy_stat = emu->get_joy_buffer();
// initialize display
palette_pc[0] = RGB_COLOR(0, 0, 0);
return d_via->read_io8(addr);
case 0xcc00:
if((addr & 0xffff) == 0xcc02) {
- return ((joy_stat[0] & 0x08) >> 3) | // bit0: right
+ joy_stat = emu->get_joy_buffer();
+ uint8_t _ret;
+ _ret = ((joy_stat[0] & 0x08) >> 3) | // bit0: right
((joy_stat[0] & 0x04) >> 1) | // bit1: left
((joy_stat[0] & 0x01) << 2) | // bit2: up
((joy_stat[0] & 0x02) << 2) | // bit3: down
((joy_stat[0] & 0x10) ) | // bit4: switch
((joy_stat[0] & 0x20) >> 1);
+ emu->release_joy_buffer(joy_stat);
+ return _ret;
}
break;
}
void KEYBOARD::initialize()
{
key_stat = emu->get_key_buffer();
- joy_stat = emu->get_joy_buffer();
+// joy_stat = emu->get_joy_buffer();
}
uint32_t KEYBOARD::read_io8(uint32_t addr)
for(int i = 0; i < 8; i++) {
val |= key_stat[key_map[1][i]] ? (1 << i) : 0;
}
+ joy_stat = emu->get_joy_buffer();
val |= (joy_stat[0] & 0x10) ? 0x01 : 0;
val |= (joy_stat[0] & 0x20) ? 0x02 : 0;
val |= (joy_stat[1] & 0x10) ? 0x10 : 0;
val |= (joy_stat[1] & 0x20) ? 0x20 : 0;
+ emu->release_joy_buffer(joy_stat);
return val;
case 0x37:
// case 0x3f:
+ joy_stat = emu->get_joy_buffer();
val |= (joy_stat[0] & 0x08) ? 0x01 : 0;
val |= (joy_stat[0] & 0x01) ? 0x02 : 0;
val |= (joy_stat[0] & 0x04) ? 0x04 : 0;
val |= (joy_stat[1] & 0x01) ? 0x20 : 0;
val |= (joy_stat[1] & 0x04) ? 0x40 : 0;
val |= (joy_stat[1] & 0x02) ? 0x80 : 0;
+ emu->release_joy_buffer(joy_stat);
return val;
}
return 0xff;
void JOYSTICK::initialize()
{
- joy_stat = emu->get_joy_buffer();
+// joy_stat = emu->get_joy_buffer();
select = 0;
// register event to update the key status
void JOYSTICK::event_frame()
{
- d_psg->write_signal(SIG_AY_3_891X_PORT_A, PSG14_MASK & ~(joy_stat[select] & 0x3f), 0x7f);
+ joy_stat = emu->get_joy_buffer();
+ uint8_t n = joy_stat[select];
+ emu->release_joy_buffer(joy_stat);
+ d_psg->write_signal(SIG_AY_3_891X_PORT_A, PSG14_MASK & ~(n & 0x3f), 0x7f);
}
void JOYSTICK::write_signal(int id, uint32_t data, uint32_t mask)
if(id == SIG_JOYSTICK_SEL) {
if(select != ((data & mask) != 0)) {
select = ((data & mask) != 0);
- d_psg->write_signal(SIG_AY_3_891X_PORT_A, PSG14_MASK & ~(joy_stat[select] & 0x3f), 0x7f);
+ joy_stat = emu->get_joy_buffer();
+ uint8_t n = joy_stat[select];
+ emu->release_joy_buffer(joy_stat);
+ d_psg->write_signal(SIG_AY_3_891X_PORT_A, PSG14_MASK & ~(n & 0x3f), 0x7f);
}
}
}
void JOYSTICK::initialize()
{
mode = 0xf;
- joy_stat = emu->get_joy_buffer();
+// joy_stat = emu->get_joy_buffer();
}
void JOYSTICK::write_io8(uint32_t addr, uint32_t data)
}
// direction
+ joy_stat = emu->get_joy_buffer();
if(dir) {
if(joy_stat[num] & 0x08) val &= ~0x08;
if(joy_stat[num] & 0x04) val &= ~0x04;
// trigger
if(joy_stat[num] & 0x10) val &= ~0x20;
if(joy_stat[num] & 0x20) val &= ~0x10;
+ emu->release_joy_buffer(joy_stat);
return val;
}
void MOUSE::initialize()
{
- stat = emu->get_mouse_buffer();
+// stat = emu->get_mouse_buffer();
select = false;
}
return;
}
// Z80SIO Ch.B DTR H->L
+ stat = emu->get_mouse_buffer();
uint32_t d0 = (stat[0] >= 128 ? 0x10 : stat[0] < -128 ? 0x20 : 0) |
(stat[1] >= 128 ? 0x40 : stat[1] < -128 ? 0x80 : 0) |
((stat[2] & 1) ? 1 : 0) | ((stat[2] & 2) ? 2 : 0);
uint32_t d1 = (uint8_t)stat[0];
uint32_t d2 = (uint8_t)stat[1];
+ emu->release_mouse_buffer(stat);
d_sio->write_signal(SIG_Z80SIO_CLEAR_CH1, 1, 1);
d_sio->write_signal(SIG_Z80SIO_RECV_CH1, d0, 0xff);
void JOYSTICK::initialize()
{
mode = 0xf;
- joy_stat = emu->get_joy_buffer();
+// joy_stat = emu->get_joy_buffer();
}
void JOYSTICK::write_io8(uint32_t addr, uint32_t data)
}
// direction
+ joy_stat = emu->get_joy_buffer();
if(dir) {
if(joy_stat[num] & 0x08) val &= ~0x08;
if(joy_stat[num] & 0x04) val &= ~0x04;
// trigger
if(joy_stat[num] & 0x10) val &= ~0x20;
if(joy_stat[num] & 0x20) val &= ~0x10;
+ emu->release_joy_buffer(joy_stat);
return val;
}
void MOUSE::initialize()
{
- stat = emu->get_mouse_buffer();
+// stat = emu->get_mouse_buffer();
select = false;
}
return;
}
// Z80SIO Ch.B DTR H->L
+ stat = emu->get_mouse_buffer();
uint32_t d0 = (stat[0] >= 128 ? 0x10 : stat[0] < -128 ? 0x20 : 0) |
(stat[1] >= 128 ? 0x40 : stat[1] < -128 ? 0x80 : 0) |
((stat[2] & 1) ? 1 : 0) | ((stat[2] & 2) ? 2 : 0);
uint32_t d1 = (uint8_t)stat[0];
uint32_t d2 = (uint8_t)stat[1];
+ emu->release_mouse_buffer(stat);
// d_sio->write_signal(SIG_Z80SIO_CLEAR_CH1, 1, 1);
d_sio->write_signal(SIG_Z80SIO_RECV_CH1, d0, 0xff);
void KEYBOARD::initialize()
{
key_stat = emu->get_key_buffer();
- mouse_stat = emu->get_mouse_buffer();
+// mouse_stat = emu->get_mouse_buffer();
key_buf = new FIFO(64);
rsp_buf = new FIFO(16);
caps = kana = graph = false;
switch(cmd) {
case 1:
// mouse ???
+ mouse_stat = emu->get_mouse_buffer();
mx = mouse_stat[0]; mx = (mx > 126) ? 126 : (mx < -128) ? -128 : mx;
my = mouse_stat[1]; my = (my > 126) ? 126 : (my < -128) ? -128 : my;
mb = mouse_stat[2];
+ emu->release_mouse_buffer(mouse_stat);
// rsp_buf->clear();
rsp_buf->write(0x140 | (mx & 0x3f));
rsp_buf->write(0x140 | (my & 0x3f));
void JOYSTICK::initialize()
{
val_1x03 = 0x7e;
- joy_stat = emu->get_joy_buffer();
+// joy_stat = emu->get_joy_buffer();
// register event
register_vline_event(this);
bool y0, y1;
clk = get_current_clock() & 0x007f;
+ joy_stat = emu->get_joy_buffer();
js = joy_stat[jnum];
+ emu->release_joy_buffer(joy_stat);
y0 = y1 = false;
switch (js & 0xc0) {
break;
case DEVICE_JOYSTICK_JOY700: // TSUKUMO JOY-700
+ joy_stat = emu->get_joy_buffer();
if(joy_stat[0] & 0x01) val &= ~0x10; // up : JB2
if(joy_stat[0] & 0x02) val &= ~0x08; // down : JB1
if(joy_stat[0] & 0x04) val &= ~0x02; // left : JA1
if(joy_stat[0] & 0x08) val &= ~0x04; // right : JA2
if(joy_stat[0] & 0x10) val &= ~0x1e; // trigger A : ALL
if(joy_stat[0] & 0x20) val &= ~0x1e; // trigger B : ALL
+ emu->release_joy_buffer(joy_stat);
break;
case DEVICE_JOYSTICK_AM7J: // AM7J ATARI Joystick adaptor
if (v == 0) {
// trigger
val_1x03 = 0x7e;
+ joy_stat = emu->get_joy_buffer();
if(joy_stat[0] & 0x10) val_1x03 &= ~0x02;
if(joy_stat[0] & 0x20) val_1x03 &= ~0x04;
if(joy_stat[1] & 0x10) val_1x03 &= ~0x08;
if(joy_stat[1] & 0x20) val_1x03 &= ~0x10;
+ emu->release_joy_buffer(joy_stat);
} else if (v == 200) {
// stick (PWM)
val_1x03 &= ~(0x06 | 0x18);
+ joy_stat = emu->get_joy_buffer();
register_event_by_clock(this, EVENT_1X03_X1, pulse_width_1x03(joy_stat[0], 0x04, 0x08), false, NULL);
register_event_by_clock(this, EVENT_1X03_Y1, pulse_width_1x03(joy_stat[0], 0x01, 0x02), false, NULL);
register_event_by_clock(this, EVENT_1X03_X2, pulse_width_1x03(joy_stat[1], 0x04, 0x08), false, NULL);
register_event_by_clock(this, EVENT_1X03_Y2, pulse_width_1x03(joy_stat[1], 0x01, 0x02), false, NULL);
+ emu->release_joy_buffer(joy_stat);
}
}
}
void JOYPAC2::initialize(int id)
{
- joy = emu->get_joy_buffer();
+// joy = emu->get_joy_buffer();
}
void JOYPAC2::write_io8(uint32_t addr, uint32_t data)
switch(addr & 0xff) {
case 0x19:
+ joy = emu->get_joy_buffer();
if(joy[1] & 0x01) val &= ~0x01;
if(joy[1] & 0x02) val &= ~0x02;
if(joy[1] & 0x04) val &= ~0x04;
if(joy[1] & 0x08) val &= ~0x08;
if(joy[1] & 0x10) val &= ~0x10;
if(joy[1] & 0x20) val &= ~0x20;
+ emu->release_joy_buffer(joy);
return val;
case 0x1a:
+ joy = emu->get_joy_buffer();
if(joy[0] & 0x01) val &= ~0x01;
if(joy[0] & 0x02) val &= ~0x02;
if(joy[0] & 0x04) val &= ~0x04;
if(joy[0] & 0x08) val &= ~0x08;
if(joy[0] & 0x10) val &= ~0x10;
if(joy[0] & 0x20) val &= ~0x20;
+ emu->release_joy_buffer(joy);
return val;
}
return 0xff;
void JOYPAC2::initialize(int id)
{
- joy = emu->get_joy_buffer();
+// joy = emu->get_joy_buffer();
}
void JOYPAC2::write_io8(uint32_t addr, uint32_t data)
switch(addr & 0xff) {
case 0x19:
+ joy = emu->get_joy_buffer();
if(joy[1] & 0x01) val &= ~0x01;
if(joy[1] & 0x02) val &= ~0x02;
if(joy[1] & 0x04) val &= ~0x04;
if(joy[1] & 0x08) val &= ~0x08;
if(joy[1] & 0x10) val &= ~0x10;
if(joy[1] & 0x20) val &= ~0x20;
+ emu->release_joy_buffer(joy);
return val;
case 0x1a:
+ joy = emu->get_joy_buffer();
if(joy[0] & 0x01) val &= ~0x01;
if(joy[0] & 0x02) val &= ~0x02;
if(joy[0] & 0x04) val &= ~0x04;
if(joy[0] & 0x08) val &= ~0x08;
if(joy[0] & 0x10) val &= ~0x10;
if(joy[0] & 0x20) val &= ~0x20;
+ emu->release_joy_buffer(joy);
return val;
}
return 0xff;
{
// init keyboard
key_stat = emu->get_key_buffer();
- mouse_stat = emu->get_mouse_buffer();
+// mouse_stat = emu->get_mouse_buffer();
key_buf = new FIFO(64);
caps = kana = false;
// mouse
if(key_buf->empty()) {
uint8_t val = 0;
+ mouse_stat = emu->get_mouse_buffer();
if(!(mouse_stat[2] & 1)) val |= 1;
if(!(mouse_stat[2] & 2)) val |= 2;
if(caps) val |= 0x10;
update_key();
key_prev = val;
}
+ emu->release_mouse_buffer(mouse_stat);
}
} else if(event_id == EVENT_10HZ) {
if(ts == 3) {
void JOYSTICK::initialize()
{
- joy_stat = emu->get_joy_buffer();
-
+// joy_stat = emu->get_joy_buffer();
// register event to update the key status
register_frame_event(this);
}
void JOYSTICK::event_frame()
{
+ joy_stat = emu->get_joy_buffer();
+ uint32_t __joy_stat[2];
+ __joy_stat[0] = joy_stat[0];
+ __joy_stat[1] = joy_stat[1];
+ emu->release_joy_buffer(joy_stat);
+
#if defined(_PC6001MK2SR) || defined(_PC6601SR)
- d_psg->write_signal(SIG_YM2203_PORT_A, ~(joy_stat[0] & 0x3f), 0xff);
- d_psg->write_signal(SIG_YM2203_PORT_B, ~(joy_stat[1] & 0x1f), 0xff);
+ d_psg->write_signal(SIG_YM2203_PORT_A, ~(__joy_stat[0] & 0x3f), 0xff);
+ d_psg->write_signal(SIG_YM2203_PORT_B, ~(__joy_stat[1] & 0x1f), 0xff);
#else
- d_psg->write_signal(SIG_AY_3_891X_PORT_A, ~(joy_stat[0] & 0x3f), 0xff);
- d_psg->write_signal(SIG_AY_3_891X_PORT_B, ~(joy_stat[1] & 0x1f), 0xff);
+ d_psg->write_signal(SIG_AY_3_891X_PORT_A, ~(__joy_stat[0] & 0x3f), 0xff);
+ d_psg->write_signal(SIG_AY_3_891X_PORT_B, ~(__joy_stat[1] & 0x1f), 0xff);
#endif
+
}
}
#endif
#ifdef SUPPORT_PC88_JOYSTICK
- joystick_status = emu->get_joy_buffer();
- mouse_status = emu->get_mouse_buffer();
+// joystick_status = emu->get_joy_buffer();
+// mouse_status = emu->get_mouse_buffer();
mouse_strobe_clock_lim = (int)((cpu_clock_low ? 720 : 1440) * 1.25);
#endif
if(Port44_OPNCH == 14) {
#ifdef SUPPORT_PC88_JOYSTICK
if(config.joystick_type == DEVICE_JOYSTICK) {
- return (~(joystick_status[0] >> 0) & 0x0f) | 0xf0;
+ joystick_status = emu->get_joy_buffer();
+ uint8_t _n = (~(joystick_status[0] >> 0) & 0x0f) | 0xf0;
+ emu->release_joy_buffer(joystick_status);
+ return _n;
} else if(config.joystick_type == DEVICE_MOUSE) {
switch(mouse_phase) {
case 0:
} else if(Port44_OPNCH == 15) {
#ifdef SUPPORT_PC88_JOYSTICK
if(config.joystick_type == DEVICE_JOYSTICK) {
- return (~(joystick_status[0] >> 4) & 0x03) | 0xfc;
+ joystick_status = emu->get_joy_buffer();
+ uint8_t _n = (~(joystick_status[0] >> 4) & 0x03) | 0xfc;
+ emu->release_joy_buffer(joystick_status);
+ return _n;
} else if(config.joystick_type == DEVICE_MOUSE) {
- return (~mouse_status[2] & 0x03) | 0xfc;
+ int _m = emu->get_mouse_button();
+ return (~_m & 0x03) | 0xfc;
}
#endif
return 0xff;
if(PortA8_OPNCH == 14) {
#ifdef SUPPORT_PC88_JOYSTICK
if(config.joystick_type == DEVICE_JOYSTICK) {
- return (~(joystick_status[0] >> 0) & 0x0f) | 0xf0;
+ joystick_status = emu->get_joy_buffer();
+ uint8_t _n = (~(joystick_status[0] >> 0) & 0x0f) | 0xf0;
+ emu->release_joy_buffer(joystick_status);
+ return _n;
} else if(config.joystick_type == DEVICE_MOUSE) {
switch(mouse_phase) {
case 0:
} else if(PortA8_OPNCH == 15) {
#ifdef SUPPORT_PC88_JOYSTICK
if(config.joystick_type == DEVICE_JOYSTICK) {
- return (~(joystick_status[0] >> 4) & 0x03) | 0xfc;
+ joystick_status = emu->get_joy_buffer();
+ uint8_t _n = (~(joystick_status[0] >> 4) & 0x03) | 0xfc;
+ emu->release_joy_buffer(joystick_status);
+ return _n;
} else if(config.joystick_type == DEVICE_MOUSE) {
- return (~mouse_status[2] & 0x03) | 0xfc;
+ int _m = emu->get_mouse_button();
+ return (~_m & 0x03) | 0xfc;
}
#endif
return 0xff;
crtc.update_blink();
#ifdef SUPPORT_PC88_JOYSTICK
+ mouse_status = emu->get_mouse_buffer();
mouse_dx += mouse_status[0];
mouse_dy += mouse_status[1];
+ emu->release_mouse_buffer(mouse_status);
#endif
}
void JOYSTICK::initialize()
{
- joy_status = emu->get_joy_buffer();
+// joy_status = emu->get_joy_buffer();
select = 0xff;
register_frame_event(this);
void JOYSTICK::event_frame()
{
if(select & 0x80) {
- d_opn->write_signal(SIG_YM2203_PORT_A, ~joy_status[(select & 0x40) >> 6], 0x3f);
+ joy_status = emu->get_joy_buffer();
+ uint8_t _n = joy_status[(select & 0x40) >> 6];
+ emu->release_joy_buffer(joy_status);
+ d_opn->write_signal(SIG_YM2203_PORT_A, ~_n, 0x3f);
}
}
void MOUSE::initialize()
{
- status = emu->get_mouse_buffer();
+// status = emu->get_mouse_buffer();
ctrlreg = 0xff;
freq = cur_freq = 0;
void MOUSE::event_frame()
{
+ status = emu->get_mouse_buffer();
dx += status[0];
if(dx > 64) {
dx = 64;
} else if(dy < -64) {
dy = -64;
}
+ emu->release_mouse_buffer(status);
update_mouse();
}
{
int val = 0;
- if(!(status[2] & 1)) val |= 0x80; // left
- if(!(status[2] & 2)) val |= 0x20; // right
- if(!(status[2] & 4)) val |= 0x40; // center
+ int32_t _button = emu->get_mouse_button();
+ if(!(_button & 1)) val |= 0x80; // left
+ if(!(_button & 2)) val |= 0x20; // right
+ if(!(_button & 4)) val |= 0x40; // center
switch(ctrlreg & 0xe0) {
case 0x00: val |= (dx >> 0) & 0x0f; break;
void PCE::initialize()
{
// get context
- joy_stat = emu->get_joy_buffer();
+// joy_stat = emu->get_joy_buffer();
// register event
register_vline_event(this);
{
uint8_t data = 0x0f;
+ joy_stat = emu->get_joy_buffer();
if(joy_high_nibble) {
if(joy_stat[index - 1] & 0x001) data &= ~0x01; // Up
if(joy_stat[index - 1] & 0x008) data &= ~0x02; // Right
if(joy_stat[index - 1] & 0x040) data &= ~0x04; // Select
if(joy_stat[index - 1] & 0x080) data &= ~0x08; // Run
}
+ emu->release_joy_buffer(joy_stat);
return data;
}
uint8_t data = 0x0f;
if(joy_second_byte) {
+ joy_stat = emu->get_joy_buffer();
if(joy_high_nibble) {
if(joy_stat[index - 1] & 0x001) data &= ~0x01; // Up
if(joy_stat[index - 1] & 0x008) data &= ~0x02; // Right
if(joy_stat[index - 1] & 0x040) data &= ~0x04; // Select
if(joy_stat[index - 1] & 0x080) data &= ~0x08; // Run
}
+ emu->release_joy_buffer(joy_stat);
} else {
if(joy_high_nibble) {
return 0x00;
} else {
+ joy_stat = emu->get_joy_buffer();
if(joy_stat[index - 1] & 0x100) data &= ~0x01; // Button #3
if(joy_stat[index - 1] & 0x200) data &= ~0x02; // Button #4
if(joy_stat[index - 1] & 0x400) data &= ~0x04; // Button #5
if(joy_stat[index - 1] & 0x800) data &= ~0x08; // Button #6
+ emu->release_joy_buffer(joy_stat);
}
}
if(!support_multi_tap) {
void JOYSTICK::initialize()
{
- joy_stat = emu->get_joy_buffer();
+// joy_stat = emu->get_joy_buffer();
// register event to update the key status
register_frame_event(this);
void JOYSTICK::event_frame()
{
- d_psg->write_signal(SIG_AY_3_891X_PORT_A, ~(joy_stat[0] & 0x1f), 0xff);
- d_psg->write_signal(SIG_AY_3_891X_PORT_B, ~(joy_stat[1] & 0x1f), 0xff);
+ joy_stat = emu->get_joy_buffer();
+ uint32_t _n[2];
+ _n[0] = joy_stat[0];
+ _n[1] = joy_stat[1];
+ emu->release_joy_buffer(joy_stat);
+ d_psg->write_signal(SIG_AY_3_891X_PORT_A, ~(_n[0] & 0x1f), 0xff);
+ d_psg->write_signal(SIG_AY_3_891X_PORT_B, ~(_n[1] & 0x1f), 0xff);
}
}
void JOYSTICK::initialize()
{
key = emu->get_key_buffer();
- joy = emu->get_joy_buffer();
+// joy = emu->get_joy_buffer();
// register event to interrupt
register_frame_event(this);
break;
case 0xfd:
val = 0;
+ joy = emu->get_joy_buffer();
if(column & 1) {
if(joy[0] & 0x40) val |= 1; // #1 select
if(joy[0] & 0x80) val |= 2; // #1 start
if(joy[1] & 0x10) val |= 4; // #2 trig1
if(joy[1] & 0x20) val |= 8; // #2 trig2
}
+ emu->release_joy_buffer(joy);
// status &= ~2;
break;
}
void KEYBOARD::initialize()
{
- joy_stat = emu->get_joy_buffer();
+// joy_stat = emu->get_joy_buffer();
}
void KEYBOARD::reset()
if(key_stat[key_map[key_no][2]]) val |= 2;
if(key_stat[key_map[key_no][1]]) val |= 4;
if(key_stat[key_map[key_no][0]]) val |= 8;
+ joy_stat = emu->get_joy_buffer();
if(key_no == 6) {
if(joy_stat[0] & 0x02) val |= 1;
if(joy_stat[0] & 0x08) val |= 2;
if(joy_stat[1] & 0x10) val |= 4;
if(joy_stat[1] & 0x20) val |= 8;
}
+ emu->release_joy_buffer(joy_stat);
return val;
case 0x40:
if(key_stat[0x11]) val |= 1; // COLOR (CTRL)
// get keyboard and joystick buffers
key = emu->get_key_buffer();
- joy = emu->get_joy_buffer();
+// joy = emu->get_joy_buffer();
ctype = 0;
}
return 0; // tutor 0x42 ???
} else if(addr == 0xe800) {
// PyuTa Jr. JOY1
+ joy = emu->get_joy_buffer();
if(joy[0] & 0x10) val |= 0x04; // JOY1 B1
if(joy[0] & 0x20) val |= 0x08; // JOY1 B2
if(joy[0] & 0x02) val |= 0x10; // JOY1 DOWN
if(joy[0] & 0x04) val |= 0x20; // JOY1 LEFT
if(joy[0] & 0x01) val |= 0x40; // JOY1 UP
if(joy[0] & 0x08) val |= 0x80; // JOY1 RIGHT
+ emu->release_joy_buffer(joy);
return val;
} else if(addr == 0xe820) {
// printer busy
return val;
} else if(addr == 0xee00) {
// PyuTa Jr. JOY2
+ joy = emu->get_joy_buffer();
if(joy[1] & 0x10) val |= 0x04; // JOY2 B1
if(joy[1] & 0x20) val |= 0x08; // JOY2 B2
if(joy[1] & 0x02) val |= 0x10; // JOY2 DOWN
if(joy[1] & 0x04) val |= 0x20; // JOY2 LEFT
if(joy[1] & 0x01) val |= 0x40; // JOY2 UP
if(joy[1] & 0x08) val |= 0x80; // JOY2 RIGHT
+ emu->release_joy_buffer(joy);
return val;
} else {
return 0xff; // pull up ?
if(key[0x4d] ) val |= 0x80; // M
return val;
case 0xec4:
+ joy = emu->get_joy_buffer();
if(key[0x30] || key[0x60] ) val |= 0x01; // 0
if(key[0xbd] ) val |= 0x02; // -
if(key[0x4f] || (joy[0] & 0x10)) val |= 0x04; // O JOY1 B1
if(key[0xbb] || (joy[0] & 0x04)) val |= 0x20; // ; JOY1 LEFT
if(key[0xbc] || (joy[0] & 0x01)) val |= 0x40; // , JOY1 UP
if(key[0xbe] || (joy[0] & 0x08)) val |= 0x80; // . JOY1 RIGHT
+ emu->release_joy_buffer(joy);
return val;
case 0xec5:
+ joy = emu->get_joy_buffer();
if(key[0xdc] || (joy[1] & 0x10)) val |= 0x04; // YEN JOY2 B1
if(key[0xc0] || (joy[1] & 0x20)) val |= 0x08; // @ JOY2 B2
if(key[0xba] || (joy[1] & 0x02)) val |= 0x10; // : JOY2 DOWN
if(key[0xdd] || (joy[1] & 0x04)) val |= 0x20; // ] JOY2 LEFT
if(key[0xbf] || (joy[1] & 0x01)) val |= 0x40; // / JOY2 UP
if(key[0xe2] || (joy[1] & 0x08)) val |= 0x80; // _ JOY2 RIGHT
+ emu->release_joy_buffer(joy);
return val;
case 0xec6:
if(key[0x11]) val |= 0x02; // EISUU -> CTRL
void KEYBOARD::initialize()
{
key_stat = emu->get_key_buffer();
- joy_stat = emu->get_joy_buffer();
+// joy_stat = emu->get_joy_buffer();
// register event to update the key status
register_frame_event(this);
}
// joystick #1
+ joy_stat = emu->get_joy_buffer();
switch(joy_stat[0] & 0x0f) {
case 0x1: status[ 9] |= 0x11; break; // u
case 0x2: status[11] |= 0x11; break; // d
}
if(joy_stat[1] & 0x10) status[12] |= 0x88; // b1
if(joy_stat[1] & 0x20) status[14] |= 0x88; // b2
-
+ emu->release_joy_buffer(joy_stat);
// $30
uint8_t total = 0;
for(int i = 0; i < 15; i++) {
void KEYBOARD::initialize()
{
key_stat = emu->get_key_buffer();
- joy_stat = emu->get_joy_buffer();
+// joy_stat = emu->get_joy_buffer();
column = 0;
break_pressed = false;
}
} else {
// joystick
+ joy_stat = emu->get_joy_buffer();
for(int i = 0; i < 12; i++) {
uint8_t map = key_map[7][i];
uint8_t stat = (map & 0x80) ? joy_stat[1] : joy_stat[0];
data |= (1 << i);
}
}
+ emu->release_joy_buffer(joy_stat);
}
d_pio->write_signal(SIG_I8255_PORT_A, ~data, 0xff);
data >>= 8;
void IO::initialize()
{
key = emu->get_key_buffer();
- joy = emu->get_joy_buffer();
+// joy = emu->get_joy_buffer();
}
void IO::reset()
case P_A:
return pa;
case P_B:
+ joy = emu->get_joy_buffer();
if(!(pa & 0x01)) {
if(joy[0] & 0x04) val &= ~0x01; // P1-L
if(joy[0] & 0x01) val &= ~0x02; // P1-U
if(joy[1] & 0x08) val &= ~0x10; // P2-R
if(joy[1] & 0x20) val &= ~0x20; // P2-TR2
}
+ emu->release_joy_buffer(joy);
if(!(pa & 0x04)) {
if(key[0x30] || key[0x60]) val &= ~0x40; // 0
if(key[0x31] || key[0x61]) val &= ~0x80; // 1
initialize_key();
caps = kana = false;
key_stat = emu->get_key_buffer();
- joy_stat = emu->get_joy_buffer();
+// joy_stat = emu->get_joy_buffer();
// initialize display
static const uint8_t color_table[16][3] = {
// bit1: ~B 0 = joystick back on
// bit0: ~F 0 = joystick forward on
{
+ joy_stat = emu->get_joy_buffer();
uint32_t stat = joy_stat[(addr & 0x100) ? 0 : 1];
+ emu->release_joy_buffer(joy_stat);
if(addr & 0x100) {
if(key_stat[0x26]) stat |= 0x01; // up
if(key_stat[0x28]) stat |= 0x02; // down
void JOYSTICK::initialize()
{
- joy_stat = emu->get_joy_buffer();
+// joy_stat = emu->get_joy_buffer();
select = 0;
// register event to update the key status
void JOYSTICK::event_frame()
{
-/// d_psg->write_signal(SIG_AY_3_891X_PORT_A, PSG14_MASK & ~(joy_stat[select] & 0x3f), 0x7f);
- d_psg->write_signal(SIG_AY_3_891X_PORT_A, ~((joy_stat[0] & 0x0f)|(joy_stat[1] & 0x0f)<<4), 0xff);
- d_memory->write_io8(select, ~((joy_stat[0] & 0x10)|(joy_stat[1] & 0x10)<<1));
+ uint32_t _n[2];
+ joy_stat = emu->get_joy_buffer();
+ _n[0] = joy_stat[0];
+ _n[1] = joy_stat[1];
+ emu->release_joy_buffer(joy_stat);
+/// d_psg->write_signal(SIG_AY_3_891X_PORT_A, PSG14_MASK & ~(_n[select] & 0x3f), 0x7f);
+ d_psg->write_signal(SIG_AY_3_891X_PORT_A, ~((_n[0] & 0x0f)|(_n[1] & 0x0f)<<4), 0xff);
+ d_memory->write_io8(select, ~((_n[0] & 0x10)|(_n[1] & 0x10)<<1));
}
#define STATE_VERSION 1
void JOYSTICK::initialize()
{
- joy_stat = emu->get_joy_buffer();
+// joy_stat = emu->get_joy_buffer();
// register event
register_frame_event(this);
#ifdef _X1TWIN
if(!vm->is_cart_inserted(0)) {
#endif
+ joy_stat = emu->get_joy_buffer();
if(joy_stat[i] & 0x01) val &= ~0x01;
if(joy_stat[i] & 0x02) val &= ~0x02;
if(joy_stat[i] & 0x04) val &= ~0x04;
if(joy_stat[i] & 0x08) val &= ~0x08;
if(joy_stat[i] & 0x10) val &= ~0x20;
if(joy_stat[i] & 0x20) val &= ~0x40;
+ emu->release_joy_buffer(joy_stat);
#ifdef _X1TWIN
}
#endif
void MOUSE::initialize()
{
- stat = emu->get_mouse_buffer();
+// stat = emu->get_mouse_buffer();
}
void MOUSE::write_signal(int id, uint32_t data, uint32_t mask)
return;
}
// Z80SIO Ch.B RTS H->L
+ stat = emu->get_mouse_buffer();
uint32_t d0 = (stat[0] >= 128 ? 0x10 : stat[0] < -128 ? 0x20 : 0) |
(stat[1] >= 128 ? 0x40 : stat[1] < -128 ? 0x80 : 0) |
((stat[2] & 1) ? 1 : 0) | ((stat[2] & 2) ? 2 : 0);
uint32_t d1 = (uint8_t)stat[0];
uint32_t d2 = (uint8_t)stat[1];
+ emu->release_mouse_buffer();
d_sio->write_signal(SIG_Z80SIO_CLEAR_CH1, 1, 1);
d_sio->write_signal(SIG_Z80SIO_RECV_CH1, d0, 0xff);
void JOYSTICK::initialize()
{
- joy_stat = emu->get_joy_buffer();
+// joy_stat = emu->get_joy_buffer();
register_frame_event(this);
}
void JOYSTICK::event_frame()
{
uint32_t val = 0x3f;
+ joy_stat = emu->get_joy_buffer();
if(joy_stat[0] & 0x01) val &= ~0x01; // up
if(joy_stat[0] & 0x02) val &= ~0x02; // dpwn
if(joy_stat[0] & 0x04) val &= ~0x04; // left
if(joy_stat[0] & 0x08) val &= ~0x08; // right
if(joy_stat[0] & 0x10) val &= ~0x10; // trigger #1
if(joy_stat[0] & 0x20) val &= ~0x20; // trigger #2
+ emu->release_joy_buffer(joy_stat);
#ifdef _USE_I8255
d_pio->write_signal(SIG_I8255_PORT_A, val, 0xff);
#else
#ifdef USE_JOYSTICK
uint32_t* get_joy_buffer()
{
+ // ToDo: Lock
return joy_status;
}
+ void release_joy_buffer(uint32_t* ptr)
+ {
+ // ToDo: Unlock
+ }
#endif
#ifdef USE_MOUSE
int32_t* get_mouse_buffer()
{
+ // ToDo: Lock
return mouse_status;
}
+ void release_mouse_buffer(int32_t* ptr)
+ {
+ // ToDo: Unlock
+ }
+ int32_t get_mouse_button()
+ {
+ return mouse_status[2];
+ }
#endif
#ifdef USE_AUTO_KEY
bool now_auto_key;