Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --advanced version: http://pastebin.com/kLNXUxcy
- dynamic_memory_start = 0x2FB800
- dynamic_memory_end = 0x34F800
- dynamic_memory_len = dynamic_memory_end - dynamic_memory_start
- particle_table = 0x0B4378
- while true do
- addr = dynamic_memory_start
- gui.drawBox(0, 0, client.bufferwidth(), 50, 0xFF000000, 0xFF000000)
- used_memory = 0
- free_memory = 0
- used_count = 0
- free_count = 0
- 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) + 4 --not including the 0xC bytes for the header
- in_use = memory.read_u16_be(addr+0x8)
- id = memory.read_u16_be(addr+0xA)
- if in_use == 1 then
- used_memory = used_memory + 0xC + blocksize
- used_count = used_count + 1
- bgcolor = 0xFF00FF00
- elseif in_use == 0 then
- free_memory = free_memory + 0xC + blocksize
- free_count = free_count + 1
- bgcolor = 0xFFFF0000
- else
- bgcolor = 0xFFFFFFFF --impossible
- end
- gui.drawBox((addr-dynamic_memory_start)*client.bufferwidth()/dynamic_memory_len-1, 0,
- (addr+0xC+blocksize-dynamic_memory_start)*client.bufferwidth()/dynamic_memory_len, 50, 0x40000000, bgcolor)
- --print(string.format("addr:%X next_addr:%X blocksize:%X in_use:%X id:%X", addr, next_addr, blocksize, in_use, id))
- if next_addr ~= addr + 0xC + blocksize then
- break --shouldn't happen except on the last iteration, unless memory is corrupt.
- end
- addr = next_addr
- end
- gui.text(30, 50, string.format("Used Memory: %X (%d blocks)", used_memory, used_count))
- gui.text(30, 65, string.format("Free Memory: %X (%d blocks)", free_memory, free_count))
- particle_count = 0
- for i=0,0x5F do
- if memory.read_u32_be(particle_table + 4*i) > 0 then
- particle_count = particle_count + 1
- end
- end
- gui.text(30, 80, string.format("Particle count: %d", particle_count))
- emu.frameadvance()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement