Advertisement
Jimmie1717

lsnes: Toy Story (U)

Feb 4th, 2018
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.42 KB | None | 0 0
  1. -- Disney's Toy Story (Super NES)
  2. -- by Jimmie1717
  3. -- lsnes rr2-Beta23
  4. -- This will only work with the NTSC-U version of the game.
  5.  
  6. print("Disney's Toy Story (Super Nintendo Entertainment System)\nby Jimmie1717");
  7.  
  8. -- Globals
  9. readByte                        = memory.readbyte;
  10. readSByte                       = memory.readsbyte;
  11. readWord                        = memory.readword;
  12. readSWord                       = memory.readsword;
  13. readDWord                       = memory.readdword;
  14. readSDWord                      = memory.readsdword;
  15. writeByte                       = memory.writebyte;
  16. writeWord                       = memory.writeword;
  17. writeDWord                      = memory.writedword;
  18.  
  19. -- RAM Addresses
  20. local addrs                     = {
  21.     general                     = {
  22.         level                   = 0x7E001A,
  23.         bonus_stars             = {
  24.             total               = 0x7E0010,
  25.             level               = 0x7E000A
  26.         }
  27.     },
  28.     woody                       = {
  29.         position                = {
  30.             x                   = 0x7E1730,
  31.             y                   = 0x7E1734
  32.         },
  33.         velocity                = {
  34.             x                   = 0x7E1780,
  35.             y                   = 0x7E1784
  36.         },
  37.         state                   = 0x7E17B0,
  38.         lives                   = 0x7E001E,
  39.         health                  = 0x7E001C
  40.     },
  41.     screen                      = {
  42.         position                = {
  43.             x                   = 0x7E004A,
  44.             y                   = 0x7E004C
  45.         }
  46.     },
  47.     level_data                  = {
  48.         [12]                    = {
  49.             position            = {
  50.                 x               = 0x7E00BA,
  51.                 y               = 0x7E00BE
  52.             },
  53.             velocity            = 0x7E00C1
  54.         }
  55.     }
  56. };
  57.  
  58. -- Use these to define the base location of where text should appear.
  59. -- i.e. 0, 0 is the top left of the screen.
  60. local x         = 3;
  61. local y         = 0;
  62.  
  63. local inputs    = {"", "", "", "", "", "", "", "", "", "", "", ""};
  64. local inputn    = {"B", "Y", "s", "S", "U", "D", "L", "R", "A", "X", "l", "r"};
  65.  
  66. function on_input()
  67.    
  68.     for i = 1, 12, 1 do
  69.         if (input.get(0, (i - 1)) == 1) then
  70.             inputs[i] = inputn[i];
  71.         else
  72.             inputs[i] = "";
  73.         end
  74.     end
  75.    
  76. end
  77.  
  78. -- Core function, this is where the magic happens.
  79. function on_paint()
  80.  
  81.     -- Draw two sets of all the info
  82.     -- One is black and offset by 1 pixel both horizontal and vertical.
  83.     -- This makes it easier to read on any color background.
  84.     -- Order matters here as they are drawn in the order you specify.
  85.     drawInput(x + 1, y + 1, 0x00000000, 0xFF000000, inputs);
  86.     drawInput(x, y, 0x00FFFFFF, 0xFF000000, inputs);
  87.    
  88.     drawText(x + 1, y + 1, 0x00000000, 0xFF000000);
  89.     drawText(x, y, 0x00FFFFFF, 0xFF000000);
  90.  
  91. end
  92. gui.repaint(); -- Update the GUI asap.
  93.  
  94. function drawText(x, y, foreColor, backColor)
  95.    
  96.     -- Text
  97.     gui.text(x, y + 24, string.format("Level:"), foreColor, backColor);
  98.     gui.text(x, y + 36, string.format("Stars (l):"), foreColor, backColor);
  99.     gui.text(x, y + 48, string.format("Stars (t):"), foreColor, backColor);
  100.     gui.text(x, y + 72, string.format("Screen X:"), foreColor, backColor);
  101.     gui.text(x, y + 84, string.format("Screen Y:"), foreColor, backColor);
  102.     gui.text(x, y + 108, string.format("Woody X:"), foreColor, backColor);
  103.     gui.text(x, y + 120, string.format("Woody Y:"), foreColor, backColor);
  104.     gui.text(x, y + 132, string.format("Velocity:"), foreColor, backColor);
  105.    
  106.     -- Values
  107.     gui.text(x + 96, y + 24, string.format("%6d", (readWord(addrs.general.level) + 1)), foreColor, backColor);
  108.     gui.text(x + 96, y + 36, string.format("%6d", readWord(addrs.general.bonus_stars.level)), foreColor, backColor);
  109.     gui.text(x + 96, y + 48, string.format("%6d", readWord(addrs.general.bonus_stars.total)), foreColor, backColor);
  110.     gui.text(x + 96, y + 72, string.format("%6d", readWord(addrs.screen.position.x)), foreColor, backColor);
  111.     gui.text(x + 96, y + 84, string.format("%6d", readWord(addrs.screen.position.y)), foreColor, backColor);
  112.    
  113.     if (readWord(addrs.general.level) + 1 == 11) then
  114.         gui.text(x + 96, y + 108, string.format("%6d", readWord(addrs.level_data[12].position.x)), foreColor, backColor);
  115.         gui.text(x + 96, y + 120, string.format("%6d", readWord(addrs.level_data[12].position.y)), foreColor, backColor);
  116.         gui.text(x + 96, y + 132, string.format("%6d", readSByte(addrs.level_data[12].velocity)), foreColor, backColor);
  117.     else
  118.         gui.text(x + 96, y + 108, string.format("%6d", readWord(addrs.woody.position.x)), foreColor, backColor);
  119.         gui.text(x + 96, y + 120, string.format("%6d", readWord(addrs.woody.position.y)), foreColor, backColor);
  120.         gui.text(x + 96, y + 132, string.format("%3d,%2d", readSWord(addrs.woody.velocity.x), (readSWord(addrs.woody.velocity.y) * -1)), foreColor, backColor);
  121.     end
  122. end
  123.  
  124. function drawInput(x, y, foreColor, backColor, i)
  125.  
  126.     -- input:   U   D   L   R   s   S   Y   B   X   A   l   r
  127.     -- index:   5   6   7   8   3   4   2   1   10  9   11  12
  128.     gui.text(x, y, string.format("%1s%1s%1s%1s%1s%1s%1s%1s%1s%1s%1s%1s", i[5], i[6], i[7], i[8], i[3], i[4], i[2], i[1], i[10], i[9], i[11], i[12]), foreColor, backColor);
  129.  
  130. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement