Skip to content

Commit

Permalink
Merge pull request #121 from lhearachel/constgen
Browse files Browse the repository at this point in the history
Generate enum-based battle constants at build-time
  • Loading branch information
lhearachel authored Jan 9, 2024
2 parents 0ae74e2 + 7bf253a commit 1bacaf3
Show file tree
Hide file tree
Showing 13 changed files with 619 additions and 571 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
/subprojects/libpng-*/
/subprojects/zlib-*/
/subprojects/packagecache
/subprojects/constgen/

# CLion folders
.idea/
Expand Down
554 changes: 554 additions & 0 deletions consts/battle.json

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions consts/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
consts_manifests = files(
'battle.json'
)

gen_consts_includes = include_directories('.')

gen_consts_root = meson.current_build_dir() / 'generated'
gen_c_consts_root = gen_consts_root / 'c'
gen_asm_consts_root = gen_consts_root / 'asm'

generated_c_consts = custom_target('gen_c_consts',
build_by_default: true,
capture: true,
output: 'gen_c_consts',
input: consts_manifests,
command: [
constgen_py,
'-f', '@INPUT@',
'-r', gen_c_consts_root,
'-l', 'c'
]
)
3 changes: 2 additions & 1 deletion include/constants/battle.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef POKEPLATINUM_CONSTANTS_BATTLE_H
#define POKEPLATINUM_CONSTANTS_BATTLE_H

#include "constants/battle/battle_effects.h"
#include "constants/battle/condition.h"
#include "constants/battle/message_tags.h"
#include "constants/battle/moves.h"
Expand All @@ -11,6 +10,8 @@
#include "constants/battle/terrain.h"
#include "constants/battle/turn_flags.h"

#include "consts/generated/c/battle.h"

#define BATTLE_TYPE_SINGLES (0 << 0)
#define BATTLE_TYPE_WILD_MON (0 << 0)
#define BATTLE_TYPE_TRAINER (1 << 0)
Expand Down
284 changes: 0 additions & 284 deletions include/constants/battle/battle_effects.h

This file was deleted.

44 changes: 21 additions & 23 deletions include/constants/battle/condition.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,28 +103,26 @@
#define FIELD_CONDITION_GRAVITY_SHIFT 12
#define FIELD_CONDITION_TRICK_ROOM_SHIFT 16

enum {
OVERWORLD_WEATHER_CLEAR = 0,
OVERWORLD_WEATHER_CLOUDY,
OVERWORLD_WEATHER_RAINING,
OVERWORLD_WEATHER_HEAVY_RAIN,
OVERWORLD_WEATHER_THUNDERSTORM,
OVERWORLD_WEATHER_SNOWING,
OVERWORLD_WEATHER_HEAVY_SNOW,
OVERWORLD_WEATHER_BLIZZARD,
OVERWORLD_WEATHER_CLEAR_8,
OVERWORLD_WEATHER_SLOW_ASHFALL,
OVERWORLD_WEATHER_SANDSTORM,
OVERWORLD_WEATHER_HAILING,
OVERWORLD_WEATHER_SPIRITS,
OVERWORLD_WEATHER_CLEAR_13,
OVERWORLD_WEATHER_FOG,
OVERWORLD_WEATHER_DEEP_FOG,
OVERWORLD_WEATHER_DARK_FLASH,

// these are only for the Battle Frontier
OVERWORLD_WEATHER_HARSH_SUN = 1001,
OVERWORLD_WEATHER_TRICK_ROOM,
};
#define OVERWORLD_WEATHER_CLEAR 0
#define OVERWORLD_WEATHER_CLOUDY 1
#define OVERWORLD_WEATHER_RAINING 2
#define OVERWORLD_WEATHER_HEAVY_RAIN 3
#define OVERWORLD_WEATHER_THUNDERSTORM 4
#define OVERWORLD_WEATHER_SNOWING 5
#define OVERWORLD_WEATHER_HEAVY_SNOW 6
#define OVERWORLD_WEATHER_BLIZZARD 7
#define OVERWORLD_WEATHER_CLEAR_8 8
#define OVERWORLD_WEATHER_SLOW_ASHFALL 9
#define OVERWORLD_WEATHER_SANDSTORM 10
#define OVERWORLD_WEATHER_HAILING 11
#define OVERWORLD_WEATHER_SPIRITS 12
#define OVERWORLD_WEATHER_CLEAR_13 13
#define OVERWORLD_WEATHER_FOG 14
#define OVERWORLD_WEATHER_DEEP_FOG 15
#define OVERWORLD_WEATHER_DARK_FLASH 16

// these are only for the Battle Frontier
#define OVERWORLD_WEATHER_HARSH_SUN 1001
#define OVERWORLD_WEATHER_TRICK_ROOM 1002

#endif // POKEPLATINUM_CONSTANTS_BATTLE_CONDITION_H
Loading

0 comments on commit 1bacaf3

Please sign in to comment.