Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --simple version: http://pastebin.com/wEj2Bgxe
- romhash = gameinfo.getromhash()
- if romhash == "B9CCA3FF260B9FF427D981626B82F96DE73586D3" then --JAP
- dynamic_memory_start = 0x2FB800
- dynamic_memory_end = 0x34F800
- particle_table = 0x0B4378
- current_menu_pointer = 0x10D85C
- selected_menu_item = 0x10D808
- menu_code_pointer = 0x159400
- elseif romhash == "3837F44CDA784B466C9A2D99DF70D77C322B97A0" then --USA
- dynamic_memory_start = 0x2FB800
- dynamic_memory_end = 0x34F800
- particle_table = 0x0B4398
- current_menu_pointer = 0x10D69C
- selected_menu_item = 0x10D648
- menu_code_pointer = 0x1543C0
- else
- print(romhash)
- end
- UPDATE_EVERY_N_FRAMES = 1
- dynamic_memory_len = dynamic_memory_end - dynamic_memory_start
- event.onexit(function() gui.DrawNew("native") end)
- while true do
- if emu.framecount() % UPDATE_EVERY_N_FRAMES == 0 or client.ispaused() then
- gui.DrawNew("native") --coordinates are now based on screen pixels rather than game pixels, and stuff is not erased automatically each frame.
- particle_count = 0
- for i=0,0x5F do
- particle_ptr = memory.read_u32_be(particle_table + 4*i)
- if particle_ptr > 0 then
- particle_count = particle_count + 1
- end
- end
- gui.drawText(24, 80, string.format("Particle count: %d", particle_count))
- if true then
- addr = dynamic_memory_start
- gui.drawBox(0, 0, client.screenwidth(), 50, 0xFF000000, 0xFF000000)
- used_memory = 0
- free_memory = 0
- used_count = 0
- free_count = 0
- hack_all_blocks_except_last_to_in_use = input.get()["F"]
- dump_block_list = input.get()["G"]
- while addr >= dynamic_memory_start and addr < dynamic_memory_end do
- next_addr = memory.read_u32_be(addr) - 0x80000000
- blocksize = memory.read_u32_be(addr+0x4) --not including the 0x10 bytes for the header
- if hack_all_blocks_except_last_to_in_use and next_addr > addr then
- memory.write_u16_be(addr+0x8, 1)
- end
- in_use = memory.read_u16_be(addr+0x8)
- id = memory.read_u16_be(addr+0xA)
- unused = memory.read_u32_be(addr+0xC) --just padding to make pointers align to 0x10, apparently...?
- if in_use == 1 then
- used_memory = used_memory + 0x10 + blocksize
- used_count = used_count + 1
- bgcolor = 0xFF00FF00
- if blocksize == 0x330 then bgcolor = 0xFF0000FF end
- elseif in_use == 0 then
- free_memory = free_memory + 0x10 + blocksize
- free_count = free_count + 1
- bgcolor = 0xFFFF0000
- else
- bgcolor = 0xFFFFFFFF --impossible
- end
- gui.drawBox((addr-dynamic_memory_start)*client.screenwidth()/dynamic_memory_len-1, 0, (addr+0x10+blocksize-dynamic_memory_start)*client.screenwidth()/dynamic_memory_len+1, 50, 0x40000000, bgcolor)
- if dump_block_list then
- print(string.format("addr:%X next_addr:%X used:%X blocksize:%X id:%X", addr, next_addr, in_use, blocksize, id))
- end
- if next_addr ~= addr + 0x10 + blocksize then
- break --shouldn't happen except on the last iteration, unless memory is corrupt.
- end
- addr = next_addr
- end
- if hack_all_blocks_except_last_to_in_use then
- for addr2 = addr+0xC,dynamic_memory_end-4,4 do
- memory.write_u32_be(addr2, 0xDEADBEEF)
- end
- print("Filled last block with DEADBEEF, marked other blocks as used.")
- end
- gui.drawText(24, 50, string.format("Used Memory: %X (%d blocks)", used_memory, used_count))
- gui.drawText(24, 65, string.format("Free Memory: %X (%d blocks)", free_memory, free_count))
- end
- menu_code_block = memory.read_u32_be(menu_code_pointer)
- if menu_code_block > 0x80000000 then
- unknown = memory.read_u32_be(menu_code_block - 0x80000000)
- menu_code_1 = memory.read_u32_be(menu_code_block - 0x80000000 + 4)
- menu_code_2 = memory.read_u32_be(menu_code_block - 0x80000000 + 8)
- gui.drawText(24, 95, string.format("Menu Code: %X %X %X", unknown, menu_code_1, menu_code_2))
- end
- menu = memory.read_u32_be(current_menu_pointer)
- if menu > 0x80000000 then
- menu_icons = menu - 0x80000000
- menu_list_text = menu_icons + 33*4
- menu_values = menu_list_text + 33*4
- menu_enabled = menu_values + 33*4
- menu_extra_numbers = menu_enabled + 33*4 --price / upgrade icons
- menu_bottom_text = menu_extra_numbers + 33*4
- menu_info = menu_bottom_text + 33*4
- shape = memory.read_u32_be(menu_info)
- double_dip_text_modifier = memory.read_u32_be(menu_info+4)
- double_dip_count = memory.read_u32_be(menu_info+8)
- length = memory.read_u32_be(menu_info+12)
- item_selected_when_opened = memory.read_u32_be(menu_info+16)
- item_selected_when_closed = memory.read_u16_be(menu_info+20)
- selected = memory.read_s32_be(selected_menu_item)
- gui.drawText(24, 110, string.format("Menu Shape: %X Length: %X Location: %X Selected: %d", shape, length, menu_icons, selected))
- for i=-1,32 do
- if i >= length and i > 0 then break end
- color = 0xFFFFFFFF
- if i==selected then
- color = 0xFFFFFF00
- end
- icon = memory.read_u32_be(menu_icons + 4*i)
- list_text_group = memory.read_u16_be(menu_list_text + 4*i)
- list_text_value = memory.read_u16_be(menu_list_text+2 + 4*i)
- value = memory.read_u32_be(menu_values + 4*i)
- enabled = memory.read_u32_be(menu_enabled + 4*i)
- extra_number = memory.read_u32_be(menu_extra_numbers + 4*i)
- bottom_text_group = memory.read_u16_be(menu_bottom_text + 4*i)
- bottom_text_value = memory.read_u16_be(menu_bottom_text+2 + 4*i)
- gui.drawText(24, 140+15*i, string.format("%2d: Value=%X Icon=%X ListText=%X:%X Enabled=%X ExtraNum=%X BottomText=%X:%X", i, value, icon, list_text_group, list_text_value, enabled, extra_number, bottom_text_group, bottom_text_value), color)
- end
- end
- end
- emu.frameadvance()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement