예제 #1
0
def shell():
    rom = agb.Agbrom(path=config.STDROM)
    try:
        proj = project.Project.load_project(PROJ)
    except:
        proj = project.Project()
        print("Project '", PROJ, "' not found. Will be created.")
    proj.save_project(path=PROJ)

    while 1:
        line = input(
            ">>Export maps: Format {bank.map}, {bank.map}, ... {bank.map} or list:{listpath}\n"
        )
        if line.find("list:") == 0:
            #Export from list(lines will be merged and fed into input)
            path = line.split(":")[1]
            fd = open(path, "r+")
            content = fd.read()
            fd.close()
            line = content.replace("\r\n", " ").replace("\n", " ")
            print(line)
        maps = map((lambda t: t.strip().split(".")), line.split(","))
        for bank, mapid in maps:
            #print("Exporting map", bank, id)
            bank = int(bank, 0)
            mapid = int(mapid, 0)
            export(bank, mapid, rom, proj)
            proj.save_project(path=PROJ)
예제 #2
0
import agb
import constants

rom = agb.Agbrom()
move_table = rom.pointer(0x3E97C)

output = ""

for i in range(0, len(constants.species_table)):
    moveset = rom.pointer(move_table + i * 4)
    output += "pokemon_move moveset_" + constants.species_table[i].lower(
    ) + "[] = {\n"
    while True:
        try:
            data = rom.u16(moveset)
        except:
            output += "\t{0x1FF, 0x7F}\n"
            break
        if data == 0xFFFF:
            output += "\t{0x1FF, 0x7F}\n"
            break
        try:
            move = constants.attack_table[data & 0x1FF]
        except:
            print("malformed move for pokemon ", constants.species_table[i])
            move = "0"
        level = data >> 9
        if level > 100: level = 0
        #print(constants.species_table[i], move, level)
        output += "\t{" + move + ", " + str(level) + "},\n"
        moveset += 2
예제 #3
0
import agb
import pstring

pstring_factory = pstring.PString("../table.tbl")

vrom = agb.Agbrom()
erom = agb.Agbrom(agb.FREPATH)

dout = []
eout = []
dbase = vrom.pointer(0x1c0)
ebase = erom.pointer(0x1c0)
for i in range(0, 0x71):
    doff = dbase + 13 * i
    eoff = ebase + 13 * i
    print(i, hex(vrom.pointer(doff)), hex(erom.pointer(eoff)))
    dout.append(pstring_factory.hex2str(vrom, doff).capitalize())
    eout.append(
        pstring_factory.hex2str(erom, eoff).capitalize(
        ) if i < 0x4E else pstring_factory.hex2str(vrom, doff).capitalize())

open("D:/temp/ability_names_ger.txt",
     "w+").write("\n".join(["=" + m for m in dout]))
open("D:/temp/ability_names_en.txt",
     "w+").write("\n".join(["=" + m for m in eout]))
예제 #4
0
import agb
import pstring

#rom = agb.Agbrom()
rom = agb.Agbrom(path=agb.FREPATH)
factory = pstring.PString("../table.tbl")

strings = []
string_names = []

#string_table = rom.pointer(0xCF194)
string_table = rom.pointer(0xCF000)

#for i in range(0, 0x187):
for i in range(0, 374):
    print(i)
    offset = string_table + 4 * i
    #strings.append(".string str_battle_x"+hex(i+12)[2:]+" GER\n\t="+factory.hex2str(rom,rom.pointer(offset))+"\n.end")
    strings.append(".string str_battle_x" + hex(i + 12)[2:] + " EN\n\t=" +
                   factory.hex2str(rom, rom.pointer(offset)) + "\n.end")
    string_names.append(".word str_battle_x" + hex(i + 12)[2:])

open("D:/temp/battlestrings.txt", "w+",
     encoding="ascii").write("\n\n".join(strings))
open("D:/temp/battlestring_table.asm", "w+").write("\n\n".join(string_names))
import agb
import pstring
import constants

#rom = agb.Agbrom()
pstring_factory = pstring.PString("../table.tbl")
rom = agb.Agbrom("D:/Hacking/1695 - Pokemon Fire Red (U)(Independent).gba")

description_table = rom.pointer(0x1C4)

descriptions = []

for i in range(0, 0x4d):
    ability_descr = rom.pointer(description_table + i * 4)
    descriptions.append(pstring_factory.hex2str(rom, ability_descr))

#Dump the descriptions
lines = [
    ".string ability_descr_" + hex(i) + " EN\n\t=" + descriptions[i] +
    "\n.end\n" for i in range(0, len(descriptions))
]
open("D:/temp/ability_descriptions_en.txt", "w+").write("\n\n".join(lines))

lines = [".word ability_descr_" + hex(i) for i in range(0, len(descriptions))]
open("D:/temp/ability_descriptions.asm", "w+").write("\n".join(lines))
예제 #6
0
import agb
import constants

#read maps
fd = open("maps2export.txt", "r+")
maps2export = fd.read()
fd.close()
maps2export = maps2export.replace("\r\n", "").split(",")

rom = agb.Agbrom(path=agb.VIOLETPATH)
wild_table = rom.pointer(0x828F4)

#For runtime scan entire table once
index_table = {}
i = 0
while True:
    off = wild_table + i * 0x14
    bank = rom.u8(off)
    mapid = rom.u8(off + 1)
    if bank == 0xFF and mapid == 0xFF: break
    index_table[bank, mapid] = i
    i += 1



outtable = ""

def export_data(offset, size, name, chances):
    out = "@// Wild data " + name + "\n.global " + name + "\n.align 4\n" + name + ":\n"
    frequency = rom.u8(offset)
    fields = rom.array(offset + 1, 3)
예제 #7
0
import agb
import constants

violet = agb.Agbrom()
frd = agb.Agbrom(agb.FRDPATH)

item_effect_table = 0x2527E0
for i in range(0, len(constants.item_table) - 13):
    vptr = violet.pointer(item_effect_table + i * 4)
    fptr = frd.pointer(item_effect_table + i * 4)
    if vptr != fptr:
        try:
            vdata = violet.array(vptr, 7) if vptr > 0 else None
            fdata = frd.array(fptr, 7) if fptr > 0 else None
            print("Dif at", i + 13, "=", constants.item_table[i + 13],
                  "\n\tViolet at", hex(vptr), ":", vdata, "\n\tFrd at",
                  hex(fptr), ":", fdata)
        except Exception as e:
            print(e, "at", hex(i), hex(vptr), hex(fptr))
예제 #8
0
import agb
import img_dump
import lz77
import pysetex
import png

#This module quickdumps a png with a palette of a tileset (for editing in right pal)

TSNUM = 251828
TSPAL = 0
COLS = 16 * 5
PATH = "D:/temp/ts" + str(TSNUM) + "p" + str(TSPAL) + ".png"

rom = agb.Agbrom(path=agb.STDPATH)

bytecnt = COLS * 2
table = pysetex.DEFAULT_TABLE
off = table + 24 * TSNUM

pal_mode = rom.u8(off + 1)
pal_off = rom.pointer(off + 0x8)

if pal_mode == 0:
    pal_data = rom.array(pal_off, bytecnt)
elif pal_mode == 1:
    pal_off += 0xE0
    pal_data = rom.array(pal_off, bytecnt)
else:
    pal_data = lz77.decomp(rom, pal_off)

pal_data = pal_data[32 * TSPAL:32 * (TSPAL + 1)]
예제 #9
0
import agb
import img_dump

rom = agb.Agbrom(path="D:/Hacking/bprd.gba")
img_dump.dump_png("D:/temp/tss.png",
                  rom,
                  0x26D2A0,
                  128,
                  48,
                  0x26D6E4,
                  16,
                  img_lz77=True)
import agb
import constants
import pstring

pstring_factory = pstring.PString("../table.tbl")

rom = agb.Agbrom("D:/Hacking/bprd.gba")
#rom = agb.Agbrom(agb.FREPATH)

desc_table = rom.pointer(0x137c64)
#desc_table = rom.pointer(0x137c40)

out = ""

for i in range(0, 354):
    str_off = rom.pointer(desc_table + i * 4)
    out += ".string str_attack_desc_" + constants.attack_table[i + 1].lower(
    ) + " GER\n\t=" + pstring_factory.hex2str(rom, str_off) + "\n.end\n\n"

open("D:/temp/attack_descr_de.txt", "w+").write(out)

out = ""
for i in range(0, len(constants.attack_table)):
    out += "\t.word str_attack_desc_" + constants.attack_table[i].lower(
    ) + "\n"

open("D:/temp/attack_descr_refs.asm", "w+").write(out)
예제 #11
0
import agb
import pstring
import constants

violet = agb.Agbrom()
bpre = agb.Agbrom(agb.FREPATH)
pstring_factory = pstring.PString("../table.tbl")

ger_item_base = violet.pointer(0x1C8)
en_item_base = bpre.pointer(0x1C8)

ger_out = ""
en_out = ""
for i in range(0, len(constants.item_table)):
    ger_off = ger_item_base + 0x2C * i
    en_off = en_item_base + 0x2C * i
    ger_desc = violet.pointer(ger_off + 20)
    en_desc = bpre.pointer(en_off + 20)
    ger_desc = pstring_factory.hex2str(violet, ger_desc)
    en_desc = pstring_factory.hex2str(bpre, en_desc)
    ger_out += ".string str_item_desc_" + hex(
        i)[1:] + "_" + constants.item_table[i].lower() + " " + "GER\n"
    ger_out += "\t=" + ger_desc + "\n\.end\n\n"
    en_out += ".string str_item_desc_" + hex(
        i)[1:] + "_" + constants.item_table[i].lower() + " " + "EN\n"
    en_out += "\t=" + en_desc + "\n\.end\n\n"

header = "\n".join([
    "extern u8 str_item_desc_" + hex(i)[1:] + "_" +
    constants.item_table[i].lower() + "[];"
    for i in range(0, len(constants.item_table))