From 75e4f784924393ccedb27f2831e5a36fe11bada5 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Tue, 3 Jul 2018 13:36:50 -0400 Subject: Merge branch 'master' of https://github.com/luckytyphlosion/pokegold-spaceworld --- engine/smallflag.asm | 142 +++++++++++++++++++++++++-------------------------- 1 file changed, 71 insertions(+), 71 deletions(-) (limited to 'engine') diff --git a/engine/smallflag.asm b/engine/smallflag.asm index dfce475..a231d0b 100755 --- a/engine/smallflag.asm +++ b/engine/smallflag.asm @@ -1,72 +1,72 @@ -SECTION "SmallFarFlagAction", ROMX[$4d33], BANK[$03] - -SmallFarFlagAction: ; 03:4d33 -; 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 +SECTION "SmallFarFlagAction", ROMX[$4d33], BANK[$03] + +SmallFarFlagAction: ; 03:4d33 +; 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 \ No newline at end of file -- cgit v1.2.3