-
Notifications
You must be signed in to change notification settings - Fork 1
/
Main.asm
5810 lines (5446 loc) · 129 KB
/
Main.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
******************************************************************************
****** ******
****** ABBS - Amiga Bulletin Board System ******
****** Written By Geir Inge Høsteng ******
****** ******
******************************************************************************
*******************************************************************************
* *
* * * * * * * * * * * * * Kode for Master task * * * * * * * * * * * * * * * *
* *
*******************************************************************************
*****************************************************************
*
* NAME
* Main.asm
*
* DESCRIPTION
* Source for the ABBS main task
*
* AUTHOR
* Geir Inge Høsteng
*
* $Id: main.asm 1.2 1995/07/08 12:01:33 geirhos Exp geirhos $
*
* MODIFICATION HISTORY
* $Log: main.asm $
;; Revision 1.2 1995/07/08 12:01:33 geirhos
;; removed unused code. small cleanup
;;
;; Revision 1.1 1995/06/24 10:32:07 geirhos
;; Initial revision
;;
*
*****************************************************************
NOLIST
include 'first.i'
include 'exec/types.i'
include 'exec/lists.i'
include 'exec/ports.i'
include 'exec/lists.i'
include 'exec/io.i'
include 'exec/memory.i'
include 'exec/tasks.i'
include 'exec/libraries.i'
include 'exec/execbase.i'
include 'dos/dos.i'
include 'dos/dostags.i'
include 'dos/dosextens.i'
include 'utility/tagitem.i'
include 'rexx/storage.i'
include 'intuition/intuition.i'
include 'intuition/screens.i'
include 'graphics/gfxbase.i'
include 'workbench/workbench.i'
include 'libraries/commodities.i'
include 'libraries/gadtools.i'
include 'fifo.i'
include 'ABBSmy.i'
include 'asm.i'
include 'bbs.i'
; LIST
CreateMissingFiles EQU 1
section kode,code
XREF comparestringsfull
XREF comparestringsifull
XREF comparestringsicase
XREF CreatePort
XREF DeletePort
XREF Exception
XREF fillinnodenr
XREF getkonfbulletname
XREF memcopylen
XREF memcopyrlen
XREF NewScreenStructure
XREF NewWindowStructure1
XREF publicportname
XREF nodestart
XREF nstart
XREF parserexxcmd
XREF strcopy
XREF atoi
XREF strcopymaxlen
XREF Environment
XREF upchar
XREF createmenutags
XREF MenuTags
XREF versionstr
XREF strlen
XREF memclr
XREF _AsmDeletePool
XREF _AsmCreatePool
XREF _AsmAllocPooled
XREF _AsmFreePooled
XDEF exebase
XDEF intbase
XDEF gfxbase
XDEF gadbase
XDEF aslbase
XDEF rexbase
XDEF dosbase
XDEF utibase
XDEF fifobase
XDEF dfobase
XDEF iffbase
XDEF utiname
XDEF mainstack
XDEF copyrighttext
XDEF protokollbaser
XDEF nodelist
XDEF mainscreenadr
XDEF abbsrootname
XDEF mainmemoryblock
XDEF main
XDEF mainmsgport
XDEF pubscreenname
XDEF MainTask
;exceptionhandler = 1
main move.l 4.w,a6
move.l a7,mainstack
moveq.l #0,d0
move.l d0,wbmessage ; nullstiller, just in case
move.l ThisTask(a6),a0
move.l pr_CLI(a0),d0
bne.b 1$ ; startet fra cli
push a2 ; henter wb startupmessage
move.l a0,a2
2$ lea pr_MsgPort(a2),a0
jsrlib WaitPort
lea pr_MsgPort(a2),a0
jsrlib GetMsg
move.l d0,wbmessage
beq.b 2$
pop a2
bra 4$
1$
IFD sdfsdfsdf
moveq.l #0,d0
move.l #dosname,a1
IFND _LVOOpenLibrary
XREF _LVOOpenLibrary
ENDIF
jsr _LVOOpenLibrary(a6)
move.l d0,dosbase
beq mainsetuperror
cmp.w #36,LIB_VERSION(a6) ; Kjører vi på noe bedre enn 1.3 ?
bcc.b 5$ ; Jepp. Kjører.
lea need2.0text,a0
bsr writemainerror
bra mainsetuperror
5$ push d2/d3/a6
move.l #readargsstring,d1
lea mainscreenadr,a0 ; bruker som tmp buffer
move.l a0,d2
moveq.l #0,d3
move.l d3,(a0)+ ; clearer
move.l d3,(a0)+
move.l dosbase,a6
jsrlib ReadArgs
move.l d0,d1
bne.b 6$
jsrlib IoErr
move.l d0,d1
move.l #abbstext,d2
jsrlib PrintFault
bra.b 7$
6$ jsrlib FreeArgs
push a2
lea mainscreenadr,a2
; bruk argumentene..
move.l (a2)+,d0
beq.b 8$
move.l d0,a0
jsr writemainerror
8$ move.l (a2)+,d0
beq.b 9$
move.l d0,a0
jsr writemainerror
9$ pop a2
move.l dosbase,a6
7$ lea mainscreenadr,a0 ; tmp buffer
moveq.l #0,d0
move.l d0,(a0)+ ; clearer igjen
move.l d0,(a0)+
jsrlib GetArgStr
move.l d0,a0
11$ move.b (a0),d0 ; ødelegger startup parametrene
beq.b 10$
move.b #0,(a0)+
bra.b 11$
10$ pop d2/d3/a6
ENDC
4$ bsr mainsetup
beq mainsetuperror ; Branch if error
bsr loadconfigs ; load userdata ++ (needs work)
bpl.b 3$ ; normal sak.
bsr openstatuswindow; ingen config, åpner vinduet så installasjon skal være lettere
bra.b main1 ; Ingen config file, dummy mode
3$ beq loadconfigserror ; ... error
bsr openfiles ; Åpner filer
beq openfileserror
bsr gettooltypes
bsr setupappicon
bsr setupcommodity
beq no_appicon
bsr startnodes ; Kick off each node.
beq startnodeserror ; No startup file.
btst #0,configbyte
bne.b main1 ; skal ikke pop'e opp
bsr openstatuswindow
main1
1$ tst.w mainshutdown
bne mainexit
move.l mainwait,d0 ; Service requests
jsrlib Wait
move.l d0,-(sp)
and.l mainportsigbit,d0
beq.b 2$
bsr mainportinput ; Some node wants a job done.
2$ move.l (sp),d0
move.l mainscreenadr,d1
beq.b 3$ ; ingen skjerm oppe, så vi sjekker ikke
and.l mainintsigbit,d0
beq.b 3$
bsr intuitioninput ; Intuition message.
3$ move.l (sp),d0
move.b statusopen,d1
beq.b 4$ ; ikke noe status vindu oppe, gi f..
and.l maingadtosigbit,d0
beq.b 4$
bsr gadtoolsinput ; Gadtools message.
tst.b closestatuswind
beq.b 4$
move.b #0,closestatuswind
move.b statusopen,d0
beq.b 4$
bsr closestatuswindow
4$ move.l (sp),d0
and.l #SIGBREAKF_CTRL_C,d0
beq.b 6$
move.b statusopen,d0
bne.b 41$
bsr openstatuswindow
bra.b 6$
41$ bsr closestatuswindow
6$ move.l (sp),d0
and.l #SIGBREAKF_CTRL_E,d0
beq.b 5$
bsr updatenodelist
5$ move.l (sp),d0
and.l maincommisigbit,d0
beq.b 7$
bsr handlecommodity
7$ move.l (sp)+,d0
and.l wbportsigbit,d0
beq 1$
bsr wbinput ; WorkBench message.
bra 1$
mainexit
bsr shutdownnodes ; free resources used for nodes.
tst.w lesconfigstatus
beq.b 1$
bsr main_saveconfig ; Saves config (needs work)
1$
startnodeserror
bsr clearcommodity
bsr clearappicon
no_appicon
bsr closefiles
openfileserror
loadconfigserror
bsr mainclosedown ; close screen,window ++
mainsetuperror
move.l wbmessage,d0
beq.b 1$
jsrlib Forbid ; reply the wb message
move.l wbmessage,a1
jsrlib ReplyMsg
1$ moveq #0,d0 ; We don't need a return code, do we ?
rts
; reads startupfile, and kick's off all nodes in there.
; returns z=1 for error, or Z=0 for no error
startnodes
push d2-d5/a2/a6
link.w a3,#-128
move.w #0,Nodes(MainBase) ; Zero nodes active
move.l dosbase,a6 ; open startup file for read.
move.l #startupfilename,d1
move.l #MODE_OLDFILE,d2
jsrlib Open
move.l d0,d4
beq 8$ ; error : No startup file
3$ move.l d4,d1 ; leser et tegn
move.l sp,d2
moveq.l #127,d3
jsrlib FGets
tst.l d0 ; null ?
beq.b 2$ ; Ja <=> EOF,error
moveq.l #0,d5 ; ingen tegn
move.l sp,a0
1$ move.b (a0)+,d0
cmp.b #10,d0 ; NewLine ?
beq.b 4$ ; Jepp.
cmp.b #' ',d0 ; Space ?
beq.b 4$ ; Jepp.
cmp.b #9,d0 ; TAB ?
beq.b 4$ ; Jepp.
cmp.b #';',d0 ; Semi kolon ?
beq.b 4$ ; Jepp
addq.l #1,d5 ; tegnpos ++
bra.b 1$
4$ tst.l d5 ; Tegnet var NL, eller komentar ferdig
beq.b 3$ ; strlen = 0 -> no name.
move.b #0,(-1,a0) ; markerer str slutt
move.l sp,a0 ; navn i a0
bsr kickoffnode ; starter node
; beq.b 3$ ; error, prøver neste
bra.b 3$
2$ move.l d4,d1
jsrlib Close
jsrlib IoErr
tst.l d0
notz
bne.b 9$
lea (errstartfiltext),a0
bra.b 81$
8$ lea nostartfiletext,a0
81$ bsr writemainerror
setz
9$ unlk a3
pop d2-d5/a2/a6
rts
; d0 = nodenr
; a0 = string å legge navnet i (160 lang)
getnodeconfigfile
push d2-d6/a6/a2
move.l a0,a2
move.l d0,d6
move.l dosbase,a6 ; open startup file for read.
move.l #startupfilename,d1
move.l #MODE_OLDFILE,d2
jsrlib Open
move.l d0,d4
beq 9$ ; error : No startup file
3$ move.l d4,d1 ; leser en string
move.l a2,d2
moveq.l #127,d3
jsrlib FGets
tst.l d0 ; null ?
beq.b 2$ ; Ja <=> EOF,error
moveq.l #0,d5 ; ingen tegn
move.l a2,a0
1$ move.b (a0)+,d0
cmp.b #10,d0 ; NewLine ?
beq.b 4$ ; Jepp.
cmp.b #' ',d0 ; Space ?
beq.b 4$ ; Jepp.
cmp.b #9,d0 ; TAB ?
beq.b 4$ ; Jepp.
cmp.b #';',d0 ; Semi kolon ?
beq.b 4$ ; Jepp
addq.l #1,d5 ; tegnpos ++
bra.b 1$
4$ tst.l d5 ; Tegnet var NL, eller komentar ferdig
beq.b 3$ ; strlen = 0 -> no name.
move.b #0,(-1,a0) ; markerer str slutt
sub.w #1,d6 ; teller ned
bne.b 3$ ; Vi er ikke ferdig enda, tar neste
move.l d4,d1
jsrlib Close
clrz
bra.b 9$
2$ move.l d4,d1
jsrlib Close
setz
9$ pop d2-d6/a6/a2
rts
; navn på config fila til noden
kickoffnode
push d2-d5/a2/a6
move.l exebase,a6
move.l a0,a2
move.w (MaxLinesMessage+CStr,MainBase),d0
mulu #LinesSize,d0
add.l #Nodenode_SIZEOF,d0
move.l d0,d2 ; husker size'n
move.l #MEMF_CLEAR!MEMF_PUBLIC,d1
jsrlib AllocMem
move.l d0,d5
beq 1$
addq.w #1,Nodes(MainBase)
move.l d0,a0
move.l d2,Nodenode_alloc(a0) ; husker size'n
move.l a2,Nodeusernr(a0) ; Midlertidig lagersted
move.w Nodes(MainBase),Nodenr(a0)
jsrlib Forbid ; legger inn noden i lista
move.l a0,a1
lea nodelist,a0
ADDTAIL
jsrlib Permit
lea CreateNewProcTags,a0
move.l #nstart,4(a0) ; slenger inn startkode
move.l a2,12(a0) ; slenger inn navnet
move.l a0,d1
move.l dosbase,a6
jsrlib CreateNewProc
; bra.b 5$
;6$ sub.l a1,a1 ; arver prioritet
; jsrlib FindTask
; move.l d0,a0
; moveq.l #0,d2
; move.b (pr_Task+TC_Struct+LN_PRI,a0),d2
; move.l a2,d1 ; name
; move.l #nodestart,d3
; lsr.l #2,d3
; move.l #4*4096,d4 ; stack størrelse
; move.l dosbase,a6
; jsrlib CreateProc
5$ tst.l d0 ; gikk det bra ?
bne.b 1$ ; ja
move.l d5,a1 ; fjerner fra lista
lea nodelist,a0
REMOVE
move.l d5,a1 ; frigir minne
move.l Nodenode_alloc(a1),d0
move.l exebase,a6
jsrlib FreeMem
subq.w #1,Nodes(MainBase)
moveq.l #0,d5
1$ move.l d5,d0
pop d2-d5/a2/a6
rts
; fjern currentdir saken (default med createnewproc)
shutdownnodes
push a2/d2
move.l nodelist+LH_HEAD,a2
1$ move.l (LN_SUCC,a2),d2 ; henter neste
beq.b 9$
move.l a2,a1 ; fjerner fra lista
REMOVE
move.l a2,a1
move.l (Nodenode_alloc,a1),d0
beq.b 2$
jsrlib FreeMem
2$ move.l d2,a2
bra.b 1$
9$ pop a2/d2
rts
intuitioninput
push d2/d3
intuitioninput1
move.l mainintuiport,a0
jsrlib GetMsg
tst.l d0
beq 9$
move.l d0,a1
move.l im_Class(a1),d0
cmp.l #MENUPICK,d0
bne 8$
move.w im_Code(a1),d2 ; husker item
move.w d2,d0
cmp.w #MENUNULL,d0
beq 8$
move.w d0,d1
and.w #$1f,d0 ;menunum
asr.w #5,d1
; move.w d1,d2
and.w #$3f,d1 ;itemnum
; asr.w #6,d2
; and.w #$1f,d2 ;subnum
push d0/d1
jsrlib ReplyMsg
pop d0/d1
tst.w d0
bne.b 2$
tst.w d1
bne.b 9$
move.w MainBits(MainBase),d0 ; er vi locked ?
and.w #MainBitsF_ABBSLocked,d0
bne.b 3$ ; ja, nekte
tst.w Nodes(MainBase)
beq.b 1$
3$ move.l intbase,a6
move.l mainscreenadr,a0
jsrlib DisplayBeep
move.l exebase,a6
bra.b 9$
1$ move.w #1,mainshutdown
bra.b 9$
2$ cmp.w #1,d0 ; sysop available ?
bne.b 9$
tst.w d1
bne.b 9$
move.l intbase,a6
move.l (mainmenustruct),a0
move.w d2,d0
jsrlib ItemAddress
move.l (exebase),a6
move.l d0,a0
move.w MainBits(MainBase),d0
and.w #~MainBitsF_SysopNotAvail,d0
move.w mi_Flags(a0),d1
and.w #CHECKED,d1
beq.b 21$
or.w #MainBitsF_SysopNotAvail,d0
21$ move.w d0,MainBits(MainBase)
bra.b 9$
8$ jsrlib ReplyMsg
bra intuitioninput1
9$ pop d2/d3
rts
mainportinput
push a2
0$ move.l mainmsgport,a0
jsrlib GetMsg
tst.l d0
beq 9$
move.l d0,a2
move.l d0,a0
XREF CheckRexxMsg
jsr CheckRexxMsg ; arexx melding ??
tst.l d0
beq.b 1$ ; nope, vanelig
move.l ARG0(a2),a0 ; kommandoen
bsr domainarexxcmd
moveq.l #0,d1
move.l d1,rm_Result2(a2)
move.l d0,rm_Result1(a2) ; setter RC
bne.b 8$ ; error
move.l a0,d0 ; har vi en streng ?
beq.b 8$ ; nope
move.l ACTION(a2),d0 ; vil han ha en string ?
btst #RXFB_RESULT,d0
beq.b 8$ ; nope
move.l rm_LibBase(a2),d0 ; henter libbase
beq.b 8$ ; har ingen!
move.l d0,a6
move.l a0,a1 ; strlen
move.l a0,d0
3$ tst.b (a1)+
bne.b 3$
subq.l #1,a1
sub.l d0,a1
move.l a1,d0
jsrlib CreateArgstring
move.l a2,a1
move.l d0,rm_Result2(a1)
move.l exebase,a6
bra.b 8$
1$ move.l a2,a0
lea msgportjumps,a1
move.w m_Command(a0),d0
cmp.w #Main_LASTCOMM,d0 ; lovlig kommando ?
bcc.b 2$ ; nei
asl.w #2,d0
move.l 0(a1,d0.w),a1
jsr (a1)
bra.b 8$
2$ move.w #Error_IllegalCMD,m_Error(a2)
8$ move.l a2,a1
tst.l MN_REPLYPORT(a1)
beq 0$
jsrlib ReplyMsg
bra 0$ ; Ta alle meldinger.
9$ pop a2
rts
wbinput push a2
0$ move.l wbmsgport,a0
jsrlib GetMsg
tst.l d0
beq 9$
move.l d0,a2
move.l d0,a0
move.w (am_Type,a0),d0
cmp.w #MTYPE_APPICON,d0
bne.b 8$ ; ukjennt sak
move.b statusopen,d0
bne.b 1$
bsr openstatuswindow
bra.b 8$
1$ bsr closestatuswindow
8$ move.l a2,a1
tst.l MN_REPLYPORT(a1)
beq 0$
jsrlib ReplyMsg
bra 0$ ; Ta alle meldinger.
9$ pop a2
rts
gadtoolsinput
push a2/a6
move.l gadbase,a6
0$ move.l maingadtoolport,a0
jsrlib GT_GetIMsg
tst.l d0
beq 9$
move.l d0,a2
move.l im_Class(a2),d0
cmp.l #IDCMP_CLOSEWINDOW,d0
bne.b 1$
move.l a2,a1
jsrlib GT_ReplyIMsg
bsr closestatuswindow
bra.b 9$
1$ cmp.l #IDCMP_NEWSIZE,d0
beq.b 5$
cmp.l #IDCMP_SIZEVERIFY,d0
bne.b 2$
5$ jsr ABBSAppWindowRender
bra.b 8$
2$ cmp.l #IDCMP_GADGETUP,d0
bne.b 3$
move.l (im_IAddress,a2),a0
move.w (gg_GadgetID,a0),d0
move.w (im_Code,a2),d1
move.l a2,a0
bsr handlestatusgadget
bra.b 8$
3$ cmp.l #IDCMP_MENUPICK,d0
bne.b 4$
move.w (im_Code,a2),d0
cmpi.w #MENUNULL,d0
beq.b 8$
bsr handlegadmenu
bra.b 8$
4$ cmp.l #IDCMP_VANILLAKEY,d0
bne.b 8$
; move.w (ie_Qualifier,a2),d0 Tar alle qualifiere
move.w (im_Code,a2),d0
bsr handlevanillakey
8$ move.l a2,a1
jsrlib GT_ReplyIMsg
bra 0$
9$ pop a2/a6
rts
updatenodelist
push a2/a3/a6
move.b statusopen,d0
beq.b 9$
move.l gadbase,a6
move.l ABBSAppWindowGadgets,a0
move.l ABBSAppWindowWnd,a1
suba.l a2,a2
lea (updatenodelisttags),a3
jsrlib GT_SetGadgetAttrsA
9$ pop a2/a3/a6
rts
handlevanillakey
push d2
bsr upchar
lea chartogadget,a0
moveq.l #0,d2
1$ move.b (a0)+,d1
beq.b 9$ ; ferdig, ukjennt tegn
addq.l #1,d2
cmp.b d0,d1
bne.b 1$
move.l d2,d0
bsr handlestatusgadget
9$ pop d2
rts
; d0 = menucode
handlegadmenu
push d2
0$ move.l d0,d2 ; husker menukode
move.l d0,d1
lsr.l #5,d1
andi.w #$3f,d1 ; finner item nummeret
andi.w #$1f,d0 ; finner menu nummeret
bne.b 2$ ; ikke menu 0
move.w d1,d0
bne.b 11$ ; ikke item 0
; Item (0,0) - about
bra.b 8$
11$ cmp.w #2,d0
bne.b 12$
move.b #1,closestatuswind ; Item (0,2) - Iconify
bra.b 8$
12$ cmp.w #4,d0
bne.b 8$
move.l (exebase),a6
bsr shutdownall
move.w MainBits(MainBase),d0 ; er vi locked ?
and.w #MainBitsF_ABBSLocked,d0
bne.b 7$ ; ja, nekte
move.w Nodes(MainBase),d1 ; Item (0,4) - Quit
bne.b 7$ ; kan ikke
move.w #1,mainshutdown
bra.b 8$
2$
7$ move.l (intbase),a6
suba.l a0,a0 ; nei, blinker vinduet.
jsrlib DisplayBeep
8$ movea.l (intbase),a6 ; Finner neste, hvis det er noen
move.w d2,d0
movea.l (ABBSAppWindowMenus),a0
jsrlib ItemAddress
tst.l d0
beq.b 9$
movea.l d0,a0
move.w (mi_NextSelect,a0),d0
cmp.w #MENUNULL,d0
bne.b 0$
9$ pop d2
move.l gadbase,a6
rts
; d0 = gadgetid
; d1 = Code (bare for listgadget, og cycle gadgeter)
; a0 = intuimessage (bare for listgadget, og cycle gadgeter)
handlestatusgadget
push d2/d3/d4/a6
move.l intbase,a6
move.w d1,d4 ; husker code
cmp.w #GD_ListViewGadget,d0
bne.b 1$
move.w d1,activenode ; lagrer hvilken node det var
move.l oldclicksecs,d0 ; sjekker om det var double click
move.l oldclickmicros,d1
move.l (im_Seconds,a0),d2
move.l (im_Micros,a0),d3
move.l d2,oldclicksecs
move.l d3,oldclickmicros
jsrlib DoubleClick
tst.l d0
beq 9$ ; ikke double, ikke vis noden
moveq.l #0,d0
move.l d0,oldclicksecs ; sletter gamle tider, for å hindre tripple click
move.l d0,oldclickmicros
move.w activenode,d0
move.w #Node_Show,d2
bra.b 2$
1$ cmp.w #GD_Win_size,d0
bhi.b 9$ ; for høy
sub.w #1,d0 ; trekker ifra for listview'n
ext.l d0
add.l d0,d0
lea (gadgetcmdtable),a0
moveq.l #0,d2
move.w (a0,d0.w),d2 ; husker i d2
bmi.b 3$ ; negative skal sendes som meldinger
subq.l #1,d2
lsl.l #2,d2
lea (gadgetjmptable),a0
add.l d2,a0
move.l (a0),a0
move.l d4,d0 ; gir code videre
move.l (exebase),a6
jsr (a0)
beq.b 8$
bra.b 9$
3$ move.w activenode,d0 ; har vi en valgt ?
cmp.w #-1,d0
bne.b 2$ ; jepp
suba.l a0,a0 ; nei, blinker vinduet.
jsrlib DisplayBeep
bra.b 9$
2$ add.w #1,d0 ; har nodenummer i d0 nå
move.l exebase,a6
move.w d2,d1
bsr sendmsgtonodeasync
bne.b 9$ ; alt ok
cmp.w #Node_Show,d2 ; Fant ikke noden (trolig nede)
bne.b 8$ ; blink hvis det ikke var show
bsr main_opennode ; da prøver vi å åpne noden
bne.b 9$ ; blinker ikke hvis det gikk bra.
8$ move.l intbase,a6
suba.l a0,a0 ; nei, blinker vinduet.
jsrlib DisplayBeep
9$ pop d2/d3/d4/a6
rts
; d0: code
; returner z = 1 for displaybeep
main_winsize
move.l ABBSAppWindowWnd,a0
move.w (wd_Height,a0),d1
neg.w d1
tst.w d0
bne.b 1$ ; 1 = Show
add.w statuswinheight,d1
sub.w #28,d1
bra.b 2$
1$ add.w statuswinheight,d1
2$ move.l (intbase),a6
moveq.l #0,d0
jsrlib SizeWindow
9$ move.l (exebase),a6
clrz
rts
main_closeabbs
move.w MainBits(MainBase),d1 ; er vi locked ?
and.w #MainBitsF_ABBSLocked,d1
bne.b 9$ ; ja, nekte
move.w Nodes(MainBase),d1
notz
beq.b 9$ ; kan ikke
move.w #1,mainshutdown ; husker at vi skal ned
9$ rts
main_opennode
push d2
link.w a3,#-128
move.w activenode,d2 ; har vi en valgt ?
cmp.w #-1,d2
beq.b 9$ ; Nei, beep
add.w #1,d2
move.w d2,d0
move.l sp,a1
lea publicportname,a0
bsr fillinnodenr ; bygger opp navnet til porten
move.l sp,a1 ; Ser om vi finner porten
jsrlib FindPort
tst.l d0
notz
beq.b 9$ ; vi fant, da er den allerede oppe
move.w d2,d0
move.l sp,a0
bsr getnodeconfigfile
beq.b 9$
move.l sp,a0
move.w activenode,d0
add.w #1,d0
bsr restartnode
9$ unlk a3
pop d2
rts
main_ejectall
move.w #Node_Eject,d0
bsr loopallopennodes
rts
shutdownall
move.w #Node_Shutdown,d0
; bra loopallopennodes
; d0.w = command to send to all open nodes
loopallopennodes
push a2/d2/d3
move.w d0,d3
move.l nodelist+LH_HEAD,a2
1$ move.l (LN_SUCC,a2),d2
beq.b 9$
move.w (Nodenr,a2),d0
beq.b 2$
move.w d3,d1
bsr sendmsgtonodeasync
beq.b 99$
2$ move.l d2,a2
bra.b 1$
9$ clrz
99$ pop a2/d2/d3
rts
openstatuswindow
push a6/a2/a3
move.b #1,statusopen
jsr SetupScreen
bne.b closestatuswindow1
jsr OpenABBSAppWindowWindow
bne.b closestatuswindow1
move.l ABBSAppWindowWnd,a0
move.w (wd_Height,a0),statuswinheight
move.l wd_UserPort(a0),a0
moveq #0,d1
move.b MP_SIGBIT(a0),d1
moveq.l #0,d0
bset d1,d0
move.l d0,maingadtosigbit
or.l #SIGBREAKF_CTRL_E,d0
or.l d0,mainwait
move.l a0,maingadtoolport
move.w #-1,activenode ; sletter hvilken node som er valgt
; move.l (gadbase),a6
; move.l ABBSAppWindowWnd,a1
; move.l ABBSAppWindowGadgets,a0
; moveq.l #GDX_Win_size*4,d0
; add.l d0,a0
; move.l (a0),a0
; suba.l a2,a2
; lea (winsizetags),a3
; jsrlib GT_SetGadgetAttrsA
pop a6/a2/a3
clrz
rts
closestatuswindow
push a6
closestatuswindow1
move.b #0,statusopen
move.l maingadtosigbit,d0
or.l #SIGBREAKF_CTRL_E,d0
not.l d0
and.l d0,mainwait
jsr CloseABBSAppWindowWindow
jsr CloseDownScreen
move.l maingadtosigbit,d0 ; fjerner gadtools sigbit'et
or.l #SIGBREAKF_CTRL_E,d0
not.l d0
and.l d0,mainwait
pop a6
setz
rts
; a0 = cmdline
domainarexxcmd
lea mainarexxcmdtxt,a1
moveq.l #1,d0 ; vi kaller parserexxcmd ifra main
bsr parserexxcmd
beq.b 9$ ; ikke kjennt
lea mainarexxjmp,a0 ; utfører kommandoen
add.l d0,a0
move.l (a0),a0
jsr (a0) ; utfører
9$ rts
; Arexx kommandoene
; de skal returnere:
; a0 - retur string til arexx programmet, 0 for ingen
; d0 - retur verdi til arexx programmet (RC)
rexx_shutdown
moveq.l #5,d0 ; RC = 5, kan ikke lukke
move.w MainBits(MainBase),d1 ; er vi locked ?
and.w #MainBitsF_ABBSLocked,d1
bne.b 9$ ; ja, nekte
move.w Nodes(MainBase),d1
bne.b 9$
move.w #1,mainshutdown
moveq.l #0,d0 ; RC = 0, alt ok
9$ sub.l a0,a0 ; ingen return string
rts
rexx_startnode
moveq.l #10,d0 ; error
lea txtbuffer(MainBase),a1
move.l rx_NumParam(a1),d1 ; har vi 1 parameter ?
beq.b 9$ ; nope.