-
Notifications
You must be signed in to change notification settings - Fork 48
/
config.cpp
3541 lines (2966 loc) · 104 KB
/
config.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// -----------------------------------------------------------------------------
// Altair 8800 Simulator
// Copyright (C) 2017 David Hansel
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
// -----------------------------------------------------------------------------
#include "Altair8800.h"
#include "config.h"
#include "mem.h"
#include "serial.h"
#include "printer.h"
#include "filesys.h"
#include "numsys.h"
#include "drive.h"
#include "cdrive.h"
#include "tdrive.h"
#include "hdsk.h"
#include "prog.h"
#include "dazzler.h"
#include "sdmanager.h"
#include "vdm1.h"
#include "cpucore.h"
#include "io.h"
#define CONFIG_FILE_VERSION 10
#define BAUD_110 0
#define BAUD_150 1
#define BAUD_300 2
#define BAUD_600 3
#define BAUD_1200 4
#define BAUD_2400 5
#define BAUD_4800 6
#define BAUD_9600 7
#define BAUD_19200 8
#define BAUD_38400 9
#define BAUD_57600 10
#define BAUD_115200 11
#define BAUD_250000 12
#define BAUD_525000 13
#define BAUD_750000 14
#define BAUD_1050000 15
#if HOST_NUM_SERIAL_PORTS>5
#error "Maximum number of host serial interfaces supported is 5"
#endif
// current configuration number
static byte config_current = 0;
// config_flags:
// vvvvvvvv mmmpphrt ttttRRRR dVCDIPFT
// T = Throttle
// t = Throttle delay if throttle is enabled (0=auto)
// F = Profile
// P = Serial Panel
// I = Serial Input
// D = Serial Debug
// C = Clear memory on powerup
// V = VI board installed
// R = RTC rate
// d = force real-time mode for disk drives
// p = printer type (00=NONE, 01=Okidata/88-LPC, 02=C700, 03=Generic)
// m = map printer to host interface (00=NONE, 01=primary, 02=secondary)
// r = real-time mode for printer
// h = real-time mode for hard drives
// v = config file version
uint32_t config_flags;
// config_flags2:
// xxxxxxxx xAPKKKMM MMMMDDDD DDVVVZZZ
// ZZZ = map dazzler to host interface (000=NONE, 001=1st, 010=2nd, 011=3rd, 100=4th, 101=5th)
// VVV = map VDM-1 to host interface (see above)
// D = VDM-1 dip switch settings
// M = VDM-1 memory address (6 highest bits)
// KKK = map VDM-1 keyboard to serial device (000=NONE, 1=SIO, 2=ACR, 3=2SIO1, 4=2SIO2, 5=2SIO3, 6=2SIO4)
// P = Processor (0=i8080, 1=z80)
uint32_t config_flags2;
// config_serial_settings:
// xxxxxxxx 44443333 2222xPPP 11110000
// 0000 = baud rate for first host interface (see baud rates above)
// 1111 = baud rate for second host interface (see baud rates above)
// 2222 = baud rate for third host interface (see baud rates above)
// 3333 = baud rate for fourth host interface (see baud rates above)
// 4444 = baud rate for fifth host interface (see baud rates above)
// PPP = primary serial interface (maximum number depends on host)
// x = unused
uint32_t config_serial_settings, new_config_serial_settings;
// cofig_serial_settings2:
// xxFFFFFB BPPSBBPP SBBPPSBB PPSBBPPS
// for all 5 host interfaces:
// BB = number of bits (0=5, 1=6, 2=7, 3=8)
// PP = parity (0=none, 1=even, 2=odd)
// S = stop bits (0=1, 1=2)
// FFFFF = support XON/XOFF flow control when sending data (for all 5 host interfaces)
uint32_t config_serial_settings2, new_config_serial_settings2;
// config_serial_device_settings[0-5]
// xxxxxxxx xxxxMMMR TT77UUVV CNNNBBBB
// BBBB = baud rate for serial playback (see baud rates above)
// NNN = NULs to send after a carriage return when playing back examples
// C = trap CLOAD/CSAVE in extended BASIC (for CSM_ACR device only)
// MMM = map device to host interface (000=NONE, 001=first, 010=second, 011=third, 100=fourth, 101=fifth, 111=primary)
// UU = only uppercase for inputs (00=off, 01=on, 10=autodetect)
// 77 = use 7 bit for serial outputs (00=off [use 8 bit], 01=on, 10=autodetect)
// TT = translate backspace to (00=off, 01=underscore, 10=autodetect, 11=delete)
// R = force realtime operation (use baud rate even if not using interrupts)
// VV = 88-SIO board version (0=rev0, 1=rev1, 2=Cromemco)
uint32_t config_serial_device_settings[NUM_SERIAL_DEVICES];
// map emulated device (SIO/2SIO etc.) to host serial port number
byte config_serial_sim_to_host[NUM_SERIAL_DEVICES];
// masks defining which interrupts (INT_*) are at which vector interrupt levels
uint32_t config_interrupt_vi_mask[8];
// mask defining whch interrupts (INT_*) are connected if VI board is not installed
uint32_t config_interrupt_mask;
// program to be run when AUX1 is raised
byte config_aux1_prog;
// amount of RAM installed
uint32_t config_mem_size;
// status bytes for generic printer emulation
byte config_printer_generic_status_busy;
byte config_printer_generic_status_ready;
// --------------------------------------------------------------------------------
static bool config_read_string(char *buf, byte bufsize)
{
int l = 0;
while( true )
{
int c = serial_read();
if( c>=32 && c<127 )
{
if( l < bufsize-1 ) { buf[l++] = c; Serial.write(c); }
}
else if( c==8 || c==127 )
{
if( l>0 )
{
l--;
Serial.print(F("\010 \010"));
}
}
else if( c==13 )
{
Serial.println();
buf[l]=0;
return true;
}
else if( c==27 )
{
Serial.println();
return false;
}
}
return true;
}
inline uint32_t get_bits(uint32_t v, byte i, byte n)
{
return (v >> ((uint32_t) i)) & ((1ul<<n)-1);
}
inline uint32_t set_bits(uint32_t v, byte i, byte n, uint32_t nv)
{
uint32_t mask = ((1ul<<n)-1) << i;
return (v & ~mask) | ((nv << i) & mask);
}
static uint32_t toggle_bits(uint32_t v, byte i, byte n, byte min = 0x00, byte max = 0xff)
{
byte b = get_bits(v, i, n) + 1;
return set_bits(v, i, n, b>max ? min : (b<min ? min : b));
}
static uint32_t toggle_vdm1_dip(uint32_t v, byte i, bool allowBoth)
{
switch( get_bits(v, i, 2) )
{
case 0: return set_bits(v, i, 2, 2);
case 2: return set_bits(v, i, 2, 1);
case 1: return set_bits(v, i, 2, allowBoth ? 3 : 0);
case 3: return set_bits(v, i, 2, 0);
}
return v;
}
static byte config_baud_rate_bits(byte iface)
{
byte n = 0;
switch( iface )
{
case 0: n = 0; break;
case 1: n = 4; break;
case 2: n = 12; break;
case 3: n = 16; break;
case 4: n = 20; break;
}
return n;
}
static uint32_t config_baud_rate(byte b)
{
uint32_t res;
switch(b)
{
case BAUD_110 : res = 110; break;
case BAUD_150 : res = 150; break;
case BAUD_300 : res = 300; break;
case BAUD_600 : res = 600; break;
case BAUD_1200 : res = 1200; break;
case BAUD_2400 : res = 2400; break;
case BAUD_4800 : res = 4800; break;
case BAUD_9600 : res = 9600; break;
case BAUD_19200 : res = 19200; break;
case BAUD_38400 : res = 38400; break;
case BAUD_57600 : res = 57600; break;
case BAUD_115200 : res = 115200; break;
case BAUD_250000 : res = 250000; break;
case BAUD_525000 : res = 525000; break;
case BAUD_750000 : res = 750000; break;
case BAUD_1050000: res = 1050000; break;
default : res = 115200; break;
}
return res;
}
float config_rtc_rate()
{
float res = 0.0;
byte value = get_bits(config_flags, 8, 4);
if( value & 0x08 )
{
switch( value & 0x07 )
{
case 0: res = 0.06f; break;
case 1: res = 0.60f; break;
case 2: res = 6.00f; break;
case 3: res = 10.00f; break;
case 4: res = 60.00f; break;
case 5: res = 100.00f; break;
case 6: res = 1000.00f; break;
case 7: res = 10000.00f; break;
}
}
return res;
}
#if USE_THROTTLE>0
int config_throttle()
{
if( config_flags & CF_THROTTLE )
{
int i = get_bits(config_flags, 12, 5);
if( i==0 )
return -1; // auto
else
return i; // manual
}
else
return 0; // off
}
#endif
byte config_aux1_program()
{
return config_aux1_prog;
}
byte config_serial_backspace(byte dev, uint16_t PC)
{
byte b = get_bits(config_serial_device_settings[dev], 14, 2);
if( b==CSFB_AUTO )
{
if( PC == 0x038A || PC == 0x0380 || PC == 0x00A0 || PC == 0x00AC )
{
// ALTAIR 4k BASIC I/O routine has "IN" instruction at 0x389 and "OUT" instruction at 0x037F
// ALTAIR EXTENDED BASIC I/O routine has "IN" instruction at 0x09f and "OUT" instruction at 0x00AB
b = CSFB_UNDERSCORE;
}
else if( PC == 0x0726 || PC == 0x08e5 )
{
// MITS Programming System II has "IN" instruction at 0x0725 and 0x07E4
b = CSFB_DELETE;
}
else
b = CSFB_NONE;
}
return b;
}
bool config_serial_ucase(byte dev, uint16_t PC)
{
byte b = get_bits(config_serial_device_settings[dev], 10, 2);
if( b==CSF_AUTO )
{
// ALTAIR 4k BASIC I/O routine has "IN" instruction at 0x0389
// MITS Programming System II has "IN" instruction at 0x0725 and 0x07E4
return (PC == 0x038A) || (PC == 0x0726) || (PC == 0x08e5);
}
else
return b==CSF_ON;
}
bool config_serial_7bit(byte dev, uint16_t PC)
{
byte b = get_bits(config_serial_device_settings[dev], 12, 2);
if( b==CSF_AUTO )
{
// ALTAIR 4k BASIC I/O routine has "OUT" instruction at 0x037F
// ALTAIR EXTENDED BASIC I/O routine has "OUT" instruction at 0x00AB
// MITS Programming System II has "OUT" instruction at 0x071B
return (PC == 0x0380) || (PC == 0x00AC) || (PC == 0x071C);
}
else
return b==CSF_ON;
}
byte config_serial_siorev()
{
return get_bits(config_serial_device_settings[CSM_SIO], 8, 2);
}
bool config_serial_trap_CLOAD()
{
return get_bits(config_serial_device_settings[CSM_ACR], 7, 1)>0;
}
uint32_t config_serial_playback_baud_rate(byte dev)
{
return config_baud_rate(get_bits(config_serial_device_settings[dev], 0, 4));
}
byte config_serial_playback_example_nuls(byte dev)
{
return get_bits(config_serial_device_settings[dev], 4, 3);
}
byte config_map_device_to_host_interface(byte s)
{
if( s==7 )
return config_host_serial_primary();
else if( s<=HOST_NUM_SERIAL_PORTS )
return s-1;
else
return 0xff;
}
bool config_serial_realtime(byte dev)
{
return get_bits(config_serial_device_settings[dev], 16, 1) ? true : false;
}
byte config_host_serial_primary()
{
return get_bits(config_serial_settings, 8, 3);
}
uint32_t config_host_serial_baud_rate(uint32_t settings, byte iface)
{
return config_baud_rate(get_bits(settings, config_baud_rate_bits(iface), 4));
}
bool config_host_serial_xonxoff(byte iface)
{
return host_serial_port_support_xonxoff(iface) && get_bits(config_serial_settings2,25+iface, 1)!=0;
}
uint32_t config_host_serial_config(uint32_t settings2, byte iface)
{
byte v = get_bits(settings2, iface * 5, 5);
switch( v )
{
#ifndef HOST_TEENSY_H // Teensy does not define these constants
case 0x00: return SERIAL_5N1;
case 0x01: return SERIAL_5N2;
case 0x02: return SERIAL_5E1;
case 0x03: return SERIAL_5E2;
case 0x04: return SERIAL_5O1;
case 0x05: return SERIAL_5O2;
case 0x08: return SERIAL_6N1;
case 0x09: return SERIAL_6N2;
case 0x0A: return SERIAL_6E1;
case 0x0B: return SERIAL_6E2;
case 0x0C: return SERIAL_6O1;
case 0x0D: return SERIAL_6O2;
case 0x10: return SERIAL_7N1;
case 0x11: return SERIAL_7N2;
case 0x12: return SERIAL_7E1;
case 0x13: return SERIAL_7E2;
case 0x14: return SERIAL_7O1;
case 0x15: return SERIAL_7O2;
#endif
case 0x18: return SERIAL_8N1;
case 0x19: return SERIAL_8N2;
case 0x1A: return SERIAL_8E1;
case 0x1B: return SERIAL_8E2;
case 0x1C: return SERIAL_8O1;
case 0x1D: return SERIAL_8O2;
// fall back to default 8N1 settings
default : return SERIAL_8N1;
}
}
uint32_t config_host_serial_config(byte iface)
{
return config_host_serial_config(config_serial_settings2, iface);
}
uint32_t config_host_serial_baud_rate(byte iface)
{
return config_host_serial_baud_rate(config_serial_settings, iface);
}
byte config_printer_map_to_host_serial()
{
return config_map_device_to_host_interface(get_bits(config_flags, 21, 3));
}
byte config_printer_type()
{
return get_bits(config_flags, 19, 2);
}
byte config_printer_generic_get_status(bool busy)
{
return busy ? config_printer_generic_status_busy : config_printer_generic_status_ready;
}
byte config_dazzler_interface()
{
return config_map_device_to_host_interface(get_bits(config_flags2, 0, 3));
}
byte config_vdm1_interface()
{
return config_map_device_to_host_interface(get_bits(config_flags2, 3, 3));
}
byte config_vdm1_dip()
{
return get_bits(config_flags2, 6, 6);
}
byte config_vdm1_keyboard_device()
{
return ((byte) get_bits(config_flags2, 18, 3))-1;
}
uint16_t config_vdm1_address()
{
return get_bits(config_flags2, 12, 6) * 1024;
}
// --------------------------------------------------------------------------------
static void set_cursor(byte row, byte col)
{
Serial.print(F("\033["));
Serial.print(row);
Serial.print(';');
Serial.print(col);
Serial.print(F("H\033[K"));
}
static void print_cpu()
{
if( config_use_z80() )
Serial.print(F("Zilog Z80"));
else
Serial.print(F("Intel 8080"));
}
static void print_mem_size(uint32_t s, byte row=0, byte col=0)
{
if( row!=0 || col!=0 ) set_cursor(row, col);
if( (s&0x3FF)==0 )
{
Serial.print(s/1024);
Serial.print(F(" KB"));
}
else
{
Serial.print(s);
Serial.print(F(" bytes"));
}
}
static void print_flag(uint32_t data, uint32_t value, byte row=0, byte col=0)
{
if( row!=0 || col!=0 ) set_cursor(row, col);
Serial.print((data&value)!=0 ? F("yes") : F("no"));
}
static void print_flag(uint32_t value, byte row=0, byte col=0)
{
print_flag(config_flags, value, row, col);
}
static void print_flag2(uint32_t value, byte row=0, byte col=0)
{
print_flag(config_flags2, value, row, col);
}
static void print_vi_flag()
{
Serial.print((config_flags&CF_HAVE_VI)!=0 ? F("Use Vector Interrupt board") : F("Interrupts connected directly to CPU"));
}
static void print_host_serial_config(uint32_t settings2, byte iface)
{
byte v = get_bits(settings2, iface * 5, 5);
Serial.print(get_bits(settings2, iface * 5 + 3, 2)+5);
switch( get_bits(settings2, iface * 5 + 1, 2) )
{
case 0 : Serial.print('N'); break;
case 1 : Serial.print('E'); break;
case 2 : Serial.print('O'); break;
case 3 : Serial.print('?'); break;
}
Serial.print(get_bits(settings2, iface * 5, 1)+1);
}
static void print_host_serial_config(byte iface, byte row, byte col)
{
if( row!=0 || col!=0 ) set_cursor(row, col);
Serial.print(config_host_serial_baud_rate(new_config_serial_settings, iface));
Serial.print(F(" baud"));
if( host_serial_port_has_configs(iface) )
{
Serial.print(' ');
print_host_serial_config(new_config_serial_settings2, iface);
}
if( config_host_serial_baud_rate(new_config_serial_settings, iface) != config_host_serial_baud_rate(iface)
||
get_bits(new_config_serial_settings2, iface * 5, 5) != get_bits(config_serial_settings2, iface * 5, 5) )
{
Serial.print(F(" (current: "));
Serial.print(config_host_serial_baud_rate(iface));
if( host_serial_port_has_configs(iface) )
{
Serial.print(' ');
print_host_serial_config(config_serial_settings2, iface);
}
Serial.print(')');
}
}
static void print_throttle(byte row = 0, byte col = 0)
{
if( row!=0 || col!=0 ) set_cursor(row, col);
int i = config_throttle();
if ( i<0 ) Serial.print(F("auto adjust"));
else if( i==0 ) Serial.print(F("off"));
else Serial.print(i);
}
static void print_serial_device_sim(byte dev)
{
switch( dev )
{
case CSM_SIO: Serial.print(F("SIO")); break;
case CSM_ACR: Serial.print(F("ACR")); break;
case CSM_2SIO1: Serial.print(F("2-SIO port 1")); break;
case CSM_2SIO2: Serial.print(F("2-SIO port 2")); break;
case CSM_2SIO3: Serial.print(F("2-SIO2 port 1")); break;
case CSM_2SIO4: Serial.print(F("2-SIO2 port 2")); break;
case 0xff : Serial.print(F("none")); break;
}
}
static void print_host_primary_interface_aux(byte iface)
{
Serial.print(host_serial_port_name(iface));
}
static void print_host_primary_interface(byte row = 0, byte col = 0)
{
if( row!=0 || col!=0 ) set_cursor(row, col);
print_host_primary_interface_aux(get_bits(new_config_serial_settings, 8, 3));
if( get_bits(new_config_serial_settings, 8, 3) != config_host_serial_primary() )
{
Serial.print(F(" (current: "));
print_host_primary_interface_aux(config_host_serial_primary());
Serial.print(')');
}
}
static void print_serial_flag(uint32_t settings, byte pos, byte bits = 2)
{
switch( get_bits(settings, pos, bits) )
{
case CSF_OFF: Serial.print(F("off")); break;
case CSF_ON: Serial.print(F("on")); break;
case CSF_AUTO: Serial.print(F("autodetect")); break;
}
}
static void print_serial_flag_backspace(uint32_t settings)
{
switch( get_bits(settings, 14, 2) )
{
case CSFB_NONE: Serial.print(F("off")); break;
case CSFB_UNDERSCORE: Serial.print(F("underscore (_)")); break;
case CSFB_DELETE: Serial.print(F("delete (127)")); break;
case CSFB_AUTO: Serial.print(F("autodetect")); break;
}
}
static void print_serial_flag_siorev(uint32_t settings)
{
switch( get_bits(settings, 8, 2) )
{
case 0: Serial.print(F("rev0")); break;
case 1: Serial.print(F("rev1")); break;
case 2: Serial.print(F("Cromemco")); break;
}
}
static void print_device_mapped_to(byte s)
{
if( s==0 )
Serial.print(F("Not mapped"));
else if( s==7 )
{
Serial.print(F("Primary ("));
print_host_primary_interface();
Serial.print(')');
}
else
Serial.print(host_serial_port_name(s-1));
}
static void print_serial_device_mapped_to(uint32_t settings)
{
print_device_mapped_to(get_bits(settings, 17, 3));
}
static void print_dazzler_mapped_to()
{
byte s = get_bits(config_flags2, 0, 3);
if( s==0 )
Serial.print(F("Disabled"));
else
{
Serial.print(F("On "));
Serial.print(host_serial_port_name(s-1));
}
}
static void print_vdm1_mapped_to()
{
byte s = get_bits(config_flags2, 3, 3);
if( s==0 )
Serial.print(F("Disabled"));
else
{
Serial.print(F("On "));
Serial.print(host_serial_port_name(s-1));
}
}
static void print_vdm1_addr()
{
uint16_t a = config_vdm1_address();
numsys_print_word(a);
}
static void print_vdm1_dip12()
{
switch( config_vdm1_dip() & 3 )
{
case 0: Serial.print(F("off/off (no display)")); break;
case 2: Serial.print(F("off/on (normal video)")); break;
case 1: Serial.print(F("on /off (inverse video)")); break;
case 3: Serial.print(F("on /on [ILLEGAL]")); break;
}
}
static void print_vdm1_dip34()
{
switch( (config_vdm1_dip()>>2) & 3 )
{
case 0: Serial.print(F("off/off (all cursors suppressed)")); break;
case 2: Serial.print(F("off/on (blinking cursor)")); break;
case 1: Serial.print(F("on /off (non-blinking cursor)")); break;
case 3: Serial.print(F("on /on [ILLEGAL]")); break;
}
}
static void print_vdm1_dip56()
{
switch( (config_vdm1_dip()>>4) & 3 )
{
case 0: Serial.print(F("off/off (all characters suppressed, VT-CR blanking on)")); break;
case 2: Serial.print(F("off/on (control characters blanked, VT-CR blanking on)")); break;
case 1: Serial.print(F("on /off (control characters shown, VT-CR blanking on)")); break;
case 3: Serial.print(F("on /on (control characters shown, VT-CR blanking off)")); break;
}
}
static void print_printer_mapped_to()
{
print_device_mapped_to(get_bits(config_flags, 21, 3));
}
static void print_rtc_frequency()
{
float rate = config_rtc_rate();
if( rate==0.0 )
Serial.print(F("Disabled"));
else
{ Serial.print(rate); Serial.print(F(" Hz")); }
}
static void print_interrupt_conn(uint32_t mask, byte b)
{
if( config_flags&CF_HAVE_VI )
{
if( b == 0xff )
Serial.print(F("Not connected"));
else
{ Serial.print(F("VI")); Serial.print(b); }
}
else
{
if( config_interrupt_mask & mask )
Serial.print(F("Connected"));
else
Serial.print(F("Not connected"));
}
}
static void print_aux1_program(byte row=0, byte col=0)
{
if( row!=0 || col!=0 ) set_cursor(row, col);
byte b = config_aux1_program();
if( b < 0x40 )
Serial.print(FP(prog_get_name(b)));
else
{
const char *image;
if( b < 0x80 )
image = tdrive_get_image_description(b&0x3f);
else if( b < 0xC0 )
image = drive_get_image_description(b&0x3f);
else
image = hdsk_get_image_description(b&0x3f);
if( image==NULL )
Serial.print(F("none"));
else
Serial.print(image);
}
}
static void print_drive_mounted()
{
byte n = 0;
for(byte i=0; i<NUM_DRIVES; i++)
if( drive_get_mounted_image(i)>0 ) n++;
Serial.print(n); Serial.print(F(" mounted"));
}
static void print_cdrive_mounted()
{
byte n = 0;
for(byte i=0; i<NUM_CDRIVES; i++)
if( cdrive_get_mounted_image(i)>0 ) n++;
Serial.print(n); Serial.print(F(" mounted"));
}
static void print_tdrive_mounted()
{
byte n = 0;
for(byte i=0; i<NUM_TDRIVES; i++)
if( tdrive_get_mounted_image(i)>0 ) n++;
Serial.print(n); Serial.print(F(" mounted"));
}
static void print_drive_mounted_image(byte d)
{
if( d==0 )
Serial.print(F("none"));
else if( drive_get_image_filename(d)==NULL )
{ Serial.print(F("empty disk #")); numsys_print_byte(d); }
else
Serial.print(drive_get_image_description(d));
}
static void print_cdrive_mounted_image(byte d)
{
if( d==0 )
Serial.print(F("none"));
else if( cdrive_get_image_filename(d)==NULL )
{ Serial.print(F("empty disk #")); numsys_print_byte(d); }
else
Serial.print(cdrive_get_image_description(d));
}
static void print_tdrive_mounted_image(byte d)
{
if( d==0 )
Serial.print(F("none"));
else if( tdrive_get_image_filename(d)==NULL )
{ Serial.print(F("empty disk #")); numsys_print_byte(d); }
else
Serial.print(tdrive_get_image_description(d));
}
static void print_hdsk_mounted()
{
byte n = 0;
for(byte i=0; i<NUM_HDSK_UNITS; i++)
for(byte j=0; j<4; j++)
if( hdsk_get_mounted_image(i, j)>0 ) n++;
Serial.print(n); Serial.print(F(" mounted"));
}
static void print_hdsk_mounted_image(byte d)
{
if( d==0 )
Serial.print(F("none"));
else if( hdsk_get_image_filename(d)==NULL )
{ Serial.print(F("empty disk #")); numsys_print_byte(d); }
else
Serial.print(hdsk_get_image_description(d));
}
static void print_printer_type()
{
switch( config_printer_type() )
{
case 0: Serial.print(F("None")); break;
case 1: Serial.print(F("Okidata/88-LPC")); break;
case 2: Serial.print(F("C700")); break;
case 3: Serial.print(F("Generic")); break;
}
}
static void print_parity(byte p)
{
switch( p )
{
case 0 : Serial.print(F("None")); break;
case 1 : Serial.print(F("Even")); break;
case 2 : Serial.print(F("Odd ")); break;
default : Serial.print(F("??? ")); break;
}
}
static void print_mapped_serial_cards()
{
bool mapped = false;
if( config_serial_map_sim_to_host(CSM_SIO)<0xff ) { Serial.print(F("SIO")); mapped = true; }
if( config_serial_map_sim_to_host(CSM_ACR)<0xff ) { if(mapped) Serial.print(','); Serial.print(F("ACR")); mapped = true; }
if( config_serial_map_sim_to_host(CSM_2SIO1)<0xff ) { if(mapped) Serial.print(','); Serial.print(F("2SIO-P1")); mapped = true; }
if( config_serial_map_sim_to_host(CSM_2SIO2)<0xff ) { if(mapped) Serial.print(','); Serial.print(F("2SIO-P2")); mapped = true; }
if( config_serial_map_sim_to_host(CSM_2SIO3)<0xff ) { if(mapped) Serial.print(','); Serial.print(F("2SIO2-P1")); mapped = true; }
if( config_serial_map_sim_to_host(CSM_2SIO4)<0xff ) { if(mapped) Serial.print(','); Serial.print(F("2SIO2-P2")); mapped = true; }
if( !mapped ) Serial.print(F("None"));
}
// --------------------------------------------------------------------------------
static void apply_host_serial_settings(uint32_t settings, uint32_t settings2)
{
config_serial_settings = settings;
config_serial_settings2 = settings2;
for(byte i=0; i<HOST_NUM_SERIAL_PORTS; i++)
host_serial_setup(i, config_host_serial_baud_rate(i),
config_host_serial_config(settings2, i),
config_host_serial_primary()==i);
// mapping for serial devices can have changed if primary serial was changed
for(byte dev=0; dev<NUM_SERIAL_DEVICES; dev++)
config_serial_sim_to_host[dev] = config_map_device_to_host_interface(get_bits(config_serial_device_settings[dev], 17, 3));
}