OSDN Git Service

[SOUND][Qt][MOVIE_SAVER] WIP: Fixing appending unneeded sound data.
[csp-qt/common_source_project-fm7.git] / source / src / debugger.cpp
index 0de752f..328609a 100644 (file)
@@ -6,14 +6,12 @@
 
        [ debugger console ]
 */
-#if defined(_MSC_VER)
-#include <conio.h>
-#else
+#if !defined(_MSC_VER)
 #include <SDL.h>
 #endif
+#include <stdlib.h>
 #include <io.h>
 #include <fcntl.h>
-#include "res/resource.h"
 #include "vm/device.h"
 #include "vm/debugger.h"
 #include "vm/vm.h"
@@ -67,7 +65,7 @@ void my_putch(OSD *osd, _TCHAR c)
        osd->write_console(&c, 1);
 }
 
-uint32 my_hexatoi(const _TCHAR *str)
+uint32_t my_hexatoi(const _TCHAR *str)
 {
        _TCHAR tmp[1024], *s;
        
@@ -85,21 +83,25 @@ uint32 my_hexatoi(const _TCHAR *str)
                return (my_hexatoi(tmp) << 4) + my_hexatoi(s + 1);
        } else if(tmp[0] == _T('%')) {
                // decimal
+#if defined(__MINGW32__)
+               return atoi(tmp + 1);
+#else
                return _tstoi(tmp + 1);
+#endif
        }
        return _tcstoul(tmp, NULL, 16);
 }
 
-uint8 my_hexatob(char *value)
+uint8_t my_hexatob(char *value)
 {
        char tmp[3];
        tmp[0] = value[0];
        tmp[1] = value[1];
        tmp[2] = '\0';
-       return (uint8)strtoul(tmp, NULL, 16);
+       return (uint8_t)strtoul(tmp, NULL, 16);
 }
 
-uint16 my_hexatow(char *value)
+uint16_t my_hexatow(char *value)
 {
        char tmp[5];
        tmp[0] = value[0];
@@ -107,7 +109,7 @@ uint16 my_hexatow(char *value)
        tmp[2] = value[2];
        tmp[3] = value[3];
        tmp[4] = '\0';
-       return (uint16)strtoul(tmp, NULL, 16);
+       return (uint16_t)strtoul(tmp, NULL, 16);
 }
 
 break_point_t *get_break_point(DEBUGGER *debugger, const _TCHAR *command)
@@ -126,15 +128,15 @@ break_point_t *get_break_point(DEBUGGER *debugger, const _TCHAR *command)
        return NULL;
 }
 
