gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
gbdk-lib/libc/targets/sm83/cpy_data.s
1 .include "global.s"
2
3 .area _CODE
4
5 .globl _vmemcpy, _set_data, _get_data, .copy_vram
6
7 ;DE: dest
8 ;HL: src
9 ;BC: len
10 .copy_vram::
11 push bc
12 ld a, c
13 call cpy_vram
14 ret
15
16 ;DE: dest
17 ;BC: src
18 ;sp+2: len
19 _vmemcpy::
20 _set_data::
21 _get_data::
22 ldhl sp, #3
23 ld a, (hl-)
24 ld l, (hl)
25 ld h, b
26 ld b, a
27 ld a, l
28 ld l, c
29
30 ;DE: dest
31 ;HL: src
32 ;B,A: len
33 cpy_vram:
34 srl b
35 rra
36 ld c, a
37 jr nc, skip_one
38
39 WAIT_STAT
40 ld a, (hl+)
41 ld (de), a
42 inc de
43 skip_one:
44 ;n/2 in bc
45 ;shift second LSB to carry
46 srl b
47 rr c
48 ;n/4 in bc
49 inc b
50 inc c
51 jr nc, test
52 jr copy_two
53 .irp idx,copy_four,copy_two
54 idx:
55 .rept 2
56 WAIT_STAT
57 ld a, (hl+)
58 ld (de), a
59 inc de
60 .endm
61 .endm
62 test:
63 .irp idx,c,b
64 dec idx
65 jr nz, copy_four
66 .endm
67
68 ;get return address
69 pop hl
70 ;throw away n
71 pop af
72 jp (hl)
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.