|
Revision 144, 3.7 kB
(checked in by krobillard, 3 years ago)
|
|
Native arguments are now kept on the stack until after the call and the
result is now always put into a1.
|
| Line | |
|---|
| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | #include <stdio.h> |
|---|
| 22 | #include "gx.h" |
|---|
| 23 | #include "audio.h" |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | #define ESC 27 |
|---|
| 27 | |
|---|
| 28 | #ifdef _WIN32 |
|---|
| 29 | extern void redirectIOToConsole(); |
|---|
| 30 | #define OPEN_CONSOLE redirectIOToConsole(); |
|---|
| 31 | #else |
|---|
| 32 | #define OPEN_CONSOLE |
|---|
| 33 | #endif |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | int main( int argc, char** argv ) |
|---|
| 37 | { |
|---|
| 38 | OEnv env; |
|---|
| 39 | char cmd[ 128 ]; |
|---|
| 40 | int ret = 0; |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | gView = glv_create( GLV_ATTRIB_DOUBLEBUFFER ); |
|---|
| 44 | if( ! gView ) |
|---|
| 45 | return( -1 ); |
|---|
| 46 | |
|---|
| 47 | #ifndef NO_AUDIO |
|---|
| 48 | audioStartup(); |
|---|
| 49 | #endif |
|---|
| 50 | |
|---|
| 51 | orInitEnv( &env, 0, 0 ); |
|---|
| 52 | gxInitEnv(); |
|---|
| 53 | |
|---|
| 54 | |
|---|
| 55 | if( argc > 1 ) |
|---|
| 56 | { |
|---|
| 57 | OIndex strN; |
|---|
| 58 | OValue* tos; |
|---|
| 59 | |
|---|
| 60 | tos = orTOS; |
|---|
| 61 | strN = orMakeCString( argv[1], -1 ); |
|---|
| 62 | orSetTF(tos, OT_FILE ); |
|---|
| 63 | orSetSeries(tos, strN, 0 ); |
|---|
| 64 | |
|---|
| 65 | orDoNative( tos ); |
|---|
| 66 | if( orErrorThrown ) |
|---|
| 67 | { |
|---|
| 68 | if( ! orErrorIsType(OR_ERROR_QUIT) ) |
|---|
| 69 | { |
|---|
| 70 | OPEN_CONSOLE |
|---|
| 71 | |
|---|
| 72 | if( orErrorIsType(OR_ERROR_HALT) ) |
|---|
| 73 | { |
|---|
| 74 | orErrorClear; |
|---|
| 75 | |
|---|
| 76 | orEnv->dataStack.used = 0; |
|---|
| 77 | orEnv->callStack.used = 0; |
|---|
| 78 | goto halt; |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | orPrintNative( orErrorThrown ); |
|---|
| 82 | ret = -1; |
|---|
| 83 | } |
|---|
| 84 | } |
|---|
| 85 | } |
|---|
| 86 | else |
|---|
| 87 | { |
|---|
| 88 | OPEN_CONSOLE |
|---|
| 89 | printf( "ORCA-GL %s (%s)\n", OR_VERSION_STR, __DATE__ ); |
|---|
| 90 | |
|---|
| 91 | halt: |
|---|
| 92 | while( 1 ) |
|---|
| 93 | { |
|---|
| 94 | printf( "O> " ); |
|---|
| 95 | fflush( stdout ); |
|---|
| 96 | fgets( cmd, 128, stdin ); |
|---|
| 97 | |
|---|
| 98 | #if 0 |
|---|
| 99 | { |
|---|
| 100 | char* cp = cmd; |
|---|
| 101 | while( *cp != '\n' ) |
|---|
| 102 | printf( " %d", (int) *cp++ ); |
|---|
| 103 | printf( "\n" ); |
|---|
| 104 | } |
|---|
| 105 | #endif |
|---|
| 106 | |
|---|
| 107 | if( cmd[0] == ESC ) |
|---|
| 108 | { |
|---|
| 109 | |
|---|
| 110 | |
|---|
| 111 | printf( "\n" ); |
|---|
| 112 | } |
|---|
| 113 | else if( cmd[0] != '\n' ) |
|---|
| 114 | { |
|---|
| 115 | orEvalCStr( cmd, -1 ); |
|---|
| 116 | |
|---|
| 117 | if( orErrorThrown ) |
|---|
| 118 | { |
|---|
| 119 | if( orErrorIsType(OR_ERROR_QUIT) ) |
|---|
| 120 | break; |
|---|
| 121 | if( ! orErrorIsType(OR_ERROR_HALT) ) |
|---|
| 122 | orPrintNative( orErrorThrown ); |
|---|
| 123 | orErrorClear; |
|---|
| 124 | } |
|---|
| 125 | else |
|---|
| 126 | { |
|---|
| 127 | OValue* val; |
|---|
| 128 | val = orTOS; |
|---|
| 129 | if( (val->type != OT_UNSET) && |
|---|
| 130 | (val->type != OT_OBJECT) && |
|---|
| 131 | (val->type != OT_FUNCTION) ) |
|---|
| 132 | { |
|---|
| 133 | printf( "== " ); |
|---|
| 134 | orProbe( val ); |
|---|
| 135 | } |
|---|
| 136 | } |
|---|
| 137 | } |
|---|
| 138 | } |
|---|
| 139 | } |
|---|
| 140 | |
|---|
| 141 | gxFreeEnv(); |
|---|
| 142 | orFreeEnv( &env ); |
|---|
| 143 | |
|---|
| 144 | #ifndef NO_AUDIO |
|---|
| 145 | audioShutdown(); |
|---|
| 146 | #endif |
|---|
| 147 | |
|---|
| 148 | glv_destroy( gView ); |
|---|
| 149 | |
|---|
| 150 | return ret; |
|---|
| 151 | } |
|---|
| 152 | |
|---|
| 153 | |
|---|
| 154 | |
|---|