Post Reply 
Yet another HP simulator (using C + X11)
10-01-2021, 10:28 PM (This post was last modified: 11-26-2021 11:27 PM by Mike T..)
Post: #1
Yet another HP simulator (using C + X11)
Currently simulates the HP21, HP 22, HP25C, HP27, HP29C, HP31, HP32, and HP33C (and hopefully soon the HP34C).

The source code can be found on GitHub.

[Image: x11-calc-21.png] [Image: x11-calc-22.png] [Image: x11-calc-25.png] [Image: x11-calc-27.png] [Image: x11-calc-29.png]

[Image: x11-calc-31.png] [Image: x11-calc-32.png] [Image: x11-calc-33.png] [Image: x11-calc-34.png]

Many thanks to those whose original works and encouragement have helped me get this far including Jacques LAPORTE, David HICKS, Greg SYDNEY-SMITH, Eric SMITH, and in particular Tony NIXON and Bernhard EMESE. I can't believe quite how far I've come with their help.

The code has been tested on Debian 11, Debian 10, Raspbian (Buster), Ubuntu 20.04, and Windows 7 using Cygwin-X and will work on both the Raspberry Pi 3 and Raspberry Pi 4. (Do not use KMS or FKMS see this thread).

It will also compile unchanged on Tru64 Unix and VAX/VMS but the keyboard mapping does not work on these systems. However I don't test every version of these platforms so I may accidentally break things occasionally!

If you get it working on your system please post the details below (OS version, gcc version and architecture).

Mike T.

HP21, HP25, HP32E, HP33C, HP34C, HP10C, HP11C, HP12C, HP32S, HP22S
Find all posts by this user
Quote this message in a reply
10-04-2021, 07:30 AM
Post: #2
RE: Yet another HP simulator (using C + X11)
Great work. Could you give a list of the keyboard shortcuts?
Find all posts by this user
Quote this message in a reply
10-04-2021, 11:18 AM
Post: #3
RE: Yet another HP simulator (using C + X11)
(10-04-2021 07:30 AM)STOX Wrote:  Great work. Could you give a list of the keyboard shortcuts?

Most should be 'obvious', but I really should document them in the README!

Look for an update later today (or tomorrow depending on where you are)...

It would be useful to know what version of Linux and gcc you used.

Mike T.

HP21, HP25, HP32E, HP33C, HP34C, HP10C, HP11C, HP12C, HP32S, HP22S
Find all posts by this user
Quote this message in a reply
10-04-2021, 12:56 PM
Post: #4
RE: Yet another HP simulator (using C + X11)
(10-04-2021 11:18 AM)Mike T. Wrote:  It would be useful to know what version of Linux and gcc you used.

Looks very nice, Mike!

Compiled and ran in Fedora 34, GCC is "gcc version 11.2.1 20210728 (Red Hat 11.2.1-1) (GCC)". Had to add "-fcommon" to FLAGS in makefile, otherwise quite a few "multiple definition of ..." linker errors popped up. Please try to add "-fno-common" on your machine to see them for yourself. If I understand correctly, GCC defaults to "-fno-common" in the newest versions so you'd probably want to clean up the code and avoid those multiple definitions.

And one runtime nitpick: the programs looks to be consuming 100% of CPU power even when not being used.

Overall it's a great start, I love the looks!
Find all posts by this user
Quote this message in a reply
10-04-2021, 11:15 PM (This post was last modified: 10-04-2021 11:22 PM by Mike T..)
Post: #5
RE: Yet another HP simulator (using C + X11)
(10-04-2021 12:56 PM)vaklaff Wrote:  And one runtime nitpick: the programs looks to be consuming 100% of CPU power even when not being used.

The compiler should detect that you are building on linux and use the usleep() function instead of a generic busy loop.

However, it turns out you also need to add '-std=gnu99' to the compiler flags for this to work. Something else I didn't notice when I upgraded!

I've updated the make file and added in '-fcommon' as well!

(10-04-2021 12:56 PM)vaklaff Wrote:  Overall it's a great start, I love the looks!

So do I, particularly the button animations! :-)

Mike T.

HP21, HP25, HP32E, HP33C, HP34C, HP10C, HP11C, HP12C, HP32S, HP22S
Find all posts by this user
Quote this message in a reply
10-08-2021, 01:35 PM
Post: #6
RE: Yet another HP simulator (using C + X11)
I just tied it on ubuntu.
Works great! Loved the graphics.
May I suggest adding an icon to suggest that the letters are buttons. (ON, OFF, PRGM and RUN buttons).
Find all posts by this user
Quote this message in a reply
10-08-2021, 09:20 PM (This post was last modified: 10-08-2021 09:24 PM by Mike T..)
Post: #7
RE: Yet another HP simulator (using C + X11)
(10-08-2021 01:35 PM)agarza Wrote:  I just tied it on ubuntu.
Works great! Loved the graphics.
May I suggest adding an icon to suggest that the letters are buttons. (ON, OFF, PRGM and RUN buttons).

I quite like the minimal approach, but I know what you mean. I tried out a couple of ideas but I've not come up with anything I like yet.

Do you mind posting the Ubuntu and gcc versions, and the machine type x86, x64, or arm etc?

Mike T.

HP21, HP25, HP32E, HP33C, HP34C, HP10C, HP11C, HP12C, HP32S, HP22S
Find all posts by this user
Quote this message in a reply
10-11-2021, 02:52 PM
Post: #8
RE: Yet another HP simulator (using C + X11)
(10-08-2021 09:20 PM)Mike T. Wrote:  
(10-08-2021 01:35 PM)agarza Wrote:  I just tied it on ubuntu.
Works great! Loved the graphics.
May I suggest adding an icon to suggest that the letters are buttons. (ON, OFF, PRGM and RUN buttons).

I quite like the minimal approach, but I know what you mean. I tried out a couple of ideas but I've not come up with anything I like yet.

Do you mind posting the Ubuntu and gcc versions, and the machine type x86, x64, or arm etc?

Ubuntu desktop v20.04.02 (Focal) AMD64
Find all posts by this user
Quote this message in a reply
10-16-2021, 04:56 PM (This post was last modified: 10-16-2021 08:48 PM by Mike T..)
Post: #9
RE: Yet another HP simulator (using C + X11)
Added continuous memory and HP29C simulation...!

Mike T.

HP21, HP25, HP32E, HP33C, HP34C, HP10C, HP11C, HP12C, HP32S, HP22S
Find all posts by this user
Quote this message in a reply
10-18-2021, 11:08 PM
Post: #10
RE: Yet another HP simulator (using C + X11)
I've finally been able to add simulators for the HP31. HP32 and HP33C, which means I've finally completed the goals I set myself when I started this project way back in 2013 (see old article).

In the end I gave up trying to use a decimal arithmetic library and GTK2 and eventually opted for the much more ambitions goal of simulating the actual hardware as it was just too hard to get a modern decimal math library to compile on VMS or Tru64 UNIX (a retro project needs to be properly retro so being able to run the simulator on these platforms was one of my goals).

Fortunately there is a LOT more information available now than when I started and thanks to that and some encouragement I've actually done it. There are a couple issues I need to sort but basically it works!

Hopefully I will be able to add the HP34 to my collection as well, however a bit of a major keyboard/button redesign is needed to accommodate all those labels. I might even be able to add one of the Voyagers like the HP10C, if the processor is not too different - more research needed!

Thanks again to everyone that helped me get this far - I'm still pinching myself.

Mike T.

HP21, HP25, HP32E, HP33C, HP34C, HP10C, HP11C, HP12C, HP32S, HP22S
Find all posts by this user
Quote this message in a reply
10-18-2021, 11:48 PM
Post: #11
RE: Yet another HP simulator (using C + X11)
(10-18-2021 11:08 PM)Mike T. Wrote:  I've finally been able to add simulators for the HP31. HP32 and HP33C, which means I've finally completed the goals I set myself when I started this project way back in 2013 (see old article).

In the end I gave up trying to use a decimal arithmetic library and GTK2 and eventually opted for the much more ambitions goal of simulating the actual hardware as it was just too hard to get a modern decimal math library to compile on VMS or Tru64 UNIX (a retro project needs to be properly retro so being able to run the simulator on these platforms was one of my goals).

