leapfrog: Less redundancy in source file names.

Also edited a pile of copy/pasted comments and made some minor code
cleanups (reducing variable scope, etc.).
This commit is contained in:
Vas Crabb 2023-04-02 01:09:38 +11:00
parent ba2a6b30c3
commit aeccf9e813
29 changed files with 83 additions and 89 deletions

View File

@ -52,10 +52,10 @@ public:
void io_w(offs_t offset, u8 data);
protected:
// device-level overrides
// device_t implementation
virtual void device_start() override;
// image-level overrides
// device_image_interface implementation
virtual std::error_condition call_load() override;
virtual void call_unload() override { }
@ -63,7 +63,7 @@ protected:
virtual const char *image_interface() const noexcept override { return "sdk85_rom"; }
virtual const char *file_extensions() const noexcept override { return "bin"; }
// slot interface overrides
// device_slot_interface implementation
virtual std::string get_default_card_software(get_default_card_software_hook &hook) const override;
private:

View File

@ -69,7 +69,7 @@ public:
vc4000_cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
virtual ~vc4000_cart_slot_device();
// image-level overrides
// device_image_interface implementation
virtual std::error_condition call_load() override;
virtual void call_unload() override { }
@ -77,7 +77,7 @@ public:
virtual const char *image_interface() const noexcept override { return "vc4000_cart"; }
virtual const char *file_extensions() const noexcept override { return "bin,rom"; }
// slot interface overrides
// device_slot_interface implementation
virtual std::string get_default_card_software(get_default_card_software_hook &hook) const override;
int get_type() { return m_type; }
@ -98,7 +98,7 @@ protected:
device_t *owner,
uint32_t clock);
// device-level overrides
// device_t implementation
virtual void device_start() override;
int m_type;

View File

@ -23,7 +23,7 @@ public:
// Construction
hp_dc100_tape_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
// device_image_interface overrides
// device_image_interface implementation
virtual std::error_condition call_load() override;
virtual std::error_condition call_create(int format_type, util::option_resolution *format_options) override;
virtual void call_unload() override;
@ -100,7 +100,7 @@ public:
auto wr_bit() { return m_wr_bit_handler.bind(); }
protected:
// device-level overrides
// device_t implementation
virtual void device_start() override;
virtual void device_reset() override;

View File

