Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
1532 lines (1369 loc) · 56.7 KB

File metadata and controls

1532 lines (1369 loc) · 56.7 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
/*
AppleWin : An Apple //e emulator for Windows
Copyright (C) 1994-1996, Michael O'Brien
Copyright (C) 1999-2001, Oliver Schmidt
Copyright (C) 2002-2005, Tom Charlesworth
Copyright (C) 2006-2014, Tom Charlesworth, Michael Pohoreski
AppleWin is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
AppleWin is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with AppleWin; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Description: Debugger
*
* Author: Copyright (C) 2006-2010 Michael Pohoreski
*/
#include "StdAfx.h"
#include <cstdarg>
#include "Debug.h"
#include "..\AppleWin.h"
#define DEBUG_COLOR_CONSOLE 0
// Utility ________________________________________________________________________________________
/*
String types:
http://www.codeproject.com/cpp/unicode.asp
TEXT() _tcsrev
_UNICODE Unicode _wcsrev
_MBCS Multi-byte _mbsrev
n/a ASCII strrev
*/
// tests if pSrc fits into pDst
// returns true if pSrc safely fits into pDst, else false (pSrc would of overflowed pDst)
//===========================================================================
bool TestStringCat ( TCHAR * pDst, LPCSTR pSrc, const int nDstSize )
{
int nLenDst = _tcslen( pDst );
int nLenSrc = _tcslen( pSrc );
int nSpcDst = nDstSize - nLenDst;
int nChars = MIN( nLenSrc, nSpcDst );
bool bOverflow = (nSpcDst <= nLenSrc); // 2.5.6.25 BUGFIX
if (bOverflow)
{
return false;
}
return true;
}
// tests if pSrc fits into pDst
// returns true if pSrc safely fits into pDst, else false (pSrc would of overflowed pDst)
//===========================================================================
bool TryStringCat ( TCHAR * pDst, LPCSTR pSrc, const int nDstSize )
{
int nLenDst = _tcslen( pDst );
int nLenSrc = _tcslen( pSrc );
int nSpcDst = nDstSize - nLenDst;
int nChars = MIN( nLenSrc, nSpcDst );
bool bOverflow = (nSpcDst < nLenSrc);
if (bOverflow)
{
return false;
}
_tcsncat( pDst, pSrc, nChars );
return true;
}
// cats string as much as possible
// returns true if pSrc safely fits into pDst, else false (pSrc would of overflowed pDst)
//===========================================================================
int StringCat ( TCHAR * pDst, LPCSTR pSrc, const int nDstSize )
{
int nLenDst = _tcslen( pDst );
int nLenSrc = _tcslen( pSrc );
int nSpcDst = nDstSize - nLenDst;
int nChars = MIN( nLenSrc, nSpcDst );
_tcsncat( pDst, pSrc, nChars );
bool bOverflow = (nSpcDst < nLenSrc);
if (bOverflow)
return 0;
return nChars;
}
// Help ___________________________________________________________________________________________
//===========================================================================
Update_t HelpLastCommand()
{
return Help_Arg_1( g_iCommand );
}
// Loads the arguments with the command to get help on and call display help.
//===========================================================================
Update_t Help_Arg_1( int iCommandHelp )
{
_Arg_1( iCommandHelp );
wsprintf( g_aArgs[ 1 ].sArg, "%s", g_aCommands[ iCommandHelp ].m_sName ); // .3 Fixed: Help_Arg_1() now copies command name into arg.name
return CmdHelpSpecific( 1 );
}
//===========================================================================
void Help_Categories()
{
const int nBuf = CONSOLE_WIDTH * 2;
char sText[ nBuf ] = "";
int nLen = 0;
// TODO/FIXME: Colorize( sText, ... )
// Colorize("Usage:")
nLen += StringCat( sText, CHC_USAGE , nBuf );
nLen += StringCat( sText, "Usage", nBuf );
nLen += StringCat( sText, CHC_DEFAULT, nBuf );
nLen += StringCat( sText, ": " , nBuf );
nLen += StringCat( sText, CHC_ARG_OPT, nBuf );
nLen += StringCat( sText, "[ ", nBuf );
nLen += StringCat( sText, CHC_ARG_MAND, nBuf );
nLen += StringCat( sText, "< ", nBuf );
for (int iCategory = _PARAM_HELPCATEGORIES_BEGIN ; iCategory < _PARAM_HELPCATEGORIES_END; iCategory++)
{
char *pName = g_aParameters[ iCategory ].m_sName;
if (nLen + strlen( pName ) >= (CONSOLE_WIDTH - 1))
{
ConsolePrint( sText );
sText[ 0 ] = 0;
nLen = StringCat( sText, " ", nBuf ); // indent
}
StringCat( sText, CHC_COMMAND, nBuf );
nLen += StringCat( sText, pName , nBuf );
if (iCategory < (_PARAM_HELPCATEGORIES_END - 1))
{
char sSep[] = " | ";
if (nLen + strlen( sSep ) >= (CONSOLE_WIDTH - 1))
{
ConsolePrint( sText );
sText[ 0 ] = 0;
nLen = StringCat( sText, " ", nBuf ); // indent
}
StringCat( sText, CHC_ARG_SEP, nBuf );
nLen += StringCat( sText, sSep, nBuf );
}
}
StringCat( sText, CHC_ARG_MAND, nBuf );
StringCat( sText, " >", nBuf);
StringCat( sText, CHC_ARG_OPT, nBuf );
StringCat( sText, " ]", nBuf);
// ConsoleBufferPush( sText );
ConsolePrint( sText ); // Transcode colored text to native console color text
ConsolePrintFormat( sText, "%sNotes%s: %s<>%s = mandatory, %s[]%s = optional, %s|%s argument option"
, CHC_USAGE
, CHC_DEFAULT
, CHC_ARG_MAND
, CHC_DEFAULT
, CHC_ARG_OPT
, CHC_DEFAULT
, CHC_ARG_SEP
, CHC_DEFAULT
);
// ConsoleBufferPush( sText );
}
void Help_Examples()
{
char sText[ CONSOLE_WIDTH ];
ConsolePrintFormat( sText, " %sExamples%s:"
, CHC_USAGE
, CHC_DEFAULT
);
}
//===========================================================================
void Help_Range()
{
ConsoleBufferPush( " Where <range> is of the form:" );
ConsoleBufferPush( " address , length [address,address+length)" );
ConsoleBufferPush( " address : end [address,end]" );
}
//===========================================================================
void Help_Operators()
{
char sText[ CONSOLE_WIDTH ];
// ConsolePrintFormat( sText," %sOperators%s:" , CHC_USAGE, CHC_DEFAULT );
// ConsolePrintFormat( sText," Operators: (Math)" );
ConsolePrintFormat( sText," Operators: (%sMath%s)" , CHC_USAGE, CHC_DEFAULT );
ConsolePrintFormat( sText," %s+%s Addition" , CHC_USAGE, CHC_DEFAULT );
ConsolePrintFormat( sText," %s-%s Subtraction" , CHC_USAGE, CHC_DEFAULT );
ConsolePrintFormat( sText," %s*%s Multiplication" , CHC_USAGE, CHC_DEFAULT );
ConsolePrintFormat( sText," %s/%s Division" , CHC_USAGE, CHC_DEFAULT );
ConsolePrintFormat( sText," %s%%%s Modulas or Remainder" , CHC_USAGE, CHC_DEFAULT );
//ConsoleBufferPush( " Operators: (Bit Wise)" );
ConsolePrintFormat( sText," Operators: (%sBit Wise%s)" , CHC_USAGE, CHC_DEFAULT );
ConsolePrintFormat( sText," %s&%s Bit-wise and (AND)" , CHC_USAGE, CHC_DEFAULT );
ConsolePrintFormat( sText," %s|%s Bit-wise or (OR )" , CHC_USAGE, CHC_DEFAULT );
ConsolePrintFormat( sText," %s^%s Bit-wise exclusive-or (EOR/XOR)" , CHC_USAGE, CHC_DEFAULT );
ConsolePrintFormat( sText," %s!%s Bit-wise negation (NOT)" , CHC_USAGE, CHC_DEFAULT );
//ConsoleBufferPush( " Operators: (Input)" );
ConsolePrintFormat( sText," Operators: (%sInput%s)" , CHC_USAGE, CHC_DEFAULT );
ConsolePrintFormat( sText," %s@%s next number refers to search results", CHC_USAGE, CHC_DEFAULT );
ConsolePrintFormat( sText," %s\"%s Designate string in ASCII format" , CHC_USAGE, CHC_DEFAULT );
ConsolePrintFormat( sText," %s\'%s Desginate string in High-Bit apple format", CHC_USAGE, CHC_DEFAULT );
ConsolePrintFormat( sText," %s$%s Designate number/symbol" , CHC_USAGE, CHC_DEFAULT );
ConsolePrintFormat( sText," %s#%s Designate number in hex" , CHC_USAGE, CHC_DEFAULT );
//ConsoleBufferPush( " Operators: (Range)" );
ConsolePrintFormat( sText," Operators: (%sRange%s)" , CHC_USAGE, CHC_DEFAULT );
ConsolePrintFormat( sText," %s,%s range seperator (2nd address is relative)", CHC_USAGE, CHC_DEFAULT );
ConsolePrintFormat( sText," %s:%s range seperator (2nd address is absolute)", CHC_USAGE, CHC_DEFAULT );
// ConsolePrintFormat( sText," Operators: (Misc)" );
ConsolePrintFormat( sText," Operators: (%sMisc%s)" , CHC_USAGE, CHC_DEFAULT );
ConsolePrintFormat( sText," %s//%s comment until end of line" , CHC_USAGE, CHC_DEFAULT );
//ConsoleBufferPush( " Operators: (Breakpoint)" );
ConsolePrintFormat( sText," Operators: (%sBreakpoint%s)" , CHC_USAGE, CHC_DEFAULT );
_tcscpy( sText, " " );
_tcscat( sText, CHC_USAGE );
int iBreakOp = 0;
for( iBreakOp = 0; iBreakOp < NUM_BREAKPOINT_OPERATORS; iBreakOp++ )
{
if ((iBreakOp >= PARAM_BP_LESS_EQUAL) &&
(iBreakOp <= PARAM_BP_GREATER_EQUAL))
{
_tcscat( sText, g_aBreakpointSymbols[ iBreakOp ] );
_tcscat( sText, " " );
}
}
_tcscat( sText, CHC_DEFAULT );
ConsolePrint( sText );
}
void Help_KeyboardShortcuts()
{
ConsoleBufferPush(" Scrolling:" );
ConsoleBufferPush(" Up Arrow" );
ConsoleBufferPush(" Down Arrow" );
ConsoleBufferPush(" Shift + Up Arrow" );
ConsoleBufferPush(" Shift + Down Arrow" );
ConsoleBufferPush(" Page Up" );
ConsoleBufferPush(" Page Down" );
ConsoleBufferPush(" Shift + Page Up" );
ConsoleBufferPush(" Shift + Page Down" );
ConsoleBufferPush(" Bookmarks:" );
ConsoleBufferPush(" Ctrl-Shift-#" );
ConsoleBufferPush(" Ctrl-# " );
}
void _ColorizeHeader(
char * & pDst,const char * & pSrc,
const char * pHeader, const int nHeaderLen )
{
int nLen;
nLen = strlen( CHC_USAGE );
strcpy( pDst, CHC_USAGE );
pDst += nLen;
nLen = nHeaderLen - 1;
strncpy( pDst, pHeader, nLen );
pDst += nLen;
pSrc += nHeaderLen;
nLen = strlen( CHC_ARG_SEP );
strcpy( pDst, CHC_ARG_SEP );
pDst += nLen;
*pDst = ':';
pDst++;
nLen = strlen( CHC_DEFAULT );
strcpy( pDst, CHC_DEFAULT );
pDst += nLen;
}
void _ColorizeOperator(
char * & pDst, const char * & pSrc,
char * pOperator )
{
int nLen;
nLen = strlen( pOperator );
strcpy( pDst, pOperator );
pDst += nLen;
*pDst = *pSrc;
pDst++;
nLen = strlen( CHC_DEFAULT );
strcpy( pDst, CHC_DEFAULT );
pDst += nLen;
pSrc++;
}
bool Colorize( char * pDst, const char * pSrc )
{
if (! pSrc)
return false;
if (! pDst)
return false;
const char sNote [] = "Note:";
const int nNote = sizeof( sNote ) - 1;
const char sSeeAlso[] = "See also:";
const char nSeeAlso = sizeof( sSeeAlso ) - 1;
const char sUsage[] = "Usage:";
const int nUsage = sizeof( sUsage ) - 1;
const char sTotal[] = "Total:";
const int nTotal = sizeof( sTotal ) - 1;
int nLen = 0;
while (*pSrc)
{
if (strncmp( sUsage, pSrc, nUsage) == 0)
{
_ColorizeHeader( pDst, pSrc, sUsage, nUsage );
}
else
if (strncmp( sSeeAlso, pSrc, nSeeAlso) == 0)
{
_ColorizeHeader( pDst, pSrc, sSeeAlso, nSeeAlso );
}
else
if (strncmp( sNote, pSrc, nNote) == 0)
{
_ColorizeHeader( pDst, pSrc, sNote, nNote );
}
else
if (strncmp( sTotal, pSrc, nNote) == 0)
{
_ColorizeHeader( pDst, pSrc, sTotal, nTotal );
}
else
if (*pSrc == '[')
{
_ColorizeOperator( pDst, pSrc, CHC_ARG_OPT );
}
else
if (*pSrc == ']')
{
_ColorizeOperator( pDst, pSrc, CHC_ARG_OPT );
}
else
if (*pSrc == '<')
{
_ColorizeOperator( pDst, pSrc, CHC_ARG_MAND );
}
else
if (*pSrc == '>')
{
_ColorizeOperator( pDst, pSrc, CHC_ARG_MAND );
}
else
if (*pSrc == '|')
{
_ColorizeOperator( pDst, pSrc, CHC_ARG_SEP );
}
else
if (*pSrc == '\'')
{
_ColorizeOperator( pDst, pSrc, CHC_ARG_SEP );
}
else
{
*pDst = *pSrc;
pDst++;
pSrc++;
}
}
*pDst = 0;
return true;
}
inline bool ConsoleColorizePrint( char* colorizeBuf, size_t /*colorizeBufSz*/,
const char* pText )
{
if (!Colorize(colorizeBuf, pText)) return false;
return ConsolePrint(colorizeBuf);
}
template<size_t _ColorizeBufSz>
inline bool ConsoleColorizePrint( char (&colorizeBuf)[_ColorizeBufSz],
const char* pText )
{
return ConsoleColorizePrint(colorizeBuf, _ColorizeBufSz, pText);
}
inline bool ConsoleColorizePrintVa( char* colorizeBuf, size_t colorizeBufSz,
char* buf, size_t bufsz,
const char* format, va_list va )
{
vsnprintf_s(buf, bufsz, _TRUNCATE, format, va);
return ConsoleColorizePrint(colorizeBuf, colorizeBufSz, buf);
}
template<size_t _ColorizeBufSz, size_t _BufSz>
inline bool ConsoleColorizePrintVa( char (&colorizeBuf)[_ColorizeBufSz],
char (&buf)[_BufSz],
const char* format, va_list va )
{
return ConsoleColorizePrintVa(colorizeBuf, _ColorizeBufSz, buf, _BufSz, format, va);
}
inline bool ConsoleColorizePrintFormat( char* colorizeBuf, size_t colorizeBufSz,
char* buf, size_t bufsz,
const char* format, ... )
{
va_list va;
va_start(va, format);
bool const r = ConsoleColorizePrintVa(colorizeBuf, colorizeBufSz, buf, bufsz, format, va);
va_end(va);
return r;
}
template<size_t _ColorizeBufSz, size_t _BufSz>
inline bool ConsoleColorizePrintFormat( char (&colorizeBuf)[_ColorizeBufSz],
char (&buf)[_BufSz],
const char* format, ... )
{
va_list va;
va_start(va, format);
bool const r = ConsoleColorizePrintVa(colorizeBuf, buf, format, va);
va_end(va);
return r;
}
//===========================================================================
Update_t CmdMOTD( int nArgs ) // Message Of The Day
{
char sText[ CONSOLE_WIDTH*2 ];
char sTemp[ CONSOLE_WIDTH*2 ];
#if DEBUG_COLOR_CONSOLE
ConsolePrint( "`" );
ConsolePrint( "`A" );
ConsolePrint( "`2`A" );
#endif
ConsolePrintFormat( sText, "`9`A`7 Apple `9][ ][+ //e `7Emulator for Windows (TM) `9`@" );
CmdVersion(0);
CmdSymbols(0);
ConsoleColorizePrintFormat( sTemp, sText, " '%sCtrl ~'%s console, '%s%s'%s (specific), '%s%s'%s (all)"
, CHC_KEY
, CHC_DEFAULT
, CHC_COMMAND
, g_aCommands[ CMD_HELP_SPECIFIC ].m_sName
, CHC_DEFAULT
// , g_aCommands[ CMD_HELP_SPECIFIC ].pHelpSummary
, CHC_COMMAND
, g_aCommands[ CMD_HELP_LIST ].m_sName
, CHC_DEFAULT
// , g_aCommands[ CMD_HELP_LIST ].pHelpSummary
);
ConsoleUpdate();
return UPDATE_ALL;
}
// Help on specific command
//===========================================================================
Update_t CmdHelpSpecific (int nArgs)
{
int iArg;
char sText[ CONSOLE_WIDTH * 2 ];
char sTemp[ CONSOLE_WIDTH * 2 ];
ZeroMemory( sText, CONSOLE_WIDTH*2 );
ZeroMemory( sTemp, CONSOLE_WIDTH*2 );
if (! nArgs)
{
Help_Categories();
return ConsoleUpdate();
}
CmdFuncPtr_t pFunction = NULL;
bool bAllCommands = false;
bool bCategory = false;
bool bDisplayCategory = true;
if ((! _tcscmp( g_aArgs[1].sArg, g_aParameters[ PARAM_WILDSTAR ].m_sName)) ||
(! _tcscmp( g_aArgs[1].sArg, g_aParameters[ PARAM_MEM_SEARCH_WILD ].m_sName)) )
{
bAllCommands = true;
nArgs = NUM_COMMANDS;
}
// If Help on category, push command name as arg
// Mame has categories:
// General, Memory, Execution, Breakpoints, Watchpoints, Expressions, Comments
int iParam = 0;
int nNewArgs = 0;
int iCmdBegin = 0;
int iCmdEnd = 0;
int nFound = 0;
int iCommand = 0;
if (! bAllCommands)
{
for (iArg = 1; iArg <= nArgs; iArg++ )
{
// int nFoundCategory = FindParam( g_aArgs[ iArg ].sArg, MATCH_EXACT, iParam, _PARAM_HELPCATEGORIES_BEGIN, _PARAM_HELPCATEGORIES_END );
int nFoundCategory = FindParam( g_aArgs[ iArg ].sArg, MATCH_FUZZY, iParam, _PARAM_HELPCATEGORIES_BEGIN, _PARAM_HELPCATEGORIES_END );
if( nFoundCategory )
bCategory = true;
else
bCategory = false;
switch( iParam )
{
case PARAM_CAT_BOOKMARKS : iCmdBegin = CMD_BOOKMARK ; iCmdEnd = CMD_BOOKMARK_SAVE ; break;
case PARAM_CAT_BREAKPOINTS: iCmdBegin = CMD_BREAK_INVALID ; iCmdEnd = CMD_BREAKPOINT_SAVE ; break;
case PARAM_CAT_CONFIG : iCmdBegin = CMD_BENCHMARK ; iCmdEnd = CMD_CONFIG_SET_DEBUG_DIR; break;
case PARAM_CAT_CPU : iCmdBegin = CMD_ASSEMBLE ; iCmdEnd = CMD_UNASSEMBLE ; break;
case PARAM_CAT_FLAGS :
nFound = FindCommand( g_aArgs[iArg].sArg, pFunction, & iCommand ); // check if we have an exact command match first
if ( nFound ) // && (iCommand != CMD_MEMORY_FILL))
bCategory = false;
else if ( nFoundCategory )
{
iCmdBegin = CMD_FLAG_CLEAR ; iCmdEnd = CMD_FLAG_SET_N;
}
break;
case PARAM_CAT_HELP : iCmdBegin = CMD_HELP_LIST ; iCmdEnd = CMD_MOTD ; break;
case PARAM_CAT_KEYBOARD :
nFound = FindCommand( g_aArgs[iArg].sArg, pFunction, & iCommand ); // check if we have an exact command match first
if ((!nFound) || (iCommand != CMD_INPUT_KEY))
{
nArgs = 0;
Help_KeyboardShortcuts();
}
bCategory = false;
break;
case PARAM_CAT_MEMORY :
nFound = FindCommand( g_aArgs[iArg].sArg, pFunction, & iCommand ); // check if we have an exact command match first
if ( nFound )// && (iCommand != CMD_MEMORY_MOVE))
bCategory = false;
else if ( nFoundCategory )
{
iCmdBegin = CMD_MEMORY_COMPARE ; iCmdEnd = CMD_MEMORY_FILL ;
}
break;
case PARAM_CAT_OUTPUT :
nFound = FindCommand( g_aArgs[iArg].sArg, pFunction, & iCommand ); // check if we have an exact command match first
if ( nFound ) // && (iCommand != CMD_OUT))
bCategory = false;
else if ( nFoundCategory )
{
iCmdBegin = CMD_OUTPUT_CALC ; iCmdEnd = CMD_OUTPUT_RUN ;
}
break;
case PARAM_CAT_SYMBOLS :
nFound = FindCommand( g_aArgs[iArg].sArg, pFunction, & iCommand ); // check if we have an exact command match first
if ( nFound ) // && (iCommand != CMD_SYMBOLS_LOOKUP) && (iCommand != CMD_MEMORY_SEARCH))
bCategory = false;
else if ( nFoundCategory )
{
iCmdBegin = CMD_SYMBOLS_LOOKUP ; iCmdEnd = CMD_SYMBOLS_LIST ;
}
break;
case PARAM_CAT_VIEW :
{
iCmdBegin = CMD_VIEW_TEXT4X ; iCmdEnd = CMD_VIEW_DHGR2 ;
}
break;
case PARAM_CAT_WATCHES :
nFound = FindCommand( g_aArgs[iArg].sArg, pFunction, & iCommand ); // check if we have an exact command match first
if (nFound) {
bCategory = false;
} else // 2.7.0.17: HELP <category> wasn't displaying when category was one of: FLAGS, OUTPUT, WATCHES
if( nFoundCategory )
{
iCmdBegin = CMD_WATCH_ADD ; iCmdEnd = CMD_WATCH_LIST ;
}
break;
case PARAM_CAT_WINDOW : iCmdBegin = CMD_WINDOW ; iCmdEnd = CMD_WINDOW_OUTPUT ; break;
case PARAM_CAT_ZEROPAGE : iCmdBegin = CMD_ZEROPAGE_POINTER; iCmdEnd = CMD_ZEROPAGE_POINTER_SAVE; break;
// case PARAM_CAT_EXPRESSION : // fall-through
case PARAM_CAT_OPERATORS : nArgs = 0; Help_Operators(); break;
case PARAM_CAT_RANGE :
// HACK: check if we have an exact command match first
nFound = FindCommand( g_aArgs[iArg].sArg, pFunction, & iCommand );
if ((!nFound) || (iCommand != CMD_REGISTER_SET))
{
nArgs = 0;
Help_Range();
}
bCategory = false;
break;
default:
bCategory = false;
break;
}
if (iCmdEnd)
iCmdEnd++;
nNewArgs = (iCmdEnd - iCmdBegin);
if (nNewArgs > 0)
break;
}
}
if (nNewArgs > 0)
{
nArgs = nNewArgs;
for (iArg = 1; iArg <= nArgs; iArg++ )
{
#if DEBUG_VAL_2
g_aArgs[ iArg ].nVal2 = iCmdBegin + iArg - 1;
#endif
g_aArgs[ iArg ].nValue = iCmdBegin + iArg - 1;
}
}
for (iArg = 1; iArg <= nArgs; iArg++ )
{
iCommand = 0;
nFound = 0;
if (bCategory)
{
#if DEBUG_VAL_2
iCommand = g_aArgs[iArg].nVal2;
#endif
iCommand = g_aArgs[ iArg ].nValue;
nFound = 1;
}
else
if (bAllCommands)
{
iCommand = iArg;
if (iCommand == NUM_COMMANDS) // skip: Internal Consistency Check __COMMANDS_VERIFY_TXT__
continue;
nFound = 1;
}
else
nFound = FindCommand( g_aArgs[iArg].sArg, pFunction, & iCommand );
if (nFound > 1)
{
DisplayAmbigiousCommands( nFound );
}
if (iCommand > NUM_COMMANDS)
continue;
if ((nArgs == 1) && (! nFound))
iCommand = g_aArgs[iArg].nValue;
Command_t *pCommand = & g_aCommands[ iCommand ];
if (! nFound)
{
iCommand = NUM_COMMANDS;
pCommand = NULL;
}
// if (nFound && (! bAllCommands) && (! bCategory))
if (nFound && (! bAllCommands) && bDisplayCategory)
{
char sCategory[ CONSOLE_WIDTH ];
int iCmd = g_aCommands[ iCommand ].iCommand; // Unaliased command
// HACK: Major kludge to display category!!!
if (iCmd <= CMD_UNASSEMBLE)
wsprintf( sCategory, "%s", g_aParameters[ PARAM_CAT_CPU ].m_sName );
else
if (iCmd <= CMD_BOOKMARK_SAVE)
wsprintf( sCategory, "%s", g_aParameters[ PARAM_CAT_BOOKMARKS ].m_sName );
else
if (iCmd <= CMD_BREAKPOINT_SAVE)
wsprintf( sCategory, "%s", g_aParameters[ PARAM_CAT_BREAKPOINTS ].m_sName );
else
if (iCmd <= CMD_CONFIG_SET_DEBUG_DIR)
wsprintf( sCategory, "%s", g_aParameters[ PARAM_CAT_CONFIG ].m_sName );
else
if (iCmd <= CMD_CURSOR_PAGE_DOWN_4K)
wsprintf( sCategory, "Scrolling" );
else
if (iCmd <= CMD_FLAG_SET_N)
wsprintf( sCategory, "%s", g_aParameters[ PARAM_CAT_FLAGS ].m_sName );
else
if (iCmd <= CMD_MOTD)
wsprintf( sCategory, "%s", g_aParameters[ PARAM_CAT_HELP ].m_sName );
else
if (iCmd <= CMD_MEMORY_FILL)
wsprintf( sCategory, "%s", g_aParameters[ PARAM_CAT_MEMORY ].m_sName );
else
if (iCmd <= CMD_OUTPUT_RUN)
wsprintf( sCategory, "%s", g_aParameters[ PARAM_CAT_OUTPUT ].m_sName );
else
if (iCmd <= CMD_SYNC)
wsprintf( sCategory, "Source" );
else
if (iCmd <= CMD_SYMBOLS_LIST)
wsprintf( sCategory, "%s", g_aParameters[ PARAM_CAT_SYMBOLS ].m_sName );
else
if (iCmd <= CMD_VIEW_DHGR2)
wsprintf( sCategory, "%s", g_aParameters[ PARAM_CAT_VIEW ].m_sName );
else
if (iCmd <= CMD_WATCH_SAVE)
wsprintf( sCategory, "%s", g_aParameters[ PARAM_CAT_WATCHES ].m_sName );
else
if (iCmd <= CMD_WINDOW_OUTPUT)
wsprintf( sCategory, "%s", g_aParameters[ PARAM_CAT_WINDOW ].m_sName );
else
if (iCmd <= CMD_ZEROPAGE_POINTER_SAVE)
wsprintf( sCategory, "%s", g_aParameters[ PARAM_CAT_ZEROPAGE ].m_sName );
else
wsprintf( sCategory, "Unknown!" );
ConsolePrintFormat( sText, "%sCategory%s: %s%s"
, CHC_USAGE
, CHC_DEFAULT
, CHC_CATEGORY
, sCategory );
if (bCategory)
if (bDisplayCategory)
bDisplayCategory = false;
}
if (pCommand)
{
char *pHelp = pCommand->pHelpSummary;
if (pHelp)
{
if (bCategory)
sprintf( sText, "%s%8s%s, "
, CHC_COMMAND
, pCommand->m_sName
, CHC_ARG_SEP
);
else
sprintf( sText, "%s%s%s, "
, CHC_COMMAND
, pCommand->m_sName
, CHC_ARG_SEP
);
// if (! TryStringCat( sText, pHelp, g_nConsoleDisplayWidth ))
// {
// if (! TryStringCat( sText, pHelp, CONSOLE_WIDTH-1 ))
// {
strncat( sText, CHC_DEFAULT, CONSOLE_WIDTH );
strncat( sText, pHelp , CONSOLE_WIDTH );
// ConsoleBufferPush( sText );
// }
// }
ConsolePrint( sText );
}
else
{
#if _DEBUG
ConsoleBufferPushFormat( sText, "%s <-- Missing", pCommand->m_sName );
#if DEBUG_COMMAND_HELP
if (! bAllCommands) // Release version doesn't display message
{
ConsoleBufferPushFormat( sText, "Missing Summary Help: %s", g_aCommands[ iCommand ].aName );
}
#endif
#endif
}
if (bCategory)
continue;
}
// MASTER HELP
switch (iCommand)
{
// CPU / General
case CMD_ASSEMBLE:
ConsoleBufferPush( " Built-in assember isn't functional yet." );
break;
case CMD_UNASSEMBLE:
ConsoleColorizePrint( sText, " Usage: [address | symbol]" );
ConsoleBufferPush( " Disassembles memory." );
break;
case CMD_GO_NORMAL_SPEED:
case CMD_GO_FULL_SPEED:
ConsoleColorizePrint( sText, " Usage: address | symbol [Skip,Length]" );
ConsoleColorizePrint( sText, " Usage: address | symbol [Start:End]" );
ConsoleBufferPush( " Skip : Start address to skip stepping" );
ConsoleBufferPush( " Length: Range of bytes past start address to skip stepping" );
ConsoleBufferPush( " End : Inclusive end address to skip stepping" );
ConsoleBufferPush( " If the Program Counter is outside the skip range, resumes single-stepping." );
ConsoleBufferPush( " Can be used to skip ROM/OS/user code." );
Help_Examples();
ConsolePrintFormat( sText, "%s G[G] C600 FA00,600" , CHC_EXAMPLE );
ConsolePrintFormat( sText, "%s G[G] C600 F000:FFFF", CHC_EXAMPLE );
break;
case CMD_JSR:
ConsoleColorizePrint( sText, " %sUsage%s: %s[symbol | address]" );
ConsoleBufferPush( " Pushes PC on stack; calls the named subroutine." );
break;
case CMD_NOP:
ConsoleBufferPush( TEXT(" Puts a NOP opcode at current instruction") );
break;
case CMD_OUT:
ConsoleColorizePrint( sText, " Usage: [address8 | address16 | symbol] ## [##]" );
ConsoleBufferPush( TEXT(" Output a byte or word to the IO address $C0xx" ) );
break;
case CMD_PROFILE:
ConsoleColorizePrintFormat( sTemp, sText, " Usage: [%s | %s | %s]"
, g_aParameters[ PARAM_RESET ].m_sName
, g_aParameters[ PARAM_SAVE ].m_sName
, g_aParameters[ PARAM_LIST ].m_sName
);
ConsoleBufferPush( " No arguments resets the profile." );
break;
// Registers
case CMD_REGISTER_SET:
ConsoleColorizePrint( sText, " Usage: <reg> <value | expression | symbol>" );
ConsoleBufferPush( " Where <reg> is one of: A X Y PC SP " );
ConsoleColorizePrintFormat( sTemp, sText, " See also: %s%s"
, CHC_CATEGORY
, g_aParameters[ PARAM_CAT_OPERATORS ].m_sName );
Help_Examples();
ConsolePrintFormat( sText, "%s R PC RESET + 1", CHC_EXAMPLE );
ConsolePrintFormat( sText, "%s R PC $FC58" , CHC_EXAMPLE );
ConsolePrintFormat( sText, "%s R A A1" , CHC_EXAMPLE );
ConsolePrintFormat( sText, "%s R A $A1" , CHC_EXAMPLE );
ConsolePrintFormat( sText, "%s R A #A1" , CHC_EXAMPLE );
break;
case CMD_SOURCE:
// ConsoleBufferPush( TEXT(" Reads assembler source file." ) );
ConsoleColorizePrintFormat( sTemp, sText, " Usage: [ %s | %s ] \"filename\"" , g_aParameters[ PARAM_SRC_MEMORY ].m_sName, g_aParameters[ PARAM_SRC_SYMBOLS ].m_sName );
ConsoleBufferPushFormat( sText, " %s: read source bytes into memory." , g_aParameters[ PARAM_SRC_MEMORY ].m_sName );
ConsoleBufferPushFormat( sText, " %s: read symbols into Source symbol table.", g_aParameters[ PARAM_SRC_SYMBOLS ].m_sName );
ConsoleBufferPushFormat( sText, " Supports: %s." , g_aParameters[ PARAM_SRC_MERLIN ].m_sName );
break;
case CMD_STEP_OUT:
ConsoleBufferPush( " Steps out of current subroutine" );
ConsoleBufferPush( " Hotkey: Ctrl-Space" ); // TODO: FIXME
break;
case CMD_STEP_OVER: // Bad name? FIXME/TODO: do we need to rename?
ConsoleColorizePrint( sText, " Usage: [#]" );
ConsoleBufferPush( " Steps, # times, thru current instruction" );
ConsoleBufferPush( " JSR will be stepped into AND out of." );
ConsoleBufferPush( " Hotkey: Ctrl-Space" ); // TODO: FIXME
break;
case CMD_TRACE:
ConsoleColorizePrint( sText, " Usage: [#]" );
ConsoleBufferPush( " Traces, # times, current instruction(s)" );
ConsoleBufferPush( " JSR will be stepped into" );
ConsoleBufferPush( " Hotkey: Shift-Space" );
break;
case CMD_TRACE_FILE:
ConsoleColorizePrint( sText, " Usage: \"[filename]\" [v]" );
break;
case CMD_TRACE_LINE:
ConsoleColorizePrint( sText, " Usage: [#]" );
ConsoleBufferPush( " Traces into current instruction" );
ConsoleBufferPush( " with cycle counting." );
break;
// Bookmarks
case CMD_BOOKMARK:
case CMD_BOOKMARK_ADD:
ConsoleColorizePrint( sText, " Usage: [address | symbol]" );
ConsoleColorizePrint( sText, " Usage: # <address | symbol>" );
ConsoleBufferPush(" If no address or symbol is specified, lists the current bookmarks." );
ConsoleBufferPush(" Updates the specified bookmark (#)" );
Help_Examples();
ConsolePrintFormat( sText, "%s %s RESET ", CHC_EXAMPLE, pCommand->m_sName );
ConsolePrintFormat( sText, "%s %s 1 HOME", CHC_EXAMPLE, pCommand->m_sName );
break;
case CMD_BOOKMARK_CLEAR:
ConsoleColorizePrint( sText, " Usage: [# | *]" );
ConsoleBufferPush( " Clears specified bookmark, or all." );
Help_Examples();
ConsolePrintFormat( sText, "%s %s 1", CHC_EXAMPLE, pCommand->m_sName );
break;
case CMD_BOOKMARK_LIST:
// case CMD_BOOKMARK_LOAD:
case CMD_BOOKMARK_SAVE:
break;
// Breakpoints
case CMD_BREAK_INVALID:
ConsoleColorizePrintFormat( sTemp, sText, TEXT(" Usage: [%s%s | %s%s] | [ # | # %s%s | # %s%s ]")
, CHC_COMMAND
, g_aParameters[ PARAM_ON ].m_sName
, CHC_COMMAND
, g_aParameters[ PARAM_OFF ].m_sName
, CHC_COMMAND
, g_aParameters[ PARAM_ON ].m_sName
, CHC_COMMAND
, g_aParameters[ PARAM_OFF ].m_sName
);
ConsoleColorizePrint( sTemp, TEXT("Where: # is 0=BRK, 1=Invalid Opcode_1, 2=Invalid Opcode_2, 3=Invalid Opcode_3"));
break;
// case CMD_BREAK_OPCODE:
case CMD_BREAKPOINT:
ConsoleColorizePrintFormat( sTemp, sText, TEXT(" Usage: [%s%s | %s%s | %s%s]")
, CHC_COMMAND
, g_aParameters[ PARAM_LOAD ].m_sName
, CHC_COMMAND
, g_aParameters[ PARAM_SAVE ].m_sName
, CHC_COMMAND
, g_aParameters[ PARAM_RESET ].m_sName );
ConsolePrintFormat( sText, " Maximum breakpoints: %s%d", CHC_NUM_DEC, MAX_BREAKPOINTS );
ConsoleBufferPush( " Set breakpoint at PC if no args." );
ConsoleBufferPush( " Loading/Saving not yet implemented." );
break;
case CMD_BREAKPOINT_ADD_REG:
ConsoleColorizePrint( sText, " Usage: [A|X|Y|PC|S] [op] <range | value>" );
ConsoleBufferPush( " Set breakpoint when reg is [op] value" );
ConsoleBufferPush( " Default operator is '='" );
ConsoleColorizePrintFormat( sTemp, sText, " See also: %s%s"
, CHC_CATEGORY
, g_aParameters[ PARAM_CAT_OPERATORS ].m_sName );
// ConsoleBufferPush( " Examples:" );
Help_Examples();
ConsolePrintFormat( sText, "%s %s PC < D000" , CHC_EXAMPLE, pCommand->m_sName );
ConsolePrintFormat( sText, "%s %s PC = F000:FFFF PC < D000,1000", CHC_EXAMPLE, pCommand->m_sName );
ConsolePrintFormat( sText, "%s %s A <= D5" , CHC_EXAMPLE, pCommand->m_sName );
ConsolePrintFormat( sText, "%s %s A != 01:FF" , CHC_EXAMPLE, pCommand->m_sName );
ConsolePrintFormat( sText, "%s %s X = A5" , CHC_EXAMPLE, pCommand->m_sName );
break;
case CMD_BREAKPOINT_ADD_SMART:
ConsoleColorizePrint( sText, " Usage: [address | register]" );
ConsoleBufferPush( " If address, sets two breakpoints" );
ConsoleBufferPush( " 1. one memory access at address" );
ConsoleBufferPush( " 2. if PC reaches address" );
// "Sets a breakpoint at the current PC or specified address." );
ConsoleBufferPush( " If an IO address, sets breakpoint on IO access." );
ConsoleBufferPush( " If register, sets a breakpoint on memory access at address of register." );
break;
case CMD_BREAKPOINT_ADD_PC:
ConsoleColorizePrint( sText, " Usage: [address]" );
ConsoleBufferPush( " Sets a breakpoint at the current PC or at the specified address." );
break;
case CMD_BREAKPOINT_CLEAR:
ConsoleColorizePrint( sText, " Usage: [# | *]" );
ConsoleBufferPush( " Clears specified breakpoint, or all." );
Help_Examples();
ConsolePrintFormat( sText, "%s %s 1", CHC_EXAMPLE, pCommand->m_sName );
break;
case CMD_BREAKPOINT_DISABLE:
ConsoleColorizePrint( sText, " Usage: [# [,#] | *]" );
ConsoleBufferPush( " Disable breakpoint previously set, or all." );
Help_Examples();
ConsolePrintFormat( sText, "%s %s 1", CHC_EXAMPLE, pCommand->m_sName );
break;
Morty Proxy This is a proxified and sanitized view of the page, visit original site.