Advertisement
DrBaldhead

TMNT_NES_TOUR_AI_KEYS_BETA

Jun 3rd, 2016
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.21 KB | None | 0 0
  1. -- This LUA script is intended for TMNT: Tournament fighters for NES.
  2. -- ---------------------------------------------------------------------------
  3.  
  4. -- This script tries to display the input data stored at the variables the game actually uses to determines the actions of the characters fighting. This includes the commands from AI or the CPU Player.
  5. -- The script displays keys as pressed from both tapping and holding. The difference in this matter might be implemented later.
  6.  
  7. local key_a = 128;
  8. local key_b = 64;
  9. local key_select = 32;
  10. local key_start = 16;
  11. local key_up = 8;
  12. local key_down = 4;
  13. local key_left = 2;
  14. local key_right = 1;
  15.  
  16. local p1tap = 0;
  17. local p2tap = 0;
  18. local p1hold = 0;
  19. local p2hold = 0;
  20.  
  21. local function draw_a(player_, iswhite)
  22. if iswhite then
  23. iswhite = "white";
  24. else
  25. iswhite = "black";
  26. end;
  27. if player_ == 1 then
  28. player = 65;
  29. else
  30. player = 235;
  31. end;
  32. gui.drawbox(player, 68, player + 5, 72, iswhite);
  33. end;
  34.  
  35. local function draw_b(player_, iswhite)
  36. if iswhite then
  37. iswhite = "white";
  38. else
  39. iswhite = "black";
  40. end;
  41. if player_ == 1 then
  42. player = 55;
  43. else
  44. player = 225;
  45. end;
  46. gui.drawbox(player, 68, player + 5, 72, iswhite);
  47. end;
  48.  
  49. local function draw_select(player_, iswhite)
  50. if iswhite then
  51. iswhite = "white";
  52. else
  53. iswhite = "black";
  54. end;
  55. if player_ == 1 then
  56. player = 35;
  57. else
  58. player = 215;
  59. end;
  60. gui.drawbox(player, 68, player + 5, 70, iswhite);
  61. end;
  62.  
  63. local function draw_start(player_, iswhite)
  64. if iswhite then
  65. iswhite = "white";
  66. else
  67. iswhite = "black";
  68. end;
  69. if player_ == 1 then
  70. player = 45;
  71. else
  72. player = 205;
  73. end;
  74. gui.drawbox(player, 68, player + 5, 70, iswhite);
  75. end;
  76.  
  77. local function draw_down(player_, iswhite)
  78. if iswhite then
  79. iswhite = "white";
  80. else
  81. iswhite = "black";
  82. end;
  83. if player_ == 1 then
  84. player = 20;
  85. else
  86. player = 190;
  87. end;
  88. gui.drawbox(player, 66, player + 3, 73, iswhite);
  89. end;
  90.  
  91. local function draw_up(player_, iswhite)
  92. if iswhite then
  93. iswhite = "white";
  94. else
  95. iswhite = "black";
  96. end;
  97. if player_ == 1 then
  98. player = 20;
  99. else
  100. player = 190;
  101. end;
  102. gui.drawbox(player, 53, player + 3, 60, iswhite);
  103. end;
  104.  
  105. local function draw_left(player_, iswhite)
  106. if iswhite then
  107. iswhite = "white";
  108. else
  109. iswhite = "black";
  110. end;
  111. if player_ == 1 then
  112. player = 10;
  113. else
  114. player = 180;
  115. end;
  116. gui.drawbox(player, 62, player + 7, 64, iswhite);
  117. end;
  118.  
  119. local function draw_right(player_, iswhite)
  120. if iswhite then
  121. iswhite = "white";
  122. else
  123. iswhite = "black";
  124. end;
  125. if player_ == 1 then
  126. player = 25;
  127. else
  128. player = 195;
  129. end;
  130. gui.drawbox(player, 62, player + 7, 64, iswhite);
  131. end;
  132.  
  133. while (true) do
  134. p1tap = memory.readbyte(0x008E);
  135. p2tap = memory.readbyte(0x008F);
  136. p1hold = memory.readbyte(0x0091);
  137. p2hold = memory.readbyte(0x0092);
  138.  
  139. draw_a(1, ((AND(p1tap, key_a) ~= 0) or (AND(p1hold, key_a) ~= 0)));
  140. draw_b(1, ((AND(p1tap, key_b) ~= 0) or (AND(p1hold, key_b) ~= 0)));
  141. draw_select(1, ((AND(p1tap, key_select) ~= 0) or (AND(p1hold, key_select) ~= 0)));
  142. draw_start(1, ((AND(p1tap, key_start) ~= 0) or (AND(p1hold, key_start) ~= 0)));
  143. draw_up(1, ((AND(p1tap, key_up) ~= 0) or (AND(p1hold, key_up) ~= 0)));
  144. draw_down(1, ((AND(p1tap, key_down) ~= 0) or (AND(p1hold, key_down) ~= 0)));
  145. draw_left(1, ((AND(p1tap, key_left) ~= 0) or (AND(p1hold, key_left) ~= 0)));
  146. draw_right(1, ((AND(p1tap, key_right) ~= 0) or (AND(p1hold, key_right) ~= 0)));
  147.  
  148. draw_a(2, ((AND(p2tap, key_a) ~= 0) or (AND(p2hold, key_a) ~= 0)));
  149. draw_b(2, ((AND(p2tap, key_b) ~= 0) or (AND(p2hold, key_b) ~= 0)));
  150. draw_select(2, ((AND(p2tap, key_select) ~= 0) or (AND(p2hold, key_select) ~= 0)));
  151. draw_start(2, ((AND(p2tap, key_start) ~= 0) or (AND(p2hold, key_start) ~= 0)));
  152. draw_up(2, ((AND(p2tap, key_up) ~= 0) or (AND(p2hold, key_up) ~= 0)));
  153. draw_down(2, ((AND(p2tap, key_down) ~= 0) or (AND(p2hold, key_down) ~= 0)));
  154. draw_left(2, ((AND(p2tap, key_left) ~= 0) or (AND(p2hold, key_left) ~= 0)));
  155. draw_right(2, ((AND(p2tap, key_right) ~= 0) or (AND(p2hold, key_right) ~= 0)));
  156.  
  157. FCEU.frameadvance();
  158. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement