okay so basically this trick almost gives you infinite savedata
first, choose a memory address above 0x7fff to represent a progress counter, a memory address above 0x7fff to represent if the game has already set the progress counter to 0, a memory address above 0x7fff to represent the progress before updating, a memory address to declare if the game has started, a variable declaring if the game is calibrating the save values, and a variable inside the game declaring how many extra groups of 64 savedata values are required.
second, in the _init function, set the initial progress counter to the actual progress counter. make an if statement which checks if the progress counter is equal or over the limit. inside that statement, run cartdata with an id concatenated with the progress, set a group of memory addresses to the cartdata values, change the progress counter by one by using the initial progress counter, and then finally load the cartridge again.
third, in the _update function, add an if statement which checks if the game has started. move all of the previous code inside of the _update function into that statement.
your code by now should look something like this:
function calibrate_save(index) for i=0,63 do poke(0x8000+index*0x40+i+range_start,dget(i)) end end --0xffff=calibration progress --0xfffe=pre-updated calibration progress --0xfffd=if has set initial calibration --0xfffc=if has started game function _init() is_calibrating=false saveids=4 range_start=0x0000 if peek(0xfffd)!=1 then poke(0xffff,0) poke(0xfffd,1) end poke(0xfffe,peek(0xffff)) if peek(0xffff)<saveids then is_calibrating=true cartdata("mygameid_decomp" .. peek(0xffff)) calibrate_save(peek(0xffff)) poke(0xffff,peek(0xfffe)) load("mygame.p8" or "#mygame") end end function _update() if not is_calibrating then -- ... end end |
all this does is use a different cartdata id for each initial runtime moment, then restarts if the values have been set, and if they have to be set.
to access the save data values, get the designated memory address within the group of memory addresses.
to save from within the game, you need to make a menuitem, which basically does the same exact thing when it calibrates the values at the start, except instead of the addresses being set, the save values are set by the addresses e.g:
--0xfffb=if is saving function _init() is_calibrating=false saveids=4 range_start=0x0000 if peek(0xfffd)!=1 then poke(0xffff,0) poke(0xfffb,0) poke(0xfffd,1) end poke(0xfffe,peek(0xffff)) if peek(0xffff)>=saveids then poke(0xfffb,0) end if peek(0xfffb)==1 then cartdata("mygameid_decomp" .. peek(0xffff)) save(peek(0xffff)) load("mygame.p8" or "#mygame") end if peek(0xffff)<saveids and peek(0xfffb)!=1 then is_calibrating=true cartdata("mygameid_decomp" .. peek(0xffff)) calibrate_save(peek(0xffff)) poke(0xffff,peek(0xfffe)) load("mygame.p8" or "#mygame") end end function save(index) for i=0,63 do dset(i,peek(0x8000+i+range_start+index*0x40)) end end function _update() if not is_calibrating then menuitem(1,"save",function() poke(0xffff,0) poke(0xfffb,1) load("mygame.p8" or "#mygame") end) --... end end |
just another minor exploit :)
[Please log in to post a comment]