mirror of
https://github.com/digarok/gsplus.git
synced 2024-11-24 06:34:02 +00:00
omg adding debugger to experimental branch
This commit is contained in:
parent
8fd37324a8
commit
225505c32e
@ -1,7 +1,7 @@
|
||||
# GSport central makefile - you need a 'vars' file linked/copied from a 'vars_xxx' template to build.
|
||||
#@todo: check for vars file and do something useful if missing :P
|
||||
|
||||
OBJECTS1 = adb.o clock.o config.o dis.o engine_c.o scc.o iwm.o \
|
||||
OBJECTS1 = adb.o clock.o config.o debug.o dis.o engine_c.o scc.o iwm.o \
|
||||
joystick_driver.o moremem.o paddles.o parallel.o printer.o \
|
||||
sim65816.o smartport.o sound.o sound_driver.o video.o \
|
||||
scc_socket_driver.o imagewriter.o scc_imagewriter.o scc_llap.o
|
||||
|
14
src/adb.c
14
src/adb.c
@ -40,9 +40,9 @@ extern int g_invert_paddles;
|
||||
extern int g_joystick_type;
|
||||
extern int g_a2vid_palette;
|
||||
extern int g_config_control_panel;
|
||||
extern int g_screenshot_requested;
|
||||
extern word32 g_cfg_vbl_count;
|
||||
extern double g_cur_dcycs;
|
||||
|
||||
extern byte *g_slow_memory_ptr;
|
||||
extern byte *g_memory_ptr;
|
||||
extern word32 g_mem_size_total;
|
||||
@ -1738,11 +1738,8 @@ adb_physical_key_update(int a2code, int is_up)
|
||||
|
||||
if(special && !is_up) {
|
||||
switch(special) {
|
||||
// OG Disabled special keys (but warp)
|
||||
#ifndef ACTIVEGS
|
||||
case 0x04: /* F4 - emulator config panel */
|
||||
if (CMD_DOWN)
|
||||
{
|
||||
if (CMD_DOWN) {
|
||||
printf("Quit!\n");
|
||||
iwm_shut();
|
||||
my_exit(1);
|
||||
@ -1753,7 +1750,11 @@ adb_physical_key_update(int a2code, int is_up)
|
||||
}
|
||||
break;
|
||||
case 0x05: /* F5 - emulator clipboard paste */
|
||||
if (SHIFT_DOWN) {
|
||||
g_screenshot_requested = 1;
|
||||
} else {
|
||||
clipboard_paste();
|
||||
}
|
||||
break;
|
||||
case 0x06: /* F6 - emulator speed */
|
||||
if(SHIFT_DOWN) {
|
||||
@ -1767,7 +1768,6 @@ adb_physical_key_update(int a2code, int is_up)
|
||||
printf("g_fast_disk_emul is now %d\n",
|
||||
g_fast_disk_emul);
|
||||
break;
|
||||
#endif
|
||||
case 0x08: /* F8 - warp pointer */
|
||||
g_warp_pointer = !g_warp_pointer;
|
||||
if(g_hide_pointer != g_warp_pointer) {
|
||||
@ -1775,7 +1775,6 @@ adb_physical_key_update(int a2code, int is_up)
|
||||
x_hide_pointer(g_hide_pointer);
|
||||
}
|
||||
break;
|
||||
#ifndef ACTIVEGS
|
||||
case 0x09: /* F9 - swap paddles */
|
||||
if(SHIFT_DOWN) {
|
||||
g_swap_paddles = !g_swap_paddles;
|
||||
@ -1804,7 +1803,6 @@ adb_physical_key_update(int a2code, int is_up)
|
||||
g_fullscreen = !g_fullscreen;
|
||||
x_full_screen(g_fullscreen);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
return;
|
||||
|
1584
src/debug.c
Normal file
1584
src/debug.c
Normal file
File diff suppressed because it is too large
Load Diff
8
src/debug.h
Normal file
8
src/debug.h
Normal file
@ -0,0 +1,8 @@
|
||||
extern void debug_init();
|
||||
extern void debug_poll_only();
|
||||
extern void debug_cpu_test();
|
||||
|
||||
// used in sim65816.c
|
||||
void debug_server_poll();
|
||||
int debug_events_waiting();
|
||||
void debug_handle_event();
|
@ -40,6 +40,7 @@
|
||||
# define FCYCS_PTR_FCYCLES_ROUND_SLOW
|
||||
#endif
|
||||
|
||||
extern int g_dbg_step;
|
||||
extern int halt_sim;
|
||||
extern int g_code_red;
|
||||
extern int g_ignore_halts;
|
||||
@ -376,6 +377,7 @@ check_breakpoints(word32 addr)
|
||||
count = g_num_breakpoints;
|
||||
for(i = 0; i < count; i++) {
|
||||
if((g_breakpts[i] & 0xffffff) == addr) {
|
||||
g_dbg_step = -2;
|
||||
halt2_printf("Hit breakpoint at %06x\n", addr);
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,8 @@
|
||||
|
||||
// @todo: mouse clip bugs.. great western shootout. Paint 8/16. still in win32
|
||||
#include "SDL.h"
|
||||
#include "SDL_image.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
@ -46,6 +48,12 @@ int g_win_status_debug_request = 0; // Desired visibility of status lines.
|
||||
int g_screen_mdepth = 0;
|
||||
int kb_shift_control_state = 0;
|
||||
|
||||
void x_take_screenshot(); // screenshot stuff
|
||||
int g_screenshot_requested = 0; // DB to know if we want to save a screenshot
|
||||
extern char g_config_gsplus_name[];
|
||||
int screenshot_index = 0; // allows us to save time by not scanning from 0 each time
|
||||
char screenshot_filename[256];
|
||||
|
||||
extern int g_screen_depth;
|
||||
extern int g_quit_sim_now;
|
||||
extern int g_border_sides_refresh_needed;
|
||||
@ -341,6 +349,12 @@ void sdl_push_kimage(Kimage *kimage_ptr,
|
||||
SDL_RenderCopy(renderer, texture, NULL, NULL);
|
||||
SDL_RenderPresent(renderer);
|
||||
|
||||
if (g_screenshot_requested) {
|
||||
x_take_screenshot();
|
||||
g_screenshot_requested = 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -583,6 +597,74 @@ int clipboard_get_char() {
|
||||
return g_clipboard[g_clipboard_pos++] | 0x80;
|
||||
}
|
||||
|
||||
void x_full_screen(int do_full) {
|
||||
if (do_full) {
|
||||
SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP);
|
||||
} else {
|
||||
SDL_SetWindowFullscreen(window, 0);
|
||||
SDL_SetWindowSize(window, BASE_WINDOW_WIDTH, X_A2_WINDOW_HEIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
int file_exists(char *fname){
|
||||
if( access( fname, F_OK ) != -1 ) {
|
||||
return 1; // file exists
|
||||
} else {
|
||||
return 0; // file doesn't exist
|
||||
}
|
||||
}
|
||||
|
||||
void make_next_screenshot_filename()
|
||||
{
|
||||
char filepart[256];
|
||||
char filename[256];
|
||||
|
||||
|
||||
int available_filename = 0;
|
||||
while (!available_filename) {
|
||||
// get location of '.'
|
||||
char *dotptr = strchr(g_config_gsplus_name, '.');
|
||||
int index = dotptr - g_config_gsplus_name;
|
||||
strncpy(filepart, g_config_gsplus_name, index);
|
||||
filepart[index] = '\0'; //terminator
|
||||
sprintf(filename, "%s%04d.png",filepart,screenshot_index);
|
||||
|
||||
if (file_exists(filename)) {
|
||||
//printf("Found existing %s\n", filename);
|
||||
screenshot_index++;
|
||||
} else {
|
||||
//printf("Available filename: %s\n", filename);
|
||||
available_filename = 1;
|
||||
}
|
||||
}
|
||||
strcpy(screenshot_filename, filename);
|
||||
}
|
||||
|
||||
// @todo: some error with writing data direct to png. output is empty/transparent?
|
||||
// workaround is this horrible hack of saving the bmp -> load bmp -> save png
|
||||
void x_take_screenshot() {
|
||||
make_next_screenshot_filename();
|
||||
|
||||
SDL_Surface *sshot = SDL_CreateRGBSurface(0, BASE_WINDOW_WIDTH, X_A2_WINDOW_HEIGHT, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
|
||||
SDL_LockSurface(sshot);
|
||||
int read = SDL_RenderReadPixels(renderer, NULL, SDL_PIXELFORMAT_ARGB8888, sshot->pixels, sshot->pitch);
|
||||
if (read != 0) {
|
||||
printf("READPXL FAIL!\n%s\n", SDL_GetError());
|
||||
}
|
||||
SDL_SaveBMP(sshot, "screenshot.bmp");
|
||||
SDL_UnlockSurface(sshot);
|
||||
SDL_FreeSurface(sshot);
|
||||
|
||||
SDL_Surface *s = SDL_CreateRGBSurface(0, BASE_WINDOW_WIDTH, X_A2_WINDOW_HEIGHT,
|
||||
32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
|
||||
if (s) {
|
||||
SDL_Surface * image = SDL_LoadBMP("screenshot.bmp");
|
||||
IMG_SavePNG(image, screenshot_filename);
|
||||
SDL_FreeSurface(image);
|
||||
|
||||
}
|
||||
SDL_FreeSurface(s);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -596,7 +678,6 @@ void x_redraw_status_lines() { }
|
||||
void x_hide_pointer(int do_hide) { }
|
||||
void x_auto_repeat_on(int must) { }
|
||||
void x_auto_repeat_off(int must) { }
|
||||
void x_full_screen(int do_full) { }
|
||||
// OG Adding release
|
||||
void x_release_kimage(Kimage* kimage_ptr) { }
|
||||
// OG Addding ratio
|
||||
|
@ -22,10 +22,10 @@
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "defc.h"
|
||||
#include "printer.h"
|
||||
#include "imagewriter.h"
|
||||
#include "debug.h"
|
||||
|
||||
extern const char *g_config_gsplus_name_list[];
|
||||
#ifdef UNDER_CE
|
||||
@ -49,7 +49,6 @@ extern const char *g_config_gsplus_name_list[];
|
||||
int g_speed_fast ; // OG Expose fast parameter
|
||||
int g_initialized = 0; // OG To know if the emulator has finalized its initialization
|
||||
int g_accept_events = 0; // OG To know if the emulator is ready to accept external events
|
||||
|
||||
char g_argv0_path[256] = "./";
|
||||
|
||||
const char *g_gsplus_default_paths[] = { "", "./", "${HOME}/","${PWD}/",
|
||||
@ -74,6 +73,8 @@ const char *g_gsplus_default_paths[] = { "", "./", "${HOME}/","${PWD}/",
|
||||
#define EV_VID_UPD 7
|
||||
|
||||
extern int g_stepping;
|
||||
extern int g_dbg_step;
|
||||
|
||||
|
||||
extern int g_c068_statereg;
|
||||
extern int g_cur_a2_stat;
|
||||
@ -114,6 +115,7 @@ extern int g_config_control_panel;
|
||||
|
||||
extern int g_audio_enable;
|
||||
extern int g_preferred_rate;
|
||||
extern int g_dbg_enable_port;
|
||||
|
||||
void U_STACK_TRACE();
|
||||
|
||||
@ -159,7 +161,7 @@ int g_imagewriter_paper = 0;
|
||||
int g_imagewriter_banner = 0;
|
||||
|
||||
int g_config_iwm_vbl_count = 0;
|
||||
const char g_gsplus_version_str[] = "0.10a";
|
||||
const char g_gsplus_version_str[] = "0.12s"; // 12 socket debug
|
||||
int g_pause=0; // OG Added pause
|
||||
|
||||
#define START_DCYCS (0.0)
|
||||
@ -242,7 +244,6 @@ Data_log *g_log_data_end_ptr = &(g_data_log_array[PC_LOG_LEN]);
|
||||
// OG Added sim65816_initglobals()
|
||||
void sim65816_initglobals()
|
||||
{
|
||||
|
||||
g_fcycles_stop = 0.0;
|
||||
halt_sim = 0;
|
||||
enter_debug = 0;
|
||||
@ -788,6 +789,7 @@ do_reset()
|
||||
engine.kpc = get_memory16_c(0x00fffc, 0);
|
||||
|
||||
g_stepping = 0;
|
||||
g_dbg_step = 0;
|
||||
|
||||
if (g_irq_pending)
|
||||
halt_printf("*** irq remainings...\n");
|
||||
@ -1047,7 +1049,14 @@ gsplusmain(int argc, char **argv)
|
||||
g_config_gsplus_name_list[0] = argv[i+1]; // super dangerous ?
|
||||
g_config_gsplus_name_list[1] = 0; // terminate string array
|
||||
i++;
|
||||
|
||||
} else if(!strcmp("-debugport", argv[i])) { // Debug port passed
|
||||
if((i+1) >= argc) {
|
||||
printf("Missing argument\n");
|
||||
exit(1);
|
||||
}
|
||||
g_dbg_enable_port = strtol(argv[i+1], 0, 0);
|
||||
printf("Debug port: %d\n", g_dbg_enable_port);
|
||||
i++;
|
||||
} else {
|
||||
if ((i == (argc - 1)) && (strncmp("-", argv[i], 1) != 0)) {
|
||||
final_arg = argv[i];
|
||||
@ -1088,6 +1097,7 @@ gsplusmain(int argc, char **argv)
|
||||
}
|
||||
|
||||
iwm_init();
|
||||
debug_init(); // enable socket debugger if configured
|
||||
config_init();
|
||||
// If the final argument was not a switch, then treat it like a disk image filename to insert
|
||||
if (final_arg) {
|
||||
@ -1129,6 +1139,7 @@ gsplusmain(int argc, char **argv)
|
||||
init_reg();
|
||||
clear_halt();
|
||||
|
||||
|
||||
initialize_events();
|
||||
|
||||
video_init();
|
||||
@ -1143,15 +1154,20 @@ gsplusmain(int argc, char **argv)
|
||||
|
||||
do_reset();
|
||||
g_stepping = 0;
|
||||
g_dbg_step = 0;
|
||||
|
||||
// OG Notify emulator has been initialized and ready to accept external events
|
||||
g_initialized = 1;
|
||||
g_accept_events = 1;
|
||||
|
||||
// Call one of two main run_prog() routines
|
||||
if (g_dbg_enable_port) {
|
||||
do_go_debug();
|
||||
} else {
|
||||
do_go();
|
||||
|
||||
/* If we get here, we hit a breakpoint, call debug intfc */
|
||||
do_debug_intfc();
|
||||
}
|
||||
|
||||
// OG Notify emulator is being closed, and cannot accept events anymore
|
||||
g_accept_events = 0;
|
||||
@ -1750,7 +1766,7 @@ run_prog()
|
||||
engine.fcycles = prerun_fcycles;
|
||||
fcycles_stop = (g_event_start.next->dcycs - g_last_vbl_dcycs) +
|
||||
0.001;
|
||||
if(g_stepping) {
|
||||
if(g_stepping || g_dbg_step < 0) {
|
||||
fcycles_stop = prerun_fcycles;
|
||||
}
|
||||
g_fcycles_stop = fcycles_stop;
|
||||
@ -1809,6 +1825,13 @@ run_prog()
|
||||
|
||||
this_event = g_event_start.next;
|
||||
while(dcycs >= this_event->dcycs) {
|
||||
if(halt_sim != 0 && halt_sim != HALT_EVENT) {
|
||||
break;
|
||||
}
|
||||
if(g_stepping || g_dbg_step != 0) {
|
||||
printf("HIT STEPPING BREAK!\n");
|
||||
break;
|
||||
}
|
||||
/* Pop this guy off of the queue */
|
||||
g_event_start.next = this_event->next;
|
||||
|
||||
@ -1818,6 +1841,10 @@ run_prog()
|
||||
switch(type & 0xff) {
|
||||
case EV_60HZ:
|
||||
update_60hz(dcycs, now_dtime);
|
||||
debug_server_poll();
|
||||
if (debug_events_waiting() > 0) {
|
||||
debug_handle_event();
|
||||
}
|
||||
break;
|
||||
case EV_STOP:
|
||||
printf("type: EV_STOP\n");
|
||||
@ -1871,7 +1898,7 @@ run_prog()
|
||||
if(halt_sim != 0 && halt_sim != HALT_EVENT) {
|
||||
break;
|
||||
}
|
||||
if(g_stepping) {
|
||||
if(g_stepping || g_dbg_step != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2327,7 +2354,6 @@ update_60hz(double dcycs, double dtime_now)
|
||||
g_dtime_pmhz_array[prev_vbl_index] = predicted_pmhz;
|
||||
g_dtime_eff_pmhz_array[prev_vbl_index] = eff_pmhz;
|
||||
|
||||
|
||||
if(g_c041_val & C041_EN_VBL_INTS) {
|
||||
add_event_vbl();
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ CCOPTS = -O2 -Wall -fomit-frame-pointer -std=gnu99 -DHAVE_ICON -DHAVE_SDL -DTOGG
|
||||
# OPTIONS FOR COMPILING C++ SOURCE
|
||||
CPPOPTS = -O2 -DHAVE_TFE -DHAVE_SDL -DTOGGLE_STATUS -I/usr/local/include/freetype2 -I/usr/local/include/SDL2
|
||||
|
||||
EXTRA_LIBS = -lSDL2 -lfreetype
|
||||
OPTS = -DGSPLUS_LITTLE_ENDIAN
|
||||
EXTRA_LIBS = -lSDL2 -lSDL2_image -lfreetype
|
||||
OPTS = -DGSPLUS_LITTLE_ENDIAN -g -O0
|
||||
SUFFIX =
|
||||
LDFLAGS = `sdl2-config --static-libs` -L/usr/local/lib
|
||||
LDOPTS = -I.
|
||||
|
Loading…
Reference in New Issue
Block a user