Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local type_to_name = { -- {{{
- -- 0x00
- '..',
- 'Somar Blast',
- 'Fire Shot',
- 'Unused',
- 'Beam Hit',
- 'Boom',
- 'Wall Hit',
- 'Bomb',
- 'Door Debr',
- 'Arrow',
- '*Wall Arrow',
- 'Ice Shot',
- 'Sword Beam',
- 'Sword Spark',
- 'Unused',
- 'Unused',
- -- 0x10
- 'Unused',
- 'Ice Spread',
- 'Unused',
- '*Ice Sparkle',
- 'Unused',
- 'Jump Splash',
- 'Ham Stars',
- 'Shov Dirt',
- 'EtherFX',
- 'BombosFX',
- 'Torch/PowFX',
- 'Wall Sparks',
- 'QuakeFX',
- 'Bonk',
- 'BootDust',
- 'Hookshot',
- -- 0x20
- 'Bed Spread',
- 'Zzzzs',
- 'Got Item',
- 'Bun/Capoof',
- 'Grave Moving',
- '???',
- 'Sword Spark',
- 'Bird',
- 'Pond Item',
- 'Pend/crystal',
- 'Spin Spark',
- 'Spin Spark2',
- 'Som Block',
- '???',
- '???',
- 'Torch flame',
- -- 0x30
- 'Pre Byrna',
- 'Byrna Spark',
- 'Flame Blob',
- 'Expl Wall',
- 'SW Burn',
- 'MS Hurray',
- 'Flute Dig',
- 'WV Expl',
- 'Bird Flute',
- 'Som Plat Blast',
- 'SBomb Expl',
- 'Unused',
- '*Sword Spark',
- 'Item Splash',
- '3D Crystal',
- 'Bush Poof',
- -- 0x40
- 'Dwarf Trans',
- 'Water @ Wishing & Swamp',
- 'Wishing Rupee',
- 'GT Seal Broken',
- } -- }}}
- local TEXT_TOP = 70
- -- UTIL
- local function tohex(num)
- return string.format('%X', num)
- end
- local function call_for_each_bank(address, fn, ...)
- for i = 0x00, 0x1F do
- fn(bit.lshift(i, 16) + address, unpack(arg))
- end
- fn(0x7E0000 + address, unpack(arg))
- end
- -- ANCILLA
- local function get_ancillae()
- local ancillae = {}
- for i=0, 9 do
- local ancilla = {
- index = i,
- type = memory.readbyte(0x7E0C4A + i),
- x = bit.bor(memory.readbyte(0x7E0C04 + i), bit.lshift(memory.readbyte(0x7E0C18 + i), 8)),
- y = bit.bor(memory.readbyte(0x7E0BFA + i), bit.lshift(memory.readbyte(0x7E0C0E + i), 8)),
- }
- ancilla['name'] = type_to_name[ancilla['type'] + 1]
- table.insert(ancillae, ancilla)
- end
- return ancillae
- end
- local function get_camera()
- return {
- ['x'] = memory.readwordsigned(0xe2),
- ['y'] = memory.readwordsigned(0xe8),
- }
- end
- -- LOGIC
- local function draw_ancilla(ancilla, camera)
- local pos = ancilla['index']
- gui.text(6, TEXT_TOP + 8 + 8 * pos, tohex(ancilla['index']) .. ': '.. ancilla['name'])
- if ancilla['type'] > 0 then
- local x = ancilla['x'] - camera['x']
- local y = ancilla['y'] - camera['y']
- gui.text(x, y, tohex(ancilla['index']), 'red')
- end
- end
- local function iterate_ancillae()
- local camera = get_camera()
- local ancillae = get_ancillae()
- for i, ancilla in pairs(ancillae) do
- draw_ancilla(ancilla, camera)
- end
- local sidx = memory.readbyteunsigned(0x7E03C4)
- gui.text(6, TEXT_TOP - 8, tohex(memory.readbyte(0x7E0C5E)) .. ' ' ..
- tohex(memory.readbyte(0x7E0C5F)) .. ' ' ..
- tohex(memory.readbyte(0x7E0C60)) .. ' ' ..
- tohex(memory.readbyte(0x7E0C61)))
- gui.text(6, TEXT_TOP, 'I:' .. tohex(sidx) .. ' ' ..
- 'H:' .. tohex(memory.readbyte(0x7E039D)) .. ' ' ..
- 'E:' .. tohex(memory.readbyte(0x7E03A4)) .. ' ' ..
- 'D:' .. tohex(memory.readbyte(0x7E0C72)))
- for i = 0, 5 do
- local addr = 0x7E0C54 + i
- gui.text(6, TEXT_TOP + 8 + 8 * 10 + 8 * i, tohex(memory.readbyte(addr)))
- end
- end
- -- EVENTS
- function on_write(addr, size)
- if addr < 0x200000 then
- addr = bit.band(addr, 0xFFFF)
- addr = 0x7E0000 + addr
- end
- val = size == 1 and memory.readbyte(addr) or memory.readword(addr)
- local line = "[" .. tohex(memory.getregister("pb"), 2) .. ":" .. tohex(memory.getregister("pc"), 4) .. "] "
- .. tohex(addr, 6) .. "[" .. tostring(size) .. "] = " .. tohex(val, size == 1 and 2 or 4)
- .. (size == 1 and " | " or " | ") .. " F=" .. emu.framecount()
- print(line)
- end
- call_for_each_bank(0x0000, function (bank_only)
- memory.registerwrite(bank_only + 0xEE, 0x1, on_write)
- end)
- --[[
- local function addancilla()
- local y = bit.band(memory.getregister("y"), 0xFF)
- local a = bit.band(memory.getregister("a"), 0xFF)
- print('+ ancilla:', type_to_name[a+1], '(Y=' .. tohex(y) .. ', A=' .. tohex(a) .. ')')
- end
- memory.registerexecute(0x1cf537, addancilla)
- ]]
- local function write_ancilla(addr, size)
- if addr < 0x200000 then
- addr = bit.band(addr, 0xFFFF)
- addr = 0x7E0000 + addr
- end
- local slot = bit.band(addr, 0xFFFF) - 0x0C4A
- local val = size == 1 and memory.readbyte(addr) or memory.readword(addr)
- if val > 0 then
- print('+ slot[' .. tohex(slot) .. ']: ' .. type_to_name[val + 1] .. ' (' .. tohex(val) .. ')')
- else
- print('- slot[' .. tohex(slot) .. ']')
- end
- end
- call_for_each_bank(0x0000, function (bank_only)
- memory.registerwrite(bank_only + 0x0C4A, 0xA, write_ancilla)
- end)
- -- memory.writebyte(0x7E03A4, 0x0)
- -- memory.writebyte(0x7E0C4A + 4, 0x03)
- -- memory.writebyte(0x7E0C4A + 3, 0x03)
- -- memory.writebyte(0x7E0C4A + 2, 0x03)
- -- memory.writebyte(0x7E0C4A + 1, 0x03)
- while true do
- iterate_ancillae()
- snes9x.frameadvance()
- -- print('-- F: ' .. emu.framecount())
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement