Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Mario Paint for drawing tablets
- -- Use with Mesen emulator
- -- Written by IsoFrieze
- -- In emulator settings, set both controller ports to "None"
- -- Setting either as "Mouse" will not work properly
- -- You'll want to turn on the "Let me use my pen as a mouse
- -- in some desktop apps" option in windows for better results
- function updateMouse()
- local mouse = emu.getMouseState()
- emu.write16(0x4DC, mouse.x, emu.memType.snesWorkRam)
- emu.write16(0x4DE, mouse.y-6, emu.memType.snesWorkRam)
- emu.write(0x4C2, 1, emu.memType.snesWorkRam)
- end
- function getButtons()
- local mouse = emu.getMouseState()
- local buttons = 1
- if mouse.left then
- buttons = buttons + 0x40
- end
- if mouse.right then
- buttons = buttons + 0x80
- end
- return buttons
- end
- function hijackButtons()
- return getButtons()
- end
- function hijackButtonsAlt()
- local state = emu.getState()
- state["cpu.a"] = getButtons()
- emu.setState(state)
- end
- emu.addEventCallback(updateMouse, emu.eventType.frameStart)
- emu.addMemoryCallback(hijackButtons, emu.callbackType.read, 0x4218)
- emu.addMemoryCallback(hijackButtonsAlt, emu.callbackType.exec, 0x1DA31)
Advertisement
Add Comment
Please, Sign In to add comment