Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --
- -- ░█▀▄░█▀█░█▀█░█▄█░░░░█░░░█░█░█▀█
- -- ░█▀▄░█░█░█░█░█░█░░░░█░░░█░█░█▀█
- -- ░▀▀░░▀▀▀░▀▀▀░▀░▀░▀░░▀▀▀░▀▀▀░▀░▀
- --
- --
- -- Fair warning: this code is about as bad as the things it does to games.
- --Original NES Braidulator by Antony Lavelle 2009 got_wot@hotmail.com http://www.the-exp.net
- --Change these settings to adjust options
- --Which key you would like to function as the "rewind key"
- local rewindKey = 'W' -- Hold this to go back in time!
- -- Keys. Feel free to change them to something convenient, because I have a weird keyboard layout
- randomkey = "A" -- Just your standard fare. One random WRAM byte.
- plusminuskey = "S" -- +/- on one random WRAM byte. Probably the safest you can do which still has some effect.
- powerkey = "D" -- Power corruption! 16 random bytes. The most fun key you can press.
- highkey = "F" -- Level corruption.
- vramkey = "G" -- Messes up vram (graphics). Purely visual - totally safe.
- freezekey = "H" -- Freezes a random byte in memory indefinedly. May have totally different effects from regular corruption.
- unfreezekey = "J" -- Unfreezes every frozen byte. This also happens automatically when rewinding.
- savetileskey = "K" -- Save current tiles.
- restoretileskey = "L" -- Restore saved tiles. Purely visual, can be used to copy tiles from game to game etc.
- savelevelkey = "I" -- Save the level blockdata
- restorelevelkey = "O" -- Restore the level blockdata
- wrammap = "Q" -- Display an interactive memory map, one pixel per byte.
- -- Opacity = value. Blue = byte changed this frame. Green = HRAM.
- -- Left: +1 Right: -1 Middle: set to $FF
- selectkey = "T" -- Level Select
- freeroamkey = "Y" -- Free roaming mode
- writetileskey = "U" -- Test tileset
- nowaterkey = "V" -- Remove water
- rewindon = "E" -- Switches rewinding on and off. May save some 15%, depending on your computer.
- debugkey = "\\" -- Displays some boring CPU info.
- --How much rewind power would you like? (The higher the number the further back in time you can go, but more computer memory is used up)
- --Do not set to 0!
- local saveMax = 2000;
- --The stuff below is for more advanced users, enter at your own peril!
- funtimes = 0;
- txttime = 0;
- -- Memory Addresses
- mode_Demo = 0xA8C6
- mode_Debug = 0xA8C7
- mode_Game = 0xA8C3
- mode_Game2 = 0xA8C4
- pause_Player = 0xA908
- pause_Enemy = 0xA9A8
- player_X = 0xA913 -- Word
- player_Y = 0xA911 -- Word
- player_Action = 0xA91A
- camera_X = 0xA902 -- Word
- camera_Y = 0xA900 -- Word
- camera_Mode = 0xA99D
- level_Id = 0xA804
- status_Hearts = 0xA808
- status_Lives = 0xA809
- status_Time = 0xA964 -- Word, reverse bytes
- player_Status = 0xA80A
- blockdata_Start = 0xAD00
- blockdata_Size = 0x0200
- leveldata_Start = 0xC000
- leveldata_Size = 0x2000
- -- Values for Memory addresses (probably uses bits but whatever)
- camera_Mode_Normal = 0x00
- camera_Mode_Train = 0x01
- camera_Mode_Free = 0x10
- camera_Mode_AutoR = 0x30
- camera_Mode_AutoL = 0x31
- player_Action_Normal = 0x00
- player_Action_Walking = 0x01
- player_Action_Crouching = 0x02
- player_Action_Climbing = 0x03
- player_Action_Swimming = 0x04
- player_Action_Air = 0x05
- player_Action_Unknown = 0x06
- player_Action_Damage = 0x07
- player_Action_Jump = 0x08
- player_Action_Death = 0x09
- player_Action_Ceiling = 0x0A
- player_Action_Dash = 0x0B
- player_Action_Hop = 0x0C
- player_Action_Dashjump = 0x0D
- player_Action_Fly = 0x0E
- player_Action_Death2 = 0x10 -- descend
- player_Action_Quicksand = 0x11
- -- These also depend on mode_Game2. They are all guaranteed to work in a level (03)
- mode_Game_LevelSelect = 0x01
- mode_Game_LevelStart = 0x02
- mode_Game_LevelMain = 0x03
- mode_Game_LevelClear = 0x04
- mode_Game_LevelExit = 0x05
- mode_Game_LevelClear2 = 0x06
- mode_Game_TimeUp = 0x07
- mode_Game_GameOver = 0x08
- mode_Game_Ending = 0x09 -- Uses other flags
- mode_Game_LastDoor = 0x09 -- Crashes if no valid door ID in RAM
- mode_Game_TreasureGet = 0x0B -- Will crash the game if called directly
- mode_Game_LevelExit2 = 0x0C
- -- Initialize other variables
- player_Underwater = 0
- player_Action_Previous = player_Action_Normal
- tmp_Action = player_Action_Normal
- tmp_freeroam = false
- dumbflag = false
- asdfg = 0
- asdfg_corrupted = 0
- -- level blocks definitions
- block_doors = {[0x48] = true, [0x4B] = true, [0x54] = true, [0x2E] = true}
- block_death = {[0x3F] = true, [0x59] = true, [0x5A] = true, [0x5C] = true, [0x5D] = true, [0x5E] = true, [0x5F] = true}
- -- extra bg: 0x60,0x61,0x76,0x7B
- -- Replacements for water (and lava) blocks
- block_water = {0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C} -- last lava
- block_nowater = {0x49,0x48,0x7F,0x7F,0x7F,0x7F,0x2B,0x2C,0x2D,0x47,0x2E,0x7E,0x7E,0x7E,0x7E,0x5D,0x5D,0x7D,0x7F} -- 5A to 5D is temp
- function rainbowcolor(ri)
- freq = 0.15
- r = math.sin(freq*ri) * 127 + 128
- g = math.sin(freq*ri+2) * 127 + 128
- b = math.sin(freq*ri+4) * 127 + 128
- return {r, g, b}
- end
- function randmemory(from, to) -- gets a random memory offset, avoiding the stack
- if gb then
- while (true) do
- bang = math.random(from, to)
- if bang < sp or bang > stack then
- break
- end
- end
- return bang
- else
- return math.random(from, to)
- end
- end
- frozen = {}
- crashi = 0
- --vram = {}
- wram = {}
- prevwram = {}
- s = {0xff, 0xff, 0x00, 0x00, 0xbb, 0xbb, 0x8b, 0x8b, 0x68, 0x68, 0x8b, 0x8b, 0xeb, 0xeb, 0x18, 0x18}
- stack = -1
- -- dumb format for speed/convenience
- invalid_opcodes = {[0xd3]= true, [0xdb]= true, [0xdd]= true, [0xe3]= true, [0xe4]= true, [0xeb]= true, [0xec]= true, [0xed]= true, [0xfd]= true, [0xf4]= true}
- local saveArray = {}; --the Array in which the save states are stored
- local saveCount = 1; --used for finding which array position to cycle through
- local save; -- the variable used for storing the save state
- local rewindCount = 0; --this stops you looping back around the array if theres nothing at the end
- local savePreventBuffer = 1; --Used for more control over when save states will be saved, not really used in this version much.
- local saveFrequency = 10; -- look at me mom, I'm editing LIVE!
- local timer = -1;
- local rewind = true
- print("Boom-W loaded!")
- while (true) do
- keys = input.get();
- joy = joypad.get(0);
- timer = timer + 1;
- savePreventBuffer = savePreventBuffer-1;
- if savePreventBuffer==0 then
- savePreventBuffer = 1;
- end;
- -- WARIO LAND SPECIFIC
- -- Set these right away
- memory.writebyte(mode_Debug, 0x01); -- Debug Mode
- memory.writeword(status_Time, 0x0004) -- Infinite time (byte order: right, left)
- memory.writebyte(status_Lives, 0x99) -- Infinite lives
- -- Get current variables
- player_Action_Current = memory.readbyte(player_Action)
- player_X_Current = memory.readword(player_X)
- player_Y_Current = memory.readword(player_Y)
- pause_Player_Current = memory.readbyte(pause_Player)
- pause_Enemy_Current = memory.readbyte(pause_Enemy)
- camera_Mode_Current = memory.readbyte(camera_Mode)
- levelid = memory.readbyte(level_Id)
- gamemode = memory.readbyte(mode_Game)
- gamemode2 = memory.readbyte(mode_Game2)
- paused = pause_Player_Current and pause_Enemy_Current
- --print (pause_Player_Current)
- player_Dead = (player_Action_Current == player_Action_Death or player_Action_Current == player_Action_Death2)
- --[[
- --Hide WINDOW at the start of the level
- --if gamemode == mode_Game_LevelInit then
- --memory.writebyte(0x0000FF4A, 0x98) -- Window Y
- --end
- ]]--
- --[[ Welp
- gui.text(1,8*0,string.format("A %02X",memory.getregister("a")), white, black)
- gui.text(1,8*1,string.format("F %02X",memory.getregister("f")), white, black)
- gui.text(1,8*2,string.format("B %02X",memory.getregister("b")), white, black)
- gui.text(1,8*3,string.format("C %02X",memory.getregister("c")), white, black)
- gui.text(1,8*4,string.format("D %02X",memory.getregister("d")), white, black)
- gui.text(1,8*5,string.format("E %02X",memory.getregister("e")), white, black)
- gui.text(1,8*6,string.format("H %02X",memory.getregister("h")), white, black)
- gui.text(1,8*7,string.format("L %02X",memory.getregister("l")), white, black)
- gui.text(1,8*8,string.format("SP %04X",memory.getregister("SP")), white, black)
- gui.text(1,8*9,string.format("PC %04X",memory.getregister("PC")), white, black)
- end]]--
- --[[
- Detect if we're underwater or not.
- The game sets action 04 if you're underwater. You're marked as out of the water only if the value is then set 05 and vice versa.
- ]]--
- if player_Action_Current == player_Action_Swimming then
- player_Underwater = 1
- tmp_Action = player_Action_Swimming -- To restore proper action if we're underwater or not
- elseif player_Action_Current == player_Action_Air then
- player_Underwater = 0
- tmp_Action = player_Action_Jump
- end
- -- Ignore if the game isn't paused (so you can go down in debug mode)
- if pause_Player_Current == 0 then
- if player_Y_Current == 0xF501 or player_Y_Current == 0xF601 then -- Check for only this specific Y coordinate so you can force yourself down further with debug mode
- memory.writeword(player_Y, 0xF001) -- 1 pixel higher
- memory.writebyte(player_Action, tmp_Action)
- elseif player_Dead then
- memory.writebyte(player_Action, player_Action_Normal); -- Prevent death once unpaused if you're down that coordinate
- end
- end
- -- All of this block is a TEMP
- -- As ideally you'd have a menu selection for this (or not)
- if gamemode == mode_Game_LevelMain then
- dumbflag = true
- -- Jump to level select if you're in a level
- -- The game is nice enough to set everything up for it
- if keys[selectkey] then
- memory.writebyte(mode_Game, mode_Game_LevelSelect)
- end
- if keys[writetileskey] then
- --preliminary block writing in memory
- gui.text(1,0, "WAIT!")
- blockCUR = 0x00;
- -- Empty block for two rows
- for layoutRAM = 0xC000, 0xC200 do
- memory.writebyte(layoutRAM, 0x7F);
- end
- -- Write all blocks in the tileset sequentially
- layoutRAM = 0xC200;
- for blockCUR = 0x00, 0x80 do
- memory.writebyte(layoutRAM,blockCUR);
- layoutRAM = layoutRAM + 0x01;
- end
- -- Write two rows and a half of empty blocks
- for layoutRAM = 0xC280, 0xC500 do
- memory.writebyte(layoutRAM, 0x7F);
- end
- -- Row of solid blocks
- for layoutRAM = 0xC500, 0xC600 do
- memory.writebyte(layoutRAM, 0x00);
- end
- for layoutRAM = 0xC600, 0xC800 do
- memory.writebyte(layoutRAM, 0x7F);
- end
- layoutRAM = 0xC800;
- for blockCUR = 0x00, 0x80 do
- memory.writebyte(layoutRAM,blockCUR);
- layoutRAM = layoutRAM + 0x01;
- end
- for layoutRAM = 0xC880, 0xC900 do
- memory.writebyte(layoutRAM, 0x7F);
- end
- for layoutRAM = 0xC900, 0xCA00 do
- memory.writebyte(layoutRAM, 0x00);
- end
- -- Set player and camera at the top of the level
- memory.writeword(camera_X, 0x4000)
- memory.writeword(camera_Y, 0x4000)
- memory.writeword(player_X, 0x4000)
- memory.writeword(player_Y, 0x4000)
- end
- -- Display
- --[[ Used to fill the rest of the window
- if paused == 1 then
- pausefill = 8
- else
- pausefill = 0
- end
- gui.box(0, 136, 159, 143, "red", "green")]]--
- -- UH OH
- x1 = memory.readbyte(player_X)
- x2 = memory.readbyte(player_X+1)
- y1 = memory.readbyte(player_Y)
- y2 = memory.readbyte(player_Y+1)
- if camera_Mode_Current == camera_Mode_Normal then
- scroll = "SEGSCRL"
- elseif camera_Mode_Current == camera_Mode_Train then
- scroll = "TRAIN"
- elseif camera_Mode_Current == camera_Mode_Free then
- scroll = "FREE"
- elseif camera_Mode_Current == camera_Mode_AutoL then
- scroll = "AUTO L"
- elseif camera_Mode_Current == camera_Mode_AutoR then
- scroll = "AUTO R"
- else
- scroll = "UNKNOWN"
- end
- gui.text(0, 137, string.format("ID %02X - X %02X%02X - Y %02X%02X - %s", levelid, x1,x2,y1,y2, scroll), "black", "white")
- if paused == 1 then
- gui.text(136, 137, "PAUSED", "black", "white")
- end
- gui.text(1, 0, string.format("Level blocks corrupted: %d", asdfg_corrupted), "black", "white");
- if keys[freeroamkey] then
- tmp_freeroam = true
- gui.text(1,137, "FREE ROAMING SET!")
- end
- end
- -- lols
- if tmp_freeroam then
- --memory.writebyte(camera_Mode, camera_Mode_AutoR);
- memory.writebyte(camera_Mode, camera_Mode_Free);
- --tmp_freeroam = false
- end
- -- Rest of the original boom-plus code here
- --keys = input.get();
- if keys[rewindKey] then
- savePreventBuffer = 5;
- if rewindCount == 0 then
- --makes sure you can't go back too far could also include other things in here, left empty for now.
- else
- savestate.load(saveArray[saveCount]);
- saveCount = saveCount-1;
- rewindCount = rewindCount-1;
- if saveCount == 0 then
- saveCount = saveMax-1;
- end;
- end;
- local HUDMATH = rewindCount / saveMax; -- Making the rewind time a percentage.
- gui.text(1,0, string.format("%.2f%%", HUDMATH * 100)); -- Displaying the time onscreen.
- if math.fmod(timer, 30) <= 15 then
- gui.text(138,8*2, "<<"); -- picky, picky
- end;
- end;
- if rewind and savePreventBuffer==1 and math.fmod(timer, saveFrequency) == 0 then
- -- gui.text(80,15,"");
- saveCount = saveCount + 1;
- if saveCount == saveMax then
- saveCount = 1;
- end
- rewindCount = rewindCount+1;
- if rewindCount == saveMax-1 then
- rewindCount = saveMax-2;
- end;
- --save = savestate.create();
- --savestate.save(save);
- --saveArray[saveCount] = save;
- end;
- pc = memory.getregister('pc')
- op = memory.readbyte(pc)
- is_invalid = invalid_opcodes[op]
- sp = memory.getregister('sp')
- if crashi <= 1 then
- if stack == -1 and sp < 0xe000 and sp >= 0xc000 then
- stack = (math.ceil(sp / 0x10) * 0x10)-1
- print(string.format("sp=%04X, stack detected at %04X", sp, stack))
- elseif sp > 0xFF00 then
- --print("Stack detected in HRAM, restart?")
- stack = -1
- end
- end
- if keys[debugkey] then
- debugtext = string.format("pc=%04X sp=%04X", pc, sp)
- gui.text(160-(string.len(debugtext)*4),0, debugtext, 'green');
- debugtext = string.format("opcode %02X", op)
- gui.text(160-(string.len(debugtext)*4),8, debugtext, 'green');
- end
- if pc >= 0x8000 or sp < 0x8000 or is_invalid or pc == 0x39 then
- crashi = crashi + 1
- if crashi >= 2 then
- gui.text(1,8, crashi, 'red');
- if crashi > 10 then
- info = "Crashed"
- else
- info = "Clinical death"
- end
- crashtext = string.format(info.." pc=%04X sp=%04X", pc, sp)
- gui.text(160-(string.len(crashtext)*4),0, crashtext, 'red');
- crashtext = ""
- if is_invalid then
- crashtext = string.format("Invalid opcode %02X", op)
- elseif pc == 0x39 then
- crashtext = string.format("Stuck in rst 38", op)
- end
- gui.text(160-(string.len(crashtext)*4),8, crashtext, 'red');
- end
- else
- crashi = 0
- end
- -- print(string.format('%04X', memory.getregister('pc')))
- if (keys[nowaterkey] and gamemode == mode_Game_LevelMain) then
- for i = leveldata_Start, leveldata_Start + leveldata_Size do
- val = memory.readbyte(i);
- -- Account for MSB
- if val > 0x7F then
- tmp_msb = 0x80
- val = val - tmp_msb
- else
- tmp_msb = 0x00
- end
- for j,v in pairs(block_water) do
- if v == val then
- memory.writebyte(i, block_nowater[j] + tmp_msb)
- break
- end
- end
- end
- end
- if keys[randomkey] then
- gui.text(1,137, "Random bytes"); -- picky, picky
- bang1 = randmemory(0x9800, 0xFEFF)
- bang2 = math.random(0, 0xFF);
- memory.writebyte(bang1, bang2);
- --print(string.format("%04X => %02X", bang1, bang2));
- end;
- if keys[plusminuskey] then
- bang1 = randmemory(0x9800, 0xFEFF)
- bang2 = AND(memory.readbyte(bang1) + math.random(-1, 1), 0xFF);
- memory.writebyte(bang1, bang2);
- gui.text(1,137, string.format("%04X +/- 1", bang1)); -- picky, picky
- --print(string.format("%04X => %02X", bang1, bang2));
- end;
- -- KABLOOEY
- if keys[powerkey] then
- gui.text(1,137, "Power corruption!", rainbowcolor(timer)); -- picky, picky
- for i = 0, 0xF do
- bang1 = randmemory(0xA000, 0xFEFF)
- bang2 = math.random(0x00, 0xFF);
- memory.writebyte(bang1, bang2);
- --print(string.format("%04X => %02X", bang1, bang2));
- end;
- end;
- -- KABLOOEY
- if keys[highkey] then
- for i = 0, 0xF do
- gui.text(1,137, "Level map corruption!"); -- picky, picky
- bang1 = randmemory(leveldata_Start, leveldata_Start+leveldata_Size)
- -- door
- if memory.readbyte(bang1) == 0x48 then
- bang1 = bang1+0x01
- end
- -- oh god
- bang2 = 0x2B; --0x7F --0x3F
- while (bang2 == 0x3F or bang2 == 0x59 or bang2 == 0x5A or bang2 == 0x5C or bang2 == 0x5D or bang2 == 0x5E or bang2 == 0x5F) do
- bang2 = math.random(0, 0x7F);
- end
- memory.writebyte(bang1, bang2);
- asdfg_corrupted = asdfg_corrupted + 1
- end;
- elseif false and gamemode == mode_Game_LevelMain then
- if asdfg == 15 then
- bang1 = randmemory(leveldata_Start, leveldata_Start+leveldata_Size)
- -- door
- val = memory.readbyte(bang1)
- -- Don't check for values before the level data
- if (bang1 > leveldata_Start+0x0100) then
- val_up = memory.readbyte(bang1-0x0100)
- else
- val_up = 0x00
- end
- -- what is an array
- if (block_doors[val] or block_doors[val_up]) then
- bang1 = bang1+0x01
- end
- -- oh god
- bang2 = 0x3F --0x47 --0x7F --0x3F
- while (block_death[bang2]) do
- bang2 = math.random(0, 0x7F);
- end
- memory.writebyte(bang1, bang2);
- asdfg = 0
- asdfg_corrupted = asdfg_corrupted + 1
- else
- asdfg = asdfg + 1
- end
- end
- if keys[vramkey] then
- rand = math.random(0, 16)
- if rand >= 3 then
- gui.text(1,137, "Trashing VRAM");
- bang1 = math.random(0x8000, 0x9FFF)
- bang2 = math.random(0, 0xFF);
- memory.writebyte(bang1, bang2);
- --elseif rand >= 3 then -- I hate you vba
- -- gui.text(1,137, "Trashing palettes");
- -- bang1 = math.random(0, 0xFF);
- -- bang2 = math.random(0, 0xFF);
- -- memory.writebyte(0xFF68, bang1);
- -- memory.writebyte(0xFF69, bang2);
- elseif rand >= 1 then
- gui.text(1,137, "Mixing up tiles");
- bang1 = math.random(0x8000, 0x9700)
- tile = memory.readbyterange(bang1, 0x10)
- bang2 = math.random(0x8000, 0x9700)
- for i,byte in pairs(tile) do
- memory.writebyte(bang2+i, byte)
- end
- memory.writebyte(bang1, bang2);
- else
- gui.text(1,137, "Trashing OAM");
- bang1 = math.random(0xFE00, 0xFE90)
- bang2 = math.random(0, 0xFF);
- memory.writebyte(bang1, bang2);
- end
- rand2 = math.random(0, 10000)
- if rand2 == 0 then
- bang = math.random(0x8000, 0x9700)
- bang = AND(bang, 0xfff0)
- for i,byte in pairs(s) do
- memory.writebyte(bang-1+i, byte)
- end
- gui.text(1,137, "4");
- end;
- --print(string.format("%04X => %02X", bang1, bang2));
- end
- if keys[freezekey] then
- gui.text(1,137, "Freeze"); -- picky, picky
- for i = 0, 0xF do
- bang1 = randmemory(0xC000, 0xDFFF)
- --bang2 = math.random(0x00, 0xFF);
- frozen[bang1] = memory.readbyte(bang1);
- --print(string.format("%04X => %02X", bang1, bang2));
- end;
- end;
- if keys[unfreezekey] or keys[rewindKey] then
- gui.text(1,137, "Unfreeze")
- frozen = {}
- end
- if keys[savetileskey] then
- gui.text(1,137, "Saved tiles"); -- picky, picky
- vram = memory.readbyterange(0x8000, 0x1800)
- blocks = memory.readbyterange(blockdata_Start, blockdata_Size) -- Come on, you want to save the blockdata too :|
- end
- if keys[restoretileskey] then
- if vram then
- gui.text(1,137, "Restored tiles")
- for i,v in pairs(vram) do
- memory.writebyte(0x8000-1+i, v);
- end
- for i,v in pairs(blocks) do
- memory.writebyte(blockdata_Start-1+i, v);
- end
- else
- gui.text(1,137, "Couldn't restore tiles")
- end
- end
- if keys[savelevelkey] then
- gui.text(1,137, "Saved level"); -- picky, picky
- level = memory.readbyterange(leveldata_Start, leveldata_Size)
- end
- if keys[restorelevelkey] then
- if level then
- gui.text(1,137, "Restored level")
- for i,v in pairs(level) do
- memory.writebyte(leveldata_Start-1+i, v);
- end
- else
- gui.text(1,137, "Couldn't restore the level")
- end
- end
- if keys[rewindon] and not lastkeys[rewindon] then
- rewind = not rewind
- end
- if keys[rewindon] then
- if rewind then
- text = "Rewind ON!"
- else
- text = "Rewind OFF!"
- end
- gui.text(1,137, text)
- end
- xmouse, ymouse, left, right, middle = keys['xmouse'], keys['ymouse'], keys['leftclick'], keys['rightclick'], keys['middleclick']
- if keys[wrammap] and not lastkeys[wrammap] then
- showwram = not showwram;
- end
- if showwram then
- --gui.text(1,137, "Live WRAM")
- wram = memory.readbyterange(0xC000, 0x2000)
- for k,v in pairs(memory.readbyterange(0xFF00, 0xFF)) do
- wram[0x2000+k] = v
- end
- width = 64
- for i,v in pairs(wram) do
- --memory.writebyte(0x8000-1+i, v);
- if prevwram[i] ~= wram[i] then
- color = {0, 0, 255, v}
- elseif frozen[0xC000+i-1] then
- color = {0, 255, 255, v}
- elseif i > 0x2000 then
- color = {0, 255, 0, v}
- else
- color = {255, 0, 0, v}
- end
- gui.pixel((i-1)%width, math.floor((i-1)/width), color)
- end
- prevwram = wram
- --xmouse, ymouse, left, right, middle = keys['xmouse'], keys['ymouse'], keys['leftclick'], keys['rightclick'], keys['middleclick']
- if left or right or middle and xmouse <= width then
- offset = 0xC000 + (xmouse%width) + (ymouse*width)
- if left then
- memory.writebyte(offset, AND(memory.readbyte(offset) + 1, 0xFF))
- elseif right then
- memory.writebyte(offset, AND(memory.readbyte(offset) - 1, 0xFF))
- else
- memory.writebyte(offset, 0xff)
- end
- end
- end
- for i,v in pairs(frozen) do
- memory.writebyte(i, v);
- end
- -- Click on the screen to move
- if left then --gamemode == mode_Game_LevelMain and
- new_X1 = memory.readbyte(camera_X)
- new_X2 = memory.readbyte(camera_X+1)+xmouse-0x50
- new_Y1 = memory.readbyte(camera_Y)
- new_Y2 = memory.readbyte(camera_Y+1)+ymouse-0x40
- -- Due to how memory.readword works and the way values are laid out in memory, we have to do this mess. S I G H
- if new_X2 > 0xFF then
- new_X2 = new_X2 - 0xFF
- new_X1 = new_X1 + 0x01
- end
- if new_Y2 > 0xFF then
- new_Y2 = new_Y2 - 0xFF
- new_Y1 = new_Y1 + 0x01
- end
- if new_X2 < 0x00 then
- new_X2 = new_X2 + 0xFF
- new_X1 = new_X1 - 0x01
- end
- if new_Y2 < 0x00 then
- new_Y2 = new_Y2 + 0xFF
- new_Y1 = new_Y1 - 0x01
- end
- --gui.text(1,8*0,string.format("X %02X%02X", new_X1, new_X2), white, black)
- --gui.text(1,8*1,string.format("Y %02X%02X", new_Y1, new_Y2), white, black)
- memory.writebyte(player_X, new_X1)
- memory.writebyte(player_X+1, new_X2)
- memory.writebyte(player_Y, new_Y1)
- memory.writebyte(player_Y+1, new_Y2)
- end
- lastkeys = keys
- player_Action_Previous = player_Action_Current
- emu.frameadvance();
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement