]> git.sur5r.net Git - cc65/blobdiff - libsrc/dbg/dbg.c
Removed (pretty inconsistently used) tab chars from source code base.
[cc65] / libsrc / dbg / dbg.c
index 8090d73ddeb6465bce439b4f36d0f70c0be4e71c..32a0cfba0494d67151e0904903209575f276e48d 100644 (file)
@@ -18,7 +18,7 @@
 
 
 /*****************************************************************************/
-/*                            Function forwards                             */
+/*                             Function forwards                             */
 /*****************************************************************************/
 
 
@@ -41,42 +41,42 @@ static char GetKeyUpdate (void);
 
 
 /*****************************************************************************/
-/*                                  Data                                    */
+/*                                   Data                                    */
 /*****************************************************************************/
 
 
 
 /* Color definitions */
 #if defined(__PLUS4__) || defined(__C16__)
-#  define COLOR_BORDER         (BCOLOR_DARKBLUE | CATTR_LUMA6)
-#  define COLOR_BACKGROUND     COLOR_WHITE
-#  define COLOR_TEXTHIGH               COLOR_BLACK
-#  define COLOR_TEXTLOW        COLOR_GRAY1
-#  define COLOR_FRAMEHIGH      COLOR_BLACK
-#  define COLOR_FRAMELOW       COLOR_GRAY2
+#  define COLOR_BORDER          (BCOLOR_DARKBLUE | CATTR_LUMA6)
+#  define COLOR_BACKGROUND      COLOR_WHITE
+#  define COLOR_TEXTHIGH        COLOR_BLACK
+#  define COLOR_TEXTLOW         COLOR_GRAY1
+#  define COLOR_FRAMEHIGH       COLOR_BLACK
+#  define COLOR_FRAMELOW        COLOR_GRAY2
 #else
 #  if defined(COLOR_GRAY3)
-#    define COLOR_BORDER       COLOR_BLACK
-#    define COLOR_BACKGROUND   COLOR_BLACK
-#    define COLOR_TEXTHIGH     COLOR_WHITE
-#    define COLOR_TEXTLOW      COLOR_GRAY3
-#    define COLOR_FRAMEHIGH    COLOR_WHITE
-#    define COLOR_FRAMELOW     COLOR_GRAY3
+#    define COLOR_BORDER        COLOR_BLACK
+#    define COLOR_BACKGROUND    COLOR_BLACK
+#    define COLOR_TEXTHIGH      COLOR_WHITE
+#    define COLOR_TEXTLOW       COLOR_GRAY3
+#    define COLOR_FRAMEHIGH     COLOR_WHITE
+#    define COLOR_FRAMELOW      COLOR_GRAY3
 #  else
 #    if defined(__APPLE2__) || defined(__APPLE2ENH__)
-#      define COLOR_BORDER             COLOR_BLACK
+#      define COLOR_BORDER      COLOR_BLACK
 #      define COLOR_BACKGROUND  COLOR_BLACK
-#      define COLOR_TEXTHIGH   COLOR_BLACK
-#      define COLOR_TEXTLOW    COLOR_BLACK
-#      define COLOR_FRAMEHIGH  COLOR_BLACK
-#      define COLOR_FRAMELOW   COLOR_BLACK
+#      define COLOR_TEXTHIGH    COLOR_BLACK
+#      define COLOR_TEXTLOW     COLOR_BLACK
+#      define COLOR_FRAMEHIGH   COLOR_BLACK
+#      define COLOR_FRAMELOW    COLOR_BLACK
 #    else
-#      define COLOR_BORDER     COLOR_BLACK
+#      define COLOR_BORDER      COLOR_BLACK
 #      define COLOR_BACKGROUND  COLOR_BLACK
-#      define COLOR_TEXTHIGH   COLOR_WHITE
-#      define COLOR_TEXTLOW    COLOR_WHITE
-#      define COLOR_FRAMEHIGH  COLOR_WHITE
-#      define COLOR_FRAMELOW   COLOR_WHITE
+#      define COLOR_TEXTHIGH    COLOR_WHITE
+#      define COLOR_TEXTLOW     COLOR_WHITE
+#      define COLOR_FRAMEHIGH   COLOR_WHITE
+#      define COLOR_FRAMELOW    COLOR_WHITE
 #    endif
 #  endif
 #endif
