C# Class FyreVM.Engine

Show file Open project: ChicagoDave/Zifmia Class Usage Examples

Public Methods

Method Description
Continue ( ) : void
Engine ( Stream gameFile ) : System

Initializes a new instance of the VM from a game file.

Engine ( Stream gameFile, Stream saveFile ) : System

Initializes a new instance of the VM from a saved state and the associated game file.

Run ( ) : void

Starts the interpreter.

This method does not return until the game finishes, either by returning from the main function or with the quit opcode.

Stop ( ) : void

Terminates the interpreter loop, causing the Run method to return.

Private Methods

Method Description
Bootstrap ( ) : void

Clears the stack and initializes VM registers from values found in RAM.

CacheDecodingTable ( ) : void

Builds a native version of the string decoding table if the table is entirely in ROM, or verifies the table's current state if the table is in RAM.

CacheDecodingTableNode ( uint node ) : StrNode
CompareKeys ( uint query, uint candidateAddr, uint keySize, SearchOptions options ) : int

Performs key comparison for the various search opcodes.

DecodeDelayedStoreOperand ( byte type, uint &operandPos, uint resultArray, int resultIndex ) : void
DecodeFloat ( uint x ) : float
DecodeLoadOperand ( Opcode opcode, byte type, uint &operandPos ) : uint
DecodeStoreOperand ( Opcode opcode, byte type, uint &operandPos ) : uint
DeliverOutput ( ) : void

Sends the queued output to the OutputReady event handler.

DonePrinting ( ) : void
EncodeFloat ( float x ) : uint
EnterFunction ( uint address ) : void

Pushes a frame for a function call, updating FP, SP, and PC. (A call stub should have already been pushed.)

EnterFunction ( uint address, uint args ) : void

Pushes a frame for a function call, updating FP, SP, and PC. (A call stub should have already been pushed.)

FloatEqual ( float f1, float f2, float tolerance ) : bool
GlkReadReference ( uint reference ) : uint
GlkWrapperCall ( uint args ) : void
GlkWrapperWrite ( string str ) : void
GlkWrapperWrite ( uint ch ) : void
GlkWriteReference ( uint reference ) : void
GlkWriteReference ( uint reference, uint value ) : void
HandleHeapMemoryRequest ( uint newEndMem ) : bool
InitGlkHandlers ( ) : void
InitOpcodeDict ( ) : void
InputChar ( ) : char
InputLine ( uint address, uint bufSize ) : void
InterpreterLoop ( ) : void

Runs the main interpreter loop.

KeyIsZero ( uint address, uint size ) : bool
LeaveFunction ( uint result ) : void
LoadFromStream ( Stream stream ) : void
NestedCall ( uint address ) : uint
NestedCall ( uint address, uint arg0 ) : uint
NestedCall ( uint address, uint arg0, uint arg1 ) : uint
NestedCall ( uint address, uint arg0, uint arg1, uint arg2 ) : uint
NextCStringChar ( ) : void
NextCompressedChar ( ) : void

Prints the next character of a compressed string, consuming one or more bits.

This is only used when the string decoding table is in RAM.

NextCompressedStringBit ( ) : bool
NextDigit ( ) : void
NextUniStringChar ( ) : void
PerformBinarySearch ( uint key, uint keySize, uint start, uint structSize, uint numStructs, uint keyOffset, SearchOptions options ) : uint
PerformCall ( uint address, uint args, uint destType, uint destAddr ) : void
PerformCall ( uint address, uint args, uint destType, uint destAddr, uint stubPC ) : void
PerformCall ( uint address, uint args, uint destType, uint destAddr, uint stubPC, bool tailCall ) : void

Enters a function, pushing a call stub first if necessary.

PerformDelayedStore ( uint type, uint address, uint value ) : void
Pop ( ) : uint
PopCallStub ( ) : CallStub
PrintIndirect ( uint address, uint argCount, uint argsAt ) : void

Prints a string, or calls a routine, when an indirect node is encountered in a compressed string.

Push ( uint value ) : void
PushCallStub ( CallStub stub ) : void
ReadCString ( uint address ) : string
ReadFromStack ( uint position ) : uint
ReadUniString ( uint address ) : string
Restart ( ) : void

Reloads the initial contents of memory (except the protected area) and starts the game over from the top of the main function.

ResumeFromCallStub ( uint result ) : void
SaveToStream ( Stream stream, uint destType, uint destAddr ) : void
SelectOutputSystem ( uint number, uint rock ) : void
SendCharToOutput ( uint ch ) : void

