-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobject.asm
73 lines (60 loc) · 1.21 KB
/
object.asm
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
;**************************************
;
; clear oam buffer with off screen sprites
;
;**************************************
InitOamBuffer:
php
.call M8
.call X16
ldx #0000
set_x_lsb:
lda #01 ; set sprite to x=-255
sta !oam_buffer,x
lda #f0 ; set sprite to y=240
sta !oam_buffer+1,x
inx
inx
inx
inx
cpx #OAML_SIZE
bne @set_x_lsb
lda #55 ; 01 01 01 01
set_x_msb:
sta !oam_buffer,x
inx
sta !oam_buffer,x
inx
cpx #OAM_SIZE
bne @set_x_msb
plp
rts
UpdatePlayerOAM:
.call M16
; player.screen_x = player.x - camera.x;
lda @player_x
sec
; Offset the player to the left (half a sprite wide)
sbc @camera_x
sbc #0008
sta @player_sx
; player.screen_y = player.y - camera.y;
lda @player_y
sec
sbc @camera_y
; Offset the player to the bottom (match with center of transformation)
clc
adc #0040
sta @player_sy
.call M8
lda @player_sx
sta !oam_buffer ; x
lda @player_sy
sta !oam_buffer+1 ; y
lda #00
sta !oam_buffer+2 ; tile number
lda #30 ; 00110000
sta !oam_buffer+3 ; vhppcccn
lda #54
sta !oam_buffer_hi
rts