From 97da416cbd45c7b8b2d5359a0fea92c43ed64886 Mon Sep 17 00:00:00 2001 From: Gwenhael Le Moine Date: Sun, 30 Apr 2023 18:16:13 +0200 Subject: [PATCH] x48ng 0.9.9 --- .gitignore | 80 +--------------------- ChangeLog => ChangeLog.from_0.4.0_to_0.6.4 | 0 INSTALL | 9 --- Makefile | 65 ++++++++++-------- README.md | 39 +++++++++++ README => README_0.6.4 | 0 X48.ad => X48NG.ad | 2 +- doc/CARDS.doc | 5 +- setup-home.sh | 6 -- setup-x48ng-home.sh | 7 ++ src/{X48.ad.h => X48NG.ad.h} | 2 +- src/config.h | 4 +- src/main.c | 4 +- src/options.c | 13 ++-- src/resources.c | 3 +- src/x48_gui.c | 5 +- x48.desktop => x48ng.desktop | 4 +- x48.man.1 => x48ng.man.1 | 0 18 files changed, 103 insertions(+), 145 deletions(-) rename ChangeLog => ChangeLog.from_0.4.0_to_0.6.4 (100%) delete mode 100644 INSTALL create mode 100644 README.md rename README => README_0.6.4 (100%) rename X48.ad => X48NG.ad (97%) delete mode 100644 setup-home.sh create mode 100644 setup-x48ng-home.sh rename src/{X48.ad.h => X48NG.ad.h} (92%) rename x48.desktop => x48ng.desktop (59%) rename x48.man.1 => x48ng.man.1 (100%) diff --git a/.gitignore b/.gitignore index 9a9c055..356fcfa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,82 +1,6 @@ -Makefile.in -aclocal.m4 -autom4te.cache/ -compile -config.guess -config.h.in -config.sub -configure -depcomp -install-sh -members -missing -romdump/Makefile.in -src/Makefile.in - -# gwh 2022-03-24 -Makefile -X48 -config.h -config.log -config.status -romdump/ -romdump/Makefile -rpm/ -rpm/x48.spec -src/.deps/ -src/.deps/actions.Po -src/.deps/checkrom.Po -src/.deps/debugger.Po -src/.deps/device.Po -src/.deps/disasm.Po -src/.deps/dump2rom.Po -src/.deps/emulate.Po -src/.deps/errors.Po -src/.deps/init.Po -src/.deps/lcd.Po -src/.deps/main.Po -src/.deps/memory.Po -src/.deps/mkcard.Po -src/.deps/options.Po -src/.deps/register.Po -src/.deps/resources.Po -src/.deps/romio.Po -src/.deps/rpl.Po -src/.deps/serial.Po -src/.deps/timer.Po -src/.deps/x48_x11.Po -src/ -src/Makefile -src/actions.o -src/checkrom -src/checkrom.o -src/debugger.o -src/device.o -src/disasm.o -src/dump2rom -src/dump2rom.o -src/emulate.o -src/errors.o -src/init.o -src/lcd.o -src/main.o -src/memory.o -src/mkcard -src/mkcard.o -src/options.o -src/register.o -src/resources.o -src/romio.o -src/rpl.o -src/serial.o -src/timer.o -src/x48 -src/x48.man -src/x48_x11.o -stamp-h1 - +src/*.o checkrom dump2rom mkcard -x48 +x48ng diff --git a/ChangeLog b/ChangeLog.from_0.4.0_to_0.6.4 similarity index 100% rename from ChangeLog rename to ChangeLog.from_0.4.0_to_0.6.4 diff --git a/INSTALL b/INSTALL deleted file mode 100644 index 7c3fad5..0000000 --- a/INSTALL +++ /dev/null @@ -1,9 +0,0 @@ - -You will only need readline support if you are planning to use the -x48 debugger. So ignore - - With ReadLine sup. in Debuger? no - -unless you want readline support in the x48 debugger. - - diff --git a/Makefile b/Makefile index 047b88b..989ef85 100644 --- a/Makefile +++ b/Makefile @@ -1,23 +1,30 @@ -# Makefile to build x48 without autotools +# Makefile to build x48ng without autotools CC = gcc -GUI_IS_X11 = 1 -#GUI_IS_SDL1 = 1 - -CFLAGS = -g -O2 #-Wall -Wextra -Wno-unused-parameter -Wno-unused-function -Wconversion -Wdouble-promotion -Wno-sign-conversion -fsanitize=undefined -fsanitize-trap +CFLAGS = -g -O2 LIBS = -lm -lhistory -lreadline -ifdef GUI_IS_X11 +#possible values: x11, sdl1 +GUI = x11 + +ifeq ($(GUI), x11) CFLAGS += -D 'GUI_IS_X11 = 1' LIBS += -lX11 -lXext endif -ifdef GUI_IS_SDL1 +ifeq ($(GUI), sdl1) CFLAGS += $(shell pkg-config --cflags SDL_gfx readline sdl12_compat) -D 'GUI_IS_SDL1 = 1' LIBS += $(shell pkg-config --libs SDL_gfx readline sdl12_compat) endif -all: mkcard checkrom dump2rom x48 +FULL_WARNINGS = no +ifeq ($(FULL_WARNINGS), yes) + CFLAGS += -Wall -Wextra -Wno-unused-parameter -Wno-unused-function -Wconversion -Wdouble-promotion -Wno-sign-conversion -fsanitize=undefined -fsanitize-trap +endif + +.PHONY: all clean clean-all pretty-code install + +all: mkcard checkrom dump2rom x48ng # Binaries mkcard: src/mkcard.o @@ -29,7 +36,7 @@ dump2rom: src/dump2rom.o checkrom: src/checkrom.o src/romio.o $(CC) $(CFLAGS) $(LIBS) $^ -o $@ -x48: src/main.o src/actions.o src/debugger.o src/device.o src/disasm.o src/emulate.o src/errors.o src/init.o src/lcd.o src/memory.o src/register.o src/resources.o src/romio.o src/rpl.o src/serial.o src/timer.o src/x48_gui.o src/options.o src/resources.o +x48ng: src/main.o src/actions.o src/debugger.o src/device.o src/disasm.o src/emulate.o src/errors.o src/init.o src/lcd.o src/memory.o src/register.o src/resources.o src/romio.o src/rpl.o src/serial.o src/timer.o src/x48_gui.o src/options.o src/resources.o $(CC) $(CFLAGS) $(LIBS) $^ -o $@ # Cleaning @@ -37,7 +44,7 @@ clean: rm -f src/*.o clean-all: clean - rm -f x48 mkcard checkrom dump2rom + rm -f x48ng mkcard checkrom dump2rom # Formatting pretty-code: @@ -45,31 +52,31 @@ pretty-code: # Installing PREFIX = /usr -DOCDIR = $(PREFIX)/doc/x48 -MANDIR = $(PREFIX)/man/man1 +DOCDIR = $(PREFIX)/doc/x48ng +MANDIR = $(PREFIX)/man install: all install -m 755 -d -- $(DESTDIR)$(PREFIX)/bin - install -c -m 755 x48 $(DESTDIR)$(PREFIX)/bin/x48 + install -c -m 755 x48ng $(DESTDIR)$(PREFIX)/bin/x48ng - install -m 755 -d -- $(DESTDIR)$(PREFIX)/share/x48 - install -c -m 755 mkcard $(DESTDIR)$(PREFIX)/share/x48/mkcard - install -c -m 755 dump2rom $(DESTDIR)$(PREFIX)/share/x48/dump2rom - install -c -m 755 checkrom $(DESTDIR)$(PREFIX)/share/x48/checkrom - install -c -m 644 hplogo.png $(DESTDIR)$(PREFIX)/share/x48/hplogo.png - cp -R ROMs/ $(DESTDIR)$(PREFIX)/share/x48/ - find $(DESTDIR)$(PREFIX)/share/x48/ROMs/ -name "*.bz2" -exec bunzip2 {} \; - sed "s|PREFIX|$(PREFIX)|g" setup-home.sh > $(DESTDIR)$(PREFIX)/share/x48/setup-x48-home.sh - chmod 755 $(DESTDIR)$(PREFIX)/share/x48/setup-x48-home.sh + install -m 755 -d -- $(DESTDIR)$(PREFIX)/share/x48ng + install -c -m 755 mkcard $(DESTDIR)$(PREFIX)/share/x48ng/mkcard + install -c -m 755 dump2rom $(DESTDIR)$(PREFIX)/share/x48ng/dump2rom + install -c -m 755 checkrom $(DESTDIR)$(PREFIX)/share/x48ng/checkrom + install -c -m 644 hplogo.png $(DESTDIR)$(PREFIX)/share/x48ng/hplogo.png + cp -R ROMs/ $(DESTDIR)$(PREFIX)/share/x48ng/ + find $(DESTDIR)$(PREFIX)/share/x48ng/ROMs/ -name "*.bz2" -exec bunzip2 {} \; + sed "s|@PREFIX@|$(PREFIX)|g" setup-x48ng-home.sh > $(DESTDIR)$(PREFIX)/share/x48ng/setup-x48ng-home.sh + chmod 755 $(DESTDIR)$(PREFIX)/share/x48ng/setup-x48ng-home.sh - install -m 755 -d -- $(DESTDIR)$(MANDIR) - install -c -m 644 x48.man.1 $(DESTDIR)$(MANDIR)/x48.1 - gzip -9 $(DESTDIR)$(MANDIR)/x48.1 + install -m 755 -d -- $(DESTDIR)$(MANDIR)/man1 + install -c -m 644 x48ng.man.1 $(DESTDIR)$(MANDIR)/man1/x48ng.1 + gzip -9 $(DESTDIR)$(MANDIR)/man1/x48ng.1 install -m 755 -d -- $(DESTDIR)$(DOCDIR) - cp -R AUTHORS COPYING ChangeLog INSTALL LICENSE README doc/ romdump/ $(DESTDIR)$(DOCDIR) + cp -R AUTHORS COPYING ChangeLog* LICENSE README* doc/ romdump/ $(DESTDIR)$(DOCDIR) install -m 755 -d -- $(DESTDIR)$(PREFIX)/share/applications - sed "s|PREFIX|$(PREFIX)|g" x48.desktop > $(DESTDIR)$(PREFIX)/share/applications/x48.desktop + sed "s|@PREFIX@|$(PREFIX)|g" x48ng.desktop > $(DESTDIR)$(PREFIX)/share/applications/x48ng.desktop - install 0m 755 -d -- $(DESTDIR)/etc/X11/app-defaults - install -c -m 644 X48.ad $(DESTDIR)/etc/X11/app-defaults/X48 + install -m 755 -d -- $(DESTDIR)/etc/X11/app-defaults + install -c -m 644 X48NG.ad $(DESTDIR)/etc/X11/app-defaults/X48NG diff --git a/README.md b/README.md new file mode 100644 index 0000000..e92fa12 --- /dev/null +++ b/README.md @@ -0,0 +1,39 @@ +# x48ng -- HP48 CPU emulator + +(I'm not very good at writing, see ./README_0.6.4 for the original README) + +This is my fork of x48-0.6.4 where I deviate from the original code and do my own thing. + +## What have I done: + +1. merged in a SDL1 version I found @ https://code.google.com/archive/p/x48-sdl/source/default/source +2. removed the code supporting Solaris, HP-UX, etc. +3. removed the autotools-based build system and wrote a simple Makefile instead +4. added a x48.desktop file and an icon + +## What more I would like to do: + +1. clean-up further. +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: SDL2 or gosu or?… +4. support the HP49g ROM? + +## Compilation + +By default the X11 version is built. + +To build the X11 version run `make GUI=x11` + +To build the SDL1 version run `make GUI=sdl1` + +## 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. +2. once installed run `/usr/share/x48/setup-x48-home.sh` to setup your ~/.x48ng/. It sets up a HP 48GX with a 128KB card in port 1 and a 4MB card in port 2 +3. run `x48ng` and enjoy + +## Development + +- `make FULL_WARNINGS=yes` to compile with all warnings +- `make clean` and `make clean-all` to clean between compilation runs +- `make pretty-code` to format the code using `clang-format` and the provided `.clang-format` diff --git a/README b/README_0.6.4 similarity index 100% rename from README rename to README_0.6.4 diff --git a/X48.ad b/X48NG.ad similarity index 97% rename from X48.ad rename to X48NG.ad index 6ad64c1..c20be96 100644 --- a/X48.ad +++ b/X48NG.ad @@ -37,7 +37,7 @@ *completeInitialize: False *resetOnStartup: False *romFileName: rom.dump -*homeDirectory: .hp48 +*homeDirectory: .x48ng ! ! resources controlling the debugger diff --git a/doc/CARDS.doc b/doc/CARDS.doc index 09b0b79..51842d9 100644 --- a/doc/CARDS.doc +++ b/doc/CARDS.doc @@ -6,11 +6,10 @@ A: Well, I guess you would have to use some sort of Card copying You should convert it into an x48 rom-file. Look at dump2rom.c. There should be changes for the size of the Card!!! - Then you should copy this to "$HOME/.hp48/port1" or "$HOME/.hp48/port2". + Then you should copy this to "$HOME/.x48ng/port1" or "$HOME/.x48ng/port2". - Change the file to read only, use 'chmod 444 $HOME/.hp48/port1'. + Change the file to read only, use 'chmod 444 $HOME/.x48ng/port1'. The emulator will notice, this is a ROM. You are mainly on your own here, I don't have such a card, so I can't try, but I hope it helps. - diff --git a/setup-home.sh b/setup-home.sh deleted file mode 100644 index 5cf305c..0000000 --- a/setup-home.sh +++ /dev/null @@ -1,6 +0,0 @@ -mkdir ~/.hp48 -cp PREFIX/share/x48/ROMs/gxrom-r ~/.hp48/rom.dump -cd ~/.hp48 -PREFIX/share/x48/mkcard 128K port1 -PREFIX/share/x48/mkcard 4M port2 -x48 -initialize diff --git a/setup-x48ng-home.sh b/setup-x48ng-home.sh new file mode 100644 index 0000000..4fee7aa --- /dev/null +++ b/setup-x48ng-home.sh @@ -0,0 +1,7 @@ +mkdir ~/.x48ng +cp @PREFIX@/share/x48/ROMs/gxrom-r ~/.x48ng/rom +cp ~/.x48ng/rom ~/.x48ng/rom.dump +cd ~/.x48ng +@PREFIX@/share/x48/mkcard 128K port1 +@PREFIX@/share/x48/mkcard 4M port2 +x48 -initialize diff --git a/src/X48.ad.h b/src/X48NG.ad.h similarity index 92% rename from src/X48.ad.h rename to src/X48NG.ad.h index eeb10cb..9e4865e 100644 --- a/src/X48.ad.h +++ b/src/X48NG.ad.h @@ -10,5 +10,5 @@ "*printWarranty: False", "*useTerminal: True", "*useSerial: False", "*serialLine: /dev/ttyS0", "*completeInitialize: False", "*resetOnStartup: False", - "*romFileName: rom.dump", "*homeDirectory: .hp48", + "*romFileName: rom.dump", "*homeDirectory: .x48ng", "*useDebugger: True", "*disassemblerMnemonics: class", diff --git a/src/config.h b/src/config.h index d1fb04e..40a501e 100644 --- a/src/config.h +++ b/src/config.h @@ -2,10 +2,10 @@ #define VERSION_MAJOR 0 /* The minor version number */ -#define VERSION_MINOR 6 +#define VERSION_MINOR 9 /* The patch level */ -#define PATCHLEVEL 4 +#define PATCHLEVEL 9 /* description */ #define COMPILE_VERSION 0 diff --git a/src/main.c b/src/main.c index 836dac3..acf3947 100644 --- a/src/main.c +++ b/src/main.c @@ -76,7 +76,7 @@ const char* errinit_text[] = { "", " ram: ram file", " hp48: HP state file", "", - "These files must be in ~/.hp48", + "These files must be in ~/.x48ng", "", "Install these files and try again.", 0 }; @@ -91,7 +91,7 @@ int main( int argc, char** argv ) { int rv, i; /* unsigned t1, t2; */ - printf( "x48-sdl\n" ); + printf( "x48ng\n" ); // SDL Initialization SDLInit(); diff --git a/src/options.c b/src/options.c index cd0b9f3..c82a703 100644 --- a/src/options.c +++ b/src/options.c @@ -10,7 +10,7 @@ void usage( void ) { fprintf( stdout, "\n\ -x48 Version %d.%d.%d, Copyright (c) 1994-2005 by Eddie C. Dost .\n\ +%s Version %d.%d.%d\n\ \n\ usage:\n\t%s [-options ...]\n\ \n\ @@ -42,14 +42,14 @@ where options include:\n\ -/+debug turn on/off debugger\n\ -disasm use (\'HP\' or \'class\') mnemonics\n\ -reset perform a reset (PC = 0) on startup\n\ - -initialize force initialization x48 from ROM-dump\n\ + -initialize force initialization x48ng from ROM-dump\n\ -rom if initializing, read ROM from \n\ - -home use directory ~/ to save x48 files\n\ + -home use directory ~/ to save x48ng files\n\ -xrm set Xresource \n\ -/+throttle turn off/on speed emulation\n\ -/+netbook turn off/on netbook layout\n\ \n", - VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL, progname ); + progname, VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL, progname ); fflush( stdout ); exit( 1 ); @@ -57,7 +57,7 @@ where options include:\n\ void show_version( void ) { fprintf( stdout, "\n\ -%s Version %d.%d.%d, x48 is Copyright (c) 1994-2005 by Eddie C. Dost .\n\n", +%s Version %d.%d.%d", progname, VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL ); } @@ -65,8 +65,7 @@ void show_copyright( void ) { fprintf( stdout, "\n\ COPYRIGHT\n\ \n\ -X48 is an Emulator/Debugger for the HP-48 Handheld Calculator.\n\ -Copyright (C) 1994 by Eddie C. Dost .\n\ +x48ng is an Emulator/Debugger for the HP-48 Handheld Calculator.\n\ \n\ This program is free software; you can redistribute it and/or modify\n\ it under the terms of the GNU General Public License as published by\n\ diff --git a/src/resources.c b/src/resources.c index 366b086..aac853b 100644 --- a/src/resources.c +++ b/src/resources.c @@ -326,7 +326,7 @@ void get_resources( // homeDirectory // Have homeDirectory in the user's home - strcpy( homeDirectory, ".hp48" ); // live files are stored in ~/.hp48 + strcpy( homeDirectory, ".x48ng" ); // live files are stored in ~/.x48ng // As a fallback, assume that a ROM will be available at the same location // as the executable We assume that the rom file is in the same @@ -357,4 +357,3 @@ void get_resources( throttle = 0; } #endif - diff --git a/src/x48_gui.c b/src/x48_gui.c index 29636b8..c765f62 100644 --- a/src/x48_gui.c +++ b/src/x48_gui.c @@ -33,7 +33,7 @@ #ifdef GUI_IS_X11 static char* defaults[] = { -#include "X48.ad.h" +#include "X48NG.ad.h" 0 }; #ifdef HAVE_XSHM @@ -7222,7 +7222,7 @@ void SDLShowInformation() { " port1: card 1 memory", " port2: card 2 memory", "", - "These files must be in ~/.hp48", + "These files must be in ~/.x48ng", "", 0 }; SDLMessageBox( 310, 280, info_title, info_text, 0xf0c0c0e0, 0xff000000, 0 ); @@ -7244,4 +7244,3 @@ void SDLShowInformation() { 0 ); } #endif - diff --git a/x48.desktop b/x48ng.desktop similarity index 59% rename from x48.desktop rename to x48ng.desktop index 3c30a0a..d08c7ba 100644 --- a/x48.desktop +++ b/x48ng.desktop @@ -3,6 +3,6 @@ Encoding=UTF-8 Version=1.0 Type=Application Terminal=false -Exec=PREFIX/bin/x48 +Exec=@PREFIX@/bin/x48 Name=x48 -Icon=PREFIX/share/x48/hplogo.png +Icon=@PREFIX@/share/x48/hplogo.png diff --git a/x48.man.1 b/x48ng.man.1 similarity index 100% rename from x48.man.1 rename to x48ng.man.1