tools: Implement npctradeproc to replace tools/jsoncnv/npc_trades.py (#1168)
Some checks are pending
build / build (push) Waiting to run

This commit is contained in:
scbroede
2026-05-18 19:36:54 -04:00
committed by GitHub
62 changed files with 466 additions and 291 deletions

View File

@@ -18,7 +18,6 @@
#include "generated/movement_types.h"
#include "generated/moves.h"
#include "generated/mystery_gift_delivery_stages.h"
#include "generated/npc_trades.h"
#include "generated/object_events_gfx.h"
#include "generated/player_transitions.h"
#include "generated/poketch_apps.h"

View File

@@ -76,7 +76,6 @@ metang_generators = {
'movement_types': { 'type': 'enum', 'tag': 'MovementType' },
'moves': { 'type': 'enum', 'tag': 'Move' },
'natures': { 'type': 'enum', 'tag': 'Nature' },
'npc_trades': { 'type': 'enum', 'tag': 'NPCTradeID' },
'object_events_gfx': { 'type': 'enum', 'tag': 'ObjectEventGfx' },
'pal_park_land_area': { 'type': 'enum', 'tag': 'PalParkLandArea' },
'pal_park_water_area': { 'type': 'enum', 'tag': 'PalParkWaterArea' },
@@ -115,7 +114,6 @@ metang_generators = {
'traps': { 'type': 'enum', 'tag': 'Trap' },
'tutor_locations': {'type': 'enum', 'tag': 'TutorLocation'},
'vars_flags': {'type': 'enum', 'tag': 'VarFlag'},
'versions': {'type': 'enum', 'tag': 'Version'},
'villa_furniture_type': {'type': 'enum', 'tag': 'VillaFurnitureType'},
'mart_specialties_id': {'type': 'enum', 'tag': 'MartSpecialtiesID'},
'mart_decor_id': {'type': 'enum', 'tag': 'MartDecorID'},
@@ -162,7 +160,6 @@ foreach gen_key : metang_generators.keys()
endforeach
moves_txt = files('moves.txt')
npc_trades_txt = files('npc_trades.txt')
species_txt = files('species.txt')
text_banks_txt = files('text_banks.txt')
trainer_classes_txt = files('trainer_classes.txt')

View File

@@ -1,5 +0,0 @@
NPC_TRADE_KAZZA_ABRA
NPC_TRADE_CHARAP_CHATOT
NPC_TRADE_GASPAR_HAUNTER
NPC_TRADE_FOPPA_MAGIKARP
MAX_NPC_TRADES

View File

@@ -1,12 +0,0 @@
VERSION_NONE
VERSION_SAPPHIRE
VERSION_RUBY
VERSION_EMERALD
VERSION_FIRERED
VERSION_LEAFGREEN
VERSION_HEARTGOLD = 7
VERSION_SOULSILVER
VERSION_DIAMOND = 10
VERSION_PEARL
VERSION_PLATINUM
VERSION_GAMECUBE = 15 # Both Colosseum and XD use the same ID

View File

@@ -0,0 +1,12 @@
#ifndef POKEPLATINUM_CONSTANTS_NPC_TRADES_H
#define POKEPLATINUM_CONSTANTS_NPC_TRADES_H
enum NPCTradeID {
NPC_TRADE_KAZZA_ABRA = 0,
NPC_TRADE_CHARAP_CHATOT,
NPC_TRADE_GASPAR_HAUNTER,
NPC_TRADE_FOPPA_MAGIKARP,
MAX_NPC_TRADES,
};
#endif // POKEPLATINUM_CONSTANTS_NPC_TRADES_H

View File

@@ -0,0 +1,35 @@
#ifndef POKEPLATINUM_CONSTANTS_VERSIONS_H
#define POKEPLATINUM_CONSTANTS_VERSIONS_H
enum Version {
VERSION_NONE = 0,
VERSION_SAPPHIRE,
VERSION_RUBY,
VERSION_EMERALD,
VERSION_FIRERED,
VERSION_LEAFGREEN,
VERSION_UNUSED_6,
VERSION_HEARTGOLD,
VERSION_SOULSILVER,
VERSION_UNUSED_9,
VERSION_DIAMOND,
VERSION_PEARL,
VERSION_PLATINUM,
VERSION_UNUSED_13,
VERSION_UNUSED_14,
VERSION_GAMECUBE, // Both Colosseum and XD use the same ID
};
enum Language {
LANGUAGE_NONE = 0,
LANGUAGE_JAPANESE,
LANGUAGE_ENGLISH,
LANGUAGE_FRENCH,
LANGUAGE_ITALIAN,
LANGUAGE_GERMAN,
LANGUAGE_UNUSED_6,
LANGUAGE_SPANISH,
LANGUAGE_KOREAN,
};
#endif // POKEPLATINUM_CONSTANTS_VERSIONS_H

View File

@@ -1,15 +1,7 @@
#ifndef POKEPLATINUM_PM_VERSION_H
#define POKEPLATINUM_PM_VERSION_H
#include "generated/versions.h"
#define JAPANESE 1
#define ENGLISH 2
#define FRENCH 3
#define ITALIAN 4
#define GERMAN 5
#define SPANISH 7
#define KOREAN 8
#include "constants/versions.h"
extern const u8 gGameVersion;
extern const u8 gGameLanguage;

View File

@@ -1,6 +1,9 @@
#ifndef POKEPLATINUM_MAIN_MENU_MAIN_MENU_UTIL_H
#define POKEPLATINUM_MAIN_MENU_MAIN_MENU_UTIL_H
#include "constants/versions.h"
#include "generated/fade_types.h"
#include "main_menu/mystery_gift_app.h"
#include "bg_window.h"
@@ -9,7 +12,6 @@
#include "overlay_manager.h"
#include "palette.h"
#include "savedata.h"
#include "screen_fade.h"
#include "sprite.h"
#include "sprite_resource.h"
#include "sprite_util.h"

View File

@@ -1,10 +1,15 @@
#ifndef POKEPLATINUM_NPC_TRADE_H
#define POKEPLATINUM_NPC_TRADE_H
#include "constants/heap.h"
#include "constants/npc_trades.h"
#include "struct_defs/pokemon.h"
#include "field/field_system_decl.h"
#include "overlay006/struct_npc_trade_animation_template.h"
#include "pokemon.h"
#include "trainer_info.h"
typedef struct NPCTradeMon {
u32 species;
@@ -33,7 +38,7 @@ typedef struct NPCTradeData {
NPCTradeMon *npcTradeMon;
Pokemon *mon;
TrainerInfo *trainerInfo;
u32 npcTradeID;
enum NPCTradeID npcTradeID;
enum HeapID heapID;
} NPCTradeData;
@@ -42,6 +47,6 @@ void NPCTrade_Free(NPCTradeData *data);
u32 NPCTrade_GetSpecies(const NPCTradeData *data);
u32 NPCTrade_GetRequestedSpecies(const NPCTradeData *data);
void NPCTrade_ReceiveMon(FieldSystem *fieldSystem, NPCTradeData *data, int slot);
void NPCTrade_FillAnimationTemplate(FieldSystem *fieldSystem, NPCTradeData *data, int slot, TradeAnimationTemplate *param3, Pokemon *givingMon, Pokemon *receivingMon);
void NPCTrade_FillAnimationTemplate(FieldSystem *fieldSystem, NPCTradeData *data, int slot, TradeAnimationTemplate *animationConfig, Pokemon *givingMon, Pokemon *receivingMon);
#endif // POKEPLATINUM_NPC_TRADE_H

View File

@@ -1,8 +1,9 @@
#ifndef POKEPLATINUM_STRUCT_NPC_TRADE_ANIMATION_TEMPLATE_H
#define POKEPLATINUM_STRUCT_NPC_TRADE_ANIMATION_TEMPLATE_H
#include "struct_defs/pokemon.h"
#include "game_options.h"
#include "pokemon.h"
#include "trainer_info.h"
enum TradeType {

View File

@@ -1,9 +1,9 @@
#ifndef POKEPLATINUM_TRAINER_INFO_H
#define POKEPLATINUM_TRAINER_INFO_H
#include "constants/heap.h"
#include "constants/string.h"
#include "heap.h"
#include "string_gf.h"
typedef struct TrainerInfo {

View File

@@ -64,7 +64,7 @@ add_global_arguments(c_args,
pokeplatinum_args = [
'-DPM_KEEP_ASSERTS',
'-DGAME_VERSION=VERSION_PLATINUM',
'-DGAME_LANGUAGE=ENGLISH'
'-DGAME_LANGUAGE=LANGUAGE_ENGLISH'
]
if get_option('gdb_debugging')

View File

@@ -330,7 +330,7 @@ res/prebuilt/contest/graphic/contest_bg.narc,/contest/graphic/contest_bg.narc
res/prebuilt/contest/graphic/contest_obj.narc,/contest/graphic/contest_obj.narc
res/prebuilt/demo/title/op_demo.narc,/demo/title/op_demo.narc
res/graphics/title_screen/titledemo.narc,/demo/title/titledemo.narc
res/field/trades/fld_trade.narc,/fielddata/pokemon_trade/fld_trade.narc
res/npc_trades.narc,/fielddata/pokemon_trade/fld_trade.narc
res/graphics/pokedex/zukan.narc,/resource/eng/zukan/zukan.narc
res/prebuilt/resource/eng/batt_rec/batt_rec_gra.narc,/resource/eng/batt_rec/batt_rec_gra.narc
res/prebuilt/resource/eng/wifi_lobby_minigame/wlmngm_tool.narc,/resource/eng/wifi_lobby_minigame/wlmngm_tool.narc
1 Source File Target File
330 res/prebuilt/contest/graphic/contest_obj.narc /contest/graphic/contest_obj.narc
331 res/prebuilt/demo/title/op_demo.narc /demo/title/op_demo.narc
332 res/graphics/title_screen/titledemo.narc /demo/title/titledemo.narc
333 res/field/trades/fld_trade.narc res/npc_trades.narc /fielddata/pokemon_trade/fld_trade.narc
334 res/graphics/pokedex/zukan.narc /resource/eng/zukan/zukan.narc
335 res/prebuilt/resource/eng/batt_rec/batt_rec_gra.narc /resource/eng/batt_rec/batt_rec_gra.narc
336 res/prebuilt/resource/eng/wifi_lobby_minigame/wlmngm_tool.narc /resource/eng/wifi_lobby_minigame/wlmngm_tool.narc

View File

@@ -329,7 +329,7 @@ ecdb14e0bc6619f114549e6126c8b6934cfc3aeb *res/prebuilt/battle/b_pl_stage/pl_bsdp
cec363028fa6bc6240f9c8da7ab8f9e8bb1b1465 *res/prebuilt/contest/graphic/contest_obj.narc
7fa87d90ba039f67221a43782bf6a1a1107d5947 *res/prebuilt/demo/title/op_demo.narc
d7e86fadf59a54f922fc7cf65ae65fa326b8429e *res/graphics/title_screen/titledemo.narc
32a0989a18cc7f3eb17c5949adecb3f057a84eea *res/field/trades/fld_trade.narc
32a0989a18cc7f3eb17c5949adecb3f057a84eea *res/npc_trades.narc
d4b6f9731b808a613338005f59959325ce1e3ac9 *res/graphics/pokedex/zukan.narc
7e85af57b27fa4a0829b24550fc6c0dd275cf994 *res/prebuilt/resource/eng/batt_rec/batt_rec_gra.narc
2994f2955035001a22a1f225c68bfa809e4c85bf *res/prebuilt/resource/eng/wifi_lobby_minigame/wlmngm_tool.narc

View File

@@ -7,4 +7,3 @@ subdir('matrices')
subdir('props')
subdir('area_data')
subdir('scripts')
subdir('trades')

View File

@@ -1,4 +1,5 @@
#include "macros/scrcmd.inc"
#include "constants/npc_trades.h"
#include "res/text/bank/eterna_city_condominiums_1f.h"

View File

@@ -1,4 +1,5 @@
#include "macros/scrcmd.inc"
#include "constants/npc_trades.h"
#include "res/text/bank/oreburgh_city_north_house_1f.h"

View File

@@ -2,8 +2,8 @@
#include "res/text/bank/menu_entries.h"
#include "res/text/bank/pal_park_lobby.h"
#include "res/field/events/events_pal_park_lobby.h"
#include "generated/versions.h"
#include "constants/pokemon.h"
#include "constants/versions.h"
ScriptEntry PalParkLobby_OnTransition

View File

@@ -1,4 +1,5 @@
#include "macros/scrcmd.inc"
#include "constants/npc_trades.h"
#include "res/text/bank/route_226_house.h"

View File

@@ -1,4 +1,5 @@
#include "macros/scrcmd.inc"
#include "constants/npc_trades.h"
#include "res/text/bank/snowpoint_city_west_house.h"

View File

@@ -2,7 +2,7 @@
#include "generated/distribution_events.h"
#include "res/text/bank/spear_pillar.h"
#include "res/field/events/events_spear_pillar.h"
#include "generated/versions.h"
#include "constants/versions.h"
ScriptEntry SpearPillar_OnTransition

View File

@@ -1,29 +0,0 @@
npc_trades_bin_gen = generator(
npc_trades_py,
arguments: [ '@INPUT@', '@OUTPUT@', ],
output: '@BASENAME@',
depends: [ py_consts_generators ],
)
npc_trades_consts = fs.read(npc_trades_txt).splitlines()
npc_trades_files = []
foreach npc_trade: npc_trades_consts
if npc_trade.startswith('MAX_')
continue
endif
npc_trades_files += files(npc_trade.to_lower() + '.json')
endforeach
npc_trades_narc = custom_target('fld_trade.narc',
output: 'fld_trade.narc',
input: npc_trades_bin_gen.process(npc_trades_files, env: jsoncnv_env),
command: [
nitroarc_exe,
'--create',
'--files-from', files('npc_trades.order'),
'--file', '@OUTPUT0@',
'@PRIVATE_DIR@',
],
)
nitrofs_files += npc_trades_narc

View File

@@ -1,4 +0,0 @@
npc_trade_kazza_abra
npc_trade_charap_chatot
npc_trade_gaspar_haunter
npc_trade_foppa_magikarp

View File

@@ -71,6 +71,26 @@ copy_gen = generator(copy_exe,
output: '@PLAINNAME@'
)
npctrade_data = custom_target('npctrade_data',
output: [
'npc_trades.narc',
'npc_trade_names.json',
],
command: [
npctradeproc_exe,
'-M', '@DEPFILE@',
'-o', meson.current_build_dir(),
meson.global_source_root() / 'include' / 'constants' / 'npc_trades.h',
meson.current_source_dir() / 'npc_trades',
],
depfile: 'npctrade_data.d'
)
nitrofs_files += npctrade_data
npctrade_text_banks = npctrade_data[1]
### DECOMPILED DATA DIRECTORIES ###
# These subpaths are listed because the result of some build-rule inside them
# is a dependency of some later build-rule.

View File

@@ -1,4 +1,6 @@
{
"name": "Charap",
"otName": "Norton",
"species": "SPECIES_CHATOT",
"hpIV": 15,
"atkIV": 20,
@@ -17,6 +19,6 @@
"heldItem": "ITEM_LEPPA_BERRY",
"otGender": "GENDER_MALE",
"unused2": 50,
"language": 2,
"language": "LANGUAGE_ENGLISH",
"requestedSpecies": "SPECIES_BUIZEL"
}

View File

@@ -1,4 +1,6 @@
{
"name": "Foppa",
"otName": "Meister",
"species": "SPECIES_MAGIKARP",
"hpIV": 15,
"atkIV": 25,
@@ -17,6 +19,6 @@
"heldItem": "ITEM_LUM_BERRY",
"otGender": "GENDER_MALE",
"unused2": 0,
"language": 5,
"language": "LANGUAGE_GERMAN",
"requestedSpecies": "SPECIES_FINNEON"
}

View File

@@ -1,4 +1,6 @@
{
"name": "Gaspar",
"otName": "Mindy",
"species": "SPECIES_HAUNTER",
"hpIV": 20,
"atkIV": 25,
@@ -17,6 +19,6 @@
"heldItem": "ITEM_EVERSTONE",
"otGender": "GENDER_FEMALE",
"unused2": 0,
"language": 2,
"language": "LANGUAGE_ENGLISH",
"requestedSpecies": "SPECIES_MEDICHAM"
}

View File

@@ -1,4 +1,6 @@
{
"name": "Kazza",
"otName": "Hilary",
"species": "SPECIES_ABRA",
"hpIV": 15,
"atkIV": 15,
@@ -17,6 +19,6 @@
"heldItem": "ITEM_ORAN_BERRY",
"otGender": "GENDER_FEMALE",
"unused2": 0,
"language": 2,
"language": "LANGUAGE_ENGLISH",
"requestedSpecies": "SPECIES_MACHOP"
}

View File

@@ -55,17 +55,14 @@ item_text_bank_names = [
'item_descriptions.json',
]
town_map_text_bank_name = [
'town_map.json'
]
# This list will be what's used hereafter when referring to any-and-all generated banks.
generated_text_banks = [
species_text_bank_names,
trainer_text_bank_names,
frontier_text_bank_names,
item_text_bank_names,
town_map_text_bank_name,
'town_map.json',
'npc_trade_names.json',
]
# 2. All other files must be static. Pull these from `generated/text_banks.txt`. This allows us
@@ -113,9 +110,10 @@ text_bank_files += species_text_banks
text_bank_files += trainer_text_banks
text_bank_files += frontier_text_banks
text_bank_files += item_text_banks
text_bank_files += npctrade_text_banks
town_map_text_bank = custom_target('town_map_text_bank',
output: town_map_text_bank_name,
output: 'town_map.json',
command: [
'cp',
'@OUTDIR@/../town_map/town_map.json',

View File

@@ -1,37 +0,0 @@
{
"key": 4839,
"messages": [
{
"id": "NPCTradeNames_Text_Kazza",
"en_US": "Kazza"
},
{
"id": "NPCTradeNames_Text_Charap",
"en_US": "Charap"
},
{
"id": "NPCTradeNames_Text_Gaspar",
"en_US": "Gaspar"
},
{
"id": "NPCTradeNames_Text_Foppa",
"en_US": "Foppa"
},
{
"id": "NPCTradeNames_Text_Hilary",
"en_US": "Hilary"
},
{
"id": "NPCTradeNames_Text_Norton",
"en_US": "Norton"
},
{
"id": "NPCTradeNames_Text_Mindy",
"en_US": "Mindy"
},
{
"id": "NPCTradeNames_Text_Meister",
"en_US": "Meister"
}
]
}

View File

@@ -3,6 +3,8 @@
#include <nitro.h>
#include <string.h>
#include "constants/versions.h"
#include "applications/pokedex/ov21_021E29DC.h"
#include "applications/pokedex/pokedex_app.h"
#include "applications/pokedex/pokedex_data_manager.h"
@@ -21,7 +23,6 @@
#include "heap.h"
#include "message.h"
#include "narc.h"
#include "pokemon.h"
#include "pokemon_sprite.h"
#include "sprite.h"
#include "sprite_resource.h"
@@ -772,22 +773,22 @@ static int LanguageMessage(int languageID)
int entryID;
switch (languageID) {
case JAPANESE:
case LANGUAGE_JAPANESE:
entryID = pl_msg_pokedex_japanese;
break;
case ENGLISH:
case LANGUAGE_ENGLISH:
entryID = pl_msg_pokedex_english;
break;
case FRENCH:
case LANGUAGE_FRENCH:
entryID = pl_msg_pokedex_french;
break;
case ITALIAN:
case LANGUAGE_ITALIAN:
entryID = pl_msg_pokedex_italian;
break;
case GERMAN:
case LANGUAGE_GERMAN:
entryID = pl_msg_pokedex_german;
break;
case SPANISH:
case LANGUAGE_SPANISH:
entryID = pl_msg_pokedex_spanish;
break;
default:

View File

@@ -3,6 +3,7 @@
#include "constants/heap.h"
#include "constants/string.h"
#include "constants/versions.h"
#include "generated/genders.h"
#include "applications/naming_screen.h"

View File

@@ -3,8 +3,10 @@
#include <nitro.h>
#include "constants/trainer_card_levels.h"
#include "constants/versions.h"
#include "generated/genders.h"
#include "applications/trainer_case/badge_chimes.h"
#include "applications/trainer_case/card_text.h"
#include "applications/trainer_case/defs.h"
#include "applications/trainer_case/sprites.h"
@@ -124,7 +126,7 @@ static void TrainerCase_ResetBadgePolishingDirection(BadgePolishingState *badgeP
static void TrainerCase_ResetBadgePolishingState(BadgePolishingState *badgePolishingState);
static void TrainerCase_PlayPolishingSoundEffects(BadgePolishingState *badgePolishingState);
static void TrainerCase_ConvertSignature1BppTo8Bpp(const u8 *signature1Bpp, u8 *signature8BppOut);
static void TrainerCase_DisplaySignature(BgConfig *bgConfig, enum BgLayer bgLayer, const u8 *signature);
static void TrainerCase_DisplaySignature(BgConfig *bgConfig, enum BgLayer bgLayer, u8 *signature);
static void TrainerCase_PlayOpenCloseBadgeCaseSoundEffect(int unused);
static void TrainerCase_UpdatePlayTime(TrainerCaseApp *trainerCaseApp, u8 liveTimeDisplay);
static int TrainerCase_CheckBadgeOrButtonTouched(BgConfig *bgConfig, const TouchScreenRect rects[]);
@@ -312,7 +314,7 @@ BOOL TrainerCaseApp_Main(ApplicationManager *appMan, int *state)
break;
case TRAINER_CASE_STATE_MAIN:
case TRAINER_CASE_STATE_MAIN: {
int input = TrainerCase_GetPlayerInput(trainerCaseApp);
if (input == INPUT_TOUCH_SCREEN_TAP) {
@@ -367,6 +369,7 @@ BOOL TrainerCaseApp_Main(ApplicationManager *appMan, int *state)
TrainerCase_UpdatePlayTime(trainerCaseApp, trainerCaseApp->trainerCase->liveTimeDisplay);
break;
}
case TRAINER_CASE_STATE_EXIT:
if (IsScreenFadeDone()) {
return TRUE;
@@ -1240,7 +1243,7 @@ static void TrainerCase_ConvertSignature1BppTo8Bpp(const u8 *signature1Bpp, u8 *
}
}
static void TrainerCase_DisplaySignature(BgConfig *bgConfig, enum BgLayer bgLayer, const u8 *signature)
static void TrainerCase_DisplaySignature(BgConfig *bgConfig, enum BgLayer bgLayer, u8 *signature)
{
Bg_LoadTiles(bgConfig, bgLayer, signature, SIGNATURE_WIDTH * SIGNATURE_HEIGHT * TILE_SIZE_8BPP, 1);

View File

@@ -1,7 +1,8 @@
#include "cutscenes/hall_of_fame.h"
#include <nitro.h>
#include <string.h>
#include "constants/versions.h"
#include "struct_defs/hall_of_fame_display_data.h"
#include "struct_defs/sprite_animation_frame.h"
@@ -14,7 +15,6 @@
#include "graphics.h"
#include "gx_layers.h"
#include "heap.h"
#include "inlines.h"
#include "math_util.h"
#include "message.h"
#include "narc.h"
@@ -352,7 +352,7 @@ BOOL HallOfFameManager_Init(ApplicationManager *appMan, int *state)
BOOL HallOfFameManager_Exit(ApplicationManager *appMan, int *state)
{
switch (*state) {
case 0:
case 0: {
HallOfFameMan *hallOfFameMan = ApplicationManager_Data(appMan);
SysTask_Done(hallOfFameMan->task_1C28);
@@ -372,6 +372,7 @@ BOOL HallOfFameManager_Exit(ApplicationManager *appMan, int *state)
Heap_Destroy(HEAP_ID_HALL_OF_FAME);
(*state)++;
break;
}
case 1:
if (ov86_0223CD80()) {
return TRUE;

View File

@@ -1,2 +1,4 @@
#include "constants/versions.h"
const u8 gGameVersion = GAME_VERSION;
const u8 gGameLanguage = GAME_LANGUAGE;

View File

@@ -4,6 +4,7 @@
#include "constants/graphics.h"
#include "constants/heap.h"
#include "constants/versions.h"
#include "assert.h"
#include "brightness_controller.h"

View File

@@ -1,9 +1,9 @@
#include "main_menu/gba_convert_string.h"
#include <nitro.h>
#include <string.h>
#include "constants/charcode.h"
#include "constants/versions.h"
#include "charcode.h"
@@ -262,22 +262,22 @@ static const charcode_t sGBACharToDSChars[][2] = {
static u16 GetSpaceChar(u32 language)
{
return (language == JAPANESE) ? CHAR_WIDE_SPACE : CHAR_SPACE;
return (language == LANGUAGE_JAPANESE) ? CHAR_WIDE_SPACE : CHAR_SPACE;
}
static u16 GetDoubleQuoteOpenChar(u32 language)
{
switch (language) {
case JAPANESE:
case LANGUAGE_JAPANESE:
default:
return CHAR_JP_DOUBLE_QUOTE_OPEN;
case ENGLISH:
case ITALIAN:
case SPANISH:
case LANGUAGE_ENGLISH:
case LANGUAGE_ITALIAN:
case LANGUAGE_SPANISH:
return CHAR_DOUBLE_QUOTE_OPEN;
case FRENCH:
case LANGUAGE_FRENCH:
return CHAR_DOUBLE_PAREN_OPEN;
case GERMAN:
case LANGUAGE_GERMAN:
return CHAR_DOUBLE_QUOTE_CLOSE_INVERTED;
}
}
@@ -285,23 +285,23 @@ static u16 GetDoubleQuoteOpenChar(u32 language)
static u16 GetDoubleQuoteCloseChar(u32 language)
{
switch (language) {
case JAPANESE:
case LANGUAGE_JAPANESE:
default:
return CHAR_JP_DOUBLE_QUOTE_CLOSE;
case ENGLISH:
case ITALIAN:
case SPANISH:
case LANGUAGE_ENGLISH:
case LANGUAGE_ITALIAN:
case LANGUAGE_SPANISH:
return CHAR_DOUBLE_QUOTE_CLOSE;
case FRENCH:
case LANGUAGE_FRENCH:
return CHAR_DOUBLE_PAREN_CLOSE;
case GERMAN:
case LANGUAGE_GERMAN:
return CHAR_DOUBLE_QUOTE_OPEN;
}
}
BOOL GBA_ConvertStringToDS(const u8 *src, charcode_t *dst, u32 length, u32 language)
{
BOOL nonJa = (language != JAPANESE);
BOOL nonJa = (language != LANGUAGE_JAPANESE);
u32 i;
for (i = 0; i < (length - 1); i++) {

View File

@@ -7,7 +7,7 @@
#include "constants/forms.h"
#include "constants/graphics.h"
#include "constants/narc.h"
#include "constants/species.h"
#include "constants/versions.h"
#include "generated/items.h"
#include "main_menu/mystery_gift_app.h"
@@ -42,7 +42,6 @@
#include "system.h"
#include "text.h"
#include "unk_02033200.h"
#include "versions.h"
#include "vram_transfer.h"
#include "res/graphics/main_menu/main_menu_graphics.naix"

View File

@@ -1,7 +1,8 @@
#include "main_menu/ov97_02235D18.h"
#include <nitro.h>
#include <string.h>
#include "constants/versions.h"
#include "main_menu/gba_save.h"
@@ -579,40 +580,40 @@ GBASaveBlock2 *GetGBASaveBlock2(void)
static const GBAPokemonCartInfo sGBAPokemonCartInfo[30] = {
// Ruby
{ 'JVXA', AGB_SET_RUBYSAPP, AGB_TYPE_RUBY, JAPANESE },
{ 'EVXA', AGB_SET_RUBYSAPP, AGB_TYPE_RUBY, ENGLISH },
{ 'FVXA', AGB_SET_RUBYSAPP, AGB_TYPE_RUBY, FRENCH },
{ 'DVXA', AGB_SET_RUBYSAPP, AGB_TYPE_RUBY, GERMAN },
{ 'SVXA', AGB_SET_RUBYSAPP, AGB_TYPE_RUBY, SPANISH },
{ 'IVXA', AGB_SET_RUBYSAPP, AGB_TYPE_RUBY, ITALIAN },
{ 'JVXA', AGB_SET_RUBYSAPP, AGB_TYPE_RUBY, LANGUAGE_JAPANESE },
{ 'EVXA', AGB_SET_RUBYSAPP, AGB_TYPE_RUBY, LANGUAGE_ENGLISH },
{ 'FVXA', AGB_SET_RUBYSAPP, AGB_TYPE_RUBY, LANGUAGE_FRENCH },
{ 'DVXA', AGB_SET_RUBYSAPP, AGB_TYPE_RUBY, LANGUAGE_GERMAN },
{ 'SVXA', AGB_SET_RUBYSAPP, AGB_TYPE_RUBY, LANGUAGE_SPANISH },
{ 'IVXA', AGB_SET_RUBYSAPP, AGB_TYPE_RUBY, LANGUAGE_ITALIAN },
// Sapphire
{ 'JPXA', AGB_SET_RUBYSAPP, AGB_TYPE_SAPPHIRE, JAPANESE },
{ 'EPXA', AGB_SET_RUBYSAPP, AGB_TYPE_SAPPHIRE, ENGLISH },
{ 'FPXA', AGB_SET_RUBYSAPP, AGB_TYPE_SAPPHIRE, FRENCH },
{ 'DPXA', AGB_SET_RUBYSAPP, AGB_TYPE_SAPPHIRE, GERMAN },
{ 'SPXA', AGB_SET_RUBYSAPP, AGB_TYPE_SAPPHIRE, SPANISH },
{ 'IPXA', AGB_SET_RUBYSAPP, AGB_TYPE_SAPPHIRE, ITALIAN },
{ 'JPXA', AGB_SET_RUBYSAPP, AGB_TYPE_SAPPHIRE, LANGUAGE_JAPANESE },
{ 'EPXA', AGB_SET_RUBYSAPP, AGB_TYPE_SAPPHIRE, LANGUAGE_ENGLISH },
{ 'FPXA', AGB_SET_RUBYSAPP, AGB_TYPE_SAPPHIRE, LANGUAGE_FRENCH },
{ 'DPXA', AGB_SET_RUBYSAPP, AGB_TYPE_SAPPHIRE, LANGUAGE_GERMAN },
{ 'SPXA', AGB_SET_RUBYSAPP, AGB_TYPE_SAPPHIRE, LANGUAGE_SPANISH },
{ 'IPXA', AGB_SET_RUBYSAPP, AGB_TYPE_SAPPHIRE, LANGUAGE_ITALIAN },
// FireRed
{ 'JRPB', AGB_SET_FIRELEAF, AGB_TYPE_FIRERED, JAPANESE },
{ 'ERPB', AGB_SET_FIRELEAF, AGB_TYPE_FIRERED, ENGLISH },
{ 'FRPB', AGB_SET_FIRELEAF, AGB_TYPE_FIRERED, FRENCH },
{ 'DRPB', AGB_SET_FIRELEAF, AGB_TYPE_FIRERED, GERMAN },
{ 'SRPB', AGB_SET_FIRELEAF, AGB_TYPE_FIRERED, SPANISH },
{ 'IRPB', AGB_SET_FIRELEAF, AGB_TYPE_FIRERED, ITALIAN },
{ 'JRPB', AGB_SET_FIRELEAF, AGB_TYPE_FIRERED, LANGUAGE_JAPANESE },
{ 'ERPB', AGB_SET_FIRELEAF, AGB_TYPE_FIRERED, LANGUAGE_ENGLISH },
{ 'FRPB', AGB_SET_FIRELEAF, AGB_TYPE_FIRERED, LANGUAGE_FRENCH },
{ 'DRPB', AGB_SET_FIRELEAF, AGB_TYPE_FIRERED, LANGUAGE_GERMAN },
{ 'SRPB', AGB_SET_FIRELEAF, AGB_TYPE_FIRERED, LANGUAGE_SPANISH },
{ 'IRPB', AGB_SET_FIRELEAF, AGB_TYPE_FIRERED, LANGUAGE_ITALIAN },
// LeafGreen
{ 'JGPB', AGB_SET_FIRELEAF, AGB_TYPE_LEAFGREEN, JAPANESE },
{ 'EGPB', AGB_SET_FIRELEAF, AGB_TYPE_LEAFGREEN, ENGLISH },
{ 'FGPB', AGB_SET_FIRELEAF, AGB_TYPE_LEAFGREEN, FRENCH },
{ 'DGPB', AGB_SET_FIRELEAF, AGB_TYPE_LEAFGREEN, GERMAN },
{ 'SGPB', AGB_SET_FIRELEAF, AGB_TYPE_LEAFGREEN, SPANISH },
{ 'IGPB', AGB_SET_FIRELEAF, AGB_TYPE_LEAFGREEN, ITALIAN },
{ 'JGPB', AGB_SET_FIRELEAF, AGB_TYPE_LEAFGREEN, LANGUAGE_JAPANESE },
{ 'EGPB', AGB_SET_FIRELEAF, AGB_TYPE_LEAFGREEN, LANGUAGE_ENGLISH },
{ 'FGPB', AGB_SET_FIRELEAF, AGB_TYPE_LEAFGREEN, LANGUAGE_FRENCH },
{ 'DGPB', AGB_SET_FIRELEAF, AGB_TYPE_LEAFGREEN, LANGUAGE_GERMAN },
{ 'SGPB', AGB_SET_FIRELEAF, AGB_TYPE_LEAFGREEN, LANGUAGE_SPANISH },
{ 'IGPB', AGB_SET_FIRELEAF, AGB_TYPE_LEAFGREEN, LANGUAGE_ITALIAN },
// Emerald
{ 'JEPB', AGB_SET_EMERALD, AGB_TYPE_EMERALD, JAPANESE },
{ 'EEPB', AGB_SET_EMERALD, AGB_TYPE_EMERALD, ENGLISH },
{ 'FEPB', AGB_SET_EMERALD, AGB_TYPE_EMERALD, FRENCH },
{ 'DEPB', AGB_SET_EMERALD, AGB_TYPE_EMERALD, GERMAN },
{ 'SEPB', AGB_SET_EMERALD, AGB_TYPE_EMERALD, SPANISH },
{ 'IEPB', AGB_SET_EMERALD, AGB_TYPE_EMERALD, ITALIAN }
{ 'JEPB', AGB_SET_EMERALD, AGB_TYPE_EMERALD, LANGUAGE_JAPANESE },
{ 'EEPB', AGB_SET_EMERALD, AGB_TYPE_EMERALD, LANGUAGE_ENGLISH },
{ 'FEPB', AGB_SET_EMERALD, AGB_TYPE_EMERALD, LANGUAGE_FRENCH },
{ 'DEPB', AGB_SET_EMERALD, AGB_TYPE_EMERALD, LANGUAGE_GERMAN },
{ 'SEPB', AGB_SET_EMERALD, AGB_TYPE_EMERALD, LANGUAGE_SPANISH },
{ 'IEPB', AGB_SET_EMERALD, AGB_TYPE_EMERALD, LANGUAGE_ITALIAN },
};
static u8 Unk_ov97_0223EC04[] = {

View File

@@ -1,10 +1,10 @@
#include "main_menu/ranger_link.h"
#include <nitro.h>
#include <string.h>
#include "constants/charcode.h"
#include "constants/graphics.h"
#include "constants/versions.h"
#include "game_opening/const_ov77_021D742C.h"
#include "main_menu/main_menu_util.h"
@@ -17,7 +17,6 @@
#include "savedata/save_table.h"
#include "bg_window.h"
#include "enums.h"
#include "font.h"
#include "game_options.h"
#include "graphics.h"
@@ -44,7 +43,6 @@
#include "text_banks.h"
#include "trainer_info.h"
#include "unk_02033200.h"
#include "versions.h"
#include "res/graphics/main_menu/main_menu_graphics.naix"
#include "res/text/bank/main_menu_alerts.h"

View File

@@ -1,5 +1,6 @@
#include "map_header.h"
#include "constants/versions.h"
#include "generated/map_headers.h"
#include "data/map_headers.h"

View File

@@ -4,6 +4,7 @@
#include <string.h>
#include "constants/heap.h"
#include "constants/versions.h"
#include "field/field_system.h"
#include "overlay006/wild_encounters.h"

View File

@@ -1,9 +1,9 @@
#include "overlay005/honey_tree.h"
#include <nitro.h>
#include <string.h>
#include "constants/map_object.h"
#include "constants/versions.h"
#include "generated/map_headers.h"
#include "field/field_system.h"

View File

@@ -1,7 +1,8 @@
#include "overlay006/dual_slot_encounters.h"
#include <nitro.h>
#include <string.h>
#include "constants/versions.h"
#include "overlay006/wild_encounters.h"

View File

@@ -3,7 +3,7 @@
#include <nitro.h>
#include <string.h>
#include "generated/npc_trades.h"
#include "constants/npc_trades.h"
#include "field/field_system.h"
#include "overlay006/struct_npc_trade_animation_template.h"

View File

@@ -4,6 +4,7 @@
#include <string.h>
#include "constants/species.h"
#include "constants/versions.h"
#include "generated/movement_actions.h"
#include "struct_decls/map_object.h"

View File

@@ -5,6 +5,7 @@
#include <ppwlobby/ppw_lobby.h>
#include <string.h>
#include "constants/versions.h"
#include "generated/game_records.h"
#include "generated/journal_online_events.h"
#include "generated/species.h"
@@ -13,7 +14,6 @@
#include "struct_decls/struct_0207E060_decl.h"
#include "struct_defs/wi_fi_history.h"
#include "global/pm_version.h"
#include "overlay066/ov66_02231428.h"
#include "overlay066/ov66_0223177C.h"
#include "overlay066/ov66_022324F0.h"
@@ -44,7 +44,6 @@
#include "font.h"
#include "game_records.h"
#include "heap.h"
#include "inlines.h"
#include "journal.h"
#include "math_util.h"
#include "message.h"
@@ -1144,7 +1143,7 @@ u32 ov66_0222E80C(const UnkStruct_ov66_0222E71C *param0)
if (ov66_0222E824(param0) == TRUE) {
language = param0->language;
} else {
language = ENGLISH;
language = LANGUAGE_ENGLISH;
}
return language;
@@ -1154,12 +1153,12 @@ u32 ov66_0222E80C(const UnkStruct_ov66_0222E71C *param0)
BOOL ov66_0222E824(const UnkStruct_ov66_0222E71C *param0)
{
switch (param0->language) {
case JAPANESE:
case ENGLISH:
case FRENCH:
case ITALIAN:
case GERMAN:
case SPANISH:
case LANGUAGE_JAPANESE:
case LANGUAGE_ENGLISH:
case LANGUAGE_FRENCH:
case LANGUAGE_ITALIAN:
case LANGUAGE_GERMAN:
case LANGUAGE_SPANISH:
return TRUE;
default:
break;

View File

@@ -4,10 +4,10 @@
#include <string.h>
#include "constants/graphics.h"
#include "constants/versions.h"
#include "struct_defs/wi_fi_history.h"
#include "global/pm_version.h"
#include "overlay066/ov66_0222DDF0.h"
#include "overlay066/ov66_02231428.h"
#include "overlay066/struct_ov66_02230F50.h"
@@ -1329,7 +1329,7 @@ static void ov69_0225D2A8(UnkStruct_ov69_0225CE64 *param0, const UnkStruct_ov66_
param0->unk_04.unk_00_1 = 0;
param0->unk_04.unk_00_0 = 0;
if (gGameLanguage == JAPANESE) {
if (gGameLanguage == LANGUAGE_JAPANESE) {
param0->unk_04.unk_00_1 = 1;
} else {
param0->unk_04.unk_00_1 = 0;

View File

@@ -4,6 +4,7 @@
#include <string.h>
#include "constants/graphics.h"
#include "constants/versions.h"
#include "struct_defs/wi_fi_history.h"
@@ -314,7 +315,7 @@ int ov92_021D0D80(ApplicationManager *appMan, int *unused)
memset(v0, 0, sizeof(UnkStruct_ov92_021D1B24));
v0->heapID = heapID;
v0->unk_BAF0 = gGameLanguage == JAPANESE;
v0->unk_BAF0 = gGameLanguage == LANGUAGE_JAPANESE;
SaveData *saveData = ApplicationManager_Args(appMan);

View File

@@ -1,7 +1,6 @@
#include "overlay104/ov104_0222DCE0.h"
#include <nitro.h>
#include <string.h>
#include "constants/heap.h"
#include "constants/narc.h"
@@ -34,7 +33,6 @@
#include "unk_02038F8C.h"
#include "unk_0208C098.h"
#include "unk_02092494.h"
#include "versions.h"
#include "wifi_history_save_data.h"
static const u16 sTrainerClassToObjectID[][2] = {

View File

@@ -1,17 +1,16 @@
#include "pokedex_language.h"
#include <nitro.h>
#include <string.h>
#include "global/pm_version.h"
#include "constants/versions.h"
static const u8 languageArray[NUM_LANGUAGES] = {
JAPANESE,
ENGLISH,
FRENCH,
GERMAN,
ITALIAN,
SPANISH
LANGUAGE_JAPANESE,
LANGUAGE_ENGLISH,
LANGUAGE_FRENCH,
LANGUAGE_GERMAN,
LANGUAGE_ITALIAN,
LANGUAGE_SPANISH
};
int PokedexLanguage_LanguageToIndex(int language)

View File

@@ -3,11 +3,12 @@
#include <nitro.h>
#include <string.h>
#include "constants/versions.h"
#include "graphics.h"
#include "heap.h"
#include "math_util.h"
#include "message.h"
#include "narc.h"
#include "savedata.h"
#include "string_gf.h"
@@ -237,12 +238,12 @@ void SentenceSaveData_Init(void *param0)
u8 language;
u8 unk_01;
} v0[] = {
{ JAPANESE, 0x0 },
{ ENGLISH, 0x1 },
{ FRENCH, 0x2 },
{ ITALIAN, 0x3 },
{ GERMAN, 0x4 },
{ SPANISH, 0x5 }
{ LANGUAGE_JAPANESE, 0x0 },
{ LANGUAGE_ENGLISH, 0x1 },
{ LANGUAGE_FRENCH, 0x2 },
{ LANGUAGE_ITALIAN, 0x3 },
{ LANGUAGE_GERMAN, 0x4 },
{ LANGUAGE_SPANISH, 0x5 }
};
UnkStruct_02014EC4 *v1 = param0;
int i;

View File

@@ -1,9 +1,9 @@
#include "unk_0205B33C.h"
#include <nitro.h>
#include <string.h>
#include "constants/union_room_message_types.h"
#include "constants/versions.h"
#include "struct_decls/struct_02014EC4_decl.h"
#include "struct_decls/struct_0205B43C_decl.h"
@@ -12,7 +12,6 @@
#include "struct_defs/struct_0205B4F8.h"
#include "field/field_system.h"
#include "global/pm_version.h"
#include "appearance.h"
#include "communication_information.h"
@@ -1280,7 +1279,7 @@ void UnionRoom_DoGreeting(StringTemplate *strTemplate, int param1, int param2, T
int language = TrainerInfo_Language(commTrainerInfo);
if (language >= JAPANESE && language <= SPANISH) {
if (language >= LANGUAGE_JAPANESE && language <= LANGUAGE_SPANISH) {
static const int v5[] = {
0,
1,
@@ -1298,22 +1297,22 @@ void UnionRoom_DoGreeting(StringTemplate *strTemplate, int param1, int param2, T
}
switch (language) {
case JAPANESE:
case LANGUAGE_JAPANESE:
entryID = UnionRoom_Text_GreetingJapanese;
break;
case ENGLISH:
case LANGUAGE_ENGLISH:
entryID = UnionRoom_Text_GreetingEnglish;
break;
case FRENCH:
case LANGUAGE_FRENCH:
entryID = UnionRoom_Text_GreetingFrench;
break;
case ITALIAN:
case LANGUAGE_ITALIAN:
entryID = UnionRoom_Text_GreetingItalian;
break;
case GERMAN:
case LANGUAGE_GERMAN:
entryID = UnionRoom_Text_GreetingGerman;
break;
case SPANISH:
case LANGUAGE_SPANISH:
entryID = UnionRoom_Text_GreetingSpanish;
break;
default:

View File

@@ -4,6 +4,7 @@
#include "constants/battle_frontier.h"
#include "constants/battle_frontier_stats.h"
#include "constants/versions.h"
#include "struct_decls/map_object.h"

View File

@@ -1,12 +1,11 @@
#include "unk_02092494.h"
#include <nitro.h>
#include <string.h>
#include "constants/versions.h"
#include "struct_defs/struct_02090800.h"
#include "global/pm_version.h"
#include "heap.h"
#include "message.h"
#include "pokemon.h"

View File

@@ -111,3 +111,12 @@ itemproc_exe = executable(
dependencies: commonproc_dep,
native: true,
)
npctradeproc_exe = executable(
'npctradeproc',
sources: [ files('src/npctradeproc.c'), c_consts_generators ],
c_args: dataproc_cflags,
include_directories: [ public_includes, toplevel_includes ],
dependencies: commonproc_dep,
native: true,
)

View File

@@ -88,12 +88,17 @@ enum_seq_t _common_initenum(initenum_params_t params) {
char *data = fload(params.basefile, &size);
char *endp = NULL;
enum_seq_t result = libenum_find(data, size, "Item", &endp);
enum_seq_t result = libenum_find(data, size, params.enumname, &endp);
if (result.errc != LIBENUM_E_OK) { // handles the empty-case
fprintf(stderr, "libenum error: %s\n", libenum_errs(result.errc));
exit(EXIT_FAILURE);
}
if (result.members == NULL) {
fprintf(stderr, "could not find enum named '%s' in %s", params.enumname, params.basefile);
exit(EXIT_FAILURE);
}
if (result.size > UINT16_MAX) {
fprintf(stderr, "count of enum members %zu exceeds maximum of %u\n",
result.size, UINT16_MAX);

View File

@@ -45,6 +45,7 @@ typedef uint64_t u64;
#define boolean(path) (dp_bool(dp_get(df, path)))
#define u8(path) (dp_u8(dp_get(df, path)))
#define u16(path) (dp_u16(dp_get(df, path)))
#define u32(path) (dp_u32(dp_get(df, path)))
#define s8(path) (dp_s8(dp_get(df, path)))
#define u8_maxbits(path, bits) (u8)(dp_u8range(dp_get(df, path), 0, maxbit(bits)) & maxbit(bits))
#define enum_u8(path, type) (dp_u8(dp_lookup(dp_get(df, path), #type)))

View File

@@ -0,0 +1,226 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "common.h"
#include "dataproc.h"
#include "libenum.h"
#include "nitroarc.h"
#include "constants/string.h"
#include "overlay006/npc_trade.h"
static enum_template_t enums[] = {
include_enum("generated/species.h", "enum Species"),
include_enum("generated/items.h", "enum Item"),
include_enum("generated/genders.h", "enum Gender"),
include_enum("constants/versions.h", "enum Language"),
{ .from_file = NULL },
};
static archive_template_t archives[] = {
{ .out_filename = "npc_trades.narc" },
{ .out_filename = NULL },
};
static textbank_template_t textbanks[] = {
{ .out_filename = "npc_trade_names.json", .key = 4839 },
{ .out_filename = NULL },
};
static void parse_args(int *pargc, char ***pargv);
static void prep_trainernames(size_t count);
static void proc_trade(datafile_t *df);
static void proc_text(datafile_t *df, size_t i);
static void pack_trainernames(size_t count);
static char *filename = NULL;
static char *base_dir = NULL;
static char *depfile_path = "npctrade_data.d";
static char *output_dir = ".";
int main(int argc, char **argv) {
int errc = EXIT_SUCCESS;
char buf[BUFSIZE] = { 0 };
datafile_t df = { 0 };
parse_args(&argc, &argv);
enum_seq_t trades = common_initenum(
filename, "NPCTradeID",
.sourcefile = __FILE__,
.depfile = depfile_path,
.outdir = output_dir,
.format = DATAPROC_F_JSON,
.enums = enums,
.archives = archives,
.textbanks = textbanks,
);
prep_trainernames(trades.size);
for (size_t i = 0; i < trades.size; i++) {
const char *stem = trades.members[i].name + lengthof("NPC_TRADE_");
char *basename = strlower(strfmt("%s.json", stem));
char *filepath = pathjoin(base_dir, NULL, basename);
declare_dep(filepath);
if (dp_load(&df, filepath) == 0) {
proc_trade(&df);
proc_text(&df, i);
}
if (dp_report(&df) == DIAG_ERROR) errc = EXIT_FAILURE;
free(basename);
free(filepath);
dp_free(&df);
}
pack_trainernames(trades.size);
return common_done(errc, NULL);
}
static void proc_trade(datafile_t *df) {
NPCTradeMon mon = {
.species = enum_u16(".species", enum Species),
.hpIV = u8_maxbits(".hpIV", 5),
.atkIV = u8_maxbits(".atkIV", 5),
.defIV = u8_maxbits(".defIV", 5),
.speedIV = u8_maxbits(".speedIV", 5),
.spAtkIV = u8_maxbits(".spAtkIV", 5),
.spDefIV = u8_maxbits(".spDefIV", 5),
.unused1 = u32(".unused1"),
.otID = u32(".otID"),
.cool = u32(".cool"),
.beauty = u32(".beauty"),
.cute = u32(".cute"),
.smart = u32(".smart"),
.tough = u32(".tough"),
.personality = u32(".personality"),
.heldItem = enum_u16(".heldItem", enum Item),
.otGender = enum_u16(".otGender", enum Gender),
.unused2 = u32(".unused2"),
.language = enum_u16(".language", enum Language),
.requestedSpecies = enum_u16(".requestedSpecies", enum Species),
};
nitroarc_ppack(&archives[0].packer, &mon, sizeof(mon), NULL);
}
static char **s_trainernames = NULL;
static void prep_trainernames(size_t count) {
char *buf_trainernames = calloc(count * (TRAINER_NAME_LEN + 1), sizeof(*buf_trainernames));
s_trainernames = calloc(count, sizeof(*s_trainernames));
for (size_t i = 0; i < count; i++) {
s_trainernames[i] = &buf_trainernames[i * (TRAINER_NAME_LEN + 1)];
}
}
static void check_name(datanode_t *node, const char *val, size_t len, size_t max, const char *domain) {
if (!val) return;
if (len > max) {
dp_error(node,
"%s name '%s' exceeds maximum length of %zu",
domain, val, max);
return;
}
if (len == 0) dp_warn(node, "%s name has length 0", domain);
}
static void proc_text(datafile_t *df, size_t i) {
char buf[BUFSIZE] = { 0 };
datanode_t pk_name = dp_get(df, ".name");
datanode_t tr_name = dp_get(df, ".otName");
const char *pk_name_val = dp_string(pk_name);
const char *tr_name_val = dp_string(tr_name);
const size_t pk_name_len = pk_name_val ? strlen(pk_name_val) : 0;
const size_t tr_name_len = tr_name_val ? strlen(tr_name_val) : 0;
check_name(&pk_name, pk_name_val, pk_name_len, MON_NAME_LEN, "traded Pokemon");
check_name(&tr_name, tr_name_val, tr_name_len, TRAINER_NAME_LEN, "trading Trainer");
datanode_t entry = dp_arr_appobject(&textbanks[0].root);
dp_obj_putstring(&entry, "id", strfmt("NPCTradeNames_Text_Mon%zu", i));
dp_obj_putstring(&entry, "en_US", pk_name_val);
memcpy(s_trainernames[i], tr_name_val, tr_name_len); // store for later
}
static void pack_trainernames(size_t count) {
char buf[BUFSIZE] = { 0 };
for (size_t i = 0; i < count; i++) {
datanode_t entry = dp_arr_appobject(&textbanks[0].root);
dp_obj_putstring(&entry, "id", strfmt("NPCTradeNames_Text_Trainer%zu", i));
dp_obj_putstring(&entry, "en_US", s_trainernames[i]);
}
free(s_trainernames[0]);
free(s_trainernames);
}
static void usage(const char *fmt, ...);
static char *program_name = NULL;
static void parse_args(int *pargc, char ***pargv) {
program_name = (*pargv)[0];
opterr = 0;
int c = 0;
while ((c = getopt(*pargc, *pargv, ":o:M:h")) != -1) {
switch (c) {
case 'o': output_dir = optarg; break;
case 'M': depfile_path = optarg; break;
case 'h': usage(NULL); break;
case ':': usage("missing argument for '-%c'", optopt); break;
default: usage("unknown option '-%c'", optopt); break;
}
}
*pargc -= optind;
*pargv += optind;
if (*pargc < 1) usage("missing required argument ENUMFILE");
if (*pargc < 2) usage("missing required argument BASEDIR");
filename = (*pargv)[0];
base_dir = (*pargv)[1];
}
static void usage(const char *fmt, ...) {
FILE *f = stdout;
if (fmt != NULL) {
f = stderr;
va_list args;
va_start(args, fmt);
fputs(program_name, f);
fputs(": ", f);
vfprintf(f, fmt, args);
fputc('\n', f);
va_end(args);
}
#define fputf(fmt, ...) fprintf(f, fmt, __VA_ARGS__)
fputf("usage: %s [-M DEPFILE] [-o OUTDIR] ENUMFILE BASEDIR\n", program_name);
fputs("\n", f);
fputs("options:\n", f);
fputs(" -o OUTDIR Write output files to OUTDIR. Does not affect DEPFILE.\n", f);
fputs(" Defaults to the current working directory.\n", f);
fputs(" -M DEPFILE Specify the full path to an output dependency file.\n", f);
fputs(" Defaults to 'npctrade_data.d'.\n", f);
#undef fputf
exit(f == stdout ? EXIT_SUCCESS : EXIT_FAILURE);
}

View File

@@ -55,7 +55,7 @@ arm9_c_flags = [
"-DPOKEPLATINUM_GENERATED_ENUM",
"-DPM_KEEP_ASSERTS",
"-DGAME_VERSION=VERSION_PLATINUM",
"-DGAME_LANGUAGE=ENGLISH",
"-DGAME_LANGUAGE=LANGUAGE_ENGLISH",
"-DEXPLICIT_WCHAR_TYPEDEF",
]

View File

@@ -14,5 +14,4 @@ encdata_ex_trophy_garden_py = find_program('encdata_ex_trophy_garden.py', native
encdata_ex_great_marsh_py = find_program('encdata_ex_great_marsh.py', native: true)
lighting_py = find_program('lighting.py', native: true)
map_matrix_py = find_program('map_matrix.py', native: true)
npc_trades_py = find_program('npc_trades.py', native: true)
prop_model_set_py = find_program('prop_model_set.py', native: true)

View File

@@ -1,58 +0,0 @@
#!/usr/bin/env python3
import json
import pathlib
import sys
from convert import from_item, from_gender, from_species, u32
ANSI_BOLD_WHITE = "\033[1;37m"
ANSI_BOLD_RED = "\033[1;31m"
ANSI_RED = "\033[31m"
ANSI_CLEAR = "\033[0m"
def parse_npc_trade(data) -> bytes:
return b"".join([
u32(from_species(data["species"])),
u32(data["hpIV"]),
u32(data["atkIV"]),
u32(data["defIV"]),
u32(data["speedIV"]),
u32(data["spAtkIV"]),
u32(data["spDefIV"]),
u32(data["unused1"]),
u32(data["otID"]),
u32(data["cool"]),
u32(data["beauty"]),
u32(data["cute"]),
u32(data["smart"]),
u32(data["tough"]),
u32(data["personality"]),
u32(from_item(data["heldItem"])),
u32(from_gender(data["otGender"])),
u32(data["unused2"]),
u32(data["language"]),
u32(from_species(data["requestedSpecies"])),
])
input_path = pathlib.Path(sys.argv[1])
output_path = pathlib.Path(sys.argv[2])
try:
data = {}
with open(input_path, 'r', encoding='utf-8') as input_file:
data = json.load(input_file)
except json.decoder.JSONDecodeError as e:
doc_lines = e.doc.splitlines()
start_line = max(e.lineno - 2, 0)
end_line = min(e.lineno + 1, len(doc_lines))
error_lines = [f"{line_num:>4} | {line}" for line_num, line in zip(list(range(start_line + 1, end_line + 1)), doc_lines[start_line : end_line])][ : end_line - start_line]
error_line_index = e.lineno - start_line - 1
error_lines[error_line_index] = error_lines[error_line_index][ : 5] + f"{ANSI_RED}{error_lines[error_line_index][5 : ]}{ANSI_CLEAR}"
error_out = "\n".join(error_lines)
print(f"{ANSI_BOLD_WHITE}{input_path}:{e.lineno}:{e.colno}: {ANSI_BOLD_RED}error: {ANSI_BOLD_WHITE}{e.msg}{ANSI_CLEAR}\n{error_out}", file=sys.stderr)
sys.exit(1)
with open(output_path, "wb") as output_file:
output_file.write(parse_npc_trade(data))