-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgame.f
119 lines (97 loc) · 1.6 KB
/
game.f
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
<perm> definitions:
hex
0 val colors
0 val addr
0 c-val spr
80 c-val Y
20 val ballvx
20 val ballvy
500 val ballx
800 val bally
ballx val oldballx
bally val oldbally
( x y -- )
: draw|
[ char | literal ]
0
spr oam-spr to spr ;
( x y -- )
: draw-paddle
over over 8 +
draw| draw|
;
( x y -- )
: draw-ball
[ char . literal ] 0 spr oam-spr to spr
;
: frame
0 to spr
joy1 btnU and if
Y 4 - to Y
then
joy1 btnD and if
Y 4 + to Y
then
ballvx ballx + to ballx
ballvy bally + to bally
ballx asr asr asr asr
dup 100 > if
1000 to ballx
ballvx negate to ballvx
else dup 0 < if
0 to ballx
ballvx negate to ballvx
then then
bally asr asr asr asr
dup E0 > if
E00 to bally
ballvy negate to ballvy
else dup 0 < if
0 to bally
ballvy negate to ballvy
then then
draw-ball
10 \ x
Y \ y
draw-paddle
E0 10 draw-paddle
ballx to oldballx
bally to oldbally
addr 1+ 1FFF and to addr
vppu-mask 1F and
colors asl asl asl asl asl or to vppu-mask
vppu-mask
[
stack LDA.ZX
FE AND.#
2001 STA
]
drop
;
: init
font 200 mv>ppu
font 1200 mv>ppu
19 to vppu-mask
;
: done
freeze \ stop emulation and write NES ROM
wait-for-ppu
\ Disable all rendering
[ 0 LDA.#
2000 STA ]
init
\ Enable frame interrupts
[ 80 LDA.#
2000 STA ]
\ Loop forever and call the frame function each frame
begin
ppu-wait-nmi
frame
0 until
;
0 15 pal-col!
1 16 pal-col!
2 30 pal-col!
3 31 pal-col!
4 pal-bright
80 to vppu-ctrl