-- List of variables about player's information -- 0x09 = Current Selected sub-level -- 0x0A = Current selected level (main) -- 0x6005 = Player Setting, 00: English, 01: Japanese -- 0x60E0 to 0x60EA = Players name stored in 11 characters -- 0x60F0 to 0x60FA = Japanese dakutens, in 11 characters -- 0x6100 to 0x61FF = Time Attack records, 5 byte format per level -- 0x6200 to 0x62FF = Challenges Completed, 00: Not done, 01: Done ----------------------------------------------------------------- -- start coding here, lets get player's stats first. local function wait1() -- memory.writebyte(0x6006, 0x01) while (memory.readbyte(0x6006) == 0x00) do -- wait1() FCEU.frameadvance() end Player_Name = {} JP_Dakuten = {} Level_Time = {} Name_Lang = memory.readbyte(0x6005) for a = 1, 11 do Player_Name[a] = memory.readbyte(0x60DF + a) JP_Dakuten[a] = memory.readbyte(0x60EF + a) end -- Calculate current selected level here a = AND (rom.readbyte(0x43CF1 + memory.readbyte(0x0A)), 0x0F) if (memory.readbyte(0x09) == 0x00) then a = rom.readbyte(0x42280 + a) end a = a*5 -- Location was found -- Read current selected level's Time Attack score here, 5 byte -- format for each level. Minute, seconds, milliseconds for b = 1, 5 do Level_Time[b] = memory.readbyte(0x60FF + a + b) end --------------------------------------------------------------- -- Send player stats to online leaderboard -- no idea how to do online stuff yet, this is placeholder --------------------------------------------------------------- -- Receiving back data from internet, only download 1 page at a time, 10 slots, and let's use Temporary RAM 7B00-7EFF OffsetAdd = 0x00 for a = 1, 1024 do -- Clear RAM for use memory.writebyte(0x7AFF + a, 0x00) end for b = 1, 10 do Slot1_Name = {0x53, 0x72, 0x6B, 0x71, 0xFE, 0x65, 0x72, 0x65, 0xFE, 0xFE, 0xFE} Slot1_Daku = {0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE} Slot1_Time = {0x05, 0x04, 0x05, 0x07, 0x03} Slot1_Sett = 0x00 -- Lang Setting - JP/EN, 1 byte 7B1B -- Player's Name is 11 bytes long, 7B00 to 7B0A -- Dakutens 11 bytes, 7B10 to 7B1A -- Level Time is 5 bytes 7B0B to 7B0F for a = 1, 11 do memory.writebyte(0x7AFF + a + OffsetAdd, Slot1_Name[a]) memory.writebyte(0x7B0F + a + OffsetAdd, Slot1_Daku[a]) end for a = 1, 5 do memory.writebyte(0x7B0A + a + OffsetAdd, Slot1_Time[a]) end memory.writebyte(0x7B1B + OffsetAdd, Slot1_Sett) OffsetAdd = OffsetAdd + 0x20 -- add +20, Ex: Slot 1: 7B00~, Slot2: 7B20, etc. end --------------------------------------------------------------- -- Print debugging messages for testing print ("Level: ", memory.readbyte(0x0A), "+ Area: ", memory.readbyte(0x09)) print ("Time: ", Level_Time) if Name_Lang == 0 then print ("Setting: English") else print ("Setting: Japanese") end print ("Name: ", Player_Name) -- The lua automatically shows decimal numbers print ("Dakuten: ", JP_Dakuten) -- English names are always filled with FE (254), otherwise show them for japanese names emu.frameadvance() memory.writebyte(0x6006, 0x00) end while (true) do wait1(); FCEU.frameadvance(); end