Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Hotkeys:
- R: Toggle running the display
- D: Print your deck to the console
- S: Print their deck to the console if you really want??
- C: Cheat your deck to have Comp Search/PP/Sneak (good for having no basics in hand)
- B: Cheat your deck to have all Bulbasaurs (good for having basics in hand)
- (These are also toggles, press it again to get your old deck back)
- A: Toggle auto-advance text (good for intro)
- TAStudio open only:
- Q/W/E: Enter your file from the Press Start screen early, easy, or 1 frame late
- ]]
- local nome = {"Grass_Energy","Fire_Energy","Water_Energy",
- "Lightning_Energy","Fighting_Energy","Psychic_Energy","Double_Colorless_Energy",
- "Potion_Energy","Full_Heal_Energy","Rainbow_Energy","Recycle_Energy",
- "Bulbasaur_LV12","Bulbasaur_LV13","Bulbasaur_LV15",
- "Ivysaur_LV20","Ivysaur_LV26","Dark_Ivysaur","Venusaur_LV64(CP!)","Venusaur_LV67",
- "Venusaur_LV67","Dark_Venusaur",
- "Caterpie_LV13","Metapod_LV20","Metapod_LV21","Butterfree_LV28",
- "Weedle_LV12","Weedle_LV15","Kakuna_LV20","Kakuna_LV23",
- "Beedrill_LV32","Ekans_LV10","Ekans_LV15","Arbok_LV27","Arbok_LV30","Dark_Arbok",
- "NidoranF_LV12","NidoranF_LV13","Nidorina_LV22","Nidorina_LV24",
- "Nidoqueen_LV43","NidoranM_LV20","NidoranM_LV22","Nidorino_LV23","Nidorino_LV25",
- "Nidoking_LV48","Zubat_LV9","Zubat_LV10","Zubat_LV12",
- "Golbat_LV25","Golbat_LV29","Dark_Golbat","Oddish_LV8","Oddish_LV21",
- "Gloom_LV22","Dark_Gloom","Vileplume_LV35","Dark_Vileplume","Paras_LV8",
- "Paras_LV15","Parasect_LV28","Parasect_LV29","Venonat_LV12","Venonat_LV15",
- "Venomoth_LV22","Venomoth_LV28","Bellsprout_LV10","Bellsprout_LV11",
- "Weepinbell_LV23","Weepinbell_LV28","Victreebel_LV42","Grimer_LV10","Grimer_LV17",
- "Muk_LV34","Dark_Muk","Exeggcute_LV14","Exeggutor_LV35",
- "Koffing_LV12","Koffing_LV13","Koffing_LV14","Weezing_LV26","Weezing_LV27",
- "Dark_Weezing","Tangela_LV8_(GB)","Tangela_LV12","Scyther_LV23","Scyther_LV25",
- "Pinsir_LV15","Pinsir_LV24","Charmander_LV9","Charmander_LV10","Charmander_LV12",
- "Charmeleon_LV32","Dark_Charmeleon","Charizard_LV76","Charizard_LV76","Dark_Charizard",
- "Vulpix_LV11","Vulpix_LV13","Ninetales_LV32","Ninetales_LV35_(GB)","Dark_Ninetales",
- "Growlithe_LV12","Growlithe_LV16","Growlithe_LV18","Arcanine_LV34_(Promo)",
- "Arcanine_LV35","Arcanine_LV45","Ponyta_LV8","Ponyta_LV10","Ponyta_LV15",
- "Rapidash_LV30","Rapidash_LV33","Dark_Rapidash","Magmar_LV18","Magmar_LV24",
- "Magmar_LV27","Magmar_LV31_(Fossil)",
- "Flareon_LV22_(GB)","Flareon_LV28_(Jungle)","Dark_Flareon","Moltres_LV35",
- "Moltres_LV37","Legendary_Moltres_LV40","Squirtle_LV8","Squirtle_LV14",
- "Squirtle_LV15","Squirtle_LV16","Wartortle_LV22","Wartortle_LV24",
- "Dark_Wartortle","Blastoise_LV52","Blastoise_LV52","Dark_Blastoise",
- "Psyduck_LV15","Psyduck_LV16","Golduck_LV27","Golduck_LV28","Dark_Golduck",
- "Poliwag_LV13","Poliwag_LV15","Poliwhirl_LV28","Poliwhirl_LV30","Poliwrath_LV40",
- "Poliwrath_LV48","Tentacool_LV10","Tentacruel_LV21",
- "Seel_LV10","Seel_LV12","Dewgong_LV24","Dewgong_LV42","Shellder_LV8","Shellder_LV16",
- "Cloyster_LV25","Krabby_LV17","Krabby_LV20","Kingler_LV27","Kingler_LV33",
- "Horsea_LV19","Horsea_LV20","Seadra_LV23","Seadra_LV26",
- "Goldeen_LV12","Seaking_LV28","Staryu_LV15","Staryu_LV17","Starmie_LV28","Dark_Starmie",
- "Magikarp_LV6","Magikarp_LV8","Magikarp_LV10",
- "Gyarados_LV41","Dark_Gyarados","Lapras_LV24","Lapras_LV31",
- "Vaporeon_LV29_(GB)","Vaporeon_LV42_(Jungle)","Dark_Vaporeon",
- "Omanyte_LV19","Omanyte_LV20","Omanyte_LV22","Omastar_LV32","Omastar_LV36",
- "Articuno_LV34","Articuno_LV35","Legendary_Articuno_LV37","Marill",
- "Pikachu_LV5","Pikachu_LV12","Pikachu_LV13","Pikachu_LV14_(Jungle)","Pikachu_LV16_(promo)",
- "Pikachu_LV16_(promo2)","Flying_Pikachu_LV12","Flying_Pikachu_LV12","Surfing_Pikachu_LV13",
- "Surfing_Pikachu_LV13","Raichu_LV32","Raichu_LV33","Raichu_LV40",
- "Raichu_LV45_(Fossil)","Dark_Raichu","Magnemite_LV12","Magnemite_LV13","Magnemite_LV14",
- "Magnemite_LV15_(GB)","Magneton_LV28","Magneton_LV30","Magneton_LV35_(Fossil)",
- "Dark_Magneton","Voltorb_LV8","Voltorb_LV10","Voltorb_LV13",
- "Electrode_LV35_(GB)","Electrode_LV42_(Jungle)","Dark_Electrode","Electabuzz_LV20_(Promo)",
- "Electabuzz_LV30","Electabuzz_LV35","Jolteon_LV24_(GB)","Jolteon_LV29","Dark_Jolteon",
- "Zapdos_LV28","Zapdos_LV40","Zapdos_LV64_(Fossil)","Legendary_Zapdos_LV68",
- "Sandshrew_LV12","Sandshrew_LV15","Sandslash_LV33","Sandslash_LV35",
- "Diglett_LV8","Diglett_LV15","Diglett_LV16","Dugtrio_LV36","Dugtrio_LV40","Dark_Dugtrio",
- "Mankey_LV7","Mankey_LV7","Mankey_LV14","Primeape_LV35","Dark_Primeape","Machop_LV18",
- "Machop_LV20","Machop_LV24","Machoke_LV24","Machoke_LV28","Machoke_LV40","Dark_Machoke",
- "Machamp_LV54","Machamp_LV67","Dark_Machamp","Geodude_LV15","Geodude_LV16",
- "Graveler_LV27","Graveler_LV28","Graveler_LV29","Golem_LV36","Golem_LV37",
- "Onix_LV12","Onix_LV25","Cubone_LV13","Cubone_LV14",
- "Marowak_LV26_(Jungle)","Marowak_LV32_(GB)","Dark_Marowak",
- "Hitmonlee_LV23","Hitmonlee_LV30","Hitmonchan_LV23","Hitmonchan_LV33",
- "Rhyhorn_LV18","Rhydon_LV37","Rhydon_LV48","Kabuto_LV9","Kabuto_LV22",
- "Kabutops_LV30","Aerodactlyl_LV28","Aerodactlyl_LV30",
- "Abra_LV8","Abra_LV10","Abra_LV14","Kadabra_LV38","Kadabra_LV39","Dark_Kadabra",
- "Alakazam_LV42","Alakazam_LV45","Dark_Alakazam",
- "Slowpoke_LV9_(Promo)","Slowpoke_LV16","Slowpoke_LV18_(Fossil)","Slowbro_LV26",
- "Slowbro_LV35","Dark_Slowbro","Gastly_LV8","Gastly_LV13","Gastly_LV17_(Fossil)",
- "Haunter_LV17_(Fossil)","Haunter_LV22","Haunter_LV25","Haunter_LV26","Dark_Haunter",
- "Gengar_LV38","Gengar_LV40","Dark_Gengar",
- "Drowzee_LV10","Drowzee_LV12","Hypno_LV30","Hypno_LV36","Dark_Hypno",
- "Mr.Mime_LV20","Mr.Mime_LV28","Jynx_LV18","Jynx_LV23","Jynx_LV27","Mewtwo_LV30","Mewtwo_LV53",
- "Mewtwo_LV54","Mewtwo_LV60_(Promo)","Mewtwo_LV60_(Promo_2)","Mewtwo_LV67",
- "GRs_Mewtwo","Mew_LV8_(Promo)","Mew_LV15_(CP!_Promo)","Mew_LV23",
- "Pidgey_LV8","Pidgey_LV10","Pidgeotto_LV36","Pidgeotto_LV38",
- "Pidgeot_LV38_(GB)","Pidgeot_LV40_(Jungle)","Rattata_LV9","Rattata_LV12","Rattata_LV15",
- "Raticate_LV41","Dark_Raticate","Spearow_LV9","Spearow_LV12",
- "Spearow_LV13","Fearow_LV24","Fearow_LV27","Dark_Fearow","Clefairy_LV14","Clefairy_LV15",
- "Clefable_LV34","Dark_Clefable",
- "Jigglypuff_LV12_(Promo)","Jigglypuff_LV13_(GB)","Jigglypuff_LV14_(Jungle)",
- "Wigglytuff_LV36","Wigglytuff_LV40","Meowth_LV10","Meowth_LV13",
- "Meowth_LV14_(GB)","Meowth_LV15_(Jungle)","Meowth_LV17","Persian_LV25","Dark_Persian",
- "Dark_Persian","Farfetch'd_LV20","Farfetch'd_LV20","Doduo_LV8",
- "Doduo_LV10","Dodrio_LV25","Dodrio_LV28","Lickitung_LV20","Lickitung_LV26",
- "Chansey_LV40","Chansey_LV55","Kangaskhan_LV36","Kangaskhan_LV38",
- "Kangaskhan_LV40","Tauros_LV32","Tauros_LV35","Ditto_LV19","Eevee_LV5","Eevee_LV9",
- "Eevee_LV12","Porygon_LV12","Porygon_LV18","Porygon_LV20","Cool_Porygon",
- "Snorlax_LV20","Snorlax_LV35","Hungry_Snorlax","Dratini_LV10",
- "Dratini_LV12","Dragonair_LV33","Dark_Dragonair","Legendary_Dragonite_LV41",
- "Dragonite_LV43","Dragonite_LV45","Dark_Dragonite","Togepi","Lugia",
- "Super_Potion","Imakuni?","Energy_Removal","Energy_Retrieval","Energy_Search",
- "Professor_Oak","Fossil_Excavation","Potion","Gambler","Revive","Max_Revive",
- "Super_Scoop_Up","Devolution_Spray","Item_Finder","Challenge!","Super_Energy_Retrieval",
- "Super_Energy_Removal","Moon_Stone","Defender","Gust_of_Wind","Mysterious_Fossil","Full_Heal",
- "Impostor_Oak's_Revenge","Impostor_Professor_Oak","Sleep!","Computer_Error!",
- "Computer_Search","Digger","Clefairy_Doll","Mr_Fuji","PlusPower","Switch","Scoop_Up",
- "Pokemon_Trader","Pokemon_Recall","Pokedex","Pokemon_Center","Pokemon_Breeder","Pokeflute",
- "The_Boss's_Way","Goop_Gas_Attack","Bill","Bill's_Teleporter","Bill's_Computer",
- "Master_Ball","Lass","Maintenance","Pokeball","Nightly_Garbage_Run","Recycle",
- "Rocket's_Sneak_Attack","Here_Comes_Team_Rocket!","The_Rocket's_Trap"}
- --163 Computer Search
- --167 PP
- --189, 1 for rocket's trap
- --C400 to C43B: IDs of deck
- memory.usememorydomain("System Bus")
- local DeckLocBegin=0xC300
- local MyDeckLocBegin=0xC200
- local DeckIDBegin=0xC480
- local MyDeckIDBegin=0xC400
- local ShuffledDeckBegin=0xC37E
- local MyShuffledDeckBegin=0xC27E
- local TopCard=0xC3BA
- local MyTopCard=0xC2BA
- --C23C: My prizes in order
- --C242: My hand in order
- --C33C: Their prizes (irrelevant)
- --C342: Their hand in order
- --C2C8: My pokemon's health
- local myDeckCards = {}
- local oppHand = {}
- local cheated = false
- local RNG1 = memory.readbyte(0xCAC8)
- local RNG2 = memory.readbyte(0xCAC9)
- local RNG3 = memory.readbyte(0xCACA)
- local initRNG1 = RNG1
- local initRNG2 = RNG2
- local initRNG3 = RNG3
- --Keyboard states last frame and this frame
- prevks = input.get()
- curks = input.get()
- --Should we display everything?
- rundisplay = true
- --Should we alternate A/B presses to auto-advance text?
- runtextskip = false
- lastInputWasA = true
- function cheat(bulba)
- if (cheated == false) then
- cheated = true
- for i=0,59 do
- myDeckCards[i] = memory.read_s16_le(MyDeckIDBegin+(i*2))
- end
- for i=0,59 do
- local loc = MyDeckIDBegin + (i*2)
- if (bulba) then
- --if (i > 5) then
- memory.writebyte(loc,12)
- --else
- --memory.writebyte(loc,1)
- --end
- memory.writebyte(loc+1,0)
- else
- if (i > 40) then
- memory.writebyte(loc,187)
- elseif (i > 19) then
- memory.writebyte(loc,167)
- else
- memory.writebyte(loc,163)
- end
- memory.writebyte(loc+1,1)
- end
- end
- else
- cheated = false
- for i=0,59 do
- local loc = MyDeckIDBegin + (i*2)
- memory.write_s16_le(loc,myDeckCards[i])
- end
- end
- end
- function advanceRNG()
- --Recreation of the code that advances RNG
- local temp = RNG2
- temp = bit.rol(temp,2)
- if (bit.check(temp,8)) then temp = bit.set(temp,0) end
- temp = bit.clear(temp,8)
- if (bit.check(temp,9)) then temp = bit.set(temp,1) end
- temp = bit.clear(temp,9)
- temp = bit.bxor(temp,RNG1)
- local carry = bit.check(temp,0)
- RNG2 = bit.bxor(RNG2,RNG1)
- temp = RNG3
- temp = bit.bxor(temp,RNG1)
- RNG1 = temp
- RNG1 = bit.rol(RNG1,1)
- if (carry) then RNG1 = bit.set(RNG1,0) end
- carry = bit.check(RNG1,8)
- RNG1 = bit.clear(RNG1,8)
- RNG2 = bit.rol(RNG2,1)
- if (carry) then RNG2 = bit.set(RNG2,0) end
- RNG2 = bit.clear(RNG2,8)
- RNG3 = RNG3 + 1
- if (RNG3 == 256) then RNG3 = 0 end
- return (bit.bxor(RNG2,RNG1))
- end
- function randomSlot(size)
- --Get a random deck slot 0-59
- --This is done by multiplying the RNG value by 60, and taking the left 8 bits
- local rng = advanceRNG()
- local temp = rng * size
- for i=0,7 do
- if (bit.check(temp,i+8)) then temp = bit.set(temp,i) else temp = bit.clear(temp,i) end
- temp = bit.clear(temp,i+8)
- end
- return temp
- end
- function shuffleOppHand(size)
- --Do 60 location swaps
- oppHand = {}
- for i=0,size-1 do
- oppHand[i] = memory.readbyte(0xC342+i)
- end
- for curLoc=0,size-1 do
- local newLoc = randomSlot(size)
- local temp = oppHand[curLoc]
- oppHand[curLoc] = oppHand[newLoc]
- oppHand[newLoc] = temp
- end
- end
- function startFile(delay)
- joypad.set({A=1})
- for i=0,31 do
- emu.frameadvance()
- end
- --print(delay)
- if (delay == 0) then
- for i=0,10 do
- emu.frameadvance()
- if (emu.islagged()) then
- tastudio.setplayback(emu.framecount()-2)
- joypad.set({A=1})
- break
- end
- end
- elseif (delay > 0) then
- for i=0,10 do
- emu.frameadvance()
- if (emu.islagged()) then
- for i=0,10 do
- emu.frameadvance()
- if (not emu.islagged()) then
- if (delay == 1) then tastudio.setplayback(emu.framecount()-1) end
- joypad.set({A=1})
- break
- end
- end
- break
- end
- end
- end
- end
- while true do
- RNG1 = memory.readbyte(0xCAC8)
- RNG2 = memory.readbyte(0xCAC9)
- RNG3 = memory.readbyte(0xCACA)
- initRNG1 = RNG1
- initRNG2 = RNG2
- initRNG3 = RNG3
- curks = input.get()
- --Write the [D]eck to a text file
- if (curks["D"] and not prevks["D"]) then
- file = io.open("deck.txt","w")
- local startSpot = MyDeckIDBegin
- for i=0,59 do
- print(tostring(i+1) .. ": " .. nome[memory.read_s16_le(startSpot+(i*2))])
- file:write(tostring(i+1) .. ": " .. nome[memory.read_s16_le(startSpot+(i*2))] .. "\r\n")
- end
- file:flush()
- file:close()
- end
- --[S]py on their deck? I dunno
- if (curks["S"] and not prevks["S"]) then
- file = io.open("deck.txt","w")
- local startSpot = DeckIDBegin
- for i=0,59 do
- print(tostring(i+1) .. ": " .. nome[memory.read_s16_le(startSpot+(i*2))])
- file:write(tostring(i+1) .. ": " .. nome[memory.read_s16_le(startSpot+(i*2))] .. "\r\n")
- end
- file:flush()
- file:close()
- end
- --[R]un
- if (curks["R"] and not prevks["R"]) then
- rundisplay = not rundisplay
- end
- --[A]dvance text
- if (curks["A"] and not prevks["A"]) then
- runtextskip = not runtextskip
- end
- --[C]heat
- if (curks["C"] and not prevks["C"]) then
- cheat(false)
- end
- --[B]asics
- if (curks["B"] and not prevks["B"]) then
- cheat(true)
- end
- if (curks["Q"] and not prevks["Q"]) then
- startFile(0)
- end
- if (curks["W"] and not prevks["W"]) then
- startFile(1)
- end
- if (curks["E"] and not prevks["E"]) then
- startFile(2)
- end
- local myHandEnd = 0
- local handEnd = 0
- local prize = 0
- --gui.text(1,1,nome[208])
- if (rundisplay) then
- local prizesPlaced = false
- for i=0,59 do
- --Display both hands
- if memory.readbyte(MyDeckLocBegin+i)==8 then prizesPlaced = true end
- if memory.readbyte(DeckLocBegin+i)==1 then
- if (nome[memory.read_s16_le(DeckIDBegin+(i*2))] ~= nil) then
- gui.text(241,1+12*handEnd,tostring(i+1) .. ": " .. nome[memory.read_s16_le(DeckIDBegin+(i*2))])
- end
- handEnd=handEnd+1
- end
- if memory.readbyte(MyDeckLocBegin+i)==1 then
- local position = 0
- for j=0,58 do
- if (memory.readbyte(0xC242+j)==i) then position = j+1 break end
- end
- if (nome[memory.read_s16_le(MyDeckIDBegin+(i*2))] ~= nil) then
- gui.text(1,21+12*myHandEnd,tostring(i+1) .. ": " .. nome[memory.read_s16_le(MyDeckIDBegin+(i*2))] .. "(" .. position .. ")")
- end
- myHandEnd=myHandEnd+1
- end
- end
- local startSpot = memory.readbyte(TopCard)
- local myStartSpot = memory.readbyte(MyTopCard)
- --if (!prizesPlaced) maxCards = 9
- if (prizesPlaced == false) then
- local numPrizes = memory.readbyte(0xCC00)
- startSpot = startSpot + numPrizes
- myStartSpot = myStartSpot + numPrizes
- for i=0,numPrizes-1 do
- end
- end
- for i=0,2 do
- --Display upcoming draws
- local draws = memory.readbyte(ShuffledDeckBegin + startSpot + i)
- if (myHandEnd > 0 and nome[memory.read_s16_le(DeckIDBegin+(draws*2))] ~= nil) then
- gui.text(261,6+12*handEnd,tostring(draws+1) .. ": " .. nome[memory.read_s16_le(DeckIDBegin+(draws*2))])
- handEnd=handEnd+1
- end
- local draws = memory.readbyte(MyShuffledDeckBegin + myStartSpot + i)
- if (myHandEnd > 0 and nome[memory.read_s16_le(MyDeckIDBegin+(draws*2))] ~= nil) then
- gui.text(21,26+12*myHandEnd,tostring(draws+1) .. ": " .. nome[memory.read_s16_le(MyDeckIDBegin+(draws*2))])
- myHandEnd=myHandEnd+1
- end
- end
- for i=0,59 do
- --Display our prizes
- --C23C: My prizes in order
- if memory.readbyte(MyDeckLocBegin+i)==8 then
- local position = 0
- for j=0,5 do
- if (memory.readbyte(0xC23C+j)==i) then position = j+1 break end
- end
- if (nome[memory.read_s16_le(MyDeckIDBegin+(i*2))] ~= nil) then
- gui.text(41,31+12*myHandEnd,tostring(i+1) .. ": " .. nome[memory.read_s16_le(MyDeckIDBegin+(i*2))] .. "(" .. position .. ")")
- end
- myHandEnd=myHandEnd+1
- end
- end
- local ShuffledDeckBegin=0xC37E
- local MyShuffledDeckBegin=0xC27E
- local TopCard=0xC3BA
- local MyTopCard=0xC2BA
- --Check upcoming flips, and Rocket's Trap results?
- gui.text(1,263,RNG1)
- gui.text(61,263,RNG2)
- gui.text(121,263,RNG3)
- gui.text(26,251,memory.read_u32_le(0xCAC8))
- local checkRocket = false
- for i=0,2 do
- advanceRNG()
- local flipRNG = bit.check(bit.bxor(RNG2,RNG1),7)
- if (flipRNG == true) then
- gui.text(1+i*60,275,"Tails")
- else
- gui.text(1+i*60,275,"Heads")
- if i == 0 then checkRocket = true end
- end
- end
- --[[ Tried to predict Rocket's Trap card grabs; This isn't how it works
- if (checkRocket) then
- RNG1 = initRNG1
- RNG2 = initRNG2
- RNG3 = initRNG3
- advanceRNG() --the heads coin
- local handSize = memory.readbyte(0xC3F4)
- shuffleOppHand(handSize)
- for i=handSize-1,handSize-3,-1 do
- if (i >= 0) then
- gui.text(200,275-(handSize-i-1)*12,((oppHand[i] + 1) .. ": " .. nome[memory.read_s16_le(DeckIDBegin+(oppHand[i]*2))]))
- end
- end
- --Hand shuffle
- --C3F4 = number of cards in opponent's hand
- end]]
- end
- if (runtextskip) then
- if (emu.islagged()) then
- lastInputWasA = not lastInputWasA
- end
- if (lastInputWasA) then
- joypad.set({B=1})
- lastInputWasA = false
- else
- joypad.set({A=1})
- lastInputWasA = true
- end
- end
- prevks = curks
- emu.frameadvance()
- end
Add Comment
Please, Sign In to add comment