Class: Machine

Method and Variable Index

Public:

Protected:

Method Descriptions

Machine(Epp *epp, ScreenOutput *display, AudioOutput *audio)

In the constructor, set up any variables and data structures you need for the machine. Don't create components or do anything to the screen display, however, since these might vary in derived classes.

You also need to take as parameters to the constructor any input devices you need, such as keyboard and joystick.

uint8 readMem(Component *comp, uint16 address)

This method is invoked by components, typically the CPU and video device in order to read the RAM, ROM and memory-mapped input of the Machine.

You are passed a pointer to the calling Component, which may need to use in order to determine the result (in multi-CPU systems, for example).

In future, this function may need to be overloaded to cope with larger address spaces and data sizes.

void writeMem(Component *comp, uint16 addrres, uint8 value)

Like readMem(), but writes the given value to the given address.

uint8 in(Component *comp, uint16 port)

This method is much like readMem(), except it is used to read input from hardware devices.

Again, different versions may be needed in the future.

void out(Component *comp, uint16 port, uint8 value)

Like writeMem(), but writes the given value to the given port.

void Emulate(void)

This method is the main emulation loop for the Machine.

Typically, the method first invokes the Machine's readROMs() and createComponents() methods, and calls setupScreen() in the VideoDevice. In the main loop, then cpu(s) is run for a number of cycles, then update() is called in the joystick, video and audio devices along with any other regular operations (eg. interrupts or reading the keyboard).

The emulate() loop must also call the checkInterface() method of the Epp object, and return if it gets a non-zero result.

For a further description, see the section "Anatomy of a Machine class".

void reset(void)

This function may be invoked by the Epp front end, and should cause the emulated machine to do a hard reboot. Typically, this may only involve resetting the CPU(s), but more might be required.

void readROM(char *file, uint8 *dest, uint32 size)

This is a utility function which will read a binary file into the area pointed to by dest. The size parameter indicates the expected size of the file. An error will be logged if there is a problem reading the file.

void readROMs(void)

This method should read any required ROM and sample files.

void createComponents(void)

This method should create the Component objects used by the Machine, via the new operator. The method is invoked by emulate().

void destroyComponents(void)

This method should delete the Component objects used by the Machine, via the delete operator. The method is invoked by emulate().

Epp *epp

Pointer to the front end object. This is used to call the checkInterface() method, and may in future provide access to users' dip switch settings.

ScreenOutput *display

Pointer to the ScreenOutput object. Usually, the Machine need not use this directly, but it will need it to create VideoDevice objects.

AudioOutput *audio

Pointer to the AudioOutput object. This may be used directly be the Machine, or may be used to create audio Components.