]> git.sur5r.net Git - cc65/blobdiff - libsrc/dbg/dbg.c
The spans do now contain the size of a span, no longer the end offset.
[cc65] / libsrc / dbg / dbg.c
index c285027d4894c015e8d86a9d34ff130890b2d6ed..c2ddb194bf3f235da67394817a1093ee65ca61ea 100644 (file)
@@ -44,6 +44,8 @@ static char GetKeyUpdate (void);
 /*                                  Data                                    */
 /*****************************************************************************/
 
+
+
 /* Color definitions */
 #if defined(__PLUS4__) || defined(__C16__)
 #  define COLOR_BORDER         (BCOLOR_DARKBLUE | CATTR_LUMA6)
@@ -53,7 +55,7 @@ static char GetKeyUpdate (void);
 #  define COLOR_FRAMEHIGH      COLOR_BLACK
 #  define COLOR_FRAMELOW       COLOR_GRAY2
 #else
-#  ifdef COLOR_GRAY3
+#  if defined(COLOR_GRAY3)
 #    define COLOR_BORDER       COLOR_BLACK
 #    define COLOR_BACKGROUND   COLOR_BLACK
 #    define COLOR_TEXTHIGH     COLOR_WHITE
@@ -61,7 +63,7 @@ static char GetKeyUpdate (void);
 #    define COLOR_FRAMEHIGH    COLOR_WHITE
 #    define COLOR_FRAMELOW     COLOR_GRAY3
 #  else
-#    ifdef __APPLE2__
+#    if defined(__APPLE2__) || defined(__APPLE2ENH__)
 #      define COLOR_BORDER             COLOR_BLACK
 #      define COLOR_BACKGROUND  COLOR_BLACK
 #      define COLOR_TEXTHIGH   COLOR_BLACK
@@ -85,7 +87,7 @@ static char GetKeyUpdate (void);
 #  define MAX_X                80
 #  define MAX_Y                25
 #  define DUMP_BYTES   16
-#elif defined(__APPLE2__) || defined(__ATARI__)
+#elif defined(__APPLE2__) || defined(__APPLE2ENH__) || defined(__ATARI__)
 #  define MAX_X         40
 #  define MAX_Y         24
 #  define DUMP_BYTES     8
@@ -95,7 +97,10 @@ static char GetKeyUpdate (void);
 #  define DUMP_BYTES    8
 #endif
 
-
+/* Replacement key definitions */
+#if defined(__APPLE2__)
+#  define CH_DEL        ('H' - 'A' + 1)         /* Ctrl+H */
+#endif
 
 /* Defines for opcodes */
 #define        OPC_BRK         0x00
@@ -168,13 +173,14 @@ static TextDesc HelpText [] = {
     { 1,  7, "+         Page down"                             },
     { 1,  8, "-         Page up"                       },
     { 1,  9, "Cursor    Move up/down"                          },
-    { 1, 10, "c         Continue"                      },
-    { 1, 11, "f         Follow instruction"            },
-    { 1, 12, "o         Goto origin"                           },
-    { 1, 13, "p         Use as new PC value"           },
-    { 1, 14, "q         Quit"                          },
-    { 1, 15, "r         Redraw screen"                         },
-    { 1, 16, "s         Skip next instruction"         },
+    { 1, 10, "a/z       Move up/down"                   },
+    { 1, 11, "c         Continue"                      },
+    { 1, 12, "f         Follow instruction"            },
+    { 1, 13, "o         Goto origin"                           },
+    { 1, 14, "p         Use as new PC value"           },
+    { 1, 15, "q         Quit"                          },
+    { 1, 16, "r         Redraw screen"                         },
+    { 1, 17, "s         Skip next instruction"         },
 };
 
 
@@ -351,7 +357,7 @@ static void DrawFrame (register FrameDesc* F, char Active)
     cvlinexy (F->fd_x2, y1, F->fd_height);
 
     /* If the window has static text associated, print the text */
-    textcolor (COLOR_TEXTLOW);
+    (void) textcolor (COLOR_TEXTLOW);
     Count = F->fd_textcount;
     T = F->fd_text;
     while (Count--) {
@@ -360,7 +366,7 @@ static void DrawFrame (register FrameDesc* F, char Active)
     }
 
     /* Set the old color */
-    textcolor (OldColor);
+    (void) textcolor (OldColor);
 }
 
 
@@ -431,7 +437,7 @@ static void DisplayPrompt (char* s)
 
     /* Clear the old prompt if there is one */
     if (ActivePrompt) {
-       textcolor (PromptColor);
+       (void) textcolor (PromptColor);
        chlinexy ((MAX_X - PromptLength) / 2, MAX_Y-1, PromptLength);
     }
 
@@ -441,11 +447,11 @@ static void DisplayPrompt (char* s)
     PromptLength = strlen (ActivePrompt);
 
     /* Display the new prompt */
-    textcolor (COLOR_TEXTHIGH);
+    (void) textcolor (COLOR_TEXTHIGH);
     cputsxy ((MAX_X - PromptLength) / 2, MAX_Y-1, ActivePrompt);
 
     /* Restore the old color */
-    textcolor (PromptColor);
+    (void) textcolor (PromptColor);
 }
 
 
@@ -465,6 +471,24 @@ static void AnyKeyPrompt (void)
 
 
 
+static char IsAbortKey (char C)
+/* Return true if C is an abort key */
+{
+#if defined(CH_ESC)
+    if (C == CH_ESC) {
+        return 1;
+    }
+#endif
+#if defined(CH_STOP)
+    if (C == CH_STOP) {
+        return 1;
+    }
+#endif
+    return 0;
+}
+
+
+
 static char Input (char* Prompt, char* Buf, unsigned char Count)
 /* Read input from the user, return 1 on success, 0 if aborted */
 {
@@ -482,7 +506,7 @@ static char Input (char* Prompt, char* Buf, unsigned char Count)
     /* Display the new prompt */
     OldColor = textcolor (COLOR_TEXTHIGH);
     cputsxy (0, MAX_Y-1, Prompt);
-    textcolor (COLOR_TEXTLOW);
+    (void) textcolor (COLOR_TEXTLOW);
 
     /* Remember where we are, enable the cursor */
     x1 = wherex ();
@@ -496,14 +520,14 @@ static char Input (char* Prompt, char* Buf, unsigned char Count)
            Buf [i] = c;
            cputcxy (x1 + i, MAX_Y-1, c);
                    ++i;
-       } else if (i > 0 && c == CH_DEL) {
+               } else if (i > 0 && c == CH_DEL) {
                    --i;
            cputcxy (x1 + i, MAX_Y-1, ' ');
            gotoxy (x1 + i, MAX_Y-1);
        } else if (c == '\n') {
            Buf [i] = '\0';
            done = 1;
-       } else if (c == CH_ESC) {
+       } else if (IsAbortKey (c)) {
            /* Abort */
            done = 2;
        }
@@ -511,7 +535,7 @@ static char Input (char* Prompt, char* Buf, unsigned char Count)
 
     /* Reset settings, display old prompt line */
     cursor (OldCursor);
-    textcolor (OldColor);
+    (void) textcolor (OldColor);
     DrawFrames ();
     Frame = ActiveFrame;
     ActiveFrame = -1;
@@ -866,11 +890,17 @@ static char AsmHandler (void)
                brk_pc = AsmAddr;
                break;
 
+            case 'a':
+#ifdef CH_CURS_UP
            case CH_CURS_UP:
+#endif
                AsmAddr = AsmBack (AsmAddr, 1);
                break;
 
+            case 'z':
+#ifdef CH_CURS_DOWN
            case CH_CURS_DOWN:
+#endif
                AsmAddr += DbgDisAsmLen (AsmAddr);
                break;
 
@@ -994,20 +1024,26 @@ static char StackHandler (void)
                StackHome ();
                break;
 
+            case 'a':
+#ifdef CH_CURS_UP:
            case CH_CURS_UP:
-               --StackAddr;
-               break;
+#endif
+               --StackAddr;
+               break;
 
