From: Mariusz Wojcieszek

Attached is update for Merit hardware based on V9938 (CRT-250 and CRT-260 - meritm.c).

New playable games:

Pit Boss II
Super Pit Boss
Pit Boss Megastar
Megatouch IV
Megatouch IV Tournament Edition
Megatouch 6
This commit is contained in:
Aaron Giles 2008-03-13 15:04:33 +00:00
parent 834d773f26
commit 9d3f7f8680
14 changed files with 2562 additions and 1170 deletions

View File

@ -55,6 +55,7 @@ typedef struct
PC16552D_CHANNEL ch[2];
int frequency;
void (* irq_handler)(int channel, int value);
void (* tx_callback)(int channel, int count, UINT8* data);
} PC16552D_REGS;
#define MAX_PC16552D_CHIPS 4
@ -146,6 +147,9 @@ static TIMER_CALLBACK( tx_fifo_timer_callback )
ch = &duart[chip].ch[channel];
if (duart[chip].tx_callback)
duart[chip].tx_callback(channel, ch->tx_fifo_num, ch->tx_fifo);
ch->tx_fifo_num = 0;
// set transmitter empty interrupt
@ -160,6 +164,7 @@ static void duart_push_tx_fifo(int chip, int channel, UINT8 data)
attotime period;
PC16552D_CHANNEL *ch = &duart[chip].ch[channel];
ch->tx_fifo[ch->tx_fifo_num] = data;
ch->tx_fifo_num++;
period = attotime_mul(ATTOTIME_IN_HZ(duart[chip].frequency), ch->divisor * 16 * 16 * 8);
@ -379,12 +384,13 @@ static void duart_w(int chip, int reg, UINT8 data)
/*****************************************************************************/
void pc16552d_init(int chip, int frequency, void (* irq_handler)(int channel, int value))
void pc16552d_init(int chip, int frequency, void (* irq_handler)(int channel, int value), void (* tx_callback)(int channel, int count, UINT8* data))
{
memset(&duart[chip], 0, sizeof(PC16552D_REGS));
duart[chip].frequency = frequency;
duart[chip].irq_handler = irq_handler;
duart[chip].tx_callback = tx_callback;
// clear interrupts
duart[chip].ch[0].pending_interrupt = 0;

View File

@ -1,7 +1,7 @@
#ifndef PC16552D_H
#define PC16552D_H
void pc16552d_init(int chip, int frequency, void (* irq_handler)(int channel, int value));
void pc16552d_init(int chip, int frequency, void (* irq_handler)(int channel, int value), void (* tx_callback)(int channel, int count, UINT8* data));
void pc16552d_rx_data(int chip, int channel, UINT8 data);
READ8_HANDLER(pc16552d_0_r);

View File

@ -10,6 +10,7 @@
***************************************************************************/
#include "driver.h"
#include "deprecat.h"
#include "z80pio.h"
#include "cpu/z80/z80.h"
#include "cpu/z80/z80daisy.h"
@ -57,6 +58,8 @@ struct _z80pio
UINT8 vector[2]; /* interrupt vector */
void (*intr)(int which); /* interrupt callbacks */
void (*rdyr[2])(int data); /* RDY active callback */
read8_machine_func port_read[2]; /* port read callbacks */
write8_machine_func port_write[2]; /* port write callbacks */
UINT8 mode[2]; /* mode 00=in,01=out,02=i/o,03=bit*/
UINT8 enable[2]; /* interrupt enable */
UINT8 mask[2]; /* mask folowers */
@ -172,6 +175,10 @@ void z80pio_init(int which, const z80pio_interface *intf)
memset(pio, 0, sizeof(*pio));
pio->intr = intf->intr;
pio->port_read[0] = intf->portAread;
pio->port_read[1] = intf->portBread;
pio->port_write[0] = intf->portAwrite;
pio->port_write[1] = intf->portBwrite;
pio->rdyr[0] = intf->rdyA;
pio->rdyr[1] = intf->rdyB;
z80pio_reset(which);
@ -221,7 +228,7 @@ void z80pio_c_w(int which, int ch, UINT8 data)
/* load direction phase ? */
if (pio->mode[ch] == 0x13)
{
logerror("PIO-%c Bits %02x\n", 'A' + ch, data);
VPRINTF(("PIO-%c Bits %02x\n", 'A' + ch, data));
pio->dir[ch] = data;
pio->mode[ch] = 0x03;
return;
@ -233,7 +240,7 @@ void z80pio_c_w(int which, int ch, UINT8 data)
/* load mask folows */
pio->mask[ch] = data;
pio->enable[ch] &= ~PIO_INT_MASK;
logerror("PIO-%c interrupt mask %02x\n",'A'+ch,data );
VPRINTF(("PIO-%c interrupt mask %02x\n",'A'+ch,data ));
return;
}
@ -241,7 +248,7 @@ void z80pio_c_w(int which, int ch, UINT8 data)
{
case PIO_OP_MODE: /* mode select 0=out,1=in,2=i/o,3=bit */
pio->mode[ch] = (data >> 6);
logerror("PIO-%c Mode %x\n", 'A' + ch, pio->mode[ch]);
VPRINTF(("PIO-%c Mode %x\n", 'A' + ch, pio->mode[ch]));
if (pio->mode[ch] == 0x03)
pio->mode[ch] = 0x13;
return;
@ -250,23 +257,23 @@ void z80pio_c_w(int which, int ch, UINT8 data)
pio->enable[ch] = data & 0xf0;
pio->mask[ch] = 0x00;
/* when interrupt enable , set vector request flag */
logerror("PIO-%c Controll %02x\n", 'A' + ch, data);
VPRINTF(("PIO-%c Controll %02x\n", 'A' + ch, data));
break;
case PIO_OP_INTE: /* interrupt enable controll */
pio->enable[ch] &= ~PIO_INT_ENABLE;
pio->enable[ch] |= (data & PIO_INT_ENABLE);
logerror("PIO-%c enable %02x\n", 'A' + ch, data & 0x80);
VPRINTF(("PIO-%c enable %02x\n", 'A' + ch, data & 0x80));
break;
default:
if (!(data & 1))
{
pio->vector[ch] = data;
logerror("PIO-%c vector %02x\n", 'A' + ch, data);
VPRINTF(("PIO-%c vector %02x\n", 'A' + ch, data));
}
else
logerror("PIO-%c illegal command %02x\n", 'A' + ch, data);
VPRINTF(("PIO-%c illegal command %02x\n", 'A' + ch, data));
break;
}
@ -277,7 +284,7 @@ void z80pio_c_w(int which, int ch, UINT8 data)
UINT8 z80pio_c_r(int which, int ch)
{
logerror("PIO-%c controll read\n", 'A' + ch );
VPRINTF(("PIO-%c controll read\n", 'A' + ch ));
return 0;
}
@ -292,6 +299,9 @@ void z80pio_d_w(int which, int ch, UINT8 data)
z80pio *pio = pios + which;
pio->out[ch] = data; /* latch out data */
if(pio->port_write[ch])
pio->port_write[ch](Machine, 0, data);
switch (pio->mode[ch])
{
case PIO_MODE0: /* mode 0 output */
@ -305,7 +315,7 @@ void z80pio_d_w(int which, int ch, UINT8 data)
return;
default:
logerror("PIO-%c data write,bad mode\n",'A'+ch );
VPRINTF(("PIO-%c data write,bad mode\n",'A'+ch ));
}
}
@ -321,19 +331,25 @@ UINT8 z80pio_d_r(int which, int ch)
case PIO_MODE1: /* mode 1 input */
set_rdy(pio, ch, 1); /* ready = H */
if(pio->port_read[ch])
pio->in[ch] = pio->port_read[ch](Machine, 0);
update_irq_state(pio, ch);
return pio->in[ch];
case PIO_MODE2: /* mode 2 i/o */
if (ch) logerror("PIO-B mode 2 \n");
if (ch) VPRINTF(("PIO-B mode 2 \n"));
set_rdy(pio, 1, 1); /* brdy = H */
if(pio->port_read[ch])
pio->in[ch] = pio->port_read[ch](Machine, 0);
update_irq_state(pio, ch);
return pio->in[ch];
case PIO_MODE3: /* mode 3 bit */
if(pio->port_read[ch])
pio->in[ch] = pio->port_read[ch](Machine, 0);
return (pio->in[ch] & pio->dir[ch]) | (pio->out[ch] & ~pio->dir[ch]);
}
logerror("PIO-%c data read,bad mode\n",'A'+ch );
VPRINTF(("PIO-%c data read,bad mode\n",'A'+ch ));
return 0;
}
@ -351,7 +367,7 @@ void z80pio_p_w(int which, UINT8 ch, UINT8 data)
switch (pio->mode[ch])
{
case PIO_MODE0:
logerror("PIO-%c OUTPUT mode and data write\n",'A'+ch );
VPRINTF(("PIO-%c OUTPUT mode and data write\n",'A'+ch ));
break;
case PIO_MODE2: /* only port A */
@ -383,7 +399,7 @@ int z80pio_p_r(int which, UINT8 ch)
break;
case PIO_MODE1:
logerror("PIO-%c INPUT mode and data read\n",'A'+ch );
VPRINTF(("PIO-%c INPUT mode and data read\n",'A'+ch ));
break;
case PIO_MODE3:
@ -429,7 +445,7 @@ static void z80pio_update_strobe(int which, int ch, int state)
if (state != 0)
{
/* positive edge */
logerror("PIO-%c positive strobe\n",'A' + ch);
VPRINTF(("PIO-%c positive strobe\n",'A' + ch));
/* ready is now inactive */
set_rdy(pio, ch, 0);
@ -507,7 +523,7 @@ int z80pio_irq_ack(int which)
return pio->vector[ch];
}
logerror("z80pio_irq_ack: failed to find an interrupt to ack!");
VPRINTF(("z80pio_irq_ack: failed to find an interrupt to ack!"));
return pio->vector[0];
}
@ -529,5 +545,34 @@ void z80pio_irq_reti(int which)
return;
}
logerror("z80pio_irq_reti: failed to find an interrupt to clear IEO on!");
VPRINTF(("z80pio_irq_reti: failed to find an interrupt to clear IEO on!"));
}
/***************************************************************************
READ/WRITE HANDLERS
***************************************************************************/
READ8_HANDLER(z80pio_0_r)
{
return (offset & 2) ? z80pio_c_r(0, offset & 1) : z80pio_d_r(0, offset & 1);
}
WRITE8_HANDLER(z80pio_0_w)
{
if (offset & 2)
z80pio_c_w(0, offset & 1, data);
else
z80pio_d_w(0, offset & 1, data);
}
READ8_HANDLER(z80pio_1_r)
{
return (offset & 2) ? z80pio_c_r(1, offset & 1) : z80pio_d_r(1, offset & 1);
}
WRITE8_HANDLER(z80pio_1_w)
{
if (offset & 2)
z80pio_c_w(1, offset & 1, data);
else
z80pio_d_w(1, offset & 1, data);
}

View File

@ -22,6 +22,10 @@
struct _z80pio_interface
{
void (*intr)(int which); /* callback when change interrupt status */
read8_machine_func portAread; /* port A read callback */
read8_machine_func portBread; /* port B read callback */
write8_machine_func portAwrite; /* port A write callback */
write8_machine_func portBwrite; /* port B write callback */
void (*rdyA)(int data); /* portA ready active callback (do not support yet)*/
void (*rdyB)(int data); /* portB ready active callback (do not support yet)*/
};
@ -90,3 +94,11 @@ void z80pio_bstb_w(int which, int state);
int z80pio_irq_state(int which);
int z80pio_irq_ack(int which);
void z80pio_irq_reti(int which);
/***************************************************************************
READ/WRITE HANDLERS
***************************************************************************/
READ8_HANDLER(z80pio_0_r);
WRITE8_HANDLER(z80pio_0_w);
READ8_HANDLER(z80pio_1_r);
WRITE8_HANDLER(z80pio_1_w);

View File

@ -476,6 +476,10 @@ INLINE void adjust_addresses(addrspace_data *space, offs_t *start, offs_t *end,
/***************************************************************************
CORE SYSTEM OPERATIONS
***************************************************************************/
/*-------------------------------------------------
memory_init - initialize the memory system
-------------------------------------------------*/
@ -486,7 +490,7 @@ void memory_init(running_machine *machine)
add_exit_callback(machine, memory_exit);
/* reset globals */
/* no current context to start */
cur_context = -1;
for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++)
log_unmap[spacenum] = TRUE;
@ -630,9 +634,277 @@ const data_accessors *memory_get_accessors(int spacenum, int databits, int endia
}
/***************************************************************************
ADDRESS MAPS
***************************************************************************/
/*-------------------------------------------------
memory_set_opbase_handler - change op-code
memory base
address_map_alloc - build and allocate an
address map for a CPU's address space
-------------------------------------------------*/
address_map *address_map_alloc(const machine_config *config, int cpunum, int spacenum)
{
int cputype = config->cpu[cpunum].type;
const addrmap_token *internal_map = (const addrmap_token *)cputype_get_info_ptr(cputype, CPUINFO_PTR_INTERNAL_MEMORY_MAP + spacenum);
address_map *map;
map = malloc_or_die(sizeof(*map));
memset(map, 0, sizeof(*map));
/* start by constructing the internal CPU map */
if (internal_map != NULL)
address_map_detokenize(map, internal_map);
/* construct the standard map */
if (config->cpu[cpunum].address_map[spacenum][0] != NULL)
address_map_detokenize(map, config->cpu[cpunum].address_map[spacenum][0]);
if (config->cpu[cpunum].address_map[spacenum][1] != NULL)
address_map_detokenize(map, config->cpu[cpunum].address_map[spacenum][1]);
return map;
}
/*-------------------------------------------------
address_map_free - release allocated memory
for an address map
-------------------------------------------------*/
void address_map_free(address_map *map)
{
/* free all entries */
while (map->entrylist != NULL)
{
address_map_entry *entry = map->entrylist;
map->entrylist = entry->next;
free(entry);
}
/* free the map */
free(map);
}
/*-------------------------------------------------
memory_get_address_map - return a pointer to
the constructed address map for a CPU's
address space
-------------------------------------------------*/
const address_map *memory_get_address_map(int cpunum, int spacenum)
{
return cpudata[cpunum].space[spacenum].map;
}
/*-------------------------------------------------
address_map_detokenize - detokenize an array
of address map tokens
-------------------------------------------------*/
static void address_map_detokenize(address_map *map, const addrmap_token *tokens)
{
address_map_entry **entryptr;
address_map_entry *entry;
UINT8 spacenum, databits;
UINT32 entrytype;
/* check the first token */
TOKEN_GET_UINT32_UNPACK3(tokens, entrytype, 8, spacenum, 8, databits, 8);
if (entrytype != ADDRMAP_TOKEN_START)
fatalerror("Address map missing ADDRMAP_TOKEN_START!");
if (spacenum >= ADDRESS_SPACES)
fatalerror("Invalid address space %d for memory map!", spacenum);
if (databits != 8 && databits != 16 && databits != 32 && databits != 64)
fatalerror("Invalid data bits %d for memory map!", databits);
if (map->spacenum != 0 && map->spacenum != spacenum)
fatalerror("Included a mismatched address map (space %d) for an existing map of type %d!\n", spacenum, map->spacenum);
if (map->databits != 0 && map->databits != databits)
fatalerror("Included a mismatched address map (databits %d) for an existing map with databits %d!\n", databits, map->databits);
/* fill in the map values */
map->spacenum = spacenum;
map->databits = databits;
/* find the end of the list */
for (entryptr = &map->entrylist; *entryptr != NULL; entryptr = &(*entryptr)->next) ;
entry = NULL;
/* loop over tokens until we hit the end */
while (entrytype != ADDRMAP_TOKEN_END)
{
/* unpack the token from the first entry */
TOKEN_GET_UINT32_UNPACK1(tokens, entrytype, 8);
switch (entrytype)
{
/* end */
case ADDRMAP_TOKEN_END:
break;
/* including */
case ADDRMAP_TOKEN_INCLUDE:
address_map_detokenize(map, TOKEN_GET_PTR(tokens, tokenptr));
for (entryptr = &map->entrylist; *entryptr != NULL; entryptr = &(*entryptr)->next) ;
entry = NULL;
break;
/* global flags */
case ADDRMAP_TOKEN_GLOBAL_MASK:
TOKEN_UNGET_UINT32(tokens);
TOKEN_GET_UINT64_UNPACK2(tokens, entrytype, 8, map->globalmask, 32);
break;
case ADDRMAP_TOKEN_UNMAP_VALUE:
TOKEN_UNGET_UINT32(tokens);
TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, map->unmapval, 1);
break;
/* start a new range */
case ADDRMAP_TOKEN_RANGE:
entry = *entryptr = malloc_or_die(sizeof(**entryptr));
entryptr = &entry->next;
memset(entry, 0, sizeof(*entry));
TOKEN_GET_UINT64_UNPACK2(tokens, entry->addrstart, 32, entry->addrend, 32);
break;
case ADDRMAP_TOKEN_MASK:
TOKEN_UNGET_UINT32(tokens);
TOKEN_GET_UINT64_UNPACK2(tokens, entrytype, 8, entry->addrmask, 32);
break;
case ADDRMAP_TOKEN_MIRROR:
TOKEN_UNGET_UINT32(tokens);
TOKEN_GET_UINT64_UNPACK2(tokens, entrytype, 8, entry->addrmirror, 32);
break;
case ADDRMAP_TOKEN_READ:
entry->read = TOKEN_GET_PTR(tokens, read);
entry->read_name = TOKEN_GET_STRING(tokens);
break;
case ADDRMAP_TOKEN_WRITE:
entry->write = TOKEN_GET_PTR(tokens, write);
entry->write_name = TOKEN_GET_STRING(tokens);
break;
case ADDRMAP_TOKEN_DEVICE_READ:
entry->read = TOKEN_GET_PTR(tokens, read);
entry->read_name = TOKEN_GET_STRING(tokens);
entry->read_devtype = TOKEN_GET_PTR(tokens, devtype);
entry->read_devtag = TOKEN_GET_STRING(tokens);
break;
case ADDRMAP_TOKEN_DEVICE_WRITE:
entry->write = TOKEN_GET_PTR(tokens, write);
entry->write_name = TOKEN_GET_STRING(tokens);
entry->write_devtype = TOKEN_GET_PTR(tokens, devtype);
entry->write_devtag = TOKEN_GET_STRING(tokens);
break;
case ADDRMAP_TOKEN_READ_PORT:
switch (map->databits)
{
case 8: entry->read.mhandler8 = port_tag_to_handler8(TOKEN_GET_STRING(tokens)); break;
case 16: entry->read.mhandler16 = port_tag_to_handler16(TOKEN_GET_STRING(tokens)); break;
case 32: entry->read.mhandler32 = port_tag_to_handler32(TOKEN_GET_STRING(tokens)); break;
case 64: entry->read.mhandler64 = port_tag_to_handler64(TOKEN_GET_STRING(tokens)); break;
}
break;
case ADDRMAP_TOKEN_REGION:
TOKEN_UNGET_UINT32(tokens);
TOKEN_GET_UINT64_UNPACK3(tokens, entrytype, 8, entry->region, 24, entry->region_offs, 32);
break;
case ADDRMAP_TOKEN_SHARE:
TOKEN_UNGET_UINT32(tokens);
TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, entry->share, 24);
break;
case ADDRMAP_TOKEN_BASEPTR:
entry->baseptr = (void **)TOKEN_GET_PTR(tokens, voidptr);
break;
case ADDRMAP_TOKEN_BASE_MEMBER:
TOKEN_UNGET_UINT32(tokens);
TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, entry->baseptroffs_plus1, 24);
entry->baseptroffs_plus1++;
break;
case ADDRMAP_TOKEN_SIZEPTR:
entry->sizeptr = TOKEN_GET_PTR(tokens, sizeptr);
break;
case ADDRMAP_TOKEN_SIZE_MEMBER:
TOKEN_UNGET_UINT32(tokens);
TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, entry->sizeptroffs_plus1, 24);
entry->sizeptroffs_plus1++;
break;
default:
fatalerror("Invalid token %d in address map\n", entrytype);
break;
}
}
}
/***************************************************************************
OPCODE BASE CONTROL
***************************************************************************/
/*-------------------------------------------------
memory_set_decrypted_region - registers an
address range as having a decrypted data
pointer
-------------------------------------------------*/
void memory_set_decrypted_region(int cpunum, offs_t addrstart, offs_t addrend, void *base)
{
addrspace_data *space = &cpudata[cpunum].space[ADDRESS_SPACE_PROGRAM];
offs_t bytestart = ADDR2BYTE(space, addrstart);
offs_t byteend = ADDR2BYTE_END(space, addrend);
int banknum, found = FALSE;
/* loop over banks looking for a match */
for (banknum = 0; banknum < STATIC_COUNT; banknum++)
{
bank_info *bank = &bankdata[banknum];
/* consider this bank if it is used for reading and matches the CPU/address space */
if (bank->used && bank->read && bank->cpunum == cpunum && bank->spacenum == ADDRESS_SPACE_PROGRAM)
{
/* verify that the region fully covers the decrypted range */
if (bank->bytestart >= bytestart && bank->byteend <= byteend)
{
/* set the decrypted pointer for the corresponding memory bank */
bankd_ptr[banknum] = (UINT8 *)base + bank->bytestart - bytestart;
found = TRUE;
/* if we are executing from here, force an opcode base update */
if (cpu_getactivecpu() >= 0 && cpunum == cur_context && opcode_entry == banknum)
force_opbase_update();
}
/* fatal error if the decrypted region straddles the bank */
else if (bank->bytestart < byteend && bank->byteend > bytestart)
fatalerror("memory_set_decrypted_region found straddled region %08X-%08X for CPU %d", bytestart, byteend, cpunum);
}
}
/* fatal error as well if we didn't find any relevant memory banks */
if (!found)
fatalerror("memory_set_decrypted_region unable to find matching region %08X-%08X for CPU %d", bytestart, byteend, cpunum);
}
/*-------------------------------------------------
memory_set_opbase_handler - register a
handler for opcode base changes on a given
CPU
-------------------------------------------------*/
opbase_handler_func memory_set_opbase_handler(int cpunum, opbase_handler_func function)
@ -646,7 +918,8 @@ opbase_handler_func memory_set_opbase_handler(int cpunum, opbase_handler_func fu
/*-------------------------------------------------
memory_set_opbase - generic opcode base changer
memory_set_opbase - called by CPU cores to
update the opcode base for the given address
-------------------------------------------------*/
void memory_set_opbase(offs_t byteaddress)
@ -710,39 +983,10 @@ void memory_set_opbase(offs_t byteaddress)
}
/*-------------------------------------------------
memory_set_decrypted_region - sets the
decrypted region for the given CPU
-------------------------------------------------*/
void memory_set_decrypted_region(int cpunum, offs_t bytestart, offs_t byteend, void *base)
{
int banknum, found = FALSE;
/* loop over banks looking for a match */
for (banknum = 0; banknum < STATIC_COUNT; banknum++)
{
bank_info *bank = &bankdata[banknum];
if (bank->used && bank->cpunum == cpunum && bank->spacenum == ADDRESS_SPACE_PROGRAM && bank->read)
{
if (bank->bytestart >= bytestart && bank->byteend <= byteend)
{
bankd_ptr[banknum] = (UINT8 *)base + bank->bytestart - bytestart;
found = TRUE;
/* if this is live, adjust now */
if (cpu_getactivecpu() >= 0 && cpunum == cur_context && opcode_entry == banknum)
force_opbase_update();
}
else if (bank->bytestart < byteend && bank->byteend > bytestart)
fatalerror("memory_set_decrypted_region found straddled region %08X-%08X for CPU %d", bytestart, byteend, cpunum);
}
}
if (!found)
fatalerror("memory_set_decrypted_region unable to find matching region %08X-%08X for CPU %d", bytestart, byteend, cpunum);
}
/***************************************************************************
OPCODE BASE CONTROL
***************************************************************************/
/*-------------------------------------------------
memory_get_read_ptr - return a pointer to the
@ -1163,218 +1407,6 @@ UINT64 *_memory_install_readwrite64_handler(int cpunum, int spacenum, offs_t add
}
/*-------------------------------------------------
address_map_alloc - build and allocate an
address map for a CPU's address space
-------------------------------------------------*/
address_map *address_map_alloc(const machine_config *config, int cpunum, int spacenum)
{
int cputype = config->cpu[cpunum].type;
const addrmap_token *internal_map = (const addrmap_token *)cputype_get_info_ptr(cputype, CPUINFO_PTR_INTERNAL_MEMORY_MAP + spacenum);
address_map *map;
map = malloc_or_die(sizeof(*map));
memset(map, 0, sizeof(*map));
/* start by constructing the internal CPU map */
if (internal_map != NULL)
address_map_detokenize(map, internal_map);
/* construct the standard map */
if (config->cpu[cpunum].address_map[spacenum][0] != NULL)
address_map_detokenize(map, config->cpu[cpunum].address_map[spacenum][0]);
if (config->cpu[cpunum].address_map[spacenum][1] != NULL)
address_map_detokenize(map, config->cpu[cpunum].address_map[spacenum][1]);
return map;
}
/*-------------------------------------------------
address_map_free - release allocated memory
for an address map
-------------------------------------------------*/
void address_map_free(address_map *map)
{
/* free all entries */
while (map->entrylist != NULL)
{
address_map_entry *entry = map->entrylist;
map->entrylist = entry->next;
free(entry);
}
/* free the map */
free(map);
}
/*-------------------------------------------------
memory_get_address_map - return a pointer to
the constructed address map for a CPU's
address space
-------------------------------------------------*/
const address_map *memory_get_address_map(int cpunum, int spacenum)
{
return cpudata[cpunum].space[spacenum].map;
}
/*-------------------------------------------------
address_map_detokenize - detokenize an array
of address map tokens
-------------------------------------------------*/
static void address_map_detokenize(address_map *map, const addrmap_token *tokens)
{
address_map_entry **entryptr;
address_map_entry *entry;
UINT8 spacenum, databits;
UINT32 entrytype;
/* check the first token */
TOKEN_GET_UINT32_UNPACK3(tokens, entrytype, 8, spacenum, 8, databits, 8);
if (entrytype != ADDRMAP_TOKEN_START)
fatalerror("Address map missing ADDRMAP_TOKEN_START!");
if (spacenum >= ADDRESS_SPACES)
fatalerror("Invalid address space %d for memory map!", spacenum);
if (databits != 8 && databits != 16 && databits != 32 && databits != 64)
fatalerror("Invalid data bits %d for memory map!", databits);
if (map->spacenum != 0 && map->spacenum != spacenum)
fatalerror("Included a mismatched address map (space %d) for an existing map of type %d!\n", spacenum, map->spacenum);
if (map->databits != 0 && map->databits != databits)
fatalerror("Included a mismatched address map (databits %d) for an existing map with databits %d!\n", databits, map->databits);
/* fill in the map values */
map->spacenum = spacenum;
map->databits = databits;
/* find the end of the list */
for (entryptr = &map->entrylist; *entryptr != NULL; entryptr = &(*entryptr)->next) ;
entry = NULL;
/* loop over tokens until we hit the end */
while (entrytype != ADDRMAP_TOKEN_END)
{
/* unpack the token from the first entry */
TOKEN_GET_UINT32_UNPACK1(tokens, entrytype, 8);
switch (entrytype)
{
/* end */
case ADDRMAP_TOKEN_END:
break;
/* including */
case ADDRMAP_TOKEN_INCLUDE:
address_map_detokenize(map, TOKEN_GET_PTR(tokens, tokenptr));
for (entryptr = &map->entrylist; *entryptr != NULL; entryptr = &(*entryptr)->next) ;
entry = NULL;
break;
/* global flags */
case ADDRMAP_TOKEN_GLOBAL_MASK:
TOKEN_UNGET_UINT32(tokens);
TOKEN_GET_UINT64_UNPACK2(tokens, entrytype, 8, map->globalmask, 32);
break;
case ADDRMAP_TOKEN_UNMAP_VALUE:
TOKEN_UNGET_UINT32(tokens);
TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, map->unmapval, 1);
break;
/* start a new range */
case ADDRMAP_TOKEN_RANGE:
entry = *entryptr = malloc_or_die(sizeof(**entryptr));
entryptr = &entry->next;
memset(entry, 0, sizeof(*entry));
TOKEN_GET_UINT64_UNPACK2(tokens, entry->addrstart, 32, entry->addrend, 32);
break;
case ADDRMAP_TOKEN_MASK:
TOKEN_UNGET_UINT32(tokens);
TOKEN_GET_UINT64_UNPACK2(tokens, entrytype, 8, entry->addrmask, 32);
break;
case ADDRMAP_TOKEN_MIRROR:
TOKEN_UNGET_UINT32(tokens);
TOKEN_GET_UINT64_UNPACK2(tokens, entrytype, 8, entry->addrmirror, 32);
break;
case ADDRMAP_TOKEN_READ:
entry->read = TOKEN_GET_PTR(tokens, read);
entry->read_name = TOKEN_GET_STRING(tokens);
break;
case ADDRMAP_TOKEN_WRITE:
entry->write = TOKEN_GET_PTR(tokens, write);
entry->write_name = TOKEN_GET_STRING(tokens);
break;
case ADDRMAP_TOKEN_DEVICE_READ:
entry->read = TOKEN_GET_PTR(tokens, read);
entry->read_name = TOKEN_GET_STRING(tokens);
entry->read_devtype = TOKEN_GET_PTR(tokens, devtype);
entry->read_devtag = TOKEN_GET_STRING(tokens);
break;
case ADDRMAP_TOKEN_DEVICE_WRITE:
entry->write = TOKEN_GET_PTR(tokens, write);
entry->write_name = TOKEN_GET_STRING(tokens);
entry->write_devtype = TOKEN_GET_PTR(tokens, devtype);
entry->write_devtag = TOKEN_GET_STRING(tokens);
break;
case ADDRMAP_TOKEN_READ_PORT:
switch (map->databits)
{
case 8: entry->read.mhandler8 = port_tag_to_handler8(TOKEN_GET_STRING(tokens)); break;
case 16: entry->read.mhandler16 = port_tag_to_handler16(TOKEN_GET_STRING(tokens)); break;
case 32: entry->read.mhandler32 = port_tag_to_handler32(TOKEN_GET_STRING(tokens)); break;
case 64: entry->read.mhandler64 = port_tag_to_handler64(TOKEN_GET_STRING(tokens)); break;
}
break;
case ADDRMAP_TOKEN_REGION:
TOKEN_UNGET_UINT32(tokens);
TOKEN_GET_UINT64_UNPACK3(tokens, entrytype, 8, entry->region, 24, entry->region_offs, 32);
break;
case ADDRMAP_TOKEN_SHARE:
TOKEN_UNGET_UINT32(tokens);
TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, entry->share, 24);
break;
case ADDRMAP_TOKEN_BASEPTR:
entry->baseptr = (void **)TOKEN_GET_PTR(tokens, voidptr);
break;
case ADDRMAP_TOKEN_BASE_MEMBER:
TOKEN_UNGET_UINT32(tokens);
TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, entry->baseptroffs_plus1, 24);
entry->baseptroffs_plus1++;
break;
case ADDRMAP_TOKEN_SIZEPTR:
entry->sizeptr = TOKEN_GET_PTR(tokens, sizeptr);
break;
case ADDRMAP_TOKEN_SIZE_MEMBER:
TOKEN_UNGET_UINT32(tokens);
TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, entry->sizeptroffs_plus1, 24);
entry->sizeptroffs_plus1++;
break;
default:
fatalerror("Invalid token %d in address map\n", entrytype);
break;
}
}
}
/*-------------------------------------------------
memory_init_cpudata - initialize the cpudata
structure for each CPU

View File

@ -431,10 +431,6 @@ union _addrmap64_token
#define change_pc(byteaddress) memory_set_opbase(byteaddress)
/* forces the next branch to generate a call to the opbase handler */
#define catch_nextBranch() do { opcode_entry = 0xff; } while (0)
/* opcode range safety check */
#define address_is_unsafe(A) ((UNEXPECTED((A) < opcode_memory_min) || UNEXPECTED((A) > opcode_memory_max)))
@ -638,6 +634,165 @@ union _addrmap64_token
/***************************************************************************
GLOBAL VARIABLES
***************************************************************************/
extern UINT8 opcode_entry; /* current entry for opcode fetching */
extern UINT8 * opcode_base; /* opcode ROM base */
extern UINT8 * opcode_arg_base; /* opcode RAM base */
extern offs_t opcode_mask; /* mask to apply to the opcode address */
extern offs_t opcode_memory_min; /* opcode memory minimum */
extern offs_t opcode_memory_max; /* opcode memory maximum */
extern address_space active_address_space[]; /* address spaces */
extern const char *const address_space_names[ADDRESS_SPACES];
/***************************************************************************
FUNCTION PROTOTYPES FOR CORE MEMORY FUNCTIONS
***************************************************************************/
/* ----- core system operations ----- */
/* initialize the memory system */
void memory_init(running_machine *machine);
/* set the current memory context */
void memory_set_context(int activecpu);
/* get a pointer to the set of memory accessor functions based on the address space,
databus width, and endianness */
const data_accessors *memory_get_accessors(int spacenum, int databits, int endianness);
/* ----- address maps ----- */
/* build and allocate an address map for a CPU's address space */
address_map *address_map_alloc(const machine_config *drv, int cpunum, int spacenum);
/* release allocated memory for an address map */
void address_map_free(address_map *map);
/* return a pointer to the constructed address map for a CPU's address space */
const address_map *memory_get_address_map(int cpunum, int spacenum);
/* ----- opcode base control ----- */
/* registers an address range as having a decrypted data pointer */
void memory_set_decrypted_region(int cpunum, offs_t addrstart, offs_t addrend, void *base);
/* register a handler for opcode base changes on a given CPU */
opbase_handler_func memory_set_opbase_handler(int cpunum, opbase_handler_func function);
/* called by CPU cores to update the opcode base for the given address */
void memory_set_opbase(offs_t byteaddress);
/* return a base pointer to memory */
void * memory_get_read_ptr(int cpunum, int spacenum, offs_t byteaddress);
void * memory_get_write_ptr(int cpunum, int spacenum, offs_t byteaddress);
void * memory_get_op_ptr(int cpunum, offs_t byteaddress, int arg);
/* memory banking */
void memory_configure_bank(int banknum, int startentry, int numentries, void *base, offs_t stride);
void memory_configure_bank_decrypted(int banknum, int startentry, int numentries, void *base, offs_t stride);
void memory_set_bank(int banknum, int entrynum);
int memory_get_bank(int banknum);
void memory_set_bankptr(int banknum, void *base);
/* debugging */
void memory_set_debugger_access(int debugger);
void memory_set_log_unmap(int spacenum, int log);
int memory_get_log_unmap(int spacenum);
/* dynamic address space mapping */
void * _memory_install_read_handler (int cpunum, int spacenum, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, FPTR handler, const char *handler_name);
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);
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);
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);
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);
void * _memory_install_write_handler (int cpunum, int spacenum, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, FPTR handler, const char *handler_name);
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);
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);
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);
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);
void * _memory_install_readwrite_handler (int cpunum, int spacenum, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, FPTR rhandler, FPTR whandler, const char *rhandler_name, const char *whandler_name);
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);
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);
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);
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);
/* memory debugging */
void memory_dump(FILE *file);
const char *memory_get_handler_string(int read0_or_write1, int cpunum, int spacenum, offs_t byteaddress);
/***************************************************************************
HELPER MACROS AND INLINES
***************************************************************************/
/* generic memory access */
INLINE UINT8 program_read_byte (offs_t byteaddress) { return (*active_address_space[ADDRESS_SPACE_PROGRAM].accessors->read_byte)(byteaddress); }
INLINE UINT16 program_read_word (offs_t byteaddress) { return (*active_address_space[ADDRESS_SPACE_PROGRAM].accessors->read_word)(byteaddress); }
INLINE UINT32 program_read_dword(offs_t byteaddress) { return (*active_address_space[ADDRESS_SPACE_PROGRAM].accessors->read_dword)(byteaddress); }
INLINE UINT64 program_read_qword(offs_t byteaddress) { return (*active_address_space[ADDRESS_SPACE_PROGRAM].accessors->read_qword)(byteaddress); }
INLINE void program_write_byte (offs_t byteaddress, UINT8 data) { (*active_address_space[ADDRESS_SPACE_PROGRAM].accessors->write_byte)(byteaddress, data); }
INLINE void program_write_word (offs_t byteaddress, UINT16 data) { (*active_address_space[ADDRESS_SPACE_PROGRAM].accessors->write_word)(byteaddress, data); }
INLINE void program_write_dword(offs_t byteaddress, UINT32 data) { (*active_address_space[ADDRESS_SPACE_PROGRAM].accessors->write_dword)(byteaddress, data); }
INLINE void program_write_qword(offs_t byteaddress, UINT64 data) { (*active_address_space[ADDRESS_SPACE_PROGRAM].accessors->write_qword)(byteaddress, data); }
INLINE UINT8 data_read_byte (offs_t byteaddress) { return (*active_address_space[ADDRESS_SPACE_DATA].accessors->read_byte)(byteaddress); }
INLINE UINT16 data_read_word (offs_t byteaddress) { return (*active_address_space[ADDRESS_SPACE_DATA].accessors->read_word)(byteaddress); }
INLINE UINT32 data_read_dword(offs_t byteaddress) { return (*active_address_space[ADDRESS_SPACE_DATA].accessors->read_dword)(byteaddress); }
INLINE UINT64 data_read_qword(offs_t byteaddress) { return (*active_address_space[ADDRESS_SPACE_DATA].accessors->read_qword)(byteaddress); }
INLINE void data_write_byte (offs_t byteaddress, UINT8 data) { (*active_address_space[ADDRESS_SPACE_DATA].accessors->write_byte)(byteaddress, data); }
INLINE void data_write_word (offs_t byteaddress, UINT16 data) { (*active_address_space[ADDRESS_SPACE_DATA].accessors->write_word)(byteaddress, data); }
INLINE void data_write_dword(offs_t byteaddress, UINT32 data) { (*active_address_space[ADDRESS_SPACE_DATA].accessors->write_dword)(byteaddress, data); }
INLINE void data_write_qword(offs_t byteaddress, UINT64 data) { (*active_address_space[ADDRESS_SPACE_DATA].accessors->write_qword)(byteaddress, data); }
INLINE UINT8 io_read_byte (offs_t byteaddress) { return (*active_address_space[ADDRESS_SPACE_IO].accessors->read_byte)(byteaddress); }
INLINE UINT16 io_read_word (offs_t byteaddress) { return (*active_address_space[ADDRESS_SPACE_IO].accessors->read_word)(byteaddress); }
INLINE UINT32 io_read_dword(offs_t byteaddress) { return (*active_address_space[ADDRESS_SPACE_IO].accessors->read_dword)(byteaddress); }
INLINE UINT64 io_read_qword(offs_t byteaddress) { return (*active_address_space[ADDRESS_SPACE_IO].accessors->read_qword)(byteaddress); }
INLINE void io_write_byte (offs_t byteaddress, UINT8 data) { (*active_address_space[ADDRESS_SPACE_IO].accessors->write_byte)(byteaddress, data); }
INLINE void io_write_word (offs_t byteaddress, UINT16 data) { (*active_address_space[ADDRESS_SPACE_IO].accessors->write_word)(byteaddress, data); }
INLINE void io_write_dword(offs_t byteaddress, UINT32 data) { (*active_address_space[ADDRESS_SPACE_IO].accessors->write_dword)(byteaddress, data); }
INLINE void io_write_qword(offs_t byteaddress, UINT64 data) { (*active_address_space[ADDRESS_SPACE_IO].accessors->write_qword)(byteaddress, data); }
/* safe opcode and opcode argument reading */
UINT8 cpu_readop_safe(offs_t byteaddress);
UINT16 cpu_readop16_safe(offs_t byteaddress);
UINT32 cpu_readop32_safe(offs_t byteaddress);
UINT64 cpu_readop64_safe(offs_t byteaddress);
UINT8 cpu_readop_arg_safe(offs_t byteaddress);
UINT16 cpu_readop_arg16_safe(offs_t byteaddress);
UINT32 cpu_readop_arg32_safe(offs_t byteaddress);
UINT64 cpu_readop_arg64_safe(offs_t byteaddress);
/* opcode and opcode argument reading */
INLINE void * cpu_opptr(offs_t byteaddress) { if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_opptr_unsafe(byteaddress); }
INLINE UINT8 cpu_readop(offs_t byteaddress) { if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_readop_unsafe(byteaddress); }
INLINE UINT16 cpu_readop16(offs_t byteaddress) { if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_readop16_unsafe(byteaddress); }
INLINE UINT32 cpu_readop32(offs_t byteaddress) { if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_readop32_unsafe(byteaddress); }
INLINE UINT64 cpu_readop64(offs_t byteaddress) { if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_readop64_unsafe(byteaddress); }
INLINE UINT8 cpu_readop_arg(offs_t byteaddress) { if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_readop_arg_unsafe(byteaddress); }
INLINE UINT16 cpu_readop_arg16(offs_t byteaddress) { if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_readop_arg16_unsafe(byteaddress); }
INLINE UINT32 cpu_readop_arg32(offs_t byteaddress) { if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_readop_arg32_unsafe(byteaddress); }
INLINE UINT64 cpu_readop_arg64(offs_t byteaddress) { if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_readop_arg64_unsafe(byteaddress); }
/***************************************************************************
FUNCTION PROTOTYPES FOR CORE READ/WRITE ROUTINES
***************************************************************************/
@ -805,148 +960,4 @@ void io_write_qword_64le(offs_t address, UINT64 data);
void io_write_masked_64le(offs_t address, UINT64 data, UINT64 mem_mask);
/***************************************************************************
FUNCTION PROTOTYPES FOR CORE MEMORY FUNCTIONS
***************************************************************************/
/* memory setup function */
void memory_init(running_machine *machine);
void memory_set_context(int activecpu);
/* ----- address maps ----- */
/* build and allocate an address map for a CPU's address space */
address_map *address_map_alloc(const machine_config *drv, int cpunum, int spacenum);
/* release allocated memory for an address map */
void address_map_free(address_map *map);
/* return a pointer to the constructed address map for a CPU's address space */
const address_map *memory_get_address_map(int cpunum, int spacenum);
/* opcode base control */
opbase_handler_func memory_set_opbase_handler(int cpunum, opbase_handler_func function);
void memory_set_opbase(offs_t byteaddress);
/* separate opcode/data encryption helper */
void memory_set_decrypted_region(int cpunum, offs_t bytestart, offs_t byteend, void *base);
/* return a base pointer to memory */
void * memory_get_read_ptr(int cpunum, int spacenum, offs_t byteaddress);
void * memory_get_write_ptr(int cpunum, int spacenum, offs_t byteaddress);
void * memory_get_op_ptr(int cpunum, offs_t byteaddress, int arg);
/* memory banking */
void memory_configure_bank(int banknum, int startentry, int numentries, void *base, offs_t stride);
void memory_configure_bank_decrypted(int banknum, int startentry, int numentries, void *base, offs_t stride);
void memory_set_bank(int banknum, int entrynum);
int memory_get_bank(int banknum);
void memory_set_bankptr(int banknum, void *base);
const data_accessors *memory_get_accessors(int spacenum, int databits, int endianness);
/* debugging */
void memory_set_debugger_access(int debugger);
void memory_set_log_unmap(int spacenum, int log);
int memory_get_log_unmap(int spacenum);
/* dynamic address space mapping */
void * _memory_install_read_handler (int cpunum, int spacenum, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, FPTR handler, const char *handler_name);
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);
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);
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);
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);
void * _memory_install_write_handler (int cpunum, int spacenum, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, FPTR handler, const char *handler_name);
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);
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);
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);
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);
void * _memory_install_readwrite_handler (int cpunum, int spacenum, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, FPTR rhandler, FPTR whandler, const char *rhandler_name, const char *whandler_name);
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);
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);
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);
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);
/* memory debugging */
void memory_dump(FILE *file);
const char *memory_get_handler_string(int read0_or_write1, int cpunum, int spacenum, offs_t byteaddress);
/***************************************************************************
GLOBAL VARIABLES
***************************************************************************/
extern UINT8 opcode_entry; /* current entry for opcode fetching */
extern UINT8 * opcode_base; /* opcode ROM base */
extern UINT8 * opcode_arg_base; /* opcode RAM base */
extern offs_t opcode_mask; /* mask to apply to the opcode address */
extern offs_t opcode_memory_min; /* opcode memory minimum */
extern offs_t opcode_memory_max; /* opcode memory maximum */
extern address_space active_address_space[]; /* address spaces */
extern const char *const address_space_names[ADDRESS_SPACES];
/***************************************************************************
HELPER MACROS AND INLINES
***************************************************************************/
/* generic memory access */
INLINE UINT8 program_read_byte (offs_t byteaddress) { return (*active_address_space[ADDRESS_SPACE_PROGRAM].accessors->read_byte)(byteaddress); }
INLINE UINT16 program_read_word (offs_t byteaddress) { return (*active_address_space[ADDRESS_SPACE_PROGRAM].accessors->read_word)(byteaddress); }
INLINE UINT32 program_read_dword(offs_t byteaddress) { return (*active_address_space[ADDRESS_SPACE_PROGRAM].accessors->read_dword)(byteaddress); }
INLINE UINT64 program_read_qword(offs_t byteaddress) { return (*active_address_space[ADDRESS_SPACE_PROGRAM].accessors->read_qword)(byteaddress); }
INLINE void program_write_byte (offs_t byteaddress, UINT8 data) { (*active_address_space[ADDRESS_SPACE_PROGRAM].accessors->write_byte)(byteaddress, data); }
INLINE void program_write_word (offs_t byteaddress, UINT16 data) { (*active_address_space[ADDRESS_SPACE_PROGRAM].accessors->write_word)(byteaddress, data); }
INLINE void program_write_dword(offs_t byteaddress, UINT32 data) { (*active_address_space[ADDRESS_SPACE_PROGRAM].accessors->write_dword)(byteaddress, data); }
INLINE void program_write_qword(offs_t byteaddress, UINT64 data) { (*active_address_space[ADDRESS_SPACE_PROGRAM].accessors->write_qword)(byteaddress, data); }
INLINE UINT8 data_read_byte (offs_t byteaddress) { return (*active_address_space[ADDRESS_SPACE_DATA].accessors->read_byte)(byteaddress); }
INLINE UINT16 data_read_word (offs_t byteaddress) { return (*active_address_space[ADDRESS_SPACE_DATA].accessors->read_word)(byteaddress); }
INLINE UINT32 data_read_dword(offs_t byteaddress) { return (*active_address_space[ADDRESS_SPACE_DATA].accessors->read_dword)(byteaddress); }
INLINE UINT64 data_read_qword(offs_t byteaddress) { return (*active_address_space[ADDRESS_SPACE_DATA].accessors->read_qword)(byteaddress); }
INLINE void data_write_byte (offs_t byteaddress, UINT8 data) { (*active_address_space[ADDRESS_SPACE_DATA].accessors->write_byte)(byteaddress, data); }
INLINE void data_write_word (offs_t byteaddress, UINT16 data) { (*active_address_space[ADDRESS_SPACE_DATA].accessors->write_word)(byteaddress, data); }
INLINE void data_write_dword(offs_t byteaddress, UINT32 data) { (*active_address_space[ADDRESS_SPACE_DATA].accessors->write_dword)(byteaddress, data); }
INLINE void data_write_qword(offs_t byteaddress, UINT64 data) { (*active_address_space[ADDRESS_SPACE_DATA].accessors->write_qword)(byteaddress, data); }
INLINE UINT8 io_read_byte (offs_t byteaddress) { return (*active_address_space[ADDRESS_SPACE_IO].accessors->read_byte)(byteaddress); }
INLINE UINT16 io_read_word (offs_t byteaddress) { return (*active_address_space[ADDRESS_SPACE_IO].accessors->read_word)(byteaddress); }
INLINE UINT32 io_read_dword(offs_t byteaddress) { return (*active_address_space[ADDRESS_SPACE_IO].accessors->read_dword)(byteaddress); }
INLINE UINT64 io_read_qword(offs_t byteaddress) { return (*active_address_space[ADDRESS_SPACE_IO].accessors->read_qword)(byteaddress); }
INLINE void io_write_byte (offs_t byteaddress, UINT8 data) { (*active_address_space[ADDRESS_SPACE_IO].accessors->write_byte)(byteaddress, data); }
INLINE void io_write_word (offs_t byteaddress, UINT16 data) { (*active_address_space[ADDRESS_SPACE_IO].accessors->write_word)(byteaddress, data); }
INLINE void io_write_dword(offs_t byteaddress, UINT32 data) { (*active_address_space[ADDRESS_SPACE_IO].accessors->write_dword)(byteaddress, data); }
INLINE void io_write_qword(offs_t byteaddress, UINT64 data) { (*active_address_space[ADDRESS_SPACE_IO].accessors->write_qword)(byteaddress, data); }
/* safe opcode and opcode argument reading */
UINT8 cpu_readop_safe(offs_t byteaddress);
UINT16 cpu_readop16_safe(offs_t byteaddress);
UINT32 cpu_readop32_safe(offs_t byteaddress);
UINT64 cpu_readop64_safe(offs_t byteaddress);
UINT8 cpu_readop_arg_safe(offs_t byteaddress);
UINT16 cpu_readop_arg16_safe(offs_t byteaddress);
UINT32 cpu_readop_arg32_safe(offs_t byteaddress);
UINT64 cpu_readop_arg64_safe(offs_t byteaddress);
/* opcode and opcode argument reading */
INLINE void * cpu_opptr(offs_t byteaddress) { if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_opptr_unsafe(byteaddress); }
INLINE UINT8 cpu_readop(offs_t byteaddress) { if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_readop_unsafe(byteaddress); }
INLINE UINT16 cpu_readop16(offs_t byteaddress) { if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_readop16_unsafe(byteaddress); }
INLINE UINT32 cpu_readop32(offs_t byteaddress) { if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_readop32_unsafe(byteaddress); }
INLINE UINT64 cpu_readop64(offs_t byteaddress) { if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_readop64_unsafe(byteaddress); }
INLINE UINT8 cpu_readop_arg(offs_t byteaddress) { if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_readop_arg_unsafe(byteaddress); }
INLINE UINT16 cpu_readop_arg16(offs_t byteaddress) { if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_readop_arg16_unsafe(byteaddress); }
INLINE UINT32 cpu_readop_arg32(offs_t byteaddress) { if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_readop_arg32_unsafe(byteaddress); }
INLINE UINT64 cpu_readop_arg64(offs_t byteaddress) { if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_readop_arg64_unsafe(byteaddress); }
#endif /* __MEMORY_H__ */

View File

@ -263,6 +263,9 @@ INLINE tilemap *indexed_tilemap(int index)
void tilemap_init(running_machine *machine)
{
if (machine->primary_screen == NULL)
return;
screen_width = video_screen_get_width(machine->primary_screen);
screen_height = video_screen_get_height(machine->primary_screen);

File diff suppressed because it is too large Load Diff

View File

@ -14,19 +14,26 @@
#define RENDER_LOW (1)
#define RENDER_AUTO (2)
void v9938_init (running_machine *, int, int, void (*callback)(int));
void v9938_reset (void);
int v9938_interrupt (void);
void v9938_set_sprite_limit (int);
void v9938_set_resolution (int);
void v9938_init (running_machine *, int which, bitmap_t *bitmap, int, int, void (*callback)(int));
void v9938_reset (int which);
int v9938_interrupt (int which);
void v9938_set_sprite_limit (int which, int);
void v9938_set_resolution (int which, int);
int v9938_get_transpen(int which);
extern PALETTE_INIT( v9938 );
extern PALETTE_INIT( v9958 );
extern WRITE8_HANDLER( v9938_palette_w );
extern WRITE8_HANDLER( v9938_vram_w );
extern READ8_HANDLER( v9938_vram_r );
extern WRITE8_HANDLER( v9938_command_w );
extern READ8_HANDLER( v9938_status_r );
extern WRITE8_HANDLER( v9938_register_w );
extern WRITE8_HANDLER( v9938_0_palette_w );
extern WRITE8_HANDLER( v9938_1_palette_w );
extern WRITE8_HANDLER( v9938_0_vram_w );
extern WRITE8_HANDLER( v9938_1_vram_w );
extern READ8_HANDLER( v9938_0_vram_r );
extern READ8_HANDLER( v9938_1_vram_r );
extern WRITE8_HANDLER( v9938_0_command_w );
extern WRITE8_HANDLER( v9938_1_command_w );
extern READ8_HANDLER( v9938_0_status_r );
extern READ8_HANDLER( v9938_1_status_r );
extern WRITE8_HANDLER( v9938_0_register_w );
extern WRITE8_HANDLER( v9938_1_register_w );
void v9938_update_mouse_state(int mx_delta, int my_delta, int button_state);
void v9938_update_mouse_state(int which, int mx_delta, int my_delta, int button_state);

View File

@ -37,11 +37,11 @@ V9938_BORDER_FUNC (default_border)
PEN_TYPE pen;
int i;
pen = Machine->pens[pal_ind16[(vdp.contReg[7]&0x0f)]];
pen = Machine->pens[vdp->pal_ind16[(vdp->contReg[7]&0x0f)]];
i = V9938_WIDTH;
while (i--) *ln++ = pen;
if (vdp.size_now != RENDER_HIGH) vdp.size_now = RENDER_LOW;
if (vdp->size_now != RENDER_HIGH) vdp->size_now = RENDER_LOW;
}
V9938_BORDER_FUNC (graphic7_border)
@ -49,11 +49,11 @@ V9938_BORDER_FUNC (graphic7_border)
PEN_TYPE pen;
int i;
pen = Machine->pens[pal_ind256[vdp.contReg[7]]];
pen = Machine->pens[vdp->pal_ind256[vdp->contReg[7]]];
i = V9938_WIDTH;
while (i--) *ln++ = pen;
if (vdp.size_now != RENDER_HIGH) vdp.size_now = RENDER_LOW;
if (vdp->size_now != RENDER_HIGH) vdp->size_now = RENDER_LOW;
}
V9938_BORDER_FUNC (graphic5_border)
@ -63,16 +63,16 @@ V9938_BORDER_FUNC (graphic5_border)
#if (V9938_WIDTH > 512)
PEN_TYPE pen1;
pen1 = Machine->pens[pal_ind16[(vdp.contReg[7]&0x03)]];
pen0 = Machine->pens[pal_ind16[((vdp.contReg[7]>>2)&0x03)]];
pen1 = Machine->pens[vdp->pal_ind16[(vdp->contReg[7]&0x03)]];
pen0 = Machine->pens[vdp->pal_ind16[((vdp->contReg[7]>>2)&0x03)]];
i = (V9938_WIDTH) / 2;
while (i--) { *ln++ = pen0; *ln++ = pen1; }
#else
pen0 = Machine->pens[pal_ind16[((vdp.contReg[7]>>2)&0x03)]];
pen0 = Machine->pens[vdp->pal_ind16[((vdp->contReg[7]>>2)&0x03)]];
i = V9938_WIDTH;
while (i--) *ln++ = pen0;
#endif
vdp.size_now = RENDER_HIGH;
vdp->size_now = RENDER_HIGH;
}
V9938_MODE_FUNC (mode_text1)
@ -81,17 +81,17 @@ V9938_MODE_FUNC (mode_text1)
PEN_TYPE fg, bg, pen;
UINT8 *nametbl, *patterntbl;
patterntbl = vdp.vram + (vdp.contReg[4] << 11);
nametbl = vdp.vram + (vdp.contReg[2] << 10);
patterntbl = vdp->vram + (vdp->contReg[4] << 11);
nametbl = vdp->vram + (vdp->contReg[2] << 10);
fg = Machine->pens[pal_ind16[vdp.contReg[7] >> 4]];
bg = Machine->pens[pal_ind16[vdp.contReg[7] & 15]];
fg = Machine->pens[vdp->pal_ind16[vdp->contReg[7] >> 4]];
bg = Machine->pens[vdp->pal_ind16[vdp->contReg[7] & 15]];
name = (line/8)*40;
pen = Machine->pens[pal_ind16[(vdp.contReg[7]&0x0f)]];
pen = Machine->pens[vdp->pal_ind16[(vdp->contReg[7]&0x0f)]];
xxx = vdp.offset_x + 8;
xxx = vdp->offset_x + 8;
#if (V9938_WIDTH > 512)
xxx *= 2;
#endif
@ -100,7 +100,7 @@ V9938_MODE_FUNC (mode_text1)
for (x=0;x<40;x++)
{
pattern = patterntbl[(nametbl[name] * 8) +
((line + vdp.contReg[23]) & 7)];
((line + vdp->contReg[23]) & 7)];
for (xx=0;xx<6;xx++)
{
*ln++ = (pattern & 0x80) ? fg : bg;
@ -113,12 +113,12 @@ V9938_MODE_FUNC (mode_text1)
name = (name + 1) & 0x3ff;
}
xxx = (16 - vdp.offset_x) + 8;
xxx = (16 - vdp->offset_x) + 8;
#if (V9938_WIDTH > 512)
xxx *= 2;
#endif
while (xxx--) *ln++ = pen;
if (vdp.size_now != RENDER_HIGH) vdp.size_now = RENDER_LOW;
if (vdp->size_now != RENDER_HIGH) vdp->size_now = RENDER_LOW;
}
V9938_MODE_FUNC (mode_text2)
@ -127,25 +127,25 @@ V9938_MODE_FUNC (mode_text2)
PEN_TYPE fg, bg, fg0, bg0, pen;
UINT8 *nametbl, *patterntbl, *colourtbl;
patterntbl = vdp.vram + (vdp.contReg[4] << 11);
colourtbl = vdp.vram + ((vdp.contReg[3] & 0xf8) << 6) + (vdp.contReg[10] << 14);
patterntbl = vdp->vram + (vdp->contReg[4] << 11);
colourtbl = vdp->vram + ((vdp->contReg[3] & 0xf8) << 6) + (vdp->contReg[10] << 14);
#if 0
colourmask = ((vdp.contReg[3] & 7) << 5) | 0x1f; /* cause a bug in Forth+ v1.0 on Geneve */
colourmask = ((vdp->contReg[3] & 7) << 5) | 0x1f; /* cause a bug in Forth+ v1.0 on Geneve */
#else
colourmask = ((vdp.contReg[3] & 7) << 6) | 0x3f; /* verify! */
colourmask = ((vdp->contReg[3] & 7) << 6) | 0x3f; /* verify! */
#endif
nametbl = vdp.vram + ((vdp.contReg[2] & 0xfc) << 10);
patternmask = ((vdp.contReg[2] & 3) << 10) | 0x3ff; /* seems correct */
nametbl = vdp->vram + ((vdp->contReg[2] & 0xfc) << 10);
patternmask = ((vdp->contReg[2] & 3) << 10) | 0x3ff; /* seems correct */
fg = Machine->pens[pal_ind16[vdp.contReg[7] >> 4]];
bg = Machine->pens[pal_ind16[vdp.contReg[7] & 15]];
fg0 = Machine->pens[pal_ind16[vdp.contReg[12] >> 4]];
bg0 = Machine->pens[pal_ind16[vdp.contReg[12] & 15]];
fg = Machine->pens[vdp->pal_ind16[vdp->contReg[7] >> 4]];
bg = Machine->pens[vdp->pal_ind16[vdp->contReg[7] & 15]];
fg0 = Machine->pens[vdp->pal_ind16[vdp->contReg[12] >> 4]];
bg0 = Machine->pens[vdp->pal_ind16[vdp->contReg[12] & 15]];
name = (line/8)*80;
xxx = vdp.offset_x + 8;
pen = Machine->pens[pal_ind16[(vdp.contReg[7]&0x0f)]];
xxx = vdp->offset_x + 8;
pen = Machine->pens[vdp->pal_ind16[(vdp->contReg[7]&0x0f)]];
#if (V9938_WIDTH > 512)
xxx *= 2;
#endif
@ -154,13 +154,13 @@ V9938_MODE_FUNC (mode_text2)
for (x=0;x<80;x++)
{
charcode = nametbl[name&patternmask];
if (vdp.blink)
if (vdp->blink)
{
pattern = colourtbl[(name/8)&colourmask];
if (pattern & (0x80 >> (name & 7) ) )
{
pattern = patterntbl[(charcode * 8) +
((line + vdp.contReg[23]) & 7)];
((line + vdp->contReg[23]) & 7)];
#if (V9938_WIDTH > 512)
*ln++ = (pattern & 0x80) ? fg0 : bg0;
@ -181,7 +181,7 @@ V9938_MODE_FUNC (mode_text2)
}
pattern = patterntbl[(charcode * 8) +
((line + vdp.contReg[23]) & 7)];
((line + vdp->contReg[23]) & 7)];
#if (V9938_WIDTH > 512)
*ln++ = (pattern & 0x80) ? fg : bg;
@ -199,12 +199,12 @@ V9938_MODE_FUNC (mode_text2)
name++;
}
xxx = 16 - vdp.offset_x + 8;
xxx = 16 - vdp->offset_x + 8;
#if (V9938_WIDTH > 512)
xxx *= 2;
#endif
while (xxx--) *ln++ = pen;
vdp.size_now = RENDER_HIGH;
vdp->size_now = RENDER_HIGH;
}
V9938_MODE_FUNC (mode_multi)
@ -213,24 +213,24 @@ V9938_MODE_FUNC (mode_multi)
int name, line2, x, xx;
PEN_TYPE pen, pen_bg;
nametbl = vdp.vram + (vdp.contReg[2] << 10);
patterntbl = vdp.vram + (vdp.contReg[4] << 11);
nametbl = vdp->vram + (vdp->contReg[2] << 10);
patterntbl = vdp->vram + (vdp->contReg[4] << 11);
line2 = (line - vdp.contReg[23]) & 255;
line2 = (line - vdp->contReg[23]) & 255;
name = (line2/8)*32;
pen_bg = Machine->pens[pal_ind16[(vdp.contReg[7]&0x0f)]];
pen_bg = Machine->pens[vdp->pal_ind16[(vdp->contReg[7]&0x0f)]];
#if (V9938_WIDTH < 512)
xx = vdp.offset_x;
xx = vdp->offset_x;
#else
xx = vdp.offset_x * 2;
xx = vdp->offset_x * 2;
#endif
while (xx--) *ln++ = pen_bg;
for (x=0;x<32;x++)
{
colour = patterntbl[(nametbl[name] * 8) + ((line2/4)&7)];
pen = Machine->pens[pal_ind16[colour>>4]];
pen = Machine->pens[vdp->pal_ind16[colour>>4]];
/* eight pixels */
*ln++ = pen;
*ln++ = pen;
@ -242,7 +242,7 @@ V9938_MODE_FUNC (mode_multi)
*ln++ = pen;
*ln++ = pen;
#endif
pen = Machine->pens[pal_ind16[colour&15]];
pen = Machine->pens[vdp->pal_ind16[colour&15]];
/* eight pixels */
*ln++ = pen;
*ln++ = pen;
@ -257,12 +257,12 @@ V9938_MODE_FUNC (mode_multi)
name++;
}
xx = 16 - vdp.offset_x;
xx = 16 - vdp->offset_x;
#if (V9938_WIDTH > 512)
xx *= 2;
#endif
while (xx--) *ln++ = pen_bg;
if (vdp.size_now != RENDER_HIGH) vdp.size_now = RENDER_LOW;
if (vdp->size_now != RENDER_HIGH) vdp->size_now = RENDER_LOW;
}
V9938_MODE_FUNC (mode_graphic1)
@ -271,19 +271,19 @@ V9938_MODE_FUNC (mode_graphic1)
UINT8 *nametbl, *patterntbl, *colourtbl;
int pattern, x, xx, line2, name, charcode, colour, xxx;
nametbl = vdp.vram + (vdp.contReg[2] << 10);
colourtbl = vdp.vram + (vdp.contReg[3] << 6) + (vdp.contReg[10] << 14);
patterntbl = vdp.vram + (vdp.contReg[4] << 11);
nametbl = vdp->vram + (vdp->contReg[2] << 10);
colourtbl = vdp->vram + (vdp->contReg[3] << 6) + (vdp->contReg[10] << 14);
patterntbl = vdp->vram + (vdp->contReg[4] << 11);
line2 = (line - vdp.contReg[23]) & 255;
line2 = (line - vdp->contReg[23]) & 255;
name = (line2/8)*32;
pen = Machine->pens[pal_ind16[(vdp.contReg[7]&0x0f)]];
pen = Machine->pens[vdp->pal_ind16[(vdp->contReg[7]&0x0f)]];
#if (V9938_WIDTH < 512)
xxx = vdp.offset_x;
xxx = vdp->offset_x;
#else
xxx = vdp.offset_x * 2;
xxx = vdp->offset_x * 2;
#endif
while (xxx--) *ln++ = pen;
@ -291,8 +291,8 @@ V9938_MODE_FUNC (mode_graphic1)
{
charcode = nametbl[name];
colour = colourtbl[charcode/8];
fg = Machine->pens[pal_ind16[colour>>4]];
bg = Machine->pens[pal_ind16[colour&15]];
fg = Machine->pens[vdp->pal_ind16[colour>>4]];
bg = Machine->pens[vdp->pal_ind16[colour&15]];
pattern = patterntbl[charcode * 8 + (line2 & 7)];
for (xx=0;xx<8;xx++)
@ -306,12 +306,12 @@ V9938_MODE_FUNC (mode_graphic1)
name++;
}
xx = 16 - vdp.offset_x;
xx = 16 - vdp->offset_x;
#if (V9938_WIDTH > 512)
xx *= 2;
#endif
while (xx--) *ln++ = pen;
if (vdp.size_now != RENDER_HIGH) vdp.size_now = RENDER_LOW;
if (vdp->size_now != RENDER_HIGH) vdp->size_now = RENDER_LOW;
}
V9938_MODE_FUNC (mode_graphic23)
@ -321,21 +321,21 @@ V9938_MODE_FUNC (mode_graphic23)
int pattern, x, xx, line2, name, charcode,
colour, colourmask, patternmask, xxx;
colourmask = (vdp.contReg[3] & 0x7f) * 8 | 7;
patternmask = (vdp.contReg[4] & 0x03) * 256 | (colourmask & 255);
colourmask = (vdp->contReg[3] & 0x7f) * 8 | 7;
patternmask = (vdp->contReg[4] & 0x03) * 256 | (colourmask & 255);
nametbl = vdp.vram + (vdp.contReg[2] << 10);
colourtbl = vdp.vram + ((vdp.contReg[3] & 0x80) << 6) + (vdp.contReg[10] << 14);
patterntbl = vdp.vram + ((vdp.contReg[4] & 0x3c) << 11);
nametbl = vdp->vram + (vdp->contReg[2] << 10);
colourtbl = vdp->vram + ((vdp->contReg[3] & 0x80) << 6) + (vdp->contReg[10] << 14);
patterntbl = vdp->vram + ((vdp->contReg[4] & 0x3c) << 11);
line2 = (line + vdp.contReg[23]) & 255;
line2 = (line + vdp->contReg[23]) & 255;
name = (line2/8)*32;
pen = Machine->pens[pal_ind16[(vdp.contReg[7]&0x0f)]];
pen = Machine->pens[vdp->pal_ind16[(vdp->contReg[7]&0x0f)]];
#if (V9938_WIDTH < 512)
xxx = vdp.offset_x;
xxx = vdp->offset_x;
#else
xxx = vdp.offset_x * 2;
xxx = vdp->offset_x * 2;
#endif
while (xxx--) *ln++ = pen;
@ -344,8 +344,8 @@ V9938_MODE_FUNC (mode_graphic23)
charcode = nametbl[name] + (line2&0xc0)*4;
colour = colourtbl[(charcode&colourmask)*8+(line2&7)];
pattern = patterntbl[(charcode&patternmask)*8+(line2&7)];
fg = Machine->pens[pal_ind16[colour>>4]];
bg = Machine->pens[pal_ind16[colour&15]];
fg = Machine->pens[vdp->pal_ind16[colour>>4]];
bg = Machine->pens[vdp->pal_ind16[colour&15]];
for (xx=0;xx<8;xx++)
{
*ln++ = (pattern & 0x80) ? fg : bg;
@ -357,12 +357,12 @@ V9938_MODE_FUNC (mode_graphic23)
name++;
}
xx = 16 - vdp.offset_x;
xx = 16 - vdp->offset_x;
#if (V9938_WIDTH > 512)
xx *= 2;
#endif
while (xx--) *ln++ = pen;
if (vdp.size_now != RENDER_HIGH) vdp.size_now = RENDER_LOW;
if (vdp->size_now != RENDER_HIGH) vdp->size_now = RENDER_LOW;
}
V9938_MODE_FUNC (mode_graphic4)
@ -371,43 +371,43 @@ V9938_MODE_FUNC (mode_graphic4)
int line2, linemask, x, xx;
PEN_TYPE pen, pen_bg;
linemask = ((vdp.contReg[2] & 0x1f) << 3) | 7;
linemask = ((vdp->contReg[2] & 0x1f) << 3) | 7;
line2 = ((line + vdp.contReg[23]) & linemask) & 255;
line2 = ((line + vdp->contReg[23]) & linemask) & 255;
nametbl = vdp.vram + ((vdp.contReg[2] & 0x40) << 10) + line2 * 128;
if ( (vdp.contReg[2] & 0x20) && (V9938_SECOND_FIELD) )
nametbl = vdp->vram + ((vdp->contReg[2] & 0x40) << 10) + line2 * 128;
if ( (vdp->contReg[2] & 0x20) && (V9938_SECOND_FIELD) )
nametbl += 0x8000;
pen_bg = Machine->pens[pal_ind16[(vdp.contReg[7]&0x0f)]];
pen_bg = Machine->pens[vdp->pal_ind16[(vdp->contReg[7]&0x0f)]];
#if (V9938_WIDTH < 512)
xx = vdp.offset_x;
xx = vdp->offset_x;
#else
xx = vdp.offset_x * 2;
xx = vdp->offset_x * 2;
#endif
while (xx--) *ln++ = pen_bg;
for (x=0;x<128;x++)
{
colour = *nametbl++;
pen = Machine->pens[pal_ind16[colour>>4]];
pen = Machine->pens[vdp->pal_ind16[colour>>4]];
*ln++ = pen;
#if (V9938_WIDTH > 512)
*ln++ = pen;
#endif
pen = Machine->pens[pal_ind16[colour&15]];
pen = Machine->pens[vdp->pal_ind16[colour&15]];
*ln++ = pen;
#if (V9938_WIDTH > 512)
*ln++ = pen;
#endif
}
xx = 16 - vdp.offset_x;
xx = 16 - vdp->offset_x;
#if (V9938_WIDTH > 512)
xx *= 2;
#endif
while (xx--) *ln++ = pen_bg;
if (vdp.size_now != RENDER_HIGH) vdp.size_now = RENDER_LOW;
if (vdp->size_now != RENDER_HIGH) vdp->size_now = RENDER_LOW;
}
V9938_MODE_FUNC (mode_graphic5)
@ -419,27 +419,27 @@ V9938_MODE_FUNC (mode_graphic5)
PEN_TYPE pen_bg1[4];
#endif
linemask = ((vdp.contReg[2] & 0x1f) << 3) | 7;
linemask = ((vdp->contReg[2] & 0x1f) << 3) | 7;
line2 = ((line + vdp.contReg[23]) & linemask) & 255;
line2 = ((line + vdp->contReg[23]) & linemask) & 255;
nametbl = vdp.vram + ((vdp.contReg[2] & 0x40) << 10) + line2 * 128;
if ( (vdp.contReg[2] & 0x20) && (V9938_SECOND_FIELD) )
nametbl = vdp->vram + ((vdp->contReg[2] & 0x40) << 10) + line2 * 128;
if ( (vdp->contReg[2] & 0x20) && (V9938_SECOND_FIELD) )
nametbl += 0x8000;
#if (V9938_WIDTH > 512)
pen_bg1[0] = Machine->pens[pal_ind16[(vdp.contReg[7]&0x03)]];
pen_bg0[0] = Machine->pens[pal_ind16[((vdp.contReg[7]>>2)&0x03)]];
pen_bg1[0] = Machine->pens[vdp->pal_ind16[(vdp->contReg[7]&0x03)]];
pen_bg0[0] = Machine->pens[vdp->pal_ind16[((vdp->contReg[7]>>2)&0x03)]];
xx = vdp.offset_x;
xx = vdp->offset_x;
while (xx--) { *ln++ = pen_bg0[0]; *ln++ = pen_bg1[0]; }
x = (vdp.contReg[8] & 0x20) ? 0 : 1;
x = (vdp->contReg[8] & 0x20) ? 0 : 1;
for (;x<4;x++)
{
pen_bg0[x] = Machine->pens[pal_ind16[x]];
pen_bg1[x] = Machine->pens[pal_ind16[x]];
pen_bg0[x] = Machine->pens[vdp->pal_ind16[x]];
pen_bg1[x] = Machine->pens[vdp->pal_ind16[x]];
}
for (x=0;x<128;x++)
@ -452,19 +452,19 @@ V9938_MODE_FUNC (mode_graphic5)
*ln++ = pen_bg1[(colour&3)];
}
pen_bg1[0] = Machine->pens[pal_ind16[(vdp.contReg[7]&0x03)]];
pen_bg0[0] = Machine->pens[pal_ind16[((vdp.contReg[7]>>2)&0x03)]];
xx = 16 - vdp.offset_x;
pen_bg1[0] = Machine->pens[vdp->pal_ind16[(vdp->contReg[7]&0x03)]];
pen_bg0[0] = Machine->pens[vdp->pal_ind16[((vdp->contReg[7]>>2)&0x03)]];
xx = 16 - vdp->offset_x;
while (xx--) { *ln++ = pen_bg0[0]; *ln++ = pen_bg1[0]; }
#else
pen_bg0[0] = Machine->pens[pal_ind16[((vdp.contReg[7]>>2)&0x03)]];
pen_bg0[0] = Machine->pens[vdp->pal_ind16[((vdp->contReg[7]>>2)&0x03)]];
x = (vdp.contReg[8] & 0x20) ? 0 : 1;
x = (vdp->contReg[8] & 0x20) ? 0 : 1;
for (;x<4;x++)
pen_bg0[x] = Machine->pens[pal_ind16[x]];
pen_bg0[x] = Machine->pens[vdp->pal_ind16[x]];
xx = vdp.offset_x;
xx = vdp->offset_x;
while (xx--) *ln++ = pen_bg0[0];
for (x=0;x<128;x++)
@ -474,11 +474,11 @@ V9938_MODE_FUNC (mode_graphic5)
*ln++ = pen_bg0[(colour>>2)&3];
}
pen_bg0[0] = Machine->pens[pal_ind16[((vdp.contReg[7]>>2)&0x03)]];
xx = 16 - vdp.offset_x;
pen_bg0[0] = Machine->pens[vdp->pal_ind16[((vdp->contReg[7]>>2)&0x03)]];
xx = 16 - vdp->offset_x;
while (xx--) *ln++ = pen_bg0[0];
#endif
vdp.size_now = RENDER_HIGH;
vdp->size_now = RENDER_HIGH;
}
V9938_MODE_FUNC (mode_graphic6)
@ -490,36 +490,36 @@ V9938_MODE_FUNC (mode_graphic6)
PEN_TYPE fg1;
#endif
linemask = ((vdp.contReg[2] & 0x1f) << 3) | 7;
linemask = ((vdp->contReg[2] & 0x1f) << 3) | 7;
line2 = ((line + vdp.contReg[23]) & linemask) & 255;
line2 = ((line + vdp->contReg[23]) & linemask) & 255;
nametbl = line2 << 8 ;
if ( (vdp.contReg[2] & 0x20) && (V9938_SECOND_FIELD) )
if ( (vdp->contReg[2] & 0x20) && (V9938_SECOND_FIELD) )
nametbl += 0x10000;
pen_bg = Machine->pens[pal_ind16[(vdp.contReg[7]&0x0f)]];
pen_bg = Machine->pens[vdp->pal_ind16[(vdp->contReg[7]&0x0f)]];
#if (V9938_WIDTH < 512)
xx = vdp.offset_x;
xx = vdp->offset_x;
#else
xx = vdp.offset_x * 2;
xx = vdp->offset_x * 2;
#endif
while (xx--) *ln++ = pen_bg;
if (vdp.contReg[2] & 0x40)
if (vdp->contReg[2] & 0x40)
{
for (x=0;x<32;x++)
{
nametbl++;
colour = vdp.vram[((nametbl&1) << 16) | (nametbl>>1)];
fg0 = Machine->pens[pal_ind16[colour>>4]];
colour = vdp->vram[((nametbl&1) << 16) | (nametbl>>1)];
fg0 = Machine->pens[vdp->pal_ind16[colour>>4]];
#if (V9938_WIDTH < 512)
*ln++ = fg0; *ln++ = fg0;
*ln++ = fg0; *ln++ = fg0;
*ln++ = fg0; *ln++ = fg0;
*ln++ = fg0; *ln++ = fg0;
#else
fg1 = Machine->pens[pal_ind16[colour&15]];
fg1 = Machine->pens[vdp->pal_ind16[colour&15]];
*ln++ = fg0; *ln++ = fg1; *ln++ = fg0; *ln++ = fg1;
*ln++ = fg0; *ln++ = fg1; *ln++ = fg0; *ln++ = fg1;
*ln++ = fg0; *ln++ = fg1; *ln++ = fg0; *ln++ = fg1;
@ -532,21 +532,21 @@ V9938_MODE_FUNC (mode_graphic6)
{
for (x=0;x<256;x++)
{
colour = vdp.vram[((nametbl&1) << 16) | (nametbl>>1)];
*ln++ = Machine->pens[pal_ind16[colour>>4]];
colour = vdp->vram[((nametbl&1) << 16) | (nametbl>>1)];
*ln++ = Machine->pens[vdp->pal_ind16[colour>>4]];
#if (V9938_WIDTH > 512)
*ln++ = Machine->pens[pal_ind16[colour&15]];
*ln++ = Machine->pens[vdp->pal_ind16[colour&15]];
#endif
nametbl++;
}
}
xx = 16 - vdp.offset_x;
xx = 16 - vdp->offset_x;
#if (V9938_WIDTH > 512)
xx *= 2;
#endif
while (xx--) *ln++ = pen_bg;
vdp.size_now = RENDER_HIGH;
vdp->size_now = RENDER_HIGH;
}
V9938_MODE_FUNC (mode_graphic7)
@ -555,29 +555,29 @@ V9938_MODE_FUNC (mode_graphic7)
int line2, linemask, x, xx, nametbl;
PEN_TYPE pen, pen_bg;
linemask = ((vdp.contReg[2] & 0x1f) << 3) | 7;
linemask = ((vdp->contReg[2] & 0x1f) << 3) | 7;
line2 = ((line + vdp.contReg[23]) & linemask) & 255;
line2 = ((line + vdp->contReg[23]) & linemask) & 255;
nametbl = line2 << 8;
if ( (vdp.contReg[2] & 0x20) && (V9938_SECOND_FIELD) )
if ( (vdp->contReg[2] & 0x20) && (V9938_SECOND_FIELD) )
nametbl += 0x10000;
pen_bg = Machine->pens[pal_ind256[vdp.contReg[7]]];
pen_bg = Machine->pens[vdp->pal_ind256[vdp->contReg[7]]];
#if (V9938_WIDTH < 512)
xx = vdp.offset_x;
xx = vdp->offset_x;
#else
xx = vdp.offset_x * 2;
xx = vdp->offset_x * 2;
#endif
while (xx--) *ln++ = pen_bg;
if (vdp.contReg[2] & 0x40)
if (vdp->contReg[2] & 0x40)
{
for (x=0;x<32;x++)
{
nametbl++;
colour = vdp.vram[((nametbl&1) << 16) | (nametbl>>1)];
pen = Machine->pens[pal_ind256[colour]];
colour = vdp->vram[((nametbl&1) << 16) | (nametbl>>1)];
pen = Machine->pens[vdp->pal_ind256[colour]];
*ln++ = pen; *ln++ = pen;
*ln++ = pen; *ln++ = pen;
*ln++ = pen; *ln++ = pen;
@ -595,8 +595,8 @@ V9938_MODE_FUNC (mode_graphic7)
{
for (x=0;x<256;x++)
{
colour = vdp.vram[((nametbl&1) << 16) | (nametbl>>1)];
pen = Machine->pens[pal_ind256[colour]];
colour = vdp->vram[((nametbl&1) << 16) | (nametbl>>1)];
pen = Machine->pens[vdp->pal_ind256[colour]];
*ln++ = pen;
#if (V9938_WIDTH > 512)
*ln++ = pen;
@ -605,12 +605,12 @@ V9938_MODE_FUNC (mode_graphic7)
}
}
xx = 16 - vdp.offset_x;
xx = 16 - vdp->offset_x;
#if (V9938_WIDTH > 512)
xx *= 2;
#endif
while (xx--) *ln++ = pen_bg;
if (vdp.size_now != RENDER_HIGH) vdp.size_now = RENDER_LOW;
if (vdp->size_now != RENDER_HIGH) vdp->size_now = RENDER_LOW;
}
V9938_MODE_FUNC (mode_unknown)
@ -618,47 +618,47 @@ V9938_MODE_FUNC (mode_unknown)
PEN_TYPE fg, bg;
int x;
fg = Machine->pens[pal_ind16[vdp.contReg[7] >> 4]];
bg = Machine->pens[pal_ind16[vdp.contReg[7] & 15]];
fg = Machine->pens[vdp->pal_ind16[vdp->contReg[7] >> 4]];
bg = Machine->pens[vdp->pal_ind16[vdp->contReg[7] & 15]];
#if (V9938_WIDTH < 512)
x = vdp.offset_x;
x = vdp->offset_x;
while (x--) *ln++ = bg;
x = 256;
while (x--) *ln++ = fg;
x = 16 - vdp.offset_x;
x = 16 - vdp->offset_x;
while (x--) *ln++ = bg;
#else
x = vdp.offset_x * 2;
x = vdp->offset_x * 2;
while (x--) *ln++ = bg;
x = 512;
while (x--) *ln++ = fg;
x = (16 - vdp.offset_x) * 2;
x = (16 - vdp->offset_x) * 2;
while (x--) *ln++ = bg;
#endif
if (vdp.size_now != RENDER_HIGH) vdp.size_now = RENDER_LOW;
if (vdp->size_now != RENDER_HIGH) vdp->size_now = RENDER_LOW;
}
V9938_SPRITE_FUNC (default_draw_sprite)
{
int i;
#if (V9938_WIDTH > 512)
ln += vdp.offset_x * 2;
ln += vdp->offset_x * 2;
#else
ln += vdp.offset_x;
ln += vdp->offset_x;
#endif
for (i=0;i<256;i++)
{
if (col[i] & 0x80)
{
*ln++ = Machine->pens[pal_ind16[col[i]&0x0f]];
*ln++ = Machine->pens[vdp->pal_ind16[col[i]&0x0f]];
#if (V9938_WIDTH > 512)
*ln++ = Machine->pens[pal_ind16[col[i]&0x0f]];
*ln++ = Machine->pens[vdp->pal_ind16[col[i]&0x0f]];
#endif
}
else
@ -673,18 +673,18 @@ V9938_SPRITE_FUNC (graphic5_draw_sprite)
{
int i;
#if (V9938_WIDTH > 512)
ln += vdp.offset_x * 2;
ln += vdp->offset_x * 2;
#else
ln += vdp.offset_x;
ln += vdp->offset_x;
#endif
for (i=0;i<256;i++)
{
if (col[i] & 0x80)
{
*ln++ = Machine->pens[pal_ind16[(col[i]>>2)&0x03]];
*ln++ = Machine->pens[vdp->pal_ind16[(col[i]>>2)&0x03]];
#if (V9938_WIDTH > 512)
*ln++ = Machine->pens[pal_ind16[col[i]&0x03]];
*ln++ = Machine->pens[vdp->pal_ind16[col[i]&0x03]];
#endif
}
else
@ -705,9 +705,9 @@ V9938_SPRITE_FUNC (graphic7_draw_sprite)
int i;
#if (V9938_WIDTH > 512)
ln += vdp.offset_x * 2;
ln += vdp->offset_x * 2;
#else
ln += vdp.offset_x;
ln += vdp->offset_x;
#endif
for (i=0;i<256;i++)

View File

@ -2259,8 +2259,8 @@ static void init_firebeat(running_machine *machine)
rtc65271_init(xram, NULL);
pc16552d_init(0, 19660800, comm_uart_irq_callback); // Network UART
pc16552d_init(1, 24000000, midi_uart_irq_callback); // MIDI UART
pc16552d_init(0, 19660800, comm_uart_irq_callback, 0); // Network UART
pc16552d_init(1, 24000000, midi_uart_irq_callback, 0); // MIDI UART
extend_board_irq_enable = 0x3f;
extend_board_irq_active = 0x00;

File diff suppressed because it is too large Load Diff

View File

@ -78,8 +78,8 @@ static WRITE8_HANDLER(pzlestar_bank_w)
static ADDRESS_MAP_START (readport_pzlestar, ADDRESS_SPACE_IO, 8)
ADDRESS_MAP_GLOBAL_MASK(0xff)
AM_RANGE( 0x98, 0x98) AM_READ( v9938_vram_r )
AM_RANGE( 0x99, 0x99) AM_READ( v9938_status_r )
AM_RANGE( 0x98, 0x98) AM_READ( v9938_0_vram_r )
AM_RANGE( 0x99, 0x99) AM_READ( v9938_0_status_r )
AM_RANGE( 0xa0, 0xa0) AM_READ( input_port_0_r )
AM_RANGE( 0xa1, 0xa1) AM_READ( input_port_1_r )
AM_RANGE( 0xf7, 0xf7) AM_READ( input_port_2_r )
@ -90,10 +90,10 @@ static ADDRESS_MAP_START (writeport_pzlestar, ADDRESS_SPACE_IO, 8)
AM_RANGE( 0x91, 0x91) AM_WRITE( pzlestar_bank_w )
AM_RANGE( 0x7c, 0x7c) AM_WRITE( YM2413_register_port_0_w )
AM_RANGE( 0x7d, 0x7d) AM_WRITE( YM2413_data_port_0_w )
AM_RANGE( 0x98, 0x98) AM_WRITE( v9938_vram_w )
AM_RANGE( 0x99, 0x99) AM_WRITE( v9938_command_w )
AM_RANGE( 0x9a, 0x9a) AM_WRITE( v9938_palette_w )
AM_RANGE( 0x9b, 0x9b) AM_WRITE( v9938_register_w )
AM_RANGE( 0x98, 0x98) AM_WRITE( v9938_0_vram_w )
AM_RANGE( 0x99, 0x99) AM_WRITE( v9938_0_command_w )
AM_RANGE( 0x9a, 0x9a) AM_WRITE( v9938_0_palette_w )
AM_RANGE( 0x9b, 0x9b) AM_WRITE( v9938_0_register_w )
ADDRESS_MAP_END
/* Sexy Boom Ports */
@ -103,18 +103,18 @@ static ADDRESS_MAP_START (readport_sexyboom, ADDRESS_SPACE_IO, 8)
AM_RANGE( 0xa0, 0xa0) AM_READ( input_port_0_r )
AM_RANGE( 0xa1, 0xa1) AM_READ( input_port_1_r )
AM_RANGE( 0xf7, 0xf7) AM_READ( input_port_2_r )
AM_RANGE( 0xf0, 0xf0) AM_READ( v9938_vram_r )
AM_RANGE( 0xf1, 0xf1) AM_READ( v9938_status_r )
AM_RANGE( 0xf0, 0xf0) AM_READ( v9938_0_vram_r )
AM_RANGE( 0xf1, 0xf1) AM_READ( v9938_0_status_r )
ADDRESS_MAP_END
static ADDRESS_MAP_START (writeport_sexyboom, ADDRESS_SPACE_IO, 8)
ADDRESS_MAP_GLOBAL_MASK(0xff)
AM_RANGE( 0x7c, 0x7c) AM_WRITE( YM2413_register_port_0_w )
AM_RANGE( 0x7d, 0x7d) AM_WRITE( YM2413_data_port_0_w )
AM_RANGE( 0xf0, 0xf0) AM_WRITE( v9938_vram_w )
AM_RANGE( 0xf1, 0xf1) AM_WRITE( v9938_command_w )
AM_RANGE( 0xf2, 0xf2) AM_WRITE( v9938_palette_w )
AM_RANGE( 0xf3, 0xf3) AM_WRITE( v9938_register_w )
AM_RANGE( 0xf0, 0xf0) AM_WRITE( v9938_0_vram_w )
AM_RANGE( 0xf1, 0xf1) AM_WRITE( v9938_0_command_w )
AM_RANGE( 0xf2, 0xf2) AM_WRITE( v9938_0_palette_w )
AM_RANGE( 0xf3, 0xf3) AM_WRITE( v9938_0_register_w )
//bank f8-ff ???
ADDRESS_MAP_END
@ -185,7 +185,7 @@ static void sangho_common_machine_reset(void)
memory_set_bankptr(2,&sangho_ram[0x4000]);
memory_set_bankptr(3,&sangho_ram[0x8000]);
memory_set_bankptr(4,&sangho_ram[0xc000]);
v9938_reset();
v9938_reset(0);
}
@ -219,15 +219,15 @@ static void msx_vdp_interrupt(int i)
static INTERRUPT_GEN( sangho_interrupt )
{
v9938_set_sprite_limit(0);
v9938_set_resolution(2);
v9938_interrupt();
v9938_set_sprite_limit(0, 0);
v9938_set_resolution(0, 2);
v9938_interrupt(0);
}
static VIDEO_START( sangho )
{
v9938_init (machine, MODEL_V9938, 0x20000, msx_vdp_interrupt);
v9938_init (machine, 0, tmpbitmap, MODEL_V9938, 0x20000, msx_vdp_interrupt);
}
static MACHINE_DRIVER_START(pzlestar)

View File

@ -7767,6 +7767,8 @@ Other Sun games
DRIVER( spitboss ) /* (c) 198? Merit */
DRIVER( pitbossm ) /* (c) 1994 Merit */
DRIVER( megat3 ) /* (c) 1995 Merit */
DRIVER( megat4 ) /* (c) 1996 Merit */
DRIVER( megat4te ) /* (c) 1996 Merit */
DRIVER( megat5 ) /* (c) 1997 Merit */
DRIVER( megat6 ) /* (c) 1998 Merit */
DRIVER( suprgolf ) /* (c) 19?? Nasco */