2019-06-14 08:36:52 +00:00
|
|
|
SECTION "Tools", ROM0
|
|
|
|
|
|
|
|
; Memory copier
|
|
|
|
; @param de - Address source to start of data to be copied
|
|
|
|
; @param hl - Address destomatopm where to copy the data to
|
|
|
|
; @param bc - The total amount of bytes to copy
|
|
|
|
; @return a = Zero
|
|
|
|
; @return bc = Zero
|
|
|
|
; @return de = Address Source to the byte after the last byte from source (garbage)
|
|
|
|
; @return hl = Address Target to the byte after the last byte on the target (garbage)
|
|
|
|
Memcpy:
|
|
|
|
ld a, [de] ; Load the value at [de] to accumilator
|
|
|
|
ld [hli], a ; Load the value from accumilator to the destination address and increment it by one
|
|
|
|
inc de ; Increment de to point to next byte to copy
|
|
|
|
dec bc ; Decrement bc the total amount of bytes to copy
|
|
|
|
ld a, b ; Load the first half of total amount of bytes to write to accumilator
|
|
|
|
or c ; OR together the second half of total amount with the first half
|
|
|
|
jr nz, Memcpy ; Loop back to Memcpy if not zero
|
|
|
|
ret
|
2019-06-18 09:08:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
;;
|
|
|
|
; Waits for the vblank ISR to increment the count of vertical blanks.
|
|
|
|
; Will lock up if DI, vblank IRQ off, or LCD off.
|
|
|
|
; Clobbers A, HL
|
|
|
|
WaitVBlank:
|
|
|
|
.wait
|
|
|
|
halt
|
|
|
|
ret
|