+static uint32_t dump_addr;
+static uint32_t dasm_addr;
 
 int debugger_command(debugger_thread_t *p, _TCHAR *command, _TCHAR *prev_command, bool cp932)
 {
        DEVICE *cpu = p->vm->get_cpu(p->cpu_index);
        DEBUGGER *debugger = (DEBUGGER *)cpu->get_debugger();
-       uint32 prog_addr_mask = cpu->debug_prog_addr_mask();
-       uint32 data_addr_mask = cpu->debug_data_addr_mask();
-       uint32 dump_addr = 0;
-       uint32 dasm_addr = cpu->get_next_pc();
+       uint32_t prog_addr_mask = cpu->get_debug_prog_addr_mask();
+       uint32_t data_addr_mask = cpu->get_debug_data_addr_mask();
        //while(!debugger->now_suspended) {
        //              p->osd->sleep(10);
        //}
@@ -153,13 +155,13 @@ int debugger_command(debugger_thread_t *p, _TCHAR *command, _TCHAR *prev_command
                        }
                        if(_tcsicmp(params[0], _T("D")) == 0) {
                                if(num <= 3) {
-                                       uint32 start_addr = dump_addr;
+                                       uint32_t start_addr = dump_addr;
                                        if(num >= 2) {
                                                start_addr = my_hexatoi(params[1]);
                                        }
                                        start_addr &= data_addr_mask;
                                        
-                                       uint32 end_addr = start_addr + 8 * 16 - 1;
+                                       uint32_t end_addr = start_addr + 8 * 16 - 1;
                                        if(num == 3) {
                                                end_addr = my_hexatoi(params[2]);
                                        }
@@ -168,7 +170,7 @@ int debugger_command(debugger_thread_t *p, _TCHAR *command, _TCHAR *prev_command
                                        if(start_addr > end_addr) {
                                                end_addr = data_addr_mask;
                                        }
-                                       for(uint64 addr = start_addr & ~0x0f; addr <= end_addr; addr++) {
+                                       for(uint64_t addr = start_addr & ~0x0f; addr <= end_addr; addr++) {
                                                if(addr > data_addr_mask) {
                                                        end_addr = data_addr_mask;
                                                        break;
@@ -181,7 +183,7 @@ int debugger_command(debugger_thread_t *p, _TCHAR *command, _TCHAR *prev_command
                                                        my_printf(p->osd, _T("   "));
                                                        buffer[addr & 0x0f] = _T(' ');
                                                } else {
-                                                       uint32 data = cpu->debug_read_data8(addr & data_addr_mask);
+                                                       uint32_t data = cpu->read_debug_data8(addr & data_addr_mask);
                                                        my_printf(p->osd, _T(" %02X"), data);
                                                        buffer[addr & 0x0f] = ((data >= 0x20 && data <= 0x7e) || (cp932 && data >= 0xa1 && data <= 0xdf)) ? data : _T('.');
                                                }
@@ -190,7 +192,7 @@ int debugger_command(debugger_thread_t *p, _TCHAR *command, _TCHAR *prev_command
                                                }
                                        }
                                        if((end_addr & 0x0f) != 0x0f) {
-                                               for(uint32 addr = (end_addr & 0x0f) + 1; addr <= 0x0f; addr++) {
+                                               for(uint32_t addr = (end_addr & 0x0f) + 1; addr <= 0x0f; addr++) {
                                                        my_printf(p->osd, _T("   "));
                                                }
                                                my_printf(p->osd, _T("  %s\n"), buffer);
@@ -202,9 +204,9 @@ int debugger_command(debugger_thread_t *p, _TCHAR *command, _TCHAR *prev_command
                                }
                        } else if(_tcsicmp(params[0], _T("E")) == 0 || _tcsicmp(params[0], _T("EB")) == 0) {
                                if(num >= 3) {
-                                       uint32 addr = my_hexatoi(params[1]) & data_addr_mask;
+                                       uint32_t addr = my_hexatoi(params[1]) & data_addr_mask;
                                        for(int i = 2; i < num; i++) {
-                                               cpu->debug_write_data8(addr, my_hexatoi(params[i]) & 0xff);
+                                               cpu->write_debug_data8(addr, my_hexatoi(params[i]) & 0xff);
                                                addr = (addr + 1) & data_addr_mask;
                                        }
                                } else {
@@ -212,9 +214,9 @@ int debugger_command(debugger_thread_t *p, _TCHAR *command, _TCHAR *prev_command
                                }
                        } else if(_tcsicmp(params[0], _T("EW")) == 0) {
                                if(num >= 3) {
-                                       uint32 addr = my_hexatoi(params[1]) & data_addr_mask;
+                                       uint32_t addr = my_hexatoi(params[1]) & data_addr_mask;
                                        for(int i = 2; i < num; i++) {
-                                               cpu->debug_write_data16(addr, my_hexatoi(params[i]) & 0xffff);
+                                               cpu->write_debug_data16(addr, my_hexatoi(params[i]) & 0xffff);
                                                addr = (addr + 2) & data_addr_mask;
                                        }
                                } else {
@@ -222,9 +224,9 @@ int debugger_command(debugger_thread_t *p, _TCHAR *command, _TCHAR *prev_command
                                }
                        } else if(_tcsicmp(params[0], _T("ED")) == 0) {
                                if(num >= 3) {
-                                       uint32 addr = my_hexatoi(params[1]) & data_addr_mask;
+                                       uint32_t addr = my_hexatoi(params[1]) & data_addr_mask;
                                        for(int i = 2; i < num; i++) {
-                                               cpu->debug_write_data32(addr, my_hexatoi(params[i]));
+                                               cpu->write_debug_data32(addr, my_hexatoi(params[i]));
                                                addr = (addr + 4) & data_addr_mask;
                                        }
                                } else {
@@ -232,12 +234,12 @@ int debugger_command(debugger_thread_t *p, _TCHAR *command, _TCHAR *prev_command
                                }
                        } else if(_tcsicmp(params[0], _T("EA")) == 0) {
                                if(num >= 3) {
-                                       uint32 addr = my_hexatoi(params[1]) & data_addr_mask;
+                                       uint32_t addr = my_hexatoi(params[1]) & data_addr_mask;
                                        my_tcscpy_s(buffer, 1024, prev_command);
                                        if((token = my_tcstok_s(buffer, _T("\""), &context)) != NULL && (token = my_tcstok_s(NULL, _T("\""), &context)) != NULL) {
                                                int len = _tcslen(token);
                                                for(int i = 0; i < len; i++) {
-                                                       cpu->debug_write_data8(addr, token[i] & 0xff);
+                                                       cpu->write_debug_data8(addr, token[i] & 0xff);
                                                        addr = (addr + 1) & data_addr_mask;
                                                }
                                        } else {
@@ -248,46 +250,46 @@ int debugger_command(debugger_thread_t *p, _TCHAR *command, _TCHAR *prev_command
                                }
                        } else if(_tcsicmp(params[0], _T("I")) == 0 || _tcsicmp(params[0], _T("IB")) == 0) {
                                if(num == 2) {
-                                       my_printf(p->osd, _T("%02X\n"), cpu->debug_read_io8(my_hexatoi(params[1])) & 0xff);
+                                       my_printf(p->osd, _T("%02X\n"), cpu->read_debug_io8(my_hexatoi(params[1])) & 0xff);
                                } else {
                                        my_printf(p->osd, _T("invalid parameter number\n"));
                                }
                        } else if(_tcsicmp(params[0], _T("IW")) == 0) {
                                if(num == 2) {
-                                       my_printf(p->osd, _T("%02X\n"), cpu->debug_read_io16(my_hexatoi(params[1])) & 0xffff);
+                                       my_printf(p->osd, _T("%02X\n"), cpu->read_debug_io16(my_hexatoi(params[1])) & 0xffff);
                                } else {
                                        my_printf(p->osd, _T("invalid parameter number\n"));
                                }
                        } else if(_tcsicmp(params[0], _T("ID")) == 0) {
                                if(num == 2) {
-                                       my_printf(p->osd, _T("%02X\n"), cpu->debug_read_io32(my_hexatoi(params[1])));
+                                       my_printf(p->osd, _T("%02X\n"), cpu->read_debug_io32(my_hexatoi(params[1])));
                                } else {
                                        my_printf(p->osd, _T("invalid parameter number\n"));
                                }
                        } else if(_tcsicmp(params[0], _T("O")) == 0 || _tcsicmp(params[0], _T("OB")) == 0) {
                                if(num == 3) {
-                                       cpu->debug_write_io8(my_hexatoi(params[1]), my_hexatoi(params[2]) & 0xff);
+                                       cpu->write_debug_io8(my_hexatoi(params[1]), my_hexatoi(params[2]) & 0xff);
                                } else {
                                        my_printf(p->osd, _T("invalid parameter number\n"));
                                }
                        } else if(_tcsicmp(params[0], _T("OW")) == 0) {
                                if(num == 3) {
-                                       cpu->debug_write_io16(my_hexatoi(params[1]), my_hexatoi(params[2]) & 0xffff);
+                                       cpu->write_debug_io16(my_hexatoi(params[1]), my_hexatoi(params[2]) & 0xffff);
                                } else {
                                        my_printf(p->osd, _T("invalid parameter number\n"));
                                }
                        } else if(_tcsicmp(params[0], _T("OD")) == 0) {
                                if(num == 3) {
-                                       cpu->debug_write_io32(my_hexatoi(params[1]), my_hexatoi(params[2]));
+                                       cpu->write_debug_io32(my_hexatoi(params[1]), my_hexatoi(params[2]));
                                } else {
                                        my_printf(p->osd, _T("invalid parameter number\n"));
                                }
                        } else if(_tcsicmp(params[0], _T("R")) == 0) {
                                if(num == 1) {
-                                       cpu->debug_regs_info(buffer, 1024);
+                                       cpu->get_debug_regs_info(buffer, 1024);
                                        my_printf(p->osd, _T("%s\n"), buffer);
                                } else if(num == 3) {
-                                       if(!cpu->debug_write_reg(params[1], my_hexatoi(params[2]))) {
+                                       if(!cpu->write_debug_reg(params[1], my_hexatoi(params[2]))) {
                                                my_printf(p->osd, _T("unknown register %s\n"), params[1]);
                                        }
                                } else {
@@ -295,16 +297,16 @@ int debugger_command(debugger_thread_t *p, _TCHAR *command, _TCHAR *prev_command
                                }
                        } else if(_tcsicmp(params[0], _T("S")) == 0) {
                                if(num >= 4) {
-                                       uint32 start_addr = my_hexatoi(params[1]) & data_addr_mask;
-                                       uint32 end_addr = my_hexatoi(params[2]) & data_addr_mask;
-                                       uint8 list[32];
+                                       uint32_t start_addr = my_hexatoi(params[1]) & data_addr_mask;
+                                       uint32_t end_addr = my_hexatoi(params[2]) & data_addr_mask;
+                                       uint8_t list[32];
                                        for(int i = 3, j = 0; i < num; i++, j++) {
                                                list[j] = my_hexatoi(params[i]);
                                        }
-                                       for(uint64 addr = start_addr; addr <= end_addr; addr++) {
+                                       for(uint64_t addr = start_addr; addr <= end_addr; addr++) {
                                                bool found = true;
                                                for(int i = 3, j = 0; i < num; i++, j++) {
-                                                       if(cpu->debug_read_data8((addr + j) & data_addr_mask) != list[j]) {
+                                                       if(cpu->read_debug_data8((addr + j) & data_addr_mask) != list[j]) {
                                                                found = false;
                                                                break;
                                                        }
@@ -322,31 +324,31 @@ int debugger_command(debugger_thread_t *p, _TCHAR *command, _TCHAR *prev_command
                                                dasm_addr = my_hexatoi(params[1]) & prog_addr_mask;
                                        }
                                        if(num == 3) {
-                                               uint32 end_addr = my_hexatoi(params[2]) & prog_addr_mask;
+                                               uint32_t end_addr = my_hexatoi(params[2]) & prog_addr_mask;
                                                while(dasm_addr <= end_addr) {
-                                                       int len = cpu->debug_dasm(dasm_addr, buffer, 1024);
-                                                       my_printf(p->osd, _T("%08X  "), dasm_addr);
+                                                       int len = cpu->debug_dasm(dasm_addr & prog_addr_mask, buffer, 1024);
+                                                       my_printf(p->osd, _T("%08X  "), dasm_addr & prog_addr_mask);
                                                        for(int i = 0; i < len; i++) {
-                                                               my_printf(p->osd, _T("%02X"), cpu->debug_read_data8((dasm_addr + i) & data_addr_mask));
+                                                               my_printf(p->osd, _T("%02X"), cpu->read_debug_data8((dasm_addr + i) & data_addr_mask));
                                                        }
                                                        for(int i = len; i < 8; i++) {
                                                                my_printf(p->osd, _T("  "));
                                                        }
                                                        my_printf(p->osd, _T("  %s\n"), buffer);
-                                                       dasm_addr = (dasm_addr + len) & prog_addr_mask;
+                                                       dasm_addr += len;
                                                }
                                        } else {
                                                for(int i = 0; i < 16; i++) {
-                                                       int len = cpu->debug_dasm(dasm_addr, buffer, 1024);
-                                                       my_printf(p->osd, _T("%08X  "), dasm_addr);
+                                                       int len = cpu->debug_dasm(dasm_addr & prog_addr_mask, buffer, 1024);
+                                                       my_printf(p->osd, _T("%08X  "), dasm_addr & prog_addr_mask);
                                                        for(int i = 0; i < len; i++) {
-                                                               my_printf(p->osd, _T("%02X"), cpu->debug_read_data8((dasm_addr + i) & data_addr_mask));
+                                                               my_printf(p->osd, _T("%02X"), cpu->read_debug_data8((dasm_addr + i) & data_addr_mask));
                                                        }
                                                        for(int i = len; i < 8; i++) {
                                                                my_printf(p->osd, _T("  "));
                                                        }
                                                        my_printf(p->osd, _T("  %s\n"), buffer);
-                                                       dasm_addr = (dasm_addr + len) & prog_addr_mask;
+                                                       dasm_addr += len;
                                                }
                                        }
                                        prev_command[1] = _T('\0'); // remove parameters to disassemble continuously
@@ -355,8 +357,8 @@ int debugger_command(debugger_thread_t *p, _TCHAR *command, _TCHAR *prev_command
                                }
                        } else if(_tcsicmp(params[0], _T("H")) == 0) {
                                if(num == 3) {
-                                       uint32 l = my_hexatoi(params[1]);
-                                       uint32 r = my_hexatoi(params[2]);
+                                       uint32_t l = my_hexatoi(params[1]);
+                                       uint32_t r = my_hexatoi(params[2]);
                                        my_printf(p->osd, _T("%08X  %08X\n"), l + r, l - r);
                                } else {
                                        my_printf(p->osd, _T("invalid parameter number\n"));
@@ -378,7 +380,7 @@ int debugger_command(debugger_thread_t *p, _TCHAR *command, _TCHAR *prev_command
                                FILEIO* fio = new FILEIO();
                                if(check_file_extension(debugger->file_path, _T(".hex"))) {
                                        if(fio->Fopen(debugger->file_path, FILEIO_READ_ASCII)) {
-                                               uint32 start_addr = 0, linear = 0, segment = 0;
+                                               uint32_t start_addr = 0, linear = 0, segment = 0;
                                                if(num >= 2) {
                                                        start_addr = my_hexatoi(params[1]);
                                                }
@@ -387,10 +389,10 @@ int debugger_command(debugger_thread_t *p, _TCHAR *command, _TCHAR *prev_command
                                                        if(line[0] != ':') continue;
                                                        int type = my_hexatob(line + 7);
                                                        if(type == 0x00) {
-                                                               uint32 bytes = my_hexatob(line + 1);
-                                                               uint32 addr = my_hexatow(line + 3) + start_addr + linear + segment;
-                                                               for(uint32 i = 0; i < bytes; i++) {
-                                                                       cpu->debug_write_data8((addr + i) & data_addr_mask, my_hexatob(line + 9 + 2 * i));
+                                                               uint32_t bytes = my_hexatob(line + 1);
+                                                               uint32_t addr = my_hexatow(line + 3) + start_addr + linear + segment;
+                                                               for(uint32_t i = 0; i < bytes; i++) {
+                                                                       cpu->write_debug_data8((addr + i) & data_addr_mask, my_hexatob(line + 9 + 2 * i));
                                                                }
                                                        } else if(type == 0x01) {
                                                                break;
@@ -408,19 +410,19 @@ int debugger_command(debugger_thread_t *p, _TCHAR *command, _TCHAR *prev_command
                                        }
                                } else {
                                        if(fio->Fopen(debugger->file_path, FILEIO_READ_BINARY)) {
-                                               uint32 start_addr = 0x100, end_addr = data_addr_mask;
+                                               uint32_t start_addr = 0x100, end_addr = data_addr_mask;
                                                if(num >= 2) {
                                                        start_addr = my_hexatoi(params[1]) & data_addr_mask;
                                                }
                                                if(num >= 3) {
                                                        end_addr = my_hexatoi(params[2]) & data_addr_mask;
                                                }
-                                               for(uint32 addr = start_addr; addr <= end_addr; addr++) {
+                                               for(uint32_t addr = start_addr; addr <= end_addr; addr++) {
                                                        int data = fio->Fgetc();
                                                        if(data == EOF) {
                                                                break;
                                                        }
-                                                       cpu->debug_write_data8(addr & data_addr_mask, data);
+                                                       cpu->write_debug_data8(addr & data_addr_mask, data);
                                                }
                                                fio->Fclose();
                                        } else {
@@ -430,18 +432,18 @@ int debugger_command(debugger_thread_t *p, _TCHAR *command, _TCHAR *prev_command
                                delete fio;
                        } else if(_tcsicmp(params[0], _T("W")) == 0) {
                                if(num == 3) {
-                                       uint32 start_addr = my_hexatoi(params[1]) & data_addr_mask, end_addr = my_hexatoi(params[2]) & data_addr_mask;
+                                       uint32_t start_addr = my_hexatoi(params[1]) & data_addr_mask, end_addr = my_hexatoi(params[2]) & data_addr_mask;
                                        FILEIO* fio = new FILEIO();
                                        if(check_file_extension(debugger->file_path, _T(".hex"))) {
                                                // write intel hex format file
                                                if(fio->Fopen(debugger->file_path, FILEIO_WRITE_ASCII)) {
-                                                       uint32 addr = start_addr;
+                                                       uint32_t addr = start_addr;
                                                        while(addr <= end_addr) {
-                                                               uint32 len = min(end_addr - addr + 1, (uint32)16);
-                                                               uint32 sum = len + ((addr >> 8) & 0xff) + (addr & 0xff) + 0x00;
+                                                               uint32_t len = min(end_addr - addr + 1, (uint32_t)16);
+                                                               uint32_t sum = len + ((addr >> 8) & 0xff) + (addr & 0xff) + 0x00;
                                                                fio->Fprintf(":%02X%04X%02X", len, addr & 0xffff, 0x00);
-                                                               for(uint32 i = 0; i < len; i++) {
-                                                                       uint8 data = cpu->debug_read_data8((addr++) & data_addr_mask);
+                                                               for(uint32_t i = 0; i < len; i++) {
+                                                                       uint8_t data = cpu->read_debug_data8((addr++) & data_addr_mask);
                                                                        sum += data;
                                                                        fio->Fprintf("%02X", data);
                                                                }
@@ -454,8 +456,8 @@ int debugger_command(debugger_thread_t *p, _TCHAR *command, _TCHAR *prev_command
                                                }
                                        } else {
                                                if(fio->Fopen(debugger->file_path, FILEIO_WRITE_BINARY)) {
-                                                       for(uint32 addr = start_addr; addr <= end_addr; addr++) {
-                                                               fio->Fputc(cpu->debug_read_data8(addr & data_addr_mask));
+                                                       for(uint32_t addr = start_addr; addr <= end_addr; addr++) {
+                                                               fio->Fputc(cpu->read_debug_data8(addr & data_addr_mask));
                                                        }
                                                        fio->Fclose();
                                                } else {
@@ -469,7 +471,7 @@ int debugger_command(debugger_thread_t *p, _TCHAR *command, _TCHAR *prev_command
                        } else if(_tcsicmp(params[0], _T( "BP")) == 0 || _tcsicmp(params[0], _T("RBP")) == 0 || _tcsicmp(params[0], _T("WBP")) == 0) {
                                break_point_t *bp = get_break_point(debugger, params[0]);
                                if(num == 2) {
-                                       uint32 addr = my_hexatoi(params[1]);
+                                       uint32_t addr = my_hexatoi(params[1]);
                                        bool found = false;
                                        for(int i = 0; i < MAX_BREAK_POINTS && !found; i++) {
                                                if(bp->table[i].status == 0 || (bp->table[i].addr == addr && bp->table[i].mask == prog_addr_mask)) {
@@ -488,7 +490,7 @@ int debugger_command(debugger_thread_t *p, _TCHAR *command, _TCHAR *prev_command
                        } else if(_tcsicmp(params[0], _T("IBP")) == 0 || _tcsicmp(params[0], _T("OBP")) == 0) {
                                break_point_t *bp = get_break_point(debugger, params[0]);
                                if(num == 2 || num == 3) {
-                                       uint32 addr = my_hexatoi(params[1]), mask = 0xff;
+                                       uint32_t addr = my_hexatoi(params[1]), mask = 0xff;
                                        if(num == 3) {
                                                mask = my_hexatoi(params[2]);
                                        }
@@ -582,7 +584,7 @@ int debugger_command(debugger_thread_t *p, _TCHAR *command, _TCHAR *prev_command
                                        debugger->now_suspended = false;
 #if defined(_MSC_VER)                                     
                                        while(!p->request_terminate && !debugger->now_suspended) {
-                                               if((GetAsyncKeyState(VK_ESCAPE) & 0x8000) != 0 && p->osd->is_console_active()) {
+                                               if(p->osd->is_console_key_pressed(VK_ESCAPE) && p->osd->is_console_active()) {
                                                        break;
                                                }
                                                p->osd->sleep(10);
@@ -608,7 +610,7 @@ int debugger_command(debugger_thread_t *p, _TCHAR *command, _TCHAR *prev_command
                                        my_printf(p->osd, _T("done\t%08X  %s\n"), cpu->get_pc(), buffer);
                                        
                                        p->osd->set_console_text_attribute(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
-                                       cpu->debug_regs_info(buffer, 1024);
+                                       cpu->get_debug_regs_info(buffer, 1024);
                                        my_printf(p->osd, _T("%s\n"), buffer);
                                        
                                        if(debugger->hit()) {
@@ -658,18 +660,12 @@ int debugger_command(debugger_thread_t *p, _TCHAR *command, _TCHAR *prev_command
                                                my_printf(p->osd, _T("done\t%08X  %s\n"), cpu->get_pc(), buffer);
                                                
                                                p->osd->set_console_text_attribute(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
-                                               cpu->debug_regs_info(buffer, 1024);
+                                               cpu->get_debug_regs_info(buffer, 1024);
                                                my_printf(p->osd, _T("%s\n"), buffer);
-#if defined(_MSC_VER)                                     
-                                               if(debugger->hit() || ((GetAsyncKeyState(VK_ESCAPE) & 0x8000) != 0 && p->osd->is_console_active())) {
-                                                       break;
-                                               }
-#elif defined(OSD_QT)
-                                               if(debugger->hit() || p->osd->console_input_string() != NULL && p->osd->is_console_active()) {
-                                                       p->osd->clear_console_input_string();
+                                               if(debugger->hit() || (p->osd->is_console_key_pressed(VK_ESCAPE) && p->osd->is_console_active())) {
+                                                       //p->osd->clear_console_input_string();
                                                        break;
                                                }
-#endif                                    
                                        }
                                        if(debugger->hit()) {
                                                p->osd->set_console_text_attribute(FOREGROUND_RED | FOREGROUND_INTENSITY);
@@ -694,11 +690,7 @@ int debugger_command(debugger_thread_t *p, _TCHAR *command, _TCHAR *prev_command
                                        my_printf(p->osd, _T("invalid parameter number\n"));
                                }
                        } else if(_tcsicmp(params[0], _T("Q")) == 0) {
-#if defined(_MSC_VER)                          
-                               PostMessage(p->osd->main_window_handle, WM_COMMAND, ID_CLOSE_DEBUGGER, 0L);
-#else
-                               p->osd->do_close_debugger_console();
-#endif                         
+                               p->osd->close_debugger_console();
                                return -1;
                        } else if(_tcsicmp(params[0], _T(">")) == 0) {
                                if(num == 2) {
@@ -738,7 +730,7 @@ int debugger_command(debugger_thread_t *p, _TCHAR *command, _TCHAR *prev_command
                                                        msec = my_hexatoi(params[3]);
                                                }
 #ifdef SUPPORT_VARIABLE_TIMING
-                                               p->osd->modify_key_buffer(code, max((int)(p->vm->frame_rate() * (double)msec / 1000.0 + 0.5), 1));
+                                               p->osd->modify_key_buffer(code, max((int)(p->vm->get_frame_rate() * (double)msec / 1000.0 + 0.5), 1));
 #else
                                                p->osd->modify_key_buffer(code, max((int)(FRAMES_PER_SEC * (double)msec / 1000.0 + 0.5), 1));
 #endif
@@ -805,25 +797,23 @@ int debugger_thread(void *lpx)
        
        debugger->now_going = false;
        debugger->now_debugging = true;
+#ifndef _USE_QT        
        while(!debugger->now_suspended) {
                p->osd->sleep(10);
        }
-       
-       uint32 prog_addr_mask = cpu->debug_prog_addr_mask();
-       uint32 data_addr_mask = cpu->debug_data_addr_mask();
-       uint32 dump_addr = 0;
-       uint32 dasm_addr = cpu->get_next_pc();
+#endif 
+       uint32_t prog_addr_mask = cpu->get_debug_prog_addr_mask();
+       uint32_t data_addr_mask = cpu->get_debug_data_addr_mask();
+       dump_addr = 0;
+       dasm_addr = cpu->get_next_pc();
        
        // initialize console
        _TCHAR buffer[1024];
-       my_stprintf_s(buffer, 1024, _T("Debugger - %s"), _T(DEVICE_NAME));
-       
-       p->osd->open_console(buffer);
-       
        bool cp932 = (p->osd->get_console_code_page() == 932);
        
+       p->osd->open_console((_TCHAR *)create_string(_T("Debugger - %s"), _T(DEVICE_NAME)));
        p->osd->set_console_text_attribute(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
-       cpu->debug_regs_info(buffer, 1024);
+       cpu->get_debug_regs_info(buffer, 1024);
        my_printf(p->osd, _T("%s\n"), buffer);
        
        p->osd->set_console_text_attribute(FOREGROUND_RED | FOREGROUND_INTENSITY);
@@ -853,11 +843,11 @@ int debugger_thread(void *lpx)
                while(!p->request_terminate && !enter_done) {
                        _TCHAR ir[16];
                        int count = p->osd->read_console_input(ir);
-                       
+
                        for(int i = 0; i < count; i++) {
                                _TCHAR chr = ir[i];
                                
-                               if(chr == 0x0d || chr == 0x0a) {
+                               if(chr == '\n' || chr == '\r') {
                                        if(ptr == 0 && prev_command[0] != _T('\0')) {
                                                memcpy(command, prev_command, sizeof(command));
                                                my_printf(p->osd, _T("%s\n"), command);
@@ -886,7 +876,7 @@ int debugger_thread(void *lpx)
                }
                // process command
                if(!p->request_terminate && enter_done) {
-                       if(debugger_command(p, command, prev_command, cp932) < 0) break;
+                       if(debugger_command((debugger_thread_t *)p, command, prev_command, cp932) < 0) break;
                }
        }
    
@@ -943,6 +933,7 @@ void EMU::open_debugger(int cpu_index)
                        if((debugger_thread_id = SDL_CreateThread(debugger_thread, "DebuggerThread", (void *)&debugger_thread_param)) != 0) {
 #else // USE_QT
                                {
+                                       //debugger_thread_id = -1;
                                        volatile debugger_thread_t *p = (debugger_thread_t *)(&debugger_thread_param);
                                        p->running = true;
                                        
@@ -955,10 +946,10 @@ void EMU::open_debugger(int cpu_index)
                                        //      p->osd->sleep(10);
                                        //}
                                        
-                                       uint32 prog_addr_mask = cpu->debug_prog_addr_mask();
-                                       uint32 data_addr_mask = cpu->debug_data_addr_mask();
-                                       uint32 dump_addr = 0;
-                                       uint32 dasm_addr = cpu->get_next_pc();
+                                       uint32_t prog_addr_mask = cpu->get_debug_prog_addr_mask();
+                                       uint32_t data_addr_mask = cpu->get_debug_data_addr_mask();
+                                       dump_addr = 0;
+                                       dasm_addr = cpu->get_next_pc();
        
                                        // initialize console
                                        _TCHAR buffer[1024];
@@ -969,7 +960,7 @@ void EMU::open_debugger(int cpu_index)
                                        bool cp932 = (p->osd->get_console_code_page() == 932);
                                        
                                        p->osd->set_console_text_attribute(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
-                                       cpu->debug_regs_info(buffer, 1024);
+                                       cpu->get_debug_regs_info(buffer, 1024);
                                        my_printf(p->osd, _T("%s\n"), buffer);
                                        
                                        p->osd->set_console_text_attribute(FOREGROUND_RED | FOREGROUND_INTENSITY);
@@ -986,8 +977,8 @@ void EMU::open_debugger(int cpu_index)
                                        }
                                        logfile = NULL;
 #endif
-                                       stop_rec_sound();
-                                       stop_rec_video();
+                                       stop_record_sound();
+                                       stop_record_video();
                                        now_debugging = true;
                        }
                }
@@ -1021,7 +1012,7 @@ void EMU::close_debugger()
        }
 }
 
-bool EMU::debugger_enabled(int cpu_index)
+bool EMU::is_debugger_enabled(int cpu_index)
 {
        return (vm->get_cpu(cpu_index) != NULL && vm->get_cpu(cpu_index)->get_debugger() != NULL);
 }