diff --git a/src/devices/cpu/gigatron/gigatron.cpp b/src/devices/cpu/gigatron/gigatron.cpp index 6c25f4abd52..78e3a19afb2 100644 --- a/src/devices/cpu/gigatron/gigatron.cpp +++ b/src/devices/cpu/gigatron/gigatron.cpp @@ -13,7 +13,7 @@ #include "gigatrondasm.h" -DEFINE_DEVICE_TYPE(GTRON, gigatron_cpu_device, "gigatron_cpu", "Gigatron CPU") +DEFINE_DEVICE_TYPE(GTRON, gigatron_cpu_device, "gigatron_cpu", "Gigatron") /* FLAGS */ @@ -24,7 +24,6 @@ DEFINE_DEVICE_TYPE(GTRON, gigatron_cpu_device, "gigatron_cpu", "Gigatron CPU") #define C 0x10 #endif - #define gigatron_readop(A) m_program->read_word(A) #define gigatron_readmem16(A) m_data->read_dword(A) #define gigatron_readmem8(A) m_data->read_byte(A) @@ -52,7 +51,8 @@ void gigatron_cpu_device::execute_run() debugger_instruction_hook(m_pc); opcode = gigatron_readop(m_pc); - m_pc = m_npc++; + m_pc = m_npc; + m_npc = (m_pc + 1) & m_romMask; uint8_t op = (opcode >> 13) & 0x0007; uint8_t mode = (opcode >> 10) & 0x0007; @@ -98,7 +98,7 @@ void gigatron_cpu_device::init() m_x = 0; m_y = 0; m_pc = 0; - m_npc = (m_pc + 1); + m_npc = (m_pc + 1) & m_romMask; m_ppc = 0; m_inReg = 0xFF; @@ -109,6 +109,7 @@ void gigatron_cpu_device::init() state_add(GTRON_AC, "AC", m_ac); state_add(GTRON_X, "X", m_x); state_add(GTRON_Y, "Y", m_y); + state_add(GTRON_IREG, "IREG", m_inReg); set_icountptr(m_icount); @@ -121,6 +122,7 @@ void gigatron_cpu_device::init() save_item(NAME(m_pc)); m_outx_cb.resolve_safe(); + m_ir_cb.resolve_safe(0); } void gigatron_cpu_device::branchOp(uint8_t op, uint8_t mode, uint8_t bus, uint8_t d) @@ -131,29 +133,29 @@ void gigatron_cpu_device::branchOp(uint8_t op, uint8_t mode, uint8_t bus, uint8_ uint16_t base = m_pc & 0xff00; switch (mode) { - case 0: + case 0: //jmp c = true; base = m_y << 8; break; - case 1: + case 1: //bgt c = (ac2 > ZERO); break; - case 2: + case 2: //blt c = (ac2 < ZERO); break; - case 3: + case 3: //bne c = (ac2 != ZERO); break; - case 4: + case 4: //beq c = (ac2 == ZERO); break; - case 5: + case 5: //bge c = (ac2 >= ZERO); break; - case 6: + case 6: //ble c = (ac2 <= ZERO); break; - case 7: + case 7: //bra c = true; break; } @@ -219,7 +221,10 @@ void gigatron_cpu_device::aluOp(uint8_t op, uint8_t mode, uint8_t bus, uint8_t d case 7: uint16_t rising = ~(m_out & b); if (rising & 0x40) + { m_outx = m_ac; + m_outx_cb(0, m_outx, 0xFF); + } break; } } @@ -313,10 +318,12 @@ void gigatron_cpu_device::execute_set_input(int irqline, int state) gigatron_cpu_device::gigatron_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : cpu_device(mconfig, GTRON, tag, owner, clock) - , m_ramMask(0x7fff) + , m_ramMask(0x7FFF) + , m_romMask(0xFFFF) , m_program_config("program", ENDIANNESS_BIG, 16, 14, -1) , m_data_config("data", ENDIANNESS_BIG, 8, 15, 0) , m_outx_cb(*this) + , m_ir_cb(*this) { } diff --git a/src/devices/cpu/gigatron/gigatron.h b/src/devices/cpu/gigatron/gigatron.h index 6cc1173d23c..50f359af21f 100644 --- a/src/devices/cpu/gigatron/gigatron.h +++ b/src/devices/cpu/gigatron/gigatron.h @@ -16,7 +16,7 @@ enum { GTRON_PC, GTRON_NPC, - GTRON_AC, GTRON_X, GTRON_Y + GTRON_AC, GTRON_X, GTRON_Y, GTRON_IREG }; @@ -26,6 +26,7 @@ public: // construction/destruction gigatron_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); auto outx_cb() { return m_outx_cb.bind(); } + auto ir_cb() { return m_ir_cb.bind(); } protected: // device-level overrides @@ -61,6 +62,7 @@ protected: uint16_t m_ppc; uint8_t m_inReg; uint16_t m_ramMask; + uint16_t m_romMask; uint16_t m_out; uint16_t m_outx; @@ -79,6 +81,7 @@ private: void gigatron_illegal(); devcb_write8 m_outx_cb; + devcb_read8 m_ir_cb; }; diff --git a/src/mame/drivers/gigatron.cpp b/src/mame/drivers/gigatron.cpp index e589c88f201..30590ebc4a2 100644 --- a/src/mame/drivers/gigatron.cpp +++ b/src/mame/drivers/gigatron.cpp @@ -48,6 +48,7 @@ private: } void blinkenlights(uint8_t data); + uint8_t inputs(); required_device m_maincpu; required_ioport m_io_inputs; @@ -82,6 +83,11 @@ void gigatron_state::blinkenlights(uint8_t data) lights_changed ^= light; } +uint8_t gigatron_state::inputs() +{ + return m_io_inputs->read() ^ 0xFF; +} + static INPUT_PORTS_START(gigatron) PORT_START("GAMEPAD") PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1) @@ -100,6 +106,7 @@ void gigatron_state::gigatron(machine_config &config) m_maincpu->set_addrmap(AS_PROGRAM, &gigatron_state::prog_map); m_maincpu->set_addrmap(AS_DATA, &gigatron_state::data_map); m_maincpu->outx_cb().set(FUNC(gigatron_state::blinkenlights)); + m_maincpu->ir_cb().set(FUNC(gigatron_state::inputs)); /* video hardware */ screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));