-
Notifications
You must be signed in to change notification settings - Fork 5
/
BASIC1.1.asm
15213 lines (13271 loc) · 758 KB
/
BASIC1.1.asm
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
;;***Main.asm
;#dialect=RASM
;Current progress:
;(Mostly) fully reverse engineered as far as **TK
;'Unassembled'[1] Amstrad CPC6128 BASIC 1.1 Source Code
;[1] 'Unassembled' meaning that this code can be modified and reassembled.
;(As far as I can tell) all links etc have been converted to labels etc in
;such a way that the code can be assembled at a different target address
;and still function correctly (excepting code which must run at a specific
;address).
;Based on the riginal commented disassembly at:
; http://cpctech.cpc-live.com/docs/basic.asm
;There are two versions of this file: a single monolithic version and
;one which has been broken out into separate 'includes'. The latter may
;prove better for modification, assembly and re-use. The former for
;exploration and reverse engineering.
;For more details see: https://github.com/Bread80/Amstrad-CPC-BASIC-Source
;and http://Bread80.com
;;***Initialisation.asm
;;=======
;;BASIC 1.1
org $c000 ;##LIT##
include "Includes/JumpblockLow.asm"
include "Includes/JumpblockMain6128.asm"
include "Includes/MemoryBASIC.asm"
;ROM header
defb $80 ; foreground rom
defb $01 ;mark
defb $02 ;version
defb $00 ;modification
defw rsx_name_table ; name table
;On entry
;DE = first byte of available memory
;HL=last byte of memory not used by BASIC
;BC=last byte of memory not used by firmware
ld sp,$c000 ;{{c006:3100c0}} ##LIT##
call KL_ROM_WALK ;{{c009:cdcbbc}} firmware function: kl rom walk
call initialise_memory_model;{{c00c:cd3ff5}}
jp c,RESET_ENTRY ;{{c00f:da0000}} ; reboot if not enough memory
xor a ;{{c012:af}}
ld (program_line_redundant_spaces_flag_),a;{{c013:3200ac}}
ld hl,version_string_message;{{c016:2133c0}} startup message "BASIC 1.1"
call init_streams_and_display_ASCIIZ_string;{{c019:cd7dc3}}
call zero_current_line_address;{{c01c:cdaade}}
call clear_errors_and_set_resume_addr_to_current;{{c01f:cd37cb}}
call REAL_init_random_number_generator;{{c022:cdbbbd}} maths function - initialise random number generator?
call cancel_AUTO_mode ;{{c025:cddec0}}
call reset_basic ;{{c028:cd45c1}}
ld de,$00f0 ;{{c02b:11f000}} DE = 240
call SYMBOL_AFTER ;{{c02e:cde9f7}} symbol after 240
jr REPL_Read_Eval_Print_Loop;{{c031:1825}}
;;= version string message
version_string_message: ;{{Addr=$c033 Data Calls/jump count: 0 Data use count: 1}}
defb " BASIC 1.1",10,10,0
;;=rsx name table
rsx_name_table: ;{{Addr=$c040 Data Calls/jump count: 0 Data use count: 1}}
defb "BASI","C"+$80 ; |BASIC
defb 0 ;end of rsx name table
;;***ProgramEntry.asm
;;<< PROGRAM ENTRY ROUTINES
;;< REPL loop, EDIT, AUTO, NEW, CLEAR (INPUT)
;;========================================================================
;; command EDIT
;EDIT <line number>
;Edit the given line number
command_EDIT: ;{{Addr=$c046 Code Calls/jump count: 0 Data use count: 1}}
call eval_line_number_or_error;{{c046:cd48cf}}
ret nz ;{{c049:c0}}
_command_edit_2: ;{{Addr=$c04a Code Calls/jump count: 1 Data use count: 0}}
ld sp,$c000 ;{{c04a:3100c0}} ##LIT##
call find_line_or_error;{{c04d:cd5ce8}}
call detokenise_line_atHL_to_buffer;{{c050:cd54e2}} convert line to string (detokenise)
call edit_text_in_BASIC_input_area_and_display_new_line;{{c053:cd01cb}} edit
jr c,REPL_execute_or_insert_in_program;{{c056:385f}} (+$5f)
;;========================================
;;REPL Read Eval Print Loop
;;REPL = Read, Evaluate, Print, Loop
;;This is the command line!
REPL_Read_Eval_Print_Loop: ;{{Addr=$c058 Code Calls/jump count: 10 Data use count: 0}}
ld sp,$c000 ;{{c058:3100c0}} ##LIT##
call reset_string_stack_and_fn_params;{{c05b:cd66c1}}
call get_current_line_number;{{c05e:cdb5de}}
call c,SOUND_HOLD ;{{c061:dcb6bc}} firmware function: sound hold
call ON_BREAK_CONT ;{{c064:cdd0c4}} ON BREAK CONT
call turn_display_on ;{{c067:cdd0c3}}
ld a,(program_protection_flag_);{{c06a:3a2cae}} program protection flag
;; do a new
or a ;{{c06d:b7}}
call nz,reset_basic ;{{c06e:c445c1}}
ld a,(ERR__Error_No) ;{{c071:3a90ad}} ; error number
sub $02 ;{{c074:d602}}
jr nz,display_ready_message;{{c076:2009}} (+$09)
ld (ERR__Error_No),a ;{{c078:3290ad}}
call get_resume_line_number;{{c07b:cdaacb}}
ex de,hl ;{{c07e:eb}}
jr c,_command_edit_2 ;{{c07f:38c9}} (-$37)
;;=display ready message
display_ready_message: ;{{Addr=$c081 Code Calls/jump count: 1 Data use count: 0}}
ld hl,ready_message ;{{c081:21d7c0}} "Ready" message
call output_ASCIIZ_string;{{c084:cd8bc3}} ; display 0 terminated string
;;-----------------------------------------------------------------
;;=REPL input loop
REPL_input_loop: ;{{Addr=$c087 Code Calls/jump count: 3 Data use count: 0}}
call zero_current_line_address;{{c087:cdaade}}
_repl_input_loop_1: ;{{Addr=$c08a Code Calls/jump count: 1 Data use count: 0}}
ld a,(AUTO_active_flag_);{{c08a:3a01ac}} AUTO active?
or a ;{{c08d:b7}}
jr z,REPL_get_input ;{{c08e:281f}} (+$1f)
;;next AUTO line number
call next_AUTO_line_number;{{c090:cd0dc1}}
jr nc,REPL_Read_Eval_Print_Loop;{{c093:30c3}} (-$3d)
call skip_space_tab_or_line_feed;{{c095:cd4dde}} skip space, lf or tab
call parse_line_number ;{{c098:cdcfee}}
jr nc,REPL_no_line_number;{{c09b:300a}}
call skip_space_tab_or_line_feed;{{c09d:cd4dde}} skip space, lf or tab
or a ;{{c0a0:b7}}
scf ;{{c0a1:37}}
call z,find_line ;{{c0a2:cc64e8}}
jr nc,_repl_input_loop_1;{{c0a5:30e3}} (-$1d)
;;=REPL no line number
REPL_no_line_number: ;{{Addr=$c0a7 Code Calls/jump count: 1 Data use count: 0}}
call nc,cancel_AUTO_mode;{{c0a7:d4dec0}}
ld hl,BASIC_input_area_for_lines_;{{c0aa:218aac}}
jr REPL_execute_or_insert_in_program;{{c0ad:1808}} (+$08)
;;-----------------------------------------------------------------
;;=REPL get input
REPL_get_input: ;{{Addr=$c0af Code Calls/jump count: 2 Data use count: 0}}
call input_text_to_BASIC_input_area;{{c0af:cdf9ca}} edit
jr nc,REPL_get_input ;{{c0b2:30fb}} (-$05)
call output_new_line ;{{c0b4:cd98c3}} ; new text line
;;=REPL execute or insert in program
REPL_execute_or_insert_in_program:;{{Addr=$c0b7 Code Calls/jump count: 2 Data use count: 0}}
call skip_space_tab_or_line_feed;{{c0b7:cd4dde}} skip space, lf or tab
or a ;{{c0ba:b7}}
jr z,REPL_input_loop ;{{c0bb:28ca}} (-$36) empty buffer - loop
call parse_line_number ;{{c0bd:cdcfee}}
jr nc,REPL_tokenise_and_execute;{{c0c0:300b}} (+$0b) no line number so execute
call copy_all_strings_vars_to_strings_area_if_not_in_strings_area;{{c0c2:cd4dfb}}
call prob_tokenise_and_insert_line;{{c0c5:cda5e7}}
call reset_exec_data ;{{c0c8:cd8fc1}}
jr REPL_input_loop ;{{c0cb:18ba}} (-$46)
;;+-----------------------------------------------------------------
;;REPL tokenise and execute
REPL_tokenise_and_execute: ;{{Addr=$c0cd Code Calls/jump count: 1 Data use count: 0}}
call tokenise_a_BASIC_line;{{c0cd:cda4df}}
call ON_BREAK_STOP ;{{c0d0:cdd3c4}} ON BREAK STOP
dec hl ;{{c0d3:2b}}
jp execute_statement_atHL;{{c0d4:c360de}}
;;========================================================================
;; ready message
ready_message: ;{{Addr=$c0d7 Data Calls/jump count: 0 Data use count: 1}}
defb "Ready",10,0
;;========================================================================
;; cancel AUTO mode
cancel_AUTO_mode: ;{{Addr=$c0de Code Calls/jump count: 4 Data use count: 0}}
xor a ;{{c0de:af}}
jr set_auto_mode_B ;{{c0df:1805}} (+$05)
;;+------------------
;; set AUTO mode
set_AUTO_mode: ;{{Addr=$c0e1 Code Calls/jump count: 2 Data use count: 0}}
ld (AUTO_line_number),hl;{{c0e1:2202ac}} current auto mode
ld a,$ff ;{{c0e4:3eff}} auto mode active
;;=set auto mode
;A=ff=active, A=0=inactive
set_auto_mode_B: ;{{Addr=$c0e6 Code Calls/jump count: 1 Data use count: 0}}
ld (AUTO_active_flag_),a;{{c0e6:3201ac}} current auto mode
ret ;{{c0e9:c9}}
;;==================================================================
;; command AUTO
;AUTO [<line number>],[<increment>]
;Generate line numbers. Values default to 10
command_AUTO: ;{{Addr=$c0ea Code Calls/jump count: 0 Data use count: 1}}
ld de,$000a ;{{c0ea:110a00}} default line number is 10
jr z,_command_auto_3 ;{{c0ed:2802}} no parameters
cp $2c ;{{c0ef:fe2c}} ',' no first parameter
_command_auto_3: ;{{Addr=$c0f1 Code Calls/jump count: 1 Data use count: 0}}
call nz,eval_line_number_or_error;{{c0f1:c448cf}} read initial line number, if given
push de ;{{c0f4:d5}}
ld de,$000a ;{{c0f5:110a00}} default increment is 10
call next_token_if_prev_is_comma;{{c0f8:cd41de}}
call c,eval_line_number_or_error;{{c0fb:dc48cf}} read increment if given
call error_if_not_end_of_statement_or_eoln;{{c0fe:cd37de}}
ex de,hl ;{{c101:eb}}
ld (AUTO_increment_step),hl;{{c102:2204ac}} AUTO increment step
pop hl ;{{c105:e1}}
call set_AUTO_mode ;{{c106:cde1c0}} store line number to create or edit
pop bc ;{{c109:c1}}
jp REPL_input_loop ;{{c10a:c387c0}}
;;=-----------------------------------------------------------------
;;next AUTO line number
next_AUTO_line_number: ;{{Addr=$c10d Code Calls/jump count: 1 Data use count: 0}}
ld hl,(AUTO_line_number);{{c10d:2a02ac}}
ex de,hl ;{{c110:eb}}
push de ;{{c111:d5}}
call detokenise_line_from_line_number;{{c112:cd38e2}}
call cancel_AUTO_mode ;{{c115:cddec0}}
call edit_text_in_BASIC_input_area_and_display_new_line;{{c118:cd01cb}} edit
pop de ;{{c11b:d1}}
ret nc ;{{c11c:d0}}
;;========================================================================
push hl ;{{c11d:e5}}
ld hl,(AUTO_increment_step);{{c11e:2a04ac}} AUTO increment step
add hl,de ;{{c121:19}}
call nc,set_AUTO_mode ;{{c122:d4e1c0}}
pop hl ;{{c125:e1}}
scf ;{{c126:37}}
ret ;{{c127:c9}}
;;========================================================================
;; command NEW
;NEW
;Completely clears the current contents of memory
command_NEW: ;{{Addr=$c128 Code Calls/jump count: 0 Data use count: 1}}
ret nz ;{{c128:c0}}
call reset_basic ;{{c129:cd45c1}}
jp REPL_Read_Eval_Print_Loop;{{c12c:c358c0}}
;;=============================================================================
;; command CLEAR, CLEAR INPUT
;CLEAR
;Clear all variables and files
command_CLEAR_CLEAR_INPUT: ;{{Addr=$c12f Code Calls/jump count: 0 Data use count: 1}}
cp $a3 ;{{c12f:fea3}} token for "INPUT"
jr z,CLEAR_INPUT ;{{c131:280c}} CLEAR INPUT
push hl ;{{c133:e5}}
call reset_variable_data;{{c134:cd78c1}}
call close_streams_and_reset_angle_mode_string_stack_and_fn_params;{{c137:cd5fc1}}
call reset_exec_data ;{{c13a:cd8fc1}}
pop hl ;{{c13d:e1}}
ret ;{{c13e:c9}}
;;========================================================================
;; CLEAR INPUT
;CLEAR INPUT ??
CLEAR_INPUT: ;{{Addr=$c13f Code Calls/jump count: 1 Data use count: 0}}
call get_next_token_skipping_space;{{c13f:cd2cde}} get next token skipping space
jp KM_FLUSH ;{{c142:c33dbd}} firmware function: km flush
;;========================================================================
;; reset basic
;; clear all memory and reset
reset_basic: ;{{Addr=$c145 Code Calls/jump count: 3 Data use count: 0}}
ld hl,(address_of_start_of_ROM_lower_reserved_a);{{c145:2a62ae}} input buffer/start of BASIC memory
ex de,hl ;{{c148:eb}}
ld hl,(HIMEM_) ;{{c149:2a5eae}} HIMEM
call BC_equal_HL_minus_DE;{{c14c:cde4ff}} BC = HL-DE
ld h,d ;{{c14f:62}}
ld l,e ;{{c150:6b}}
inc de ;{{c151:13}}
xor a ;{{c152:af}}
ld (hl),a ;{{c153:77}}
ldir ;{{c154:edb0}}
ld (program_protection_flag_),a;{{c156:322cae}}
call clear_all_variables;{{c159:cdead5}}
call clear_program_and_variables_etc;{{c15c:cd6fc1}}
;;=close streams and reset angle mode, string stack and fn params
close_streams_and_reset_angle_mode_string_stack_and_fn_params:;{{Addr=$c15f Code Calls/jump count: 1 Data use count: 0}}
call close_input_and_output_streams;{{c15f:cd00d3}} close input and output streams
;;=reset angle mode, string stack and fn params
reset_angle_mode_string_stack_and_fn_params:;{{Addr=$c162 Code Calls/jump count: 1 Data use count: 0}}
xor a ;{{c162:af}}
call SET_ANGLE_MODE ;{{c163:cd97bd}} maths: set angle mode
;;=reset string stack and fn params
reset_string_stack_and_fn_params: ;{{Addr=$c166 Code Calls/jump count: 1 Data use count: 0}}
call clear_string_stack;{{c166:cdccfb}} string catenation
call clear_FN_params_data;{{c169:cd20da}}
jp select_txt_stream_zero;{{c16c:c3a1c1}}
;;-------------------------------------------------------------------
;;=clear program and variables etc
clear_program_and_variables_etc: ;{{Addr=$c16f Code Calls/jump count: 3 Data use count: 0}}
call command_TROFF ;{{c16f:cdc5de}} ; TROFF
call cancel_AUTO_mode ;{{c172:cddec0}}
call reset_zone_and_clear_program;{{c175:cd89c1}}
;;=reset variable data
reset_variable_data: ;{{Addr=$c178 Code Calls/jump count: 3 Data use count: 0}}
push bc ;{{c178:c5}}
push hl ;{{c179:e5}}
call empty_strings_area;{{c17a:cd8cf6}}
call clear_all_variables;{{c17d:cdead5}}
call defreal_a_to_z ;{{c180:cd38d6}}
call reset_variable_types_and_pointers;{{c183:cd4dea}}
pop hl ;{{c186:e1}}
pop bc ;{{c187:c1}}
ret ;{{c188:c9}}
;;-----------------------------------------------------------------
;;=reset zone and clear program
reset_zone_and_clear_program: ;{{Addr=$c189 Code Calls/jump count: 2 Data use count: 0}}
call set_zone_13 ;{{c189:cd99f2}}
call clear_program ;{{c18c:cd61e7}} ; ?
;;-----------------------------------------------------------------
;;=reset exec data
;Appears to be a 'light' reset after running and before editing etc.
reset_exec_data: ;{{Addr=$c18f Code Calls/jump count: 7 Data use count: 0}}
call clear_error_handlers;{{c18f:cdaccc}}
call clear_last_RUN_error_line_address;{{c192:cd7ecc}}
call initialise_event_system;{{c195:cda3c9}}
call prob_clear_execution_stack;{{c198:cd4ff6}}
call clear_DEFFN_list_and_reset_variable_types_and_pointers;{{c19b:cd0ed6}}
jp reset_READ_pointer;{{c19e:c3d4dc}}
;;***Streams.asm
;;<< (TEXT) STREAM MANAGEMENT
;;=========================================
;;select txt stream zero
select_txt_stream_zero: ;{{Addr=$c1a1 Code Calls/jump count: 4 Data use count: 0}}
xor a ;{{c1a1:af}}
call swap_input_streams;{{c1a2:cdb3c1}}
xor a ;{{c1a5:af}}
;;=select txt stream
select_txt_stream: ;{{Addr=$c1a6 Code Calls/jump count: 7 Data use count: 0}}
push hl ;{{c1a6:e5}}
push af ;{{c1a7:f5}}
cp $08 ;{{c1a8:fe08}}
call c,TXT_STR_SELECT ;{{c1aa:dcb4bb}} firmware function: txt str select
pop af ;{{c1ad:f1}}
ld hl,current_output_stream_;{{c1ae:2106ac}}
jr swap_stream_number_atHL;{{c1b1:1804}} (+$04)
;;==========================================
;;swap input streams
swap_input_streams: ;{{Addr=$c1b3 Code Calls/jump count: 3 Data use count: 0}}
push hl ;{{c1b3:e5}}
ld hl,current_input_stream_;{{c1b4:2107ac}}
;;=swap stream number atHL
swap_stream_number_atHL: ;{{Addr=$c1b7 Code Calls/jump count: 1 Data use count: 0}}
push de ;{{c1b7:d5}}
ld e,a ;{{c1b8:5f}}
ld a,(hl) ;{{c1b9:7e}}
ld (hl),e ;{{c1ba:73}}
pop de ;{{c1bb:d1}}
pop hl ;{{c1bc:e1}}
ret ;{{c1bd:c9}}
;;-----------------------------------------------------------------
;;=get output stream
get_output_stream: ;{{Addr=$c1be Code Calls/jump count: 4 Data use count: 0}}
ld a,(current_output_stream_);{{c1be:3a06ac}}
cp $08 ;{{c1c1:fe08}}
ret ;{{c1c3:c9}}
;;-----------------------------------------------------------------
;;=get input stream
;returns Carry clear if stream is on screen, Carry set if not on screen (i.e. a file)
get_input_stream: ;{{Addr=$c1c4 Code Calls/jump count: 7 Data use count: 0}}
ld a,(current_input_stream_);{{c1c4:3a07ac}}
cp $09 ;{{c1c7:fe09}}
ret ;{{c1c9:c9}}
;;-----------------------------------------------------------------
;;=eval and select txt stream
eval_and_select_txt_stream: ;{{Addr=$c1ca Code Calls/jump count: 1 Data use count: 0}}
call eval_and_validate_stream_number_if_present;{{c1ca:cdfbc1}}
jr select_txt_stream ;{{c1cd:18d7}} (-$29)
;;=exec following on evalled stream and swap back
exec_following_on_evalled_stream_and_swap_back:;{{Addr=$c1cf Code Calls/jump count: 2 Data use count: 0}}
call eval_and_validate_stream_number_if_present;{{c1cf:cdfbc1}}
jr exec_TOS_on_stream_and_swap_back;{{c1d2:1818}} (+$18)
;;=swap both streams, exec TOS and swap back
swap_both_streams_exec_TOS_and_swap_back:;{{Addr=$c1d4 Code Calls/jump count: 2 Data use count: 0}}
call eval_and_validate_stream_number_if_present;{{c1d4:cdfbc1}}
call swap_input_streams;{{c1d7:cdb3c1}}
pop bc ;{{c1da:c1}}
push af ;{{c1db:f5}}
call get_input_stream ;{{c1dc:cdc4c1}}
call exec_BC_on_stream_and_swap_back;{{c1df:cdedc1}}
pop af ;{{c1e2:f1}}
jr swap_input_streams;{{c1e3:18ce}} (-$32)
;;===============================================
;;=exec TOS on evalled stream and swap back
exec_TOS_on_evalled_stream_and_swap_back:;{{Addr=$c1e5 Code Calls/jump count: 8 Data use count: 0}}
call eval_and_validate_stream_number_if_present;{{c1e5:cdfbc1}}
cp $08 ;{{c1e8:fe08}}
jr nc,raise_Improper_Argument_error;{{c1ea:3031}} (+$31)
;;=exec TOS on stream and swap back
exec_TOS_on_stream_and_swap_back: ;{{Addr=$c1ec Code Calls/jump count: 2 Data use count: 0}}
pop bc ;{{c1ec:c1}}
;;=exec BC on stream and swap back
exec_BC_on_stream_and_swap_back: ;{{Addr=$c1ed Code Calls/jump count: 1 Data use count: 0}}
call select_txt_stream ;{{c1ed:cda6c1}}
push af ;{{c1f0:f5}}
ld a,(hl) ;{{c1f1:7e}}
cp $2c ;{{c1f2:fe2c}} ','
call JP_BC ;{{c1f4:cdfcff}} JP (BC)
pop af ;{{c1f7:f1}}
jp select_txt_stream ;{{c1f8:c3a6c1}}
;;======================================
;;=eval and validate stream number if present
eval_and_validate_stream_number_if_present:;{{Addr=$c1fb Code Calls/jump count: 4 Data use count: 0}}
ld a,(hl) ;{{c1fb:7e}}
cp $23 ;{{c1fc:fe23}} #
ld a,$00 ;{{c1fe:3e00}}
ret nz ;{{c200:c0}}
call eval_and_validate_stream_number;{{c201:cd0dc2}}
push af ;{{c204:f5}}
call next_token_if_prev_is_comma;{{c205:cd41de}}
call nc,error_if_not_end_of_statement_or_eoln;{{c208:d437de}}
pop af ;{{c20b:f1}}
ret ;{{c20c:c9}}
;;====================================
;;=eval and validate stream number
eval_and_validate_stream_number: ;{{Addr=$c20d Code Calls/jump count: 3 Data use count: 0}}
call next_token_if_equals_inline_data_byte;{{c20d:cd25de}}
defb $23 ;Inline token to test "#"
ld a,$0a ;{{c211:3e0a}}
;;=check byte value in range.
;; if not give "Improper Argument" error message
;; In: A = max value
;; Out: A = value if in range
check_byte_value_in_range: ;{{Addr=$c213 Code Calls/jump count: 6 Data use count: 0}}
push bc ;{{c213:c5}}
push de ;{{c214:d5}}
ld b,a ;{{c215:47}}
call eval_expr_as_byte_or_error;{{c216:cdb8ce}} get number and check it's less than 255
cp b ;{{c219:b8}} compare to value we want
pop de ;{{c21a:d1}}
pop bc ;{{c21b:c1}}
ret c ;{{c21c:d8}} ; return if less than value
;; greater than value
;;=raise Improper Argument error
raise_Improper_Argument_error: ;{{Addr=$c21d Code Calls/jump count: 2 Data use count: 0}}
jp Error_Improper_Argument;{{c21d:c34dcb}} Error: Improper Argument
;;========================================================================
;; check number is less than 2
check_number_is_less_than_2: ;{{Addr=$c220 Code Calls/jump count: 5 Data use count: 0}}
ld a,$02 ;{{c220:3e02}}
jr check_byte_value_in_range;{{c222:18ef}} check value is in range
;;***Screen.asm
;;<< SCREEN HANDLING FUNCTIONS
;;========================================================================
;; command PEN
;PEN [#<stream expression>,]<masked ink>
;Sets the ink to use for the foreground of the given window.
command_PEN: ;{{Addr=$c224 Code Calls/jump count: 0 Data use count: 1}}
call exec_TOS_on_evalled_stream_and_swap_back;{{c224:cde5c1}}
ld bc,TXT_SET_PEN ;{{c227:0190bb}} firmware function: txt set pen
call nz,_command_paper_2;{{c22a:c43fc2}}
call next_token_if_prev_is_comma;{{c22d:cd41de}}
ret nc ;{{c230:d0}}
call check_number_is_less_than_2;{{c231:cd20c2}} check number is less than 2
ld bc,TXT_SET_BACK ;{{c234:019fbb}} firmware function: txt set back
jr _command_paper_3 ;{{c237:1809}}
;;========================================================================
;; command PAPER
;PAPER [#<stream expression>,]<masked ink>
;Sets the ink to use for the background of the given window.
command_PAPER: ;{{Addr=$c239 Code Calls/jump count: 0 Data use count: 1}}
call exec_TOS_on_evalled_stream_and_swap_back;{{c239:cde5c1}}
ld bc,TXT_SET_PAPER ;{{c23c:0196bb}} firmware function: txt set paper
_command_paper_2: ;{{Addr=$c23f Code Calls/jump count: 1 Data use count: 0}}
call check_value_is_less_than_16;{{c23f:cd71c2}} check parameter is less than 16
_command_paper_3: ;{{Addr=$c242 Code Calls/jump count: 1 Data use count: 0}}
push hl ;{{c242:e5}}
call JP_BC ;{{c243:cdfcff}} JP (BC)
pop hl ;{{c246:e1}}
ret ;{{c247:c9}}
;;=========================================================================
;; command BORDER
;BORDER <colour>[,colour]
;Set the border colour. If two values are supplied border will flash between them
command_BORDER: ;{{Addr=$c248 Code Calls/jump count: 0 Data use count: 1}}
call eval_one_or_two_numbers_less_than_32;{{c248:cd62c2}} one or two numbers each less than 32
;; B,C = numbers which are the inks
push hl ;{{c24b:e5}}
call SCR_SET_BORDER ;{{c24c:cd38bc}} firmware function: scr set border
pop hl ;{{c24f:e1}}
ret ;{{c250:c9}}
;;=========================================================================
;; command INK
;INK <ink number>,<colour>[,<colour>]
;Specifies the colour for an ink. If two colours are given the ink flashes between the two.
command_INK: ;{{Addr=$c251 Code Calls/jump count: 0 Data use count: 1}}
call check_value_is_less_than_16;{{c251:cd71c2}} check parameter is less than 16
push af ;{{c254:f5}}
call next_token_if_comma;{{c255:cd15de}} check for comma
call eval_one_or_two_numbers_less_than_32;{{c258:cd62c2}} one or two numbers each less than 32
;; B,C = numbers which are the inks
pop af ;{{c25b:f1}}
push hl ;{{c25c:e5}}
call SCR_SET_INK ;{{c25d:cd32bc}} firmware function: scr set ink
pop hl ;{{c260:e1}}
ret ;{{c261:c9}}
;;=========================================================================
;; eval one or two numbers less than 32
;; used to get ink values
;;
;; first number in B, second number in C
eval_one_or_two_numbers_less_than_32:;{{Addr=$c262 Code Calls/jump count: 2 Data use count: 0}}
call _eval_one_or_two_numbers_less_than_32_4;{{c262:cd6ac2}}
ld b,c ;{{c265:41}}
call next_token_if_prev_is_comma;{{c266:cd41de}}
ret nc ;{{c269:d0}}
_eval_one_or_two_numbers_less_than_32_4:;{{Addr=$c26a Code Calls/jump count: 1 Data use count: 0}}
ld a,$20 ;{{c26a:3e20}}
call check_byte_value_in_range;{{c26c:cd13c2}} check value is in range
ld c,a ;{{c26f:4f}}
ret ;{{c270:c9}}
;;========================================================================
;; check value is less than 16
check_value_is_less_than_16: ;{{Addr=$c271 Code Calls/jump count: 5 Data use count: 0}}
ld a,$10 ;{{c271:3e10}}
jr check_byte_value_in_range;{{c273:189e}} check value is in range
;;========================================================================
;; command MODE
;MODE <integer expression>
;Changes screen mode
command_MODE: ;{{Addr=$c275 Code Calls/jump count: 0 Data use count: 1}}
ld a,$03 ;{{c275:3e03}}
call check_byte_value_in_range;{{c277:cd13c2}} check value is in range
;; A = mode
push hl ;{{c27a:e5}}
call SCR_SET_MODE ;{{c27b:cd0ebc}} firmware function: scr set mode
pop hl ;{{c27e:e1}}
ret ;{{c27f:c9}}
;;=============================================================================
;; command CLS
;CLS [#<stream expression>]
;Clear the screen window for a stream
;Stream expression must be 0..7. If no value is given stream #0 is cleared.
command_CLS: ;{{Addr=$c280 Code Calls/jump count: 0 Data use count: 1}}
call exec_TOS_on_evalled_stream_and_swap_back;{{c280:cde5c1}}
push hl ;{{c283:e5}}
call TXT_CLEAR_WINDOW ;{{c284:cd6cbb}} firmware function: txt clear window
pop hl ;{{c287:e1}}
ret ;{{c288:c9}}
;;=eval stream param, and exec TOS, and swap back
eval_stream_param_and_exec_TOS_and_swap_back:;{{Addr=$c289 Code Calls/jump count: 2 Data use count: 0}}
call eval_and_validate_stream_number;{{c289:cd0dc2}}
cp $08 ;{{c28c:fe08}}
jr nc,raise_Improper_Argument_error;{{c28e:308d}} (-$73)
;;=exec TOS on stream and swap back
exec_tos_on_stream_and_swap_back_B:;{{Addr=$c290 Code Calls/jump count: 1 Data use count: 0}}
push af ;{{c290:f5}}
call next_token_if_close_bracket;{{c291:cd1dde}} check for close bracket
pop af ;{{c294:f1}}
jp exec_TOS_on_stream_and_swap_back;{{c295:c3ecc1}}
;;========================================================================
;; function COPYCHR$
function_COPYCHR: ;{{Addr=$c298 Code Calls/jump count: 0 Data use count: 1}}
call eval_stream_param_and_exec_TOS_and_swap_back;{{c298:cd89c2}}
call TXT_RD_CHAR ;{{c29b:cd60bb}} firmware function: txt rd char
jp create_single_char_or_null_string;{{c29e:c378fa}}
;;========================================================================
;; function VPOS
;VPOS(#<stream expression>)
;Returns the vertical position of the given stream
function_VPOS: ;{{Addr=$c2a1 Code Calls/jump count: 0 Data use count: 1}}
call eval_stream_param_and_exec_TOS_and_swap_back;{{c2a1:cd89c2}}
push hl ;{{c2a4:e5}}
call get_Y_cursor_position;{{c2a5:cdc7c2}} get y cursor position
jr _function_pos_4 ;{{c2a8:180a}} (+$0a)
;;========================================================================
;; function POS
;POS(#<stream expression>)
;Established the position of the specified stream.
;1. Screen streams #0..#7: Returns the current x coordinate. 1 is the left column
;2. Printer stream #8: Returns the current position across the printer, counting
;all character codes greater than &1F. 1 is the left column
;3. Cassette output stream #9: Returns the number of printing characters since the last
;carriage return, where printing characters are those > &1F. 1 is the leftmost column.
function_POS: ;{{Addr=$c2aa Code Calls/jump count: 0 Data use count: 1}}
call eval_and_validate_stream_number;{{c2aa:cd0dc2}}
call exec_tos_on_stream_and_swap_back_B;{{c2ad:cd90c2}}
push hl ;{{c2b0:e5}}
call get_xpos_of_output_stream;{{c2b1:cdb9c2}}
_function_pos_4: ;{{Addr=$c2b4 Code Calls/jump count: 1 Data use count: 0}}
call store_A_in_accumulator_as_INT;{{c2b4:cd32ff}}
pop hl ;{{c2b7:e1}}
ret ;{{c2b8:c9}}
;;========================================================================
;;=get xpos of output stream
;stream can be stream, file or printer
get_xpos_of_output_stream: ;{{Addr=$c2b9 Code Calls/jump count: 4 Data use count: 0}}
call get_output_stream ;{{c2b9:cdbec1}}
ld a,(printer_stream_current_x_position_);{{c2bc:3a08ac}}
ret z ;{{c2bf:c8}}
ld a,(file_output_stream_current_line_position);{{c2c0:3a0aac}}
ret nc ;{{c2c3:d0}}
jp get_x_cursor_position;{{c2c4:c3ecc3}}
;;========================================================================
;; get Y cursor position
get_Y_cursor_position: ;{{Addr=$c2c7 Code Calls/jump count: 2 Data use count: 0}}
call TXT_GET_CURSOR ;{{c2c7:cd78bb}} firmware function: txt get cursor
call TXT_VALIDATE ;{{c2ca:cd87bb}} firmware function: txt validate
ld a,l ;{{c2cd:7d}}
ret ;{{c2ce:c9}}
;;========================================================================
;;=pos is xpos in D in range
pos_is_xpos_in_D_in_range: ;{{Addr=$c2cf Code Calls/jump count: 2 Data use count: 0}}
call get_output_stream ;{{c2cf:cdbec1}}
jr z,poss_get_screen_width;{{c2d2:280d}} (+$0d)
ret nc ;{{c2d4:d0}}
push de ;{{c2d5:d5}}
push hl ;{{c2d6:e5}}
call TXT_GET_WINDOW ;{{c2d7:cd69bb}} firmware function: txt get window
ld a,d ;{{c2da:7a}}
sub h ;{{c2db:94}}
inc a ;{{c2dc:3c}}
pop hl ;{{c2dd:e1}}
pop de ;{{c2de:d1}}
scf ;{{c2df:37}}
ret ;{{c2e0:c9}}
;;=poss get screen width
poss_get_screen_width: ;{{Addr=$c2e1 Code Calls/jump count: 1 Data use count: 0}}
ld a,(WIDTH_) ;{{c2e1:3a09ac}}
cp $ff ;{{c2e4:feff}}
ret ;{{c2e6:c9}}
;;=poss validate xpos in D
poss_validate_xpos_in_D: ;{{Addr=$c2e7 Code Calls/jump count: 2 Data use count: 0}}
push hl ;{{c2e7:e5}}
ld h,a ;{{c2e8:67}}
call pos_is_xpos_in_D_in_range;{{c2e9:cdcfc2}}
ccf ;{{c2ec:3f}}
jr c,_poss_validate_xpos_in_d_15;{{c2ed:380e}} (+$0e)
ld l,a ;{{c2ef:6f}}
call get_xpos_of_output_stream;{{c2f0:cdb9c2}}
dec a ;{{c2f3:3d}}
scf ;{{c2f4:37}}
jr z,_poss_validate_xpos_in_d_15;{{c2f5:2806}} (+$06)
add a,h ;{{c2f7:84}}
ccf ;{{c2f8:3f}}
jr nc,_poss_validate_xpos_in_d_15;{{c2f9:3002}} (+$02)
dec a ;{{c2fb:3d}}
cp l ;{{c2fc:bd}}
_poss_validate_xpos_in_d_15: ;{{Addr=$c2fd Code Calls/jump count: 3 Data use count: 0}}
pop hl ;{{c2fd:e1}}
ret ;{{c2fe:c9}}
;;========================================================================
;; command LOCATE
;LOCATE [#<stream expression>,]<x coordinate>,<y coordinate>
;Positions the text cursor in the specified stream, default 0.
;Valid coordinates are 0..255. (1,1) is the top-left or the window.
command_LOCATE: ;{{Addr=$c2ff Code Calls/jump count: 0 Data use count: 1}}
call exec_TOS_on_evalled_stream_and_swap_back;{{c2ff:cde5c1}}
call eval_two_params_minus_1_to_D_E;{{c302:cd51c3}}
push hl ;{{c305:e5}}
ex de,hl ;{{c306:eb}}
inc h ;{{c307:24}}
inc l ;{{c308:2c}}
call TXT_SET_CURSOR ;{{c309:cd75bb}} firmware function: txt set cursor
pop hl ;{{c30c:e1}}
ret ;{{c30d:c9}}
;;========================================================================
;; command WINDOW, WINDOW SWAP
;WINDOW [#<stream expression>,]<left>,<right>,<top>,<bottom>
;Defines a text window. Values can be 1..255
;WINDOW SWAP <stream expression>,<stream expression>
;Swaps two text windows
command_WINDOW_WINDOW_SWAP: ;{{Addr=$c30e Code Calls/jump count: 0 Data use count: 1}}
cp $e7 ;{{c30e:fee7}}
jr z,window_swap ;{{c310:2816}} (+$16)
call exec_TOS_on_evalled_stream_and_swap_back;{{c312:cde5c1}}
call eval_two_params_minus_1_to_D_E;{{c315:cd51c3}}
push de ;{{c318:d5}}
call next_token_if_comma;{{c319:cd15de}} check for comma
call eval_two_params_minus_1_to_D_E;{{c31c:cd51c3}}
ex (sp),hl ;{{c31f:e3}}
ld a,d ;{{c320:7a}}
ld d,l ;{{c321:55}}
ld l,a ;{{c322:6f}}
call TXT_WIN_ENABLE ;{{c323:cd66bb}} firmware function: txt win enable
pop hl ;{{c326:e1}}
ret ;{{c327:c9}}
;;========================================================================
;;=window swap
window_swap: ;{{Addr=$c328 Code Calls/jump count: 1 Data use count: 0}}
call get_next_token_skipping_space;{{c328:cd2cde}} get next token skipping space
call eval_number_less_than_8;{{c32b:cd3ec3}} get number less than 8
ld c,a ;{{c32e:4f}}
call next_token_if_prev_is_comma;{{c32f:cd41de}}
ld a,$00 ;{{c332:3e00}}
call c,eval_number_less_than_8;{{c334:dc3ec3}} get number less than 8
ld b,a ;{{c337:47}}
push hl ;{{c338:e5}}
call TXT_SWAP_STREAMS ;{{c339:cdb7bb}} firmware function: txt swap streams
pop hl ;{{c33c:e1}}
ret ;{{c33d:c9}}
;;=eval number less than 8
eval_number_less_than_8: ;{{Addr=$c33e Code Calls/jump count: 2 Data use count: 0}}
ld a,$08 ;{{c33e:3e08}}
jp check_byte_value_in_range;{{c340:c313c2}} check value is in range
;;========================================================================
;; command TAG
;TAG [#<stream expression>]
;Enables text at graphics on the given stream
;Text is printed with the top left pixel at the graphics cursor position.
;Control characters have to effect and print as symbols
command_TAG: ;{{Addr=$c343 Code Calls/jump count: 0 Data use count: 1}}
call exec_TOS_on_evalled_stream_and_swap_back;{{c343:cde5c1}}
ld a,$ff ;{{c346:3eff}}
jr _command_tagoff_2 ;{{c348:1804}} (+$04)
;;========================================================================
;; command TAGOFF
;TAGOFF [#<stream expression>]
;Cancels TAG for the given stream
command_TAGOFF: ;{{Addr=$c34a Code Calls/jump count: 0 Data use count: 1}}
call exec_TOS_on_evalled_stream_and_swap_back;{{c34a:cde5c1}}
xor a ;{{c34d:af}}
_command_tagoff_2: ;{{Addr=$c34e Code Calls/jump count: 1 Data use count: 0}}
jp TXT_SET_GRAPHIC ;{{c34e:c363bb}} firmware function: txt set graphic
;;-------------------------------------------------------------------------
;;=eval two params minus 1 to D E
eval_two_params_minus_1_to_D_E: ;{{Addr=$c351 Code Calls/jump count: 3 Data use count: 0}}
call eval_param_minus_1_to_E;{{c351:cd58c3}}
ld d,e ;{{c354:53}}
call next_token_if_comma;{{c355:cd15de}} check for comma
;;--------------------------------------------------------------------------
;;=eval param minus 1 to E
eval_param_minus_1_to_E: ;{{Addr=$c358 Code Calls/jump count: 1 Data use count: 0}}
push de ;{{c358:d5}}
call eval_expr_as_int_less_than_256;{{c359:cdc3ce}}
pop de ;{{c35c:d1}}
ld e,a ;{{c35d:5f}}
dec e ;{{c35e:1d}}
ret ;{{c35f:c9}}
;;========================================================================
;; command CURSOR
command_CURSOR: ;{{Addr=$c360 Code Calls/jump count: 0 Data use count: 1}}
call exec_TOS_on_evalled_stream_and_swap_back;{{c360:cde5c1}}
jr z,_command_cursor_6;{{c363:280a}} (+$0a)
call check_number_is_less_than_2;{{c365:cd20c2}} check number is less than 2
or a ;{{c368:b7}}
call z,TXT_CUR_OFF ;{{c369:cc84bb}} firmware function: txt cur off
call nz,TXT_CUR_ON ;{{c36c:c481bb}} firmware function: txt cur on
_command_cursor_6: ;{{Addr=$c36f Code Calls/jump count: 1 Data use count: 0}}
call next_token_if_prev_is_comma;{{c36f:cd41de}}
ret nc ;{{c372:d0}}
call check_number_is_less_than_2;{{c373:cd20c2}} check number is less than 2
or a ;{{c376:b7}}
jp z,TXT_CUR_DISABLE ;{{c377:ca7ebb}} firmware function: txt cur disable
jp TXT_CUR_ENABLE ;{{c37a:c37bbb}} firmware function: txt cur enable
;;***StreamIO.asm
;;<< STREAM I/O
;;< Low level I/O via streams, WIDTH and EOF
;;=====================================================
;; init streams and display ASCIIZ string
init_streams_and_display_ASCIIZ_string:;{{Addr=$c37d Code Calls/jump count: 1 Data use count: 0}}
push hl ;{{c37d:e5}}
ld hl,$8401 ;{{c37e:210184}}
ld (printer_stream_current_x_position_),hl;{{c381:2208ac}}
call set_file_output_stream_line_pos_to_1;{{c384:cd69c4}}
call select_txt_stream_zero;{{c387:cda1c1}}
pop hl ;{{c38a:e1}}
;;+----------------------------------------------------
;;output ASCIIZ string
output_ASCIIZ_string: ;{{Addr=$c38b Code Calls/jump count: 7 Data use count: 0}}
push af ;{{c38b:f5}}
push hl ;{{c38c:e5}}
_output_asciiz_string_2: ;{{Addr=$c38d Code Calls/jump count: 1 Data use count: 0}}
ld a,(hl) ;{{c38d:7e}} get character
inc hl ;{{c38e:23}}
or a ;{{c38f:b7}}
call nz,output_char ;{{c390:c4a0c3}} ; display text char
jr nz,_output_asciiz_string_2;{{c393:20f8}} (-$08)
pop hl ;{{c395:e1}}
pop af ;{{c396:f1}}
ret ;{{c397:c9}}
;;=======================================================
;; output new line
output_new_line: ;{{Addr=$c398 Code Calls/jump count: 15 Data use count: 0}}
push af ;{{c398:f5}}
ld a,$0a ;{{c399:3e0a}}
call output_char ;{{c39b:cda0c3}} ; display text char
pop af ;{{c39e:f1}}
ret ;{{c39f:c9}}
;;=======================================================
;; output char
output_char: ;{{Addr=$c3a0 Code Calls/jump count: 12 Data use count: 0}}
push af ;{{c3a0:f5}}
push bc ;{{c3a1:c5}}
call output_char_or_new_line;{{c3a2:cda8c3}}
pop bc ;{{c3a5:c1}}
pop af ;{{c3a6:f1}}
ret ;{{c3a7:c9}}
;;-=======================================================
;;=output char or new line
output_char_or_new_line: ;{{Addr=$c3a8 Code Calls/jump count: 1 Data use count: 0}}
cp $0a ;{{c3a8:fe0a}}
jr nz,output_raw_char;{{c3aa:200c}} (+$0c)
call get_output_stream ;{{c3ac:cdbec1}}
jp z,printer_new_line;{{c3af:caf5c3}}
jp nc,write_crlf_to_file;{{c3b2:d231c4}} write cr, lf to file
jp display_cr_lf ;{{c3b5:c3e2c3}}
;;-------------------------------------------------------------------
;;=output raw char
;A=char
output_raw_char: ;{{Addr=$c3b8 Code Calls/jump count: 5 Data use count: 0}}
push af ;{{c3b8:f5}}
push bc ;{{c3b9:c5}}
ld c,a ;{{c3ba:4f}}
call output_raw_char_to_current_stream;{{c3bb:cdc1c3}}
pop bc ;{{c3be:c1}}
pop af ;{{c3bf:f1}}
ret ;{{c3c0:c9}}
;;-------------------------------------------------------------------
;;=output raw char to current stream
;C=char
;stream could be printer, file or display
output_raw_char_to_current_stream:;{{Addr=$c3c1 Code Calls/jump count: 1 Data use count: 0}}
ld a,(current_output_stream_);{{c3c1:3a06ac}}
cp $08 ;{{c3c4:fe08}}
jp z,output_char_to_printer;{{c3c6:cafcc3}}
jp nc,write_char_to_file;{{c3c9:d238c4}} write char to file
ld a,c ;{{c3cc:79}}
jp do_txt_output ;{{c3cd:c3e9c3}}
;;========================================================================
;;=turn display on
;and move cursor to new line if not at start of line
turn_display_on: ;{{Addr=$c3d0 Code Calls/jump count: 3 Data use count: 0}}
xor a ;{{c3d0:af}} output letters using text functions
call TXT_SET_GRAPHIC ;{{c3d1:cd63bb}} firmware function: txt set graphic
xor a ;{{c3d4:af}} opaque characters
push hl ;{{c3d5:e5}}
call TXT_SET_BACK ;{{c3d6:cd9fbb}} firmware function: txt set back
pop hl ;{{c3d9:e1}}
call TXT_VDU_ENABLE ;{{c3da:cd54bb}} firmware function: txt vdu enable
call get_x_cursor_position;{{c3dd:cdecc3}} get x cursor position
dec a ;{{c3e0:3d}}
ret z ;{{c3e1:c8}}
;;=display cr lf
display_cr_lf: ;{{Addr=$c3e2 Code Calls/jump count: 1 Data use count: 0}}
ld a,$0d ;{{c3e2:3e0d}} print CR,LF
call do_txt_output ;{{c3e4:cde9c3}}
ld a,$0a ;{{c3e7:3e0a}}
;;=do txt output
do_txt_output: ;{{Addr=$c3e9 Code Calls/jump count: 2 Data use count: 0}}
jp TXT_OUTPUT ;{{c3e9:c35abb}} firmware function: txt output
;;========================================================================
;; get x cursor position
get_x_cursor_position: ;{{Addr=$c3ec Code Calls/jump count: 2 Data use count: 0}}
push bc ;{{c3ec:c5}}
push hl ;{{c3ed:e5}}
call get_Y_cursor_position;{{c3ee:cdc7c2}}
ld a,h ;{{c3f1:7c}}
pop hl ;{{c3f2:e1}}
pop bc ;{{c3f3:c1}}
ret ;{{c3f4:c9}}
;;========================================================================
;;=printer new line
printer_new_line: ;{{Addr=$c3f5 Code Calls/jump count: 1 Data use count: 0}}
ld c,$0d ;{{c3f5:0e0d}}
call output_char_to_printer;{{c3f7:cdfcc3}}
ld c,$0a ;{{c3fa:0e0a}}
;;=output char to printer
output_char_to_printer: ;{{Addr=$c3fc Code Calls/jump count: 2 Data use count: 0}}
push hl ;{{c3fc:e5}}
ld hl,(printer_stream_current_x_position_);{{c3fd:2a08ac}}
call process_new_lines_for_file_or_printer;{{c400:cd11c4}}
ld (printer_stream_current_x_position_),a;{{c403:3208ac}}
pop hl ;{{c406:e1}}
;;=print char
print_char: ;{{Addr=$c407 Code Calls/jump count: 1 Data use count: 0}}
ld a,c ;{{c407:79}}
call MC_PRINT_CHAR ;{{c408:cd2bbd}} firmware function: mc print char
ret c ;{{c40b:d8}} printed? (otherwise port busy)
call test_for_break_key;{{c40c:cd72c4}} key - abort if break