File: turbo-test.c

package info (click to toggle)
cc65 2.19-2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 20,268 kB
  • sloc: ansic: 117,151; asm: 66,339; pascal: 4,248; makefile: 1,009; perl: 607
file content (57 lines) | stat: -rw-r--r-- 1,275 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* Accelerator test code. */

#ifndef ACC_DETECT
#error This file cannot be used directly (yet)
#endif

#include <time.h>
#include <accelerator.h>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>

static void print_time_taken(void)
{
    clock_t curtime = clock();
    clock_t newtime;
    unsigned long i;
    char buffer[10];

    printf("Doing a speed test, please wait\n");
    for (i = 0; i < 0x1000; i++) { }
    newtime = clock() - curtime;
    ultoa(newtime, buffer, 10);
    printf("Time taken : %s\n", buffer);
}

static void print_current_speed(void)
{
    unsigned char status;

    status = ACC_GET_SPEED();
    printf("Current "ACC_NAME" speed : %d\n", status + 1);
}

void main(void)
{
    unsigned char status;
    unsigned char speed = 0;

    status = ACC_DETECT();
    clrscr();
    if (status == 0) {
        printf("No "ACC_NAME" detected\n");
    } else {
        status = ACC_GET_SPEED();
        print_current_speed();

        /* cycle through all the speeds */
        for (speed = SPEED_1X; speed <= SPEED_20X; ++speed) {
            printf("Setting "ACC_NAME" speed to %d\n", speed + 1);
            ACC_SET_SPEED(speed);
            print_current_speed();
            print_time_taken();
        }
        ACC_SET_SPEED(status);
    }
}