Advertisement
pigdevil2010

Untitled

Apr 27th, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.88 KB | None | 0 0
  1. -- By pigdevil2010 for using in this video:
  2. -- This script works in VBA-RR
  3.  
  4. n = {0x88d0, 0x8b40, 0x8ac0, 0x8a10, 0x8a40, 0x8b10} -- VRAM addresses of "Number" tile
  5.  
  6. curr = 0 -- First phone number in the list
  7. p = true
  8.  
  9. -- Converting numbers into VRAM address functions
  10.  
  11. function hexU(a)
  12.     i = math.floor(a / 16)
  13.     if i > 9 then return 0x8760 + i * 16
  14.     else return 0x8f60 + i * 16 end
  15. end
  16.  
  17. function hexL(a)
  18.     i = a % 16
  19.     if i > 9 then return 0x8760 + i * 16
  20.     else return 0x8f60 + i * 16 end
  21. end
  22.  
  23. -- Check if we're currently in Pokegear menu by adding every values from address 0x9000 to 0x95ff and compare with the checksum
  24.  
  25. function gear()
  26.     chk = 0
  27.     for i = 0x9000, 0x95fc, 4 do chk = chk + memory.readdword(i) end
  28.     return chk == 709077982679
  29. end
  30.  
  31. -- Draw a tile that stored in the given VRAM
  32.  
  33. function drawtile(vram, x, y)
  34.     for i = 0, 7, 1 do for j = 0, 7, 1 do
  35.         if bit.band(bit.rshift(memory.readbyte(vram + i * 2), 7 - j), 1) == 1 then
  36.             gui.pixel(x + j, y + i, "white")
  37.         end
  38.     end end
  39. end
  40.  
  41. -- Main function
  42.  
  43. for i = 0, 9, 1 do memory.writebyte(0xdc7c + i, i) end -- Make it write phone number 00 - 09 at the first time it run
  44.  
  45. function upd()
  46.     ge = gear()
  47.     if memory.readword(0xcf64) == 2 and ge then
  48.         for i = 1, 6, 1 do drawtile(n[i], 64 + i * 8, 8) end
  49.         drawtile(hexU(curr), 96, 16)
  50.         drawtile(hexL(curr), 104, 16)
  51.         drawtile(0x8e30, 112, 16)
  52.         if curr == 250 then
  53.             drawtile(0x8850, 120, 16)
  54.             drawtile(0x8850, 128, 16)
  55.         else
  56.             drawtile(hexU(curr + 9), 120, 16)
  57.             drawtile(hexL(curr + 9), 128, 16)
  58.         end
  59.     end
  60.     if memory.readword(0xcf64) == 3 and ge then
  61.         if p and curr < 250 then
  62.             curr = curr + 10
  63.             p = false
  64.             for i = 0, 9, 1 do
  65.                 t = curr + i
  66.                 if t > 255 then t = 0 end
  67.                 memory.writebyte(0xdc7c + i, t)
  68.             end
  69.         end
  70.     else p = true end
  71.     curr = memory.readbyte(0xdc7c)
  72. end
  73.  
  74. gui.register(upd) -- Make it update every frame
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement