forked from dragonbytes/CoCoIRC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoco_irc.asm
1897 lines (1719 loc) · 56.3 KB
/
coco_irc.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
******************************************************************
* CoCoIRC - a simple IRC client for nitros-9 that uses drivewire
* to communication with internet
* Written by Todd Wallace (LordDragon)
******************************************************************
; TODO STUFF
; ---------------------------------------------------------------------------------
; - add a command to list all of the current settings in your config file
; - add filtering ability to ONLY see channel messages from the active channel
; - add CTCP PING function
; - implement wordwrap on inputbar when it scrolls to next "page"
; - add support to play BELL when your nickname is said in chatlog by someone
; - add CTCP VERSION requesting
; potential structure for channel allocation ram blocks
; 0-1 = 16 bit offset to start of ring buffer
; 2-3 = 16bit offset to current location of chatlog buffer
; 4-255 = channel name / private nick name / etc in null terminated ASCII
; Definitions/equates
STDOUT EQU 1
STDIN EQU 0
H6309 set 1
network_signal EQU 32
keyboard_signal EQU 33
connect_timeout_signal EQU $88
server_timeout_signal EQU $99
nickChanByteSize EQU 32
max_nick_length EQU 20
server_timeout_interval EQU 3600 ; 60 * 60 = 1 minute
server_timeout_count EQU 5 ; minutes
cr_lf EQU $0D0A
screen_width EQU 80
; Color number defintions
colorNormal EQU 16 ; this is really color 0 since upper 4 bits
; are truncated, but lets me use NULL terminated
; strings with color codes
; (nice trick @Deek !)
colorTimestamp EQU 1
colorChanName EQU 2
colorQuit EQU 3
colorYourNick EQU 4
colorJoinPart EQU 5
colorNotice EQU 6
colorNickChan EQU 7
;debug_mode EQU 1
use_word_wrap EQU 1
include os9.d
include rbf.d
include scf.d
pragma cescapes
; Module header setup info
MOD MODULE_SIZE,moduleName,$11,$80,START_EXEC,data_size
START_MODULE
**************************************************************************************
; -----------------------------------------------------
; Variables
org 0
uRegImage RMB 2
chatlogPath RMB 1
statusbarPath RMB 1
inputbarPath RMB 1
networkPath RMB 1
nilPath RMB 1
configFilePath RMB 1
helpFilePath RMB 1
; pointers
inputBufferStart RMB 2
inputBufferPtr RMB 2
inputBufferEnd RMB 2
networkBufferPtr RMB 2
serverBufferPtr RMB 2
serverBufferEnd RMB 2
serverBufferLength RMB 2
netBufferBytesRem RMB 1
keyInputCount RMB 1
outputBufferPtr RMB 2
tempPtr RMB 2
nickPtr RMB 2
chanPtr RMB 2
msgPtr RMB 2
paramLength RMB 1
serverCmdPtr RMB 2
sourceHostmaskPtr RMB 2
wrapSourcePtr RMB 2
wrapDestPtr RMB 2
cmdWordLength RMB 1
cmdWordCounter RMB 1
u8Value RMB 1
u16Value RMB 2
u32Value RMB 4
epochYear RMB 1
epochMonth RMB 1
epochDay RMB 1
epochHour RMB 1
epochMinute RMB 1
epochSecond RMB 1
strNumeric RMB 6
decDigitCounter RMB 1
columnWidth RMB 1
columnSpacing RMB 1
columnCounter RMB 1
; flags
networkDataReady RMB 1
keyboardDataReady RMB 1
abortFlag RMB 1
connectTimeoutFlag RMB 1
connectPendingFlag RMB 1
disconnectedFlag RMB 1
connectedStatus RMB 1
idValidatedFlag RMB 1
activeDestFlag RMB 1
moreNamesPendingFlag RMB 1
timeoutCounter RMB 1
namesRequestedFlag RMB 1
nickServLoginPending RMB 1
oldConfigFlag RMB 1
tempCounter RMB 1
tempChar RMB 1
tempWord RMB 2
; this area contains block of settings written to config file
; ---------------------------
; color theme values
configFileVariables EQU .
backColorChatlog RMB 1
backColorStatusbar RMB 1
textColorNormal RMB 1
textColorTimestamp RMB 1
textColorChanName RMB 1
textColorQuit RMB 1
textColorYourNick RMB 1
textColorJoinPart RMB 1
textColorNickNotice RMB 1
textColorNickChan RMB 1
; config file flags
printMOTDflag RMB 1
showTimestampFlag RMB 1
showNamesOnJoinFlag RMB 1
; ---------------------------
; Extended config file params
nickServPassFlag RMB 1 ; 0 = no password saved, and therefore, no auto-login possibile either
; positive non-zero = password saved, but auto-login is disabled.
; negative non-zero = password saved and auto-login enabled
; ---------------------------
currentNickname RMB 32
currentUsername RMB 32
currentRealname RMB 32
pdBuffer RMB 32
sysDateTime RMB 6
strTimestamp RMB 18
palBuffer RMB 16
; buffers/windows arrays etc
inputBuffer RMB 256
inputBufferSz EQU .-inputBuffer
networkBuffer RMB 256
networkBufferSz EQU .-networkBuffer
serverBuffer RMB 512
serverBufferSz EQU .-serverBuffer
outputBuffer RMB 1024
IFDEF use_word_wrap
wordWrapBuffer RMB 1024
ENDC
; Structure of Destination Array:
; First 2 bytes are 0 when that slot is empty/unused, otherwise, they are part of the
; channel/nick name.
destOffset RMB 2
destArray RMB nickChanByteSize*16 ; enough for 16 channels/nicknames total
destArraySz EQU .-destArray
; server variables
serverAddress RMB 64
serverPort RMB 6
serverHostname RMB 128
serverYourNick RMB 20
serverYourNickUpper RMB 20
serverNetworkName RMB 32
serverChanName RMB 32
sourceNickname RMB max_nick_length
destNickname RMB max_nick_length
destChanName RMB 32
yourHostmask RMB 128
strFixedOutput RMB 64
strModeOperators RMB 2
userQuitMessage RMB 64
userVersionReply RMB 64
userServerDefault RMB 64
userNickservPass RMB 32
userNickservPassSz EQU .-userNickservPass
; End of Variables
; -----------------------------------------------------
data_size EQU .
; -----------------------------------------------------
; Constants
moduleName FCS "cocoirc"
networkPathName FCS "/N"
winPathName FCC "/W\r"
nilPathName FCC "/NIL\r"
configFilePathName FCC "/DD/SYS/cocoirc.conf\r"
helpUsageFilename FCC "/DD/SYS/cocoirc.hlp\r"
charEraseLn FCB $03,$0D
charBell FCB C$BELL
charsBSO FCB C$BSP,C$SPAC,C$BSP
charClear FCB C$FORM
strCoCoIRCversion FCN "1.0"
strIntro1 FCN "Welcome to \x1b\x32\x05CoCoIRC v"
strIntro2 FCN "\x1b\x32\x10, a native Internet Relay Chat Client\r\n\n"
strAuthor FCN "Written by \x1b\x32\x04Todd Wallace\x1b\x32\x10 for the Tandy Color Computer 3\r\n"
strWebsite FCN "For the latest updates on all my CoCo projects, go to \x1b\x32\x04https://tektodd.com\x1b\x32\x10\r\n\n"
strTitleGraphical FCN "CoCoIRC v"
strIntroHelp FCN "Type /HELP for program instructions and a list of other commands you can use.\r\n\n"
strCocoIRC FCN " CoCoIRC - "
strStateDisconnected FCN "Disconnected"
strStateConnected FCN "Connected | "
strStatusActive FCN "Active Window: "
strStatusActiveNone FCN "No Active Windows"
; user variable defaults
strVersionReply FCN "CoCoIRC v1.0 / NitrOS-9 / Tandy Color Computer 3\r"
strExitQuitMsg FCN "CoCoIRC user has quit. Soarrry about that.\r"
strDefaultNickname FCN "SamGime\r"
strDefaultUsername FCN "cocouser\r" ; THIS MUST BE LOWERCASE CUZ, REASONS?
strDefaultRealname FCN "Samuel Gimes\r"
strServerDefault FCN "irc.libera.chat:6667\r"
encryptionKey FCN "coco4eva"
dwSetChatlog FCB $1B,$20,2,0,0,80,22,0,1,1
dwSetStatusbar FCB $1B,$20,0,0,22,80,1,0,2
dwSetInputbar FCB $1B,$20,0,0,23,80,1,0,1
paletteDefs FCB 0,8 ; background colors main + statusbar
FCB 63,56,48,9,25,18,36,52 ; 8 foreground colors
dwSelectCodes FCB $1B,$21
setFontCodes FCB $1B,$3A,$C8,$42
; constats for epoch adder routine
epochDigitCounters FQB 1
FQB 10
FQB 100
FQB 1000
FQB 10000
FQB 100000
FQB 1000000
FQB 10000000
FQB 100000000
FQB 1000000000
epochConstDay FQB 86400 ; seconds per day
epochConstHour FQB 3600
epochConst72offset FQB 63072000 ; seconds between 1970 and 1972 (first leap year)
epochConstOffset FQB 94694400 ; seconds between epoch begin (1970) and start of 1973
epochMonthTable EQU *
epochConstJan FQB 2678400 ; (31 * 86400)
epochConstFeb FQB 2419200 ; (28 * 86400)
epochConstMar FQB 2678400 ; (31 * 86400)
epochConstApr FQB 2592000 ; (30 * 86400)
epochConstMay FQB 2678400 ; (31 * 86400)
epochConstJun FQB 2592000 ; (30 * 86400)
epochConstJul FQB 2678400 ; (31 * 86400)
epochConstAug FQB 2678400 ; (31 * 86400)
epochConstSep FQB 2592000 ; (30 * 86400)
epochConstOct FQB 2678400 ; (31 * 86400)
epochConstNov FQB 2592000 ; (30 * 86400)
epochConstDec FQB 2678400 ; (31 * 86400)
strEpochJan FCN "January"
strEpochFeb FCN "February"
strEpochMar FCN "March"
strEpochApr FCN "April"
strEpochMay FCN "May"
strEpochJun FCN "June"
strEpochJul FCN "July"
strEpochAug FCN "August"
strEpochSep FCN "September"
strEpochOct FCN "October"
strEpochNov FCN "November"
strEpochDec FCN "December"
strEpochMonthPtrs FDB strEpochJan
FDB strEpochFeb
FDB strEpochMar
FDB strEpochApr
FDB strEpochMay
FDB strEpochJun
FDB strEpochJul
FDB strEpochAug
FDB strEpochSep
FDB strEpochOct
FDB strEpochNov
FDB strEpochDec
; user command words
userCmdWords EQU *
strSERVERkeyword FCN "SERVER"
strCONNECTkeyword FCN "CONNECT"
strEXITkeyword FCN "EXIT"
strQUITkeyword FCN "QUIT"
strJOINkeyword FCN "JOIN"
strPARTkeyword FCN "PART"
strCYCLEkeyword FCN "CYCLE"
strTOPICkeyword FCN "TOPIC"
strNAMESkeyword FCN "NAMES"
strMSGkeyword FCN "MSG"
strMEkeyword FCN "ME"
strACTIONkeyword FCN "ACTION"
strNICKkeyword FCN "NICK"
strQUERYkeyword FCN "QUERY"
strWHOISkeyword FCN "WHOIS"
strCLOSEkeyword FCN "CLOSE"
strNOTICEkeyword FCN "NOTICE"
strKICKkeyword FCN "KICK"
strMODEkeyword FCN "MODE"
strOPkeyword FCN "OP"
strDEOPkeyword FCN "DEOP"
strVOICEkeyword FCN "VOICE"
strDEVOICEkeyword FCN "DEVOICE"
strBANkeyword FCN "BAN"
strUNBANkeyword FCN "UNBAN"
strNICKSERVkeyword FCN "NICKSERV"
strNSkeyword FCN "NS" ; alternate for NickServ
strRAWkeyword FCN "RAW"
strSETkeyword FCN "SET"
strSAVEkeyword FCN "SAVE"
strLOADkeyword FCN "LOAD"
strCLEARkeyword FCN "CLEAR"
strHELPkeyword FCN "HELP"
strABOUTkeyword FCN "ABOUT"
strPREVkeyword FCN "PREV"
strNEXTkeyword FCN "NEXT"
strEPOCHkeyword FCN "EPOCH"
strINTROkeyword FCN "INTRO"
strCTCPkeyword FCN "CTCP"
FCB $FF
userCmdWordPtrs FDB COMMAND_SERVER
FDB COMMAND_SERVER
FDB COMMAND_EXIT
FDB COMMAND_QUIT
FDB COMMAND_JOIN
FDB COMMAND_PART
FDB COMMAND_CYCLE
FDB COMMAND_TOPIC
FDB COMMAND_NAMES
FDB COMMAND_MSG
FDB COMMAND_ACTION
FDB COMMAND_ACTION
FDB COMMAND_NICK
FDB COMMAND_QUERY
FDB COMMAND_WHOIS
FDB COMMAND_CLOSE
FDB COMMAND_NOTICE
FDB COMMAND_KICK
FDB COMMAND_MODE
FDB COMMAND_OP
FDB COMMAND_DEOP
FDB COMMAND_VOICE
FDB COMMAND_DEVOICE
FDB COMMAND_BAN
FDB COMMAND_UNBAN
FDB COMMAND_NICKSERV
FDB COMMAND_NICKSERV
FDB COMMAND_RAW
FDB COMMAND_SET
FDB COMMAND_SAVE
FDB COMMAND_LOAD
FDB COMMAND_CLEAR
FDB COMMAND_HELP
FDB COMMAND_ABOUT
FDB COMMAND_PREV_DESTINATION
FDB COMMAND_NEXT_DESTINATION
FDB COMMAND_EPOCH
FDB COMMAND_INTRO
FDB COMMAND_CTCP
dwConnected FCC "CONNECTED\r\n"
dwConnectedSize EQU *-dwConnected
noCarrier FCC "NO CARRIER\r\n"
noCarrierSize EQU *-noCarrier
strQuitChangingServer FCN "QUIT :Changing servers...\r\n"
strCycleChanMsg FCN " :Cycling...\r\n"
; keywords and other parameter constants
strNetworkKeyword FCN "NETWORK="
strPRIVMSGkeyword FCN "PRIVMSG"
strPINGkeyword FCN "PING"
strVERSIONkeyword FCN "VERSION"
strREALNAMEkeyword FCN "REALNAME"
strUSERkeyword FCN "USER"
strQUITMSGkeyword FCN "QUITMSG"
strMOTDkeyword FCN "MOTD"
strCOLORkeyword FCN "COLOR"
strTEXTkeyword FCN "TEXT"
strTIMESTAMPkeyword FCN "TIMESTAMP"
strCHANNAMEkeyword FCN "CHANNAME"
strYOURNICKkeyword FCN "YOURNICK"
strCHANINFOkeyword FCN "CHANINFO"
strCHANNICKkeyword FCN "CHANNICK"
strBACKGROUNDkeyword FCN "BACKGROUND"
strSTATUSBARkeyword FCN "STATUSBAR"
strDEFAULTSkeyword FCN "DEFAULTS"
strTRUEkeyword FCN "TRUE"
strONkeyword FCN "ON"
strFALSEkeyword FCN "FALSE"
strOFFkeyword FCN "OFF"
strIDENTIFYkeyword FCN "IDENTIFY"
strPASSkeyword FCN "PASS"
strLOGINkeyword FCN "LOGIN"
strAUTOLOGINkeyword FCN "AUTOLOGIN"
strIRCserverConnect FCN "ATD "
strIRCserverQuit FCN "QUIT "
strIRCserverPart FCN "PART "
strIRCserverJoin FCN "JOIN "
strIRCserverMsg FCN "PRIVMSG "
strIRCserverNotice FCN "NOTICE "
strIRCserverNick FCN "NICK "
strIRCserverUser FCN "USER "
strIRCserverAction FCN "ACTION "
strIRCserverWhois FCN "WHOIS "
strIRCserverKick FCN "KICK "
strIRCserverMode FCN "MODE "
strIRCserverTopic FCN "TOPIC "
strIRCserverNames FCN "NAMES "
strTimestampTemplate FCB $1B,$32,colorTimestamp
FCC "[ : : ] "
FCB $1B,$32,colorNormal
strTimestampTemplateSz EQU *-strTimestampTemplate
FCB $00 ; NULL for string-copying routines
strUserMsgTrying FCN "-- Trying IRC server "
strUserMsgTryingPort FCN " port "
strUserMsgDefaultServer FCN "-- Using your saved server address or the default if not set\r\n"
strUserMsgConnected FCN "-- Connected. Logging in...\r\n"
strUserMsgDisconnected FCN "-- Disconnected from IRC server\r\n"
strUserMsgChangingServer FCN "-- Disconnected to change server\r\n"
strUserMsgYouJoined FCN "You have joined channel "
strUserMsgHasJoined FCN " has joined channel "
strUserMsgYouParted FCN "You have left channel "
strUserMsgHasParted FCN " has left channel "
strUserMsgTopic FCN "Topic for "
strUserMsgTopicSetBy FCN " set by "
strUserMsgTopicNotSet FCN "Topic not set for channel "
strUserMsgNames FCN "Current users on channel "
strUserMsgNamesEnd FCN "End of user list"
strUserMsgQuit FCN " has quit IRC "
strUserMsgMOTDsuppress FCN "-- Ignoring MOTD messages... "
strUserMsgMOTDsuppressed FCN "Done!\r\n"
strUserMsgYourNick FCN "Your nickname is "
strUserMsgYourNewNick FCN "Your nickname is now "
strUserMsgNickChanged FCN " changed their nickname to "
strUserMsgSetsMode FCN " sets mode "
strUserMsgOnChannel FCN " on channel "
strUserMsgUserModeChg FCN "* You set usermode "
strUserMsgVersionRequested FCN "* Received a CTCP VERSION request from "
strUserMsgVersionSent FCN "* Sent CTCP VERSION reply: "
strUserMsgCTCPSentRequest1 FCN "* Sent CTCP "
strUserMsgCTCPSentRequest2 FCN " request to "
strUserMsgYouKicked FCN "* You have been kicked from "
strUserMsgWasKicked FCN " was kicked from "
strUserMsgKickedBy FCN " by "
strUserMsgWhoisIdle FCN "Idle "
strUserMsgWhoisDays FCN " days "
strUserMsgWhoisHours FCN " hours "
strUserMsgWhoisMins FCN " minutes "
strUserMsgWhoisSecs FCN " seconds"
strUserMsgWhoisSignon FCN "Signed on "
strUserMsgNickServCustom FCN "* You sent NICKSERV command: "
strUserMsgNickServIDsent FCN "* Sent NickServ identify request\r\n"
strMsgTryingConfigFile FCN "Trying to load configuration from file "
strMsgConfigFileLoaded FCN "Config loaded successfully.\r\n\n"
strMsgNoConfigFile FCN "Config file could be not found or is inaccessible.\r\n\n"
strMsgStartupNoConfigFile FCN "Config file not found or inaccessible.\r\n\n\x1b\x32\x04Default\x1b\x32\x10 settings will be used for this session. If this is your first time using CoCoIRC or IRC in general, type \x1b\x32\x05/INTRO\x1b\x32\x10 for some tips on how to get started or \x1b\x32\x05/HELP\x1b\x32\x10 to view the complete list of available commands and other program instructions.\r\n\n"
strMsgConfigSaving FCN "Saving configuration to file "
strMsgConfigDots FCN "...\r\n"
strMsgConfigOldVersion FCB $1B,$32,colorNotice
FCC "Warning: "
FCB $1B,$32,colorNormal
FCC "Your config file is from a older version of CoCoIRC. While it will\r\n"
FCC "still work just fine, the next time you use /SAVE to update your config file,\r\n"
FCN "it will be overwritten with the new version format.\r\n\n"
strIntro FCN "\x1b\x32\x06-=\x1b\x32\x07 Introduction \x1b\x32\x06=-\x1b\x32\x10\r\n\nOh hai thar! To get started chatting with CoCoIRC, you can use the command \x1b\x32\x05/SERVER <address>[:port]\x1b\x32\x10 to connect to an IRC network. A list of popular networks and their address info can be found at \x1b\x32\x04http://irchelp.org/networks/\x1b\x32\x10. If you don't specify a port number, the default of 6667 will be used.\r\n\nIf you would like to chat with other CoCo users on IRC, I would recommend connecting to \x1b\x32\x06irc.libera.chat\x1b\x32\x10 and joining us in the \x1b\x32\x02#coco_chat\x1b\x32\x10 channel by using the command \x1b\x32\x05/JOIN \x1b\x32\x02#coco_chat\x1b\x32\x10. Have fun and long live the CoCo!\r\n\n"
strMsgDefaultsSaved FCN "Configuration saved.\r\n\n"
strMsgNewDefaultNextConnect FCN "-- You must (re)connect to server for change to take effect"
strMsgNewDefaultNick FCN "-- New default for your NICKNAME: "
strMsgNewDefaultRealname FCN "-- New default for your REAL NAME: "
strMsgNewDefaultUsername FCN "-- New default for your USERNAME: "
strMsgNewDefaultQuitMsg FCN "-- New default for your QUIT MESSAGE: "
strMsgNewDefaultCTCPver FCN "-- New default for your CTCP VERSION REPLY: "
strMsgNewDefaultServer FCN "-- New default for your IRC SERVER: "
strMsgNewDefaultNickserv FCN "-- New default for your NICKSERV PASSWORD: "
strMsgNewDefaultColor FCN "-- New default color for "
strMsgColorResetDefaults FCN "-- Color palette has been reset to default values\r\n"
strMsgDefaultChanInfo FCN "CHANNEL INFORMATION: "
strMsgDefaultChatlogText FCN "CHATLOG TEXT: "
strMsgDefaultBackground FCN "BACKGROUND: "
strMsgDefaultNotice FCN "NOTICES: "
strMsgDefaultQuit FCN "QUIT MESSAGES: "
strMsgDefaultChatNicks FCN "CHANNEL NICKNAMES: "
strMsgDefaultYourNick FCN "YOUR NICKNAME: "
strMsgDefaultStatusbar FCN "STATUS BAR: "
strMsgDefaultChanName FCN "CHANNEL NAMES: "
strMsgDefaultTimestamp FCN "TIMESTAMP: "
strMsgTimestampEnabled FCN "-- Timestamps are now ENABLED\r\n"
strMsgTimestampDisabled FCN "-- Timestamps are now DISABLED\r\n"
strMsgMOTDenabled FCN "-- Server MOTD messages are now ENABLED\r\n"
strMsgMOTDdisabled FCN "-- Server MOTD messages are now DISABLED\r\n"
strMsgNamesOnJoinEnabled FCN "-- Display of nicknames when joining channels is now ENABLED\r\n"
strMsgNamesOnJoinDisabled FCN "-- Display of nicknames when joining channels is now DISABLED\r\n"
strMsgNickServLoginEnabled FCN "-- NickServ auto-login is now ENABLED\r\n"
strMsgNickServLoginDisabled FCN "-- NickServ auto-login is now DISABLED\r\n"
; pointers for the color variable labels
colorNamePtr FDB strMsgDefaultBackground
FDB strMsgDefaultStatusbar
FDB strMsgDefaultChatlogText
FDB strMsgDefaultTimestamp
FDB strMsgDefaultChanName
FDB strMsgDefaultQuit
FDB strMsgDefaultYourNick
FDB strMsgDefaultChanInfo
FDB strMsgDefaultNotice
FDB strMsgDefaultChatNicks
; errors
strErrorInvalidCmd FCN "-- Invalid command. Use /HELP to see a list of available commands.\r\n"
strErrorVRNmodule FCN "-- Couldn't load VRN /NIL module. Timeout timers will not function\r\n"
strErrorIRCtimeout FCN "-- Connection attempt has timed out. Aborting\r\n"
strErrorPingTimeout FCN "-- Connection with IRC server has timed out (300 seconds). Aborted\r\n"
strDisconnectedMsg FCN "-- Disconnected\r\n"
strErrorDWPath1 FCN "-- Could not open path to /N device descriptor. This is\r\n"
strErrorDWPath2 FCN "required for internet connectivity. Is DriveWire installed?\r\n"
strErrorReading FCC "-- Error reading bytes from DriveWire server\r"
strErrorWritingConfig FCN "Error writing to config file. Could not save settings.\r\n"
strErrorDeletingConfig FCN "Error deleting old config file. Could not save settings.\r\n"
strErrorHelpFile FCN "-- Could not open or access the help file at /DD/SYS/cocoirc.hlp\r\n"
strErrorHelpNotFound1 FCN "-- No help info found on that command. Type /HELP to see a complete\r\n"
strErrorHelpNotFound2 FCN " list of available commands.\r\n"
strErrorTime FCC "-- Error reading time\r\n"
strErrorTimeSz EQU *-strErrorTime
strErrorJoinedAlready FCN "-- You already joined that channel\r\n"
strErrorNotConnected FCN "-- You must be connected to an IRC server to use that command\r\n"
strErrorMsgInvalid FCN "-- Invalid parameter(s)\r\n"
strErrorMsgUseHelp FCN "-- Use /HELP for a list of commands their usage\r\n"
strErrorMsgMissingParam FCN "-- Missing parameter(s)\r\n"
strErrorMsgNoActiveWin FCN "-- No active window to use\r\n"
strErrorMsgDestListFull FCN "-- Window list is full. Please use /PART or /CLOSE and try again\r\n"
strErrorInvalidChanName FCN "-- Invalid channel name\r\n"
strErrorNickInUse1 FCN "* Nickname "
strErrorNickInUse2 FCN " is already in use.\r\n"
strErrorNickChooseAnother FCN "-- Choose another using /NICK <nickname>\r\n"
strErrorNoSuchNick FCN "* No such nickname "
strErrorNoSuchChannel FCN "* No such channel "
strErrorNoOps FCN "* You are not an operator on channel "
strErrorNickInvalid FCN "-- Missing parameter. Syntax is /NICK <nickname>\r\n"
strErrorCloseDestNotFound FCN "-- Cannot find that window entry to close\r\n"
strErrorCloseMissingParam FCN "-- No active window to close or none specified\r\n"
strErrorNickServLogin FCN "-- Cannot set auto-login because no NickServ password has been set yet\r\n"
strErrorNickServNoPass FCN "-- Cannot login to NickServ because no password has been set\r\n"
; About section
strAbout1 FCB $1B,$32,colorJoinPart
FCN "\r\nCoCoIRC v"
strAbout2 FCB $1B,$32,colorNormal
FCC " Written by "
FCB $1B,$32,colorYourNick
FCN "Todd Wallace\r\n\n"
strAboutDescription FCB $1B,$32,colorNormal
FCC "CoCoIRC was a labor of love of mine that has been several months in the\r\n"
FCC "making. I actually first had the idea back in the 90s when I was in college.\r\n"
FCC "I had seen terminal-based solutions for the CoCo that let you chat on IRC\r\n"
FCC "using telnet, but I thought it would be so much cooler to have some kind of\r\n"
FCC "native client similiar to mIRC on Windows. At the time, I lacked the skill to\r\n"
FCC "write something like that and didn't have access to the modern hardware\r\n"
FCC "luxuries we have now, but when I learned about DriveWire and it's virtual\r\n"
FCC "terminal functionality, CoCoIRC was born! In the future, I do plan to support\r\n"
FCC "other serial to TCP/IP solutions if they have working NitrOS-9 drivers.\r\n\n"
FCC "I want to really thank the CoCo community for all their advice and support\r\n"
FCC "in writing this program, without which this would NOT have been possible.\r\n\n"
FCC "Special thanks goes out to "
FCB $1B,$32,colorYourNick
FCC "L. Curtis Boyle"
FCB $1B,$32,colorNormal,',',C$SPAC,$1B,$32,colorYourNick
FCC "William Astle"
FCB $1B,$32,colorNormal
FCC ", and "
FCB $1B,$32,colorYourNick
FCC "Deek"
FCB $1B,$32,colorNormal
FCC ". You guys\r\n"
FCC "are always around to answer my questions or just chat. Thank you!\r\n\n"
strAboutDescriptionSz EQU *-strAboutDescription
; debug strings
IFDEF debug_mode
strJoinStart FCN "Join Started\r\n"
strJoinEnd FCN "Join Finished\r\n"
asciiHexList FCC "0123456789ABCDEF"
asciiHexPrefix FCB '$'
ENDC
; -----------------------------------------------------
START_EXEC
**************************************************************************************
* Program code area
* RULE #1 - USE U TO REFERENCE ANY CHANGEABLE VARIABLES IN THE DATA AREA.
* RULE #2 - USE PCR TO REFERENCE CONSTANTS SINCE THEY RESIDE WITH EXECUTABLE CODE.
* RULE #3 - NEVER USE JSR FOR CALLING SUBROUTINES. ALWAYS USE BSR OR LBSR INSTEAD.
**************************************************************************************
stu <uRegImage ; save copy of data area pointer in U
; init some variables
ldd #0
std <serverBufferLength
sta <keyboardDataReady
sta <networkDataReady
sta <abortFlag
sta <connectTimeoutFlag
sta <connectPendingFlag
sta <disconnectedFlag
sta <connectedStatus
sta <idValidatedFlag
sta <activeDestFlag
sta <moreNamesPendingFlag
sta <printMOTDflag
sta serverYourNick,U
sta serverHostname,U
sta serverNetworkName,U
std destOffset,U
sta <namesRequestedFlag
sta <nickServPassFlag
sta <nickServLoginPending
ldd #$FFFF
sta <networkPath
sta <nilPath
sta <configFilePath
lda #1
sta <showTimestampFlag
sta <showNamesOnJoinFlag
lda #80
sta <columnCounter
lda #server_timeout_count
sta <timeoutCounter
leay networkBuffer,U
sty <networkBufferPtr
leay serverBuffer,U
sty <serverBufferPtr
leay serverBufferSz,Y
sty <serverBufferEnd
leay inputBuffer,U
sty <inputBufferStart
sty <inputBufferPtr
leay inputBufferSz-1,Y ; always leave room for a CR at the end
sty <inputBufferEnd
; setup timestamp delimitters/brackets/bordering spaces
leay strTimestamp,U
leax strTimestampTemplate,PCR
lbsr STRING_COPY_RAW
; setup the channel/nickname destination array
lbsr DESTINATION_INITIALIZE_ARRAY
; init the fixed width printing variables
lda #20
sta <columnWidth
lda #3
sta <columnSpacing
; setup path to VRN driver for timer functionality like timeout timers
lda #UPDAT.
clrb
leax nilPathName,PCR
os9 I$Open
bcc GOT_VRN_PATH
; tell user vrn is needed for the timeout timers to work
leax strErrorVRNmodule,PCR
lbsr PRINT_INFO_ERROR_MESSAGE
lda #$FF ; this makes sure bit 7 is set so we know there is no VRN
GOT_VRN_PATH
sta <nilPath
; setup all the window paths
lda #UPDAT.
clrb
leax winPathName,PCR
os9 I$Open
sta <chatlogPath
ldy #10
leax dwSetChatlog,PCR
os9 I$Write
; you must select the main window before doing anything else it seems
lda <chatlogPath
leax dwSelectCodes,PCR
ldy #2
os9 I$Write
; setup statusbar window path
lda #UPDAT.
clrb
leax winPathName,PCR
os9 I$Open
sta <statusbarPath
ldy #9
leax dwSetStatusbar,PCR
os9 I$Write
; setup input bar window path
lda #UPDAT.
clrb
leax winPathName,PCR
os9 I$Open
sta <inputbarPath
ldy #9
leax dwSetInputbar,PCR
os9 I$Write
; start with default color palette
lbsr INIT_COLOR_SETTINGS
lbsr WRITE_COLOR_CONFIG_TO_PALETTE
; turn off echo/linefeed for inputbar window so we can edit out backspace codes and CR etc
lda <inputbarPath
ldb #SS.Opt
leax pdBuffer,U
os9 I$GetStt
clr PD.EKO-PD.OPT,X
clr PD.ALF-PD.OPT,X
lda <inputbarPath
ldb #SS.Opt
leax pdBuffer,U
os9 I$SetStt
; select inputbar
ldy #2
leax dwSelectCodes,PCR
os9 I$Write
; print initial status bar
lbsr STATUS_BAR_UPDATE
; setup the intercept stuff
leax SIGNAL_HANDLER,PCR
os9 F$Icpt
; setup the signal for keyboard input
lda <inputbarPath
ldb #SS.SSig
ldx #keyboard_signal
os9 I$SetStt
; print the intro information
leax strIntro1,PCR
lbsr PRINT_CHATLOG_NULL_STRING
leax strCoCoIRCversion,PCR
lbsr PRINT_CHATLOG_NULL_STRING
leax strIntro2,PCR
lbsr PRINT_CHATLOG_NULL_STRING
leax strAuthor,PCR
lbsr PRINT_CHATLOG_NULL_STRING
leax strWebsite,PCR
lbsr PRINT_CHATLOG_NULL_STRING
; leax strIntroHelp,PCR
; lbsr PRINT_CHATLOG_NULL_STRING
;lbsr DRAW_INTRO_BOX
; tell user you are trying to load config file and if exists, load them into their variables if exists.
; otherwise, load defaults
leay outputBuffer,U
leax strMsgTryingConfigFile,PCR
lbsr STRING_COPY_RAW
leax configFilePathName,PCR
lbsr STRING_COPY_CR
leax strMsgConfigDots,PCR
lbsr STRING_COPY_RAW
leax outputBuffer,U
lbsr PRINT_CHATLOG_NULL_STRING
lbsr CONFIG_LOAD_FROM_FILE
bcs CONFIG_FILE_NONE_LOAD_DEFAULTS
; inform the user saved settings are successfully loaded
leax strMsgConfigFileLoaded,PCR
lbsr PRINT_CHATLOG_NULL_STRING
lda <oldConfigFlag
beq CONFIG_FILE_RECENT_VERSION
leax strMsgConfigOldVersion,PCR
lbsr PRINT_CHATLOG_NULL_STRING
CONFIG_FILE_RECENT_VERSION
; display the normal /HELP notice since a config file exists and this is not a brand new user
leax strIntroHelp,PCR
lbsr PRINT_CHATLOG_NULL_STRING
; write the config's palette values to the window paths
lbsr WRITE_COLOR_CONFIG_TO_PALETTE
bra CONFIG_FILE_DONE
CONFIG_FILE_NONE_LOAD_DEFAULTS
; this could mean it's a new user so tell them about /INTRO and /HELP
leax strMsgStartupNoConfigFile,PCR
lbsr PRINT_CHATLOG_WITH_WORD_WRAP
; init internal settings variables such as nickname, username, realname with defaults
leax strDefaultNickname,PCR
leay currentNickname,U
lbsr STRING_COPY_RAW
leax strDefaultUsername,PCR
leay currentUsername,U
lbsr STRING_COPY_RAW
leax strDefaultRealname,PCR
leay currentRealname,U
lbsr STRING_COPY_RAW
leax strVersionReply,PCR
leay userVersionReply,U
lbsr STRING_COPY_RAW
leax strExitQuitMsg,PCR
leay userQuitMessage,U
lbsr STRING_COPY_RAW
leax strServerDefault,PCR
leay userServerDefault,U
lbsr STRING_COPY_RAW
CONFIG_FILE_DONE
MAINLOOP
ldb <abortFlag
lbne EXIT_ABORT
; check to see if we suddenly lost connection to drivewire server
ldb <disconnectedFlag
beq MAINLOOP_CHECK_CONNECTION_ATTEMPT_TIMEOUT
; we have been disconnected either on purpose, or unexpecedly
; disable any running timeout timers
lda <nilPath
bmi MAINLOOP_SKIP_DISABLE_VRN_TIMER
ldb #SS.FClr
ldx #0
ldy #0
os9 I$SetStt
MAINLOOP_SKIP_DISABLE_VRN_TIMER
; let the user know what the situation is
leax strDisconnectedMsg,PCR
lbsr PRINT_INFO_ERROR_MESSAGE
lbsr DRIVEWIRE_RESET ; close the path, reset flags, variables, ptrs, etc
lbsr DESTINATION_INITIALIZE_ARRAY
lbsr STATUS_BAR_UPDATE
bra MAINLOOP
MAINLOOP_CHECK_CONNECTION_ATTEMPT_TIMEOUT
; check to see if a connection attempt to irc server has timed out
ldb <connectTimeoutFlag
beq MAINLOOP_CHECK_SERVER_TIMEOUT
; connecting to IRC server has timed out. inform the user of the bad news
leax strErrorIRCtimeout,PCR
lbsr PRINT_INFO_ERROR_MESSAGE
lbsr DRIVEWIRE_RESET ; close the path, reset flags, variables, ptrs, etc
lbsr DESTINATION_INITIALIZE_ARRAY
lbsr STATUS_BAR_UPDATE
bra MAINLOOP
MAINLOOP_CHECK_SERVER_TIMEOUT
; check to see if we have stopped receiving messages from the IRC server.
ldb <timeoutCounter
bne MAINLOOP_CHECK_KEYBOARD
; if here, we have not seen any network traffic from the IRC server in awhile. assume we
; have lost the connection somehow and abort.
; first, disable signal timer
lda <nilPath
ldb #SS.FClr
ldx #0
ldy #0
os9 I$SetStt
; then reset timeout counter value
lda #server_timeout_count
sta <timeoutCounter
; let the user know
leax strErrorPingTimeout,PCR
lbsr PRINT_INFO_ERROR_MESSAGE
lbsr DRIVEWIRE_RESET ; close the path, reset flags, variables, ptrs, etc
lbsr DESTINATION_INITIALIZE_ARRAY
lbsr STATUS_BAR_UPDATE
bra MAINLOOP
MAINLOOP_CHECK_KEYBOARD
ldb <keyboardDataReady
lbeq MAINLOOP_CHECK_NETWORK
ldx <inputBufferPtr
lda <inputbarPath
ldb #SS.Ready
os9 I$GetStt
lbcs MAINLOOP_KEYBOARD_RESET_SIGNAL ; something went wrong, just reset/ignore
stb <keyInputCount
MAINLOOP_KEYBOARD_NEXT_READ
ldy #1
os9 I$Read
ldb ,X
; figure out what it is and what to do with it.
cmpb #C$CR
lbeq MAINLOOP_KEYBOARD_CR
cmpb #C$BSP
beq MAINLOOP_KEYBOARD_BACKSPACE
cmpb #$11 ; CTRL + Right Arrow
beq MAINLOOP_KEYBOARD_NEXT_DEST
cmpb #$10 ; CTRL + Left Arrow
beq MAINLOOP_KEYBOARD_PREV_DEST
cmpb #$20
blo MAINLOOP_KEYBOARD_DEC_COUNTER ; skip special characters like esc codes
; if here, its a normal character
cmpx <inputBufferEnd
lbhs MAINLOOP_KEYBOARD_PLAY_BELL ; buffer is full, so ignore unless its a CR or BS
; normal char, write to screen etc
ldy #1
os9 I$Write
dec <columnCounter
bne MAINLOOP_KEYBOARD_SKIP_COLUMN_RESET
ldb #screen_width
stb <columnCounter
MAINLOOP_KEYBOARD_SKIP_COLUMN_RESET
leax 1,X
MAINLOOP_KEYBOARD_DEC_COUNTER
dec <keyInputCount
bne MAINLOOP_KEYBOARD_NEXT_READ
stx <inputBufferPtr ; save the inputbuffer pointer
lbra MAINLOOP_KEYBOARD_RESET_SIGNAL
MAINLOOP_KEYBOARD_NEXT_DEST
lbsr COMMAND_NEXT_DESTINATION
bra MAINLOOP_KEYBOARD_DEC_COUNTER
MAINLOOP_KEYBOARD_PREV_DEST
lbsr COMMAND_PREV_DESTINATION
bra MAINLOOP_KEYBOARD_DEC_COUNTER
MAINLOOP_KEYBOARD_BACKSPACE
cmpx <inputBufferStart
bls MAINLOOP_KEYBOARD_PLAY_BELL
; before we do anythig else, check to see if we are backspacing to a previous page off-screen
ldb <columnCounter
cmpb #screen_width
beq MAINLOOP_KEYBOARD_BACKSPACE_RESTORE_PREV_LINE
inc <columnCounter
; do a destructive backspace to screen
pshs X
leax charsBSO,PCR
ldy #3
os9 I$Write
puls X
leax -1,X
bra MAINLOOP_KEYBOARD_DEC_COUNTER
MAINLOOP_KEYBOARD_BACKSPACE_RESTORE_PREV_LINE
stx <tempPtr
leax -screen_width,X
ldy #screen_width-1
os9 I$Write
ldx <tempPtr
leax -1,X
ldb #1
stb <columnCounter
bra MAINLOOP_KEYBOARD_DEC_COUNTER
MAINLOOP_KEYBOARD_PLAY_BELL
pshs X
; play the BELL noise to let them know the buffer is full
leax charBell,PCR
ldy #1
os9 I$Write
puls X
bra MAINLOOP_KEYBOARD_DEC_COUNTER