Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function inject_old_y_tracker()
- -- storing the old_y used for the lap calculation in a variable that we can read at the end of the frame
- memory.write_u32_le(0x0C027C, 0x31EF0000) -- andi t7, 0x0 | clearing t7
- memory.write_u32_le(0x0C028C, 0x3C0F8007) -- lui t7, 0x8007 | t7 = 0x80070000
- memory.write_u32_le(0x0C0294, 0x35EF4900) -- ori t7, t7, 0x4900 | t7 = 0x80074900
- memory.write_u32_le(0x0C029C, 0x0012C880) -- sll t9, s2, 0x2 | t9 = 4 * player_id
- memory.write_u32_le(0x0C02A0, 0x00000000) -- nop | taking out the x > 0 from the logic
- memory.write_u32_le(0x0C02A4, 0x01F97820) -- add t7, t7, t9 | t7 = 0x80074900 + 4 * player_id
- memory.write_u32_le(0x0C02B0, 0x2858FE13) -- slti t8, v0, 0xFE13 | changing registers so we can save old_y
- memory.write_u32_le(0x0C02B4, 0x1700001D) -- bne t8, zero, 0x001d | changing registers so we can save old_y
- memory.write_u32_le(0x0C02B8, 0xADE20000) -- sw v0, 0x0(t7) | t7 <- old_y
- end
- local function read_pointer(address)
- x = memory.read_u32_le(address)
- if (x == 0) then
- return 0
- end
- return memory.read_u32_le(address) - 0x80000000
- end
- -- Variables
- player_pointer = 0x09D530
- y = 0
- x = 0
- old_y = 0
- last_y = 0
- even_frame = true
- i = 0
- while true do
- -- I'm always injecting the tracker every frame because it's less annoying when dealing with save states
- inject_old_y_tracker()
- -- Since Bash is a 30fps game, only gather data each 2 frames
- if even_frame then
- -- Read data from memory
- player_struct = read_pointer(player_pointer)
- x = memory.read_s32_le(player_struct + 0x10)
- y = memory.read_s32_le(player_struct + 0x18)
- old_y = memory.read_s32_le(0x074900)
- end
- -- If your old Y isn't the Y from the last frame, a mismatch happened
- if old_y ~= last_y then
- gui.text(2, 60, "Old Y mismatch", "yellow")
- end
- gui.text(2, 80, "Old y: " .. old_y, "white")
- gui.text(2, 100, "Y: " .. y, "white")
- -- Lap logic (lap skips happens because of old y mismatches due to collisions with A.Is)
- if x > 0 and old_y > -494 and y < -493 then
- gui.text(2, 120, "LAP COMPLETED" .. i, "green")
- if even_frame then
- i = i + 1
- end
- end
- gui.text(2, 140, "LAP #" .. i, "white")
- -- Only update the last_y in the odd frame
- if not even_frame then
- last_y = y
- end
- -- Change the parity of the frame
- even_frame = not even_frame
- emu.frameadvance()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement