2 FUJITSU FM Towns Emulator 'eFMTowns'
4 Author : Kyuma.Ohta <whatisthis.sowhat _at_ gmail.com>
6 History : 2020.01.28 Initial from FM7.
7 [ Towns Joystick ports]
13 #include "../device.h"
15 #define SIG_JOYPORT_CH0 0
16 #define SIG_JOYPORT_CH1 (65536 * 256)
17 #define SIG_JOYPORT_DATA 256
18 #define SIG_JOYPORT_COM 512
19 #define SIG_JOYPORT_MASK 768
21 #define SIG_JOYPORT_TYPE_NULL 0
22 #define SIG_JOYPORT_TYPE_2BUTTONS 1
23 #define SIG_JOYPORT_TYPE_6BUTTONS 2
24 #define SIG_JOYPORT_TYPE_ANALOG 3 /* ToDo: For CYBER STICK */
25 #define SIG_JOYPORT_TYPE_MOUSE 4
26 #define SIG_JOYPORT_TYPE_TWIN_2B_0 5 /* ToDo: For RIBBLE RABBLE */
27 #define SIG_JOYPORT_TYPE_TWIN_2B_1 6 /* ToDo: For RIBBLE RABBLE */
28 #define SIG_JOYPORT_CONNECT 7 /* ToDo: RESET */
30 // MSX RELATED PORT CONFIGURATION
31 // https://www.msx.org/wiki/General_Purpose_port
32 #define LINE_JOYPORT_UP (1 << 0) /* IN 1 */
33 #define LINE_JOYPORT_DOWN (1 << 1) /* IN 2 */
34 #define LINE_JOYPORT_LEFT (1 << 2) /* IN 3 */
35 #define LINE_JOYPORT_RIGHT (1 << 3) /* IN 4 */
36 #define LINE_JOYPORT_A (1 << 4) /* IN 6 */
37 #define LINE_JOYPORT_B (1 << 5) /* IN 7 */
38 #define LINE_JOYPORT_TRIGGER (1 << 6) /* OUT 8 */
39 #define LINE_JOYPORT_DUMMY (1 << 7) /* DUMMY */
40 // Belows are dummy define
41 #define LINE_JOYPORT_POW_PLUS (1 << 8) /* +5V PIN 5*/
42 #define LINE_JOYPORT_POW_GND (1 << 9) /* GND PIN 8*/
45 class JOYSTICK : public DEVICE
51 bool emulate_mouse[2];
56 uint32_t connected_type[2];
58 void set_emulate_mouse();
59 void __FASTCALL send_signals(int ch, uint32_t data);
62 JOYSTICK(VM_TEMPLATE* parent_vm, EMU_TEMPLATE* parent_emu) : DEVICE(parent_vm, parent_emu)
67 connected_type[0] = SIG_JOYPORT_CH0 | SIG_JOYPORT_TYPE_NULL;
68 connected_type[1] = SIG_JOYPORT_CH1 | SIG_JOYPORT_TYPE_NULL;
70 set_device_name(_T("FM-Towns PAD Port"));
75 void initialize(void);
79 void __FASTCALL write_io8(uint32_t addr, uint32_t data);
80 uint32_t __FASTCALL read_io8(uint32_t addr);
81 void __FASTCALL write_signal(int id, uint32_t data, uint32_t mask);
82 uint32_t __FASTCALL read_signal(int id);
85 bool process_state(FILEIO* state_fio, bool loading);
88 void set_context_joypad(int num, DEVICE* dev)
90 if((d_joypad[num] == nullptr) && (dev != nullptr)) {
94 void set_context_mouse(DEVICE* dev)
96 if((d_mouse == nullptr) && (dev != nullptr)) {