@ -40,7 +40,7 @@ menu_control_floppy_image::~menu_control_floppy_image()
void menu_control_floppy_image::do_load_create()
{
if(input_filename.compare("")==0) {
if(input_filename.empty()) {
std::error_condition err = fd.create(output_filename, nullptr, nullptr);
if (err) {
machine().popmessage("Error: %s", err.message());
@ -56,7 +56,7 @@ void menu_control_floppy_image::do_load_create()
}
} else {
std::error_condition err = fd.load(input_filename);
if (!err && (output_filename.compare("") != 0))
if (!err && !output_filename.empty()) {
err = fd.reopen_for_write(output_filename);
if (err) {
machine().popmessage("Error: %s", err.message());

View File

@ -151,13 +151,7 @@ ROM_END
QUICKLOAD_LOAD_MEMBER(lynx_state::quickload_cb)
{
address_space &space = m_maincpu->space(AS_PROGRAM);
std::vector<u8> data;
u8 *rom = memregion("maincpu")->base();
u8 header[10]; // 80 08 dw Start dw Len B S 9 3
uint16_t start, length;
int i;
if (image.fread( header, sizeof(header)) != sizeof(header))
return image_error::UNSPECIFIED;
@ -169,21 +163,22 @@ QUICKLOAD_LOAD_MEMBER(lynx_state::quickload_cb)
return err;
}
start = header[3] | (header[2]<<8); //! big endian format in file format for little endian cpu
length = header[5] | (header[4]<<8);
length -= 10;
uint16_t const start = header[3] | (header[2]<<8); //! big endian format in file format for little endian cpu
uint16_t const length = (header[5] | (header[4]<<8)) - 10;
std::vector<u8> data;
data.resize(length);
if (image.fread( &data[0], length) != length)
if (image.fread(&data[0], length) != length)
{
osd_printf_error("%s: Invalid length in file header\n", image.basename());
return image_error::INVALIDIMAGE;
}
for (i = 0; i < length; i++)
address_space &space = m_maincpu->space(AS_PROGRAM);
for (int i = 0; i < length; i++)
space.write_byte(start + i, data[i]);
u8 *rom = memregion("maincpu")->base();
rom[0x1fc] = start & 0xff;
rom[0x1fd] = start >> 8;
space.write_byte(0x1fc, start & 0xff);

View File

@ -183,12 +183,11 @@ QUICKLOAD_LOAD_MEMBER(binbug_state::quickload_cb)
int i;
int quick_addr = 0x440;
int exec_addr;
int quick_length;
std::vector<u8> quick_data;
int read_;
std::error_condition result = image_error::UNSPECIFIED;
quick_length = image.length();
int const quick_length = image.length();
if (quick_length < 0x0444)
{
result = image_error::INVALIDLENGTH;

View File

@ -342,11 +342,9 @@ void d6800_state::machine_reset()
QUICKLOAD_LOAD_MEMBER(d6800_state::quickload_cb)
{
address_space &space = m_maincpu->space(AS_PROGRAM);
u8 ch;
u16 quick_addr = 0x200;
u16 exec_addr = 0xc000;
u32 quick_length = image.length();
constexpr u16 QUICK_ADDR = 0x200;
u32 const quick_length = image.length();
if (quick_length > 0xe00)
{
osd_printf_error("%s: File exceeds 3854 bytes\n", image.basename());
@ -354,17 +352,20 @@ QUICKLOAD_LOAD_MEMBER(d6800_state::quickload_cb)
return image_error::INVALIDIMAGE;
}
address_space &space = m_maincpu->space(AS_PROGRAM);
for (u32 i = 0; i < quick_length; i++)
{
u8 ch;
image.fread(&ch, 1);
space.write_byte(i + quick_addr, ch);
space.write_byte(i + QUICK_ADDR, ch);
}
u16 exec_addr = 0xc000;
if (image.is_filetype("bin"))
exec_addr = quick_addr;
exec_addr = QUICK_ADDR;
/* display a message about the loaded quickload */
image.message(" Quickload: size=%04X : start=%04X : end=%04X : exec=%04X",quick_length,quick_addr,quick_addr+quick_length,exec_addr);
// display a message about the loaded quickload
image.message(" Quickload: size=%04X : start=%04X : end=%04X : exec=%04X", quick_length, QUICK_ADDR, QUICK_ADDR+quick_length, exec_addr);
// Start the quickload
m_maincpu->set_pc(exec_addr);

View File

@ -321,12 +321,11 @@ QUICKLOAD_LOAD_MEMBER(eti660_state::quickload_cb)
int quick_addr = 0x600;
int quick_length;
std::vector<u8> quick_data;
int read_;
std::error_condition result = image_error::UNSPECIFIED;
quick_length = image.length();
quick_data.resize(quick_length);
read_ = image.fread( &quick_data[0], quick_length);
int const read_ = image.fread( &quick_data[0], quick_length);
if (read_ != quick_length)
{
result = image_error::INVALIDIMAGE;

View File

@ -154,12 +154,11 @@ QUICKLOAD_LOAD_MEMBER(pipbug_state::quickload_cb)
int i;
int quick_addr = 0x440;
int exec_addr;
int quick_length;
std::vector<u8> quick_data;
int read_;
std::error_condition result = image_error::UNSPECIFIED;
quick_length = image.length();
int const quick_length = image.length();
if (quick_length < 0x0444)
{
result = image_error::INVALIDLENGTH;

View File

@ -29,14 +29,13 @@ std::error_condition apexc_cylinder_image_device::call_load()
/* load RAM contents */
m_writable = !is_readonly();
fread( machine().root_device().memshare("maincpu")->ptr(), 0x1000);
fread(machine().root_device().memshare("maincpu")->ptr(), 0x1000);
#ifdef LSB_FIRST
{ /* fix endianness */
uint32_t *RAM = (uint32_t *)(machine().root_device().memshare("maincpu")->ptr());
/* fix endianness */
auto const RAM = reinterpret_cast<uint32_t *>(machine().root_device().memshare("maincpu")->ptr());
for (int i=0; i < 0x0400; i++)
RAM[i] = big_endianize_int32(RAM[i]);
}
for (int i=0; i < 0x0400; i++)
RAM[i] = big_endianize_int32(RAM[i]);
#endif
return std::error_condition();

View File

@ -172,10 +172,6 @@ private:
SNAPSHOT_LOAD_MEMBER(ace_state::snapshot_cb)
{
std::vector<uint8_t> RAM(0x10000);
cpu_device *cpu = m_maincpu;
address_space &space = cpu->space(AS_PROGRAM);
unsigned char ace_repeat, ace_byte;
u16 ace_index=0x2000;
bool done = false;
@ -187,9 +183,11 @@ SNAPSHOT_LOAD_MEMBER(ace_state::snapshot_cb)
}
logerror("Loading file %s.\r\n", image.filename());
std::vector<uint8_t> RAM(0x10000);
while (!done && (ace_index < 0x8001))
{
image.fread( &ace_byte, 1);
unsigned char ace_repeat, ace_byte;
image.fread(&ace_byte, 1);
if (ace_byte == 0xed)
{
image.fread(&ace_byte, 1);
@ -223,15 +221,16 @@ SNAPSHOT_LOAD_MEMBER(ace_state::snapshot_cb)
return image_error::INVALIDIMAGE;
}
// patch CPU registers
// Some games do not follow the standard, and have rubbish in the CPU area. So,
// we check that some other bytes are correct.
// 2080 = memory size of original machine, should be 0000 or 8000 or C000.
// 2118 = new stack pointer, do not use if between 8000 and FF00.
// patch CPU registers
// Some games do not follow the standard, and have rubbish in the CPU area. So,
// we check that some other bytes are correct.
// 2080 = memory size of original machine, should be 0000 or 8000 or C000.
// 2118 = new stack pointer, do not use if between 8000 and FF00.
ace_index = RAM[0x2080] | (RAM[0x2081] << 8);
if ((ace_index & 0x3FFF)==0)
cpu_device *cpu = m_maincpu;
if ((ace_index & 0x3fff) == 0)
{
cpu->set_state_int(Z80_AF, RAM[0x2100] | (RAM[0x2101] << 8));
cpu->set_state_int(Z80_BC, RAM[0x2104] | (RAM[0x2105] << 8));
@ -254,7 +253,8 @@ SNAPSHOT_LOAD_MEMBER(ace_state::snapshot_cb)
cpu->set_state_int(Z80_SP, RAM[0x2118] | (RAM[0x2119] << 8));
}
/* Copy data to the address space */
// Copy data to the address space
address_space &space = cpu->space(AS_PROGRAM);
for (ace_index = 0x2000; ace_index < 0x8000; ace_index++)
space.write_byte(ace_index, RAM[ace_index]);

View File

@ -514,7 +514,7 @@ std::error_condition force68k_state::force68k_load_cart(device_image_interface &
{
uint32_t size = slot->common_get_size("rom");
if (size > 0x20000) // Max 128Kb
if (size > 0x2'0000) // Max 128Kb
{
LOG("Cartridge size exceeding max size (128Kb): %d\n", size);
osd_printf_error("%s: Cartridge size exceeding max size (128Kb)\n", image.basename());

View File

@ -1920,7 +1920,7 @@ DEVICE_IMAGE_LOAD_MEMBER(supracan_state::cart_load)
{
uint32_t size = m_cart->common_get_size("rom");
if (size > 0x400000)
if (size > 0x40'0000)
{
osd_printf_error("%s: Unsupported cartridge size\n", image.basename());
return image_error::INVALIDLENGTH;

View File

@ -256,7 +256,7 @@ DEVICE_IMAGE_LOAD_MEMBER(gameking_state::cart_load)
{
uint32_t size = m_cart->common_get_size("rom");
if (size > 0x100000)
if (size > 0x10'0000)
{
osd_printf_error("%s: Unsupported cartridge size\n", image.basename());
return image_error::INVALIDLENGTH;

View File

@ -27,20 +27,23 @@ Rom banking (in U bank):
****************************************************************************/
#include "emu.h"
#include "cpu/s2650/s2650.h"
#include "imagedev/cassette.h"
#include "imagedev/snapquik.h"
#include "machine/keyboard.h"
#include "sound/spkrdev.h"
#include "emupal.h"
#include "screen.h"
#include "speaker.h"
#define VERBOSE 1
#include "logmacro.h"
namespace {
#define LOG 1
class phunsy_state : public driver_device
{
public:
@ -119,8 +122,7 @@ void phunsy_state::phunsy_data(address_map &map)
void phunsy_state::phunsy_ctrl_w(uint8_t data)
{
if (LOG)
logerror("%s: phunsy_ctrl_w %02x\n", machine().describe_context(), data);
LOG("%s: phunsy_ctrl_w %02x\n", machine().describe_context(), data);
// Q-bank
membank("bankq")->set_entry(data & 15);
@ -135,8 +137,7 @@ void phunsy_state::phunsy_ctrl_w(uint8_t data)
void phunsy_state::phunsy_data_w(uint8_t data)
{
if (LOG)
logerror("%s: phunsy_data_w %02x\n", machine().describe_context(), data);
LOG("%s: phunsy_data_w %02x\n", machine().describe_context(), data);
m_data_out = data;
@ -162,8 +163,7 @@ uint8_t phunsy_state::phunsy_data_r()
{
uint8_t data = 0xff;
//if (LOG)
//logerror("%s: phunsy_data_r\n", machine().describe_context());
//LOG("%s: phunsy_data_r\n", machine().describe_context());
if ( m_data_out & 0x02 )
{
@ -290,7 +290,7 @@ QUICKLOAD_LOAD_MEMBER(phunsy_state::quickload_cb)
uint16_t quick_addr = 0x1800;
std::vector<uint8_t> quick_data;
std::error_condition result = image_error::UNSPECIFIED;
int quick_length = image.length();
int const quick_length = image.length();
if (quick_length > 0x4000)
{
result = image_error::INVALIDLENGTH;

View File

@ -316,12 +316,11 @@ QUICKLOAD_LOAD_MEMBER(ravens_base::quickload_cb)
int i;
int quick_addr = 0x900;
int exec_addr;
int quick_length;
std::vector<u8> quick_data;
int read_;
std::error_condition result = image_error::UNSPECIFIED;
quick_length = image.length();
int const quick_length = image.length();
if (quick_length < 0x0900)
{
result = image_error::INVALIDLENGTH;

View File

@ -732,7 +732,7 @@ QUICKLOAD_LOAD_MEMBER(homelab_state::quickload_cb)
for (i = 0; i < quick_length; i++)
{
int j = (quick_addr + i);
unsigned j = (quick_addr + i);
if (image.fread(&ch, 1) != 1)
{
osd_printf_error("%s: Unexpected EOF while writing byte to %04X\n", image.basename(), j);

View File

@ -34,7 +34,7 @@ public:
uint8_t poll_r () const;
protected:
// device-level overrides
// device_t implementation
virtual void device_add_mconfig(machine_config &config) override;
virtual void device_start() override;
virtual void device_reset() override;

View File

@ -34,7 +34,7 @@ public:
m_max_size = max_size;
}
// image-level overrides
// device_image_interface implementation
virtual bool is_readable() const noexcept override { return true; }
virtual bool is_writeable() const noexcept override { return true; }
virtual bool is_creatable() const noexcept override { return true; }
@ -52,7 +52,7 @@ public:
uint8_t *port_data() const { return m_port_data.get(); }
protected:
// device-level overrides
// device_t implementation
virtual void device_start() override;
private:

View File

@ -34,10 +34,10 @@ public:
void install_read_handler(address_space& space);
protected:
// device-level overrides
// device_t implementation
virtual void device_start() override;
// image-level overrides
// device_image_interface implementation
virtual std::error_condition call_load() override;
virtual void call_unload() override;

View File

@ -29,11 +29,11 @@ public:
void install_rw_handlers(address_space *space_r , address_space *space_w);
protected:
// device-level overrides
// device_t implementation
virtual void device_add_mconfig(machine_config &config) override;
virtual void device_start() override;
// image-level overrides
// device_image_interface implementation
virtual std::error_condition call_load() override;
virtual void call_unload() override;

View File

@ -19,15 +19,15 @@ class hp9845_optrom_device : public device_t,
public device_rom_image_interface
{
public:
// construction/destruction
// construction/destruction
hp9845_optrom_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
virtual ~hp9845_optrom_device();
protected:
// device-level overrides
// device_t implementation
virtual void device_start() override;
// image-level overrides
// device_rom_image_interface implementation
virtual std::error_condition call_load() override;
virtual void call_unload() override;

View File

@ -31,10 +31,10 @@ public:
void install_read_handler(address_space& space);
protected:
// device-level overrides
// device_t implementation
virtual void device_start() override;
// image-level overrides
// device_image_interface implementation
virtual std::error_condition call_load() override;
virtual void call_unload() override;

View File

@ -36,8 +36,6 @@ public:
virtual void call_unload() override;
virtual std::error_condition call_create(int format_type, util::option_resolution *format_options) override;
// device-level overrides
virtual void device_start() override;
u8 read(offs_t offset);
void write(offs_t offset, u8 data);
@ -49,7 +47,11 @@ public:
/* returns the index of the current memory card, or -1 if none */
int present() { return is_loaded() ? 0 : -1; }
private:
// device_t implementation
virtual void device_start() override;
u8 m_memcard_data[0x100];
u8 m_protection_data[4];
u8 m_security_data[4];

View File

@ -732,6 +732,7 @@ void rex6000_state::rex6000_palettte(palette_device &palette) const
QUICKLOAD_LOAD_MEMBER(rex6000_state::quickload_rex6000)
{
// FIXME: this suffers buffer overruns on excessively short images and various kinds of invalid images
static const char magic[] = "ApplicationName:Addin";
uint32_t img_start = 0;

View File

@ -24372,7 +24372,7 @@ tandy102 //
tandy200 //
trsm100 //
@source:leapfrog/leapfrog_iquest.cpp
@source:leapfrog/iquest.cpp
iquest
ttwistfb
ttwistbq
@ -24381,20 +24381,20 @@ ttwistsp
ttwistvc
turboex
@source:leapfrog/leapfrog_leappad.cpp
@source:leapfrog/leappad.cpp
leappad // (c) 2001 LeapFrog / Knowledge Kids Enterprises, Inc.
mfleappad // (c) 2002 LeapFrog
ltleappad // (c) 2005 LeapFrog
@source:leapfrog/leapfrog_leapster_explorer.cpp
leapexpr
@source:leapfrog/leapster.cpp
leapster //
leapster2 //
leapsterlmx //
leapstertv //
@source:leapfrog/leapster_explorer.cpp
leapexpr
@source:learsiegler/adm11.cpp
adm12 //