Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- health_addr = 0x0214F7B2
- Hx_energy_addr = 0x0214F895
- money_addr = 0x0214F870
- lives_addr = 0x0214F86C
- pItem = "big health"
- nItem = "void"
- count = 0
- switch = 0
- ID = 3
- loop = {4, 9, 34, 3, 9, 4, 9, 0}
- loopC = {0, 0, 0, 0, 0, 0, 0, 0}
- loops = {}
- function writeHealth(amount)
- memory.writebyte(health_addr, amount)
- end
- function readHealth()
- return memory.readbyte(health_addr)
- end
- function writeEnergy(amount)
- memory.writebyte(Hx_energy_addr, amount)
- end
- function readEnergy()
- return memory.readbyte(Hx_energy_addr)
- end
- function writeMoney(amount)
- memory.writeword(money_addr, amount)
- end
- function readMoney()
- return memory.readword(money_addr)
- end
- function writeLives(amount)
- memory.writebyte(lives_addr, amount)
- end
- function readLives()
- return memory.readbyte(lives_addr)
- end
- function cheatRNG(value)
- memory.writedword(0x02108790, value)
- end
- function initValues()
- writeHealth(1)
- writeEnergy(0)
- writeMoney(0)
- writeLives(0)
- end
- function controlValues()
- local curHealth = readHealth()
- local curEnergy = readEnergy()
- local curMoney = readMoney()
- local curLives = readLives()
- local item = "Nothing"
- ID = 3
- if curHealth == 5 then
- item = "small health"
- ID = 2
- elseif curHealth > 5 then
- item = "big health"
- ID = 1
- end
- if curEnergy == 4 then
- item = "small energy"
- ID = 5
- elseif curEnergy > 4 then
- item = "big energy"
- ID = 4
- end
- if curMoney == 4 then
- item = "small money"
- ID = 7
- elseif curMoney > 4 then
- item = "big money"
- ID = 6
- end
- if curLives == 1 then
- item = "life up"
- ID = 8
- end
- if (item == pItem) then
- count = count + 1
- else
- switch = 1
- nItem = item
- end
- return item
- end
- function openLog(mode)
- return io.open("item_rng.log", mode)
- end
- function beginLog()
- local f = openLog("a")
- f:write("------------------\n")
- f:close()
- end
- function writeLine(text)
- local f = openLog("a")
- f:write(text, "\n")
- f:close()
- end
- -- Save states
- function save()
- local obj = savestate.create()
- savestate.save(obj)
- return obj
- end
- s = save()
- function load()
- savestate.load(s)
- end
- function input()
- joypad.set(1, { ['L'] = 1})
- end
- beginLog()
- local rngcheat = -1
- while true do
- load()
- initValues()
- cheatRNG(rngcheat)
- for i = 1, 1 do
- cheatRNG(rngcheat)
- emu.frameadvance()
- cheatRNG(rngcheat)
- end
- for i = 1, 22 do
- input()
- cheatRNG(rngcheat)
- emu.frameadvance()
- cheatRNG(rngcheat)
- end
- controlValues()
- if (switch == 1) then
- writeLine(count.. " ".. pItem)
- if (pItem == "big health") then
- ID = 1
- elseif (pItem == "small health") then
- ID = 2
- elseif (pItem == "Nothing") then
- ID = 3
- elseif (pItem == "big energy") then
- ID = 4
- elseif (pItem == "small energy") then
- ID = 5
- elseif (pItem == "big money") then
- ID = 6
- elseif (pItem == "small money") then
- ID = 7
- elseif (pItem == "life up") then
- ID = 8
- end
- loopC[ID] = count - loop[ID]
- pItem = nItem
- switch = 0
- count = 1
- if (nItem == "big health") then
- writeLine("")
- table.insert(loops, loopC)
- print(loopC)
- writeLine("")
- loopC = {0, 0, 0, 0, 0, 0, 0, 0}
- end
- end
- rngcheat = rngcheat + 1
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement