Skip to content

Commit

Permalink
Big Update, added support for Fairy Type in the GUI, added support fo…
Browse files Browse the repository at this point in the history
…r Emerald EX.
  • Loading branch information
NPO-197 committed Oct 10, 2021
1 parent 8a79986 commit e13eb35
Show file tree
Hide file tree
Showing 10 changed files with 378 additions and 77 deletions.
73 changes: 69 additions & 4 deletions DetectROM.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
import mmap
import os
#mmap is used to memory-map the rom files to help handel editing


#TBD Use an enum for this instead of an int...
#DETECTED ROMS : NUMBER
#VANILLA CRYSTAL : 1
#CRYSTAL SPPEDCHOICE: 2
#EMERALD SPEEDCHOICE: 3
#EMERALD EX: 4

def TestROM(inputfile):

f = open(inputfile,"r+b")

size = os.path.getsize(inputfile)
print('Size:'+str(size))
# memory-map the file, size 0 means whole file
mm = mmap.mmap(f.fileno(),0)
#first try to detect if it's a known gbc file, else detect if it's a known gba file
GBCTest = TestGBC(mm,inputfile)
if GBCTest[1]==0:
return TestGBA(mm)
return GBCTest

if GBCTest[1]!=0:
return GBCTest
return TestGBA(mm)

def TestGBC(mm,filename):

Expand Down Expand Up @@ -44,6 +55,12 @@ def TestGBC(mm,filename):
return ['Error.',0]

def TestGBA(mm):
Test3 = TestEmeraldSpeedChoice(mm)
if Test3[1]!=0:
return Test3
return TestEmeraldEX(mm)

def TestEmeraldSpeedChoice(mm):
#There are 10 pointers used by various functions that point to the Old Type Chart
TypeChartPointers =[0x0472F0, #TypeCalc Pointer 1
0x047430, #TypeCalc Pointer 2
Expand All @@ -69,3 +86,51 @@ def TestGBA(mm):
if mm.read(873)!=bytearray(873): #873 bytes is the largest our typechart can get with 17 types...
return ['Error Free ROM is not free???',0] #this *could* happen if someone is trying to use this on a ROM hack
return ['EmeraldSpeedChoice Detected!',3]

def TestEmeraldEX(mm):
#The Data of both typecharts as it apears in the EX ROM.
TypechartDataEX= [
0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x00,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,
0x00,0x20,0x00,0x10,0x00,0x08,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x08,0x00,0x00,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x20,0x00,0x10,0x00,0x20,0x00,0x08,
0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x20,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,
0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x10,0x00,0x08,0x00,0x00,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x20,
0x00,0x10,0x00,0x10,0x00,0x00,0x00,0x20,0x00,0x10,0x00,0x20,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x08,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,
0x00,0x10,0x00,0x08,0x00,0x20,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x10,
0x00,0x10,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x08,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x08,
0x00,0x00,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x10,
0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x08,0x00,0x08,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x20,
0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,
0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x20,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x08,0x00,0x08,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x08,0x00,0x10,0x00,0x10,
0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x08,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x10,
0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x08,0x00,0x20,0x00,0x20,0x00,0x08,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x08,0x00,0x20,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x10,
0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x00,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x08,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x10,
0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x00,0x00,0x10,
0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x08,0x00,0x08,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x20,0x00,0x10,0x00,0x10,
0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x00,
0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x08,
0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x20,0x00,0x10,
0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x20,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,
0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x20,0x00,0x10,0x00,0x08,0x00,0x20,0x00,0x20,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x08,0x00,0x10,0x00,0x08,0x00,0x20,
0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,
0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x10,0x00,0x20,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x08,
0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x08,0x00,0x10,0x00,0x08,0x00,0x20,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,
0x00,0x10,0x00,0x20,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x10,
0x00,0x10,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x20,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x20,
0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x10,
0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x20,0x00,0x20,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x08,
0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,
0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x08,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x20,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x20,0x00,0x10,0x00,0x10,
0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x20,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x10,
0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x20,0x00,0x08,0x00,0x08,0x00,0x20,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x20,0x00,0x08,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x10,
0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x20,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x10,
0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x10,
0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x20,0x00,0x20,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x08,0x00,0x10,0x00,0x10,
0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x20,
0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x20,
0x00,0x10,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x08,0x00,0x10]
#Start of the two type tables used in EX (Inverse Typechart is imediatly after...)
mm.seek(0x37AFC6)
if list(mm.read(len(TypechartDataEX)))!=TypechartDataEX:
print('EX error.')
return ['Error Couldn\'t detect ROM',0]
return ['Emerald EX Detected!',4]
2 changes: 1 addition & 1 deletion HexEdit.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def HexEdit(inputfile,outputfile,mins,maxs,RandomTypeChartMatrix,seed):
cm = [[0,1,2,3],mins,maxs]
# we generate a random type chart as a general latin square (so it's balanced)
RandomTypeChartMatrix = GL.RandGls(cm,n)
Sl.Spoiler(outputfile[:-4]+'log.csv',RandomTypeChartMatrix,seed)
Sl.Spoiler(2,outputfile[:-4]+'log.csv',RandomTypeChartMatrix,seed)

matchups = ['0A','14','05','00']
RandomTypeChartMatrixHex = []
Expand Down
30 changes: 16 additions & 14 deletions HexEditGen3.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,9 @@
import SpoilerLog
#SpoilerLog is used to generate the spoiler log.

inputfile = "pokeemerald-speedchoice-1.2.1.gba"
outputfile ="test.gba"
TC = []
mins =[0,2,2,0]
maxs =[17,7,5,1]
seed = 0


#Used to generate a ROM with a custom type chart for gen 3 ROMS
def SaveChart(inputfile,outputfile,TypeChart,seed):
#Converts a Type Chart from a grid format to a list, for gen 3 type order.
def TypeChartToList(TypeChart):
matchups = [0x0A,0x14,0x05,0x00]
TypeChartList = []
Imunities = []
Expand All @@ -29,27 +22,36 @@ def SaveChart(inputfile,outputfile,TypeChart,seed):
AtkType+=1
if DefType>8:
DefType+=1
#Put Imunities after the Forsight breakpoint
#Put Imunities at the end (after Forsight breakpoint)
if Matchup == 0x00:
Imunities.extend([AtkType,DefType,Matchup])
continue
#Toss Neutral Matchups
#Ignore Neutral Matchups
if Matchup == 0x0A:
continue
#Put NotVerry / Super Effective into the list
TypeChartList.extend([AtkType,DefType,Matchup])

TypeChartList.extend([0xFE,0xFE,0x00])#Foresight break point
TypeChartList.extend(Imunities)
TypeChartList.extend([0xFF,0xFF,0x00])#End of matchups list
HexEdit(inputfile,outputfile,TypeChartList)
SpoilerLog.Spoiler(outputfile[:-4]+'log.csv',TypeChart,seed)
return(TypeChartList)

#Used to generate a ROM with a random type chart based on the settings
def Rando(inputfile,outputfile,mins,maxs,seed):
def Rando(ROMType,inputfile,outputfile,mins,maxs,seed):
# constraint matrix based on given mins and maxs
cm = [[0,1,2,3],mins,maxs]
# we generate a random type chart as a general latin square (so it's balanced)
TypeChart = GL.RandGls(cm,17) #Only 17 types in gen 3
SaveChart(inputfile,outputfile,TypeChart,seed)

#Used to generate a ROM with a custom type chart for gen 3 ROMS
def SaveChart(ROMType,inputfile,outputfile,TypeChart,seed):
TypeChartList = TypeChartToList(TypeChart)
HexEdit(inputfile,outputfile,TypeChartList)
SpoilerLog.Spoiler(3,outputfile[:-4]+'log.csv',TypeChart,seed)


def HexEdit(inputfile,outputfile,NewTypeChartList):
#first make a copy of the input file so we can edit it without destroying the original file
shutil.copy(inputfile,outputfile)
Expand Down
91 changes: 91 additions & 0 deletions HexEditGen3EX.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import mmap, shutil
#mmap is used to memory-map the .gba file to help handel editing
#shutil is used to copy files
import GeneralLatinSquare as GL
#GeneralLatinSquare is used to generate the random typechart
import SpoilerLog
#SpoilerLog is used to generate the spoiler log.

DEFAULTCHARTGEN6 = [
[0,0,0,0,0,2,0,3,2,0,0,0,0,0,0,0,0,0],
[1,0,2,2,0,1,2,3,1,0,0,0,0,2,1,0,1,2],
[0,1,0,0,0,2,1,0,2,0,0,1,2,0,0,0,0,0],
[0,0,0,2,2,2,0,2,3,0,0,1,0,0,0,0,0,1],
[0,0,3,1,0,1,2,0,1,1,0,2,1,0,0,0,0,0],
[0,2,1,0,2,0,1,0,2,1,0,0,0,0,1,0,0,0],
[0,2,2,2,0,0,0,2,2,2,0,1,0,1,0,0,1,2],
[3,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,2,0],
[0,0,0,0,0,1,0,0,2,2,2,0,2,0,1,0,0,1],
[0,0,0,0,0,2,1,0,1,2,2,1,0,0,1,2,0,0],
[0,0,0,0,1,1,0,0,0,1,2,2,0,0,0,2,0,0],
[0,0,2,2,1,1,2,0,2,2,1,2,0,0,0,2,0,0],
[0,0,1,0,3,0,0,0,0,0,1,2,2,0,0,2,0,0],
[0,1,0,1,0,0,0,0,2,0,0,0,0,2,0,0,3,0],
[0,0,1,0,1,0,0,0,2,2,2,1,0,0,2,1,0,0],
[0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,1,0,3],
[0,2,0,0,0,0,0,1,0,0,0,0,0,1,0,0,2,2],
[0,1,0,2,0,0,0,0,2,2,0,0,0,0,0,1,1,0]]

#Each matchup is stored in something called UQ_4_12 format?
#16 bit value with 0x0010 = 1.0 and 0x0008 = 0.5 ect...

def TypeChartToData(TypeChart):
Hex=[0x10,0x20,0x08,0x00] #the least signifigant byte of the multiplier
Data = []
for i in range(len(TypeChart)):
#insert Mystery Type
if i == 9:
for j in range(len(TypeChart)):
#insert Mystery X Mystery
if j == 9:
Data.extend([0x00,0x10]) #All Mystery type matchups are x1.0 by default
Data.extend([0x00,0x10])

for j in range(len(TypeChart)):
#insert Mystery Type
if j == 9:
Data.extend([0x00,0x10])
Data.extend([0x00,Hex[TypeChart[i][j]]])
return(Data)

#Returns the inverse TypeChart
def InverseTypeChart(TypeChart):
Inv = [0,2,1,1] #Super Effective -> NotVeryEffective NotVery/NoEffect -> SuperEffective
InvChart = []
for i in range(len(TypeChart)):
InvChart.append([])
for j in range(len(TypeChart)):
InvChart[i].append(Inv[TypeChart[i][j]])
return InvChart

def Rando(inputfile,outputfile,mins,maxs,seed):
# constraint matrix based on given mins and maxs
cm = [[0,1,2,3],mins,maxs]
# we generate a random type chart as a general latin square (so it's balanced)
TypeChart = GL.RandGls(cm,18) # Emerald EX has the Fairy type so 18 types.
SaveChart(inputfile,outputfile,TypeChart,seed)


#Used to generate a ROM with a custom type chart for Emerald EX.
def SaveChart(inputfile,outputfile,TypeChart,seed):
TypeChartData = TypeChartToData(TypeChart) #Calc Chart data for EX ROM Format
InverseData = TypeChartToData(InverseTypeChart(TypeChart)) #Calc Inverse Chart data for EX ROM Format
TypeChartData.extend(InverseData) #We need to add the inverse chart data imeadiatly afterwards
HexEdit(inputfile,outputfile,TypeChartData)
SpoilerLog.Spoiler(6,outputfile[:-4]+'log.csv',TypeChart,seed)


def HexEdit(inputfile,outputfile,NewTypeChartData):
#first make a copy of the input file so we can edit it without destroying the original file
shutil.copy(inputfile,outputfile)

f = open(outputfile, "r+b")

# memory-map the file, size 0 means whole file
mm = mmap.mmap(f.fileno(),0)
#Just go to the offset of the type chart and write in the new one!
mm.seek(0x37AFC6)
mm.write(bytearray(NewTypeChartData))
#Don't forget to close the file when you are done!
mm.close()
return
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Currently supports:
- Pokemon - Crystal Version (UE) (V1.0) [C][!].gbc `sha1: F4CD194BDEE0D04CA4EAC29E09B8E4E9D818C133`
- crystal-speedchoice-v7.2.gbc `sha1: 19AB11096EB2BA6BF9A8360093B2DDAE3E7ABBAB`
- pokeemerald-speedchoice-1.2.1.gba `sha1: C65E8F3DC990484CE522A979CDBCF9732A2F5AAB`
- pokeemerald-ex-speedchoice-0.3.0.gba `sha1: A57527512AA3856C43808BED9E4B2F1FF6FB2FE6`

# Type Chart Tracker
I would suggest using Demki's tracker found here: https://demki.github.io/poketypechart/
Expand All @@ -19,6 +20,8 @@ First run the '.exe' file from the dist.zip folder, Download from 'Releases'.

Click 'OpenROM' and select a clean or randomized ROM (Make sure the base ROM is supported by this randomizer!)

Make sure the correct Gen is selected for the game you are randomizing, Gen6+ for EX, Gen2+ for everything else, Gen1 is currently not supported.

Then select the settings you want for generating a random Type Chart using the Sliders.

If you would like a completely random type chart (very unbalanced) have each slider set to it's minimum and maximum values.
Expand Down
27 changes: 25 additions & 2 deletions SpoilerLog.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#function to generate a spoiler log for the randomizer
def Spoiler(FileName,RandomTypeChart,seed):
def Spoiler(Gen,FileName,RandomTypeChart,seed):
if Gen>=6:
spoilergen6(FileName,RandomTypeChart,seed)
return
TypeNames = ['Bug', 'Dark', 'Dragon', 'Electric', 'Fighting', 'Fire', 'Flying', 'Ghost', 'Grass', 'Ground', 'Ice', 'Normal', 'Poison', 'Psychic', 'Rock', 'Steel', 'Water']
TypeIndex = [6, 16, 15, 12, 1, 9, 2, 7, 11, 4, 14, 0, 3, 13, 5, 8, 10]
matchups = ['1.0','2.0','0.5','0.0']
Expand All @@ -14,7 +17,27 @@ def Spoiler(FileName,RandomTypeChart,seed):
f.write(','+matchups[RandomTypeChart[TypeIndex[i]][TypeIndex[j]]])
except:
print(RandomTypeChart)
raise
raise
f.write("\n")

f.close()

def spoilergen6(FileName,RandomTypeChart,seed):
TypeNames = ['Bug', 'Dark', 'Dragon', 'Electric', 'Fairy', 'Fighting', 'Fire', 'Flying', 'Ghost', 'Grass', 'Ground', 'Ice', 'Normal', 'Poison', 'Psychic', 'Rock', 'Steel', 'Water']
TypeIndex = [6, 16, 15, 12, 17, 1, 9, 2, 7, 11, 4, 14, 0, 3, 13, 5, 8, 10]
matchups = ['1.0','2.0','0.5','0.0']
f = open(FileName,'w+')
#Abreviate each type's name so it dosen't take up too much space
f.write("Seed:"+str(seed)+",BUG,DAR,DRA,ELE,FAI,FIG,FIR,FLY,GHO,GRA,GRO,ICE,NOR,POI,PSY,ROC,STE,WAT\n")
for i in range(18):
f.write(TypeNames[i])
#The chart is stored in index format so we need to swap it into alphabetical format for the Tracker.
for j in range(18):
try:
f.write(','+matchups[RandomTypeChart[TypeIndex[i]][TypeIndex[j]]])
except:
print(RandomTypeChart)
raise
f.write("\n")

f.close()
1 change: 1 addition & 0 deletions test.sav

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions tkSliderWidget.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
tkSliderWidget originaly made by MenxLi
Modified by NPO-119 to include discrete option, active option, and redraw function
Modified by NPO-197 to include discrete option, active option, and redraw function
"""

Expand Down Expand Up @@ -125,8 +125,10 @@ def __moveBar(self, idx, pos):
def redraw(self):
for bar in self.bars:
ids = bar["Ids"]
pos = bar["Pos"]
val = bar["Value"]
if val > self.max_val:
val = self.max_val
pos = (val-self.min_val)/(self.max_val-self.min_val)
for id in ids:
self.canv.delete(id)
bar["Ids"] = self.__addBar(pos)
Expand Down
5 changes: 4 additions & 1 deletion tk_ToolTip_class101.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Modified to include a delay time by Victor Zaccardo, 25mar16
Modified to include changetext() by NPO-119
"""
"""

try:
# for Python2
Expand All @@ -30,6 +30,9 @@ def __init__(self, widget, text='widget info'):
self.id = None
self.tw = None

def destroy(self):
self.widget.destroy()

def changetext(self,text):
self.text = text

Expand Down
Loading

0 comments on commit e13eb35

Please sign in to comment.