Skip to content

Commit

Permalink
Merge branch 'master' into remove-extras
Browse files Browse the repository at this point in the history
  • Loading branch information
kanzure committed Aug 27, 2013
2 parents 464cfc9 + c61b3d4 commit 3453879
Show file tree
Hide file tree
Showing 393 changed files with 87,807 additions and 21,705 deletions.
116 changes: 65 additions & 51 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Getting Started

Compiling **pokecrystal.gbc** requires a certain **Pokemon Crystal** rom:
Assembling **pokecrystal.gbc** requires a certain **Pokemon Crystal** rom:

```
Pokemon - Crystal Version (UE) (V1.0) [C][!].gbc
Expand All @@ -9,11 +9,14 @@ md5: 9f2922b235a5eeb78d65594e82ef5dde

Save it as **baserom.gbc** in the repository.

Feel free to ask us on **[nucleus.kafuka.org #skeetendo](https://kiwiirc.com/client/irc.nolimitzone.com/?#skeetendo)** if something goes wrong!
Feel free to ask us on
**[nucleus.kafuka.org #skeetendo](https://kiwiirc.com/client/irc.nolimitzone.com/?#skeetendo)**
if something goes wrong.

# Windows

If you are on Windows and can't install Linux, **Cygwin** is a great alternative.
If you're on Windows and can't install Linux, **Cygwin** is a great alternative.


## Installing Cygwin

Expand All @@ -24,14 +27,20 @@ Cygwin provides a virtual Linux environment on Windows systems. Just get **setup
During the install:

* Keep the defaults.

* Most mirrors are molasses. Use **http://mirrors.kernel.org**.

* From the package selection, select **wget**.
* From the package selection, pick:
* **wget**
* **make**
* **git**
* **python**
* **python-setuptools**
* **unzip**

## Using Cygwin

Launch the **Cygwin terminal**. Maybe you know your way around the Linux terminal, **bash**. If not, a crash course:
Launch the **Cygwin terminal**.
Maybe you know your way around the Linux terminal ( **bash** ).
If not, a crash course:
```bash
# list files in current directory
ls
Expand All @@ -45,48 +54,40 @@ cd /away/we/go

## Getting up and running

We need a couple more things to be able to compile.

If you're feeling lazy, just paste these commands into your terminal.
We need three things to assemble the source into a rom.

**apt-cyg** lets you install new packages without running Cygwin setup.
1. **rgbds**
2. a **pokecrystal** repository
3. a **base rom**

We use **rgbds** to spit out a Game Boy rom from source.
```bash
wget http://apt-cyg.googlecode.com/svn/trunk/apt-cyg
chmod +x apt-cyg
mv apt-cyg /usr/local/bin/
cd /usr/local/bin
wget http://iimarck.us/etc/rgbds-20130811.zip
unzip -j rgbds-20130811.zip
rm rgbds-20130811.zip
```

Now we can use apt-cyg to install everything else.

```bash
apt-cyg install make git python python-setuptools unzip
easy_install pip
```

**rgbds** will let you compile Game Boy roms.

```bash
wget http://diyhpl.us/~bryan/irc/pokered/rgbds/rgbds-0.0.1.zip
unzip rgbds-0.0.1.zip
mv rgbds-0.0.1/* /usr/local/bin
rm -r rgbds-0.0.1*
```

Set up the **pokecrystal** repository:

The **pokecrystal** repository contains the source files used to create the rom.
```bash
cd ~
git clone https://github.com/kanzure/pokecrystal
cd pokecrystal

# install python requirements
pip install -r extras/requirements.txt
easy_install pip
pip install -r requirements.txt
```

## Don't forget baserom.gbc!!
Not everything is included in the source yet.
Missing patches are copied from a **base rom** (not included).

```
Pokemon - Crystal Version (UE) (V1.0) [C][!].gbc
md5: 9f2922b235a5eeb78d65594e82ef5dde
```

Make sure you downloaded a base rom. Name it **baserom.gbc**.
Name it **baserom.gbc**.

**pokecrystal** only compiles with the use of a git submodule. To activate the submodule type:

Expand All @@ -105,29 +106,25 @@ make

This ought to take **between 3 and 15 seconds**, depending on your computer.

If you see `cmp baserom.gbc pokecrystal.gbc` as the last line, the build was successful!
If the last line is `cmp baserom.gbc pokecrystal.gbc`, the build was successful!

Your first compile processes every source file at once. After that, **only modified source files have to be reprocessed**, so compiling again should be a few seconds faster.
Your first build processes every source file at once.
After that, **only modified source files have to be processed again**,
so compiling again should be a few seconds faster.

# Linux

```bash
sudo apt-get install make gcc bison git python python-setuptools

# unittest2 is required if using python2.6
sudo easy_install unittest2
sudo easy_install pip

# download rgbds source code
# install rgbds
git clone git://github.com/bentley/rgbds.git

# compile rgbds
cd rgbds
make
sudo make install

# check if rgbasm is installed now
which rgbasm
cd ..

# download pokecrystal
git clone git://github.com/kanzure/pokecrystal.git
Expand All @@ -144,22 +141,39 @@ pip install -r extras/requirements.txt
git config diff.hex.textconv hexdump
```

To compile the rom from asm source:
Put your base rom in the pokecrystal repository. Name it **baserom.gbc**.

