2002-12-06 21:55:56 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <conio.h>
|
|
|
|
#include <em.h>
|
|
|
|
|
|
|
|
#define FORCE_ERROR1 0
|
|
|
|
#define FORCE_ERROR2 0
|
|
|
|
|
2002-12-09 12:22:48 +00:00
|
|
|
#define PAGE_SIZE 128 /* Size in words */
|
|
|
|
#define BUF_SIZE (PAGE_SIZE + PAGE_SIZE/2)
|
|
|
|
static unsigned buf[BUF_SIZE];
|
2002-12-06 21:55:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2005-11-20 13:31:42 +00:00
|
|
|
static void cleanup (void)
|
|
|
|
/* Remove the driver on exit */
|
|
|
|
{
|
|
|
|
em_unload ();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-12-09 12:22:48 +00:00
|
|
|
static void fill (register unsigned* page, register unsigned char count, register unsigned num)
|
2002-12-06 21:55:56 +00:00
|
|
|
{
|
2002-12-09 12:22:48 +00:00
|
|
|
register unsigned char i;
|
|
|
|
for (i = 0; i < count; ++i, ++page) {
|
2002-12-06 21:55:56 +00:00
|
|
|
*page = num;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-12-09 12:22:48 +00:00
|
|
|
static void cmp (unsigned page, register const unsigned* buf,
|
|
|
|
register unsigned char count, register unsigned num)
|
2002-12-06 21:55:56 +00:00
|
|
|
{
|
2002-12-09 12:22:48 +00:00
|
|
|
register unsigned char i;
|
|
|
|
for (i = 0; i < count; ++i, ++buf) {
|
2002-12-06 21:55:56 +00:00
|
|
|
if (*buf != num) {
|
|
|
|
cprintf ("\r\nData mismatch in page $%04X at $%04X\r\n"
|
|
|
|
"Data is $%04X (should be $%04X)\r\n",
|
|
|
|
page, buf, *buf, num);
|
2013-08-27 20:01:19 +00:00
|
|
|
#ifdef __ATARI__
|
|
|
|
cgetc ();
|
|
|
|
#endif
|
2002-12-06 21:55:56 +00:00
|
|
|
exit (EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-29 06:06:32 +00:00
|
|
|
typedef struct emd_test_s {
|
|
|
|
char key;
|
|
|
|
char *displayname;
|
|
|
|
char *drivername;
|
|
|
|
} emd_test_t;
|
|
|
|
|
|
|
|
static emd_test_t drivers[] = {
|
|
|
|
|
|
|
|
#if defined(__APPLE2__)
|
2015-11-30 18:15:28 +00:00
|
|
|
{ '0', "Apple II auxiliary memory", "a2.auxmem.emd" },
|
2015-11-29 06:06:32 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__APPLE2ENH__)
|
|
|
|
{ '0', "Apple II auxiliary memory", "a2e.auxmem.emd" },
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__ATARI__)
|
|
|
|
{ '0', "Atari 130XE memory", "atr130.emd" },
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__ATARIXL__)
|
2015-11-30 18:15:28 +00:00
|
|
|
{ '0', "Atari 130XE memory", "atrx130.emd" },
|
2015-11-29 06:06:32 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__C16__)
|
|
|
|
{ '0', "C16 RAM above $8000", "c16-ram.emd" },
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__C64__)
|
|
|
|
{ '0', "C64 RAM above $D000", "c64-ram.emd" },
|
|
|
|
{ '1', "C64 256K", "c64-c256k.emd" },
|
|
|
|
{ '2', "Double Quick Brown Box", "c64-dqbb.emd" },
|
|
|
|
{ '3', "GEORAM", "c64-georam.emd" },
|
|
|
|
{ '4', "Isepic", "c64-isepic.emd" },
|
|
|
|
{ '5', "RamCart", "c64-ramcart.emd" },
|
|
|
|
{ '6', "REU", "c64-reu.emd" },
|
|
|
|
{ '7', "C128 VDC (in C64 mode)", "c64-vdc.emd" },
|
|
|
|
{ '8', "C64DTV himem", "dtv-himem.emd" },
|
2016-02-26 22:51:37 +00:00
|
|
|
{ '9', "65816 extra banks", "c64-65816.emd" },
|
2015-11-29 06:06:32 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__C128__)
|
|
|
|
{ '0', "C128 RAM in bank 1", "c128-ram.emd" },
|
|
|
|
{ '1', "C128 RAM in banks 1, 2 & 3", "c128-ram2.emd" },
|
|
|
|
{ '2', "GEORAM", "c128-georam.emd" },
|
|
|
|
{ '3', "RamCart", "c128-ramcart.emd" },
|
|
|
|
{ '4', "REU", "c128-reu.emd" },
|
|
|
|
{ '5', "VDC", "c128-vdc.emd" },
|
2015-11-30 17:53:30 +00:00
|
|
|
{ '6', "Internal Function RAM", "c128-ifnram.emd" },
|
2015-12-01 04:14:45 +00:00
|
|
|
{ '7', "External Function RAM", "c128-efnram.emd" },
|
2015-11-29 06:06:32 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__CBM510__)
|
|
|
|
{ '0', "CBM5x0 RAM in bank 2", "cbm510-ram.emd" },
|
|
|
|
#endif
|
2002-12-06 21:55:56 +00:00
|
|
|
|
2015-11-29 06:06:32 +00:00
|
|
|
#if defined(__CBM610__)
|
|
|
|
{ '0', "CBM6x0/7x0 RAM in bank 2", "cbm610-ram.emd" },
|
|
|
|
#endif
|
|
|
|
|
2015-11-29 18:50:22 +00:00
|
|
|
{ 0, NULL, NULL }
|
2015-11-29 06:06:32 +00:00
|
|
|
};
|
2002-12-06 21:55:56 +00:00
|
|
|
|
|
|
|
int main (void)
|
|
|
|
{
|
|
|
|
unsigned char Res;
|
|
|
|
unsigned I;
|
2002-12-09 12:22:48 +00:00
|
|
|
unsigned Offs;
|
2002-12-06 21:55:56 +00:00
|
|
|
unsigned PageCount;
|
|
|
|
unsigned char X, Y;
|
|
|
|
struct em_copy c;
|
2015-11-29 06:06:32 +00:00
|
|
|
unsigned index;
|
|
|
|
signed char valid_key = -1;
|
|
|
|
char key;
|
|
|
|
|
|
|
|
clrscr ();
|
|
|
|
cputs ("Which RAM exp to test?\r\n\r\n");
|
2015-11-29 18:50:22 +00:00
|
|
|
for (index = 0; drivers[index].key; ++index) {
|
2015-11-29 06:06:32 +00:00
|
|
|
cprintf("%c: %s\r\n", drivers[index].key, drivers[index].displayname);
|
|
|
|
}
|
|
|
|
|
2015-11-29 18:50:22 +00:00
|
|
|
while (valid_key < 0) {
|
2015-11-29 06:06:32 +00:00
|
|
|
key = cgetc();
|
2015-11-29 18:50:22 +00:00
|
|
|
for (index = 0; drivers[index].key && valid_key < 0; ++index) {
|
2015-11-29 06:06:32 +00:00
|
|
|
if (key == drivers[index].key) {
|
|
|
|
valid_key = index;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-12-06 21:55:56 +00:00
|
|
|
|
|
|
|
clrscr ();
|
2015-11-29 06:06:32 +00:00
|
|
|
Res = em_load_driver (drivers[valid_key].drivername);
|
2002-12-06 21:55:56 +00:00
|
|
|
if (Res != EM_ERR_OK) {
|
2013-05-09 11:56:54 +00:00
|
|
|
cprintf ("Error in em_load_driver: %u\r\n", Res);
|
2002-12-06 21:55:56 +00:00
|
|
|
cprintf ("os: %u, %s\r\n", _oserror, _stroserror (_oserror));
|
2013-08-27 20:01:19 +00:00
|
|
|
#ifdef __ATARI__
|
|
|
|
cgetc ();
|
|
|
|
#endif
|
2013-05-09 11:56:54 +00:00
|
|
|
exit (EXIT_FAILURE);
|
2002-12-06 21:55:56 +00:00
|
|
|
}
|
2005-11-20 13:31:42 +00:00
|
|
|
atexit (cleanup);
|
2002-12-06 21:55:56 +00:00
|
|
|
|
|
|
|
/* Get the number of available pages */
|
|
|
|
PageCount = em_pagecount ();
|
|
|
|
cprintf ("Loaded ok, page count = $%04X\r\n", PageCount);
|
|
|
|
|
2002-12-09 12:22:48 +00:00
|
|
|
/* TEST #1: em_map/em_use/em_commit */
|
|
|
|
cputs ("Testing em_map/em_use/em_commit");
|
|
|
|
|
2002-12-06 21:55:56 +00:00
|
|
|
/* Fill all pages */
|
2002-12-09 12:22:48 +00:00
|
|
|
cputs ("\r\n Filling ");
|
2002-12-06 21:55:56 +00:00
|
|
|
X = wherex ();
|
|
|
|
Y = wherey ();
|
|
|
|
for (I = 0; I < PageCount; ++I) {
|
2002-12-09 12:22:48 +00:00
|
|
|
|
|
|
|
/* Fill the buffer and copy it to em */
|
|
|
|
fill (em_use (I), PAGE_SIZE, I);
|
2002-12-06 21:55:56 +00:00
|
|
|
em_commit ();
|
2002-12-09 12:22:48 +00:00
|
|
|
|
|
|
|
/* Keep the user happy */
|
2002-12-06 21:55:56 +00:00
|
|
|
gotoxy (X, Y);
|
|
|
|
cputhex16 (I);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if FORCE_ERROR1
|
|
|
|
((unsigned*) em_map (0x03))[0x73] = 0xFFFF;
|
|
|
|
em_commit ();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Check all pages */
|
2002-12-09 12:22:48 +00:00
|
|
|
cputs ("\r\n Comparing ");
|
2002-12-06 21:55:56 +00:00
|
|
|
X = wherex ();
|
|
|
|
Y = wherey ();
|
|
|
|
for (I = 0; I < PageCount; ++I) {
|
2002-12-09 12:22:48 +00:00
|
|
|
|
|
|
|
/* Get the buffer and compare it */
|
|
|
|
cmp (I, em_map (I), PAGE_SIZE, I);
|
|
|
|
|
|
|
|
/* Keep the user happy */
|
2002-12-06 21:55:56 +00:00
|
|
|
gotoxy (X, Y);
|
|
|
|
cputhex16 (I);
|
|
|
|
}
|
|
|
|
|
2005-11-20 13:31:42 +00:00
|
|
|
/* TEST #2: em_copyfrom/em_copyto. */
|
2002-12-09 12:22:48 +00:00
|
|
|
cputs ("\r\nTesting em_copyfrom/em_copyto");
|
|
|
|
|
|
|
|
/* We're filling now 384 bytes per run to test the copy routines with
|
2014-06-30 09:10:35 +00:00
|
|
|
** other sizes.
|
|
|
|
*/
|
2002-12-09 12:22:48 +00:00
|
|
|
PageCount = (PageCount * 2) / 3;
|
|
|
|
|
2002-12-06 21:55:56 +00:00
|
|
|
/* Setup the copy structure */
|
|
|
|
c.buf = buf;
|
|
|
|
c.count = sizeof (buf);
|
|
|
|
|
|
|
|
/* Fill again all pages */
|
2002-12-09 12:22:48 +00:00
|
|
|
cputs ("\r\n Filling ");
|
2002-12-06 21:55:56 +00:00
|
|
|
X = wherex ();
|
|
|
|
Y = wherey ();
|
2002-12-09 12:22:48 +00:00
|
|
|
c.page = 0;
|
|
|
|
c.offs = 0;
|
2002-12-06 21:55:56 +00:00
|
|
|
for (I = 0; I < PageCount; ++I) {
|
2002-12-09 12:22:48 +00:00
|
|
|
|
|
|
|
/* Fill the buffer and copy it to em */
|
|
|
|
fill (buf, BUF_SIZE, I ^ 0xFFFF);
|
2002-12-06 21:55:56 +00:00
|
|
|
em_copyto (&c);
|
2002-12-09 12:22:48 +00:00
|
|
|
|
|
|
|
/* Adjust the em offset */
|
|
|
|
Offs = c.offs + sizeof (buf);
|
|
|
|
c.offs = (unsigned char) Offs;
|
|
|
|
c.page += (Offs >> 8);
|
|
|
|
|
|
|
|
/* Keep the user happy */
|
2002-12-06 21:55:56 +00:00
|
|
|
gotoxy (X, Y);
|
|
|
|
cputhex16 (I);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if FORCE_ERROR2
|
|
|
|
c.page = 0x03;
|
|
|
|
em_copyfrom (&c);
|
|
|
|
buf[0x73] = 0xFFFF;
|
|
|
|
em_copyto (&c);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Check all pages */
|
2002-12-09 12:22:48 +00:00
|
|
|
cputs ("\r\n Comparing ");
|
2002-12-06 21:55:56 +00:00
|
|
|
X = wherex ();
|
|
|
|
Y = wherey ();
|
2002-12-09 12:22:48 +00:00
|
|
|
c.page = 0;
|
|
|
|
c.offs = 0;
|
2002-12-06 21:55:56 +00:00
|
|
|
for (I = 0; I < PageCount; ++I) {
|
2002-12-09 12:22:48 +00:00
|
|
|
|
|
|
|
/* Get the buffer and compare it */
|
2002-12-06 21:55:56 +00:00
|
|
|
em_copyfrom (&c);
|
2002-12-09 12:22:48 +00:00
|
|
|
cmp (I, buf, BUF_SIZE, I ^ 0xFFFF);
|
|
|
|
|
|
|
|
/* Adjust the em offset */
|
|
|
|
Offs = c.offs + sizeof (buf);
|
|
|
|
c.offs = (unsigned char) Offs;
|
|
|
|
c.page += (Offs >> 8);
|
|
|
|
|
|
|
|
/* Keep the user happy */
|
2002-12-06 21:55:56 +00:00
|
|
|
gotoxy (X, Y);
|
|
|
|
cputhex16 (I);
|
|
|
|
}
|
|
|
|
|
2002-12-09 12:22:48 +00:00
|
|
|
/* Success */
|
|
|
|
cprintf ("\r\nPassed!\r\n");
|
2002-12-06 21:55:56 +00:00
|
|
|
|
2013-08-27 20:01:19 +00:00
|
|
|
#ifdef __ATARI__
|
|
|
|
cgetc ();
|
|
|
|
#endif
|
|
|
|
|
2002-12-06 21:55:56 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|