|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.zmpp.vm.Machine3
public class Machine3
This class implements the state and some services of a Z-machine, version 3.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.zmpp.vm.Machine |
---|
Machine.VariableType |
Constructor Summary | |
---|---|
Machine3()
Constructor. |
Method Summary | |
---|---|
void |
enableOutputStream(int streamnumber,
boolean flag)
Enables or disables the specified output stream. |
RoutineContext |
getCurrentRoutineContext()
Returns the current routine context without affecting the state of the machine. |
Dictionary |
getDictionary()
Returns the dictonary. |
MemoryAccess |
getMemoryAccess()
Returns the reference to the memory access object. |
ObjectTree |
getObjectTree()
Returns the object tree. |
int |
getProgramCounter()
Returns the current program counter. |
int |
getRoutineStackPointer()
|
int |
getStackPointer()
Returns the global stack pointer. |
short |
getStackTopElement()
Returns the value at the top of the stack without removing it. |
StoryFileHeader |
getStoryFileHeader()
Returns the story file header. |
short |
getVariable(int variableNumber)
Returns the value of the specified variable. |
static Machine.VariableType |
getVariableType(int variableNumber)
Returns the variable type for the given variable number. |
void |
halt(String errormsg)
Halts the machine with the specified error message. |
boolean |
hasValidChecksum()
Returns true, if the checksum validation was successful. |
void |
initialize(MemoryAccess memaccess,
StoryFileHeader fileheader)
Initialization function. |
boolean |
isRunning()
Indicates if the virtual machine is running. |
void |
newline()
Prints a newline to the active output streams. |
Instruction |
nextStep()
|
void |
popRoutineContext(short returnValue)
Pops the current routine context from the stack. |
void |
print(String str)
Prints the specified string to the active output streams. |
void |
printNumber(short number)
Prints the specified signed number. |
void |
printZchar(short zchar)
Prints the specified ZSCII character. |
void |
printZsciiString(int address)
Prints the ZSCII string at the specified address to the active output streams. |
void |
pushRoutineContext(RoutineContext routineContext)
Pushes a new routine context onto the routine context stack. |
void |
quit()
Exists the virtual machine. |
short |
random(short range)
Generates a number in the range between 1 and range. |
void |
readLine(int address,
int bufferlen)
Reads a string from the selected input stream. |
void |
restart()
Restarts the virtual machine. |
boolean |
restore()
Restores a previously saved state. |
boolean |
save()
Saves the current state. |
void |
selectInputStream(int streamnumber)
Selects an input stream. |
void |
setInputStream(int streamnumber,
InputStream stream)
Sets an input stream to the specified number. |
void |
setOutputStream(int streamnumber,
OutputStream stream)
Sets the output stream to the specified number. |
void |
setProgramCounter(int address)
Sets the program counter to a new address. |
void |
setStackPointer(int stackpointer)
Sets the global stack pointer to the specified value. |
void |
setStackTopElement(short value)
Sets the value of the element at the top of the stack without incrementing the stack pointer. |
void |
setStatusLine(StatusLine statusLine)
Sets the Z-machine's status line. |
void |
setVariable(int variableNumber,
short value)
Sets the value of the specified variable. |
void |
start()
Starts the virtual machine. |
int |
translatePackedAddress(int packedAddress)
Translates a packed address into a byte address. |
void |
updateStatusLine()
Updates the status line. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Machine3()
Method Detail |
---|
public void initialize(MemoryAccess memaccess, StoryFileHeader fileheader)
initialize
in interface Machine
memaccess
- the MemoryAccess objectfileheader
- the story file headerpublic StoryFileHeader getStoryFileHeader()
getStoryFileHeader
in interface Machine
public boolean hasValidChecksum()
hasValidChecksum
in interface Machine
public MemoryAccess getMemoryAccess()
getMemoryAccess
in interface Machine
public Dictionary getDictionary()
getDictionary
in interface Machine
public ObjectTree getObjectTree()
Machine
getObjectTree
in interface Machine
public int getStackPointer()
getStackPointer
in interface Machine
public void setStackPointer(int stackpointer)
setStackPointer
in interface Machine
stackpointer
- the new stack pointer valuepublic short getStackTopElement()
getStackTopElement
in interface Machine
public void setStackTopElement(short value)
Machine
setStackTopElement
in interface Machine
value
- the value to setpublic int getProgramCounter()
getProgramCounter
in interface Machine
public void setProgramCounter(int address)
setProgramCounter
in interface Machine
address
- the new addresspublic short getVariable(int variableNumber)
getVariable
in interface Machine
variableNumber
- the variable number
public void setVariable(int variableNumber, short value)
setVariable
in interface Machine
variableNumber
- the variable numbervalue
- the value to writepublic void pushRoutineContext(RoutineContext routineContext)
pushRoutineContext
in interface Machine
routineContext
- the routine context objectpublic void popRoutineContext(short returnValue)
popRoutineContext
in interface Machine
returnValue
- the return valuepublic RoutineContext getCurrentRoutineContext()
getCurrentRoutineContext
in interface Machine
public int getRoutineStackPointer()
public static Machine.VariableType getVariableType(int variableNumber)
variableNumber
- the variable number
public short random(short range)
random
in interface Machine
range
- the range
public void setOutputStream(int streamnumber, OutputStream stream)
setOutputStream
in interface Machine
streamnumber
- the stream numberstream
- the output streampublic void printZsciiString(int address)
printZsciiString
in interface Machine
address
- the address of an ZSCII stringpublic void print(String str)
print
in interface Machine
str
- the string to printpublic void newline()
newline
in interface Machine
public void printZchar(short zchar)
printZchar
in interface Machine
zchar
- the ZSCII character to printpublic void printNumber(short number)
printNumber
in interface Machine
number
- the number to print§public void enableOutputStream(int streamnumber, boolean flag)
enableOutputStream
in interface Machine
streamnumber
- the output stream numberflag
- true to enable, false to disablepublic void setInputStream(int streamnumber, InputStream stream)
setInputStream
in interface Machine
streamnumber
- the input stream numberstream
- the input stream to setpublic void selectInputStream(int streamnumber)
selectInputStream
in interface Machine
streamnumber
- the input stream number to selectpublic void readLine(int address, int bufferlen)
readLine
in interface Machine
address
- the start address in memorybufferlen
- the length of the bufferpublic int translatePackedAddress(int packedAddress)
translatePackedAddress
in interface Machine
packedAddress
- the packed address
public void updateStatusLine()
Machine
updateStatusLine
in interface Machine
public void setStatusLine(StatusLine statusLine)
setStatusLine
in interface Machine
statusLine
- the status linepublic void halt(String errormsg)
halt
in interface Machine
errormsg
- the error messagepublic boolean save()
save
in interface Machine
public boolean restore()
restore
in interface Machine
public void restart()
restart
in interface Machine
public void quit()
quit
in interface Machine
public boolean isRunning()
isRunning
in interface Machine
public void start()
start
in interface Machine
public Instruction nextStep()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |