// print a memory dump (duh) void print_memory_dump(unsigned int addr) { int i = 0, j = 0; // temporary indices char tmpstr[160] = { 0 }; const char lines = 13; // # of lines in the memory dump newline(); for(j=0 ; j < lines ; j++) { sprintf(tmpstr, "%04X: ", addr); outstr(tmpstr); for(i=0; i < 16; i++,addr++) { sprintf(tmpstr, "%02X ", g_game->cpu_mem_read(addr)); outstr(tmpstr); } outstr(" | "); addr-=16; for(i=0;i < 16;i++,addr++) { char ch = g_game->cpu_mem_read(addr); outchr(isprint(ch) ? ch :'.'); } newline(); } }
void con_getline(char *buf, int length) { int index = 0; char ch = 0; // loop until we encounter a linefeed or carriage return, or until we run out of space while (!get_quitflag()) { ch = con_getkey(); // if we get a linefeed or carriage return, we're done ... if ((ch == 10) || (ch == 13)) { break; } // backspace, it works but it doesn't look pretty on the screen else if (ch == 8) { if (index >0) { index = index - 1; outstr("[BACK]"); } } // if we've run out of space, terminate the string prematurely to avoid crashing else if (index >= (length - 1)) { break; } // otherwise if we get a printable character, add it to the string else if (ch >= ' ') { outchr(ch); // echo it to the screen buf[index] = ch; index = index + 1; } // else it was a non-printable character, so we ignore it } buf[index] = 0; // terminate the string newline(); // go to the next line }
void cmd_show (char *cp) { char c, curbf, dirty, *p; const char *fname, *name; int l, rf; Buffer *buffer; uLong lines; if (*cp == 0) goto usage; do { p = uptospace (cp); /* Show buffer info */ if (strncasecmp ("buffers", cp, p - cp) == 0) { outfmt (0, "\nBuffers:\n"); l = 0; for (buffer = NULL; (buffer = buffer_next (buffer)) != NULL;) { name = buffer_name (buffer); if (strlen (name) > l) l = strlen (name); } for (buffer = NULL; (buffer = buffer_next (buffer)) != NULL;) { name = buffer_name (buffer); fname = buffer_filename (buffer); lines = buffer_linecount (buffer); rf = (buffer_getreadfile (buffer) != NULL); curbf = (buffer == cur_position.buffer) ? '>' : ' '; dirty = buffer_dirty (buffer, -1) ? '*' : ' '; outfmt (strlen (name) + 16, " %c %c %*.*s: %5u%c line%c", curbf, dirty, l, l, name, lines, rf ? '+' : ' ', (lines == 1) ? ' ' : 's'); if (fname != NULL) outfmt (strlen (fname), " => %s", fname); if (buffer == main_buffer) outstr (" (main buffer)"); outchr ('\n'); } continue; } /* Show info about files */ if (strncasecmp ("files", cp, p - cp) == 0) { outfmt (0, "\nFiles:\n"); outfmt (strlen (help_name), " Help: %s\n", help_name); outfmt (strlen (journal_name), " Journal: %s\n", journal_name[0] == 0 ? "<none>" : journal_name); continue; } /* Show keypad definitions */ if (strncasecmp ("keypad", cp, p - cp) == 0) { show_keypad (); continue; } goto usage; } while (*(cp = skipspaces (p)) != 0); return; usage: outerr (0, "specify BUFFERS, FILES, KEYPAD\n"); }