Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Configurable stuff
- --[[
- 0 => Sonic 1 REV00
- 1 => Sonic 1 REV01
- 2 => Sonic 2 Nick Arcade
- 3 => Sonic 2 Simon Wai
- 4 => Sonic 2 REV00
- ]]--
- gameVersion = 0
- buttondelay = 6 -- delay for holding navigation buttons (in frames)
- goat = false -- do not set unless you know how this script works
- -- nonconfigurable stuff below
- sonic1Rev0 = 0
- sonic1Rev1 = 1
- sonic2NAProto = 2
- sonic2SWProto = 3
- sonic2Rev0 = 4
- -- SONIC 1 OBJECT LIST
- if gameVersion < sonic2NAProto then
- objects = {
- --[[ {0x53, 0x01, 0x04, 0x42B8, 0x0000, 0x8746, 0x00, 0x00, 0x04, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, ""},
- {0x55, 0x00, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ""},
- {0x71, 0x31, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ""},
- {0x73, 0x00, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ""},
- {0x74, 0x01, 0x86, 0x0345, 0x0000, 0xB36E, 0x08, 0x08, 0x05, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, ""},
- ]]--
- -- Type SType
- {0x01, 0x00, 0x84, 0x0780, 0x0002, 0x11E2, 0x13, 0x09, 0x02, 0x18, 0x01, 0x01, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, "Sonic"},
- {0x02, 0x00, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Null"},
- {0x09, 0x00, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Sonic (Special Stage)"},
- {0x0D, 0x00, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Signpost"},
- {0x0E, 0x00, 0x00, 0x2300, 0x0000, 0xA888, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, "Sonic (Title Screen)"},
- {0x0F, 0x00, 0x80, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, "Title screen text"},
- {0x11, 0x0C, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "GHZ Bridge", "Number of logs"},
- {0x13, 0x30, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Fireball Maker", "Fireball spawn delay"},
- {0x14, 0x02, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Fireball"},
- {0x15, 0x06, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Swinging Platform"},
- {0x17, 0x10, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Rotating spikes (GHZ)"},
- {0x18, 0x01, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Platform"},
- {0x19, 0x00, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Blank object"},
- {0x1A, 0x00, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Collapsing Ledge (GHZ)"},
- {0x1C, 0x03, 0x01, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, "Zone Scenery"},
- {0x1F, 0x00, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Crabmeat"},
- {0x21, 0x00, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "HUD"},
- {0x22, 0x00, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Buzz Bomber "},
- {0x23, 0x00, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Buzz Bomber Bomb"},
- {0x25, 0x12, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Ring"},
- {0x26, 0x06, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Monitor"},
- {0x27, 0x00, 0x84, 0x05A0, 0x0000, 0x8EC6, 0x0E, 0x08, 0x01, 0x0C, 0x00, 0x03, 0x01, 0x00, 0x00, 0x80, 0x04, 0x02, "Explosion"},
- {0x28, 0x00, 0x85, 0x0592, 0x0000, 0x947E, 0x0C, 0x00, 0x06, 0x08, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, "Animals"},
- {0x29, 0x00, 0x84, 0x2797, 0x0000, 0x94AE, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, "Points"},
- {0x2B, 0x00, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Chopper"},
- {0x2E, 0x00, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, "Monitor contents"},
- {0x2F, 0x01, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Large Platform (MZ)"},
- {0x30, 0x01, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Large Glassy Block"},
- {0x31, 0x80, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Chandelier (MZ)"},
- {0x32, 0x80, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Switch"},
- {0x33, 0x00, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Moveable block"},
- {0x34, 0x00, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Title card"},
- {0x35, 0x00, 0x84, 0x0345, 0x0000, 0xB36E, 0x00, 0x00, 0x01, 0x08, 0x00, 0x01, 0x00, 0x8B, 0x00, 0x00, 0x02, 0x00, "Floor fireball"},
- {0x36, 0x00, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Spikes"},
- {0x37, 0x00, 0x84, 0x27B2, 0x0000, 0x9F92, 0x08, 0x08, 0x03, 0x08, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x02, 0x00, "Rings (When hit)"},
- {0x38, 0x00, 0x86, 0x055C, 0x0001, 0x43B2, 0x00, 0x00, 0x01, 0x10, 0x04, 0x01, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, "Invincibility Stars"},
- {0x39, 0x00, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Game Over/Time Over"},
- {0x3A, 0x00, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "End of level screen"},
- {0x3B, 0x00, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Purple rock (GHZ)"},
- {0x3C, 0x00, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Breakable wall"},
- {0x3D, 0x00, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Eggman (GHZ)"},
- {0x3E, 0x01, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Egg Prison"},
- {0x3F, 0x05, 0x84, 0x046C, 0x0001, 0x8580, 0x00, 0x00, 0x06, 0x08, 0x01, 0x20, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, "Large Explosion"},
- {0x40, 0x00, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Motobug"},
- {0x41, 0x02, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Spring"},
- {0x42, 0x00, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Newtron"},
- {0x44, 0x00, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Wall Barrier (GHZ)"},
- {0x46, 0x00, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Solid block (MZ)"},
- {0x48, 0x00, 0x04, 0x046C, 0x0001, 0x7DD4, 0x00, 0x00, 0x06, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, "Swinging Ball (GHZ Boss)"},
- {0x49, 0x00, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Waterfall SFX"},
- {0x4A, 0x00, 0x00, 0x0000, 0x0001, 0x446C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Proto Special stage warp"},
- {0x4B, 0x00, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Giant Ring"},
- {0x4C, 0x01, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Lava"},
- {0x4D, 0x00, 0x04, 0x63A8, 0x0000, 0xF24A, 0x00, 0x00, 0x01, 0x20, 0x06, 0x01, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, "Lava falling from ceiling"},
- {0x4E, 0x00, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Wall of lava"},
- {0x50, 0x00, 0x84, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, "Yadrin"},
- {0x51, 0x00, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Smashable Green Block"},
- {0x52, 0x41, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Moving Block (MZ)"},
- {0x54, 0x01, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Invisible lava hurtbox (MZ)"},
- {0x78, 0x00, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Caterkiller"},
- {0x79, 0x00, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Lamppost"},
- {0x7C, 0x00, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Giant ring flash"},
- {0x7D, 0x03, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Hidden points"},
- {0x7E, 0x00, 0x00, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "Special stage results screen"},
- {0x7F, 0x00, 0x00, 0x8541, 0x0000, 0xCDF4, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, "Emeralds (SS Results screen)"},
- {0x8A, 0x00, 0x80, 0x00A6, 0x0001, 0x72E2, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, "Credits text"},
- }
- subtypes = {}
- subtypes[0x14] = {
- {0x00, "Jumping (1)"},
- {0x01, "Jumping (2)"},
- {0x02, "Jumping (3)"},
- {0x03, "Jumping (4)"},
- {0x04, "Medium - Facing up"},
- {0x05, "Medium - Facing down"},
- {0x06, "Medium - Facing left"},
- {0x07, "Medium - Facing right"},
- -- glitchy stuff
- {0x08, "Static - Facing right"},
- {0x09, "10 Points"},
- {0x0A, "Very Slow - Facing right"},
- {0x0B, "Instant - Facing right"},
- {0x0C, "Temp vertical wall"},
- {0x0D, "Slow - Facing right"},
- }
- subtypes[0x15] = {
- {0x00, "Normal - 1"},
- {0x01, "Normal - 2"},
- {0x02, "Normal - 3"},
- {0x03, "Normal - 4"},
- {0x04, "Normal - 5"},
- {0x05, "Normal - 6"},
- {0x06, "Normal - 7"},
- {0x07, "Normal - 8"},
- {0x08, "Normal - 9"},
- {0x09, "Normal - 10"},
- {0x0A, "Normal - 11"},
- {0x0B, "Normal - 12"},
- {0x0C, "Normal - 13"},
- {0x0D, "Normal - 14"},
- {0x10, "Wrecking Ball - 1"},
- {0x11, "Wrecking Ball - 2"},
- {0x12, "Wrecking Ball - 3"},
- {0x13, "Wrecking Ball - 4"},
- {0x14, "Wrecking Ball - 5"},
- {0x15, "Wrecking Ball - 6"},
- {0x16, "Wrecking Ball - 7"},
- {0x17, "Wrecking Ball - 8"},
- {0x18, "Wrecking Ball - 9"},
- {0x19, "Wrecking Ball - 10"},
- {0x1A, "Wrecking Ball - 11"},
- {0x1B, "Wrecking Ball - 12"},
- {0x1C, "Wrecking Ball - 13"},
- {0x1D, "Wrecking Ball - 14"},
- }
- subtypes[0x18] = {
- {0x0, "Doesn't move"},
- {0x1, "Moves side to side"},
- {0x2, "Moves up and down"},
- {0x3, "Falls when stood on"},
- {0x4, "Falls immediately"},
- {0x5, "Moves side to side"},
- {0x6, "Moves up and down"},
- {0x7, "Rises when switch is pressed"},
- {0x8, "Rises immediately"},
- {0x9, "Doesn't move"},
- {0xA, "Large, moves up and down"},
- {0xB, "Moves up and down slowly"},
- {0xC, "Moves up and down slowly"},
- }
- --subtypes[0x1A] = {
- -- {0x00, "Style 1"},
- -- {0x01, "Style 2"},
- --}
- subtypes[0x1C] = {
- {0x00, "Fireball launcher (SLZ)"},
- {0x03, "Bridge Stump (GHZ)"},
- }
- subtypes[0x26] = {
- {0x00, "Blank"},
- {0x01, "Robotnik"},
- {0x02, "1-Up"},
- {0x03, "Speed Up"},
- {0x04, "Shield"},
- {0x05, "Invincibility"},
- {0x06, "Ring"},
- {0x07, "S"},
- {0x08, "Goggles"},
- }
- subtypes[0x2F] = {
- {0x00, "Large - Static"},
- {0x01, "Large - Oscillation 1"},
- {0x02, "Large - Oscillation 2"},
- {0x03, "Large - Oscillation 3"},
- {0x04, "Large - Oscillation 4"},
- {0x05, "Large - Sinking into lava"},
- {0x10, "Diagonal - Static"},
- {0x11, "Diagonal - Oscillation 1"},
- {0x12, "Diagonal - Oscillation 2"},
- {0x13, "Diagonal - Oscillation 3"},
- {0x14, "Diagonal - Oscillation 4"},
- {0x15, "Diagonal - Sinking into lava"},
- {0x20, "Flat - Static"},
- {0x21, "Flat - Oscillation 1"},
- {0x22, "Flat - Oscillation 2"},
- {0x23, "Flat - Oscillation 3"},
- {0x24, "Flat - Oscillation 4"},
- {0x25, "Flat - Sinking into lava"},
- }
- subtypes[0x30] = {
- {0x00, "Big - Static"},
- {0x02, "Big - Oscillating"},
- {0x06, "[Glitch] Sets demo mode"},
- {0x08, "Small - Static"},
- {0x0A, "Small - Oscillating"},
- {0x04, "Activated by switch 0"},
- {0x14, "Activated by switch 1"},
- {0x24, "Activated by switch 2"},
- {0x34, "Activated by switch 3"},
- {0x44, "Activated by switch 4"},
- {0x54, "Activated by switch 5"},
- {0x64, "Activated by switch 6"},
- {0x74, "Activated by switch 7"},
- {0x84, "Activated by switch 8"},
- {0x94, "Activated by switch 9"},
- {0xA4, "Activated by switch A"},
- {0xB4, "Activated by switch B"},
- {0xC4, "Activated by switch C"},
- {0xD4, "Activated by switch D"},
- {0xE4, "Activated by switch E"},
- {0xF4, "Activated by switch F"},
- }
- subtypes[0x31] = {
- {0x00, "Spiked Large - Static"},
- {0x01, "Spiked Large - Long chain"},
- {0x03, "Spiked Large - Medium chain"},
- {0x02, "Spiked Large - Short chain"},
- {0x10, "Spiked Small - Static"},
- {0x11, "Spiked Small - Long chain"},
- {0x13, "Spiked Small - Medium chain"},
- {0x12, "Spiked Small - Short chain"},
- {0x20, "Block Small - Static"},
- {0x21, "Block Small - Long chain"},
- {0x23, "Block Small - Medium chain"},
- {0x22, "Block Small - Short chain"},
- {0x80, "Activated by switch 0"},
- {0x81, "Activated by switch 1"},
- {0x82, "Activated by switch 2"},
- }
- subtypes[0x32] = {}
- for i = 0x01, 0x10 do
- subtypes[0x32][i] = {i - 1, "Switch " .. i - 1}
- end
- for i = 0x21, 0x30 do
- subtypes[0x32][i - 0x10] = {i - 1, "Flashing Switch " .. i - 0x21}
- end
- subtypes[0x36] = {
- {0x00, "Upright (3) - Still"},
- {0x01, "Upright (3) - V Movement"},
- {0x02, "Upright (3) - H Movement"},
- {0x10, "Sideways (3) - Still"},
- {0x11, "Sideways (3) - V Movement"},
- {0x12, "Sideways (3) - H Movement"},
- {0x20, "Upright (1) - Still"},
- {0x21, "Upright (1) - V Movement"},
- {0x22, "Upright (1) - H Movement"},
- {0x30, "Upright (3; wide) - Still"},
- {0x31, "Upright (3; wide) - V Movement"},
- {0x32, "Upright (3; wide) - H Movement"},
- {0x40, "Upright (6; wide) - Still"},
- {0x41, "Upright (6; wide) - V Movement"},
- {0x42, "Upright (6; wide) - H Movement"},
- {0x50, "Sideways (1) - Still"},
- {0x51, "Sideways (1) - V Movement"},
- {0x52, "Sideways (1) - H Movement"},
- }
- subtypes[0x3C] = {
- {0x00, "Left edge"},
- {0x01, "Main wall"},
- {0x02, "Right edge"},
- }
- subtypes[0x3E] = {
- {0x00, "Prison"},
- {0x01, "Button"},
- {0x02, "Explosions"},
- }
- subtypes[0x41] = {
- {0x00, "Red vertical spring"},
- {0x02, "Yellow vertical spring"},
- {0x10, "Red spring facing left"},
- {0x12, "Yellow spring facing left"},
- }
- subtypes[0x42] = {
- {0x00, "Flies along the ground"},
- {0x01, "Fires missile, then disappears"},
- }
- subtypes[0x44] = {
- {0x00, "Shading at top"},
- {0x01, "Regular platform"},
- {0x02, "Fully shaded"},
- }
- subtypes[0x46] = {
- {0x00, "Static"},
- {0x01, "Wobbling, doesn't fall"},
- {0x02, "Wobbling, falls"},
- {0x03, "Immediately falls"},
- {0x04, "Wobbling, slow"},
- }
- subtypes[0x4C] = {
- {0x00, "Lava geyser"},
- {0x01, "Falling from ceiling"},
- {0x03, "[Glitch] Stream"},
- }
- subtypes[0x52] = {
- {0x00, "Static"},
- {0x01, "H moving block"},
- {0x02, "Moves right when standing"},
- {0x05, "Moves right, then falls"},
- {0x06, "Immediately falls"},
- {0x07, "Appears on switch 2"},
- {0x08, "V moving block"},
- {0x09, "Sliding block"},
- {0x28, "V moving platform"},
- {0x39, "Sliding platform"},
- {0x41, "H moving platform"},
- {0x03, "[Glitch] Moves right"},
- {0x04, "[Glitch] Static"},
- }
- subtypes[0x54] = {
- {0x00, "Small"},
- {0x01, "Medium"},
- {0x02, "Big"},
- }
- subtypes[0x79] = {
- {0x00, ""},
- {0x01, ""},
- {0x02, ""},
- {0x03, ""},
- {0x04, ""},
- {0x05, ""},
- {0x06, ""},
- {0x07, ""},
- {0x08, ""},
- {0x09, ""},
- }
- subtypes[0x7D] = {
- {0x01, "1000 points"},
- {0x02, "100 points"},
- {0x03, "10 points"},
- }
- -- for obj testing only
- if goat then
- subtypes[goat] = {}
- for i = 0x00, 0x100 do
- subtypes[goat][i] = {i - 1, ""}
- end
- end
- -- REV01 patch data
- if gameVersion == sonic1Rev1 then
- objects[1] = {0x01, 0x00, 0x84, 0x0780, 0x0002, 0x1CF4, 0x13, 0x09, 0x02, 0x18, 0x01, 0x03, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, "Sonic"}
- objects[2] = {0x0E, 0x00, 0x00, 0x2300, 0x0000, 0xAF12, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, "Sonic (Title Screen)"}
- objects[2] = {0x27, 0x00, 0x84, 0x05A0, 0x0000, 0x9544, 0x00, 0x00, 0x01, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, "Explosion"}
- objects[2] = {0x28, 0x00, 0x85, 0x0592, 0x0000, 0x9AFC, 0x0C, 0x00, 0x06, 0x08, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, "Freed Animals"}
- objects[2] = {0x29, 0x00, 0x84, 0x2797, 0x0000, 0x9B2C, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, "Points"}
- objects[2] = {0x2E, 0x00, 0xA4, 0x0680, 0x0000, 0xAC80, 0x00, 0x00, 0x03, 0x08, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x00, "Monitor contents"}
- objects[2] = {0x48, 0x05, 0x04, 0x046C, 0x0001, 0x8580, 0x00, 0x00, 0x06, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, ""}
- objects[2] = {0x7F, 0x00, 0x00, 0x8541, 0x0000, 0xD482, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, "Emeralds (SS Results screen)"}
- objects[2] = {0x8A, 0x00, 0x80, 0x00A6, 0x0001, 0x7A8E, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, "Credits text"}
- end
- elseif gameVersion == sonic2NAProto then
- elseif gameVersion == sonic2SWProto then
- elseif gameVersion >= sonic2Rev0 then
- end
- -- Addresses for object ram
- if gameVersion < sonic2NAProto then
- -- Sonic 1
- address = 0xFFD000
- minaddr = 0xFFD000
- maxaddr = 0xFFEFC0
- else
- -- Sonic 2
- address = 0xFFB000
- minaddr = 0xFFB000
- maxaddr = 0xFFCFC0
- end
- function math.round(num, idp)
- local mult = 10^(idp or 0)
- if num >= 0 then return math.floor(num * mult + 0.5) / mult
- else return math.ceil(num * mult - 0.5) / mult end
- end
- function mouserange(x1, y1, x2, y2)
- return (inpt.xmouse >= x1 and inpt.xmouse <= x2 and inpt.ymouse >= y1 and inpt.ymouse <= y2)
- end
- -- to go with memory.print
- function memory.writeval(addr, value, len)
- if len == 1 then
- memory.writebyte(addr, value)
- elseif len == 2 then
- memory.writeword(addr, value)
- else
- memory.writelong(addr, value)
- end
- end
- function memory.readval(addr, len)
- if len == 1 then
- return memory.readbyte(addr)
- elseif len == 2 then
- return memory.readword(addr)
- else
- return memory.readlong(addr)
- end
- end
- --[[
- THANKS GUYS FOR NOT IMPLEMENTING THESE FUNCTIONS!!11!!
- ]]--
- function memory.readlong(addr)
- local a1 = memory.readword(addr)
- local a2 = memory.readword(addr + 4)
- --print (string.format("%04X", a1) .. " + " .. string.format("%04X", a2) .. " = " .. string.format("%04X", (a1 * 0x10000) + a2))
- return (a1 * 0x10000) + a2
- end
- function memory.writelong(addr, val)
- local v_upper = math.floor(val / 0x10000)
- local v_lower = val % 0x10000
- memory.writeword(addr, v_upper)
- memory.writeword(addr + 4, v_lower)
- --print (string.format("%04X", v_upper) .. " + " .. string.format("%04X", v_lower) .. " = " .. string.format("%04X", val))
- end
- function string.pad(str, val)
- local l = string.len(str)
- if l >= val then -- the string is already big enough to fit
- return str
- else
- local pad = val - l
- return string.rep(" ", pad) .. str
- end
- end
- --[[
- Searches the first free slot (obj 00) from the not-reserved ones
- ]]--
- function searchfree()
- local i = minaddr + 0x800
- local out
- while (i < maxaddr) do
- out = memory.readbyte(i)
- if (out == 0) then
- return i
- else
- i = i + 0x40
- end
- end
- return nil
- end
- function getkeyfromtype(id, subtype)
- local sres = nil
- for i in ipairs(objects) do
- if objects[i][1] == id then
- -- iterate over subtypes if they exist
- if subtypes[id] ~= nil then
- for j in ipairs(subtypes) do
- if (subtypes[j][1] == subtype) then
- sres = j
- break
- end
- end
- end
- return {i, sres}
- end
- end
- return {2, sres} -- null / unknown
- end
- function getbit(value, pos)
- if (pos == 1) then
- offset = 1
- else
- offset = (2 ^ pos) - 2
- end
- return math.floor(value / offset) % 2
- end
- function setbit(value, pos, cached)
- if cached == nil then
- cached = getbit(value, pos)
- end
- if (pos == 1) then
- offset = 1
- else
- offset = 2 ^ pos - 2
- end
- if cached == 0 then
- return value + offset
- else
- return value - offset
- end
- end
- function getobjectpos(addr)
- local out = {
- x = memory.readword(addr + 0x08) - screen_x,
- y = memory.readword(addr + 0x0C) - screen_y,
- ry = memory.readbyte(addr + 0x16), -- radius x
- rx = memory.readbyte(addr + 0x17), -- radius y
- }
- -- this bit forces the height to be 32 pixels
- --local changer = getbit(memory.readbyte(addr + 0x01), 3)
- if out['ry'] < 2 or out['rx'] < 2 then
- out['ry'] = 0x8
- out['rx'] = 0x8
- end
- return out
- end
- -- search through non-null objects and render their hitbox
- function renderhitbox()
- local i = minaddr
- local stat
- local color
- while i < maxaddr do
- if memory.readbyte(i) ~= 0 then
- stat = getobjectpos(i)
- if (mouserange(stat['x'] - stat['rx'], stat['y'] - stat['ry'], stat['x'] + stat['rx'], stat['y'] + stat['ry'])) then
- if (inpt.leftclick) then
- color = "green"
- moveobject(i)
- address = i -- also select it
- else
- color = "white"
- end
- else
- color = "red"
- end
- gui.box(stat['x'] - stat['rx'], stat['y'] - stat['ry'], stat['x'] + stat['rx'], stat['y'] + stat['ry'], "#00000000", color)
- end
- i = i + 0x40
- end
- end
- function moveobject(addr)
- local x = screen_x + inpt.xmouse
- local y = screen_y + inpt.ymouse
- memory.writeword(addr + 0x08, x)
- memory.writeword(addr + 0x0C, y)
- end
- --[[
- Debug scanning
- Constantly scans the object list until it finds the object in its first state
- when it does it will return the address
- ]]--
- function scanobject(id, subtype)
- if (id) then
- local i = minaddr
- local out
- local checksub
- -- if no subtype is specified, skip the subtype check
- if (subtype == nil) then
- checksub = subtype
- end
- while (i < maxaddr) do
- checkid = memory.readbyte(i)
- if (subtype) then
- checksub = memory.readbyte(i+0x28)
- end
- if (checkid == id and checksub == subtype) then
- return i
- else
- i = i + 0x40
- end
- end
- end
- return nil
- end
- function memory.print(addr, len, title, objecttitle, bit)
- local color -- table color
- local print_val -- value in hexadecimal form
- local res
- res = memory.readval(addr, len) -- output (read address)
- --local print_addr = title .. " (" .. string.format("%06X", addr) .. ")" -- address in hex form
- local x2 = string.len(title)
- -- calculate a temporary offset for the buttons
- local button_offset
- if (bit == nil) then
- button_offset = 4
- else
- button_offset = 0
- end
- -- text padding
- if len == 1 then
- if objecttitle then
- x2 = 31
- print_val = string.pad(string.format("%02X ", res) .. objecttitle, x2 + button_offset)
- else
- print_val = string.pad(string.format("%02X", res), x2 + button_offset)
- end
- if min == nil then
- min = 0x00
- max = 0xFF
- jump = 1
- end
- elseif len == 2 then
- print_val = string.pad(string.format("%04X", res), x2 + button_offset)
- if min == nil then
- min = 0x00
- max = 0xFFFF
- jump = 1
- end
- else
- print_val = string.pad(string.format("%08X", res), x2 + button_offset)
- if min == nil then
- min = 0x00
- max = 0xFFFFFFFF
- jump = 1
- end
- end
- -- account for font size
- x2 = x2 * 4
- if (bit == nil) then
- navbuttons(addr, len, res, table_x + x2 + 1, table_y, min, max, jump) -- will take x + 16 + 1
- button_offset = 18
- --table_x = table_x + x2 + 19
- else
- --checkbox(addr, res, bit, table_x + x2 + 1, table_y) -- will take x + 8 + 1
- button_offset = 10
- end
- -- draw address
- gui.box(table_x, table_y, table_x + x2, table_y + 8, "#000000f0", color)
- gui.text(table_x + 1, table_y + 1, title, "white", "clear")
- -- and its value
- gui.box(table_x, table_y + 9, table_x + x2 + button_offset, table_y + 16, "#000000f0", color)
- gui.text(table_x + 1, table_y + 10, print_val, "white", "clear")
- table_x = table_x + x2 + button_offset + 1
- return res
- end
- --[[
- Render a checkbox
- addr: address to change
- res: value of address
- bit: bits to switch
- x: x position
- y: y position
- ]]--
- function checkbox(addr, res, bit, title, x, y)
- local bitvalue = getbit(res, bit)
- local offset = (string.len(title) * 4)
- -- selection color and hitbox
- local color = "black"
- if (buttondelaycur == 0 and mouserange(x + offset + 1, y, x + offset + 11, y + 8)) then
- -- left selected: decrement
- if inpt.leftclick then
- color = "green"
- memory.writebyte(addr, setbit(res, bit, bitvalue))
- buttondelaycur = buttondelay
- else
- color = "white"
- end
- end
- -- checkbox icon
- local check = " X"
- if bitvalue == 0 then
- check = ""
- end
- gui.box(x, y, x + 10 + offset, y + 8, "#000000f0", "black")
- gui.text(x + 1, y + 1, title, "white", "clear")
- gui.box(x + offset + 1, y, x + 11 + offset, y + 8, "#000000f0", color)
- gui.text(x + offset + 2, y + 1, check, "white", "clear")
- end
- --[[
- Render two clickable buttons to respectively decrement / increment values
- addr: address to change
- len: value length (1 - byte, 2 - word, 4 - long)
- res: value of address
- x: x position
- y: y position
- ]]--
- function navbuttons(addr, len, res, x, y, min, max, jump)
- -- selection colors
- local colors = {"black", "black"}
- if (buttondelaycur == 0) then
- -- Selection ""hitbox""
- local selectleft = mouserange(x, y, x + 8, y + 8)
- local selectright = mouserange(x + 9, y, x + 17, y + 8)
- if selectleft then
- -- left selected: decrement
- if inpt.leftclick then
- colors[1] = "green"
- if res > 0 then
- memory.writeval(addr, res - 1, len)
- buttondelaycur = buttondelay
- end
- else
- colors[1] = "white"
- end
- elseif selectright then
- -- right selected: increment
- if inpt.leftclick then
- colors[2] = "green"
- memory.writeval(addr, res + 1, len)
- buttondelaycur = buttondelay
- else
- colors[2] = "white"
- end
- end
- end
- -- render the buttons
- gui.box(x, y, x + 8, y + 8, "#000000f0", colors[1])
- gui.text(x + 1, y + 1, "<", "white", "clear")
- gui.box(x + 9, y, x + 17, y + 8, "#000000f0", colors[2])
- gui.text(x + 10, y + 1, ">", "white", "clear")
- end
- --[[
- Increment / Decrement the object id
- ]]--
- function objbuttons(addr, jump, min, max, x, y)
- -- selection colors
- local colors = {"black", "black"}
- if (buttondelaycur == 0) then
- -- Selection ""hitbox""
- local selectleft = address > min and mouserange(x, y, x + 8, y + 8)
- local selectright = address < max and mouserange(x + 9, y, x + 17, y + 8)
- -- selection colors
- if address <= min then
- colors[1] = "gray"
- end
- if address >= max then
- colors[2] = "gray"
- end
- if selectleft then
- -- left selected: decrement
- if inpt.leftclick then
- colors[1] = "green"
- address = address - jump
- buttondelaycur = buttondelay
- else
- colors[1] = "white"
- end
- elseif selectright then
- -- right selected: increment
- if inpt.leftclick then
- colors[2] = "green"
- address = address + jump
- buttondelaycur = buttondelay
- else
- colors[2] = "white"
- end
- end
- end
- -- render the buttons
- gui.box(x, y, x + 8, y + 8, "#000000f0", colors[1])
- gui.text(x + 1, y + 1, "<", "white", "clear")
- gui.box(x + 9, y, x + 17, y + 8, "#000000f0", colors[2])
- gui.text(x + 10, y + 1, ">", "white", "clear")
- end
- --[[
- This table contains object information
- ]]--
- function rendertable()
- local objstate = {}
- -- Draw table
- table_x = 0;
- table_y = 0;
- -- Print object status
- -- (address, byte (1) or word (2)
- -- draw address
- -- Navigation buttons
- objbuttons(address, 0x40, minaddr, maxaddr, 19 * 4 + 1, 0)
- -- Table title with address information
- local id = math.floor((address - minaddr) / 0x40)
- local addr_text = "Object " .. string.format("%02X", id) .. " (" .. string.format("%06X", address) .. ")";
- local addr_len = 19 * 4 --string.len(addr_text) * 4
- gui.box(0, 0, addr_len, 8, "#000000f0", color)
- gui.text(1, 1, addr_text, "white", "clear")
- table_x = 0
- table_y = 9
- objectmarker = getkeyfromtype(memory.readbyte(address), memory.readbyte(address+0x28))
- local typetitle
- if objects[objectmarker[1]] == nil then
- typetitle = nil
- else
- typetitle = objects[objectmarker[1]][19]
- end
- local subtypetitle
- if objectmarker[2] == nil then
- subtypetitle = nil
- else
- subtypetitle = subtypes[objectmarker[1]][objectmarker[2]]
- end
- memory.print(address, 1, "Object type", typetitle)
- table_x = 0
- table_y = table_y + 17
- memory.print(address + 0x28, 1, "Object subtype", subtypetitle)
- table_x = 0
- table_y = table_y + 17
- memory.print(address + 0x08, 2, "Object X")
- --memory.print(address + 0x0A, 2, "Subpixel X")
- memory.print(address + 0x0C, 2, "Object Y")
- --memory.print(address + 0x0E, 2, "Subpixel Y")
- --memory.print(address + 0x01, 1, "Rendering", nil, true)
- local rendering = memory.readbyte(address + 0x01)
- checkbox(address + 0x01, rendering, 1, "H Mirroring", table_x + 1, table_y)
- checkbox(address + 0x01, rendering, 2, "V Mirroring", table_x + 1, table_y + 9)
- table_x = 0
- table_y = table_y + 17
- memory.print(address + 0x24, 1, "Routine 1")
- memory.print(address + 0x25, 1, "Routine 2")
- -- obj status dump
- --[[
- table_x = 0
- table_y = 190
- for i = 0x1, 0x10 do
- memory.print(address - 1 + i, 1, "")
- end
- table_x = 0
- table_y = table_y + 17
- for i = 0x11, 0x20 do
- memory.print(address - 1 + i, 1, "")
- end
- ]]--
- end
- function spawnobject(id, subtype, addr, x, y)
- local d
- if subtypes[objects[id][1]] == nil or subtype == nil then -- if no subtype is specified use the default
- d = objects[id][2]
- else
- d = subtypes[objects[id][1]][subtype][1]
- end
- memory.writebyte(addr, objects[id][1]) -- object type
- memory.writebyte(addr + 0x28, d) -- object subtype
- memory.writebyte(addr + 0x01, objects[id][3]) -- rendering
- memory.writeword(addr + 0x02, objects[id][4]) -- art
- memory.writeword(addr + 0x04, objects[id][5]) -- mappings offset
- memory.writeword(addr + 0x06, objects[id][6]) -- mappings offset
- memory.writeword(addr + 0x08, x) -- x
- memory.writeword(addr + 0x0A, 0) -- x subpixel
- memory.writeword(addr + 0x0C, y) -- y
- memory.writeword(addr + 0x0E, 0) -- y subpixel
- memory.writebyte(addr + 0x16, objects[id][7]) -- h radius hitbox
- memory.writebyte(addr + 0x17, objects[id][8]) -- v radius hitbox
- memory.writebyte(addr + 0x18, objects[id][9]) -- priority
- memory.writebyte(addr + 0x19, objects[id][10]) -- h radius
- memory.writebyte(addr + 0x1A, objects[id][11]) -- animation
- memory.writebyte(addr + 0x1B, objects[id][12]) -- frame
- memory.writebyte(addr + 0x1C, objects[id][13]) -- anim id
- memory.writebyte(addr + 0x1D, objects[id][13]) -- anim id
- memory.writebyte(addr + 0x1E, 0x07) -- anim id
- memory.writebyte(addr + 0x20, objects[id][14]) -- collision response
- memory.writebyte(addr + 0x21, objects[id][15]) -- custom collision response
- memory.writebyte(addr + 0x22, objects[id][16]) -- status
- memory.writebyte(addr + 0x23, reference)
- reference = reference - 1
- memory.writebyte(addr + 0x24, objects[id][17]) -- routine 1
- memory.writebyte(addr + 0x25, objects[id][18]) -- routine 2
- memory.writebyte(addr + 0x26, 0x00) -- angle
- print("Spawned object " .. id .. " - " .. d .. " at " .. string.format("%06X", addr))
- --print (objectdebug(addr, "Sonic (Spawned)"))
- end
- function objectdebug(addr, title)
- return ("{" ..
- string.format("0x%02X, ", memory.readbyte(addr)) ..
- string.format("0x%02X, ", memory.readbyte(addr + 0x28)) ..
- string.format("0x%02X, ", memory.readbyte(addr + 0x01)) ..
- string.format("0x%04X, ", memory.readword(addr + 0x02)) ..
- string.format("0x%04X, ", memory.readword(addr + 0x04)) ..
- string.format("0x%04X, ", memory.readword(addr + 0x06)) ..
- string.format("0x%02X, ", memory.readbyte(addr + 0x16)) ..
- string.format("0x%02X, ", memory.readbyte(addr + 0x17)) ..
- string.format("0x%02X, ", memory.readbyte(addr + 0x18)) ..
- string.format("0x%02X, ", memory.readbyte(addr + 0x19)) ..
- string.format("0x%02X, ", memory.readbyte(addr + 0x1A)) ..
- string.format("0x%02X, ", memory.readbyte(addr + 0x1B)) ..
- string.format("0x%02X, ", memory.readbyte(addr + 0x1C)) ..
- string.format("0x%02X, ", memory.readbyte(addr + 0x20)) ..
- string.format("0x%02X, ", memory.readbyte(addr + 0x21)) ..
- string.format("0x%02X, ", memory.readbyte(addr + 0x22)) ..
- string.format("0x%02X, ", memory.readbyte(addr + 0x24)) ..
- string.format("0x%02X, ", memory.readbyte(addr + 0x25)) ..
- "\"" .. title .. "\"},")
- end
- --[[
- Object editing list
- ]]--
- function rendermenu()
- local x = 180
- local y = 0
- local slot
- local screen -- screen x and y
- gui.box(x - 35, y, x + 90, y + 8, "#000000f0", "black")
- gui.text(x - 34, y + 1, string.format("%02X ", objects[selection][1]) .. objects[selection][19], "white", "clear")
- -- type selection
- local hhack
- local objectid
- if objects[selection + 1] == nil then
- hhack = 0
- objectid = 0
- else
- hhack = 0xFF
- objectid = objects[selection][1]
- end
- selection = selbuttons(selection, 1, hhack, x + 90 + 1, y)
- --subtype selection
- local subtypeid
- if (subtypes[objectid] ~= nil) then
- subtypeid = subtypes[objectid][subselection][1]
- gui.box(x - 35, y + 9, x + 90, y + 17, "#000000f0", "black")
- gui.text(x - 34, y + 10, string.format("%02X ", subtypeid) .. subtypes[objectid][subselection][2], "white", "clear")
- if subtypes[objectid][subselection + 1] == nil then
- hhack = 0
- else
- hhack = 0xFF
- end
- subselection = selbuttons(subselection, 1, hhack, x + 90 + 1, y + 9)
- else
- subtypeid = nil
- -- subtype extra values
- if (objects[selection][20] ~= nil) then
- gui.box(x - 35, y + 9, x + 90, y + 17, "#000000f0", "black")
- gui.text(x - 34, y + 10, "Subtype: " .. objects[selection][20], "white", "clear")
- end
- end
- -- Pressing the "add object" button
- local setcolor = "black"
- if putobject == 1 then
- if inpt.leftclick and buttondelaycur == 0 then
- putobject = 0
- -- spawn the object
- slot = searchfree()
- if slot then
- spawnobject(selection, subselection, slot, screen_x + inpt.xmouse, screen_y + inpt.ymouse)
- else
- print("No more objects can be added.")
- end
- else
- local x_radius = objects[selection][8]
- local y_radius = objects[selection][7]
- if (x_radius == 0) then x_radius = 8 end
- if (y_radius == 0) then y_radius = 8 end
- gui.box(inpt.xmouse - x_radius, inpt.ymouse - y_radius, inpt.xmouse + x_radius, inpt.ymouse + y_radius, "#00000080", "black")
- end
- else
- if mouserange(x+110, y, x+140, y+8) then
- if inpt.leftclick then
- putobject = 1
- buttondelaycur = buttondelay -- prevent accidental inserts
- else
- setcolor = "green"
- end
- end
- end
- gui.box(x + 110, y, x + 140, y + 8, "#000000f0", setcolor)
- gui.text(x + 114, y + 1, "Set", "white", "clear")
- -- Button to jump to first address with specified object
- local holdcolor = "black"
- if mouserange(x + 110, y + 9, x + 140, y + 17) then
- if inpt.leftclick then
- holdcolor = "white"
- -- todo: find first object with selection and subselection
- local search = scanobject(objectid, subtypeid)
- if search then
- address = search
- end
- else
- holdcolor = "green"
- end
- end
- gui.box(x + 110, y + 9, x + 140, y + 17, "#000000f0", holdcolor)
- gui.text(x + 114, y + 10, "Find", "white", "clear")
- end
- function selbuttons(var, min, max, x, y)
- -- var colors
- local colors = {"black", "black"}
- if (buttondelaycur == 0) then
- -- Selection ""hitbox""
- local selectleft = var > min and mouserange(x, y, x + 8, y + 8)
- local selectright = var < max and mouserange(x + 9, y, x + 17, y + 8)
- if var <= min then
- colors[1] = "gray"
- end
- if var >= max then
- colors[2] = "gray"
- end
- if selectleft then
- -- left selected: decrement
- if inpt.leftclick then
- colors[1] = "green"
- var = var - 1
- subselection = 1 -- reset subtype selection
- buttondelaycur = buttondelay
- else
- colors[1] = "white"
- end
- elseif selectright then
- -- right selected: increment
- if inpt.leftclick then
- colors[2] = "green"
- var = var + 1
- subselection = 1
- buttondelaycur = buttondelay
- else
- colors[2] = "white"
- end
- end
- end
- -- render the buttons
- gui.box(x, y, x + 8, y + 8, "#000000f0", colors[1])
- gui.text(x + 1, y + 1, "<", "white", "clear")
- gui.box(x + 9, y, x + 17, y + 8, "#000000f0", colors[2])
- gui.text(x + 10, y + 1, ">", "white", "clear")
- return var
- end
- function logobjects()
- local search
- local i
- for i = 1, 0xFF do
- if logobj[i] == nil then -- CHECK
- search = scanobject(i)
- if search then
- print (objectdebug(search, ""))
- logobj[i] = true
- --emu.pause()
- end
- end
- end
- end
- selection = 1
- subselection = 1
- putobject = 0
- reference = 0xFF
- screen_x = 0
- screen_y = 0
- buttondelaycur = 0
- -- LOGGING OBJECTS' FIRST STATE
- logobj = {}
- for i in ipairs(objects) do
- -- logobj[<obj id>] = true
- -- these are skipped by the logobj
- logobj[objects[i][1]] = true
- end
- while true do
- inpto = inpt;
- inpt = input.get()
- if gameVersion >= sonic2NAProto then
- screen_y = memory.readword(0xFFEE04)
- screen_x = memory.readword(0xFFEE00)
- else
- screen_y = memory.readword(0xFFF704)
- screen_x = memory.readword(0xFFF700)
- end
- logobjects()
- renderhitbox()
- rendertable()
- rendermenu()
- -- decrease frame limiter
- if (buttondelaycur > 0) then
- buttondelaycur = buttondelaycur - 1
- end
- emu.frameadvance()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement