pret / pokemon-reverse-engineering-tools Goto Github PK
View Code? Open in Web Editor NEWTools for building and disassembling Pokémon Red and Pokémon Crystal
Tools for building and disassembling Pokémon Red and Pokémon Crystal
Not sure which repo to post this issue in. I'm using pret/pokemontcg but the issue is happening in pret/pokemon-reverse-engineering-tools or extras submodule.
Upon running make I get this error:
File "extras/pokemontools/gfx.py", line 71
tiles = sorted(enumerate(tiles), key= lambda (i, tile): i % width)
^
SyntaxError: invalid syntax
Makefile:20: recipe for target 'src/main.o' failed
make: *** [src/main.o] Error 1
But i see that the current extras is referencing an old version of pokemon-reverse-engineering-tools. Maybe I can update it to the newest version or perhaps the whole project has been abandoned in which case I shouldn't really do much with it.
gbz80disasm.py crashes if there is no hram.asm file, but pokered doesn't use an hram.asm file.
Currently, it assumes the .wav file has a sample rate of 22050, a sample width of 1 byte, and 1 channel. It should be able to at least handle arbitrary sample rates and sample widths.
There's no reason to keep redefining load_rom
everywhere. Just have one place in the source code where a rom is defined and can be loaded.
$ python dump_sections.py
Traceback (most recent call last):
File "dump_sections.py", line 126, in <module>
output = dump_sections(baserom)
File "dump_sections.py", line 83, in dump_sections
last_bank = calculate_bank_quantity(path, bank_size=bank_size)
File "dump_sections.py", line 46, in calculate_bank_quantity
return float(os.lstat(path).st_size) / bank_size
OSError: [Errno 2] No such file or directory: 'baserom.gbc'
and then:
$ python dump_sections.py
Traceback (most recent call last):
File "dump_sections.py", line 126, in <module>
output = dump_sections(baserom)
File "dump_sections.py", line 92, in dump_sections
banks = range(initial_bank, last_bank)
TypeError: range() integer end argument expected, got float.
wtf?
Above report is from pokecrystal issue 141.
Don't use globals.
When rebuilding .2bpp files in pokecrystal/gfx/pics
, gfx.py does not take into account the presence of a .pal file. Instead, it completely overwrites the existing file, resulting in a garbage build. It also overwrites the bitmask.asm and frames.asm files, which breaks pic animations.
Currently, adding and using a new macro in kanzure/pokecrystal requires the user to add a class to pokemontools/crystal.py.
Sometimes using a macro is the easiest way to arrange arbitrary data structures. For that purpose the macro does not need to be persistent and is best defined inline. bentley/rgbds already lets you do this, like so:
move: MACRO
db \1 ; animation
db \2 ; effect
db \3 ; power
db \4 ; type
db \5 * $ff / 100 ; accuracy (percent)
db \6 ; pp
db \7 * $ff / 100 ; effect chance (percent)
ENDM
move POUND, EFFECT_NORMAL_HIT, 40, NORMAL, 100, 35, 0
Apparently depending on rgbds is undesirable, and depending on pokemontools is not. In that case, this should be implemented in pokemontools.
Not all .sav files are created the same. The decorator should save in a metadata file an entry about what parameters were used when calling a function. Then, when loading a save state to skip a function, only load a save state that matches the parameters. If that combination of parameters hasn't been played and saved yet, then play it.
There might be parameters that don't influence the save state structure, in which case, the skippable decorator should be given a list of which params don't matter.
@skippable(ignore=["some_param"])
def play_part5(self, some_param=None):
Some of the tests work against asm files from kanzure/pokecrystal and therefore fail because the files aren't present.
Instead of copying the asm files into the repo, make a tests/data/ folder with sample asm for each of the different situations that get tested.
The README is falling behind. The current README is a leftover from pokecrystal/extras/README.md back when everything was shoved into the extras/ path in pokecrystal.
Things the README should include:
$ python extras/pokemontools/gbz80disasm.py 48c19
Traceback (most recent call last):
File "extras/pokemontools/gbz80disasm.py", line 934, in
disasm.initialize()
File "extras/pokemontools/gbz80disasm.py", line 619, in initialize
self.wram.initialize()
File "/home/Daniel/pokered/extras/pokemontools/wram.py", line 108, in initialize
self.setup_hram_constants()
File "/home/Daniel/pokered/extras/pokemontools/wram.py", line 149, in setup_hram_constants
self.hram_constants = self.read_hram_constants()
File "/home/Daniel/pokered/extras/pokemontools/wram.py", line 142, in read_hram_constants
hram_constants = read_constants(self.paths["hram"])
File "/home/Daniel/pokered/extras/pokemontools/wram.py", line 80, in read_constants
with open(filepath, "r") as file_handler:
IOError: [Errno 2] No such file or directory: '/home/Daniel/pokered/hram.asm'
Aborted (core dumped)
kanzure@deathfortress:~/code/pokecrystal$ python extras/pokemontools/gbz80disasm.py 0x45f
Traceback (most recent call last):
File "extras/pokemontools/gbz80disasm.py", line 934, in <module>
disasm.initialize()
File "extras/pokemontools/gbz80disasm.py", line 619, in initialize
self.wram.initialize()
File "/home/kanzure/code/pokecrystal/extras/pokemontools/wram.py", line 106, in initialize
self.setup_wram_sections()
File "/home/kanzure/code/pokecrystal/extras/pokemontools/wram.py", line 128, in setup_wram_sections
self.wram_sections = self.read_wram_sections()
File "/home/kanzure/code/pokecrystal/extras/pokemontools/wram.py", line 121, in read_wram_sections
wram_sections = read_bss_sections(wram_content)
File "/home/kanzure/code/pokecrystal/extras/pokemontools/wram.py", line 48, in read_bss_sections
length = eval(line[3:line.find(';')].replace('$','0x'))
File "<string>", line 1, in <module>
NameError: name 'OBJECT_LENGTH' is not defined
Using eval is wrong many times over. Let's use something else.
Some users maintain only a python3 environment; requiring legacy python may deter those users.
Name it class Rom
or class ROM
. The idea behind RomStr
was to provide a set of standard functions for manipulating a ROM, but it was subclassed from str
which isn't good python.
Not sure if this is a problem in my OS but a preprocessor somehow don't let me make it with this error:
Traceback (most recent call last):
File "prequeue.py", line 11, in <module>
import preprocessor
File "/home/pigu/pokecrystal/preprocessor.py", line 30, in <module>
from extras.pokemontools.battle_animations import (
File "/home/pigu/pokecrystal/extras/pokemontools/battle_animations.py", line 43, in <module>
objs = { k: v for k, v in anims.items() if 'ANIM_OBJ' in v }
File "/home/pigu/pokecrystal/extras/pokemontools/battle_animations.py", line 43, in <dictcomp>
objs = { k: v for k, v in anims.items() if 'ANIM_OBJ' in v }
TypeError: argument of type 'int' is not iterable
So I decided to print anims variable, it appears that it contains constant entries and every Python builtins entries as well...
So, is there a way to work around this problem?
From 94d767f16157de2a1c6bd000687c39e0fefd3d12 Mon Sep 17 00:00:00 2001
From: Tauwasser <[email protected]>
Date: Sun, 28 Feb 2016 23:14:53 +0100
Subject: [PATCH] gfx.py: PNGs should be opened in binary mode
PNG files were opened as text files, thus the signature 0x0D 0x0A bytes were swallowed depending on OS.
Signed-off-by: Tauwasser <[email protected]>
---
pokemontools/gfx.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pokemontools/gfx.py b/pokemontools/gfx.py
index 3f221d6..6f78b7f 100644
--- a/pokemontools/gfx.py
+++ b/pokemontools/gfx.py
@@ -594,7 +594,7 @@ def png_to_2bpp(filein, **kwargs):
arguments.update(kwargs)
if type(filein) is str:
- filein = open(filein)
+ filein = open(filein, 'rb')
assert type(filein) is file
--
There's no reason to have two separate disassemblers.
I found your handy source code and followed the instructions but when compiliing I get this error involving gfx.py here's what the terminal tells me...
$ make
Traceback (most recent call last):
File "extras/pokemontools/gfx.py", line 1442, in
main()
File "extras/pokemontools/gfx.py", line 1438, in main
method(args.filenames)
File "extras/pokemontools/gfx.py", line 1366, in convert_to_2bpp
export_png_to_2bpp(filename)
File "extras/pokemontools/gfx.py", line 994, in export_png_to_2bpp
image, arguments = png_to_2bpp(filein, *arguments)
File "extras/pokemontools/gfx.py", line 1073, in png_to_2bpp
width, height, rgba, info = png.Reader(filein).asRGBA8()
AttributeError: 'module' object has no attribute 'Reader'
Makefile:79: recipe for target 'red/main.o' failed
make: ** [red/main.o] Error 1
I'm not sure what the issue is, normally I'm decent at deciphering code but this one has me stumped.
The label processing code in extras/
is getting ridiculous. There are a few separate locations where label processing code is implemented:
class Label
in crystal.py
crystal.py
crystal.py
labels.py
class RomStr
in romstr.py
These should be consolidated and merged into one location. I bet there might even be one or two functions that are conceptually similar.
Above issue is from pret/pokecrystal#37
The tests aren't passing and this is bad. Needs to be fixed very soon.
The vba tests fail because save-states/
doesn't exist. Maybe auto-create it?
When I was making my own crystal hack, I noticed that the logo have a problem.
This logo is a compressed graphics, so I decided to dump this file to see what command that caused this problem and found out that all of the problem pixels are the part of reverse (0x6) command.
I tried to make the compression routine in gfx.py to not to score and do the reverse command then compress it. No problems found.
I concluded that there was a problem in reverse compression routine in gfx.py
At the moment it is using relative paths, which is wrong and easily broken.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.