@@ -90,17 +90,17 @@ static char GetKeyUpdate (void);
 /* Screen definitions */
 #if defined(__CBM610__)
 #  define BIGSCREEN
-#  define MAX_X                80
-#  define MAX_Y                25
-#  define DUMP_BYTES   16
+#  define MAX_X         80
+#  define MAX_Y         25
+#  define DUMP_BYTES    16
 #elif defined(__APPLE2__) || defined(__APPLE2ENH__) || defined(__ATARI__)
 #  define MAX_X         40
 #  define MAX_Y         24
 #  define DUMP_BYTES     8
 #else
-#  define MAX_X        40
-#  define MAX_Y                25
-#  define DUMP_BYTES    8
+#  define MAX_X         40
+#  define MAX_Y         25
+#  define DUMP_BYTES     8
 #endif
 
 /* Replacement key definitions */
@@ -138,27 +138,27 @@ static char GetKeyUpdate (void);
 #endif
 
 /* Defines for opcodes */
-#define        OPC_BRK         0x00
-#define OPC_BPL                0x10
-#define OPC_JSR                0x20
-#define OPC_BMI                0x30
-#define OPC_RTI                0x40
-#define OPC_JMP                0x4C
-#define OPC_BVC                0x50
-#define OPC_RTS                0x60
-#define OPC_JMPIND     0x6C
-#define OPC_BVS                0x70
-#define OPC_BCC                0x90
-#define OPC_BCS                0xB0
-#define OPC_BNE                0xD0
-#define OPC_BEQ                0xF0
+#define OPC_BRK         0x00
+#define OPC_BPL         0x10
+#define OPC_JSR         0x20
+#define OPC_BMI         0x30
+#define OPC_RTI         0x40
+#define OPC_JMP         0x4C
+#define OPC_BVC         0x50
+#define OPC_RTS         0x60
+#define OPC_JMPIND      0x6C
+#define OPC_BVS         0x70
+#define OPC_BCC         0x90
+#define OPC_BCS         0xB0
+#define OPC_BNE         0xD0
+#define OPC_BEQ         0xF0
 
 
 
 /* Register values that are used also in the assembler stuff */
-extern unsigned char DbgSP;            /* Stack pointer */
-extern unsigned      DbgCS;            /* C stack pointer */
-extern unsigned      DbgHI;            /* High 16 bit of primary reg */
+extern unsigned char DbgSP;             /* Stack pointer */
+extern unsigned      DbgCS;             /* C stack pointer */
+extern unsigned      DbgHI;             /* High 16 bit of primary reg */
 
 
 
@@ -166,22 +166,22 @@ extern unsigned      DbgHI;               /* High 16 bit of primary reg */
 typedef struct {
     unsigned char x;
     unsigned char y;
-    char*                text;
+    char*         text;
 } TextDesc;
 
 /* Window descriptor */
 typedef struct {
-    unsigned char fd_tl;                       /* Top left char */
-    unsigned char fd_tr;               /* Top right char */
-    unsigned char fd_bl;               /* Bottom left char */
-    unsigned char fd_br;               /* Bottom right char */
-    unsigned char fd_x1, fd_y1;                /* Upper left corner */
-    unsigned char fd_x2, fd_y2;                /* Lower right corner */
-    unsigned char fd_width, fd_height; /* Redundant but faster */
-    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 */
+    unsigned char fd_tl;                /* Top left char */
+    unsigned char fd_tr;                /* Top right char */
+    unsigned char fd_bl;                /* Bottom left char */
+    unsigned char fd_br;                /* Bottom right char */
+    unsigned char fd_x1, fd_y1;         /* Upper left corner */
+    unsigned char fd_x2, fd_y2;         /* Lower right corner */
+    unsigned char fd_width, fd_height;  /* Redundant but faster */
+    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 */
 } FrameDesc;
 
 
@@ -198,24 +198,24 @@ static TextDesc RegText [] = {
     { 1,  7, "HI" }
 };
 static TextDesc HelpText [] = {
-    { 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,  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"         },
+    { 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"          },
 };
 
 
@@ -281,51 +281,51 @@ static FrameDesc* Frames [] = {
 static int ActiveFrame = -1;
 
 /* Window names */
-#define        WIN_ASM         0
-#define WIN_REG                1
-#define WIN_STACK      2
-#define WIN_CSTACK     3
-#define WIN_DUMP       4
-#define WIN_HELP       5
+#define WIN_ASM         0
+#define WIN_REG         1
+#define WIN_STACK       2
+#define WIN_CSTACK      3
+#define WIN_DUMP        4
+#define WIN_HELP        5
 
 /* Other window data */
-static unsigned AsmAddr;       /* Start address of output */
-static unsigned DumpAddr;      /* Start address of output */
-static unsigned CStackAddr;    /* Start address of output */
-static unsigned char StackAddr;        /* Start address of output */
+static unsigned AsmAddr;        /* Start address of output */
+static unsigned DumpAddr;       /* Start address of output */
+static unsigned CStackAddr;     /* Start address of output */
+static unsigned char StackAddr; /* Start address of output */
 
 
 
 /* Prompt line data */
-static char* ActivePrompt = 0; /* Last prompt line displayed */
-static char PromptColor;       /* Color behind prompt */
-static char PromptLength;      /* Length of current prompt string */
+static char* ActivePrompt = 0;  /* Last prompt line displayed */
+static char PromptColor;        /* Color behind prompt */
+static char PromptLength;       /* Length of current prompt string */
 
 
 
 /* Values for the bk_use field of struct BreakPoint */
-#define BRK_EMPTY      0x00
-#define BRK_USER       0x01
-#define BRK_TMP                0x80
+#define BRK_EMPTY       0x00
+#define BRK_USER        0x01
+#define BRK_TMP         0x80
 
 /* Structure describing a breakpoint */
 typedef struct {
-    unsigned      bk_addr;     /* Address, 0 if unused */
-    unsigned char bk_opc;      /* Opcode */
-    unsigned char bk_use;      /* 1 if in use, 0 otherwise */
+    unsigned      bk_addr;      /* Address, 0 if unused */
+    unsigned char bk_opc;       /* Opcode */
+    unsigned char bk_use;       /* 1 if in use, 0 otherwise */
 } BreakPoint;
 
 
 
 /* Temporary breakpoints - also accessed from the assembler source */
-#define MAX_USERBREAKS 10
+#define MAX_USERBREAKS  10
 unsigned char DbgBreakCount = 0;
 BreakPoint DbgBreaks [MAX_USERBREAKS+2];
 
 
 
 /*****************************************************************************/
-/*             Forwards for functions in the assembler source               */
+/*              Forwards for functions in the assembler source               */
 /*****************************************************************************/
 
 
@@ -341,7 +341,7 @@ BreakPoint* DbgIsBreak (unsigned Addr);
 
 
 /*****************************************************************************/
-/*                        Frame/window drawing code                         */
+/*                         Frame/window drawing code                         */
 /*****************************************************************************/
 
 
@@ -357,17 +357,17 @@ static void DrawFrame (register FrameDesc* F, char Active)
 
     /* Determine the characters for the corners, set frame color */
     if (Active) {
-       OldColor = textcolor (COLOR_FRAMEHIGH);
-               tl = CH_ULCORNER;
-       tr = CH_URCORNER;
-       bl = CH_LLCORNER;
-       br = CH_LRCORNER;
+        OldColor = textcolor (COLOR_FRAMEHIGH);
+        tl = CH_ULCORNER;
+        tr = CH_URCORNER;
+        bl = CH_LLCORNER;
+        br = CH_LRCORNER;
     } else {
-       OldColor = textcolor (COLOR_FRAMELOW);
-               tl = F->fd_tl;
-       tr = F->fd_tr;
-       bl = F->fd_bl;
-       br = F->fd_br;
+        OldColor = textcolor (COLOR_FRAMELOW);
+        tl = F->fd_tl;
+        tr = F->fd_tr;
+        bl = F->fd_bl;
+        br = F->fd_br;
     }
 
     /* Get the coordinates into locals for faster access */
@@ -396,8 +396,8 @@ static void DrawFrame (register FrameDesc* F, char Active)
     Count = F->fd_textcount;
     T = F->fd_text;
     while (Count--) {
-       cputsxy (x1 + T->x, y1 + T->y, T->text);
-       ++T;
+        cputsxy (x1 + T->x, y1 + T->y, T->text);
+        ++T;
     }
 
     /* Set the old color */
@@ -414,10 +414,10 @@ static void DrawFrames (void)
 
     /* Build the frame layout of the screen */
     for (I = 0; I < sizeof (Frames) / sizeof (Frames [0]); ++I) {
-       F = Frames [I];
-       if (F->fd_visible) {
-           DrawFrame (F, 0);
-       }
+        F = Frames [I];
+        if (F->fd_visible) {
+            DrawFrame (F, 0);
+        }
     }
 }
 
@@ -431,25 +431,25 @@ static void ActivateFrame (int Num, unsigned char Clear)
 
     if (ActiveFrame != Num) {
 
-       /* Deactivate the old one */
-       if (ActiveFrame >= 0) {
-           DrawFrame (Frames [ActiveFrame], 0);
-       }
-
-       /* Activate the new one */
-       if ((ActiveFrame = Num) >= 0) {
-                   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);
-               }
-           }
-           DrawFrame (F, 1);
-       }
-
-       /* Redraw the current prompt line */
-       DisplayPrompt (ActivePrompt);
+        /* Deactivate the old one */
+        if (ActiveFrame >= 0) {
+            DrawFrame (Frames [ActiveFrame], 0);
+        }
+
+        /* Activate the new one */
+        if ((ActiveFrame = Num) >= 0) {
+            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);
+                }
+            }
+            DrawFrame (F, 1);
+        }
+
+        /* Redraw the current prompt line */
+        DisplayPrompt (ActivePrompt);
 
     }
 }
@@ -457,7 +457,7 @@ static void ActivateFrame (int Num, unsigned char Clear)
 
 
 /*****************************************************************************/
-/*                               Prompt line                                */
+/*                                Prompt line                                */
 /*****************************************************************************/
 
 
@@ -472,8 +472,8 @@ static void DisplayPrompt (char* s)
 
     /* Clear the old prompt if there is one */
     if (ActivePrompt) {
-       (void) textcolor (PromptColor);
-       chlinexy ((MAX_X - PromptLength) / 2, MAX_Y-1, PromptLength);
+        (void) textcolor (PromptColor);
+        chlinexy ((MAX_X - PromptLength) / 2, MAX_Y-1, PromptLength);
     }
 
     /* Get the new prompt data */
@@ -550,22 +550,22 @@ static char Input (char* Prompt, char* Buf, unsigned char Count)
     /* Get input and handle it */
     i = done = 0;
     do {
-       c = cgetc ();
-       if (isalnum (c) && i < Count) {
-           Buf [i] = c;
-           cputcxy (x1 + i, MAX_Y-1, c);
-                   ++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 (IsAbortKey (c)) {
-           /* Abort */
-           done = 2;
-       }
+        c = cgetc ();
+        if (isalnum (c) && i < Count) {
+            Buf [i] = c;
+            cputcxy (x1 + i, MAX_Y-1, c);
+            ++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 (IsAbortKey (c)) {
+            /* Abort */
+            done = 2;
+        }
     } while (!done);
 
     /* Reset settings, display old prompt line */
@@ -592,25 +592,25 @@ static char InputHex (char* Prompt, unsigned* Val)
     /* Read input from the user (4 digits max), check input */
     if (Input (Prompt, Buf, sizeof (Buf)-1) && isxdigit (Buf [0])) {
 
-       /* Check the characters and convert to hex */
-       P = Buf;
-       V = 0;
-       while ((C = *P) && isxdigit (C)) {
-           V <<= 4;
-                   if (isdigit (C)) {
-               C -= '0';
-           } else {
-               C = toupper (C) - ('A' - 10);
-           }
-           V += C;
-           ++P;
-       }
-
-       /* Assign the value */
-       *Val = V;
-
-       /* Success */
-       return 1;
+        /* Check the characters and convert to hex */
+        P = Buf;
+        V = 0;
+        while ((C = *P) && isxdigit (C)) {
+            V <<= 4;
+            if (isdigit (C)) {
+                C -= '0';
+            } else {
+                C = toupper (C) - ('A' - 10);
+            }
+            V += C;
+            ++P;
+        }
+
+        /* Assign the value */
+        *Val = V;
+
+        /* Success */
+        return 1;
 
     } else {
 
@@ -662,7 +662,7 @@ static void BreakInRomError (void)
 
 
 /*****************************************************************************/
-/*                           Breakpoint handling                            */
+/*                            Breakpoint handling                            */
 /*****************************************************************************/
 
 
@@ -683,25 +683,25 @@ static void DbgToggleUserBreak (unsigned Addr)
     register BreakPoint* B = DbgIsBreak (Addr);
 
     if (B) {
-       /* We have a breakpoint, remove it */
-       B->bk_use = BRK_EMPTY;
-       --DbgBreakCount;
+        /* We have a breakpoint, remove it */
+        B->bk_use = BRK_EMPTY;
+        --DbgBreakCount;
     } else {
-       /* We don't have a breakpoint, set one */
-               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 ();
-           } else {
-               /* Set the breakpoint */
-               B = DbgGetBreakSlot ();
-               B->bk_addr = Addr;
-               B->bk_use  = BRK_USER;
-               ++DbgBreakCount;
-           }
-       }
+        /* We don't have a breakpoint, set one */
+        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 ();
+            } else {
+                /* Set the breakpoint */
+                B = DbgGetBreakSlot ();
+                B->bk_addr = Addr;
+                B->bk_use  = BRK_USER;
+                ++DbgBreakCount;
+            }
+        }
     }
 }
 
