-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoam_meta_spr_clip.s
107 lines (79 loc) · 1.25 KB
/
oam_meta_spr_clip.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
.importzp TEMP, _oam_off
.import popa, popax
.include "nes.inc"
.include "zpvars.inc"
;void __fastcall__ oam_meta_spr_clip(signed int x,unsigned char y,const unsigned char *metasprite);
.segment "ZEROPAGE"
SPR_XOFF: .res 1
SPR_YOFF: .res 1
.segment "CODE"
.export _oam_meta_spr_clip
_oam_meta_spr_clip:
sta <PTR
stx <PTR+1
jsr popa ;y
sta <SCRY
jsr popax ;x
sta <SCRX
stx <DST ;this is X MSB, repurposing RAM variable name
ldx _oam_off
ldy #0
@1:
lda (PTR),y ;x offset
cmp #$80
beq @2
iny
sta <SPR_XOFF+0
clc
adc <SCRX
sta <SPR_XOFF+1
lda <SPR_XOFF+0
ora #$7f
bmi :+
lda #0
:
adc <DST
bne @skip
lda <SPR_XOFF+1
sta OAM_BUF+3,x
lda (PTR),y ;y offset
iny
clc
adc <SCRY
sta OAM_BUF+0,x
lda (PTR),y ;tile
iny
sta OAM_BUF+1,x
lda (PTR),y ;attribute
iny
sta OAM_BUF+2,x
inx
inx
inx
inx
jmp @1
@skip:
iny
iny
iny
jmp @1
@2:
stx _oam_off
rts
; static unsigned char sx,sy,tile,pal,off;
; static signed int sxx;
; off=0;
; while(1)
; {
; sx=metasprite[off++];
; if(sx==128) return;
; sxx =x+(signed char)sx;
; sy =metasprite[off++]+y;
; tile=metasprite[off++];
; pal =metasprite[off++];
; if(!(sxx&0xff00))
; {
; oam_spr(sxx,sy,tile,pal,oam_off);
; oam_off+=4;
; }
; }