forked from ResistanceVault/preservation-abbs20
-
Notifications
You must be signed in to change notification settings - Fork 0
/
transfer.asm
1078 lines (1023 loc) · 22.6 KB
/
transfer.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
*****************************************************************
*
* NAME
* transfer.asm
*
* DESCRIPTION
* transfer rutines
*
* AUTHOR
* Geir Inge Høsteng
*
* $Id: transfer.asm 1.1 1995/06/24 10:32:07 geirhos Exp geirhos $
*
* MODIFICATION HISTORY
* $Log: transfer.asm $
;; Revision 1.1 1995/06/24 10:32:07 geirhos
;; Initial revision
;;
*
*****************************************************************
NOLIST
include 'first.i'
; IFND __M68
include 'exec/types.i'
include 'devices/serial.i'
include 'intuition/intuition.i'
; ENDC
include 'asm.i'
include 'bbs.i'
include 'fse.i'
include 'node.i'
XDEF sendfile
XDEF dosendGogR
XDEF doreciveGogR
XDEF receivefile
XDEF shortprotocname
XDEF protoclname
XDEF protocolisbatch
XDEF docheckGogR
XREF deletefile
XREF dosbase
XREF exebase
XREF findcleanup
XREF initserread
XREF parseprotocol
XREF protocolinitstr
XREF protokollbaser
XREF readlineprompt
XREF setupa4a5
XREF startyourtext
XREF stopserread
XREF strcopy
XREF traprotocoltext
XREF writecontext
XREF writetext
XREF writetexto
XREF receivetext
XREF trfstatl1text
XREF trfstatl2text
XREF logdlmsgtext
XREF fjernpath
XREF calctime
XREF getfilelen
XREF konverter
XREF konverterw
XREF errorstext
XREF writelogtexttimed
XREF cpstext
XREF serwritestringdo
XREF sendtext
XREF logulmsgtext
XREF toaysopupload
XREF writetosysoptextd
XREF findfirst
XREF findnext
XREF waitseroutput
XREF memcopylen
XREF serwritestringlen
XREF divl
XREF writeconchar
XREF cleartoEOLtext
XREF writecontextrfill
XREF serreadstring
;nocarrier = 1
IFND DEMO
; a0 = filename
sendfile
push a2/a3/d2
movea.l a0,a2
move.b #-1,(DlUlstatus,NodeBase)
moveq.l #0,d2
move.w d2,(tmpword,NodeBase) ; sletter antall errors
move.l d2,(tmpwhilenotinparagon,NodeBase) ; sletter antall bytes
tst.b (readlinemore,NodeBase) ; er det mere innput ?
bne.b 8$ ; jepp. da er det protokoll
move.b (Protocol+CU,NodeBase),d2
beq.b 8$
subq.l #1,d2
bra.b 5$ ; Vi har en protokoll
8$ lea (traprotocoltext),a0
bsr readlineprompt
beq 9$
bsr parseprotocol
beq.b 8$
move.l d0,d2
5$ lsl.l #2,d2
lea (startyourtext),a0
bsr writetext
lea (protoclname),a0
movea.l (0,a0,d2.w),a0
bsr writetext
lea (receivetext),a0
bsr writetexto
move.w (Userbits+CU,NodeBase),d0
btst #USERB_G_R,d0
beq.b 4$
movea.l a2,a0
move.l d2,d0
lsr.l #2,d0
bsr dosendGogR
4$ move.b #0,(DlUlstatus,NodeBase) ; Setter error
lea (protokollinitstr),a0 ; init string
movea.l (0,a0,d2.w),a0
bsr setup_xprio
; beq.s 9$ ; kan aldri forekomme
movea.l d0,a3
bsr stopserread
movea.l (dosbase),a6
lea (tmpdatestamp,NodeBase),a0 ; lagrer start tiden
move.l a0,d1
jsrlib DateStamp
lea (protokollbaser),a0
adda.l d2,a0
movea.l (a0),a6
movea.l a3,a0
push d2-d7/a2-a6
jsr (_LVOXProtocolSetup,a6)
pop d2-d7/a2-a6
tst.l d0
beq 1$
tst.b (Tinymode,NodeBase) ; skriver ut header (hvis ikke
bne.b 6$ ; tiny mode)
move.l a6,-(a7)
movea.l (exebase),a6
lea (trfstatl1text),a0
bsr writecontext
lea (trfstatl2text),a0
bsr writecontext
movea.l (a7)+,a6
6$ moveq.l #0,d0 ; sletter lagringsstedet
move.l d0,(tmpval,NodeBase)
movea.l a3,a0
move.l a2,(xpr_filename,a0)
push d2-d7/a2-a6
jsr (_LVOXProtocolSend,a6)
pop d2-d7/a2-a6
move.l a6,-(sp)
tst.l d0
beq.b 2$
move.b #1,(DlUlstatus,NodeBase)
movea.l (dosbase),a6 ; Sjekker tiden nu
lea (lastchartime,NodeBase),a0
move.l a0,d1
jsrlib DateStamp
movea.l (exebase),a6
lea (logdlmsgtext),a0
moveq.l #0,d0 ; dette er Download
bsr skrivuldllog
2$ move.l (tmpval,NodeBase),d1 ; lukker filen hvis den er åpen
beq.b 3$
movea.l (dosbase),a6
jsrlib Close
3$ moveq.l #0,d0 ; sletter igjen
move.l d0,(tmpval,NodeBase)
movea.l (sp)+,a6
movea.l a3,a0
move.l #0,(xpr_filename,a0)
push d2-d7/a2-a6
jsr (_LVOXProtocolCleanup,a6)
pop d2-d7/a2-a6
1$ movea.l (exebase),a6
; move.l a3,a0
; bsr clear_xprio (ingenting å gjøre...)
9$ pop a2/a3/d2
bsr initserread
moveq.l #0,d0
move.l d0,(SerTotOut,NodeBase) ; empty counter
move.b (batch,NodeBase),d1
beq.b 91$
move.b d0,(batch,NodeBase)
bsr findcleanup
91$ tst.b (DlUlstatus,NodeBase)
rts
XREF _Write_user_CPS
;skrivr feks:
;09:35 Downloaded file: (Z) thor21_bbs.lha (1719 cps 1100 s 100 err)
;a2 = filename
;a0 = logfile text
;d0 = 0 -> Download, 1 = upload, 2 = ungrab (ikke skriv i tosysop fila)
skrivuldllog
push d3/a3/d4/d5
link.w a3,#-160
move.l a3,d4
move.l d0,d5 ; husker hva det var
movea.l a0,a3
move.l sp,a1 ; bruker dette til å lagre str'en i
move.b #'(',(a1)+
lea (shortprotocname),a0
adda.l d2,a0
bsr strcopy
move.b #')',(-1,a1)
move.b #' ',(a1)+
movea.l a2,a0
move.l a1,d3
bsr fjernpath
movea.l d3,a1
bsr strcopy
move.b #' ',(-1,a1)
move.b #0,(a1) ; avslutter srtringen for sikkerhetsskyld
move.l a1,d3 ; husker hvor vi var i str'en
lea (lastchartime,NodeBase),a1 ; tiden nå
lea (tmpdatestamp,NodeBase),a0 ; tiden for start av DL.
bsr calctime ; beregner antall sekunder
move.l d0,d2 ; husker antall sek.
beq 3$ ; egentlig umulig, men..
move.b (batch,NodeBase),d0 ; er det batch ?
beq.b 5$ ; nei, finn størrelsen
move.l (tmpwhilenotinparagon,NodeBase),d0
beq.b 3$ ; egentlig umulig, men ...
bra.b 4$
5$ movea.l a2,a0
move.l (ULfilenamehack,NodeBase),d0
beq.b 2$
movea.l d0,a0
2$ bsr getfilelen
beq.b 3$
4$ movea.l d3,a0 ; henter ut igjen
move.b #'(',(a0)+
divu.w d2,d0 ; beregner cps'en
bsr konverterw
movea.l a0,a1
move.b #' ',(a1)+
lea (cpstext),a0
bsr strcopy
subq.l #1,a1
movea.l a1,a0
move.l d2,d0
bsr konverter
movea.l a0,a1
; move.b #' ',(a1)+
; move.b #'s',(a1)+
lea (secstext),a0
bsr strcopy
subq.l #1,a1
move.w (tmpword,NodeBase),d0 ; noen error's ?
beq.b 1$ ; nei, ikke noen utskrift
move.b #' ',(-1,a1)
movea.l a1,a0
jsr (konverterw)
move.b #' ',(a0)+
movea.l a0,a1
lea (errorstext),a0
bsr strcopy
subq.l #1,a1
1$ move.b #')',(a1)+
move.b #0,(a1)
3$ movea.l a3,a0
move.l sp,a1
bsr writelogtexttimed
cmp.b #1,d5 ; vanlig upload ?
bne.b 6$ ; nei
move.l sp,a1 ; skriver til tosysop fila
lea (toaysopupload),a0
bsr writetosysoptextd
6$ move.l d4,a3
; jsr (_Write_user_CPS)
unlk a3
pop d3/a3/d4/d5
rts
dosendGogR
movem.l d0,-(a7)
bsr fjernpath
move.l a0,-(a7)
lea (tmptext,NodeBase),a1
lea (vipparamkode),a0
bsr strcopy
subq.l #1,a1
movea.l (a7)+,a0
bsr strcopy
move.b #13,(-1,a1)
move.l (a7)+,d0
mulu.w #6,d0
lea (recivefilekoder),a0
adda.l d0,a0
bsr strcopy
lea (tmptext,NodeBase),a0
bsr serwritestringdo
rts
doreciveGogR
movem.l d0,-(a7)
bsr fjernpath
move.l a0,-(a7)
lea (tmptext,NodeBase),a1
lea (vipparamkode),a0
bsr strcopy
subq.l #1,a1
movea.l (a7)+,a0
bsr strcopy
move.b #13,(-1,a1)
move.l (a7)+,d0
mulu.w #6,d0
lea (sendfilekoder),a0
adda.l d0,a0
bsr strcopy
lea (tmptext,NodeBase),a0
bra serwritestringdo
docheckGogR
tst.w (CommsPort+Nodemem,NodeBase)
beq.b 9$
lea (checkG_Rkode),a0
bsr serwritestringdo
lea (tmptext,NodeBase),a0
moveq.l #0,d0
move.l #1000000,d1 ; 1 sek timeout mellom tegnene
jsr (serreadstring)
movea.l a0,a1
lea (logfilemenutext),a0
bsr writelogtexttimed
9$ rts
; a0 = filename
; d0 = 1, ungrab (ikke skriv i tosysop fila)
receivefile
push a2/a3/d2/d3
movea.l a0,a2
move.l d0,d3 ; skal vi skrive i tosysop fila ? (1 = nei)
moveq.l #0,d2
move.w d2,(tmpword,NodeBase) ; sletter antall errors
tst.b (readlinemore,NodeBase) ; er det mere innput ?
bne.b 8$ ; jepp. da er det protokoll
move.b (Protocol+CU,NodeBase),d2
beq.b 8$
subq.l #1,d2
bra.b 5$ ; Vi har en protokoll
8$ lea (traprotocoltext),a0
bsr readlineprompt
beq 9$
bsr parseprotocol
beq.b 8$
move.l d0,d2
5$ lsl.l #2,d2
lea (startyourtext),a0
bsr writetext
lea (protoclname),a0
movea.l (0,a0,d2.w),a0
bsr writetext
lea (sendtext),a0
bsr writetexto
move.w (Userbits+CU,NodeBase),d0
btst #USERB_G_R,d0
beq.b 4$
movea.l a2,a0
move.l d2,d0
lsr.l #2,d0
bsr doreciveGogR
4$ move.b #0,(DlUlstatus,NodeBase) ; Setter error
lea (protokollinitstr),a0 ; init string
movea.l (0,a0,d2.w),a0
bsr setup_xprio
; beq.s 9$ ; kan aldri forekomme
movea.l d0,a3
bsr stopserread
movea.l (dosbase),a6
lea (tmpdatestamp,NodeBase),a0 ; lagrer start tiden
move.l a0,d1
jsrlib DateStamp
lea (protokollbaser),a0
adda.l d2,a0
movea.l (a0),a6
movea.l a3,a0
movem.l d2-d7/a2-a6,-(sp)
jsr (_LVOXProtocolSetup,a6)
movem.l (sp)+,d2-d7/a2-a6
tst.l d0
beq 1$
tst.b (Tinymode,NodeBase) ; skriver ut header (hvis ikke
bne.b 6$ ; tiny mode)
move.l a6,-(a7)
movea.l (exebase),a6
lea (trfstatl1text),a0
bsr writecontext
lea (trfstatl2text),a0
bsr writecontext
movea.l (a7)+,a6
6$ moveq.l #0,d0
move.l d0,(tmpval,NodeBase) ; sikrer at verdien er riktig
move.l a2,(xpr_filename,a3)
movea.l a3,a0
movem.l d2-d7/a2-a6,-(sp)
jsr (_LVOXProtocolReceive,a6)
movem.l (sp)+,d2-d7/a2-a6
move.l a6,-(sp)
tst.l d0
beq.b 2$
move.b #1,(DlUlstatus,NodeBase)
movea.l (dosbase),a6 ; Sjekker tiden nu
lea (lastchartime,NodeBase),a0
move.l a0,d1
jsrlib DateStamp
movea.l (exebase),a6
lea (logulmsgtext),a0
moveq.l #1,d0 ; dette er Upload
tst.l d3
beq.b 7$ ; vanelig upload
moveq.l #2,d0 ; dette er ungrab
7$ bsr skrivuldllog
2$ move.l (tmpval,NodeBase),d1 ; lukker filen hvis den er åpen
beq.b 3$
movea.l (dosbase),a6
jsrlib Close
3$ moveq.l #0,d0 ; sletter igjen
move.l d0,(tmpval,NodeBase)
movea.l (sp)+,a6
movea.l a3,a0
move.l #0,(xpr_filename,a0)
movem.l d2-d7/a2-a6,-(sp)
jsr (_LVOXProtocolCleanup,a6)
movem.l (sp)+,d2-d7/a2-a6
1$ movea.l (exebase),a6
; move.l a3,a0
; bsr clear_xprio (ingenting å gjøre...)
9$ pop a3/a2/d2/d3
bsr initserread
moveq.l #0,d0
move.l d0,(SerTotOut,NodeBase) ; empty counter
tst.b (DlUlstatus,NodeBase)
rts
setup_xprio
push a2
movea.l a0,a2
lea (xpriomem,NodeBase),a0 ; clear'er minnet (for sikkerhets skyld)
moveq.l #XPR_IO_SIZEOF,d0
moveq.l #0,d1
subq.l #1,d0
1$ move.b d1,(a0)+
dbf d0,1$
lea (xpriomem,NodeBase),a0
move.l a2,(xpr_filename,a0)
move.l #fopen,(xpr_fopen,a0)
move.l #fclose,(xpr_fclose,a0)
move.l #fread,(xpr_fread,a0)
move.l #fwrite,(xpr_fwrite,a0)
move.l #sread,(xpr_sread,a0)
move.l #swrite,(xpr_swrite,a0)
move.l #sflush,(xpr_sflush,a0)
move.l #update,(xpr_update,a0)
move.l #chkabort,(xpr_chkabort,a0)
move.l d1,(xpr_chkmisc,a0)
move.l #gets,(xpr_gets,a0)
move.l d1,(xpr_setserial,a0)
; move.l #setserial,xpr_setserial(a0)
move.l #ffirst,(xpr_ffirst,a0)
move.l #fnext,(xpr_fnext,a0)
move.l #finfo,(xpr_finfo,a0)
move.l #fseek,(xpr_fseek,a0)
move.l #XPR_EXTENSION,(xpr_extension,a0)
move.l d1,(xpr_data,a0)
move.l d1,(xpr_options,a0)
move.l #unlink,(xpr_unlink,a0)
move.l d1,(xpr_squery,a0)
move.l d1,(xpr_getptr,a0)
move.l a0,d0
pop a2
rts
ffirst push a4/a5/a6
bsr setupa4a5
move.b (batch,NodeBase),d0
beq.b 1$
bsr findfirst
beq.b 8$
move.l (tmpmsgmem,NodeBase),d0
addq.l #3,d0
and.l #$fffffffc,d0
move.l d0,a0 ; findfile struct
lea (ff_full,a0),a0
move.l a0,(ULfilenamehack,NodeBase)
bsr getfilelen
beq.b 2$ ; error, den kommer vi over senere også..
add.l d0,(tmpwhilenotinparagon,NodeBase) ; husker størrelsen
2$ moveq.l #1,d0
bra.b 9$
1$ exg a0,a1
bsr strcopy
moveq.l #1,d0
bra.b 9$
8$ moveq.l #0,d0
9$ pop a4/a5/a6
rts
fnext push a4/a5/a6
bsr setupa4a5
moveq.l #0,d0
move.b (batch,NodeBase),d0
beq.b 9$
bsr findnext
beq.b 8$
move.l (tmpmsgmem,NodeBase),d0
addq.l #3,d0
and.l #$fffffffc,d0
move.l d0,a0 ; findfile struct
lea (ff_full,a0),a0
move.l a0,(ULfilenamehack,NodeBase)
bsr getfilelen
beq.b 2$ ; error, den kommer vi over senere også..
add.l d0,(tmpwhilenotinparagon,NodeBase) ; husker størrelsen
2$ moveq.l #1,d0
bra.b 9$
8$ moveq.l #0,d0
9$ pop a4/a5/a6
rts
fopen movem.l d2/d3/a4/a5/a6,-(sp)
move.l a0,d1
bsr setupa4a5
move.l (ULfilenamehack,NodeBase),d0 ; Hack for å forhindre filnavn
beq.b 5$ ; overide som Zmodem har.
move.l d0,d1 ; Ja, vi hadde filnavn, bytt.
5$ moveq.l #0,d0
move.b (a1),d3
cmpi.b #'r',d3
bne.b 1$
move.l #MODE_OLDFILE,d2
bra.b 4$
1$ cmpi.b #'w',d3
bne.b 2$
move.l #MODE_NEWFILE,d2
bra.b 4$
2$ cmpi.b #'a',d3
bne.b 9$
move.l #MODE_OLDFILE,d2
4$ movea.l (dosbase),a6
jsrlib Open
; tst.l d0
move.l d0,(tmpval,NodeBase) ; husker fileptr (for å sikre at den er i bruk)
beq.b 9$
cmpi.b #'a',d3
bne.b 9$
; move.l d0,-(a7)
move.l d0,d1
moveq.l #0,d2
moveq.l #OFFSET_END,d3
jsrlib Seek
; move.l (a7)+,d0
move.l (tmpval,NodeBase),d0 ; henter fileptr
9$ movem.l (sp)+,a6/d2/d3/a4/a5
rts
fclose push a4/a5/a6
bsr setupa4a5
move.l a0,d1
movea.l (dosbase),a6
jsrlib Close
moveq.l #0,d0
move.l d0,(tmpval,NodeBase) ; husker at den er stengt
pop a4/a5/a6
rts
fread movem.l d2/d3/d4/a6,-(sp)
move.l d0,d4 ; block size
beq.b 9$
move.l d0,d3
mulu.w d1,d3
move.l a1,d1
move.l a0,d2
movea.l (dosbase),a6
jsrlib Read
moveq.l #-1,d1
cmp.l d0,d1
bne.b 8$
moveq.l #0,d0
bra.b 9$
8$ divu.w d4,d0
andi.l #$ffff,d0
9$ movem.l (sp)+,a6/d2/d3/d4
rts
fwrite movem.l d2/d3/d4/a6,-(sp)
move.l d0,d4 ; block size
beq.b 9$
move.l d0,d3
mulu.w d1,d3
move.l a1,d1
move.l a0,d2
movea.l (dosbase),a6
jsrlib Write
moveq.l #-1,d1
cmp.l d0,d1
bne.b 8$
moveq.l #0,d0
bra.b 9$
8$ divu.w d4,d0
andi.l #$ffff,d0
9$ movem.l (sp)+,a6/d2/d3/d4
rts
fseek movem.l d2/d3/a6,-(sp)
move.l d0,d2
moveq.l #-1,d0
move.l d1,d3
bne.b 1$
moveq.l #OFFSET_BEGINNING,d3
bra.b 4$
1$ subq.l #1,d3
bne.b 2$
moveq.l #OFFSET_CURRENT,d3
bra.b 4$
2$ subq.l #1,d3
bne.b 9$
moveq.l #OFFSET_END,d3
4$ move.l a0,d1
movea.l (dosbase),a6
jsrlib Seek
moveq.l #-1,d1
cmp.l d0,d1
beq.b 9$
moveq.l #0,d0
9$ movem.l (sp)+,a6/d2/d3
rts
finfo moveq.l #2,d1
cmp.l d1,d0
bne.b 1$
moveq.l #1,d0 ; Filtype. Alltid binær.
rts
1$ moveq.l #1,d1
cmp.l d1,d0
beq.b 2$
moveq.l #0,d0 ; ukjent. returner error.
rts
2$ movem.l a6/a4/a5,-(sp)
bsr setupa4a5
move.l (ULfilenamehack,NodeBase),d0 ; Hack for å forhindre filnavn
beq.b 3$ ; overide som Zmodem har.
movea.l d0,a0 ; Ja, vi hadde filnavn, bytt.
3$ bsr getfilelen
movem.l (sp)+,a6/a4/a5
rts
swrite push a6/a4/a5/d2/d3
movea.l (exebase),a6
bsr setupa4a5
move.l d0,d3
move.l a0,d2
bsr waitseroutput
move.l (tmpmsgmem,NodeBase),a1 ; Bruker tmpmsgmem til copy space
lea ($400,a1),a1
move.l d2,a0
move.l d3,d0
bsr memcopylen
move.l (tmpmsgmem,NodeBase),a0
lea ($400,a0),a0
move.l d3,d0
bsr serwritestringlen
; bsr serwritestringlendo
pop a6/a4/a5/d2/d3
rts
;a0 = buffer
;d0 = len
;d1 = timeout
sread movem.l d2/d3/a2/a6/a4/a5,-(sp)
movea.l (exebase),a6
bsr setupa4a5
movea.l a0,a2 ; Buffer
move.l d0,d2 ; lengde vi skal lese
move.l d1,d3 ; timeout
; tst.l d3 ; Har vi timeout ?
bne.b 1$
movea.l (sreadreq,NodeBase),a1 ; Leser alle tegn i inn buffer
move.w #SDCMD_QUERY,(IO_COMMAND,a1)
jsrlib DoIO ; Sjekke flagg
movea.l (sreadreq,NodeBase),a1
IFND nocarrier
move.w (Setup+Nodemem,NodeBase),d0
btst #SETUPB_NullModem,d0 ; Nullmodem ?
bne.b 2$ ; jepp, no CD checking.
move.w (IO_STATUS,a1),d1 ; Henter serial.status
btst #5,d1 ; Har vi CD ?
beq.b 2$ ; Ja, hopp
move.b #NoCarrier,(readcharstatus,NodeBase)
bra 9$ ; No carrier, Logoff !!
ENDC
2$ move.l (IO_ACTUAL,a1),d0
beq 9$
cmp.l d0,d2
bcc.b 3$
move.l d2,d0 ; Vi har flere uleste bytes enn len.
3$ move.w #CMD_READ,(IO_COMMAND,a1)
move.l a2,(IO_DATA,a1)
move.l d0,(IO_LENGTH,a1)
jsrlib DoIO
movea.l (sreadreq,NodeBase),a1
move.l (IO_ACTUAL,a1),d3
bra 9$
1$ movea.l (sreadreq,NodeBase),a1 ; Setter igang ny request
move.w #CMD_READ,(IO_COMMAND,a1)
move.l a2,(IO_DATA,a1)
move.l d2,(IO_LENGTH,a1)
jsrlib SendIO
move.l d3,d0
move.l #1000000,d1
bsr divl
movea.l (timer1req,NodeBase),a1
move.l d0,(TV_SECS+IOTV_TIME,a1)
move.l d1,(TV_MICRO+IOTV_TIME,a1)
move.w #TR_ADDREQUEST,(IO_COMMAND,a1)
jsrlib SendIO ; Starter timeout'en.
10$ move.l (timer1sigbit,NodeBase),d0
or.l (sersigbit,NodeBase),d0
jsrlib Wait
move.l d0,d2
and.l (sersigbit,NodeBase),d0
beq.b 4$
movea.l (sreadreq,NodeBase),a1
jsrlib CheckIO
tst.l d0
beq.b 4$
movea.l (timer1req,NodeBase),a1
bra.b 5$
4$ and.l (timer1sigbit,NodeBase),d2
beq.b 10$
movea.l (timer1req,NodeBase),a1
jsrlib CheckIO
tst.l d0
beq.b 10$
movea.l (sreadreq,NodeBase),a1
5$ jsrlib AbortIO
movea.l (timer1req,NodeBase),a1
jsrlib WaitIO
movea.l (sreadreq,NodeBase),a1
jsrlib WaitIO
movea.l (sreadreq,NodeBase),a1
move.l (IO_ACTUAL,a1),d3
move.w #SDCMD_QUERY,(IO_COMMAND,a1)
jsrlib DoIO ; Sjekke flagg
movea.l (sreadreq,NodeBase),a1
IFND nocarrier
move.w (Setup+Nodemem,NodeBase),d0
btst #SETUPB_NullModem,d0 ; Nullmodem ?
bne.b 9$ ; jepp, no CD checking.
move.w (IO_STATUS,a1),d1 ; Henter serial.status
btst #5,d1 ; Har vi CD ?
beq.b 9$ ; Ja, hopp
move.b #NoCarrier,(readcharstatus,NodeBase)
bra.b 6$
ENDC
9$ move.l d3,d0
tst.b (readcharstatus,NodeBase)
notz
bne.b 99$
6$ moveq.l #-1,d0
99$ movem.l (sp)+,d2/d3/a2/a6/a4/a5
rts
sflush movem.l a6/a4/a5,-(sp)
bsr setupa4a5
movea.l (exebase),a6
movea.l (sreadreq,NodeBase),a1
jsrlib WaitIO
movea.l (sreadreq,NodeBase),a1
move.w #CMD_CLEAR,(IO_COMMAND,a1) ; Flush'es serial buffers
jsrlib DoIO
movem.l (sp)+,a6/a4/a5
rts
update push a2/a6/a4/a5/d2/d3
movea.l a0,a2
bsr setupa4a5
movea.l (exebase),a6
move.l (windowadr,NodeBase),d0
beq 9$ ; no window
move.l (xpru_updatemask,a2),d0
move.l d0,d3
andi.l #XPRUF_ERRORMSG+XPRUF_BLOCKS+XPRUF_BYTES+XPRUF_ERRORS+XPRUF_TIMEOUTS+XPRUF_EXPECTTIME+XPRUF_ELAPSEDTIME+XPRUF_DATARATE,d0
beq 9$
tst.b (Tinymode,NodeBase)
bne 9$
move.b #13,d0 ; starter først på linjen.
bsr writeconchar
move.l (xpru_blocks,a2),d0
moveq.l #4,d1
moveq.l #XPRUB_BLOCKS,d2
bsr 10$
move.b #' ',d0
bsr writeconchar
move.l (xpru_bytes,a2),d0
moveq.l #10,d1
moveq.l #XPRUB_BYTES,d2
bsr 10$
move.b #' ',d0
bsr writeconchar
movea.l (xpru_elapsedtime,a2),a0
moveq.l #10,d0
moveq.l #XPRUB_ELAPSEDTIME,d2
bsr 20$
move.b #' ',d0
bsr writeconchar
movea.l (xpru_expecttime,a2),a0
moveq.l #10,d0
moveq.l #XPRUB_EXPECTTIME,d2
bsr 20$
move.b #' ',d0
bsr writeconchar
move.l (xpru_datarate,a2),d0
moveq.l #4,d1
moveq.l #XPRUB_DATARATE,d2
bsr 10$
move.b #' ',d0
bsr writeconchar
move.l (xpru_timeouts,a2),d0
moveq.l #4,d1
moveq.l #XPRUB_TIMEOUTS,d2
bsr 10$
move.b #' ',d0
bsr writeconchar
move.l (xpru_errors,a2),d0
moveq.l #4,d1
moveq.l #XPRUB_ERRORS,d2
btst d2,d3 ; er denne gyldig ?
beq.b 1$ ; nei
move.w d0,(tmpword,NodeBase) ; lagrer errors
1$ bsr 10$
move.b #' ',d0
bsr writeconchar
move.l (xpru_updatemask,a2),d0 ; har vi error melding ?
andi.l #XPRUF_ERRORMSG,d0
beq.b 8$ ; nei, ut
movea.l (xpru_errormsg,a2),a0 ; skriver den ut
bsr writecontext
move.b #10,d0 ; ny linje
bsr writeconchar
8$ lea (cleartoEOLtext),a0 ; sletter alt etter
bsr writecontext
9$ pop a2/a6/a4/a5/d2/d3
rts
10$ btst d2,d3 ; er denne gyldig ?
bne.b 11$ ; ja
move.l d1,d0 ; nei, hopper over plassene
bra 30$
11$ move.l d1,-(a7) ; skriver ut tallet
lea (tmptext,NodeBase),a0
bsr konverter
move.l (a7)+,d0
lea (tmptext,NodeBase),a0 ; og fyller ut alle plassene
bra writecontextrfill
20$ btst d2,d3 ; er denne gyldig ?
beq.b 30$ ; nei, hopper over plassene
bra writecontextrfill
; d0 = antall posisjoner
30$ lea (tmptext,NodeBase),a0
move.b #$9b,(a0)+
bsr konverter
move.b #'C',(a0)+
move.b #0,(a0)
lea (tmptext,NodeBase),a0
bra writecontext
chkabort
push a4/a5
bsr setupa4a5
moveq.l #0,d0
tst.b (readcharstatus,NodeBase)
beq.b 9$
moveq.l #-1,d0
9$ pop a4/a5
rts
gets moveq.l #0,d0
rts
unlink movem.l a6/a4/a5,-(sp)
movea.l (exebase),a6
bsr setupa4a5
bsr deletefile
tst.w d0
bne.b 1$
moveq.l #-1,d0
bra.b 9$
1$ moveq.l #0,d0
9$ movem.l (sp)+,a6/a4/a5
rts
IFD notyet
setserial
movem.l d2/a6/a4/a5,-(sp)
move.l d0,d2
movea.l (exebase),a6
bsr setupa4a5
movea.l (sreadreq,NodeBase),a1
moveq.l #12*4,d0
1$ subq.l #4,d0
bcs.b 2$
move.l (IO_BAUD,a1),d1
lea (xprbaudates),a0
cmp.l (0,a0,d0.w),d1
bne.b 1$
lsr.l #2,d0
2$ andi.l #$ff,d0
swap d0
moveq #0,d1
move.b (IO_EXTFLAGS+3,a1),d1
cmpi.b #8,(IO_READLEN,a1)
beq.b 3$
bset #3,d1
3$ cmpi.b #8,(IO_WRITELEN,a1)
beq.b 4$
bset #4,d1
4$ cmpi.b #1,(IO_STOPBITS,a1)
beq.b 5$
bset #2,d1
5$ lsl.w #8,d1
or.w d1,d0
move.b (IO_SERFLAGS,a1),d0
moveq.l #-1,d1
cmp.l d2,d1
beq 9$
move.l d0,d2
move.b (IO_SERFLAGS,a1),-(sp)
move.b (IO_READLEN,a1),-(sp)
move.b (IO_WRITELEN,a1),-(sp)
move.b (IO_STOPBITS,a1),-(sp)
move.l (IO_BAUD,a1),-(sp)
move.b (IO_EXTFLAGS+3,a1),d1
move.w d1,-(sp)
movea.l (sreadreq,NodeBase),a1
move.b d0,(IO_SERFLAGS,a1)
swap d0
lsl.w #2,d0
move.w (Setup+Nodemem,NodeBase),d1
btst #SETUPB_Lockedbaud,d1
bne.b 10$
lea (xprbaudates),a0
move.l (0,a0,d0.w),(IO_BAUD,a1)
10$ swap d0
lsr.w #8,d0
move.b #8,(IO_READLEN,a1)
move.b #8,(IO_WRITELEN,a1)
move.b #1,(IO_STOPBITS,a1)
btst #3,d0
beq.b 71$
move.b #7,(IO_READLEN,a1)
71$ btst #4,d0
beq.b 72$
move.b #7,(IO_WRITELEN,a1)
72$ btst #2,d0
beq.b 73$
move.b #2,(IO_STOPBITS,a1)
73$ andi.w #$3,d0
move.b d0,(IO_EXTFLAGS+3,a1)
move.w #SDCMD_SETPARAMS,(IO_COMMAND,a1)
jsrlib DoIO
tst.l d0
beq.b 6$
movea.l (sreadreq,NodeBase),a1
move.w (sp)+,d1
move.b (sp)+,(IO_EXTFLAGS+3,a1)
move.w (Setup+Nodemem,NodeBase),d0
btst #SETUPB_Lockedbaud,d0
bne.b 12$
addq.l #4,sp
bra.b 11$
12$ move.l (sp)+,(IO_BAUD,a1)
11$ move.b (sp)+,(IO_STOPBITS,a1)