From 7670442d0480c2c210316b5d5dcea7bb7f817f56 Mon Sep 17 00:00:00 2001
From: mike632t <1799044+mike632t@users.noreply.github.com>
Date: Sun, 12 May 2024 23:38:06 +0100
Subject: [PATCH 01/14] Use a separate makefile for MacOS
---
makefile | 3 ++-
src/makefile | 5 +++--
src/makefile.bsd | 7 +------
src/makefile.darwin | 46 +++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 52 insertions(+), 9 deletions(-)
create mode 100644 src/makefile.darwin
diff --git a/makefile b/makefile
index 86ba08b..9ea5f0a 100644
--- a/makefile
+++ b/makefile
@@ -103,6 +103,7 @@
# same common files. Make is still parallelizing
# submakes calls which do the real work. - macmpi
# 29 Apr 24 - Improve parallel make performance - macmpi
+# 12 May 24 - Use a separate makefile for MacOS - MT
#
PROGRAM = x11-calc
@@ -115,7 +116,7 @@ IMG = img
# Files to be backed up (and the current date).
-_files = `ls makefile makefile.*.[0-9] $(SRC)/makefile $(SRC)/makefile.all $(SRC)/makefile.linux $(SRC)/makefile.bsd $(SRC)/makefile.osf1 $(SRC)/makefile.*.[0-9] 2>/dev/null || true`
+_files = `ls makefile makefile.*.[0-9] $(SRC)/makefile $(SRC)/makefile.all $(SRC)/makefile.linux $(SRC)/makefile.darwin $(SRC)/makefile.bsd $(SRC)/makefile.osf1 $(SRC)/makefile.*.[0-9] 2>/dev/null || true`
_source = `ls $(SRC)/*.c $(SRC)/*.c.[0-9] $(SRC)/*.h $(SRC)/*.h.[0-9] $(SRC)/*.in $(SRC)/*.in.[0-9] 2>/dev/null || true`
_data = `ls $(ROM)/$(PROGRAM)*.rom $(ROM)/$(PROGRAM)*.rom.[0-9] $(PRG)/$(PROGRAM)*.dat $(PRG)/$(PROGRAM)*.dat.[0-9] 2>/dev/null || true`
_images = `ls $(SRC)/*.ico $(SRC)/*.ico.[0-9] $(SRC)/*.png $(SRC)/*.png.[0-9] $(SRC)/*.svg $(SRC)/*.svg.[0-9] $(IMG)/*.png $(IMG)/*.png.[0-9] 2>/dev/null || true`
diff --git a/src/makefile b/src/makefile
index 4d0d04d..6eb35ca 100644
--- a/src/makefile
+++ b/src/makefile
@@ -24,16 +24,17 @@
# Linux (now we can get rid of make.sh) - MT
# 24 Mar 24 - Pass model number - MT
# 29 Mar 24 - Use linux/bsd/osf1 makefiles -macmpi
+# 12 May 24 - Use a separate makefile for MacOS - MT
#
MODEL = 21
all:
@_os="`uname -s | tr '[:upper:]' '[:lower:]'`"; \
- echo "$$_os" | grep -qwE "freebsd|netbsd|darwin" && _os=bsd; \
+ echo "$$_os" | grep -qwE "freebsd|netbsd" && _os=bsd; \
$(MAKE) -s -f "makefile.$$_os" MODEL=$(MODEL) $@
.DEFAULT:
@_os="`uname -s | tr '[:upper:]' '[:lower:]'`"; \
- echo "$$_os" | grep -qwE "freebsd|netbsd|darwin" && _os=bsd; \
+ echo "$$_os" | grep -qwE "freebsd|netbsd" && _os=bsd; \
$(MAKE) -s -f "makefile.$$_os" MODEL=$(MODEL) $@
diff --git a/src/makefile.bsd b/src/makefile.bsd
index b033f18..4b007df 100644
--- a/src/makefile.bsd
+++ b/src/makefile.bsd
@@ -26,6 +26,7 @@
#
# 28 Mar 24 - Initial version - macmpi
# 06 May 24 - Fixed include path for Darwin - MT
+# 12 May 24 - Use a separate makefile for MacOS - MT
#
CFLAGS ?=
@@ -51,10 +52,4 @@ CFLAGS += -I/usr/X11R7/include/
LDFLAGS += -L/usr/X11R7/lib/ -R /usr/X11R7/lib
.endif
-.if ${OS} == "Darwin" # MacOS
-LANG = LANG_en
-CFLAGS += -I/opt/X11/include/
-LDFLAGS += -L/opt/X11/lib/
-.endif
-
include makefile.all
diff --git a/src/makefile.darwin b/src/makefile.darwin
new file mode 100644
index 0000000..be552c0
--- /dev/null
+++ b/src/makefile.darwin
@@ -0,0 +1,46 @@
+#
+# makefile - RPN (Reverse Polish) calculator simulator.
+#
+# Copyright(C) 2019 - MT
+#
+# makefile.
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation, either version 3 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see .
+#
+# Note seperator (tab) at the beginning of the line CANNOT be a space..!
+#
+# https://stackoverflow.com/questions/50941196/
+#
+# https://www.gnu.org/software/make/manual/html_node/Prerequisite-Types.html
+#
+# 12 May 13 - Initial version - MT
+#
+
+CFLAGS += -I/opt/X11/include/
+LDFLAGS += -L/opt/X11/lib/
+LDLIBS ?=
+
+LANG = LANG_en
+
+ifneq ($(COMMIT),)
+CFLAGS += -DCOMMIT_ID='"[Commit Id : $(COMMIT)]"'
+endif
+ifneq ($(SCALE_WIDTH),)
+CFLAGS += -DSCALE_WIDTH=$(SCALE_WIDTH)
+endif
+ifneq ($(SCALE_HEIGHT),)
+CFLAGS += -DSCALE_HEIGHT=$(SCALE_HEIGHT)
+endif
+
+include makefile.all
From 6b4a41c0bd42ac98b6d649db72ab3eb4ce426cb5 Mon Sep 17 00:00:00 2001
From: mike632t <1799044+mike632t@users.noreply.github.com>
Date: Sun, 12 May 2024 23:42:32 +0100
Subject: [PATCH 02/14] Updated comments
---
src/makefile.darwin | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/makefile.darwin b/src/makefile.darwin
index be552c0..128c7a1 100644
--- a/src/makefile.darwin
+++ b/src/makefile.darwin
@@ -3,7 +3,7 @@
#
# Copyright(C) 2019 - MT
#
-# makefile.
+# makefile.darwin
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
@@ -24,7 +24,7 @@
#
# https://www.gnu.org/software/make/manual/html_node/Prerequisite-Types.html
#
-# 12 May 13 - Initial version - MT
+# 12 May 24 - Initial version - MT
#
CFLAGS += -I/opt/X11/include/
From be92fed8d805c12fcff770b080feeee3ae96369e Mon Sep 17 00:00:00 2001
From: mike632t <1799044+mike632t@users.noreply.github.com>
Date: Sat, 18 May 2024 22:20:58 +0100
Subject: [PATCH 03/14] Updated README
---
README.md | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/README.md b/README.md
index e97aadc..4fa8025 100644
--- a/README.md
+++ b/README.md
@@ -385,10 +385,6 @@ pre-compiled binary package from [Flathub](https://flathub.org/apps/io.github.mi
- Keyboard test is successful but these models do not pass the self-test.
-##### HP 29C
-
-- All 30 registers have continuous memory.
-
##### HP 37E
- Fails self-test.
@@ -426,21 +422,23 @@ on Xwayland the window manager does not handle this correctly.
### Acknowledgements [Back to Top](#top)
There are almost certainly some names I've missed off this list but without
-the help and encouragement from a multiple it is unlikely that this project
-would have happened at all or that it would got as far as it has.
+the help and encouragement from several members of the calculator community
+it is unlikely that this project would have happened at all or that I would
+have managed to get as far as I have.
-- `Teenix` for convincing me that it was possible in the first place and help
-since (at least I think I glad he did).
+- `Teenix` for convincing me that it was possible in the first place.
-- `Teenix/Panamatik` for their excellent simulators from which I was able to
-figure out most of what should happen when each instruction is executed.
+- `Teenix` and `Panamatik` for their excellent simulators from which I was able
+to figure out most of what should happen when each instruction is executed.
- `Agarza` for providing the details of the voyager displays.
-- `Macmpi` for completely rewriting the makefiles creating a Flatpak package the simulator
-for Flatpak and for packaging and testing the simulators on Alpine Linux.
+- `Macmpi` for completely rewriting the makefiles and packaging the simulator
+for Flatpak.
+
+- `Macmpi` for packaging and testing the simulators on Alpine Linux
-- `Agarza/Martin HEPPERLE` for translating the help text.
+- `Agarza` and `Martin HEPPERLE` for translating the help text.
- `Brouhaha` for taking the time to explain the workings of various models.
From 67eb9f619006058fc9ca311afe4dd5e6e286cad8 Mon Sep 17 00:00:00 2001
From: mike632t <1799044+mike632t@users.noreply.github.com>
Date: Sat, 18 May 2024 23:40:55 +0100
Subject: [PATCH 04/14] Updated README
---
README.md | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index 4fa8025..4f1c1f3 100644
--- a/README.md
+++ b/README.md
@@ -158,11 +158,11 @@ If you install the simulator on most modern desktops it should create a new
menu entry that will start the launcher script by default. When invoked for
the first time this will prompt you to select the default simulator as well
as any additional command line options. These selections will be saved and
-used in future.
+the selected simulator will become the new default.
-On some desktop environments it is also possible to right click on the menu
-icon which will display a sub-menu that will allow you to select a specific
-model directly as well as change the default model and options.
+When using some desktop environments (like GNOME and KDE) it is possible to
+access a sub-menu that will allow you to select a specific model as well as
+change the default settings by right clicking on the menu icon.
#### Keyboard Shortcuts
@@ -218,6 +218,12 @@ For models with a 'sliding' On/Off switch clicking on the switch will turn
the simulator on or off, but if when switching off you hold down the switch
down for two seconds the program will exit.
+#### Window Size
+
+The size of the simulator window can be adjusted from the command line with
+the `--zoom ZOOM` option, where the value for ZOOM can be in the range zero
+to four (0-4).
+
#### Debugging
You can start the simulation in trace mode using '-t', or in single step
From 9efe9d83ccd095fd28a968de7a0ec2cf044516c3 Mon Sep 17 00:00:00 2001
From: mike632t <1799044+mike632t@users.noreply.github.com>
Date: Sat, 18 May 2024 23:41:23 +0100
Subject: [PATCH 05/14] Added To Do list
---
x11-calc-todo.md | 54 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
create mode 100644 x11-calc-todo.md
diff --git a/x11-calc-todo.md b/x11-calc-todo.md
new file mode 100644
index 0000000..5fb5b81
--- /dev/null
+++ b/x11-calc-todo.md
@@ -0,0 +1,54 @@
+
+## To Do List
+
+- [x] Fix segmentation fault in display code (HP12C).
+
+- [x] Update build instruction for Tru64 UNIX.
+
+- [x] Update screenshots.
+
+- [x] Implement display jumper setting in SPICE series.
+
+- [x] Update help text.
+
+- [x] Fix launcher help text display.
+
+- [-] Allow any _programmable_ model to load a saved program.
+ (Not possible without modifying the firmware)
+
+- [ ] Update README (document new options).
+
+- [ ] Use variables for all error messages, and add missing translations.
+ https://superuser.com/questions/392439/lang-and-language-environment-variable-in-debian-based-systems
+
+- [ ] Fix window resizing.
+
+- [ ] Allow user to resize the window at runtime (scroll wheel?).
+
+- [ ] Add new button styles for HP67 and HP1x.
+
+- [ ] Implement different styles of digit (to allow for different decimal
+ point positions, and number of segments etc).
+
+- [ ] Better segregation of common code (switch, label and keyboard).
+
+- [ ] Translate README.
+
+- [ ] Move VMS make script to top level directory.
+
+- [ ] Implement the display decoder as a separate 'chip'.
+
+- [ ] Add logic for a separate 'PIK chip' and move printer code.
+
+- [ ] Expand ~ in path.
+ https://stackoverflow.com/questions/40128376/how-to-expand-tilde-in-path
+
+- [ ] Debug HP10.
+
+- [ ] Add HP19C.
+
+- [ ] Implement 16 segment digit display.
+
+- [ ] Add display decoder for HP41C
+
+- [ ] Add support for HP41C?
From 7643e1a1d6818c2fa62a115e19864a427e5b1061 Mon Sep 17 00:00:00 2001
From: mike632t <1799044+mike632t@users.noreply.github.com>
Date: Sat, 18 May 2024 23:42:04 +0100
Subject: [PATCH 06/14] Updated To Do list
---
x11-calc-todo.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/x11-calc-todo.md b/x11-calc-todo.md
index 5fb5b81..f8e002b 100644
--- a/x11-calc-todo.md
+++ b/x11-calc-todo.md
@@ -16,7 +16,7 @@
- [-] Allow any _programmable_ model to load a saved program.
(Not possible without modifying the firmware)
-- [ ] Update README (document new options).
+- [x] Update README (document new options).
- [ ] Use variables for all error messages, and add missing translations.
https://superuser.com/questions/392439/lang-and-language-environment-variable-in-debian-based-systems
From e037099ef8f836551a840776e44e195d1c9207ca Mon Sep 17 00:00:00 2001
From: mike632t <1799044+mike632t@users.noreply.github.com>
Date: Sat, 18 May 2024 23:43:14 +0100
Subject: [PATCH 07/14] Updated To Do list
---
x11-calc-todo.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/x11-calc-todo.md b/x11-calc-todo.md
index f8e002b..0caf7ba 100644
--- a/x11-calc-todo.md
+++ b/x11-calc-todo.md
@@ -19,6 +19,7 @@
- [x] Update README (document new options).
- [ ] Use variables for all error messages, and add missing translations.
+
https://superuser.com/questions/392439/lang-and-language-environment-variable-in-debian-based-systems
- [ ] Fix window resizing.
From 51d39d7e3f16fbe06b87b46471cc39bb7bc411df Mon Sep 17 00:00:00 2001
From: mike632t <1799044+mike632t@users.noreply.github.com>
Date: Sat, 18 May 2024 23:44:11 +0100
Subject: [PATCH 08/14] Updated To Do list
---
x11-calc-todo.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/x11-calc-todo.md b/x11-calc-todo.md
index 0caf7ba..3aff2ae 100644
--- a/x11-calc-todo.md
+++ b/x11-calc-todo.md
@@ -20,7 +20,7 @@
- [ ] Use variables for all error messages, and add missing translations.
- https://superuser.com/questions/392439/lang-and-language-environment-variable-in-debian-based-systems
+ https://superuser.com/questions/392439/lang-and-language-environment-variable-in-debian-based-systems
- [ ] Fix window resizing.
From c6f70b985be108d957c1611b688623c25b61310c Mon Sep 17 00:00:00 2001
From: mike632t <1799044+mike632t@users.noreply.github.com>
Date: Sat, 18 May 2024 23:50:37 +0100
Subject: [PATCH 09/14] Updated To Do list
---
x11-calc-todo.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/x11-calc-todo.md b/x11-calc-todo.md
index 3aff2ae..fcd8dc2 100644
--- a/x11-calc-todo.md
+++ b/x11-calc-todo.md
@@ -13,14 +13,14 @@
- [x] Fix launcher help text display.
-- [-] Allow any _programmable_ model to load a saved program.
+- [ ] Allow any _programmable_ model to load a saved program.
(Not possible without modifying the firmware)
- [x] Update README (document new options).
- [ ] Use variables for all error messages, and add missing translations.
- https://superuser.com/questions/392439/lang-and-language-environment-variable-in-debian-based-systems
+ [https://superuser.com/questions/392439/lang-and-language-environment-variable-in-debian-based-systems]::
- [ ] Fix window resizing.
From 6e46e78c29b22668234ec94d03bfa371641eefe8 Mon Sep 17 00:00:00 2001
From: mike632t <1799044+mike632t@users.noreply.github.com>
Date: Sun, 19 May 2024 00:13:12 +0100
Subject: [PATCH 10/14] Updated To Do list
---
x11-calc-todo.md | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/x11-calc-todo.md b/x11-calc-todo.md
index fcd8dc2..fb4bc47 100644
--- a/x11-calc-todo.md
+++ b/x11-calc-todo.md
@@ -1,6 +1,8 @@
## To Do List
+### Planned changes
+
- [x] Fix segmentation fault in display code (HP12C).
- [x] Update build instruction for Tru64 UNIX.
@@ -13,9 +15,6 @@
- [x] Fix launcher help text display.
-- [ ] Allow any _programmable_ model to load a saved program.
- (Not possible without modifying the firmware)
-
- [x] Update README (document new options).
- [ ] Use variables for all error messages, and add missing translations.
@@ -23,6 +22,7 @@
[https://superuser.com/questions/392439/lang-and-language-environment-variable-in-debian-based-systems]::
- [ ] Fix window resizing.
+ Using window hints to resize the window when doesn't work every where environments
- [ ] Allow user to resize the window at runtime (scroll wheel?).
@@ -35,6 +35,8 @@
- [ ] Translate README.
+- [ ] Finish debugging HP10 instruction set.
+
- [ ] Move VMS make script to top level directory.
- [ ] Implement the display decoder as a separate 'chip'.
@@ -44,8 +46,6 @@
- [ ] Expand ~ in path.
https://stackoverflow.com/questions/40128376/how-to-expand-tilde-in-path
-- [ ] Debug HP10.
-
- [ ] Add HP19C.
- [ ] Implement 16 segment digit display.
@@ -53,3 +53,9 @@
- [ ] Add display decoder for HP41C
- [ ] Add support for HP41C?
+
+### Rejected changes
+
+- [ ] Allow any _programmable_ model to load a saved program.
+ (Not possible without modifying the firmware)
+
From 3d48ac9feb9c5cc1e431679e7bbe3cef935fb260 Mon Sep 17 00:00:00 2001
From: mike632t <1799044+mike632t@users.noreply.github.com>
Date: Sun, 19 May 2024 00:17:10 +0100
Subject: [PATCH 11/14] Updated To Do list
---
x11-calc-todo.md | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/x11-calc-todo.md b/x11-calc-todo.md
index fb4bc47..9cee0af 100644
--- a/x11-calc-todo.md
+++ b/x11-calc-todo.md
@@ -26,6 +26,10 @@
- [ ] Allow user to resize the window at runtime (scroll wheel?).
+- [ ] Finish debugging HP10 instruction set.
+
+- [ ] Add logic for a separate 'PIK chip' and move printer code.
+
- [ ] Add new button styles for HP67 and HP1x.
- [ ] Implement different styles of digit (to allow for different decimal
@@ -35,16 +39,13 @@
- [ ] Translate README.
-- [ ] Finish debugging HP10 instruction set.
-
- [ ] Move VMS make script to top level directory.
- [ ] Implement the display decoder as a separate 'chip'.
-- [ ] Add logic for a separate 'PIK chip' and move printer code.
+- [ ] Expand tilde (~) in filenames.
-- [ ] Expand ~ in path.
- https://stackoverflow.com/questions/40128376/how-to-expand-tilde-in-path
+ [https://stackoverflow.com/questions/40128376/how-to-expand-tilde-in-path]::
- [ ] Add HP19C.
From 7df7464447132588f40dca22410e8ab2be6110cd Mon Sep 17 00:00:00 2001
From: macmpi <16296055+macmpi@users.noreply.github.com>
Date: Tue, 4 Jun 2024 22:12:09 +0200
Subject: [PATCH 12/14] add Alpine package install instructions
---
README.md | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 4f1c1f3..ca5428e 100644
--- a/README.md
+++ b/README.md
@@ -83,6 +83,8 @@ Tru64 Unix.
The simulator has been successfully compiled and tested on:
+ - Alpine 3.20, gcc 13.2.1, x64 + arm64
+
- Alpine 3.19, gcc 13.2.1, x64 + arm64
- Debian 12 (Bookworm), clang 14.0.6, x64 + arm64
@@ -375,7 +377,12 @@ make DESTDIR=/tmp/staging install
### Using a pre-compiled package [Back to Top](#top)
If you don't want to download an compile the sources yourself you can use a
-pre-compiled binary package from [Flathub](https://flathub.org/apps/io.github.mike632t.x11-calc) using Flatpak.
+pre-compiled binary package compatible with most distros from [Flathub](https://flathub.org/apps/io.github.mike632t.x11-calc) using Flatpak.
+
+A native binary package is also available on Alpine Linux 3.20 release.\
+If x11 is not already installed, add it as standalone (`setup-xorg-base`) or together with a standard desktop (`setup-desktop`).\
+Make sure `community` repo is enabled and then install with `apk add x11-calc`.\
+To leverage GUI for setup, install `apk add zenity`. Optional program saves may be installed with `apk add x11-calc-prg`.
### Known Issues [Back to Top](#top)
From ecdc8a51d06b6b1810af0fb9c97dceeb9da829a3 Mon Sep 17 00:00:00 2001
From: mike632t <1799044+mike632t@users.noreply.github.com>
Date: Fri, 7 Jun 2024 22:49:31 +0100
Subject: [PATCH 13/14] Updated
---
x11-calc-todo.md | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/x11-calc-todo.md b/x11-calc-todo.md
index 9cee0af..985934b 100644
--- a/x11-calc-todo.md
+++ b/x11-calc-todo.md
@@ -24,13 +24,15 @@
- [ ] Fix window resizing.
Using window hints to resize the window when doesn't work every where environments
-- [ ] Allow user to resize the window at runtime (scroll wheel?).
+ [https://tronche.com/gui/x/xlib/window/XMoveResizeWindow.html]::
-- [ ] Finish debugging HP10 instruction set.
+- [ ] Allow user to resize the window at runtime (scroll wheel?).
- [ ] Add logic for a separate 'PIK chip' and move printer code.
-- [ ] Add new button styles for HP67 and HP1x.
+- [ ] Finish debugging HP10 instruction set.
+
+- [ ] Add new button styles for HP67 and HP1xC.
- [ ] Implement different styles of digit (to allow for different decimal
point positions, and number of segments etc).
From ab56a16c067525340cacc56cdd40bd406ce9e2c3 Mon Sep 17 00:00:00 2001
From: mike632t <1799044+mike632t@users.noreply.github.com>
Date: Sun, 16 Jun 2024 18:44:23 +0100
Subject: [PATCH 14/14] Sets the application icon to the X windows logo
---
src/x11-calc.c | 285 +++++++++++++++++++++++------------------------
src/x11-logo.xbm | 46 ++++++++
2 files changed, 188 insertions(+), 143 deletions(-)
create mode 100644 src/x11-logo.xbm
diff --git a/src/x11-calc.c b/src/x11-calc.c
index cbc1920..22f8834 100644
--- a/src/x11-calc.c
+++ b/src/x11-calc.c
@@ -308,6 +308,7 @@
* 03 May 24 - Sets the abort flag and interval counter immediately
* before the main loop - MT
* 04 May 24 - Do not define unused switches - MT
+ * 15 Jun 24 - Sets the application icon to the X windows logo - MT
*
* To Do - Parse command line in a separate routine.
* - Add verbose option.
@@ -319,8 +320,8 @@
#define NAME "x11-calc"
#define VERSION "0.14"
-#define BUILD "0154"
-#define DATE "04 May 24"
+#define BUILD "0155"
+#define DATE "15 Jun 24"
#define AUTHOR "MT"
#define INTERVAL 25 /* Number of ticks to execute before updating the display */
@@ -356,10 +357,12 @@
#include "x11-keyboard.h"
-#include "gcc-debug.h" /* print() */
+#include "x11-logo.xbm"
+
+#include "gcc-debug.h" /* debug() */
#include "gcc-wait.h" /* i_wait() */
-void v_version() /* Display version information */
+void v_version() /* Display version information */
{
fprintf(stdout, "%s: Version %s.%s %s", FILENAME, VERSION, BUILD, COMMIT_ID);
if (__DATE__[4] == ' ') fprintf(stdout, " 0"); else fprintf(stdout, " %c", __DATE__[4]);
@@ -367,7 +370,7 @@ void v_version() /* Display version information */
__DATE__[0], __DATE__[1], __DATE__[2], &__DATE__[9], __TIME__ );
}
-void v_warning(const char *s_format, ...) /* Print formatted warning message and exit */
+void v_warning(const char *s_format, ...) /* Print formatted warning message and exit */
{
va_list t_args;
va_start(t_args, s_format);
@@ -376,10 +379,10 @@ void v_warning(const char *s_format, ...) /* Print formatted warning message and
va_end(t_args);
}
-void v_error(int i_errno, const char *s_format, ...) /* Print formatted error message and exit returning errno */
+void v_error(int i_errno, const char *s_format, ...) /* Print formatted error message and exit returning errno */
{
va_list t_args;
- if (!(i_errno)) i_errno = -1; /* If errno not set return -1 */
+ if (!(i_errno)) i_errno = -1; /* If errno not set return -1 */
va_start(t_args, s_format);
fprintf(stderr, "%s: ", FILENAME);
vfprintf(stderr, s_format, t_args);
@@ -391,34 +394,35 @@ void v_set_blank_cursor(Display *x_display, Window x_application_window, Cursor
{
Pixmap x_blank;
XColor x_Color;
- char c_pixmap_data[1] = {0}; /* An empty pixmap */
- x_blank = XCreateBitmapFromData (x_display, x_application_window, c_pixmap_data, 1, 1); /* Create an empty bitmap */
- (*x_cursor) = XCreatePixmapCursor(x_display, x_blank, x_blank, &x_Color, &x_Color, 0, 0); /* Use the empty pixmap to create a blank cursor */
- XFreePixmap (x_display, x_blank); /* Free up pixmap */
+ char c_pixmap_data[1] = {0}; /* An empty pixmap */
+ x_blank = XCreateBitmapFromData (x_display, x_application_window, c_pixmap_data, 1, 1); /* Create an empty bitmap */
+ (*x_cursor) = XCreatePixmapCursor(x_display, x_blank, x_blank, &x_Color, &x_Color, 0, 0); /* Use the empty pixmap to create a blank cursor */
+ XFreePixmap (x_display, x_blank); /* Free up pixmap */
}
int main(int argc, char *argv[])
{
- Display *x_display; /* Pointer to X display structure */
- Window x_application_window; /* Application window structure */
- Cursor x_cursor; /* Application cursor */
+ Display *x_display; /* Pointer to X display structure */
+ Window x_application_window; /* Application window structure */
+ Cursor x_cursor; /* Application cursor */
+ Pixmap x_logo; /* Application icon */
XEvent x_event;
XSizeHints *h_size_hint;
Atom wm_delete;
XRectangle o_window_position;
XRectangle o_window_geometry;
- obutton *h_button[BUTTONS]; /* Array to hold pointers to buttons */
+ obutton *h_button[BUTTONS]; /* Array to hold pointers to buttons */
obutton *h_pressed = NULL;
- odisplay *h_display; /* Pointer to display structure */
+ odisplay *h_display; /* Pointer to display structure */
oprocessor *h_processor;
- char *s_display_name = ""; /* Just use the default display */
- char *s_title = TITLE; /* Windows title */
+ char *s_display_name = ""; /* Just use the default display */
+ char *s_title = TITLE; /* Windows title */
char *s_pathname = NULL;
- int i_window_top; /* Window top */
- int i_window_left; /* Window left */
- unsigned int i_window_width; /* Window width */
+ int i_window_top; /* Window top */
+ int i_window_left; /* Window left */
+ unsigned int i_window_width; /* Window width */
unsigned int i_window_height; /* Window height */
float f_scale = 1.0;
@@ -426,8 +430,8 @@ int main(int argc, char *argv[])
unsigned int i_screen_width; /* Screen width */
unsigned int i_screen_height; /* Screen height */
- unsigned int i_background_colour = BACKGROUND; /* Window's background colour */
- unsigned int i_window_border = 4; /* Window's border width */
+ unsigned int i_background_colour = BACKGROUND; /* Window's background colour */
+ unsigned int i_window_border = 4; /* Window's border width */
unsigned int i_colour_depth; /* Window's colour depth */
int i_screen; /* Default screen number */
@@ -456,8 +460,8 @@ int main(int argc, char *argv[])
#endif
h_processor = h_processor_create(i_rom);
-#if defined(unix) || defined(__unix__) || defined(__APPLE__) /* Parse UNIX style command line options */
- b_abort = False; /* Stop processing command line */
+#if defined(unix) || defined(__unix__) || defined(__APPLE__) /* Parse UNIX style command line options */
+ b_abort = False; /* Stop processing command line */
for (i_count = 1; i_count < argc && (b_abort != True); i_count++)
{
if (argv[i_count][0] == '-')
@@ -467,24 +471,24 @@ int main(int argc, char *argv[])
{
switch (argv[i_count][i_index])
{
- case 'b': /* Breakpoint */
+ case 'b': /* Breakpoint */
if (argv[i_count][i_index + 1] != 0)
v_error(EINVAL, h_err_invalid_argument, argv[i_count][i_index + 1]);
else
if (i_count + 1 < argc)
{
i_breakpoint = 0;
- for (i_offset = 0; i_offset < strlen(argv[i_count + 1]); i_offset++) /* Parse octal number */
+ for (i_offset = 0; i_offset < strlen(argv[i_count + 1]); i_offset++) /* Parse octal number */
{
if ((argv[i_count + 1][i_offset] < '0') || (argv[i_count + 1][i_offset] > '7'))
v_error(EINVAL, h_err_invalid_number, argv[i_count + 1]);
else
i_breakpoint = i_breakpoint * 8 + argv[i_count + 1][i_offset] - '0';
}
- if ((i_breakpoint < 0) || (i_breakpoint > ROM_SIZE) || (i_breakpoint > 07777)) /* Check address range */
+ if ((i_breakpoint < 0) || (i_breakpoint > ROM_SIZE) || (i_breakpoint > 07777)) /* Check address range */
v_error(EINVAL, h_err_numeric_range, argv[i_count + 1]);
else {
- if (i_count + 2 < argc) /* Remove the parameter from the arguments */
+ if (i_count + 2 < argc) /* Remove the parameter from the arguments */
for (i_offset = i_count + 1; i_offset < argc - 1; i_offset++)
argv[i_offset] = argv[i_offset + 1];
argc--;
@@ -494,25 +498,25 @@ int main(int argc, char *argv[])
v_error(EINVAL, h_err_missing_argument, argv[i_count]);
i_index = strlen(argv[i_count]) - 1;
break;
- case 'i': /* Trap Instruction */
+ case 'i': /* Trap Instruction */
if (argv[i_count][i_index + 1] != 0)
v_error(EINVAL, h_err_invalid_argument, argv[i_count][i_index + 1]);
else
if (i_count + 1 < argc)
{
i_trap = 0;
- for (i_offset = 0; i_offset < strlen(argv[i_count + 1]); i_offset++) /* Parse octal number */
+ for (i_offset = 0; i_offset < strlen(argv[i_count + 1]); i_offset++) /* Parse octal number */
{
if ((argv[i_count + 1][i_offset] < '0') || (argv[i_count + 1][i_offset] > '7'))
v_error(EINVAL, h_err_invalid_number, argv[i_count + 1]);
else
i_trap = i_trap * 8 + argv[i_count + 1][i_offset] - '0';
}
- if ((i_trap < 0) || (i_trap > 01777)) /* Check range */
+ if ((i_trap < 0) || (i_trap > 01777)) /* Check range */
v_error(EINVAL, h_err_numeric_range, argv[i_count + 1]);
else
{
- if (i_count + 2 < argc) /* Remove the parameter from the arguments */
+ if (i_count + 2 < argc) /* Remove the parameter from the arguments */
for (i_offset = i_count + 1; i_offset < argc - 1; i_offset++)
argv[i_offset] = argv[i_offset + 1];
argc--;
@@ -522,14 +526,14 @@ int main(int argc, char *argv[])
v_error(EINVAL, h_err_missing_argument, argv[i_count]);
i_index = strlen(argv[i_count]) - 1;
break;
- case 'r': /* Read ROM contents */
+ case 'r': /* Read ROM contents */
if (argv[i_count][i_index + 1] != 0)
v_error(EINVAL, h_err_invalid_argument, argv[i_count][i_index + 1]);
else
if (i_count + 1 < argc)
{
- v_read_rom(h_processor, argv[i_count + 1]); /* Load user specified settings */
- if (i_count + 2 < argc) /* Remove the parameter from the arguments */
+ v_read_rom(h_processor, argv[i_count + 1]); /* Load user specified settings */
+ if (i_count + 2 < argc) /* Remove the parameter from the arguments */
for (i_offset = i_count + 1; i_offset < argc - 1; i_offset++)
argv[i_offset] = argv[i_offset + 1];
argc--;
@@ -538,34 +542,34 @@ int main(int argc, char *argv[])
v_error(EINVAL, h_err_missing_argument, argv[i_count]);
i_index = strlen(argv[i_count]) - 1;
break;
- case 's': /* Start in single step mode */
+ case 's': /* Start in single step mode */
b_trace = b_step = True;
break;
- case 't': /* Enable tracing */
+ case 't': /* Enable tracing */
b_trace = True;
break;
- case '-': /* '--' terminates command line processing */
+ case '-': /* '--' terminates command line processing */
i_index = strlen(argv[i_count]);
if (i_index == 2)
- b_abort = True; /* '--' terminates command line processing */
+ b_abort = True; /* '--' terminates command line processing */
else
if (!strncmp(argv[i_count], "--zoom", i_index))
{
if (i_count + 1 < argc)
{
i_zoom = 0;
- for (i_offset = 0; i_offset < strlen(argv[i_count + 1]); i_offset++) /* Parse decimal number */
+ for (i_offset = 0; i_offset < strlen(argv[i_count + 1]); i_offset++) /* Parse decimal number */
{
if ((argv[i_count + 1][i_offset] < '0') || (argv[i_count + 1][i_offset] > '9'))
v_error(EINVAL, h_err_numeric_range, argv[i_count + 1]);
else
i_zoom = i_zoom * 10 + argv[i_count + 1][i_offset] - '0';
}
- if ((i_zoom < 0) || (i_zoom > 4)) /* Check range */
- v_error(EINVAL, h_err_numeric_range, argv[i_count + 1]); /** TODO: Add new error message */
+ if ((i_zoom < 0) || (i_zoom > 4)) /* Check range */
+ v_error(EINVAL, h_err_numeric_range, argv[i_count + 1]); /** TODO: Add new error message */
else
{
- if (i_count + 2 < argc) /* Remove the parameter from the arguments */
+ if (i_count + 2 < argc) /* Remove the parameter from the arguments */
for (i_offset = i_count + 1; i_offset < argc - 1; i_offset++)
argv[i_offset] = argv[i_offset + 1];
argc--;
@@ -576,12 +580,12 @@ int main(int argc, char *argv[])
v_error(EINVAL, h_err_missing_argument, argv[i_count]);
}
else if (!strncmp(argv[i_count], "--no-cursor", i_index))
- b_cursor = False; /* Don't draw a cursor - unless drawn by the window manager */
+ b_cursor = False; /* Don't draw a cursor - unless drawn by the window manager */
else if (!strncmp(argv[i_count], "--cursor", i_index))
- b_cursor = True; /* Draw cursor */
+ b_cursor = True; /* Draw cursor */
else if (!strncmp(argv[i_count], "--version", i_index))
{
- v_version(); /* Display version information */
+ v_version(); /* Display version information */
fprintf(stdout, h_msg_licence, &__DATE__[7], AUTHOR);
exit(0);
}
@@ -592,12 +596,12 @@ int main(int argc, char *argv[])
}
else /* If we get here then the we have an invalid long option */
v_error(EINVAL, h_err_unrecognised_option, argv[i_count]);
- i_index--; /* Leave index pointing at end of string (so argv[i_count][i_index] = 0) */
+ i_index--; /* Leave index pointing at end of string (so argv[i_count][i_index] = 0) */
break;
- default: /* If we get here the single letter option is unknown */
+ default: /* If we get here the single letter option is unknown */
v_error(EINVAL, h_err_invalid_option, argv[i_count][i_index]);
}
- i_index++; /* Parse next letter in option */
+ i_index++; /* Parse next letter in option */
}
if (argv[i_count][1] != 0)
{
@@ -607,28 +611,28 @@ int main(int argc, char *argv[])
}
}
}
-#else /* Parse DEC style command line options */
+#else /* Parse DEC style command line options */
for (i_count = 1; i_count < argc; i_count++)
{
if (argv[i_count][0] == '/')
{
- for (i_index = 0; argv[i_count][i_index]; i_index++) /* Convert option to uppercase */
+ for (i_index = 0; argv[i_count][i_index]; i_index++) /* Convert option to uppercase */
if (argv[i_count][i_index] >= 'a' && argv[i_count][i_index] <= 'z')
- argv[i_count][i_index] = argv[i_count][i_index] - 32; /* TO DO - Assumes 8-bit ASCII encoding */
+ argv[i_count][i_index] = argv[i_count][i_index] - 32; /* TO DO - Assumes 8-bit ASCII encoding */
if (!strncmp(argv[i_count], "/STEP", i_index))
- b_trace = True; /* Start in single step mode */
+ b_trace = True; /* Start in single step mode */
else if (!strncmp(argv[i_count], "/CURSOR", i_index))
- b_cursor = True; /* Enable tracing */
+ b_cursor = True; /* Enable tracing */
else if (!strncmp(argv[i_count], "/NOCURSOR", i_index))
- b_trace = False; /* Enable tracing */
+ b_trace = False; /* Enable tracing */
else if (!strncmp(argv[i_count], "/TRACE", i_index))
- b_trace = True; /* Enable tracing */
+ b_trace = True; /* Enable tracing */
else if (!strncmp(argv[i_count], "/ROM", i_index))
{
if (i_count + 1 < argc)
{
- v_read_rom(h_processor, argv[i_count + 1]); /* Load user specified settings */
- if (i_count + 2 < argc) /* Remove the parameter from the arguments */
+ v_read_rom(h_processor, argv[i_count + 1]); /* Load user specified settings */
+ if (i_count + 2 < argc) /* Remove the parameter from the arguments */
for (i_offset = i_count + 1; i_offset < argc - 1; i_offset++)
argv[i_offset] = argv[i_offset + 1];
argc--;
@@ -638,7 +642,7 @@ int main(int argc, char *argv[])
}
else if (!strncmp(argv[i_count], "/VERSION", i_index))
{
- v_version; /* Display version information */
+ v_version; /* Display version information */
fprintf(stdout, h_msg_licence, &__DATE__[7], AUTHOR);
exit(0);
}
@@ -660,30 +664,30 @@ int main(int argc, char *argv[])
#endif
#if defined(CONTINIOUS)
- if (argc > 2) v_error(EINVAL, h_err_invalid_operand); /* There should never be more than one command lime parameter */
- if (argc > 1) s_pathname = argv[1]; /* Set path name if a parameter was passed and continuous memory is enabled */
+ if (argc > 2) v_error(EINVAL, h_err_invalid_operand); /* There should never be more than one command lime parameter */
+ if (argc > 1) s_pathname = argv[1]; /* Set path name if a parameter was passed and continuous memory is enabled */
#else
- if (argc > 1) v_error(EINVAL, h_err_invalid_operand); /* There shouldn't any command line parameters */
+ if (argc > 1) v_error(EINVAL, h_err_invalid_operand); /* There shouldn't any command line parameters */
#endif
- i_wait(200); /* Sleep for 200 milliseconds to 'debounce' keyboard! */
+ i_wait(200); /* Sleep for 200 milliseconds to 'debounce' keyboard! */
i_count = ROM_SIZE;
- while ((i_count > 0) && (i_rom[--i_count] == 0)); /* Check that the ROM isn't empty */
+ while ((i_count > 0) && (i_rom[--i_count] == 0)); /* Check that the ROM isn't empty */
if (i_count == 0) v_error (ENODATA, h_err_ROM);
- if (!(x_display = XOpenDisplay(s_display_name))) v_error (errno, h_err_display, s_display_name); /* Open the display and create a new window */
+ if (!(x_display = XOpenDisplay(s_display_name))) v_error (errno, h_err_display, s_display_name); /* Open the display and create a new window */
- i_screen = DefaultScreen(x_display); /* Get the default screen for our X server */
+ i_screen = DefaultScreen(x_display); /* Get the default screen for our X server */
i_screen_width = DisplayWidth(x_display, i_screen);
i_screen_height = DisplayHeight(x_display, i_screen);
- o_window_position.width = WIDTH; /* Window width in pixels */
- o_window_position.height = HEIGHT; /* Window height in pixels */
+ o_window_position.width = WIDTH; /* Window width in pixels */
+ o_window_position.height = HEIGHT; /* Window height in pixels */
o_window_position.x = (i_screen_width - o_window_position.width) / 2 ; /* Centre window on screen - ignored by most window managers but useful in kiosk mode */
o_window_position.y = (i_screen_height - o_window_position.height) / 2;
- o_window_geometry = o_window_position; /* Save window position */
+ o_window_geometry = o_window_position; /* Save window position */
x_application_window = XCreateSimpleWindow(x_display, /* Create the application window, as a child of the root window */
RootWindow(x_display, i_screen),
@@ -692,19 +696,7 @@ int main(int argc, char *argv[])
o_window_position.height, /* Window height */
i_window_border, /* Border width - ignored ? */
BlackPixel(x_display, i_screen), /* Preferred method */
- i_background_colour); /* Background colour */
-
- h_size_hint = XAllocSizeHints(); /* Set application window size */
- h_size_hint->flags = PMinSize | PMaxSize;
- h_size_hint->height = o_window_position.height; /* Obsolete but used by some oli_window_leftder windows managers */
- h_size_hint->width = o_window_position.width; /* Obsolete but used by some older windows managers */
- h_size_hint->min_height = o_window_position.height;
- h_size_hint->min_width = o_window_position.width;
- h_size_hint->max_height = o_window_position.height;
- h_size_hint->max_width = o_window_position.width;
- XSetWMNormalHints(x_display, x_application_window, h_size_hint);
-
- XStoreName(x_display, x_application_window, s_title); /* Set the window title */
+ i_background_colour); /* Background colour */
if (XGetGeometry(x_display, x_application_window, /* Get window geometry */
&RootWindow(x_display, i_screen),
@@ -715,13 +707,16 @@ int main(int argc, char *argv[])
&i_colour_depth) == False)
v_error(errno, h_err_display_properties);
- if (i_colour_depth != COLOUR_DEPTH) v_error(errno, h_err_display_colour, COLOUR_DEPTH); /* Check colour depth */
+ if (i_colour_depth != COLOUR_DEPTH) v_error(errno, h_err_display_colour, COLOUR_DEPTH); /* Check colour depth */
+
+ if (!(x_logo = XCreateBitmapFromData(x_display, x_application_window, (char*) logo_bits, logo_width, logo_height)))
+ v_error(errno, "Can't create pixmap\n"); /* Check colour depth */
if (b_cursor)
- x_cursor = XCreateFontCursor(x_display, XC_arrow); /* Create a 'default' cursor */
+ x_cursor = XCreateFontCursor(x_display, XC_arrow); /* Create a 'default' cursor */
else
- v_set_blank_cursor(x_display, x_application_window, &x_cursor); /* Get a blank cursor */
- XDefineCursor(x_display, x_application_window, x_cursor); /* Define the desired X cursor */
+ v_set_blank_cursor(x_display, x_application_window, &x_cursor); /* Get a blank cursor */
+ XDefineCursor(x_display, x_application_window, x_cursor); /* Define the desired X cursor */
if (!(h_normal_font = h_get_font(x_display, s_normal_fonts))) v_error(errno, h_err_font, s_normal_fonts[0]);
if (!(h_small_font = h_get_font(x_display, s_small_fonts))) v_error(errno, h_err_font, s_small_fonts[0]);
@@ -730,9 +725,9 @@ int main(int argc, char *argv[])
h_display = h_display_create(0, BEZEL_LEFT, BEZEL_TOP, BEZEL_WIDTH, BEZEL_HEIGHT,
DISPLAY_LEFT, DISPLAY_TOP, DISPLAY_WIDTH, DISPLAY_HEIGHT, DIGIT_COLOUR, DIGIT_BACKGROUND,
- DISPLAY_BACKGROUND, BEZEL_COLOUR); /* Create display */
+ DISPLAY_BACKGROUND, BEZEL_COLOUR); /* Create display */
- v_init_buttons(h_button); /* Create buttons */
+ v_init_buttons(h_button); /* Create buttons */
#if defined(SWITCHES)
v_init_switches(h_switch);
@@ -748,43 +743,45 @@ int main(int argc, char *argv[])
o_window_position.width = o_window_geometry.width * f_scale;
o_window_position.height = o_window_geometry.height * f_scale;
- h_size_hint->height = o_window_position.height; /* Obsolete but used by some oli_window_leftder windows managers */
- h_size_hint->width = o_window_position.width; /* Obsolete but used by some older windows managers */
+ h_size_hint = XAllocSizeHints(); /* Set application window size */
+ h_size_hint->flags = PMinSize | PMaxSize;
+ h_size_hint->height = o_window_position.height; /* Obsolete but used by some oli_window_leftder windows managers */
+ h_size_hint->width = o_window_position.width; /* Obsolete but used by some older windows managers */
h_size_hint->min_height = o_window_position.height;
h_size_hint->min_width = o_window_position.width;
h_size_hint->max_height = o_window_position.height;
h_size_hint->max_width = o_window_position.width;
- XSetWMNormalHints(x_display, x_application_window, h_size_hint);
+ XSetStandardProperties(x_display, x_application_window, s_title, s_title, x_logo, argv, argc, h_size_hint); /* Set the window title and icon */
- i_display_resize(h_display, f_scale); /* Resize display */
+ i_display_resize(h_display, f_scale); /* Resize display */
- for (i_count = 0; i_count < BUTTONS; i_count++) /* Resize buttons */
+ for (i_count = 0; i_count < BUTTONS; i_count++) /* Resize buttons */
i_button_resize(h_button[i_count], f_scale);
#if defined(SWITCHES)
- for (i_count = 0; i_count < SWITCHES; i_count++) /* Resize labels */
+ for (i_count = 0; i_count < SWITCHES; i_count++) /* Resize labels */
i_switch_resize(h_switch[i_count], f_scale);
#endif
#if defined(LABELS)
- for (i_count = 0; i_count < LABELS; i_count++) /* Resize labels */
+ for (i_count = 0; i_count < LABELS; i_count++) /* Resize labels */
i_label_resize(h_label[i_count], f_scale);
#endif
#if defined(__linux__) || defined(__NetBSD__) || defined(__FreeBSD__)
- h_keyboard = h_keyboard_create(x_display); /* Only works with Linux */
+ h_keyboard = h_keyboard_create(x_display); /* Only works with Linux */
#endif
XSelectInput(x_display, x_application_window, FocusChangeMask | ExposureMask | /* Select kind of events we are interested in */
KeyPressMask | KeyReleaseMask | ButtonPressMask |
ButtonReleaseMask | StructureNotifyMask | SubstructureNotifyMask);
- wm_delete = XInternAtom(x_display, "WM_DELETE_WINDOW", False); /* Create a windows delete message 'atom'. */
- XSetWMProtocols(x_display, x_application_window, &wm_delete, 1); /* Tell the display to pass wm_delete messages to the application window */
+ wm_delete = XInternAtom(x_display, "WM_DELETE_WINDOW", False); /* Create a windows delete message 'atom'. */
+ XSetWMProtocols(x_display, x_application_window, &wm_delete, 1); /* Tell the display to pass wm_delete messages to the application window */
- XMapWindow(x_display, x_application_window); /* Show window on display */
- XRaiseWindow(x_display, x_application_window); /* Raise window - ensures expose event is raised? */
+ XMapWindow(x_display, x_application_window); /* Show window on display */
+ XRaiseWindow(x_display, x_application_window); /* Raise window - ensures expose event is raised? */
v_version();
fprintf(stdout, "ROM Size: %4u words \n", ROM_SIZE);
@@ -795,36 +792,36 @@ int main(int argc, char *argv[])
if (s_pathname == NULL)
v_restore_state(h_processor);
else
- v_read_state(h_processor, s_pathname); /* Load user specified settings */
+ v_read_state(h_processor, s_pathname); /* Load user specified settings */
#if defined(SWITCHES)
- h_processor->enabled = h_switch[0]->state; /* Allow switches to be undefined if not used */
+ h_processor->enabled = h_switch[0]->state; /* Allow switches to be undefined if not used */
if (SWITCHES == 2) h_processor->mode = h_switch[1]->state;
#endif
b_abort = False;
i_count = 0;
- while (!b_abort) /* Main program event loop */
+ while (!b_abort) /* Main program event loop */
{
i_count--;
if (i_count < 0)
{
i_display_update(h_display, h_processor);
- i_display_draw(x_display, x_application_window, i_screen, h_display); /* Redraw display */
+ i_display_draw(x_display, x_application_window, i_screen, h_display); /* Redraw display */
i_count = INTERVAL;
#if defined(HP67)
- i_wait(INTERVAL / 4); /* Sleep for ~6.25 ms per tick */
+ i_wait(INTERVAL / 4); /* Sleep for ~6.25 ms per tick */
#elif defined(VOYAGER)
- i_wait(INTERVAL / 3); /* Sleep for ~8.33 ms per tick */
+ i_wait(INTERVAL / 3); /* Sleep for ~8.33 ms per tick */
#elif defined(SPICE)
- i_wait(INTERVAL / 3); /* Sleep for ~8.33 ms per tick */
+ i_wait(INTERVAL / 3); /* Sleep for ~8.33 ms per tick */
#else
- i_wait(INTERVAL / 2); /* Sleep for ~12.5 ms per tick */
+ i_wait(INTERVAL / 2); /* Sleep for ~12.5 ms per tick */
#endif
if (i_ticks > 0) i_ticks -= 1;
if (i_ticks == 0) b_abort = True;
}
- if (((h_processor->pc & 0xfff) == i_breakpoint) || (h_processor->rom[h_processor->pc] == i_trap)) /* Check for Breakpoint or Instruction Trap */
+ if (((h_processor->pc & 0xfff) == i_breakpoint) || (h_processor->rom[h_processor->pc] == i_trap)) /* Check for Breakpoint or Instruction Trap */
{
if (!h_processor->trace || !h_processor->step) fprintf(stderr, "** break **\n");
h_processor->trace = h_processor->step = True;
@@ -842,33 +839,34 @@ int main(int argc, char *argv[])
{
h_pressed->state = False;
i_button_draw(x_display, x_application_window, i_screen, h_pressed);
- h_processor->keypressed = False; /* Don't clear the status bit here!! */
+ h_processor->keypressed = False; /* Don't clear the status bit here!! */
}
break;
#if defined(__linux__) || defined(__NetBSD__) || defined(__FreeBSD__)
case KeyPress :
- h_key_pressed(h_keyboard, x_display, x_event.xkey.keycode, x_event.xkey.state); /* Attempts to translate a key code into a character */
- if (h_keyboard->key == (XK_BackSpace & 0x1f)) h_keyboard->key = XK_Escape & 0x1f; /* Map backspace to escape */
- if (h_keyboard->key == (XK_Z & 0x1f)) /* Ctrl-Z to exit */
+ h_key_pressed(h_keyboard, x_display, x_event.xkey.keycode, x_event.xkey.state); /* Attempts to translate a key code into a character */
+ if (h_keyboard->key == (XK_BackSpace & 0x1f)) h_keyboard->key = XK_Escape & 0x1f; /* Map backspace to escape */
+ if (h_keyboard->key == (XK_Z & 0x1f)) /* Ctrl-Z to exit */
b_abort = True;
- else if (h_keyboard->key == (XK_Q & 0x1f)) /* Ctrl-Q to resume */
+ else if (h_keyboard->key == (XK_Q & 0x1f)) /* Ctrl-Q to resume */
h_processor->step = !(b_run = True);
- else if (h_keyboard->key == (XK_S & 0x1f)) /* Ctrl-S or space to single step */
+ else if (h_keyboard->key == (XK_S & 0x1f)) /* Ctrl-S or space to single step */
h_processor->trace = h_processor->step = b_run = True;
- else if (h_keyboard->key == (XK_T & 0x1f)) /* Ctrl-T to toggle tracing */
+ else if (h_keyboard->key == (XK_T & 0x1f)) /* Ctrl-T to toggle tracing */
h_processor->trace = !h_processor->trace;
- else if (h_keyboard->key == (XK_R & 0x1f)) /* Ctrl-R to display internal CPU registers */
+ else if (h_keyboard->key == (XK_R & 0x1f)) /* Ctrl-R to display internal CPU registers */
v_fprint_registers(stdout, h_processor);
- else if (h_keyboard->key == (XK_C & 0x1f)) /* Ctrl-C to reset */
+ else if (h_keyboard->key == (XK_C & 0x1f)) /* Ctrl-C to reset */
{
v_processor_reset(h_processor);
if (s_pathname == NULL)
- v_restore_state(h_processor); /* Load current saved settings */
+ v_restore_state(h_processor); /* Load current saved settings */
else
- v_read_state(h_processor, s_pathname); /* Load user specified settings */
+ v_read_state(h_processor, s_pathname); /* Load user specified settings */
b_run = True;
}
- else { /* Check for matching button */
+ else /* Check for matching button */
+ {
int i_count;
for (i_count = 0; i_count < BUTTONS; i_count++)
{
@@ -880,7 +878,7 @@ int main(int argc, char *argv[])
h_processor->code = h_pressed->index;
h_processor->keypressed = True;
#if !defined(SWITCHES)
- h_processor->enabled = True; /* Any key press wil wake up the processor */
+ h_processor->enabled = True; /* Any key press wil wake up the processor */
h_processor->sleep = False;
#endif
break;
@@ -890,14 +888,14 @@ int main(int argc, char *argv[])
break;
case KeyRelease :
h_key_released(h_keyboard, x_display, x_event.xkey.keycode, x_event.xkey.state);
- if (h_keyboard->key == (XK_BackSpace & 0x1f)) h_keyboard->key = XK_Escape & 0x1f; /* Map backspace to escape */
+ if (h_keyboard->key == (XK_BackSpace & 0x1f)) h_keyboard->key = XK_Escape & 0x1f; /* Map backspace to escape */
if (h_pressed != NULL)
{
if (h_keyboard->key == h_pressed->key)
{
h_pressed->state = False;
i_button_draw(x_display, x_application_window, i_screen, h_pressed);
- h_processor->keypressed = False; /* Don't clear the status bit here!! */
+ h_processor->keypressed = False; /* Don't clear the status bit here!! */
}
}
break;
@@ -917,29 +915,30 @@ int main(int argc, char *argv[])
h_processor->code = h_pressed->index;
h_processor->keypressed = True;
#if !defined(SWITCHES)
- h_processor->enabled = True; /* Any key press wil wake up the processor */
+ h_processor->enabled = True; /* Any key press wil wake up the processor */
h_processor->sleep = False;
#endif
break;
}
}
#if defined(SWITCHES)
- if (h_pressed == NULL) { /* It wasn't a button that was pressed check the switches */
+ if (h_pressed == NULL) /* It wasn't a button that was pressed check the switches */
+ {
if (!(h_switch_pressed(h_switch[0], x_event.xbutton.x, x_event.xbutton.y) == NULL))
{
- h_switch[0]->state = !(h_switch[0]->state); /* Toggle switch */
+ h_switch[0]->state = !(h_switch[0]->state); /* Toggle switch */
i_switch_draw(x_display, x_application_window, i_screen, h_switch[0]);
if (h_switch[0]->state)
{
- v_processor_reset(h_processor); /* Reset the processor */
- v_restore_state(h_processor); /* Restore saved settings */
+ v_processor_reset(h_processor); /* Reset the processor */
+ v_restore_state(h_processor); /* Restore saved settings */
}
else
{
- v_save_state(h_processor); /* Save current settings */
- h_processor->enabled = False; /* Disable the processor */
+ v_save_state(h_processor); /* Save current settings */
+ h_processor->enabled = False; /* Disable the processor */
#if defined(HP67)
- i_ticks = DELAY * 4; /* Set count down */
+ i_ticks = DELAY * 4; /* Set count down */
#elif defined(VOYAGER)
i_ticks = DELAY * 3;
#elif defined(SPICE)
@@ -952,7 +951,7 @@ int main(int argc, char *argv[])
if (SWITCHES == 2)
if (h_switch_pressed(h_switch[1], x_event.xbutton.x, x_event.xbutton.y) != NULL)
{
- h_processor->mode = i_switch_click(h_switch[1]); /* Update prgm/run switch */
+ h_processor->mode = i_switch_click(h_switch[1]); /* Update prgm/run switch */
i_switch_draw(x_display, x_application_window, i_screen, h_switch[1]);
}
}
@@ -966,41 +965,41 @@ int main(int argc, char *argv[])
{
h_pressed->state = False;
i_button_draw(x_display, x_application_window, i_screen, h_pressed);
- h_processor->keypressed = False; /* Don't clear the status bit here!! */
+ h_processor->keypressed = False; /* Don't clear the status bit here!! */
}
#if defined(SWITCHES)
- if (h_pressed == NULL) /* It wasn't a button that was released so check the switches */
+ if (h_pressed == NULL) /* It wasn't a button that was released so check the switches */
if (!(h_switch_pressed(h_switch[0], x_event.xbutton.x, x_event.xbutton.y) == NULL))
i_ticks = -1;
#endif
}
break;
- case Expose : /* Draw or redraw the window */
+ case Expose : /* Draw or redraw the window */
{
int i_count;
i_display_draw(x_display, x_application_window, i_screen, h_display);/* Draw display */
#if defined(LABELS)
- for (i_count = 0; i_count < LABELS; i_count++) /* Draw labels */
+ for (i_count = 0; i_count < LABELS; i_count++) /* Draw labels */
i_label_draw(x_display, x_application_window, i_screen, h_label[i_count]);
#endif
#if defined(SWITCHES)
- for (i_count = 0; i_count < SWITCHES; i_count++) /* Draw switches */
+ for (i_count = 0; i_count < SWITCHES; i_count++) /* Draw switches */
i_switch_draw(x_display, x_application_window, i_screen, h_switch[i_count]);
#endif
- for (i_count = 0; i_count < BUTTONS; i_count++) /* Draw buttons */
+ for (i_count = 0; i_count < BUTTONS; i_count++) /* Draw buttons */
i_button_draw(x_display, x_application_window, i_screen, h_button[i_count]);
}
break;
- case ClientMessage : /* Message from window manager */
+ case ClientMessage : /* Message from window manager */
if (x_event.xclient.data.l[0] == wm_delete) b_abort = True;
break;
}
}
}
- v_save_state(h_processor); /* Save state */
+ v_save_state(h_processor); /* Save state */
- XDestroyWindow(x_display, x_application_window); /* Close connection to server */
+ XDestroyWindow(x_display, x_application_window); /* Close connection to server */
XCloseDisplay(x_display);
exit(0);
diff --git a/src/x11-logo.xbm b/src/x11-logo.xbm
new file mode 100644
index 0000000..fe17b96
--- /dev/null
+++ b/src/x11-logo.xbm
@@ -0,0 +1,46 @@
+#define logo_width 64
+#define logo_height 64
+static unsigned char logo_bits[] = {
+ 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xfe, 0xff, 0x01, 0x00,
+ 0x00, 0x00, 0x00, 0xf8, 0xfc, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x7c,
+ 0xf8, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x3e, 0xf8, 0xff, 0x07, 0x00,
+ 0x00, 0x00, 0x00, 0x1f, 0xf0, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x80, 0x0f,
+ 0xe0, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x80, 0x0f, 0xc0, 0xff, 0x3f, 0x00,
+ 0x00, 0x00, 0xc0, 0x07, 0xc0, 0xff, 0x3f, 0x00, 0x00, 0x00, 0xe0, 0x03,
+ 0x80, 0xff, 0x7f, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x00, 0xff, 0xff, 0x00,
+ 0x00, 0x00, 0xf8, 0x00, 0x00, 0xfe, 0xff, 0x01, 0x00, 0x00, 0xf8, 0x00,
+ 0x00, 0xfe, 0xff, 0x01, 0x00, 0x00, 0x7c, 0x00, 0x00, 0xfc, 0xff, 0x03,
+ 0x00, 0x00, 0x3e, 0x00, 0x00, 0xf8, 0xff, 0x07, 0x00, 0x00, 0x1f, 0x00,
+ 0x00, 0xf0, 0xff, 0x0f, 0x00, 0x80, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0x0f,
+ 0x00, 0xc0, 0x07, 0x00, 0x00, 0xe0, 0xff, 0x1f, 0x00, 0xc0, 0x07, 0x00,
+ 0x00, 0xc0, 0xff, 0x3f, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x80, 0xff, 0x7f,
+ 0x00, 0xf0, 0x01, 0x00, 0x00, 0x80, 0xff, 0x7f, 0x00, 0xf8, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0xff, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff,
+ 0x01, 0x7c, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x03, 0x3e, 0x00, 0x00,
+ 0x00, 0x00, 0xfc, 0xff, 0x03, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff,
+ 0x87, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xcf, 0x07, 0x00, 0x00,
+ 0x00, 0x00, 0xe0, 0xff, 0xcf, 0x07, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff,
+ 0xe7, 0x03, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xf3, 0x01, 0x00, 0x00,
+ 0x00, 0x00, 0x80, 0xff, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
+ 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xfe, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x7e, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e,
+ 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9f, 0xff, 0x07, 0x00, 0x00,
+ 0x00, 0x00, 0x80, 0xcf, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xe7,
+ 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xe7, 0xff, 0x1f, 0x00, 0x00,
+ 0x00, 0x00, 0xe0, 0xc3, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xc1,
+ 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x80, 0xff, 0x7f, 0x00, 0x00,
+ 0x00, 0x00, 0x7c, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00,
+ 0xfe, 0xff, 0x01, 0x00, 0x00, 0x00, 0x3e, 0x00, 0xfe, 0xff, 0x01, 0x00,
+ 0x00, 0x00, 0x1f, 0x00, 0xfc, 0xff, 0x03, 0x00, 0x00, 0x80, 0x0f, 0x00,
+ 0xf8, 0xff, 0x07, 0x00, 0x00, 0xc0, 0x07, 0x00, 0xf0, 0xff, 0x0f, 0x00,
+ 0x00, 0xe0, 0x03, 0x00, 0xf0, 0xff, 0x0f, 0x00, 0x00, 0xe0, 0x03, 0x00,
+ 0xe0, 0xff, 0x1f, 0x00, 0x00, 0xf0, 0x01, 0x00, 0xc0, 0xff, 0x3f, 0x00,
+ 0x00, 0xf8, 0x00, 0x00, 0x80, 0xff, 0x7f, 0x00, 0x00, 0x7c, 0x00, 0x00,
+ 0x80, 0xff, 0x7f, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00,
+ 0x00, 0x3e, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x01, 0x00, 0x1f, 0x00, 0x00,
+ 0x00, 0xfc, 0xff, 0x03, 0x80, 0x0f, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x03,
+ 0xc0, 0x07, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x07, 0xe0, 0x03, 0x00, 0x00,
+ 0x00, 0xf0, 0xff, 0x0f, 0xe0, 0x03, 0x00, 0x00, 0x00, 0xe0, 0xff, 0x1f,
+ 0xf0, 0x01, 0x00, 0x00, 0x00, 0xe0, 0xff, 0x1f, 0xf8, 0x00, 0x00, 0x00,
+ 0x00, 0xc0, 0xff, 0x3f, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x7f,
+ 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff};