summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRangi42 <remy.oukaour+rangi42@gmail.com>2018-02-26 11:28:46 -0500
committerRangi42 <remy.oukaour+rangi42@gmail.com>2018-02-26 11:28:46 -0500
commit83af28e32f2bfcde9210c06bc5eb6466f92e4aa2 (patch)
tree7f5a34575b27d4d8f871a373ac1b4978f8657497
parentaaedef5dd3edff15a809b4c3e0f9c4e6eaa310c5 (diff)
Add more tables of contents, and commit the script used
-rw-r--r--Add-a-new-Fairy-type.md16
-rw-r--r--Allow-map-tiles-to-appear-above-sprites.md11
-rw-r--r--Automatically-reuse-Repel.md27
-rw-r--r--Colored-trainer-card-badges.md8
-rw-r--r--Remove-the-25%-failure-chance-for-AI-status-moves.md5
-rw-r--r--toc.py89
6 files changed, 135 insertions, 21 deletions
diff --git a/Add-a-new-Fairy-type.md b/Add-a-new-Fairy-type.md
index 0d30387..c29663c 100644
--- a/Add-a-new-Fairy-type.md
+++ b/Add-a-new-Fairy-type.md
@@ -3,16 +3,16 @@ This tutorial is for how to add a new type for Pokémon or moves. As an example,
## Contents
-1. [Add a `FAIRY` constant](#1-add-a-fairy-constant)
-2. [Update `TypeNames`](#2-update-typenames)
-3. [Update `TypeMatchups`](#3-update-typematchups)
-4. [Update `PokedexTypeSearchConversionTable` and `PokedexTypeSearchStrings`](#4-update-pokedextypesearchconversiontable-and-pokedextypesearchstrings)
+1. [Define a `FAIRY` constant](#1-define-a-fairy-constant)
+2. [Give the type a name](#2-give-the-type-a-name)
+3. [List the type matchups](#3-list-the-type-matchups)
+4. [Make it searchable in the Pokédex](#4-make-it-searchable-in-the-pokédex)
5. [Update Pokémon types](#5-update-pokémon-types)
6. [Update move types](#6-update-move-types)
7. [Change `POLKADOT_BOW` to boost Fairy moves](#7-change-polkadot_bow-to-boost-fairy-moves)
-## 1. Add a `FAIRY` constant
+## 1. Define a `FAIRY` constant
Gen 2 was before the physical/special split, so the types after `SPECIAL` count as special, and the rest count as physical. Fairy moves are mostly special, so we'll add it there.
@@ -35,7 +35,7 @@ TYPES_END EQU const_value
(If you're using an old version of pokecrystal where the `EGG_FAIRY` egg group constant was still called `FAIRY`, you'll have to name the type something different, like `FAIRY_T` or `FAERIE`.)
-## 2. Update `TypeNames`
+## 2. Give the type a name
Edit [data/types/names.asm](../blob/master/data/types/names.asm):
@@ -54,7 +54,7 @@ Dark: db "DARK@"
```
-## 3. Update `TypeMatchups`
+## 3. List the type matchups
Edit [data/types/type_matchups.asm](../blob/master/data/types/type_matchups.asm):
@@ -85,7 +85,7 @@ TypeMatchups: ; 34bb1
```
-## 4. Update `PokedexTypeSearchConversionTable` and `PokedexTypeSearchStrings`
+## 4. Make it searchable in the Pokédex
These tables are used for the Pokédex's type search feature.
diff --git a/Allow-map-tiles-to-appear-above-sprites.md b/Allow-map-tiles-to-appear-above-sprites.md
index 4b01c1b..0b4f90b 100644
--- a/Allow-map-tiles-to-appear-above-sprites.md
+++ b/Allow-map-tiles-to-appear-above-sprites.md
@@ -22,6 +22,15 @@ PRIORITY EQU 1 << OAM_PRIORITY ; $80
Every tile on the screen has an attribute byte. The lowest three bits define the color, which is why there's only room for eight colors (from `PAL_BG_GRAY`, 0, to `PAL_BG_TEXT`, 7). The other bits control other properties. In particular, the high bit controls **tile priority**. So if the [gfx/tilesets/\*\_palette\_map.asm](../blob/master/gfx/tilesets/) files could define tiles' priority as well as color, you could make any tile have priority over sprites.
+## Contents
+
+1. [Define `PAL_BG_PRIORITY_*` constants](#1-define-pal_bg_priority_-constants)
+2. [Use one byte per color for tileset palettes](#2-use-one-byte-per-color-for-tileset-palettes)
+3. [Fix the skipped space in palette_map.asm files](#3-fix-the-skipped-space-in-palette_mapasm-files)
+4. [Fix the bank overflow](#4-fix-the-bank-overflow)
+5. [Correctly read the extended palette data](#5-correctly-read-the-extended-palette-data)
+
+
## 1. Define `PAL_BG_PRIORITY_*` constants
Edit [constants/tileset_constants.asm](../blob/master/constants/tileset_constants.asm):
@@ -89,7 +98,7 @@ endr
```
-## 4. Fix the potential bank overflow
+## 4. Fix the bank overflow
Now the tileset palette data will take up twice as much space—one byte per tile instead of half a byte—so it won't fit in its ROM bank. Edit [main.asm](../blob/master/main.asm):
diff --git a/Automatically-reuse-Repel.md b/Automatically-reuse-Repel.md
index 8c1db9a..aba0ce8 100644
--- a/Automatically-reuse-Repel.md
+++ b/Automatically-reuse-Repel.md
@@ -2,13 +2,16 @@ Starting in B2/W2, when a Repel, Super Repel, or Max Repel expires and you have
Implementing this feature in Gen 2 is relatively simple, but does involve a number of different areas:
-- WRAM and SRAM need space to save the type of Repel
-- The Repel item effect needs to save its type
-- The script that notifies when a Repel wears off needs to check if you have another one and let you choose to reuse it
-- There needs to be an alternative notification message including the "Use another?" question text
+## Contents
+1. [Add space in WRAM and SRAM for the type of Repel used](#1-add-space-in-wram-and-sram-for-the-type-of-repel-used)
+2. [Store the type when a Repel is used](#2-store-the-type-when-a-repel-is-used)
+3. [Check if you have more of the last-used type when one wears off](#3-check-if-you-have-more-of-the-last-used-type-when-one-wears-off)
+4. [Ask whether to use another Repel, and do so, if applicable](#4-ask-whether-to-use-another-repel-and-do-so-if-applicable)
+5. [Define the "Use another?" message](#5-define-the-use-another-message)
-## 1. Add space in RAM for `wRepelType`
+
+## 1. Add space in WRAM and SRAM for the type of Repel used
There's already this line in [wram.asm](../blob/master/wram.asm):
@@ -32,22 +35,22 @@ wKurtApricornQuantity:: db
```
-## 2. Store `wRepelType` when a Repel is used
+## 2. Store the type when a Repel is used
The file that defines item effects is, predictably, [engine/item_effects.asm](../blob/master/engine/item_effects.asm). It turns out that Repel, Super Repel, and Max Repel all use the same code, so we don't have to write anything three times.
```diff
-SuperRepel: ; f462
+SuperRepelEffect: ; f462
ld b, 200
jr UseRepel
; f466
-MaxRepel: ; f466
+MaxRepelEffect: ; f466
ld b, 250
jr UseRepel
; f466
-Repel: ; f46a
+RepelEffect: ; f46a
ld b, 100
; f46c
@@ -72,7 +75,7 @@ TextJump_RepelUsedEarlierIsStillInEffect: ; 0xf47d
```
-## 3. Ask whether to reuse Repel
+## 3. Check if you have more of the last-used type when one wears off
Edit [engine/events.asm](../blob/master/engine/events.asm):
@@ -105,7 +108,7 @@ DoRepelStep: ; 96bd7
Note that `UseAnotherRepelScript` hasn't been defined yet, so we'll do that next.
-## 4. Define `UseAnotherRepelScript`
+## 4. Ask whether to use another Repel, and do so, if applicable
Edit [engine/events/misc_scripts_2.asm](../blob/master/engine/events/misc_scripts_2.asm):
@@ -140,7 +143,7 @@ RepelWoreOffScript:: ; 0x13619
Again, we have not yet defined `UseAnotherRepelText`, so let's finish up with that.
-## 5. Define `UseAnotherRepelText`
+## 5. Define the "Use another?" message
Edit [data/text/common_1.asm](../blob/master/data/text/common_1.asm):
diff --git a/Colored-trainer-card-badges.md b/Colored-trainer-card-badges.md
index c0f4af3..b175e5b 100644
--- a/Colored-trainer-card-badges.md
+++ b/Colored-trainer-card-badges.md
@@ -1,6 +1,14 @@
This one is a simple upgrade.
+## Contents
+
+1. [Define the colors](#1-define-the-colors)
+2. [Load the colors](#2-load-the-colors)
+3. [Apply the colors to the badges](#3-apply-the-colors-to-the-badges)
+4. [Redesign some badge graphics](#4-redesign-some-badge-graphics)
+
+
## 1. Define the colors
Create **gfx/trainer_card/badges.pal**:
diff --git a/Remove-the-25%-failure-chance-for-AI-status-moves.md b/Remove-the-25%-failure-chance-for-AI-status-moves.md
index fb228d6..3f7025e 100644
--- a/Remove-the-25%-failure-chance-for-AI-status-moves.md
+++ b/Remove-the-25%-failure-chance-for-AI-status-moves.md
@@ -1,5 +1,10 @@
When the AI uses stat-lowering or status-inflicting moves, like Screech or Sleep Powder, it has an additional 25% chance to fail on top of the usual accuracy and evasion modifiers. This is caused by four different clauses in [engine/battle/effect_commands.asm](../blob/master/engine/battle/effect_commands.asm), all of which will need deleting.
+- `BattleCommand_StatDown`
+- `BattleCommand_SleepTarget`
+- `BattleCommand_Poison`
+- `BattleCommand_Paralyze`
+
In `BattleCommand_StatDown`:
```diff
diff --git a/toc.py b/toc.py
new file mode 100644
index 0000000..9bdc8cc
--- /dev/null
+++ b/toc.py
@@ -0,0 +1,89 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+"""
+Usage: python3 toc.py [-n] files.md...
+Replace a "## TOC" heading in a Markdown file with a table of contents,
+generated from the other headings in the file. Supports multiple files.
+Headings must start with "##" signs to be detected.
+"""
+
+import sys
+import re
+from collections import namedtuple
+
+toc_name = 'Contents'
+valid_toc_headings = {'## TOC', '##TOC'}
+
+TocItem = namedtuple('TocItem', ['name', 'anchor', 'level'])
+punctuation_regexp = re.compile(r'[^\w\- ]+')
+
+def name_to_anchor(name):
+ # GitHub's algorithm for generating anchors from headings
+ # https://github.com/jch/html-pipeline/blob/master/lib/html/pipeline/toc_filter.rb
+ anchor = name.strip().lower() # lowercase
+ anchor = re.sub(punctuation_regexp, '', anchor) # remove punctuation
+ anchor = anchor.replace(' ', '-') # replace spaces with dash
+ return anchor
+
+def get_toc_index(lines):
+ toc_index = None
+ for i, line in enumerate(lines):
+ if line.rstrip() in valid_toc_headings:
+ toc_index = i
+ break
+ return toc_index
+
+def get_toc_items(lines, toc_index):
+ for i, line in enumerate(lines):
+ if i <= toc_index:
+ continue
+ if line.startswith('##'):
+ name = line.lstrip('#')
+ level = len(line) - len(name) - len('##')
+ name = name.strip()
+ anchor = name_to_anchor(name)
+ yield TocItem(name, anchor, level)
+
+def toc_string(toc_items):
+ lines = ['## %s' % toc_name, '']
+ for name, anchor, level in toc_items:
+ padding = ' ' * level
+ line = '%s- [%s](#%s)' % (padding, name, anchor)
+ lines.append(line)
+ return '\n'.join(lines) + '\n'
+
+def add_toc(filename):
+ with open(filename, 'r', encoding='utf-8') as f:
+ lines = f.readlines()
+ toc_index = get_toc_index(lines)
+ if toc_index is None:
+ return None # no TOC heading
+ toc_items = list(get_toc_items(lines, toc_index))
+ if not toc_items:
+ return False # no content headings
+ with open(filename, 'w', encoding='utf-8') as f:
+ for i, line in enumerate(lines):
+ if i == toc_index:
+ f.write(toc_string(toc_items))
+ else:
+ f.write(line)
+ return True # OK
+
+def main():
+ if len(sys.argv) < 2:
+ print('*** ERROR: No filenames specified')
+ print(__doc__)
+ exit(1)
+ for filename in sys.argv[1:]:
+ print(filename)
+ result = add_toc(filename)
+ if result is None:
+ print('*** WARNING: No "## TOC" heading found')
+ elif result is False:
+ print('*** WARNING: No content headings found')
+ else:
+ print('OK')
+
+if __name__ == '__main__':
+ main()