-           case CH_CURS_DOWN:
-               ++StackAddr;
-               break;
+            case 'z':
+#ifdef CH_CURS_DOWN
+           case CH_CURS_DOWN:
+#endif
+               ++StackAddr;
+               break;
 
-           default:
-               return c;
+           default:
+               return c;
 
-       }
+       }
 
-       /* Update the window contents */
+       /* Update the window contents */
                UpdateStack ();
     }
 }
@@ -1028,9 +1064,9 @@ static unsigned UpdateCStack (void)
     unsigned char y;
 
     for (y = CStackFrame.fd_y2-1; y > CStackFrame.fd_y1; --y) {
-       gotoxy (x, y);
-       cputhex16 (* (unsigned*)mem);
-       mem += 2;
+       gotoxy (x, y);
+       cputhex16 (* (unsigned*)mem);
+       mem += 2;
     }
     cputsxy (CStackFrame.fd_x1+1, CStackFrame.fd_y2-1, "->");
     return mem;
@@ -1063,35 +1099,41 @@ static char CStackHandler (void)
 
     while (1) {
 
-       /* Read and handle input */
-       switch (c = GetKeyUpdate ()) {
+       /* Read and handle input */
+       switch (c = GetKeyUpdate ()) {
 
-           case  '+':
+           case  '+':
                        CStackAddr += BytesPerPage;
-               break;
+               break;
 
-           case '-':
-               CStackAddr -= BytesPerPage;
-               break;
+           case '-':
+               CStackAddr -= BytesPerPage;
+               break;
 
-           case 'o':
-               CStackHome ();
-               break;
+           case 'o':
+               CStackHome ();
+               break;
 
-           case CH_CURS_UP:
-               CStackAddr -= 2;
-               break;
+            case 'a':
+#ifdef CH_CURS_UP
+           case CH_CURS_UP:
+#endif
+               CStackAddr -= 2;
+               break;
 
-           case CH_CURS_DOWN:
-               CStackAddr += 2;
-               break;
+            case 'z':
+#ifdef CH_CURS_DOWN
+           case CH_CURS_DOWN:
+#endif
+               CStackAddr += 2;
+               break;
 
-           default:
-               return c;
+           default:
+               return c;
 
-       }
+       }
 
-       /* Update the window contents */
+       /* Update the window contents */
                UpdateCStack ();
     }
 }
@@ -1157,11 +1199,17 @@ static char DumpHandler (void)
                DumpHome ();
                break;
 
+            case 'a':
+#ifdef CH_CURS_UP
            case CH_CURS_UP:
-               DumpAddr -= 8;
-               break;
+#endif
+               DumpAddr -= 8;
+               break;
 
-           case CH_CURS_DOWN:
+            case 'z':
+#ifdef CH_CURS_DOWN
+           case CH_CURS_DOWN:
+#endif
                DumpAddr += 8;
                break;
 
@@ -1262,7 +1310,7 @@ static void SingleStep (char StepInto)
            /* Be sure not to set the breakpoint twice if this is a jump to
             * the following instruction.
             */
-           Offs = *(signed char*)(brk_pc+1);
+            Offs = ((signed char*)brk_pc)[1];
            if (Offs) {
                DbgSetTmpBreak (brk_pc + Offs + 2);
            }
@@ -1306,13 +1354,13 @@ static void RedrawStatic (char Frame)
     ActiveFrame = -1;
 
     /* Clear the screen hide the cursor */
-    bordercolor (COLOR_BORDER);
-    bgcolor (COLOR_BACKGROUND);
+    (void) bordercolor (COLOR_BORDER);
+    (void) bgcolor (COLOR_BACKGROUND);
     clrscr ();
     cursor (0);
 
     /* Build the frame layout of the screen */
-    textcolor (COLOR_FRAMELOW);
+    (void) textcolor (COLOR_FRAMELOW);
     DrawFrames ();
 
     /* Draw the prompt line */
@@ -1500,4 +1548,4 @@ void DbgEntry (void)
 }
 
 
-    
+