Sends a single character to the output system (other than IOSystem.Filter.

SendStringToOutput ( string str ) : void

Sends a string to the output system (other than IOSystem.Filter.

StoreResult ( OpcodeRule rule, byte type, uint address, uint value ) : void
StreamCharCore ( uint value ) : void
StringToLatin1 ( string str ) : byte[]
TakeBranch ( uint target ) : void
Truncate ( double d ) : double
VerifyDecodingTable ( ) : void

Checks that the string decoding table is well-formed, i.e., that it contains at least one branch, one end marker, and no unrecognized node types.

WriteToStack ( uint position, uint value ) : void
WriteTrace ( string str ) : void
glk_char_to_lower ( uint args ) : uint
glk_char_to_upper ( uint args ) : uint
glk_fileref_iterate ( uint args ) : uint
glk_request_line_event ( uint args ) : uint
glk_select ( uint args ) : uint
glk_set_style ( uint args ) : uint
glk_set_window ( uint args ) : uint
glk_stream_close ( uint args ) : uint
glk_stream_get_current ( uint args ) : uint
glk_stream_iterate ( uint args ) : uint
glk_stream_open_memory ( uint args ) : uint
glk_stream_open_memory_uni ( uint args ) : uint
glk_stream_set_current ( uint args ) : uint
glk_window_iterate ( uint args ) : uint
glk_window_open ( uint args ) : uint
op_accelfunc ( uint args ) : void
op_accelparam ( uint args ) : void
op_acos ( uint args ) : void
op_add ( uint args ) : void
op_aload ( uint args ) : void
op_aloadb ( uint args ) : void
op_aloadbit ( uint args ) : void
op_aloads ( uint args ) : void
op_asin ( uint args ) : void
op_astore ( uint args ) : void
op_astoreb ( uint args ) : void
op_astorebit ( uint args ) : void
op_astores ( uint args ) : void
op_atan ( uint args ) : void
op_atan2 ( uint args ) : void
op_binarysearch ( uint args ) : void
op_bitand ( uint args ) : void
op_bitnot ( uint args ) : void
op_bitor ( uint args ) : void
op_bitxor ( uint args ) : void
op_call ( uint args ) : void
op_callf ( uint args ) : void
op_callfi ( uint args ) : void
op_callfii ( uint args ) : void
op_callfiii ( uint args ) : void
op_catch ( uint args ) : void
op_ceil ( uint args ) : void
op_copy ( uint args ) : void
op_copyb ( uint args ) : void
op_copys ( uint args ) : void
op_cos ( uint args ) : void
op_debugtrap ( uint args ) : void
op_div ( uint args ) : void
op_exp ( uint args ) : void
op_fadd ( uint args ) : void
op_fdiv ( uint args ) : void
op_floor ( uint args ) : void
op_fmod ( uint args ) : void
op_fmul ( uint args ) : void
op_fsub ( uint args ) : void
op_ftonumn ( uint args ) : void
op_ftonumz ( uint args ) : void
op_fyrecall ( uint args ) : void
op_gestalt ( uint args ) : void
op_getiosys ( uint args ) : void
op_getmemsize ( uint args ) : void
op_getstringtbl ( uint args ) : void
op_glk ( uint args ) : void
op_jeq ( uint args ) : void
op_jfeq ( uint args ) : void
op_jfge ( uint args ) : void
op_jfgt ( uint args ) : void
op_jfle ( uint args ) : void
op_jflt ( uint args ) : void
op_jfne ( uint args ) : void
op_jge ( uint args ) : void
op_jgeu ( uint args ) : void
op_jgt ( uint args ) : void
op_jgtu ( uint args ) : void
op_jisinf ( uint args ) : void
op_jisnan ( uint args ) : void
op_jle ( uint args ) : void
op_jleu ( uint args ) : void
op_jlt ( uint args ) : void
op_jltu ( uint args ) : void
op_jne ( uint args ) : void
op_jnz ( uint args ) : void
op_jump ( uint args ) : void
op_jumpabs ( uint args ) : void
op_jz ( uint args ) : void
op_linearsearch ( uint args ) : void
op_linkedsearch ( uint args ) : void
op_log ( uint args ) : void
op_malloc ( uint args ) : void
op_mcopy ( uint args ) : void
op_mfree ( uint args ) : void
op_mod ( uint args ) : void
op_mul ( uint args ) : void
op_mzero ( uint args ) : void
op_neg ( uint args ) : void
op_nop ( uint args ) : void
op_numtof ( uint args ) : void
op_pow ( uint args ) : void
op_protect ( uint args ) : void
op_quit ( uint args ) : void
op_random ( uint args ) : void
op_restart ( uint args ) : void
op_restore ( uint args ) : void
op_restoreundo ( uint args ) : void
op_return ( uint args ) : void
op_save ( uint args ) : void
op_saveundo ( uint args ) : void
op_setiosys ( uint args ) : void
op_setmemsize ( uint args ) : void
op_setrandom ( uint args ) : void
op_setstringtbl ( uint args ) : void
op_sexb ( uint args ) : void
op_sexs ( uint args ) : void
op_shiftl ( uint args ) : void
op_sin ( uint args ) : void
op_sqrt ( uint args ) : void
op_sshiftr ( uint args ) : void
op_stkcopy ( uint args ) : void
op_stkcount ( uint args ) : void
op_stkpeek ( uint args ) : void
op_stkroll ( uint args ) : void
op_stkswap ( uint args ) : void
op_streamchar ( uint args ) : void
op_streamnum ( uint args ) : void
op_streamstr ( uint args ) : void
op_streamunichar ( uint args ) : void
op_sub ( uint args ) : void
op_tailcall ( uint args ) : void
op_tan ( uint args ) : void
op_throw ( uint args ) : void
op_ushiftr ( uint args ) : void
op_verify ( uint args ) : void

Method Details

Continue() public method

public Continue ( ) : void
return void

Engine() public method

Initializes a new instance of the VM from a game file.
public Engine ( Stream gameFile ) : System
gameFile Stream A stream containing the ROM and /// initial RAM.
return System

Engine() public method

Initializes a new instance of the VM from a saved state and the associated game file.
public Engine ( Stream gameFile, Stream saveFile ) : System
gameFile Stream A stream containing the ROM and /// initial RAM.
saveFile Stream A stream containing a /// state that was saved by the specified game file.
return System

Run() public method

Starts the interpreter.
This method does not return until the game finishes, either by returning from the main function or with the quit opcode.
public Run ( ) : void
return void

Stop() public method

Terminates the interpreter loop, causing the Run method to return.
public Stop ( ) : void
return void