]> git.sur5r.net Git - cc65/blobdiff - libsrc/dbg/dbg.c
Only for jumps, the lib uses named asm labels in branches
[cc65] / libsrc / dbg / dbg.c
index 32a0cfba0494d67151e0904903209575f276e48d..60b4527996b8c9d19ff70f4146987464feb58b92 100644 (file)
@@ -1,9 +1,9 @@
 /*
- * dbg.c
- *
- * Ullrich von Bassewitz, 08.08.1998
- *
- */
+** dbg.c
+**
+** Ullrich von Bassewitz, 08.08.1998
+**
+*/
 
 
 
@@ -32,7 +32,7 @@ static char DumpHandler (void);
 static char HelpHandler (void);
 
 /* Forwards for other functions */
-static void DisplayPrompt (char* s);
+static void DisplayPrompt (const char* s);
 static void SingleStep (char StepInto);
 static void RedrawStatic (char  Frame);
 static void Redraw (char Frame);
@@ -47,7 +47,7 @@ static char GetKeyUpdate (void);
 
 
 /* Color definitions */
-#if defined(__PLUS4__) || defined(__C16__)
+#if defined(__C16__)
 #  define COLOR_BORDER          (BCOLOR_DARKBLUE | CATTR_LUMA6)
 #  define COLOR_BACKGROUND      COLOR_WHITE
 #  define COLOR_TEXTHIGH        COLOR_BLACK
@@ -63,7 +63,7 @@ static char GetKeyUpdate (void);
 #    define COLOR_FRAMEHIGH     COLOR_WHITE
 #    define COLOR_FRAMELOW      COLOR_GRAY3
 #  else
-#    if defined(__APPLE2__) || defined(__APPLE2ENH__)
+#    if defined(__APPLE2__)
 #      define COLOR_BORDER      COLOR_BLACK
 #      define COLOR_BACKGROUND  COLOR_BLACK
 #      define COLOR_TEXTHIGH    COLOR_BLACK
@@ -93,7 +93,7 @@ static char GetKeyUpdate (void);
 #  define MAX_X         80
 #  define MAX_Y         25
 #  define DUMP_BYTES    16
-#elif defined(__APPLE2__) || defined(__APPLE2ENH__) || defined(__ATARI__)
+#elif defined(__APPLE2__) || defined(__ATARI__)
 #  define MAX_X         40
 #  define MAX_Y         24
 #  define DUMP_BYTES     8
@@ -104,7 +104,7 @@ static char GetKeyUpdate (void);
 #endif
 
 /* Replacement key definitions */
-#if defined(__APPLE2__) || defined(__LYNX__) || defined(__SUPERVISION__)
+#ifndef CH_DEL
 #  define CH_DEL        ('H' - 'A' + 1)         /* Ctrl+H */
 #endif
 
@@ -166,7 +166,7 @@ extern unsigned      DbgHI;             /* High 16 bit of primary reg */
 typedef struct {
     unsigned char x;
     unsigned char y;
-    char*         text;
+    const char*   text;
 } TextDesc;
 
 /* Window descriptor */
@@ -181,13 +181,13 @@ typedef struct {
     unsigned char fd_visible;           /* Is the window currently visible? */
     char (*fd_func) (void);             /* Handler function */
     unsigned char fd_textcount;         /* Number of text lines to print */
-    TextDesc*     fd_text;              /* Static text in the window */
+    const TextDesc* fd_text;            /* Static text in the window */
 } FrameDesc;
 
 
 
 /* Texts for the windows */
-static TextDesc RegText [] = {
+static const TextDesc RegText [] = {
     { 1,  0, "PC" },
     { 1,  1, "SR" },
     { 1,  2, "A"  },
@@ -197,7 +197,7 @@ static TextDesc RegText [] = {
     { 1,  6, "CS" },
     { 1,  7, "HI" }
 };
-static TextDesc HelpText [] = {
+static const TextDesc HelpText [] = {
     { 1,  0, "F1, ?     Help"                           },
     { 1,  1, "F2, t     Toggle breakpoint"              },
     { 1,  2, "F3, u     Run until subroutine returns"   },
@@ -220,7 +220,7 @@ static TextDesc HelpText [] = {
 
 
 /* Window data */
-static FrameDesc AsmFrame = {
+static const FrameDesc AsmFrame = {
     CH_ULCORNER, CH_TTEE, CH_LTEE, CH_CROSS,
     0, 0, MAX_X - 10, 15,
     MAX_X - 11, 14,
@@ -228,7 +228,7 @@ static FrameDesc AsmFrame = {
     AsmHandler,
     0, 0
 };
-static FrameDesc RegFrame = {
+static const FrameDesc RegFrame = {
     CH_TTEE, CH_URCORNER, CH_LTEE, CH_RTEE,
     MAX_X - 10, 0, MAX_X - 1, 9,
     8, 8,
@@ -236,7 +236,7 @@ static FrameDesc RegFrame = {
     RegHandler,
     sizeof (RegText) / sizeof (RegText [0]), RegText
 };
-static FrameDesc StackFrame = {
+static const FrameDesc StackFrame = {
     CH_LTEE, CH_RTEE, CH_CROSS, CH_RTEE,
     MAX_X - 10, 9, MAX_X - 1, 15,
     8, 5,
@@ -244,7 +244,7 @@ static FrameDesc StackFrame = {
     StackHandler,
     0, 0
 };
-static FrameDesc CStackFrame = {
+static const FrameDesc CStackFrame = {
     CH_CROSS, CH_RTEE, CH_BTEE, CH_LRCORNER,
     MAX_X - 10, 15, MAX_X - 1, MAX_Y - 1,
     8, MAX_Y - 17,
@@ -252,7 +252,7 @@ static FrameDesc CStackFrame = {
     CStackHandler,
     0, 0
 };
-static FrameDesc DumpFrame = {
+static const FrameDesc DumpFrame = {
     CH_LTEE, CH_CROSS, CH_LLCORNER, CH_BTEE,
     0, 15, MAX_X - 10, MAX_Y-1,
     MAX_X - 11, MAX_Y - 17,
@@ -260,7 +260,7 @@ static FrameDesc DumpFrame = {
     DumpHandler,
     0, 0
 };
-static FrameDesc HelpFrame = {
+static const FrameDesc HelpFrame = {
     CH_ULCORNER, CH_URCORNER, CH_LLCORNER, CH_LRCORNER,
     0, 0, MAX_X - 1, MAX_Y-1,
     MAX_X - 2, MAX_Y - 2,
@@ -268,7 +268,7 @@ static FrameDesc HelpFrame = {
     HelpHandler,
     sizeof (HelpText) / sizeof (HelpText [0]), HelpText
 };
-static FrameDesc* Frames [] = {
+static const FrameDesc* const Frames [] = {
     &AsmFrame,
     &RegFrame,
     &StackFrame,
@@ -297,7 +297,7 @@ static unsigned char StackAddr; /* Start address of output */
 
 
 /* Prompt line data */
-static char* ActivePrompt = 0;  /* Last prompt line displayed */
+static const char* ActivePrompt = 0;  /* Last prompt line displayed */
 static char PromptColor;        /* Color behind prompt */
 static char PromptLength;       /* Length of current prompt string */
 
@@ -335,8 +335,8 @@ BreakPoint* DbgGetBreakSlot (void);
 
 BreakPoint* DbgIsBreak (unsigned Addr);
 /* Check if there is a user breakpoint at the given address, if so, return
- * a pointer to the slot, else return 0.
- */
+** a pointer to the slot, else return 0.
+*/
 
 
 
@@ -346,10 +346,10 @@ BreakPoint* DbgIsBreak (unsigned Addr);
 
 
 
-static void DrawFrame (register FrameDesc* F, char Active)
+static void DrawFrame (register const FrameDesc* F, char Active)
 /* Draw one window frame */
 {
-    TextDesc* T;
+    const TextDesc* T;
     unsigned char Count;
     unsigned char tl, tr, bl, br;
     unsigned char x1, y1, width;
@@ -410,7 +410,7 @@ static void DrawFrames (void)
 /* Draw all frames */
 {
     unsigned char I;
-    FrameDesc* F;
+    const FrameDesc* F;
 
     /* Build the frame layout of the screen */
     for (I = 0; I < sizeof (Frames) / sizeof (Frames [0]); ++I) {
@@ -427,7 +427,7 @@ static void ActivateFrame (int Num, unsigned char Clear)
 /* Activate a new frame, deactivate the old one */
 {
     unsigned char y;
-    register FrameDesc* F;
+    register const FrameDesc* F;
 
     if (ActiveFrame != Num) {
 
@@ -462,7 +462,7 @@ static void ActivateFrame (int Num, unsigned char Clear)
 
 
 
-static void DisplayPrompt (char* s)
+static void DisplayPrompt (const char* s)
 /* Display a prompt */
 {
     unsigned char OldColor;
@@ -518,6 +518,10 @@ static char IsAbortKey (char C)
     if (C == CH_STOP) {
         return 1;
     }
+#endif
+#if !defined(CH_ESC) && !defined(CH_STOP)
+    /* Avoid compiler warning about unused parameter */
+    (void) C;
 #endif
     return 0;
 }
@@ -622,11 +626,11 @@ static char InputHex (char* Prompt, unsigned* Val)
 
 
 
-static void ErrorPrompt (char* Msg)
+static void ErrorPrompt (const char* Msg)
 /* Display an error message and wait for a key */
 {
     /* Save the current prompt */
-    char* OldPrompt = ActivePrompt;
+    const char* OldPrompt = ActivePrompt;
 
     /* Display the new one */
     DisplayPrompt (Msg);
@@ -725,8 +729,8 @@ static void DbgResetTmpBreaks (void)
 
 static unsigned char DbgTmpBreaksOk (void)
 /* Check if the temporary breakpoints can be set, if so, return 1, if not,
- * reset them all and return 0.
- */
+** reset them all and return 0.
+*/
 {
     unsigned char i;
     BreakPoint* B = DbgBreaks;
@@ -751,8 +755,8 @@ static unsigned char DbgTmpBreaksOk (void)
 
 static unsigned AsmBack (unsigned mem, unsigned char lines)
 /* Go back in the assembler window the given number of lines (calculate
- * new start address).
- */
+** new start address).
+*/
 {
     unsigned cur;
     unsigned adr [32];
@@ -772,8 +776,8 @@ static unsigned AsmBack (unsigned mem, unsigned char lines)
                     return adr [(in - lines - 1) & 0x1F];
                 } else {
                     /* The requested address is inside an instruction, go back
-                     * one more byte and try again.
-                     */
+                    ** one more byte and try again.
+                    */
                     ++offs;
                     break;
                 }
@@ -1343,8 +1347,8 @@ static void SingleStep (char StepInto)
         case OPC_BNE:
         case OPC_BEQ:
             /* Be sure not to set the breakpoint twice if this is a jump to
-             * the following instruction.
-             */
+            ** the following instruction.
+            */
             Offs = ((signed char*)brk_pc)[1];
             if (Offs) {
                 DbgSetTmpBreak (brk_pc + Offs + 2);
@@ -1487,8 +1491,8 @@ void DbgEntry (void)
     }
 
     /* Only initialize variables here, don't do a display update. The actual
-     * display update will be done while waiting for user input.
-     */
+    ** display update will be done while waiting for user input.
+    */
     AsmHome ();
     UpdateReg ();               /* Must update this (static later) */
     StackHome ();