de.michab.simulator.mos6502
Class Extension

java.lang.Object
  extended byde.michab.simulator.mos6502.Extension
All Implemented Interfaces:
Addressable, Chip

public abstract class Extension
extends java.lang.Object
implements Chip

This is an extension a.k.a. a patch. An instance of this class can be installed in memory just like a Chip (which it implements actually.) If execution hits the memory address, the extensionCalled() template method is activated and an RTS opcode is returned.

Version:
$Revision: 1.12 $
Author:
Michael G. Binz

Constructor Summary
Extension(Memory m)
          Create an instance.
 
Method Summary
protected abstract  void extensionCalled(Memory m)
          This is the template method called on hit of the Extension in memory.
abstract  int getBaseAddress()
          Returns this Extension's base address.
 Memory getMemory()
          Returns the memory this extension is installed in.
 Port[] getPorts()
          Get an array of the chip's ports.
 byte read(int port)
          Default read implementation.
 void reset()
          An empty implementation of the reset method.
 void write(int port, byte value)
          Default implementation of write for an extension.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Extension

public Extension(Memory m)
Create an instance.

Parameters:
m - The emulation's memory.
Method Detail

write

public void write(int port,
                  byte value)
Default implementation of write for an extension. Just ignores the call.

Specified by:
write in interface Addressable
Parameters:
port - The target address.
value - The value to be written.
See Also:
Addressable.write(int, byte)

read

public byte read(int port)
Default read implementation. Activates the extensionCalled() template method and returns an RTS opcode.

Specified by:
read in interface Addressable
Parameters:
port - The source address.
Returns:
The byte read.
See Also:
Addressable.read(int)

getMemory

public Memory getMemory()
Returns the memory this extension is installed in.

Returns:
The memory this extension is installed in.

getPorts

public Port[] getPorts()
Description copied from interface: Chip
Get an array of the chip's ports. May return null if this chip does not support ports.

Specified by:
getPorts in interface Chip
Returns:
An array of the chip's ports.

reset

public void reset()
An empty implementation of the reset method.

Specified by:
reset in interface Chip
See Also:
Chip.reset()

extensionCalled

protected abstract void extensionCalled(Memory m)
This is the template method called on hit of the Extension in memory. The passed Memory is the same that would be returned by getMemory().

Parameters:
m - A reference to the memory the extension is installed in.
See Also:
getMemory()

getBaseAddress

public abstract int getBaseAddress()
Returns this Extension's base address.

Returns:
This Extension's base address.