forked from albs-br/msx-wings
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReadInput.s
More file actions
93 lines (70 loc) · 1.94 KB
/
ReadInput.s
File metadata and controls
93 lines (70 loc) · 1.94 KB
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
PLANE_PLAYER_WIDTH: equ 21
PLANE_PLAYER_HEIGHT: equ 31
PLANE_PLAYER_PIXELS_PER_MOV: equ 3
ReadInput:
; read keyboard
ld a, 8 ; 8th line
call BIOS_SNSMAT ; Read Data Of Specified Line From Keyboard Matrix
ld e, a ; save value
push de
bit 0, a ; 0th bit (space bar)
call z, .shot
pop de
ld a, e
bit 4, a ; 4th bit (key left)
call z, .playerLeft
ld a, e
bit 7, a ; 7th bit (key right)
call z, .playerRight
ld a, e
bit 5, a ; 5th bit (key up)
call z, .playerUp
ld a, e
bit 6, a ; 6th bit (key down)
call z, .playerDown
ret
.playerLeft:
ld a, (Player_X)
sub PLANE_PLAYER_PIXELS_PER_MOV
ret c
ld (Player_X), a
; ; clear 7th bit (key right)
; ld a, e
; or 1000 0000b
; ld e, a
ret
.playerRight:
ld a, (Player_X)
add PLANE_PLAYER_PIXELS_PER_MOV
cp 255 - PLANE_PLAYER_WIDTH
ret nc
ld (Player_X), a
; ; clear 4th bit (key left)
; ld a, e
; or 0001 0000b
; ld e, a
ret
.playerUp:
ld a, (Player_Y_Static)
sub PLANE_PLAYER_PIXELS_PER_MOV
ret c
ld (Player_Y_Static), a
ld a, (Player_Y)
sub PLANE_PLAYER_PIXELS_PER_MOV
ld (Player_Y), a
ret
.playerDown:
ld a, (Player_Y_Static)
add PLANE_PLAYER_PIXELS_PER_MOV
cp 191 - PLANE_PLAYER_HEIGHT
ret nc
ld (Player_Y_Static), a
ld a, (Player_Y)
add PLANE_PLAYER_PIXELS_PER_MOV
ld (Player_Y), a
ret
.shot:
; get next shot struct addr
ld hl, (NextShot_Struct_Addr)
call PlayerShot_Init
ret