-
Notifications
You must be signed in to change notification settings - Fork 0
/
light_pen_cb2.s65
135 lines (93 loc) · 3.58 KB
/
light_pen_cb2.s65
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
;-------------------------------------------------------------------------
; This code is free software: you can redistribute it and/or modify it
; under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
; This code is distributed in the hope that it will be useful, but
; WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
; General Public License for more details.
; You should have received a copy of the GNU General Public License
; along with this code. If not, see <https://www.gnu.org/licenses/>.
;-------------------------------------------------------------------------
draw_timer_adjustment=0
screen_base=$3000
screen_row_stride=640
.include "framework.s65"
;-------------------------------------------------------------------------
.section zp
lightpen_addr:
.fill 2
.send zp
;-------------------------------------------------------------------------
.section code
;-------------------------------------------------------------------------
fx_init_1: .proc
jsr load_mode2_screen
rts
.pend
;-------------------------------------------------------------------------
fx_init_2: .proc
lda #<screen_base
sta lightpen_addr+0
lda >#screen_base
sta lightpen_addr+1
jsr lightpen_marker
rts
.pend
;-------------------------------------------------------------------------
fx_update: .proc
inc screen_base+31*screen_row_stride
jsr lightpen_marker
jsr get_lightpen_addr
jsr lightpen_marker
sta (lightpen_addr),y
rts
.pend
;-------------------------------------------------------------------------
lightpen_marker: .proc
.for i=0,i<8,i+=1
ldy #i
lda (lightpen_addr),y
eor #mode2_value(5,5)
sta (lightpen_addr),y
.next
rts
.pend
;-------------------------------------------------------------------------
get_lightpen_addr: .proc
lda #16
sta $fe00
lda $fe01
sta lightpen_addr+1
lda #17
sta $fe00
lda $fe01
sta lightpen_addr+0
asl lightpen_addr+0
rol lightpen_addr+1
asl lightpen_addr+0
rol lightpen_addr+1
asl lightpen_addr+0
rol lightpen_addr+1
rts
.pend
;-------------------------------------------------------------------------
fx_draw: .proc
lda $fe4c
and #%00011111
ora #%11100000 ;CB2 high
sta $fe4c
nop
nop
nop
nop
jsr cycles_wait_32768
lda $fe4c
and #%00011111
ora #%11000000 ;CB2 low
sta $fe4c
rts
.pend
;-------------------------------------------------------------------------
.send code