|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Machine
This interface gives the instructions an abstract access to the current Z-machine's state.
Nested Class Summary | |
---|---|
static class |
Machine.VariableType
The possible variable types. |
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 |
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. |
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. |
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 num)
Prints the specified signed number. |
void |
printZchar(short zchar)
Prints the specified ZSCII character. |
void |
printZsciiString(int stringAddress)
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. |
Method Detail |
---|
StoryFileHeader getStoryFileHeader()
boolean hasValidChecksum()
int getProgramCounter()
void setProgramCounter(int address)
address
- the new addressint getStackPointer()
void setStackPointer(int stackpointer)
stackpointer
- the new stack pointer valueshort getStackTopElement()
void setStackTopElement(short value)
value
- the value to setMemoryAccess getMemoryAccess()
short getVariable(int variableNumber)
variableNumber
- the variable number
IllegalStateException
- if a local variable is accessed without
a subroutine context or if a non-existent local variable is accessedvoid setVariable(int variableNumber, short value)
variableNumber
- the variable numbervalue
- the value to write
IllegalStateException
- if a local variable is accessed without
a subroutine context or if a non-existent local variable is accessedvoid pushRoutineContext(RoutineContext routineContext)
routineContext
- the routine context objectvoid popRoutineContext(short returnValue)
returnValue
- the return value
IllegalStateException
- if no RoutineContext existsRoutineContext getCurrentRoutineContext()
Dictionary getDictionary()
ObjectTree getObjectTree()
void setOutputStream(int streamnumber, OutputStream stream)
streamnumber
- the stream numberstream
- the output streamvoid enableOutputStream(int streamnumber, boolean flag)
streamnumber
- the output stream numberflag
- true to enable, false to disablevoid setInputStream(int streamnumber, InputStream stream)
streamnumber
- the input stream numberstream
- the input stream to setvoid selectInputStream(int streamnumber)
streamnumber
- the input stream number to selectvoid readLine(int address, int bufferlen)
address
- the start address in memorybufferlen
- the length of the buffervoid printZsciiString(int stringAddress)
stringAddress
- the address of an ZSCII stringvoid print(String str)
str
- the string to printvoid newline()
void printZchar(short zchar)
zchar
- the ZSCII character to printvoid printNumber(short num)
num
- the number to print§int translatePackedAddress(int packedAddress)
packedAddress
- the packed address
short random(short range)
range
- the range
void updateStatusLine()
void setStatusLine(StatusLine statusline)
statusline
- the status linevoid initialize(MemoryAccess memaccess, StoryFileHeader fileheader)
memaccess
- the MemoryAccess objectfileheader
- the story file headervoid halt(String errormsg)
errormsg
- the error messageboolean save()
boolean restore()
void restart()
void start()
void quit()
boolean isRunning()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |