SECTION "Utilities", ROM0 ; Busy-wait until vertical blank occurs wait_for_vblank:: ld a, [$ff41] and 3 cp 1 jr nz, wait_for_vblank ret ; Copy data between two regions ; @param bc Pointer to the destination region ; @param hl Pointer to the source region ; @param d Size (in bytes) to copy. Must be >0 ; @destroy a, b, c, d, h, l memcpy:: ld a, [hli] ld [bc], a inc bc dec d jr nz, memcpy ret ; Fill a memory region with a value ; @param hl Pointer to the destination region ; @param a Byte to fill with ; @param c Number of bytes to fill. Must be >0 ; @destroy a, c, hl memset:: ld [hli], a dec c jr nz, memset ret ; Divide a value by 10 (http://homepage.divms.uiowa.edu/~jones/bcd/decimal.html#division) ; @param b Dividend ; @return a Quotient ; @destroy b div10:: ld a, b srl a srl a add b srl a add b srl a srl a srl a add b srl a add b srl a srl a srl a srl a ret