Skip to content

Commit

Permalink
Identify more bit flags
Browse files Browse the repository at this point in the history
  • Loading branch information
Rangi42 committed Oct 9, 2024
1 parent ee02b0e commit 7ca0619
Show file tree
Hide file tree
Showing 67 changed files with 401 additions and 316 deletions.
2 changes: 2 additions & 0 deletions constants/battle_anim_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ DEF BATTLEANIMSTRUCT_VAR2 rb ; 10
DEF BATTLEANIMSTRUCT_LENGTH EQU _RS
DEF NUM_BATTLE_ANIM_STRUCTS EQU 10 ; see wActiveAnimObjects

DEF BATTLEANIMSTRUCT_OAMFLAGS_FIX_COORDS_F EQU 0

; wBattleAnimTileDict size (see wram.asm)
DEF NUM_BATTLEANIMTILEDICT_ENTRIES EQU 5

Expand Down
6 changes: 6 additions & 0 deletions constants/battle_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ DEF EFFECTIVE EQU 10
DEF NOT_VERY_EFFECTIVE EQU 05
DEF NO_EFFECT EQU 00

; wTypeModifier
DEF EFFECTIVENESS_MASK EQU %01111111
const_def 7
shift_const STAB_DAMAGE

; enemy AI behavior
DEF BASE_AI_SWITCH_SCORE EQU 10

Expand Down Expand Up @@ -216,6 +221,7 @@ DEF ALL_STATUS EQU (1 << PSN) | (1 << BRN) | (1 << FRZ) | (1 << PAR) | SLP_MASK
const SCREENS_SAFEGUARD
const SCREENS_LIGHT_SCREEN
const SCREENS_REFLECT
const SCREENS_UNUSED

; values in wBattleWeather
const_def
Expand Down
8 changes: 5 additions & 3 deletions constants/hardware_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ DEF RTC_M EQU $09 ; Minutes 0-59 (0-3Bh)
DEF RTC_H EQU $0a ; Hours 0-23 (0-17h)
DEF RTC_DL EQU $0b ; Lower 8 bits of Day Counter (0-FFh)
DEF RTC_DH EQU $0c ; Upper 1 bit of Day Counter, Carry Bit, Halt Flag
; Bit 0 Most significant bit of Day Counter (Bit 8)
; Bit 6 Halt (0=Active, 1=Stop Timer)
; Bit 7 Day Counter Carry Bit (1=Counter Overflow)
DEF RTC_DH_HI EQU 0 ; Most significant bit of Day Counter (Bit 8)
DEF RTC_DH_HALT EQU 6 ; Halt (0=Active, 1=Stop Timer)
DEF RTC_DH_OVERFLOW EQU 7 ; Day Counter Carry Bit (1=Counter Overflow)

; interrupt flags
DEF VBLANK EQU 0
Expand All @@ -62,6 +62,8 @@ DEF PRIORITY EQU 1 << OAM_PRIORITY ; $80

; Hardware registers
DEF rJOYP EQU $ff00 ; Joypad (R/W)
DEF rJOYP_BUTTONS EQU 4
DEF rJOYP_DPAD EQU 5
DEF rSB EQU $ff01 ; Serial transfer data (R/W)
DEF rSC EQU $ff02 ; Serial Transfer Control (R/W)
DEF rSC_ON EQU 7
Expand Down
33 changes: 11 additions & 22 deletions constants/input_constants.asm
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
; joypad buttons
const_def
const A_BUTTON_F ; 0
const B_BUTTON_F ; 1
const SELECT_F ; 2
const START_F ; 3
const D_RIGHT_F ; 4
const D_LEFT_F ; 5
const D_UP_F ; 6
const D_DOWN_F ; 7
shift_const A_BUTTON ; 0
shift_const B_BUTTON ; 1
shift_const SELECT ; 2
shift_const START ; 3
shift_const D_RIGHT ; 4
shift_const D_LEFT ; 5
shift_const D_UP ; 6
shift_const D_DOWN ; 7

DEF NO_INPUT EQU %00000000
DEF A_BUTTON EQU 1 << A_BUTTON_F
DEF B_BUTTON EQU 1 << B_BUTTON_F
DEF SELECT EQU 1 << SELECT_F
DEF START EQU 1 << START_F
DEF D_RIGHT EQU 1 << D_RIGHT_F
DEF D_LEFT EQU 1 << D_LEFT_F
DEF D_UP EQU 1 << D_UP_F
DEF D_DOWN EQU 1 << D_DOWN_F
DEF NO_INPUT EQU %00000000

DEF BUTTONS EQU A_BUTTON | B_BUTTON | SELECT | START
DEF D_PAD EQU D_RIGHT | D_LEFT | D_UP | D_DOWN

DEF R_DPAD EQU %00100000
DEF R_BUTTONS EQU %00010000
DEF BUTTONS EQU A_BUTTON | B_BUTTON | SELECT | START
DEF D_PAD EQU D_RIGHT | D_LEFT | D_UP | D_DOWN
8 changes: 1 addition & 7 deletions constants/map_data_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,8 @@ DEF NUM_MAP_PALETTES EQU const_value
const FISHGROUP_QWILFISH_NO_SWARM
DEF NUM_FISHGROUPS EQU const_value - 1

; connection directions (see data/maps/data.asm)
const_def
const EAST_F
const WEST_F
const SOUTH_F
const NORTH_F

; wMapConnections
; connection directions (see data/maps/data.asm)
const_def
shift_const EAST
shift_const WEST
Expand Down
3 changes: 3 additions & 0 deletions constants/map_setup_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ DEF NUM_MAPSETUP_SCRIPTS EQU const_value - $f1
const MAPCALLBACK_CMDQUEUE
const MAPCALLBACK_SPRITES
const MAPCALLBACK_NEWMAP

; see data/maps/setup_script_pointers.asm
DEF MAPSETUPSCRIPT_HAS_PARAM_F EQU 7
23 changes: 19 additions & 4 deletions constants/menu_constants.asm
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
; MenuHeader flags
const_def
shift_const MENU_RESTORE_TILES ; Will be set if MENU_BACKUP_TILES(_2) is set.
shift_const MENU_UNUSED_1
shift_const MENU_UNUSED_2
const_skip 2
shift_const MENU_NO_CLICK_SFX
shift_const MENU_SPRITE_ANIMS
shift_const MENU_UNUSED_3
shift_const MENU_UNUSED
shift_const MENU_BACKUP_TILES
shift_const MENU_BACKUP_TILES_2

Expand All @@ -25,8 +24,8 @@
const_def
shift_const SCROLLINGMENU_CALL_FUNCTION1_CANCEL
shift_const SCROLLINGMENU_CALL_FUNCTION3_NO_SWITCH
shift_const SCROLLINGMENU_ENABLE_LEFT
shift_const SCROLLINGMENU_ENABLE_RIGHT
shift_const SCROLLINGMENU_ENABLE_LEFT
shift_const SCROLLINGMENU_DISPLAY_ARROWS
shift_const SCROLLINGMENU_ENABLE_FUNCTION3
shift_const SCROLLINGMENU_ENABLE_START
Expand All @@ -37,6 +36,22 @@
const SCROLLINGMENU_ITEMS_NORMAL
const SCROLLINGMENU_ITEMS_QUANTITY

; _2DMenu more flags
const_def
shift_const _2DMENU_EXIT_RIGHT
shift_const _2DMENU_EXIT_LEFT
shift_const _2DMENU_EXIT_UP
shift_const _2DMENU_EXIT_DOWN
shift_const _2DMENU_WRAP_LEFT_RIGHT
shift_const _2DMENU_WRAP_UP_DOWN
shift_const _2DMENU_ENABLE_SPRITE_ANIMS
shift_const _2DMENU_DISABLE_JOYPAD_FILTER

; _2DMenu more flags 2
const_def
const_skip 7
shift_const _2DMENU_EXITING

; MonMenuOptions indexes (see data/mon_menu.asm)
; used by PokemonActionSubmenu (see engine/pokemon/mon_menu.asm)
const_def 1
Expand Down
11 changes: 11 additions & 0 deletions constants/printer_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,14 @@
const PRINTER_ERROR_2
const PRINTER_ERROR_3
const PRINTER_ERROR_4

; wPrinterStatusFlags
const_def 5
shift_const PRINTER_STATUS_ERROR_3
shift_const PRINTER_STATUS_ERROR_4
shift_const PRINTER_STATUS_ERROR_1

; wPrinterConnectionOpen
const_def
const PRINTER_CONNECTION_OPEN
const PRINTER_CONNECTION_SUCCESS
55 changes: 45 additions & 10 deletions constants/ram_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ DEF GBPRINTER_DARKEST EQU $7f
const_def
const MENU_ACCOUNT ; 0

; wDST::
DEF DST_F EQU 7

; wWalkingDirection::
const_def -1
const STANDING ; -1
Expand Down Expand Up @@ -96,6 +99,10 @@ DEF LAST_12_SPRITE_OAM_STRUCTS_RESERVED_F EQU 1
DEF TEXT_STATE_F EQU 6
DEF SCRIPTED_MOVEMENT_STATE_F EQU 7

; wSpriteFlags::
DEF SPRITES_SKIP_WALKING_GFX_F EQU 6
DEF SPRITES_SKIP_STANDING_GFX_F EQU 7

; wPokemonWithdrawDepositParameter::
DEF PC_WITHDRAW EQU 0
DEF PC_DEPOSIT EQU 1
Expand All @@ -118,21 +125,23 @@ DEF INIT_OTHER_ITEM_LIST EQU 3
DEF INIT_PLAYEROT_LIST EQU 4
DEF INIT_MON_LIST EQU 5

; wEnteredMapFromContinue::
DEF ENTERED_MAP_FROM_CONTINUE_2 EQU 2
DEF ENTERED_MAP_FROM_CONTINUE_7 EQU 7

; wTimeOfDay::
const_def
const MORN_F ; 0
const DAY_F ; 1
const NITE_F ; 2
const DARKNESS_F ; 3
shift_const MORN ; 0
shift_const DAY ; 1
shift_const NITE ; 2
shift_const DARKNESS ; 3
DEF NUM_DAYTIMES EQU const_value

DEF MORN EQU 1 << MORN_F
DEF DAY EQU 1 << DAY_F
DEF NITE EQU 1 << NITE_F
DEF DARKNESS EQU 1 << DARKNESS_F

DEF ANYTIME EQU MORN | DAY | NITE

; wTimeOfDayPalFlags
DEF FORCED_PALSET_F EQU 7

; wTimeOfDayPalset::
DEF DARKNESS_PALSET EQU (DARKNESS_F << 6) | (DARKNESS_F << 4) | (DARKNESS_F << 2) | DARKNESS_F

Expand All @@ -143,6 +152,10 @@ DEF DARKNESS_PALSET EQU (DARKNESS_F << 6) | (DARKNESS_F << 4) | (DARKNESS_F << 2
const BATTLEANIM_IN_LOOP_F ; 2
const BATTLEANIM_KEEPSPRITES_F ; 3

; wBattleScriptFlags::
DEF BATTLESCRIPT_WILD_F EQU 0
DEF BATTLESCRIPT_SCRIPTED_F EQU 7

; wPlayerSpriteSetupFlags::
DEF PLAYERSPRITESETUP_FACING_MASK EQU %11
DEF PLAYERSPRITESETUP_FEMALE_TO_MALE_F EQU 2
Expand All @@ -163,7 +176,20 @@ DEF PLAYERSPRITESETUP_RESET_ACTION_F EQU 7
const MAPEVENTS_OFF ; 1

; wScriptFlags::
DEF SCRIPT_RUNNING EQU 2
const_def
const SCRIPT_FLAG_0
const SCRIPT_FLAG_1
const SCRIPT_RUNNING
const RUN_DEFERRED_SCRIPT

; wEnabledPlayerEvents::
const_def
const PLAYEREVENTS_COUNT_STEPS
const PLAYEREVENTS_COORD_EVENTS
const PLAYEREVENTS_WARPS_AND_CONNECTIONS
const_skip
const PLAYEREVENTS_WILD_ENCOUNTERS
const PLAYEREVENTS_5

; wScriptMode::
const_def
Expand All @@ -176,6 +202,9 @@ DEF SCRIPT_RUNNING EQU 2
DEF SPAWN_LANCE EQU 1
DEF SPAWN_RED EQU 2

; wGameTimeCap::
DEF GAME_TIME_CAPPED EQU 0

; wCurDay::
const_def
const SUNDAY ; 0
Expand Down Expand Up @@ -300,6 +329,12 @@ DEF DAYCARELADY_HAS_MON_F EQU 0
; shared flag between wDayCareMan and wDayCareLady
DEF DAYCARE_INTRO_SEEN_F EQU 7

; sRTCStatusFlags::
const_def 5
shift_const RTC_DAYS_EXCEED_139
shift_const RTC_DAYS_EXCEED_255
shift_const RTC_RESET

; hVBlank::
; VBlankHandlers indexes (see home/vblank.asm)
const_def
Expand Down
13 changes: 4 additions & 9 deletions constants/text_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,11 @@ DEF TEXTBOX_INNERY EQU TEXTBOX_Y + 2
; see gfx/frames/*.png
DEF TEXTBOX_FRAME_TILES EQU 6

; PrintNum bit flags
; PrintNum bit flags (see engine/math/print_num.asm)
const_def 5
const PRINTNUM_MONEY_F ; 5
const PRINTNUM_LEFTALIGN_F ; 6
const PRINTNUM_LEADINGZEROS_F ; 7

; PrintNum arguments (see engine/math/print_num.asm)
DEF PRINTNUM_MONEY EQU 1 << PRINTNUM_MONEY_F
DEF PRINTNUM_LEFTALIGN EQU 1 << PRINTNUM_LEFTALIGN_F
DEF PRINTNUM_LEADINGZEROS EQU 1 << PRINTNUM_LEADINGZEROS_F
shift_const PRINTNUM_MONEY ; 5
shift_const PRINTNUM_LEFTALIGN ; 6
shift_const PRINTNUM_LEADINGZEROS ; 7

; character sets (see charmap.asm)
DEF FIRST_REGULAR_TEXT_CHAR EQU $60
Expand Down
12 changes: 11 additions & 1 deletion data/maps/setup_script_pointers.asm
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
MACRO add_mapsetup
\1_MapSetupCmd:
dba \1
; A second argument of TRUE indicates taking a parameter.
if _NARG == 2
if \2
db (1 << MAPSETUPSCRIPT_HAS_PARAM_F) | BANK(\1)
dw \1
else
dba \1
endc
else
dba \1
endc
ENDM

MapSetupCommands:
Expand Down
4 changes: 4 additions & 0 deletions data/maps/setup_scripts.asm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ MapSetupScripts:
; valid commands are listed in MapSetupCommands (see data/maps/setup_script_pointers.asm)
MACRO mapsetup
db (\1_MapSetupCmd - MapSetupCommands) / 3
; `mapsetup` takes a parameter if `add_mapsetup` indicates taking one.
if _NARG == 2
db \2 ; param
endc
ENDM

MapSetupScript_Teleport:
Expand Down
2 changes: 1 addition & 1 deletion engine/battle/ai/redundant.asm
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ AI_Redundant:
.FutureSight:
; BUG: AI does not discourage Future Sight when it's already been used (see docs/bugs_and_glitches.md)
ld a, [wEnemyScreens]
bit 5, a
bit SCREENS_UNUSED, a
ret

.Heal:
Expand Down
Loading

0 comments on commit 7ca0619

Please sign in to comment.