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 fill (register unsigned* page, register unsigned char count, register unsigned num)
21 register unsigned char i;
22 for (i = 0; i < count; ++i, ++page) {
29 static void cmp (unsigned page, register const unsigned* buf,
30 register unsigned char count, register unsigned num)
32 register unsigned char i;
33 for (i = 0; i < count; ++i, ++buf) {
35 cprintf ("\r\nData mismatch in page $%04X at $%04X\r\n"
36 "Data is $%04X (should be $%04X)\r\n",
37 page, buf, *buf, num);
55 Res = em_load_driver ("c64-ram.emd");
56 if (Res != EM_ERR_OK) {
57 cprintf ("Error in em_load_driver: %u\r\n", Res);
58 cprintf ("os: %u, %s\r\n", _oserror, _stroserror (_oserror));
62 /* Get the number of available pages */
63 PageCount = em_pagecount ();
64 cprintf ("Loaded ok, page count = $%04X\r\n", PageCount);
66 /* TEST #1: em_map/em_use/em_commit */
67 cputs ("Testing em_map/em_use/em_commit");
70 cputs ("\r\n Filling ");
73 for (I = 0; I < PageCount; ++I) {
75 /* Fill the buffer and copy it to em */
76 fill (em_use (I), PAGE_SIZE, I);
79 /* Keep the user happy */
85 ((unsigned*) em_map (0x03))[0x73] = 0xFFFF;
90 cputs ("\r\n Comparing ");
93 for (I = 0; I < PageCount; ++I) {
95 /* Get the buffer and compare it */
96 cmp (I, em_map (I), PAGE_SIZE, I);
98 /* Keep the user happy */
103 /* TEST #1: em_copyfrom/em_copyto. */
104 cputs ("\r\nTesting em_copyfrom/em_copyto");
106 /* We're filling now 384 bytes per run to test the copy routines with
109 PageCount = (PageCount * 2) / 3;
111 /* Setup the copy structure */
113 c.count = sizeof (buf);
115 /* Fill again all pages */
116 cputs ("\r\n Filling ");
121 for (I = 0; I < PageCount; ++I) {
123 /* Fill the buffer and copy it to em */
124 fill (buf, BUF_SIZE, I ^ 0xFFFF);
127 /* Adjust the em offset */
128 Offs = c.offs + sizeof (buf);
129 c.offs = (unsigned char) Offs;
130 c.page += (Offs >> 8);
132 /* Keep the user happy */
144 /* Check all pages */
145 cputs ("\r\n Comparing ");
150 for (I = 0; I < PageCount; ++I) {
152 /* Get the buffer and compare it */
154 cmp (I, buf, BUF_SIZE, I ^ 0xFFFF);
156 /* Adjust the em offset */
157 Offs = c.offs + sizeof (buf);
158 c.offs = (unsigned char) Offs;
159 c.page += (Offs >> 8);
161 /* Keep the user happy */
167 cprintf ("\r\nPassed!\r\n");