diff options
Diffstat (limited to 'src/home/hblank.asm')
-rw-r--r-- | src/home/hblank.asm | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/home/hblank.asm b/src/home/hblank.asm new file mode 100644 index 0000000..acf2eaa --- /dev/null +++ b/src/home/hblank.asm @@ -0,0 +1,43 @@ +; copy b bytes of data from hl to de, but only during hblank +HblankCopyDataHLtoDE: + push bc +.loop + ei + di + ldh a, [rSTAT] ; + and STAT_LCDC_STATUS ; + jr nz, .loop ; assert hblank + ld a, [hl] + ld [de], a + ldh a, [rSTAT] ; + and STAT_LCDC_STATUS ; + jr nz, .loop ; assert still in hblank + ei + inc hl + inc de + dec b + jr nz, .loop + pop bc + ret + +; copy c bytes of data from de to hl, but only during hblank +HblankCopyDataDEtoHL: + push bc +.loop + ei + di + ldh a, [rSTAT] ; + and STAT_LCDC_STATUS ; + jr nz, .loop ; assert hblank + ld a, [de] + ld [hl], a + ldh a, [rSTAT] ; + and STAT_LCDC_STATUS ; + jr nz, .loop ; assert still in hblank + ei + inc hl + inc de + dec c + jr nz, .loop + pop bc + ret |