git @ Cat's Eye Technologies SixtyPical / cfbc840
version of demo with joystick is almost a game. Cat's Eye Technologies 8 years ago
4 changed file(s) with 172 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
1111 } else {
1212 }
1313 }
14
15 routine compare_16_bit {
16 lda >m
17 cmp >n
18 if beq {
19 lda <m
20 cmp <n
21 } else {
22 }
23 }
0 assign byte table screen $0400
1 assign byte table screen2 1274
2 assign byte table screen3 1524
3 assign byte table screen4 1774
4
5 assign byte table colormap 55296
6 assign byte table colormap2 55546
7 assign byte table colormap3 55796
8 assign byte table colormap4 56046
9
10 assign byte vic_border 53280
11 assign byte table vic_bg 53281
12
13 assign byte joy2 $dc00
14
15 assign vector cinv 788
16
17 ; ---------
18
19 reserve vector save_cinv
20 assign word position $fb
21 reserve word delta
22 reserve byte value
23 reserve word compare_target
24
25 routine main {
26 lda #5
27 sta vic_border
28 lda #0
29 sta vic_bg
30 jsr reset_position
31 jsr clear_screen
32 sei {
33 copy vector cinv to save_cinv
34 copy routine our_cinv to cinv
35 }
36 clc
37 repeat bcc { }
38 }
39
40 routine our_cinv {
41 lda value
42 inc value
43 ldy #0
44 sta (position), y
45 jsr read_stick
46 jsr advance_pos
47
48 lda #$07 ; just past bottom of screen
49 sta >compare_target
50 lda #$e8
51 sta <compare_target
52 jsr compare_pos
53
54 if bcs {
55 jsr reset_position
56 } else {
57
58 lda #$04
59 sta >compare_target
60 lda #$00
61 sta <compare_target
62 jsr compare_pos
63
64 if bcc {
65 jsr reset_position
66 } else { }
67 }
68 jmp save_cinv
69 }
70
71 routine reset_position {
72 lda #$00
73 sta <position
74 lda #$04
75 sta >position
76 }
77
78 routine advance_pos {
79 clc
80 lda <position
81 adc <delta
82 sta <position
83 lda >position
84 adc >delta
85 sta >position
86 }
87
88 routine compare_pos {
89 lda >position
90 cmp >compare_target
91 if beq {
92 lda <position
93 cmp <compare_target
94 } else {
95 }
96 }
97
98 routine clear_screen {
99 ldy #0
100 repeat bne {
101 lda #1
102 sta colormap, y
103 sta colormap2, y
104 sta colormap3, y
105 sta colormap4, y
106
107 lda #32
108 sta screen, y
109 sta screen2, y
110 sta screen3, y
111 sta screen4, y
112
113 iny
114 cpy #250
115 }
116 }
117
118 routine read_stick {
119 lda #0
120 sta <delta
121 sta >delta
122 ldx joy2
123 txa
124 and #1 ; up
125 if beq {
126 lda #216 ; -40
127 sta <delta
128 lda #255
129 sta >delta
130 } else {
131 txa
132 and #2 ; down
133 if beq {
134 lda #40
135 sta <delta
136 } else {
137 txa
138 and #4 ; left
139 if beq {
140 lda #255 ; -1
141 sta <delta
142 lda #255
143 sta >delta
144 } else {
145 txa
146 and #8 ; right
147 if beq {
148 lda #1
149 sta <delta
150 } else { }
151 }
152 }
153 }
154 }
8282 emitInstr p r (ADD A (NamedLocation st label)) = "adc " ++ label
8383 emitInstr p r (ADD A (Immediate val)) = "adc #" ++ (show val)
8484
85 emitInstr p r (ADD A (LowByteOf (NamedLocation st label))) = "adc " ++ label
86 emitInstr p r (ADD A (HighByteOf (NamedLocation st label))) = "adc " ++ label ++ "+1"
87
8588 emitInstr p r (AND A (NamedLocation st label)) = "and " ++ label
8689 emitInstr p r (AND A (Immediate val)) = "and #" ++ (show val)
8790
300300 addressing_mode gen
301301 where
302302 gen (Immediately v) [] = ADD A (Immediate v)
303 gen (LowBytely l) [] = ADD A (LowByteOf (NamedLocation Nothing l))
304 gen (HighBytely l) [] = ADD A (HighByteOf (NamedLocation Nothing l))
303305 gen (Directly l) [] = ADD A (NamedLocation Nothing l)
304306
305307 sbc :: Parser Instruction
309311 addressing_mode gen
310312 where
311313 gen (Immediately v) [] = SUB A (Immediate v)
314 gen (LowBytely l) [] = SUB A (LowByteOf (NamedLocation Nothing l))
315 gen (HighBytely l) [] = SUB A (HighByteOf (NamedLocation Nothing l))
312316 gen (Directly l) [] = SUB A (NamedLocation Nothing l)
313317
314318 and :: Parser Instruction