From 519be73d61aa63adbeebf5b7dba36230f4e24c25 Mon Sep 17 00:00:00 2001 From: Justin Kerk Date: Sat, 31 Jan 2015 12:40:43 -0800 Subject: [PATCH 01/14] Remove duplicate and unused code (compare src/lib/util/cstrpool.c) (nw) --- src/emu/softlist.c | 92 ---------------------------------------------- 1 file changed, 92 deletions(-) diff --git a/src/emu/softlist.c b/src/emu/softlist.c index ef9b179a180..9ef5f0cba65 100644 --- a/src/emu/softlist.c +++ b/src/emu/softlist.c @@ -264,98 +264,6 @@ bool software_info::has_multiple_parts(const char *interface) const -//************************************************************************** -// CONST STRING POOL -//************************************************************************** - -//------------------------------------------------- -// const_string_pool - constructor -//------------------------------------------------- - -const_string_pool::const_string_pool() -{ -} - - -//------------------------------------------------- -// add - add a string to the string pool -//------------------------------------------------- - -const char *const_string_pool::add(const char *string) -{ - // if NULL or a small number (for some hash strings), just return as-is - if (FPTR(string) < 0x100) - return string; - - // scan to find space - for (pool_chunk *chunk = m_chunklist.first(); chunk != NULL; chunk = chunk->next()) - { - const char *result = chunk->add(string); - if (result != NULL) - return result; - } - - // no space anywhere, create a new pool and prepend it (so it gets used first) - const char *result = m_chunklist.prepend(*global_alloc(pool_chunk)).add(string); - assert(result != NULL); - return result; -} - - -//------------------------------------------------- -// contains - determine if the given string -// pointer lives in the pool -//------------------------------------------------- - -bool const_string_pool::contains(const char *string) -{ - // if NULL or a small number (for some hash strings), then yes, effectively - if (FPTR(string) < 0x100) - return true; - - // scan to find it - for (pool_chunk *chunk = m_chunklist.first(); chunk != NULL; chunk = chunk->next()) - if (chunk->contains(string)) - return true; - - return false; -} - - -//------------------------------------------------- -// pool_chunk - constructor -//------------------------------------------------- - -const_string_pool::pool_chunk::pool_chunk() - : m_next(NULL), - m_used(0) -{ -} - - -//------------------------------------------------- -// add - add a string to this pool -//------------------------------------------------- - -const char *const_string_pool::pool_chunk::add(const char *string) -{ - // get the length of the string (no string can be longer than a full pool) - int bytes = strlen(string) + 1; - assert(bytes < POOL_SIZE); - - // if too big, return NULL - if (m_used + bytes > POOL_SIZE) - return NULL; - - // allocate, copy, and return the memory - char *dest = &m_buffer[m_used]; - m_used += bytes; - memcpy(dest, string, bytes); - return dest; -} - - - //************************************************************************** // SOFTWARE LIST DEVICE //************************************************************************** From 509e4d02da3aeac3514253216c1b25658d581b6d Mon Sep 17 00:00:00 2001 From: Justin Kerk Date: Sat, 31 Jan 2015 12:46:19 -0800 Subject: [PATCH 02/14] Fix compile with NO_USE_MIDI (nw) --- src/osd/modules/midi/portmidi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/osd/modules/midi/portmidi.c b/src/osd/modules/midi/portmidi.c index 66f5eed0273..ef5ea1dd99a 100644 --- a/src/osd/modules/midi/portmidi.c +++ b/src/osd/modules/midi/portmidi.c @@ -452,7 +452,7 @@ void osd_midi_device_pm::write(UINT8 data) } #else #include "modules/osdmodule.h" - #include "netdev_module.h" + #include "midi_module.h" MODULE_NOT_SUPPORTED(pm_module, OSD_MIDI_PROVIDER, "pm") #endif From 02d7e0e289cf1d42e17628fabbb4ac92bb2eca86 Mon Sep 17 00:00:00 2001 From: hap Date: Sat, 31 Jan 2015 22:42:01 +0100 Subject: [PATCH 03/14] s2000 fix a couple of bugs --- src/emu/cpu/amis2000/amis2000.c | 25 ++++----- src/emu/cpu/amis2000/amis2000.h | 2 +- src/emu/cpu/amis2000/amis2000op.inc | 85 +++++++++++++++++------------ src/mess/drivers/wildfire.c | 19 ++++++- 4 files changed, 79 insertions(+), 52 deletions(-) diff --git a/src/emu/cpu/amis2000/amis2000.c b/src/emu/cpu/amis2000/amis2000.c index 5afe974f681..d6c4967d0dc 100644 --- a/src/emu/cpu/amis2000/amis2000.c +++ b/src/emu/cpu/amis2000/amis2000.c @@ -5,6 +5,7 @@ American Microsystems, Inc.(AMI) S2000-family 4-bit MCU cores, introduced late 1970s TODO: + - bug(s)? - MESS wildfire.c doesn't work yet - unemulated opcodes (need more testing material) - support external program map - add 50/60hz timer @@ -25,12 +26,12 @@ const device_type AMI_S2150 = &device_creator; // internal memory maps static ADDRESS_MAP_START(program_1k, AS_PROGRAM, 8, amis2000_device) - AM_RANGE(0x0000, 0x03ff) AM_ROM AM_MIRROR(0x1c00) + AM_RANGE(0x0000, 0x03ff) AM_ROM ADDRESS_MAP_END static ADDRESS_MAP_START(program_1_5k, AS_PROGRAM, 8, amis2000_device) - AM_RANGE(0x0000, 0x03ff) AM_ROM AM_MIRROR(0x1800) - AM_RANGE(0x0400, 0x05ff) AM_ROM AM_MIRROR(0x1a00) + AM_RANGE(0x0000, 0x03ff) AM_ROM + AM_RANGE(0x0400, 0x05ff) AM_ROM AM_MIRROR(0x200) ADDRESS_MAP_END @@ -116,7 +117,7 @@ offs_t amis2000_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 enum { S2000_PC=1, S2000_BL, S2000_BU, - S2000_ACC, S2000_E, S2000_CARRY + S2000_ACC, S2000_E, S2000_CY }; void amis2000_device::device_start() @@ -138,9 +139,9 @@ void amis2000_device::device_start() m_pc = 0; m_ppr = 0; m_pbr = 0; - m_pp_index = 0; m_skip = false; m_op = 0; + m_prev_op = 0; m_f = 0; m_carry = 0; m_bl = 0; @@ -157,9 +158,9 @@ void amis2000_device::device_start() save_item(NAME(m_pc)); save_item(NAME(m_ppr)); save_item(NAME(m_pbr)); - save_item(NAME(m_pp_index)); save_item(NAME(m_skip)); save_item(NAME(m_op)); + save_item(NAME(m_prev_op)); save_item(NAME(m_f)); save_item(NAME(m_carry)); save_item(NAME(m_bl)); @@ -177,7 +178,7 @@ void amis2000_device::device_start() state_add(S2000_BU, "BU", m_bu ).formatstr("%01X"); state_add(S2000_ACC, "ACC", m_acc ).formatstr("%01X"); state_add(S2000_E, "E", m_e ).formatstr("%01X"); - state_add(S2000_CARRY, "CARRY", m_carry ).formatstr("%01X"); + state_add(S2000_CY, "CY", m_carry ).formatstr("%01X"); state_add(STATE_GENPC, "curpc", m_pc).formatstr("%04X").noshow(); state_add(STATE_GENFLAGS, "GENFLAGS", m_f).formatstr("%6s").noshow(); @@ -218,14 +219,8 @@ void amis2000_device::execute_run() { m_icount--; - // increase PP prefix count - if ((m_op & 0xf0) == 0x60) - { - if (m_pp_index < 2) - m_pp_index++; - } - else - m_pp_index = 0; + // remember previous opcode + m_prev_op = m_op; debugger_instruction_hook(this, m_pc); m_op = m_program->read_byte(m_pc); diff --git a/src/emu/cpu/amis2000/amis2000.h b/src/emu/cpu/amis2000/amis2000.h index 966a85cd524..d8960bfd062 100644 --- a/src/emu/cpu/amis2000/amis2000.h +++ b/src/emu/cpu/amis2000/amis2000.h @@ -80,9 +80,9 @@ protected: UINT16 m_pc; // 13-bit program counter UINT8 m_ppr; // prepared page register (PP 1) UINT8 m_pbr; // prepared bank register (PP 2) - UINT8 m_pp_index; // number of handled PP prefixes bool m_skip; // skip next opcode, including PP prefixes UINT8 m_op; + UINT8 m_prev_op; // previous opcode, needed for PP, LAI, LB* UINT8 m_f; // generic flags: 2 on 2000/2150, 6 on 2200/2400 UINT8 m_carry; // carry flag UINT8 m_bl; // 4-bit ram index x diff --git a/src/emu/cpu/amis2000/amis2000op.inc b/src/emu/cpu/amis2000/amis2000op.inc index 97fa6b6db82..5a188a3f336 100644 --- a/src/emu/cpu/amis2000/amis2000op.inc +++ b/src/emu/cpu/amis2000/amis2000op.inc @@ -4,13 +4,13 @@ UINT8 amis2000_device::ram_r() { - UINT16 address = m_bu << m_bu_bits | m_bl; + UINT16 address = m_bu << 4 | m_bl; return m_data->read_byte(address) & 0xf; } void amis2000_device::ram_w(UINT8 data) { - UINT16 address = m_bu << m_bu_bits | m_bl; + UINT16 address = m_bu << 4 | m_bl; m_data->write_byte(address, data & 0xf); } @@ -44,10 +44,14 @@ void amis2000_device::op_illegal() void amis2000_device::op_lai() { // LAI X: load ACC with X, select I and K inputs - UINT8 param = m_op & 0x0f; - m_acc = param; - m_i = m_read_i(0, 0xff) & param; - m_k = m_read_k(0, 0xff) & param; + // note: only execute the first one in a sequence of LAI + if ((m_prev_op & 0xf0) != (m_op & 0xf0)) + { + UINT8 param = m_op & 0x0f; + m_acc = param; + m_i = m_read_i(0, 0xff) & param; + m_k = m_read_k(0, 0xff) & param; + } } void amis2000_device::op_lab() @@ -89,33 +93,49 @@ void amis2000_device::op_xae() void amis2000_device::op_lbe() { // LBE Y: load BU with Y, load BL with E - UINT8 param = m_op & 0x03; - m_bu = param & m_bu_mask; - m_bl = m_e; + // note: only execute the first one in a sequence of LB* + if ((m_prev_op & 0xf0) != (m_op & 0xf0)) + { + UINT8 param = m_op & 0x03; + m_bu = param & m_bu_mask; + m_bl = m_e; + } } void amis2000_device::op_lbep() { // LBEP Y: load BU with Y, load BL with E+1 - UINT8 param = m_op & 0x03; - m_bu = param & m_bu_mask; - m_bl = m_e + 1; + // note: only execute the first one in a sequence of LB* + if ((m_prev_op & 0xf0) != (m_op & 0xf0)) + { + UINT8 param = m_op & 0x03; + m_bu = param & m_bu_mask; + m_bl = m_e + 1; + } } void amis2000_device::op_lbz() { // LBZ Y: load BU with Y, load BL with 0 - UINT8 param = m_op & 0x03; - m_bu = param & m_bu_mask; - m_bl = 0; + // note: only execute the first one in a sequence of LB* + if ((m_prev_op & 0xf0) != (m_op & 0xf0)) + { + UINT8 param = m_op & 0x03; + m_bu = param & m_bu_mask; + m_bl = 0; + } } void amis2000_device::op_lbf() { // LBF Y: load BU with Y, load BL with 15 - UINT8 param = m_op & 0x03; - m_bu = param & m_bu_mask; - m_bl = 0xf; + // note: only execute the first one in a sequence of LB* + if ((m_prev_op & 0xf0) != (m_op & 0xf0)) + { + UINT8 param = m_op & 0x03; + m_bu = param & m_bu_mask; + m_bl = 0xf; + } } @@ -279,7 +299,7 @@ void amis2000_device::op_pp() { // PP _X: prepare page/bank with _X UINT8 param = ~m_op & 0x0f; - if (m_pp_index == 0) + if ((m_prev_op & 0xf0) != (m_op & 0xf0)) m_ppr = param; else m_pbr = param & 7; @@ -290,15 +310,12 @@ void amis2000_device::op_jmp() // JMP X: jump to X(+PP) UINT16 mask = 0x3f; UINT16 param = m_op & mask; - if (m_pp_index > 0) + + // if previous opcode was PP, change PC high bits too + if ((m_prev_op & 0xf0) == 0x60) { - param |= m_ppr << 6; - mask |= 0x3c0; - } - if (m_pp_index > 1) - { - param |= m_pbr << 10; - mask |= 0x1c00; + param |= (m_ppr << 6) | (m_pbr << 10); + mask = 0x1fff; } m_pc = (m_pc & ~mask) | param; } @@ -308,13 +325,11 @@ void amis2000_device::op_jms() // JMS X: call to X(+PP) m_icount--; push_callstack(); - if (m_pp_index == 0) - { - // subroutines default location is page 15 - m_ppr = 0xf; - m_pp_index++; - } op_jmp(); + + // subroutines default location is page 15 + if ((m_prev_op & 0xf0) != 0x60) + m_pc |= 0x3c0; } void amis2000_device::op_rt() @@ -384,13 +399,13 @@ void amis2000_device::op_sos() void amis2000_device::op_tf1() { // TF1: skip next on flag 1 - m_skip = (m_f & 0x01); + m_skip = (m_f & 0x01) ? true : false; } void amis2000_device::op_tf2() { // TF2: skip next on flag 2 - m_skip = (m_f & 0x02); + m_skip = (m_f & 0x02) ? true : false; } diff --git a/src/mess/drivers/wildfire.c b/src/mess/drivers/wildfire.c index c4dce72cc1a..39db9be728f 100644 --- a/src/mess/drivers/wildfire.c +++ b/src/mess/drivers/wildfire.c @@ -31,6 +31,9 @@ public: required_device m_maincpu; required_device m_speaker; + DECLARE_WRITE8_MEMBER(write_d); + DECLARE_WRITE16_MEMBER(write_a); + virtual void machine_start(); }; @@ -41,7 +44,13 @@ public: ***************************************************************************/ -//.. +WRITE8_MEMBER(wildfire_state::write_d) +{ +} + +WRITE16_MEMBER(wildfire_state::write_a) +{ +} @@ -52,6 +61,11 @@ public: ***************************************************************************/ static INPUT_PORTS_START( wildfire ) + PORT_START("IN1") // I + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("Shooter Button") + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("Left Flipper") + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("Right Flipper") + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED ) INPUT_PORTS_END @@ -71,6 +85,9 @@ static MACHINE_CONFIG_START( wildfire, wildfire_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", AMI_S2150, MASTER_CLOCK) + MCFG_AMI_S2000_READ_I_CB(IOPORT("IN1")) + MCFG_AMI_S2000_WRITE_D_CB(WRITE8(wildfire_state, write_d)) + MCFG_AMI_S2000_WRITE_A_CB(WRITE16(wildfire_state, write_a)) MCFG_DEFAULT_LAYOUT(layout_wildfire) From f47544a1b7b444b7abd05254b1d219f86ec1fb21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sat, 31 Jan 2015 23:34:21 +0100 Subject: [PATCH 04/14] vconv: disabled C4826 again (nw) --- src/osd/windows/vconv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/osd/windows/vconv.c b/src/osd/windows/vconv.c index e8bc4626c41..05041037400 100644 --- a/src/osd/windows/vconv.c +++ b/src/osd/windows/vconv.c @@ -103,7 +103,8 @@ static const translation_info gcc_translate[] = // warning C4711: function 'xxx' selected for automatic inline expansion // optimized only // warning C4805: 'x' : unsafe mix of type 'xxx' and type 'xxx' in operation // warning C4820: 'xxx' : 'x' bytes padding added after data member 'xxx' - { VS7, "-Wall", "/Wall /W4 /wd4003 /wd4018 /wd4061 /wd4100 /wd4127 /wd4131 /wd4141 /wd4146 /wd4150 /wd4189 /wd4201 /wd4242 /wd4244 /wd4250 /wd4255 /wd4296 /wd4310 /wd4324 /wd4347 /wd4435 /wd4510 /wd4512 /wd4514 /wd4571 /wd4610 /wd4619 /wd4625 /wd4626 /wd4668 /wd4702 /wd4706 /wd4710 /wd4711 /wd4805 /wd4820" }, + // warning C4826: Conversion from 'type1 ' to 'type_2' is sign-extended. This may cause unexpected runtime behavior. // 32-bit only + { VS7, "-Wall", "/Wall /W4 /wd4003 /wd4018 /wd4061 /wd4100 /wd4127 /wd4131 /wd4141 /wd4146 /wd4150 /wd4189 /wd4201 /wd4242 /wd4244 /wd4250 /wd4255 /wd4296 /wd4310 /wd4324 /wd4347 /wd4435 /wd4510 /wd4512 /wd4514 /wd4571 /wd4610 /wd4619 /wd4625 /wd4626 /wd4668 /wd4702 /wd4706 /wd4710 /wd4711 /wd4805 /wd4820 /wd4826" }, { 0, "-Wall", "/W0" }, { VS7, "-Wno-unused", "/wd4100 /wd4101 /wd4102 /wd4505" }, { 0, "-Wno-sign-compare", "/wd4365 /wd4389 /wd4245 /wd4388" }, From 22b90a3374a5bd6ad17341e463bbc4463fc0e326 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sat, 31 Jan 2015 23:36:03 +0100 Subject: [PATCH 05/14] Revert "fix compile on MSVC 2012 (nw)" This reverts commit 9afc7cdb5b57f6b15125d4d207baa7c61ee50287. --- 3rdparty/sqlite3/sqlite3.h | 9 +-------- src/emu/cpu/drcbex64.h | 4 ++-- src/emu/cpu/drcbex86.h | 4 ++-- src/emu/cpu/uml.h | 10 +++++----- src/emu/ui/inputmap.c | 2 +- src/emu/ui/mainmenu.c | 2 +- src/lib/util/bitmap.c | 2 +- src/osd/windows/winprefix.h | 1 - 8 files changed, 13 insertions(+), 21 deletions(-) diff --git a/3rdparty/sqlite3/sqlite3.h b/3rdparty/sqlite3/sqlite3.h index 352f4909fbc..c31f126dbbe 100644 --- a/3rdparty/sqlite3/sqlite3.h +++ b/3rdparty/sqlite3/sqlite3.h @@ -256,13 +256,6 @@ typedef struct sqlite3 sqlite3; typedef sqlite_int64 sqlite3_int64; typedef sqlite_uint64 sqlite3_uint64; -/* pointer-sized values */ -#ifdef PTR64 -typedef sqlite3_uint64 FPTR; -#else -typedef unsigned int FPTR; -#endif - /* ** If compiling for a processor that lacks floating point support, ** substitute integer for floating-point. @@ -4389,7 +4382,7 @@ SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(voi */ typedef void (*sqlite3_destructor_type)(void*); #define SQLITE_STATIC ((sqlite3_destructor_type)0) -#define SQLITE_TRANSIENT ((sqlite3_destructor_type)(FPTR)-1) +#define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1) /* ** CAPI3REF: Setting The Result Of An SQL Function diff --git a/src/emu/cpu/drcbex64.h b/src/emu/cpu/drcbex64.h index dcd5505fe5b..6b6cf729b64 100644 --- a/src/emu/cpu/drcbex64.h +++ b/src/emu/cpu/drcbex64.h @@ -73,8 +73,8 @@ private: static inline be_parameter make_ireg(int regnum) { assert(regnum >= 0 && regnum < x64emit::REG_MAX); return be_parameter(PTYPE_INT_REGISTER, regnum); } static inline be_parameter make_freg(int regnum) { assert(regnum >= 0 && regnum < x64emit::REG_MAX); return be_parameter(PTYPE_FLOAT_REGISTER, regnum); } static inline be_parameter make_vreg(int regnum) { assert(regnum >= 0 && regnum < x64emit::REG_MAX); return be_parameter(PTYPE_VECTOR_REGISTER, regnum); } - static inline be_parameter make_memory(void *base) { return be_parameter(PTYPE_MEMORY, static_cast(reinterpret_cast(base))); } - static inline be_parameter make_memory(const void *base) { return be_parameter(PTYPE_MEMORY, static_cast(reinterpret_cast(const_cast(base)))); } + static inline be_parameter make_memory(void *base) { return be_parameter(PTYPE_MEMORY, reinterpret_cast(base)); } + static inline be_parameter make_memory(const void *base) { return be_parameter(PTYPE_MEMORY, reinterpret_cast(const_cast(base))); } // operators bool operator==(const be_parameter &rhs) const { return (m_type == rhs.m_type && m_value == rhs.m_value); } diff --git a/src/emu/cpu/drcbex86.h b/src/emu/cpu/drcbex86.h index 1e3910f4084..3c3af63d0d0 100644 --- a/src/emu/cpu/drcbex86.h +++ b/src/emu/cpu/drcbex86.h @@ -73,8 +73,8 @@ private: static inline be_parameter make_ireg(int regnum) { assert(regnum >= 0 && regnum < x86emit::REG_MAX); return be_parameter(PTYPE_INT_REGISTER, regnum); } static inline be_parameter make_freg(int regnum) { assert(regnum >= 0 && regnum < x86emit::REG_MAX); return be_parameter(PTYPE_FLOAT_REGISTER, regnum); } static inline be_parameter make_vreg(int regnum) { assert(regnum >= 0 && regnum < x86emit::REG_MAX); return be_parameter(PTYPE_VECTOR_REGISTER, regnum); } - static inline be_parameter make_memory(void *base) { return be_parameter(PTYPE_MEMORY, static_cast(reinterpret_cast(base))); } - static inline be_parameter make_memory(const void *base) { return be_parameter(PTYPE_MEMORY, static_cast(reinterpret_cast(const_cast(base)))); } + static inline be_parameter make_memory(void *base) { return be_parameter(PTYPE_MEMORY, reinterpret_cast(base)); } + static inline be_parameter make_memory(const void *base) { return be_parameter(PTYPE_MEMORY, reinterpret_cast(const_cast(base))); } // operators bool operator==(const be_parameter &rhs) const { return (m_type == rhs.m_type && m_value == rhs.m_value); } diff --git a/src/emu/cpu/uml.h b/src/emu/cpu/uml.h index db1ed62f83a..53eacfa49d9 100644 --- a/src/emu/cpu/uml.h +++ b/src/emu/cpu/uml.h @@ -305,7 +305,7 @@ namespace uml parameter(UINT64 val) : m_type(PTYPE_IMMEDIATE), m_value(val) { } parameter(operand_size size, memory_scale scale) : m_type(PTYPE_SIZE_SCALE), m_value((scale << 4) | size) { assert(size >= SIZE_BYTE && size <= SIZE_DQWORD); assert(scale >= SCALE_x1 && scale <= SCALE_x8); } parameter(operand_size size, memory_space space) : m_type(PTYPE_SIZE_SPACE), m_value((space << 4) | size) { assert(size >= SIZE_BYTE && size <= SIZE_DQWORD); assert(space >= SPACE_PROGRAM && space <= SPACE_IO); } - parameter(code_handle &handle) : m_type(PTYPE_CODE_HANDLE), m_value(static_cast(reinterpret_cast(&handle))) { } + parameter(code_handle &handle) : m_type(PTYPE_CODE_HANDLE), m_value(reinterpret_cast(&handle)) { } parameter(code_label &label) : m_type(PTYPE_CODE_LABEL), m_value(label) { } // creators for types that don't safely default @@ -313,11 +313,11 @@ namespace uml static inline parameter make_freg(int regnum) { assert(regnum >= REG_F0 && regnum < REG_F_END); return parameter(PTYPE_FLOAT_REGISTER, regnum); } static inline parameter make_vreg(int regnum) { assert(regnum >= REG_V0 && regnum < REG_V_END); return parameter(PTYPE_VECTOR_REGISTER, regnum); } static inline parameter make_mapvar(int mvnum) { assert(mvnum >= MAPVAR_M0 && mvnum < MAPVAR_END); return parameter(PTYPE_MAPVAR, mvnum); } - static inline parameter make_memory(void *base) { return parameter(PTYPE_MEMORY, static_cast(reinterpret_cast(base))); } - static inline parameter make_memory(const void *base) { return parameter(PTYPE_MEMORY, static_cast(reinterpret_cast(const_cast(base)))); } + static inline parameter make_memory(void *base) { return parameter(PTYPE_MEMORY, reinterpret_cast(base)); } + static inline parameter make_memory(const void *base) { return parameter(PTYPE_MEMORY, reinterpret_cast(const_cast(base))); } static inline parameter make_size(operand_size size) { assert(size >= SIZE_BYTE && size <= SIZE_DQWORD); return parameter(PTYPE_SIZE, size); } - static inline parameter make_string(const char *string) { return parameter(PTYPE_STRING, static_cast(reinterpret_cast(const_cast(string)))); } - static inline parameter make_cfunc(c_function func) { return parameter(PTYPE_C_FUNCTION, static_cast(reinterpret_cast(func))); } + static inline parameter make_string(const char *string) { return parameter(PTYPE_STRING, reinterpret_cast(const_cast(string))); } + static inline parameter make_cfunc(c_function func) { return parameter(PTYPE_C_FUNCTION, reinterpret_cast(func)); } static inline parameter make_rounding(float_rounding_mode mode) { assert(mode >= ROUND_TRUNC && mode <= ROUND_DEFAULT); return parameter(PTYPE_ROUNDING, mode); } // operators diff --git a/src/emu/ui/inputmap.c b/src/emu/ui/inputmap.c index 472bd7cb15b..4150bfc9649 100644 --- a/src/emu/ui/inputmap.c +++ b/src/emu/ui/inputmap.c @@ -73,7 +73,7 @@ void ui_menu_input_groups::handle() /* process the menu */ const ui_menu_event *menu_event = process(0); if (menu_event != NULL && menu_event->iptkey == IPT_UI_SELECT) - ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_input_general(machine(), container, int((long long)((FPTR)menu_event->itemref)-1)))); + ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_input_general(machine(), container, int((long long)(menu_event->itemref)-1)))); } diff --git a/src/emu/ui/mainmenu.c b/src/emu/ui/mainmenu.c index 0110c3754f9..9809833a506 100644 --- a/src/emu/ui/mainmenu.c +++ b/src/emu/ui/mainmenu.c @@ -151,7 +151,7 @@ void ui_menu_main::handle() /* process the menu */ const ui_menu_event *menu_event = process(0); if (menu_event != NULL && menu_event->iptkey == IPT_UI_SELECT) { - switch((long long)((FPTR) menu_event->itemref)) { + switch((long long)(menu_event->itemref)) { case INPUT_GROUPS: ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_input_groups(machine(), container))); break; diff --git a/src/lib/util/bitmap.c b/src/lib/util/bitmap.c index 170e2dd98b7..4d1f8502f50 100644 --- a/src/lib/util/bitmap.c +++ b/src/lib/util/bitmap.c @@ -49,7 +49,7 @@ inline INT32 bitmap_t::compute_rowpixels(int width, int xslop) inline void bitmap_t::compute_base(int xslop, int yslop) { m_base = m_alloc + (m_rowpixels * yslop + xslop) * (m_bpp / 8); - UINT64 aligned_base = ((static_cast(reinterpret_cast(m_base)) + (BITMAP_OVERALL_ALIGN - 1)) / BITMAP_OVERALL_ALIGN) * BITMAP_OVERALL_ALIGN; + UINT64 aligned_base = ((reinterpret_cast(m_base) + (BITMAP_OVERALL_ALIGN - 1)) / BITMAP_OVERALL_ALIGN) * BITMAP_OVERALL_ALIGN; m_base = reinterpret_cast(aligned_base); } diff --git a/src/osd/windows/winprefix.h b/src/osd/windows/winprefix.h index 1f26a2104a2..2635685eff1 100644 --- a/src/osd/windows/winprefix.h +++ b/src/osd/windows/winprefix.h @@ -31,7 +31,6 @@ #pragma warning (disable: 5025 5026 5027) #define _CRT_STDIO_LEGACY_WIDE_SPECIFIERS #endif -#define strtoll _strtoi64 #endif #ifdef __GNUC__ From 78bacb07c2f07359c2fb6d81d3e889a1efdd0e14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sat, 31 Jan 2015 23:42:53 +0100 Subject: [PATCH 06/14] restored winprefix.h change by Peter Ferrie (nw) also moved some code around and only defined strtoll when it is actually necessary --- src/osd/windows/winprefix.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/osd/windows/winprefix.h b/src/osd/windows/winprefix.h index 2635685eff1..979a11d9386 100644 --- a/src/osd/windows/winprefix.h +++ b/src/osd/windows/winprefix.h @@ -20,6 +20,14 @@ #if _MSC_VER < 1500 #define vsnprintf _vsnprintf #endif +#if _MSC_VER < 1800 +#define _USE_MATH_DEFINES +#include +static __inline double fmin(double x, double y){ return (x < y) ? x : y; } +static __inline double fmax(double x, double y){ return (x > y) ? x : y; } +static __inline double log2(double x) { return log(x) * M_LOG2E; } +#define strtoll _strtoi64 +#endif #if _MSC_VER < 1900 #define snprintf _snprintf #else @@ -40,14 +48,5 @@ #define min(x,y) fmin(x,y) #define max(x,y) fmax(x,y) #endif -#ifdef _MSC_VER -#if _MSC_VER < 1800 -#define _USE_MATH_DEFINES -#include -static __inline double fmin(double x, double y){ return (x < y) ? x : y; } -static __inline double fmax(double x, double y){ return (x > y) ? x : y; } -static __inline double log2(double x) { return log(x) * M_LOG2E; } -#endif -#endif #define PATH_SEPARATOR "\\" From 6b75e786a3693138e8c49f61b28e0730c2231b0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sat, 31 Jan 2015 23:54:38 +0100 Subject: [PATCH 07/14] some winprefix.h cleanups (nw) --- src/osd/windows/winprefix.h | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/osd/windows/winprefix.h b/src/osd/windows/winprefix.h index 979a11d9386..411e327a9d4 100644 --- a/src/osd/windows/winprefix.h +++ b/src/osd/windows/winprefix.h @@ -13,22 +13,18 @@ #ifdef _MSC_VER #include #include -#if _MSC_VER < 1800 +#if _MSC_VER < 1500 // < VS2008 +#define vsnprintf _vsnprintf +#elif _MSC_VER < 1800 // < VS2013 #define alloca _alloca #define round(x) floor((x) + 0.5) -#endif -#if _MSC_VER < 1500 -#define vsnprintf _vsnprintf -#endif -#if _MSC_VER < 1800 +#define strtoll _strtoi64 #define _USE_MATH_DEFINES #include static __inline double fmin(double x, double y){ return (x < y) ? x : y; } static __inline double fmax(double x, double y){ return (x > y) ? x : y; } static __inline double log2(double x) { return log(x) * M_LOG2E; } -#define strtoll _strtoi64 -#endif -#if _MSC_VER < 1900 +#elif _MSC_VER < 1900 // < VS2015 #define snprintf _snprintf #else #pragma warning (disable: 4091) From 4a18ab8682c722bca364de67787bd471d04d6d72 Mon Sep 17 00:00:00 2001 From: hap Date: Sun, 1 Feb 2015 00:40:32 +0100 Subject: [PATCH 08/14] bugfix --- src/emu/cpu/amis2000/amis2000op.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/emu/cpu/amis2000/amis2000op.inc b/src/emu/cpu/amis2000/amis2000op.inc index 5a188a3f336..504fc174379 100644 --- a/src/emu/cpu/amis2000/amis2000op.inc +++ b/src/emu/cpu/amis2000/amis2000op.inc @@ -110,7 +110,7 @@ void amis2000_device::op_lbep() { UINT8 param = m_op & 0x03; m_bu = param & m_bu_mask; - m_bl = m_e + 1; + m_bl = (m_e + 1) & 0xf; } } @@ -146,7 +146,7 @@ void amis2000_device::op_lam() // LAM _Y: load ACC with RAM, xor BU with _Y m_acc = ram_r(); UINT8 param = ~m_op & 0x03; - m_bu ^= param & m_bu_mask; + m_bu ^= (param & m_bu_mask); } void amis2000_device::op_xc() @@ -156,7 +156,7 @@ void amis2000_device::op_xc() m_acc = ram_r(); ram_w(old_acc); UINT8 param = ~m_op & 0x03; - m_bu ^= param & m_bu_mask; + m_bu ^= (param & m_bu_mask); } void amis2000_device::op_xci() From 0d5783fd8562e1b2c5f797f0453a3ae3783b0349 Mon Sep 17 00:00:00 2001 From: arbee Date: Sat, 31 Jan 2015 22:26:30 -0500 Subject: [PATCH 09/14] apple2: properly handle ProDOS-order Microsoft CP/M boot disk [R. Belmont] --- src/lib/formats/ap2_dsk.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib/formats/ap2_dsk.c b/src/lib/formats/ap2_dsk.c index 056fe05aebc..5e66b601e42 100644 --- a/src/lib/formats/ap2_dsk.c +++ b/src/lib/formats/ap2_dsk.c @@ -615,6 +615,7 @@ bool a2_16sect_format::load(io_generic *io, UINT32 form_factor, floppy_image *im static const unsigned char dos33_block1[4] = { 0xa2, 0x02, 0x8e, 0x52 }; static const unsigned char sos_block1[4] = { 0xc9, 0x20, 0xf0, 0x3e }; static const unsigned char a3a2emul_block1[6] = { 0x8d, 0xd0, 0x03, 0x4c, 0xc7, 0xa4 }; + static const unsigned char cpm22_block1[8] = { 0xa2, 0x55, 0xa9, 0x00, 0x9d, 0x00, 0x0d, 0xca }; io_generic_read(io, sector_data, fpos, 256*16); @@ -656,6 +657,10 @@ bool a2_16sect_format::load(io_generic *io, UINT32 form_factor, floppy_image *im m_prodos_order = true; } // check for a later version of the Pascal boot block else if (!memcmp(pascal2_block1, §or_data[0x100], 4)) + { + m_prodos_order = true; + } // check for CP/M disks in ProDOS order + else if (!memcmp(cpm22_block1, §or_data[0x100], 8)) { m_prodos_order = true; } From 5dab7eb95c2177958e0543ab7c08db26c1d4bda7 Mon Sep 17 00:00:00 2001 From: arbee Date: Sat, 31 Jan 2015 22:28:22 -0500 Subject: [PATCH 10/14] (MESS) apple2 updates: [R. Belmont] - Provide centralized DMA mechanism for slot cards - Fixed 0.156 regressions for Z80 SoftCard, The Mill 6809, and Mountain Computer Music System - Provide debugger protection for slot-based foreign CPUs executing from Apple II DMA --- src/emu/bus/a2bus/a2bus.c | 25 ++++++ src/emu/bus/a2bus/a2bus.h | 22 +++++- src/emu/bus/a2bus/a2mcms.c | 6 +- src/emu/bus/a2bus/a2mcms.h | 6 +- src/emu/bus/a2bus/a2softcard.c | 38 ++++----- src/emu/bus/a2bus/a2softcard.h | 1 - src/emu/bus/a2bus/a2themill.c | 139 +++++++++++++++------------------ src/emu/bus/a2bus/a2themill.h | 1 - 8 files changed, 130 insertions(+), 108 deletions(-) diff --git a/src/emu/bus/a2bus/a2bus.c b/src/emu/bus/a2bus/a2bus.c index 61739a0cd41..cd2eab4eea7 100644 --- a/src/emu/bus/a2bus/a2bus.c +++ b/src/emu/bus/a2bus/a2bus.c @@ -160,6 +160,7 @@ a2bus_device::a2bus_device(const machine_config &mconfig, device_type type, cons void a2bus_device::device_start() { m_maincpu = machine().device(m_cputag); + m_maincpu_space = &machine().device(m_cputag)->space(AS_PROGRAM); // resolve callbacks m_out_irq_cb.resolve_safe(); @@ -246,6 +247,30 @@ void a2bus_device::set_maincpu_halt(int state) m_maincpu->set_input_line(INPUT_LINE_HALT, state); } +UINT8 a2bus_device::dma_r(address_space &space, UINT16 offset) +{ + m_maincpu_space->set_debugger_access(space.debugger_access()); + + return m_maincpu_space->read_byte(offset); +} + +void a2bus_device::dma_w(address_space &space, UINT16 offset, UINT8 data) +{ + m_maincpu_space->set_debugger_access(space.debugger_access()); + + m_maincpu_space->write_byte(offset, data); +} + +UINT8 a2bus_device::dma_nospace_r(UINT16 offset) +{ + return m_maincpu_space->read_byte(offset); +} + +void a2bus_device::dma_nospace_w(UINT16 offset, UINT8 data) +{ + m_maincpu_space->write_byte(offset, data); +} + void a2bus_device::recalc_inh(int slot) { m_out_inh_cb(ASSERT_LINE); diff --git a/src/emu/bus/a2bus/a2bus.h b/src/emu/bus/a2bus/a2bus.h index a440ef0c83c..f14b1d40354 100644 --- a/src/emu/bus/a2bus/a2bus.h +++ b/src/emu/bus/a2bus/a2bus.h @@ -106,6 +106,10 @@ public: void set_nmi_line(int state, int slot); void set_maincpu_halt(int state); void recalc_inh(int slot); + UINT8 dma_r(address_space &space, UINT16 offset); + void dma_w(address_space &space, UINT16 offset, UINT8 data); + UINT8 dma_nospace_r(UINT16 offset); + void dma_nospace_w(UINT16 offset, UINT8 data); DECLARE_WRITE_LINE_MEMBER( irq_w ); DECLARE_WRITE_LINE_MEMBER( nmi_w ); @@ -117,6 +121,7 @@ protected: // internal state cpu_device *m_maincpu; + address_space *m_maincpu_space; devcb_write_line m_out_irq_cb; devcb_write_line m_out_nmi_cb; @@ -144,12 +149,12 @@ public: device_a2bus_card_interface(const machine_config &mconfig, device_t &device); virtual ~device_a2bus_card_interface(); - virtual UINT8 read_c0nx(address_space &space, UINT8 offset) { printf("a2bus: unhandled read at C0n%x\n", offset); return 0; } // C0nX - /DEVSEL - virtual void write_c0nx(address_space &space, UINT8 offset, UINT8 data) { printf("a2bus: unhandled write %02x to C0n%x\n", data, offset); } + virtual UINT8 read_c0nx(address_space &space, UINT8 offset) { logerror("a2bus: unhandled read at C0n%x\n", offset); return 0; } // C0nX - /DEVSEL + virtual void write_c0nx(address_space &space, UINT8 offset, UINT8 data) { logerror("a2bus: unhandled write %02x to C0n%x\n", data, offset); } virtual UINT8 read_cnxx(address_space &space, UINT8 offset) { return 0; } // CnXX - /IOSEL - virtual void write_cnxx(address_space &space, UINT8 offset, UINT8 data) { printf("a2bus: unhandled write %02x to Cn%02x\n", data, offset); } + virtual void write_cnxx(address_space &space, UINT8 offset, UINT8 data) { logerror("a2bus: unhandled write %02x to Cn%02x\n", data, offset); } virtual UINT8 read_c800(address_space &space, UINT16 offset) { return 0; } // C800 - /IOSTB - virtual void write_c800(address_space &space, UINT16 offset, UINT8 data) { printf("a2bus: unhandled write %02x to %04x\n", data, offset + 0xc800); } + virtual void write_c800(address_space &space, UINT16 offset, UINT8 data) { logerror("a2bus: unhandled write %02x to %04x\n", data, offset + 0xc800); } virtual bool take_c800() { return true; } // override and return false if your card doesn't take over the c800 space virtual UINT8 read_inh_rom(address_space &space, UINT16 offset) { return 0; } virtual void write_inh_rom(address_space &space, UINT16 offset, UINT8 data) { } @@ -171,6 +176,15 @@ public: void recalc_slot_inh() { m_a2bus->recalc_inh(m_slot); } void set_maincpu_halt(int state) { m_a2bus->set_maincpu_halt(state); } + // pass through the original address space if any for debugger protection + // when debugging e.g. coprocessor cards (Z80 SoftCard etc). + UINT8 slot_dma_read(address_space &space, UINT16 offset) { return m_a2bus->dma_r(space, offset); } + void slot_dma_write(address_space &space, UINT16 offset, UINT8 data) { m_a2bus->dma_w(space, offset, data); } + + // these versions forego that protection for when the DMA isn't coming from a debuggable CPU device + UINT8 slot_dma_read_no_space(UINT16 offset) { return m_a2bus->dma_nospace_r(offset); } + void slot_dma_write_no_space(UINT16 offset, UINT8 data) { m_a2bus->dma_nospace_w(offset, data); } + // inline configuration static void static_set_a2bus_tag(device_t &device, const char *tag, const char *slottag); public: diff --git a/src/emu/bus/a2bus/a2mcms.c b/src/emu/bus/a2bus/a2mcms.c index 9b57980979d..e9bb29d1243 100644 --- a/src/emu/bus/a2bus/a2mcms.c +++ b/src/emu/bus/a2bus/a2mcms.c @@ -94,6 +94,7 @@ void a2bus_mcms1_device::device_start() void a2bus_mcms1_device::device_reset() { + m_mcms->set_bus_device(this); } // read once at c0n0 to disable 125 Hz IRQs @@ -290,7 +291,7 @@ void mcms_device::sound_stream_update(sound_stream &stream, stream_sample_t **in wptr = (m_table[v]<<8) | (m_acc[v]>>8); m_rand = (m_acc[v]>>8) & 0x1f; - sample = (m_6502space->read_byte(wptr) ^ 0x80); + sample = (m_pBusDevice->slot_dma_read_no_space(wptr) ^ 0x80); if (v & 1) { mixL += sample * m_vols[v]; @@ -355,9 +356,6 @@ WRITE8_MEMBER(mcms_device::voiceregs_w) WRITE8_MEMBER(mcms_device::control_w) { - // keep the space (TODO: we need to define a formal DMA mechanism from machine/apple2 out to the slots) - m_6502space = &space; - m_stream->update(); switch (offset) diff --git a/src/emu/bus/a2bus/a2mcms.h b/src/emu/bus/a2bus/a2mcms.h index c4d5e3dd730..283d13be62c 100644 --- a/src/emu/bus/a2bus/a2mcms.h +++ b/src/emu/bus/a2bus/a2mcms.h @@ -20,6 +20,8 @@ // TYPE DEFINITIONS //************************************************************************** +class a2bus_mcms1_device; + class mcms_device : public device_t, public device_sound_interface { public: @@ -30,6 +32,8 @@ public: DECLARE_WRITE8_MEMBER(control_w); UINT8 get_pen_rand(void) { m_stream->update(); return m_rand; } + void set_bus_device(a2bus_mcms1_device *pDev) { m_pBusDevice = pDev; } + template static devcb_base &set_irq_cb(device_t &device, _Object wr) { return downcast(device).m_write_irq.set_callback(wr); } devcb_write_line m_write_irq; @@ -43,8 +47,8 @@ protected: private: sound_stream *m_stream; - address_space *m_6502space; emu_timer *m_timer, *m_clrtimer; + a2bus_mcms1_device *m_pBusDevice; bool m_enabled; UINT8 m_vols[16]; UINT8 m_table[16]; diff --git a/src/emu/bus/a2bus/a2softcard.c b/src/emu/bus/a2bus/a2softcard.c index 5163c48936f..2def3ca23a3 100644 --- a/src/emu/bus/a2bus/a2softcard.c +++ b/src/emu/bus/a2bus/a2softcard.c @@ -52,16 +52,14 @@ machine_config_constructor a2bus_softcard_device::device_mconfig_additions() con a2bus_softcard_device::a2bus_softcard_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) : device_t(mconfig, type, name, tag, owner, clock, shortname, source), device_a2bus_card_interface(mconfig, *this), - m_z80(*this, Z80_TAG), - m_6502space(NULL) + m_z80(*this, Z80_TAG) { } a2bus_softcard_device::a2bus_softcard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : device_t(mconfig, A2BUS_SOFTCARD, "Microsoft SoftCard", tag, owner, clock, "a2softcard", __FILE__), device_a2bus_card_interface(mconfig, *this), - m_z80(*this, Z80_TAG), - m_6502space(NULL) + m_z80(*this, Z80_TAG) { } @@ -82,7 +80,6 @@ void a2bus_softcard_device::device_reset() { m_bEnabled = false; - m_6502space = NULL; m_FirstZ80Boot = true; m_z80->set_input_line(INPUT_LINE_HALT, ASSERT_LINE); } @@ -91,9 +88,6 @@ void a2bus_softcard_device::write_cnxx(address_space &space, UINT8 offset, UINT8 { if (!m_bEnabled) { - // steal the 6502's address space - m_6502space = &space; - m_z80->set_input_line(INPUT_LINE_HALT, CLEAR_LINE); set_maincpu_halt(ASSERT_LINE); @@ -115,31 +109,31 @@ void a2bus_softcard_device::write_cnxx(address_space &space, UINT8 offset, UINT8 READ8_MEMBER( a2bus_softcard_device::dma_r ) { - if (m_6502space) + if (m_bEnabled) { if (offset <= 0xafff) { - return m_6502space->read_byte(offset+0x1000); + return slot_dma_read(space, offset+0x1000); } else if (offset <= 0xbfff) // LC bank 2 d000-dfff { - return m_6502space->read_byte((offset&0xfff) + 0xd000); + return slot_dma_read(space, (offset&0xfff) + 0xd000); } else if (offset <= 0xcfff) // LC e000-efff { - return m_6502space->read_byte((offset&0xfff) + 0xe000); + return slot_dma_read(space, (offset&0xfff) + 0xe000); } else if (offset <= 0xdfff) // LC f000-ffff (or ROM?) { - return m_6502space->read_byte((offset&0xfff) + 0xf000); + return slot_dma_read(space, (offset&0xfff) + 0xf000); } else if (offset <= 0xefff) // I/O space c000-cfff { - return m_6502space->read_byte((offset&0xfff) + 0xc000); + return slot_dma_read(space, (offset&0xfff) + 0xc000); } else // zero page { - return m_6502space->read_byte(offset&0xfff); + return slot_dma_read(space, offset&0xfff); } } @@ -153,31 +147,31 @@ READ8_MEMBER( a2bus_softcard_device::dma_r ) WRITE8_MEMBER( a2bus_softcard_device::dma_w ) { - if (m_6502space) + if (m_bEnabled) { if (offset <= 0xafff) { - m_6502space->write_byte(offset+0x1000, data); + slot_dma_write(space, offset+0x1000, data); } else if (offset <= 0xbfff) // LC bank 2 d000-dfff { - m_6502space->write_byte((offset&0xfff) + 0xd000, data); + slot_dma_write(space, (offset&0xfff) + 0xd000, data); } else if (offset <= 0xcfff) // LC e000-efff { - m_6502space->write_byte((offset&0xfff) + 0xe000, data); + slot_dma_write(space, (offset&0xfff) + 0xe000, data); } else if (offset <= 0xdfff) // LC f000-ffff (or ROM?) { - m_6502space->write_byte((offset&0xfff) + 0xf000, data); + slot_dma_write(space, (offset&0xfff) + 0xf000, data); } else if (offset <= 0xefff) // I/O space c000-cfff { - m_6502space->write_byte((offset&0xfff) + 0xc000, data); + slot_dma_write(space, (offset&0xfff) + 0xc000, data); } else // zero page { - m_6502space->write_byte(offset&0xfff, data); + slot_dma_write(space, offset&0xfff, data); } } } diff --git a/src/emu/bus/a2bus/a2softcard.h b/src/emu/bus/a2bus/a2softcard.h index 4c8ab984e45..55d4fd8ae6a 100644 --- a/src/emu/bus/a2bus/a2softcard.h +++ b/src/emu/bus/a2bus/a2softcard.h @@ -44,7 +44,6 @@ protected: private: bool m_bEnabled; bool m_FirstZ80Boot; - address_space *m_6502space; }; // device type definition diff --git a/src/emu/bus/a2bus/a2themill.c b/src/emu/bus/a2bus/a2themill.c index 2eba107063e..168e07926fb 100644 --- a/src/emu/bus/a2bus/a2themill.c +++ b/src/emu/bus/a2bus/a2themill.c @@ -71,16 +71,14 @@ machine_config_constructor a2bus_themill_device::device_mconfig_additions() cons a2bus_themill_device::a2bus_themill_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) : device_t(mconfig, type, name, tag, owner, clock, shortname, source), device_a2bus_card_interface(mconfig, *this), - m_6809(*this, M6809_TAG), - m_6502space(NULL) + m_6809(*this, M6809_TAG) { } a2bus_themill_device::a2bus_themill_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : device_t(mconfig, A2BUS_THEMILL, "Stellation Two The Mill", tag, owner, clock, "a2themill", __FILE__), device_a2bus_card_interface(mconfig, *this), - m_6809(*this, M6809_TAG), - m_6502space(NULL) + m_6809(*this, M6809_TAG) { } @@ -102,7 +100,6 @@ void a2bus_themill_device::device_start() void a2bus_themill_device::device_reset() { m_bEnabled = false; - m_6502space = NULL; m_flipAddrSpace = false; m_6809Mode = false; m_status = 0xc0; // OS9 loader relies on this @@ -135,8 +132,6 @@ void a2bus_themill_device::write_c0nx(address_space &space, UINT8 offset, UINT8 case 2: // 6809 reset if (data & 0x80) { - // steal the 6502's address space - m_6502space = &space; m_6809->reset(); m_6809->set_input_line(INPUT_LINE_HALT, CLEAR_LINE); @@ -241,45 +236,42 @@ void a2bus_themill_device::write_c0nx(address_space &space, UINT8 offset, UINT8 READ8_MEMBER( a2bus_themill_device::dma_r ) { - if (m_6502space) + if (m_6809Mode) { - if (m_6809Mode) + if (offset <= 0xafff) { - if (offset <= 0xafff) - { - return m_6502space->read_byte(offset+0x1000); - } - else if (offset <= 0xbfff) - { - return m_6502space->read_byte((offset&0xfff) + 0xd000); - } - else if (offset <= 0xcfff) - { - return m_6502space->read_byte((offset&0xfff) + 0xe000); - } - else if (offset <= 0xdfff) - { - return m_6502space->read_byte((offset&0xfff) + 0xf000); - } - else if (offset <= 0xefff) - { - return m_6502space->read_byte((offset&0xfff) + 0xc000); - } - else // 6809 Fxxx -> 6502 ZP - { - return m_6502space->read_byte(offset&0xfff); - } + return slot_dma_read(space, offset+0x1000); + } + else if (offset <= 0xbfff) + { + return slot_dma_read(space, (offset&0xfff) + 0xd000); + } + else if (offset <= 0xcfff) + { + return slot_dma_read(space, (offset&0xfff) + 0xe000); + } + else if (offset <= 0xdfff) + { + return slot_dma_read(space, (offset&0xfff) + 0xf000); + } + else if (offset <= 0xefff) + { + return slot_dma_read(space, (offset&0xfff) + 0xc000); + } + else // 6809 Fxxx -> 6502 ZP + { + return slot_dma_read(space, offset&0xfff); + } + } + else + { + if (m_flipAddrSpace) + { + return slot_dma_read(space, offset^0x8000); } else { - if (m_flipAddrSpace) - { - return m_6502space->read_byte(offset^0x8000); - } - else - { - return m_6502space->read_byte(offset); - } + return slot_dma_read(space, offset); } } @@ -293,45 +285,42 @@ READ8_MEMBER( a2bus_themill_device::dma_r ) WRITE8_MEMBER( a2bus_themill_device::dma_w ) { - if (m_6502space) + if (m_6809Mode) { - if (m_6809Mode) + if (offset <= 0xafff) { - if (offset <= 0xafff) - { - m_6502space->write_byte(offset+0x1000, data); - } - else if (offset <= 0xbfff) - { - m_6502space->write_byte((offset&0xfff) + 0xd000, data); - } - else if (offset <= 0xcfff) - { - m_6502space->write_byte((offset&0xfff) + 0xe000, data); - } - else if (offset <= 0xdfff) - { - m_6502space->write_byte((offset&0xfff) + 0xf000, data); - } - else if (offset <= 0xefff) - { - m_6502space->write_byte((offset&0xfff) + 0xc000, data); - } - else // 6809 Fxxx -> 6502 ZP - { - m_6502space->write_byte(offset&0xfff, data); - } + slot_dma_write(space, offset+0x1000, data); + } + else if (offset <= 0xbfff) + { + slot_dma_write(space, (offset&0xfff) + 0xd000, data); + } + else if (offset <= 0xcfff) + { + slot_dma_write(space, (offset&0xfff) + 0xe000, data); + } + else if (offset <= 0xdfff) + { + slot_dma_write(space, (offset&0xfff) + 0xf000, data); + } + else if (offset <= 0xefff) + { + slot_dma_write(space, (offset&0xfff) + 0xc000, data); + } + else // 6809 Fxxx -> 6502 ZP + { + slot_dma_write(space, offset&0xfff, data); + } + } + else + { + if (m_flipAddrSpace) + { + slot_dma_write(space, offset^0x8000, data); } else { - if (m_flipAddrSpace) - { - m_6502space->write_byte(offset^0x8000, data); - } - else - { - m_6502space->write_byte(offset, data); - } + slot_dma_write(space, offset, data); } } } diff --git a/src/emu/bus/a2bus/a2themill.h b/src/emu/bus/a2bus/a2themill.h index f4de01b93e1..9424eddfa5d 100644 --- a/src/emu/bus/a2bus/a2themill.h +++ b/src/emu/bus/a2bus/a2themill.h @@ -46,7 +46,6 @@ private: bool m_bEnabled; bool m_flipAddrSpace; bool m_6809Mode; - address_space *m_6502space; UINT8 m_status; }; From 31bc7f4bbb8f805e1f05623d9d8d784750de92ad Mon Sep 17 00:00:00 2001 From: Justin Kerk Date: Sat, 31 Jan 2015 23:13:50 -0800 Subject: [PATCH 11/14] Work around Emscripten linking issues by avoiding ar altogether (nw) See https://github.com/kripken/emscripten/issues/2619 --- makefile | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/makefile b/makefile index 9a762b8d259..c7922e99b90 100644 --- a/makefile +++ b/makefile @@ -650,9 +650,6 @@ ifeq ($(COMMAND_MODE),"legacy") ARFLAGS = -crs endif endif -ifeq ($(TARGETOS),emscripten) -ARFLAGS = cr -endif #------------------------------------------------- @@ -929,11 +926,19 @@ $(sort $(OBJDIRS)): ifndef EXECUTABLE_DEFINED -$(EMULATOR): $(EMUINFOOBJ) $(DRIVLISTOBJ) $(DRVLIBS) $(LIBOSD) $(LIBBUS) $(LIBOPTIONAL) $(LIBEMU) $(LIBDASM) $(LIBUTIL) $(EXPAT) $(SOFTFLOAT) $(JPEG_LIB) $(FLAC_LIB) $(7Z_LIB) $(FORMATS_LIB) $(LUA_LIB) $(SQLITE3_LIB) $(WEB_LIB) $(ZLIB) $(LIBOCORE) $(MIDI_LIB) $(RESFILE) +EMULATOROBJLIST = $(EMUINFOOBJ) $(DRIVLISTOBJ) $(DRVLIBS) $(LIBOSD) $(LIBBUS) $(LIBOPTIONAL) $(LIBEMU) $(LIBDASM) $(LIBUTIL) $(EXPAT) $(SOFTFLOAT) $(JPEG_LIB) $(FLAC_LIB) $(7Z_LIB) $(FORMATS_LIB) $(LUA_LIB) $(SQLITE3_LIB) $(WEB_LIB) $(ZLIB) $(LIBOCORE) $(MIDI_LIB) $(RESFILE) + +ifeq ($(TARGETOS),emscripten) +EMULATOROBJ = $(EMULATOROBJLIST:.a=.bc) +else +EMULATOROBJ = $(EMULATOROBJLIST) +endif + +$(EMULATOR): $(EMULATOROBJ) $(CC) $(CDEFS) $(CFLAGS) -c $(SRC)/version.c -o $(VERSIONOBJ) @echo Linking $@... ifeq ($(TARGETOS),emscripten) -# Emscripten's linker seems to be stricter about the ordering of .a files +# Emscripten's linker seems to be stricter about the ordering of files $(LD) $(LDFLAGS) $(LDFLAGSEMULATOR) $(VERSIONOBJ) -Wl,--start-group $^ -Wl,--end-group $(LIBS) -o $@ else $(LD) $(LDFLAGS) $(LDFLAGSEMULATOR) $(VERSIONOBJ) $^ $(LIBS) -o $@ @@ -1002,10 +1007,20 @@ $(DRIVLISTSRC): $(SRC)/$(TARGET)/$(SUBTARGET).lst $(MAKELIST_TARGET) @echo Building driver list $<... @$(MAKELIST) $< >$@ +ifeq ($(TARGETOS),emscripten) +# Avoid using .a files with Emscripten, link to bitcode instead +$(OBJ)/%.a: + @echo Linking $@... + $(RM) $@ + $(LD) $^ -o $@ +$(OBJ)/%.bc: $(OBJ)/%.a + @cp $< $@ +else $(OBJ)/%.a: @echo Archiving $@... $(RM) $@ $(AR) $(ARFLAGS) $@ $^ +endif ifeq ($(TARGETOS),macosx) $(OBJ)/%.o: $(SRC)/%.m | $(OSPREBUILD) From 09b6ec9869349cf9befd8c3589f1dccb32bacd1a Mon Sep 17 00:00:00 2001 From: Ivan Vangelista Date: Sun, 1 Feb 2015 09:07:26 +0100 Subject: [PATCH 12/14] fastfred.c: added save state support to all games except imago and imagoa (nw) These 2 games use the galaxold starfield functions and therefore suffer from the same underlying save problem. Up to now I've not been able to identify the cause. --- src/mame/drivers/fastfred.c | 25 +++++++++---- src/mame/includes/fastfred.h | 71 ++++++++++++++++++++---------------- src/mame/video/fastfred.c | 18 +++++++++ 3 files changed, 74 insertions(+), 40 deletions(-) diff --git a/src/mame/drivers/fastfred.c b/src/mame/drivers/fastfred.c index dd8bd56dc0a..f42185acea5 100644 --- a/src/mame/drivers/fastfred.c +++ b/src/mame/drivers/fastfred.c @@ -14,6 +14,14 @@ #include "sound/ay8910.h" +void fastfred_state::machine_start() +{ + save_item(NAME(m_charbank)); + save_item(NAME(m_colorbank)); + save_item(NAME(m_nmi_mask)); + save_item(NAME(m_sound_nmi_mask)); +} + // This routine is a big hack, but the only way I can get the game working // without knowing anything about the way the protection chip works. // These values were derived based on disassembly of the code. Usually, it @@ -124,6 +132,7 @@ READ8_MEMBER(fastfred_state::boggy84_custom_io_r) MACHINE_START_MEMBER(fastfred_state,imago) { + machine_start(); m_gfxdecode->gfx(1)->set_source(m_imago_sprites); } @@ -1039,13 +1048,13 @@ DRIVER_INIT_MEMBER(fastfred_state,imago) m_hardware_type = 3; } -GAME( 1982, flyboy, 0, fastfred, flyboy, fastfred_state, flyboy, ROT90, "Kaneko", "Fly-Boy", 0 ) -GAME( 1982, flyboyb, flyboy, fastfred, flyboy, fastfred_state, flyboyb, ROT90, "bootleg", "Fly-Boy (bootleg)", 0 ) -GAME( 1982, fastfred, flyboy, fastfred, fastfred, fastfred_state, fastfred, ROT90, "Kaneko (Atari license)", "Fast Freddie", 0 ) -GAME( 1983, jumpcoas, 0, jumpcoas, jumpcoas, fastfred_state, jumpcoas, ROT90, "Kaneko", "Jump Coaster", 0 ) -GAME( 1983, jumpcoast,jumpcoas, jumpcoas, jumpcoas, fastfred_state, jumpcoas, ROT90, "Kaneko (Taito license)", "Jump Coaster (Taito)", 0 ) -GAME( 1983, boggy84, 0, jumpcoas, boggy84, fastfred_state, boggy84, ROT90, "Kaneko", "Boggy '84", 0 ) -GAME( 1983, boggy84b, boggy84, jumpcoas, boggy84, fastfred_state, boggy84b, ROT90, "bootleg (Eddie's Games)", "Boggy '84 (bootleg)", 0 ) -GAME( 1986, redrobin, 0, fastfred, redrobin, fastfred_state, flyboyb, ROT90, "Elettronolo", "Red Robin", 0 ) +GAME( 1982, flyboy, 0, fastfred, flyboy, fastfred_state, flyboy, ROT90, "Kaneko", "Fly-Boy", GAME_SUPPORTS_SAVE ) +GAME( 1982, flyboyb, flyboy, fastfred, flyboy, fastfred_state, flyboyb, ROT90, "bootleg", "Fly-Boy (bootleg)", GAME_SUPPORTS_SAVE ) +GAME( 1982, fastfred, flyboy, fastfred, fastfred, fastfred_state, fastfred, ROT90, "Kaneko (Atari license)", "Fast Freddie", GAME_SUPPORTS_SAVE ) +GAME( 1983, jumpcoas, 0, jumpcoas, jumpcoas, fastfred_state, jumpcoas, ROT90, "Kaneko", "Jump Coaster", GAME_SUPPORTS_SAVE ) +GAME( 1983, jumpcoast,jumpcoas, jumpcoas, jumpcoas, fastfred_state, jumpcoas, ROT90, "Kaneko (Taito license)", "Jump Coaster (Taito)", GAME_SUPPORTS_SAVE ) +GAME( 1983, boggy84, 0, jumpcoas, boggy84, fastfred_state, boggy84, ROT90, "Kaneko", "Boggy '84", GAME_SUPPORTS_SAVE ) +GAME( 1983, boggy84b, boggy84, jumpcoas, boggy84, fastfred_state, boggy84b, ROT90, "bootleg (Eddie's Games)", "Boggy '84 (bootleg)", GAME_SUPPORTS_SAVE ) +GAME( 1986, redrobin, 0, fastfred, redrobin, fastfred_state, flyboyb, ROT90, "Elettronolo", "Red Robin", GAME_SUPPORTS_SAVE ) GAME( 1984, imago, 0, imago, imago, fastfred_state, imago, ROT90, "Acom", "Imago (cocktail set)", 0 ) GAME( 1983, imagoa, imago, imago, imagoa, fastfred_state, imago, ROT90, "Acom", "Imago (no cocktail set)", 0 ) diff --git a/src/mame/includes/fastfred.h b/src/mame/includes/fastfred.h index 096e9e4da15..50747bcf6a2 100644 --- a/src/mame/includes/fastfred.h +++ b/src/mame/includes/fastfred.h @@ -12,34 +12,36 @@ class fastfred_state : public galaxold_state public: fastfred_state(const machine_config &mconfig, device_type type, const char *tag) : galaxold_state(mconfig, type, tag), + m_gfxdecode(*this, "gfxdecode"), + m_palette(*this, "palette"), m_videoram(*this, "videoram"), m_spriteram(*this, "spriteram"), m_attributesram(*this, "attributesram"), m_background_color(*this, "bgcolor"), - m_imago_fg_videoram(*this, "imago_fg_vram"), - m_gfxdecode(*this, "gfxdecode"), - m_palette(*this, "palette") { } + m_imago_fg_videoram(*this, "imago_fg_vram") { } - UINT8 m_imago_sprites[0x800*3]; - UINT16 m_imago_sprites_address; - UINT8 m_imago_sprites_bank; - int m_hardware_type; + required_device m_gfxdecode; + required_device m_palette; + required_shared_ptr m_videoram; required_shared_ptr m_spriteram; required_shared_ptr m_attributesram; optional_shared_ptr m_background_color; optional_shared_ptr m_imago_fg_videoram; - required_device m_gfxdecode; - required_device m_palette; + int m_hardware_type; UINT16 m_charbank; UINT8 m_colorbank; + UINT8 m_nmi_mask; + UINT8 m_sound_nmi_mask; + UINT8 m_imago_sprites[0x800*3]; + UINT16 m_imago_sprites_address; + UINT8 m_imago_sprites_bank; + tilemap_t *m_bg_tilemap; tilemap_t *m_fg_tilemap; tilemap_t *m_web_tilemap; - UINT8 m_nmi_mask; - UINT8 m_sound_nmi_mask; DECLARE_READ8_MEMBER(fastfred_custom_io_r); DECLARE_READ8_MEMBER(flyboy_custom1_io_r); DECLARE_READ8_MEMBER(flyboy_custom2_io_r); @@ -51,26 +53,6 @@ public: DECLARE_READ8_MEMBER(imago_sprites_offset_r); DECLARE_WRITE8_MEMBER(nmi_mask_w); DECLARE_WRITE8_MEMBER(sound_nmi_mask_w); - DECLARE_DRIVER_INIT(fastfred); - DECLARE_DRIVER_INIT(flyboy); - DECLARE_DRIVER_INIT(flyboyb); - DECLARE_DRIVER_INIT(imago); - DECLARE_DRIVER_INIT(boggy84); - DECLARE_DRIVER_INIT(jumpcoas); - DECLARE_DRIVER_INIT(boggy84b); - TILE_GET_INFO_MEMBER(get_tile_info); - TILE_GET_INFO_MEMBER(imago_get_tile_info_bg); - TILE_GET_INFO_MEMBER(imago_get_tile_info_fg); - TILE_GET_INFO_MEMBER(imago_get_tile_info_web); - DECLARE_VIDEO_START(fastfred); - DECLARE_PALETTE_INIT(fastfred); - DECLARE_MACHINE_START(imago); - DECLARE_VIDEO_START(imago); - UINT32 screen_update_fastfred(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - UINT32 screen_update_imago(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - INTERRUPT_GEN_MEMBER(vblank_irq); - INTERRUPT_GEN_MEMBER(sound_timer_irq); - void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect); DECLARE_WRITE8_MEMBER(fastfred_videoram_w); DECLARE_WRITE8_MEMBER(fastfred_attributes_w); DECLARE_WRITE8_MEMBER(fastfred_charbank1_w); @@ -79,7 +61,32 @@ public: DECLARE_WRITE8_MEMBER(fastfred_colorbank2_w); DECLARE_WRITE8_MEMBER(fastfred_flip_screen_x_w); DECLARE_WRITE8_MEMBER(fastfred_flip_screen_y_w); - DECLARE_WRITE8_MEMBER(imago_fg_videoram_w); DECLARE_WRITE8_MEMBER(imago_charbank_w); + + DECLARE_DRIVER_INIT(fastfred); + DECLARE_DRIVER_INIT(flyboy); + DECLARE_DRIVER_INIT(flyboyb); + DECLARE_DRIVER_INIT(imago); + DECLARE_DRIVER_INIT(boggy84); + DECLARE_DRIVER_INIT(jumpcoas); + DECLARE_DRIVER_INIT(boggy84b); + + TILE_GET_INFO_MEMBER(get_tile_info); + TILE_GET_INFO_MEMBER(imago_get_tile_info_bg); + TILE_GET_INFO_MEMBER(imago_get_tile_info_fg); + TILE_GET_INFO_MEMBER(imago_get_tile_info_web); + + INTERRUPT_GEN_MEMBER(vblank_irq); + INTERRUPT_GEN_MEMBER(sound_timer_irq); + + virtual void machine_start(); + DECLARE_PALETTE_INIT(fastfred); + DECLARE_MACHINE_START(imago); + DECLARE_VIDEO_START(fastfred); + DECLARE_VIDEO_START(imago); + + UINT32 screen_update_fastfred(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + UINT32 screen_update_imago(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect); }; diff --git a/src/mame/video/fastfred.c b/src/mame/video/fastfred.c index 1836155ae7e..fb4afb7c0cf 100644 --- a/src/mame/video/fastfred.c +++ b/src/mame/video/fastfred.c @@ -345,6 +345,24 @@ VIDEO_START_MEMBER(fastfred_state,imago) /* web colors */ m_palette->set_pen_color(256+64+0,rgb_t(0x50,0x00,0x00)); m_palette->set_pen_color(256+64+1,rgb_t(0x00,0x00,0x00)); + + save_item(NAME(m_imago_sprites)); + save_item(NAME(m_imago_sprites_address)); + save_item(NAME(m_imago_sprites_bank)); + + // galaxold starfield related save states. Something's still missing here. + save_item(NAME(m_stars_on)); + save_item(NAME(m_stars_blink_state)); + save_item(NAME(m_timer_adjusted)); + save_item(NAME(m_stars_colors_start)); + save_item(NAME(m_stars_scrollpos)); + + for (int i = 0; i < STAR_COUNT; i++) + { + save_item(NAME(m_stars[i].x), i); + save_item(NAME(m_stars[i].y), i); + save_item(NAME(m_stars[i].color), i); + } } UINT32 fastfred_state::screen_update_imago(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) From 80fd679d311bfb3bbee59151df7b974310503211 Mon Sep 17 00:00:00 2001 From: hap Date: Sun, 1 Feb 2015 13:27:28 +0100 Subject: [PATCH 13/14] s2000 improved d-latch --- src/emu/cpu/amis2000/amis2000.c | 20 ++++++++++------ src/emu/cpu/amis2000/amis2000.h | 5 +++- src/emu/cpu/amis2000/amis2000d.c | 20 +++++++--------- src/emu/cpu/amis2000/amis2000op.inc | 36 ++++++++++++++++++----------- src/mess/drivers/wildfire.c | 5 ++-- 5 files changed, 50 insertions(+), 36 deletions(-) diff --git a/src/emu/cpu/amis2000/amis2000.c b/src/emu/cpu/amis2000/amis2000.c index d6c4967d0dc..9b227fd89b6 100644 --- a/src/emu/cpu/amis2000/amis2000.c +++ b/src/emu/cpu/amis2000/amis2000.c @@ -5,9 +5,9 @@ American Microsystems, Inc.(AMI) S2000-family 4-bit MCU cores, introduced late 1970s TODO: - - bug(s)? - MESS wildfire.c doesn't work yet - unemulated opcodes (need more testing material) - support external program map + - STATUS pin(wildfire.c sound?) - add 50/60hz timer - add S2200/S2400 @@ -16,6 +16,8 @@ #include "amis2000.h" #include "debugger.h" +#include "amis2000op.inc" + // S2000 is the most basic one, 64 nibbles internal RAM and 1KB internal ROM // S2150 increased RAM to 80 nibbles and ROM to 1.5KB @@ -31,7 +33,8 @@ ADDRESS_MAP_END static ADDRESS_MAP_START(program_1_5k, AS_PROGRAM, 8, amis2000_device) AM_RANGE(0x0000, 0x03ff) AM_ROM - AM_RANGE(0x0400, 0x05ff) AM_ROM AM_MIRROR(0x200) + AM_RANGE(0x0400, 0x05ff) AM_NOP + AM_RANGE(0x0600, 0x07ff) AM_ROM ADDRESS_MAP_END @@ -151,6 +154,8 @@ void amis2000_device::device_start() m_i = 0; m_k = 0; m_d = 0; + m_d_active = false; + m_d_polarity = 0; m_a = 0; // register for savestates @@ -170,6 +175,8 @@ void amis2000_device::device_start() save_item(NAME(m_i)); save_item(NAME(m_k)); save_item(NAME(m_d)); + save_item(NAME(m_d_active)); + save_item(NAME(m_d_polarity)); save_item(NAME(m_a)); // register state for debugger @@ -199,10 +206,11 @@ void amis2000_device::device_reset() m_op = 0; // clear i/o + m_d_polarity = 0; + m_d = 0; d_latch_out(false); + m_a = 0; m_write_a(0, 0, 0xffff); m_i = 0; m_k = 0; - m_d = 0; m_write_d(0, 0, 0xff); - m_a = 0; m_write_a(0, 0, 0xffff); } @@ -211,8 +219,6 @@ void amis2000_device::device_reset() // execute //------------------------------------------------- -#include "amis2000op.inc" - void amis2000_device::execute_run() { while (m_icount > 0) @@ -246,7 +252,7 @@ void amis2000_device::execute_run() switch (m_op) { case 0x00: op_nop(); break; - case 0x01: op_illegal(); break; // reserved for devkit-use + case 0x01: op_halt(); break; case 0x02: op_rt(); break; case 0x03: op_rts(); break; case 0x04: op_psh(); break; diff --git a/src/emu/cpu/amis2000/amis2000.h b/src/emu/cpu/amis2000/amis2000.h index d8960bfd062..18c3b5d43a3 100644 --- a/src/emu/cpu/amis2000/amis2000.h +++ b/src/emu/cpu/amis2000/amis2000.h @@ -92,6 +92,8 @@ protected: UINT8 m_i; // 4-bit i-pins latch UINT8 m_k; // 4-bit k-pins latch UINT8 m_d; // 8-bit d-pins latch + bool m_d_active; // d-pins available for direct i/o(floating), or outputting d-latch + UINT8 m_d_polarity; // invert d-latch output UINT16 m_a; // 13-bit a-pins latch (master strobe latch) devcb_read8 m_read_k; @@ -106,7 +108,7 @@ protected: void ram_w(UINT8 data); void pop_callstack(); void push_callstack(); - void op_illegal(); + void d_latch_out(bool active); void op_lai(); void op_lab(); @@ -141,6 +143,7 @@ protected: void op_rt(); void op_rts(); void op_nop(); + void op_halt(); void op_szc(); void op_szm(); diff --git a/src/emu/cpu/amis2000/amis2000d.c b/src/emu/cpu/amis2000/amis2000d.c index 81fc59b58d9..0c9079a3b3e 100644 --- a/src/emu/cpu/amis2000/amis2000d.c +++ b/src/emu/cpu/amis2000/amis2000d.c @@ -17,9 +17,8 @@ enum e_mnemonics mLAM, mXC, mXCI, mXCD, mSTM, mRSM, mADD, mADCS, mADIS, mAND, mXOR, mCMA, mSTC, mRSC, mSF1, mRF1, mSF2, mRF2, mSAM, mSZM, mSBE, mSZC, mSOS, mSZK, mSZI, mTF1, mTF2, - mPP, mJMP, mJMS, mRT, mRTS, mNOP, - mINP, mOUT, mDISB, mDISN, mMVS, mPSH, mPSL, mEUR, - mILL + mPP, mJMP, mJMS, mRT, mRTS, mNOP, mHALT, + mINP, mOUT, mDISB, mDISN, mMVS, mPSH, mPSL, mEUR }; static const char *const s_mnemonics[] = @@ -28,9 +27,8 @@ static const char *const s_mnemonics[] = "LAM", "XC", "XCI", "XCD", "STM", "RSM", "ADD", "ADCS", "ADIS", "AND", "XOR", "CMA", "STC", "RSC", "SF1", "RF1", "SF2", "RF2", "SAM", "SZM", "SBE", "SZC", "SOS", "SZK", "SZI", "TF1", "TF2", - "PP", "JMP", "JMS", "RT", "RTS", "NOP", - "INP", "OUT", "DISB", "DISN", "MVS", "PSH", "PSL", "EUR", - "?" + "PP", "JMP", "JMS", "RT", "RTS", "NOP", "HALT", + "INP", "OUT", "DISB", "DISN", "MVS", "PSH", "PSL", "EUR" }; @@ -43,9 +41,8 @@ static const UINT32 s_flags[] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, _OVER, _OUT, _OUT, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0 + 0, 0, _OVER, _OUT, _OUT, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0 }; @@ -55,16 +52,15 @@ static const int s_bits[] = -2, -2, -2, -2, 2, 2, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, - -4, 6, 6, 0, 0, 0, + -4, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }; static const UINT8 s2000_mnemonic[0x100] = { /* 0x00 */ - mNOP, mILL, mRT, mRTS, mPSH, mPSL, mAND, mSOS, + mNOP, mHALT, mRT, mRTS, mPSH, mPSL, mAND, mSOS, mSBE, mSZC, mSTC, mRSC, mLAE, mXAE, mINP, mEUR, /* 0x10 */ mCMA, mXABU, mLAB, mXAB, mADCS, mXOR, mADD, mSAM, diff --git a/src/emu/cpu/amis2000/amis2000op.inc b/src/emu/cpu/amis2000/amis2000op.inc index 504fc174379..ed6f6158d89 100644 --- a/src/emu/cpu/amis2000/amis2000op.inc +++ b/src/emu/cpu/amis2000/amis2000op.inc @@ -33,9 +33,10 @@ void amis2000_device::push_callstack() m_callstack[0] = m_pc & m_callstack_mask; } -void amis2000_device::op_illegal() +void amis2000_device::d_latch_out(bool active) { - logerror("%s unknown opcode $%02X at $%04X\n", tag(), m_op, m_pc); + m_write_d(0, active ? (m_d ^ m_d_polarity) : 0, 0xff); + m_d_active = active; } @@ -195,21 +196,22 @@ void amis2000_device::op_rsm() void amis2000_device::op_inp() { // INP: input D-pins to ACC and RAM - op_illegal(); + UINT8 in = m_d_active ? m_d : m_read_d(0, 0xff); + m_acc = in & 0xf; + ram_w(in >> 4 & 0xf); } void amis2000_device::op_out() { // OUT: pulse output ACC and RAM to D-pins - op_illegal(); + logerror("%s unknown opcode $%02X at $%04X\n", tag(), m_op, m_pc); } void amis2000_device::op_disb() { // DISB: set D-latch to ACC and RAM directly m_d = m_acc | ram_r() << 4; - m_write_d(0, m_d, 0xff); - // TODO: exit from floating mode on D-pins + d_latch_out(true); } void amis2000_device::op_disn() @@ -221,15 +223,14 @@ void amis2000_device::op_disn() 0x7e, 0x30, 0x6d, 0x79, 0x33, 0x5b, 0x5f, 0x70, 0x7f, 0x7b, 0x77, 0x1f, 0x4e, 0x3d, 0x4f, 0x47 }; m_d = lut_segment_decoder[m_acc] | (m_carry ? 0x80 : 0x00); - m_write_d(0, m_d, 0xff); - // TODO: exit from floating mode on D-pins + d_latch_out(true); } void amis2000_device::op_mvs() { // MVS: output master strobe latch to A-pins + d_latch_out(false); m_write_a(0, m_a, 0xffff); - // TODO: enter floating mode on D-pins } void amis2000_device::op_psh() @@ -244,7 +245,7 @@ void amis2000_device::op_psh() case 0xe: // exit from floating mode on D-pins - // ? + d_latch_out(true); break; case 0xf: @@ -271,7 +272,7 @@ void amis2000_device::op_psl() case 0xe: // enter floating mode on D-pins - // ? + d_latch_out(false); break; case 0xf: @@ -288,8 +289,9 @@ void amis2000_device::op_psl() void amis2000_device::op_eur() { - // EUR: set timer frequency(European) and D-latch polarity - op_illegal(); + // EUR: set timer frequency(European) and D-latch polarity, via ACC + m_d_polarity = (m_acc & 1) ? 0x00 : 0xff; + d_latch_out(m_d_active); // refresh } @@ -350,6 +352,12 @@ void amis2000_device::op_nop() // NOP: no operation } +void amis2000_device::op_halt() +{ + // HALT: debugger breakpoint for devkit-use + logerror("%s unknown opcode $%02X at $%04X\n", tag(), m_op, m_pc); +} + // Skip Instructions @@ -393,7 +401,7 @@ void amis2000_device::op_sam() void amis2000_device::op_sos() { // SOS: skip next on SF(timer output), clear SF - op_illegal(); + logerror("%s unknown opcode $%02X at $%04X\n", tag(), m_op, m_pc); } void amis2000_device::op_tf1() diff --git a/src/mess/drivers/wildfire.c b/src/mess/drivers/wildfire.c index 39db9be728f..f147aee90c2 100644 --- a/src/mess/drivers/wildfire.c +++ b/src/mess/drivers/wildfire.c @@ -108,8 +108,9 @@ MACHINE_CONFIG_END ***************************************************************************/ ROM_START( wildfire ) - ROM_REGION( 0x0600, "maincpu", 0 ) - ROM_LOAD( "us4341385", 0x0000, 0x0600, CRC(84ac0f1f) SHA1(1e00ddd402acfc2cc267c34eed4b89d863e2144f) ) // from patent US4334679, data should be correct (it included checksums) + ROM_REGION( 0x0800, "maincpu", ROMREGION_ERASE00 ) + ROM_LOAD( "us4341385", 0x0000, 0x0400, CRC(84ac0f1f) SHA1(1e00ddd402acfc2cc267c34eed4b89d863e2144f) ) // from patent US4334679, data should be correct (it included checksums) + ROM_CONTINUE( 0x0600, 0x0200 ) ROM_END From df61155a85edfa4c75768e6d6d1d2c7735e43aa9 Mon Sep 17 00:00:00 2001 From: hap Date: Sun, 1 Feb 2015 13:33:54 +0100 Subject: [PATCH 14/14] nw --- src/emu/cpu/amis2000/amis2000d.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/emu/cpu/amis2000/amis2000d.c b/src/emu/cpu/amis2000/amis2000d.c index 0c9079a3b3e..efb2f74b5f6 100644 --- a/src/emu/cpu/amis2000/amis2000d.c +++ b/src/emu/cpu/amis2000/amis2000d.c @@ -53,7 +53,7 @@ static const int s_bits[] = 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, -4, 6, 6, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0 };