├── CHANGELOG.md
├── LICENSE.md
├── README.md
├── WHY.TXT
├── doc
├── 302L22.ppt
├── IntegerArithm.pdf
├── arithmetic2.ps
├── ca-lec7.ppt
├── ca11.pdf
├── ca12.pdf
└── division.pdf
├── img
├── help.png
├── tiny3dBig.gif
├── tiny3dBig2.gif
├── title.png
└── vms_icon.gif
├── pc
├── nonrestoring.c
└── sinetable.c
├── rom
├── 3D.DCI
├── 3D.VMI
├── 3D.VMS
└── start.vms
├── src
├── 3d.s
├── 3d_add.i
├── 3d_clip_and_draw_lines.i
├── 3d_demo.i
├── 3d_div.i
├── 3d_dot_product.i
├── 3d_draw_line.i
├── 3d_framebuffer.i
├── 3d_matrix.i
├── 3d_matrix_skeletons.i
├── 3d_mul.i
├── 3d_polygon_data.i
├── 3d_project_point.i
├── 3d_put_polygon.i
├── 3d_rotate_x.i
├── 3d_rotate_y.i
├── 3d_rotate_z.i
├── 3d_scale.i
├── 3d_sincos.i
├── 3d_stack.i
├── 3d_sub.i
├── 3d_test.i
├── 3d_translate.i
├── Tiny3dEngine.dev
├── Tiny3dEngine.layout
├── help.i
├── icon.i
├── logo.i
├── misc.i
├── sfr.i
├── sinetable.i
└── title.i
└── util
├── DCI_VMI.COM
├── assemble.bat
├── bmp2asm.bat
├── createDCI.bat
└── sinetable.bat
/LICENSE.md:
--------------------------------------------------------------------------------
1 | ;
2 | ; Copyright (c) 2003/2006/2023 Thomas Fuchs / The Rockin'-B, www.rockin-b.de
3 | ;
4 | ; Permission is granted to anyone to use this software for any purpose
5 | ; and to redistribute it freely, subject to the following restrictions:
6 | ;
7 | ; 1. The origin of this software must not be misrepresented. You must not
8 | ; claim that you wrote the original software. If you use this software
9 | ; in a product, an acknowledgment in the product documentation would be
10 | ; appreciated but is not required.
11 | ;
12 | ; 2. ANY COMMERCIAL USE IS PROHIBITED. This includes that you must not use
13 | ; this software in the production of a commercial product. Only an explicit
14 | ; permission by the author can allow you to do that.
15 | ;
16 | ; 3. Any modification applied to the software must be marked as such clearly.
17 | ;
18 | ; 4. This license may not be removed or altered from any distribution.
19 | ;
20 | ;
21 | ; NO WARRANTY
22 | ;
23 | ; THERE IS NO WARRANTY FOR THE PROGRAM.
24 | ; THE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
25 | ; EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
26 | ; THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE.
27 | ; THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.
28 | ; SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
29 | ; SERVICING, REPAIR OR CORRECTION.
30 | ;
31 | ; IN NO EVENT WILL THE COPYRIGHT HOLDER BE LIABLE TO YOU FOR DAMAGES,
32 | ; INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
33 | ; OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
34 | ; TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
35 | ; YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
36 | ; PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
37 | ; POSSIBILITY OF SUCH DAMAGES.
38 | ;
39 |
40 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Tiny 3D Engine
2 | Tiny 3D Engine for the Sega Dreamcast's Visual Memory Unit by Thomas Fuchs / The Rockin'-B
3 |
4 |
5 |
6 | 
7 |
|
8 |
9 |
|
10 |
11 |
|
12 |
13 |
|
14 |
15 | ## Features
16 | * Generic Matrix Transform Stack
17 | * Translation, Rotation, Scaling Operations
18 | * Perspective Projection Matrix
19 | * Multiple Geometry Types
20 | * Fast Lookup Table-Based SIN/COS Functions
21 | * Rendering Functions for Points and Lines
22 | * Clipping Routines
23 | * 16-Bit Addition (with Carry) of 2 Twos-Compliment Integers
24 | * 16-Bit Multiplicaton of 2 Twos-Compliment Integers
25 | * 16-Bit Division of 2 Twos-Compliment Integers
26 | * Dot Product for 3D/4D Vectors
27 |
28 | ## History
29 | The Tiny3D engine was developed from 2003 to 2006 by Thomas Fuchs, aka "The Rockin'-B," who was a well-known indie developer within the Sega Dreamcast VMU and Sega Saturn homebrew communities. It was originally released for download on his site, http://www.rockin-b.de/, where it stayed for many years, until the links eventually broke sometime around 2010.
30 |
31 | For years, Tiny3D engine was just an incredibly impressive ROM circulating around without any source code, with The Rockin'-B seemingly disappearing from the homebrew scene and his website. In 2023, I was finally able to contact him, and he has graciously supplied the VMU development scene with his original source tree, including source code, documentation, binaries, and a rigorous history of his work. I have uploaded it here so that it may be preserved and can benefit other VMU developers in the future.
32 |
33 | ## Building
34 | The project has been migrated away from building with Marcus Comstedt's original aslc86k assembler and to the newer, Waterbear assembler, which is fully cross-platform and has several additional features.
35 |
36 | To build, simply cd into the cloned repository, then run:
37 |
38 | $ waterbear assemble src/3d.s -o Tiny3D.vms
39 |
40 | ## References
41 | Within the doc folder lies a wealth of useful information, used during the development of the engine. These include varoius presentations and PDFs on the math routines and integer algorithms.
42 |
43 | ## Future Work and Optimizations
44 | Within The Rockin'-B's carefully kept notes (CHANGELOG) lies a treasure trove of information along with a list of potential and in-progress ideas for various performance optimizations which could still be implemented.
45 |
46 | ## ROMs
47 | The binary ROM images are available for download and can be used with any VMU emulator or loaded onto the actual device, using something such as DreamShell or VMU Explorer.
48 | * 3D.VMI (Web Browser Info Format)
49 | * 3D.VMS (Web Browser File Format)
50 | * 3D.DCI (Nexus Memory Card Format)
51 |
--------------------------------------------------------------------------------
/WHY.TXT:
--------------------------------------------------------------------------------
1 | You wonder why the Tiny 3d Engine for VMU
2 | took almost 3 years between completion and release?
3 |
4 | You wonder why the subtitle is "War On Iraque Edition"?
5 |
6 |
7 | The development of Tiny 3d Engine was stopped
8 | about the time when the war on iraque began.
9 | Although at that time I had nothing to do
10 | with either people in america nor iraq,
11 | the overall mood induced by Mr. Motherfuck himself
12 | caused a dramatical impact in my life (that I won't explain in detail)
13 | that holds on until today.
14 | Well, I'm someone who does not forgive nor forget.
15 | So this subtitle is just to remind that
16 | this war did not only destroy lifes of
17 | thousands from iraque and america,
18 | but did also effect people who are not involved in any way.
19 |
20 | Don't get me wrong about my huge dissappointment,
21 | because this is only one of a million things in the world
22 | that people can be dissappointed about.
23 |
24 |
--------------------------------------------------------------------------------
/doc/302L22.ppt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gyrovorbis/tiny3dengine/4cada5c9850b1252f522270635a28cafcd9e7763/doc/302L22.ppt
--------------------------------------------------------------------------------
/doc/IntegerArithm.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gyrovorbis/tiny3dengine/4cada5c9850b1252f522270635a28cafcd9e7763/doc/IntegerArithm.pdf
--------------------------------------------------------------------------------
/doc/ca-lec7.ppt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gyrovorbis/tiny3dengine/4cada5c9850b1252f522270635a28cafcd9e7763/doc/ca-lec7.ppt
--------------------------------------------------------------------------------
/doc/ca11.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gyrovorbis/tiny3dengine/4cada5c9850b1252f522270635a28cafcd9e7763/doc/ca11.pdf
--------------------------------------------------------------------------------
/doc/ca12.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gyrovorbis/tiny3dengine/4cada5c9850b1252f522270635a28cafcd9e7763/doc/ca12.pdf
--------------------------------------------------------------------------------
/doc/division.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gyrovorbis/tiny3dengine/4cada5c9850b1252f522270635a28cafcd9e7763/doc/division.pdf
--------------------------------------------------------------------------------
/img/help.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gyrovorbis/tiny3dengine/4cada5c9850b1252f522270635a28cafcd9e7763/img/help.png
--------------------------------------------------------------------------------
/img/tiny3dBig.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gyrovorbis/tiny3dengine/4cada5c9850b1252f522270635a28cafcd9e7763/img/tiny3dBig.gif
--------------------------------------------------------------------------------
/img/tiny3dBig2.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gyrovorbis/tiny3dengine/4cada5c9850b1252f522270635a28cafcd9e7763/img/tiny3dBig2.gif
--------------------------------------------------------------------------------
/img/title.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gyrovorbis/tiny3dengine/4cada5c9850b1252f522270635a28cafcd9e7763/img/title.png
--------------------------------------------------------------------------------
/img/vms_icon.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gyrovorbis/tiny3dengine/4cada5c9850b1252f522270635a28cafcd9e7763/img/vms_icon.gif
--------------------------------------------------------------------------------
/pc/nonrestoring.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gyrovorbis/tiny3dengine/4cada5c9850b1252f522270635a28cafcd9e7763/pc/nonrestoring.c
--------------------------------------------------------------------------------
/pc/sinetable.c:
--------------------------------------------------------------------------------
1 | #include
2 | #define M_PI 3.1415926535897932384626433832795
3 |
4 |
5 | int main(int argc, char argv[])
6 | {
7 | int i;
8 | printf("\t;; a sinetable for all angles between 0 and 90 degrees,\n\t;; represented as 16 bit fixed point number.\n\n");
9 |
10 | for(i = 0; i <= 90; i++)
11 | {
12 | // printf("\t .word %i\t;; sin(%ideg)\n", (short)(256 * sin((M_PI / 180) * i)), i);
13 | // bytes were swapped
14 | printf("\t .byte %i\n\t .byte %i\t;; sin(%ideg)\n", (unsigned char)(sin((M_PI / 180) * i)), (unsigned char)(256 * sin((M_PI / 180) * i)), i);
15 | }
16 |
17 |
18 |
19 | return 1;
20 | }
21 |
--------------------------------------------------------------------------------
/rom/3D.DCI:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gyrovorbis/tiny3dengine/4cada5c9850b1252f522270635a28cafcd9e7763/rom/3D.DCI
--------------------------------------------------------------------------------
/rom/3D.VMI:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gyrovorbis/tiny3dengine/4cada5c9850b1252f522270635a28cafcd9e7763/rom/3D.VMI
--------------------------------------------------------------------------------
/rom/3D.VMS:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gyrovorbis/tiny3dengine/4cada5c9850b1252f522270635a28cafcd9e7763/rom/3D.VMS
--------------------------------------------------------------------------------
/rom/start.vms:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gyrovorbis/tiny3dengine/4cada5c9850b1252f522270635a28cafcd9e7763/rom/start.vms
--------------------------------------------------------------------------------
/src/3d_add.i:
--------------------------------------------------------------------------------
1 |
2 | ;; Tiny 3d Engine for VMU
3 | ;;
4 | ;; >> War On Iraque Edition (06/01/08) <<
5 | ;;
6 | ;; by Rockin'-B, www.rockin-b.de
7 |
8 | ;
9 | ; Copyright (c) 2003/2006 Thomas Fuchs / The Rockin'-B, www.rockin-b.de
10 | ;
11 | ; Permission is granted to anyone to use this software for any purpose
12 | ; and to redistribute it freely, subject to the following restrictions:
13 | ;
14 | ; 1. The origin of this software must not be misrepresented. You must not
15 | ; claim that you wrote the original software. If you use this software
16 | ; in a product, an acknowledgment in the product documentation would be
17 | ; appreciated but is not required.
18 | ;
19 | ; 2. ANY COMMERCIAL USE IS PROHIBITED. This includes that you must not use
20 | ; this software in the production of a commercial product. Only an explicit
21 | ; permission by the author can allow you to do that.
22 | ;
23 | ; 3. Any modification applied to the software must be marked as such clearly.
24 | ;
25 | ; 4. This license may not be removed or altered from any distribution.
26 | ;
27 | ;
28 | ; NO WARRANTY
29 | ;
30 | ; THERE IS NO WARRANTY FOR THE PROGRAM.
31 | ; THE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
32 | ; EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
33 | ; THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE.
34 | ; THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.
35 | ; SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
36 | ; SERVICING, REPAIR OR CORRECTION.
37 | ;
38 | ; IN NO EVENT WILL THE COPYRIGHT HOLDER BE LIABLE TO YOU FOR DAMAGES,
39 | ; INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
40 | ; OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
41 | ; TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
42 | ; YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
43 | ; PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
44 | ; POSSIBILITY OF SUCH DAMAGES.
45 | ;
46 |
47 |
48 | ;; function: "add_16bit"
49 | ;; - performs the addition of 2 16 bit integers A_x and B_x
50 | ;; in 2's complement form
51 | ;; - result is stored in A_x
52 | ;; CYCLES: - subroutine: 16 + call = 18 cycles, embedded: 12-14 cycles
53 | ;; INPUTS: - A_low
54 | ;; - A_high
55 | ;; - B_low
56 | ;; - B_high
57 | ;; OUTPUTS: - A_low
58 | ;; - A_high
59 |
60 |
61 | add_16bit:
62 | push acc
63 |
64 | ld A_low
65 | ; clr1 psw, cy
66 | add B_low
67 | st A_low
68 | ld A_high
69 | addc B_high
70 | st A_high
71 |
72 | ;; overflow CAN occur, when one negative number is added to a positive and
73 | ;; overflow WILL occur, when 2 negative numbers are added
74 | ; bn psw, cy, .no_overflow
75 | ; bp A_high, 7, .no_overflow
76 | ;; now an overflow has occured
77 | ; clr1 psw, cy
78 |
79 | .no_overflow:
80 | pop acc
81 |
82 | ret
83 |
84 |
85 |
86 | add_17bit:
87 | push acc
88 | push psw
89 |
90 | callf add_16bit
91 |
92 | ;; set carry bit only when old and new carry bit are different
93 | pop acc
94 | xor psw
95 | clr1 psw, cy
96 |
97 | bn acc, cy, .no_set
98 | set1 psw, cy
99 |
100 | .no_set:
101 | pop acc
102 | ret
103 |
104 |
--------------------------------------------------------------------------------
/src/3d_clip_and_draw_lines.i:
--------------------------------------------------------------------------------
1 |
2 | ;; Tiny 3d Engine for VMU
3 | ;;
4 | ;; >> War On Iraque Edition (06/01/08) <<
5 | ;;
6 | ;; by Rockin'-B, www.rockin-b.de
7 |
8 | ;
9 | ; Copyright (c) 2003/2006 Thomas Fuchs / The Rockin'-B, www.rockin-b.de
10 | ;
11 | ; Permission is granted to anyone to use this software for any purpose
12 | ; and to redistribute it freely, subject to the following restrictions:
13 | ;
14 | ; 1. The origin of this software must not be misrepresented. You must not
15 | ; claim that you wrote the original software. If you use this software
16 | ; in a product, an acknowledgment in the product documentation would be
17 | ; appreciated but is not required.
18 | ;
19 | ; 2. ANY COMMERCIAL USE IS PROHIBITED. This includes that you must not use
20 | ; this software in the production of a commercial product. Only an explicit
21 | ; permission by the author can allow you to do that.
22 | ;
23 | ; 3. Any modification applied to the software must be marked as such clearly.
24 | ;
25 | ; 4. This license may not be removed or altered from any distribution.
26 | ;
27 | ;
28 | ; NO WARRANTY
29 | ;
30 | ; THERE IS NO WARRANTY FOR THE PROGRAM.
31 | ; THE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
32 | ; EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
33 | ; THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE.
34 | ; THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.
35 | ; SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
36 | ; SERVICING, REPAIR OR CORRECTION.
37 | ;
38 | ; IN NO EVENT WILL THE COPYRIGHT HOLDER BE LIABLE TO YOU FOR DAMAGES,
39 | ; INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
40 | ; OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
41 | ; TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
42 | ; YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
43 | ; PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
44 | ; POSSIBILITY OF SUCH DAMAGES.
45 | ;
46 |
47 |
48 | ;; function "clip_and_draw_lines"
49 | ;; - transforms start and end point of a line
50 | ;; such that they are on the screen, if possible
51 | ;; INPUTS: point1_x, point1_y
52 | ;; point2_x, point2_y
53 | ;; OUTPUTS: point1_x, point1_y
54 | ;; point2_x, point2_y
55 |
56 | clip_and_draw_lines:
57 | push point1_x
58 | push point1_y
59 | push point2_x
60 | push point2_y
61 | push acc
62 | push b
63 | push c
64 |
65 | bn control, no_clipping, .clip1
66 | brf .skip_v_bottom
67 |
68 | .clip1:
69 |
70 | ;; check if vertically outside of screen
71 |
72 | ;; first make sure that left point is in point1_? and right point is in point2_?
73 |
74 | ld point2_y
75 | sub point1_y
76 | bn acc, 7, .dont_swap1 ; if dy < 0, switch points
77 | bp psw, cy, .swap1 ; be aware of negative values
78 | .swap1:
79 | clr1 psw, cy
80 |
81 | ld point1_y ; switch y components
82 | xch point2_y
83 | st point1_y
84 |
85 | ld point1_x ; switch x components
86 | xch point2_x
87 | st point1_x
88 |
89 | .dont_swap1:
90 |
91 | ;; check top
92 |
93 | ;; if point1 is inside, don't check for point2, too
94 |
95 | bn point1_y, 7, .skip_v_top
96 |
97 | ;; if point2 is also top outside, don't draw line
98 |
99 | bn point2_y, 7, .comp_p1x
100 | brf .dont_draw
101 |
102 | .comp_p1x:
103 | ;; compute new point1_x
104 |
105 | ;; compute dx/dy
106 |
107 | ;; compute dy
108 |
109 | ld point2_y
110 | sub point1_y
111 | st b
112 |
113 | ;; compute dx
114 |
115 | ld point2_x
116 | sub point1_x
117 |
118 | clr1 control, sign
119 | bn acc, 7, .pos_p1x
120 | xor #%11111111
121 | inc acc
122 | set1 control, sign
123 |
124 | .pos_p1x:
125 | st acc ;; take care of rational values
126 | mov #0, c
127 |
128 | div
129 |
130 | ;; finished: dx/dy
131 |
132 | ;; result remains in c
133 |
134 | ;; compute number of points to clip away
135 | push acc
136 |
137 | ld point1_y
138 | xor #%11111111
139 | inc acc
140 | ; sub #32
141 | st b
142 |
143 | pop acc
144 |
145 | ;; compute x-axis difference
146 |
147 | mul
148 |
149 | st c
150 |
151 | ld point1_x
152 |
153 | sub c
154 | bp control, sign, .neg_p1x
155 | add c
156 | add c
157 | .neg_p1x:
158 | st point1_x
159 |
160 |
161 | ;; and set point1_y
162 |
163 | mov #0, point1_y
164 |
165 |
166 |
167 | .skip_v_top:
168 |
169 | ;; check bottom
170 |
171 | ;; if point2 is inside, don't check for point1, too
172 |
173 | ld point2_y
174 | sub #32
175 | bp psw, cy, .skip_v_bottom
176 |
177 | ;; check if point2 is right or left
178 |
179 | sub #96
180 | bn psw, cy, .skip_v_bottom
181 |
182 | ;; if point1 is also bottom outside, don't draw line
183 |
184 | ld point1_y ;; on screen check
185 | sub #32
186 | bp psw, cy, .comp_p2x
187 |
188 | sub #96 ;; right outside check
189 | bn psw, cy, .comp_p2x
190 | brf .dont_draw
191 |
192 | .comp_p2x:
193 | ;; compute new point2_x
194 |
195 | ;; compute dx/dy
196 |
197 | ;; compute dy
198 |
199 | ld point2_y
200 | sub point1_y
201 | st b
202 |
203 | ;; compute dx
204 |
205 | ld point2_x
206 | sub point1_x
207 |
208 | clr1 control, sign
209 | bn acc, 7, .pos_p2x
210 | xor #%11111111
211 | inc acc
212 | set1 control, sign
213 |
214 | .pos_p2x:
215 | st acc ;; take care of rational values
216 | mov #0, c
217 |
218 | div
219 |
220 | ;; finished: dx/dy
221 |
222 | ;; result remains in c
223 |
224 | ;; compute number of points to clip away
225 | push acc
226 |
227 | ld point2_y
228 | ; xor #%11111111
229 | ; inc acc
230 | sub #31
231 | st b
232 |
233 | pop acc
234 |
235 | ;; compute x-axis difference
236 |
237 | mul
238 |
239 | st c
240 |
241 | ld point2_x
242 |
243 | sub c
244 | bn control, sign, .neg_p2x
245 | add c
246 | add c
247 | .neg_p2x:
248 | st point2_x
249 |
250 |
251 | ;; and set point2_y
252 |
253 | mov #31, point2_y
254 |
255 | ;;;;
256 | ld point1_x
257 | st b
258 | ld point2_x
259 | st c
260 | mov #%10101010, acc
261 | .test:
262 | callf getkeys
263 | be #$FF, .test
264 | ;;;;
265 |
266 |
267 | .skip_v_bottom:
268 |
269 |
270 | ;; check if horizontally outside of screen
271 |
272 | ;; first make sure that left point is in point1_? and right point is in point2_?
273 |
274 | ld point2_x
275 | sub point1_x
276 | bn acc, 7, .dont_swap2 ; if dx < 0, switch points
277 | bp psw, cy, .swap2 ; be aware of negative values
278 | .swap2:
279 | clr1 psw, cy
280 |
281 | ld point1_y ; switch y components
282 | xch point2_y
283 | st point1_y
284 |
285 | ld point1_x ; switch x components
286 | xch point2_x
287 | st point1_x
288 |
289 | .dont_swap2:
290 | bn control, no_clipping, .clip2
291 | brf .skip_h_right
292 |
293 | .clip2:
294 |
295 | ;; check left
296 |
297 | ;; if point1 is inside, don't check for point2, too
298 |
299 | bn point1_x, 7, .skip_h_left
300 |
301 | ;; if point2 is also left outside, don't draw line
302 |
303 | bn point2_x, 7, .comp_p1y
304 | brf .dont_draw
305 |
306 | .comp_p1y:
307 |
308 | ;; compute new point1_y
309 |
310 | ;; compute dy/dx
311 |
312 | ;; compute dx
313 |
314 | ld point2_x
315 | sub point1_x
316 | st b
317 |
318 | ;; compute dy
319 |
320 | ld point2_y
321 | sub point1_y
322 |
323 | clr1 control, sign
324 | bn acc, 7, .pos_p1y
325 | xor #%11111111
326 | inc acc
327 | set1 control, sign
328 |
329 | .pos_p1y:
330 | st acc ;; take care of rational values
331 | mov #0, c
332 |
333 | div
334 |
335 | ;; finished: dy/dx
336 |
337 | ;; result remains in c
338 |
339 | ;; compute number of points to clip away
340 | push acc
341 |
342 | ld point1_x
343 | xor #%11111111
344 | inc acc
345 | ; sub #47
346 | st b
347 |
348 | pop acc
349 |
350 | ;; compute y-axis difference
351 |
352 | mul
353 |
354 | st c
355 |
356 | ld point1_y
357 |
358 | sub c
359 | bp control, sign, .neg_p1x1
360 | add c
361 | add c
362 | .neg_p1x1:
363 | st point1_y
364 |
365 |
366 | ;; and set point1_x
367 |
368 | mov #0, point1_x
369 |
370 | .skip_h_left:
371 |
372 | ;; check right
373 |
374 | ;; if point2 is inside, don't check for point1, too
375 |
376 | ld point2_x
377 | sub #48
378 | bp psw, cy, .skip_h_right
379 |
380 | ;; check if point2 is right or left
381 |
382 | sub #80
383 | bn psw, cy, .skip_h_right
384 |
385 | ;; if point1 is also right outside, don't draw line
386 |
387 | ld point1_x ;; on screen check
388 | sub #48
389 | bp psw, cy, .comp_p2y
390 |
391 | sub #80 ;; right outside check
392 | bp psw, cy, .dont_draw
393 | ; bn psw, cy, .comp_p2y
394 | ; brf .dont_draw
395 |
396 | .comp_p2y:
397 | ;; compute new point2_y
398 |
399 | ;; compute dy/dx
400 |
401 | ;; compute dx
402 |
403 | ld point2_x
404 | sub point1_x
405 | st b
406 |
407 | ;; compute dy
408 |
409 | ld point2_y
410 | sub point1_y
411 |
412 | clr1 control, sign
413 | bn acc, 7, .pos_p2y
414 | xor #%11111111
415 | inc acc
416 | set1 control, sign
417 |
418 | .pos_p2y:
419 | st acc ;; take care of rational values
420 | mov #0, c
421 |
422 | div
423 |
424 | ;; finished: dy/dx
425 |
426 | ;; result remains in c
427 |
428 | ;; compute number of points to clip away
429 | push acc
430 |
431 | ld point2_x
432 | ; xor #%11111111
433 | ; inc acc
434 | sub #47
435 | st b
436 |
437 | pop acc
438 |
439 | ;; compute y-axis difference
440 |
441 | mul
442 |
443 | st c
444 |
445 | ld point2_y
446 |
447 | sub c
448 | bn control, sign, .neg_p2y
449 | add c
450 | add c
451 | .neg_p2y:
452 | st point2_y
453 |
454 |
455 | ;; and set point2_x
456 |
457 | mov #47, point2_x
458 |
459 |
460 | .skip_h_right:
461 |
462 |
463 |
464 | callf draw_line
465 |
466 | .dont_draw:
467 | pop c
468 | pop b
469 | pop acc
470 | pop point2_y
471 | pop point2_x
472 | pop point1_y
473 | pop point1_x
474 |
475 | ret
476 |
477 |
--------------------------------------------------------------------------------
/src/3d_div.i:
--------------------------------------------------------------------------------
1 |
2 | ;; Tiny 3d Engine for VMU
3 | ;;
4 | ;; >> War On Iraque Edition (06/01/08) <<
5 | ;;
6 | ;; by Rockin'-B, www.rockin-b.de
7 |
8 | ;
9 | ; Copyright (c) 2003/2006 Thomas Fuchs / The Rockin'-B, www.rockin-b.de
10 | ;
11 | ; Permission is granted to anyone to use this software for any purpose
12 | ; and to redistribute it freely, subject to the following restrictions:
13 | ;
14 | ; 1. The origin of this software must not be misrepresented. You must not
15 | ; claim that you wrote the original software. If you use this software
16 | ; in a product, an acknowledgment in the product documentation would be
17 | ; appreciated but is not required.
18 | ;
19 | ; 2. ANY COMMERCIAL USE IS PROHIBITED. This includes that you must not use
20 | ; this software in the production of a commercial product. Only an explicit
21 | ; permission by the author can allow you to do that.
22 | ;
23 | ; 3. Any modification applied to the software must be marked as such clearly.
24 | ;
25 | ; 4. This license may not be removed or altered from any distribution.
26 | ;
27 | ;
28 | ; NO WARRANTY
29 | ;
30 | ; THERE IS NO WARRANTY FOR THE PROGRAM.
31 | ; THE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
32 | ; EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
33 | ; THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE.
34 | ; THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.
35 | ; SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
36 | ; SERVICING, REPAIR OR CORRECTION.
37 | ;
38 | ; IN NO EVENT WILL THE COPYRIGHT HOLDER BE LIABLE TO YOU FOR DAMAGES,
39 | ; INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
40 | ; OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
41 | ; TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
42 | ; YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
43 | ; PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
44 | ; POSSIBILITY OF SUCH DAMAGES.
45 | ;
46 |
47 |
48 | ;; function: "div_16bit" - 8.8 bits fixed point
49 | ;; - performs nonrestoring division of 2
50 | ;; 16bit integers C_x(dividend) and B_x(divisor)
51 | ;; in 2's complement form
52 | ;; - result is a 16 bit quotient stored in C_x and remainder in A_x,
53 | ;; INPUTS: - C_high, dividend
54 | ;; - C_low
55 | ;; - B_high, divisor
56 | ;; - B_low
57 | ;; OUTPUTS: - A_high, remainder
58 | ;; - A_low
59 | ;; - C_high, quotient
60 | ;; - C_low
61 | ;; MODIFIES: - bit sign in control
62 |
63 | div_16bit_slow:
64 | push acc
65 | push count
66 | push 1
67 |
68 | ; skipped for fixed point compatibility,
69 | ; ;; initialisation:
70 | ; xor acc ; clear A
71 | ; st A_low
72 | ; st A_high
73 |
74 | ;; now check for negative arguments
75 | clr1 control, sign
76 |
77 | ;; look if dividend is negative
78 | bn C_high, 7, .skip0
79 | not1 control, sign
80 | mov #C_low, 1
81 | callf twos_complement_16bit
82 |
83 | .skip0:
84 | ;; look if divisor is negative
85 | bn B_high, 7, .skip1
86 | not1 control, sign
87 | mov #B_low, 1
88 | callf twos_complement_16bit
89 |
90 | .skip1:
91 | ;; now shift the divident left to provide fixed point compatibility
92 | ld C_high
93 | st A_low
94 | ld C_low
95 | st C_high
96 | xor acc
97 | st C_low
98 | st A_high
99 |
100 | mov #16, count ; work on 16 bits
101 |
102 | .shiftloop:
103 | ; don't care what's shifted in
104 | ld C_low ; left shift A, Q (accumulator and dividend)
105 | rolc
106 | st C_low
107 | ld C_high
108 | rolc
109 | st C_high
110 | ld A_low
111 | rolc
112 | st A_low
113 | ld A_high
114 | rolc
115 | st A_high
116 |
117 | ; clr1 psw, cy ; don't influence later subs/adds
118 |
119 | ; bp A_high, 7, .negative0 ; A < 0? now look at the sign of the accumulator
120 | bp psw, cy, .negative0 ; A < 0? now look at the sign of the accumulator
121 |
122 | .positive0:
123 | callf sub_17bit ; A = A - M
124 |
125 | ; bp A_high, 7, .negative1 ; A < 0? now look at the sign of the accumulator
126 | bp psw, cy, .negative1 ; A < 0? now look at the sign of the accumulator
127 |
128 | .positive1:
129 | set1 C_low, 0 ; Q(0) = 1
130 |
131 | dbnz count, .shiftloop
132 |
133 | br .finished
134 |
135 | .negative0:
136 | callf add_17bit ; A = A + M
137 |
138 | ; bn A_high, 7, .positive1 ; A < 0? now look at the sign of the accumulator
139 | bn psw, cy, .positive1 ; A < 0? now look at the sign of the accumulator
140 |
141 | .negative1:
142 | clr1 C_low, 0 ; Q(0) = 1
143 |
144 | dbnz count, .shiftloop
145 |
146 | .finished:
147 | ; bn A_high, 7, .end0 ; A < 0? now look at the sign of the accumulator
148 | bn psw, cy, .end0 ; A < 0? now look at the sign of the accumulator
149 | callf add_16bit ; A = A + M
150 |
151 | .end0:
152 | bn control, sign, .end1
153 | mov #C_low, 1
154 | callf twos_complement_16bit
155 |
156 | .end1:
157 | pop 1
158 | pop count
159 | pop acc
160 |
161 | ret
162 |
163 |
164 | ;; use VM's multiplication function to speed up
165 | ;; discards divisor's low 8 bits, don't cares about remainder
166 |
167 |
168 | div_16bit:
169 | push acc
170 | push b
171 | push c
172 |
173 | ;; now check for negative arguments
174 | clr1 control, sign
175 |
176 | ;; look if dividend is negative
177 | bn C_high, 7, .skip0
178 | not1 control, sign
179 |
180 | ;; inlined "twos_complement"
181 |
182 | ld C_low
183 | xor #%11111111
184 | add #1
185 | st C_low
186 | ld C_high
187 | xor #%11111111
188 | addc #0
189 | st C_high
190 |
191 | .skip0:
192 | ;; look if divisor is negative
193 | bn B_high, 7, .skip1
194 | not1 control, sign
195 |
196 | ;; inlined "twos_complement"
197 |
198 | ld B_low
199 | xor #%11111111
200 | add #1
201 | st B_low
202 | ld B_high
203 | xor #%11111111
204 | addc #0
205 | st B_high
206 |
207 | .skip1:
208 |
209 | ;; instead of providing 8.8 fixed point compliency
210 | ;; by multiplying the dividend with 256(left shift of 8 bits),
211 | ;; devide the divisor by 256(right shift of 8 bits)
212 |
213 | ld B_high
214 | st b
215 | ld C_low
216 | st c
217 | ld C_high
218 |
219 | div
220 |
221 | ;; we have to check if remainder / B_low >= high 8 bit quotient
222 | ;; otherwise the result needs to be corrected(recomputed)
223 |
224 | push c
225 | push acc
226 |
227 | ;; prepare division
228 |
229 | mov #0, c
230 | ld B_low
231 | xch b
232 |
233 | div
234 |
235 | pop b
236 | sub b ;; only compare integer portion
237 |
238 | pop c
239 | ld b
240 |
241 | bn psw, cy, .correct
242 |
243 | ;; recompute and correct result
244 |
245 | ld B_high
246 | st b
247 | inc b ;; that's the correction
248 | ld C_low
249 | st c
250 | ld C_high
251 |
252 | div
253 |
254 | .correct:
255 | st C_high
256 | ld c
257 | st C_low
258 |
259 | bn control, sign, .end
260 |
261 | ;; inlined "twos_complement"
262 | ld C_low
263 | xor #%11111111
264 | add #1
265 | st C_low
266 | ld C_high
267 | xor #%11111111
268 | addc #0
269 | st C_high
270 |
271 | .end:
272 | pop c
273 | pop b
274 | pop acc
275 |
276 | ret
277 |
278 |
--------------------------------------------------------------------------------
/src/3d_dot_product.i:
--------------------------------------------------------------------------------
1 |
2 | ;; Tiny 3d Engine for VMU
3 | ;;
4 | ;; >> War On Iraque Edition (06/01/08) <<
5 | ;;
6 | ;; by Rockin'-B, www.rockin-b.de
7 |
8 | ;
9 | ; Copyright (c) 2003/2006 Thomas Fuchs / The Rockin'-B, www.rockin-b.de
10 | ;
11 | ; Permission is granted to anyone to use this software for any purpose
12 | ; and to redistribute it freely, subject to the following restrictions:
13 | ;
14 | ; 1. The origin of this software must not be misrepresented. You must not
15 | ; claim that you wrote the original software. If you use this software
16 | ; in a product, an acknowledgment in the product documentation would be
17 | ; appreciated but is not required.
18 | ;
19 | ; 2. ANY COMMERCIAL USE IS PROHIBITED. This includes that you must not use
20 | ; this software in the production of a commercial product. Only an explicit
21 | ; permission by the author can allow you to do that.
22 | ;
23 | ; 3. Any modification applied to the software must be marked as such clearly.
24 | ;
25 | ; 4. This license may not be removed or altered from any distribution.
26 | ;
27 | ;
28 | ; NO WARRANTY
29 | ;
30 | ; THERE IS NO WARRANTY FOR THE PROGRAM.
31 | ; THE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
32 | ; EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
33 | ; THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE.
34 | ; THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.
35 | ; SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
36 | ; SERVICING, REPAIR OR CORRECTION.
37 | ;
38 | ; IN NO EVENT WILL THE COPYRIGHT HOLDER BE LIABLE TO YOU FOR DAMAGES,
39 | ; INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
40 | ; OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
41 | ; TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
42 | ; YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
43 | ; PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
44 | ; POSSIBILITY OF SUCH DAMAGES.
45 | ;
46 |
47 |
48 | ;; function: "dot_product"
49 | ;; - used for 3x4 matrix multiplication
50 | ;; -> allows to handle 3 and 4 dimensions(last one multiplied by 1)
51 | ;; - performs a dot product of 2 3(4)-dimensional vectors
52 | ;; INPUTS: - 0 points to topmost element of vector 1
53 | ;; - 1 points to topmost element of vector 2
54 | ;; - bit "full_dimension" in control
55 | ;; OUTPUTS: - A_high/A_low hold 16 bit dot-product
56 |
57 |
58 | ;; assumes that all 16 pointers are set
59 | ;; and that irbk0 = irbk1 = 0
60 |
61 | dot_product:
62 | push acc
63 |
64 | ;; 1
65 |
66 | ld @R0
67 | st B_high
68 | ld @R1
69 | st C_high
70 | inc 0
71 | inc 1
72 | ld @R0
73 | st B_low
74 | ld @R1
75 | st C_low
76 | inc 0
77 | dec 1
78 |
79 | callf mul_16bit
80 |
81 | push C_low ; save result on stack,
82 | push C_high ; we have 4 multiplications, but only 3 additions
83 |
84 | set1 psw, irbk0
85 |
86 | ;; 2
87 |
88 | ld @R0
89 | st B_high
90 | ld @R1
91 | st C_high
92 | inc 4
93 | inc 5
94 | ld @R0
95 | st B_low
96 | ld @R1
97 | st C_low
98 | inc 4
99 | dec 5
100 |
101 | callf mul_16bit
102 |
103 | push C_low ; save result on stack,
104 | push C_high ; we have 4 multiplications, but only 3 additions
105 |
106 | clr1 psw, irbk0
107 | set1 psw, irbk1
108 |
109 | ;; 3
110 |
111 | ld @R0
112 | st B_high
113 | ld @R1
114 | st C_high
115 | inc 8
116 | inc 9
117 | ld @R0
118 | st B_low
119 | ld @R1
120 | st C_low
121 | inc 8
122 | dec 9
123 |
124 | callf mul_16bit
125 |
126 | push C_low ; save result on stack,
127 | push C_high ; we have 4 multiplications, but only 3 additions
128 |
129 | set1 psw, irbk0
130 |
131 | bn control, full_dimension, .skip_4th
132 | ;; 4
133 | ;; this multiplication is always with 1, can be left out
134 |
135 |
136 | ld @R1
137 | st C_high
138 | inc 13
139 | ld @R1
140 | st C_low
141 | dec 13
142 |
143 | push C_low ; save result on stack,
144 | push C_high ; we have 4 multiplications, but only 3 additions
145 |
146 | .skip_4th:
147 | pop A_high
148 | pop A_low
149 |
150 | ;; second, compute the sum of 3(4) products using 2(3) additions
151 |
152 | pop B_high
153 | pop B_low
154 |
155 | ;; inlined "add_16bit"
156 |
157 | ld A_low
158 | add B_low
159 | st A_low
160 | ld A_high
161 | addc B_high
162 | st A_high
163 |
164 | pop B_high
165 | pop B_low
166 |
167 | ;; inlined "add_16bit"
168 |
169 | ld A_low
170 | add B_low
171 | st A_low
172 | ld A_high
173 | addc B_high
174 | st A_high
175 |
176 | bn control, full_dimension, .skip_3rd
177 |
178 | pop B_high
179 | pop B_low
180 |
181 | ;; inlined "add_16bit"
182 |
183 | ld A_low
184 | add B_low
185 | st A_low
186 | ld A_high
187 | addc B_high
188 | st A_high
189 |
190 | .skip_3rd:
191 |
192 | ;; store result
193 |
194 | ld A_high
195 | st @R0
196 | inc 12
197 | ld A_low
198 | st @R0
199 | inc 12
200 |
201 | clr1 psw, irbk0
202 | clr1 psw, irbk1
203 |
204 | pop acc
205 |
206 | ret
207 |
208 |
209 |
210 |
211 |
212 | ;; function: "dot_product_transposed"
213 | ;; - used for point transformation
214 | ;; INPUTS: R0 points to 3x4 matrix line (c?1 c?2 c?3 c?4)
215 | ;; R1 points to point (x y z 1) with last "1" being omitted
216 | ;; OUTPUTS: A_high/A_low - the dot product
217 |
218 | dot_product_transposed:
219 | ; push acc
220 | push 1
221 | ; push count
222 |
223 | mov #3, count ; first, compute the 3 products
224 | .mul:
225 | ld @R0
226 | st B_high
227 | ld @R1
228 | st C_high
229 | inc 0
230 | inc 1
231 | ld @R0
232 | st B_low
233 | ld @R1
234 | st C_low
235 | inc 0
236 | inc 1
237 |
238 | callf mul_16bit
239 |
240 | push C_low ; save result on stack,
241 | push C_high ; we have 4 multiplications, but only 3 additions
242 |
243 | dbnz count, .mul
244 |
245 | ;; 4th element is always multiplied by 1, skip multiplication
246 |
247 | ld @R0
248 | st A_high
249 | inc 0
250 | ld @R0
251 | st A_low
252 |
253 | ; second, compute the sum of 4 products using 3 additions
254 |
255 | pop B_high
256 | pop B_low
257 |
258 | ;; inlined "add_16bit"
259 |
260 | ld A_low
261 | add B_low
262 | st A_low
263 | ld A_high
264 | addc B_high
265 | st A_high
266 |
267 | pop B_high
268 | pop B_low
269 |
270 | ;; inlined "add_16bit"
271 |
272 | ld A_low
273 | add B_low
274 | st A_low
275 | ld A_high
276 | addc B_high
277 | st A_high
278 |
279 | pop B_high
280 | pop B_low
281 |
282 | ;; inlined "add_16bit"
283 |
284 | ld A_low
285 | add B_low
286 | st A_low
287 | ld A_high
288 | addc B_high
289 | st A_high
290 |
291 | ; pop count
292 | pop 1
293 | ; pop acc
294 |
295 | ret
296 |
297 |
--------------------------------------------------------------------------------
/src/3d_draw_line.i:
--------------------------------------------------------------------------------
1 |
2 | ;; Tiny 3d Engine for VMU
3 | ;;
4 | ;; >> War On Iraque Edition (06/01/08) <<
5 | ;;
6 | ;; by Rockin'-B, www.rockin-b.de
7 |
8 | ;
9 | ; Copyright (c) 2003/2006 Thomas Fuchs / The Rockin'-B, www.rockin-b.de
10 | ;
11 | ; Permission is granted to anyone to use this software for any purpose
12 | ; and to redistribute it freely, subject to the following restrictions:
13 | ;
14 | ; 1. The origin of this software must not be misrepresented. You must not
15 | ; claim that you wrote the original software. If you use this software
16 | ; in a product, an acknowledgment in the product documentation would be
17 | ; appreciated but is not required.
18 | ;
19 | ; 2. ANY COMMERCIAL USE IS PROHIBITED. This includes that you must not use
20 | ; this software in the production of a commercial product. Only an explicit
21 | ; permission by the author can allow you to do that.
22 | ;
23 | ; 3. Any modification applied to the software must be marked as such clearly.
24 | ;
25 | ; 4. This license may not be removed or altered from any distribution.
26 | ;
27 | ;
28 | ; NO WARRANTY
29 | ;
30 | ; THERE IS NO WARRANTY FOR THE PROGRAM.
31 | ; THE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
32 | ; EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
33 | ; THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE.
34 | ; THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.
35 | ; SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
36 | ; SERVICING, REPAIR OR CORRECTION.
37 | ;
38 | ; IN NO EVENT WILL THE COPYRIGHT HOLDER BE LIABLE TO YOU FOR DAMAGES,
39 | ; INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
40 | ; OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
41 | ; TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
42 | ; YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
43 | ; PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
44 | ; POSSIBILITY OF SUCH DAMAGES.
45 | ;
46 |
47 |
48 | ;; function "draw_line"
49 | ;; - implements Bresenham's algorithm for fast drawing
50 | ;; INPUTS: - point1_x,
51 | ;; - point1_y,
52 | ;; - point2_x,
53 | ;; - point2_y point coordinates
54 |
55 | draw_line:
56 | push acc
57 | push b
58 | push c
59 | push count
60 | push vsel
61 | push vrmad1
62 | push vrmad2
63 |
64 | mov #0, count
65 |
66 | ;; initially set dx, dy, x and y
67 |
68 | .begin:
69 | ld point2_x
70 | st c ; c = x_1
71 | sub point1_x
72 | bn psw, cy, .normal ; if dx < 0, switch points
73 | clr1 psw, cy
74 | ; ld point1_y ; switch y components
75 | ; st b
76 | ; ld point2_y
77 | ; st point1_y
78 | ; ld b
79 | ; st point2_y
80 |
81 | ; ld point1_x ; switch x components
82 | ; st point2_x
83 | ; ld c
84 | ; st point1_x
85 |
86 | ld point1_y ; switch y components
87 | xch point2_y
88 | st point1_y
89 |
90 | ld point1_x ; switch x components
91 | xch point2_x
92 | st point1_x
93 |
94 | br .begin ; recompute dx
95 |
96 | .normal:
97 | st dx ; point2_x = dx, point1_x = x
98 | st t
99 |
100 | ;; init first points work RAM position, save masking bit to b
101 | ;; and make sure that workRAM pointers don't increase automatically
102 |
103 | bp control, fast_polyline, .get_values
104 | callf adress_workRAM
105 | br .store
106 |
107 | .get_values:
108 | ld T_vrmad1
109 | st vrmad1
110 | xor acc
111 | ;ld T_vrmad2
112 | st vrmad2
113 | ld T_b
114 |
115 | ;;;;;
116 | ; ld T_vrmad1
117 | ; st b
118 | ; st c
119 | ; ld T_b
120 | ;.test:
121 | ;
122 | ; br .test
123 | ;;;;;;
124 | .store:
125 | st b
126 | clr1 vsel, ince
127 |
128 | ;; seperate 4 methods
129 | ;; first check if dy >= 0
130 |
131 | ;; adjusting to draw_point's coordinate system
132 | ld point1_y
133 | sub point2_y
134 | bp psw, cy, .method_2_3
135 | st dy ; point2_y = dy, point1_y = y
136 |
137 | .method_0_1:
138 | ;; dy >= 0
139 | ;;
140 | ;; |
141 | ;; |
142 | ;; |
143 | ;; |____
144 | ;;
145 |
146 | ;; now check if dy > dx
147 | ld dx
148 | sub dy
149 | bn psw, cy, .method_1
150 |
151 | .method_0:
152 | ;; dy > dx
153 | ;; => 1 < m
154 | ;;
155 | ;; | /
156 | ;; | /
157 | ;; | /
158 | ;; |/
159 | ;;
160 |
161 | ;; recompute point2_y
162 | ld point1_y
163 | sub dy
164 | st c
165 |
166 | callf method0
167 | br .end
168 |
169 | .method_1:
170 | ;; dy <= dx
171 | ;; => 0 <= m <= 1
172 | ;;
173 | ;; /
174 | ;; /
175 | ;; /
176 | ;; /
177 | ;; ----
178 |
179 | callf method1
180 | br .end
181 |
182 | .method_2_3:
183 | ;; dy < 0
184 | ;; ____
185 | ;; |
186 | ;; |
187 | ;; |
188 | ;; |
189 | ;;
190 |
191 | ld dy ; now dy is positive again
192 | sub y
193 | st dy
194 |
195 | ;; now check if dy > dx
196 | ld dx
197 | sub dy
198 | bp psw, cy, .method_3
199 |
200 | .method_2:
201 | ;; dy <= dx
202 | ;; => -1 <= m < 0
203 | ;;
204 | ;; ____
205 | ;; \
206 | ;; \
207 | ;; \
208 | ;; \
209 | ;;
210 |
211 | callf method2
212 | br .end
213 |
214 | .method_3:
215 | ;; dy > dx
216 | ;; => m < -1
217 | ;;
218 | ;; |\
219 | ;; | \
220 | ;; | \
221 | ;; | \
222 | ;;
223 |
224 | ;; recompute point2_y
225 | ld point1_y
226 | add dy
227 | st c
228 |
229 | callf method3
230 |
231 | .end:
232 | ;; for fast polyline drawing: save position
233 |
234 | ld vrmad1
235 | st T_vrmad1
236 | ld vrmad2
237 | st T_vrmad2
238 | ld b
239 | st T_b
240 |
241 | pop vrmad2
242 | pop vrmad1
243 | pop vsel
244 | pop count
245 | pop c
246 | pop b
247 | pop acc
248 |
249 | ret
250 |
251 |
252 |
253 | ;; 1 < m
254 | ;;
255 | ;; | /
256 | ;; | /
257 | ;; | /
258 | ;; |/
259 | ;;
260 | ;; bottom up
261 |
262 | method0:
263 | .loop:
264 | ld y ; while x < x_1
265 | be c, .end
266 |
267 | ; mark
268 | ld b
269 | or vtrbf
270 | st vtrbf
271 |
272 | ;; adjusting to draw_point's coordinate system
273 | dec y ; x := x + 1
274 | ;; adjust work RAM adress
275 | ld vrmad1
276 | sub #6
277 | st vrmad1
278 |
279 | ld t ; t := t - 2dx
280 | sub dx
281 | bn psw, cy, .continue ; IF t < 0 part1
282 | set1 count, 0
283 |
284 | .continue:
285 | sub dx
286 | st t
287 | bpc count, 0, .increase
288 | bn psw, cy, .loop ; IF t < 0 part2
289 | ; THEN
290 | .increase:
291 | ;; adjusting to draw_point's coordinate system
292 | inc x ; y := y + 1
293 | ;; adjust work RAM adress
294 | ld b
295 | ror
296 | st b
297 | bn b, 7, .in_byte
298 | inc vrmad1
299 |
300 | .in_byte:
301 |
302 | ld t ; t := t + 2dy
303 | add dy
304 | add dy
305 | st t
306 | br .loop
307 | .end:
308 | ; mark
309 | ld b
310 | or vtrbf
311 | st vtrbf
312 |
313 | ret
314 |
315 |
316 |
317 | ;; 0 <= m <= 1
318 | ;;
319 | ;; /
320 | ;; /
321 | ;; /
322 | ;; /
323 | ;; ----
324 | ;; left to right
325 |
326 | method1:
327 | .loop:
328 | ld x ; while x < x_1
329 | be c, .end
330 |
331 | ; mark
332 | ld b
333 | or vtrbf
334 | st vtrbf
335 |
336 | inc x ; x := x + 1
337 | ;; adjust work RAM adress
338 | ld b
339 | ror
340 | st b
341 | bn b, 7, .in_byte
342 | inc vrmad1
343 |
344 | .in_byte:
345 |
346 | ld t ; t := t - 2dy
347 | sub dy
348 | bn psw, cy, .continue ; IF t < 0 part1
349 | set1 count, 0
350 |
351 | .continue:
352 | sub dy
353 | st t
354 | bpc count, 0, .increase
355 | bn psw, cy, .loop ; IF t < 0 part2
356 | ; THEN
357 | .increase:
358 | ;; adjusting to draw_point's coordinate system
359 | dec y ; y := y + 1
360 | ;; adjust work RAM adress
361 | ld vrmad1
362 | sub #6
363 | st vrmad1
364 |
365 | ld t ; t := t + 2dx
366 | add dx
367 | add dx
368 | st t
369 | br .loop
370 | .end:
371 | ; mark
372 | ld b
373 | or vtrbf
374 | st vtrbf
375 |
376 | ret
377 |
378 |
379 |
380 | ;; -1 <= m < 0
381 | ;;
382 | ;; ____
383 | ;; \
384 | ;; \
385 | ;; \
386 | ;; \
387 | ;;
388 | ;; left to right
389 |
390 | method2:
391 | .loop:
392 | ld x ; while x < x_1
393 | be c, .end
394 |
395 | ; mark
396 | ld b
397 | or vtrbf
398 | st vtrbf
399 |
400 | inc x ; x := x + 1
401 | ;; adjust work RAM adress
402 | ld b
403 | ror
404 | st b
405 | bn b, 7, .in_byte
406 | inc vrmad1
407 |
408 | .in_byte:
409 |
410 | ld t ; t := t - 2dy
411 | sub dy
412 | bn psw, cy, .continue ; IF t < 0, part1
413 | set1 count, 0
414 |
415 | .continue:
416 | sub dy
417 | st t
418 | bpc count, 0, .increase
419 | bn psw, cy, .loop ; IF t < 0, part2
420 | ; THEN
421 | .increase:
422 | ;; adjusting to draw_point's coordinate system
423 | inc y ; y := y + 1
424 | ;; adjust work RAM adress
425 | ld vrmad1
426 | add #6
427 | st vrmad1
428 |
429 | ld t ; t := t + 2dx
430 | add dx
431 | add dx
432 | st t
433 | br .loop
434 | .end:
435 | ; mark
436 | ld b
437 | or vtrbf
438 | st vtrbf
439 |
440 | ret
441 |
442 |
443 |
444 | ;; -1 > m
445 | ;;
446 | ;; |\
447 | ;; | \
448 | ;; | \
449 | ;; | \
450 | ;;
451 | ;; top down
452 |
453 | method3:
454 | .loop:
455 | ld y ; while x < x_1
456 | be c, .end
457 |
458 | ; mark
459 | ld b
460 | or vtrbf
461 | st vtrbf
462 |
463 | ;; adjusting to draw_point's coordinate system
464 | inc y ; x := x + 1
465 | ;; adjust work RAM adress
466 | ld vrmad1
467 | add #6
468 | st vrmad1
469 |
470 | ld t ; t := t - 2dy
471 | sub dx
472 | bn psw, cy, .continue ; IF t < 0 part1
473 | set1 count, 0
474 |
475 | .continue:
476 | sub dx
477 | st t
478 | bpc count, 0, .increase
479 | bn psw, cy, .loop ; IF t < 0 part2
480 | ; THEN
481 | .increase:
482 | ;; adjusting to draw_point's coordinate system
483 | inc x ; y := y + 1
484 | ;; adjust work RAM adress
485 | ld b
486 | ror
487 | st b
488 | bn b, 7, .in_byte
489 | inc vrmad1
490 |
491 | .in_byte:
492 | ld t ; t := t + 2dy
493 | add dy
494 | add dy
495 | st t
496 | br .loop
497 | .end:
498 | ; mark
499 | ld b
500 | or vtrbf
501 | st vtrbf
502 |
503 | ret
504 |
505 |
--------------------------------------------------------------------------------
/src/3d_framebuffer.i:
--------------------------------------------------------------------------------
1 |
2 | ;; Tiny 3d Engine for VMU
3 | ;;
4 | ;; >> War On Iraque Edition (06/01/08) <<
5 | ;;
6 | ;; by Rockin'-B, www.rockin-b.de
7 |
8 | ;
9 | ; Copyright (c) 2003/2006 Thomas Fuchs / The Rockin'-B, www.rockin-b.de
10 | ;
11 | ; Permission is granted to anyone to use this software for any purpose
12 | ; and to redistribute it freely, subject to the following restrictions:
13 | ;
14 | ; 1. The origin of this software must not be misrepresented. You must not
15 | ; claim that you wrote the original software. If you use this software
16 | ; in a product, an acknowledgment in the product documentation would be
17 | ; appreciated but is not required.
18 | ;
19 | ; 2. ANY COMMERCIAL USE IS PROHIBITED. This includes that you must not use
20 | ; this software in the production of a commercial product. Only an explicit
21 | ; permission by the author can allow you to do that.
22 | ;
23 | ; 3. Any modification applied to the software must be marked as such clearly.
24 | ;
25 | ; 4. This license may not be removed or altered from any distribution.
26 | ;
27 | ;
28 | ; NO WARRANTY
29 | ;
30 | ; THERE IS NO WARRANTY FOR THE PROGRAM.
31 | ; THE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
32 | ; EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
33 | ; THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE.
34 | ; THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.
35 | ; SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
36 | ; SERVICING, REPAIR OR CORRECTION.
37 | ;
38 | ; IN NO EVENT WILL THE COPYRIGHT HOLDER BE LIABLE TO YOU FOR DAMAGES,
39 | ; INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
40 | ; OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
41 | ; TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
42 | ; YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
43 | ; PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
44 | ; POSSIBILITY OF SUCH DAMAGES.
45 | ;
46 |
47 |
48 | ;; function "display_framebuffer"
49 | ;; - first 192 bytes of workRAM are copied to screen
50 |
51 | display_framebuffer:
52 | push acc
53 | push c
54 | push 2
55 | push xbnk
56 | push count
57 | push vrmad1
58 | push vrmad2
59 | push vsel
60 |
61 | xor acc
62 | st vrmad1
63 | st vrmad2
64 | st xbnk
65 |
66 | set1 vsel, ince
67 |
68 | callf write_selected_half_of_screen
69 | inc xbnk
70 | callf write_selected_half_of_screen
71 |
72 | pop vsel
73 | pop vrmad2
74 | pop vrmad1
75 | pop count
76 | pop xbnk
77 | pop 2
78 | pop c
79 | pop acc
80 |
81 | ret
82 |
83 |
84 |
85 | ;; function "write_selected_half_of_screen"
86 | ;; - sets the given bytes to selected half of screen
87 | ;; - assumes that ince of vsel is set
88 | ;; INPUTS: - xbnk
89 | ;; - 96 bytes in work RAM
90 | ;; - vrmad1
91 | ;; - vrmad2
92 | ;; OUTPUTS: - selected bank of XRAM
93 | ;; MODIFIES: - c
94 | ;; - 2
95 | ;; - count
96 | ;; - vtrbf
97 | ;; - vrmad1(indirect)
98 | ;; - vrmad2(indirect)
99 | ;; - vlreg(indirect)
100 |
101 | write_selected_half_of_screen:
102 | mov #8, count ;; # of line pairs to write
103 | mov #$7C, 2 ;; starting address
104 | .next_two_lines:
105 | mov #12, c
106 | ld 2 ;; adjust XRAM pointer to next two lines
107 | add #4
108 | st 2
109 | .next_byte:
110 | ld vtrbf
111 | st @R2
112 | inc 2
113 | dbnz c, .next_byte
114 | dbnz count, .next_two_lines
115 |
116 | ret
117 |
118 |
119 |
120 | ;; function "clear_framebuffer"
121 | ;; - first 192 bytes of workRAM are set to zero
122 |
123 |
124 | clear_framebuffer:
125 | push acc
126 | push vsel
127 | push vrmad1
128 | push vrmad2
129 |
130 | clr1 vsel, ince ; we are not using auto increment
131 | mov #191, vrmad1
132 | xor acc
133 | st vrmad2
134 |
135 | .next_byte:
136 | st vtrbf
137 | dbnz vrmad1, .next_byte
138 |
139 | st vtrbf
140 |
141 | pop vrmad2
142 | pop vrmad1
143 | pop vsel
144 | pop acc
145 |
146 | ret
147 |
148 |
--------------------------------------------------------------------------------
/src/3d_matrix.i:
--------------------------------------------------------------------------------
1 |
2 | ;; Tiny 3d Engine for VMU
3 | ;;
4 | ;; >> War On Iraque Edition (06/01/08) <<
5 | ;;
6 | ;; by Rockin'-B, www.rockin-b.de
7 |
8 | ;
9 | ; Copyright (c) 2003/2006 Thomas Fuchs / The Rockin'-B, www.rockin-b.de
10 | ;
11 | ; Permission is granted to anyone to use this software for any purpose
12 | ; and to redistribute it freely, subject to the following restrictions:
13 | ;
14 | ; 1. The origin of this software must not be misrepresented. You must not
15 | ; claim that you wrote the original software. If you use this software
16 | ; in a product, an acknowledgment in the product documentation would be
17 | ; appreciated but is not required.
18 | ;
19 | ; 2. ANY COMMERCIAL USE IS PROHIBITED. This includes that you must not use
20 | ; this software in the production of a commercial product. Only an explicit
21 | ; permission by the author can allow you to do that.
22 | ;
23 | ; 3. Any modification applied to the software must be marked as such clearly.
24 | ;
25 | ; 4. This license may not be removed or altered from any distribution.
26 | ;
27 | ;
28 | ; NO WARRANTY
29 | ;
30 | ; THERE IS NO WARRANTY FOR THE PROGRAM.
31 | ; THE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
32 | ; EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
33 | ; THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE.
34 | ; THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.
35 | ; SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
36 | ; SERVICING, REPAIR OR CORRECTION.
37 | ;
38 | ; IN NO EVENT WILL THE COPYRIGHT HOLDER BE LIABLE TO YOU FOR DAMAGES,
39 | ; INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
40 | ; OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
41 | ; TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
42 | ; YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
43 | ; PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
44 | ; POSSIBILITY OF SUCH DAMAGES.
45 | ;
46 |
47 |
48 | ;; function: "multiply_matrix"
49 | ;; - multiplies the current matrix with the specified matrix
50 | ;; from the left
51 | ;; - result overwrites current matrix
52 | ;; INPUTS: - R1 points to matrix to multiply with
53 | ;; - R0 points to current matrix
54 | ;; OUTPUTS: - current matrix in RAM
55 | ;; NEEDS: - additional(to variable rescue on enter AND nested functions)
56 | ;; 32 bytes in stack for resulting temporary matrix
57 |
58 | multiply_matrix:
59 | push acc
60 | push count
61 | push c
62 | push 1
63 |
64 | mov #3, count ; 4 rows(left matrix)
65 |
66 | ;; prepare for 1st pointer adjustment
67 |
68 | ld 1
69 | sub #8
70 | st 1
71 |
72 | ld 0
73 | add #24
74 | st 8
75 |
76 | ;; pointer 12 points to start of result matrix
77 | ;; select free current matrix
78 |
79 | mov #c1_start, 12
80 | bn control, current_matrix, .next_row
81 | mov #c0_start, 12
82 |
83 | .next_row:
84 | mov #4, c ; 4 columns(right matrix, but transposed, so row instead of column) for each row(left matrix)
85 | clr1 control, full_dimension
86 | ;; set pointers
87 |
88 | ;; left matrix (R1)
89 | ;; adjust R1 to point to next row
90 |
91 | ld 1
92 | add #8
93 | st 1
94 | add #2
95 | st 5
96 | add #2
97 | st 9
98 | ;; pointer to 4th element of left matrix needs to be set only when multiplied with last column
99 |
100 | ;; right matrix (R0)
101 | ;; adjust R0 to point to first column
102 |
103 | ;; pointer to 4th row of right matrix is not necessary
104 | ld 8
105 | sub #8
106 | st 8
107 | sub #8
108 | st 4
109 | sub #8
110 | st 0
111 |
112 | .next_column:
113 | ;; only last column needs 4 dimensions, others only 3
114 |
115 | ld c
116 | bne #1, .small_dimension
117 | set1 control, full_dimension
118 |
119 | ;; adjust last element's(of left matrix) pointer
120 |
121 | ld 9
122 | add #2
123 | st 13
124 |
125 | .small_dimension:
126 | callf dot_product
127 |
128 | dbnz c, .next_column
129 |
130 | dbnz count, .next_row
131 |
132 | ;; set new current matrix
133 |
134 | not1 control, current_matrix
135 |
136 | mov #c1_start, 0
137 | bp control, current_matrix, .skip
138 | mov #c0_start, 0
139 |
140 | .skip:
141 | pop 1
142 | pop c
143 | pop count
144 | pop acc
145 |
146 | ret
147 |
148 |
149 |
150 |
151 | ;; function "copy_matrix"
152 | ;; - copies source 3x4 matrix to destination 3x4 part of 4x4 matrix
153 | ;; INPUTS: - R1 points to source matrix start
154 | ;; - R0 points to target matrix start
155 |
156 | copy_matrix:
157 | push acc
158 | push 0
159 | push 1
160 | push count
161 |
162 | mov #24, count
163 |
164 | .loop:
165 | ld @R1
166 | st @R0
167 | inc 1
168 | inc 0
169 |
170 | dbnz count, .loop
171 |
172 |
173 | pop count
174 | pop 1
175 | pop 0
176 | pop acc
177 |
178 | ret
179 |
180 |
181 |
182 | ;; function: "display_matrix"
183 | ;; for debugging: prints the specified matrix with this format:
184 | ;;
185 | ;; 11 12
186 | ;;
187 | ;; 21 22
188 | ;;
189 | ;; 31 32
190 | ;;
191 | ;; 41 42
192 | ;;
193 | ;; 13 14
194 | ;;
195 | ;; 23 24
196 | ;;
197 | ;; 33 34
198 | ;;
199 | ;; 43 44
200 | ;;
201 | ;; INPUTS: - R1 points to element 11 of matrix to display
202 | ;; - xbnk selects upper or lower half of screen
203 |
204 |
205 | display_matrix:
206 | ; push xbnk
207 | push 2
208 | push c
209 | push count
210 |
211 | ; mov #0, xbnk
212 | mov #$80, 2
213 |
214 |
215 | ;; process elements 1x and 2x
216 | mov #3, c
217 |
218 | .loop:
219 | callf display_2_elements
220 |
221 | ld 2
222 | add #6
223 | st 2
224 | ld 1
225 | add #4
226 | st 1
227 |
228 | dbnz c, .loop
229 |
230 |
231 | ;; adjust to element 13 of matrix
232 | ld 1
233 | sub #20
234 | st 1
235 |
236 | ;; process elements 3x and 4x
237 | mov #3, c
238 |
239 | .loop1:
240 | callf display_2_elements
241 |
242 | ld 2
243 | add #6
244 | st 2
245 | ld 1
246 | add #4
247 | st 1
248 |
249 | dbnz c, .loop1
250 |
251 |
252 | pop count
253 | pop c
254 | pop 2
255 | ; pop xbnk
256 |
257 | ret
258 |
259 |
260 |
261 | display_2_elements:
262 | mov #4, count
263 |
264 | .loop:
265 | ld @R1
266 | st @R2
267 | inc 1
268 | inc 2
269 |
270 | dbnz count, .loop
271 |
272 |
273 | inc 2
274 | inc 2
275 |
276 | ;; underline
277 |
278 | mov #4, count
279 |
280 | .loop1:
281 | mov #$FF, @R2
282 | inc 2
283 |
284 | dbnz count, .loop1
285 |
286 | ret
287 |
288 |
--------------------------------------------------------------------------------
/src/3d_matrix_skeletons.i:
--------------------------------------------------------------------------------
1 |
2 | ;; Tiny 3d Engine for VMU
3 | ;;
4 | ;; >> War On Iraque Edition (06/01/08) <<
5 | ;;
6 | ;; by Rockin'-B, www.rockin-b.de
7 |
8 | ;
9 | ; Copyright (c) 2003/2006 Thomas Fuchs / The Rockin'-B, www.rockin-b.de
10 | ;
11 | ; Permission is granted to anyone to use this software for any purpose
12 | ; and to redistribute it freely, subject to the following restrictions:
13 | ;
14 | ; 1. The origin of this software must not be misrepresented. You must not
15 | ; claim that you wrote the original software. If you use this software
16 | ; in a product, an acknowledgment in the product documentation would be
17 | ; appreciated but is not required.
18 | ;
19 | ; 2. ANY COMMERCIAL USE IS PROHIBITED. This includes that you must not use
20 | ; this software in the production of a commercial product. Only an explicit
21 | ; permission by the author can allow you to do that.
22 | ;
23 | ; 3. Any modification applied to the software must be marked as such clearly.
24 | ;
25 | ; 4. This license may not be removed or altered from any distribution.
26 | ;
27 | ;
28 | ; NO WARRANTY
29 | ;
30 | ; THERE IS NO WARRANTY FOR THE PROGRAM.
31 | ; THE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
32 | ; EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
33 | ; THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE.
34 | ; THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.
35 | ; SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
36 | ; SERVICING, REPAIR OR CORRECTION.
37 | ;
38 | ; IN NO EVENT WILL THE COPYRIGHT HOLDER BE LIABLE TO YOU FOR DAMAGES,
39 | ; INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
40 | ; OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
41 | ; TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
42 | ; YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
43 | ; PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
44 | ; POSSIBILITY OF SUCH DAMAGES.
45 | ;
46 |
47 |
48 | matrix_skeletons:
49 |
50 |
51 | ;; RAM 88:
52 |
53 | ;; translation
54 | ;; / 1 0 0 tx \
55 | ;; | 0 1 0 ty |
56 | ;; | 0 0 1 tz |
57 | ;; \ 0 0 0 1 /
58 |
59 | .byte 1,0, 0,0, 0,0, 0,0
60 | .byte 0,0, 1,0, 0,0, 0,0
61 | .byte 0,0, 0,0, 1,0, 0,0
62 |
63 | ; just a test matrix...
64 | ; .byte 1,2, 3,4, 5,6, 7,8
65 | ; .byte 9,10, 11,12, 13,14, 15,16
66 | ; .byte 17,18, 19,20, 21,22, 23,24
67 |
68 | ;; RAM 112:
69 |
70 | ;; scaling
71 | ;; / sx 0 0 0 \
72 | ;; | 0 sy 0 0 |
73 | ;; | 0 0 sz 0 |
74 | ;; \ 0 0 0 1 /
75 |
76 | .byte 1,0, 0,0, 0,0, 0,0
77 | .byte 0,0, 1,0, 0,0, 0,0
78 | .byte 0,0, 0,0, 1,0, 0,0
79 |
80 | ;; RAM 136:
81 |
82 | ;; x-axis rotation
83 | ;; / 1 0 0 0 \
84 | ;; | 0 cos(angle) -sin(angle) 0 |
85 | ;; | 0 sin(angle) cos(angle) 0 |
86 | ;; \ 0 0 0 1 /
87 |
88 | .byte 1,0, 0,0, 0,0, 0,0
89 | .byte 0,0, 0,0, 0,0, 0,0
90 | .byte 0,0, 0,0, 0,0, 0,0
91 |
92 | ;; RAM 160:
93 |
94 | ;; y-axis rotation
95 | ;; / cos(angle) 0 sin(angle) 0 \
96 | ;; | 0 1 0 0 |
97 | ;; | -sin(angle) 0 cos(angle) 0 |
98 | ;; \ 0 0 0 1 /
99 |
100 | .byte 0,0, 0,0, 0,0, 0,0
101 | .byte 0,0, 1,0, 0,0, 0,0
102 | .byte 0,0, 0,0, 0,0, 0,0
103 |
104 | ;; RAM 184:
105 |
106 | ;; z-axis rotation
107 | ;; / cos(angle) -sin(angle) 0 0 \
108 | ;; | sin(angle) cos(angle) 0 0 |
109 | ;; | 0 0 1 0 |
110 | ;; \ 0 0 0 1 /
111 |
112 | .byte 0,0, 0,0, 0,0, 0,0
113 | .byte 0,0, 0,0, 0,0, 0,0
114 | .byte 0,0, 0,0, 1,0, 0,0
115 |
116 | ;; RAM 208:
117 |
118 | ;; current matrix 0
119 | ;; / 1 0 0 tx \
120 | ;; | 0 1 0 ty |
121 | ;; | 0 0 1 tz |
122 | ;; \ 0 0 0 1 /
123 |
124 | .byte 1,0, 0,0, 0,0, 0,0
125 | .byte 0,0, 1,0, 0,0, 0,0
126 | .byte 0,0, 0,0, 1,0, 0,0
127 |
128 | ;; RAM 232:
129 |
130 | ;; current matrix 1
131 | ;; / 1 0 0 tx \
132 | ;; | 0 1 0 ty |
133 | ;; | 0 0 1 tz |
134 | ;; \ 0 0 0 1 /
135 |
136 | .byte 1,0, 0,0, 0,0, 0,0
137 | .byte 0,0, 1,0, 0,0, 0,0
138 | .byte 0,0, 0,0, 1,0, 0,0
139 |
140 | ;; RAM 256: out of range
141 |
142 |
--------------------------------------------------------------------------------
/src/3d_mul.i:
--------------------------------------------------------------------------------
1 |
2 | ;; Tiny 3d Engine for VMU
3 | ;;
4 | ;; >> War On Iraque Edition (06/01/08) <<
5 | ;;
6 | ;; by Rockin'-B, www.rockin-b.de
7 |
8 | ;
9 | ; Copyright (c) 2003/2006 Thomas Fuchs / The Rockin'-B, www.rockin-b.de
10 | ;
11 | ; Permission is granted to anyone to use this software for any purpose
12 | ; and to redistribute it freely, subject to the following restrictions:
13 | ;
14 | ; 1. The origin of this software must not be misrepresented. You must not
15 | ; claim that you wrote the original software. If you use this software
16 | ; in a product, an acknowledgment in the product documentation would be
17 | ; appreciated but is not required.
18 | ;
19 | ; 2. ANY COMMERCIAL USE IS PROHIBITED. This includes that you must not use
20 | ; this software in the production of a commercial product. Only an explicit
21 | ; permission by the author can allow you to do that.
22 | ;
23 | ; 3. Any modification applied to the software must be marked as such clearly.
24 | ;
25 | ; 4. This license may not be removed or altered from any distribution.
26 | ;
27 | ;
28 | ; NO WARRANTY
29 | ;
30 | ; THERE IS NO WARRANTY FOR THE PROGRAM.
31 | ; THE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
32 | ; EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
33 | ; THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE.
34 | ; THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.
35 | ; SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
36 | ; SERVICING, REPAIR OR CORRECTION.
37 | ;
38 | ; IN NO EVENT WILL THE COPYRIGHT HOLDER BE LIABLE TO YOU FOR DAMAGES,
39 | ; INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
40 | ; OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
41 | ; TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
42 | ; YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
43 | ; PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
44 | ; POSSIBILITY OF SUCH DAMAGES.
45 | ;
46 |
47 |
48 | ;; function: "mul_16bit" - 8.8 bits fixed point
49 | ;; - performs multiplication of 2 16bit integers C_x and B_x
50 | ;; in 2's complement form
51 | ;; - result is a 32 bit integer stored in A_x and C_x,
52 | ;; C_x being the low 16 bits and A_x the high 16 bits
53 | ;; INPUTS: - C_high multiplier
54 | ;; - C_low
55 | ;; - B_high multiplicand
56 | ;; - B_low
57 | ;; OUTPUTS: - A_high, msb is msb of product
58 | ;; !! C_x !! - A_low
59 | ;; - C_high
60 | ;; - C_low, lsb is lsb of product
61 | ;; MODIFIES: - bit sign in control
62 |
63 | ;; use VM's multiplication function to speed up
64 | ;; !! use free space in SFR area in RAM for temporary storage
65 |
66 | mul_16bit:
67 | push acc
68 | push b
69 | push c
70 |
71 | ;; now check for negative arguments
72 | clr1 control, sign
73 |
74 | ;; look if multiplier is negative
75 | bn C_high, 7, .skip0
76 | not1 control, sign
77 |
78 | ;; inlined "twos_complement"
79 |
80 | ld C_low
81 | xor #%11111111
82 | add #1
83 | st C_low
84 | ld C_high
85 | xor #%11111111
86 | addc #0
87 | st C_high
88 |
89 | .skip0:
90 | ;; look if multiplicand is negative
91 | bn B_high, 7, .skip1
92 | not1 control, sign
93 |
94 | ;; inlined "twos_complement"
95 |
96 | ld B_low
97 | xor #%11111111
98 | add #1
99 | st B_low
100 | ld B_high
101 | xor #%11111111
102 | addc #0
103 | st B_high
104 |
105 | .skip1:
106 | ;; start to multiply low 8 bits of multiplicand
107 |
108 | ld B_low
109 | st b
110 | ld C_low
111 | st c
112 | ld C_high
113 |
114 | mul
115 |
116 | ;; for being 8.8 fixed point complient,
117 | ;; we discard the low 8 bits in c
118 | ;; and only use b,acc
119 |
120 | st T_low
121 | ld b
122 | st T_high
123 |
124 | ;; now multiply the high 8 bits of the multiplicand
125 |
126 | ld B_high
127 | st b
128 | ld C_low
129 | st c
130 | ld C_high
131 |
132 | mul
133 |
134 | ;; for being 8.8 fixed point complient,
135 | ;; we discard the high 8 bits in b
136 | ;; and only use acc, c
137 |
138 | ;; have to add previous result
139 |
140 | st b
141 | ld c
142 | add T_low
143 | st C_low
144 |
145 | ld b
146 | addc T_high
147 | st C_high
148 |
149 | bn control, sign, .end
150 |
151 | ;; inlined "twos_complement"
152 | ld C_low
153 | xor #%11111111
154 | add #1
155 | st C_low
156 | ld C_high
157 | xor #%11111111
158 | addc #0
159 | st C_high
160 |
161 | .end:
162 | pop c
163 | pop b
164 | pop acc
165 |
166 | ret
167 |
168 |
--------------------------------------------------------------------------------
/src/3d_polygon_data.i:
--------------------------------------------------------------------------------
1 |
2 | ;; Tiny 3d Engine for VMU
3 | ;;
4 | ;; >> War On Iraque Edition (06/01/08) <<
5 | ;;
6 | ;; by Rockin'-B, www.rockin-b.de
7 |
8 | ;
9 | ; Copyright (c) 2003/2006 Thomas Fuchs / The Rockin'-B, www.rockin-b.de
10 | ;
11 | ; Permission is granted to anyone to use this software for any purpose
12 | ; and to redistribute it freely, subject to the following restrictions:
13 | ;
14 | ; 1. The origin of this software must not be misrepresented. You must not
15 | ; claim that you wrote the original software. If you use this software
16 | ; in a product, an acknowledgment in the product documentation would be
17 | ; appreciated but is not required.
18 | ;
19 | ; 2. ANY COMMERCIAL USE IS PROHIBITED. This includes that you must not use
20 | ; this software in the production of a commercial product. Only an explicit
21 | ; permission by the author can allow you to do that.
22 | ;
23 | ; 3. Any modification applied to the software must be marked as such clearly.
24 | ;
25 | ; 4. This license may not be removed or altered from any distribution.
26 | ;
27 | ;
28 | ; NO WARRANTY
29 | ;
30 | ; THERE IS NO WARRANTY FOR THE PROGRAM.
31 | ; THE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
32 | ; EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
33 | ; THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE.
34 | ; THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.
35 | ; SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
36 | ; SERVICING, REPAIR OR CORRECTION.
37 | ;
38 | ; IN NO EVENT WILL THE COPYRIGHT HOLDER BE LIABLE TO YOU FOR DAMAGES,
39 | ; INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
40 | ; OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
41 | ; TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
42 | ; YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
43 | ; PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
44 | ; POSSIBILITY OF SUCH DAMAGES.
45 | ;
46 |
47 |
48 | ;; polygon data for testing
49 |
50 | ;; a cube made of lines
51 | polygon_data_05:
52 | .byte 2 ;; data type: lines
53 | .byte 8 ;; number of points
54 |
55 | ;; frontplane
56 |
57 | .byte $00 ;; x top right
58 | .byte $05
59 | .byte $FF ;; y
60 | .byte $FB
61 | .byte $FF ;; z
62 | .byte $FB
63 |
64 | .byte $00 ;; x bottom right
65 | .byte $05
66 | .byte $00 ;; y
67 | .byte $05
68 | .byte $FF ;; z
69 | .byte $FB
70 |
71 | .byte $FF ;; x bottom left
72 | .byte $FB
73 | .byte $00 ;; y
74 | .byte $05
75 | .byte $FF ;; z
76 | .byte $FB
77 |
78 | .byte $FF ;; x top left
79 | .byte $FB
80 | .byte $FF ;; y
81 | .byte $FB
82 | .byte $FF ;; z
83 | .byte $FB
84 |
85 | ;; backplane
86 |
87 | .byte $00 ;; x top right
88 | .byte $05
89 | .byte $FF ;; y
90 | .byte $FB
91 | .byte $00 ;; z
92 | .byte $05
93 |
94 | .byte $00 ;; x bottom right
95 | .byte $05
96 | .byte $00 ;; y
97 | .byte $05
98 | .byte $00 ;; z
99 | .byte $05
100 |
101 | .byte $FF ;; x bottom left
102 | .byte $FB
103 | .byte $00 ;; y
104 | .byte $05
105 | .byte $00 ;; z
106 | .byte $05
107 |
108 | .byte $FF ;; x top left
109 | .byte $FB
110 | .byte $FF ;; y
111 | .byte $FB
112 | .byte $00 ;; z
113 | .byte $05
114 |
115 | .byte 12 ;; number of lines
116 |
117 | ;; front plane
118 |
119 | .byte 0,1
120 | .byte 1,2
121 | .byte 2,3
122 | .byte 3,0
123 |
124 | ;; back plane
125 |
126 | .byte 4,5
127 | .byte 5,6
128 | .byte 6,7
129 | .byte 7,4
130 |
131 | ;; connection lines
132 |
133 | .byte 0,4
134 | .byte 1,5
135 | .byte 2,6
136 | .byte 3,7
137 |
138 | ;; a cube made of polylines
139 | polygon_data_04:
140 | .byte 3 ;; data type: polylines
141 | .byte 8 ;; number of points
142 |
143 | ;; frontplane
144 |
145 | .byte $00 ;; x top right
146 | .byte $05
147 | .byte $FF ;; y
148 | .byte $FB
149 | .byte $FF ;; z
150 | .byte $FB
151 |
152 | .byte $00 ;; x bottom right
153 | .byte $05
154 | .byte $00 ;; y
155 | .byte $05
156 | .byte $FF ;; z
157 | .byte $FB
158 |
159 | .byte $FF ;; x bottom left
160 | .byte $FB
161 | .byte $00 ;; y
162 | .byte $05
163 | .byte $FF ;; z
164 | .byte $FB
165 |
166 | .byte $FF ;; x top left
167 | .byte $FB
168 | .byte $FF ;; y
169 | .byte $FB
170 | .byte $FF ;; z
171 | .byte $FB
172 |
173 | ;; backplane
174 |
175 | .byte $00 ;; x top right
176 | .byte $05
177 | .byte $FF ;; y
178 | .byte $FB
179 | .byte $00 ;; z
180 | .byte $05
181 |
182 | .byte $00 ;; x bottom right
183 | .byte $05
184 | .byte $00 ;; y
185 | .byte $05
186 | .byte $00 ;; z
187 | .byte $05
188 |
189 | .byte $FF ;; x bottom left
190 | .byte $FB
191 | .byte $00 ;; y
192 | .byte $05
193 | .byte $00 ;; z
194 | .byte $05
195 |
196 | .byte $FF ;; x top left
197 | .byte $FB
198 | .byte $FF ;; y
199 | .byte $FB
200 | .byte $00 ;; z
201 | .byte $05
202 |
203 | .byte 4 ;; number of polylines
204 |
205 | ;; longest polyline
206 |
207 | .byte 9 ;; number of line segments
208 |
209 | .byte 0,1,2,3,0,4,5,6,7,4 ;; point indices between which are the line segments
210 |
211 | ;; 1st line segment
212 |
213 | .byte 1
214 |
215 | .byte 3,7
216 |
217 | ;; 2nd line segment
218 |
219 | .byte 1
220 |
221 | .byte 2,6
222 |
223 | ;; 3rd line segment
224 |
225 | .byte 1
226 |
227 | .byte 1,5
228 |
229 |
230 | ;; a pyramid made of points
231 | polygon_data_03:
232 | .byte 0 ;; data type: points
233 | .byte 5 ;; number of points
234 |
235 | .byte $00 ;; x top
236 | .byte $00
237 | .byte $FF ;; y
238 | .byte $FB
239 | .byte $00 ;; z
240 | .byte $00
241 |
242 | .byte $FF ;; x front left
243 | .byte $FB
244 | .byte $00 ;; y
245 | .byte $05
246 | .byte $FF ;; z
247 | .byte $FB
248 |
249 | .byte $00 ;; x front right
250 | .byte $05
251 | .byte $00 ;; y
252 | .byte $05
253 | .byte $FF ;; z
254 | .byte $FB
255 |
256 | .byte $00 ;; x back right
257 | .byte $05
258 | .byte $00 ;; y
259 | .byte $05
260 | .byte $00 ;; z
261 | .byte $05
262 |
263 | .byte $FF ;; x back left
264 | .byte $FB
265 | .byte $00 ;; y
266 | .byte $05
267 | .byte $00 ;; z
268 | .byte $05
269 |
270 | ;; a pyramid made of polylines
271 | polygon_data_02:
272 | .byte 3 ;; data type: polylines
273 | .byte 5 ;; number of points
274 |
275 | .byte $00 ;; x top
276 | .byte $00
277 | .byte $FF ;; y
278 | .byte $FB
279 | .byte $00 ;; z
280 | .byte $00
281 |
282 | .byte $FF ;; x front left
283 | .byte $FB
284 | .byte $00 ;; y
285 | .byte $05
286 | .byte $FF ;; z
287 | .byte $FB
288 |
289 | .byte $00 ;; x front right
290 | .byte $05
291 | .byte $00 ;; y
292 | .byte $05
293 | .byte $FF ;; z
294 | .byte $FB
295 |
296 | .byte $00 ;; x back right
297 | .byte $05
298 | .byte $00 ;; y
299 | .byte $05
300 | .byte $00 ;; z
301 | .byte $05
302 |
303 | .byte $FF ;; x back left
304 | .byte $FB
305 | .byte $00 ;; y
306 | .byte $05
307 | .byte $00 ;; z
308 | .byte $05
309 |
310 | .byte 2 ;; number of polylines
311 |
312 | ;; longest polyline
313 |
314 | .byte 7
315 |
316 | .byte 1,4,0,1,2,0,3,4
317 |
318 | ;; remaining line
319 |
320 | .byte 1
321 |
322 | .byte 2,3
323 |
324 | ;; a pyramid made of lines
325 | polygon_data_06:
326 | .byte 2 ;; data type: lines
327 | .byte 5 ;; number of points
328 |
329 | .byte $00 ;; x top
330 | .byte $00
331 | .byte $FF ;; y
332 | .byte $FB
333 | .byte $00 ;; z
334 | .byte $00
335 |
336 | .byte $FF ;; x front left
337 | .byte $FB
338 | .byte $00 ;; y
339 | .byte $05
340 | .byte $FF ;; z
341 | .byte $FB
342 |
343 | .byte $00 ;; x front right
344 | .byte $05
345 | .byte $00 ;; y
346 | .byte $05
347 | .byte $FF ;; z
348 | .byte $FB
349 |
350 | .byte $00 ;; x back right
351 | .byte $05
352 | .byte $00 ;; y
353 | .byte $05
354 | .byte $00 ;; z
355 | .byte $05
356 |
357 | .byte $FF ;; x back left
358 | .byte $FB
359 | .byte $00 ;; y
360 | .byte $05
361 | .byte $00 ;; z
362 | .byte $05
363 |
364 | .byte 1 ;; number of lines
365 |
366 | ;; bottom plane
367 |
368 | .byte 1,2
369 | .byte 2,3
370 | .byte 3,4
371 | .byte 4,1
372 |
373 | ;; side
374 |
375 | .byte 0,1
376 | .byte 0,2
377 | .byte 0,3
378 | .byte 0,4
379 | ;; a cube made of points with center in (0,0,0)
380 | polygon_data_01:
381 | .byte 0 ;; data type: points
382 | .byte 8 ;; number of points
383 |
384 | ;; frontplane
385 |
386 | .byte $00 ;; x top right
387 | .byte $05
388 | .byte $FF ;; y
389 | .byte $FB
390 | .byte $FF ;; z
391 | .byte $FB
392 |
393 | .byte $00 ;; x bottom right
394 | .byte $05
395 | .byte $00 ;; y
396 | .byte $05
397 | .byte $FF ;; z
398 | .byte $FB
399 |
400 | .byte $FF ;; x bottom left
401 | .byte $FB
402 | .byte $00 ;; y
403 | .byte $05
404 | .byte $FF ;; z
405 | .byte $FB
406 |
407 | .byte $FF ;; x top left
408 | .byte $FB
409 | .byte $FF ;; y
410 | .byte $FB
411 | .byte $FF ;; z
412 | .byte $FB
413 |
414 | ;; backplane
415 |
416 | .byte $00 ;; x top right
417 | .byte $05
418 | .byte $FF ;; y
419 | .byte $FB
420 | .byte $00 ;; z
421 | .byte $05
422 |
423 | .byte $00 ;; x bottom right
424 | .byte $05
425 | .byte $00 ;; y
426 | .byte $05
427 | .byte $00 ;; z
428 | .byte $05
429 |
430 | .byte $FF ;; x bottom left
431 | .byte $FB
432 | .byte $00 ;; y
433 | .byte $05
434 | .byte $00 ;; z
435 | .byte $05
436 |
437 | .byte $FF ;; x top left
438 | .byte $FB
439 | .byte $FF ;; y
440 | .byte $FB
441 | .byte $00 ;; z
442 | .byte $05
443 |
444 |
445 |
446 | polygon_lines_01:
447 | .byte 1 ;; data type: polyline
448 | .byte 2 ;; number of points
449 |
450 | .byte 0 ;; x
451 | .byte 19
452 | .byte 0 ;; y
453 | .byte 11
454 | .byte 0 ;; z
455 | .byte 5
456 |
457 | .byte 0 ;; x
458 | .byte 29
459 | .byte 0 ;; y
460 | .byte 11
461 | .byte 0 ;; z
462 | .byte 5
463 |
464 |
--------------------------------------------------------------------------------
/src/3d_project_point.i:
--------------------------------------------------------------------------------
1 |
2 | ;; Tiny 3d Engine for VMU
3 | ;;
4 | ;; >> War On Iraque Edition (06/01/08) <<
5 | ;;
6 | ;; by Rockin'-B, www.rockin-b.de
7 |
8 | ;
9 | ; Copyright (c) 2003/2006 Thomas Fuchs / The Rockin'-B, www.rockin-b.de
10 | ;
11 | ; Permission is granted to anyone to use this software for any purpose
12 | ; and to redistribute it freely, subject to the following restrictions:
13 | ;
14 | ; 1. The origin of this software must not be misrepresented. You must not
15 | ; claim that you wrote the original software. If you use this software
16 | ; in a product, an acknowledgment in the product documentation would be
17 | ; appreciated but is not required.
18 | ;
19 | ; 2. ANY COMMERCIAL USE IS PROHIBITED. This includes that you must not use
20 | ; this software in the production of a commercial product. Only an explicit
21 | ; permission by the author can allow you to do that.
22 | ;
23 | ; 3. Any modification applied to the software must be marked as such clearly.
24 | ;
25 | ; 4. This license may not be removed or altered from any distribution.
26 | ;
27 | ;
28 | ; NO WARRANTY
29 | ;
30 | ; THERE IS NO WARRANTY FOR THE PROGRAM.
31 | ; THE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
32 | ; EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
33 | ; THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE.
34 | ; THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.
35 | ; SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
36 | ; SERVICING, REPAIR OR CORRECTION.
37 | ;
38 | ; IN NO EVENT WILL THE COPYRIGHT HOLDER BE LIABLE TO YOU FOR DAMAGES,
39 | ; INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
40 | ; OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
41 | ; TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
42 | ; YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
43 | ; PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
44 | ; POSSIBILITY OF SUCH DAMAGES.
45 | ;
46 |
47 |
48 | project_point:
49 | mov #temp_vector, acc
50 | add #4
51 | st 1
52 | ;; x axis first(first component in workRAM)
53 | ;; Sx = (Sz - Cz)*dx/dz - Cx
54 | ;; = (0 - Cz)*(Px - 0)/(Pz - Cz) + 0
55 | ;; = (-Cz * Px)/(Pz - Cz)
56 |
57 |
58 | ;; (Pz - Cz)
59 |
60 | ld @R1
61 | st A_high
62 | inc 1
63 | ld @R1
64 | st A_low
65 | mov #Cz_high, B_high
66 | mov #Cz_low, B_low
67 |
68 | callf sub_16bit
69 |
70 | push A_high
71 | push A_low
72 | ;; (0 - Cz)
73 |
74 | mov #0, A_high
75 | mov #0, A_low
76 |
77 | callf sub_16bit
78 |
79 | ;; (0 - Cz) / (Pz - Cz)
80 |
81 | ;; move (0 - Cz) to C
82 |
83 | ld A_high
84 | st C_high
85 | ld A_low
86 | st C_low
87 |
88 | ;; move (Pz - Cz) from stack to B
89 |
90 | pop B_low
91 | pop B_high
92 |
93 | callf div_16bit
94 |
95 | ;; result is in C_x, save for y projection
96 | push C_high
97 | push C_low
98 |
99 |
100 | ;; (0 - Cz)/(Pz - Cz) * Px
101 |
102 | ;; move Px to B
103 |
104 | mov #temp_vector, 1
105 | ld @R1
106 | st B_high
107 | inc 1
108 | ld @R1
109 | st B_low
110 | inc 1
111 |
112 | callf mul_16bit
113 |
114 | ;; select low 16 bit to proceed
115 |
116 | ld C_high
117 | st A_high
118 | ld C_low
119 | st A_low
120 |
121 | ;; move right for half of screen width
122 |
123 | mov #0, B_high
124 | mov #24, B_low
125 | callf add_16bit
126 |
127 | ;; Sx: select low 8 bits for display
128 |
129 | ld A_low
130 | st vtrbf
131 |
132 | ;; y axis second(second component in workRAM)
133 |
134 | ;; Sy = (Sz - Cz)*dy/dz - Cy
135 | ;; = (0 - Cz)*(Py - 0)/(Pz - Cz) + 0
136 | ;; = (-Cz * Py)/(Pz - Cz)
137 |
138 | ;; (0 - Cz)/(Pz - Cz) * (Py - Cy)
139 |
140 | ;; move Py to B
141 |
142 | ld @R1
143 | st B_high
144 | inc 1
145 | ld @R1
146 | st B_low
147 |
148 | ;; move (0 - Cz)/(Pz - Cz) from stack to C
149 |
150 | pop C_low
151 | pop C_high
152 |
153 | callf mul_16bit
154 |
155 | ;; select low 16 bit to proceed
156 |
157 | ld C_high
158 | st A_high
159 | ld C_low
160 | st A_low
161 |
162 | ;; move down for half of screen height
163 |
164 | mov #0, B_high
165 | mov #16, B_low
166 | callf add_16bit
167 |
168 | ;; Sy: select low 8 bits for display
169 |
170 | ld A_low
171 | st vtrbf
172 |
173 | ret
174 |
175 |
--------------------------------------------------------------------------------
/src/3d_put_polygon.i:
--------------------------------------------------------------------------------
1 |
2 | ;; Tiny 3d Engine for VMU
3 | ;;
4 | ;; >> War On Iraque Edition (06/01/08) <<
5 | ;;
6 | ;; by Rockin'-B, www.rockin-b.de
7 |
8 | ;
9 | ; Copyright (c) 2003/2006 Thomas Fuchs / The Rockin'-B, www.rockin-b.de
10 | ;
11 | ; Permission is granted to anyone to use this software for any purpose
12 | ; and to redistribute it freely, subject to the following restrictions:
13 | ;
14 | ; 1. The origin of this software must not be misrepresented. You must not
15 | ; claim that you wrote the original software. If you use this software
16 | ; in a product, an acknowledgment in the product documentation would be
17 | ; appreciated but is not required.
18 | ;
19 | ; 2. ANY COMMERCIAL USE IS PROHIBITED. This includes that you must not use
20 | ; this software in the production of a commercial product. Only an explicit
21 | ; permission by the author can allow you to do that.
22 | ;
23 | ; 3. Any modification applied to the software must be marked as such clearly.
24 | ;
25 | ; 4. This license may not be removed or altered from any distribution.
26 | ;
27 | ;
28 | ; NO WARRANTY
29 | ;
30 | ; THERE IS NO WARRANTY FOR THE PROGRAM.
31 | ; THE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
32 | ; EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
33 | ; THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE.
34 | ; THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.
35 | ; SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
36 | ; SERVICING, REPAIR OR CORRECTION.
37 | ;
38 | ; IN NO EVENT WILL THE COPYRIGHT HOLDER BE LIABLE TO YOU FOR DAMAGES,
39 | ; INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
40 | ; OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
41 | ; TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
42 | ; YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
43 | ; PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
44 | ; POSSIBILITY OF SUCH DAMAGES.
45 | ;
46 |
47 |
48 | ;; polygon data format in flashrom:
49 | ;;
50 | ;; byte offset: comment:
51 | ;; 00 option header
52 | ;; : header format:
53 | ;; : value: comment:
54 | ;; : %0000000 points
55 | ;; : %0000001 polyline
56 | ;; : %0000010 lines
57 | ;; : %0000011 polylines
58 | ;; 01 number of points following
59 | ;; : number of points format:
60 | ;; : 1-32 maximum of points the workRAM can hold(projected, 2x8bits)
61 | ;; : 1-42 ensures that "number of lines" can be addressed
62 | ;; : using offset(1 byte) only
63 | ;; :
64 | ;; :
65 | ;; 1+6n x_high
66 | ;; 1+6n+1 x_low
67 | ;; 1+6n+2 y_high
68 | ;; 1+6n+3 y_low
69 | ;; 1+6n+4 z_high
70 | ;; 1+6n+5 z_low
71 | ;; :
72 | ;; :
73 | ;; m number of lines following
74 | ;; : number of lines format:
75 | ;; : 0-127 ensures that all lines can be addressed
76 | ;; : using offset(1 byte) only
77 | ;; :
78 | ;; :
79 | ;; m+2k first point(index) of k-th line
80 | ;; m+2k+1 second point(index) of k-th line
81 | ;; : and first point of k+1-th line
82 | ;; : second point of k+1-th line
83 | ;; : and first point of k+2-th line
84 | ;; :
85 | ;; :
86 | ;;
87 | ;;
88 | ;; workRAM usage for transformed and projected points
89 | ;; byte offset:
90 | ;; 192 point1_x
91 | ;; 193 point1_y
92 | ;; :
93 | ;; :
94 | ;; :
95 | ;; 254 point32_x
96 | ;; 255 point32_y
97 |
98 |
99 | ;; function: "put_polygon"
100 | ;; - draws the given polygon structure into framebuffer
101 | ;; -> performs coordinate transformation of all points using current matrix
102 | ;; -> performs perspective projection
103 | ;; -> draws points/polylines into framebuffer
104 | ;; INPUTS: - trh/trl, flashrom address of polygon data
105 | ;;
106 |
107 | put_polygon:
108 | push acc
109 | push count
110 | push c
111 | push 1
112 | push vsel
113 | push vrmad1
114 | push vrmad2
115 |
116 | ;; 1. transform all points of the object to screen coordinates
117 |
118 | ;; prepare to transform all points
119 |
120 | ;; init workRAM
121 |
122 | set1 vsel, ince ; we are using auto increment
123 | mov #192, vrmad1
124 | xor acc
125 | st vrmad2
126 |
127 | ;; extract header and number of points
128 | ldc
129 | st header
130 | mov #1, acc
131 | ldc
132 | st npoints
133 | st count
134 |
135 | ;; now start transforming all points
136 |
137 | mov #2, offset
138 |
139 | .next_point:
140 | ;; get one point
141 |
142 | mov #6, c
143 | mov #temp_vector, 1
144 |
145 | .next_byte:
146 | ld offset
147 | ldc
148 | st @R1
149 | inc offset
150 | inc 1
151 |
152 | dbnz c, .next_byte
153 |
154 | ;; transform that point to world coordinate system
155 |
156 | mov #temp_vector, 1
157 | ;; assume that R0 allready points to current matrix
158 | callf transform_point
159 |
160 | ;; now do the projection
161 |
162 | callf project_point
163 |
164 | dbnz count, .next_point
165 |
166 | ;; 2. Draw all visible things to the screen
167 |
168 | ;; prepare
169 |
170 | ;; reinit workRAM pointers
171 |
172 | mov #192, vrmad1
173 |
174 | ;; get number of points
175 |
176 | ld npoints
177 | st count
178 |
179 | ;; evaluate header to determine data type
180 |
181 | ld header
182 |
183 |
184 | bne #0, .polyline
185 |
186 | .point:
187 | ;; it's a collection of points
188 |
189 | ;; check if at least one point is there
190 |
191 | ld count
192 | bnz .next_point2
193 | brf .end
194 |
195 | ;; if so, display them all
196 |
197 | .next_point2:
198 | ld vtrbf
199 | st point1_x
200 | ld vtrbf
201 | st point1_y
202 |
203 | ;; check for visibility
204 | ;; bounds should be:
205 | ;; 0 <= point1_x <= 47
206 | ;; 0 <= point1_y <= 31
207 |
208 | ld point1_x
209 | sub #48
210 | bn psw, cy, .skip
211 |
212 | ld point1_y
213 | sub #32
214 | bn psw, cy, .skip
215 |
216 |
217 | callf draw_point
218 | mov #0, vrmad2 ; refresh for softvms
219 |
220 | .skip:
221 | dbnz count, .next_point2
222 |
223 | brf .end
224 |
225 | .polyline:
226 |
227 | bne #1, .lines
228 |
229 | ;; it's a polyline
230 |
231 | ;; check if at least 2 points are available
232 |
233 | ld count
234 | and #%11111110
235 | bnz .proceed
236 | brf .end
237 |
238 | .proceed:
239 |
240 | ;; draw a line(n-1) between all neighboring points(n)
241 |
242 | dec count
243 |
244 | ld vtrbf
245 | st point2_x
246 | ld vtrbf
247 | st point2_y
248 |
249 | clr1 control, fast_polyline
250 |
251 | .next_point3:
252 | ;; copy over old point
253 |
254 | ld point2_x
255 | st point1_x
256 | ld point2_y
257 | st point1_y
258 |
259 | ;; and add a new point
260 |
261 | ld vtrbf
262 | st point2_x
263 | ld vtrbf
264 | st point2_y
265 |
266 | callf clip_and_draw_lines
267 |
268 | ; callf draw_line
269 | mov #0, vrmad2 ; refresh for softvms
270 |
271 | ; set1 control, fast_polyline
272 |
273 | dbnz count, .next_point3
274 |
275 | clr1 control, fast_polyline
276 |
277 | brf .end
278 |
279 | .lines:
280 |
281 | bne #2, .polylines
282 |
283 | ;; it's a collection of lines
284 |
285 | ;; get number of lines
286 |
287 | ld offset
288 | ldc
289 | st nlines
290 |
291 | ;; start line drawing loop
292 | .nextline:
293 | ;; get first point
294 |
295 | inc offset
296 | ld offset
297 | ldc
298 | add acc ;; every point has 2 bytes
299 | add #192
300 | st vrmad1
301 | ld vtrbf
302 | st point1_x
303 | ld vtrbf
304 | st point1_y
305 |
306 | ;; get second point
307 |
308 | inc offset
309 | ld offset
310 | ldc
311 | add acc ;; every point has 2 bytes
312 | add #192
313 | st vrmad1
314 | ld vtrbf
315 | st point2_x
316 | ld vtrbf
317 | st point2_y
318 |
319 | callf clip_and_draw_lines
320 |
321 | ; callf draw_line
322 | mov #0, vrmad2 ; refresh for softvms
323 |
324 | dbnz nlines, .nextline
325 |
326 | brf .end
327 |
328 | .polylines:
329 |
330 | ;; it's a collection of polylines
331 |
332 | ;; get number of polylines
333 |
334 | ld offset
335 | ldc
336 | inc offset
337 | st npolylines
338 |
339 | .nextpolyline:
340 | ;; get number of line segments
341 |
342 | ld offset
343 | ldc
344 | inc offset
345 | st nlines
346 |
347 | ;; get first point
348 |
349 | ld offset
350 | ldc
351 | inc offset
352 | add acc ;; every point has 2 bytes
353 | add #192
354 | st vrmad1
355 | ld vtrbf
356 | st point2_x
357 | ld vtrbf
358 | st point2_y
359 |
360 | clr1 control, fast_polyline
361 |
362 | .nextlinesegment:
363 |
364 | ;; copy over old point
365 |
366 | ld point2_x
367 | st point1_x
368 | ld point2_y
369 | st point1_y
370 |
371 | ;; get second point
372 |
373 | ld offset
374 | ldc
375 | inc offset
376 | add acc ;; every point has 2 bytes
377 | add #192
378 | st vrmad1
379 | ld vtrbf
380 | st point2_x
381 | ld vtrbf
382 | st point2_y
383 |
384 | callf clip_and_draw_lines
385 |
386 | ; callf draw_line
387 | mov #0, vrmad2 ; refresh for softvms
388 |
389 | ; set1 control, fast_polyline
390 |
391 | dbnz nlines, .nextlinesegment
392 |
393 | dbnz npolylines, .nextpolyline
394 |
395 | clr1 control, fast_polyline
396 |
397 | .end:
398 | pop vrmad2
399 | pop vrmad1
400 | pop vsel
401 | pop 1
402 | pop c
403 | pop count
404 | pop acc
405 |
406 | ret
407 |
408 |
--------------------------------------------------------------------------------
/src/3d_rotate_x.i:
--------------------------------------------------------------------------------
1 |
2 | ;; Tiny 3d Engine for VMU
3 | ;;
4 | ;; >> War On Iraque Edition (06/01/08) <<
5 | ;;
6 | ;; by Rockin'-B, www.rockin-b.de
7 |
8 | ;
9 | ; Copyright (c) 2003/2006 Thomas Fuchs / The Rockin'-B, www.rockin-b.de
10 | ;
11 | ; Permission is granted to anyone to use this software for any purpose
12 | ; and to redistribute it freely, subject to the following restrictions:
13 | ;
14 | ; 1. The origin of this software must not be misrepresented. You must not
15 | ; claim that you wrote the original software. If you use this software
16 | ; in a product, an acknowledgment in the product documentation would be
17 | ; appreciated but is not required.
18 | ;
19 | ; 2. ANY COMMERCIAL USE IS PROHIBITED. This includes that you must not use
20 | ; this software in the production of a commercial product. Only an explicit
21 | ; permission by the author can allow you to do that.
22 | ;
23 | ; 3. Any modification applied to the software must be marked as such clearly.
24 | ;
25 | ; 4. This license may not be removed or altered from any distribution.
26 | ;
27 | ;
28 | ; NO WARRANTY
29 | ;
30 | ; THERE IS NO WARRANTY FOR THE PROGRAM.
31 | ; THE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
32 | ; EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
33 | ; THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE.
34 | ; THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.
35 | ; SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
36 | ; SERVICING, REPAIR OR CORRECTION.
37 | ;
38 | ; IN NO EVENT WILL THE COPYRIGHT HOLDER BE LIABLE TO YOU FOR DAMAGES,
39 | ; INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
40 | ; OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
41 | ; TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
42 | ; YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
43 | ; PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
44 | ; POSSIBILITY OF SUCH DAMAGES.
45 | ;
46 |
47 |
48 | ;; function "rotate_x"
49 | ;; - multiplies the current matrix with the following matrix:
50 | ;;
51 | ;; / 1 0 0 0 \
52 | ;; | 0 cos(angle) -sin(angle) 0 |
53 | ;; | 0 sin(angle) cos(angle) 0 |
54 | ;; \ 0 0 0 1 /
55 | ;;
56 | ;; INPUTS: - ax_high, ax_low: angle, 2's complement degree amount
57 | ;; - R0 points to current matrix
58 | ;; OUTPUTS: - current matrix(indirect)
59 |
60 | rotate_x:
61 | push acc
62 | push 1
63 |
64 | ;; first get sine and cosine values
65 |
66 | mov #ax_high, 1
67 | callf sincos
68 |
69 | ;; and insert the values into the rotation matrix
70 |
71 | ld cos_high
72 | st rx_c1_high
73 | st rx_c2_high
74 | ld cos_low
75 | st rx_c1_low
76 | st rx_c2_low
77 | ld sin_high
78 | st rx_s_high
79 | ld sin_low
80 | st rx_s_low
81 |
82 | ;; compute 2's complement!!!
83 |
84 | mov #sin_low, 1
85 | callf twos_complement_16bit
86 |
87 | ld sin_high
88 | st rx_ns_high
89 | ld sin_low
90 | st rx_ns_low
91 |
92 | ;; second multiply the x-axis rotation matrix to the current matrix
93 |
94 | mov #rx_start, 1
95 |
96 | bn control, first_mm, .multiply
97 |
98 | .copy:
99 | callf copy_matrix
100 | bpc control, first_mm, .end ;; is faster than clr1 plus branch
101 |
102 | .multiply:
103 | callf multiply_matrix
104 |
105 | .end:
106 | pop 1
107 | pop acc
108 |
109 | ret
110 |
111 |
112 | ;; FAST TRANSFORM: only computes the changing elements of current matrix
113 | ;; -> no need to perform whole matrix multiplication!
114 | ;; - inlined add_16bit/sub_16bit
115 | ;;
116 | ;; PERFORMS:
117 | ;; / c11 c12 c13 c12 \
118 | ;; | c*c21-s*c31 c*c22-s*c32 c*c23-s*c33 c*c24-s*c34 |
119 | ;; \ c*c31+s*c21 c*c32+s*c22 c*c33+s*c23 c*c34+s*c24 /
120 |
121 | rotate_x_fast:
122 | push acc
123 | push 1
124 | push count
125 | push b
126 |
127 | ;; first: get sine and cosine values
128 |
129 | mov #ax_high, 1
130 | callf sincos
131 |
132 | ;; second: compute the products
133 |
134 | ;; let R1 point to 2nd row of current matrix
135 |
136 | ld 0
137 | add #8
138 | st 1
139 |
140 | ;; let R4 point to cosine products
141 | ;; and R5 point to sine products
142 |
143 | mov #temp_storage, acc
144 | st 4
145 | add #16
146 | st 5
147 |
148 | mov #8, count
149 |
150 | .next_element1:
151 | ;; load matrix element
152 |
153 | ld @R1
154 | st B_high
155 | inc 1
156 | ld @R1
157 | st B_low
158 | inc 1
159 |
160 | set1 psw, irbk0
161 |
162 | ;; perform cosine product
163 |
164 | ld cos_high
165 | st C_high
166 | ld cos_low
167 | st C_low
168 |
169 | callf mul_16bit
170 |
171 | ld C_high
172 | st @R0
173 | inc 4
174 | ld C_low
175 | st @R0
176 | inc 4
177 |
178 | ;; perform sine product
179 |
180 | ld sin_high
181 | st C_high
182 | ld sin_low
183 | st C_low
184 |
185 | callf mul_16bit
186 |
187 | ld C_high
188 | st @R1
189 | inc 5
190 | ld C_low
191 | st @R1
192 | inc 5
193 |
194 | clr1 psw, irbk0
195 |
196 | dbnz count, .next_element1
197 |
198 |
199 | ;; third: perform adds and subs and insert the data into the current matrix
200 |
201 | ;; 3rd row right to left:
202 |
203 | ;; let R1 point to last elements low 8 bit of 3rd row of current matrix
204 |
205 | ld 0
206 | add #23
207 | st 1
208 |
209 | ;; let R4 point to cosine products c*c34....c*c31
210 | ;; and R5 point to sine products s*c24....s*c21
211 |
212 | mov #temp_storage, acc
213 | add #15
214 | st 4
215 | add #8
216 | st 5
217 |
218 | mov #4, count
219 |
220 | .next_element2:
221 | ;; load operands add and store
222 |
223 | set1 psw, irbk0
224 |
225 | clr1 psw, cy
226 |
227 | ld @R0
228 | add @R1
229 | st b
230 | dec 4
231 | dec 5
232 | ld @R0
233 | addc @R1
234 | dec 4
235 | dec 5
236 |
237 | clr1 psw, irbk0
238 |
239 | dec 1
240 | st @R1
241 | inc 1
242 | ld b
243 | st @R1
244 | dec 1
245 | dec 1
246 |
247 | dbnz count, .next_element2
248 |
249 | ;; 2nd row:
250 |
251 | ;; let R5 point to sine products s*c34....s*c31
252 |
253 | mov #temp_storage, acc
254 | add #31
255 | st 5
256 |
257 |
258 | mov #4, count
259 |
260 | .next_element3:
261 | ;; load operands, sub and store
262 |
263 | set1 psw, irbk0
264 |
265 | clr1 psw, cy
266 |
267 | ld @R0
268 | sub @R1
269 | st b
270 | dec 4
271 | dec 5
272 | ld @R0
273 | subc @R1
274 | dec 4
275 | dec 5
276 |
277 | clr1 psw, irbk0
278 |
279 | dec 1
280 | st @R1
281 | inc 1
282 | ld b
283 | st @R1
284 | dec 1
285 | dec 1
286 |
287 | dbnz count, .next_element3
288 |
289 | ;; otherwise these transforms would be simply overwritten
290 | ;; by first multiplied matrix
291 |
292 | clr1 control, first_mm
293 |
294 | pop b
295 | pop count
296 | pop 1
297 | pop acc
298 |
299 | ret
300 |
301 |
--------------------------------------------------------------------------------
/src/3d_rotate_y.i:
--------------------------------------------------------------------------------
1 |
2 | ;; Tiny 3d Engine for VMU
3 | ;;
4 | ;; >> War On Iraque Edition (06/01/08) <<
5 | ;;
6 | ;; by Rockin'-B, www.rockin-b.de
7 |
8 | ;
9 | ; Copyright (c) 2003/2006 Thomas Fuchs / The Rockin'-B, www.rockin-b.de
10 | ;
11 | ; Permission is granted to anyone to use this software for any purpose
12 | ; and to redistribute it freely, subject to the following restrictions:
13 | ;
14 | ; 1. The origin of this software must not be misrepresented. You must not
15 | ; claim that you wrote the original software. If you use this software
16 | ; in a product, an acknowledgment in the product documentation would be
17 | ; appreciated but is not required.
18 | ;
19 | ; 2. ANY COMMERCIAL USE IS PROHIBITED. This includes that you must not use
20 | ; this software in the production of a commercial product. Only an explicit
21 | ; permission by the author can allow you to do that.
22 | ;
23 | ; 3. Any modification applied to the software must be marked as such clearly.
24 | ;
25 | ; 4. This license may not be removed or altered from any distribution.
26 | ;
27 | ;
28 | ; NO WARRANTY
29 | ;
30 | ; THERE IS NO WARRANTY FOR THE PROGRAM.
31 | ; THE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
32 | ; EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
33 | ; THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE.
34 | ; THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.
35 | ; SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
36 | ; SERVICING, REPAIR OR CORRECTION.
37 | ;
38 | ; IN NO EVENT WILL THE COPYRIGHT HOLDER BE LIABLE TO YOU FOR DAMAGES,
39 | ; INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
40 | ; OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
41 | ; TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
42 | ; YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
43 | ; PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
44 | ; POSSIBILITY OF SUCH DAMAGES.
45 | ;
46 |
47 |
48 | ;; function "rotate_y"
49 | ;; - multiplies the current matrix with the following matrix:
50 | ;;
51 | ;; / cos(angle) 0 sin(angle) 0 \
52 | ;; | 0 1 0 0 |
53 | ;; | -sin(angle) 0 cos(angle) 0 |
54 | ;; \ 0 0 0 1 /
55 | ;;
56 | ;; INPUTS: - ay_high, ay_low: angle, 2's complement degree amount
57 | ;; - R0 points to current matrix
58 | ;; OUTPUTS: - current matrix(indirect)
59 |
60 | rotate_y_mm:
61 | push acc
62 | push 1
63 |
64 | ;; first get sine and cosine values
65 |
66 | mov #ay_high, 1
67 | callf sincos
68 |
69 | ;; and insert the values into the rotation matrix
70 |
71 | ld cos_high
72 | st ry_c1_high
73 | st ry_c2_high
74 | ld cos_low
75 | st ry_c1_low
76 | st ry_c2_low
77 | ld sin_high
78 | st ry_s_high
79 | ld sin_low
80 | st ry_s_low
81 |
82 | ;; compute 2's complement!!!
83 |
84 | mov #sin_low, 1
85 | callf twos_complement_16bit
86 |
87 | ld sin_high
88 | st ry_ns_high
89 | ld sin_low
90 | st ry_ns_low
91 |
92 | ;; second multiply the y-axis rotation matrix to the current matrix
93 |
94 | mov #ry_start, 1
95 |
96 | bn control, first_mm, .multiply
97 |
98 | .copy:
99 | callf copy_matrix
100 | bpc control, first_mm, .end ;; is faster than clr1 plus branch
101 |
102 | .multiply:
103 | callf multiply_matrix
104 |
105 | .end:
106 | pop 1
107 | pop acc
108 |
109 | ret
110 |
111 |
112 |
113 |
114 | ;; FAST TRANSFORM: only computes the changing elements of current matrix
115 | ;; -> no need to perform whole matrix multiplication!
116 | ;; - inlined add_16bit/sub_16bit
117 | ;;
118 | ;; PERFORMS:
119 | ;; / c*c11+s*c31 c*c12+s*c32 c*c13+s*c33 c*c14+s*c34 \
120 | ;; | c21 c22 c23 c24 |
121 | ;; \ c*c31-s*c11 c*c32-s*c12 c*c33-s*c13 c*c34-s*c14 /
122 |
123 | rotate_y:
124 | push acc
125 | push 1
126 | push count
127 | push b
128 | push c
129 |
130 | ;; first: get sine and cosine values
131 |
132 | mov #ay_high, 1
133 | callf sincos
134 |
135 | ;; second: compute the products
136 |
137 | ;; let R1 point to 1st row of current matrix
138 |
139 | ld 0
140 | st 1
141 |
142 | ;; let R4 point to cosine products
143 | ;; and R5 point to sine products
144 |
145 | mov #temp_storage, acc
146 | st 4
147 | add #16
148 | st 5
149 |
150 | mov #2, c
151 |
152 | .next_row:
153 | ; push c
154 |
155 | mov #4, count
156 |
157 | .next_element1:
158 | ;; load matrix element
159 |
160 | ld @R1
161 | st B_high
162 | inc 1
163 | ld @R1
164 | st B_low
165 | inc 1
166 |
167 | set1 psw, irbk0
168 |
169 | ;; perform cosine product
170 |
171 | ld cos_high
172 | st C_high
173 | ld cos_low
174 | st C_low
175 |
176 | callf mul_16bit
177 |
178 | ld C_high
179 | st @R0
180 | inc 4
181 | ld C_low
182 | st @R0
183 | inc 4
184 |
185 | ;; perform sine product
186 |
187 | ld sin_high
188 | st C_high
189 | ld sin_low
190 | st C_low
191 |
192 | callf mul_16bit
193 |
194 | ld C_high
195 | st @R1
196 | inc 5
197 | ld C_low
198 | st @R1
199 | inc 5
200 |
201 | clr1 psw, irbk0
202 |
203 | dbnz count, .next_element1
204 |
205 | ;; skip 2nd line
206 |
207 | ld 1
208 | add #8
209 | st 1
210 |
211 | ; pop c
212 |
213 | dbnz c, .next_row
214 |
215 | ;; third: perform adds and subs and insert the data into the current matrix
216 |
217 | ;; 3rd row right to left:
218 |
219 | ;; let R1 point to last elements low 8 bit of 3rd row of current matrix
220 |
221 | ld 0
222 | add #23
223 | st 1
224 |
225 | ;; let R4 point to cosine products c*c34....c*c31
226 | ;; and R5 point to sine products s*c14....s*c11
227 |
228 | mov #temp_storage, acc
229 | add #15
230 | st 4
231 | add #8
232 | st 5
233 |
234 | mov #4, count
235 |
236 | .next_element2:
237 | ;; load operands sub and store
238 |
239 | set1 psw, irbk0
240 |
241 | clr1 psw, cy
242 |
243 | ld @R0
244 | sub @R1
245 | st b
246 | dec 4
247 | dec 5
248 | ld @R0
249 | subc @R1
250 | dec 4
251 | dec 5
252 |
253 | clr1 psw, irbk0
254 |
255 | dec 1
256 | st @R1
257 | inc 1
258 | ld b
259 | st @R1
260 | dec 1
261 | dec 1
262 |
263 | dbnz count, .next_element2
264 |
265 | ;; 1st row:
266 |
267 | ;; let R1 point to last elements low 8 bit of 1st row of current matrix
268 |
269 | ld 0
270 | add #7
271 | st 1
272 |
273 | ;; let R5 point to sine products s*c34....s*c31
274 |
275 | mov #temp_storage, acc
276 | add #31
277 | st 5
278 |
279 |
280 | mov #4, count
281 |
282 | .next_element3:
283 | ;; load operands, adds and store
284 |
285 | set1 psw, irbk0
286 |
287 | clr1 psw, cy
288 |
289 | ld @R0
290 | add @R1
291 | st b
292 | dec 4
293 | dec 5
294 | ld @R0
295 | addc @R1
296 | dec 4
297 | dec 5
298 |
299 | clr1 psw, irbk0
300 |
301 | dec 1
302 | st @R1
303 | inc 1
304 | ld b
305 | st @R1
306 | dec 1
307 | dec 1
308 |
309 | dbnz count, .next_element3
310 |
311 | ;; otherwise these transforms would be simply overwritten
312 | ;; by first multiplied matrix
313 |
314 | clr1 control, first_mm
315 |
316 | pop c
317 | pop b
318 | pop count
319 | pop 1
320 | pop acc
321 |
322 | ret
323 |
324 |
--------------------------------------------------------------------------------
/src/3d_rotate_z.i:
--------------------------------------------------------------------------------
1 |
2 | ;; Tiny 3d Engine for VMU
3 | ;;
4 | ;; >> War On Iraque Edition (06/01/08) <<
5 | ;;
6 | ;; by Rockin'-B, www.rockin-b.de
7 |
8 | ;
9 | ; Copyright (c) 2003/2006 Thomas Fuchs / The Rockin'-B, www.rockin-b.de
10 | ;
11 | ; Permission is granted to anyone to use this software for any purpose
12 | ; and to redistribute it freely, subject to the following restrictions:
13 | ;
14 | ; 1. The origin of this software must not be misrepresented. You must not
15 | ; claim that you wrote the original software. If you use this software
16 | ; in a product, an acknowledgment in the product documentation would be
17 | ; appreciated but is not required.
18 | ;
19 | ; 2. ANY COMMERCIAL USE IS PROHIBITED. This includes that you must not use
20 | ; this software in the production of a commercial product. Only an explicit
21 | ; permission by the author can allow you to do that.
22 | ;
23 | ; 3. Any modification applied to the software must be marked as such clearly.
24 | ;
25 | ; 4. This license may not be removed or altered from any distribution.
26 | ;
27 | ;
28 | ; NO WARRANTY
29 | ;
30 | ; THERE IS NO WARRANTY FOR THE PROGRAM.
31 | ; THE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
32 | ; EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
33 | ; THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE.
34 | ; THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.
35 | ; SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
36 | ; SERVICING, REPAIR OR CORRECTION.
37 | ;
38 | ; IN NO EVENT WILL THE COPYRIGHT HOLDER BE LIABLE TO YOU FOR DAMAGES,
39 | ; INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
40 | ; OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
41 | ; TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
42 | ; YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
43 | ; PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
44 | ; POSSIBILITY OF SUCH DAMAGES.
45 | ;
46 |
47 |
48 | ;; function "rotate_z"
49 | ;; - multiplies the current matrix with the following matrix:
50 | ;;
51 | ;; / cos(angle) -sin(angle) 0 0 \
52 | ;; | sin(angle) cos(angle) 0 0 |
53 | ;; | 0 0 1 0 |
54 | ;; \ 0 0 0 1 /
55 | ;;
56 | ;; INPUTS: - ax_high, ax_low: angle, 2's complement degree amount
57 | ;; - R0 points to current matrix
58 | ;; OUTPUTS: - current matrix(indirect)
59 |
60 | rotate_z_mm:
61 | push acc
62 | push 1
63 |
64 | ;; first get sine and cosine values
65 |
66 | mov #az_high, 1
67 | callf sincos
68 |
69 | ;; and insert the values into the rotation matrix
70 |
71 | ld cos_high
72 | st rz_c1_high
73 | st rz_c2_high
74 | ld cos_low
75 | st rz_c1_low
76 | st rz_c2_low
77 | ld sin_high
78 | st rz_s_high
79 | ld sin_low
80 | st rz_s_low
81 |
82 | ;; compute 2's complement!!!
83 |
84 | mov #sin_low, 1
85 | callf twos_complement_16bit
86 |
87 | ld sin_high
88 | st rz_ns_high
89 | ld sin_low
90 | st rz_ns_low
91 |
92 | ;; second multiply the z-axis rotation matrix to the current matrix
93 |
94 | mov #rz_start, 1
95 |
96 | bn control, first_mm, .multiply
97 |
98 | .copy:
99 | callf copy_matrix
100 | bpc control, first_mm, .end ;; is faster than clr1 plus branch
101 |
102 | .multiply:
103 | callf multiply_matrix
104 |
105 | .end:
106 | pop 1
107 | pop acc
108 |
109 | ret
110 |
111 |
112 | ;; FAST TRANSFORM: only computes the changing elements of current matrix
113 | ;; -> no need to perform whole matrix multiplication!
114 | ;; - inlined add_16bit/sub_16bit
115 | ;;
116 | ;; PERFORMS:
117 | ;; / c*c11-s*c21 c*c12-s*c22 c*c13-s*c23 c*c14-s*c24 \
118 | ;; | c*c21+s*c11 c*c22+s*c12 c*c23+s*c13 c*c24+s*c14 |
119 | ;; \ c31 c32 c33 c34 /
120 |
121 | rotate_z:
122 | push acc
123 | push 1
124 | push count
125 | push b
126 |
127 | ;; first: get sine and cosine values
128 |
129 | mov #az_high, 1
130 | callf sincos
131 |
132 | ;; second: compute the products
133 |
134 | ;; let R1 point to first elements high 8 bits of first row
135 |
136 | ld 0
137 | st 1
138 |
139 | ;; let R4 point to cosine products
140 | ;; and R5 point to sine products
141 |
142 | mov #temp_storage, acc
143 | st 4
144 | add #16
145 | st 5
146 |
147 | mov #8, count
148 |
149 | .next_element1:
150 | ;; load matrix element
151 |
152 | ld @R1
153 | st B_high
154 | inc 1
155 | ld @R1
156 | st B_low
157 | inc 1
158 |
159 | ; ld B_high
160 | ; st c
161 | ; ld B_low
162 | ; st b
163 | ;
164 | ;.test:
165 | ; br .test
166 |
167 | set1 psw, irbk0
168 |
169 | ;; perform cosine product
170 |
171 | ld cos_high
172 | st C_high
173 | ld cos_low
174 | st C_low
175 |
176 | callf mul_16bit
177 |
178 | ld C_high
179 | st @R0
180 | inc 4
181 | ld C_low
182 | st @R0
183 | inc 4
184 |
185 | ;; perform sine product
186 |
187 | ld sin_high
188 | st C_high
189 | ld sin_low
190 | st C_low
191 |
192 | callf mul_16bit
193 |
194 | ld C_high
195 | st @R1
196 | inc 5
197 | ld C_low
198 | st @R1
199 | inc 5
200 |
201 | clr1 psw, irbk0
202 |
203 | dbnz count, .next_element1
204 |
205 |
206 | ;; third: perform adds and subs and insert the data into the current matrix
207 |
208 | ;; 2nd row right to left:
209 |
210 | ;; let R1 point to last elements low 8 bit of 2nd row of current matrix
211 |
212 | ld 0
213 | add #15
214 | st 1
215 |
216 | ;; let R4 point to cosine products c*c24....c*c21
217 | ;; and R5 point to sine products s*c14....s*c11
218 |
219 | mov #temp_storage, acc
220 | add #15
221 | st 4
222 | add #8
223 | st 5
224 |
225 | mov #4, count
226 |
227 | .next_element2:
228 | ;; load operands add and store
229 |
230 | set1 psw, irbk0
231 |
232 | clr1 psw, cy
233 |
234 | ld @R0
235 | add @R1
236 | st b
237 | dec 4
238 | dec 5
239 | ld @R0
240 | addc @R1
241 | dec 4
242 | dec 5
243 |
244 | clr1 psw, irbk0
245 |
246 | dec 1
247 | st @R1
248 | inc 1
249 | ld b
250 | st @R1
251 | dec 1
252 | dec 1
253 |
254 | dbnz count, .next_element2
255 |
256 | ;; 1st row:
257 |
258 | ;; let R5 point to sine products s*c24....s*c21
259 |
260 | mov #temp_storage, acc
261 | add #31
262 | st 5
263 |
264 |
265 | mov #4, count
266 |
267 | .next_element3:
268 | ;; load operands, sub and store
269 |
270 | set1 psw, irbk0
271 |
272 | clr1 psw, cy
273 |
274 | ld @R0
275 | sub @R1
276 | st b
277 | dec 4
278 | dec 5
279 | ld @R0
280 | subc @R1
281 | dec 4
282 | dec 5
283 |
284 | clr1 psw, irbk0
285 |
286 | dec 1
287 | st @R1
288 | inc 1
289 | ld b
290 | st @R1
291 | dec 1
292 | dec 1
293 |
294 | dbnz count, .next_element3
295 |
296 | ;; otherwise these transforms would be simply overwritten
297 | ;; by first multiplied matrix
298 |
299 | clr1 control, first_mm
300 |
301 | pop b
302 | pop count
303 | pop 1
304 | pop acc
305 |
306 | ret
307 |
308 |
--------------------------------------------------------------------------------
/src/3d_scale.i:
--------------------------------------------------------------------------------
1 |
2 | ;; Tiny 3d Engine for VMU
3 | ;;
4 | ;; >> War On Iraque Edition (06/01/08) <<
5 | ;;
6 | ;; by Rockin'-B, www.rockin-b.de
7 |
8 | ;
9 | ; Copyright (c) 2003/2006 Thomas Fuchs / The Rockin'-B, www.rockin-b.de
10 | ;
11 | ; Permission is granted to anyone to use this software for any purpose
12 | ; and to redistribute it freely, subject to the following restrictions:
13 | ;
14 | ; 1. The origin of this software must not be misrepresented. You must not
15 | ; claim that you wrote the original software. If you use this software
16 | ; in a product, an acknowledgment in the product documentation would be
17 | ; appreciated but is not required.
18 | ;
19 | ; 2. ANY COMMERCIAL USE IS PROHIBITED. This includes that you must not use
20 | ; this software in the production of a commercial product. Only an explicit
21 | ; permission by the author can allow you to do that.
22 | ;
23 | ; 3. Any modification applied to the software must be marked as such clearly.
24 | ;
25 | ; 4. This license may not be removed or altered from any distribution.
26 | ;
27 | ;
28 | ; NO WARRANTY
29 | ;
30 | ; THERE IS NO WARRANTY FOR THE PROGRAM.
31 | ; THE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
32 | ; EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
33 | ; THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE.
34 | ; THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.
35 | ; SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
36 | ; SERVICING, REPAIR OR CORRECTION.
37 | ;
38 | ; IN NO EVENT WILL THE COPYRIGHT HOLDER BE LIABLE TO YOU FOR DAMAGES,
39 | ; INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
40 | ; OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
41 | ; TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
42 | ; YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
43 | ; PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
44 | ; POSSIBILITY OF SUCH DAMAGES.
45 | ;
46 |
47 |
48 | ;; function "scale"
49 | ;; - multiplies the current matrix with the following matrix:
50 | ;;
51 | ;; / sx 0 0 0 \
52 | ;; | 0 sy 0 0 |
53 | ;; | 0 0 sz 0 |
54 | ;; \ 0 0 0 1 /
55 | ;;
56 | ;; INPUTS: - sx_high
57 | ;; - sx_low
58 | ;; - sy_high
59 | ;; - sy_low
60 | ;; - sz_high
61 | ;; - sz_low
62 | ;; - R0 points to current matrix
63 | ;; OUTPUTS: - current matrix(indirect)
64 |
65 | scale_mm:
66 | push 1
67 |
68 | ;; multiply the scale matrix to the current matrix
69 |
70 | mov #s_start, 1
71 |
72 | bn control, first_mm, .multiply
73 |
74 | .copy:
75 | callf copy_matrix
76 | bpc control, first_mm, .end ;; is faster than clr1 plus branch
77 |
78 | .multiply:
79 | callf multiply_matrix
80 |
81 | .end:
82 | pop 1
83 |
84 | ret
85 |
86 |
87 | ;; FAST TRANSFORM: only computes the changing elements of current matrix
88 | ;; -> no need to perform whole matrix multiplication!
89 | ;;
90 | ;; PERFORMS:
91 | ;; / c11 c12 c13 c12 \
92 | ;; (sx,sy,sz)*| c21 c22 c23 c24 |
93 | ;; \ c31 c32 c33 c34 /
94 |
95 | scale:
96 | push acc
97 | push 1
98 | push count
99 |
100 | ;; multiplies each of the 3 lines with a scale factor
101 |
102 | ld 0
103 | st 1
104 |
105 | ;; perform x-axis scaling
106 |
107 | ;; load scale factor
108 |
109 | ld sx_high
110 | st B_high
111 | ld sx_low
112 | st B_low
113 |
114 | mov #4, count
115 |
116 | .multiply_sx:
117 |
118 | ;; load multiplicand
119 |
120 | ld @R1
121 | st C_high
122 | inc 1
123 | ld @R1
124 | st C_low
125 |
126 | callf mul_16bit
127 |
128 | ;; store result
129 |
130 | ld C_low
131 | st @R1
132 | dec 1
133 | ld C_high
134 | st @R1
135 | inc 1
136 | inc 1
137 |
138 | dbnz count, .multiply_sx
139 |
140 |
141 | ;; perform y-axis scaling
142 |
143 | ;; load scale factor
144 |
145 | ld sy_high
146 | st B_high
147 | ld sy_low
148 | st B_low
149 |
150 | mov #4, count
151 |
152 | .multiply_sy:
153 |
154 | ;; load multiplicand
155 |
156 | ld @R1
157 | st C_high
158 | inc 1
159 | ld @R1
160 | st C_low
161 |
162 | callf mul_16bit
163 |
164 | ;; store result
165 |
166 | ld C_low
167 | st @R1
168 | dec 1
169 | ld C_high
170 | st @R1
171 | inc 1
172 | inc 1
173 |
174 | dbnz count, .multiply_sy
175 |
176 |
177 | ;; perform z-axis scaling
178 |
179 | ;; load scale factor
180 |
181 | ld sz_high
182 | st B_high
183 | ld sz_low
184 | st B_low
185 |
186 | mov #4, count
187 |
188 | .multiply_sz:
189 |
190 | ;; load multiplicand
191 |
192 | ld @R1
193 | st C_high
194 | inc 1
195 | ld @R1
196 | st C_low
197 |
198 | callf mul_16bit
199 |
200 | ;; store result
201 |
202 | ld C_low
203 | st @R1
204 | dec 1
205 | ld C_high
206 | st @R1
207 | inc 1
208 | inc 1
209 |
210 | dbnz count, .multiply_sz
211 |
212 | ;; otherwise these transforms would be simply overwritten
213 | ;; by first multiplied matrix
214 |
215 | clr1 control, first_mm
216 |
217 | pop count
218 | pop 1
219 | pop acc
220 |
221 | ret
222 |
223 |
--------------------------------------------------------------------------------
/src/3d_sincos.i:
--------------------------------------------------------------------------------
1 |
2 | ;; Tiny 3d Engine for VMU
3 | ;;
4 | ;; >> War On Iraque Edition (06/01/08) <<
5 | ;;
6 | ;; by Rockin'-B, www.rockin-b.de
7 |
8 | ;
9 | ; Copyright (c) 2003/2006 Thomas Fuchs / The Rockin'-B, www.rockin-b.de
10 | ;
11 | ; Permission is granted to anyone to use this software for any purpose
12 | ; and to redistribute it freely, subject to the following restrictions:
13 | ;
14 | ; 1. The origin of this software must not be misrepresented. You must not
15 | ; claim that you wrote the original software. If you use this software
16 | ; in a product, an acknowledgment in the product documentation would be
17 | ; appreciated but is not required.
18 | ;
19 | ; 2. ANY COMMERCIAL USE IS PROHIBITED. This includes that you must not use
20 | ; this software in the production of a commercial product. Only an explicit
21 | ; permission by the author can allow you to do that.
22 | ;
23 | ; 3. Any modification applied to the software must be marked as such clearly.
24 | ;
25 | ; 4. This license may not be removed or altered from any distribution.
26 | ;
27 | ;
28 | ; NO WARRANTY
29 | ;
30 | ; THERE IS NO WARRANTY FOR THE PROGRAM.
31 | ; THE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
32 | ; EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
33 | ; THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE.
34 | ; THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.
35 | ; SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
36 | ; SERVICING, REPAIR OR CORRECTION.
37 | ;
38 | ; IN NO EVENT WILL THE COPYRIGHT HOLDER BE LIABLE TO YOU FOR DAMAGES,
39 | ; INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
40 | ; OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
41 | ; TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
42 | ; YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
43 | ; PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
44 | ; POSSIBILITY OF SUCH DAMAGES.
45 | ;
46 |
47 |
48 | ;; trigonometric functions
49 |
50 | ;; function: "sincos"
51 | ;; - computes sine and cosine values using the sinetable
52 | ;; - accepts 2's complement 16 bit angles
53 | ;; INPUTS: - R1: points to high byte of 2's complement angle
54 | ;; OUTPUTS: - sin_high
55 | ;; - sin_low
56 | ;; MODIFIES: - bit sign of control
57 |
58 | sincos:
59 | push offset
60 | push trl
61 | push trh
62 | ld @R1
63 | push acc
64 | inc 1
65 | ld @R1
66 | push acc
67 | dec 1
68 | push 1
69 |
70 | ;; both sine and cosine are fetched from the same table
71 |
72 | mov #sinetable, trh
74 |
75 | ;; first take sine into account, later extract cosine from resulting angle
76 |
77 | ;; examine the angle and transform to 0 - 90 degrees range
78 |
79 | ;; sign first
80 |
81 | clr1 control, sign_sin ; remember the sign of the angle for later
82 | ld @R1
83 | bn acc, 7, .positive1
84 | set1 control, sign_sin
85 | ;clr1 acc, 7
86 | inc 1
87 | callf twos_complement_16bit
88 |
89 | .positive1:
90 |
91 | ;; transform to 0 - 360 degrees range
92 |
93 | ;; perform angle - 360 as long as this is a positive value
94 |
95 | ld @R1
96 | st A_high
97 | inc 1
98 | ld @R1
99 | st A_low
100 | mov #$01, B_high
101 | mov #$68, B_low
102 |
103 | .proceed:
104 | callf sub_16bit
105 |
106 | bp A_high, 7, .leave
107 |
108 | ;; save the last positive value
109 |
110 | ld A_low
111 | st @R1
112 | dec 1
113 | ld A_high
114 | st @R1
115 | inc 1
116 |
117 | br .proceed
118 |
119 | .leave:
120 | dec 1
121 |
122 |
123 | ;; transform to 0 - 180 degrees range
124 |
125 | ;; if |angle| > 180 degrees, sub 180
126 |
127 |
128 | ld @R1
129 | st A_high
130 | inc 1
131 | ld @R1
132 | st A_low
133 | mov #$00, B_high
134 | mov #$B4, B_low
135 |
136 | callf sub_16bit
137 |
138 | clr1 control, sign_cos
139 | bp A_high, 7, .negative1
140 | mov #A_low, 1
141 | not1 control, sign_sin
142 | not1 control, sign_cos
143 |
144 | .negative1:
145 | ;; R1 now points to low 8 bits of angle
146 |
147 | ;; transform to 0 - 90 degrees range
148 |
149 | ;; mirror at 90 degrees
150 | ;; perform 180 - angle if it's over 90 degrees
151 |
152 | ld @R1
153 | sub #90
154 | bp acc, 7, .negative2
155 | mov #180, acc
156 | sub @R1
157 | st @R1
158 | not1 control, sign_cos
159 |
160 | .negative2:
161 |
162 | ;; compute address in sinetable
163 |
164 | ld @R1
165 | add acc
166 | st offset ; flashrom address offset:
167 | ; every entry in sinetable got 2 bytes
168 |
169 | ;; get the data from the sinetable
170 |
171 | ldc
172 | st sin_high
173 | inc offset
174 | ld offset
175 | ldc
176 | st sin_low
177 |
178 | ;; handle sign of the angle
179 |
180 | bn control, sign_sin, .positive2
181 | ; sin(-angle) = -sin(angle)
182 | ;; compute 2's complement
183 | push 1
184 |
185 | mov #sin_low, 1
186 | callf twos_complement_16bit
187 |
188 | pop 1
189 |
190 | .positive2:
191 |
192 | ;; now cosine:
193 |
194 | mov #90, acc
195 | sub @R1
196 |
197 | add acc
198 | st offset ; flashrom address offset:
199 | ; every entry in sinetable got 2 bytes
200 |
201 | ;; get the data from the sinetable
202 |
203 | ldc
204 | st cos_high
205 | inc offset
206 | ld offset
207 | ldc
208 | st cos_low
209 |
210 | ;; handle sign of the angle
211 |
212 | bn control, sign_cos, .positive3
213 | ; sin(-angle) = -sin(angle)
214 | ;; compute 2's complement
215 | mov #cos_low, 1
216 | callf twos_complement_16bit
217 |
218 | .positive3:
219 | pop 1
220 | inc 1
221 | pop acc
222 | st @R1
223 | dec 1
224 | pop acc
225 | st @R1
226 | pop trh
227 | pop trl
228 | pop offset
229 |
230 | ret
231 |
232 |
233 | ;; the sinetable to provide values for rotation matrix creation
234 | sinetable:
235 | .include"sinetable.i"
236 |
237 |
--------------------------------------------------------------------------------
/src/3d_stack.i:
--------------------------------------------------------------------------------
1 |
2 | ;; Tiny 3d Engine for VMU
3 | ;;
4 | ;; >> War On Iraque Edition (06/01/08) <<
5 | ;;
6 | ;; by Rockin'-B, www.rockin-b.de
7 |
8 | ;
9 | ; Copyright (c) 2003/2006 Thomas Fuchs / The Rockin'-B, www.rockin-b.de
10 | ;
11 | ; Permission is granted to anyone to use this software for any purpose
12 | ; and to redistribute it freely, subject to the following restrictions:
13 | ;
14 | ; 1. The origin of this software must not be misrepresented. You must not
15 | ; claim that you wrote the original software. If you use this software
16 | ; in a product, an acknowledgment in the product documentation would be
17 | ; appreciated but is not required.
18 | ;
19 | ; 2. ANY COMMERCIAL USE IS PROHIBITED. This includes that you must not use
20 | ; this software in the production of a commercial product. Only an explicit
21 | ; permission by the author can allow you to do that.
22 | ;
23 | ; 3. Any modification applied to the software must be marked as such clearly.
24 | ;
25 | ; 4. This license may not be removed or altered from any distribution.
26 | ;
27 | ;
28 | ; NO WARRANTY
29 | ;
30 | ; THERE IS NO WARRANTY FOR THE PROGRAM.
31 | ; THE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
32 | ; EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
33 | ; THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE.
34 | ; THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.
35 | ; SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
36 | ; SERVICING, REPAIR OR CORRECTION.
37 | ;
38 | ; IN NO EVENT WILL THE COPYRIGHT HOLDER BE LIABLE TO YOU FOR DAMAGES,
39 | ; INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
40 | ; OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
41 | ; TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
42 | ; YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
43 | ; PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
44 | ; POSSIBILITY OF SUCH DAMAGES.
45 | ;
46 |
47 |
48 | ;; function "push_matrix"
49 | ;; - copies the currrent matrix on stack
50 | ;; and increments stack_entries and adjusts stack_top
51 | ;; INPUTS: - stack_top
52 | ;; OUTPUTS: - stack_top
53 | ;; - stack_entries
54 |
55 | push_matrix:
56 | push acc
57 | push count
58 | push vrmad1
59 | push vrmad2
60 | push vsel
61 |
62 |
63 | ;; copy the current matrix on top of matrix stack
64 |
65 | ;; prepare
66 |
67 | ld stack_top
68 | st vrmad1
69 | mov #1, vrmad2
70 | set1 vsel, ince
71 |
72 | mov #24, count
73 |
74 | ;; copy loop
75 |
76 | .next_byte:
77 | ld @R0
78 | st vtrbf
79 | inc 0
80 |
81 | dbnz count, .next_byte
82 |
83 | ;; now adjust the matrix pointer and the number of matrices in stack
84 | ld vrmad1
85 | st stack_top
86 | inc stack_entries
87 |
88 | ;; reset current matrix pointer(faster than push/pop)
89 |
90 | ld 0
91 | sub #24
92 | st 0
93 |
94 | pop vsel
95 | pop vrmad2
96 | pop vrmad1
97 | pop count
98 | pop acc
99 |
100 | ret
101 |
102 |
103 |
104 |
105 | push_unit_matrix:
106 | callf push_matrix
107 | set1 control, first_mm
108 |
109 | ret
110 |
111 |
112 |
113 |
114 |
115 | ;; function: "pop_matrix"
116 | ;; - if there is at least one matrix in the stack,
117 | ;; it decrements the matrix pointer
118 | ;; INPUTS: - stack_elements
119 | ;; OUTPUTS: - stack_elements
120 | ;; - stack_top
121 |
122 | pop_matrix:
123 | push acc
124 | push count
125 | push vrmad1
126 | push vrmad2
127 | push vsel
128 |
129 | ;; only pop matrix, when there is at least one in the stack
130 | ld stack_entries
131 | bz .end
132 |
133 | ;; copy the top of matrix stack to current matrix
134 |
135 | ;; prepare
136 |
137 | ld stack_top
138 | sub #24
139 | st stack_top
140 | st vrmad1
141 | mov #1, vrmad2
142 | set1 vsel, ince
143 |
144 | mov #24, count
145 |
146 | ;; copy loop, reverse order
147 |
148 | .next_byte:
149 | ld vtrbf
150 | st @R0
151 | inc 0
152 |
153 | dbnz count, .next_byte
154 |
155 | ;; now adjust the number of matrices in stack
156 |
157 | dec stack_entries
158 |
159 | ;; reset current matrix pointer(faster than push/pop)
160 |
161 | ld 0
162 | sub #24
163 | st 0
164 |
165 | .end:
166 | pop vsel
167 | pop vrmad2
168 | pop vrmad1
169 | pop count
170 | pop acc
171 |
172 | ret
173 |
174 |
175 |
176 | ;; function: "init_stack"
177 | ;; - sets transformation and current matrix skeletons, settings and pointers
178 |
179 |
180 | init_stack:
181 | push acc
182 | push trl
183 | push trh
184 | push offset
185 | push count
186 |
187 | ;; now copy over the matrix skeletons
188 |
189 | ;; prepare
190 |
191 | mov #t_start, 0
192 |
193 | mov #matrix_skeletons, trh
195 |
196 | mov #168, count
197 | mov #0, offset
198 |
199 | ;; copy loop
200 |
201 | .next_byte:
202 | ld offset
203 | ldc
204 | st @R0
205 | inc 0
206 | inc offset
207 |
208 | dbnz count, .next_byte
209 |
210 | mov #0, stack_entries ; for sure
211 | mov #stack_top, 0
212 |
213 | set1 control, first_mm
214 | clr1 control, current_matrix ; set current matrix location
215 | mov #c0_start, 0
216 |
217 | pop count
218 | pop offset
219 | pop trh
220 | pop trl
221 | pop acc
222 |
223 | ret
224 |
225 |
226 | ;; function: "reset_stack"
227 | ;; - makes current matrix a unit matrix and clears the stack
228 |
229 |
230 | reset_stack:
231 | push acc
232 | push count
233 |
234 | ;; make the current matrices a unit matrix
235 |
236 | ;; first clear them
237 |
238 | mov #c1_start, 0
239 | mov #48, count
240 | xor acc
241 |
242 | .next_byte:
243 | st @R0
244 | inc 0
245 |
246 | dbnz count, .next_byte
247 |
248 | ;; then insert the 1's
249 |
250 | mov #1, acc
251 | st 252
252 | st 242
253 | st 232
254 |
255 | st 228
256 | st 218
257 | st 208
258 |
259 | ;; make stack empty
260 |
261 | mov #0, stack_entries ; for sure
262 | mov #stack_top, 0
263 |
264 | set1 control, first_mm
265 | clr1 control, current_matrix ; set current matrix location
266 | mov #c0_start, 0
267 |
268 | pop count
269 | pop acc
270 |
271 | ret
272 |
273 |
--------------------------------------------------------------------------------
/src/3d_sub.i:
--------------------------------------------------------------------------------
1 |
2 | ;; Tiny 3d Engine for VMU
3 | ;;
4 | ;; >> War On Iraque Edition (06/01/08) <<
5 | ;;
6 | ;; by Rockin'-B, www.rockin-b.de
7 |
8 | ;
9 | ; Copyright (c) 2003/2006 Thomas Fuchs / The Rockin'-B, www.rockin-b.de
10 | ;
11 | ; Permission is granted to anyone to use this software for any purpose
12 | ; and to redistribute it freely, subject to the following restrictions:
13 | ;
14 | ; 1. The origin of this software must not be misrepresented. You must not
15 | ; claim that you wrote the original software. If you use this software
16 | ; in a product, an acknowledgment in the product documentation would be
17 | ; appreciated but is not required.
18 | ;
19 | ; 2. ANY COMMERCIAL USE IS PROHIBITED. This includes that you must not use
20 | ; this software in the production of a commercial product. Only an explicit
21 | ; permission by the author can allow you to do that.
22 | ;
23 | ; 3. Any modification applied to the software must be marked as such clearly.
24 | ;
25 | ; 4. This license may not be removed or altered from any distribution.
26 | ;
27 | ;
28 | ; NO WARRANTY
29 | ;
30 | ; THERE IS NO WARRANTY FOR THE PROGRAM.
31 | ; THE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
32 | ; EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
33 | ; THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE.
34 | ; THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.
35 | ; SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
36 | ; SERVICING, REPAIR OR CORRECTION.
37 | ;
38 | ; IN NO EVENT WILL THE COPYRIGHT HOLDER BE LIABLE TO YOU FOR DAMAGES,
39 | ; INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
40 | ; OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
41 | ; TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
42 | ; YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
43 | ; PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
44 | ; POSSIBILITY OF SUCH DAMAGES.
45 | ;
46 |
47 |
48 | ;; function: "sub_16bit"
49 | ;; - performs the subtraction of 2 16 bit integers A_x and B_x
50 | ;; in 2's complement form
51 | ;; - result is stored in A_x
52 | ;; CYCLES: - subroutine: 16 + call = 18 cycles, embedded: 12-14 cycles
53 | ;; INPUTS: - A_low
54 | ;; - A_high
55 | ;; - B_low
56 | ;; - B_high
57 | ;; OUTPUTS: - A_low
58 | ;; - A_high
59 |
60 |
61 | sub_16bit:
62 | push acc
63 |
64 | ld A_low
65 | ; clr1 psw, cy
66 | sub B_low
67 | st A_low
68 | ld A_high
69 | subc B_high
70 | st A_high
71 |
72 | ;; overflow CAN occur, when one negative number is added to a positive and
73 | ;; overflow WILL occur, when 2 negative numbers are added
74 | ; bn psw, cy, .no_overflow
75 | ; bp A_high, 7, .no_overflow
76 | ;; now an overflow has occured
77 | ; clr1 psw, cy
78 |
79 | .no_overflow:
80 | pop acc
81 |
82 | ret
83 |
84 |
85 |
86 |
87 | sub_17bit:
88 | push acc
89 | push psw
90 |
91 | callf sub_16bit
92 |
93 | ;; set carry bit only when old and new carry bit are different
94 | pop acc
95 | xor psw
96 | clr1 psw, cy
97 |
98 | bn acc, cy, .no_set
99 | set1 psw, cy
100 |
101 | .no_set:
102 | pop acc
103 | ret
104 |
105 |
--------------------------------------------------------------------------------
/src/3d_translate.i:
--------------------------------------------------------------------------------
1 |
2 | ;; Tiny 3d Engine for VMU
3 | ;;
4 | ;; >> War On Iraque Edition (06/01/08) <<
5 | ;;
6 | ;; by Rockin'-B, www.rockin-b.de
7 |
8 | ;
9 | ; Copyright (c) 2003/2006 Thomas Fuchs / The Rockin'-B, www.rockin-b.de
10 | ;
11 | ; Permission is granted to anyone to use this software for any purpose
12 | ; and to redistribute it freely, subject to the following restrictions:
13 | ;
14 | ; 1. The origin of this software must not be misrepresented. You must not
15 | ; claim that you wrote the original software. If you use this software
16 | ; in a product, an acknowledgment in the product documentation would be
17 | ; appreciated but is not required.
18 | ;
19 | ; 2. ANY COMMERCIAL USE IS PROHIBITED. This includes that you must not use
20 | ; this software in the production of a commercial product. Only an explicit
21 | ; permission by the author can allow you to do that.
22 | ;
23 | ; 3. Any modification applied to the software must be marked as such clearly.
24 | ;
25 | ; 4. This license may not be removed or altered from any distribution.
26 | ;
27 | ;
28 | ; NO WARRANTY
29 | ;
30 | ; THERE IS NO WARRANTY FOR THE PROGRAM.
31 | ; THE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
32 | ; EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
33 | ; THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE.
34 | ; THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.
35 | ; SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
36 | ; SERVICING, REPAIR OR CORRECTION.
37 | ;
38 | ; IN NO EVENT WILL THE COPYRIGHT HOLDER BE LIABLE TO YOU FOR DAMAGES,
39 | ; INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
40 | ; OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
41 | ; TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
42 | ; YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
43 | ; PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
44 | ; POSSIBILITY OF SUCH DAMAGES.
45 | ;
46 |
47 |
48 | ;; function "translate"
49 | ;; - multiplies the current matrix with the following matrix:
50 | ;;
51 | ;; / 1 0 0 tx \
52 | ;; | 0 1 0 ty |
53 | ;; | 0 0 1 tz |
54 | ;; \ 0 0 0 1 /
55 | ;;
56 | ;; INPUTS: - tx_high
57 | ;; - tx_low
58 | ;; - ty_high
59 | ;; - ty_low
60 | ;; - tz_high
61 | ;; - tz_low
62 | ;; - R0 points to current matrix
63 | ;; OUTPUTS: - current matrix(indirect)
64 |
65 | translate_mm:
66 | push 1
67 |
68 | ;; multiply the translation matrix to the current matrix
69 |
70 | mov #t_start, 1
71 |
72 | bn control, first_mm, .multiply
73 |
74 | .copy:
75 | callf copy_matrix
76 | bpc control, first_mm, .end ;; is faster than clr1 plus branch
77 |
78 | .multiply:
79 | callf multiply_matrix
80 |
81 | .end:
82 | pop 1
83 |
84 | ret
85 |
86 |
87 | ;; FAST TRANSFORM: only computes the changing elements of current matrix
88 | ;; -> no need to perform whole matrix multiplication!
89 | ;; - inlined add_16bit
90 | ;;
91 | ;; PERFORMS:
92 | ;; / c11 c12 c13 (c12 + tx) \
93 | ;; | c21 c22 c23 (c24 + ty) |
94 | ;; \ c31 c32 c33 (c34 + tz) /
95 |
96 | translate:
97 | push acc
98 | push 1
99 |
100 |
101 | ;; update x-axis translation
102 |
103 | ld 0
104 | add #7
105 | st 1
106 |
107 | ld @R1
108 | add tx_low
109 | st @R1
110 | dec 1
111 | ld @R1
112 | addc tx_high
113 | st @R1
114 |
115 | ;; update y-axis translation
116 |
117 | ld 1
118 | add #9
119 | st 1
120 |
121 | ld @R1
122 | add ty_low
123 | st @R1
124 | dec 1
125 | ld @R1
126 | addc ty_high
127 | st @R1
128 |
129 | ;; update z-axis translation
130 |
131 | ld 1
132 | add #9
133 | st 1
134 |
135 | ld @R1
136 | add tz_low
137 | st @R1
138 | dec 1
139 | ld @R1
140 | addc tz_high
141 | st @R1
142 |
143 | ;; otherwise these transforms would be simply overwritten
144 | ;; by first multiplied matrix
145 |
146 | clr1 control, first_mm
147 |
148 | pop 1
149 | pop acc
150 |
151 | ret
152 |
153 |
--------------------------------------------------------------------------------
/src/Tiny3dEngine.dev:
--------------------------------------------------------------------------------
1 | [Project]
2 | FileName=Tiny3dEngine.dev
3 | Name=Tiny3dEngine
4 | UnitCount=25
5 | Type=1
6 | Ver=1
7 | ObjFiles=
8 | Includes=
9 | Libs=
10 | PrivateResource=
11 | ResourceIncludes=
12 | MakeIncludes=
13 | Compiler=
14 | CppCompiler=
15 | Linker=
16 | IsCpp=0
17 | Icon=
18 | ExeOutput=
19 | ObjectOutput=
20 | OverrideOutput=0
21 | OverrideOutputName=
22 | HostApplication=
23 | Folders=
24 | CommandLine=
25 | UseCustomMakefile=0
26 | CustomMakefile=
27 | IncludeVersionInfo=0
28 | SupportXPThemes=0
29 | CompilerSet=0
30 | CompilerSettings=0000000000000000000000
31 |
32 | [Unit3]
33 | FileName=3d_test.i
34 | Folder=
35 | Compile=1
36 | Link=1
37 | Priority=1000
38 | OverrideBuildCmd=0
39 | BuildCmd=
40 |
41 | [Unit1]
42 | FileName=3d.s
43 | Folder=Tiny3dEngine
44 | Compile=0
45 | Link=0
46 | Priority=1000
47 | OverrideBuildCmd=0
48 | BuildCmd=
49 |
50 | [Unit2]
51 | FileName=history.txt
52 | Folder=Tiny3dEngine
53 | Compile=0
54 | Link=0
55 | Priority=1000
56 | OverrideBuildCmd=0
57 | BuildCmd=
58 |
59 | [VersionInfo]
60 | Major=0
61 | Minor=1
62 | Release=1
63 | Build=1
64 | LanguageID=1033
65 | CharsetID=1252
66 | CompanyName=
67 | FileVersion=
68 | FileDescription=Developed using the Dev-C++ IDE
69 | InternalName=
70 | LegalCopyright=
71 | LegalTrademarks=
72 | OriginalFilename=
73 | ProductName=
74 | ProductVersion=
75 | AutoIncBuildNr=0
76 |
77 | [Unit4]
78 | FileName=3d_stack.i
79 | Folder=
80 | Compile=1
81 | Link=1
82 | Priority=1000
83 | OverrideBuildCmd=0
84 | BuildCmd=
85 |
86 | [Unit5]
87 | FileName=3d_translate.i
88 | Folder=
89 | Compile=1
90 | Link=1
91 | Priority=1000
92 | OverrideBuildCmd=0
93 | BuildCmd=
94 |
95 | [Unit6]
96 | FileName=3d_scale.i
97 | Folder=
98 | Compile=1
99 | Link=1
100 | Priority=1000
101 | OverrideBuildCmd=0
102 | BuildCmd=
103 |
104 | [Unit7]
105 | FileName=3d_rotate_x.i
106 | Folder=
107 | Compile=1
108 | Link=1
109 | Priority=1000
110 | OverrideBuildCmd=0
111 | BuildCmd=
112 |
113 | [Unit8]
114 | FileName=3d_rotate_y.i
115 | Folder=
116 | Compile=1
117 | Link=1
118 | Priority=1000
119 | OverrideBuildCmd=0
120 | BuildCmd=
121 |
122 | [Unit9]
123 | FileName=3d_rotate_z.i
124 | Folder=
125 | Compile=1
126 | Link=1
127 | Priority=1000
128 | OverrideBuildCmd=0
129 | BuildCmd=
130 |
131 | [Unit10]
132 | FileName=3d_mul.i
133 | Folder=
134 | Compile=1
135 | Link=1
136 | Priority=1000
137 | OverrideBuildCmd=0
138 | BuildCmd=
139 |
140 | [Unit11]
141 | FileName=3d_div.i
142 | Folder=
143 | Compile=1
144 | Link=1
145 | Priority=1000
146 | OverrideBuildCmd=0
147 | BuildCmd=
148 |
149 | [Unit12]
150 | FileName=3d_add.i
151 | Folder=
152 | Compile=1
153 | Link=1
154 | Priority=1000
155 | OverrideBuildCmd=0
156 | BuildCmd=
157 |
158 | [Unit13]
159 | FileName=3d_sub.i
160 | Folder=
161 | Compile=1
162 | Link=1
163 | Priority=1000
164 | OverrideBuildCmd=0
165 | BuildCmd=
166 |
167 | [Unit14]
168 | FileName=3d_framebuffer.i
169 | Folder=
170 | Compile=1
171 | Link=1
172 | Priority=1000
173 | OverrideBuildCmd=0
174 | BuildCmd=
175 |
176 | [Unit15]
177 | FileName=3d_sincos.i
178 | Folder=
179 | Compile=1
180 | Link=1
181 | Priority=1000
182 | OverrideBuildCmd=0
183 | BuildCmd=
184 |
185 | [Unit16]
186 | FileName=3d_matrix.i
187 | Folder=
188 | Compile=1
189 | Link=1
190 | Priority=1000
191 | OverrideBuildCmd=0
192 | BuildCmd=
193 |
194 | [Unit17]
195 | FileName=3d_demo.i
196 | Folder=
197 | Compile=1
198 | Link=1
199 | Priority=1000
200 | OverrideBuildCmd=0
201 | BuildCmd=
202 |
203 | [Unit18]
204 | FileName=3d_draw_line.i
205 | Folder=
206 | Compile=1
207 | Link=1
208 | Priority=1000
209 | OverrideBuildCmd=0
210 | BuildCmd=
211 |
212 | [Unit19]
213 | FileName=3d_polygon_data.i
214 | Folder=
215 | Compile=1
216 | Link=1
217 | Priority=1000
218 | OverrideBuildCmd=0
219 | BuildCmd=
220 |
221 | [Unit20]
222 | FileName=3d_matrix_skeletons.i
223 | Folder=
224 | Compile=1
225 | Link=1
226 | Priority=1000
227 | OverrideBuildCmd=0
228 | BuildCmd=
229 |
230 | [Unit21]
231 | FileName=3d_dot_product.i
232 | Folder=
233 | Compile=1
234 | Link=1
235 | Priority=1000
236 | OverrideBuildCmd=0
237 | BuildCmd=
238 |
239 | [Unit22]
240 | FileName=3d_put_polygon.i
241 | Folder=
242 | Compile=1
243 | Link=1
244 | Priority=1000
245 | OverrideBuildCmd=0
246 | BuildCmd=
247 |
248 | [Unit23]
249 | FileName=3d_project_point.i
250 | Folder=
251 | Compile=1
252 | Link=1
253 | Priority=1000
254 | OverrideBuildCmd=0
255 | BuildCmd=
256 |
257 | [Unit24]
258 | FileName=3d_clip_and_draw_lines.i
259 | Folder=
260 | Compile=1
261 | Link=1
262 | Priority=1000
263 | OverrideBuildCmd=0
264 | BuildCmd=
265 |
266 | [Unit25]
267 | FileName=WHY.TXT
268 | Folder=
269 | Compile=1
270 | Link=1
271 | Priority=1000
272 | OverrideBuildCmd=0
273 | BuildCmd=
274 |
275 |
--------------------------------------------------------------------------------
/src/Tiny3dEngine.layout:
--------------------------------------------------------------------------------
1 | [Editor_6]
2 | CursorCol=1
3 | CursorRow=48
4 | TopLine=25
5 | LeftChar=1
6 | Open=0
7 | Top=0
8 | [Editor_5]
9 | CursorCol=1
10 | CursorRow=48
11 | TopLine=25
12 | LeftChar=1
13 | Open=0
14 | Top=0
15 | [Editor_4]
16 | CursorCol=1
17 | CursorRow=48
18 | TopLine=25
19 | LeftChar=1
20 | Open=0
21 | Top=0
22 | [Editor_3]
23 | CursorCol=1
24 | CursorRow=48
25 | TopLine=25
26 | LeftChar=1
27 | Open=0
28 | Top=0
29 | [Editor_2]
30 | CursorCol=1
31 | CursorRow=48
32 | TopLine=25
33 | LeftChar=1
34 | Open=0
35 | Top=0
36 | [Editors]
37 | Focused=4
38 | Order=
39 | [Editor_0]
40 | Open=0
41 | Top=0
42 | CursorCol=6
43 | CursorRow=418
44 | TopLine=486
45 | LeftChar=1
46 | [Editor_1]
47 | Open=0
48 | Top=0
49 | CursorCol=36
50 | CursorRow=4
51 | TopLine=1
52 | LeftChar=1
53 | [Editor_7]
54 | Open=0
55 | Top=0
56 | CursorCol=1
57 | CursorRow=48
58 | TopLine=25
59 | LeftChar=1
60 | [Editor_8]
61 | Open=0
62 | Top=0
63 | CursorCol=1
64 | CursorRow=48
65 | TopLine=25
66 | LeftChar=1
67 | [Editor_9]
68 | Open=0
69 | Top=0
70 | CursorCol=1
71 | CursorRow=48
72 | TopLine=25
73 | LeftChar=1
74 | [Editor_12]
75 | CursorCol=1
76 | CursorRow=48
77 | TopLine=25
78 | LeftChar=1
79 | Open=0
80 | Top=0
81 | [Editor_11]
82 | CursorCol=1
83 | CursorRow=1
84 | TopLine=1
85 | LeftChar=1
86 | Open=0
87 | Top=0
88 | [Editor_10]
89 | CursorCol=1
90 | CursorRow=48
91 | TopLine=25
92 | LeftChar=1
93 | Open=0
94 | Top=0
95 | [Editor_13]
96 | CursorCol=1
97 | CursorRow=48
98 | TopLine=25
99 | LeftChar=1
100 | Open=0
101 | Top=0
102 | [Editor_14]
103 | CursorCol=1
104 | CursorRow=48
105 | TopLine=25
106 | LeftChar=1
107 | Open=0
108 | Top=0
109 | [Editor_15]
110 | CursorCol=1
111 | CursorRow=48
112 | TopLine=25
113 | LeftChar=1
114 | Open=0
115 | Top=0
116 | [Editor_17]
117 | CursorCol=1
118 | CursorRow=48
119 | TopLine=25
120 | LeftChar=1
121 | Open=0
122 | Top=0
123 | [Editor_21]
124 | CursorCol=1
125 | CursorRow=48
126 | TopLine=25
127 | LeftChar=1
128 | Open=0
129 | Top=0
130 | [Editor_20]
131 | CursorCol=1
132 | CursorRow=48
133 | TopLine=25
134 | LeftChar=1
135 | Open=0
136 | Top=0
137 | [Editor_19]
138 | CursorCol=1
139 | CursorRow=48
140 | TopLine=25
141 | LeftChar=1
142 | Open=0
143 | Top=0
144 | [Editor_18]
145 | CursorCol=1
146 | CursorRow=48
147 | TopLine=25
148 | LeftChar=1
149 | Open=0
150 | Top=0
151 | [Editor_16]
152 | CursorCol=1
153 | CursorRow=48
154 | TopLine=25
155 | LeftChar=1
156 | Open=0
157 | Top=0
158 | [Editor_22]
159 | CursorCol=1
160 | CursorRow=48
161 | TopLine=25
162 | LeftChar=1
163 | Open=0
164 | Top=0
165 | [Editor_23]
166 | CursorCol=1
167 | CursorRow=48
168 | TopLine=25
169 | LeftChar=1
170 | Open=0
171 | Top=0
172 | [Editor_24]
173 | CursorCol=38
174 | CursorRow=21
175 | TopLine=1
176 | LeftChar=1
177 | Open=0
178 | Top=0
179 |
--------------------------------------------------------------------------------
/src/help.i:
--------------------------------------------------------------------------------
1 | ;; Created with BMP2ASM v2.0, by
2 | ;; Source file: "help.bmp"
3 |
4 | help:
5 | .byte 48,32
6 | .byte %00100000,%00011010,%00101011,%10010010,%10000000,%00000000
7 | .byte %01010000,%00100010,%00101001,%00101010,%10000000,%00000000
8 | .byte %01110011,%00010010,%10101001,%00100011,%10110000,%00000000
9 | .byte %01010000,%00001010,%10101001,%00101010,%10010000,%00000000
10 | .byte %01010000,%00110001,%01001001,%00010010,%10010000,%00000000
11 | .byte %00000000,%00000000,%00000000,%00000000,%00010000,%00000000
12 | .byte %00000000,%00100010,%01001100,%11100000,%00010000,%00000000
13 | .byte %00000000,%00110110,%10101010,%10000000,%01010000,%00000000
14 | .byte %00000000,%00101010,%10101010,%11100000,%11110000,%00000000
15 | .byte %00000000,%00100010,%10101010,%10000000,%01000000,%00000000
16 | .byte %00000000,%00100010,%01001100,%11100000,%00000000,%00000000
17 | .byte %00000000,%00000000,%00000000,%00000000,%00000000,%00000000
18 | .byte %01100000,%00010001,%00111010,%10100100,%11101110,%00000000
19 | .byte %01010000,%00101010,%10010010,%10101010,%01001000,%00000000
20 | .byte %01100011,%00111010,%00010010,%10101110,%01001110,%11111000
21 | .byte %01010000,%00101010,%10010010,%10101010,%01001000,%00001000
22 | .byte %01100000,%00101001,%00010010,%01001010,%01001110,%00011100
23 | .byte %00000000,%00000000,%00000000,%00000000,%00000000,%00001000
24 | .byte %00000000,%00000000,%00000000,%00000000,%00000000,%00000000
25 | .byte %00000000,%00111011,%00110011,%00011011,%10010011,%00100010
26 | .byte %00000000,%00010010,%10101010,%10100010,%00101010,%10110110
27 | .byte %00000000,%00010011,%00111010,%10010011,%00101011,%00101010
28 | .byte %00000000,%00010010,%10101010,%10001010,%00101010,%10100010
29 | .byte %00000000,%00010010,%10101010,%10110010,%00010010,%10100010
30 | .byte %00000000,%00000000,%00000000,%00000000,%00000000,%00000000
31 | .byte %00000000,%00000000,%00000000,%00000000,%00000100,%00000000
32 | .byte %01100000,%00010010,%10010011,%00011011,%10001110,%00000000
33 | .byte %01010000,%00101010,%10101010,%10100010,%00000100,%00000000
34 | .byte %01010011,%00100011,%10111010,%10111011,%10111100,%00000000
35 | .byte %01010000,%00101010,%10101010,%10101010,%00000000,%00000000
36 | .byte %01100000,%00010010,%10101010,%10010011,%10000000,%00000000
37 | .byte %00000000,%00000000,%00000000,%00000000,%00000000,%00000000
38 |
--------------------------------------------------------------------------------
/src/icon.i:
--------------------------------------------------------------------------------
1 | ;; This is the VMU file directory icon, present in all VMU applications
2 | ;; from www.Rockin-B.de
3 |
4 |
5 | .byte $CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC
6 | .byte $CF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FC
7 | .byte $CF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FC
8 | .byte $CF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FC
9 | .byte $CF,$CC,$CC,$CF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$CF,$FF,$FF,$FC
10 | .byte $CF,$CF,$FF,$FC,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$CF,$FF,$FF,$FC
11 | .byte $CF,$CF,$FF,$FF,$CF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$CF,$FF,$FF,$FC
12 | .byte $CF,$CF,$FF,$FF,$FC,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$CF,$FF,$FF,$FC
13 | .byte $CF,$CF,$FF,$FF,$FC,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$CF,$FF,$FF,$FC
14 | .byte $CF,$CF,$FF,$FF,$FC,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$CF,$FF,$FF,$FC
15 | .byte $CF,$CF,$FF,$FF,$FC,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$CF,$FF,$FF,$FC
16 | .byte $CF,$CF,$FF,$FF,$FC,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$CF,$FF,$FF,$FC
17 | .byte $CF,$CF,$FF,$FF,$CF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$CF,$FF,$FF,$FC
18 | .byte $CF,$CF,$FF,$FC,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$CF,$FF,$FF,$FC
19 | .byte $CF,$CC,$CC,$CF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$CF,$FF,$FC,$FC
20 | .byte $CF,$CC,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$CF,$FF,$CF,$FC
21 | .byte $CF,$CC,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$CF,$FC,$FF,$FC
22 | .byte $CF,$CF,$CF,$FF,$FF,$FC,$CC,$FF,$FF,$FC,$CC,$FF,$CF,$FC,$FF,$FC
23 | .byte $CF,$CF,$CF,$FF,$FF,$CF,$FF,$CF,$FF,$CF,$FF,$CF,$CF,$CF,$FF,$FC
24 | .byte $CF,$CF,$FC,$FF,$FF,$CF,$FF,$CF,$FF,$CF,$FF,$CF,$CC,$CF,$FF,$FC
25 | .byte $CF,$CF,$FC,$FF,$FC,$FF,$FF,$FC,$FC,$FF,$FF,$FF,$CF,$CF,$FF,$FC
26 | .byte $CF,$CF,$FC,$FF,$FC,$FF,$FF,$FC,$FC,$FF,$FF,$FF,$CF,$FC,$FF,$FC
27 | .byte $CF,$CF,$FF,$CF,$FC,$FF,$FF,$FC,$FC,$FF,$FF,$FF,$CF,$FC,$FF,$FC
28 | .byte $CF,$CF,$FF,$CF,$FC,$FF,$FF,$FC,$FC,$FF,$FF,$FF,$CF,$FC,$FF,$FC
29 | .byte $CF,$CF,$FF,$FC,$FC,$FF,$FF,$FC,$FC,$FF,$FF,$FF,$CF,$FF,$CF,$FC
30 | .byte $CF,$CF,$FF,$FC,$FF,$CF,$FF,$CF,$FF,$CF,$FF,$CF,$CF,$FF,$CF,$FC
31 | .byte $CF,$CF,$FF,$FF,$CF,$CF,$FF,$CF,$FF,$CF,$FF,$CF,$CF,$FF,$FC,$FC
32 | .byte $CF,$CF,$FF,$FF,$CF,$FC,$CC,$FF,$FF,$FC,$CC,$FF,$CF,$FF,$FC,$FC
33 | .byte $CF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FC
34 | .byte $CF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FC
35 | .byte $CF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FC
36 | .byte $CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC
37 |
38 | .byte $CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC
39 | .byte $CF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FC
40 | .byte $CF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FC
41 | .byte $CF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FC
42 | .byte $CF,$FF,$FF,$FF,$FC,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FC
43 | .byte $CF,$FF,$FF,$FF,$FC,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FC
44 | .byte $CF,$FF,$FF,$FF,$FC,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FC
45 | .byte $CF,$FF,$FF,$FF,$FC,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FC
46 | .byte $CF,$FF,$FF,$FF,$FC,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FC,$FC
47 | .byte $CF,$FF,$FF,$FF,$FC,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$CC,$FC
48 | .byte $CF,$FF,$FF,$FF,$FC,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FC,$CF,$FC
49 | .byte $CF,$FF,$FF,$FF,$FC,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FC,$FF,$FC
50 | .byte $CF,$FF,$FF,$FF,$FC,$FF,$FF,$FF,$FC,$FF,$FF,$FF,$FF,$FF,$FF,$FC
51 | .byte $CF,$FF,$FF,$FF,$FC,$FF,$FF,$FF,$CC,$CF,$FF,$FF,$FF,$FF,$FF,$FC
52 | .byte $CF,$FF,$FF,$FF,$FC,$FF,$FF,$CF,$FC,$FF,$FF,$FF,$FF,$FF,$FF,$FC
53 | .byte $CF,$FF,$FF,$FF,$FC,$FF,$FC,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FC
54 | .byte $CF,$FF,$FF,$FF,$FC,$FF,$CF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FC
55 | .byte $CF,$FF,$CC,$CF,$FC,$FF,$CF,$FF,$FC,$FF,$CC,$CC,$CC,$CF,$FF,$FC
56 | .byte $CF,$FC,$FF,$FC,$FC,$FC,$FF,$FF,$FC,$FF,$CF,$FF,$FF,$CF,$FF,$FC
57 | .byte $CF,$FC,$FF,$FC,$FC,$CC,$FF,$FF,$FC,$FF,$CF,$FF,$FF,$CF,$FF,$FC
58 | .byte $CF,$CF,$FF,$FF,$FC,$FC,$FF,$FF,$FC,$FF,$CF,$FF,$FF,$CF,$FF,$FC
59 | .byte $CF,$CF,$FF,$FF,$FC,$FF,$CF,$FF,$FC,$FF,$CF,$FF,$FF,$CF,$FF,$FC
60 | .byte $CF,$CF,$FF,$FF,$FC,$FF,$CF,$FF,$FC,$FF,$CF,$FF,$FF,$CF,$FF,$FC
61 | .byte $CF,$CF,$FF,$FF,$FC,$FF,$CF,$FF,$FC,$FF,$CF,$FF,$FF,$CF,$FF,$FC
62 | .byte $CF,$CF,$FF,$FF,$FC,$FF,$FC,$FF,$FC,$FF,$CF,$FF,$FF,$CF,$FF,$FC
63 | .byte $CF,$FC,$FF,$FC,$FC,$FF,$FC,$FF,$FC,$FF,$CF,$FF,$FF,$CF,$FF,$FC
64 | .byte $CF,$FC,$FF,$FC,$FC,$FF,$FF,$CF,$FC,$FF,$CF,$FF,$FF,$CF,$FF,$FC
65 | .byte $CF,$FF,$CC,$CF,$FC,$FF,$FF,$CF,$FC,$FF,$CF,$FF,$FF,$CF,$FF,$FC
66 | .byte $CF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FC
67 | .byte $CF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FC
68 | .byte $CF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FC
69 | .byte $CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC
70 |
71 | .byte $CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC
72 | .byte $CF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FC
73 | .byte $CF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FC
74 | .byte $CF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FC
75 | .byte $CF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$CC,$CC,$CC,$CF,$FF,$FC
76 | .byte $CF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$CC,$CC,$CC,$CC,$FF,$FC
77 | .byte $CF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$CC,$FF,$FF,$CC,$CF,$FC
78 | .byte $CF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$CC,$FF,$FF,$FC,$CC,$FC
79 | .byte $CF,$FF,$FF,$FF,$FF,$FF,$FF,$FC,$FF,$FF,$CC,$FF,$FF,$FF,$CC,$FC
80 | .byte $CF,$FF,$FF,$FF,$FF,$FF,$FF,$CC,$FF,$FF,$CC,$FF,$FF,$FF,$CC,$FC
81 | .byte $CF,$FF,$FF,$FF,$FF,$FF,$FC,$CF,$FF,$FF,$CC,$FF,$FF,$FF,$CC,$FC
82 | .byte $CF,$FF,$FF,$FF,$FF,$FF,$FC,$FF,$FF,$FF,$CC,$FF,$FF,$FF,$CC,$FC
83 | .byte $CF,$FC,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$CC,$FF,$FF,$FC,$CC,$FC
84 | .byte $CF,$CC,$CF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$CC,$FF,$FF,$CC,$CF,$FC
85 | .byte $CF,$FC,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$CC,$CC,$CC,$CC,$FF,$FC
86 | .byte $CF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$CC,$CC,$CC,$CF,$FF,$FC
87 | .byte $CF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$CC,$CC,$CC,$CF,$FF,$FC
88 | .byte $CF,$FC,$FF,$CC,$CC,$CC,$CF,$FF,$FF,$FF,$CC,$CC,$CC,$CC,$FF,$FC
89 | .byte $CF,$FC,$FF,$CF,$FF,$FF,$CF,$FF,$FF,$FF,$CC,$FF,$FF,$CC,$CF,$FC
90 | .byte $CF,$FC,$FF,$CF,$FF,$FF,$CF,$FF,$FF,$FF,$CC,$FF,$FF,$FC,$CC,$FC
91 | .byte $CF,$FC,$FF,$CF,$FF,$FF,$CF,$FF,$FF,$FF,$CC,$FF,$FF,$FF,$CC,$FC
92 | .byte $CF,$FC,$FF,$CF,$FF,$FF,$CF,$CC,$CC,$CF,$CC,$FF,$FF,$FF,$CC,$FC
93 | .byte $CF,$FC,$FF,$CF,$FF,$FF,$CF,$CC,$CC,$CF,$CC,$FF,$FF,$FF,$CC,$FC
94 | .byte $CF,$FC,$FF,$CF,$FF,$FF,$CF,$FF,$FF,$FF,$CC,$FF,$FF,$FF,$CC,$FC
95 | .byte $CF,$FC,$FF,$CF,$FF,$FF,$CF,$FF,$FF,$FF,$CC,$FF,$FF,$FC,$CC,$FC
96 | .byte $CF,$FC,$FF,$CF,$FF,$FF,$CF,$FF,$FF,$FF,$CC,$FF,$FF,$CC,$CF,$FC
97 | .byte $CF,$FC,$FF,$CF,$FF,$FF,$CF,$FF,$FF,$FF,$CC,$CC,$CC,$CC,$FF,$FC
98 | .byte $CF,$FC,$FF,$CF,$FF,$FF,$CF,$FF,$FF,$FF,$CC,$CC,$CC,$CF,$FF,$FC
99 | .byte $CF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FC
100 | .byte $CF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FC
101 | .byte $CF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FC
102 | .byte $CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC
103 |
--------------------------------------------------------------------------------
/src/misc.i:
--------------------------------------------------------------------------------
1 | ;; This is a collection of functions
2 | ;; from the famous tiny tetris by Marcus Comsted
3 |
4 |
5 |
6 | getkeys:
7 | bp p7,0,quit ; external 5VOLT ?
8 | ld p3 ; p3(Keys) into ACC
9 | bn acc,6,quit ; MODE-key
10 | bn acc,7,sleep ; SLEEP-key
11 | ret
12 |
13 | quit:
14 | jmp goodbye
15 |
16 | sleep:
17 | bn p3,7,sleep ; Wait for SLEEP to be depressed
18 | mov #0,vccr ; Blank LCD
19 | sleepmore:
20 | set1 pcon,0 ; Enter HALT mode
21 | bp p7,0,quit ; Docked?
22 | bp p3,7,sleepmore ; No SLEEP press yet
23 | mov #$80,vccr ; Reenable LCD
24 |
25 | waitsleepup:
26 | bn p3,7,waitsleepup
27 | br getkeys
28 |
29 |
30 | ;; Function: clrscr
31 | ;;
32 | ;; Clears the screen
33 |
34 | clrscr:
35 | clr1 ocr,5
36 | push acc
37 | push xbnk
38 | push 2
39 | mov #0,xbnk
40 | .cbank: mov #$80,2
41 | .cloop: mov #0,@R2
42 | inc 2
43 | ld 2
44 | and #$f
45 | bne #$c,.cskip
46 | ld 2
47 | add #4
48 | st 2
49 | .cskip: ld 2
50 | bnz .cloop
51 | bp xbnk,0,.cexit
52 | mov #1,xbnk
53 | br .cbank
54 | .cexit: pop 2
55 | pop xbnk
56 | pop acc
57 | set1 ocr,5
58 | ret
59 |
60 |
61 | ;; Function: setscr
62 | ;;
63 | ;; Copies a predefined full-screen image to the screen
64 | ;;
65 | ;; Inputs:
66 | ;; trl = low byte of predefined screen ROM address
67 | ;; trh = high byte of predefined screen ROM address
68 |
69 | setscr:
70 | push acc
71 | push xbnk
72 | push c
73 | push 2
74 |
75 | ld trl
76 | add #2
77 | st trl
78 |
79 | bn psw, cy, .no_ovf
80 | inc trh
81 |
82 | .no_ovf:
83 | mov #$80,2
84 | xor acc
85 | st xbnk
86 | st c
87 | .sloop: ldc
88 | st @R2
89 | inc 2
90 | ld 2
91 | and #$f
92 | bne #$c,.sskip
93 | ld 2
94 | add #4
95 | st 2
96 | bnz .sskip
97 | inc xbnk
98 | mov #$80,2
99 | .sskip: inc c
100 | ld c
101 | bne #$c0,.sloop
102 | pop 2
103 | pop c
104 | pop xbnk
105 | pop acc
106 |
107 | ret
108 |
109 |
110 |
--------------------------------------------------------------------------------
/src/sfr.i:
--------------------------------------------------------------------------------
1 |
2 | *
3 | * Special Function Register addresses
4 | *
5 |
6 | ACC EQU $100
7 | PSW EQU $101
8 | B EQU $102
9 | C EQU $103
10 | TRL EQU $104
11 | TRH EQU $105
12 | SP EQU $106
13 | PCON EQU $107
14 | IE EQU $108
15 | IP EQU $109
16 | EXT EQU $10D
17 | OCR EQU $10E
18 | T0CON EQU $110
19 | T0PRR EQU $111
20 | T0L EQU $112
21 | T0LR EQU $113
22 | T0H EQU $114
23 | T0HR EQU $115
24 | T1CNT EQU $118
25 | T1LC EQU $11A
26 | T1L EQU $11B
27 | T1LR EQU $11B
28 | T1HC EQU $11C
29 | T1H EQU $11D
30 | T1HR EQU $11D
31 | MCR EQU $120
32 | STAD EQU $122
33 | CNR EQU $123
34 | TDR EQU $124
35 | XBNK EQU $125
36 | VCCR EQU $127
37 | SCON0 EQU $130
38 | SBUF0 EQU $131
39 | SBR EQU $132
40 | SCON1 EQU $134
41 | SBUF1 EQU $135
42 | P1 EQU $144
43 | P1DDR EQU $145
44 | P1FCR EQU $146
45 | P3 EQU $14C
46 | P3DDR EQU $14D
47 | P3INT EQU $14E
48 | P7 EQU $15C
49 | I01CR EQU $15D
50 | I23CR EQU $15E
51 | ISL EQU $15F
52 | VSEL EQU $163
53 | VRMAD1 EQU $164
54 | VRMAD2 EQU $165
55 | VTRBF EQU $166
56 | VLREG EQU $167
57 | BTCR EQU $17F
58 | XRAM EQU $180
59 |
60 |
61 | *
62 | * PSW bits
63 | *
64 | CY EQU 7
65 | AC EQU 6
66 | IRBK1 EQU 4
67 | IRBK0 EQU 3
68 | OV EQU 2
69 | RAMBK0 EQU 1
70 | P EQU 0
71 |
72 | *
73 | * PCON bits
74 | *
75 | HOLD EQU 1
76 | HALT EQU 0
77 |
78 | *
79 | * IE bits (names guessed by sgust@ithh.infoserv.de)
80 | *
81 | MASTIE EQU 7
82 | INT1PRI EQU 1
83 | INT0PRI EQU 0
84 |
85 | *
86 | * OCR bits (names guessed by sgust@ithh.infoserv.de)
87 | *
88 | HALFCLK EQU 7
89 | SUBCLK EQU 5
90 | MAINCLK EQU 4
91 | RCCTL EQU 1
92 | MAINCTL EQU 0
93 |
94 | *
95 | * T0CON bits
96 | *
97 | T0HRUN EQU 7
98 | T0LRUN EQU 6
99 | T0LONG EQU 5
100 | ELDT0C EQU 4
101 | T0HOVF EQU 3
102 | T0HIE EQU 2
103 | T0LOVF EQU 1
104 | T0LIE EQU 0
105 |
106 | *
107 | * T1CNT bits
108 | *
109 | T1HRUN EQU 7
110 | T1LRUN EQU 6
111 | T1LONG EQU 5
112 | ELDT1C EQU 4
113 | T1HOVF EQU 3
114 | T1HIE EQU 2
115 | T1LOVF EQU 1
116 | T1LIE EQU 0
117 |
118 | *
119 | * P3INT bits (names guessed by sgust@ithh.infoserv.de)
120 | *
121 | P3HOLD EQU 2
122 | P3IFLAG EQU 1
123 | P3IE EQU 0
124 |
125 | *
126 | *VSEL bits(added by Butze@Rockin-b.de)
127 | *
128 | INCE EQU 4
129 |
130 | *
131 | *MCR bits(added by Butze@Rockin-b.de)
132 | *
133 | MCR0 EQU 0
134 | MCR3 EQU 3
135 | MCR4 EQU 4
136 |
137 | *
138 | *VCCR bits(added by Butze@Rockin-b.de)
139 | *
140 | VCCR7 EQU 7
141 |
142 |
143 |
--------------------------------------------------------------------------------
/src/sinetable.i:
--------------------------------------------------------------------------------
1 | ;; a sinetable for all angles between 0 and 90 degrees,
2 | ;; represented as 16 bit fixed point number.
3 |
4 | .byte 0
5 | .byte 0 ;; sin(0deg)
6 | .byte 0
7 | .byte 4 ;; sin(1deg)
8 | .byte 0
9 | .byte 8 ;; sin(2deg)
10 | .byte 0
11 | .byte 13 ;; sin(3deg)
12 | .byte 0
13 | .byte 17 ;; sin(4deg)
14 | .byte 0
15 | .byte 22 ;; sin(5deg)
16 | .byte 0
17 | .byte 26 ;; sin(6deg)
18 | .byte 0
19 | .byte 31 ;; sin(7deg)
20 | .byte 0
21 | .byte 35 ;; sin(8deg)
22 | .byte 0
23 | .byte 40 ;; sin(9deg)
24 | .byte 0
25 | .byte 44 ;; sin(10deg)
26 | .byte 0
27 | .byte 48 ;; sin(11deg)
28 | .byte 0
29 | .byte 53 ;; sin(12deg)
30 | .byte 0
31 | .byte 57 ;; sin(13deg)
32 | .byte 0
33 | .byte 61 ;; sin(14deg)
34 | .byte 0
35 | .byte 66 ;; sin(15deg)
36 | .byte 0
37 | .byte 70 ;; sin(16deg)
38 | .byte 0
39 | .byte 74 ;; sin(17deg)
40 | .byte 0
41 | .byte 79 ;; sin(18deg)
42 | .byte 0
43 | .byte 83 ;; sin(19deg)
44 | .byte 0
45 | .byte 87 ;; sin(20deg)
46 | .byte 0
47 | .byte 91 ;; sin(21deg)
48 | .byte 0
49 | .byte 95 ;; sin(22deg)
50 | .byte 0
51 | .byte 100 ;; sin(23deg)
52 | .byte 0
53 | .byte 104 ;; sin(24deg)
54 | .byte 0
55 | .byte 108 ;; sin(25deg)
56 | .byte 0
57 | .byte 112 ;; sin(26deg)
58 | .byte 0
59 | .byte 116 ;; sin(27deg)
60 | .byte 0
61 | .byte 120 ;; sin(28deg)
62 | .byte 0
63 | .byte 124 ;; sin(29deg)
64 | .byte 0
65 | .byte 127 ;; sin(30deg)
66 | .byte 0
67 | .byte 131 ;; sin(31deg)
68 | .byte 0
69 | .byte 135 ;; sin(32deg)
70 | .byte 0
71 | .byte 139 ;; sin(33deg)
72 | .byte 0
73 | .byte 143 ;; sin(34deg)
74 | .byte 0
75 | .byte 146 ;; sin(35deg)
76 | .byte 0
77 | .byte 150 ;; sin(36deg)
78 | .byte 0
79 | .byte 154 ;; sin(37deg)
80 | .byte 0
81 | .byte 157 ;; sin(38deg)
82 | .byte 0
83 | .byte 161 ;; sin(39deg)
84 | .byte 0
85 | .byte 164 ;; sin(40deg)
86 | .byte 0
87 | .byte 167 ;; sin(41deg)
88 | .byte 0
89 | .byte 171 ;; sin(42deg)
90 | .byte 0
91 | .byte 174 ;; sin(43deg)
92 | .byte 0
93 | .byte 177 ;; sin(44deg)
94 | .byte 0
95 | .byte 181 ;; sin(45deg)
96 | .byte 0
97 | .byte 184 ;; sin(46deg)
98 | .byte 0
99 | .byte 187 ;; sin(47deg)
100 | .byte 0
101 | .byte 190 ;; sin(48deg)
102 | .byte 0
103 | .byte 193 ;; sin(49deg)
104 | .byte 0
105 | .byte 196 ;; sin(50deg)
106 | .byte 0
107 | .byte 198 ;; sin(51deg)
108 | .byte 0
109 | .byte 201 ;; sin(52deg)
110 | .byte 0
111 | .byte 204 ;; sin(53deg)
112 | .byte 0
113 | .byte 207 ;; sin(54deg)
114 | .byte 0
115 | .byte 209 ;; sin(55deg)
116 | .byte 0
117 | .byte 212 ;; sin(56deg)
118 | .byte 0
119 | .byte 214 ;; sin(57deg)
120 | .byte 0
121 | .byte 217 ;; sin(58deg)
122 | .byte 0
123 | .byte 219 ;; sin(59deg)
124 | .byte 0
125 | .byte 221 ;; sin(60deg)
126 | .byte 0
127 | .byte 223 ;; sin(61deg)
128 | .byte 0
129 | .byte 226 ;; sin(62deg)
130 | .byte 0
131 | .byte 228 ;; sin(63deg)
132 | .byte 0
133 | .byte 230 ;; sin(64deg)
134 | .byte 0
135 | .byte 232 ;; sin(65deg)
136 | .byte 0
137 | .byte 233 ;; sin(66deg)
138 | .byte 0
139 | .byte 235 ;; sin(67deg)
140 | .byte 0
141 | .byte 237 ;; sin(68deg)
142 | .byte 0
143 | .byte 238 ;; sin(69deg)
144 | .byte 0
145 | .byte 240 ;; sin(70deg)
146 | .byte 0
147 | .byte 242 ;; sin(71deg)
148 | .byte 0
149 | .byte 243 ;; sin(72deg)
150 | .byte 0
151 | .byte 244 ;; sin(73deg)
152 | .byte 0
153 | .byte 246 ;; sin(74deg)
154 | .byte 0
155 | .byte 247 ;; sin(75deg)
156 | .byte 0
157 | .byte 248 ;; sin(76deg)
158 | .byte 0
159 | .byte 249 ;; sin(77deg)
160 | .byte 0
161 | .byte 250 ;; sin(78deg)
162 | .byte 0
163 | .byte 251 ;; sin(79deg)
164 | .byte 0
165 | .byte 252 ;; sin(80deg)
166 | .byte 0
167 | .byte 252 ;; sin(81deg)
168 | .byte 0
169 | .byte 253 ;; sin(82deg)
170 | .byte 0
171 | .byte 254 ;; sin(83deg)
172 | .byte 0
173 | .byte 254 ;; sin(84deg)
174 | .byte 0
175 | .byte 255 ;; sin(85deg)
176 | .byte 0
177 | .byte 255 ;; sin(86deg)
178 | .byte 0
179 | .byte 255 ;; sin(87deg)
180 | .byte 0
181 | .byte 255 ;; sin(88deg)
182 | .byte 0
183 | .byte 255 ;; sin(89deg)
184 | .byte 1
185 | .byte 0 ;; sin(90deg)
186 |
--------------------------------------------------------------------------------
/src/title.i:
--------------------------------------------------------------------------------
1 | ;; Created with BMP2ASM v2.0, by
2 | ;; Source file: "title.bmp"
3 |
4 | title:
5 | .byte 48,32
6 | .byte %01110000,%00000000,%01000010,%00111000,%00000000,%00000000
7 | .byte %00100100,%00000000,%10100010,%00100000,%00000010,%00000000
8 | .byte %00100000,%00000000,%00100010,%00100000,%00000000,%00000000
9 | .byte %00100101,%10010100,%01000110,%00111011,%00010010,%11000100
10 | .byte %00100101,%01010100,%00101010,%00100010,%10101010,%10101010
11 | .byte %00100101,%01010100,%10101010,%00100010,%10101010,%10101100
12 | .byte %00100101,%01001100,%01000110,%00111010,%10011010,%10100110
13 | .byte %00000000,%00000100,%00000000,%00000000,%00001000,%00000000
14 | .byte %00000000,%00011000,%00000000,%00000000,%00110000,%00000000
15 | .byte %00000000,%00000000,%00000000,%00000000,%00000000,%00000000
16 | .byte %11111111,%11111111,%11111111,%11111111,%11111111,%11111111
17 | .byte %00000000,%00000000,%00000000,%00000000,%00000000,%00000000
18 | .byte %01000100,%10011000,%01001100,%00101100,%01000100,%10101110
19 | .byte %01000101,%01010100,%10101010,%00101010,%10101010,%10101000
20 | .byte %01010101,%11011000,%10101010,%00101100,%11101010,%10101110
21 | .byte %01010101,%01010100,%10101010,%00101010,%10101100,%10101000
22 | .byte %00101001,%01010100,%01001010,%00101010,%10100110,%01101110
23 | .byte %00000000,%00000000,%00000000,%00000000,%00000000,%00000000
24 | .byte %00000000,%00000000,%00000000,%00000000,%00000000,%00000000
25 | .byte %00000000,%00001110,%11001011,%10100100,%11000000,%00000000
26 | .byte %00000000,%00001000,%10101001,%00101010,%10100000,%00000000
27 | .byte %00000000,%00001110,%10101001,%00101010,%10100000,%00000000
28 | .byte %00000000,%00001000,%10101001,%00101010,%10100000,%00000000
29 | .byte %00000000,%00001110,%11001001,%00100100,%10100000,%00000000
30 | .byte %00000000,%00000000,%00000000,%00000000,%00000000,%00000000
31 | .byte %11111111,%11111111,%11111111,%11111111,%11111111,%11111111
32 | .byte %00000000,%00000000,%00000000,%00000000,%00000000,%00000000
33 | .byte %00010001,%10001000,%10010101,%01100000,%11000011,%00111000
34 | .byte %00010001,%01010101,%01010101,%01010000,%10100010,%10100000
35 | .byte %01011101,%10010101,%00011001,%01010110,%11000010,%10110000
36 | .byte %00111101,%01010101,%01010101,%01010000,%10100010,%10100000
37 | .byte %00011101,%01001000,%10010101,%01010000,%11001011,%00111000
38 |
--------------------------------------------------------------------------------
/util/DCI_VMI.COM:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gyrovorbis/tiny3dengine/4cada5c9850b1252f522270635a28cafcd9e7763/util/DCI_VMI.COM
--------------------------------------------------------------------------------
/util/assemble.bat:
--------------------------------------------------------------------------------
1 | vmuasm 3d.s
2 | PAUSE
--------------------------------------------------------------------------------
/util/bmp2asm.bat:
--------------------------------------------------------------------------------
1 | bmp2asm title.bmp > title.i
2 | bmp2asm help.bmp > help.i
3 |
--------------------------------------------------------------------------------
/util/createDCI.bat:
--------------------------------------------------------------------------------
1 | DCI_VMI.COM 3D.VMS
2 |
--------------------------------------------------------------------------------
/util/sinetable.bat:
--------------------------------------------------------------------------------
1 | cd pc
2 | sinetable > ../sinetable.i
3 |
--------------------------------------------------------------------------------