Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------ Settings Table ------
- local Settings = {
- ["SavegamesX"]=60,
- ["SavegamesY"]=20,
- ["MyFont"]=2,
- ["PaddingTop"]=0,
- ["PaddingBottom"]=0
- }
- ----- Misc Settings -----
- local clickedFrames = 0
- local clicked=false
- local X=0
- local Y=0
- local XBefore=0
- local YBefore=0
- ------ Extra Padding --------
- local PaddingLeft=0
- local PaddingRight=0
- local PaddingTop=0
- local PaddingBottom=0
- local PaddingTopSetting=0 -- in "Add Space", before actually adding it to PaddingTop/Bottom
- local PaddingBottomSetting=0
- ------ Read only stuff ------
- local FontTable = {{8,"SF Intermosaic B"},
- {10,"Arial"},
- {9,"MS Reference Sans Serif"},
- {9,"Square721 BT"},
- {9,"Century Gothic"}}
- local ColorButtonSelected = 0xB0A0A0A0
- local ColorButtonNormal = 0xA0303030
- ------ Game Version ------
- local GameVersion=0
- local GameVersionText=""
- if gameinfo.getromhash()=="7C303CDDE5061EE329296948060B875CB50BA410" then
- GameVersion=1 -- usa
- GameVersionText="USA"
- elseif gameinfo.getromhash()=="EDC538AC505BFCD337ABDD03B3A6F2744D81EAAB" then
- GameVersion=2 -- jp
- GameVersionText="Japan"
- elseif gameinfo.getromhash()=="FA2314C2FBE0DB1AB17175F8BE7CCEB0AB084EFC" then
- GameVersion=3 -- eu
- GameVersionText="Europe"
- else
- GameVersion=4
- GameVersionText="Game not recognized"
- end
- local Region=0
- if GameVersion==1 or GameVersion==3 then
- Region=1 -- english
- elseif GameVersion==2 then
- Region=2 --jp
- else Region=3 end --not M+L
- local toboolean = function(string)
- if string=="true" then
- string=true
- elseif string=="false" then
- string=false
- else
- string=nil
- end
- return string
- end
- function text(x, y, text, color, backcolor)
- if backcolor==nil then backcolor=0x00000000 end
- gui.drawText(x, y, text,color,backcolor,FontTable[ Settings["MyFont"] ][1],FontTable[ Settings["MyFont"] ][2])
- end
- function box(x,y,x2,y2)
- gui.drawBox(x,y,x2,y2,0x00000000,0xD0000000)
- end
- function boxNormal(x,y,x2,y2)
- gui.drawBox(x,y,x2,y2,0xFF000000,0xA0000000)
- end
- function boxSelected(x,y,x2,y2)
- gui.drawBox(x,y,x2,y2,0xFF000000,0xA0505050)
- end
- function img(path,x,y)
- gui.drawImage(path,x,y)
- end
- function arrowDown(xpos,ypos,col)
- gui.drawLine(xpos,ypos,xpos+6,ypos,col)
- gui.drawLine(xpos+1,ypos+1,xpos+5,ypos+1,col)
- gui.drawLine(xpos+2,ypos+2,xpos+4,ypos+2,col)
- gui.drawPixel(xpos+3,ypos+3,col)
- end
- function arrowUp(xpos,ypos,col)
- gui.drawLine(xpos,ypos,xpos+6,ypos,col)
- gui.drawLine(xpos+1,ypos-1,xpos+5,ypos-1,col)
- gui.drawLine(xpos+2,ypos-2,xpos+4,ypos-2,col)
- gui.drawPixel(xpos+3,ypos-3,col)
- end
- function drawDisplayBox(posx,posy,width,height,bordercolor,color,colorchangesonhover,clickedfunction)
- if colorchangesonhover then
- if X > posx and X < posx+width and Y > posy and Y < posy+height then
- if clicked and clickedFrames > 0 then
- menuscreen=0 -- close menu
- clickedfunction() -- custom function passed in the parameter
- end
- gui.drawBox(posx,posy,posx+width,posy+height,bordercolor,color-0x30000000)
- else
- gui.drawBox(posx,posy,posx+width,posy+height,bordercolor,color)
- end
- else
- if X > posx and X < posx+width and Y > posy and Y < posy+height then
- if clicked and clickedFrames > 0 then
- menuscreen=0 -- close menu
- clickedfunction() -- custom function passed in the parameter
- end
- end
- gui.drawBox(posx,posy,posx+width,posy+height,bordercolor,color)
- end
- end
- --posx,posy,width of the container
- function drawCloseButton(posx,posy,width,clickedfunction)
- if X>posx+width-10 and X<posx+width and Y>posy and Y<posy+10 then
- if clicked and clickedFrames==1 then
- clickedfunction()
- end
- gui.drawBox(posx+width-10,posy,posx+width,posy+10,0xFF000000,0xA0C0C0C0)
- else
- gui.drawBox(posx+width-10,posy,posx+width,posy+10,0xFF000000,0xA0A0A0A0)
- end
- text(posx+width-8,posy-(FontTable[ Settings["MyFont"] ][1]-8),"x",0xFFFFFFFF)
- end
- function drawButton(posx,posy,width,height,label,color,frequency,clickedfunction)
- if X>posx and X<posx+width and Y>posy and Y<posy+height then
- if clicked and clickedFrames%frequency==1 then
- clickedfunction()
- end
- gui.drawBox(posx,posy,posx+width,posy+height,color-0x00303030,color+0x30303030)
- else
- gui.drawBox(posx,posy,posx+width,posy+height,color-0x00303030,color)
- end
- text(posx+2,posy-(FontTable[ Settings["MyFont"] ][1]-8),label,0xFFFFFFFF)
- end
- local drawEditSavegames = function()
- memory.usememorydomain("EWRAM")
- SavegamesX=Settings["SavegamesX"]
- SavegamesY=Settings["SavegamesY"]
- width=170
- height=115
- drawDisplayBox(SavegamesX,SavegamesY,width,height,0xFF202020,0xA0000000,false, function()
- --what happens if clicked on:
- SavegamesY = SavegamesY + (Y-YBefore) --enables mouse drag
- SavegamesX = SavegamesX + (X-XBefore)
- if SavegamesY < 0 then SavegamesY=0 --prevents display from going offscreen
- elseif SavegamesY > 159-height+PaddingTop+PaddingBottom then SavegamesY=159-height+PaddingTop+PaddingBottom end
- if SavegamesX < 0 then SavegamesX=0
- elseif SavegamesX > 239-width+PaddingLeft+PaddingRight then SavegamesX=239-width+PaddingLeft+PaddingRight end
- Settings["SavegamesY"]=SavegamesY
- Settings["SavegamesX"]=SavegamesX
- end)
- -- slots in use
- text(3+SavegamesX,12+SavegamesY,"slots in use:",0xFFFFFFFF)
- if bit.check(memory.read_u8(0x001e7e),0) then
- text(83+SavegamesX,12+SavegamesY, "1", 0xFFFFFF00)
- else
- text(83+SavegamesX,12+SavegamesY, "1", 0x5FFFFFFF)
- end
- if bit.check(memory.read_u8(0x001e7e),1) then
- text(90+SavegamesX,12+SavegamesY, "2", 0xFFFFFF00)
- else
- text(90+SavegamesX,12+SavegamesY, "2", 0x5FFFFFFF)
- end
- if bit.check(memory.read_u8(0x001e7e),2) then
- text(97+SavegamesX,12+SavegamesY, "3", 0xFFFFFF00)
- else
- text(97+SavegamesX,12+SavegamesY, "3", 0x5FFFFFFF)
- end
- t=""
- if bit.check(memory.read_u8(0x001e7e),7) then
- t=t.."1"
- else
- t=t.."0"
- end
- if bit.check(memory.read_u8(0x001e7e),6) then
- t=t.."1"
- else
- t=t.."0"
- end
- if bit.check(memory.read_u8(0x001e7e),5) then
- t=t.."1"
- else
- t=t.."0"
- end
- if bit.check(memory.read_u8(0x001e7e),4) then
- t=t.."1 "
- else
- t=t.."0 "
- end
- if bit.check(memory.read_u8(0x001e7e),3) then
- t=t.."1"
- else
- t=t.."0"
- end
- if bit.check(memory.read_u8(0x001e7e),2) then
- t=t.."1"
- else
- t=t.."0"
- end
- if bit.check(memory.read_u8(0x001e7e),1) then
- t=t.."1"
- else
- t=t.."0"
- end
- if bit.check(memory.read_u8(0x001e7e),0) then
- t=t.."1"
- else
- t=t.."0"
- end
- text(114+SavegamesX,12+SavegamesY,t,0xFFFFFFFF)
- -- current slot
- memory.usememorydomain("IWRAM")
- if bit.check(memory.read_u8(0x0d40),2) then
- currentslot=2
- elseif bit.check(memory.read_u8(0x0d40),3) then
- currentslot=3
- else
- currentslot=1
- end
- text(3+SavegamesX,22+SavegamesY,"current slot: ".. currentslot,0xFFFFFFFF)
- t=""
- if bit.check(memory.read_u8(0x0d40),7) then
- t=t.."1"
- else
- t=t.."0"
- end
- if bit.check(memory.read_u8(0x0d40),6) then
- t=t.."1"
- else
- t=t.."0"
- end
- if bit.check(memory.read_u8(0x0d40),5) then
- t=t.."1"
- else
- t=t.."0"
- end
- if bit.check(memory.read_u8(0x0d40),4) then
- t=t.."1 "
- else
- t=t.."0 "
- end
- if bit.check(memory.read_u8(0x0d40),3) then
- t=t.."1"
- else
- t=t.."0"
- end
- if bit.check(memory.read_u8(0x0d40),2) then
- t=t.."1"
- else
- t=t.."0"
- end
- if bit.check(memory.read_u8(0x0d40),1) then
- t=t.."1"
- else
- t=t.."0"
- end
- if bit.check(memory.read_u8(0x0d40),0) then
- t=t.."1"
- else
- t=t.."0"
- end
- text(114+SavegamesX,22+SavegamesY,t,0xFFFFFFFF)
- memory.usememorydomain("EWRAM")
- -- copy 1 to 2
- drawButton(SavegamesX+3,SavegamesY+34,70,10,"copy 1 to 2",ColorButtonNormal,20,function()
- --write values
- for i=0,1783,1 do
- memory.write_u8(0x002580+i, memory.read_u8(0x001e88+i) )
- end
- --set "slots in use" flag
- memory.write_u8( 0x001e7e, bit.set(memory.read_u8(0x001e7e),1) )
- editedMemory=true
- end)
- -- copy 1 to 3
- drawButton(SavegamesX+3,SavegamesY+46,70,10,"copy 1 to 3",ColorButtonNormal,20,function()
- --write values
- for i=0,1783,1 do
- memory.write_u8(0x002c78+i, memory.read_u8(0x001e88+i) )
- end
- --set "slots in use" flag
- memory.write_u8( 0x001e7e, bit.set(memory.read_u8(0x001e7e),2) )
- editedMemory=true
- end)
- -- copy 2 to 1
- drawButton(SavegamesX+3,SavegamesY+58,70,10,"copy 2 to 1",ColorButtonNormal,20,function()
- --write values
- for i=0,1783,1 do
- memory.write_u8(0x001e88+i, memory.read_u8(0x002580+i) )
- end
- --set "slots in use" flag
- memory.write_u8( 0x001e7e, bit.set(memory.read_u8(0x001e7e),0) )
- editedMemory=true
- end)
- -- copy 2 to 3
- drawButton(SavegamesX+3,SavegamesY+70,70,10,"copy 2 to 3",ColorButtonNormal,20,function()
- --write values
- for i=0,1783,1 do
- memory.write_u8(0x002c78+i, memory.read_u8(0x002580+i) )
- end
- --set "slots in use" flag
- memory.write_u8( 0x001e7e, bit.set(memory.read_u8(0x001e7e),2) )
- editedMemory=true
- end)
- -- copy 3 to 1
- drawButton(SavegamesX+3,SavegamesY+82,70,10,"copy 3 to 1",ColorButtonNormal,20,function()
- --write values
- for i=0,1783,1 do
- memory.write_u8(0x001e88+i, memory.read_u8(0x002c78+i) )
- end
- --set "slots in use" flag
- memory.write_u8( 0x001e7e, bit.set(memory.read_u8(0x001e7e),0) )
- editedMemory=true
- end)
- -- copy 3 to 2
- drawButton(SavegamesX+3,SavegamesY+94,70,10,"copy 3 to 2",ColorButtonNormal,20,function()
- --write values
- for i=0,1783,1 do
- memory.write_u8(0x002580+i, memory.read_u8(0x002c78+i) )
- end
- --set "slots in use" flag
- memory.write_u8( 0x001e7e, bit.set(memory.read_u8(0x001e7e),1) )
- editedMemory=true
- end)
- -- current slot -> 1
- drawButton(SavegamesX+80,SavegamesY+34,80,10,"set slot=1",ColorButtonNormal,20,function()
- memory.usememorydomain("IWRAM")
- memory.write_u8( 0x000d40, bit.clear(memory.read_u8(0x000d40),2) )
- memory.write_u8( 0x000d40, bit.clear(memory.read_u8(0x000d40),3) )
- editedMemory=true
- memory.usememorydomain("EWRAM")
- end)
- -- current slot -> 2
- drawButton(SavegamesX+80,SavegamesY+46,80,10,"set slot=2",ColorButtonNormal,20,function()
- memory.usememorydomain("IWRAM")
- memory.write_u8( 0x000d40, bit.set(memory.read_u8(0x000d40),2) )
- memory.write_u8( 0x000d40, bit.clear(memory.read_u8(0x000d40),3) )
- editedMemory=true
- memory.usememorydomain("EWRAM")
- end)
- -- current slot -> 3
- drawButton(SavegamesX+80,SavegamesY+58,80,10,"set slot=3",ColorButtonNormal,20,function()
- memory.usememorydomain("IWRAM")
- memory.write_u8( 0x000d40, bit.set(memory.read_u8(0x000d40),3) )
- memory.write_u8( 0x000d40, bit.clear(memory.read_u8(0x000d40),2) )
- editedMemory=true
- memory.usememorydomain("EWRAM")
- end)
- -- wipe 1
- drawButton(SavegamesX+80,SavegamesY+70,80,10,"wipe slot 1",ColorButtonNormal,20,function()
- --delete values
- for i=0,1783,1 do
- memory.write_u8(0x001e88+i, 0 )
- end
- --set "slots in use" flag
- memory.write_u8( 0x001e7e, bit.clear(memory.read_u8(0x001e7e),0) )
- editedMemory=true
- end)
- -- wipe 2
- drawButton(SavegamesX+80,SavegamesY+82,80,10,"wipe slot 2",ColorButtonNormal,20,function()
- --delete values
- for i=0,1783,1 do
- memory.write_u8(0x002580+i, 0 )
- end
- --set "slots in use" flag
- memory.write_u8( 0x001e7e, bit.clear(memory.read_u8(0x001e7e),1) )
- editedMemory=true
- end)
- -- wipe 3
- drawButton(SavegamesX+80,SavegamesY+94,80,10,"wipe slot 3",ColorButtonNormal,20,function()
- --delete values
- for i=0,1783,1 do
- memory.write_u8(0x002c78+i, 0 )
- end
- --set "slots in use" flag
- memory.write_u8( 0x001e7e, bit.clear(memory.read_u8(0x001e7e),2) )
- editedMemory=true
- end)
- -- close button
- drawCloseButton(SavegamesX,SavegamesY,width,function()
- Settings["BoolEditSavegames"]=false
- if Settings["BoolNotifications"] then print("Edit Savegames Display has been closed.") end
- end)
- -- other text:
- text(3+SavegamesX,SavegamesY,"Edit Savegames",0xFF808080)
- --text(3+SavegamesX,58+SavegamesY,"sry, can't finish as long\nas I don't understand\nchecksums...",0xFFFF8020)
- end
- client.setwindowsize(2)
- while true do
- memory.usememorydomain("EWRAM")
- X = input.getmouse().X + PaddingLeft
- Y = input.getmouse().Y + PaddingTop
- clicked = input.getmouse().Left
- if clicked then clickedFrames = clickedFrames + 1
- else clickedFrames = 0 end
- drawEditSavegames()
- XBefore=X
- YBefore=Y
- emu.frameadvance()
- clicked=false
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement