shithub: pokecrystal

Download patch

ref: e8ddecd0eb1b79f2436f1ea8a0f2163bedec7550
parent: b24cd55f968909c3ec29c6455a32463c987f3063
parent: 476f9ba40d5b59fd724ac1234b34448df372d52c
author: Rangi <35663410+Rangi42@users.noreply.github.com>
date: Sat May 25 09:54:29 EDT 2019

Merge pull request #636 from mid-kid/patch

Small cleanups

--- a/Makefile
+++ b/Makefile
@@ -65,9 +65,9 @@
 	$(MAKE) -C tools/
 
 
-$(crystal_obj):   RGBASMFLAGS = -D _CRYSTAL
-$(crystal11_obj): RGBASMFLAGS = -D _CRYSTAL -D _CRYSTAL11
-$(crystal_au_obj): RGBASMFLAGS = -D _CRYSTAL -D _CRYSTAL11 -D _CRYSTAL_AU
+$(crystal_obj):   RGBASMFLAGS =
+$(crystal11_obj): RGBASMFLAGS = -D _CRYSTAL11
+$(crystal_au_obj): RGBASMFLAGS = -D _CRYSTAL11 -D _CRYSTAL_AU
 
 # The dep rules have to be explicit or else missing files won't be reported.
 # As a side effect, they're evaluated immediately instead of when the rule is invoked.
--- a/constants/deco_constants.asm
+++ b/constants/deco_constants.asm
@@ -62,8 +62,8 @@
 ; decorations:
 ; - DecorationAttributes (see data/decorations/attributes.asm)
 ; - DecorationIDs (see data/decorations/decorations.asm)
-const_value = 1
-__enum__ = 0
+	const_def 1
+	enum_start
 ; FindOwnedBeds.beds values (see engine/overworld/decorations.asm)
 	const BEDS
 	deco  FEATHERY_BED
@@ -121,7 +121,7 @@
 	deco  GEODUDE_DOLL
 	deco  MACHOP_DOLL
 	deco  TENTACOOL_DOLL
-NUM_NON_TROPHY_DECOS = __enum__
+NUM_NON_TROPHY_DECOS EQU __enum__
 	deco  GOLD_TROPHY_DOLL
 	deco  SILVER_TROPHY_DOLL
-NUM_DECOS = __enum__
+NUM_DECOS EQU __enum__
--- a/constants/hardware_constants.asm
+++ b/constants/hardware_constants.asm
@@ -42,6 +42,7 @@
 TIMER    EQU 2
 SERIAL   EQU 3
 JOYPAD   EQU 4
+IE_DEFAULT EQU (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK)
 
 ; OAM attribute flags
 OAM_TILE_BANK EQU 3
--- a/constants/item_constants.asm
+++ b/constants/item_constants.asm
@@ -199,7 +199,7 @@
 
 add_tm: MACRO
 if !DEF(TM01)
-TM01 = const_value
+TM01 EQU const_value
 	enum_start 1
 endc
 	define _\@_1, "TM_\1"
@@ -260,11 +260,11 @@
 	add_tm FIRE_PUNCH   ; f0
 	add_tm FURY_CUTTER  ; f1
 	add_tm NIGHTMARE    ; f2
-NUM_TMS = const_value - TM01 - 2 ; discount ITEM_C3 and ITEM_DC
+NUM_TMS EQU const_value - TM01 - 2 ; discount ITEM_C3 and ITEM_DC
 
 add_hm: MACRO
 if !DEF(HM01)
-HM01 = const_value
+HM01 EQU const_value
 endc
 	define _\@_1, "HM_\1"
 	const _\@_1
@@ -278,7 +278,7 @@
 	add_hm FLASH        ; f7
 	add_hm WHIRLPOOL    ; f8
 	add_hm WATERFALL    ; f9
-NUM_HMS = const_value - HM01
+NUM_HMS EQU const_value - HM01
 
 add_mt: MACRO
 	enum \1_TMNUM
@@ -287,7 +287,7 @@
 	add_mt FLAMETHROWER
 	add_mt THUNDERBOLT
 	add_mt ICE_BEAM
-NUM_TM_HM_TUTOR = __enum__ + -1
+NUM_TM_HM_TUTOR EQU __enum__ + -1
 
 	const ITEM_FA       ; fa
 
--- a/data/pokemon/egg_move_pointers.asm
+++ b/data/pokemon/egg_move_pointers.asm
@@ -118,11 +118,7 @@
 	dw NoEggMoves
 	dw GoldeenEggMoves
 	dw NoEggMoves
-if _CRYSTAL
 	dw NoEggMoves
-else
-	dw StaryuEggMoves
-endc
 	dw NoEggMoves
 	dw MrMimeEggMoves
 	dw ScytherEggMoves
--- a/data/pokemon/egg_moves.asm
+++ b/data/pokemon/egg_moves.asm
@@ -17,9 +17,6 @@
 	db LIGHT_SCREEN
 	db SKULL_BASH
 	db SAFEGUARD
-if !_CRYSTAL
-	db CHARM
-endc
 	db RAZOR_WIND
 	db PETAL_DANCE
 	db -1 ; end
@@ -46,9 +43,6 @@
 	db PURSUIT
 	db FAINT_ATTACK
 	db FORESIGHT
-if !_CRYSTAL
-	db STEEL_WING
-endc
 	db -1 ; end
 
 RattataEggMoves:
@@ -73,9 +67,7 @@
 	db SLAM
 	db SPITE
 	db BEAT_UP
-if _CRYSTAL
 	db CRUNCH
-endc
 	db -1 ; end
 
 SandshrewEggMoves:
@@ -83,9 +75,7 @@
 	db SAFEGUARD
 	db COUNTER
 	db RAPID_SPIN
-if _CRYSTAL
 	db METAL_CLAW
