beginGraphicsTransfer: ;{ 00:27BA
    ; Set VRAM transfer flag
    ld a, $ff
    ld [vramTransferFlag], a
    push bc
    push de
    push hl

    .loop:
        ; Skip some common routines during the Varia animation
        ld a, [variaAnimationFlag]
        and a
        jr z, .endIf_A
            call drawSamus_longJump
            call handleEnemiesOrQueen
            callFar drawHudMetroid
            call clearUnusedOamSlots_longJump
        .endIf_A:

        .loop_waitLCDStatusAnti
            ldh a, [rSTAT]
            and $02
            jr z, .loop_waitLCDStatusAnti
            
        ld a, [vramTransferFlag]
        or a
        jr z, .return ; just to make sure theres stuff to transfer

        ld a, [vramTransfer_srcBank]
        ld [rMBC_BANK_REG], a
        ldh a, [hVramTransfer.sizeLow]
        ld c, a
        ldh a, [hVramTransfer.sizeHigh]
        ld b, a
        ldh a, [hVramTransfer.srcAddrLow]
        ld l, a
        ldh a, [hVramTransfer.srcAddrHigh]
        ld h, a
        ldh a, [hVramTransfer.destAddrLow]
        ld e, a
        ldh a, [hVramTransfer.destAddrHigh]
        ld d, a

        .loop_waitLCDStatus
            ldh a, [rSTAT]
            and $03
            jr z, .writeNextByte ; hblank
            dec a ; vblank
            jr z, .loop ; cancel this batch if i couldn't do 256 bytes with the hblanks
            jr .loop_waitLCDStatus

            .writeNextByte:
            ld a, [hl+]
            ld [de], a
            inc de
            dec bc

            ld a, c
            or a
        jr nz, .loop_waitLCDStatus

        ; Save transfer parameters
        ld a, c
        ldh [hVramTransfer.sizeLow], a
        ld a, b
        ldh [hVramTransfer.sizeHigh], a
        ld a, l
        ldh [hVramTransfer.srcAddrLow], a
        ld a, h
        ldh [hVramTransfer.srcAddrHigh], a
        ld a, e
        ldh [hVramTransfer.destAddrLow], a
        ld a, d
        ldh [hVramTransfer.destAddrHigh], a

        ; Clear update flag if done
        ld a, b
        or c
        jr nz, .endIf_B
            xor a
            ld [vramTransferFlag], a
            jr .return
        .endIf_B:

        ; Wait until WRAM transfer is done
        call waitOneFrame
        ld a, [vramTransferFlag]
        and a
    jr nz, .loop
    .return:
    pop hl
    pop de
    pop bc
ret ;}
