]> cloudbase.mooo.com Git - z180-stamp.git/blame - avr/z180-serv.c
bugfix integer promotion. increase size of message fifos to 64
[z180-stamp.git] / avr / z180-serv.c
CommitLineData
35edb766
L
1/*
2 * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
72f58822 7#include "common.h"
5f7f3586
L
8#include <stdlib.h>
9#include <string.h>
10#include <stdbool.h>
89adce76 11#include <util/atomic.h>
72f58822 12
89adce76 13#include "background.h"
5f7f3586
L
14#include "env.h"
15#include "ff.h"
72f58822
L
16#include "serial.h"
17#include "z80-if.h"
889202c4 18#include "debug.h"
5f7f3586 19#include "print-utils.h"
89adce76 20#include "z180-serv.h"
daacc6f9 21#include "timer.h"
845cbdbd
L
22#include "time.h"
23#include "bcd.h"
24#include "rtc.h"
7d60b20b
L
25
26#define DEBUG_CPM_SDIO 0 /* set to 1 to debug */
27
28#define debug_cpmsd(fmt, args...) \
29 debug_cond(DEBUG_CPM_SDIO, fmt, ##args)
30
31
32
72f58822
L
33/*--------------------------------------------------------------------------*/
34
72f58822
L
35
36uint8_t z80_get_byte(uint32_t adr)
37{
38 uint8_t data;
8a7decea 39
62f624d3 40 z80_bus_cmd(Request);
89adce76 41 data = z80_read(adr);
62f624d3 42 z80_bus_cmd(Release);
8a7decea 43
72f58822
L
44 return data;
45}
46
47
48/*--------------------------------------------------------------------------*/
49
50struct msg_item {
51 uint8_t fct;
52 uint8_t sub_min, sub_max;
53 void (*func)(uint8_t, int, uint8_t *);
54};
55
56uint32_t msg_to_addr(uint8_t *msg)
57{
58 union {
59 uint32_t as32;
60 uint8_t as8[4];
61 } addr;
62
63 addr.as8[0] = msg[0];
64 addr.as8[1] = msg[1];
65 addr.as8[2] = msg[2];
66 addr.as8[3] = 0;
67
68 return addr.as32;
69}
70
72f58822 71
1a2460dc
L
72static int msg_xmit_header(uint8_t func, uint8_t subf, int len)
73{
74 z80_memfifo_putc(fifo_msgout, 0xAE);
75 z80_memfifo_putc(fifo_msgout, len+2);
76 z80_memfifo_putc(fifo_msgout, func);
77 z80_memfifo_putc(fifo_msgout, subf);
78
79 return 0;
80}
81
82int msg_xmit(uint8_t func, uint8_t subf, int len, uint8_t *msg)
83{
84 msg_xmit_header(func, subf, len);
85 while (len--)
86 z80_memfifo_putc(fifo_msgout, *msg++);
87
88 return 0;
89}
90
72f58822
L
91void do_msg_ini_memfifo(uint8_t subf, int len, uint8_t * msg)
92{
93 (void)len;
94
89adce76 95 z80_memfifo_init(subf, msg_to_addr(msg));
72f58822
L
96}
97
98
99void do_msg_char_out(uint8_t subf, int len, uint8_t * msg)
100{
101 (void)subf;
102
103 while (len--)
104 putchar(*msg++);
105}
106
1a2460dc
L
107/* echo message */
108void do_msg_echo(uint8_t subf, int len, uint8_t * msg)
109{
110 (void)subf;
111
112 /* send re-echo */
113 msg_xmit(1, 3, len, msg);
114}
115
8590a76b
L
116/* get timer */
117void do_msg_get_timer(uint8_t subf, int len, uint8_t * msg)
118{
a8eb521f 119 uint32_t time_ms = (len >= 4) ? *(uint32_t *) msg : 0;
8590a76b 120
a8eb521f 121 time_ms = get_timer(time_ms);
8590a76b
L
122 msg_xmit(3, subf, sizeof(time_ms), (uint8_t *) &time_ms);
123}
124
5f7f3586
L
125/* ---------------------------------------------------------------------------*/
126
845cbdbd
L
127#define CPM_DAY_OFFSET ((1978-1900) * 365 + 19) /* 19 leap years */
128
129/*
130 * Convert CP/M time stamp to a broken-down time structure
131 *
132 */
133int mk_date_time (int len, uint8_t *msg, struct tm *tmp)
134{
135 time_t stamp;
136
137 if (len != 5)
138 return -1;
139
140 /* days since 2000-01-01 */
141 long days = msg[3] + (msg[4] << 8) - 8036;
142
143 if (days < 0)
144 return -1;
145
146 stamp = days * ONE_DAY;
147 stamp += bcd2bin(msg[0]);
148 stamp += bcd2bin(msg[1]) * 60 ;
8d0fad4c 149 stamp += bcd2bin(msg[2]) * 3600L;
845cbdbd
L
150 gmtime_r(&stamp, tmp);
151 return 0;
152}
153
154void mk_cpm_time(struct tm *tmp, uint8_t cpm_time[5])
155{
156 uint16_t days = 1;
157 uint_fast8_t leap=2;
158
159 for (int year=78; year < tmp->tm_year; year++) {
160 days = days + 365 + (leap == 0);
161 leap = (leap+1)%4;
162 }
163 days += tmp->tm_yday;
164
165 cpm_time[0] = bin2bcd(tmp->tm_sec);
166 cpm_time[1] = bin2bcd(tmp->tm_min);
167 cpm_time[2] = bin2bcd(tmp->tm_hour);
168 cpm_time[3] = days;
169 cpm_time[4] = days >> 8;
845cbdbd
L
170}
171
172/* get/set cp/m time */
173void do_msg_get_set_time(uint8_t subf, int len, uint8_t * msg)
174{
175 struct tm t;
176 uint8_t cpm_time[5];
177 int rc;
178
179 memset(cpm_time, 0, ARRAY_SIZE(cpm_time));
180
181 switch (subf) {
182 case 3: /* set date & time */
183 /* initialize t with current time */
184 rc = rtc_get (&t);
185
186 if (rc == 0) {
187 /* insert new date & time */
188 if (mk_date_time (len, msg, &t) != 0) {
189 my_puts_P(PSTR("## set_time: Bad date format\n"));
190 break;
191 }
192
193 time_t time;
194 time = mk_gmtime(&t);
195 gmtime_r(&time, &t);
196
197 /* and write to RTC */
198 rc = rtc_set (&t);
199 if(rc)
200 my_puts_P(PSTR("## set_time: Set date failed\n"));
201 } else {
202 my_puts_P(PSTR("## set_time: Get date failed\n"));
203 }
204 /* FALL TROUGH */
205 case 2: /* get date & time */
206 rc = rtc_get (&t);
207
208 if (rc) {
209 my_puts_P(PSTR("## get_time: Get date failed\n"));
210 break;
211 }
212
213 time_t time;
214 time = mk_gmtime(&t);
215 //mktime(&t);
216 gmtime_r(&time, &t);
217
218
219 mk_cpm_time(&t, cpm_time);
220 break;
221 }
222
223 msg_xmit(3, subf, sizeof(cpm_time), cpm_time);
224}
225
226/* ---------------------------------------------------------------------------*/
227
01484095 228#define MAX_DRIVE 4
5f7f3586 229#define BLOCK_SIZE 512
daacc6f9
L
230#define TPA_BASE 0x10000
231#define COMMON_BASE 0xC000
5f7f3586
L
232
233struct cpm_drive_s {
234 uint8_t drv;
235 uint8_t device;
236 char *img_name;
393b1897 237 bool dirty;
5f7f3586
L
238 FIL fd;
239};
240
241static uint8_t disk_buffer[BLOCK_SIZE];
5f7f3586 242static struct cpm_drive_s drv_table[MAX_DRIVE];
393b1897
L
243static int handle_cpm_drv_to;
244
245#define f_dirty(fp) ((fp)->fs->wflag != 0)
246
247
248int cpm_drv_to(int state)
249{
250 static uint32_t ts;
251
252 switch(state) {
253 case 0:
254 break;
255
256 case 1:
257 ts = get_timer(0);
258 state = 2;
259 break;
260
261 case 2:
262 if (get_timer(ts) > 1000) {
263 for (uint_fast8_t i=0; i < MAX_DRIVE; i++) {
264// if (&drv_table[i].fd && f_dirty(&drv_table[i].fd)) {
265 if (drv_table[i].dirty) {
266 f_sync(&drv_table[i].fd);
267 drv_table[i].dirty = false;
268 debug_cpmsd("## %7lu f_sync: %c:\n", get_timer(0), i+'A');
269 }
270 }
271 state = 0;
272 }
273 }
274 return state;
275}
276
277
278void msg_cpm_result(uint8_t subf, uint8_t rc, int res)
279{
280 uint8_t result_msg[3];
281
282 if (res)
283 rc |= 0x80;
284
285 result_msg[0] = rc;
286 result_msg[1] = res;
287 result_msg[2] = res >> 8;
288
289 if (rc) {
290 debug_cpmsd("###%7lu error rc: %.02x, res: %d\n", get_timer(0), rc, res);
291 }
292
293 msg_xmit(2, subf, sizeof(result_msg), result_msg);
294}
5f7f3586
L
295
296/*
297 db 2 ; disk command
298 ds 1 ; subcommand (login/read/write)
299 ds 1 ; @adrv (8 bits) +0
300 ds 1 ; @rdrv (8 bits) +1
301 ds 3 ; @xdph (24 bits) +2
302*/
303
304void do_msg_cpm_login(uint8_t subf, int len, uint8_t * msg)
305{
306
307 FRESULT res = 0;
5f7f3586
L
308 uint8_t drv;
309 char *np;
5f7f3586
L
310
311 (void)subf;
312
313 if (len != 5) { /* TODO: check adrv, rdrv */
393b1897 314 return msg_cpm_result(subf, 0x01, res);
5f7f3586
L
315 }
316
7d60b20b 317 debug_cpmsd("\n## %7lu login: %c:\n", get_timer(0), msg[0]+'A');
5f7f3586
L
318
319
320 drv = msg[0];
321 if ( drv>= MAX_DRIVE) {
393b1897 322 return msg_cpm_result(subf, 0x02, res);
5f7f3586
L
323 }
324
5f7f3586
L
325/*
326 uint32_t dph = ((uint32_t)msg[4] << 16) + ((uint16_t)msg[3] << 8) + msg[2];
327*/
328
329 if (drv_table[drv].img_name != NULL) {
7d60b20b 330 debug_cpmsd("## %7lu close: '%s'\n", get_timer(0), drv_table[drv].img_name);
5f7f3586 331 f_close(&drv_table[drv].fd);
393b1897 332 drv_table[drv].dirty = false;
5f7f3586
L
333 free(drv_table[drv].img_name);
334 drv_table[drv].img_name = NULL;
335 }
336
337 strcpy_P((char *)disk_buffer, PSTR("dsk0"));
338 disk_buffer[3] = msg[0] + '0';
339 if (((np = getenv((char*)disk_buffer)) == NULL) ||
340 ((drv_table[drv].img_name = strdup(np)) == NULL)) {
393b1897 341 return msg_cpm_result(subf, 0x03, res);
5f7f3586
L
342 }
343
344
345 res = f_open(&drv_table[drv].fd, drv_table[drv].img_name,
346 FA_WRITE | FA_READ);
347
7d60b20b 348 debug_cpmsd("## %7lu open: '%s', (env: '%s'), res: %d\n", get_timer(0),
5f7f3586
L
349 drv_table[drv].img_name, disk_buffer, res);
350
5f7f3586 351 /* send result*/
393b1897 352 msg_cpm_result(subf, 0x00, res);
5f7f3586
L
353}
354
355
356/*
357 db 2 ; disk command
358 ds 1 ; subcommand (login/read/write)
daacc6f9
L
359 ds 1 ; @adrv (8 bits) +0
360 ds 1 ; @rdrv (8 bits) +1
361 ds 2 ; @trk (16 bits) +2
362 ds 2 ; @sect(16 bits) +4
363 ds 1 ; @cnt (8 bits) +6
5f7f3586
L
364 ds 3 ; phys. transfer addr +7
365*/
366
daacc6f9
L
367#define ADRV 0
368#define RDRV 1
369#define TRK 2
370#define SEC 4
371#define CNT 6
372#define ADDR 7
373
5f7f3586
L
374void do_msg_cpm_rw(uint8_t subf, int len, uint8_t * msg)
375{
376 uint8_t drv;
377 uint32_t addr;
378 uint32_t pos;
7d60b20b 379 uint8_t secs;
5f7f3586
L
380 bool dowrite = (subf == 2);
381 FRESULT res = 0;
382 uint8_t rc = 0;
383 bool buserr = 0;
5f7f3586
L
384
385 if (len != 10) { /* TODO: check adrv, rdrv */
393b1897 386 return msg_cpm_result(subf, 0x01, res);
5f7f3586
L
387 }
388
daacc6f9 389 drv = msg[ADRV];
5f7f3586 390 if ( drv>= MAX_DRIVE) {
393b1897 391 return msg_cpm_result(subf, 0x02, res);
5f7f3586
L
392 }
393
7d60b20b 394 secs = msg[CNT];
daacc6f9 395 addr = ((uint32_t)msg[ADDR+2] << 16) + ((uint16_t)msg[ADDR+1] << 8) + msg[ADDR];
5f7f3586 396
5f7f3586 397
daacc6f9
L
398 /* TODO: tracks per sector from dpb */
399 pos = (((uint16_t)(msg[TRK+1] << 8) + msg[TRK]) * 8
400 + ((uint32_t)(msg[SEC+1] << 8) + msg[SEC])) * BLOCK_SIZE;
5f7f3586 401
7d60b20b
L
402 debug_cpmsd("## %7lu cpm_rw: %s %c: trk:%4d, sec: %d, pos: %.8lx, secs: %2d, "
403 "addr: %.5lx\n", get_timer(0), dowrite ? "write" : " read",
404 msg[ADRV]+'A', ((uint16_t)(msg[TRK+1] << 8) + msg[TRK]), msg[SEC],
405 pos, msg[CNT], addr);
5f7f3586
L
406
407 res = f_lseek(&drv_table[drv].fd, pos);
7d60b20b 408 while (!res && secs--) {
daacc6f9
L
409 unsigned int cnt, br;
410
7d60b20b
L
411 /* check bank boundary crossing */
412 cnt = 0;
daacc6f9 413 if (addr < (TPA_BASE + COMMON_BASE) &&
7d60b20b 414 (addr + BLOCK_SIZE) > (TPA_BASE + COMMON_BASE)) {
daacc6f9 415 cnt = (TPA_BASE + COMMON_BASE) - addr;
daacc6f9
L
416 }
417
7d60b20b
L
418 if (cnt) {
419 debug_cpmsd("## %67c addr: %.5lx, cnt: %3d\n", ' ', addr, cnt);
420 debug_cpmsd("## %67c addr: %.5lx, cnt: %3d\n", ' ', addr+cnt-TPA_BASE, BLOCK_SIZE-cnt);
421 }
5f7f3586
L
422
423 if (dowrite) {
424 if (!(z80_bus_cmd(Request) & ZST_ACQUIRED)) {
425 buserr = 1;
7d60b20b 426 break;
5f7f3586 427 } else {
7d60b20b
L
428 if (cnt) {
429 z80_read_block(disk_buffer, addr, cnt);
430 addr = addr + cnt - TPA_BASE;
431 }
432 z80_read_block(disk_buffer+cnt, addr, BLOCK_SIZE - cnt);
5f7f3586 433 z80_bus_cmd(Release);
5f7f3586 434 }
7d60b20b 435 res = f_write(&drv_table[drv].fd, disk_buffer, BLOCK_SIZE, &br);
5f7f3586 436 } else {
7d60b20b
L
437 res = f_read(&drv_table[drv].fd, disk_buffer, BLOCK_SIZE, &br);
438 if (res == FR_OK && br == BLOCK_SIZE) {
5f7f3586
L
439 if (!(z80_bus_cmd(Request) & ZST_ACQUIRED)) {
440 buserr = 1;
7d60b20b 441 break;
5f7f3586 442 } else {
7d60b20b
L
443 if (cnt) {
444 z80_write_block(disk_buffer, addr, cnt);
445 addr = addr + cnt - TPA_BASE;
446 }
447 z80_write_block(disk_buffer+cnt, addr, BLOCK_SIZE - cnt);
5f7f3586
L
448 z80_bus_cmd(Release);
449 }
450 }
451 }
452
7d60b20b
L
453 if (br != BLOCK_SIZE) {
454 debug_cpmsd("## %7lu f_read res: %d, bytes rd/wr: %u\n", get_timer(0), res, br);
5f7f3586
L
455 dump_ram(disk_buffer, 0, 64, "Read Data");
456 res = -1;
457 }
daacc6f9 458
7d60b20b 459 addr += BLOCK_SIZE;
5f7f3586
L
460 }
461
393b1897
L
462 if (dowrite && !res) {
463// res = f_sync(&drv_table[drv].fd);
464 drv_table[drv].dirty = true;
465 bg_setstat(handle_cpm_drv_to, 1);
466 }
467
daacc6f9 468
5f7f3586 469 if (buserr) {
7d60b20b 470 debug_cpmsd("Bus timeout\n");
5f7f3586
L
471 rc = 0x03;
472 }
5f7f3586
L
473
474 /* send result*/
393b1897 475 msg_cpm_result(subf, rc, res);
5f7f3586
L
476}
477
72f58822
L
478
479const FLASH struct msg_item z80_messages[] =
480{
481 { 0, /* fct nr. */
89adce76 482 1, 3, /* sub fct nr. from, to */
72f58822
L
483 do_msg_ini_memfifo},
484 { 1,
485 1, 1,
486 do_msg_char_out},
1a2460dc
L
487 { 1,
488 2, 2,
489 do_msg_echo},
5f7f3586
L
490 { 2,
491 0, 0,
492 do_msg_cpm_login},
493 { 2,
494 1, 2,
495 do_msg_cpm_rw},
8590a76b
L
496 { 3,
497 1, 1,
498 do_msg_get_timer},
845cbdbd
L
499 { 3,
500 2, 3, /* 2: get, 3: set time and date */
501 do_msg_get_set_time},
72f58822
L
502 { 0xff, /* end mark */
503 0, 0,
504 0},
505
506};
507
508
509
510
511void do_message(int len, uint8_t *msg)
512{
513 uint8_t fct, sub_fct;
514 int_fast8_t i = 0;
515
516 if (len >= 2) {
517 fct = *msg++;
518 sub_fct = *msg++;
519 len -= 2;
520
89adce76
L
521 while (fct != z80_messages[i].fct) {
522 if (z80_messages[i].fct == 0xff) {
523 DBG_P(1, "do_message: Unknown function: %i, %i\n",
524 fct, sub_fct);
525 return; /* TODO: unknown message # */
526 }
8a7decea 527
72f58822 528 ++i;
72f58822
L
529 }
530
531 while (fct == z80_messages[i].fct) {
8a7decea 532 if (sub_fct >= z80_messages[i].sub_min &&
89adce76 533 sub_fct <= z80_messages[i].sub_max )
72f58822
L
534 break;
535 ++i;
536 }
537
538 if (z80_messages[i].fct != fct) {
539 DBG_P(1, "do_message: Unknown sub function: %i, %i\n",
540 fct, sub_fct);
541 return; /* TODO: unknown message sub# */
542 }
543
544 (z80_messages[i].func)(sub_fct, len, msg);
545
546
547 } else {
548 /* TODO: error */
549 DBG_P(1, "do_message: to few arguments (%i); this shouldn't happen!\n", len);
550 }
551}
552
553
554
555#define CTRBUF_LEN 256
556
557void check_msg_fifo(void)
558{
559 int ch;
560 static int_fast8_t state;
561 static int msglen,idx;
562 static uint8_t buffer[CTRBUF_LEN];
563
89adce76 564 while ((ch = z80_memfifo_getc(fifo_msgin)) >= 0) {
72f58822
L
565 switch (state) {
566 case 0: /* wait for start of message */
3531528e 567 if (ch == 0xAE) { /* TODO: magic number */
72f58822
L
568 msglen = 0;
569 idx = 0;
570 state = 1;
571 }
572 break;
573 case 1: /* get msg len */
574 if (ch > 0 && ch <= CTRBUF_LEN) {
575 msglen = ch;
576 state = 2;
577 } else
578 state = 0;
579 break;
580 case 2: /* get message */
581 buffer[idx++] = ch;
89adce76
L
582 if (idx == msglen) {
583 do_message(msglen, buffer);
584 state = 0;
585 }
586 break;
587 }
588 }
589}
590
591
592int msg_handling(int state)
593{
594 uint8_t pending;
8a7decea
L
595
596 ATOMIC_BLOCK(ATOMIC_FORCEON) {
89adce76
L
597 pending = (Stat & S_MSG_PENDING) != 0;
598 Stat &= ~S_MSG_PENDING;
599 }
ad9bc17c
L
600/*
601 * TODO: if pending but no message chr --> special condition. ie init,...
602 */
8a7decea 603
89adce76
L
604 if (pending) {
605 switch (state) {
1a2460dc 606 case 0: /* need init */
cdc4625b 607 /* Get address of fifo_list */
89adce76 608 z80_bus_cmd(Request);
cdc4625b 609 uint32_t fifo_list = z80_read(0x40) +
89adce76
L
610 ((uint16_t) z80_read(0x41) << 8) +
611 ((uint32_t) z80_read(0x42) << 16);
612 z80_bus_cmd(Release);
cdc4625b
L
613 if (fifo_list != 0) {
614 /* Get address of fifo 0 */
615 z80_bus_cmd(Request);
616 uint32_t fifo_addr = z80_read(fifo_list) +
617 ((uint16_t) z80_read(fifo_list+1) << 8) +
618 ((uint32_t) z80_read(fifo_list+2) << 16);
619 z80_bus_cmd(Release);
620 if (fifo_addr != 0) {
621 z80_memfifo_init(fifo_msgin, fifo_addr);
622 state = 1;
623 }
89adce76
L
624 }
625 break;
1a2460dc 626 case 1: /* awaiting messages */
89adce76 627 check_msg_fifo();
72f58822
L
628 break;
629 }
630 }
631
89adce76
L
632 return state;
633}
89adce76
L
634
635
636static int handle_msg_handling;
637
638void setup_z180_serv(void)
639{
8a7decea 640
89adce76 641 handle_msg_handling = bg_register(msg_handling, 0);
393b1897 642 handle_cpm_drv_to = bg_register(cpm_drv_to, 0);
72f58822
L
643}
644
89adce76
L
645void restart_z180_serv(void)
646{
647 z80_bus_cmd(Request);
648 z80_write(0x40, 0);
649 z80_write(0x41, 0);
650 z80_write(0x42, 0);
651 z80_bus_cmd(Release);
8a7decea
L
652
653 for (int i = 0; i < NUM_FIFOS; i++)
654 z80_memfifo_init(i, 0);
89adce76 655 bg_setstat(handle_msg_handling, 0);
5f7f3586 656
89adce76 657}
72f58822 658
845cbdbd 659#if 0
72f58822
L
660/*--------------------------------------------------------------------------*/
661
72f58822
L
662const FLASH uint8_t iniprog[] = {
663 0xAF, // xor a
664 0xED, 0x39, 0x36, // out0 (rcr),a ;disable DRAM refresh
665 0x3E, 0x30, // ld a,030h
666 0xED, 0x39, 0x32 //out0 (dcntl),a ;0 mem, max i/0 wait states
667};
668
669const FLASH uint8_t sertest[] = {
670 0xAF, // xor a
671 0xED, 0x39, 0x36, // out0 (rcr),a ;disable DRAM refresh
672 0x3E, 0x30, // ld a,030h
673 0xED, 0x39, 0x32, // out0 (dcntl),a ;0 mem, max i/0 wait states
674 0x3E, 0x80, // ld a,M_MPBT ;no MP, PS=10, DR=16, SS=0
675 0xED, 0x39, 0x03, // out0 (cntlb1),a
676 0x3E, 0x64, // ld a,M_RE + M_TE + M_MOD2 ;
677 0xED, 0x39, 0x01, // out0 (cntla1),a
678 0x3E, 0x00, // ld a,0
679 0xED, 0x39, 0x05, // out0 (stat1),a ;Enable rx interrupts
680 0xED, 0x38, 0x05, //l0:in0 a,(stat1)
681 0xE6, 0x80, // and 80h
682 0x28, 0xF9, // jr z,l0
683 0xED, 0x00, 0x09, // in0 b,(rdr1)
684 0xED, 0x38, 0x05, //l1:in0 a,(stat1)
685 0xE6, 0x02, // and 02h
686 0x28, 0xF9, // jr z,l1
687 0xED, 0x01, 0x07, // out0 (tdr1),b
688 0x18, 0xEA, // jr l0
689};
690
691const FLASH uint8_t test1[] = {
692 0xAF, // xor a
693 0xED, 0x39, 0x36, // out0 (rcr),a ;disable DRAM refresh
694 0x3E, 0x30, // ld a,030h
695 0xED, 0x39, 0x32, // out0 (dcntl),a ;0 mem, max i/0 wait states
696 0x21, 0x1E, 0x00, // ld hl,dmclrt ;load DMA registers
697 0x06, 0x08, // ld b,dmct_e-dmclrt
698 0x0E, 0x20, // ld c,sar0l
8a7decea 699 0xED, 0x93, // otimr
72f58822
L
700 0x3E, 0xC3, // ld a,0c3h ;dst +1, src +1, burst
701 0xED, 0x39, 0x31, // out0 (dmode),a ;
8a7decea 702 0x3E, 0x62, // ld a,062h ;enable dma0,
72f58822
L
703 0xED, 0x39, 0x30, //cl_1: out0 (dstat),a ;copy 64k
704 0x18, 0xFB, // jr cl_1 ;
8a7decea 705 0x00, 0x00, //dmclrt: dw 0 ;src (inc)
72f58822
L
706 0x00, // db 0 ;src
707 0x00, 0x00, // dw 0 ;dst (inc),
708 0x00, // db 0 ;dst
709 0x00, 0x00, // dw 0 ;count (64k)
710};
845cbdbd 711#endif