]> git.sur5r.net Git - cc65/blobdiff - libsrc/dbg/dbg.c
Replaced whole bunch for Makefiles with a single generic Makefile.
[cc65] / libsrc / dbg / dbg.c
index 9ddf9d80ff35319f5d44e0a090233f75b7cdb799..8090d73ddeb6465bce439b4f36d0f70c0be4e71c 100644 (file)
@@ -44,8 +44,10 @@ static char GetKeyUpdate (void);
 /*                                  Data                                    */
 /*****************************************************************************/
 
+
+
 /* Color definitions */
-#ifdef __PLUS4__
+#if defined(__PLUS4__) || defined(__C16__)
 #  define COLOR_BORDER         (BCOLOR_DARKBLUE | CATTR_LUMA6)
 #  define COLOR_BACKGROUND     COLOR_WHITE
 #  define COLOR_TEXTHIGH               COLOR_BLACK
@@ -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
@@ -78,6 +80,12 @@ static char GetKeyUpdate (void);
 #    endif
 #  endif
 #endif
+#ifndef COLOR_BLACK
+#  define COLOR_BLACK   0
+#endif
+#ifndef COLOR_WHITE
+#  define COLOR_WHITE   1
+#endif
 
 /* Screen definitions */
 #if defined(__CBM610__)
@@ -85,7 +93,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,35 +103,39 @@ static char GetKeyUpdate (void);
 #  define DUMP_BYTES    8
 #endif
 
+/* Replacement key definitions */
+#if defined(__APPLE2__) || defined(__LYNX__) || defined(__SUPERVISION__)
+#  define CH_DEL        ('H' - 'A' + 1)         /* Ctrl+H */
+#endif
 
-
-/* Key definitions */
-#ifndef CH_F1
-#  define CH_F1                '?'
+/* Replacement char definitions */
+#ifndef CH_ULCORNER
+#  define CH_ULCORNER   '+'
 #endif
-#ifndef CH_F2
-#  define CH_F2                0
+#ifndef CH_URCORNER
+#  define CH_URCORNER   '+'
 #endif
-#ifndef CH_F3
-#  define CH_F3                0
+#ifndef CH_LLCORNER
+#  define CH_LLCORNER   '+'
 #endif
-#ifndef CH_F4
-#  define CH_F4                0
+#ifndef CH_LRCORNER
+#  define CH_LRCORNER   '+'
 #endif
-#ifndef CH_F5
-#  define CH_F5                0
+#ifndef CH_TTEE
+#  define CH_TTEE       '+'
 #endif
-#ifndef CH_F6
-#  define CH_F6                0
+#ifndef CH_LTEE
+#  define CH_LTEE       '+'
 #endif
-#ifndef CH_F7
-#  define CH_F7                0
+#ifndef CH_RTEE
+#  define CH_RTEE       '+'
 #endif
-#ifndef CH_F8
-#  define CH_F8                0
+#ifndef CH_BTEE
+#  define CH_BTEE       '+'
+#endif
+#ifndef CH_CROSS
+#  define CH_CROSS      '+'
 #endif
-
-
 
 /* Defines for opcodes */
 #define        OPC_BRK         0x00
@@ -186,23 +198,24 @@ static TextDesc RegText [] = {
     { 1,  7, "HI" }
 };
 static TextDesc HelpText [] = {
-    { 1,  0, "F1      Help"                            },
-    { 1,  1, "F2      Toggle breakpoint"               },
-    { 1,  2, "F3      Run until subroutine returns"    },
-    { 1,  3, "F4      Run to cursor"                   },
-    { 1,  4, "F7      Step into"                       },
-    { 1,  5, "F8      Step over"                       },
-    { 1,  6, "1-5     Select active window"            },
-    { 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, "r       Redraw screen"                   },
-    { 1, 15, "q       Quit"                            },
-    { 1, 16, "s       Skip next instruction"           },
+    { 1,  0, "F1, ?     Help"                          },
+    { 1,  1, "F2, t     Toggle breakpoint"             },
+    { 1,  2, "F3, u     Run until subroutine returns"  },
+    { 1,  3, "F4, h     Run to cursor"                         },
+    { 1,  4, "F7, space Step into"                             },
+    { 1,  5, "F8, enter Step over"                             },
+    { 1,  6, "1-5       Select active window"          },
+    { 1,  7, "+         Page down"                             },
+    { 1,  8, "-         Page up"                       },
+    { 1,  9, "Cursor    Move up/down"                          },
+    { 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"         },
 };
 
 
@@ -333,7 +346,7 @@ BreakPoint* DbgIsBreak (unsigned Addr);
 
 
 
-static void DrawFrame (FrameDesc* F, char Active)
+static void DrawFrame (register FrameDesc* F, char Active)
 /* Draw one window frame */
 {
     TextDesc* T;
@@ -351,7 +364,7 @@ static void DrawFrame (FrameDesc* F, char Active)
        br = CH_LRCORNER;
     } else {
        OldColor = textcolor (COLOR_FRAMELOW);
-       tl = F->fd_tl;
+               tl = F->fd_tl;
        tr = F->fd_tr;
        bl = F->fd_bl;
        br = F->fd_br;
@@ -379,7 +392,7 @@ static void DrawFrame (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--) {
@@ -388,7 +401,7 @@ static void DrawFrame (FrameDesc* F, char Active)
     }
 
     /* Set the old color */
-    textcolor (OldColor);
+    (void) textcolor (OldColor);
 }
 
 
@@ -414,7 +427,7 @@ static void ActivateFrame (int Num, unsigned char Clear)
 /* Activate a new frame, deactivate the old one */
 {
     unsigned char y;
-    FrameDesc* F;
+    register FrameDesc* F;
 
     if (ActiveFrame != Num) {
 
@@ -428,9 +441,9 @@ static void ActivateFrame (int Num, unsigned char Clear)
                    F = Frames [ActiveFrame];
            /* Clear the frame if requested */
            if (Clear) {
-               for (y = F->fd_y1+1; y < F->fd_y2; ++y) {
-                   cclearxy (F->fd_x1+1, y, F->fd_width);
-               }
+               for (y = F->fd_y1+1; y < F->fd_y2; ++y) {
+                   cclearxy (F->fd_x1+1, y, F->fd_width);
+               }
            }
            DrawFrame (F, 1);
        }
@@ -444,7 +457,7 @@ static void ActivateFrame (int Num, unsigned char Clear)
 
 
 /*****************************************************************************/
-/*                               Prompt line                                */
+/*                               Prompt line                                */
 /*****************************************************************************/
 
 
@@ -459,7 +472,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);
     }
 
@@ -469,11 +482,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);
 }
 
 
@@ -493,6 +506,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 */
 {
@@ -510,7 +541,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 ();
@@ -523,15 +554,15 @@ static char Input (char* Prompt, char* Buf, unsigned char Count)
        if (isalnum (c) && i < Count) {
            Buf [i] = c;
            cputcxy (x1 + i, MAX_Y-1, c);
-           ++i;
-       } else if (i > 0 && c == CH_DEL) {
+                   ++i;
+               } 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;
        }
@@ -539,7 +570,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;
@@ -550,8 +581,8 @@ static char Input (char* Prompt, char* Buf, unsigned char Count)
 
 
 
-static int InputHex (char* Prompt, unsigned* Val)
-/* Prompt for a hexadecimal value */
+static char InputHex (char* Prompt, unsigned* Val)
+/* Prompt for a hexadecimal value. Return 0 on failure. */
 {
     char Buf [5];
     char* P;
@@ -566,7 +597,7 @@ static int InputHex (char* Prompt, unsigned* Val)
        V = 0;
        while ((C = *P) && isxdigit (C)) {
            V <<= 4;
-           if (isdigit (C)) {
+                   if (isdigit (C)) {
                C -= '0';
            } else {
                C = toupper (C) - ('A' - 10);
@@ -591,14 +622,6 @@ static int InputHex (char* Prompt, unsigned* Val)
 
 
 
-static int InputGoto (unsigned* Addr)
-/* Prompt "Goto" and read an address */
-{
-    return InputHex ("Goto: ", Addr);
-}
-
-
-
 static void ErrorPrompt (char* Msg)
 /* Display an error message and wait for a key */
 {
@@ -617,6 +640,19 @@ static void ErrorPrompt (char* Msg)
 
 
 
+static char InputGoto (unsigned* Addr)
+/* Prompt "Goto" and read an address. Print an error and return 0 on failure. */
+{
+    char Ok;
+    Ok = InputHex ("Goto: ", Addr);
+    if (!Ok) {
+        ErrorPrompt ("Invalid input - press a key");
+    }
+    return Ok;
+}
+
+
+
 static void BreakInRomError (void)
 /* Print an error message if we cannot set a breakpoint */
 {
@@ -644,7 +680,7 @@ static void DbgSetTmpBreak (unsigned Addr)
 static void DbgToggleUserBreak (unsigned Addr)
 /* Set a breakpoint */
 {
-    BreakPoint* B = DbgIsBreak (Addr);
+    register BreakPoint* B = DbgIsBreak (Addr);
 
     if (B) {
        /* We have a breakpoint, remove it */
@@ -652,18 +688,18 @@ static void DbgToggleUserBreak (unsigned Addr)
        --DbgBreakCount;
     } else {
        /* We don't have a breakpoint, set one */
-       if (DbgBreakCount >= MAX_USERBREAKS) {
+               if (DbgBreakCount >= MAX_USERBREAKS) {
            ErrorPrompt ("Too many breakpoints - press a key");
        } else {
            /* Test if we can set a breakpoint at that address */
            if (!DbgIsRAM (Addr)) {
-               BreakInRomError ();
+               BreakInRomError ();
            } else {
-               /* Set the breakpoint */
-               B = DbgGetBreakSlot ();
-               B->bk_addr = Addr;
-               B->bk_use  = BRK_USER;
-               ++DbgBreakCount;
+               /* Set the breakpoint */
+               B = DbgGetBreakSlot ();
+               B->bk_addr = Addr;
+               B->bk_use  = BRK_USER;
+               ++DbgBreakCount;
            }
        }
     }
@@ -681,7 +717,7 @@ static void DbgResetTmpBreaks (void)
        if (B->bk_use == BRK_TMP) {
            B->bk_use = BRK_EMPTY;
        }
-       ++B;
+       ++B;
     }
 }
 
@@ -695,12 +731,12 @@ static unsigned char DbgTmpBreaksOk (void)
     unsigned char i;
     BreakPoint* B = DbgBreaks;
     for (i = 0; i < MAX_USERBREAKS; ++i) {
-       if (B->bk_use == BRK_TMP && !DbgIsRAM (B->bk_addr)) {
-           BreakInRomError ();
-           DbgResetTmpBreaks ();
-           return 0;
+               if (B->bk_use == BRK_TMP && !DbgIsRAM (B->bk_addr)) {
+           BreakInRomError ();
+           DbgResetTmpBreaks ();
+           return 0;
        }
-       ++B;
+       ++B;
     }
     return 1;
 }
@@ -708,7 +744,7 @@ static unsigned char DbgTmpBreaksOk (void)
 
 
 /*****************************************************************************/
-/*                         Assembler window stuff                           */
+/*                         Assembler window stuff                           */
 /*****************************************************************************/
 
 
@@ -731,17 +767,17 @@ static unsigned AsmBack (unsigned mem, unsigned char lines)
            adr [in] = cur;
            in = (in + 1) & 0x1F;
                    if (cur >= mem) {
-               if (cur == mem || offs == 12) {
-                   /* Found */
-                   return adr [(in - lines - 1) & 0x1F];
-               } else {
-                   /* The requested address is inside an instruction, go back
-                    * one more byte and try again.
-                    */
-                   ++offs;
-                   break;
-               }
-           }
+               if (cur == mem || offs == 12) {
+                   /* Found */
+                   return adr [(in - lines - 1) & 0x1F];
+               } else {
+                   /* The requested address is inside an instruction, go back
+                    * one more byte and try again.
+                    */
+                           ++offs;
+                   break;
+               }
+           }
        }
     }
 }
@@ -759,22 +795,22 @@ static unsigned UpdateAsm (void)
     unsigned      m = AsmBack (AsmAddr, 2);
 
     for (y = AsmFrame.fd_y1+1; y < AsmFrame.fd_y2; ++y) {
-       len = DbgDisAsm (m, buf, width);
+       len = DbgDisAsm (m, buf, width);
                if (m == brk_pc) {
-           buf [4] = '-';
-           buf [5] = '>';
-       }
-       if (DbgIsBreak (m)) {
-           buf [5] = '*';
-       }
-       if (m == AsmAddr) {
-           revers (1);
-           cputsxy (1, y, buf);
-           revers (0);
-       } else {
-           cputsxy (1, y, buf);
-       }
-       m += len;
+           buf [4] = '-';
+           buf [5] = '>';
+       }
+       if (DbgIsBreak (m)) {
+           buf [5] = '*';
+       }
+       if (m == AsmAddr) {
+           revers (1);
+           cputsxy (1, y, buf);
+           revers (0);
+       } else {
+           cputsxy (1, y, buf);
+       }
+       m += len;
     }
     return m;
 }
@@ -794,33 +830,33 @@ static void AsmFollow (void)
 {
     switch (*(unsigned char*) AsmAddr) {
 
-       case OPC_JMP:
-       case OPC_JSR:
+       case OPC_JMP:
+       case OPC_JSR:
                    AsmAddr = AsmArg16 ();
-           break;
+           break;
 
         case OPC_JMPIND:
-           AsmAddr = *(unsigned*)AsmArg16 ();
-           break;
-
-       case OPC_BPL:
-       case OPC_BMI:
-       case OPC_BVC:
-       case OPC_BVS:
-       case OPC_BCC:
-       case OPC_BCS:
-       case OPC_BNE:
-       case OPC_BEQ:
+           AsmAddr = *(unsigned*)AsmArg16 ();
+           break;
+
+       case OPC_BPL:
+       case OPC_BMI:
+       case OPC_BVC:
+       case OPC_BVS:
+       case OPC_BCC:
+       case OPC_BCS:
+       case OPC_BNE:
+       case OPC_BEQ:
                    AsmAddr = AsmAddr + 2 + *(signed char*)(AsmAddr+1);
-           break;
+           break;
 
         case OPC_RTS:
-           AsmAddr = (*(unsigned*) (DbgSP + 0x101) + 1);
-           break;
+           AsmAddr = (*(unsigned*) (DbgSP + 0x101) + 1);
+           break;
 
         case OPC_RTI:
-           AsmAddr = *(unsigned*) (DbgSP + 0x102);
-           break;
+           AsmAddr = *(unsigned*) (DbgSP + 0x102);
+           break;
 
     }
 }
@@ -855,20 +891,23 @@ static char AsmHandler (void)
        /* Update the window contents */
        Last = UpdateAsm ();
 
-       /* Read and handle input */
-       switch (c = GetKeyUpdate ()) {
+       /* Read and handle input */
+       switch (c = GetKeyUpdate ()) {
 
-           case  '+':
-               AsmAddr = Last;
-               break;
+           case  '+':
+               AsmAddr = Last;
+               break;
 
-           case '-':
-               AsmAddr = AsmBack (AsmAddr, AsmFrame.fd_height);
-               break;
+           case '-':
+               AsmAddr = AsmBack (AsmAddr, AsmFrame.fd_height);
+               break;
 
-           case CH_F2:
-               DbgToggleUserBreak (AsmAddr);
-               break;
+           case 't':
+#ifdef CH_F2
+           case CH_F2:
+#endif
+               DbgToggleUserBreak (AsmAddr);
+               break;
 
            case 'f':
                AsmFollow ();
@@ -886,11 +925,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;
 
@@ -949,7 +994,7 @@ static char RegHandler (void)
 
 
 /*****************************************************************************/
-/*                            Stack window stuff                            */
+/*                            Stack window stuff                            */
 /*****************************************************************************/
 
 
@@ -963,10 +1008,10 @@ static unsigned UpdateStack (void)
     unsigned char y;
 
     for (y = StackFrame.fd_y2-1; y > StackFrame.fd_y1; --y) {
-       gotoxy (x1, y);
-       cputhex8 (mem);
-       gotoxy (x2, y);
-       cputhex8 (* (unsigned char*) (mem + 0x100));
+       gotoxy (x1, y);
+       cputhex8 (mem);
+       gotoxy (x2, y);
+       cputhex8 (* (unsigned char*) (mem + 0x100));
                ++mem;
     }
     return mem;
@@ -999,35 +1044,41 @@ static char StackHandler (void)
 
     while (1) {
 
-       /* Read and handle input */
-       switch (c = GetKeyUpdate ()) {
+       /* Read and handle input */
+       switch (c = GetKeyUpdate ()) {
 
-           case  '+':
+           case  '+':
                        StackAddr += BytesPerPage;
-               break;
+               break;
 
-           case '-':
-               StackAddr -= BytesPerPage;
-               break;
+           case '-':
+               StackAddr -= BytesPerPage;
+               break;
 
-           case 'o':
-               StackHome ();
-               break;
+           case 'o':
+               StackHome ();
+               break;
 
-           case CH_CURS_UP:
-               --StackAddr;
-               break;
+            case 'a':
+#ifdef CH_CURS_UP:
+           case CH_CURS_UP:
+#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 ();
     }
 }
@@ -1048,9 +1099,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;
@@ -1083,35 +1134,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 ();
     }
 }
@@ -1119,7 +1176,7 @@ static char CStackHandler (void)
 
 
 /*****************************************************************************/
-/*                            Dump window stuff                             */
+/*                            Dump window stuff                             */
 /*****************************************************************************/
 
 
@@ -1134,8 +1191,8 @@ static unsigned UpdateDump (void)
     unsigned char* p = (unsigned char*) mem;
 
     for (y = DumpFrame.fd_y1+1; y < DumpFrame.fd_y2; ++y) {
-       cputsxy (x, y, DbgMemDump (mem, Buf, DUMP_BYTES));
-       mem += DUMP_BYTES;
+       cputsxy (x, y, DbgMemDump (mem, Buf, DUMP_BYTES));
+       mem += DUMP_BYTES;
     }
     return mem;
 }
@@ -1158,37 +1215,43 @@ static char DumpHandler (void)
 
     while (1) {
 
-       /* Read and handle input */
-       switch (c = GetKeyUpdate ()) {
+       /* Read and handle input */
+       switch (c = GetKeyUpdate ()) {
 
-           case  '+':
-               DumpAddr += BytesPerPage;
-               break;
+           case  '+':
+               DumpAddr += BytesPerPage;
+               break;
 
-           case '-':
+           case '-':
                DumpAddr -= BytesPerPage;
-               break;
+               break;
 
-           case 'g':
-               InputGoto (&DumpAddr);
-               break;
+           case 'g':
+               InputGoto (&DumpAddr);
+               break;
 
-           case 'o':
-               DumpHome ();
-               break;
+           case 'o':
+               DumpHome ();
+               break;
 
-           case CH_CURS_UP:
-               DumpAddr -= 8;
-               break;
+            case 'a':
+#ifdef CH_CURS_UP
+           case CH_CURS_UP:
+#endif
+               DumpAddr -= 8;
+               break;
 
-           case CH_CURS_DOWN:
-               DumpAddr += 8;
-               break;
+            case 'z':
+#ifdef CH_CURS_DOWN
+           case CH_CURS_DOWN:
+#endif
+               DumpAddr += 8;
+               break;
 
-           default:
-               return c;
+           default:
+               return c;
 
-       }
+       }
 
        /* Update the window contents */
                UpdateDump ();
@@ -1198,7 +1261,7 @@ static char DumpHandler (void)
 
 
 /*****************************************************************************/
-/*                            Help window stuff                             */
+/*                            Help window stuff                             */
 /*****************************************************************************/
 
 
@@ -1226,7 +1289,7 @@ static char HelpHandler (void)
 
 
 /*****************************************************************************/
-/*                               Singlestep                                 */
+/*                               Singlestep                                 */
 /*****************************************************************************/
 
 
@@ -1262,49 +1325,49 @@ static void SingleStep (char StepInto)
     switch (*(unsigned char*) brk_pc) {
 
         case OPC_JMP:
-           /* Set breakpoint at target */
-           DbgSetTmpBreak (GetArg16 ());
-           return;
+           /* Set breakpoint at target */
+           DbgSetTmpBreak (GetArg16 ());
+           return;
 
        case OPC_JMPIND:
-           /* Indirect jump, ignore CPU error when crossing page */
-           DbgSetTmpBreak (*(unsigned*)GetArg16 ());
-           return;
-
-       case OPC_BPL:
-       case OPC_BMI:
-       case OPC_BVC:
-       case OPC_BVS:
-       case OPC_BCC:
-       case OPC_BCS:
-       case OPC_BNE:
-       case OPC_BEQ:
-           /* Be sure not to set the breakpoint twice if this is a jump to
-            * the following instruction.
-            */
-           Offs = *(signed char*)(brk_pc+1);
-           if (Offs) {
-               DbgSetTmpBreak (brk_pc + Offs + 2);
-           }
-           break;
+           /* Indirect jump, ignore CPU error when crossing page */
+           DbgSetTmpBreak (*(unsigned*)GetArg16 ());
+           return;
+
+       case OPC_BPL:
+       case OPC_BMI:
+       case OPC_BVC:
+       case OPC_BVS:
+       case OPC_BCC:
+       case OPC_BCS:
+       case OPC_BNE:
+       case OPC_BEQ:
+           /* Be sure not to set the breakpoint twice if this is a jump to
+            * the following instruction.
+            */
+            Offs = ((signed char*)brk_pc)[1];
+           if (Offs) {
+               DbgSetTmpBreak (brk_pc + Offs + 2);
+           }
+           break;
 
         case OPC_RTS:
-           /* Set a breakpoint at the return target */
-           SetRTSBreak ();
-           return;
+           /* Set a breakpoint at the return target */
+           SetRTSBreak ();
+           return;
 
         case OPC_RTI:
-           /* Set a breakpoint at the return target */
-           DbgSetTmpBreak (GetStack16 (1));
-           return;
+           /* Set a breakpoint at the return target */
+           DbgSetTmpBreak (GetStack16 (1));
+           return;
 
         case OPC_JSR:
-           if (StepInto) {
-               /* Set breakpoint at target */
-               DbgSetTmpBreak (GetArg16 ());
-               return;
-           }
-           break;
+           if (StepInto) {
+               /* Set breakpoint at target */
+               DbgSetTmpBreak (GetArg16 ());
+               return;
+           }
+           break;
     }
 
     /* Place a breakpoint behind the instruction */
@@ -1314,7 +1377,7 @@ static void SingleStep (char StepInto)
 
 
 /*****************************************************************************/
-/*                       High level window handling                         */
+/*                       High level window handling                         */
 /*****************************************************************************/
 
 
@@ -1326,13 +1389,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 */
@@ -1398,7 +1461,7 @@ static char GetKeyUpdate (void)
 
 
 /*****************************************************************************/
-/*                      Externally visible functions                        */
+/*                      Externally visible functions                        */
 /*****************************************************************************/
 
 
@@ -1412,15 +1475,15 @@ void DbgEntry (void)
 
     /* If this is the first call, setup the display */
     if (FirstTime) {
-       FirstTime = 0;
-
-       /* Draw the window, default active frame is ASM frame */
-       RedrawStatic (WIN_ASM);
-       InitAsm ();
-       InitReg ();
-       InitStack ();
-       InitCStack ();
-       UpdateDump ();
+       FirstTime = 0;
+
+       /* Draw the window, default active frame is ASM frame */
+       RedrawStatic (WIN_ASM);
+       InitAsm ();
+       InitReg ();
+       InitStack ();
+       InitCStack ();
+       UpdateDump ();
     }
 
     /* Only initialize variables here, don't do a display update. The actual
@@ -1430,57 +1493,76 @@ void DbgEntry (void)
     UpdateReg ();              /* Must update this (static later) */
     StackHome ();
     CStackHome ();
-    DumpHome ();
 
     /* Wait for user input */
     done = 0;
     while (!done) {
        c = Frames [ActiveFrame]->fd_func ();
-       switch (c) {
-
-           case '1':
-           case '2':
-           case '3':
-           case '4':
-           case '5':
-               ActivateFrame (c - '1', 0);
-               break;
-
-           case CH_F1:
-               HelpHandler ();
-               break;
-
-           case CH_F3:
-               /* Go until return */
-               SetRTSBreak ();
-               done = 1;
-               break;
-
-           case CH_F4:
-               /* Go to cursor, only possible if cursor not at current PC */
-               if (AsmAddr != brk_pc) {
-                   DbgSetTmpBreak (AsmAddr);
-                   done = 1;
-               }
-               break;
-
-           case ' ':
-           case '\n':
-           case CH_F7:
-           case CH_F8:
-               SingleStep (c == CH_F7 || c == ' ');
-               if (DbgTmpBreaksOk ()) {
-                   /* Could set breakpoints */
-                   done = 1;
-               }
-               break;
+       switch (c) {
+
+           case '1':
+           case '2':
+           case '3':
+           case '4':
+           case '5':
+               ActivateFrame (c - '1', 0);
+               break;
+
+           case '?':
+#ifdef CH_F1
+                   case CH_F1:
+#endif
+                       HelpHandler ();
+                       break;
 
-           case 'c':
-           case 0:
-               done = 1;
+           case 'u':
+#ifdef CH_F3
+                   case CH_F3:
+#endif
+               /* Go until return */
+               SetRTSBreak ();
+               done = 1;
+               break;
+
+           case 'h':
+#ifdef CH_F4
+           case CH_F4:
+#endif
+               /* Go to cursor, only possible if cursor not at current PC */
+               if (AsmAddr != brk_pc) {
+                   DbgSetTmpBreak (AsmAddr);
+                   done = 1;
+               }
+               break;
+
+           case ' ':
+#ifdef CH_F7
+           case CH_F7:
+#endif
+               SingleStep (1);
+               if (DbgTmpBreaksOk ()) {
+                   /* Could set breakpoints */
+                   done = 1;
+               }
+               break;
+
+           case '\n':
+#ifdef CH_F8
+           case CH_F8:
+#endif
+               SingleStep (0);
+               if (DbgTmpBreaksOk ()) {
+                   /* Could set breakpoints */
+                   done = 1;
+               }
+               break;
+
+           case 'c':
+           case 0:
+               done = 1;
                break;
 
-           case 's':
+                   case 's':
                /* Skip instruction */
                brk_pc += DbgDisAsmLen (brk_pc);
                InitAsm ();
@@ -1501,3 +1583,4 @@ void DbgEntry (void)
 }
 
 
+