mirror of
https://github.com/holub/mame
synced 2025-06-03 19:36:26 +03:00
[NES MESS] Minor cleanups
This commit is contained in:
parent
48a7cee3d0
commit
42b6aa8507
@ -406,20 +406,6 @@ static INPUT_PORTS_START( famicom )
|
||||
INPUT_PORTS_END
|
||||
|
||||
|
||||
#ifdef UNUSED_FUNCTION
|
||||
/* This layout is not changed at runtime */
|
||||
gfx_layout nes_vram_charlayout =
|
||||
{
|
||||
8,8, /* 8*8 characters */
|
||||
512, /* 512 characters */
|
||||
2, /* 2 bits per pixel */
|
||||
{ 8*8, 0 }, /* the two bitplanes are separated */
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7 },
|
||||
{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
|
||||
16*8 /* every char takes 16 consecutive bytes */
|
||||
};
|
||||
#endif
|
||||
|
||||
static const nes_interface nes_apu_interface =
|
||||
{
|
||||
"maincpu"
|
||||
|
@ -1,9 +1,9 @@
|
||||
/*****************************************************************************
|
||||
*
|
||||
* includes/nes.h
|
||||
*
|
||||
* Nintendo Entertainment System (Famicom)
|
||||
*
|
||||
|
||||
nes.h
|
||||
|
||||
Nintendo Entertainment System (Famicom)
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef NES_H_
|
||||
@ -68,6 +68,7 @@ public:
|
||||
void pcb_handlers_setup();
|
||||
int pcb_initialize(int idx);
|
||||
int nes_pcb_reset();
|
||||
void update_prg_banks(int prg_bank_start, int prg_bank_end);
|
||||
|
||||
DECLARE_WRITE8_MEMBER(nes_chr_w);
|
||||
DECLARE_READ8_MEMBER(nes_chr_r);
|
||||
@ -84,13 +85,6 @@ public:
|
||||
read8_delegate m_mmc_read_mid;
|
||||
read8_delegate m_mmc_read;
|
||||
|
||||
/* devices */
|
||||
// cpu_device *m_maincpu;
|
||||
// ppu2c0x_device *m_ppu;
|
||||
// device_t *m_sound;
|
||||
device_t *m_cart;
|
||||
// emu_timer *m_irq_timer;
|
||||
|
||||
/***** FDS-floppy related *****/
|
||||
|
||||
int m_disk_expansion;
|
||||
@ -120,6 +114,7 @@ public:
|
||||
DECLARE_WRITE8_MEMBER(nes_vh_sprite_dma_w);
|
||||
DECLARE_DRIVER_INIT(famicom);
|
||||
virtual void machine_start();
|
||||
virtual void machine_stop();
|
||||
virtual void machine_reset();
|
||||
virtual void video_start();
|
||||
virtual void palette_init();
|
||||
@ -129,6 +124,16 @@ public:
|
||||
DECLARE_READ8_MEMBER(psg_4015_r);
|
||||
DECLARE_WRITE8_MEMBER(psg_4015_w);
|
||||
DECLARE_WRITE8_MEMBER(psg_4017_w);
|
||||
|
||||
private:
|
||||
/* devices */
|
||||
// cpu_device *m_maincpu;
|
||||
// ppu2c0x_device *m_ppu;
|
||||
// device_t *m_sound;
|
||||
device_t *m_cart;
|
||||
// emu_timer *m_irq_timer;
|
||||
ioport_port *m_io_ctrlsel;
|
||||
memory_bank *m_prg_bank_mem[5];
|
||||
};
|
||||
|
||||
/*----------- defined in machine/nes.c -----------*/
|
||||
|
@ -1,3 +1,11 @@
|
||||
/*****************************************************************************
|
||||
|
||||
nes.c
|
||||
|
||||
Nintendo Entertainment System (Famicom)
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
#include "emu.h"
|
||||
#include "crsshair.h"
|
||||
#include "cpu/m6502/m6502.h"
|
||||
@ -23,8 +31,6 @@
|
||||
FUNCTION PROTOTYPES
|
||||
***************************************************************************/
|
||||
|
||||
static void nes_machine_stop(running_machine &machine);
|
||||
|
||||
|
||||
static void fds_irq(device_t *device, int scanline, int vblank, int blanked);
|
||||
|
||||
@ -284,16 +290,26 @@ static void nes_state_register( running_machine &machine )
|
||||
machine.save().register_postload(save_prepost_delegate(FUNC(nes_banks_restore), state));
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// machine_start
|
||||
//-------------------------------------------------
|
||||
|
||||
void nes_state::machine_start()
|
||||
{
|
||||
|
||||
m_ppu = machine().device<ppu2c0x_device>("ppu");
|
||||
init_nes_core();
|
||||
machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(nes_machine_stop),&machine()));
|
||||
|
||||
m_maincpu = machine().device<cpu_device>("maincpu");
|
||||
m_sound = machine().device("nessound");
|
||||
m_cart = machine().device("cart");
|
||||
init_nes_core();
|
||||
|
||||
m_maincpu = machine().device<cpu_device>("maincpu");
|
||||
m_sound = machine().device("nessound");
|
||||
m_cart = machine().device("cart");
|
||||
m_io_ctrlsel = ioport("CTRLSEL");
|
||||
m_prg_bank_mem[0] = membank("bank1");
|
||||
m_prg_bank_mem[1] = membank("bank2");
|
||||
m_prg_bank_mem[2] = membank("bank3");
|
||||
m_prg_bank_mem[3] = membank("bank4");
|
||||
m_prg_bank_mem[4] = membank("bank5");
|
||||
|
||||
// If we're starting famicom with no disk inserted, we still haven't initialized the VRAM needed for
|
||||
// video emulation, so we need to take care of it now
|
||||
@ -312,23 +328,45 @@ void nes_state::machine_start()
|
||||
nes_state_register(machine());
|
||||
}
|
||||
|
||||
static void nes_machine_stop( running_machine &machine )
|
||||
{
|
||||
nes_state *state = machine.driver_data<nes_state>();
|
||||
device_image_interface *image = dynamic_cast<device_image_interface *>(state->m_cart);
|
||||
/* Write out the battery file if necessary */
|
||||
if (state->m_battery)
|
||||
image->battery_save(state->m_battery_ram, state->m_battery_size);
|
||||
|
||||
if (state->m_mapper_bram_size)
|
||||
image->battery_save(state->m_mapper_bram, state->m_mapper_bram_size);
|
||||
//-------------------------------------------------
|
||||
// machine_stop
|
||||
//-------------------------------------------------
|
||||
|
||||
void nes_state::machine_stop()
|
||||
{
|
||||
device_image_interface *image = dynamic_cast<device_image_interface *>(m_cart);
|
||||
/* Write out the battery file if necessary */
|
||||
if (m_battery)
|
||||
image->battery_save(m_battery_ram, m_battery_size);
|
||||
|
||||
if (m_mapper_bram_size)
|
||||
image->battery_save(m_mapper_bram, m_mapper_bram_size);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// update_prg_banks
|
||||
//-------------------------------------------------
|
||||
|
||||
void nes_state::update_prg_banks(int prg_bank_start, int prg_bank_end)
|
||||
{
|
||||
for (int prg_bank = prg_bank_start; prg_bank <= prg_bank_end; prg_bank++)
|
||||
{
|
||||
assert(prg_bank >= 0);
|
||||
assert(prg_bank < ARRAY_LENGTH(m_prg_bank));
|
||||
assert(prg_bank < ARRAY_LENGTH(m_prg_bank_mem));
|
||||
|
||||
m_prg_bank_mem[prg_bank]->set_entry(m_prg_bank[prg_bank]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
READ8_MEMBER(nes_state::nes_IN0_r)
|
||||
{
|
||||
int cfg = ioport("CTRLSEL")->read();
|
||||
int cfg = m_io_ctrlsel->read();
|
||||
int ret;
|
||||
|
||||
if ((cfg & 0x000f) >= 0x08) // for now we treat the FC keyboard separately from other inputs!
|
||||
@ -397,7 +435,7 @@ static UINT8 nes_read_subor_keyboard_line( running_machine &machine, UINT8 scan,
|
||||
|
||||
READ8_MEMBER(nes_state::nes_IN1_r)
|
||||
{
|
||||
int cfg = ioport("CTRLSEL")->read();
|
||||
int cfg = m_io_ctrlsel->read();
|
||||
int ret;
|
||||
|
||||
if ((cfg & 0x000f) == 0x08) // for now we treat the FC keyboard separately from other inputs!
|
||||
@ -525,7 +563,7 @@ static void nes_read_input_device( running_machine &machine, int cfg, nes_input
|
||||
|
||||
TIMER_CALLBACK_MEMBER(nes_state::lightgun_tick)
|
||||
{
|
||||
if ((machine().root_device().ioport("CTRLSEL")->read() & 0x000f) == 0x0002)
|
||||
if ((m_io_ctrlsel->read() & 0x000f) == 0x0002)
|
||||
{
|
||||
/* enable lightpen crosshair */
|
||||
crosshair_set_screen(machine(), 0, CROSSHAIR_SCREEN_ALL);
|
||||
@ -536,7 +574,7 @@ TIMER_CALLBACK_MEMBER(nes_state::lightgun_tick)
|
||||
crosshair_set_screen(machine(), 0, CROSSHAIR_SCREEN_NONE);
|
||||
}
|
||||
|
||||
if ((machine().root_device().ioport("CTRLSEL")->read() & 0x00f0) == 0x0030)
|
||||
if ((m_io_ctrlsel->read() & 0x00f0) == 0x0030)
|
||||
{
|
||||
/* enable lightpen crosshair */
|
||||
crosshair_set_screen(machine(), 1, CROSSHAIR_SCREEN_ALL);
|
||||
@ -550,7 +588,7 @@ TIMER_CALLBACK_MEMBER(nes_state::lightgun_tick)
|
||||
|
||||
WRITE8_MEMBER(nes_state::nes_IN0_w)
|
||||
{
|
||||
int cfg = ioport("CTRLSEL")->read();
|
||||
int cfg = m_io_ctrlsel->read();
|
||||
|
||||
/* Check if lightgun has been chosen as input: if so, enable crosshair */
|
||||
machine().scheduler().timer_set(attotime::zero, timer_expired_delegate(FUNC(nes_state::lightgun_tick),this));
|
||||
|
@ -237,6 +237,8 @@ READ8_MEMBER(nes_state::nes_low_mapper_r)
|
||||
|
||||
void nes_carts_state::wram_bank(int bank, int source)
|
||||
{
|
||||
nes_state *state = machine().driver_data<nes_state>();
|
||||
|
||||
assert(m_battery || m_prg_ram);
|
||||
if (source == NES_BATTERY)
|
||||
{
|
||||
@ -248,16 +250,13 @@ void nes_carts_state::wram_bank(int bank, int source)
|
||||
bank &= (m_wram_size / 0x2000) - 1;
|
||||
m_prg_bank[4] = m_prgram_bank5_start + bank;
|
||||
}
|
||||
membank("bank5")->set_entry(m_prg_bank[4]);
|
||||
state->update_prg_banks(4, 4);
|
||||
}
|
||||
|
||||
INLINE void prg_bank_refresh( running_machine &machine )
|
||||
{
|
||||
nes_state *state = machine.driver_data<nes_state>();
|
||||
state->membank("bank1")->set_entry(state->m_prg_bank[0]);
|
||||
state->membank("bank2")->set_entry(state->m_prg_bank[1]);
|
||||
state->membank("bank3")->set_entry(state->m_prg_bank[2]);
|
||||
state->membank("bank4")->set_entry(state->m_prg_bank[3]);
|
||||
state->update_prg_banks(0, 3);
|
||||
}
|
||||
|
||||
/* PRG ROM in 8K, 16K or 32K blocks */
|
||||
|
Loading…
Reference in New Issue
Block a user