GithubHelp home page GithubHelp logo

pret / pokered Goto Github PK

View Code? Open in Web Editor NEW
3.8K 119.0 844.0 18.94 MB

Disassembly of Pokémon Red/Blue

Makefile 0.14% Assembly 92.36% C 0.89% Python 6.55% Awk 0.05%
pokemon disassembly gameboy reverse-engineering gbz80

pokered's Introduction

Pokémon Red and Blue Build Status

This is a disassembly of Pokémon Red and Blue.

It builds the following ROMs:

  • Pokemon Red (UE) [S][!].gb sha1: ea9bcae617fdf159b045185467ae58b2e4a48b9a
  • Pokemon Blue (UE) [S][!].gb sha1: d7037c83e1ae5b39bde3c30787637ba1d4c48ce2
  • BLUEMONS.GB (debug build) sha1: 5b1456177671b79b263c614ea0e7cc9ac542e9c4
  • dmgapae0.e69.patch sha1: 0fb5f743696adfe1dbb2e062111f08f9bc5a293a
  • dmgapee0.e68.patch sha1: ed4be94dc29c64271942c87f2157bca9ca1019c7

To set up the repository, see INSTALL.md.

See also

You can find us on Discord (pret, #pokered).

For other pret projects, see pret.github.io.

pokered's People

Contributors

akatsuki105 avatar antoniond avatar codercharmander avatar dannye avatar eggy0 avatar huderlem avatar iimarckus avatar kanzure avatar kqesar avatar linusu avatar luckytyphlosion avatar mattbruv avatar mid-kid avatar mrwint avatar pikalaxalt avatar pokechu22 avatar pokeglitch avatar rangi42 avatar rawr51919 avatar roukaour avatar sanqui avatar satomew avatar sawakita avatar stag019 avatar strager avatar vortyne avatar vulcandth avatar xcrystal avatar xeons avatar yenatch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pokered's Issues

IMAP doesn't use map constants.

        IMAP $29,$2,$B,PalletTownName
        IMAP OAKS_LAB + 1, 2, 11, PalletTownName

This is a good opportunity to enumerate map constants. That way you could instead do

        ...

        enum REDS_HOUSE_1F
        enum REDS_HOUSE_2F
        enum BLUES_HOUSE
        enum OAKS_LAB

IMAP_PALLET equ __enum__

        enum VIRIDIAN_POKECENTER
        ...

then

        IMAP PALLET, 2, 11, PalletTownName

Use macros for warps and signs too, not just objects and warp-to points

In the data/mapObjects/ files, objects are defined with object and warp-to points with EVENT_DISP. However, warps and signs are defined with db. Using named macros would make it easier for mapping programs to parse these files. warp and sign would work, and would avoid colliding with pokecrystal's warp_def, warp_event, or signpost.

Cannot make src/asm/asmy.o on Mac OS X

On Mac OS X:
$ make
c99: invalid argument `error=implicit-int' to -W
Makefile:83: recipe for target 'src/asm/asmy.o' failed
make: *** [src/asm/asmy.o] Error 64

Not an issue but just a question (or two)...

With this disassembly, are you doing a 1:1 compatible build of the Pokemon Red/Blue ROMs?

For example if you play any of the built ROMs, will the game be identical to the retail ROM? Or do we have bug fixes that nerf some of the common glitches and other things like MissingNo?

I don't mind if we're doing a 1:1 replica of the classic game code, but bonus points if MissingNo and friends get nerfed.

Compiling with cygwin

While trying to compile in cygwin, I get the following error:
ERROR: wram.asm(3146):
Constant mustn't be negative: -2
make: *** [Makefile:46: wram_red.o] Error 5

However, I haven't actually made any changes to this file, especially not anything related to that particular line, so I'm unsure of what would be causing it.

Change name to wd74b

I was searching and wd74b at wram is the flag that controls if the players has the pokedex.

wd74b could be: W_ISPOKEDEXOWNED or something similar

Error while compiling. Makefile:87: recipe for target 'red/main.o' failed

$ make
rgbasm -h -o red/main.o red/main.tx
ERROR: red/main.tx(2) -> main.tx(15) -> home.tx(4676) -> add_tx_pre(1) : Macro 'ext_id' not defined
ERROR: red/main.tx(2) -> main.tx(15) -> home.tx(4677) -> add_tx_pre(1) : syntax error
Assembly aborted in pass 1 (2 errors)!
Makefile:87: recipe for target 'red/main.o' failed
make: *** [red/main.o] Error 1

I'm using Linux, Debian. Someone else is getting the same issue using Windows 7, however. I am also having an error for

sudo pip install -r extras/requirements.txt

I get the error:

Command /usr/bin/python -c "import setuptools, tokenize;file='/tmp/pip_build_root/pillow/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /tmp/pip-Si_iHU-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/pillow
Storing debug log for failure in /root/.pip/pip.log

Not sure if it's worth mentioning, but I have an older version installed, all the way from May, and it still compiles just fine.

Thanks!

Use Japanese Overlay Key?

Hey, in the Japanese games the alphabet has assigned a special key so that if you press ° it'll overlay on top of the character and make ぱぴぷぺぽ as opposed to はひふへほ for example. I wanted to utilize this for my game, so that if I were to replace it and press ˆ I'd get ĈĜĤ.

But I don't know how to:

  1. Access the Japanese alphabet and/or that special key in the first place (if even it exists in the English release?),
  2. change the key mapping in the text editor so that if I type ĉ it shows up as ĉ in-game (I've submitted a separate help request for that).

It could be that one of the many blank keys on the English alphabet layout is this special key, so I guess I can try looking at that first...

Duty cycle command naming

I am not sure if "duty" and "dutycycle" are the best names. They could be potentially confusing because they don't agree with the usual meaning of "duty cycle".

Normally, the term "duty cycle" means the percentage of time a signal is active over one cycle (on a Game Boy, this can be 12.5%, 25%, 50% or 75%).

We are calling a fixed duty cycle "duty", which is fine, but we have another command called "dutycycle" which seems like it should be a synonym but isn't.

The "dutycycle" command specifies 4 duty cycles. Every update, the duty cycles are rotated. This results in a sequence of duty cycles that repeats every 4 updates. It could be called a cycle of duty cycles.

I don't know what the best names would be. Maybe "dutycycle" and "dutycycles" would make it more obvious. I also think that the existing "dutycycle" command should take 4 parameters rather than one.

What do you think?

Programming language

Was Pokemon Red originally written in Assmbly?

Why not C? Was it because of some hardware limitations? Was it to optimize it as much as possible in terms of performance and required space?

rgbgfx + c tools

need to unearth pkmncompress.c and use the other pokecrystal c tools instead of the submodule

Missing resources.

When im compiling the ASM code with rgbasm i get the next error:
rgbasm: Unable to open incbin file 'gfx/tilesets/flower/flower1.2bpp': No such file or directory
The error is that there isn't a file named flower1.2bpp on the folder gfx/tilesets/flower.

use a macro for object events

    db $7 ; people
    db SPRITE_HIKER, $3 + 4, $5 + 4, $ff, $d0, TRAINER | $1, BLACKBELT + $C8, $1
    db SPRITE_HIKER, $4 + 4, $3 + 4, $ff, $d3, TRAINER | $2, BLACKBELT + $C8, $2
    db SPRITE_HIKER, $6 + 4, $3 + 4, $ff, $d3, TRAINER | $3, BLACKBELT + $C8, $3
    db SPRITE_HIKER, $5 + 4, $5 + 4, $ff, $d2, TRAINER | $4, BLACKBELT + $C8, $4
    db SPRITE_HIKER, $7 + 4, $5 + 4, $ff, $d2, TRAINER | $5, BLACKBELT + $C8, $5
    db SPRITE_BALL, $1 + 4, $4 + 4, $ff, $ff, $6 ; person
    db SPRITE_BALL, $1 + 4, $5 + 4, $ff, $ff, $7 ; person
    db 7
    object SPRITE_HIKER,  3,  5, FACE, DOWN,  1, BLACKBELT, 1
    object SPRITE_HIKER,  4,  3, FACE, LEFT,  2, BLACKBELT, 2
    object SPRITE_HIKER,  6,  3, FACE, LEFT,  3, BLACKBELT, 3
    object SPRITE_HIKER,  5,  5, FACE, RIGHT, 4, BLACKBELT, 4
    object SPRITE_HIKER,  7,  5, FACE, RIGHT, 5, BLACKBELT, 5
    object SPRITE_BALL,   1,  4, FACE, STAY,  6
    object SPRITE_BALL,   1,  5, FACE, STAY,  7

It would also help to describe what each parameter is and/or create shortcuts. For instance, $ff, $d3 means "face left".

object: macro
; sprite, x, y, action, direction, script
; - item_id
; - trainer, id
    ...
endm

Trainers and items take an extra two bytes and one byte respectively, so they can be inferred from _NARG.

how to open the asm files?

i want to listen to the unused tracks and the cries and idk how to open the asm files for them
help plz

Tidy up map connection macros.

The map connection macros have constants like ROUTE_10_HEIGHT - 24, but that doesn't really capture what the actual value should be. I'm not sure what the right thing to do is, but it seems like hardcoding the actual value would be better than doing confusing subtraction.

Question: Changing Alphabet?

Hey, I realize that to change the general in-game alphabet I just edit font.png, but how can I change which keys map to what when editing text/dialogue so I can ex. write ĉ in the text editor and ĉ appears in the game? (Instead of how it is now where I replace x with ĉ on font.png, then type x in the text editor in order to get ĉ).

split up and group related wram/rom sections

Find a way to arrange disorganized sections in the same order as the baserom.

  • Is this feasible when rgblink only cares about the order objects and sections are read?
  • Will it even be any easier to manage if rgblink is changed to sort sections by some other method?

Section prototypes were proposed in the past. Example:

section "first", wram0
section "second", wram0

section "main", rom0
    dw wSecond, wFirst

section "second", wram0
wSecond:
    ds 10

section "first", wram0
wFirst:
    ds 10

outputs

c00a c000

This method works already within an object, but rgblink considers one object at a time when determining section placement, even if both sections are declared in both objects.

Support for Yellow version?

Good day.

I wanted to drop by and ask if there are some plans about giving Pokemon Yellow the same treatment as Red & Blue?
I would love to see the game in full colour along with many of the Gen II features.
I would surely give it a second run from scratch up to all the 151 Pokemon if it becomes available.

Thanks in advance!

Disassemble Pokemon Green.

Can you disassemble the Japanese Green? I'm trying to get something from the files, but I can't find them anywhere else online. Thanks!

Build fails using Python 3.5.2

I'm using Arch Linux here and got "python" pointing to Python 3.5.2.

Typing "make" would result in the following message:

$ make                                                                                                  
rgbasm -D _RED -h -o audio_red.o audio.asm                                                                                        
  File "extras/pokemontools/gfx.py", line 72                                                                                      
    tiles = sorted(enumerate(tiles), key= lambda (i, tile): i % width) 

A workaround for me was to modify the first line of the Makefile from PYTHON := python to PYTHON := python2.7.

Question - Green Version?

Hey, do you guys have any plans for making this work with Green (or the Japanese games in general)? I want to make a Green hack but as it is now it means replacing the graphics, pallette, cave layout, and all the dialogue, and then anyone else who wants to do the same thing has to go through all the same trouble as me....

EDIT: nevermind, I found out someone's doing it!

.blk Readability

I'm assuming the map files .blk are hex files. Do you think it would be possible to have these in a readable format and then converted back to hex during make?

Like have it in ascii format

HEADER
tile (0,0)(tile#,special1,special2)
tile (0,1)(tile#,special1,special2)

Since it isn't assembly code and just standard bytes I think making it user friendly in source would be great. This would make map editing much easier

charmap.asm syntax error?

Hey! Bit of a linux noob here but I know my way around. After getting all rgbds to finally work (using stable branch), get this problem.

(precise)sam@localhost:~/newfolder/test/pokered$ make
rgbasm -h -o red/main.o red/main.asm
ERROR: red/main.asm(1) -> red.asm(2) -> charmap.asm(2) :
syntax error
Assembly aborted in pass 1 (1 errors)!
make: *** [red/main.o] Error 1

So it says there's a syntax error in charmap.asm at line 2. Can't see what it is but I've never programmed assembly.

MIDI importer

After coming across this wonderful project, I saw an issue in the Crystal disassembly planning a MIDI importer, and after studying the music macro format a bit I decided to bang one out for Red over the last week:

https://github.com/mtolly/pokemid

Currently the main features are: it takes care of turning MIDI durations and pitches into the right sequence of note speed and octave commands, it supports both one-shot and looping tracks, as well as most of the note alteration macros, and also does some rudimentary code shrinking by finding repeated sections and making subroutines.

For now it is a ~500-line Haskell program, but I've put up binaries on the release page for Windows/Mac/Linux so you hopefully shouldn't need to install anything to try it out. It comes with 2 short MIDI files as tests, which generate equivalent (but not identical) code for introbattle.asm and safarizone.asm.

Basically I'd like to know what you guys want out of the tool. It is not finished but all the core logic and design is there. The primary issue is that it does not generate identical code to the original files, only code which behaves equivalently (to my knowledge). Emitting identical assembly can't be easily done without making the MIDI files specify more low-level details of labels and branching which doesn't seem useful to me. So I wouldn't really recommend using this to store the repo's music in MIDI like how the images are stored in PNG.

Cant Compile with cygwin

Hi,
I'm trying to compile with cygwin but i get this error:
$ make red
Preprocessing 1 file...
rgbasm -h -o red/audio.o red/audio.tx
rgbasm -h -o red/main.o red/main.tx
ERROR: red/main.tx(2) -> main.tx(15) -> home.tx(4677) -> add_tx_pre(1) :
Macro 'ext_id' not defined
ERROR: red/main.tx(2) -> main.tx(15) -> home.tx(4678) -> add_tx_pre(1) :
syntax error
Assembly aborted in pass 1 (2 errors)!
Makefile:87: recipe for target 'red/main.o' failed
make: *** [red/main.o] Error 1

I go to the code:
add_tx_pre CardKeySuccessText ; 01
then i go to add_tx_pre:
add_tx_pre: MACRO
\1_id:: dw \1
ENDM
The problem is inside that.

I tried to compile with a version before Text was changed to add_tx_pre and it works.

Rename PSYCHIC to PSYCHIC_TYPE

People often forget or aren't aware of the difference between PSYCHIC and PSYCHIC_M.

This would prevent someone from using the wrong PSYCHIC constant.

RIP Nintendo CEO - Mr Satoru Iwata

I know it's not a technically an issue, and I apologise if it's considered spamming the issues... but considering how many hours he must have spent poring over the code that has been liberated in this repository, I thought it was more suitable to leave my sentiments here then in a Facebook post to an audience of mostly non-gamer friends.

I did not know much about the Iwata-san's programming talents before today. For instance, I didn't know that he led the programming on one of my all time favourite games, 'Earthbound'. Or indeed that he was able to decipher the pokemon battle system within a week, and go on to port it for another game in the franchise.

This quote is probably being overused today, but I love the fact that a CEO of one of the world's biggest videogame companies was able to say it-

"On my business card, I am a corporate president. In my mind, I am a game developer. But in my heart, I am a gamer." - Satoru Iwata in his keynote speech at GDC 2005

RIP

https://www.nintendo.co.uk/Iwata-Asks/Iwata-Asks-Pokemon-HeartGold-Version-SoulSilver-Version/Iwata-Asks-Pokemon-HeartGold-Version-SoulSilver-Version/3-Just-Being-President-Was-A-Waste-/3-Just-Being-President-Was-A-Waste--225951.html

http://www.gamefaqs.com/boards/631516-wii-u/65723555

Unable to load fixed ROMX section into bank $1F

Trying to build using cgywin, it comes up with this error.
$ make
rgbasm -h -o red/audio.o red/audio.asm
rgbasm -h -o red/main.o red/main.asm
rgbasm -h -o red/text.o red/text.asm
rgbasm -h -o red/wram.o red/wram.asm
rgblink -n pokered.sym -o pokered.gbc red/audio.o red/main.o red/text.o red/wram.o
: Unable to load fixed ROMX section into bank $1F
Makefile:91: recipe for target 'pokered.gbc' failed
make: *** [pokered.gbc] Error 1

What causes this?

I was able to build Kanzure's version without any errors. (except the fact my modified .asm files would not be applied in the build)

Sound and Battles are broken

The only sounds working correctly are Professor Oak song while choosing name and such and pokemon cries. The rest are either playing the wrong songs, wrong speed, or just aren't present.

The first battle with Gary glitches after first attack, taking forever to load, not continuing, etc.

This is the current build.

I also noticed that there were warning signs during make about jp [hl] and [sp + 0] being obsolete, so i wrote a script to fix them, although this does not fix the problems listed above.

find . -name "*.asm" -exec sed -i -e 's/jp \[hl\]/jp hl/g' {} \;
echo "Done fixing jp hl"
find . -name "*.asm" -exec sed -i -e 's/\[sp + 0\]/sp+0/g' {} \;
echo "Dont fixing sp+0"

MBC Type?

I'm having trouble determining which MBC is officially used for these cartridges.

I can see from the disassembly, and from my own dumped Pokemon Blue, that it acts like an MBC1. But looking at the header data, at 0x0147, I find the value 0x13, indicating an MBC3 controller with SRAM and battery, but no RTC.

Have I overseen something, or is the value of 0x13 or my MBC table just incorrect?

Removing Missingno?

I wondered if you will be removing Missingno. Also I can I test this game? I don't know how to convert it into a .gba game yet but thanks anyway

Fresh Install + "Make Red" problem

Hi, I just tried to re-install pokered after I did a fresh install of my OS. I wrote "cd pokered, make red" immediately after and got this error:

rgbasm -D _RED -h -o audio_red.o audio.asm
make: rgbasm: No such file or directory
make: *** [audio_red.o] Error 1

I searched and the "rgbasm" file's in the "rgbds" folder. What am I doing wrong?

Make failed: Section 'Stack' is too big

I followed the instructions exactly, and it gives me this error.

screenshot from 2017-04-28 14 01 05

Also the install instructions don't mention that flex has to be installed. 'sudo apt-get install flex' worked though.

How do I assemble on mac?

I'm on mac. I'm completely new to programming. How do I assemble a ROM that reflects the changes I've made? The command in install.md builds the original disassembly.

Queston

Can some one make an updated version on how to ad genders

Suggestion: Japanese Graphics?

Hi, it would be really cool if we could somehow have the option of picking from the English or Japanese graphics. Seems like the Japanese Red and Green have different graphics compared to the Japanese Yellow, but the English Red uses the Japanese Yellow graphics. Check it out:

skarmavbild 2016-03-12 kl 19 34 08
skarmavbild 2016-03-12 kl 19 37 37

The only things I've seen people talk about so far have been the pokemon battle sprites + the overworld flowers being different, but as the pictures show there's probably a lot more...

EDIT: Maybe it's mostly just a mapping issue? It seems like the English Yellow actually uses some of the same graphics as the Japanese RBG, so I guess I'll be stealing stuff from pokeyellow!

Non-default Cygwin binary directory not in PATH

So, I've tried to build the ROM files but I seem to get an error.

bash-4.4$ git clone --recursive https://github.com/pret/pokered
Cloning into 'pokered'...
remote: Counting objects: 22380, done.
remote: Total 22380 (delta 0), reused 0 (delta 0), pack-reused 22380
ects: 100% (
Receiving objects: 100% (22380/22380), 11.84 MiB | 543.00 KiB/s, done.
Resolving deltas: 100% (14763/14763), done.
Checking connectivity... done.
Checking out files: 100% (2847/2847), done.
Submodule 'extras' (git://github.com/kanzure/pokemon-reverse-engineering-tools.git) registered for path 'extras'
Cloning into '/usr/bin/pokered/extras'...
remote: Counting objects: 4577, done.
remote: Total 4577 (delta 0), reused 0 (delta 0), pack-reused 4577
ts: 100%
Receiving objects: 100% (4577/4577), 2.29 MiB | 546.00 KiB/s, done.
Resolving deltas: 100% (2882/2882), done.
Checking connectivity... done.
Submodule path 'extras': checked out '0e1798937a4bf723813574281d0dc12c471c9199'
bash-4.4$ cd pokered
bash-4.4$ make
rgbasm -D _RED -h -o audio_red.o audio.asm
make: rgbasm: Command not found
make: *** [Makefile:37: audio_red.o] Error 127
bash-4.4$

I'm running 64-bit Windows 10. I've installed Cygwin on HDD E:\ , I've put the rgbasm files on the right directory and I believe I have set the var "Path" correctly. Any clues?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.