Fortunately there is a LOT more information available now than when I started and thanks to that and some encouragement I've actually done it. There are a couple issues I need to sort but basically it works!

Hopefully I will be able to add the HP34 to my collection as well, however a bit of a major keyboard/button redesign is needed to accommodate all those labels. I might even be able to add one of the Voyagers like the HP10C, if the processor is not too different - more research needed!

Thanks again to everyone that helped me get this far - I'm still pinching myself.

Bravo!

Hope you can get the HP34c working. It was my first HP calculator.
Find all posts by this user
Quote this message in a reply
11-03-2021, 10:54 PM (This post was last modified: 11-03-2021 10:55 PM by Mike T..)
Post: #12
RE: Yet another HP simulator (using C + X11)
(10-18-2021 11:48 PM)agarza Wrote:  
(10-18-2021 11:08 PM)Mike T. Wrote:  I've finally been able to add simulators for the HP31. HP32 and HP33C, which means I've finally completed the goals I set myself when I started this project way back in 2013 (see old article).

In the end I gave up trying to use a decimal arithmetic library and GTK2 and eventually opted for the much more ambitions goal of simulating the actual hardware as it was just too hard to get a modern decimal math library to compile on VMS or Tru64 UNIX (a retro project needs to be properly retro so being able to run the simulator on these platforms was one of my goals).

Fortunately there is a LOT more information available now than when I started and thanks to that and some encouragement I've actually done it. There are a couple issues I need to sort but basically it works!

Hopefully I will be able to add the HP34 to my collection as well, however a bit of a major keyboard/button redesign is needed to accommodate all those labels. I might even be able to add one of the Voyagers like the HP10C, if the processor is not too different - more research needed!

Thanks again to everyone that helped me get this far - I'm still pinching myself.

Bravo!

Hope you can get the HP34c working. It was my first HP calculator.

I need to tidy up a few loose ends and may try adding a couple of useful new features (like allowing the size of the window to be changed) first.

The most obvious difficulty with the HP34C is finding enough space for the additional function labels, without changing the existing code too much, so it may take a while sort out but it is on my to do list!

Mike T.

HP21, HP25, HP32E, HP33C, HP34C, HP10C, HP11C, HP12C, HP32S, HP22S
Find all posts by this user
Quote this message in a reply
11-26-2021, 12:48 AM
Post: #13
RE: Yet another HP simulator (using C + X11)
(10-18-2021 11:48 PM)agarza Wrote:  Bravo!

Hope you can get the HP34c working. It was my first HP calculator.

You might like the latest screenshot I just added...

Mike T.

HP21, HP25, HP32E, HP33C, HP34C, HP10C, HP11C, HP12C, HP32S, HP22S
Find all posts by this user
Quote this message in a reply
11-28-2021, 07:24 PM (This post was last modified: 11-29-2021 09:56 AM by Mike T..)
Post: #14
RE: Yet another HP simulator (using C + X11)
(10-18-2021 11:48 PM)agarza Wrote:  Hope you can get the HP34c working. It was my first HP calculator.

Needs more testing but I think I've got the HP34C simulation working now. (Solve, register arithmetic, and a short pseudo random number generator program all seem to work).

I'm very pleased to have been able met my stretch target after so long, and I think I can now claim to at least understand the basics of the 'C' language and X11.

Mike T.

HP21, HP25, HP32E, HP33C, HP34C, HP10C, HP11C, HP12C, HP32S, HP22S
Find all posts by this user
Quote this message in a reply
11-28-2021, 09:33 PM
Post: #15
RE: Yet another HP simulator (using C + X11)
I must admit, I'm a little curious about the choice of X11 when everyone has been trying to get rid of it for the last decade!

— Ian Abbott
Find all posts by this user
Quote this message in a reply
11-28-2021, 09:43 PM
Post: #16
RE: Yet another HP simulator (using C + X11)
How is that going, anyway? When I migrated Free42 from GTK 2 to GTK 3, I tested it under Wayland to see how that worked with the Wayland support in GTK 3, and it was usable but glitchy, not really something you'd want to use on a daily basis.

