-
Notifications
You must be signed in to change notification settings - Fork 0
/
MOST.ASM
4621 lines (3811 loc) · 69.4 KB
/
MOST.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
; ����������������
; �ファイル ページャー MOST�
; � by Ken/ichiro(OPA) �
; ����������������
IDEAL
INCLUDE "STDIO.ASH"
INCLUDE "FILE.ASH"
INCLUDE "MOUSE.ASH"
INCLUDE "STRING.ASH"
INCLUDE "VRAM.ASH"
VSYNC_MARK EQU OFF ;画面右上に"VSYNC"と表示する
KEYBIOS_CALL EQU OFF ;キー入力をBIOSで行う
FDEBUG EQU OFF ;関数名を表示する
_VERSION EQU "1.19"
FNAMEBIT EQU 6 ;ファイル名ポインタ計算のシフト幅
MAXFILES EQU 96 ;最大ファイル数(2^FNAMEBITであること)
FNAMESIZE EQU 64 ;ファイル名バッファ幅
MAXLINE EQU 30000 ;1ファイルの最大行数
BACK EQU -1
NEXT EQU 1
TVRAMSIZE EQU 0C00H ;テキストVRAMの大きさ(ワード)
TMP = 0
PSTART
MACRO _$LBL NUM ;ここはデバッグ用のマクロなんだな
LABEL _$L&NUM BYTE ;FDEBUGを参照。
ENDM
MACRO _$PUT NUM
VPUTS 60,0,<AOF _$L&NUM>
ENDM
MACRO FUNCN NAME
IF FDEBUG
DEFS DATA
_$LBL %TMP
DB "&NAME& ",NULL
ENDS
PUSH AX
PUSH DX
_$PUT %TMP
POP DX
POP AX
TMP = TMP + 1
ENDIF
ENDM
;************************************************
DEFS CODE
START: SETSEG DS,DGROUP
MOV AX,ES
PUSH DS
POP ES
MOV [PSP],AX
GETARGS AX
CALL SETCOMSPEC
XOR DX,DX
MOV [EDITOR],DL
MOV [CLIP],DL
CALL SETMOSTENV ;AX = PSP SEG
MOV AH,1AH ; = SETDTA DTA
MOV DX,AOF DTA
DOSINT
MOV CX,MAXFILES ;現在行を初期化
MOV AX,1
MOV DI,AOF NOWTOPLINE
CLD
REP STOSW
MOV CX,10*2 ;マークを初期化
MOV AX,-1
MOV DI,AOF MARKBUF
; CLD
REP STOSW
XOR AX,AX
MOV [SEARCHDIR],AX
MOV [SEARCHWORD+2],AL
MOV AX,3
MOV DX,32767
MUSINT
XOR AX,AX
CMP DX,32767
JE @@1
MOV CX,320
MOV DX,200
MOV AX,4
MUSINT
MOV AX,65535
@@1: MOV [MOUSE],AX
MOV AX,4400H
XOR BX,BX ;BX<=STDIN
DOSINT
TEST DX,0000000010000000B
JNZ CHARDEV
INC [FILES] ;標準入力がブロックデバイス
MOV [FNAME+0],NULL
MOV [TABSIZES+0],8
JMP CHKARGV_OK
CHARDEV: XOR CX,CX
CMP [ARGC],CL
JNE CHKARGV
INC [ARGC]
MOV BX,AOF ARGV ;力技!!
MOV [WORD BX],(AOF ARGV)+2
MOV BX,[BX]
MOV [WORD BX],'*' ; '*' NULL
CHKARGV: CMP [ARGC],CL
JE CHKARGV_OK
PUSH CX
SHL CX,1
MOV BX,CX
MOV BX,[AOF ARGV+BX]
MOV AL,[BX]
; CMP AL,'-' ;スイッチ文字か
; JE ARG_SW
CMP AL,'/'
JNE ARG_FILE
ARG_SW: INC BX ;/?か
MOV AL,[BX]
CMP AL,'?'
JNE ARG_HELP
PUTS <AOF CREDIT>
PUTS <AOF USASE_MES>
CMP [MOUSE],NO
JE @@2
PUTS <AOF CANMOUSE_MES>
@@2: RETURN 1
ARG_HELP: CALL HELP ;/○の時
RETURN 1
ARG_FILE: STRCPY <AOF FWORK>,BX ;ファイル名の時
MOV SI,AOF FWORK
CALL GETFN ;ファイル名の*文字補完
STRCHR <AOF FWORK>,'.' ;拡張子があるか
TEST DI,DI
JNZ EXT_ARU
CMP [MOSTEXTNUM],0 ;補完候補がない
JE EXT_ARU
MOV DI,AOF FWORK ;文字列の最後をポイント
CALL _STRLEN
MOV [BYTE DI-1],'.'
XOR CX,CX ;拡張子補完
XOR AX,AX
EXT_LOOP: CMP CX,[MOSTEXTNUM]
JE EXT_END
PUSH AX ;あったか
PUSH CX ;いくつめか
PUSH DI ;ポインタ
MOV SI,CX
SHL SI,2
ADD SI,AOF MOSTEXT
STRCPY DI,SI
CALL FINDFILE
POP DI
POP CX
POP AX
JC @@1
INC AX
@@1: INC CX
JMP SHORT EXT_LOOP
EXT_END: DEC DI
MOV [BYTE DI],NULL
TEST AX,AX
JZ NOEX
JMP SHORT ARG_NEXT
EXT_ARU: CALL FINDFILE
JNC ARG_NEXT
NOEX: PUTS <AOF NO_EXIST_MES> ;1つも見つからない
PUTS <AOF FWORK>
PUTS <AOF KOKKA_MES>
RETURN 1
ARG_NEXT: POP CX
INC CX
JMP CHKARGV
CHKARGV_OK:
XOR AX,AX ;キーバッファビープの無視
MOV ES,AX
MOV BX,500H
MOV AL,[ES:BX]
OR AL,20H
MOV [ES:BX],AL
PUSH DS
POP ES
CALL PUSHTVRAM
CALL PUSH_VECT
DO: CALL DOFILE ;ここがメインか?
CMP AX,-1
JE MAIN_QUIT
MOV [FN],AX
JMP SHORT DO
MAIN_QUIT: ;正常終了
CALL POP_VECT
CALL POPTVRAM
CALL KEYFLUSH
RETURN 0
;************************************************
PROC FINDFILE NEAR ;ファイルを検索しリストに追加
STRCHR <AOF FWORK>,'*'
TEST DI,DI
JNZ WILDFILE
STRCHR <AOF FWORK>,'?'
TEST DI,DI
JNZ WILDFILE
H_OPEN <AOF FWORK>,00100000B ;ワイルドカード文字がない
JC ARG_NOEX
H_CLOSE AX
CMP [FILES],MAXFILES
JE FILE_END
MOV DI,AOF FNAME
MOV BX,[FILES]
PUSH BX
INC [FILES]
SHL BX,FNAMEBIT
ADD DI,BX
PUSH DI
STRCPY DI,<AOF FWORK>
POP DI
POP BX
CALL SETTABSIZES
CLC
RET
ARG_NOEX: STC
RET
WILDFILE: GETPATH MYBUF,FWORK ;ワイルドカード文字がある
F_SEARCH FWORK,06H
JC ARG_NOEX
ARG_EXIST: CMP [FILES],MAXFILES
JE FILE_END ;ファイルが多すぎる
MOV DI,AOF FNAME
MOV BX,[FILES]
PUSH BX
INC [FILES]
SHL BX,FNAMEBIT
ADD DI,BX
MOV SI,AOF MYBUF
STRCPY DI,SI
PUSH DI
MOV SI,AOF DTA + 1EH
STRCPY DI,SI
POP DI
POP BX
CALL SETTABSIZES
N_SEARCH
JNC ARG_EXIST
FILE_END: CLC
RET
ENDP
;************************************************
PROC DOFILE NEAR ;主役ルーチン
FUNCN DOFILE
CALL OPEN_FILE
MOV DX,AOF WAIT_MES
CALL PUTMES
; CALL VCLS30
CALL PUTPAGE
CALL PUTSTAT
LOOP_TOP:
CALL BGETC ;********************
FUNCN DO_LOOP
DO_LOOP2: MOV [INKEY],AX
CMP AX,3600H ;次ページ
JE D_N_PAGE
CMP AH,2BH
JNE KSEL_2
CMP [QFLAG],0 ;^Q が前にあれば
JE NOLAST ;ファイル末端
MOV AX,[NL]
ADD AX,[LINES2]
CMP AX,[FMAXLINE]
JNB PASS
CALL MARK0
MOV AX,[FMAXLINE]
CMP AX,[READMAXLINE]
JE @@4
MOV DX,AOF WAIT_MES
CALL PUTMES
MOV [BYTE TABCFLAG],0
MOV DX,[READMAXLINE]
@@3: MOV AX,[FMAXLINE]
INC AX
CMP DX,AX
JNBE @@4
PUSH DX
CALL READLINE
POP DX
INC DX
JMP SHORT @@3
@@4: MOV [BYTE TABCFLAG],1
MOV AX,[FMAXLINE]
INC AX
CMP AX,[LINES]
JNB @@5
MOV [NL],1
JMP SHORT @@6
@@5: MOV DX,[FMAXLINE]
SUB DX,[LINES2]
MOV [NL],DX
@@6: CALL PUTPAGE
MOV DX,[NL]
MOV [SEARCHLINE],DX
JMP DO_LOOP
NOLAST: CMP AX,2B03H
JNE KSEL_2
D_N_PAGE: MOV DX,[NL] ;次頁
ADD DX,[LINES2]
CMP DX,[FMAXLINE]
JNB PASS
MOV DX,[LINEH]
ADD [NL],DX
MOV DX,[NL]
ADD DX,[LINES2]
CMP DX,[READMAXLINE]
JBE @@N1
MOV CX,DX
MOV [BYTE TABCFLAG],0
MOV DX,[READMAXLINE]
@@N2: INC DX
PUSH CX
PUSH DX
CALL READLINE
POP DX
POP CX
CMP CX,DX
JNE @@N2
@@N1: MOV [BYTE TABCFLAG],1
CMP DX,[FMAXLINE]
JB @@N3
MOV DX,[FMAXLINE]
SUB DX,[LINES2]
MOV [NL],DX
@@N3: CALL PUTPAGE
MOV DX,[NL]
MOV [SEARCHLINE],DX
JMP DO_LOOP
KSEL_2: CMP AX,3700H ;前ページ
JE D_B_PAGE
CMP AH,13H
JNE KSEL_31
CMP [QFLAG],0
JE NOTOP
CMP [NL],1
JNE @@W1
MOV [SEARCHLINE],1
JMP PASS
@@W1: CALL MARK0
MOV AX,1
MOV [NL],AX
MOV [SEARCHLINE],AX
CALL PUTPAGE
JMP DO_LOOP
NOTOP: CMP AX,1312H
JNE KSEL_31
D_B_PAGE: CMP [NL],1
JE PASS
MOV DX,[NL]
SUB DX,[LINEH]
JBE @@@D1
CMP DX,1
JNBE @@@D2
@@@D1: MOV DX,1
@@@D2: MOV [NL],DX
CALL PUTPAGE
MOV DX,[NL]
MOV [SEARCHLINE],DX
JMP DO_LOOP
KSEL_31: CMP AX,0291AH ;^Z
JE S_N_LINES
; JMP SHORT KSEL_3
KSEL_3: MOV [S_FLAG1],0
CMP AX,2A18H ;次行
JE S_N_LINE1
CMP AX,3D00H
JNE KSEL_41
MOV [S_FLAG1],-1
CALL GETSFT
TEST AL,10H
JZ S_N_LINE1
S_N_LINES: XOR AL,AL
CALL S_NEXTLINE
MOV DX,[NL]
MOV [SEARCHLINE],DX
TEST AX,AX
JZ DO_LOOP
CALL KBHIT
TEST BH,BH
JZ S_N_LINES
JMP DO_LOOP
S_N_LINE1: CALL GETSFT
TEST AL,1
JNZ D_N_LINE
S_N_@1: MOV AL,[DEF_SPEED]
CALL S_NEXTLINE
CALL GETSFT
TEST AL,1
JNZ D_N_LINE
CMP [S_FLAG1],0
JE S_N_@2
TEST AL,16
JNZ S_N_LINES
S_N_@2: CALL CHKTBL_DOWN
JNZ S_N_@1
MOV DX,[NL]
MOV [SEARCHLINE],DX
JMP DO_LOOP
D_N_LINE: MOV AL,[DEF_SPEED+1]
CALL S_NEXTLINE
CALL GETSFT
TEST AL,1
JNZ D_N_LINE
MOV DX,[NL]
MOV [SEARCHLINE],DX
JMP DO_LOOP
KSEL_41: CMP AX,01117H ;^W
JE S_B_LINES
; JMP SHORT KSEL_4
KSEL_4: MOV [S_FLAG1],0
CMP AX,1205H ;前行
JE S_B_LINE1
CMP AX,3A00H
JNE KSEL_51
MOV [S_FLAG1],-1
CALL GETSFT
TEST AL,10H
JZ S_B_LINE1
S_B_LINES: XOR AL,AL
CALL S_BACKLINE
MOV DX,[NL]
MOV [SEARCHLINE],DX
TEST AX,AX
JZ DO_LOOP
CALL KBHIT
TEST BH,BH
JZ S_B_LINES
JMP DO_LOOP
S_B_LINE1: CALL GETSFT
TEST AL,1
JNZ D_B_LINE
S_B_@1: MOV AL,[DEF_SPEED]
CALL S_BACKLINE
CALL GETSFT
TEST AL,1
JNZ D_B_LINE
CMP [S_FLAG1],0
JE S_B_@2
TEST AL,16
JNZ S_B_LINES
S_B_@2: CALL CHKTBL_UP
JNZ S_B_@1
MOV DX,[NL]
MOV [SEARCHLINE],DX
JMP DO_LOOP
D_B_LINE: MOV AL,[DEF_SPEED+1]
CALL S_BACKLINE
CALL GETSFT
TEST AL,1
JNZ D_B_LINE
MOV DX,[NL]
MOV [SEARCHLINE],DX
JMP DO_LOOP
KSEL_51: CMP AX,03420H ;[SPACE]による次のページ
JNE KSEL_52
MOV AX,[LINES]
K5L: DEC AX
JZ K5E
PUSH AX
MOV AL,[DEF_SPEED]
CALL S_NEXTLINE
POP AX
JMP SHORT K5L
K5E: CALL KEYFLUSH
JMP DO_LOOP
KSEL_52: CMP AX,00F09H ;[TAB]
JNE KSEL_5
CALL CHGTAB
JMP DO_LOOP
KSEL_5: CMP AX,230AH ;マーク
JNE KSEL_6
CALL MARK
JMP DO_LOOP
KSEL_6: CMP AX,6400H ;ジャンプ
JNE KSEL_7
CALL JUMP
CMP AX,-1
JE DO_LOOP
CMP AX,[FN]
JNE JQ
CALL PUTPAGE
JMP DO_LOOP
JQ: PUSH AX
PUSH ES
H_CLOSE [HANDLE]
FREEMEM [HEAP]
POP ES
POP AX
RET
KSEL_7: CMP AX,3800H ;速度アップ
JNE KSEL_75
CALL GETSFT
MOV BX,AOF DEF_SPEED
TEST AL,10H
JZ @@U1
INC BX
INC BX
@@U1: TEST AL,01H
JZ @@U2
INC BX
@@U2:
MOV AL,[BX]
CMP AL,16
JAE DO_LOOP
SHL AL,1
MOV [BX],AL
JMP DO_LOOP
KSEL_75: CMP AX,3900H ;速度ダウン
JNE KSEL_85
CALL GETSFT
MOV BX,AOF DEF_SPEED
TEST AL,10H
JZ @@D1
INC BX
INC BX
@@D1: TEST AL,01H
JZ @@D2
INC BX
@@D2:
MOV AL,[BX]
CMP AL,1
JBE DO_LOOP
SHR AL,1
MOV [BX],AL
JMP DO_LOOP
KSEL_85: CMP [QFLAG],0 ;^QO (OS SHELL)
JE KSEL_8
CMP AH,18H
JE GOTOCH
KSEL_8: CMP AX,27 ;終了
JE OWARI
CMP AX,1C0DH
JNE KSEL_9
CALL GETSFT
TEST AL,1
JNZ GOTOEDIT
TEST AL,10H
JZ OWARI
GOTOCH: ;子プロセス
MOV BX,[NOW_FNAME]
CMP [BYTE BX],NULL
JE DO_LOOP
CALL CHILD
MOV AX,[FN]
RET
GOTOEDIT: CMP [EDITOR],NULL ;エディタ起動
JE DO_LOOP
MOV BX,[NOW_FNAME]
CMP [BYTE BX],NULL
JE DO_LOOP
CALL C_EDITOR
MOV AX,-1
CMP [EDIT_QUIT],OFF
JNE @@GOE
MOV AX,[FN]
@@GOE: RET
OWARI: CMP [QFLAG],0
JNE DO_LOOP
CALL CLOSE_FILE
MOV AX,-1
RET
KSEL_9: CMP AX,3E00H ;次のファイル
JNE KSEL_10
MOV AX,[FN]
INC AX
CMP AX,[FILES]
JNB PASS
CALL CLOSE_FILE
MOV AX,[FN]
INC AX
RET
KSEL_10: CMP AX,0AE00H ;前のファイル
JNE KSEL_11
MOV AX,[FN]
TEST AX,AX
JBE PASS
CALL CLOSE_FILE
MOV AX,[FN]
DEC AX
RET
KSEL_11: CMP AX,6300H ;[F02] ファイル選択
JNE KSEL_115
CALL SEL_FILE
JMP DO_LOOP
KSEL_115: CMP AX,6700H ;クリップ
JE CLP
CMP AH,19H ;P's keycode
JNE KSEL_12
CLP: CMP [CLIPFLAG],0
JE DO_LOOP ;DO 3連発
CALL DO_CLIP
JMP DO_LOOP
KSEL_12: CMP AX,0C1EH ;↓検索
JNE KSEL_13
CALL INPUTSTR
TEST AX,AX
JNZ S_F
CALL PUTPAGE
JMP DO_LOOP
S_F: CALL MARK0
MOV AX,NEXT
MOV [SEARCHDIR],AX
MOV AX,[NL]
MOV [SEARCHLINE],AX
CALL SEARCH
TEST AX,AX
JZ FIND_ERR
JMP FIND_OK
KSEL_13: CMP AX,0D1CH ;↑検索
JNE KSEL_14
CALL INPUTSTR
TEST AX,AX
JNZ S_B
CALL PUTPAGE
JMP DO_LOOP
S_B: CALL MARK0
MOV AX,BACK
MOV [SEARCHDIR],AX
MOV AX,[NL]
DEC AX
MOV [SEARCHLINE],AX
CALL SEARCH
TEST AX,AX
JZ FIND_ERR
JMP FIND_OK
KSEL_14: CMP AX,6600H ;同じ文字列を↓検索
JNE KSEL_15
MOV [SEARCHDIR],NEXT
JMP SHORT S_N
KSEL_15: CMP AX,8600H ;同じ文字列を↑検索
JNE KSEL_16
MOV [SEARCHDIR],BACK
S_N: MOV AL,[SEARCHWORD+2]
TEST AL,AL
JZ DO_LOOP
MOV AX,[SEARCHDIR]
ADD [SEARCHLINE],AX
CALL SEARCH
TEST AX,AX
JZ FIND_ERR
JMP FIND_OK
KSEL_16: CMP AX,3F00H ;ヘルプ
JNE KSEL_161
MOV AX,[LINES]
PUSH AX
CMP AX,20
JNE @@NOSET25
MOV [LINES],25
PUTS <AOF SET_L25>
@@NOSET25: CALL VHELP
MOV DX,AOF WAITING_MES
CALL PUTMES
CALL BGETC
POP AX
MOV [LINES],AX
CMP AX,20
JNE KS16_A
PUTS <AOF SET_L20>
KS16_A: CALL VCLS30
CALL SPLIT
CALL PUTPAGE
JMP DO_LOOP
KSEL_161: CMP AX,2107H ;^G 画面モード切り換え
JNE KSEL_17
CMP [LINES],30
JE DO_LOOP
MOV DX,[LINES]
CMP DX,20
JE @@162
MOV AX,20
MOV DX,AOF SET_L20
JMP SHORT @@163
@@162: MOV AX,25
MOV DX,AOF SET_L25
@@163: PUTS DX
CALL SETLINES
CALL PUTPAGE
JMP DO_LOOP
KSEL_17: CMP AH,0FFH ;マウス次の行
JNE KSEL_18
CALL S_NEXTLINE
MOV DX,[NL]
MOV [SEARCHLINE],DX
TEST AX,AX
JZ MOUSE_STOP
JMP DO_LOOP
KSEL_18: CMP AH,0FEH ;マウス前の行
JNE KSEL_19
CALL S_BACKLINE
MOV DX,[NL]
MOV [SEARCHLINE],DX
TEST AX,AX
JZ MOUSE_STOP
; JMP DO_LOOP
;*********************
KSEL_19:
DO_LOOP: CALL QCHK
JMP LOOP_TOP
PASS: CALL PUTSTAT ;コマンドが無視された
JMP DO_LOOP
MOUSE_STOP: MOV DX,200 ;マウスを真ん中に戻す
MOV AX,4
MUSINT
JMP DO_LOOP
FIND_OK: CALL PUTSEARCHPAGE ;検索成功
CALL BGETC
MOV [INKEY],AX
PUSH AX
CALL QCHK
MOV AX,V_WHITE
CALL SEARCH_ATT
POP AX
JMP DO_LOOP2
FIND_ERR: CALL PUTPAGE ;検索失敗
PUTC BEEP
MOV DX,AOF CANT_FIND_MES
CALL PUTMES
JMP DO_LOOP
ENDP
;************************************************
PROC QCHK NEAR ;^Q フラグの設定
FUNCN QCHK
PUSH ES
PUSH AX
MOV AX,0A000H
MOV ES,AX
CMP [INKEY],1011H
JNE NO_Q
CMP [QFLAG],0
JNE NO_Q
MOV [QFLAG],-1
MOV AX,'^Q'
JMP SHORT @@QQ
NO_Q: MOV [QFLAG],0
MOV AX,' '
@@QQ: MOV [ES:(30*80+60)*2],AH
MOV [ES:(30*80+61)*2],AL
POP AX
POP ES
RET
ENDP
;************************************************
PROC PUTPAGE NEAR ;1ページ表示
FUNCN PUTPAGE
XOR CX,CX
MOV DI,[NL]
PUTP_LOOP: PUSH CX
PUSH DI
MOV DX,DI
CALL READLINE
POP DI
POP CX
VCLL CX
VPUTS 0,CL,<AOF MYBUF>
INC DI
INC CX
CMP CL,[BYTE LINES]
JB PUTP_LOOP
; CALL SPLIT
CALL ATTSET
CALL PUTSTAT
RET
ENDP
;************************************************
PROC NEXTLINE NEAR ;次の行表示
FUNCN NEXTLINE
MOV DX,[NL]
ADD DX,[LINES]
PUSH DX
CALL READLINE
MOV [SS_ROLL],1
CALL VSYNCWAIT
POP DX
INC [NL]
MOV AX,[LINES]
DEC AX
VCLL AX
VPUTS 0,AL,<AOF MYBUF>
CALL ATTSET
CALL PUTSTAT
MOV AX,-1
RET
ENDP
;************************************************
PROC S_NEXTLINE NEAR ;スムース次の行
FUNCN S_NEXTLINE
MOV DX,[NL]
ADD DX,[LINES2]
INC DX
CMP DX,[FMAXLINE]
JNA @@X
MOV DX,[NL]
CMP DX,0
JG S_NXL_END
@@X: TEST AL,AL
JNZ @@2
CALL GETSFT