org.zmpp.base
Class MemorySection

java.lang.Object
  extended by org.zmpp.base.MemorySection
All Implemented Interfaces:
MemoryAccess, MemoryReadAccess

public class MemorySection
extends Object
implements MemoryAccess

A MemorySection object wraps a reference to a MemoryAccess object, a length and a start to support subsections within memory. All access functions will be relative to the initialized start offset within the global memory.

Version:
1.0
Author:
Wei-ju Wu

Constructor Summary
MemorySection(MemoryAccess memaccess, int start, int length)
           
 
Method Summary
 int getLength()
          Returns the length of this object in bytes.
 byte readByte(int address)
          Returns the signed 8 bit value at specified address.
 short readShort(int address)
          Returns the signed 16 bit word at the specified address.
 long readUnsigned32(int address)
          Reads the unsigned 32 bit word at the specified address.
 short readUnsignedByte(int address)
          Returns the unsigned 8 bit value at the specified address.
 int readUnsignedShort(int address)
          Reads the unsigned 16 bit word at the specified address.
 void writeByte(int address, byte value)
          Writes a byte value to the specified address.
 void writeShort(int address, short value)
          Writes a short value to the memory.
 void writeUnsigned32(int address, long value)
          Writes an unsigned 32 bit value to the specified address.
 void writeUnsignedByte(int address, short value)
          Writes an unsigned byte value to the specified address.
 void writeUnsignedShort(int address, int value)
          Writes an unsigned 16 bit value to the specified address.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MemorySection

public MemorySection(MemoryAccess memaccess,
                     int start,
                     int length)
Method Detail

getLength

public int getLength()
Returns the length of this object in bytes.

Returns:
the length in bytes

writeUnsignedShort

public void writeUnsignedShort(int address,
                               int value)
Writes an unsigned 16 bit value to the specified address.

Specified by:
writeUnsignedShort in interface MemoryAccess
Parameters:
address - the address to write to
value - the value to write

writeShort

public void writeShort(int address,
                       short value)
Writes a short value to the memory.

Specified by:
writeShort in interface MemoryAccess
Parameters:
address - the address
value - the value

writeUnsignedByte

public void writeUnsignedByte(int address,
                              short value)
Writes an unsigned byte value to the specified address.

Specified by:
writeUnsignedByte in interface MemoryAccess
Parameters:
address - the address to write to
value - the value to write

writeByte

public void writeByte(int address,
                      byte value)
Writes a byte value to the specified address.

Specified by:
writeByte in interface MemoryAccess
Parameters:
address - the address
value - the value

writeUnsigned32

public void writeUnsigned32(int address,
                            long value)
Writes an unsigned 32 bit value to the specified address.

Specified by:
writeUnsigned32 in interface MemoryAccess
Parameters:
address - the address to write to
value - the value to write

readUnsigned32

public long readUnsigned32(int address)
Reads the unsigned 32 bit word at the specified address.

Specified by:
readUnsigned32 in interface MemoryReadAccess
Parameters:
address - the address
Returns:
the 32 bit unsigned value as long

readUnsignedShort

public int readUnsignedShort(int address)
Reads the unsigned 16 bit word at the specified address.

Specified by:
readUnsignedShort in interface MemoryReadAccess
Parameters:
address - the address
Returns:
the 16 bit unsigned value as int

readShort

public short readShort(int address)
Returns the signed 16 bit word at the specified address.

Specified by:
readShort in interface MemoryReadAccess
Parameters:
address - the address
Returns:
the 16 bit signed value

readUnsignedByte

public short readUnsignedByte(int address)
Returns the unsigned 8 bit value at the specified address.

Specified by:
readUnsignedByte in interface MemoryReadAccess
Parameters:
address - the address
Returns:
the 8 bit unsigned value

readByte

public byte readByte(int address)
Returns the signed 8 bit value at specified address.

Specified by:
readByte in interface MemoryReadAccess
Parameters:
address - the byte address
Returns:
the 8 bit signed value


Copyright © 2005 . All Rights Reserved.