Log In  

This is a function that will generate cart's guid (used for cartdata function) based on things specific to the cartridge (mapdata, gfx, sfx and code).

function getcartguid()
  reload(0x4300,0x4300,7168)
  alphabet = "1234567890abcdefghijklmnopqrstuvwxyz_1234567890abcdefghijklmnopqrstuvwxyz_1234567890abcdefghijklmnopqrstuvwxyz_1234567890abcdefghijklmnopqrstuvwxyz_1234567890abcdefghijklmnopqrstuvwxyz_1234567890abcdefghijklmnopqrstuvwxyz_1234567890abcdefghijklmnopqrstuvwx"
        guid = ""
        for i=0,15 do
          num = peek (0x0+i)
          guid = guid .. sub(alphabet,num+1,num+1)
        end
        for i=0,15 do
          num = peek (0x2000+i)
          guid = guid .. sub(alphabet,num+1,num+1)
        end
        for i=0,15 do
          num = peek (0x3200+i)
          guid = guid .. sub(alphabet,num+1,num+1)
        end
        for i=0,15 do
          num = peek (0x43af+i)
          guid = guid .. sub(alphabet,num+1,num+1)
        end
        --print (#guid)
        --print (guid)
        return guid
end

Probably it could've been more optimized, but I am pretty sure it will work correctly. Resulting string will be
somewhat random, but will be unique as no two carts have same map, gfx, sfx and code and overlap in areas
checked by the function is minimal between different carts.

P#14891 2015-10-02 20:33 ( Edited 2015-10-03 00:34)


[Please log in to post a comment]