Dotsarecool

Mario Paint Tablet Script

Jul 31st, 2025 (edited)
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.14 KB | Gaming | 0 0
  1. -- Mario Paint for drawing tablets
  2. -- Use with Mesen emulator
  3. -- Written by IsoFrieze
  4.  
  5. -- In emulator settings, set both controller ports to "None"
  6. -- Setting either as "Mouse" will not work properly
  7. -- You'll want to turn on the "Let me use my pen as a mouse
  8. -- in some desktop apps" option in windows for better results
  9.  
  10. function updateMouse()
  11.     local mouse = emu.getMouseState()
  12.    
  13.     emu.write16(0x4DC, mouse.x, emu.memType.snesWorkRam)
  14.     emu.write16(0x4DE, mouse.y-6, emu.memType.snesWorkRam)
  15.    
  16.     emu.write(0x4C2, 1, emu.memType.snesWorkRam)
  17. end
  18.  
  19. function getButtons()
  20.     local mouse = emu.getMouseState()
  21.    
  22.     local buttons = 1
  23.     if mouse.left then
  24.         buttons = buttons + 0x40
  25.     end
  26.     if mouse.right then
  27.         buttons = buttons + 0x80
  28.     end
  29.    
  30.     return buttons
  31. end
  32.  
  33. function hijackButtons()
  34.     return getButtons()
  35. end
  36.  
  37. function hijackButtonsAlt()
  38.     local state = emu.getState()
  39.     state["cpu.a"] = getButtons()
  40.     emu.setState(state)
  41. end
  42.  
  43. emu.addEventCallback(updateMouse, emu.eventType.frameStart)
  44. emu.addMemoryCallback(hijackButtons, emu.callbackType.read, 0x4218)
  45. emu.addMemoryCallback(hijackButtonsAlt, emu.callbackType.exec, 0x1DA31)
  46.  
  47.  
Advertisement
Add Comment
Please, Sign In to add comment