10 #define FORCE_ERROR2 0
13 #define PAGE_SIZE 128 /* Size in words */
14 #define BUF_SIZE (PAGE_SIZE + PAGE_SIZE/2)
15 static unsigned buf[BUF_SIZE];
19 static void cleanup (void)
20 /* Remove the driver on exit */
27 static void fill (register unsigned* page, register unsigned char count, register unsigned num)
29 register unsigned char i;
30 for (i = 0; i < count; ++i, ++page) {
37 static void cmp (unsigned page, register const unsigned* buf,
38 register unsigned char count, register unsigned num)
40 register unsigned char i;
41 for (i = 0; i < count; ++i, ++buf) {
43 cprintf ("\r\nData mismatch in page $%04X at $%04X\r\n"
44 "Data is $%04X (should be $%04X)\r\n",
45 page, buf, *buf, num);
63 Res = em_load_driver ("c64-ram.emd");
64 if (Res != EM_ERR_OK) {
65 cprintf ("Error in em_load_driver: %u\r\n", Res);
66 cprintf ("os: %u, %s\r\n", _oserror, _stroserror (_oserror));
71 /* Get the number of available pages */
72 PageCount = em_pagecount ();
73 cprintf ("Loaded ok, page count = $%04X\r\n", PageCount);
75 /* TEST #1: em_map/em_use/em_commit */
76 cputs ("Testing em_map/em_use/em_commit");
79 cputs ("\r\n Filling ");
82 for (I = 0; I < PageCount; ++I) {
84 /* Fill the buffer and copy it to em */
85 fill (em_use (I), PAGE_SIZE, I);
88 /* Keep the user happy */
94 ((unsigned*) em_map (0x03))[0x73] = 0xFFFF;
99 cputs ("\r\n Comparing ");
102 for (I = 0; I < PageCount; ++I) {
104 /* Get the buffer and compare it */
105 cmp (I, em_map (I), PAGE_SIZE, I);
107 /* Keep the user happy */
112 /* TEST #2: em_copyfrom/em_copyto. */
113 cputs ("\r\nTesting em_copyfrom/em_copyto");
115 /* We're filling now 384 bytes per run to test the copy routines with
118 PageCount = (PageCount * 2) / 3;
120 /* Setup the copy structure */
122 c.count = sizeof (buf);
124 /* Fill again all pages */
125 cputs ("\r\n Filling ");
130 for (I = 0; I < PageCount; ++I) {
132 /* Fill the buffer and copy it to em */
133 fill (buf, BUF_SIZE, I ^ 0xFFFF);
136 /* Adjust the em offset */
137 Offs = c.offs + sizeof (buf);
138 c.offs = (unsigned char) Offs;
139 c.page += (Offs >> 8);
141 /* Keep the user happy */
153 /* Check all pages */
154 cputs ("\r\n Comparing ");
159 for (I = 0; I < PageCount; ++I) {
161 /* Get the buffer and compare it */
163 cmp (I, buf, BUF_SIZE, I ^ 0xFFFF);
165 /* Adjust the em offset */
166 Offs = c.offs + sizeof (buf);
167 c.offs = (unsigned char) Offs;
168 c.page += (Offs >> 8);
170 /* Keep the user happy */
176 cprintf ("\r\nPassed!\r\n");