gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
gbdk-lib/libc/targets/z80/sms_metasprites_flip.s
1 .include "global.s"
2
3 .title "Metasprites"
4 .module Metasprites
5
6 .ez80
7
8 .area _DATA
9
10 .globl ___current_metasprite, ___current_base_tile, ___render_shadow_OAM
11
12 .area _CODE
13
14 .macro MOVE_METASPRITE_BODY neg_dx neg_dy
15 ld iyl, a
16
17 pop hl
18 pop bc
19 push hl
20
21 push af
22 push ix
23
24 ld ix, (___current_metasprite)
25
26 ld a, (___render_shadow_OAM)
27 ld iyh, a
28 1$:
29 ld a, 0(ix) ; dy
30 cp #0x80
31 jp z, 2$
32 .ifne neg_dy
33 neg ; apply flipy (or no-op)
34 .endif
35 add a, a
36 sbc a, a
37 ld h, a
38 ld a, 0(ix)
39 .ifne neg_dy
40 neg ; apply flipy (or no-op)
41 .endif
42 ld l, a
43 inc ix
44 add hl, bc
45 ld b, h
46 ld c, l
47
48 ld a, #0x20
49 add l
50 ld l, a
51 adc h
52 sub l
53 jp nz, 5$
54 ld a, l
55 cp #(0x20 + 0xC0)
56 jp c, 6$
57 5$:
58 ld 0(iy), #0xC0
59 jp 7$
60 6$:
61 ld 0(iy), c
62 7$:
63 ld a, 0(ix) ; dx
64 .ifne neg_dx
65 neg ; apply flipx (or no-op)
66 .endif
67 add a, a
68 sbc a, a
69 ld h, a
70 ld a, 0(ix)
71 .ifne neg_dx
72 neg ; apply flipx (or no-op)
73 .endif
74 ld l, a
75 inc ix
76 add hl, de
77 ex de, hl
78 ld a, d
79 or a
80 jp nz, 4$
81
82 ld a, iyl
83 rlca
84 ld iyl, a
85
86 ld 0x40(iy), e
87
88 ld a, (___current_base_tile)
89 add 0(ix) ; tile
90 inc ix
91 ld 0x41(iy), a
92
93 ld a, iyl
94 rrca
95 inc a
96 ld iyl, a
97
98 jp 1$
99 4$:
100 ld 0(iy), #0xC0
101 inc ix
102 inc iyl
103 jp 1$
104 2$:
105 pop ix
106 pop bc
107
108 ld a, iyl
109 sub b
110 ret
111 .endm
112
113 ___move_metasprite_flipx::
114 MOVE_METASPRITE_BODY 1,0
115
116 ___move_metasprite_flipy::
117 MOVE_METASPRITE_BODY 0,1
118
119 ___move_metasprite_flipxy::
120 MOVE_METASPRITE_BODY 1,1
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.