@@ -714,10 +714,10 @@ static void DbgResetTmpBreaks (void)
     BreakPoint* B = DbgBreaks;
 
     for (i = 0; i < MAX_USERBREAKS; ++i) {
-       if (B->bk_use == BRK_TMP) {
-           B->bk_use = BRK_EMPTY;
-       }
-       ++B;
+        if (B->bk_use == BRK_TMP) {
+            B->bk_use = BRK_EMPTY;
+        }
+        ++B;
     }
 }
 
@@ -731,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;
-       }
-       ++B;
+        if (B->bk_use == BRK_TMP && !DbgIsRAM (B->bk_addr)) {
+            BreakInRomError ();
+            DbgResetTmpBreaks ();
+            return 0;
+        }
+        ++B;
     }
     return 1;
 }
@@ -744,7 +744,7 @@ static unsigned char DbgTmpBreaksOk (void)
 
 
 /*****************************************************************************/
-/*                         Assembler window stuff                           */
+/*                          Assembler window stuff                           */
 /*****************************************************************************/
 
 
@@ -760,25 +760,25 @@ static unsigned AsmBack (unsigned mem, unsigned char lines)
 
     unsigned offs = 6;
     while (1) {
-       in = 0;
-       cur = mem - (lines * 3) - offs;
-       while (1) {
-           cur += DbgDisAsmLen (cur);
-           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;
-               }
-           }
-       }
+        in = 0;
+        cur = mem - (lines * 3) - offs;
+        while (1) {
+            cur += DbgDisAsmLen (cur);
+            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;
+                }
+            }
+        }
     }
 }
 
@@ -795,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);
-               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;
+        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;
     }
     return m;
 }
@@ -830,33 +830,33 @@ static void AsmFollow (void)
 {
     switch (*(unsigned char*) AsmAddr) {
 
-       case OPC_JMP:
-       case OPC_JSR:
-                   AsmAddr = AsmArg16 ();
-           break;
+        case OPC_JMP:
+        case OPC_JSR:
+            AsmAddr = AsmArg16 ();
+            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 = AsmAddr + 2 + *(signed char*)(AsmAddr+1);
-           break;
+            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;
 
         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;
 
     }
 }
@@ -888,68 +888,68 @@ static char AsmHandler (void)
 
     while (1) {
 
-       /* Update the window contents */
-       Last = UpdateAsm ();
+        /* 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 't':
+            case 't':
 #ifdef CH_F2
-           case CH_F2:
+            case CH_F2:
 #endif
-               DbgToggleUserBreak (AsmAddr);
-               break;
+                DbgToggleUserBreak (AsmAddr);
+                break;
 
-           case 'f':
-               AsmFollow ();
-               break;
+            case 'f':
+                AsmFollow ();
+                break;
 
-           case 'g':
-               InputGoto (&AsmAddr);
-               break;
+            case 'g':
+                InputGoto (&AsmAddr);
+                break;
 
-           case 'o':
-               AsmHome ();
-               break;
+            case 'o':
+                AsmHome ();
+                break;
 
-           case 'p':
-               brk_pc = AsmAddr;
-               break;
+            case 'p':
+                brk_pc = AsmAddr;
+                break;
 
             case 'a':
 #ifdef CH_CURS_UP
-           case CH_CURS_UP:
+            case CH_CURS_UP:
 #endif
-               AsmAddr = AsmBack (AsmAddr, 1);
-               break;
+                AsmAddr = AsmBack (AsmAddr, 1);
+                break;
 
             case 'z':
 #ifdef CH_CURS_DOWN
-           case CH_CURS_DOWN:
+            case CH_CURS_DOWN:
 #endif
-               AsmAddr += DbgDisAsmLen (AsmAddr);
-               break;
+                AsmAddr += DbgDisAsmLen (AsmAddr);
+                break;
 
-           default:
-               return c;
+            default:
+                return c;
 
-       }
+        }
     }
 }
 
 
 
 /*****************************************************************************/
-/*                          Register window stuff                           */
+/*                           Register window stuff                           */
 /*****************************************************************************/
 
 
@@ -962,14 +962,14 @@ static unsigned UpdateReg (void)
     unsigned char y = RegFrame.fd_y1;
 
     /* Print the register contents */
-    gotoxy (x1, ++y);          cputhex16 (brk_pc);
-    gotoxy (x2, ++y);          cputhex8  (brk_sr);
-    gotoxy (x2, ++y);          cputhex8  (brk_a);
-    gotoxy (x2, ++y);          cputhex8  (brk_x);
-    gotoxy (x2, ++y);          cputhex8  (brk_y);
-    gotoxy (x2, ++y);          cputhex8  (DbgSP);
+    gotoxy (x1, ++y);   cputhex16 (brk_pc);
+    gotoxy (x2, ++y);   cputhex8  (brk_sr);
+    gotoxy (x2, ++y);   cputhex8  (brk_a);
+    gotoxy (x2, ++y);   cputhex8  (brk_x);
+    gotoxy (x2, ++y);   cputhex8  (brk_y);
+    gotoxy (x2, ++y);   cputhex8  (DbgSP);
     gotoxy (x1, ++y);   cputhex16 (DbgCS);
-    gotoxy (x1, ++y);          cputhex16 (DbgHI);
+    gotoxy (x1, ++y);   cputhex16 (DbgHI);
 
     /* Not needed */
     return 0;
@@ -994,7 +994,7 @@ static char RegHandler (void)
 
 
 /*****************************************************************************/
-/*                            Stack window stuff                            */
+/*                             Stack window stuff                            */
 /*****************************************************************************/
 
 
@@ -1008,11 +1008,11 @@ 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));
-               ++mem;
+        gotoxy (x1, y);
+        cputhex8 (mem);
+        gotoxy (x2, y);
+        cputhex8 (* (unsigned char*) (mem + 0x100));
+        ++mem;
     }
     return mem;
 }
