funcube: use memory_share_creator for nvram

This commit is contained in:
hap 2024-03-02 23:11:38 +01:00
parent 03d3b6f199
commit 780764ae7a
3 changed files with 49 additions and 69 deletions

View File

@ -113,9 +113,9 @@ funcube series:
void seta2_state::machine_start()
{
if (memregion( "x1snd" ) != nullptr)
if (memregion("x1snd") != nullptr)
{
uint32_t const max = memregion( "x1snd" )->bytes() / 0x20000;
uint32_t const max = memregion("x1snd")->bytes() / 0x20000;
for (int i = 0; i < 8; i++)
{
if (m_x1_bank[i] != nullptr)
@ -123,7 +123,7 @@ void seta2_state::machine_start()
uint32_t ind = 0;
while (ind < 256)
{
m_x1_bank[i]->configure_entries(ind, max, memregion( "x1snd" )->base(), 0x20000); // TODO : Mirrored?
m_x1_bank[i]->configure_entries(ind, max, memregion("x1snd")->base(), 0x20000); // TODO : Mirrored?
ind += max;
}
}
@ -161,7 +161,7 @@ void seta2_state::grdians_lockout_w(uint8_t data)
// initially 0, then either $25 (coin 1) or $2a (coin 2)
machine().bookkeeping().coin_counter_w(0,data & 0x01); // or 0x04
machine().bookkeeping().coin_counter_w(1,data & 0x02); // or 0x08
// popmessage("%04X", data & 0xff);
//popmessage("%04X", data & 0xff);
}
void seta2_state::grdians_map(address_map &map)
@ -430,7 +430,7 @@ void seta2_state::reelquak_leds_w(offs_t offset, uint16_t data, uint16_t mem_mas
m_dispenser->motor_w(BIT(data, 8)); // ticket dispenser
}
// popmessage("LED %04X", data);
//popmessage("LED %04X", data);
}
void seta2_state::reelquak_coin_w(uint8_t data)
@ -439,9 +439,9 @@ void seta2_state::reelquak_coin_w(uint8_t data)
machine().bookkeeping().coin_counter_w(1, data & 0x02); // coin in
machine().bookkeeping().coin_counter_w(2, data & 0x04); // pay out
machine().bookkeeping().coin_counter_w(3, data & 0x08); // key in
// data & 0x10); // Sound IRQ Ack.? 1->0
// data & 0x20); // Vblank IRQ.? 1
// popmessage("COIN %04X", data & 0xff);
// data & 0x10); // Sound IRQ Ack.? 1->0
// data & 0x20); // Vblank IRQ.? 1
//popmessage("COIN %04X", data & 0xff);
}
void seta2_state::reelquak_map(address_map &map)
@ -486,10 +486,11 @@ void seta2_state::samshoot_coin_w(uint8_t data)
{
machine().bookkeeping().coin_counter_w(0, data & 0x10);
machine().bookkeeping().coin_counter_w(1, data & 0x20);
// Are these connected? They are set in I/O test
machine().bookkeeping().coin_lockout_w(0,~data & 0x40);
machine().bookkeeping().coin_lockout_w(1,~data & 0x80);
// popmessage("%04x",data);
//popmessage("%04x",data);
}
void seta2_state::samshoot_map(address_map &map)
@ -528,35 +529,35 @@ void seta2_state::samshoot_map(address_map &map)
void staraudi_state::staraudi_debug_outputs()
{
// popmessage("L1: %04X L2: %04X CAM: %04X", m_lamps1, m_lamps2, m_cam);
//popmessage("L1: %04X L2: %04X CAM: %04X", m_lamps1, m_lamps2, m_cam);
}
void staraudi_state::lamps1_w(offs_t offset, uint8_t data, uint8_t mem_mask)
{
COMBINE_DATA(&m_lamps1);
m_leds[0] = BIT(data, 0); // Lamp 1 |
m_leds[1] = BIT(data, 1); // Lamp 2 |- Camera Lamps
m_leds[2] = BIT(data, 2); // Lamp 3 |
// data & 0x08 ); // Degauss
m_leds[0] = BIT(data, 0); // Lamp 1 |
m_leds[1] = BIT(data, 1); // Lamp 2 |- Camera Lamps
m_leds[2] = BIT(data, 2); // Lamp 3 |
// data & 0x08 ); // Degauss
staraudi_debug_outputs();
}
void staraudi_state::lamps2_w(offs_t offset, uint8_t data, uint8_t mem_mask)
{
COMBINE_DATA(&m_lamps2);
// data & 0x20 ); // ? Always On
m_leds[3] = BIT(data, 6); // 2P Switch Lamp
m_leds[4] = BIT(data, 7); // 1P Switch Lamp
// data & 0x20 ); // ? Always On
m_leds[3] = BIT(data, 6); // 2P Switch Lamp
m_leds[4] = BIT(data, 7); // 1P Switch Lamp
staraudi_debug_outputs();
}
void staraudi_state::camera_w(offs_t offset, uint8_t data, uint8_t mem_mask)
{
COMBINE_DATA(&m_cam);
// data & 0x01 ); // ? Always On
// data & 0x02 ); // ? Print Test
// data & 0x08 ); // Camera On (Test Mode)
// data & 0x20 ); // ?
// data & 0x01 ); // ? Always On
// data & 0x02 ); // ? Print Test
// data & 0x08 ); // Camera On (Test Mode)
// data & 0x20 ); // ?
staraudi_debug_outputs();
}
@ -622,7 +623,7 @@ void seta2_state::telpacfl_lamp1_w(uint8_t data)
for (int i = 0; i <= 7; i++)
m_lamps[i] = BIT(data, i);
// popmessage("LAMP1 %04X", data);
//popmessage("LAMP1 %04X", data);
}
void seta2_state::telpacfl_lamp2_w(uint8_t data)
@ -630,11 +631,11 @@ void seta2_state::telpacfl_lamp2_w(uint8_t data)
m_lamps[8] = BIT(data, 0); // on/off lamp (throughout)
m_lamps[9] = BIT(data, 1); // bet lamp
m_lamps[10] = BIT(data, 2); // payout lamp
m_dispenser->motor_w( data & 0x08 ); // coin out motor
machine().bookkeeping().coin_counter_w(0, data & 0x10); // coin out counter
// data & 0x20 ); // on credit increase
m_dispenser->motor_w(data & 0x08); // coin out motor
machine().bookkeeping().coin_counter_w(0, data & 0x10); // coin out counter
// data & 0x20 ); // on credit increase
// popmessage("LAMP2 %04X", data);
//popmessage("LAMP2 %04X", data);
}
void seta2_state::telpacfl_lockout_w(uint8_t data)
@ -644,7 +645,7 @@ void seta2_state::telpacfl_lockout_w(uint8_t data)
machine().bookkeeping().coin_lockout_w(1, ~data & 0x08); // 100yen blocker
// bits 0x30 ?
// popmessage("LOCK %04X", data);
//popmessage("LOCK %04X", data);
}
void seta2_state::telpacfl_map(address_map &map)
@ -757,7 +758,8 @@ void funcube_touchscreen_device::device_reset()
TIMER_CALLBACK_MEMBER(funcube_touchscreen_device::read_buttons)
{
uint8_t button_state = m_btn->read();
if(m_button_state != button_state) {
if (m_button_state != button_state)
{
m_button_state = button_state;
m_serial[0] = button_state ? 0xfe : 0xfd;
m_serial[1] = m_x->read();
@ -770,7 +772,7 @@ TIMER_CALLBACK_MEMBER(funcube_touchscreen_device::read_buttons)
void funcube_touchscreen_device::tra_complete()
{
if(m_serial_pos != 4)
if (m_serial_pos != 4)
transmit_register_setup(m_serial[m_serial_pos++]);
}
@ -780,30 +782,8 @@ void funcube_touchscreen_device::tra_callback()
}
// Bus conversion functions:
// RAM shared with the sub CPU
uint32_t funcube_state::nvram_r(offs_t offset)
{
uint16_t val = m_nvram[offset];
return ((val & 0xff00) << 8) | (val & 0x00ff);
}
void funcube_state::nvram_w(offs_t offset, uint32_t data, uint32_t mem_mask)
{
if (ACCESSING_BITS_0_7)
{
m_nvram[offset] = (m_nvram[offset] & 0xff00) | (data & 0x000000ff);
}
if (ACCESSING_BITS_16_23)
{
m_nvram[offset] = (m_nvram[offset] & 0x00ff) | ((data & 0x00ff0000) >> 8);
}
}
// Main CPU
uint32_t funcube_state::debug_r()
{
uint32_t ret = ioport("DEBUG")->read();
@ -830,7 +810,7 @@ void funcube_state::funcube_map(address_map &map)
map(0x00840000, 0x0084ffff).ram().w(m_palette, FUNC(palette_device::write32)).share("palette"); // Palette
map(0x00860000, 0x0086003f).rw(FUNC(funcube_state::vregs_r), FUNC(funcube_state::vregs_w));
map(0x00c00000, 0x00c002ff).rw(FUNC(funcube_state::nvram_r), FUNC(funcube_state::nvram_w));
map(0x00c00000, 0x00c002ff).rw(FUNC(funcube_state::nvram_r), FUNC(funcube_state::nvram_w)).umask32(0x00ff00ff);
map(0xf0000000, 0xf00001ff).rw("maincpu_onboard", FUNC(mcf5206e_peripheral_device::seta2_coldfire_regs_r), FUNC(mcf5206e_peripheral_device::seta2_coldfire_regs_w)); // technically this can be moved with MBAR
map(0xffffe000, 0xffffffff).ram(); // SRAM
@ -851,7 +831,7 @@ void funcube_state::funcube2_map(address_map &map)
map(0x00840000, 0x0084ffff).ram().w(m_palette, FUNC(palette_device::write32)).share("palette");
map(0x00860000, 0x0086003f).rw(FUNC(funcube_state::vregs_r), FUNC(funcube_state::vregs_w));
map(0x00c00000, 0x00c002ff).rw(FUNC(funcube_state::nvram_r), FUNC(funcube_state::nvram_w));
map(0x00c00000, 0x00c002ff).rw(FUNC(funcube_state::nvram_r), FUNC(funcube_state::nvram_w)).umask32(0x00ff00ff);
map(0xf0000000, 0xf00001ff).rw("maincpu_onboard", FUNC(mcf5206e_peripheral_device::seta2_coldfire_regs_r), FUNC(mcf5206e_peripheral_device::seta2_coldfire_regs_w)); // technically this can be moved with MBAR
map(0xffffe000, 0xffffffff).ram(); // SRAM
@ -862,7 +842,7 @@ void funcube_state::funcube2_map(address_map &map)
void funcube_state::funcube_sub_map(address_map &map)
{
map(0x000000, 0x01ffff).rom();
map(0x200000, 0x20017f).ram().share("nvram");
map(0x200000, 0x20017f).rw(FUNC(funcube_state::nvram_r), FUNC(funcube_state::nvram_w)).umask16(0xffff);
}
@ -875,20 +855,20 @@ void funcube_state::funcube_sub_map(address_map &map)
uint16_t funcube_state::coins_r()
{
uint8_t ret = ioport("SWITCH")->read();
uint8_t coin_bit0 = 1; // active low
uint8_t coin_bit0 = 1; // active low
uint8_t coin_bit1 = 1;
uint8_t hopper_bit = (m_hopper_motor && !(m_screen->frame_number()%20)) ? 1 : 0;
uint8_t hopper_bit = (m_hopper_motor && !(m_screen->frame_number() % 20)) ? 1 : 0;
const uint64_t coin_total_cycles = FUNCUBE_SUB_CPU_CLOCK.value() / (1000/10);
if ( m_coin_start_cycles )
if (m_coin_start_cycles)
{
uint64_t elapsed = m_sub->total_cycles() - m_coin_start_cycles;
if ( elapsed < coin_total_cycles/2 )
if (elapsed < coin_total_cycles/2)
coin_bit0 = 0;
else if ( elapsed < coin_total_cycles )
else if (elapsed < coin_total_cycles)
coin_bit1 = 0;
else
m_coin_start_cycles = 0;
@ -904,9 +884,7 @@ uint16_t funcube_state::coins_r()
void funcube_state::funcube_debug_outputs()
{
#ifdef MAME_DEBUG
// popmessage("LED: %02x OUT: %02x", m_funcube_leds, m_outputs);
#endif
//popmessage("LED: %02x OUT: %02x", m_funcube_leds, m_outputs);
}
void funcube_state::leds_w(uint16_t data)

View File

@ -35,7 +35,6 @@ public:
m_dispenser(*this, "dispenser"),
m_x1_bank(*this, "x1_bank_%u", 1U),
m_nvram(*this, "nvram"),
m_spriteram(*this, "spriteram", 0x40000, ENDIANNESS_BIG),
m_tileram(*this, "tileram"),
m_vregs(*this, "vregs", 0x40, ENDIANNESS_BIG),
@ -127,7 +126,6 @@ protected:
optional_device<ticket_dispenser_device> m_dispenser;
optional_memory_bank_array<8> m_x1_bank;
optional_shared_ptr<uint16_t> m_nvram;
memory_share_creator<uint16_t> m_spriteram;
optional_shared_ptr<uint16_t> m_tileram;
memory_share_creator<uint16_t> m_vregs;
@ -168,6 +166,7 @@ class funcube_state : public seta2_state
public:
funcube_state(const machine_config &mconfig, device_type type, const char *tag)
: seta2_state(mconfig, type, tag)
, m_nvram(*this, "nvram", 0x180, ENDIANNESS_BIG)
{ }
void funcube(machine_config &config);
@ -179,11 +178,14 @@ public:
void init_funcube2();
private:
memory_share_creator<uint8_t> m_nvram;
virtual void machine_start() override;
virtual void machine_reset() override;
uint32_t nvram_r(offs_t offset);
void nvram_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
uint8_t nvram_r(offs_t offset) { return m_nvram[offset]; }
void nvram_w(offs_t offset, uint8_t data) { m_nvram[offset] = data; }
uint32_t debug_r();
uint16_t coins_r();
void leds_w(uint16_t data);

View File

@ -565,7 +565,7 @@ void seta2_state::draw_sprites_line(bitmap_ind16 &bitmap, const rectangle &clipr
if (nozoom_fixedpalette_fixedposition)
{
use_shadow = 0;
// which_gfx = 4 << 8;
//which_gfx = 4 << 8;
usedscanline = realscanline; // no zooming?
usedxzoom = 0x10000;
usedxoffset = 0;
@ -854,7 +854,7 @@ void seta2_state::draw_sprites(bitmap_ind16& bitmap, const rectangle& cliprect)
yy &= 0x07ffffff;
yy >>= 16;
// printf("line %04x yline requested %04x\n", y, yy);
//printf("line %04x yline requested %04x\n", y, yy);
if (yy & 0x400)
yy -= 0x800;
@ -899,7 +899,7 @@ uint32_t seta2_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap,
// Black or pen 0?
bitmap.fill(m_palette->pen(0), cliprect);
if ( (m_vregs[0x30/2] & 1) == 0 ) // 1 = BLANK SCREEN
if ((m_vregs[0x30/2] & 1) == 0) // 1 = BLANK SCREEN
draw_sprites(bitmap, cliprect);
return 0;