ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/Frodo4/Src/IEC.cpp
Revision: 1.3
Committed: 2004-01-11T00:09:51Z (20 years, 3 months ago) by cebix
Branch: MAIN
Changes since 1.2: +448 -18 lines
Log Message:
some cleanups and refactoring

File Contents

# Content
1 /*
2 * IEC.cpp - IEC bus routines, 1541 emulation (DOS level)
3 *
4 * Frodo (C) 1994-1997,2002-2003 Christian Bauer
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21 /*
22 * Notes:
23 * ------
24 *
25 * - There are three kinds of devices on the IEC bus: controllers,
26 * listeners and talkers. We are always the controller and we
27 * can additionally be either listener or talker. There can be
28 * only one listener and one talker active at the same time (the
29 * real IEC bus allows multiple listeners, but we don't).
30 * - There is one Drive object for every emulated drive (8..11).
31 * A pointer to one of them is stored in "listener"/"talker"
32 * when talk()/listen() is called and is used by the functions
33 * called afterwards.
34 * - The Drive objects have four virtual functions so that the
35 * interface to them is independent of their implementation:
36 * Open() opens a channel
37 * Close() closes a channel
38 * Read() reads from a channel
39 * Write() writes to a channel
40 * - The EOI/EOF signal is special on the IEC bus in that it is
41 * Sent before the last byte, not after it.
42 */
43
44 #include "sysdeps.h"
45
46 #include "IEC.h"
47 #include "1541fs.h"
48 #include "1541d64.h"
49 #include "1541t64.h"
50 #include "Prefs.h"
51 #include "Display.h"
52
53
54 /*
55 * Constructor: Initialize variables
56 */
57
58 IEC::IEC(C64Display *display) : the_display(display)
59 {
60 int i;
61
62 // Create drives 8..11
63 for (i=0; i<4; i++)
64 drive[i] = NULL; // Important because UpdateLEDs is called from the drive constructors (via set_error)
65
66 if (!ThePrefs.Emul1541Proc)
67 for (i=0; i<4; i++) {
68 if (ThePrefs.DriveType[i] == DRVTYPE_DIR)
69 drive[i] = new FSDrive(this, ThePrefs.DrivePath[i]);
70 else if (ThePrefs.DriveType[i] == DRVTYPE_D64)
71 drive[i] = new D64Drive(this, ThePrefs.DrivePath[i]);
72 else
73 drive[i] = new T64Drive(this, ThePrefs.DrivePath[i]);
74 }
75
76 listener_active = talker_active = false;
77 listening = false;
78 }
79
80
81 /*
82 * Destructor: Delete drives
83 */
84
85 IEC::~IEC()
86 {
87 for (int i=0; i<4; i++)
88 delete drive[i];
89 }
90
91
92 /*
93 * Reset all drives
94 */
95
96 void IEC::Reset(void)
97 {
98 for (int i=0; i<4; i++)
99 if (drive[i] != NULL && drive[i]->Ready)
100 drive[i]->Reset();
101
102 UpdateLEDs();
103 }
104
105
106 /*
107 * Preferences have changed, prefs points to new preferences,
108 * ThePrefs still holds the previous ones. Check if drive settings
109 * have changed.
110 */
111
112 void IEC::NewPrefs(Prefs *prefs)
113 {
114 // Delete and recreate all changed drives
115 for (int i=0; i<4; i++)
116 if ((ThePrefs.DriveType[i] != prefs->DriveType[i]) || strcmp(ThePrefs.DrivePath[i], prefs->DrivePath[i]) || ThePrefs.Emul1541Proc != prefs->Emul1541Proc) {
117 delete drive[i];
118 drive[i] = NULL; // Important because UpdateLEDs is called from drive constructors (via set_error())
119 if (!prefs->Emul1541Proc) {
120 if (prefs->DriveType[i] == DRVTYPE_DIR)
121 drive[i] = new FSDrive(this, prefs->DrivePath[i]);
122 else if (prefs->DriveType[i] == DRVTYPE_D64)
123 drive[i] = new D64Drive(this, prefs->DrivePath[i]);
124 else
125 drive[i] = new T64Drive(this, prefs->DrivePath[i]);
126 }
127 }
128
129 UpdateLEDs();
130 }
131
132
133 /*
134 * Update drive LED display
135 */
136
137 void IEC::UpdateLEDs(void)
138 {
139 if (drive[0] != NULL && drive[1] != NULL && drive[2] != NULL && drive[3] != NULL)
140 the_display->UpdateLEDs(drive[0]->LED, drive[1]->LED, drive[2]->LED, drive[3]->LED);
141 }
142
143
144 /*
145 * Output one byte
146 */
147
148 uint8 IEC::Out(uint8 byte, bool eoi)
149 {
150 if (listener_active) {
151 if (received_cmd == CMD_OPEN)
152 return open_out(byte, eoi);
153 if (received_cmd == CMD_DATA)
154 return data_out(byte, eoi);
155 return ST_TIMEOUT;
156 } else
157 return ST_TIMEOUT;
158 }
159
160
161 /*
162 * Output one byte with ATN (Talk/Listen/Untalk/Unlisten)
163 */
164
165 uint8 IEC::OutATN(uint8 byte)
166 {
167 received_cmd = sec_addr = 0; // Command is sent with secondary address
168 switch (byte & 0xf0) {
169 case ATN_LISTEN:
170 listening = true;
171 return listen(byte & 0x0f);
172 case ATN_UNLISTEN:
173 listening = false;
174 return unlisten();
175 case ATN_TALK:
176 listening = false;
177 return talk(byte & 0x0f);
178 case ATN_UNTALK:
179 listening = false;
180 return untalk();
181 }
182 return ST_TIMEOUT;
183 }
184
185
186 /*
187 * Output secondary address
188 */
189
190 uint8 IEC::OutSec(uint8 byte)
191 {
192 if (listening) {
193 if (listener_active) {
194 sec_addr = byte & 0x0f;
195 received_cmd = byte & 0xf0;
196 return sec_listen();
197 }
198 } else {
199 if (talker_active) {
200 sec_addr = byte & 0x0f;
201 received_cmd = byte & 0xf0;
202 return sec_talk();
203 }
204 }
205 return ST_TIMEOUT;
206 }
207
208
209 /*
210 * Read one byte
211 */
212
213 uint8 IEC::In(uint8 *byte)
214 {
215 if (talker_active && (received_cmd == CMD_DATA))
216 return data_in(byte);
217
218 *byte = 0;
219 return ST_TIMEOUT;
220 }
221
222
223 /*
224 * Assert ATN (for Untalk)
225 */
226
227 void IEC::SetATN(void)
228 {
229 // Only needed for real IEC
230 }
231
232
233 /*
234 * Release ATN
235 */
236
237 void IEC::RelATN(void)
238 {
239 // Only needed for real IEC
240 }
241
242
243 /*
244 * Talk-attention turn-around
245 */
246
247 void IEC::Turnaround(void)
248 {
249 // Only needed for real IEC
250 }
251
252
253 /*
254 * System line release
255 */
256
257 void IEC::Release(void)
258 {
259 // Only needed for real IEC
260 }
261
262
263 /*
264 * Listen
265 */
266
267 uint8 IEC::listen(int device)
268 {
269 if ((device >= 8) && (device <= 11)) {
270 if ((listener = drive[device-8]) != NULL && listener->Ready) {
271 listener_active = true;
272 return ST_OK;
273 }
274 }
275
276 listener_active = false;
277 return ST_NOTPRESENT;
278 }
279
280
281 /*
282 * Talk
283 */
284
285 uint8 IEC::talk(int device)
286 {
287 if ((device >= 8) && (device <= 11)) {
288 if ((talker = drive[device-8]) != NULL && talker->Ready) {
289 talker_active = true;
290 return ST_OK;
291 }
292 }
293
294 talker_active = false;
295 return ST_NOTPRESENT;
296 }
297
298
299 /*
300 * Unlisten
301 */
302
303 uint8 IEC::unlisten(void)
304 {
305 listener_active = false;
306 return ST_OK;
307 }
308
309
310 /*
311 * Untalk
312 */
313
314 uint8 IEC::untalk(void)
315 {
316 talker_active = false;
317 return ST_OK;
318 }
319
320
321 /*
322 * Secondary address after Listen
323 */
324
325 uint8 IEC::sec_listen(void)
326 {
327 switch (received_cmd) {
328
329 case CMD_OPEN: // Prepare for receiving the file name
330 name_ptr = name_buf;
331 name_len = 0;
332 return ST_OK;
333
334 case CMD_CLOSE: // Close channel
335 if (listener->LED != DRVLED_ERROR) {
336 listener->LED = DRVLED_OFF; // Turn off drive LED
337 UpdateLEDs();
338 }
339 return listener->Close(sec_addr);
340 }
341 return ST_OK;
342 }
343
344
345 /*
346 * Secondary address after Talk
347 */
348
349 uint8 IEC::sec_talk(void)
350 {
351 return ST_OK;
352 }
353
354
355 /*
356 * Byte after Open command: Store character in file name, open file on EOI
357 */
358
359 uint8 IEC::open_out(uint8 byte, bool eoi)
360 {
361 if (name_len < NAMEBUF_LENGTH) {
362 *name_ptr++ = byte;
363 name_len++;
364 }
365
366 if (eoi) {
367 *name_ptr = 0; // End string
368 listener->LED = DRVLED_ON; // Turn on drive LED
369 UpdateLEDs();
370 return listener->Open(sec_addr, name_buf, name_len);
371 }
372
373 return ST_OK;
374 }
375
376
377 /*
378 * Write byte to channel
379 */
380
381 uint8 IEC::data_out(uint8 byte, bool eoi)
382 {
383 return listener->Write(sec_addr, byte, eoi);
384 }
385
386
387 /*
388 * Read byte from channel
389 */
390
391 uint8 IEC::data_in(uint8 *byte)
392 {
393 return talker->Read(sec_addr, byte);
394 }
395
396
397 /*
398 * Drive constructor
399 */
400
401 Drive::Drive(IEC *iec)
402 {
403 the_iec = iec;
404 LED = DRVLED_OFF;
405 Ready = false;
406 set_error(ERR_STARTUP);
407 }
408
409
410 /*
411 * Set error message on drive
412 */
413
414 // 1541 error messages
415 static const char *Errors_1541[] = {
416 "00, OK,%02d,%02d\x0d",
417 "01, FILES SCRATCHED,%02d,%02d\x0d",
418 "03, UNIMPLEMENTED,%02d,%02d\x0d",
419 "20, READ ERROR,%02d,%02d\x0d",
420 "21, READ ERROR,%02d,%02d\x0d",
421 "22, READ ERROR,%02d,%02d\x0d",
422 "23, READ ERROR,%02d,%02d\x0d",
423 "24, READ ERROR,%02d,%02d\x0d",
424 "25, WRITE ERROR,%02d,%02d\x0d",
425 "26, WRITE PROTECT ON,%02d,%02d\x0d",
426 "27, READ ERROR,%02d,%02d\x0d",
427 "28, WRITE ERROR,%02d,%02d\x0d",
428 "29, DISK ID MISMATCH,%02d,%02d\x0d",
429 "30, SYNTAX ERROR,%02d,%02d\x0d",
430 "31, SYNTAX ERROR,%02d,%02d\x0d",
431 "32, SYNTAX ERROR,%02d,%02d\x0d",
432 "33, SYNTAX ERROR,%02d,%02d\x0d",
433 "34, SYNTAX ERROR,%02d,%02d\x0d",
434 "60, WRITE FILE OPEN,%02d,%02d\x0d",
435 "61, FILE NOT OPEN,%02d,%02d\x0d",
436 "62, FILE NOT FOUND,%02d,%02d\x0d",
437 "63, FILE EXISTS,%02d,%02d\x0d",
438 "64, FILE TYPE MISMATCH,%02d,%02d\x0d",
439 "65, NO BLOCK,%02d,%02d\x0d",
440 "66, ILLEGAL TRACK OR SECTOR,%02d,%02d\x0d",
441 "70, NO CHANNEL,%02d,%02d\x0d",
442 "71, DIR ERROR,%02d,%02d\x0d",
443 "72, DISK FULL,%02d,%02d\x0d",
444 "73, CBM DOS V2.6 1541,%02d,%02d\x0d",
445 "74, DRIVE NOT READY,%02d,%02d\x0d"
446 };
447
448 void Drive::set_error(int error, int track, int sector)
449 {
450 // Write error message to buffer
451 sprintf(error_buf, Errors_1541[error], track, sector);
452 error_ptr = error_buf;
453 error_len = strlen(error_buf);
454
455 // Set drive condition
456 if (error != ERR_OK && error != ERR_SCRATCHED)
457 if (error == ERR_STARTUP)
458 LED = DRVLED_OFF;
459 else
460 LED = DRVLED_ERROR;
461 else if (LED == DRVLED_ERROR)
462 LED = DRVLED_OFF;
463 the_iec->UpdateLEDs();
464 }
465
466
467 /*
468 * Parse file name, determine access mode and file type
469 */
470
471 void Drive::parse_file_name(const uint8 *src, int src_len, uint8 *dest, int &dest_len, int &mode, int &type, int &rec_len, bool convert_charset)
472 {
473 // If the string contains a ':', the file name starts after that
474 const uint8 *p = (const uint8 *)memchr(src, ':', src_len);
475 if (p) {
476 p++;
477 src_len -= p - src;
478 } else
479 p = src;
480
481 // Transfer file name upto ','
482 dest_len = 0;
483 uint8 *q = dest;
484 while (*p != ',' && src_len-- > 0) {
485 if (convert_charset)
486 *q++ = petscii2ascii(*p++);
487 else
488 *q++ = *p++;
489 dest_len++;
490 }
491 *q++ = 0;
492
493 // Strip trailing CRs
494 while (dest_len > 0 && dest[dest_len - 1] == 0x0d)
495 dest[--dest_len] = 0;
496
497 // Look for mode and type parameters separated by ','
498 p++; src_len--;
499 while (src_len > 0) {
500 switch (*p) {
501 case 'D':
502 type = FTYPE_DEL;
503 break;
504 case 'S':
505 type = FTYPE_SEQ;
506 break;
507 case 'P':
508 type = FTYPE_PRG;
509 break;
510 case 'U':
511 type = FTYPE_USR;
512 break;
513 case 'L':
514 type = FTYPE_REL;
515 while (*p != ',' && src_len-- > 0) p++;
516 p++; src_len--;
517 rec_len = *p++; src_len--;
518 if (src_len < 0)
519 rec_len = 0;
520 break;
521 case 'R':
522 mode = FMODE_READ;
523 break;
524 case 'W':
525 mode = FMODE_WRITE;
526 break;
527 case 'A':
528 mode = FMODE_APPEND;
529 break;
530 case 'M':
531 mode = FMODE_M;
532 break;
533 }
534
535 // Skip to ','
536 while (*p != ',' && src_len-- > 0) p++;
537 p++; src_len--;
538 }
539 }
540
541
542 /*
543 * Execute DOS command (parse command and call appropriate routine)
544 */
545
546 static void parse_block_cmd_args(const uint8 *p, int &arg1, int &arg2, int &arg3, int &arg4)
547 {
548 arg1 = arg2 = arg3 = arg4 = 0;
549
550 while (*p == ' ' || *p == 0x1d || *p == ',') p++;
551 while (*p >= '0' && *p < '@')
552 arg1 = arg1 * 10 + (*p++ & 0x0f);
553
554 while (*p == ' ' || *p == 0x1d || *p == ',') p++;
555 while (*p >= '0' && *p < '@')
556 arg2 = arg2 * 10 + (*p++ & 0x0f);
557
558 while (*p == ' ' || *p == 0x1d || *p == ',') p++;
559 while (*p >= '0' && *p < '@')
560 arg3 = arg3 * 10 + (*p++ & 0x0f);
561
562 while (*p == ' ' || *p == 0x1d || *p == ',') p++;
563 while (*p >= '0' && *p < '@')
564 arg4 = arg4 * 10 + (*p++ & 0x0f);
565 }
566
567 void Drive::execute_cmd(const uint8 *cmd, int cmd_len)
568 {
569 // Strip trailing CRs
570 while (cmd_len > 0 && cmd[cmd_len - 1] == 0x0d)
571 cmd_len--;
572
573 // Find token delimiters
574 const uint8 *colon = (const uint8 *)memchr(cmd, ':', cmd_len);
575 const uint8 *equal = colon ? (const uint8 *)memchr(colon, '=', cmd_len - (colon - cmd)) : NULL;
576 const uint8 *comma = (const uint8 *)memchr(cmd, ',', cmd_len);
577 const uint8 *minus = (const uint8 *)memchr(cmd, '-', cmd_len);
578
579 // Parse command name
580 set_error(ERR_OK);
581 switch (cmd[0]) {
582 case 'B': // Block/buffer
583 if (!minus)
584 set_error(ERR_SYNTAX31);
585 else {
586 // Parse arguments (up to 4 decimal numbers separated by
587 // space, cursor right or comma)
588 const uint8 *p = colon ? colon + 1 : cmd + 3;
589 int arg1, arg2, arg3, arg4;
590 parse_block_cmd_args(p, arg1, arg2, arg3, arg4);
591
592 // Switch on command
593 switch (minus[1]) {
594 case 'R':
595 block_read_cmd(arg1, arg3, arg4);
596 break;
597 case 'W':
598 block_write_cmd(arg1, arg3, arg4);
599 break;
600 case 'E':
601 block_execute_cmd(arg1, arg3, arg4);
602 break;
603 case 'A':
604 block_allocate_cmd(arg2, arg3);
605 break;
606 case 'F':
607 block_free_cmd(arg2, arg3);
608 break;
609 case 'P':
610 buffer_pointer_cmd(arg1, arg2);
611 break;
612 default:
613 set_error(ERR_SYNTAX31);
614 break;
615 }
616 }
617 break;
618
619 case 'M': // Memory
620 if (cmd[1] != '-')
621 set_error(ERR_SYNTAX31);
622 else {
623 // Read parameters
624 uint16 adr = uint8(cmd[3]) | (uint8(cmd[4]) << 8);
625 uint8 len = uint8(cmd[5]);
626
627 // Switch on command
628 switch (cmd[2]) {
629 case 'R':
630 mem_read_cmd(adr, (cmd_len < 6) ? 1 : len);
631 break;
632 case 'W':
633 mem_write_cmd(adr, len, (uint8 *)cmd + 6);
634 break;
635 case 'E':
636 mem_execute_cmd(adr);
637 break;
638 default:
639 set_error(ERR_SYNTAX31);
640 break;
641 }
642 }
643 break;
644
645 case 'C': // Copy
646 if (!colon)
647 set_error(ERR_SYNTAX31);
648 else if (!equal || memchr(cmd, '*', cmd_len) || memchr(cmd, '?', cmd_len) || (comma && comma < equal))
649 set_error(ERR_SYNTAX30);
650 else
651 copy_cmd(colon + 1, equal - colon - 1, equal + 1, cmd_len - (equal + 1 - cmd));
652 break;
653
654 case 'R': // Rename
655 if (!colon)
656 set_error(ERR_SYNTAX34);
657 else if (!equal || comma || memchr(cmd, '*', cmd_len) || memchr(cmd, '?', cmd_len))
658 set_error(ERR_SYNTAX30);
659 else
660 rename_cmd(colon + 1, equal - colon - 1, equal + 1, cmd_len - (equal + 1 - cmd));
661 break;
662
663 case 'S': // Scratch
664 if (!colon)
665 set_error(ERR_SYNTAX34);
666 else
667 scratch_cmd(colon + 1, cmd_len - (colon + 1 - cmd));
668 break;
669
670 case 'P': // Position
671 position_cmd(cmd + 1, cmd_len - 1);
672 break;
673
674 case 'I': // Initialize
675 initialize_cmd();
676 break;
677
678 case 'N': // New (format)
679 if (!colon)
680 set_error(ERR_SYNTAX34);
681 else
682 new_cmd(colon + 1, comma ? (comma - colon - 1) : cmd_len - (colon + 1 - cmd), comma);
683 break;
684
685 case 'V': // Validate
686 validate_cmd();
687 break;
688
689 case 'U': // User
690 if (cmd[1] == '0')
691 break;
692 switch (cmd[1] & 0x0f) {
693 case 1: { // U1/UA: Read block
694 const uint8 *p = colon ? colon + 1 : cmd + 2;
695 int arg1, arg2, arg3, arg4;
696 parse_block_cmd_args(p, arg1, arg2, arg3, arg4);
697 block_read_cmd(arg1, arg3, arg4, true);
698 break;
699 }
700 case 2: { // U2/UB: Write block
701 const uint8 *p = colon ? colon + 1 : cmd + 2;
702 int arg1, arg2, arg3, arg4;
703 parse_block_cmd_args(p, arg1, arg2, arg3, arg4);
704 block_write_cmd(arg1, arg3, arg4, true);
705 break;
706 }
707 case 9: // U9/UI: C64/VC20 mode switch
708 if (cmd[2] != '+' && cmd[2] != '-')
709 Reset();
710 break;
711 case 10: // U:/UJ: Reset
712 Reset();
713 break;
714 default:
715 set_error(ERR_UNIMPLEMENTED);
716 break;
717 }
718 break;
719
720 default:
721 set_error(ERR_SYNTAX31);
722 break;
723 }
724 }
725
726 // BLOCK-READ:channel,0,track,sector
727 void Drive::block_read_cmd(int channel, int track, int sector, bool user_cmd)
728 {
729 set_error(ERR_UNIMPLEMENTED);
730 }
731
732 // BLOCK-WRITE:channel,0,track,sector
733 void Drive::block_write_cmd(int channel, int track, int sector, bool user_cmd)
734 {
735 set_error(ERR_UNIMPLEMENTED);
736 }
737
738 // BLOCK-EXECUTE:channel,0,track,sector
739 void Drive::block_execute_cmd(int channel, int track, int sector)
740 {
741 set_error(ERR_UNIMPLEMENTED);
742 }
743
744 // BLOCK-ALLOCATE:0,track,sector
745 void Drive::block_allocate_cmd(int track, int sector)
746 {
747 set_error(ERR_UNIMPLEMENTED);
748 }
749
750 // BLOCK-FREE:0,track,sector
751 void Drive::block_free_cmd(int track, int sector)
752 {
753 set_error(ERR_UNIMPLEMENTED);
754 }
755
756 // BUFFER-POINTER:channel,pos
757 void Drive::buffer_pointer_cmd(int channel, int pos)
758 {
759 set_error(ERR_UNIMPLEMENTED);
760 }
761
762 // M-R<adr low><adr high>[<number>]
763 void Drive::mem_read_cmd(uint16 adr, uint8 len)
764 {
765 unsupp_cmd();
766 error_ptr = error_buf;
767 error_buf[0] = 0;
768 error_len = 0;
769 set_error(ERR_OK);
770 }
771
772 // M-W<adr low><adr high><number><data...>
773 void Drive::mem_write_cmd(uint16 adr, uint8 len, uint8 *p)
774 {
775 set_error(ERR_UNIMPLEMENTED);
776 }
777
778 // M-E<adr low><adr high>
779 void Drive::mem_execute_cmd(uint16 adr)
780 {
781 set_error(ERR_UNIMPLEMENTED);
782 }
783
784 // COPY:new=file1,file2,...
785 // ^ ^
786 // new_file old_files
787 void Drive::copy_cmd(const uint8 *new_file, int new_file_len, const uint8 *old_files, int old_files_len)
788 {
789 set_error(ERR_UNIMPLEMENTED);
790 }
791
792 // RENAME:new=old
793 // ^ ^
794 // new_file old_file
795 void Drive::rename_cmd(const uint8 *new_file, int new_file_len, const uint8 *old_file, int old_file_len)
796 {
797 set_error(ERR_UNIMPLEMENTED);
798 }
799
800 // SCRATCH:file1,file2,...
801 // ^
802 // files
803 void Drive::scratch_cmd(const uint8 *files, int files_len)
804 {
805 set_error(ERR_UNIMPLEMENTED);
806 }
807
808 // P<channel><record low><record high><byte>
809 // ^
810 // cmd
811 void Drive::position_cmd(const uint8 *cmd, int cmd_len)
812 {
813 set_error(ERR_UNIMPLEMENTED);
814 }
815
816 // INITIALIZE
817 void Drive::initialize_cmd(void)
818 {
819 set_error(ERR_UNIMPLEMENTED);
820 }
821
822 // NEW:name,id
823 // ^ ^
824 // name comma (or NULL)
825 void Drive::new_cmd(const uint8 *name, int name_len, const uint8 *comma)
826 {
827 set_error(ERR_UNIMPLEMENTED);
828 }
829
830 // VALIDATE
831 void Drive::validate_cmd(void)
832 {
833 set_error(ERR_UNIMPLEMENTED);
834 }
835
836
837 /*
838 * Notice user of unsupported drive command
839 */
840
841 void Drive::unsupp_cmd(void)
842 {
843 }
844
845
846 /*
847 * Convert PETSCII<->ASCII
848 */
849
850 char ascii2petscii(char c)
851 {
852 if ((c >= 'A') && (c <= 'Z') || (c >= 'a') && (c <= 'z'))
853 return c ^ 0x20;
854 return c;
855 }
856
857 void ascii2petscii(char *dest, const char *src, int n)
858 {
859 while (n-- && (*dest++ = ascii2petscii(*src++))) ;
860 }
861
862 char petscii2ascii(uint8 c)
863 {
864 if ((c >= 'A') && (c <= 'Z') || (c >= 'a') && (c <= 'z'))
865 return c ^ 0x20;
866 if ((c >= 0xc1) && (c <= 0xda))
867 return c ^ 0x80;
868 return c;
869 }
870
871 void petscii2ascii(char *dest, const char *src, int n)
872 {
873 while (n-- && (*dest++ = petscii2ascii(*src++))) ;
874 }