From e2cf4987cf297d3a8a6d5cfb1b5bf7c6f7fca644 Mon Sep 17 00:00:00 2001 From: Marco van den Heuvel Date: Tue, 10 Apr 2018 15:24:15 -0700 Subject: [PATCH] Added some accelerator test code. --- testcode/lib/accelerator/Makefile | 9 +++ testcode/lib/accelerator/c64-c128-scpu-test.c | 8 +++ testcode/lib/accelerator/turbo-test.c | 57 +++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 testcode/lib/accelerator/Makefile create mode 100755 testcode/lib/accelerator/c64-c128-scpu-test.c create mode 100644 testcode/lib/accelerator/turbo-test.c diff --git a/testcode/lib/accelerator/Makefile b/testcode/lib/accelerator/Makefile new file mode 100644 index 000000000..ece54ec36 --- /dev/null +++ b/testcode/lib/accelerator/Makefile @@ -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 diff --git a/testcode/lib/accelerator/c64-c128-scpu-test.c b/testcode/lib/accelerator/c64-c128-scpu-test.c new file mode 100755 index 000000000..975244df5 --- /dev/null +++ b/testcode/lib/accelerator/c64-c128-scpu-test.c @@ -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" diff --git a/testcode/lib/accelerator/turbo-test.c b/testcode/lib/accelerator/turbo-test.c new file mode 100644 index 000000000..8c854c00c --- /dev/null +++ b/testcode/lib/accelerator/turbo-test.c @@ -0,0 +1,57 @@ +/* Accelerator test code. */ + +#ifndef ACC_DETECT +#error This file cannot be used directly (yet) +#endif + +#include +#include +#include +#include +#include + +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); + } +} -- 2.39.5