diff --git a/src/emu/inptport.c b/src/emu/inptport.c index 6d09f42bdf9..60297456e8a 100644 --- a/src/emu/inptport.c +++ b/src/emu/inptport.c @@ -3359,22 +3359,6 @@ UINT32 input_port_read_safe(running_machine *machine, const char *tag, UINT32 de -/************************************* - * - * Input port writing - * - *************************************/ - -void input_port_set_digital_value(running_machine *machine, int port_num, UINT32 value, UINT32 mask) -{ - /* used by MESS for natural keyboard input */ - input_port_info *portinfo = &port_info[port_num]; - portinfo->digital &= ~mask; - portinfo->digital |= value; -} - - - /************************************* * * Return position of crosshair axis diff --git a/src/emu/inptport.h b/src/emu/inptport.h index 65f9615e52a..9b600980229 100644 --- a/src/emu/inptport.h +++ b/src/emu/inptport.h @@ -937,8 +937,6 @@ int input_ui_pressed_repeat(int code, int speed); void input_port_update_defaults(void); -void input_port_set_digital_value(running_machine *machine, int port_num, UINT32 value, UINT32 mask); - UINT32 get_crosshair_pos(int port_num, UINT8 player, UINT8 axis); UINT32 input_port_read_indexed(running_machine *machine, int port); diff --git a/src/emu/machine/6821pia.c b/src/emu/machine/6821pia.c index c7cb2c1216f..3009bd2c114 100644 --- a/src/emu/machine/6821pia.c +++ b/src/emu/machine/6821pia.c @@ -1198,82 +1198,6 @@ WRITE8_HANDLER( pia_5_alt_w ) { pia_alt_write(5, offset, data); } WRITE8_HANDLER( pia_6_alt_w ) { pia_alt_write(6, offset, data); } WRITE8_HANDLER( pia_7_alt_w ) { pia_alt_write(7, offset, data); } -/******************* Standard 16-bit CPU interfaces, D0-D7 *******************/ - -READ16_HANDLER( pia_0_lsb_r ) { return pia_read(0, offset); } -READ16_HANDLER( pia_1_lsb_r ) { return pia_read(1, offset); } -READ16_HANDLER( pia_2_lsb_r ) { return pia_read(2, offset); } -READ16_HANDLER( pia_3_lsb_r ) { return pia_read(3, offset); } -READ16_HANDLER( pia_4_lsb_r ) { return pia_read(4, offset); } -READ16_HANDLER( pia_5_lsb_r ) { return pia_read(5, offset); } -READ16_HANDLER( pia_6_lsb_r ) { return pia_read(6, offset); } -READ16_HANDLER( pia_7_lsb_r ) { return pia_read(7, offset); } - -WRITE16_HANDLER( pia_0_lsb_w ) { if (ACCESSING_BITS_0_7) pia_write(0, offset, data); } -WRITE16_HANDLER( pia_1_lsb_w ) { if (ACCESSING_BITS_0_7) pia_write(1, offset, data); } -WRITE16_HANDLER( pia_2_lsb_w ) { if (ACCESSING_BITS_0_7) pia_write(2, offset, data); } -WRITE16_HANDLER( pia_3_lsb_w ) { if (ACCESSING_BITS_0_7) pia_write(3, offset, data); } -WRITE16_HANDLER( pia_4_lsb_w ) { if (ACCESSING_BITS_0_7) pia_write(4, offset, data); } -WRITE16_HANDLER( pia_5_lsb_w ) { if (ACCESSING_BITS_0_7) pia_write(5, offset, data); } -WRITE16_HANDLER( pia_6_lsb_w ) { if (ACCESSING_BITS_0_7) pia_write(6, offset, data); } -WRITE16_HANDLER( pia_7_lsb_w ) { if (ACCESSING_BITS_0_7) pia_write(7, offset, data); } - -READ16_HANDLER( pia_0_lsb_alt_r ) { return pia_alt_read(0, offset); } -READ16_HANDLER( pia_1_lsb_alt_r ) { return pia_alt_read(1, offset); } -READ16_HANDLER( pia_2_lsb_alt_r ) { return pia_alt_read(2, offset); } -READ16_HANDLER( pia_3_lsb_alt_r ) { return pia_alt_read(3, offset); } -READ16_HANDLER( pia_4_lsb_alt_r ) { return pia_alt_read(4, offset); } -READ16_HANDLER( pia_5_lsb_alt_r ) { return pia_alt_read(5, offset); } -READ16_HANDLER( pia_6_lsb_alt_r ) { return pia_alt_read(6, offset); } -READ16_HANDLER( pia_7_lsb_alt_r ) { return pia_alt_read(7, offset); } - -WRITE16_HANDLER( pia_0_lsb_alt_w ) { if (ACCESSING_BITS_0_7) pia_alt_write(0, offset, data); } -WRITE16_HANDLER( pia_1_lsb_alt_w ) { if (ACCESSING_BITS_0_7) pia_alt_write(1, offset, data); } -WRITE16_HANDLER( pia_2_lsb_alt_w ) { if (ACCESSING_BITS_0_7) pia_alt_write(2, offset, data); } -WRITE16_HANDLER( pia_3_lsb_alt_w ) { if (ACCESSING_BITS_0_7) pia_alt_write(3, offset, data); } -WRITE16_HANDLER( pia_4_lsb_alt_w ) { if (ACCESSING_BITS_0_7) pia_alt_write(4, offset, data); } -WRITE16_HANDLER( pia_5_lsb_alt_w ) { if (ACCESSING_BITS_0_7) pia_alt_write(5, offset, data); } -WRITE16_HANDLER( pia_6_lsb_alt_w ) { if (ACCESSING_BITS_0_7) pia_alt_write(6, offset, data); } -WRITE16_HANDLER( pia_7_lsb_alt_w ) { if (ACCESSING_BITS_0_7) pia_alt_write(7, offset, data); } - -/******************* Standard 16-bit CPU interfaces, D8-D15 *******************/ - -READ16_HANDLER( pia_0_msb_r ) { return pia_read(0, offset) << 8; } -READ16_HANDLER( pia_1_msb_r ) { return pia_read(1, offset) << 8; } -READ16_HANDLER( pia_2_msb_r ) { return pia_read(2, offset) << 8; } -READ16_HANDLER( pia_3_msb_r ) { return pia_read(3, offset) << 8; } -READ16_HANDLER( pia_4_msb_r ) { return pia_read(4, offset) << 8; } -READ16_HANDLER( pia_5_msb_r ) { return pia_read(5, offset) << 8; } -READ16_HANDLER( pia_6_msb_r ) { return pia_read(6, offset) << 8; } -READ16_HANDLER( pia_7_msb_r ) { return pia_read(7, offset) << 8; } - -WRITE16_HANDLER( pia_0_msb_w ) { if (ACCESSING_BITS_8_15) pia_write(0, offset, data >> 8); } -WRITE16_HANDLER( pia_1_msb_w ) { if (ACCESSING_BITS_8_15) pia_write(1, offset, data >> 8); } -WRITE16_HANDLER( pia_2_msb_w ) { if (ACCESSING_BITS_8_15) pia_write(2, offset, data >> 8); } -WRITE16_HANDLER( pia_3_msb_w ) { if (ACCESSING_BITS_8_15) pia_write(3, offset, data >> 8); } -WRITE16_HANDLER( pia_4_msb_w ) { if (ACCESSING_BITS_8_15) pia_write(4, offset, data >> 8); } -WRITE16_HANDLER( pia_5_msb_w ) { if (ACCESSING_BITS_8_15) pia_write(5, offset, data >> 8); } -WRITE16_HANDLER( pia_6_msb_w ) { if (ACCESSING_BITS_8_15) pia_write(6, offset, data >> 8); } -WRITE16_HANDLER( pia_7_msb_w ) { if (ACCESSING_BITS_8_15) pia_write(7, offset, data >> 8); } - -READ16_HANDLER( pia_0_msb_alt_r ) { return pia_alt_read(0, offset) << 8; } -READ16_HANDLER( pia_1_msb_alt_r ) { return pia_alt_read(1, offset) << 8; } -READ16_HANDLER( pia_2_msb_alt_r ) { return pia_alt_read(2, offset) << 8; } -READ16_HANDLER( pia_3_msb_alt_r ) { return pia_alt_read(3, offset) << 8; } -READ16_HANDLER( pia_4_msb_alt_r ) { return pia_alt_read(4, offset) << 8; } -READ16_HANDLER( pia_5_msb_alt_r ) { return pia_alt_read(5, offset) << 8; } -READ16_HANDLER( pia_6_msb_alt_r ) { return pia_alt_read(6, offset) << 8; } -READ16_HANDLER( pia_7_msb_alt_r ) { return pia_alt_read(7, offset) << 8; } - -WRITE16_HANDLER( pia_0_msb_alt_w ) { if (ACCESSING_BITS_8_15) pia_alt_write(0, offset, data >> 8); } -WRITE16_HANDLER( pia_1_msb_alt_w ) { if (ACCESSING_BITS_8_15) pia_alt_write(1, offset, data >> 8); } -WRITE16_HANDLER( pia_2_msb_alt_w ) { if (ACCESSING_BITS_8_15) pia_alt_write(2, offset, data >> 8); } -WRITE16_HANDLER( pia_3_msb_alt_w ) { if (ACCESSING_BITS_8_15) pia_alt_write(3, offset, data >> 8); } -WRITE16_HANDLER( pia_4_msb_alt_w ) { if (ACCESSING_BITS_8_15) pia_alt_write(4, offset, data >> 8); } -WRITE16_HANDLER( pia_5_msb_alt_w ) { if (ACCESSING_BITS_8_15) pia_alt_write(5, offset, data >> 8); } -WRITE16_HANDLER( pia_6_msb_alt_w ) { if (ACCESSING_BITS_8_15) pia_alt_write(6, offset, data >> 8); } -WRITE16_HANDLER( pia_7_msb_alt_w ) { if (ACCESSING_BITS_8_15) pia_alt_write(7, offset, data >> 8); } - /******************* 8-bit A/B port interfaces *******************/ WRITE8_HANDLER( pia_0_porta_w ) { pia_set_input_a(0, data, 0); } diff --git a/src/emu/machine/6821pia.h b/src/emu/machine/6821pia.h index a912dd5d12c..1d6fbb1e6d7 100644 --- a/src/emu/machine/6821pia.h +++ b/src/emu/machine/6821pia.h @@ -168,86 +168,6 @@ WRITE8_HANDLER( pia_7_alt_w ); -/*---------- Standard 16-bit CPU interfaces, D0-D7 -------*/ - -READ16_HANDLER( pia_0_lsb_r ); -READ16_HANDLER( pia_1_lsb_r ); -READ16_HANDLER( pia_2_lsb_r ); -READ16_HANDLER( pia_3_lsb_r ); -READ16_HANDLER( pia_4_lsb_r ); -READ16_HANDLER( pia_5_lsb_r ); -READ16_HANDLER( pia_6_lsb_r ); -READ16_HANDLER( pia_7_lsb_r ); - -WRITE16_HANDLER( pia_0_lsb_w ); -WRITE16_HANDLER( pia_1_lsb_w ); -WRITE16_HANDLER( pia_2_lsb_w ); -WRITE16_HANDLER( pia_3_lsb_w ); -WRITE16_HANDLER( pia_4_lsb_w ); -WRITE16_HANDLER( pia_5_lsb_w ); -WRITE16_HANDLER( pia_6_lsb_w ); -WRITE16_HANDLER( pia_7_lsb_w ); - -READ16_HANDLER( pia_0_lsb_alt_r ); -READ16_HANDLER( pia_1_lsb_alt_r ); -READ16_HANDLER( pia_2_lsb_alt_r ); -READ16_HANDLER( pia_3_lsb_alt_r ); -READ16_HANDLER( pia_4_lsb_alt_r ); -READ16_HANDLER( pia_5_lsb_alt_r ); -READ16_HANDLER( pia_6_lsb_alt_r ); -READ16_HANDLER( pia_7_lsb_alt_r ); - -WRITE16_HANDLER( pia_0_lsb_alt_w ); -WRITE16_HANDLER( pia_1_lsb_alt_w ); -WRITE16_HANDLER( pia_2_lsb_alt_w ); -WRITE16_HANDLER( pia_3_lsb_alt_w ); -WRITE16_HANDLER( pia_4_lsb_alt_w ); -WRITE16_HANDLER( pia_5_lsb_alt_w ); -WRITE16_HANDLER( pia_6_lsb_alt_w ); -WRITE16_HANDLER( pia_7_lsb_alt_w ); - - - -/*--------- Standard 16-bit CPU interfaces, D8-D15 -------*/ - -READ16_HANDLER( pia_0_msb_r ); -READ16_HANDLER( pia_1_msb_r ); -READ16_HANDLER( pia_2_msb_r ); -READ16_HANDLER( pia_3_msb_r ); -READ16_HANDLER( pia_4_msb_r ); -READ16_HANDLER( pia_5_msb_r ); -READ16_HANDLER( pia_6_msb_r ); -READ16_HANDLER( pia_7_msb_r ); - -WRITE16_HANDLER( pia_0_msb_w ); -WRITE16_HANDLER( pia_1_msb_w ); -WRITE16_HANDLER( pia_2_msb_w ); -WRITE16_HANDLER( pia_3_msb_w ); -WRITE16_HANDLER( pia_4_msb_w ); -WRITE16_HANDLER( pia_5_msb_w ); -WRITE16_HANDLER( pia_6_msb_w ); -WRITE16_HANDLER( pia_7_msb_w ); - -READ16_HANDLER( pia_0_msb_alt_r ); -READ16_HANDLER( pia_1_msb_alt_r ); -READ16_HANDLER( pia_2_msb_alt_r ); -READ16_HANDLER( pia_3_msb_alt_r ); -READ16_HANDLER( pia_4_msb_alt_r ); -READ16_HANDLER( pia_5_msb_alt_r ); -READ16_HANDLER( pia_6_msb_alt_r ); -READ16_HANDLER( pia_7_msb_alt_r ); - -WRITE16_HANDLER( pia_0_msb_alt_w ); -WRITE16_HANDLER( pia_1_msb_alt_w ); -WRITE16_HANDLER( pia_2_msb_alt_w ); -WRITE16_HANDLER( pia_3_msb_alt_w ); -WRITE16_HANDLER( pia_4_msb_alt_w ); -WRITE16_HANDLER( pia_5_msb_alt_w ); -WRITE16_HANDLER( pia_6_msb_alt_w ); -WRITE16_HANDLER( pia_7_msb_alt_w ); - - - /*--------------- 8-bit A/B port interfaces -------------*/ WRITE8_HANDLER( pia_0_porta_w ); diff --git a/src/emu/memory.c b/src/emu/memory.c index dab459e5e0a..f9ff5f61da3 100644 --- a/src/emu/memory.c +++ b/src/emu/memory.c @@ -204,6 +204,7 @@ typedef enum _read_or_write read_or_write; #endif + /*************************************************************************** TYPE DEFINITIONS ***************************************************************************/ @@ -242,6 +243,9 @@ struct _handler_data memory_handler handler; /* function pointer for handler */ void * object; /* object associated with the handler */ const char * name; /* name of the handler */ + memory_handler subhandler; /* function pointer for subhandler */ + void * subobject; /* object associated with the subhandler */ + UINT32 subshift; /* shift for the subhandler */ offs_t bytestart; /* byte-adjusted start address for handler */ offs_t byteend; /* byte-adjusted end address for handler */ offs_t bytemask; /* byte-adjusted mask against the final address */ @@ -269,6 +273,7 @@ struct _addrspace_data { UINT8 cpunum; /* CPU index */ UINT8 spacenum; /* address space index */ + UINT8 endianness; /* endianness of this space */ INT8 ashift; /* address shift */ UINT8 abits; /* address bits */ UINT8 dbits; /* data bits */ @@ -333,7 +338,7 @@ static bank_info bankdata[STATIC_COUNT]; /* data gathered for each bank */ #ifdef ENABLE_DEBUGGER static debug_hook_read_func debug_hook_read; /* pointer to debugger callback for memory reads */ -static debug_hook_write_func debug_hook_write; /* pointer to debugger callback for memory writes */ +static debug_hook_write_func debug_hook_write; /* pointer to debugger callback for memory writes */ #endif static const data_accessors memory_accessors[ADDRESS_SPACES][4][2] = @@ -412,12 +417,13 @@ static void address_map_detokenize(address_map *map, const addrmap_token *tokens static void memory_init_cpudata(const machine_config *config); static void memory_init_preflight(const machine_config *config); static void memory_init_populate(running_machine *machine); -static void install_mem_handler_private(addrspace_data *space, read_or_write readorwrite, int databits, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, genf *handler, void *object, const char *handler_name); -static void install_mem_handler(addrspace_data *space, read_or_write readorwrite, int databits, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, genf *handler, void *object, const char *handler_name); +static void space_map_range_private(addrspace_data *space, read_or_write readorwrite, int handlerbits, int handlershift, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, genf *handler, void *object, const char *handler_name); +static void space_map_range(addrspace_data *space, read_or_write readorwrite, int handlerbits, int handlershift, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, genf *handler, void *object, const char *handler_name); static void bank_assign_static(int banknum, int cpunum, int spacenum, read_or_write readorwrite, offs_t bytestart, offs_t byteend); static genf *bank_assign_dynamic(int cpunum, int spacenum, read_or_write readorwrite, offs_t bytestart, offs_t byteend); -static UINT8 get_handler_index(handler_data *table, void *object, genf *handler, const char *handler_name, offs_t bytestart, offs_t byteend, offs_t bytemask); -static void populate_table_range(addrspace_data *space, read_or_write readorwrite, offs_t bytestart, offs_t byteend, UINT8 handler); +static UINT8 table_assign_handler(handler_data *table, void *object, genf *handler, const char *handler_name, offs_t bytestart, offs_t byteend, offs_t bytemask); +static void table_populate_range(table_data *tabledata, offs_t bytestart, offs_t byteend, UINT8 handler); +static void table_populate_range_mirrored(table_data *tabledata, offs_t bytestart, offs_t byteend, offs_t bytemirror, UINT8 handler); static UINT8 subtable_alloc(table_data *tabledata); static void subtable_realloc(table_data *tabledata, UINT8 subentry); static int subtable_merge(table_data *tabledata); @@ -430,7 +436,8 @@ static void register_for_save(int cpunum, int spacenum, offs_t bytestart, void * static address_map_entry *assign_intersecting_blocks(addrspace_data *space, offs_t bytestart, offs_t byteend, UINT8 *base); static void memory_init_locate(running_machine *machine); static void *memory_find_base(int cpunum, int spacenum, offs_t byteaddress); -static genf *get_static_handler(int databits, int readorwrite, int spacenum, int which); +static memory_handler get_stub_handler(read_or_write readorwrite, int spacedbits, int spaceendian, int handlerdbits, int handlershift); +static genf *get_static_handler(int handlerbits, int readorwrite, int spacenum, int which); static void memory_exit(running_machine *machine); static void mem_dump(void); @@ -782,11 +789,15 @@ static void address_map_detokenize(address_map *map, const addrmap_token *tokens break; case ADDRMAP_TOKEN_READ: + TOKEN_UNGET_UINT32(tokens); + TOKEN_GET_UINT32_UNPACK3(tokens, entrytype, 8, entry->read_bits, 2, entry->read_shift, 6); entry->read = TOKEN_GET_PTR(tokens, read); entry->read_name = TOKEN_GET_STRING(tokens); break; case ADDRMAP_TOKEN_WRITE: + TOKEN_UNGET_UINT32(tokens); + TOKEN_GET_UINT32_UNPACK3(tokens, entrytype, 8, entry->write_bits, 2, entry->write_shift, 6); entry->write = TOKEN_GET_PTR(tokens, write); entry->write_name = TOKEN_GET_STRING(tokens); break; @@ -1273,7 +1284,7 @@ void *_memory_install_read_handler(int cpunum, int spacenum, offs_t addrstart, o addrspace_data *space = &cpudata[cpunum].space[spacenum]; if (handler >= STATIC_COUNT) fatalerror("fatal: can only use static banks with memory_install_read_handler()"); - install_mem_handler(space, ROW_READ, space->dbits, addrstart, addrend, addrmask, addrmirror, (genf *)(FPTR)handler, Machine, handler_name); + space_map_range(space, ROW_READ, space->dbits, 0, addrstart, addrend, addrmask, addrmirror, (genf *)(FPTR)handler, Machine, handler_name); mem_dump(); return memory_find_base(cpunum, spacenum, ADDR2BYTE(space, addrstart)); } @@ -1281,7 +1292,7 @@ void *_memory_install_read_handler(int cpunum, int spacenum, offs_t addrstart, o UINT8 *_memory_install_read8_handler(int cpunum, int spacenum, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read8_machine_func handler, const char *handler_name) { addrspace_data *space = &cpudata[cpunum].space[spacenum]; - install_mem_handler(space, ROW_READ, 8, addrstart, addrend, addrmask, addrmirror, (genf *)handler, Machine, handler_name); + space_map_range(space, ROW_READ, 8, 0, addrstart, addrend, addrmask, addrmirror, (genf *)handler, Machine, handler_name); mem_dump(); return memory_find_base(cpunum, spacenum, ADDR2BYTE(space, addrstart)); } @@ -1289,7 +1300,7 @@ UINT8 *_memory_install_read8_handler(int cpunum, int spacenum, offs_t addrstart, UINT16 *_memory_install_read16_handler(int cpunum, int spacenum, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read16_machine_func handler, const char *handler_name) { addrspace_data *space = &cpudata[cpunum].space[spacenum]; - install_mem_handler(space, ROW_READ, 16, addrstart, addrend, addrmask, addrmirror, (genf *)handler, Machine, handler_name); + space_map_range(space, ROW_READ, 16, 0, addrstart, addrend, addrmask, addrmirror, (genf *)handler, Machine, handler_name); mem_dump(); return memory_find_base(cpunum, spacenum, ADDR2BYTE(space, addrstart)); } @@ -1297,7 +1308,7 @@ UINT16 *_memory_install_read16_handler(int cpunum, int spacenum, offs_t addrstar UINT32 *_memory_install_read32_handler(int cpunum, int spacenum, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read32_machine_func handler, const char *handler_name) { addrspace_data *space = &cpudata[cpunum].space[spacenum]; - install_mem_handler(space, ROW_READ, 32, addrstart, addrend, addrmask, addrmirror, (genf *)handler, Machine, handler_name); + space_map_range(space, ROW_READ, 32, 0, addrstart, addrend, addrmask, addrmirror, (genf *)handler, Machine, handler_name); mem_dump(); return memory_find_base(cpunum, spacenum, ADDR2BYTE(space, addrstart)); } @@ -1305,7 +1316,7 @@ UINT32 *_memory_install_read32_handler(int cpunum, int spacenum, offs_t addrstar UINT64 *_memory_install_read64_handler(int cpunum, int spacenum, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read64_machine_func handler, const char *handler_name) { addrspace_data *space = &cpudata[cpunum].space[spacenum]; - install_mem_handler(space, ROW_READ, 64, addrstart, addrend, addrmask, addrmirror, (genf *)handler, Machine, handler_name); + space_map_range(space, ROW_READ, 64, 0, addrstart, addrend, addrmask, addrmirror, (genf *)handler, Machine, handler_name); mem_dump(); return memory_find_base(cpunum, spacenum, ADDR2BYTE(space, addrstart)); } @@ -1321,7 +1332,7 @@ void *_memory_install_write_handler(int cpunum, int spacenum, offs_t addrstart, addrspace_data *space = &cpudata[cpunum].space[spacenum]; if (handler >= STATIC_COUNT) fatalerror("fatal: can only use static banks with memory_install_write_handler()"); - install_mem_handler(space, ROW_WRITE, space->dbits, addrstart, addrend, addrmask, addrmirror, (genf *)handler, Machine, handler_name); + space_map_range(space, ROW_WRITE, space->dbits, 0, addrstart, addrend, addrmask, addrmirror, (genf *)handler, Machine, handler_name); mem_dump(); return memory_find_base(cpunum, spacenum, ADDR2BYTE(space, addrstart)); } @@ -1329,7 +1340,7 @@ void *_memory_install_write_handler(int cpunum, int spacenum, offs_t addrstart, UINT8 *_memory_install_write8_handler(int cpunum, int spacenum, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, write8_machine_func handler, const char *handler_name) { addrspace_data *space = &cpudata[cpunum].space[spacenum]; - install_mem_handler(space, ROW_WRITE, 8, addrstart, addrend, addrmask, addrmirror, (genf *)handler, Machine, handler_name); + space_map_range(space, ROW_WRITE, 8, 0, addrstart, addrend, addrmask, addrmirror, (genf *)handler, Machine, handler_name); mem_dump(); return memory_find_base(cpunum, spacenum, ADDR2BYTE(space, addrstart)); } @@ -1337,7 +1348,7 @@ UINT8 *_memory_install_write8_handler(int cpunum, int spacenum, offs_t addrstart UINT16 *_memory_install_write16_handler(int cpunum, int spacenum, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, write16_machine_func handler, const char *handler_name) { addrspace_data *space = &cpudata[cpunum].space[spacenum]; - install_mem_handler(space, ROW_WRITE, 16, addrstart, addrend, addrmask, addrmirror, (genf *)handler, Machine, handler_name); + space_map_range(space, ROW_WRITE, 16, 0, addrstart, addrend, addrmask, addrmirror, (genf *)handler, Machine, handler_name); mem_dump(); return memory_find_base(cpunum, spacenum, ADDR2BYTE(space, addrstart)); } @@ -1345,7 +1356,7 @@ UINT16 *_memory_install_write16_handler(int cpunum, int spacenum, offs_t addrsta UINT32 *_memory_install_write32_handler(int cpunum, int spacenum, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, write32_machine_func handler, const char *handler_name) { addrspace_data *space = &cpudata[cpunum].space[spacenum]; - install_mem_handler(space, ROW_WRITE, 32, addrstart, addrend, addrmask, addrmirror, (genf *)handler, Machine, handler_name); + space_map_range(space, ROW_WRITE, 32, 0, addrstart, addrend, addrmask, addrmirror, (genf *)handler, Machine, handler_name); mem_dump(); return memory_find_base(cpunum, spacenum, ADDR2BYTE(space, addrstart)); } @@ -1353,7 +1364,7 @@ UINT32 *_memory_install_write32_handler(int cpunum, int spacenum, offs_t addrsta UINT64 *_memory_install_write64_handler(int cpunum, int spacenum, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, write64_machine_func handler, const char *handler_name) { addrspace_data *space = &cpudata[cpunum].space[spacenum]; - install_mem_handler(space, ROW_WRITE, 64, addrstart, addrend, addrmask, addrmirror, (genf *)handler, Machine, handler_name); + space_map_range(space, ROW_WRITE, 64, 0, addrstart, addrend, addrmask, addrmirror, (genf *)handler, Machine, handler_name); mem_dump(); return memory_find_base(cpunum, spacenum, ADDR2BYTE(space, addrstart)); } @@ -1369,8 +1380,8 @@ void *_memory_install_readwrite_handler(int cpunum, int spacenum, offs_t addrsta addrspace_data *space = &cpudata[cpunum].space[spacenum]; if (rhandler >= STATIC_COUNT || whandler >= STATIC_COUNT) fatalerror("fatal: can only use static banks with memory_install_readwrite_handler()"); - install_mem_handler(space, ROW_READ, space->dbits, addrstart, addrend, addrmask, addrmirror, (genf *)(FPTR)rhandler, Machine, rhandler_name); - install_mem_handler(space, ROW_WRITE, space->dbits, addrstart, addrend, addrmask, addrmirror, (genf *)(FPTR)whandler, Machine, whandler_name); + space_map_range(space, ROW_READ, space->dbits, 0, addrstart, addrend, addrmask, addrmirror, (genf *)(FPTR)rhandler, Machine, rhandler_name); + space_map_range(space, ROW_WRITE, space->dbits, 0, addrstart, addrend, addrmask, addrmirror, (genf *)(FPTR)whandler, Machine, whandler_name); mem_dump(); return memory_find_base(cpunum, spacenum, ADDR2BYTE(space, addrstart)); } @@ -1378,8 +1389,8 @@ void *_memory_install_readwrite_handler(int cpunum, int spacenum, offs_t addrsta UINT8 *_memory_install_readwrite8_handler(int cpunum, int spacenum, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read8_machine_func rhandler, write8_machine_func whandler, const char *rhandler_name, const char *whandler_name) { addrspace_data *space = &cpudata[cpunum].space[spacenum]; - install_mem_handler(space, ROW_READ, 8, addrstart, addrend, addrmask, addrmirror, (genf *)rhandler, Machine, rhandler_name); - install_mem_handler(space, ROW_WRITE, 8, addrstart, addrend, addrmask, addrmirror, (genf *)whandler, Machine, whandler_name); + space_map_range(space, ROW_READ, 8, 0, addrstart, addrend, addrmask, addrmirror, (genf *)rhandler, Machine, rhandler_name); + space_map_range(space, ROW_WRITE, 8, 0, addrstart, addrend, addrmask, addrmirror, (genf *)whandler, Machine, whandler_name); mem_dump(); return memory_find_base(cpunum, spacenum, ADDR2BYTE(space, addrstart)); } @@ -1387,8 +1398,8 @@ UINT8 *_memory_install_readwrite8_handler(int cpunum, int spacenum, offs_t addrs UINT16 *_memory_install_readwrite16_handler(int cpunum, int spacenum, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read16_machine_func rhandler, write16_machine_func whandler, const char *rhandler_name, const char *whandler_name) { addrspace_data *space = &cpudata[cpunum].space[spacenum]; - install_mem_handler(space, ROW_READ, 16, addrstart, addrend, addrmask, addrmirror, (genf *)rhandler, Machine, rhandler_name); - install_mem_handler(space, ROW_WRITE, 16, addrstart, addrend, addrmask, addrmirror, (genf *)whandler, Machine, whandler_name); + space_map_range(space, ROW_READ, 16, 0, addrstart, addrend, addrmask, addrmirror, (genf *)rhandler, Machine, rhandler_name); + space_map_range(space, ROW_WRITE, 16, 0, addrstart, addrend, addrmask, addrmirror, (genf *)whandler, Machine, whandler_name); mem_dump(); return memory_find_base(cpunum, spacenum, ADDR2BYTE(space, addrstart)); } @@ -1396,8 +1407,8 @@ UINT16 *_memory_install_readwrite16_handler(int cpunum, int spacenum, offs_t add UINT32 *_memory_install_readwrite32_handler(int cpunum, int spacenum, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read32_machine_func rhandler, write32_machine_func whandler, const char *rhandler_name, const char *whandler_name) { addrspace_data *space = &cpudata[cpunum].space[spacenum]; - install_mem_handler(space, ROW_READ, 32, addrstart, addrend, addrmask, addrmirror, (genf *)rhandler, Machine, rhandler_name); - install_mem_handler(space, ROW_WRITE, 32, addrstart, addrend, addrmask, addrmirror, (genf *)whandler, Machine, whandler_name); + space_map_range(space, ROW_READ, 32, 0, addrstart, addrend, addrmask, addrmirror, (genf *)rhandler, Machine, rhandler_name); + space_map_range(space, ROW_WRITE, 32, 0, addrstart, addrend, addrmask, addrmirror, (genf *)whandler, Machine, whandler_name); mem_dump(); return memory_find_base(cpunum, spacenum, ADDR2BYTE(space, addrstart)); } @@ -1405,8 +1416,8 @@ UINT32 *_memory_install_readwrite32_handler(int cpunum, int spacenum, offs_t add UINT64 *_memory_install_readwrite64_handler(int cpunum, int spacenum, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read64_machine_func rhandler, write64_machine_func whandler, const char *rhandler_name, const char *whandler_name) { addrspace_data *space = &cpudata[cpunum].space[spacenum]; - install_mem_handler(space, ROW_READ, 64, addrstart, addrend, addrmask, addrmirror, (genf *)rhandler, Machine, rhandler_name); - install_mem_handler(space, ROW_WRITE, 64, addrstart, addrend, addrmask, addrmirror, (genf *)whandler, Machine, whandler_name); + space_map_range(space, ROW_READ, 64, 0, addrstart, addrend, addrmask, addrmirror, (genf *)rhandler, Machine, rhandler_name); + space_map_range(space, ROW_WRITE, 64, 0, addrstart, addrend, addrmask, addrmirror, (genf *)whandler, Machine, whandler_name); mem_dump(); return memory_find_base(cpunum, spacenum, ADDR2BYTE(space, addrstart)); } @@ -1443,12 +1454,13 @@ static void memory_init_cpudata(const machine_config *config) /* determine the address and data bits */ space->cpunum = cpunum; space->spacenum = spacenum; + space->endianness = cputype_endianness(cputype); space->ashift = cputype_addrbus_shift(cputype, spacenum); space->abits = cputype_addrbus_width(cputype, spacenum); space->dbits = cputype_databus_width(cputype, spacenum); space->addrmask = 0xffffffffUL >> (32 - space->abits); space->bytemask = ADDR2BYTE_END(space, space->addrmask); - space->accessors = memory_get_accessors(spacenum, space->dbits, cputype_endianness(cputype)); + space->accessors = memory_get_accessors(spacenum, space->dbits, space->endianness); space->map = NULL; /* if there's nothing here, just punt */ @@ -1614,6 +1626,7 @@ static void memory_init_populate(running_machine *machine) if (entry->read.generic != NULL) { + int bits = (entry->read_bits == 0) ? space->dbits : (4 << entry->read_bits); void *object = machine; if (entry->read_devtype != NULL) { @@ -1621,10 +1634,11 @@ static void memory_init_populate(running_machine *machine) if (object == NULL) fatalerror("Unidentified object in memory map: type=%s tag=%s\n", devtype_name(entry->read_devtype), entry->read_devtag); } - install_mem_handler_private(space, ROW_READ, space->dbits, entry->addrstart, entry->addrend, entry->addrmask, entry->addrmirror, entry->read.generic, object, entry->read_name); + space_map_range_private(space, ROW_READ, bits, entry->read_shift, entry->addrstart, entry->addrend, entry->addrmask, entry->addrmirror, entry->read.generic, object, entry->read_name); } if (entry->write.generic != NULL) { + int bits = (entry->write_bits == 0) ? space->dbits : (4 << entry->write_bits); void *object = machine; if (entry->write_devtype != NULL) { @@ -1632,7 +1646,7 @@ static void memory_init_populate(running_machine *machine) if (object == NULL) fatalerror("Unidentified object in memory map: type=%s tag=%s\n", devtype_name(entry->write_devtype), entry->write_devtag); } - install_mem_handler_private(space, ROW_WRITE, space->dbits, entry->addrstart, entry->addrend, entry->addrmask, entry->addrmirror, entry->write.generic, object, entry->write_name); + space_map_range_private(space, ROW_WRITE, bits, entry->write_shift, entry->addrstart, entry->addrend, entry->addrmask, entry->addrmirror, entry->write.generic, object, entry->write_name); } } } @@ -1641,13 +1655,13 @@ static void memory_init_populate(running_machine *machine) /*------------------------------------------------- - install_mem_handler_private - wrapper for - install_mem_handler which is used at + space_map_range_private - wrapper for + space_map_range which is used at initialization time and converts RAM/ROM banks to dynamically assigned banks -------------------------------------------------*/ -static void install_mem_handler_private(addrspace_data *space, read_or_write readorwrite, int databits, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, genf *handler, void *object, const char *handler_name) +static void space_map_range_private(addrspace_data *space, read_or_write readorwrite, int handlerbits, int handlershift, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, genf *handler, void *object, const char *handler_name) { /* translate ROM to RAM/UNMAP here */ if (HANDLER_IS_ROM(handler)) @@ -1671,31 +1685,25 @@ static void install_mem_handler_private(addrspace_data *space, read_or_write rea } /* then do a normal installation */ - install_mem_handler(space, readorwrite, databits, addrstart, addrend, addrmask, addrmirror, handler, object, handler_name); + space_map_range(space, readorwrite, handlerbits, handlershift, addrstart, addrend, addrmask, addrmirror, handler, object, handler_name); } /*------------------------------------------------- - install_mem_handler - installs a handler for - memory operations + space_map_range - maps a range of addresses + to the specified handler within an address + space -------------------------------------------------*/ -static void install_mem_handler(addrspace_data *space, read_or_write readorwrite, int databits, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, genf *handler, void *object, const char *handler_name) +static void space_map_range(addrspace_data *space, read_or_write readorwrite, int handlerbits, int handlershift, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, genf *handler, void *object, const char *handler_name) { - offs_t lmirrorbit[LEVEL2_BITS], lmirrorbits, hmirrorbit[32 - LEVEL2_BITS], hmirrorbits, lmirrorcount, hmirrorcount; table_data *tabledata = (readorwrite == ROW_WRITE) ? &space->write : &space->read; offs_t bytestart, byteend, bytemask, bytemirror; - UINT8 idx, prev_entry = STATIC_INVALID; - int cur_index, prev_index = 0; - int i; + UINT8 entry; - /* sanity check */ - if (HANDLER_IS_ROM(handler) || HANDLER_IS_RAM(handler)) - fatalerror("fatal: install_mem_handler called with ROM or RAM after initialization"); - if (space->dbits != databits) - fatalerror("fatal: install_mem_handler called with a %d-bit handler for a %d-bit address space", databits, space->dbits); - if (addrstart > addrend) - fatalerror("fatal: install_mem_handler called with start greater than end"); + /* sanity checks */ + assert(space != NULL); + assert(handlerbits == 8 || handlerbits == 16 || handlerbits == 32 || handlerbits == 64); /* adjust the incoming addresses */ bytestart = addrstart; @@ -1704,71 +1712,42 @@ static void install_mem_handler(addrspace_data *space, read_or_write readorwrite bytemask = addrmask; adjust_addresses(space, &bytestart, &byteend, &bytemask, &bytemirror); + /* validity checks */ + assert_always(!HANDLER_IS_ROM(handler), "space_map_range called with ROM after initialization"); + assert_always(!HANDLER_IS_RAM(handler), "space_map_range called with RAM after initialization"); + assert_always(addrstart <= addrend, "space_map_range called with start greater than end"); + assert_always(handlerbits <= space->dbits, "space_map_range called with handlers larger than the address space"); + assert_always(handlershift == SHIFT_PACKED || handlerbits + handlershift <= space->dbits, "space_map_range called with out-of-range handlershift"); + assert_always((bytestart & (space->dbits / 8 - 1)) == 0, "space_map_range called with misaligned start address"); + assert_always((byteend & (space->dbits / 8 - 1)) == (space->dbits / 8 - 1), "space_map_range called with misaligned end address"); + /* if we're installing a new bank, make sure we mark it */ if (HANDLER_IS_BANK(handler)) bank_assign_static(HANDLER_TO_BANK(handler), space->cpunum, space->spacenum, readorwrite, bytestart, byteend); - /* determine the mirror bits */ - hmirrorbits = lmirrorbits = 0; - for (i = 0; i < LEVEL2_BITS; i++) - if (bytemirror & (1 << i)) - lmirrorbit[lmirrorbits++] = 1 << i; - for (i = LEVEL2_BITS; i < 32; i++) - if (bytemirror & (1 << i)) - hmirrorbit[hmirrorbits++] = 1 << i; - /* get the final handler index */ - idx = get_handler_index(tabledata->handlers, object, handler, handler_name, bytestart, byteend, bytemask); + entry = table_assign_handler(tabledata->handlers, object, handler, handler_name, bytestart, byteend, bytemask); - /* loop over mirrors in the level 2 table */ - for (hmirrorcount = 0; hmirrorcount < (1 << hmirrorbits); hmirrorcount++) + /* fix up the handler if a stub is required */ + if (handlerbits != space->dbits) { - /* compute the base of this mirror */ - offs_t hmirrorbase = 0; - for (i = 0; i < hmirrorbits; i++) - if (hmirrorcount & (1 << i)) - hmirrorbase |= hmirrorbit[i]; - - /* if this is not our first time through, and the level 2 entry matches the previous - level 2 entry, just do a quick map and get out; note that this only works for entries - which don't span multiple level 1 table entries */ - cur_index = LEVEL1_INDEX(bytestart + hmirrorbase); - if (cur_index == LEVEL1_INDEX(byteend + hmirrorbase)) - { - if (hmirrorcount != 0 && prev_entry == tabledata->table[cur_index]) - { - VPRINTF(("Quick mapping subtable at %08X to match subtable at %08X\n", cur_index << LEVEL2_BITS, prev_index << LEVEL2_BITS)); - - /* release the subtable if the old value was a subtable */ - if (tabledata->table[cur_index] >= SUBTABLE_BASE) - subtable_release(tabledata, tabledata->table[cur_index]); - - /* reallocate the subtable if the new value is a subtable */ - if (tabledata->table[prev_index] >= SUBTABLE_BASE) - subtable_realloc(tabledata, tabledata->table[prev_index]); - - /* set the new value and short-circuit the mapping step */ - tabledata->table[cur_index] = tabledata->table[prev_index]; - continue; - } - prev_index = cur_index; - prev_entry = tabledata->table[cur_index]; - } - - /* loop over mirrors in the level 1 table */ - for (lmirrorcount = 0; lmirrorcount < (1 << lmirrorbits); lmirrorcount++) - { - /* compute the base of this mirror */ - offs_t lmirrorbase = hmirrorbase; - for (i = 0; i < lmirrorbits; i++) - if (lmirrorcount & (1 << i)) - lmirrorbase |= lmirrorbit[i]; - - /* populate the tables */ - populate_table_range(space, readorwrite, bytestart + lmirrorbase, byteend + lmirrorbase, idx); - } + handler_data *hdata = &tabledata->handlers[entry]; + + assert_always(!HANDLER_IS_STATIC(entry), "space_map_range called with static handlers and mismatched data bus widths"); + + /* copy raw data to the subhandler data */ + hdata->subobject = hdata->object; + hdata->subhandler = hdata->handler; + hdata->subshift = handlershift; + + /* fill in a stub as the real handler */ + hdata->object = hdata; + hdata->handler = get_stub_handler(readorwrite, space->dbits, space->endianness, handlerbits, handlershift); } + /* populate it */ + table_populate_range_mirrored(tabledata, bytestart, byteend, bytemirror, entry); + /* if this is being installed to a live CPU, update the context */ if (space->cpunum == cur_context) memory_set_context(cur_context); @@ -1842,11 +1821,11 @@ static genf *bank_assign_dynamic(int cpunum, int spacenum, read_or_write readorw /*------------------------------------------------- - get_handler_index - finds the index of a + table_assign_handler - finds the index of a handler, or allocates a new one as necessary -------------------------------------------------*/ -static UINT8 get_handler_index(handler_data *table, void *object, genf *handler, const char *handler_name, offs_t bytestart, offs_t byteend, offs_t bytemask) +static UINT8 table_assign_handler(handler_data *table, void *object, genf *handler, const char *handler_name, offs_t bytestart, offs_t byteend, offs_t bytemask) { int entry; @@ -1893,13 +1872,12 @@ static UINT8 get_handler_index(handler_data *table, void *object, genf *handler, /*------------------------------------------------- - populate_table_range - assign a memory handler + table_populate_range - assign a memory handler to a range of addresses -------------------------------------------------*/ -static void populate_table_range(addrspace_data *space, read_or_write readorwrite, offs_t bytestart, offs_t byteend, UINT8 handler) +static void table_populate_range(table_data *tabledata, offs_t bytestart, offs_t byteend, UINT8 handler) { - table_data *tabledata = (readorwrite == ROW_WRITE) ? &space->write : &space->read; offs_t l2mask = (1 << LEVEL2_BITS) - 1; offs_t l1start = bytestart >> LEVEL2_BITS; offs_t l2start = bytestart & l2mask; @@ -1956,6 +1934,79 @@ static void populate_table_range(addrspace_data *space, read_or_write readorwrit } +/*------------------------------------------------- + table_populate_range_mirrored - assign a + memory handler to a range of addresses + including mirrors +-------------------------------------------------*/ + +static void table_populate_range_mirrored(table_data *tabledata, offs_t bytestart, offs_t byteend, offs_t bytemirror, UINT8 handler) +{ + offs_t lmirrorbit[LEVEL2_BITS], lmirrorbits, hmirrorbit[32 - LEVEL2_BITS], hmirrorbits, lmirrorcount, hmirrorcount; + UINT8 prev_entry = STATIC_INVALID; + int cur_index, prev_index = 0; + int i; + + /* determine the mirror bits */ + hmirrorbits = lmirrorbits = 0; + for (i = 0; i < LEVEL2_BITS; i++) + if (bytemirror & (1 << i)) + lmirrorbit[lmirrorbits++] = 1 << i; + for (i = LEVEL2_BITS; i < 32; i++) + if (bytemirror & (1 << i)) + hmirrorbit[hmirrorbits++] = 1 << i; + + /* loop over mirrors in the level 2 table */ + for (hmirrorcount = 0; hmirrorcount < (1 << hmirrorbits); hmirrorcount++) + { + /* compute the base of this mirror */ + offs_t hmirrorbase = 0; + for (i = 0; i < hmirrorbits; i++) + if (hmirrorcount & (1 << i)) + hmirrorbase |= hmirrorbit[i]; + + /* if this is not our first time through, and the level 2 entry matches the previous + level 2 entry, just do a quick map and get out; note that this only works for entries + which don't span multiple level 1 table entries */ + cur_index = LEVEL1_INDEX(bytestart + hmirrorbase); + if (cur_index == LEVEL1_INDEX(byteend + hmirrorbase)) + { + if (hmirrorcount != 0 && prev_entry == tabledata->table[cur_index]) + { + VPRINTF(("Quick mapping subtable at %08X to match subtable at %08X\n", cur_index << LEVEL2_BITS, prev_index << LEVEL2_BITS)); + + /* release the subtable if the old value was a subtable */ + if (tabledata->table[cur_index] >= SUBTABLE_BASE) + subtable_release(tabledata, tabledata->table[cur_index]); + + /* reallocate the subtable if the new value is a subtable */ + if (tabledata->table[prev_index] >= SUBTABLE_BASE) + subtable_realloc(tabledata, tabledata->table[prev_index]); + + /* set the new value and short-circuit the mapping step */ + tabledata->table[cur_index] = tabledata->table[prev_index]; + continue; + } + prev_index = cur_index; + prev_entry = tabledata->table[cur_index]; + } + + /* loop over mirrors in the level 1 table */ + for (lmirrorcount = 0; lmirrorcount < (1 << lmirrorbits); lmirrorcount++) + { + /* compute the base of this mirror */ + offs_t lmirrorbase = hmirrorbase; + for (i = 0; i < lmirrorbits; i++) + if (lmirrorcount & (1 << i)) + lmirrorbase |= lmirrorbit[i]; + + /* populate the tables */ + table_populate_range(tabledata, bytestart + lmirrorbase, byteend + lmirrorbase, handler); + } + } +} + + /*------------------------------------------------- subtable_alloc - allocate a fresh subtable and set its usecount to 1 @@ -2697,11 +2748,11 @@ static WRITE64_HANDLER( mwh64_nop ) { } memory handlers -------------------------------------------------*/ -static genf *get_static_handler(int databits, int readorwrite, int spacenum, int which) +static genf *get_static_handler(int handlerbits, int readorwrite, int spacenum, int which) { static const struct { - UINT8 databits; + UINT8 handlerbits; UINT8 handlernum; UINT8 spacenum; genf * read; @@ -2739,7 +2790,7 @@ static genf *get_static_handler(int databits, int readorwrite, int spacenum, int int tablenum; for (tablenum = 0; tablenum < sizeof(static_handler_list) / sizeof(static_handler_list[0]); tablenum++) - if (static_handler_list[tablenum].databits == databits && static_handler_list[tablenum].handlernum == which) + if (static_handler_list[tablenum].handlerbits == handlerbits && static_handler_list[tablenum].handlernum == which) if (static_handler_list[tablenum].spacenum == 0xff || static_handler_list[tablenum].spacenum == spacenum) return readorwrite ? static_handler_list[tablenum].write : static_handler_list[tablenum].read; @@ -2944,7 +2995,836 @@ static void mem_dump(void) +/*************************************************************************** + STUB HANDLERS THAT MAP TO BYTE READS +***************************************************************************/ +/*------------------------------------------------- + stub_read8_from_16_shifted - return a 16-bit + value from a single byte access in a + particular lane +-------------------------------------------------*/ + +static READ16_HANDLER( stub_read8_from_16_shifted ) +{ + handler_data *handler = (handler_data *)machine; + if ((UINT8)(mem_mask >> handler->subshift) != 0xff) + return (*handler->subhandler.read.mhandler8)(handler->subobject, offset) << handler->subshift; + else + return 0; +} + + +/*------------------------------------------------- + stub_read8_from_16le_packed - return a 16-bit + value combined from one or more byte accesses +-------------------------------------------------*/ + +static READ16_HANDLER( stub_read8_from_16le_packed ) +{ + handler_data *handler = (handler_data *)machine; + UINT16 result = 0; + if (ACCESSING_BITS_0_7) + result |= (*handler->subhandler.read.mhandler8)(handler->subobject, offset * 2 + 0) << 0; + if (ACCESSING_BITS_8_15) + result |= (*handler->subhandler.read.mhandler8)(handler->subobject, offset * 2 + 1) << 8; + return result; +} + + +/*------------------------------------------------- + stub_read8_from_16be_packed - return a 16-bit + value combined from one or more byte accesses +-------------------------------------------------*/ + +static READ16_HANDLER( stub_read8_from_16be_packed ) +{ + handler_data *handler = (handler_data *)machine; + UINT16 result = 0; + if (ACCESSING_BITS_8_15) + result |= (*handler->subhandler.read.mhandler8)(handler->subobject, offset * 2 + 0) << 8; + if (ACCESSING_BITS_0_7) + result |= (*handler->subhandler.read.mhandler8)(handler->subobject, offset * 2 + 1) << 0; + return result; +} + + +/*------------------------------------------------- + stub_read8_from_32_shifted - return a 32-bit + value from a single byte access in a + particular lane +-------------------------------------------------*/ + +static READ32_HANDLER( stub_read8_from_32_shifted ) +{ + handler_data *handler = (handler_data *)machine; + if ((UINT8)(mem_mask >> handler->subshift) != 0xff) + return (*handler->subhandler.read.mhandler8)(handler->subobject, offset) << handler->subshift; + else + return 0; +} + + +/*------------------------------------------------- + stub_read8_from_32le_packed - return a 32-bit + value combined from one or more byte accesses +-------------------------------------------------*/ + +static READ32_HANDLER( stub_read8_from_32le_packed ) +{ + handler_data *handler = (handler_data *)machine; + UINT32 result = 0; + if (ACCESSING_BITS_0_7) + result |= (*handler->subhandler.read.mhandler8)(handler->subobject, offset * 4 + 0) << 0; + if (ACCESSING_BITS_8_15) + result |= (*handler->subhandler.read.mhandler8)(handler->subobject, offset * 4 + 1) << 8; + if (ACCESSING_BITS_16_23) + result |= (*handler->subhandler.read.mhandler8)(handler->subobject, offset * 4 + 2) << 16; + if (ACCESSING_BITS_24_31) + result |= (*handler->subhandler.read.mhandler8)(handler->subobject, offset * 4 + 3) << 24; + return result; +} + + +/*------------------------------------------------- + stub_read8_from_32be_packed - return a 32-bit + value combined from one or more byte accesses +-------------------------------------------------*/ + +static READ32_HANDLER( stub_read8_from_32be_packed ) +{ + handler_data *handler = (handler_data *)machine; + UINT32 result = 0; + if (ACCESSING_BITS_24_31) + result |= (*handler->subhandler.read.mhandler8)(handler->subobject, offset * 4 + 0) << 24; + if (ACCESSING_BITS_16_23) + result |= (*handler->subhandler.read.mhandler8)(handler->subobject, offset * 4 + 1) << 16; + if (ACCESSING_BITS_8_15) + result |= (*handler->subhandler.read.mhandler8)(handler->subobject, offset * 4 + 2) << 8; + if (ACCESSING_BITS_0_7) + result |= (*handler->subhandler.read.mhandler8)(handler->subobject, offset * 4 + 3) << 0; + return result; +} + + +/*------------------------------------------------- + stub_read8_from_64_shifted - return a 64-bit + value from a single byte access in a + particular lane +-------------------------------------------------*/ + +static READ64_HANDLER( stub_read8_from_64_shifted ) +{ + handler_data *handler = (handler_data *)machine; + if ((UINT8)(mem_mask >> handler->subshift) != 0xff) + return (UINT64)(*handler->subhandler.read.mhandler8)(handler->subobject, offset) << handler->subshift; + else + return 0; +} + + +/*------------------------------------------------- + stub_read8_from_64le_packed - return a 64-bit + value combined from one or more byte accesses +-------------------------------------------------*/ + +static READ64_HANDLER( stub_read8_from_64le_packed ) +{ + handler_data *handler = (handler_data *)machine; + UINT64 result = 0; + if (ACCESSING_BITS_0_7) + result |= (*handler->subhandler.read.mhandler8)(handler->subobject, offset * 8 + 0) << 0; + if (ACCESSING_BITS_8_15) + result |= (*handler->subhandler.read.mhandler8)(handler->subobject, offset * 8 + 1) << 8; + if (ACCESSING_BITS_16_23) + result |= (*handler->subhandler.read.mhandler8)(handler->subobject, offset * 8 + 2) << 16; + if (ACCESSING_BITS_24_31) + result |= (*handler->subhandler.read.mhandler8)(handler->subobject, offset * 8 + 3) << 24; + if (ACCESSING_BITS_32_39) + result |= (UINT64)(*handler->subhandler.read.mhandler8)(handler->subobject, offset * 8 + 4) << 32; + if (ACCESSING_BITS_40_47) + result |= (UINT64)(*handler->subhandler.read.mhandler8)(handler->subobject, offset * 8 + 5) << 40; + if (ACCESSING_BITS_48_55) + result |= (UINT64)(*handler->subhandler.read.mhandler8)(handler->subobject, offset * 8 + 6) << 48; + if (ACCESSING_BITS_56_63) + result |= (UINT64)(*handler->subhandler.read.mhandler8)(handler->subobject, offset * 8 + 7) << 56; + return result; +} + + +/*------------------------------------------------- + stub_read8_from_64be_packed - return a 64-bit + value combined from one or more byte accesses +-------------------------------------------------*/ + +static READ64_HANDLER( stub_read8_from_64be_packed ) +{ + handler_data *handler = (handler_data *)machine; + UINT64 result = 0; + if (ACCESSING_BITS_56_63) + result |= (UINT64)(*handler->subhandler.read.mhandler8)(handler->subobject, offset * 8 + 0) << 56; + if (ACCESSING_BITS_48_55) + result |= (UINT64)(*handler->subhandler.read.mhandler8)(handler->subobject, offset * 8 + 1) << 48; + if (ACCESSING_BITS_40_47) + result |= (UINT64)(*handler->subhandler.read.mhandler8)(handler->subobject, offset * 8 + 2) << 40; + if (ACCESSING_BITS_32_39) + result |= (UINT64)(*handler->subhandler.read.mhandler8)(handler->subobject, offset * 8 + 3) << 32; + if (ACCESSING_BITS_24_31) + result |= (*handler->subhandler.read.mhandler8)(handler->subobject, offset * 8 + 4) << 24; + if (ACCESSING_BITS_16_23) + result |= (*handler->subhandler.read.mhandler8)(handler->subobject, offset * 8 + 5) << 16; + if (ACCESSING_BITS_8_15) + result |= (*handler->subhandler.read.mhandler8)(handler->subobject, offset * 8 + 6) << 8; + if (ACCESSING_BITS_0_7) + result |= (*handler->subhandler.read.mhandler8)(handler->subobject, offset * 8 + 7) << 0; + return result; +} + + + +/*************************************************************************** + STUB HANDLERS THAT MAP TO BYTE WRITES +***************************************************************************/ + +/*------------------------------------------------- + stub_write8_from_16_shifted - write a 16-bit + value to a single byte lane +-------------------------------------------------*/ + +static WRITE16_HANDLER( stub_write8_from_16_shifted ) +{ + handler_data *handler = (handler_data *)machine; + if ((UINT8)(mem_mask >> handler->subshift) != 0xff) + (*handler->subhandler.write.mhandler8)(handler->subobject, offset, data >> handler->subshift); +} + + +/*------------------------------------------------- + stub_write8_from_16le_packed - convert a 16-bit + write to one or more byte accesses +-------------------------------------------------*/ + +static WRITE16_HANDLER( stub_write8_from_16le_packed ) +{ + handler_data *handler = (handler_data *)machine; + if (ACCESSING_BITS_0_7) + (*handler->subhandler.write.mhandler8)(handler->subobject, offset * 2 + 0, data >> 0); + if (ACCESSING_BITS_8_15) + (*handler->subhandler.write.mhandler8)(handler->subobject, offset * 2 + 1, data >> 8); +} + + +/*------------------------------------------------- + stub_write8_from_16be_packed - convert a 16-bit + write to one or more byte accesses +-------------------------------------------------*/ + +static WRITE16_HANDLER( stub_write8_from_16be_packed ) +{ + handler_data *handler = (handler_data *)machine; + if (ACCESSING_BITS_8_15) + (*handler->subhandler.write.mhandler8)(handler->subobject, offset * 2 + 0, data >> 8); + if (ACCESSING_BITS_0_7) + (*handler->subhandler.write.mhandler8)(handler->subobject, offset * 2 + 1, data >> 0); +} + + +/*------------------------------------------------- + stub_write8_from_32_shifted - write a 32-bit + value to a single byte lane +-------------------------------------------------*/ + +static WRITE32_HANDLER( stub_write8_from_32_shifted ) +{ + handler_data *handler = (handler_data *)machine; + if ((UINT8)(mem_mask >> handler->subshift) != 0xff) + (*handler->subhandler.write.mhandler8)(handler->subobject, offset, data >> handler->subshift); +} + + +/*------------------------------------------------- + stub_write8_from_32le_packed - convert a 32-bit + write to one or more byte accesses +-------------------------------------------------*/ + +static WRITE32_HANDLER( stub_write8_from_32le_packed ) +{ + handler_data *handler = (handler_data *)machine; + if (ACCESSING_BITS_0_7) + (*handler->subhandler.write.mhandler8)(handler->subobject, offset * 4 + 0, data >> 0); + if (ACCESSING_BITS_8_15) + (*handler->subhandler.write.mhandler8)(handler->subobject, offset * 4 + 1, data >> 8); + if (ACCESSING_BITS_16_23) + (*handler->subhandler.write.mhandler8)(handler->subobject, offset * 4 + 2, data >> 16); + if (ACCESSING_BITS_24_31) + (*handler->subhandler.write.mhandler8)(handler->subobject, offset * 4 + 3, data >> 24); +} + + +/*------------------------------------------------- + stub_write8_from_32be_packed - convert a 32-bit + write to one or more byte accesses +-------------------------------------------------*/ + +static WRITE32_HANDLER( stub_write8_from_32be_packed ) +{ + handler_data *handler = (handler_data *)machine; + if (ACCESSING_BITS_24_31) + (*handler->subhandler.write.mhandler8)(handler->subobject, offset * 4 + 0, data >> 24); + if (ACCESSING_BITS_16_23) + (*handler->subhandler.write.mhandler8)(handler->subobject, offset * 4 + 1, data >> 16); + if (ACCESSING_BITS_8_15) + (*handler->subhandler.write.mhandler8)(handler->subobject, offset * 4 + 2, data >> 8); + if (ACCESSING_BITS_0_7) + (*handler->subhandler.write.mhandler8)(handler->subobject, offset * 4 + 3, data >> 0); +} + + +/*------------------------------------------------- + stub_write8_from_64_shifted - write a 64-bit + value to a single byte lane +-------------------------------------------------*/ + +static WRITE64_HANDLER( stub_write8_from_64_shifted ) +{ + handler_data *handler = (handler_data *)machine; + if ((UINT8)(mem_mask >> handler->subshift) != 0xff) + (*handler->subhandler.write.mhandler8)(handler->subobject, offset, data >> handler->subshift); +} + + +/*------------------------------------------------- + stub_write8_from_64le_packed - convert a 64-bit + write to one or more byte accesses +-------------------------------------------------*/ + +static WRITE64_HANDLER( stub_write8_from_64le_packed ) +{ + handler_data *handler = (handler_data *)machine; + if (ACCESSING_BITS_0_7) + (*handler->subhandler.write.mhandler8)(handler->subobject, offset * 8 + 0, data >> 0); + if (ACCESSING_BITS_8_15) + (*handler->subhandler.write.mhandler8)(handler->subobject, offset * 8 + 1, data >> 8); + if (ACCESSING_BITS_16_23) + (*handler->subhandler.write.mhandler8)(handler->subobject, offset * 8 + 2, data >> 16); + if (ACCESSING_BITS_24_31) + (*handler->subhandler.write.mhandler8)(handler->subobject, offset * 8 + 3, data >> 24); + if (ACCESSING_BITS_32_39) + (*handler->subhandler.write.mhandler8)(handler->subobject, offset * 8 + 4, data >> 32); + if (ACCESSING_BITS_40_47) + (*handler->subhandler.write.mhandler8)(handler->subobject, offset * 8 + 5, data >> 40); + if (ACCESSING_BITS_48_55) + (*handler->subhandler.write.mhandler8)(handler->subobject, offset * 8 + 6, data >> 48); + if (ACCESSING_BITS_56_63) + (*handler->subhandler.write.mhandler8)(handler->subobject, offset * 8 + 7, data >> 56); +} + + +/*------------------------------------------------- + stub_write8_from_64be_packed - convert a 64-bit + write to one or more byte accesses +-------------------------------------------------*/ + +static WRITE64_HANDLER( stub_write8_from_64be_packed ) +{ + handler_data *handler = (handler_data *)machine; + if (ACCESSING_BITS_56_63) + (*handler->subhandler.write.mhandler8)(handler->subobject, offset * 8 + 0, data >> 56); + if (ACCESSING_BITS_48_55) + (*handler->subhandler.write.mhandler8)(handler->subobject, offset * 8 + 1, data >> 48); + if (ACCESSING_BITS_40_47) + (*handler->subhandler.write.mhandler8)(handler->subobject, offset * 8 + 2, data >> 40); + if (ACCESSING_BITS_32_39) + (*handler->subhandler.write.mhandler8)(handler->subobject, offset * 8 + 3, data >> 32); + if (ACCESSING_BITS_24_31) + (*handler->subhandler.write.mhandler8)(handler->subobject, offset * 8 + 4, data >> 24); + if (ACCESSING_BITS_16_23) + (*handler->subhandler.write.mhandler8)(handler->subobject, offset * 8 + 5, data >> 16); + if (ACCESSING_BITS_8_15) + (*handler->subhandler.write.mhandler8)(handler->subobject, offset * 8 + 6, data >> 8); + if (ACCESSING_BITS_0_7) + (*handler->subhandler.write.mhandler8)(handler->subobject, offset * 8 + 7, data >> 0); +} + + + +/*************************************************************************** + STUB HANDLERS THAT MAP TO WORD READS +***************************************************************************/ + +/*------------------------------------------------- + stub_read16_from_32_shifted - return a 32-bit + value from a single word access in a + particular lane +-------------------------------------------------*/ + +static READ32_HANDLER( stub_read16_from_32_shifted ) +{ + handler_data *handler = (handler_data *)machine; + if ((UINT16)(mem_mask >> handler->subshift) != 0xffff) + return (*handler->subhandler.read.mhandler16)(handler->subobject, offset, mem_mask >> handler->subshift) << handler->subshift; + else + return 0; +} + + +/*------------------------------------------------- + stub_read16_from_32le_packed - return a 32-bit + value combined from one or more word accesses +-------------------------------------------------*/ + +static READ32_HANDLER( stub_read16_from_32le_packed ) +{ + handler_data *handler = (handler_data *)machine; + UINT32 result = 0; + if ((mem_mask & 0x0000ffff) != 0x0000ffff) + result |= (*handler->subhandler.read.mhandler16)(handler->subobject, offset * 2 + 0, mem_mask >> 0) << 0; + if ((mem_mask & 0xffff0000) != 0xffff0000) + result |= (*handler->subhandler.read.mhandler16)(handler->subobject, offset * 2 + 1, mem_mask >> 16) << 16; + return result; +} + + +/*------------------------------------------------- + stub_read16_from_32be_packed - return a 32-bit + value combined from one or more word accesses +-------------------------------------------------*/ + +static READ32_HANDLER( stub_read16_from_32be_packed ) +{ + handler_data *handler = (handler_data *)machine; + UINT32 result = 0; + if ((mem_mask & 0xffff0000) != 0xffff0000) + result |= (*handler->subhandler.read.mhandler16)(handler->subobject, offset * 2 + 0, mem_mask >> 16) << 16; + if ((mem_mask & 0x0000ffff) != 0x0000ffff) + result |= (*handler->subhandler.read.mhandler16)(handler->subobject, offset * 2 + 1, mem_mask >> 0) << 0; + return result; +} + + +/*------------------------------------------------- + stub_read16_from_64_shifted - return a 64-bit + value from a single word access in a + particular lane +-------------------------------------------------*/ + +static READ64_HANDLER( stub_read16_from_64_shifted ) +{ + handler_data *handler = (handler_data *)machine; + if ((UINT16)(mem_mask >> handler->subshift) != 0xffff) + return (UINT64)(*handler->subhandler.read.mhandler16)(handler->subobject, offset, mem_mask >> handler->subshift) << handler->subshift; + else + return 0; +} + + +/*------------------------------------------------- + stub_read16_from_64le_packed - return a 64-bit + value combined from one or more word accesses +-------------------------------------------------*/ + +static READ64_HANDLER( stub_read16_from_64le_packed ) +{ + handler_data *handler = (handler_data *)machine; + UINT32 result = 0; + if ((mem_mask & U64(0x000000000000ffff)) != U64(0x000000000000ffff)) + result |= (*handler->subhandler.read.mhandler16)(handler->subobject, offset * 4 + 0, mem_mask >> 0) << 0; + if ((mem_mask & U64(0x00000000ffff0000)) != U64(0x00000000ffff0000)) + result |= (*handler->subhandler.read.mhandler16)(handler->subobject, offset * 4 + 1, mem_mask >> 16) << 16; + if ((mem_mask & U64(0x0000ffff00000000)) != U64(0x0000ffff00000000)) + result |= (UINT64)(*handler->subhandler.read.mhandler16)(handler->subobject, offset * 4 + 2, mem_mask >> 32) << 32; + if ((mem_mask & U64(0xffff000000000000)) != U64(0xffff000000000000)) + result |= (UINT64)(*handler->subhandler.read.mhandler16)(handler->subobject, offset * 4 + 3, mem_mask >> 48) << 48; + return result; +} + + +/*------------------------------------------------- + stub_read16_from_64be_packed - return a 64-bit + value combined from one or more word accesses +-------------------------------------------------*/ + +static READ64_HANDLER( stub_read16_from_64be_packed ) +{ + handler_data *handler = (handler_data *)machine; + UINT32 result = 0; + if ((mem_mask & U64(0xffff000000000000)) != U64(0xffff000000000000)) + result |= (UINT64)(*handler->subhandler.read.mhandler16)(handler->subobject, offset * 4 + 0, mem_mask >> 48) << 48; + if ((mem_mask & U64(0x0000ffff00000000)) != U64(0x0000ffff00000000)) + result |= (UINT64)(*handler->subhandler.read.mhandler16)(handler->subobject, offset * 4 + 1, mem_mask >> 32) << 32; + if ((mem_mask & U64(0x00000000ffff0000)) != U64(0x00000000ffff0000)) + result |= (*handler->subhandler.read.mhandler16)(handler->subobject, offset * 4 + 2, mem_mask >> 16) << 16; + if ((mem_mask & U64(0x000000000000ffff)) != U64(0x000000000000ffff)) + result |= (*handler->subhandler.read.mhandler16)(handler->subobject, offset * 4 + 3, mem_mask >> 0) << 0; + return result; +} + + + +/*************************************************************************** + STUB HANDLERS THAT MAP TO WORD WRITES +***************************************************************************/ + +/*------------------------------------------------- + stub_write16_from_32_shifted - write a 32-bit + value to a single word lane +-------------------------------------------------*/ + +static WRITE32_HANDLER( stub_write16_from_32_shifted ) +{ + handler_data *handler = (handler_data *)machine; + if ((UINT16)(mem_mask >> handler->subshift) != 0xffff) + (*handler->subhandler.write.mhandler16)(handler->subobject, offset, data >> handler->subshift, mem_mask >> handler->subshift); +} + + +/*------------------------------------------------- + stub_write16_from_32le_packed - convert a 32-bit + write to one or more word accesses +-------------------------------------------------*/ + +static WRITE32_HANDLER( stub_write16_from_32le_packed ) +{ + handler_data *handler = (handler_data *)machine; + if ((mem_mask & 0x0000ffff) != 0x0000ffff) + (*handler->subhandler.write.mhandler16)(handler->subobject, offset * 2 + 0, data >> 0, mem_mask >> 0); + if ((mem_mask & 0xffff0000) != 0xffff0000) + (*handler->subhandler.write.mhandler16)(handler->subobject, offset * 2 + 1, data >> 16, mem_mask >> 16); +} + + +/*------------------------------------------------- + stub_write16_from_32be_packed - convert a 32-bit + write to one or more word accesses +-------------------------------------------------*/ + +static WRITE32_HANDLER( stub_write16_from_32be_packed ) +{ + handler_data *handler = (handler_data *)machine; + if ((mem_mask & 0xffff0000) != 0xffff0000) + (*handler->subhandler.write.mhandler16)(handler->subobject, offset * 2 + 0, data >> 16, mem_mask >> 16); + if ((mem_mask & 0x0000ffff) != 0x0000ffff) + (*handler->subhandler.write.mhandler16)(handler->subobject, offset * 2 + 1, data >> 0, mem_mask >> 0); +} + + +/*------------------------------------------------- + stub_write16_from_64_shifted - write a 64-bit + value to a single word lane +-------------------------------------------------*/ + +static WRITE64_HANDLER( stub_write16_from_64_shifted ) +{ + handler_data *handler = (handler_data *)machine; + if ((UINT16)(mem_mask >> handler->subshift) != 0xffff) + (*handler->subhandler.write.mhandler16)(handler->subobject, offset, data >> handler->subshift, mem_mask >> handler->subshift); +} + + +/*------------------------------------------------- + stub_write16_from_64le_packed - convert a 64-bit + write to one or more word accesses +-------------------------------------------------*/ + +static WRITE64_HANDLER( stub_write16_from_64le_packed ) +{ + handler_data *handler = (handler_data *)machine; + if ((mem_mask & U64(0x000000000000ffff)) != U64(0x000000000000ffff)) + (*handler->subhandler.write.mhandler16)(handler->subobject, offset * 4 + 0, data >> 0, mem_mask >> 0); + if ((mem_mask & U64(0x00000000ffff0000)) != U64(0x00000000ffff0000)) + (*handler->subhandler.write.mhandler16)(handler->subobject, offset * 4 + 1, data >> 16, mem_mask >> 16); + if ((mem_mask & U64(0x0000ffff00000000)) != U64(0x0000ffff00000000)) + (*handler->subhandler.write.mhandler16)(handler->subobject, offset * 4 + 2, data >> 32, mem_mask >> 32); + if ((mem_mask & U64(0xffff000000000000)) != U64(0xffff000000000000)) + (*handler->subhandler.write.mhandler16)(handler->subobject, offset * 4 + 3, data >> 48, mem_mask >> 48); +} + + +/*------------------------------------------------- + stub_write16_from_64be_packed - convert a 64-bit + write to one or more word accesses +-------------------------------------------------*/ + +static WRITE64_HANDLER( stub_write16_from_64be_packed ) +{ + handler_data *handler = (handler_data *)machine; + if ((mem_mask & U64(0xffff000000000000)) != U64(0xffff000000000000)) + (*handler->subhandler.write.mhandler16)(handler->subobject, offset * 4 + 0, data >> 48, mem_mask >> 48); + if ((mem_mask & U64(0x0000ffff00000000)) != U64(0x0000ffff00000000)) + (*handler->subhandler.write.mhandler16)(handler->subobject, offset * 4 + 1, data >> 32, mem_mask >> 32); + if ((mem_mask & U64(0x00000000ffff0000)) != U64(0x00000000ffff0000)) + (*handler->subhandler.write.mhandler16)(handler->subobject, offset * 4 + 2, data >> 16, mem_mask >> 16); + if ((mem_mask & U64(0x000000000000ffff)) != U64(0x000000000000ffff)) + (*handler->subhandler.write.mhandler16)(handler->subobject, offset * 4 + 3, data >> 0, mem_mask >> 0); +} + + + +/*************************************************************************** + STUB HANDLERS THAT MAP TO DWORD READS +***************************************************************************/ + +/*------------------------------------------------- + stub_read32_from_64_shifted - return a 64-bit + value from a single dword access in a + particular lane +-------------------------------------------------*/ + +static READ64_HANDLER( stub_read32_from_64_shifted ) +{ + handler_data *handler = (handler_data *)machine; + if ((UINT32)(mem_mask >> handler->subshift) != 0xffffffff) + return (UINT64)(*handler->subhandler.read.mhandler32)(handler->subobject, offset, mem_mask >> handler->subshift) << handler->subshift; + else + return 0; +} + + +/*------------------------------------------------- + stub_read32_from_64le_packed - return a 64-bit + value combined from one or more dword accesses +-------------------------------------------------*/ + +static READ64_HANDLER( stub_read32_from_64le_packed ) +{ + handler_data *handler = (handler_data *)machine; + UINT32 result = 0; + if ((mem_mask & U64(0x00000000ffffffff)) != U64(0x00000000ffffffff)) + result |= (*handler->subhandler.read.mhandler32)(handler->subobject, offset * 2 + 0, mem_mask >> 0) << 0; + if ((mem_mask & U64(0xffffffff00000000)) != U64(0xffffffff00000000)) + result |= (UINT64)(*handler->subhandler.read.mhandler32)(handler->subobject, offset * 2 + 1, mem_mask >> 32) << 32; + return result; +} + + +/*------------------------------------------------- + stub_read32_from_64be_packed - return a 64-bit + value combined from one or more dword accesses +-------------------------------------------------*/ + +static READ64_HANDLER( stub_read32_from_64be_packed ) +{ + handler_data *handler = (handler_data *)machine; + UINT32 result = 0; + if ((mem_mask & U64(0xffffffff00000000)) != U64(0xffffffff00000000)) + result |= (UINT64)(*handler->subhandler.read.mhandler32)(handler->subobject, offset * 2 + 0, mem_mask >> 32) << 32; + if ((mem_mask & U64(0x00000000ffffffff)) != U64(0x00000000ffffffff)) + result |= (*handler->subhandler.read.mhandler32)(handler->subobject, offset * 2 + 1, mem_mask >> 0) << 0; + return result; +} + + + +/*************************************************************************** + STUB HANDLERS THAT MAP TO DWORD WRITES +***************************************************************************/ + +/*------------------------------------------------- + stub_write32_from_64_shifted - write a 64-bit + value to a single word lane +-------------------------------------------------*/ + +static WRITE64_HANDLER( stub_write32_from_64_shifted ) +{ + handler_data *handler = (handler_data *)machine; + if ((UINT32)(mem_mask >> handler->subshift) != 0xffffffff) + (*handler->subhandler.write.mhandler32)(handler->subobject, offset, data >> handler->subshift, mem_mask >> handler->subshift); +} + + +/*------------------------------------------------- + stub_write32_from_64le_packed - convert a 64-bit + write to one or more word accesses +-------------------------------------------------*/ + +static WRITE64_HANDLER( stub_write32_from_64le_packed ) +{ + handler_data *handler = (handler_data *)machine; + if ((mem_mask & U64(0x00000000ffffffff)) != U64(0x00000000ffffffff)) + (*handler->subhandler.write.mhandler32)(handler->subobject, offset * 2 + 0, data >> 0, mem_mask >> 0); + if ((mem_mask & U64(0xffffffff00000000)) != U64(0xffffffff00000000)) + (*handler->subhandler.write.mhandler32)(handler->subobject, offset * 2 + 1, data >> 32, mem_mask >> 32); +} + + +/*------------------------------------------------- + stub_write32_from_64be_packed - convert a 64-bit + write to one or more word accesses +-------------------------------------------------*/ + +static WRITE64_HANDLER( stub_write32_from_64be_packed ) +{ + handler_data *handler = (handler_data *)machine; + if ((mem_mask & U64(0xffffffff00000000)) != U64(0xffffffff00000000)) + (*handler->subhandler.write.mhandler32)(handler->subobject, offset * 2 + 0, data >> 32, mem_mask >> 32); + if ((mem_mask & U64(0x00000000ffffffff)) != U64(0x00000000ffffffff)) + (*handler->subhandler.write.mhandler32)(handler->subobject, offset * 2 + 1, data >> 0, mem_mask >> 0); +} + + + +/*************************************************************************** + STUB ACCESSORS +***************************************************************************/ + +/*------------------------------------------------- + get_stub_handler - return the appropriate + stub handler +-------------------------------------------------*/ + +static memory_handler get_stub_handler(read_or_write readorwrite, int spacedbits, int spaceendian, int handlerdbits, int handlershift) +{ + memory_handler result = { 0 }; + + /* read stubs */ + if (readorwrite == ROW_READ) + { + /* 16-bit read stubs */ + if (spacedbits == 16) + { + if (handlerdbits == 8) + { + if (handlershift != SHIFT_PACKED) + result.read.mhandler16 = stub_read8_from_16_shifted; + else if (spaceendian == CPU_IS_LE) + result.read.mhandler16 = stub_read8_from_16le_packed; + else if (spaceendian == CPU_IS_BE) + result.read.mhandler16 = stub_read8_from_16be_packed; + } + } + + /* 32-bit read stubs */ + else if (spacedbits == 32) + { + if (handlerdbits == 8) + { + if (handlershift != SHIFT_PACKED) + result.read.mhandler32 = stub_read8_from_32_shifted; + else if (spaceendian == CPU_IS_LE) + result.read.mhandler32 = stub_read8_from_32le_packed; + else if (spaceendian == CPU_IS_BE) + result.read.mhandler32 = stub_read8_from_32be_packed; + } + else if (handlerdbits == 16) + { + if (handlershift != SHIFT_PACKED) + result.read.mhandler32 = stub_read16_from_32_shifted; + else if (spaceendian == CPU_IS_LE) + result.read.mhandler32 = stub_read16_from_32le_packed; + else if (spaceendian == CPU_IS_BE) + result.read.mhandler32 = stub_read16_from_32be_packed; + } + } + + /* 64-bit read stubs */ + else if (spacedbits == 64) + { + if (handlerdbits == 8) + { + if (handlershift != SHIFT_PACKED) + result.read.mhandler64 = stub_read8_from_64_shifted; + else if (spaceendian == CPU_IS_LE) + result.read.mhandler64 = stub_read8_from_64le_packed; + else if (spaceendian == CPU_IS_BE) + result.read.mhandler64 = stub_read8_from_64be_packed; + } + else if (handlerdbits == 16) + { + if (handlershift != SHIFT_PACKED) + result.read.mhandler64 = stub_read16_from_64_shifted; + else if (spaceendian == CPU_IS_LE) + result.read.mhandler64 = stub_read16_from_64le_packed; + else if (spaceendian == CPU_IS_BE) + result.read.mhandler64 = stub_read16_from_64be_packed; + } + else if (handlerdbits == 32) + { + if (handlershift != SHIFT_PACKED) + result.read.mhandler64 = stub_read32_from_64_shifted; + else if (spaceendian == CPU_IS_LE) + result.read.mhandler64 = stub_read32_from_64le_packed; + else if (spaceendian == CPU_IS_BE) + result.read.mhandler64 = stub_read32_from_64be_packed; + } + } + } + + /* write stubs */ + else if (readorwrite == ROW_WRITE) + { + /* 16-bit write stubs */ + if (spacedbits == 16) + { + if (handlerdbits == 8) + { + if (handlershift != SHIFT_PACKED) + result.write.mhandler16 = stub_write8_from_16_shifted; + else if (spaceendian == CPU_IS_LE) + result.write.mhandler16 = stub_write8_from_16le_packed; + else if (spaceendian == CPU_IS_BE) + result.write.mhandler16 = stub_write8_from_16be_packed; + } + } + + /* 32-bit write stubs */ + else if (spacedbits == 32) + { + if (handlerdbits == 8) + { + if (handlershift != SHIFT_PACKED) + result.write.mhandler32 = stub_write8_from_32_shifted; + else if (spaceendian == CPU_IS_LE) + result.write.mhandler32 = stub_write8_from_32le_packed; + else if (spaceendian == CPU_IS_BE) + result.write.mhandler32 = stub_write8_from_32be_packed; + } + else if (handlerdbits == 16) + { + if (handlershift != SHIFT_PACKED) + result.write.mhandler32 = stub_write16_from_32_shifted; + else if (spaceendian == CPU_IS_LE) + result.write.mhandler32 = stub_write16_from_32le_packed; + else if (spaceendian == CPU_IS_BE) + result.write.mhandler32 = stub_write16_from_32be_packed; + } + } + + /* 64-bit write stubs */ + else if (spacedbits == 64) + { + if (handlerdbits == 8) + { + if (handlershift != SHIFT_PACKED) + result.write.mhandler64 = stub_write8_from_64_shifted; + else if (spaceendian == CPU_IS_LE) + result.write.mhandler64 = stub_write8_from_64le_packed; + else if (spaceendian == CPU_IS_BE) + result.write.mhandler64 = stub_write8_from_64be_packed; + } + else if (handlerdbits == 16) + { + if (handlershift != SHIFT_PACKED) + result.write.mhandler64 = stub_write16_from_64_shifted; + else if (spaceendian == CPU_IS_LE) + result.write.mhandler64 = stub_write16_from_64le_packed; + else if (spaceendian == CPU_IS_BE) + result.write.mhandler64 = stub_write16_from_64be_packed; + } + else if (handlerdbits == 32) + { + if (handlershift != SHIFT_PACKED) + result.write.mhandler64 = stub_write32_from_64_shifted; + else if (spaceendian == CPU_IS_LE) + result.write.mhandler64 = stub_write32_from_64le_packed; + else if (spaceendian == CPU_IS_BE) + result.write.mhandler64 = stub_write32_from_64be_packed; + } + } + } + + assert(result.read.generic != NULL); + return result; +} @@ -2974,6 +3854,7 @@ INLINE UINT32 lookup_write_entry(const address_space *space, offs_t address) } + /*************************************************************************** 8-BIT READ HANDLERS ***************************************************************************/ @@ -3170,7 +4051,7 @@ UINT64 io_read_qword_8be(offs_t address) ***************************************************************************/ /*------------------------------------------------- - write_byte_generic - write a byte to an + stub_write_byte_generic - write a byte to an arbitrary address space -------------------------------------------------*/ diff --git a/src/emu/memory.h b/src/emu/memory.h index 8b81619b144..43634b77b65 100644 --- a/src/emu/memory.h +++ b/src/emu/memory.h @@ -23,6 +23,11 @@ CONSTANTS ***************************************************************************/ +/* stub handler shift amounts */ +#define SHIFT_PACKED 1 + + + /* address spaces */ enum { @@ -192,10 +197,14 @@ struct _address_map_entry offs_t addrmirror; /* mirror bits */ offs_t addrmask; /* mask bits */ read_handler read; /* read handler callback */ + UINT8 read_bits; /* bits for the read handler callback (0=default, 1=8, 2=16, 3=32) */ + UINT8 read_shift; /* shift value for the read handler */ const char * read_name; /* read handler callback name */ device_type read_devtype; /* read device type for device references */ const char * read_devtag; /* read tag for the relevant device */ write_handler write; /* write handler callback */ + UINT8 write_bits; /* bits for the write handler callback (0=default, 1=8, 2=16, 3=32) */ + UINT8 write_shift; /* shift value for the write handler */ const char * write_name; /* write handler callback name */ device_type write_devtype; /* read device type for device references */ const char * write_devtag; /* read tag for the relevant device */ @@ -284,6 +293,8 @@ union _addrmap16_token write16_device_func dwrite; /* pointer to native device write handler */ read8_machine_func mread8; /* pointer to 8-bit machine read handler */ write8_machine_func mwrite8; /* pointer to 8-bit machine write handler */ + read8_device_func dread8; /* pointer to 8-bit device read handler */ + write8_device_func dwrite8; /* pointer to 8-bit device write handler */ read_handler read; /* generic read handlers */ write_handler write; /* generic write handlers */ device_type devtype; /* device type */ @@ -304,8 +315,12 @@ union _addrmap32_token write32_device_func dwrite; /* pointer to native device write handler */ read8_machine_func mread8; /* pointer to 8-bit machine read handler */ write8_machine_func mwrite8; /* pointer to 8-bit machine write handler */ + read8_device_func dread8; /* pointer to 8-bit device read handler */ + write8_device_func dwrite8; /* pointer to 8-bit device write handler */ read16_machine_func mread16; /* pointer to 16-bit machine read handler */ write16_machine_func mwrite16; /* pointer to 16-bit machine write handler */ + read16_device_func dread16; /* pointer to 16-bit device read handler */ + write16_device_func dwrite16; /* pointer to 16-bit device write handler */ read_handler read; /* generic read handlers */ write_handler write; /* generic write handlers */ device_type devtype; /* device type */ @@ -326,10 +341,16 @@ union _addrmap64_token write64_device_func dwrite; /* pointer to native device write handler */ read8_machine_func mread8; /* pointer to 8-bit machine read handler */ write8_machine_func mwrite8; /* pointer to 8-bit machine write handler */ + read8_device_func dread8; /* pointer to 8-bit device read handler */ + write8_device_func dwrite8; /* pointer to 8-bit device write handler */ read16_machine_func mread16; /* pointer to 16-bit machine read handler */ write16_machine_func mwrite16; /* pointer to 16-bit machine write handler */ + read16_device_func dread16; /* pointer to 16-bit device read handler */ + write16_device_func dwrite16; /* pointer to 16-bit device write handler */ read32_machine_func mread32; /* pointer to 32-bit machine read handler */ write32_machine_func mwrite32; /* pointer to 32-bit machine write handler */ + read32_device_func dread32; /* pointer to 32-bit device read handler */ + write32_device_func dwrite32; /* pointer to 32-bit device write handler */ read_handler read; /* generic read handlers */ write_handler write; /* generic write handlers */ device_type devtype; /* device type */ @@ -574,31 +595,103 @@ union _addrmap64_token TOKEN_UINT64_PACK2(ADDRMAP_TOKEN_MIRROR, 8, _mirror, 32), #define AM_READ(_handler) \ - TOKEN_UINT32_PACK1(ADDRMAP_TOKEN_READ, 8), \ + TOKEN_UINT32_PACK3(ADDRMAP_TOKEN_READ, 8, 0, 2, 0, 6), \ TOKEN_PTR(mread, _handler), \ TOKEN_STRING(#_handler), +#define AM_READ8(_handler, _shift) \ + TOKEN_UINT32_PACK3(ADDRMAP_TOKEN_READ, 8, 1, 2, (_shift), 6), \ + TOKEN_PTR(mread8, _handler), \ + TOKEN_STRING(#_handler), + +#define AM_READ16(_handler, _shift) \ + TOKEN_UINT32_PACK3(ADDRMAP_TOKEN_READ, 8, 2, 2, (_shift), 6), \ + TOKEN_PTR(mread16, _handler), \ + TOKEN_STRING(#_handler), + +#define AM_READ32(_handler, _shift) \ + TOKEN_UINT32_PACK3(ADDRMAP_TOKEN_READ, 8, 3, 2, (_shift), 6), \ + TOKEN_PTR(mread32, _handler), \ + TOKEN_STRING(#_handler), + #define AM_WRITE(_handler) \ - TOKEN_UINT32_PACK1(ADDRMAP_TOKEN_WRITE, 8), \ + TOKEN_UINT32_PACK3(ADDRMAP_TOKEN_WRITE, 8, 0, 2, 0, 6), \ TOKEN_PTR(mwrite, _handler), \ TOKEN_STRING(#_handler), +#define AM_WRITE8(_handler, _shift) \ + TOKEN_UINT32_PACK3(ADDRMAP_TOKEN_WRITE, 8, 1, 2, (_shift), 6), \ + TOKEN_PTR(mwrite8, _handler), \ + TOKEN_STRING(#_handler), + +#define AM_WRITE16(_handler, _shift) \ + TOKEN_UINT32_PACK3(ADDRMAP_TOKEN_WRITE, 8, 2, 2, (_shift), 6), \ + TOKEN_PTR(mwrite16, _handler), \ + TOKEN_STRING(#_handler), + +#define AM_WRITE32(_handler, _shift) \ + TOKEN_UINT32_PACK3(ADDRMAP_TOKEN_WRITE, 8, 3, 2, (_shift), 6), \ + TOKEN_PTR(mwrite32, _handler), \ + TOKEN_STRING(#_handler), + #define AM_DEVREAD(_type, _tag, _handler) \ - TOKEN_UINT32_PACK1(ADDRMAP_TOKEN_DEVICE_READ, 8), \ + TOKEN_UINT32_PACK3(ADDRMAP_TOKEN_DEVICE_READ, 8, 0, 2, 0, 6), \ TOKEN_PTR(dread, _handler), \ TOKEN_STRING(#_handler), \ TOKEN_PTR(devtype, _type), \ TOKEN_STRING(_tag), +#define AM_DEVREAD8(_type, _tag, _handler, _shift) \ + TOKEN_UINT32_PACK3(ADDRMAP_TOKEN_DEVICE_READ, 8, 1, 2, (_shift), 6), \ + TOKEN_PTR(dread8, _handler), \ + TOKEN_STRING(#_handler), \ + TOKEN_PTR(devtype, _type), \ + TOKEN_STRING(_tag), + +#define AM_DEVREAD16(_type, _tag, _handler, _shift) \ + TOKEN_UINT32_PACK3(ADDRMAP_TOKEN_DEVICE_READ, 8, 2, 2, (_shift), 6), \ + TOKEN_PTR(dread16, _handler), \ + TOKEN_STRING(#_handler), \ + TOKEN_PTR(devtype, _type), \ + TOKEN_STRING(_tag), + +#define AM_DEVREAD32(_type, _tag, _handler, _shift) \ + TOKEN_UINT32_PACK3(ADDRMAP_TOKEN_DEVICE_READ, 8, 3, 2, (_shift), 6), \ + TOKEN_PTR(dread32, _handler), \ + TOKEN_STRING(#_handler), \ + TOKEN_PTR(devtype, _type), \ + TOKEN_STRING(_tag), + #define AM_DEVWRITE(_type, _tag, _handler) \ - TOKEN_UINT32_PACK1(ADDRMAP_TOKEN_DEVICE_WRITE, 8), \ + TOKEN_UINT32_PACK3(ADDRMAP_TOKEN_DEVICE_WRITE, 8, 0, 2, 0, 6), \ TOKEN_PTR(dwrite, _handler), \ TOKEN_STRING(#_handler), \ TOKEN_PTR(devtype, _type), \ TOKEN_STRING(_tag), +#define AM_DEVWRITE8(_type, _tag, _handler, _shift) \ + TOKEN_UINT32_PACK3(ADDRMAP_TOKEN_DEVICE_WRITE, 8, 1, 2, (_shift), 6), \ + TOKEN_PTR(dwrite8, _handler), \ + TOKEN_STRING(#_handler), \ + TOKEN_PTR(devtype, _type), \ + TOKEN_STRING(_tag), + +#define AM_DEVWRITE16(_type, _tag, _handler, _shift) \ + TOKEN_UINT32_PACK3(ADDRMAP_TOKEN_DEVICE_WRITE, 8, 2, 2, (_shift), 6), \ + TOKEN_PTR(dwrite16, _handler), \ + TOKEN_STRING(#_handler), \ + TOKEN_PTR(devtype, _type), \ + TOKEN_STRING(_tag), + +#define AM_DEVWRITE32(_type, _tag, _handler, _shift) \ + TOKEN_UINT32_PACK3(ADDRMAP_TOKEN_DEVICE_WRITE, 8, 3, 2, (_shift), 6), \ + TOKEN_PTR(dwrite32, _handler), \ + TOKEN_STRING(#_handler), \ + TOKEN_PTR(devtype, _type), \ + TOKEN_STRING(_tag), + #define AM_READ_PORT(_tag) \ - TOKEN_UINT32_PACK1(ADDRMAP_TOKEN_READ_PORT, 8), \ + TOKEN_UINT32_PACK3(ADDRMAP_TOKEN_READ_PORT, 8, 0, 2, 0, 6), \ TOKEN_STRING(_tag), #define AM_REGION(_region, _offs) \ @@ -624,7 +717,13 @@ union _addrmap64_token /* common shortcuts */ #define AM_READWRITE(_read,_write) AM_READ(_read) AM_WRITE(_write) +#define AM_READWRITE8(_read,_write,_shift) AM_READ8(_read,_shift) AM_WRITE8(_write,_shift) +#define AM_READWRITE16(_read,_write,_shift) AM_READ16(_read,_shift) AM_WRITE16(_write,_shift) +#define AM_READWRITE32(_read,_write,_shift) AM_READ32(_read,_shift) AM_WRITE32(_write,_shift) #define AM_DEVREADWRITE(_type,_tag,_read,_write) AM_DEVREAD(_type,_tag,_read) AM_DEVWRITE(_type,_tag,_write) +#define AM_DEVREADWRITE8(_type,_tag,_read,_write,_shift) AM_DEVREAD8(_type,_tag,_read,_shift) AM_DEVWRITE8(_type,_tag,_write,_shift) +#define AM_DEVREADWRITE16(_type,_tag,_read,_write,_shift) AM_DEVREAD16(_type,_tag,_read,_shift) AM_DEVWRITE16(_type,_tag,_write,_shift) +#define AM_DEVREADWRITE32(_type,_tag,_read,_write,_shift) AM_DEVREAD32(_type,_tag,_read,_shift) AM_DEVWRITE32(_type,_tag,_write,_shift) #define AM_ROM AM_READ(SMH_ROM) #define AM_RAM AM_READWRITE(SMH_RAM, SMH_RAM) #define AM_WRITEONLY AM_WRITE(SMH_RAM) diff --git a/src/mame/audio/mcr.c b/src/mame/audio/mcr.c index 79fe9766c2f..8b1fcfa11ff 100644 --- a/src/mame/audio/mcr.c +++ b/src/mame/audio/mcr.c @@ -692,7 +692,7 @@ static ADDRESS_MAP_START( soundsgood_map, ADDRESS_SPACE_PROGRAM, 16 ) ADDRESS_MAP_UNMAP_HIGH ADDRESS_MAP_GLOBAL_MASK(0x7ffff) AM_RANGE(0x000000, 0x03ffff) AM_ROM - AM_RANGE(0x060000, 0x060007) AM_READWRITE(pia_1_msb_alt_r, pia_1_msb_alt_w) + AM_RANGE(0x060000, 0x060007) AM_READWRITE8(pia_1_alt_r, pia_1_alt_w, 8) AM_RANGE(0x070000, 0x070fff) AM_RAM ADDRESS_MAP_END diff --git a/src/mame/drivers/gaelco3d.c b/src/mame/drivers/gaelco3d.c index 46d063e5163..38e5c217382 100644 --- a/src/mame/drivers/gaelco3d.c +++ b/src/mame/drivers/gaelco3d.c @@ -144,7 +144,6 @@ REF. 970429 #include "driver.h" #include "deprecat.h" -#include "memconv.h" #include "gaelco3d.h" #include "cpu/tms32031/tms32031.h" #include "cpu/adsp2100/adsp2100.h" @@ -253,7 +252,6 @@ static WRITE16_HANDLER( irq_ack_w ) { cpunum_set_input_line(Machine, 0, 2, CLEAR_LINE); } -static WRITE32_HANDLER( irq_ack_020_w ) { if (ACCESSING_BITS_16_31) irq_ack_w(machine, offset, data >> 16, mem_mask >> 16); } @@ -271,7 +269,6 @@ static READ16_HANDLER( eeprom_data_r ) logerror("eeprom_data_r(%02X)\n", result); return result; } -static READ32_HANDLER( eeprom_data_020_r ) { return eeprom_data_r(machine, offset, mem_mask) << 16; } static WRITE16_HANDLER( eeprom_data_w ) @@ -279,7 +276,6 @@ static WRITE16_HANDLER( eeprom_data_w ) if (ACCESSING_BITS_0_7) EEPROM_write_bit(data & 0x01); } -static WRITE32_HANDLER( eeprom_data_020_w ) { if (ACCESSING_BITS_0_15) eeprom_data_w(machine, offset, data, mem_mask); } static WRITE16_HANDLER( eeprom_clock_w ) @@ -287,7 +283,6 @@ static WRITE16_HANDLER( eeprom_clock_w ) if (ACCESSING_BITS_0_7) EEPROM_set_clock_line((data & 0x01) ? ASSERT_LINE : CLEAR_LINE); } -static WRITE32_HANDLER( eeprom_clock_020_w ) { if (ACCESSING_BITS_0_15) eeprom_clock_w(machine, offset, data, mem_mask); } static WRITE16_HANDLER( eeprom_cs_w ) @@ -295,7 +290,6 @@ static WRITE16_HANDLER( eeprom_cs_w ) if (ACCESSING_BITS_0_7) EEPROM_set_cs_line((data & 0x01) ? CLEAR_LINE : ASSERT_LINE); } -static WRITE32_HANDLER( eeprom_cs_020_w ) { if (ACCESSING_BITS_0_15) eeprom_cs_w(machine, offset, data, mem_mask); } @@ -319,13 +313,12 @@ static WRITE16_HANDLER( sound_data_w ) if (ACCESSING_BITS_0_7) timer_call_after_resynch(NULL, data & 0xff, delayed_sound_w); } -static WRITE32_HANDLER( sound_data_020_w ) { if (ACCESSING_BITS_16_31) sound_data_w(machine, offset, data >> 16, mem_mask >> 16); } static READ16_HANDLER( sound_data_r ) { logerror("sound_data_r(%02X)\n", sound_data); - cpunum_set_input_line(Machine, 2, ADSP2115_IRQ2, CLEAR_LINE); + cpunum_set_input_line(machine, 2, ADSP2115_IRQ2, CLEAR_LINE); return sound_data; } @@ -337,7 +330,6 @@ static READ16_HANDLER( sound_status_r ) return sound_status; return 0xffff; } -static READ32_HANDLER( sound_status_020_r ) { if (ACCESSING_BITS_0_15) return sound_status_r(machine, offset, mem_mask); return ~0; } static WRITE16_HANDLER( sound_status_w ) @@ -354,12 +346,6 @@ static WRITE16_HANDLER( sound_status_w ) * *************************************/ -static READ32_HANDLER( input_port_0_020_r ) { return input_port_read_indexed(machine, 0) << 16; } -static READ32_HANDLER( input_port_1_020_r ) { return input_port_read_indexed(machine, 1) << 16; } -static READ32_HANDLER( input_port_2_020_r ) { return input_port_read_indexed(machine, 2) << 16; } -static READ32_HANDLER( input_port_3_020_r ) { return input_port_read_indexed(machine, 3) << 16; } - - static CUSTOM_INPUT( analog_bit_r ) { int which = (FPTR)param; @@ -383,7 +369,6 @@ static WRITE16_HANDLER( analog_port_clock_w ) else logerror("%06X:analog_port_clock_w(%02X) = %08X & %08X\n", activecpu_get_pc(), offset, data, ~mem_mask); } -static WRITE32_HANDLER( analog_port_clock_020_w ) { if (ACCESSING_BITS_0_15) analog_port_clock_w(machine, offset, data, mem_mask); } static WRITE16_HANDLER( analog_port_latch_w ) @@ -402,7 +387,6 @@ static WRITE16_HANDLER( analog_port_latch_w ) else logerror("%06X:analog_port_latch_w(%02X) = %08X & %08X\n", activecpu_get_pc(), offset, data, ~mem_mask); } -static WRITE32_HANDLER( analog_port_latch_020_w ) { if (ACCESSING_BITS_0_15) analog_port_latch_w(machine, offset, data, mem_mask); } @@ -444,9 +428,8 @@ static WRITE16_HANDLER( tms_reset_w ) /* this is set to 0 while data is uploaded, then set to $ffff after it is done */ /* it does not ever appear to be touched after that */ logerror("%06X:tms_reset_w(%02X) = %08X & %08X\n", activecpu_get_pc(), offset, data, ~mem_mask); - cpunum_set_input_line(Machine, 1, INPUT_LINE_RESET, (data == 0xffff) ? CLEAR_LINE : ASSERT_LINE); + cpunum_set_input_line(machine, 1, INPUT_LINE_RESET, (data == 0xffff) ? CLEAR_LINE : ASSERT_LINE); } -static WRITE32_HANDLER( tms_reset_020_w ) { if (ACCESSING_BITS_0_15) tms_reset_w(machine, offset, data, mem_mask); } static WRITE16_HANDLER( tms_irq_w ) @@ -455,16 +438,14 @@ static WRITE16_HANDLER( tms_irq_w ) /* done after uploading, and after modifying the comm area */ logerror("%06X:tms_irq_w(%02X) = %08X & %08X\n", activecpu_get_pc(), offset, data, ~mem_mask); if (ACCESSING_BITS_0_7) - cpunum_set_input_line(Machine, 1, 0, (data & 0x01) ? CLEAR_LINE : ASSERT_LINE); + cpunum_set_input_line(machine, 1, 0, (data & 0x01) ? CLEAR_LINE : ASSERT_LINE); } -static WRITE32_HANDLER( tms_irq_020_w ) { if (ACCESSING_BITS_0_15) tms_irq_w(machine, offset, data, mem_mask); } static WRITE16_HANDLER( tms_control3_w ) { logerror("%06X:tms_control3_w(%02X) = %08X & %08X\n", activecpu_get_pc(), offset, data, ~mem_mask); } -static WRITE32_HANDLER( tms_control3_020_w ) { if (ACCESSING_BITS_0_15) tms_control3_w(machine, offset, data, mem_mask); } static WRITE16_HANDLER( tms_comm_w ) @@ -472,7 +453,6 @@ static WRITE16_HANDLER( tms_comm_w ) COMBINE_DATA(&tms_comm_base[offset ^ tms_offset_xor]); logerror("%06X:tms_comm_w(%02X) = %08X & %08X\n", activecpu_get_pc(), offset*2, data, ~mem_mask); } -static WRITE32_HANDLER( tms_comm_020_w ) { write32be_with_16be_handler(tms_comm_w, machine, offset, data, mem_mask); } @@ -708,7 +688,6 @@ static WRITE16_HANDLER( led_0_w ) if (ACCESSING_BITS_0_7) set_led_status(0, data != 0); } -static WRITE32_HANDLER( led_0_020_w ) { if (ACCESSING_BITS_0_15) led_0_w(machine, offset, data, mem_mask); } static WRITE16_HANDLER( led_1_w ) @@ -717,7 +696,6 @@ static WRITE16_HANDLER( led_1_w ) if (ACCESSING_BITS_0_7) set_led_status(1, data != 0); } -static WRITE32_HANDLER( led_1_020_w ) { if (ACCESSING_BITS_0_15) led_1_w(machine, offset, data, mem_mask); } @@ -758,29 +736,29 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( main020_map, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0x000000, 0x1fffff) AM_ROM AM_RANGE(0x400000, 0x40ffff) AM_READWRITE(SMH_RAM, gaelco3d_paletteram_020_w) AM_BASE(&paletteram32) - AM_RANGE(0x51000c, 0x51000f) AM_READ(input_port_0_020_r) - AM_RANGE(0x51001c, 0x51001f) AM_READ(input_port_1_020_r) - AM_RANGE(0x51002c, 0x51002f) AM_READ(input_port_2_020_r) - AM_RANGE(0x51003c, 0x51003f) AM_READ(input_port_3_020_r) - AM_RANGE(0x510040, 0x510043) AM_READ(sound_status_020_r) - AM_RANGE(0x510040, 0x510043) AM_WRITE(sound_data_020_w) - AM_RANGE(0x510100, 0x510103) AM_READ(eeprom_data_020_r) - AM_RANGE(0x510100, 0x510103) AM_WRITE(irq_ack_020_w) + AM_RANGE(0x51000c, 0x51000f) AM_READ16(input_port_0_word_r, 16) + AM_RANGE(0x51001c, 0x51001f) AM_READ16(input_port_1_word_r, 16) + AM_RANGE(0x51002c, 0x51002f) AM_READ16(input_port_2_word_r, 16) + AM_RANGE(0x51003c, 0x51003f) AM_READ16(input_port_3_word_r, 16) + AM_RANGE(0x510040, 0x510043) AM_READ16(sound_status_r, 0) + AM_RANGE(0x510040, 0x510043) AM_WRITE16(sound_data_w, 16) + AM_RANGE(0x510100, 0x510103) AM_READ16(eeprom_data_r, 16) + AM_RANGE(0x510100, 0x510103) AM_WRITE16(irq_ack_w, 16) AM_RANGE(0x510104, 0x510107) AM_WRITE(unknown_107_w) - AM_RANGE(0x510110, 0x510113) AM_WRITE(eeprom_data_020_w) - AM_RANGE(0x510114, 0x510117) AM_WRITE(tms_control3_020_w) - AM_RANGE(0x510118, 0x51011b) AM_WRITE(eeprom_clock_020_w) - AM_RANGE(0x510120, 0x510123) AM_WRITE(eeprom_cs_020_w) + AM_RANGE(0x510110, 0x510113) AM_WRITE16(eeprom_data_w, 0) + AM_RANGE(0x510114, 0x510117) AM_WRITE16(tms_control3_w, 0) + AM_RANGE(0x510118, 0x51011b) AM_WRITE16(eeprom_clock_w, 0) + AM_RANGE(0x510120, 0x510123) AM_WRITE16(eeprom_cs_w, 0) AM_RANGE(0x510124, 0x510127) AM_WRITE(unknown_127_w) - AM_RANGE(0x510128, 0x51012b) AM_WRITE(tms_reset_020_w) - AM_RANGE(0x510130, 0x510133) AM_WRITE(tms_irq_020_w) + AM_RANGE(0x510128, 0x51012b) AM_WRITE16(tms_reset_w, 0) + AM_RANGE(0x510130, 0x510133) AM_WRITE16(tms_irq_w, 0) AM_RANGE(0x510134, 0x510137) AM_WRITE(unknown_137_w) AM_RANGE(0x510138, 0x51013b) AM_WRITE(unknown_13a_w) - AM_RANGE(0x510144, 0x510147) AM_WRITE(led_0_020_w) - AM_RANGE(0x510154, 0x510157) AM_WRITE(analog_port_clock_020_w) - AM_RANGE(0x510164, 0x510167) AM_WRITE(analog_port_latch_020_w) - AM_RANGE(0x510174, 0x510177) AM_WRITE(led_1_020_w) - AM_RANGE(0xfe7f80, 0xfe7fff) AM_WRITE(tms_comm_020_w) AM_BASE((UINT32 **)&tms_comm_base) + AM_RANGE(0x510144, 0x510147) AM_WRITE16(led_0_w, 0) + AM_RANGE(0x510154, 0x510157) AM_WRITE16(analog_port_clock_w, 0) + AM_RANGE(0x510164, 0x510167) AM_WRITE16(analog_port_latch_w, 0) + AM_RANGE(0x510174, 0x510177) AM_WRITE16(led_1_w, 0) + AM_RANGE(0xfe7f80, 0xfe7fff) AM_WRITE16(tms_comm_w, SHIFT_PACKED) AM_BASE((UINT32 **)&tms_comm_base) AM_RANGE(0xfe0000, 0xfeffff) AM_RAM AM_BASE((UINT32 **)&m68k_ram_base) ADDRESS_MAP_END diff --git a/src/mame/drivers/itech8.c b/src/mame/drivers/itech8.c index aeaa515650c..92889957a43 100644 --- a/src/mame/drivers/itech8.c +++ b/src/mame/drivers/itech8.c @@ -454,7 +454,6 @@ #include "driver.h" #include "deprecat.h" -#include "memconv.h" #include "cpu/m6809/m6809.h" #include "machine/6821pia.h" #include "machine/6522via.h" @@ -828,38 +827,10 @@ static void via_irq(int state) /************************************* * - * 16-bit memory shunts + * 16-bit-specific handlers * *************************************/ -static READ16_HANDLER( blitter16_r ) -{ - return read16be_with_read8_handler(itech8_blitter_r, machine, offset, mem_mask); -} - - -static READ16_HANDLER( tms34061_16_r ) -{ - /* since multiple XY accesses can move the pointer multiple times, we have to */ - /* be careful to only perform one read per access here; fortunately, the low */ - /* bit doesn't matter in XY addressing mode */ - if ((offset & 0x700) == 0x100) - { - int result = itech8_tms34061_r(machine, offset * 2); - return (result << 8) | result; - } - else - return (itech8_tms34061_r(machine, offset * 2 + 0) << 8) + itech8_tms34061_r(machine, offset * 2 + 1); -} - - -static WRITE16_HANDLER( sound_data16_w ) -{ - if (ACCESSING_BITS_8_15) - sound_data_w(machine, 0, data >> 8); -} - - static WRITE16_HANDLER( grom_bank16_w ) { if (ACCESSING_BITS_8_15) @@ -874,19 +845,6 @@ static WRITE16_HANDLER( display_page16_w ) } -static WRITE16_HANDLER( tms34061_latch16_w ) -{ - if (ACCESSING_BITS_8_15) - tms34061_latch_w(machine, 0, data >> 8); -} - - -static WRITE16_HANDLER( blitter16_w ) -{ - write16be_with_write8_handler(itech8_blitter_w, machine, offset, data, mem_mask); -} - - static WRITE16_HANDLER( palette16_w ) { if (ACCESSING_BITS_8_15) @@ -894,12 +852,6 @@ static WRITE16_HANDLER( palette16_w ) } -static WRITE16_HANDLER( tms34061_16_w ) -{ - write16be_with_write8_handler(itech8_tms34061_w, machine, offset, data, mem_mask); -} - - /************************************* * @@ -981,14 +933,14 @@ static ADDRESS_MAP_START( ninclown_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x00007f) AM_RAM AM_REGION(REGION_CPU1, 0) AM_RANGE(0x000080, 0x003fff) AM_RAM AM_BASE((void *)&main_ram) AM_SIZE(&main_ram_size) AM_RANGE(0x004000, 0x07ffff) AM_ROM - AM_RANGE(0x100080, 0x100081) AM_WRITE(sound_data16_w) + AM_RANGE(0x100080, 0x100081) AM_WRITE8(sound_data_w, 8) AM_RANGE(0x100100, 0x100101) AM_READWRITE(input_port_0_word_r, grom_bank16_w) AM_BASE((void *)&itech8_grom_bank) AM_RANGE(0x100180, 0x100181) AM_READWRITE(input_port_1_word_r, display_page16_w) - AM_RANGE(0x100240, 0x100241) AM_WRITE(tms34061_latch16_w) + AM_RANGE(0x100240, 0x100241) AM_WRITE8(tms34061_latch_w, 8) AM_RANGE(0x100280, 0x100281) AM_READWRITE(input_port_2_word_r, SMH_NOP) - AM_RANGE(0x100300, 0x10031f) AM_READWRITE(blitter16_r, blitter16_w) + AM_RANGE(0x100300, 0x10031f) AM_READWRITE8(itech8_blitter_r, itech8_blitter_w, SHIFT_PACKED) AM_RANGE(0x100380, 0x1003ff) AM_WRITE(palette16_w) - AM_RANGE(0x110000, 0x110fff) AM_READWRITE(tms34061_16_r, tms34061_16_w) + AM_RANGE(0x110000, 0x110fff) AM_READWRITE8(itech8_tms34061_r, itech8_tms34061_w, SHIFT_PACKED) ADDRESS_MAP_END diff --git a/src/mame/drivers/mcr68.c b/src/mame/drivers/mcr68.c index a03e82afa04..a1818f02fd1 100644 --- a/src/mame/drivers/mcr68.c +++ b/src/mame/drivers/mcr68.c @@ -331,9 +331,9 @@ static ADDRESS_MAP_START( zwackery_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x080000, 0x080fff) AM_RAM AM_RANGE(0x084000, 0x084fff) AM_RAM AM_RANGE(0x100000, 0x10000f) AM_READWRITE(zwackery_6840_r, mcr68_6840_upper_w) - AM_RANGE(0x104000, 0x104007) AM_READWRITE(pia_2_msb_r, pia_2_msb_w) - AM_RANGE(0x108000, 0x108007) AM_READWRITE(pia_3_lsb_r, pia_3_lsb_w) - AM_RANGE(0x10c000, 0x10c007) AM_READWRITE(pia_4_lsb_r, pia_4_lsb_w) + AM_RANGE(0x104000, 0x104007) AM_READWRITE8(pia_2_r, pia_2_w, 8) + AM_RANGE(0x108000, 0x108007) AM_READWRITE8(pia_3_r, pia_3_w, 0) + AM_RANGE(0x10c000, 0x10c007) AM_READWRITE8(pia_4_r, pia_4_w, 0) AM_RANGE(0x800000, 0x800fff) AM_READWRITE(SMH_RAM, zwackery_videoram_w) AM_BASE(&videoram16) AM_SIZE(&videoram_size) AM_RANGE(0x802000, 0x803fff) AM_READWRITE(SMH_RAM, zwackery_paletteram_w) AM_BASE(&paletteram16) AM_RANGE(0xc00000, 0xc00fff) AM_READWRITE(SMH_RAM, zwackery_spriteram_w) AM_BASE(&spriteram16) AM_SIZE(&spriteram_size)