Skip to content

gridcomp/gridcomp.cpp: implement application ROMs#15193

Open
vklachkov wants to merge 1 commit intomamedev:masterfrom
vklachkov-contrib:gridrom-chapter-two
Open

gridcomp/gridcomp.cpp: implement application ROMs#15193
vklachkov wants to merge 1 commit intomamedev:masterfrom
vklachkov-contrib:gridrom-chapter-two

Conversation

@vklachkov
Copy link
Copy Markdown
Contributor

Continuation of PR #15159.

Adds Application ROM support to the GRiD Compass II. Implemented based on the CCPROM code. In the code, I tried to explain the logic of this mechanism in detail.

What remains unresolved is a TODO for a flag when installing 32KiB ROMs. I don't know exactly what it is for. But everything seems to work, here are the screenshot:

Screenshot with two ROM's

Works on both 1129 and 1139.

namespace {

#define I80130_TAG "osp"
#define NUMBER_OF_ROMS 4
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a constexpr within gridcomp_state would be more C++-y.


// TODO: Handle 32KB flag at offset 2.

if (offset == 8)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why didn't you put a specific handler at dfea8?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that all of this is implemented in a single PAL. That's why I decided to combine both the activator and the 32-kilobyte flag into a single function.

m_active_slots[offset / 2] = data;
}

uint8_t gridcomp_state::app_rom_r(offs_t offset)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is app_rom_r called often when running? Because there's a way to make it significantly more efficient (using banks and views) but it's a little more complicated. So does the system run from there or just cupy stuff to ram?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is called very often. Depending on the ROM, the laptop may either execute the code directly or copy the contents into memory. But judging by my logs, this is a pretty "hot" function.

I don't like this implementation, it smells of some kind of reinventing the wheel. But I didn't have the energy to figure out how to do it more cleanly, so I decided to make the PR as is. If you think such code has no place in MAME -- please point me to some machines I could look at for inspiration, and I'll be ready to redo app_rom_r...


// 4 slot selection registers are located at addresses:
// DFE0:8, DFE0:A, DFE0:C, and DFE0:E.
m_active_slots[offset / 2] = data;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when writing at odd addresses? Is A0 ignored (what you implemented) or is the write ignored?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know. There's no mention of this in the CCPROM code, and not a single program I know of writes to odd addresses. I decided to ignore writes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest a logerror() or similar if it happens, so that you know if it ever comes up.

Comment on lines +291 to +308
if (!m_roms_enabled)
return 0xFF;

// The address space of the ROM is divided into 4 "windows".
const uint32_t window_size = 0x8000;

// Calculate the quarter number from which we are reading.
const size_t quarter = offset / window_size;

// And look up which ROM slot is mapped to this window.
const size_t slot = m_active_slots[quarter];
const auto& rom = m_app_roms[slot];

// It does not matter what is returned if the ROM is not present because
// CCPROM checks the 0xBB66 marker at offset 9FF0:0,
// and then also verifies the checksum and other things.
if (!rom->exists())
return 0xFF;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kind of trivial compared to fixing the performance issues, but please use lowercase hex digits in MAME code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants