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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
.org 0
.equ INT_VECTOR 0xff00
call init
call init_game
game_loop:
halt
call entities_erase
call stars_update
call entities_update
call entities_draw
jmp game_loop
init:
; setup an int handler so we
; can use the frame int to sync
ld a, >INT_VECTOR
ld x, <INT_VECTOR
ld b, <int_handler
ld [a : x], b
inc x
ld b, >int_handler
ld [a : x], b
; enable interrupts
cif
ret
init_game:
halt
; set player initial coordinates
ld x, <player_coord
ld a, >player_coord
ld y, 56
ld [a : x], y
inc x
bo
inc a
ld y, 104
ld [a : x], y
; erase the screen
ld b, 0
ld a, 0xbf
ld x, 0
ld y, 0x40
fill_loop:
ld [a : x], b
inc x
bno
jmp fill_loop
inc a
dec y
bnz
jmp fill_loop
call entities_draw
ret
int_handler:
iret
.include "random.asm"
.include "starfield.asm"
.include "entities.asm"
.include "player.asm"
;
; entity data
;
entities:
; type
.db ET_PLAYER
; x, y
player_coord:
.db 0, 0
; frame
.db 0
.dw player_sprite
.dw player_update
; end of list
.db ET_END
; sprite data
player_sprite:
.incpng "assets/player.png"
; starfield data
stars:
; video addr, speed, color
.dw 0xc361
.db 1, 15
.dw 0xc204
.db 1, 6
.dw 0xcdf9
.db 1, 15
.dw 0xdb87
.db 1, 3
.dw 0xd242
.db 1, 15
.dw 0xdeea
.db 1, 6
.dw 0xe7af
.db 1, 15
.dw 0xed68
.db 1, 3
.dw 0xf812
.db 1, 15
.dw 0xfbca
.db 1, 13
.dw 0xc361
.db 2, 8
.dw 0xc204
.db 2, 9
.dw 0xcdf9
.db 3, 7
.dw 0xdb87
.db 3, 4
.dw 0xd242
.db 2, 8
.dw 0xdeea
.db 3, 9
.dw 0xe7af
.db 3, 6
.dw 0xed68
.db 2, 9
.dw 0xf812
.db 3, 14
.dw 0xfbca
.db 2, 3
; end of list
.dw 0xffff
|