git @ Cat's Eye Technologies SixtyPical / 1b5f4c0
Add architecture-dependent "joy2delta.60p" to "standard library". Chris Pressey 2 years ago
5 changed file(s) with 43 addition(s) and 77 deletion(s). Raw diff Collapse all Expand all
2323 generation for constructs in tail position, notably
2424 tail optimization of `calls`, but also for `goto`s and
2525 `if` blocks at the end of a routine.
26 * Began collecting architecture-specific and portable
27 include-files for a nascent "standard library".
2628
2729 0.20
2830 ----
7777 Implementation
7878 --------------
7979
80 ### Line numbers in analysis error messages
80 ### Filename and line number in analysis error messages
8181
8282 For analysis errors, there is a line number, but it's the line of the routine
8383 after the routine in which the analysis error occurred. Fix this.
84
85 ### Libraries
86
87 Now that we have dead-code removal, establish some libraries of reusable
88 routines.
8984
9085 Blue-skying
9186 -----------
00 // ****************************
11 // * Demo Game for SixtyPical *
22 // ****************************
3
4 include "joy2delta.60p"
35
46 // ----------------------------------------------------------------
57 // Type Definitions
5557 byte vic_bg @ 53281
5658 byte table[2048] screen @ 1024
5759 byte table[2048] colormap @ 55296
58 byte joy2 @ $dc00
5960
6061 // ----------------------------------------------------------------
6162 // Global Variables
6869 word new_pos
6970
7071 word table[256] actor_delta
71 word delta
7272
7373 byte player_died
7474
101101 // ----------------------------------------------------------------
102102 // Utility Routines
103103 // ----------------------------------------------------------------
104
105 define read_stick routine
106 inputs joy2
107 outputs delta
108 trashes a, x, z, n
109 {
110 ld x, joy2
111 ld a, x
112 and a, 1 // up
113 if z {
114 copy $ffd8, delta // -40
115 } else {
116 ld a, x
117 and a, 2 // down
118 if z {
119 copy word 40, delta
120 } else {
121 ld a, x
122 and a, 4 // left
123 if z {
124 copy $ffff, delta // -1
125 } else {
126 ld a, x
127 and a, 8 // right
128 if z {
129 copy word 1, delta
130 } else {
131 copy word 0, delta
132 }
133 }
134 }
135 }
136 }
137104
138105 // You can repeatedly (i.e. as part of actor logic or an IRQ handler)
139106 // call this routine.
0 include "joy2delta.60p"
1
02 word screen @ 1024
1 byte joy2 @ $dc00
2
3 word delta
4
5 define read_stick routine
6 inputs joy2
7 outputs delta
8 trashes a, x, z, n
9 {
10 ld x, joy2
11 ld a, x
12 and a, 1 // up
13 if z {
14 copy $ffd8, delta // -40
15 } else {
16 ld a, x
17 and a, 2 // down
18 if z {
19 copy word 40, delta
20 } else {
21 ld a, x
22 and a, 4 // left
23 if z {
24 copy $ffff, delta // -1
25 } else {
26 ld a, x
27 and a, 8 // right
28 if z {
29 copy word 1, delta
30 } else {
31 copy word 0, delta
32 }
33 }
34 }
35 }
36 }
373
384 define main routine
395 inputs joy2
0 byte joy2 @ $dc00
1
2 word delta
3
4 define read_stick routine
5 inputs joy2
6 outputs delta
7 trashes a, x, z, n
8 {
9 ld x, joy2
10 ld a, x
11 and a, 1 // up
12 if z {
13 copy $ffd8, delta // -40
14 } else {
15 ld a, x
16 and a, 2 // down
17 if z {
18 copy word 40, delta
19 } else {
20 ld a, x
21 and a, 4 // left
22 if z {
23 copy $ffff, delta // -1
24 } else {
25 ld a, x
26 and a, 8 // right
27 if z {
28 copy word 1, delta
29 } else {
30 copy word 0, delta
31 }
32 }
33 }
34 }
35 }