diff options
Diffstat (limited to 'src')
125 files changed, 2980 insertions, 2124 deletions
diff --git a/src/devices/bus/isa/trident.cpp b/src/devices/bus/isa/trident.cpp index 85b83d968cc..b97f35abc78 100644 --- a/src/devices/bus/isa/trident.cpp +++ b/src/devices/bus/isa/trident.cpp @@ -12,18 +12,31 @@ #include "trident.h" #include "debugger.h" -const device_type TRIDENT_VGA = &device_creator<trident_vga_device>; +const device_type TRIDENT_VGA = &device_creator<tgui9860_device>; +const device_type TVGA9000_VGA = &device_creator<tvga9000_device>; #define CRTC_PORT_ADDR ((vga.miscellaneous_output&1)?0x3d0:0x3b0) #define LOG (1) #define LOG_ACCEL (1) -trident_vga_device::trident_vga_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : svga_device(mconfig, TRIDENT_VGA, "Trident TGUI9680", tag, owner, clock, "trident_vga", __FILE__) +trident_vga_device::trident_vga_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) + : svga_device(mconfig, type, name, tag, owner, clock, shortname, source) { } +tgui9860_device::tgui9860_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : trident_vga_device(mconfig, TRIDENT_VGA, "Trident TGUI9680", tag, owner, clock, "trident_vga", __FILE__) +{ + m_version = 0xd3; // 0xd3 identifies at TGUI9660XGi (set to 0xe3 to identify at TGUI9440AGi) +} + +tvga9000_device::tvga9000_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : trident_vga_device(mconfig, TVGA9000_VGA, "Trident TVGA9000", tag, owner, clock, "tvga9000_vga", __FILE__) +{ + m_version = 0x43; +} + UINT8 trident_vga_device::READPIXEL8(INT16 x, INT16 y) { return (vga.memory[((y & 0xfff)*offset() + (x & 0xfff)) % vga.svga_intf.vram_size]); @@ -174,7 +187,7 @@ void trident_vga_device::device_start() void trident_vga_device::device_reset() { svga_device::device_reset(); - svga.id = 0xd3; // 0xd3 identifies at TGUI9660XGi (set to 0xe3 to identify at TGUI9440AGi) + svga.id = m_version; tri.revision = 0x01; // revision identifies as TGUI9680 tri.new_mode = false; // start up in old mode tri.dac_active = false; @@ -377,11 +390,14 @@ void trident_vga_device::trident_define_video_mode() switch((tri.pixel_depth & 0x0c) >> 2) { case 0: - default: if(!(tri.pixel_depth & 0x10)) svga.rgb8_en = 1; break; + default: if(!(tri.pixel_depth & 0x10) || (tri.cr1e & 0x80)) svga.rgb8_en = 1; break; case 1: if((tri.dac & 0xf0) == 0x30) svga.rgb16_en = 1; else svga.rgb15_en = 1; break; case 2: svga.rgb32_en = 1; break; } + if((tri.cr1e & 0x80) && (svga.id == 0x43)) + divisor = 2; + recompute_params_clock(divisor, xtal); } diff --git a/src/devices/bus/isa/trident.h b/src/devices/bus/isa/trident.h index db470ec2838..47ba8d3f8e4 100644 --- a/src/devices/bus/isa/trident.h +++ b/src/devices/bus/isa/trident.h @@ -16,7 +16,7 @@ class trident_vga_device : public svga_device { public: // construction/destruction - trident_vga_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + trident_vga_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); virtual READ8_MEMBER(port_03c0_r) override; virtual WRITE8_MEMBER(port_03c0_w) override; @@ -113,6 +113,7 @@ protected: INT16 accel_mem_y; UINT32 accel_transfer; } tri; + UINT8 m_version; private: UINT8 trident_seq_reg_read(UINT8 index); void trident_seq_reg_write(UINT8 index, UINT8 data); @@ -146,8 +147,20 @@ private: UINT32 handle_rop(UINT32 src, UINT32 dst); }; +class tgui9860_device : public trident_vga_device +{ +public: + tgui9860_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); +}; + +class tvga9000_device : public trident_vga_device +{ +public: + tvga9000_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); +}; // device type definition extern const device_type TRIDENT_VGA; +extern const device_type TVGA9000_VGA; #endif /* TRIDENT_H_ */ diff --git a/src/devices/bus/svi3x8/slot/cards.cpp b/src/devices/bus/svi3x8/slot/cards.cpp index 8e60b1ae1d8..aedcb736d03 100644 --- a/src/devices/bus/svi3x8/slot/cards.cpp +++ b/src/devices/bus/svi3x8/slot/cards.cpp @@ -11,6 +11,7 @@ SLOT_INTERFACE_START( svi_slot_cards ) SLOT_INTERFACE("sv801", SV801) SLOT_INTERFACE("sv803", SV803) + SLOT_INTERFACE("sv805", SV805) SLOT_INTERFACE("sv806", SV806) SLOT_INTERFACE("sv807", SV807) SLOT_INTERFACE_END diff --git a/src/devices/bus/svi3x8/slot/cards.h b/src/devices/bus/svi3x8/slot/cards.h index 03492742e53..8bc3e31f1bc 100644 --- a/src/devices/bus/svi3x8/slot/cards.h +++ b/src/devices/bus/svi3x8/slot/cards.h @@ -14,6 +14,7 @@ #include "emu.h" #include "sv801.h" #include "sv803.h" +#include "sv805.h" #include "sv806.h" #include "sv807.h" diff --git a/src/devices/bus/svi3x8/slot/slot.h b/src/devices/bus/svi3x8/slot/slot.h index 6cea923f6f6..e41e6c107f1 100644 --- a/src/devices/bus/svi3x8/slot/slot.h +++ b/src/devices/bus/svi3x8/slot/slot.h @@ -96,6 +96,7 @@ public: void add_card(device_svi_slot_interface *card); // from slot + DECLARE_WRITE_LINE_MEMBER( int_w ) { m_int_handler(state); }; DECLARE_WRITE_LINE_MEMBER( romdis_w ) { m_romdis_handler(state); }; DECLARE_WRITE_LINE_MEMBER( ramdis_w ) { m_ramdis_handler(state); }; diff --git a/src/devices/bus/svi3x8/slot/sv805.cpp b/src/devices/bus/svi3x8/slot/sv805.cpp new file mode 100644 index 00000000000..d240e95f2e1 --- /dev/null +++ b/src/devices/bus/svi3x8/slot/sv805.cpp @@ -0,0 +1,109 @@ +// license:GPL-2.0+ +// copyright-holders:Dirk Best +/*************************************************************************** + + SV-805 RS-232 Interface for SVI 318/328 + +***************************************************************************/ + +#include "sv805.h" + + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +const device_type SV805 = &device_creator<sv805_device>; + +//------------------------------------------------- +// machine_config_additions - device-specific +// machine configurations +//------------------------------------------------- + +static MACHINE_CONFIG_FRAGMENT( sv805 ) + MCFG_DEVICE_ADD("uart", INS8250, XTAL_3_072MHz) + MCFG_INS8250_OUT_INT_CB(WRITELINE(sv805_device, uart_intr_w)) + MCFG_INS8250_OUT_TX_CB(DEVWRITELINE("rs232", rs232_port_device, write_txd)) + MCFG_INS8250_OUT_DTR_CB(DEVWRITELINE("rs232", rs232_port_device, write_dtr)) + MCFG_INS8250_OUT_RTS_CB(DEVWRITELINE("rs232", rs232_port_device, write_rts)) + + MCFG_RS232_PORT_ADD("rs232", default_rs232_devices, nullptr) + MCFG_RS232_RXD_HANDLER(DEVWRITELINE("uart", ins8250_uart_device, rx_w)) + MCFG_RS232_DCD_HANDLER(DEVWRITELINE("uart", ins8250_uart_device, dcd_w)) + MCFG_RS232_DSR_HANDLER(DEVWRITELINE("uart", ins8250_uart_device, dsr_w)) + MCFG_RS232_CTS_HANDLER(DEVWRITELINE("uart", ins8250_uart_device, cts_w)) +MACHINE_CONFIG_END + +machine_config_constructor sv805_device::device_mconfig_additions() const +{ + return MACHINE_CONFIG_NAME( sv805 ); +} + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// sv806_device - constructor +//------------------------------------------------- + +sv805_device::sv805_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, SV805, "SV-805 RS-232 Interface", tag, owner, clock, "sv805", __FILE__), + device_svi_slot_interface(mconfig, *this), + m_uart(*this, "uart"), + m_rs232(*this, "rs232") +{ +} + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void sv805_device::device_start() +{ +} + + +//************************************************************************** +// IMPLEMENTATION +//************************************************************************** + +READ8_MEMBER( sv805_device::iorq_r ) +{ + switch (offset) + { + case 0x28: + case 0x29: + case 0x2a: + case 0x2b: + case 0x2c: + case 0x2d: + case 0x2e: + case 0x2f: + return m_uart->ins8250_r(space, offset & 0x07); + } + + return 0xff; +} + +WRITE8_MEMBER( sv805_device::iorq_w ) +{ + switch (offset) + { + case 0x28: + case 0x29: + case 0x2a: + case 0x2b: + case 0x2c: + case 0x2d: + case 0x2e: + case 0x2f: + m_uart->ins8250_w(space, offset & 0x07, data); + } +} + +WRITE_LINE_MEMBER( sv805_device::uart_intr_w ) +{ + m_bus->int_w(state); +} diff --git a/src/devices/bus/svi3x8/slot/sv805.h b/src/devices/bus/svi3x8/slot/sv805.h new file mode 100644 index 00000000000..6d64ef54256 --- /dev/null +++ b/src/devices/bus/svi3x8/slot/sv805.h @@ -0,0 +1,49 @@ +// license:GPL-2.0+ +// copyright-holders:Dirk Best +/*************************************************************************** + + SV-805 RS-232 Interface for SVI 318/328 + +***************************************************************************/ + +#pragma once + +#ifndef __SVI3X8_SLOT_SV805_H__ +#define __SVI3X8_SLOT_SV805_H__ + +#include "emu.h" +#include "slot.h" +#include "machine/ins8250.h" +#include "bus/rs232/rs232.h" + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> sv805_device + +class sv805_device : public device_t, public device_svi_slot_interface +{ +public: + // construction/destruction + sv805_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + virtual DECLARE_READ8_MEMBER( iorq_r ) override; + virtual DECLARE_WRITE8_MEMBER( iorq_w ) override; + + DECLARE_WRITE_LINE_MEMBER( uart_intr_w ); + +protected: + virtual machine_config_constructor device_mconfig_additions() const override; + virtual void device_start() override; + +private: + required_device<ins8250_device> m_uart; + required_device<rs232_port_device> m_rs232; +}; + +// device type definition +extern const device_type SV805; + +#endif // __SVI3X8_SLOT_SV805_H__ diff --git a/src/devices/bus/ti99x/gromport.cpp b/src/devices/bus/ti99x/gromport.cpp index 2b9a66d028a..baa77932f7e 100644 --- a/src/devices/bus/ti99x/gromport.cpp +++ b/src/devices/bus/ti99x/gromport.cpp @@ -2245,43 +2245,46 @@ rpk_socket::rpk_socket(const char* id, int length, UINT8* contents) /* Locate a file in the ZIP container */ -const zip_file::file_header* rpk_reader::find_file(zip_file &zip, const char *filename, UINT32 crc) +int rpk_reader::find_file(util::archive_file &zip, const char *filename, UINT32 crc) { - const zip_file::file_header *header; - for (header = zip.first_file(); header != nullptr; header = zip.next_file()) + for (int header = zip.first_file(); header >= 0; header = zip.next_file()) { - // We don't check for CRC == 0. - if (crc != 0) + // Ignore directories + if (!zip.current_is_directory()) { - // if the CRC and name both match, we're good - // if the CRC matches and the name doesn't, we're still good - if (header->crc == crc) - return header; - } - else - { - if (core_stricmp(header->filename, filename)==0) + // We don't check for CRC == 0. + if (crc != 0) + { + // if the CRC and name both match, we're good + // if the CRC matches and the name doesn't, we're still good + if (zip.current_crc() == crc) + return header; + } + else { - return header; + if (core_stricmp(zip.current_name().c_str(), filename) == 0) + { + return header; + } } } } - return nullptr; + return -1; } /* Load a rom resource and put it in a pcb socket instance. */ -rpk_socket* rpk_reader::load_rom_resource(zip_file &zip, xml_data_node* rom_resource_node, const char* socketname) +rpk_socket* rpk_reader::load_rom_resource(util::archive_file &zip, xml_data_node* rom_resource_node, const char* socketname) { const char* file; const char* crcstr; const char* sha1; - zip_file::error ziperr; + util::archive_file::error ziperr; UINT32 crc; int length; UINT8* contents; - const zip_file::file_header *header; + int header; // find the file attribute (required) file = xml_get_attribute_string(rom_resource_node, "file", nullptr); @@ -2301,9 +2304,9 @@ rpk_socket* rpk_reader::load_rom_resource(zip_file &zip, xml_data_node* rom_reso crc = strtoul(crcstr, nullptr, 16); header = find_file(zip, file, crc); } - if (header == nullptr) throw rpk_exception(RPK_INVALID_FILE_REF, "File not found or CRC check failed"); + if (header < 0) throw rpk_exception(RPK_INVALID_FILE_REF, "File not found or CRC check failed"); - length = header->uncompressed_length; + length = zip.current_uncompressed_length(); // Allocate storage contents = global_alloc_array_clear<UINT8>(length); @@ -2311,9 +2314,9 @@ rpk_socket* rpk_reader::load_rom_resource(zip_file &zip, xml_data_node* rom_reso // and unzip file from the zip file ziperr = zip.decompress(contents, length); - if (ziperr != zip_file::error::NONE) + if (ziperr != util::archive_file::error::NONE) { - if (ziperr == zip_file::error::UNSUPPORTED) throw rpk_exception(RPK_ZIP_UNSUPPORTED); + if (ziperr == util::archive_file::error::UNSUPPORTED) throw rpk_exception(RPK_ZIP_UNSUPPORTED); else throw rpk_exception(RPK_ZIP_ERROR); } @@ -2414,15 +2417,14 @@ rpk_socket* rpk_reader::load_ram_resource(emu_options &options, xml_data_node* r rpk* rpk_reader::open(emu_options &options, const char *filename, const char *system_name) { - zip_file::error ziperr; + util::archive_file::error ziperr; - const zip_file::file_header *header; const char *pcb_type; const char *id; const char *uses_name; const char *resource_name; - zip_file::ptr zipfile; + util::archive_file::ptr zipfile; std::vector<char> layout_text; xml_data_node *layout_xml = nullptr; @@ -2442,25 +2444,24 @@ rpk* rpk_reader::open(emu_options &options, const char *filename, const char *sy try { /* open the ZIP file */ - ziperr = zip_file::open(filename, zipfile); - if (ziperr != zip_file::error::NONE) throw rpk_exception(RPK_NOT_ZIP_FORMAT); + ziperr = util::archive_file::open_zip(filename, zipfile); + if (ziperr != util::archive_file::error::NONE) throw rpk_exception(RPK_NOT_ZIP_FORMAT); /* find the layout.xml file */ - header = find_file(*zipfile, "layout.xml", 0); - if (header == nullptr) throw rpk_exception(RPK_MISSING_LAYOUT); + if (find_file(*zipfile, "layout.xml", 0) < 0) throw rpk_exception(RPK_MISSING_LAYOUT); /* reserve space for the layout file contents (+1 for the termination) */ - layout_text.resize(header->uncompressed_length + 1); + layout_text.resize(zipfile->current_uncompressed_length() + 1); /* uncompress the layout text */ - ziperr = zipfile->decompress(&layout_text[0], header->uncompressed_length); - if (ziperr != zip_file::error::NONE) + ziperr = zipfile->decompress(&layout_text[0], zipfile->current_uncompressed_length()); + if (ziperr != util::archive_file::error::NONE) { - if (ziperr == zip_file::error::UNSUPPORTED) throw rpk_exception(RPK_ZIP_UNSUPPORTED); + if (ziperr == util::archive_file::error::UNSUPPORTED) throw rpk_exception(RPK_ZIP_UNSUPPORTED); else throw rpk_exception(RPK_ZIP_ERROR); } - layout_text[header->uncompressed_length] = '\0'; // Null-terminate + layout_text[zipfile->current_uncompressed_length()] = '\0'; // Null-terminate /* parse the layout text */ layout_xml = xml_string_read(&layout_text[0], nullptr); diff --git a/src/devices/bus/ti99x/gromport.h b/src/devices/bus/ti99x/gromport.h index 9b60425aa06..36900c40045 100644 --- a/src/devices/bus/ti99x/gromport.h +++ b/src/devices/bus/ti99x/gromport.h @@ -454,10 +454,10 @@ public: rpk *open(emu_options &options, const char *filename, const char *system_name); private: - const zip_file::file_header* find_file(zip_file &zip, const char *filename, UINT32 crc); - rpk_socket* load_rom_resource(zip_file &zip, xml_data_node* rom_resource_node, const char* socketname); - rpk_socket* load_ram_resource(emu_options &options, xml_data_node* ram_resource_node, const char* socketname, const char* system_name); - const pcb_type* m_types; + int find_file(util::archive_file &zip, const char *filename, UINT32 crc); + rpk_socket* load_rom_resource(util::archive_file &zip, xml_data_node* rom_resource_node, const char* socketname); + rpk_socket* load_ram_resource(emu_options &options, xml_data_node* ram_resource_node, const char* socketname, const char* system_name); + const pcb_type* m_types; }; class rpk diff --git a/src/devices/imagedev/floppy.cpp b/src/devices/imagedev/floppy.cpp index 38e0a5ff9d8..345d6bce3cd 100644 --- a/src/devices/imagedev/floppy.cpp +++ b/src/devices/imagedev/floppy.cpp @@ -365,7 +365,7 @@ floppy_image_format_t *floppy_image_device::identify(std::string filename) util::core_file::ptr fd; std::string revised_path; - osd_file::error err = zippath_fopen(filename.c_str(), OPEN_FLAG_READ, fd, revised_path); + osd_file::error err = util::zippath_fopen(filename.c_str(), OPEN_FLAG_READ, fd, revised_path); if(err != osd_file::error::NONE) { seterror(IMAGE_ERROR_INVALIDIMAGE, "Unable to open the image file"); return nullptr; @@ -1004,7 +1004,7 @@ void ui_menu_control_floppy_image::hook_load(std::string filename, bool softlist std::string tmp_path; util::core_file::ptr tmp_file; /* attempt to open the file for writing but *without* create */ - filerr = zippath_fopen(filename.c_str(), OPEN_FLAG_READ | OPEN_FLAG_WRITE, tmp_file, tmp_path); + filerr = util::zippath_fopen(filename.c_str(), OPEN_FLAG_READ | OPEN_FLAG_WRITE, tmp_file, tmp_path); if(filerr == osd_file::error::NONE) tmp_file.reset(); else @@ -1048,7 +1048,7 @@ void ui_menu_control_floppy_image::handle() state = START_FILE; handle(); } else { - zippath_combine(output_filename, current_directory.c_str(), current_file.c_str()); + util::zippath_combine(output_filename, current_directory.c_str(), current_file.c_str()); output_format = format_array[submenu_result]; do_load_create(); ui_menu::stack_pop(machine()); diff --git a/src/devices/machine/gt64xxx.cpp b/src/devices/machine/gt64xxx.cpp new file mode 100644 index 00000000000..1b4f0a642ef --- /dev/null +++ b/src/devices/machine/gt64xxx.cpp @@ -0,0 +1,600 @@ +// license:BSD-3-Clause +// copyright-holders: Aaron Giles, Ted Green +#include "gt64xxx.h" + +/************************************* + * + * Debugging constants + * + *************************************/ +#define LOG_GALILEO (0) +#define LOG_REG (0) +#define LOG_TIMERS (0) +#define LOG_DMA (0) + +const device_type GT64XXX = &device_creator<gt64xxx_device>; + +DEVICE_ADDRESS_MAP_START(config_map, 32, gt64xxx_device) + AM_INHERIT_FROM(pci_device::config_map) +ADDRESS_MAP_END + +// cpu i/f map +DEVICE_ADDRESS_MAP_START(cpu_map, 32, gt64xxx_device) + AM_RANGE(0x00000000, 0x00000cff) AM_READWRITE( cpu_if_r, cpu_if_w) +ADDRESS_MAP_END + +gt64xxx_device::gt64xxx_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : pci_host_device(mconfig, GT64XXX, "Galileo GT-64XXX System Controller", tag, owner, clock, "gt64xxx", __FILE__), + m_be(0), m_autoconfig(0), m_irq_num(-1), + m_mem_config("memory_space", ENDIANNESS_LITTLE, 32, 32), + m_io_config("io_space", ENDIANNESS_LITTLE, 32, 32) +{ +} + +const address_space_config *gt64xxx_device::memory_space_config(address_spacenum spacenum) const +{ + return (spacenum == AS_PROGRAM) ? pci_bridge_device::memory_space_config(spacenum) : (spacenum == AS_DATA) ? &m_mem_config : (spacenum == AS_IO) ? &m_io_config : NULL; +} + +void gt64xxx_device::device_start() +{ + pci_host_device::device_start(); + m_cpu = machine().device<mips3_device>(cpu_tag); + m_cpu_space = &m_cpu->space(AS_PROGRAM); + memory_space = &space(AS_DATA); + io_space = &space(AS_IO); + + memory_window_start = 0; + memory_window_end = 0xffffffff; + memory_offset = 0; + io_window_start = 0; + io_window_end = 0xffffffff; + io_offset = 0x00000000; + status = 0x0; + + // ROM size = 4 MB + m_cpu_space->install_rom (0x1fc00000, 0x1fffffff, m_region->base()); + + // MIPS drc + m_cpu->add_fastram(0x1fc00000, 0x1fffffff, TRUE, m_region->base()); +} + +void gt64xxx_device::device_reset() +{ + pci_device::device_reset(); + + // Configuration register defaults + m_reg[GREG_CPU_CONFIG] = m_be ? 0 : (1<<12); + m_reg[GREG_RAS_1_0_LO] = 0x0; + m_reg[GREG_RAS_1_0_HI] = 0x7; + m_reg[GREG_RAS_3_2_LO] = 0x8; + m_reg[GREG_RAS_3_2_HI] = 0xf; + m_reg[GREG_CS_2_0_LO] = 0xe0; + m_reg[GREG_CS_2_0_HI] = 0x70; + m_reg[GREG_CS_3_BOOT_LO] = 0xf8; + m_reg[GREG_CS_3_BOOT_HI] = 0x7f; + m_reg[GREG_PCI_IO_LO] = 0x80; + m_reg[GREG_PCI_IO_HI] = 0xf; + m_reg[GREG_PCI_MEM0_LO] = 0x90; + m_reg[GREG_PCI_MEM0_HI] = 0x1f; + m_reg[GREG_INTERNAL_SPACE] = 0xa0; + m_reg[GREG_PCI_MEM1_LO] = 0x790; + m_reg[GREG_PCI_MEM1_HI] = 0x1f; + + m_reg[GREG_RAS0_LO] = 0x0; + m_reg[GREG_RAS0_HI] = 0x7; + m_reg[GREG_RAS1_LO] = 0x8; + m_reg[GREG_RAS1_HI] = 0xf; + m_reg[GREG_RAS2_LO] = 0x10; + m_reg[GREG_RAS2_HI] = 0x17; + m_reg[GREG_RAS3_LO] = 0x18; + m_reg[GREG_RAS3_HI] = 0x1f; + m_reg[GREG_CS0_LO] = 0xc0; + m_reg[GREG_CS0_HI] = 0xc7; + m_reg[GREG_CS1_LO] = 0xc8; + m_reg[GREG_CS1_HI] = 0xcf; + m_reg[GREG_CS2_LO] = 0xd0; + m_reg[GREG_CS2_HI] = 0xdf; + m_reg[GREG_CS3_LO] = 0xf0; + m_reg[GREG_CS3_HI] = 0xfb; + m_reg[GREG_CSBOOT_LO] = 0xfc; + m_reg[GREG_CSBOOT_HI] = 0xff; + + m_reg[GREG_PCI_COMMAND] = m_be ? 0 : 1; + + map_cpu_space(); + regenerate_config_mapping(); +} + +void gt64xxx_device::map_cpu_space() +{ + UINT32 winStart, winEnd; + + // ROM region starts at 0x1fc00000 + m_cpu_space->unmap_readwrite(0x00000000, 0x1fbfffff); + m_cpu_space->unmap_readwrite(0x20000000, 0xffffffff); + + // Clear fastram regions in cpu after rom + m_cpu->clear_fastram(1); + + // CPU Regs + winStart = m_reg[GREG_INTERNAL_SPACE]<<21; + winEnd = winStart + sizeof(m_reg) - 1; + m_cpu_space->install_device(winStart, winEnd, *static_cast<gt64xxx_device *>(this), >64xxx_device::cpu_map); + if (LOG_GALILEO) + logerror("%s: map_cpu_space cpu_reg start: %08X end: %08X\n", tag(), winStart, winEnd); + + // Ras0 + winStart = (m_reg[GREG_RAS_1_0_LO]<<21) | (m_reg[GREG_RAS0_LO]<<20); + winEnd = (m_reg[GREG_RAS_1_0_LO]<<21) | (m_reg[GREG_RAS0_HI]<<20) | 0xfffff; + m_ram[0].resize((winEnd+1-winStart)/4); + m_cpu_space->install_ram(winStart, winEnd, &m_ram[0][0]); + m_cpu->add_fastram(winStart, m_ram[0].size()*sizeof(m_ram[0][0]), FALSE, &m_ram[0][0]); + if (LOG_GALILEO) + logerror("%s: map_cpu_space ras0 start: %08X end: %08X\n", tag(), winStart, winEnd); + + // PCI IO Window + winStart = m_reg[GREG_PCI_IO_LO]<<21; + winEnd = (m_reg[GREG_PCI_IO_LO]<<21) | (m_reg[GREG_PCI_IO_HI]<<21) | 0x1fffff; + m_cpu_space->install_read_handler(winStart, winEnd, 0, 0, read32_delegate(FUNC(gt64xxx_device::master_io_r), this)); + m_cpu_space->install_write_handler(winStart, winEnd, 0, 0, write32_delegate(FUNC(gt64xxx_device::master_io_w), this)); + if (LOG_GALILEO) + logerror("%s: map_cpu_space pci_io start: %08X end: %08X\n", tag(), winStart, winEnd); + + // PCI MEM0 Window + winStart = m_reg[GREG_PCI_MEM0_LO]<<21; + winEnd = (m_reg[GREG_PCI_MEM0_LO]<<21) | (m_reg[GREG_PCI_MEM0_HI]<<21) | 0x1fffff; + m_cpu_space->install_read_handler(winStart, winEnd, 0, 0, read32_delegate(FUNC(gt64xxx_device::master_mem0_r), this)); + m_cpu_space->install_write_handler(winStart, winEnd, 0, 0, write32_delegate(FUNC(gt64xxx_device::master_mem0_w), this)); + if (LOG_GALILEO) + logerror("%s: map_cpu_space pci_mem0 start: %08X end: %08X\n", tag(), winStart, winEnd); + + // PCI MEM1 Window + winStart = m_reg[GREG_PCI_MEM1_LO]<<21; + winEnd = (m_reg[GREG_PCI_MEM1_LO]<<21) | (m_reg[GREG_PCI_MEM1_HI]<<21) | 0x1fffff; + m_cpu_space->install_read_handler(winStart, winEnd, 0, 0, read32_delegate(FUNC(gt64xxx_device::master_mem1_r), this)); + m_cpu_space->install_write_handler(winStart, winEnd, 0, 0, write32_delegate(FUNC(gt64xxx_device::master_mem1_w), this)); + if (LOG_GALILEO) + logerror("%s: map_cpu_space pci_mem1 start: %08X end: %08X\n", tag(), winStart, winEnd); + +} + +void gt64xxx_device::map_extra(UINT64 memory_window_start, UINT64 memory_window_end, UINT64 memory_offset, address_space *memory_space, + UINT64 io_window_start, UINT64 io_window_end, UINT64 io_offset, address_space *io_space) +{ + /* + UINT32 winStart, winEnd, winSize; + + // PCI Target Window 1 + if (m_cpu_regs[NREG_PCITW1]&0x1000) { + winStart = m_cpu_regs[NREG_PCITW1]&0xffe00000; + winEnd = winStart | (~(0xf0000000 | (((m_cpu_regs[NREG_PCITW1]>>13)&0x7f)<<21))); + winSize = winEnd - winStart + 1; + memory_space->install_read_handler(winStart, winEnd, 0, 0, read32_delegate(FUNC(gt64xxx_device::target1_r), this)); + memory_space->install_write_handler(winStart, winEnd, 0, 0, write32_delegate(FUNC(gt64xxx_device::target1_w), this)); + if (LOG_GALILEO) + logerror("%s: map_extra Target Window 1 start=%08X end=%08X size=%08X laddr=%08X\n", tag(), winStart, winEnd, winSize, m_target1_laddr); + } + */ +} + +void gt64xxx_device::reset_all_mappings() +{ + pci_device::reset_all_mappings(); +} + +// PCI bus control +READ32_MEMBER (gt64xxx_device::pci_config_r) +{ + UINT32 result = 0; + if (LOG_GALILEO) + logerror("%06X:galileo pci_config_r from offset %02X = %08X & %08X\n", space.device().safe_pc(), offset*4, result, mem_mask); + return result; +} +WRITE32_MEMBER (gt64xxx_device::pci_config_w) +{ + if (LOG_GALILEO) + logerror("%06X:galileo pci_config_w to offset %02X = %08X & %08X\n", space.device().safe_pc(), offset*4, data, mem_mask); +} +// PCI Master Window 0 +READ32_MEMBER (gt64xxx_device::master_mem0_r) +{ + UINT32 result = this->space(AS_DATA).read_dword((m_reg[GREG_PCI_MEM0_LO]<<21) | (offset*4), mem_mask); + if (LOG_GALILEO) + logerror("%06X:galileo pci mem0 read from offset %08X = %08X & %08X\n", space.device().safe_pc(), (m_reg[GREG_PCI_MEM0_LO]<<21) | (offset*4), result, mem_mask); + return result; +} +WRITE32_MEMBER (gt64xxx_device::master_mem0_w) +{ + this->space(AS_DATA).write_dword((m_reg[GREG_PCI_MEM0_LO]<<21) | (offset*4), data, mem_mask); + if (LOG_GALILEO) + logerror("%06X:galileo pci mem0 write to offset %08X = %08X & %08X\n", space.device().safe_pc(), (m_reg[GREG_PCI_MEM0_LO]<<21) | (offset*4), data, mem_mask); +} + +// PCI Master Window 1 +READ32_MEMBER (gt64xxx_device::master_mem1_r) +{ + UINT32 result = this->space(AS_DATA).read_dword((m_reg[GREG_PCI_MEM1_LO]<<21) | (offset*4), mem_mask); + if (LOG_GALILEO) + logerror("%06X:galileo pci mem1 read from offset %08X = %08X & %08X\n", space.device().safe_pc(), (m_reg[GREG_PCI_MEM1_LO]<<21) | (offset*4), result, mem_mask); + return result; +} +WRITE32_MEMBER (gt64xxx_device::master_mem1_w) +{ + this->space(AS_DATA).write_dword((m_reg[GREG_PCI_MEM1_LO]<<21) | (offset*4), data, mem_mask); + if (LOG_GALILEO) + logerror("%06X:galileo pci mem1 write to offset %08X = %08X & %08X\n", space.device().safe_pc(), (m_reg[GREG_PCI_MEM1_LO]<<21) | (offset*4), data, mem_mask); +} + +// PCI Master IO +READ32_MEMBER (gt64xxx_device::master_io_r) +{ + UINT32 result = this->space(AS_IO).read_dword((m_reg[GREG_PCI_IO_LO]<<21) | (offset*4), mem_mask); + if (LOG_GALILEO) + logerror("%06X:galileo pci io read from offset %08X = %08X & %08X\n", space.device().safe_pc(), (m_reg[GREG_PCI_IO_LO]<<21) | (offset*4), result, mem_mask); + return result; +} +WRITE32_MEMBER (gt64xxx_device::master_io_w) +{ + this->space(AS_IO).write_dword((m_reg[GREG_PCI_IO_LO]<<21) | (offset*4), data, mem_mask); + if (LOG_GALILEO) + logerror("%06X:galileo pciio write to offset %08X = %08X & %08X\n", space.device().safe_pc(), (m_reg[GREG_PCI_IO_LO]<<21) | (offset*4), data, mem_mask); +} + + +// CPU I/F +READ32_MEMBER (gt64xxx_device::cpu_if_r) +{ + UINT32 result = m_reg[offset]; + + /* switch off the offset for special cases */ + switch (offset) + { + case GREG_TIMER0_COUNT: + case GREG_TIMER1_COUNT: + case GREG_TIMER2_COUNT: + case GREG_TIMER3_COUNT: + { + int which = offset % 4; + galileo_timer *timer = &m_timer[which]; + + result = timer->count; + if (timer->active) + { + UINT32 elapsed = (timer->timer->elapsed() * m_clock).as_double(); + result = (result > elapsed) ? (result - elapsed) : 0; + } + + /* eat some time for those which poll this register */ + space.device().execute().eat_cycles(100); + + if (LOG_TIMERS) + logerror("%08X:hires_timer_r = %08X\n", space.device().safe_pc(), result); + break; + } + + case GREG_PCI_COMMAND: + // code at 40188 loops until this returns non-zero in bit 0 + //result = 0x0001; + break; + + case GREG_CONFIG_DATA: + result = config_data_r(space, offset); + break; + + case GREG_CONFIG_ADDRESS: + result = config_address_r(space, offset); + break; + + case GREG_INT_STATE: + case GREG_INT_MASK: + case GREG_TIMER_CONTROL: +// if (LOG_GALILEO) +// logerror("%08X:Galileo read from offset %03X = %08X\n", space.device().safe_pc(), offset*4, result); + break; + + default: + logerror("%08X:Galileo read from offset %03X = %08X\n", space.device().safe_pc(), offset*4, result); + break; + } + + if (m_be) result = FLIPENDIAN_INT32(result); + + return result; +} + +WRITE32_MEMBER(gt64xxx_device::cpu_if_w) +{ + if (m_be) { + data = FLIPENDIAN_INT32(data); + mem_mask = FLIPENDIAN_INT32(mem_mask); + } + + UINT32 oldata = m_reg[offset]; + COMBINE_DATA(&m_reg[offset]); + + /* switch off the offset for special cases */ + switch (offset) + { + case GREG_RAS_1_0_LO: + case GREG_RAS_1_0_HI: + case GREG_RAS_3_2_LO: + case GREG_RAS_3_2_HI: + case GREG_CS_2_0_LO: + case GREG_CS_2_0_HI: + case GREG_CS_3_BOOT_LO: + case GREG_CS_3_BOOT_HI: + case GREG_PCI_IO_LO: + case GREG_PCI_IO_HI: + case GREG_PCI_MEM0_LO: + case GREG_PCI_MEM0_HI: + case GREG_INTERNAL_SPACE: + case GREG_PCI_MEM1_LO: + case GREG_PCI_MEM1_HI: + map_cpu_space(); + if (LOG_GALILEO) + logerror("%08X:Galileo Memory Map data write to offset %03X = %08X & %08X\n", space.device().safe_pc(), offset*4, data, mem_mask); + break; + + case GREG_DMA0_CONTROL: + case GREG_DMA1_CONTROL: + case GREG_DMA2_CONTROL: + case GREG_DMA3_CONTROL: + { + int which = offset % 4; + + if (LOG_DMA) + logerror("%08X:Galileo write to offset %03X = %08X & %08X\n", space.device().safe_pc(), offset*4, data, mem_mask); + + /* keep the read only activity bit */ + m_reg[offset] &= ~0x4000; + m_reg[offset] |= (oldata & 0x4000); + + /* fetch next record */ + if (data & 0x2000) + dma_fetch_next(space, which); + m_reg[offset] &= ~0x2000; + + /* if enabling, start the DMA */ + if (!(oldata & 0x1000) && (data & 0x1000)) + perform_dma(space, which); + break; + } + + case GREG_TIMER0_COUNT: + case GREG_TIMER1_COUNT: + case GREG_TIMER2_COUNT: + case GREG_TIMER3_COUNT: + { + int which = offset % 4; + galileo_timer *timer = &m_timer[which]; + + if (which != 0) + data &= 0xffffff; + if (!timer->active) + timer->count = data; + if (LOG_TIMERS) + logerror("%08X:timer/counter %d count = %08X [start=%08X]\n", space.device().safe_pc(), offset % 4, data, timer->count); + break; + } + + case GREG_TIMER_CONTROL: + { + int which, mask; + + if (LOG_TIMERS) + logerror("%08X:timer/counter control = %08X\n", space.device().safe_pc(), data); + for (which = 0, mask = 0x01; which < 4; which++, mask <<= 2) + { + galileo_timer *timer = &m_timer[which]; + if (!timer->active && (data & mask)) + { + timer->active = 1; + if (timer->count == 0) + { + timer->count = m_reg[GREG_TIMER0_COUNT + which]; + if (which != 0) + timer->count &= 0xffffff; + } + timer->timer->adjust(TIMER_PERIOD * timer->count, which); + if (LOG_TIMERS) + logerror("Adjusted timer to fire in %f secs\n", (TIMER_PERIOD * timer->count).as_double()); + } + else if (timer->active && !(data & mask)) + { + UINT32 elapsed = (timer->timer->elapsed() * m_clock).as_double(); + timer->active = 0; + timer->count = (timer->count > elapsed) ? (timer->count - elapsed) : 0; + timer->timer->adjust(attotime::never, which); + if (LOG_TIMERS) + logerror("Disabled timer\n"); + } + } + break; + } + + case GREG_INT_STATE: + if (LOG_GALILEO) + logerror("%08X:Galileo write to IRQ clear = %08X & %08X\n", offset*4, data, mem_mask); + m_reg[offset] = oldata & data; + update_irqs(); + break; + + case GREG_CONFIG_DATA: + pci_host_device::config_data_w(space, offset, data); + if (LOG_GALILEO) + logerror("%08X:Galileo PCI config data write to offset %03X = %08X & %08X\n", space.device().safe_pc(), offset*4, data, mem_mask); + break; + + case GREG_CONFIG_ADDRESS: + pci_host_device::config_address_w(space, offset, data); + if (LOG_GALILEO) + logerror("%08X:Galileo PCI config address write to offset %03X = %08X & %08X\n", space.device().safe_pc(), offset*4, data, mem_mask); + break; + + case GREG_DMA0_COUNT: case GREG_DMA1_COUNT: case GREG_DMA2_COUNT: case GREG_DMA3_COUNT: + case GREG_DMA0_SOURCE: case GREG_DMA1_SOURCE: case GREG_DMA2_SOURCE: case GREG_DMA3_SOURCE: + case GREG_DMA0_DEST: case GREG_DMA1_DEST: case GREG_DMA2_DEST: case GREG_DMA3_DEST: + case GREG_DMA0_NEXT: case GREG_DMA1_NEXT: case GREG_DMA2_NEXT: case GREG_DMA3_NEXT: + case GREG_INT_MASK: + if (LOG_GALILEO) + logerror("%08X:Galileo write to offset %03X = %08X & %08X\n", space.device().safe_pc(), offset*4, data, mem_mask); + break; + + default: + logerror("%08X:Galileo write to offset %03X = %08X & %08X\n", space.device().safe_pc(), offset*4, data, mem_mask); + break; + } +} + +/************************************* + * + * Galileo timers & interrupts + * + *************************************/ + +void gt64xxx_device::update_irqs() +{ + int state = CLEAR_LINE; + + /* if any unmasked interrupts are live, we generate */ + if (m_reg[GREG_INT_STATE] & m_reg[GREG_INT_MASK]) + state = ASSERT_LINE; + if (m_irq_num != -1) + m_cpu->set_input_line(m_irq_num, state); + + if (LOG_GALILEO) + logerror("Galileo IRQ %s\n", (state == ASSERT_LINE) ? "asserted" : "cleared"); +} + + +TIMER_CALLBACK_MEMBER(gt64xxx_device::timer_callback) +{ + int which = param; + galileo_timer *timer = &m_timer[which]; + + if (LOG_TIMERS) + logerror("timer %d fired\n", which); + + /* copy the start value from the registers */ + timer->count = m_reg[GREG_TIMER0_COUNT + which]; + if (which != 0) + timer->count &= 0xffffff; + + /* if we're a timer, adjust the timer to fire again */ + if (m_reg[GREG_TIMER_CONTROL] & (2 << (2 * which))) + timer->timer->adjust(TIMER_PERIOD * timer->count, which); + else + timer->active = timer->count = 0; + + /* trigger the interrupt */ + m_reg[GREG_INT_STATE] |= 1 << (GINT_T0EXP_SHIFT + which); + update_irqs(); +} + +/************************************* + * + * Galileo DMA handler + * + *************************************/ + +int gt64xxx_device::dma_fetch_next(address_space &space, int which) +{ + offs_t address = 0; + UINT32 data; + + /* no-op for unchained mode */ + if (!(m_reg[GREG_DMA0_CONTROL + which] & 0x200)) + address = m_reg[GREG_DMA0_NEXT + which]; + + /* if we hit the end address, signal an interrupt */ + if (address == 0) + { + if (m_reg[GREG_DMA0_CONTROL + which] & 0x400) + { + m_reg[GREG_INT_STATE] |= 1 << (GINT_DMA0COMP_SHIFT + which); + update_irqs(); + } + m_reg[GREG_DMA0_CONTROL + which] &= ~0x5000; + return 0; + } + + /* fetch the byte count */ + data = space.read_dword(address); address += 4; + m_reg[GREG_DMA0_COUNT + which] = data; + + /* fetch the source address */ + data = space.read_dword(address); address += 4; + m_reg[GREG_DMA0_SOURCE + which] = data; + + /* fetch the dest address */ + data = space.read_dword(address); address += 4; + m_reg[GREG_DMA0_DEST + which] = data; + + /* fetch the next record address */ + data = space.read_dword(address); address += 4; + m_reg[GREG_DMA0_NEXT + which] = data; + return 1; +} + + +void gt64xxx_device::perform_dma(address_space &space, int which) +{ + do + { + offs_t srcaddr = m_reg[GREG_DMA0_SOURCE + which]; + offs_t dstaddr = m_reg[GREG_DMA0_DEST + which]; + UINT32 bytesleft = m_reg[GREG_DMA0_COUNT + which] & 0xffff; + int srcinc, dstinc; + + m_dma_active = which; + m_reg[GREG_DMA0_CONTROL + which] |= 0x5000; + + /* determine src/dst inc */ + switch ((m_reg[GREG_DMA0_CONTROL + which] >> 2) & 3) + { + default: + case 0: srcinc = 1; break; + case 1: srcinc = -1; break; + case 2: srcinc = 0; break; + } + switch ((m_reg[GREG_DMA0_CONTROL + which] >> 4) & 3) + { + default: + case 0: dstinc = 1; break; + case 1: dstinc = -1; break; + case 2: dstinc = 0; break; + } + + if (LOG_DMA) + logerror("Performing DMA%d: src=%08X dst=%08X bytes=%04X sinc=%d dinc=%d\n", which, srcaddr, dstaddr, bytesleft, srcinc, dstinc); + + /* standard transfer */ + while (bytesleft > 0) + { + space.write_byte(dstaddr, space.read_byte(srcaddr)); + srcaddr += srcinc; + dstaddr += dstinc; + bytesleft--; + } + + /* not verified, but seems logical these should be updated byte the end */ + m_reg[GREG_DMA0_SOURCE + which] = srcaddr; + m_reg[GREG_DMA0_DEST + which] = dstaddr; + m_reg[GREG_DMA0_COUNT + which] = (m_reg[GREG_DMA0_COUNT + which] & ~0xffff) | bytesleft; + m_dma_active = -1; + + /* if we did not hit zero, punt and return later */ + if (bytesleft != 0) + return; + + /* interrupt? */ + if (!(m_reg[GREG_DMA0_CONTROL + which] & 0x400)) + { + m_reg[GREG_INT_STATE] |= 1 << (GINT_DMA0COMP_SHIFT + which); + update_irqs(); + } + } while (dma_fetch_next(space, which)); + + m_reg[GREG_DMA0_CONTROL + which] &= ~0x5000; +} diff --git a/src/devices/machine/gt64xxx.h b/src/devices/machine/gt64xxx.h new file mode 100644 index 00000000000..a31674d59e8 --- /dev/null +++ b/src/devices/machine/gt64xxx.h @@ -0,0 +1,259 @@ +// license:BSD-3-Clause +// copyright-holders: Aaron Giles, Ted Green +// Galileo GT-64xxx System Controller +// Skeleton code based off seattle machine driver. +// TODO: +// Testing +// Need PCI to be able to have a target delay a dma transfer +// Add PCI target maps +// Add PCI Func 1 calls +// Configurable byte swapping on cpu and pci busses. + +#ifndef GT64XXX_H +#define GT64XXX_H + +#include "pci.h" +#include "cpu/mips/mips3.h" + +// Supports R4600/4650/4700/R5000 CPUs +#define MCFG_GT64010_ADD(_tag, _cpu_tag, _clock) \ + MCFG_PCI_HOST_ADD(_tag, GT64XXX, 0x014611ab, 0x03, 0x00000000) \ + downcast<gt64xxx_device *>(device)->set_cpu_tag(_cpu_tag); \ + downcast<gt64xxx_device *>(device)->set_clock(_clock); + +// Supports the following 32-bit bus CPUs: +// IDT RC4640 and RC4650 (in 32-bit mode) +// QED RM523X +// NEC/Toshiba VR4300 +#define MCFG_GT64111_ADD(_tag, _cpu_tag, _clock) \ + MCFG_PCI_DEVICE_ADD(_tag, GT64XXX, 0x414611ab, 0x10, 0x058000, 0x00000000) \ + downcast<gt64xxx_device *>(device)->set_cpu_tag(_cpu_tag); \ + downcast<gt64xxx_device *>(device)->set_clock(_clock); + +#define MCFG_GT64XXX_SET_BE_CPU(_be) \ + downcast<gt64xxx_device *>(device)->set_be(_be); + +#define MCFG_GT64XXX__IRQ_ADD(_irq_num) \ + downcast<gt64xxx_device *>(device)->set_irq_info(_irq_num); + +/************************************* + * + * Galileo constants + * + *************************************/ + +//#define SYSTEM_CLOCK 50000000 +#define TIMER_PERIOD attotime::from_hz(m_clock) + +/* Galileo registers - 0x000-0x3ff */ +#define GREG_CPU_CONFIG (0x000/4) +#define GREG_RAS_1_0_LO (0x008/4) +#define GREG_RAS_1_0_HI (0x010/4) +#define GREG_RAS_3_2_LO (0x018/4) +#define GREG_RAS_3_2_HI (0x020/4) +#define GREG_CS_2_0_LO (0x028/4) +#define GREG_CS_2_0_HI (0x030/4) +#define GREG_CS_3_BOOT_LO (0x038/4) +#define GREG_CS_3_BOOT_HI (0x040/4) +#define GREG_PCI_IO_LO (0x048/4) +#define GREG_PCI_IO_HI (0x050/4) +#define GREG_PCI_MEM0_LO (0x058/4) +#define GREG_PCI_MEM0_HI (0x060/4) +#define GREG_INTERNAL_SPACE (0x068/4) +#define GREG_BUSERR_LO (0x070/4) +#define GREG_BUSERR_HI (0x078/4) +// GT-64111 only +#define GREG_PCI_MEM1_LO (0x080/4) +#define GREG_PCI_MEM1_HI (0x088/4) + +/* Galileo registers - 0x400-0x7ff */ +#define GREG_RAS0_LO (0x400/4) +#define GREG_RAS0_HI (0x404/4) +#define GREG_RAS1_LO (0x408/4) +#define GREG_RAS1_HI (0x40c/4) +#define GREG_RAS2_LO (0x410/4) +#define GREG_RAS2_HI (0x414/4) +#define GREG_RAS3_LO (0x418/4) +#define GREG_RAS3_HI (0x41c/4) +#define GREG_CS0_LO (0x420/4) +#define GREG_CS0_HI (0x424/4) +#define GREG_CS1_LO (0x428/4) +#define GREG_CS1_HI (0x42c/4) +#define GREG_CS2_LO (0x430/4) +#define GREG_CS2_HI (0x434/4) +#define GREG_CS3_LO (0x438/4) +#define GREG_CS3_HI (0x43c/4) +#define GREG_CSBOOT_LO (0x440/4) +#define GREG_CSBOOT_HI (0x444/4) +#define GREG_DRAM_CONFIG (0x448/4) +#define GREG_DRAM_BANK0 (0x44c/4) +#define GREG_DRAM_BANK1 (0x450/4) +#define GREG_DRAM_BANK2 (0x454/4) +#define GREG_DRAM_BANK3 (0x458/4) +#define GREG_DEVICE_BANK0 (0x45c/4) +#define GREG_DEVICE_BANK1 (0x460/4) +#define GREG_DEVICE_BANK2 (0x464/4) +#define GREG_DEVICE_BANK3 (0x468/4) +#define GREG_DEVICE_BOOT (0x46c/4) +#define GREG_ADDRESS_ERROR (0x470/4) + +/* Galileo registers - 0x800-0xbff */ +#define GREG_DMA0_COUNT (0x800/4) +#define GREG_DMA1_COUNT (0x804/4) +#define GREG_DMA2_COUNT (0x808/4) +#define GREG_DMA3_COUNT (0x80c/4) +#define GREG_DMA0_SOURCE (0x810/4) +#define GREG_DMA1_SOURCE (0x814/4) +#define GREG_DMA2_SOURCE (0x818/4) +#define GREG_DMA3_SOURCE (0x81c/4) +#define GREG_DMA0_DEST (0x820/4) +#define GREG_DMA1_DEST (0x824/4) +#define GREG_DMA2_DEST (0x828/4) +#define GREG_DMA3_DEST (0x82c/4) +#define GREG_DMA0_NEXT (0x830/4) +#define GREG_DMA1_NEXT (0x834/4) +#define GREG_DMA2_NEXT (0x838/4) +#define GREG_DMA3_NEXT (0x83c/4) +#define GREG_DMA0_CONTROL (0x840/4) +#define GREG_DMA1_CONTROL (0x844/4) +#define GREG_DMA2_CONTROL (0x848/4) +#define GREG_DMA3_CONTROL (0x84c/4) +#define GREG_TIMER0_COUNT (0x850/4) +#define GREG_TIMER1_COUNT (0x854/4) +#define GREG_TIMER2_COUNT (0x858/4) +#define GREG_TIMER3_COUNT (0x85c/4) +#define GREG_DMA_ARBITER (0x860/4) +#define GREG_TIMER_CONTROL (0x864/4) + +/* Galileo registers - 0xc00-0xfff */ +#define GREG_PCI_COMMAND (0xc00/4) +#define GREG_PCI_TIMEOUT (0xc04/4) +#define GREG_PCI_RAS_1_0 (0xc08/4) +#define GREG_PCI_RAS_3_2 (0xc0c/4) +#define GREG_PCI_CS_2_0 (0xc10/4) +#define GREG_PCI_CS_3_BOOT (0xc14/4) +#define GREG_INT_STATE (0xc18/4) +#define GREG_INT_MASK (0xc1c/4) +#define GREG_PCI_INT_MASK (0xc24/4) +#define GREG_CONFIG_ADDRESS (0xcf8/4) +#define GREG_CONFIG_DATA (0xcfc/4) + +/* Galileo interrupts */ +#define GINT_SUMMARY_SHIFT (0) +#define GINT_MEMOUT_SHIFT (1) +#define GINT_DMAOUT_SHIFT (2) +#define GINT_CPUOUT_SHIFT (3) +#define GINT_DMA0COMP_SHIFT (4) +#define GINT_DMA1COMP_SHIFT (5) +#define GINT_DMA2COMP_SHIFT (6) +#define GINT_DMA3COMP_SHIFT (7) +#define GINT_T0EXP_SHIFT (8) +#define GINT_T1EXP_SHIFT (9) +#define GINT_T2EXP_SHIFT (10) +#define GINT_T3EXP_SHIFT (11) +#define GINT_MASRDERR_SHIFT (12) +#define GINT_SLVWRERR_SHIFT (13) +#define GINT_MASWRERR_SHIFT (14) +#define GINT_SLVRDERR_SHIFT (15) +#define GINT_ADDRERR_SHIFT (16) +#define GINT_MEMERR_SHIFT (17) +#define GINT_MASABORT_SHIFT (18) +#define GINT_TARABORT_SHIFT (19) +#define GINT_RETRYCTR_SHIFT (20) + +/************************************* + * Structures + *************************************/ +struct galileo_timer +{ + emu_timer * timer; + UINT32 count; + UINT8 active; +}; + + +class gt64xxx_device : public pci_host_device { +public: + gt64xxx_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + virtual void reset_all_mappings() override; + virtual void map_extra(UINT64 memory_window_start, UINT64 memory_window_end, UINT64 memory_offset, address_space *memory_space, + UINT64 io_window_start, UINT64 io_window_end, UINT64 io_offset, address_space *io_space) override; + + void set_cpu_tag(const char *tag) { cpu_tag = tag;} + void set_cpu_tag(const UINT32 clock) { m_clock = clock;} + void set_clock(const UINT32 clock) {m_clock = clock;} + void set_be(const int be) {m_be = be;} + void set_autoconfig(const int autoconfig) {m_autoconfig = autoconfig;} + void set_irq_info(const int irq_num) {m_irq_num = irq_num;} + + virtual DECLARE_ADDRESS_MAP(config_map, 32) override; + + // pci bus + DECLARE_READ32_MEMBER( pci_config_r); + DECLARE_WRITE32_MEMBER( pci_config_w); + + // cpu bus + DECLARE_READ32_MEMBER (cpu_if_r); + DECLARE_WRITE32_MEMBER(cpu_if_w); + + DECLARE_READ32_MEMBER (master_mem0_r); + DECLARE_WRITE32_MEMBER(master_mem0_w); + + DECLARE_READ32_MEMBER (master_mem1_r); + DECLARE_WRITE32_MEMBER(master_mem1_w); + + DECLARE_READ32_MEMBER (master_io_r); + DECLARE_WRITE32_MEMBER(master_io_w); + + // devices + DECLARE_READ32_MEMBER (ras_1_0_r); + DECLARE_WRITE32_MEMBER(ras_1_0_w); + DECLARE_READ32_MEMBER (ras_3_2_r); + DECLARE_WRITE32_MEMBER(ras_3_2_w); + DECLARE_READ32_MEMBER (cs_2_0_r); + DECLARE_WRITE32_MEMBER(cs_2_0_w); + DECLARE_READ32_MEMBER (cs_boot_3_r); + DECLARE_WRITE32_MEMBER(cs_boot_3_w); + +protected: + address_space *m_cpu_space; + virtual const address_space_config *memory_space_config(address_spacenum spacenum) const override; + virtual void device_start() override; + virtual void device_reset() override; + +private: + mips3_device *m_cpu; + const char *cpu_tag; + UINT32 m_clock; + int m_be, m_autoconfig; + int m_irq_num; + + address_space_config m_mem_config, m_io_config; + + DECLARE_ADDRESS_MAP(cpu_map, 32); + + void map_cpu_space(); + + /* raw register data */ + UINT32 m_reg[0xd00/4]; + + /* timer info */ + galileo_timer m_timer[4]; + + /* DMA info */ + INT8 m_dma_active; + + // Ram + std::vector<UINT32> m_ram[4]; + + TIMER_CALLBACK_MEMBER(timer_callback); + void update_irqs(); + int dma_fetch_next(address_space &space, int which); + void perform_dma(address_space &space, int which); + +}; + +extern const device_type GT64XXX; + +#endif diff --git a/src/devices/machine/ins8250.cpp b/src/devices/machine/ins8250.cpp index bbd0fee1584..e032039cb7d 100644 --- a/src/devices/machine/ins8250.cpp +++ b/src/devices/machine/ins8250.cpp @@ -316,7 +316,7 @@ WRITE8_MEMBER( ins8250_uart_device::ins8250_w ) bits 5 - 0, you could cause an interrupt if the appropriate IER bit is set. */ - m_regs.lsr = (m_regs.lsr & 0x40) | (data & ~0x40); + m_regs.lsr = (m_regs.lsr & 0x60) | (data & ~0x60); tmp = 0; tmp |= ( m_regs.lsr & 0x01 ) ? COM_INT_PENDING_RECEIVED_DATA_AVAILABLE : 0; diff --git a/src/devices/video/h63484.cpp b/src/devices/video/h63484.cpp index 1e0d7cbb0d8..2ae38362913 100644 --- a/src/devices/video/h63484.cpp +++ b/src/devices/video/h63484.cpp @@ -1913,7 +1913,8 @@ void h63484_device::video_registers_w(int offset) READ16_MEMBER( h63484_device::status_r ) { - return m_sr; + // kothello is coded so that upper byte of this should be 0xff (tests with jc opcode). Maybe it's just unconnected? + return m_sr | 0xff00; } READ16_MEMBER( h63484_device::data_r ) diff --git a/src/emu/clifront.cpp b/src/emu/clifront.cpp index 79b53e943c7..975c3c8f71b 100644 --- a/src/emu/clifront.cpp +++ b/src/emu/clifront.cpp @@ -15,7 +15,6 @@ #include "audit.h" #include "info.h" #include "unzip.h" -#include "un7z.h" #include "validity.h" #include "sound/samples.h" #include "cliopts.h" @@ -266,7 +265,7 @@ int cli_frontend::execute(int argc, char **argv) m_result = MAMERR_FATALERROR; } - _7z_file::cache_clear(); + util::archive_file::cache_clear(); global_free(manager); return m_result; @@ -1000,7 +999,7 @@ void cli_frontend::verifyroms(const char *gamename) } // clear out any cached files - zip_file::cache_clear(); + util::archive_file::cache_clear(); // return an error if none found if (matched == 0) @@ -1092,7 +1091,7 @@ void cli_frontend::verifysamples(const char *gamename) } // clear out any cached files - zip_file::cache_clear(); + util::archive_file::cache_clear(); // return an error if none found if (matched == 0) @@ -1407,7 +1406,7 @@ void cli_frontend::verifysoftware(const char *gamename) } // clear out any cached files - zip_file::cache_clear(); + util::archive_file::cache_clear(); // return an error if none found if (matched == 0) @@ -1529,7 +1528,7 @@ void cli_frontend::verifysoftlist(const char *gamename) } // clear out any cached files - zip_file::cache_clear(); + util::archive_file::cache_clear(); // return an error if none found if (matched == 0) @@ -1758,28 +1757,32 @@ void media_identifier::identify(const char *filename) } // if that failed, and the filename ends with .zip, identify as a ZIP file - if (core_filename_ends_with(filename, ".7z")) + if (core_filename_ends_with(filename, ".7z") || core_filename_ends_with(filename, ".zip")) { // first attempt to examine it as a valid _7Z file - _7z_file::ptr _7z; - _7z_file::error _7zerr = _7z_file::open(filename, _7z); - if (_7zerr == _7z_file::error::NONE && _7z != nullptr) + util::archive_file::ptr archive; + util::archive_file::error err; + if (core_filename_ends_with(filename, ".7z")) + err = util::archive_file::open_7z(filename, archive); + else + err = util::archive_file::open_zip(filename, archive); + if ((err == util::archive_file::error::NONE) && archive) { std::vector<std::uint8_t> data; // loop over entries in the .7z, skipping empty files and directories - for (int i = _7z->first_file(); i >= 0; i = _7z->next_file()) + for (int i = archive->first_file(); i >= 0; i = archive->next_file()) { - const std::uint64_t length(_7z->current_uncompressed_length()); - if ((length != 0) && (std::uint32_t(length) == length)) + const std::uint64_t length(archive->current_uncompressed_length()); + if (!archive->current_is_directory() && (length != 0) && (std::uint32_t(length) == length)) { // decompress data into RAM and identify it try { data.resize(std::size_t(length)); - _7zerr = _7z->decompress(&data[0], std::uint32_t(length)); - if (_7zerr == _7z_file::error::NONE) - identify_data(_7z->current_name().c_str(), &data[0], length); + err = archive->decompress(&data[0], std::uint32_t(length)); + if (err == util::archive_file::error::NONE) + identify_data(archive->current_name().c_str(), &data[0], length); } catch (...) { @@ -1791,31 +1794,8 @@ void media_identifier::identify(const char *filename) } // clear out any cached files - _7z.reset(); - _7z_file::cache_clear(); - } - else if (core_filename_ends_with(filename, ".zip")) - { - // first attempt to examine it as a valid ZIP file - zip_file::ptr zip = nullptr; - zip_file::error ziperr = zip_file::open(filename, zip); - if (ziperr == zip_file::error::NONE && zip != nullptr) - { - // loop over entries in the ZIP, skipping empty files and directories - for (const zip_file::file_header *entry = zip->first_file(); entry != nullptr; entry = zip->next_file()) - if (entry->uncompressed_length != 0) - { - // decompress data into RAM and identify it - dynamic_buffer data(entry->uncompressed_length); - ziperr = zip->decompress(&data[0], entry->uncompressed_length); - if (ziperr == zip_file::error::NONE) - identify_data(entry->filename, &data[0], entry->uncompressed_length); - } - } - - // clear out any cached files - zip.reset(); - zip_file::cache_clear(); + archive.reset(); + util::archive_file::cache_clear(); } // otherwise, identify as a raw file diff --git a/src/emu/debug/debugcmd.cpp b/src/emu/debug/debugcmd.cpp index b8a7ebc4874..2e10b40356e 100644 --- a/src/emu/debug/debugcmd.cpp +++ b/src/emu/debug/debugcmd.cpp @@ -1872,6 +1872,7 @@ static void execute_dump(running_machine &machine, int ref, int params, const ch for (i = offset; i <= endoffset; i += 16) { output.clear(); + output.rdbuf()->clear(); /* print the address */ util::stream_format(output, "%0*X: ", space->logaddrchars(), (UINT32)space->byte_to_address(i)); @@ -2306,6 +2307,7 @@ static void execute_cheatlist(running_machine &machine, int ref, int params, con { active_cheat++; output.clear(); + output.rdbuf()->clear(); stream_format( output, " <cheat desc=\"Possibility %d : %0*X (%0*X)\">\n" @@ -2516,6 +2518,7 @@ static void execute_dasm(running_machine &machine, int ref, int params, const ch offs_t tempaddr; int numbytes = 0; output.clear(); + output.rdbuf()->clear(); /* print the address */ stream_format(output, "%0*X: ", space->logaddrchars(), (UINT32)space->byte_to_address(pcbyte)); diff --git a/src/emu/debug/dvbpoints.cpp b/src/emu/debug/dvbpoints.cpp index 463fc4dbe08..7da6ac4c399 100644 --- a/src/emu/debug/dvbpoints.cpp +++ b/src/emu/debug/dvbpoints.cpp @@ -240,6 +240,7 @@ void debug_view_breakpoints::view_update() if (m_visible.y > 0) { linebuf.clear(); + linebuf.rdbuf()->clear(); linebuf << "ID"; if (m_sortType == &cIndexAscending) linebuf.put('\\'); else if (m_sortType == &cIndexDescending) linebuf.put('/'); @@ -282,6 +283,7 @@ void debug_view_breakpoints::view_update() device_debug::breakpoint *const bp = m_buffer[bpi]; linebuf.clear(); + linebuf.rdbuf()->clear(); util::stream_format(linebuf, "%2X", bp->index()); pad_ostream_to_length(linebuf, tableBreaks[0]); linebuf.put(bp->enabled() ? 'X' : 'O'); diff --git a/src/emu/debug/dvwpoints.cpp b/src/emu/debug/dvwpoints.cpp index 4720f1dbf3c..8b82a6d3de0 100644 --- a/src/emu/debug/dvwpoints.cpp +++ b/src/emu/debug/dvwpoints.cpp @@ -266,6 +266,7 @@ void debug_view_watchpoints::view_update() if (m_visible.y > 0) { linebuf.clear(); + linebuf.rdbuf()->clear(); linebuf << "ID"; if (m_sortType == &cIndexAscending) linebuf.put('\\'); else if (m_sortType == &cIndexDescending) linebuf.put('/'); @@ -317,6 +318,7 @@ void debug_view_watchpoints::view_update() device_debug::watchpoint *const wp = m_buffer[wpi]; linebuf.clear(); + linebuf.rdbuf()->clear(); util::stream_format(linebuf, "%2X", wp->index()); pad_ostream_to_length(linebuf, tableBreaks[0]); linebuf.put(wp->enabled() ? 'X' : 'O'); diff --git a/src/emu/diimage.cpp b/src/emu/diimage.cpp index 216b1af1fca..f225f6cd444 100644 --- a/src/emu/diimage.cpp +++ b/src/emu/diimage.cpp @@ -158,7 +158,7 @@ void device_image_interface::device_compute_hash(hash_collection &hashes, const image_error_t device_image_interface::set_image_filename(const char *filename) { m_image_name = filename; - zippath_parent(m_working_directory, filename); + util::zippath_parent(m_working_directory, filename); m_basename.assign(m_image_name); size_t loc1 = m_image_name.find_last_of('\\'); @@ -319,7 +319,7 @@ bool device_image_interface::try_change_working_directory(const char *subdir) /* did we successfully identify the directory? */ if (success) - zippath_combine(m_working_directory, m_working_directory.c_str(), subdir); + util::zippath_combine(m_working_directory, m_working_directory.c_str(), subdir); return success; } @@ -611,7 +611,7 @@ image_error_t device_image_interface::load_image_by_path(UINT32 open_flags, cons std::string revised_path; /* attempt to read the file */ - auto const filerr = zippath_fopen(path, open_flags, m_file, revised_path); + auto const filerr = util::zippath_fopen(path, open_flags, m_file, revised_path); /* did the open succeed? */ switch(filerr) @@ -663,7 +663,7 @@ int device_image_interface::reopen_for_write(const char *path) std::string revised_path; /* attempt to open the file for writing*/ - auto const filerr = zippath_fopen(path, OPEN_FLAG_READ|OPEN_FLAG_WRITE|OPEN_FLAG_CREATE, m_file, revised_path); + auto const filerr = util::zippath_fopen(path, OPEN_FLAG_READ|OPEN_FLAG_WRITE|OPEN_FLAG_CREATE, m_file, revised_path); /* did the open succeed? */ switch(filerr) diff --git a/src/emu/drivers/xtal.h b/src/emu/drivers/xtal.h index 476db5e99ab..f9e56c65931 100644 --- a/src/emu/drivers/xtal.h +++ b/src/emu/drivers/xtal.h @@ -56,6 +56,7 @@ enum XTAL_2_4576MHz = 2457600, /* Atari ST MFP, NEC PC-98xx */ XTAL_2_5MHz = 2500000, /* Janken Man units */ XTAL_3MHz = 3000000, /* Probably only used to drive 68705 or similar MCUs on 80's Taito PCBs */ + XTAL_3_072MHz = 3072000, /* INS 8520 input clock rate */ XTAL_3_12MHz = 3120000, /* SP0250 clock on Gottlieb games */ XTAL_3_5MHz = 3500000, /* Reported by Commodore 65 document, true xtal unchecked on PCB */ XTAL_3_52128MHz = 3521280, /* RCA COSMAC VIP */ diff --git a/src/emu/fileio.cpp b/src/emu/fileio.cpp index e0d7cdd7772..812f2a7007f 100644 --- a/src/emu/fileio.cpp +++ b/src/emu/fileio.cpp @@ -10,7 +10,6 @@ #include "emu.h" #include "unzip.h" -#include "un7z.h" #include "fileio.h" @@ -146,8 +145,6 @@ emu_file::emu_file(UINT32 openflags) m_openflags(openflags), m_zipfile(nullptr), m_ziplength(0), - m__7zfile(), - m__7zlength(0), m_remove_on_close(false), m_restrict_to_mediapath(false) { @@ -164,8 +161,6 @@ emu_file::emu_file(const char *searchpath, UINT32 openflags) m_openflags(openflags), m_zipfile(nullptr), m_ziplength(0), - m__7zfile(), - m__7zlength(0), m_remove_on_close(false), m_restrict_to_mediapath(false) { @@ -228,12 +223,6 @@ hash_collection &emu_file::hashes(const char *types) return m_hashes; // if we have ZIP data, just hash that directly - if (!m__7zdata.empty()) - { - m_hashes.compute(&m__7zdata[0], m__7zdata.size(), needed.c_str()); - return m_hashes; - } - if (!m_zipdata.empty()) { m_hashes.compute(&m_zipdata[0], m_zipdata.size(), needed.c_str()); @@ -338,7 +327,7 @@ osd_file::error emu_file::open_next() while (m_iterator.next(m_fullpath, m_filename.c_str())) { // attempt to open the file directly - filerr = util::core_file::open(m_fullpath.c_str(), m_openflags, m_file); + filerr = util::core_file::open(m_fullpath, m_openflags, m_file); if (filerr == osd_file::error::NONE) break; @@ -386,11 +375,9 @@ osd_file::error emu_file::open_ram(const void *data, UINT32 length) void emu_file::close() { // close files and free memory - m__7zfile.reset(); m_zipfile.reset(); m_file.reset(); - m__7zdata.clear(); m_zipdata.clear(); if (m_remove_on_close) @@ -423,10 +410,7 @@ osd_file::error emu_file::compress(int level) bool emu_file::compressed_file_ready(void) { // load the ZIP file now if we haven't yet - if (m__7zfile != nullptr && load__7zped_file() != osd_file::error::NONE) - return true; - - if (m_zipfile != nullptr && load_zipped_file() != osd_file::error::NONE) + if (m_zipfile && (load_zipped_file() != osd_file::error::NONE)) return true; return false; @@ -493,9 +477,6 @@ bool emu_file::eof() UINT64 emu_file::size() { // use the ZIP length if present - if (m__7zfile != nullptr) - return m__7zlength; - if (m_zipfile != nullptr) return m_ziplength; @@ -676,44 +657,37 @@ osd_file::error emu_file::attempt_zipped() m_fullpath = m_fullpath.substr(0, dirsep).append(".zip"); // attempt to open the ZIP file - zip_file::ptr zip; - zip_file::error ziperr = zip_file::open(m_fullpath, zip); + util::archive_file::ptr zip; + util::archive_file::error ziperr = util::archive_file::open_zip(m_fullpath, zip); // chop the .zip back off the filename before continuing m_fullpath = m_fullpath.substr(0, dirsep); // if we failed to open this file, continue scanning - if (ziperr != zip_file::error::NONE) + if (ziperr != util::archive_file::error::NONE) continue; + int header = -1; + // see if we can find a file with the right name and (if available) crc - const zip_file::file_header *header; - for (header = zip->first_file(); header != nullptr; header = zip->next_file()) - if (zip_filename_match(*header, filename) && (!(m_openflags & OPEN_FLAG_HAS_CRC) || header->crc == m_crc)) - break; + if (m_openflags & OPEN_FLAG_HAS_CRC) header = zip->search(m_crc, filename); // if that failed, look for a file with the right crc, but the wrong filename - if (header == nullptr && (m_openflags & OPEN_FLAG_HAS_CRC)) - for (header = zip->first_file(); header != nullptr; header = zip->next_file()) - if (header->crc == m_crc && !zip_header_is_path(*header)) - break; + if (header < 0 && (m_openflags & OPEN_FLAG_HAS_CRC)) header = zip->search(m_crc); // if that failed, look for a file with the right name; reporting a bad checksum // is more helpful and less confusing than reporting "rom not found" - if (header == nullptr) - for (header = zip->first_file(); header != nullptr; header = zip->next_file()) - if (zip_filename_match(*header, filename)) - break; + if (header < 0) header = zip->search(filename); // if we got it, read the data - if (header != nullptr) + if (header >= 0) { m_zipfile = std::move(zip); - m_ziplength = header->uncompressed_length; + m_ziplength = m_zipfile->current_uncompressed_length(); // build a hash with just the CRC m_hashes.reset(); - m_hashes.add_crc(header->crc); + m_hashes.add_crc(m_zipfile->current_crc()); return (m_openflags & OPEN_FLAG_NO_PRELOAD) ? osd_file::error::NONE : load_zipped_file(); } @@ -724,64 +698,6 @@ osd_file::error emu_file::attempt_zipped() //------------------------------------------------- -// load_zipped_file - load a ZIPped file -//------------------------------------------------- - -osd_file::error emu_file::load_zipped_file() -{ - assert(m_file == nullptr); - assert(m_zipdata.empty()); - assert(m_zipfile != nullptr); - - // allocate some memory - m_zipdata.resize(m_ziplength); - - // read the data into our buffer and return - zip_file::error ziperr = m_zipfile->decompress(&m_zipdata[0], m_zipdata.size()); - if (ziperr != zip_file::error::NONE) - { - m_zipdata.clear(); - return osd_file::error::FAILURE; - } - - // convert to RAM file - osd_file::error filerr = util::core_file::open_ram(&m_zipdata[0], m_zipdata.size(), m_openflags, m_file); - if (filerr != osd_file::error::NONE) - { - m_zipdata.clear(); - return osd_file::error::FAILURE; - } - - // close out the ZIP file - m_zipfile.reset(); - return osd_file::error::NONE; -} - - -//------------------------------------------------- -// zip_filename_match - compare zip filename -// to expected filename, ignoring any directory -//------------------------------------------------- - -bool emu_file::zip_filename_match(const zip_file::file_header &header, const std::string &filename) -{ - const char *zipfile = header.filename + header.filename_length - filename.length(); - return (zipfile >= header.filename && core_stricmp(filename.c_str(),zipfile) == 0 && (zipfile == header.filename || zipfile[-1] == '/')); -} - - -//------------------------------------------------- -// zip_header_is_path - check whether filename -// in header is a path -//------------------------------------------------- - -bool emu_file::zip_header_is_path(const zip_file::file_header &header) -{ - const char *zipfile = header.filename + header.filename_length - 1; - return (zipfile >= header.filename && zipfile[0] == '/'); -} - -//------------------------------------------------- // attempt__7zped - attempt to open a .7z file //------------------------------------------------- @@ -810,14 +726,14 @@ osd_file::error emu_file::attempt__7zped() m_fullpath = m_fullpath.substr(0, dirsep).append(".7z"); // attempt to open the _7Z file - _7z_file::ptr _7z; - _7z_file::error _7zerr = _7z_file::open(m_fullpath, _7z); + util::archive_file::ptr _7z; + util::archive_file::error _7zerr = util::archive_file::open_7z(m_fullpath, _7z); // chop the ._7z back off the filename before continuing m_fullpath = m_fullpath.substr(0, dirsep); // if we failed to open this file, continue scanning - if (_7zerr != _7z_file::error::NONE) + if (_7zerr != util::archive_file::error::NONE) continue; int fileno = -1; @@ -826,21 +742,21 @@ osd_file::error emu_file::attempt__7zped() if (m_openflags & OPEN_FLAG_HAS_CRC) fileno = _7z->search(m_crc, filename); // if that failed, look for a file with the right crc, but the wrong filename - if ((fileno == -1) && (m_openflags & OPEN_FLAG_HAS_CRC)) fileno = _7z->search(m_crc); + if ((fileno < 0) && (m_openflags & OPEN_FLAG_HAS_CRC)) fileno = _7z->search(m_crc); // if that failed, look for a file with the right name; reporting a bad checksum // is more helpful and less confusing than reporting "rom not found" - if (fileno == -1) fileno = _7z->search(filename); + if (fileno < 0) fileno = _7z->search(filename); - if (fileno != -1) + if (fileno >= 0) { - m__7zfile = std::move(_7z); - m__7zlength = m__7zfile->current_uncompressed_length(); + m_zipfile = std::move(_7z); + m_ziplength = m_zipfile->current_uncompressed_length(); // build a hash with just the CRC m_hashes.reset(); - m_hashes.add_crc(m__7zfile->current_crc()); - return (m_openflags & OPEN_FLAG_NO_PRELOAD) ? osd_file::error::NONE : load__7zped_file(); + m_hashes.add_crc(m_zipfile->current_crc()); + return (m_openflags & OPEN_FLAG_NO_PRELOAD) ? osd_file::error::NONE : load_zipped_file(); } // close up the _7Z file and try the next level @@ -850,35 +766,35 @@ osd_file::error emu_file::attempt__7zped() //------------------------------------------------- -// load__7zped_file - load a _7Zped file +// load_zipped_file - load a ZIPped file //------------------------------------------------- -osd_file::error emu_file::load__7zped_file() +osd_file::error emu_file::load_zipped_file() { assert(m_file == nullptr); - assert(m__7zdata.empty()); - assert(m__7zfile); + assert(m_zipdata.empty()); + assert(m_zipfile); // allocate some memory - m__7zdata.resize(m__7zlength); + m_zipdata.resize(m_ziplength); // read the data into our buffer and return - _7z_file::error _7zerr = m__7zfile->decompress(&m__7zdata[0], m__7zdata.size()); - if (_7zerr != _7z_file::error::NONE) + auto const ziperr = m_zipfile->decompress(&m_zipdata[0], m_zipdata.size()); + if (ziperr != util::archive_file::error::NONE) { - m__7zdata.clear(); + m_zipdata.clear(); return osd_file::error::FAILURE; } // convert to RAM file - osd_file::error filerr = util::core_file::open_ram(&m__7zdata[0], m__7zdata.size(), m_openflags, m_file); + osd_file::error filerr = util::core_file::open_ram(&m_zipdata[0], m_zipdata.size(), m_openflags, m_file); if (filerr != osd_file::error::NONE) { - m__7zdata.clear(); + m_zipdata.clear(); return osd_file::error::FAILURE; } - // close out the _7Z file - m__7zfile.reset(); + // close out the ZIP file + m_zipfile.reset(); return osd_file::error::NONE; } diff --git a/src/emu/fileio.h b/src/emu/fileio.h index c54c740d686..a29372f071d 100644 --- a/src/emu/fileio.h +++ b/src/emu/fileio.h @@ -15,7 +15,6 @@ #include "corefile.h" #include "hash.h" -#include "unzip.h" // some systems use macros for getc/putc rather than functions #ifdef getc @@ -27,7 +26,7 @@ //************************************************************************** // forward declarations -class _7z_file; +namespace util { class archive_file; } // ======================> path_iterator @@ -146,12 +145,8 @@ private: // internal helpers osd_file::error attempt_zipped(); - osd_file::error load_zipped_file(); - bool zip_filename_match(const zip_file::file_header &header, const std::string &filename); - bool zip_header_is_path(const zip_file::file_header &header); - osd_file::error attempt__7zped(); - osd_file::error load__7zped_file(); + osd_file::error load_zipped_file(); // internal state std::string m_filename; // original filename provided @@ -163,14 +158,10 @@ private: UINT32 m_openflags; // flags we used for the open hash_collection m_hashes; // collection of hashes - zip_file::ptr m_zipfile; // ZIP file pointer + std::unique_ptr<util::archive_file> m_zipfile; // ZIP file pointer dynamic_buffer m_zipdata; // ZIP file data UINT64 m_ziplength; // ZIP file length - std::unique_ptr<_7z_file> m__7zfile; // 7Z file pointer - dynamic_buffer m__7zdata; // 7Z file data - UINT64 m__7zlength; // 7Z file length - bool m_remove_on_close; // flag: remove the file when closing bool m_restrict_to_mediapath; // flag: restrict to paths inside the media-path }; diff --git a/src/emu/machine.cpp b/src/emu/machine.cpp index 00db05b59c3..825843c4b10 100644 --- a/src/emu/machine.cpp +++ b/src/emu/machine.cpp @@ -440,7 +440,7 @@ int running_machine::run(bool firstrun) // call all exit callbacks registered call_notifiers(MACHINE_NOTIFY_EXIT); - zip_file::cache_clear(); + util::archive_file::cache_clear(); // close the logfile m_logfile.reset(); diff --git a/src/emu/render.cpp b/src/emu/render.cpp index ec84b67a741..abe7ee87cc7 100644 --- a/src/emu/render.cpp +++ b/src/emu/render.cpp @@ -1768,29 +1768,39 @@ void render_target::add_container_primitives(render_primitive_list &list, const // set the palette prim->texture.palette = curitem->texture()->get_adjusted_palette(container); - // determine UV coordinates and apply clipping + // determine UV coordinates prim->texcoords = oriented_texcoords[finalorient]; + + // apply clipping clipped = render_clip_quad(&prim->bounds, &cliprect, &prim->texcoords); // apply the final orientation from the quad flags and then build up the final flags - prim->flags = (curitem->flags() & ~(PRIMFLAG_TEXORIENT_MASK | PRIMFLAG_BLENDMODE_MASK | PRIMFLAG_TEXFORMAT_MASK)) | - PRIMFLAG_TEXORIENT(finalorient) | - PRIMFLAG_TEXFORMAT(curitem->texture()->format()); - if (blendmode != -1) - prim->flags |= PRIMFLAG_BLENDMODE(blendmode); - else - prim->flags |= PRIMFLAG_BLENDMODE(PRIMFLAG_GET_BLENDMODE(curitem->flags())); + prim->flags = (curitem->flags() & ~(PRIMFLAG_TEXORIENT_MASK | PRIMFLAG_BLENDMODE_MASK | PRIMFLAG_TEXFORMAT_MASK)) + | PRIMFLAG_TEXORIENT(finalorient) + | PRIMFLAG_TEXFORMAT(curitem->texture()->format()); + prim->flags |= blendmode != -1 + ? PRIMFLAG_BLENDMODE(blendmode) + : PRIMFLAG_BLENDMODE(PRIMFLAG_GET_BLENDMODE(curitem->flags())); } else { + if (curitem->flags() & PRIMFLAG_VECTORBUF_MASK) + { + // determine UV coordinates + prim->texcoords = oriented_texcoords[0]; + } + // adjust the color for brightness/contrast/gamma prim->color.r = container.apply_brightness_contrast_gamma_fp(prim->color.r); prim->color.g = container.apply_brightness_contrast_gamma_fp(prim->color.g); prim->color.b = container.apply_brightness_contrast_gamma_fp(prim->color.b); - // no texture -- set the basic flags + // no texture prim->texture.base = nullptr; - prim->flags = (curitem->flags() &~ PRIMFLAG_BLENDMODE_MASK) | PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA); + + // set the basic flags + prim->flags = (curitem->flags() & ~PRIMFLAG_BLENDMODE_MASK) + | PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA); // apply clipping clipped = render_clip_quad(&prim->bounds, &cliprect, nullptr); diff --git a/src/emu/render.h b/src/emu/render.h index edba69fef84..c968d2207dc 100644 --- a/src/emu/render.h +++ b/src/emu/render.h @@ -336,6 +336,8 @@ public: // getters render_primitive *next() const { return m_next; } bool packable(const INT32 pack_size) const { return (flags & PRIMFLAG_PACKABLE) && texture.base != nullptr && texture.width <= pack_size && texture.height <= pack_size; } + float get_quad_width() const { return bounds.x1 - bounds.x0; } + float get_quad_height() const { return bounds.y1 - bounds.y0; } // reset to prepare for re-use void reset(); diff --git a/src/emu/ui/auditmenu.cpp b/src/emu/ui/auditmenu.cpp index c30619be3a9..a4d7de4779b 100644 --- a/src/emu/ui/auditmenu.cpp +++ b/src/emu/ui/auditmenu.cpp @@ -1,5 +1,5 @@ // license:BSD-3-Clause -// copyright-holders:Dankan1890 +// copyright-holders:Maurizio Petrarota /********************************************************************* ui/auditmenu.cpp diff --git a/src/emu/ui/auditmenu.h b/src/emu/ui/auditmenu.h index caad05796a6..ba8c5e80631 100644 --- a/src/emu/ui/auditmenu.h +++ b/src/emu/ui/auditmenu.h @@ -1,5 +1,5 @@ // license:BSD-3-Clause -// copyright-holders:Dankan1890 +// copyright-holders:Maurizio Petrarota /*************************************************************************** ui/auditmenu.h diff --git a/src/emu/ui/barcode.cpp b/src/emu/ui/barcode.cpp index e9f779737a8..4dc734a2bd2 100644 --- a/src/emu/ui/barcode.cpp +++ b/src/emu/ui/barcode.cpp @@ -2,7 +2,7 @@ // copyright-holders:Fabio Priuli /*************************************************************************** - ui/barcode.c + ui/barcode.cpp "Barcode Reader" control diff --git a/src/emu/ui/cheatopt.cpp b/src/emu/ui/cheatopt.cpp index 9c5f91d54bc..ceb2c3301f5 100644 --- a/src/emu/ui/cheatopt.cpp +++ b/src/emu/ui/cheatopt.cpp @@ -2,7 +2,7 @@ // copyright-holders:Nicola Salmoria, Aaron Giles, Nathan Woods /********************************************************************* - ui/cheatopt.c + ui/cheatopt.cpp Internal menu for the cheat interface. diff --git a/src/emu/ui/cmddata.h b/src/emu/ui/cmddata.h index 5fa2658d2cb..31dd8c5ebd8 100644 --- a/src/emu/ui/cmddata.h +++ b/src/emu/ui/cmddata.h @@ -1,5 +1,5 @@ // license:BSD-3-Clause -// copyright-holders:Dankan1890 +// copyright-holders:Maurizio Petrarota /********************************************************************* ui/cmddata.h @@ -143,10 +143,8 @@ static rgb_t color_table[] = BUTTON_COLOR_SILVER // 8 Player Lever }; -// for color glyph #define COLOR_BUTTONS ARRAY_LENGTH(color_table) -// Follow Varialbe Defined Arraies for Game Command Tag struct fix_command_t { unsigned char glyph_char; diff --git a/src/emu/ui/cmdrender.h b/src/emu/ui/cmdrender.h index 01cc169816d..b8d0eb1571b 100644 --- a/src/emu/ui/cmdrender.h +++ b/src/emu/ui/cmdrender.h @@ -1,5 +1,5 @@ // license:BSD-3-Clause -// copyright-holders:Dankan1890 +// copyright-holders:Maurizio Petrarota /*************************************************************************** ui/cmdrender.h diff --git a/src/emu/ui/ctrlmenu.cpp b/src/emu/ui/ctrlmenu.cpp index 9e2f4c2950d..d3d743f552e 100644 --- a/src/emu/ui/ctrlmenu.cpp +++ b/src/emu/ui/ctrlmenu.cpp @@ -1,5 +1,5 @@ // license:BSD-3-Clause -// copyright-holders:Dankan1890 +// copyright-holders:Maurizio Petrarota /********************************************************************* ui/ctrlmenu.cpp diff --git a/src/emu/ui/ctrlmenu.h b/src/emu/ui/ctrlmenu.h index 4c1325071d6..0db85ee878a 100644 --- a/src/emu/ui/ctrlmenu.h +++ b/src/emu/ui/ctrlmenu.h @@ -1,5 +1,5 @@ // license:BSD-3-Clause -// copyright-holders:Dankan1890 +// copyright-holders:Maurizio Petrarota /*************************************************************************** ui/ctrlmenu.h diff --git a/src/emu/ui/custmenu.cpp b/src/emu/ui/custmenu.cpp index 85df4afcd8a..fb833c93c51 100644 --- a/src/emu/ui/custmenu.cpp +++ b/src/emu/ui/custmenu.cpp @@ -1,5 +1,5 @@ // license:BSD-3-Clause -// copyright-holders:Dankan1890 +// copyright-holders:Maurizio Petrarota /********************************************************************* ui/custmenu.cpp diff --git a/src/emu/ui/custmenu.h b/src/emu/ui/custmenu.h index d136e911164..338344dcddd 100644 --- a/src/emu/ui/custmenu.h +++ b/src/emu/ui/custmenu.h @@ -1,5 +1,5 @@ // license:BSD-3-Clause -// copyright-holders:Dankan1890 +// copyright-holders:Maurizio Petrarota /*************************************************************************** ui/custmenu.h diff --git a/src/emu/ui/custui.cpp b/src/emu/ui/custui.cpp index 14f5cefc4b6..816875131dc 100644 --- a/src/emu/ui/custui.cpp +++ b/src/emu/ui/custui.cpp @@ -1,5 +1,5 @@ // license:BSD-3-Clause -// copyright-holders:Dankan1890 +// copyright-holders:Maurizio Petrarota /********************************************************************* ui/custui.cpp diff --git a/src/emu/ui/custui.h b/src/emu/ui/custui.h index 46f42967b6a..0a2e55745c9 100644 --- a/src/emu/ui/custui.h +++ b/src/emu/ui/custui.h @@ -1,5 +1,5 @@ // license:BSD-3-Clause -// copyright-holders:Dankan1890 +// copyright-holders:Maurizio Petrarota /*************************************************************************** ui/custui.h diff --git a/src/emu/ui/datfile.cpp b/src/emu/ui/datfile.cpp index 35dfde7249d..799cdaf3823 100644 --- a/src/emu/ui/datfile.cpp +++ b/src/emu/ui/datfile.cpp @@ -1,5 +1,5 @@ // license:BSD-3-Clause -// copyright-holders:Dankan1890 +// copyright-holders:Maurizio Petrarota /*************************************************************************** ui/datfile.cpp diff --git a/src/emu/ui/datfile.h b/src/emu/ui/datfile.h index 7b38599ba21..fa5f527a635 100644 --- a/src/emu/ui/datfile.h +++ b/src/emu/ui/datfile.h @@ -1,5 +1,5 @@ // license:BSD-3-Clause -// copyright-holders:Dankan1890 +// copyright-holders:Maurizio Petrarota /*************************************************************************** ui/datfile.h diff --git a/src/emu/ui/datmenu.cpp b/src/emu/ui/datmenu.cpp index 93c776f3e51..a4d3e619ced 100644 --- a/src/emu/ui/datmenu.cpp +++ b/src/emu/ui/datmenu.cpp @@ -1,5 +1,5 @@ // license:BSD-3-Clause -// copyright-holders:Dankan1890 +// copyright-holders:Maurizio Petrarota /********************************************************************* ui/datmenu.cpp @@ -36,6 +36,8 @@ ui_menu_dats_view::ui_menu_dats_view(running_machine &machine, render_container } } m_driver = (driver == nullptr) ? &machine.system() : driver; + m_actual = 0; + m_issoft = false; init_items(); } @@ -52,8 +54,8 @@ ui_menu_dats_view::ui_menu_dats_view(running_machine &machine, render_container m_parent = swinfo->parentname; m_driver = (driver == nullptr) ? &machine.system() : driver; m_swinfo = swinfo; - - issoft = true; + m_actual = 0; + m_issoft = true; if (machine.datfile().has_software(m_list, m_short, m_parent)) m_items_list.emplace_back(_("Software History"), UI_HISTORY_LOAD, machine.datfile().rev_history()); @@ -78,15 +80,15 @@ void ui_menu_dats_view::handle() const ui_menu_event *m_event = process(MENU_FLAG_UI_DATS); if (m_event != nullptr) { - if (m_event->iptkey == IPT_UI_LEFT && actual > 0) + if (m_event->iptkey == IPT_UI_LEFT && m_actual > 0) { - actual--; + m_actual--; reset(UI_MENU_RESET_SELECT_FIRST); } - if (m_event->iptkey == IPT_UI_RIGHT && actual < m_items_list.size() - 1) + if (m_event->iptkey == IPT_UI_RIGHT && m_actual < m_items_list.size() - 1) { - actual++; + m_actual++; reset(UI_MENU_RESET_SELECT_FIRST); } } @@ -99,7 +101,7 @@ void ui_menu_dats_view::handle() void ui_menu_dats_view::populate() { machine().pause(); - (issoft == true) ? get_data_sw() : get_data(); + (m_issoft == true) ? get_data_sw() : get_data(); item_append(MENU_SEPARATOR_ITEM, nullptr, (MENU_FLAG_UI_DATS | MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW), nullptr); customtop = 2.0f * machine().ui().get_line_height() + 4.0f * UI_BOX_TB_BORDER; @@ -116,7 +118,7 @@ void ui_menu_dats_view::custom_render(void *selectedref, float top, float bottom ui_manager &mui = machine().ui(); float maxwidth = origx2 - origx1; float width; - std::string driver = (issoft == true) ? m_swinfo->longname : m_driver->description; + std::string driver = (m_issoft == true) ? m_swinfo->longname : m_driver->description; mui.draw_text_full(container, driver.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr); @@ -168,8 +170,8 @@ void ui_menu_dats_view::custom_render(void *selectedref, float top, float bottom for (auto & elem : m_items_list) { x1 += space; - rgb_t fcolor = (actual == x) ? rgb_t(0xff, 0xff, 0xff, 0x00) : UI_TEXT_COLOR; - rgb_t bcolor = (actual == x) ? rgb_t(0xff, 0xff, 0xff, 0xff) : UI_TEXT_BG_COLOR; + rgb_t fcolor = (m_actual == x) ? rgb_t(0xff, 0xff, 0xff, 0x00) : UI_TEXT_COLOR; + rgb_t bcolor = (m_actual == x) ? rgb_t(0xff, 0xff, 0xff, 0xff) : UI_TEXT_BG_COLOR; mui.draw_text_full(container, elem.label.c_str(), x1, y1, 1.0f, JUSTIFY_LEFT, WRAP_NEVER, DRAW_NONE, fcolor, bcolor, &width, nullptr); if (bcolor != UI_TEXT_BG_COLOR) @@ -184,7 +186,7 @@ void ui_menu_dats_view::custom_render(void *selectedref, float top, float bottom // bottom std::string revision; - revision.assign(_("Revision: ")).append(m_items_list[actual].revision); + revision.assign(_("Revision: ")).append(m_items_list[m_actual].revision); mui.draw_text_full(container, revision.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr); width += 2 * UI_BOX_LR_BORDER; @@ -219,7 +221,7 @@ void ui_menu_dats_view::get_data() std::vector<int> xend; std::string buffer; std::vector<std::string> m_item; - if (m_items_list[actual].option == UI_COMMAND_LOAD) + if (m_items_list[m_actual].option == UI_COMMAND_LOAD) { machine().datfile().command_sub_menu(m_driver, m_item); if (!m_item.empty()) @@ -236,7 +238,7 @@ void ui_menu_dats_view::get_data() } } else - machine().datfile().load_data_info(m_driver, buffer, m_items_list[actual].option); + machine().datfile().load_data_info(m_driver, buffer, m_items_list[m_actual].option); int totallines = machine().ui().wrap_text(container, buffer.c_str(), 0.0f, 0.0f, 1.0f - (4.0f * UI_BOX_LR_BORDER), xstart, xend); for (int x = 0; x < totallines; ++x) @@ -252,7 +254,7 @@ void ui_menu_dats_view::get_data_sw() std::vector<int> xend; std::string buffer; std::vector<std::string> m_item; - if (m_items_list[actual].option == 0) + if (m_items_list[m_actual].option == 0) buffer = m_swinfo->usage; else { diff --git a/src/emu/ui/datmenu.h b/src/emu/ui/datmenu.h index 0d2ae7d686d..10de3894816 100644 --- a/src/emu/ui/datmenu.h +++ b/src/emu/ui/datmenu.h @@ -1,5 +1,5 @@ // license:BSD-3-Clause -// copyright-holders:Dankan1890 +// copyright-holders:Maurizio Petrarota /*************************************************************************** ui/datmenu.h @@ -31,14 +31,14 @@ public: virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; private: - int actual; + int m_actual; const game_driver *m_driver; ui_software_info *m_swinfo; std::string m_list, m_short, m_long, m_parent; void get_data(); void get_data_sw(); void init_items(); - bool issoft; + bool m_issoft; struct list_items { list_items(std::string l, int i, std::string rev) { label = l; option = i; revision = rev; } diff --git a/src/emu/ui/defimg.h b/src/emu/ui/defimg.h index 43b334b8f93..bce018449d1 100644 --- a/src/emu/ui/defimg.h +++ b/src/emu/ui/defimg.h @@ -1,5 +1,6 @@ // license:BSD-3-Clause -// copyright-holders:Dankan1890 +// copyright-holders:Maurizio Petrarota + static const UINT32 no_avail_bmp[] = { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00231f20, 0x00000000, 0x00000000, 0x00000000, 0x01231f20, 0x04231f20, 0x11231f20, 0x2e231f20, 0x62231f20, 0x8e231f20, 0xb4231f20, 0xd4231f20, 0xe5231f20, 0xf2231f20, 0xfd231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xff231f20, 0xfd231f20, 0xf2231f20, 0xe5231f20, 0xd4231f20, 0xb4231f20, 0x8e231f20, 0x62231f20, 0x2e231f20, 0x11231f20, 0x04231f20, 0x01231f20, 0x00000000, 0x00000000, 0x00000000, 0x00231f20, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, diff --git a/src/emu/ui/devopt.cpp b/src/emu/ui/devopt.cpp index f7c4ea2a88c..bafb8e77114 100644 --- a/src/emu/ui/devopt.cpp +++ b/src/emu/ui/devopt.cpp @@ -2,7 +2,7 @@ // copyright-holders:Nathan Woods /********************************************************************* - ui/devopt.c + ui/devopt.cpp Internal menu for the device configuration. diff --git a/src/emu/ui/dirmenu.cpp b/src/emu/ui/dirmenu.cpp index 03260a337d9..88c701b67ef 100644 --- a/src/emu/ui/dirmenu.cpp +++ b/src/emu/ui/dirmenu.cpp @@ -55,6 +55,7 @@ static const folders_entry s_folders[] = { __("Logos"), OPTION_LOGOS_PATH, ADDING }, { __("Scores"), OPTION_SCORES_PATH, ADDING }, { __("Versus"), OPTION_VERSUS_PATH, ADDING }, + { __("Covers"), OPTION_COVER_PATH, ADDING } }; diff --git a/src/emu/ui/dirmenu.h b/src/emu/ui/dirmenu.h index 5c48d9ad696..6b68764b258 100644 --- a/src/emu/ui/dirmenu.h +++ b/src/emu/ui/dirmenu.h @@ -1,5 +1,5 @@ // license:BSD-3-Clause -// copyright-holders:Dankan1890 +// copyright-holders:Maurizio Petrarota /*************************************************************************** ui/dirmenu.h diff --git a/src/emu/ui/dsplmenu.cpp b/src/emu/ui/dsplmenu.cpp index db300830c80..d0d308d3bb9 100644 --- a/src/emu/ui/dsplmenu.cpp +++ b/src/emu/ui/dsplmenu.cpp @@ -1,5 +1,5 @@ // license:BSD-3-Clause -// copyright-holders:Dankan1890 +// copyright-holders:Maurizio Petrarota /********************************************************************* ui/dsplmenu.cpp diff --git a/src/emu/ui/dsplmenu.h b/src/emu/ui/dsplmenu.h index 814304ec6bd..69b92e3bbe0 100644 --- a/src/emu/ui/dsplmenu.h +++ b/src/emu/ui/dsplmenu.h @@ -1,5 +1,5 @@ // license:BSD-3-Clause -// copyright-holders:Dankan1890 +// copyright-holders:Maurizio Petrarota /*************************************************************************** ui/dsplmenu.h diff --git a/src/emu/ui/filemngr.cpp b/src/emu/ui/filemngr.cpp index d46199793ce..fa139e1c696 100644 --- a/src/emu/ui/filemngr.cpp +++ b/src/emu/ui/filemngr.cpp @@ -2,7 +2,7 @@ // copyright-holders:Nathan Woods /********************************************************************* - ui/filemngr.c + ui/filemngr.cpp MESS's clunky built-in file manager diff --git a/src/emu/ui/filesel.cpp b/src/emu/ui/filesel.cpp index 89658407279..7a8cd32ec94 100644 --- a/src/emu/ui/filesel.cpp +++ b/src/emu/ui/filesel.cpp @@ -2,7 +2,7 @@ // copyright-holders:Nathan Woods /*************************************************************************** - ui/filesel.c + ui/filesel.cpp MESS's clunky built-in file manager @@ -474,7 +474,7 @@ ui_menu_file_selector::file_selector_entry *ui_menu_file_selector::append_dirent } // determine the full path - zippath_combine(buffer, m_current_directory.c_str(), dirent->name); + util::zippath_combine(buffer, m_current_directory.c_str(), dirent->name); // create the file selector entry entry = append_entry( @@ -535,7 +535,7 @@ void ui_menu_file_selector::append_entry_menu_item(const file_selector_entry *en void ui_menu_file_selector::populate() { - zippath_directory *directory = nullptr; + util::zippath_directory *directory = nullptr; osd_file::error err; const osd_directory_entry *dirent; const file_selector_entry *entry; @@ -545,7 +545,7 @@ void ui_menu_file_selector::populate() const char *path = m_current_directory.c_str(); // open the directory - err = zippath_opendir(path, &directory); + err = util::zippath_opendir(path, &directory); // clear out the menu entries m_entrylist = nullptr; @@ -581,7 +581,7 @@ void ui_menu_file_selector::populate() // build the menu for each item if (err == osd_file::error::NONE) { - while((dirent = zippath_readdir(directory)) != nullptr) + while((dirent = util::zippath_readdir(directory)) != nullptr) { // append a dirent entry entry = append_dirent_entry(dirent); @@ -611,7 +611,7 @@ void ui_menu_file_selector::populate() customtop = machine().ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; if (directory != nullptr) - zippath_closedir(directory); + util::zippath_closedir(directory); } @@ -656,7 +656,7 @@ void ui_menu_file_selector::handle() case SELECTOR_ENTRY_TYPE_DRIVE: case SELECTOR_ENTRY_TYPE_DIRECTORY: // drive/directory - first check the path - err = zippath_opendir(entry->fullpath, nullptr); + err = util::zippath_opendir(entry->fullpath, nullptr); if (err != osd_file::error::NONE) { // this path is problematic; present the user with an error and bail diff --git a/src/emu/ui/icorender.h b/src/emu/ui/icorender.h index 79452bd9fca..ac942ac922e 100644 --- a/src/emu/ui/icorender.h +++ b/src/emu/ui/icorender.h @@ -1,5 +1,5 @@ // license:BSD-3-Clause -// copyright-holders:Dankan1890;Victor Laskin +// copyright-holders:Maurizio Petrarota, Victor Laskin /*************************************************************************** ui/icorender.h diff --git a/src/emu/ui/imgcntrl.cpp b/src/emu/ui/imgcntrl.cpp index f0b6f3da5b4..0b44f1f8e8c 100644 --- a/src/emu/ui/imgcntrl.cpp +++ b/src/emu/ui/imgcntrl.cpp @@ -59,12 +59,12 @@ ui_menu_control_device_image::ui_menu_control_device_image(running_machine &mach if (image->exists()) { current_file.assign(image->filename()); - zippath_parent(current_directory, current_file.c_str()); + util::zippath_parent(current_directory, current_file.c_str()); } else current_directory.assign(image->working_directory()); /* check to see if the path exists; if not clear it */ - if (zippath_opendir(current_directory.c_str(), nullptr) != osd_file::error::NONE) + if (util::zippath_opendir(current_directory.c_str(), nullptr) != osd_file::error::NONE) current_directory.clear(); } } @@ -90,7 +90,7 @@ void ui_menu_control_device_image::test_create(bool &can_create, bool &need_conf osd_dir_entry_type file_type; /* assemble the full path */ - zippath_combine(path, current_directory.c_str(), current_file.c_str()); + util::zippath_combine(path, current_directory.c_str(), current_file.c_str()); /* does a file or a directory exist at the path */ entry = osd_stat(path.c_str()); @@ -183,11 +183,11 @@ void ui_menu_control_device_image::handle() case START_FILE: { bool can_create = false; if(image->is_creatable()) { - zippath_directory *directory = nullptr; - osd_file::error err = zippath_opendir(current_directory.c_str(), &directory); - can_create = err == osd_file::error::NONE && !zippath_is_zip(directory); + util::zippath_directory *directory = nullptr; + osd_file::error err = util::zippath_opendir(current_directory.c_str(), &directory); + can_create = err == osd_file::error::NONE && !util::zippath_is_zip(directory); if(directory) - zippath_closedir(directory); + util::zippath_closedir(directory); } submenu_result = -1; ui_menu::stack_push(global_alloc_clear<ui_menu_file_selector>(machine(), container, image, current_directory, current_file, true, image->image_interface()!=nullptr, can_create, &submenu_result)); @@ -335,7 +335,7 @@ void ui_menu_control_device_image::handle() case DO_CREATE: { std::string path; - zippath_combine(path, current_directory.c_str(), current_file.c_str()); + util::zippath_combine(path, current_directory.c_str(), current_file.c_str()); int err = image->create(path.c_str(), nullptr, nullptr); if (err != 0) machine().popmessage("Error: %s", image->error()); diff --git a/src/emu/ui/info.cpp b/src/emu/ui/info.cpp index 8c202f77e91..10090c32305 100644 --- a/src/emu/ui/info.cpp +++ b/src/emu/ui/info.cpp @@ -2,7 +2,7 @@ // copyright-holders:Nicola Salmoria, Aaron Giles, Nathan Woods /*************************************************************************** - ui/info.c + ui/info.cpp System and image info screens diff --git a/src/emu/ui/info_pty.cpp b/src/emu/ui/info_pty.cpp index 06497b876bb..563b77dbff5 100644 --- a/src/emu/ui/info_pty.cpp +++ b/src/emu/ui/info_pty.cpp @@ -2,7 +2,7 @@ // copyright-holders:F.Ulivi /*************************************************************************** - ui/info_pty.c + ui/info_pty.cpp Information screen on pseudo terminals diff --git a/src/emu/ui/inifile.cpp b/src/emu/ui/inifile.cpp index ac669e03d40..33bd433a7f7 100644 --- a/src/emu/ui/inifile.cpp +++ b/src/emu/ui/inifile.cpp @@ -1,5 +1,5 @@ // license:BSD-3-Clause -// copyright-holders:Dankan1890 +// copyright-holders:Maurizio Petrarota /*************************************************************************** ui/inifile.cpp @@ -18,8 +18,8 @@ //------------------------------------------------- // GLOBAL VARIABLES //------------------------------------------------- -UINT16 inifile_manager::current_category = 0; -UINT16 inifile_manager::current_file = 0; +UINT16 inifile_manager::c_cat = 0; +UINT16 inifile_manager::c_file = 0; //------------------------------------------------- // ctor @@ -48,10 +48,6 @@ void inifile_manager::directory_scan() int length = strlen(dir->name); std::string filename(dir->name); - // skip ui_favorite file - if (!core_stricmp("ui_favorite.ini", filename.c_str())) - continue; - // check .ini file ending if ((length > 4) && dir->name[length - 4] == '.' && tolower((UINT8)dir->name[length - 3]) == 'i' && tolower((UINT8)dir->name[length - 2]) == 'n' && tolower((UINT8)dir->name[length - 1]) == 'i') @@ -103,8 +99,8 @@ void inifile_manager::load_ini_category(std::vector<int> &temp_filter) return; bool search_clones = false; - std::string filename(ini_index[current_file].name); - long offset = ini_index[current_file].category[current_category].offset; + std::string filename(ini_index[c_file].first); + long offset = ini_index[c_file].second[c_cat].second; if (!core_stricmp(filename.c_str(), "category.ini") || !core_stricmp(filename.c_str(), "alltime.ini")) search_clones = true; diff --git a/src/emu/ui/inifile.h b/src/emu/ui/inifile.h index 5c9e7ebdc65..c16617b25f1 100644 --- a/src/emu/ui/inifile.h +++ b/src/emu/ui/inifile.h @@ -1,5 +1,5 @@ // license:BSD-3-Clause -// copyright-holders:Dankan1890 +// copyright-holders:Maurizio Petrarota /*************************************************************************** ui/inifile.h @@ -22,41 +22,36 @@ class inifile_manager { public: - // category structure - struct IniCategoryIndex - { - IniCategoryIndex(std::string _name, long _offset) { name = _name; offset = _offset; } - std::string name; - long offset; - }; - - using categoryindex = std::vector<IniCategoryIndex>; - - // ini file structure - struct IniFileIndex - { - IniFileIndex(std::string _name, categoryindex _category) { name = _name; category = _category; } - std::string name; - categoryindex category; - }; - // construction/destruction inifile_manager(running_machine &machine); // getters running_machine &machine() const { return m_machine; } + std::string get_file(int file = -1) { return ((file == -1) ? ini_index[c_file].first : ini_index[file].first); } + std::string get_category(int cat = -1) { return ((cat == -1) ? ini_index[c_file].second[c_cat].first : ini_index[c_file].second[cat].first); } + size_t total() { return ini_index.size(); } + size_t cat_total() { return ini_index[c_file].second.size(); } + UINT16 &cur_file() { return c_file; } + UINT16 &cur_cat() { return c_cat; } // load games from category void load_ini_category(std::vector<int> &temp_filter); - // files indices - std::vector<IniFileIndex> ini_index; - static UINT16 current_file, current_category; - - std::string actual_file() { return ini_index[current_file].name; } - std::string actual_category() { return ini_index[current_file].category[current_category].name; } + // setters + void move_file(int d) { c_file += d; c_cat = 0; } + void move_cat(int d) { c_cat += d; } + void set_cat(int i = -1) { (i == -1) ? c_cat = 0 : c_cat = i; } + void set_file(int i = -1) { (i == -1) ? c_file = 0 : c_file = i; } private: + + // ini file structure + using categoryindex = std::vector<std::pair<std::string, long>>; + + // files indices + static UINT16 c_file, c_cat; + std::vector<std::pair<std::string, categoryindex>> ini_index; + // init category index void init_category(std::string &filename); diff --git a/src/emu/ui/inputmap.cpp b/src/emu/ui/inputmap.cpp index 5ecb4546cce..df146fcf3e1 100644 --- a/src/emu/ui/inputmap.cpp +++ b/src/emu/ui/inputmap.cpp @@ -2,7 +2,7 @@ // copyright-holders:Nicola Salmoria, Aaron Giles, Nathan Woods /********************************************************************* - ui/inputmap.c + ui/inputmap.cpp Internal menus for input mappings. diff --git a/src/emu/ui/mainmenu.cpp b/src/emu/ui/mainmenu.cpp index 0cf449e8f84..7fe16d771b0 100644 --- a/src/emu/ui/mainmenu.cpp +++ b/src/emu/ui/mainmenu.cpp @@ -2,7 +2,7 @@ // copyright-holders:Nicola Salmoria, Aaron Giles, Nathan Woods /********************************************************************* - ui/mainmenu.c + ui/mainmenu.cpp Internal MAME menus for the user interface. diff --git a/src/emu/ui/menu.cpp b/src/emu/ui/menu.cpp index 4682a4fc203..cee5d132eb1 100644 --- a/src/emu/ui/menu.cpp +++ b/src/emu/ui/menu.cpp @@ -35,27 +35,28 @@ struct ui_arts_info { - const char *title, *path, *addpath; + const char *title, *path; }; static const ui_arts_info arts_info[] = { - { __("Snapshots"), OPTION_SNAPSHOT_DIRECTORY, "snap" }, - { __("Cabinets"), OPTION_CABINETS_PATH, "cabinets;cabdevs" }, - { __("Control Panels"), OPTION_CPANELS_PATH, "cpanel" }, - { __("PCBs"), OPTION_PCBS_PATH, "pcb" }, - { __("Flyers"), OPTION_FLYERS_PATH, "flyers" }, - { __("Titles"), OPTION_TITLES_PATH, "titles" }, - { __("Ends"), OPTION_ENDS_PATH, "ends" }, - { __("Artwork Preview"), OPTION_ARTPREV_PATH, "artwork preview" }, - { __("Bosses"), OPTION_BOSSES_PATH, "bosses" }, - { __("Logos"), OPTION_LOGOS_PATH, "logo" }, - { __("Versus"), OPTION_VERSUS_PATH, "versus" }, - { __("Game Over"), OPTION_GAMEOVER_PATH, "gameover" }, - { __("HowTo"), OPTION_HOWTO_PATH, "howto" }, - { __("Scores"), OPTION_SCORES_PATH, "scores" }, - { __("Select"), OPTION_SELECT_PATH, "select" }, - { __("Marquees"), OPTION_MARQUEES_PATH, "marquees" }, + { __("Snapshots"), OPTION_SNAPSHOT_DIRECTORY }, + { __("Cabinets"), OPTION_CABINETS_PATH }, + { __("Control Panels"), OPTION_CPANELS_PATH }, + { __("PCBs"), OPTION_PCBS_PATH }, + { __("Flyers"), OPTION_FLYERS_PATH }, + { __("Titles"), OPTION_TITLES_PATH }, + { __("Ends"), OPTION_ENDS_PATH }, + { __("Artwork Preview"), OPTION_ARTPREV_PATH }, + { __("Bosses"), OPTION_BOSSES_PATH }, + { __("Logos"), OPTION_LOGOS_PATH }, + { __("Versus"), OPTION_VERSUS_PATH }, + { __("Game Over"), OPTION_GAMEOVER_PATH }, + { __("HowTo"), OPTION_HOWTO_PATH }, + { __("Scores"), OPTION_SCORES_PATH }, + { __("Select"), OPTION_SELECT_PATH }, + { __("Marquees"), OPTION_MARQUEES_PATH }, + { __("Covers"), OPTION_COVER_PATH }, { nullptr } }; @@ -1653,9 +1654,35 @@ void ui_menu::get_title_search(std::string &snaptext, std::string &searchstr) std::string tmp(searchstr); path_iterator path(tmp.c_str()); - std::string curpath; + std::string curpath, addpath; - path_iterator path_iter(arts_info[ui_globals::curimage_view].addpath); + if (ui_globals::curimage_view != SNAPSHOT_VIEW) + { + ui_options moptions; + for (ui_options::entry *f_entry = moptions.first(); f_entry != nullptr; f_entry = f_entry->next()) + { + const char *name = f_entry->name(); + if (name && strlen(name) && !strcmp(arts_info[ui_globals::curimage_view].path, f_entry->name())) + { + addpath = f_entry->default_value(); + break; + } + } + } + else + { + emu_options moptions; + for (emu_options::entry *f_entry = moptions.first(); f_entry != nullptr; f_entry = f_entry->next()) + { + const char *name = f_entry->name(); + if (name && strlen(name) && !strcmp(arts_info[ui_globals::curimage_view].path, f_entry->name())) + { + addpath = f_entry->default_value(); + break; + } + } + } + path_iterator path_iter(addpath.c_str()); std::string c_path; // iterate over path and add path for zipped formats diff --git a/src/emu/ui/miscmenu.cpp b/src/emu/ui/miscmenu.cpp index e11a416e01d..d890f4f4d35 100644 --- a/src/emu/ui/miscmenu.cpp +++ b/src/emu/ui/miscmenu.cpp @@ -1,8 +1,8 @@ // license:BSD-3-Clause -// copyright-holders:Nicola Salmoria, Aaron Giles, Nathan Woods,Dankan1890 +// copyright-holders:Nicola Salmoria, Aaron Giles, Nathan Woods, Maurizio Petrarota /********************************************************************* - miscmenu.c + ui/miscmenu.cpp Internal MAME menus for the user interface. @@ -634,7 +634,7 @@ void ui_menu_misc_options::populate() { // add options items for (int opt = 1; opt < ARRAY_LENGTH(m_options); ++opt) - item_append(_(m_options[opt].description), m_options[opt].status ? "On" : "Off", m_options[opt].status ? MENU_FLAG_RIGHT_ARROW : MENU_FLAG_LEFT_ARROW, (void *)(FPTR)opt); + item_append(_(m_options[opt].description), m_options[opt].status ? _("On") : _("Off"), m_options[opt].status ? MENU_FLAG_RIGHT_ARROW : MENU_FLAG_LEFT_ARROW, (void *)(FPTR)opt); item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); customtop = machine().ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER); diff --git a/src/emu/ui/moptions.cpp b/src/emu/ui/moptions.cpp index de0b627ee9f..4f41c7fbdac 100644 --- a/src/emu/ui/moptions.cpp +++ b/src/emu/ui/moptions.cpp @@ -2,7 +2,7 @@ // copyright-holders:Maurizio Petrarota /*************************************************************************** - ui/moptions.c + ui/moptions.cpp UI main options manager. @@ -19,26 +19,27 @@ const options_entry ui_options::s_option_entries[] = { // seach path options - { nullptr, nullptr, OPTION_HEADER, "UI SEARCH PATH OPTIONS" }, - { OPTION_HISTORY_PATH, "history;dats;.", OPTION_STRING, "path to history files" }, - { OPTION_EXTRAINI_PATH, "folders", OPTION_STRING, "path to extra ini files" }, - { OPTION_CABINETS_PATH, "cabinets;cabdevs", OPTION_STRING, "path to cabinets / devices image" }, - { OPTION_CPANELS_PATH, "cpanel", OPTION_STRING, "path to control panel image" }, - { OPTION_PCBS_PATH, "pcb", OPTION_STRING, "path to pcbs image" }, - { OPTION_FLYERS_PATH, "flyers", OPTION_STRING, "path to flyers image" }, - { OPTION_TITLES_PATH, "titles", OPTION_STRING, "path to titles image" }, - { OPTION_ENDS_PATH, "ends", OPTION_STRING, "path to ends image" }, - { OPTION_MARQUEES_PATH, "marquees", OPTION_STRING, "path to marquees image" }, - { OPTION_ARTPREV_PATH, "artwork preview", OPTION_STRING, "path to artwork preview image" }, - { OPTION_BOSSES_PATH, "bosses", OPTION_STRING, "path to bosses image" }, - { OPTION_LOGOS_PATH, "logo", OPTION_STRING, "path to logos image" }, - { OPTION_SCORES_PATH, "scores", OPTION_STRING, "path to scores image" }, - { OPTION_VERSUS_PATH, "versus", OPTION_STRING, "path to versus image" }, - { OPTION_GAMEOVER_PATH, "gameover", OPTION_STRING, "path to gameover image" }, - { OPTION_HOWTO_PATH, "howto", OPTION_STRING, "path to howto image" }, - { OPTION_SELECT_PATH, "select", OPTION_STRING, "path to select image" }, - { OPTION_ICONS_PATH, "icons", OPTION_STRING, "path to ICOns image" }, - { OPTION_UI_PATH, "ui", OPTION_STRING, "path to UI files" }, + { nullptr, nullptr, OPTION_HEADER, "UI SEARCH PATH OPTIONS" }, + { OPTION_HISTORY_PATH, "history;dats;.", OPTION_STRING, "path to history files" }, + { OPTION_EXTRAINI_PATH, "folders", OPTION_STRING, "path to extra ini files" }, + { OPTION_CABINETS_PATH, "cabinets;cabdevs", OPTION_STRING, "path to cabinets / devices image" }, + { OPTION_CPANELS_PATH, "cpanel", OPTION_STRING, "path to control panel image" }, + { OPTION_PCBS_PATH, "pcb", OPTION_STRING, "path to pcbs image" }, + { OPTION_FLYERS_PATH, "flyers", OPTION_STRING, "path to flyers image" }, + { OPTION_TITLES_PATH, "titles", OPTION_STRING, "path to titles image" }, + { OPTION_ENDS_PATH, "ends", OPTION_STRING, "path to ends image" }, + { OPTION_MARQUEES_PATH, "marquees", OPTION_STRING, "path to marquees image" }, + { OPTION_ARTPREV_PATH, "artwork preview;artpreview", OPTION_STRING, "path to artwork preview image" }, + { OPTION_BOSSES_PATH, "bosses", OPTION_STRING, "path to bosses image" }, + { OPTION_LOGOS_PATH, "logo", OPTION_STRING, "path to logos image" }, + { OPTION_SCORES_PATH, "scores", OPTION_STRING, "path to scores image" }, + { OPTION_VERSUS_PATH, "versus", OPTION_STRING, "path to versus image" }, + { OPTION_GAMEOVER_PATH, "gameover", OPTION_STRING, "path to gameover image" }, + { OPTION_HOWTO_PATH, "howto", OPTION_STRING, "path to howto image" }, + { OPTION_SELECT_PATH, "select", OPTION_STRING, "path to select image" }, + { OPTION_ICONS_PATH, "icons", OPTION_STRING, "path to ICOns image" }, + { OPTION_COVER_PATH, "covers", OPTION_STRING, "path to software cover image" }, + { OPTION_UI_PATH, "ui", OPTION_STRING, "path to UI files" }, // misc options { nullptr, nullptr, OPTION_HEADER, "UI MISC OPTIONS" }, diff --git a/src/emu/ui/moptions.h b/src/emu/ui/moptions.h index 9706dcda7f5..55d800651f4 100644 --- a/src/emu/ui/moptions.h +++ b/src/emu/ui/moptions.h @@ -1,5 +1,5 @@ // license:BSD-3-Clause -// copyright-holders:Dankan1890 +// copyright-holders:Maurizio Petrarota /*************************************************************************** ui/moptions.h @@ -34,6 +34,7 @@ #define OPTION_HOWTO_PATH "howto_directory" #define OPTION_SELECT_PATH "select_directory" #define OPTION_ICONS_PATH "icons_directory" +#define OPTION_COVER_PATH "covers_directory" #define OPTION_UI_PATH "ui_path" // core misc options @@ -95,6 +96,7 @@ public: const char *howto_directory() const { return value(OPTION_HOWTO_PATH); } const char *select_directory() const { return value(OPTION_SELECT_PATH); } const char *icons_directory() const { return value(OPTION_ICONS_PATH); } + const char *covers_directory() const { return value(OPTION_COVER_PATH); } const char *ui_path() const { return value(OPTION_UI_PATH); } // Misc options diff --git a/src/emu/ui/optsmenu.cpp b/src/emu/ui/optsmenu.cpp index c80ad0ad00e..a87de984694 100644 --- a/src/emu/ui/optsmenu.cpp +++ b/src/emu/ui/optsmenu.cpp @@ -91,26 +91,24 @@ void ui_menu_game_options::handle() { if (m_event->iptkey == IPT_UI_LEFT) { - machine().inifile().current_file--; - machine().inifile().current_category = 0; + machine().inifile().move_file(-1); changed = true; } else if (m_event->iptkey == IPT_UI_RIGHT) { - machine().inifile().current_file++; - machine().inifile().current_category = 0; + machine().inifile().move_file(1); changed = true; } else if (m_event->iptkey == IPT_UI_SELECT) { inifile_manager &ifile = machine().inifile(); - int total = ifile.ini_index.size(); + int total = ifile.total(); std::vector<std::string> s_sel(total); - machine().inifile().current_category = 0; + machine().inifile().set_cat(0); for (size_t index = 0; index < total; ++index) - s_sel[index] = ifile.ini_index[index].name; + s_sel[index] = ifile.get_file(index); - ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(machine(), container, s_sel, ifile.current_file, SELECTOR_INIFILE)); + ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(machine(), container, s_sel, ifile.cur_file(), SELECTOR_INIFILE)); } break; } @@ -118,24 +116,23 @@ void ui_menu_game_options::handle() { if (m_event->iptkey == IPT_UI_LEFT) { - machine().inifile().current_category--; + machine().inifile().move_cat(-1); changed = true; } else if (m_event->iptkey == IPT_UI_RIGHT) { - machine().inifile().current_category++; + machine().inifile().move_cat(1); changed = true; } else if (m_event->iptkey == IPT_UI_SELECT) { inifile_manager &ifile = machine().inifile(); - int cfile = ifile.current_file; - int total = ifile.ini_index[cfile].category.size(); + int total = ifile.cat_total(); std::vector<std::string> s_sel(total); for (int index = 0; index < total; ++index) - s_sel[index] = ifile.ini_index[cfile].category[index].name; + s_sel[index] = ifile.get_category(index); - ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(machine(), container, s_sel, ifile.current_category, SELECTOR_CATEGORY)); + ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(machine(), container, s_sel, ifile.cur_cat(), SELECTOR_CATEGORY)); } break; } @@ -217,20 +214,19 @@ void ui_menu_game_options::populate() item_append(_("Filter"), main_filters::text[m_main], arrow_flags, (void *)(FPTR)FILTER_MENU); // add category subitem - if (m_main == FILTER_CATEGORY && !machine().inifile().ini_index.empty()) + if (m_main == FILTER_CATEGORY && machine().inifile().total() > 0) { inifile_manager &inif = machine().inifile(); - int afile = inif.current_file; - arrow_flags = get_arrow_flags(0, inif.ini_index.size() - 1, afile); + arrow_flags = get_arrow_flags(0, inif.total() - 1, inif.cur_file()); fbuff = _(" ^!File"); convert_command_glyph(fbuff); - item_append(fbuff.c_str(), inif.actual_file().c_str(), arrow_flags, (void *)(FPTR)FILE_CATEGORY_FILTER); + item_append(fbuff.c_str(), inif.get_file().c_str(), arrow_flags, (void *)(FPTR)FILE_CATEGORY_FILTER); - arrow_flags = get_arrow_flags(0, inif.ini_index[afile].category.size() - 1, inif.current_category); + arrow_flags = get_arrow_flags(0, inif.cat_total() - 1, inif.cur_cat()); fbuff = _(" ^!Category"); convert_command_glyph(fbuff); - item_append(fbuff.c_str(), inif.actual_category().c_str(), arrow_flags, (void *)(FPTR)CATEGORY_FILTER); + item_append(fbuff.c_str(), inif.get_category().c_str(), arrow_flags, (void *)(FPTR)CATEGORY_FILTER); } // add manufacturer subitem else if (m_main == FILTER_MANUFACTURER && c_mnfct::ui.size() > 0) diff --git a/src/emu/ui/selector.cpp b/src/emu/ui/selector.cpp index 5f1704b79fe..af199b1cfe8 100644 --- a/src/emu/ui/selector.cpp +++ b/src/emu/ui/selector.cpp @@ -1,8 +1,8 @@ // license:BSD-3-Clause -// copyright-holders:Dankan1890 +// copyright-holders:Maurizio Petrarota /********************************************************************* - ui/m_selector.cpp + ui/selector.cpp Internal UI user interface. @@ -66,13 +66,13 @@ void ui_menu_selector::handle() switch (m_category) { case SELECTOR_INIFILE: - machine().inifile().current_file = m_selector; - machine().inifile().current_category = 0; + machine().inifile().set_file(m_selector); + machine().inifile().set_cat(0); ui_menu::menu_stack->parent->reset(UI_MENU_RESET_REMEMBER_REF); break; case SELECTOR_CATEGORY: - machine().inifile().current_category = m_selector; + machine().inifile().set_cat(m_selector); ui_menu::menu_stack->parent->reset(UI_MENU_RESET_REMEMBER_REF); break; diff --git a/src/emu/ui/selector.h b/src/emu/ui/selector.h index b2ccba2a8b6..6809729396d 100644 --- a/src/emu/ui/selector.h +++ b/src/emu/ui/selector.h @@ -1,5 +1,5 @@ // license:BSD-3-Clause -// copyright-holders:Dankan1890 +// copyright-holders:Maurizio Petrarota /*************************************************************************** ui/selector.h diff --git a/src/emu/ui/selgame.cpp b/src/emu/ui/selgame.cpp index 567b0f0605c..39480dd0b79 100644 --- a/src/emu/ui/selgame.cpp +++ b/src/emu/ui/selgame.cpp @@ -194,6 +194,7 @@ ui_menu_select_game::ui_menu_select_game(running_machine &machine, render_contai ui_globals::switch_image = false; ui_globals::default_image = true; ui_globals::panels_status = moptions.hide_panels(); + m_searchlist[0] = nullptr; } //------------------------------------------------- @@ -810,12 +811,12 @@ void ui_menu_select_game::custom_render(void *selectedref, float top, float bott m_isabios); std::string filtered; - if (main_filters::actual == FILTER_CATEGORY && !machine().inifile().ini_index.empty()) + if (main_filters::actual == FILTER_CATEGORY && machine().inifile().total() > 0) { filtered = string_format(_("%1$s (%2$s - %3$s) - "), main_filters::text[main_filters::actual], - machine().inifile().actual_file(), - machine().inifile().actual_category()); + machine().inifile().get_file(), + machine().inifile().get_category()); } else if (main_filters::actual == FILTER_MANUFACTURER) { @@ -1097,7 +1098,7 @@ void ui_menu_select_game::inkey_select(const ui_menu_event *m_event) } } - std::vector<s_bios> biosname; + s_bios biosname; if (!machine().ui().options().skip_bios_menu() && has_multiple_bios(driver, biosname)) ui_menu::stack_push(global_alloc_clear<ui_bios_selection>(machine(), container, biosname, (void *)driver, false, false)); else @@ -1154,7 +1155,7 @@ void ui_menu_select_game::inkey_select_favorite(const ui_menu_event *m_event) // if everything looks good, schedule the new driver if (summary == media_auditor::CORRECT || summary == media_auditor::BEST_AVAILABLE || summary == media_auditor::NONE_NEEDED) { - std::vector<s_bios> biosname; + s_bios biosname; if (!mopt.skip_bios_menu() && has_multiple_bios(ui_swinfo->driver, biosname)) ui_menu::stack_push(global_alloc_clear<ui_bios_selection>(machine(), container, biosname, (void *)ui_swinfo->driver, false, false)); else @@ -1187,7 +1188,7 @@ void ui_menu_select_game::inkey_select_favorite(const ui_menu_event *m_event) media_auditor::summary summary = auditor.audit_software(swlist->list_name(), swinfo, AUDIT_VALIDATE_FAST); if (summary == media_auditor::CORRECT || summary == media_auditor::BEST_AVAILABLE || summary == media_auditor::NONE_NEEDED) { - std::vector<s_bios> biosname; + s_bios biosname; if (!mopt.skip_bios_menu() && has_multiple_bios(ui_swinfo->driver, biosname)) { ui_menu::stack_push(global_alloc_clear<ui_bios_selection>(machine(), container, biosname, (void *)ui_swinfo, true, false)); @@ -1195,7 +1196,7 @@ void ui_menu_select_game::inkey_select_favorite(const ui_menu_event *m_event) } else if (!mopt.skip_parts_menu() && swinfo->has_multiple_parts(ui_swinfo->interface.c_str())) { - std::unordered_map<std::string, std::string> parts; + s_parts parts; for (const software_part *swpart = swinfo->first_part(); swpart != nullptr; swpart = swpart->next()) { if (swpart->matches_interface(ui_swinfo->interface.c_str())) diff --git a/src/emu/ui/selgame.h b/src/emu/ui/selgame.h index b099f45c796..474aa57ed8a 100644 --- a/src/emu/ui/selgame.h +++ b/src/emu/ui/selgame.h @@ -1,5 +1,5 @@ // license:BSD-3-Clause -// copyright-holders:Dankan1890 +// copyright-holders:Maurizio Petrarota /*************************************************************************** ui/selgame.h diff --git a/src/emu/ui/selsoft.cpp b/src/emu/ui/selsoft.cpp index 0f0e0da4a6b..b20a35415f0 100644 --- a/src/emu/ui/selsoft.cpp +++ b/src/emu/ui/selsoft.cpp @@ -1,5 +1,5 @@ // license:BSD-3-Clause -// copyright-holders:Dankan1890 +// copyright-holders:Maurizio Petrarota /*************************************************************************** ui/selsoft.cpp @@ -86,7 +86,7 @@ bool compare_software(ui_software_info a, ui_software_info b) // get bios count //------------------------------------------------- -bool has_multiple_bios(const game_driver *driver, std::vector<s_bios> &biosname) +bool has_multiple_bios(const game_driver *driver, s_bios &biosname) { if (driver->rom == nullptr) return 0; @@ -901,7 +901,7 @@ void ui_menu_select_software::inkey_select(const ui_menu_event *m_event) if (ui_swinfo->startempty == 1) { - std::vector<s_bios> biosname; + s_bios biosname; if (!mopt.skip_bios_menu() && has_multiple_bios(ui_swinfo->driver, biosname)) ui_menu::stack_push(global_alloc_clear<ui_bios_selection>(machine(), container, biosname, (void *)ui_swinfo->driver, false, true)); else @@ -929,7 +929,7 @@ void ui_menu_select_software::inkey_select(const ui_menu_event *m_event) if (summary == media_auditor::CORRECT || summary == media_auditor::BEST_AVAILABLE || summary == media_auditor::NONE_NEEDED) { - std::vector<s_bios> biosname; + s_bios biosname; if (!mopt.skip_bios_menu() && has_multiple_bios(ui_swinfo->driver, biosname)) { ui_menu::stack_push(global_alloc_clear<ui_bios_selection>(machine(), container, biosname, (void *)ui_swinfo, true, false)); @@ -937,7 +937,7 @@ void ui_menu_select_software::inkey_select(const ui_menu_event *m_event) } else if (!mopt.skip_parts_menu() && swinfo->has_multiple_parts(ui_swinfo->interface.c_str())) { - std::unordered_map<std::string, std::string> parts; + s_parts parts; for (const software_part *swpart = swinfo->first_part(); swpart != nullptr; swpart = swpart->next()) { if (swpart->matches_interface(ui_swinfo->interface.c_str())) @@ -1926,7 +1926,7 @@ void ui_menu_select_software::draw_right_panel(void *selectedref, float origx1, // ctor //------------------------------------------------- -ui_software_parts::ui_software_parts(running_machine &machine, render_container *container, std::unordered_map<std::string, std::string> parts, ui_software_info *ui_info) : ui_menu(machine, container) +ui_software_parts::ui_software_parts(running_machine &machine, render_container *container, s_parts parts, ui_software_info *ui_info) : ui_menu(machine, container) { m_parts = parts; m_uiinfo = ui_info; @@ -2019,7 +2019,7 @@ void ui_software_parts::custom_render(void *selectedref, float top, float bottom // ctor //------------------------------------------------- -ui_bios_selection::ui_bios_selection(running_machine &machine, render_container *container, std::vector<s_bios> biosname, void *_driver, bool _software, bool _inlist) : ui_menu(machine, container) +ui_bios_selection::ui_bios_selection(running_machine &machine, render_container *container, s_bios biosname, void *_driver, bool _software, bool _inlist) : ui_menu(machine, container) { m_bios = biosname; m_driver = _driver; @@ -2042,7 +2042,7 @@ ui_bios_selection::~ui_bios_selection() void ui_bios_selection::populate() { for (auto & elem : m_bios) - item_append(elem.name.c_str(), nullptr, 0, (void *)&elem.name); + item_append(elem.first.c_str(), nullptr, 0, (void *)&elem.first); item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); customtop = machine().ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER); @@ -2059,7 +2059,7 @@ void ui_bios_selection::handle() emu_options &moptions = machine().options(); if (event != nullptr && event->iptkey == IPT_UI_SELECT && event->itemref != nullptr) for (auto & elem : m_bios) - if ((void*)&elem.name == event->itemref) + if ((void*)&elem.first == event->itemref) { if (!m_software) { @@ -2075,7 +2075,7 @@ void ui_bios_selection::handle() } std::string error; - moptions.set_value("bios", elem.id, OPTION_PRIORITY_CMDLINE, error); + moptions.set_value("bios", elem.second, OPTION_PRIORITY_CMDLINE, error); machine().manager().schedule_new_driver(*s_driver); machine().schedule_hard_reset(); ui_menu::stack_reset(machine()); @@ -2084,14 +2084,14 @@ void ui_bios_selection::handle() { ui_software_info *ui_swinfo = (ui_software_info *)m_driver; std::string error; - machine().options().set_value("bios", elem.id, OPTION_PRIORITY_CMDLINE, error); + machine().options().set_value("bios", elem.second, OPTION_PRIORITY_CMDLINE, error); driver_enumerator drivlist(machine().options(), *ui_swinfo->driver); drivlist.next(); software_list_device *swlist = software_list_device::find_by_name(drivlist.config(), ui_swinfo->listname.c_str()); software_info *swinfo = swlist->find(ui_swinfo->shortname.c_str()); if (!machine().ui().options().skip_parts_menu() && swinfo->has_multiple_parts(ui_swinfo->interface.c_str())) { - std::unordered_map<std::string, std::string> parts; + s_parts parts; for (const software_part *swpart = swinfo->first_part(); swpart != nullptr; swpart = swpart->next()) { if (swpart->matches_interface(ui_swinfo->interface.c_str())) diff --git a/src/emu/ui/selsoft.h b/src/emu/ui/selsoft.h index afb28c48134..a3d121f52c7 100644 --- a/src/emu/ui/selsoft.h +++ b/src/emu/ui/selsoft.h @@ -14,12 +14,8 @@ #include "ui/custmenu.h" -struct s_bios -{ - s_bios(std::string _name, int _id) { name = _name; id = _id; } - std::string name; - int id; -}; +using s_bios = std::vector<std::pair<std::string, int>>; +using s_parts = std::unordered_map<std::string, std::string>; // Menu Class class ui_menu_select_software : public ui_menu @@ -69,7 +65,7 @@ private: class ui_software_parts : public ui_menu { public: - ui_software_parts(running_machine &machine, render_container *container, std::unordered_map<std::string, std::string> parts, ui_software_info *ui_info); + ui_software_parts(running_machine &machine, render_container *container, s_parts parts, ui_software_info *ui_info); virtual ~ui_software_parts(); virtual void populate() override; virtual void handle() override; @@ -77,13 +73,13 @@ public: private: ui_software_info *m_uiinfo; - std::unordered_map<std::string, std::string> m_parts; + s_parts m_parts; }; class ui_bios_selection : public ui_menu { public: - ui_bios_selection(running_machine &machine, render_container *container, std::vector<s_bios> biosname, void *driver, bool software, bool inlist); + ui_bios_selection(running_machine &machine, render_container *container, s_bios biosname, void *driver, bool software, bool inlist); virtual ~ui_bios_selection(); virtual void populate() override; virtual void handle() override; @@ -91,9 +87,9 @@ public: private: - void *m_driver; - bool m_software, m_inlist; - std::vector<s_bios> m_bios; + void *m_driver; + bool m_software, m_inlist; + s_bios m_bios; }; struct reselect_last @@ -108,7 +104,7 @@ private: }; // Getter -bool has_multiple_bios(const game_driver *driver, std::vector<s_bios> &biosname); +bool has_multiple_bios(const game_driver *driver, s_bios &biosname); #endif /* __UI_SELSOFT_H__ */ diff --git a/src/emu/ui/sliders.cpp b/src/emu/ui/sliders.cpp index d53ad402943..b339eaef37b 100644 --- a/src/emu/ui/sliders.cpp +++ b/src/emu/ui/sliders.cpp @@ -2,7 +2,7 @@ // copyright-holders:Nicola Salmoria, Aaron Giles, Nathan Woods /********************************************************************* - miscmenu.c + ui/sliders.cpp Internal MAME menus for the user interface. diff --git a/src/emu/ui/slotopt.cpp b/src/emu/ui/slotopt.cpp index a67c217c7f1..c4fd58f754f 100644 --- a/src/emu/ui/slotopt.cpp +++ b/src/emu/ui/slotopt.cpp @@ -2,7 +2,7 @@ // copyright-holders:Nicola Salmoria, Aaron Giles, Nathan Woods /********************************************************************* - ui/slotopt.c + ui/slotopt.cpp Internal menu for the slot options. diff --git a/src/emu/ui/sndmenu.cpp b/src/emu/ui/sndmenu.cpp index ab1731e6589..dd3e717d98a 100644 --- a/src/emu/ui/sndmenu.cpp +++ b/src/emu/ui/sndmenu.cpp @@ -1,5 +1,5 @@ // license:BSD-3-Clause -// copyright-holders:Dankan1890 +// copyright-holders:Maurizio Petrarota /********************************************************************* ui/sndmenu.cpp diff --git a/src/emu/ui/sndmenu.h b/src/emu/ui/sndmenu.h index 8b13b38ea88..24bb0a79277 100644 --- a/src/emu/ui/sndmenu.h +++ b/src/emu/ui/sndmenu.h @@ -1,5 +1,5 @@ // license:BSD-3-Clause -// copyright-holders:Dankan1890 +// copyright-holders:Maurizio Petrarota /*************************************************************************** ui/sndmenu.h diff --git a/src/emu/ui/starimg.h b/src/emu/ui/starimg.h index 2704e486e5b..f57ebb8797f 100644 --- a/src/emu/ui/starimg.h +++ b/src/emu/ui/starimg.h @@ -1,5 +1,6 @@ // license:BSD-3-Clause -// copyright-holders:Dankan1890 +// copyright-holders:Maurizio Petrarota + static const UINT32 favorite_star_bmp[] = { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, diff --git a/src/emu/ui/swlist.cpp b/src/emu/ui/swlist.cpp index 2d4891d5673..3c2595389b2 100644 --- a/src/emu/ui/swlist.cpp +++ b/src/emu/ui/swlist.cpp @@ -2,7 +2,7 @@ // copyright-holders:Nicola Salmoria, Aaron Giles, Nathan Woods /********************************************************************* - ui/swlist.c + ui/swlist.cpp Internal MAME user interface for software list. diff --git a/src/emu/ui/tapectrl.cpp b/src/emu/ui/tapectrl.cpp index 0362f0c8a84..510d0eb3fb3 100644 --- a/src/emu/ui/tapectrl.cpp +++ b/src/emu/ui/tapectrl.cpp @@ -2,7 +2,7 @@ // copyright-holders:Nicola Salmoria, Aaron Giles, Nathan Woods /*************************************************************************** - ui/tapectrl.c + ui/tapectrl.cpp Tape control diff --git a/src/emu/ui/ui.cpp b/src/emu/ui/ui.cpp index a265e74c7b1..549784cf971 100644 --- a/src/emu/ui/ui.cpp +++ b/src/emu/ui/ui.cpp @@ -2,7 +2,7 @@ // copyright-holders:Nicola Salmoria, Aaron Giles, Nathan Woods /********************************************************************* - ui.c + ui.cpp Functions used to handle MAME's user interface. diff --git a/src/emu/ui/utils.h b/src/emu/ui/utils.h index 5c1485e102b..d6087131285 100644 --- a/src/emu/ui/utils.h +++ b/src/emu/ui/utils.h @@ -1,5 +1,5 @@ // license:BSD-3-Clause -// copyright-holders:Dankan1890 +// copyright-holders:Maurizio Petrarota /*************************************************************************** ui/utils.h diff --git a/src/emu/ui/videoopt.cpp b/src/emu/ui/videoopt.cpp index 6ba6aa710f3..388ee07981b 100644 --- a/src/emu/ui/videoopt.cpp +++ b/src/emu/ui/videoopt.cpp @@ -2,7 +2,7 @@ // copyright-holders:Nicola Salmoria, Aaron Giles, Nathan Woods /********************************************************************* - ui/videoopt.c + ui/videoopt.cpp Internal menus for video options diff --git a/src/ldplayer/ldplayer.cpp b/src/ldplayer/ldplayer.cpp index 4f16ba130b8..5129b334448 100644 --- a/src/ldplayer/ldplayer.cpp +++ b/src/ldplayer/ldplayer.cpp @@ -195,8 +195,8 @@ chd_file *ldplayer_state::get_disc() { // open the file itself via our search path emu_file image_file(machine().options().media_path(), OPEN_FLAG_READ); - file_error filerr = image_file.open(dir->name); - if (filerr == FILERR_NONE) + osd_file::error filerr = image_file.open(dir->name); + if (filerr == osd_file::error::NONE) { std::string fullpath(image_file.fullpath()); image_file.close(); diff --git a/src/lib/util/cdrom.cpp b/src/lib/util/cdrom.cpp index bd48a73d8d8..da3d921ae4a 100644 --- a/src/lib/util/cdrom.cpp +++ b/src/lib/util/cdrom.cpp @@ -244,7 +244,7 @@ cdrom_file *cdrom_open(const char *inputfile) for (i = 0; i < file->cdtoc.numtrks; i++) { - osd_file::error filerr = util::core_file::open(file->track_info.track[i].fname.c_str(), OPEN_FLAG_READ, file->fhandle[i]); + osd_file::error filerr = util::core_file::open(file->track_info.track[i].fname, OPEN_FLAG_READ, file->fhandle[i]); if (filerr != osd_file::error::NONE) { fprintf(stderr, "Unable to open file: %s\n", file->track_info.track[i].fname.c_str()); diff --git a/src/lib/util/corefile.cpp b/src/lib/util/corefile.cpp index 5c16d886fe3..e3d34ec3738 100644 --- a/src/lib/util/corefile.cpp +++ b/src/lib/util/corefile.cpp @@ -1084,7 +1084,7 @@ osd_file::error core_osd_file::osd_or_zlib_write(void const *buffer, std::uint64 return an error code -------------------------------------------------*/ -osd_file::error core_file::open(char const *filename, std::uint32_t openflags, ptr &file) +osd_file::error core_file::open(std::string const &filename, std::uint32_t openflags, ptr &file) { try { @@ -1190,7 +1190,7 @@ core_file::~core_file() pointer -------------------------------------------------*/ -osd_file::error core_file::load(char const *filename, void **data, std::uint32_t &length) +osd_file::error core_file::load(std::string const &filename, void **data, std::uint32_t &length) { ptr file; @@ -1219,7 +1219,7 @@ osd_file::error core_file::load(char const *filename, void **data, std::uint32_t return osd_file::error::NONE; } -osd_file::error core_file::load(char const *filename, dynamic_buffer &data) +osd_file::error core_file::load(std::string const &filename, dynamic_buffer &data) { ptr file; diff --git a/src/lib/util/corefile.h b/src/lib/util/corefile.h index e66545440c2..8f71832411f 100644 --- a/src/lib/util/corefile.h +++ b/src/lib/util/corefile.h @@ -48,7 +48,7 @@ public: // ----- file open/close ----- // open a file with the specified filename - static osd_file::error open(const char *filename, std::uint32_t openflags, ptr &file); + static osd_file::error open(std::string const &filename, std::uint32_t openflags, ptr &file); // open a RAM-based "file" using the given data and length (read-only) static osd_file::error open_ram(const void *data, std::size_t length, std::uint32_t openflags, ptr &file); @@ -100,8 +100,8 @@ public: virtual const void *buffer() = 0; // open a file with the specified filename, read it into memory, and return a pointer - static osd_file::error load(const char *filename, void **data, std::uint32_t &length); - static osd_file::error load(const char *filename, dynamic_buffer &data); + static osd_file::error load(std::string const &filename, void **data, std::uint32_t &length); + static osd_file::error load(std::string const &filename, dynamic_buffer &data); // ----- file write ----- diff --git a/src/lib/util/un7z.cpp b/src/lib/util/un7z.cpp index b05e4623e57..bca825c1f71 100644 --- a/src/lib/util/un7z.cpp +++ b/src/lib/util/un7z.cpp @@ -10,7 +10,7 @@ // this is based on unzip.c, with modifications needed to use the 7zip library -#include "un7z.h" +#include "unzip.h" #include "corestr.h" #include "unicode.h" @@ -19,15 +19,18 @@ #include "lzma/C/7zCrc.h" #include "lzma/C/7zVersion.h" +#include <algorithm> #include <array> #include <cassert> #include <cstdio> #include <cstdlib> #include <cstring> +#include <mutex> #include <utility> #include <vector> +namespace util { namespace { /*************************************************************************** TYPE DEFINITIONS @@ -98,6 +101,7 @@ public: static ptr find_cached(const std::string &filename) { + std::lock_guard<std::mutex> guard(s_cache_mutex); for (std::size_t cachenum = 0; cachenum < s_cache.size(); cachenum++) { // if we have a valid entry and it matches our filename, use it and remove from the cache @@ -114,10 +118,11 @@ public: static void cache_clear() { // clear call cache entries + std::lock_guard<std::mutex> guard(s_cache_mutex); for (std::size_t cachenum = 0; cachenum < s_cache.size(); s_cache[cachenum++].reset()) { } } - _7z_file::error initialize(); + archive_file::error initialize(); int first_file() { return search(0, 0, std::string(), false, false); } int next_file() { return (m_curr_file_idx < 0) ? -1 : search(m_curr_file_idx + 1, 0, std::string(), false, false); } @@ -126,11 +131,12 @@ public: int search(const std::string &filename) { return search(0, 0, filename, false, true); } int search(std::uint32_t crc, const std::string &filename) { return search(0, crc, filename, true, true); } + bool current_is_directory() const { return m_curr_is_dir; } const std::string ¤t_name() const { return m_curr_name; } std::uint64_t current_uncompressed_length() const { return m_curr_length; } std::uint32_t current_crc() const { return m_curr_crc; } - _7z_file::error decompress(void *buffer, std::uint32_t length); + archive_file::error decompress(void *buffer, std::uint32_t length); private: m7z_file_impl(const m7z_file_impl &) = delete; @@ -143,10 +149,12 @@ private: static constexpr std::size_t CACHE_SIZE = 8; static std::array<ptr, CACHE_SIZE> s_cache; + static std::mutex s_cache_mutex; const std::string m_filename; // copy of _7Z filename (for caching) int m_curr_file_idx; // current file index + bool m_curr_is_dir; // current file is directory std::string m_curr_name; // current file name std::uint64_t m_curr_length; // current file uncompressed length std::uint32_t m_curr_crc; // current file crc @@ -170,7 +178,7 @@ private: }; -class m7z_file_wrapper : public _7z_file +class m7z_file_wrapper : public archive_file { public: m7z_file_wrapper(m7z_file_impl::ptr &&impl) : m_impl(std::move(impl)) { assert(m_impl); } @@ -183,6 +191,7 @@ public: virtual int search(const std::string &filename) override { return m_impl->search(filename); } virtual int search(std::uint32_t crc, const std::string &filename) override { return m_impl->search(crc, filename); } + virtual bool current_is_directory() const override { return m_impl->current_is_directory(); } virtual const std::string ¤t_name() const override { return m_impl->current_name(); } virtual std::uint64_t current_uncompressed_length() const override { return m_impl->current_uncompressed_length(); } virtual std::uint32_t current_crc() const override { return m_impl->current_crc(); } @@ -200,6 +209,7 @@ private: ***************************************************************************/ std::array<m7z_file_impl::ptr, m7z_file_impl::CACHE_SIZE> m7z_file_impl::s_cache; +std::mutex m7z_file_impl::s_cache_mutex; @@ -250,6 +260,7 @@ CFileInStream::CFileInStream() m7z_file_impl::m7z_file_impl(const std::string &filename) : m_filename(filename) , m_curr_file_idx(-1) + , m_curr_is_dir(false) , m_curr_name() , m_curr_length(0) , m_curr_crc(0) @@ -269,11 +280,11 @@ m7z_file_impl::m7z_file_impl(const std::string &filename) } -_7z_file::error m7z_file_impl::initialize() +archive_file::error m7z_file_impl::initialize() { osd_file::error const err = osd_file::open(m_filename, OPEN_FLAG_READ, m_archive_stream.osdfile, m_archive_stream.length); if (err != osd_file::error::NONE) - return _7z_file::error::FILE_ERROR; + return archive_file::error::FILE_ERROR; LookToRead_CreateVTable(&m_look_stream, False); m_look_stream.realStream = &m_archive_stream; @@ -286,9 +297,9 @@ _7z_file::error m7z_file_impl::initialize() SRes const res = SzArEx_Open(&m_db, &m_look_stream.s, &m_alloc_imp, &m_alloc_temp_imp); if (res != SZ_OK) - return _7z_file::error::FILE_ERROR; + return archive_file::error::FILE_ERROR; - return _7z_file::error::NONE; + return archive_file::error::NONE; } @@ -305,6 +316,7 @@ void m7z_file_impl::close(ptr &&archive) archive->m_archive_stream.osdfile.reset(); // find the first NULL entry in the cache + std::lock_guard<std::mutex> guard(s_cache_mutex); std::size_t cachenum; for (cachenum = 0; cachenum < s_cache.size(); cachenum++) if (!s_cache[cachenum]) @@ -331,7 +343,7 @@ void m7z_file_impl::close(ptr &&archive) from a _7Z into the target buffer -------------------------------------------------*/ -_7z_file::error m7z_file_impl::decompress(void *buffer, std::uint32_t length) +archive_file::error m7z_file_impl::decompress(void *buffer, std::uint32_t length) { // make sure the file is open.. if (!m_archive_stream.osdfile) @@ -339,7 +351,7 @@ _7z_file::error m7z_file_impl::decompress(void *buffer, std::uint32_t length) m_archive_stream.currfpos = 0; osd_file::error const err = osd_file::open(m_filename, OPEN_FLAG_READ, m_archive_stream.osdfile, m_archive_stream.length); if (err != osd_file::error::NONE) - return _7z_file::error::FILE_ERROR; + return archive_file::error::FILE_ERROR; } size_t offset = 0; @@ -353,11 +365,11 @@ _7z_file::error m7z_file_impl::decompress(void *buffer, std::uint32_t length) &m_alloc_imp, &m_alloc_temp_imp); if (res != SZ_OK) - return _7z_file::error::FILE_ERROR; + return archive_file::error::FILE_ERROR; std::memcpy(buffer, m_out_buffer + offset, length); - return _7z_file::error::NONE; + return archive_file::error::NONE; } @@ -367,25 +379,22 @@ int m7z_file_impl::search(int i, std::uint32_t search_crc, const std::string &se { const CSzFileItem &f(m_db.db.Files[i]); - // if it's a directory entry we don't care about it.. - if (!f.IsDir) + make_utf8_name(i); + const std::uint64_t size(f.Size); + const std::uint32_t crc(f.Crc); + const bool crcmatch(crc == search_crc); + const bool namematch(!core_stricmp(search_filename.c_str(), &m_utf8_buf[0])); + + const bool found = ((!matchcrc && !matchname) || !f.IsDir) && (!matchcrc || crcmatch) && (!matchname || namematch); + if (found) { - make_utf8_name(i); - const std::uint64_t size(f.Size); - const std::uint32_t crc(f.Crc); - const bool crcmatch(crc == search_crc); - const bool namematch(core_stricmp(search_filename.c_str(), &m_utf8_buf[0]) == 0); - - const bool found = (!matchcrc || crcmatch) && (!matchname || namematch); - if (found) - { - m_curr_file_idx = i; - m_curr_name = &m_utf8_buf[0]; - m_curr_length = size; - m_curr_crc = crc; + m_curr_file_idx = i; + m_curr_is_dir = bool(f.IsDir); + m_curr_name = &m_utf8_buf[0]; + m_curr_length = size; + m_curr_crc = crc; - return i; - } + return i; } } @@ -432,17 +441,13 @@ void m7z_file_impl::make_utf8_name(int index) assert(out_pos < m_utf8_buf.size()); } m_utf8_buf[out_pos++] = '\0'; + m_utf8_buf.resize(out_pos); } } // anonymous namespace -_7z_file::~_7z_file() -{ -} - - -_7z_file::error _7z_file::open(const std::string &filename, ptr &result) +archive_file::error archive_file::open_7z(const std::string &filename, ptr &result) { // ensure we start with a NULL result result.reset(); @@ -477,7 +482,10 @@ _7z_file::error _7z_file::open(const std::string &filename, ptr &result) cache and free all memory -------------------------------------------------*/ -void _7z_file::cache_clear() +void m7z_file_cache_clear() { + // This is a trampoline called from unzip.cpp to avoid the need to have the zip and 7zip code in one file m7z_file_impl::cache_clear(); } + +} // namespace util diff --git a/src/lib/util/un7z.h b/src/lib/util/un7z.h deleted file mode 100644 index d2d2e18e25f..00000000000 --- a/src/lib/util/un7z.h +++ /dev/null @@ -1,83 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Aaron Giles, Vas Crabb -/*************************************************************************** - - un7z.h - - 7z file management. - -***************************************************************************/ - -// this is based on unzip.h, with modifications needed to use the 7zip library - -#pragma once - -#ifndef MAME_LIB_UTIL_UN7Z_H -#define MAME_LIB_UTIL_UN7Z_H - -#include "osdcore.h" - -#include <cstdint> -#include <memory> -#include <string> - - -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ - -// describes an open _7Z file -class _7z_file -{ -public: - - // Error types - enum class error - { - NONE = 0, - OUT_OF_MEMORY, - FILE_ERROR, - BAD_SIGNATURE, - DECOMPRESS_ERROR, - FILE_TRUNCATED, - FILE_CORRUPT, - UNSUPPORTED, - BUFFER_TOO_SMALL - }; - - typedef std::unique_ptr<_7z_file> ptr; - - - virtual ~_7z_file(); - - /* ----- 7Z file access ----- */ - - // open a 7Z file and parse its central directory - static error open(const std::string &filename, ptr &result); - - // clear out all open 7Z files from the cache - static void cache_clear(); - - - /* ----- contained file access ----- */ - - // iterating over files - virtual int first_file() = 0; - virtual int next_file() = 0; - - // find a file index by crc, filename or both - virtual int search(std::uint32_t crc) = 0; - virtual int search(const std::string &filename) = 0; - virtual int search(std::uint32_t crc, const std::string &filename) = 0; - - // information on most recently found file - virtual const std::string ¤t_name() const = 0; - virtual std::uint64_t current_uncompressed_length() const = 0; - virtual std::uint32_t current_crc() const = 0; - - // decompress the most recently found file in the _7Z - virtual error decompress(void *buffer, std::uint32_t length) = 0; - -}; - -#endif // MAME_LIB_UTIL_UN7Z_H diff --git a/src/lib/util/unzip.cpp b/src/lib/util/unzip.cpp index 321f4e0b69f..06ab41aae3a 100644 --- a/src/lib/util/unzip.cpp +++ b/src/lib/util/unzip.cpp @@ -8,21 +8,25 @@ ***************************************************************************/ -#include "osdcore.h" #include "unzip.h" +#include "corestr.h" +#include "osdcore.h" + + #include <algorithm> #include <array> #include <cassert> #include <cstring> #include <cstdlib> +#include <mutex> #include <utility> #include <vector> #include <zlib.h> - +namespace util { namespace { /*************************************************************************** CONSTANTS @@ -71,29 +75,8 @@ namespace { #define ZIPCRC 0x0e #define ZIPSIZE 0x12 #define ZIPUNCMP 0x16 - -/** - * @def ZIPFNLN - * - * @brief A macro that defines zipfnln. - */ - #define ZIPFNLN 0x1a - -/** - * @def ZIPXTRALN - * - * @brief A macro that defines zipxtraln. - */ - #define ZIPXTRALN 0x1c - -/** - * @def ZIPNAME - * - * @brief A macro that defines zipname. - */ - #define ZIPNAME 0x1e @@ -115,6 +98,8 @@ public: , m_cd() , m_cd_pos(0) , m_header() + , m_curr_is_dir(false) + , m_curr_name() , m_buffer() { std::memset(&m_header, 0, sizeof(m_header)); @@ -123,6 +108,7 @@ public: static ptr find_cached(const std::string &filename) { + std::lock_guard<std::mutex> guard(s_cache_mutex); for (std::size_t cachenum = 0; cachenum < s_cache.size(); cachenum++) { // if we have a valid entry and it matches our filename, use it and remove from the cache @@ -139,37 +125,65 @@ public: static void cache_clear() { // clear call cache entries + std::lock_guard<std::mutex> guard(s_cache_mutex); for (std::size_t cachenum = 0; cachenum < s_cache.size(); s_cache[cachenum++].reset()) { } } - zip_file::error initialize() + archive_file::error initialize() { // read ecd data auto const ziperr = read_ecd(); - if (ziperr != zip_file::error::NONE) + if (ziperr != archive_file::error::NONE) return ziperr; // verify that we can work with this zipfile (no disk spanning allowed) if ((m_ecd.disk_number != m_ecd.cd_start_disk_number) || (m_ecd.cd_disk_entries != m_ecd.cd_total_entries)) - return zip_file::error::UNSUPPORTED; + return archive_file::error::UNSUPPORTED; // allocate memory for the central directory try { m_cd.resize(m_ecd.cd_size + 1); } - catch (...) { return zip_file::error::OUT_OF_MEMORY; } + catch (...) { return archive_file::error::OUT_OF_MEMORY; } // read the central directory std::uint32_t read_length; auto const filerr = m_file->read(&m_cd[0], m_ecd.cd_start_disk_offset, m_ecd.cd_size, read_length); if ((filerr != osd_file::error::NONE) || (read_length != m_ecd.cd_size)) - return (filerr == osd_file::error::NONE) ? zip_file::error::FILE_TRUNCATED : zip_file::error::FILE_ERROR; + return (filerr == osd_file::error::NONE) ? archive_file::error::FILE_TRUNCATED : archive_file::error::FILE_ERROR; - return zip_file::error::NONE; + return archive_file::error::NONE; } - // contained file access - const zip_file::file_header *first_file(); - const zip_file::file_header *next_file(); - zip_file::error decompress(void *buffer, std::uint32_t length); + int first_file() + { + m_cd_pos = 0; + return search(0, std::string(), false, false); + } + int next_file() + { + return search(0, std::string(), false, false); + } + int search(std::uint32_t crc) + { + m_cd_pos = 0; + return search(crc, std::string(), true, false); + } + int search(const std::string &filename) + { + m_cd_pos = 0; + return search(0, filename, false, true); + } + int search(std::uint32_t crc, const std::string &filename) + { + m_cd_pos = 0; + return search(crc, filename, true, true); + } + + bool current_is_directory() const { return m_curr_is_dir; } + const std::string ¤t_name() const { return m_curr_name; } + std::uint64_t current_uncompressed_length() const { return m_header.uncompressed_length; } + std::uint32_t current_crc() const { return m_header.crc; } + + archive_file::error decompress(void *buffer, std::uint32_t length); private: zip_file_impl(const zip_file_impl &) = delete; @@ -177,30 +191,47 @@ private: zip_file_impl &operator=(const zip_file_impl &) = delete; zip_file_impl &operator=(zip_file_impl &&) = delete; - zip_file::error reopen() + int search(std::uint32_t search_crc, const std::string &search_filename, bool matchcrc, bool matchname); + + archive_file::error reopen() { if (!m_file) { auto const filerr = osd_file::open(m_filename, OPEN_FLAG_READ, m_file, m_length); if (filerr != osd_file::error::NONE) - return zip_file::error::FILE_ERROR; + return archive_file::error::FILE_ERROR; } - return zip_file::error::NONE; + return archive_file::error::NONE; } // ZIP file parsing - zip_file::error read_ecd(); - zip_file::error get_compressed_data_offset(std::uint64_t &offset); + archive_file::error read_ecd(); + archive_file::error get_compressed_data_offset(std::uint64_t &offset); // decompression interfaces - zip_file::error decompress_data_type_0(std::uint64_t offset, void *buffer, std::uint32_t length); - zip_file::error decompress_data_type_8(std::uint64_t offset, void *buffer, std::uint32_t length); + archive_file::error decompress_data_type_0(std::uint64_t offset, void *buffer, std::uint32_t length); + archive_file::error decompress_data_type_8(std::uint64_t offset, void *buffer, std::uint32_t length); - struct file_header_int : zip_file::file_header + struct file_header { - std::uint8_t * raw; // pointer to the raw data - std::uint32_t rawlength; // length of the raw data - std::uint8_t saved; // saved byte from after filename + std::uint32_t signature; // central file header signature + std::uint16_t version_created; // version made by + std::uint16_t version_needed; // version needed to extract + std::uint16_t bit_flag; // general purpose bit flag + std::uint16_t compression; // compression method + std::uint16_t file_time; // last mod file time + std::uint16_t file_date; // last mod file date + std::uint32_t crc; // crc-32 + std::uint32_t compressed_length; // compressed size + std::uint32_t uncompressed_length; // uncompressed size + std::uint16_t filename_length; // filename length + std::uint16_t extra_field_length; // extra field length + std::uint16_t file_comment_length; // file comment length + std::uint16_t start_disk_number; // disk number start + std::uint16_t internal_attributes; // internal file attributes + std::uint32_t external_attributes; // external file attributes + std::uint32_t local_header_offset; // relative offset of local header + const char * filename; // filename }; // contains extracted end of central directory information @@ -220,9 +251,10 @@ private: std::uint32_t rawlength; // length of the raw data }; - static constexpr std::size_t DECOMPRESS_BUFSIZE = 16384; - static constexpr std::size_t CACHE_SIZE = 8; // number of open files to cache - static std::array<ptr, CACHE_SIZE> s_cache; + static constexpr std::size_t DECOMPRESS_BUFSIZE = 16384; + static constexpr std::size_t CACHE_SIZE = 8; // number of open files to cache + static std::array<ptr, CACHE_SIZE> s_cache; + static std::mutex s_cache_mutex; const std::string m_filename; // copy of ZIP filename (for caching) osd_file::ptr m_file; // OSD file handle @@ -232,20 +264,32 @@ private: std::vector<std::uint8_t> m_cd; // central directory raw data std::uint32_t m_cd_pos; // position in central directory - file_header_int m_header; // current file header + file_header m_header; // current file header + bool m_curr_is_dir; // current file is directory + std::string m_curr_name; // current file name std::array<std::uint8_t, DECOMPRESS_BUFSIZE> m_buffer; // buffer for decompression }; -class zip_file_wrapper : public zip_file +class zip_file_wrapper : public archive_file { public: zip_file_wrapper(zip_file_impl::ptr &&impl) : m_impl(std::move(impl)) { assert(m_impl); } virtual ~zip_file_wrapper() { zip_file_impl::close(std::move(m_impl)); } - virtual const file_header *first_file() override { return m_impl->first_file(); } - virtual const file_header *next_file() override { return m_impl->next_file(); } + virtual int first_file() override { return m_impl->first_file(); } + virtual int next_file() override { return m_impl->next_file(); } + + virtual int search(std::uint32_t crc) override { return m_impl->search(crc); } + virtual int search(const std::string &filename) override { return m_impl->search(filename); } + virtual int search(std::uint32_t crc, const std::string &filename) override { return m_impl->search(crc, filename); } + + virtual bool current_is_directory() const override { return m_impl->current_is_directory(); } + virtual const std::string ¤t_name() const override { return m_impl->current_name(); } + virtual std::uint64_t current_uncompressed_length() const override { return m_impl->current_uncompressed_length(); } + virtual std::uint32_t current_crc() const override { return m_impl->current_crc(); } + virtual error decompress(void *buffer, std::uint32_t length) override { return m_impl->decompress(buffer, length); } private: @@ -268,7 +312,7 @@ private: * @return The word. */ -inline UINT16 read_word(UINT8 *buf) +inline std::uint16_t read_word(std::uint8_t const *buf) { return (buf[1] << 8) | buf[0]; } @@ -283,7 +327,7 @@ inline UINT16 read_word(UINT8 *buf) * @return The double word. */ -inline UINT32 read_dword(UINT8 *buf) +inline std::uint32_t read_dword(std::uint8_t const *buf) { return (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; } @@ -296,6 +340,7 @@ inline UINT32 read_dword(UINT8 *buf) /** @brief The zip cache[ zip cache size]. */ std::array<zip_file_impl::ptr, zip_file_impl::CACHE_SIZE> zip_file_impl::s_cache; +std::mutex zip_file_impl::s_cache_mutex; @@ -320,6 +365,7 @@ void zip_file_impl::close(ptr &&zip) zip->m_file.reset(); // find the first NULL entry in the cache + std::lock_guard<std::mutex> guard(s_cache_mutex); std::size_t cachenum; for (cachenum = 0; cachenum < s_cache.size(); cachenum++) if (!s_cache[cachenum]) @@ -345,88 +391,63 @@ void zip_file_impl::close(ptr &&zip) in the ZIP -------------------------------------------------*/ -/** - * @fn const zip_file_header *zip_file_first_file(zip_file *zip) - * - * @brief Zip file first file. - * - * @param [in,out] zip If non-null, the zip. - * - * @return null if it fails, else a zip_file_header*. - */ - -const zip_file::file_header *zip_file_impl::first_file() -{ - /* reset the position and go from there */ - m_cd_pos = 0; - return next_file(); -} - - /*------------------------------------------------- zip_file_next_entry - return the next entry in the ZIP -------------------------------------------------*/ -/** - * @fn const zip_file_header *zip_file_next_file(zip_file *zip) - * - * @brief Zip file next file. - * - * @param [in,out] zip If non-null, the zip. - * - * @return null if it fails, else a zip_file_header*. - */ - -const zip_file::file_header *zip_file_impl::next_file() +int zip_file_impl::search(std::uint32_t search_crc, const std::string &search_filename, bool matchcrc, bool matchname) { - // fix up any modified data - if (m_header.raw) + // if we're at or past the end, we're done + std::string filename; + while (m_cd_pos <= m_ecd.cd_size) { - m_header.raw[ZIPCFN + m_header.filename_length] = m_header.saved; - m_header.raw = nullptr; - } + // extract file header info + std::uint8_t const *const raw = &m_cd[0] + m_cd_pos; + m_header.signature = read_dword(raw + ZIPCENSIG); + m_header.version_created = read_word (raw + ZIPCVER); + m_header.version_needed = read_word (raw + ZIPCVXT); + m_header.bit_flag = read_word (raw + ZIPCFLG); + m_header.compression = read_word (raw + ZIPCMTHD); + m_header.file_time = read_word (raw + ZIPCTIM); + m_header.file_date = read_word (raw + ZIPCDAT); + m_header.crc = read_dword(raw + ZIPCCRC); + m_header.compressed_length = read_dword(raw + ZIPCSIZ); + m_header.uncompressed_length = read_dword(raw + ZIPCUNC); + m_header.filename_length = read_word (raw + ZIPCFNL); + m_header.extra_field_length = read_word (raw + ZIPCXTL); + m_header.file_comment_length = read_word (raw + ZIPCCML); + m_header.start_disk_number = read_word (raw + ZIPDSK); + m_header.internal_attributes = read_word (raw + ZIPINT); + m_header.external_attributes = read_dword(raw + ZIPEXT); + m_header.local_header_offset = read_dword(raw + ZIPOFST); + m_header.filename = reinterpret_cast<const char *>(raw + ZIPCFN); + + // make sure we have enough data + std::uint32_t const rawlength = ZIPCFN + m_header.filename_length + m_header.extra_field_length + m_header.file_comment_length; + if ((m_cd_pos + rawlength) > m_ecd.cd_size) + break; - // if we're at or past the end, we're done - if (m_cd_pos >= m_ecd.cd_size) - return nullptr; - - // extract file header info - m_header.raw = &m_cd[0] + m_cd_pos; - m_header.rawlength = ZIPCFN; - m_header.signature = read_dword(m_header.raw + ZIPCENSIG); - m_header.version_created = read_word (m_header.raw + ZIPCVER); - m_header.version_needed = read_word (m_header.raw + ZIPCVXT); - m_header.bit_flag = read_word (m_header.raw + ZIPCFLG); - m_header.compression = read_word (m_header.raw + ZIPCMTHD); - m_header.file_time = read_word (m_header.raw + ZIPCTIM); - m_header.file_date = read_word (m_header.raw + ZIPCDAT); - m_header.crc = read_dword(m_header.raw + ZIPCCRC); - m_header.compressed_length = read_dword(m_header.raw + ZIPCSIZ); - m_header.uncompressed_length = read_dword(m_header.raw + ZIPCUNC); - m_header.filename_length = read_word (m_header.raw + ZIPCFNL); - m_header.extra_field_length = read_word (m_header.raw + ZIPCXTL); - m_header.file_comment_length = read_word (m_header.raw + ZIPCCML); - m_header.start_disk_number = read_word (m_header.raw + ZIPDSK); - m_header.internal_attributes = read_word (m_header.raw + ZIPINT); - m_header.external_attributes = read_dword(m_header.raw + ZIPEXT); - m_header.local_header_offset = read_dword(m_header.raw + ZIPOFST); - m_header.filename = reinterpret_cast<const char *>(m_header.raw + ZIPCFN); - - // make sure we have enough data - m_header.rawlength += m_header.filename_length; - m_header.rawlength += m_header.extra_field_length; - m_header.rawlength += m_header.file_comment_length; - if (m_cd_pos + m_header.rawlength > m_ecd.cd_size) - return nullptr; - - // NULL terminate the filename - m_header.saved = m_header.raw[ZIPCFN + m_header.filename_length]; - m_header.raw[ZIPCFN + m_header.filename_length] = 0; - - // advance the position - m_cd_pos += m_header.rawlength; - return &m_header; + // advance the position + m_cd_pos += rawlength; + + // copy the filename filename + bool const is_dir((m_header.filename_length > 0) && (m_header.filename[m_header.filename_length - 1] == '/')); + filename.assign(m_header.filename, m_header.filename_length - (is_dir ? 1 : 0)); + + // check to see if it matches query + bool const crcmatch(search_crc == m_header.crc); + const bool namematch(!core_stricmp(search_filename.c_str(), filename.c_str())); + + bool const found = ((!matchcrc && !matchname) || !is_dir) && (!matchcrc || crcmatch) && (!matchname || namematch); + if (found) + { + m_curr_is_dir = is_dir; + m_curr_name = std::move(filename); + return 0; + } + } + return -1; } @@ -447,22 +468,22 @@ const zip_file::file_header *zip_file_impl::next_file() * @return A zip_error. */ -zip_file::error zip_file_impl::decompress(void *buffer, UINT32 length) +archive_file::error zip_file_impl::decompress(void *buffer, std::uint32_t length) { - zip_file::error ziperr; + archive_file::error ziperr; std::uint64_t offset; // if we don't have enough buffer, error if (length < m_header.uncompressed_length) - return zip_file::error::BUFFER_TOO_SMALL; + return archive_file::error::BUFFER_TOO_SMALL; // make sure the info in the header aligns with what we know if (m_header.start_disk_number != m_ecd.disk_number) - return zip_file::error::UNSUPPORTED; + return archive_file::error::UNSUPPORTED; // get the compressed data offset ziperr = get_compressed_data_offset(offset); - if (ziperr != zip_file::error::NONE) + if (ziperr != archive_file::error::NONE) return ziperr; // handle compression types @@ -477,7 +498,7 @@ zip_file::error zip_file_impl::decompress(void *buffer, UINT32 length) break; default: - ziperr = zip_file::error::UNSUPPORTED; + ziperr = archive_file::error::UNSUPPORTED; break; } return ziperr; @@ -503,11 +524,11 @@ zip_file::error zip_file_impl::decompress(void *buffer, UINT32 length) * @return The ecd. */ -zip_file::error zip_file_impl::read_ecd() +archive_file::error zip_file_impl::read_ecd() { // make sure the file handle is open auto const ziperr = reopen(); - if (ziperr != zip_file::error::NONE) + if (ziperr != archive_file::error::NONE) return ziperr; // we may need multiple tries @@ -521,13 +542,13 @@ zip_file::error zip_file_impl::read_ecd() // allocate buffer std::unique_ptr<std::uint8_t []> buffer; try { buffer.reset(new std::uint8_t[buflen + 1]); } - catch (...) { return zip_file::error::OUT_OF_MEMORY; } + catch (...) { return archive_file::error::OUT_OF_MEMORY; } // read in one buffers' worth of data std::uint32_t read_length; auto const error = m_file->read(&buffer[0], m_length - buflen, buflen, read_length); if (error != osd_file::error::NONE || read_length != buflen) - return zip_file::error::FILE_ERROR; + return archive_file::error::FILE_ERROR; // find the ECD signature std::int32_t offset; @@ -556,16 +577,16 @@ zip_file::error zip_file_impl::read_ecd() m_ecd.cd_start_disk_offset = read_dword(&m_ecd.raw[ZIPEOFST]); m_ecd.comment_length = read_word (&m_ecd.raw[ZIPECOML]); m_ecd.comment = reinterpret_cast<const char *>(&m_ecd.raw[ZIPECOM]); - return zip_file::error::NONE; + return archive_file::error::NONE; } // didn't find it; free this buffer and expand our search if (buflen < m_length) buflen *= 2; else - return zip_file::error::BAD_SIGNATURE; + return archive_file::error::BAD_SIGNATURE; } - return zip_file::error::OUT_OF_MEMORY; + return archive_file::error::OUT_OF_MEMORY; } @@ -585,25 +606,25 @@ zip_file::error zip_file_impl::read_ecd() * @return The compressed data offset. */ -zip_file::error zip_file_impl::get_compressed_data_offset(std::uint64_t &offset) +archive_file::error zip_file_impl::get_compressed_data_offset(std::uint64_t &offset) { // make sure the file handle is open auto const ziperr = reopen(); - if (ziperr != zip_file::error::NONE) + if (ziperr != archive_file::error::NONE) return ziperr; // now go read the fixed-sized part of the local file header std::uint32_t read_length; auto const error = m_file->read(&m_buffer[0], m_header.local_header_offset, ZIPNAME, read_length); if (error != osd_file::error::NONE || read_length != ZIPNAME) - return (error == osd_file::error::NONE) ? zip_file::error::FILE_TRUNCATED : zip_file::error::FILE_ERROR; + return (error == osd_file::error::NONE) ? archive_file::error::FILE_TRUNCATED : archive_file::error::FILE_ERROR; /* compute the final offset */ offset = m_header.local_header_offset + ZIPNAME; offset += read_word(&m_buffer[ZIPFNLN]); offset += read_word(&m_buffer[ZIPXTRALN]); - return zip_file::error::NONE; + return archive_file::error::NONE; } @@ -630,18 +651,18 @@ zip_file::error zip_file_impl::get_compressed_data_offset(std::uint64_t &offset) * @return A zip_error. */ -zip_file::error zip_file_impl::decompress_data_type_0(std::uint64_t offset, void *buffer, std::uint32_t length) +archive_file::error zip_file_impl::decompress_data_type_0(std::uint64_t offset, void *buffer, std::uint32_t length) { std::uint32_t read_length; // the data is uncompressed; just read it auto const filerr = m_file->read(buffer, offset, m_header.compressed_length, read_length); if (filerr != osd_file::error::NONE) - return zip_file::error::FILE_ERROR; + return archive_file::error::FILE_ERROR; else if (read_length != m_header.compressed_length) - return zip_file::error::FILE_TRUNCATED; + return archive_file::error::FILE_TRUNCATED; else - return zip_file::error::NONE; + return archive_file::error::NONE; } @@ -663,14 +684,14 @@ zip_file::error zip_file_impl::decompress_data_type_0(std::uint64_t offset, void * @return A zip_error. */ -zip_file::error zip_file_impl::decompress_data_type_8(std::uint64_t offset, void *buffer, std::uint32_t length) +archive_file::error zip_file_impl::decompress_data_type_8(std::uint64_t offset, void *buffer, std::uint32_t length) { std::uint32_t input_remaining = m_header.compressed_length; int zerr; // make sure we don't need a newer mechanism if (m_header.version_needed > 0x14) - return zip_file::error::UNSUPPORTED; + return archive_file::error::UNSUPPORTED; /* reset the stream */ z_stream stream; @@ -681,7 +702,7 @@ zip_file::error zip_file_impl::decompress_data_type_8(std::uint64_t offset, void // initialize the decompressor zerr = inflateInit2(&stream, -MAX_WBITS); if (zerr != Z_OK) - return zip_file::error::DECOMPRESS_ERROR; + return archive_file::error::DECOMPRESS_ERROR; // loop until we're done while (1) @@ -692,7 +713,7 @@ zip_file::error zip_file_impl::decompress_data_type_8(std::uint64_t offset, void if (filerr != osd_file::error::NONE) { inflateEnd(&stream); - return zip_file::error::FILE_ERROR; + return archive_file::error::FILE_ERROR; } offset += read_length; @@ -700,7 +721,7 @@ zip_file::error zip_file_impl::decompress_data_type_8(std::uint64_t offset, void if (read_length == 0 && input_remaining > 0) { inflateEnd(&stream); - return zip_file::error::FILE_TRUNCATED; + return archive_file::error::FILE_TRUNCATED; } // fill out the input data @@ -719,20 +740,20 @@ zip_file::error zip_file_impl::decompress_data_type_8(std::uint64_t offset, void if (zerr != Z_OK) { inflateEnd(&stream); - return zip_file::error::DECOMPRESS_ERROR; + return archive_file::error::DECOMPRESS_ERROR; } } // finish decompression zerr = inflateEnd(&stream); if (zerr != Z_OK) - return zip_file::error::DECOMPRESS_ERROR; + return archive_file::error::DECOMPRESS_ERROR; /* if anything looks funny, report an error */ if (stream.avail_out > 0 || input_remaining > 0) - return zip_file::error::DECOMPRESS_ERROR; + return archive_file::error::DECOMPRESS_ERROR; - return zip_file::error::NONE; + return archive_file::error::NONE; } } // anonymous namespace @@ -740,6 +761,14 @@ zip_file::error zip_file_impl::decompress_data_type_8(std::uint64_t offset, void /*************************************************************************** + un7z.cpp TRAMPOLINES +***************************************************************************/ + +void m7z_file_cache_clear(); + + + +/*************************************************************************** ZIP FILE ACCESS ***************************************************************************/ @@ -758,10 +787,10 @@ zip_file::error zip_file_impl::decompress_data_type_8(std::uint64_t offset, void * @return A zip_error. */ -zip_file::error zip_file::open(const std::string &filename, ptr &zip) +archive_file::error archive_file::open_zip(const std::string &filename, ptr &result) { // ensure we start with a NULL result - zip.reset(); + result.reset(); // see if we are in the cache, and reopen if so zip_file_impl::ptr newimpl(zip_file_impl::find_cached(filename)); @@ -777,7 +806,7 @@ zip_file::error zip_file::open(const std::string &filename, ptr &zip) try { - zip = std::make_unique<zip_file_wrapper>(std::move(newimpl)); + result = std::make_unique<zip_file_wrapper>(std::move(newimpl)); return error::NONE; } catch (...) @@ -793,18 +822,15 @@ zip_file::error zip_file::open(const std::string &filename, ptr &zip) cache and free all memory -------------------------------------------------*/ -/** - * @fn void zip_file_cache_clear(void) - * - * @brief Zip file cache clear. - */ - -void zip_file::cache_clear() +void archive_file::cache_clear() { zip_file_impl::cache_clear(); + m7z_file_cache_clear(); } -zip_file::~zip_file() +archive_file::~archive_file() { } + +} // namespace util diff --git a/src/lib/util/unzip.h b/src/lib/util/unzip.h index 2882cda0fc3..5fafaec57a4 100644 --- a/src/lib/util/unzip.h +++ b/src/lib/util/unzip.h @@ -4,7 +4,7 @@ unzip.h - ZIP file management. + archive file management. ***************************************************************************/ @@ -20,12 +20,14 @@ #include <string> +namespace util { + /*************************************************************************** TYPE DEFINITIONS ***************************************************************************/ -// describes an open ZIP file -class zip_file +// describes an open archive file +class archive_file { public: @@ -43,55 +45,45 @@ public: BUFFER_TOO_SMALL }; - // contains extracted file header information - struct file_header - { - std::uint32_t signature; // central file header signature - std::uint16_t version_created; // version made by - std::uint16_t version_needed; // version needed to extract - std::uint16_t bit_flag; // general purpose bit flag - std::uint16_t compression; // compression method - std::uint16_t file_time; // last mod file time - std::uint16_t file_date; // last mod file date - std::uint32_t crc; // crc-32 - std::uint32_t compressed_length; // compressed size - std::uint32_t uncompressed_length; // uncompressed size - std::uint16_t filename_length; // filename length - std::uint16_t extra_field_length; // extra field length - std::uint16_t file_comment_length; // file comment length - std::uint16_t start_disk_number; // disk number start - std::uint16_t internal_attributes; // internal file attributes - std::uint32_t external_attributes; // external file attributes - std::uint32_t local_header_offset; // relative offset of local header - const char * filename; // filename - }; - - typedef std::unique_ptr<zip_file> ptr; + typedef std::unique_ptr<archive_file> ptr; - /* ----- ZIP file access ----- */ + /* ----- archive file access ----- */ // open a ZIP file and parse its central directory - static error open(const std::string &filename, ptr &zip); + static error open_zip(const std::string &filename, ptr &zip); + + // open a 7Z file and parse its central directory + static error open_7z(const std::string &filename, ptr &result); - // close a ZIP file (may actually be left open due to caching) - virtual ~zip_file(); + // close an archive file (may actually be left open due to caching) + virtual ~archive_file(); - // clear out all open ZIP files from the cache + // clear out all open files from the cache static void cache_clear(); /* ----- contained file access ----- */ - // find the first file in the ZIP - virtual const file_header *first_file() = 0; + // iterating over files - returns negative on reaching end + virtual int first_file() = 0; + virtual int next_file() = 0; + + // find a file index by crc, filename or both - returns non-negative on match + virtual int search(std::uint32_t crc) = 0; + virtual int search(const std::string &filename) = 0; + virtual int search(std::uint32_t crc, const std::string &filename) = 0; - // find the next file in the ZIP - virtual const file_header *next_file() = 0; + // information on most recently found file + virtual bool current_is_directory() const = 0; + virtual const std::string ¤t_name() const = 0; + virtual std::uint64_t current_uncompressed_length() const = 0; + virtual std::uint32_t current_crc() const = 0; // decompress the most recently found file in the ZIP virtual error decompress(void *buffer, std::uint32_t length) = 0; }; +} // namespace util #endif // MAME_LIB_UTIL_UNZIP_H diff --git a/src/lib/util/vecstream.h b/src/lib/util/vecstream.h index bf144501253..fda218c3e68 100644 --- a/src/lib/util/vecstream.h +++ b/src/lib/util/vecstream.h @@ -320,11 +320,10 @@ public: basic_ivectorstream(vector_type const &content, std::ios_base::openmode mode = std::ios_base::in) : std::basic_istream<CharT, Traits>(&m_rdbuf), m_rdbuf(content, mode) { } basic_ivectorstream(vector_type &&content, std::ios_base::openmode mode = std::ios_base::in) : std::basic_istream<CharT, Traits>(&m_rdbuf), m_rdbuf(std::move(content), mode) { } - basic_vectorbuf<CharT, Traits, Allocator> *rdbuf() const { return reinterpret_cast<basic_vectorbuf<CharT, Traits, Allocator> *>(std::basic_istream<CharT, Traits>::rdbuf()); } + basic_vectorbuf<CharT, Traits, Allocator> *rdbuf() const { return static_cast<basic_vectorbuf<CharT, Traits, Allocator> *>(std::basic_istream<CharT, Traits>::rdbuf()); } vector_type const &vec() const { return rdbuf()->vec(); } void vec(const vector_type &content) { rdbuf()->vec(content); } void vec(vector_type &&content) { rdbuf()->vec(std::move(content)); } - basic_ivectorstream &clear() { rdbuf()->clear(); return *this; } void swap(basic_ivectorstream &that) { std::basic_istream<CharT, Traits>::swap(that); rdbuf()->swap(*that.rdbuf()); } @@ -342,12 +341,11 @@ public: basic_ovectorstream(vector_type const &content, std::ios_base::openmode mode = std::ios_base::out) : std::basic_ostream<CharT, Traits>(&m_rdbuf), m_rdbuf(content, mode) { } basic_ovectorstream(vector_type &&content, std::ios_base::openmode mode = std::ios_base::out) : std::basic_ostream<CharT, Traits>(&m_rdbuf), m_rdbuf(std::move(content), mode) { } - basic_vectorbuf<CharT, Traits, Allocator> *rdbuf() const { return reinterpret_cast<basic_vectorbuf<CharT, Traits, Allocator> *>(std::basic_ostream<CharT, Traits>::rdbuf()); } + basic_vectorbuf<CharT, Traits, Allocator> *rdbuf() const { return static_cast<basic_vectorbuf<CharT, Traits, Allocator> *>(std::basic_ostream<CharT, Traits>::rdbuf()); } vector_type const &vec() const { return rdbuf()->vec(); } void vec(const vector_type &content) { rdbuf()->vec(content); } void vec(vector_type &&content) { rdbuf()->vec(std::move(content)); } - basic_ovectorstream &clear() { rdbuf()->clear(); return *this; } basic_ovectorstream &reserve(typename vector_type::size_type size) { rdbuf()->reserve(size); return *this; } void swap(basic_ovectorstream &that) { std::basic_ostream<CharT, Traits>::swap(that); rdbuf()->swap(*that.rdbuf()); } @@ -366,12 +364,11 @@ public: basic_vectorstream(vector_type const &content, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) : std::basic_iostream<CharT, Traits>(&m_rdbuf), m_rdbuf(content, mode) { } basic_vectorstream(vector_type &&content, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) : std::basic_iostream<CharT, Traits>(&m_rdbuf), m_rdbuf(std::move(content), mode) { } - basic_vectorbuf<CharT, Traits, Allocator> *rdbuf() const { return reinterpret_cast<basic_vectorbuf<CharT, Traits, Allocator> *>(std::basic_iostream<CharT, Traits>::rdbuf()); } + basic_vectorbuf<CharT, Traits, Allocator> *rdbuf() const { return static_cast<basic_vectorbuf<CharT, Traits, Allocator> *>(std::basic_iostream<CharT, Traits>::rdbuf()); } vector_type const &vec() const { return rdbuf()->vec(); } void vec(const vector_type &content) { rdbuf()->vec(content); } void vec(vector_type &&content) { rdbuf()->vec(std::move(content)); } - basic_vectorstream &clear() { rdbuf()->clear(); return *this; } basic_vectorstream &reserve(typename vector_type::size_type size) { rdbuf()->reserve(size); return *this; } void swap(basic_vectorstream &that) { std::basic_iostream<CharT, Traits>::swap(that); rdbuf()->swap(*that.rdbuf()); } diff --git a/src/lib/util/zippath.cpp b/src/lib/util/zippath.cpp index 18e2031dcdd..edeecf80c47 100644 --- a/src/lib/util/zippath.cpp +++ b/src/lib/util/zippath.cpp @@ -8,15 +8,19 @@ ***************************************************************************/ -#include <ctype.h> -#include <stdlib.h> -#include <new> -#include <assert.h> #include "zippath.h" #include "unzip.h" #include "corestr.h" #include "osdcore.h" +#include <stdlib.h> + +#include <cassert> +#include <cctype> +#include <new> + + +namespace util { /*************************************************************************** TYPE DEFINITIONS @@ -66,7 +70,7 @@ public: /** @brief true to called zip first. */ bool called_zip_first; /** @brief The zipfile. */ - zip_file::ptr zipfile; + archive_file::ptr zipfile; /** @brief The zipprefix. */ std::string zipprefix; /** @brief The returned dirlist. */ @@ -78,10 +82,10 @@ public: FUNCTION PROTOTYPES ***************************************************************************/ -static const zip_file::file_header *zippath_find_sub_path(zip_file &zipfile, const char *subpath, osd_dir_entry_type *type); -static int is_zip_file(const char *path); -static int is_zip_file_separator(char c); -static int is_7z_file(const char *path); +static int zippath_find_sub_path(archive_file &zipfile, std::string const &subpath, osd_dir_entry_type &type); +static bool is_zip_file(std::string const &path); +static bool is_zip_file_separator(char c); +static bool is_7z_file(std::string const &path); /*************************************************************************** @@ -148,29 +152,15 @@ static void parse_parent_path(const char *path, int *beginpos, int *endpos) zippath_parent - retrieves the parent directory -------------------------------------------------*/ -/** - * @fn std::string &zippath_parent(std::string &dst, const char *path) - * - * @brief Zippath parent. - * - * @param [in,out] dst Destination for the. - * @param path Full pathname of the file. - * - * @return A std::string& - */ - std::string &zippath_parent(std::string &dst, const char *path) { int pos; parse_parent_path(path, &pos, nullptr); - /* return the result */ - if (pos >= 0) { + if (pos >= 0) dst.assign(path, pos + 1); - } - else { + else dst.clear(); - } return dst; } @@ -255,7 +245,7 @@ std::string &zippath_combine(std::string &dst, const char *path1, const char *pa -------------------------------------------------*/ /** - * @fn static osd_file::error file_error_from_zip_error(zip_file::error ziperr) + * @fn static osd_file::error file_error_from_zip_error(archive_file::error ziperr) * * @brief File error from zip error. * @@ -264,26 +254,26 @@ std::string &zippath_combine(std::string &dst, const char *path1, const char *pa * @return A osd_file::error. */ -static osd_file::error file_error_from_zip_error(zip_file::error ziperr) +static osd_file::error file_error_from_zip_error(archive_file::error ziperr) { osd_file::error filerr; switch(ziperr) { - case zip_file::error::NONE: + case archive_file::error::NONE: filerr = osd_file::error::NONE; break; - case zip_file::error::OUT_OF_MEMORY: + case archive_file::error::OUT_OF_MEMORY: filerr = osd_file::error::OUT_OF_MEMORY; break; - case zip_file::error::BAD_SIGNATURE: - case zip_file::error::DECOMPRESS_ERROR: - case zip_file::error::FILE_TRUNCATED: - case zip_file::error::FILE_CORRUPT: - case zip_file::error::UNSUPPORTED: - case zip_file::error::FILE_ERROR: + case archive_file::error::BAD_SIGNATURE: + case archive_file::error::DECOMPRESS_ERROR: + case archive_file::error::FILE_TRUNCATED: + case archive_file::error::FILE_CORRUPT: + case archive_file::error::UNSUPPORTED: + case archive_file::error::FILE_ERROR: filerr = osd_file::error::INVALID_DATA; break; - case zip_file::error::BUFFER_TOO_SMALL: + case archive_file::error::BUFFER_TOO_SMALL: default: filerr = osd_file::error::FAILURE; break; @@ -298,7 +288,7 @@ static osd_file::error file_error_from_zip_error(zip_file::error ziperr) -------------------------------------------------*/ /** - * @fn static osd_file::error create_core_file_from_zip(zip_file *zip, const zip_file_header *header, util::core_file::ptr &file) + * @fn static osd_file::error create_core_file_from_zip(archive_file *zip, util::core_file::ptr &file) * * @brief Creates core file from zip. * @@ -309,27 +299,27 @@ static osd_file::error file_error_from_zip_error(zip_file::error ziperr) * @return The new core file from zip. */ -static osd_file::error create_core_file_from_zip(zip_file &zip, const zip_file::file_header *header, util::core_file::ptr &file) +static osd_file::error create_core_file_from_zip(archive_file &zip, util::core_file::ptr &file) { osd_file::error filerr; - zip_file::error ziperr; + archive_file::error ziperr; void *ptr; - ptr = malloc(header->uncompressed_length); + ptr = malloc(zip.current_uncompressed_length()); if (ptr == nullptr) { filerr = osd_file::error::OUT_OF_MEMORY; goto done; } - ziperr = zip.decompress(ptr, header->uncompressed_length); - if (ziperr != zip_file::error::NONE) + ziperr = zip.decompress(ptr, zip.current_uncompressed_length()); + if (ziperr != archive_file::error::NONE) { filerr = file_error_from_zip_error(ziperr); goto done; } - filerr = util::core_file::open_ram_copy(ptr, header->uncompressed_length, OPEN_FLAG_READ, file); + filerr = util::core_file::open_ram_copy(ptr, zip.current_uncompressed_length(), OPEN_FLAG_READ, file); if (filerr != osd_file::error::NONE) goto done; @@ -360,9 +350,9 @@ done: osd_file::error zippath_fopen(const char *filename, UINT32 openflags, util::core_file::ptr &file, std::string &revised_path) { osd_file::error filerr = osd_file::error::NOT_FOUND; - zip_file::error ziperr; - zip_file::ptr zip; - const zip_file::file_header *header; + archive_file::error ziperr; + archive_file::ptr zip; + int header; osd_dir_entry_type entry_type; int len; @@ -376,11 +366,11 @@ osd_file::error zippath_fopen(const char *filename, UINT32 openflags, util::core && ((openflags == OPEN_FLAG_READ) || (subpath.length() == 0))) { /* is the mainpath a ZIP path? */ - if (is_zip_file(mainpath.c_str())) + if (is_zip_file(mainpath) || is_7z_file(mainpath)) { /* this file might be a zip file - lets take a look */ - ziperr = zip_file::open(mainpath, zip); - if (ziperr == zip_file::error::NONE) + ziperr = is_zip_file(mainpath) ? archive_file::open_zip(mainpath, zip) : archive_file::open_7z(mainpath, zip); + if (ziperr == archive_file::error::NONE) { /* it is a zip file - error if we're not opening for reading */ if (openflags != OPEN_FLAG_READ) @@ -390,34 +380,29 @@ osd_file::error zippath_fopen(const char *filename, UINT32 openflags, util::core } if (subpath.length() > 0) - header = zippath_find_sub_path(*zip, subpath.c_str(), &entry_type); + header = zippath_find_sub_path(*zip, subpath, entry_type); else header = zip->first_file(); - if (header == nullptr) + if (header < 0) { filerr = osd_file::error::NOT_FOUND; goto done; } /* attempt to read the file */ - filerr = create_core_file_from_zip(*zip, header, file); + filerr = create_core_file_from_zip(*zip, file); if (filerr != osd_file::error::NONE) goto done; /* update subpath, if appropriate */ if (subpath.length() == 0) - subpath.assign(header->filename); + subpath.assign(zip->current_name()); /* we're done */ goto done; } } - else if (is_7z_file(mainpath.c_str())) - { - filerr = osd_file::error::INVALID_DATA; - goto done; - } if (subpath.length() == 0) filerr = util::core_file::open(filename, openflags, file); @@ -523,10 +508,10 @@ static int is_root(const char *path) * @return An int. */ -static int is_7z_file(const char *path) +static bool is_7z_file(std::string const &path) { - const char *s = strrchr(path, '.'); - return (s != nullptr) && !core_stricmp(s, ".7z"); + auto const s = path.rfind('.'); + return (std::string::npos != s) && !core_stricmp(path.c_str() + s, ".7z"); } @@ -535,20 +520,10 @@ static int is_7z_file(const char *path) ZIP file -------------------------------------------------*/ -/** - * @fn static int is_zip_file(const char *path) - * - * @brief Is zip file. - * - * @param path Full pathname of the file. - * - * @return An int. - */ - -static int is_zip_file(const char *path) +static bool is_zip_file(std::string const &path) { - const char *s = strrchr(path, '.'); - return (s != nullptr) && !core_stricmp(s, ".zip"); + auto const s = path.rfind('.'); + return (std::string::npos != s) && !core_stricmp(path.c_str() + s, ".zip"); } @@ -568,7 +543,7 @@ static int is_zip_file(const char *path) * @return An int. */ -static int is_zip_file_separator(char c) +static bool is_zip_file_separator(char c) { return (c == '/') || (c == '\\'); } @@ -590,7 +565,7 @@ static int is_zip_file_separator(char c) * @return An int. */ -static int is_zip_path_separator(char c) +static bool is_zip_path_separator(char c) { return is_zip_file_separator(c) || is_path_separator(c); } @@ -613,38 +588,35 @@ static int is_zip_path_separator(char c) * @return A char. */ -static char next_path_char(const char *s, int *pos) +static char next_path_char(std::string const &s, std::string::size_type &pos) { - char result; - - /* skip over any initial separators */ - if (*pos == 0) + // skip over any initial separators + if (pos == 0) { - while(is_zip_file_separator(s[*pos])) - (*pos)++; + while ((pos < s.length()) && is_zip_file_separator(s[pos])) + pos++; } - /* are we at a path separator? */ - if (is_zip_file_separator(s[*pos])) + // are we at a path separator? + if (pos == s.length()) { - /* skip over path separators */ - while(is_zip_file_separator(s[*pos])) - (*pos)++; - - /* normalize as '/' */ - result = '/'; + // return NUL + return '\0'; } - else if (s[*pos] != '\0') + else if (is_zip_file_separator(s[pos])) { - /* return character */ - result = tolower(s[(*pos)++]); + // skip over path separators + while((pos < s.length()) && is_zip_file_separator(s[pos])) + pos++; + + // normalize as '/' + return '/'; } else { - /* return NUL */ - result = '\0'; + // return character + return std::tolower(s[pos++]); } - return result; } @@ -656,7 +628,7 @@ static char next_path_char(const char *s, int *pos) -------------------------------------------------*/ /** - * @fn static const zip_file_header *zippath_find_sub_path(zip_file *zipfile, const char *subpath, osd_dir_entry_type *type) + * @fn static const zip_file_header *zippath_find_sub_path(archive_file *zipfile, const char *subpath, osd_dir_entry_type *type) * * @brief Zippath find sub path. * @@ -667,50 +639,36 @@ static char next_path_char(const char *s, int *pos) * @return null if it fails, else a zip_file_header*. */ -static const zip_file::file_header *zippath_find_sub_path(zip_file &zipfile, const char *subpath, osd_dir_entry_type *type) +static int zippath_find_sub_path(archive_file &zipfile, std::string const &subpath, osd_dir_entry_type &type) { - int i, j; - char c1, c2, last_char; - const zip_file::file_header *header; - - for (header = zipfile.first_file(); header != nullptr; header = zipfile.next_file()) + for (int header = zipfile.first_file(); header >= 0; header = zipfile.next_file()) { - /* special case */ - if (subpath == nullptr) + std::string::size_type i = 0, j = 0; + char c1, c2; + do { - if (type != nullptr) - *type = ENTTYPE_FILE; - return header; + c1 = next_path_char(zipfile.current_name(), i); + c2 = next_path_char(subpath, j); } + while ((c1 == c2) && c1 && c2); - i = 0; - j = 0; - last_char = '/'; - while(((c1 = next_path_char(header->filename, &i)) == (c2 = next_path_char(subpath, &j))) && - ( c1 != '\0' && c2 != '\0' )) - last_char = c2; - - - if (c2 == '\0') + if (!c2 || ((c2 == '/') && !(c2 = next_path_char(subpath, j)))) { - if (c1 == '\0') + if (!c1) { - if (type != nullptr) - *type = ENTTYPE_FILE; + type = zipfile.current_is_directory() ? ENTTYPE_DIR : ENTTYPE_FILE; return header; } - else if ((last_char == '/') || (c1 == '/')) + else if ((c1 == '/') || (i <= 1U)) { - if (type != nullptr) - *type = ENTTYPE_DIR; + type = ENTTYPE_DIR; return header; } } } - if (type != nullptr) - *type = ENTTYPE_NONE; - return nullptr; + type = ENTTYPE_NONE; + return -1; } @@ -721,7 +679,7 @@ static const zip_file::file_header *zippath_find_sub_path(zip_file &zipfile, con -------------------------------------------------*/ /** - * @fn static osd_file::error zippath_resolve(const char *path, osd_dir_entry_type &entry_type, zip_file *&zipfile, std::string &newpath) + * @fn static osd_file::error zippath_resolve(const char *path, osd_dir_entry_type &entry_type, archive_file *&zipfile, std::string &newpath) * * @brief Zippath resolve. * @@ -733,94 +691,78 @@ static const zip_file::file_header *zippath_find_sub_path(zip_file &zipfile, con * @return A osd_file::error. */ -static osd_file::error zippath_resolve(const char *path, osd_dir_entry_type &entry_type, zip_file::ptr &zipfile, std::string &newpath) +static osd_file::error zippath_resolve(const char *path, osd_dir_entry_type &entry_type, archive_file::ptr &zipfile, std::string &newpath) { - osd_file::error err; - osd_directory_entry *current_entry = nullptr; - osd_dir_entry_type current_entry_type; - int went_up = FALSE; - int i; - newpath.clear(); - /* be conservative */ + // be conservative entry_type = ENTTYPE_NONE; zipfile.reset(); std::string apath(path); std::string apath_trimmed; + osd_dir_entry_type current_entry_type; + bool went_up = false; do { - /* trim the path of trailing path separators */ - i = apath.length(); - while (i > 1 && is_path_separator(apath[i - 1])) + // trim the path of trailing path separators + auto i = apath.length(); + while ((i > 1) && is_path_separator(apath[i - 1])) i--; - apath = apath.substr(0, i); - apath_trimmed.assign(apath); + apath.resize(i); + apath_trimmed = apath; - /* stat the path */ - current_entry = osd_stat(apath_trimmed.c_str()); + // stat the path + std::unique_ptr<osd_directory_entry, void (*)(void *)> current_entry(osd_stat(apath_trimmed), &osd_free); - /* did we find anything? */ - if (current_entry != nullptr) + // did we find anything? + if (current_entry) { - /* get the entry type and free the stat entry */ + // get the entry type and free the stat entry current_entry_type = current_entry->type; - osd_free(current_entry); - current_entry = nullptr; } else { - /* if we have not found the file or directory, go up */ + // if we have not found the file or directory, go up current_entry_type = ENTTYPE_NONE; - went_up = TRUE; + went_up = true; std::string parent; - apath.assign(zippath_parent(parent, apath.c_str())); + apath = zippath_parent(parent, apath.c_str()); } } - while (current_entry_type == ENTTYPE_NONE && !is_root(apath.c_str())); + while ((current_entry_type == ENTTYPE_NONE) && !is_root(apath.c_str())); - /* if we did not find anything, then error out */ + // if we did not find anything, then error out if (current_entry_type == ENTTYPE_NONE) - { - err = osd_file::error::NOT_FOUND; - goto done; - } + return osd_file::error::NOT_FOUND; - /* is this file a ZIP file? */ - if ((current_entry_type == ENTTYPE_FILE) && is_zip_file(apath_trimmed.c_str()) - && (zip_file::open(apath_trimmed, zipfile) == zip_file::error::NONE)) + // is this file a ZIP file? + if ((current_entry_type == ENTTYPE_FILE) && + ((is_zip_file(apath_trimmed) && (archive_file::open_zip(apath_trimmed, zipfile) == archive_file::error::NONE)) || + (is_7z_file(apath_trimmed) && (archive_file::open_7z(apath_trimmed, zipfile) == archive_file::error::NONE)))) { - i = strlen(path + apath.length()); - while (i > 0 && is_zip_path_separator(path[apath.length() + i - 1])) + auto i = strlen(path + apath.length()); + while ((i > 0) && is_zip_path_separator(path[apath.length() + i - 1])) i--; newpath.assign(path + apath.length(), i); - /* this was a true ZIP path - attempt to identify the type of path */ - zippath_find_sub_path(*zipfile, newpath.c_str(), ¤t_entry_type); + // this was a true ZIP path - attempt to identify the type of path + zippath_find_sub_path(*zipfile, newpath, current_entry_type); if (current_entry_type == ENTTYPE_NONE) - { - err = osd_file::error::NOT_FOUND; - goto done; - } + return osd_file::error::NOT_FOUND; } else { - /* this was a normal path */ + // this was a normal path if (went_up) - { - err = osd_file::error::NOT_FOUND; - goto done; - } - newpath.assign(path); + return osd_file::error::NOT_FOUND; + + newpath = path; } - /* success! */ + // success! entry_type = current_entry_type; - err = osd_file::error::NONE; - -done: - return err; + return osd_file::error::NONE; } @@ -868,11 +810,11 @@ osd_file::error zippath_opendir(const char *path, zippath_directory **directory) } /* was the result a ZIP? */ - if (result->zipfile == nullptr) + if (!result->zipfile) { /* a conventional directory */ result->directory = osd_opendir(path); - if (result->directory == nullptr) + if (!result->directory) { err = osd_file::error::FAILURE; goto done; @@ -943,20 +885,27 @@ void zippath_closedir(zippath_directory *directory) * @return null if it fails, else the relative path. */ -static const char *get_relative_path(zippath_directory *directory, const zip_file::file_header *header) +static const char *get_relative_path(zippath_directory const &directory) { - const char *result = nullptr; - int len = directory->zipprefix.length(); + auto len = directory.zipprefix.length(); + const char *prefix = directory.zipprefix.c_str(); + while (is_zip_file_separator(*prefix)) + { + len--; + prefix++; + } - if ((len <= strlen(header->filename)) - && !strncmp(directory->zipprefix.c_str(), header->filename, len)) + if ((len <= directory.zipfile->current_name().length()) && + !strncmp(prefix, directory.zipfile->current_name().c_str(), len)) { - result = &header->filename[len]; - while(is_zip_file_separator(*result)) + const char *result = &directory.zipfile->current_name().c_str()[len]; + while (is_zip_file_separator(*result)) result++; + + return *result ? result : nullptr; } - return result; + return nullptr; } @@ -977,7 +926,7 @@ static const char *get_relative_path(zippath_directory *directory, const zip_fil const osd_directory_entry *zippath_readdir(zippath_directory *directory) { const osd_directory_entry *result = nullptr; - const zip_file::file_header *header; + int header; const char *relpath; const char *separator; const char *s; @@ -992,7 +941,7 @@ const osd_directory_entry *zippath_readdir(zippath_directory *directory) directory->returned_entry.type = ENTTYPE_DIR; result = &directory->returned_entry; } - else if (directory->directory != nullptr) + else if (directory->directory) { /* a normal directory read */ do @@ -1002,7 +951,7 @@ const osd_directory_entry *zippath_readdir(zippath_directory *directory) while((result != nullptr) && (!strcmp(result->name, ".") || !strcmp(result->name, ".."))); /* special case - is this entry a ZIP file? if so we need to return it as a "directory" */ - if ((result != nullptr) && is_zip_file(result->name)) + if ((result != nullptr) && (is_zip_file(result->name) || is_7z_file(result->name))) { /* copy; but change the entry type */ directory->returned_entry = *result; @@ -1010,7 +959,7 @@ const osd_directory_entry *zippath_readdir(zippath_directory *directory) result = &directory->returned_entry; } } - else if (directory->zipfile != nullptr) + else if (directory->zipfile) { do { @@ -1024,7 +973,7 @@ const osd_directory_entry *zippath_readdir(zippath_directory *directory) directory->called_zip_first = true; relpath = nullptr; } - while((header != nullptr) && ((relpath = get_relative_path(directory, header)) == nullptr)); + while((header >= 0) && ((relpath = get_relative_path(*directory)) == nullptr)); if (relpath != nullptr) { @@ -1063,7 +1012,7 @@ const osd_directory_entry *zippath_readdir(zippath_directory *directory) memset(&directory->returned_entry, 0, sizeof(directory->returned_entry)); directory->returned_entry.name = relpath; directory->returned_entry.type = ENTTYPE_FILE; - directory->returned_entry.size = header->uncompressed_length; + directory->returned_entry.size = directory->zipfile->current_uncompressed_length(); result = &directory->returned_entry; } } @@ -1094,3 +1043,5 @@ int zippath_is_zip(zippath_directory *directory) { return directory->zipfile != nullptr; } + +} // namespace util diff --git a/src/lib/util/zippath.h b/src/lib/util/zippath.h index d54dd68c38d..653617d66cc 100644 --- a/src/lib/util/zippath.h +++ b/src/lib/util/zippath.h @@ -10,14 +10,16 @@ #pragma once -#ifndef __ZIPPATH_H__ -#define __ZIPPATH_H__ +#ifndef MAME_LIB_UTIL_ZIPPATH_H +#define MAME_LIB_UTIL_ZIPPATH_H #include "corefile.h" #include <string> #include "unzip.h" +namespace util { + /*************************************************************************** TYPE DEFINITIONS ***************************************************************************/ @@ -62,6 +64,7 @@ const osd_directory_entry *zippath_readdir(zippath_directory *directory); /* returns TRUE if this path is a ZIP path or FALSE if not */ int zippath_is_zip(zippath_directory *directory); +} // namespace util -#endif /* __ZIPPATH_H__ */ +#endif /* MAME_LIB_UTIL_ZIPPATH_H */ diff --git a/src/mame/drivers/angelkds.cpp b/src/mame/drivers/angelkds.cpp index db73d337800..aa6d996010b 100644 --- a/src/mame/drivers/angelkds.cpp +++ b/src/mame/drivers/angelkds.cpp @@ -22,13 +22,11 @@ for details on this encryption scheme /* notes / todo: -Decrypt Space Position Somehow (not something I -can do) Unknown Reads / Writes Whats the Prom for? nothing important? -Is the level order correct? the progress sprite on the side of the screen re-appears at the bottom when you get to the top, but the wrap-around is needed for other things, actual game bug? +Angel Kids service mode doesn't seem to work, did it ever? */ @@ -130,7 +128,7 @@ Dumped by Chackn #include "machine/segacrp2.h" #include "sound/2203intf.h" #include "includes/angelkds.h" - +#include "machine/i8255.h" @@ -146,37 +144,8 @@ WRITE8_MEMBER(angelkds_state::angelkds_cpu_bank_write) } -/*** Fake Inputs - -these make the game a bit easier for testing purposes - -*/ - -#define FAKEINPUTS 0 - -#if FAKEINPUTS - -READ8_MEMBER(angelkds_state::angelkds_input_r) -{ - int fake; - static const char *const portnames[] = { "I81", "I82" }; - static const char *const fakenames[] = { "FAKE1", "FAKE2" }; - fake = ioport(fakenames[offset])->read(); - - return ((fake & 0x01) ? fake : ioport(portnames[offset])->read()); -} - -#else - -READ8_MEMBER(angelkds_state::angelkds_input_r) -{ - static const char *const portnames[] = { "I81", "I82" }; - - return ioport(portnames[offset])->read(); -} -#endif /*** Memory Structures @@ -202,7 +171,8 @@ static ADDRESS_MAP_START( main_map, AS_PROGRAM, 8, angelkds_state ) AM_RANGE(0xe400, 0xe7ff) AM_RAM_WRITE(angelkds_bgbotvideoram_w) AM_SHARE("bgbotvideoram") /* Bottom Half of Screen */ AM_RANGE(0xe800, 0xebff) AM_RAM_WRITE(angelkds_txvideoram_w) AM_SHARE("txvideoram") AM_RANGE(0xec00, 0xecff) AM_RAM AM_SHARE("spriteram") - AM_RANGE(0xed00, 0xeeff) AM_RAM_WRITE(angelkds_paletteram_w) AM_SHARE("paletteram") + AM_RANGE(0xed00, 0xedff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette") + AM_RANGE(0xee00, 0xeeff) AM_RAM_DEVWRITE("palette", palette_device, write_ext) AM_SHARE("palette_ext") AM_RANGE(0xef00, 0xefff) AM_RAM AM_RANGE(0xf000, 0xf000) AM_WRITE(angelkds_bgtopbank_write) AM_RANGE(0xf001, 0xf001) AM_WRITE(angelkds_bgtopscroll_write) @@ -220,17 +190,17 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( main_portmap, AS_IO, 8, angelkds_state ) ADDRESS_MAP_GLOBAL_MASK(0xff) AM_RANGE(0x00, 0x00) AM_WRITENOP // 00 on start-up, not again - AM_RANGE(0x42, 0x42) AM_WRITE(angelkds_cpu_bank_write) - AM_RANGE(0x43, 0x43) AM_WRITENOP // 9a on start-up, not again - AM_RANGE(0x40, 0x40) AM_READ_PORT("I40") /* "Coinage" Dip Switches */ - AM_RANGE(0x41, 0x41) AM_READ_PORT("I41") /* Other Dip Switches */ - AM_RANGE(0x42, 0x42) AM_READ_PORT("I42") /* Players inputs (not needed ?) */ - AM_RANGE(0x80, 0x80) AM_READ_PORT("I80") /* System inputs */ - AM_RANGE(0x81, 0x82) AM_READ(angelkds_input_r) /* Players inputs */ - AM_RANGE(0x83, 0x83) AM_WRITENOP // 9b on start-up, not again + + AM_RANGE(0x40, 0x43) AM_DEVREADWRITE("ppi8255_0", i8255_device, read, write) + AM_RANGE(0x80, 0x83) AM_DEVREADWRITE("ppi8255_1", i8255_device, read, write) + AM_RANGE(0xc0, 0xc3) AM_READWRITE(angelkds_main_sound_r, angelkds_main_sound_w) // 02 various points ADDRESS_MAP_END + + + + /* sub cpu */ static ADDRESS_MAP_START( sub_map, AS_PROGRAM, 8, angelkds_state ) @@ -261,16 +231,6 @@ ADDRESS_MAP_END PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_LEFT ) PORT_PLAYER(player) PORT_8WAY \ PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_RIGHT ) PORT_PLAYER(player) PORT_8WAY -#define ANGELDSK_FAKE_PLAYERS_INPUT( player ) \ - PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(player) /* To enter initials */ \ - PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* Unused */ \ - PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(player) PORT_8WAY \ - PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(player) PORT_8WAY \ - PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(player) PORT_8WAY \ - PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(player) PORT_8WAY \ - PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(player) /* To shorten the rope and */ \ - /* move right in hiscores table */ - static INPUT_PORTS_START( angelkds ) /* @@ -339,15 +299,6 @@ static INPUT_PORTS_START( angelkds ) PORT_DIPSETTING( 0x80, DEF_STR( Hard ) ) PORT_DIPSETTING( 0x00, DEF_STR( Very_Hard ) ) - PORT_START("I42") /* inport $42 */ - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN ) // duplicated IPT_JOYSTICK_LEFTRIGHT - PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_8WAY // duplicated IPT_JOYSTICK_LEFTRIGHT - PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_8WAY PORT_COCKTAIL - PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_START("I80") /* inport $80 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 ) @@ -365,23 +316,6 @@ static INPUT_PORTS_START( angelkds ) PORT_START("I82") /* inport $82 */ ANGELDSK_PLAYERS_INPUT( 2 ) -#if FAKEINPUTS - - /* Fake inputs to allow to play the game with 1 joystick instead of 2 */ - PORT_START("FAKE1") - PORT_DIPNAME( 0x01, 0x00, "FAKE (for debug) Joysticks (Player 1)" ) - PORT_DIPSETTING( 0x01, "1" ) - PORT_DIPSETTING( 0x00, "2" ) - ANGELDSK_FAKE_PLAYERS_INPUT( 1 ) - - PORT_START("FAKE2") - PORT_DIPNAME( 0x01, 0x00, "FAKE (for debug) Joysticks (Player 2)" ) - PORT_DIPSETTING( 0x01, "1" ) - PORT_DIPSETTING( 0x00, "2" ) - ANGELDSK_FAKE_PLAYERS_INPUT( 2 ) - -#endif - INPUT_PORTS_END static INPUT_PORTS_START( spcpostn ) @@ -443,16 +377,6 @@ static INPUT_PORTS_START( spcpostn ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW2:8" ) /* Listed as "Unused" */ - PORT_START("I42") /* inport $42 */ - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_START("I80") /* inport $80 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 ) @@ -601,6 +525,16 @@ static MACHINE_CONFIG_START( angelkds, angelkds_state ) MCFG_CPU_PROGRAM_MAP(sub_map) MCFG_CPU_IO_MAP(sub_portmap) + MCFG_DEVICE_ADD("ppi8255_0", I8255A, 0) + MCFG_I8255_IN_PORTA_CB(IOPORT("I40")) + MCFG_I8255_IN_PORTB_CB(IOPORT("I41")) + MCFG_I8255_IN_PORTC_CB(READ8(angelkds_state, angeklds_ff_r)) // or left inputs don't work + MCFG_I8255_OUT_PORTC_CB(WRITE8(angelkds_state, angelkds_cpu_bank_write)) + + MCFG_DEVICE_ADD("ppi8255_1", I8255A, 0) + MCFG_I8255_IN_PORTA_CB(IOPORT("I80")) + MCFG_I8255_IN_PORTB_CB(IOPORT("I81")) + MCFG_I8255_IN_PORTC_CB(IOPORT("I82")) MCFG_QUANTUM_TIME(attotime::from_hz(6000)) @@ -615,6 +549,7 @@ static MACHINE_CONFIG_START( angelkds, angelkds_state ) MCFG_GFXDECODE_ADD("gfxdecode", "palette", angelkds) MCFG_PALETTE_ADD("palette", 0x100) + MCFG_PALETTE_FORMAT(xxxxBBBBGGGGRRRR) MCFG_SPEAKER_STANDARD_MONO("mono") @@ -657,7 +592,7 @@ ROM_START( angelkds ) ROM_REGION( 0x8000, "maincpu", 0 ) ROM_LOAD( "11428.c10", 0x00000, 0x08000, CRC(90daacd2) SHA1(7e50ad1cbed0c1e6bad04ef1611cad25538c905f) ) - ROM_REGION( 0x20000, "user1", 0 ) /* Banked Code */ + ROM_REGION( 0x40000, "user1", 0 ) /* Banked Code */ ROM_LOAD( "11424.c1", 0x00000, 0x08000, CRC(b55997f6) SHA1(7ed746becac1851f39591f1fdbeff64aa97d6206) ) ROM_LOAD( "11425.c2", 0x08000, 0x08000, CRC(299359de) SHA1(f531dd3bfe6f64e9e043cb4f85d5657455241dc7) ) ROM_LOAD( "11426.c3", 0x10000, 0x08000, CRC(5fad8bd3) SHA1(4d865342eb10dcfb779eee4ac1e159bb9ec140cb) ) @@ -704,7 +639,7 @@ ROM_START( spcpostn ) ROM_REGION( 0x8000, "maincpu", 0 ) /* D317-0005 (NEC Z80 Custom) */ ROM_LOAD( "epr10125.c10", 0x00000, 0x08000, CRC(bffd38c6) SHA1(af02907124343ddecd21439d25f1ebb81ef9f51a) ) /* encrypted */ - ROM_REGION( 0x28000, "user1", 0 ) /* Banked Code */ + ROM_REGION( 0x40000, "user1", 0 ) /* Banked Code */ ROM_LOAD( "epr10120.c1", 0x00000, 0x08000, CRC(d6399f99) SHA1(4c7d19a8798e5a10b688bf793ca74f5170fd9b51) ) ROM_LOAD( "epr10121.c2", 0x08000, 0x08000, CRC(d4861560) SHA1(74d28c36a08880abbd3c398cc3e990e8986caccb) ) ROM_LOAD( "epr10122.c3", 0x10000, 0x08000, CRC(7a1bff1b) SHA1(e1bda8430fd632c1813dd78e0f210a358e1b0d2f) ) @@ -740,7 +675,7 @@ ROM_END DRIVER_INIT_MEMBER(angelkds_state,angelkds) { UINT8 *RAM = memregion("user1")->base(); - membank("bank1")->configure_entries(0, 8, &RAM[0x0000], 0x4000); + membank("bank1")->configure_entries(0, 16, &RAM[0x0000], 0x4000); } DRIVER_INIT_MEMBER(angelkds_state,spcpostn) @@ -750,7 +685,7 @@ DRIVER_INIT_MEMBER(angelkds_state,spcpostn) // 317-0005 sega_decode_317(memregion("maincpu")->base(), m_decrypted_opcodes, 1); - membank("bank1")->configure_entries(0, 10, &RAM[0x0000], 0x4000); + membank("bank1")->configure_entries(0, 16, &RAM[0x0000], 0x4000); } diff --git a/src/mame/drivers/carjmbre.cpp b/src/mame/drivers/carjmbre.cpp index 68a1330fefd..127d6d7c385 100644 --- a/src/mame/drivers/carjmbre.cpp +++ b/src/mame/drivers/carjmbre.cpp @@ -4,6 +4,14 @@ Car Jamboree Omori Electric CAD (OEC) 1983 + + TODO: + - colors are wrong + - sprite priorities? + +---------------------------------------------------------------------------- + + PCB sketch: c14 c.d19 c13 c.d18 c10 diff --git a/src/mame/drivers/hh_sm510.cpp b/src/mame/drivers/hh_sm510.cpp index 13c8b835fc4..de6ecf3836e 100644 --- a/src/mame/drivers/hh_sm510.cpp +++ b/src/mame/drivers/hh_sm510.cpp @@ -89,11 +89,14 @@ WRITE16_MEMBER(hh_sm510_state::lcd_segment_w) if (state != m_lcd_output_cache[index]) { - // output to x.y, where x = row a/b/bs/c*4 + H1-4, y = seg1-16 + // output to row.seg.H, where: + // row = row a/b/bs/c (0/1/2/3) + // seg = seg 1-16 (0-15) + // H = H1-H4 (0-3) char buf[0x10]; - sprintf(buf, "%d.%d", offset, seg); + sprintf(buf, "%d.%d.%d", offset >> 2, seg, offset & 3); output().set_value(buf, state); - + m_lcd_output_cache[index] = state; } } @@ -186,13 +189,13 @@ static INPUT_PORTS_START( ktopgun ) PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_CHANGED_MEMBER(DEVICE_SELF, hh_sm510_state, input_changed, NULL) PORT_START("IN.1") - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_CHANGED_MEMBER(DEVICE_SELF, hh_sm510_state, input_changed, NULL) // sel - PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_CHANGED_MEMBER(DEVICE_SELF, hh_sm510_state, input_changed, NULL) // sound on/off - PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_CHANGED_MEMBER(DEVICE_SELF, hh_sm510_state, input_changed, NULL) // off - PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_CHANGED_MEMBER(DEVICE_SELF, hh_sm510_state, input_changed, NULL) // fire + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_CHANGED_MEMBER(DEVICE_SELF, hh_sm510_state, input_changed, NULL) + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_CHANGED_MEMBER(DEVICE_SELF, hh_sm510_state, input_changed, NULL) PORT_NAME("Sound") + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_CHANGED_MEMBER(DEVICE_SELF, hh_sm510_state, input_changed, NULL) PORT_NAME("Off") + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_CHANGED_MEMBER(DEVICE_SELF, hh_sm510_state, input_changed, NULL) PORT_START("IN.2") - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_CHANGED_MEMBER(DEVICE_SELF, hh_sm510_state, input_changed, NULL) // on + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_START ) PORT_CHANGED_MEMBER(DEVICE_SELF, hh_sm510_state, input_changed, NULL) PORT_NAME("On/Start") PORT_BIT( 0x0e, IP_ACTIVE_HIGH, IPT_UNUSED ) INPUT_PORTS_END diff --git a/src/mame/drivers/iteagle.cpp b/src/mame/drivers/iteagle.cpp index ff6b387bc45..9e725636055 100644 --- a/src/mame/drivers/iteagle.cpp +++ b/src/mame/drivers/iteagle.cpp @@ -142,11 +142,11 @@ void iteagle_state::machine_reset() { } -#define PCI_ID_IDE ":pci:06.0" +#define PCI_ID_IDE ":pci:06.0" // Primary IDE Control ":pci:06.1" // Seconday IDE Control ":pci:06.2" #define PCI_ID_SOUND ":pci:07.0" -#define PCI_ID_FPGA ":pci:08.0" +#define PCI_ID_FPGA ":pci:08.0" #define PCI_ID_VIDEO ":pci:09.0" #define PCI_ID_EEPROM ":pci:0a.0" @@ -161,7 +161,7 @@ static MACHINE_CONFIG_START( iteagle, iteagle_state ) MCFG_VRC4373_ADD( ":pci:00.0", ":maincpu") MCFG_ITEAGLE_IDE_ADD( PCI_ID_IDE) MCFG_ITEAGLE_IDE_IRQ_ADD( ":maincpu", MIPS3_IRQ2) - MCFG_ITEAGLE_FPGA_ADD( PCI_ID_FPGA, ":maincpu", MIPS3_IRQ1) + MCFG_ITEAGLE_FPGA_ADD( PCI_ID_FPGA, ":maincpu", MIPS3_IRQ1, MIPS3_IRQ4) MCFG_ES1373_ADD( PCI_ID_SOUND) MCFG_SOUND_ROUTE(0, PCI_ID_SOUND":lspeaker", 1.0) MCFG_SOUND_ROUTE(1, PCI_ID_SOUND":rspeaker", 1.0) @@ -228,7 +228,15 @@ MACHINE_CONFIG_END static MACHINE_CONFIG_DERIVED( bbhsc, iteagle ) MCFG_DEVICE_MODIFY(PCI_ID_FPGA) - MCFG_ITEAGLE_FPGA_INIT(0x02000600, 0x0c0a0a) + // 0xXX01XXXX = tournament board + MCFG_ITEAGLE_FPGA_INIT(0x02010600, 0x0c0a0a) + MCFG_DEVICE_MODIFY(PCI_ID_EEPROM) + MCFG_ITEAGLE_EEPROM_INIT(0x0000, 0x7) +MACHINE_CONFIG_END + +static MACHINE_CONFIG_DERIVED( bbh2sp, iteagle ) + MCFG_DEVICE_MODIFY(PCI_ID_FPGA) + MCFG_ITEAGLE_FPGA_INIT(0x02000602, 0x0d0a0a) MCFG_DEVICE_MODIFY(PCI_ID_EEPROM) MCFG_ITEAGLE_EEPROM_INIT(0x0000, 0x7) MACHINE_CONFIG_END @@ -538,6 +546,21 @@ ROM_START( bbhsc ) DISK_REGION( PCI_ID_IDE":ide:0:hdd:image" ) DISK_IMAGE( "bbhsc_v1.50.07_cf", 0, SHA1(21dcf1f7e5ab901ac64e6afb099c35e273b3bf1f) ) /* Build 16:35:34, Feb 26 2002 - 4gb Compact Flash conversion */ ROM_END + //DISK_IMAGE( "bbhsc_v1.50.07_cf", 0, SHA1(21dcf1f7e5ab901ac64e6afb099c35e273b3bf1f) ) /* Build 16:35:34, Feb 26 2002 - 4gb Compact Flash conversion */ + //DISK_IMAGE( "bbhsc_v1.60.01", 0, SHA1(8554fdd7193ee27c0fe8ca921aa8db9c0378b313) ) + +ROM_START( bbh2sp ) + EAGLE_BIOS + + ROM_REGION( 0x0880, "atmel", 0 ) /* Atmel 90S2313 AVR internal CPU code */ + ROM_LOAD( "bbh2-us.u53", 0x0000, 0x0880, NO_DUMP ) + + DISK_REGION( PCI_ID_IDE":ide:0:hdd:image" ) + DISK_IMAGE( "bbh2sp_v2.02.11", 0, SHA1(63e41cca534f4774bfba4b4dda9620fe805029b4) ) +ROM_END + //DISK_IMAGE( "bbh2sp_v2.02.08", 0, SHA1(13b9b4ea0465f55dd1c7bc6e2f962c3c9b9566bd) ) + //DISK_IMAGE( "bbh2sp_v2.02.09", 0, SHA1(fac3963b6da35a8c8b00f6826bc10e9c7230b1d6) ) + //DISK_IMAGE( "bbh2sp_v2.02.11", 0, SHA1(63e41cca534f4774bfba4b4dda9620fe805029b4) ) ROM_START( bbhcotw ) /* This version is meant for 8meg GREEN board PCBs */ EAGLE_BIOS @@ -570,4 +593,5 @@ GAME( 2004, gtfore05b, gtfore05, gtfore05, iteagle, driver_device, 0, ROT0, "I GAME( 2004, gtfore05c, gtfore05, gtfore05, iteagle, driver_device, 0, ROT0, "Incredible Technologies", "Golden Tee Fore! 2005 Extra (v5.00.00)", 0 ) GAME( 2005, gtfore06, iteagle, gtfore06, iteagle, driver_device, 0, ROT0, "Incredible Technologies", "Golden Tee Fore! 2006 Complete (v6.00.01)", 0 ) GAME( 2002, bbhsc, iteagle, bbhsc, bbh, driver_device, 0, ROT0, "Incredible Technologies", "Big Buck Hunter - Shooter's Challenge (v1.50.07)", MACHINE_NOT_WORKING ) // doesn't boot +GAME( 2002, bbh2sp, iteagle, bbh2sp, bbh, driver_device, 0, ROT0, "Incredible Technologies", "Big Buck Hunter II - Sportsman's Paradise (v2.02.11)", MACHINE_NOT_WORKING ) // SW51-2 needs to be off GAME( 2006, bbhcotw, iteagle, bbhcotw, bbh, driver_device, 0, ROT0, "Incredible Technologies", "Big Buck Hunter Call of the Wild (v3.02.5)", MACHINE_NOT_WORKING ) // random lockups diff --git a/src/mame/drivers/pcat_dyn.cpp b/src/mame/drivers/pcat_dyn.cpp index baaa94626ee..db385937cfe 100644 --- a/src/mame/drivers/pcat_dyn.cpp +++ b/src/mame/drivers/pcat_dyn.cpp @@ -84,34 +84,11 @@ ADDRESS_MAP_END PORT_BIT( bit, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME(text) PORT_CODE(key1) static INPUT_PORTS_START( pcat_dyn ) - PORT_START("pc_keyboard_0") - PORT_BIT ( 0x0001, 0x0000, IPT_UNUSED ) /* unused scancode 0 */ - AT_KEYB_HELPER( 0x0002, "Esc", KEYCODE_Q ) /* Esc 01 81 */ - - PORT_START("pc_keyboard_1") - AT_KEYB_HELPER( 0x0020, "Y", KEYCODE_Y ) /* Y 15 95 */ - AT_KEYB_HELPER( 0x1000, "Enter", KEYCODE_ENTER ) /* Enter 1C 9C */ - - PORT_START("pc_keyboard_2") - - PORT_START("pc_keyboard_3") - AT_KEYB_HELPER( 0x0002, "N", KEYCODE_N ) /* N 31 B1 */ - AT_KEYB_HELPER( 0x0800, "F1", KEYCODE_S ) /* F1 3B BB */ - - PORT_START("pc_keyboard_4") - - PORT_START("pc_keyboard_5") - - PORT_START("pc_keyboard_6") - AT_KEYB_HELPER( 0x0040, "(MF2)Cursor Up", KEYCODE_UP ) /* Up 67 e7 */ - AT_KEYB_HELPER( 0x0080, "(MF2)Page Up", KEYCODE_PGUP ) /* Page Up 68 e8 */ - AT_KEYB_HELPER( 0x0100, "(MF2)Cursor Left", KEYCODE_LEFT ) /* Left 69 e9 */ - AT_KEYB_HELPER( 0x0200, "(MF2)Cursor Right", KEYCODE_RIGHT ) /* Right 6a ea */ - AT_KEYB_HELPER( 0x0800, "(MF2)Cursor Down", KEYCODE_DOWN ) /* Down 6c ec */ - AT_KEYB_HELPER( 0x1000, "(MF2)Page Down", KEYCODE_PGDN ) /* Page Down 6d ed */ - AT_KEYB_HELPER( 0x4000, "Del", KEYCODE_A ) /* Delete 6f ef */ - - PORT_START("pc_keyboard_7") + // 8 -- Bookkeeping + // L -- Coin + // M,N,Numpad 6 -- Hang + // Enter,Numpad 4 -- 5 Credits + PORT_INCLUDE(at_keyboard) INPUT_PORTS_END static SLOT_INTERFACE_START(pcat_dyn_com) @@ -129,6 +106,7 @@ static MACHINE_CONFIG_START( pcat_dyn, pcat_dyn_state ) MCFG_FRAGMENT_ADD( pcvideo_trident_vga ) MCFG_SCREEN_MODIFY("screen") MCFG_SCREEN_REFRESH_RATE(60) + MCFG_DEVICE_REPLACE("vga", TVGA9000_VGA, 0) MCFG_FRAGMENT_ADD( pcat_common ) @@ -182,7 +160,7 @@ ROM_START(toursol) ROM_LOAD("sol.u21", 0x00000, 0x40000, CRC(e97724d9) SHA1(995b89d129c371b815c6b498093bd1bbf9fd8755)) ROM_LOAD("sol.u22", 0x40000, 0x40000, CRC(69d42f50) SHA1(737fe62f3827b00b4f6f3b72ef6c7b6740947e95)) ROM_LOAD("sol.u23", 0x80000, 0x40000, CRC(d1e39bd4) SHA1(39c7ee43cddb53fba0f7c0572ddc40289c4edd07)) - ROM_LOAD("sol.u24", 0xa0000, 0x40000, CRC(555341e0) SHA1(81fee576728855e234ff7aae06f54ae9705c3ab5)) + ROM_LOAD("sol.u24", 0xc0000, 0x40000, CRC(555341e0) SHA1(81fee576728855e234ff7aae06f54ae9705c3ab5)) ROM_LOAD("sol.u28", 0xe0000, 0x02000, CRC(c9374d50) SHA1(49173bc69f70bb2a7e8af9d03e2538b34aa881d8)) ROM_FILL(0x2a3e6, 1, 0xeb) // skip prot(?) check @@ -203,7 +181,7 @@ ROM_START(toursol1) ROM_LOAD("prom.0", 0x00000, 0x40000, CRC(f26ce73f) SHA1(5516c31aa18716a47f46e412fc273ae8784d2061)) ROM_LOAD("prom.1", 0x40000, 0x40000, CRC(8f96e2a8) SHA1(bc3ce8b99e6ff40e355df2c3f797f1fe88b3b219)) ROM_LOAD("prom.2", 0x80000, 0x40000, CRC(8b0ac5cf) SHA1(1c2b6a53c9ff4d18a5227d899facbbc719f40205)) - ROM_LOAD("prom.3", 0xa0000, 0x40000, CRC(9352e965) SHA1(2bfb647ec27c60a8c821fdf7483199e1a444cea8)) + ROM_LOAD("prom.3", 0xc0000, 0x40000, CRC(9352e965) SHA1(2bfb647ec27c60a8c821fdf7483199e1a444cea8)) ROM_LOAD("prom.7", 0xe0000, 0x02000, CRC(154c8092) SHA1(4439ee82f36d5d5c334494ba7bb4848e839213a7)) ROM_REGION(128, "rtc", 0) diff --git a/src/mame/drivers/shanghai.cpp b/src/mame/drivers/shanghai.cpp index 1aeb26c541f..e5f10928555 100644 --- a/src/mame/drivers/shanghai.cpp +++ b/src/mame/drivers/shanghai.cpp @@ -6,12 +6,10 @@ Shanghai driver by Nicola Salmoria -The end of round animation in Shanghai is wrong; change the opcode at 0xfb1f2 -to a NOP to jump to it immediately at the beginning of a round. - -I'm not sure about the refresh rate, 60Hz makes time match the dip switch -settings, but music runs too fast. - +TODO: +- games are currently too fast (especially noticeable with kothello screen transitions), either irqs actually + fires every two frames or a HD63484 SR bit isn't behaving correctly; +- minor glitch with gfx copy on shanghai stage info panel (garbage on right); * kothello @@ -24,7 +22,7 @@ displayed. #include "emu.h" #include "cpu/nec/nec.h" #include "audio/seibu.h" -#include "video/hd63484.h" +#include "video/h63484.h" class shanghai_state : public driver_device @@ -32,20 +30,14 @@ class shanghai_state : public driver_device public: shanghai_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), - m_maincpu(*this, "maincpu"), - m_hd63484(*this, "hd63484") { } + m_maincpu(*this, "maincpu") { } required_device<cpu_device> m_maincpu; - required_device<hd63484_device> m_hd63484; DECLARE_WRITE16_MEMBER(shanghai_coin_w); - DECLARE_READ16_MEMBER(kothello_hd63484_status_r); - virtual void video_start() override; DECLARE_PALETTE_INIT(shanghai); - UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - INTERRUPT_GEN_MEMBER(interrupt); }; @@ -80,57 +72,6 @@ PALETTE_INIT_MEMBER(shanghai_state,shanghai) } } -void shanghai_state::video_start() -{ -} - -UINT32 shanghai_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - int x, y, b, src; - - address_space &space = machine().driver_data()->generic_space(); - b = ((m_hd63484->regs_r(space, 0xcc/2, 0xffff) & 0x000f) << 16) + m_hd63484->regs_r(space, 0xce/2, 0xffff); - for (y = 0; y < 280; y++) - { - for (x = 0 ; x < (m_hd63484->regs_r(space, 0xca/2, 0xffff) & 0x0fff) * 2 ; x += 2) - { - b &= (HD63484_RAM_SIZE - 1); - src = m_hd63484->ram_r(space, b, 0xffff); - bitmap.pix16(y, x) = src & 0x00ff; - bitmap.pix16(y, x + 1) = (src & 0xff00) >> 8; - b++; - } - } - - if ((m_hd63484->regs_r(space, 0x06/2, 0xffff) & 0x0300) == 0x0300) - { - int sy = (m_hd63484->regs_r(space, 0x94/2, 0xffff) & 0x0fff) - (m_hd63484->regs_r(space, 0x88/2, 0xffff) >> 8); - int h = m_hd63484->regs_r(space, 0x96/2, 0xffff) & 0x0fff; - int sx = ((m_hd63484->regs_r(space, 0x92/2, 0xffff) >> 8) - (m_hd63484->regs_r(space, 0x84/2, 0xffff) >> 8)) * 4; - int w = (m_hd63484->regs_r(space, 0x92/2, 0xffff) & 0xff) * 4; - if (sx < 0) sx = 0; // not sure about this (shangha2 title screen) - - b = (((m_hd63484->regs_r(space, 0xdc/2, 0xffff) & 0x000f) << 16) + m_hd63484->regs_r(space, 0xde/2, 0xffff)); - - for (y = sy ; y <= sy + h && y < 280 ; y++) - { - for (x = 0 ; x < (m_hd63484->regs_r(space, 0xca/2, 0xffff) & 0x0fff) * 2 ; x += 2) - { - b &= (HD63484_RAM_SIZE - 1); - src = m_hd63484->ram_r(space, b, 0xffff); - if (x <= w && x + sx >= 0 && x + sx < (m_hd63484->regs_r(space, 0xca/2, 0xffff) & 0x0fff) * 2) - { - bitmap.pix16(y, x + sx) = src & 0x00ff; - bitmap.pix16(y, x + sx + 1) = (src & 0xff00) >> 8; - } - b++; - } - } - } - - return 0; -} - INTERRUPT_GEN_MEMBER(shanghai_state::interrupt) { device.execute().set_input_line_and_vector(0,HOLD_LINE,0x80); @@ -159,8 +100,8 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( shanghai_portmap, AS_IO, 16, shanghai_state ) - AM_RANGE(0x00, 0x01) AM_DEVREADWRITE("hd63484", hd63484_device, status_r, address_w) - AM_RANGE(0x02, 0x03) AM_DEVREADWRITE("hd63484", hd63484_device, data_r, data_w) + AM_RANGE(0x00, 0x01) AM_DEVREADWRITE("h63484", h63484_device, status_r, address_w) + AM_RANGE(0x02, 0x03) AM_DEVREADWRITE("h63484", h63484_device, data_r, data_w) AM_RANGE(0x20, 0x23) AM_DEVREADWRITE8("ymsnd", ym2203_device, read, write, 0x00ff) AM_RANGE(0x40, 0x41) AM_READ_PORT("P1") AM_RANGE(0x44, 0x45) AM_READ_PORT("P2") @@ -173,21 +114,16 @@ static ADDRESS_MAP_START( shangha2_portmap, AS_IO, 16, shanghai_state ) AM_RANGE(0x00, 0x01) AM_READ_PORT("P1") AM_RANGE(0x10, 0x11) AM_READ_PORT("P2") AM_RANGE(0x20, 0x21) AM_READ_PORT("SYSTEM") - AM_RANGE(0x30, 0x31) AM_DEVREADWRITE("hd63484", hd63484_device, status_r, address_w) - AM_RANGE(0x32, 0x33) AM_DEVREADWRITE("hd63484", hd63484_device, data_r, data_w) + AM_RANGE(0x30, 0x31) AM_DEVREADWRITE("h63484", h63484_device, status_r, address_w) + AM_RANGE(0x32, 0x33) AM_DEVREADWRITE("h63484", h63484_device, data_r, data_w) AM_RANGE(0x40, 0x43) AM_DEVREADWRITE8("ymsnd", ym2203_device, read, write, 0x00ff) AM_RANGE(0x50, 0x51) AM_WRITE(shanghai_coin_w) ADDRESS_MAP_END -READ16_MEMBER(shanghai_state::kothello_hd63484_status_r) -{ - return 0xff22; /* write FIFO ready + command end + read FIFO ready */ -} - static ADDRESS_MAP_START( kothello_map, AS_PROGRAM, 16, shanghai_state ) AM_RANGE(0x00000, 0x07fff) AM_RAM - AM_RANGE(0x08010, 0x08011) AM_READ(kothello_hd63484_status_r) AM_DEVWRITE("hd63484", hd63484_device, address_w) - AM_RANGE(0x08012, 0x08013) AM_DEVREADWRITE("hd63484", hd63484_device, data_r, data_w) + AM_RANGE(0x08010, 0x08011) AM_DEVREADWRITE("h63484", h63484_device, status_r, address_w) + AM_RANGE(0x08012, 0x08013) AM_DEVREADWRITE("h63484", h63484_device, data_r, data_w) AM_RANGE(0x09010, 0x09011) AM_READ_PORT("P1") AM_RANGE(0x09012, 0x09013) AM_READ_PORT("P2") AM_RANGE(0x09014, 0x09015) AM_READ_PORT("SYSTEM") @@ -418,6 +354,9 @@ static INPUT_PORTS_START( shangha2 ) PORT_DIPSETTING( 0x80, DEF_STR( 1C_4C ) ) INPUT_PORTS_END +static ADDRESS_MAP_START( h63484_map, AS_0, 16, shanghai_state ) + AM_RANGE(0x00000, 0x3ffff) AM_RAM +ADDRESS_MAP_END static MACHINE_CONFIG_START( shanghai, shanghai_state ) @@ -429,19 +368,19 @@ static MACHINE_CONFIG_START( shanghai, shanghai_state ) /* video hardware */ MCFG_SCREEN_ADD("screen", RASTER) - MCFG_SCREEN_REFRESH_RATE(30) + MCFG_SCREEN_REFRESH_RATE(57) + //MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) MCFG_SCREEN_SIZE(384, 280) - MCFG_SCREEN_VISIBLE_AREA(0, 384-1, 0, 280-1) // Base Screen is 384 pixel - MCFG_SCREEN_UPDATE_DRIVER(shanghai_state, screen_update) + MCFG_SCREEN_VISIBLE_AREA(0, 384-1, 0, 280-1) + MCFG_SCREEN_UPDATE_DEVICE("h63484", h63484_device, update_screen) MCFG_SCREEN_PALETTE("palette") MCFG_PALETTE_ADD("palette", 256) MCFG_PALETTE_FORMAT(xxxxBBBBGGGGRRRR) MCFG_PALETTE_INIT_OWNER(shanghai_state,shanghai) - // TODO: convert to use H63484 - MCFG_DEVICE_ADD("hd63484", HD63484, 0) - + MCFG_H63484_ADD("h63484", 0, h63484_map) + /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") @@ -465,17 +404,17 @@ static MACHINE_CONFIG_START( shangha2, shanghai_state ) /* video hardware */ MCFG_SCREEN_ADD("screen", RASTER) - MCFG_SCREEN_REFRESH_RATE(30) + MCFG_SCREEN_REFRESH_RATE(57) + //MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) MCFG_SCREEN_SIZE(384, 280) - MCFG_SCREEN_VISIBLE_AREA(0, 384-1, 0, 280-1) // Base Screen is 384 pixel - MCFG_SCREEN_UPDATE_DRIVER(shanghai_state, screen_update) + MCFG_SCREEN_VISIBLE_AREA(0, 384-1, 0, 280-1) + MCFG_SCREEN_UPDATE_DEVICE("h63484", h63484_device, update_screen) MCFG_SCREEN_PALETTE("palette") MCFG_PALETTE_ADD("palette", 256) MCFG_PALETTE_FORMAT(xxxxBBBBGGGGRRRR) - // TODO: convert to use H63484 - MCFG_DEVICE_ADD("hd63484", HD63484, 0) + MCFG_H63484_ADD("h63484", 0, h63484_map) /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") @@ -503,17 +442,17 @@ static MACHINE_CONFIG_START( kothello, shanghai_state ) /* video hardware */ MCFG_SCREEN_ADD("screen", RASTER) - MCFG_SCREEN_REFRESH_RATE(30) /* Should be 57Hz, but plays too fast */ + MCFG_SCREEN_REFRESH_RATE(57) + //MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) MCFG_SCREEN_SIZE(384, 280) - MCFG_SCREEN_VISIBLE_AREA(8, 384-1, 0, 250-1) // Base Screen is 376 pixel - MCFG_SCREEN_UPDATE_DRIVER(shanghai_state, screen_update) + MCFG_SCREEN_VISIBLE_AREA(0, 384-1, 0, 280-1) + MCFG_SCREEN_UPDATE_DEVICE("h63484", h63484_device, update_screen) MCFG_SCREEN_PALETTE("palette") MCFG_PALETTE_ADD("palette", 256) MCFG_PALETTE_FORMAT(xxxxBBBBGGGGRRRR) - // TODO: convert to use H63484 - MCFG_DEVICE_ADD("hd63484", HD63484, 0) + MCFG_H63484_ADD("h63484", 0, h63484_map) /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") diff --git a/src/mame/includes/angelkds.h b/src/mame/includes/angelkds.h index ecd59f1e4e5..1617fc2579a 100644 --- a/src/mame/includes/angelkds.h +++ b/src/mame/includes/angelkds.h @@ -15,11 +15,9 @@ public: m_bgbotvideoram(*this, "bgbotvideoram"), m_txvideoram(*this, "txvideoram"), m_spriteram(*this, "spriteram"), - m_paletteram(*this, "paletteram"), m_subcpu(*this, "sub"), m_maincpu(*this, "maincpu"), m_gfxdecode(*this, "gfxdecode"), - m_palette(*this, "palette"), m_decrypted_opcodes(*this, "decrypted_opcodes") { } /* memory pointers */ @@ -27,7 +25,6 @@ public: required_shared_ptr<UINT8> m_bgbotvideoram; required_shared_ptr<UINT8> m_txvideoram; required_shared_ptr<UINT8> m_spriteram; - required_shared_ptr<UINT8> m_paletteram; tilemap_t *m_tx_tilemap; tilemap_t *m_bgbot_tilemap; @@ -42,8 +39,8 @@ public: /* devices */ required_device<cpu_device> m_subcpu; + DECLARE_READ8_MEMBER(angeklds_ff_r) { return 0xff; }; DECLARE_WRITE8_MEMBER(angelkds_cpu_bank_write); - DECLARE_READ8_MEMBER(angelkds_input_r); DECLARE_WRITE8_MEMBER(angelkds_main_sound_w); DECLARE_READ8_MEMBER(angelkds_main_sound_r); DECLARE_WRITE8_MEMBER(angelkds_sub_sound_w); @@ -57,7 +54,6 @@ public: DECLARE_WRITE8_MEMBER(angelkds_bgbotbank_write); DECLARE_WRITE8_MEMBER(angelkds_bgbotscroll_write); DECLARE_WRITE8_MEMBER(angelkds_layer_ctrl_write); - DECLARE_WRITE8_MEMBER(angelkds_paletteram_w); DECLARE_DRIVER_INIT(angelkds); DECLARE_DRIVER_INIT(spcpostn); TILE_GET_INFO_MEMBER(get_tx_tile_info); @@ -71,6 +67,5 @@ public: DECLARE_WRITE_LINE_MEMBER(irqhandler); required_device<cpu_device> m_maincpu; required_device<gfxdecode_device> m_gfxdecode; - required_device<palette_device> m_palette; optional_shared_ptr<UINT8> m_decrypted_opcodes; }; diff --git a/src/mame/layout/hh_sm510_test.lay b/src/mame/layout/hh_sm510_test.lay index f960f795acc..6c767675bfd 100644 --- a/src/mame/layout/hh_sm510_test.lay +++ b/src/mame/layout/hh_sm510_test.lay @@ -22,280 +22,287 @@ <bounds left="0" right="64" top="0" bottom="64" /> </bezel> - <!-- max 16*16 matrix --> + <!-- max 4*16*4 matrix --> - <bezel name="0.0" element="led"><bounds x="0" y="0" width="1" height="1" /></bezel> - <bezel name="0.1" element="led"><bounds x="0" y="2" width="1" height="1" /></bezel> - <bezel name="0.2" element="led"><bounds x="0" y="4" width="1" height="1" /></bezel> - <bezel name="0.3" element="led"><bounds x="0" y="6" width="1" height="1" /></bezel> - <bezel name="0.4" element="led"><bounds x="0" y="8" width="1" height="1" /></bezel> - <bezel name="0.5" element="led"><bounds x="0" y="10" width="1" height="1" /></bezel> - <bezel name="0.6" element="led"><bounds x="0" y="12" width="1" height="1" /></bezel> - <bezel name="0.7" element="led"><bounds x="0" y="14" width="1" height="1" /></bezel> - <bezel name="0.8" element="led"><bounds x="0" y="16" width="1" height="1" /></bezel> - <bezel name="0.9" element="led"><bounds x="0" y="18" width="1" height="1" /></bezel> - <bezel name="0.10" element="led"><bounds x="0" y="20" width="1" height="1" /></bezel> - <bezel name="0.11" element="led"><bounds x="0" y="22" width="1" height="1" /></bezel> - <bezel name="0.12" element="led"><bounds x="0" y="24" width="1" height="1" /></bezel> - <bezel name="0.13" element="led"><bounds x="0" y="26" width="1" height="1" /></bezel> - <bezel name="0.14" element="led"><bounds x="0" y="28" width="1" height="1" /></bezel> - <bezel name="0.15" element="led"><bounds x="0" y="30" width="1" height="1" /></bezel> + <!-- a --> - <bezel name="1.0" element="led"><bounds x="2" y="0" width="1" height="1" /></bezel> - <bezel name="1.1" element="led"><bounds x="2" y="2" width="1" height="1" /></bezel> - <bezel name="1.2" element="led"><bounds x="2" y="4" width="1" height="1" /></bezel> - <bezel name="1.3" element="led"><bounds x="2" y="6" width="1" height="1" /></bezel> - <bezel name="1.4" element="led"><bounds x="2" y="8" width="1" height="1" /></bezel> - <bezel name="1.5" element="led"><bounds x="2" y="10" width="1" height="1" /></bezel> - <bezel name="1.6" element="led"><bounds x="2" y="12" width="1" height="1" /></bezel> - <bezel name="1.7" element="led"><bounds x="2" y="14" width="1" height="1" /></bezel> - <bezel name="1.8" element="led"><bounds x="2" y="16" width="1" height="1" /></bezel> - <bezel name="1.9" element="led"><bounds x="2" y="18" width="1" height="1" /></bezel> - <bezel name="1.10" element="led"><bounds x="2" y="20" width="1" height="1" /></bezel> - <bezel name="1.11" element="led"><bounds x="2" y="22" width="1" height="1" /></bezel> - <bezel name="1.12" element="led"><bounds x="2" y="24" width="1" height="1" /></bezel> - <bezel name="1.13" element="led"><bounds x="2" y="26" width="1" height="1" /></bezel> - <bezel name="1.14" element="led"><bounds x="2" y="28" width="1" height="1" /></bezel> - <bezel name="1.15" element="led"><bounds x="2" y="30" width="1" height="1" /></bezel> + <bezel name="0.0.0" element="led"><bounds x="0" y="0" width="1" height="1" /></bezel> + <bezel name="0.1.0" element="led"><bounds x="0" y="2" width="1" height="1" /></bezel> + <bezel name="0.2.0" element="led"><bounds x="0" y="4" width="1" height="1" /></bezel> + <bezel name="0.3.0" element="led"><bounds x="0" y="6" width="1" height="1" /></bezel> + <bezel name="0.4.0" element="led"><bounds x="0" y="8" width="1" height="1" /></bezel> + <bezel name="0.5.0" element="led"><bounds x="0" y="10" width="1" height="1" /></bezel> + <bezel name="0.6.0" element="led"><bounds x="0" y="12" width="1" height="1" /></bezel> + <bezel name="0.7.0" element="led"><bounds x="0" y="14" width="1" height="1" /></bezel> + <bezel name="0.8.0" element="led"><bounds x="0" y="16" width="1" height="1" /></bezel> + <bezel name="0.9.0" element="led"><bounds x="0" y="18" width="1" height="1" /></bezel> + <bezel name="0.10.0" element="led"><bounds x="0" y="20" width="1" height="1" /></bezel> + <bezel name="0.11.0" element="led"><bounds x="0" y="22" width="1" height="1" /></bezel> + <bezel name="0.12.0" element="led"><bounds x="0" y="24" width="1" height="1" /></bezel> + <bezel name="0.13.0" element="led"><bounds x="0" y="26" width="1" height="1" /></bezel> + <bezel name="0.14.0" element="led"><bounds x="0" y="28" width="1" height="1" /></bezel> + <bezel name="0.15.0" element="led"><bounds x="0" y="30" width="1" height="1" /></bezel> - <bezel name="2.0" element="led"><bounds x="4" y="0" width="1" height="1" /></bezel> - <bezel name="2.1" element="led"><bounds x="4" y="2" width="1" height="1" /></bezel> - <bezel name="2.2" element="led"><bounds x="4" y="4" width="1" height="1" /></bezel> - <bezel name="2.3" element="led"><bounds x="4" y="6" width="1" height="1" /></bezel> - <bezel name="2.4" element="led"><bounds x="4" y="8" width="1" height="1" /></bezel> - <bezel name="2.5" element="led"><bounds x="4" y="10" width="1" height="1" /></bezel> - <bezel name="2.6" element="led"><bounds x="4" y="12" width="1" height="1" /></bezel> - <bezel name="2.7" element="led"><bounds x="4" y="14" width="1" height="1" /></bezel> - <bezel name="2.8" element="led"><bounds x="4" y="16" width="1" height="1" /></bezel> - <bezel name="2.9" element="led"><bounds x="4" y="18" width="1" height="1" /></bezel> - <bezel name="2.10" element="led"><bounds x="4" y="20" width="1" height="1" /></bezel> - <bezel name="2.11" element="led"><bounds x="4" y="22" width="1" height="1" /></bezel> - <bezel name="2.12" element="led"><bounds x="4" y="24" width="1" height="1" /></bezel> - <bezel name="2.13" element="led"><bounds x="4" y="26" width="1" height="1" /></bezel> - <bezel name="2.14" element="led"><bounds x="4" y="28" width="1" height="1" /></bezel> - <bezel name="2.15" element="led"><bounds x="4" y="30" width="1" height="1" /></bezel> + <bezel name="0.0.1" element="led"><bounds x="2" y="0" width="1" height="1" /></bezel> + <bezel name="0.1.1" element="led"><bounds x="2" y="2" width="1" height="1" /></bezel> + <bezel name="0.2.1" element="led"><bounds x="2" y="4" width="1" height="1" /></bezel> + <bezel name="0.3.1" element="led"><bounds x="2" y="6" width="1" height="1" /></bezel> + <bezel name="0.4.1" element="led"><bounds x="2" y="8" width="1" height="1" /></bezel> + <bezel name="0.5.1" element="led"><bounds x="2" y="10" width="1" height="1" /></bezel> + <bezel name="0.6.1" element="led"><bounds x="2" y="12" width="1" height="1" /></bezel> + <bezel name="0.7.1" element="led"><bounds x="2" y="14" width="1" height="1" /></bezel> + <bezel name="0.8.1" element="led"><bounds x="2" y="16" width="1" height="1" /></bezel> + <bezel name="0.9.1" element="led"><bounds x="2" y="18" width="1" height="1" /></bezel> + <bezel name="0.10.1" element="led"><bounds x="2" y="20" width="1" height="1" /></bezel> + <bezel name="0.11.1" element="led"><bounds x="2" y="22" width="1" height="1" /></bezel> + <bezel name="0.12.1" element="led"><bounds x="2" y="24" width="1" height="1" /></bezel> + <bezel name="0.13.1" element="led"><bounds x="2" y="26" width="1" height="1" /></bezel> + <bezel name="0.14.1" element="led"><bounds x="2" y="28" width="1" height="1" /></bezel> + <bezel name="0.15.1" element="led"><bounds x="2" y="30" width="1" height="1" /></bezel> - <bezel name="3.0" element="led"><bounds x="6" y="0" width="1" height="1" /></bezel> - <bezel name="3.1" element="led"><bounds x="6" y="2" width="1" height="1" /></bezel> - <bezel name="3.2" element="led"><bounds x="6" y="4" width="1" height="1" /></bezel> - <bezel name="3.3" element="led"><bounds x="6" y="6" width="1" height="1" /></bezel> - <bezel name="3.4" element="led"><bounds x="6" y="8" width="1" height="1" /></bezel> - <bezel name="3.5" element="led"><bounds x="6" y="10" width="1" height="1" /></bezel> - <bezel name="3.6" element="led"><bounds x="6" y="12" width="1" height="1" /></bezel> - <bezel name="3.7" element="led"><bounds x="6" y="14" width="1" height="1" /></bezel> - <bezel name="3.8" element="led"><bounds x="6" y="16" width="1" height="1" /></bezel> - <bezel name="3.9" element="led"><bounds x="6" y="18" width="1" height="1" /></bezel> - <bezel name="3.10" element="led"><bounds x="6" y="20" width="1" height="1" /></bezel> - <bezel name="3.11" element="led"><bounds x="6" y="22" width="1" height="1" /></bezel> - <bezel name="3.12" element="led"><bounds x="6" y="24" width="1" height="1" /></bezel> - <bezel name="3.13" element="led"><bounds x="6" y="26" width="1" height="1" /></bezel> - <bezel name="3.14" element="led"><bounds x="6" y="28" width="1" height="1" /></bezel> - <bezel name="3.15" element="led"><bounds x="6" y="30" width="1" height="1" /></bezel> + <bezel name="0.0.2" element="led"><bounds x="4" y="0" width="1" height="1" /></bezel> + <bezel name="0.1.2" element="led"><bounds x="4" y="2" width="1" height="1" /></bezel> + <bezel name="0.2.2" element="led"><bounds x="4" y="4" width="1" height="1" /></bezel> + <bezel name="0.3.2" element="led"><bounds x="4" y="6" width="1" height="1" /></bezel> + <bezel name="0.4.2" element="led"><bounds x="4" y="8" width="1" height="1" /></bezel> + <bezel name="0.5.2" element="led"><bounds x="4" y="10" width="1" height="1" /></bezel> + <bezel name="0.6.2" element="led"><bounds x="4" y="12" width="1" height="1" /></bezel> + <bezel name="0.7.2" element="led"><bounds x="4" y="14" width="1" height="1" /></bezel> + <bezel name="0.8.2" element="led"><bounds x="4" y="16" width="1" height="1" /></bezel> + <bezel name="0.9.2" element="led"><bounds x="4" y="18" width="1" height="1" /></bezel> + <bezel name="0.10.2" element="led"><bounds x="4" y="20" width="1" height="1" /></bezel> + <bezel name="0.11.2" element="led"><bounds x="4" y="22" width="1" height="1" /></bezel> + <bezel name="0.12.2" element="led"><bounds x="4" y="24" width="1" height="1" /></bezel> + <bezel name="0.13.2" element="led"><bounds x="4" y="26" width="1" height="1" /></bezel> + <bezel name="0.14.2" element="led"><bounds x="4" y="28" width="1" height="1" /></bezel> + <bezel name="0.15.2" element="led"><bounds x="4" y="30" width="1" height="1" /></bezel> - <bezel name="4.0" element="led"><bounds x="8" y="0" width="1" height="1" /></bezel> - <bezel name="4.1" element="led"><bounds x="8" y="2" width="1" height="1" /></bezel> - <bezel name="4.2" element="led"><bounds x="8" y="4" width="1" height="1" /></bezel> - <bezel name="4.3" element="led"><bounds x="8" y="6" width="1" height="1" /></bezel> - <bezel name="4.4" element="led"><bounds x="8" y="8" width="1" height="1" /></bezel> - <bezel name="4.5" element="led"><bounds x="8" y="10" width="1" height="1" /></bezel> - <bezel name="4.6" element="led"><bounds x="8" y="12" width="1" height="1" /></bezel> - <bezel name="4.7" element="led"><bounds x="8" y="14" width="1" height="1" /></bezel> - <bezel name="4.8" element="led"><bounds x="8" y="16" width="1" height="1" /></bezel> - <bezel name="4.9" element="led"><bounds x="8" y="18" width="1" height="1" /></bezel> - <bezel name="4.10" element="led"><bounds x="8" y="20" width="1" height="1" /></bezel> - <bezel name="4.11" element="led"><bounds x="8" y="22" width="1" height="1" /></bezel> - <bezel name="4.12" element="led"><bounds x="8" y="24" width="1" height="1" /></bezel> - <bezel name="4.13" element="led"><bounds x="8" y="26" width="1" height="1" /></bezel> - <bezel name="4.14" element="led"><bounds x="8" y="28" width="1" height="1" /></bezel> - <bezel name="4.15" element="led"><bounds x="8" y="30" width="1" height="1" /></bezel> + <bezel name="0.0.3" element="led"><bounds x="6" y="0" width="1" height="1" /></bezel> + <bezel name="0.1.3" element="led"><bounds x="6" y="2" width="1" height="1" /></bezel> + <bezel name="0.2.3" element="led"><bounds x="6" y="4" width="1" height="1" /></bezel> + <bezel name="0.3.3" element="led"><bounds x="6" y="6" width="1" height="1" /></bezel> + <bezel name="0.4.3" element="led"><bounds x="6" y="8" width="1" height="1" /></bezel> + <bezel name="0.5.3" element="led"><bounds x="6" y="10" width="1" height="1" /></bezel> + <bezel name="0.6.3" element="led"><bounds x="6" y="12" width="1" height="1" /></bezel> + <bezel name="0.7.3" element="led"><bounds x="6" y="14" width="1" height="1" /></bezel> + <bezel name="0.8.3" element="led"><bounds x="6" y="16" width="1" height="1" /></bezel> + <bezel name="0.9.3" element="led"><bounds x="6" y="18" width="1" height="1" /></bezel> + <bezel name="0.10.3" element="led"><bounds x="6" y="20" width="1" height="1" /></bezel> + <bezel name="0.11.3" element="led"><bounds x="6" y="22" width="1" height="1" /></bezel> + <bezel name="0.12.3" element="led"><bounds x="6" y="24" width="1" height="1" /></bezel> + <bezel name="0.13.3" element="led"><bounds x="6" y="26" width="1" height="1" /></bezel> + <bezel name="0.14.3" element="led"><bounds x="6" y="28" width="1" height="1" /></bezel> + <bezel name="0.15.3" element="led"><bounds x="6" y="30" width="1" height="1" /></bezel> - <bezel name="5.0" element="led"><bounds x="10" y="0" width="1" height="1" /></bezel> - <bezel name="5.1" element="led"><bounds x="10" y="2" width="1" height="1" /></bezel> - <bezel name="5.2" element="led"><bounds x="10" y="4" width="1" height="1" /></bezel> - <bezel name="5.3" element="led"><bounds x="10" y="6" width="1" height="1" /></bezel> - <bezel name="5.4" element="led"><bounds x="10" y="8" width="1" height="1" /></bezel> - <bezel name="5.5" element="led"><bounds x="10" y="10" width="1" height="1" /></bezel> - <bezel name="5.6" element="led"><bounds x="10" y="12" width="1" height="1" /></bezel> - <bezel name="5.7" element="led"><bounds x="10" y="14" width="1" height="1" /></bezel> - <bezel name="5.8" element="led"><bounds x="10" y="16" width="1" height="1" /></bezel> - <bezel name="5.9" element="led"><bounds x="10" y="18" width="1" height="1" /></bezel> - <bezel name="5.10" element="led"><bounds x="10" y="20" width="1" height="1" /></bezel> - <bezel name="5.11" element="led"><bounds x="10" y="22" width="1" height="1" /></bezel> - <bezel name="5.12" element="led"><bounds x="10" y="24" width="1" height="1" /></bezel> - <bezel name="5.13" element="led"><bounds x="10" y="26" width="1" height="1" /></bezel> - <bezel name="5.14" element="led"><bounds x="10" y="28" width="1" height="1" /></bezel> - <bezel name="5.15" element="led"><bounds x="10" y="30" width="1" height="1" /></bezel> + <!-- b --> - <bezel name="6.0" element="led"><bounds x="12" y="0" width="1" height="1" /></bezel> - <bezel name="6.1" element="led"><bounds x="12" y="2" width="1" height="1" /></bezel> - <bezel name="6.2" element="led"><bounds x="12" y="4" width="1" height="1" /></bezel> - <bezel name="6.3" element="led"><bounds x="12" y="6" width="1" height="1" /></bezel> - <bezel name="6.4" element="led"><bounds x="12" y="8" width="1" height="1" /></bezel> - <bezel name="6.5" element="led"><bounds x="12" y="10" width="1" height="1" /></bezel> - <bezel name="6.6" element="led"><bounds x="12" y="12" width="1" height="1" /></bezel> - <bezel name="6.7" element="led"><bounds x="12" y="14" width="1" height="1" /></bezel> - <bezel name="6.8" element="led"><bounds x="12" y="16" width="1" height="1" /></bezel> - <bezel name="6.9" element="led"><bounds x="12" y="18" width="1" height="1" /></bezel> - <bezel name="6.10" element="led"><bounds x="12" y="20" width="1" height="1" /></bezel> - <bezel name="6.11" element="led"><bounds x="12" y="22" width="1" height="1" /></bezel> - <bezel name="6.12" element="led"><bounds x="12" y="24" width="1" height="1" /></bezel> - <bezel name="6.13" element="led"><bounds x="12" y="26" width="1" height="1" /></bezel> - <bezel name="6.14" element="led"><bounds x="12" y="28" width="1" height="1" /></bezel> - <bezel name="6.15" element="led"><bounds x="12" y="30" width="1" height="1" /></bezel> + <bezel name="1.0.0" element="led"><bounds x="10" y="0" width="1" height="1" /></bezel> + <bezel name="1.1.0" element="led"><bounds x="10" y="2" width="1" height="1" /></bezel> + <bezel name="1.2.0" element="led"><bounds x="10" y="4" width="1" height="1" /></bezel> + <bezel name="1.3.0" element="led"><bounds x="10" y="6" width="1" height="1" /></bezel> + <bezel name="1.4.0" element="led"><bounds x="10" y="8" width="1" height="1" /></bezel> + <bezel name="1.5.0" element="led"><bounds x="10" y="10" width="1" height="1" /></bezel> + <bezel name="1.6.0" element="led"><bounds x="10" y="12" width="1" height="1" /></bezel> + <bezel name="1.7.0" element="led"><bounds x="10" y="14" width="1" height="1" /></bezel> + <bezel name="1.8.0" element="led"><bounds x="10" y="16" width="1" height="1" /></bezel> + <bezel name="1.9.0" element="led"><bounds x="10" y="18" width="1" height="1" /></bezel> + <bezel name="1.10.0" element="led"><bounds x="10" y="20" width="1" height="1" /></bezel> + <bezel name="1.11.0" element="led"><bounds x="10" y="22" width="1" height="1" /></bezel> + <bezel name="1.12.0" element="led"><bounds x="10" y="24" width="1" height="1" /></bezel> + <bezel name="1.13.0" element="led"><bounds x="10" y="26" width="1" height="1" /></bezel> + <bezel name="1.14.0" element="led"><bounds x="10" y="28" width="1" height="1" /></bezel> + <bezel name="1.15.0" element="led"><bounds x="10" y="30" width="1" height="1" /></bezel> - <bezel name="7.0" element="led"><bounds x="14" y="0" width="1" height="1" /></bezel> - <bezel name="7.1" element="led"><bounds x="14" y="2" width="1" height="1" /></bezel> - <bezel name="7.2" element="led"><bounds x="14" y="4" width="1" height="1" /></bezel> - <bezel name="7.3" element="led"><bounds x="14" y="6" width="1" height="1" /></bezel> - <bezel name="7.4" element="led"><bounds x="14" y="8" width="1" height="1" /></bezel> - <bezel name="7.5" element="led"><bounds x="14" y="10" width="1" height="1" /></bezel> - <bezel name="7.6" element="led"><bounds x="14" y="12" width="1" height="1" /></bezel> - <bezel name="7.7" element="led"><bounds x="14" y="14" width="1" height="1" /></bezel> - <bezel name="7.8" element="led"><bounds x="14" y="16" width="1" height="1" /></bezel> - <bezel name="7.9" element="led"><bounds x="14" y="18" width="1" height="1" /></bezel> - <bezel name="7.10" element="led"><bounds x="14" y="20" width="1" height="1" /></bezel> - <bezel name="7.11" element="led"><bounds x="14" y="22" width="1" height="1" /></bezel> - <bezel name="7.12" element="led"><bounds x="14" y="24" width="1" height="1" /></bezel> - <bezel name="7.13" element="led"><bounds x="14" y="26" width="1" height="1" /></bezel> - <bezel name="7.14" element="led"><bounds x="14" y="28" width="1" height="1" /></bezel> - <bezel name="7.15" element="led"><bounds x="14" y="30" width="1" height="1" /></bezel> + <bezel name="1.0.1" element="led"><bounds x="12" y="0" width="1" height="1" /></bezel> + <bezel name="1.1.1" element="led"><bounds x="12" y="2" width="1" height="1" /></bezel> + <bezel name="1.2.1" element="led"><bounds x="12" y="4" width="1" height="1" /></bezel> + <bezel name="1.3.1" element="led"><bounds x="12" y="6" width="1" height="1" /></bezel> + <bezel name="1.4.1" element="led"><bounds x="12" y="8" width="1" height="1" /></bezel> + <bezel name="1.5.1" element="led"><bounds x="12" y="10" width="1" height="1" /></bezel> + <bezel name="1.6.1" element="led"><bounds x="12" y="12" width="1" height="1" /></bezel> + <bezel name="1.7.1" element="led"><bounds x="12" y="14" width="1" height="1" /></bezel> + <bezel name="1.8.1" element="led"><bounds x="12" y="16" width="1" height="1" /></bezel> + <bezel name="1.9.1" element="led"><bounds x="12" y="18" width="1" height="1" /></bezel> + <bezel name="1.10.1" element="led"><bounds x="12" y="20" width="1" height="1" /></bezel> + <bezel name="1.11.1" element="led"><bounds x="12" y="22" width="1" height="1" /></bezel> + <bezel name="1.12.1" element="led"><bounds x="12" y="24" width="1" height="1" /></bezel> + <bezel name="1.13.1" element="led"><bounds x="12" y="26" width="1" height="1" /></bezel> + <bezel name="1.14.1" element="led"><bounds x="12" y="28" width="1" height="1" /></bezel> + <bezel name="1.15.1" element="led"><bounds x="12" y="30" width="1" height="1" /></bezel> - <bezel name="8.0" element="led"><bounds x="16" y="0" width="1" height="1" /></bezel> - <bezel name="8.1" element="led"><bounds x="16" y="2" width="1" height="1" /></bezel> - <bezel name="8.2" element="led"><bounds x="16" y="4" width="1" height="1" /></bezel> - <bezel name="8.3" element="led"><bounds x="16" y="6" width="1" height="1" /></bezel> - <bezel name="8.4" element="led"><bounds x="16" y="8" width="1" height="1" /></bezel> - <bezel name="8.5" element="led"><bounds x="16" y="10" width="1" height="1" /></bezel> - <bezel name="8.6" element="led"><bounds x="16" y="12" width="1" height="1" /></bezel> - <bezel name="8.7" element="led"><bounds x="16" y="14" width="1" height="1" /></bezel> - <bezel name="8.8" element="led"><bounds x="16" y="16" width="1" height="1" /></bezel> - <bezel name="8.9" element="led"><bounds x="16" y="18" width="1" height="1" /></bezel> - <bezel name="8.10" element="led"><bounds x="16" y="20" width="1" height="1" /></bezel> - <bezel name="8.11" element="led"><bounds x="16" y="22" width="1" height="1" /></bezel> - <bezel name="8.12" element="led"><bounds x="16" y="24" width="1" height="1" /></bezel> - <bezel name="8.13" element="led"><bounds x="16" y="26" width="1" height="1" /></bezel> - <bezel name="8.14" element="led"><bounds x="16" y="28" width="1" height="1" /></bezel> - <bezel name="8.15" element="led"><bounds x="16" y="30" width="1" height="1" /></bezel> + <bezel name="1.0.2" element="led"><bounds x="14" y="0" width="1" height="1" /></bezel> + <bezel name="1.1.2" element="led"><bounds x="14" y="2" width="1" height="1" /></bezel> + <bezel name="1.2.2" element="led"><bounds x="14" y="4" width="1" height="1" /></bezel> + <bezel name="1.3.2" element="led"><bounds x="14" y="6" width="1" height="1" /></bezel> + <bezel name="1.4.2" element="led"><bounds x="14" y="8" width="1" height="1" /></bezel> + <bezel name="1.5.2" element="led"><bounds x="14" y="10" width="1" height="1" /></bezel> + <bezel name="1.6.2" element="led"><bounds x="14" y="12" width="1" height="1" /></bezel> + <bezel name="1.7.2" element="led"><bounds x="14" y="14" width="1" height="1" /></bezel> + <bezel name="1.8.2" element="led"><bounds x="14" y="16" width="1" height="1" /></bezel> + <bezel name="1.9.2" element="led"><bounds x="14" y="18" width="1" height="1" /></bezel> + <bezel name="1.10.2" element="led"><bounds x="14" y="20" width="1" height="1" /></bezel> + <bezel name="1.11.2" element="led"><bounds x="14" y="22" width="1" height="1" /></bezel> + <bezel name="1.12.2" element="led"><bounds x="14" y="24" width="1" height="1" /></bezel> + <bezel name="1.13.2" element="led"><bounds x="14" y="26" width="1" height="1" /></bezel> + <bezel name="1.14.2" element="led"><bounds x="14" y="28" width="1" height="1" /></bezel> + <bezel name="1.15.2" element="led"><bounds x="14" y="30" width="1" height="1" /></bezel> - <bezel name="9.0" element="led"><bounds x="18" y="0" width="1" height="1" /></bezel> - <bezel name="9.1" element="led"><bounds x="18" y="2" width="1" height="1" /></bezel> - <bezel name="9.2" element="led"><bounds x="18" y="4" width="1" height="1" /></bezel> - <bezel name="9.3" element="led"><bounds x="18" y="6" width="1" height="1" /></bezel> - <bezel name="9.4" element="led"><bounds x="18" y="8" width="1" height="1" /></bezel> - <bezel name="9.5" element="led"><bounds x="18" y="10" width="1" height="1" /></bezel> - <bezel name="9.6" element="led"><bounds x="18" y="12" width="1" height="1" /></bezel> - <bezel name="9.7" element="led"><bounds x="18" y="14" width="1" height="1" /></bezel> - <bezel name="9.8" element="led"><bounds x="18" y="16" width="1" height="1" /></bezel> - <bezel name="9.9" element="led"><bounds x="18" y="18" width="1" height="1" /></bezel> - <bezel name="9.10" element="led"><bounds x="18" y="20" width="1" height="1" /></bezel> - <bezel name="9.11" element="led"><bounds x="18" y="22" width="1" height="1" /></bezel> - <bezel name="9.12" element="led"><bounds x="18" y="24" width="1" height="1" /></bezel> - <bezel name="9.13" element="led"><bounds x="18" y="26" width="1" height="1" /></bezel> - <bezel name="9.14" element="led"><bounds x="18" y="28" width="1" height="1" /></bezel> - <bezel name="9.15" element="led"><bounds x="18" y="30" width="1" height="1" /></bezel> + <bezel name="1.0.3" element="led"><bounds x="16" y="0" width="1" height="1" /></bezel> + <bezel name="1.1.3" element="led"><bounds x="16" y="2" width="1" height="1" /></bezel> + <bezel name="1.2.3" element="led"><bounds x="16" y="4" width="1" height="1" /></bezel> + <bezel name="1.3.3" element="led"><bounds x="16" y="6" width="1" height="1" /></bezel> + <bezel name="1.4.3" element="led"><bounds x="16" y="8" width="1" height="1" /></bezel> + <bezel name="1.5.3" element="led"><bounds x="16" y="10" width="1" height="1" /></bezel> + <bezel name="1.6.3" element="led"><bounds x="16" y="12" width="1" height="1" /></bezel> + <bezel name="1.7.3" element="led"><bounds x="16" y="14" width="1" height="1" /></bezel> + <bezel name="1.8.3" element="led"><bounds x="16" y="16" width="1" height="1" /></bezel> + <bezel name="1.9.3" element="led"><bounds x="16" y="18" width="1" height="1" /></bezel> + <bezel name="1.10.3" element="led"><bounds x="16" y="20" width="1" height="1" /></bezel> + <bezel name="1.11.3" element="led"><bounds x="16" y="22" width="1" height="1" /></bezel> + <bezel name="1.12.3" element="led"><bounds x="16" y="24" width="1" height="1" /></bezel> + <bezel name="1.13.3" element="led"><bounds x="16" y="26" width="1" height="1" /></bezel> + <bezel name="1.14.3" element="led"><bounds x="16" y="28" width="1" height="1" /></bezel> + <bezel name="1.15.3" element="led"><bounds x="16" y="30" width="1" height="1" /></bezel> - <bezel name="10.0" element="led"><bounds x="20" y="0" width="1" height="1" /></bezel> - <bezel name="10.1" element="led"><bounds x="20" y="2" width="1" height="1" /></bezel> - <bezel name="10.2" element="led"><bounds x="20" y="4" width="1" height="1" /></bezel> - <bezel name="10.3" element="led"><bounds x="20" y="6" width="1" height="1" /></bezel> - <bezel name="10.4" element="led"><bounds x="20" y="8" width="1" height="1" /></bezel> - <bezel name="10.5" element="led"><bounds x="20" y="10" width="1" height="1" /></bezel> - <bezel name="10.6" element="led"><bounds x="20" y="12" width="1" height="1" /></bezel> - <bezel name="10.7" element="led"><bounds x="20" y="14" width="1" height="1" /></bezel> - <bezel name="10.8" element="led"><bounds x="20" y="16" width="1" height="1" /></bezel> - <bezel name="10.9" element="led"><bounds x="20" y="18" width="1" height="1" /></bezel> - <bezel name="10.10" element="led"><bounds x="20" y="20" width="1" height="1" /></bezel> - <bezel name="10.11" element="led"><bounds x="20" y="22" width="1" height="1" /></bezel> - <bezel name="10.12" element="led"><bounds x="20" y="24" width="1" height="1" /></bezel> - <bezel name="10.13" element="led"><bounds x="20" y="26" width="1" height="1" /></bezel> - <bezel name="10.14" element="led"><bounds x="20" y="28" width="1" height="1" /></bezel> - <bezel name="10.15" element="led"><bounds x="20" y="30" width="1" height="1" /></bezel> + <!-- bs --> - <bezel name="11.0" element="led"><bounds x="22" y="0" width="1" height="1" /></bezel> - <bezel name="11.1" element="led"><bounds x="22" y="2" width="1" height="1" /></bezel> - <bezel name="11.2" element="led"><bounds x="22" y="4" width="1" height="1" /></bezel> - <bezel name="11.3" element="led"><bounds x="22" y="6" width="1" height="1" /></bezel> - <bezel name="11.4" element="led"><bounds x="22" y="8" width="1" height="1" /></bezel> - <bezel name="11.5" element="led"><bounds x="22" y="10" width="1" height="1" /></bezel> - <bezel name="11.6" element="led"><bounds x="22" y="12" width="1" height="1" /></bezel> - <bezel name="11.7" element="led"><bounds x="22" y="14" width="1" height="1" /></bezel> - <bezel name="11.8" element="led"><bounds x="22" y="16" width="1" height="1" /></bezel> - <bezel name="11.9" element="led"><bounds x="22" y="18" width="1" height="1" /></bezel> - <bezel name="11.10" element="led"><bounds x="22" y="20" width="1" height="1" /></bezel> - <bezel name="11.11" element="led"><bounds x="22" y="22" width="1" height="1" /></bezel> - <bezel name="11.12" element="led"><bounds x="22" y="24" width="1" height="1" /></bezel> - <bezel name="11.13" element="led"><bounds x="22" y="26" width="1" height="1" /></bezel> - <bezel name="11.14" element="led"><bounds x="22" y="28" width="1" height="1" /></bezel> - <bezel name="11.15" element="led"><bounds x="22" y="30" width="1" height="1" /></bezel> + <bezel name="2.0.0" element="led"><bounds x="20" y="0" width="1" height="1" /></bezel> + <bezel name="2.1.0" element="led"><bounds x="20" y="2" width="1" height="1" /></bezel> + <bezel name="2.2.0" element="led"><bounds x="20" y="4" width="1" height="1" /></bezel> + <bezel name="2.3.0" element="led"><bounds x="20" y="6" width="1" height="1" /></bezel> + <bezel name="2.4.0" element="led"><bounds x="20" y="8" width="1" height="1" /></bezel> + <bezel name="2.5.0" element="led"><bounds x="20" y="10" width="1" height="1" /></bezel> + <bezel name="2.6.0" element="led"><bounds x="20" y="12" width="1" height="1" /></bezel> + <bezel name="2.7.0" element="led"><bounds x="20" y="14" width="1" height="1" /></bezel> + <bezel name="2.8.0" element="led"><bounds x="20" y="16" width="1" height="1" /></bezel> + <bezel name="2.9.0" element="led"><bounds x="20" y="18" width="1" height="1" /></bezel> + <bezel name="2.10.0" element="led"><bounds x="20" y="20" width="1" height="1" /></bezel> + <bezel name="2.11.0" element="led"><bounds x="20" y="22" width="1" height="1" /></bezel> + <bezel name="2.12.0" element="led"><bounds x="20" y="24" width="1" height="1" /></bezel> + <bezel name="2.13.0" element="led"><bounds x="20" y="26" width="1" height="1" /></bezel> + <bezel name="2.14.0" element="led"><bounds x="20" y="28" width="1" height="1" /></bezel> + <bezel name="2.15.0" element="led"><bounds x="20" y="30" width="1" height="1" /></bezel> - <bezel name="12.0" element="led"><bounds x="24" y="0" width="1" height="1" /></bezel> - <bezel name="12.1" element="led"><bounds x="24" y="2" width="1" height="1" /></bezel> - <bezel name="12.2" element="led"><bounds x="24" y="4" width="1" height="1" /></bezel> - <bezel name="12.3" element="led"><bounds x="24" y="6" width="1" height="1" /></bezel> - <bezel name="12.4" element="led"><bounds x="24" y="8" width="1" height="1" /></bezel> - <bezel name="12.5" element="led"><bounds x="24" y="10" width="1" height="1" /></bezel> - <bezel name="12.6" element="led"><bounds x="24" y="12" width="1" height="1" /></bezel> - <bezel name="12.7" element="led"><bounds x="24" y="14" width="1" height="1" /></bezel> - <bezel name="12.8" element="led"><bounds x="24" y="16" width="1" height="1" /></bezel> - <bezel name="12.9" element="led"><bounds x="24" y="18" width="1" height="1" /></bezel> - <bezel name="12.10" element="led"><bounds x="24" y="20" width="1" height="1" /></bezel> - <bezel name="12.11" element="led"><bounds x="24" y="22" width="1" height="1" /></bezel> - <bezel name="12.12" element="led"><bounds x="24" y="24" width="1" height="1" /></bezel> - <bezel name="12.13" element="led"><bounds x="24" y="26" width="1" height="1" /></bezel> - <bezel name="12.14" element="led"><bounds x="24" y="28" width="1" height="1" /></bezel> - <bezel name="12.15" element="led"><bounds x="24" y="30" width="1" height="1" /></bezel> + <bezel name="2.0.1" element="led"><bounds x="22" y="0" width="1" height="1" /></bezel> + <bezel name="2.1.1" element="led"><bounds x="22" y="2" width="1" height="1" /></bezel> + <bezel name="2.2.1" element="led"><bounds x="22" y="4" width="1" height="1" /></bezel> + <bezel name="2.3.1" element="led"><bounds x="22" y="6" width="1" height="1" /></bezel> + <bezel name="2.4.1" element="led"><bounds x="22" y="8" width="1" height="1" /></bezel> + <bezel name="2.5.1" element="led"><bounds x="22" y="10" width="1" height="1" /></bezel> + <bezel name="2.6.1" element="led"><bounds x="22" y="12" width="1" height="1" /></bezel> + <bezel name="2.7.1" element="led"><bounds x="22" y="14" width="1" height="1" /></bezel> + <bezel name="2.8.1" element="led"><bounds x="22" y="16" width="1" height="1" /></bezel> + <bezel name="2.9.1" element="led"><bounds x="22" y="18" width="1" height="1" /></bezel> + <bezel name="2.10.1" element="led"><bounds x="22" y="20" width="1" height="1" /></bezel> + <bezel name="2.11.1" element="led"><bounds x="22" y="22" width="1" height="1" /></bezel> + <bezel name="2.12.1" element="led"><bounds x="22" y="24" width="1" height="1" /></bezel> + <bezel name="2.13.1" element="led"><bounds x="22" y="26" width="1" height="1" /></bezel> + <bezel name="2.14.1" element="led"><bounds x="22" y="28" width="1" height="1" /></bezel> + <bezel name="2.15.1" element="led"><bounds x="22" y="30" width="1" height="1" /></bezel> - <bezel name="13.0" element="led"><bounds x="26" y="0" width="1" height="1" /></bezel> - <bezel name="13.1" element="led"><bounds x="26" y="2" width="1" height="1" /></bezel> - <bezel name="13.2" element="led"><bounds x="26" y="4" width="1" height="1" /></bezel> - <bezel name="13.3" element="led"><bounds x="26" y="6" width="1" height="1" /></bezel> - <bezel name="13.4" element="led"><bounds x="26" y="8" width="1" height="1" /></bezel> - <bezel name="13.5" element="led"><bounds x="26" y="10" width="1" height="1" /></bezel> - <bezel name="13.6" element="led"><bounds x="26" y="12" width="1" height="1" /></bezel> - <bezel name="13.7" element="led"><bounds x="26" y="14" width="1" height="1" /></bezel> - <bezel name="13.8" element="led"><bounds x="26" y="16" width="1" height="1" /></bezel> - <bezel name="13.9" element="led"><bounds x="26" y="18" width="1" height="1" /></bezel> - <bezel name="13.10" element="led"><bounds x="26" y="20" width="1" height="1" /></bezel> - <bezel name="13.11" element="led"><bounds x="26" y="22" width="1" height="1" /></bezel> - <bezel name="13.12" element="led"><bounds x="26" y="24" width="1" height="1" /></bezel> - <bezel name="13.13" element="led"><bounds x="26" y="26" width="1" height="1" /></bezel> - <bezel name="13.14" element="led"><bounds x="26" y="28" width="1" height="1" /></bezel> - <bezel name="13.15" element="led"><bounds x="26" y="30" width="1" height="1" /></bezel> + <bezel name="2.0.2" element="led"><bounds x="24" y="0" width="1" height="1" /></bezel> + <bezel name="2.1.2" element="led"><bounds x="24" y="2" width="1" height="1" /></bezel> + <bezel name="2.2.2" element="led"><bounds x="24" y="4" width="1" height="1" /></bezel> + <bezel name="2.3.2" element="led"><bounds x="24" y="6" width="1" height="1" /></bezel> + <bezel name="2.4.2" element="led"><bounds x="24" y="8" width="1" height="1" /></bezel> + <bezel name="2.5.2" element="led"><bounds x="24" y="10" width="1" height="1" /></bezel> + <bezel name="2.6.2" element="led"><bounds x="24" y="12" width="1" height="1" /></bezel> + <bezel name="2.7.2" element="led"><bounds x="24" y="14" width="1" height="1" /></bezel> + <bezel name="2.8.2" element="led"><bounds x="24" y="16" width="1" height="1" /></bezel> + <bezel name="2.9.2" element="led"><bounds x="24" y="18" width="1" height="1" /></bezel> + <bezel name="2.10.2" element="led"><bounds x="24" y="20" width="1" height="1" /></bezel> + <bezel name="2.11.2" element="led"><bounds x="24" y="22" width="1" height="1" /></bezel> + <bezel name="2.12.2" element="led"><bounds x="24" y="24" width="1" height="1" /></bezel> + <bezel name="2.13.2" element="led"><bounds x="24" y="26" width="1" height="1" /></bezel> + <bezel name="2.14.2" element="led"><bounds x="24" y="28" width="1" height="1" /></bezel> + <bezel name="2.15.2" element="led"><bounds x="24" y="30" width="1" height="1" /></bezel> - <bezel name="14.0" element="led"><bounds x="28" y="0" width="1" height="1" /></bezel> - <bezel name="14.1" element="led"><bounds x="28" y="2" width="1" height="1" /></bezel> - <bezel name="14.2" element="led"><bounds x="28" y="4" width="1" height="1" /></bezel> - <bezel name="14.3" element="led"><bounds x="28" y="6" width="1" height="1" /></bezel> - <bezel name="14.4" element="led"><bounds x="28" y="8" width="1" height="1" /></bezel> - <bezel name="14.5" element="led"><bounds x="28" y="10" width="1" height="1" /></bezel> - <bezel name="14.6" element="led"><bounds x="28" y="12" width="1" height="1" /></bezel> - <bezel name="14.7" element="led"><bounds x="28" y="14" width="1" height="1" /></bezel> - <bezel name="14.8" element="led"><bounds x="28" y="16" width="1" height="1" /></bezel> - <bezel name="14.9" element="led"><bounds x="28" y="18" width="1" height="1" /></bezel> - <bezel name="14.10" element="led"><bounds x="28" y="20" width="1" height="1" /></bezel> - <bezel name="14.11" element="led"><bounds x="28" y="22" width="1" height="1" /></bezel> - <bezel name="14.12" element="led"><bounds x="28" y="24" width="1" height="1" /></bezel> - <bezel name="14.13" element="led"><bounds x="28" y="26" width="1" height="1" /></bezel> - <bezel name="14.14" element="led"><bounds x="28" y="28" width="1" height="1" /></bezel> - <bezel name="14.15" element="led"><bounds x="28" y="30" width="1" height="1" /></bezel> + <bezel name="2.0.3" element="led"><bounds x="26" y="0" width="1" height="1" /></bezel> + <bezel name="2.1.3" element="led"><bounds x="26" y="2" width="1" height="1" /></bezel> + <bezel name="2.2.3" element="led"><bounds x="26" y="4" width="1" height="1" /></bezel> + <bezel name="2.3.3" element="led"><bounds x="26" y="6" width="1" height="1" /></bezel> + <bezel name="2.4.3" element="led"><bounds x="26" y="8" width="1" height="1" /></bezel> + <bezel name="2.5.3" element="led"><bounds x="26" y="10" width="1" height="1" /></bezel> + <bezel name="2.6.3" element="led"><bounds x="26" y="12" width="1" height="1" /></bezel> + <bezel name="2.7.3" element="led"><bounds x="26" y="14" width="1" height="1" /></bezel> + <bezel name="2.8.3" element="led"><bounds x="26" y="16" width="1" height="1" /></bezel> + <bezel name="2.9.3" element="led"><bounds x="26" y="18" width="1" height="1" /></bezel> + <bezel name="2.10.3" element="led"><bounds x="26" y="20" width="1" height="1" /></bezel> + <bezel name="2.11.3" element="led"><bounds x="26" y="22" width="1" height="1" /></bezel> + <bezel name="2.12.3" element="led"><bounds x="26" y="24" width="1" height="1" /></bezel> + <bezel name="2.13.3" element="led"><bounds x="26" y="26" width="1" height="1" /></bezel> + <bezel name="2.14.3" element="led"><bounds x="26" y="28" width="1" height="1" /></bezel> + <bezel name="2.15.3" element="led"><bounds x="26" y="30" width="1" height="1" /></bezel> - <bezel name="15.0" element="led"><bounds x="30" y="0" width="1" height="1" /></bezel> - <bezel name="15.1" element="led"><bounds x="30" y="2" width="1" height="1" /></bezel> - <bezel name="15.2" element="led"><bounds x="30" y="4" width="1" height="1" /></bezel> - <bezel name="15.3" element="led"><bounds x="30" y="6" width="1" height="1" /></bezel> - <bezel name="15.4" element="led"><bounds x="30" y="8" width="1" height="1" /></bezel> - <bezel name="15.5" element="led"><bounds x="30" y="10" width="1" height="1" /></bezel> - <bezel name="15.6" element="led"><bounds x="30" y="12" width="1" height="1" /></bezel> - <bezel name="15.7" element="led"><bounds x="30" y="14" width="1" height="1" /></bezel> - <bezel name="15.8" element="led"><bounds x="30" y="16" width="1" height="1" /></bezel> - <bezel name="15.9" element="led"><bounds x="30" y="18" width="1" height="1" /></bezel> - <bezel name="15.10" element="led"><bounds x="30" y="20" width="1" height="1" /></bezel> - <bezel name="15.11" element="led"><bounds x="30" y="22" width="1" height="1" /></bezel> - <bezel name="15.12" element="led"><bounds x="30" y="24" width="1" height="1" /></bezel> - <bezel name="15.13" element="led"><bounds x="30" y="26" width="1" height="1" /></bezel> - <bezel name="15.14" element="led"><bounds x="30" y="28" width="1" height="1" /></bezel> - <bezel name="15.15" element="led"><bounds x="30" y="30" width="1" height="1" /></bezel> + <!-- c --> + <bezel name="3.0.0" element="led"><bounds x="30" y="0" width="1" height="1" /></bezel> + <bezel name="3.1.0" element="led"><bounds x="30" y="2" width="1" height="1" /></bezel> + <bezel name="3.2.0" element="led"><bounds x="30" y="4" width="1" height="1" /></bezel> + <bezel name="3.3.0" element="led"><bounds x="30" y="6" width="1" height="1" /></bezel> + <bezel name="3.4.0" element="led"><bounds x="30" y="8" width="1" height="1" /></bezel> + <bezel name="3.5.0" element="led"><bounds x="30" y="10" width="1" height="1" /></bezel> + <bezel name="3.6.0" element="led"><bounds x="30" y="12" width="1" height="1" /></bezel> + <bezel name="3.7.0" element="led"><bounds x="30" y="14" width="1" height="1" /></bezel> + <bezel name="3.8.0" element="led"><bounds x="30" y="16" width="1" height="1" /></bezel> + <bezel name="3.9.0" element="led"><bounds x="30" y="18" width="1" height="1" /></bezel> + <bezel name="3.10.0" element="led"><bounds x="30" y="20" width="1" height="1" /></bezel> + <bezel name="3.11.0" element="led"><bounds x="30" y="22" width="1" height="1" /></bezel> + <bezel name="3.12.0" element="led"><bounds x="30" y="24" width="1" height="1" /></bezel> + <bezel name="3.13.0" element="led"><bounds x="30" y="26" width="1" height="1" /></bezel> + <bezel name="3.14.0" element="led"><bounds x="30" y="28" width="1" height="1" /></bezel> + <bezel name="3.15.0" element="led"><bounds x="30" y="30" width="1" height="1" /></bezel> + + <bezel name="3.0.1" element="led"><bounds x="32" y="0" width="1" height="1" /></bezel> + <bezel name="3.1.1" element="led"><bounds x="32" y="2" width="1" height="1" /></bezel> + <bezel name="3.2.1" element="led"><bounds x="32" y="4" width="1" height="1" /></bezel> + <bezel name="3.3.1" element="led"><bounds x="32" y="6" width="1" height="1" /></bezel> + <bezel name="3.4.1" element="led"><bounds x="32" y="8" width="1" height="1" /></bezel> + <bezel name="3.5.1" element="led"><bounds x="32" y="10" width="1" height="1" /></bezel> + <bezel name="3.6.1" element="led"><bounds x="32" y="12" width="1" height="1" /></bezel> + <bezel name="3.7.1" element="led"><bounds x="32" y="14" width="1" height="1" /></bezel> + <bezel name="3.8.1" element="led"><bounds x="32" y="16" width="1" height="1" /></bezel> + <bezel name="3.9.1" element="led"><bounds x="32" y="18" width="1" height="1" /></bezel> + <bezel name="3.10.1" element="led"><bounds x="32" y="20" width="1" height="1" /></bezel> + <bezel name="3.11.1" element="led"><bounds x="32" y="22" width="1" height="1" /></bezel> + <bezel name="3.12.1" element="led"><bounds x="32" y="24" width="1" height="1" /></bezel> + <bezel name="3.13.1" element="led"><bounds x="32" y="26" width="1" height="1" /></bezel> + <bezel name="3.14.1" element="led"><bounds x="32" y="28" width="1" height="1" /></bezel> + <bezel name="3.15.1" element="led"><bounds x="32" y="30" width="1" height="1" /></bezel> + + <bezel name="3.0.2" element="led"><bounds x="34" y="0" width="1" height="1" /></bezel> + <bezel name="3.1.2" element="led"><bounds x="34" y="2" width="1" height="1" /></bezel> + <bezel name="3.2.2" element="led"><bounds x="34" y="4" width="1" height="1" /></bezel> + <bezel name="3.3.2" element="led"><bounds x="34" y="6" width="1" height="1" /></bezel> + <bezel name="3.4.2" element="led"><bounds x="34" y="8" width="1" height="1" /></bezel> + <bezel name="3.5.2" element="led"><bounds x="34" y="10" width="1" height="1" /></bezel> + <bezel name="3.6.2" element="led"><bounds x="34" y="12" width="1" height="1" /></bezel> + <bezel name="3.7.2" element="led"><bounds x="34" y="14" width="1" height="1" /></bezel> + <bezel name="3.8.2" element="led"><bounds x="34" y="16" width="1" height="1" /></bezel> + <bezel name="3.9.2" element="led"><bounds x="34" y="18" width="1" height="1" /></bezel> + <bezel name="3.10.2" element="led"><bounds x="34" y="20" width="1" height="1" /></bezel> + <bezel name="3.11.2" element="led"><bounds x="34" y="22" width="1" height="1" /></bezel> + <bezel name="3.12.2" element="led"><bounds x="34" y="24" width="1" height="1" /></bezel> + <bezel name="3.13.2" element="led"><bounds x="34" y="26" width="1" height="1" /></bezel> + <bezel name="3.14.2" element="led"><bounds x="34" y="28" width="1" height="1" /></bezel> + <bezel name="3.15.2" element="led"><bounds x="34" y="30" width="1" height="1" /></bezel> + + <bezel name="3.0.3" element="led"><bounds x="36" y="0" width="1" height="1" /></bezel> + <bezel name="3.1.3" element="led"><bounds x="36" y="2" width="1" height="1" /></bezel> + <bezel name="3.2.3" element="led"><bounds x="36" y="4" width="1" height="1" /></bezel> + <bezel name="3.3.3" element="led"><bounds x="36" y="6" width="1" height="1" /></bezel> + <bezel name="3.4.3" element="led"><bounds x="36" y="8" width="1" height="1" /></bezel> + <bezel name="3.5.3" element="led"><bounds x="36" y="10" width="1" height="1" /></bezel> + <bezel name="3.6.3" element="led"><bounds x="36" y="12" width="1" height="1" /></bezel> + <bezel name="3.7.3" element="led"><bounds x="36" y="14" width="1" height="1" /></bezel> + <bezel name="3.8.3" element="led"><bounds x="36" y="16" width="1" height="1" /></bezel> + <bezel name="3.9.3" element="led"><bounds x="36" y="18" width="1" height="1" /></bezel> + <bezel name="3.10.3" element="led"><bounds x="36" y="20" width="1" height="1" /></bezel> + <bezel name="3.11.3" element="led"><bounds x="36" y="22" width="1" height="1" /></bezel> + <bezel name="3.12.3" element="led"><bounds x="36" y="24" width="1" height="1" /></bezel> + <bezel name="3.13.3" element="led"><bounds x="36" y="26" width="1" height="1" /></bezel> + <bezel name="3.14.3" element="led"><bounds x="36" y="28" width="1" height="1" /></bezel> + <bezel name="3.15.3" element="led"><bounds x="36" y="30" width="1" height="1" /></bezel> </view> </mamelayout> diff --git a/src/mame/machine/iteagle_fpga.cpp b/src/mame/machine/iteagle_fpga.cpp index 40e1a9bb19e..7f4c6218f67 100644 --- a/src/mame/machine/iteagle_fpga.cpp +++ b/src/mame/machine/iteagle_fpga.cpp @@ -73,9 +73,11 @@ void iteagle_fpga_device::device_reset() m_seq_rem1 = 0; m_seq_rem2 = 0; + // Nibble starting at bit 20 is resolution, byte 0 is atmel response // 0x00080000 and interrupt starts reading from 0x14 // 0x02000000 and interrupt starts reading from 0x18 - m_fpga_regs[0x04/4] = 0x00000000; // Nibble starting at bit 20 is resolution, byte 0 is atmel response + // Write 0x01000000 is a global interrupt clear + m_fpga_regs[0x04/4] = 0x00000000; m_prev_reg = 0; m_serial_str.clear(); @@ -89,6 +91,7 @@ void iteagle_fpga_device::device_reset() m_serial_com1[0] = 0x2c; m_serial_com2[0] = 0x2c; m_serial_com3[0] = 0x2c; + m_serial_rx3.clear(); } void iteagle_fpga_device::update_sequence(UINT32 data) @@ -144,7 +147,7 @@ void iteagle_fpga_device::update_sequence_eg1(UINT32 data) m_seq = (m_seq>>9) | ((feed&0x1ff)<<15); m_fpga_regs[offset] = (m_fpga_regs[offset]&0xFFFFFF00) | ((val1 + m_seq_rem1 + m_seq_rem2) & 0xff); } - if (0 && LOG_FPGA) + if (0 && LOG_FPGA) logerror("%s:fpga update_sequence In: %02X Seq: %06X Out: %02X other %02X%02X%02X\n", machine().describe_context(), data, m_seq, m_fpga_regs[offset]&0xff, m_seq_rem2, m_seq_rem1, val1); } @@ -154,7 +157,7 @@ void iteagle_fpga_device::update_sequence_eg1(UINT32 data) //------------------------------------------------- void iteagle_fpga_device::device_timer(emu_timer &timer, device_timer_id tid, int param, void *ptr) { - if (m_fpga_regs[0x4/4]&0x01000000) { + if (m_fpga_regs[0x4/4] & 0x01000000) { //m_fpga_regs[0x04/4] |= 0x02080000; m_fpga_regs[0x04/4] |= 0x00080000; m_cpu->set_input_line(m_irq_num, ASSERT_LINE); @@ -179,7 +182,6 @@ READ32_MEMBER( iteagle_fpga_device::fpga_r ) if (LOG_FPGA && !ACCESSING_BITS_0_7) logerror("%s:fpga_r offset %04X = %08X & %08X\n", machine().describe_context(), offset*4, result, mem_mask); break; - case 0x08/4: result = ((machine().root_device().ioport("TRACKY1")->read()&0xff)<<8) | (machine().root_device().ioport("TRACKX1")->read()&0xff); if (LOG_FPGA && m_prev_reg!=offset) @@ -195,7 +197,7 @@ READ32_MEMBER( iteagle_fpga_device::fpga_r ) if (LOG_FPGA) logerror("%s:fpga_r offset %04X = %08X & %08X\n", machine().describe_context(), offset*4, result, mem_mask); break; - case 0x0c/4: // 1d = modem byte + case 0x0c/4: // result = (result & 0xFFFF0000) | ((m_serial_com1[m_serial_idx]&0xff)<<8) | (m_serial_com0[m_serial_idx]&0xff); if (ACCESSING_BITS_0_15) { m_serial_data = false; @@ -210,12 +212,25 @@ READ32_MEMBER( iteagle_fpga_device::fpga_r ) m_serial_data = false; m_serial_idx = 0; } + if (ACCESSING_BITS_24_31) { + if (!m_serial_rx3.empty()) { + logerror("fpga_r: read byte: %c\n", m_serial_rx3.at(0)); + result = (result & 0x00FFFFFF) | (m_serial_rx3.at(0)<<24); + m_serial_rx3.erase(m_serial_rx3.begin()); + } + if (m_serial_rx3.empty()) { + m_serial_com3[0] &= ~0x1; + m_serial_com3[3] &= ~0x20; + m_cpu->set_input_line(m_serial_irq_num, CLEAR_LINE); + } + } if (LOG_FPGA) logerror("%s:fpga_r offset %04X = %08X & %08X\n", machine().describe_context(), offset*4, result, mem_mask); break; default: if (LOG_FPGA) logerror("%s:fpga_r offset %04X = %08X & %08X\n", machine().describe_context(), offset*4, result, mem_mask); + osd_printf_debug("%s:fpga_r offset %04X = %08X & %08X\n", machine().describe_context(), offset*4, result, mem_mask); break; } if (offset!=0x4/4) @@ -236,9 +251,12 @@ WRITE32_MEMBER( iteagle_fpga_device::fpga_w ) update_sequence(data & 0xff); if (0 && LOG_FPGA) logerror("%s:fpga_w offset %04X = %08X & %08X\n", machine().describe_context(), offset*4, data, mem_mask); - } + } else if (ACCESSING_BITS_8_15) { + // Interrupt enable? + if (LOG_FPGA) + logerror("%s:fpga_w offset %04X = %08X & %08X\n", machine().describe_context(), offset*4, data, mem_mask); + } else if (ACCESSING_BITS_24_31 && (data & 0x01000000)) { // Interrupt clear/enable - if (ACCESSING_BITS_24_31 && (data & 0x01000000)) { m_cpu->set_input_line(m_irq_num, CLEAR_LINE); // Not sure what value to use here, needed for lightgun m_timer->adjust(attotime::from_hz(59)); @@ -295,7 +313,7 @@ WRITE32_MEMBER( iteagle_fpga_device::fpga_w ) if (m_serial_str.size()==0) m_serial_str = "com1: "; m_serial_str += (data>>24)&0xff; - if (1 || ((data>>24)&0xff)==0xd) { + if (1) { if (LOG_SERIAL) logerror("%s\n", m_serial_str.c_str()); osd_printf_debug("%s\n", m_serial_str.c_str()); m_serial_str.clear(); @@ -326,7 +344,7 @@ WRITE32_MEMBER( iteagle_fpga_device::fpga_w ) if (m_serial_str.size()==0) m_serial_str = "com2: "; m_serial_str += (data>>16)&0xff; - if (1 || ((data>>16)&0xff)==0xd) { + if (1) { if (LOG_SERIAL) logerror("%s\n", m_serial_str.c_str()); osd_printf_debug("%s\n", m_serial_str.c_str()); m_serial_str.clear(); @@ -339,6 +357,15 @@ WRITE32_MEMBER( iteagle_fpga_device::fpga_w ) if (((data>>24)&0xff)==0xd) { if (LOG_SERIAL) logerror("%s\n", m_serial_str.c_str()); osd_printf_debug("%s\n", m_serial_str.c_str()); + if (m_serial_str.find("ATI5") != -1) + m_serial_rx3 += "OK\r181\r"; + else if (m_serial_str.find("ATS0?") != -1) + m_serial_rx3 += "0\r"; + else + m_serial_rx3 += "OK\r"; + m_serial_com3[0] |= 0x1; + m_serial_com3[3] = 0x20; + m_cpu->set_input_line(m_serial_irq_num, ASSERT_LINE); m_serial_str.clear(); } } @@ -348,6 +375,7 @@ WRITE32_MEMBER( iteagle_fpga_device::fpga_w ) default: if (LOG_FPGA) logerror("%s:fpga_w offset %04X = %08X & %08X\n", machine().describe_context(), offset*4, data, mem_mask); + osd_printf_debug("%s:fpga_w offset %04X = %08X & %08X\n", machine().describe_context(), offset*4, data, mem_mask); break; } } @@ -362,7 +390,7 @@ WRITE32_MEMBER( iteagle_fpga_device::fpga_w ) void iteagle_fpga_device::nvram_default() { - memset(m_rtc_regs, 0, sizeof(m_rtc_regs)); + memset(m_rtc_regs, 0x0, sizeof(m_rtc_regs)); } //------------------------------------------------- @@ -466,7 +494,8 @@ ADDRESS_MAP_END // 0x6 = OperID // 0xe = SW Version // 0xf = 0x01 for extra courses -// 0x7f = checksum +// 0x3e = 0x0002 for good nvram +// 0x3f = checksum static const UINT16 iteagle_default_eeprom[0x40] = { 0xd000,0x0022,0x0000,0x0003,0x1209,0x1111,0x2222,0x1234, @@ -652,7 +681,7 @@ void iteagle_ide_device::device_reset() { pci_device::device_reset(); memset(m_ctrl_regs, 0, sizeof(m_ctrl_regs)); - m_ctrl_regs[0x10/4] = 0x00070000; // 0x6=No SIMM, 0x2, 0x1, 0x0 = SIMM . Top 16 bits are compared to 0x3. Bit 0 might be lan chip present. + m_ctrl_regs[0x10/4] = 0x00000000; // 0x6=No SIMM, 0x2, 0x1, 0x0 = SIMM . Top 16 bits are compared to 0x3. Bit 0 might be lan chip present. memset(m_rtc_regs, 0, sizeof(m_rtc_regs)); m_rtc_regs[0xa] = 0x20; // 32.768 MHz m_rtc_regs[0xb] = 0x02; // 24-hour format @@ -667,6 +696,7 @@ READ32_MEMBER( iteagle_ide_device::ctrl_r ) case 0x0/4: if (LOG_IDE_REG) logerror("%s:fpga ctrl_r from offset %04X = %08X & %08X\n", machine().describe_context(), offset*4, result, mem_mask); + osd_printf_debug("%s:fpga ctrl_r from offset %04X = %08X & %08X\n", machine().describe_context(), offset*4, result, mem_mask); break; case 0x70/4: if (ACCESSING_BITS_8_15) { @@ -696,6 +726,7 @@ READ32_MEMBER( iteagle_ide_device::ctrl_r ) default: if (LOG_IDE_REG) logerror("%s:fpga ctrl_r from offset %04X = %08X & %08X\n", machine().describe_context(), offset*4, result, mem_mask); + osd_printf_debug("%s:fpga ctrl_r from offset %04X = %08X & %08X\n", machine().describe_context(), offset*4, result, mem_mask); break; } return result; @@ -737,7 +768,7 @@ READ32_MEMBER( iteagle_ide_device::ide_r ) if (m_irq_num!=-1 && m_irq_status==1) { m_irq_status = 0; m_cpu->set_input_line(m_irq_num, CLEAR_LINE); - if (LOG_IDE) + if (LOG_IDE_CTRL) logerror("%s:ide_r Clearing interrupt\n", machine().describe_context()); } } @@ -752,7 +783,7 @@ WRITE32_MEMBER( iteagle_ide_device::ide_w ) if (m_irq_num!=-1 && m_irq_status==1) { m_irq_status = 0; m_cpu->set_input_line(m_irq_num, CLEAR_LINE); - if (LOG_IDE) + if (LOG_IDE_CTRL) logerror("%s:ide_w Clearing interrupt\n", machine().describe_context()); } } diff --git a/src/mame/machine/iteagle_fpga.h b/src/mame/machine/iteagle_fpga.h index fe5f9a76687..66d2238c2a9 100644 --- a/src/mame/machine/iteagle_fpga.h +++ b/src/mame/machine/iteagle_fpga.h @@ -10,15 +10,17 @@ #include "machine/idectrl.h" #include "machine/eepromser.h" -#define MCFG_ITEAGLE_FPGA_ADD(_tag, _cpu_tag, _irq_num) \ +//MCFG_PCI_DEVICE_ADD(_tag, _type, _main_id, _revision, _pclass, _subsystem_id) + +#define MCFG_ITEAGLE_FPGA_ADD(_tag, _cpu_tag, _irq_num, _serial_irq_num) \ MCFG_PCI_DEVICE_ADD(_tag, ITEAGLE_FPGA, 0x55CC33AA, 0xAA, 0xAAAAAA, 0x00) \ - downcast<iteagle_fpga_device *>(device)->set_irq_info(_cpu_tag, _irq_num); + downcast<iteagle_fpga_device *>(device)->set_irq_info(_cpu_tag, _irq_num, _serial_irq_num); #define MCFG_ITEAGLE_FPGA_INIT(_version, _seq_init) \ downcast<iteagle_fpga_device *>(device)->set_init_info(_version, _seq_init); #define MCFG_ITEAGLE_EEPROM_ADD(_tag) \ - MCFG_PCI_DEVICE_ADD(_tag, ITEAGLE_EEPROM, 0x80861229, 0x00, 0x088000, 0x00) + MCFG_PCI_DEVICE_ADD(_tag, ITEAGLE_EEPROM, 0x80861229, 0x02, 0x020000, 0x00) #define MCFG_ITEAGLE_EEPROM_INIT(_sw_version, _hw_version) \ downcast<iteagle_eeprom_device *>(device)->set_info(_sw_version, _hw_version); @@ -36,8 +38,8 @@ class iteagle_fpga_device : public pci_device, public: iteagle_fpga_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); void set_init_info(int version, int seq_init) {m_version=version; m_seq_init=seq_init;} - void set_irq_info(const char *tag, const int irq_num) {m_cpu_tag = tag; m_irq_num = irq_num;} - + void set_irq_info(const char *tag, const int irq_num, const int serial_num) { + m_cpu_tag = tag; m_irq_num = irq_num; m_serial_irq_num = serial_num;} protected: virtual void device_start() override; @@ -54,6 +56,7 @@ private: const char *m_cpu_tag; cpu_device *m_cpu; int m_irq_num; + int m_serial_irq_num; UINT32 m_fpga_regs[0x20/4]; UINT32 m_rtc_regs[0x800/4]; @@ -61,6 +64,7 @@ private: UINT32 m_prev_reg; std::string m_serial_str; + std::string m_serial_rx3; UINT8 m_serial_idx; bool m_serial_data; UINT8 m_serial_com0[0x10]; diff --git a/src/mame/mame.lst b/src/mame/mame.lst index 5922ef777c0..10d623840a1 100644 --- a/src/mame/mame.lst +++ b/src/mame/mame.lst @@ -14207,6 +14207,7 @@ iskr1031 // istellar // (c) 1983 Funai / Gakken @source:iteagle.cpp +bbh2sp // bbhcotw // bbhsc // carnking // diff --git a/src/mame/video/angelkds.cpp b/src/mame/video/angelkds.cpp index 7ddc2da4892..bcb1e13931c 100644 --- a/src/mame/video/angelkds.cpp +++ b/src/mame/video/angelkds.cpp @@ -213,22 +213,6 @@ void angelkds_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprec } -/*** Palette Handling - - 4 bits of Red, 4 bits of Green, 4 bits of Blue - -*/ - -WRITE8_MEMBER(angelkds_state::angelkds_paletteram_w) -{ - int no; - - m_paletteram[offset] = data; - - no = offset & 0xff; - m_palette->set_pen_color(no, pal4bit(m_paletteram[no]), pal4bit(m_paletteram[no]>>4), pal4bit(m_paletteram[no + 0x100])); -} - /*** Video Start & Update */ diff --git a/src/osd/modules/file/winfile.cpp b/src/osd/modules/file/winfile.cpp index 894ce5b58bb..c7032a4e6b5 100644 --- a/src/osd/modules/file/winfile.cpp +++ b/src/osd/modules/file/winfile.cpp @@ -57,8 +57,9 @@ public: virtual error read(void *buffer, std::uint64_t offset, std::uint32_t length, std::uint32_t &actual) override { // attempt to set the file pointer - LONG upper(std::uint32_t(offset >> 32)); - DWORD result(SetFilePointer(m_handle, std::uint32_t(offset), &upper, FILE_BEGIN)); + LARGE_INTEGER largeOffset; + largeOffset.QuadPart = offset; + DWORD result(SetFilePointerEx(m_handle, largeOffset, NULL, FILE_BEGIN)); if (INVALID_SET_FILE_POINTER == result) { DWORD const err(GetLastError()); @@ -77,8 +78,9 @@ public: virtual error write(void const *buffer, std::uint64_t offset, std::uint32_t length, std::uint32_t &actual) override { // attempt to set the file pointer - LONG upper(std::uint32_t(offset >> 32)); - DWORD result(SetFilePointer(m_handle, std::uint32_t(offset), &upper, FILE_BEGIN)); + LARGE_INTEGER largeOffset; + largeOffset.QuadPart = offset; + DWORD result(SetFilePointerEx(m_handle, largeOffset, NULL, FILE_BEGIN)); if (INVALID_SET_FILE_POINTER == result) { DWORD const err(GetLastError()); @@ -97,8 +99,9 @@ public: virtual error truncate(std::uint64_t offset) override { // attempt to set the file pointer - LONG upper(std::uint32_t(offset >> 32)); - DWORD const result(SetFilePointer(m_handle, std::uint32_t(offset), &upper, FILE_BEGIN)); + LARGE_INTEGER largeOffset; + largeOffset.QuadPart = offset; + DWORD const result(SetFilePointerEx(m_handle, largeOffset, NULL, FILE_BEGIN)); if (INVALID_SET_FILE_POINTER == result) { DWORD const err(GetLastError()); @@ -163,7 +166,8 @@ DWORD create_path_recursive(TCHAR *path) } // if the path already exists, we're done - if (GetFileAttributes(path) != INVALID_FILE_ATTRIBUTES) + WIN32_FILE_ATTRIBUTE_DATA fileinfo; + if (GetFileAttributesEx(path, GetFileExInfoStandard, &fileinfo) != INVALID_FILE_ATTRIBUTES) return NO_ERROR; else if (!CreateDirectory(path, NULL)) return GetLastError(); @@ -376,12 +380,12 @@ osd_directory_entry *osd_stat(const std::string &path) { // need to do special logic for root directories memset(&find_data, 0, sizeof(find_data)); - find_data.dwFileAttributes = GetFileAttributes(t_path); + GetFileAttributesEx(t_path, GetFileExInfoStandard, &find_data.dwFileAttributes); } else { // attempt to find the first file - find = FindFirstFile(t_path, &find_data); + find = FindFirstFileEx(t_path, FindExInfoStandard, &find_data, FindExSearchNameMatch, NULL, 0); if (find == INVALID_HANDLE_VALUE) goto done; } diff --git a/src/osd/modules/font/font_sdl.cpp b/src/osd/modules/font/font_sdl.cpp index bfe3013032e..3600b190460 100644 --- a/src/osd/modules/font/font_sdl.cpp +++ b/src/osd/modules/font/font_sdl.cpp @@ -203,10 +203,8 @@ osd_font_sdl::TTF_Font_ptr osd_font_sdl::TTF_OpenFont_Magic(std::string const &n auto const bytes_read = file.read(buffer, sizeof(buffer)); file.close(); - if ((bytes_read >= sizeof(ttf_magic)) && !std::memcmp(buffer, ttf_magic, sizeof(ttf_magic))) - return TTF_Font_ptr(TTF_OpenFont(name.c_str(), POINT_SIZE), &TTF_CloseFont); - - if (((bytes_read >= sizeof(ttc1_magic)) && !std::memcmp(buffer, ttc1_magic, sizeof(ttc1_magic))) || + if (((bytes_read >= sizeof(ttf_magic)) && !std::memcmp(buffer, ttf_magic, sizeof(ttf_magic))) || + ((bytes_read >= sizeof(ttc1_magic)) && !std::memcmp(buffer, ttc1_magic, sizeof(ttc1_magic))) || ((bytes_read >= sizeof(ttc2_magic)) && !std::memcmp(buffer, ttc2_magic, sizeof(ttc2_magic)))) return TTF_Font_ptr(TTF_OpenFontIndex(name.c_str(), POINT_SIZE, index), &TTF_CloseFont); } diff --git a/src/osd/modules/input/input_common.h b/src/osd/modules/input/input_common.h index 23d9c958c8c..ce6a939ea74 100644 --- a/src/osd/modules/input/input_common.h +++ b/src/osd/modules/input/input_common.h @@ -13,7 +13,6 @@ #include <memory> #include <chrono> -#include <string> #include <queue> //============================================================ @@ -444,7 +443,8 @@ public: m_input_enabled(FALSE), m_mouse_enabled(FALSE), m_lightgun_enabled(FALSE), - m_input_paused(FALSE) + m_input_paused(FALSE), + m_options(nullptr) { } diff --git a/src/osd/modules/input/input_dinput.cpp b/src/osd/modules/input/input_dinput.cpp index a56f913854d..ea4be5682cf 100644 --- a/src/osd/modules/input/input_dinput.cpp +++ b/src/osd/modules/input/input_dinput.cpp @@ -14,7 +14,6 @@ // standard windows headers #define WIN32_LEAN_AND_MEAN #include <windows.h> -#include <winioctl.h> #include <tchar.h> // undef WINNT for dinput.h to prevent duplicate definition @@ -28,7 +27,6 @@ // MAME headers #include "emu.h" #include "osdepend.h" -#include "ui/ui.h" #include "strconv.h" // MAMEOS headers @@ -153,13 +151,15 @@ private: public: dinput_module(const char* type, const char* name) - : wininput_module(type, name) + : wininput_module(type, name), + m_dinput(nullptr), + m_dinput_version(0) { } int init_internal() override { - HRESULT result = S_OK; + HRESULT result; #if DIRECTINPUT_VERSION >= 0x800 m_dinput_version = DIRECTINPUT_VERSION; diff --git a/src/osd/modules/input/input_rawinput.cpp b/src/osd/modules/input/input_rawinput.cpp index 2bfdf134f34..750033ea640 100644 --- a/src/osd/modules/input/input_rawinput.cpp +++ b/src/osd/modules/input/input_rawinput.cpp @@ -14,16 +14,15 @@ // standard windows headers #define WIN32_LEAN_AND_MEAN #include <windows.h> -#include <winioctl.h> #include <tchar.h> #undef interface #include <mutex> +#include <functional> // MAME headers #include "emu.h" #include "osdepend.h" -#include "ui/ui.h" #include "strconv.h" // MAMEOS headers @@ -50,185 +49,236 @@ typedef lazy_loaded_function_p5<INT, HRAWINPUT, UINT, LPVOID, PINT, UINT> get_ra typedef lazy_loaded_function_p4<INT, HANDLE, UINT, LPVOID, PINT> get_rawinput_device_info_ptr; typedef lazy_loaded_function_p3<BOOL, PCRAWINPUTDEVICE, UINT, UINT> register_rawinput_devices_ptr; +class safe_regkey +{ +private: + HKEY m_key; + +public: + safe_regkey() + : m_key(nullptr) + { + } + + explicit safe_regkey(HKEY key) + : m_key(key) + { + } + + bool valid() const { return m_key != nullptr; } + + void close() + { + if (m_key != nullptr) + { + RegCloseKey(m_key); + m_key = nullptr; + } + } + + ~safe_regkey() + { + close(); + } + + operator HKEY() const { return m_key; } +}; + +//============================================================ +// reg_open_key +//============================================================ + +static safe_regkey reg_open_key(HKEY basekey, const std::wstring &subkey) +{ + HKEY key; + if (RegOpenKeyEx(basekey, subkey.c_str(), 0, KEY_READ, &key) == ERROR_SUCCESS) + return safe_regkey(key); + + return safe_regkey(); + +} + +//============================================================ +// reg_enum_key +//============================================================ + +static std::wstring reg_enum_key(HKEY key, int index) +{ + WCHAR keyname[MAX_PATH]; + DWORD namelen; + if (RegEnumKeyEx(key, index, keyname, &namelen, nullptr, nullptr, nullptr, nullptr) == ERROR_SUCCESS) + return std::wstring(keyname, namelen); + + return std::wstring(); +} + //============================================================ // reg_query_string //============================================================ -static TCHAR *reg_query_string(HKEY key, const TCHAR *path) +static std::wstring reg_query_string(HKEY key, const TCHAR *path) { - TCHAR *buffer; DWORD datalen; LONG result; // first query to get the length - result = RegQueryValueEx(key, path, NULL, NULL, NULL, &datalen); + result = RegQueryValueEx(key, path, nullptr, nullptr, nullptr, &datalen); if (result != ERROR_SUCCESS) - return NULL; + return std::wstring(); // allocate a buffer - buffer = global_alloc_array(TCHAR, datalen + sizeof(*buffer)); - buffer[datalen / sizeof(*buffer)] = 0; + auto buffer = std::make_unique<TCHAR[]>(datalen + sizeof(TCHAR)); + buffer[datalen / sizeof(TCHAR)] = 0; // now get the actual data - result = RegQueryValueEx(key, path, NULL, NULL, (LPBYTE)buffer, &datalen); + result = RegQueryValueEx(key, path, nullptr, nullptr, reinterpret_cast<LPBYTE>(buffer.get()), &datalen); if (result == ERROR_SUCCESS) - return buffer; + return std::wstring(buffer.get()); - // otherwise return a NULL buffer - global_free_array(buffer); - return NULL; + // otherwise return an empty string + return std::wstring(); } -//============================================================ -// rawinput_device_improve_name -//============================================================ - -static TCHAR *rawinput_device_improve_name(TCHAR *name) +static std::wstring trim_prefix(const std::wstring &devicename) { - static const TCHAR usbbasepath[] = TEXT("SYSTEM\\CurrentControlSet\\Enum\\USB"); - static const TCHAR basepath[] = TEXT("SYSTEM\\CurrentControlSet\\Enum\\"); - TCHAR *regstring = NULL; - TCHAR *parentid = NULL; - TCHAR *regpath = NULL; - const TCHAR *chsrc; - HKEY regkey = NULL; - int usbindex; - TCHAR *chdst; - LONG result; + // remove anything prior to the final semicolon + auto semicolon_index = devicename.find_last_of(';'); + if (semicolon_index != std::wstring::npos) + return devicename.substr(semicolon_index + 1); - // The RAW name received is formatted as: - // \??\type-id#hardware-id#instance-id#{DeviceClasses-id} - // XP starts with "\??\" - // Vista64 starts with "\\?\" + return devicename; +} - // ensure the name is something we can handle - if (_tcsncmp(name, TEXT("\\\\?\\"), 4) != 0 && _tcsncmp(name, TEXT("\\??\\"), 4) != 0) - return name; +static std::wstring compute_device_regpath(const std::wstring &name) +{ + static const std::wstring basepath(L"SYSTEM\\CurrentControlSet\\Enum\\"); // allocate a temporary string and concatenate the base path plus the name - regpath = global_alloc_array(TCHAR, _tcslen(basepath) + 1 + _tcslen(name)); - _tcscpy(regpath, basepath); - chdst = regpath + _tcslen(regpath); + auto regpath_buffer = std::make_unique<TCHAR[]>(basepath.length() + 1 + name.length()); + wcscpy(regpath_buffer.get(), basepath.c_str()); + WCHAR * chdst = regpath_buffer.get() + basepath.length(); // convert all # to \ in the name - for (chsrc = name + 4; *chsrc != 0; chsrc++) - *chdst++ = (*chsrc == '#') ? '\\' : *chsrc; + for (int i = 4; i < name.length(); i++) + *chdst++ = (name[i] == '#') ? '\\' : name[i]; *chdst = 0; // remove the final chunk - chdst = _tcsrchr(regpath, '\\'); - if (chdst == NULL) - goto exit; + chdst = wcsrchr(regpath_buffer.get(), '\\'); + if (chdst == nullptr) + return std::wstring(); + *chdst = 0; + return std::wstring(regpath_buffer.get()); +} + +static std::wstring improve_name_from_base_path(const std::wstring ®path, bool *hid) +{ // now try to open the registry key - result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, regpath, 0, KEY_READ, ®key); - if (result != ERROR_SUCCESS) - goto exit; + auto device_key = reg_open_key(HKEY_LOCAL_MACHINE, regpath); + if (!device_key.valid()) + return std::wstring(); // fetch the device description; if it exists, we are finished - regstring = reg_query_string(regkey, TEXT("DeviceDesc")); - if (regstring != NULL) - goto convert; - - // close this key - RegCloseKey(regkey); - regkey = NULL; + auto regstring = reg_query_string(device_key, L"DeviceDesc"); + if (!regstring.empty()) + return trim_prefix(regstring); // if the key name does not contain "HID", it's not going to be in the USB tree; give up - if (_tcsstr(regpath, TEXT("HID")) == NULL) - goto exit; + *hid = regpath.find(L"HID") != std::string::npos; + return std::wstring(); +} + +static void foreach_subkey(HKEY key, std::function<bool(HKEY)> action) +{ + for (int i = 0; ; i++) + { + std::wstring name = reg_enum_key(key, i); + if (name.empty()) + break; + + safe_regkey subkey = reg_open_key(key, name); + if (!subkey.valid()) + break; + + bool shouldcontinue = action(subkey); + if (!shouldcontinue) + break; + } +} + +static std::wstring improve_name_from_usb_path(const std::wstring ®path) +{ + static const std::wstring usbbasepath(L"SYSTEM\\CurrentControlSet\\Enum\\USB"); // extract the expected parent ID from the regpath - parentid = _tcsrchr(regpath, '\\'); - if (parentid == NULL) - goto exit; - parentid++; + size_t last_slash_index = regpath.find_last_of('\\'); + if (last_slash_index == std::wstring::npos) + return std::wstring(); + + std::wstring parentid = regpath.substr(last_slash_index + 1); // open the USB key - result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, usbbasepath, 0, KEY_READ, ®key); - if (result != ERROR_SUCCESS) - goto exit; + auto usb_key = reg_open_key(HKEY_LOCAL_MACHINE, usbbasepath); + if (!usb_key.valid()) + return std::wstring(); - // enumerate the USB key - for (usbindex = 0; result == ERROR_SUCCESS && regstring == NULL; usbindex++) - { - TCHAR keyname[MAX_PATH]; - DWORD namelen; + std::wstring regstring; - // get the next enumerated subkey and scan it - namelen = ARRAY_LENGTH(keyname) - 1; - result = RegEnumKeyEx(regkey, usbindex, keyname, &namelen, NULL, NULL, NULL, NULL); - if (result == ERROR_SUCCESS) + foreach_subkey(usb_key, [®string, &parentid](HKEY subkey) + { + foreach_subkey(subkey, [®string, &parentid](HKEY endkey) { - LONG subresult; - int subindex; - HKEY subkey; + std::wstring endparentid = reg_query_string(endkey, L"ParentIdPrefix"); + + // This key doesn't have a ParentIdPrefix + if (endparentid.empty()) + return true; - // open the subkey - subresult = RegOpenKeyEx(regkey, keyname, 0, KEY_READ, &subkey); - if (subresult != ERROR_SUCCESS) - continue; + // do we have a match? + if (parentid.find(endparentid) == 0) + regstring = reg_query_string(endkey, L"DeviceDesc"); - // enumerate the subkey - for (subindex = 0; subresult == ERROR_SUCCESS && regstring == NULL; subindex++) - { - // get the next enumerated subkey and scan it - namelen = ARRAY_LENGTH(keyname) - 1; - subresult = RegEnumKeyEx(subkey, subindex, keyname, &namelen, NULL, NULL, NULL, NULL); - if (subresult == ERROR_SUCCESS) - { - TCHAR *endparentid; - LONG endresult; - HKEY endkey; - - // open this final key - endresult = RegOpenKeyEx(subkey, keyname, 0, KEY_READ, &endkey); - if (endresult != ERROR_SUCCESS) - continue; - - // do we have a match? - endparentid = reg_query_string(endkey, TEXT("ParentIdPrefix")); - if (endparentid != NULL && _tcsncmp(parentid, endparentid, _tcslen(endparentid)) == 0) - regstring = reg_query_string(endkey, TEXT("DeviceDesc")); - - // free memory and close the key - if (endparentid != NULL) - global_free_array(endparentid); - RegCloseKey(endkey); - } - } + return regstring.empty(); + }); - // close the subkey - RegCloseKey(subkey); - } - } + return regstring.empty(); + }); - // if we didn't find anything, go to the exit - if (regstring == NULL) - goto exit; + return trim_prefix(regstring); +} -convert: - // replace the name with the nicer one - global_free_array(name); +//============================================================ +// rawinput_device_improve_name +//============================================================ - // remove anything prior to the final semicolon - chsrc = _tcsrchr(regstring, ';'); - if (chsrc != NULL) - chsrc++; - else - chsrc = regstring; - name = global_alloc_array(TCHAR, _tcslen(chsrc) + 1); - _tcscpy(name, chsrc); - -exit: - if (regstring != NULL) - global_free_array(regstring); - if (regpath != NULL) - global_free_array(regpath); - if (regkey != NULL) - RegCloseKey(regkey); +static std::wstring rawinput_device_improve_name(const std::wstring &name) +{ + // The RAW name received is formatted as: + // \??\type-id#hardware-id#instance-id#{DeviceClasses-id} + // XP starts with "\??\" + // Vista64 starts with "\\?\" + // ensure the name is something we can handle + if (name.find(L"\\\\?\\") != 0 && name.find(L"\\??\\") != 0) + return name; + + std::wstring regpath = compute_device_regpath(name); + + bool hid = false; + auto improved = improve_name_from_base_path(regpath, &hid); + if (!improved.empty()) + return improved; + + if (hid) + { + improved = improve_name_from_usb_path(regpath); + if (!improved.empty()) + return improved; + } + + // Fall back to the original name return name; } @@ -244,11 +294,12 @@ private: public: rawinput_device(running_machine& machine, const char* name, input_device_class deviceclass, input_module& module) - : event_based_device(machine, name, deviceclass, module) + : event_based_device(machine, name, deviceclass, module), + m_handle(nullptr) { } - HANDLE device_handle() { return m_handle; } + HANDLE device_handle() const { return m_handle; } void set_handle(HANDLE handle) { m_handle = handle; } }; @@ -328,7 +379,7 @@ public: // update zaxis if (rawinput.data.mouse.usButtonFlags & RI_MOUSE_WHEEL) - mouse.lZ += (INT16)rawinput.data.mouse.usButtonData * INPUT_RELATIVE_PER_PIXEL; + mouse.lZ += static_cast<INT16>(rawinput.data.mouse.usButtonData) * INPUT_RELATIVE_PER_PIXEL; // update the button states; always update the corresponding mouse buttons if (rawinput.data.mouse.usButtonFlags & RI_MOUSE_BUTTON_1_DOWN) mouse.rgbButtons[0] = 0x80; @@ -392,7 +443,7 @@ public: { // get the number of devices, allocate a device list, and fetch it int device_count = 0; - if (get_rawinput_device_list(NULL, &device_count, sizeof(RAWINPUTDEVICELIST)) != 0) + if (get_rawinput_device_list(nullptr, &device_count, sizeof(RAWINPUTDEVICELIST)) != 0) return; if (device_count == 0) @@ -452,10 +503,10 @@ protected: template<class TDevice> TDevice* create_rawinput_device(running_machine &machine, PRAWINPUTDEVICELIST rawinputdevice) { - TDevice* devinfo = nullptr; + TDevice* devinfo; INT name_length = 0; // determine the length of the device name, allocate it, and fetch it if not nameless - if (get_rawinput_device_info(rawinputdevice->hDevice, RIDI_DEVICENAME, NULL, &name_length) != 0) + if (get_rawinput_device_info(rawinputdevice->hDevice, RIDI_DEVICENAME, nullptr, &name_length) != 0) return nullptr; std::unique_ptr<TCHAR[]> tname = std::make_unique<TCHAR[]>(name_length + 1); @@ -463,15 +514,15 @@ protected: return nullptr; // if this is an RDP name, skip it - if (_tcsstr(tname.get(), TEXT("Root#RDP_")) != NULL) + if (_tcsstr(tname.get(), TEXT("Root#RDP_")) != nullptr) return nullptr; // improve the name and then allocate a device - tname = std::unique_ptr<TCHAR[]>(rawinput_device_improve_name(tname.release())); + std::wstring name = rawinput_device_improve_name(tname.get()); // convert name to utf8 auto osd_deleter = [](void *ptr) { osd_free(ptr); }; - auto utf8_name = std::unique_ptr<char, decltype(osd_deleter)>(utf8_from_tstring(tname.get()), osd_deleter); + auto utf8_name = std::unique_ptr<char, decltype(osd_deleter)>(utf8_from_wstring(name.c_str()), osd_deleter); devinfo = devicelist()->create_device<TDevice>(machine, utf8_name.get(), *this); @@ -487,12 +538,12 @@ protected: if (!input_enabled() || eventid != INPUT_EVENT_RAWINPUT) return FALSE; - HRAWINPUT rawinputdevice = *(HRAWINPUT*)eventdata; + HRAWINPUT rawinputdevice = *static_cast<HRAWINPUT*>(eventdata); BYTE small_buffer[4096]; std::unique_ptr<BYTE[]> larger_buffer; LPBYTE data = small_buffer; - BOOL result = FALSE; + BOOL result; int size; // ignore if not enabled @@ -500,7 +551,7 @@ protected: return FALSE; // determine the size of databuffer we need - if (get_rawinput_data(rawinputdevice, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER)) != 0) + if (get_rawinput_data(rawinputdevice, RID_INPUT, nullptr, &size, sizeof(RAWINPUTHEADER)) != 0) return FALSE; // if necessary, allocate a temporary buffer and fetch the data @@ -508,12 +559,12 @@ protected: { larger_buffer = std::make_unique<BYTE[]>(size); data = larger_buffer.get(); - if (data == NULL) + if (data == nullptr) return FALSE; } // fetch the data and process the appropriate message types - result = get_rawinput_data((HRAWINPUT)rawinputdevice, RID_INPUT, data, &size, sizeof(RAWINPUTHEADER)); + result = get_rawinput_data(static_cast<HRAWINPUT>(rawinputdevice), RID_INPUT, data, &size, sizeof(RAWINPUTHEADER)); if (result) { std::lock_guard<std::mutex> scope_lock(m_module_lock); @@ -523,11 +574,14 @@ protected: for (int i = 0; i < devicelist()->size(); i++) { devinfo = dynamic_cast<rawinput_device*>(devicelist()->at(i)); - RAWINPUT *input = reinterpret_cast<RAWINPUT*>(data); - if (input->header.hDevice == devinfo->device_handle()) + if (devinfo) { - devinfo->queue_events(input, 1); - result = TRUE; + RAWINPUT *input = reinterpret_cast<RAWINPUT*>(data); + if (input->header.hDevice == devinfo->device_handle()) + { + devinfo->queue_events(input, 1); + result = TRUE; + } } } } @@ -559,7 +613,7 @@ protected: // allocate and link in a new device rawinput_keyboard_device *devinfo = create_rawinput_device<rawinput_keyboard_device>(machine, device); - if (devinfo == NULL) + if (devinfo == nullptr) return; keyboard_trans_table &table = keyboard_trans_table::instance(); @@ -606,19 +660,19 @@ protected: // allocate and link in a new device rawinput_mouse_device *devinfo = create_rawinput_device<rawinput_mouse_device>(machine, device); - if (devinfo == NULL) + if (devinfo == nullptr) return; // populate the axes for (int axisnum = 0; axisnum < 3; axisnum++) { - devinfo->device()->add_item(default_axis_name[axisnum], (input_item_id)(ITEM_ID_XAXIS + axisnum), generic_axis_get_state, &devinfo->mouse.lX + axisnum); + devinfo->device()->add_item(default_axis_name[axisnum], static_cast<input_item_id>(ITEM_ID_XAXIS + axisnum), generic_axis_get_state, &devinfo->mouse.lX + axisnum); } // populate the buttons for (int butnum = 0; butnum < 5; butnum++) { - devinfo->device()->add_item(default_button_name(butnum), (input_item_id)(ITEM_ID_BUTTON1 + butnum), generic_button_get_state, &devinfo->mouse.rgbButtons[butnum]); + devinfo->device()->add_item(default_button_name(butnum), static_cast<input_item_id>(ITEM_ID_BUTTON1 + butnum), generic_button_get_state, &devinfo->mouse.rgbButtons[butnum]); } } }; diff --git a/src/osd/modules/input/input_win32.cpp b/src/osd/modules/input/input_win32.cpp index 0fb86095112..6256210ae7c 100644 --- a/src/osd/modules/input/input_win32.cpp +++ b/src/osd/modules/input/input_win32.cpp @@ -253,7 +253,8 @@ public: win32_lightgun_device(running_machine& machine, const char *name, input_module &module) : event_based_device(machine, name, DEVICE_CLASS_LIGHTGUN, module), m_lightgun_shared_axis_mode(FALSE), - m_gun_index(0) + m_gun_index(0), + mouse({0}) { m_lightgun_shared_axis_mode = downcast<windows_options &>(machine.options()).dual_lightgun(); diff --git a/src/osd/modules/input/input_windows.h b/src/osd/modules/input/input_windows.h index b79560c97a7..3c4178d5606 100644 --- a/src/osd/modules/input/input_windows.h +++ b/src/osd/modules/input/input_windows.h @@ -37,7 +37,8 @@ protected: public: wininput_module(const char * type, const char * name) - : input_module_base(type, name) + : input_module_base(type, name), + m_global_inputs_enabled(false) { } diff --git a/src/osd/modules/lib/osdobj_common.cpp b/src/osd/modules/lib/osdobj_common.cpp index 7d33cb1218c..100b8bba0c8 100644 --- a/src/osd/modules/lib/osdobj_common.cpp +++ b/src/osd/modules/lib/osdobj_common.cpp @@ -158,8 +158,10 @@ osd_common_t::osd_common_t(osd_options &options) : osd_output(), m_machine(nullptr), m_options(options), m_print_verbose(false), + m_font_module(nullptr), m_sound(nullptr), m_debugger(nullptr), + m_midi(nullptr), m_keyboard_input(nullptr), m_mouse_input(nullptr), m_lightgun_input(nullptr), diff --git a/src/osd/modules/render/d3d/d3dcomm.h b/src/osd/modules/render/d3d/d3dcomm.h index 4894cd7f491..3419619df57 100644 --- a/src/osd/modules/render/d3d/d3dcomm.h +++ b/src/osd/modules/render/d3d/d3dcomm.h @@ -244,7 +244,7 @@ public: cache_target() { } ~cache_target(); - bool init(renderer_d3d9 *d3d, d3d_base *d3dintf, int width, int height, int prescale_x, int prescale_y); + bool init(renderer_d3d9 *d3d, d3d_base *d3dintf, int source_width, int source_height, int target_width, int target_height); surface *last_target; texture *last_texture; @@ -269,31 +269,34 @@ public: d3d_render_target() { } ~d3d_render_target(); - bool init(renderer_d3d9 *d3d, d3d_base *d3dintf, int width, int height, int prescale_x, int prescale_y); + bool init(renderer_d3d9 *d3d, d3d_base *d3dintf, int source_width, int source_height, int target_width, int target_height); int next_index(int index) { return ++index > 1 ? 0 : index; } + // real target dimension int target_width; int target_height; - int prescale_x; - int prescale_y; - + // only used to identify/find the render target int width; int height; int screen_index; int page_index; - surface *prescale_target[2]; - texture *prescale_texture[2]; - surface *native_target[2]; - texture *native_texture[2]; + surface *target_surface[2]; + texture *target_texture[2]; + surface *source_surface[2]; + texture *source_texture[2]; d3d_render_target *next; d3d_render_target *prev; - surface *bloom_target[11]; + surface *bloom_surface[11]; texture *bloom_texture[11]; + + float bloom_dims[11][2]; + + int bloom_count; }; #endif diff --git a/src/osd/modules/render/d3d/d3dhlsl.cpp b/src/osd/modules/render/d3d/d3dhlsl.cpp index 5fcc8209500..3706b68042d 100644 --- a/src/osd/modules/render/d3d/d3dhlsl.cpp +++ b/src/osd/modules/render/d3d/d3dhlsl.cpp @@ -60,7 +60,7 @@ static direct3dx9_loadeffect_ptr g_load_effect = nullptr; //============================================================ shaders::shaders() : - d3dintf(nullptr), machine(nullptr), d3d(nullptr), num_screens(0), curr_screen(0), curr_frame(0), write_ini(false), read_ini(false), hlsl_prescale_x(0), hlsl_prescale_y(0), bloom_count(0), + d3dintf(nullptr), machine(nullptr), d3d(nullptr), num_screens(0), curr_screen(0), curr_frame(0), vecbuf_type(), vecbuf_index(0), vecbuf_count(0), avi_output_file(nullptr), avi_frame(0), avi_copy_surface(nullptr), avi_copy_texture(nullptr), avi_final_target(nullptr), avi_final_texture(nullptr), black_surface(nullptr), black_texture(nullptr), render_snap(false), snap_rendered(false), snap_copy_target(nullptr), snap_copy_texture(nullptr), snap_target(nullptr), snap_texture(nullptr), snap_width(0), snap_height(0), lines_pending(false), backbuffer(nullptr), curr_effect(nullptr), default_effect(nullptr), prescale_effect(nullptr), post_effect(nullptr), distortion_effect(nullptr), @@ -69,9 +69,6 @@ shaders::shaders() : { master_enable = false; vector_enable = true; - hlsl_prescale_x = 1; - hlsl_prescale_x = 1; - preset = -1; shadow_texture = nullptr; options = nullptr; paused = true; @@ -410,8 +407,6 @@ void shaders::toggle() { // free shader resources before renderer resources delete_resources(false); - - g_slider_list = nullptr; } master_enable = !master_enable; @@ -436,10 +431,6 @@ void shaders::toggle() { master_enable = false; } - else - { - g_slider_list = init_slider_list(); - } } } } @@ -556,9 +547,9 @@ void shaders::remove_render_target(texture_info *texture) remove_render_target(find_render_target(texture)); } -void shaders::remove_render_target(int width, int height, UINT32 screen_index, UINT32 page_index) +void shaders::remove_render_target(int source_width, int source_height, UINT32 screen_index, UINT32 page_index) { - d3d_render_target *target = find_render_target(width, height, screen_index, page_index); + d3d_render_target *target = find_render_target(source_width, source_height, screen_index, page_index); if (target != nullptr) { remove_render_target(target); @@ -662,14 +653,17 @@ void shaders::init(d3d_base *d3dintf, running_machine *machine, renderer_d3d9 *r // check if no driver loaded (not all settings might be loaded yet) if (&machine->system() == &GAME_NAME(___empty)) { + options->params_init = false; + last_options.params_init = false; + return; } + enumerate_screens(); + windows_options &winoptions = downcast<windows_options &>(machine->options()); master_enable = winoptions.d3d_hlsl_enable(); - hlsl_prescale_x = winoptions.d3d_hlsl_prescale_x(); - hlsl_prescale_y = winoptions.d3d_hlsl_prescale_y(); snap_width = winoptions.d3d_snap_width(); snap_height = winoptions.d3d_snap_height(); @@ -697,6 +691,7 @@ void shaders::init(d3d_base *d3dintf, running_machine *machine, renderer_d3d9 *r options->scanline_alpha = winoptions.screen_scanline_amount(); options->scanline_scale = winoptions.screen_scanline_scale(); options->scanline_height = winoptions.screen_scanline_height(); + options->scanline_variation = winoptions.screen_scanline_variation(); options->scanline_bright_scale = winoptions.screen_scanline_bright_scale(); options->scanline_bright_offset = winoptions.screen_scanline_bright_offset(); options->scanline_jitter = winoptions.screen_scanline_jitter(); @@ -749,8 +744,6 @@ void shaders::init(d3d_base *d3dintf, running_machine *machine, renderer_d3d9 *r } options->params_dirty = true; - - g_slider_list = init_slider_list(); } @@ -957,6 +950,7 @@ int shaders::create_resources(bool reset) effects[i]->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS); effects[i]->add_uniform("QuadDims", uniform::UT_VEC2, uniform::CU_QUAD_DIMS); effects[i]->add_uniform("SwapXY", uniform::UT_BOOL, uniform::CU_SWAP_XY); + effects[i]->add_uniform("VectorScreen", uniform::UT_BOOL, uniform::CU_VECTOR_SCREEN); } ntsc_effect->add_uniform("CCValue", uniform::UT_FLOAT, uniform::CU_NTSC_CCFREQ); @@ -986,26 +980,19 @@ int shaders::create_resources(bool reset) phosphor_effect->add_uniform("Phosphor", uniform::UT_VEC3, uniform::CU_PHOSPHOR_LIFE); - post_effect->add_uniform("VignettingAmount", uniform::UT_FLOAT, uniform::CU_POST_VIGNETTING); // backward compatibility - post_effect->add_uniform("CurvatureAmount", uniform::UT_FLOAT, uniform::CU_POST_CURVATURE); // backward compatibility - post_effect->add_uniform("RoundCornerAmount", uniform::UT_FLOAT, uniform::CU_POST_ROUND_CORNER); // backward compatibility - post_effect->add_uniform("SmoothBorderAmount", uniform::UT_FLOAT, uniform::CU_POST_SMOOTH_BORDER); // backward compatibility - post_effect->add_uniform("ReflectionAmount", uniform::UT_FLOAT, uniform::CU_POST_REFLECTION); // backward compatibility - post_effect->add_uniform("ShadowAlpha", uniform::UT_FLOAT, uniform::CU_POST_SHADOW_ALPHA); post_effect->add_uniform("ShadowCount", uniform::UT_VEC2, uniform::CU_POST_SHADOW_COUNT); post_effect->add_uniform("ShadowUV", uniform::UT_VEC2, uniform::CU_POST_SHADOW_UV); post_effect->add_uniform("ShadowUVOffset", uniform::UT_VEC2, uniform::CU_POST_SHADOW_UV_OFFSET); post_effect->add_uniform("ShadowDims", uniform::UT_VEC2, uniform::CU_POST_SHADOW_DIMS); - post_effect->add_uniform("ScanlineAlpha", uniform::UT_FLOAT, uniform::CU_POST_SCANLINE_ALPHA); post_effect->add_uniform("ScanlineScale", uniform::UT_FLOAT, uniform::CU_POST_SCANLINE_SCALE); post_effect->add_uniform("ScanlineHeight", uniform::UT_FLOAT, uniform::CU_POST_SCANLINE_HEIGHT); + post_effect->add_uniform("ScanlineVariation", uniform::UT_FLOAT, uniform::CU_POST_SCANLINE_VARIATION); post_effect->add_uniform("ScanlineBrightScale", uniform::UT_FLOAT, uniform::CU_POST_SCANLINE_BRIGHT_SCALE); post_effect->add_uniform("ScanlineBrightOffset", uniform::UT_FLOAT, uniform::CU_POST_SCANLINE_BRIGHT_OFFSET); post_effect->add_uniform("Power", uniform::UT_VEC3, uniform::CU_POST_POWER); post_effect->add_uniform("Floor", uniform::UT_VEC3, uniform::CU_POST_FLOOR); - post_effect->add_uniform("RotationType", uniform::UT_INT, uniform::CU_ROTATION_TYPE); distortion_effect->add_uniform("VignettingAmount", uniform::UT_FLOAT, uniform::CU_POST_VIGNETTING); @@ -1013,11 +1000,12 @@ int shaders::create_resources(bool reset) distortion_effect->add_uniform("RoundCornerAmount", uniform::UT_FLOAT, uniform::CU_POST_ROUND_CORNER); distortion_effect->add_uniform("SmoothBorderAmount", uniform::UT_FLOAT, uniform::CU_POST_SMOOTH_BORDER); distortion_effect->add_uniform("ReflectionAmount", uniform::UT_FLOAT, uniform::CU_POST_REFLECTION); - distortion_effect->add_uniform("RotationType", uniform::UT_INT, uniform::CU_ROTATION_TYPE); initialized = true; + init_slider_list(); + return 0; } @@ -1035,7 +1023,7 @@ void shaders::begin_draw() curr_effect = default_effect; - default_effect->set_technique("DefaultTechnique"); + default_effect->set_technique("ScreenTechnique"); post_effect->set_technique("DefaultTechnique"); distortion_effect->set_technique("DefaultTechnique"); prescale_effect->set_technique("DefaultTechnique"); @@ -1158,9 +1146,9 @@ void shaders::init_effect_info(poly_info *poly) // shaders::find_render_target //============================================================ -d3d_render_target* shaders::find_render_target(texture_info *info) +d3d_render_target* shaders::find_render_target(texture_info *texture) { - UINT32 screen_index_data = (UINT32)info->get_texinfo().osddata; + UINT32 screen_index_data = (UINT32)texture->get_texinfo().osddata; UINT32 screen_index = screen_index_data >> 1; UINT32 page_index = screen_index_data & 1; @@ -1168,8 +1156,8 @@ d3d_render_target* shaders::find_render_target(texture_info *info) while (curr != nullptr && ( curr->screen_index != screen_index || curr->page_index != page_index || - curr->width != info->get_texinfo().width || - curr->height != info->get_texinfo().height)) + curr->width != texture->get_width() || + curr->height != texture->get_height())) { curr = curr->next; } @@ -1182,12 +1170,12 @@ d3d_render_target* shaders::find_render_target(texture_info *info) // shaders::find_render_target //============================================================ -d3d_render_target* shaders::find_render_target(int width, int height, UINT32 screen_index, UINT32 page_index) +d3d_render_target* shaders::find_render_target(int source_width, int source_height, UINT32 screen_index, UINT32 page_index) { d3d_render_target *curr = targethead; while (curr != nullptr && ( - curr->width != width || - curr->height != height || + curr->width != source_width || + curr->height != source_height || curr->screen_index != screen_index || curr->page_index != page_index)) { @@ -1236,9 +1224,9 @@ int shaders::ntsc_pass(d3d_render_target *rt, int source_index, poly_info *poly, curr_effect->set_float("SignalOffset", signal_offset); next_index = rt->next_index(next_index); - blit(rt->native_target[next_index], true, D3DPT_TRIANGLELIST, 0, 2); + blit(rt->source_surface[next_index], true, D3DPT_TRIANGLELIST, 0, 2); - color_effect->set_texture("Diffuse", rt->native_texture[next_index]); + color_effect->set_texture("Diffuse", rt->source_texture[next_index]); return next_index; } @@ -1293,7 +1281,7 @@ int shaders::color_convolution_pass(d3d_render_target *rt, int source_index, pol // initial "Diffuse" texture is set in shaders::set_texture() or the result of shaders::ntsc_pass() next_index = rt->next_index(next_index); - blit(rt->native_target[next_index], true, D3DPT_TRIANGLELIST, 0, 2); + blit(rt->source_surface[next_index], true, D3DPT_TRIANGLELIST, 0, 2); return next_index; } @@ -1304,10 +1292,10 @@ int shaders::prescale_pass(d3d_render_target *rt, int source_index, poly_info *p curr_effect = prescale_effect; curr_effect->update_uniforms(); - curr_effect->set_texture("Diffuse", rt->native_texture[next_index]); + curr_effect->set_texture("Diffuse", rt->source_texture[next_index]); next_index = rt->next_index(next_index); - blit(rt->prescale_target[next_index], true, D3DPT_TRIANGLELIST, 0, 2); + blit(rt->target_surface[next_index], true, D3DPT_TRIANGLELIST, 0, 2); return next_index; } @@ -1327,10 +1315,10 @@ int shaders::deconverge_pass(d3d_render_target *rt, int source_index, poly_info curr_effect = deconverge_effect; curr_effect->update_uniforms(); - curr_effect->set_texture("Diffuse", rt->prescale_texture[next_index]); + curr_effect->set_texture("Diffuse", rt->target_texture[next_index]); next_index = rt->next_index(next_index); - blit(rt->prescale_target[next_index], true, D3DPT_TRIANGLELIST, 0, 2); + blit(rt->target_surface[next_index], true, D3DPT_TRIANGLELIST, 0, 2); return next_index; } @@ -1347,10 +1335,10 @@ int shaders::defocus_pass(d3d_render_target *rt, int source_index, poly_info *po curr_effect = focus_effect; curr_effect->update_uniforms(); - curr_effect->set_texture("Diffuse", rt->prescale_texture[next_index]); + curr_effect->set_texture("Diffuse", rt->target_texture[next_index]); next_index = rt->next_index(next_index); - blit(rt->prescale_target[next_index], true, D3DPT_TRIANGLELIST, 0, 2); + blit(rt->target_surface[next_index], true, D3DPT_TRIANGLELIST, 0, 2); return next_index; } @@ -1367,17 +1355,17 @@ int shaders::phosphor_pass(d3d_render_target *rt, cache_target *ct, int source_i curr_effect = phosphor_effect; curr_effect->update_uniforms(); - curr_effect->set_texture("Diffuse", rt->prescale_texture[next_index]); + curr_effect->set_texture("Diffuse", rt->target_texture[next_index]); curr_effect->set_texture("LastPass", ct->last_texture); curr_effect->set_bool("Passthrough", false); next_index = rt->next_index(next_index); - blit(rt->prescale_target[next_index], true, D3DPT_TRIANGLELIST, 0, 2); + blit(rt->target_surface[next_index], true, D3DPT_TRIANGLELIST, 0, 2); // Pass along our phosphor'd screen curr_effect->update_uniforms(); - curr_effect->set_texture("Diffuse", rt->prescale_texture[next_index]); - curr_effect->set_texture("LastPass", rt->prescale_texture[next_index]); + curr_effect->set_texture("Diffuse", rt->target_texture[next_index]); + curr_effect->set_texture("LastPass", rt->target_texture[next_index]); curr_effect->set_bool("Passthrough", true); // Avoid changing targets due to page flipping @@ -1390,9 +1378,6 @@ int shaders::post_pass(d3d_render_target *rt, int source_index, poly_info *poly, { int next_index = source_index; - bool prepare_vector = - machine->first_screen()->screen_type() == SCREEN_TYPE_VECTOR; - screen_device_iterator screen_iterator(machine->root_device()); screen_device *screen = screen_iterator.first(); for (int i = 0; i < curr_screen; i++) @@ -1409,15 +1394,20 @@ int shaders::post_pass(d3d_render_target *rt, int source_index, poly_info *poly, float screen_scale[2] = { xscale, yscale }; float screen_offset[2] = { xoffset, yoffset }; - rgb_t back_color_rgb = !machine->first_screen()->has_palette() ? rgb_t(0, 0, 0) : machine->first_screen()->palette().palette()->entry_color(0); + rgb_t back_color_rgb = !machine->first_screen()->has_palette() + ? rgb_t(0, 0, 0) + : machine->first_screen()->palette().palette()->entry_color(0); back_color_rgb = apply_color_convolution(back_color_rgb); - float back_color[3] = { static_cast<float>(back_color_rgb.r()) / 255.0f, static_cast<float>(back_color_rgb.g()) / 255.0f, static_cast<float>(back_color_rgb.b()) / 255.0f }; + float back_color[3] = { + static_cast<float>(back_color_rgb.r()) / 255.0f, + static_cast<float>(back_color_rgb.g()) / 255.0f, + static_cast<float>(back_color_rgb.b()) / 255.0f }; curr_effect = post_effect; curr_effect->update_uniforms(); curr_effect->set_texture("ShadowTexture", shadow_texture == nullptr ? nullptr : shadow_texture->get_finaltex()); curr_effect->set_int("ShadowTileMode", options->shadow_mask_tile_mode); - curr_effect->set_texture("DiffuseTexture", rt->prescale_texture[next_index]); + curr_effect->set_texture("DiffuseTexture", rt->target_texture[next_index]); curr_effect->set_vector("BackColor", 3, back_color); curr_effect->set_vector("ScreenScale", 2, screen_scale); curr_effect->set_vector("ScreenOffset", 2, screen_offset); @@ -1425,10 +1415,9 @@ int shaders::post_pass(d3d_render_target *rt, int source_index, poly_info *poly, curr_effect->set_float("TimeMilliseconds", (float)machine->time().as_double() * 1000.0f); curr_effect->set_float("HumBarAlpha", options->hum_bar_alpha); curr_effect->set_bool("PrepareBloom", prepare_bloom); - curr_effect->set_bool("PrepareVector", prepare_vector); next_index = rt->next_index(next_index); - blit(prepare_bloom ? rt->native_target[next_index] : rt->prescale_target[next_index], true, poly->get_type(), vertnum, poly->get_count()); + blit(prepare_bloom ? rt->source_surface[next_index] : rt->target_surface[next_index], true, D3DPT_TRIANGLELIST, 0, 2); return next_index; } @@ -1443,38 +1432,21 @@ int shaders::downsample_pass(d3d_render_target *rt, int source_index, poly_info return next_index; } - bool prepare_vector = - machine->first_screen()->screen_type() == SCREEN_TYPE_VECTOR; - curr_effect = downsample_effect; curr_effect->update_uniforms(); - curr_effect->set_bool("PrepareVector", prepare_vector); - int bloom_index = 0; - float bloom_width = prepare_vector ? rt->target_width : rt->target_width / hlsl_prescale_x; - float bloom_height = prepare_vector ? rt->target_height : rt->target_height / hlsl_prescale_y; - float bloom_size = (bloom_width < bloom_height) ? bloom_width : bloom_height; - for (; bloom_size >= 2.0f && bloom_index < 11; bloom_size *= 0.5f) + for (int bloom_index = 0; bloom_index < rt->bloom_count; bloom_index++) { - bloom_dims[bloom_index][0] = (float)(int)bloom_width; - bloom_dims[bloom_index][1] = (float)(int)bloom_height; - - curr_effect->set_vector("TargetDims", 2, bloom_dims[bloom_index]); + curr_effect->set_vector("TargetDims", 2, rt->bloom_dims[bloom_index]); + curr_effect->set_int("BloomLevel", bloom_index + 1); curr_effect->set_texture("DiffuseTexture", bloom_index == 0 - ? rt->native_texture[next_index] + ? rt->source_texture[next_index] : rt->bloom_texture[bloom_index - 1]); - blit(rt->bloom_target[bloom_index], true, poly->get_type(), vertnum, poly->get_count()); - - bloom_width *= 0.5f; - bloom_height *= 0.5f; - - bloom_index++; + blit(rt->bloom_surface[bloom_index], true, D3DPT_TRIANGLELIST, 0, 2); } - bloom_count = bloom_index; - return next_index; } @@ -1519,33 +1491,33 @@ int shaders::bloom_pass(d3d_render_target *rt, int source_index, poly_info *poly curr_effect->set_vector("Level78Weight", 2, weight78); curr_effect->set_vector("Level9AWeight", 2, weight9A); - curr_effect->set_vector("Level0Size", 2, bloom_dims[0]); - curr_effect->set_vector("Level12Size", 4, bloom_dims[1]); - curr_effect->set_vector("Level34Size", 4, bloom_dims[3]); - curr_effect->set_vector("Level56Size", 4, bloom_dims[5]); - curr_effect->set_vector("Level78Size", 4, bloom_dims[7]); - curr_effect->set_vector("Level9ASize", 4, bloom_dims[9]); + curr_effect->set_vector("Level0Size", 2, rt->bloom_dims[0]); + curr_effect->set_vector("Level12Size", 4, rt->bloom_dims[1]); + curr_effect->set_vector("Level34Size", 4, rt->bloom_dims[3]); + curr_effect->set_vector("Level56Size", 4, rt->bloom_dims[5]); + curr_effect->set_vector("Level78Size", 4, rt->bloom_dims[7]); + curr_effect->set_vector("Level9ASize", 4, rt->bloom_dims[9]); curr_effect->set_int("BloomBlendMode", options->bloom_blend_mode); curr_effect->set_float("BloomScale", options->bloom_scale); curr_effect->set_vector("BloomOverdrive", 3, options->bloom_overdrive); - curr_effect->set_texture("DiffuseA", rt->prescale_texture[next_index]); + curr_effect->set_texture("DiffuseA", rt->target_texture[next_index]); char name[9] = "Diffuse*"; - for (int index = 1; index < bloom_count; index++) + for (int index = 1; index < rt->bloom_count; index++) { name[7] = 'A' + index; curr_effect->set_texture(name, rt->bloom_texture[index - 1]); } - for (int index = bloom_count; index < 11; index++) + for (int index = rt->bloom_count; index < 11; index++) { name[7] = 'A' + index; curr_effect->set_texture(name, black_texture); } next_index = rt->next_index(next_index); - blit(rt->prescale_target[next_index], true, poly->get_type(), vertnum, poly->get_count()); + blit(rt->target_surface[next_index], true, D3DPT_TRIANGLELIST, 0, 2); return next_index; } @@ -1564,32 +1536,12 @@ int shaders::distortion_pass(d3d_render_target *rt, int source_index, poly_info return next_index; } - int screen_count = d3d->window().target()->current_view()->screens().count(); - - // only one screen is supported - if (screen_count > 1) - { - return next_index; - } - - render_bounds bounds = d3d->window().target()->current_view()->bounds(); - render_bounds screen_bounds = d3d->window().target()->current_view()->screen_bounds(); - - // artworks are not supported - if (bounds.x0 != screen_bounds.x0 || - bounds.y0 != screen_bounds.y0 || - bounds.x1 != screen_bounds.x1 || - bounds.y1 != screen_bounds.y1) - { - return next_index; - } - curr_effect = distortion_effect; curr_effect->update_uniforms(); - curr_effect->set_texture("DiffuseTexture", rt->prescale_texture[next_index]); + curr_effect->set_texture("DiffuseTexture", rt->target_texture[next_index]); next_index = rt->next_index(next_index); - blit(rt->prescale_target[next_index], true, poly->get_type(), vertnum, poly->get_count()); + blit(rt->target_surface[next_index], true, D3DPT_TRIANGLELIST, 0, 2); return next_index; } @@ -1606,7 +1558,7 @@ int shaders::vector_pass(d3d_render_target *rt, int source_index, poly_info *pol curr_effect->set_vector("TimeParams", 2, time_params); curr_effect->set_vector("LengthParams", 3, length_params); - blit(rt->prescale_target[next_index], true, poly->get_type(), vertnum, poly->get_count()); + blit(rt->target_surface[next_index], true, poly->get_type(), vertnum, poly->get_count()); return next_index; } @@ -1617,13 +1569,12 @@ int shaders::vector_buffer_pass(d3d_render_target *rt, int source_index, poly_in curr_effect = default_effect; curr_effect->update_uniforms(); + curr_effect->set_technique("VectorBufferTechnique"); - curr_effect->set_texture("Diffuse", rt->prescale_texture[next_index]); - curr_effect->set_bool("PostPass", true); - curr_effect->set_float("Brighten", 1.0f); + curr_effect->set_texture("Diffuse", rt->target_texture[next_index]); next_index = rt->next_index(next_index); - blit(rt->prescale_target[next_index], true, poly->get_type(), vertnum, poly->get_count()); + blit(rt->target_surface[next_index], true, D3DPT_TRIANGLELIST, 0, 2); return next_index; } @@ -1632,17 +1583,13 @@ int shaders::screen_pass(d3d_render_target *rt, int source_index, poly_info *pol { int next_index = source_index; - bool prepare_vector = - machine->first_screen()->screen_type() == SCREEN_TYPE_VECTOR; - curr_effect = default_effect; curr_effect->update_uniforms(); + curr_effect->set_technique("ScreenTechnique"); - curr_effect->set_texture("Diffuse", rt->prescale_texture[next_index]); - curr_effect->set_bool("PostPass", true); - curr_effect->set_float("Brighten", prepare_vector ? 1.0f : 0.0f); + curr_effect->set_texture("Diffuse", rt->target_texture[next_index]); - // we do not clear the backbuffe here because multiple screens might rendered into + // we do not clear the backbuffe here because multiple screens might be rendered into blit(backbuffer, false, poly->get_type(), vertnum, poly->get_count()); if (avi_output_file != nullptr) @@ -1660,12 +1607,11 @@ int shaders::screen_pass(d3d_render_target *rt, int source_index, poly_info *pol return next_index; } -void shaders::menu_pass(poly_info *poly, int vertnum) +void shaders::ui_pass(poly_info *poly, int vertnum) { curr_effect = default_effect; curr_effect->update_uniforms(); - curr_effect->set_bool("PostPass", false); - curr_effect->set_float("Brighten", 0.0f); + curr_effect->set_technique("UiTechnique"); blit(nullptr, false, poly->get_type(), vertnum, poly->get_count()); } @@ -1694,10 +1640,11 @@ void shaders::render_quad(poly_info *poly, int vertnum) d3d_render_target *rt = curr_render_target; if (rt == nullptr) { + osd_printf_verbose("Direct3D: No raster render target\n"); return; } - cache_target *ct = find_cache_target(rt->screen_index, curr_texture->get_texinfo().width, curr_texture->get_texinfo().height); + cache_target *ct = find_cache_target(rt->screen_index, curr_texture->get_width(), curr_texture->get_height()); int next_index = 0; @@ -1729,22 +1676,21 @@ void shaders::render_quad(poly_info *poly, int vertnum) curr_texture->increment_frame_count(); curr_texture->mask_frame_count(options->yiq_phase_count); - options->params_dirty = false; - curr_screen++; } else if (PRIMFLAG_GET_VECTOR(poly->get_flags()) && vector_enable) { + lines_pending = true; + curr_render_target = find_render_target(d3d->get_width(), d3d->get_height(), 0, 0); d3d_render_target *rt = curr_render_target; if (rt == nullptr) { + osd_printf_verbose("Direct3D: No vector render target\n"); return; } - lines_pending = true; - int next_index = 0; next_index = vector_pass(rt, next_index, poly, vertnum); @@ -1757,11 +1703,14 @@ void shaders::render_quad(poly_info *poly, int vertnum) } else if (PRIMFLAG_GET_VECTORBUF(poly->get_flags()) && vector_enable) { + curr_screen = curr_screen < num_screens ? curr_screen : 0; + curr_render_target = find_render_target(d3d->get_width(), d3d->get_height(), 0, 0); d3d_render_target *rt = curr_render_target; if (rt == nullptr) { + osd_printf_verbose("Direct3D: No vector buffer render target\n"); return; } @@ -1788,7 +1737,9 @@ void shaders::render_quad(poly_info *poly, int vertnum) next_index = distortion_pass(rt, next_index, poly, vertnum); // render on screen + d3d->set_wrap(D3DTADDRESS_MIRROR); next_index = screen_pass(rt, next_index, poly, vertnum); + d3d->set_wrap(PRIMFLAG_GET_TEXWRAP(curr_texture->get_flags()) ? D3DTADDRESS_WRAP : D3DTADDRESS_CLAMP); HRESULT result = (*d3dintf->device.set_render_target)(d3d->get_device(), 0, backbuffer); if (result != D3D_OK) @@ -1797,12 +1748,16 @@ void shaders::render_quad(poly_info *poly, int vertnum) } lines_pending = false; + + curr_screen++; } else { - menu_pass(poly, vertnum); + ui_pass(poly, vertnum); } + options->params_dirty = false; + curr_render_target = nullptr; curr_texture = nullptr; curr_poly = nullptr; @@ -1825,39 +1780,18 @@ void shaders::end_draw() //============================================================ -// shaders::register_prescaled_texture -//============================================================ - -bool shaders::register_prescaled_texture(texture_info *texture) -{ - return register_texture(texture); -} - - -//============================================================ // shaders::add_cache_target - register a cache target //============================================================ -bool shaders::add_cache_target(renderer_d3d9* d3d, texture_info* info, int width, int height, int xprescale, int yprescale, int screen_index) +bool shaders::add_cache_target(renderer_d3d9* d3d, texture_info* texture, int source_width, int source_height, int target_width, int target_height, int screen_index) { cache_target* target = (cache_target*)global_alloc_clear<cache_target>(); - if (!target->init(d3d, d3dintf, width, height, xprescale, yprescale)) + if (!target->init(d3d, d3dintf, source_width, source_height, target_width, target_height)) { global_free(target); return false; } - if (info != nullptr) - { - target->width = info->get_texinfo().width; - target->height = info->get_texinfo().height; - } - else - { - target->width = d3d->get_width(); - target->height = d3d->get_height(); - } - target->next = cachehead; target->prev = nullptr; @@ -1872,19 +1806,65 @@ bool shaders::add_cache_target(renderer_d3d9* d3d, texture_info* info, int width return true; } -d3d_render_target* shaders::get_vector_target() +//============================================================ +// shaders::get_texture_target(render_primitive::prim, texture_info::texture) +//============================================================ +d3d_render_target* shaders::get_texture_target(render_primitive *prim, texture_info *texture) +{ + if (!vector_enable) + { + return nullptr; + } + + bool swap_xy = d3d->swap_xy(); + int target_width = swap_xy + ? static_cast<int>(prim->get_quad_height() + 0.5f) + : static_cast<int>(prim->get_quad_width() + 0.5f); + int target_height = swap_xy + ? static_cast<int>(prim->get_quad_width() + 0.5f) + : static_cast<int>(prim->get_quad_height() + 0.5f); + + // find render target and check if the size of the target quad has changed + d3d_render_target *target = find_render_target(texture); + if (target != nullptr && target->target_width == target_width && target->target_height == target_height) + { + return target; + } + + osd_printf_verbose("get_texture_target() - invalid size\n"); + + return nullptr; +} + +d3d_render_target* shaders::get_vector_target(render_primitive *prim) { if (!vector_enable) { return nullptr; } - return find_render_target(d3d->get_width(), d3d->get_height(), 0, 0); + int target_width = static_cast<int>(prim->get_quad_width() + 0.5f); + int target_height = static_cast<int>(prim->get_quad_height() + 0.5f); + + // find render target and check of the size of the target quad has changed + d3d_render_target *target = find_render_target(d3d->get_width(), d3d->get_height(), 0, 0); + if (target != nullptr && target->target_width == target_width && target->target_height == target_height) + { + return target; + } + + osd_printf_verbose("get_vector_target() - invalid size\n"); + + return nullptr; } void shaders::create_vector_target(render_primitive *prim) { - if (!add_render_target(d3d, nullptr, d3d->get_width(), d3d->get_height(), 1, 1)) + int target_width = static_cast<int>(prim->get_quad_width() + 0.5f); + int target_height = static_cast<int>(prim->get_quad_height() + 0.5f); + + osd_printf_verbose("create_vector_target() - %f, %f; %d, %d\n", prim->get_quad_width(), prim->get_quad_height(), (int)(prim->get_quad_width() + 0.5f), (int)(prim->get_quad_height() + 0.5f)); + if (!add_render_target(d3d, nullptr, d3d->get_width(), d3d->get_height(), target_width, target_height)) { vector_enable = false; } @@ -1895,25 +1875,25 @@ void shaders::create_vector_target(render_primitive *prim) // shaders::add_render_target - register a render target //============================================================ -bool shaders::add_render_target(renderer_d3d9* d3d, texture_info* info, int width, int height, int xprescale, int yprescale) +bool shaders::add_render_target(renderer_d3d9* d3d, texture_info* texture, int source_width, int source_height, int target_width, int target_height) { UINT32 screen_index = 0; UINT32 page_index = 0; - if (info != nullptr) + if (texture != nullptr) { - d3d_render_target *existing_target = find_render_target(info); + d3d_render_target *existing_target = find_render_target(texture); if (existing_target != nullptr) { remove_render_target(existing_target); } - UINT32 screen_index_data = (UINT32)info->get_texinfo().osddata; + UINT32 screen_index_data = (UINT32)texture->get_texinfo().osddata; screen_index = screen_index_data >> 1; page_index = screen_index_data & 1; } else { - d3d_render_target *existing_target = find_render_target(d3d->get_width(), d3d->get_height(), 0, 0); + d3d_render_target *existing_target = find_render_target(source_width, source_height, 0, 0); if (existing_target != nullptr) { remove_render_target(existing_target); @@ -1922,37 +1902,26 @@ bool shaders::add_render_target(renderer_d3d9* d3d, texture_info* info, int widt d3d_render_target* target = (d3d_render_target*)global_alloc_clear<d3d_render_target>(); - if (!target->init(d3d, d3dintf, width, height, xprescale, yprescale)) + if (!target->init(d3d, d3dintf, source_width, source_height, target_width, target_height)) { global_free(target); return false; } - if (info != nullptr) - { - target->width = info->get_texinfo().width; - target->height = info->get_texinfo().height; - } - else - { - target->width = d3d->get_width(); - target->height = d3d->get_height(); - } + target->screen_index = screen_index; + target->page_index = page_index; - HRESULT result = (*d3dintf->device.set_render_target)(d3d->get_device(), 0, target->prescale_target[0]); + HRESULT result = (*d3dintf->device.set_render_target)(d3d->get_device(), 0, target->target_surface[0]); if (result != D3D_OK) osd_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result); result = (*d3dintf->device.clear)(d3d->get_device(), 0, nullptr, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0); if (result != D3D_OK) osd_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result); result = (*d3dintf->device.set_render_target)(d3d->get_device(), 0, backbuffer); if (result != D3D_OK) osd_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result); - target->screen_index = screen_index; - target->page_index = page_index; - - cache_target* cache = find_cache_target(target->screen_index, target->width, target->height); + cache_target* cache = find_cache_target(target->screen_index, source_width, source_height); if (cache == nullptr) { - if (!add_cache_target(d3d, info, width, height, xprescale, yprescale, target->screen_index)) + if (!add_cache_target(d3d, texture, source_width, source_height, target_width, target_height, target->screen_index)) { global_free(target); return false; @@ -1986,51 +1955,27 @@ void shaders::enumerate_screens() // shaders::register_texture(texture::info) //============================================================ -bool shaders::register_texture(texture_info *texture) +bool shaders::register_texture(render_primitive *prim, texture_info *texture) { - int width = texture->get_width(); - int height = texture->get_height(); - int xscale = texture->get_xscale(); - int yscale = texture->get_yscale(); - if (!master_enable || !d3dintf->post_fx_available) { return false; } - enumerate_screens(); - - // Find the nearest prescale factor that is over our screen size - if (hlsl_prescale_x == 0) - { - hlsl_prescale_x = 1; - while (width * xscale * hlsl_prescale_x <= d3d->get_width()) - { - hlsl_prescale_x++; - } - hlsl_prescale_x--; - } - - if (hlsl_prescale_y == 0) - { - hlsl_prescale_y = 1; - while (height * yscale * hlsl_prescale_y <= d3d->get_height()) - { - hlsl_prescale_y++; - } - hlsl_prescale_y--; - } - - hlsl_prescale_x = ((hlsl_prescale_x == 0) ? 1 : hlsl_prescale_x); - hlsl_prescale_y = ((hlsl_prescale_y == 0) ? 1 : hlsl_prescale_y); + bool swap_xy = d3d->swap_xy(); + int target_width = swap_xy + ? static_cast<int>(prim->get_quad_height() + 0.5f) + : static_cast<int>(prim->get_quad_width() + 0.5f); + int target_height = swap_xy + ? static_cast<int>(prim->get_quad_width() + 0.5f) + : static_cast<int>(prim->get_quad_height() + 0.5f); - if (!add_render_target(d3d, texture, width, height, xscale * hlsl_prescale_x, yscale * hlsl_prescale_y)) + osd_printf_verbose("register_texture() - %f, %f; %d, %d\n", prim->get_quad_width(), prim->get_quad_height(), (int)(prim->get_quad_width() + 0.5f), (int)(prim->get_quad_height() + 0.5f)); + if (!add_render_target(d3d, texture, texture->get_width(), texture->get_height(), target_width, target_height)) { return false; } - options->params_dirty = true; - return true; } @@ -2173,6 +2118,8 @@ void shaders::delete_resources(bool reset) } shadow_bitmap.reset(); + + g_slider_list = nullptr; } @@ -2326,6 +2273,7 @@ enum slider_option SLIDER_SCANLINE_ALPHA, SLIDER_SCANLINE_SCALE, SLIDER_SCANLINE_HEIGHT, + SLIDER_SCANLINE_VARIATION, SLIDER_SCANLINE_BRIGHT_SCALE, SLIDER_SCANLINE_BRIGHT_OFFSET, SLIDER_SCANLINE_JITTER, @@ -2400,10 +2348,11 @@ slider_desc shaders::s_sliders[] = { "Screen Reflection", 0, 0, 100, 1, SLIDER_FLOAT, SLIDER_SCREEN_TYPE_ANY, SLIDER_REFLECTION, 0.01f, "%1.2f", {} }, { "Image Vignetting", 0, 0, 100, 1, SLIDER_FLOAT, SLIDER_SCREEN_TYPE_ANY, SLIDER_VIGNETTING, 0.01f, "%1.2f", {} }, { "Scanline Darkness", 0, 0, 100, 1, SLIDER_FLOAT, SLIDER_SCREEN_TYPE_LCD_OR_RASTER, SLIDER_SCANLINE_ALPHA, 0.01f, "%1.2f", {} }, - { "Scanline Screen Height", 1, 20, 80, 1, SLIDER_FLOAT, SLIDER_SCREEN_TYPE_LCD_OR_RASTER, SLIDER_SCANLINE_SCALE, 0.05f, "%1.2f", {} }, - { "Scanline Indiv. Height", 1, 20, 80, 1, SLIDER_FLOAT, SLIDER_SCREEN_TYPE_LCD_OR_RASTER, SLIDER_SCANLINE_HEIGHT, 0.05f, "%1.2f", {} }, - { "Scanline Brightness", 0, 20, 40, 1, SLIDER_FLOAT, SLIDER_SCREEN_TYPE_LCD_OR_RASTER, SLIDER_SCANLINE_BRIGHT_SCALE, 0.05f, "%1.2f", {} }, - { "Scanline Brightness Overdrive", 0, 0, 20, 1, SLIDER_FLOAT, SLIDER_SCREEN_TYPE_LCD_OR_RASTER, SLIDER_SCANLINE_BRIGHT_OFFSET, 0.05f, "%1.2f", {} }, + { "Scanline Screen Scale", 0, 100, 400, 1, SLIDER_FLOAT, SLIDER_SCREEN_TYPE_LCD_OR_RASTER, SLIDER_SCANLINE_SCALE, 0.01f, "%1.2f", {} }, + { "Scanline Height", 0, 100, 400, 1, SLIDER_FLOAT, SLIDER_SCREEN_TYPE_LCD_OR_RASTER, SLIDER_SCANLINE_HEIGHT, 0.01f, "%1.2f", {} }, + { "Scanline Height Variation", 0, 100, 400, 1, SLIDER_FLOAT, SLIDER_SCREEN_TYPE_LCD_OR_RASTER, SLIDER_SCANLINE_VARIATION, 0.01f, "%1.2f", {} }, + { "Scanline Brightness", 0, 100, 200, 1, SLIDER_FLOAT, SLIDER_SCREEN_TYPE_LCD_OR_RASTER, SLIDER_SCANLINE_BRIGHT_SCALE, 0.01f, "%1.2f", {} }, + { "Scanline Brightness Overdrive", 0, 0, 100, 1, SLIDER_FLOAT, SLIDER_SCREEN_TYPE_LCD_OR_RASTER, SLIDER_SCANLINE_BRIGHT_OFFSET, 0.01f, "%1.2f", {} }, { "Scanline Jitter", 0, 0, 100, 1, SLIDER_FLOAT, SLIDER_SCREEN_TYPE_LCD_OR_RASTER, SLIDER_SCANLINE_JITTER, 0.01f, "%1.2f", {} }, { "Hum Bar Darkness", 0, 0, 100, 1, SLIDER_FLOAT, SLIDER_SCREEN_TYPE_LCD_OR_RASTER, SLIDER_HUM_BAR_ALPHA, 0.01f, "%2.2f", {} }, { "Defocus", 0, 0, 100, 1, SLIDER_VEC2, SLIDER_SCREEN_TYPE_ANY, SLIDER_DEFOCUS, 0.1f, "%2.1f", {} }, @@ -2476,6 +2425,7 @@ void *shaders::get_slider_option(int id, int index) case SLIDER_SCANLINE_ALPHA: return &(options->scanline_alpha); case SLIDER_SCANLINE_SCALE: return &(options->scanline_scale); case SLIDER_SCANLINE_HEIGHT: return &(options->scanline_height); + case SLIDER_SCANLINE_VARIATION: return &(options->scanline_variation); case SLIDER_SCANLINE_BRIGHT_SCALE: return &(options->scanline_bright_scale); case SLIDER_SCANLINE_BRIGHT_OFFSET: return &(options->scanline_bright_offset); case SLIDER_SCANLINE_JITTER: return &(options->scanline_jitter); @@ -2524,20 +2474,19 @@ void *shaders::get_slider_option(int id, int index) return nullptr; } -slider_state *shaders::init_slider_list() +void shaders::init_slider_list() { if (!master_enable || !d3dintf->post_fx_available) { g_slider_list = nullptr; - return nullptr; } slider_state *listhead = nullptr; slider_state **tailptr = &listhead; - for (int index = 0; s_sliders[index].name != nullptr; index++) + for (int i = 0; s_sliders[i].name != nullptr; i++) { - slider_desc *desc = &s_sliders[index]; + slider_desc *desc = &s_sliders[i]; int screen_type = machine->first_screen()->screen_type(); if ((screen_type == SCREEN_TYPE_VECTOR && (desc->screen_type & SLIDER_SCREEN_TYPE_VECTOR) == SLIDER_SCREEN_TYPE_VECTOR) || @@ -2557,9 +2506,10 @@ slider_state *shaders::init_slider_list() count = 1; break; } - for (int index = 0; index < count; index++) + + for (int j = 0; j < count; j++) { - slider* slider_arg = new slider(desc, get_slider_option(desc->id, index), &options->params_dirty); + slider* slider_arg = new slider(desc, get_slider_option(desc->id, j), &options->params_dirty); sliders.push_back(slider_arg); std::string name = desc->name; switch (desc->slider_type) @@ -2567,13 +2517,13 @@ slider_state *shaders::init_slider_list() case SLIDER_VEC2: { std::string names[2] = { " X", " Y" }; - name = name + names[index]; + name = name + names[j]; break; } case SLIDER_COLOR: { std::string names[3] = { " Red", " Green", " Blue" }; - name = name + names[index]; + name = name + names[j]; break; } default: @@ -2585,7 +2535,7 @@ slider_state *shaders::init_slider_list() } } - return listhead; + g_slider_list = listhead; } @@ -2661,28 +2611,25 @@ void uniform::update() vec2f sourcedims = shadersys->curr_texture->get_rawdims(); m_shader->set_vector("SourceDims", 2, &sourcedims.c.x); } - + else + { + vec2f sourcedims = d3d->get_dims(); + m_shader->set_vector("SourceDims", 2, &sourcedims.c.x); + } break; } case CU_SOURCE_RECT: { - bool prepare_vector = - d3d->window().machine().first_screen()->screen_type() == SCREEN_TYPE_VECTOR; - - if (prepare_vector) - { - float delta[2] = { 1.0f, 1.0f }; - m_shader->set_vector("SourceRect", 2, delta); - break; - } - if (shadersys->curr_texture != nullptr) { vec2f delta = shadersys->curr_texture->get_uvstop() - shadersys->curr_texture->get_uvstart(); m_shader->set_vector("SourceRect", 2, &delta.c.x); - break; } - + else + { + float delta[2] = { 1.0f, 1.0f }; + m_shader->set_vector("SourceRect", 2, delta); + } break; } case CU_TARGET_DIMS: @@ -2701,8 +2648,9 @@ void uniform::update() if (shadersys->curr_poly != nullptr) { float quaddims[2] = { - shadersys->curr_poly->get_prim_width(), - shadersys->curr_poly->get_prim_height() }; + // round + static_cast<float>(static_cast<int>(shadersys->curr_poly->get_prim_width() + 0.5f)), + static_cast<float>(static_cast<int>(shadersys->curr_poly->get_prim_height() + 0.5f)) }; m_shader->set_vector("QuadDims", 2, quaddims); } break; @@ -2710,18 +2658,15 @@ void uniform::update() case CU_SWAP_XY: { - bool orientation_swap_xy = - (d3d->window().machine().system().flags & ORIENTATION_SWAP_XY) == ORIENTATION_SWAP_XY; - bool rotation_swap_xy = - (d3d->window().target()->orientation() & ROT90) == ROT90 || - (d3d->window().target()->orientation() & ROT270) == ROT270; - m_shader->set_bool("SwapXY", orientation_swap_xy ^ rotation_swap_xy); + m_shader->set_bool("SwapXY", d3d->swap_xy()); + break; } case CU_ORIENTATION_SWAP: { bool orientation_swap_xy = (d3d->window().machine().system().flags & ORIENTATION_SWAP_XY) == ORIENTATION_SWAP_XY; m_shader->set_bool("OrientationSwapXY", orientation_swap_xy); + break; } case CU_ROTATION_SWAP: @@ -2730,6 +2675,7 @@ void uniform::update() (d3d->window().target()->orientation() & ROT90) == ROT90 || (d3d->window().target()->orientation() & ROT270) == ROT270; m_shader->set_bool("RotationSwapXY", rotation_swap_xy); + break; } case CU_ROTATION_TYPE: { @@ -2742,6 +2688,14 @@ void uniform::update() ? 3 : 0; m_shader->set_int("RotationType", rotation_type); + break; + } + case CU_VECTOR_SCREEN: + { + bool vector_screen = + d3d->window().machine().first_screen()->screen_type() == SCREEN_TYPE_VECTOR; + m_shader->set_bool("VectorScreen", vector_screen); + break; } case CU_NTSC_CCFREQ: @@ -2880,6 +2834,9 @@ void uniform::update() case CU_POST_SCANLINE_HEIGHT: m_shader->set_float("ScanlineHeight", options->scanline_height); break; + case CU_POST_SCANLINE_VARIATION: + m_shader->set_float("ScanlineVariation", options->scanline_variation); + break; case CU_POST_SCANLINE_BRIGHT_SCALE: m_shader->set_float("ScanlineBrightScale", options->scanline_bright_scale); break; diff --git a/src/osd/modules/render/d3d/d3dhlsl.h b/src/osd/modules/render/d3d/d3dhlsl.h index 8358efc86e7..74dd433a406 100644 --- a/src/osd/modules/render/d3d/d3dhlsl.h +++ b/src/osd/modules/render/d3d/d3dhlsl.h @@ -53,6 +53,7 @@ public: CU_ORIENTATION_SWAP, CU_ROTATION_SWAP, CU_ROTATION_TYPE, + CU_VECTOR_SCREEN, CU_NTSC_CCFREQ, CU_NTSC_A, @@ -96,6 +97,7 @@ public: CU_POST_SCANLINE_ALPHA, CU_POST_SCANLINE_SCALE, CU_POST_SCANLINE_HEIGHT, + CU_POST_SCANLINE_VARIATION, CU_POST_SCANLINE_BRIGHT_SCALE, CU_POST_SCANLINE_BRIGHT_OFFSET, CU_POST_POWER, @@ -207,6 +209,7 @@ struct hlsl_options float scanline_alpha; float scanline_scale; float scanline_height; + float scanline_variation; float scanline_bright_scale; float scanline_bright_offset; float scanline_jitter; @@ -306,7 +309,7 @@ public: void toggle(); bool vector_enabled() { return master_enable && vector_enable; } - d3d_render_target* get_vector_target(); + d3d_render_target* get_vector_target(render_primitive *prim); void create_vector_target(render_primitive *prim); void begin_frame(); @@ -318,10 +321,10 @@ public: void init_effect_info(poly_info *poly); void render_quad(poly_info *poly, int vertnum); - bool register_texture(texture_info *texture); - bool register_prescaled_texture(texture_info *texture); - bool add_render_target(renderer_d3d9* d3d, texture_info* info, int width, int height, int xprescale, int yprescale); - bool add_cache_target(renderer_d3d9* d3d, texture_info* info, int width, int height, int xprescale, int yprescale, int screen_index); + bool register_texture(render_primitive *prim, texture_info *texture); + d3d_render_target* get_texture_target(render_primitive *prim, texture_info *texture); + bool add_render_target(renderer_d3d9* d3d, texture_info* texture, int source_width, int source_height, int target_width, int target_height); + bool add_cache_target(renderer_d3d9* d3d, texture_info* texture, int source_width, int source_height, int target_width, int target_height, int screen_index); void window_save(); void window_record(); @@ -332,17 +335,17 @@ public: void record_texture(); void init_fsfx_quad(void *vertbuf); - void set_texture(texture_info *texture); - d3d_render_target * find_render_target(texture_info *info); + void set_texture(texture_info *info); + d3d_render_target * find_render_target(texture_info *texture); void remove_render_target(texture_info *texture); - void remove_render_target(int width, int height, UINT32 screen_index, UINT32 page_index); + void remove_render_target(int source_width, int source_height, UINT32 screen_index, UINT32 page_index); void remove_render_target(d3d_render_target *rt); int create_resources(bool reset); void delete_resources(bool reset); // slider-related functions - slider_state *init_slider_list(); + void init_slider_list(); void *get_slider_option(int id, int index = 0); private: @@ -352,9 +355,7 @@ private: void end_avi_recording(); void begin_avi_recording(const char *name); - bool register_texture(texture_info *texture, int width, int height, int xscale, int yscale); - - d3d_render_target* find_render_target(int width, int height, UINT32 screen_index, UINT32 page_index); + d3d_render_target* find_render_target(int source_width, int source_height, UINT32 screen_index, UINT32 page_index); cache_target * find_cache_target(UINT32 screen_index, int width, int height); void remove_cache_target(cache_target *cache); @@ -374,7 +375,7 @@ private: int vector_pass(d3d_render_target *rt, int source_index, poly_info *poly, int vertnum); int vector_buffer_pass(d3d_render_target *rt, int source_index, poly_info *poly, int vertnum); int screen_pass(d3d_render_target *rt, int source_index, poly_info *poly, int vertnum); - void menu_pass(poly_info *poly, int vertnum); + void ui_pass(poly_info *poly, int vertnum); d3d_base * d3dintf; // D3D interface @@ -388,13 +389,6 @@ private: int curr_screen; // current screen for render target operations int curr_frame; // current frame (0/1) of a screen for render target operations int lastidx; // index of the last-encountered target - bool write_ini; // enable external ini saving - bool read_ini; // enable external ini loading - int hlsl_prescale_x; // hlsl prescale x - int hlsl_prescale_y; // hlsl prescale y - float bloom_dims[11][2]; // bloom texture dimensions - int bloom_count; // count of used bloom textures - int preset; // preset, if relevant bitmap_argb32 shadow_bitmap; // shadow mask bitmap for post-processing shader texture_info * shadow_texture; // shadow mask texture for post-processing shader hlsl_options * options; // current options diff --git a/src/osd/modules/render/drawd3d.cpp b/src/osd/modules/render/drawd3d.cpp index 422edaf7b26..4b8cc430640 100644 --- a/src/osd/modules/render/drawd3d.cpp +++ b/src/osd/modules/render/drawd3d.cpp @@ -209,6 +209,7 @@ render_primitive_list *renderer_d3d9::get_primitives() } if (m_shaders != nullptr) { + // do not transform primitives (scale, offset) if shaders are enabled, the shaders will handle the transformation window().target()->set_transform_primitives(!m_shaders->enabled()); } return &window().target()->get_primitives(); @@ -636,8 +637,16 @@ void d3d_texture_manager::update_textures() texture_info *texture = find_texinfo(&prim->texture, prim->flags); if (texture == nullptr) { - // if there isn't one, create a new texture - global_alloc(texture_info(this, &prim->texture, m_renderer->window().prescale(), prim->flags)); + if (m_renderer->get_shaders()->enabled()) + { + // if there isn't one, create a new texture without prescale + texture = global_alloc(texture_info(this, &prim->texture, 1, prim->flags)); + } + else + { + // if there isn't one, create a new texture + texture = global_alloc(texture_info(this, &prim->texture, m_renderer->window().prescale(), prim->flags)); + } } else { @@ -648,10 +657,21 @@ void d3d_texture_manager::update_textures() texture->get_texinfo().seqid = prim->texture.seqid; } } + + if (m_renderer->get_shaders()->enabled()) + { + if (!m_renderer->get_shaders()->get_texture_target(prim, texture)) + { + if (!m_renderer->get_shaders()->register_texture(prim, texture)) + { + d3dintf->post_fx_available = false; + } + } + } } else if(m_renderer->get_shaders()->vector_enabled() && PRIMFLAG_GET_VECTORBUF(prim->flags)) { - if (!m_renderer->get_shaders()->get_vector_target()) + if (!m_renderer->get_shaders()->get_vector_target(prim)) { m_renderer->get_shaders()->create_vector_target(prim); } @@ -684,12 +704,15 @@ void renderer_d3d9::begin_frame() m_shaders->init_fsfx_quad(m_hlsl_buf); } + // loop over line primitives m_line_count = 0; - - // loop over primitives for (render_primitive *prim = window().m_primlist->first(); prim != nullptr; prim = prim->next()) + { if (prim->type == render_primitive::LINE && PRIMFLAG_GET_VECTOR(prim->flags)) + { m_line_count++; + } + } } void renderer_d3d9::process_primitives() @@ -1374,6 +1397,9 @@ void renderer_d3d9::batch_vectors() m_vectorbatch = mesh_alloc(m_line_count * vector_size); m_batchindex = 0; + float width = 0.0f; + float height = 0.0f; + static int start_index = 0; int line_index = 0; float period = options.screen_vector_time_period(); @@ -1398,6 +1424,14 @@ void renderer_d3d9::batch_vectors() } break; + case render_primitive::QUAD: + if (PRIMFLAG_GET_VECTORBUF(prim->flags)) + { + width = prim->bounds.x1 - prim->bounds.x0; + height = prim->bounds.y1 - prim->bounds.y0; + } + break; + default: // Skip break; @@ -1406,7 +1440,7 @@ void renderer_d3d9::batch_vectors() // now add a polygon entry m_poly[m_numpolys].init(D3DPT_TRIANGLELIST, m_line_count * (options.antialias() ? 8 : 2), vector_size * m_line_count, cached_flags, - m_texture_manager->get_vector_texture(), D3DTOP_MODULATE, 0.0f, 1.0f, 0.0f, 0.0f); + m_texture_manager->get_vector_texture(), D3DTOP_MODULATE, 0.0f, 1.0f, width, height); m_numpolys++; start_index += (int)((float)line_index * period); @@ -1631,11 +1665,12 @@ void renderer_d3d9::draw_quad(const render_primitive *prim) float height = prim->bounds.y1 - prim->bounds.y0; // set the texture coordinates - if(texture != nullptr) + if (texture != nullptr) { vec2f& start = texture->get_uvstart(); vec2f& stop = texture->get_uvstop(); vec2f delta = stop - start; + vertex[0].u0 = start.c.x + delta.c.x * prim->texcoords.tl.u; vertex[0].v0 = start.c.y + delta.c.y * prim->texcoords.tl.v; vertex[1].u0 = start.c.x + delta.c.x * prim->texcoords.tr.u; @@ -1888,6 +1923,30 @@ texture_info::texture_info(d3d_texture_manager *manager, const render_texinfo* t m_d3dsurface = nullptr; m_d3dfinaltex = nullptr; + // determine texture type, required to compute texture size + if (!PRIMFLAG_GET_SCREENTEX(flags)) + { + m_type = TEXTURE_TYPE_PLAIN; + } + else + { + if ((m_xprescale == 1 && m_yprescale == 1) || m_renderer->get_shaders()->enabled()) + { + m_type = m_texture_manager->is_dynamic_supported() ? TEXTURE_TYPE_DYNAMIC : TEXTURE_TYPE_PLAIN; + } + else + { + if (m_texture_manager->is_stretch_supported() && PRIMFLAG_GET_TEXFORMAT(flags) != TEXFORMAT_YUY16) + { + m_type = TEXTURE_TYPE_SURFACE; + } + else + { + m_type = m_texture_manager->is_dynamic_supported() ? TEXTURE_TYPE_DYNAMIC : TEXTURE_TYPE_PLAIN; + } + } + } + // compute the size compute_size(texsource->width, texsource->height); @@ -1899,7 +1958,6 @@ texture_info::texture_info(d3d_texture_manager *manager, const render_texinfo* t if (result != D3D_OK) goto error; m_d3dfinaltex = m_d3dtex; - m_type = TEXTURE_TYPE_PLAIN; } // screen textures are allocated differently @@ -1964,16 +2022,9 @@ texture_info::texture_info(d3d_texture_manager *manager, const render_texinfo* t if (result == D3D_OK) { m_d3dfinaltex = m_d3dtex; - m_type = m_texture_manager->is_dynamic_supported() ? TEXTURE_TYPE_DYNAMIC : TEXTURE_TYPE_PLAIN; - if (m_renderer->get_shaders()->enabled() && !m_renderer->get_shaders()->register_texture(this)) - { - goto error; - } - break; } } - // screen textures with prescaling require two allocations else { @@ -1986,9 +2037,7 @@ texture_info::texture_info(d3d_texture_manager *manager, const render_texinfo* t { continue; } - m_type = TEXTURE_TYPE_SURFACE; } - // otherwise, we allocate a dynamic texture for the source else { @@ -1997,7 +2046,6 @@ texture_info::texture_info(d3d_texture_manager *manager, const render_texinfo* t { continue; } - m_type = m_texture_manager->is_dynamic_supported() ? TEXTURE_TYPE_DYNAMIC : TEXTURE_TYPE_PLAIN; } // for the target surface, we allocate a render target texture @@ -2006,15 +2054,13 @@ texture_info::texture_info(d3d_texture_manager *manager, const render_texinfo* t // target surfaces typically cannot be YCbCr, so we always pick RGB in that case D3DFORMAT finalfmt = (format != m_texture_manager->get_yuv_format()) ? format : D3DFMT_A8R8G8B8; + result = (*d3dintf->device.create_texture)(m_renderer->get_device(), scwidth, scheight, 1, D3DUSAGE_RENDERTARGET, finalfmt, D3DPOOL_DEFAULT, &m_d3dfinaltex); if (result == D3D_OK) { - if (m_renderer->get_shaders()->enabled() && !m_renderer->get_shaders()->register_prescaled_texture(this)) - { - goto error; - } break; } + (*d3dintf->texture.release)(m_d3dtex); m_d3dtex = nullptr; } @@ -2024,7 +2070,6 @@ texture_info::texture_info(d3d_texture_manager *manager, const render_texinfo* t // copy the data to the texture set_data(texsource, flags); - //texsource->osdhandle = (void*)this; // add us to the texture list if(m_texture_manager->get_texlist() != nullptr) m_texture_manager->get_texlist()->m_prev = this; @@ -2112,30 +2157,42 @@ void texture_info::compute_size(int texwidth, int texheight) m_xborderpix = 0; m_yborderpix = 0; - // if we're not wrapping, add a 1-2 pixel border on all sides - if (ENABLE_BORDER_PIX && !(m_flags & PRIMFLAG_TEXWRAP_MASK)) + bool shaders_enabled = m_renderer->get_shaders()->enabled(); + bool wrap_texture = (m_flags & PRIMFLAG_TEXWRAP_MASK) == PRIMFLAG_TEXWRAP_MASK; + bool border_texture = ENABLE_BORDER_PIX && !wrap_texture; + bool surface_texture = m_type == TEXTURE_TYPE_SURFACE; + + // skip border when shaders are enabled and we're not creating a surface (UI) texture + if (!shaders_enabled || surface_texture) { - // note we need 2 pixels in X for YUY textures - m_xborderpix = (PRIMFLAG_GET_TEXFORMAT(m_flags) == TEXFORMAT_YUY16) ? 2 : 1; - m_yborderpix = 1; + // if we're not wrapping, add a 1-2 pixel border on all sides + if (border_texture) + { + // note we need 2 pixels in X for YUY textures + m_xborderpix = (PRIMFLAG_GET_TEXFORMAT(m_flags) == TEXFORMAT_YUY16) ? 2 : 1; + m_yborderpix = 1; + } } - // compute final texture size finalwidth += 2 * m_xborderpix; finalheight += 2 * m_yborderpix; - compute_size_subroutine(finalwidth, finalheight, &finalwidth, &finalheight); - - // if we added pixels for the border, and that just barely pushed us over, take it back - if (finalwidth > m_texture_manager->get_max_texture_width() || finalheight > m_texture_manager->get_max_texture_height()) + // take texture size as given when shaders are enabled and we're not creating a surface (UI) texture, still update wrapped textures + if (!shaders_enabled || surface_texture || wrap_texture) { - finalheight = texheight; - finalwidth = texwidth; + compute_size_subroutine(finalwidth, finalheight, &finalwidth, &finalheight); - m_xborderpix = 0; - m_yborderpix = 0; + // if we added pixels for the border, and that just barely pushed us over, take it back + if (finalwidth > m_texture_manager->get_max_texture_width() || finalheight > m_texture_manager->get_max_texture_height()) + { + finalheight = texheight; + finalwidth = texwidth; - compute_size_subroutine(finalwidth, finalheight, &finalwidth, &finalheight); + m_xborderpix = 0; + m_yborderpix = 0; + + compute_size_subroutine(finalwidth, finalheight, &finalwidth, &finalheight); + } } // if we're above the max width/height, do what? @@ -2714,18 +2771,20 @@ cache_target::~cache_target() // cache_target::init - initializes a target cache //============================================================ -bool cache_target::init(renderer_d3d9 *d3d, d3d_base *d3dintf, int width, int height, int prescale_x, int prescale_y) +bool cache_target::init(renderer_d3d9 *d3d, d3d_base *d3dintf, int source_width, int source_height, int target_width, int target_height) { - HRESULT result = (*d3dintf->device.create_texture)(d3d->get_device(), width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &last_texture); + this->width = source_width; + this->height = source_height; + this->target_width = target_width; + this->target_height = target_height; + + HRESULT result = (*d3dintf->device.create_texture)(d3d->get_device(), target_width, target_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &last_texture); if (result != D3D_OK) { return false; } (*d3dintf->texture.get_surface_level)(last_texture, 0, &last_target); - target_width = width * prescale_x; - target_height = height * prescale_y; - return true; } @@ -2743,34 +2802,34 @@ d3d_render_target::~d3d_render_target() (*d3dintf->texture.release)(bloom_texture[index]); bloom_texture[index] = nullptr; } - if (bloom_target[index] != nullptr) + if (bloom_surface[index] != nullptr) { - (*d3dintf->surface.release)(bloom_target[index]); - bloom_target[index] = nullptr; + (*d3dintf->surface.release)(bloom_surface[index]); + bloom_surface[index] = nullptr; } } for (int index = 0; index < 2; index++) { - if (native_texture[index] != nullptr) + if (source_texture[index] != nullptr) { - (*d3dintf->texture.release)(native_texture[index]); - native_texture[index] = nullptr; + (*d3dintf->texture.release)(source_texture[index]); + source_texture[index] = nullptr; } - if (native_target[index] != nullptr) + if (source_surface[index] != nullptr) { - (*d3dintf->surface.release)(native_target[index]); - native_target[index] = nullptr; + (*d3dintf->surface.release)(source_surface[index]); + source_surface[index] = nullptr; } - if (prescale_texture[index] != nullptr) + if (target_texture[index] != nullptr) { - (*d3dintf->texture.release)(prescale_texture[index]); - prescale_texture[index] = nullptr; + (*d3dintf->texture.release)(target_texture[index]); + target_texture[index] = nullptr; } - if (prescale_target[index] != nullptr) + if (target_surface[index] != nullptr) { - (*d3dintf->surface.release)(prescale_target[index]); - prescale_target[index] = nullptr; + (*d3dintf->surface.release)(target_surface[index]); + target_surface[index] = nullptr; } } } @@ -2780,51 +2839,61 @@ d3d_render_target::~d3d_render_target() // d3d_render_target::init - initializes a render target //============================================================ -bool d3d_render_target::init(renderer_d3d9 *d3d, d3d_base *d3dintf, int width, int height, int prescale_x, int prescale_y) +bool d3d_render_target::init(renderer_d3d9 *d3d, d3d_base *d3dintf, int source_width, int source_height, int target_width, int target_height) { HRESULT result; + this->width = source_width; + this->height = source_height; + + this->target_width = target_width; + this->target_height = target_height; + for (int index = 0; index < 2; index++) { - result = (*d3dintf->device.create_texture)(d3d->get_device(), width, height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &native_texture[index]); + result = (*d3dintf->device.create_texture)(d3d->get_device(), source_width, source_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &source_texture[index]); if (result != D3D_OK) { return false; } - (*d3dintf->texture.get_surface_level)(native_texture[index], 0, &native_target[index]); + (*d3dintf->texture.get_surface_level)(source_texture[index], 0, &source_surface[index]); - result = (*d3dintf->device.create_texture)(d3d->get_device(), width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &prescale_texture[index]); + result = (*d3dintf->device.create_texture)(d3d->get_device(), target_width, target_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &target_texture[index]); if (result != D3D_OK) { return false; } - (*d3dintf->texture.get_surface_level)(prescale_texture[index], 0, &prescale_target[index]); + (*d3dintf->texture.get_surface_level)(target_texture[index], 0, &target_surface[index]); } - int bloom_index = 0; - float bloom_size = (d3d->get_width() < d3d->get_height()) ? d3d->get_width() : d3d->get_height(); - float bloom_width = d3d->get_width(); - float bloom_height = d3d->get_height(); - for (; bloom_size >= 2.0f && bloom_index < 11; bloom_size *= 0.5f) + bool vector_screen = + d3d->window().machine().first_screen()->screen_type() == SCREEN_TYPE_VECTOR; + + // larger blur width for vector screens than raster screens + float scale_factor = vector_screen ? 0.5f : 0.75f; + + float bloom_width = (float)source_width; + float bloom_height = (float)source_height; + float bloom_size = bloom_width < bloom_height ? bloom_width : bloom_height; + for (int bloom_index = 0; bloom_index < 11 && bloom_size >= 2.0f; bloom_size *= scale_factor) { - bloom_width *= 0.5f; - bloom_height *= 0.5f; + this->bloom_dims[bloom_index][0] = (int)bloom_width; + this->bloom_dims[bloom_index][1] = (int)bloom_height; result = (*d3dintf->device.create_texture)(d3d->get_device(), (int)bloom_width, (int)bloom_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &bloom_texture[bloom_index]); if (result != D3D_OK) { return false; } - (*d3dintf->texture.get_surface_level)(bloom_texture[bloom_index], 0, &bloom_target[bloom_index]); + (*d3dintf->texture.get_surface_level)(bloom_texture[bloom_index], 0, &bloom_surface[bloom_index]); - bloom_index++; - } + bloom_width *= scale_factor; + bloom_height *= scale_factor; - this->width = width; - this->height = height; + bloom_index++; - target_width = width * prescale_x; - target_height = height * prescale_y; + this->bloom_count = bloom_index; + } return true; } diff --git a/src/osd/modules/render/drawd3d.h b/src/osd/modules/render/drawd3d.h index 474f9ef8487..de8506ebfbd 100644 --- a/src/osd/modules/render/drawd3d.h +++ b/src/osd/modules/render/drawd3d.h @@ -54,6 +54,17 @@ public: virtual void record() override; virtual void toggle_fsfx() override; + bool swap_xy() + { + // todo: move to osd_window + bool orientation_swap_xy = + (window().machine().system().flags & ORIENTATION_SWAP_XY) == ORIENTATION_SWAP_XY; + bool rotation_swap_xy = + (window().target()->orientation() & ROT90) == ROT90 || + (window().target()->orientation() & ROT270) == ROT270; + return orientation_swap_xy ^ rotation_swap_xy; + }; + int initialize(); int device_create(HWND device_HWND); @@ -81,8 +92,6 @@ public: vertex * mesh_alloc(int numverts); - void update_textures(); - void process_primitives(); void primitive_flush_pending(); diff --git a/src/osd/windows/windir.cpp b/src/osd/windows/windir.cpp index edbe688ffe9..87b1b5e05ce 100644 --- a/src/osd/windows/windir.cpp +++ b/src/osd/windows/windir.cpp @@ -72,7 +72,7 @@ osd_directory *osd_opendir(const char *dirname) _sntprintf(dirfilter, dirfilter_size, TEXT("%s\\*.*"), t_dirname); // attempt to find the first file - dir->find = FindFirstFile(dirfilter, &dir->data); + dir->find = FindFirstFileEx(dirfilter, FindExInfoStandard, &dir->data, FindExSearchNameMatch, nullptr, 0); error: // cleanup diff --git a/src/osd/windows/window.cpp b/src/osd/windows/window.cpp index 31c85788c56..c6fd834b17f 100644 --- a/src/osd/windows/window.cpp +++ b/src/osd/windows/window.cpp @@ -281,6 +281,7 @@ void windows_osd_interface::update_slider_list() { for (win_window_info *window = win_window_list; window != nullptr; window = window->m_next) { + // check if any window has dirty sliders if (window->m_renderer && window->m_renderer->sliders_dirty()) { build_slider_list(); @@ -291,26 +292,13 @@ void windows_osd_interface::update_slider_list() void windows_osd_interface::build_slider_list() { - m_sliders = nullptr; - slider_state *curr = m_sliders; - for (win_window_info *info = win_window_list; info != nullptr; info = info->m_next) + // FIXME: take all sliders from all windows without concatenate them by slider_state->next + + for (win_window_info *window = win_window_list; window != nullptr; window = window->m_next) { - slider_state *window_sliders = info->m_renderer->get_slider_list(); - if (window_sliders != nullptr) - { - if (m_sliders == nullptr) - { - m_sliders = curr = window_sliders; - } - else - { - while (curr->next != nullptr) - { - curr = curr->next; - } - curr->next = window_sliders; - } - } + // take the sliders of the first window + m_sliders = window->m_renderer->get_slider_list(); + return; } } diff --git a/src/osd/windows/winmain.cpp b/src/osd/windows/winmain.cpp index 2ed2561e747..5638628d121 100644 --- a/src/osd/windows/winmain.cpp +++ b/src/osd/windows/winmain.cpp @@ -279,8 +279,6 @@ const options_entry windows_options::s_option_entries[] = { nullptr, nullptr, OPTION_HEADER, "DIRECT3D POST-PROCESSING OPTIONS" }, { WINOPTION_HLSL_ENABLE";hlsl", "0", OPTION_BOOLEAN, "enables HLSL post-processing (PS3.0 required)" }, { WINOPTION_HLSLPATH, "hlsl", OPTION_STRING, "path to hlsl files" }, - { WINOPTION_HLSL_PRESCALE_X, "0", OPTION_INTEGER, "HLSL pre-scale override factor for X (0 for auto)" }, - { WINOPTION_HLSL_PRESCALE_Y, "0", OPTION_INTEGER, "HLSL pre-scale override factor for Y (0 for auto)" }, { WINOPTION_HLSL_WRITE, nullptr, OPTION_STRING, "enables HLSL AVI writing (huge disk bandwidth suggested)" }, { WINOPTION_HLSL_SNAP_WIDTH, "2048", OPTION_STRING, "HLSL upscaled-snapshot width" }, { WINOPTION_HLSL_SNAP_HEIGHT, "1536", OPTION_STRING, "HLSL upscaled-snapshot height" }, @@ -302,25 +300,26 @@ const options_entry windows_options::s_option_entries[] = { WINOPTION_SCANLINE_AMOUNT";fs_scanam(0.0-4.0)", "0.0", OPTION_FLOAT, "overall alpha scaling value for scanlines" }, { WINOPTION_SCANLINE_SCALE";fs_scansc(0.0-4.0)", "1.0", OPTION_FLOAT, "overall height scaling value for scanlines" }, { WINOPTION_SCANLINE_HEIGHT";fs_scanh(0.0-4.0)", "1.0", OPTION_FLOAT, "individual height scaling value for scanlines" }, + { WINOPTION_SCANLINE_VARIATION";fs_scanv(0.0-4.0)", "1.0", OPTION_FLOAT, "individual height varying value for scanlines" }, { WINOPTION_SCANLINE_BRIGHT_SCALE";fs_scanbs(0.0-2.0)", "1.0", OPTION_FLOAT, "overall brightness scaling value for scanlines (multiplicative)" }, { WINOPTION_SCANLINE_BRIGHT_OFFSET";fs_scanbo(0.0-1.0)", "0.0", OPTION_FLOAT, "overall brightness offset value for scanlines (additive)" }, { WINOPTION_SCANLINE_JITTER";fs_scanjt(0.0-4.0)", "0.0", OPTION_FLOAT, "overall interlace jitter scaling value for scanlines" }, { WINOPTION_HUM_BAR_ALPHA";fs_humba(0.0-1.0)", "0.0", OPTION_FLOAT, "overall alpha scaling value for hum bar" }, - { WINOPTION_DEFOCUS";fs_focus", "1.0,0.0", OPTION_STRING, "overall defocus value in screen-relative coords" }, - { WINOPTION_CONVERGE_X";fs_convx", "0.25,0.00,-0.25", OPTION_STRING, "convergence in screen-relative X direction" }, - { WINOPTION_CONVERGE_Y";fs_convy", "0.0,0.25,-0.25", OPTION_STRING, "convergence in screen-relative Y direction" }, + { WINOPTION_DEFOCUS";fs_focus", "0.0,0.0", OPTION_STRING, "overall defocus value in screen-relative coords" }, + { WINOPTION_CONVERGE_X";fs_convx", "0.0,0.0,0.0", OPTION_STRING, "convergence in screen-relative X direction" }, + { WINOPTION_CONVERGE_Y";fs_convy", "0.0,0.0,0.0", OPTION_STRING, "convergence in screen-relative Y direction" }, { WINOPTION_RADIAL_CONVERGE_X";fs_rconvx", "0.0,0.0,0.0", OPTION_STRING, "radial convergence in screen-relative X direction" }, { WINOPTION_RADIAL_CONVERGE_Y";fs_rconvy", "0.0,0.0,0.0", OPTION_STRING, "radial convergence in screen-relative Y direction" }, /* RGB colorspace convolution below this line */ { WINOPTION_RED_RATIO";fs_redratio", "1.0,0.0,0.0", OPTION_STRING, "red output signal generated by input signal" }, { WINOPTION_GRN_RATIO";fs_grnratio", "0.0,1.0,0.0", OPTION_STRING, "green output signal generated by input signal" }, { WINOPTION_BLU_RATIO";fs_bluratio", "0.0,0.0,1.0", OPTION_STRING, "blue output signal generated by input signal" }, - { WINOPTION_SATURATION";fs_sat(0.0-4.0)", "1.4", OPTION_FLOAT, "saturation scaling value" }, + { WINOPTION_SATURATION";fs_sat(0.0-4.0)", "1.0", OPTION_FLOAT, "saturation scaling value" }, { WINOPTION_OFFSET";fs_offset", "0.0,0.0,0.0", OPTION_STRING, "signal offset value (additive)" }, - { WINOPTION_SCALE";fs_scale", "0.95,0.95,0.95", OPTION_STRING, "signal scaling value (multiplicative)" }, - { WINOPTION_POWER";fs_power", "0.8,0.8,0.8", OPTION_STRING, "signal power value (exponential)" }, - { WINOPTION_FLOOR";fs_floor", "0.05,0.05,0.05", OPTION_STRING, "signal floor level" }, - { WINOPTION_PHOSPHOR";fs_phosphor", "0.4,0.4,0.4", OPTION_STRING, "phosphorescence decay rate (0.0 is instant, 1.0 is forever)" }, + { WINOPTION_SCALE";fs_scale", "1.0,1.0,1.0", OPTION_STRING, "signal scaling value (multiplicative)" }, + { WINOPTION_POWER";fs_power", "1.0,1.0,1.0", OPTION_STRING, "signal power value (exponential)" }, + { WINOPTION_FLOOR";fs_floor", "0.0,0.0,0.0", OPTION_STRING, "signal floor level" }, + { WINOPTION_PHOSPHOR";fs_phosphor", "0.0,0.0,0.0", OPTION_STRING, "phosphorescence decay rate (0.0 is instant, 1.0 is forever)" }, /* NTSC simulation below this line */ { nullptr, nullptr, OPTION_HEADER, "NTSC POST-PROCESSING OPTIONS" }, { WINOPTION_YIQ_ENABLE";yiq", "0", OPTION_BOOLEAN, "enables YIQ-space HLSL post-processing" }, @@ -342,20 +341,20 @@ const options_entry windows_options::s_option_entries[] = { WINOPTION_VECTOR_LENGTH_RATIO";vecsize", "500.0", OPTION_FLOAT, "Vector fade length (4.0 - vectors fade the most at and above 4 pixels, etc.)" }, /* Bloom below this line */ { nullptr, nullptr, OPTION_HEADER, "BLOOM POST-PROCESSING OPTIONS" }, - { WINOPTION_BLOOM_BLEND_MODE, "0", OPTION_INTEGER, "bloom blend mode (0 for addition, 1 for darken)" }, - { WINOPTION_BLOOM_SCALE, "0.25", OPTION_FLOAT, "Intensity factor for bloom" }, + { WINOPTION_BLOOM_BLEND_MODE, "0", OPTION_INTEGER, "bloom blend mode (0 for brighten, 1 for darken)" }, + { WINOPTION_BLOOM_SCALE, "0.0", OPTION_FLOAT, "Intensity factor for bloom" }, { WINOPTION_BLOOM_OVERDRIVE, "1.0,1.0,1.0", OPTION_STRING, "Overdrive factor for bloom" }, { WINOPTION_BLOOM_LEVEL0_WEIGHT, "1.0", OPTION_FLOAT, "Bloom level 0 (full-size target) weight" }, - { WINOPTION_BLOOM_LEVEL1_WEIGHT, "0.64", OPTION_FLOAT, "Bloom level 1 (half-size target) weight" }, - { WINOPTION_BLOOM_LEVEL2_WEIGHT, "0.32", OPTION_FLOAT, "Bloom level 2 (quarter-size target) weight" }, - { WINOPTION_BLOOM_LEVEL3_WEIGHT, "0.16", OPTION_FLOAT, "Bloom level 3 (.) weight" }, - { WINOPTION_BLOOM_LEVEL4_WEIGHT, "0.08", OPTION_FLOAT, "Bloom level 4 (.) weight" }, - { WINOPTION_BLOOM_LEVEL5_WEIGHT, "0.04", OPTION_FLOAT, "Bloom level 5 (.) weight" }, - { WINOPTION_BLOOM_LEVEL6_WEIGHT, "0.04", OPTION_FLOAT, "Bloom level 6 (.) weight" }, - { WINOPTION_BLOOM_LEVEL7_WEIGHT, "0.02", OPTION_FLOAT, "Bloom level 7 (.) weight" }, - { WINOPTION_BLOOM_LEVEL8_WEIGHT, "0.02", OPTION_FLOAT, "Bloom level 8 (.) weight" }, - { WINOPTION_BLOOM_LEVEL9_WEIGHT, "0.01", OPTION_FLOAT, "Bloom level 9 (.) weight" }, - { WINOPTION_BLOOM_LEVEL10_WEIGHT, "0.01", OPTION_FLOAT, "Bloom level 10 (1x1 target) weight" }, + { WINOPTION_BLOOM_LEVEL1_WEIGHT, "0.64", OPTION_FLOAT, "Bloom level 1 (1/2-size target) weight" }, + { WINOPTION_BLOOM_LEVEL2_WEIGHT, "0.32", OPTION_FLOAT, "Bloom level 2 (1/4-size target) weight" }, + { WINOPTION_BLOOM_LEVEL3_WEIGHT, "0.16", OPTION_FLOAT, "Bloom level 3 (1/8-size target) weight" }, + { WINOPTION_BLOOM_LEVEL4_WEIGHT, "0.08", OPTION_FLOAT, "Bloom level 4 (1/16-size target) weight" }, + { WINOPTION_BLOOM_LEVEL5_WEIGHT, "0.04", OPTION_FLOAT, "Bloom level 5 (1/32-size target) weight" }, + { WINOPTION_BLOOM_LEVEL6_WEIGHT, "0.04", OPTION_FLOAT, "Bloom level 6 (1/64-size target) weight" }, + { WINOPTION_BLOOM_LEVEL7_WEIGHT, "0.02", OPTION_FLOAT, "Bloom level 7 (1/128-size target) weight" }, + { WINOPTION_BLOOM_LEVEL8_WEIGHT, "0.02", OPTION_FLOAT, "Bloom level 8 (1/256-size target) weight" }, + { WINOPTION_BLOOM_LEVEL9_WEIGHT, "0.01", OPTION_FLOAT, "Bloom level 9 (1/512-size target) weight" }, + { WINOPTION_BLOOM_LEVEL10_WEIGHT, "0.01", OPTION_FLOAT, "Bloom level 10 (1/1024-size target) weight" }, // full screen options { nullptr, nullptr, OPTION_HEADER, "FULL SCREEN OPTIONS" }, diff --git a/src/osd/windows/winmain.h b/src/osd/windows/winmain.h index bf6eed57559..45c93b66c49 100644 --- a/src/osd/windows/winmain.h +++ b/src/osd/windows/winmain.h @@ -28,8 +28,6 @@ // core post-processing options #define WINOPTION_HLSL_ENABLE "hlsl_enable" #define WINOPTION_HLSLPATH "hlslpath" -#define WINOPTION_HLSL_PRESCALE_X "hlsl_prescale_x" -#define WINOPTION_HLSL_PRESCALE_Y "hlsl_prescale_y" #define WINOPTION_HLSL_WRITE "hlsl_write" #define WINOPTION_HLSL_SNAP_WIDTH "hlsl_snap_width" #define WINOPTION_HLSL_SNAP_HEIGHT "hlsl_snap_height" @@ -50,6 +48,7 @@ #define WINOPTION_SCANLINE_AMOUNT "scanline_alpha" #define WINOPTION_SCANLINE_SCALE "scanline_size" #define WINOPTION_SCANLINE_HEIGHT "scanline_height" +#define WINOPTION_SCANLINE_VARIATION "scanline_variation" #define WINOPTION_SCANLINE_BRIGHT_SCALE "scanline_bright_scale" #define WINOPTION_SCANLINE_BRIGHT_OFFSET "scanline_bright_offset" #define WINOPTION_SCANLINE_JITTER "scanline_jitter" @@ -130,8 +129,6 @@ public: const char *screen_post_fx_dir() const { return value(WINOPTION_HLSLPATH); } bool d3d_hlsl_enable() const { return bool_value(WINOPTION_HLSL_ENABLE); } const char *d3d_hlsl_write() const { return value(WINOPTION_HLSL_WRITE); } - int d3d_hlsl_prescale_x() const { return int_value(WINOPTION_HLSL_PRESCALE_X); } - int d3d_hlsl_prescale_y() const { return int_value(WINOPTION_HLSL_PRESCALE_Y); } int d3d_snap_width() const { return int_value(WINOPTION_HLSL_SNAP_WIDTH); } int d3d_snap_height() const { return int_value(WINOPTION_HLSL_SNAP_HEIGHT); } int screen_shadow_mask_tile_mode() const { return int_value(WINOPTION_SHADOW_MASK_TILE_MODE); } @@ -146,6 +143,7 @@ public: float screen_scanline_amount() const { return float_value(WINOPTION_SCANLINE_AMOUNT); } float screen_scanline_scale() const { return float_value(WINOPTION_SCANLINE_SCALE); } float screen_scanline_height() const { return float_value(WINOPTION_SCANLINE_HEIGHT); } + float screen_scanline_variation() const { return float_value(WINOPTION_SCANLINE_VARIATION); } float screen_scanline_bright_scale() const { return float_value(WINOPTION_SCANLINE_BRIGHT_SCALE); } float screen_scanline_bright_offset() const { return float_value(WINOPTION_SCANLINE_BRIGHT_OFFSET); } float screen_scanline_jitter() const { return float_value(WINOPTION_SCANLINE_JITTER); } diff --git a/src/tools/chdman.cpp b/src/tools/chdman.cpp index edf7ee0b14a..95dd285a94d 100644 --- a/src/tools/chdman.cpp +++ b/src/tools/chdman.cpp @@ -333,7 +333,7 @@ public: { m_file.reset(); m_lastfile = m_info.track[tracknum].fname; - osd_file::error filerr = util::core_file::open(m_lastfile.c_str(), OPEN_FLAG_READ, m_file); + osd_file::error filerr = util::core_file::open(m_lastfile, OPEN_FLAG_READ, m_file); if (filerr != osd_file::error::NONE) report_error(1, "Error opening input file (%s)'", m_lastfile.c_str()); } @@ -1574,7 +1574,7 @@ static void do_create_raw(parameters_t ¶ms) auto input_file_str = params.find(OPTION_INPUT); if (input_file_str != params.end()) { - osd_file::error filerr = util::core_file::open(input_file_str->second->c_str(), OPEN_FLAG_READ, input_file); + osd_file::error filerr = util::core_file::open(*input_file_str->second, OPEN_FLAG_READ, input_file); if (filerr != osd_file::error::NONE) report_error(1, "Unable to open file (%s)", input_file_str->second->c_str()); } @@ -1671,7 +1671,7 @@ static void do_create_hd(parameters_t ¶ms) auto input_file_str = params.find(OPTION_INPUT); if (input_file_str != params.end()) { - osd_file::error filerr = util::core_file::open(input_file_str->second->c_str(), OPEN_FLAG_READ, input_file); + osd_file::error filerr = util::core_file::open(*input_file_str->second, OPEN_FLAG_READ, input_file); if (filerr != osd_file::error::NONE) report_error(1, "Unable to open file (%s)", input_file_str->second->c_str()); } @@ -2240,7 +2240,7 @@ static void do_extract_raw(parameters_t ¶ms) try { // process output file - osd_file::error filerr = util::core_file::open(output_file_str->second->c_str(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, output_file); + osd_file::error filerr = util::core_file::open(*output_file_str->second, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, output_file); if (filerr != osd_file::error::NONE) report_error(1, "Unable to open file (%s)", output_file_str->second->c_str()); @@ -2345,14 +2345,14 @@ static void do_extract_cd(parameters_t ¶ms) } // process output file - osd_file::error filerr = util::core_file::open(output_file_str->second->c_str(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_NO_BOM, output_toc_file); + osd_file::error filerr = util::core_file::open(*output_file_str->second, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_NO_BOM, output_toc_file); if (filerr != osd_file::error::NONE) report_error(1, "Unable to open file (%s)", output_file_str->second->c_str()); // process output BIN file if (mode != MODE_GDI) { - filerr = util::core_file::open(output_bin_file_str->c_str(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, output_bin_file); + filerr = util::core_file::open(*output_bin_file_str, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, output_bin_file); if (filerr != osd_file::error::NONE) report_error(1, "Unable to open file (%s)", output_bin_file_str->c_str()); } @@ -2388,7 +2388,7 @@ static void do_extract_cd(parameters_t ¶ms) output_bin_file.reset(); - filerr = util::core_file::open(trackbin_name.c_str(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, output_bin_file); + filerr = util::core_file::open(trackbin_name, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, output_bin_file); if (filerr != osd_file::error::NONE) report_error(1, "Unable to open file (%s)", trackbin_name.c_str()); @@ -2795,7 +2795,7 @@ static void do_dump_metadata(parameters_t ¶ms) // create the file if (output_file_str != params.end()) { - osd_file::error filerr = util::core_file::open(output_file_str->second->c_str(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, output_file); + osd_file::error filerr = util::core_file::open(*output_file_str->second, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, output_file); if (filerr != osd_file::error::NONE) report_error(1, "Unable to open file (%s)", output_file_str->second->c_str()); diff --git a/src/tools/imgtool/stream.cpp b/src/tools/imgtool/stream.cpp index d96cf325a7a..b11e7a5e4be 100644 --- a/src/tools/imgtool/stream.cpp +++ b/src/tools/imgtool/stream.cpp @@ -104,24 +104,23 @@ static imgtool_stream *stream_open_zip(const char *zipname, const char *subname, imgfile->imgtype = IMG_MEM; - zip_file::ptr z; - const zip_file::file_header *zipent = nullptr; - zip_file::open(zipname, z); + util::archive_file::ptr z; + util::archive_file::open_zip(zipname, z); if (!z) return nullptr; - zipent = z->first_file(); - while (zipent && subname && strcmp(subname, zipent->filename)) + int zipent = z->first_file(); + while ((zipent >= 0) && subname && strcmp(subname, z->current_name().c_str())) zipent = z->next_file(); - if (!zipent) + if (zipent < 0) return nullptr; - imgfile->filesize = zipent->uncompressed_length; - imgfile->buffer = reinterpret_cast<std::uint8_t *>(malloc(zipent->uncompressed_length)); + imgfile->filesize = z->current_uncompressed_length(); + imgfile->buffer = reinterpret_cast<std::uint8_t *>(malloc(z->current_uncompressed_length())); if (!imgfile->buffer) return nullptr; - if (z->decompress(imgfile->buffer, zipent->uncompressed_length) != zip_file::error::NONE) + if (z->decompress(imgfile->buffer, z->current_uncompressed_length()) != util::archive_file::error::NONE) return nullptr; return imgfile.release(); diff --git a/src/tools/pngcmp.cpp b/src/tools/pngcmp.cpp index aa33a421e5d..e34bcf401e4 100644 --- a/src/tools/pngcmp.cpp +++ b/src/tools/pngcmp.cpp @@ -80,7 +80,7 @@ static int generate_png_diff(const std::string& imgfile1, const std::string& img int x, y; /* open the source image */ - filerr = util::core_file::open(imgfile1.c_str(), OPEN_FLAG_READ, file); + filerr = util::core_file::open(imgfile1, OPEN_FLAG_READ, file); if (filerr != osd_file::error::NONE) { printf("Could not open %s (%d)\n", imgfile1.c_str(), int(filerr)); @@ -97,7 +97,7 @@ static int generate_png_diff(const std::string& imgfile1, const std::string& img } /* open the source image */ - filerr = util::core_file::open(imgfile2.c_str(), OPEN_FLAG_READ, file); + filerr = util::core_file::open(imgfile2, OPEN_FLAG_READ, file); if (filerr != osd_file::error::NONE) { printf("Could not open %s (%d)\n", imgfile2.c_str(), int(filerr)); @@ -170,7 +170,7 @@ static int generate_png_diff(const std::string& imgfile1, const std::string& img } /* write the final PNG */ - filerr = util::core_file::open(outfilename.c_str(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, file); + filerr = util::core_file::open(outfilename, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, file); if (filerr != osd_file::error::NONE) { printf("Could not open %s (%d)\n", outfilename.c_str(), int(filerr)); diff --git a/src/tools/regrep.cpp b/src/tools/regrep.cpp index 4d02151672b..0c6d11093c6 100644 --- a/src/tools/regrep.cpp +++ b/src/tools/regrep.cpp @@ -565,7 +565,7 @@ static util::core_file::ptr create_file_and_output_header(std::string &filename, util::core_file::ptr file; /* create the indexfile */ - if (util::core_file::open(filename.c_str(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS | OPEN_FLAG_NO_BOM, file) != osd_file::error::NONE) + if (util::core_file::open(filename, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS | OPEN_FLAG_NO_BOM, file) != osd_file::error::NONE) return util::core_file::ptr(); /* print a header */ @@ -735,7 +735,7 @@ static int compare_screenshots(summary_file *curfile) fullname = string_format("%s" PATH_SEPARATOR "snap" PATH_SEPARATOR "%s" PATH_SEPARATOR "final.png", lists[listnum].dir, curfile->name); /* open the file */ - filerr = util::core_file::open(fullname.c_str(), OPEN_FLAG_READ, file); + filerr = util::core_file::open(fullname, OPEN_FLAG_READ, file); /* if that failed, look in the old location */ if (filerr != osd_file::error::NONE) @@ -744,7 +744,7 @@ static int compare_screenshots(summary_file *curfile) fullname = string_format("%s" PATH_SEPARATOR "snap" PATH_SEPARATOR "_%s.png", lists[listnum].dir, curfile->name); /* open the file */ - filerr = util::core_file::open(fullname.c_str(), OPEN_FLAG_READ, file); + filerr = util::core_file::open(fullname, OPEN_FLAG_READ, file); } /* if that worked, load the file */ @@ -853,7 +853,7 @@ static int generate_png_diff(const summary_file *curfile, std::string &destdir, tempname = string_format("%s" PATH_SEPARATOR "%s", lists[listnum].dir, srcimgname.c_str()); /* open the source image */ - filerr = util::core_file::open(tempname.c_str(), OPEN_FLAG_READ, file); + filerr = util::core_file::open(tempname, OPEN_FLAG_READ, file); if (filerr != osd_file::error::NONE) goto error; @@ -925,7 +925,7 @@ static int generate_png_diff(const summary_file *curfile, std::string &destdir, } /* write the final PNG */ - filerr = util::core_file::open(dstfilename.c_str(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, file); + filerr = util::core_file::open(dstfilename, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, file); if (filerr != osd_file::error::NONE) goto error; pngerr = png_write_bitmap(*file, nullptr, finalbitmap, 0, nullptr); diff --git a/src/tools/romcmp.cpp b/src/tools/romcmp.cpp index a6919631cd8..641667b6342 100644 --- a/src/tools/romcmp.cpp +++ b/src/tools/romcmp.cpp @@ -490,43 +490,45 @@ static int load_files(int i, int *found, const char *path) /* if not, try to open as a ZIP file */ else { - zip_file::ptr zip; - const zip_file::file_header* zipent; - zip_file::error ziperr; + util::archive_file::ptr zip; /* wasn't a directory, so try to open it as a zip file */ - ziperr = zip_file::open(path, zip); - if (ziperr != zip_file::error::NONE) + if ((util::archive_file::open_zip(path, zip) != util::archive_file::error::NONE) && + (util::archive_file::open_7z(path, zip) != util::archive_file::error::NONE)) { printf("Error, cannot open zip file '%s' !\n", path); return 1; } /* load all files in zip file */ - for (zipent = zip->first_file(); zipent != nullptr; zipent = zip->next_file()) + for (int zipent = zip->first_file(); zipent >= 0; zipent = zip->next_file()) { + if (zip->current_is_directory()) continue; + int size; - size = zipent->uncompressed_length; + size = zip->current_uncompressed_length(); while (size && (size & 1) == 0) size >>= 1; - if (zipent->uncompressed_length == 0) // || (size & ~1)) + if (zip->current_uncompressed_length() == 0) // || (size & ~1)) + { printf("%-23s %-23s ignored (not a ROM)\n", - i ? "" : zipent->filename, i ? zipent->filename : ""); + i ? "" : zip->current_name().c_str(), i ? zip->current_name().c_str() : ""); + } else { fileinfo *file = &files[i][found[i]]; - const char *delim = strrchr(zipent->filename,'/'); + const char *delim = strrchr(zip->current_name().c_str(), '/'); if (delim) strcpy (file->name,delim+1); else - strcpy(file->name,zipent->filename); - file->size = zipent->uncompressed_length; + strcpy(file->name,zip->current_name().c_str()); + file->size = zip->current_uncompressed_length(); if ((file->buf = (unsigned char *)malloc(file->size)) == nullptr) printf("%s: out of memory!\n",file->name); else { - if (zip->decompress(file->buf, file->size) != zip_file::error::NONE) + if (zip->decompress(file->buf, file->size) != util::archive_file::error::NONE) { free(file->buf); file->buf = nullptr; @@ -743,6 +745,6 @@ int CLIB_DECL main(int argc,char *argv[]) } } - zip_file::cache_clear(); + util::archive_file::cache_clear(); return 0; } diff --git a/src/tools/split.cpp b/src/tools/split.cpp index 5151229edd8..586264283d7 100644 --- a/src/tools/split.cpp +++ b/src/tools/split.cpp @@ -119,7 +119,7 @@ static int split_file(const char *filename, const char *basename, UINT32 splitsi splitfilename.assign(basename).append(".split"); // create the split file - filerr = util::core_file::open(splitfilename.c_str(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_NO_BOM, splitfile); + filerr = util::core_file::open(splitfilename, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_NO_BOM, splitfile); if (filerr != osd_file::error::NONE) { fprintf(stderr, "Fatal error: unable to create split file '%s'\n", splitfilename.c_str()); @@ -155,7 +155,7 @@ static int split_file(const char *filename, const char *basename, UINT32 splitsi outfilename = string_format("%s.%03d", basename, partnum); // create it - filerr = util::core_file::open(outfilename.c_str(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, outfile); + filerr = util::core_file::open(outfilename, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, outfile); if (filerr != osd_file::error::NONE) { printf("\n"); @@ -267,7 +267,7 @@ static int join_file(const char *filename, const char *outname, int write_output if (write_output) { // don't overwrite the original! - filerr = util::core_file::open(outfilename.c_str(), OPEN_FLAG_READ, outfile); + filerr = util::core_file::open(outfilename, OPEN_FLAG_READ, outfile); if (filerr == osd_file::error::NONE) { outfile.reset(); @@ -276,7 +276,7 @@ static int join_file(const char *filename, const char *outname, int write_output } // open the output for write - filerr = util::core_file::open(outfilename.c_str(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, outfile); + filerr = util::core_file::open(outfilename, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, outfile); if (filerr != osd_file::error::NONE) { fprintf(stderr, "Fatal error: unable to create file '%s'\n", outfilename.c_str()); diff --git a/src/tools/src2html.cpp b/src/tools/src2html.cpp index 9b3110a212f..38260a62879 100644 --- a/src/tools/src2html.cpp +++ b/src/tools/src2html.cpp @@ -517,7 +517,7 @@ static int output_file(file_type type, int srcrootlen, int dstrootlen, std::stri // open the source file util::core_file::ptr src; - if (util::core_file::open(srcfile.c_str(), OPEN_FLAG_READ, src) != osd_file::error::NONE) + if (util::core_file::open(srcfile, OPEN_FLAG_READ, src) != osd_file::error::NONE) { fprintf(stderr, "Unable to read file '%s'\n", srcfile.c_str()); return 1; @@ -732,7 +732,7 @@ static util::core_file::ptr create_file_and_output_header(std::string &filename, { // create the indexfile util::core_file::ptr file; - if (util::core_file::open(filename.c_str(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS | OPEN_FLAG_NO_BOM, file) != osd_file::error::NONE) + if (util::core_file::open(filename, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS | OPEN_FLAG_NO_BOM, file) != osd_file::error::NONE) return util::core_file::ptr(); // print a header @@ -865,7 +865,7 @@ static bool find_include_file(std::string &srcincpath, int srcrootlen, int dstro // see if we can open it util::core_file::ptr testfile; - if (util::core_file::open(srcincpath.c_str(), OPEN_FLAG_READ, testfile) == osd_file::error::NONE) + if (util::core_file::open(srcincpath, OPEN_FLAG_READ, testfile) == osd_file::error::NONE) { // close the file testfile.reset(); |