-
Notifications
You must be signed in to change notification settings - Fork 0
/
player_control.asm
122 lines (100 loc) · 1.22 KB
/
player_control.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
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
;
; Player control routines
;
.LOCAL player_control
joystick_0 = $278
joystick_up = %0001
joystick_down = %0010
joystick_left = %0100
joystick_right = %1000
min_x = $30
max_x = $D0
min_y = $1E
max_y = $A0
.PROC read_controls
; coord_utils.map_from_screen_to_grid_coords
; lda #"*"
; sta (position),y
move_player
rts
.ENDP
.PROC move_player
up
lda #joystick_up
bit joystick_0
bne down
lda #min_y
cmp p0_y
beq left
move_up
jmp left
down
lda #joystick_down
bit joystick_0
bne left
lda #max_y
cmp p0_y
beq left
move_down
left
lda #joystick_left
bit joystick_0
bne right
lda #min_x
cmp p0_x
beq done
dec p0_x
lda p0_x
sta p0_hpos
jmp done
right
lda #joystick_right
bit joystick_0
bne done
lda #max_x
cmp p0_x
beq done
inc p0_x
lda p0_x
sta p0_hpos
done
rts
.ENDP
.PROC move_up
lda p0_y
dec p0_y
sta p0_addr
ldx #8
move_loop
ldy #1 ; stupid logic, think again
lda (p0_addr),y
dey
sta (p0_addr),y
inc p0_addr
dex
bne move_loop
done
rts
.ENDP
.PROC move_down
lda p0_y
cmp max_y
beq done
lda p0_y
clc
adc #8
sta p0_addr
move_loop
ldy #0
dec p0_addr
lda (p0_addr),y
iny
sta (p0_addr),y
lda p0_y
cmp p0_addr
bne move_loop
inc p0_y
done
rts
.ENDP
.ENDL