diff options
author | yenatch <yenatch@gmail.com> | 2018-04-04 21:04:14 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-04 21:04:14 -0400 |
commit | fe4377ce532d1fea1b28d2c52e4f62f0ca702a30 (patch) | |
tree | 6ce2635ce57ff2735839235e3061e7f3009cfe5d /engine/smallflag.asm | |
parent | 0c446367ce79dfe2a26f4bd7668036477811a279 (diff) | |
parent | 38107209a6ad431b399cc36405c0af8b5babf5ef (diff) |
Merge pull request #501 from mid-kid/reorg
Organize the engine/ directory
Diffstat (limited to 'engine/smallflag.asm')
-rw-r--r-- | engine/smallflag.asm | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/engine/smallflag.asm b/engine/smallflag.asm new file mode 100644 index 000000000..2a6d91ee1 --- /dev/null +++ b/engine/smallflag.asm @@ -0,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 |