ref: 05ba221eb53472d9c617d96a6aaed9c2e87e2ad7
parent: be76ee56a89e72c0b87a605321bb1670e86f8220
author: mid-kid <[email protected]>
date: Sun Mar 25 15:14:26 EDT 2018
`flagpredef.asm` → `smallflag.asm`
--- a/engine/flagpredef.asm
+++ /dev/null
@@ -1,70 +1,0 @@
-SmallFarFlagAction: ; 4d7c1
-; Perform action b on bit c in flag array hl.
-; If checking a flag, check flag array d:hl unless d is 0.
-
-; For longer flag arrays, see FlagAction.
-
- push hl
- push bc
-
-; Divide by 8 to get the byte we want.
- push bc
- srl c
- srl c
- srl c
- ld b, 0
- add hl, bc
- pop bc
-
-; Which bit we want from the byte
- ld a, c
- and 7
- ld c, a
-
-; Shift left until we can mask the bit
- ld a, 1
- jr z, .shifted
-.shift
- add a
- dec c
- jr nz, .shift
-.shifted
- ld c, a
-
-; What are we doing to this flag?
- dec b
- jr z, .set ; 1
- dec b
- jr z, .check ; 2
-
-.reset
- ld a, c
- cpl
- and [hl]
- ld [hl], a
- jr .done
-
-.set
- ld a, [hl]
- or c
- ld [hl], a
- jr .done
-
-.check
- ld a, d
- cp 0
- jr nz, .farcheck
-
- ld a, [hl]
- and c
- jr .done
-
-.farcheck
- call GetFarByte
- and c
-
-.done
- pop bc
- pop hl
- ld c, a
- ret
--- /dev/null
+++ b/engine/smallflag.asm
@@ -1,0 +1,70 @@
+SmallFarFlagAction: ; 4d7c1
+; Perform action b on bit c in flag array hl.
+; If checking a flag, check flag array d:hl unless d is 0.
+
+; For longer flag arrays, see FlagAction.
+
+ push hl
+ push bc
+
+; Divide by 8 to get the byte we want.
+ push bc
+ srl c
+ srl c
+ srl c
+ ld b, 0
+ add hl, bc
+ pop bc
+
+; Which bit we want from the byte
+ ld a, c
+ and 7
+ ld c, a
+
+; Shift left until we can mask the bit
+ ld a, 1
+ jr z, .shifted
+.shift
+ add a
+ dec c
+ jr nz, .shift
+.shifted
+ ld c, a
+
+; What are we doing to this flag?
+ dec b
+ jr z, .set ; 1
+ dec b
+ jr z, .check ; 2
+
+.reset
+ ld a, c
+ cpl
+ and [hl]
+ ld [hl], a
+ jr .done
+
+.set
+ ld a, [hl]
+ or c
+ ld [hl], a
+ jr .done
+
+.check
+ ld a, d
+ cp 0
+ jr nz, .farcheck
+
+ ld a, [hl]
+ and c
+ jr .done
+
+.farcheck
+ call GetFarByte
+ and c
+
+.done
+ pop bc
+ pop hl
+ ld c, a
+ ret
--- a/main.asm
+++ b/main.asm
@@ -225,7 +225,7 @@
INCLUDE "engine/rtc/reset_password.asm"
INCLUDE "engine/menus/delete_save.asm"
INCLUDE "data/tilesets.asm"
-INCLUDE "engine/flagpredef.asm"
+INCLUDE "engine/smallflag.asm"
INCLUDE "engine/gfx/trademonfrontpic.asm"
INCLUDE "engine/events/pokerus/check_pokerus.asm"
INCLUDE "engine/events/lucky_number.asm"