@@ -1044,49 +1044,49 @@ static char StackHandler (void)
 
     while (1) {
 
-       /* Read and handle input */
-       switch (c = GetKeyUpdate ()) {
+        /* Read and handle input */
+        switch (c = GetKeyUpdate ()) {
 
-           case  '+':
-                       StackAddr += BytesPerPage;
-               break;
+            case  '+':
+                StackAddr += BytesPerPage;
+                break;
 
-           case '-':
-               StackAddr -= BytesPerPage;
-               break;
+            case '-':
+                StackAddr -= BytesPerPage;
+                break;
 
-           case 'o':
-               StackHome ();
-               break;
+            case 'o':
+                StackHome ();
+                break;
 
             case 'a':
 #ifdef CH_CURS_UP:
-           case CH_CURS_UP:
+            case CH_CURS_UP:
 #endif
-               --StackAddr;
-               break;
+                --StackAddr;
+                break;
 
             case 'z':
 #ifdef CH_CURS_DOWN
-           case CH_CURS_DOWN:
+            case CH_CURS_DOWN:
 #endif
-               ++StackAddr;
-               break;
+                ++StackAddr;
+                break;
 
-           default:
-               return c;
+            default:
+                return c;
 
-       }
+        }
 
-       /* Update the window contents */
-               UpdateStack ();
+        /* Update the window contents */
+        UpdateStack ();
     }
 }
 
 
 
 /*****************************************************************************/
-/*                                  C Stack window stuff                            */
+/*                           C Stack window stuff                            */
 /*****************************************************************************/
 
 
@@ -1099,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;
@@ -1134,49 +1134,49 @@ static char CStackHandler (void)
 
     while (1) {
 
-       /* Read and handle input */
-       switch (c = GetKeyUpdate ()) {
+        /* Read and handle input */
+        switch (c = GetKeyUpdate ()) {
 
-           case  '+':
-                       CStackAddr += BytesPerPage;
-               break;
+            case  '+':
+                CStackAddr += BytesPerPage;
+                break;
 
-           case '-':
-               CStackAddr -= BytesPerPage;
-               break;
+            case '-':
+                CStackAddr -= BytesPerPage;
+                break;
 
-           case 'o':
-               CStackHome ();
-               break;
+            case 'o':
+                CStackHome ();
+                break;
 
             case 'a':
 #ifdef CH_CURS_UP
-           case CH_CURS_UP:
+            case CH_CURS_UP:
 #endif
-               CStackAddr -= 2;
-               break;
+                CStackAddr -= 2;
+                break;
 
             case 'z':
 #ifdef CH_CURS_DOWN
-           case CH_CURS_DOWN:
+            case CH_CURS_DOWN:
 #endif
-               CStackAddr += 2;
-               break;
+                CStackAddr += 2;
+                break;
 
-           default:
-               return c;
+            default:
+                return c;
 
-       }
+        }
 
-       /* Update the window contents */
-               UpdateCStack ();
+        /* Update the window contents */
+        UpdateCStack ();
     }
 }
 
 
 
 /*****************************************************************************/
-/*                            Dump window stuff                             */
+/*                             Dump window stuff                             */
 /*****************************************************************************/
 
 
@@ -1191,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;
 }
@@ -1215,53 +1215,53 @@ 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 '-':
-               DumpAddr -= BytesPerPage;
-               break;
+            case '-':
+                DumpAddr -= BytesPerPage;
+                break;
 
-           case 'g':
-               InputGoto (&DumpAddr);
-               break;
+            case 'g':
+                InputGoto (&DumpAddr);
+                break;
 
-           case 'o':
-               DumpHome ();
-               break;
+            case 'o':
+                DumpHome ();
+                break;
 
             case 'a':
 #ifdef CH_CURS_UP
-           case CH_CURS_UP:
+            case CH_CURS_UP:
 #endif
-               DumpAddr -= 8;
-               break;
+                DumpAddr -= 8;
+                break;
 
             case 'z':
 #ifdef CH_CURS_DOWN
-           case CH_CURS_DOWN:
+            case CH_CURS_DOWN:
 #endif
-               DumpAddr += 8;
-               break;
+                DumpAddr += 8;
+                break;
 
-           default:
-               return c;
+            default:
+                return c;
 
-       }
+        }
 
-       /* Update the window contents */
-               UpdateDump ();
+        /* Update the window contents */
+        UpdateDump ();
     }
 }
 
 
 
 /*****************************************************************************/
-/*                            Help window stuff                             */
+/*                             Help window stuff                             */
 /*****************************************************************************/
 
 
@@ -1289,7 +1289,7 @@ static char HelpHandler (void)
 
 
 /*****************************************************************************/
-/*                               Singlestep                                 */
+/*                                Singlestep                                 */
 /*****************************************************************************/
 
 
@@ -1325,49 +1325,49 @@ static void SingleStep (char StepInto)
     switch (*(unsigned char*) brk_pc) {
 
         case OPC_JMP:
-           /* 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.
-            */
+            /* 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;
+            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 */
@@ -1377,7 +1377,7 @@ static void SingleStep (char StepInto)
 
 
 /*****************************************************************************/
-/*                       High level window handling                         */
+/*                        High level window handling                         */
 /*****************************************************************************/
 
 
@@ -1431,26 +1431,26 @@ static char GetKeyUpdate (void)
     /* While there are no keys... */
     while (!kbhit ()) {
 
-       switch (Win) {
+        switch (Win) {
 
-           case 0:
-               UpdateAsm ();
-               break;
+            case 0:
+                UpdateAsm ();
+                break;
 
-           case 1:
-               UpdateStack ();
-               break;
+            case 1:
+                UpdateStack ();
+                break;
 
-           case 2:
-               UpdateCStack ();
-               break;
+            case 2:
+                UpdateCStack ();
+                break;
 
-           case 3:
-               UpdateDump ();
-               break;
-       }
+            case 3:
+                UpdateDump ();
+                break;
+        }
 
-       Win = (Win + 1) & 0x03;
+        Win = (Win + 1) & 0x03;
 
     }
 
@@ -1461,7 +1461,7 @@ static char GetKeyUpdate (void)
 
 
 /*****************************************************************************/
-/*                      Externally visible functions                        */
+/*                       Externally visible functions                        */
 /*****************************************************************************/
 
 
@@ -1475,110 +1475,110 @@ 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
      * display update will be done while waiting for user input.
      */
     AsmHome ();
-    UpdateReg ();              /* Must update this (static later) */
+    UpdateReg ();               /* Must update this (static later) */
     StackHome ();
     CStackHome ();
 
     /* 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 '?':
+        c = Frames [ActiveFrame]->fd_func ();
+        switch (c) {
+
+            case '1':
+            case '2':
+            case '3':
+            case '4':
+            case '5':
+                ActivateFrame (c - '1', 0);
+                break;
+
+            case '?':
 #ifdef CH_F1
-                   case CH_F1:
+            case CH_F1:
 #endif
-                       HelpHandler ();
-                       break;
+                HelpHandler ();
+                break;
 
-           case 'u':
+            case 'u':
 #ifdef CH_F3
-                   case CH_F3:
+            case CH_F3:
 #endif
-               /* Go until return */
-               SetRTSBreak ();
-               done = 1;
-               break;
+                /* Go until return */
+                SetRTSBreak ();
+                done = 1;
+                break;
 
-           case 'h':
+            case 'h':
 #ifdef CH_F4
-           case 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 ' ':
+                /* 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:
+            case CH_F7:
 #endif
-               SingleStep (1);
-               if (DbgTmpBreaksOk ()) {
-                   /* Could set breakpoints */
-                   done = 1;
-               }
-               break;
-
-           case '\n':
+                SingleStep (1);
+                if (DbgTmpBreaksOk ()) {
+                    /* Could set breakpoints */
+                    done = 1;
+                }
+                break;
+
+            case '\n':
 #ifdef CH_F8
-           case 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':
-               /* Skip instruction */
-               brk_pc += DbgDisAsmLen (brk_pc);
-               InitAsm ();
-               break;
-
-           case 'r':
-               /* Redraw screen */
-               Redraw (ActiveFrame);
-               break;
-
-           case 'q':
-               /* Quit program */
-               clrscr ();
-               exit (1);
-
-       }
+                SingleStep (0);
+                if (DbgTmpBreaksOk ()) {
+                    /* Could set breakpoints */
+                    done = 1;
+                }
+                break;
+
+            case 'c':
+            case 0:
+                done = 1;
+                break;
+
+            case 's':
+                /* Skip instruction */
+                brk_pc += DbgDisAsmLen (brk_pc);
+                InitAsm ();
+                break;
+
+            case 'r':
+                /* Redraw screen */
+                Redraw (ActiveFrame);
+                break;
+
+            case 'q':
+                /* Quit program */
+                clrscr ();
+                exit (1);
+
+        }
     }
 }