Advertisement
Blazephlozard

frog game lua

Jun 22nd, 2020
1,421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.03 KB | None | 0 0
  1. local AddrXWrap     = 0x0642;
  2. local AddrXScreen   = 0x0658;
  3. local AddrXSub      = 0x062C;
  4. local AddrXSpd      = 0x06C6;
  5. local AddrXSpdSub   = 0x06B0;
  6. local AddrY         = 0x0684;
  7. local AddrYSub      = 0x066E;
  8. local AddrYSpd      = 0x06F2;
  9. local AddrYSpdSub   = 0x06DC;
  10.  
  11. PrevX = 0
  12. XDiff = 0
  13. XSubDiff = 0
  14.  
  15. gui.defaultPixelFont("fceux")
  16.  
  17. while true do
  18.     emu.frameadvance();
  19.     --Position
  20.     XWrap=memory.readbyte(AddrXWrap);
  21.     XScreen=memory.readbyte(AddrXScreen);
  22.     X=XScreen*256+XWrap;
  23.     X=string.format("%04u",X);
  24.    
  25.     XSub=memory.readbyte(AddrXSub);
  26.    
  27.     XDiff = (X + (XSub/256)) - PrevX;
  28.     PrevX = (X + (XSub/256));
  29.    
  30.     XSub=string.format("%03u",XSub/256*1000);
  31.    
  32.     if XWrap>=0x20 and XWrap<0x80 then
  33.         BoostColor="green";
  34.     else
  35.         BoostColor="red";
  36.     end;
  37.    
  38.     Y=memory.readbyte(AddrY);
  39.     Y=string.format("%03u",Y);
  40.     YSub=memory.readbyte(AddrYSub);
  41.     YSub=string.format("%03u",YSub/256*1000);
  42.     XWrap=string.format("%02x",XWrap);
  43.     gui.pixelText(1,9,X.."."..XSub,"white",0);
  44.     gui.pixelText(60,9,Y.."."..YSub,"white",0);
  45.     gui.pixelText(1,33,XWrap,BoostColor,0);
  46.    
  47.     --Speed
  48.     XSpd=memory.read_s8(AddrXSpd);
  49.     if XSpd>=0 then
  50.         XSpdTextX=19;
  51.     else
  52.         XSpdTextX=14;
  53.     end;
  54.     XSpdSub=memory.readbyte(AddrXSpdSub);
  55.     if XSpd<0 then
  56.         XSpdSub=256-XSpdSub;
  57.         if XSpdSub~=0 then
  58.             XSpd=XSpd+1;
  59.         end;
  60.         if XSpd==0 then
  61.             XSpd="-"..YSpd;
  62.         end;
  63.     end;
  64.     XSpdSub=string.format("%03u",XSpdSub/256*1000);
  65.     if XSpd==0 then
  66.         XSpdColor="red"
  67.     else
  68.         XSpdColor="white"
  69.     end;
  70.    
  71.     YSpd=memory.read_s8(AddrYSpd);
  72.     if YSpd>=0 then
  73.         YSpdTextX=62;
  74.     else
  75.         YSpdTextX=57;
  76.     end;
  77.     YSpdSub=memory.readbyte(AddrYSpdSub);
  78.     if YSpd<0 then
  79.         YSpdSub=256-YSpdSub;
  80.         if YSpdSub~=0 then
  81.             YSpd=YSpd+1;
  82.         end;
  83.         if YSpd==0 then
  84.             YSpd="-"..YSpd;
  85.         end;
  86.     end;
  87.     YSpdSub=string.format("%03u",YSpdSub/256*1000);
  88.     gui.pixelText(XSpdTextX,17,XSpd.."."..XSpdSub,XSpdColor,0);
  89.     gui.pixelText(YSpdTextX,17,YSpd.."."..YSpdSub,"white",0);
  90.    
  91.     gui.pixelText(XSpdTextX+1,26,string.format("%.3f",XDiff),"black",0);
  92.     gui.pixelText(XSpdTextX,25,string.format("%.3f",XDiff),XSpdColor,0);
  93.    
  94. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement