/[projet1]/public/oric/routines/rasterization/linebench/Main.c
Defence Force logotype

Annotation of /public/oric/routines/rasterization/linebench/Main.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 261 - (hide annotations)
Mon Feb 8 14:01:57 2010 UTC (9 years, 9 months ago) by thrust26
File MIME type: text/plain
File size: 8513 byte(s)
optimized chunking, 482
1 dbug 46
2     #include <lib.h>
3    
4     // --------------------------------------
5     // LineBench
6     // --------------------------------------
7     // (c) 2003-2008 Mickael Pointier.
8     // This code is provided as-is.
9     // I do not assume any responsability
10     // concerning the fact this is a bug-free
11     // software !!!
12     // Except that, you can use this example
13     // without any limitation !
14     // If you manage to do something with that
15     // please, contact me :)
16     // --------------------------------------
17     // --------------------------------------
18     // For more information, please contact me
19     // on internet:
20     // e-mail: mike@defence-force.org
21     // URL: http://www.defence-force.org
22     // --------------------------------------
23     // Note: This text was typed with a Win32
24     // editor. So perhaps the text will not be
25     // displayed correctly with other OS.
26    
27    
28     // ============================================================================
29     //
30 thrust26 258 // Externals
31 dbug 46 //
32     // ============================================================================
33    
34     #include "params.h"
35    
36     //
37     // ===== Display.s =====
38     //
39 thrust26 258 extern unsigned char CurrentPixelX; // Coordinate X of edited pixel/byte
40     extern unsigned char CurrentPixelY; // Coordinate Y of edited pixel/byte
41 dbug 46
42 thrust26 258 extern unsigned char OtherPixelX; // Coordinate X of other edited pixel/byte
43     extern unsigned char OtherPixelY; // Coordinate Y of other edited pixel/byte
44 dbug 46
45    
46     //
47     // ===== Buffer.s =====
48     //
49     void DrawLine();
50 dbug 219 void DrawLine8();
51     void DrawLine8_toptobottomandlefttoright();
52 dbug 46
53     //
54     // ===== Clip.s =====
55     //
56     void DrawClippedLine();
57     void Break();
58    
59     extern int LargeX0;
60     extern int LargeY0;
61     extern int LargeX1;
62     extern int LargeY1;
63    
64     extern int LargeX;
65     extern int LargeY;
66    
67    
68 dbug 219 void test0()
69     {
70 thrust26 258 int i;
71 dbug 46
72 thrust26 258 // Testing all positions from top left
73     for (i=0;i<=239;i++)
74     {
75     CurrentPixelX=0;
76     CurrentPixelY=0;
77     OtherPixelX=i;
78     OtherPixelY=199;
79 dbug 219
80 thrust26 258 DrawLine8();
81     //DrawLine8_toptobottomandlefttoright();
82     }
83 dbug 219
84 thrust26 258 /*
85     // TopLeft to BottomRight
86     CurrentPixelX=0;
87     CurrentPixelY=0;
88     OtherPixelX=239;
89     OtherPixelY=199;
90     */
91    
92     /*
93     // TopLeft to BottomRight - diagonal
94     CurrentPixelX=1;
95     CurrentPixelY=0;
96     OtherPixelX=199;
97     OtherPixelY=199;
98     */
99    
100     /*
101     // BottomLeft to TopRight
102     CurrentPixelX=0;
103     CurrentPixelY=199;
104     OtherPixelX=239;
105     OtherPixelY=0;
106     */
107    
108     /*
109     // TopRight to BottomLeft
110     CurrentPixelX=239;
111     CurrentPixelY=0;
112     OtherPixelX=0;
113     OtherPixelY=199;
114     */
115    
116     //DrawLine();
117     //DrawLine8();
118    
119     while (1);
120 dbug 219 }
121    
122    
123     void line_mike_8()
124     {
125 thrust26 261 int i, j;
126 dbug 219
127 thrust26 261 // test correctness:
128     /*for (j=0; j<8; j++)
129     {
130     for (i=2; i<=99; i+=5)
131     {
132     // very horizontal
133     CurrentPixelX = 160+j;
134     CurrentPixelY = 100-i;
135     OtherPixelX = 80-j;
136     OtherPixelY = 100+i;
137     DrawLine8();
138 thrust26 259
139 thrust26 261 // very horizontal
140     CurrentPixelX = 160+j;
141     CurrentPixelY = 100+i;
142     OtherPixelX = 80-j;
143     OtherPixelY = 100-i;
144     DrawLine8();
145     }
146     // vertical
147     CurrentPixelX = 80-j;
148     CurrentPixelY = 0;
149     OtherPixelX = CurrentPixelX;
150     OtherPixelY = 200;
151 thrust26 259 DrawLine8();
152    
153 thrust26 261 // vertical
154     CurrentPixelX = 160+j;
155     CurrentPixelY = 0;
156     OtherPixelX = CurrentPixelX;
157     OtherPixelY = 200;
158 thrust26 259 DrawLine8();
159    
160 thrust26 261 for (i=0; i<50; i++)
161     {
162     // vertical
163     CurrentPixelX = 0;
164     CurrentPixelY = 199;
165     OtherPixelX = 239;
166     OtherPixelY = 199;
167     DrawLine8();
168     }
169 thrust26 259
170 thrust26 261 // vertical
171     CurrentPixelX = 80-j;
172     CurrentPixelY = 0;
173     OtherPixelX = CurrentPixelX;
174     OtherPixelY = 200;
175 thrust26 259 DrawLine8();
176    
177     // vertical
178 thrust26 261 CurrentPixelX = 160+j;
179     CurrentPixelY = 0;
180     OtherPixelX = CurrentPixelX;
181     OtherPixelY = 200;
182 thrust26 259 DrawLine8();
183    
184 thrust26 261 for (i=2; i<=99; i+=5)
185 thrust26 258 {
186 thrust26 261 // very horizontal
187     CurrentPixelX = 160+j;
188     CurrentPixelY = 100-i;
189     OtherPixelX = 80-j;
190     OtherPixelY = 100+i;
191     DrawLine8();
192 dbug 219
193 thrust26 261 // very horizontal
194     CurrentPixelX = 160+j;
195     CurrentPixelY = 100+i;
196     OtherPixelX = 80-j;
197     OtherPixelY = 100-i;
198     DrawLine8();
199 thrust26 258 }
200 thrust26 261 }*/
201 dbug 219
202 thrust26 261 // benchmark
203     for (i=0;i<239;i++)
204     {
205     OtherPixelX=i;
206     OtherPixelY=0;
207     CurrentPixelX=239-i;
208     CurrentPixelY=199;
209     DrawLine8();
210     }
211     for (i=198;i>=0;i--)
212     {
213     OtherPixelX=0;
214     OtherPixelY=i;
215     CurrentPixelX=239;
216     CurrentPixelY=199-i;
217     DrawLine8();
218     }
219 dbug 219 }
220    
221    
222 dbug 46 void line_mike()
223     {
224 thrust26 258 int i;
225 dbug 46
226 thrust26 258 /*
227     CurrentPixelX=0;
228     CurrentPixelY=0;
229     OtherPixelX=0;
230     OtherPixelY=199;
231 dbug 46
232 thrust26 258 DrawLine();
233     */
234 dbug 219
235 thrust26 258 /*
236     while (1)
237     {
238     LargeX0=0;
239     LargeY0=0;
240     LargeX1=239;
241     LargeY1=199;
242 dbug 46
243 thrust26 258 DrawClippedLine();
244     }
245     */
246 dbug 46
247 thrust26 258 /*
248     while (1)
249     {
250     for (i=30;i<50;i++)
251     {
252     LargeX0=i;
253     LargeY0=0;
254     LargeX1=239-i;
255     LargeY1=199;
256 dbug 219
257 thrust26 258 DrawClippedLine();
258     }
259     }
260     for (i=0;i<199;i++)
261     {
262     LargeX0=0;
263     LargeY0=i;
264     LargeX1=239;
265     LargeY1=199-i;
266 dbug 219
267 thrust26 258 DrawClippedLine();
268     }
269     */
270    
271     for (i=0;i<239;i++)
272     {
273     OtherPixelX=i;
274     OtherPixelY=0;
275     CurrentPixelX=239-i;
276     CurrentPixelY=199;
277    
278     DrawLine();
279     }
280     for (i=0;i<199;i++)
281     {
282     OtherPixelX=0;
283     OtherPixelY=i;
284     CurrentPixelX=239;
285     CurrentPixelY=199-i;
286    
287     DrawLine();
288     }
289     /*
290     for (i=0;i<239;i++)
291     {
292     CurrentPixelX=i;
293     CurrentPixelY=0;
294     OtherPixelX=239-i;
295     OtherPixelY=199;
296    
297     DrawLine();
298     }
299     for (i=0;i<199;i++)
300     {
301     CurrentPixelX=0;
302     CurrentPixelY=i;
303     OtherPixelX=239;
304     OtherPixelY=199-i;
305    
306     DrawLine();
307     }
308     */
309    
310 dbug 46 }
311    
312    
313     void line_basic()
314     {
315 thrust26 258 unsigned char i;
316     for (i=0;i<239;i++)
317     {
318     curset(i,0,3);
319     draw(239-i-i,199,2);
320     }
321     for (i=0;i<199;i++)
322     {
323     curset(0,i,3);
324     draw(239,199-i-i,2);
325     }
326 dbug 46 }
327    
328    
329     void test()
330     {
331 thrust26 258 unsigned int delay;
332    
333     while (1)
334     {
335     // Judd routine first
336     printf("\nMike 8bit: ");
337     *(unsigned int*)0x276=0;
338     line_mike_8();
339     delay=65536-(*(unsigned int*)0x276);
340     printf(" duration: %d",delay);
341     /*
342     // Mike routine first
343     printf("\nMike 16bit: ");
344     *(unsigned int*)0x276=0;
345     line_mike();
346     delay=65536-(*(unsigned int*)0x276);
347     printf(" duration: %d",delay);
348    
349     // Basic routine second
350     printf("\nBasic: ");
351     *(unsigned int*)0x276=0;
352     line_basic();
353     delay=65536-(*(unsigned int*)0x276);
354     printf(" duration: %d",delay);
355     */
356     }
357 dbug 46 }
358    
359    
360 dbug 219
361    
362 dbug 46 void main()
363 thrust26 258 {
364     GenerateTables();
365     hires();
366 dbug 46
367 thrust26 258 test();
368     //test0();
369 dbug 46 }
370    
371    

  ViewVC Help
Powered by ViewVC 1.1.26