ZoriaRPG

Debug Cheat Shell (v1.9, Working)

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