This document assumes some familiarty with the Sega Mark III, Sega Master
System (SMS) and Sega Game Gear (GG) game consoles. See the
Technical Documents section of
S8-Dev for information about these
systems.
Binary (Base 2) numbers are represented using the WLA-DX format of the "%"
symbol follwed by a string of binary digits (0 and 1). An example of a valid
binary number representation is: %11100110.
The Sega Mark III Architecture (SM3A) is based on
the Zilog Z80 microprocessor. This microprocessor is a
little-endian machine, meaning that bytes
of a word are numbered starting from the least-significant byte. As a
result, the SM3A and AGAMA extensions are also
little-endian. The least-significant byte in a word will always be stored to
memory first, at the lower address, followed by the most-significant byte at
the higher address.
Diagrams of data structures in memory will have lower memory addresses
towards the bottom of the page, with higher addresses growing towards the top
of the page.
where:
For example:
In this example, LOOP1 is a label, LD is the mnemonic identifier for the
opcode, HL is the destination operand, and STARTVALUE is the source operand.
Note, though, that this specification deviates slightly from Z80 assembly language with regard to the accumulator (the "A" register). In Z80 assembly
language, certain arithmetic instructions use an implied accumulator operand;
the accumulator is not explicitly specified in the instruction. For example,
the instruction:
Version 0.03.01 (April 2, 2004): Updated for release of MesaDX version 0.03a.
MesaDX 0.03a includes several bug fixes and includes support for Power-On
Configuration bit "SMS1 Bus".
Version 0.03.00 (March 13, 2004): Update for release of MesaDX version 0.03
Version 0.02.00 (August 26, 2001): Update for release of MesaDX version 0.02
Version 0.01.00 (June 10, 2001): Update for release of MesaDX version 0.01
Version 0.00.01: Formatting Changes.
Version 0.00.00: Initial version. Corresponding to MesaDX version 0.00
Super Majik Spiral Crew, Jon, and Richard Talbot-Watkins: Their documents
describing the technical details of the Sega Master System and Sega Game Gear
are the foundations of the public's current understanding of these systems.
Andrew Lindsay: Designer of the MK1. His help with the SMS memory system
and ROM storage was invaluable. With this information I was able to design and
build the SMSARCH, a SMS cartridge backup unit.
James McKay: Provided me with my first glimpse of the SMS memory
architecture. Also, for providing miscellaneous information in a (publically
released) e-mail converstation with "Neon Spiral Injector."
Bock (or Zoop or Omar Cornut): Bock has been a strong presence in the
SMS/GG emulation community. His contributions have on many occasions inspired
my own efforts. Additionally, his founding and continuous support of S8-Dev has
been a great service to all of us still interested in software development for
Sega 8-bit systems.
Maxim: Maxim has made numerous contributions to the world of Sega 8-bit
emulation including utilities, demo programs, and technical documents. Maxim
is an active member of the S8-Dev forum and can always be depended on to step
up and answer the difficult technical questions. Maxim also wrote an
outstanding document covering the TI SN76489 sound chip.
Charles MacDonald: Charles' unending work documenting the minutae of the
various Video Display Processors used in various SM3A implementations has been
invaluable during the development of MesaDX. Charles has also written many
test programs and has on several occasions been kind enough to test demo
programs on a real SMS.
Martin Konrad: Martin Konrad is the brains behind the SDSC Debug Console.
He is also the author of an outstanding SMS debugging emulator, eSMS. eSMS is
the first emulator to include an SDSC Debug Console. Hopefully, MesaDX will
be the second.
Heliophobe: Heliophobe has made many technical contributions to Sega
8-bit emulation including demos and a SMS emulator for the Dreamcast: SMEG.
Heliophobe has also provided feedback and suggestions for improving MesaDX,
many of which have been implemented in MesaDX.
S8-Dev: All the members of S8-Dev deserve to be thanked, not only for
their continuous interest in Sega 8-bit development, but also for perhaps being
the only people in the world who might be interested in using an emulator
like MesaDX
Quinntesson (Jeff Quinn, my brother, author of the Genesis/SegaCD/32X
emulator AGES): His understanding and interest in the more technical aspects of emulation
have greatly increased my own understanding of emulation. Our long
conversations about all things emulation-related have proved to be invaluable
during the (long) development of MesaDX.
Depending on your version of Windows you may also require two other DLL files:
mfc70.dll and msvcr70.dll. Both of these are available in a separate
downloadable ZIP archive on the MesaDX webpage.
If MesaDX Version 0.04 reports that it is missing any other DLLs, please
contact the MesaDX author.
Also, compiled within the MesaDX executable are several icons that can be used for files of types: *.mdx, *.sms, and *.gg.
The New System Configuration window is broken into two tabbed dialog
box sections: the Devices section and the Power-On Configuration
section.
The Devices page allows the user to specify which devices they'd like
to have installed in the system. A list of all the devices in an AGAMA
(Sega Mark 3, Sega Master System, or Game Gear) system is shown under
"Installed Devices". For each of these devices the Device ID, Model number and
Version number is shown, or the device is marked "Not Installed". By clicking
the device mnemonic in this list, the user is then allowed to select which
device emulator they would like to have installed in that device slot. The
list of available device emulators for a particular device slot is shown in
the "Select Device to Install" list. This list shows all the devices that are
suitable for a particular device slot. For example, selecting "PROC" in the
"Installed Devices" list will allow the user to select which processor emulator
they'd like to use in the current system configuration. In this release of
MesaDX (and the Kokin DLL), only one processor device emulator is provided,
(the A080 model).
The information about the provided processor emulators is shown in the "Select
Device to Install" list, and since only one emulator is provided and
the PROC is a require device, this device emulator will be selected
automatically. For other device slots, more than one device emulator may be
available. Clicking a device in the "Select Device to Install" list will
select that device for installation in the device slot specified.
Descriptions for each of the device emulators are also provided when the
device is clicked. This description should provide the user with enough
information to decide which device emulator they want to use in a particular
system configuration. If a device is not required
for a particular device slot, then the option "Not Installed" will also appear
in the "Select Device to Install" list. Selecting "Not Installed" will leave
that device slot empty.
If a device requires a memory image file, then the "Data File" and "Back-up
RAM File" entry boxes will be enabled. All devices for which the "Data File"
box is enabled will require that a data file be specified. Not specifying a
file will result in an error. The "Back-up RAM File" is optional.
The other tab, the Power-On Configuration tab, allows the user to specify
flags that control how the emulator devices power-on. You will notice that
some of the power-on configuration flags are disabled and that the Suspended
flag
is permanently checked. The current version of MesaDX does not support AGAMA
Monitor Mode or GG Mode, so these flags are disabled. Also, MesaDX currently
requires that the emulator start in the suspended state so that various debug
features can be initialized, which is why the Suspended flag is checked.
It is possible that future versions of MesaDX will allow the user to select
whether or not the emulator powers-on in the suspended state. Currently,
though, the user is permitted to adjust the settings of the other power-on
configuration options: the machine region, clock frequency, the bus type, and
the boot device.
The Export Region flag is used to indicate the system's region
setting. When the flag is unchecked, the system is a native Japanese NTSC
system. When the flag is checked, the system is an export (U.S. NTSC) system.
(European PAL systems are not yet supported in MesaDX.) The Export Region flag is checked by default in MesaDX Version 0.04,
(representing the personal biases of the emulator author).
The 50 Hz flag is used to select whether the system VDP should use a
60 Hz or 50 Hz clock. 60 Hz clocks are used by NTSC systems. 50 HZ are used
by PAL systems.
The SMS1 Bus flag is used to indicate the behavior of the system's
processor bus. When the flag is checked, the system uses a SMS1-type bus.
A SMS1 bus retains the last data value driven on the bus. In the case of a
bus transaction where no devices respond, the data returned is the last data
value that appeared on the bus. Usually, this data value is the last byte of
the most-recently fetched instruction. If the flag is unchecked, the system
uses a SMS2/GG-type bus. This bus will always return a $FF if no data is driven
on the bus by a responding device.
The final option, the Boot Device menu, allows the user to specify which
memory device is enabled (mapped into the Z80 address space) at power-on. The
default is the Boot ROM, which represents the system's internal ROM or "BIOS". (BIOS is technically the wrong term since BIOS is an acronym for Basic
Input/Output Service which doesn't really exist in the Sega Mark III
Architecture. For this reason, all MesaDX documentation will refer to the
built-in system ROM as Boot ROM, or BROM.)
Along with the Boot Device option comes a Lock Boot Device flag.
This flag will prevent the boot device from being mapped out of addressable
memory via writes to port $3E, permanently locking the Boot Device into
addressable memory.
Once the memory devices have been configured, the Power On button
should be click to being the emulation session. If a Power On problem
occurs it is likely a result of a badly configured system. In
general, the steps required to successfully create a system configuration are:
Once the system is powered-on, the system configuration can be saved. Select
the Save or Save As... options from the File menu in the
main MesaDX application window to save the system configuration.
To quickly load a ROM image as a cartridge, simply select Load ROM
Image... from the File menu in the main MesaDX application window
(or use the Ctrl-I hot-key combination). The New System Configuration
dialog box will open, with the system pre-configured and ready for power-on.
The user can select one of 6 different types of pre-configured system
configurations in the "System Type" drop-down box. These include:
The default configuration is the first one, SMS1 Export NTSC (American).
Selecting OK will power-on the system. However, if the user desires to
view or modify the default configuration settings before power-on, then
check the Show System Configuration box before clicking OK.
Doing so will open the standard System Configuration
dialog box when the user does click OK. All the devices will already be
configured as appropriate based on the system configuration they chose.
The user can now modify the system configuration as desired. Clicking
OK here will then power on the system.
MesaDX correctly emulates the mechanism by which memory devices are
mapped into and out of the processor's address space. Consequently,
some commercial game software will not work correctly without an
official Sega Boot ROM ("BIOS") image.
Most SMS Boot ROM code initializes the first byte of RAM (address
$C000) with a bit mask indicating which memory devices are enabled,
and some commercial game software depends on this value. MesaDX
Version 0.04 does not pre-initialize $C000 and it's possible that the
default value, if read by software, will confuse it into incorrectly
disabling or enabling a memory device. To prevent this MesaDX provides
the Lock Boot Device power-on configuration option. It is
recommended that this option be used unless specifically testing
Boot ROM ("BIOS") software that is intended to correctly detect and
enable memory devices.
The System Configuration view contains the Power-On Configuration
settings as well as a list of all the installed emulator devices. Along with
the device mnemonic, each installed device has its Device ID, Model and
Version numbers listed. These identifiers are not that important in this
version of MesaDX, but they will be critical once AGAMA Monitor Mode
is supported. Devices not currently installed in the emulation system are
labelled as Not Installed.
For more information about each device, select a device mnemonic in the device
list (even for devices not installed) and click the Details... button.
A window showing the device mnemonic, ID, model and version numbers will open.
The window will also contain a short description of the device. For memory
devices, the data files installed as the memory contents will also be shown.
The POST result code is available in the 4 most-significant bits of the devices
Power-On Configuration Register (POCR). If the result code is non-zero, then
the POST failed. The result codes are device-dependent and can be found in
Appendix B: Power-On Self Test
(POST) Code Summary in the Kokin User's Manual
If all the devices pass POST the emulator has successfully powered-on and is
ready to be used.
The Resume and Suspend commands are mutually exclusive; only
one is enabled at a time, depending on the current state of the emulator.
Suspend is used to pause emulation. Each device is suspended and will
no longer perform an active processing (only the PROC, VDP, and PSG perform
active processing). Devices will still respond to bus transactions, though,
so their state can be queried and modified by the user (through the various
data views described in Chapter 4), if desired.
If the emulator is suspended, emulation can be resumed using the Resume
command. The state of emulation (resumed or suspended) is shown in a small
status pane in the lower right-hand corner of the main MesaDX application
window.
The Power-On (Hard-Reset) command restarts the emulator in a way
similar to turning the power off and then back on. Hard Reset differs from
pushing the Reset button on the console. The Reset button is just a
"soft-reset" and is implemented in the game software. Power-On
(Hard-Reset) is the only way to get the emulator out of the Shutdown
state. (Shutdown is discussed in more detail in section 3.3:
Shutdown.)
Finally, the Step command is used to single-step through instructions.
Please note that in order to use these keys for controller 1, the Primary Video
Output view must be the active window. (The Primary Video Output view opens
automatically when a system configuration is loaded.) If another view is
active, any keystrokes will be directed to that view (notably the arrow keys
which are used to scroll certain views).
Future versions of MesaDX will support peripheral port 2 and other
controller types.
When the emulator enters Shutdown, a message box indicating the cause will
be displayed. The message box will indicate the responsible device and
give the shutdown code. Table 3.3.a below lists the shutdown codes defined in
the current release of MesaDX along with a brief description of each code.
Most of the codes above apply to monitor mode, which is disabled in the
current version of MesaDX, so Shutdown should occur very infrequently. In
fact, the only time Shutdown should occur with the current version of MesaDX
is if the SHUTDOWN event handling flag for a specific device event is set, or
in other words, the user requested that the system shutdown (instead of
suspending) in response to a certain event. Please note that all compulsory
events have their SHUTDOWN flags set automatically, so if a compuslory event
triggers and no other event handling mechanism is specified the system will
shutdown.
The Instruction View determines instruction boundaries by unassembling
data from the beginning of memory (address $0000) through to the end.
Due to paging and data sections in memory, the instruction
boundaries shown may not always be the true boundaries. As result,
execution may sometimes appear to jump into the middle of an
instruction as shown in the Instruction Unassembly view. If the
processor's PC isn't equal to a current instruction boundary, use the
"Expand Listing" option in the Instruction Unassembly view's toolbar to
show instruction unassembly at each byte in memory. The current
instruction will be highlighted in a gray box. (See below for more
information on the "Expand Listing"option.)
Each unassembled instruction is one row in the view. The information for
each instruction is arranged in columns. The left-most column contains the
instruction's address in hexadecimal. The next column is the instruction
object code, also in hexadecimal. Finally, the last column is the
instruction mnemonic and operands. All immediate operands are displayed
in hexadecimal.
The instruction pointed to by the current PC is highlighted in a gray box.
This instruction is the next instruction to be executed. For some
types of instructions a fourth column showing additional information will be
displayed. For memory reference instructions, the current data in memory at
the reference address will be shown. For jump or branch instructions the
current and target PC will be shown. The forth column is only displayed for
the current instruction.
The Instruction Unassembly view also includes a toolbar to ease navigation
through the unassembly listing.
Type a memory address in the "Scroll to" box (and press 'Enter') to have the
view scroll directly to nearest instruction on or before that address.
Pressing 'Escape' will cancel the "Scroll to" operation.
Check the "Track PC" box to always keep the current instruction in view. (If
the current instruction is not on a recognized instruction boundary, the view
will jump to an address near the current instruction. Use the "Expand
Listing" option to make all the instructions visible.)
Check the "Expand Listing" box to show the unassembly for every byte in memory.
Instructions in black are those instructions that line on instruction boundaries
based on unassembly starting from address $0000 in memory. Instructions
printed in gray are instructions that do not lie on instruction boundaries
based on unassembly starting from address $0000 in memory. (See the
Technical Note above for more information about instruction boundaries.)
The Processor (PROC) Registers view can also be used to edit the values
in registers or flags.
Registers can be edited by typing a new value into the register edit box and
pressing 'Enter'. To cancel an edit, press 'Escape' instead. The Tab
key can be used to cycle through the registers for editing.
The flags can be edited two ways. The first is to simply edit the value in
the "AF" register as described above. This method requires that you know which
bits correspond to which flags. The other way is to set the flag bits
directly by clicking on the radio button for the desired settings in the right hand side of the register view. Note that the Parity and Overflow flag are
really the same flag bit; setting (or reseting) one will like-wise set (or
reset) the other.
Whenever a register or flag is changed during execution, the change is
highlighted in red text. These highlights can be used to quickly
determine when a register value changes. If a register's value didn't change
during execution, the value will be displayed in the standard black text. Note
that when executing a group of instructions using the Resume command,
any changes to register values are highlighted, not just the changes
made during the execution of the last instruction in the group.
The Video Display Processor (VDP) Registers view can also be used to edit the
values in the VDP or Palette registers.
Registers can be edited by typing a new value into the register
edit box and pressing 'Enter'. To cancel an edit, press 'Escape' instead.
The Tab key can be used to cycle through the registers for editing.
Like the Processor (PROC) Register view, changes in a register's value
during execution are highlighted in red text. If a register's value didn't change during execution, the value will be displayed in the standard black text.
Note that when executing a group of instructions using Resume command,
any changes to register values are highlighted, not just the changes
made during the execution of the last instruction in the group.
The Programmable Sound Generator (PSG) Registers view can also be used to edit
the values in registers or noise channel settings.
Registers can be edited by typing a new value into the register edit box and
pressing 'Enter'. To cancel an edit, press 'Escape' instead. The Tab
key can be used to cycle through the registers for editing.
The noise channel configuration can be adjusted in two ways. The first is to
simply edit the value the noise channel control register as described above.
This method requires that you know which bits correspond to which settings.
The other way is to set the control bits directly by clicking on the radio
buttons for the desired settings in the right hand side of the register view.
Whenever a register or flag is changed during execution, the change is
highlighted in red text. These highlights can be used to quickly
determine when a register value changes. If a register's value didn't change
during execution, the value will be displayed in the standard black text. Note
that when executing a group of instructions using the Resume command,
any changes to register values are highlighted, not just the changes
made during the execution of the last instruction in the group.
The AXRs in each of the views described below can be edited by typing a new
value into the register edit box and pressing 'Enter'. To cancel an edit, press
'Escape' instead. The Tab key can be used to cycle through the registers
for editing.
Whenever a register is changed during execution, the change is highlighted in
red text. These highlights can be used to quickly determine when a register
value changes. If a register's value didn't change during execution, the value
will be displayed in the standard black text. Note that when executing a group
of instructions using the Resume command, any changes to register
values are highlighted, not just the changes made during the execution of the
last instruction in the group.
Please see Chapter 2: KokinMIOH
in the Kokin User's Manual for more information about the Memory and I/O
Hub included in the Kokin emulation library.
Please see Chapter 3: KokinMIOH
in the Kokin User's Manual for more information about the Memory and I/O
Hub included in the Kokin emulation library.
Please see Chapter 6: KokinA235
in the Kokin User's Manual for more information about the memory device
and mapper used to implement the BROM that is included in the Kokin emulation
library.
Please see Chapter 4: KokinSRAM
in the Kokin User's Manual for more information about the System RAM device
included in the Kokin emulation library.
Please see Chapter 5: KokinCARD
in the Kokin User's Manual for more information about the Sega Card device
included in the Kokin emulation library.
Please see Chapter 6: KokinA235
in the Kokin User's Manual for more information about the memory device
and mapper used to implement the EXT0 that is included in the Kokin emulation
library.
Please see Chapter 7: KokinVDP
in the Kokin User's Manual for more information about the VDP device
included in the Kokin emulation library.
Please see Chapter 8: KokinPSG
in the Kokin User's Manual for more information about the PSG device
included in the Kokin emulation library.
To edit the memory contents, simply double-click on the byte or word that
should be changed. An edit box will open allowing the user to enter a new
value. Press the "Enter" key to commit the result. "ESC" will cancel the
edit.
The Processor (PROC) Memory view also includes a toolbar that allows some
customization of the display.
Type a memory address in the "scroll to" box (and press 'Enter') to have the
view scroll directly to a memory address. Pressing 'Escape' will cancel the
"Scroll to" operation.
Chose between "Byte Width" or "Word Width" to select how the data should be
displayed.
Check the "Display ASCII" box to show the ASCII characters for each byte of
memory. Unprintable characters are shown as a period (.).
To edit the memory contents, simply double-click on the byte that
should be changed. An edit box will open allowing the user to enter a new
value. Press the "Enter" key to commit the result. "ESC" will cancel the
edit.
The Processor (PROC) Memory view also includes a toolbar that allows some
customization of the display.
Type a memory address in the "Scroll to" box (and press 'Enter') to have the
view scroll directly to a memory address. Pressing 'Escape' will cancel the
"Scroll to" operation.
Also, the Primary Video Output view is the target for peripheral (controller)
input. See Table 3.2.a: Mapping of Keys to Emulator
Peripheral (Controller) Functions for the mapping of keys to the emulator
input functions. Please note that the Primary Video Output view must be the
active window in order for user input to be considered controller intput
directed toward the emulator.
The Primary Video Output view also includes a toolbar that allows some
customization of the display.
Check the "Double Size (Magnify 2x)" box to double the size of the view.
The Tiles/Palette view also includes a toolbar that allows some
customization of the display.
Check the "Double Size (Magnify 2x)" box to double the size of the view.
If the VDP is in Mode4, checking the "Use Sprite Palette" box will instruct
the VDP to render the tiles using the sprite palette (last 16 palette entries)
instead of using the normal first 16 palette entries.
If the VDP is in Graphics2, then checking the "Use Sprite Palette" box will
instruct the VDP to render the sprite patterns and the fixed Graphics2 palette.
Unchecking the option will instruct the VDP to simply render the pattern table.
Note that the affect of checking (or unchecking) the
"Use Sprite Palette" box will only be seen while the emulator is running
(resumed) since the VDP renders this screen only while it is running. If the
emulator is suspended when the box is checked or unchecked, the update won't
occur until the next time the emulator resumes execution.
To add a breakpoint, click the Add button in the Breakpoint view's
toolbar. An Add Breakpoint dialog box will open. The current version
of MesaDX supports the following breakpoint types:
In the Add Breakpoint dialog box, select the type of breakpoint desired,
and then define the breakpoint location. If the location is a memory or port
address, type the address in the Memory/Port Address edit box and type
'Enter' to commit the address ('Escape will discard the address). Otherwise,
use the drop down boxes for the appropriate breakpoint type to select the
breakpoint location. For the PSG, see Table 4.10.a for a list of the mnemonics
used to refer to the different PSG registers. The register mnemonics for the
other devices are self explanatory.
Once the breakpoint type and location have been selected, click "OK" to add the
breakpoint. The new breakpoint will appear in the Breakpoints view. The type
and location of the breakpoint will be shown and the breakpoint will be
enabled.
Once a breakpoint is added it can be removed or disabled.
Removing a breakpoint deletes it from the list. Once a breakpoint is removed it
has to be added again using the Add button and the breakpoint type and
location information will have to be re-entered. To remove a breakpoint,
select the breakpoint from the list by clicking in the Type column in the row corresponding to the desired breakpoint. The breakpoint should be
highlighted. Now, click the Remove button in the Breakpoints view
toolbar. The breakpoint will be removed from the list and will no longer
trigger.
However, if a breakpoint only needs to be temporarily removed, it is better to simply disable it. To disable a breakpoint, select the breakpoint from the list
by clicking in the Type column in the row corresponding to the desired
breakpoint. Now, the Enabled check box can be clicked to disable the
breakpoint. The breakpoint information will remain in the breakpoints list,
but the breakpoint will no longer trigger. To re-enable the breakpoint simply
select the desired breakpoint and again and check the Enabled box in
the toolbar. Enabling and disabling a breakpoint is a convenient way control
breakpoint behavior without the need to keep re-entering breakpoint information.
To remove all breakpoints at once, click the Remove All button in the
Breakpoints view toolbar.
The Breakpoints view requires the SUSPEND event handling flag for
certain device events to be set.
The primary mechanism for supporting breakpoints in AGAMA devices
is to specify that certain events should suspend emulation.
Immediately after Power-On (Hard-Reset) MesaDX automatically
sets the SUSPEND event flag for various device events so that
the standard breakpoints will work. The following is a list of
the device events whose SUSPEND flags are set automatically by
MesaDX:
The current versions of MesaDX and the Kokin emulator library support two
different mechanisms for handling events: SUSPEND and SHUTDOWN.
If SUSPEND is specified for an event and the event triggers, the
emulator will suspend execution, allowing the user to investigate the
exact circumstance and instruction where the event triggered.
If SHUTDOWN is specified for an event and the event triggers, the
emulator will enter Shutdown mode. Once the emulator is in shutdown the
only way to get out is to perform a Power-On (Hard-Reset). The user can
still investigate the reasons the system entered shutdown, via the various
device AXR views, but generally SUSPEND is preferred since emulation
can be resumed from right where it left off. Note, though, that if no
event handling mechanism is specified at all for an event and the event
triggers, the system will automatically enter Shutdown.
Programming an event cause the system to either suspend or shutdown is
accomplished via the device's Event Handling Code Register (EHCR) and EVent
Handling Flags Register (EHFR). First, write the 8-bit event code for the
desired event into the EHCR (use the device's AXR view for this). Once the
write is committed the EHFR will be updated to reflect that event's current
handling flags. Now, set either the SUSPEND flag (bit 8) or the
SHUTDOWN flag (bit 10), or both. Note, though, that the SHUTDOWN
bit is ignored unless no other handling flag is set, so setting both flags
is unnecessary. Now, the next time the event triggers the system will either
suspend or shutdown. In the case of suspend, though, the way the system
resumes depends on the type of event. Event types are discussed next.
There are three kinds of events currently defined in the AGAMA specification:
compulsory events, protection events, and breakpoint events. Each of these
events behaves slightly differently and affects the way the system resumes.
Compulsory events always trigger. They cannot be silenced (via the
COMPATIBLESILENT or MONITORSILENT flags in the EHFR). Generally
a compulsory events indicate errors that the system cannot resolve on its own.
The user will usually have to manually re-configure some portion of the
system to prevent a compulsory event from triggering. An example of a
compulsory event is the processor's INVALID_INSTR event that gets triggered
whenever the processor encounters an unknown (or unsupported) opcode.
Compulsory events have their SHUTDOWN flags set by default, so if
no other handling mechanism is specified, the system will simply enter shutdown
when a compulsory event triggers.
Protection events are the second kind of event. Protection events are
generally used to prohibit certain actions, like data writes. When a
protection event triggers it indicates that an illegal action was attempted.
The event triggers to allow the user to respond to or investigate the action
before any machine state is altered or corrupted. One example of a protection
event is in the SRAM device which allows various types of protection to be
applied to RAM. Unlike compulsory events, protection events can be silenced.
However, the action that triggers the event is still prohibited. For example,
if memory writes to RAM are protected, and the event is silenced, a write
transaction will still occur, but the SRAM device will simply throw out the
write data leaving memory unchanged. Protection events also have their
SHUTDOWN flags set by default, so if no other handling mechanism is
specified, the system will simply enter shutdown when a protection event
triggers.
The third and final type of event is a breakpoint event. Breakpoint events are
similar to protection events except that a silenced breakpoint event allows
the action to proceed. Furthermore, the silence flags for breakpoint events
are automatically set when the event triggers. This allows the user
to investigate the cause of the breakpoint but then easily resume execution
without having to worry about the breakpoint triggering again. Unlike
compulsory and protection events, breakpoint events do not have their
SHUTDOWN flags set. If no handling mechanism for a breakpoint event
is specified the event is simply ignored.
Please see the AGAMA Specification
for more information on events and event handling, and please see the
Kokin User's Manual for information
about specific device events.
The first place to look is the Hub's Last Message Information Register (LMIR)
and Last Message Data Register (LMDR). The Hub's LMIR contains the Device ID
and message code of the last message broadcast by the Hub. The Device ID is
in the high 8-bits of the LMIR. The message code is in the low 8-bits of
the LMIR. If the system just suspended the message code will almost
certainly be $03, which is the code for the SUSPEND system message.
(See the Kokin User's Manual for a
complete list of all the system message codes.)
Once the Device ID is found from the Hub's LMIR, the Device Event Code Register
(DECR), Device Event Address Register (DEAR), Device Event Data Register (DEDR),
and the Device Event Flags Register (DEFR) for that device can be examined to
determine why the device requested that the system suspend. See the
Kokin User's Manual for information about
each device's events and event codes.
This document is the official MesaDX for Windows 98 user's manual.
Introduction
I.1 About this Document
[To Be Completed]
I.2 Document Conventions
This document uses a specific notation for hexadecimal and binary numbers,
symbolic representation of instructions, and data-structure formats.
Familiarity with this notation is essential for effective use of MesaDX.
I.2.1 Hexadecimal and Binary Numbers
Hexadecimal (Base 16) numbers are represented using the
WLA-DX format of the "$" symbol followed by a
string of hexadecimal digits (1-9 and A-F). The hexadecimal digits 'A' through
'F' will always be upper-case. An example of a valid hexadecimal number
representation is: $C0FF.
I.2.2 Bit and Byte Order
Bits are numbered starting from right to left, (i.e., least-significant to
most-significant.) All bytes consist of eight bits: 0 through 7.I.2.3 Reserved Bits
In certain register layout descriptions, various bits will be marked as
Reserved. These bits are reserved for future expansion of the
AGAMA specification, and all reserved bits are implicitly RESET (0). Software
should never attempt to SET these bits (to 1). Generally, if the modification
of a read-only or reserved bit is attempted an error will occur and the
entire write to the register will be discarded. Access to registers with
reserved bits should follow the guidelines below:
I.2.4 Instruction Operands
The main processor used in the
Sega Mark III Architecture (SM3A) is the Zilog Z80
microprocessor. Therefore, the symbolic representation of instructions is
taken directly from Z80 assembly language. The format is shown below:
When two operands are present, the right operand is the source and the left
is the destination.LOOP1: LD HL, STARTVALUE
AND B implies the accumulator is both a source
and a destination. In contrast, the assembly language used in this
specification always specifies the accumulator. The same instruction
is written as: AND A, B in this specification. The object codes
for these instructions are identical, just the instruction notation differs.
I.3 Revision History
Version 0.04.00 (September 23, 2006): Updated for release of MesaDX version
0.04. MesaDX 0.04 includes an entirely new mechanism for specifying the
system configuration which allows user to specify which devices are installed.
This version also addes support for 32-bit color Windows display modes, memory
editing, Graphics2 mode, the SMS2 VDP, and CodeMasters mapper.
I.4 Acknowledgements
MesaDX could not have existed without the help of numerous people.
Chapter 1: Getting Started with MesaDX
1.1 Installing MesaDX
Simply copy the MesaDX program file (MesaDX.exe), and the Kokin.dll to the desired destination folder.
1.2 Associating Files with MesaDX
MesaDX registers itself with the Windows registry allowing files with specific
extensions to be associated with MesaDX. Currently, these associations are not
made automatically; it is up to the user to inform Windows which file
extensions to associate with MesaDX. Future revisions of this manual will
include specific instructions on how to associate *.mdx files with MesaDX for
interested users. Those Windows users who already know how to make such associations manually may do so at any time. Once an association is made, simply double-click the desired MesaDX System Configuration (*.mdx) file
to launch an instance of MesaDX using that system configuration.
MesaDX Version 0.04 supports a sophisticated mechanism for configuring
the emulator. MesaDX allows the user to specify Power-On Configuration
information and control precisely which devices are installed in the system.
Users also pick which memory image files to associate with certain devices.
All of this information can then be saved in MesaDX System
Configuration (*.mdx) files. These system configuration files are a first step
in making MesaDX more project-based. As such, system configuration files
created with MesaDX 0.04 will most-likely not be compatible with future versions
of MesaDX. Furthermore, the new capability of specifying which devices to
install prohibits the use of system configuration files created with MesaDX 0.03
or 0.03a with MesaDX 0.04.
Chapter 2: System Configurations and Power-On
2.1 Creating a New System Configuration
To create a new system configuration, simply select New Configuration...
from the File menu in the main MesaDX application window (or use the
Ctrl-N hot-key combination). The New System Configuration dialog box
will appear.
2.2 (Quick Start) Loading ROM Images
The procedure described above for creating a new system configuration allows
the user a great deal of flexibility, but sometimes that much flexibility is
unnecessary. MesaDX Version 0.04 provides a quicker way of creating a
system configuration when the user simply wants to load a ROM image file
as a standard game cartridge.
Table 2.2.a: Summary of Available Pre-defined System Configurations
Configuration Export Region Flag
50Hz Flag VDP Type
SMS1 Export NTSC (American) SET CLEAR KokinVDP_A124 (315-5124, SMS1-compatible)
SMS1 Export PAL (European) SET SET KokinVDP_A124 (315-5124, SMS1-compatible)
SMS1 Japan NTSC (Japanese) CLEAR CLEAR KokinVDP_A124 (315-5124, SMS1-compatible)
SMS2 Export NTSC (American) SET CLEAR KokinVDP_A246 (315-5246, SMS2-compatible)
SMS2 Export PAL (European) SET SET KokinVDP_A246 (315-5246, SMS2-compatible)
SMS2 Japan NTSC (Japanese) CLEAR CLEAR KokinVDP_A246 (315-5246, SMS2-compatible)
Technical Note
2.3 Viewing the Current System Configuration
Once a system configuration has been created, and the system has been
powered-on, the configuration can be viewed by selecting System
Configuration from the Configuration menu in the main MesaDX
application window.
2.4 Power-On Self Test (POST)
When the emulation system first powers-on, each device executes a
Power-On Self Test to verify that everything is
in working order. The tests vary from device to device, but for the most
part the tests consist of verifying compile-time assumptions, checking
that required devices are installed correctly, and ensuring that ROM image files
are not too large for their respective devices. (For example, Sega Card devices
only support ROM images of 32KB.) If one or more device's POST fails, a
Power-On Self Test (POST) Summary window will open showing the POST
results for each installed device.
Chapter 3: Running the Emulator
3.1 Resuming and Suspending Emulation
Table 3.1.a lists the commands, along with their hot-key combinations, that
are implemented in the current version of MesaDX for controlling emulation.
All of these commands are also available under the Debug menu in the
main menu bar.
Table 3.1.a: Emulation Control Commands and Hot-Key Cominbations
Command Hot-Key
Resume F5
Suspend Shift+F5
Power-On (Hard-Reset) Ctrl+F12
Step F11
3.2 Control Pad 1
In MesaDX Version 0.04 the only peripheral device that is emulated is
Control Pad 1. The control pad is standard SMS-type control pad consisting
of a 4-way directional pad along with two buttons. Table 3.2.a shows which
keyboard keys map to the control pad buttons. The table also shows which
keys map to the consoles Pause and Reset buttons.
Table 3.2.a: Mapping of keys to emulator peripheral (controller)
functions
Keyboard Key Function
Up Arrow UP
Down Arrow DOWN
Left Arrow LEFT
Right Arrow RIGHT
Z BUTTON 2
X BUTTON 1
Spacebar PAUSE
Home RESET
3.3 Shutdown
When the emulator encounters a fatal error, or a compulsory event triggers and
no handling mechanism is defined, the system will enter Shutdown. The only
way to get out of the shutdown state is to perform a Power-On
(Hard-Reset).
Table 3.3.a: Shutdown Codes and Descriptions
Shutdown Code Mnemonic Description
1 REENTERMONITOR The emulator attempted to re-enter
monitor mode while it was in monitor mode.
2 READAXR The HUB attempted to read a device's AXR
to determine how a triggered event was to be handled, and the read
failed. (When a device event triggers the HUB must query the device to
determine how the event is to be handled. See the
AGAMA Specification for
more information about events and event handling.)
3 BROADCASTERROR The HUB attempted to broadcast a
system message to all the device and the broadcast failed for some
reason.
4 DEVICEEVENT A device event triggered and the
event handling mechanism specified in the device's DEFR requested
that the system go into Shutdown.
5 NODEFRFLAGS A device event triggered but no
event handling mechanism was specified in the device's DEFR.
6 UNKNOWNDEFRFLAG A device event triggered but a
reserved or undefined flag in the device's DEFR was set.
MesaDX provides a number of views that display important information about the
emulator state. Each view is in its own window and can be re-sized or moved
individually. Also, some views have scrolling capabilities. Scrolling is
normally done by clicking the scroll-bar on the right edge of each view window,
but the keyboard can also be used. Arrow keys scroll the view by one line.
The Page Up or Page Dn keys scroll the view by one page.
Chapter 4: Using the Views
4.1 Instruction Unassembly View
The Instruction Unassembly view can be opened by selecting Instruction
Unassembly in the View menu in the main menu bar. This view displays
unassembled instructions, starting from address 0x0000 and unassembling through
to the end of memory (64KBytes). The unassembly view interprets all memory as
code, and makes no effort to determine the location of data sections in the ROM
image.
Technical Note
4.2 Processor (PROC) Registers View
The Processor (PROC) Registers view can be opened by selecting Processor
(PROC) Registers from the View menu in the main menu bar. This view
displays the current contents of the processor registers. It also shows the
state of each flag in the flags register (the "F" register.) All register data
is displayed in hexadecimal.
4.3 Video Display Processor (VDP) Registers View
The Video Display Processor (VDP) Registers view can be opened by selecting
Video Display Processor (VDP) Registers from the View menu in the
main menu bar. This view displays the current contents of the VDP registers
and palette registers. All register data is displayed in hexadecimal.
4.4 Programmable Sound Generator (PSG) Registers View
The Programmable Sound Generator's (PSG) Registers view can be opened by
selecting Programmable Sound Generator (PSG) Registers from the
View menu in the main menu bar. This view displays the current contents
of the PSG registers. It also interprets the contents of the noise channel
registers allowing the user to quickly interpret how the noise channel is
configured. All register data is displayed in hexadecimal.
4.5 AGAMA Extension Registers (AXR) Views
Each device in the Kokin emulator library is an AGAMA device and consequently
contains a set of 256 AGAMA Extension Registers (AXR). These registers contain
device status and configuration information and providing access to the
device's AGAMA feature extensions.
4.5.1 External Debugger (EXTD) AXRs View
No AXRs view for the External Debugger is available in the current version
of MesaDX.
4.5.2 Processor (PROC) AXRs View
The Processor (PROC) AXRs view can be opened by selecting AGAMA Extensions Registers from the View menu in the main menu bar,
and then selecting Processor (PROC) AXRs. All register data is
displayed in hexadecimal.
4.5.3 Memory and I/O Hub (HUB) AXRs view
The Memory and I/O Hub (HUB) AXRs view can be opened by selecting AGAMA Extensions Registers from the View menu in the main menu bar,
and then selecting Memory and I/O Hub (HUB) AXRs. All register data is
displayed in hexadecimal.
4.5.4 Boot ROM (BROM) AXRs View
The Boot ROM (BROM) AXRs view can be opened by selecting AGAMA Extensions Registers from the View menu in the main menu bar,
and then selecting Boot ROM (BROM) AXRs. All register data is
displayed in hexadecimal.
4.5.5 System RAM (SRAM) AXRs View
The System RAM (SRAM) AXRs view can be opened by selecting AGAMA Extensions Registers from the View menu in the main menu bar,
and then selecting System RAM (SRAM) AXRs. All register data is
displayed in hexadecimal.
4.5.6 Sega Card (CARD) AXRs View
The Sega Card (CARD) AXRs view can be opened by selecting AGAMA Extensions Registers from the View menu in the main menu bar,
and then selecting Sega (CARD) AXRs. All register data is
displayed in hexadecimal.
4.5.7 External Device 0 (EXT0) AXRs View
The External Device 0 (EXT0) AXRs view can be opened by selecting AGAMA Extensions Registers from the View menu in the main menu bar,
and then selecting External Device 0 (EXT0). All register data is
displayed in hexadecimal.
4.5.8 External Device 1 (EXT1) AXRs View
This device is not implemented in this version of MesaDX, and no AXRs view is
available.4.5.9 Video Display Processor (VDP) AXRs View
The Video Display Processor (VDP) AXRs view can be opened by selecting AGAMA
Extensions Registers from the View menu in the main menu bar,
and then selecting Video Display Processor (VDP) AXRs. All register
data is displayed in hexadecimal.
4.5.10 Programmable Sound Generator (PSG) AXRs View
The Programmable Sound Generator (PSG) AXRs view can be opened by selecting
AGAMA Extensions Registers from the View menu in the main menu
bar, and then selecting Programmable Sound Generator (PSG) AXRs. All
register data is displayed in hexadecimal.
4.5.11 FM Unit (FMU) AXRs View
This device is not implemented in this version of MesaDX, and no AXRs view is
available.
4.6 Processor (PROC) Memory View
The Processor (PROC) Memory view can be opened by selecting Processor
(PROC) Memory from the View menu in the main menu bar. This view
displays the current memory as viewed from the processor's perspective. The
view shows the memory map as the processor would see it, with all paging, RAM
mirroring, and device enabling in place. All memory data is displayed in
hexadecimal.
4.7 Video Display Processor (VDP) Memory View
The Video Display Processor (VDP) Memory view can be opened by selecting
Video Display Processor (VDP) Memory from the View menu in the
main menu bar. This view displays the current contents of VRAM. All memory
data is displayed in hexadecimal.
4.8 Primary Video Output View
The Primary Video Output view can be opened by selecting Primary Video
Output from the View menu in the main menu bar. The Primary Video
Output view is opened automatically when a system configuration is opened and
powered-on. This view displays the primary video output from the VDP which,
in the current KokinVDP implemention, is the game screen. Note that the VDP
only updates this view while the emulator is running (resumed).
4.9 Tiles/Palette View
The Tiles/Palette view can be opened by selecting Tiles/Palette from the
View menu in the main menu bar. This view displays the secondary video
output from the VDP which, in the current KokinVDP implemention, is a rendering
of the current tiles in VRAM along with swatches of the current palette. Note
that the VDP only updates this view while the emulator is running (resumed).
4.10 Breakpoints View
The Breakpoints view can be opened by selecting Breakpoints from the Debug menu in the main menu bar, or by using the hot-key combination
Ctrl-B. This view contains a listing of all currently defined
breakpoints as well as a toolbar for easy breakpoint management.
Table 4.10.a: PSG Register Mnemonics
Mnemonic Register Name
C0FR Channel 0 Frequency Register
C0AR Channel 0 Attenuation Register
C1FR Channel 1 Frequency Register
C1AR Channel 1 Attenuation Register
C2FR Channel 2 Frequency Register
C2AR Channel 2 Attenuation Register
NCCR Noise Channel Control Register
NCAR Noise Channel Attenuation Register
Technical Note
The user is urged not to reset the SUSPEND flag for these device
events.
4.11 Debug Console View
The Debug Console View is not available in MesaDX Version 0.04. Future
versions of MesaDX will support include a SDSC Debug Console screen.
Chapter 5: Advanced Debug Capabilities
5.1: SDSC Debug Console
The SDSC Debug Console is not available in the current version of MesaDX.
Future versions will support all the SDSC Debug Console functionality.
5.2: Events
The most fundamental debug features added to the SM3A via the AGAMA Extensions
are events and event handling. Through the event handling mechanism both
breakpoints and monitor mode can be implemented. This section covers a little
bit about how events work and how to specify handling mechanisms for events.
By programming events directly, the user can create many more types of
breakpoints then just those currently supported in the Breakpoints view.
5.3: Determining Why the Emulator Suspended
Given the number and kinds of breakpoints that can be specified (using the
Breakpoints view or using event handling flags) it can be difficult to
determine the exact breakpoint that triggered. Forunately, there are signs in
the device AXRs that will precisely describe why emulation suspended.
Glossary
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z