-- Original script by AleMastroianni
-- Awards structure in ram provided by Drashed, his excel was really helpful
-- Console.log version provided by ThunderAxe31, modifying the original script
-- Thanks to ThunderAxe31 for the tips, it was my first script, never coded anything before this, hopefully its useful for research
-- Thanks to Natty for the pics resizing, that improved performance when drawing lots of png's
local AWARD1 = 0x8FBA4
local AWARD2 = 0x8FBA8
local AWARD3 = 0x8FBAC
local AWARD4 = 0x8FBB0
local AWARD5 = 0x8FBB4
local CASTLE_SAPPHIRE, TUBES_PLATINUM, JOE_KEY = 0x1, 0x1, 0x1
local LABS_SAPPHIRE, SKYWAY_PLATINUM, PINSTRIPE_KEY = 0x2, 0x2, 0x2
local PASS_SAPPHIRE, SPEEDWAY_PLATINUM, OXIDE_STAR = 0x4, 0x4, 0x4
local STATION_SAPPHIRE, CAVES_PLATINUM = 0x8, 0x8
local PARK_SAPPHIRE, CASTLE_PLATINUM = 0x10, 0x10
local ARENA_SAPPHIRE, LABS_PLATINUM = 0x20, 0x20
local CANYON_TROPHY, COLISEUM_SAPPHIRE, PASS_PLATINUM = 0x40, 0x40, 0x40
local MINES_TROPHY, TURBO_SAPPHIRE, STATION_PLATINUM = 0x80, 0x80, 0x80
local BLUFF_TROPHY, CANYON_GOLD, PARK_PLATINUM = 0x100, 0x100, 0x100
local COVE_TROPHY, MINES_GOLD, ARENA_PLATINUM = 0x200, 0x200, 0x200
local TEMPLE_TROPHY, BLUFF_GOLD, COLISEUM_PLATINUM, RED_GEM = 0x400, 0x400, 0x400, 0x400
local PYRAMID_TROPHY, COVE_GOLD, TURBO_PLATINUM, GREEN_GEM = 0x800, 0x800, 0x800, 0x800
local TUBES_TROPHY, TEMPLE_GOLD, CANYON_TOKEN, BLUE_GEM = 0x1000, 0x1000, 0x1000, 0x1000
local SKYWAY_TROPHY, PYRAMID_GOLD, MINES_TOKEN, YELLOW_GEM = 0x2000, 0x2000, 0x2000, 0x2000
local SPEEDWAY_TROPHY, TUBES_GOLD, BLUFF_TOKEN, PURPLE_GEM = 0x4000, 0x4000, 0x4000, 0x4000
local CAVES_TROPHY, SKYWAY_GOLD, COVE_TOKEN, SKULL_ROCK_TOKEN = 0x8000, 0x8000, 0x8000, 0x8000
local CASTLE_TROPHY, SPEEDWAY_GOLD, TEMPLE_TOKEN, RAMPAGE_RUINS_TOKEN = 0x10000, 0x10000, 0x10000, 0x10000
local LABS_TROPHY, CAVES_GOLD, PYRAMID_TOKEN, ROCKY_ROAD_TOKEN = 0x20000, 0x20000, 0x20000, 0x20000
local PASS_TROPHY, CASTLE_GOLD, TUBES_TOKEN, NITRO_COURT_TOKEN = 0x40000, 0x40000, 0x40000, 0x40000
local STATION_TROPHY, LABS_GOLD, SKYWAY_TOKEN = 0x80000, 0x80000, 0x80000
local PARK_TROPHY, PASS_GOLD, SPEEDWAY_TOKEN = 0x100000, 0x100000, 0x100000
local ARENA_TROPHY, STATION_GOLD, CAVES_TOKEN = 0x200000, 0x200000, 0x200000
local CANYON_SAPPHIRE, PARK_GOLD, CASTLE_TOKEN = 0x400000, 0x400000, 0x400000
local MINES_SAPPHIRE, ARENA_GOLD, LABS_TOKEN = 0x800000, 0x800000, 0x800000
local BLUFF_SAPPHIRE, COLISEUM_GOLD, PASS_TOKEN = 0x1000000, 0x1000000, 0x1000000
local COVE_SAPPHIRE, TURBO_GOLD, STATION_TOKEN = 0x2000000, 0x2000000, 0x2000000
local TEMPLE_SAPPHIRE, CANYON_PLATINUM, PARK_TOKEN = 0x4000000,0x4000000, 0x4000000
local PYRAMID_SAPPHIRE, MINES_PLATINUM, ARENA_TOKEN = 0x8000000, 0x8000000, 0x8000000
local TUBES_SAPPHIRE, BLUFF_PLATINUM = 0x10000000, 0x10000000
local SKYWAY_SAPPHIRE, COVE_PLATINUM = 0x20000000, 0x20000000
local SPEEDWAY_SAPPHIRE, TEMPLE_PLATINUM, ROO_KEY = 0x40000000, 0x40000000, 0x40000000
local CAVES_SAPPHIRE, PYRAMID_PLATINUM, PAPU_KEY = 0x80000000, 0x80000000, 0x80000000
local AWARD1_value_old = memory.read_u32_le( AWARD1 )
local AWARD2_value_old = memory.read_u32_le( AWARD2 )
local AWARD3_value_old = memory.read_u32_le( AWARD3 )
local AWARD4_value_old = memory.read_u32_le( AWARD4 )
local AWARD5_value_old = memory.read_u32_le( AWARD5 )
local framecount = -1
while true do
--this is necessary to check if a state was loaded, in order to prevent false positives
if framecount ~= emu.framecount()-1 then
AWARD1_value_old = memory.read_u32_le( AWARD1 )
AWARD2_value_old = memory.read_u32_le( AWARD2 )
AWARD3_value_old = memory.read_u32_le( AWARD3 )
AWARD4_value_old = memory.read_u32_le( AWARD4 )
AWARD5_value_old = memory.read_u32_le( AWARD5 )
end
framecount = emu.framecount()
--check for AWARD1 items
local AWARD1_value = memory.read_u32_le( AWARD1 )
if AWARD1_value > AWARD1_value_old then
local test_value = AWARD1_value -AWARD1_value_old
if bit.band (test_value, COVE_TROPHY) == 0x200 then
console.log("At frame " .. emu.framecount() .. " you got Cove Trophy")
end
if bit.band (test_value,COVE_SAPPHIRE) == 0x2000000 then
console.log("At frame " .. emu.framecount() .. " you got Cove Sapphire")
end
if bit.band (test_value, TUBES_TROPHY) == 0x1000 then
console.log("At frame " .. emu.framecount() .. " you got Tubes Trophy")
end
if bit.band (test_value,TUBES_SAPPHIRE) == 0x10000000 then
console.log("At frame " .. emu.framecount() .. " you got Tubes Sapphire")
end
if bit.band (test_value, CAVES_TROPHY) == 0x8000 then
console.log("At frame " .. emu.framecount() .. " you got Caves Trophy")
end
if bit.band (test_value,CAVES_SAPPHIRE) == 0x80000000 then
console.log("At frame " .. emu.framecount() .. " you got Caves Sapphire")
end
if bit.band (test_value, SPEEDWAY_TROPHY) == 0x4000 then
console.log("At frame " .. emu.framecount() .. " you got Speedway Trophy")
end
if bit.band (test_value,SPEEDWAY_SAPPHIRE) == 0x40000000 then
console.log("At frame " .. emu.framecount() .. " you got Speedway Sapphire")
end
if bit.band (test_value, TEMPLE_TROPHY) == 0x400 then
console.log("At frame " .. emu.framecount() .. " you got Temple Trophy")
end
if bit.band (test_value,TEMPLE_SAPPHIRE) == 0x4000000 then
console.log("At frame " .. emu.framecount() .. " you got Temple Sapphire")
end
if bit.band (test_value, PARK_TROPHY) == 0x100000 then
console.log("At frame " .. emu.framecount() .. " you got Park Trophy")
end
if bit.band (test_value, PYRAMID_TROPHY) == 0x800 then
console.log("At frame " .. emu.framecount() .. " you got Pyramid Trophy")
end
if bit.band (test_value, CANYON_TROPHY) == 0x40 then
console.log("At frame " .. emu.framecount() .. " you got Canyon Trophy")
end
if bit.band (test_value, CANYON_SAPPHIRE) == 0x400000 then
console.log("At frame " .. emu.framecount() .. " you got Canyon Sapphire")
end
if bit.band (test_value, BLUFF_TROPHY) == 0x100 then
console.log("At frame " .. emu.framecount() .. " you got Bluff Trophy")
end
if bit.band (test_value, BLUFF_SAPPHIRE) == 0x1000000 then
console.log("At frame " .. emu.framecount() .. " you got Bluff Sapphire")
end
if bit.band (test_value, MINES_TROPHY) == 0x80 then
console.log("At frame " .. emu.framecount() .. " you got Mines Trophy")
end
if bit.band (test_value, MINES_SAPPHIRE) == 0x800000 then
console.log("At frame " .. emu.framecount() .. " you got Mines Sapphire")
end
if bit.band (test_value, PASS_TROPHY) == 0x40000 then
console.log("At frame " .. emu.framecount() .. " you got Pass Trophy")
end
if bit.band (test_value, PASS_SAPPHIRE) == 0x4 then
console.log("At frame " .. emu.framecount() .. " you got Pass Sapphire")
end
if bit.band (test_value, ARENA_TROPHY) == 0x200000 then
console.log("At frame " .. emu.framecount() .. " you got Arena Trophy")
end
if bit.band (test_value, LABS_TROPHY) == 0x20000 then
console.log("At frame " .. emu.framecount() .. " you got Labs Trophy")
end
if bit.band (test_value, CASTLE_TROPHY) == 0x10000 then
console.log("At frame " .. emu.framecount() .. " you got Castle Trophy")
end
if bit.band (test_value, SKYWAY_TROPHY) == 0x2000 then
console.log("At frame " .. emu.framecount() .. " you got Skyway Trophy")
end
if bit.band (test_value, SKYWAY_SAPPHIRE) == 0x20000000 then
console.log("At frame " .. emu.framecount() .. " you got Skyway Sapphire")
end
if bit.band (test_value, STATION_TROPHY) == 0x80000 then
console.log("At frame " .. emu.framecount() .. " you got Station Trophy")
end
end
AWARD1_value_old = AWARD1_value
--check for AWARD2 items
local AWARD2_value = memory.read_u32_le( AWARD2 )
if AWARD2_value > AWARD2_value_old then
local test_value = AWARD2_value -AWARD2_value_old
if bit.band (test_value,COVE_GOLD) == 0x800 then
console.log("At frame " .. emu.framecount() .. " you got Cove Gold")
end
if bit.band (test_value,COVE_PLATINUM) == 0x20000000 then
console.log("At frame " .. emu.framecount() .. " you got Cove Platinum")
end
if bit.band (test_value,TUBES_GOLD) == 0x4000 then
console.log("At frame " .. emu.framecount() .. " you got Tubes Gold")
end
if bit.band (test_value,CAVES_GOLD) == 0x20000 then
console.log("At frame " .. emu.framecount() .. " you got Caves Gold")
end
if bit.band (test_value,SPEEDWAY_GOLD) == 0x10000 then
console.log("At frame " .. emu.framecount() .. " you got Speedway Gold")
end
if bit.band (test_value,TEMPLE_GOLD) == 0x1000 then
console.log("At frame " .. emu.framecount() .. " you got Temple Gold")
end
if bit.band (test_value,TEMPLE_PLATINUM) == 0x40000000 then
console.log("At frame " .. emu.framecount() .. " you got Temple Platinum")
end
if bit.band (test_value, PARK_SAPPHIRE) == 0x10 then
console.log("At frame " .. emu.framecount() .. " you got Park Sapphire")
end
if bit.band (test_value, PARK_GOLD) == 0x400000 then
console.log("At frame " .. emu.framecount() .. " you got Park Gold")
end
if bit.band (test_value, PYRAMID_GOLD) == 0x2000 then
console.log("At frame " .. emu.framecount() .. " you got Pyramid Gold")
end
if bit.band (test_value, PYRAMID_PLATINUM) == 0x80000000 then
console.log("At frame " .. emu.framecount() .. " you got Pyramid Platinum")
end
if bit.band (test_value, CANYON_GOLD) == 0x100 then
console.log("At frame " .. emu.framecount() .. " you got Canyon Gold")
end
if bit.band (test_value, CANYON_PLATINUM) == 0x4000000 then
console.log("At frame " .. emu.framecount() .. " you got Canyon Platinum")
end
if bit.band (test_value, BLUFF_GOLD) == 0x400 then
console.log("At frame " .. emu.framecount() .. " you got Bluff Gold")
end
if bit.band (test_value, BLUFF_PLATINUM) == 0x10000000 then
console.log("At frame " .. emu.framecount() .. " you got Bluff Platinum")
end
if bit.band (test_value, MINES_GOLD) == 0x200 then
console.log("At frame " .. emu.framecount() .. " you got Mines Gold")
end
if bit.band (test_value, MINES_PLATINUM) == 0x8000000 then
console.log("At frame " .. emu.framecount() .. " you got Mines Platinum")
end
if bit.band (test_value, PASS_GOLD) == 0x100000 then
console.log("At frame " .. emu.framecount() .. " you got Pass Gold")
end
if bit.band (test_value, ARENA_SAPPHIRE) == 0x20 then
console.log("At frame " .. emu.framecount() .. " you got Arena Sapphire")
end
if bit.band (test_value, ARENA_GOLD) == 0x800000 then
console.log("At frame " .. emu.framecount() .. " you got Arena Gold")
end
if bit.band (test_value, LABS_SAPPHIRE) == 0x2 then
console.log("At frame " .. emu.framecount() .. " you got Labs Sapphire")
end
if bit.band (test_value, LABS_GOLD) == 0x80000 then
console.log("At frame " .. emu.framecount() .. " you got Labs Gold")
end
if bit.band (test_value, CASTLE_SAPPHIRE) == 0x1 then
console.log("At frame " .. emu.framecount() .. " you got Castle Sapphire")
end
if bit.band (test_value, CASTLE_GOLD) == 0x40000 then
console.log("At frame " .. emu.framecount() .. " you got Castle Gold")
end
if bit.band (test_value, SKYWAY_GOLD) == 0x8000 then
console.log("At frame " .. emu.framecount() .. " you got Skyway Gold")
end
if bit.band (test_value, STATION_SAPPHIRE) == 0x8 then
console.log("At frame " .. emu.framecount() .. " you got Station Sapphire")
end
if bit.band (test_value, STATION_GOLD) == 0x200000 then
console.log("At frame " .. emu.framecount() .. " you got Station Gold")
end
if bit.band (test_value, COLISEUM_SAPPHIRE) == 0x40 then
console.log("At frame " .. emu.framecount() .. " you got Coliseum Sapphire")
end
if bit.band (test_value, COLISEUM_GOLD) == 0x1000000 then
console.log("At frame " .. emu.framecount() .. " you got Coliseum Gold")
end
if bit.band (test_value, COLISEUM_PLATINUM) == 0x400 then
console.log("At frame " .. emu.framecount() .. " you got Coliseum Platinum")
end
if bit.band (test_value, TURBO_SAPPHIRE) == 0x80 then
console.log("At frame " .. emu.framecount() .. " you got Turbo Sapphire")
end
if bit.band (test_value, TURBO_GOLD) == 0x2000000 then
console.log("At frame " .. emu.framecount() .. " you got Turbo Gold")
end
end
AWARD2_value_old = AWARD2_value
--check for AWARD3 items
local AWARD3_value = memory.read_u32_le( AWARD3 )
if AWARD3_value > AWARD3_value_old then
local test_value = AWARD3_value -AWARD3_value_old
if bit.band (test_value, COVE_TOKEN) == 0x8000 then
console.log("At frame " .. emu.framecount() .. " you got Cove Token")
end
if bit.band (test_value, TUBES_TOKEN) == 0x40000 then
console.log("At frame " .. emu.framecount() .. " you got Tubes Token")
end
if bit.band (test_value,TUBES_PLATINUM) == 0x1 then
console.log("At frame " .. emu.framecount() .. " you got Tubes Platinum")
end
if bit.band (test_value, CAVES_TOKEN) == 0x200000 then
console.log("At frame " .. emu.framecount() .. " you got Cave Token")
end
if bit.band (test_value,CAVES_PLATINUM) == 0x8 then
console.log("At frame " .. emu.framecount() .. " you got Cave Platinum")
end
if bit.band (test_value, SPEEDWAY_TOKEN) == 0x100000 then
console.log("At frame " .. emu.framecount() .. " you got Speedway Token")
end
if bit.band (test_value,SPEEDWAY_PLATINUM) == 0x4 then
console.log("At frame " .. emu.framecount() .. " you got Speedway Platinum")
end
if bit.band (test_value, TEMPLE_TOKEN) == 0x10000 then
console.log("At frame " .. emu.framecount() .. " you got Temple Token")
end
if bit.band (test_value, PARK_TOKEN) == 0x4000000 then
console.log("At frame " .. emu.framecount() .. " you got Park Token")
end
if bit.band (test_value, PARK_PLATINUM) == 0x100 then
console.log("At frame " .. emu.framecount() .. " you got Park Platinum")
end
if bit.band (test_value, PYRAMID_TOKEN) == 0x20000 then
console.log("At frame " .. emu.framecount() .. " you got Pyramid Token")
end
if bit.band (test_value, CANYON_TOKEN) == 0x1000 then
console.log("At frame " .. emu.framecount() .. " you got Canyon Token")
end
if bit.band (test_value, BLUFF_TOKEN) == 0x4000 then
console.log("At frame " .. emu.framecount() .. " you got Bluff Token")
end
if bit.band (test_value, MINES_TOKEN) == 0x2000 then
console.log("At frame " .. emu.framecount() .. " you got Mines Token")
end
if bit.band (test_value, PASS_TOKEN) == 0x1000000 then
console.log("At frame " .. emu.framecount() .. " you got Pass Token")
end
if bit.band (test_value, PASS_PLATINUM) == 0x40 then
console.log("At frame " .. emu.framecount() .. " you got Pass Platinum")
end
if bit.band (test_value, ARENA_TOKEN) == 0x8000000 then
console.log("At frame " .. emu.framecount() .. " you got Arena Token")
end
if bit.band (test_value, ARENA_PLATINUM) == 0x200 then
console.log("At frame " .. emu.framecount() .. " you got Arena Platinum")
end
if bit.band (test_value, LABS_TOKEN) == 0x800000 then
console.log("At frame " .. emu.framecount() .. " you got Labs Token")
end
if bit.band (test_value, LABS_PLATINUM) == 0x20 then
console.log("At frame " .. emu.framecount() .. " you got Labs Platinum")
end
if bit.band (test_value, CASTLE_TOKEN) == 0x400000 then
console.log("At frame " .. emu.framecount() .. " you got Castle Token")
end
if bit.band (test_value, CASTLE_PLATINUM) == 0x10 then
console.log("At frame " .. emu.framecount() .. " you got Castle Platinum")
end
if bit.band (test_value, SKYWAY_TOKEN) == 0x80000 then
console.log("At frame " .. emu.framecount() .. " you got Skyway Token")
end
if bit.band (test_value, SKYWAY_PLATINUM) == 0x2 then
console.log("At frame " .. emu.framecount() .. " you got Skyway Platinum")
end
if bit.band (test_value, STATION_TOKEN) == 0x2000000 then
console.log("At frame " .. emu.framecount() .. " you got Station Token")
end
if bit.band (test_value, STATION_PLATINUM) == 0x80 then
console.log("At frame " .. emu.framecount() .. " you got Station Platinum")
end
if bit.band (test_value, TURBO_PLATINUM) == 0x800 then
console.log("At frame " .. emu.framecount() .. " you got Turbo Platinum")
end
if bit.band (test_value, ROO_KEY) == 0x40000000 then
console.log("At frame " .. emu.framecount() .. " you got Roo Key")
end
if bit.band (test_value, PAPU_KEY) == 0x80000000 then
console.log("At frame " .. emu.framecount() .. " you got Papu Key")
end
end
AWARD3_value_old = AWARD3_value
--check for AWARD4 items
local AWARD4_value = memory.read_u32_le( AWARD4 )
if AWARD4_value > AWARD4_value_old then
local test_value = AWARD4_value -AWARD4_value_old
if bit.band (test_value, SKULL_ROCK_TOKEN) == 0x8000 then
console.log("At frame " .. emu.framecount() .. " you got Skull Rock Token")
end
if bit.band (test_value, RAMPAGE_RUINS_TOKEN) == 0x10000 then
console.log("At frame " .. emu.framecount() .. " you got Rampage Ruins Token")
end
if bit.band (test_value, ROCKY_ROAD_TOKEN) == 0x20000 then
console.log("At frame " .. emu.framecount() .. " you got Rocky Road Token")
end
if bit.band (test_value, NITRO_COURT_TOKEN) == 0x40000 then
console.log("At frame " .. emu.framecount() .. " you got Nitro Court Token")
end
if bit.band (test_value, RED_GEM) == 0x400 then
console.log("At frame " .. emu.framecount() .. " you got Red Gem")
end
if bit.band (test_value, BLUE_GEM) == 0x1000 then
console.log("At frame " .. emu.framecount() .. " you got Blue Gem")
end
if bit.band (test_value, GREEN_GEM) == 0x800 then
console.log("At frame " .. emu.framecount() .. " you got Green Gem")
end
if bit.band (test_value, YELLOW_GEM) == 0x2000 then
console.log("At frame " .. emu.framecount() .. " you got Yellow Gem")
end
if bit.band (test_value, PURPLE_GEM) == 0x4000 then
console.log("At frame " .. emu.framecount() .. " you got Purple Gem")
end
if bit.band (test_value, JOE_KEY) == 0x1 then
console.log("At frame " .. emu.framecount() .. " you got Joe Key")
end
if bit.band (test_value, PINSTRIPE_KEY) == 0x2 then
console.log("At frame " .. emu.framecount() .. " you got Pinstripe Key")
end
if bit.band (test_value, OXIDE_STAR) == 0x4 then
console.log("At frame " .. emu.framecount() .. " you got Oxide Star")
end
end
AWARD4_value_old = AWARD4_value
--check for AWARD5 items
local AWARD5_value = memory.read_u32_le( AWARD5 )
if AWARD5_value > AWARD5_value_old then
local test_value = AWARD5_value -AWARD5_value_old
end
AWARD5_value_old = AWARD5_value
emu.frameadvance()
end