git @ Cat's Eye Technologies SixtyPical / 5e4bf5c
Get eg/* working again. Cat's Eye Technologies 8 years ago
7 changed file(s) with 95 addition(s) and 84 deletion(s). Raw diff Collapse all Expand all
1818 | }
1919 | sta screen
2020 | }
21 = jmp main
2122 = main:
2223 = lda screen
2324 = cmp screen
4546 | }
4647 | sty screen
4748 | }
49 = jmp main
4850 = main:
4951 = ldy zero
5052 =
7678 | lda #3
7779 | }
7880 | }
81 = jmp main
7982 = main:
8083 = BEQ _label_3
8184 = lda #3
112115 | inc screen
113116 | jmp (save_cinv)
114117 | }
118 = jmp main
115119 = main:
116120 = sei
117121 = lda cinv
140144 | routine main {
141145 | copy #23 position
142146 | }
147 = jmp main
143148 = main:
144149 = lda #23
145150 = sta position
153158 | routine main {
154159 | copy #$0400 position
155160 | }
161 = jmp main
156162 = main:
157163 = lda #0
158164 = sta position
202202 | ora #8
203203 | ora vbyte
204204 | }
205 = jmp main
205206 = main:
206207 = lda #4
207208 = ldx #0
275276 | eor #5
276277 | eor vbyte
277278 | }
279 = jmp main
278280 = main:
279281 = asl
280282 = asl vbyte
304306 | lda #2
305307 | }
306308 | }
309 = jmp main
307310 = main:
308311 = pha
309312 = sei
2020 reserve word m
2121 reserve word n
2222
23 routine main {
24 lda #5
25 sta vic_border
26 lda #0
27 sta vic_bg
28 jsr reset_position
29 jsr clear_screen
30 sei {
31 copy cinv save_cinv
32 copy routine our_cinv to cinv
33 }
34 clc
35 repeat bcc { }
36 }
37
3823 routine reset_position {
3924 lda #$00
4025 sta <position
4126 lda #$04
4227 sta >position
43 }
44
45 routine our_cinv {
46 lda value
47 inc value
48 ldy #0
49 sta (position), y
50 jsr increment_pos
51 jsr compare_pos
52 if beq {
53 jsr reset_position
54 } else {
55 }
56 jmp (save_cinv)
5728 }
5829
5930 routine increment_pos {
6637 sta >position
6738 }
6839
40 routine compare_16_bit {
41 lda >m
42 cmp >n
43 if beq {
44 lda <m
45 cmp <n
46 } else {
47 }
48 }
49
6950 routine compare_pos {
7051 lda <position
7152 sta <m
7657 lda #$e8
7758 sta <n
7859 jsr compare_16_bit
79 }
80
81 routine compare_16_bit {
82 lda >m
83 cmp >n
84 if beq {
85 lda <m
86 cmp <n
87 } else {
88 }
8960 }
9061
9162 routine clear_screen {
10778 cpy #250
10879 }
10980 }
81
82 routine our_cinv {
83 lda value
84 inc value
85 ldy #0
86 sta (position), y
87 jsr increment_pos
88 jsr compare_pos
89 if beq {
90 jsr reset_position
91 } else {
92 }
93 jmp (save_cinv)
94 }
95
96 routine main {
97 lda #5
98 sta vic_border
99 lda #0
100 sta vic_bg
101 jsr reset_position
102 jsr clear_screen
103 sei {
104 copy cinv save_cinv
105 copy routine our_cinv to cinv
106 }
107 clc
108 repeat bcc { }
109 }
2525 reserve byte value
2626 reserve word compare_target
2727
28 routine main {
29 lda #5
30 sta vic_border
31 lda #0
32 sta vic_bg
33 jsr reset_position
34 jsr clear_screen
35 sei {
36 copy cinv save_cinv
37 copy routine our_cinv to cinv
38 }
39 clc
40 repeat bcc { }
41 }
42
43 routine our_cinv {
44 lda #32
45 ldy #0
46 sta (position), y
47 jsr read_stick
48 jsr advance_pos
49 jsr check_new_position_in_bounds
50 if bcs {
51 jsr install_new_position
52 } else { }
53
54 lda #81
55 ldy #0
56 sta (position), y
57
58 jmp (save_cinv)
59 }
60
6128 routine reset_position {
6229 copy #$0400 position
6330 }
7643 copy new_position position
7744 }
7845
46 routine compare_new_pos {
47 lda >new_position
48 cmp >compare_target
49 if beq {
50 lda <new_position
51 cmp <compare_target
52 } else {
53 }
54 }
55
7956 routine check_new_position_in_bounds {
8057 copy #$07e8 compare_target ; just past bottom of screen
8158 jsr compare_new_pos
9269 } else {
9370 sec
9471 }
95 }
96 }
97
98 routine compare_new_pos {
99 lda >new_position
100 cmp >compare_target
101 if beq {
102 lda <new_position
103 cmp <compare_target
104 } else {
10572 }
10673 }
10774
162129 }
163130 }
164131 }
132
133 routine our_cinv {
134 lda #32
135 ldy #0
136 sta (position), y
137 jsr read_stick
138 jsr advance_pos
139 jsr check_new_position_in_bounds
140 if bcs {
141 jsr install_new_position
142 } else { }
143
144 lda #81
145 ldy #0
146 sta (position), y
147
148 jmp (save_cinv)
149 }
150
151 routine main {
152 lda #5
153 sta vic_border
154 lda #0
155 sta vic_bg
156 jsr reset_position
157 jsr clear_screen
158 sei {
159 copy cinv save_cinv
160 copy routine our_cinv to cinv
161 }
162 clc
163 repeat bcc { }
164 }
108108 checkInstr NOP progCtx routCtx =
109109 routCtx
110110
111 {-
112111 checkInstr instr _ _ = error (
113112 "Internal error: sixtypical doesn't know how to " ++
114113 "analyze '" ++ (show instr) ++ "'")
115 -}
116114
117115 --
118116 -- Utility function:
132130 Map.insert location usage routCtxAccum
133131 False ->
134132 Map.insert location (PoisonedWith ulocation) routCtxAccum
133 PoisonedWith ulocation ->
134 Map.insert location usage routCtxAccum
135135 in
136136 Map.foldrWithKey (poison) routCtx calledRoutCtx
137137
66 import SixtyPical.Model
77
88 emitProgram p@(Program decls routines) =
9 " jmp main\n" ++
910 emitRoutines p routines ++
1011 emitDecls p decls
1112
4040
4141 toplevel :: Parser Program
4242 toplevel = do
43 spaces
4344 decls <- many decl
4445 routines <- many routine
4546 return $ Program decls routines