-
Notifications
You must be signed in to change notification settings - Fork 2
/
config_1982.s
1350 lines (1257 loc) · 46.7 KB
/
config_1982.s
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
RST0: EQU 0x0000
BDOS: EQU 0x0005
CON_READ: EQU 0x01
CON_WRITE: EQU 0x02
CON_RAWIO: EQU 0x06
CON_RAWIO_PEEK_CHAR: EQU 0xff
CON_WRITESTR: EQU 0x09
DRV_SET: EQU 0x0E
BIOS_config_byte: EQU 0xfa34
BIOS_WRITE_fa2a: EQU 0xfa2a
BIOS_SETSEC_fa21: EQU 0xfa21
BIOS_SETTRK_fa1e: EQU 0xfa1e
BIOS_SETDMA_fa24: EQU 0xfa24
io_port_00_serial_baud_rate: EQU 0x00
changes_pending_yes: EQU 0x00
changes_pending_no: EQU 0xff
write_safe_yes: EQU 0xff
write_safe_no: EQU 0x00
; ASCII codes
no_key: EQU 0x00
line_feed: EQU 0x0a
form_feed: EQU 0x0c
return_key: EQU 0x0d
clear_screen: EQU 0x1a
escape: EQU 0x1b
home: EQU 0x1e
ORG 0x0100
JP main_menu_reset
JP main_menu_reset
move_cursor:
; Output an 0xff terminated string in DE to console
LD A, (DE)
CP 0xff
RET Z
PUSH DE
LD C, CON_WRITE
LD E, A
CALL BDOS
POP DE
INC DE
JR move_cursor
main_menu_reset:
; The config will be stored in B:
LD A, 0x1
LD (disk_drive_destination), A
; Let's mark that there are no changes to save
LD A, changes_pending_no
LD (changes_pending), A
main_menu:
; Show the main menu and select an option
LD C,CON_WRITESTR
LD DE,msg_menu_header
CALL BDOS
LD C,CON_WRITESTR
LD DE,msg_main_menu
CALL BDOS
LD C,CON_READ
CALL BDOS
PUSH AF
LD C,CON_WRITESTR
LD DE,msg_new_line
CALL BDOS
POP AF
CP '1'
JP Z,menu_1_iobyte
CP '2'
JP Z,menu_2_write_safe
CP '3'
JP Z,menu_3_cursor_keys
CP '4'
JP Z,menu_4_keypad
CP '5'
JP Z,menu_5_baud_rate
CP escape
JP Z,menu_exit
JP main_menu
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; OPTION 5: Configure the serial port baud rate
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
menu_5_baud_rate:
; Show the baud rate menu and select an option
LD C,CON_WRITESTR
LD DE,msg_menu_header
CALL BDOS
LD C,CON_WRITESTR
LD DE,msg_baud_rate_menu
CALL BDOS
LD C,CON_READ
CALL BDOS
PUSH AF
LD C,CON_WRITESTR
LD DE,msg_new_line
CALL BDOS
POP AF
CP '1'
JP Z,menu_5_baud_rate_1_help
CP escape
JP Z,main_menu
CP '2'
JP Z,menu_5_baud_rate_2_change
JP menu_5_baud_rate
menu_5_baud_rate_2_change:
; Show the baud rate change menu
LD C,CON_WRITESTR
LD DE,msg_baud_rate_change_menu
CALL BDOS
baud_rate_selection_reset:
LD A,0x0
LD (current_selection),A
LD C,CON_WRITESTR
LD DE,msg_form_feeds
CALL BDOS
baud_rate_selection:
LD C,CON_RAWIO
LD E,CON_RAWIO_PEEK_CHAR
CALL BDOS
CP no_key
JR Z,baud_rate_selection
CP escape
JR Z,menu_5_baud_rate
CP line_feed
JP Z,baud_rate_selection_next
CP return_key
JR NZ,baud_rate_selection
; We have a selection
LD A,(current_selection)
CP 0x10
JP NC,baud_rate_selection
; The selection is valid
; Configure the serial port
OUT (io_port_00_serial_baud_rate),A
JP menu_5_baud_rate
baud_rate_selection_next:
; Select the next baud rate
LD A,(current_selection)
INC A
LD (current_selection),A
; If we are past the last option, restart
CP 0x11
JR Z,baud_rate_selection_reset
LD C,CON_WRITESTR
LD DE,msg_line_feed
CALL BDOS
JR baud_rate_selection
current_selection:
; Variable uses on all the sections
db 0h
msg_baud_rate_change_menu:
db clear_screen
db " 50\r\n"
db " 75\r\n"
db " 110\t\tMove the cursor to the baud rate which\r\n"
db " 134.5\r\n"
db " 150\t\tyou want to use by typing the [LINE FEED] key.\r\n"
db " 300\r\n"
db " 600\r\n"
db " 1200\t\tWhen the cursor is at the rate you want\r\n"
db " 1800\r\n"
db " 2000\t\ttype the RETURN key and it will be set.\r\n"
db " 2400\r\n"
db " 3600\t\tThe new baud rate will be effective now.\r\n"
db " 4800\r\n"
db " 7200\r\n"
db " 9600\r\n"
db "19200\r\n"
db "Type [ESC] key to return to the previous menu (no changes)\r\n\r\n\n"
db "(* NOTE: The baud rate will always default to 300 baud *)\r\n"
db "(* after the power is first turned on and when *)\r\n"
db "(* the RESET button is pressed. *)\r\n$"
msg_form_feeds:
db home,form_feed,form_feed,form_feed,form_feed,form_feed,"$"
msg_line_feed:
db "\n$"
menu_5_baud_rate_1_help:
; Show the baud rate help screen
LD C,CON_WRITESTR
LD DE,msg_help_baud_rate
CALL BDOS
LD C,CON_WRITESTR
LD DE,msg_press_any_key
CALL BDOS
LD C,CON_READ
CALL BDOS
JP menu_5_baud_rate
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; OPTION 4: Configure the keypad mappings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
menu_4_keypad:
; Show the keypad menu and select an option
LD C,CON_WRITESTR
LD DE,msg_menu_header
CALL BDOS
LD C,CON_WRITESTR
LD DE,msg_keypad_menu
CALL BDOS
LD C,CON_READ
CALL BDOS
PUSH AF
LD C,CON_WRITESTR
LD DE,msg_new_line
CALL BDOS
POP AF
CP '1'
JP Z,menu_4_keypad_1_help
CP '2'
JP Z,menu_4_keypad_2_change
CP escape
JP Z,main_menu
JP menu_4_keypad
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; HEX INPUT:
; Used on options 3 and 4 to retreive an hex value
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
key_selection_input:
; Set the next key to map
LD A,(current_selection)
INC A
LD (current_selection),A
; Retrieve the HEX mapping
CALL key_edit_H
; Store the key if there is data
JR NZ,store_key_change
; Return to the sequence if we had a line feed
CP line_feed
RET Z
; We are done, back to the previous menu
POP HL
LD HL,(menu_escape_address)
JP (HL)
; unused
db 0xC8
store_key_change:;
; Mark that there are changes to save
LD A,changes_pending_yes
LD (changes_pending),A
; Calculate the position on the BIOS copy to store the mapping
; HL has the section and we offset with the selection - 1
LD DE,0x0
LD A,(current_selection)
DEC A
LD E,A
LD HL,(key_config_base_address)
ADD HL,DE
LD A,C
; Store it
LD (HL),A
RET
key_edit_H:
LD C,CON_RAWIO
LD E,CON_RAWIO_PEEK_CHAR
CALL BDOS
CP no_key
JR Z,key_edit_H
CP line_feed
RET Z
CP escape
RET Z
; If less than '0' ignore the key press
CP '0'
JR C,key_edit_H
; Is it '9' or less?
CP '9' + 1
; Yes, it is a decimal digit between 0 and 9
JR C,key_decimal_digit_H
; No, it must be A to F, if not we will ignore the key press
; To lowercase
RES 0x5,A
CP 'F' + 1
JR NC,key_edit_H
CP 'A'
JR C,key_edit_H
; It is an hex digit, echo it
PUSH AF
LD C,CON_WRITE
LD E,A
CALL BDOS
POP AF
; substract 7 to have A-F just after 0-9
SUB 'A' - '9' - 1
JR key_process_digit_H
key_decimal_digit_H:
; It is a decimal digit, echo it
PUSH AF
LD C,CON_WRITE
LD E,A
CALL BDOS
POP AF
key_process_digit_H:
; Convert the ASCII digit to a number
SUB '0'
; Set it as the high nibble
RLC A
RLC A
RLC A
RLC A
AND 0xf0
PUSH AF
key_edit_L:
LD C,CON_RAWIO
LD E,CON_RAWIO_PEEK_CHAR
CALL BDOS
CP no_key
JR Z,key_edit_L
CP line_feed
JR Z,key_edit_L_cancel
CP escape
JR NZ,key_edit_L_continue
key_edit_L_cancel:
POP HL
RET
key_edit_L_continue:
; If less than '0' ignore the key press
CP '0'
JR C,key_edit_L
; Is it '9' or less?
CP '9' + 1
; Yes, it is a decimal digit between 0 and 9
JR C,key_decimal_digit_L
; No, it must be A to F, if not we will ignore the key press
; To lowercase
RES 0x5,A
CP 'F' + 1
JR NC,key_edit_L
CP 'A'
JR C,key_edit_L
PUSH AF
; It is an hex digit, echo it
LD C,CON_WRITE
LD E,A
CALL BDOS
POP AF
; substract 7 to have A-F just after 0-9
SUB 'A' - '9' - 1
JR key_process_digit_L
key_decimal_digit_L:
; It is a decimal digit, echo it
PUSH AF
LD C,CON_WRITE
LD E,A
CALL BDOS
POP AF
key_process_digit_L:
; Convert the ASCII digit to a number
SUB '0'
; Set it as the low nibble
AND 0xf
LD C,A
POP AF
OR C
LD C,A
RET NZ
INC A
RET
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; OPTION 4: Configure the keypad mappings (continued)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
menu_4_keypad_2_change:
; Set the address of the previous menu
LD HL,menu_4_keypad
LD (menu_escape_address),HL
; Set the address of the key mapping to change
LD HL,bios_content_keypad_map
LD (key_config_base_address),HL
; Show the menu
LD C,CON_WRITESTR
LD DE,msg_keypad_change_menu
CALL BDOS
keypad_sequence:
; Move through the keypad sequence
LD A,0x0
LD (current_selection),A
LD DE,keypad_options_positions
CALL move_cursor
CALL key_selection_input
LD DE,keypad_options_positions+5
CALL move_cursor
CALL key_selection_input
LD DE,keypad_options_positions+10
CALL move_cursor
CALL key_selection_input
LD DE,keypad_options_positions+15
CALL move_cursor
CALL key_selection_input
LD DE,keypad_options_positions+20
CALL move_cursor
CALL key_selection_input
LD DE,keypad_options_positions+25
CALL move_cursor
CALL key_selection_input
LD DE,keypad_options_positions+30
CALL move_cursor
CALL key_selection_input
LD DE,keypad_options_positions+35
CALL move_cursor
CALL key_selection_input
LD DE,keypad_options_positions+40
CALL move_cursor
CALL key_selection_input
LD DE,keypad_options_positions+45
CALL move_cursor
CALL key_selection_input
LD DE,keypad_options_positions+50
CALL move_cursor
CALL key_selection_input
LD DE,keypad_options_positions+55
CALL move_cursor
CALL key_selection_input
LD DE,keypad_options_positions+60
CALL move_cursor
CALL key_selection_input
LD DE,keypad_options_positions+65
CALL move_cursor
CALL key_selection_input
LD DE,keypad_options_positions+70
CALL move_cursor
keypad_selection_esc:
; The cursor is on the top of the ESC option
LD C,CON_RAWIO
LD E,CON_RAWIO_PEEK_CHAR
CALL BDOS
CP no_key
JR Z,keypad_selection_esc
CP escape
JP Z,menu_4_keypad
CP line_feed
JR NZ,keypad_selection_esc
; Restart the sequence
JP keypad_sequence
msg_keypad_change_menu:
db clear_screen
db "-----------------------------\tMove the cursor to the key you wish\r\n"
db ": : : : :\r\n"
db ": 7 : 8 : 9 : - :\tto change. Use the [LINE FEED] key.\r\n"
db ": : : : :\r\n"
db ": 37 : 38 : 39 : 2D :\tThe default HEXADECIMAL code will be\r\n"
db ";------;------;------;------:\r\n"
db ": : : : :\tthe number which is flashing.\r\n"
db ": 4 : 5 : 6 : , :\r\n"
db ": : : : :\r\n"
db ": 34 : 35 : 36 : 2C :\tWhen you reach the key you wish to change.\r\n"
db ":------:------:------:------:\r\n"
db ": : : : :\tType in the new HEXADECIMAL code.\r\n"
db ": 1 : 2 : 3 : :\r\n"
db ": : : : :\r\n"
db ": 31 : 32 : 33 : ENTER:\t(* NOTE: you must enter both digits *)\r\n"
db ":------:------:------: :\r\n"
db ": : : 0D :\t(* to change the code. *)\r\n"
db ": 0 : . : :\r\n"
db ": : : :\r\n"
db ": 30 : 2E : : Type the [ESC] key to return to the previous menu\r\n"
db "-----------------------------\r\n$"
keypad_options_positions:
db 0x1B,"=3&",0xFF
db 0x1B,"=.#",0xFF
db 0x1B,"=.*",0xFF
db 0x1B,"=.1",0xFF
db 0x1B,"=)#",0xFF
db 0x1B,"=)*",0xFF
db 0x1B,"=)1",0xFF
db 0x1B,"=$#",0xFF
db 0x1B,"=$*",0xFF
db 0x1B,"=$1",0xFF
db 0x1B,"=$8",0xFF
db 0x1B,"=)8",0xFF
db 0x1B,"=08",0xFF
db 0x1B,"=31",0xFF
db 0x1B,"=3I",0xFF
menu_4_keypad_1_help:
; Show the help for keypad configuration
LD C,CON_WRITESTR
LD DE,msg_help_keypad
CALL BDOS
LD C,CON_WRITESTR
LD DE,msg_press_any_key
CALL BDOS
LD C,CON_READ
CALL BDOS
JP menu_4_keypad
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; OPTION 3: Configure the corsor keys mappings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
menu_3_cursor_keys:
; Show the cursor keys menu and select the option
LD C,CON_WRITESTR
LD DE,msg_menu_header
CALL BDOS
LD C,CON_WRITESTR
LD DE,msg_cursor_keys_menu
CALL BDOS
LD C,CON_READ
CALL BDOS
PUSH AF
LD C,CON_WRITESTR
LD DE,msg_new_line
CALL BDOS
POP AF
CP '1'
JP Z,menu_3_cursor_keys_1_help
CP escape
JP Z,main_menu
CP '2'
JP Z,menu_3_cursor_keys_2_change
JR menu_3_cursor_keys
menu_3_cursor_keys_2_change:
; Set the address of the keypad mapping to change
LD HL,bios_content_arrow_key_map
LD (key_config_base_address),HL
; Set the address of the previous menu
LD HL,menu_3_cursor_keys
LD (menu_escape_address),HL
; Show the menu
LD C,CON_WRITESTR
LD DE,msg_cursor_keys_change_menu
CALL BDOS
cursor_keys_sequence:
; Move through the cursor keys sequence
LD A,0x0
LD (current_selection),A
LD DE,cursor_keys_options_positions
CALL move_cursor
CALL key_selection_input
LD DE,cursor_keys_options_positions+5
CALL move_cursor
CALL key_selection_input
LD DE,cursor_keys_options_positions+10
CALL move_cursor
CALL key_selection_input
LD DE,cursor_keys_options_positions+15
CALL move_cursor
CALL key_selection_input
LD DE,cursor_keys_options_positions+20
CALL move_cursor
cursor_keys_selection_esc:
; The cursor is on top of the ESC option
LD C,CON_RAWIO
LD E,CON_RAWIO_PEEK_CHAR
CALL BDOS
CP no_key
JR Z,cursor_keys_selection_esc
CP line_feed
JP Z,cursor_keys_sequence
CP escape
JR NZ,cursor_keys_selection_esc
JP menu_3_cursor_keys
; Restart the sequence
JP cursor_keys_sequence
menu_3_cursor_keys_1_help:
; Show the help for cursor keys configuration
LD C,CON_WRITESTR
LD DE,msg_help_cursor_keys
CALL BDOS
LD C,CON_WRITESTR
LD DE,msg_press_any_key
CALL BDOS
LD C,CON_READ
CALL BDOS
JP menu_3_cursor_keys
msg_cursor_keys_change_menu:
db clear_screen
db "\r\n"
db "\r\n"
db " ---------------------------------\r\n"
db " : : : : :\r\n"
db " : ^ : : : <- : -> :\r\n"
db " : : : v : : :\r\n"
db " : : : : :\r\n"
db " : 0B : 0A : 08 : 0C :\r\n"
db " ---------------------------------\r\n"
db "\r\n"
db "\r\n"
db " Type the [ESC] key to return to the previous menu.\r\n"
db "\r\n"
db " Move the cursor to the key which you wish to change by pressing\r\n"
db " the [LINE FEED] key. The default HEXADECIMAL code will be the flashing number.\r\n"
db " Type the new HEXADECIMAL number you wish to assign to the key.\r\n"
db "\r\n"
db " You must type both digits to effect the change.\r\n\r\n$"
cursor_keys_options_positions:
db 0x1B,"='/",0xFF
db 0x1B,"='7",0xFF
db 0x1B,"='?",0xFF
db 0x1B,"='G",0xFF
db 0x1B,"=+2",0xFF
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; OPTION 2: Configure the write safe flag
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
menu_2_write_safe:
; Show the menu and select the option
LD C,CON_WRITESTR
LD DE,msg_menu_header
CALL BDOS
LD C,CON_WRITESTR
LD DE,msg_write_safe_menu
CALL BDOS
LD C,CON_READ
CALL BDOS
PUSH AF
LD C,CON_WRITESTR
LD DE,msg_new_line
CALL BDOS
POP AF
CP '1'
JP Z,menu_2_write_safe_1_help
CP '2'
JP Z,menu_2_write_safe_2_change
CP escape
JP Z,main_menu
JP menu_2_write_safe
menu_2_write_safe_2_change:
; Show the change menu
LD C,CON_WRITESTR
LD DE,msg_write_safe_change_menu
CALL BDOS
; There is a sequence of three states: YES, NO and ESC
write_safe_yes_option:
; We are on the YES option
LD DE,write_safe_options_position_yes
CALL move_cursor
write_safe_yes_option_loop:
LD C,CON_RAWIO
LD E,CON_RAWIO_PEEK_CHAR
CALL BDOS
CP no_key
JR Z,write_safe_yes_option_loop
CP line_feed
; Line feed: go to the NO option
JR Z,write_safe_no_option
CP escape
; Escape: go back to the menu
JP Z,menu_2_write_safe
CP return_key
JR NZ,write_safe_yes_option
; Return: select the YES option
LD A,write_safe_yes
LD (bios_content_config_byte),A
LD A,changes_pending_yes
LD (changes_pending),A
JP menu_2_write_safe
write_safe_no_option:
; We are on the NO option
LD DE,write_safe_options_position_no
CALL move_cursor
write_safe_no_option_loop:
LD C,CON_RAWIO
LD E,CON_RAWIO_PEEK_CHAR
CALL BDOS
CP no_key
JR Z,write_safe_no_option_loop
CP line_feed
; Line feed go to the ESC option
JR Z,write_safe_esc_option
CP escape
; Escape: go back to the menu
JR Z,menu_2_write_safe
CP return_key
JR NZ,write_safe_no_option
; Return: select the NO option
LD A,write_safe_no ; = changes_pending_yes
LD (bios_content_config_byte),A
LD (changes_pending),A
JP menu_2_write_safe
write_safe_esc_option:
; We are on the ESC option
LD DE,write_safe_options_position_esc
CALL move_cursor
write_safe_esc_option_loop:
LD C,CON_RAWIO
LD E,CON_RAWIO_PEEK_CHAR
CALL BDOS
CP no_key
JR Z,write_safe_esc_option_loop
CP escape
; Escape: go back to the menu
JP Z,menu_2_write_safe
CP line_feed
JP NZ,write_safe_esc_option
; Line feed: go to the YES option
JP write_safe_yes_option
menu_2_write_safe_1_help:
; Show the help for write safe flag
LD C,CON_WRITESTR
LD DE,msg_help_write_safe
CALL BDOS
LD C,CON_WRITESTR
LD DE,msg_press_any_key
CALL BDOS
LD C,CON_READ
CALL BDOS
JP menu_2_write_safe
msg_write_safe_change_menu:
db clear_screen
db "\r\n"
db "\r\n"
db "\r\n"
db "Yes I want Write Safe enabeled.\r\n"
db "\r\n"
db "No do not enable Write Safe.\tThis is the default mode on your KAYPRO II .\r\n"
db "\r\n"
db "Type the [ESC] key to return to the previous menu.\r\n"
db "\r\n"
db "\r\n"
db "Use the [LINE FEED] key to move the cursor to the mode\r\n"
db "which you wish to use and then type the [RETURN] key to\r\n"
db "enter your choice.\r\n"
db "\r\n"
db "**** PLEASE read the help file before you enable Write Safe. ****\r\n"
db "**** If you do not understand it ASK your dealer. ****\r\n$"
write_safe_options_position_yes:
db 0x1B,"=# ",0xFF
write_safe_options_position_no:
db 0x1B,"=% ",0xFF
write_safe_options_position_esc:
db 0x1B,"='+",0xFF
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; OPTION 1: Configure the IOBYTE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
menu_1_iobyte:
; Show the menu and select the option
LD C,CON_WRITESTR
LD DE,msg_menu_header
CALL BDOS
LD C,CON_WRITESTR
LD DE,msg_iobyte_menu
CALL BDOS
LD C,CON_READ
CALL BDOS
PUSH AF
LD C,CON_WRITESTR
LD DE,msg_new_line
CALL BDOS
POP AF
CP '1'
JP Z,menu_1_iobyte_1_help
CP '2'
JP Z,menu_1_iobyte_2_change
CP escape
JP Z,main_menu
JP menu_1_iobyte
menu_1_iobyte_2_change:
LD C,CON_WRITESTR
LD DE,msg_iobyte_change_menu
CALL BDOS
; Set to the address of the IOBYTE on the BIOS copy
LD HL,bios_content_io_byte
LD (key_config_base_address),HL
; Set the address of the previous menu
LD HL,menu_1_iobyte
LD (menu_escape_address),HL
iobyte_sequence_CON:
LD A,0x0
LD (current_selection),A
; Two options to set CON
LD DE,iobyte_options_position_CON_CRT
CALL move_cursor
CALL iobyte_selection_input
LD DE,iobyte_options_position_CON_TTY
CALL move_cursor
CALL iobyte_selection_input
iobyte_sequence_LST:
; Two options to set LST
LD DE,iobyte_options_position_LST_LPT
CALL move_cursor
CALL iobyte_selection_input
LD DE,iobyte_options_position_LST_TTY
CALL move_cursor
CALL iobyte_selection_input
iobyte_sequence_esc:
LD DE,iobyte_options_position_esc
CALL move_cursor
iobyte_selection_esc:
LD C,CON_RAWIO
LD E,CON_RAWIO_PEEK_CHAR
CALL BDOS
CP no_key
JR Z,iobyte_selection_esc
CP escape
; Escape: go back to the menu
JP Z,menu_1_iobyte
CP line_feed
; Line feed: restart the sequence
JR NZ,iobyte_selection_esc
JP iobyte_sequence_CON
iobyte_selection_input:
LD C,CON_RAWIO
LD E,CON_RAWIO_PEEK_CHAR
CALL BDOS
CP no_key
JR Z,iobyte_selection_input
CP escape
; No escape, process the key press
JR NZ,iobyte_process_key
; Escape: go back to the menu
POP HL
LD HL,(menu_escape_address)
JP (HL)
iobyte_process_key:
CP line_feed
JR NZ,iobyte_process_key_continue
; Line feed: continue the sequence
LD A,(current_selection)
INC A
LD (current_selection),A
RET
iobyte_process_key_continue:
CP return_key
JR NZ,iobyte_selection_input
; Return key: select the option
LD A,changes_pending_yes
LD (changes_pending),A
; Calculate the address of the function to call. The
; address is in:
; selection_id*2 + iobyte_options_handlers
LD A,(current_selection)
ADD A,A ; A = A*2
LD DE,0x0
LD E,A
LD HL,iobyte_options_handlers
ADD HL,DE
; Read low byte
LD E,(HL)
; Read high byte
INC HL
LD D,(HL)
EX DE,HL
LD DE,(key_config_base_address)
JP (HL)
iobyte_options_handlers:
dw iobyte_option_handler_CON_CRT
dw iobyte_option_handler_CON_TTY
dw iobyte_option_handler_LST_LPT
dw iobyte_option_handler_LST_TTY
iobyte_option_handler_CON_CRT:
LD A,(DE)
; iobyte CONSOLE = 01-CRT
RES 0x1,A
SET 0x0,A
LD (DE),A
; Continue on the LST options
LD HL,iobyte_sequence_LST
LD A,0x2
LD (current_selection),A
POP DE
JP (HL)
iobyte_option_handler_CON_TTY:
LD A,(DE)
; iobyte CONSOLE = 00-TTY
RES 0x0,A
RES 0x1,A
LD (DE),A
; Continue on the LST options (just the next one)
LD A,(current_selection)
INC A
LD (current_selection),A
RET
iobyte_option_handler_LST_LPT:
LD A,(DE)
; iobyte LIST = 10-LPT
RES 0x6,A
SET 0x7,A
LD (DE),A
; Continue on the ESC option
LD HL,iobyte_sequence_esc
JP (HL)
iobyte_option_handler_LST_TTY:
LD A,(DE)
; iobyte LIST = 00-TTY
RES 0x7,A
RES 0x6,A
LD (DE),A
; Continue on the ESC option
RET
menu_1_iobyte_1_help:
; Display the help
LD C,CON_WRITESTR
LD DE,msg_help_iobyte
CALL BDOS
LD C,CON_WRITESTR
LD DE,msg_press_any_key
CALL BDOS
LD C,CON_READ
CALL BDOS
JP menu_1_iobyte
msg_iobyte_change_menu:
db clear_screen
db "\r\n"
db "\r\n"
db "\tDefault settings\tPosibile changes\r\n"
db "\t----------------\t----------------\r\n"
db "\r\n"
db "\tCON:=CRT:\t\tCON:=TTY:\tType the [LINE FEED] key to \r\n"
db "\tLST:=LPT:\t\tLST:=TTY:\tmove the cursor to the mode \r\n"
db "\tPUN:=TTY:\t\t- none -\tyou wish to select.\r\n"
db "\tRDR:=TTY:\t\t- none -\tThen the RETURN key to enter\r\n"
db "\t\t\t\t\t\tyour selection.\r\n"
db "\tType the [ESC] key to return to the previous menu.\r\n"
db "\r\n"
db "* CON: If you chose CON:=TTY: then all input and output will be through the\r\n"
db "\tserial connector on the back of your KAYPRO II instead of through the\r\n"
db "\tkeyboard and the CRT.\r\n"
db "\r\n"
db "\r\n"
db "* LST:\tThis setting will decide wether the output directed at a printer\r\n"
db "\twill go through the LPT: (parallel connector) or to the\r\n"
db "\tTTY: (serial connector).\r\n$"
iobyte_options_position_CON_CRT:
db 0x1B,"=%,",0xFF
iobyte_options_position_CON_TTY:
db 0x1B,"=%D",0xFF
iobyte_options_position_LST_LPT:
db 0x1B,"=&,",0xFF
iobyte_options_position_LST_TTY:
db 0x1B,"=&D",0xFF
iobyte_options_position_esc:
db 0x1B,"=*3",0xFF
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; EXIT AND SAVE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
menu_exit:
LD A,(changes_pending)
CP changes_pending_no
; If changes are pending, ask the user if he wants to save them
JP NZ,save_changes_menu
exit_without_saving_changes:
; Reset the BIOS config in memory (not on disk)
; Why?
LD A,write_safe_no
LD (BIOS_config_byte),A
JP Z,RST0
save_changes_menu: