Advertisement
ZoriaRPG

Debug Cheat Shell (v1.8, Working)

Nov 1st, 2018
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 33.89 KB | None | 0 0
  1. /////////////////////////////////
  2. /// Debug Shell for ZC Quests ///
  3. /// Alpha Version 1.8.0       ///
  4. /// 1st November, 2018        ///
  5. /// By: ZoriaRPG              ///
  6. /// Requires: ZC Necromancer  ///
  7. /////////////////////////////////
  8. //
  9. // v1.2   : Finished working code. now it all functions as I intend.
  10. // v1.2.1 : Added a code comment block with examples on how to add more instructions to match_instruction().
  11. // v1.2.1 : Added a sanity check to setting Link->Item[]. It now only works on inventory items.
  12. // v1.3.0 : Added the SAVE instruction.
  13. // v1.4.0 : Added CREATEITEM ( cri,id,x,y )
  14. // v1.4.0 : Added CREATENPC ( crn,id,x,y )
  15. // v1.4.0 : Fixed bug where buffer persists through saves.
  16. // v1.5.0 : Added LX and LY as literal args for Link's X and Y positions.
  17. // v1.6.0 : Added LX and LY tracing.
  18. // v1.6.0 : Added PALETTE as pal,n1,n2 -- POS now requires more than 'p' -- to change DMap Palette. -1 for current DMap.
  19. // v1.6.0 :       This sets Game->DmapPalette[n1] = n2
  20. // v1.6.0 : Added MONOCHROME as mon,n to set Graphics->Monochrome(n1)
  21. // v1.6.1 : Added break instructiosn to fix invalid rval and other invalid returns in switch statements.
  22. // v1.6.2 : Added clear instructions to case for NONE in switch(instr).
  23. // v1.7.0 : Added LTRIFORCE to set if Link has the triforce for a given level as 'lt,id,true|false'
  24. // v1.7.0 : Added LCOMPASS to set if Link has the compass for a given level as 'lc,id,true|false'
  25. // v1.7.0 : Added LMAP to set if Link has the map for a given level as 'lm,id,true|false'
  26. // v1.7.0 : Added LBOSSKEY to set if Link has the boss key for a given level as 'lb,id,true|false'
  27. // v1.7.0 : Added LKEYS to set the current number of LEVEL KEYS for a given level ID as 'lk,levelid,number'
  28. // v1.7.0 : Added BOMBS to set the current number of bombs as 'b,number'
  29. // v1.7.0 : Added MBOMBS to set the current number of max bombs as 'b,number'
  30. // v1.7.0 : Added ARROWS to set the current number of arrows as 'a,number'
  31. // v1.7.0 : Added MARROWS to set the current number of max arrows as 'a,number'
  32. // v1.7.0 : Added RUPEES to set the current number of rupees as 'r,number'
  33. // v1.7.0 : Added MRUPEES to set the current number of max rupees as 'r,number'
  34. // v1.7.0 : Added KEYS to set the current number of keys as 'k,number'
  35. // v1.7.0 : Added BIGHITBOX to set the if Link's hitbox is large (full tile collision), or small, as 'h,t|f'
  36. // v1.7.0 : Added LINKDIAGONAL to set the if Link may move diagonally, as 'd,t|f'
  37. // v1.7.1 : orrected a bug where RUPEES was using Game->Counter[RUPEES} insead of CR_RUPEES.
  38. // v1.7.1 : Added a NULL case for token[1] of command 'r', so that 'r' without any other legal char as the next token is RUPEES.
  39. // v1.8.0 : Added SETFFSCRIPT as 'fs,ffc_id,script_id'
  40. // v1.8.0 : Added SETFFCDATA as 'fs,ffc_id,combo_id'
  41. // v1.8.0 : Added RUNFFCSCRIPTID as 'run,script_id'
  42. // v1.8.0 : Fixed missing break statements in execute() switch(instr).
  43.  
  44.  
  45. import "std.zh"
  46.  
  47. /*
  48. DEFINED INSTRUCTION VALUES
  49.     w WARP: return 2;   //dmap,screen
  50.     p POS: return 2;        //x,y
  51.     mx MOVEX: return 1;     //pixels (+/-)
  52.     my MOVEY: return 1;     //pixels (+/-)
  53.     rh REFILLHP: return 0;  //aNONE
  54.     rm REFILLMP: return 0;  //NONE
  55.     rc REFILLCTR: return 1; //counter
  56.     mh MAXHP: return 1; //amount
  57.     mm MAXMP: return 1; //amount
  58.     mc MAXCTR: return 2;    //counter, amount
  59.     save SAVE: return 0;   
  60.     cri CREATEITEM: return 3;   //id, x, y
  61.     crn CREATENPC: return 3;    //id, x, y
  62.    
  63.     inv INVINCIBLE: return 1;   //(BOOL) on / off
  64.     itm LINKITEM: return 2; //item, (BOOL), on / off
  65.     pal PALETTE return 2
  66.     mon MONOCHROME return 1
  67.    
  68.     h BIGHITBOX
  69.     d LINKDIAGONAL
  70.    
  71.     a ARROWS
  72.     b BOMBS
  73.     r RUPEES
  74.     mb MAXBOMBS
  75.     ma MAXARROWS
  76.     mr MAXRUPEES
  77.     k KEYS
  78.     lk LKEYS
  79.     lm LMAP
  80.     lc LCOMPASS
  81.     lt LTRIFORCE
  82.    
  83.  
  84. //COMMAND LIST
  85.     w: Warp Link to a specific dmap and screen
  86.     p: Reposition Link on the screen.
  87.     mx: Move link by +/-n pixels on the X axis.
  88.     my: Move link by +/-n pixels on the Y axis.
  89.     rh: Refill Link's HP to Max.
  90.     rm: Refill Link's HP to Max.
  91.     rc: Refill a specific counter to Max.
  92.     mh: Set Link's Max HP.
  93.     mm: Set Link's Max MP
  94.     mc: Set the maximum value of a specific counter.
  95.     inv: Set Link's Invisible state.
  96.     itm: Set the state of a specific item in Link's inventory.
  97.     save: Save the game.
  98.     cri: Create an item.
  99.     crn: Create an npc.
  100.     pal: Change a DMap palette; -1 for current dmap.
  101.     mono: Set monochrome effect.
  102.    
  103.     h: Set if Link uses a full tile hitbox. (hitbox)
  104.     d: Set if Link can move diagonally.
  105.    
  106.     a: Set the current number of Arrows
  107.     b: Set the current number of Bombs
  108.     r: Set the current number of Rupees
  109.     mb: Set the current number of Max Bombs
  110.     ma: Set the current number of Max Arrows
  111.     mr: Set the current number of Max Rupees
  112.     k: Set the current number of Keys
  113.     lk: Set the current number of Level Keys for a specific level ID.
  114.     lm: Set if the MAP item for a specific Level is in inventory.
  115.     lc: Set if the COMPASS item for a specific Level is in inventory.
  116.     lt: Set if the TRIFORCE item for a specific Level is in inventory.
  117.     lb: Set if the BOSS KEy item for a specific Level is in inventory.
  118.    
  119.     fd: Set the Data value of one ffc.
  120.     fs: Set the Script value of one ffc.
  121.     run: Attempt to run an ffc script.
  122.    
  123. //SYNTAX
  124. //command,args
  125.     w,1,2
  126.     p,1,2
  127.     mx,1
  128.     mx,-1
  129.     my,1
  130.     my,-1
  131.     rh
  132.     rm
  133.     rc,1
  134.     mh,1
  135.     mm,1
  136.     mc,1,2
  137.     inv,true
  138.     inv,false
  139.     itm,1,true
  140.     itm,1,false
  141.     save
  142.     cri,1,2,3 //id,x,y
  143.     crn,1,2,3 //id,x,y
  144.     pal,1,2 //dmap (-1 for current), palette
  145.     mono,1 : mono,type
  146.     h,true|false
  147.     d,true|false
  148.    
  149.     a,1
  150.     b,1
  151.     r,1
  152.     mb,1
  153.     ma,1
  154.     mr,1
  155.     k,1
  156.     lk,1,2 (level id, number)
  157.     lm,1,t|f (level id, true|false)
  158.     lc,1,t|f (level id, true|false)
  159.     lt,1,t|f (level id, true|false)
  160.     lb,1,t|f (level id, true|false)
  161.    
  162.     fd,1,2 (fs,ffc_id,combo_id)
  163.     fs,1,2 (fs,ffc_id,script_id)
  164.     run,1 (run,ffc_script_id)
  165.        
  166.        
  167.  
  168. */
  169.  
  170. script typedef ffc namespace;
  171. typedef const int define;
  172. typedef const int CFG;
  173.  
  174.  
  175.  
  176. namespace script debugshell
  177. {
  178.     CFG INVISIBLE_COMBO = 1;
  179.    
  180.     define INSTRUCTION_SIZE = 1; //The number of stack registers that any given *instruction* requires.
  181.     define MAX_INSTR_QUEUE = 1; //The number of instructions that can be enqueued.
  182.     define MAX_ARGS     = 3; //The maximum number of args that any instruction can use/require.
  183.     define STACK_SIZE   = 1 + ((INSTRUCTION_SIZE+MAX_ARGS)*MAX_INSTR_QUEUE);
  184.     define MAX_TOKEN_LENGTH = 16;
  185.     define BUFFER_LENGTH    = 42;
  186.     int stack[STACK_SIZE];
  187.     int SP;
  188.    
  189.     int debug_buffer[BUFFER_LENGTH];
  190.    
  191.     define YES = 1;
  192.     define NO = 0;
  193.    
  194.     CFG log_actions = YES;
  195.     CFG WINDOW_F_KEY = 7; //We use F7 to open the debug window.
  196.    
  197.    
  198.     define FONT = FONT_APPLE2; //Apple II
  199.     define F_COLOUR = 0x01; //font colour, white
  200.     define F_BCOLOUR = -1; //font background colour, translucent
  201.     define W_COLOUR = 0x03; //window colour (background), black
  202.     define W_S_COLOUR = 0xC5; //window colour (background), black
  203.     define CHAR_WIDTH = 6; //5 + one space
  204.     define CHAR_HEIGHT = 9; //8 + one space
  205.     define WINDOW_X = 15; //window indent over screen
  206.     define WINDOW_Y = 19; //window indent over screen
  207.     define WINDOW_H = 50;//CHAR_WIDTH * BUFFER_LENGTH;
  208.     define WINDOW_W = 180; //CHAR_HEIGHT * 3;
  209.     define WINDOW_S_X = 12; //window indent over screen
  210.     define WINDOW_S_Y = 16; //window indent over screen
  211.     define WINDOW_S_H = 50; //CHAR_WIDTH * BUFFER_LENGTH;
  212.     define WINDOW_S_W = 180; //CHAR_HEIGHT * 3;
  213.     define CHAR_X = 2; //Initial x indent
  214.     define CHAR_Y = 2; //Initial y indent
  215.     define W_OPACITY = OP_OPAQUE; //Window translucency.
  216.     define F_OPACITY = OP_OPAQUE; //Font translucency.
  217.     define W_LAYER = 6; //window draw layer
  218.     define F_LAYER = 6; //font draw layer
  219.    
  220.     CFG KEY_DELAY = 6; //frames between keystrokes
  221.    
  222.     define TYPESFX = 63;
  223.    
  224.     void process()
  225.     {
  226.         if ( Input->Key[51] ) //46+WINDOW_F_KEY] )
  227.         {
  228.             TraceS("Enabled Deb ug Shell");
  229.             if ( type() )
  230.             {
  231.                 TraceS("process() evaluated type() true");
  232.                
  233.                 int r = read(debug_buffer);
  234.                 if ( r ) execute();
  235.             }
  236.         }
  237.     }
  238.    
  239.     //if ( type() execute() )
  240.     //returns true if the user presses enter
  241.     bool type()
  242.     {
  243.         int frame = 0;
  244.         if ( !frame ) TraceS("Starting type()");
  245.         ++frame;
  246.         Game->TypingMode = true;
  247.         int key_timer; int buffer_pos = 0;
  248.         bool typing = true;
  249.         //while(!Input->ReadKey[KEY_ENTER] || Input->ReadKey[KEY_ENTER_PAD])
  250.         while(typing)
  251.         {
  252.             if ( key_timer <= 0 )
  253.             {
  254.                 if ( Input->ReadKey[KEY_BACKSPACE] ) //backspace
  255.                 {
  256.                    
  257.                     if ( buffer_pos > 0 )
  258.                     {
  259.                         debug_buffer[buffer_pos] = 0;
  260.                         --buffer_pos;
  261.                         debug_buffer[buffer_pos] = 0;
  262.                     }
  263.                     key_timer = KEY_DELAY;
  264.                     continue;
  265.                 }
  266.                 else if ( Input->ReadKey[KEY_ENTER] || Input->ReadKey[KEY_ENTER_PAD] )
  267.                 {
  268.                     Game->TypingMode = false;
  269.                     TraceNL(); TraceS("Read enter key, and buffer position is: "); Trace(buffer_pos); TraceNL();
  270.                     if ( !buffer_pos ) return false; //do not execute if there are no commands
  271.                     return true;
  272.                 }
  273.                 else if ( EscKey() )
  274.                 {
  275.                     for ( int q = 0; q < BUFFER_LENGTH; ++q ) debug_buffer[q] = 0;
  276.                    
  277.                    
  278.                     Game->TypingMode = false;
  279.                     return false; //exit and do not process.
  280.                 }
  281.                
  282.                 else
  283.                 {
  284.                     //else normal key
  285.                     int k;
  286.                     int LegalKeys[]=
  287.                     {
  288.                         KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G, KEY_H,
  289.                         KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N, KEY_O, KEY_P,
  290.                         KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U, KEY_V, KEY_W, KEY_X,
  291.                         KEY_Y, KEY_Z, KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5,
  292.                         KEY_6, KEY_7, KEY_8, KEY_9, KEY_0_PAD, KEY_1_PAD, KEY_2_PAD,
  293.                         KEY_3_PAD, KEY_4_PAD, KEY_5_PAD,
  294.                         KEY_6_PAD, KEY_7_PAD, KEY_8_PAD, KEY_9_PAD,
  295.                         //KEY_TILDE,
  296.                         KEY_MINUS,
  297.                         //KEY_EQUALS, KEY_OPENBRACE, KEY_CLOSEBRACE,
  298.                         //KEY_COLON, KEY_QUOTE, KEY_BACKSLASH, KEY_BACKSLASH2,
  299.                         KEY_COMMA,
  300.                         //KEY_SEMICOLON, KEY_SLASH, KEY_SPACE, KEY_SLASH_PAD,
  301.                         //KEY_ASTERISK,
  302.                         KEY_MINUS_PAD
  303.                         //KEY_PLUS_PAD, KEY_CIRCUMFLEX, KEY_COLON2, KEY_EQUALS_PAD, KEY_STOP
  304.                     };
  305.  
  306.                    
  307.                     for ( int kk = SizeOfArray(LegalKeys)-1; kk >= 0; --kk )
  308.                     {
  309.                         k = LegalKeys[kk];
  310.                         if ( Input->ReadKey[k] )
  311.                         {
  312.                             TraceS("Read a key: "); Trace(k); TraceNL();
  313.                             debug_buffer[buffer_pos] = KeyToChar(k,(Input->ReadKey[KEY_LSHIFT])||(Input->ReadKey[KEY_RSHIFT])); //Warning!: Some masking may occur. :P
  314.                             TraceNL(); TraceS(debug_buffer); TraceNL();
  315.                             ++buffer_pos;
  316.                             key_timer = KEY_DELAY;
  317.                             break;
  318.                         }
  319.                     }
  320.                    
  321.                     //continue;
  322.                 }
  323.             }
  324.             else { --key_timer; }
  325.            
  326.             draw();
  327.             Waitframe();
  328.         }
  329.        
  330.     }
  331.    
  332.     void draw()
  333.     {
  334.         Screen->Rectangle(W_LAYER, WINDOW_S_X, WINDOW_S_Y, WINDOW_S_X+WINDOW_W, WINDOW_S_Y+WINDOW_H, W_S_COLOUR, 1, 0,0,0,true,W_OPACITY);
  335.         Screen->Rectangle(W_LAYER, WINDOW_X, WINDOW_Y, WINDOW_X+WINDOW_W, WINDOW_Y+WINDOW_H, W_COLOUR, 1, 0,0,0,true,W_OPACITY);
  336.         Screen->DrawString(F_LAYER,WINDOW_X+CHAR_X,WINDOW_Y+CHAR_Y,FONT,F_COLOUR,F_BCOLOUR,0,debug_buffer,F_OPACITY);
  337.     }
  338.    
  339.     void TraceErrorS(int s, int s2)
  340.     {
  341.         TraceS(s); TraceS(": "); TraceS(s2); TraceNL();
  342.     }
  343.    
  344.     void TraceError(int s, float v, float v2)
  345.     {
  346.         int buf[12]; int buf2[12];
  347.         ftoa(buf,v);
  348.         ftoa(buf2,v2);
  349.         TraceS(s); TraceS(": "); TraceS(buf); TraceS(", "); TraceS(buf2); TraceNL();
  350.     }
  351.    
  352.     void TraceErrorVS(int s, float v, int s2)
  353.     {
  354.         int buf[12];
  355.         ftoa(buf,v);
  356.         TraceS(s); TraceS(": "); TraceS(buf); TraceS(", "); TraceS(s2); TraceNL();
  357.     }
  358.    
  359.     //instruction       //variables
  360.     define NONE =   0;  //NONE
  361.     define WARP     =   1;  //dmap,screen
  362.     define POS  =   2;  //x,y
  363.     define MOVEX    =   3;  //pixels (+/-)
  364.     define MOVEY    =   4;  //pixels (+/-)
  365.     define REFILLHP =   5;  //aNONE
  366.     define REFILLMP =   6;  //NONE
  367.     define REFILLCTR =  7;  //counter
  368.     define MAXHP    =   8;  //amount
  369.     define MAXMP    =   9;  //amount
  370.     define MAXCTR   =   10; //counter, amount
  371.    
  372.     define INVINCIBLE =     11; //(BOOL) on / off
  373.     define LINKITEM =   12; //item, (BOOL), on / off
  374.     define SAVE =       13; //item, (BOOL), on / off
  375.     define CREATEITEM =     14; //item, (BOOL), on / off
  376.     define CREATENPC =  15; //item, (BOOL), on / off
  377.     define PALETTE =    16; //item, (BOOL), on / off
  378.     define MONOCHROME =     17; //item, (BOOL), on / off
  379.     define BOMBS =      18; //item, (BOOL), on / off
  380.     define MBOMBS =     19; //item, (BOOL), on / off
  381.     define ARROWS =     20; //item, (BOOL), on / off
  382.     define MARROWS =    21; //item, (BOOL), on / off
  383.     define KEYS =       22; //item, (BOOL), on / off
  384.     define LKEYS =      23; //item, (BOOL), on / off
  385.     define RUPEES =     24; //item, (BOOL), on / off
  386.     define MRUPEES =    25; //item, (BOOL), on / off
  387.     define LMAP =       26; //level map, level id, true|false
  388.     define LBOSSKEY =   27; //level map, level id, true|false
  389.     define BIGHITBOX =  28; //level map, level id, true|false
  390.     define LINKDIAGONAL =   29; //level map, level id, true|false
  391.     define LTRIFORCE =  30; //level map, level id, true|false
  392.     define LCOMPASS =   31; //level map, level id, true|false
  393.     define RUNFFCSCRIPTID = 32;
  394.     define SETFFSCRIPT =    33;
  395.     define SETFFDATA =  34;
  396.    
  397.    
  398.    
  399.    
  400.     int num_instruction_params(int instr)
  401.     {
  402.         switch(instr)
  403.         {
  404.             //instruction       //variables
  405.             case NONE: return 0;
  406.             case WARP: return 2;    //dmap,screen
  407.             case POS: return 2;     //x,y
  408.             case MOVEX: return 1;   //pixels (+/-)
  409.             case MOVEY: return 1;   //pixels (+/-)
  410.             case REFILLHP: return 0;    //aNONE
  411.             case REFILLMP: return 0;    //NONE
  412.             case REFILLCTR: return 1;   //counter
  413.             case MAXHP: return 1;   //amount
  414.             case MAXMP: return 1;   //amount
  415.             case MAXCTR: return 2;  //counter, amount
  416.            
  417.             case INVINCIBLE: return 1;  //(BOOL) on / off
  418.             case LINKITEM: return 2;    //item, (BOOL), on / off
  419.             case SAVE: return 0;    //item, (BOOL), on / off
  420.             case CREATEITEM: return 3;  //item, (BOOL), on / off
  421.             case CREATENPC: return 3;   //item, (BOOL), on / off
  422.             case PALETTE: return 2; //item, (BOOL), on / off
  423.             case MONOCHROME: return 1;  //item, (BOOL), on / off
  424.            
  425.             case BOMBS: return 1;
  426.             case MBOMBS: return 1;
  427.             case ARROWS: return 1;
  428.             case MARROWS: return 1;
  429.             case KEYS: return 1;
  430.             case LKEYS: return 2; //level, number
  431.             case RUPEES: return 1;
  432.             case MRUPEES: return 1;
  433.             case LMAP: return 2;    //level map, level id, true|false
  434.             case LBOSSKEY: return 2;    //level bosskey, level id, true|false
  435.             case LTRIFORCE: return 2;   //level bosskey, level id, true|false
  436.             case LCOMPASS: return 2;    //level bosskey, level id, true|false
  437.             case BIGHITBOX: return 1;   //true|false
  438.             case LINKDIAGONAL: return 1;    //true|false
  439.             case RUNFFCSCRIPTID: return 1;
  440.             case SETFFSCRIPT: return 2;
  441.             case SETFFDATA: return 2;
  442.    
  443.             default:
  444.             {
  445.                
  446.                 TraceError("Invalid instruction passed to stack",instr);
  447.                 clearbuffer();
  448.                 return 0;
  449.             }
  450.         }
  451.     }
  452.    
  453.    
  454.    
  455.     int match_instruction(int token)
  456.     {
  457.         TraceNL(); TraceS("Input token into match_instruction is: "); TraceS(token); TraceNL();
  458.        
  459.         TraceNL(); TraceErrorS("match_instruction() token is: ",token); TraceNL();
  460.         TraceNL(); TraceError("Matching string with strcmp to 'w': ", strcmp(token,"w")); TraceNL();
  461.        
  462.         /* ONE WAY TO DO THIS. I did this with individual characters, and switches, to minimise the checks down
  463.         to the absolute minimum. -Z
  464.        
  465.         You could add specific instructions this way, if you wish.
  466.        
  467.         if ( !(strcmp(token,"w") ) ) TraceErrorS("Token in match_instruction() matched to WARP. Token: ", token);
  468.         if ( !(strcmp(token,"W") ) ) TraceErrorS("Token in match_instruction() matched to WARP. Token: ", token);
  469.         if ( !(strcmp(token,"p") ) ) TraceErrorS("Token in match_instruction() matched to POS. Token: ", token);
  470.         if ( !(strcmp(token,"P") ) ) TraceErrorS("Token in match_instruction() matched to POS. Token: ", token);
  471.         if ( !(strcmp(token,"rh") ) ) TraceErrorS("Token in match_instruction() matched to REFILLHP. Token: ", token);
  472.         if ( !(strcmp(token,"RH") ) ) TraceErrorS("Token in match_instruction() matched to REFILLHP. Token: ", token);
  473.         if ( !(strcmp(token,"Rh") ) ) TraceErrorS("Token in match_instruction() matched to REFILLHP. Token: ", token);
  474.         if ( !(strcmp(token,"rH") ) ) TraceErrorS("Token in match_instruction() matched to REFILLHP. Token: ", token);
  475.         */
  476.        
  477.         switch(token[0])
  478.         {
  479.             //A
  480.             case 'a':
  481.             case 'A':
  482.                 return ARROWS;
  483.             //B
  484.             case 'b':
  485.             case 'B':
  486.             {
  487.                 return BOMBS;
  488.                 /*
  489.                 switch(token[1])
  490.                 {
  491.                     case 'i':
  492.                     case 'I':
  493.                         return BIGHITBOX;
  494.                     case 'o':
  495.                     case 'O':
  496.                         return BOMBS;
  497.                     default: TraceErrorS("match_instruction(TOKEN) could not evaluate the instruction:",token); clearbuffer(); return 0;
  498.                 }
  499.                 */
  500.             }
  501.             case 'c':
  502.             case 'C':
  503.             {
  504.                 switch(token[1])
  505.                 {
  506.                     case 'r':
  507.                     case 'R':
  508.                     {
  509.                         switch(token[2])
  510.                         {
  511.                             case 'i':
  512.                             case 'I':
  513.                             {
  514.                                 TraceNL(); TraceS("instr() found token 'cri'"); TraceNL(); return CREATEITEM;
  515.                             }
  516.                            
  517.                             case 'n':
  518.                             case 'N':
  519.                             {
  520.                                 TraceNL(); TraceS("instr() found token 'cri'"); TraceNL(); return CREATENPC;
  521.                             }
  522.                
  523.                             default: TraceErrorS("match_instruction(TOKEN) could not evaluate the instruction:",token); clearbuffer(); return 0;
  524.                         }
  525.                     }
  526.                     default: TraceErrorS("match_instruction(TOKEN) could not evaluate the instruction:",token); clearbuffer(); return 0;
  527.                 }
  528.                 break;
  529.             }
  530.             //D
  531.             case 'd':
  532.             case 'D':
  533.                 return LINKDIAGONAL;
  534.             //E
  535.             //F
  536.             case 'f':
  537.             case 'F':
  538.             {
  539.                 switch(token[1])
  540.                 {
  541.                     case 'd':
  542.                     case 'D':
  543.                         return SETFFDATA;
  544.                     case 'S':
  545.                     case 's':
  546.                         return SETFFSCRIPT;
  547.                     default: TraceErrorS("match_instruction(TOKEN) could not evaluate the instruction:",token); clearbuffer(); return 0;
  548.                 }
  549.             }
  550.             //G
  551.             //H
  552.             case 'h':
  553.             case 'H':
  554.                 return BIGHITBOX;
  555.             //I
  556.             case 'i':
  557.             case 'I':
  558.             {
  559.                 switch(token[1])
  560.                 {
  561.                     case 'n':
  562.                     case 'N':
  563.                         return INVINCIBLE;
  564.                     case 't':
  565.                     case 'T':
  566.                         return LINKITEM;
  567.                     default: TraceErrorS("match_instruction(TOKEN) could not evaluate the instruction:",token); clearbuffer(); return 0;
  568.                 }
  569.                 break;
  570.             }
  571.             //J
  572.             //K
  573.             case 'k':
  574.             case 'K':
  575.                 return KEYS;
  576.             //L
  577.             case 'l':
  578.             case 'L':
  579.             {
  580.                 switch(token[1])
  581.                 {
  582.                     case 'b':
  583.                     case 'B':
  584.                         return LBOSSKEY;
  585.                     case 'c':
  586.                     case 'C':
  587.                         return LCOMPASS;
  588.                     case 'K':
  589.                     case 'k':
  590.                         return LKEYS;
  591.                     case 'M':
  592.                     case 'm':
  593.                         return LMAP;
  594.                     case 't':
  595.                     case 'T':
  596.                         return LTRIFORCE;
  597.                     default: TraceErrorS("match_instruction(TOKEN) could not evaluate the instruction:",token); clearbuffer(); return 0;
  598.                 }
  599.                
  600.             }
  601.             //M
  602.             case 'm':
  603.             case 'M':
  604.             {
  605.                 switch(token[1])
  606.                 {
  607.                     case 'x':
  608.                     case 'X':
  609.                         TraceNL(); TraceS("instr() found token 'mx'"); return MOVEX;
  610.                     case 'y':
  611.                     case 'Y':
  612.                         TraceNL(); TraceS("instr() found token 'my'"); return MOVEY;
  613.                     case 'h':
  614.                     case 'H':
  615.                         return MAXHP;
  616.                     case 'm':
  617.                     case 'M':
  618.                         return MAXMP;
  619.                     case 'c':
  620.                     case 'C':
  621.                         return MAXCTR;
  622.                     case 'o':
  623.                     case 'O':
  624.                         return MONOCHROME;
  625.                     case 'b':
  626.                     case 'B':
  627.                         return MBOMBS;
  628.                    
  629.                     case 'a':
  630.                     case 'A':
  631.                         return MARROWS;
  632.                     case 'R':
  633.                     case 'r':
  634.                         return MRUPEES;
  635.                    
  636.                     default: TraceErrorS("match_instruction(TOKEN) could not evaluate the instruction:",token); clearbuffer(); return 0;
  637.                 }
  638.                 break;
  639.             }
  640.            
  641.             //P
  642.             case 'p':
  643.             case 'P':
  644.             {
  645.                 switch(token[1])
  646.                 {
  647.                     case 'o':
  648.                     case 'O':
  649.                         TraceNL(); TraceS("instr() found token 'p'"); TraceNL(); return POS;
  650.                     case 'a':
  651.                     case 'A':
  652.                         TraceNL(); TraceS("instr() found token 'p'"); TraceNL(); return PALETTE;
  653.                     default: TraceErrorS("match_instruction(TOKEN) could not evaluate the instruction:",token); clearbuffer(); return 0;
  654.                 }
  655.                 break;
  656.             }
  657.             //Q
  658.             //R
  659.             case 'r':
  660.             case 'R':
  661.             {
  662.                 switch(token[1])
  663.                 {
  664.                     case NULL:
  665.                         return RUPEES;
  666.                     case 'h':
  667.                     case 'H':
  668.                         return REFILLHP;
  669.                     case 'm':
  670.                     case 'M':
  671.                         return REFILLMP;
  672.                     case 'c':
  673.                     case 'C':
  674.                         return REFILLCTR;
  675.                     case 'U':
  676.                     case 'u':
  677.                     {
  678.                         switch(token[2])
  679.                         {
  680.                             case NULL:
  681.                                 return RUPEES;
  682.                             case 'n':
  683.                             case 'N':
  684.                                 return RUNFFCSCRIPTID;
  685.                             default: TraceErrorS("match_instruction(TOKEN) could not evaluate the instruction:",token); clearbuffer(); return 0;
  686.                         }
  687.                     }
  688.                     default: TraceErrorS("match_instruction(TOKEN) could not evaluate the instruction:",token); clearbuffer(); return 0;
  689.                 }
  690.                 break;
  691.             }
  692.             //S
  693.             case 's':
  694.             case 'S':
  695.             {
  696.                 switch(token[1])
  697.                 {
  698.                     case 'a':
  699.                     case 'A':
  700.                     case 'V':
  701.                     case 'v':
  702.                     {
  703.                         TraceNL(); TraceS("instr() found token 'save'"); return SAVE;
  704.                     }
  705.                     default: TraceErrorS("match_instruction(TOKEN) could not evaluate the instruction:",token); clearbuffer(); return 0;
  706.                 }
  707.                 break;
  708.             }
  709.             //T
  710.             //U
  711.             //V
  712.             //W
  713.             case 'w':
  714.             case 'W':
  715.                 TraceNL(); TraceS("instr() found token 'w'"); TraceNL(); return WARP;
  716.            
  717.             default: TraceErrorS("match_instruction(TOKEN) could not evaluate the instruction:",token); clearbuffer(); return 0;
  718.         }
  719.        
  720.         //if ( strcmp(token,"w") == 0) { TraceNL(); TraceS("instr() found token 'w'"); return WARP; }
  721.         //else if ( strcmp(token,"p") == 0) { TraceNL(); TraceS("instr() found token 'p'"); return POS; }
  722.         //else if ( strcmp(token,"mx") == 0) { TraceNL(); TraceS("instr() found token 'mx'"); return MOVEX; }
  723.         //else if ( strcmp(token,"my") == 0) return MOVEY;
  724.         //else if ( strcmp(token,"rh") == 0) return REFILLHP;
  725.         //else if ( strcmp(token,"rm") == 0) return REFILLMP;
  726.         //else if ( strcmp(token,"rc") == 0) return REFILLCTR;
  727.         //else if ( strcmp(token,"mh") == 0) return MAXHP;
  728.         //else if ( strcmp(token,"mm") == 0) return MAXMP;
  729.         //else if ( strcmp(token,"mc") == 0) return MAXCTR;
  730.         //else if ( strcmp(token,"inv") == 0) return INVINCIBLE;
  731.         //else// if ( strcmp(token,"itm") == 0) return LINKITEM;
  732.         //else
  733.         //{
  734.         //  TraceErrorS("match_instruction(TOKEN) could not evaluate the instruction:",token);
  735.         //  return 0;
  736.         //}
  737.     }
  738.    
  739.     void clearbuffer()
  740.     {
  741.         for ( int q = 0; q < BUFFER_LENGTH; ++q ) debug_buffer[q] = 0;
  742.     }
  743.     int read(int str)
  744.     {
  745.         //debug
  746.         TraceNL(); TraceS("Starting read() with an initial buffer of: "); TraceS(str); TraceNL();
  747.         int token[16]; int input_string_pos;
  748.         int e; int token_pos = 0; int current_param;
  749.         for ( input_string_pos = 0; input_string_pos < MAX_TOKEN_LENGTH; ++input_string_pos )
  750.         {
  751.             if (str[input_string_pos] == ',' ) { ++input_string_pos; break; }
  752.             if (str[input_string_pos] == NULL ) break;
  753.            
  754.             token[token_pos] = str[input_string_pos];
  755.             ++token_pos;
  756.            
  757.            
  758.             //debug
  759.            
  760.             //++input_string_pos; //skip the comma now. If there are no params, we'll be on NULL.
  761.         }
  762.         //debug
  763.         TraceNL(); TraceS("read() token: "); TraceS(token); TraceNL();
  764.        
  765.         //put the instruction onto the stack.
  766.         //Right now, we are only allowing one instruction at a time.
  767.         //This allows for future expansion.
  768.         stack[SP] = match_instruction(token);
  769.         TraceNL(); TraceS("SP is: "); Trace(stack[SP]); TraceNL();
  770.         int num_params = num_instruction_params(stack[SP]);
  771.         TraceNL(); TraceS("Number of expected params "); Trace(num_params); TraceNL();
  772.        
  773.         if ( num_params )
  774.         {
  775.             if ( str[input_string_pos] == NULL )
  776.             {
  777.                 //no params.
  778.                 TraceErrorS("Input string is missing params. Token was:", token);
  779.                 return 0;
  780.             }
  781.         }
  782.        
  783.         ++SP; //get the stack ready for the next instruction.
  784.         //push the variables onto the stack.
  785.         while ( current_param < num_params )  //repeat this until we are out of params
  786.             //NOT a Do loop, because some instructions have no params!
  787.         {
  788.             for ( token_pos = MAX_TOKEN_LENGTH-1; token_pos >= 0; --token_pos ) token[token_pos] = 0; //clear the token
  789.            
  790.             //copy over new token
  791.             token_pos = 0;
  792.             TraceNL(); TraceS("read() is seeking for params."); TraceNL();
  793.             int temp_max = input_string_pos+MAX_TOKEN_LENGTH;
  794.             for ( ; input_string_pos < temp_max; ++input_string_pos )
  795.             {
  796.                 if (str[input_string_pos] == ',' ) { ++input_string_pos; break; }
  797.                 if (str[input_string_pos] == NULL ) break;
  798.                
  799.                 token[token_pos] = str[input_string_pos];
  800.                 ++token_pos;
  801.                
  802.                
  803.                 //debug
  804.                
  805.                 //++input_string_pos; //skip the comma now. If there are no params, we'll be on NULL.
  806.             }
  807.             /*
  808.             while( str[input_string_pos] != ',' || str[input_string_pos] != NULL ) //|| current_param >= num_params ) //token terminates on a comma, or the end of the string
  809.             {
  810.                 token[token_pos] = str[input_string_pos]; //store the variable into a new token
  811.                 ++token_pos;
  812.             }
  813.             */
  814.             TraceNL(); TraceS("read() is getting tval"); TraceNL();
  815.             int tval; //value of the param
  816.             //first check the boolean types:
  817.             TraceNL(); TraceS("The arg token is: "); TraceS(token); TraceNL();
  818.             if ( !isNumber(token[0]) )
  819.             {
  820.                 switch(token[0])
  821.                 {
  822.                    
  823.                     case '-': tval = atof(token); break;
  824.                    
  825.                     case 't':
  826.                     case 'T':
  827.                         tval = 1; break;
  828.                     case 'f':
  829.                     case 'F':
  830.                         tval = 0; break;
  831.                    
  832.                     case 'l':
  833.                     case 'L':
  834.                     {
  835.                         switch(token[1])
  836.                         {
  837.                             case 'x':
  838.                             case 'X':
  839.                             {
  840.                                 TraceError("tval set to Link->X: ", Link->X);
  841.                                 tval = Link->X; break;
  842.                             }
  843.                             case 'y':
  844.                             case 'Y':
  845.                             {
  846.                                 TraceError("tval set to Link->Y: ", Link->Y);
  847.                                 tval = Link->Y; break;
  848.                             }
  849.                             default: TraceErrorS("Invalid token passed as an argument for instruction: ", token); tval = 0; break;
  850.                         }
  851.                         break;
  852.                     }
  853.                    
  854.                     default: TraceErrorS("Invalid token passed as an argument for instruction: ", token); tval = 0; break;
  855.                 }
  856.                 //if ( strcmp(token,"true") ) tval = 1;
  857.                 //else if ( strcmp(token,"T") ) tval = 1;
  858.                 //else if ( strcmp(token,"false") ) tval = 0;
  859.                 //else if ( strcmp(token,"F") ) tval = 0;
  860.                
  861.             }
  862.             else //literals
  863.             {
  864.                
  865.                 tval = atof(token);
  866.                 TraceNL(); TraceS("found a literal var of: "); Trace(tval); TraceNL();
  867.                
  868.             }
  869.             //push the token value onto the stack
  870.             stack[SP] = tval;
  871.        
  872.             //now out stack looks like:
  873.            
  874.             //: PARAMn where n is the loop iteration
  875.             //: PARAMn where n is the loop iteration
  876.             //: PARAMn where n is the loop iteration
  877.             //: INSTRUCTION
  878.            
  879.             ++SP; //this is why the stack size must be +1 larger than the3 total number of instructions and
  880.             //params that it can hold.
  881.             ++current_param;
  882.            
  883.         } //repeat this until we are out of params
  884.         return 1;
  885.        
  886.     }
  887.    
  888.     //void getVarValue(int str)
  889.     //{
  890.     //  variables[VP] = atof(str);
  891.     //  ++VP;
  892.     //}
  893.    
  894.     void execute()
  895.     {
  896.        
  897.         TraceNL(); TraceS("Stack Trace");
  898.         for ( int q = SizeOfArray(stack)-1; q >= 0; --q )
  899.         {
  900.             TraceNL(); Trace(stack[q]);
  901.         }
  902.        
  903.        
  904.         TraceNL(); TraceS("Running execute()"); TraceNL();
  905.         int reg_ptr = 0; //read the stack starting here, until we reach TOP.
  906.         int args[MAX_ARGS];
  907.         //evaluate the instruction:
  908.         int instr = stack[reg_ptr];
  909.         ++reg_ptr;
  910.         int current_arg = 0;
  911.         int num_of_params = num_instruction_params(instr);
  912.         TraceNL(); TraceS("execute() expects number of args to be: "); Trace(num_of_params); TraceNL();
  913.         for ( ; num_of_params > 0; --num_of_params )
  914.         {
  915.             args[current_arg] = stack[reg_ptr];
  916.             TraceNL(); TraceS("Putting an arg on the heap. Arg value: "); Trace(args[current_arg]); TraceNL();
  917.             ++current_arg;
  918.             ++reg_ptr;
  919.            
  920.         }
  921.        
  922.         TraceNL(); TraceS("execute believes that the present instruction is: "); Trace(instr); TraceNL();
  923.         TraceNL(); TraceS("args[0] is: "); Trace(args[0]); TraceNL();
  924.         TraceNL(); TraceS("args[1] is: "); Trace(args[1]); TraceNL();
  925.        
  926.         switch(instr)
  927.         {
  928.             case NONE:
  929.                 TraceError("STACK INSTRUCTION IS INVALID: ", instr);
  930.                 Game->TypingMode = false;
  931.                 clearbuffer();
  932.                 break;
  933.             case WARP:
  934.             {
  935.                 Link->Warp(args[0],args[1]);
  936.                 if ( log_actions ) TraceError("Cheat System Warped Link to dmap,screen:",args[0],args[1]);
  937.                 break;
  938.             }
  939.             case POS:
  940.             {
  941.                 Link->X = args[0];
  942.                 Link->Y = args[1];
  943.                 if ( log_actions ) TraceError("Cheat System repositioned Link to X,Y:",args[0],args[1]);
  944.                 break;
  945.             }
  946.            
  947.             case MOVEX:
  948.             {
  949.                 Link->X += args[0];
  950.                 if ( log_actions ) TraceError("Cheat system moved Link on his X axis by: ", args[0]);
  951.                 break;
  952.             }
  953.             case MOVEY:
  954.             {
  955.                 Link->Y += args[0];
  956.                 if ( log_actions ) TraceError("Cheat system moved Link on his Y axis by", args[0]);
  957.                 break;
  958.             }
  959.             case REFILLHP:
  960.             {
  961.                 Link->HP =  Link->MaxHP;
  962.                 if ( log_actions ) TraceError("Cheat system refilled Link's HP to", Link->MaxHP);
  963.                 break;
  964.             }
  965.             case REFILLMP:
  966.             {
  967.                 Link->MP =  Link->MaxMP;
  968.                 if ( log_actions ) TraceError("Cheat system refilled Link's MP to", Link->MaxHP);
  969.                 break;
  970.             }
  971.             case REFILLCTR:
  972.             {
  973.                 Game->Counter[args[0]] =  Game->MCounter[args[0]];
  974.                 if ( log_actions ) TraceError("Cheat system refilled Counter", args[0]);
  975.                 break;
  976.             }
  977.             case MAXHP:
  978.             {
  979.                 Game->MCounter[CR_LIFE] = args[0];
  980.                 if ( log_actions ) TraceError("Cheat system set Link's Max HP to:",args[0]);
  981.                 break;
  982.             }
  983.             case MAXMP:
  984.             {
  985.                 Game->MCounter[CR_MAGIC] = args[0];
  986.                 if ( log_actions ) TraceError("Cheat system set Link's Max MP to:",args[0]);
  987.                 break;
  988.             }
  989.             case MAXCTR:
  990.             {
  991.                 Game->Counter[args[0]] = args[1];
  992.                 if ( log_actions ) TraceError("Cheat system refilled Counter (id, amount):",args[0],args[1]);
  993.                 break;
  994.             }
  995.            
  996.             case INVINCIBLE:
  997.             {
  998.                 if ( args[0] )
  999.                 {
  1000.                     Link->Invisible = true;
  1001.                     if ( log_actions ) TraceErrorS("Cheat system set Link's Invisibility state to ","true");
  1002.                     break;
  1003.                 }
  1004.                 else
  1005.                 {
  1006.                     Link->Invisible = false;
  1007.                     if ( log_actions ) TraceErrorS("Cheat system set Link's Invisibility state to ","false");
  1008.                     break;
  1009.                    
  1010.                 }
  1011.                
  1012.             }
  1013.             case LINKITEM:
  1014.             {
  1015.                 itemdata id = Game->LoadItemData(args[0]);
  1016.                 if ( id->Keep )
  1017.                 {
  1018.                     if ( args[1] )
  1019.                     {
  1020.                        
  1021.                         Link->Item[args[0]] = true;
  1022.                         if ( log_actions ) TraceErrorS("Cheat system set Link's Inventory Item to (item, state)","true");
  1023.                         break;
  1024.                     }
  1025.                     else
  1026.                     {
  1027.                         Link->Item[args[0]] = false;
  1028.                         if ( log_actions ) TraceErrorS("Cheat system set Link's Inventory Item to (item, state)","false");
  1029.                         break;
  1030.                        
  1031.                     }
  1032.                 }
  1033.                 else break;
  1034.             }
  1035.             case SAVE:
  1036.             {
  1037.                 TraceNL(); TraceS("Cheat system is saving the game.");
  1038.                 clearbuffer();
  1039.                 Game->Save();
  1040.                 break;
  1041.             }
  1042.             case CREATEITEM:
  1043.             {
  1044.                 if ( log_actions ) TraceError("Cheat system is creating item ID: ", args[0]);
  1045.                 if ( log_actions ) TraceError("Cheat system is creating item at X Position: ", args[1]);
  1046.                 if ( log_actions ) TraceError("Cheat system is creating item at Y Position: ", args[2]);
  1047.                 item cci = Screen->CreateItem(args[0]);
  1048.                 cci->X = args[1];
  1049.                 cci->Y = args[2];
  1050.                 break;
  1051.             }
  1052.             case CREATENPC:
  1053.             {
  1054.                 if ( log_actions ) TraceError("Cheat system is creating npc ID: ", args[0]);
  1055.                 if ( log_actions ) TraceError("Cheat system is creating npc at X Position: ", args[1]);
  1056.                 if ( log_actions ) TraceError("Cheat system is creating npc at Y Position: ", args[2]);
  1057.                 npc ccn = Screen->CreateNPC(args[0]);
  1058.                 ccn->X = args[1];
  1059.                 ccn->Y = args[2];
  1060.                 break;
  1061.             }
  1062.             case PALETTE:
  1063.             {
  1064.                 if ( args[0] < 0 )
  1065.                 {
  1066.                     Game->DMapPalette[Game->GetCurDMap()] = args[1];
  1067.                 }
  1068.                 else Game->DMapPalette[args[0]] = args[1];
  1069.                 break;
  1070.             }
  1071.             case MONOCHROME:
  1072.             {
  1073.                 Graphics->Monochrome(args[0]); break;
  1074.             }
  1075.             case MBOMBS: Game->MCounter[CR_BOMBS] = args[0]; break;
  1076.             case BOMBS: Game->Counter[CR_BOMBS] = args[0]; break;
  1077.             case MARROWS: Game->MCounter[CR_ARROWS] = args[0]; break;
  1078.             case ARROWS: Game->Counter[CR_ARROWS] = args[0]; break;
  1079.             case KEYS: Game->Counter[CR_KEYS] = args[0]; break;
  1080.             case RUPEES: Game->Counter[CR_RUPEES] = args[0]; break;
  1081.             case MRUPEES: Game->MCounter[CR_RUPEES] = args[0]; break;
  1082.            
  1083.             case LKEYS: Game->LKeys[args[0]] = args[1]; break;
  1084.             case LINKDIAGONAL: Link->Diagonal = Cond(args[0],true,false); break;
  1085.             case BIGHITBOX: Link->BigHitbox = Cond(args[0],true,false); break;
  1086.            
  1087.             case LMAP:
  1088.             {
  1089.                 if ( args[1] ) //true
  1090.                 {  
  1091.                     Game->LItems[args[0]] |= LI_MAP;
  1092.                 }
  1093.                 else Game->LItems[args[0]] &= ~LI_MAP;
  1094.                 break;
  1095.             }
  1096.             case LBOSSKEY:
  1097.             {
  1098.                 if ( args[1] ) //true
  1099.                 {  
  1100.                     Game->LItems[args[0]] |= LI_BOSSKEY;
  1101.                 }
  1102.                 else Game->LItems[args[0]] &= ~LI_BOSSKEY;
  1103.                 break;
  1104.             }
  1105.             case LCOMPASS:
  1106.             {
  1107.                 if ( args[1] ) //true
  1108.                 {  
  1109.                     Game->LItems[args[0]] |= LI_COMPASS;
  1110.                 }
  1111.                 else Game->LItems[args[0]] &= ~LI_COMPASS;
  1112.                 break;
  1113.             }
  1114.             case LTRIFORCE:
  1115.             {
  1116.                 if ( args[1] ) //true
  1117.                 {  
  1118.                     Game->LItems[args[0]] |= LI_TRIFORCE;
  1119.                 }
  1120.                 else Game->LItems[args[0]] &= ~LI_TRIFORCE;
  1121.                 break;
  1122.             }
  1123.             case SETFFDATA:
  1124.             {
  1125.                 ffc f = Screen->LoadFFC(args[0]);
  1126.                 f->Data = args[1];
  1127.                 break;
  1128.             }
  1129.             case SETFFSCRIPT:
  1130.             {
  1131.                 ffc f = Screen->LoadFFC(args[0]);
  1132.                 f->Script = args[1];
  1133.                 break;
  1134.             }
  1135.             case RUNFFCSCRIPTID:
  1136.             {
  1137.                 ffc f; bool running;
  1138.                 for ( int q = 1; q < 33; ++q )
  1139.                 {  
  1140.                     f = Screen->LoadFFC(args[0]);
  1141.                     if ( !f->Script )
  1142.                     {
  1143.                         if ( !f->Data ) f->Data = INVISIBLE_COMBO;
  1144.                         f->Script = args[1];
  1145.                         running = true;
  1146.                         break;
  1147.                     }
  1148.                 }
  1149.                 if ( !running ) TraceError("Cheat system could not find a free ffc for command RUN. Try FS,id,scriptid instead.",NULL);
  1150.                 break;
  1151.             }
  1152.  
  1153.                
  1154.             default:
  1155.             {
  1156.                
  1157.                 TraceError("Invalid instruction passed to stack",instr);
  1158.                 break;
  1159.             }
  1160.            
  1161.            
  1162.         }
  1163.         ///-----later, we'll add this: //pop everything off of the stack
  1164.         //just wipe the stack for now, as we only support one command at this time
  1165.         for ( int q = 0; q < 3; ++q ) stack[q] = 0;
  1166.         SP = 0;
  1167.        
  1168.         //clear the main buffer, too!
  1169.         for ( int cl = 0; cl < BUFFER_LENGTH; ++cl ) debug_buffer[cl] = 0;
  1170.         Game->TypingMode = false; //insurance clear
  1171.         Link->PressStart = false;
  1172.         Link->InputStart = false;
  1173.        
  1174.        
  1175.     }
  1176.        
  1177.     void run()
  1178.     {
  1179.    
  1180.        
  1181.        
  1182.     }
  1183. }
  1184.  
  1185. global script test
  1186. {
  1187.     void run()
  1188.     {
  1189.         debugshell.SP = 0;
  1190.         debugshell.clearbuffer();
  1191.         while(1)
  1192.         {
  1193.             debugshell.process();
  1194.             Waitdraw();
  1195.             Waitframe();
  1196.         }
  1197.        
  1198.     }
  1199. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement