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