To compile the rom from source:
```bash
make
```

That will take between 3 and 15 seconds, depending on your computer. If you see `cmp baserom.gbc pokecrystal.gbc` as the last line, the build was successful! Rejoice!
That will take between 3 and 15 seconds, depending on your computer.
If you see `cmp baserom.gbc pokecrystal.gbc` as the last line, the build was successful! Rejoice!


# Now what?

**main.asm** is a good starting point. The structure of the source is laid out here.
**[pokecrystal.asm](https://github.com/kanzure/pokecrystal/blob/master/pokecrystal.asm)** is a good starting point.
The structure of the source is laid out here.


* Other **make targets** that may come in handy:

* `make clean` deletes any preprocessed source files (.tx), rgbds object files and pokecrystal.gbc.
* `make pngs` decompresses any **lz** files in gfx/ and then exports any graphics files to **png**.
* `make lzs` does the reverse. This is already part of the build process, so **modified pngs will automatically be converted to 2bpp and lz-compressed** without any additional work.


* **Can't find something?**
Anyone can add to the source. There's lots to be uncovered.

* **Can't find something?** Anyone can add to the source. There's lots to be uncovered.
* **Do your own thing!**
The asm source is hack-friendly, and the supplementary scripts in extras/ can be used for other projects.

* **Do your own thing!** The asm source is hack-friendly, and the supplementary scripts in extras/ can be used for other projects.
We'll be happy to answer any **questions** on
**[nucleus.kafuka.org #skeetendo](https://kiwiirc.com/client/irc.nolimitzone.com/?#skeetendo)**.

* We'll be happy to answer any **questions** on **[nucleus.kafuka.org #skeetendo](https://kiwiirc.com/client/irc.nolimitzone.com/?#skeetendo)**.

Other **make targets** that may come in handy:

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pokecrystal.o: $(TEXTFILES:.asm=.tx) wram.asm constants.asm $(shell find constan
@rm -f $@

pokecrystal.gbc: pokecrystal.o
rgblink -o $@ $<
rgblink -n pokecrystal.sym -m pokecrystal.map -o $@ $<
rgbfix -Cjv -i BYTE -k 01 -l 0x33 -m 0x10 -p 0 -r 3 -t PM_CRYSTAL $@

pngs:
Expand Down
12 changes: 4 additions & 8 deletions battle/effect_commands.asm
Original file line number Diff line number Diff line change
Expand Up @@ -6850,7 +6850,7 @@ Function0x365d7: ; 365d7
ld a, $5
call Function0x3661d

ld hl, $6d45
ld hl, BadgeStatBoosts
call CallBankF

call SwitchTurn
Expand Down Expand Up @@ -8385,7 +8385,7 @@ BattleCommand98: ; 36f25
; doubleflyingdamage
ld a, BATTLE_VARS_SUBSTATUS3_OPP
call CleanGetBattleVarPair
bit 6, a ; flying
bit SUBSTATUS_FLYING, a
ret z
jr DoubleDamage
; 36f2f
Expand All @@ -8395,7 +8395,7 @@ BattleCommand99: ; 36f2f
; doubleundergrounddamage
ld a, BATTLE_VARS_SUBSTATUS3_OPP
call CleanGetBattleVarPair
bit 5, a ; underground
bit SUBSTATUS_UNDERGROUND, a
ret z

; fallthrough
Expand Down Expand Up @@ -10623,11 +10623,7 @@ BattleCommand6d: ; 37be8
ld a, [AttackMissed]
and a
ret nz

ld a, $3e
ld hl, $7ced
rst FarCall

callba GetHiddenPower
ret
; 37bf4

Expand Down
108 changes: 108 additions & 0 deletions battle/hidden_power.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
GetHiddenPower: ; fbced
; Override Hidden Power's type and power based on the actor's DVs.

ld hl, BattleMonDVs
ld a, [hBattleTurn]
and a
jr z, .GotDVs
ld hl, EnemyMonDVs
.GotDVs


; Power:

; Take the top bit from...

; Atk
ld a, [hl]
swap a
and 8
ld b, a
; Def
ld a, [hli]
and 8
srl a
or b
ld b, a
; Spd
ld a, [hl]
swap a
and 8
srl a
srl a
or b
ld b, a
; Spc
ld a, [hl]
and 8
srl a
srl a
srl a
or b
ld b, a

; * 5
add a
add a
add b
ld b, a

; + (Spc & 3)
ld a, [hld]
and 3
add b

; / 2
srl a

; + 30
add 30
; + 1
inc a
ld d, a


; Type:

; Def & 3
ld a, [hl]
and 3
ld b, a

; + (Atk & 3) << 2
ld a, [hl]
and 3 << 4
swap a
add a
add a
or b

; Skip Normal
inc a

; Skip type 6 (unused)
cp 6
jr c, .GotType
inc a

; Skip unused types between Steel and Fire
cp STEEL + 1
jr c, .GotType
add FIRE - (STEEL + 1)


.GotType
push af
ld a, BATTLE_VARS_MOVE_TYPE
call GetBattleVarPair
pop af
ld [hl], a

ld a, d
push af
callba BattleCommand06
pop af
ld d, a
ret
; fbd54

Loading

0 comments on commit 3453879

Please sign in to comment.