SHARE
TWEET

Kirby Tilt and Tumble lua

Blazephlozard Jun 30th, 2020 926 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. memory.usememorydomain("System Bus")
  2. AddrXBig        = 0xFFA5;
  3. AddrXSmall      = 0xFFA6;
  4. AddrXSub        = 0xFFA7;
  5. AddrXSpd        = 0xFFD2; --big endian 16
  6. AddrYBig        = 0xFFA8;
  7. AddrYSmall      = 0xFFA9;
  8. AddrYSub        = 0xFFAA;
  9. AddrYSpd        = 0xFFD4; --big endian 16
  10. AddrZBig        = 0xFFAB;
  11. AddrZSmall      = 0xFFAC;
  12. AddrZSub        = 0xFFAD;
  13. AddrZSpd        = 0xFFD6; --big endian 16
  14.  
  15. PrevX = 0
  16. XDiff = 0
  17. PrevY = 0
  18. YDiff = 0
  19. PrevZ = 0
  20. ZDiff = 0
  21.  
  22. XPosTable = {}
  23. YPosTable = {}
  24.  
  25. XColor = "white"
  26. XDiffColor = "white"
  27. XSpdColor = "white"
  28.  
  29. --gui.defaultPixelFont("gens")
  30. gui.defaultPixelFont("fceux")
  31.  
  32. while true do
  33.     emu.frameadvance();
  34.     --Position
  35.     XSmall=memory.readbyte(AddrXSmall);
  36.     XBig=memory.readbyte(AddrXBig);
  37.     X=XBig*256+XSmall;
  38.    
  39.     XSub=memory.readbyte(AddrXSub);
  40.     X = (X + (XSub/256))
  41.    
  42.     XDiff = X - PrevX;
  43.     PrevX = X;
  44.    
  45.     --in this game vertical travel is what needs to be compared, generally
  46.     --[[if (XPosTable[emu.framecount()] == null or XPosTable[emu.framecount()] == X) then
  47.         XPosTable[emu.framecount()] = X;
  48.         XColor = "white";
  49.     elseif (XPosTable[emu.framecount()] < X) then
  50.         XPosTable[emu.framecount()] = X;
  51.         XColor = "green";
  52.     else
  53.         XColor = "red";
  54.     end]]
  55.     --[[if XDiff>1.5 then
  56.         XDiffColor = "green"
  57.     elseif XDiff<1.5 then
  58.         XDiffColor = "red"
  59.     else
  60.         XDiffColor = "white"
  61.     end]]
  62.    
  63.     YSmall=memory.readbyte(AddrYSmall);
  64.     YBig=memory.readbyte(AddrYBig);
  65.     Y=YBig*256+YSmall;
  66.     YSub=memory.readbyte(AddrYSub);
  67.     Y = (Y + (YSub/256))
  68.    
  69.     YDiff = Y - PrevY;
  70.     PrevY = Y;
  71.    
  72.     if (YPosTable[emu.framecount()] == null or YPosTable[emu.framecount()] == Y) then
  73.         YPosTable[emu.framecount()] = Y;
  74.         YColor = "white";
  75.     elseif (YPosTable[emu.framecount()] > Y) then
  76.         YPosTable[emu.framecount()] = Y;
  77.         YColor = "green";
  78.     else
  79.         YColor = "red";
  80.     end
  81.    
  82.     -- negative 2 pixels per frame is the target speed
  83.     if YDiff<-2 then
  84.         YDiffColor = "green"
  85.     elseif YDiff>-2 then
  86.         YDiffColor = "red"
  87.     else
  88.         YDiffColor = "white"
  89.     end
  90.    
  91.     ZSmall=memory.readbyte(AddrZSmall);
  92.     ZBig=memory.readbyte(AddrZBig);
  93.     Z=ZBig*256+ZSmall;
  94.     ZSub=memory.readbyte(AddrZSub);
  95.     Z = (Z + (ZSub/256))
  96.    
  97.     ZDiff = Z - PrevZ;
  98.     PrevZ = Z;
  99.    
  100.     --the speed variables are not proving useful/accurate compared to diff
  101.     --Speed
  102.     --XSpd=memory.read_s16_be(AddrXSpd)/256;
  103.     --YSpd=memory.read_s16_be(AddrYSpd)/256;
  104.     --ZSpd=memory.read_s16_be(AddrZSpd)/256;
  105.    
  106.     gui.pixelText(3, 2, string.format("% 9.3f",X),XColor)
  107.     --gui.pixelText(10, 18, string.format("% 9.3f",XSpd),XSpdColor)
  108.     gui.pixelText(3, 11, string.format("% 9.3f",XDiff),XDiffColor)
  109.    
  110.     gui.pixelText(58, 2, string.format("% 9.3f",Y),YColor)
  111.     --gui.pixelText(65, 18, string.format("% 9.3f",YSpd))
  112.     gui.pixelText(58, 11, string.format("% 9.3f",YDiff),YDiffColor)
  113.    
  114.     gui.pixelText(113, 2, string.format("% 7.3f",Z))
  115.     --gui.pixelText(120, 18, string.format("% 9.3f",ZSpd))
  116.     gui.pixelText(113, 11, string.format("% 7.3f",ZDiff))
  117.  
  118.    
  119. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top