1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-08 15:29:37 +00:00

Added some accelerator test code.

This commit is contained in:
Marco van den Heuvel 2018-04-10 15:24:15 -07:00
parent 89c3ed6d7f
commit e2cf4987cf
3 changed files with 74 additions and 0 deletions

View File

@ -0,0 +1,9 @@
CL ?= cl65
all: c64-scpu-test.prg c128-scpu-test.prg
c64-scpu-test.prg: c64-c128-scpu-test.c
$(CL) -t c64 c64-c128-scpu-test.c -o c64-scpu-test.prg
c128-scpu-test.prg: c64-c128-scpu-test.c
$(CL) -t c128 c64-c128-scpu-test.c -o c128-scpu-test.prg

View File

@ -0,0 +1,8 @@
/* C64/C128 SuperCPU accelerator test code. */
#define ACC_DETECT detect_scpu
#define ACC_GET_SPEED get_scpu_speed
#define ACC_SET_SPEED set_scpu_speed
#define ACC_NAME "SuperCPU"
#include "turbo-test.c"

View File

@ -0,0 +1,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);
}
}