Skip to content

Commit

Permalink
drop WITH_DEBUGGER, debugger is always built and embedded
Browse files Browse the repository at this point in the history
  • Loading branch information
gwenhael-le-moine committed Sep 6, 2023
1 parent 5412d63 commit 5205e2c
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 59 deletions.
17 changes: 7 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
# possible values: x11, sdl1
GUI ?= x11

# possible values: yes, no
WITH_DEBUGGER ?= yes

VERSION_MAJOR = 0
VERSION_MINOR = 12
PATCHLEVEL = 1
Expand Down Expand Up @@ -46,13 +43,13 @@ DOTOS = src/main.o \
src/x48_resources.o \
src/x48.o

ifeq ($(WITH_DEBUGGER), yes)
DOTOS += src/debugger.o \
src/debugger_disasm.o \
src/debugger_rpl.o
CFLAGS += $(shell pkg-config --cflags readline) -DWITH_DEBUGGER=1
LIBS += $(shell pkg-config --libs readline)
endif
### debugger
DOTOS += src/debugger.o \
src/debugger_disasm.o \
src/debugger_rpl.o
CFLAGS += $(shell pkg-config --cflags readline)
LIBS += $(shell pkg-config --libs readline)
### /debugger

.PHONY: all clean clean-all pretty-code install

Expand Down
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ See https://github.com/gwenhael-le-moine/x48ng/issues
## What more I would like to do:

1. clean-up further.
- drop use of the `verbose` variable
- use seperate files for x11 and sdl1 specific code
2. split the core emulator in a lib and have the GUI use that to cleanly separate the two.
3. have a more modern GUI in gtk4
4. can something be merged from droid48? [ https://github.com/shagr4th/droid48 ]
Expand All @@ -35,11 +37,6 @@ To build the X11 version run `make GUI=x11`

To build the SDL1 version run `make GUI=sdl1`

### Debugger

Debugger is not built by default.
To build the debugger compile with `make WITH_DEBUGGER=yes`

## Installation

1. Run `sudo make install PREFIX=/usr DOCDIR=/usr/doc/x48ng MANDIR=/usr/man DESTDIR=/tmp/package` filling in your own values for PREFIX, DOCDIR, MANDIR and DESTDIR.
Expand Down
10 changes: 0 additions & 10 deletions src/hp48_emulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
#include "timer.h"
#include "x48.h"

#if defined( WITH_DEBUGGER )
#include "debugger.h" /* enter_debugger, TRAP_INSTRUCTION, ILLEGAL_INSTRUCTION */
#endif

extern int throttle;

Expand Down Expand Up @@ -2198,9 +2196,7 @@ inline int step_instruction( void ) {
op3 = read_nibbles( saturn.PC + 4, 1 );
saturn.PC += 5;
if ( op3 != 0 ) {
#if defined( WITH_DEBUGGER )
enter_debugger |= TRAP_INSTRUCTION;
#endif
return 1;
}
} else {
Expand All @@ -2224,10 +2220,8 @@ inline int step_instruction( void ) {
}
instructions++;

#if defined( WITH_DEBUGGER )
if ( stop )
enter_debugger |= ILLEGAL_INSTRUCTION;
#endif

return stop;
}
Expand Down Expand Up @@ -2438,10 +2432,6 @@ void emulate( void ) {
if ( schedule_event-- <= 0 )
schedule();
} while (
#if defined( WITH_DEBUGGER )
!enter_debugger
#else
1
#endif
);
}
6 changes: 0 additions & 6 deletions src/hp48emu_actions.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
#include "timer.h"
#include "x48.h"

#if defined( WITH_DEBUGGER )
#include "debugger.h" /* in_debugger, enter_debugger */
#endif

static int interrupt_called = 0;
extern long nibble_masks[ 16 ];
Expand Down Expand Up @@ -275,11 +273,9 @@ void do_shutdown( void ) {
saturn.int_pending = 0;
}

#if defined( WITH_DEBUGGER )
if ( in_debugger )
wake = 1;
else
#endif
wake = 0;

alarms = 0;
Expand Down Expand Up @@ -340,10 +336,8 @@ void do_shutdown( void ) {
alarms++;
}

#if defined( WITH_DEBUGGER )
if ( enter_debugger )
wake = 1;
#endif
} while ( wake == 0 );

stop_timer( IDLE_TIMER );
Expand Down
10 changes: 0 additions & 10 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
#include "x48.h"
#include "x48_resources.h"

#if defined( WITH_DEBUGGER )
#include "debugger.h" /* enter_debugger, USER_INTERRUPT, exec_flags, emulate_debug, debug */
#endif

#if defined( GUI_IS_X11 )
char* progname;
Expand All @@ -26,11 +24,9 @@ char** saved_argv;

void signal_handler( int sig ) {
switch ( sig ) {
#if defined( WITH_DEBUGGER )
case SIGINT: /* Ctrl-C */
enter_debugger |= USER_INTERRUPT;
break;
#endif
case SIGALRM:
got_alarm = 1;
break;
Expand Down Expand Up @@ -112,7 +108,6 @@ int main( int argc, char** argv ) {
#endif
sigaction( SIGALRM, &sa, ( struct sigaction* )0 );

#if defined( WITH_DEBUGGER )
sigemptyset( &set );
sigaddset( &set, SIGINT );
sa.sa_handler = signal_handler;
Expand All @@ -121,7 +116,6 @@ int main( int argc, char** argv ) {
sa.sa_flags = SA_RESTART;
#endif
sigaction( SIGINT, &sa, ( struct sigaction* )0 );
#endif

sigemptyset( &set );
sigaddset( &set, SIGPIPE );
Expand Down Expand Up @@ -156,16 +150,12 @@ int main( int argc, char** argv ) {
/* Start emulation loop */
/************************/
do {
#if defined( WITH_DEBUGGER )
if ( !exec_flags )
#endif
emulate();
#if defined( WITH_DEBUGGER )
else
emulate_debug();

debug();
#endif
} while ( 1 );

return 0;
Expand Down
4 changes: 0 additions & 4 deletions src/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,11 +317,7 @@ t1_t2_ticks get_t1_t2( void ) {

access_time -= stop;

#if defined( WITH_DEBUGGER )
if ( adj_time_pending || in_debugger ) {
#else
if ( adj_time_pending ) {
#endif
/*
* We have been inside an interrupt for very long, maybe
* or we are sleeping in the debugger.
Expand Down
8 changes: 3 additions & 5 deletions src/x48.c
Original file line number Diff line number Diff line change
Expand Up @@ -6389,14 +6389,12 @@ int get_ui_event( void ) {
}
}
}
#if defined( WITH_DEBUGGER )
else if ( xev.xbutton.button == Button3 ) {
/* TODO Make cut from the screen work. */
get_stack();
} else {
/* printf("In display %d\n", xev.xbutton.button); */
}
#endif
} /* else {
printf("In display %d\n", xev.xbutton.button);
} */
} else {
if ( xev.xbutton.button == Button1 ||
xev.xbutton.button == Button2 ||
Expand Down
9 changes: 0 additions & 9 deletions src/x48_resources.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@
#include "x48_errors.h"
#include "x48_resources.h"

#if defined( WITH_DEBUGGER )
#include "debugger.h" /* `disassembler_mode` & `CLASS_MNEMONICS` */
#else
#define HP_MNEMONICS 0
#define CLASS_MNEMONICS 1
#endif

int verbose;
int useTerminal;
Expand Down Expand Up @@ -369,10 +364,8 @@ void get_resources( void ) {
useSerial = 0;
initialize = 0;
resetOnStartup = 0;
#if defined( WITH_DEBUGGER )
useDebugger = 1;
disassembler_mode = CLASS_MNEMONICS; // HP_MNEMONICS
#endif
netbook = 0;
throttle = 0;

Expand All @@ -398,11 +391,9 @@ void get_resources( void ) {
romFileName = get_string_resource( "romFileName", "RomFileName" );
homeDirectory = get_string_resource( "homeDirectory", "HomeDirectory" );

#if defined( WITH_DEBUGGER )
useDebugger = get_boolean_resource( "useDebugger", "UseDebugger" );
disassembler_mode = get_mnemonic_resource( "disassemblerMnemonics",
"DisassemblerMnemonics" );
#endif

netbook = get_boolean_resource( "netbook", "Netbook" );

Expand Down

0 comments on commit 5205e2c

Please sign in to comment.