-endc
 	db -1 ; end
 
 NidoranFEggMoves:
@@ -129,9 +119,6 @@
 	db RAZOR_LEAF
 	db FLAIL
 	db SYNTHESIS
-if !_CRYSTAL
-	db CHARM
-endc
 	db -1 ; end
 
 ParasEggMoves:
@@ -140,9 +127,6 @@
 	db COUNTER
 	db PSYBEAM
 	db FLAIL
-if !_CRYSTAL
-	db SWEET_SCENT
-endc
 	db LIGHT_SCREEN
 	db PURSUIT
 	db -1 ; end
@@ -176,9 +160,7 @@
 	db LIGHT_SCREEN
 	db FUTURE_SIGHT
 	db PSYCHIC_M
-if _CRYSTAL
 	db CROSS_CHOP
-endc
 	db -1 ; end
 
 MankeyEggMoves:
@@ -257,9 +239,6 @@
 	db -1 ; end
 
 FarfetchDEggMoves:
-if !_CRYSTAL
-	db STEEL_WING
-endc
 	db FORESIGHT
 	db MIRROR_MOVE
 	db GUST
@@ -337,9 +316,7 @@
 	db SCREECH
 	db SKULL_BASH
 	db PERISH_SONG
-if _CRYSTAL
 	db SWORDS_DANCE
-endc
 	db -1 ; end
 
 LickitungEggMoves:
@@ -403,14 +380,6 @@
 	db HYDRO_PUMP
 	db -1 ; end
 
-if !_CRYSTAL
-StaryuEggMoves:
-	db AURORA_BEAM
-	db BARRIER
-	db SUPERSONIC
-	db -1 ; end
-endc
-
 MrMimeEggMoves:
 	db FUTURE_SIGHT
 	db HYPNOSIS
@@ -461,16 +430,10 @@
 	db WHIRLWIND
 	db PURSUIT
 	db FORESIGHT
-if !_CRYSTAL
-	db STEEL_WING
-endc
 	db -1 ; end
 
 SnorlaxEggMoves:
 	db LICK
-if !_CRYSTAL
-	db CHARM
-endc
 	db -1 ; end
 
 DratiniEggMoves:
@@ -495,9 +458,7 @@
 	db REVERSAL
 	db THRASH
 	db FORESIGHT
-if _CRYSTAL
 	db SUBMISSION
-endc
 	db -1 ; end
 
 TotodileEggMoves:
@@ -523,9 +484,7 @@
 	db FAINT_ATTACK
 	db WING_ATTACK
 	db WHIRLWIND
-if _CRYSTAL
 	db SKY_ATTACK
-endc
 	db -1 ; end
 
 LedybaEggMoves:
@@ -650,9 +609,7 @@
 	db QUICK_ATTACK
 	db MIRROR_MOVE
 	db WING_ATTACK
-if _CRYSTAL
 	db SKY_ATTACK
-endc
 	db -1 ; end
 
 MisdreavusEggMoves:
@@ -732,9 +689,7 @@
 	db SEISMIC_TOSS
 	db FOCUS_ENERGY
 	db COUNTER
-if _CRYSTAL
 	db METAL_CLAW
-endc
 	db -1 ; end
 
 SlugmaEggMoves:
@@ -784,9 +739,7 @@
 	db DRILL_PECK
 	db PURSUIT
 	db WHIRLWIND
-if _CRYSTAL
 	db SKY_ATTACK
-endc
 	db -1 ; end
 
 HoundourEggMoves:
@@ -803,9 +756,7 @@
 	db FOCUS_ENERGY
 	db BODY_SLAM
 	db ANCIENTPOWER
-if _CRYSTAL
 	db WATER_GUN
-endc
 	db -1 ; end
 
 StantlerEggMoves:
@@ -824,9 +775,6 @@
 	db -1 ; end
 
 SmoochumEggMoves:
-if !_CRYSTAL
-	db LOVELY_KISS
-endc
 	db MEDITATE
 	db -1 ; end
 
@@ -835,9 +783,7 @@
 	db BARRIER
 	db ROLLING_KICK
 	db MEDITATE
-if _CRYSTAL
 	db CROSS_CHOP
-endc
 	db -1 ; end
 
 MagbyEggMoves:
@@ -845,9 +791,7 @@
 	db MEGA_PUNCH
 	db BARRIER
 	db SCREECH
-if _CRYSTAL
 	db CROSS_CHOP
-endc
 	db -1 ; end
 
 MiltankEggMoves:
--- a/data/pokemon/evos_attacks.asm
+++ b/data/pokemon/evos_attacks.asm
@@ -670,9 +670,7 @@
 
 DugtrioEvosAttacks:
 	db 0 ; no more evolutions
-if _CRYSTAL
 	db 1, TRI_ATTACK
-endc
 	db 1, SCRATCH
 	db 1, GROWL
 	db 1, MAGNITUDE
@@ -1115,11 +1113,7 @@
 	db 16, SONICBOOM
 	db 21, THUNDER_WAVE
 	db 27, LOCK_ON
-if _CRYSTAL
 	db 35, TRI_ATTACK
-else
-	db 35, SWIFT
-endc
 	db 43, SCREECH
 	db 53, ZAP_CANNON
 	db 0 ; no more level-up moves
@@ -1235,9 +1229,7 @@
 	db 1, SUPERSONIC
 	db 1, AURORA_BEAM
 	db 1, PROTECT
-if _CRYSTAL
 	db 33, SPIKES
-endc
 	db 41, SPIKE_CANNON
 	db 0 ; no more level-up moves
 
@@ -1814,11 +1806,7 @@
 	db 16, GROWL
 	db 23, QUICK_ATTACK
 	db 30, BITE
-if _CRYSTAL
 	db 36, BATON_PASS
-else
-	db 36, FOCUS_ENERGY
-endc
 	db 42, TAKE_DOWN
 	db 0 ; no more level-up moves
 
@@ -2297,11 +2285,7 @@
 	db 23, LEECH_LIFE
 	db 30, FURY_SWIPES
 	db 37, SPIDER_WEB
-if _CRYSTAL
 	db 45, AGILITY
-else
-	db 45, SCREECH
-endc
 	db 53, PSYCHIC_M
 	db 0 ; no more level-up moves
 
@@ -2317,11 +2301,7 @@
 	db 25, LEECH_LIFE
 	db 34, FURY_SWIPES
 	db 43, SPIDER_WEB
-if _CRYSTAL
 	db 53, AGILITY
-else
-	db 53, SCREECH
-endc
 	db 63, PSYCHIC_M
 	db 0 ; no more level-up moves
 
@@ -2544,11 +2524,7 @@
 	db EVOLVE_LEVEL, 18, SKIPLOOM
 	db 0 ; no more evolutions
 	db 1, SPLASH
-if _CRYSTAL
 	db 5, SYNTHESIS
-else
-	db 1, SYNTHESIS
-endc
 	db 5, TAIL_WHIP
 	db 10, TACKLE
 	db 13, POISONPOWDER
@@ -2566,9 +2542,7 @@
 	db 1, SYNTHESIS
 	db 1, TAIL_WHIP
 	db 1, TACKLE
-if _CRYSTAL
 	db 5, SYNTHESIS
-endc
 	db 5, TAIL_WHIP
 	db 10, TACKLE
 	db 13, POISONPOWDER
@@ -2585,9 +2559,7 @@
 	db 1, SYNTHESIS
 	db 1, TAIL_WHIP
 	db 1, TACKLE
-if _CRYSTAL
 	db 5, SYNTHESIS
-endc
 	db 5, TAIL_WHIP
 	db 10, TACKLE
 	db 13, POISONPOWDER
@@ -2641,11 +2613,7 @@
 	db 19, SONICBOOM
 	db 25, DETECT
 	db 31, SUPERSONIC
-if _CRYSTAL
 	db 37, WING_ATTACK
-else
-	db 37, SWIFT
-endc
 	db 43, SCREECH
 	db 0 ; no more level-up moves
 
@@ -2857,9 +2825,7 @@
 
 QwilfishEvosAttacks:
 	db 0 ; no more evolutions
-if _CRYSTAL
 	db 1, SPIKES
-endc
 	db 1, TACKLE
 	db 1, POISON_STING
 	db 10, HARDEN
@@ -2919,9 +2885,7 @@
 	db 41, AGILITY
 	db 49, SLASH
 	db 57, BEAT_UP
-if _CRYSTAL
 	db 65, METAL_CLAW
-endc
 	db 0 ; no more level-up moves
 
 TeddiursaEvosAttacks:
@@ -2989,9 +2953,7 @@
 	db 28, TAKE_DOWN
 	db 37, MIST
 	db 46, BLIZZARD
-if _CRYSTAL
 	db 55, AMNESIA
-endc
 	db 0 ; no more level-up moves
 
 PiloswineEvosAttacks:
@@ -3005,9 +2967,7 @@
 	db 33, FURY_ATTACK
 	db 42, MIST
 	db 56, BLIZZARD
-if _CRYSTAL
 	db 70, AMNESIA
-endc
 	db 0 ; no more level-up moves
 
 CorsolaEvosAttacks:
@@ -3300,17 +3260,10 @@
 	db 0 ; no more evolutions
 	db 1, BITE
 	db 1, LEER
-if _CRYSTAL
 	db 11, BUBBLEBEAM
 	db 21, RAIN_DANCE
 	db 31, GUST
 	db 41, AURORA_BEAM
-else
-	db 11, WATER_GUN
-	db 21, ROAR
-	db 31, GUST
-	db 41, BUBBLEBEAM
-endc
 	db 51, MIST
 	db 61, MIRROR_COAT
 	db 71, HYDRO_PUMP
--- a/docs/design_flaws.md
+++ b/docs/design_flaws.md
@@ -332,7 +332,7 @@
 	add_tm PSYCHIC_M    ; dd
 	...
 	add_tm NIGHTMARE    ; f2
-NUM_TMS = const_value - TM01 - 2 ; discount ITEM_C3 and ITEM_DC
+NUM_TMS EQU const_value - TM01 - 2 ; discount ITEM_C3 and ITEM_DC
 ```
 
 `GetTMHMNumber` and `GetNumberedTMHM` in [engine/items/items.asm](https://github.com/pret/pokecrystal/blob/master/engine/items/items.asm) have to compensate for this.
--- a/engine/events/magnet_train.asm
+++ b/engine/events/magnet_train.asm
@@ -3,14 +3,14 @@
 	and a
 	jr nz, .ToGoldenrod
 	ld a, 1 ; forwards
-	lb bc,  $40,  $60
-	lb de, (11 * 8) - (11 * 8 + 4), -$60
+	lb bc, 8 * TILE_WIDTH, 12 * TILE_WIDTH
+	lb de, (11 * TILE_WIDTH) - (11 * TILE_WIDTH + 4), -12 * TILE_WIDTH
 	jr .continue
 
 .ToGoldenrod:
 	ld a, -1 ; backwards
-	lb bc, -$40, -$60
-	lb de, (11 * 8) + (11 * 8 + 4), $60
+	lb bc, -8 * TILE_WIDTH, -12 * TILE_WIDTH
+	lb de, (11 * TILE_WIDTH) + (11 * TILE_WIDTH + 4), 12 * TILE_WIDTH
 
 .continue
 	ld h, a
@@ -34,11 +34,11 @@
 	push af
 	ldh a, [hSCY]
 	push af
-	call MagntTrain_LoadGFX_PlayMusic
+	call MagnetTrain_LoadGFX_PlayMusic
 	ld hl, hVBlank
 	ld a, [hl]
 	push af
-	ld [hl], $1
+	ld [hl], 1
 .loop
 	ld a, [wJumptableIndex]
 	and a
@@ -84,18 +84,19 @@
 
 MagnetTrain_UpdateLYOverrides:
 	ld hl, wLYOverridesBackup
-	ld c, $2f
+	ld c, 6 * TILE_WIDTH - 1
 	ld a, [wMagnetTrainOffset]
 	add a
 	ldh [hSCX], a
 	call .loadloop
-	ld c, $30
+	ld c, 6 * TILE_WIDTH
 	ld a, [wMagnetTrainPosition]
 	call .loadloop
-	ld c, $31
+	ld c, 6 * TILE_WIDTH + 1
 	ld a, [wMagnetTrainOffset]
 	add a
 	call .loadloop
+
 	ld a, [wMagnetTrainDirection]
 	ld d, a
 	ld hl, wMagnetTrainOffset
@@ -111,7 +112,7 @@
 	jr nz, .loadloop
 	ret
 
-MagntTrain_LoadGFX_PlayMusic:
+MagnetTrain_LoadGFX_PlayMusic:
 	call ClearBGPalettes
 	call ClearSprites
 	call DisableLCD
@@ -118,7 +119,7 @@
 	callfar ClearSpriteAnims
 	call SetMagnetTrainPals
 	call DrawMagnetTrain
-	ld a, $90
+	ld a, SCREEN_HEIGHT_PX
 	ldh [hWY], a
 	call EnableLCD
 	xor a
@@ -125,6 +126,8 @@
 	ldh [hBGMapMode], a
 	ldh [hSCX], a
 	ldh [hSCY], a
+
+	; Load the player sprite
 	ldh a, [rSVBK]
 	push af
 	ld a, BANK(wPlayerGender)
@@ -135,6 +138,8 @@
 	ld hl, vTiles0
 	ld c, 4
 	call Request2bpp
+
+	; Load the trainer walking frame
 	ld hl, 12 tiles
 	add hl, de
 	ld d, h
@@ -142,7 +147,9 @@
 	ld hl, vTiles0 tile $04
 	ld c, 4
 	call Request2bpp
+
 	call MagnetTrain_InitLYOverrides
+
 	ld hl, wJumptableIndex
 	xor a
 	ld [hli], a ; wJumptableIndex
@@ -150,6 +157,7 @@
 	ld [hli], a ; wMagnetTrainOffset
 	ld [hli], a ; wMagnetTrainPosition
 	ld [hli], a ; wMagnetTrainWaitCounter
+
 	ld de, MUSIC_MAGNET_TRAIN
 	call PlayMusic2
 	ret
@@ -159,25 +167,26 @@
 	xor a
 .loop
 	call GetMagnetTrainBGTiles
-	ld b, 32 / 2
+	ld b, BG_MAP_WIDTH / 2
 	call .FillAlt
 	inc a
-	cp $12
+	cp SCREEN_HEIGHT
 	jr c, .loop
+
 	hlbgcoord 0, 6
-	ld de, MagnetTrainTilemap1
+	ld de, MagnetTrainTilemap
 	ld c, 20
 	call .FillLine
 	hlbgcoord 0, 7
-	ld de, MagnetTrainTilemap2
+	ld de, MagnetTrainTilemap + 20
 	ld c, 20
 	call .FillLine
 	hlbgcoord 0, 8
-	ld de, MagnetTrainTilemap3
+	ld de, MagnetTrainTilemap + (20 * 2)
 	ld c, 20
 	call .FillLine
 	hlbgcoord 0, 9
-	ld de, MagnetTrainTilemap4
+	ld de, MagnetTrainTilemap + (20 * 3)
 	ld c, 20
 	call .FillLine
 	ret
@@ -247,7 +256,7 @@
 	ret
 
 SetMagnetTrainPals:
-	ld a, $1
+	ld a, 1
 	ldh [rVBK], a
 
 	; bushes
@@ -274,7 +283,7 @@
 	ld a, PAL_BG_YELLOW
 	call ByteFill
 
-	ld a, $0
+	ld a, 0
 	ldh [rVBK], a
 	ret
 
@@ -305,7 +314,7 @@
 	ret
 
 .InitPlayerSpriteAnim:
-	ld d, 10 * 8 + 5
+	ld d, (8 + 2) * TILE_WIDTH + 5
 	ld a, [wMagnetTrainPlayerSpriteInitX]
 	ld e, a
 	ld b, SPRITE_ANIM_INDEX_MAGNET_TRAIN_RED
@@ -317,7 +326,6 @@
 	bit PLAYERGENDER_FEMALE_F, a
 	jr z, .got_gender
 	ld b, SPRITE_ANIM_INDEX_MAGNET_TRAIN_BLUE
-
 .got_gender
 	pop af
 	ldh [rSVBK], a
@@ -325,9 +333,9 @@
 	call _InitSpriteAnimStruct
 	ld hl, SPRITEANIMSTRUCT_TILE_ID
 	add hl, bc
-	ld [hl], $0
+	ld [hl], 0
 	call .Next
-	ld a, $80
+	ld a, 128
 	ld [wMagnetTrainWaitCounter], a
 	ret
 
@@ -350,7 +358,7 @@
 
 .PrepareToHoldTrain:
 	call .Next
-	ld a, $80
+	ld a, 128
 	ld [wMagnetTrainWaitCounter], a
 	ret
 
@@ -408,6 +416,7 @@
 	call MagnetTrain_UpdateLYOverrides
 	call PushLYOverrides
 	call DelayFrame
+
 	ldh a, [rSVBK]
 	push af
 	ld a, BANK(wEnvironment)
@@ -416,14 +425,16 @@
 	push af
 	ld a, [wEnvironment]
 	push af
+
 	ld a, [wTimeOfDay]
 	maskbits NUM_DAYTIMES
 	ld [wTimeOfDayPal], a
-	ld a, $1
+	ld a, TOWN
 	ld [wEnvironment], a
 	ld b, SCGB_MAPPALS
 	call GetSGBLayout
 	call UpdateTimePals
+
 	ldh a, [rBGP]
 	ld [wBGP], a
 	ldh a, [rOBP0]
@@ -430,6 +441,7 @@
 	ld [wOBP0], a
 	ldh a, [rOBP1]
 	ld [wOBP1], a
+
 	pop af
 	ld [wEnvironment], a
 	pop af
@@ -438,11 +450,8 @@
 	ldh [rSVBK], a
 	ret
 
-MagnetTrainTilemap1:
+MagnetTrainTilemap:
 	db $1f, $05, $06, $0a, $0a, $0a, $09, $0a, $0a, $0a, $0a, $0a, $0a, $09, $0a, $0a, $0a, $0b, $0c, $1f
-MagnetTrainTilemap2:
 	db $14, $15, $16, $1a, $1a, $1a, $19, $1a, $1a, $1a, $1a, $1a, $1a, $19, $1a, $1a, $1a, $1b, $1c, $1d
-MagnetTrainTilemap3:
 	db $24, $25, $26, $27, $07, $2f, $29, $28, $28, $28, $28, $28, $28, $29, $07, $2f, $2a, $2b, $2c, $2d
-MagnetTrainTilemap4:
 	db $20, $1f, $2e, $1f, $17, $00, $2e, $1f, $1f, $1f, $1f, $1f, $1f, $2e, $17, $00, $1f, $2e, $1f, $0f
--- a/engine/link/link.asm
+++ b/engine/link/link.asm
@@ -50,17 +50,17 @@
 	call DelayFrames
 	xor a
 	ldh [hSerialSend], a
-	ld a, (0 << rSC_ON) | 1
+	ld a, (0 << rSC_ON) | (1 << rSC_CLOCK)
 	ldh [rSC], a
-	ld a, (1 << rSC_ON) | 1
+	ld a, (1 << rSC_ON) | (1 << rSC_CLOCK)
 	ldh [rSC], a
 
 	call DelayFrame
 	xor a
 	ldh [hSerialSend], a
-	ld a, (0 << rSC_ON) | 1
+	ld a, (0 << rSC_ON) | (1 << rSC_CLOCK)
 	ldh [rSC], a
-	ld a, (1 << rSC_ON) | 1
+	ld a, (1 << rSC_ON) | (1 << rSC_CLOCK)
 	ldh [rSC], a
 
 .player_1
@@ -70,7 +70,7 @@
 	call DelayFrames
 	xor a
 	ldh [rIF], a
-	ld a, $8
+	ld a, 1 << SERIAL
 	ldh [rIE], a
 	ld hl, wd1f3
 	ld de, wEnemyMonSpecies
@@ -90,7 +90,7 @@
 	call Serial_ExchangeBytes
 	xor a
 	ldh [rIF], a
-	ld a, $1d
+	ld a, (1 << JOYPAD) | (1 << SERIAL) | (1 << TIMER) | (1 << VBLANK)
 	ldh [rIE], a
 	call Link_CopyRandomNumbers
 	ld hl, wOTPlayerName
@@ -194,17 +194,17 @@
 	call DelayFrames
 	xor a
 	ldh [hSerialSend], a
-	ld a, (0 << rSC_ON) | 1
+	ld a, (0 << rSC_ON) | (1 << rSC_CLOCK)
 	ldh [rSC], a
-	ld a, (1 << rSC_ON) | 1
+	ld a, (1 << rSC_ON) | (1 << rSC_CLOCK)
 	ldh [rSC], a
 
 	call DelayFrame
 	xor a
 	ldh [hSerialSend], a
-	ld a, (0 << rSC_ON) | 1
+	ld a, (0 << rSC_ON) | (1 << rSC_CLOCK)
 	ldh [rSC], a
-	ld a, (1 << rSC_ON) | 1
+	ld a, (1 << rSC_ON) | (1 << rSC_CLOCK)
 	ldh [rSC], a
 
 .Player1:
@@ -214,7 +214,7 @@
 	call DelayFrames
 	xor a
 	ldh [rIF], a
-	ld a, $8
+	ld a, 1 << SERIAL
 	ldh [rIE], a
 	ld hl, wd1f3
 	ld de, wEnemyMonSpecies
@@ -243,7 +243,7 @@
 .not_trading
 	xor a
 	ldh [rIF], a
-	ld a, $1d
+	ld a, (1 << JOYPAD) | (1 << SERIAL) | (1 << TIMER) | (1 << VBLANK)
 	ldh [rIE], a
 	ld de, MUSIC_NONE
 	call PlayMusic
@@ -447,7 +447,7 @@
 	xor a
 	ldh [rIF], a
 	ldh a, [rIE]
-	set 1, a
+	set LCD_STAT, a
 	ldh [rIE], a
 	pop af
 	ldh [rIF], a
@@ -1558,9 +1558,9 @@
 	xor a
 	ldh [rSB], a
 	ldh [hSerialSend], a
-	ld a, (0 << rSC_ON) | 1
+	ld a, (0 << rSC_ON) | (1 << rSC_CLOCK)
 	ldh [rSC], a
-	ld a, (1 << rSC_ON) | 1
+	ld a, (1 << rSC_ON) | (1 << rSC_CLOCK)
 	ldh [rSC], a
 	ret
 
@@ -2104,9 +2104,9 @@
 	xor a
 	ldh [rSB], a
 	ldh [hSerialReceive], a
-	ld a, (0 << rSC_ON) | 1
+	ld a, (0 << rSC_ON) | (1 << rSC_CLOCK)
 	ldh [rSC], a
-	ld a, (1 << rSC_ON) | 1
+	ld a, (1 << rSC_ON) | (1 << rSC_CLOCK)
 	ldh [rSC], a
 	ld c, 3
 	call DelayFrames
@@ -2113,9 +2113,9 @@
 	xor a
 	ldh [rSB], a
 	ldh [hSerialReceive], a
-	ld a, (0 << rSC_ON) | 0
+	ld a, (0 << rSC_ON) | (0 << rSC_CLOCK)
 	ldh [rSC], a
-	ld a, (1 << rSC_ON) | 0
+	ld a, (1 << rSC_ON) | (0 << rSC_CLOCK)
 	ldh [rSC], a
 	ld c, 3
 	call DelayFrames
@@ -2131,7 +2131,7 @@
 	push af
 	xor a
 	ldh [rIF], a
-	ld a, $f
+	ld a, IE_DEFAULT
 	ldh [rIE], a
 	pop af
 	ldh [rIF], a
@@ -2160,9 +2160,9 @@
 	ldh [rSB], a
 	xor a
 	ldh [hSerialReceive], a
-	ld a, (0 << rSC_ON) | 0
+	ld a, (0 << rSC_ON) | (0 << rSC_CLOCK)
 	ldh [rSC], a
-	ld a, (1 << rSC_ON) | 0
+	ld a, (1 << rSC_ON) | (0 << rSC_CLOCK)
 	ldh [rSC], a
 	xor a ; LINK_TIMECAPSULE - 1
 	ld [wPlayerLinkAction], a
@@ -2177,9 +2177,9 @@
 	ldh [rSB], a
 	xor a
 	ldh [hSerialReceive], a
-	ld a, (0 << rSC_ON) | 0
+	ld a, (0 << rSC_ON) | (0 << rSC_CLOCK)
 	ldh [rSC], a
-	ld a, (1 << rSC_ON) | 0
+	ld a, (1 << rSC_ON) | (0 << rSC_CLOCK)
 	ldh [rSC], a
 	call DelayFrame
 	call DelayFrame
@@ -2202,9 +2202,9 @@
 	ldh [rSB], a
 	xor a
 	ldh [hSerialReceive], a
-	ld a, (0 << rSC_ON) | 0
+	ld a, (0 << rSC_ON) | (0 << rSC_CLOCK)
 	ldh [rSC], a
-	ld a, (1 << rSC_ON) | 0
+	ld a, (1 << rSC_ON) | (0 << rSC_CLOCK)
 	ldh [rSC], a
 	ld a, [wLinkTimeoutFrames]
 	dec a
@@ -2218,9 +2218,9 @@
 .not_done
 	ld a, $1
 	ldh [rSB], a
-	ld a, (0 << rSC_ON) | 1
+	ld a, (0 << rSC_ON) | (1 << rSC_CLOCK)
 	ldh [rSC], a
-	ld a, (1 << rSC_ON) | 1
+	ld a, (1 << rSC_ON) | (1 << rSC_CLOCK)
 	ldh [rSC], a
 	call DelayFrame
 	jr .loop
--- a/engine/link/mystery_gift.asm
+++ b/engine/link/mystery_gift.asm
@@ -434,7 +434,7 @@
 	xor a
 	ldh [rIF], a
 	ldh a, [rIE]
-	or $1
+	or 1 << VBLANK
 	ldh [rIE], a
 	ei
 	call DelayFrame
@@ -559,7 +559,7 @@
 	xor a
 	ldh [rIF], a
 	ldh a, [rIE]
-	or $1
+	or 1 << VBLANK
 	ldh [rIE], a
 	ei
 	call DelayFrame
@@ -600,7 +600,7 @@
 
 Function104d5e:
 	call Function104d74
-	ld a, $4
+	ld a, 1 << TIMER
 	ldh [rIE], a
 	xor a
 	ldh [rIF], a
--- a/engine/overworld/scripting.asm
+++ b/engine/overworld/scripting.asm
@@ -145,9 +145,7 @@
 	dw Script_loadmenu                   ; 4f
 	dw Script_closewindow                ; 50
 	dw Script_jumptextfaceplayer         ; 51
-if _CRYSTAL
 	dw Script_farjumptext                ; 52
-endc
 	dw Script_jumptext                   ; 53
 	dw Script_waitbutton                 ; 54
 	dw Script_buttonsound                ; 55
@@ -330,8 +328,6 @@
 	closetext
 	end
 
-if _CRYSTAL
-
 Script_farjumptext:
 ; script command 0x52
 ; parameters: text_pointer
@@ -345,8 +341,6 @@
 	ld b, BANK(JumpTextScript)
 	ld hl, JumpTextScript
 	jp ScriptJump
-
-endc
 
 Script_writetext:
 ; script command 0x4c
--- a/engine/printer/printer.asm
+++ b/engine/printer/printer.asm
@@ -56,7 +56,7 @@
 	push af
 	xor a
 	ldh [rIF], a
-	ld a, $9
+	ld a, (1 << SERIAL) | (1 << VBLANK)
 	ldh [rIE], a
 
 	call Printer_StartTransmission
@@ -140,13 +140,13 @@
 	push af
 	xor a
 	ldh [rIF], a
-	ld a, %1001
+	ld a, (1 << SERIAL) | (1 << VBLANK)
 	ldh [rIE], a
 
 	ld hl, hVBlank
 	ld a, [hl]
 	push af
-	ld [hl], %0100
+	ld [hl], 4
 
 	xor a
 	ldh [hBGMapMode], a
@@ -219,7 +219,7 @@
 	push af
 	xor a
 	ldh [rIF], a
-	ld a, $9
+	ld a, (1 << SERIAL) | (1 << VBLANK)
 	ldh [rIE], a
 	ld hl, hVBlank
 	ld a, [hl]
@@ -284,7 +284,7 @@
 	push af
 	xor a
 	ldh [rIF], a
-	ld a, %1001
+	ld a, (1 << SERIAL) | (1 << VBLANK)
 	ldh [rIE], a
 
 	xor a
@@ -326,7 +326,7 @@
 	push af
 	xor a
 	ldh [rIF], a
-	ld a, %1001
+	ld a, (1 << SERIAL) | (1 << VBLANK)
 	ldh [rIE], a
 
 	xor a
@@ -390,7 +390,7 @@
 	push af
 	xor a
 	ldh [rIF], a
-	ld a, %1001
+	ld a, (1 << SERIAL) | (1 << VBLANK)
 	ldh [rIE], a
 
 	ld hl, hVBlank
@@ -458,9 +458,9 @@
 	ld [wPrinterOpcode], a
 	ld a, $88
 	ldh [rSB], a
-	ld a, $1
+	ld a, (0 << rSC_ON) | (1 << rSC_CLOCK)
 	ldh [rSC], a
-	ld a, $81
+	ld a, (1 << rSC_ON) | (1 << rSC_CLOCK)
 	ldh [rSC], a
 .loop2
 	ld a, [wPrinterOpcode]
--- a/engine/printer/printer_serial.asm
+++ b/engine/printer/printer_serial.asm
@@ -279,9 +279,9 @@
 	ld [wPrinterOpcode], a
 	ld a, $88
 	ldh [rSB], a
-	ld a, $1
+	ld a, (0 << rSC_ON) | (1 << rSC_CLOCK)
 	ldh [rSC], a
-	ld a, $81
+	ld a, (1 << rSC_ON) | (1 << rSC_CLOCK)
 	ldh [rSC], a
 	ret
 
@@ -622,9 +622,9 @@
 
 Printer_SerialSend:
 	ldh [rSB], a
-	ld a, $1 ; switch to internal clock
+	ld a, (0 << rSC_ON) | (1 << rSC_CLOCK)
 	ldh [rSC], a
-	ld a, $81 ; start transfer
+	ld a, (1 << rSC_ON) | (1 << rSC_CLOCK)
 	ldh [rSC], a
 	ret
 
--- a/home/handshake.asm
+++ b/home/handshake.asm
@@ -32,11 +32,11 @@
 	ldh [rSB], a
 
 ; switch to internal clock
-	ld a, %00000001
+	ld a, (0 << rSC_ON) | (1 << rSC_CLOCK)
 	ldh [rSC], a
 
 ; start transfer
-	ld a, %10000001
+	ld a, (1 << rSC_ON) | (1 << rSC_CLOCK)
 	ldh [rSC], a
 
 	ret
--- a/home/init.asm
+++ b/home/init.asm
@@ -6,7 +6,7 @@
 	call ClearPalettes
 	xor a
 	ldh [rIF], a
-	ld a, 1 ; VBlank int
+	ld a, 1 << VBLANK
 	ldh [rIE], a
 	ei
 
@@ -154,7 +154,7 @@
 
 	xor a
 	ldh [rIF], a
-	ld a, %1111 ; VBlank, LCDStat, Timer, Serial interrupts
+	ld a, IE_DEFAULT
 	ldh [rIE], a
 	ei
 
--- a/home/lcd.asm
+++ b/home/lcd.asm
@@ -46,7 +46,7 @@
 	ld b, a
 
 ; Disable VBlank
-	res 0, a ; vblank
+	res VBLANK, a
 	ldh [rIE], a
 
 .wait
--- a/home/serial.asm
+++ b/home/serial.asm
@@ -28,9 +28,9 @@
 	cp USING_INTERNAL_CLOCK
 	jr z, .player2
 
-	ld a, 0 << rSC_ON
+	ld a, (0 << rSC_ON) | (0 << rSC_CLOCK)
 	ldh [rSC], a
-	ld a, 1 << rSC_ON
+	ld a, (1 << rSC_ON) | (0 << rSC_CLOCK)
 	ldh [rSC], a
 	jr .player2
 
@@ -65,9 +65,9 @@
 	bit 7, a
 	jr nz, .wait_bit_7
 
-	ld a, 0 << rSC_ON
+	ld a, (0 << rSC_ON) | (0 << rSC_CLOCK)
 	ldh [rSC], a
-	ld a, 1 << rSC_ON
+	ld a, (1 << rSC_ON) | (0 << rSC_CLOCK)
 	ldh [rSC], a
 	jr .player2
 
@@ -130,9 +130,9 @@
 	ldh a, [hSerialConnectionStatus]
 	cp USING_INTERNAL_CLOCK
 	jr nz, .not_player_2
-	ld a, (0 << rSC_ON) | 1
+	ld a, (0 << rSC_ON) | (1 << rSC_CLOCK)
 	ldh [rSC], a
-	ld a, (1 << rSC_ON) | 1
+	ld a, (1 << rSC_ON) | (1 << rSC_CLOCK)
 	ldh [rSC], a
 .not_player_2
 .loop2
@@ -352,9 +352,9 @@
 	ldh a, [hSerialConnectionStatus]
 	cp USING_INTERNAL_CLOCK
 	jr nz, .player_1
-	ld a, (0 << rSC_ON) | 1
+	ld a, (0 << rSC_ON) | (1 << rSC_CLOCK)
 	ldh [rSC], a
-	ld a, (1 << rSC_ON) | 1
+	ld a, (1 << rSC_ON) | (1 << rSC_CLOCK)
 	ldh [rSC], a
 
 .player_1
@@ -382,9 +382,9 @@
 	ldh a, [hSerialConnectionStatus]
 	cp USING_INTERNAL_CLOCK
 	ret nz
-	ld a, (0 << rSC_ON) | 1
+	ld a, (0 << rSC_ON) | (1 << rSC_CLOCK)
 	ldh [rSC], a
-	ld a, (1 << rSC_ON) | 1
+	ld a, (1 << rSC_ON) | (1 << rSC_CLOCK)
 	ldh [rSC], a
 	ret
 
@@ -396,8 +396,8 @@
 	ldh [rSB], a
 	xor a
 	ldh [hSerialReceive], a
-	ld a, 0 << rSC_ON
+	ld a, (0 << rSC_ON) | (0 << rSC_CLOCK)
 	ldh [rSC], a
-	ld a, 1 << rSC_ON
+	ld a, (1 << rSC_ON) | (0 << rSC_CLOCK)
 	ldh [rSC], a
 	ret
--- a/home/vblank.asm
+++ b/home/vblank.asm
@@ -196,13 +196,13 @@
 	xor a
 	ldh [rIF], a
 	; enable lcd stat
-	ld a, %10 ; lcd stat
+	ld a, 1 << LCD_STAT
 	ldh [rIE], a
 	; rerequest serial int if applicable (still disabled)
 	; request lcd stat
 	ld a, b
-	and %1000 ; serial
-	or %10 ; lcd stat
+	and 1 << SERIAL
+	or 1 << LCD_STAT
 	ldh [rIF], a
 
 	ei
@@ -220,7 +220,7 @@
 	xor a
 	ldh [rIF], a
 	; enable ints besides joypad
-	ld a, %1111 ; serial timer lcdstat vblank
+	ld a, IE_DEFAULT
 	ldh [rIE], a
 	; rerequest ints
 	ld a, b
@@ -279,7 +279,7 @@
 	push af
 	xor a
 	ldh [rIF], a
-	ld a, %10 ; lcd stat
+	ld a, 1 << LCD_STAT
 	ldh [rIE], a
 	ldh [rIF], a
 
@@ -302,7 +302,7 @@
 	xor a
 	ldh [rIF], a
 	; enable ints besides joypad
-	ld a, %1111 ; serial timer lcdstat vblank
+	ld a, IE_DEFAULT
 	ldh [rIE], a
 	; request ints
 	ld a, b
@@ -368,7 +368,7 @@
 
 	xor a
 	ldh [rIF], a
-	ld a, %10 ; lcd stat
+	ld a, 1 << LCD_STAT
 	ldh [rIE], a
 	; request lcd stat
 	ldh [rIF], a
@@ -384,7 +384,7 @@
 	xor a
 	ldh [rIF], a
 	; enable ints besides joypad
-	ld a, %1111 ; serial timer lcdstat vblank
+	ld a, IE_DEFAULT
 	ldh [rIE], a
 	ret
 
--- a/lib/mobile/main.asm
+++ b/lib/mobile/main.asm
@@ -605,7 +605,7 @@
 Function110393:
 	ld c, LOW(rIE)
 	ldh a, [c]
-	or $c
+	or (1 << SERIAL) | (1 << TIMER)
 	ldh [c], a
 	ret
 
@@ -4101,9 +4101,9 @@
 Function111b2e:
 	ld hl, $c822
 	set 1, [hl]
-	ld a, $3
+	ld a, (0 << rSC_ON) | (1 << rSC_CGB) | (1 << rSC_CLOCK)
 	ldh [rSC], a
-	ld a, $83
+	ld a, (1 << rSC_ON) | (1 << rSC_CGB) | (1 << rSC_CLOCK)
 	ldh [rSC], a
 
 Function111b3b:
@@ -4684,7 +4684,7 @@
 	ret
 .asm_111f17
 	ldh a, [rSC]
-	and $80
+	and 1 << rSC_ON
 	jr nz, .asm_111f17
 	di
 	ld a, [$c81e]
--- a/macros/enum.asm
+++ b/macros/enum.asm
@@ -14,7 +14,7 @@
 ENDM
 
 enum: MACRO
-\1 = __enum__
+\1 EQU __enum__
 __enum__ = __enum__ + __enumdir__
 ENDM
 
--- a/macros/scripts/events.asm
+++ b/macros/scripts/events.asm
@@ -536,13 +536,11 @@
 	dw \1 ; text_pointer
 ENDM
 
-; if _CRYSTAL
 	enum farjumptext_command ; $52
 farjumptext: MACRO
 	db farjumptext_command
 	dba \1
 ENDM
-; endc
 
 	enum jumptext_command ; $53
 jumptext: MACRO
--- a/mobile/mobile_40.asm
+++ b/mobile/mobile_40.asm
@@ -79,7 +79,7 @@
 	call DoubleSpeed
 	xor a
 	ldh [rIF], a
-	ld a, 1 << VBLANK | 1 << LCD_STAT | 1 << TIMER | 1 << SERIAL
+	ld a, IE_DEFAULT
 	ldh [rIE], a
 	xor a
 	ldh [hMapAnims], a
@@ -162,7 +162,7 @@
 	xor a
 	ldh [rIF], a
 	ldh a, [rIE]
-	and $13
+	and $1f ^ (1 << SERIAL | 1 << TIMER)
 	ldh [rIE], a
 	xor a
 	ldh [hMobileReceive], a
--- a/mobile/mobile_46.asm
+++ b/mobile/mobile_46.asm
@@ -469,7 +469,7 @@
 	ld a, [hl]
 	ld [wcd7f], a
 	set 1, [hl]
-	ld a, $f
+	ld a, (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK)
 	ldh [rIE], a
 	ld a, $1
 	ldh [hMobileReceive], a