trunk/src/emu/cpu/amis2000/amis2000.c
| r243594 | r243595 | |
| 6 | 6 | Overall functionality is similar to (and probably derived from) NEC uCOM-4. |
| 7 | 7 | |
| 8 | 8 | References: |
| 9 | | - AMI MOS Products Catalog 1979/1980 |
| 9 | - AMI MOS Products Catalog Winter 1979 |
| 10 | 10 | - AMI S2000 Programming Manual (rev. 2) |
| 11 | 11 | |
| 12 | 12 | TODO: |
| r243594 | r243595 | |
| 27 | 27 | // S2000 is the most basic one, 64 nibbles internal RAM and 1KB internal ROM |
| 28 | 28 | // S2150 increased RAM to 80 nibbles and ROM to 1.5KB |
| 29 | 29 | // high-voltage output versions of these chips (S2000A and S2150A) are identical overall |
| 30 | | const device_type AMI_S2000 = &device_creator<amis2000_cpu_device>; |
| 31 | | const device_type AMI_S2150 = &device_creator<amis2150_cpu_device>; |
| 30 | const device_type AMI_S2000 = &device_creator<amis2000_device>; |
| 31 | const device_type AMI_S2150 = &device_creator<amis2150_device>; |
| 32 | 32 | |
| 33 | | // S2152 is an extension to S2150, removing the K pins and adding a better timer |
| 34 | | const device_type AMI_S2152 = &device_creator<amis2152_cpu_device>; |
| 35 | 33 | |
| 36 | | |
| 37 | 34 | // internal memory maps |
| 38 | | static ADDRESS_MAP_START(program_1k, AS_PROGRAM, 8, amis2000_base_device) |
| 35 | static ADDRESS_MAP_START(program_1k, AS_PROGRAM, 8, amis2000_device) |
| 39 | 36 | AM_RANGE(0x0000, 0x03ff) AM_ROM |
| 40 | 37 | ADDRESS_MAP_END |
| 41 | 38 | |
| 42 | | static ADDRESS_MAP_START(program_1_5k, AS_PROGRAM, 8, amis2000_base_device) |
| 39 | static ADDRESS_MAP_START(program_1_5k, AS_PROGRAM, 8, amis2000_device) |
| 43 | 40 | AM_RANGE(0x0000, 0x03ff) AM_ROM |
| 44 | 41 | AM_RANGE(0x0400, 0x05ff) AM_NOP // 0x00 |
| 45 | 42 | AM_RANGE(0x0600, 0x07ff) AM_ROM |
| 46 | 43 | ADDRESS_MAP_END |
| 47 | 44 | |
| 48 | 45 | |
| 49 | | static ADDRESS_MAP_START(data_64x4, AS_DATA, 8, amis2000_base_device) |
| 46 | static ADDRESS_MAP_START(data_64x4, AS_DATA, 8, amis2000_device) |
| 50 | 47 | AM_RANGE(0x00, 0x3f) AM_RAM |
| 51 | 48 | ADDRESS_MAP_END |
| 52 | 49 | |
| 53 | | static ADDRESS_MAP_START(data_80x4, AS_DATA, 8, amis2000_base_device) |
| 50 | static ADDRESS_MAP_START(data_80x4, AS_DATA, 8, amis2000_device) |
| 54 | 51 | AM_RANGE(0x00, 0x3f) AM_RAM |
| 55 | 52 | AM_RANGE(0x40, 0x4f) AM_RAM |
| 56 | 53 | ADDRESS_MAP_END |
| 57 | 54 | |
| 58 | 55 | |
| 59 | 56 | // device definitions |
| 60 | | amis2000_cpu_device::amis2000_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 61 | | : amis2000_base_device(mconfig, AMI_S2000, "AMI S2000", tag, owner, clock, 2, 10, 3, 13, ADDRESS_MAP_NAME(program_1k), 6, ADDRESS_MAP_NAME(data_64x4), "amis2000", __FILE__) |
| 62 | | { } |
| 57 | amis2000_device::amis2000_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 58 | : cpu_device(mconfig, AMI_S2000, "AMI S2000", tag, owner, clock, "amis2000", __FILE__), |
| 59 | m_program_config("program", ENDIANNESS_BIG, 8, 13, 0, ADDRESS_MAP_NAME(program_1k)), |
| 60 | m_data_config("data", ENDIANNESS_BIG, 8, 6, 0, ADDRESS_MAP_NAME(data_64x4)), |
| 61 | m_bu_bits(2), |
| 62 | m_callstack_bits(10), |
| 63 | m_callstack_depth(3), |
| 64 | m_read_k(*this), |
| 65 | m_read_i(*this), |
| 66 | m_read_d(*this), |
| 67 | m_write_d(*this), |
| 68 | m_write_a(*this) |
| 69 | { |
| 70 | } |
| 63 | 71 | |
| 64 | | amis2150_cpu_device::amis2150_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 65 | | : amis2000_base_device(mconfig, AMI_S2150, "AMI S2150", tag, owner, clock, 3, 11, 3, 13, ADDRESS_MAP_NAME(program_1_5k), 7, ADDRESS_MAP_NAME(data_80x4), "amis2150", __FILE__) |
| 66 | | { } |
| 72 | amis2000_device::amis2000_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT8 bu_bits, UINT8 callstack_bits, UINT8 callstack_depth, int prgwidth, address_map_constructor program, int datawidth, address_map_constructor data, const char *shortname, const char *source) |
| 73 | : cpu_device(mconfig, type, name, tag, owner, clock, shortname, source), |
| 74 | m_program_config("program", ENDIANNESS_BIG, 8, prgwidth, 0, program), |
| 75 | m_data_config("data", ENDIANNESS_BIG, 8, datawidth, 0, data), |
| 76 | m_bu_bits(bu_bits), |
| 77 | m_callstack_bits(callstack_bits), |
| 78 | m_callstack_depth(callstack_depth), |
| 79 | m_read_k(*this), |
| 80 | m_read_i(*this), |
| 81 | m_read_d(*this), |
| 82 | m_write_d(*this), |
| 83 | m_write_a(*this) |
| 84 | { |
| 85 | } |
| 67 | 86 | |
| 68 | | amis2152_cpu_device::amis2152_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 69 | | : amis2000_base_device(mconfig, AMI_S2152, "AMI S2152", tag, owner, clock, 3, 11, 3, 13, ADDRESS_MAP_NAME(program_1_5k), 7, ADDRESS_MAP_NAME(data_80x4), "amis2152", __FILE__) |
| 70 | | { } |
| 87 | amis2150_device::amis2150_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 88 | : amis2000_device(mconfig, AMI_S2150, "AMI S2150", tag, owner, clock, 3, 11, 3, 13, ADDRESS_MAP_NAME(program_1_5k), 7, ADDRESS_MAP_NAME(data_80x4), "amis2150", __FILE__) |
| 89 | { |
| 90 | } |
| 71 | 91 | |
| 72 | 92 | |
| 73 | | |
| 74 | 93 | // disasm |
| 75 | | void amis2000_base_device::state_string_export(const device_state_entry &entry, astring &string) |
| 94 | void amis2000_device::state_string_export(const device_state_entry &entry, astring &string) |
| 76 | 95 | { |
| 77 | 96 | switch (entry.index()) |
| 78 | 97 | { |
| r243594 | r243595 | |
| 91 | 110 | } |
| 92 | 111 | } |
| 93 | 112 | |
| 94 | | offs_t amis2000_base_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) |
| 113 | offs_t amis2000_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) |
| 95 | 114 | { |
| 96 | 115 | extern CPU_DISASSEMBLE(amis2000); |
| 97 | 116 | return CPU_DISASSEMBLE_NAME(amis2000)(this, buffer, pc, oprom, opram, options); |
| r243594 | r243595 | |
| 109 | 128 | S2000_ACC, S2000_E, S2000_CY |
| 110 | 129 | }; |
| 111 | 130 | |
| 112 | | void amis2000_base_device::device_start() |
| 131 | void amis2000_device::device_start() |
| 113 | 132 | { |
| 114 | 133 | m_program = &space(AS_PROGRAM); |
| 115 | 134 | m_data = &space(AS_DATA); |
| r243594 | r243595 | |
| 119 | 138 | m_read_d.resolve_safe(0); |
| 120 | 139 | m_write_d.resolve_safe(); |
| 121 | 140 | m_write_a.resolve_safe(); |
| 122 | | m_write_f.resolve_safe(); |
| 123 | 141 | |
| 124 | 142 | m_bu_mask = (1 << m_bu_bits) - 1; |
| 125 | 143 | m_callstack_mask = (1 << m_callstack_bits) - 1; |
| r243594 | r243595 | |
| 179 | 197 | } |
| 180 | 198 | |
| 181 | 199 | |
| 182 | | void amis2152_cpu_device::device_start() |
| 183 | | { |
| 184 | | amis2000_base_device::device_start(); |
| 185 | 200 | |
| 186 | | m_d2f_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(amis2152_cpu_device::d2f_timer_cb), this)); |
| 187 | | |
| 188 | | // zerofill |
| 189 | | m_d2f_latch = 0; |
| 190 | | m_fout_state = 0; |
| 191 | | |
| 192 | | // register for savestates |
| 193 | | save_item(NAME(m_d2f_latch)); |
| 194 | | save_item(NAME(m_fout_state)); |
| 195 | | } |
| 196 | | |
| 197 | | |
| 198 | | |
| 199 | 201 | //------------------------------------------------- |
| 200 | 202 | // device_reset - device-specific reset |
| 201 | 203 | //------------------------------------------------- |
| 202 | 204 | |
| 203 | | void amis2000_base_device::device_reset() |
| 205 | void amis2000_device::device_reset() |
| 204 | 206 | { |
| 205 | 207 | m_pc = 0; |
| 206 | 208 | m_op = 0; |
| 207 | 209 | m_skip = false; |
| 208 | 210 | |
| 209 | 211 | // clear i/o |
| 210 | | m_a = 0x1fff; |
| 211 | | m_write_a(0, m_a, 0xffff); |
| 212 | 212 | m_d_polarity = 0; |
| 213 | | m_d = 0; |
| 214 | | d_latch_out(false); |
| 213 | m_d = 0; d_latch_out(false); |
| 214 | m_a = 0; m_write_a(0, 0, 0xffff); |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | |
| 218 | | void amis2152_cpu_device::device_reset() |
| 219 | | { |
| 220 | | amis2000_base_device::device_reset(); |
| 221 | 218 | |
| 222 | | // start d2f timer |
| 223 | | m_write_f(0); |
| 224 | | d2f_timer_clock(); |
| 225 | | } |
| 226 | | |
| 227 | | |
| 228 | | |
| 229 | 219 | //------------------------------------------------- |
| 230 | 220 | // execute |
| 231 | 221 | //------------------------------------------------- |
| 232 | 222 | |
| 233 | | void amis2000_base_device::execute_run() |
| 223 | void amis2000_device::execute_run() |
| 234 | 224 | { |
| 235 | 225 | while (m_icount > 0) |
| 236 | 226 | { |
trunk/src/emu/cpu/amis2000/amis2000.h
| r243594 | r243595 | |
| 14 | 14 | |
| 15 | 15 | // generic input pins (4 bits each) |
| 16 | 16 | #define MCFG_AMI_S2000_READ_K_CB(_devcb) \ |
| 17 | | amis2000_base_device::set_read_k_callback(*device, DEVCB_##_devcb); |
| 17 | amis2000_device::set_read_k_callback(*device, DEVCB_##_devcb); |
| 18 | 18 | |
| 19 | 19 | #define MCFG_AMI_S2000_READ_I_CB(_devcb) \ |
| 20 | | amis2000_base_device::set_read_i_callback(*device, DEVCB_##_devcb); |
| 20 | amis2000_device::set_read_i_callback(*device, DEVCB_##_devcb); |
| 21 | 21 | |
| 22 | 22 | // 8-bit external databus coupled as input/output pins |
| 23 | 23 | #define MCFG_AMI_S2000_READ_D_CB(_devcb) \ |
| 24 | | amis2000_base_device::set_read_d_callback(*device, DEVCB_##_devcb); |
| 24 | amis2000_device::set_read_d_callback(*device, DEVCB_##_devcb); |
| 25 | 25 | |
| 26 | 26 | #define MCFG_AMI_S2000_WRITE_D_CB(_devcb) \ |
| 27 | | amis2000_base_device::set_write_d_callback(*device, DEVCB_##_devcb); |
| 27 | amis2000_device::set_write_d_callback(*device, DEVCB_##_devcb); |
| 28 | 28 | |
| 29 | 29 | // 13-bit external addressbus coupled as output pins |
| 30 | 30 | #define MCFG_AMI_S2000_WRITE_A_CB(_devcb) \ |
| 31 | | amis2000_base_device::set_write_a_callback(*device, DEVCB_##_devcb); |
| 31 | amis2000_device::set_write_a_callback(*device, DEVCB_##_devcb); |
| 32 | 32 | |
| 33 | | // F_out pin (only for S2152) |
| 34 | | #define MCFG_AMI_S2152_FOUT_CB(_devcb) \ |
| 35 | | amis2000_base_device::set_write_f_callback(*device, DEVCB_##_devcb); |
| 36 | 33 | |
| 37 | | |
| 38 | | class amis2000_base_device : public cpu_device |
| 34 | class amis2000_device : public cpu_device |
| 39 | 35 | { |
| 40 | 36 | public: |
| 41 | 37 | // construction/destruction |
| 42 | | amis2000_base_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT8 bu_bits, UINT8 callstack_bits, UINT8 callstack_depth, int prgwidth, address_map_constructor program, int datawidth, address_map_constructor data, const char *shortname, const char *source) |
| 43 | | : cpu_device(mconfig, type, name, tag, owner, clock, shortname, source) |
| 44 | | , m_program_config("program", ENDIANNESS_BIG, 8, prgwidth, 0, program) |
| 45 | | , m_data_config("data", ENDIANNESS_BIG, 8, datawidth, 0, data) |
| 46 | | , m_bu_bits(bu_bits) |
| 47 | | , m_callstack_bits(callstack_bits) |
| 48 | | , m_callstack_depth(callstack_depth) |
| 49 | | , m_read_k(*this) |
| 50 | | , m_read_i(*this) |
| 51 | | , m_read_d(*this) |
| 52 | | , m_write_d(*this) |
| 53 | | , m_write_a(*this) |
| 54 | | , m_write_f(*this) |
| 55 | | { } |
| 38 | amis2000_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 39 | amis2000_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT8 bu_bits, UINT8 callstack_bits, UINT8 callstack_depth, int prgwidth, address_map_constructor program, int datawidth, address_map_constructor data, const char *shortname, const char *source); |
| 56 | 40 | |
| 57 | 41 | // static configuration helpers |
| 58 | | template<class _Object> static devcb_base &set_read_k_callback(device_t &device, _Object object) { return downcast<amis2000_base_device &>(device).m_read_k.set_callback(object); } |
| 59 | | template<class _Object> static devcb_base &set_read_i_callback(device_t &device, _Object object) { return downcast<amis2000_base_device &>(device).m_read_i.set_callback(object); } |
| 60 | | template<class _Object> static devcb_base &set_read_d_callback(device_t &device, _Object object) { return downcast<amis2000_base_device &>(device).m_read_d.set_callback(object); } |
| 61 | | template<class _Object> static devcb_base &set_write_d_callback(device_t &device, _Object object) { return downcast<amis2000_base_device &>(device).m_write_d.set_callback(object); } |
| 62 | | template<class _Object> static devcb_base &set_write_a_callback(device_t &device, _Object object) { return downcast<amis2000_base_device &>(device).m_write_a.set_callback(object); } |
| 63 | | template<class _Object> static devcb_base &set_write_f_callback(device_t &device, _Object object) { return downcast<amis2000_base_device &>(device).m_write_f.set_callback(object); } |
| 42 | template<class _Object> static devcb_base &set_read_k_callback(device_t &device, _Object object) { return downcast<amis2000_device &>(device).m_read_k.set_callback(object); } |
| 43 | template<class _Object> static devcb_base &set_read_i_callback(device_t &device, _Object object) { return downcast<amis2000_device &>(device).m_read_i.set_callback(object); } |
| 44 | template<class _Object> static devcb_base &set_read_d_callback(device_t &device, _Object object) { return downcast<amis2000_device &>(device).m_read_d.set_callback(object); } |
| 45 | template<class _Object> static devcb_base &set_write_d_callback(device_t &device, _Object object) { return downcast<amis2000_device &>(device).m_write_d.set_callback(object); } |
| 46 | template<class _Object> static devcb_base &set_write_a_callback(device_t &device, _Object object) { return downcast<amis2000_device &>(device).m_write_a.set_callback(object); } |
| 64 | 47 | |
| 65 | 48 | protected: |
| 66 | 49 | // device-level overrides |
| r243594 | r243595 | |
| 120 | 103 | devcb_read8 m_read_d; |
| 121 | 104 | devcb_write8 m_write_d; |
| 122 | 105 | devcb_write16 m_write_a; |
| 123 | | devcb_write_line m_write_f; |
| 124 | 106 | |
| 125 | 107 | // misc internal helpers |
| 126 | 108 | UINT8 ram_r(); |
| r243594 | r243595 | |
| 130 | 112 | void d_latch_out(bool active); |
| 131 | 113 | |
| 132 | 114 | // opcode handlers |
| 133 | | virtual void op_lai(); |
| 134 | | virtual void op_lab(); |
| 135 | | virtual void op_lae(); |
| 136 | | virtual void op_xab(); |
| 137 | | virtual void op_xabu(); |
| 138 | | virtual void op_xae(); |
| 139 | | virtual void op_lbe(); |
| 140 | | virtual void op_lbep(); |
| 141 | | virtual void op_lbz(); |
| 142 | | virtual void op_lbf(); |
| 115 | void op_lai(); |
| 116 | void op_lab(); |
| 117 | void op_lae(); |
| 118 | void op_xab(); |
| 119 | void op_xabu(); |
| 120 | void op_xae(); |
| 121 | void op_lbe(); |
| 122 | void op_lbep(); |
| 123 | void op_lbz(); |
| 124 | void op_lbf(); |
| 143 | 125 | |
| 144 | | virtual void op_lam(); |
| 145 | | virtual void op_xc(); |
| 146 | | virtual void op_xci(); |
| 147 | | virtual void op_xcd(); |
| 148 | | virtual void op_stm(); |
| 149 | | virtual void op_rsm(); |
| 126 | void op_lam(); |
| 127 | void op_xc(); |
| 128 | void op_xci(); |
| 129 | void op_xcd(); |
| 130 | void op_stm(); |
| 131 | void op_rsm(); |
| 150 | 132 | |
| 151 | | virtual void op_inp(); |
| 152 | | virtual void op_out(); |
| 153 | | virtual void op_disb(); |
| 154 | | virtual void op_disn(); |
| 155 | | virtual void op_mvs(); |
| 156 | | virtual void op_psh(); |
| 157 | | virtual void op_psl(); |
| 158 | | virtual void op_eur(); |
| 133 | void op_inp(); |
| 134 | void op_out(); |
| 135 | void op_disb(); |
| 136 | void op_disn(); |
| 137 | void op_mvs(); |
| 138 | void op_psh(); |
| 139 | void op_psl(); |
| 140 | void op_eur(); |
| 159 | 141 | |
| 160 | | virtual void op_pp(); |
| 161 | | virtual void op_jmp(); |
| 162 | | virtual void op_jms(); |
| 163 | | virtual void op_rt(); |
| 164 | | virtual void op_rts(); |
| 165 | | virtual void op_nop(); |
| 166 | | virtual void op_halt(); |
| 142 | void op_pp(); |
| 143 | void op_jmp(); |
| 144 | void op_jms(); |
| 145 | void op_rt(); |
| 146 | void op_rts(); |
| 147 | void op_nop(); |
| 148 | void op_halt(); |
| 167 | 149 | |
| 168 | | virtual void op_szc(); |
| 169 | | virtual void op_szm(); |
| 170 | | virtual void op_szi(); |
| 171 | | virtual void op_szk(); |
| 172 | | virtual void op_sbe(); |
| 173 | | virtual void op_sam(); |
| 174 | | virtual void op_sos(); |
| 175 | | virtual void op_tf1(); |
| 176 | | virtual void op_tf2(); |
| 150 | void op_szc(); |
| 151 | void op_szm(); |
| 152 | void op_szi(); |
| 153 | void op_szk(); |
| 154 | void op_sbe(); |
| 155 | void op_sam(); |
| 156 | void op_sos(); |
| 157 | void op_tf1(); |
| 158 | void op_tf2(); |
| 177 | 159 | |
| 178 | | virtual void op_adcs(); |
| 179 | | virtual void op_adis(); |
| 180 | | virtual void op_add(); |
| 181 | | virtual void op_and(); |
| 182 | | virtual void op_xor(); |
| 183 | | virtual void op_stc(); |
| 184 | | virtual void op_rsc(); |
| 185 | | virtual void op_cma(); |
| 186 | | virtual void op_sf1(); |
| 187 | | virtual void op_rf1(); |
| 188 | | virtual void op_sf2(); |
| 189 | | virtual void op_rf2(); |
| 160 | void op_adcs(); |
| 161 | void op_adis(); |
| 162 | void op_add(); |
| 163 | void op_and(); |
| 164 | void op_xor(); |
| 165 | void op_stc(); |
| 166 | void op_rsc(); |
| 167 | void op_cma(); |
| 168 | void op_sf1(); |
| 169 | void op_rf1(); |
| 170 | void op_sf2(); |
| 171 | void op_rf2(); |
| 190 | 172 | }; |
| 191 | 173 | |
| 192 | 174 | |
| 193 | | class amis2000_cpu_device : public amis2000_base_device |
| 175 | class amis2150_device : public amis2000_device |
| 194 | 176 | { |
| 195 | 177 | public: |
| 196 | | amis2000_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 178 | amis2150_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 197 | 179 | }; |
| 198 | 180 | |
| 199 | 181 | |
| 200 | | class amis2150_cpu_device : public amis2000_base_device |
| 201 | | { |
| 202 | | public: |
| 203 | | amis2150_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 204 | | }; |
| 205 | 182 | |
| 206 | | |
| 207 | | class amis2152_cpu_device : public amis2000_base_device |
| 208 | | { |
| 209 | | public: |
| 210 | | amis2152_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 211 | | |
| 212 | | protected: |
| 213 | | // device-level overrides |
| 214 | | virtual void device_start(); |
| 215 | | virtual void device_reset(); |
| 216 | | |
| 217 | | // digital-to-frequency converter |
| 218 | | UINT8 m_d2f_latch; |
| 219 | | emu_timer *m_d2f_timer; |
| 220 | | int m_fout_state; |
| 221 | | |
| 222 | | void d2f_timer_clock(); |
| 223 | | TIMER_CALLBACK_MEMBER(d2f_timer_cb); |
| 224 | | |
| 225 | | // opcode handlers |
| 226 | | virtual void op_szk(); |
| 227 | | }; |
| 228 | | |
| 229 | | |
| 230 | | |
| 231 | 183 | extern const device_type AMI_S2000; |
| 232 | 184 | extern const device_type AMI_S2150; |
| 233 | | extern const device_type AMI_S2152; |
| 234 | 185 | |
| 235 | 186 | |
| 236 | 187 | #endif /* _AMIS2000_H_ */ |
trunk/src/emu/cpu/amis2000/amis2000op.inc
| r243594 | r243595 | |
| 2 | 2 | |
| 3 | 3 | // internal helpers |
| 4 | 4 | |
| 5 | | inline UINT8 amis2000_base_device::ram_r() |
| 5 | inline UINT8 amis2000_device::ram_r() |
| 6 | 6 | { |
| 7 | 7 | UINT16 address = m_bu << 4 | m_bl; |
| 8 | 8 | return m_data->read_byte(address) & 0xf; |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | | inline void amis2000_base_device::ram_w(UINT8 data) |
| 11 | inline void amis2000_device::ram_w(UINT8 data) |
| 12 | 12 | { |
| 13 | 13 | UINT16 address = m_bu << 4 | m_bl; |
| 14 | 14 | m_data->write_byte(address, data & 0xf); |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | | void amis2000_base_device::pop_callstack() |
| 17 | void amis2000_device::pop_callstack() |
| 18 | 18 | { |
| 19 | 19 | m_pc = (m_pc & ~m_callstack_mask) | (m_callstack[0] & m_callstack_mask); |
| 20 | 20 | for (int i = 0; i < m_callstack_depth-1; i++) |
| 21 | 21 | m_callstack[i] = m_callstack[i+1]; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | | void amis2000_base_device::push_callstack() |
| 24 | void amis2000_device::push_callstack() |
| 25 | 25 | { |
| 26 | 26 | for (int i = m_callstack_depth-1; i >= 1; i--) |
| 27 | 27 | m_callstack[i] = m_callstack[i-1]; |
| 28 | 28 | m_callstack[0] = m_pc & m_callstack_mask; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | | void amis2000_base_device::d_latch_out(bool active) |
| 31 | void amis2000_device::d_latch_out(bool active) |
| 32 | 32 | { |
| 33 | 33 | m_write_d(0, active ? (m_d ^ m_d_polarity) : 0, 0xff); |
| 34 | 34 | m_d_active = active; |
| r243594 | r243595 | |
| 37 | 37 | |
| 38 | 38 | // Register Instructions |
| 39 | 39 | |
| 40 | | void amis2000_base_device::op_lai() |
| 40 | void amis2000_device::op_lai() |
| 41 | 41 | { |
| 42 | 42 | // LAI X: load ACC with X, select I and K inputs |
| 43 | 43 | // note: only execute the first one in a sequence of LAI |
| r243594 | r243595 | |
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | | void amis2000_base_device::op_lab() |
| 52 | void amis2000_device::op_lab() |
| 53 | 53 | { |
| 54 | 54 | // LAB: load ACC with BL |
| 55 | 55 | m_acc = m_bl; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | | void amis2000_base_device::op_lae() |
| 58 | void amis2000_device::op_lae() |
| 59 | 59 | { |
| 60 | 60 | // LAE: load ACC with E |
| 61 | 61 | m_acc = m_e; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | | void amis2000_base_device::op_xab() |
| 64 | void amis2000_device::op_xab() |
| 65 | 65 | { |
| 66 | 66 | // XAB: exchange ACC with BL |
| 67 | 67 | UINT8 old_acc = m_acc; |
| r243594 | r243595 | |
| 69 | 69 | m_bl = old_acc; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | | void amis2000_base_device::op_xabu() |
| 72 | void amis2000_device::op_xabu() |
| 73 | 73 | { |
| 74 | 74 | // XABU: exchange ACC with BU |
| 75 | 75 | UINT8 old_acc = m_acc; |
| r243594 | r243595 | |
| 77 | 77 | m_bu = old_acc & m_bu_mask; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | | void amis2000_base_device::op_xae() |
| 80 | void amis2000_device::op_xae() |
| 81 | 81 | { |
| 82 | 82 | // XAE: exchange ACC with E |
| 83 | 83 | UINT8 old_acc = m_acc; |
| r243594 | r243595 | |
| 85 | 85 | m_e = old_acc; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | | void amis2000_base_device::op_lbe() |
| 88 | void amis2000_device::op_lbe() |
| 89 | 89 | { |
| 90 | 90 | // LBE Y: load BU with Y, load BL with E |
| 91 | 91 | // note: only execute the first one in a sequence of LB* |
| r243594 | r243595 | |
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | | void amis2000_base_device::op_lbep() |
| 100 | void amis2000_device::op_lbep() |
| 101 | 101 | { |
| 102 | 102 | // LBEP Y: load BU with Y, load BL with E+1 |
| 103 | 103 | // note: only execute the first one in a sequence of LB* |
| r243594 | r243595 | |
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | | void amis2000_base_device::op_lbz() |
| 112 | void amis2000_device::op_lbz() |
| 113 | 113 | { |
| 114 | 114 | // LBZ Y: load BU with Y, load BL with 0 |
| 115 | 115 | // note: only execute the first one in a sequence of LB* |
| r243594 | r243595 | |
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | | void amis2000_base_device::op_lbf() |
| 124 | void amis2000_device::op_lbf() |
| 125 | 125 | { |
| 126 | 126 | // LBF Y: load BU with Y, load BL with 15 |
| 127 | 127 | // note: only execute the first one in a sequence of LB* |
| r243594 | r243595 | |
| 136 | 136 | |
| 137 | 137 | // RAM Instructions |
| 138 | 138 | |
| 139 | | void amis2000_base_device::op_lam() |
| 139 | void amis2000_device::op_lam() |
| 140 | 140 | { |
| 141 | 141 | // LAM _Y: load ACC with RAM, xor BU with _Y |
| 142 | 142 | m_acc = ram_r(); |
| r243594 | r243595 | |
| 144 | 144 | m_bu ^= (param & m_bu_mask); |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | | void amis2000_base_device::op_xc() |
| 147 | void amis2000_device::op_xc() |
| 148 | 148 | { |
| 149 | 149 | // XC _Y: exchange ACC with RAM, xor BU with _Y |
| 150 | 150 | UINT8 old_acc = m_acc; |
| r243594 | r243595 | |
| 154 | 154 | m_bu ^= (param & m_bu_mask); |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | | void amis2000_base_device::op_xci() |
| 157 | void amis2000_device::op_xci() |
| 158 | 158 | { |
| 159 | 159 | // XCI _Y: exchange ACC with RAM, increment BL(skip next on carry), xor BU with _Y |
| 160 | 160 | op_xc(); |
| r243594 | r243595 | |
| 162 | 162 | m_skip = (m_bl == 0); |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | | void amis2000_base_device::op_xcd() |
| 165 | void amis2000_device::op_xcd() |
| 166 | 166 | { |
| 167 | 167 | // XCD _Y: exchange ACC with RAM, decrement BL(skip next on carry), xor BU with _Y |
| 168 | 168 | op_xc(); |
| r243594 | r243595 | |
| 170 | 170 | m_skip = (m_bl == 0xf); |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | | void amis2000_base_device::op_stm() |
| 173 | void amis2000_device::op_stm() |
| 174 | 174 | { |
| 175 | 175 | // STM Z: set RAM bit Z |
| 176 | 176 | UINT8 param = 1 << (m_op & 0x03); |
| 177 | 177 | ram_w(ram_r() | param); |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | | void amis2000_base_device::op_rsm() |
| 180 | void amis2000_device::op_rsm() |
| 181 | 181 | { |
| 182 | 182 | // RSM Z: reset RAM bit Z |
| 183 | 183 | UINT8 param = 1 << (m_op & 0x03); |
| r243594 | r243595 | |
| 187 | 187 | |
| 188 | 188 | // Input/Output Instructions |
| 189 | 189 | |
| 190 | | void amis2000_base_device::op_inp() |
| 190 | void amis2000_device::op_inp() |
| 191 | 191 | { |
| 192 | 192 | // INP: input D-pins to ACC and RAM |
| 193 | 193 | UINT8 in = m_d_active ? m_d : m_read_d(0, 0xff); |
| r243594 | r243595 | |
| 195 | 195 | ram_w(in >> 4 & 0xf); |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | | void amis2000_base_device::op_out() |
| 198 | void amis2000_device::op_out() |
| 199 | 199 | { |
| 200 | 200 | // OUT: pulse output ACC and RAM to D-pins |
| 201 | 201 | logerror("%s unknown opcode $%02X at $%04X\n", tag(), m_op, m_pc); |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | | void amis2000_base_device::op_disb() |
| 204 | void amis2000_device::op_disb() |
| 205 | 205 | { |
| 206 | 206 | // DISB: set D-latch to ACC and RAM directly |
| 207 | 207 | m_d = m_acc | ram_r() << 4; |
| 208 | 208 | d_latch_out(true); |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | | void amis2000_base_device::op_disn() |
| 211 | void amis2000_device::op_disn() |
| 212 | 212 | { |
| 213 | 213 | // DISN: set D-latch to ACC+carry via on-die segment decoder |
| 214 | 214 | static const UINT8 lut_segment_decoder[0x10] = |
| r243594 | r243595 | |
| 220 | 220 | d_latch_out(true); |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | | void amis2000_base_device::op_mvs() |
| 223 | void amis2000_device::op_mvs() |
| 224 | 224 | { |
| 225 | 225 | // MVS: output master strobe latch to A-pins |
| 226 | 226 | d_latch_out(false); |
| 227 | 227 | m_write_a(0, m_a, 0xffff); |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | | void amis2000_base_device::op_psh() |
| 230 | void amis2000_device::op_psh() |
| 231 | 231 | { |
| 232 | 232 | // PSH: preset high(BL) master strobe latch |
| 233 | 233 | switch (m_bl) |
| r243594 | r243595 | |
| 254 | 254 | } |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | | void amis2000_base_device::op_psl() |
| 257 | void amis2000_device::op_psl() |
| 258 | 258 | { |
| 259 | 259 | // PSL: preset low(BL) master strobe latch |
| 260 | 260 | switch (m_bl) |
| r243594 | r243595 | |
| 281 | 281 | } |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | | void amis2000_base_device::op_eur() |
| 284 | void amis2000_device::op_eur() |
| 285 | 285 | { |
| 286 | 286 | // EUR: set timer frequency(European) and D-latch polarity, via ACC |
| 287 | 287 | m_d_polarity = (m_acc & 1) ? 0x00 : 0xff; |
| r243594 | r243595 | |
| 291 | 291 | |
| 292 | 292 | // Program Control Instructions |
| 293 | 293 | |
| 294 | | void amis2000_base_device::op_pp() |
| 294 | void amis2000_device::op_pp() |
| 295 | 295 | { |
| 296 | 296 | // PP _X: prepare page/bank with _X |
| 297 | 297 | UINT8 param = ~m_op & 0x0f; |
| r243594 | r243595 | |
| 301 | 301 | m_pbr = param & 7; |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | | void amis2000_base_device::op_jmp() |
| 304 | void amis2000_device::op_jmp() |
| 305 | 305 | { |
| 306 | 306 | // JMP X: jump to X(+PP) |
| 307 | 307 | UINT16 mask = 0x3f; |
| r243594 | r243595 | |
| 316 | 316 | m_pc = (m_pc & ~mask) | param; |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | | void amis2000_base_device::op_jms() |
| 319 | void amis2000_device::op_jms() |
| 320 | 320 | { |
| 321 | 321 | // JMS X: call to X(+PP) |
| 322 | 322 | m_icount--; |
| r243594 | r243595 | |
| 328 | 328 | m_pc |= 0x3c0; |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | | void amis2000_base_device::op_rt() |
| 331 | void amis2000_device::op_rt() |
| 332 | 332 | { |
| 333 | 333 | // RT: return from subroutine |
| 334 | 334 | pop_callstack(); |
| 335 | 335 | } |
| 336 | 336 | |
| 337 | | void amis2000_base_device::op_rts() |
| 337 | void amis2000_device::op_rts() |
| 338 | 338 | { |
| 339 | 339 | // RTS: return from subroutine and skip next |
| 340 | 340 | op_rt(); |
| 341 | 341 | m_skip = true; |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | | void amis2000_base_device::op_nop() |
| 344 | void amis2000_device::op_nop() |
| 345 | 345 | { |
| 346 | 346 | // NOP: no operation |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | | void amis2000_base_device::op_halt() |
| 349 | void amis2000_device::op_halt() |
| 350 | 350 | { |
| 351 | 351 | // HALT: debugger breakpoint for devkit-use |
| 352 | 352 | logerror("%s unknown opcode $%02X at $%04X\n", tag(), m_op, m_pc); |
| r243594 | r243595 | |
| 355 | 355 | |
| 356 | 356 | // Skip Instructions |
| 357 | 357 | |
| 358 | | void amis2000_base_device::op_szc() |
| 358 | void amis2000_device::op_szc() |
| 359 | 359 | { |
| 360 | 360 | // SZC: skip next on zero(no) carry |
| 361 | 361 | m_skip = !m_carry; |
| 362 | 362 | } |
| 363 | 363 | |
| 364 | | void amis2000_base_device::op_szm() |
| 364 | void amis2000_device::op_szm() |
| 365 | 365 | { |
| 366 | 366 | // SZM Z: skip next on zero RAM bit Z |
| 367 | 367 | UINT8 param = 1 << (m_op & 0x03); |
| 368 | 368 | m_skip = !(ram_r() & param); |
| 369 | 369 | } |
| 370 | 370 | |
| 371 | | void amis2000_base_device::op_szi() |
| 371 | void amis2000_device::op_szi() |
| 372 | 372 | { |
| 373 | 373 | // SZI: skip next on I pin(s) |
| 374 | 374 | m_skip = ((~m_read_i(0, 0xff) & m_ki_mask) != 0); |
| 375 | 375 | } |
| 376 | 376 | |
| 377 | | void amis2000_base_device::op_szk() |
| 377 | void amis2000_device::op_szk() |
| 378 | 378 | { |
| 379 | 379 | // SZK: skip next on K pin(s) |
| 380 | 380 | m_skip = ((~m_read_k(0, 0xff) & m_ki_mask) != 0); |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | | void amis2000_base_device::op_sbe() |
| 383 | void amis2000_device::op_sbe() |
| 384 | 384 | { |
| 385 | 385 | // SBE: skip next on BL equals E |
| 386 | 386 | m_skip = (m_bl == m_e); |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | | void amis2000_base_device::op_sam() |
| 389 | void amis2000_device::op_sam() |
| 390 | 390 | { |
| 391 | 391 | // SAM: skip next on ACC equals RAM |
| 392 | 392 | m_skip = (m_acc == ram_r()); |
| 393 | 393 | } |
| 394 | 394 | |
| 395 | | void amis2000_base_device::op_sos() |
| 395 | void amis2000_device::op_sos() |
| 396 | 396 | { |
| 397 | 397 | // SOS: skip next on SF(timer output), clear SF |
| 398 | 398 | logerror("%s unknown opcode $%02X at $%04X\n", tag(), m_op, m_pc); |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | | void amis2000_base_device::op_tf1() |
| 401 | void amis2000_device::op_tf1() |
| 402 | 402 | { |
| 403 | 403 | // TF1: skip next on flag 1 |
| 404 | 404 | m_skip = ((m_f & 0x01) != 0); |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | | void amis2000_base_device::op_tf2() |
| 407 | void amis2000_device::op_tf2() |
| 408 | 408 | { |
| 409 | 409 | // TF2: skip next on flag 2 |
| 410 | 410 | m_skip = ((m_f & 0x02) != 0); |
| r243594 | r243595 | |
| 413 | 413 | |
| 414 | 414 | // Arithmetic and Logical Instructions |
| 415 | 415 | |
| 416 | | void amis2000_base_device::op_adcs() |
| 416 | void amis2000_device::op_adcs() |
| 417 | 417 | { |
| 418 | 418 | // ADCS: add RAM to ACC+carry, skip next on not carry |
| 419 | 419 | m_acc += ram_r() + m_carry; |
| r243594 | r243595 | |
| 422 | 422 | m_acc &= 0xf; |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | | void amis2000_base_device::op_adis() |
| 425 | void amis2000_device::op_adis() |
| 426 | 426 | { |
| 427 | 427 | // ADIS X: add X to ACC, skip next on not carry |
| 428 | 428 | UINT8 param = m_op & 0x0f; |
| r243594 | r243595 | |
| 431 | 431 | m_acc &= 0xf; |
| 432 | 432 | } |
| 433 | 433 | |
| 434 | | void amis2000_base_device::op_add() |
| 434 | void amis2000_device::op_add() |
| 435 | 435 | { |
| 436 | 436 | // ADD: add RAM to ACC |
| 437 | 437 | m_acc = (m_acc + ram_r()) & 0xf; |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | | void amis2000_base_device::op_and() |
| 440 | void amis2000_device::op_and() |
| 441 | 441 | { |
| 442 | 442 | // AND: and ACC with RAM |
| 443 | 443 | m_acc &= ram_r(); |
| 444 | 444 | } |
| 445 | 445 | |
| 446 | | void amis2000_base_device::op_xor() |
| 446 | void amis2000_device::op_xor() |
| 447 | 447 | { |
| 448 | 448 | // XOR: xor ACC with RAM |
| 449 | 449 | m_acc ^= ram_r(); |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | | void amis2000_base_device::op_stc() |
| 452 | void amis2000_device::op_stc() |
| 453 | 453 | { |
| 454 | 454 | // STC: set carry |
| 455 | 455 | m_carry = 1; |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | | void amis2000_base_device::op_rsc() |
| 458 | void amis2000_device::op_rsc() |
| 459 | 459 | { |
| 460 | 460 | // RSC: reset carry |
| 461 | 461 | m_carry = 0; |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | | void amis2000_base_device::op_cma() |
| 464 | void amis2000_device::op_cma() |
| 465 | 465 | { |
| 466 | 466 | // CMA: complement ACC |
| 467 | 467 | m_acc ^= 0xf; |
| 468 | 468 | } |
| 469 | 469 | |
| 470 | | void amis2000_base_device::op_sf1() |
| 470 | void amis2000_device::op_sf1() |
| 471 | 471 | { |
| 472 | 472 | // SF1: set flag 1 |
| 473 | 473 | m_f |= 0x01; |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | | void amis2000_base_device::op_rf1() |
| 476 | void amis2000_device::op_rf1() |
| 477 | 477 | { |
| 478 | 478 | // RF1: reset flag 1 |
| 479 | 479 | m_f &= ~0x01; |
| 480 | 480 | } |
| 481 | 481 | |
| 482 | | void amis2000_base_device::op_sf2() |
| 482 | void amis2000_device::op_sf2() |
| 483 | 483 | { |
| 484 | 484 | // SF2: set flag 2 |
| 485 | 485 | m_f |= 0x02; |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | | void amis2000_base_device::op_rf2() |
| 488 | void amis2000_device::op_rf2() |
| 489 | 489 | { |
| 490 | 490 | // RF2: reset flag 2 |
| 491 | 491 | m_f &= ~0x02; |
| 492 | 492 | } |
| 493 | | |
| 494 | | |
| 495 | | |
| 496 | | // AMI S2152 specific handlers |
| 497 | | |
| 498 | | void amis2152_cpu_device::d2f_timer_clock() |
| 499 | | { |
| 500 | | // schedule next timeout (frequency is guessed) |
| 501 | | attotime base = attotime::from_hz(unscaled_clock() / 4 / 64); |
| 502 | | m_d2f_timer->adjust(base * (0x10 - m_d2f_latch)); |
| 503 | | } |
| 504 | | |
| 505 | | TIMER_CALLBACK_MEMBER(amis2152_cpu_device::d2f_timer_cb) |
| 506 | | { |
| 507 | | m_write_f(m_fout_state); |
| 508 | | m_fout_state ^= 1; |
| 509 | | |
| 510 | | d2f_timer_clock(); |
| 511 | | } |
| 512 | | |
| 513 | | void amis2152_cpu_device::op_szk() |
| 514 | | { |
| 515 | | // instead of SZK: ???: load d2f latch with ACC(?) |
| 516 | | m_d2f_latch = m_acc; |
| 517 | | } |
trunk/src/mame/drivers/n8080.c
| r243594 | r243595 | |
| 3 | 3 | Nintendo 8080 hardware |
| 4 | 4 | |
| 5 | 5 | - Space Fever |
| 6 | | - Space Fever High Splitter (aka SF-Hisplitter) |
| 6 | - Space Fever High Splitter |
| 7 | 7 | - Space Launcher |
| 8 | 8 | - Sheriff / Bandido / Western Gun 2 |
| 9 | 9 | - Helifire |
| r243594 | r243595 | |
| 933 | 933 | GAME( 1979, spacefev, 0, spacefev, spacefev, driver_device, 0, ROT270, "Nintendo", "Space Fever (New Ver.)", GAME_SUPPORTS_SAVE ) |
| 934 | 934 | GAME( 1979, spacefevo, spacefev, spacefev, spacefev, driver_device, 0, ROT270, "Nintendo", "Space Fever (Old Ver.)", GAME_SUPPORTS_SAVE ) |
| 935 | 935 | GAME( 1979, spacefevo2, spacefev, spacefev, spacefev, driver_device, 0, ROT270, "Nintendo", "Space Fever (Older Ver.)", GAME_SUPPORTS_SAVE ) |
| 936 | | GAME( 1979, highsplt, 0, spacefev, highsplt, driver_device, 0, ROT270, "Nintendo", "Space Fever High Splitter (set 1)", GAME_SUPPORTS_SAVE ) // known as "SF-Hisplitter" on its flyer |
| 937 | | GAME( 1979, highsplta, highsplt, spacefev, highsplt, driver_device, 0, ROT270, "Nintendo", "Space Fever High Splitter (set 2)", GAME_SUPPORTS_SAVE ) // known as "SF-Hisplitter" on its flyer |
| 938 | | GAME( 1979, highspltb, highsplt, spacefev, highsplt, driver_device, 0, ROT270, "Nintendo", "Space Fever High Splitter (alt Sound)", GAME_SUPPORTS_SAVE ) // known as "SF-Hisplitter" on its flyer |
| 936 | GAME( 1979, highsplt, 0, spacefev, highsplt, driver_device, 0, ROT270, "Nintendo", "Space Fever High Splitter (set 1)", GAME_SUPPORTS_SAVE ) |
| 937 | GAME( 1979, highsplta, highsplt, spacefev, highsplt, driver_device, 0, ROT270, "Nintendo", "Space Fever High Splitter (set 2)", GAME_SUPPORTS_SAVE ) |
| 938 | GAME( 1979, highspltb, highsplt, spacefev, highsplt, driver_device, 0, ROT270, "Nintendo", "Space Fever High Splitter (alt Sound)", GAME_SUPPORTS_SAVE ) |
| 939 | 939 | GAME( 1979, spacelnc, 0, spacefev, spacelnc, driver_device, 0, ROT270, "Nintendo", "Space Launcher", GAME_SUPPORTS_SAVE ) |
| 940 | 940 | GAME( 1979, sheriff, 0, sheriff, sheriff, driver_device, 0, ROT270, "Nintendo", "Sheriff", GAME_SUPPORTS_SAVE ) |
| 941 | 941 | GAME( 1980, bandido, sheriff, sheriff, bandido, driver_device, 0, ROT270, "Nintendo (Exidy license)", "Bandido", GAME_SUPPORTS_SAVE ) |
trunk/src/mame/drivers/wc90.c
| r243594 | r243595 | |
| 55 | 55 | * * |
| 56 | 56 | ***************************** |
| 57 | 57 | |
| 58 | | There is known to be a Pacman hack running on this hardware. It was done by Mike C. and isn't meant |
| 58 | There is known to be a Pacman hack running on this hardware. It was done by Mike C. and isn't ment |
| 59 | 59 | for inclusion in MAME. However the roms with checksums are listed below to prevent it being added |
| 60 | 60 | as a newly "found" game: |
| 61 | 61 | |
| r243594 | r243595 | |
| 79 | 79 | #include "includes/wc90.h" |
| 80 | 80 | |
| 81 | 81 | |
| 82 | | WRITE8_MEMBER(wc90_state::bankswitch_w) |
| 82 | WRITE8_MEMBER(wc90_state::wc90_bankswitch_w) |
| 83 | 83 | { |
| 84 | 84 | int bankaddress; |
| 85 | 85 | UINT8 *RAM = memregion("maincpu")->base(); |
| r243594 | r243595 | |
| 89 | 89 | membank("bank1")->set_base(&RAM[bankaddress] ); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | | WRITE8_MEMBER(wc90_state::bankswitch1_w) |
| 92 | WRITE8_MEMBER(wc90_state::wc90_bankswitch1_w) |
| 93 | 93 | { |
| 94 | 94 | int bankaddress; |
| 95 | 95 | UINT8 *RAM = memregion("sub")->base(); |
| r243594 | r243595 | |
| 99 | 99 | membank("bank2")->set_base(&RAM[bankaddress] ); |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | | WRITE8_MEMBER(wc90_state::sound_command_w) |
| 102 | WRITE8_MEMBER(wc90_state::wc90_sound_command_w) |
| 103 | 103 | { |
| 104 | 104 | soundlatch_byte_w(space, offset, data); |
| 105 | 105 | m_audiocpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE); |
| r243594 | r243595 | |
| 110 | 110 | static ADDRESS_MAP_START( wc90_map_1, AS_PROGRAM, 8, wc90_state ) |
| 111 | 111 | AM_RANGE(0x0000, 0x7fff) AM_ROM |
| 112 | 112 | AM_RANGE(0x8000, 0x9fff) AM_RAM /* Main RAM */ |
| 113 | | AM_RANGE(0xa000, 0xafff) AM_RAM_WRITE(fgvideoram_w) AM_SHARE("fgvideoram") /* fg video ram */ |
| 113 | AM_RANGE(0xa000, 0xafff) AM_RAM_WRITE(wc90_fgvideoram_w) AM_SHARE("fgvideoram") /* fg video ram */ |
| 114 | 114 | AM_RANGE(0xb000, 0xbfff) AM_RAM |
| 115 | | AM_RANGE(0xc000, 0xcfff) AM_RAM_WRITE(bgvideoram_w) AM_SHARE("bgvideoram") |
| 115 | AM_RANGE(0xc000, 0xcfff) AM_RAM_WRITE(wc90_bgvideoram_w) AM_SHARE("bgvideoram") |
| 116 | 116 | AM_RANGE(0xd000, 0xdfff) AM_RAM |
| 117 | | AM_RANGE(0xe000, 0xefff) AM_RAM_WRITE(txvideoram_w) AM_SHARE("txvideoram") /* tx video ram */ |
| 117 | AM_RANGE(0xe000, 0xefff) AM_RAM_WRITE(wc90_txvideoram_w) AM_SHARE("txvideoram") /* tx video ram */ |
| 118 | 118 | AM_RANGE(0xf000, 0xf7ff) AM_ROMBANK("bank1") |
| 119 | 119 | AM_RANGE(0xf800, 0xfbff) AM_RAM AM_SHARE("share1") |
| 120 | 120 | AM_RANGE(0xfc00, 0xfc00) AM_READ_PORT("P1") |
| r243594 | r243595 | |
| 134 | 134 | AM_RANGE(0xfc43, 0xfc43) AM_WRITEONLY AM_SHARE("scroll2yhi") |
| 135 | 135 | AM_RANGE(0xfc46, 0xfc46) AM_WRITEONLY AM_SHARE("scroll2xlo") |
| 136 | 136 | AM_RANGE(0xfc47, 0xfc47) AM_WRITEONLY AM_SHARE("scroll2xhi") |
| 137 | | AM_RANGE(0xfcc0, 0xfcc0) AM_WRITE(sound_command_w) |
| 137 | AM_RANGE(0xfcc0, 0xfcc0) AM_WRITE(wc90_sound_command_w) |
| 138 | 138 | AM_RANGE(0xfcd0, 0xfcd0) AM_WRITE(watchdog_reset_w) |
| 139 | | AM_RANGE(0xfce0, 0xfce0) AM_WRITE(bankswitch_w) |
| 139 | AM_RANGE(0xfce0, 0xfce0) AM_WRITE(wc90_bankswitch_w) |
| 140 | 140 | ADDRESS_MAP_END |
| 141 | 141 | |
| 142 | 142 | static ADDRESS_MAP_START( wc90_map_2, AS_PROGRAM, 8, wc90_state ) |
| r243594 | r243595 | |
| 147 | 147 | AM_RANGE(0xe000, 0xe7ff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette") |
| 148 | 148 | AM_RANGE(0xf000, 0xf7ff) AM_ROMBANK("bank2") |
| 149 | 149 | AM_RANGE(0xf800, 0xfbff) AM_RAM AM_SHARE("share1") |
| 150 | | AM_RANGE(0xfc00, 0xfc00) AM_WRITE(bankswitch1_w) |
| 150 | AM_RANGE(0xfc00, 0xfc00) AM_WRITE(wc90_bankswitch1_w) |
| 151 | 151 | AM_RANGE(0xfc01, 0xfc01) AM_WRITE(watchdog_reset_w) |
| 152 | 152 | ADDRESS_MAP_END |
| 153 | 153 | |
| r243594 | r243595 | |
| 316 | 316 | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) |
| 317 | 317 | MCFG_SCREEN_SIZE(32*8, 32*8) |
| 318 | 318 | MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1) |
| 319 | | MCFG_SCREEN_UPDATE_DRIVER(wc90_state, screen_update) |
| 319 | MCFG_SCREEN_UPDATE_DRIVER(wc90_state, screen_update_wc90) |
| 320 | 320 | MCFG_SCREEN_PALETTE("palette") |
| 321 | 321 | |
| 322 | 322 | MCFG_GFXDECODE_ADD("gfxdecode", "palette", wc90) |
| r243594 | r243595 | |
| 472 | 472 | ROM_LOAD( "ic82_06.bin", 0x00000, 0x20000, CRC(2fd692ed) SHA1(0273dc39181504320bec0187d074b2f86c821508) ) |
| 473 | 473 | ROM_END |
| 474 | 474 | |
| 475 | | GAME( 1989, wc90, 0, wc90, wc90, driver_device, 0, ROT0, "Tecmo", "Tecmo World Cup '90 (World)", GAME_IMPERFECT_SOUND | GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE ) |
| 476 | | GAME( 1989, wc90a, wc90, wc90, wc90, driver_device, 0, ROT0, "Tecmo", "Tecmo World Cup '90 (Euro set 1)", GAME_IMPERFECT_SOUND | GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE ) |
| 477 | | GAME( 1989, wc90b, wc90, wc90, wc90, driver_device, 0, ROT0, "Tecmo", "Tecmo World Cup '90 (Euro set 2)", GAME_IMPERFECT_SOUND | GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE ) |
| 478 | | GAME( 1989, wc90t, wc90, wc90t,wc90, driver_device, 0, ROT0, "Tecmo", "Tecmo World Cup '90 (trackball set 1)", GAME_IMPERFECT_SOUND | GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE ) |
| 475 | GAME( 1989, wc90, 0, wc90, wc90, driver_device, 0, ROT0, "Tecmo", "Tecmo World Cup '90 (World)", GAME_IMPERFECT_SOUND | GAME_NO_COCKTAIL ) |
| 476 | GAME( 1989, wc90a, wc90, wc90, wc90, driver_device, 0, ROT0, "Tecmo", "Tecmo World Cup '90 (Euro set 1)", GAME_IMPERFECT_SOUND | GAME_NO_COCKTAIL ) |
| 477 | GAME( 1989, wc90b, wc90, wc90, wc90, driver_device, 0, ROT0, "Tecmo", "Tecmo World Cup '90 (Euro set 2)", GAME_IMPERFECT_SOUND | GAME_NO_COCKTAIL ) |
| 478 | GAME( 1989, wc90t, wc90, wc90t,wc90, driver_device, 0, ROT0, "Tecmo", "Tecmo World Cup '90 (trackball set 1)", GAME_IMPERFECT_SOUND | GAME_NO_COCKTAIL ) |
trunk/src/mame/drivers/wwfsstar.c
| r243594 | r243595 | |
| 121 | 121 | 04 Mar 2002 | Fixed Dip Switches and Inputs (Steph) |
| 122 | 122 | | Fixed screen flipping by using similar routine to the one |
| 123 | 123 | | in src/video/wwfwfest.c (Steph) |
| 124 | | 18 Jun 2001 | Changed Interrupt Function .. it's not fully understood what |
| 124 | 18 Jun 2001 | Changed Interrupt Function .. its not fully understood whats |
| 125 | 125 | | is meant to be going on .. |
| 126 | 126 | 15 Jun 2001 | Cleaned up Sprite Drawing a bit, correcting some clipping probs, |
| 127 | 127 | | mapped DSW's |
| r243594 | r243595 | |
| 170 | 170 | |
| 171 | 171 | static ADDRESS_MAP_START( main_map, AS_PROGRAM, 16, wwfsstar_state ) |
| 172 | 172 | AM_RANGE(0x000000, 0x03ffff) AM_ROM |
| 173 | | AM_RANGE(0x080000, 0x080fff) AM_RAM_WRITE(fg0_videoram_w) AM_SHARE("fg0_videoram") /* FG0 Ram */ |
| 174 | | AM_RANGE(0x0c0000, 0x0c0fff) AM_RAM_WRITE(bg0_videoram_w) AM_SHARE("bg0_videoram") /* BG0 Ram */ |
| 173 | AM_RANGE(0x080000, 0x080fff) AM_RAM_WRITE(wwfsstar_fg0_videoram_w) AM_SHARE("fg0_videoram") /* FG0 Ram */ |
| 174 | AM_RANGE(0x0c0000, 0x0c0fff) AM_RAM_WRITE(wwfsstar_bg0_videoram_w) AM_SHARE("bg0_videoram") /* BG0 Ram */ |
| 175 | 175 | AM_RANGE(0x100000, 0x1003ff) AM_RAM AM_SHARE("spriteram") /* SPR Ram */ |
| 176 | 176 | AM_RANGE(0x140000, 0x140fff) AM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette") |
| 177 | | AM_RANGE(0x180000, 0x180003) AM_WRITE(irqack_w) |
| 177 | AM_RANGE(0x180000, 0x180003) AM_WRITE(wwfsstar_irqack_w) |
| 178 | 178 | AM_RANGE(0x180000, 0x180001) AM_READ_PORT("DSW1") |
| 179 | 179 | AM_RANGE(0x180002, 0x180003) AM_READ_PORT("DSW2") |
| 180 | 180 | AM_RANGE(0x180004, 0x180005) AM_READ_PORT("P1") |
| 181 | | AM_RANGE(0x180004, 0x180007) AM_WRITE(scroll_w) |
| 181 | AM_RANGE(0x180004, 0x180007) AM_WRITE(wwfsstar_scrollwrite) |
| 182 | 182 | AM_RANGE(0x180006, 0x180007) AM_READ_PORT("P2") |
| 183 | 183 | AM_RANGE(0x180008, 0x180009) AM_READ_PORT("SYSTEM") |
| 184 | | AM_RANGE(0x180008, 0x180009) AM_WRITE(sound_w) |
| 185 | | AM_RANGE(0x18000a, 0x18000b) AM_WRITE(flipscreen_w) |
| 184 | AM_RANGE(0x180008, 0x180009) AM_WRITE(wwfsstar_soundwrite) |
| 185 | AM_RANGE(0x18000a, 0x18000b) AM_WRITE(wwfsstar_flipscreen_w) |
| 186 | 186 | AM_RANGE(0x1c0000, 0x1c3fff) AM_RAM /* Work Ram */ |
| 187 | 187 | ADDRESS_MAP_END |
| 188 | 188 | |
| r243594 | r243595 | |
| 201 | 201 | as used by the above memory map |
| 202 | 202 | *******************************************************************************/ |
| 203 | 203 | |
| 204 | | WRITE16_MEMBER(wwfsstar_state::scroll_w) |
| 204 | WRITE16_MEMBER(wwfsstar_state::wwfsstar_scrollwrite) |
| 205 | 205 | { |
| 206 | 206 | switch (offset) |
| 207 | 207 | { |
| r243594 | r243595 | |
| 214 | 214 | } |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | | WRITE16_MEMBER(wwfsstar_state::sound_w) |
| 217 | WRITE16_MEMBER(wwfsstar_state::wwfsstar_soundwrite) |
| 218 | 218 | { |
| 219 | 219 | soundlatch_byte_w(space, 1, data & 0xff); |
| 220 | 220 | m_audiocpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE ); |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | | WRITE16_MEMBER(wwfsstar_state::flipscreen_w) |
| 223 | WRITE16_MEMBER(wwfsstar_state::wwfsstar_flipscreen_w) |
| 224 | 224 | { |
| 225 | 225 | flip_screen_set(data & 1); |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | | WRITE16_MEMBER(wwfsstar_state::irqack_w) |
| 228 | WRITE16_MEMBER(wwfsstar_state::wwfsstar_irqack_w) |
| 229 | 229 | { |
| 230 | 230 | if (offset == 0) |
| 231 | 231 | m_maincpu->set_input_line(6, CLEAR_LINE); |
| r243594 | r243595 | |
| 247 | 247 | A hack is required: raise the vblank bit a scanline early. |
| 248 | 248 | */ |
| 249 | 249 | |
| 250 | | TIMER_DEVICE_CALLBACK_MEMBER(wwfsstar_state::scanline) |
| 250 | TIMER_DEVICE_CALLBACK_MEMBER(wwfsstar_state::wwfsstar_scanline) |
| 251 | 251 | { |
| 252 | 252 | int scanline = param; |
| 253 | 253 | |
| r243594 | r243595 | |
| 278 | 278 | } |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | | CUSTOM_INPUT_MEMBER(wwfsstar_state::vblank_r) |
| 281 | CUSTOM_INPUT_MEMBER(wwfsstar_state::wwfsstar_vblank_r) |
| 282 | 282 | { |
| 283 | 283 | return m_vblank; |
| 284 | 284 | } |
| r243594 | r243595 | |
| 313 | 313 | PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START2 ) PORT_NAME("Button B (1P VS 2P - Buy-in)") |
| 314 | 314 | |
| 315 | 315 | PORT_START("SYSTEM") |
| 316 | | PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, wwfsstar_state, vblank_r, NULL) /* VBlank */ |
| 316 | PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, wwfsstar_state,wwfsstar_vblank_r, NULL) /* VBlank */ |
| 317 | 317 | PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN1 ) |
| 318 | 318 | PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_COIN2 ) |
| 319 | 319 | PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_SERVICE1 ) |
| r243594 | r243595 | |
| 416 | 416 | /* basic machine hardware */ |
| 417 | 417 | MCFG_CPU_ADD("maincpu", M68000, CPU_CLOCK) |
| 418 | 418 | MCFG_CPU_PROGRAM_MAP(main_map) |
| 419 | | MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer", wwfsstar_state, scanline, "screen", 0, 1) |
| 419 | MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer", wwfsstar_state, wwfsstar_scanline, "screen", 0, 1) |
| 420 | 420 | |
| 421 | 421 | MCFG_CPU_ADD("audiocpu", Z80, XTAL_3_579545MHz) |
| 422 | 422 | MCFG_CPU_PROGRAM_MAP(sound_map) |
| r243594 | r243595 | |
| 424 | 424 | /* video hardware */ |
| 425 | 425 | MCFG_SCREEN_ADD("screen", RASTER) |
| 426 | 426 | MCFG_SCREEN_RAW_PARAMS(PIXEL_CLOCK, 320, 0, 256, 272, 8, 248) /* HTOTAL and VTOTAL are guessed */ |
| 427 | | MCFG_SCREEN_UPDATE_DRIVER(wwfsstar_state, screen_update) |
| 427 | MCFG_SCREEN_UPDATE_DRIVER(wwfsstar_state, screen_update_wwfsstar) |
| 428 | 428 | MCFG_SCREEN_PALETTE("palette") |
| 429 | 429 | |
| 430 | 430 | MCFG_GFXDECODE_ADD("gfxdecode", "palette", wwfsstar) |
| r243594 | r243595 | |
| 627 | 627 | |
| 628 | 628 | |
| 629 | 629 | |
| 630 | | GAME( 1989, wwfsstar, 0, wwfsstar, wwfsstar, driver_device, 0, ROT0, "Technos Japan", "WWF Superstars (Europe)", GAME_SUPPORTS_SAVE ) |
| 631 | | GAME( 1989, wwfsstaru, wwfsstar, wwfsstar, wwfsstar, driver_device, 0, ROT0, "Technos Japan", "WWF Superstars (US, Newer)", GAME_SUPPORTS_SAVE ) |
| 632 | | GAME( 1989, wwfsstarua, wwfsstar, wwfsstar, wwfsstar, driver_device, 0, ROT0, "Technos Japan", "WWF Superstars (US)", GAME_SUPPORTS_SAVE ) |
| 633 | | GAME( 1989, wwfsstarj, wwfsstar, wwfsstar, wwfsstar, driver_device, 0, ROT0, "Technos Japan", "WWF Superstars (Japan)", GAME_SUPPORTS_SAVE ) |
| 634 | | GAME( 1989, wwfsstarb, wwfsstar, wwfsstar, wwfsstar, driver_device, 0, ROT0, "bootleg", "WWF Superstars (bootleg)", GAME_SUPPORTS_SAVE ) |
| 630 | GAME( 1989, wwfsstar, 0, wwfsstar, wwfsstar, driver_device, 0, ROT0, "Technos Japan", "WWF Superstars (Europe)", 0 ) |
| 631 | GAME( 1989, wwfsstaru, wwfsstar, wwfsstar, wwfsstar, driver_device, 0, ROT0, "Technos Japan", "WWF Superstars (US, Newer)", 0 ) |
| 632 | GAME( 1989, wwfsstarua, wwfsstar, wwfsstar, wwfsstar, driver_device, 0, ROT0, "Technos Japan", "WWF Superstars (US)", 0 ) |
| 633 | GAME( 1989, wwfsstarj, wwfsstar, wwfsstar, wwfsstar, driver_device, 0, ROT0, "Technos Japan", "WWF Superstars (Japan)", 0 ) |
| 634 | GAME( 1989, wwfsstarb, wwfsstar, wwfsstar, wwfsstar, driver_device, 0, ROT0, "bootleg", "WWF Superstars (bootleg)", 0 ) |
trunk/src/mame/drivers/xxmissio.c
| r243594 | r243595 | |
| 14 | 14 | #include "includes/xxmissio.h" |
| 15 | 15 | |
| 16 | 16 | |
| 17 | | WRITE8_MEMBER(xxmissio_state::bank_sel_w) |
| 17 | WRITE8_MEMBER(xxmissio_state::xxmissio_bank_sel_w) |
| 18 | 18 | { |
| 19 | 19 | membank("bank1")->set_entry(data & 7); |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | | CUSTOM_INPUT_MEMBER(xxmissio_state::status_r) |
| 22 | CUSTOM_INPUT_MEMBER(xxmissio_state::xxmissio_status_r) |
| 23 | 23 | { |
| 24 | 24 | int bit_mask = (FPTR)param; |
| 25 | 25 | return (m_status & bit_mask) ? 1 : 0; |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | | WRITE8_MEMBER(xxmissio_state::status_m_w) |
| 28 | WRITE8_MEMBER(xxmissio_state::xxmissio_status_m_w) |
| 29 | 29 | { |
| 30 | 30 | switch (data) |
| 31 | 31 | { |
| r243594 | r243595 | |
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | | WRITE8_MEMBER(xxmissio_state::status_s_w) |
| 47 | WRITE8_MEMBER(xxmissio_state::xxmissio_status_s_w) |
| 48 | 48 | { |
| 49 | 49 | switch (data) |
| 50 | 50 | { |
| r243594 | r243595 | |
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | | INTERRUPT_GEN_MEMBER(xxmissio_state::interrupt_m) |
| 66 | INTERRUPT_GEN_MEMBER(xxmissio_state::xxmissio_interrupt_m) |
| 67 | 67 | { |
| 68 | 68 | m_status &= ~0x20; |
| 69 | | m_maincpu->set_input_line(0, HOLD_LINE); |
| 69 | device.execute().set_input_line(0, HOLD_LINE); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | | INTERRUPT_GEN_MEMBER(xxmissio_state::interrupt_s) |
| 72 | INTERRUPT_GEN_MEMBER(xxmissio_state::xxmissio_interrupt_s) |
| 73 | 73 | { |
| 74 | 74 | m_status &= ~0x10; |
| 75 | | m_subcpu->set_input_line(0, HOLD_LINE); |
| 75 | device.execute().set_input_line(0, HOLD_LINE); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | void xxmissio_state::machine_start() |
| 79 | 79 | { |
| 80 | 80 | membank("bank1")->configure_entries(0, 8, memregion("user1")->base(), 0x4000); |
| 81 | 81 | membank("bank1")->set_entry(0); |
| 82 | | |
| 83 | | save_item(NAME(m_status)); |
| 84 | 82 | } |
| 85 | 83 | |
| 86 | 84 | /****************************************************************************/ |
| r243594 | r243595 | |
| 94 | 92 | AM_RANGE(0xa000, 0xa000) AM_READ_PORT("P1") |
| 95 | 93 | AM_RANGE(0xa001, 0xa001) AM_READ_PORT("P2") |
| 96 | 94 | AM_RANGE(0xa002, 0xa002) AM_READ_PORT("STATUS") |
| 97 | | AM_RANGE(0xa002, 0xa002) AM_WRITE(status_m_w) |
| 98 | | AM_RANGE(0xa003, 0xa003) AM_WRITE(flipscreen_w) |
| 95 | AM_RANGE(0xa002, 0xa002) AM_WRITE(xxmissio_status_m_w) |
| 96 | AM_RANGE(0xa003, 0xa003) AM_WRITE(xxmissio_flipscreen_w) |
| 99 | 97 | |
| 100 | 98 | AM_RANGE(0xc000, 0xc7ff) AM_RAM AM_SHARE("fgram") |
| 101 | | AM_RANGE(0xc800, 0xcfff) AM_READWRITE(bgram_r, bgram_w) AM_SHARE("bgram") |
| 99 | AM_RANGE(0xc800, 0xcfff) AM_READWRITE(xxmissio_bgram_r, xxmissio_bgram_w) AM_SHARE("bgram") |
| 102 | 100 | AM_RANGE(0xd000, 0xd7ff) AM_RAM AM_SHARE("spriteram") |
| 103 | 101 | |
| 104 | 102 | AM_RANGE(0xd800, 0xdaff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette") |
| r243594 | r243595 | |
| 114 | 112 | |
| 115 | 113 | AM_RANGE(0x8000, 0x8001) AM_DEVREADWRITE("ym1", ym2203_device, read, write) |
| 116 | 114 | AM_RANGE(0x8002, 0x8003) AM_DEVREADWRITE("ym2", ym2203_device, read, write) |
| 117 | | AM_RANGE(0x8006, 0x8006) AM_WRITE(bank_sel_w) |
| 115 | AM_RANGE(0x8006, 0x8006) AM_WRITE(xxmissio_bank_sel_w) |
| 118 | 116 | |
| 119 | 117 | AM_RANGE(0xa000, 0xa000) AM_READ_PORT("P1") |
| 120 | 118 | AM_RANGE(0xa001, 0xa001) AM_READ_PORT("P2") |
| 121 | 119 | AM_RANGE(0xa002, 0xa002) AM_READ_PORT("STATUS") |
| 122 | | AM_RANGE(0xa002, 0xa002) AM_WRITE(status_s_w) |
| 123 | | AM_RANGE(0xa003, 0xa003) AM_WRITE(flipscreen_w) |
| 120 | AM_RANGE(0xa002, 0xa002) AM_WRITE(xxmissio_status_s_w) |
| 121 | AM_RANGE(0xa003, 0xa003) AM_WRITE(xxmissio_flipscreen_w) |
| 124 | 122 | |
| 125 | 123 | AM_RANGE(0xc000, 0xc7ff) AM_SHARE("fgram") AM_RAM |
| 126 | | AM_RANGE(0xc800, 0xcfff) AM_SHARE("bgram") AM_READWRITE(bgram_r, bgram_w) |
| 124 | AM_RANGE(0xc800, 0xcfff) AM_SHARE("bgram") AM_READWRITE(xxmissio_bgram_r, xxmissio_bgram_w) |
| 127 | 125 | AM_RANGE(0xd000, 0xd7ff) AM_SHARE("spriteram") AM_RAM |
| 128 | 126 | |
| 129 | 127 | AM_RANGE(0xd800, 0xdaff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette") |
| r243594 | r243595 | |
| 198 | 196 | PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW2:8" ) /* Shown as "Unused" in the manual */ |
| 199 | 197 | |
| 200 | 198 | PORT_START("STATUS") |
| 201 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, xxmissio_state, status_r, (void *)0x01) |
| 199 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, xxmissio_state,xxmissio_status_r, (void *)0x01) |
| 202 | 200 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_CUSTOM ) PORT_VBLANK("screen") |
| 203 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, xxmissio_state, status_r, (void *)0x04) |
| 204 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, xxmissio_state, status_r, (void *)0x08) |
| 205 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, xxmissio_state, status_r, (void *)0x10) |
| 206 | | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, xxmissio_state, status_r, (void *)0x20) |
| 207 | | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, xxmissio_state, status_r, (void *)0x40) |
| 208 | | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, xxmissio_state, status_r, (void *)0x80) |
| 201 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, xxmissio_state,xxmissio_status_r, (void *)0x04) |
| 202 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, xxmissio_state,xxmissio_status_r, (void *)0x08) |
| 203 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, xxmissio_state,xxmissio_status_r, (void *)0x10) |
| 204 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, xxmissio_state,xxmissio_status_r, (void *)0x20) |
| 205 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, xxmissio_state,xxmissio_status_r, (void *)0x40) |
| 206 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, xxmissio_state,xxmissio_status_r, (void *)0x80) |
| 209 | 207 | INPUT_PORTS_END |
| 210 | 208 | |
| 211 | 209 | /****************************************************************************/ |
| r243594 | r243595 | |
| 260 | 258 | /* basic machine hardware */ |
| 261 | 259 | MCFG_CPU_ADD("maincpu", Z80,12000000/4) /* 3.0MHz */ |
| 262 | 260 | MCFG_CPU_PROGRAM_MAP(map1) |
| 263 | | MCFG_CPU_VBLANK_INT_DRIVER("screen", xxmissio_state, interrupt_m) |
| 261 | MCFG_CPU_VBLANK_INT_DRIVER("screen", xxmissio_state, xxmissio_interrupt_m) |
| 264 | 262 | |
| 265 | 263 | MCFG_CPU_ADD("sub", Z80,12000000/4) /* 3.0MHz */ |
| 266 | 264 | MCFG_CPU_PROGRAM_MAP(map2) |
| 267 | | MCFG_CPU_PERIODIC_INT_DRIVER(xxmissio_state, interrupt_s, 2*60) |
| 265 | MCFG_CPU_PERIODIC_INT_DRIVER(xxmissio_state, xxmissio_interrupt_s, 2*60) |
| 268 | 266 | |
| 269 | 267 | MCFG_QUANTUM_TIME(attotime::from_hz(6000)) |
| 270 | 268 | |
| r243594 | r243595 | |
| 275 | 273 | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */) |
| 276 | 274 | MCFG_SCREEN_SIZE(64*8, 32*8) |
| 277 | 275 | MCFG_SCREEN_VISIBLE_AREA(0*8, 64*8-1, 4*8, 28*8-1) |
| 278 | | MCFG_SCREEN_UPDATE_DRIVER(xxmissio_state, screen_update) |
| 276 | MCFG_SCREEN_UPDATE_DRIVER(xxmissio_state, screen_update_xxmissio) |
| 279 | 277 | MCFG_SCREEN_PALETTE("palette") |
| 280 | 278 | |
| 281 | 279 | MCFG_GFXDECODE_ADD("gfxdecode", "palette", xxmissio) |
| r243594 | r243595 | |
| 295 | 293 | MCFG_SOUND_ROUTE(3, "mono", 0.40) |
| 296 | 294 | |
| 297 | 295 | MCFG_SOUND_ADD("ym2", YM2203, 12000000/8) |
| 298 | | MCFG_AY8910_PORT_A_WRITE_CB(WRITE8(xxmissio_state, scroll_x_w)) |
| 299 | | MCFG_AY8910_PORT_B_WRITE_CB(WRITE8(xxmissio_state, scroll_y_w)) |
| 296 | MCFG_AY8910_PORT_A_WRITE_CB(WRITE8(xxmissio_state, xxmissio_scroll_x_w)) |
| 297 | MCFG_AY8910_PORT_B_WRITE_CB(WRITE8(xxmissio_state, xxmissio_scroll_y_w)) |
| 300 | 298 | MCFG_SOUND_ROUTE(0, "mono", 0.15) |
| 301 | 299 | MCFG_SOUND_ROUTE(1, "mono", 0.15) |
| 302 | 300 | MCFG_SOUND_ROUTE(2, "mono", 0.15) |
| r243594 | r243595 | |
| 328 | 326 | ROM_LOAD16_BYTE( "xx11.4b", 0x0001, 0x8000, CRC(d9dd827c) SHA1(aea3a5abd871adf7f75ad4d6cc57eff0833135c7) ) |
| 329 | 327 | ROM_END |
| 330 | 328 | |
| 331 | | GAME( 1986, xxmissio, 0, xxmissio, xxmissio, driver_device, 0, ROT90, "UPL", "XX Mission", GAME_SUPPORTS_SAVE ) |
| 329 | GAME( 1986, xxmissio, 0, xxmissio, xxmissio, driver_device, 0, ROT90, "UPL", "XX Mission", 0 ) |
trunk/src/mame/includes/wc90.h
| r243594 | r243595 | |
| 5 | 5 | public: |
| 6 | 6 | wc90_state(const machine_config &mconfig, device_type type, const char *tag) |
| 7 | 7 | : driver_device(mconfig, type, tag), |
| 8 | | m_maincpu(*this, "maincpu"), |
| 9 | | m_audiocpu(*this, "audiocpu"), |
| 10 | | m_gfxdecode(*this, "gfxdecode"), |
| 11 | | m_palette(*this, "palette"), |
| 12 | | m_sprgen(*this, "spritegen"), |
| 13 | 8 | m_fgvideoram(*this, "fgvideoram"), |
| 14 | 9 | m_bgvideoram(*this, "bgvideoram"), |
| 15 | 10 | m_txvideoram(*this, "txvideoram"), |
| r243594 | r243595 | |
| 25 | 20 | m_scroll1yhi(*this, "scroll1yhi"), |
| 26 | 21 | m_scroll2ylo(*this, "scroll2ylo"), |
| 27 | 22 | m_scroll2yhi(*this, "scroll2yhi"), |
| 28 | | m_spriteram(*this, "spriteram") |
| 23 | m_spriteram(*this, "spriteram"), |
| 24 | m_maincpu(*this, "maincpu"), |
| 25 | m_audiocpu(*this, "audiocpu"), |
| 26 | m_gfxdecode(*this, "gfxdecode"), |
| 27 | m_palette(*this, "palette"), |
| 28 | m_sprgen(*this, "spritegen") |
| 29 | 29 | { } |
| 30 | 30 | |
| 31 | | |
| 32 | | required_device<cpu_device> m_maincpu; |
| 33 | | required_device<cpu_device> m_audiocpu; |
| 34 | | required_device<gfxdecode_device> m_gfxdecode; |
| 35 | | required_device<palette_device> m_palette; |
| 36 | | required_device<tecmo_spr_device> m_sprgen; |
| 37 | 31 | |
| 32 | |
| 38 | 33 | required_shared_ptr<UINT8> m_fgvideoram; |
| 39 | 34 | required_shared_ptr<UINT8> m_bgvideoram; |
| 40 | 35 | required_shared_ptr<UINT8> m_txvideoram; |
| r243594 | r243595 | |
| 50 | 45 | required_shared_ptr<UINT8> m_scroll1yhi; |
| 51 | 46 | required_shared_ptr<UINT8> m_scroll2ylo; |
| 52 | 47 | required_shared_ptr<UINT8> m_scroll2yhi; |
| 53 | | required_shared_ptr<UINT8> m_spriteram; |
| 54 | | |
| 55 | 48 | tilemap_t *m_tx_tilemap; |
| 56 | 49 | tilemap_t *m_fg_tilemap; |
| 57 | 50 | tilemap_t *m_bg_tilemap; |
| 58 | | |
| 59 | | DECLARE_WRITE8_MEMBER(bankswitch_w); |
| 60 | | DECLARE_WRITE8_MEMBER(bankswitch1_w); |
| 61 | | DECLARE_WRITE8_MEMBER(sound_command_w); |
| 62 | | DECLARE_WRITE8_MEMBER(bgvideoram_w); |
| 63 | | DECLARE_WRITE8_MEMBER(fgvideoram_w); |
| 64 | | DECLARE_WRITE8_MEMBER(txvideoram_w); |
| 65 | | DECLARE_WRITE_LINE_MEMBER(irqhandler); |
| 66 | | |
| 51 | required_shared_ptr<UINT8> m_spriteram; |
| 52 | DECLARE_WRITE8_MEMBER(wc90_bankswitch_w); |
| 53 | DECLARE_WRITE8_MEMBER(wc90_bankswitch1_w); |
| 54 | DECLARE_WRITE8_MEMBER(wc90_sound_command_w); |
| 55 | DECLARE_WRITE8_MEMBER(wc90_bgvideoram_w); |
| 56 | DECLARE_WRITE8_MEMBER(wc90_fgvideoram_w); |
| 57 | DECLARE_WRITE8_MEMBER(wc90_txvideoram_w); |
| 67 | 58 | TILE_GET_INFO_MEMBER(get_bg_tile_info); |
| 68 | 59 | TILE_GET_INFO_MEMBER(get_fg_tile_info); |
| 69 | 60 | TILE_GET_INFO_MEMBER(get_tx_tile_info); |
| 70 | 61 | TILE_GET_INFO_MEMBER(track_get_bg_tile_info); |
| 71 | 62 | TILE_GET_INFO_MEMBER(track_get_fg_tile_info); |
| 72 | | |
| 73 | 63 | virtual void video_start(); |
| 74 | 64 | DECLARE_VIDEO_START(wc90t); |
| 75 | | |
| 76 | | UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 65 | UINT32 screen_update_wc90(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 66 | |
| 67 | DECLARE_WRITE_LINE_MEMBER(irqhandler); |
| 68 | required_device<cpu_device> m_maincpu; |
| 69 | required_device<cpu_device> m_audiocpu; |
| 70 | required_device<gfxdecode_device> m_gfxdecode; |
| 71 | required_device<palette_device> m_palette; |
| 72 | required_device<tecmo_spr_device> m_sprgen; |
| 77 | 73 | }; |
trunk/src/mame/includes/wwfsstar.h
| r243594 | r243595 | |
| 3 | 3 | public: |
| 4 | 4 | wwfsstar_state(const machine_config &mconfig, device_type type, const char *tag) |
| 5 | 5 | : driver_device(mconfig, type, tag), |
| 6 | m_spriteram(*this, "spriteram"), |
| 7 | m_fg0_videoram(*this, "fg0_videoram"), |
| 8 | m_bg0_videoram(*this, "bg0_videoram"), |
| 6 | 9 | m_maincpu(*this, "maincpu"), |
| 7 | 10 | m_audiocpu(*this, "audiocpu"), |
| 8 | 11 | m_gfxdecode(*this, "gfxdecode"), |
| 9 | 12 | m_screen(*this, "screen"), |
| 10 | | m_palette(*this, "palette"), |
| 11 | | m_spriteram(*this, "spriteram"), |
| 12 | | m_fg0_videoram(*this, "fg0_videoram"), |
| 13 | | m_bg0_videoram(*this, "bg0_videoram") { } |
| 13 | m_palette(*this, "palette") { } |
| 14 | 14 | |
| 15 | | required_device<cpu_device> m_maincpu; |
| 16 | | required_device<cpu_device> m_audiocpu; |
| 17 | | required_device<gfxdecode_device> m_gfxdecode; |
| 18 | | required_device<screen_device> m_screen; |
| 19 | | required_device<palette_device> m_palette; |
| 20 | | |
| 21 | | required_shared_ptr<UINT16> m_spriteram; |
| 22 | | required_shared_ptr<UINT16> m_fg0_videoram; |
| 23 | | required_shared_ptr<UINT16> m_bg0_videoram; |
| 24 | | |
| 25 | 15 | int m_vblank; |
| 26 | 16 | int m_scrollx; |
| 27 | 17 | int m_scrolly; |
| 18 | required_shared_ptr<UINT16> m_spriteram; |
| 19 | required_shared_ptr<UINT16> m_fg0_videoram; |
| 20 | required_shared_ptr<UINT16> m_bg0_videoram; |
| 28 | 21 | tilemap_t *m_fg0_tilemap; |
| 29 | 22 | tilemap_t *m_bg0_tilemap; |
| 30 | | |
| 31 | | DECLARE_WRITE16_MEMBER(scroll_w); |
| 32 | | DECLARE_WRITE16_MEMBER(sound_w); |
| 33 | | DECLARE_WRITE16_MEMBER(flipscreen_w); |
| 34 | | DECLARE_WRITE16_MEMBER(irqack_w); |
| 35 | | DECLARE_WRITE16_MEMBER(fg0_videoram_w); |
| 36 | | DECLARE_WRITE16_MEMBER(bg0_videoram_w); |
| 37 | | |
| 38 | | DECLARE_CUSTOM_INPUT_MEMBER(vblank_r); |
| 39 | | |
| 40 | | TIMER_DEVICE_CALLBACK_MEMBER(scanline); |
| 41 | | |
| 23 | DECLARE_WRITE16_MEMBER(wwfsstar_scrollwrite); |
| 24 | DECLARE_WRITE16_MEMBER(wwfsstar_soundwrite); |
| 25 | DECLARE_WRITE16_MEMBER(wwfsstar_flipscreen_w); |
| 26 | DECLARE_WRITE16_MEMBER(wwfsstar_irqack_w); |
| 27 | DECLARE_WRITE16_MEMBER(wwfsstar_fg0_videoram_w); |
| 28 | DECLARE_WRITE16_MEMBER(wwfsstar_bg0_videoram_w); |
| 29 | DECLARE_CUSTOM_INPUT_MEMBER(wwfsstar_vblank_r); |
| 42 | 30 | TILE_GET_INFO_MEMBER(get_fg0_tile_info); |
| 43 | 31 | TILEMAP_MAPPER_MEMBER(bg0_scan); |
| 44 | 32 | TILE_GET_INFO_MEMBER(get_bg0_tile_info); |
| 45 | | |
| 46 | 33 | virtual void video_start(); |
| 47 | | |
| 48 | | UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 34 | UINT32 screen_update_wwfsstar(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 35 | TIMER_DEVICE_CALLBACK_MEMBER(wwfsstar_scanline); |
| 49 | 36 | void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect ); |
| 37 | required_device<cpu_device> m_maincpu; |
| 38 | required_device<cpu_device> m_audiocpu; |
| 39 | required_device<gfxdecode_device> m_gfxdecode; |
| 40 | required_device<screen_device> m_screen; |
| 41 | required_device<palette_device> m_palette; |
| 50 | 42 | }; |
trunk/src/mame/includes/xxmissio.h
| r243594 | r243595 | |
| 3 | 3 | public: |
| 4 | 4 | xxmissio_state(const machine_config &mconfig, device_type type, const char *tag) |
| 5 | 5 | : driver_device(mconfig, type, tag), |
| 6 | m_bgram(*this, "bgram"), |
| 7 | m_fgram(*this, "fgram"), |
| 8 | m_spriteram(*this, "spriteram"), |
| 6 | 9 | m_maincpu(*this, "maincpu"), |
| 7 | 10 | m_subcpu(*this, "sub"), |
| 8 | 11 | m_gfxdecode(*this, "gfxdecode"), |
| 9 | | m_palette(*this, "palette"), |
| 10 | | m_bgram(*this, "bgram"), |
| 11 | | m_fgram(*this, "fgram"), |
| 12 | | m_spriteram(*this, "spriteram") { } |
| 12 | m_palette(*this, "palette") { } |
| 13 | 13 | |
| 14 | | required_device<cpu_device> m_maincpu; |
| 15 | | required_device<cpu_device> m_subcpu; |
| 16 | | required_device<gfxdecode_device> m_gfxdecode; |
| 17 | | required_device<palette_device> m_palette; |
| 18 | | |
| 14 | UINT8 m_status; |
| 19 | 15 | required_shared_ptr<UINT8> m_bgram; |
| 20 | 16 | required_shared_ptr<UINT8> m_fgram; |
| 21 | 17 | required_shared_ptr<UINT8> m_spriteram; |
| 22 | | |
| 23 | 18 | tilemap_t *m_bg_tilemap; |
| 24 | 19 | tilemap_t *m_fg_tilemap; |
| 25 | | UINT8 m_status; |
| 26 | 20 | UINT8 m_xscroll; |
| 27 | 21 | UINT8 m_yscroll; |
| 28 | 22 | UINT8 m_flipscreen; |
| 29 | | |
| 30 | | DECLARE_WRITE8_MEMBER(bank_sel_w); |
| 31 | | DECLARE_WRITE8_MEMBER(status_m_w); |
| 32 | | DECLARE_WRITE8_MEMBER(status_s_w); |
| 33 | | DECLARE_WRITE8_MEMBER(flipscreen_w); |
| 34 | | DECLARE_WRITE8_MEMBER(bgram_w); |
| 35 | | DECLARE_READ8_MEMBER(bgram_r); |
| 36 | | DECLARE_WRITE8_MEMBER(scroll_x_w); |
| 37 | | DECLARE_WRITE8_MEMBER(scroll_y_w); |
| 38 | | |
| 39 | | DECLARE_CUSTOM_INPUT_MEMBER(status_r); |
| 40 | | |
| 41 | | INTERRUPT_GEN_MEMBER(interrupt_m); |
| 42 | | INTERRUPT_GEN_MEMBER(interrupt_s); |
| 43 | | |
| 23 | DECLARE_WRITE8_MEMBER(xxmissio_bank_sel_w); |
| 24 | DECLARE_WRITE8_MEMBER(xxmissio_status_m_w); |
| 25 | DECLARE_WRITE8_MEMBER(xxmissio_status_s_w); |
| 26 | DECLARE_WRITE8_MEMBER(xxmissio_flipscreen_w); |
| 27 | DECLARE_WRITE8_MEMBER(xxmissio_bgram_w); |
| 28 | DECLARE_READ8_MEMBER(xxmissio_bgram_r); |
| 29 | DECLARE_CUSTOM_INPUT_MEMBER(xxmissio_status_r); |
| 44 | 30 | TILE_GET_INFO_MEMBER(get_bg_tile_info); |
| 45 | 31 | TILE_GET_INFO_MEMBER(get_fg_tile_info); |
| 46 | | |
| 47 | 32 | virtual void machine_start(); |
| 48 | 33 | virtual void video_start(); |
| 49 | | |
| 50 | | UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 34 | UINT32 screen_update_xxmissio(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 35 | INTERRUPT_GEN_MEMBER(xxmissio_interrupt_m); |
| 36 | INTERRUPT_GEN_MEMBER(xxmissio_interrupt_s); |
| 37 | DECLARE_WRITE8_MEMBER(xxmissio_scroll_x_w); |
| 38 | DECLARE_WRITE8_MEMBER(xxmissio_scroll_y_w); |
| 51 | 39 | void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx); |
| 40 | required_device<cpu_device> m_maincpu; |
| 41 | required_device<cpu_device> m_subcpu; |
| 42 | required_device<gfxdecode_device> m_gfxdecode; |
| 43 | required_device<palette_device> m_palette; |
| 52 | 44 | }; |
trunk/src/mess/drivers/wildfire.c
| r243594 | r243595 | |
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | TODO: |
| 16 | | - sound emulation could still be improved |
| 16 | - bad sound (probably MCU related) |
| 17 | 17 | - when the game strobes a led faster, it should appear brighter, for example when |
| 18 | 18 | the ball hits one of the bumpers |
| 19 | 19 | - some 7segs digits are wrong (mcu on-die decoder is customizable?) |
| r243594 | r243595 | |
| 28 | 28 | #include "wildfire.lh" // this is a test layout, external artwork is necessary |
| 29 | 29 | |
| 30 | 30 | // master clock is a single stage RC oscillator: R=?K, C=?pf, |
| 31 | | // S2000 default frequency is 850kHz |
| 31 | // S2150 default frequency is 850kHz |
| 32 | 32 | #define MASTER_CLOCK (850000) |
| 33 | 33 | |
| 34 | 34 | |
| r243594 | r243595 | |
| 38 | 38 | wildfire_state(const machine_config &mconfig, device_type type, const char *tag) |
| 39 | 39 | : driver_device(mconfig, type, tag), |
| 40 | 40 | m_maincpu(*this, "maincpu"), |
| 41 | | m_speaker(*this, "speaker"), |
| 42 | | m_a12_decay_timer(*this, "a12_decay") |
| 41 | m_speaker(*this, "speaker") |
| 43 | 42 | { } |
| 44 | 43 | |
| 45 | 44 | required_device<cpu_device> m_maincpu; |
| 46 | 45 | required_device<speaker_sound_device> m_speaker; |
| 47 | | required_device<timer_device> m_a12_decay_timer; |
| 48 | 46 | |
| 49 | 47 | UINT8 m_d; |
| 50 | 48 | UINT16 m_a; |
| 51 | | UINT8 m_q2; |
| 52 | | UINT8 m_q3; |
| 53 | 49 | |
| 54 | 50 | UINT16 m_display_state[0x10]; |
| 55 | 51 | UINT16 m_display_cache[0x10]; |
| r243594 | r243595 | |
| 57 | 53 | |
| 58 | 54 | DECLARE_WRITE8_MEMBER(write_d); |
| 59 | 55 | DECLARE_WRITE16_MEMBER(write_a); |
| 60 | | DECLARE_WRITE_LINE_MEMBER(write_f); |
| 61 | 56 | |
| 62 | 57 | TIMER_DEVICE_CALLBACK_MEMBER(display_decay_tick); |
| 63 | | bool index_is_7segled(int index); |
| 64 | 58 | void display_update(); |
| 65 | | |
| 66 | | TIMER_DEVICE_CALLBACK_MEMBER(reset_q2); |
| 67 | | void write_a12(int state); |
| 68 | | void sound_update(); |
| 59 | bool index_is_7segled(int index); |
| 69 | 60 | |
| 70 | 61 | virtual void machine_start(); |
| 71 | 62 | }; |
| r243594 | r243595 | |
| 113 | 104 | for (int i = 0; i < 0x10; i++) |
| 114 | 105 | { |
| 115 | 106 | // update current state |
| 116 | | m_display_state[i] = (m_a >> i & 1) ? m_d : 0; |
| 107 | m_display_state[i] = (~m_a >> i & 1) ? m_d : 0; |
| 117 | 108 | |
| 118 | 109 | active_state[i] = 0; |
| 119 | 110 | |
| r243594 | r243595 | |
| 159 | 150 | |
| 160 | 151 | /*************************************************************************** |
| 161 | 152 | |
| 162 | | Sound |
| 163 | | |
| 164 | | ***************************************************************************/ |
| 165 | | |
| 166 | | // Sound output is via a speaker between transistors Q2(from A12) and Q3(from F_out) |
| 167 | | // A12 to Q2 has a little electronic circuit going, causing a slight delay. |
| 168 | | // (see patent US4334679 FIG.5, the 2 resistors are 10K and the cap is a 4.7uF electrolytic) |
| 169 | | |
| 170 | | // decay time, in steps of 1ms |
| 171 | | #define A12_DECAY_TIME 5 /* a complete guess */ |
| 172 | | |
| 173 | | void wildfire_state::sound_update() |
| 174 | | { |
| 175 | | m_speaker->level_w(m_q2 & m_q3); |
| 176 | | } |
| 177 | | |
| 178 | | WRITE_LINE_MEMBER(wildfire_state::write_f) |
| 179 | | { |
| 180 | | // F_out pin: speaker out |
| 181 | | m_q3 = (state) ? 1 : 0; |
| 182 | | sound_update(); |
| 183 | | } |
| 184 | | |
| 185 | | TIMER_DEVICE_CALLBACK_MEMBER(wildfire_state::reset_q2) |
| 186 | | { |
| 187 | | m_q2 = 0; |
| 188 | | sound_update(); |
| 189 | | } |
| 190 | | |
| 191 | | void wildfire_state::write_a12(int state) |
| 192 | | { |
| 193 | | if (state) |
| 194 | | { |
| 195 | | m_a12_decay_timer->adjust(attotime::never); |
| 196 | | m_q2 = state; |
| 197 | | sound_update(); |
| 198 | | } |
| 199 | | else if (m_a >> 12 & 1) |
| 200 | | { |
| 201 | | // falling edge |
| 202 | | m_a12_decay_timer->adjust(attotime::from_msec(A12_DECAY_TIME)); |
| 203 | | } |
| 204 | | } |
| 205 | | |
| 206 | | |
| 207 | | |
| 208 | | /*************************************************************************** |
| 209 | | |
| 210 | 153 | I/O |
| 211 | 154 | |
| 212 | 155 | ***************************************************************************/ |
| r243594 | r243595 | |
| 220 | 163 | |
| 221 | 164 | WRITE16_MEMBER(wildfire_state::write_a) |
| 222 | 165 | { |
| 223 | | data ^= 0x1fff; // active-low |
| 224 | | |
| 225 | | // A12: enable speaker |
| 226 | | write_a12(data >> 12 & 1); |
| 166 | // A12: enable speaker out |
| 167 | // this is in combination with the MCU K4-pin, how? |
| 168 | m_speaker->level_w(data >> 12 & 1); |
| 227 | 169 | |
| 228 | 170 | // A0-A2: select 7segleds |
| 229 | 171 | // A3-A11: select other leds |
| r243594 | r243595 | |
| 264 | 206 | |
| 265 | 207 | m_d = 0; |
| 266 | 208 | m_a = 0; |
| 267 | | m_q2 = 0; |
| 268 | | m_q3 = 0; |
| 269 | 209 | |
| 270 | 210 | // register for savestates |
| 271 | 211 | save_item(NAME(m_display_state)); |
| r243594 | r243595 | |
| 274 | 214 | |
| 275 | 215 | save_item(NAME(m_d)); |
| 276 | 216 | save_item(NAME(m_a)); |
| 277 | | save_item(NAME(m_q2)); |
| 278 | | save_item(NAME(m_q3)); |
| 279 | 217 | } |
| 280 | 218 | |
| 281 | 219 | |
| 282 | 220 | static MACHINE_CONFIG_START( wildfire, wildfire_state ) |
| 283 | 221 | |
| 284 | 222 | /* basic machine hardware */ |
| 285 | | MCFG_CPU_ADD("maincpu", AMI_S2152, MASTER_CLOCK) |
| 223 | MCFG_CPU_ADD("maincpu", AMI_S2150, MASTER_CLOCK) |
| 286 | 224 | MCFG_AMI_S2000_READ_I_CB(IOPORT("IN1")) |
| 287 | 225 | MCFG_AMI_S2000_WRITE_D_CB(WRITE8(wildfire_state, write_d)) |
| 288 | 226 | MCFG_AMI_S2000_WRITE_A_CB(WRITE16(wildfire_state, write_a)) |
| 289 | | MCFG_AMI_S2152_FOUT_CB(WRITELINE(wildfire_state, write_f)) |
| 290 | 227 | |
| 291 | 228 | MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", wildfire_state, display_decay_tick, attotime::from_msec(1)) |
| 292 | | MCFG_TIMER_DRIVER_ADD("a12_decay", wildfire_state, reset_q2) |
| 293 | 229 | |
| 294 | 230 | MCFG_DEFAULT_LAYOUT(layout_wildfire) |
| 295 | 231 | |
trunk/src/osd/modules/debugger/qt/breakpointswindow.c
| r0 | r243595 | |
| 1 | #define NO_MEM_TRACKING |
| 2 | |
| 3 | #include "breakpointswindow.h" |
| 4 | |
| 5 | #include "debug/debugcon.h" |
| 6 | #include "debug/debugcpu.h" |
| 7 | #include "debug/dvbpoints.h" |
| 8 | #include "debug/dvwpoints.h" |
| 9 | |
| 10 | |
| 11 | BreakpointsWindow::BreakpointsWindow(running_machine* machine, QWidget* parent) : |
| 12 | WindowQt(machine, NULL) |
| 13 | { |
| 14 | setWindowTitle("Debug: All Breakpoints"); |
| 15 | |
| 16 | if (parent != NULL) |
| 17 | { |
| 18 | QPoint parentPos = parent->pos(); |
| 19 | setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400); |
| 20 | } |
| 21 | |
| 22 | // |
| 23 | // The main frame and its input and breakpoints widgets |
| 24 | // |
| 25 | QFrame* mainWindowFrame = new QFrame(this); |
| 26 | |
| 27 | // The main breakpoints view |
| 28 | m_breakpointsView = new DebuggerView(DVT_BREAK_POINTS, m_machine, this); |
| 29 | |
| 30 | // Layout |
| 31 | QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame); |
| 32 | vLayout->setObjectName("vlayout"); |
| 33 | vLayout->setSpacing(3); |
| 34 | vLayout->setContentsMargins(2,2,2,2); |
| 35 | vLayout->addWidget(m_breakpointsView); |
| 36 | |
| 37 | setCentralWidget(mainWindowFrame); |
| 38 | |
| 39 | // |
| 40 | // Menu bars |
| 41 | // |
| 42 | QActionGroup* typeGroup = new QActionGroup(this); |
| 43 | typeGroup->setObjectName("typegroup"); |
| 44 | QAction* typeBreak = new QAction("Breakpoints", this); |
| 45 | typeBreak->setObjectName("typebreak"); |
| 46 | QAction* typeWatch = new QAction("Watchpoints", this); |
| 47 | typeWatch->setObjectName("typewatch"); |
| 48 | typeBreak->setCheckable(true); |
| 49 | typeWatch->setCheckable(true); |
| 50 | typeBreak->setActionGroup(typeGroup); |
| 51 | typeWatch->setActionGroup(typeGroup); |
| 52 | typeBreak->setShortcut(QKeySequence("Ctrl+1")); |
| 53 | typeWatch->setShortcut(QKeySequence("Ctrl+2")); |
| 54 | typeBreak->setChecked(true); |
| 55 | connect(typeGroup, SIGNAL(triggered(QAction*)), this, SLOT(typeChanged(QAction*))); |
| 56 | |
| 57 | // Assemble the options menu |
| 58 | QMenu* optionsMenu = menuBar()->addMenu("&Options"); |
| 59 | optionsMenu->addActions(typeGroup->actions()); |
| 60 | } |
| 61 | |
| 62 | |
| 63 | BreakpointsWindow::~BreakpointsWindow() |
| 64 | { |
| 65 | } |
| 66 | |
| 67 | |
| 68 | void BreakpointsWindow::typeChanged(QAction* changedTo) |
| 69 | { |
| 70 | // Clean |
| 71 | delete m_breakpointsView; |
| 72 | m_breakpointsView = NULL; |
| 73 | |
| 74 | // Create |
| 75 | if (changedTo->text() == "Breakpoints") |
| 76 | { |
| 77 | m_breakpointsView = new DebuggerView(DVT_BREAK_POINTS, m_machine, this); |
| 78 | setWindowTitle("Debug: All Breakpoints"); |
| 79 | } |
| 80 | else if (changedTo->text() == "Watchpoints") |
| 81 | { |
| 82 | m_breakpointsView = new DebuggerView(DVT_WATCH_POINTS, m_machine, this); |
| 83 | setWindowTitle("Debug: All Watchpoints"); |
| 84 | } |
| 85 | |
| 86 | // Re-register |
| 87 | QVBoxLayout* layout = findChild<QVBoxLayout*>("vlayout"); |
| 88 | layout->addWidget(m_breakpointsView); |
| 89 | } |
| 90 | |
| 91 | |
| 92 | |
| 93 | //========================================================================= |
| 94 | // BreakpointsWindowQtConfig |
| 95 | //========================================================================= |
| 96 | void BreakpointsWindowQtConfig::buildFromQWidget(QWidget* widget) |
| 97 | { |
| 98 | WindowQtConfig::buildFromQWidget(widget); |
| 99 | BreakpointsWindow* window = dynamic_cast<BreakpointsWindow*>(widget); |
| 100 | |
| 101 | QActionGroup* typeGroup = window->findChild<QActionGroup*>("typegroup"); |
| 102 | if (typeGroup->checkedAction()->text() == "Breakpoints") |
| 103 | m_bwType = 0; |
| 104 | else if (typeGroup->checkedAction()->text() == "Watchpoints") |
| 105 | m_bwType = 1; |
| 106 | } |
| 107 | |
| 108 | |
| 109 | void BreakpointsWindowQtConfig::applyToQWidget(QWidget* widget) |
| 110 | { |
| 111 | WindowQtConfig::applyToQWidget(widget); |
| 112 | BreakpointsWindow* window = dynamic_cast<BreakpointsWindow*>(widget); |
| 113 | |
| 114 | QActionGroup* typeGroup = window->findChild<QActionGroup*>("typegroup"); |
| 115 | typeGroup->actions()[m_bwType]->trigger(); |
| 116 | } |
| 117 | |
| 118 | |
| 119 | void BreakpointsWindowQtConfig::addToXmlDataNode(xml_data_node* node) const |
| 120 | { |
| 121 | WindowQtConfig::addToXmlDataNode(node); |
| 122 | xml_set_attribute_int(node, "bwtype", m_bwType); |
| 123 | } |
| 124 | |
| 125 | |
| 126 | void BreakpointsWindowQtConfig::recoverFromXmlNode(xml_data_node* node) |
| 127 | { |
| 128 | WindowQtConfig::recoverFromXmlNode(node); |
| 129 | m_bwType = xml_get_attribute_int(node, "bwtype", m_bwType); |
| 130 | } |
trunk/src/osd/modules/debugger/qt/dasmwindow.c
| r0 | r243595 | |
| 1 | #define NO_MEM_TRACKING |
| 2 | |
| 3 | #include "dasmwindow.h" |
| 4 | |
| 5 | #include "debug/debugcon.h" |
| 6 | #include "debug/debugcpu.h" |
| 7 | #include "debug/dvdisasm.h" |
| 8 | |
| 9 | |
| 10 | DasmWindow::DasmWindow(running_machine* machine, QWidget* parent) : |
| 11 | WindowQt(machine, NULL) |
| 12 | { |
| 13 | setWindowTitle("Debug: Disassembly View"); |
| 14 | |
| 15 | if (parent != NULL) |
| 16 | { |
| 17 | QPoint parentPos = parent->pos(); |
| 18 | setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400); |
| 19 | } |
| 20 | |
| 21 | // |
| 22 | // The main frame and its input and log widgets |
| 23 | // |
| 24 | QFrame* mainWindowFrame = new QFrame(this); |
| 25 | |
| 26 | // The top frame & groupbox that contains the input widgets |
| 27 | QFrame* topSubFrame = new QFrame(mainWindowFrame); |
| 28 | |
| 29 | // The input edit |
| 30 | m_inputEdit = new QLineEdit(topSubFrame); |
| 31 | connect(m_inputEdit, SIGNAL(returnPressed()), this, SLOT(expressionSubmitted())); |
| 32 | |
| 33 | // The cpu combo box |
| 34 | m_cpuComboBox = new QComboBox(topSubFrame); |
| 35 | m_cpuComboBox->setObjectName("cpu"); |
| 36 | m_cpuComboBox->setMinimumWidth(300); |
| 37 | connect(m_cpuComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(cpuChanged(int))); |
| 38 | |
| 39 | // The main disasm window |
| 40 | m_dasmView = new DebuggerView(DVT_DISASSEMBLY, |
| 41 | m_machine, |
| 42 | this); |
| 43 | |
| 44 | // Force a recompute of the disassembly region |
| 45 | downcast<debug_view_disasm*>(m_dasmView->view())->set_expression("curpc"); |
| 46 | |
| 47 | // Populate the combo box & set the proper cpu |
| 48 | populateComboBox(); |
| 49 | //const debug_view_source *source = mem->views[0]->view->source_for_device(curcpu); |
| 50 | //gtk_combo_box_set_active(zone_w, mem->views[0]->view->source_list().indexof(*source)); |
| 51 | //mem->views[0]->view->set_source(*source); |
| 52 | |
| 53 | |
| 54 | // Layout |
| 55 | QHBoxLayout* subLayout = new QHBoxLayout(topSubFrame); |
| 56 | subLayout->addWidget(m_inputEdit); |
| 57 | subLayout->addWidget(m_cpuComboBox); |
| 58 | subLayout->setSpacing(3); |
| 59 | subLayout->setContentsMargins(2,2,2,2); |
| 60 | |
| 61 | QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame); |
| 62 | vLayout->setSpacing(3); |
| 63 | vLayout->setContentsMargins(2,2,2,2); |
| 64 | vLayout->addWidget(topSubFrame); |
| 65 | vLayout->addWidget(m_dasmView); |
| 66 | |
| 67 | setCentralWidget(mainWindowFrame); |
| 68 | |
| 69 | // |
| 70 | // Menu bars |
| 71 | // |
| 72 | // Create two commands |
| 73 | QAction* breakpointSetAct = new QAction("Toggle Breakpoint At Cursor", this); |
| 74 | QAction* runToCursorAct = new QAction("Run To Cursor", this); |
| 75 | breakpointSetAct->setShortcut(Qt::Key_F9); |
| 76 | runToCursorAct->setShortcut(Qt::Key_F4); |
| 77 | connect(breakpointSetAct, SIGNAL(triggered(bool)), this, SLOT(toggleBreakpointAtCursor(bool))); |
| 78 | connect(runToCursorAct, SIGNAL(triggered(bool)), this, SLOT(runToCursor(bool))); |
| 79 | |
| 80 | // Right bar options |
| 81 | QActionGroup* rightBarGroup = new QActionGroup(this); |
| 82 | rightBarGroup->setObjectName("rightbargroup"); |
| 83 | QAction* rightActRaw = new QAction("Raw Opcodes", this); |
| 84 | QAction* rightActEncrypted = new QAction("Encrypted Opcodes", this); |
| 85 | QAction* rightActComments = new QAction("Comments", this); |
| 86 | rightActRaw->setCheckable(true); |
| 87 | rightActEncrypted->setCheckable(true); |
| 88 | rightActComments->setCheckable(true); |
| 89 | rightActRaw->setActionGroup(rightBarGroup); |
| 90 | rightActEncrypted->setActionGroup(rightBarGroup); |
| 91 | rightActComments->setActionGroup(rightBarGroup); |
| 92 | rightActRaw->setShortcut(QKeySequence("Ctrl+R")); |
| 93 | rightActEncrypted->setShortcut(QKeySequence("Ctrl+E")); |
| 94 | rightActComments->setShortcut(QKeySequence("Ctrl+C")); |
| 95 | rightActRaw->setChecked(true); |
| 96 | connect(rightBarGroup, SIGNAL(triggered(QAction*)), this, SLOT(rightBarChanged(QAction*))); |
| 97 | |
| 98 | // Assemble the options menu |
| 99 | QMenu* optionsMenu = menuBar()->addMenu("&Options"); |
| 100 | optionsMenu->addAction(breakpointSetAct); |
| 101 | optionsMenu->addAction(runToCursorAct); |
| 102 | optionsMenu->addSeparator(); |
| 103 | optionsMenu->addActions(rightBarGroup->actions()); |
| 104 | } |
| 105 | |
| 106 | |
| 107 | DasmWindow::~DasmWindow() |
| 108 | { |
| 109 | } |
| 110 | |
| 111 | |
| 112 | void DasmWindow::cpuChanged(int index) |
| 113 | { |
| 114 | m_dasmView->view()->set_source(*m_dasmView->view()->source_list().find(index)); |
| 115 | m_dasmView->viewport()->update(); |
| 116 | } |
| 117 | |
| 118 | |
| 119 | void DasmWindow::expressionSubmitted() |
| 120 | { |
| 121 | const QString expression = m_inputEdit->text(); |
| 122 | downcast<debug_view_disasm*>(m_dasmView->view())->set_expression(expression.toLocal8Bit().data()); |
| 123 | m_dasmView->viewport()->update(); |
| 124 | } |
| 125 | |
| 126 | |
| 127 | void DasmWindow::toggleBreakpointAtCursor(bool changedTo) |
| 128 | { |
| 129 | if (m_dasmView->view()->cursor_visible()) |
| 130 | { |
| 131 | if (debug_cpu_get_visible_cpu(*m_machine) == m_dasmView->view()->source()->device()) |
| 132 | { |
| 133 | offs_t address = downcast<debug_view_disasm *>(m_dasmView->view())->selected_address(); |
| 134 | device_debug *cpuinfo = m_dasmView->view()->source()->device()->debug(); |
| 135 | |
| 136 | // Find an existing breakpoint at this address |
| 137 | INT32 bpindex = -1; |
| 138 | for (device_debug::breakpoint* bp = cpuinfo->breakpoint_first(); |
| 139 | bp != NULL; |
| 140 | bp = bp->next()) |
| 141 | { |
| 142 | if (address == bp->address()) |
| 143 | { |
| 144 | bpindex = bp->index(); |
| 145 | break; |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | // If none exists, add a new one |
| 150 | astring command; |
| 151 | if (bpindex == -1) |
| 152 | { |
| 153 | command.printf("bpset 0x%X", address); |
| 154 | } |
| 155 | else |
| 156 | { |
| 157 | command.printf("bpclear 0x%X", bpindex); |
| 158 | } |
| 159 | debug_console_execute_command(*m_machine, command, 1); |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | refreshAll(); |
| 164 | } |
| 165 | |
| 166 | |
| 167 | void DasmWindow::runToCursor(bool changedTo) |
| 168 | { |
| 169 | if (m_dasmView->view()->cursor_visible()) |
| 170 | { |
| 171 | if (debug_cpu_get_visible_cpu(*m_machine) == m_dasmView->view()->source()->device()) |
| 172 | { |
| 173 | offs_t address = downcast<debug_view_disasm*>(m_dasmView->view())->selected_address(); |
| 174 | astring command; |
| 175 | command.printf("go 0x%X", address); |
| 176 | debug_console_execute_command(*m_machine, command, 1); |
| 177 | } |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | |
| 182 | void DasmWindow::rightBarChanged(QAction* changedTo) |
| 183 | { |
| 184 | debug_view_disasm* dasmView = downcast<debug_view_disasm*>(m_dasmView->view()); |
| 185 | if (changedTo->text() == "Raw Opcodes") |
| 186 | { |
| 187 | dasmView->set_right_column(DASM_RIGHTCOL_RAW); |
| 188 | } |
| 189 | else if (changedTo->text() == "Encrypted Opcodes") |
| 190 | { |
| 191 | dasmView->set_right_column(DASM_RIGHTCOL_ENCRYPTED); |
| 192 | } |
| 193 | else if (changedTo->text() == "Comments") |
| 194 | { |
| 195 | dasmView->set_right_column(DASM_RIGHTCOL_COMMENTS); |
| 196 | } |
| 197 | m_dasmView->viewport()->update(); |
| 198 | } |
| 199 | |
| 200 | |
| 201 | void DasmWindow::populateComboBox() |
| 202 | { |
| 203 | if (m_dasmView == NULL) |
| 204 | return; |
| 205 | |
| 206 | m_cpuComboBox->clear(); |
| 207 | for (const debug_view_source* source = m_dasmView->view()->first_source(); |
| 208 | source != NULL; |
| 209 | source = source->next()) |
| 210 | { |
| 211 | m_cpuComboBox->addItem(source->name()); |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | |
| 216 | //========================================================================= |
| 217 | // DasmWindowQtConfig |
| 218 | //========================================================================= |
| 219 | void DasmWindowQtConfig::buildFromQWidget(QWidget* widget) |
| 220 | { |
| 221 | WindowQtConfig::buildFromQWidget(widget); |
| 222 | DasmWindow* window = dynamic_cast<DasmWindow*>(widget); |
| 223 | QComboBox* cpu = window->findChild<QComboBox*>("cpu"); |
| 224 | m_cpu = cpu->currentIndex(); |
| 225 | |
| 226 | QActionGroup* rightBarGroup = window->findChild<QActionGroup*>("rightbargroup"); |
| 227 | if (rightBarGroup->checkedAction()->text() == "Raw Opcodes") |
| 228 | m_rightBar = 0; |
| 229 | else if (rightBarGroup->checkedAction()->text() == "Encrypted Opcodes") |
| 230 | m_rightBar = 1; |
| 231 | else if (rightBarGroup->checkedAction()->text() == "Comments") |
| 232 | m_rightBar = 2; |
| 233 | } |
| 234 | |
| 235 | void DasmWindowQtConfig::applyToQWidget(QWidget* widget) |
| 236 | { |
| 237 | WindowQtConfig::applyToQWidget(widget); |
| 238 | DasmWindow* window = dynamic_cast<DasmWindow*>(widget); |
| 239 | QComboBox* cpu = window->findChild<QComboBox*>("cpu"); |
| 240 | cpu->setCurrentIndex(m_cpu); |
| 241 | |
| 242 | QActionGroup* rightBarGroup = window->findChild<QActionGroup*>("rightbargroup"); |
| 243 | rightBarGroup->actions()[m_rightBar]->trigger(); |
| 244 | } |
| 245 | |
| 246 | void DasmWindowQtConfig::addToXmlDataNode(xml_data_node* node) const |
| 247 | { |
| 248 | WindowQtConfig::addToXmlDataNode(node); |
| 249 | xml_set_attribute_int(node, "cpu", m_cpu); |
| 250 | xml_set_attribute_int(node, "rightbar", m_rightBar); |
| 251 | } |
| 252 | |
| 253 | void DasmWindowQtConfig::recoverFromXmlNode(xml_data_node* node) |
| 254 | { |
| 255 | WindowQtConfig::recoverFromXmlNode(node); |
| 256 | m_cpu = xml_get_attribute_int(node, "cpu", m_cpu); |
| 257 | m_rightBar = xml_get_attribute_int(node, "rightbar", m_rightBar); |
| 258 | } |
trunk/src/osd/modules/debugger/qt/debuggerview.c
| r0 | r243595 | |
| 1 | #define NO_MEM_TRACKING |
| 2 | |
| 3 | #include "debuggerview.h" |
| 4 | |
| 5 | DebuggerView::DebuggerView(const debug_view_type& type, |
| 6 | running_machine* machine, |
| 7 | QWidget* parent) : |
| 8 | QAbstractScrollArea(parent), |
| 9 | m_preferBottom(false), |
| 10 | m_view(NULL), |
| 11 | m_machine(machine) |
| 12 | { |
| 13 | // I like setting the font per-view since it doesn't override the menuing fonts. |
| 14 | QFont viewFontRequest("Courier New"); |
| 15 | viewFontRequest.setFixedPitch(true); |
| 16 | viewFontRequest.setPointSize(11); |
| 17 | setFont(viewFontRequest); |
| 18 | |
| 19 | m_view = m_machine->debug_view().alloc_view(type, |
| 20 | DebuggerView::debuggerViewUpdate, |
| 21 | this); |
| 22 | |
| 23 | connect(verticalScrollBar(), SIGNAL(valueChanged(int)), |
| 24 | this, SLOT(verticalScrollSlot(int))); |
| 25 | connect(horizontalScrollBar(), SIGNAL(valueChanged(int)), |
| 26 | this, SLOT(horizontalScrollSlot(int))); |
| 27 | } |
| 28 | |
| 29 | |
| 30 | DebuggerView::~DebuggerView() |
| 31 | { |
| 32 | if (m_machine && m_view) |
| 33 | m_machine->debug_view().free_view(*m_view); |
| 34 | } |
| 35 | |
| 36 | // TODO: remove this version no later than January 1, 2015 |
| 37 | #if QT_VERSION < QT_VERSION_CHECK(4, 7, 0) |
| 38 | void DebuggerView::paintEvent(QPaintEvent* event) |
| 39 | { |
| 40 | // Tell the MAME debug view how much real estate is available |
| 41 | QFontMetrics actualFont = fontMetrics(); |
| 42 | const int fontWidth = MAX(1, actualFont.width('_')); |
| 43 | const int fontHeight = MAX(1, actualFont.height()); |
| 44 | m_view->set_visible_size(debug_view_xy(width()/fontWidth, height()/fontHeight)); |
| 45 | |
| 46 | |
| 47 | // Handle the scroll bars |
| 48 | const int horizontalScrollCharDiff = m_view->total_size().x - m_view->visible_size().x; |
| 49 | const int horizontalScrollSize = horizontalScrollCharDiff < 0 ? 0 : horizontalScrollCharDiff; |
| 50 | horizontalScrollBar()->setRange(0, horizontalScrollSize); |
| 51 | |
| 52 | // If the horizontal scroll bar appears, make sure to adjust the vertical scrollbar accordingly |
| 53 | const int verticalScrollAdjust = horizontalScrollSize > 0 ? 1 : 0; |
| 54 | |
| 55 | const int verticalScrollCharDiff = m_view->total_size().y - m_view->visible_size().y; |
| 56 | const int verticalScrollSize = verticalScrollCharDiff < 0 ? 0 : verticalScrollCharDiff+verticalScrollAdjust; |
| 57 | bool atEnd = false; |
| 58 | if (verticalScrollBar()->value() == verticalScrollBar()->maximum()) |
| 59 | { |
| 60 | atEnd = true; |
| 61 | } |
| 62 | verticalScrollBar()->setRange(0, verticalScrollSize); |
| 63 | if (m_preferBottom && atEnd) |
| 64 | { |
| 65 | verticalScrollBar()->setValue(verticalScrollSize); |
| 66 | } |
| 67 | |
| 68 | |
| 69 | // Draw the viewport widget |
| 70 | QPainter painter(viewport()); |
| 71 | painter.fillRect(0, 0, width(), height(), QBrush(Qt::white)); |
| 72 | painter.setBackgroundMode(Qt::OpaqueMode); |
| 73 | painter.setBackground(QColor(255,255,255)); |
| 74 | |
| 75 | // Background control |
| 76 | QBrush bgBrush; |
| 77 | bgBrush.setStyle(Qt::SolidPattern); |
| 78 | painter.setPen(QPen(QColor(0,0,0))); |
| 79 | |
| 80 | size_t viewDataOffset = 0; |
| 81 | const debug_view_xy& visibleCharDims = m_view->visible_size(); |
| 82 | for (int y = 0; y < visibleCharDims.y; y++) |
| 83 | { |
| 84 | for (int x = 0; x < visibleCharDims.x; x++) |
| 85 | { |
| 86 | const unsigned char textAttr = m_view->viewdata()[viewDataOffset].attrib; |
| 87 | |
| 88 | if (x == 0 || textAttr != m_view->viewdata()[viewDataOffset-1].attrib) |
| 89 | { |
| 90 | // Text color handling |
| 91 | QColor fgColor(0,0,0); |
| 92 | QColor bgColor(255,255,255); |
| 93 | |
| 94 | if(textAttr & DCA_VISITED) |
| 95 | { |
| 96 | bgColor.setRgb(0xc6, 0xe2, 0xff); |
| 97 | } |
| 98 | if(textAttr & DCA_ANCILLARY) |
| 99 | { |
| 100 | bgColor.setRgb(0xe0, 0xe0, 0xe0); |
| 101 | } |
| 102 | if(textAttr & DCA_SELECTED) |
| 103 | { |
| 104 | bgColor.setRgb(0xff, 0x80, 0x80); |
| 105 | } |
| 106 | if(textAttr & DCA_CURRENT) |
| 107 | { |
| 108 | bgColor.setRgb(0xff, 0xff, 0x00); |
| 109 | } |
| 110 | if ((textAttr & DCA_SELECTED) && (textAttr & DCA_CURRENT)) |
| 111 | { |
| 112 | bgColor.setRgb(0xff,0xc0,0x80); |
| 113 | } |
| 114 | if(textAttr & DCA_CHANGED) |
| 115 | { |
| 116 | fgColor.setRgb(0xff, 0x00, 0x00); |
| 117 | } |
| 118 | if(textAttr & DCA_INVALID) |
| 119 | { |
| 120 | fgColor.setRgb(0x00, 0x00, 0xff); |
| 121 | } |
| 122 | if(textAttr & DCA_DISABLED) |
| 123 | { |
| 124 | fgColor.setRgb((fgColor.red() + bgColor.red()) >> 1, |
| 125 | (fgColor.green() + bgColor.green()) >> 1, |
| 126 | (fgColor.blue() + bgColor.blue()) >> 1); |
| 127 | } |
| 128 | if(textAttr & DCA_COMMENT) |
| 129 | { |
| 130 | fgColor.setRgb(0x00, 0x80, 0x00); |
| 131 | } |
| 132 | |
| 133 | bgBrush.setColor(bgColor); |
| 134 | painter.setBackground(bgBrush); |
| 135 | painter.setPen(QPen(fgColor)); |
| 136 | } |
| 137 | |
| 138 | // Your character is not guaranteed to take up the entire fontWidth x fontHeight, so fill before. |
| 139 | painter.fillRect(x*fontWidth, y*fontHeight, fontWidth, fontHeight, bgBrush); |
| 140 | |
| 141 | // There is a touchy interplay between font height, drawing difference, visible position, etc |
| 142 | // Fonts don't get drawn "down and to the left" like boxes, so some wiggling is needed. |
| 143 | painter.drawText(x*fontWidth, |
| 144 | (y*fontHeight + (fontHeight*0.80)), |
| 145 | QString(m_view->viewdata()[viewDataOffset].byte)); |
| 146 | viewDataOffset++; |
| 147 | } |
| 148 | } |
| 149 | } |
| 150 | #else |
| 151 | void DebuggerView::paintEvent(QPaintEvent* event) |
| 152 | { |
| 153 | // Tell the MAME debug view how much real estate is available |
| 154 | QFontMetrics actualFont = fontMetrics(); |
| 155 | const double fontWidth = actualFont.width(QString(100, '_')) / 100.; |
| 156 | const int fontHeight = MAX(1, actualFont.height()); |
| 157 | m_view->set_visible_size(debug_view_xy(width()/fontWidth, height()/fontHeight)); |
| 158 | |
| 159 | |
| 160 | // Handle the scroll bars |
| 161 | const int horizontalScrollCharDiff = m_view->total_size().x - m_view->visible_size().x; |
| 162 | const int horizontalScrollSize = horizontalScrollCharDiff < 0 ? 0 : horizontalScrollCharDiff; |
| 163 | horizontalScrollBar()->setRange(0, horizontalScrollSize); |
| 164 | |
| 165 | // If the horizontal scroll bar appears, make sure to adjust the vertical scrollbar accordingly |
| 166 | const int verticalScrollAdjust = horizontalScrollSize > 0 ? 1 : 0; |
| 167 | |
| 168 | const int verticalScrollCharDiff = m_view->total_size().y - m_view->visible_size().y; |
| 169 | const int verticalScrollSize = verticalScrollCharDiff < 0 ? 0 : verticalScrollCharDiff+verticalScrollAdjust; |
| 170 | bool atEnd = false; |
| 171 | if (verticalScrollBar()->value() == verticalScrollBar()->maximum()) |
| 172 | { |
| 173 | atEnd = true; |
| 174 | } |
| 175 | verticalScrollBar()->setRange(0, verticalScrollSize); |
| 176 | if (m_preferBottom && atEnd) |
| 177 | { |
| 178 | verticalScrollBar()->setValue(verticalScrollSize); |
| 179 | } |
| 180 | |
| 181 | |
| 182 | // Draw the viewport widget |
| 183 | QPainter painter(viewport()); |
| 184 | painter.fillRect(0, 0, width(), height(), QBrush(Qt::white)); |
| 185 | painter.setBackgroundMode(Qt::OpaqueMode); |
| 186 | painter.setBackground(QColor(255,255,255)); |
| 187 | |
| 188 | // Background control |
| 189 | QBrush bgBrush; |
| 190 | bgBrush.setStyle(Qt::SolidPattern); |
| 191 | painter.setPen(QPen(QColor(0,0,0))); |
| 192 | |
| 193 | size_t viewDataOffset = 0; |
| 194 | const debug_view_xy& visibleCharDims = m_view->visible_size(); |
| 195 | const debug_view_char* viewdata = m_view->viewdata(); |
| 196 | for (int y = 0; y < visibleCharDims.y; y++) |
| 197 | { |
| 198 | int width = 1; |
| 199 | for (int x = 0; x < visibleCharDims.x; viewDataOffset += width, x += width) |
| 200 | { |
| 201 | const unsigned char textAttr = viewdata[viewDataOffset].attrib; |
| 202 | |
| 203 | // Text color handling |
| 204 | QColor fgColor(0,0,0); |
| 205 | QColor bgColor(255,255,255); |
| 206 | |
| 207 | if(textAttr & DCA_VISITED) |
| 208 | { |
| 209 | bgColor.setRgb(0xc6, 0xe2, 0xff); |
| 210 | } |
| 211 | if(textAttr & DCA_ANCILLARY) |
| 212 | { |
| 213 | bgColor.setRgb(0xe0, 0xe0, 0xe0); |
| 214 | } |
| 215 | if(textAttr & DCA_SELECTED) |
| 216 | { |
| 217 | bgColor.setRgb(0xff, 0x80, 0x80); |
| 218 | } |
| 219 | if(textAttr & DCA_CURRENT) |
| 220 | { |
| 221 | bgColor.setRgb(0xff, 0xff, 0x00); |
| 222 | } |
| 223 | if ((textAttr & DCA_SELECTED) && (textAttr & DCA_CURRENT)) |
| 224 | { |
| 225 | bgColor.setRgb(0xff,0xc0,0x80); |
| 226 | } |
| 227 | if(textAttr & DCA_CHANGED) |
| 228 | { |
| 229 | fgColor.setRgb(0xff, 0x00, 0x00); |
| 230 | } |
| 231 | if(textAttr & DCA_INVALID) |
| 232 | { |
| 233 | fgColor.setRgb(0x00, 0x00, 0xff); |
| 234 | } |
| 235 | if(textAttr & DCA_DISABLED) |
| 236 | { |
| 237 | fgColor.setRgb((fgColor.red() + bgColor.red()) >> 1, |
| 238 | (fgColor.green() + bgColor.green()) >> 1, |
| 239 | (fgColor.blue() + bgColor.blue()) >> 1); |
| 240 | } |
| 241 | if(textAttr & DCA_COMMENT) |
| 242 | { |
| 243 | fgColor.setRgb(0x00, 0x80, 0x00); |
| 244 | } |
| 245 | |
| 246 | bgBrush.setColor(bgColor); |
| 247 | painter.setBackground(bgBrush); |
| 248 | painter.setPen(QPen(fgColor)); |
| 249 | |
| 250 | QString text(QChar(viewdata[viewDataOffset].byte)); |
| 251 | for (width = 1; x + width < visibleCharDims.x; width++) |
| 252 | { |
| 253 | if (textAttr != viewdata[viewDataOffset + width].attrib) |
| 254 | break; |
| 255 | text.append(QChar(viewdata[viewDataOffset + width].byte)); |
| 256 | } |
| 257 | |
| 258 | // Your characters are not guaranteed to take up the entire length x fontWidth x fontHeight, so fill before. |
| 259 | painter.fillRect(x*fontWidth, y*fontHeight, width*fontWidth, fontHeight, bgBrush); |
| 260 | |
| 261 | // There is a touchy interplay between font height, drawing difference, visible position, etc |
| 262 | // Fonts don't get drawn "down and to the left" like boxes, so some wiggling is needed. |
| 263 | painter.drawText(x*fontWidth, (y*fontHeight + (fontHeight*0.80)), text); |
| 264 | } |
| 265 | } |
| 266 | } |
| 267 | #endif |
| 268 | |
| 269 | void DebuggerView::keyPressEvent(QKeyEvent* event) |
| 270 | { |
| 271 | if (m_view == NULL) |
| 272 | return QWidget::keyPressEvent(event); |
| 273 | |
| 274 | Qt::KeyboardModifiers keyMods = QApplication::keyboardModifiers(); |
| 275 | const bool ctrlDown = keyMods.testFlag(Qt::ControlModifier); |
| 276 | |
| 277 | int keyPress = -1; |
| 278 | switch (event->key()) |
| 279 | { |
| 280 | case Qt::Key_Up: |
| 281 | keyPress = DCH_UP; |
| 282 | break; |
| 283 | case Qt::Key_Down: |
| 284 | keyPress = DCH_DOWN; |
| 285 | break; |
| 286 | case Qt::Key_Left: |
| 287 | keyPress = DCH_LEFT; |
| 288 | if (ctrlDown) keyPress = DCH_CTRLLEFT; |
| 289 | break; |
| 290 | case Qt::Key_Right: |
| 291 | keyPress = DCH_RIGHT; |
| 292 | if (ctrlDown) keyPress = DCH_CTRLRIGHT; |
| 293 | break; |
| 294 | case Qt::Key_PageUp: |
| 295 | keyPress = DCH_PUP; |
| 296 | break; |
| 297 | case Qt::Key_PageDown: |
| 298 | keyPress = DCH_PDOWN; |
| 299 | break; |
| 300 | case Qt::Key_Home: |
| 301 | keyPress = DCH_HOME; |
| 302 | if (ctrlDown) keyPress = DCH_CTRLHOME; |
| 303 | break; |
| 304 | case Qt::Key_End: |
| 305 | keyPress = DCH_END; |
| 306 | if (ctrlDown) keyPress = DCH_CTRLEND; |
| 307 | break; |
| 308 | case Qt::Key_0: keyPress = '0'; break; |
| 309 | case Qt::Key_1: keyPress = '1'; break; |
| 310 | case Qt::Key_2: keyPress = '2'; break; |
| 311 | case Qt::Key_3: keyPress = '3'; break; |
| 312 | case Qt::Key_4: keyPress = '4'; break; |
| 313 | case Qt::Key_5: keyPress = '5'; break; |
| 314 | case Qt::Key_6: keyPress = '6'; break; |
| 315 | case Qt::Key_7: keyPress = '7'; break; |
| 316 | case Qt::Key_8: keyPress = '8'; break; |
| 317 | case Qt::Key_9: keyPress = '9'; break; |
| 318 | case Qt::Key_A: keyPress = 'a'; break; |
| 319 | case Qt::Key_B: keyPress = 'b'; break; |
| 320 | case Qt::Key_C: keyPress = 'c'; break; |
| 321 | case Qt::Key_D: keyPress = 'd'; break; |
| 322 | case Qt::Key_E: keyPress = 'e'; break; |
| 323 | case Qt::Key_F: keyPress = 'f'; break; |
| 324 | default: |
| 325 | return QWidget::keyPressEvent(event); |
| 326 | } |
| 327 | |
| 328 | m_view->set_cursor_visible(true); |
| 329 | m_view->process_char(keyPress); |
| 330 | |
| 331 | // Catch the view up with the cursor |
| 332 | verticalScrollBar()->setValue(m_view->visible_position().y); |
| 333 | |
| 334 | viewport()->update(); |
| 335 | update(); |
| 336 | } |
| 337 | |
| 338 | |
| 339 | void DebuggerView::mousePressEvent(QMouseEvent* event) |
| 340 | { |
| 341 | if (m_view == NULL) |
| 342 | return; |
| 343 | |
| 344 | if (event->button() == Qt::LeftButton) |
| 345 | { |
| 346 | QFontMetrics actualFont = fontMetrics(); |
| 347 | const double fontWidth = actualFont.width(QString(100, '_')) / 100.; |
| 348 | const int fontHeight = MAX(1, actualFont.height()); |
| 349 | |
| 350 | debug_view_xy topLeft = m_view->visible_position(); |
| 351 | debug_view_xy clickViewPosition; |
| 352 | clickViewPosition.x = topLeft.x + (event->x() / fontWidth); |
| 353 | clickViewPosition.y = topLeft.y + (event->y() / fontHeight); |
| 354 | m_view->process_click(DCK_LEFT_CLICK, clickViewPosition); |
| 355 | |
| 356 | viewport()->update(); |
| 357 | update(); |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | |
| 362 | void DebuggerView::verticalScrollSlot(int value) |
| 363 | { |
| 364 | m_view->set_visible_position(debug_view_xy(horizontalScrollBar()->value(), value)); |
| 365 | } |
| 366 | |
| 367 | |
| 368 | void DebuggerView::horizontalScrollSlot(int value) |
| 369 | { |
| 370 | m_view->set_visible_position(debug_view_xy(value, verticalScrollBar()->value())); |
| 371 | } |
| 372 | |
| 373 | |
| 374 | void DebuggerView::debuggerViewUpdate(debug_view& debugView, void* osdPrivate) |
| 375 | { |
| 376 | // Get a handle to the DebuggerView being updated & redraw |
| 377 | DebuggerView* dView = (DebuggerView*)osdPrivate; |
| 378 | dView->verticalScrollBar()->setValue(dView->view()->visible_position().y); |
| 379 | dView->horizontalScrollBar()->setValue(dView->view()->visible_position().x); |
| 380 | dView->viewport()->update(); |
| 381 | dView->update(); |
| 382 | } |
trunk/src/osd/modules/debugger/qt/debugqtbreakpointswindow.c
| r243594 | r243595 | |
| 1 | | #define NO_MEM_TRACKING |
| 2 | | |
| 3 | | #include "debugqtbreakpointswindow.h" |
| 4 | | |
| 5 | | #include "debug/debugcon.h" |
| 6 | | #include "debug/debugcpu.h" |
| 7 | | #include "debug/dvbpoints.h" |
| 8 | | #include "debug/dvwpoints.h" |
| 9 | | |
| 10 | | |
| 11 | | BreakpointsWindow::BreakpointsWindow(running_machine* machine, QWidget* parent) : |
| 12 | | WindowQt(machine, NULL) |
| 13 | | { |
| 14 | | setWindowTitle("Debug: All Breakpoints"); |
| 15 | | |
| 16 | | if (parent != NULL) |
| 17 | | { |
| 18 | | QPoint parentPos = parent->pos(); |
| 19 | | setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400); |
| 20 | | } |
| 21 | | |
| 22 | | // |
| 23 | | // The main frame and its input and breakpoints widgets |
| 24 | | // |
| 25 | | QFrame* mainWindowFrame = new QFrame(this); |
| 26 | | |
| 27 | | // The main breakpoints view |
| 28 | | m_breakpointsView = new DebuggerView(DVT_BREAK_POINTS, m_machine, this); |
| 29 | | |
| 30 | | // Layout |
| 31 | | QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame); |
| 32 | | vLayout->setObjectName("vlayout"); |
| 33 | | vLayout->setSpacing(3); |
| 34 | | vLayout->setContentsMargins(2,2,2,2); |
| 35 | | vLayout->addWidget(m_breakpointsView); |
| 36 | | |
| 37 | | setCentralWidget(mainWindowFrame); |
| 38 | | |
| 39 | | // |
| 40 | | // Menu bars |
| 41 | | // |
| 42 | | QActionGroup* typeGroup = new QActionGroup(this); |
| 43 | | typeGroup->setObjectName("typegroup"); |
| 44 | | QAction* typeBreak = new QAction("Breakpoints", this); |
| 45 | | typeBreak->setObjectName("typebreak"); |
| 46 | | QAction* typeWatch = new QAction("Watchpoints", this); |
| 47 | | typeWatch->setObjectName("typewatch"); |
| 48 | | typeBreak->setCheckable(true); |
| 49 | | typeWatch->setCheckable(true); |
| 50 | | typeBreak->setActionGroup(typeGroup); |
| 51 | | typeWatch->setActionGroup(typeGroup); |
| 52 | | typeBreak->setShortcut(QKeySequence("Ctrl+1")); |
| 53 | | typeWatch->setShortcut(QKeySequence("Ctrl+2")); |
| 54 | | typeBreak->setChecked(true); |
| 55 | | connect(typeGroup, SIGNAL(triggered(QAction*)), this, SLOT(typeChanged(QAction*))); |
| 56 | | |
| 57 | | // Assemble the options menu |
| 58 | | QMenu* optionsMenu = menuBar()->addMenu("&Options"); |
| 59 | | optionsMenu->addActions(typeGroup->actions()); |
| 60 | | } |
| 61 | | |
| 62 | | |
| 63 | | BreakpointsWindow::~BreakpointsWindow() |
| 64 | | { |
| 65 | | } |
| 66 | | |
| 67 | | |
| 68 | | void BreakpointsWindow::typeChanged(QAction* changedTo) |
| 69 | | { |
| 70 | | // Clean |
| 71 | | delete m_breakpointsView; |
| 72 | | m_breakpointsView = NULL; |
| 73 | | |
| 74 | | // Create |
| 75 | | if (changedTo->text() == "Breakpoints") |
| 76 | | { |
| 77 | | m_breakpointsView = new DebuggerView(DVT_BREAK_POINTS, m_machine, this); |
| 78 | | setWindowTitle("Debug: All Breakpoints"); |
| 79 | | } |
| 80 | | else if (changedTo->text() == "Watchpoints") |
| 81 | | { |
| 82 | | m_breakpointsView = new DebuggerView(DVT_WATCH_POINTS, m_machine, this); |
| 83 | | setWindowTitle("Debug: All Watchpoints"); |
| 84 | | } |
| 85 | | |
| 86 | | // Re-register |
| 87 | | QVBoxLayout* layout = findChild<QVBoxLayout*>("vlayout"); |
| 88 | | layout->addWidget(m_breakpointsView); |
| 89 | | } |
| 90 | | |
| 91 | | |
| 92 | | |
| 93 | | //========================================================================= |
| 94 | | // BreakpointsWindowQtConfig |
| 95 | | //========================================================================= |
| 96 | | void BreakpointsWindowQtConfig::buildFromQWidget(QWidget* widget) |
| 97 | | { |
| 98 | | WindowQtConfig::buildFromQWidget(widget); |
| 99 | | BreakpointsWindow* window = dynamic_cast<BreakpointsWindow*>(widget); |
| 100 | | |
| 101 | | QActionGroup* typeGroup = window->findChild<QActionGroup*>("typegroup"); |
| 102 | | if (typeGroup->checkedAction()->text() == "Breakpoints") |
| 103 | | m_bwType = 0; |
| 104 | | else if (typeGroup->checkedAction()->text() == "Watchpoints") |
| 105 | | m_bwType = 1; |
| 106 | | } |
| 107 | | |
| 108 | | |
| 109 | | void BreakpointsWindowQtConfig::applyToQWidget(QWidget* widget) |
| 110 | | { |
| 111 | | WindowQtConfig::applyToQWidget(widget); |
| 112 | | BreakpointsWindow* window = dynamic_cast<BreakpointsWindow*>(widget); |
| 113 | | |
| 114 | | QActionGroup* typeGroup = window->findChild<QActionGroup*>("typegroup"); |
| 115 | | typeGroup->actions()[m_bwType]->trigger(); |
| 116 | | } |
| 117 | | |
| 118 | | |
| 119 | | void BreakpointsWindowQtConfig::addToXmlDataNode(xml_data_node* node) const |
| 120 | | { |
| 121 | | WindowQtConfig::addToXmlDataNode(node); |
| 122 | | xml_set_attribute_int(node, "bwtype", m_bwType); |
| 123 | | } |
| 124 | | |
| 125 | | |
| 126 | | void BreakpointsWindowQtConfig::recoverFromXmlNode(xml_data_node* node) |
| 127 | | { |
| 128 | | WindowQtConfig::recoverFromXmlNode(node); |
| 129 | | m_bwType = xml_get_attribute_int(node, "bwtype", m_bwType); |
| 130 | | } |
trunk/src/osd/modules/debugger/qt/debugqtdasmwindow.c
| r243594 | r243595 | |
| 1 | | #define NO_MEM_TRACKING |
| 2 | | |
| 3 | | #include "debugqtdasmwindow.h" |
| 4 | | |
| 5 | | #include "debug/debugcon.h" |
| 6 | | #include "debug/debugcpu.h" |
| 7 | | #include "debug/dvdisasm.h" |
| 8 | | |
| 9 | | |
| 10 | | DasmWindow::DasmWindow(running_machine* machine, QWidget* parent) : |
| 11 | | WindowQt(machine, NULL) |
| 12 | | { |
| 13 | | setWindowTitle("Debug: Disassembly View"); |
| 14 | | |
| 15 | | if (parent != NULL) |
| 16 | | { |
| 17 | | QPoint parentPos = parent->pos(); |
| 18 | | setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400); |
| 19 | | } |
| 20 | | |
| 21 | | // |
| 22 | | // The main frame and its input and log widgets |
| 23 | | // |
| 24 | | QFrame* mainWindowFrame = new QFrame(this); |
| 25 | | |
| 26 | | // The top frame & groupbox that contains the input widgets |
| 27 | | QFrame* topSubFrame = new QFrame(mainWindowFrame); |
| 28 | | |
| 29 | | // The input edit |
| 30 | | m_inputEdit = new QLineEdit(topSubFrame); |
| 31 | | connect(m_inputEdit, SIGNAL(returnPressed()), this, SLOT(expressionSubmitted())); |
| 32 | | |
| 33 | | // The cpu combo box |
| 34 | | m_cpuComboBox = new QComboBox(topSubFrame); |
| 35 | | m_cpuComboBox->setObjectName("cpu"); |
| 36 | | m_cpuComboBox->setMinimumWidth(300); |
| 37 | | connect(m_cpuComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(cpuChanged(int))); |
| 38 | | |
| 39 | | // The main disasm window |
| 40 | | m_dasmView = new DebuggerView(DVT_DISASSEMBLY, |
| 41 | | m_machine, |
| 42 | | this); |
| 43 | | |
| 44 | | // Force a recompute of the disassembly region |
| 45 | | downcast<debug_view_disasm*>(m_dasmView->view())->set_expression("curpc"); |
| 46 | | |
| 47 | | // Populate the combo box & set the proper cpu |
| 48 | | populateComboBox(); |
| 49 | | //const debug_view_source *source = mem->views[0]->view->source_for_device(curcpu); |
| 50 | | //gtk_combo_box_set_active(zone_w, mem->views[0]->view->source_list().indexof(*source)); |
| 51 | | //mem->views[0]->view->set_source(*source); |
| 52 | | |
| 53 | | |
| 54 | | // Layout |
| 55 | | QHBoxLayout* subLayout = new QHBoxLayout(topSubFrame); |
| 56 | | subLayout->addWidget(m_inputEdit); |
| 57 | | subLayout->addWidget(m_cpuComboBox); |
| 58 | | subLayout->setSpacing(3); |
| 59 | | subLayout->setContentsMargins(2,2,2,2); |
| 60 | | |
| 61 | | QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame); |
| 62 | | vLayout->setSpacing(3); |
| 63 | | vLayout->setContentsMargins(2,2,2,2); |
| 64 | | vLayout->addWidget(topSubFrame); |
| 65 | | vLayout->addWidget(m_dasmView); |
| 66 | | |
| 67 | | setCentralWidget(mainWindowFrame); |
| 68 | | |
| 69 | | // |
| 70 | | // Menu bars |
| 71 | | // |
| 72 | | // Create two commands |
| 73 | | QAction* breakpointSetAct = new QAction("Toggle Breakpoint At Cursor", this); |
| 74 | | QAction* runToCursorAct = new QAction("Run To Cursor", this); |
| 75 | | breakpointSetAct->setShortcut(Qt::Key_F9); |
| 76 | | runToCursorAct->setShortcut(Qt::Key_F4); |
| 77 | | connect(breakpointSetAct, SIGNAL(triggered(bool)), this, SLOT(toggleBreakpointAtCursor(bool))); |
| 78 | | connect(runToCursorAct, SIGNAL(triggered(bool)), this, SLOT(runToCursor(bool))); |
| 79 | | |
| 80 | | // Right bar options |
| 81 | | QActionGroup* rightBarGroup = new QActionGroup(this); |
| 82 | | rightBarGroup->setObjectName("rightbargroup"); |
| 83 | | QAction* rightActRaw = new QAction("Raw Opcodes", this); |
| 84 | | QAction* rightActEncrypted = new QAction("Encrypted Opcodes", this); |
| 85 | | QAction* rightActComments = new QAction("Comments", this); |
| 86 | | rightActRaw->setCheckable(true); |
| 87 | | rightActEncrypted->setCheckable(true); |
| 88 | | rightActComments->setCheckable(true); |
| 89 | | rightActRaw->setActionGroup(rightBarGroup); |
| 90 | | rightActEncrypted->setActionGroup(rightBarGroup); |
| 91 | | rightActComments->setActionGroup(rightBarGroup); |
| 92 | | rightActRaw->setShortcut(QKeySequence("Ctrl+R")); |
| 93 | | rightActEncrypted->setShortcut(QKeySequence("Ctrl+E")); |
| 94 | | rightActComments->setShortcut(QKeySequence("Ctrl+C")); |
| 95 | | rightActRaw->setChecked(true); |
| 96 | | connect(rightBarGroup, SIGNAL(triggered(QAction*)), this, SLOT(rightBarChanged(QAction*))); |
| 97 | | |
| 98 | | // Assemble the options menu |
| 99 | | QMenu* optionsMenu = menuBar()->addMenu("&Options"); |
| 100 | | optionsMenu->addAction(breakpointSetAct); |
| 101 | | optionsMenu->addAction(runToCursorAct); |
| 102 | | optionsMenu->addSeparator(); |
| 103 | | optionsMenu->addActions(rightBarGroup->actions()); |
| 104 | | } |
| 105 | | |
| 106 | | |
| 107 | | DasmWindow::~DasmWindow() |
| 108 | | { |
| 109 | | } |
| 110 | | |
| 111 | | |
| 112 | | void DasmWindow::cpuChanged(int index) |
| 113 | | { |
| 114 | | m_dasmView->view()->set_source(*m_dasmView->view()->source_list().find(index)); |
| 115 | | m_dasmView->viewport()->update(); |
| 116 | | } |
| 117 | | |
| 118 | | |
| 119 | | void DasmWindow::expressionSubmitted() |
| 120 | | { |
| 121 | | const QString expression = m_inputEdit->text(); |
| 122 | | downcast<debug_view_disasm*>(m_dasmView->view())->set_expression(expression.toLocal8Bit().data()); |
| 123 | | m_dasmView->viewport()->update(); |
| 124 | | } |
| 125 | | |
| 126 | | |
| 127 | | void DasmWindow::toggleBreakpointAtCursor(bool changedTo) |
| 128 | | { |
| 129 | | if (m_dasmView->view()->cursor_visible()) |
| 130 | | { |
| 131 | | if (debug_cpu_get_visible_cpu(*m_machine) == m_dasmView->view()->source()->device()) |
| 132 | | { |
| 133 | | offs_t address = downcast<debug_view_disasm *>(m_dasmView->view())->selected_address(); |
| 134 | | device_debug *cpuinfo = m_dasmView->view()->source()->device()->debug(); |
| 135 | | |
| 136 | | // Find an existing breakpoint at this address |
| 137 | | INT32 bpindex = -1; |
| 138 | | for (device_debug::breakpoint* bp = cpuinfo->breakpoint_first(); |
| 139 | | bp != NULL; |
| 140 | | bp = bp->next()) |
| 141 | | { |
| 142 | | if (address == bp->address()) |
| 143 | | { |
| 144 | | bpindex = bp->index(); |
| 145 | | break; |
| 146 | | } |
| 147 | | } |
| 148 | | |
| 149 | | // If none exists, add a new one |
| 150 | | astring command; |
| 151 | | if (bpindex == -1) |
| 152 | | { |
| 153 | | command.printf("bpset 0x%X", address); |
| 154 | | } |
| 155 | | else |
| 156 | | { |
| 157 | | command.printf("bpclear 0x%X", bpindex); |
| 158 | | } |
| 159 | | debug_console_execute_command(*m_machine, command, 1); |
| 160 | | } |
| 161 | | } |
| 162 | | |
| 163 | | refreshAll(); |
| 164 | | } |
| 165 | | |
| 166 | | |
| 167 | | void DasmWindow::runToCursor(bool changedTo) |
| 168 | | { |
| 169 | | if (m_dasmView->view()->cursor_visible()) |
| 170 | | { |
| 171 | | if (debug_cpu_get_visible_cpu(*m_machine) == m_dasmView->view()->source()->device()) |
| 172 | | { |
| 173 | | offs_t address = downcast<debug_view_disasm*>(m_dasmView->view())->selected_address(); |
| 174 | | astring command; |
| 175 | | command.printf("go 0x%X", address); |
| 176 | | debug_console_execute_command(*m_machine, command, 1); |
| 177 | | } |
| 178 | | } |
| 179 | | } |
| 180 | | |
| 181 | | |
| 182 | | void DasmWindow::rightBarChanged(QAction* changedTo) |
| 183 | | { |
| 184 | | debug_view_disasm* dasmView = downcast<debug_view_disasm*>(m_dasmView->view()); |
| 185 | | if (changedTo->text() == "Raw Opcodes") |
| 186 | | { |
| 187 | | dasmView->set_right_column(DASM_RIGHTCOL_RAW); |
| 188 | | } |
| 189 | | else if (changedTo->text() == "Encrypted Opcodes") |
| 190 | | { |
| 191 | | dasmView->set_right_column(DASM_RIGHTCOL_ENCRYPTED); |
| 192 | | } |
| 193 | | else if (changedTo->text() == "Comments") |
| 194 | | { |
| 195 | | dasmView->set_right_column(DASM_RIGHTCOL_COMMENTS); |
| 196 | | } |
| 197 | | m_dasmView->viewport()->update(); |
| 198 | | } |
| 199 | | |
| 200 | | |
| 201 | | void DasmWindow::populateComboBox() |
| 202 | | { |
| 203 | | if (m_dasmView == NULL) |
| 204 | | return; |
| 205 | | |
| 206 | | m_cpuComboBox->clear(); |
| 207 | | for (const debug_view_source* source = m_dasmView->view()->first_source(); |
| 208 | | source != NULL; |
| 209 | | source = source->next()) |
| 210 | | { |
| 211 | | m_cpuComboBox->addItem(source->name()); |
| 212 | | } |
| 213 | | } |
| 214 | | |
| 215 | | |
| 216 | | //========================================================================= |
| 217 | | // DasmWindowQtConfig |
| 218 | | //========================================================================= |
| 219 | | void DasmWindowQtConfig::buildFromQWidget(QWidget* widget) |
| 220 | | { |
| 221 | | WindowQtConfig::buildFromQWidget(widget); |
| 222 | | DasmWindow* window = dynamic_cast<DasmWindow*>(widget); |
| 223 | | QComboBox* cpu = window->findChild<QComboBox*>("cpu"); |
| 224 | | m_cpu = cpu->currentIndex(); |
| 225 | | |
| 226 | | QActionGroup* rightBarGroup = window->findChild<QActionGroup*>("rightbargroup"); |
| 227 | | if (rightBarGroup->checkedAction()->text() == "Raw Opcodes") |
| 228 | | m_rightBar = 0; |
| 229 | | else if (rightBarGroup->checkedAction()->text() == "Encrypted Opcodes") |
| 230 | | m_rightBar = 1; |
| 231 | | else if (rightBarGroup->checkedAction()->text() == "Comments") |
| 232 | | m_rightBar = 2; |
| 233 | | } |
| 234 | | |
| 235 | | void DasmWindowQtConfig::applyToQWidget(QWidget* widget) |
| 236 | | { |
| 237 | | WindowQtConfig::applyToQWidget(widget); |
| 238 | | DasmWindow* window = dynamic_cast<DasmWindow*>(widget); |
| 239 | | QComboBox* cpu = window->findChild<QComboBox*>("cpu"); |
| 240 | | cpu->setCurrentIndex(m_cpu); |
| 241 | | |
| 242 | | QActionGroup* rightBarGroup = window->findChild<QActionGroup*>("rightbargroup"); |
| 243 | | rightBarGroup->actions()[m_rightBar]->trigger(); |
| 244 | | } |
| 245 | | |
| 246 | | void DasmWindowQtConfig::addToXmlDataNode(xml_data_node* node) const |
| 247 | | { |
| 248 | | WindowQtConfig::addToXmlDataNode(node); |
| 249 | | xml_set_attribute_int(node, "cpu", m_cpu); |
| 250 | | xml_set_attribute_int(node, "rightbar", m_rightBar); |
| 251 | | } |
| 252 | | |
| 253 | | void DasmWindowQtConfig::recoverFromXmlNode(xml_data_node* node) |
| 254 | | { |
| 255 | | WindowQtConfig::recoverFromXmlNode(node); |
| 256 | | m_cpu = xml_get_attribute_int(node, "cpu", m_cpu); |
| 257 | | m_rightBar = xml_get_attribute_int(node, "rightbar", m_rightBar); |
| 258 | | } |
trunk/src/osd/modules/debugger/qt/debugqtdeviceinformationwindow.c
| r243594 | r243595 | |
| 1 | | #define NO_MEM_TRACKING |
| 2 | | |
| 3 | | #include "debugqtdeviceinformationwindow.h" |
| 4 | | |
| 5 | | |
| 6 | | DeviceInformationWindow::DeviceInformationWindow(running_machine* machine, device_t* device, QWidget* parent) : |
| 7 | | WindowQt(machine, NULL) |
| 8 | | { |
| 9 | | m_device = device; |
| 10 | | |
| 11 | | if (parent != NULL) |
| 12 | | { |
| 13 | | QPoint parentPos = parent->pos(); |
| 14 | | setGeometry(parentPos.x()+100, parentPos.y()+100, 600, 400); |
| 15 | | } |
| 16 | | |
| 17 | | if(m_device) |
| 18 | | fill_device_information(); |
| 19 | | } |
| 20 | | |
| 21 | | |
| 22 | | DeviceInformationWindow::~DeviceInformationWindow() |
| 23 | | { |
| 24 | | } |
| 25 | | |
| 26 | | void DeviceInformationWindow::fill_device_information() |
| 27 | | { |
| 28 | | char title[4069]; |
| 29 | | sprintf(title, "Debug: Device %s", m_device->tag()); |
| 30 | | setWindowTitle(title); |
| 31 | | |
| 32 | | |
| 33 | | QFrame *mainWindowFrame = new QFrame(this); |
| 34 | | QVBoxLayout *vLayout = new QVBoxLayout(mainWindowFrame); |
| 35 | | vLayout->setObjectName("vlayout"); |
| 36 | | vLayout->setSpacing(3); |
| 37 | | vLayout->setContentsMargins(2,2,2,2); |
| 38 | | |
| 39 | | QFrame *primaryFrame = new QFrame(mainWindowFrame); |
| 40 | | primaryFrame->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); |
| 41 | | QGridLayout *gl1 = new QGridLayout(primaryFrame); |
| 42 | | gl1->addWidget(new QLabel(QString("Tag"), primaryFrame), 0, 0); |
| 43 | | gl1->addWidget(new QLabel(QString(m_device->tag()), primaryFrame), 0, 1); |
| 44 | | gl1->addWidget(new QLabel(QString("Name"), primaryFrame), 1, 0); |
| 45 | | gl1->addWidget(new QLabel(QString(m_device->name()), primaryFrame), 1, 1); |
| 46 | | gl1->addWidget(new QLabel(QString("Shortname"), primaryFrame), 2, 0); |
| 47 | | gl1->addWidget(new QLabel(QString(m_device->shortname()), primaryFrame), 2, 1); |
| 48 | | |
| 49 | | int cpos = 3; |
| 50 | | device_interface *intf = m_device->first_interface(); |
| 51 | | if(intf) { |
| 52 | | gl1->addWidget(new QLabel(QString("Interfaces"), primaryFrame), cpos, 0); |
| 53 | | while(intf) { |
| 54 | | gl1->addWidget(new QLabel(QString(intf->interface_type()), primaryFrame), cpos, 1); |
| 55 | | cpos++; |
| 56 | | intf = intf->interface_next(); |
| 57 | | } |
| 58 | | } |
| 59 | | |
| 60 | | vLayout->addWidget(primaryFrame); |
| 61 | | |
| 62 | | device_memory_interface *d_memory; |
| 63 | | if(m_device->interface(d_memory)) { |
| 64 | | QFrame *f = new QFrame(mainWindowFrame); |
| 65 | | f->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); |
| 66 | | QVBoxLayout *vb = new QVBoxLayout(f); |
| 67 | | bool first = true; |
| 68 | | for(address_spacenum i=AS_0; i<ADDRESS_SPACES; i++) |
| 69 | | if(d_memory->has_space(i)) { |
| 70 | | QFrame *ff = new QFrame(f); |
| 71 | | QHBoxLayout *hb = new QHBoxLayout(ff); |
| 72 | | if(first) { |
| 73 | | hb->addWidget(new QLabel("Memory maps")); |
| 74 | | first = false; |
| 75 | | } |
| 76 | | hb->addStretch(); |
| 77 | | hb->addWidget(new QLabel(d_memory->space_config(i)->name())); |
| 78 | | vb->addWidget(ff); |
| 79 | | } |
| 80 | | vLayout->addWidget(f); |
| 81 | | } |
| 82 | | |
| 83 | | vLayout->addStretch(); |
| 84 | | |
| 85 | | setCentralWidget(mainWindowFrame); |
| 86 | | } |
| 87 | | |
| 88 | | void DeviceInformationWindow::set_device(const char *tag) |
| 89 | | { |
| 90 | | m_device = m_machine->device(tag); |
| 91 | | if(!m_device) |
| 92 | | m_device = &m_machine->root_device(); |
| 93 | | fill_device_information(); |
| 94 | | } |
| 95 | | |
| 96 | | const char *DeviceInformationWindow::device_tag() const |
| 97 | | { |
| 98 | | return m_device->tag(); |
| 99 | | } |
| 100 | | |
| 101 | | |
| 102 | | //========================================================================= |
| 103 | | // DeviceInformationWindowQtConfig |
| 104 | | //========================================================================= |
| 105 | | void DeviceInformationWindowQtConfig::buildFromQWidget(QWidget* widget) |
| 106 | | { |
| 107 | | WindowQtConfig::buildFromQWidget(widget); |
| 108 | | DeviceInformationWindow* window = dynamic_cast<DeviceInformationWindow*>(widget); |
| 109 | | m_device_tag = window->device_tag(); |
| 110 | | } |
| 111 | | |
| 112 | | |
| 113 | | void DeviceInformationWindowQtConfig::applyToQWidget(QWidget* widget) |
| 114 | | { |
| 115 | | WindowQtConfig::applyToQWidget(widget); |
| 116 | | DeviceInformationWindow* window = dynamic_cast<DeviceInformationWindow*>(widget); |
| 117 | | window->set_device(m_device_tag.cstr()); |
| 118 | | } |
| 119 | | |
| 120 | | |
| 121 | | void DeviceInformationWindowQtConfig::addToXmlDataNode(xml_data_node* node) const |
| 122 | | { |
| 123 | | WindowQtConfig::addToXmlDataNode(node); |
| 124 | | xml_set_attribute(node, "device-tag", m_device_tag); |
| 125 | | } |
| 126 | | |
| 127 | | |
| 128 | | void DeviceInformationWindowQtConfig::recoverFromXmlNode(xml_data_node* node) |
| 129 | | { |
| 130 | | WindowQtConfig::recoverFromXmlNode(node); |
| 131 | | m_device_tag = xml_get_attribute_string(node, "device-tag", ":"); |
| 132 | | } |
trunk/src/osd/modules/debugger/qt/debugqtdeviceswindow.c
| r243594 | r243595 | |
| 1 | | #define NO_MEM_TRACKING |
| 2 | | |
| 3 | | #include "debugqtdeviceswindow.h" |
| 4 | | #include "debugqtdeviceinformationwindow.h" |
| 5 | | |
| 6 | | DevicesWindowModel::DevicesWindowModel(running_machine *machine, QObject *parent) |
| 7 | | { |
| 8 | | m_machine = machine; |
| 9 | | } |
| 10 | | |
| 11 | | DevicesWindowModel::~DevicesWindowModel() |
| 12 | | { |
| 13 | | } |
| 14 | | |
| 15 | | QVariant DevicesWindowModel::data(const QModelIndex &index, int role) const |
| 16 | | { |
| 17 | | if(!index.isValid() || role != Qt::DisplayRole) |
| 18 | | return QVariant(); |
| 19 | | |
| 20 | | device_t *dev = static_cast<device_t *>(index.internalPointer()); |
| 21 | | switch(index.column()) { |
| 22 | | case 0: return dev == &m_machine->root_device() ? QString("<root>") : QString(dev->basetag()); |
| 23 | | case 1: return QString(dev->name()); |
| 24 | | } |
| 25 | | |
| 26 | | return QVariant(); |
| 27 | | } |
| 28 | | |
| 29 | | Qt::ItemFlags DevicesWindowModel::flags(const QModelIndex &index) const |
| 30 | | { |
| 31 | | if(!index.isValid()) |
| 32 | | return 0; |
| 33 | | |
| 34 | | return QAbstractItemModel::flags(index); |
| 35 | | } |
| 36 | | |
| 37 | | QVariant DevicesWindowModel::headerData(int section, Qt::Orientation orientation, int role) const |
| 38 | | { |
| 39 | | if(role != Qt::DisplayRole || section < 0 || section >= 2) |
| 40 | | return QVariant(); |
| 41 | | return QString(section ? "Name" : "Tag"); |
| 42 | | } |
| 43 | | |
| 44 | | QModelIndex DevicesWindowModel::index(int row, int column, const QModelIndex &parent) const |
| 45 | | { |
| 46 | | if(!hasIndex(row, column, parent)) |
| 47 | | return QModelIndex(); |
| 48 | | |
| 49 | | device_t *target = NULL; |
| 50 | | |
| 51 | | if(!parent.isValid()) { |
| 52 | | if(row == 0) |
| 53 | | target = &m_machine->root_device(); |
| 54 | | |
| 55 | | } else { |
| 56 | | device_t *dparent = static_cast<device_t *>(parent.internalPointer()); |
| 57 | | int count = row; |
| 58 | | for(target = dparent->first_subdevice(); count && target; target = target->next()) |
| 59 | | count--; |
| 60 | | } |
| 61 | | |
| 62 | | if(target) |
| 63 | | return createIndex(row, column, target); |
| 64 | | |
| 65 | | return QModelIndex(); |
| 66 | | } |
| 67 | | |
| 68 | | QModelIndex DevicesWindowModel::parent(const QModelIndex &index) const |
| 69 | | { |
| 70 | | if(!index.isValid()) |
| 71 | | return QModelIndex(); |
| 72 | | |
| 73 | | device_t *dchild = static_cast<device_t *>(index.internalPointer()); |
| 74 | | device_t *dparent = dchild->owner(); |
| 75 | | |
| 76 | | if(!dparent) |
| 77 | | return QModelIndex(); |
| 78 | | |
| 79 | | device_t *dpp = dparent->owner(); |
| 80 | | int row = 0; |
| 81 | | if(dpp) { |
| 82 | | for(device_t *child = dpp->first_subdevice(); child && child != dparent; child = child->next()) |
| 83 | | row++; |
| 84 | | } |
| 85 | | return createIndex(row, 0, dparent); |
| 86 | | } |
| 87 | | |
| 88 | | int DevicesWindowModel::rowCount(const QModelIndex &parent) const |
| 89 | | { |
| 90 | | if(!parent.isValid()) |
| 91 | | return 1; |
| 92 | | |
| 93 | | device_t *dparent = static_cast<device_t *>(parent.internalPointer()); |
| 94 | | int count = 0; |
| 95 | | for(device_t *child = dparent->first_subdevice(); child; child = child->next()) |
| 96 | | count++; |
| 97 | | |
| 98 | | return count; |
| 99 | | } |
| 100 | | |
| 101 | | int DevicesWindowModel::columnCount(const QModelIndex &parent) const |
| 102 | | { |
| 103 | | return 2; |
| 104 | | } |
| 105 | | |
| 106 | | |
| 107 | | |
| 108 | | DevicesWindow::DevicesWindow(running_machine* machine, QWidget* parent) : |
| 109 | | WindowQt(machine, NULL), |
| 110 | | m_devices_model(machine) |
| 111 | | { |
| 112 | | m_selected_device = NULL; |
| 113 | | |
| 114 | | setWindowTitle("Debug: All Devices"); |
| 115 | | |
| 116 | | if (parent != NULL) |
| 117 | | { |
| 118 | | QPoint parentPos = parent->pos(); |
| 119 | | setGeometry(parentPos.x()+100, parentPos.y()+100, 600, 400); |
| 120 | | } |
| 121 | | |
| 122 | | // |
| 123 | | // The tree widget |
| 124 | | // |
| 125 | | m_devices_view = new QTreeView(this); |
| 126 | | m_devices_view->setModel(&m_devices_model); |
| 127 | | m_devices_view->expandAll(); |
| 128 | | m_devices_view->resizeColumnToContents(0); |
| 129 | | connect(m_devices_view->selectionModel(), SIGNAL(currentRowChanged(const QModelIndex &,const QModelIndex &)), this, SLOT(currentRowChanged(const QModelIndex &,const QModelIndex &))); |
| 130 | | connect(m_devices_view, SIGNAL(activated(const QModelIndex &)), this, SLOT(activated(const QModelIndex &))); |
| 131 | | setCentralWidget(m_devices_view); |
| 132 | | } |
| 133 | | |
| 134 | | |
| 135 | | DevicesWindow::~DevicesWindow() |
| 136 | | { |
| 137 | | } |
| 138 | | |
| 139 | | |
| 140 | | void DevicesWindow::currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous) |
| 141 | | { |
| 142 | | m_selected_device = static_cast<device_t *>(current.internalPointer()); |
| 143 | | } |
| 144 | | |
| 145 | | |
| 146 | | void DevicesWindow::activated(const QModelIndex &index) |
| 147 | | { |
| 148 | | device_t *dev = static_cast<device_t *>(index.internalPointer()); |
| 149 | | (new DeviceInformationWindow(m_machine, dev, this))->show(); |
| 150 | | } |
| 151 | | |
| 152 | | |
| 153 | | |
| 154 | | //========================================================================= |
| 155 | | // DevicesWindowQtConfig |
| 156 | | //========================================================================= |
| 157 | | void DevicesWindowQtConfig::buildFromQWidget(QWidget* widget) |
| 158 | | { |
| 159 | | WindowQtConfig::buildFromQWidget(widget); |
| 160 | | // DevicesWindow* window = dynamic_cast<DevicesWindow*>(widget); |
| 161 | | } |
| 162 | | |
| 163 | | |
| 164 | | void DevicesWindowQtConfig::applyToQWidget(QWidget* widget) |
| 165 | | { |
| 166 | | WindowQtConfig::applyToQWidget(widget); |
| 167 | | // DevicesWindow* window = dynamic_cast<DevicesWindow*>(widget); |
| 168 | | } |
| 169 | | |
| 170 | | |
| 171 | | void DevicesWindowQtConfig::addToXmlDataNode(xml_data_node* node) const |
| 172 | | { |
| 173 | | WindowQtConfig::addToXmlDataNode(node); |
| 174 | | } |
| 175 | | |
| 176 | | |
| 177 | | void DevicesWindowQtConfig::recoverFromXmlNode(xml_data_node* node) |
| 178 | | { |
| 179 | | WindowQtConfig::recoverFromXmlNode(node); |
| 180 | | } |
trunk/src/osd/modules/debugger/qt/debugqtmainwindow.c
| r243594 | r243595 | |
| 1 | | #define NO_MEM_TRACKING |
| 2 | | |
| 3 | | #include "debugqtmainwindow.h" |
| 4 | | |
| 5 | | #include "debug/debugcon.h" |
| 6 | | #include "debug/debugcpu.h" |
| 7 | | #include "debug/dvdisasm.h" |
| 8 | | |
| 9 | | |
| 10 | | MainWindow::MainWindow(running_machine* machine, QWidget* parent) : |
| 11 | | WindowQt(machine, NULL), |
| 12 | | m_historyIndex(0), |
| 13 | | m_inputHistory() |
| 14 | | { |
| 15 | | setGeometry(300, 300, 1000, 600); |
| 16 | | |
| 17 | | // |
| 18 | | // The main frame and its input and log widgets |
| 19 | | // |
| 20 | | QFrame* mainWindowFrame = new QFrame(this); |
| 21 | | |
| 22 | | // The input line |
| 23 | | m_inputEdit = new QLineEdit(mainWindowFrame); |
| 24 | | connect(m_inputEdit, SIGNAL(returnPressed()), this, SLOT(executeCommand())); |
| 25 | | m_inputEdit->installEventFilter(this); |
| 26 | | |
| 27 | | |
| 28 | | // The log view |
| 29 | | m_consoleView = new DebuggerView(DVT_CONSOLE, |
| 30 | | m_machine, |
| 31 | | mainWindowFrame); |
| 32 | | m_consoleView->setFocusPolicy(Qt::NoFocus); |
| 33 | | m_consoleView->setPreferBottom(true); |
| 34 | | |
| 35 | | QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame); |
| 36 | | vLayout->addWidget(m_consoleView); |
| 37 | | vLayout->addWidget(m_inputEdit); |
| 38 | | vLayout->setSpacing(3); |
| 39 | | vLayout->setContentsMargins(4,0,4,2); |
| 40 | | |
| 41 | | setCentralWidget(mainWindowFrame); |
| 42 | | |
| 43 | | // |
| 44 | | // Options Menu |
| 45 | | // |
| 46 | | // Create two commands |
| 47 | | QAction* breakpointSetAct = new QAction("Toggle Breakpoint At Cursor", this); |
| 48 | | QAction* runToCursorAct = new QAction("Run To Cursor", this); |
| 49 | | breakpointSetAct->setShortcut(Qt::Key_F9); |
| 50 | | runToCursorAct->setShortcut(Qt::Key_F4); |
| 51 | | connect(breakpointSetAct, SIGNAL(triggered(bool)), this, SLOT(toggleBreakpointAtCursor(bool))); |
| 52 | | connect(runToCursorAct, SIGNAL(triggered(bool)), this, SLOT(runToCursor(bool))); |
| 53 | | |
| 54 | | // Right bar options |
| 55 | | QActionGroup* rightBarGroup = new QActionGroup(this); |
| 56 | | rightBarGroup->setObjectName("rightbargroup"); |
| 57 | | QAction* rightActRaw = new QAction("Raw Opcodes", this); |
| 58 | | QAction* rightActEncrypted = new QAction("Encrypted Opcodes", this); |
| 59 | | QAction* rightActComments = new QAction("Comments", this); |
| 60 | | rightActRaw->setCheckable(true); |
| 61 | | rightActEncrypted->setCheckable(true); |
| 62 | | rightActComments->setCheckable(true); |
| 63 | | rightActRaw->setActionGroup(rightBarGroup); |
| 64 | | rightActEncrypted->setActionGroup(rightBarGroup); |
| 65 | | rightActComments->setActionGroup(rightBarGroup); |
| 66 | | rightActRaw->setShortcut(QKeySequence("Ctrl+R")); |
| 67 | | rightActEncrypted->setShortcut(QKeySequence("Ctrl+E")); |
| 68 | | rightActComments->setShortcut(QKeySequence("Ctrl+C")); |
| 69 | | rightActRaw->setChecked(true); |
| 70 | | connect(rightBarGroup, SIGNAL(triggered(QAction*)), this, SLOT(rightBarChanged(QAction*))); |
| 71 | | |
| 72 | | // Assemble the options menu |
| 73 | | QMenu* optionsMenu = menuBar()->addMenu("&Options"); |
| 74 | | optionsMenu->addAction(breakpointSetAct); |
| 75 | | optionsMenu->addAction(runToCursorAct); |
| 76 | | optionsMenu->addSeparator(); |
| 77 | | optionsMenu->addActions(rightBarGroup->actions()); |
| 78 | | |
| 79 | | // |
| 80 | | // Images menu |
| 81 | | // |
| 82 | | image_interface_iterator imageIterTest(m_machine->root_device()); |
| 83 | | if (imageIterTest.first() != NULL) |
| 84 | | { |
| 85 | | createImagesMenu(); |
| 86 | | } |
| 87 | | |
| 88 | | // |
| 89 | | // Dock window menu |
| 90 | | // |
| 91 | | QMenu* dockMenu = menuBar()->addMenu("Doc&ks"); |
| 92 | | |
| 93 | | setCorner(Qt::TopRightCorner, Qt::TopDockWidgetArea); |
| 94 | | setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea); |
| 95 | | |
| 96 | | // The processor dock |
| 97 | | QDockWidget* cpuDock = new QDockWidget("processor", this); |
| 98 | | cpuDock->setObjectName("cpudock"); |
| 99 | | cpuDock->setAllowedAreas(Qt::LeftDockWidgetArea); |
| 100 | | m_procFrame = new ProcessorDockWidget(m_machine, cpuDock); |
| 101 | | cpuDock->setWidget(dynamic_cast<QWidget*>(m_procFrame)); |
| 102 | | |
| 103 | | addDockWidget(Qt::LeftDockWidgetArea, cpuDock); |
| 104 | | dockMenu->addAction(cpuDock->toggleViewAction()); |
| 105 | | |
| 106 | | // The disassembly dock |
| 107 | | QDockWidget* dasmDock = new QDockWidget("dasm", this); |
| 108 | | dasmDock->setObjectName("dasmdock"); |
| 109 | | dasmDock->setAllowedAreas(Qt::TopDockWidgetArea); |
| 110 | | m_dasmFrame = new DasmDockWidget(m_machine, dasmDock); |
| 111 | | dasmDock->setWidget(m_dasmFrame); |
| 112 | | |
| 113 | | addDockWidget(Qt::TopDockWidgetArea, dasmDock); |
| 114 | | dockMenu->addAction(dasmDock->toggleViewAction()); |
| 115 | | } |
| 116 | | |
| 117 | | |
| 118 | | MainWindow::~MainWindow() |
| 119 | | { |
| 120 | | } |
| 121 | | |
| 122 | | |
| 123 | | void MainWindow::setProcessor(device_t* processor) |
| 124 | | { |
| 125 | | // Cpu swap |
| 126 | | m_procFrame->view()->view()->set_source(*m_procFrame->view()->view()->source_for_device(processor)); |
| 127 | | m_dasmFrame->view()->view()->set_source(*m_dasmFrame->view()->view()->source_for_device(processor)); |
| 128 | | |
| 129 | | // Scrollbar refresh - seems I should be able to do in the DebuggerView |
| 130 | | m_dasmFrame->view()->verticalScrollBar()->setValue(m_dasmFrame->view()->view()->visible_position().y); |
| 131 | | m_dasmFrame->view()->verticalScrollBar()->setValue(m_dasmFrame->view()->view()->visible_position().y); |
| 132 | | |
| 133 | | // Window title |
| 134 | | astring title; |
| 135 | | title.printf("Debug: %s - %s '%s'", m_machine->system().name, processor->name(), processor->tag()); |
| 136 | | setWindowTitle(title.cstr()); |
| 137 | | } |
| 138 | | |
| 139 | | |
| 140 | | // Used to intercept the user clicking 'X' in the upper corner |
| 141 | | void MainWindow::closeEvent(QCloseEvent* event) |
| 142 | | { |
| 143 | | debugActQuit(); |
| 144 | | |
| 145 | | // Insure the window doesn't disappear before we get a chance to save its parameters |
| 146 | | event->ignore(); |
| 147 | | } |
| 148 | | |
| 149 | | |
| 150 | | // Used to intercept the user hitting the up arrow in the input widget |
| 151 | | bool MainWindow::eventFilter(QObject* obj, QEvent* event) |
| 152 | | { |
| 153 | | // Only filter keypresses |
| 154 | | QKeyEvent* keyEvent = NULL; |
| 155 | | if (event->type() == QEvent::KeyPress) |
| 156 | | { |
| 157 | | keyEvent = static_cast<QKeyEvent*>(event); |
| 158 | | } |
| 159 | | else |
| 160 | | { |
| 161 | | return QObject::eventFilter(obj, event); |
| 162 | | } |
| 163 | | |
| 164 | | // Catch up & down keys |
| 165 | | if (keyEvent->key() == Qt::Key_Up || keyEvent->key() == Qt::Key_Down) |
| 166 | | { |
| 167 | | if (keyEvent->key() == Qt::Key_Up) |
| 168 | | { |
| 169 | | if (m_historyIndex > 0) |
| 170 | | m_historyIndex--; |
| 171 | | } |
| 172 | | else if (keyEvent->key() == Qt::Key_Down) |
| 173 | | { |
| 174 | | if (m_historyIndex < m_inputHistory.size()) |
| 175 | | m_historyIndex++; |
| 176 | | } |
| 177 | | |
| 178 | | // Populate the input edit or clear it if you're at the end |
| 179 | | if (m_historyIndex == m_inputHistory.size()) |
| 180 | | { |
| 181 | | m_inputEdit->setText(""); |
| 182 | | } |
| 183 | | else |
| 184 | | { |
| 185 | | m_inputEdit->setText(m_inputHistory[m_historyIndex]); |
| 186 | | } |
| 187 | | } |
| 188 | | else if (keyEvent->key() == Qt::Key_Enter) |
| 189 | | { |
| 190 | | executeCommand(false); |
| 191 | | } |
| 192 | | else |
| 193 | | { |
| 194 | | return QObject::eventFilter(obj, event); |
| 195 | | } |
| 196 | | |
| 197 | | return true; |
| 198 | | } |
| 199 | | |
| 200 | | |
| 201 | | void MainWindow::toggleBreakpointAtCursor(bool changedTo) |
| 202 | | { |
| 203 | | debug_view_disasm* dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view()); |
| 204 | | if (dasmView->cursor_visible()) |
| 205 | | { |
| 206 | | if (debug_cpu_get_visible_cpu(*m_machine) == dasmView->source()->device()) |
| 207 | | { |
| 208 | | offs_t address = downcast<debug_view_disasm *>(dasmView)->selected_address(); |
| 209 | | device_debug *cpuinfo = dasmView->source()->device()->debug(); |
| 210 | | |
| 211 | | // Find an existing breakpoint at this address |
| 212 | | INT32 bpindex = -1; |
| 213 | | for (device_debug::breakpoint* bp = cpuinfo->breakpoint_first(); |
| 214 | | bp != NULL; |
| 215 | | bp = bp->next()) |
| 216 | | { |
| 217 | | if (address == bp->address()) |
| 218 | | { |
| 219 | | bpindex = bp->index(); |
| 220 | | break; |
| 221 | | } |
| 222 | | } |
| 223 | | |
| 224 | | // If none exists, add a new one |
| 225 | | astring command; |
| 226 | | if (bpindex == -1) |
| 227 | | { |
| 228 | | command.printf("bpset 0x%X", address); |
| 229 | | } |
| 230 | | else |
| 231 | | { |
| 232 | | command.printf("bpclear 0x%X", bpindex); |
| 233 | | } |
| 234 | | debug_console_execute_command(*m_machine, command, 1); |
| 235 | | } |
| 236 | | } |
| 237 | | |
| 238 | | refreshAll(); |
| 239 | | } |
| 240 | | |
| 241 | | |
| 242 | | void MainWindow::runToCursor(bool changedTo) |
| 243 | | { |
| 244 | | debug_view_disasm* dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view()); |
| 245 | | if (dasmView->cursor_visible()) |
| 246 | | { |
| 247 | | if (debug_cpu_get_visible_cpu(*m_machine) == dasmView->source()->device()) |
| 248 | | { |
| 249 | | offs_t address = downcast<debug_view_disasm*>(dasmView)->selected_address(); |
| 250 | | astring command; |
| 251 | | command.printf("go 0x%X", address); |
| 252 | | debug_console_execute_command(*m_machine, command, 1); |
| 253 | | } |
| 254 | | } |
| 255 | | } |
| 256 | | |
| 257 | | |
| 258 | | void MainWindow::rightBarChanged(QAction* changedTo) |
| 259 | | { |
| 260 | | debug_view_disasm* dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view()); |
| 261 | | if (changedTo->text() == "Raw Opcodes") |
| 262 | | { |
| 263 | | dasmView->set_right_column(DASM_RIGHTCOL_RAW); |
| 264 | | } |
| 265 | | else if (changedTo->text() == "Encrypted Opcodes") |
| 266 | | { |
| 267 | | dasmView->set_right_column(DASM_RIGHTCOL_ENCRYPTED); |
| 268 | | } |
| 269 | | else if (changedTo->text() == "Comments") |
| 270 | | { |
| 271 | | dasmView->set_right_column(DASM_RIGHTCOL_COMMENTS); |
| 272 | | } |
| 273 | | m_dasmFrame->view()->viewport()->update(); |
| 274 | | } |
| 275 | | |
| 276 | | |
| 277 | | void MainWindow::executeCommand(bool withClear) |
| 278 | | { |
| 279 | | QString command = m_inputEdit->text(); |
| 280 | | |
| 281 | | // A blank command is a "silent step" |
| 282 | | if (command == "") |
| 283 | | { |
| 284 | | debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step(); |
| 285 | | return; |
| 286 | | } |
| 287 | | |
| 288 | | // Send along the command |
| 289 | | debug_console_execute_command(*m_machine, |
| 290 | | command.toLocal8Bit().data(), |
| 291 | | true); |
| 292 | | |
| 293 | | // Add history & set the index to be the top of the stack |
| 294 | | addToHistory(command); |
| 295 | | |
| 296 | | // Clear out the text and reset the history pointer only if asked |
| 297 | | if (withClear) |
| 298 | | { |
| 299 | | m_inputEdit->clear(); |
| 300 | | m_historyIndex = m_inputHistory.size(); |
| 301 | | } |
| 302 | | |
| 303 | | // Refresh |
| 304 | | m_consoleView->viewport()->update(); |
| 305 | | refreshAll(); |
| 306 | | } |
| 307 | | |
| 308 | | |
| 309 | | void MainWindow::mountImage(bool changedTo) |
| 310 | | { |
| 311 | | // The image interface index was assigned to the QAction's data memeber |
| 312 | | const int imageIndex = dynamic_cast<QAction*>(sender())->data().toInt(); |
| 313 | | image_interface_iterator iter(m_machine->root_device()); |
| 314 | | device_image_interface *img = iter.byindex(imageIndex); |
| 315 | | if (img == NULL) |
| 316 | | { |
| 317 | | debug_console_printf(*m_machine, "Something is wrong with the mount menu.\n"); |
| 318 | | refreshAll(); |
| 319 | | return; |
| 320 | | } |
| 321 | | |
| 322 | | // File dialog |
| 323 | | QString filename = QFileDialog::getOpenFileName(this, |
| 324 | | "Select an image file", |
| 325 | | QDir::currentPath(), |
| 326 | | tr("All files (*.*)")); |
| 327 | | |
| 328 | | if (img->load(filename.toUtf8().data()) != IMAGE_INIT_PASS) |
| 329 | | { |
| 330 | | debug_console_printf(*m_machine, "Image could not be mounted.\n"); |
| 331 | | refreshAll(); |
| 332 | | return; |
| 333 | | } |
| 334 | | |
| 335 | | // Activate the unmount menu option |
| 336 | | QAction* unmountAct = sender()->parent()->findChild<QAction*>("unmount"); |
| 337 | | unmountAct->setEnabled(true); |
| 338 | | |
| 339 | | // Set the mount name |
| 340 | | QMenu* parentMenuItem = dynamic_cast<QMenu*>(sender()->parent()); |
| 341 | | QString baseString = parentMenuItem->title(); |
| 342 | | baseString.truncate(baseString.lastIndexOf(QString(" : "))); |
| 343 | | const QString newTitle = baseString + QString(" : ") + QString(img->filename()); |
| 344 | | parentMenuItem->setTitle(newTitle); |
| 345 | | |
| 346 | | debug_console_printf(*m_machine, "Image %s mounted successfully.\n", filename.toUtf8().data()); |
| 347 | | refreshAll(); |
| 348 | | } |
| 349 | | |
| 350 | | |
| 351 | | void MainWindow::unmountImage(bool changedTo) |
| 352 | | { |
| 353 | | // The image interface index was assigned to the QAction's data memeber |
| 354 | | const int imageIndex = dynamic_cast<QAction*>(sender())->data().toInt(); |
| 355 | | image_interface_iterator iter(m_machine->root_device()); |
| 356 | | device_image_interface *img = iter.byindex(imageIndex); |
| 357 | | |
| 358 | | img->unload(); |
| 359 | | |
| 360 | | // Deactivate the unmount menu option |
| 361 | | dynamic_cast<QAction*>(sender())->setEnabled(false); |
| 362 | | |
| 363 | | // Set the mount name |
| 364 | | QMenu* parentMenuItem = dynamic_cast<QMenu*>(sender()->parent()); |
| 365 | | QString baseString = parentMenuItem->title(); |
| 366 | | baseString.truncate(baseString.lastIndexOf(QString(" : "))); |
| 367 | | const QString newTitle = baseString + QString(" : ") + QString("[empty slot]"); |
| 368 | | parentMenuItem->setTitle(newTitle); |
| 369 | | |
| 370 | | debug_console_printf(*m_machine, "Image successfully unmounted.\n"); |
| 371 | | refreshAll(); |
| 372 | | } |
| 373 | | |
| 374 | | |
| 375 | | void MainWindow::debugActClose() |
| 376 | | { |
| 377 | | m_machine->schedule_exit(); |
| 378 | | } |
| 379 | | |
| 380 | | |
| 381 | | void MainWindow::addToHistory(const QString& command) |
| 382 | | { |
| 383 | | if (command == "") |
| 384 | | return; |
| 385 | | |
| 386 | | // Always push back when there is no previous history |
| 387 | | if (m_inputHistory.size() == 0) |
| 388 | | { |
| 389 | | m_inputHistory.push_back(m_inputEdit->text()); |
| 390 | | return; |
| 391 | | } |
| 392 | | |
| 393 | | // If there is previous history, make sure it's not what you just executed |
| 394 | | if (m_inputHistory.back() != m_inputEdit->text()) |
| 395 | | { |
| 396 | | m_inputHistory.push_back(m_inputEdit->text()); |
| 397 | | } |
| 398 | | } |
| 399 | | |
| 400 | | |
| 401 | | void MainWindow::createImagesMenu() |
| 402 | | { |
| 403 | | QMenu* imagesMenu = menuBar()->addMenu("&Images"); |
| 404 | | |
| 405 | | int interfaceIndex = 0; |
| 406 | | image_interface_iterator iter(m_machine->root_device()); |
| 407 | | for (device_image_interface *img = iter.first(); img != NULL; img = iter.next()) |
| 408 | | { |
| 409 | | astring menuName; |
| 410 | | menuName.format("%s : %s", img->device().name(), img->exists() ? img->filename() : "[empty slot]"); |
| 411 | | |
| 412 | | QMenu* interfaceMenu = imagesMenu->addMenu(menuName.cstr()); |
| 413 | | interfaceMenu->setObjectName(img->device().name()); |
| 414 | | |
| 415 | | QAction* mountAct = new QAction("Mount...", interfaceMenu); |
| 416 | | QAction* unmountAct = new QAction("Unmount", interfaceMenu); |
| 417 | | mountAct->setObjectName("mount"); |
| 418 | | mountAct->setData(QVariant(interfaceIndex)); |
| 419 | | unmountAct->setObjectName("unmount"); |
| 420 | | unmountAct->setData(QVariant(interfaceIndex)); |
| 421 | | connect(mountAct, SIGNAL(triggered(bool)), this, SLOT(mountImage(bool))); |
| 422 | | connect(unmountAct, SIGNAL(triggered(bool)), this, SLOT(unmountImage(bool))); |
| 423 | | |
| 424 | | if (!img->exists()) |
| 425 | | unmountAct->setEnabled(false); |
| 426 | | |
| 427 | | interfaceMenu->addAction(mountAct); |
| 428 | | interfaceMenu->addAction(unmountAct); |
| 429 | | |
| 430 | | // TODO: Cassette operations |
| 431 | | |
| 432 | | interfaceIndex++; |
| 433 | | } |
| 434 | | } |
| 435 | | |
| 436 | | |
| 437 | | //========================================================================= |
| 438 | | // MainWindowQtConfig |
| 439 | | //========================================================================= |
| 440 | | void MainWindowQtConfig::buildFromQWidget(QWidget* widget) |
| 441 | | { |
| 442 | | WindowQtConfig::buildFromQWidget(widget); |
| 443 | | MainWindow* window = dynamic_cast<MainWindow*>(widget); |
| 444 | | m_windowState = window->saveState(); |
| 445 | | |
| 446 | | QActionGroup* rightBarGroup = window->findChild<QActionGroup*>("rightbargroup"); |
| 447 | | if (rightBarGroup->checkedAction()->text() == "Raw Opcodes") |
| 448 | | m_rightBar = 0; |
| 449 | | else if (rightBarGroup->checkedAction()->text() == "Encrypted Opcodes") |
| 450 | | m_rightBar = 1; |
| 451 | | else if (rightBarGroup->checkedAction()->text() == "Comments") |
| 452 | | m_rightBar = 2; |
| 453 | | } |
| 454 | | |
| 455 | | |
| 456 | | void MainWindowQtConfig::applyToQWidget(QWidget* widget) |
| 457 | | { |
| 458 | | WindowQtConfig::applyToQWidget(widget); |
| 459 | | MainWindow* window = dynamic_cast<MainWindow*>(widget); |
| 460 | | window->restoreState(m_windowState); |
| 461 | | |
| 462 | | QActionGroup* rightBarGroup = window->findChild<QActionGroup*>("rightbargroup"); |
| 463 | | rightBarGroup->actions()[m_rightBar]->trigger(); |
| 464 | | } |
| 465 | | |
| 466 | | |
| 467 | | void MainWindowQtConfig::addToXmlDataNode(xml_data_node* node) const |
| 468 | | { |
| 469 | | WindowQtConfig::addToXmlDataNode(node); |
| 470 | | xml_set_attribute_int(node, "rightbar", m_rightBar); |
| 471 | | xml_set_attribute(node, "qtwindowstate", m_windowState.toPercentEncoding().data()); |
| 472 | | } |
| 473 | | |
| 474 | | |
| 475 | | void MainWindowQtConfig::recoverFromXmlNode(xml_data_node* node) |
| 476 | | { |
| 477 | | WindowQtConfig::recoverFromXmlNode(node); |
| 478 | | const char* state = xml_get_attribute_string(node, "qtwindowstate", ""); |
| 479 | | m_windowState = QByteArray::fromPercentEncoding(state); |
| 480 | | m_rightBar = xml_get_attribute_int(node, "rightbar", m_rightBar); |
| 481 | | } |
| 482 | | |
| 483 | | DasmDockWidget::~DasmDockWidget() |
| 484 | | { |
| 485 | | } |
| 486 | | |
| 487 | | ProcessorDockWidget::~ProcessorDockWidget() |
| 488 | | { |
| 489 | | } |
trunk/src/osd/modules/debugger/qt/debugqtmainwindow.h
| r243594 | r243595 | |
| 1 | | #ifndef __DEBUG_QT_MAIN_WINDOW_H__ |
| 2 | | #define __DEBUG_QT_MAIN_WINDOW_H__ |
| 3 | | |
| 4 | | #include <QtGui/QtGui> |
| 5 | | #include <vector> |
| 6 | | |
| 7 | | #include "debug/dvdisasm.h" |
| 8 | | |
| 9 | | #include "debugqtview.h" |
| 10 | | #include "debugqtwindow.h" |
| 11 | | |
| 12 | | class DasmDockWidget; |
| 13 | | class ProcessorDockWidget; |
| 14 | | |
| 15 | | |
| 16 | | //============================================================ |
| 17 | | // The Main Window. Contains processor and dasm docks. |
| 18 | | //============================================================ |
| 19 | | class MainWindow : public WindowQt |
| 20 | | { |
| 21 | | Q_OBJECT |
| 22 | | |
| 23 | | public: |
| 24 | | MainWindow(running_machine* machine, QWidget* parent=NULL); |
| 25 | | virtual ~MainWindow(); |
| 26 | | |
| 27 | | void setProcessor(device_t* processor); |
| 28 | | |
| 29 | | |
| 30 | | protected: |
| 31 | | // Used to intercept the user clicking 'X' in the upper corner |
| 32 | | void closeEvent(QCloseEvent* event); |
| 33 | | |
| 34 | | // Used to intercept the user hitting the up arrow in the input widget |
| 35 | | bool eventFilter(QObject* obj, QEvent* event); |
| 36 | | |
| 37 | | |
| 38 | | private slots: |
| 39 | | void toggleBreakpointAtCursor(bool changedTo); |
| 40 | | void runToCursor(bool changedTo); |
| 41 | | void rightBarChanged(QAction* changedTo); |
| 42 | | |
| 43 | | void executeCommand(bool withClear=true); |
| 44 | | |
| 45 | | void mountImage(bool changedTo); |
| 46 | | void unmountImage(bool changedTo); |
| 47 | | |
| 48 | | // Closing the main window actually exits the program |
| 49 | | void debugActClose(); |
| 50 | | |
| 51 | | |
| 52 | | private: |
| 53 | | // Widgets and docks |
| 54 | | QLineEdit* m_inputEdit; |
| 55 | | DebuggerView* m_consoleView; |
| 56 | | ProcessorDockWidget* m_procFrame; |
| 57 | | DasmDockWidget* m_dasmFrame; |
| 58 | | |
| 59 | | // Terminal history |
| 60 | | int m_historyIndex; |
| 61 | | std::vector<QString> m_inputHistory; |
| 62 | | void addToHistory(const QString& command); |
| 63 | | |
| 64 | | void createImagesMenu(); |
| 65 | | }; |
| 66 | | |
| 67 | | |
| 68 | | //============================================================ |
| 69 | | // Docks with the Main Window. Disassembly. |
| 70 | | //============================================================ |
| 71 | | class DasmDockWidget : public QWidget |
| 72 | | { |
| 73 | | Q_OBJECT |
| 74 | | |
| 75 | | public: |
| 76 | | DasmDockWidget(running_machine* machine, QWidget* parent=NULL) : |
| 77 | | QWidget(parent), |
| 78 | | m_machine(machine) |
| 79 | | { |
| 80 | | m_dasmView = new DebuggerView(DVT_DISASSEMBLY, |
| 81 | | m_machine, |
| 82 | | this); |
| 83 | | |
| 84 | | // Force a recompute of the disassembly region |
| 85 | | downcast<debug_view_disasm*>(m_dasmView->view())->set_expression("curpc"); |
| 86 | | |
| 87 | | QVBoxLayout* dvLayout = new QVBoxLayout(this); |
| 88 | | dvLayout->addWidget(m_dasmView); |
| 89 | | dvLayout->setContentsMargins(4,0,4,0); |
| 90 | | } |
| 91 | | |
| 92 | | |
| 93 | | virtual ~DasmDockWidget(); |
| 94 | | |
| 95 | | |
| 96 | | DebuggerView* view() { return m_dasmView; } |
| 97 | | |
| 98 | | |
| 99 | | QSize minimumSizeHint() const |
| 100 | | { |
| 101 | | return QSize(150,150); |
| 102 | | } |
| 103 | | |
| 104 | | |
| 105 | | QSize sizeHint() const |
| 106 | | { |
| 107 | | return QSize(150,200); |
| 108 | | } |
| 109 | | |
| 110 | | |
| 111 | | private: |
| 112 | | DebuggerView* m_dasmView; |
| 113 | | |
| 114 | | running_machine* m_machine; |
| 115 | | }; |
| 116 | | |
| 117 | | |
| 118 | | //============================================================ |
| 119 | | // Docks with the Main Window. Processor information. |
| 120 | | //============================================================ |
| 121 | | class ProcessorDockWidget : public QWidget |
| 122 | | { |
| 123 | | Q_OBJECT |
| 124 | | |
| 125 | | public: |
| 126 | | ProcessorDockWidget(running_machine* machine, |
| 127 | | QWidget* parent=NULL) : |
| 128 | | QWidget(parent), |
| 129 | | m_processorView(NULL), |
| 130 | | m_machine(machine) |
| 131 | | { |
| 132 | | m_processorView = new DebuggerView(DVT_STATE, |
| 133 | | m_machine, |
| 134 | | this); |
| 135 | | m_processorView->setFocusPolicy(Qt::NoFocus); |
| 136 | | |
| 137 | | QVBoxLayout* cvLayout = new QVBoxLayout(this); |
| 138 | | cvLayout->addWidget(m_processorView); |
| 139 | | cvLayout->setContentsMargins(4,0,4,2); |
| 140 | | } |
| 141 | | |
| 142 | | |
| 143 | | virtual ~ProcessorDockWidget(); |
| 144 | | |
| 145 | | |
| 146 | | DebuggerView* view() { return m_processorView; } |
| 147 | | |
| 148 | | |
| 149 | | QSize minimumSizeHint() const |
| 150 | | { |
| 151 | | return QSize(150,300); |
| 152 | | } |
| 153 | | |
| 154 | | |
| 155 | | QSize sizeHint() const |
| 156 | | { |
| 157 | | return QSize(200,300); |
| 158 | | } |
| 159 | | |
| 160 | | |
| 161 | | private: |
| 162 | | DebuggerView* m_processorView; |
| 163 | | |
| 164 | | running_machine* m_machine; |
| 165 | | }; |
| 166 | | |
| 167 | | |
| 168 | | //========================================================================= |
| 169 | | // A way to store the configuration of a window long enough to read/write. |
| 170 | | //========================================================================= |
| 171 | | class MainWindowQtConfig : public WindowQtConfig |
| 172 | | { |
| 173 | | public: |
| 174 | | MainWindowQtConfig() : |
| 175 | | WindowQtConfig(WIN_TYPE_MAIN), |
| 176 | | m_rightBar(0), |
| 177 | | m_windowState() |
| 178 | | {} |
| 179 | | |
| 180 | | ~MainWindowQtConfig() {} |
| 181 | | |
| 182 | | // Settings |
| 183 | | int m_rightBar; |
| 184 | | QByteArray m_windowState; |
| 185 | | |
| 186 | | void buildFromQWidget(QWidget* widget); |
| 187 | | void applyToQWidget(QWidget* widget); |
| 188 | | void addToXmlDataNode(xml_data_node* node) const; |
| 189 | | void recoverFromXmlNode(xml_data_node* node); |
| 190 | | }; |
| 191 | | |
| 192 | | |
| 193 | | |
| 194 | | #endif |
trunk/src/osd/modules/debugger/qt/debugqtmemorywindow.c
| r243594 | r243595 | |
| 1 | | #define NO_MEM_TRACKING |
| 2 | | |
| 3 | | #include "debugqtmemorywindow.h" |
| 4 | | |
| 5 | | #include "debug/dvmemory.h" |
| 6 | | #include "debug/debugcon.h" |
| 7 | | #include "debug/debugcpu.h" |
| 8 | | |
| 9 | | |
| 10 | | MemoryWindow::MemoryWindow(running_machine* machine, QWidget* parent) : |
| 11 | | WindowQt(machine, NULL) |
| 12 | | { |
| 13 | | setWindowTitle("Debug: Memory View"); |
| 14 | | |
| 15 | | if (parent != NULL) |
| 16 | | { |
| 17 | | QPoint parentPos = parent->pos(); |
| 18 | | setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400); |
| 19 | | } |
| 20 | | |
| 21 | | // |
| 22 | | // The main frame and its input and log widgets |
| 23 | | // |
| 24 | | QFrame* mainWindowFrame = new QFrame(this); |
| 25 | | |
| 26 | | // The top frame & groupbox that contains the input widgets |
| 27 | | QFrame* topSubFrame = new QFrame(mainWindowFrame); |
| 28 | | |
| 29 | | // The input edit |
| 30 | | m_inputEdit = new QLineEdit(topSubFrame); |
| 31 | | connect(m_inputEdit, SIGNAL(returnPressed()), this, SLOT(expressionSubmitted())); |
| 32 | | |
| 33 | | // The memory space combo box |
| 34 | | m_memoryComboBox = new QComboBox(topSubFrame); |
| 35 | | m_memoryComboBox->setObjectName("memoryregion"); |
| 36 | | m_memoryComboBox->setMinimumWidth(300); |
| 37 | | connect(m_memoryComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(memoryRegionChanged(int))); |
| 38 | | |
| 39 | | // The main memory window |
| 40 | | m_memTable = new DebuggerMemView(DVT_MEMORY, m_machine, this); |
| 41 | | |
| 42 | | // Layout |
| 43 | | QHBoxLayout* subLayout = new QHBoxLayout(topSubFrame); |
| 44 | | subLayout->addWidget(m_inputEdit); |
| 45 | | subLayout->addWidget(m_memoryComboBox); |
| 46 | | subLayout->setSpacing(3); |
| 47 | | subLayout->setContentsMargins(2,2,2,2); |
| 48 | | |
| 49 | | QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame); |
| 50 | | vLayout->setSpacing(3); |
| 51 | | vLayout->setContentsMargins(2,2,2,2); |
| 52 | | vLayout->addWidget(topSubFrame); |
| 53 | | vLayout->addWidget(m_memTable); |
| 54 | | |
| 55 | | setCentralWidget(mainWindowFrame); |
| 56 | | |
| 57 | | // |
| 58 | | // Menu bars |
| 59 | | // |
| 60 | | // Create a byte-chunk group |
| 61 | | QActionGroup* chunkGroup = new QActionGroup(this); |
| 62 | | chunkGroup->setObjectName("chunkgroup"); |
| 63 | | QAction* chunkActOne = new QAction("1-byte chunks", this); |
| 64 | | chunkActOne->setObjectName("chunkActOne"); |
| 65 | | QAction* chunkActTwo = new QAction("2-byte chunks", this); |
| 66 | | chunkActTwo->setObjectName("chunkActTwo"); |
| 67 | | QAction* chunkActFour = new QAction("4-byte chunks", this); |
| 68 | | chunkActFour->setObjectName("chunkActFour"); |
| 69 | | chunkActOne->setCheckable(true); |
| 70 | | chunkActTwo->setCheckable(true); |
| 71 | | chunkActFour->setCheckable(true); |
| 72 | | chunkActOne->setActionGroup(chunkGroup); |
| 73 | | chunkActTwo->setActionGroup(chunkGroup); |
| 74 | | chunkActFour->setActionGroup(chunkGroup); |
| 75 | | chunkActOne->setShortcut(QKeySequence("Ctrl+1")); |
| 76 | | chunkActTwo->setShortcut(QKeySequence("Ctrl+2")); |
| 77 | | chunkActFour->setShortcut(QKeySequence("Ctrl+4")); |
| 78 | | chunkActOne->setChecked(true); |
| 79 | | connect(chunkGroup, SIGNAL(triggered(QAction*)), this, SLOT(chunkChanged(QAction*))); |
| 80 | | |
| 81 | | // Create a address display group |
| 82 | | QActionGroup* addressGroup = new QActionGroup(this); |
| 83 | | addressGroup->setObjectName("addressgroup"); |
| 84 | | QAction* addressActLogical = new QAction("Logical Addresses", this); |
| 85 | | QAction* addressActPhysical = new QAction("Physical Addresses", this); |
| 86 | | addressActLogical->setCheckable(true); |
| 87 | | addressActPhysical->setCheckable(true); |
| 88 | | addressActLogical->setActionGroup(addressGroup); |
| 89 | | addressActPhysical->setActionGroup(addressGroup); |
| 90 | | addressActLogical->setShortcut(QKeySequence("Ctrl+G")); |
| 91 | | addressActPhysical->setShortcut(QKeySequence("Ctrl+Y")); |
| 92 | | addressActLogical->setChecked(true); |
| 93 | | connect(addressGroup, SIGNAL(triggered(QAction*)), this, SLOT(addressChanged(QAction*))); |
| 94 | | |
| 95 | | // Create a reverse view radio |
| 96 | | QAction* reverseAct = new QAction("Reverse View", this); |
| 97 | | reverseAct->setObjectName("reverse"); |
| 98 | | reverseAct->setCheckable(true); |
| 99 | | reverseAct->setShortcut(QKeySequence("Ctrl+R")); |
| 100 | | connect(reverseAct, SIGNAL(toggled(bool)), this, SLOT(reverseChanged(bool))); |
| 101 | | |
| 102 | | // Create increase and decrease bytes-per-line actions |
| 103 | | QAction* increaseBplAct = new QAction("Increase Bytes Per Line", this); |
| 104 | | QAction* decreaseBplAct = new QAction("Decrease Bytes Per Line", this); |
| 105 | | increaseBplAct->setShortcut(QKeySequence("Ctrl+P")); |
| 106 | | decreaseBplAct->setShortcut(QKeySequence("Ctrl+O")); |
| 107 | | connect(increaseBplAct, SIGNAL(triggered(bool)), this, SLOT(increaseBytesPerLine(bool))); |
| 108 | | connect(decreaseBplAct, SIGNAL(triggered(bool)), this, SLOT(decreaseBytesPerLine(bool))); |
| 109 | | |
| 110 | | // Assemble the options menu |
| 111 | | QMenu* optionsMenu = menuBar()->addMenu("&Options"); |
| 112 | | optionsMenu->addActions(chunkGroup->actions()); |
| 113 | | optionsMenu->addSeparator(); |
| 114 | | optionsMenu->addActions(addressGroup->actions()); |
| 115 | | optionsMenu->addSeparator(); |
| 116 | | optionsMenu->addAction(reverseAct); |
| 117 | | optionsMenu->addSeparator(); |
| 118 | | optionsMenu->addAction(increaseBplAct); |
| 119 | | optionsMenu->addAction(decreaseBplAct); |
| 120 | | |
| 121 | | |
| 122 | | // |
| 123 | | // Initialize |
| 124 | | // |
| 125 | | populateComboBox(); |
| 126 | | |
| 127 | | // Set to the current CPU's memory view |
| 128 | | setToCurrentCpu(); |
| 129 | | } |
| 130 | | |
| 131 | | |
| 132 | | MemoryWindow::~MemoryWindow() |
| 133 | | { |
| 134 | | } |
| 135 | | |
| 136 | | |
| 137 | | void MemoryWindow::memoryRegionChanged(int index) |
| 138 | | { |
| 139 | | m_memTable->view()->set_source(*m_memTable->view()->source_list().find(index)); |
| 140 | | m_memTable->viewport()->update(); |
| 141 | | |
| 142 | | // Update the chunk size radio buttons to the memory region's default |
| 143 | | debug_view_memory* memView = downcast<debug_view_memory*>(m_memTable->view()); |
| 144 | | switch(memView->bytes_per_chunk()) |
| 145 | | { |
| 146 | | case 1: chunkSizeMenuItem("chunkActOne")->setChecked(true); break; |
| 147 | | case 2: chunkSizeMenuItem("chunkActTwo")->setChecked(true); break; |
| 148 | | case 4: chunkSizeMenuItem("chunkActFour")->setChecked(true); break; |
| 149 | | default: break; |
| 150 | | } |
| 151 | | } |
| 152 | | |
| 153 | | |
| 154 | | void MemoryWindow::expressionSubmitted() |
| 155 | | { |
| 156 | | const QString expression = m_inputEdit->text(); |
| 157 | | downcast<debug_view_memory*>(m_memTable->view())->set_expression(expression.toLocal8Bit().data()); |
| 158 | | |
| 159 | | // Make the cursor pop |
| 160 | | m_memTable->view()->set_cursor_visible(true); |
| 161 | | |
| 162 | | // Check where the cursor is and adjust the scroll accordingly |
| 163 | | debug_view_xy cursorPosition = m_memTable->view()->cursor_position(); |
| 164 | | // TODO: check if the region is already visible? |
| 165 | | m_memTable->verticalScrollBar()->setValue(cursorPosition.y); |
| 166 | | |
| 167 | | m_memTable->update(); |
| 168 | | m_memTable->viewport()->update(); |
| 169 | | } |
| 170 | | |
| 171 | | |
| 172 | | void MemoryWindow::chunkChanged(QAction* changedTo) |
| 173 | | { |
| 174 | | debug_view_memory* memView = downcast<debug_view_memory*>(m_memTable->view()); |
| 175 | | if (changedTo->text() == "1-byte chunks") |
| 176 | | { |
| 177 | | memView->set_bytes_per_chunk(1); |
| 178 | | } |
| 179 | | else if (changedTo->text() == "2-byte chunks") |
| 180 | | { |
| 181 | | memView->set_bytes_per_chunk(2); |
| 182 | | } |
| 183 | | else if (changedTo->text() == "4-byte chunks") |
| 184 | | { |
| 185 | | memView->set_bytes_per_chunk(4); |
| 186 | | } |
| 187 | | m_memTable->viewport()->update(); |
| 188 | | } |
| 189 | | |
| 190 | | |
| 191 | | void MemoryWindow::addressChanged(QAction* changedTo) |
| 192 | | { |
| 193 | | debug_view_memory* memView = downcast<debug_view_memory*>(m_memTable->view()); |
| 194 | | if (changedTo->text() == "Logical Addresses") |
| 195 | | { |
| 196 | | memView->set_physical(false); |
| 197 | | } |
| 198 | | else if (changedTo->text() == "Physical Addresses") |
| 199 | | { |
| 200 | | memView->set_physical(true); |
| 201 | | } |
| 202 | | m_memTable->viewport()->update(); |
| 203 | | } |
| 204 | | |
| 205 | | |
| 206 | | void MemoryWindow::reverseChanged(bool changedTo) |
| 207 | | { |
| 208 | | debug_view_memory* memView = downcast<debug_view_memory*>(m_memTable->view()); |
| 209 | | memView->set_reverse(changedTo); |
| 210 | | m_memTable->viewport()->update(); |
| 211 | | } |
| 212 | | |
| 213 | | |
| 214 | | void MemoryWindow::increaseBytesPerLine(bool changedTo) |
| 215 | | { |
| 216 | | debug_view_memory* memView = downcast<debug_view_memory*>(m_memTable->view()); |
| 217 | | memView->set_chunks_per_row(memView->chunks_per_row() + 1); |
| 218 | | m_memTable->viewport()->update(); |
| 219 | | } |
| 220 | | |
| 221 | | |
| 222 | | void MemoryWindow::decreaseBytesPerLine(bool checked) |
| 223 | | { |
| 224 | | debug_view_memory* memView = downcast<debug_view_memory*>(m_memTable->view()); |
| 225 | | memView->set_chunks_per_row(memView->chunks_per_row() - 1); |
| 226 | | m_memTable->viewport()->update(); |
| 227 | | } |
| 228 | | |
| 229 | | |
| 230 | | void MemoryWindow::populateComboBox() |
| 231 | | { |
| 232 | | if (m_memTable == NULL) |
| 233 | | return; |
| 234 | | |
| 235 | | m_memoryComboBox->clear(); |
| 236 | | for (const debug_view_source* source = m_memTable->view()->first_source(); |
| 237 | | source != NULL; |
| 238 | | source = source->next()) |
| 239 | | { |
| 240 | | m_memoryComboBox->addItem(source->name()); |
| 241 | | } |
| 242 | | } |
| 243 | | |
| 244 | | |
| 245 | | void MemoryWindow::setToCurrentCpu() |
| 246 | | { |
| 247 | | device_t* curCpu = debug_cpu_get_visible_cpu(*m_machine); |
| 248 | | const debug_view_source *source = m_memTable->view()->source_for_device(curCpu); |
| 249 | | const int listIndex = m_memTable->view()->source_list().indexof(*source); |
| 250 | | m_memoryComboBox->setCurrentIndex(listIndex); |
| 251 | | } |
| 252 | | |
| 253 | | |
| 254 | | // I have a hard time storing QActions as class members. This is a substitute. |
| 255 | | QAction* MemoryWindow::chunkSizeMenuItem(const QString& itemName) |
| 256 | | { |
| 257 | | QList<QMenu*> menus = menuBar()->findChildren<QMenu*>(); |
| 258 | | for (int i = 0; i < menus.length(); i++) |
| 259 | | { |
| 260 | | if (menus[i]->title() != "&Options") continue; |
| 261 | | QList<QAction*> actions = menus[i]->actions(); |
| 262 | | for (int j = 0; j < actions.length(); j++) |
| 263 | | { |
| 264 | | if (actions[j]->objectName() == itemName) |
| 265 | | return actions[j]; |
| 266 | | } |
| 267 | | } |
| 268 | | return NULL; |
| 269 | | } |
| 270 | | |
| 271 | | |
| 272 | | //========================================================================= |
| 273 | | // DebuggerMemView |
| 274 | | //========================================================================= |
| 275 | | void DebuggerMemView::mousePressEvent(QMouseEvent* event) |
| 276 | | { |
| 277 | | const bool leftClick = event->button() == Qt::LeftButton; |
| 278 | | const bool rightClick = event->button() == Qt::RightButton; |
| 279 | | |
| 280 | | if (leftClick || rightClick) |
| 281 | | { |
| 282 | | QFontMetrics actualFont = fontMetrics(); |
| 283 | | const double fontWidth = actualFont.width(QString(100, '_')) / 100.; |
| 284 | | const int fontHeight = MAX(1, actualFont.height()); |
| 285 | | |
| 286 | | debug_view_xy topLeft = view()->visible_position(); |
| 287 | | debug_view_xy clickViewPosition; |
| 288 | | clickViewPosition.x = topLeft.x + (event->x() / fontWidth); |
| 289 | | clickViewPosition.y = topLeft.y + (event->y() / fontHeight); |
| 290 | | if (leftClick) |
| 291 | | { |
| 292 | | view()->process_click(DCK_LEFT_CLICK, clickViewPosition); |
| 293 | | } |
| 294 | | else if (rightClick) |
| 295 | | { |
| 296 | | // Display the last known PC to write to this memory location & copy it onto the clipboard |
| 297 | | debug_view_memory* memView = downcast<debug_view_memory*>(view()); |
| 298 | | const offs_t address = memView->addressAtCursorPosition(clickViewPosition); |
| 299 | | const debug_view_memory_source* source = downcast<const debug_view_memory_source*>(memView->source()); |
| 300 | | address_space* addressSpace = source->space(); |
| 301 | | const int nativeDataWidth = addressSpace->data_width() / 8; |
| 302 | | const UINT64 memValue = debug_read_memory(*addressSpace, |
| 303 | | addressSpace->address_to_byte(address), |
| 304 | | nativeDataWidth, |
| 305 | | true); |
| 306 | | const offs_t pc = source->device()->debug()->track_mem_pc_from_space_address_data(addressSpace->spacenum(), |
| 307 | | address, |
| 308 | | memValue); |
| 309 | | if (pc != (offs_t)(-1)) |
| 310 | | { |
| 311 | | // TODO: You can specify a box that the tooltip stays alive within - might be good? |
| 312 | | const QString addressAndPc = QString("Address %1 written at PC=%2").arg(address, 2, 16).arg(pc, 2, 16); |
| 313 | | QToolTip::showText(QCursor::pos(), addressAndPc, NULL); |
| 314 | | |
| 315 | | // Copy the PC into the clipboard as well |
| 316 | | QClipboard *clipboard = QApplication::clipboard(); |
| 317 | | clipboard->setText(QString("%1").arg(pc, 2, 16)); |
| 318 | | } |
| 319 | | else |
| 320 | | { |
| 321 | | QToolTip::showText(QCursor::pos(), "UNKNOWN PC", NULL); |
| 322 | | } |
| 323 | | } |
| 324 | | |
| 325 | | viewport()->update(); |
| 326 | | update(); |
| 327 | | } |
| 328 | | } |
| 329 | | |
| 330 | | |
| 331 | | //========================================================================= |
| 332 | | // MemoryWindowQtConfig |
| 333 | | //========================================================================= |
| 334 | | void MemoryWindowQtConfig::buildFromQWidget(QWidget* widget) |
| 335 | | { |
| 336 | | WindowQtConfig::buildFromQWidget(widget); |
| 337 | | MemoryWindow* window = dynamic_cast<MemoryWindow*>(widget); |
| 338 | | QComboBox* memoryRegion = window->findChild<QComboBox*>("memoryregion"); |
| 339 | | m_memoryRegion = memoryRegion->currentIndex(); |
| 340 | | |
| 341 | | QAction* reverse = window->findChild<QAction*>("reverse"); |
| 342 | | m_reverse = reverse->isChecked(); |
| 343 | | |
| 344 | | QActionGroup* addressGroup = window->findChild<QActionGroup*>("addressgroup"); |
| 345 | | if (addressGroup->checkedAction()->text() == "Logical Addresses") |
| 346 | | m_addressMode = 0; |
| 347 | | else if (addressGroup->checkedAction()->text() == "Physical Addresses") |
| 348 | | m_addressMode = 1; |
| 349 | | |
| 350 | | QActionGroup* chunkGroup = window->findChild<QActionGroup*>("chunkgroup"); |
| 351 | | if (chunkGroup->checkedAction()->text() == "1-byte chunks") |
| 352 | | m_chunkSize = 0; |
| 353 | | else if (chunkGroup->checkedAction()->text() == "2-byte chunks") |
| 354 | | m_chunkSize = 1; |
| 355 | | else if (chunkGroup->checkedAction()->text() == "4-byte chunks") |
| 356 | | m_chunkSize = 2; |
| 357 | | } |
| 358 | | |
| 359 | | |
| 360 | | void MemoryWindowQtConfig::applyToQWidget(QWidget* widget) |
| 361 | | { |
| 362 | | WindowQtConfig::applyToQWidget(widget); |
| 363 | | MemoryWindow* window = dynamic_cast<MemoryWindow*>(widget); |
| 364 | | QComboBox* memoryRegion = window->findChild<QComboBox*>("memoryregion"); |
| 365 | | memoryRegion->setCurrentIndex(m_memoryRegion); |
| 366 | | |
| 367 | | QAction* reverse = window->findChild<QAction*>("reverse"); |
| 368 | | if (m_reverse) reverse->trigger(); |
| 369 | | |
| 370 | | QActionGroup* addressGroup = window->findChild<QActionGroup*>("addressgroup"); |
| 371 | | addressGroup->actions()[m_addressMode]->trigger(); |
| 372 | | |
| 373 | | QActionGroup* chunkGroup = window->findChild<QActionGroup*>("chunkgroup"); |
| 374 | | chunkGroup->actions()[m_chunkSize]->trigger(); |
| 375 | | } |
| 376 | | |
| 377 | | |
| 378 | | void MemoryWindowQtConfig::addToXmlDataNode(xml_data_node* node) const |
| 379 | | { |
| 380 | | WindowQtConfig::addToXmlDataNode(node); |
| 381 | | xml_set_attribute_int(node, "memoryregion", m_memoryRegion); |
| 382 | | xml_set_attribute_int(node, "reverse", m_reverse); |
| 383 | | xml_set_attribute_int(node, "addressmode", m_addressMode); |
| 384 | | xml_set_attribute_int(node, "chunksize", m_chunkSize); |
| 385 | | } |
| 386 | | |
| 387 | | |
| 388 | | void MemoryWindowQtConfig::recoverFromXmlNode(xml_data_node* node) |
| 389 | | { |
| 390 | | WindowQtConfig::recoverFromXmlNode(node); |
| 391 | | m_memoryRegion = xml_get_attribute_int(node, "memoryregion", m_memoryRegion); |
| 392 | | m_reverse = xml_get_attribute_int(node, "reverse", m_reverse); |
| 393 | | m_addressMode = xml_get_attribute_int(node, "addressmode", m_addressMode); |
| 394 | | m_chunkSize = xml_get_attribute_int(node, "chunksize", m_chunkSize); |
| 395 | | } |
trunk/src/osd/modules/debugger/qt/debugqtview.c
| r243594 | r243595 | |
| 1 | | #define NO_MEM_TRACKING |
| 2 | | |
| 3 | | #include "debugqtview.h" |
| 4 | | |
| 5 | | DebuggerView::DebuggerView(const debug_view_type& type, |
| 6 | | running_machine* machine, |
| 7 | | QWidget* parent) : |
| 8 | | QAbstractScrollArea(parent), |
| 9 | | m_preferBottom(false), |
| 10 | | m_view(NULL), |
| 11 | | m_machine(machine) |
| 12 | | { |
| 13 | | // I like setting the font per-view since it doesn't override the menuing fonts. |
| 14 | | QFont viewFontRequest("Courier New"); |
| 15 | | viewFontRequest.setFixedPitch(true); |
| 16 | | viewFontRequest.setPointSize(11); |
| 17 | | setFont(viewFontRequest); |
| 18 | | |
| 19 | | m_view = m_machine->debug_view().alloc_view(type, |
| 20 | | DebuggerView::debuggerViewUpdate, |
| 21 | | this); |
| 22 | | |
| 23 | | connect(verticalScrollBar(), SIGNAL(valueChanged(int)), |
| 24 | | this, SLOT(verticalScrollSlot(int))); |
| 25 | | connect(horizontalScrollBar(), SIGNAL(valueChanged(int)), |
| 26 | | this, SLOT(horizontalScrollSlot(int))); |
| 27 | | } |
| 28 | | |
| 29 | | |
| 30 | | DebuggerView::~DebuggerView() |
| 31 | | { |
| 32 | | if (m_machine && m_view) |
| 33 | | m_machine->debug_view().free_view(*m_view); |
| 34 | | } |
| 35 | | |
| 36 | | // TODO: remove this version no later than January 1, 2015 |
| 37 | | #if QT_VERSION < QT_VERSION_CHECK(4, 7, 0) |
| 38 | | void DebuggerView::paintEvent(QPaintEvent* event) |
| 39 | | { |
| 40 | | // Tell the MAME debug view how much real estate is available |
| 41 | | QFontMetrics actualFont = fontMetrics(); |
| 42 | | const int fontWidth = MAX(1, actualFont.width('_')); |
| 43 | | const int fontHeight = MAX(1, actualFont.height()); |
| 44 | | m_view->set_visible_size(debug_view_xy(width()/fontWidth, height()/fontHeight)); |
| 45 | | |
| 46 | | |
| 47 | | // Handle the scroll bars |
| 48 | | const int horizontalScrollCharDiff = m_view->total_size().x - m_view->visible_size().x; |
| 49 | | const int horizontalScrollSize = horizontalScrollCharDiff < 0 ? 0 : horizontalScrollCharDiff; |
| 50 | | horizontalScrollBar()->setRange(0, horizontalScrollSize); |
| 51 | | |
| 52 | | // If the horizontal scroll bar appears, make sure to adjust the vertical scrollbar accordingly |
| 53 | | const int verticalScrollAdjust = horizontalScrollSize > 0 ? 1 : 0; |
| 54 | | |
| 55 | | const int verticalScrollCharDiff = m_view->total_size().y - m_view->visible_size().y; |
| 56 | | const int verticalScrollSize = verticalScrollCharDiff < 0 ? 0 : verticalScrollCharDiff+verticalScrollAdjust; |
| 57 | | bool atEnd = false; |
| 58 | | if (verticalScrollBar()->value() == verticalScrollBar()->maximum()) |
| 59 | | { |
| 60 | | atEnd = true; |
| 61 | | } |
| 62 | | verticalScrollBar()->setRange(0, verticalScrollSize); |
| 63 | | if (m_preferBottom && atEnd) |
| 64 | | { |
| 65 | | verticalScrollBar()->setValue(verticalScrollSize); |
| 66 | | } |
| 67 | | |
| 68 | | |
| 69 | | // Draw the viewport widget |
| 70 | | QPainter painter(viewport()); |
| 71 | | painter.fillRect(0, 0, width(), height(), QBrush(Qt::white)); |
| 72 | | painter.setBackgroundMode(Qt::OpaqueMode); |
| 73 | | painter.setBackground(QColor(255,255,255)); |
| 74 | | |
| 75 | | // Background control |
| 76 | | QBrush bgBrush; |
| 77 | | bgBrush.setStyle(Qt::SolidPattern); |
| 78 | | painter.setPen(QPen(QColor(0,0,0))); |
| 79 | | |
| 80 | | size_t viewDataOffset = 0; |
| 81 | | const debug_view_xy& visibleCharDims = m_view->visible_size(); |
| 82 | | for (int y = 0; y < visibleCharDims.y; y++) |
| 83 | | { |
| 84 | | for (int x = 0; x < visibleCharDims.x; x++) |
| 85 | | { |
| 86 | | const unsigned char textAttr = m_view->viewdata()[viewDataOffset].attrib; |
| 87 | | |
| 88 | | if (x == 0 || textAttr != m_view->viewdata()[viewDataOffset-1].attrib) |
| 89 | | { |
| 90 | | // Text color handling |
| 91 | | QColor fgColor(0,0,0); |
| 92 | | QColor bgColor(255,255,255); |
| 93 | | |
| 94 | | if(textAttr & DCA_VISITED) |
| 95 | | { |
| 96 | | bgColor.setRgb(0xc6, 0xe2, 0xff); |
| 97 | | } |
| 98 | | if(textAttr & DCA_ANCILLARY) |
| 99 | | { |
| 100 | | bgColor.setRgb(0xe0, 0xe0, 0xe0); |
| 101 | | } |
| 102 | | if(textAttr & DCA_SELECTED) |
| 103 | | { |
| 104 | | bgColor.setRgb(0xff, 0x80, 0x80); |
| 105 | | } |
| 106 | | if(textAttr & DCA_CURRENT) |
| 107 | | { |
| 108 | | bgColor.setRgb(0xff, 0xff, 0x00); |
| 109 | | } |
| 110 | | if ((textAttr & DCA_SELECTED) && (textAttr & DCA_CURRENT)) |
| 111 | | { |
| 112 | | bgColor.setRgb(0xff,0xc0,0x80); |
| 113 | | } |
| 114 | | if(textAttr & DCA_CHANGED) |
| 115 | | { |
| 116 | | fgColor.setRgb(0xff, 0x00, 0x00); |
| 117 | | } |
| 118 | | if(textAttr & DCA_INVALID) |
| 119 | | { |
| 120 | | fgColor.setRgb(0x00, 0x00, 0xff); |
| 121 | | } |
| 122 | | if(textAttr & DCA_DISABLED) |
| 123 | | { |
| 124 | | fgColor.setRgb((fgColor.red() + bgColor.red()) >> 1, |
| 125 | | (fgColor.green() + bgColor.green()) >> 1, |
| 126 | | (fgColor.blue() + bgColor.blue()) >> 1); |
| 127 | | } |
| 128 | | if(textAttr & DCA_COMMENT) |
| 129 | | { |
| 130 | | fgColor.setRgb(0x00, 0x80, 0x00); |
| 131 | | } |
| 132 | | |
| 133 | | bgBrush.setColor(bgColor); |
| 134 | | painter.setBackground(bgBrush); |
| 135 | | painter.setPen(QPen(fgColor)); |
| 136 | | } |
| 137 | | |
| 138 | | // Your character is not guaranteed to take up the entire fontWidth x fontHeight, so fill before. |
| 139 | | painter.fillRect(x*fontWidth, y*fontHeight, fontWidth, fontHeight, bgBrush); |
| 140 | | |
| 141 | | // There is a touchy interplay between font height, drawing difference, visible position, etc |
| 142 | | // Fonts don't get drawn "down and to the left" like boxes, so some wiggling is needed. |
| 143 | | painter.drawText(x*fontWidth, |
| 144 | | (y*fontHeight + (fontHeight*0.80)), |
| 145 | | QString(m_view->viewdata()[viewDataOffset].byte)); |
| 146 | | viewDataOffset++; |
| 147 | | } |
| 148 | | } |
| 149 | | } |
| 150 | | #else |
| 151 | | void DebuggerView::paintEvent(QPaintEvent* event) |
| 152 | | { |
| 153 | | // Tell the MAME debug view how much real estate is available |
| 154 | | QFontMetrics actualFont = fontMetrics(); |
| 155 | | const double fontWidth = actualFont.width(QString(100, '_')) / 100.; |
| 156 | | const int fontHeight = MAX(1, actualFont.height()); |
| 157 | | m_view->set_visible_size(debug_view_xy(width()/fontWidth, height()/fontHeight)); |
| 158 | | |
| 159 | | |
| 160 | | // Handle the scroll bars |
| 161 | | const int horizontalScrollCharDiff = m_view->total_size().x - m_view->visible_size().x; |
| 162 | | const int horizontalScrollSize = horizontalScrollCharDiff < 0 ? 0 : horizontalScrollCharDiff; |
| 163 | | horizontalScrollBar()->setRange(0, horizontalScrollSize); |
| 164 | | |
| 165 | | // If the horizontal scroll bar appears, make sure to adjust the vertical scrollbar accordingly |
| 166 | | const int verticalScrollAdjust = horizontalScrollSize > 0 ? 1 : 0; |
| 167 | | |
| 168 | | const int verticalScrollCharDiff = m_view->total_size().y - m_view->visible_size().y; |
| 169 | | const int verticalScrollSize = verticalScrollCharDiff < 0 ? 0 : verticalScrollCharDiff+verticalScrollAdjust; |
| 170 | | bool atEnd = false; |
| 171 | | if (verticalScrollBar()->value() == verticalScrollBar()->maximum()) |
| 172 | | { |
| 173 | | atEnd = true; |
| 174 | | } |
| 175 | | verticalScrollBar()->setRange(0, verticalScrollSize); |
| 176 | | if (m_preferBottom && atEnd) |
| 177 | | { |
| 178 | | verticalScrollBar()->setValue(verticalScrollSize); |
| 179 | | } |
| 180 | | |
| 181 | | |
| 182 | | // Draw the viewport widget |
| 183 | | QPainter painter(viewport()); |
| 184 | | painter.fillRect(0, 0, width(), height(), QBrush(Qt::white)); |
| 185 | | painter.setBackgroundMode(Qt::OpaqueMode); |
| 186 | | painter.setBackground(QColor(255,255,255)); |
| 187 | | |
| 188 | | // Background control |
| 189 | | QBrush bgBrush; |
| 190 | | bgBrush.setStyle(Qt::SolidPattern); |
| 191 | | painter.setPen(QPen(QColor(0,0,0))); |
| 192 | | |
| 193 | | size_t viewDataOffset = 0; |
| 194 | | const debug_view_xy& visibleCharDims = m_view->visible_size(); |
| 195 | | const debug_view_char* viewdata = m_view->viewdata(); |
| 196 | | for (int y = 0; y < visibleCharDims.y; y++) |
| 197 | | { |
| 198 | | int width = 1; |
| 199 | | for (int x = 0; x < visibleCharDims.x; viewDataOffset += width, x += width) |
| 200 | | { |
| 201 | | const unsigned char textAttr = viewdata[viewDataOffset].attrib; |
| 202 | | |
| 203 | | // Text color handling |
| 204 | | QColor fgColor(0,0,0); |
| 205 | | QColor bgColor(255,255,255); |
| 206 | | |
| 207 | | if(textAttr & DCA_VISITED) |
| 208 | | { |
| 209 | | bgColor.setRgb(0xc6, 0xe2, 0xff); |
| 210 | | } |
| 211 | | if(textAttr & DCA_ANCILLARY) |
| 212 | | { |
| 213 | | bgColor.setRgb(0xe0, 0xe0, 0xe0); |
| 214 | | } |
| 215 | | if(textAttr & DCA_SELECTED) |
| 216 | | { |
| 217 | | bgColor.setRgb(0xff, 0x80, 0x80); |
| 218 | | } |
| 219 | | if(textAttr & DCA_CURRENT) |
| 220 | | { |
| 221 | | bgColor.setRgb(0xff, 0xff, 0x00); |
| 222 | | } |
| 223 | | if ((textAttr & DCA_SELECTED) && (textAttr & DCA_CURRENT)) |
| 224 | | { |
| 225 | | bgColor.setRgb(0xff,0xc0,0x80); |
| 226 | | } |
| 227 | | if(textAttr & DCA_CHANGED) |
| 228 | | { |
| 229 | | fgColor.setRgb(0xff, 0x00, 0x00); |
| 230 | | } |
| 231 | | if(textAttr & DCA_INVALID) |
| 232 | | { |
| 233 | | fgColor.setRgb(0x00, 0x00, 0xff); |
| 234 | | } |
| 235 | | if(textAttr & DCA_DISABLED) |
| 236 | | { |
| 237 | | fgColor.setRgb((fgColor.red() + bgColor.red()) >> 1, |
| 238 | | (fgColor.green() + bgColor.green()) >> 1, |
| 239 | | (fgColor.blue() + bgColor.blue()) >> 1); |
| 240 | | } |
| 241 | | if(textAttr & DCA_COMMENT) |
| 242 | | { |
| 243 | | fgColor.setRgb(0x00, 0x80, 0x00); |
| 244 | | } |
| 245 | | |
| 246 | | bgBrush.setColor(bgColor); |
| 247 | | painter.setBackground(bgBrush); |
| 248 | | painter.setPen(QPen(fgColor)); |
| 249 | | |
| 250 | | QString text(QChar(viewdata[viewDataOffset].byte)); |
| 251 | | for (width = 1; x + width < visibleCharDims.x; width++) |
| 252 | | { |
| 253 | | if (textAttr != viewdata[viewDataOffset + width].attrib) |
| 254 | | break; |
| 255 | | text.append(QChar(viewdata[viewDataOffset + width].byte)); |
| 256 | | } |
| 257 | | |
| 258 | | // Your characters are not guaranteed to take up the entire length x fontWidth x fontHeight, so fill before. |
| 259 | | painter.fillRect(x*fontWidth, y*fontHeight, width*fontWidth, fontHeight, bgBrush); |
| 260 | | |
| 261 | | // There is a touchy interplay between font height, drawing difference, visible position, etc |
| 262 | | // Fonts don't get drawn "down and to the left" like boxes, so some wiggling is needed. |
| 263 | | painter.drawText(x*fontWidth, (y*fontHeight + (fontHeight*0.80)), text); |
| 264 | | } |
| 265 | | } |
| 266 | | } |
| 267 | | #endif |
| 268 | | |
| 269 | | void DebuggerView::keyPressEvent(QKeyEvent* event) |
| 270 | | { |
| 271 | | if (m_view == NULL) |
| 272 | | return QWidget::keyPressEvent(event); |
| 273 | | |
| 274 | | Qt::KeyboardModifiers keyMods = QApplication::keyboardModifiers(); |
| 275 | | const bool ctrlDown = keyMods.testFlag(Qt::ControlModifier); |
| 276 | | |
| 277 | | int keyPress = -1; |
| 278 | | switch (event->key()) |
| 279 | | { |
| 280 | | case Qt::Key_Up: |
| 281 | | keyPress = DCH_UP; |
| 282 | | break; |
| 283 | | case Qt::Key_Down: |
| 284 | | keyPress = DCH_DOWN; |
| 285 | | break; |
| 286 | | case Qt::Key_Left: |
| 287 | | keyPress = DCH_LEFT; |
| 288 | | if (ctrlDown) keyPress = DCH_CTRLLEFT; |
| 289 | | break; |
| 290 | | case Qt::Key_Right: |
| 291 | | keyPress = DCH_RIGHT; |
| 292 | | if (ctrlDown) keyPress = DCH_CTRLRIGHT; |
| 293 | | break; |
| 294 | | case Qt::Key_PageUp: |
| 295 | | keyPress = DCH_PUP; |
| 296 | | break; |
| 297 | | case Qt::Key_PageDown: |
| 298 | | keyPress = DCH_PDOWN; |
| 299 | | break; |
| 300 | | case Qt::Key_Home: |
| 301 | | keyPress = DCH_HOME; |
| 302 | | if (ctrlDown) keyPress = DCH_CTRLHOME; |
| 303 | | break; |
| 304 | | case Qt::Key_End: |
| 305 | | keyPress = DCH_END; |
| 306 | | if (ctrlDown) keyPress = DCH_CTRLEND; |
| 307 | | break; |
| 308 | | case Qt::Key_0: keyPress = '0'; break; |
| 309 | | case Qt::Key_1: keyPress = '1'; break; |
| 310 | | case Qt::Key_2: keyPress = '2'; break; |
| 311 | | case Qt::Key_3: keyPress = '3'; break; |
| 312 | | case Qt::Key_4: keyPress = '4'; break; |
| 313 | | case Qt::Key_5: keyPress = '5'; break; |
| 314 | | case Qt::Key_6: keyPress = '6'; break; |
| 315 | | case Qt::Key_7: keyPress = '7'; break; |
| 316 | | case Qt::Key_8: keyPress = '8'; break; |
| 317 | | case Qt::Key_9: keyPress = '9'; break; |
| 318 | | case Qt::Key_A: keyPress = 'a'; break; |
| 319 | | case Qt::Key_B: keyPress = 'b'; break; |
| 320 | | case Qt::Key_C: keyPress = 'c'; break; |
| 321 | | case Qt::Key_D: keyPress = 'd'; break; |
| 322 | | case Qt::Key_E: keyPress = 'e'; break; |
| 323 | | case Qt::Key_F: keyPress = 'f'; break; |
| 324 | | default: |
| 325 | | return QWidget::keyPressEvent(event); |
| 326 | | } |
| 327 | | |
| 328 | | m_view->set_cursor_visible(true); |
| 329 | | m_view->process_char(keyPress); |
| 330 | | |
| 331 | | // Catch the view up with the cursor |
| 332 | | verticalScrollBar()->setValue(m_view->visible_position().y); |
| 333 | | |
| 334 | | viewport()->update(); |
| 335 | | update(); |
| 336 | | } |
| 337 | | |
| 338 | | |
| 339 | | void DebuggerView::mousePressEvent(QMouseEvent* event) |
| 340 | | { |
| 341 | | if (m_view == NULL) |
| 342 | | return; |
| 343 | | |
| 344 | | if (event->button() == Qt::LeftButton) |
| 345 | | { |
| 346 | | QFontMetrics actualFont = fontMetrics(); |
| 347 | | const double fontWidth = actualFont.width(QString(100, '_')) / 100.; |
| 348 | | const int fontHeight = MAX(1, actualFont.height()); |
| 349 | | |
| 350 | | debug_view_xy topLeft = m_view->visible_position(); |
| 351 | | debug_view_xy clickViewPosition; |
| 352 | | clickViewPosition.x = topLeft.x + (event->x() / fontWidth); |
| 353 | | clickViewPosition.y = topLeft.y + (event->y() / fontHeight); |
| 354 | | m_view->process_click(DCK_LEFT_CLICK, clickViewPosition); |
| 355 | | |
| 356 | | viewport()->update(); |
| 357 | | update(); |
| 358 | | } |
| 359 | | } |
| 360 | | |
| 361 | | |
| 362 | | void DebuggerView::verticalScrollSlot(int value) |
| 363 | | { |
| 364 | | m_view->set_visible_position(debug_view_xy(horizontalScrollBar()->value(), value)); |
| 365 | | } |
| 366 | | |
| 367 | | |
| 368 | | void DebuggerView::horizontalScrollSlot(int value) |
| 369 | | { |
| 370 | | m_view->set_visible_position(debug_view_xy(value, verticalScrollBar()->value())); |
| 371 | | } |
| 372 | | |
| 373 | | |
| 374 | | void DebuggerView::debuggerViewUpdate(debug_view& debugView, void* osdPrivate) |
| 375 | | { |
| 376 | | // Get a handle to the DebuggerView being updated & redraw |
| 377 | | DebuggerView* dView = (DebuggerView*)osdPrivate; |
| 378 | | dView->verticalScrollBar()->setValue(dView->view()->visible_position().y); |
| 379 | | dView->horizontalScrollBar()->setValue(dView->view()->visible_position().x); |
| 380 | | dView->viewport()->update(); |
| 381 | | dView->update(); |
| 382 | | } |
trunk/src/osd/modules/debugger/qt/debugqtwindow.c
| r243594 | r243595 | |
| 1 | | #define NO_MEM_TRACKING |
| 2 | | |
| 3 | | #include "debugqtwindow.h" |
| 4 | | #include "debugqtlogwindow.h" |
| 5 | | #include "debugqtdasmwindow.h" |
| 6 | | #include "debugqtmemorywindow.h" |
| 7 | | #include "debugqtbreakpointswindow.h" |
| 8 | | #include "debugqtdeviceswindow.h" |
| 9 | | |
| 10 | | bool WindowQt::s_refreshAll = false; |
| 11 | | bool WindowQt::s_hideAll = false; |
| 12 | | |
| 13 | | |
| 14 | | // Since all debug windows are intended to be top-level, this inherited |
| 15 | | // constructor is always called with a NULL parent. The passed-in parent widget, |
| 16 | | // however, is often used to place each child window & the code to do this can |
| 17 | | // be found in most of the inherited classes. |
| 18 | | |
| 19 | | WindowQt::WindowQt(running_machine* machine, QWidget* parent) : |
| 20 | | QMainWindow(parent), |
| 21 | | m_machine(machine) |
| 22 | | { |
| 23 | | setAttribute(Qt::WA_DeleteOnClose, true); |
| 24 | | |
| 25 | | // The Debug menu bar |
| 26 | | QAction* debugActOpenMemory = new QAction("New &Memory Window", this); |
| 27 | | debugActOpenMemory->setShortcut(QKeySequence("Ctrl+M")); |
| 28 | | connect(debugActOpenMemory, SIGNAL(triggered()), this, SLOT(debugActOpenMemory())); |
| 29 | | |
| 30 | | QAction* debugActOpenDasm = new QAction("New &Dasm Window", this); |
| 31 | | debugActOpenDasm->setShortcut(QKeySequence("Ctrl+D")); |
| 32 | | connect(debugActOpenDasm, SIGNAL(triggered()), this, SLOT(debugActOpenDasm())); |
| 33 | | |
| 34 | | QAction* debugActOpenLog = new QAction("New &Log Window", this); |
| 35 | | debugActOpenLog->setShortcut(QKeySequence("Ctrl+L")); |
| 36 | | connect(debugActOpenLog, SIGNAL(triggered()), this, SLOT(debugActOpenLog())); |
| 37 | | |
| 38 | | QAction* debugActOpenPoints = new QAction("New &Break|Watchpoints Window", this); |
| 39 | | debugActOpenPoints->setShortcut(QKeySequence("Ctrl+B")); |
| 40 | | connect(debugActOpenPoints, SIGNAL(triggered()), this, SLOT(debugActOpenPoints())); |
| 41 | | |
| 42 | | QAction* debugActOpenDevices = new QAction("New D&evices Window", this); |
| 43 | | debugActOpenDevices->setShortcut(QKeySequence("Shift+Ctrl+D")); |
| 44 | | connect(debugActOpenDevices, SIGNAL(triggered()), this, SLOT(debugActOpenDevices())); |
| 45 | | |
| 46 | | QAction* dbgActRun = new QAction("Run", this); |
| 47 | | dbgActRun->setShortcut(Qt::Key_F5); |
| 48 | | connect(dbgActRun, SIGNAL(triggered()), this, SLOT(debugActRun())); |
| 49 | | |
| 50 | | QAction* dbgActRunAndHide = new QAction("Run And Hide Debugger", this); |
| 51 | | dbgActRunAndHide->setShortcut(Qt::Key_F12); |
| 52 | | connect(dbgActRunAndHide, SIGNAL(triggered()), this, SLOT(debugActRunAndHide())); |
| 53 | | |
| 54 | | QAction* dbgActRunToNextCpu = new QAction("Run to Next CPU", this); |
| 55 | | dbgActRunToNextCpu->setShortcut(Qt::Key_F6); |
| 56 | | connect(dbgActRunToNextCpu, SIGNAL(triggered()), this, SLOT(debugActRunToNextCpu())); |
| 57 | | |
| 58 | | QAction* dbgActRunNextInt = new QAction("Run to Next Interrupt on This CPU", this); |
| 59 | | dbgActRunNextInt->setShortcut(Qt::Key_F7); |
| 60 | | connect(dbgActRunNextInt, SIGNAL(triggered()), this, SLOT(debugActRunNextInt())); |
| 61 | | |
| 62 | | QAction* dbgActRunNextVBlank = new QAction("Run to Next VBlank", this); |
| 63 | | dbgActRunNextVBlank->setShortcut(Qt::Key_F8); |
| 64 | | connect(dbgActRunNextVBlank, SIGNAL(triggered()), this, SLOT(debugActRunNextVBlank())); |
| 65 | | |
| 66 | | QAction* dbgActStepInto = new QAction("Step Into", this); |
| 67 | | dbgActStepInto->setShortcut(Qt::Key_F11); |
| 68 | | connect(dbgActStepInto, SIGNAL(triggered()), this, SLOT(debugActStepInto())); |
| 69 | | |
| 70 | | QAction* dbgActStepOver = new QAction("Step Over", this); |
| 71 | | dbgActStepOver->setShortcut(Qt::Key_F10); |
| 72 | | connect(dbgActStepOver, SIGNAL(triggered()), this, SLOT(debugActStepOver())); |
| 73 | | |
| 74 | | QAction* dbgActStepOut = new QAction("Step Out", this); |
| 75 | | dbgActStepOut->setShortcut(QKeySequence("Shift+F11")); |
| 76 | | connect(dbgActStepOut, SIGNAL(triggered()), this, SLOT(debugActStepOut())); |
| 77 | | |
| 78 | | QAction* dbgActSoftReset = new QAction("Soft Reset", this); |
| 79 | | dbgActSoftReset->setShortcut(Qt::Key_F3); |
| 80 | | connect(dbgActSoftReset, SIGNAL(triggered()), this, SLOT(debugActSoftReset())); |
| 81 | | |
| 82 | | QAction* dbgActHardReset = new QAction("Hard Reset", this); |
| 83 | | dbgActHardReset->setShortcut(QKeySequence("Shift+F3")); |
| 84 | | connect(dbgActHardReset, SIGNAL(triggered()), this, SLOT(debugActHardReset())); |
| 85 | | |
| 86 | | QAction* dbgActClose = new QAction("Close &Window", this); |
| 87 | | dbgActClose->setShortcut(QKeySequence::Close); |
| 88 | | connect(dbgActClose, SIGNAL(triggered()), this, SLOT(debugActClose())); |
| 89 | | |
| 90 | | QAction* dbgActQuit = new QAction("&Quit", this); |
| 91 | | dbgActQuit->setShortcut(QKeySequence::Quit); |
| 92 | | connect(dbgActQuit, SIGNAL(triggered()), this, SLOT(debugActQuit())); |
| 93 | | |
| 94 | | // Construct the menu |
| 95 | | QMenu* debugMenu = menuBar()->addMenu("&Debug"); |
| 96 | | debugMenu->addAction(debugActOpenMemory); |
| 97 | | debugMenu->addAction(debugActOpenDasm); |
| 98 | | debugMenu->addAction(debugActOpenLog); |
| 99 | | debugMenu->addAction(debugActOpenPoints); |
| 100 | | debugMenu->addAction(debugActOpenDevices); |
| 101 | | debugMenu->addSeparator(); |
| 102 | | debugMenu->addAction(dbgActRun); |
| 103 | | debugMenu->addAction(dbgActRunAndHide); |
| 104 | | debugMenu->addAction(dbgActRunToNextCpu); |
| 105 | | debugMenu->addAction(dbgActRunNextInt); |
| 106 | | debugMenu->addAction(dbgActRunNextVBlank); |
| 107 | | debugMenu->addSeparator(); |
| 108 | | debugMenu->addAction(dbgActStepInto); |
| 109 | | debugMenu->addAction(dbgActStepOver); |
| 110 | | debugMenu->addAction(dbgActStepOut); |
| 111 | | debugMenu->addSeparator(); |
| 112 | | debugMenu->addAction(dbgActSoftReset); |
| 113 | | debugMenu->addAction(dbgActHardReset); |
| 114 | | debugMenu->addSeparator(); |
| 115 | | debugMenu->addAction(dbgActClose); |
| 116 | | debugMenu->addAction(dbgActQuit); |
| 117 | | } |
| 118 | | |
| 119 | | |
| 120 | | WindowQt::~WindowQt() |
| 121 | | { |
| 122 | | } |
| 123 | | |
| 124 | | void WindowQt::debugActOpenMemory() |
| 125 | | { |
| 126 | | MemoryWindow* foo = new MemoryWindow(m_machine, this); |
| 127 | | // A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon |
| 128 | | // foo->setWindowFlags(Qt::Dialog); |
| 129 | | // foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint); |
| 130 | | foo->show(); |
| 131 | | } |
| 132 | | |
| 133 | | |
| 134 | | void WindowQt::debugActOpenDasm() |
| 135 | | { |
| 136 | | DasmWindow* foo = new DasmWindow(m_machine, this); |
| 137 | | // A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon |
| 138 | | // foo->setWindowFlags(Qt::Dialog); |
| 139 | | // foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint); |
| 140 | | foo->show(); |
| 141 | | } |
| 142 | | |
| 143 | | |
| 144 | | void WindowQt::debugActOpenLog() |
| 145 | | { |
| 146 | | LogWindow* foo = new LogWindow(m_machine, this); |
| 147 | | // A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon |
| 148 | | // foo->setWindowFlags(Qt::Dialog); |
| 149 | | // foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint); |
| 150 | | foo->show(); |
| 151 | | } |
| 152 | | |
| 153 | | |
| 154 | | void WindowQt::debugActOpenPoints() |
| 155 | | { |
| 156 | | BreakpointsWindow* foo = new BreakpointsWindow(m_machine, this); |
| 157 | | // A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon |
| 158 | | // foo->setWindowFlags(Qt::Dialog); |
| 159 | | // foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint); |
| 160 | | foo->show(); |
| 161 | | } |
| 162 | | |
| 163 | | |
| 164 | | void WindowQt::debugActOpenDevices() |
| 165 | | { |
| 166 | | DevicesWindow* foo = new DevicesWindow(m_machine, this); |
| 167 | | // A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon |
| 168 | | // foo->setWindowFlags(Qt::Dialog); |
| 169 | | // foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint); |
| 170 | | foo->show(); |
| 171 | | } |
| 172 | | |
| 173 | | |
| 174 | | void WindowQt::debugActRun() |
| 175 | | { |
| 176 | | debug_cpu_get_visible_cpu(*m_machine)->debug()->go(); |
| 177 | | } |
| 178 | | |
| 179 | | void WindowQt::debugActRunAndHide() |
| 180 | | { |
| 181 | | debug_cpu_get_visible_cpu(*m_machine)->debug()->go(); |
| 182 | | hideAll(); |
| 183 | | } |
| 184 | | |
| 185 | | void WindowQt::debugActRunToNextCpu() |
| 186 | | { |
| 187 | | debug_cpu_get_visible_cpu(*m_machine)->debug()->go_next_device(); |
| 188 | | } |
| 189 | | |
| 190 | | void WindowQt::debugActRunNextInt() |
| 191 | | { |
| 192 | | debug_cpu_get_visible_cpu(*m_machine)->debug()->go_interrupt(); |
| 193 | | } |
| 194 | | |
| 195 | | void WindowQt::debugActRunNextVBlank() |
| 196 | | { |
| 197 | | debug_cpu_get_visible_cpu(*m_machine)->debug()->go_vblank(); |
| 198 | | } |
| 199 | | |
| 200 | | void WindowQt::debugActStepInto() |
| 201 | | { |
| 202 | | debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step(); |
| 203 | | } |
| 204 | | |
| 205 | | void WindowQt::debugActStepOver() |
| 206 | | { |
| 207 | | debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step_over(); |
| 208 | | } |
| 209 | | |
| 210 | | void WindowQt::debugActStepOut() |
| 211 | | { |
| 212 | | debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step_out(); |
| 213 | | } |
| 214 | | |
| 215 | | void WindowQt::debugActSoftReset() |
| 216 | | { |
| 217 | | m_machine->schedule_soft_reset(); |
| 218 | | debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step(); |
| 219 | | } |
| 220 | | |
| 221 | | void WindowQt::debugActHardReset() |
| 222 | | { |
| 223 | | m_machine->schedule_hard_reset(); |
| 224 | | } |
| 225 | | |
| 226 | | void WindowQt::debugActClose() |
| 227 | | { |
| 228 | | close(); |
| 229 | | } |
| 230 | | |
| 231 | | void WindowQt::debugActQuit() |
| 232 | | { |
| 233 | | m_machine->schedule_exit(); |
| 234 | | } |
| 235 | | |
| 236 | | |
| 237 | | //========================================================================= |
| 238 | | // WindowQtConfig |
| 239 | | //========================================================================= |
| 240 | | void WindowQtConfig::buildFromQWidget(QWidget* widget) |
| 241 | | { |
| 242 | | m_position.setX(widget->geometry().topLeft().x()); |
| 243 | | m_position.setY(widget->geometry().topLeft().y()); |
| 244 | | m_size.setX(widget->size().width()); |
| 245 | | m_size.setY(widget->size().height()); |
| 246 | | } |
| 247 | | |
| 248 | | |
| 249 | | void WindowQtConfig::applyToQWidget(QWidget* widget) |
| 250 | | { |
| 251 | | widget->setGeometry(m_position.x(), m_position.y(), m_size.x(), m_size.y()); |
| 252 | | } |
| 253 | | |
| 254 | | |
| 255 | | void WindowQtConfig::addToXmlDataNode(xml_data_node* node) const |
| 256 | | { |
| 257 | | xml_set_attribute_int(node, "type", m_type); |
| 258 | | xml_set_attribute_int(node, "position_x", m_position.x()); |
| 259 | | xml_set_attribute_int(node, "position_y", m_position.y()); |
| 260 | | xml_set_attribute_int(node, "size_x", m_size.x()); |
| 261 | | xml_set_attribute_int(node, "size_y", m_size.y()); |
| 262 | | } |
| 263 | | |
| 264 | | |
| 265 | | void WindowQtConfig::recoverFromXmlNode(xml_data_node* node) |
| 266 | | { |
| 267 | | m_size.setX(xml_get_attribute_int(node, "size_x", m_size.x())); |
| 268 | | m_size.setY(xml_get_attribute_int(node, "size_y", m_size.y())); |
| 269 | | m_position.setX(xml_get_attribute_int(node, "position_x", m_position.x())); |
| 270 | | m_position.setY(xml_get_attribute_int(node, "position_y", m_position.y())); |
| 271 | | m_type = (WindowQtConfig::WindowType)xml_get_attribute_int(node, "type", m_type); |
| 272 | | } |
trunk/src/osd/modules/debugger/qt/deviceinformationwindow.c
| r0 | r243595 | |
| 1 | #define NO_MEM_TRACKING |
| 2 | |
| 3 | #include "deviceinformationwindow.h" |
| 4 | |
| 5 | |
| 6 | DeviceInformationWindow::DeviceInformationWindow(running_machine* machine, device_t* device, QWidget* parent) : |
| 7 | WindowQt(machine, NULL) |
| 8 | { |
| 9 | m_device = device; |
| 10 | |
| 11 | if (parent != NULL) |
| 12 | { |
| 13 | QPoint parentPos = parent->pos(); |
| 14 | setGeometry(parentPos.x()+100, parentPos.y()+100, 600, 400); |
| 15 | } |
| 16 | |
| 17 | if(m_device) |
| 18 | fill_device_information(); |
| 19 | } |
| 20 | |
| 21 | |
| 22 | DeviceInformationWindow::~DeviceInformationWindow() |
| 23 | { |
| 24 | } |
| 25 | |
| 26 | void DeviceInformationWindow::fill_device_information() |
| 27 | { |
| 28 | char title[4069]; |
| 29 | sprintf(title, "Debug: Device %s", m_device->tag()); |
| 30 | setWindowTitle(title); |
| 31 | |
| 32 | |
| 33 | QFrame *mainWindowFrame = new QFrame(this); |
| 34 | QVBoxLayout *vLayout = new QVBoxLayout(mainWindowFrame); |
| 35 | vLayout->setObjectName("vlayout"); |
| 36 | vLayout->setSpacing(3); |
| 37 | vLayout->setContentsMargins(2,2,2,2); |
| 38 | |
| 39 | QFrame *primaryFrame = new QFrame(mainWindowFrame); |
| 40 | primaryFrame->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); |
| 41 | QGridLayout *gl1 = new QGridLayout(primaryFrame); |
| 42 | gl1->addWidget(new QLabel(QString("Tag"), primaryFrame), 0, 0); |
| 43 | gl1->addWidget(new QLabel(QString(m_device->tag()), primaryFrame), 0, 1); |
| 44 | gl1->addWidget(new QLabel(QString("Name"), primaryFrame), 1, 0); |
| 45 | gl1->addWidget(new QLabel(QString(m_device->name()), primaryFrame), 1, 1); |
| 46 | gl1->addWidget(new QLabel(QString("Shortname"), primaryFrame), 2, 0); |
| 47 | gl1->addWidget(new QLabel(QString(m_device->shortname()), primaryFrame), 2, 1); |
| 48 | |
| 49 | int cpos = 3; |
| 50 | device_interface *intf = m_device->first_interface(); |
| 51 | if(intf) { |
| 52 | gl1->addWidget(new QLabel(QString("Interfaces"), primaryFrame), cpos, 0); |
| 53 | while(intf) { |
| 54 | gl1->addWidget(new QLabel(QString(intf->interface_type()), primaryFrame), cpos, 1); |
| 55 | cpos++; |
| 56 | intf = intf->interface_next(); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | vLayout->addWidget(primaryFrame); |
| 61 | |
| 62 | device_memory_interface *d_memory; |
| 63 | if(m_device->interface(d_memory)) { |
| 64 | QFrame *f = new QFrame(mainWindowFrame); |
| 65 | f->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); |
| 66 | QVBoxLayout *vb = new QVBoxLayout(f); |
| 67 | bool first = true; |
| 68 | for(address_spacenum i=AS_0; i<ADDRESS_SPACES; i++) |
| 69 | if(d_memory->has_space(i)) { |
| 70 | QFrame *ff = new QFrame(f); |
| 71 | QHBoxLayout *hb = new QHBoxLayout(ff); |
| 72 | if(first) { |
| 73 | hb->addWidget(new QLabel("Memory maps")); |
| 74 | first = false; |
| 75 | } |
| 76 | hb->addStretch(); |
| 77 | hb->addWidget(new QLabel(d_memory->space_config(i)->name())); |
| 78 | vb->addWidget(ff); |
| 79 | } |
| 80 | vLayout->addWidget(f); |
| 81 | } |
| 82 | |
| 83 | vLayout->addStretch(); |
| 84 | |
| 85 | setCentralWidget(mainWindowFrame); |
| 86 | } |
| 87 | |
| 88 | void DeviceInformationWindow::set_device(const char *tag) |
| 89 | { |
| 90 | m_device = m_machine->device(tag); |
| 91 | if(!m_device) |
| 92 | m_device = &m_machine->root_device(); |
| 93 | fill_device_information(); |
| 94 | } |
| 95 | |
| 96 | const char *DeviceInformationWindow::device_tag() const |
| 97 | { |
| 98 | return m_device->tag(); |
| 99 | } |
| 100 | |
| 101 | |
| 102 | //========================================================================= |
| 103 | // DeviceInformationWindowQtConfig |
| 104 | //========================================================================= |
| 105 | void DeviceInformationWindowQtConfig::buildFromQWidget(QWidget* widget) |
| 106 | { |
| 107 | WindowQtConfig::buildFromQWidget(widget); |
| 108 | DeviceInformationWindow* window = dynamic_cast<DeviceInformationWindow*>(widget); |
| 109 | m_device_tag = window->device_tag(); |
| 110 | } |
| 111 | |
| 112 | |
| 113 | void DeviceInformationWindowQtConfig::applyToQWidget(QWidget* widget) |
| 114 | { |
| 115 | WindowQtConfig::applyToQWidget(widget); |
| 116 | DeviceInformationWindow* window = dynamic_cast<DeviceInformationWindow*>(widget); |
| 117 | window->set_device(m_device_tag.cstr()); |
| 118 | } |
| 119 | |
| 120 | |
| 121 | void DeviceInformationWindowQtConfig::addToXmlDataNode(xml_data_node* node) const |
| 122 | { |
| 123 | WindowQtConfig::addToXmlDataNode(node); |
| 124 | xml_set_attribute(node, "device-tag", m_device_tag); |
| 125 | } |
| 126 | |
| 127 | |
| 128 | void DeviceInformationWindowQtConfig::recoverFromXmlNode(xml_data_node* node) |
| 129 | { |
| 130 | WindowQtConfig::recoverFromXmlNode(node); |
| 131 | m_device_tag = xml_get_attribute_string(node, "device-tag", ":"); |
| 132 | } |
trunk/src/osd/modules/debugger/qt/deviceswindow.c
| r0 | r243595 | |
| 1 | #define NO_MEM_TRACKING |
| 2 | |
| 3 | #include "deviceswindow.h" |
| 4 | #include "deviceinformationwindow.h" |
| 5 | |
| 6 | DevicesWindowModel::DevicesWindowModel(running_machine *machine, QObject *parent) |
| 7 | { |
| 8 | m_machine = machine; |
| 9 | } |
| 10 | |
| 11 | DevicesWindowModel::~DevicesWindowModel() |
| 12 | { |
| 13 | } |
| 14 | |
| 15 | QVariant DevicesWindowModel::data(const QModelIndex &index, int role) const |
| 16 | { |
| 17 | if(!index.isValid() || role != Qt::DisplayRole) |
| 18 | return QVariant(); |
| 19 | |
| 20 | device_t *dev = static_cast<device_t *>(index.internalPointer()); |
| 21 | switch(index.column()) { |
| 22 | case 0: return dev == &m_machine->root_device() ? QString("<root>") : QString(dev->basetag()); |
| 23 | case 1: return QString(dev->name()); |
| 24 | } |
| 25 | |
| 26 | return QVariant(); |
| 27 | } |
| 28 | |
| 29 | Qt::ItemFlags DevicesWindowModel::flags(const QModelIndex &index) const |
| 30 | { |
| 31 | if(!index.isValid()) |
| 32 | return 0; |
| 33 | |
| 34 | return QAbstractItemModel::flags(index); |
| 35 | } |
| 36 | |
| 37 | QVariant DevicesWindowModel::headerData(int section, Qt::Orientation orientation, int role) const |
| 38 | { |
| 39 | if(role != Qt::DisplayRole || section < 0 || section >= 2) |
| 40 | return QVariant(); |
| 41 | return QString(section ? "Name" : "Tag"); |
| 42 | } |
| 43 | |
| 44 | QModelIndex DevicesWindowModel::index(int row, int column, const QModelIndex &parent) const |
| 45 | { |
| 46 | if(!hasIndex(row, column, parent)) |
| 47 | return QModelIndex(); |
| 48 | |
| 49 | device_t *target = NULL; |
| 50 | |
| 51 | if(!parent.isValid()) { |
| 52 | if(row == 0) |
| 53 | target = &m_machine->root_device(); |
| 54 | |
| 55 | } else { |
| 56 | device_t *dparent = static_cast<device_t *>(parent.internalPointer()); |
| 57 | int count = row; |
| 58 | for(target = dparent->first_subdevice(); count && target; target = target->next()) |
| 59 | count--; |
| 60 | } |
| 61 | |
| 62 | if(target) |
| 63 | return createIndex(row, column, target); |
| 64 | |
| 65 | return QModelIndex(); |
| 66 | } |
| 67 | |
| 68 | QModelIndex DevicesWindowModel::parent(const QModelIndex &index) const |
| 69 | { |
| 70 | if(!index.isValid()) |
| 71 | return QModelIndex(); |
| 72 | |
| 73 | device_t *dchild = static_cast<device_t *>(index.internalPointer()); |
| 74 | device_t *dparent = dchild->owner(); |
| 75 | |
| 76 | if(!dparent) |
| 77 | return QModelIndex(); |
| 78 | |
| 79 | device_t *dpp = dparent->owner(); |
| 80 | int row = 0; |
| 81 | if(dpp) { |
| 82 | for(device_t *child = dpp->first_subdevice(); child && child != dparent; child = child->next()) |
| 83 | row++; |
| 84 | } |
| 85 | return createIndex(row, 0, dparent); |
| 86 | } |
| 87 | |
| 88 | int DevicesWindowModel::rowCount(const QModelIndex &parent) const |
| 89 | { |
| 90 | if(!parent.isValid()) |
| 91 | return 1; |
| 92 | |
| 93 | device_t *dparent = static_cast<device_t *>(parent.internalPointer()); |
| 94 | int count = 0; |
| 95 | for(device_t *child = dparent->first_subdevice(); child; child = child->next()) |
| 96 | count++; |
| 97 | |
| 98 | return count; |
| 99 | } |
| 100 | |
| 101 | int DevicesWindowModel::columnCount(const QModelIndex &parent) const |
| 102 | { |
| 103 | return 2; |
| 104 | } |
| 105 | |
| 106 | |
| 107 | |
| 108 | DevicesWindow::DevicesWindow(running_machine* machine, QWidget* parent) : |
| 109 | WindowQt(machine, NULL), |
| 110 | m_devices_model(machine) |
| 111 | { |
| 112 | m_selected_device = NULL; |
| 113 | |
| 114 | setWindowTitle("Debug: All Devices"); |
| 115 | |
| 116 | if (parent != NULL) |
| 117 | { |
| 118 | QPoint parentPos = parent->pos(); |
| 119 | setGeometry(parentPos.x()+100, parentPos.y()+100, 600, 400); |
| 120 | } |
| 121 | |
| 122 | // |
| 123 | // The tree widget |
| 124 | // |
| 125 | m_devices_view = new QTreeView(this); |
| 126 | m_devices_view->setModel(&m_devices_model); |
| 127 | m_devices_view->expandAll(); |
| 128 | m_devices_view->resizeColumnToContents(0); |
| 129 | connect(m_devices_view->selectionModel(), SIGNAL(currentRowChanged(const QModelIndex &,const QModelIndex &)), this, SLOT(currentRowChanged(const QModelIndex &,const QModelIndex &))); |
| 130 | connect(m_devices_view, SIGNAL(activated(const QModelIndex &)), this, SLOT(activated(const QModelIndex &))); |
| 131 | setCentralWidget(m_devices_view); |
| 132 | } |
| 133 | |
| 134 | |
| 135 | DevicesWindow::~DevicesWindow() |
| 136 | { |
| 137 | } |
| 138 | |
| 139 | |
| 140 | void DevicesWindow::currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous) |
| 141 | { |
| 142 | m_selected_device = static_cast<device_t *>(current.internalPointer()); |
| 143 | } |
| 144 | |
| 145 | |
| 146 | void DevicesWindow::activated(const QModelIndex &index) |
| 147 | { |
| 148 | device_t *dev = static_cast<device_t *>(index.internalPointer()); |
| 149 | (new DeviceInformationWindow(m_machine, dev, this))->show(); |
| 150 | } |
| 151 | |
| 152 | |
| 153 | |
| 154 | //========================================================================= |
| 155 | // DevicesWindowQtConfig |
| 156 | //========================================================================= |
| 157 | void DevicesWindowQtConfig::buildFromQWidget(QWidget* widget) |
| 158 | { |
| 159 | WindowQtConfig::buildFromQWidget(widget); |
| 160 | // DevicesWindow* window = dynamic_cast<DevicesWindow*>(widget); |
| 161 | } |
| 162 | |
| 163 | |
| 164 | void DevicesWindowQtConfig::applyToQWidget(QWidget* widget) |
| 165 | { |
| 166 | WindowQtConfig::applyToQWidget(widget); |
| 167 | // DevicesWindow* window = dynamic_cast<DevicesWindow*>(widget); |
| 168 | } |
| 169 | |
| 170 | |
| 171 | void DevicesWindowQtConfig::addToXmlDataNode(xml_data_node* node) const |
| 172 | { |
| 173 | WindowQtConfig::addToXmlDataNode(node); |
| 174 | } |
| 175 | |
| 176 | |
| 177 | void DevicesWindowQtConfig::recoverFromXmlNode(xml_data_node* node) |
| 178 | { |
| 179 | WindowQtConfig::recoverFromXmlNode(node); |
| 180 | } |
trunk/src/osd/modules/debugger/qt/mainwindow.c
| r0 | r243595 | |
| 1 | #define NO_MEM_TRACKING |
| 2 | |
| 3 | #include "mainwindow.h" |
| 4 | |
| 5 | #include "debug/debugcon.h" |
| 6 | #include "debug/debugcpu.h" |
| 7 | #include "debug/dvdisasm.h" |
| 8 | |
| 9 | |
| 10 | MainWindow::MainWindow(running_machine* machine, QWidget* parent) : |
| 11 | WindowQt(machine, NULL), |
| 12 | m_historyIndex(0), |
| 13 | m_inputHistory() |
| 14 | { |
| 15 | setGeometry(300, 300, 1000, 600); |
| 16 | |
| 17 | // |
| 18 | // The main frame and its input and log widgets |
| 19 | // |
| 20 | QFrame* mainWindowFrame = new QFrame(this); |
| 21 | |
| 22 | // The input line |
| 23 | m_inputEdit = new QLineEdit(mainWindowFrame); |
| 24 | connect(m_inputEdit, SIGNAL(returnPressed()), this, SLOT(executeCommand())); |
| 25 | m_inputEdit->installEventFilter(this); |
| 26 | |
| 27 | |
| 28 | // The log view |
| 29 | m_consoleView = new DebuggerView(DVT_CONSOLE, |
| 30 | m_machine, |
| 31 | mainWindowFrame); |
| 32 | m_consoleView->setFocusPolicy(Qt::NoFocus); |
| 33 | m_consoleView->setPreferBottom(true); |
| 34 | |
| 35 | QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame); |
| 36 | vLayout->addWidget(m_consoleView); |
| 37 | vLayout->addWidget(m_inputEdit); |
| 38 | vLayout->setSpacing(3); |
| 39 | vLayout->setContentsMargins(4,0,4,2); |
| 40 | |
| 41 | setCentralWidget(mainWindowFrame); |
| 42 | |
| 43 | // |
| 44 | // Options Menu |
| 45 | // |
| 46 | // Create two commands |
| 47 | QAction* breakpointSetAct = new QAction("Toggle Breakpoint At Cursor", this); |
| 48 | QAction* runToCursorAct = new QAction("Run To Cursor", this); |
| 49 | breakpointSetAct->setShortcut(Qt::Key_F9); |
| 50 | runToCursorAct->setShortcut(Qt::Key_F4); |
| 51 | connect(breakpointSetAct, SIGNAL(triggered(bool)), this, SLOT(toggleBreakpointAtCursor(bool))); |
| 52 | connect(runToCursorAct, SIGNAL(triggered(bool)), this, SLOT(runToCursor(bool))); |
| 53 | |
| 54 | // Right bar options |
| 55 | QActionGroup* rightBarGroup = new QActionGroup(this); |
| 56 | rightBarGroup->setObjectName("rightbargroup"); |
| 57 | QAction* rightActRaw = new QAction("Raw Opcodes", this); |
| 58 | QAction* rightActEncrypted = new QAction("Encrypted Opcodes", this); |
| 59 | QAction* rightActComments = new QAction("Comments", this); |
| 60 | rightActRaw->setCheckable(true); |
| 61 | rightActEncrypted->setCheckable(true); |
| 62 | rightActComments->setCheckable(true); |
| 63 | rightActRaw->setActionGroup(rightBarGroup); |
| 64 | rightActEncrypted->setActionGroup(rightBarGroup); |
| 65 | rightActComments->setActionGroup(rightBarGroup); |
| 66 | rightActRaw->setShortcut(QKeySequence("Ctrl+R")); |
| 67 | rightActEncrypted->setShortcut(QKeySequence("Ctrl+E")); |
| 68 | rightActComments->setShortcut(QKeySequence("Ctrl+C")); |
| 69 | rightActRaw->setChecked(true); |
| 70 | connect(rightBarGroup, SIGNAL(triggered(QAction*)), this, SLOT(rightBarChanged(QAction*))); |
| 71 | |
| 72 | // Assemble the options menu |
| 73 | QMenu* optionsMenu = menuBar()->addMenu("&Options"); |
| 74 | optionsMenu->addAction(breakpointSetAct); |
| 75 | optionsMenu->addAction(runToCursorAct); |
| 76 | optionsMenu->addSeparator(); |
| 77 | optionsMenu->addActions(rightBarGroup->actions()); |
| 78 | |
| 79 | // |
| 80 | // Images menu |
| 81 | // |
| 82 | image_interface_iterator imageIterTest(m_machine->root_device()); |
| 83 | if (imageIterTest.first() != NULL) |
| 84 | { |
| 85 | createImagesMenu(); |
| 86 | } |
| 87 | |
| 88 | // |
| 89 | // Dock window menu |
| 90 | // |
| 91 | QMenu* dockMenu = menuBar()->addMenu("Doc&ks"); |
| 92 | |
| 93 | setCorner(Qt::TopRightCorner, Qt::TopDockWidgetArea); |
| 94 | setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea); |
| 95 | |
| 96 | // The processor dock |
| 97 | QDockWidget* cpuDock = new QDockWidget("processor", this); |
| 98 | cpuDock->setObjectName("cpudock"); |
| 99 | cpuDock->setAllowedAreas(Qt::LeftDockWidgetArea); |
| 100 | m_procFrame = new ProcessorDockWidget(m_machine, cpuDock); |
| 101 | cpuDock->setWidget(dynamic_cast<QWidget*>(m_procFrame)); |
| 102 | |
| 103 | addDockWidget(Qt::LeftDockWidgetArea, cpuDock); |
| 104 | dockMenu->addAction(cpuDock->toggleViewAction()); |
| 105 | |
| 106 | // The disassembly dock |
| 107 | QDockWidget* dasmDock = new QDockWidget("dasm", this); |
| 108 | dasmDock->setObjectName("dasmdock"); |
| 109 | dasmDock->setAllowedAreas(Qt::TopDockWidgetArea); |
| 110 | m_dasmFrame = new DasmDockWidget(m_machine, dasmDock); |
| 111 | dasmDock->setWidget(m_dasmFrame); |
| 112 | |
| 113 | addDockWidget(Qt::TopDockWidgetArea, dasmDock); |
| 114 | dockMenu->addAction(dasmDock->toggleViewAction()); |
| 115 | } |
| 116 | |
| 117 | |
| 118 | MainWindow::~MainWindow() |
| 119 | { |
| 120 | } |
| 121 | |
| 122 | |
| 123 | void MainWindow::setProcessor(device_t* processor) |
| 124 | { |
| 125 | // Cpu swap |
| 126 | m_procFrame->view()->view()->set_source(*m_procFrame->view()->view()->source_for_device(processor)); |
| 127 | m_dasmFrame->view()->view()->set_source(*m_dasmFrame->view()->view()->source_for_device(processor)); |
| 128 | |
| 129 | // Scrollbar refresh - seems I should be able to do in the DebuggerView |
| 130 | m_dasmFrame->view()->verticalScrollBar()->setValue(m_dasmFrame->view()->view()->visible_position().y); |
| 131 | m_dasmFrame->view()->verticalScrollBar()->setValue(m_dasmFrame->view()->view()->visible_position().y); |
| 132 | |
| 133 | // Window title |
| 134 | astring title; |
| 135 | title.printf("Debug: %s - %s '%s'", m_machine->system().name, processor->name(), processor->tag()); |
| 136 | setWindowTitle(title.cstr()); |
| 137 | } |
| 138 | |
| 139 | |
| 140 | // Used to intercept the user clicking 'X' in the upper corner |
| 141 | void MainWindow::closeEvent(QCloseEvent* event) |
| 142 | { |
| 143 | debugActQuit(); |
| 144 | |
| 145 | // Insure the window doesn't disappear before we get a chance to save its parameters |
| 146 | event->ignore(); |
| 147 | } |
| 148 | |
| 149 | |
| 150 | // Used to intercept the user hitting the up arrow in the input widget |
| 151 | bool MainWindow::eventFilter(QObject* obj, QEvent* event) |
| 152 | { |
| 153 | // Only filter keypresses |
| 154 | QKeyEvent* keyEvent = NULL; |
| 155 | if (event->type() == QEvent::KeyPress) |
| 156 | { |
| 157 | keyEvent = static_cast<QKeyEvent*>(event); |
| 158 | } |
| 159 | else |
| 160 | { |
| 161 | return QObject::eventFilter(obj, event); |
| 162 | } |
| 163 | |
| 164 | // Catch up & down keys |
| 165 | if (keyEvent->key() == Qt::Key_Up || keyEvent->key() == Qt::Key_Down) |
| 166 | { |
| 167 | if (keyEvent->key() == Qt::Key_Up) |
| 168 | { |
| 169 | if (m_historyIndex > 0) |
| 170 | m_historyIndex--; |
| 171 | } |
| 172 | else if (keyEvent->key() == Qt::Key_Down) |
| 173 | { |
| 174 | if (m_historyIndex < m_inputHistory.size()) |
| 175 | m_historyIndex++; |
| 176 | } |
| 177 | |
| 178 | // Populate the input edit or clear it if you're at the end |
| 179 | if (m_historyIndex == m_inputHistory.size()) |
| 180 | { |
| 181 | m_inputEdit->setText(""); |
| 182 | } |
| 183 | else |
| 184 | { |
| 185 | m_inputEdit->setText(m_inputHistory[m_historyIndex]); |
| 186 | } |
| 187 | } |
| 188 | else if (keyEvent->key() == Qt::Key_Enter) |
| 189 | { |
| 190 | executeCommand(false); |
| 191 | } |
| 192 | else |
| 193 | { |
| 194 | return QObject::eventFilter(obj, event); |
| 195 | } |
| 196 | |
| 197 | return true; |
| 198 | } |
| 199 | |
| 200 | |
| 201 | void MainWindow::toggleBreakpointAtCursor(bool changedTo) |
| 202 | { |
| 203 | debug_view_disasm* dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view()); |
| 204 | if (dasmView->cursor_visible()) |
| 205 | { |
| 206 | if (debug_cpu_get_visible_cpu(*m_machine) == dasmView->source()->device()) |
| 207 | { |
| 208 | offs_t address = downcast<debug_view_disasm *>(dasmView)->selected_address(); |
| 209 | device_debug *cpuinfo = dasmView->source()->device()->debug(); |
| 210 | |
| 211 | // Find an existing breakpoint at this address |
| 212 | INT32 bpindex = -1; |
| 213 | for (device_debug::breakpoint* bp = cpuinfo->breakpoint_first(); |
| 214 | bp != NULL; |
| 215 | bp = bp->next()) |
| 216 | { |
| 217 | if (address == bp->address()) |
| 218 | { |
| 219 | bpindex = bp->index(); |
| 220 | break; |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | // If none exists, add a new one |
| 225 | astring command; |
| 226 | if (bpindex == -1) |
| 227 | { |
| 228 | command.printf("bpset 0x%X", address); |
| 229 | } |
| 230 | else |
| 231 | { |
| 232 | command.printf("bpclear 0x%X", bpindex); |
| 233 | } |
| 234 | debug_console_execute_command(*m_machine, command, 1); |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | refreshAll(); |
| 239 | } |
| 240 | |
| 241 | |
| 242 | void MainWindow::runToCursor(bool changedTo) |
| 243 | { |
| 244 | debug_view_disasm* dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view()); |
| 245 | if (dasmView->cursor_visible()) |
| 246 | { |
| 247 | if (debug_cpu_get_visible_cpu(*m_machine) == dasmView->source()->device()) |
| 248 | { |
| 249 | offs_t address = downcast<debug_view_disasm*>(dasmView)->selected_address(); |
| 250 | astring command; |
| 251 | command.printf("go 0x%X", address); |
| 252 | debug_console_execute_command(*m_machine, command, 1); |
| 253 | } |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | |
| 258 | void MainWindow::rightBarChanged(QAction* changedTo) |
| 259 | { |
| 260 | debug_view_disasm* dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view()); |
| 261 | if (changedTo->text() == "Raw Opcodes") |
| 262 | { |
| 263 | dasmView->set_right_column(DASM_RIGHTCOL_RAW); |
| 264 | } |
| 265 | else if (changedTo->text() == "Encrypted Opcodes") |
| 266 | { |
| 267 | dasmView->set_right_column(DASM_RIGHTCOL_ENCRYPTED); |
| 268 | } |
| 269 | else if (changedTo->text() == "Comments") |
| 270 | { |
| 271 | dasmView->set_right_column(DASM_RIGHTCOL_COMMENTS); |
| 272 | } |
| 273 | m_dasmFrame->view()->viewport()->update(); |
| 274 | } |
| 275 | |
| 276 | |
| 277 | void MainWindow::executeCommand(bool withClear) |
| 278 | { |
| 279 | QString command = m_inputEdit->text(); |
| 280 | |
| 281 | // A blank command is a "silent step" |
| 282 | if (command == "") |
| 283 | { |
| 284 | debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step(); |
| 285 | return; |
| 286 | } |
| 287 | |
| 288 | // Send along the command |
| 289 | debug_console_execute_command(*m_machine, |
| 290 | command.toLocal8Bit().data(), |
| 291 | true); |
| 292 | |
| 293 | // Add history & set the index to be the top of the stack |
| 294 | addToHistory(command); |
| 295 | |
| 296 | // Clear out the text and reset the history pointer only if asked |
| 297 | if (withClear) |
| 298 | { |
| 299 | m_inputEdit->clear(); |
| 300 | m_historyIndex = m_inputHistory.size(); |
| 301 | } |
| 302 | |
| 303 | // Refresh |
| 304 | m_consoleView->viewport()->update(); |
| 305 | refreshAll(); |
| 306 | } |
| 307 | |
| 308 | |
| 309 | void MainWindow::mountImage(bool changedTo) |
| 310 | { |
| 311 | // The image interface index was assigned to the QAction's data memeber |
| 312 | const int imageIndex = dynamic_cast<QAction*>(sender())->data().toInt(); |
| 313 | image_interface_iterator iter(m_machine->root_device()); |
| 314 | device_image_interface *img = iter.byindex(imageIndex); |
| 315 | if (img == NULL) |
| 316 | { |
| 317 | debug_console_printf(*m_machine, "Something is wrong with the mount menu.\n"); |
| 318 | refreshAll(); |
| 319 | return; |
| 320 | } |
| 321 | |
| 322 | // File dialog |
| 323 | QString filename = QFileDialog::getOpenFileName(this, |
| 324 | "Select an image file", |
| 325 | QDir::currentPath(), |
| 326 | tr("All files (*.*)")); |
| 327 | |
| 328 | if (img->load(filename.toUtf8().data()) != IMAGE_INIT_PASS) |
| 329 | { |
| 330 | debug_console_printf(*m_machine, "Image could not be mounted.\n"); |
| 331 | refreshAll(); |
| 332 | return; |
| 333 | } |
| 334 | |
| 335 | // Activate the unmount menu option |
| 336 | QAction* unmountAct = sender()->parent()->findChild<QAction*>("unmount"); |
| 337 | unmountAct->setEnabled(true); |
| 338 | |
| 339 | // Set the mount name |
| 340 | QMenu* parentMenuItem = dynamic_cast<QMenu*>(sender()->parent()); |
| 341 | QString baseString = parentMenuItem->title(); |
| 342 | baseString.truncate(baseString.lastIndexOf(QString(" : "))); |
| 343 | const QString newTitle = baseString + QString(" : ") + QString(img->filename()); |
| 344 | parentMenuItem->setTitle(newTitle); |
| 345 | |
| 346 | debug_console_printf(*m_machine, "Image %s mounted successfully.\n", filename.toUtf8().data()); |
| 347 | refreshAll(); |
| 348 | } |
| 349 | |
| 350 | |
| 351 | void MainWindow::unmountImage(bool changedTo) |
| 352 | { |
| 353 | // The image interface index was assigned to the QAction's data memeber |
| 354 | const int imageIndex = dynamic_cast<QAction*>(sender())->data().toInt(); |
| 355 | image_interface_iterator iter(m_machine->root_device()); |
| 356 | device_image_interface *img = iter.byindex(imageIndex); |
| 357 | |
| 358 | img->unload(); |
| 359 | |
| 360 | // Deactivate the unmount menu option |
| 361 | dynamic_cast<QAction*>(sender())->setEnabled(false); |
| 362 | |
| 363 | // Set the mount name |
| 364 | QMenu* parentMenuItem = dynamic_cast<QMenu*>(sender()->parent()); |
| 365 | QString baseString = parentMenuItem->title(); |
| 366 | baseString.truncate(baseString.lastIndexOf(QString(" : "))); |
| 367 | const QString newTitle = baseString + QString(" : ") + QString("[empty slot]"); |
| 368 | parentMenuItem->setTitle(newTitle); |
| 369 | |
| 370 | debug_console_printf(*m_machine, "Image successfully unmounted.\n"); |
| 371 | refreshAll(); |
| 372 | } |
| 373 | |
| 374 | |
| 375 | void MainWindow::debugActClose() |
| 376 | { |
| 377 | m_machine->schedule_exit(); |
| 378 | } |
| 379 | |
| 380 | |
| 381 | void MainWindow::addToHistory(const QString& command) |
| 382 | { |
| 383 | if (command == "") |
| 384 | return; |
| 385 | |
| 386 | // Always push back when there is no previous history |
| 387 | if (m_inputHistory.size() == 0) |
| 388 | { |
| 389 | m_inputHistory.push_back(m_inputEdit->text()); |
| 390 | return; |
| 391 | } |
| 392 | |
| 393 | // If there is previous history, make sure it's not what you just executed |
| 394 | if (m_inputHistory.back() != m_inputEdit->text()) |
| 395 | { |
| 396 | m_inputHistory.push_back(m_inputEdit->text()); |
| 397 | } |
| 398 | } |
| 399 | |
| 400 | |
| 401 | void MainWindow::createImagesMenu() |
| 402 | { |
| 403 | QMenu* imagesMenu = menuBar()->addMenu("&Images"); |
| 404 | |
| 405 | int interfaceIndex = 0; |
| 406 | image_interface_iterator iter(m_machine->root_device()); |
| 407 | for (device_image_interface *img = iter.first(); img != NULL; img = iter.next()) |
| 408 | { |
| 409 | astring menuName; |
| 410 | menuName.format("%s : %s", img->device().name(), img->exists() ? img->filename() : "[empty slot]"); |
| 411 | |
| 412 | QMenu* interfaceMenu = imagesMenu->addMenu(menuName.cstr()); |
| 413 | interfaceMenu->setObjectName(img->device().name()); |
| 414 | |
| 415 | QAction* mountAct = new QAction("Mount...", interfaceMenu); |
| 416 | QAction* unmountAct = new QAction("Unmount", interfaceMenu); |
| 417 | mountAct->setObjectName("mount"); |
| 418 | mountAct->setData(QVariant(interfaceIndex)); |
| 419 | unmountAct->setObjectName("unmount"); |
| 420 | unmountAct->setData(QVariant(interfaceIndex)); |
| 421 | connect(mountAct, SIGNAL(triggered(bool)), this, SLOT(mountImage(bool))); |
| 422 | connect(unmountAct, SIGNAL(triggered(bool)), this, SLOT(unmountImage(bool))); |
| 423 | |
| 424 | if (!img->exists()) |
| 425 | unmountAct->setEnabled(false); |
| 426 | |
| 427 | interfaceMenu->addAction(mountAct); |
| 428 | interfaceMenu->addAction(unmountAct); |
| 429 | |
| 430 | // TODO: Cassette operations |
| 431 | |
| 432 | interfaceIndex++; |
| 433 | } |
| 434 | } |
| 435 | |
| 436 | |
| 437 | //========================================================================= |
| 438 | // MainWindowQtConfig |
| 439 | //========================================================================= |
| 440 | void MainWindowQtConfig::buildFromQWidget(QWidget* widget) |
| 441 | { |
| 442 | WindowQtConfig::buildFromQWidget(widget); |
| 443 | MainWindow* window = dynamic_cast<MainWindow*>(widget); |
| 444 | m_windowState = window->saveState(); |
| 445 | |
| 446 | QActionGroup* rightBarGroup = window->findChild<QActionGroup*>("rightbargroup"); |
| 447 | if (rightBarGroup->checkedAction()->text() == "Raw Opcodes") |
| 448 | m_rightBar = 0; |
| 449 | else if (rightBarGroup->checkedAction()->text() == "Encrypted Opcodes") |
| 450 | m_rightBar = 1; |
| 451 | else if (rightBarGroup->checkedAction()->text() == "Comments") |
| 452 | m_rightBar = 2; |
| 453 | } |
| 454 | |
| 455 | |
| 456 | void MainWindowQtConfig::applyToQWidget(QWidget* widget) |
| 457 | { |
| 458 | WindowQtConfig::applyToQWidget(widget); |
| 459 | MainWindow* window = dynamic_cast<MainWindow*>(widget); |
| 460 | window->restoreState(m_windowState); |
| 461 | |
| 462 | QActionGroup* rightBarGroup = window->findChild<QActionGroup*>("rightbargroup"); |
| 463 | rightBarGroup->actions()[m_rightBar]->trigger(); |
| 464 | } |
| 465 | |
| 466 | |
| 467 | void MainWindowQtConfig::addToXmlDataNode(xml_data_node* node) const |
| 468 | { |
| 469 | WindowQtConfig::addToXmlDataNode(node); |
| 470 | xml_set_attribute_int(node, "rightbar", m_rightBar); |
| 471 | xml_set_attribute(node, "qtwindowstate", m_windowState.toPercentEncoding().data()); |
| 472 | } |
| 473 | |
| 474 | |
| 475 | void MainWindowQtConfig::recoverFromXmlNode(xml_data_node* node) |
| 476 | { |
| 477 | WindowQtConfig::recoverFromXmlNode(node); |
| 478 | const char* state = xml_get_attribute_string(node, "qtwindowstate", ""); |
| 479 | m_windowState = QByteArray::fromPercentEncoding(state); |
| 480 | m_rightBar = xml_get_attribute_int(node, "rightbar", m_rightBar); |
| 481 | } |
| 482 | |
| 483 | DasmDockWidget::~DasmDockWidget() |
| 484 | { |
| 485 | } |
| 486 | |
| 487 | ProcessorDockWidget::~ProcessorDockWidget() |
| 488 | { |
| 489 | } |
trunk/src/osd/modules/debugger/qt/mainwindow.h
| r0 | r243595 | |
| 1 | #ifndef __DEBUG_QT_MAIN_WINDOW_H__ |
| 2 | #define __DEBUG_QT_MAIN_WINDOW_H__ |
| 3 | |
| 4 | #include <QtGui/QtGui> |
| 5 | #include <vector> |
| 6 | |
| 7 | #include "debug/dvdisasm.h" |
| 8 | |
| 9 | #include "debuggerview.h" |
| 10 | #include "windowqt.h" |
| 11 | |
| 12 | class DasmDockWidget; |
| 13 | class ProcessorDockWidget; |
| 14 | |
| 15 | |
| 16 | //============================================================ |
| 17 | // The Main Window. Contains processor and dasm docks. |
| 18 | //============================================================ |
| 19 | class MainWindow : public WindowQt |
| 20 | { |
| 21 | Q_OBJECT |
| 22 | |
| 23 | public: |
| 24 | MainWindow(running_machine* machine, QWidget* parent=NULL); |
| 25 | virtual ~MainWindow(); |
| 26 | |
| 27 | void setProcessor(device_t* processor); |
| 28 | |
| 29 | |
| 30 | protected: |
| 31 | // Used to intercept the user clicking 'X' in the upper corner |
| 32 | void closeEvent(QCloseEvent* event); |
| 33 | |
| 34 | // Used to intercept the user hitting the up arrow in the input widget |
| 35 | bool eventFilter(QObject* obj, QEvent* event); |
| 36 | |
| 37 | |
| 38 | private slots: |
| 39 | void toggleBreakpointAtCursor(bool changedTo); |
| 40 | void runToCursor(bool changedTo); |
| 41 | void rightBarChanged(QAction* changedTo); |
| 42 | |
| 43 | void executeCommand(bool withClear=true); |
| 44 | |
| 45 | void mountImage(bool changedTo); |
| 46 | void unmountImage(bool changedTo); |
| 47 | |
| 48 | // Closing the main window actually exits the program |
| 49 | void debugActClose(); |
| 50 | |
| 51 | |
| 52 | private: |
| 53 | // Widgets and docks |
| 54 | QLineEdit* m_inputEdit; |
| 55 | DebuggerView* m_consoleView; |
| 56 | ProcessorDockWidget* m_procFrame; |
| 57 | DasmDockWidget* m_dasmFrame; |
| 58 | |
| 59 | // Terminal history |
| 60 | int m_historyIndex; |
| 61 | std::vector<QString> m_inputHistory; |
| 62 | void addToHistory(const QString& command); |
| 63 | |
| 64 | void createImagesMenu(); |
| 65 | }; |
| 66 | |
| 67 | |
| 68 | //============================================================ |
| 69 | // Docks with the Main Window. Disassembly. |
| 70 | //============================================================ |
| 71 | class DasmDockWidget : public QWidget |
| 72 | { |
| 73 | Q_OBJECT |
| 74 | |
| 75 | public: |
| 76 | DasmDockWidget(running_machine* machine, QWidget* parent=NULL) : |
| 77 | QWidget(parent), |
| 78 | m_machine(machine) |
| 79 | { |
| 80 | m_dasmView = new DebuggerView(DVT_DISASSEMBLY, |
| 81 | m_machine, |
| 82 | this); |
| 83 | |
| 84 | // Force a recompute of the disassembly region |
| 85 | downcast<debug_view_disasm*>(m_dasmView->view())->set_expression("curpc"); |
| 86 | |
| 87 | QVBoxLayout* dvLayout = new QVBoxLayout(this); |
| 88 | dvLayout->addWidget(m_dasmView); |
| 89 | dvLayout->setContentsMargins(4,0,4,0); |
| 90 | } |
| 91 | |
| 92 | |
| 93 | virtual ~DasmDockWidget(); |
| 94 | |
| 95 | |
| 96 | DebuggerView* view() { return m_dasmView; } |
| 97 | |
| 98 | |
| 99 | QSize minimumSizeHint() const |
| 100 | { |
| 101 | return QSize(150,150); |
| 102 | } |
| 103 | |
| 104 | |
| 105 | QSize sizeHint() const |
| 106 | { |
| 107 | return QSize(150,200); |
| 108 | } |
| 109 | |
| 110 | |
| 111 | private: |
| 112 | DebuggerView* m_dasmView; |
| 113 | |
| 114 | running_machine* m_machine; |
| 115 | }; |
| 116 | |
| 117 | |
| 118 | //============================================================ |
| 119 | // Docks with the Main Window. Processor information. |
| 120 | //============================================================ |
| 121 | class ProcessorDockWidget : public QWidget |
| 122 | { |
| 123 | Q_OBJECT |
| 124 | |
| 125 | public: |
| 126 | ProcessorDockWidget(running_machine* machine, |
| 127 | QWidget* parent=NULL) : |
| 128 | QWidget(parent), |
| 129 | m_processorView(NULL), |
| 130 | m_machine(machine) |
| 131 | { |
| 132 | m_processorView = new DebuggerView(DVT_STATE, |
| 133 | m_machine, |
| 134 | this); |
| 135 | m_processorView->setFocusPolicy(Qt::NoFocus); |
| 136 | |
| 137 | QVBoxLayout* cvLayout = new QVBoxLayout(this); |
| 138 | cvLayout->addWidget(m_processorView); |
| 139 | cvLayout->setContentsMargins(4,0,4,2); |
| 140 | } |
| 141 | |
| 142 | |
| 143 | virtual ~ProcessorDockWidget(); |
| 144 | |
| 145 | |
| 146 | DebuggerView* view() { return m_processorView; } |
| 147 | |
| 148 | |
| 149 | QSize minimumSizeHint() const |
| 150 | { |
| 151 | return QSize(150,300); |
| 152 | } |
| 153 | |
| 154 | |
| 155 | QSize sizeHint() const |
| 156 | { |
| 157 | return QSize(200,300); |
| 158 | } |
| 159 | |
| 160 | |
| 161 | private: |
| 162 | DebuggerView* m_processorView; |
| 163 | |
| 164 | running_machine* m_machine; |
| 165 | }; |
| 166 | |
| 167 | |
| 168 | //========================================================================= |
| 169 | // A way to store the configuration of a window long enough to read/write. |
| 170 | //========================================================================= |
| 171 | class MainWindowQtConfig : public WindowQtConfig |
| 172 | { |
| 173 | public: |
| 174 | MainWindowQtConfig() : |
| 175 | WindowQtConfig(WIN_TYPE_MAIN), |
| 176 | m_rightBar(0), |
| 177 | m_windowState() |
| 178 | {} |
| 179 | |
| 180 | ~MainWindowQtConfig() {} |
| 181 | |
| 182 | // Settings |
| 183 | int m_rightBar; |
| 184 | QByteArray m_windowState; |
| 185 | |
| 186 | void buildFromQWidget(QWidget* widget); |
| 187 | void applyToQWidget(QWidget* widget); |
| 188 | void addToXmlDataNode(xml_data_node* node) const; |
| 189 | void recoverFromXmlNode(xml_data_node* node); |
| 190 | }; |
| 191 | |
| 192 | |
| 193 | |
| 194 | #endif |
trunk/src/osd/modules/debugger/qt/memorywindow.c
| r0 | r243595 | |
| 1 | #define NO_MEM_TRACKING |
| 2 | |
| 3 | #include "memorywindow.h" |
| 4 | |
| 5 | #include "debug/dvmemory.h" |
| 6 | #include "debug/debugcon.h" |
| 7 | #include "debug/debugcpu.h" |
| 8 | |
| 9 | |
| 10 | MemoryWindow::MemoryWindow(running_machine* machine, QWidget* parent) : |
| 11 | WindowQt(machine, NULL) |
| 12 | { |
| 13 | setWindowTitle("Debug: Memory View"); |
| 14 | |
| 15 | if (parent != NULL) |
| 16 | { |
| 17 | QPoint parentPos = parent->pos(); |
| 18 | setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400); |
| 19 | } |
| 20 | |
| 21 | // |
| 22 | // The main frame and its input and log widgets |
| 23 | // |
| 24 | QFrame* mainWindowFrame = new QFrame(this); |
| 25 | |
| 26 | // The top frame & groupbox that contains the input widgets |
| 27 | QFrame* topSubFrame = new QFrame(mainWindowFrame); |
| 28 | |
| 29 | // The input edit |
| 30 | m_inputEdit = new QLineEdit(topSubFrame); |
| 31 | connect(m_inputEdit, SIGNAL(returnPressed()), this, SLOT(expressionSubmitted())); |
| 32 | |
| 33 | // The memory space combo box |
| 34 | m_memoryComboBox = new QComboBox(topSubFrame); |
| 35 | m_memoryComboBox->setObjectName("memoryregion"); |
| 36 | m_memoryComboBox->setMinimumWidth(300); |
| 37 | connect(m_memoryComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(memoryRegionChanged(int))); |
| 38 | |
| 39 | // The main memory window |
| 40 | m_memTable = new DebuggerMemView(DVT_MEMORY, m_machine, this); |
| 41 | |
| 42 | // Layout |
| 43 | QHBoxLayout* subLayout = new QHBoxLayout(topSubFrame); |
| 44 | subLayout->addWidget(m_inputEdit); |
| 45 | subLayout->addWidget(m_memoryComboBox); |
| 46 | subLayout->setSpacing(3); |
| 47 | subLayout->setContentsMargins(2,2,2,2); |
| 48 | |
| 49 | QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame); |
| 50 | vLayout->setSpacing(3); |
| 51 | vLayout->setContentsMargins(2,2,2,2); |
| 52 | vLayout->addWidget(topSubFrame); |
| 53 | vLayout->addWidget(m_memTable); |
| 54 | |
| 55 | setCentralWidget(mainWindowFrame); |
| 56 | |
| 57 | // |
| 58 | // Menu bars |
| 59 | // |
| 60 | // Create a byte-chunk group |
| 61 | QActionGroup* chunkGroup = new QActionGroup(this); |
| 62 | chunkGroup->setObjectName("chunkgroup"); |
| 63 | QAction* chunkActOne = new QAction("1-byte chunks", this); |
| 64 | chunkActOne->setObjectName("chunkActOne"); |
| 65 | QAction* chunkActTwo = new QAction("2-byte chunks", this); |
| 66 | chunkActTwo->setObjectName("chunkActTwo"); |
| 67 | QAction* chunkActFour = new QAction("4-byte chunks", this); |
| 68 | chunkActFour->setObjectName("chunkActFour"); |
| 69 | chunkActOne->setCheckable(true); |
| 70 | chunkActTwo->setCheckable(true); |
| 71 | chunkActFour->setCheckable(true); |
| 72 | chunkActOne->setActionGroup(chunkGroup); |
| 73 | chunkActTwo->setActionGroup(chunkGroup); |
| 74 | chunkActFour->setActionGroup(chunkGroup); |
| 75 | chunkActOne->setShortcut(QKeySequence("Ctrl+1")); |
| 76 | chunkActTwo->setShortcut(QKeySequence("Ctrl+2")); |
| 77 | chunkActFour->setShortcut(QKeySequence("Ctrl+4")); |
| 78 | chunkActOne->setChecked(true); |
| 79 | connect(chunkGroup, SIGNAL(triggered(QAction*)), this, SLOT(chunkChanged(QAction*))); |
| 80 | |
| 81 | // Create a address display group |
| 82 | QActionGroup* addressGroup = new QActionGroup(this); |
| 83 | addressGroup->setObjectName("addressgroup"); |
| 84 | QAction* addressActLogical = new QAction("Logical Addresses", this); |
| 85 | QAction* addressActPhysical = new QAction("Physical Addresses", this); |
| 86 | addressActLogical->setCheckable(true); |
| 87 | addressActPhysical->setCheckable(true); |
| 88 | addressActLogical->setActionGroup(addressGroup); |
| 89 | addressActPhysical->setActionGroup(addressGroup); |
| 90 | addressActLogical->setShortcut(QKeySequence("Ctrl+G")); |
| 91 | addressActPhysical->setShortcut(QKeySequence("Ctrl+Y")); |
| 92 | addressActLogical->setChecked(true); |
| 93 | connect(addressGroup, SIGNAL(triggered(QAction*)), this, SLOT(addressChanged(QAction*))); |
| 94 | |
| 95 | // Create a reverse view radio |
| 96 | QAction* reverseAct = new QAction("Reverse View", this); |
| 97 | reverseAct->setObjectName("reverse"); |
| 98 | reverseAct->setCheckable(true); |
| 99 | reverseAct->setShortcut(QKeySequence("Ctrl+R")); |
| 100 | connect(reverseAct, SIGNAL(toggled(bool)), this, SLOT(reverseChanged(bool))); |
| 101 | |
| 102 | // Create increase and decrease bytes-per-line actions |
| 103 | QAction* increaseBplAct = new QAction("Increase Bytes Per Line", this); |
| 104 | QAction* decreaseBplAct = new QAction("Decrease Bytes Per Line", this); |
| 105 | increaseBplAct->setShortcut(QKeySequence("Ctrl+P")); |
| 106 | decreaseBplAct->setShortcut(QKeySequence("Ctrl+O")); |
| 107 | connect(increaseBplAct, SIGNAL(triggered(bool)), this, SLOT(increaseBytesPerLine(bool))); |
| 108 | connect(decreaseBplAct, SIGNAL(triggered(bool)), this, SLOT(decreaseBytesPerLine(bool))); |
| 109 | |
| 110 | // Assemble the options menu |
| 111 | QMenu* optionsMenu = menuBar()->addMenu("&Options"); |
| 112 | optionsMenu->addActions(chunkGroup->actions()); |
| 113 | optionsMenu->addSeparator(); |
| 114 | optionsMenu->addActions(addressGroup->actions()); |
| 115 | optionsMenu->addSeparator(); |
| 116 | optionsMenu->addAction(reverseAct); |
| 117 | optionsMenu->addSeparator(); |
| 118 | optionsMenu->addAction(increaseBplAct); |
| 119 | optionsMenu->addAction(decreaseBplAct); |
| 120 | |
| 121 | |
| 122 | // |
| 123 | // Initialize |
| 124 | // |
| 125 | populateComboBox(); |
| 126 | |
| 127 | // Set to the current CPU's memory view |
| 128 | setToCurrentCpu(); |
| 129 | } |
| 130 | |
| 131 | |
| 132 | MemoryWindow::~MemoryWindow() |
| 133 | { |
| 134 | } |
| 135 | |
| 136 | |
| 137 | void MemoryWindow::memoryRegionChanged(int index) |
| 138 | { |
| 139 | m_memTable->view()->set_source(*m_memTable->view()->source_list().find(index)); |
| 140 | m_memTable->viewport()->update(); |
| 141 | |
| 142 | // Update the chunk size radio buttons to the memory region's default |
| 143 | debug_view_memory* memView = downcast<debug_view_memory*>(m_memTable->view()); |
| 144 | switch(memView->bytes_per_chunk()) |
| 145 | { |
| 146 | case 1: chunkSizeMenuItem("chunkActOne")->setChecked(true); break; |
| 147 | case 2: chunkSizeMenuItem("chunkActTwo")->setChecked(true); break; |
| 148 | case 4: chunkSizeMenuItem("chunkActFour")->setChecked(true); break; |
| 149 | default: break; |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | |
| 154 | void MemoryWindow::expressionSubmitted() |
| 155 | { |
| 156 | const QString expression = m_inputEdit->text(); |
| 157 | downcast<debug_view_memory*>(m_memTable->view())->set_expression(expression.toLocal8Bit().data()); |
| 158 | |
| 159 | // Make the cursor pop |
| 160 | m_memTable->view()->set_cursor_visible(true); |
| 161 | |
| 162 | // Check where the cursor is and adjust the scroll accordingly |
| 163 | debug_view_xy cursorPosition = m_memTable->view()->cursor_position(); |
| 164 | // TODO: check if the region is already visible? |
| 165 | m_memTable->verticalScrollBar()->setValue(cursorPosition.y); |
| 166 | |
| 167 | m_memTable->update(); |
| 168 | m_memTable->viewport()->update(); |
| 169 | } |
| 170 | |
| 171 | |
| 172 | void MemoryWindow::chunkChanged(QAction* changedTo) |
| 173 | { |
| 174 | debug_view_memory* memView = downcast<debug_view_memory*>(m_memTable->view()); |
| 175 | if (changedTo->text() == "1-byte chunks") |
| 176 | { |
| 177 | memView->set_bytes_per_chunk(1); |
| 178 | } |
| 179 | else if (changedTo->text() == "2-byte chunks") |
| 180 | { |
| 181 | memView->set_bytes_per_chunk(2); |
| 182 | } |
| 183 | else if (changedTo->text() == "4-byte chunks") |
| 184 | { |
| 185 | memView->set_bytes_per_chunk(4); |
| 186 | } |
| 187 | m_memTable->viewport()->update(); |
| 188 | } |
| 189 | |
| 190 | |
| 191 | void MemoryWindow::addressChanged(QAction* changedTo) |
| 192 | { |
| 193 | debug_view_memory* memView = downcast<debug_view_memory*>(m_memTable->view()); |
| 194 | if (changedTo->text() == "Logical Addresses") |
| 195 | { |
| 196 | memView->set_physical(false); |
| 197 | } |
| 198 | else if (changedTo->text() == "Physical Addresses") |
| 199 | { |
| 200 | memView->set_physical(true); |
| 201 | } |
| 202 | m_memTable->viewport()->update(); |
| 203 | } |
| 204 | |
| 205 | |
| 206 | void MemoryWindow::reverseChanged(bool changedTo) |
| 207 | { |
| 208 | debug_view_memory* memView = downcast<debug_view_memory*>(m_memTable->view()); |
| 209 | memView->set_reverse(changedTo); |
| 210 | m_memTable->viewport()->update(); |
| 211 | } |
| 212 | |
| 213 | |
| 214 | void MemoryWindow::increaseBytesPerLine(bool changedTo) |
| 215 | { |
| 216 | debug_view_memory* memView = downcast<debug_view_memory*>(m_memTable->view()); |
| 217 | memView->set_chunks_per_row(memView->chunks_per_row() + 1); |
| 218 | m_memTable->viewport()->update(); |
| 219 | } |
| 220 | |
| 221 | |
| 222 | void MemoryWindow::decreaseBytesPerLine(bool checked) |
| 223 | { |
| 224 | debug_view_memory* memView = downcast<debug_view_memory*>(m_memTable->view()); |
| 225 | memView->set_chunks_per_row(memView->chunks_per_row() - 1); |
| 226 | m_memTable->viewport()->update(); |
| 227 | } |
| 228 | |
| 229 | |
| 230 | void MemoryWindow::populateComboBox() |
| 231 | { |
| 232 | if (m_memTable == NULL) |
| 233 | return; |
| 234 | |
| 235 | m_memoryComboBox->clear(); |
| 236 | for (const debug_view_source* source = m_memTable->view()->first_source(); |
| 237 | source != NULL; |
| 238 | source = source->next()) |
| 239 | { |
| 240 | m_memoryComboBox->addItem(source->name()); |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | |
| 245 | void MemoryWindow::setToCurrentCpu() |
| 246 | { |
| 247 | device_t* curCpu = debug_cpu_get_visible_cpu(*m_machine); |
| 248 | const debug_view_source *source = m_memTable->view()->source_for_device(curCpu); |
| 249 | const int listIndex = m_memTable->view()->source_list().indexof(*source); |
| 250 | m_memoryComboBox->setCurrentIndex(listIndex); |
| 251 | } |
| 252 | |
| 253 | |
| 254 | // I have a hard time storing QActions as class members. This is a substitute. |
| 255 | QAction* MemoryWindow::chunkSizeMenuItem(const QString& itemName) |
| 256 | { |
| 257 | QList<QMenu*> menus = menuBar()->findChildren<QMenu*>(); |
| 258 | for (int i = 0; i < menus.length(); i++) |
| 259 | { |
| 260 | if (menus[i]->title() != "&Options") continue; |
| 261 | QList<QAction*> actions = menus[i]->actions(); |
| 262 | for (int j = 0; j < actions.length(); j++) |
| 263 | { |
| 264 | if (actions[j]->objectName() == itemName) |
| 265 | return actions[j]; |
| 266 | } |
| 267 | } |
| 268 | return NULL; |
| 269 | } |
| 270 | |
| 271 | |
| 272 | //========================================================================= |
| 273 | // DebuggerMemView |
| 274 | //========================================================================= |
| 275 | void DebuggerMemView::mousePressEvent(QMouseEvent* event) |
| 276 | { |
| 277 | const bool leftClick = event->button() == Qt::LeftButton; |
| 278 | const bool rightClick = event->button() == Qt::RightButton; |
| 279 | |
| 280 | if (leftClick || rightClick) |
| 281 | { |
| 282 | QFontMetrics actualFont = fontMetrics(); |
| 283 | const double fontWidth = actualFont.width(QString(100, '_')) / 100.; |
| 284 | const int fontHeight = MAX(1, actualFont.height()); |
| 285 | |
| 286 | debug_view_xy topLeft = view()->visible_position(); |
| 287 | debug_view_xy clickViewPosition; |
| 288 | clickViewPosition.x = topLeft.x + (event->x() / fontWidth); |
| 289 | clickViewPosition.y = topLeft.y + (event->y() / fontHeight); |
| 290 | if (leftClick) |
| 291 | { |
| 292 | view()->process_click(DCK_LEFT_CLICK, clickViewPosition); |
| 293 | } |
| 294 | else if (rightClick) |
| 295 | { |
| 296 | // Display the last known PC to write to this memory location & copy it onto the clipboard |
| 297 | debug_view_memory* memView = downcast<debug_view_memory*>(view()); |
| 298 | const offs_t address = memView->addressAtCursorPosition(clickViewPosition); |
| 299 | const debug_view_memory_source* source = downcast<const debug_view_memory_source*>(memView->source()); |
| 300 | address_space* addressSpace = source->space(); |
| 301 | const int nativeDataWidth = addressSpace->data_width() / 8; |
| 302 | const UINT64 memValue = debug_read_memory(*addressSpace, |
| 303 | addressSpace->address_to_byte(address), |
| 304 | nativeDataWidth, |
| 305 | true); |
| 306 | const offs_t pc = source->device()->debug()->track_mem_pc_from_space_address_data(addressSpace->spacenum(), |
| 307 | address, |
| 308 | memValue); |
| 309 | if (pc != (offs_t)(-1)) |
| 310 | { |
| 311 | // TODO: You can specify a box that the tooltip stays alive within - might be good? |
| 312 | const QString addressAndPc = QString("Address %1 written at PC=%2").arg(address, 2, 16).arg(pc, 2, 16); |
| 313 | QToolTip::showText(QCursor::pos(), addressAndPc, NULL); |
| 314 | |
| 315 | // Copy the PC into the clipboard as well |
| 316 | QClipboard *clipboard = QApplication::clipboard(); |
| 317 | clipboard->setText(QString("%1").arg(pc, 2, 16)); |
| 318 | } |
| 319 | else |
| 320 | { |
| 321 | QToolTip::showText(QCursor::pos(), "UNKNOWN PC", NULL); |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | viewport()->update(); |
| 326 | update(); |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | |
| 331 | //========================================================================= |
| 332 | // MemoryWindowQtConfig |
| 333 | //========================================================================= |
| 334 | void MemoryWindowQtConfig::buildFromQWidget(QWidget* widget) |
| 335 | { |
| 336 | WindowQtConfig::buildFromQWidget(widget); |
| 337 | MemoryWindow* window = dynamic_cast<MemoryWindow*>(widget); |
| 338 | QComboBox* memoryRegion = window->findChild<QComboBox*>("memoryregion"); |
| 339 | m_memoryRegion = memoryRegion->currentIndex(); |
| 340 | |
| 341 | QAction* reverse = window->findChild<QAction*>("reverse"); |
| 342 | m_reverse = reverse->isChecked(); |
| 343 | |
| 344 | QActionGroup* addressGroup = window->findChild<QActionGroup*>("addressgroup"); |
| 345 | if (addressGroup->checkedAction()->text() == "Logical Addresses") |
| 346 | m_addressMode = 0; |
| 347 | else if (addressGroup->checkedAction()->text() == "Physical Addresses") |
| 348 | m_addressMode = 1; |
| 349 | |
| 350 | QActionGroup* chunkGroup = window->findChild<QActionGroup*>("chunkgroup"); |
| 351 | if (chunkGroup->checkedAction()->text() == "1-byte chunks") |
| 352 | m_chunkSize = 0; |
| 353 | else if (chunkGroup->checkedAction()->text() == "2-byte chunks") |
| 354 | m_chunkSize = 1; |
| 355 | else if (chunkGroup->checkedAction()->text() == "4-byte chunks") |
| 356 | m_chunkSize = 2; |
| 357 | } |
| 358 | |
| 359 | |
| 360 | void MemoryWindowQtConfig::applyToQWidget(QWidget* widget) |
| 361 | { |
| 362 | WindowQtConfig::applyToQWidget(widget); |
| 363 | MemoryWindow* window = dynamic_cast<MemoryWindow*>(widget); |
| 364 | QComboBox* memoryRegion = window->findChild<QComboBox*>("memoryregion"); |
| 365 | memoryRegion->setCurrentIndex(m_memoryRegion); |
| 366 | |
| 367 | QAction* reverse = window->findChild<QAction*>("reverse"); |
| 368 | if (m_reverse) reverse->trigger(); |
| 369 | |
| 370 | QActionGroup* addressGroup = window->findChild<QActionGroup*>("addressgroup"); |
| 371 | addressGroup->actions()[m_addressMode]->trigger(); |
| 372 | |
| 373 | QActionGroup* chunkGroup = window->findChild<QActionGroup*>("chunkgroup"); |
| 374 | chunkGroup->actions()[m_chunkSize]->trigger(); |
| 375 | } |
| 376 | |
| 377 | |
| 378 | void MemoryWindowQtConfig::addToXmlDataNode(xml_data_node* node) const |
| 379 | { |
| 380 | WindowQtConfig::addToXmlDataNode(node); |
| 381 | xml_set_attribute_int(node, "memoryregion", m_memoryRegion); |
| 382 | xml_set_attribute_int(node, "reverse", m_reverse); |
| 383 | xml_set_attribute_int(node, "addressmode", m_addressMode); |
| 384 | xml_set_attribute_int(node, "chunksize", m_chunkSize); |
| 385 | } |
| 386 | |
| 387 | |
| 388 | void MemoryWindowQtConfig::recoverFromXmlNode(xml_data_node* node) |
| 389 | { |
| 390 | WindowQtConfig::recoverFromXmlNode(node); |
| 391 | m_memoryRegion = xml_get_attribute_int(node, "memoryregion", m_memoryRegion); |
| 392 | m_reverse = xml_get_attribute_int(node, "reverse", m_reverse); |
| 393 | m_addressMode = xml_get_attribute_int(node, "addressmode", m_addressMode); |
| 394 | m_chunkSize = xml_get_attribute_int(node, "chunksize", m_chunkSize); |
| 395 | } |
trunk/src/osd/modules/debugger/qt/windowqt.c
| r0 | r243595 | |
| 1 | #define NO_MEM_TRACKING |
| 2 | |
| 3 | #include "windowqt.h" |
| 4 | #include "logwindow.h" |
| 5 | #include "dasmwindow.h" |
| 6 | #include "memorywindow.h" |
| 7 | #include "breakpointswindow.h" |
| 8 | #include "deviceswindow.h" |
| 9 | |
| 10 | bool WindowQt::s_refreshAll = false; |
| 11 | bool WindowQt::s_hideAll = false; |
| 12 | |
| 13 | |
| 14 | // Since all debug windows are intended to be top-level, this inherited |
| 15 | // constructor is always called with a NULL parent. The passed-in parent widget, |
| 16 | // however, is often used to place each child window & the code to do this can |
| 17 | // be found in most of the inherited classes. |
| 18 | |
| 19 | WindowQt::WindowQt(running_machine* machine, QWidget* parent) : |
| 20 | QMainWindow(parent), |
| 21 | m_machine(machine) |
| 22 | { |
| 23 | setAttribute(Qt::WA_DeleteOnClose, true); |
| 24 | |
| 25 | // The Debug menu bar |
| 26 | QAction* debugActOpenMemory = new QAction("New &Memory Window", this); |
| 27 | debugActOpenMemory->setShortcut(QKeySequence("Ctrl+M")); |
| 28 | connect(debugActOpenMemory, SIGNAL(triggered()), this, SLOT(debugActOpenMemory())); |
| 29 | |
| 30 | QAction* debugActOpenDasm = new QAction("New &Dasm Window", this); |
| 31 | debugActOpenDasm->setShortcut(QKeySequence("Ctrl+D")); |
| 32 | connect(debugActOpenDasm, SIGNAL(triggered()), this, SLOT(debugActOpenDasm())); |
| 33 | |
| 34 | QAction* debugActOpenLog = new QAction("New &Log Window", this); |
| 35 | debugActOpenLog->setShortcut(QKeySequence("Ctrl+L")); |
| 36 | connect(debugActOpenLog, SIGNAL(triggered()), this, SLOT(debugActOpenLog())); |
| 37 | |
| 38 | QAction* debugActOpenPoints = new QAction("New &Break|Watchpoints Window", this); |
| 39 | debugActOpenPoints->setShortcut(QKeySequence("Ctrl+B")); |
| 40 | connect(debugActOpenPoints, SIGNAL(triggered()), this, SLOT(debugActOpenPoints())); |
| 41 | |
| 42 | QAction* debugActOpenDevices = new QAction("New D&evices Window", this); |
| 43 | debugActOpenDevices->setShortcut(QKeySequence("Shift+Ctrl+D")); |
| 44 | connect(debugActOpenDevices, SIGNAL(triggered()), this, SLOT(debugActOpenDevices())); |
| 45 | |
| 46 | QAction* dbgActRun = new QAction("Run", this); |
| 47 | dbgActRun->setShortcut(Qt::Key_F5); |
| 48 | connect(dbgActRun, SIGNAL(triggered()), this, SLOT(debugActRun())); |
| 49 | |
| 50 | QAction* dbgActRunAndHide = new QAction("Run And Hide Debugger", this); |
| 51 | dbgActRunAndHide->setShortcut(Qt::Key_F12); |
| 52 | connect(dbgActRunAndHide, SIGNAL(triggered()), this, SLOT(debugActRunAndHide())); |
| 53 | |
| 54 | QAction* dbgActRunToNextCpu = new QAction("Run to Next CPU", this); |
| 55 | dbgActRunToNextCpu->setShortcut(Qt::Key_F6); |
| 56 | connect(dbgActRunToNextCpu, SIGNAL(triggered()), this, SLOT(debugActRunToNextCpu())); |
| 57 | |
| 58 | QAction* dbgActRunNextInt = new QAction("Run to Next Interrupt on This CPU", this); |
| 59 | dbgActRunNextInt->setShortcut(Qt::Key_F7); |
| 60 | connect(dbgActRunNextInt, SIGNAL(triggered()), this, SLOT(debugActRunNextInt())); |
| 61 | |
| 62 | QAction* dbgActRunNextVBlank = new QAction("Run to Next VBlank", this); |
| 63 | dbgActRunNextVBlank->setShortcut(Qt::Key_F8); |
| 64 | connect(dbgActRunNextVBlank, SIGNAL(triggered()), this, SLOT(debugActRunNextVBlank())); |
| 65 | |
| 66 | QAction* dbgActStepInto = new QAction("Step Into", this); |
| 67 | dbgActStepInto->setShortcut(Qt::Key_F11); |
| 68 | connect(dbgActStepInto, SIGNAL(triggered()), this, SLOT(debugActStepInto())); |
| 69 | |
| 70 | QAction* dbgActStepOver = new QAction("Step Over", this); |
| 71 | dbgActStepOver->setShortcut(Qt::Key_F10); |
| 72 | connect(dbgActStepOver, SIGNAL(triggered()), this, SLOT(debugActStepOver())); |
| 73 | |
| 74 | QAction* dbgActStepOut = new QAction("Step Out", this); |
| 75 | dbgActStepOut->setShortcut(QKeySequence("Shift+F11")); |
| 76 | connect(dbgActStepOut, SIGNAL(triggered()), this, SLOT(debugActStepOut())); |
| 77 | |
| 78 | QAction* dbgActSoftReset = new QAction("Soft Reset", this); |
| 79 | dbgActSoftReset->setShortcut(Qt::Key_F3); |
| 80 | connect(dbgActSoftReset, SIGNAL(triggered()), this, SLOT(debugActSoftReset())); |
| 81 | |
| 82 | QAction* dbgActHardReset = new QAction("Hard Reset", this); |
| 83 | dbgActHardReset->setShortcut(QKeySequence("Shift+F3")); |
| 84 | connect(dbgActHardReset, SIGNAL(triggered()), this, SLOT(debugActHardReset())); |
| 85 | |
| 86 | QAction* dbgActClose = new QAction("Close &Window", this); |
| 87 | dbgActClose->setShortcut(QKeySequence::Close); |
| 88 | connect(dbgActClose, SIGNAL(triggered()), this, SLOT(debugActClose())); |
| 89 | |
| 90 | QAction* dbgActQuit = new QAction("&Quit", this); |
| 91 | dbgActQuit->setShortcut(QKeySequence::Quit); |
| 92 | connect(dbgActQuit, SIGNAL(triggered()), this, SLOT(debugActQuit())); |
| 93 | |
| 94 | // Construct the menu |
| 95 | QMenu* debugMenu = menuBar()->addMenu("&Debug"); |
| 96 | debugMenu->addAction(debugActOpenMemory); |
| 97 | debugMenu->addAction(debugActOpenDasm); |
| 98 | debugMenu->addAction(debugActOpenLog); |
| 99 | debugMenu->addAction(debugActOpenPoints); |
| 100 | debugMenu->addAction(debugActOpenDevices); |
| 101 | debugMenu->addSeparator(); |
| 102 | debugMenu->addAction(dbgActRun); |
| 103 | debugMenu->addAction(dbgActRunAndHide); |
| 104 | debugMenu->addAction(dbgActRunToNextCpu); |
| 105 | debugMenu->addAction(dbgActRunNextInt); |
| 106 | debugMenu->addAction(dbgActRunNextVBlank); |
| 107 | debugMenu->addSeparator(); |
| 108 | debugMenu->addAction(dbgActStepInto); |
| 109 | debugMenu->addAction(dbgActStepOver); |
| 110 | debugMenu->addAction(dbgActStepOut); |
| 111 | debugMenu->addSeparator(); |
| 112 | debugMenu->addAction(dbgActSoftReset); |
| 113 | debugMenu->addAction(dbgActHardReset); |
| 114 | debugMenu->addSeparator(); |
| 115 | debugMenu->addAction(dbgActClose); |
| 116 | debugMenu->addAction(dbgActQuit); |
| 117 | } |
| 118 | |
| 119 | |
| 120 | WindowQt::~WindowQt() |
| 121 | { |
| 122 | } |
| 123 | |
| 124 | void WindowQt::debugActOpenMemory() |
| 125 | { |
| 126 | MemoryWindow* foo = new MemoryWindow(m_machine, this); |
| 127 | // A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon |
| 128 | // foo->setWindowFlags(Qt::Dialog); |
| 129 | // foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint); |
| 130 | foo->show(); |
| 131 | } |
| 132 | |
| 133 | |
| 134 | void WindowQt::debugActOpenDasm() |
| 135 | { |
| 136 | DasmWindow* foo = new DasmWindow(m_machine, this); |
| 137 | // A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon |
| 138 | // foo->setWindowFlags(Qt::Dialog); |
| 139 | // foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint); |
| 140 | foo->show(); |
| 141 | } |
| 142 | |
| 143 | |
| 144 | void WindowQt::debugActOpenLog() |
| 145 | { |
| 146 | LogWindow* foo = new LogWindow(m_machine, this); |
| 147 | // A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon |
| 148 | // foo->setWindowFlags(Qt::Dialog); |
| 149 | // foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint); |
| 150 | foo->show(); |
| 151 | } |
| 152 | |
| 153 | |
| 154 | void WindowQt::debugActOpenPoints() |
| 155 | { |
| 156 | BreakpointsWindow* foo = new BreakpointsWindow(m_machine, this); |
| 157 | // A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon |
| 158 | // foo->setWindowFlags(Qt::Dialog); |
| 159 | // foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint); |
| 160 | foo->show(); |
| 161 | } |
| 162 | |
| 163 | |
| 164 | void WindowQt::debugActOpenDevices() |
| 165 | { |
| 166 | DevicesWindow* foo = new DevicesWindow(m_machine, this); |
| 167 | // A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon |
| 168 | // foo->setWindowFlags(Qt::Dialog); |
| 169 | // foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint); |
| 170 | foo->show(); |
| 171 | } |
| 172 | |
| 173 | |
| 174 | void WindowQt::debugActRun() |
| 175 | { |
| 176 | debug_cpu_get_visible_cpu(*m_machine)->debug()->go(); |
| 177 | } |
| 178 | |
| 179 | void WindowQt::debugActRunAndHide() |
| 180 | { |
| 181 | debug_cpu_get_visible_cpu(*m_machine)->debug()->go(); |
| 182 | hideAll(); |
| 183 | } |
| 184 | |
| 185 | void WindowQt::debugActRunToNextCpu() |
| 186 | { |
| 187 | debug_cpu_get_visible_cpu(*m_machine)->debug()->go_next_device(); |
| 188 | } |
| 189 | |
| 190 | void WindowQt::debugActRunNextInt() |
| 191 | { |
| 192 | debug_cpu_get_visible_cpu(*m_machine)->debug()->go_interrupt(); |
| 193 | } |
| 194 | |
| 195 | void WindowQt::debugActRunNextVBlank() |
| 196 | { |
| 197 | debug_cpu_get_visible_cpu(*m_machine)->debug()->go_vblank(); |
| 198 | } |
| 199 | |
| 200 | void WindowQt::debugActStepInto() |
| 201 | { |
| 202 | debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step(); |
| 203 | } |
| 204 | |
| 205 | void WindowQt::debugActStepOver() |
| 206 | { |
| 207 | debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step_over(); |
| 208 | } |
| 209 | |
| 210 | void WindowQt::debugActStepOut() |
| 211 | { |
| 212 | debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step_out(); |
| 213 | } |
| 214 | |
| 215 | void WindowQt::debugActSoftReset() |
| 216 | { |
| 217 | m_machine->schedule_soft_reset(); |
| 218 | debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step(); |
| 219 | } |
| 220 | |
| 221 | void WindowQt::debugActHardReset() |
| 222 | { |
| 223 | m_machine->schedule_hard_reset(); |
| 224 | } |
| 225 | |
| 226 | void WindowQt::debugActClose() |
| 227 | { |
| 228 | close(); |
| 229 | } |
| 230 | |
| 231 | void WindowQt::debugActQuit() |
| 232 | { |
| 233 | m_machine->schedule_exit(); |
| 234 | } |
| 235 | |
| 236 | |
| 237 | //========================================================================= |
| 238 | // WindowQtConfig |
| 239 | //========================================================================= |
| 240 | void WindowQtConfig::buildFromQWidget(QWidget* widget) |
| 241 | { |
| 242 | m_position.setX(widget->geometry().topLeft().x()); |
| 243 | m_position.setY(widget->geometry().topLeft().y()); |
| 244 | m_size.setX(widget->size().width()); |
| 245 | m_size.setY(widget->size().height()); |
| 246 | } |
| 247 | |
| 248 | |
| 249 | void WindowQtConfig::applyToQWidget(QWidget* widget) |
| 250 | { |
| 251 | widget->setGeometry(m_position.x(), m_position.y(), m_size.x(), m_size.y()); |
| 252 | } |
| 253 | |
| 254 | |
| 255 | void WindowQtConfig::addToXmlDataNode(xml_data_node* node) const |
| 256 | { |
| 257 | xml_set_attribute_int(node, "type", m_type); |
| 258 | xml_set_attribute_int(node, "position_x", m_position.x()); |
| 259 | xml_set_attribute_int(node, "position_y", m_position.y()); |
| 260 | xml_set_attribute_int(node, "size_x", m_size.x()); |
| 261 | xml_set_attribute_int(node, "size_y", m_size.y()); |
| 262 | } |
| 263 | |
| 264 | |
| 265 | void WindowQtConfig::recoverFromXmlNode(xml_data_node* node) |
| 266 | { |
| 267 | m_size.setX(xml_get_attribute_int(node, "size_x", m_size.x())); |
| 268 | m_size.setY(xml_get_attribute_int(node, "size_y", m_size.y())); |
| 269 | m_position.setX(xml_get_attribute_int(node, "position_x", m_position.x())); |
| 270 | m_position.setY(xml_get_attribute_int(node, "position_y", m_position.y())); |
| 271 | m_type = (WindowQtConfig::WindowType)xml_get_attribute_int(node, "type", m_type); |
| 272 | } |