skeleton/flashvga2.cpp: map i2c EEPROM and Timekeeper

This commit is contained in:
angelosa 2026-05-22 22:22:13 +02:00
parent 45eadf1ded
commit 0e32d6312f

View File

@ -6,7 +6,8 @@
"Flash VGA 2" hardware (from TourVisión?) for video-slots. "Flash VGA 2" hardware (from TourVisión?) for video-slots.
TODO: TODO:
- Currently fails on timekeeper check ("error en reloj"); - Currently fails on timekeeper check ("error en reloj"), does extensive checks in the empty
dump area;
=================================================================================================== ===================================================================================================
@ -55,6 +56,7 @@ TODO:
#include "emu.h" #include "emu.h"
#include "cpu/i86/i186.h" #include "cpu/i86/i186.h"
#include "machine/i2cmem.h"
#include "machine/mc68681.h" #include "machine/mc68681.h"
#include "machine/timekpr.h" #include "machine/timekpr.h"
@ -80,6 +82,7 @@ public:
, m_palette(*this, "palette") , m_palette(*this, "palette")
, m_program_bank(*this, "program_bank") , m_program_bank(*this, "program_bank")
, m_vram(*this, "vram") , m_vram(*this, "vram")
, m_eeprom(*this, "eeprom")
{ } { }
void flashvga2(machine_config &config); void flashvga2(machine_config &config);
@ -97,6 +100,7 @@ private:
required_device<palette_device> m_palette; required_device<palette_device> m_palette;
required_memory_bank m_program_bank; required_memory_bank m_program_bank;
required_shared_ptr<u16> m_vram; required_shared_ptr<u16> m_vram;
required_device<i2c_24c256_device> m_eeprom;
void mem_map(address_map &map); void mem_map(address_map &map);
void io_map(address_map &map); void io_map(address_map &map);
@ -134,25 +138,40 @@ uint32_t flashvga2_state::screen_update(screen_device &screen, bitmap_ind16 &bit
void flashvga2_state::mem_map(address_map &map) void flashvga2_state::mem_map(address_map &map)
{ {
map(0x00000, 0x3ffff).ram(); map(0x00000, 0x30fff).ram();
// TODO: check limits and parallelism (access in 8-bit only?)
map(0x30000, 0x31fff).rw("rtc", FUNC(m48t02_device::read), FUNC(m48t02_device::write)).umask16(0x00ff);
map(0x32000, 0x3ffff).ram();
map(0x40000, 0x7ffff).ram().share("vram"); map(0x40000, 0x7ffff).ram().share("vram");
// TODO: several zero writes in this area (flash ROM side-effect?) // TODO: several zero writes in this area (flash ROM side-effect?)
map(0x80000, 0xbffff).bankr("program_bank"); map(0x80000, 0xbffff).bankr("program_bank").lw16(NAME([this] (offs_t offset, u16 data, u16 mem_mask) {
if (data)
LOG("Warning: write at [%05x] %04x & %04x\n", offset * 2 + 0x80000, data, mem_mask);
}));
map(0xc0000, 0xfffff).rom().region("program_rom", 0x7c0000); map(0xc0000, 0xfffff).rom().region("program_rom", 0x7c0000);
} }
void flashvga2_state::io_map(address_map &map) void flashvga2_state::io_map(address_map &map)
{ {
map(0x2000, 0x201f).rw("uart", FUNC(scn2681_device::read), FUNC(scn2681_device::write)).umask16(0x00ff); map(0x2000, 0x201f).rw("uart", FUNC(scn2681_device::read), FUNC(scn2681_device::write)).umask16(0x00ff);
map(0x2178, 0x2179).portr("IN0"); map(0x2176, 0x2177).nopw();
map(0x217a, 0x217b).portr("IN1"); map(0x2178, 0x2179).portr("IN0").nopw();
map(0x217a, 0x217b).portr("IN1").nopw();
map(0x2180, 0x2180).lw8(NAME([this] (offs_t offset, u8 data) { map(0x2180, 0x2180).lw8(NAME([this] (offs_t offset, u8 data) {
// assumed, currently selects pages 7 and 8 only // assumed, currently selects pages 7 and 8 only
m_program_bank->set_entry(data & 0x1f); m_program_bank->set_entry(data & 0x1f);
if (data & 0xe0) if (data & 0xe0)
LOG("$2180: write %02x\n", data); LOG("$2180: write %02x\n", data);
})); }));
// map(0x2184, 0x2184) i2c style protocol map(0x2184, 0x2184).lrw8(
NAME([this] (offs_t offset) {
return m_eeprom->read_sda();
}),
NAME([this] (offs_t offset, u8 data) {
m_eeprom->write_scl(BIT(data, 1));
m_eeprom->write_sda(BIT(data, 0));
})
);
} }
static INPUT_PORTS_START(ruletamag) static INPUT_PORTS_START(ruletamag)
@ -232,7 +251,9 @@ void flashvga2_state::flashvga2(machine_config &config)
scn2681_device &uart(SCN2681(config, "uart", 3.6864_MHz_XTAL)); // Philips SCC2692AC1A44 scn2681_device &uart(SCN2681(config, "uart", 3.6864_MHz_XTAL)); // Philips SCC2692AC1A44
uart.irq_cb().set_inputline(m_maincpu, INPUT_LINE_NMI); uart.irq_cb().set_inputline(m_maincpu, INPUT_LINE_NMI);
M48T02(config, "m48t18", 0); // ST M48T18-150PC1 M48T02(config, "rtc", 0); // ST M48T18-150PC1
I2C_24C256(config, m_eeprom, 0);
// TODO: refine, is it really 60 Hz? // TODO: refine, is it really 60 Hz?
screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER)); screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
@ -259,14 +280,27 @@ ROM_START( ruletamag )
ROM_LOAD16_BYTE( "m29f032d.u100", 0x000000, 0x400000, CRC(04bf20c2) SHA1(fc4be2c22dc266d6a460aeca257b449be5ab630f) ) ROM_LOAD16_BYTE( "m29f032d.u100", 0x000000, 0x400000, CRC(04bf20c2) SHA1(fc4be2c22dc266d6a460aeca257b449be5ab630f) )
ROM_LOAD16_BYTE( "m29f032d.u101", 0x000001, 0x400000, CRC(2bd85284) SHA1(36f4b918d1d9b57bf382fa940180b3a1aac9780f) ) ROM_LOAD16_BYTE( "m29f032d.u101", 0x000001, 0x400000, CRC(2bd85284) SHA1(36f4b918d1d9b57bf382fa940180b3a1aac9780f) )
ROM_REGION( 0x8000, "seeprom", 0 ) ROM_REGION( 0x8000, "eeprom", 0 )
ROM_LOAD( "m24256bf.u31", 0x000000, 0x008000, CRC(af9adcae) SHA1(ac6274edc4240d5cf397455868009263264ffc6e) ) ROM_LOAD( "m24256bf.u31", 0x000000, 0x008000, CRC(af9adcae) SHA1(ac6274edc4240d5cf397455868009263264ffc6e) )
/* With an unintialized NVRAM/timekeeper, the machine won't work and Will output just a "ERROR EN RELOJ" message. /* With an unintialized NVRAM/timekeeper, the machine won't work and Will output just a "ERROR EN RELOJ" message.
With the included dump (corrupted), it will output the message "ERROR EN MODULO", but still won't boot. With the included dump (corrupted), it will output the message "ERROR EN MODULO", but still won't boot.
Maybe there's a way to initialize the NVRAM, but there's nothing about it on the manual. */ Maybe there's a way to initialize the NVRAM, but there's nothing about it on the manual. */
ROM_REGION( 0x2000, "nvram", 0 ) ROM_REGION( 0x2000, "rtc", 0 )
ROM_LOAD( "m48t18.u38", 0x000000, 0x002000, BAD_DUMP CRC(025fb8c2) SHA1(61c90ecad8565cfd20674034a5917b0225edbfe5) ) // Corrupted ROM_LOAD( "m48t18.u38", 0x000000, 0x002000, BAD_DUMP CRC(025fb8c2) SHA1(61c90ecad8565cfd20674034a5917b0225edbfe5) ) // Corrupted
// patch checks at PC=d3299 onward
ROM_FILL( 0x0044 >> 1, 1, 0x55 )
ROM_FILL( 0x0046 >> 1, 1, 0xaa )
// checksum for 0x48 ~ 0x5c
ROM_FILL( 0x005e >> 1, 1, 0xf4 )
ROM_FILL( 0x0060 >> 1, 1, 0x0b )
// does further checks if this skipped (going back to "error en reloj")
// ROM_FILL( 0x00b0 >> 1, 1, 0x55 )
// ROM_FILL( 0x00b2 >> 1, 1, 0xaa )
// ROM_FILL( 0x0008 >> 1, 1, 0x71 )
// ROM_FILL( 0x000a >> 1, 1, 0xac )
ROM_END ROM_END