From 0a2eabd59a3e23ad5904cf20a79d941ae3a0f806 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Wed, 19 Sep 2018 21:49:10 -0400 Subject: [PATCH 1/5] Refactor .gitattributes and .gitignore --- .gitattributes | 41 ++++++++++++++++++++++++++++++++--------- .gitignore | 1 + 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/.gitattributes b/.gitattributes index c0197ac4f..63f271aff 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,11 +1,34 @@ -# No monkey business with line endings -* -text +# Auto detect text files and perform LF normalization +* text eol=lf -# hexdump binary files -*.png binary diff=hex -*.lz binary diff=hex +# Explicitly declare text files you want to always be normalized and converted +# to native line endings on checkout. + +# files part of the build +*.asm text +*.pal text +*.link text +*.txt text + +# extra files +*.awk text +*.c text +*.h text +*.MD text +*.py text +*.sh text +*.sha1 text + +# Denote all files that are truly binary and should not be modified. +*.png binary diff=hex +*.lz.* binary diff=hex +*.bin binary diff=hex +*.blk binary diff=hex +*.rle binary diff=hex +*.attrmap binary diff=hex +*.tilemap binary diff=hex + +# these are generated but just in case +*.lz binary diff=hex *.2bpp binary diff=hex -*.1bpp binary diff=hex -*.bin binary diff=hex -*.blk binary diff=hex - +*.1bpp binary diff=hex \ No newline at end of file diff --git a/.gitignore b/.gitignore index d3dfbf82b..3a781d1df 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ *.sgm *.sav *.rtc +*.sn* # rgbds extras *.map From d6c44f0ca4b5bc93820e9ad1b46a3492dabdd26e Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Thu, 20 Sep 2018 11:17:05 -0400 Subject: [PATCH 2/5] Remove *.pal from gitignore, remove more build objects with make clean. --- .gitignore | 4 ++-- Makefile | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 3a781d1df..55797d264 100644 --- a/.gitignore +++ b/.gitignore @@ -40,8 +40,8 @@ pokecrystal.txt *.2bpp *.1bpp *.lz -*.pal *.animated.tilemap gfx/pokemon/*/bitmask.asm gfx/pokemon/*/frames.asm -!gfx/pokemon/*/shiny.pal +!gfx/pokemon/unown/bitmask.asm +!gfx/pokemon/unown/frames.asm \ No newline at end of file diff --git a/Makefile b/Makefile index 6ece5e510..f92cdda04 100644 --- a/Makefile +++ b/Makefile @@ -42,8 +42,10 @@ all: crystal crystal: pokecrystal.gbc crystal11: pokecrystal11.gbc +# TODO: clean bitmask.asm and frames.asm for all mons except unown clean: rm -f $(roms) $(crystal_obj) $(crystal11_obj) $(roms:.gbc=.map) $(roms:.gbc=.sym) + find . \( -iname '*.1bpp' -o -iname '*.2bpp' -o -iname '*.lz' -o -iname '*.gbcpal' -o -iname '*.dimensions' -o -iname '*.animated.tilemap' \) -exec rm {} + $(MAKE) clean -C tools/ compare: $(roms) From 850ef245f38b7ac587d5cf62acdc380774bb2716 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Thu, 20 Sep 2018 11:32:53 -0400 Subject: [PATCH 3/5] Fix toc.py line endings (for travis-ci) --- tools/toc.py | 178 +++++++++++++++++++++++++-------------------------- 1 file changed, 89 insertions(+), 89 deletions(-) diff --git a/tools/toc.py b/tools/toc.py index 9bdc8cca6..8ff50be94 100755 --- a/tools/toc.py +++ b/tools/toc.py @@ -1,89 +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() +#!/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() From 4ab1ee8920c07116bddba1a7eb0f46924198b1b4 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Sun, 23 Sep 2018 13:44:23 -0400 Subject: [PATCH 4/5] Add make tidy and remove bitmask.asm and frames.asm in make clean --- Makefile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index f92cdda04..c78a996ce 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ crystal11_obj := $(crystal_obj:.o=11.o) ### Build targets .SUFFIXES: -.PHONY: all crystal crystal11 clean compare tools +.PHONY: all crystal crystal11 clean compare tools tidy .SECONDEXPANSION: .PRECIOUS: .SECONDARY: @@ -42,10 +42,14 @@ all: crystal crystal: pokecrystal.gbc crystal11: pokecrystal11.gbc -# TODO: clean bitmask.asm and frames.asm for all mons except unown clean: rm -f $(roms) $(crystal_obj) $(crystal11_obj) $(roms:.gbc=.map) $(roms:.gbc=.sym) - find . \( -iname '*.1bpp' -o -iname '*.2bpp' -o -iname '*.lz' -o -iname '*.gbcpal' -o -iname '*.dimensions' -o -iname '*.animated.tilemap' \) -exec rm {} + + find gfx \( -name "*.[12]bpp" -o -name "*.lz" -o -name "*.gbcpal" \) -delete + find gfx/pokemon -mindepth 1 ! -path "gfx/pokemon/unown/*" \( -name "bitmask.asm" -o -name "frames.asm" -o -name "front.animated.tilemap" -o -name "front.dimensions" \) -delete + $(MAKE) clean -C tools/ + +tidy: + rm -f $(roms) $(crystal_obj) $(crystal11_obj) $(roms:.gbc=.map) $(roms:.gbc=.sym) $(MAKE) clean -C tools/ compare: $(roms) From 0e30519bd44c88f958c917645052180b32ebfac2 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Sun, 23 Sep 2018 14:03:55 -0400 Subject: [PATCH 5/5] Lowercase *.md --- .gitattributes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index 63f271aff..adc91cdb3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -14,7 +14,7 @@ *.awk text *.c text *.h text -*.MD text +*.md text *.py text *.sh text *.sha1 text