mirror of
https://github.com/pret/pokeruby.git
synced 2026-03-21 17:54:19 -05:00
Sync tools
This commit is contained in:
parent
00369ab8ef
commit
7505574a7d
51
Makefile
51
Makefile
|
|
@ -5,6 +5,9 @@ ifeq (compare,$(MAKECMDGOALS))
|
|||
COMPARE := 1
|
||||
endif
|
||||
|
||||
# Default make rule
|
||||
all: rom
|
||||
|
||||
# don't use dkP's base_tools anymore
|
||||
# because the redefinition of $(CC) conflicts
|
||||
# with when we want to use $(CC) to preprocess files
|
||||
|
|
@ -70,6 +73,10 @@ CPP := $(PREFIX)cpp
|
|||
LD := $(PREFIX)ld
|
||||
OBJCOPY := $(PREFIX)objcopy
|
||||
|
||||
# Variable filled out in other make files
|
||||
AUTO_GEN_TARGETS :=
|
||||
include make_tools.mk
|
||||
|
||||
SHA1SUM := $(shell { command -v sha1sum || command -v shasum; } 2>/dev/null) -c
|
||||
GBAGFX := tools/gbagfx/gbagfx$(EXE)
|
||||
RSFONT := tools/rsfont/rsfont$(EXE)
|
||||
|
|
@ -106,6 +113,7 @@ ELF := $(ROM:%.gba=%.elf)
|
|||
SYM := $(ROM:%.gba=%.sym)
|
||||
|
||||
BUILD_DIR := build/$(BUILD_NAME)
|
||||
DATA_ASM_SUBDIR = data
|
||||
|
||||
C_SOURCES := $(wildcard src/*.c src/*/*.c src/*/*/*.c)
|
||||
ASM_SOURCES := $(wildcard src/*.s src/*/*.s asm/*.s data/*.s sound/*.s sound/*/*.s)
|
||||
|
|
@ -151,14 +159,15 @@ ALL_BUILDS := ruby ruby_debug ruby_rev1 ruby_rev2 sapphire sapphire_debug sapphi
|
|||
MODERN_BUILDS := $(ALL_BUILDS:%=%_modern)
|
||||
|
||||
# Available targets
|
||||
.PHONY: all clean mostlyclean tidy tools syms $(ALL_BUILDS)
|
||||
.PHONY: all clean tidy syms $(ALL_BUILDS)
|
||||
|
||||
infoshell = $(foreach line, $(shell $1 | sed "s/ /__SPACE__/g"), $(info $(subst __SPACE__, ,$(line))))
|
||||
|
||||
# Build tools when building the rom
|
||||
# Disable dependency scanning for clean/tidy/tools
|
||||
ifeq (,$(filter-out all modern compare syms,$(MAKECMDGOALS)))
|
||||
$(call infoshell, $(MAKE) tools)
|
||||
$(call infoshell, $(MAKE) -f make_tools.mk)
|
||||
$(call infoshell, $(MAKE) generated)
|
||||
else
|
||||
NODEP := 1
|
||||
endif
|
||||
|
|
@ -184,18 +193,19 @@ MAKEFLAGS += --no-print-directory
|
|||
# Create build subdirectories
|
||||
$(shell mkdir -p $(SUBDIRS))
|
||||
|
||||
AUTO_GEN_TARGETS :=
|
||||
# Pretend rules that are actually flags defer to `make all`
|
||||
modern: all
|
||||
compare: all
|
||||
|
||||
all: $(ROM)
|
||||
# Other rules
|
||||
rom: $(ROM)
|
||||
ifeq ($(COMPARE),1)
|
||||
@$(SHA1SUM) $(BUILD_NAME).sha1
|
||||
endif
|
||||
|
||||
compare: ; @$(MAKE) COMPARE=1
|
||||
|
||||
syms: $(SYM)
|
||||
|
||||
mostlyclean: tidy
|
||||
clean: tidy
|
||||
find sound/direct_sound_samples \( -iname '*.bin' \) -exec rm {} +
|
||||
$(RM) $(ALL_OBJECTS)
|
||||
find . \( -iname '*.1bpp' -o -iname '*.4bpp' -o -iname '*.8bpp' -o -iname '*.gbapal' -o -iname '*.lz' -o -iname '*.rl' \) -exec rm {} +
|
||||
|
|
@ -204,31 +214,6 @@ mostlyclean: tidy
|
|||
find data/maps \( -iname 'connections.inc' -o -iname 'events.inc' -o -iname 'header.inc' \) -exec rm {} +
|
||||
rm -f $(AUTO_GEN_TARGETS)
|
||||
|
||||
clean: mostlyclean
|
||||
$(MAKE) clean -C tools/gbagfx
|
||||
$(MAKE) clean -C tools/scaninc
|
||||
$(MAKE) clean -C tools/preproc
|
||||
$(MAKE) clean -C tools/bin2c
|
||||
$(MAKE) clean -C tools/rsfont
|
||||
$(MAKE) clean -C tools/aif2pcm
|
||||
$(MAKE) clean -C tools/ramscrgen
|
||||
$(MAKE) clean -C tools/gbafix
|
||||
$(MAKE) clean -C tools/mapjson
|
||||
$(MAKE) clean -C tools/jsonproc
|
||||
|
||||
tools:
|
||||
@$(MAKE) -C tools/gbagfx
|
||||
@$(MAKE) -C tools/scaninc
|
||||
@$(MAKE) -C tools/preproc
|
||||
@$(MAKE) -C tools/bin2c
|
||||
@$(MAKE) -C tools/rsfont
|
||||
@$(MAKE) -C tools/aif2pcm
|
||||
@$(MAKE) -C tools/ramscrgen
|
||||
@$(MAKE) -C tools/mid2agb
|
||||
@$(MAKE) -C tools/gbafix
|
||||
@$(MAKE) -C tools/mapjson
|
||||
@$(MAKE) -C tools/jsonproc
|
||||
|
||||
tidy:
|
||||
$(RM) $(ALL_BUILDS:%=poke%{.gba,.elf,.map})
|
||||
$(RM) $(MODERN_BUILDS:%=poke%{.gba,.elf,.map})
|
||||
|
|
@ -323,6 +308,8 @@ include override.mk
|
|||
include map_data_rules.mk
|
||||
include json_data_rules.mk
|
||||
|
||||
generated: $(AUTO_GEN_TARGETS)
|
||||
|
||||
%.1bpp: %.png ; $(GBAGFX) $< $@ $(GFX_OPTS)
|
||||
%.4bpp: %.png ; $(GBAGFX) $< $@ $(GFX_OPTS)
|
||||
%.8bpp: %.png ; $(GBAGFX) $< $@ $(GFX_OPTS)
|
||||
|
|
|
|||
190
include/characters.h
Normal file
190
include/characters.h
Normal file
|
|
@ -0,0 +1,190 @@
|
|||
#ifndef GUARD_CHARACTERS_H
|
||||
#define GUARD_CHARACTERS_H
|
||||
|
||||
#define CHAR_SPACE 0x00
|
||||
#define CHAR_LV 0x34
|
||||
#define CHAR_SONG_WORD_SEPARATOR 0x37 // separates words in the bard song. Not sure if it's used for anything else
|
||||
#define CHAR_0 0xA1
|
||||
#define CHAR_EXCL_MARK 0xAB
|
||||
#define CHAR_QUESTION_MARK 0xAC
|
||||
#define CHAR_PERIOD 0xAD
|
||||
#define CHAR_HYPHEN 0xAE
|
||||
#define CHAR_ELLIPSIS 0xB0
|
||||
#define CHAR_DBL_QUOT_LEFT 0xB1
|
||||
#define CHAR_DBL_QUOT_RIGHT 0xB2
|
||||
#define CHAR_SGL_QUOT_LEFT 0xB3
|
||||
#define CHAR_SGL_QUOT_RIGHT 0xB4
|
||||
#define CHAR_MALE 0xB5
|
||||
#define CHAR_FEMALE 0xB6
|
||||
#define CHAR_CURRENCY 0xB7
|
||||
#define CHAR_COMMA 0xB8
|
||||
#define CHAR_MULT_SIGN 0xB9
|
||||
#define CHAR_SLASH 0xBA
|
||||
#define CHAR_A 0xBB
|
||||
#define CHAR_B 0xBC
|
||||
#define CHAR_C 0xBD
|
||||
#define CHAR_D 0xBE
|
||||
#define CHAR_E 0xBF
|
||||
#define CHAR_F 0xC0
|
||||
#define CHAR_G 0xC1
|
||||
#define CHAR_H 0xC2
|
||||
#define CHAR_I 0xC3
|
||||
#define CHAR_J 0xC4
|
||||
#define CHAR_K 0xC5
|
||||
#define CHAR_L 0xC6
|
||||
#define CHAR_M 0xC7
|
||||
#define CHAR_N 0xC8
|
||||
#define CHAR_O 0xC9
|
||||
#define CHAR_P 0xCA
|
||||
#define CHAR_Q 0xCB
|
||||
#define CHAR_R 0xCC
|
||||
#define CHAR_S 0xCD
|
||||
#define CHAR_T 0xCE
|
||||
#define CHAR_U 0xCF
|
||||
#define CHAR_V 0xD0
|
||||
#define CHAR_W 0xD1
|
||||
#define CHAR_X 0xD2
|
||||
#define CHAR_Y 0xD3
|
||||
#define CHAR_Z 0xD4
|
||||
#define CHAR_a 0xD5
|
||||
#define CHAR_b 0xD6
|
||||
#define CHAR_c 0xD7
|
||||
#define CHAR_d 0xD8
|
||||
#define CHAR_e 0xD9
|
||||
#define CHAR_f 0xDA
|
||||
#define CHAR_g 0xDB
|
||||
#define CHAR_h 0xDC
|
||||
#define CHAR_i 0xDD
|
||||
#define CHAR_j 0xDE
|
||||
#define CHAR_k 0xDF
|
||||
#define CHAR_l 0xE0
|
||||
#define CHAR_m 0xE1
|
||||
#define CHAR_n 0xE2
|
||||
#define CHAR_o 0xE3
|
||||
#define CHAR_p 0xE4
|
||||
#define CHAR_q 0xE5
|
||||
#define CHAR_r 0xE6
|
||||
#define CHAR_s 0xE7
|
||||
#define CHAR_t 0xE8
|
||||
#define CHAR_u 0xE9
|
||||
#define CHAR_v 0xEA
|
||||
#define CHAR_w 0xEB
|
||||
#define CHAR_x 0xEC
|
||||
#define CHAR_y 0xED
|
||||
#define CHAR_z 0xEE
|
||||
#define CHAR_COLON 0xF0
|
||||
#define CHAR_PROMPT_SCROLL 0xFA // waits for button press and scrolls dialog
|
||||
#define CHAR_PROMPT_CLEAR 0xFB // waits for button press and clears dialog
|
||||
#define EXT_CTRL_CODE_BEGIN 0xFC // extended control code
|
||||
#define PLACEHOLDER_BEGIN 0xFD // string placeholder
|
||||
#define CHAR_NEWLINE 0xFE
|
||||
#define EOS 0xFF // end of string
|
||||
|
||||
#define TEXT_COLOR_TRANSPARENT 0x00
|
||||
#define TEXT_COLOR_DARK_GREY 0x01
|
||||
#define TEXT_COLOR_RED 0x02
|
||||
#define TEXT_COLOR_GREEN 0x03
|
||||
#define TEXT_COLOR_BLUE 0x04
|
||||
#define TEXT_COLOR_YELLOW 0x05
|
||||
#define TEXT_COLOR_CYAN 0x06
|
||||
#define TEXT_COLOR_MAGENTA 0x07
|
||||
#define TEXT_COLOR_LIGHT_GREY 0x08
|
||||
#define TEXT_COLOR_BLACK 0x09
|
||||
#define TEXT_COLOR_BLACK2 0x0A
|
||||
#define TEXT_COLOR_SILVER 0x0B
|
||||
#define TEXT_COLOR_WHITE 0x0C
|
||||
#define TEXT_COLOR_SKY_BLUE 0x0D
|
||||
#define TEXT_COLOR_LIGHT_BLUE 0x0E
|
||||
#define TEXT_COLOR_WHITE2 0x0F
|
||||
|
||||
#define EXT_CTRL_CODE_COLOR 0x01
|
||||
#define EXT_CTRL_CODE_HIGHLIGHT 0x02
|
||||
#define EXT_CTRL_CODE_SHADOW 0x03
|
||||
#define EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW 0x04
|
||||
#define EXT_CTRL_CODE_PALETTE 0x05
|
||||
#define EXT_CTRL_CODE_SIZE 0x06
|
||||
#define EXT_CTRL_CODE_RESET_SIZE 0x07
|
||||
#define EXT_CTRL_CODE_PAUSE 0x08
|
||||
#define EXT_CTRL_CODE_PAUSE_UNTIL_PRESS 0x09
|
||||
#define EXT_CTRL_CODE_WAIT_SE 0x0A
|
||||
#define EXT_CTRL_CODE_PLAY_BGM 0x0B
|
||||
#define EXT_CTRL_CODE_ESCAPE 0x0C
|
||||
#define EXT_CTRL_CODE_SHIFT_TEXT 0x0D // nop
|
||||
#define EXT_CTRL_CODE_SHIFT_DOWN 0x0E
|
||||
#define EXT_CTRL_CODE_FILL_WINDOW 0x0F
|
||||
#define EXT_CTRL_CODE_PLAY_SE 0x10
|
||||
#define EXT_CTRL_CODE_CLEAR 0x11
|
||||
#define EXT_CTRL_CODE_SKIP 0x12
|
||||
#define EXT_CTRL_CODE_CLEAR_TO 0x13
|
||||
#define EXT_CTRL_CODE_MIN_LETTER_SPACING 0x14
|
||||
#define EXT_CTRL_CODE_JPN 0x15
|
||||
#define EXT_CTRL_CODE_ENG 0x16
|
||||
|
||||
// Note that while all dot combinations are represented in
|
||||
// the Braille font, they are not all meaningful characters.
|
||||
// Only those that have direct single-character translations are listed.
|
||||
#define BRAILLE_CHAR_SPACE 0x00
|
||||
#define BRAILLE_CHAR_A 0x01
|
||||
//
|
||||
#define BRAILLE_CHAR_C 0x03
|
||||
#define BRAILLE_CHAR_COMMA 0x04
|
||||
#define BRAILLE_CHAR_B 0x05
|
||||
#define BRAILLE_CHAR_I 0x06
|
||||
#define BRAILLE_CHAR_F 0x07
|
||||
//
|
||||
#define BRAILLE_CHAR_E 0x09
|
||||
//
|
||||
#define BRAILLE_CHAR_D 0x0B
|
||||
#define BRAILLE_CHAR_COLON 0x0C
|
||||
#define BRAILLE_CHAR_H 0x0D
|
||||
#define BRAILLE_CHAR_J 0x0E
|
||||
#define BRAILLE_CHAR_G 0x0F
|
||||
#define BRAILLE_CHAR_APOSTROPHE 0x10
|
||||
#define BRAILLE_CHAR_K 0x11
|
||||
#define BRAILLE_CHAR_SLASH 0x12
|
||||
#define BRAILLE_CHAR_M 0x13
|
||||
#define BRAILLE_CHAR_SEMICOLON 0x14
|
||||
#define BRAILLE_CHAR_L 0x15
|
||||
#define BRAILLE_CHAR_S 0x16
|
||||
#define BRAILLE_CHAR_P 0x17
|
||||
//
|
||||
#define BRAILLE_CHAR_O 0x19
|
||||
//
|
||||
#define BRAILLE_CHAR_N 0x1B
|
||||
#define BRAILLE_CHAR_EXCL_MARK 0x1C
|
||||
#define BRAILLE_CHAR_R 0x1D
|
||||
#define BRAILLE_CHAR_T 0x1E
|
||||
#define BRAILLE_CHAR_Q 0x1F
|
||||
//
|
||||
#define BRAILLE_CHAR_PERIOD 0x2C
|
||||
//
|
||||
#define BRAILLE_CHAR_W 0x2E
|
||||
//
|
||||
#define BRAILLE_CHAR_HYPHEN 0x30
|
||||
#define BRAILLE_CHAR_U 0x31
|
||||
//
|
||||
#define BRAILLE_CHAR_X 0x33
|
||||
#define BRAILLE_CHAR_QUESTION_MARK 0x34 // Also double quote left
|
||||
#define BRAILLE_CHAR_V 0x35
|
||||
//
|
||||
#define BRAILLE_CHAR_DBL_QUOTE_RIGHT 0x38
|
||||
#define BRAILLE_CHAR_Z 0x39
|
||||
#define BRAILLE_CHAR_NUMBER 0x3A
|
||||
#define BRAILLE_CHAR_Y 0x3B
|
||||
#define BRAILLE_CHAR_PAREN 0x3C
|
||||
//
|
||||
#define NUM_BRAILLE_CHARS 0x40
|
||||
|
||||
// Digits must be preceded by BRAILLE_CHAR_NUMBER
|
||||
#define BRAILLE_CHAR_1 BRAILLE_CHAR_A
|
||||
#define BRAILLE_CHAR_2 BRAILLE_CHAR_B
|
||||
#define BRAILLE_CHAR_3 BRAILLE_CHAR_C
|
||||
#define BRAILLE_CHAR_4 BRAILLE_CHAR_D
|
||||
#define BRAILLE_CHAR_5 BRAILLE_CHAR_E
|
||||
#define BRAILLE_CHAR_6 BRAILLE_CHAR_F
|
||||
#define BRAILLE_CHAR_7 BRAILLE_CHAR_G
|
||||
#define BRAILLE_CHAR_8 BRAILLE_CHAR_H
|
||||
#define BRAILLE_CHAR_9 BRAILLE_CHAR_I
|
||||
#define BRAILLE_CHAR_0 BRAILLE_CHAR_J
|
||||
|
||||
#endif // GUARD_CHARACTERS_H
|
||||
3
include/constants/.gitignore
vendored
Normal file
3
include/constants/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# Will be moved to build/ eventually
|
||||
map_groups.h
|
||||
layouts.h
|
||||
|
|
@ -1,341 +0,0 @@
|
|||
#ifndef GUARD_CONSTANTS_LAYOUTS_H
|
||||
#define GUARD_CONSTANTS_LAYOUTS_H
|
||||
|
||||
//
|
||||
// DO NOT MODIFY THIS FILE! It is auto-generated from data/layouts/layouts.json
|
||||
//
|
||||
|
||||
#define LAYOUT_PETALBURG_CITY 1
|
||||
#define LAYOUT_SLATEPORT_CITY 2
|
||||
#define LAYOUT_MAUVILLE_CITY 3
|
||||
#define LAYOUT_RUSTBORO_CITY 4
|
||||
#define LAYOUT_FORTREE_CITY 5
|
||||
#define LAYOUT_LILYCOVE_CITY 6
|
||||
#define LAYOUT_MOSSDEEP_CITY 7
|
||||
#define LAYOUT_SOOTOPOLIS_CITY 8
|
||||
#define LAYOUT_EVER_GRANDE_CITY 9
|
||||
#define LAYOUT_LITTLEROOT_TOWN 10
|
||||
#define LAYOUT_OLDALE_TOWN 11
|
||||
#define LAYOUT_DEWFORD_TOWN 12
|
||||
#define LAYOUT_LAVARIDGE_TOWN 13
|
||||
#define LAYOUT_FALLARBOR_TOWN 14
|
||||
#define LAYOUT_VERDANTURF_TOWN 15
|
||||
#define LAYOUT_PACIFIDLOG_TOWN 16
|
||||
#define LAYOUT_ROUTE101 17
|
||||
#define LAYOUT_ROUTE102 18
|
||||
#define LAYOUT_ROUTE103 19
|
||||
#define LAYOUT_ROUTE104 20
|
||||
#define LAYOUT_ROUTE105 21
|
||||
#define LAYOUT_ROUTE106 22
|
||||
#define LAYOUT_ROUTE107 23
|
||||
#define LAYOUT_ROUTE108 24
|
||||
#define LAYOUT_ROUTE109 25
|
||||
#define LAYOUT_ROUTE110 26
|
||||
#define LAYOUT_ROUTE111 27
|
||||
#define LAYOUT_ROUTE112 28
|
||||
#define LAYOUT_ROUTE113 29
|
||||
#define LAYOUT_ROUTE114 30
|
||||
#define LAYOUT_ROUTE115 31
|
||||
#define LAYOUT_ROUTE116 32
|
||||
#define LAYOUT_ROUTE117 33
|
||||
#define LAYOUT_ROUTE118 34
|
||||
#define LAYOUT_ROUTE119 35
|
||||
#define LAYOUT_ROUTE120 36
|
||||
#define LAYOUT_ROUTE121 37
|
||||
#define LAYOUT_ROUTE122 38
|
||||
#define LAYOUT_ROUTE123 39
|
||||
#define LAYOUT_ROUTE124 40
|
||||
#define LAYOUT_ROUTE125 41
|
||||
#define LAYOUT_ROUTE126 42
|
||||
#define LAYOUT_ROUTE127 43
|
||||
#define LAYOUT_ROUTE128 44
|
||||
#define LAYOUT_ROUTE129 45
|
||||
#define LAYOUT_UNREFERENCED_MAP 46
|
||||
#define LAYOUT_ROUTE131 47
|
||||
#define LAYOUT_ROUTE132 48
|
||||
#define LAYOUT_ROUTE133 49
|
||||
#define LAYOUT_ROUTE134 50
|
||||
#define LAYOUT_UNDERWATER2 51
|
||||
#define LAYOUT_UNDERWATER3 52
|
||||
#define LAYOUT_UNDERWATER4 53
|
||||
#define LAYOUT_LITTLEROOT_TOWN_BRENDANS_HOUSE_1F 54
|
||||
#define LAYOUT_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F 55
|
||||
#define LAYOUT_LITTLEROOT_TOWN_MAYS_HOUSE_1F 56
|
||||
#define LAYOUT_LITTLEROOT_TOWN_MAYS_HOUSE_2F 57
|
||||
#define LAYOUT_LITTLEROOT_TOWN_PROFESSOR_BIRCHS_LAB 58
|
||||
#define LAYOUT_HOUSE1 59
|
||||
#define LAYOUT_HOUSE2 60
|
||||
#define LAYOUT_POKEMON_CENTER_1F 61
|
||||
#define LAYOUT_POKEMON_CENTER_2F 62
|
||||
#define LAYOUT_POKE_MART 63
|
||||
#define LAYOUT_HOUSE3 64
|
||||
#define LAYOUT_DEWFORD_TOWN_GYM 65
|
||||
#define LAYOUT_DEWFORD_TOWN_HALL 66
|
||||
#define LAYOUT_HOUSE4 67
|
||||
#define LAYOUT_LAVARIDGE_TOWN_HERB_SHOP 68
|
||||
#define LAYOUT_LAVARIDGE_TOWN_GYM_1F 69
|
||||
#define LAYOUT_LAVARIDGE_TOWN_GYM_B1F 70
|
||||
#define LAYOUT_LAVARIDGE_TOWN_POKEMON_CENTER_1F 71
|
||||
#define LAYOUT_CONTEST_LOBBY 72
|
||||
#define LAYOUT_CONTEST_HALL 73
|
||||
#define LAYOUT_LILYCOVE_CITY_HOUSE2 74
|
||||
#define LAYOUT_UNKNOWN_MAP_082CF564 75
|
||||
#define LAYOUT_VERDANTURF_TOWN_WANDAS_HOUSE 76
|
||||
#define LAYOUT_PACIFIDLOG_TOWN_HOUSE1 77
|
||||
#define LAYOUT_PACIFIDLOG_TOWN_HOUSE2 78
|
||||
#define LAYOUT_PETALBURG_CITY_GYM 79
|
||||
#define LAYOUT_HOUSE_WITH_BED 80
|
||||
#define LAYOUT_SLATEPORT_CITY_STERNS_SHIPYARD_1F 81
|
||||
#define LAYOUT_SLATEPORT_CITY_STERNS_SHIPYARD_2F 82
|
||||
#define LAYOUT_UNKNOWN_MAP_082D05D8 83
|
||||
#define LAYOUT_UNKNOWN_MAP_082D05FC 84
|
||||
#define LAYOUT_SLATEPORT_CITY_POKEMON_FAN_CLUB 85
|
||||
#define LAYOUT_SLATEPORT_CITY_OCEANIC_MUSEUM_1F 86
|
||||
#define LAYOUT_SLATEPORT_CITY_OCEANIC_MUSEUM_2F 87
|
||||
#define LAYOUT_HARBOR 88
|
||||
#define LAYOUT_MAUVILLE_CITY_GYM 89
|
||||
#define LAYOUT_MAUVILLE_CITY_BIKE_SHOP 90
|
||||
#define LAYOUT_MAUVILLE_CITY_GAME_CORNER 91
|
||||
#define LAYOUT_RUSTBORO_CITY_DEVON_CORP_1F 92
|
||||
#define LAYOUT_RUSTBORO_CITY_DEVON_CORP_2F 93
|
||||
#define LAYOUT_RUSTBORO_CITY_GYM 94
|
||||
#define LAYOUT_RUSTBORO_CITY_POKEMON_SCHOOL 95
|
||||
#define LAYOUT_RUSTBORO_CITY_HOUSE 96
|
||||
#define LAYOUT_RUSTBORO_CITY_HOUSE1 97
|
||||
#define LAYOUT_RUSTBORO_CITY_CUTTERS_HOUSE 98
|
||||
#define LAYOUT_FORTREE_CITY_HOUSE1 99
|
||||
#define LAYOUT_FORTREE_CITY_GYM 100
|
||||
#define LAYOUT_FORTREE_CITY_HOUSE2 101
|
||||
#define LAYOUT_ROUTE104_MR_BRINEYS_HOUSE 102
|
||||
#define LAYOUT_LILYCOVE_CITY_LILYCOVE_MUSEUM_1F 103
|
||||
#define LAYOUT_LILYCOVE_CITY_LILYCOVE_MUSEUM_2F 104
|
||||
#define LAYOUT_LILYCOVE_CITY_CONTEST_LOBBY 105
|
||||
#define LAYOUT_LILYCOVE_CITY_CONTEST_HALL 106
|
||||
#define LAYOUT_LILYCOVE_CITY_POKEMON_TRAINER_FAN_CLUB 107
|
||||
#define LAYOUT_LILYCOVE_CITY_EMPTY_MAP 108
|
||||
#define LAYOUT_MOSSDEEP_CITY_GYM 109
|
||||
#define LAYOUT_SOOTOPOLIS_CITY_GYM_1F 110
|
||||
#define LAYOUT_SOOTOPOLIS_CITY_GYM_B1F 111
|
||||
#define LAYOUT_EVER_GRANDE_CITY_SIDNEYS_ROOM 112
|
||||
#define LAYOUT_EVER_GRANDE_CITY_PHOEBES_ROOM 113
|
||||
#define LAYOUT_EVER_GRANDE_CITY_GLACIAS_ROOM 114
|
||||
#define LAYOUT_EVER_GRANDE_CITY_DRAKES_ROOM 115
|
||||
#define LAYOUT_EVER_GRANDE_CITY_CHAMPIONS_ROOM 116
|
||||
#define LAYOUT_EVER_GRANDE_CITY_SHORT_CORRIDOR 117
|
||||
#define LAYOUT_ROUTE104_PRETTY_PETAL_FLOWER_SHOP 118
|
||||
#define LAYOUT_CABLE_CAR_STATION 119
|
||||
#define LAYOUT_ROUTE114_FOSSIL_MANIACS_HOUSE 120
|
||||
#define LAYOUT_ROUTE114_FOSSIL_MANIACS_TUNNEL 121
|
||||
#define LAYOUT_ROUTE114_LANETTES_HOUSE 122
|
||||
#define LAYOUT_ROUTE116_TUNNELERS_REST_HOUSE 123
|
||||
#define LAYOUT_ROUTE117_POKEMON_DAY_CARE 124
|
||||
#define LAYOUT_ROUTE121_SAFARI_ZONE_ENTRANCE 125
|
||||
#define LAYOUT_METEOR_FALLS_1F_1R 126
|
||||
#define LAYOUT_METEOR_FALLS_1F_2R 127
|
||||
#define LAYOUT_METEOR_FALLS_B1F_1R 128
|
||||
#define LAYOUT_METEOR_FALLS_B1F_2R 129
|
||||
#define LAYOUT_RUSTURF_TUNNEL 130
|
||||
#define LAYOUT_UNDERWATER_SOOTOPOLIS_CITY 131
|
||||
#define LAYOUT_DESERT_RUINS 132
|
||||
#define LAYOUT_GRANITE_CAVE_1F 133
|
||||
#define LAYOUT_GRANITE_CAVE_B1F 134
|
||||
#define LAYOUT_GRANITE_CAVE_B2F 135
|
||||
#define LAYOUT_PETALBURG_WOODS 136
|
||||
#define LAYOUT_MT_CHIMNEY 137
|
||||
#define LAYOUT_MT_PYRE_1F 138
|
||||
#define LAYOUT_MT_PYRE_2F 139
|
||||
#define LAYOUT_MT_PYRE_3F 140
|
||||
#define LAYOUT_MT_PYRE_4F 141
|
||||
#define LAYOUT_MT_PYRE_5F 142
|
||||
#define LAYOUT_MT_PYRE_6F 143
|
||||
#define LAYOUT_AQUA_HIDEOUT_1F 144
|
||||
#define LAYOUT_AQUA_HIDEOUT_B1F 145
|
||||
#define LAYOUT_AQUA_HIDEOUT_B2F 146
|
||||
#define LAYOUT_UNDERWATER_SEAFLOOR_CAVERN 147
|
||||
#define LAYOUT_SEAFLOOR_CAVERN_ENTRANCE 148
|
||||
#define LAYOUT_SEAFLOOR_CAVERN_ROOM1 149
|
||||
#define LAYOUT_SEAFLOOR_CAVERN_ROOM2 150
|
||||
#define LAYOUT_SEAFLOOR_CAVERN_ROOM3 151
|
||||
#define LAYOUT_SEAFLOOR_CAVERN_ROOM4 152
|
||||
#define LAYOUT_SEAFLOOR_CAVERN_ROOM5 153
|
||||
#define LAYOUT_SEAFLOOR_CAVERN_ROOM6 154
|
||||
#define LAYOUT_SEAFLOOR_CAVERN_ROOM7 155
|
||||
#define LAYOUT_SEAFLOOR_CAVERN_ROOM8 156
|
||||
#define LAYOUT_SEAFLOOR_CAVERN_ROOM9 157
|
||||
#define LAYOUT_CAVE_OF_ORIGIN_ENTRANCE 158
|
||||
#define LAYOUT_CAVE_OF_ORIGIN_1F 159
|
||||
#define LAYOUT_CAVE_OF_ORIGIN_B1F 160
|
||||
#define LAYOUT_CAVE_OF_ORIGIN_B2F 161
|
||||
#define LAYOUT_CAVE_OF_ORIGIN_B3F 162
|
||||
#define LAYOUT_CAVE_OF_ORIGIN_B4F 163
|
||||
#define LAYOUT_VICTORY_ROAD_1F 164
|
||||
#define LAYOUT_SHOAL_CAVE_LOW_TIDE_ENTRANCE_ROOM 165
|
||||
#define LAYOUT_SHOAL_CAVE_LOW_TIDE_INNER_ROOM 166
|
||||
#define LAYOUT_SHOAL_CAVE_LOW_TIDE_STAIRS_ROOM 167
|
||||
#define LAYOUT_SHOAL_CAVE_LOW_TIDE_LOWER_ROOM 168
|
||||
#define LAYOUT_SHOAL_CAVE_HIGH_TIDE_ENTRANCE_ROOM 169
|
||||
#define LAYOUT_SHOAL_CAVE_HIGH_TIDE_INNER_ROOM 170
|
||||
#define LAYOUT_UNKNOWN_MAP_082E55C8 171
|
||||
#define LAYOUT_UNKNOWN_MAP_082E55EC 172
|
||||
#define LAYOUT_UNKNOWN_MAP_082E5610 173
|
||||
#define LAYOUT_UNKNOWN_MAP_082E5634 174
|
||||
#define LAYOUT_UNKNOWN_MAP_082E5658 175
|
||||
#define LAYOUT_UNKNOWN_MAP_082E567C 176
|
||||
#define LAYOUT_UNKNOWN_MAP_082E56A0 177
|
||||
#define LAYOUT_UNKNOWN_MAP_082E56C4 178
|
||||
#define LAYOUT_UNKNOWN_MAP_082E56E8 179
|
||||
#define LAYOUT_UNKNOWN_MAP_082E570C 180
|
||||
#define LAYOUT_UNKNOWN_MAP_082E5730 181
|
||||
#define LAYOUT_UNKNOWN_MAP_082E5754 182
|
||||
#define LAYOUT_UNKNOWN_MAP_082E5778 183
|
||||
#define LAYOUT_UNKNOWN_MAP_082E579C 184
|
||||
#define LAYOUT_NEW_MAUVILLE_ENTRANCE 185
|
||||
#define LAYOUT_NEW_MAUVILLE_INSIDE 186
|
||||
#define LAYOUT_ABANDONED_SHIP_DECK 187
|
||||
#define LAYOUT_ABANDONED_SHIP_CORRIDORS_1F 188
|
||||
#define LAYOUT_ABANDONED_SHIP_ROOMS_1F 189
|
||||
#define LAYOUT_ABANDONED_SHIP_CORRIDORS_B1F 190
|
||||
#define LAYOUT_ABANDONED_SHIP_ROOMS_B1F 191
|
||||
#define LAYOUT_ABANDONED_SHIP_ROOMS2_B1F 192
|
||||
#define LAYOUT_ABANDONED_SHIP_UNDERWATER1 193
|
||||
#define LAYOUT_ABANDONED_SHIP_ROOM_B1F 194
|
||||
#define LAYOUT_ABANDONED_SHIP_ROOMS2_1F 195
|
||||
#define LAYOUT_ABANDONED_SHIP_CAPTAINS_OFFICE 196
|
||||
#define LAYOUT_ABANDONED_SHIP_UNDERWATER2 197
|
||||
#define LAYOUT_SECRET_BASE_RED_CAVE1 198
|
||||
#define LAYOUT_SECRET_BASE_BROWN_CAVE1 199
|
||||
#define LAYOUT_SECRET_BASE_BLUE_CAVE1 200
|
||||
#define LAYOUT_SECRET_BASE_YELLOW_CAVE1 201
|
||||
#define LAYOUT_SECRET_BASE_TREE1 202
|
||||
#define LAYOUT_SECRET_BASE_SHRUB1 203
|
||||
#define LAYOUT_SECRET_BASE_RED_CAVE2 204
|
||||
#define LAYOUT_SECRET_BASE_BROWN_CAVE2 205
|
||||
#define LAYOUT_SECRET_BASE_BLUE_CAVE2 206
|
||||
#define LAYOUT_SECRET_BASE_YELLOW_CAVE2 207
|
||||
#define LAYOUT_SECRET_BASE_TREE2 208
|
||||
#define LAYOUT_SECRET_BASE_SHRUB2 209
|
||||
#define LAYOUT_SECRET_BASE_RED_CAVE3 210
|
||||
#define LAYOUT_SECRET_BASE_BROWN_CAVE3 211
|
||||
#define LAYOUT_SECRET_BASE_BLUE_CAVE3 212
|
||||
#define LAYOUT_SECRET_BASE_YELLOW_CAVE3 213
|
||||
#define LAYOUT_SECRET_BASE_TREE3 214
|
||||
#define LAYOUT_SECRET_BASE_SHRUB3 215
|
||||
#define LAYOUT_SECRET_BASE_RED_CAVE4 216
|
||||
#define LAYOUT_SECRET_BASE_BROWN_CAVE4 217
|
||||
#define LAYOUT_SECRET_BASE_BLUE_CAVE4 218
|
||||
#define LAYOUT_SECRET_BASE_YELLOW_CAVE4 219
|
||||
#define LAYOUT_SECRET_BASE_TREE4 220
|
||||
#define LAYOUT_SECRET_BASE_SHRUB4 221
|
||||
#define LAYOUT_SINGLE_BATTLE_COLOSSEUM 222
|
||||
#define LAYOUT_TRADE_CENTER 223
|
||||
#define LAYOUT_RECORD_CORNER 224
|
||||
#define LAYOUT_DOUBLE_BATTLE_COLOSSEUM 225
|
||||
#define LAYOUT_LINK_CONTEST_ROOM1 226
|
||||
#define LAYOUT_UNKNOWN_MAP_25_29 227
|
||||
#define LAYOUT_UNKNOWN_MAP_25_30 228
|
||||
#define LAYOUT_UNKNOWN_MAP_25_31 229
|
||||
#define LAYOUT_UNKNOWN_MAP_25_32 230
|
||||
#define LAYOUT_UNKNOWN_MAP_25_33 231
|
||||
#define LAYOUT_UNKNOWN_MAP_25_34 232
|
||||
#define LAYOUT_LINK_CONTEST_ROOM2 233
|
||||
#define LAYOUT_LINK_CONTEST_ROOM3 234
|
||||
#define LAYOUT_LINK_CONTEST_ROOM4 235
|
||||
#define LAYOUT_LINK_CONTEST_ROOM5 236
|
||||
#define LAYOUT_LINK_CONTEST_ROOM6 237
|
||||
#define LAYOUT_INSIDE_OF_TRUCK 238
|
||||
#define LAYOUT_SAFARI_ZONE_NORTHWEST 239
|
||||
#define LAYOUT_SAFARI_ZONE_NORTHEAST 240
|
||||
#define LAYOUT_SAFARI_ZONE_SOUTHWEST 241
|
||||
#define LAYOUT_SAFARI_ZONE_SOUTHEAST 242
|
||||
#define LAYOUT_UNKNOWN_MAP_082EDF30 243
|
||||
#define LAYOUT_ROUTE109_SEASHORE_HOUSE 244
|
||||
#define LAYOUT_ROUTE110_TRICK_HOUSE_ENTRANCE 245
|
||||
#define LAYOUT_ROUTE110_TRICK_HOUSE_END 246
|
||||
#define LAYOUT_ROUTE110_TRICK_HOUSE_CORRIDOR 247
|
||||
#define LAYOUT_ROUTE110_TRICK_HOUSE_PUZZLE1 248
|
||||
#define LAYOUT_ROUTE110_TRICK_HOUSE_PUZZLE2 249
|
||||
#define LAYOUT_ROUTE110_TRICK_HOUSE_PUZZLE3 250
|
||||
#define LAYOUT_ROUTE110_TRICK_HOUSE_PUZZLE4 251
|
||||
#define LAYOUT_ROUTE110_TRICK_HOUSE_PUZZLE5 252
|
||||
#define LAYOUT_ROUTE110_TRICK_HOUSE_PUZZLE6 253
|
||||
#define LAYOUT_ROUTE110_TRICK_HOUSE_PUZZLE7 254
|
||||
#define LAYOUT_ROUTE110_TRICK_HOUSE_PUZZLE8 255
|
||||
#define LAYOUT_FORTREE_CITY_DECORATION_SHOP 256
|
||||
#define LAYOUT_ROUTE110_SEASIDE_CYCLING_ROAD_ENTRACE 257
|
||||
#define LAYOUT_LILYCOVE_CITY_DEPARTMENT_STORE_1F 258
|
||||
#define LAYOUT_LILYCOVE_CITY_DEPARTMENT_STORE_2F 259
|
||||
#define LAYOUT_LILYCOVE_CITY_DEPARTMENT_STORE_3F 260
|
||||
#define LAYOUT_LILYCOVE_CITY_DEPARTMENT_STORE_4F 261
|
||||
#define LAYOUT_LILYCOVE_CITY_DEPARTMENT_STORE_5F 262
|
||||
#define LAYOUT_LILYCOVE_CITY_DEPARTMENT_STORE_ROOFTOP 263
|
||||
#define LAYOUT_ROUTE130 264
|
||||
#define LAYOUT_BATTLE_TOWER_LOBBY 265
|
||||
#define LAYOUT_BATTLE_TOWER_OUTSIDE 266
|
||||
#define LAYOUT_BATTLE_TOWER_ELEVATOR 267
|
||||
#define LAYOUT_BATTLE_TOWER_CORRIDOR 268
|
||||
#define LAYOUT_BATTLE_TOWER_BATTLE_ROOM 269
|
||||
#define LAYOUT_RUSTBORO_CITY_DEVON_CORP_3F 270
|
||||
#define LAYOUT_EVER_GRANDE_CITY_POKEMON_LEAGUE 271
|
||||
#define LAYOUT_ROUTE119_WEATHER_INSTITUTE_1F 272
|
||||
#define LAYOUT_ROUTE119_WEATHER_INSTITUTE_2F 273
|
||||
#define LAYOUT_LILYCOVE_CITY_DEPARTMENT_STORE_ELEVATOR 274
|
||||
#define LAYOUT_UNDERWATER1 275
|
||||
#define LAYOUT_MOSSDEEP_CITY_SPACE_CENTER_1F 276
|
||||
#define LAYOUT_MOSSDEEP_CITY_SPACE_CENTER_2F 277
|
||||
#define LAYOUT_SS_TIDAL_CORRIDOR 278
|
||||
#define LAYOUT_SS_TIDAL_LOWER_DECK 279
|
||||
#define LAYOUT_SS_TIDAL_ROOMS 280
|
||||
#define LAYOUT_ISLAND_CAVE 281
|
||||
#define LAYOUT_ANCIENT_TOMB 282
|
||||
#define LAYOUT_UNDERWATER_ROUTE134 283
|
||||
#define LAYOUT_UNDERWATER_SEALED_CHAMBER 284
|
||||
#define LAYOUT_SEALED_CHAMBER_OUTER_ROOM 285
|
||||
#define LAYOUT_VICTORY_ROAD_B1F 286
|
||||
#define LAYOUT_VICTORY_ROAD_B2F 287
|
||||
#define LAYOUT_ROUTE104_PROTOTYPE 288
|
||||
#define LAYOUT_GRANITE_CAVE_STEVENS_ROOM 289
|
||||
#define LAYOUT_ABANDONED_SHIP_HIDDEN_FLOOR_CORRIDORS 290
|
||||
#define LAYOUT_SOUTHERN_ISLAND_EXTERIOR 291
|
||||
#define LAYOUT_SOUTHERN_ISLAND_INTERIOR 292
|
||||
#define LAYOUT_JAGGED_PASS 293
|
||||
#define LAYOUT_FIERY_PATH 294
|
||||
#define LAYOUT_RUSTBORO_CITY_FLAT2_1F 295
|
||||
#define LAYOUT_RUSTBORO_CITY_FLAT2_2F 296
|
||||
#define LAYOUT_RUSTBORO_CITY_FLAT2_3F 297
|
||||
#define LAYOUT_SOOTOPOLIS_CITY_HOUSE8 298
|
||||
#define LAYOUT_EVER_GRANDE_CITY_HALL_OF_FAME 299
|
||||
#define LAYOUT_LILYCOVE_CITY_COVE_LILY_MOTEL_1F 300
|
||||
#define LAYOUT_LILYCOVE_CITY_COVE_LILY_MOTEL_2F 301
|
||||
#define LAYOUT_ROUTE124_DIVING_TREASURE_HUNTERS_HOUSE 302
|
||||
#define LAYOUT_MT_PYRE_EXTERIOR 303
|
||||
#define LAYOUT_MT_PYRE_SUMMIT 304
|
||||
#define LAYOUT_SEALED_CHAMBER_INNER_ROOM 305
|
||||
#define LAYOUT_MOSSDEEP_CITY_GAME_CORNER_1F 306
|
||||
#define LAYOUT_MOSSDEEP_CITY_GAME_CORNER_B1F 307
|
||||
#define LAYOUT_SOOTOPOLIS_CITY_HOUSE1 308
|
||||
#define LAYOUT_SOOTOPOLIS_CITY_HOUSE2 309
|
||||
#define LAYOUT_SOOTOPOLIS_CITY_HOUSE3 310
|
||||
#define LAYOUT_ABANDONED_SHIP_HIDDEN_FLOOR_ROOMS 311
|
||||
#define LAYOUT_SCORCHED_SLAB 312
|
||||
#define LAYOUT_UNKNOWN_MAP_082FF894 313
|
||||
#define LAYOUT_RUSTBORO_CITY_FLAT1_1F 314
|
||||
#define LAYOUT_RUSTBORO_CITY_FLAT1_2F 315
|
||||
#define LAYOUT_EVER_GRANDE_CITY_CORRIDOR4 316
|
||||
#define LAYOUT_MAGMA_HIDEOUT_1F 317
|
||||
#define LAYOUT_MAGMA_HIDEOUT_B1F 318
|
||||
#define LAYOUT_MAGMA_HIDEOUT_B2F 319
|
||||
#define LAYOUT_UNKNOWN_MAP_08302970 320
|
||||
#define LAYOUT_SKY_PILLAR_ENTRANCE 321
|
||||
#define LAYOUT_SKY_PILLAR_OUTSIDE 322
|
||||
#define LAYOUT_SKY_PILLAR_1F 323
|
||||
#define LAYOUT_SKY_PILLAR_2F 324
|
||||
#define LAYOUT_SKY_PILLAR_3F 325
|
||||
#define LAYOUT_SKY_PILLAR_4F 326
|
||||
#define LAYOUT_UNKNOWN_MAP_083041B4 327
|
||||
#define LAYOUT_MOSSDEEP_CITY_STEVENS_HOUSE 328
|
||||
#define LAYOUT_SHOAL_CAVE_LOW_TIDE_ICE_ROOM 329
|
||||
#define LAYOUT_SAFARI_ZONE_REST_HOUSE 330
|
||||
#define LAYOUT_SKY_PILLAR_5F 331
|
||||
#define LAYOUT_SKY_PILLAR_TOP 332
|
||||
|
||||
#endif // GUARD_CONSTANTS_LAYOUTS_H
|
||||
|
|
@ -1,472 +0,0 @@
|
|||
#ifndef GUARD_CONSTANTS_MAP_GROUPS_H
|
||||
#define GUARD_CONSTANTS_MAP_GROUPS_H
|
||||
|
||||
//
|
||||
// DO NOT MODIFY THIS FILE! It is auto-generated from data/maps/map_groups.json
|
||||
//
|
||||
|
||||
// gMapGroup_TownsAndRoutes
|
||||
#define MAP_PETALBURG_CITY (0 | (0 << 8))
|
||||
#define MAP_SLATEPORT_CITY (1 | (0 << 8))
|
||||
#define MAP_MAUVILLE_CITY (2 | (0 << 8))
|
||||
#define MAP_RUSTBORO_CITY (3 | (0 << 8))
|
||||
#define MAP_FORTREE_CITY (4 | (0 << 8))
|
||||
#define MAP_LILYCOVE_CITY (5 | (0 << 8))
|
||||
#define MAP_MOSSDEEP_CITY (6 | (0 << 8))
|
||||
#define MAP_SOOTOPOLIS_CITY (7 | (0 << 8))
|
||||
#define MAP_EVER_GRANDE_CITY (8 | (0 << 8))
|
||||
#define MAP_LITTLEROOT_TOWN (9 | (0 << 8))
|
||||
#define MAP_OLDALE_TOWN (10 | (0 << 8))
|
||||
#define MAP_DEWFORD_TOWN (11 | (0 << 8))
|
||||
#define MAP_LAVARIDGE_TOWN (12 | (0 << 8))
|
||||
#define MAP_FALLARBOR_TOWN (13 | (0 << 8))
|
||||
#define MAP_VERDANTURF_TOWN (14 | (0 << 8))
|
||||
#define MAP_PACIFIDLOG_TOWN (15 | (0 << 8))
|
||||
#define MAP_ROUTE101 (16 | (0 << 8))
|
||||
#define MAP_ROUTE102 (17 | (0 << 8))
|
||||
#define MAP_ROUTE103 (18 | (0 << 8))
|
||||
#define MAP_ROUTE104 (19 | (0 << 8))
|
||||
#define MAP_ROUTE105 (20 | (0 << 8))
|
||||
#define MAP_ROUTE106 (21 | (0 << 8))
|
||||
#define MAP_ROUTE107 (22 | (0 << 8))
|
||||
#define MAP_ROUTE108 (23 | (0 << 8))
|
||||
#define MAP_ROUTE109 (24 | (0 << 8))
|
||||
#define MAP_ROUTE110 (25 | (0 << 8))
|
||||
#define MAP_ROUTE111 (26 | (0 << 8))
|
||||
#define MAP_ROUTE112 (27 | (0 << 8))
|
||||
#define MAP_ROUTE113 (28 | (0 << 8))
|
||||
#define MAP_ROUTE114 (29 | (0 << 8))
|
||||
#define MAP_ROUTE115 (30 | (0 << 8))
|
||||
#define MAP_ROUTE116 (31 | (0 << 8))
|
||||
#define MAP_ROUTE117 (32 | (0 << 8))
|
||||
#define MAP_ROUTE118 (33 | (0 << 8))
|
||||
#define MAP_ROUTE119 (34 | (0 << 8))
|
||||
#define MAP_ROUTE120 (35 | (0 << 8))
|
||||
#define MAP_ROUTE121 (36 | (0 << 8))
|
||||
#define MAP_ROUTE122 (37 | (0 << 8))
|
||||
#define MAP_ROUTE123 (38 | (0 << 8))
|
||||
#define MAP_ROUTE124 (39 | (0 << 8))
|
||||
#define MAP_ROUTE125 (40 | (0 << 8))
|
||||
#define MAP_ROUTE126 (41 | (0 << 8))
|
||||
#define MAP_ROUTE127 (42 | (0 << 8))
|
||||
#define MAP_ROUTE128 (43 | (0 << 8))
|
||||
#define MAP_ROUTE129 (44 | (0 << 8))
|
||||
#define MAP_ROUTE130 (45 | (0 << 8))
|
||||
#define MAP_ROUTE131 (46 | (0 << 8))
|
||||
#define MAP_ROUTE132 (47 | (0 << 8))
|
||||
#define MAP_ROUTE133 (48 | (0 << 8))
|
||||
#define MAP_ROUTE134 (49 | (0 << 8))
|
||||
#define MAP_UNDERWATER1 (50 | (0 << 8))
|
||||
#define MAP_UNDERWATER2 (51 | (0 << 8))
|
||||
#define MAP_UNDERWATER3 (52 | (0 << 8))
|
||||
#define MAP_UNDERWATER4 (53 | (0 << 8))
|
||||
|
||||
// gMapGroup_IndoorLittleroot
|
||||
#define MAP_LITTLEROOT_TOWN_BRENDANS_HOUSE_1F (0 | (1 << 8))
|
||||
#define MAP_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F (1 | (1 << 8))
|
||||
#define MAP_LITTLEROOT_TOWN_MAYS_HOUSE_1F (2 | (1 << 8))
|
||||
#define MAP_LITTLEROOT_TOWN_MAYS_HOUSE_2F (3 | (1 << 8))
|
||||
#define MAP_LITTLEROOT_TOWN_PROFESSOR_BIRCHS_LAB (4 | (1 << 8))
|
||||
|
||||
// gMapGroup_IndoorOldale
|
||||
#define MAP_OLDALE_TOWN_HOUSE1 (0 | (2 << 8))
|
||||
#define MAP_OLDALE_TOWN_HOUSE2 (1 | (2 << 8))
|
||||
#define MAP_OLDALE_TOWN_POKEMON_CENTER_1F (2 | (2 << 8))
|
||||
#define MAP_OLDALE_TOWN_POKEMON_CENTER_2F (3 | (2 << 8))
|
||||
#define MAP_OLDALE_TOWN_MART (4 | (2 << 8))
|
||||
|
||||
// gMapGroup_IndoorDewford
|
||||
#define MAP_DEWFORD_TOWN_HOUSE1 (0 | (3 << 8))
|
||||
#define MAP_DEWFORD_TOWN_POKEMON_CENTER_1F (1 | (3 << 8))
|
||||
#define MAP_DEWFORD_TOWN_POKEMON_CENTER_2F (2 | (3 << 8))
|
||||
#define MAP_DEWFORD_TOWN_GYM (3 | (3 << 8))
|
||||
#define MAP_DEWFORD_TOWN_HALL (4 | (3 << 8))
|
||||
#define MAP_DEWFORD_TOWN_HOUSE2 (5 | (3 << 8))
|
||||
|
||||
// gMapGroup_IndoorLavaridge
|
||||
#define MAP_LAVARIDGE_TOWN_HERB_SHOP (0 | (4 << 8))
|
||||
#define MAP_LAVARIDGE_TOWN_GYM_1F (1 | (4 << 8))
|
||||
#define MAP_LAVARIDGE_TOWN_GYM_B1F (2 | (4 << 8))
|
||||
#define MAP_LAVARIDGE_TOWN_HOUSE (3 | (4 << 8))
|
||||
#define MAP_LAVARIDGE_TOWN_MART (4 | (4 << 8))
|
||||
#define MAP_LAVARIDGE_TOWN_POKEMON_CENTER_1F (5 | (4 << 8))
|
||||
#define MAP_LAVARIDGE_TOWN_POKEMON_CENTER_2F (6 | (4 << 8))
|
||||
|
||||
// gMapGroup_IndoorFallarbor
|
||||
#define MAP_FALLARBOR_TOWN_MART (0 | (5 << 8))
|
||||
#define MAP_FALLARBOR_TOWN_CONTEST_LOBBY (1 | (5 << 8))
|
||||
#define MAP_FALLARBOR_TOWN_CONTEST_HALL (2 | (5 << 8))
|
||||
#define MAP_FALLARBOR_TOWN_POKEMON_CENTER_1F (3 | (5 << 8))
|
||||
#define MAP_FALLARBOR_TOWN_POKEMON_CENTER_2F (4 | (5 << 8))
|
||||
#define MAP_FALLARBOR_TOWN_HOUSE1 (5 | (5 << 8))
|
||||
#define MAP_FALLARBOR_TOWN_HOUSE2 (6 | (5 << 8))
|
||||
|
||||
// gMapGroup_IndoorVerdanturf
|
||||
#define MAP_VERDANTURF_TOWN_CONTEST_LOBBY (0 | (6 << 8))
|
||||
#define MAP_VERDANTURF_TOWN_CONTEST_HALL (1 | (6 << 8))
|
||||
#define MAP_VERDANTURF_TOWN_MART (2 | (6 << 8))
|
||||
#define MAP_VERDANTURF_TOWN_POKEMON_CENTER_1F (3 | (6 << 8))
|
||||
#define MAP_VERDANTURF_TOWN_POKEMON_CENTER_2F (4 | (6 << 8))
|
||||
#define MAP_VERDANTURF_TOWN_WANDAS_HOUSE (5 | (6 << 8))
|
||||
#define MAP_VERDANTURF_TOWN_FRIENDSHIP_RATERS_HOUSE (6 | (6 << 8))
|
||||
#define MAP_VERDANTURF_TOWN_HOUSE (7 | (6 << 8))
|
||||
|
||||
// gMapGroup_IndoorPacifidlog
|
||||
#define MAP_PACIFIDLOG_TOWN_POKEMON_CENTER_1F (0 | (7 << 8))
|
||||
#define MAP_PACIFIDLOG_TOWN_POKEMON_CENTER_2F (1 | (7 << 8))
|
||||
#define MAP_PACIFIDLOG_TOWN_HOUSE1 (2 | (7 << 8))
|
||||
#define MAP_PACIFIDLOG_TOWN_HOUSE2 (3 | (7 << 8))
|
||||
#define MAP_PACIFIDLOG_TOWN_HOUSE3 (4 | (7 << 8))
|
||||
#define MAP_PACIFIDLOG_TOWN_HOUSE4 (5 | (7 << 8))
|
||||
#define MAP_PACIFIDLOG_TOWN_HOUSE5 (6 | (7 << 8))
|
||||
|
||||
// gMapGroup_IndoorPetalburg
|
||||
#define MAP_PETALBURG_CITY_WALLYS_HOUSE (0 | (8 << 8))
|
||||
#define MAP_PETALBURG_CITY_GYM (1 | (8 << 8))
|
||||
#define MAP_PETALBURG_CITY_HOUSE1 (2 | (8 << 8))
|
||||
#define MAP_PETALBURG_CITY_HOUSE2 (3 | (8 << 8))
|
||||
#define MAP_PETALBURG_CITY_POKEMON_CENTER_1F (4 | (8 << 8))
|
||||
#define MAP_PETALBURG_CITY_POKEMON_CENTER_2F (5 | (8 << 8))
|
||||
#define MAP_PETALBURG_CITY_MART (6 | (8 << 8))
|
||||
|
||||
// gMapGroup_IndoorSlateport
|
||||
#define MAP_SLATEPORT_CITY_STERNS_SHIPYARD_1F (0 | (9 << 8))
|
||||
#define MAP_SLATEPORT_CITY_STERNS_SHIPYARD_2F (1 | (9 << 8))
|
||||
#define MAP_SLATEPORT_CITY_CONTEST_LOBBY (2 | (9 << 8))
|
||||
#define MAP_SLATEPORT_CITY_CONTEST_HALL (3 | (9 << 8))
|
||||
#define MAP_SLATEPORT_CITY_HOUSE1 (4 | (9 << 8))
|
||||
#define MAP_SLATEPORT_CITY_POKEMON_FAN_CLUB (5 | (9 << 8))
|
||||
#define MAP_SLATEPORT_CITY_OCEANIC_MUSEUM_1F (6 | (9 << 8))
|
||||
#define MAP_SLATEPORT_CITY_OCEANIC_MUSEUM_2F (7 | (9 << 8))
|
||||
#define MAP_SLATEPORT_CITY_HARBOR (8 | (9 << 8))
|
||||
#define MAP_SLATEPORT_CITY_HOUSE2 (9 | (9 << 8))
|
||||
#define MAP_SLATEPORT_CITY_POKEMON_CENTER_1F (10 | (9 << 8))
|
||||
#define MAP_SLATEPORT_CITY_POKEMON_CENTER_2F (11 | (9 << 8))
|
||||
#define MAP_SLATEPORT_CITY_MART (12 | (9 << 8))
|
||||
|
||||
// gMapGroup_IndoorMauville
|
||||
#define MAP_MAUVILLE_CITY_GYM (0 | (10 << 8))
|
||||
#define MAP_MAUVILLE_CITY_BIKE_SHOP (1 | (10 << 8))
|
||||
#define MAP_MAUVILLE_CITY_HOUSE1 (2 | (10 << 8))
|
||||
#define MAP_MAUVILLE_CITY_GAME_CORNER (3 | (10 << 8))
|
||||
#define MAP_MAUVILLE_CITY_HOUSE2 (4 | (10 << 8))
|
||||
#define MAP_MAUVILLE_CITY_POKEMON_CENTER_1F (5 | (10 << 8))
|
||||
#define MAP_MAUVILLE_CITY_POKEMON_CENTER_2F (6 | (10 << 8))
|
||||
#define MAP_MAUVILLE_CITY_MART (7 | (10 << 8))
|
||||
|
||||
// gMapGroup_IndoorRustboro
|
||||
#define MAP_RUSTBORO_CITY_DEVON_CORP_1F (0 | (11 << 8))
|
||||
#define MAP_RUSTBORO_CITY_DEVON_CORP_2F (1 | (11 << 8))
|
||||
#define MAP_RUSTBORO_CITY_DEVON_CORP_3F (2 | (11 << 8))
|
||||
#define MAP_RUSTBORO_CITY_GYM (3 | (11 << 8))
|
||||
#define MAP_RUSTBORO_CITY_POKEMON_SCHOOL (4 | (11 << 8))
|
||||
#define MAP_RUSTBORO_CITY_POKEMON_CENTER_1F (5 | (11 << 8))
|
||||
#define MAP_RUSTBORO_CITY_POKEMON_CENTER_2F (6 | (11 << 8))
|
||||
#define MAP_RUSTBORO_CITY_MART (7 | (11 << 8))
|
||||
#define MAP_RUSTBORO_CITY_FLAT1_1F (8 | (11 << 8))
|
||||
#define MAP_RUSTBORO_CITY_FLAT1_2F (9 | (11 << 8))
|
||||
#define MAP_RUSTBORO_CITY_HOUSE1 (10 | (11 << 8))
|
||||
#define MAP_RUSTBORO_CITY_CUTTERS_HOUSE (11 | (11 << 8))
|
||||
#define MAP_RUSTBORO_CITY_HOUSE2 (12 | (11 << 8))
|
||||
#define MAP_RUSTBORO_CITY_FLAT2_1F (13 | (11 << 8))
|
||||
#define MAP_RUSTBORO_CITY_FLAT2_2F (14 | (11 << 8))
|
||||
#define MAP_RUSTBORO_CITY_FLAT2_3F (15 | (11 << 8))
|
||||
#define MAP_RUSTBORO_CITY_HOUSE3 (16 | (11 << 8))
|
||||
|
||||
// gMapGroup_IndoorFortree
|
||||
#define MAP_FORTREE_CITY_HOUSE1 (0 | (12 << 8))
|
||||
#define MAP_FORTREE_CITY_GYM (1 | (12 << 8))
|
||||
#define MAP_FORTREE_CITY_POKEMON_CENTER_1F (2 | (12 << 8))
|
||||
#define MAP_FORTREE_CITY_POKEMON_CENTER_2F (3 | (12 << 8))
|
||||
#define MAP_FORTREE_CITY_MART (4 | (12 << 8))
|
||||
#define MAP_FORTREE_CITY_HOUSE2 (5 | (12 << 8))
|
||||
#define MAP_FORTREE_CITY_HOUSE3 (6 | (12 << 8))
|
||||
#define MAP_FORTREE_CITY_HOUSE4 (7 | (12 << 8))
|
||||
#define MAP_FORTREE_CITY_HOUSE5 (8 | (12 << 8))
|
||||
#define MAP_FORTREE_CITY_DECORATION_SHOP (9 | (12 << 8))
|
||||
|
||||
// gMapGroup_IndoorLilycove
|
||||
#define MAP_LILYCOVE_CITY_COVE_LILY_MOTEL_1F (0 | (13 << 8))
|
||||
#define MAP_LILYCOVE_CITY_COVE_LILY_MOTEL_2F (1 | (13 << 8))
|
||||
#define MAP_LILYCOVE_CITY_LILYCOVE_MUSEUM_1F (2 | (13 << 8))
|
||||
#define MAP_LILYCOVE_CITY_LILYCOVE_MUSEUM_2F (3 | (13 << 8))
|
||||
#define MAP_LILYCOVE_CITY_CONTEST_LOBBY (4 | (13 << 8))
|
||||
#define MAP_LILYCOVE_CITY_CONTEST_HALL (5 | (13 << 8))
|
||||
#define MAP_LILYCOVE_CITY_POKEMON_CENTER_1F (6 | (13 << 8))
|
||||
#define MAP_LILYCOVE_CITY_POKEMON_CENTER_2F (7 | (13 << 8))
|
||||
#define MAP_LILYCOVE_CITY_UNUSED_MART (8 | (13 << 8))
|
||||
#define MAP_LILYCOVE_CITY_POKEMON_TRAINER_FAN_CLUB (9 | (13 << 8))
|
||||
#define MAP_LILYCOVE_CITY_HARBOR (10 | (13 << 8))
|
||||
#define MAP_LILYCOVE_CITY_EMPTY_MAP (11 | (13 << 8))
|
||||
#define MAP_LILYCOVE_CITY_MOVE_DELETERS_HOUSE (12 | (13 << 8))
|
||||
#define MAP_LILYCOVE_CITY_HOUSE1 (13 | (13 << 8))
|
||||
#define MAP_LILYCOVE_CITY_HOUSE2 (14 | (13 << 8))
|
||||
#define MAP_LILYCOVE_CITY_HOUSE3 (15 | (13 << 8))
|
||||
#define MAP_LILYCOVE_CITY_HOUSE4 (16 | (13 << 8))
|
||||
#define MAP_LILYCOVE_CITY_DEPARTMENT_STORE_1F (17 | (13 << 8))
|
||||
#define MAP_LILYCOVE_CITY_DEPARTMENT_STORE_2F (18 | (13 << 8))
|
||||
#define MAP_LILYCOVE_CITY_DEPARTMENT_STORE_3F (19 | (13 << 8))
|
||||
#define MAP_LILYCOVE_CITY_DEPARTMENT_STORE_4F (20 | (13 << 8))
|
||||
#define MAP_LILYCOVE_CITY_DEPARTMENT_STORE_5F (21 | (13 << 8))
|
||||
#define MAP_LILYCOVE_CITY_DEPARTMENT_STORE_ROOFTOP (22 | (13 << 8))
|
||||
#define MAP_LILYCOVE_CITY_DEPARTMENT_STORE_ELEVATOR (23 | (13 << 8))
|
||||
|
||||
// gMapGroup_IndoorMossdeep
|
||||
#define MAP_MOSSDEEP_CITY_GYM (0 | (14 << 8))
|
||||
#define MAP_MOSSDEEP_CITY_HOUSE1 (1 | (14 << 8))
|
||||
#define MAP_MOSSDEEP_CITY_HOUSE2 (2 | (14 << 8))
|
||||
#define MAP_MOSSDEEP_CITY_POKEMON_CENTER_1F (3 | (14 << 8))
|
||||
#define MAP_MOSSDEEP_CITY_POKEMON_CENTER_2F (4 | (14 << 8))
|
||||
#define MAP_MOSSDEEP_CITY_MART (5 | (14 << 8))
|
||||
#define MAP_MOSSDEEP_CITY_HOUSE3 (6 | (14 << 8))
|
||||
#define MAP_MOSSDEEP_CITY_STEVENS_HOUSE (7 | (14 << 8))
|
||||
#define MAP_MOSSDEEP_CITY_HOUSE4 (8 | (14 << 8))
|
||||
#define MAP_MOSSDEEP_CITY_SPACE_CENTER_1F (9 | (14 << 8))
|
||||
#define MAP_MOSSDEEP_CITY_SPACE_CENTER_2F (10 | (14 << 8))
|
||||
#define MAP_MOSSDEEP_CITY_GAME_CORNER_1F (11 | (14 << 8))
|
||||
#define MAP_MOSSDEEP_CITY_GAME_CORNER_B1F (12 | (14 << 8))
|
||||
|
||||
// gMapGroup_IndoorSootopolis
|
||||
#define MAP_SOOTOPOLIS_CITY_GYM_1F (0 | (15 << 8))
|
||||
#define MAP_SOOTOPOLIS_CITY_GYM_B1F (1 | (15 << 8))
|
||||
#define MAP_SOOTOPOLIS_CITY_POKEMON_CENTER_1F (2 | (15 << 8))
|
||||
#define MAP_SOOTOPOLIS_CITY_POKEMON_CENTER_2F (3 | (15 << 8))
|
||||
#define MAP_SOOTOPOLIS_CITY_MART (4 | (15 << 8))
|
||||
#define MAP_SOOTOPOLIS_CITY_HOUSE1 (5 | (15 << 8))
|
||||
#define MAP_SOOTOPOLIS_CITY_HOUSE2 (6 | (15 << 8))
|
||||
#define MAP_SOOTOPOLIS_CITY_HOUSE3 (7 | (15 << 8))
|
||||
#define MAP_SOOTOPOLIS_CITY_HOUSE4 (8 | (15 << 8))
|
||||
#define MAP_SOOTOPOLIS_CITY_HOUSE5 (9 | (15 << 8))
|
||||
#define MAP_SOOTOPOLIS_CITY_HOUSE6 (10 | (15 << 8))
|
||||
#define MAP_SOOTOPOLIS_CITY_HOUSE7 (11 | (15 << 8))
|
||||
#define MAP_SOOTOPOLIS_CITY_HOUSE8 (12 | (15 << 8))
|
||||
|
||||
// gMapGroup_IndoorEverGrande
|
||||
#define MAP_EVER_GRANDE_CITY_SIDNEYS_ROOM (0 | (16 << 8))
|
||||
#define MAP_EVER_GRANDE_CITY_PHOEBES_ROOM (1 | (16 << 8))
|
||||
#define MAP_EVER_GRANDE_CITY_GLACIAS_ROOM (2 | (16 << 8))
|
||||
#define MAP_EVER_GRANDE_CITY_DRAKES_ROOM (3 | (16 << 8))
|
||||
#define MAP_EVER_GRANDE_CITY_CHAMPIONS_ROOM (4 | (16 << 8))
|
||||
#define MAP_EVER_GRANDE_CITY_CORRIDOR1 (5 | (16 << 8))
|
||||
#define MAP_EVER_GRANDE_CITY_CORRIDOR2 (6 | (16 << 8))
|
||||
#define MAP_EVER_GRANDE_CITY_CORRIDOR3 (7 | (16 << 8))
|
||||
#define MAP_EVER_GRANDE_CITY_CORRIDOR4 (8 | (16 << 8))
|
||||
#define MAP_EVER_GRANDE_CITY_CORRIDOR5 (9 | (16 << 8))
|
||||
#define MAP_EVER_GRANDE_CITY_POKEMON_LEAGUE (10 | (16 << 8))
|
||||
#define MAP_EVER_GRANDE_CITY_HALL_OF_FAME (11 | (16 << 8))
|
||||
#define MAP_EVER_GRANDE_CITY_POKEMON_CENTER_1F (12 | (16 << 8))
|
||||
#define MAP_EVER_GRANDE_CITY_POKEMON_CENTER_2F (13 | (16 << 8))
|
||||
|
||||
// gMapGroup_IndoorRoute104
|
||||
#define MAP_ROUTE104_MR_BRINEYS_HOUSE (0 | (17 << 8))
|
||||
#define MAP_ROUTE104_PRETTY_PETAL_FLOWER_SHOP (1 | (17 << 8))
|
||||
|
||||
// gMapGroup_IndoorRoute111
|
||||
#define MAP_ROUTE111_WINSTRATE_FAMILYS_HOUSE (0 | (18 << 8))
|
||||
#define MAP_ROUTE111_OLD_LADYS_REST_STOP (1 | (18 << 8))
|
||||
|
||||
// gMapGroup_IndoorRoute112
|
||||
#define MAP_ROUTE112_CABLE_CAR_STATION (0 | (19 << 8))
|
||||
#define MAP_MT_CHIMNEY_CABLE_CAR_STATION (1 | (19 << 8))
|
||||
|
||||
// gMapGroup_IndoorRoute114
|
||||
#define MAP_ROUTE114_FOSSIL_MANIACS_HOUSE (0 | (20 << 8))
|
||||
#define MAP_ROUTE114_FOSSIL_MANIACS_TUNNEL (1 | (20 << 8))
|
||||
#define MAP_ROUTE114_LANETTES_HOUSE (2 | (20 << 8))
|
||||
|
||||
// gMapGroup_IndoorRoute116
|
||||
#define MAP_ROUTE116_TUNNELERS_REST_HOUSE (0 | (21 << 8))
|
||||
|
||||
// gMapGroup_IndoorRoute117
|
||||
#define MAP_ROUTE117_POKEMON_DAY_CARE (0 | (22 << 8))
|
||||
|
||||
// gMapGroup_IndoorRoute121
|
||||
#define MAP_ROUTE121_SAFARI_ZONE_ENTRANCE (0 | (23 << 8))
|
||||
|
||||
// gMapGroup_Dungeons
|
||||
#define MAP_METEOR_FALLS_1F_1R (0 | (24 << 8))
|
||||
#define MAP_METEOR_FALLS_1F_2R (1 | (24 << 8))
|
||||
#define MAP_METEOR_FALLS_B1F_1R (2 | (24 << 8))
|
||||
#define MAP_METEOR_FALLS_B1F_2R (3 | (24 << 8))
|
||||
#define MAP_RUSTURF_TUNNEL (4 | (24 << 8))
|
||||
#define MAP_UNDERWATER_SOOTOPOLIS_CITY (5 | (24 << 8))
|
||||
#define MAP_DESERT_RUINS (6 | (24 << 8))
|
||||
#define MAP_GRANITE_CAVE_1F (7 | (24 << 8))
|
||||
#define MAP_GRANITE_CAVE_B1F (8 | (24 << 8))
|
||||
#define MAP_GRANITE_CAVE_B2F (9 | (24 << 8))
|
||||
#define MAP_GRANITE_CAVE_STEVENS_ROOM (10 | (24 << 8))
|
||||
#define MAP_PETALBURG_WOODS (11 | (24 << 8))
|
||||
#define MAP_MT_CHIMNEY (12 | (24 << 8))
|
||||
#define MAP_JAGGED_PASS (13 | (24 << 8))
|
||||
#define MAP_FIERY_PATH (14 | (24 << 8))
|
||||
#define MAP_MT_PYRE_1F (15 | (24 << 8))
|
||||
#define MAP_MT_PYRE_2F (16 | (24 << 8))
|
||||
#define MAP_MT_PYRE_3F (17 | (24 << 8))
|
||||
#define MAP_MT_PYRE_4F (18 | (24 << 8))
|
||||
#define MAP_MT_PYRE_5F (19 | (24 << 8))
|
||||
#define MAP_MT_PYRE_6F (20 | (24 << 8))
|
||||
#define MAP_MT_PYRE_EXTERIOR (21 | (24 << 8))
|
||||
#define MAP_MT_PYRE_SUMMIT (22 | (24 << 8))
|
||||
#define MAP_AQUA_HIDEOUT_1F (23 | (24 << 8))
|
||||
#define MAP_AQUA_HIDEOUT_B1F (24 | (24 << 8))
|
||||
#define MAP_AQUA_HIDEOUT_B2F (25 | (24 << 8))
|
||||
#define MAP_UNDERWATER_SEAFLOOR_CAVERN (26 | (24 << 8))
|
||||
#define MAP_SEAFLOOR_CAVERN_ENTRANCE (27 | (24 << 8))
|
||||
#define MAP_SEAFLOOR_CAVERN_ROOM1 (28 | (24 << 8))
|
||||
#define MAP_SEAFLOOR_CAVERN_ROOM2 (29 | (24 << 8))
|
||||
#define MAP_SEAFLOOR_CAVERN_ROOM3 (30 | (24 << 8))
|
||||
#define MAP_SEAFLOOR_CAVERN_ROOM4 (31 | (24 << 8))
|
||||
#define MAP_SEAFLOOR_CAVERN_ROOM5 (32 | (24 << 8))
|
||||
#define MAP_SEAFLOOR_CAVERN_ROOM6 (33 | (24 << 8))
|
||||
#define MAP_SEAFLOOR_CAVERN_ROOM7 (34 | (24 << 8))
|
||||
#define MAP_SEAFLOOR_CAVERN_ROOM8 (35 | (24 << 8))
|
||||
#define MAP_SEAFLOOR_CAVERN_ROOM9 (36 | (24 << 8))
|
||||
#define MAP_CAVE_OF_ORIGIN_ENTRANCE (37 | (24 << 8))
|
||||
#define MAP_CAVE_OF_ORIGIN_1F (38 | (24 << 8))
|
||||
#define MAP_CAVE_OF_ORIGIN_B1F (39 | (24 << 8))
|
||||
#define MAP_CAVE_OF_ORIGIN_B2F (40 | (24 << 8))
|
||||
#define MAP_CAVE_OF_ORIGIN_B3F (41 | (24 << 8))
|
||||
#define MAP_CAVE_OF_ORIGIN_B4F (42 | (24 << 8))
|
||||
#define MAP_VICTORY_ROAD_1F (43 | (24 << 8))
|
||||
#define MAP_VICTORY_ROAD_B1F (44 | (24 << 8))
|
||||
#define MAP_VICTORY_ROAD_B2F (45 | (24 << 8))
|
||||
#define MAP_SHOAL_CAVE_LOW_TIDE_ENTRANCE_ROOM (46 | (24 << 8))
|
||||
#define MAP_SHOAL_CAVE_LOW_TIDE_INNER_ROOM (47 | (24 << 8))
|
||||
#define MAP_SHOAL_CAVE_LOW_TIDE_STAIRS_ROOM (48 | (24 << 8))
|
||||
#define MAP_SHOAL_CAVE_LOW_TIDE_LOWER_ROOM (49 | (24 << 8))
|
||||
#define MAP_SHOAL_CAVE_HIGH_TIDE_ENTRANCE_ROOM (50 | (24 << 8))
|
||||
#define MAP_SHOAL_CAVE_HIGH_TIDE_INNER_ROOM (51 | (24 << 8))
|
||||
#define MAP_NEW_MAUVILLE_ENTRANCE (52 | (24 << 8))
|
||||
#define MAP_NEW_MAUVILLE_INSIDE (53 | (24 << 8))
|
||||
#define MAP_ABANDONED_SHIP_DECK (54 | (24 << 8))
|
||||
#define MAP_ABANDONED_SHIP_CORRIDORS_1F (55 | (24 << 8))
|
||||
#define MAP_ABANDONED_SHIP_ROOMS_1F (56 | (24 << 8))
|
||||
#define MAP_ABANDONED_SHIP_CORRIDORS_B1F (57 | (24 << 8))
|
||||
#define MAP_ABANDONED_SHIP_ROOMS_B1F (58 | (24 << 8))
|
||||
#define MAP_ABANDONED_SHIP_ROOMS2_B1F (59 | (24 << 8))
|
||||
#define MAP_ABANDONED_SHIP_UNDERWATER1 (60 | (24 << 8))
|
||||
#define MAP_ABANDONED_SHIP_ROOM_B1F (61 | (24 << 8))
|
||||
#define MAP_ABANDONED_SHIP_ROOMS2_1F (62 | (24 << 8))
|
||||
#define MAP_ABANDONED_SHIP_CAPTAINS_OFFICE (63 | (24 << 8))
|
||||
#define MAP_ABANDONED_SHIP_UNDERWATER2 (64 | (24 << 8))
|
||||
#define MAP_ABANDONED_SHIP_HIDDEN_FLOOR_CORRIDORS (65 | (24 << 8))
|
||||
#define MAP_ABANDONED_SHIP_HIDDEN_FLOOR_ROOMS (66 | (24 << 8))
|
||||
#define MAP_ISLAND_CAVE (67 | (24 << 8))
|
||||
#define MAP_ANCIENT_TOMB (68 | (24 << 8))
|
||||
#define MAP_UNDERWATER_ROUTE134 (69 | (24 << 8))
|
||||
#define MAP_UNDERWATER_SEALED_CHAMBER (70 | (24 << 8))
|
||||
#define MAP_SEALED_CHAMBER_OUTER_ROOM (71 | (24 << 8))
|
||||
#define MAP_SEALED_CHAMBER_INNER_ROOM (72 | (24 << 8))
|
||||
#define MAP_SCORCHED_SLAB (73 | (24 << 8))
|
||||
#define MAP_MAGMA_HIDEOUT_1F (74 | (24 << 8))
|
||||
#define MAP_MAGMA_HIDEOUT_B1F (75 | (24 << 8))
|
||||
#define MAP_MAGMA_HIDEOUT_B2F (76 | (24 << 8))
|
||||
#define MAP_SKY_PILLAR_ENTRANCE (77 | (24 << 8))
|
||||
#define MAP_SKY_PILLAR_OUTSIDE (78 | (24 << 8))
|
||||
#define MAP_SKY_PILLAR_1F (79 | (24 << 8))
|
||||
#define MAP_SKY_PILLAR_2F (80 | (24 << 8))
|
||||
#define MAP_SKY_PILLAR_3F (81 | (24 << 8))
|
||||
#define MAP_SKY_PILLAR_4F (82 | (24 << 8))
|
||||
#define MAP_SHOAL_CAVE_LOW_TIDE_ICE_ROOM (83 | (24 << 8))
|
||||
#define MAP_SKY_PILLAR_5F (84 | (24 << 8))
|
||||
#define MAP_SKY_PILLAR_TOP (85 | (24 << 8))
|
||||
|
||||
// gMapGroup_IndoorDynamic
|
||||
#define MAP_SECRET_BASE_RED_CAVE1 (0 | (25 << 8))
|
||||
#define MAP_SECRET_BASE_BROWN_CAVE1 (1 | (25 << 8))
|
||||
#define MAP_SECRET_BASE_BLUE_CAVE1 (2 | (25 << 8))
|
||||
#define MAP_SECRET_BASE_YELLOW_CAVE1 (3 | (25 << 8))
|
||||
#define MAP_SECRET_BASE_TREE1 (4 | (25 << 8))
|
||||
#define MAP_SECRET_BASE_SHRUB1 (5 | (25 << 8))
|
||||
#define MAP_SECRET_BASE_RED_CAVE2 (6 | (25 << 8))
|
||||
#define MAP_SECRET_BASE_BROWN_CAVE2 (7 | (25 << 8))
|
||||
#define MAP_SECRET_BASE_BLUE_CAVE2 (8 | (25 << 8))
|
||||
#define MAP_SECRET_BASE_YELLOW_CAVE2 (9 | (25 << 8))
|
||||
#define MAP_SECRET_BASE_TREE2 (10 | (25 << 8))
|
||||
#define MAP_SECRET_BASE_SHRUB2 (11 | (25 << 8))
|
||||
#define MAP_SECRET_BASE_RED_CAVE3 (12 | (25 << 8))
|
||||
#define MAP_SECRET_BASE_BROWN_CAVE3 (13 | (25 << 8))
|
||||
#define MAP_SECRET_BASE_BLUE_CAVE3 (14 | (25 << 8))
|
||||
#define MAP_SECRET_BASE_YELLOW_CAVE3 (15 | (25 << 8))
|
||||
#define MAP_SECRET_BASE_TREE3 (16 | (25 << 8))
|
||||
#define MAP_SECRET_BASE_SHRUB3 (17 | (25 << 8))
|
||||
#define MAP_SECRET_BASE_RED_CAVE4 (18 | (25 << 8))
|
||||
#define MAP_SECRET_BASE_BROWN_CAVE4 (19 | (25 << 8))
|
||||
#define MAP_SECRET_BASE_BLUE_CAVE4 (20 | (25 << 8))
|
||||
#define MAP_SECRET_BASE_YELLOW_CAVE4 (21 | (25 << 8))
|
||||
#define MAP_SECRET_BASE_TREE4 (22 | (25 << 8))
|
||||
#define MAP_SECRET_BASE_SHRUB4 (23 | (25 << 8))
|
||||
#define MAP_SINGLE_BATTLE_COLOSSEUM (24 | (25 << 8))
|
||||
#define MAP_TRADE_CENTER (25 | (25 << 8))
|
||||
#define MAP_RECORD_CORNER (26 | (25 << 8))
|
||||
#define MAP_DOUBLE_BATTLE_COLOSSEUM (27 | (25 << 8))
|
||||
#define MAP_LINK_CONTEST_ROOM1 (28 | (25 << 8))
|
||||
#define MAP_UNKNOWN_MAP_25_29 (29 | (25 << 8))
|
||||
#define MAP_UNKNOWN_MAP_25_30 (30 | (25 << 8))
|
||||
#define MAP_UNKNOWN_MAP_25_31 (31 | (25 << 8))
|
||||
#define MAP_UNKNOWN_MAP_25_32 (32 | (25 << 8))
|
||||
#define MAP_UNKNOWN_MAP_25_33 (33 | (25 << 8))
|
||||
#define MAP_UNKNOWN_MAP_25_34 (34 | (25 << 8))
|
||||
#define MAP_LINK_CONTEST_ROOM2 (35 | (25 << 8))
|
||||
#define MAP_LINK_CONTEST_ROOM3 (36 | (25 << 8))
|
||||
#define MAP_LINK_CONTEST_ROOM4 (37 | (25 << 8))
|
||||
#define MAP_LINK_CONTEST_ROOM5 (38 | (25 << 8))
|
||||
#define MAP_LINK_CONTEST_ROOM6 (39 | (25 << 8))
|
||||
#define MAP_INSIDE_OF_TRUCK (40 | (25 << 8))
|
||||
#define MAP_SS_TIDAL_CORRIDOR (41 | (25 << 8))
|
||||
#define MAP_SS_TIDAL_LOWER_DECK (42 | (25 << 8))
|
||||
#define MAP_SS_TIDAL_ROOMS (43 | (25 << 8))
|
||||
|
||||
// gMapGroup_SpecialArea
|
||||
#define MAP_SAFARI_ZONE_NORTHWEST (0 | (26 << 8))
|
||||
#define MAP_SAFARI_ZONE_NORTHEAST (1 | (26 << 8))
|
||||
#define MAP_SAFARI_ZONE_SOUTHWEST (2 | (26 << 8))
|
||||
#define MAP_SAFARI_ZONE_SOUTHEAST (3 | (26 << 8))
|
||||
#define MAP_BATTLE_TOWER_OUTSIDE (4 | (26 << 8))
|
||||
#define MAP_BATTLE_TOWER_LOBBY (5 | (26 << 8))
|
||||
#define MAP_BATTLE_TOWER_ELEVATOR (6 | (26 << 8))
|
||||
#define MAP_BATTLE_TOWER_CORRIDOR (7 | (26 << 8))
|
||||
#define MAP_BATTLE_TOWER_BATTLE_ROOM (8 | (26 << 8))
|
||||
#define MAP_SOUTHERN_ISLAND_EXTERIOR (9 | (26 << 8))
|
||||
#define MAP_SOUTHERN_ISLAND_INTERIOR (10 | (26 << 8))
|
||||
#define MAP_SAFARI_ZONE_REST_HOUSE (11 | (26 << 8))
|
||||
|
||||
// gMapGroup_IndoorRoute104Prototype
|
||||
#define MAP_ROUTE104_PROTOTYPE (0 | (27 << 8))
|
||||
#define MAP_ROUTE104_PROTOTYPE_PRETTY_PETAL_FLOWER_SHOP (1 | (27 << 8))
|
||||
|
||||
// gMapGroup_IndoorRoute109
|
||||
#define MAP_ROUTE109_SEASHORE_HOUSE (0 | (28 << 8))
|
||||
|
||||
// gMapGroup_IndoorRoute110
|
||||
#define MAP_ROUTE110_TRICK_HOUSE_ENTRANCE (0 | (29 << 8))
|
||||
#define MAP_ROUTE110_TRICK_HOUSE_END (1 | (29 << 8))
|
||||
#define MAP_ROUTE110_TRICK_HOUSE_CORRIDOR (2 | (29 << 8))
|
||||
#define MAP_ROUTE110_TRICK_HOUSE_PUZZLE1 (3 | (29 << 8))
|
||||
#define MAP_ROUTE110_TRICK_HOUSE_PUZZLE2 (4 | (29 << 8))
|
||||
#define MAP_ROUTE110_TRICK_HOUSE_PUZZLE3 (5 | (29 << 8))
|
||||
#define MAP_ROUTE110_TRICK_HOUSE_PUZZLE4 (6 | (29 << 8))
|
||||
#define MAP_ROUTE110_TRICK_HOUSE_PUZZLE5 (7 | (29 << 8))
|
||||
#define MAP_ROUTE110_TRICK_HOUSE_PUZZLE6 (8 | (29 << 8))
|
||||
#define MAP_ROUTE110_TRICK_HOUSE_PUZZLE7 (9 | (29 << 8))
|
||||
#define MAP_ROUTE110_TRICK_HOUSE_PUZZLE8 (10 | (29 << 8))
|
||||
#define MAP_ROUTE110_SEASIDE_CYCLING_ROAD_SOUTH_ENTRANCE (11 | (29 << 8))
|
||||
#define MAP_ROUTE110_SEASIDE_CYCLING_ROAD_NORTH_ENTRANCE (12 | (29 << 8))
|
||||
|
||||
// gMapGroup_IndoorRoute113
|
||||
#define MAP_ROUTE113_GLASS_WORKSHOP (0 | (30 << 8))
|
||||
|
||||
// gMapGroup_IndoorRoute123
|
||||
#define MAP_ROUTE123_BERRY_MASTERS_HOUSE (0 | (31 << 8))
|
||||
|
||||
// gMapGroup_IndoorRoute119
|
||||
#define MAP_ROUTE119_WEATHER_INSTITUTE_1F (0 | (32 << 8))
|
||||
#define MAP_ROUTE119_WEATHER_INSTITUTE_2F (1 | (32 << 8))
|
||||
#define MAP_ROUTE119_HOUSE (2 | (32 << 8))
|
||||
|
||||
// gMapGroup_IndoorRoute124
|
||||
#define MAP_ROUTE124_DIVING_TREASURE_HUNTERS_HOUSE (0 | (33 << 8))
|
||||
|
||||
#define MAP_GROUPS_COUNT 34
|
||||
|
||||
#endif // GUARD_CONSTANTS_MAP_GROUPS_H
|
||||
119
include/text.h
119
include/text.h
|
|
@ -1,124 +1,7 @@
|
|||
#ifndef GUARD_TEXT_H
|
||||
#define GUARD_TEXT_H
|
||||
|
||||
#define CHAR_SPACE 0x00
|
||||
#define CHAR_LV 0x34
|
||||
#define CHAR_SONG_WORD_SEPARATOR 0x37 // separates words in the bard song. Not sure if it's used for anything else
|
||||
#define CHAR_0 0xA1
|
||||
#define CHAR_EXCL_MARK 0xAB
|
||||
#define CHAR_QUESTION_MARK 0xAC
|
||||
#define CHAR_PERIOD 0xAD
|
||||
#define CHAR_HYPHEN 0xAE
|
||||
#define CHAR_ELLIPSIS 0xB0
|
||||
#define CHAR_DBL_QUOT_LEFT 0xB1
|
||||
#define CHAR_DBL_QUOT_RIGHT 0xB2
|
||||
#define CHAR_SGL_QUOT_LEFT 0xB3
|
||||
#define CHAR_SGL_QUOT_RIGHT 0xB4
|
||||
#define CHAR_MALE 0xB5
|
||||
#define CHAR_FEMALE 0xB6
|
||||
#define CHAR_CURRENCY 0xB7
|
||||
#define CHAR_COMMA 0xB8
|
||||
#define CHAR_MULT_SIGN 0xB9
|
||||
#define CHAR_SLASH 0xBA
|
||||
#define CHAR_A 0xBB
|
||||
#define CHAR_B 0xBC
|
||||
#define CHAR_C 0xBD
|
||||
#define CHAR_D 0xBE
|
||||
#define CHAR_E 0xBF
|
||||
#define CHAR_F 0xC0
|
||||
#define CHAR_G 0xC1
|
||||
#define CHAR_H 0xC2
|
||||
#define CHAR_I 0xC3
|
||||
#define CHAR_J 0xC4
|
||||
#define CHAR_K 0xC5
|
||||
#define CHAR_L 0xC6
|
||||
#define CHAR_M 0xC7
|
||||
#define CHAR_N 0xC8
|
||||
#define CHAR_O 0xC9
|
||||
#define CHAR_P 0xCA
|
||||
#define CHAR_Q 0xCB
|
||||
#define CHAR_R 0xCC
|
||||
#define CHAR_S 0xCD
|
||||
#define CHAR_T 0xCE
|
||||
#define CHAR_U 0xCF
|
||||
#define CHAR_V 0xD0
|
||||
#define CHAR_W 0xD1
|
||||
#define CHAR_X 0xD2
|
||||
#define CHAR_Y 0xD3
|
||||
#define CHAR_Z 0xD4
|
||||
#define CHAR_a 0xD5
|
||||
#define CHAR_b 0xD6
|
||||
#define CHAR_c 0xD7
|
||||
#define CHAR_d 0xD8
|
||||
#define CHAR_e 0xD9
|
||||
#define CHAR_f 0xDA
|
||||
#define CHAR_g 0xDB
|
||||
#define CHAR_h 0xDC
|
||||
#define CHAR_i 0xDD
|
||||
#define CHAR_j 0xDE
|
||||
#define CHAR_k 0xDF
|
||||
#define CHAR_l 0xE0
|
||||
#define CHAR_m 0xE1
|
||||
#define CHAR_n 0xE2
|
||||
#define CHAR_o 0xE3
|
||||
#define CHAR_p 0xE4
|
||||
#define CHAR_q 0xE5
|
||||
#define CHAR_r 0xE6
|
||||
#define CHAR_s 0xE7
|
||||
#define CHAR_t 0xE8
|
||||
#define CHAR_u 0xE9
|
||||
#define CHAR_v 0xEA
|
||||
#define CHAR_w 0xEB
|
||||
#define CHAR_x 0xEC
|
||||
#define CHAR_y 0xED
|
||||
#define CHAR_z 0xEE
|
||||
#define CHAR_COLON 0xF0
|
||||
#define CHAR_PROMPT_SCROLL 0xFA // waits for button press and scrolls dialog
|
||||
#define CHAR_PROMPT_CLEAR 0xFB // waits for button press and clears dialog
|
||||
#define EXT_CTRL_CODE_BEGIN 0xFC // extended control code
|
||||
#define PLACEHOLDER_BEGIN 0xFD // string placeholder
|
||||
#define CHAR_NEWLINE 0xFE
|
||||
#define EOS 0xFF // end of string
|
||||
|
||||
#define TEXT_COLOR_TRANSPARENT 0x00
|
||||
#define TEXT_COLOR_DARK_GREY 0x01
|
||||
#define TEXT_COLOR_RED 0x02
|
||||
#define TEXT_COLOR_GREEN 0x03
|
||||
#define TEXT_COLOR_BLUE 0x04
|
||||
#define TEXT_COLOR_YELLOW 0x05
|
||||
#define TEXT_COLOR_CYAN 0x06
|
||||
#define TEXT_COLOR_MAGENTA 0x07
|
||||
#define TEXT_COLOR_LIGHT_GREY 0x08
|
||||
#define TEXT_COLOR_BLACK 0x09
|
||||
#define TEXT_COLOR_BLACK2 0x0A
|
||||
#define TEXT_COLOR_SILVER 0x0B
|
||||
#define TEXT_COLOR_WHITE 0x0C
|
||||
#define TEXT_COLOR_SKY_BLUE 0x0D
|
||||
#define TEXT_COLOR_LIGHT_BLUE 0x0E
|
||||
#define TEXT_COLOR_WHITE2 0x0F
|
||||
|
||||
#define EXT_CTRL_CODE_COLOR 0x01
|
||||
#define EXT_CTRL_CODE_HIGHLIGHT 0x02
|
||||
#define EXT_CTRL_CODE_SHADOW 0x03
|
||||
#define EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW 0x04
|
||||
#define EXT_CTRL_CODE_PALETTE 0x05
|
||||
#define EXT_CTRL_CODE_SIZE 0x06
|
||||
#define EXT_CTRL_CODE_RESET_SIZE 0x07
|
||||
#define EXT_CTRL_CODE_PAUSE 0x08
|
||||
#define EXT_CTRL_CODE_PAUSE_UNTIL_PRESS 0x09
|
||||
#define EXT_CTRL_CODE_WAIT_SE 0x0A
|
||||
#define EXT_CTRL_CODE_PLAY_BGM 0x0B
|
||||
#define EXT_CTRL_CODE_ESCAPE 0x0C
|
||||
#define EXT_CTRL_CODE_SHIFT_TEXT 0x0D // nop
|
||||
#define EXT_CTRL_CODE_SHIFT_DOWN 0x0E
|
||||
#define EXT_CTRL_CODE_FILL_WINDOW 0x0F
|
||||
#define EXT_CTRL_CODE_PLAY_SE 0x10
|
||||
#define EXT_CTRL_CODE_CLEAR 0x11
|
||||
#define EXT_CTRL_CODE_SKIP 0x12
|
||||
#define EXT_CTRL_CODE_CLEAR_TO 0x13
|
||||
#define EXT_CTRL_CODE_MIN_LETTER_SPACING 0x14
|
||||
#define EXT_CTRL_CODE_JPN 0x15
|
||||
#define EXT_CTRL_CODE_ENG 0x16
|
||||
#include "characters.h"
|
||||
|
||||
struct WindowTemplate
|
||||
{
|
||||
|
|
|
|||
22
make_tools.mk
Normal file
22
make_tools.mk
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# This controls building executables in the `tools` folder.
|
||||
# Can be invoked through the `Makefile` or standalone.
|
||||
|
||||
MAKEFLAGS += --no-print-directory
|
||||
|
||||
# Inclusive list. If you don't want a tool to be built, don't add it here.
|
||||
TOOLS_DIR := tools
|
||||
TOOL_NAMES := aif2pcm bin2c gbafix gbagfx jsonproc mapjson mid2agb preproc ramscrgen rsfont scaninc
|
||||
|
||||
TOOLDIRS := $(TOOL_NAMES:%=$(TOOLS_DIR)/%)
|
||||
|
||||
# Tool making doesnt require a pokefirered dependency scan.
|
||||
RULES_NO_SCAN += tools check-tools clean-tools $(TOOLDIRS)
|
||||
.PHONY: $(RULES_NO_SCAN)
|
||||
|
||||
tools: $(TOOLDIRS)
|
||||
|
||||
$(TOOLDIRS):
|
||||
@$(MAKE) -C $@
|
||||
|
||||
clean-tools:
|
||||
@$(foreach tooldir,$(TOOLDIRS),$(MAKE) clean -C $(tooldir);)
|
||||
|
|
@ -1,31 +1,32 @@
|
|||
# Map JSON data
|
||||
|
||||
MAPS_DIR = data/maps
|
||||
LAYOUTS_DIR = data/layouts
|
||||
# Inputs
|
||||
MAPS_DIR = $(DATA_ASM_SUBDIR)/maps
|
||||
LAYOUTS_DIR = $(DATA_ASM_SUBDIR)/layouts
|
||||
|
||||
MAP_DIRS := $(dir $(wildcard $(MAPS_DIR)/*/))
|
||||
# Outputs
|
||||
MAPS_OUTDIR := $(MAPS_DIR)
|
||||
LAYOUTS_OUTDIR := $(LAYOUTS_DIR)
|
||||
INCLUDECONSTS_OUTDIR := include/constants
|
||||
|
||||
AUTO_GEN_TARGETS += $(INCLUDECONSTS_OUTDIR)/map_groups.h
|
||||
AUTO_GEN_TARGETS += $(INCLUDECONSTS_OUTDIR)/layouts.h
|
||||
|
||||
MAP_DIRS := $(dir $(wildcard $(MAPS_DIR)/*/map.json))
|
||||
MAP_CONNECTIONS := $(patsubst $(MAPS_DIR)/%/,$(MAPS_DIR)/%/connections.inc,$(MAP_DIRS))
|
||||
MAP_EVENTS := $(patsubst $(MAPS_DIR)/%/,$(MAPS_DIR)/%/events.inc,$(MAP_DIRS))
|
||||
MAP_HEADERS := $(patsubst $(MAPS_DIR)/%/,$(MAPS_DIR)/%/header.inc,$(MAP_DIRS))
|
||||
|
||||
$(BUILD_DIR)/data/maps.o: data/maps.s $(LAYOUTS_DIR)/layouts.inc $(LAYOUTS_DIR)/layouts_table.inc $(MAPS_DIR)/headers.inc $(MAPS_DIR)/groups.inc $(MAPS_DIR)/connections.inc $(MAP_CONNECTIONS) $(MAP_HEADERS)
|
||||
$(PREPROC) $< charmap.txt | $(CPP) -I include | $(AS) $(ASFLAGS) -o $@
|
||||
$(PREPROC) $< charmap.txt | $(CPP) -I include -nostdinc -undef -Wno-unicode - | $(PREPROC) -ie $< charmap.txt | $(AS) $(ASFLAGS) -o $@
|
||||
$(BUILD_DIR)/data/map_events.o: data/map_events.s $(MAPS_DIR)/events.inc $(MAP_EVENTS)
|
||||
$(PREPROC) $< charmap.txt | $(CPP) -I include | $(AS) $(ASFLAGS) -o $@
|
||||
$(PREPROC) $< charmap.txt | $(CPP) -I include -nostdinc -undef -Wno-unicode - | $(PREPROC) -ie $< charmap.txt | $(AS) $(ASFLAGS) -o $@
|
||||
|
||||
$(MAPS_DIR)/%/header.inc: $(MAPS_DIR)/%/map.json
|
||||
$(MAPJSON) map ruby $< $(LAYOUTS_DIR)/layouts.json
|
||||
$(MAPS_DIR)/%/events.inc: $(MAPS_DIR)/%/header.inc ;
|
||||
$(MAPS_DIR)/%/connections.inc: $(MAPS_DIR)/%/events.inc ;
|
||||
$(MAPS_OUTDIR)/%/header.inc $(MAPS_OUTDIR)/%/events.inc $(MAPS_OUTDIR)/%/connections.inc: $(MAPS_DIR)/%/map.json
|
||||
$(MAPJSON) map ruby $< $(LAYOUTS_DIR)/layouts.json $(@D)
|
||||
|
||||
$(MAPS_DIR)/groups.inc: $(MAPS_DIR)/map_groups.json
|
||||
$(MAPJSON) groups ruby $<
|
||||
$(MAPS_DIR)/connections.inc: $(MAPS_DIR)/groups.inc ;
|
||||
$(MAPS_DIR)/events.inc: $(MAPS_DIR)/connections.inc ;
|
||||
$(MAPS_DIR)/headers.inc: $(MAPS_DIR)/events.inc ;
|
||||
include/constants/map_groups.h: $(MAPS_DIR)/headers.inc ;
|
||||
$(MAPS_OUTDIR)/connections.inc $(MAPS_OUTDIR)/groups.inc $(MAPS_OUTDIR)/events.inc $(MAPS_OUTDIR)/headers.inc $(INCLUDECONSTS_OUTDIR)/map_groups.h: $(MAPS_DIR)/map_groups.json
|
||||
$(MAPJSON) groups ruby $< $(MAPS_OUTDIR) $(INCLUDECONSTS_OUTDIR)
|
||||
|
||||
$(LAYOUTS_DIR)/layouts.inc: $(LAYOUTS_DIR)/layouts.json
|
||||
$(MAPJSON) layouts ruby $<
|
||||
$(LAYOUTS_DIR)/layouts_table.inc: $(LAYOUTS_DIR)/layouts.inc ;
|
||||
include/constants/layouts.h: $(LAYOUTS_DIR)/layouts_table.inc ;
|
||||
$(LAYOUTS_OUTDIR)/layouts.inc $(LAYOUTS_OUTDIR)/layouts_table.inc $(INCLUDECONSTS_OUTDIR)/layouts.h: $(LAYOUTS_DIR)/layouts.json
|
||||
$(MAPJSON) layouts ruby $< $(LAYOUTS_OUTDIR) $(INCLUDECONSTS_OUTDIR)
|
||||
|
|
|
|||
|
|
@ -1,17 +1,23 @@
|
|||
CC = gcc
|
||||
CC ?= gcc
|
||||
|
||||
CFLAGS = -Wall -Wextra -Wno-switch -Werror -std=c11 -O2 -s
|
||||
CFLAGS = -Wall -Wextra -Wno-switch -Werror -std=c11 -O2
|
||||
|
||||
LIBS = -lm
|
||||
|
||||
SRCS = main.c extended.c
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
EXE := .exe
|
||||
else
|
||||
EXE :=
|
||||
endif
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all: aif2pcm
|
||||
all: aif2pcm$(EXE)
|
||||
@:
|
||||
|
||||
aif2pcm: $(SRCS)
|
||||
aif2pcm$(EXE): $(SRCS)
|
||||
$(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS)
|
||||
|
||||
clean:
|
||||
|
|
|
|||
|
|
@ -51,8 +51,12 @@ do \
|
|||
|
||||
typedef struct {
|
||||
unsigned long num_samples;
|
||||
uint8_t *samples;
|
||||
union {
|
||||
uint8_t *samples8;
|
||||
uint16_t *samples16;
|
||||
};
|
||||
uint8_t midi_note;
|
||||
uint8_t sample_size;
|
||||
bool has_loop;
|
||||
unsigned long loop_offset;
|
||||
double sample_rate;
|
||||
|
|
@ -208,11 +212,11 @@ void read_aif(struct Bytes *aif, AifData *aif_data)
|
|||
num_sample_frames |= (aif->data[pos++] << 8);
|
||||
num_sample_frames |= (uint8_t)aif->data[pos++];
|
||||
|
||||
short sample_size = (aif->data[pos++] << 8);
|
||||
sample_size |= (uint8_t)aif->data[pos++];
|
||||
if (sample_size != 8)
|
||||
aif_data->sample_size = (aif->data[pos++] << 8);
|
||||
aif_data->sample_size |= (uint8_t)aif->data[pos++];
|
||||
if (aif_data->sample_size != 8 && aif_data->sample_size != 16)
|
||||
{
|
||||
FATAL_ERROR("sampleSize (%d) in the COMM Chunk must be 8!\n", sample_size);
|
||||
FATAL_ERROR("sampleSize (%d) in the COMM Chunk must be 8 or 16!\n", aif_data->sample_size);
|
||||
}
|
||||
|
||||
double sample_rate = ieee754_read_extended((uint8_t*)(aif->data + pos));
|
||||
|
|
@ -234,7 +238,7 @@ void read_aif(struct Bytes *aif, AifData *aif_data)
|
|||
{
|
||||
FATAL_ERROR("More than one MARK Chunk in file!\n");
|
||||
}
|
||||
|
||||
|
||||
markers = calloc(num_markers, sizeof(struct Marker));
|
||||
|
||||
// Read each marker.
|
||||
|
|
@ -285,7 +289,7 @@ void read_aif(struct Bytes *aif, AifData *aif_data)
|
|||
// Skip NoLooping sustain loop.
|
||||
pos += 4;
|
||||
}
|
||||
|
||||
|
||||
// Skip release loop, we don't need it.
|
||||
pos += 6;
|
||||
}
|
||||
|
|
@ -295,11 +299,28 @@ void read_aif(struct Bytes *aif, AifData *aif_data)
|
|||
pos += 8;
|
||||
|
||||
unsigned long num_samples = chunk_size - 8;
|
||||
uint8_t *sample_data = (uint8_t *)malloc(num_samples * sizeof(uint8_t));
|
||||
memcpy(sample_data, &aif->data[pos], num_samples);
|
||||
if (aif_data->sample_size == 8)
|
||||
{
|
||||
uint8_t *sample_data = (uint8_t *)malloc(num_samples * sizeof(uint8_t));
|
||||
memcpy(sample_data, &aif->data[pos], num_samples);
|
||||
|
||||
aif_data->samples = sample_data;
|
||||
aif_data->real_num_samples = num_samples;
|
||||
aif_data->samples8 = sample_data;
|
||||
aif_data->real_num_samples = num_samples;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint16_t *sample_data = (uint16_t *)malloc(num_samples * sizeof(uint16_t));
|
||||
uint16_t *sample_data_swapped = (uint16_t *)malloc(num_samples * sizeof(uint16_t));
|
||||
memcpy(sample_data, &aif->data[pos], num_samples);
|
||||
for (long unsigned i = 0; i < num_samples; i++)
|
||||
{
|
||||
sample_data_swapped[i] = __builtin_bswap16(sample_data[i]);
|
||||
}
|
||||
|
||||
aif_data->samples16 = sample_data_swapped;
|
||||
aif_data->real_num_samples = num_samples;
|
||||
free(sample_data);
|
||||
}
|
||||
pos += chunk_size - 8;
|
||||
}
|
||||
else
|
||||
|
|
@ -308,12 +329,12 @@ void read_aif(struct Bytes *aif, AifData *aif_data)
|
|||
pos += chunk_size;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (markers)
|
||||
{
|
||||
// Resolve loop points.
|
||||
struct Marker *cur_marker = markers;
|
||||
|
||||
|
||||
// Grab loop start point.
|
||||
for (int i = 0; i < num_markers; i++, cur_marker++)
|
||||
{
|
||||
|
|
@ -351,6 +372,12 @@ const int gDeltaEncodingTable[] = {
|
|||
-64, -49, -36, -25, -16, -9, -4, -1,
|
||||
};
|
||||
|
||||
#define POSITIVE_DELTAS_START 0
|
||||
#define POSITIVE_DELTAS_END 8
|
||||
|
||||
#define NEGATIVE_DELTAS_START 8
|
||||
#define NEGATIVE_DELTAS_END 16
|
||||
|
||||
struct Bytes *delta_decompress(struct Bytes *delta, unsigned int expected_length)
|
||||
{
|
||||
struct Bytes *pcm = malloc(sizeof(struct Bytes));
|
||||
|
|
@ -418,15 +445,32 @@ struct Bytes *delta_decompress(struct Bytes *delta, unsigned int expected_length
|
|||
return pcm;
|
||||
}
|
||||
|
||||
#define U8_TO_S8(value) ((value) < 128 ? (value) : (value) - 256)
|
||||
#define ABS(value) ((value) >= 0 ? (value) : -(value))
|
||||
|
||||
int get_delta_index(uint8_t sample, uint8_t prev_sample)
|
||||
{
|
||||
int best_error = INT_MAX;
|
||||
int best_index = -1;
|
||||
int delta_table_start_index;
|
||||
int delta_table_end_index;
|
||||
int sample_signed = U8_TO_S8(sample);
|
||||
int prev_sample_signed = U8_TO_S8(prev_sample);
|
||||
|
||||
for (int i = 0; i < 16; i++)
|
||||
// if we're going up (or equal), only choose positive deltas
|
||||
if (prev_sample_signed <= sample_signed) {
|
||||
delta_table_start_index = POSITIVE_DELTAS_START;
|
||||
delta_table_end_index = POSITIVE_DELTAS_END;
|
||||
} else {
|
||||
delta_table_start_index = NEGATIVE_DELTAS_START;
|
||||
delta_table_end_index = NEGATIVE_DELTAS_END;
|
||||
}
|
||||
|
||||
for (int i = delta_table_start_index; i < delta_table_end_index; i++)
|
||||
{
|
||||
uint8_t new_sample = prev_sample + gDeltaEncodingTable[i];
|
||||
int error = sample > new_sample ? sample - new_sample : new_sample - sample;
|
||||
int new_sample_signed = U8_TO_S8(new_sample);
|
||||
int error = ABS(new_sample_signed - sample_signed);
|
||||
|
||||
if (error < best_error)
|
||||
{
|
||||
|
|
@ -527,9 +571,22 @@ do { \
|
|||
void aif2pcm(const char *aif_filename, const char *pcm_filename, bool compress)
|
||||
{
|
||||
struct Bytes *aif = read_bytearray(aif_filename);
|
||||
AifData aif_data = {0,0,0,0,0,0,0};
|
||||
AifData aif_data = {0};
|
||||
read_aif(aif, &aif_data);
|
||||
|
||||
// Convert 16-bit to 8-bit if necessary
|
||||
if (aif_data.sample_size == 16)
|
||||
{
|
||||
aif_data.real_num_samples /= 2;
|
||||
uint8_t *converted_samples = malloc(aif_data.real_num_samples * sizeof(uint8_t));
|
||||
for (unsigned long i = 0; i < aif_data.real_num_samples; i++)
|
||||
{
|
||||
converted_samples[i] = aif_data.samples16[i] >> 8;
|
||||
}
|
||||
free(aif_data.samples16);
|
||||
aif_data.samples8 = converted_samples;
|
||||
}
|
||||
|
||||
int header_size = 0x10;
|
||||
struct Bytes *pcm;
|
||||
struct Bytes output = {0,0};
|
||||
|
|
@ -537,7 +594,7 @@ void aif2pcm(const char *aif_filename, const char *pcm_filename, bool compress)
|
|||
if (compress)
|
||||
{
|
||||
struct Bytes *input = malloc(sizeof(struct Bytes));
|
||||
input->data = aif_data.samples;
|
||||
input->data = aif_data.samples8;
|
||||
input->length = aif_data.real_num_samples;
|
||||
pcm = delta_compress(input);
|
||||
free(input);
|
||||
|
|
@ -545,7 +602,7 @@ void aif2pcm(const char *aif_filename, const char *pcm_filename, bool compress)
|
|||
else
|
||||
{
|
||||
pcm = malloc(sizeof(struct Bytes));
|
||||
pcm->data = aif_data.samples;
|
||||
pcm->data = aif_data.samples8;
|
||||
pcm->length = aif_data.real_num_samples;
|
||||
}
|
||||
output.length = header_size + pcm->length;
|
||||
|
|
@ -568,7 +625,7 @@ void aif2pcm(const char *aif_filename, const char *pcm_filename, bool compress)
|
|||
free(aif);
|
||||
free(pcm);
|
||||
free(output.data);
|
||||
free(aif_data.samples);
|
||||
free(aif_data.samples8);
|
||||
}
|
||||
|
||||
// Reads a .pcm file containing an array of 8-bit samples and produces an .aif file.
|
||||
|
|
@ -608,8 +665,8 @@ void pcm2aif(const char *pcm_filename, const char *aif_filename, uint32_t base_n
|
|||
pcm->data += 0x10;
|
||||
}
|
||||
|
||||
aif_data->samples = malloc(pcm->length);
|
||||
memcpy(aif_data->samples, pcm->data, pcm->length);
|
||||
aif_data->samples8 = malloc(pcm->length);
|
||||
memcpy(aif_data->samples8, pcm->data, pcm->length);
|
||||
|
||||
struct Bytes *aif = malloc(sizeof(struct Bytes));
|
||||
aif->length = 54 + 60 + pcm->length;
|
||||
|
|
@ -796,14 +853,14 @@ void pcm2aif(const char *pcm_filename, const char *aif_filename, uint32_t base_n
|
|||
// Sound Data Chunk soundData
|
||||
for (unsigned int i = 0; i < aif_data->loop_offset; i++)
|
||||
{
|
||||
aif->data[pos++] = aif_data->samples[i];
|
||||
aif->data[pos++] = aif_data->samples8[i];
|
||||
}
|
||||
|
||||
int j = 0;
|
||||
for (unsigned int i = aif_data->loop_offset; i < pcm->length; i++)
|
||||
{
|
||||
int pcm_index = aif_data->loop_offset + (j++ % (pcm->length - aif_data->loop_offset));
|
||||
aif->data[pos++] = aif_data->samples[pcm_index];
|
||||
aif->data[pos++] = aif_data->samples8[pcm_index];
|
||||
}
|
||||
|
||||
aif->length = pos;
|
||||
|
|
|
|||
|
|
@ -1,15 +1,21 @@
|
|||
CC = gcc
|
||||
CC ?= gcc
|
||||
|
||||
CFLAGS = -Wall -Wextra -Werror -std=c11 -O2 -s
|
||||
CFLAGS = -Wall -Wextra -Werror -std=c11 -O2
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
SRCS = bin2c.c
|
||||
|
||||
all: bin2c
|
||||
ifeq ($(OS),Windows_NT)
|
||||
EXE := .exe
|
||||
else
|
||||
EXE :=
|
||||
endif
|
||||
|
||||
all: bin2c$(EXE)
|
||||
@:
|
||||
|
||||
bin2c: $(SRCS)
|
||||
bin2c$(EXE): $(SRCS)
|
||||
$(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS)
|
||||
|
||||
clean:
|
||||
|
|
|
|||
|
|
@ -1,13 +1,18 @@
|
|||
CC = gcc
|
||||
CC ?= gcc
|
||||
.PHONY: all clean
|
||||
|
||||
SRCS = gbafix.c
|
||||
|
||||
.PHONY: all clean
|
||||
ifeq ($(OS),Windows_NT)
|
||||
EXE := .exe
|
||||
else
|
||||
EXE :=
|
||||
endif
|
||||
|
||||
all: gbafix
|
||||
all: gbafix$(EXE)
|
||||
@:
|
||||
|
||||
gbafix: $(SRCS)
|
||||
gbafix$(EXE): $(SRCS)
|
||||
$(CC) $(SRCS) -o $@ $(LDFLAGS)
|
||||
|
||||
clean:
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
|
||||
History
|
||||
-------
|
||||
v1.07 - added support for ELF input, (PikalaxALT)
|
||||
v1.06 - added output silencing, (Sierraffinity)
|
||||
v1.05 - added debug offset argument, (Sierraffinity)
|
||||
v1.04 - converted to plain C, (WinterMute)
|
||||
|
|
@ -50,7 +51,7 @@
|
|||
#include <stdint.h>
|
||||
#include "elf.h"
|
||||
|
||||
#define VER "1.06"
|
||||
#define VER "1.07"
|
||||
#define ARGV argv[arg]
|
||||
#define VALUE (ARGV+2)
|
||||
#define NUMBER strtoul(VALUE, NULL, 0)
|
||||
|
|
@ -138,6 +139,7 @@ int main(int argc, char *argv[])
|
|||
char *argfile = 0;
|
||||
FILE *infile;
|
||||
int silent = 0;
|
||||
int schedule_pad = 0;
|
||||
|
||||
int size,bit;
|
||||
|
||||
|
|
@ -172,28 +174,27 @@ int main(int argc, char *argv[])
|
|||
return -1;
|
||||
}
|
||||
|
||||
uint32_t sh_offset = 0;
|
||||
|
||||
// read file
|
||||
infile = fopen(argfile, "r+b");
|
||||
if (!infile) { fprintf(stderr, "Error opening input file!\n"); return -1; }
|
||||
fseek(infile, 0, SEEK_SET);
|
||||
fseek(infile, sh_offset, SEEK_SET);
|
||||
fread(&header, sizeof(header), 1, infile);
|
||||
|
||||
// elf check
|
||||
uint32_t sh_offset = 0;
|
||||
Elf32_Shdr secHeader;
|
||||
if (memcmp(&header, ELFMAG, 4) == 0) {
|
||||
Elf32_Ehdr *elfHeader = (Elf32_Ehdr *)&header;
|
||||
fseek(infile, elfHeader->e_shoff, SEEK_SET);
|
||||
int i;
|
||||
for (i = 0; i < elfHeader->e_shnum; i++) {
|
||||
Elf32_Shdr secHeader;
|
||||
fread(&secHeader, sizeof(Elf32_Shdr), 1, infile);
|
||||
if (secHeader.sh_type == SHT_PROGBITS && secHeader.sh_addr == elfHeader->e_entry) {
|
||||
fseek(infile, secHeader.sh_offset, SEEK_SET);
|
||||
sh_offset = secHeader.sh_offset;
|
||||
break;
|
||||
}
|
||||
if (secHeader.sh_type == SHT_PROGBITS && secHeader.sh_addr == elfHeader->e_entry) break;
|
||||
}
|
||||
if (i == elfHeader->e_shnum) { fprintf(stderr, "Error finding entry point!\n"); return 1; }
|
||||
fseek(infile, secHeader.sh_offset, SEEK_SET);
|
||||
sh_offset = secHeader.sh_offset;
|
||||
fread(&header, sizeof(header), 1, infile);
|
||||
}
|
||||
|
||||
|
|
@ -205,21 +206,13 @@ int main(int argc, char *argv[])
|
|||
// parse command line
|
||||
for (arg=1; arg<argc; arg++)
|
||||
{
|
||||
if ((ARGV[0] == '-'))
|
||||
if (ARGV[0] == '-')
|
||||
{
|
||||
switch (ARGV[1])
|
||||
{
|
||||
case 'p': // pad
|
||||
{
|
||||
fseek(infile, 0, SEEK_END);
|
||||
size = ftell(infile);
|
||||
for (bit=31; bit>=0; bit--) if (size & (1<<bit)) break;
|
||||
if (size != (1<<bit))
|
||||
{
|
||||
int todo = (1<<(bit+1)) - size;
|
||||
while (todo--) fputc(0xFF, infile);
|
||||
}
|
||||
fseek(infile, 0, SEEK_SET);
|
||||
schedule_pad = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -299,6 +292,21 @@ int main(int argc, char *argv[])
|
|||
header.complement = HeaderComplement();
|
||||
//header.checksum = checksum_without_header + HeaderChecksum();
|
||||
|
||||
if (schedule_pad) {
|
||||
if (sh_offset != 0) {
|
||||
fprintf(stderr, "Warning: Cannot safely pad an ELF\n");
|
||||
} else {
|
||||
fseek(infile, 0, SEEK_END);
|
||||
size = ftell(infile);
|
||||
for (bit=31; bit>=0; bit--) if (size & (1<<bit)) break;
|
||||
if (size != (1<<bit))
|
||||
{
|
||||
int todo = (1<<(bit+1)) - size;
|
||||
while (todo--) fputc(0xFF, infile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fseek(infile, sh_offset, SEEK_SET);
|
||||
fwrite(&header, sizeof(header), 1, infile);
|
||||
fclose(infile);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
CC = gcc
|
||||
CC ?= gcc
|
||||
|
||||
CFLAGS = -Wall -Wextra -Werror -Wno-sign-compare -std=c11 -O2 -DPNG_SKIP_SETJMP_CHECK
|
||||
CFLAGS = -Wall -Wextra -Werror -Wno-sign-compare -std=c11 -O3 -flto -DPNG_SKIP_SETJMP_CHECK
|
||||
CFLAGS += $(shell pkg-config --cflags libpng)
|
||||
|
||||
LIBS = -lpng -lz
|
||||
|
|
@ -8,15 +8,21 @@ LDFLAGS += $(shell pkg-config --libs-only-L libpng)
|
|||
|
||||
SRCS = main.c convert_png.c gfx.c jasc_pal.c lz.c rl.c util.c font.c huff.c
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
EXE := .exe
|
||||
else
|
||||
EXE :=
|
||||
endif
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all: gbagfx
|
||||
all: gbagfx$(EXE)
|
||||
@:
|
||||
|
||||
gbagfx-debug: $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h
|
||||
gbagfx-debug$(EXE): $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h
|
||||
$(CC) $(CFLAGS) -DDEBUG $(SRCS) -o $@ $(LDFLAGS) $(LIBS)
|
||||
|
||||
gbagfx: $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h
|
||||
gbagfx$(EXE): $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h
|
||||
$(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS)
|
||||
|
||||
clean:
|
||||
|
|
|
|||
|
|
@ -62,10 +62,7 @@ static unsigned char *ConvertBitDepth(unsigned char *src, int srcBitDepth, int d
|
|||
|
||||
for (j = 8 - srcBitDepth; j >= 0; j -= srcBitDepth)
|
||||
{
|
||||
unsigned char pixel = (srcByte >> j) % (1 << srcBitDepth);
|
||||
|
||||
if (pixel >= (1 << destBitDepth))
|
||||
FATAL_ERROR("Image exceeds the maximum color value for a %ibpp image.\n", destBitDepth);
|
||||
unsigned char pixel = ((srcByte >> j) % (1 << srcBitDepth)) % (1 << destBitDepth);
|
||||
*dest |= pixel << destBit;
|
||||
destBit -= destBitDepth;
|
||||
if (destBit < 0)
|
||||
|
|
@ -125,7 +122,7 @@ void ReadPng(char *path, struct Image *image)
|
|||
free(row_pointers);
|
||||
fclose(fp);
|
||||
|
||||
if (bit_depth != image->bitDepth)
|
||||
if (bit_depth != image->bitDepth && image->tilemap.data.affine == NULL)
|
||||
{
|
||||
unsigned char *src = image->pixels;
|
||||
|
||||
|
|
@ -133,7 +130,6 @@ void ReadPng(char *path, struct Image *image)
|
|||
FATAL_ERROR("Bit depth of image must be 1, 2, 4, or 8.\n");
|
||||
image->pixels = ConvertBitDepth(image->pixels, bit_depth, image->bitDepth, image->width * image->height);
|
||||
free(src);
|
||||
image->bitDepth = bit_depth;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include "global.h"
|
||||
#include "gfx.h"
|
||||
#include "util.h"
|
||||
|
|
@ -203,26 +204,188 @@ static void ConvertToTiles8Bpp(unsigned char *src, unsigned char *dest, int numT
|
|||
}
|
||||
}
|
||||
|
||||
void ReadImage(char *path, int tilesWidth, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors)
|
||||
// For untiled, plain images
|
||||
static void CopyPlainPixels(unsigned char *src, unsigned char *dest, int size, int dataWidth, bool invertColors)
|
||||
{
|
||||
int tileSize = bitDepth * 8;
|
||||
if (dataWidth == 0) return;
|
||||
for (int i = 0; i < size; i += dataWidth) {
|
||||
for (int j = dataWidth; j > 0; j--) {
|
||||
unsigned char pixels = src[i + j - 1];
|
||||
*dest++ = invertColors ? ~pixels : pixels;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void DecodeAffineTilemap(unsigned char *input, unsigned char *output, unsigned char *tilemap, int tileSize, int numTiles)
|
||||
{
|
||||
for (int i = 0; i < numTiles; i++)
|
||||
{
|
||||
memcpy(&output[i * tileSize], &input[tilemap[i] * tileSize], tileSize);
|
||||
}
|
||||
}
|
||||
|
||||
#define REVERSE_BIT_ORDER(x) ({ \
|
||||
((((x) >> 7) & 1) << 0) \
|
||||
| ((((x) >> 6) & 1) << 1) \
|
||||
| ((((x) >> 5) & 1) << 2) \
|
||||
| ((((x) >> 4) & 1) << 3) \
|
||||
| ((((x) >> 3) & 1) << 4) \
|
||||
| ((((x) >> 2) & 1) << 5) \
|
||||
| ((((x) >> 1) & 1) << 6) \
|
||||
| ((((x) >> 0) & 1) << 7); \
|
||||
})
|
||||
|
||||
#define SWAP_BYTES(a, b) ({ \
|
||||
unsigned char tmp = *(a); \
|
||||
*(a) = *(b); \
|
||||
*(b) = tmp; \
|
||||
})
|
||||
|
||||
#define NSWAP(x) ({ (((x) >> 4) & 0xF) | (((x) << 4) & 0xF0); })
|
||||
|
||||
#define SWAP_NYBBLES(a, b) ({ \
|
||||
unsigned char tmp = NSWAP(*(a)); \
|
||||
*(a) = NSWAP(*(b)); \
|
||||
*(b) = tmp; \
|
||||
})
|
||||
|
||||
static void VflipTile(unsigned char * tile, int bitDepth)
|
||||
{
|
||||
int i;
|
||||
switch (bitDepth)
|
||||
{
|
||||
case 1:
|
||||
SWAP_BYTES(&tile[0], &tile[7]);
|
||||
SWAP_BYTES(&tile[1], &tile[6]);
|
||||
SWAP_BYTES(&tile[2], &tile[5]);
|
||||
SWAP_BYTES(&tile[3], &tile[4]);
|
||||
break;
|
||||
case 4:
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
SWAP_BYTES(&tile[i + 0], &tile[i + 28]);
|
||||
SWAP_BYTES(&tile[i + 4], &tile[i + 24]);
|
||||
SWAP_BYTES(&tile[i + 8], &tile[i + 20]);
|
||||
SWAP_BYTES(&tile[i + 12], &tile[i + 16]);
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
SWAP_BYTES(&tile[i + 0], &tile[i + 56]);
|
||||
SWAP_BYTES(&tile[i + 8], &tile[i + 48]);
|
||||
SWAP_BYTES(&tile[i + 16], &tile[i + 40]);
|
||||
SWAP_BYTES(&tile[i + 24], &tile[i + 32]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void HflipTile(unsigned char * tile, int bitDepth)
|
||||
{
|
||||
int i;
|
||||
switch (bitDepth)
|
||||
{
|
||||
case 1:
|
||||
for (i = 0; i < 8; i++)
|
||||
tile[i] = REVERSE_BIT_ORDER(tile[i]);
|
||||
break;
|
||||
case 4:
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
SWAP_NYBBLES(&tile[4 * i + 0], &tile[4 * i + 3]);
|
||||
SWAP_NYBBLES(&tile[4 * i + 1], &tile[4 * i + 2]);
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
SWAP_BYTES(&tile[8 * i + 0], &tile[8 * i + 7]);
|
||||
SWAP_BYTES(&tile[8 * i + 1], &tile[8 * i + 6]);
|
||||
SWAP_BYTES(&tile[8 * i + 2], &tile[8 * i + 5]);
|
||||
SWAP_BYTES(&tile[8 * i + 3], &tile[8 * i + 4]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void DecodeNonAffineTilemap(unsigned char *input, unsigned char *output, struct NonAffineTile *tilemap, int tileSize, int outTileSize, int bitDepth, int numTiles)
|
||||
{
|
||||
unsigned char * in_tile;
|
||||
unsigned char * out_tile = output;
|
||||
int effectiveBitDepth = tileSize == outTileSize ? bitDepth : 8;
|
||||
for (int i = 0; i < numTiles; i++)
|
||||
{
|
||||
in_tile = &input[tilemap[i].index * tileSize];
|
||||
if (tileSize == outTileSize)
|
||||
memcpy(out_tile, in_tile, tileSize);
|
||||
else
|
||||
{
|
||||
for (int j = 0; j < 64; j++)
|
||||
{
|
||||
int shift = (j & 1) * 4;
|
||||
out_tile[j] = (in_tile[j / 2] & (0xF << shift)) >> shift;
|
||||
}
|
||||
}
|
||||
if (tilemap[i].hflip)
|
||||
HflipTile(out_tile, effectiveBitDepth);
|
||||
if (tilemap[i].vflip)
|
||||
VflipTile(out_tile, effectiveBitDepth);
|
||||
if (bitDepth == 4 && effectiveBitDepth == 8)
|
||||
{
|
||||
for (int j = 0; j < 64; j++)
|
||||
{
|
||||
out_tile[j] &= 0xF;
|
||||
out_tile[j] |= (15 - tilemap[i].palno) << 4;
|
||||
}
|
||||
}
|
||||
out_tile += outTileSize;
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned char *DecodeTilemap(unsigned char *tiles, struct Tilemap *tilemap, int *numTiles_p, bool isAffine, int tileSize, int outTileSize, int bitDepth)
|
||||
{
|
||||
int mapTileSize = isAffine ? 1 : 2;
|
||||
int numTiles = tilemap->size / mapTileSize;
|
||||
unsigned char *decoded = calloc(numTiles, outTileSize);
|
||||
if (isAffine)
|
||||
DecodeAffineTilemap(tiles, decoded, tilemap->data.affine, tileSize, numTiles);
|
||||
else
|
||||
DecodeNonAffineTilemap(tiles, decoded, tilemap->data.non_affine, tileSize, outTileSize, bitDepth, numTiles);
|
||||
free(tiles);
|
||||
*numTiles_p = numTiles;
|
||||
return decoded;
|
||||
}
|
||||
|
||||
void ReadTileImage(char *path, int tilesWidth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors)
|
||||
{
|
||||
int tileSize = image->bitDepth * 8;
|
||||
|
||||
int fileSize;
|
||||
unsigned char *buffer = ReadWholeFile(path, &fileSize);
|
||||
|
||||
int numTiles = fileSize / tileSize;
|
||||
if (image->tilemap.data.affine != NULL)
|
||||
{
|
||||
int outTileSize = (image->bitDepth == 4 && image->palette.numColors > 16) ? 64 : tileSize;
|
||||
buffer = DecodeTilemap(buffer, &image->tilemap, &numTiles, image->isAffine, tileSize, outTileSize, image->bitDepth);
|
||||
if (outTileSize == 64)
|
||||
{
|
||||
tileSize = 64;
|
||||
image->bitDepth = 8;
|
||||
}
|
||||
}
|
||||
|
||||
int tilesHeight = (numTiles + tilesWidth - 1) / tilesWidth;
|
||||
|
||||
if (tilesWidth % metatileWidth != 0)
|
||||
FATAL_ERROR("The width in tiles (%d) isn't a multiple of the specified metatile width (%d)", tilesWidth, metatileWidth);
|
||||
FATAL_ERROR("The width in tiles (%d) isn't a multiple of the specified metatile width (%d)\n", tilesWidth, metatileWidth);
|
||||
|
||||
if (tilesHeight % metatileHeight != 0)
|
||||
FATAL_ERROR("The height in tiles (%d) isn't a multiple of the specified metatile height (%d)", tilesHeight, metatileHeight);
|
||||
FATAL_ERROR("The height in tiles (%d) isn't a multiple of the specified metatile height (%d)\n", tilesHeight, metatileHeight);
|
||||
|
||||
image->width = tilesWidth * 8;
|
||||
image->height = tilesHeight * 8;
|
||||
image->bitDepth = bitDepth;
|
||||
image->pixels = calloc(tilesWidth * tilesHeight, tileSize);
|
||||
|
||||
if (image->pixels == NULL)
|
||||
|
|
@ -230,7 +393,7 @@ void ReadImage(char *path, int tilesWidth, int bitDepth, int metatileWidth, int
|
|||
|
||||
int metatilesWide = tilesWidth / metatileWidth;
|
||||
|
||||
switch (bitDepth) {
|
||||
switch (image->bitDepth) {
|
||||
case 1:
|
||||
ConvertFromTiles1Bpp(buffer, image->pixels, numTiles, metatilesWide, metatileWidth, metatileHeight, invertColors);
|
||||
break;
|
||||
|
|
@ -245,9 +408,9 @@ void ReadImage(char *path, int tilesWidth, int bitDepth, int metatileWidth, int
|
|||
free(buffer);
|
||||
}
|
||||
|
||||
void WriteImage(char *path, int numTiles, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors)
|
||||
void WriteTileImage(char *path, enum NumTilesMode numTilesMode, int numTiles, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors)
|
||||
{
|
||||
int tileSize = bitDepth * 8;
|
||||
int tileSize = image->bitDepth * 8;
|
||||
|
||||
if (image->width % 8 != 0)
|
||||
FATAL_ERROR("The width in pixels (%d) isn't a multiple of 8.\n", image->width);
|
||||
|
|
@ -259,10 +422,10 @@ void WriteImage(char *path, int numTiles, int bitDepth, int metatileWidth, int m
|
|||
int tilesHeight = image->height / 8;
|
||||
|
||||
if (tilesWidth % metatileWidth != 0)
|
||||
FATAL_ERROR("The width in tiles (%d) isn't a multiple of the specified metatile width (%d)", tilesWidth, metatileWidth);
|
||||
FATAL_ERROR("The width in tiles (%d) isn't a multiple of the specified metatile width (%d)\n", tilesWidth, metatileWidth);
|
||||
|
||||
if (tilesHeight % metatileHeight != 0)
|
||||
FATAL_ERROR("The height in tiles (%d) isn't a multiple of the specified metatile height (%d)", tilesHeight, metatileHeight);
|
||||
FATAL_ERROR("The height in tiles (%d) isn't a multiple of the specified metatile height (%d)\n", tilesHeight, metatileHeight);
|
||||
|
||||
int maxNumTiles = tilesWidth * tilesHeight;
|
||||
|
||||
|
|
@ -272,25 +435,96 @@ void WriteImage(char *path, int numTiles, int bitDepth, int metatileWidth, int m
|
|||
FATAL_ERROR("The specified number of tiles (%d) is greater than the maximum possible value (%d).\n", numTiles, maxNumTiles);
|
||||
|
||||
int bufferSize = numTiles * tileSize;
|
||||
unsigned char *buffer = malloc(bufferSize);
|
||||
int maxBufferSize = maxNumTiles * tileSize;
|
||||
unsigned char *buffer = malloc(maxBufferSize);
|
||||
|
||||
if (buffer == NULL)
|
||||
FATAL_ERROR("Failed to allocate memory for pixels.\n");
|
||||
|
||||
int metatilesWide = tilesWidth / metatileWidth;
|
||||
|
||||
switch (bitDepth) {
|
||||
switch (image->bitDepth) {
|
||||
case 1:
|
||||
ConvertToTiles1Bpp(image->pixels, buffer, numTiles, metatilesWide, metatileWidth, metatileHeight, invertColors);
|
||||
ConvertToTiles1Bpp(image->pixels, buffer, maxNumTiles, metatilesWide, metatileWidth, metatileHeight, invertColors);
|
||||
break;
|
||||
case 4:
|
||||
ConvertToTiles4Bpp(image->pixels, buffer, numTiles, metatilesWide, metatileWidth, metatileHeight, invertColors);
|
||||
ConvertToTiles4Bpp(image->pixels, buffer, maxNumTiles, metatilesWide, metatileWidth, metatileHeight, invertColors);
|
||||
break;
|
||||
case 8:
|
||||
ConvertToTiles8Bpp(image->pixels, buffer, numTiles, metatilesWide, metatileWidth, metatileHeight, invertColors);
|
||||
ConvertToTiles8Bpp(image->pixels, buffer, maxNumTiles, metatilesWide, metatileWidth, metatileHeight, invertColors);
|
||||
break;
|
||||
}
|
||||
|
||||
bool zeroPadded = true;
|
||||
for (int i = bufferSize; i < maxBufferSize && zeroPadded; i++) {
|
||||
if (buffer[i] != 0)
|
||||
{
|
||||
switch (numTilesMode)
|
||||
{
|
||||
case NUM_TILES_IGNORE:
|
||||
break;
|
||||
case NUM_TILES_WARN:
|
||||
fprintf(stderr, "Ignoring -num_tiles %d because tile %d contains non-transparent pixels.\n", numTiles, 1 + i / tileSize);
|
||||
zeroPadded = false;
|
||||
break;
|
||||
case NUM_TILES_ERROR:
|
||||
FATAL_ERROR("Tile %d contains non-transparent pixels.\n", 1 + i / tileSize);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WriteWholeFile(path, buffer, zeroPadded ? bufferSize : maxBufferSize);
|
||||
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
void ReadPlainImage(char *path, int dataWidth, struct Image *image, bool invertColors)
|
||||
{
|
||||
int fileSize;
|
||||
unsigned char *buffer = ReadWholeFile(path, &fileSize);
|
||||
|
||||
if (fileSize % dataWidth != 0)
|
||||
FATAL_ERROR("The image data size (%d) isn't a multiple of the specified data width %d.\n", fileSize, dataWidth);
|
||||
|
||||
// png scanlines have wasted bits if they do not align to byte boundaries.
|
||||
// pngs misaligned in this way are not currently handled.
|
||||
int pixelsPerByte = 8 / image->bitDepth;
|
||||
if (image->width % pixelsPerByte != 0)
|
||||
FATAL_ERROR("The width in pixels (%d) isn't a multiple of %d.\n", image->width, pixelsPerByte);
|
||||
|
||||
int numPixels = fileSize * pixelsPerByte;
|
||||
image->height = (numPixels + image->width - 1) / image->width;
|
||||
image->pixels = calloc(image->width * image->height * image->bitDepth / 8, 1);
|
||||
|
||||
if (image->pixels == NULL)
|
||||
FATAL_ERROR("Failed to allocate memory for pixels.\n");
|
||||
|
||||
CopyPlainPixels(buffer, image->pixels, fileSize, dataWidth, invertColors);
|
||||
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
void WritePlainImage(char *path, int dataWidth, struct Image *image, bool invertColors)
|
||||
{
|
||||
int bufferSize = image->width * image->height * image->bitDepth / 8;
|
||||
|
||||
if (bufferSize % dataWidth != 0)
|
||||
FATAL_ERROR("The image data size (%d) isn't a multiple of the specified data width %d.\n", bufferSize, dataWidth);
|
||||
|
||||
// png scanlines have wasted bits if they do not align to byte boundaries.
|
||||
// pngs misaligned in this way are not currently handled.
|
||||
int pixelsPerByte = 8 / image->bitDepth;
|
||||
if (image->width % pixelsPerByte != 0)
|
||||
FATAL_ERROR("The width in pixels (%d) isn't a multiple of %d.\n", image->width, pixelsPerByte);
|
||||
|
||||
unsigned char *buffer = malloc(bufferSize);
|
||||
|
||||
if (buffer == NULL)
|
||||
FATAL_ERROR("Failed to allocate memory for pixels.\n");
|
||||
|
||||
CopyPlainPixels(image->pixels, buffer, bufferSize, dataWidth, invertColors);
|
||||
|
||||
WriteWholeFile(path, buffer, bufferSize);
|
||||
|
||||
free(buffer);
|
||||
|
|
@ -298,6 +532,11 @@ void WriteImage(char *path, int numTiles, int bitDepth, int metatileWidth, int m
|
|||
|
||||
void FreeImage(struct Image *image)
|
||||
{
|
||||
if (image->tilemap.data.affine != NULL)
|
||||
{
|
||||
free(image->tilemap.data.affine);
|
||||
image->tilemap.data.affine = NULL;
|
||||
}
|
||||
free(image->pixels);
|
||||
image->pixels = NULL;
|
||||
}
|
||||
|
|
@ -318,6 +557,12 @@ void ReadGbaPalette(char *path, struct Palette *palette)
|
|||
palette->colors[i].green = UPCONVERT_BIT_DEPTH(GET_GBA_PAL_GREEN(paletteEntry));
|
||||
palette->colors[i].blue = UPCONVERT_BIT_DEPTH(GET_GBA_PAL_BLUE(paletteEntry));
|
||||
}
|
||||
// png can only accept 16 or 256 colors, so fill the remainder with black
|
||||
if (palette->numColors > 16)
|
||||
{
|
||||
memset(&palette->colors[palette->numColors], 0, (256 - palette->numColors) * sizeof(struct Color));
|
||||
palette->numColors = 256;
|
||||
}
|
||||
|
||||
free(data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,21 @@ struct Palette {
|
|||
int numColors;
|
||||
};
|
||||
|
||||
struct NonAffineTile {
|
||||
unsigned short index:10;
|
||||
unsigned short hflip:1;
|
||||
unsigned short vflip:1;
|
||||
unsigned short palno:4;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct Tilemap {
|
||||
union {
|
||||
struct NonAffineTile *non_affine;
|
||||
unsigned char *affine;
|
||||
} data;
|
||||
int size;
|
||||
};
|
||||
|
||||
struct Image {
|
||||
int width;
|
||||
int height;
|
||||
|
|
@ -25,10 +40,20 @@ struct Image {
|
|||
bool hasPalette;
|
||||
struct Palette palette;
|
||||
bool hasTransparency;
|
||||
struct Tilemap tilemap;
|
||||
bool isAffine;
|
||||
};
|
||||
|
||||
void ReadImage(char *path, int tilesWidth, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors);
|
||||
void WriteImage(char *path, int numTiles, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors);
|
||||
enum NumTilesMode {
|
||||
NUM_TILES_IGNORE,
|
||||
NUM_TILES_WARN,
|
||||
NUM_TILES_ERROR,
|
||||
};
|
||||
|
||||
void ReadTileImage(char *path, int tilesWidth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors);
|
||||
void WriteTileImage(char *path, enum NumTilesMode numTilesMode, int numTiles, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors);
|
||||
void ReadPlainImage(char *path, int dataWidth, struct Image *image, bool invertColors);
|
||||
void WritePlainImage(char *path, int dataWidth, struct Image *image, bool invertColors);
|
||||
void FreeImage(struct Image *image);
|
||||
void ReadGbaPalette(char *path, struct Palette *palette);
|
||||
void WriteGbaPalette(char *path, struct Palette *palette);
|
||||
|
|
|
|||
|
|
@ -6,21 +6,21 @@
|
|||
#include "global.h"
|
||||
#include "huff.h"
|
||||
|
||||
static int cmp_tree(const void * a0, const void * b0) {
|
||||
static int cmp_tree(const void *a0, const void *b0) {
|
||||
return ((struct HuffData *)a0)->value - ((struct HuffData *)b0)->value;
|
||||
}
|
||||
|
||||
typedef int (*cmpfun)(const void *, const void *);
|
||||
|
||||
int msort_r(void * data, size_t count, size_t size, cmpfun cmp, void * buffer) {
|
||||
int msort_r(void *data, size_t count, size_t size, cmpfun cmp, void *buffer) {
|
||||
/*
|
||||
* Out-of-place mergesort (stable sort)
|
||||
* Returns 1 on success, 0 on failure
|
||||
*/
|
||||
void * leftPtr;
|
||||
void * rightPtr;
|
||||
void * leftEnd;
|
||||
void * rightEnd;
|
||||
void *leftPtr;
|
||||
void *rightPtr;
|
||||
void *leftEnd;
|
||||
void *rightEnd;
|
||||
int i;
|
||||
|
||||
switch (count) {
|
||||
|
|
@ -85,8 +85,8 @@ int msort_r(void * data, size_t count, size_t size, cmpfun cmp, void * buffer) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int msort(void * data, size_t count, size_t size, cmpfun cmp) {
|
||||
void * buffer = malloc(count * size);
|
||||
int msort(void *data, size_t count, size_t size, cmpfun cmp) {
|
||||
void *buffer = malloc(count * size);
|
||||
if (buffer == NULL) return 0;
|
||||
int result = msort_r(data, count, size, cmp, buffer);
|
||||
free(buffer);
|
||||
|
|
|
|||
|
|
@ -46,10 +46,14 @@ void ReadJascPaletteLine(FILE *fp, char *line)
|
|||
}
|
||||
|
||||
if (c == '\n')
|
||||
FATAL_ERROR("LF line endings aren't supported.\n");
|
||||
{
|
||||
line[length] = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (c == EOF)
|
||||
FATAL_ERROR("Unexpected EOF. No CRLF at end of file.\n");
|
||||
FATAL_ERROR("Unexpected EOF. No LF or CRLF at end of file.\n");
|
||||
|
||||
if (c == 0)
|
||||
FATAL_ERROR("NUL character in file.\n");
|
||||
|
|
|
|||
|
|
@ -25,6 +25,9 @@ void ConvertGbaToPng(char *inputPath, char *outputPath, struct GbaToPngOptions *
|
|||
{
|
||||
struct Image image;
|
||||
|
||||
image.bitDepth = options->bitDepth;
|
||||
image.tilemap.data.affine = NULL;
|
||||
|
||||
if (options->paletteFilePath != NULL)
|
||||
{
|
||||
char *paletteFileExtension = GetFileExtensionAfterDot(options->paletteFilePath);
|
||||
|
|
@ -45,7 +48,24 @@ void ConvertGbaToPng(char *inputPath, char *outputPath, struct GbaToPngOptions *
|
|||
image.hasPalette = false;
|
||||
}
|
||||
|
||||
ReadImage(inputPath, options->width, options->bitDepth, options->metatileWidth, options->metatileHeight, &image, !image.hasPalette);
|
||||
if (options->isTiled)
|
||||
{
|
||||
if (options->tilemapFilePath != NULL)
|
||||
{
|
||||
int fileSize;
|
||||
image.tilemap.data.affine = ReadWholeFile(options->tilemapFilePath, &fileSize);
|
||||
if (options->isAffineMap && options->bitDepth != 8)
|
||||
FATAL_ERROR("affine maps are necessarily 8bpp\n");
|
||||
image.isAffine = options->isAffineMap;
|
||||
image.tilemap.size = fileSize;
|
||||
}
|
||||
ReadTileImage(inputPath, options->width, options->metatileWidth, options->metatileHeight, &image, !image.hasPalette);
|
||||
}
|
||||
else
|
||||
{
|
||||
image.width = options->width;
|
||||
ReadPlainImage(inputPath, options->dataWidth, &image, !image.hasPalette);
|
||||
}
|
||||
|
||||
image.hasTransparency = options->hasTransparency;
|
||||
|
||||
|
|
@ -59,10 +79,14 @@ void ConvertPngToGba(char *inputPath, char *outputPath, struct PngToGbaOptions *
|
|||
struct Image image;
|
||||
|
||||
image.bitDepth = options->bitDepth;
|
||||
image.tilemap.data.affine = NULL; // initialize to NULL to avoid issues in FreeImage
|
||||
|
||||
ReadPng(inputPath, &image);
|
||||
|
||||
WriteImage(outputPath, options->numTiles, options->bitDepth, options->metatileWidth, options->metatileHeight, &image, !image.hasPalette);
|
||||
if (options->isTiled)
|
||||
WriteTileImage(outputPath, options->numTilesMode, options->numTiles, options->metatileWidth, options->metatileHeight, &image, !image.hasPalette);
|
||||
else
|
||||
WritePlainImage(outputPath, options->dataWidth, &image, !image.hasPalette);
|
||||
|
||||
FreeImage(&image);
|
||||
}
|
||||
|
|
@ -77,6 +101,10 @@ void HandleGbaToPngCommand(char *inputPath, char *outputPath, int argc, char **a
|
|||
options.width = 1;
|
||||
options.metatileWidth = 1;
|
||||
options.metatileHeight = 1;
|
||||
options.tilemapFilePath = NULL;
|
||||
options.isAffineMap = false;
|
||||
options.isTiled = true;
|
||||
options.dataWidth = 1;
|
||||
|
||||
for (int i = 3; i < argc; i++)
|
||||
{
|
||||
|
|
@ -134,6 +162,33 @@ void HandleGbaToPngCommand(char *inputPath, char *outputPath, int argc, char **a
|
|||
if (options.metatileHeight < 1)
|
||||
FATAL_ERROR("metatile height must be positive.\n");
|
||||
}
|
||||
else if (strcmp(option, "-tilemap") == 0)
|
||||
{
|
||||
if (i + 1 >= argc)
|
||||
FATAL_ERROR("No tilemap value following \"-tilemap\".\n");
|
||||
i++;
|
||||
options.tilemapFilePath = argv[i];
|
||||
}
|
||||
else if (strcmp(option, "-affine") == 0)
|
||||
{
|
||||
options.isAffineMap = true;
|
||||
}
|
||||
else if (strcmp(option, "-plain") == 0)
|
||||
{
|
||||
options.isTiled = false;
|
||||
}
|
||||
else if (strcmp(option, "-data_width") == 0)
|
||||
{
|
||||
if (i + 1 >= argc)
|
||||
FATAL_ERROR("No data width value following \"-data_width\".\n");
|
||||
i++;
|
||||
|
||||
if (!ParseNumber(argv[i], NULL, 10, &options.dataWidth))
|
||||
FATAL_ERROR("Failed to parse data width.\n");
|
||||
|
||||
if (options.dataWidth < 1)
|
||||
FATAL_ERROR("Data width must be positive.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
FATAL_ERROR("Unrecognized option \"%s\".\n", option);
|
||||
|
|
@ -149,12 +204,16 @@ void HandleGbaToPngCommand(char *inputPath, char *outputPath, int argc, char **a
|
|||
void HandlePngToGbaCommand(char *inputPath, char *outputPath, int argc, char **argv)
|
||||
{
|
||||
char *outputFileExtension = GetFileExtensionAfterDot(outputPath);
|
||||
int bitDepth = outputFileExtension[0] - '0';
|
||||
struct PngToGbaOptions options;
|
||||
options.numTilesMode = NUM_TILES_IGNORE;
|
||||
options.numTiles = 0;
|
||||
options.bitDepth = bitDepth;
|
||||
options.bitDepth = outputFileExtension[0] - '0';
|
||||
options.metatileWidth = 1;
|
||||
options.metatileHeight = 1;
|
||||
options.tilemapFilePath = NULL;
|
||||
options.isAffineMap = false;
|
||||
options.isTiled = true;
|
||||
options.dataWidth = 1;
|
||||
|
||||
for (int i = 3; i < argc; i++)
|
||||
{
|
||||
|
|
@ -173,6 +232,12 @@ void HandlePngToGbaCommand(char *inputPath, char *outputPath, int argc, char **a
|
|||
if (options.numTiles < 1)
|
||||
FATAL_ERROR("Number of tiles must be positive.\n");
|
||||
}
|
||||
else if (strcmp(option, "-Wnum_tiles") == 0) {
|
||||
options.numTilesMode = NUM_TILES_WARN;
|
||||
}
|
||||
else if (strcmp(option, "-Werror=num_tiles") == 0) {
|
||||
options.numTilesMode = NUM_TILES_ERROR;
|
||||
}
|
||||
else if (strcmp(option, "-mwidth") == 0)
|
||||
{
|
||||
if (i + 1 >= argc)
|
||||
|
|
@ -199,6 +264,22 @@ void HandlePngToGbaCommand(char *inputPath, char *outputPath, int argc, char **a
|
|||
if (options.metatileHeight < 1)
|
||||
FATAL_ERROR("metatile height must be positive.\n");
|
||||
}
|
||||
else if (strcmp(option, "-plain") == 0)
|
||||
{
|
||||
options.isTiled = false;
|
||||
}
|
||||
else if (strcmp(option, "-data_width") == 0)
|
||||
{
|
||||
if (i + 1 >= argc)
|
||||
FATAL_ERROR("No data width value following \"-data_width\".\n");
|
||||
i++;
|
||||
|
||||
if (!ParseNumber(argv[i], NULL, 10, &options.dataWidth))
|
||||
FATAL_ERROR("Failed to parse data width.\n");
|
||||
|
||||
if (options.dataWidth < 1)
|
||||
FATAL_ERROR("Data width must be positive.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
FATAL_ERROR("Unrecognized option \"%s\".\n", option);
|
||||
|
|
@ -272,6 +353,7 @@ void HandleJascToGbaPaletteCommand(char *inputPath, char *outputPath, int argc,
|
|||
void HandleLatinFontToPngCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED)
|
||||
{
|
||||
struct Image image;
|
||||
image.tilemap.data.affine = NULL; // initialize to NULL to avoid issues in FreeImage
|
||||
|
||||
ReadLatinFont(inputPath, &image);
|
||||
WritePng(outputPath, &image);
|
||||
|
|
@ -282,6 +364,7 @@ void HandleLatinFontToPngCommand(char *inputPath, char *outputPath, int argc UNU
|
|||
void HandlePngToLatinFontCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED)
|
||||
{
|
||||
struct Image image;
|
||||
image.tilemap.data.affine = NULL; // initialize to NULL to avoid issues in FreeImage
|
||||
|
||||
image.bitDepth = 2;
|
||||
|
||||
|
|
@ -294,6 +377,7 @@ void HandlePngToLatinFontCommand(char *inputPath, char *outputPath, int argc UNU
|
|||
void HandleHalfwidthJapaneseFontToPngCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED)
|
||||
{
|
||||
struct Image image;
|
||||
image.tilemap.data.affine = NULL; // initialize to NULL to avoid issues in FreeImage
|
||||
|
||||
ReadHalfwidthJapaneseFont(inputPath, &image);
|
||||
WritePng(outputPath, &image);
|
||||
|
|
@ -304,6 +388,7 @@ void HandleHalfwidthJapaneseFontToPngCommand(char *inputPath, char *outputPath,
|
|||
void HandlePngToHalfwidthJapaneseFontCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED)
|
||||
{
|
||||
struct Image image;
|
||||
image.tilemap.data.affine = NULL; // initialize to NULL to avoid issues in FreeImage
|
||||
|
||||
image.bitDepth = 2;
|
||||
|
||||
|
|
@ -316,6 +401,7 @@ void HandlePngToHalfwidthJapaneseFontCommand(char *inputPath, char *outputPath,
|
|||
void HandleFullwidthJapaneseFontToPngCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED)
|
||||
{
|
||||
struct Image image;
|
||||
image.tilemap.data.affine = NULL; // initialize to NULL to avoid issues in FreeImage
|
||||
|
||||
ReadFullwidthJapaneseFont(inputPath, &image);
|
||||
WritePng(outputPath, &image);
|
||||
|
|
@ -326,6 +412,7 @@ void HandleFullwidthJapaneseFontToPngCommand(char *inputPath, char *outputPath,
|
|||
void HandlePngToFullwidthJapaneseFontCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED)
|
||||
{
|
||||
struct Image image;
|
||||
image.tilemap.data.affine = NULL; // initialize to NULL to avoid issues in FreeImage
|
||||
|
||||
image.bitDepth = 2;
|
||||
|
||||
|
|
@ -360,7 +447,7 @@ void HandleLZCompressCommand(char *inputPath, char *outputPath, int argc, char *
|
|||
else if (strcmp(option, "-search") == 0)
|
||||
{
|
||||
if (i + 1 >= argc)
|
||||
FATAL_ERROR("No size following \"-overflow\".\n");
|
||||
FATAL_ERROR("No size following \"-search\".\n");
|
||||
|
||||
i++;
|
||||
|
||||
|
|
|
|||
10
tools/gbagfx/options.h
Executable file → Normal file
10
tools/gbagfx/options.h
Executable file → Normal file
|
|
@ -4,6 +4,7 @@
|
|||
#define OPTIONS_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "gfx.h"
|
||||
|
||||
struct GbaToPngOptions {
|
||||
char *paletteFilePath;
|
||||
|
|
@ -12,13 +13,22 @@ struct GbaToPngOptions {
|
|||
int width;
|
||||
int metatileWidth;
|
||||
int metatileHeight;
|
||||
char *tilemapFilePath;
|
||||
bool isAffineMap;
|
||||
bool isTiled;
|
||||
int dataWidth;
|
||||
};
|
||||
|
||||
struct PngToGbaOptions {
|
||||
int numTiles;
|
||||
enum NumTilesMode numTilesMode;
|
||||
int bitDepth;
|
||||
int metatileWidth;
|
||||
int metatileHeight;
|
||||
char *tilemapFilePath;
|
||||
bool isAffineMap;
|
||||
bool isTiled;
|
||||
int dataWidth;
|
||||
};
|
||||
|
||||
#endif // OPTIONS_H
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
CXX := g++
|
||||
CXX ?= g++
|
||||
|
||||
CXXFLAGS := -Wall -std=c++11 -O2
|
||||
CXXFLAGS := -Wall -std=c++17 -O2
|
||||
|
||||
INCLUDES := -I .
|
||||
|
||||
|
|
@ -8,12 +8,18 @@ SRCS := jsonproc.cpp
|
|||
|
||||
HEADERS := jsonproc.h inja.hpp nlohmann/json.hpp
|
||||
|
||||
.PHONY: clean all
|
||||
ifeq ($(OS),Windows_NT)
|
||||
EXE := .exe
|
||||
else
|
||||
EXE :=
|
||||
endif
|
||||
|
||||
all: jsonproc
|
||||
.PHONY: all clean
|
||||
|
||||
all: jsonproc$(EXE)
|
||||
@:
|
||||
|
||||
jsonproc: $(SRCS) $(HEADERS)
|
||||
jsonproc$(EXE): $(SRCS) $(HEADERS)
|
||||
$(CXX) $(CXXFLAGS) $(INCLUDES) $(SRCS) -o $@ $(LDFLAGS)
|
||||
|
||||
clean:
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,4 +1,6 @@
|
|||
// jsonproc.cpp
|
||||
// jsonproc converts JSON data to an output file based on an Inja template.
|
||||
// https://github.com/pantor/inja
|
||||
|
||||
#include "jsonproc.h"
|
||||
|
||||
|
|
@ -8,7 +10,7 @@
|
|||
using std::string; using std::to_string;
|
||||
|
||||
#include <algorithm>
|
||||
using std::remove_if;
|
||||
using std::replace_if;
|
||||
|
||||
#include <inja.hpp>
|
||||
using namespace inja;
|
||||
|
|
@ -112,11 +114,16 @@ int main(int argc, char *argv[])
|
|||
});
|
||||
|
||||
env.add_callback("cleanString", 1, [](Arguments& args) {
|
||||
string badChars = ".'{} \n\t-_\u00e9";
|
||||
string str = args.at(0)->get<string>();
|
||||
str.erase(remove_if(str.begin(), str.end(), [&badChars](const char &c) {
|
||||
return badChars.find(c) != std::string::npos;
|
||||
}), str.end());
|
||||
for (unsigned int i = 0; i < str.length(); i++) {
|
||||
// This code is not Unicode aware, so UTF-8 is not easily parsable without introducing
|
||||
// another library. Just filter out any non-alphanumeric characters for now.
|
||||
// TODO: proper Unicode string normalization
|
||||
if ((i == 0 && isdigit(str[i]))
|
||||
|| !isalnum(str[i])) {
|
||||
str[i] = '_';
|
||||
}
|
||||
}
|
||||
return str;
|
||||
});
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
12
tools/mapjson/Makefile
Executable file → Normal file
12
tools/mapjson/Makefile
Executable file → Normal file
|
|
@ -1,4 +1,4 @@
|
|||
CXX := g++
|
||||
CXX ?= g++
|
||||
|
||||
CXXFLAGS := -Wall -std=c++11 -O2
|
||||
|
||||
|
|
@ -6,12 +6,18 @@ SRCS := json11.cpp mapjson.cpp
|
|||
|
||||
HEADERS := mapjson.h
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
EXE := .exe
|
||||
else
|
||||
EXE :=
|
||||
endif
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all: mapjson
|
||||
all: mapjson$(EXE)
|
||||
@:
|
||||
|
||||
mapjson: $(SRCS) $(HEADERS)
|
||||
mapjson$(EXE): $(SRCS) $(HEADERS)
|
||||
$(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS)
|
||||
|
||||
clean:
|
||||
|
|
|
|||
17
tools/mapjson/json11.cpp
Executable file → Normal file
17
tools/mapjson/json11.cpp
Executable file → Normal file
|
|
@ -33,7 +33,6 @@ using std::vector;
|
|||
using std::map;
|
||||
using std::make_shared;
|
||||
using std::initializer_list;
|
||||
using std::move;
|
||||
|
||||
/* Helper for representing null - just a do-nothing struct, plus comparison
|
||||
* operators so the helpers in JsonValue work. We can't use nullptr_t because
|
||||
|
|
@ -149,7 +148,7 @@ protected:
|
|||
|
||||
// Constructors
|
||||
explicit Value(const T &value) : m_value(value) {}
|
||||
explicit Value(T &&value) : m_value(move(value)) {}
|
||||
explicit Value(T &&value) : m_value(std::move(value)) {}
|
||||
|
||||
// Get type tag
|
||||
Json::Type type() const override {
|
||||
|
|
@ -196,7 +195,7 @@ class JsonString final : public Value<Json::STRING, string> {
|
|||
const string &string_value() const override { return m_value; }
|
||||
public:
|
||||
explicit JsonString(const string &value) : Value(value) {}
|
||||
explicit JsonString(string &&value) : Value(move(value)) {}
|
||||
explicit JsonString(string &&value) : Value(std::move(value)) {}
|
||||
};
|
||||
|
||||
class JsonArray final : public Value<Json::ARRAY, Json::array> {
|
||||
|
|
@ -204,7 +203,7 @@ class JsonArray final : public Value<Json::ARRAY, Json::array> {
|
|||
const Json & operator[](size_t i) const override;
|
||||
public:
|
||||
explicit JsonArray(const Json::array &value) : Value(value) {}
|
||||
explicit JsonArray(Json::array &&value) : Value(move(value)) {}
|
||||
explicit JsonArray(Json::array &&value) : Value(std::move(value)) {}
|
||||
};
|
||||
|
||||
class JsonObject final : public Value<Json::OBJECT, Json::object> {
|
||||
|
|
@ -212,7 +211,7 @@ class JsonObject final : public Value<Json::OBJECT, Json::object> {
|
|||
const Json & operator[](const string &key) const override;
|
||||
public:
|
||||
explicit JsonObject(const Json::object &value) : Value(value) {}
|
||||
explicit JsonObject(Json::object &&value) : Value(move(value)) {}
|
||||
explicit JsonObject(Json::object &&value) : Value(std::move(value)) {}
|
||||
};
|
||||
|
||||
class JsonNull final : public Value<Json::NUL, NullStruct> {
|
||||
|
|
@ -254,12 +253,12 @@ Json::Json(double value) : m_ptr(make_shared<JsonDouble>(value)) {
|
|||
Json::Json(int value) : m_ptr(make_shared<JsonInt>(value)) {}
|
||||
Json::Json(bool value) : m_ptr(value ? statics().t : statics().f) {}
|
||||
Json::Json(const string &value) : m_ptr(make_shared<JsonString>(value)) {}
|
||||
Json::Json(string &&value) : m_ptr(make_shared<JsonString>(move(value))) {}
|
||||
Json::Json(string &&value) : m_ptr(make_shared<JsonString>(std::move(value))) {}
|
||||
Json::Json(const char * value) : m_ptr(make_shared<JsonString>(value)) {}
|
||||
Json::Json(const Json::array &values) : m_ptr(make_shared<JsonArray>(values)) {}
|
||||
Json::Json(Json::array &&values) : m_ptr(make_shared<JsonArray>(move(values))) {}
|
||||
Json::Json(Json::array &&values) : m_ptr(make_shared<JsonArray>(std::move(values))) {}
|
||||
Json::Json(const Json::object &values) : m_ptr(make_shared<JsonObject>(values)) {}
|
||||
Json::Json(Json::object &&values) : m_ptr(make_shared<JsonObject>(move(values))) {}
|
||||
Json::Json(Json::object &&values) : m_ptr(make_shared<JsonObject>(std::move(values))) {}
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * *
|
||||
* Accessors
|
||||
|
|
@ -357,7 +356,7 @@ struct JsonParser final {
|
|||
* Mark this parse as failed.
|
||||
*/
|
||||
Json fail(string &&msg) {
|
||||
return fail(move(msg), Json());
|
||||
return fail(std::move(msg), Json());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
|
|
|||
0
tools/mapjson/json11.h
Executable file → Normal file
0
tools/mapjson/json11.h
Executable file → Normal file
114
tools/mapjson/mapjson.cpp
Executable file → Normal file
114
tools/mapjson/mapjson.cpp
Executable file → Normal file
|
|
@ -30,6 +30,8 @@ using json11::Json;
|
|||
#include "mapjson.h"
|
||||
|
||||
string version;
|
||||
// System directory separator
|
||||
string sep;
|
||||
|
||||
string read_text_file(string filepath) {
|
||||
ifstream in_file(filepath);
|
||||
|
|
@ -195,7 +197,7 @@ string generate_map_events_text(Json map_data) {
|
|||
|
||||
string mapName = json_to_string(map_data, "name");
|
||||
|
||||
text << "@\n@ DO NOT MODIFY THIS FILE! It is auto-generated from data/maps/" << mapName << "/map.json\n@\n\n";
|
||||
text << "@\n@ DO NOT MODIFY THIS FILE! It is auto-generated from data/maps/" << mapName << "/map.json\n@\n\n\t.align 2\n\n";
|
||||
|
||||
string objects_label, warps_label, coords_label, bgs_label;
|
||||
|
||||
|
|
@ -330,13 +332,22 @@ string generate_map_events_text(Json map_data) {
|
|||
return text.str();
|
||||
}
|
||||
|
||||
string get_directory_name(string filename) {
|
||||
size_t dir_pos = filename.find_last_of("/\\");
|
||||
string strip_trailing_separator(string filename) {
|
||||
if(filename.back() == '/' || filename.back() == '\\')
|
||||
filename.pop_back();
|
||||
|
||||
return filename;
|
||||
}
|
||||
void infer_separator(string filename) {
|
||||
size_t dir_pos = filename.find_last_of("/\\");
|
||||
sep = filename[dir_pos];
|
||||
}
|
||||
string file_parent(string filename){
|
||||
size_t dir_pos = filename.find_last_of("/\\");
|
||||
return filename.substr(0, dir_pos + 1);
|
||||
}
|
||||
|
||||
void process_map(string map_filepath, string layouts_filepath) {
|
||||
void process_map(string map_filepath, string layouts_filepath, string output_dir) {
|
||||
string mapdata_err, layouts_err;
|
||||
|
||||
string mapdata_json_text = read_text_file(map_filepath);
|
||||
|
|
@ -354,10 +365,10 @@ void process_map(string map_filepath, string layouts_filepath) {
|
|||
string events_text = generate_map_events_text(map_data);
|
||||
string connections_text = generate_map_connections_text(map_data);
|
||||
|
||||
string files_dir = get_directory_name(map_filepath);
|
||||
write_text_file(files_dir + "header.inc", header_text);
|
||||
write_text_file(files_dir + "events.inc", events_text);
|
||||
write_text_file(files_dir + "connections.inc", connections_text);
|
||||
string out_dir = strip_trailing_separator(output_dir).append(sep);
|
||||
write_text_file(out_dir + "header.inc", header_text);
|
||||
write_text_file(out_dir + "events.inc", events_text);
|
||||
write_text_file(out_dir + "connections.inc", connections_text);
|
||||
}
|
||||
|
||||
string generate_groups_text(Json groups_data) {
|
||||
|
|
@ -382,7 +393,7 @@ string generate_groups_text(Json groups_data) {
|
|||
return text.str();
|
||||
}
|
||||
|
||||
string generate_connections_text(Json groups_data) {
|
||||
string generate_connections_text(Json groups_data, string include_path) {
|
||||
vector<Json> map_names;
|
||||
|
||||
for (auto &group : groups_data["group_order"].array_items())
|
||||
|
|
@ -407,12 +418,12 @@ string generate_connections_text(Json groups_data) {
|
|||
text << "@\n@ DO NOT MODIFY THIS FILE! It is auto-generated from data/maps/map_groups.json\n@\n\n";
|
||||
|
||||
for (Json map_name : map_names)
|
||||
text << "\t.include \"data/maps/" << json_to_string(map_name) << "/connections.inc\"\n";
|
||||
text << "\t.include \"" << include_path << "/" << json_to_string(map_name) << "/connections.inc\"\n";
|
||||
|
||||
return text.str();
|
||||
}
|
||||
|
||||
string generate_headers_text(Json groups_data) {
|
||||
string generate_headers_text(Json groups_data, string include_path) {
|
||||
vector<string> map_names;
|
||||
|
||||
for (auto &group : groups_data["group_order"].array_items())
|
||||
|
|
@ -424,12 +435,12 @@ string generate_headers_text(Json groups_data) {
|
|||
text << "@\n@ DO NOT MODIFY THIS FILE! It is auto-generated from data/maps/map_groups.json\n@\n\n";
|
||||
|
||||
for (string map_name : map_names)
|
||||
text << "\t.include \"data/maps/" << map_name << "/header.inc\"\n";
|
||||
text << "\t.include \"" << include_path << "/" << map_name << "/header.inc\"\n";
|
||||
|
||||
return text.str();
|
||||
}
|
||||
|
||||
string generate_events_text(Json groups_data) {
|
||||
string generate_events_text(Json groups_data, string include_path) {
|
||||
vector<string> map_names;
|
||||
|
||||
for (auto &group : groups_data["group_order"].array_items())
|
||||
|
|
@ -438,17 +449,16 @@ string generate_events_text(Json groups_data) {
|
|||
|
||||
ostringstream text;
|
||||
|
||||
text << "@\n@ DO NOT MODIFY THIS FILE! It is auto-generated from data/maps/map_groups.json\n@\n\n";
|
||||
text << "@\n@ DO NOT MODIFY THIS FILE! It is auto-generated from " << include_path << "/map_groups.json\n@\n\n";
|
||||
|
||||
for (string map_name : map_names)
|
||||
text << "\t.include \"data/maps/" << map_name << "/events.inc\"\n";
|
||||
text << "\t.include \"" << include_path << "/" << map_name << "/events.inc\"\n";
|
||||
|
||||
return text.str();
|
||||
}
|
||||
|
||||
string generate_map_constants_text(string groups_filepath, Json groups_data) {
|
||||
string file_dir = get_directory_name(groups_filepath);
|
||||
char dir_separator = file_dir.back();
|
||||
string file_dir = file_parent(groups_filepath) + sep;
|
||||
|
||||
ostringstream text;
|
||||
|
||||
|
|
@ -466,7 +476,7 @@ string generate_map_constants_text(string groups_filepath, Json groups_data) {
|
|||
size_t max_length = 0;
|
||||
|
||||
for (auto &map_name : groups_data[groupName].array_items()) {
|
||||
string map_filepath = file_dir + json_to_string(map_name) + dir_separator + "map.json";
|
||||
string map_filepath = file_dir + json_to_string(map_name) + sep + "map.json";
|
||||
string err_str;
|
||||
Json map_data = Json::parse(read_text_file(map_filepath), err_str);
|
||||
if (map_data == Json())
|
||||
|
|
@ -493,7 +503,11 @@ string generate_map_constants_text(string groups_filepath, Json groups_data) {
|
|||
return text.str();
|
||||
}
|
||||
|
||||
void process_groups(string groups_filepath) {
|
||||
// Output paths are directories with trailing path separators
|
||||
void process_groups(string groups_filepath, string output_asm, string output_c) {
|
||||
output_asm = strip_trailing_separator(output_asm); // Remove separator if existing.
|
||||
output_c = strip_trailing_separator(output_c);
|
||||
|
||||
string err;
|
||||
Json groups_data = Json::parse(read_text_file(groups_filepath), err);
|
||||
|
||||
|
|
@ -501,19 +515,16 @@ void process_groups(string groups_filepath) {
|
|||
FATAL_ERROR("%s\n", err.c_str());
|
||||
|
||||
string groups_text = generate_groups_text(groups_data);
|
||||
string connections_text = generate_connections_text(groups_data);
|
||||
string headers_text = generate_headers_text(groups_data);
|
||||
string events_text = generate_events_text(groups_data);
|
||||
string connections_text = generate_connections_text(groups_data, output_asm);
|
||||
string headers_text = generate_headers_text(groups_data, output_asm);
|
||||
string events_text = generate_events_text(groups_data, output_asm);
|
||||
string map_header_text = generate_map_constants_text(groups_filepath, groups_data);
|
||||
|
||||
string file_dir = get_directory_name(groups_filepath);
|
||||
char s = file_dir.back();
|
||||
|
||||
write_text_file(file_dir + "groups.inc", groups_text);
|
||||
write_text_file(file_dir + "connections.inc", connections_text);
|
||||
write_text_file(file_dir + "headers.inc", headers_text);
|
||||
write_text_file(file_dir + "events.inc", events_text);
|
||||
write_text_file(file_dir + ".." + s + ".." + s + "include" + s + "constants" + s + "map_groups.h", map_header_text);
|
||||
write_text_file(output_asm + sep + "groups.inc", groups_text);
|
||||
write_text_file(output_asm + sep + "connections.inc", connections_text);
|
||||
write_text_file(output_asm + sep + "headers.inc", headers_text);
|
||||
write_text_file(output_asm + sep + "events.inc", events_text);
|
||||
write_text_file(output_c + sep + "map_groups.h", map_header_text);
|
||||
}
|
||||
|
||||
string generate_layout_headers_text(Json layouts_data) {
|
||||
|
|
@ -586,7 +597,10 @@ string generate_layouts_constants_text(Json layouts_data) {
|
|||
return text.str();
|
||||
}
|
||||
|
||||
void process_layouts(string layouts_filepath) {
|
||||
void process_layouts(string layouts_filepath, string output_asm, string output_c) {
|
||||
output_asm = strip_trailing_separator(output_asm).append(sep);
|
||||
output_c = strip_trailing_separator(output_c).append(sep);
|
||||
|
||||
string err;
|
||||
Json layouts_data = Json::parse(read_text_file(layouts_filepath), err);
|
||||
|
||||
|
|
@ -597,12 +611,9 @@ void process_layouts(string layouts_filepath) {
|
|||
string layouts_table_text = generate_layouts_table_text(layouts_data);
|
||||
string layouts_constants_text = generate_layouts_constants_text(layouts_data);
|
||||
|
||||
string file_dir = get_directory_name(layouts_filepath);
|
||||
char s = file_dir.back();
|
||||
|
||||
write_text_file(file_dir + "layouts.inc", layout_headers_text);
|
||||
write_text_file(file_dir + "layouts_table.inc", layouts_table_text);
|
||||
write_text_file(file_dir + ".." + s + ".." + s + "include" + s + "constants" + s + "layouts.h", layouts_constants_text);
|
||||
write_text_file(output_asm + "layouts.inc", layout_headers_text);
|
||||
write_text_file(output_asm + "layouts_table.inc", layouts_table_text);
|
||||
write_text_file(output_c + "layouts.h", layouts_constants_text);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
|
@ -620,29 +631,40 @@ int main(int argc, char *argv[]) {
|
|||
FATAL_ERROR("ERROR: <mode> must be 'layouts', 'map', or 'groups'.\n");
|
||||
|
||||
if (mode == "map") {
|
||||
if (argc != 5)
|
||||
FATAL_ERROR("USAGE: mapjson map <game-version> <map_file> <layouts_file>\n");
|
||||
if (argc != 6)
|
||||
FATAL_ERROR("USAGE: mapjson map <game-version> <map_file> <layouts_file> <output_dir>\n");
|
||||
|
||||
infer_separator(argv[3]);
|
||||
string filepath(argv[3]);
|
||||
string layouts_filepath(argv[4]);
|
||||
string output_dir(argv[5]);
|
||||
|
||||
process_map(filepath, layouts_filepath);
|
||||
process_map(filepath, layouts_filepath, output_dir);
|
||||
}
|
||||
else if (mode == "groups") {
|
||||
if (argc != 4)
|
||||
FATAL_ERROR("USAGE: mapjson groups <game-version> <groups_file>\n");
|
||||
if (argc != 6)
|
||||
FATAL_ERROR("USAGE: mapjson groups <game-version> <groups_file> <output_asm_dir> <output_c_dir>\n");
|
||||
|
||||
infer_separator(argv[3]);
|
||||
string filepath(argv[3]);
|
||||
string output_asm(argv[4]);
|
||||
string output_c(argv[5]);
|
||||
|
||||
process_groups(filepath);
|
||||
process_groups(filepath, output_asm, output_c);
|
||||
}
|
||||
else if (mode == "layouts") {
|
||||
if (argc != 4)
|
||||
FATAL_ERROR("USAGE: mapjson layouts <game-version> <layouts_file>\n");
|
||||
if (argc != 6)
|
||||
FATAL_ERROR("USAGE: mapjson layouts <game-version> <layouts_file> <output_asm_dir> <output_c_dir>\n");
|
||||
|
||||
infer_separator(argv[3]);
|
||||
string filepath(argv[3]);
|
||||
string output_asm(argv[4]);
|
||||
string output_c(argv[5]);
|
||||
|
||||
process_layouts(filepath);
|
||||
process_layouts(filepath, output_asm, output_c);
|
||||
}
|
||||
else {
|
||||
FATAL_ERROR("ERROR: <mode> must be 'layouts', 'map', or 'groups'.\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
0
tools/mapjson/mapjson.h
Executable file → Normal file
0
tools/mapjson/mapjson.h
Executable file → Normal file
|
|
@ -1,17 +1,23 @@
|
|||
CXX := g++
|
||||
CXX ?= g++
|
||||
|
||||
CXXFLAGS := -std=c++11 -O2 -s -Wall -Wno-switch -Werror
|
||||
CXXFLAGS := -std=c++11 -O2 -Wall -Wno-switch -Werror
|
||||
|
||||
SRCS := agb.cpp error.cpp main.cpp midi.cpp tables.cpp
|
||||
|
||||
HEADERS := agb.h error.h main.h midi.h tables.h
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
EXE := .exe
|
||||
else
|
||||
EXE :=
|
||||
endif
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all: mid2agb
|
||||
all: mid2agb$(EXE)
|
||||
@:
|
||||
|
||||
mid2agb: $(SRCS) $(HEADERS)
|
||||
mid2agb$(EXE): $(SRCS) $(HEADERS)
|
||||
$(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS)
|
||||
|
||||
clean:
|
||||
|
|
|
|||
|
|
@ -39,6 +39,9 @@ static bool s_noteChanged;
|
|||
static bool s_velocityChanged;
|
||||
static bool s_inPattern;
|
||||
static int s_extendedCommand;
|
||||
static int s_memaccOp;
|
||||
static int s_memaccParam1;
|
||||
static int s_memaccParam2;
|
||||
|
||||
void PrintAgbHeader()
|
||||
{
|
||||
|
|
@ -248,6 +251,84 @@ void PrintSeqLoopLabel(const Event& event)
|
|||
ResetTrackVars();
|
||||
}
|
||||
|
||||
void PrintMemAcc(const Event& event)
|
||||
{
|
||||
switch (s_memaccOp)
|
||||
{
|
||||
case 0x00:
|
||||
PrintByte("MEMACC, mem_set, 0x%02X, %u", s_memaccParam1, event.param2);
|
||||
break;
|
||||
case 0x01:
|
||||
PrintByte("MEMACC, mem_add, 0x%02X, %u", s_memaccParam1, event.param2);
|
||||
break;
|
||||
case 0x02:
|
||||
PrintByte("MEMACC, mem_sub, 0x%02X, %u", s_memaccParam1, event.param2);
|
||||
break;
|
||||
case 0x03:
|
||||
PrintByte("MEMACC, mem_mem_set, 0x%02X, 0x%02X", s_memaccParam1, event.param2);
|
||||
break;
|
||||
case 0x04:
|
||||
PrintByte("MEMACC, mem_mem_add, 0x%02X, 0x%02X", s_memaccParam1, event.param2);
|
||||
break;
|
||||
case 0x05:
|
||||
PrintByte("MEMACC, mem_mem_sub, 0x%02X, 0x%02X", s_memaccParam1, event.param2);
|
||||
break;
|
||||
// TODO: everything else
|
||||
case 0x06:
|
||||
break;
|
||||
case 0x07:
|
||||
break;
|
||||
case 0x08:
|
||||
break;
|
||||
case 0x09:
|
||||
break;
|
||||
case 0x0A:
|
||||
break;
|
||||
case 0x0B:
|
||||
break;
|
||||
case 0x0C:
|
||||
break;
|
||||
case 0x0D:
|
||||
break;
|
||||
case 0x0E:
|
||||
break;
|
||||
case 0x0F:
|
||||
break;
|
||||
case 0x10:
|
||||
break;
|
||||
case 0x11:
|
||||
break;
|
||||
case 0x46:
|
||||
break;
|
||||
case 0x47:
|
||||
break;
|
||||
case 0x48:
|
||||
break;
|
||||
case 0x49:
|
||||
break;
|
||||
case 0x4A:
|
||||
break;
|
||||
case 0x4B:
|
||||
break;
|
||||
case 0x4C:
|
||||
break;
|
||||
case 0x4D:
|
||||
break;
|
||||
case 0x4E:
|
||||
break;
|
||||
case 0x4F:
|
||||
break;
|
||||
case 0x50:
|
||||
break;
|
||||
case 0x51:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
PrintWait(event.time);
|
||||
}
|
||||
|
||||
void PrintExtendedOp(const Event& event)
|
||||
{
|
||||
// TODO: support for other extended commands
|
||||
|
|
@ -281,16 +362,19 @@ void PrintControllerOp(const Event& event)
|
|||
break;
|
||||
case 0x0C:
|
||||
case 0x10:
|
||||
// TODO: memacc
|
||||
PrintMemAcc(event);
|
||||
break;
|
||||
case 0x0D:
|
||||
// TODO: memacc var
|
||||
s_memaccOp = event.param2;
|
||||
PrintWait(event.time);
|
||||
break;
|
||||
case 0x0E:
|
||||
// TODO: memacc var
|
||||
s_memaccParam1 = event.param2;
|
||||
PrintWait(event.time);
|
||||
break;
|
||||
case 0x0F:
|
||||
// TODO: memacc var
|
||||
s_memaccParam2 = event.param2;
|
||||
PrintWait(event.time);
|
||||
break;
|
||||
case 0x11:
|
||||
std::fprintf(g_outputFile, "%s_%u_L%u:\n", g_asmLabel.c_str(), g_agbTrack, event.param2);
|
||||
|
|
@ -335,8 +419,6 @@ void PrintAgbTrack(std::vector<Event>& events)
|
|||
{
|
||||
std::fprintf(g_outputFile, "\n@**************** Track %u (Midi-Chn.%u) ****************@\n\n", g_agbTrack, g_midiChan + 1);
|
||||
std::fprintf(g_outputFile, "%s_%u:\n", g_asmLabel.c_str(), g_agbTrack);
|
||||
PrintWait(g_initialWait);
|
||||
PrintByte("KEYSH , %s_key%+d", g_asmLabel.c_str(), 0);
|
||||
|
||||
int wholeNoteCount = 0;
|
||||
int loopEndBlockNum = 0;
|
||||
|
|
@ -360,6 +442,9 @@ void PrintAgbTrack(std::vector<Event>& events)
|
|||
if (!foundVolBeforeNote)
|
||||
PrintByte("\tVOL , 127*%s_mvl/mxv", g_asmLabel.c_str());
|
||||
|
||||
PrintWait(g_initialWait);
|
||||
PrintByte("KEYSH , %s_key%+d", g_asmLabel.c_str(), 0);
|
||||
|
||||
for (unsigned i = 0; events[i].type != EventType::EndOfTrack; i++)
|
||||
{
|
||||
const Event& event = events[i];
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ int main(int argc, char** argv)
|
|||
|
||||
if (option[0] == '-' && option[1] != '\0')
|
||||
{
|
||||
const char *arg = GetArgument(argc, argv, i);
|
||||
const char *arg;
|
||||
|
||||
switch (std::toupper(option[1]))
|
||||
{
|
||||
|
|
@ -146,29 +146,34 @@ int main(int argc, char** argv)
|
|||
g_exactGateTime = true;
|
||||
break;
|
||||
case 'G':
|
||||
arg = GetArgument(argc, argv, i);
|
||||
if (arg == nullptr)
|
||||
PrintUsage();
|
||||
g_voiceGroup = std::stoi(arg);
|
||||
break;
|
||||
case 'L':
|
||||
arg = GetArgument(argc, argv, i);
|
||||
if (arg == nullptr)
|
||||
PrintUsage();
|
||||
g_asmLabel = std::stoi(arg);
|
||||
g_asmLabel = arg;
|
||||
break;
|
||||
case 'N':
|
||||
g_compressionEnabled = false;
|
||||
break;
|
||||
case 'P':
|
||||
arg = GetArgument(argc, argv, i);
|
||||
if (arg == nullptr)
|
||||
PrintUsage();
|
||||
g_priority = std::stoi(arg);
|
||||
break;
|
||||
case 'R':
|
||||
arg = GetArgument(argc, argv, i);
|
||||
if (arg == nullptr)
|
||||
PrintUsage();
|
||||
g_reverb = std::stoi(arg);
|
||||
break;
|
||||
case 'V':
|
||||
arg = GetArgument(argc, argv, i);
|
||||
if (arg == nullptr)
|
||||
PrintUsage();
|
||||
g_masterVolume = std::stoi(arg);
|
||||
|
|
|
|||
|
|
@ -780,7 +780,7 @@ int CalculateCompressionScore(std::vector<Event>& events, int index)
|
|||
std::uint8_t lastVelocity = 0x80u;
|
||||
EventType lastType = events[index].type;
|
||||
std::int32_t lastDuration = 0x80000000;
|
||||
std::uint8_t lastNote = 0x80u;
|
||||
std::uint8_t lastNote = 0x40u;
|
||||
|
||||
if (events[index].time > 0)
|
||||
score++;
|
||||
|
|
@ -844,7 +844,7 @@ int CalculateCompressionScore(std::vector<Event>& events, int index)
|
|||
lastType = events[i].type;
|
||||
|
||||
if (events[i].time)
|
||||
++score;
|
||||
score++;
|
||||
}
|
||||
|
||||
return score;
|
||||
|
|
@ -852,6 +852,12 @@ int CalculateCompressionScore(std::vector<Event>& events, int index)
|
|||
|
||||
bool IsCompressionMatch(std::vector<Event>& events, int index1, int index2)
|
||||
{
|
||||
if (events[index1].type != events[index2].type ||
|
||||
events[index1].note != events[index2].note ||
|
||||
events[index1].param1 != events[index2].param1 ||
|
||||
events[index1].time != events[index2].time)
|
||||
return false;
|
||||
|
||||
index1++;
|
||||
index2++;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,19 +1,25 @@
|
|||
CXX := g++
|
||||
CXX ?= g++
|
||||
|
||||
CXXFLAGS := -std=c++11 -O2 -s -Wall -Wno-switch -Werror
|
||||
CXXFLAGS := -std=c++11 -O2 -Wall -Wno-switch -Werror
|
||||
|
||||
SRCS := asm_file.cpp c_file.cpp charmap.cpp preproc.cpp string_parser.cpp \
|
||||
utf8.cpp
|
||||
utf8.cpp io.cpp
|
||||
|
||||
HEADERS := asm_file.h c_file.h char_util.h charmap.h preproc.h string_parser.h \
|
||||
utf8.h
|
||||
utf8.h io.h
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
EXE := .exe
|
||||
else
|
||||
EXE :=
|
||||
endif
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all: preproc
|
||||
all: preproc$(EXE)
|
||||
@:
|
||||
|
||||
preproc: $(SRCS) $(HEADERS)
|
||||
preproc$(EXE): $(SRCS) $(HEADERS)
|
||||
$(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS)
|
||||
|
||||
clean:
|
||||
|
|
|
|||
|
|
@ -26,33 +26,13 @@
|
|||
#include "char_util.h"
|
||||
#include "utf8.h"
|
||||
#include "string_parser.h"
|
||||
#include "../../include/characters.h"
|
||||
#include "io.h"
|
||||
|
||||
AsmFile::AsmFile(std::string filename) : m_filename(filename)
|
||||
AsmFile::AsmFile(std::string filename, bool isStdin, bool doEnum) : m_filename(filename)
|
||||
{
|
||||
FILE *fp = std::fopen(filename.c_str(), "rb");
|
||||
|
||||
if (fp == NULL)
|
||||
FATAL_ERROR("Failed to open \"%s\" for reading.\n", filename.c_str());
|
||||
|
||||
std::fseek(fp, 0, SEEK_END);
|
||||
|
||||
m_size = std::ftell(fp);
|
||||
|
||||
if (m_size < 0)
|
||||
FATAL_ERROR("File size of \"%s\" is less than zero.\n", filename.c_str());
|
||||
else if (m_size == 0)
|
||||
return; // Empty file
|
||||
|
||||
m_buffer = new char[m_size + 1];
|
||||
|
||||
std::rewind(fp);
|
||||
|
||||
if (std::fread(m_buffer, m_size, 1, fp) != 1)
|
||||
FATAL_ERROR("Failed to read \"%s\".\n", filename.c_str());
|
||||
|
||||
m_buffer[m_size] = 0;
|
||||
|
||||
std::fclose(fp);
|
||||
m_buffer = ReadFileToBuffer(filename.c_str(), isStdin, &m_size);
|
||||
m_doEnum = doEnum;
|
||||
|
||||
m_pos = 0;
|
||||
m_lineNum = 1;
|
||||
|
|
@ -64,6 +44,7 @@ AsmFile::AsmFile(std::string filename) : m_filename(filename)
|
|||
AsmFile::AsmFile(AsmFile&& other) : m_filename(std::move(other.m_filename))
|
||||
{
|
||||
m_buffer = other.m_buffer;
|
||||
m_doEnum = other.m_doEnum;
|
||||
m_pos = other.m_pos;
|
||||
m_size = other.m_size;
|
||||
m_lineNum = other.m_lineNum;
|
||||
|
|
@ -173,6 +154,8 @@ Directive AsmFile::GetDirective()
|
|||
return Directive::String;
|
||||
else if (CheckForDirective(".braille"))
|
||||
return Directive::Braille;
|
||||
else if (CheckForDirective("enum"))
|
||||
return Directive::Enum;
|
||||
else
|
||||
return Directive::Unknown;
|
||||
}
|
||||
|
|
@ -283,7 +266,7 @@ int AsmFile::ReadString(unsigned char* s)
|
|||
|
||||
while (length < padLength)
|
||||
{
|
||||
s[length++] = 0;
|
||||
s[length++] = CHAR_SPACE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -292,40 +275,92 @@ int AsmFile::ReadString(unsigned char* s)
|
|||
return length;
|
||||
}
|
||||
|
||||
void AsmFile::VerifyStringLength(int length)
|
||||
{
|
||||
if (length == kMaxStringLength)
|
||||
RaiseError("mapped string longer than %d bytes", kMaxStringLength);
|
||||
}
|
||||
|
||||
int AsmFile::ReadBraille(unsigned char* s)
|
||||
{
|
||||
static std::map<char, unsigned char> encoding =
|
||||
{
|
||||
{ 'A', 0x01 },
|
||||
{ 'B', 0x05 },
|
||||
{ 'C', 0x03 },
|
||||
{ 'D', 0x0B },
|
||||
{ 'E', 0x09 },
|
||||
{ 'F', 0x07 },
|
||||
{ 'G', 0x0F },
|
||||
{ 'H', 0x0D },
|
||||
{ 'I', 0x06 },
|
||||
{ 'J', 0x0E },
|
||||
{ 'K', 0x11 },
|
||||
{ 'L', 0x15 },
|
||||
{ 'M', 0x13 },
|
||||
{ 'N', 0x1B },
|
||||
{ 'O', 0x19 },
|
||||
{ 'P', 0x17 },
|
||||
{ 'Q', 0x1F },
|
||||
{ 'R', 0x1D },
|
||||
{ 'S', 0x16 },
|
||||
{ 'T', 0x1E },
|
||||
{ 'U', 0x31 },
|
||||
{ 'V', 0x35 },
|
||||
{ 'W', 0x2E },
|
||||
{ 'X', 0x33 },
|
||||
{ 'Y', 0x3B },
|
||||
{ 'Z', 0x39 },
|
||||
{ ' ', 0x00 },
|
||||
{ ',', 0x04 },
|
||||
{ '.', 0x2C },
|
||||
{ '$', 0xFF },
|
||||
{ 'A', BRAILLE_CHAR_A },
|
||||
{ 'B', BRAILLE_CHAR_B },
|
||||
{ 'C', BRAILLE_CHAR_C },
|
||||
{ 'D', BRAILLE_CHAR_D },
|
||||
{ 'E', BRAILLE_CHAR_E },
|
||||
{ 'F', BRAILLE_CHAR_F },
|
||||
{ 'G', BRAILLE_CHAR_G },
|
||||
{ 'H', BRAILLE_CHAR_H },
|
||||
{ 'I', BRAILLE_CHAR_I },
|
||||
{ 'J', BRAILLE_CHAR_J },
|
||||
{ 'K', BRAILLE_CHAR_K },
|
||||
{ 'L', BRAILLE_CHAR_L },
|
||||
{ 'M', BRAILLE_CHAR_M },
|
||||
{ 'N', BRAILLE_CHAR_N },
|
||||
{ 'O', BRAILLE_CHAR_O },
|
||||
{ 'P', BRAILLE_CHAR_P },
|
||||
{ 'Q', BRAILLE_CHAR_Q },
|
||||
{ 'R', BRAILLE_CHAR_R },
|
||||
{ 'S', BRAILLE_CHAR_S },
|
||||
{ 'T', BRAILLE_CHAR_T },
|
||||
{ 'U', BRAILLE_CHAR_U },
|
||||
{ 'V', BRAILLE_CHAR_V },
|
||||
{ 'W', BRAILLE_CHAR_W },
|
||||
{ 'X', BRAILLE_CHAR_X },
|
||||
{ 'Y', BRAILLE_CHAR_Y },
|
||||
{ 'Z', BRAILLE_CHAR_Z },
|
||||
{ 'a', BRAILLE_CHAR_A },
|
||||
{ 'b', BRAILLE_CHAR_B },
|
||||
{ 'c', BRAILLE_CHAR_C },
|
||||
{ 'd', BRAILLE_CHAR_D },
|
||||
{ 'e', BRAILLE_CHAR_E },
|
||||
{ 'f', BRAILLE_CHAR_F },
|
||||
{ 'g', BRAILLE_CHAR_G },
|
||||
{ 'h', BRAILLE_CHAR_H },
|
||||
{ 'i', BRAILLE_CHAR_I },
|
||||
{ 'j', BRAILLE_CHAR_J },
|
||||
{ 'k', BRAILLE_CHAR_K },
|
||||
{ 'l', BRAILLE_CHAR_L },
|
||||
{ 'm', BRAILLE_CHAR_M },
|
||||
{ 'n', BRAILLE_CHAR_N },
|
||||
{ 'o', BRAILLE_CHAR_O },
|
||||
{ 'p', BRAILLE_CHAR_P },
|
||||
{ 'q', BRAILLE_CHAR_Q },
|
||||
{ 'r', BRAILLE_CHAR_R },
|
||||
{ 's', BRAILLE_CHAR_S },
|
||||
{ 't', BRAILLE_CHAR_T },
|
||||
{ 'u', BRAILLE_CHAR_U },
|
||||
{ 'v', BRAILLE_CHAR_V },
|
||||
{ 'w', BRAILLE_CHAR_W },
|
||||
{ 'x', BRAILLE_CHAR_X },
|
||||
{ 'y', BRAILLE_CHAR_Y },
|
||||
{ 'z', BRAILLE_CHAR_Z },
|
||||
{ '0', BRAILLE_CHAR_0 },
|
||||
{ '1', BRAILLE_CHAR_1 },
|
||||
{ '2', BRAILLE_CHAR_2 },
|
||||
{ '3', BRAILLE_CHAR_3 },
|
||||
{ '4', BRAILLE_CHAR_4 },
|
||||
{ '5', BRAILLE_CHAR_5 },
|
||||
{ '6', BRAILLE_CHAR_6 },
|
||||
{ '7', BRAILLE_CHAR_7 },
|
||||
{ '8', BRAILLE_CHAR_8 },
|
||||
{ '9', BRAILLE_CHAR_9 },
|
||||
{ ' ', BRAILLE_CHAR_SPACE },
|
||||
{ ',', BRAILLE_CHAR_COMMA },
|
||||
{ '.', BRAILLE_CHAR_PERIOD },
|
||||
{ '?', BRAILLE_CHAR_QUESTION_MARK },
|
||||
{ '!', BRAILLE_CHAR_EXCL_MARK },
|
||||
{ ':', BRAILLE_CHAR_COLON },
|
||||
{ ';', BRAILLE_CHAR_SEMICOLON },
|
||||
{ '-', BRAILLE_CHAR_HYPHEN },
|
||||
{ '/', BRAILLE_CHAR_SLASH },
|
||||
{ '(', BRAILLE_CHAR_PAREN },
|
||||
{ ')', BRAILLE_CHAR_PAREN },
|
||||
{ '\'', BRAILLE_CHAR_APOSTROPHE },
|
||||
{ '#', BRAILLE_CHAR_NUMBER },
|
||||
{ '$', EOS },
|
||||
};
|
||||
|
||||
SkipWhitespace();
|
||||
|
|
@ -337,14 +372,13 @@ int AsmFile::ReadBraille(unsigned char* s)
|
|||
|
||||
m_pos++;
|
||||
|
||||
bool inNumber = false;
|
||||
while (m_buffer[m_pos] != '"')
|
||||
{
|
||||
if (length == kMaxStringLength)
|
||||
RaiseError("mapped string longer than %d bytes", kMaxStringLength);
|
||||
|
||||
if (m_buffer[m_pos] == '\\' && m_buffer[m_pos + 1] == 'n')
|
||||
{
|
||||
s[length++] = 0xFE;
|
||||
VerifyStringLength(length);
|
||||
s[length++] = CHAR_NEWLINE;
|
||||
m_pos += 2;
|
||||
}
|
||||
else
|
||||
|
|
@ -359,6 +393,21 @@ int AsmFile::ReadBraille(unsigned char* s)
|
|||
RaiseError("character '\\x%02X' not valid in braille string", m_buffer[m_pos]);
|
||||
}
|
||||
|
||||
if (!inNumber && c >= '0' && c <= '9' )
|
||||
{
|
||||
// Output number indicator at start of a number
|
||||
inNumber = true;
|
||||
VerifyStringLength(length);
|
||||
s[length++] = BRAILLE_CHAR_NUMBER;
|
||||
}
|
||||
else if (inNumber && encoding[c] == BRAILLE_CHAR_SPACE)
|
||||
{
|
||||
// Number ends at a space.
|
||||
// Non-number characters encountered before a space will simply be output as is.
|
||||
inNumber = false;
|
||||
}
|
||||
|
||||
VerifyStringLength(length);
|
||||
s[length++] = encoding[c];
|
||||
m_pos++;
|
||||
}
|
||||
|
|
@ -460,6 +509,88 @@ void AsmFile::OutputLine()
|
|||
}
|
||||
}
|
||||
|
||||
// parses an assumed C `enum`. Returns false if `enum { ...` is not matched
|
||||
bool AsmFile::ParseEnum()
|
||||
{
|
||||
if (!m_doEnum)
|
||||
return false;
|
||||
|
||||
long fallbackPosition = m_pos;
|
||||
std::string headerFilename = "";
|
||||
long currentHeaderLine = SkipWhitespaceAndEol();
|
||||
std::string enumName = ReadIdentifier();
|
||||
currentHeaderLine += SkipWhitespaceAndEol();
|
||||
std::string enumBase = "0";
|
||||
long enumCounter = 0;
|
||||
long symbolCount = 0;
|
||||
|
||||
if (m_buffer[m_pos] != '{') // assume assembly macro, otherwise assume enum and report errors accordingly
|
||||
{
|
||||
m_pos = fallbackPosition - 4;
|
||||
return false;
|
||||
}
|
||||
|
||||
currentHeaderLine += FindLastLineNumber(headerFilename);
|
||||
m_pos++;
|
||||
for (;;)
|
||||
{
|
||||
currentHeaderLine += SkipWhitespaceAndEol();
|
||||
std::string currentIdentName = ReadIdentifier();
|
||||
if (!currentIdentName.empty())
|
||||
{
|
||||
std::printf("# %ld \"%s\"\n", currentHeaderLine, headerFilename.c_str());
|
||||
currentHeaderLine += SkipWhitespaceAndEol();
|
||||
if (m_buffer[m_pos] == '=')
|
||||
{
|
||||
m_pos++;
|
||||
SkipWhitespace();
|
||||
enumBase.clear();
|
||||
for (;;)
|
||||
{
|
||||
if (m_pos == m_size)
|
||||
RaiseError("unexpected EOF");
|
||||
if (m_buffer[m_pos] == ',')
|
||||
break;
|
||||
if (m_buffer[m_pos] == '\n')
|
||||
{
|
||||
currentHeaderLine++;
|
||||
enumBase.push_back(' ');
|
||||
}
|
||||
else
|
||||
{
|
||||
enumBase.push_back(m_buffer[m_pos]);
|
||||
}
|
||||
m_pos++;
|
||||
}
|
||||
enumCounter = 0;
|
||||
}
|
||||
std::printf(".equiv %s, (%s) + %ld\n", currentIdentName.c_str(), enumBase.c_str(), enumCounter);
|
||||
enumCounter++;
|
||||
symbolCount++;
|
||||
}
|
||||
else if (symbolCount == 0)
|
||||
{
|
||||
RaiseError("%s:%ld: empty enum is invalid", headerFilename.c_str(), currentHeaderLine);
|
||||
}
|
||||
|
||||
if (m_buffer[m_pos] != ',')
|
||||
{
|
||||
currentHeaderLine += SkipWhitespaceAndEol();
|
||||
if (m_buffer[m_pos++] == '}' && m_buffer[m_pos++] == ';')
|
||||
{
|
||||
ExpectEmptyRestOfLine();
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
RaiseError("unterminated enum from included file %s:%ld", headerFilename.c_str(), currentHeaderLine);
|
||||
}
|
||||
}
|
||||
m_pos++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Asserts that the rest of the line is empty and moves to the next one.
|
||||
void AsmFile::ExpectEmptyRestOfLine()
|
||||
{
|
||||
|
|
@ -532,3 +663,130 @@ void AsmFile::RaiseWarning(const char* format, ...)
|
|||
{
|
||||
DO_REPORT("warning");
|
||||
}
|
||||
|
||||
// Skips Whitespace including newlines and returns the amount of newlines skipped
|
||||
int AsmFile::SkipWhitespaceAndEol()
|
||||
{
|
||||
int newlines = 0;
|
||||
while (m_buffer[m_pos] == '\t' || m_buffer[m_pos] == ' ' || m_buffer[m_pos] == '\n')
|
||||
{
|
||||
if (m_buffer[m_pos] == '\n')
|
||||
newlines++;
|
||||
m_pos++;
|
||||
}
|
||||
return newlines;
|
||||
}
|
||||
|
||||
// returns the last line indicator and its corresponding file name without modifying the token index
|
||||
int AsmFile::FindLastLineNumber(std::string& filename)
|
||||
{
|
||||
long pos = m_pos;
|
||||
long linebreaks = 0;
|
||||
while (m_buffer[pos] != '#' && pos >= 0)
|
||||
{
|
||||
if (m_buffer[pos] == '\n')
|
||||
linebreaks++;
|
||||
pos--;
|
||||
}
|
||||
|
||||
if (pos < 0)
|
||||
RaiseError("line indicator for header file not found before `enum`");
|
||||
|
||||
pos++;
|
||||
while (m_buffer[pos] == ' ' || m_buffer[pos] == '\t')
|
||||
pos++;
|
||||
|
||||
if (!IsAsciiDigit(m_buffer[pos]))
|
||||
RaiseError("malformatted line indicator found before `enum`, expected line number");
|
||||
|
||||
unsigned n = 0;
|
||||
int digit = 0;
|
||||
while ((digit = ConvertDigit(m_buffer[pos++], 10)) != -1)
|
||||
n = 10 * n + digit;
|
||||
|
||||
while (m_buffer[pos] == ' ' || m_buffer[pos] == '\t')
|
||||
pos++;
|
||||
|
||||
if (m_buffer[pos++] != '"')
|
||||
RaiseError("malformatted line indicator found before `enum`, expected filename");
|
||||
|
||||
while (m_buffer[pos] != '"')
|
||||
{
|
||||
unsigned char c = m_buffer[pos++];
|
||||
|
||||
if (c == 0)
|
||||
{
|
||||
if (pos >= m_size)
|
||||
RaiseError("unexpected EOF in line indicator");
|
||||
else
|
||||
RaiseError("unexpected null character in line indicator");
|
||||
}
|
||||
|
||||
if (!IsAsciiPrintable(c))
|
||||
RaiseError("unexpected character '\\x%02X' in line indicator", c);
|
||||
|
||||
if (c == '\\')
|
||||
{
|
||||
c = m_buffer[pos];
|
||||
RaiseError("unexpected escape '\\%c' in line indicator", c);
|
||||
}
|
||||
|
||||
filename += c;
|
||||
}
|
||||
|
||||
return n + linebreaks - 1;
|
||||
}
|
||||
|
||||
std::string AsmFile::ReadIdentifier()
|
||||
{
|
||||
long start = m_pos;
|
||||
if (!IsIdentifierStartingChar(m_buffer[m_pos]))
|
||||
return std::string();
|
||||
|
||||
m_pos++;
|
||||
|
||||
while (IsIdentifierChar(m_buffer[m_pos]))
|
||||
m_pos++;
|
||||
|
||||
return std::string(&m_buffer[start], m_pos - start);
|
||||
}
|
||||
|
||||
long AsmFile::ReadInteger(std::string filename, long line)
|
||||
{
|
||||
bool negate = false;
|
||||
int radix = 10;
|
||||
if (!IsAsciiDigit(m_buffer[m_pos]))
|
||||
{
|
||||
if (m_buffer[m_pos++] == '-')
|
||||
negate = true;
|
||||
else
|
||||
RaiseError("expected number in included file %s:%ld", filename.c_str(), line);
|
||||
}
|
||||
|
||||
if (m_buffer[m_pos] == '0' && m_buffer[m_pos + 1] == 'x')
|
||||
{
|
||||
radix = 16;
|
||||
m_pos += 2;
|
||||
}
|
||||
else if (m_buffer[m_pos] == '0' && m_buffer[m_pos + 1] == 'b')
|
||||
{
|
||||
radix = 2;
|
||||
m_pos += 2;
|
||||
}
|
||||
else if (m_buffer[m_pos] == '0' && IsAsciiDigit(m_buffer[m_pos+1]))
|
||||
{
|
||||
radix = 8;
|
||||
m_pos++;
|
||||
}
|
||||
|
||||
long n = 0;
|
||||
int digit;
|
||||
|
||||
while ((digit = ConvertDigit(m_buffer[m_pos], radix)) != -1)
|
||||
{
|
||||
n = n * radix + digit;
|
||||
m_pos++;
|
||||
}
|
||||
|
||||
return negate ? -n : n;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,13 +31,14 @@ enum class Directive
|
|||
Include,
|
||||
String,
|
||||
Braille,
|
||||
Enum,
|
||||
Unknown
|
||||
};
|
||||
|
||||
class AsmFile
|
||||
{
|
||||
public:
|
||||
AsmFile(std::string filename);
|
||||
AsmFile(std::string filename, bool isStdin, bool doEnum);
|
||||
AsmFile(AsmFile&& other);
|
||||
AsmFile(const AsmFile&) = delete;
|
||||
~AsmFile();
|
||||
|
|
@ -49,9 +50,11 @@ public:
|
|||
bool IsAtEnd();
|
||||
void OutputLine();
|
||||
void OutputLocation();
|
||||
bool ParseEnum();
|
||||
|
||||
private:
|
||||
char* m_buffer;
|
||||
bool m_doEnum;
|
||||
long m_pos;
|
||||
long m_size;
|
||||
long m_lineNum;
|
||||
|
|
@ -67,6 +70,11 @@ private:
|
|||
void ReportDiagnostic(const char* type, const char* format, std::va_list args);
|
||||
void RaiseError(const char* format, ...);
|
||||
void RaiseWarning(const char* format, ...);
|
||||
void VerifyStringLength(int length);
|
||||
int SkipWhitespaceAndEol();
|
||||
int FindLastLineNumber(std::string& filename);
|
||||
std::string ReadIdentifier();
|
||||
long ReadInteger(std::string filename, long line);
|
||||
};
|
||||
|
||||
#endif // ASM_FILE_H
|
||||
|
|
|
|||
|
|
@ -23,55 +23,27 @@
|
|||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <cstring>
|
||||
#include <cerrno>
|
||||
#include "preproc.h"
|
||||
#include "c_file.h"
|
||||
#include "char_util.h"
|
||||
#include "utf8.h"
|
||||
#include "string_parser.h"
|
||||
#include "io.h"
|
||||
|
||||
CFile::CFile(std::string filename) : m_filename(filename)
|
||||
CFile::CFile(const char * filenameCStr, bool isStdin)
|
||||
{
|
||||
if (filename == "-") {
|
||||
std::string s, b;
|
||||
if (isStdin)
|
||||
m_filename = std::string{"<stdin>/"}.append(filenameCStr);
|
||||
else
|
||||
m_filename = std::string(filenameCStr);
|
||||
|
||||
while (!std::cin.eof()) {
|
||||
std::getline(std::cin, b);
|
||||
s += b + "\n";
|
||||
}
|
||||
m_size = s.size();
|
||||
m_buffer = new char[m_size + 1];
|
||||
memcpy(m_buffer, s.c_str(), m_size);
|
||||
m_buffer[m_size] = 0;
|
||||
} else {
|
||||
FILE *fp = std::fopen(filename.c_str(), "rb");
|
||||
|
||||
if (fp == NULL)
|
||||
FATAL_ERROR("Failed to open \"%s\" for reading.\n", filename.c_str());
|
||||
|
||||
std::fseek(fp, 0, SEEK_END);
|
||||
|
||||
m_size = std::ftell(fp);
|
||||
|
||||
if (m_size < 0)
|
||||
FATAL_ERROR("File size of \"%s\" is less than zero.\n", filename.c_str());
|
||||
|
||||
m_buffer = new char[m_size + 1];
|
||||
|
||||
std::rewind(fp);
|
||||
|
||||
if (std::fread(m_buffer, m_size, 1, fp) != 1)
|
||||
FATAL_ERROR("Failed to read \"%s\".\n", filename.c_str());
|
||||
|
||||
m_buffer[m_size] = 0;
|
||||
|
||||
std::fclose(fp);
|
||||
}
|
||||
m_buffer = ReadFileToBuffer(filenameCStr, isStdin, &m_size);
|
||||
|
||||
m_pos = 0;
|
||||
m_lineNum = 1;
|
||||
m_isStdin = isStdin;
|
||||
}
|
||||
|
||||
CFile::CFile(CFile&& other) : m_filename(std::move(other.m_filename))
|
||||
|
|
@ -80,13 +52,14 @@ CFile::CFile(CFile&& other) : m_filename(std::move(other.m_filename))
|
|||
m_pos = other.m_pos;
|
||||
m_size = other.m_size;
|
||||
m_lineNum = other.m_lineNum;
|
||||
m_isStdin = other.m_isStdin;
|
||||
|
||||
other.m_buffer = nullptr;
|
||||
other.m_buffer = NULL;
|
||||
}
|
||||
|
||||
CFile::~CFile()
|
||||
{
|
||||
delete[] m_buffer;
|
||||
free(m_buffer);
|
||||
}
|
||||
|
||||
void CFile::Preproc()
|
||||
|
|
@ -370,7 +343,7 @@ void CFile::TryConvertIncbin()
|
|||
|
||||
if (m_buffer[m_pos] == '\\')
|
||||
RaiseError("unexpected escape in path string");
|
||||
|
||||
|
||||
m_pos++;
|
||||
}
|
||||
|
||||
|
|
@ -405,7 +378,7 @@ void CFile::TryConvertIncbin()
|
|||
|
||||
m_pos++;
|
||||
}
|
||||
|
||||
|
||||
if (m_buffer[m_pos] != ')')
|
||||
RaiseError("expected ')'");
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
class CFile
|
||||
{
|
||||
public:
|
||||
CFile(std::string filename);
|
||||
CFile(const char * filenameCStr, bool isStdin);
|
||||
CFile(CFile&& other);
|
||||
CFile(const CFile&) = delete;
|
||||
~CFile();
|
||||
|
|
@ -42,6 +42,7 @@ private:
|
|||
long m_size;
|
||||
long m_lineNum;
|
||||
std::string m_filename;
|
||||
bool m_isStdin;
|
||||
|
||||
bool ConsumeHorizontalWhitespace();
|
||||
bool ConsumeNewline();
|
||||
|
|
|
|||
51
tools/preproc/io.cpp
Normal file
51
tools/preproc/io.cpp
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
#include "preproc.h"
|
||||
#include "io.h"
|
||||
#include <string>
|
||||
#include <cerrno>
|
||||
#include <cstring>
|
||||
|
||||
char *ReadFileToBuffer(const char *filename, bool isStdin, long *size)
|
||||
{
|
||||
FILE *fp;
|
||||
if (isStdin)
|
||||
fp = stdin;
|
||||
else
|
||||
fp = std::fopen(filename, "rb");
|
||||
|
||||
if (fp == NULL)
|
||||
FATAL_ERROR("Failed to open \"%s\" for reading.\n", filename);
|
||||
|
||||
*size = 0;
|
||||
char *buffer = (char *)malloc(CHUNK_SIZE + 1);
|
||||
if (buffer == NULL) {
|
||||
FATAL_ERROR("Failed to allocate memory to process file \"%s\"!", filename);
|
||||
}
|
||||
|
||||
std::size_t numAllocatedBytes = CHUNK_SIZE + 1;
|
||||
std::size_t bufferOffset = 0;
|
||||
std::size_t count;
|
||||
|
||||
while ((count = std::fread(buffer + bufferOffset, 1, CHUNK_SIZE, fp)) != 0) {
|
||||
if (!std::ferror(fp)) {
|
||||
*size += count;
|
||||
|
||||
if (std::feof(fp)) {
|
||||
break;
|
||||
}
|
||||
|
||||
numAllocatedBytes += CHUNK_SIZE;
|
||||
bufferOffset += CHUNK_SIZE;
|
||||
buffer = (char *)realloc(buffer, numAllocatedBytes);
|
||||
if (buffer == NULL) {
|
||||
FATAL_ERROR("Failed to allocate memory to process file \"%s\"!", filename);
|
||||
}
|
||||
} else {
|
||||
FATAL_ERROR("Failed to read \"%s\". (error: %s)", filename, std::strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
buffer[*size] = 0;
|
||||
|
||||
std::fclose(fp);
|
||||
return buffer;
|
||||
}
|
||||
8
tools/preproc/io.h
Normal file
8
tools/preproc/io.h
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef IO_H_
|
||||
#define IO_H_
|
||||
|
||||
#define CHUNK_SIZE 4096
|
||||
|
||||
char *ReadFileToBuffer(const char *filename, bool isStdin, long *size);
|
||||
|
||||
#endif // IO_H_
|
||||
|
|
@ -20,11 +20,14 @@
|
|||
|
||||
#include <string>
|
||||
#include <stack>
|
||||
#include <unistd.h>
|
||||
#include "preproc.h"
|
||||
#include "asm_file.h"
|
||||
#include "c_file.h"
|
||||
#include "charmap.h"
|
||||
|
||||
static void UsageAndExit(const char *program);
|
||||
|
||||
Charmap* g_charmap;
|
||||
|
||||
void PrintAsmBytes(unsigned char *s, int length)
|
||||
|
|
@ -43,11 +46,12 @@ void PrintAsmBytes(unsigned char *s, int length)
|
|||
}
|
||||
}
|
||||
|
||||
void PreprocAsmFile(std::string filename)
|
||||
void PreprocAsmFile(std::string filename, bool isStdin, bool doEnum)
|
||||
{
|
||||
std::stack<AsmFile> stack;
|
||||
|
||||
stack.push(AsmFile(filename));
|
||||
stack.push(AsmFile(filename, isStdin, doEnum));
|
||||
std::printf("# 1 \"%s\"\n", filename.c_str());
|
||||
|
||||
for (;;)
|
||||
{
|
||||
|
|
@ -66,7 +70,7 @@ void PreprocAsmFile(std::string filename)
|
|||
switch (directive)
|
||||
{
|
||||
case Directive::Include:
|
||||
stack.push(AsmFile(stack.top().ReadPath()));
|
||||
stack.push(AsmFile(stack.top().ReadPath(), false, doEnum));
|
||||
stack.top().OutputLocation();
|
||||
break;
|
||||
case Directive::String:
|
||||
|
|
@ -83,6 +87,12 @@ void PreprocAsmFile(std::string filename)
|
|||
PrintAsmBytes(s, length);
|
||||
break;
|
||||
}
|
||||
case Directive::Enum:
|
||||
{
|
||||
if (!stack.top().ParseEnum())
|
||||
stack.top().OutputLine();
|
||||
break;
|
||||
}
|
||||
case Directive::Unknown:
|
||||
{
|
||||
std::string globalLabel = stack.top().GetGlobalLabel();
|
||||
|
|
@ -103,15 +113,15 @@ void PreprocAsmFile(std::string filename)
|
|||
}
|
||||
}
|
||||
|
||||
void PreprocCFile(std::string filename)
|
||||
void PreprocCFile(const char * filename, bool isStdin)
|
||||
{
|
||||
CFile cFile(filename);
|
||||
CFile cFile(filename, isStdin);
|
||||
cFile.Preproc();
|
||||
}
|
||||
|
||||
char* GetFileExtension(char* filename)
|
||||
const char* GetFileExtension(const char* filename)
|
||||
{
|
||||
char* extension = filename;
|
||||
const char* extension = filename;
|
||||
|
||||
while (*extension != 0)
|
||||
extension++;
|
||||
|
|
@ -130,32 +140,64 @@ char* GetFileExtension(char* filename)
|
|||
return extension;
|
||||
}
|
||||
|
||||
static void UsageAndExit(const char *program)
|
||||
{
|
||||
std::fprintf(stderr, "Usage: %s [-i] [-e] SRC_FILE CHARMAP_FILE\nwhere -i denotes if input is from stdin\n -e enables enum handling\n", program);
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc != 3)
|
||||
int opt;
|
||||
const char *source = NULL;
|
||||
const char *charmap = NULL;
|
||||
bool isStdin = false;
|
||||
bool doEnum = false;
|
||||
|
||||
/* preproc [-i] [-e] SRC_FILE CHARMAP_FILE */
|
||||
while ((opt = getopt(argc, argv, "ie")) != -1)
|
||||
{
|
||||
std::fprintf(stderr, "Usage: %s SRC_FILE CHARMAP_FILE", argv[0]);
|
||||
return 1;
|
||||
switch (opt)
|
||||
{
|
||||
case 'i':
|
||||
isStdin = true;
|
||||
break;
|
||||
case 'e':
|
||||
doEnum = true;
|
||||
break;
|
||||
default:
|
||||
UsageAndExit(argv[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
g_charmap = new Charmap(argv[2]);
|
||||
if (optind + 2 != argc)
|
||||
UsageAndExit(argv[0]);
|
||||
|
||||
if (argv[1][0] == '-' && argv[1][1] == 0) {
|
||||
PreprocCFile("-");
|
||||
} else {
|
||||
char* extension = GetFileExtension(argv[1]);
|
||||
source = argv[optind + 0];
|
||||
charmap = argv[optind + 1];
|
||||
|
||||
if (!extension)
|
||||
FATAL_ERROR("\"%s\" has no file extension.\n", argv[1]);
|
||||
g_charmap = new Charmap(charmap);
|
||||
|
||||
if ((extension[0] == 's') && extension[1] == 0)
|
||||
PreprocAsmFile(argv[1]);
|
||||
else if ((extension[0] == 'c' || extension[0] == 'i') && extension[1] == 0)
|
||||
PreprocCFile(argv[1]);
|
||||
else
|
||||
FATAL_ERROR("\"%s\" has an unknown file extension of \"%s\".\n", argv[1], extension);
|
||||
const char* extension = GetFileExtension(source);
|
||||
|
||||
if (!extension)
|
||||
FATAL_ERROR("\"%s\" has no file extension.\n", argv[1]);
|
||||
|
||||
if ((extension[0] == 's') && extension[1] == 0)
|
||||
{
|
||||
PreprocAsmFile(source, isStdin, doEnum);
|
||||
}
|
||||
else if ((extension[0] == 'c' || extension[0] == 'i') && extension[1] == 0)
|
||||
{
|
||||
if (doEnum)
|
||||
FATAL_ERROR("-e is invalid for C sources\n");
|
||||
PreprocCFile(source, isStdin);
|
||||
}
|
||||
else
|
||||
{
|
||||
FATAL_ERROR("\"%s\" has an unknown file extension of \"%s\".\n", argv[1], extension);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
CXX := g++
|
||||
CXX ?= g++
|
||||
|
||||
CXXFLAGS := -std=c++11 -O2 -s -Wall -Wno-switch -Werror
|
||||
CXXFLAGS := -std=c++11 -O2 -Wall -Wno-switch -Werror
|
||||
|
||||
SRCS := main.cpp sym_file.cpp elf.cpp
|
||||
|
||||
|
|
@ -8,10 +8,16 @@ HEADERS := ramscrgen.h sym_file.h elf.h char_util.h
|
|||
|
||||
.PHONY: all clean
|
||||
|
||||
all: ramscrgen
|
||||
ifeq ($(OS),Windows_NT)
|
||||
EXE := .exe
|
||||
else
|
||||
EXE :=
|
||||
endif
|
||||
|
||||
all: ramscrgen$(EXE)
|
||||
@:
|
||||
|
||||
ramscrgen: $(SRCS) $(HEADERS)
|
||||
ramscrgen$(EXE): $(SRCS) $(HEADERS)
|
||||
$(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS)
|
||||
|
||||
clean:
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
#define SHN_COMMON 0xFFF2
|
||||
|
||||
static std::string s_elfPath;
|
||||
static std::string s_archiveFilePath;
|
||||
static std::string s_archiveObjectPath;
|
||||
|
||||
static FILE *s_file;
|
||||
|
||||
|
|
@ -22,6 +24,7 @@ static std::uint32_t s_symtabOffset;
|
|||
static std::uint32_t s_strtabOffset;
|
||||
|
||||
static std::uint32_t s_symbolCount;
|
||||
static std::uint32_t s_elfFileOffset;
|
||||
|
||||
struct Symbol
|
||||
{
|
||||
|
|
@ -31,7 +34,7 @@ struct Symbol
|
|||
|
||||
static void Seek(long offset)
|
||||
{
|
||||
if (std::fseek(s_file, offset, SEEK_SET) != 0)
|
||||
if (std::fseek(s_file, s_elfFileOffset + offset, SEEK_SET) != 0)
|
||||
FATAL_ERROR("error: failed to seek to %ld in \"%s\"", offset, s_elfPath.c_str());
|
||||
}
|
||||
|
||||
|
|
@ -98,6 +101,18 @@ static void VerifyElfIdent()
|
|||
FATAL_ERROR("error: \"%s\" not little-endian ELF\n", s_elfPath.c_str());
|
||||
}
|
||||
|
||||
static void VerifyAr()
|
||||
{
|
||||
char expectedMagic[8] = {'!', '<', 'a', 'r', 'c', 'h', '>', '\n'};
|
||||
char magic[8];
|
||||
|
||||
if (std::fread(magic, 8, 1, s_file) != 1)
|
||||
FATAL_ERROR("error: failed to read AR magic from \"%s\"\n", s_archiveFilePath.c_str());
|
||||
|
||||
if (std::memcmp(magic, expectedMagic, 8) != 0)
|
||||
FATAL_ERROR("error: AR magic did not match in \"%s\"\n", s_archiveFilePath.c_str());
|
||||
}
|
||||
|
||||
static void ReadElfHeader()
|
||||
{
|
||||
Seek(0x20);
|
||||
|
|
@ -108,6 +123,40 @@ static void ReadElfHeader()
|
|||
s_shstrtabIndex = ReadInt16();
|
||||
}
|
||||
|
||||
static void FindArObj()
|
||||
{
|
||||
char file_ident[17] = {0};
|
||||
char filesize_s[11] = {0};
|
||||
char expectedEndMagic[2] = { 0x60, 0x0a };
|
||||
char end_magic[2];
|
||||
std::size_t filesize;
|
||||
|
||||
Seek(8);
|
||||
while (!std::feof(s_file)) {
|
||||
if (std::fread(file_ident, 16, 1, s_file) != 1)
|
||||
FATAL_ERROR("error: failed to read file ident in \"%s\"\n", s_archiveFilePath.c_str());
|
||||
Skip(32);
|
||||
if (std::fread(filesize_s, 10, 1, s_file) != 1)
|
||||
FATAL_ERROR("error: failed to read filesize in \"%s\"\n", s_archiveFilePath.c_str());
|
||||
if (std::fread(end_magic, 2, 1, s_file) != 1)
|
||||
FATAL_ERROR("error: failed to read end sentinel in \"%s\"\n", s_archiveFilePath.c_str());
|
||||
if (std::memcmp(end_magic, expectedEndMagic, 2) != 0)
|
||||
FATAL_ERROR("error: corrupted archive header in \"%s\" at \"%s\"\n", s_archiveFilePath.c_str(), file_ident);
|
||||
|
||||
char * ptr = std::strchr(file_ident, '/');
|
||||
if (ptr != nullptr)
|
||||
*ptr = 0;
|
||||
filesize = std::strtoul(filesize_s, nullptr, 10);
|
||||
if (std::strncmp(s_archiveObjectPath.c_str(), file_ident, 16) == 0) {
|
||||
s_elfFileOffset = std::ftell(s_file);
|
||||
return;
|
||||
}
|
||||
Skip(filesize);
|
||||
}
|
||||
|
||||
FATAL_ERROR("error: could not find object \"%s\" in archive \"%s\"\n", s_archiveObjectPath.c_str(), s_archiveFilePath.c_str());
|
||||
}
|
||||
|
||||
static std::string GetSectionName(std::uint32_t shstrtabOffset, int index)
|
||||
{
|
||||
Seek(s_sectionHeaderOffset + s_sectionHeaderEntrySize * index);
|
||||
|
|
@ -153,21 +202,14 @@ static void FindTableOffsets()
|
|||
FATAL_ERROR("error: couldn't find .strtab section in \"%s\"\n", s_elfPath.c_str());
|
||||
}
|
||||
|
||||
std::map<std::string, std::uint32_t> GetCommonSymbols(std::string path)
|
||||
static std::map<std::string, std::uint32_t> GetCommonSymbols_Shared()
|
||||
{
|
||||
s_elfPath = path;
|
||||
|
||||
std::map<std::string, std::uint32_t> commonSymbols;
|
||||
|
||||
s_file = std::fopen(s_elfPath.c_str(), "rb");
|
||||
|
||||
if (s_file == NULL)
|
||||
FATAL_ERROR("error: failed to open \"%s\" for reading\n", path.c_str());
|
||||
|
||||
VerifyElfIdent();
|
||||
ReadElfHeader();
|
||||
FindTableOffsets();
|
||||
|
||||
|
||||
std::map<std::string, std::uint32_t> commonSymbols;
|
||||
|
||||
std::vector<Symbol> commonSymbolVec;
|
||||
|
||||
Seek(s_symtabOffset);
|
||||
|
|
@ -193,3 +235,38 @@ std::map<std::string, std::uint32_t> GetCommonSymbols(std::string path)
|
|||
|
||||
return commonSymbols;
|
||||
}
|
||||
|
||||
std::map<std::string, std::uint32_t> GetCommonSymbolsFromLib(std::string sourcePath, std::string libpath)
|
||||
{
|
||||
std::size_t colonPos = libpath.find(':');
|
||||
if (colonPos == std::string::npos)
|
||||
FATAL_ERROR("error: missing colon separator in libfile \"%s\"\n", s_elfPath.c_str());
|
||||
|
||||
s_archiveObjectPath = libpath.substr(colonPos + 1);
|
||||
s_archiveFilePath = sourcePath + "/" + libpath.substr(1, colonPos - 1);
|
||||
s_elfPath = sourcePath + "/" + libpath.substr(1);
|
||||
|
||||
s_file = std::fopen(s_archiveFilePath.c_str(), "rb");
|
||||
|
||||
if (s_file == NULL)
|
||||
FATAL_ERROR("error: failed to open \"%s\" for reading\n", s_archiveFilePath.c_str());
|
||||
|
||||
VerifyAr();
|
||||
FindArObj();
|
||||
return GetCommonSymbols_Shared();
|
||||
}
|
||||
|
||||
std::map<std::string, std::uint32_t> GetCommonSymbols(std::string sourcePath, std::string path)
|
||||
{
|
||||
s_elfFileOffset = 0;
|
||||
if (path[0] == '*')
|
||||
return GetCommonSymbolsFromLib(sourcePath, path);
|
||||
|
||||
s_elfPath = sourcePath + "/" + path;
|
||||
s_file = std::fopen(s_elfPath.c_str(), "rb");
|
||||
|
||||
if (s_file == NULL)
|
||||
FATAL_ERROR("error: failed to open \"%s\" for reading\n", path.c_str());
|
||||
|
||||
return GetCommonSymbols_Shared();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,6 @@
|
|||
#include <map>
|
||||
#include <string>
|
||||
|
||||
std::map<std::string, std::uint32_t> GetCommonSymbols(std::string path);
|
||||
std::map<std::string, std::uint32_t> GetCommonSymbols(std::string sourcePath, std::string path);
|
||||
|
||||
#endif // ELF_H
|
||||
|
|
|
|||
|
|
@ -27,9 +27,15 @@
|
|||
|
||||
void HandleCommonInclude(std::string filename, std::string sourcePath, std::string symOrderPath, std::string lang)
|
||||
{
|
||||
auto commonSymbols = GetCommonSymbols(sourcePath + "/" + filename);
|
||||
auto commonSymbols = GetCommonSymbols(sourcePath, filename);
|
||||
std::size_t dotIndex;
|
||||
|
||||
std::size_t dotIndex = filename.find_last_of('.');
|
||||
if (filename[0] == '*') {
|
||||
dotIndex = filename.find_last_of(':');
|
||||
filename = filename.substr(dotIndex + 1);
|
||||
}
|
||||
|
||||
dotIndex = filename.find_last_of('.');
|
||||
|
||||
if (dotIndex == std::string::npos)
|
||||
FATAL_ERROR("error: \"%s\" doesn't have a file extension\n", filename.c_str());
|
||||
|
|
@ -73,7 +79,7 @@ void HandleCommonInclude(std::string filename, std::string sourcePath, std::stri
|
|||
}
|
||||
}
|
||||
|
||||
void ConvertSymFile(std::string filename, std::string sectionName, std::string lang, bool common, std::string sourcePath, std::string commonSymPath)
|
||||
void ConvertSymFile(std::string filename, std::string sectionName, std::string lang, bool common, std::string sourcePath, std::string commonSymPath, std::string libSourcePath)
|
||||
{
|
||||
SymFile symFile(filename);
|
||||
|
||||
|
|
@ -91,7 +97,7 @@ void ConvertSymFile(std::string filename, std::string sectionName, std::string l
|
|||
symFile.ExpectEmptyRestOfLine();
|
||||
printf(". = ALIGN(4);\n");
|
||||
if (common)
|
||||
HandleCommonInclude(incFilename, sourcePath, commonSymPath, lang);
|
||||
HandleCommonInclude(incFilename, incFilename[0] == '*' ? libSourcePath : sourcePath, commonSymPath, lang);
|
||||
else
|
||||
printf("%s(%s);\n", incFilename.c_str(), sectionName.c_str());
|
||||
break;
|
||||
|
|
@ -148,6 +154,7 @@ int main(int argc, char **argv)
|
|||
std::string lang = std::string(argv[3]);
|
||||
std::string sourcePath;
|
||||
std::string commonSymPath;
|
||||
std::string libSourcePath;
|
||||
|
||||
if (argc > 4)
|
||||
{
|
||||
|
|
@ -166,8 +173,15 @@ int main(int argc, char **argv)
|
|||
|
||||
sourcePath = paths.substr(0, commaPos);
|
||||
commonSymPath = paths.substr(commaPos + 1);
|
||||
commaPos = commonSymPath.find(',');
|
||||
if (commaPos == std::string::npos) {
|
||||
libSourcePath = "tools/agbcc/lib";
|
||||
} else {
|
||||
libSourcePath = commonSymPath.substr(commaPos + 1);
|
||||
commonSymPath = commonSymPath.substr(0, commaPos);
|
||||
}
|
||||
}
|
||||
|
||||
ConvertSymFile(symFileName, sectionName, lang, common, sourcePath, commonSymPath);
|
||||
ConvertSymFile(symFileName, sectionName, lang, common, sourcePath, commonSymPath, libSourcePath);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
CC = gcc
|
||||
CC ?= gcc
|
||||
|
||||
CFLAGS = -Wall -Wextra -Werror -std=c11 -O2 -s -DPNG_SKIP_SETJMP_CHECK
|
||||
CFLAGS = -Wall -Wextra -Werror -std=c11 -O2 -DPNG_SKIP_SETJMP_CHECK
|
||||
CFLAGS += $(shell pkg-config --cflags libpng)
|
||||
|
||||
LIBS = -lpng -lz
|
||||
|
|
@ -10,10 +10,16 @@ SRCS = main.c convert_png.c util.c font.c
|
|||
|
||||
.PHONY: all clean
|
||||
|
||||
all: rsfont
|
||||
ifeq ($(OS),Windows_NT)
|
||||
EXE := .exe
|
||||
else
|
||||
EXE :=
|
||||
endif
|
||||
|
||||
all: rsfont$(EXE)
|
||||
@:
|
||||
|
||||
rsfont: $(SRCS) convert_png.h gfx.h global.h util.h font.h
|
||||
rsfont$(EXE): $(SRCS) convert_png.h gfx.h global.h util.h font.h
|
||||
$(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS)
|
||||
|
||||
clean:
|
||||
|
|
|
|||
|
|
@ -1,17 +1,23 @@
|
|||
CXX = g++
|
||||
CXX ?= g++
|
||||
|
||||
CXXFLAGS = -Wall -Werror -std=c++11 -O2
|
||||
|
||||
SRCS = scaninc.cpp c_file.cpp asm_file.cpp
|
||||
SRCS = scaninc.cpp c_file.cpp asm_file.cpp source_file.cpp
|
||||
|
||||
HEADERS := scaninc.h asm_file.h c_file.h
|
||||
HEADERS := scaninc.h asm_file.h c_file.h source_file.h
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all: scaninc
|
||||
ifeq ($(OS),Windows_NT)
|
||||
EXE := .exe
|
||||
else
|
||||
EXE :=
|
||||
endif
|
||||
|
||||
all: scaninc$(EXE)
|
||||
@:
|
||||
|
||||
scaninc: $(SRCS) $(HEADERS)
|
||||
scaninc$(EXE): $(SRCS) $(HEADERS)
|
||||
$(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS)
|
||||
|
||||
clean:
|
||||
|
|
|
|||
|
|
@ -69,7 +69,8 @@ IncDirectiveType AsmFile::ReadUntilIncDirective(std::string &path)
|
|||
|
||||
IncDirectiveType incDirectiveType = IncDirectiveType::None;
|
||||
|
||||
if (PeekChar() == '.')
|
||||
char c = PeekChar();
|
||||
if (c == '.' || c == '#')
|
||||
{
|
||||
m_pos++;
|
||||
|
||||
|
|
|
|||
|
|
@ -24,9 +24,11 @@
|
|||
#include <queue>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <tuple>
|
||||
#include <fstream>
|
||||
#include "scaninc.h"
|
||||
#include "asm_file.h"
|
||||
#include "c_file.h"
|
||||
#include "source_file.h"
|
||||
|
||||
bool CanOpenFile(std::string path)
|
||||
{
|
||||
|
|
@ -39,14 +41,18 @@ bool CanOpenFile(std::string path)
|
|||
return true;
|
||||
}
|
||||
|
||||
const char *const USAGE = "Usage: scaninc [-I INCLUDE_PATH] FILE_PATH\n";
|
||||
const char *const USAGE = "Usage: scaninc [-I INCLUDE_PATH] [-M DEPENDENCY_OUT_PATH] FILE_PATH\n";
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
std::queue<std::string> filesToProcess;
|
||||
std::set<std::string> dependencies;
|
||||
std::set<std::string> dependencies_includes;
|
||||
|
||||
std::list<std::string> includeDirs;
|
||||
std::vector<std::string> includeDirs;
|
||||
|
||||
bool makeformat = false;
|
||||
std::string make_outfile;
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
|
|
@ -63,12 +69,19 @@ int main(int argc, char **argv)
|
|||
argv++;
|
||||
includeDir = std::string(argv[0]);
|
||||
}
|
||||
if (includeDir.back() != '/')
|
||||
if (!includeDir.empty() && includeDir.back() != '/')
|
||||
{
|
||||
includeDir += '/';
|
||||
}
|
||||
includeDirs.push_back(includeDir);
|
||||
}
|
||||
else if(arg.substr(0, 2) == "-M")
|
||||
{
|
||||
makeformat = true;
|
||||
argc--;
|
||||
argv++;
|
||||
make_outfile = std::string(argv[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
FATAL_ERROR(USAGE);
|
||||
|
|
@ -83,83 +96,81 @@ int main(int argc, char **argv)
|
|||
|
||||
std::string initialPath(argv[0]);
|
||||
|
||||
std::size_t pos = initialPath.find_last_of('.');
|
||||
filesToProcess.push(initialPath);
|
||||
|
||||
if (pos == std::string::npos)
|
||||
FATAL_ERROR("no file extension in path \"%s\"\n", initialPath.c_str());
|
||||
|
||||
std::string extension = initialPath.substr(pos + 1);
|
||||
|
||||
std::string srcDir("");
|
||||
std::size_t slash = initialPath.rfind('/');
|
||||
if (slash != std::string::npos)
|
||||
while (!filesToProcess.empty())
|
||||
{
|
||||
srcDir = initialPath.substr(0, slash + 1);
|
||||
}
|
||||
includeDirs.push_back(srcDir);
|
||||
std::string filePath = filesToProcess.front();
|
||||
SourceFile file(filePath);
|
||||
filesToProcess.pop();
|
||||
|
||||
if (extension == "c" || extension == "h")
|
||||
{
|
||||
filesToProcess.push(initialPath);
|
||||
|
||||
while (!filesToProcess.empty())
|
||||
includeDirs.push_back(file.GetSrcDir());
|
||||
for (auto incbin : file.GetIncbins())
|
||||
{
|
||||
CFile file(filesToProcess.front());
|
||||
filesToProcess.pop();
|
||||
|
||||
file.FindIncbins();
|
||||
for (auto incbin : file.GetIncbins())
|
||||
dependencies.insert(incbin);
|
||||
}
|
||||
for (auto include : file.GetIncludes())
|
||||
{
|
||||
bool exists = false;
|
||||
std::string path("");
|
||||
for (auto includeDir : includeDirs)
|
||||
{
|
||||
dependencies.insert(incbin);
|
||||
}
|
||||
for (auto include : file.GetIncludes())
|
||||
{
|
||||
for (auto includeDir : includeDirs)
|
||||
path = includeDir + include;
|
||||
if (CanOpenFile(path))
|
||||
{
|
||||
std::string path(includeDir + include);
|
||||
if (CanOpenFile(path))
|
||||
{
|
||||
bool inserted = dependencies.insert(path).second;
|
||||
if (inserted)
|
||||
{
|
||||
filesToProcess.push(path);
|
||||
}
|
||||
break;
|
||||
}
|
||||
exists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (extension == "s" || extension == "inc")
|
||||
{
|
||||
filesToProcess.push(initialPath);
|
||||
|
||||
while (!filesToProcess.empty())
|
||||
{
|
||||
AsmFile file(filesToProcess.front());
|
||||
|
||||
filesToProcess.pop();
|
||||
|
||||
IncDirectiveType incDirectiveType;
|
||||
std::string path;
|
||||
|
||||
while ((incDirectiveType = file.ReadUntilIncDirective(path)) != IncDirectiveType::None)
|
||||
if (!exists && (file.FileType() == SourceFileType::Asm || file.FileType() == SourceFileType::Inc))
|
||||
{
|
||||
bool inserted = dependencies.insert(path).second;
|
||||
if (inserted
|
||||
&& incDirectiveType == IncDirectiveType::Include
|
||||
&& CanOpenFile(path))
|
||||
filesToProcess.push(path);
|
||||
path = include;
|
||||
if (CanOpenFile(path))
|
||||
exists = true;
|
||||
}
|
||||
if (!exists)
|
||||
continue;
|
||||
|
||||
dependencies_includes.insert(path);
|
||||
bool inserted = dependencies.insert(path).second;
|
||||
if (inserted && exists)
|
||||
{
|
||||
filesToProcess.push(path);
|
||||
}
|
||||
}
|
||||
includeDirs.pop_back();
|
||||
}
|
||||
|
||||
if(!makeformat)
|
||||
{
|
||||
for (const std::string &path : dependencies)
|
||||
{
|
||||
std::printf("%s\n", path.c_str());
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
FATAL_ERROR("unknown extension \"%s\"\n", extension.c_str());
|
||||
}
|
||||
// Write out make rules to a file
|
||||
std::ofstream output(make_outfile);
|
||||
|
||||
for (const std::string &path : dependencies)
|
||||
{
|
||||
std::printf("%s\n", path.c_str());
|
||||
// Print a make rule for the object file
|
||||
size_t ext_pos = make_outfile.find_last_of(".");
|
||||
auto object_file = make_outfile.substr(0, ext_pos + 1) + "o";
|
||||
output << object_file.c_str() << ": ";
|
||||
for (const std::string &path : dependencies)
|
||||
{
|
||||
output << path << " ";
|
||||
}
|
||||
|
||||
// Dependency list rule.
|
||||
// Although these rules are identical, they need to be separate, else make will trigger the rule again after the file is created for the first time.
|
||||
output << "\n" << make_outfile.c_str() << ": ";
|
||||
for (const std::string &path : dependencies_includes)
|
||||
{
|
||||
output << path << " ";
|
||||
}
|
||||
output.flush();
|
||||
output.close();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
130
tools/scaninc/source_file.cpp
Normal file
130
tools/scaninc/source_file.cpp
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
// Copyright(c) 2019 Phlosioneer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include <new>
|
||||
#include "source_file.h"
|
||||
|
||||
|
||||
SourceFileType GetFileType(std::string& path)
|
||||
{
|
||||
std::size_t pos = path.find_last_of('.');
|
||||
|
||||
if (pos == std::string::npos)
|
||||
FATAL_ERROR("no file extension in path \"%s\"\n", path.c_str());
|
||||
|
||||
std::string extension = path.substr(pos + 1);
|
||||
|
||||
if (extension == "c")
|
||||
return SourceFileType::Cpp;
|
||||
else if (extension == "s")
|
||||
return SourceFileType::Asm;
|
||||
else if (extension == "h")
|
||||
return SourceFileType::Header;
|
||||
else if (extension == "inc")
|
||||
return SourceFileType::Inc;
|
||||
else
|
||||
FATAL_ERROR("Unrecognized extension \"%s\"\n", extension.c_str());
|
||||
|
||||
// Unreachable
|
||||
return SourceFileType::Cpp;
|
||||
}
|
||||
|
||||
std::string GetDir(std::string& path)
|
||||
{
|
||||
std::size_t slash = path.rfind('/');
|
||||
|
||||
if (slash != std::string::npos)
|
||||
return path.substr(0, slash + 1);
|
||||
else
|
||||
return std::string("");
|
||||
}
|
||||
|
||||
SourceFile::SourceFile(std::string path)
|
||||
{
|
||||
m_file_type = GetFileType(path);
|
||||
|
||||
m_src_dir = GetDir(path);
|
||||
|
||||
if (m_file_type == SourceFileType::Cpp
|
||||
|| m_file_type == SourceFileType::Header)
|
||||
{
|
||||
new (&m_source_file.c_file) CFile(path);
|
||||
m_source_file.c_file.FindIncbins();
|
||||
}
|
||||
else
|
||||
{
|
||||
AsmFile file(path);
|
||||
std::set<std::string> incbins;
|
||||
std::set<std::string> includes;
|
||||
|
||||
IncDirectiveType incDirectiveType;
|
||||
std::string outputPath;
|
||||
|
||||
while ((incDirectiveType = file.ReadUntilIncDirective(outputPath)) != IncDirectiveType::None)
|
||||
{
|
||||
if (incDirectiveType == IncDirectiveType::Include)
|
||||
includes.insert(outputPath);
|
||||
else
|
||||
incbins.insert(outputPath);
|
||||
}
|
||||
|
||||
new (&m_source_file.asm_wrapper) SourceFile::InnerUnion::AsmWrapper{incbins, includes};
|
||||
}
|
||||
}
|
||||
|
||||
SourceFileType SourceFile::FileType()
|
||||
{
|
||||
return m_file_type;
|
||||
}
|
||||
|
||||
SourceFile::~SourceFile()
|
||||
{
|
||||
if (m_file_type == SourceFileType::Cpp || m_file_type == SourceFileType::Header)
|
||||
{
|
||||
m_source_file.c_file.~CFile();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_source_file.asm_wrapper.asm_incbins.~set();
|
||||
m_source_file.asm_wrapper.asm_includes.~set();
|
||||
}
|
||||
}
|
||||
|
||||
const std::set<std::string>& SourceFile::GetIncbins()
|
||||
{
|
||||
if (m_file_type == SourceFileType::Cpp || m_file_type == SourceFileType::Header)
|
||||
return m_source_file.c_file.GetIncbins();
|
||||
else
|
||||
return m_source_file.asm_wrapper.asm_incbins;
|
||||
}
|
||||
|
||||
const std::set<std::string>& SourceFile::GetIncludes()
|
||||
{
|
||||
if (m_file_type == SourceFileType::Cpp || m_file_type == SourceFileType::Header)
|
||||
return m_source_file.c_file.GetIncludes();
|
||||
else
|
||||
return m_source_file.asm_wrapper.asm_includes;
|
||||
}
|
||||
|
||||
std::string& SourceFile::GetSrcDir()
|
||||
{
|
||||
return m_src_dir;
|
||||
}
|
||||
|
||||
72
tools/scaninc/source_file.h
Normal file
72
tools/scaninc/source_file.h
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
// Copyright(c) 2019 Phlosioneer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#ifndef SOURCE_FILE_H
|
||||
#define SOURCE_FILE_H
|
||||
|
||||
#include <string>
|
||||
#include "scaninc.h"
|
||||
#include "asm_file.h"
|
||||
#include "c_file.h"
|
||||
|
||||
enum class SourceFileType
|
||||
{
|
||||
Cpp,
|
||||
Header,
|
||||
Asm,
|
||||
Inc
|
||||
};
|
||||
|
||||
SourceFileType GetFileType(std::string& path);
|
||||
|
||||
class SourceFile
|
||||
{
|
||||
public:
|
||||
|
||||
SourceFile(std::string path);
|
||||
~SourceFile();
|
||||
SourceFile(SourceFile const&) = delete;
|
||||
SourceFile(SourceFile&&) = delete;
|
||||
SourceFile& operator =(SourceFile const&) = delete;
|
||||
SourceFile& operator =(SourceFile&&) = delete;
|
||||
bool HasIncbins();
|
||||
const std::set<std::string>& GetIncbins();
|
||||
const std::set<std::string>& GetIncludes();
|
||||
std::string& GetSrcDir();
|
||||
SourceFileType FileType();
|
||||
|
||||
private:
|
||||
union InnerUnion {
|
||||
CFile c_file;
|
||||
struct AsmWrapper {
|
||||
std::set<std::string> asm_incbins;
|
||||
std::set<std::string> asm_includes;
|
||||
} asm_wrapper;
|
||||
|
||||
// Construction and destruction handled by SourceFile.
|
||||
InnerUnion() {};
|
||||
~InnerUnion() {};
|
||||
} m_source_file;
|
||||
SourceFileType m_file_type;
|
||||
std::string m_src_dir;
|
||||
};
|
||||
|
||||
#endif // SOURCE_FILE_H
|
||||
|
||||
Loading…
Reference in New Issue
Block a user