Of course even if and when Wayland ever becomes the default graphics environment on Linux, there will probably still be support for true X clients, just like you can use the Cygwin X server on Windows or XQuartz on the Mac...
Visit this user's website Find all posts by this user
Quote this message in a reply
11-29-2021, 09:33 AM
Post: #17
RE: Yet another HP simulator (using C + X11)
(11-28-2021 09:33 PM)ijabbott Wrote:  I must admit, I'm a little curious about the choice of X11 when everyone has been trying to get rid of it for the last decade!

One of my goals was to produce an application that was as portable as possible, and even if Wayland had existed when I started I would not have chosen it is as it isn't supported on legacy (non PC) architectures.

X11 applications are not going away and backward compatibility is provided by XWayland so I have no plans to upgrade at the moment!!

That said I did almost give up on trying to get my code to compile using VAXC more then once! However, using a C compiler that old did actually teach me a lot (and not just not to avoid old compilers!) .

Mike T.

HP21, HP25, HP32E, HP33C, HP34C, HP10C, HP11C, HP12C, HP32S, HP22S
Find all posts by this user
Quote this message in a reply
12-01-2021, 09:48 PM
Post: #18
RE: Yet another HP simulator (using C + X11)
(11-29-2021 09:33 AM)Mike T. Wrote:  
(11-28-2021 09:33 PM)ijabbott Wrote:  I must admit, I'm a little curious about the choice of X11 when everyone has been trying to get rid of it for the last decade!

One of my goals was to produce an application that was as portable as possible, and even if Wayland had existed when I started I would not have chosen it is as it isn't supported on legacy (non PC) architectures.

Yes, that's a perfectly reasonable reason. I hadn't considered that fans of HP calculators would want to emulate their delights on legacy systems. Smile

Quote:X11 applications are not going away and backward compatibility is provided by XWayland so I have no plans to upgrade at the moment!!

I'm not sure what the best modern cross-platform windowing/widget toolkit is to use. GTK's C interface seems to be trying too hard to be OO, and Qt does not support C. I haven't used any of them in anger though.

Quote:That said I did almost give up on trying to get my code to compile using VAXC more then once! However, using a C compiler that old did actually teach me a lot (and not just not to avoid old compilers!) .

It works the other way too when newer versions of GCC complain about things that seem perfectly reasonable!

— Ian Abbott
Find all posts by this user
Quote this message in a reply
12-01-2021, 11:11 PM
Post: #19
RE: Yet another HP simulator (using C + X11)
(12-01-2021 09:48 PM)ijabbott Wrote:  I'm not sure what the best modern cross-platform windowing/widget toolkit is to use. GTK's C interface seems to be trying too hard to be OO, and Qt does not support C. I haven't used any of them in anger though.

I haven't used Qt, but GTK isn't bad. It's not particularly elegant, but it gets the job done without the developer having to tie themselves in knots. Coming from Motif, it was positively delightful, and porting Free42 to GTK was one of the easiest ports I've done (the absolute easiest was porting the Windows version to Windows Mobile, but that doesn't really count).

(12-01-2021 09:48 PM)ijabbott Wrote:  It works the other way too when newer versions of GCC complain about things that seem perfectly reasonable!

You can tell a legacy project by the steadily growing list of -Wno-yada-yada-yada options it needs to get the compiler to shut up. Big Grin
Visit this user's website Find all posts by this user
Quote this message in a reply
12-02-2021, 01:07 AM
Post: #20
RE: Yet another HP simulator (using C + X11)
Very nice, thanks; they look wonderful.

I compiled on Linux Debian unstable, gcc 11.2.0-12, then displayed over X to my Mac laptop, via XQuartz.

It's a shame the kdb shortcuts then don't work. And it's quite small, and can't be enlarged.

But the real problem was that many mouse-clicks on the keys are missed. More than half.

This could well be a fault with XQuartz, of course; although I don't recall seeing it with other apps. But I don't use it all that much.

thanks again.

Cambridge, UK
41CL/DM41X 12/15C/16C DM15/16 71B 17B/BII/bII+ 28S 42S/DM42 32SII 48GX 50g 35s 30b/WP34S Prime G2
& Casios, Rockwell 18R :)
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: