diff --git a/src/devices/cpu/gigatron/gigatron.cpp b/src/devices/cpu/gigatron/gigatron.cpp index 78e3a19afb2..9226bdda40c 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") +DEFINE_DEVICE_TYPE(GTRON, gigatron_cpu_device, "gigatron_cpu", "Gigatron CPU") /* FLAGS */ @@ -89,19 +89,6 @@ void gigatron_cpu_device::device_start() m_program = &space(AS_PROGRAM); m_data = &space(AS_DATA); - init(); -} - -void gigatron_cpu_device::init() -{ - m_ac = 0; - m_x = 0; - m_y = 0; - m_pc = 0; - m_npc = (m_pc + 1) & m_romMask; - m_ppc = 0; - m_inReg = 0xFF; - state_add(GTRON_PC, "PC", m_pc); state_add(GTRON_NPC, "NPC", m_npc); state_add(STATE_GENPC, "GENPC", m_pc).noshow(); @@ -110,6 +97,8 @@ void gigatron_cpu_device::init() state_add(GTRON_X, "X", m_x); state_add(GTRON_Y, "Y", m_y); state_add(GTRON_IREG, "IREG", m_inReg); + state_add(GTRON_OUTX, "OUTX", m_outx); + state_add(GTRON_OUT, "OUT", m_out); set_icountptr(m_icount); @@ -120,9 +109,27 @@ void gigatron_cpu_device::init() save_item(NAME(m_ppc)); save_item(NAME(m_inReg)); save_item(NAME(m_pc)); + save_item(NAME(m_outx)); + save_item(NAME(m_out)); m_outx_cb.resolve_safe(); + m_out_cb.resolve_safe(); m_ir_cb.resolve_safe(0); + + reset_cpu(); +} + +void gigatron_cpu_device::reset_cpu() +{ + m_ac = 0; + m_x = 0; + m_y = 0; + m_pc = 0; + m_npc = (m_pc + 1) & m_romMask; + m_ppc = 0; + m_inReg = 0xFF; + m_outx = 0; + m_out = 0; } void gigatron_cpu_device::branchOp(uint8_t op, uint8_t mode, uint8_t bus, uint8_t d) @@ -220,6 +227,10 @@ void gigatron_cpu_device::aluOp(uint8_t op, uint8_t mode, uint8_t bus, uint8_t d case 6: case 7: uint16_t rising = ~(m_out & b); + m_out = b; + m_out_cb(0, m_out, 0xFF); + + // rising edge of out[6] registers outx from ac if (rising & 0x40) { m_outx = m_ac; @@ -276,6 +287,9 @@ void gigatron_cpu_device::storeOp(uint8_t op, uint8_t mode, uint8_t bus, uint8_t case 0: b = d; break; + case 1: + b = 0; + break; case 2: b = m_ac; break; @@ -292,7 +306,7 @@ void gigatron_cpu_device::storeOp(uint8_t op, uint8_t mode, uint8_t bus, uint8_t switch (mode) { - case 4: + case 4: // XXX not clear whether x++ mode takes priority m_x = b; break; case 5: @@ -303,6 +317,7 @@ void gigatron_cpu_device::storeOp(uint8_t op, uint8_t mode, uint8_t bus, uint8_t void gigatron_cpu_device::device_reset() { + reset_cpu(); } void gigatron_cpu_device::execute_set_input(int irqline, int state) @@ -323,6 +338,7 @@ gigatron_cpu_device::gigatron_cpu_device(const machine_config &mconfig, const ch , m_program_config("program", ENDIANNESS_BIG, 16, 14, -1) , m_data_config("data", ENDIANNESS_BIG, 8, 15, 0) , m_outx_cb(*this) + , m_out_cb(*this) , m_ir_cb(*this) { } diff --git a/src/devices/cpu/gigatron/gigatron.h b/src/devices/cpu/gigatron/gigatron.h index 50f359af21f..b0dfa150be4 100644 --- a/src/devices/cpu/gigatron/gigatron.h +++ b/src/devices/cpu/gigatron/gigatron.h @@ -16,7 +16,8 @@ enum { GTRON_PC, GTRON_NPC, - GTRON_AC, GTRON_X, GTRON_Y, GTRON_IREG + GTRON_AC, GTRON_X, GTRON_Y, GTRON_IREG, + GTRON_OUTX, GTRON_OUT }; @@ -26,6 +27,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 out_cb() { return m_out_cb.bind(); } auto ir_cb() { return m_ir_cb.bind(); } protected: @@ -48,6 +50,8 @@ protected: // device_memory_interface overrides virtual space_config_vector memory_space_config() const override; + + void reset_cpu(); void branchOp(uint8_t op, uint8_t mode, uint8_t bus, uint8_t d); void aluOp(uint8_t op, uint8_t mode, uint8_t bus, uint8_t d); @@ -63,10 +67,8 @@ protected: uint8_t m_inReg; uint16_t m_ramMask; uint16_t m_romMask; - uint16_t m_out; - uint16_t m_outx; - - virtual void init(); + uint8_t m_out; + uint8_t m_outx; private: address_space_config m_program_config; @@ -81,6 +83,7 @@ private: void gigatron_illegal(); devcb_write8 m_outx_cb; + devcb_write8 m_out_cb; devcb_read8 m_ir_cb; }; diff --git a/src/mame/drivers/gigatron.cpp b/src/mame/drivers/gigatron.cpp index 30590ebc4a2..5ec4714dc1d 100644 --- a/src/mame/drivers/gigatron.cpp +++ b/src/mame/drivers/gigatron.cpp @@ -16,6 +16,8 @@ #include "speaker.h" #define MAIN_CLOCK 6250000 +#define VSYNC 0x80 +#define HSYNC 0x40 class gigatron_state : public driver_device { @@ -36,24 +38,70 @@ private: virtual void machine_start() override; virtual void machine_reset() override; + virtual void video_start() override; void prog_map(address_map &map); void data_map(address_map &map); uint16_t lights_changed; - - uint8_t gigatron_random() - { - return machine().rand() & 0xff; - } + + //Video Generation stuff + uint8_t machineOut; + uint8_t row; + uint8_t col; + uint8_t pixel; void blinkenlights(uint8_t data); + void video_draw(u8 data); uint8_t inputs(); + + std::unique_ptr m_bitmap_render; + std::unique_ptr m_bitmap_buffer; required_device m_maincpu; required_ioport m_io_inputs; }; +void gigatron_state::video_start() +{ + m_bitmap_render = std::make_unique(640, 480); + m_bitmap_buffer = std::make_unique(640, 480); +} + +void gigatron_state::video_draw(u8 data) +{ + uint8_t out = data; + uint8_t falling = machineOut & ~out; + + if (falling & VSYNC) + { + row = 0; + pixel = 0; + } + + if (falling & HSYNC) + { + col = 0; + row++; + } + + machineOut = out; + + if ((out & (VSYNC | HSYNC)) != (VSYNC | HSYNC)) + { + return; + } + + if((row >= 0 && row < 480) && (col >= 0 && col < 640)) + { + //uint16_t *dest; + //uint8_t tPixel = pixel; + //uint8_t r = (out << 6) & 0xC0; + //uint8_t g = (out << 4) & 0xC0; + //uint8_t b = (out << 2) & 0xC0; + } +} + uint32_t gigatron_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { return 0; @@ -106,6 +154,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->out_cb().set(FUNC(gigatron_state::video_draw)); m_maincpu->ir_cb().set(FUNC(gigatron_state::inputs)); /* video hardware */ @@ -120,15 +169,16 @@ void gigatron_state::gigatron(machine_config &config) } ROM_START( gigatron ) - ROM_REGION( 0x20000, "maincpu", 0 ) - ROM_SYSTEM_BIOS(0, "v4", "Gigatron ROM V4") - ROMX_LOAD( "gigrom4.rom", 0x0000, 0x20000, CRC(78995109) SHA1(2395fc48e64099836111f5aeca39ddbf4650ea4e),ROM_BIOS(0)) - ROM_SYSTEM_BIOS(1, "v3", "Gigatron ROM V3") - ROMX_LOAD( "gigrom3.rom", 0x0000, 0x20000, CRC(1536efbe) SHA1(959268069e761a01d620396eedb9abc1ee63c421),ROM_BIOS(1)) - ROM_SYSTEM_BIOS(2, "v2", "Gigatron ROM V2") - ROMX_LOAD( "gigrom2.rom", 0x0000, 0x20000, CRC(b4a3d936) SHA1(c93f417d589144b912c79f85b9e942d66242c2c3),ROM_BIOS(2)) - ROM_SYSTEM_BIOS(3, "v1", "Gigatron ROM V1") - ROMX_LOAD( "gigrom1.rom", 0x0000, 0x20000, CRC(8ea5a2af) SHA1(e5758d5cc467c3476bd8f992fd45dfcdf06d0430),ROM_BIOS(3)) + ROM_SYSTEM_BIOS(0, "v5a", "Gigatron ROM V5a") + ROMX_LOAD( "gigrom5a.rom", 0x0000, 0x20000, CRC(DCC071A6) SHA1(F82059BA0227FF48E4C687B90C8445DA30213EE2),ROM_BIOS(0)) + ROM_SYSTEM_BIOS(1, "v4", "Gigatron ROM V4") + ROMX_LOAD( "gigrom4.rom", 0x0000, 0x20000, CRC(78995109) SHA1(2395fc48e64099836111f5aeca39ddbf4650ea4e),ROM_BIOS(1)) + ROM_SYSTEM_BIOS(2, "v3", "Gigatron ROM V3") + ROMX_LOAD( "gigrom3.rom", 0x0000, 0x20000, CRC(1536efbe) SHA1(959268069e761a01d620396eedb9abc1ee63c421),ROM_BIOS(2)) + ROM_SYSTEM_BIOS(3, "v2", "Gigatron ROM V2") + ROMX_LOAD( "gigrom2.rom", 0x0000, 0x20000, CRC(b4a3d936) SHA1(c93f417d589144b912c79f85b9e942d66242c2c3),ROM_BIOS(3)) + ROM_SYSTEM_BIOS(4, "v1", "Gigatron ROM V1") + ROMX_LOAD( "gigrom1.rom", 0x0000, 0x20000, CRC(8ea5a2af) SHA1(e5758d5cc467c3476bd8f992fd45dfcdf06d0430),ROM_BIOS(4)) ROM_END -COMP(2018, gigatron, 0, 0, gigatron, gigatron, gigatron_state, empty_init, "Marcel van Kervinck", "Gigatron TTL Microcomputer", MACHINE_IS_SKELETON) +COMP(2018, gigatron, 0, 0, gigatron, gigatron, gigatron_state, empty_init, "Marcel van Kervinck / Walter Belgers", "Gigatron TTL Microcomputer", MACHINE_IS_SKELETON)