Skip to content

Instantly share code, notes, and snippets.

@untoxa
Last active June 14, 2020 19:31
Show Gist options
  • Save untoxa/43677e603df64b9bb58bb0910d827b7a to your computer and use it in GitHub Desktop.
Save untoxa/43677e603df64b9bb58bb0910d827b7a to your computer and use it in GitHub Desktop.
DMG Fading functions allows to fade in/out to black and in/out to white
UBYTE DMGFadetoWhiteStep(UBYTE pal, UBYTE step) __naked {
pal; step;
__asm
lda HL, 3(SP)
ld A, (HL-)
ld E, (HL)
or A
ret Z
ld D, A
1$:
ld H, #4
2$:
ld A, E
and #3
jr Z, 3$
dec A
3$:
srl A
rr L
srl A
rr L
srl E
srl E
dec H
jr NZ, 2$
ld E, L
dec D
jr NZ, 1$
ret
__endasm;
}
UBYTE DMGFadeToBlackStep(UBYTE pal, UBYTE step) __naked {
pal; step;
__asm
lda HL, 3(SP)
ld A, (HL-)
ld E, (HL)
or A
ret Z
ld D, A
1$:
ld H, #4
2$:
ld A, E
and #3
cp #3
jr Z, 3$
inc A
3$:
srl A
rr L
srl A
rr L
srl E
srl E
dec H
jr NZ, 2$
ld E, L
dec D
jr NZ, 1$
ret
__endasm;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment