MAMEWorld >> EmuChat
View all threads Index   Flat Mode Flat  

ShimaPong
MAME Fan
Reged: 03/12/05
Posts: 783
Send PM
Testers ID:4027 (20pacgal hangs at boot)
12/03/10 06:56 PM


I find the problem in the following routine. See memory.c.


Code:


void address_space::prepare_map()
{
const region_info *devregion = (m_spacenum == ADDRESS_SPACE_0) ? m_machine.region(m_device.tag()) : NULL;
UINT32 devregionsize = (devregion != NULL) ? devregion->bytes() : 0;

// allocate the address map
m_map = global_alloc(address_map(m_device.baseconfig(), m_spacenum));

// extract global parameters specified by the map
m_unmap = (m_map->m_unmapval == 0) ? 0 : ~0;
if (m_map->m_globalmask != 0)
{
m_addrmask = m_map->m_globalmask;
m_bytemask = address_to_byte_end(m_addrmask);
}

// make a pass over the address map, adjusting for the device and getting memory pointers
for (address_map_entry *entry = m_map->m_entrylist.first(); entry != NULL; entry = entry->next())
{
// computed adjusted addresses first
entry->m_bytestart = entry->m_addrstart;
entry->m_byteend = entry->m_addrend;
entry->m_bytemirror = entry->m_addrmirror;
entry->m_bytemask = entry->m_addrmask;
adjust_addresses(entry->m_bytestart, entry->m_byteend, entry->m_bytemask, entry->m_bytemirror);



"entry->m_addrmask" will be "0" in this time so that "entry->m_bytemask" also "0".
In this case, adjust_address() with mirror != 0 causes wrong mask adjustment.


Code:


inline void address_space::adjust_addresses(offs_t &start, offs_t &end, offs_t &mask, offs_t &mirror)
{
// adjust start/end/mask values
if (mask == 0)
mask = m_addrmask & ~mirror;
else
mask &= m_addrmask;
start &= ~mirror & m_addrmask;
end &= ~mirror & m_addrmask;



In 20pacgal.c, "0xA000 - 0xFFFF" is defined as "AM_RANGE(0x0a000, 0x0ffff) AM_MIRROR(0x40000) AM_ROM".
So... adjusted mask is "(0xFFFFF & 0xBFFFF (= ~0x40000)) = 0xBFFFF" (Not 0xFFFFF!).

This value is used in find_backing_memory() to add requested memory entry into each handlers.
The problem happens when compare "0xA000 - 0xFFFF" (ROM) vs "0x4FF00 - 0x4FFFF" (sprite_color_lookup).
Start_address is "0x4FF00 & 0xBFFFF = 0xFF00" and end_address is "0x4FFFF & 0xBFFFF = 0xFFFF".
So write_handler regists "ROM" entry as "sprite_color_lookup" and it breaks the contents of ROM at boot sequence.

Quick fix is...

Code:


// computed adjusted addresses first
entry->m_bytestart = entry->m_addrstart;
entry->m_byteend = entry->m_addrend;
entry->m_bytemirror = entry->m_addrmirror;
entry->m_bytemask = m_bytemask;
adjust_addresses(entry->m_bytestart, entry->m_byteend, entry->m_bytemask, entry->m_bytemirror);


Main point is that set tha value for (global) address_space's "m_bytemask" instead of address_map_entry's.


"Any company has no power to stop people emulating"
MAME is the emulator of no giving in the pressure from any company even if they don't allow







Entire thread
Subject Posted by Posted on
* Testers ID:4027 (20pacgal hangs at boot) ShimaPong 12/03/10 06:56 PM
. * Again ShimaPong  12/05/10 03:33 PM
. * > ALL ShimaPong  12/05/10 07:41 AM
. * Re: Testers ID:4027 (20pacgal hangs at boot) redk9258  12/04/10 04:03 AM
. * Re: Testers ID:4027 (20pacgal hangs at boot) R. Belmont  12/04/10 05:15 PM
. * Re: Testers ID:4027 (20pacgal hangs at boot) ShimaPong  12/04/10 04:24 PM
. * Re: Testers ID:4027 (20pacgal hangs at boot) redk9258  12/04/10 09:02 PM
. * Re: Testers ID:4027 (20pacgal hangs at boot) ShimaPong  12/04/10 03:34 AM
. * Re: Testers ID:4027 (20pacgal hangs at boot) redk9258  12/04/10 03:52 AM
. * Re: Testers ID:4027 (20pacgal hangs at boot) Mamesick  12/04/10 09:02 AM
. * Re: Testers ID:4027 (20pacgal hangs at boot) ShimaPong  12/04/10 04:28 PM
. * Re: Testers ID:4027 (20pacgal hangs at boot) Mamesick  12/04/10 05:26 PM
. * Re: Testers ID:4027 (20pacgal hangs at boot) ShimaPong  12/05/10 07:38 AM
. * Re: Testers ID:4027 (20pacgal hangs at boot) CrapBoardSoftware  12/04/10 03:50 PM
. * Re: Testers ID:4027 (20pacgal hangs at boot) swm3rd  12/04/10 06:21 PM

Extra information Permissions
Moderator:  Robbbert, Tafoid 
0 registered and 25 anonymous users are browsing this forum.
You cannot start new topics
You cannot reply to topics
HTML is enabled
UBBCode is enabled
Thread views: 2841