1 /* mul-test.c -- Test the multiplication operator. */
8 /* Number of elements in the progress bar. Use a power of 2, to avoid the
9 ** multiplication (which is about to be tested).
11 #define BAR_ELEMENTS 32U
14 static const unsigned char revers_bar[8] = {
15 0, 0, 0, 0, 0, 1, 1, 1
17 static const unsigned char small_bar[8] = {
18 ' ', 0xa5, 0xb4, 0xb5, 0xa1, 0xb6, 0xaa, 0xa7
21 #elif defined(__ATARI__)
24 /* Screen co-ordinates for the progress meter */
25 static unsigned char Width, Height;
26 static unsigned char X, Y;
28 static void ProgressMeter (unsigned Val)
29 /* Print the progress bar. */
32 cprintf (" %5lu/65536\r\n", (unsigned long) Val);
34 cclear (Val / (unsigned)(65536U / BAR_ELEMENTS));
36 /* Commodore and Atari computers can show eight times greater precision. */
38 Val = (Val / (unsigned)(65536U / BAR_ELEMENTS / 8)) % 8;
39 revers (revers_bar[Val]);
40 cputc (small_bar[Val]);
42 #elif defined(__ATARI__)
63 /* Actual test variables */
64 register unsigned lhs = 0;
65 register unsigned rhs = 0;
66 register unsigned res;
68 /* Clear the screen, and output an informational message. */
70 screensize (&Width, &Height);
71 cprintf ("This program does an exhaustive test of\r\n"
72 "the multiplication routine. It runs for\r\n"
73 "several days; so, please wait very\r\n"
74 "patiently (or, speed up your emulator).\r\n"
78 /* Remember the current position for the progress bar */
82 /* Mark the maximum limit of the bar. */
84 cputcxy (BAR_ELEMENTS, Y, ' ');
85 cputcxy (BAR_ELEMENTS, Y + 1, ' ');
88 /* [Targets that have clock() will define CLOCKS_PER_SEC.] */
91 /* Start timing the test. */
97 /* Update the progress bar */
100 /* Enable this to test the progress-meter code.
101 ** (And, run emulators at their maximun speed.)
107 /* Do one row of tests */
110 if (lhs * rhs != res) {
111 #ifdef CLOCKS_PER_SEC
115 cprintf ("Error on %u * %u: %u != %u\r\n", lhs, rhs, lhs * rhs, res);
116 cprintf ("Press a key -- 'Q' to quit. ");
118 C = toupper (cgetc ());
119 cclearxy (0, Y+3, Width);
120 cclearxy (0, Y+4, Width);
122 #ifdef CLOCKS_PER_SEC
124 /* Don't time the user's interaction. */
125 Ticks += clock () - Wait;
133 if (kbhit () && toupper (cgetc ()) == 'Q') {
138 } while (++rhs != 0);
140 } while (++lhs != 0);
143 #ifdef CLOCKS_PER_SEC
145 /* Calculate the time used */
146 Ticks = clock() - Ticks;
147 Milli = ((Ticks % CLOCKS_PER_SEC) * 1000) / CLOCKS_PER_SEC;
148 Sec = (unsigned) (Ticks / CLOCKS_PER_SEC);
156 /* Print the time used */
158 cprintf ("Time used:\r\n"
162 " %u.%03u seconds.\n", Days, Hours, Minu, Sec, Milli);
165 cprintf ("\rTap a key, to exit. ");