diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml deleted file mode 100644 index 0e7c898..0000000 --- a/.github/workflows/c-cpp.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: C/C++ CI - -on: - push: - branches: [ "main", "develop" ] - pull_request: - branches: [ "main" ] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: update deps - run: sudo apt-get -y update - - name: install deps - run: sudo apt install pkgconf libreadline-dev libsdl2-dev libx11-dev libxext-dev liblua5.4-dev - - name: make standard - run: make clean-all && make - - name: make without any sdl - run: make clean-all && make WITH_SDL2=no - - name: make without x11 - run: make clean-all && make WITH_X11=no - - name: make with neither x11 nor sdl - run: make clean-all && make WITH_X11=no WITH_SDL2=no diff --git a/.gitignore b/.gitignore index 717fe6d..2958f53 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ src/*.o src/legacy_tools/*.o dist/x48ng* +/libx48ng.a diff --git a/Makefile b/Makefile index ea87a88..c355d2b 100644 --- a/Makefile +++ b/Makefile @@ -6,8 +6,7 @@ # The governing license can be found in the LICENSE file or at # https://opensource.org/license/MIT. -TARGETS = dist/x48ng dist/x48ng-checkrom dist/x48ng-dump2rom - +TARGETS = libx48ng.a PREFIX = /usr DOCDIR = $(PREFIX)/doc/x48ng MANDIR = $(PREFIX)/man @@ -16,13 +15,10 @@ CFLAGS ?= -g -O2 FULL_WARNINGS = no LUA_VERSION ?= lua PKG_CONFIG ?= pkg-config -WITH_X11 ?= yes -WITH_SDL ?= yes -WITH_SDL2 ?= yes VERSION_MAJOR = 0 -VERSION_MINOR = 40 -PATCHLEVEL = 2 +VERSION_MINOR = 41 +PATCHLEVEL = 0 DOTOS = src/emu_serial.o \ src/emu_emulate.o \ @@ -32,11 +28,7 @@ DOTOS = src/emu_serial.o \ src/emu_register.o \ src/emu_timer.o \ src/debugger.o \ - src/config.o \ src/romio.o \ - src/ui_text.o \ - src/ui.o \ - src/main.o MAKEFLAGS +=-j$(NUM_CORES) -l$(NUM_CORES) @@ -84,72 +76,29 @@ override CPPFLAGS := -I./src/ -D_GNU_SOURCE=1 \ LIBS = -lm -### lua -override CFLAGS += $(shell "$(PKG_CONFIG)" --cflags $(LUA_VERSION)) -LIBS += $(shell "$(PKG_CONFIG)" --libs $(LUA_VERSION)) +# ### lua +# override CFLAGS += $(shell "$(PKG_CONFIG)" --cflags $(LUA_VERSION)) +# LIBS += $(shell "$(PKG_CONFIG)" --libs $(LUA_VERSION)) ### debugger override CFLAGS += $(shell "$(PKG_CONFIG)" --cflags readline) LIBS += $(shell "$(PKG_CONFIG)" --libs readline) -### Text UI -override CFLAGS += $(shell "$(PKG_CONFIG)" --cflags ncursesw) -DNCURSES_WIDECHAR=1 -LIBS += $(shell "$(PKG_CONFIG)" --libs ncursesw) - -### X11 UI -ifeq ($(WITH_X11), yes) - X11CFLAGS = $(shell "$(PKG_CONFIG)" --cflags x11 xext) -D_GNU_SOURCE=1 - X11LIBS = $(shell "$(PKG_CONFIG)" --libs x11 xext) - - override CFLAGS += $(X11CFLAGS) -DHAS_X11=1 - LIBS += $(X11LIBS) - DOTOS += src/ui_x11.o -endif - -### SDL2 UI -ifeq ($(WITH_SDL), yes) - WITH_SDL2 = yes -endif -ifeq ($(WITH_SDL2), yes) - SDLCFLAGS = $(shell "$(PKG_CONFIG)" --cflags sdl2) - SDLLIBS = $(shell "$(PKG_CONFIG)" --libs sdl2) - - override CFLAGS += $(SDLCFLAGS) -DHAS_SDL2=1 - LIBS += $(SDLLIBS) - DOTOS += src/ui_sdl2.o -endif - -# depfiles = $(objects:.o=.d) - -# # Have the compiler output dependency files with make targets for each -# # of the object files. The `MT` option specifies the dependency file -# # itself as a target, so that it's regenerated when it should be. -# %.dep.mk: %.c -# $(CC) -M -MP -MT '$(<:.c=.o) $@' $(CPPFLAGS) $< > $@ - -# # Include each of those dependency files; Make will run the rule above -# # to generate each dependency file (if it needs to). -# -include $(depfiles) - .PHONY: all clean clean-all pretty-code install mrproper all: $(TARGETS) -dist/x48ng-dump2rom: src/legacy_tools/dump2rom.o -dist/x48ng-checkrom: src/legacy_tools/checkrom.o src/romio.o -dist/x48ng: $(DOTOS) - # Binaries -$(TARGETS): - $(CC) $^ -o $@ $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(LIBS) +libx48ng.a: $(DOTOS) + ar rcs $@ $^ # Cleaning clean: - rm -f src/*.o src/legacy_tools/*.o src/*.dep.mk src/legacy_tools/*.dep.mk + rm -f src/*.o mrproper: clean rm -f $(TARGETS) - make -C dist/ROMs mrproper + # make -C dist/ROMs mrproper clean-all: mrproper @@ -158,32 +107,32 @@ pretty-code: clang-format -i src/*.c src/*.h src/legacy_tools/*.c # Installing -get-roms: - make -C dist/ROMs +# get-roms: +# make -C dist/ROMs -dist/config.lua: dist/x48ng - $^ --print-config > $@ +# dist/config.lua: dist/x48ng +# $^ --print-config > $@ -install: all dist/config.lua - install -m 755 -d -- $(DESTDIR)$(PREFIX)/bin - install -c -m 755 dist/x48ng $(DESTDIR)$(PREFIX)/bin/x48ng +# install: all dist/config.lua +# install -m 755 -d -- $(DESTDIR)$(PREFIX)/bin +# install -c -m 755 dist/x48ng $(DESTDIR)$(PREFIX)/bin/x48ng - install -m 755 -d -- $(DESTDIR)$(PREFIX)/share/x48ng - install -c -m 644 dist/hplogo.png $(DESTDIR)$(PREFIX)/share/x48ng/hplogo.png - cp -R dist/ROMs/ $(DESTDIR)$(PREFIX)/share/x48ng/ - install -c -m 755 dist/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)$(PREFIX)/share/x48ng +# install -c -m 644 dist/hplogo.png $(DESTDIR)$(PREFIX)/share/x48ng/hplogo.png +# cp -R dist/ROMs/ $(DESTDIR)$(PREFIX)/share/x48ng/ +# install -c -m 755 dist/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)$(PREFIX)/libexec - install -c -m 755 dist/x48ng-dump2rom $(DESTDIR)$(PREFIX)/libexec/x48ng-dump2rom - install -c -m 755 dist/x48ng-checkrom $(DESTDIR)$(PREFIX)/libexec/x48ng-checkrom +# install -m 755 -d -- $(DESTDIR)$(PREFIX)/libexec +# install -c -m 755 dist/x48ng-dump2rom $(DESTDIR)$(PREFIX)/libexec/x48ng-dump2rom +# install -c -m 755 dist/x48ng-checkrom $(DESTDIR)$(PREFIX)/libexec/x48ng-checkrom - install -m 755 -d -- $(DESTDIR)$(MANDIR)/man1 - sed "s|@VERSION@|$(VERSION_MAJOR).$(VERSION_MINOR).$(PATCHLEVEL)|g" dist/x48ng.man.1 > $(DESTDIR)$(MANDIR)/man1/x48ng.1 +# install -m 755 -d -- $(DESTDIR)$(MANDIR)/man1 +# sed "s|@VERSION@|$(VERSION_MAJOR).$(VERSION_MINOR).$(PATCHLEVEL)|g" dist/x48ng.man.1 > $(DESTDIR)$(MANDIR)/man1/x48ng.1 - install -m 755 -d -- $(DESTDIR)$(DOCDIR) - cp -R AUTHORS LICENSE README* doc* romdump/ $(DESTDIR)$(DOCDIR) - install -c -m 644 dist/config.lua $(DESTDIR)$(DOCDIR)/config.lua +# install -m 755 -d -- $(DESTDIR)$(DOCDIR) +# cp -R AUTHORS LICENSE README* doc* romdump/ $(DESTDIR)$(DOCDIR) +# install -c -m 644 dist/config.lua $(DESTDIR)$(DOCDIR)/config.lua - install -m 755 -d -- $(DESTDIR)$(PREFIX)/share/applications - sed "s|@PREFIX@|$(PREFIX)|g" dist/x48ng.desktop > $(DESTDIR)$(PREFIX)/share/applications/x48ng.desktop +# install -m 755 -d -- $(DESTDIR)$(PREFIX)/share/applications +# sed "s|@PREFIX@|$(PREFIX)|g" dist/x48ng.desktop > $(DESTDIR)$(PREFIX)/share/applications/x48ng.desktop diff --git a/dist/config.lua b/dist/config.lua deleted file mode 100644 index bc46abb..0000000 --- a/dist/config.lua +++ /dev/null @@ -1,39 +0,0 @@ --------------------------------------------------------------------------------- --- Configuration file for x48ng --- This is a comment --- `config_dir` is relative to $XDG_CONFIG_HOME/, or $HOME/.config/ or absolute -config_dir = "x48ng" - --- Pathes are either relative to `config_dir` or absolute -rom = "rom" -ram = "ram" -state = "state" -port1 = "port1" -port2 = "port2" - -pseudo_terminal = false -serial = false -serial_line = "/dev/ttyS0" - -verbose = false -debugger = false -throttle = false - --------------------- --- User Interface -- --------------------- -frontend = "x11" -- possible values: "x11", "sdl", "tui", "tui-small", "tui-tiny" -hide_chrome = false -fullscreen = false -mono = false -gray = false -leave_shift_keys = false -inhibit_shutdown = false - -x11_visual = "default" -netbook = false -font_small = "-*-fixed-bold-r-normal-*-14-*-*-*-*-*-iso8859-1" -font_medium = "-*-fixed-bold-r-normal-*-15-*-*-*-*-*-iso8859-1" -font_large = "-*-fixed-medium-r-normal-*-20-*-*-*-*-*-iso8859-1" -font_devices = "-*-fixed-medium-r-normal-*-12-*-*-*-*-*-iso8859-1" --------------------------------------------------------------------------------- diff --git a/dist/hplogo.png b/dist/hplogo.png deleted file mode 100644 index a4fff9f..0000000 Binary files a/dist/hplogo.png and /dev/null differ diff --git a/dist/x48ng.desktop b/dist/x48ng.desktop deleted file mode 100644 index 4448b8b..0000000 --- a/dist/x48ng.desktop +++ /dev/null @@ -1,9 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Exec=@PREFIX@/bin/x48ng -Name=x48ng -Icon=@PREFIX@/share/x48ng/hplogo.png -Categories=Utility; diff --git a/dist/x48ng.man.1 b/dist/x48ng.man.1 deleted file mode 100644 index aad16e6..0000000 --- a/dist/x48ng.man.1 +++ /dev/null @@ -1,218 +0,0 @@ -.\" # @configure_input@ -.\" -.\" $Id$ -.\" Copyright (c) 2005 G. Allen Morris III -.\" -.\" Permission is hereby granted, free of charge, to any person obtaining -.\" a copy of this software and associated documentation files (the -.\" "Software"), to deal in the Software without restriction, including -.\" without limitation the rights to use, copy, modify, merge, publish, -.\" distribute, sublicense, and/or sell copies of the Software, and to -.\" permit persons to whom the Software is furnished to do so, subject to -.\" the following conditions: -.\" -.\" The above copyright notice and this permission notice shall be included -.\" in all copies or substantial portions of the Software. -.\" -.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR -.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -.\" OTHER DEALINGS IN THE SOFTWARE. -.\" -.\" Except as contained in this notice, the name of the X Consortium shall -.\" not be used in advertising or otherwise to promote the sale, use or -.\" other dealings in this Software without prior written authorization -.\" from the X Consortium. -.\" -.\" $XFree86: xc/programs/xcalc/xcalc.man,v 1.5 2003/03/19 01:49:28 dawes Exp $ -.\" -.de EX \"Begin example -.ne 5 -.if n .sp 1 -.if t .sp .5 -.nf -.in +.5i -.. -.de EE -.fi -.in -.5i -.if n .sp 1 -.if t .sp .5 -.. -.TH X48NG 1 "14 September 2023" "Version @VERSION@" "X48NG Manual Pages" -.SH NAME -x48ng \- scientific calculator and an HP 48 emulator -.SH SYNOPSIS -.B x48ng -[\--options ...] - -where options include (depending on compiled front-ends): -.br - \-h \-\-help what you are reading -.br - \-v \-\-version show version -.br - \-\-print\-config print configuration as config file -.br - \-c \-\-config= use as x48ng's config file (default: ~/.config/x48ng/config.lua) -.br - \-\-config\-dir= use as x48ng's home (default: ~/.config/x48ng/) -.br - \-\-rom= use (absolute or relative to ) as ROM (default: rom) -.br - \-\-ram= use (absolute or relative to ) as RAM (default: ram) -.br - \-\-state= use (absolute or relative to ) as STATE (default: hp48) -.br - \-\-port1= use (absolute or relative to ) as PORT1 (default: port1) -.br - \-\-port2= use (absolute or relative to ) as PORT2 (default: port2) -.br - \-\-serial\-line= use as serial device default: /dev/ttyS0) -.br - \-V \-\-verbose be verbose (default: false) -.br - \-\-x11 use X11 front-end (default: true) -.br - \-\-sdl2 use SDL2 front-end (default: false) -.br - \-\-sdl use SDL front-end (DEPRECATED) (default: false) -.br - \-\-tui use terminal front-end (default: false) -.br - \-\-tui\-small use text small front-end (2×2 pixels per character) (default: false) -.br - \-\-tui\-tiny use text tiny front-end (2×2 pixels per character) (default: false) -.br - \-t \-\-terminal activate pseudo terminal interface (default: false) -.br - \-s \-\-serial activate serial interface (default: false) -.br - \-\-debug enable the debugger -.br - \-r \-\-reset perform a reset on startup -.br - \-T \-\-throttle try to emulate real speed (default: false) -.br - \-\-no\-chrome only display the LCD (default: false) -.br - \-\-fullscreen make the UI fullscreen (default: false) -.br - \-\-scale= scale the SDL2 UI by -.br - \-\-netbook make the UI horizontal (default: false) -.br - \-\-visual= use visual (default: default), possible values: -.br - \-\-small\-font= use as small font -.br - \-\-medium\-font= use as medium font -.br - \-\-large\-font= use as large font -.br - \-\-connection\-font= use as connection font -.br - \-\-mono make the UI monochrome (default: false) -.br - \-\-gray make the UI grayscale (default: false) -.br - \-\-leave\-shift\-keys _not_ mapping the shift keys to let them free for numbers (default: false) -.br - \-\-inhibit\-shutdown __tentative fix for stuck-on-OFF bug__ (default: false) - - -.SH DESCRIPTION -.I x48ng -is a scientific calculator desktop accessory that emulate an HP\-48 SX -or an HP\-48 GX. -\" .SH OPTIONS -\" .PP -\" \fIx48ng\fP accepts all of the standard toolkit command line options along -\" with several additional options: -\" .PP -\" .TP 8 -\" .B \-help -\" Show a list of options. -\" .PP -\" .TP 8 -\" .B \-version -\" This causes x48ng to print a version number to the standard output. -\" .PP -\" .TP 8 -\" .B \-iconic -\" Start iconic -\" .SH OPERATION - -.PP -x48ng emulates an HP 48 calculator. This manual does not attempt to -describe the operation of the HP calulator, but only the user interface -to the emulator. - -\" .I Pointer Usage: -\" When mouse button one is press on an x48ng key the key is depress until -\" the mouse button is released. If you wish to have more than one key -\" press at a time mouse button 3 may be used. Button pressed with mouse -\" button 3 will remain pressed until mouse button 1 is used. For example -\" to reset the calulator you can press the A key and the F key with mouse -\" button 3 and then press the on button with mouse button 1. - -\" Mouse button 2 will paste the text in the cut buffer to the calculator -\" if it is press in the display area of the calculator. See notes on -\" pasting text into the calculator below. - -\" Use of mouse elsewhere on the image of the calculator is undefined. - -.SH ACCELERATORS - -The keyboard may be used to input data into the x48ng. -The number keys on the keyboard coresponds to the number buttons on -the calaculator, and the alphbetic keys on the keyboard control the -buttons on the top half of the calculator and the @code{+/-} and -@code{EXX} keys. - -The @code{ENTER} button is attached to the Enter key, the delete key -to the <-/DROP button and Divide, multiply, subtract and add buttons to -the /, *, -, and + keys on the key board. - -.SH --tui SPECIAL KEYBINDINGS - -I had to be a bit 'creative' mapping keys there: - -- [On] is either [F4] or [Esc] or [Home] or [\\] - -- [Left Shift] is either [F5] or [PgUp] or [[] - -- [Right Shift] is either [F6] or [PgDn] or []] - -- [Alpha] is either [F8] or [Ins] or [;] - -To quit `x48ng --tui` use [F10] or [Shift+End] or [|] - - -.SH COLORS -The x48ng is trying to look like a particular device. -The colors are therefore not selectable. -.br -\" .SH "ENVIRONMENT" -\" XUSERFILESEARCHPATH -\" .SH "SEE ALSO" -\" X(7x), xrdb(1) -.SH BUGS -.PP -Bugs can be found and reported at: https://github.com/gwenhael-le-moine/x48ng -.SH COPYRIGHT -Copyright \(co 2023- Gwenhael Le Moine -.br -Copyright \(co 1994-2005 Eddie C. Dost -.br -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -.SH AUTHORS -Gwenhael Le Moine -.br -Eddie C. Dost -.br -G. Allen Morris III diff --git a/doc_0.6.4/CARDS.doc b/doc_0.6.4/CARDS.doc deleted file mode 100644 index 51842d9..0000000 --- a/doc_0.6.4/CARDS.doc +++ /dev/null @@ -1,15 +0,0 @@ -Q: How do you dump the Equation Lib? - -A: Well, I guess you would have to use some sort of Card copying - program from the HP48. This should give you an Image of the card. - - 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/.x48ng/port1" or "$HOME/.x48ng/port2". - - 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/doc_0.6.4/ChangeLog.up_to_0.6.4 b/doc_0.6.4/ChangeLog.up_to_0.6.4 deleted file mode 100644 index bd26ab0..0000000 --- a/doc_0.6.4/ChangeLog.up_to_0.6.4 +++ /dev/null @@ -1,230 +0,0 @@ -2011-08-08 "G. Allen Morris III" release 0.6.4 - * Default to throttling speed only when key-pressed - * Add throttle switch for speed emulation - * Fix buffer overflow bug - * release keys on loss of focus - * typo in access_time adjust - -2010-02-01 "G. Allen Morris III" release 0.6.3 - * made updates to x48.spec - * put debian directory in dist file - * install X48 app data in correct place - using pkg-config appdefaultdir xt - * removed more debugging messages - * added 'netbook' look for small/short screens - use +netbook on the command line - -2010-01-30 "G. Allen Morris III" release 0.6.2 - * remove setlocal code that was causing a bug. - * removed some debugging code. - -2009-06-31 "G. Allen Morris III" release 0.6.1 - * Fix to XShm to solve the 'LCD' Scramble problem. - -2006-04-20 "G. Allen Morris III" - * Added simple paste feature - * Repaired debugger non-readline input - * Changed from building with Imakefile to using GNU autoconfig - -2005-03-20 "G. Allen Morris III" - * added equal key for + and Meta Keys for Alpha - * applied a different fix for the arrow repeat key bug - * fixed a bug in the timer one logic. The cursor now flashes on input. - -2005-03-20 "G. Allen Morris III" - * added patch [000390] time.h compile bug - * added patch [000391] Arrow key repeat patch - * added ChangeLog file - -2005-03-18 "G. Allen Morris III" - * starting from x48 0.4.0. -1995/01/16 Version 0.4.0 On the net - - - Implemented CONFIG/UNCNFG more exactly. - - - Added support for different RAM or ROM cards. - - - Added G/GX support (lost of changes) - new colors, new labels, ... - - - Rewrote ROMDump for both S/SX and G/GX. Lots faster now. - Thanks go to Robert Tiismus - - - Corrected handling of Display and Menu images, fixed number - of lines in init_display(), to avoid XShmError on virgin - startup - - - Catch SIGPIPE and save state, so everything is saved, when - x48 gets terminated by xkill or the window manager - - -********************************************************************** - -1994/12/07 Version 0.3.5 On the net - - - Serial and terminal lines now have the baudrate set - correctly. - - . Watch out for the IR (serial) connection: speed is - always set to 2400 Baud by the HP - . On the wire (terminal) connection speed is set to the - selected value - - - Removed stupid rounding in adjtime routine - - . This caused missing of some part of a second when - adjusting the time on the HP - - - Suppress adjusting timer2 if this would cause an - increase of the timer, slow down the timer instead. - - . Thanks go to Lutz Vieweg (he spotted this bug, while - trying to use QED. (lkv@mania.robin.de) - - - Support for contrast control (ON_+, ON_-) added - - - - Started command line parsing... (see below) - - Changes to the X11 Interface - ---------------------------- - - - Implemented color-icon. Show state of HP48 in icon: - - . if 'x48' is displayed, calculator is on. - . if 'x48' is blinking, calculator is transfering data. - - - Implemented use of the WM_SAVE_YOURSELF protocol. - - - x48 now uses Xrm...() functions to parse and use - Xresources and the command line. - - - Better handling of ButtonPresses and KeyPresses - - - The program now sets the WM_COMMAND property - - - Now colors look well on monochrome and gray - - - A new Colormap is allocated if the standard Colormap is full - - - All possible visuals are supported by the color allocation - modell (at least on Linux, I don't really know how to handle - DirectColor ...) - - -********************************************************************** - -1994/11/02 Version 0.3.4 On the net - - - Real time support mostly works (uses system time) - - - Stores ROM, RAM, and Ports in 'compressed' format - - - tty lines work on HPUX - Thanks go to Lutz Vieweg (lkv@mania.robin.de) - - - debugger now works on operating systems, where timers interrupt - the read system call. - - - Debugger now uses Class instruction set - - - Disassembler completed (at least hope so) - - -********************************************************************** - -1994/10/06 Version 0.3.3 On the net - - - - checkrom, a program to test the ROM CRC included - - - tty lines work on IRIX - Thanks go to !!!LOOK AT THE MAIL!!! - - - faster X11 interface - Uses Pixmaps now to update changed nibbles. - Whenever possible uses XSHM Extension to update - the display. - - - Start of debugger implementation - - - Disassembler started (HP & Alonzo) - - - SHUTDN bug fixed (didn't wake on received chars) - Thanks go to Lutz Vieweg (lkv@mania.robin.de) - - - Display bit offset implemented - - -********************************************************************** - -1994/10/02 Version 0.3.2 not published - - - Major speed improvement due to scheduling of emulator - specific events (timers, adjtime, receive, ...) - This *really* speeds up the main emulator loop. - - -********************************************************************** - -1994/09/30 Version 0.3.1 not published - - - Added MAGIC number to ~/.hp48/hp48 file - - - Minor optimizations - - -********************************************************************** - -1994/09/18 Second Release (Version 0.2) - - - Pure X11 interface - - - Start of real time support - - - SHUTDN implemented - - - Keyboard support - - - Compiles better (less warnings) on SunOS, Solaris - - -********************************************************************** - -1994/08/26 Initial Release (Version 0.1) - - - Emulates the HP48sx fairly - - - Compiles well only on Linux - - - Uses XView Panel and Canvas - - - Must be started in source directory - - - No SHUTDN - - - No real time - - - Misses HP48 keyboard interrupts - - - Slow - - -********************************************************************** - -1994/07 Look at em48 by Paul Fox - - - Starts to run like a HP48 - - -********************************************************************** - -1994/05 First Versions - - - No Display at all, merely debugging output - - -********************************************************************** - -1994/04 Fed up with stupid Desktop Calculators - diff --git a/doc_0.6.4/INSTALLING b/doc_0.6.4/INSTALLING deleted file mode 100644 index f2321c6..0000000 --- a/doc_0.6.4/INSTALLING +++ /dev/null @@ -1,34 +0,0 @@ -INSTALLATION -============ - -I improved handling of differences in Solaris, SunOS, HP/UX, and Linux. -Things are not perfect, anyway. - -To configure some things for the Makefiles, edit 'config.h' in the -directory 'x48-0.4.0'. There you can set the compiler, flags to -pass to the compiler, and some other stuff. - -To build the emulator do the following in the directory 'x48-0.4.0': - - 1. xmkmf - 2. make - -This should give you the programs 'x48', 'dump2rom', and 'checkrom' -'mkcard' in the directory 'x48-0.4.0/bin'. - -To get the serial line working, you should set up your .Xdefaults for -x48. The resources concerning the serial line are: - -x48*useSerial: True -x48*serialLine: /dev/ttyS0 ; your serial device here, this - ; looks good for Linux. - -Run 'x48 -help' for a list of command line options. - -Look at 'x48-0.4.0/src/X48.ad' for the whole set of Xresources the -program uses. - -To use RAM cards (128K or 32K on the SX, up to 4M on the GX), use the -program 'mkcard', and put the resulting file in the directory ~/.hp48/ -in a file called 'port1' or 'port2'. - diff --git a/doc_0.6.4/README_0.6.4 b/doc_0.6.4/README_0.6.4 deleted file mode 100644 index ce0f217..0000000 --- a/doc_0.6.4/README_0.6.4 +++ /dev/null @@ -1,356 +0,0 @@ -x48 -- HP48 CPU emulator -======================== - -This is x48, an HP48 CPU emulator. This is Version 0.6.4 - -if the 'LCD' is scrambled, you might try running x48 in one of the 3 ways below -to see if that will solve the problem. - -1. run 'x48 +xshm' -2. put 'x48*useXShm: False' in you .Xdefaults file (man xrdb) -3. run './configure --disable-shm' to build x48 without the Shared memory extention. - -If it does please leave a bug report at https://github.com/gwenhael-le-moine/x48/issues - -====== - -for version 0.4.0 - -What's new: - - - Implemented CONFIG/UNCNFG more exactly. - - - Added support for different RAM or ROM cards. - - - Added G/GX support (lost of changes) - new colors, new labels, ... - - - Rewrote ROMDump for both S/SX and G/GX. Lots faster now. - Thanks go to Robert Tiismus - - - Corrected handling of Display and Menu images, fixed number - of lines in init_display(), to avoid XShmError on virgin - startup - - - Catch SIGPIPE and save state, so everything is saved, when - x48 gets terminated by xkill or the window manager - - -NOTE (from EM48 README by Paul Fox) -=================================== - -This emulator is capable of providing a faithful replication of the -HP48. In order to do so, it requires a copy of the ROM software -from YOUR calculator. In order to avoid breaking copyright laws, -and upsetting HP, you MUST BE THE PROUD OWNER OF AN HP48 before -running this program. Of course you can run this program without a -copy of the ROM software in order to write trivial machine code -programs but you will not be able to access any of the calculator -functionality. - -Instructions on how to download a copy of the ROM are provided -later in this document. - - -CREDITS -======= - - -I would like to thank Robert Tiismus -for his help with ROMDump for the G/GX. The ROMDump utility gained -a lot of speed and works for both S/SX and G/GX now. - - -I used SADHP to disassemble parts of the 48's ROM and some other -programs to test x48, also I very closely looked at SADHP while -writing code for RPL debugging. So here go sincere thanks: - --- Jan Brittenson --- Mika Heiskanen - -Latest version of SADHP is available from - wuarchive.wust.edu:/systems/hp/hp48Uploads/ -Get it to look deeper into your HP48. - - -I would like to thank Lutz Vieweg for his -outstanding bug reports. Must be the crazyness of porting gcc to -the 48, and of writing code in assembler, that digs out all the -bugs in x48. Go on like this Lutz. - - -I must thank Joe Ervin for his article on keyboard handling. - - -I also must thank Paul Fox, Author of EM48, for his work on his -emulator, the source code was a great help for solving some problems, -specially the memory bank switching. Thanks Paul. - - -I would also like to thank Alonzo Gariepy for his contribution to -the world on how the HP28/HP48 works. - - -I would sincerely like to ask HP about giving me a 48 GX, so the world -could receive more complete x48, also I could use some ROM cards, like -the EQ-LIB to implement an easy use of these. Well, I credited HP in -the last releases, but now x48 really gets running and I still haven't -heard a word from them... -Just remember, x48 comes under the terms and conditions of the GPL. - - -HACKERS PLEA -============ - -I will continue to work on this product and support it where I have -the time, and would therefore appreciate any patches or bug fixes, -etc which any of you make so that I can keep control of the software. - -Information in the form of loose english, context diffs, or -suggestions are welcome so that we can all make this product a -little better. - - -INSTALLATION -============ - -I improved handling of differences in Solaris, SunOS, HP/UX, and Linux. -Things are not perfect, anyway. - -To configure some things for the Makefiles, edit 'config.h' in the -directory 'x48-0.4.0'. There you can set the compiler, flags to -pass to the compiler, and some other stuff. - -To build the emulator do the following in the directory 'x48-0.4.0': - - 1. xmkmf - 2. make - -This should give you the programs 'x48', 'dump2rom', 'checkrom', and -'mkcard' in the directory 'x48-0.4.0/bin'. - -To get the serial line working, you should set up your .Xdefaults for -x48. The resources concerning the serial line are: - -x48*useSerial: True -x48*serialLine: /dev/ttyS0 ; your serial device here, this - ; looks good for Linux. - -Run 'x48 -help' for a list of command line options. - -Look at 'x48-0.4.0/src/X48.ad' for the whole set of Xresources the -program uses. - - -HOW TO DOWNLOAD A COPY OF THE ROM -================================= - -The emulator works by executing an image of the HP48s ROM. In order -to run the emulator you must have a version of your ROM on the system. - -********************************************************************** -* This includes the HIDDEN ROM. Please don't use DUMP programs, that * -* don't dump the HIDDEN ROM. The emulator won't run. * -********************************************************************** - - -To get a memory dump you need to do the following: - - -- Download the file 'romdump/ROMDump' to your HP. - -- To capture a complete ROM, start kermit on your computer, set the - line so it fits your HP, set the speed to 9600 baud and type - 'log session', then 'connect'. - -- On a HP48 S/SX type '#0h #7FFFFh ROMDump', - on a HP48 G/GX type '#0h #FFFFFh ROMDump'. - This will take about 15 minutes on the S/SX, 30 minutes on the G/GX. - -- When done, type the kermit-Escape (usually CTRL-\) followed - by 'C' on your Computer. Say 'quit' to the kermit. - -Your ROM should now be in the file 'session.log'. - - - -Now you have a file containing lines like - -#00000:2369B108DADF1008 -... - -This has to be converted to a binary ROM for x48. - -Run the command: `dump2rom session.log` -This will convert your dump into a rom file readable by the emulator -called 'rom.dump'. - -CHECK the file with the program 'checkrom'. -Type: `checkrom rom.dump`. It should say: - - ROM Version is HP48-A - ROM CRC reads 0xcb76 (for Rev. A, will be different for other ROMs) - IROM OK: ROM CRC test passed. - -or - - ROM Version is HP48-R - ROM CRC 1 reads 0xdfed (for Rev. R, will be different for other ROMs) - ROM CRC 2 reads 0xf0b1 ( --- " --- ) - IROM OK: ROM CRC test passed. - -If the test failed, something went wrong transfering the ROM. Don't -start thinking about the size or the nibbles in 'rom.dump'. That's -all correct. Do the Transfer again. - -If you know how to do it, you could of course only transfer the -'broken' part of the dump, using e.g. '#60000h #60080h ROMDump' -and fix these lines in 'session.log'. - - -USING THE EMULATOR -================== - -Go into the directory, where your ROM dump resides and type 'x48', or -type 'x48 -rom ', where is the file containing your -ROM dump. - -On the first start the emulator will read the ROM dump. -It will start running at the addr 00000. This will result in the -question 'Try to recover memory?' Answer 'NO'. - -To use the emulator, click your mouse at the buttons -on the emulator. You have to press the button down long enough, so -the HP-48 will considder it a keypress. Well, this should work. - -To do something like ON-E, or ON-A-F, one would use the middle mouse -button to press ON, then the middle mouse button to press A. These -keys should stay depressed. Now use the left mouse button to press F. -This should release all three keys and yield the desired results. - -You can check your ROM dump by pressing ON-E. This enters the selftest -of the HP-48. If it says IROM OK after some time, your ROM CRC has -been calculated correctly. - -The SX emulator has 32K RAM and two 128K RAM cards, both read/write. -To access all memory you have to do: 1 MERGE 2 MERGE -The GX emulator has 128K RAM and no RAM cards, yet. -To access all memory you have to do: 1 MERGE 2 MERGE - -When you hit the 'quit' button of the window frame (under ol(v)wm), -the emulator saves its state, RAM, ROM, and the ports to files in -the directory '$HOME/.hp48/', so the next time it is started, all -your stuff should be still there. - -If the emulator gets messed up, or crashes, enter the debugger -by typing CTRL-C in the shell you started x48. At the prompt type -`reset`, confirm with `y`. Then type `cont`. - -If this does not help, enter the debugger again, and type -`exit`, confirm with `y`. This will NOT save the stuff, so the next -time you use x48, it should be in the same state as on the last run. - -Another way to achive this, is to send SIGTERM or SIGKILL to x48. - - -USING RAM CARDS -=============== - -To get a RAM card, use the program 'mkcard' to build the card, and -copy the resulting file to $HOME/.hp48/port1 or $HOME/.hp48/port2. -On the next start of the emulator, the card should be detected and -usable. (Maybe you have to turn it off, and on again...) - - -KEYBOARD SUPPORT -================ - -I have added simple keyboard support: - -The keys 'A' - 'Z', '0' - '9', '+', '-', '*', '/', 'RETURN', '.', 'SPACE', -'DELETE', and 'BACKSPACE' are mapped to the according keys on the HP-48's -keyboard. The SHIFT keys give you the Orange and Blue shifts. 'ALT' gives -you the `alpha' key, and 'ESC' the `ON' key. -The keys 'F1' - 'F2' also access the menu labels on the HP. The cursor keys -give you the HP-48 keys 'K', 'P', 'Q', and 'R'. - -Note that the key 'A' doesn't give you the letter "A" on the HP, but the -button in Row 1, Column 1 on the HP keyboard. The function executed depends -on the Shift State of the HP. - -To do something like 'ON-A-F', press and hold `ESC', then press and hold -`A', then press `F' and release all buttons. - - -TALKING TO THE OUTSIDE WORLD -============================ - -The emulator shows one line similar to: - - wire:/dev/ttyp2 IR:/dev/ttyS0 - -right below it's display. - -If you have a backup off your real HP-48 on your computer, you -could restore it using kermit: - -On the emulator enter the IO menu, hit SETUP, configure to - wire, binary, 9600, none, 1, 3. - -'wire' is the local computer connection, 'IR' talks to the serial -line of your computer. This is strange, but the other way around -it does not work, yet. - -Go to the IO menu again. Hit SERVER. The emulator says: - Awaiting Server Command - -On your computer take an unused xterm, go to the directory where -you keep your backups, and start kermit. Configure the line: - -type 'set line /dev/ttyp2' <---- use the number from the line - below the display !!! - -This should be the pseudo terminal connected to your emulator. - -At the kermit prompt type: 'send backup18.08.1994', or however your -backup was called. There should be communication going. - -After the transfer you should have a VAR 'backup18.08.1994'. Hit -the menu key for it. It says BackupHOMEDIR. Type RESTORE. That's -all. - - -Talking to the serial line, to e.g. another real HP-48 works the -same, just configure the IO to IR. - -!!! Note that the communcication speed is 2400 Baud here, - because the emulator, or better the HP48, thinks he is - doing IR transfer. - - -KNOWN BUGS -========== - -Very slow, especially the GX compared to a real GX. - -Lots of guesses in the devices section of the emulator. I could realy -use the 'SATURN HARDWARE SPECIFICATION' from HP. If anyone has access -to it, send a copy, or tell me where to get it. - -Documentation is missing. There should be a file 'x48.texinfo' to -describe the various options and flags of x48. - - -ACCESS TO THE AUTHOR -==================== - -Please send any bug reports, context-diffs or suggestions to - -ecd@dressler.de - -Eddie C. Dost -61, Rue de la Chapelle -4850 Moresnet-Chapelle -Belgium - -Have Fun. diff --git a/doc_0.6.4/TODO b/doc_0.6.4/TODO deleted file mode 100644 index 79d6f60..0000000 --- a/doc_0.6.4/TODO +++ /dev/null @@ -1,35 +0,0 @@ -TODO -- HP48sx Emulator x48 -=========================== - -Write an MMU. Will increase speed significantly. - -Contact Eric Bryntse: - - ask for description of his Gateway-48 library - to trace down the following bug: - When an alarm wakes up x48, it is not starting - the exec without being given a password. - -Find a way to handle NumLock on those Solaris OpenWindows machines... -(take a look at xterm source) - -There should be a menu popping up when the HP Logo in the top left is -hit. It should contain some useful things like - - - RESET BUTTON - - Configuration (Serial, start kermit automatically, ...) - - Port configuration (pull card, insert ROM/RAM card, etc.) - - Pop up a window with debug outputs (speed, cpu usage, PC, ...) - - The 'About x48' field - -!!! Implement an Instruction Cache ... !!! <- SPEED - -Speed up register arithmetic. +- SPEED - -Implement a function "load file (filename)": - - - Read a file starting with "HPHP48-%c" - - try putting it on the stack as HP Object - - should not be hard to store it in a variable called 'filename' then - - --> Here we got a fast bypass to the kermit protocol. - diff --git a/romdump/README b/romdump/README deleted file mode 100644 index ff312c1..0000000 --- a/romdump/README +++ /dev/null @@ -1,63 +0,0 @@ -This file is part of ROMDump, a ROM dump utilty for the HP48sx Calculator. -Copyright (C) 1994 Eddie C. Dost (ecd@dressler.de) - -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 2 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, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - - -This is ROMDump, a utility to dump the ROM of ANY HP48 -====================================================== - - - -Usage: (2:hxs, 1:hxs --> ) pop start address from level 2, - pop end address from level 1, and dump - ROM to the serial at 9600 baud using - lines of form "aaaaa:hhhhhhhhhhhhhhhh\n\r" - with 16 nibbles ROM data hhhhhhhhhhhhhhhh - at address aaaaa. - - - -- Download the file ROMDump to your HP. - -- To capture a complete ROM, start kermit on your computer, - set the line so that it fits your HP (use speed == 9600) - and type 'log session', then 'connect'. - -- On your HP48 S/SX type '#0h #7FFF0h ROMDump' or on the G/GX - '#0h #FFFF0h ROMDump'. This will give you a complete ROM dump. - This will take about 15 minutes on the S/SX, 30 minutes on the G/GX. - -- When done, type the kermit-Escape (usually CTRL-\) followed - by 'C' on your Computer. Say 'quit' to the kermit. - -- Your ROM should now be in the file 'session.log'. - - - -- To dump a certain range of ROM, enter the start-address in hex - and the end address in hex, and press 'ROMDump'. - - (For example: '#7FFF0h #7FFFFh' ROMDump will output - "7FFF0:84054383D21467BC\n\r" on a Version A S/SX.) - - -I have included the assembler source (class version) for those -interested in fiddling with the hidden ROM... - - - -Eddie C. Dost (ecd@dressler.de) diff --git a/romdump/ROMDump b/romdump/ROMDump deleted file mode 100644 index a8f101e..0000000 Binary files a/romdump/ROMDump and /dev/null differ diff --git a/romdump/ROMDump.s b/romdump/ROMDump.s deleted file mode 100644 index ccfe250..0000000 --- a/romdump/ROMDump.s +++ /dev/null @@ -1,464 +0,0 @@ -; -; $Id: ROMDump.s,v 1.4 1995/01/11 18:21:36 ecd Exp ecd $ -; -; This file is part of ROMDump, a ROM dump utility for the HP48 Calculator. -; Copyright (C) 1994 Eddie C. Dost (ecd@dressler.de) -; -; 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 2 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, write to the Free Software -; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -; -; Usage: -; -; (2: hxs, 1: hxs --> ) pop start address from level 2, -; pop end address from level 1, and dump -; ROM to the serial at 9600 baud using -; lines of form "aaaaa:hhhhhhhhhhhhhhhh\n\r" -; with 16 nibbles ROM data hhhhhhhhhhhhhhhh -; at address aaaaa. -; -; machine independent addresses (supported by HP) -; -AllowIntr equ $010e5 -DisableIntr equ $01115 -DOBINT equ $02911 -DOCOL equ $02d9d -DOCODE equ $02dcc -SEMI equ $0312b -GETPTRLOOP equ $05143 -SAVPTR equ $0679b -GETPTR equ $067d2 -CK2NOLASTWD equ $18a8d -CKandDISPATCH1 equ $18fb2 -VERSTRING equ $30794 -PopASavptr equ $3251c -; -; machine independent addresses (NOT supported by HP) -; -POPHXS equ $53f8d - -; -; machine dependent addresses -; -sx_GosubHidC equ $026bf -sx_prog_low equ $700f1 ; IRAMBUFF -sx_prog_high equ $f00f1 ; IRAMBUFF when RAM configured high - -gx_GosubHidC equ $026ca -gx_prog_low equ $800f5 ; IRAMBUFF -gx_prog_high equ $c00f5 ; IRAMBUFF when RAM configured high -gx_LINECOUNT equ $8069a - -; -; flags used -; -sGX equ 0 -sHIGH equ 1 - -; -; begin off assembler code -; - textr "HPHP48-R" - - dcr.5 DOCOL - dcr.5 CK2NOLASTWD - dcr.5 CKandDISPATCH1 - dcr.5 DOBINT - dcr.5 $000bb - - ; - ; only executed when (2: hxs, 1: hxs) - ; - dcr.5 DOCOL - dcr.5 VERSTRING - - dcr.5 DOCODE -code_start - dcr.5 code_end-code_start - - jsr DisableIntr - - ; - ; figure out version - ; - jsr PopASavptr - move.1 #0, p - move.5 #24, c.p - add.a c, a - move.a a, d1 - move.b (d1), a - move.2 #$4a, c.p ; 'J' == last version for S/SX - bclr #sGX, st - ble.b a, c, got_version - bset #sGX, st -got_version - bclr #sHIGH, st - - ; - ; get arguments - ; - jsr GETPTR - jsr POPHXS - move.1 #0, p - move.5 #$ffff0, c.p - and.a c, a - move.a a, r4 - - jsr GETPTR - jsr POPHXS - move.1 #0, p - move.5 #$ffff0, c.p - and.a c, a - move.a a, r3 - - ; - ; open IO - ; - move.5 #$00110, d1 - move.1 #8, a.p - move.1 a, (d1) - - ; - ; set speed to 9600 baud - ; - move.2 #$0d, d1 - move.1 #6, a.p - move.1 a, (d1) - - ; - ; dump ROM $00000 - $6ffff - ; -dump_rom_0 - move.a r3, a - move.5 #$6fff0, c.p - bgt.a a, c, dump_rom_7 - move.a a, r1 - - move.a r4, c - move.a c, b - move.5 #$6fff0, c.p - ble.a b, c, end_addr_0 - move.a c, b -end_addr_0 - subr.a b, a - bcc continue_0 - bra.3 dump_done -continue_0 - move.a a, r2 - - bsr.3 prog_start - - move.5 #$70000, a.p - move.a a, r3 - - ; - ; dump ROM $70000 - $7ffff - ; -dump_rom_7 - move.a r3, a - move.5 #$7fff0, c.p - bgt.a a, c, dump_done_7 - bra.3 continue_7 -dump_done_7 - bbs #sGX, st, continue_8 - bra.3 dump_done -continue_8 - bra.3 dump_rom_8 -continue_7 - move.a a, r1 - - move.a r4, c - move.a c, b - move.5 #$7fff0, c.p - ble.a b, c, end_addr_7 - move.a c, b -end_addr_7 - subr.a b, a - bcc continue_7_2 - bra.3 dump_done -continue_7_2 - move.a a, r2 - - bbs #sGX, st, gx_dump_rom_7 - bsr.3 copy_prog - move.5 #sx_prog_high, c.p - jsr sx_GosubHidC - bsr.3 copy_prog - bra.3 dump_done - -gx_dump_rom_7 - ; - ; unconfigure devices at 7e000 - 7ffff - ; - move.5 #$7f000, c.p - uncnfg - move.5 #$7e000, c.p - uncnfg - - bsr.3 prog_start - - ; - ; reconfigure devices at 7e000 - 7ffff - ; - move.5 #$ff000, c.p - config - move.5 #$7f000, c.p - config - move.5 #$ff000, c.p - config - move.5 #$7e000, c.p - config - - move.5 #$80000, a.p - move.a a, r3 - - ; - ; dump ROM $80000 - $bffff - ; -dump_rom_8 - move.a r3, a - move.5 #$bfff0, c.p - bgt.a a, c, dump_rom_c - move.a a, r1 - - move.a r4, c - move.a c, b - move.5 #$bfff0, c.p - ble.a b, c, end_addr_8 - move.a c, b -end_addr_8 - subr.a b, a - bcc continue_8_2 - bra.3 dump_done -continue_8_2 - move.a a, r2 - - bsr.3 copy_prog - move.5 #gx_prog_high, c.p - jsr gx_GosubHidC - bsr.3 copy_prog - - move.5 #$c0000, a.p - move.a a, r3 - - ; - ; dump ROM $c0000 - $fffff - ; -dump_rom_c - move.a r3, a - move.a a, r1 - - move.a r4, c - move.a c, b - move.5 #$ffff0, c.p - ble.a b, c, end_addr_c - move.a c, b -end_addr_c - subr.a b, a - bcs dump_done - move.a a, r2 - - bsr.3 copy_prog - bset #sHIGH, st - jsr gx_prog_low - bsr.3 copy_prog - -dump_done - ; - ; close IO - ; - bsr.3 send_crnl - move.5 #$00110, d1 - move.1 #0, a.p - move.1 a, (d1) - - ; - ; back to RPL - ; - jsr AllowIntr - jmp GETPTRLOOP - -; -; exchange program with memory at address prog_low -; -copy_prog - move.a pc, c -prog_offset - move.5 #prog_start-prog_offset, a.p - add.a a, c - move.a c, d0 - bbs #sGX, st, gx_addr - move.5 #sx_prog_low, d1 - bra.3 sx_addr -gx_addr - move.5 #gx_prog_low, d1 -sx_addr - move.5 #prog_end-prog_start, a.p - lsr.a #4, a - move.a a, b - -copy_word - move.w (d0), a - move.w (d1), c - move.w c, (d0) - move.w a, (d1) - add.a #16, d0 - add.a #16, d1 - dec.a b - bcc copy_word - rtn - -; -; this is the start of the actual dump routine -; -prog_start - bbc #sHIGH, st, skip_uncover_c - ; - ; uncover ROM at c0000 - fffff - ; - move.5 #$7f000, d0 - move.b (d0), c - move.5 #gx_LINECOUNT, d0 - move.b (d0), c - bset #7, c - move.b c, (d0) - move.5 #$00128, d0 - move.b c, (d0) - move.5 #$c0000, c.p - uncnfg - uncnfg - -skip_uncover_c - ; - ; get start address and number of words - ; - move.a r1, a - move.a a, d0 - move.a r2, a - - ; - ; dump the ROM - ; -loop - move.a a, r0 - bsr.3 send_addr - move.2 #$3a, c.p - bsr.3 send_char - move.w (d0), c - bsr.3 send_data - bsr.3 send_crnl - - add.a #16, d0 - move.a r0, a - sub.a #16, a - bcc loop - - bbc #sHIGH, st, skip_cover_c - ; - ; reconfigure memory ports at c0000 - ; - move.5 #$c0000, c.p - config - config - config - config - move.5 #gx_LINECOUNT, d0 - move.b (d0), c - bclr #7, c - move.b c, (d0) - move.5 #$00128, d0 - move.b c, (d0) - move.5 #$7f040, d0 - move.b (d0), c - -skip_cover_c - rtn - -; -; send data in C.W as hex characters -; -send_data - move.w c, b - move.2 #$0f, c.p - move.b c, d - bra.3 send_all - -; -; send addr in D0 as hex characters -; -send_addr - exg.a a, d0 - move.a a, c - exg.a a, d0 - exg.1 p, c.4 - exg.1 p, c.0 - exg.1 p, c.4 - exg.1 p, c.3 - exg.1 p, c.1 - exg.1 p, c.3 - move.a c, b - move.2 #$04, c.p - move.b c, d - -; -; send D.B many nibbles from B.W -; -send_all - clr.b c - move.p b, c - bsr.3 send_hex_nib - lsr.w #4, b - dec.b d - bcc send_all - rtn - -; -; send "\n\r" -; -send_crnl - move.2 #$0d, c.p - bsr.3 send_char - move.2 #$0a, c.p - bsr.3 send_char - rtn - -; -; send nibble in C.B as hex character -; -send_hex_nib - move.2 #$30, a.p - add.b a, c - move.2 #$39, a.p - ble.b c, a, send_char - move.2 #$07, a.p - add.b a, c -; -; send character in C.B -; -send_char - move.5 #$00112, d1 -xmtrdy - move.1 (d1), a - bbs #0, a, xmtrdy - move.2 #$16, d1 - move.b c, (d1) - rtn - -prog_end - dcr.8 $00000000 - dcr.8 $00000000 - -code_end - - dcr.5 SEMI ; end of DISPATCH - dcr.5 SEMI ; end of program object diff --git a/sdl-screenshot.png b/sdl-screenshot.png deleted file mode 100644 index 490ab4c..0000000 Binary files a/sdl-screenshot.png and /dev/null differ diff --git a/src/config.c b/src/config.c deleted file mode 100644 index 05f7601..0000000 --- a/src/config.c +++ /dev/null @@ -1,752 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include "config.h" - -config_t config = { - .progname = ( char* )"x48ng", - - .verbose = false, - .print_config = false, - .useTerminal = false, - .useSerial = false, - .useDebugger = false, - .throttle = false, - .resetOnStartup = false, - - .serialLine = NULL, - - .frontend_type = FRONTEND_TEXT, - - .leave_shift_keys = false, - .inhibit_shutdown = false, - - .mono = false, - .gray = false, - - /* tui */ - .small = false, - .tiny = false, - - /* sdl */ - .hide_chrome = false, - .show_ui_fullscreen = false, - .scale = 1.0, - - /* x11 */ - .netbook = false, - .name = ( char* )"x48ng", - .title = ( char* )"x48ng", - .x11_visual = NULL, - /* default | staticgray | staticcolor | truecolor | grayscale | - * pseudocolor | directcolor | 0xnn | nn - */ - .monoIcon = false, - .iconic = false, - .xrm = true, - .smallFont = NULL, - .mediumFont = NULL, - .largeFont = NULL, - .connFont = NULL, -}; - -char* configDir = ( char* )"x48ng"; -char* config_file = ( char* )"config.lua"; -char* romFileName = NULL; -char* ramFileName = NULL; -char* stateFileName = NULL; -char* port1FileName = NULL; -char* port2FileName = NULL; - -char normalized_config_path[ MAX_LENGTH_FILENAME ]; -char normalized_config_file[ MAX_LENGTH_FILENAME ]; -char normalized_rom_path[ MAX_LENGTH_FILENAME ]; -char normalized_ram_path[ MAX_LENGTH_FILENAME ]; -char normalized_state_path[ MAX_LENGTH_FILENAME ]; -char normalized_port1_path[ MAX_LENGTH_FILENAME ]; -char normalized_port2_path[ MAX_LENGTH_FILENAME ]; - -lua_State* config_lua_values; - -#ifndef LUA_OK -# define LUA_OK 0 -#endif - -static inline bool config_read( const char* filename ) -{ - int rc; - - assert( filename != NULL ); - - /*--------------------------------------------------- - ; Create the Lua state, which includes NO predefined - ; functions or values. This is literally an empty - ; slate. - ;----------------------------------------------------*/ - config_lua_values = luaL_newstate(); - if ( config_lua_values == NULL ) { - fprintf( stderr, "cannot create Lua state\n" ); - return false; - } - - /*----------------------------------------------------- - ; For the truly paranoid about sandboxing, enable the - ; following code, which removes the string library, - ; which some people find problematic to leave un-sand- - ; boxed. But in my opinion, if you are worried about - ; such attacks in a configuration file, you have bigger - ; security issues to worry about than this. - ;------------------------------------------------------*/ -#ifdef PARANOID - lua_pushliteral( config_lua_values, "x" ); - lua_pushnil( config_lua_values ); - lua_setmetatable( config_lua_values, -2 ); - lua_pop( config_lua_values, 1 ); -#endif - - /*----------------------------------------------------- - ; Lua 5.2+ can restrict scripts to being text only, - ; to avoid a potential problem with loading pre-compiled - ; Lua scripts that may have malformed Lua VM code that - ; could possibly lead to an exploit, but again, if you - ; have to worry about that, you have bigger security - ; issues to worry about. But in any case, here I'm - ; restricting the file to "text" only. - ;------------------------------------------------------*/ - rc = luaL_loadfile( config_lua_values, filename ); - if ( rc != LUA_OK ) { - fprintf( stderr, "Lua error: (%d) %s\n", rc, lua_tostring( config_lua_values, -1 ) ); - return false; - } - - rc = lua_pcall( config_lua_values, 0, 0, 0 ); - if ( rc != LUA_OK ) { - fprintf( stderr, "Lua error: (%d) %s\n", rc, lua_tostring( config_lua_values, -1 ) ); - return false; - } - - return true; -} - -static inline void get_absolute_config_dir( char* source, char* dest ) -{ - if ( source[ 0 ] != '/' ) { - char* xdg_config_home = getenv( "XDG_CONFIG_HOME" ); - - if ( xdg_config_home ) { - if ( config.verbose ) - fprintf( stderr, "XDG_CONFIG_HOME is %s\n", xdg_config_home ); - - strcpy( dest, xdg_config_home ); - strcat( dest, "/" ); - } else { - char* home = getenv( "HOME" ); - - if ( home ) { - if ( config.verbose ) - fprintf( stderr, "HOME is %s\n", home ); - - strcpy( dest, home ); - strcat( dest, "/.config/" ); - } else { - struct passwd* pwd = getpwuid( getuid() ); - - if ( pwd ) { - if ( config.verbose ) - fprintf( stderr, "pwd->pw_dir is %s\n", pwd->pw_dir ); - - strcpy( dest, pwd->pw_dir ); - strcat( dest, "/" ); - } else { - if ( config.verbose ) - fprintf( stderr, "can\'t figure out your home directory, " - "trying /tmp\n" ); - - strcpy( dest, "/tmp" ); - } - } - } - } - - strcat( dest, source ); - - if ( dest[ strlen( dest ) ] != '/' ) - strcat( dest, "/" ); -} - -static inline void normalize_filename( const char* orig, char* dest ) -{ - if ( orig[ 0 ] == '/' ) - strcpy( dest, "" ); - else - strcpy( dest, normalized_config_path ); - strcat( dest, orig ); -} - -static inline bool normalize_config_dir( void ) -{ - struct stat st; - - get_absolute_config_dir( configDir, normalized_config_path ); - if ( config.verbose ) - fprintf( stderr, "normalized_config_path: %s\n", normalized_config_path ); - - if ( stat( normalized_config_path, &st ) == -1 ) - if ( errno == ENOENT ) - return false; - - return true; -} - -static inline void normalize_filenames( void ) -{ - normalize_filename( config_file, normalized_config_file ); - - normalize_filename( romFileName, normalized_rom_path ); - normalize_filename( ramFileName, normalized_ram_path ); - normalize_filename( stateFileName, normalized_state_path ); - normalize_filename( port1FileName, normalized_port1_path ); - normalize_filename( port2FileName, normalized_port2_path ); -} - -int config_init( int argc, char* argv[] ) -{ - int option_index; - int c = '?'; - - char* clopt_configDir = NULL; - char* clopt_romFileName = NULL; - char* clopt_ramFileName = NULL; - char* clopt_stateFileName = NULL; - char* clopt_port1FileName = NULL; - char* clopt_port2FileName = NULL; - char* clopt_serialLine = NULL; - char* clopt_x11_visual = NULL; - char* clopt_smallFont = NULL; - char* clopt_mediumFont = NULL; - char* clopt_largeFont = NULL; - char* clopt_connFont = NULL; - int clopt_frontend_type = -1; - int clopt_verbose = -1; - int clopt_useTerminal = -1; - int clopt_useSerial = -1; - int clopt_useDebugger = -1; - int clopt_throttle = -1; - int clopt_hide_chrome = -1; - int clopt_show_ui_fullscreen = -1; - double clopt_scale = -1.0; - int clopt_netbook = -1; - int clopt_mono = -1; - int clopt_gray = -1; - int clopt_small = -1; - int clopt_tiny = -1; - int clopt_leave_shift_keys = -1; - int clopt_inhibit_shutdown = -1; - - const char* optstring = "c:hvVtsirT"; - struct option long_options[] = { - {"config", required_argument, NULL, 'c' }, - {"config-dir", required_argument, NULL, 1000 }, - {"rom", required_argument, NULL, 1010 }, - {"ram", required_argument, NULL, 1011 }, - {"state", required_argument, NULL, 1012 }, - {"port1", required_argument, NULL, 1013 }, - {"port2", required_argument, NULL, 1014 }, - - {"serial-line", required_argument, NULL, 1015 }, - - {"help", no_argument, NULL, 'h' }, - {"version", no_argument, NULL, 'v' }, - - {"print-config", no_argument, ( int* )&config.print_config, true }, - {"verbose", no_argument, &clopt_verbose, true }, - {"terminal", no_argument, &clopt_useTerminal, true }, - {"serial", no_argument, &clopt_useSerial, true }, - - {"reset", no_argument, ( int* )&config.resetOnStartup, true }, - {"throttle", no_argument, &clopt_throttle, true }, - - {"debug", no_argument, &clopt_useDebugger, true }, - - {"sdl2", no_argument, &clopt_frontend_type, FRONTEND_SDL2}, - {"sdl", no_argument, &clopt_frontend_type, FRONTEND_SDL2}, - {"no-chrome", no_argument, &clopt_hide_chrome, true }, - {"fullscreen", no_argument, &clopt_show_ui_fullscreen, true }, - {"scale", required_argument, NULL, 7110 }, - - {"x11", no_argument, &clopt_frontend_type, FRONTEND_X11 }, - {"netbook", no_argument, &clopt_netbook, true }, - {"visual", required_argument, NULL, 8110 }, - {"small-font", required_argument, NULL, 8111 }, - {"medium-font", required_argument, NULL, 8112 }, - {"large-font", required_argument, NULL, 8113 }, - {"connection-font", required_argument, NULL, 8114 }, - - {"tui", no_argument, NULL, 9100 }, - {"tui-small", no_argument, NULL, 9110 }, - {"tui-tiny", no_argument, NULL, 9120 }, - {"small", no_argument, NULL, 9109 }, /* DEPRECATED */ - {"tiny", no_argument, NULL, 9119 }, /* DEPRECATED */ - - {"mono", no_argument, &clopt_mono, true }, - {"gray", no_argument, &clopt_gray, true }, - {"leave-shift-keys", no_argument, &clopt_leave_shift_keys, true }, - {"inhibit-shutdown", no_argument, &clopt_inhibit_shutdown, true }, - - {0, 0, 0, 0 } - }; - - const char* help_text = "usage: %s [options]\n" - "options:\n" - " -h --help what you are reading\n" - " -v --version show version\n" - " --print-config print configuration as config file\n" - " -c --config= use as x48ng's config file (default: " - "$XDG_CONFIG_HOME/x48ng/config.lua)\n" - " --config-dir= use as x48ng's home (default: " - "$XDG_CONFIG_HOME/x48ng/)\n" - " --rom= use (absolute or relative to " - ") as ROM (default: rom)\n" - " --ram= use (absolute or relative to " - ") as RAM (default: ram)\n" - " --state= use (absolute or relative " - "to ) as STATE (default: hp48)\n" - " --port1= use (absolute or relative " - "to ) as PORT1 (default: port1)\n" - " --port2= use (absolute or relative " - "to ) as PORT2 (default: port2)\n" - " --serial-line= use as serial device default: " - "%s)\n" - " -V --verbose be verbose (default: false)\n" - " --x11 use X11 front-end (default: true)\n" - " --sdl2 use SDL2 front-end (default: false)\n" - " --tui use text front-end (default: false)\n" - " --tui-small use text small front-end (2×2 pixels per character) (default: " - "false)\n" - " --tui-tiny use text tiny front-end (2×4 pixels per character) (default: " - "false)\n" - " -t --use-terminal activate pseudo terminal interface (default: " - "true)\n" - " -s --use-serial activate serial interface (default: false)\n" - " --debug enable the debugger\n" - " -r --reset perform a reset on startup\n" - " -T --throttle try to emulate real speed (default: false)\n" - " --no-chrome only display the LCD (default: " - "false)\n" - " --fullscreen make the UI fullscreen " - "(default: false)\n" - " --scale= make the UI scale times " - "(default: 1.0)\n" - " --netbook make the UI horizontal (default: " - "false)\n" - " --visual= use x11 visual (default: " - "default), possible values: " - "\n" - " --small-font= use as small " - "font (default: %s)\n" - " --medium-font= use as medium " - "font (default: %s)\n" - " --large-font= use as large " - "font (default: %s)\n" - " --connection-font= use as " - "connection font (default: %s)\n" - " --mono make the UI monochrome (default: " - "false)\n" - " --gray make the UI grayscale (default: " - "false)\n" - " --leave-shift-keys _not_ mapping the shift keys to let them free for numbers (default: " - "false)\n" - " --inhibit-shutdown __tentative fix for stuck-on-OFF bug__ (default: " - "false)\n"; - while ( c != EOF ) { - c = getopt_long( argc, argv, optstring, long_options, &option_index ); - - switch ( c ) { - case 'h': - fprintf( stderr, help_text, config.progname, config.serialLine, config.smallFont, config.mediumFont, config.largeFont, - config.connFont ); - exit( 0 ); - break; - case 'v': - fprintf( stderr, "%s %d.%d.%d\n", config.progname, VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL ); - exit( 0 ); - break; - case 'c': - config_file = optarg; - break; - case 1000: - clopt_configDir = optarg; - break; - case 1010: - clopt_romFileName = optarg; - break; - case 1011: - clopt_ramFileName = optarg; - break; - case 1012: - clopt_stateFileName = optarg; - break; - case 1013: - clopt_port1FileName = optarg; - break; - case 1014: - clopt_port2FileName = optarg; - break; - case 1015: - clopt_serialLine = optarg; - break; - case 7110: - clopt_scale = atof( optarg ); - break; - case 8110: - clopt_x11_visual = optarg; - break; - case 8111: - clopt_smallFont = optarg; - break; - case 8112: - clopt_mediumFont = optarg; - break; - case 8113: - clopt_largeFont = optarg; - break; - case 8114: - clopt_connFont = optarg; - break; - case 9100: - clopt_frontend_type = FRONTEND_TEXT; - clopt_small = false; - clopt_tiny = false; - break; - case 9109: - fprintf( stdout, "`--small` is deprecated, please use `--tui-small` instead of `--tui --small`" ); - /* break; */ /* intentional fall-through */ - case 9110: - clopt_frontend_type = FRONTEND_TEXT; - clopt_small = true; - clopt_tiny = false; - break; - case 9119: - fprintf( stdout, "`--tiny` is deprecated, please use `--tui-tiny` instead of `--tui --tiny`" ); - /* break; */ /* intentional fall-through */ - case 9120: - clopt_frontend_type = FRONTEND_TEXT; - clopt_small = false; - clopt_tiny = true; - break; - case 'V': - clopt_verbose = true; - break; - case 't': - clopt_useTerminal = true; - break; - case 's': - clopt_useSerial = true; - break; - case 'r': - config.resetOnStartup = true; - break; - case 'T': - clopt_throttle = true; - break; - - case '?': - case ':': - exit( 0 ); - break; - default: - break; - } - } - - if ( optind < argc ) { - fprintf( stderr, "Invalid arguments : " ); - while ( optind < argc ) - fprintf( stderr, "%s\n", argv[ optind++ ] ); - fprintf( stderr, "\n" ); - } - - if ( !normalize_config_dir() ) - fprintf( stderr, "Configuration directory doesn't exist!\n" ); - - /**********************/ - /* 1. read config.lua */ - /**********************/ - normalize_filename( config_file, normalized_config_file ); - if ( !config_read( normalized_config_file ) ) { - fprintf( stderr, "\nConfiguration file %s doesn't seem to exist or is invalid!\n", normalized_config_file ); - fprintf( stderr, "Continuing using default configuration as printed below.\n\n" ); - - fprintf( stderr, "You can solve this by running `mkdir -p %s && %s --print-config >> %s`\n\n", normalized_config_path, - config.progname, normalized_config_file ); - config.print_config = true; - } - - lua_getglobal( config_lua_values, "config_dir" ); - configDir = ( char* )luaL_optstring( config_lua_values, -1, "x48ng" ); - - lua_getglobal( config_lua_values, "rom" ); - romFileName = ( char* )luaL_optstring( config_lua_values, -1, "rom" ); - - lua_getglobal( config_lua_values, "ram" ); - ramFileName = ( char* )luaL_optstring( config_lua_values, -1, "ram" ); - - lua_getglobal( config_lua_values, "state" ); - stateFileName = ( char* )luaL_optstring( config_lua_values, -1, "state" ); - - lua_getglobal( config_lua_values, "port1" ); - port1FileName = ( char* )luaL_optstring( config_lua_values, -1, "port1" ); - - lua_getglobal( config_lua_values, "port2" ); - port2FileName = ( char* )luaL_optstring( config_lua_values, -1, "port2" ); - - lua_getglobal( config_lua_values, "serial_line" ); - config.serialLine = ( char* )luaL_optstring( config_lua_values, -1, "/dev/ttyS0" ); - - lua_getglobal( config_lua_values, "pseudo_terminal" ); - config.useTerminal = lua_toboolean( config_lua_values, -1 ); - - lua_getglobal( config_lua_values, "serial" ); - config.useSerial = lua_toboolean( config_lua_values, -1 ); - - lua_getglobal( config_lua_values, "debugger" ); - config.useDebugger = lua_toboolean( config_lua_values, -1 ); - - lua_getglobal( config_lua_values, "throttle" ); - config.throttle = lua_toboolean( config_lua_values, -1 ); - - lua_getglobal( config_lua_values, "frontend" ); -#ifdef HAS_X11 -# define DEFAULT_FRONTEND "x11" -#elif HAS_SDL2 -# define DEFAULT_FRONTEND "sdl2" -#else -# define DEFAULT_FRONTEND "tui" -#endif - const char* svalue = luaL_optstring( config_lua_values, -1, DEFAULT_FRONTEND ); - if ( svalue != NULL ) { - if ( strcmp( svalue, "x11" ) == 0 ) - config.frontend_type = FRONTEND_X11; - if ( strcmp( svalue, "sdl2" ) == 0 ) - config.frontend_type = FRONTEND_SDL2; - if ( strcmp( svalue, "sdl" ) == 0 ) /* retro-compatibility */ - config.frontend_type = FRONTEND_SDL2; - if ( strcmp( svalue, "tui" ) == 0 ) { - config.frontend_type = FRONTEND_TEXT; - config.small = false; - config.tiny = false; - } - if ( strcmp( svalue, "tui-small" ) == 0 ) { - config.frontend_type = FRONTEND_TEXT; - config.small = true; - config.tiny = false; - } - if ( strcmp( svalue, "tui-tiny" ) == 0 ) { - config.frontend_type = FRONTEND_TEXT; - config.small = false; - config.tiny = true; - } - } - - lua_getglobal( config_lua_values, "hide_chrome" ); - config.hide_chrome = lua_toboolean( config_lua_values, -1 ); - - lua_getglobal( config_lua_values, "fullscreen" ); - config.show_ui_fullscreen = lua_toboolean( config_lua_values, -1 ); - - lua_getglobal( config_lua_values, "scale" ); - config.scale = luaL_optnumber( config_lua_values, -1, 1.0 ); - - lua_getglobal( config_lua_values, "netbook" ); - config.netbook = lua_toboolean( config_lua_values, -1 ); - - lua_getglobal( config_lua_values, "mono" ); - config.mono = lua_toboolean( config_lua_values, -1 ); - - lua_getglobal( config_lua_values, "gray" ); - config.gray = lua_toboolean( config_lua_values, -1 ); - - /* DEPRECATED */ - lua_getglobal( config_lua_values, "small" ); - config.small = lua_toboolean( config_lua_values, -1 ); - - /* DEPRECATED */ - lua_getglobal( config_lua_values, "tiny" ); - config.tiny = lua_toboolean( config_lua_values, -1 ); - - lua_getglobal( config_lua_values, "leave_shift_keys" ); - config.leave_shift_keys = lua_toboolean( config_lua_values, -1 ); - - lua_getglobal( config_lua_values, "inhibit_shutdown" ); - config.inhibit_shutdown = lua_toboolean( config_lua_values, -1 ); - - lua_getglobal( config_lua_values, "x11_visual" ); - config.x11_visual = ( char* )luaL_optstring( config_lua_values, -1, "default" ); - - lua_getglobal( config_lua_values, "font_small" ); - config.smallFont = ( char* )luaL_optstring( config_lua_values, -1, "-*-fixed-bold-r-normal-*-14-*-*-*-*-*-iso8859-1" ); - - lua_getglobal( config_lua_values, "font_medium" ); - config.mediumFont = ( char* )luaL_optstring( config_lua_values, -1, "-*-fixed-bold-r-normal-*-15-*-*-*-*-*-iso8859-1" ); - - lua_getglobal( config_lua_values, "font_large" ); - config.largeFont = ( char* )luaL_optstring( config_lua_values, -1, "-*-fixed-medium-r-normal-*-20-*-*-*-*-*-iso8859-1" ); - - lua_getglobal( config_lua_values, "font_devices" ); - config.connFont = ( char* )luaL_optstring( config_lua_values, -1, "-*-fixed-medium-r-normal-*-12-*-*-*-*-*-iso8859-1" ); - - /****************************************************/ - /* 2. treat command-line params which have priority */ - /****************************************************/ - if ( clopt_configDir != NULL ) - configDir = strdup( clopt_configDir ); - if ( clopt_romFileName != NULL ) - romFileName = strdup( clopt_romFileName ); - if ( clopt_ramFileName != NULL ) - ramFileName = strdup( clopt_ramFileName ); - if ( clopt_stateFileName != NULL ) - stateFileName = strdup( clopt_stateFileName ); - if ( clopt_port1FileName != NULL ) - port1FileName = strdup( clopt_port1FileName ); - if ( clopt_port2FileName != NULL ) - port2FileName = strdup( clopt_port2FileName ); - if ( clopt_serialLine != NULL ) - config.serialLine = strdup( clopt_serialLine ); - if ( clopt_x11_visual != NULL ) - config.x11_visual = strdup( clopt_x11_visual ); - if ( clopt_smallFont != NULL ) - config.smallFont = strdup( clopt_smallFont ); - if ( clopt_mediumFont != NULL ) - config.mediumFont = strdup( clopt_mediumFont ); - if ( clopt_largeFont != NULL ) - config.largeFont = strdup( clopt_largeFont ); - if ( clopt_connFont != NULL ) - config.connFont = strdup( clopt_connFont ); - - if ( clopt_verbose != -1 ) - config.verbose = clopt_verbose; - if ( clopt_useTerminal != -1 ) - config.useTerminal = clopt_useTerminal; - if ( clopt_useSerial != -1 ) - config.useSerial = clopt_useSerial; - if ( clopt_throttle != -1 ) - config.throttle = clopt_throttle; - if ( clopt_useDebugger != -1 ) - config.useDebugger = clopt_useDebugger; - if ( clopt_frontend_type != -1 ) - config.frontend_type = clopt_frontend_type; - if ( clopt_hide_chrome != -1 ) - config.hide_chrome = clopt_hide_chrome; - if ( clopt_show_ui_fullscreen != -1 ) - config.show_ui_fullscreen = clopt_show_ui_fullscreen; - if ( clopt_scale > 0.0 ) - config.scale = clopt_scale; - if ( clopt_netbook != -1 ) - config.netbook = clopt_netbook; - if ( clopt_mono != -1 ) - config.mono = clopt_mono; - if ( clopt_gray != -1 ) - config.gray = clopt_gray; - if ( clopt_small != -1 ) - config.small = clopt_small; - if ( clopt_tiny != -1 ) - config.tiny = clopt_tiny; - if ( clopt_leave_shift_keys != -1 ) - config.leave_shift_keys = clopt_leave_shift_keys; - if ( clopt_inhibit_shutdown != -1 ) - config.inhibit_shutdown = clopt_inhibit_shutdown; - - /* After getting configs and params */ - /* normalize config_dir again in case it's been modified */ - if ( !normalize_config_dir() ) - fprintf( stderr, "Configuration directory doesn't exist!\n" ); - - normalize_filenames(); - - config.print_config |= config.verbose; - if ( config.print_config ) { - fprintf( stdout, "--------------------------------------------------------------------------------\n" ); - fprintf( stdout, "-- Configuration file for x48ng\n" ); - fprintf( stdout, "-- This is a comment\n" ); - fprintf( stdout, "-- `config_dir` is relative to $XDG_CONFIG_HOME/, or $HOME/.config/ or absolute\n" ); - fprintf( stdout, "config_dir = \"%s\"\n", configDir ); - fprintf( stdout, "\n" ); - fprintf( stdout, "-- Pathes are either relative to `config_dir` or absolute\n" ); - fprintf( stdout, "rom = \"%s\"\n", romFileName ); - fprintf( stdout, "ram = \"%s\"\n", ramFileName ); - fprintf( stdout, "state = \"%s\"\n", stateFileName ); - fprintf( stdout, "port1 = \"%s\"\n", port1FileName ); - fprintf( stdout, "port2 = \"%s\"\n", port2FileName ); - fprintf( stdout, "\n" ); - fprintf( stdout, "pseudo_terminal = %s\n", config.useTerminal ? "true" : "false" ); - fprintf( stdout, "serial = %s\n", config.useSerial ? "true" : "false" ); - fprintf( stdout, "serial_line = \"%s\"\n", config.serialLine ); - fprintf( stdout, "\n" ); - fprintf( stdout, "verbose = %s\n", config.verbose ? "true" : "false" ); - fprintf( stdout, "debugger = %s\n", config.useDebugger ? "true" : "false" ); - fprintf( stdout, "throttle = %s\n", config.throttle ? "true" : "false" ); - fprintf( stdout, "\n" ); - fprintf( stdout, "--------------------\n" ); - fprintf( stdout, "-- User Interface --\n" ); - fprintf( stdout, "--------------------\n" ); - fprintf( stdout, "frontend = \"" ); - switch ( config.frontend_type ) { - case FRONTEND_X11: - fprintf( stdout, "x11" ); - break; - case FRONTEND_SDL2: - fprintf( stdout, "sdl2" ); - break; - case FRONTEND_TEXT: - if ( config.small ) - fprintf( stdout, "tui-small" ); - else if ( config.tiny ) - fprintf( stdout, "tui-tiny" ); - else - fprintf( stdout, "tui" ); - break; - } - fprintf( stdout, "\" -- possible values: \"x11\", \"sdl2\" \"tui\", \"tui-small\", \"tui-tiny\"\n" ); - fprintf( stdout, "hide_chrome = %s\n", config.hide_chrome ? "true" : "false" ); - fprintf( stdout, "fullscreen = %s\n", config.show_ui_fullscreen ? "true" : "false" ); - fprintf( stdout, "scale = %f -- applies only to sdl2\n", config.scale ); - fprintf( stdout, "mono = %s\n", config.mono ? "true" : "false" ); - fprintf( stdout, "gray = %s\n", config.gray ? "true" : "false" ); - fprintf( stdout, "leave_shift_keys = %s\n", config.leave_shift_keys ? "true" : "false" ); - fprintf( stdout, "inhibit_shutdown = %s\n", config.inhibit_shutdown ? "true" : "false" ); - fprintf( stdout, "\n" ); - fprintf( stdout, "x11_visual = \"%s\"\n", config.x11_visual ); - fprintf( stdout, "netbook = %s\n", config.netbook ? "true" : "false" ); - fprintf( stdout, "font_small = \"%s\"\n", config.smallFont ); - fprintf( stdout, "font_medium = \"%s\"\n", config.mediumFont ); - fprintf( stdout, "font_large = \"%s\"\n", config.largeFont ); - fprintf( stdout, "font_devices = \"%s\"\n", config.connFont ); - fprintf( stdout, "--------------------------------------------------------------------------------\n" ); - - if ( !config.verbose ) - exit( 0 ); - } - if ( config.verbose ) { - fprintf( stderr, "normalized_config_path = %s\n", normalized_config_path ); - fprintf( stderr, "normalized_rom_path = %s\n", normalized_rom_path ); - fprintf( stderr, "normalized_ram_path = %s\n", normalized_ram_path ); - fprintf( stderr, "normalized_state_path = %s\n", normalized_state_path ); - fprintf( stderr, "normalized_port1_path = %s\n", normalized_port1_path ); - fprintf( stderr, "normalized_port2_path = %s\n", normalized_port2_path ); - } - - return ( optind ); -} diff --git a/src/config.h b/src/config.h deleted file mode 100644 index bcd90e3..0000000 --- a/src/config.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef _CONFIG_H -#define _CONFIG_H 1 - -#include - -#define FRONTEND_TEXT 0 -#define FRONTEND_X11 1 -#define FRONTEND_SDL2 2 - -typedef struct { - char* progname; - - bool verbose; - bool print_config; - bool useTerminal; - bool useSerial; - bool useDebugger; - bool throttle; - bool resetOnStartup; - int frontend_type; - - char* serialLine; - - bool leave_shift_keys; - bool inhibit_shutdown; - - bool mono; - bool gray; - - /* tui */ - bool small; - bool tiny; - - /* sdl */ - bool hide_chrome; - bool show_ui_fullscreen; - double scale; - - /* x11 */ - bool netbook; - char* name; - char* title; - char* x11_visual; - bool monoIcon; - bool iconic; - bool xrm; - char* smallFont; - char* mediumFont; - char* largeFont; - char* connFont; -} config_t; -extern config_t config; - -#define MAX_LENGTH_FILENAME 2048 -extern char normalized_config_path[ MAX_LENGTH_FILENAME ]; -extern char normalized_config_file[ MAX_LENGTH_FILENAME ]; -extern char normalized_rom_path[ MAX_LENGTH_FILENAME ]; -extern char normalized_ram_path[ MAX_LENGTH_FILENAME ]; -extern char normalized_state_path[ MAX_LENGTH_FILENAME ]; -extern char normalized_port1_path[ MAX_LENGTH_FILENAME ]; -extern char normalized_port2_path[ MAX_LENGTH_FILENAME ]; - -/*************/ -/* functions */ -/*************/ -extern int config_init( int argc, char* argv[] ); - -#endif /* !_CONFIG_H */ diff --git a/src/debugger.c b/src/debugger.c index dbc07ea..4a10ada 100644 --- a/src/debugger.c +++ b/src/debugger.c @@ -7,11 +7,11 @@ #include #include -#include "config.h" +//#include "config.h" #include "emulator.h" #include "emulator_for_debugger.h" #include "romio.h" -#include "ui.h" /* ui_update_LCD(); */ +//#include "ui.h" /* ui_update_LCD(); */ #include "debugger.h" #define MAX_ARGS 16 @@ -3529,7 +3529,7 @@ static void cmd_load( int argc, char** argv ) free( tmp_saturn.port2 ); /* After reloading state we need to refresh the UI's LCD */ - ui_update_LCD(); + /* ui_update_LCD(); */ } else { printf( "Loading emulator-state from files failed.\n" ); if ( saturn.rom ) @@ -3572,7 +3572,7 @@ static void cmd_exit( int argc, char** argv ) save_before_exit = false; // please_exit = true; - close_and_exit(); + /* close_and_exit(); */ } } @@ -3583,7 +3583,7 @@ static void cmd_quit( int argc, char** argv ) save_before_exit = true; // please_exit = true; - close_and_exit(); + /* close_and_exit(); */ } } @@ -4064,35 +4064,35 @@ int debug( void ) /* * do we want to debug ??? */ - if ( !config.useDebugger ) { - if ( enter_debugger & ILLEGAL_INSTRUCTION ) { - if ( config.verbose ) - fprintf( stderr, "reset (illegal instruction at 0x%.5lX)\n", saturn.PC ); - saturn.PC = 0; - } - if ( enter_debugger & USER_INTERRUPT ) - if ( config.verbose ) - printf( "usnterrupt (SIGINT) ignored\n" ); + /* if ( !config.useDebugger ) { */ + /* if ( enter_debugger & ILLEGAL_INSTRUCTION ) { */ + /* if ( config.verbose ) */ + /* fprintf( stderr, "reset (illegal instruction at 0x%.5lX)\n", saturn.PC ); */ + /* saturn.PC = 0; */ + /* } */ + /* if ( enter_debugger & USER_INTERRUPT ) */ + /* if ( config.verbose ) */ + /* printf( "usnterrupt (SIGINT) ignored\n" ); */ - // please_exit = true; + /* // please_exit = true; */ - if ( enter_debugger & BREAKPOINT_HIT ) - if ( config.verbose ) - printf( "breakpoint hit at 0x%.5lX ignored\n", saturn.PC ); - if ( enter_debugger & TRAP_INSTRUCTION ) - if ( config.verbose ) - printf( "trap instruction at 0x%.5lX ignored\n", saturn.PC ); + /* if ( enter_debugger & BREAKPOINT_HIT ) */ + /* if ( config.verbose ) */ + /* printf( "breakpoint hit at 0x%.5lX ignored\n", saturn.PC ); */ + /* if ( enter_debugger & TRAP_INSTRUCTION ) */ + /* if ( config.verbose ) */ + /* printf( "trap instruction at 0x%.5lX ignored\n", saturn.PC ); */ - enter_debugger = 0; - return 0; - } + /* enter_debugger = 0; */ + /* return 0; */ + /* } */ /* * update the lcd if necessary */ if ( device.display_touched ) { device.display_touched = 0; - ui_update_LCD(); + /* ui_update_LCD(); */ } /* diff --git a/src/emu_emulate.c b/src/emu_emulate.c index c0e0273..d616ce0 100644 --- a/src/emu_emulate.c +++ b/src/emu_emulate.c @@ -6,8 +6,8 @@ #include "debugger.h" /* enter_debugger, TRAP_INSTRUCTION, ILLEGAL_INSTRUCTION */ #include "emulator.h" #include "emulator_inner.h" -#include "config.h" /* throttle */ -#include "ui.h" /* ui_get_event(); ui_adjust_contrast(); ui_update_LCD(); ui_draw_annunc(); */ +//#include "config.h" /* throttle */ +//#include "ui.h" /* ui_get_event(); ui_adjust_contrast(); ui_update_LCD(); ui_draw_annunc(); */ #include "debugger.h" /* in_debugger, enter_debugger */ @@ -1252,7 +1252,7 @@ static bool step_instruction_080( void ) break; case 7: /* SHUTDN */ saturn.PC += 3; - if ( config.inhibit_shutdown ) + /* if ( config.inhibit_shutdown ) */ break; /***************************/ @@ -1297,7 +1297,7 @@ static bool step_instruction_080( void ) if ( device.display_touched ) { device.display_touched = 0; - ui_refresh_LCD(); + //ui_refresh_LCD(); } stop_timer( RUN_TIMER ); @@ -1318,7 +1318,7 @@ static bool step_instruction_080( void ) if ( sigalarm_triggered ) { sigalarm_triggered = false; - ui_refresh_LCD(); + /* ui_refresh_LCD(); */ ticks = get_t1_t2(); if ( saturn.t2_ctrl & 0x01 ) @@ -1328,7 +1328,7 @@ static bool step_instruction_080( void ) set_t1 = ticks.t1_ticks; interrupt_called = false; - ui_get_event(); + /* ui_get_event(); */ if ( interrupt_called ) wake = true; @@ -2857,17 +2857,17 @@ void schedule( void ) // TODO: move this out into ui_*.c if ( device.display_touched > 0 && device.display_touched-- == 1 ) { device.display_touched = 0; - ui_update_LCD(); + // ui_update_LCD(); } if ( device.display_touched > 0 ) device_check = true; if ( device.contrast_touched ) { device.contrast_touched = false; - ui_adjust_contrast(); + /* ui_adjust_contrast(); */ } if ( device.ann_touched ) { device.ann_touched = false; - ui_draw_annunc(); + /* ui_draw_annunc(); */ } /* serial */ @@ -3011,8 +3011,8 @@ void schedule( void ) if ( sigalarm_triggered ) { sigalarm_triggered = false; - ui_refresh_LCD(); + /* ui_refresh_LCD(); */ - ui_get_event(); + /* ui_get_event(); */ } } diff --git a/src/emu_init.c b/src/emu_init.c index 01e7b2c..cde926e 100644 --- a/src/emu_init.c +++ b/src/emu_init.c @@ -10,7 +10,7 @@ #include "emulator.h" #include "emulator_inner.h" #include "romio.h" -#include "config.h" +/* #include "config.h" */ #define X48_MAGIC 0x48503438 #define NB_CONFIG 8 @@ -18,6 +18,8 @@ #define RAM_SIZE_SX 0x10000 #define RAM_SIZE_GX 0x40000 +#define MAX_LENGTH_FILENAME 1024 + // bool please_exit = false; bool save_before_exit = true; @@ -148,8 +150,8 @@ int read_8( FILE* fp, word_8* var ) unsigned char tmp; if ( fread( &tmp, 1, 1, fp ) != 1 ) { - if ( config.verbose ) - fprintf( stderr, "can\'t read word_8\n" ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "can\'t read word_8\n" ); */ return 0; } *var = tmp; @@ -161,8 +163,8 @@ int read_char( FILE* fp, char* var ) char tmp; if ( fread( &tmp, 1, 1, fp ) != 1 ) { - if ( config.verbose ) - fprintf( stderr, "can\'t read char\n" ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "can\'t read char\n" ); */ return 0; } *var = tmp; @@ -174,8 +176,8 @@ int read_16( FILE* fp, word_16* var ) unsigned char tmp[ 2 ]; if ( fread( &tmp[ 0 ], 1, 2, fp ) != 2 ) { - if ( config.verbose ) - fprintf( stderr, "can\'t read word_16\n" ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "can\'t read word_16\n" ); */ return 0; } *var = tmp[ 0 ] << 8; @@ -188,8 +190,8 @@ int read_32( FILE* fp, word_32* var ) unsigned char tmp[ 4 ]; if ( fread( &tmp[ 0 ], 1, 4, fp ) != 4 ) { - if ( config.verbose ) - fprintf( stderr, "can\'t read word_32\n" ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "can\'t read word_32\n" ); */ return 0; } *var = tmp[ 0 ] << 24; @@ -204,8 +206,8 @@ int read_u_long( FILE* fp, unsigned long* var ) unsigned char tmp[ 4 ]; if ( fread( &tmp[ 0 ], 1, 4, fp ) != 4 ) { - if ( config.verbose ) - fprintf( stderr, "can\'t read unsigned long\n" ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "can\'t read unsigned long\n" ); */ return 0; } *var = tmp[ 0 ] << 24; @@ -390,14 +392,12 @@ int read_mem_file( char* name, word_4* mem, int size ) int i, j; if ( NULL == ( fp = fopen( name, "r" ) ) ) { - if ( config.verbose ) - fprintf( stderr, "ct open %s\n", name ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "ct open %s\n", name ); */ return 0; } if ( stat( name, &st ) < 0 ) { - if ( config.verbose ) - fprintf( stderr, "can\'t stat %s\n", name ); return 0; } @@ -406,8 +406,8 @@ int read_mem_file( char* name, word_4* mem, int size ) * size is same as memory size, old version file */ if ( fread( mem, 1, ( size_t )size, fp ) != ( unsigned long )size ) { - if ( config.verbose ) - fprintf( stderr, "can\'t read %s\n", name ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "can\'t read %s\n", name ); */ fclose( fp ); return 0; } @@ -417,8 +417,8 @@ int read_mem_file( char* name, word_4* mem, int size ) */ if ( st.st_size != size / 2 ) { - if ( config.verbose ) - fprintf( stderr, "strange size %s, expected %d, found %ld\n", name, size / 2, st.st_size ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "strange size %s, expected %d, found %ld\n", name, size / 2, st.st_size ); */ fclose( fp ); return 0; } @@ -426,8 +426,8 @@ int read_mem_file( char* name, word_4* mem, int size ) if ( NULL == ( tmp_mem = ( word_8* )malloc( ( size_t )st.st_size ) ) ) { for ( i = 0, j = 0; i < size / 2; i++ ) { if ( 1 != fread( &byte, 1, 1, fp ) ) { - if ( config.verbose ) - fprintf( stderr, "can\'t read %s\n", name ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "can\'t read %s\n", name ); */ fclose( fp ); return 0; } @@ -436,8 +436,8 @@ int read_mem_file( char* name, word_4* mem, int size ) } } else { if ( fread( tmp_mem, 1, ( size_t )size / 2, fp ) != ( unsigned long )( size / 2 ) ) { - if ( config.verbose ) - fprintf( stderr, "can\'t read %s\n", name ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "can\'t read %s\n", name ); */ fclose( fp ); free( tmp_mem ); return 0; @@ -454,13 +454,13 @@ int read_mem_file( char* name, word_4* mem, int size ) fclose( fp ); - if ( config.verbose ) - printf( "read %s\n", name ); + /* if ( config.verbose ) */ + /* printf( "read %s\n", name ); */ return 1; } -int read_files( void ) +int read_files( char* normalized_rom_path, char* normalized_ram_path, char* normalized_state_path, char* normalized_port1_path, char* normalized_port2_path ) { /* unsigned long v1, v2; */ int i; @@ -476,8 +476,8 @@ int read_files( void ) if ( !read_rom_file( normalized_rom_path, &saturn.rom, &rom_size ) ) return 0; - if ( config.verbose ) - printf( "read %s\n", normalized_rom_path ); + /* if ( config.verbose ) */ + /* printf( "read %s\n", normalized_rom_path ); */ rom_is_new = false; @@ -485,8 +485,8 @@ int read_files( void ) /* 2. read saved state from ~/.x48ng/state into fp */ /**************************************************/ if ( NULL == ( fp = fopen( normalized_state_path, "r" ) ) ) { - if ( config.verbose ) - fprintf( stderr, "can\'t open %s\n", normalized_state_path ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "can\'t open %s\n", normalized_state_path ); */ return 0; } @@ -509,8 +509,8 @@ int read_files( void ) read_version = true; for ( i = 0; i < 4; i++ ) { if ( !read_char( fp, &saturn.version[ i ] ) ) { - if ( config.verbose ) - fprintf( stderr, "can\'t read version\n" ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "can\'t read version\n" ); */ read_version = false; } } @@ -528,11 +528,11 @@ int read_files( void ) * try to read latest version file */ if ( !read_state_file( fp ) ) { - if ( config.verbose ) - fprintf( stderr, "can't handle %s\n", normalized_state_path ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "can't handle %s\n", normalized_state_path ); */ init_saturn(); - } else if ( config.verbose ) - printf( "read %s\n", normalized_state_path ); + } /* else if ( config.verbose ) */ + /* printf( "read %s\n", normalized_state_path ); */ } } fclose( fp ); @@ -545,8 +545,8 @@ int read_files( void ) saturn.ram = ( word_4* )NULL; if ( NULL == ( saturn.ram = ( word_4* )malloc( ram_size ) ) ) { - if ( config.verbose ) - fprintf( stderr, "can\'t malloc RAM[%d]\n", ram_size ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "can\'t malloc RAM[%d]\n", ram_size ); */ exit( 1 ); } @@ -554,8 +554,8 @@ int read_files( void ) /* 3. read RAM from ~/.x48ng/ram into saturn.ram */ /*************************************************/ if ( ( fp = fopen( normalized_ram_path, "r" ) ) == NULL ) { - if ( config.verbose ) - fprintf( stderr, "can\'t open %s\n", normalized_ram_path ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "can\'t open %s\n", normalized_ram_path ); */ return 0; } if ( !read_mem_file( normalized_ram_path, saturn.ram, ram_size ) ) @@ -578,8 +578,8 @@ int read_files( void ) port1_size = 2 * st.st_size; if ( ( port1_size == 0x10000 ) || ( port1_size == 0x40000 ) ) { if ( NULL == ( saturn.port1 = ( word_4* )malloc( port1_size ) ) ) { - if ( config.verbose ) - fprintf( stderr, "can\'t malloc PORT1[%ld]\n", port1_size ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "can\'t malloc PORT1[%ld]\n", port1_size ); */ } else if ( !read_mem_file( normalized_port1_path, saturn.port1, port1_size ) ) { port1_size = 0; port1_is_ram = false; @@ -611,8 +611,8 @@ int read_files( void ) if ( ( opt_gx && ( ( port2_size % 0x40000 ) == 0 ) ) || ( !opt_gx && ( ( port2_size == 0x10000 ) || ( port2_size == 0x40000 ) ) ) ) { if ( NULL == ( saturn.port2 = ( word_4* )malloc( port2_size ) ) ) { - if ( config.verbose ) - fprintf( stderr, "can\'t malloc PORT2[%ld]\n", port2_size ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "can\'t malloc PORT2[%ld]\n", port2_size ); */ } else if ( !read_mem_file( normalized_port2_path, saturn.port2, port2_size ) ) { port2_size = 0; port2_is_ram = false; @@ -647,8 +647,8 @@ int write_8( FILE* fp, word_8* var ) tmp = *var; if ( fwrite( &tmp, 1, 1, fp ) != 1 ) { - if ( config.verbose ) - fprintf( stderr, "can\'t write word_8\n" ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "can\'t write word_8\n" ); */ return 0; } return 1; @@ -660,8 +660,8 @@ int write_char( FILE* fp, char* var ) tmp = *var; if ( fwrite( &tmp, 1, 1, fp ) != 1 ) { - if ( config.verbose ) - fprintf( stderr, "can\'t write char\n" ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "can\'t write char\n" ); */ return 0; } return 1; @@ -674,8 +674,8 @@ int write_16( FILE* fp, word_16* var ) tmp[ 0 ] = ( *var >> 8 ) & 0xff; tmp[ 1 ] = *var & 0xff; if ( fwrite( &tmp[ 0 ], 1, 2, fp ) != 2 ) { - if ( config.verbose ) - fprintf( stderr, "can\'t write word_16\n" ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "can\'t write word_16\n" ); */ return 0; } return 1; @@ -690,8 +690,8 @@ int write_32( FILE* fp, word_32* var ) tmp[ 2 ] = ( *var >> 8 ) & 0xff; tmp[ 3 ] = *var & 0xff; if ( fwrite( &tmp[ 0 ], 1, 4, fp ) != 4 ) { - if ( config.verbose ) - fprintf( stderr, "can\'t write word_32\n" ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "can\'t write word_32\n" ); */ return 0; } return 1; @@ -706,8 +706,8 @@ int write_u_long( FILE* fp, unsigned long* var ) tmp[ 2 ] = ( *var >> 8 ) & 0xff; tmp[ 3 ] = *var & 0xff; if ( fwrite( &tmp[ 0 ], 1, 4, fp ) != 4 ) { - if ( config.verbose ) - fprintf( stderr, "can\'t write unsigned long\n" ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "can\'t write unsigned long\n" ); */ return 0; } return 1; @@ -721,8 +721,8 @@ int write_mem_file( char* name, word_4* mem, int size ) int i, j; if ( NULL == ( fp = fopen( name, "w" ) ) ) { - if ( config.verbose ) - fprintf( stderr, "can\'t open %s\n", name ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "can\'t open %s\n", name ); */ return 0; } @@ -731,8 +731,8 @@ int write_mem_file( char* name, word_4* mem, int size ) byte = ( mem[ j++ ] & 0x0f ); byte |= ( mem[ j++ ] << 4 ) & 0xf0; if ( 1 != fwrite( &byte, 1, 1, fp ) ) { - if ( config.verbose ) - fprintf( stderr, "can\'t write %s\n", name ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "can\'t write %s\n", name ); */ fclose( fp ); return 0; } @@ -744,8 +744,8 @@ int write_mem_file( char* name, word_4* mem, int size ) } if ( fwrite( tmp_mem, 1, ( size_t )size / 2, fp ) != ( unsigned long )size / 2 ) { - if ( config.verbose ) - fprintf( stderr, "can\'t write %s\n", name ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "can\'t write %s\n", name ); */ fclose( fp ); free( tmp_mem ); return 0; @@ -756,8 +756,8 @@ int write_mem_file( char* name, word_4* mem, int size ) fclose( fp ); - if ( config.verbose ) - printf( "wrote %s\n", name ); + /* if ( config.verbose ) */ + /* printf( "wrote %s\n", name ); */ return 1; } @@ -768,8 +768,8 @@ int write_state_file( char* filename ) FILE* fp; if ( ( fp = fopen( filename, "w" ) ) == NULL ) { - if ( config.verbose ) - fprintf( stderr, "can\'t open %s, no saving done\n", filename ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "can\'t open %s, no saving done\n", filename ); */ return 0; } @@ -868,58 +868,58 @@ int write_state_file( char* filename ) fclose( fp ); - if ( config.verbose ) - printf( "wrote %s\n", filename ); + /* if ( config.verbose ) */ + /* printf( "wrote %s\n", filename ); */ return 1; } -int write_files( void ) +int write_files( char* normalized_rom_path, char* normalized_ram_path, char* normalized_state_path, char* normalized_port1_path, char* normalized_port2_path ) { struct stat st; - bool make_dir = false; + /* bool make_dir = false; */ int ram_size = opt_gx ? RAM_SIZE_GX : RAM_SIZE_SX; - if ( stat( normalized_config_path, &st ) == -1 ) { - if ( errno == ENOENT ) { - make_dir = true; - } else { - if ( config.verbose ) - fprintf( stderr, "can\'t stat %s, saving to /tmp\n", normalized_config_path ); - strcpy( normalized_config_path, "/tmp" ); - } - } else { - if ( !S_ISDIR( st.st_mode ) ) { - if ( config.verbose ) - fprintf( stderr, "%s is no directory, saving to /tmp\n", normalized_config_path ); - strcpy( normalized_config_path, "/tmp" ); - } - } + /* if ( stat( normalized_config_path, &st ) == -1 ) { */ + /* if ( errno == ENOENT ) { */ + /* make_dir = true; */ + /* } else { */ + /* /\* if ( config.verbose ) *\/ */ + /* /\* fprintf( stderr, "can\'t stat %s, saving to /tmp\n", normalized_config_path ); *\/ */ + /* strcpy( normalized_config_path, "/tmp" ); */ + /* } */ + /* } else { */ + /* if ( !S_ISDIR( st.st_mode ) ) { */ + /* /\* if ( config.verbose ) *\/ */ + /* /\* fprintf( stderr, "%s is no directory, saving to /tmp\n", normalized_config_path ); *\/ */ + /* strcpy( normalized_config_path, "/tmp" ); */ + /* } */ + /* } */ - if ( make_dir ) { - if ( mkdir( normalized_config_path, 0777 ) == -1 ) { - if ( config.verbose ) - fprintf( stderr, "can\'t mkdir %s, saving to /tmp\n", normalized_config_path ); - strcpy( normalized_config_path, "/tmp" ); - } - } + /* if ( make_dir ) { */ + /* if ( mkdir( normalized_config_path, 0777 ) == -1 ) { */ + /* /\* if ( config.verbose ) *\/ */ + /* /\* fprintf( stderr, "can\'t mkdir %s, saving to /tmp\n", normalized_config_path ); *\/ */ + /* strcpy( normalized_config_path, "/tmp" ); */ + /* } */ + /* } */ - if ( !write_state_file( normalized_state_path ) ) - return 0; + /* if ( !write_state_file( normalized_state_path ) ) */ + /* return 0; */ - rom_is_new = make_dir; - if ( rom_is_new ) { - char new_rom_path[ MAX_LENGTH_FILENAME ]; + /* rom_is_new = make_dir; */ + /* if ( rom_is_new ) { */ + /* char new_rom_path[ MAX_LENGTH_FILENAME ]; */ - strcpy( new_rom_path, normalized_config_path ); - strcat( new_rom_path, "rom" ); + /* strcpy( new_rom_path, normalized_config_path ); */ + /* strcat( new_rom_path, "rom" ); */ - if ( !write_mem_file( new_rom_path, saturn.rom, rom_size ) ) - return 0; + /* if ( !write_mem_file( new_rom_path, saturn.rom, rom_size ) ) */ + /* return 0; */ - if ( config.verbose ) - printf( "wrote %s\n", new_rom_path ); - } + /* /\* if ( config.verbose ) *\/ */ + /* /\* printf( "wrote %s\n", new_rom_path ); *\/ */ + /* } */ if ( !write_mem_file( normalized_ram_path, saturn.ram, ram_size ) ) return 0; @@ -944,16 +944,16 @@ int read_rom( const char* fname ) if ( !read_rom_file( fname, &saturn.rom, &rom_size ) ) return 0; - if ( config.verbose ) - printf( "read %s\n", fname ); + /* if ( config.verbose ) */ + /* printf( "read %s\n", fname ); */ dev_memory_init(); ram_size = opt_gx ? RAM_SIZE_GX : RAM_SIZE_SX; if ( NULL == ( saturn.ram = ( word_4* )malloc( ram_size ) ) ) { - if ( config.verbose ) - fprintf( stderr, "can\'t malloc RAM\n" ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "can\'t malloc RAM\n" ); */ return 0; } @@ -999,22 +999,32 @@ void init_display( void ) display.contrast |= ( ( saturn.disp_test & 0x1 ) << 4 ); } -void start_emulator( void ) +char* normalized_rom_path; +char* normalized_ram_path; +char* normalized_state_path; +char* normalized_port1_path; +char* normalized_port2_path; +void start_emulator( char* n_rom_path, char* n_ram_path, char* n_state_path, char* n_port1_path, char* n_port2_path ) { + normalized_rom_path = n_rom_path; + normalized_ram_path = n_ram_path; + normalized_state_path = n_state_path; + normalized_port1_path = n_port1_path; + normalized_port2_path = n_port2_path; // please_exit = false; save_before_exit = true; /* If files are successfully read => return and let's go */ - if ( read_files() ) { - if ( config.resetOnStartup ) - saturn.PC = 0x00000; + if ( read_files(n_rom_path, n_ram_path, n_state_path, n_port1_path, n_port2_path) ) { + /* if ( config.resetOnStartup ) */ + /* saturn.PC = 0x00000; */ } else { /* if files were not readable => initialize */ - if ( config.verbose ) - fprintf( stderr, "initialization of %s\n", normalized_config_path ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "initialization of %s\n", n_config_path ); */ init_saturn(); - if ( !read_rom( normalized_rom_path ) ) + if ( !read_rom( n_rom_path ) ) exit( 1 ); /* can't read ROM */ } @@ -1022,8 +1032,8 @@ void start_emulator( void ) init_display(); } -void exit_emulator( void ) +void exit_emulator( ) { if ( save_before_exit ) - write_files(); + write_files(normalized_rom_path, normalized_ram_path, normalized_state_path, normalized_port1_path, normalized_port2_path); } diff --git a/src/emu_memory.c b/src/emu_memory.c index a334224..164b821 100644 --- a/src/emu_memory.c +++ b/src/emu_memory.c @@ -7,8 +7,8 @@ #include "emulator.h" #include "emulator_inner.h" #include "romio.h" -#include "config.h" -#include "ui.h" /* ui_disp_draw_nibble(); ui_menu_draw_nibble(); */ +/* #include "config.h" */ +/* #include "ui.h" /\* ui_disp_draw_nibble(); ui_menu_draw_nibble(); *\/ */ #define MCTL_MMIO_SX 0 #define MCTL_SysRAM_SX 1 @@ -264,8 +264,8 @@ void write_dev_mem( long addr, int val ) device.t2_touched = true; return; default: - if ( config.verbose ) - fprintf( stderr, "%.5lx: UNKNOWN DEVICE WRITE AT 0x%lx !!!\n", saturn.PC, addr ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "%.5lx: UNKNOWN DEVICE WRITE AT 0x%lx !!!\n", saturn.PC, addr ); */ return; } } @@ -379,8 +379,8 @@ int read_dev_mem( long addr ) case 0x13f: return ( saturn.timer2 >> ( ( addr - 0x138 ) * 4 ) ) & 0xf; default: - if ( config.verbose ) - fprintf( stderr, "%.5lx: UNKNOWN DEVICE READ AT 0x%lx !!!\n", saturn.PC, addr ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "%.5lx: UNKNOWN DEVICE READ AT 0x%lx !!!\n", saturn.PC, addr ); */ return 0x00; } } @@ -469,14 +469,14 @@ void write_nibble_sx( long addr, int val ) if ( device.display_touched ) return; - if ( addr >= display.disp_start && addr < display.disp_end ) - ui_disp_draw_nibble( addr, val ); + /* if ( addr >= display.disp_start && addr < display.disp_end ) */ + /* ui_disp_draw_nibble( addr, val ); */ if ( display.lines == 63 ) return; - if ( addr >= display.menu_start && addr < display.menu_end ) - ui_menu_draw_nibble( addr, val ); + /* if ( addr >= display.menu_start && addr < display.menu_end ) */ + /* ui_menu_draw_nibble( addr, val ); */ } void write_nibble_gx( long addr, int val ) @@ -619,14 +619,14 @@ void write_nibble_gx( long addr, int val ) if ( device.display_touched ) return; - if ( addr >= display.disp_start && addr < display.disp_end ) - ui_disp_draw_nibble( addr, val ); + /* if ( addr >= display.disp_start && addr < display.disp_end ) */ + /* ui_disp_draw_nibble( addr, val ); */ if ( display.lines == 63 ) return; - if ( addr >= display.menu_start && addr < display.menu_end ) - ui_menu_draw_nibble( addr, val ); + /* if ( addr >= display.menu_start && addr < display.menu_end ) */ + /* ui_menu_draw_nibble( addr, val ); */ } int read_nibble_sx( long addr ) diff --git a/src/emu_serial.c b/src/emu_serial.c index 53c4e61..c80e647 100644 --- a/src/emu_serial.c +++ b/src/emu_serial.c @@ -8,7 +8,7 @@ #include #include "emulator_inner.h" /* saturn, do_interupt() */ -#include "config.h" /* config.verbose, config.useTerminal, config.useSerial */ +//#include "config.h" /* config.verbose, config.useTerminal, config.useSerial */ static int wire_fd; static int ir_fd; @@ -40,7 +40,7 @@ int init_serial( void ) wire_fd = -1; ttyp = -1; - if ( config.useTerminal ) { + /* if ( config.useTerminal ) { */ /* Unix98 PTY (Preferred) */ if ( ( wire_fd = open( "/dev/ptmx", O_RDWR | O_NONBLOCK, 0666 ) ) >= 0 ) { grantpt( wire_fd ); @@ -50,8 +50,8 @@ int init_serial( void ) exit( -1 ); } if ( ( ttyp = open( tty_dev_name, O_RDWR | O_NDELAY, 0666 ) ) >= 0 ) { - if ( config.verbose ) - printf( "wire connection on %s\n", tty_dev_name ); + /* if ( config.verbose ) */ + /* printf( "wire connection on %s\n", tty_dev_name ); */ wire_name = strdup( tty_dev_name ); } } @@ -64,8 +64,8 @@ int init_serial( void ) if ( ( wire_fd = open( tty_dev_name, O_RDWR | O_EXCL | O_NDELAY, 0666 ) ) >= 0 ) { ttyp = wire_fd; sprintf( tty_dev_name, "/dev/tty%c%x", c, n ); - if ( config.verbose ) - printf( "wire connection on %s\n", tty_dev_name ); + /* if ( config.verbose ) */ + /* printf( "wire connection on %s\n", tty_dev_name ); */ wire_name = strdup( tty_dev_name ); break; } @@ -73,7 +73,7 @@ int init_serial( void ) c++; } while ( ( wire_fd < 0 ) && ( errno != ENOENT ) ); } - } + /* } */ if ( ttyp >= 0 ) { #if defined( TCSANOW ) @@ -82,8 +82,8 @@ int init_serial( void ) if ( ioctl( ttyp, TCGETS, ( char* )&ttybuf ) < 0 ) #endif { - if ( config.verbose ) - fprintf( stderr, "ioctl(wire, TCGETS) failed, errno = %d\n", errno ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "ioctl(wire, TCGETS) failed, errno = %d\n", errno ); */ wire_fd = -1; ttyp = -1; } @@ -105,22 +105,22 @@ int init_serial( void ) if ( ioctl( ttyp, TCSETS, ( char* )&ttybuf ) < 0 ) #endif { - if ( config.verbose ) - fprintf( stderr, "ioctl(wire, TCSETS) failed, errno = %d\n", errno ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "ioctl(wire, TCSETS) failed, errno = %d\n", errno ); */ wire_fd = -1; ttyp = -1; } } ir_fd = -1; - if ( config.useSerial ) { - sprintf( tty_dev_name, "%s", config.serialLine ); - if ( ( ir_fd = open( tty_dev_name, O_RDWR | O_NDELAY ) ) >= 0 ) { - if ( config.verbose ) - printf( "IR connection on %s\n", tty_dev_name ); - ir_name = strdup( tty_dev_name ); - } - } + /* if ( config.useSerial ) { */ + /* sprintf( tty_dev_name, "%s", config.serialLine ); */ + /* if ( ( ir_fd = open( tty_dev_name, O_RDWR | O_NDELAY ) ) >= 0 ) { */ + /* /\* if ( config.verbose ) *\/ */ + /* /\* printf( "IR connection on %s\n", tty_dev_name ); *\/ */ + /* ir_name = strdup( tty_dev_name ); */ + /* } */ + /* } */ if ( ir_fd >= 0 ) { #if defined( TCSANOW ) @@ -129,8 +129,8 @@ int init_serial( void ) if ( ioctl( ir_fd, TCGETS, ( char* )&ttybuf ) < 0 ) #endif { - if ( config.verbose ) - fprintf( stderr, "ioctl(IR, TCGETS) failed, errno = %d\n", errno ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "ioctl(IR, TCGETS) failed, errno = %d\n", errno ); */ ir_fd = -1; } } @@ -151,8 +151,8 @@ int init_serial( void ) if ( ioctl( ir_fd, TCSETS, ( char* )&ttybuf ) < 0 ) #endif { - if ( config.verbose ) - fprintf( stderr, "ioctl(IR, TCSETS) failed, errno = %d\n", errno ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "ioctl(IR, TCSETS) failed, errno = %d\n", errno ); */ ir_fd = -1; } @@ -173,8 +173,8 @@ void serial_baud( int baud ) if ( ioctl( ir_fd, TCGETS, ( char* )&ttybuf ) < 0 ) #endif { - if ( config.verbose ) - fprintf( stderr, "ioctl(IR, TCGETS) failed, errno = %d\n", errno ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "ioctl(IR, TCGETS) failed, errno = %d\n", errno ); */ ir_fd = -1; error = 1; @@ -225,8 +225,8 @@ void serial_baud( int baud ) } if ( ( ir_fd >= 0 ) && ( ( ttybuf.c_cflag & CBAUD ) == 0 ) ) { - if ( config.verbose ) - fprintf( stderr, "can\'t set baud rate, using 9600\n" ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "can\'t set baud rate, using 9600\n" ); */ ttybuf.c_cflag |= B9600; } @@ -238,8 +238,8 @@ void serial_baud( int baud ) if ( ioctl( ir_fd, TCSETS, ( char* )&ttybuf ) < 0 ) #endif { - if ( config.verbose ) - fprintf( stderr, "ioctl(IR, TCSETS) failed, errno = %d\n", errno ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "ioctl(IR, TCSETS) failed, errno = %d\n", errno ); */ ir_fd = -1; error = 1; @@ -253,8 +253,8 @@ void serial_baud( int baud ) if ( ioctl( ttyp, TCGETS, ( char* )&ttybuf ) < 0 ) #endif { - if ( config.verbose ) - fprintf( stderr, "ioctl(wire, TCGETS) failed, errno = %d\n", errno ); + /* if ( config.verbose ) */ + /* fprintf( stderr, "ioctl(wire, TCGETS) failed, errno = %d\n", errno ); */ wire_fd = -1; ttyp = -1; @@ -305,8 +305,8 @@ void transmit_char( void ) if ( saturn.io_ctrl & 0x04 ) do_interupt(); } else { - if ( errno != EAGAIN && config.verbose ) - fprintf( stderr, "serial write error: %d\n", errno ); + /* if ( errno != EAGAIN && config.verbose ) */ + /* fprintf( stderr, "serial write error: %d\n", errno ); */ saturn.tcs &= 0x0e; if ( saturn.io_ctrl & 0x04 ) diff --git a/src/emulator.h b/src/emulator.h index f6cd0c2..4bd2582 100644 --- a/src/emulator.h +++ b/src/emulator.h @@ -290,7 +290,7 @@ extern int annunciators_bits[ NB_ANNUNCIATORS ]; // extern bool please_exit; extern bool save_before_exit; -extern void start_emulator( void ); /* used in main.c */ +extern void start_emulator( char* normalized_rom_path, char* normalized_ram_path, char* normalized_state_path, char* normalized_port1_path, char* normalized_port2_path ); /* used in main.c */ extern void exit_emulator( void ); /* used in debugger.c; ui_*.c */ /********************/ diff --git a/src/legacy_tools/checkrom.c b/src/legacy_tools/checkrom.c deleted file mode 100644 index 3ead3ee..0000000 --- a/src/legacy_tools/checkrom.c +++ /dev/null @@ -1,86 +0,0 @@ -#include -#include -#include -#include - -#include "romio.h" - -unsigned char* rom; -unsigned short rom_crc, crc; - -#define calc_crc( n ) ( crc = ( ( crc >> 4 ) ^ ( ( ( crc ^ n ) & 0xf ) * 0x1081 ) ) ) - -int main( int argc, char** argv ) -{ - unsigned char version[ 7 ]; - long ver_addr; - int i, a, c, d0, d1, D0, D1; - int fail; - - if ( argc < 2 ) { - fprintf( stderr, "usage: %s rom-file\n", argv[ 0 ] ); - exit( 1 ); - } - - if ( !read_rom_file( argv[ 1 ], &rom, &rom_size ) ) { - fprintf( stderr, "%s: can\'t read ROM from %s\n", argv[ 0 ], argv[ 1 ] ); - exit( 1 ); - } - - ver_addr = opt_gx ? 0x7ffbf : 0x7fff0; - - for ( i = 0; i < 6; i++ ) { - version[ i ] = rom[ ver_addr + 2 * i + 1 ] << 4; - version[ i ] |= rom[ ver_addr + 2 * i ]; - } - version[ 6 ] = '\0'; - printf( "ROM Version is %s\n", version ); - - for ( i = 0x100; i < 0x140; i++ ) - rom[ i ] = 0x0; - - fail = a = 0; - D0 = 0x00000; - D1 = 0x40000; - for ( unsigned int d = 1; d <= rom_size / 0x80000; d++ ) { - crc = 0x0000; - rom_crc = 0; - for ( i = 0; i < 4; i++ ) { - rom_crc <<= 4; - rom_crc |= ( rom[ 0x80000 * d - i - 1 ] & 0x0f ); - } - - if ( opt_gx ) - printf( "ROM CRC %d reads 0x%.4x\n", d, rom_crc ); - else - printf( "ROM CRC reads 0x%.4x\n", rom_crc ); - - d0 = D0; - d1 = D1; - for ( c = 0x3fff; c >= 0x0000; c-- ) { - for ( i = 0; i < 16; i++ ) - calc_crc( rom[ d0 + i ] ); - - d0 += 16; - - for ( i = 0; i < 16; i++ ) - calc_crc( rom[ d1 + i ] ); - - d1 += 16; - } - D0 += 0x80000; - D1 += 0x80000; - a = crc; - a = ( ( a | 0xf0000 ) + 1 ) & 0xfffff; - - if ( a != 0x00000 ) - fail++; - } - - if ( fail != 0 ) - printf( "IROM %.4x: ROM CRC test FAILED !!!\n", a & 0xffff ); - else - printf( "IROM OK: ROM CRC test passed.\n" ); - - return 0; -} diff --git a/src/legacy_tools/dump2rom.c b/src/legacy_tools/dump2rom.c deleted file mode 100644 index 7854059..0000000 --- a/src/legacy_tools/dump2rom.c +++ /dev/null @@ -1,149 +0,0 @@ -#include -#include -#include -#include -#include -#include - -unsigned char* core; - -#define DEFAULT_ROM_FILE "rom.dump" - -bool write_mem_file( const char* name, unsigned char* mem, size_t size ) -{ - FILE* fp; - unsigned char* tmp_mem; - unsigned char byte; - int i, j; - - if ( NULL == ( fp = fopen( name, "w" ) ) ) { - fprintf( stderr, "can\'t open %s\n", name ); - return 0; - } - - if ( NULL == ( tmp_mem = ( unsigned char* )malloc( size / 2 ) ) ) { - for ( i = 0, j = 0; i < ( int )size / 2; i++ ) { - byte = ( mem[ j++ ] & 0x0f ); - byte |= ( unsigned char )( ( mem[ j++ ] << 4 ) & 0xf0 ); - if ( 1 != fwrite( &byte, 1, 1, fp ) ) { - fprintf( stderr, "can\'t write %s\n", name ); - fclose( fp ); - return false; - } - } - } else { - for ( i = 0, j = 0; i < ( int )size / 2; i++ ) { - tmp_mem[ i ] = ( mem[ j++ ] & 0x0f ); - tmp_mem[ i ] |= ( unsigned char )( ( mem[ j++ ] << 4 ) & 0xf0 ); - } - - if ( fwrite( tmp_mem, 1, ( size_t )size / 2, fp ) != size / 2 ) { - fprintf( stderr, "can\'t write %s\n", name ); - fclose( fp ); - free( tmp_mem ); - return false; - } - - free( tmp_mem ); - } - - fclose( fp ); - return true; -} - -int main( int argc, char** argv ) -{ - FILE* dump; - long addr; - size_t size; - int ch, i; - bool gx, error; - - if ( argc < 2 ) { - fprintf( stderr, "usage: %s hp48-dump-file\n", argv[ 0 ] ); - exit( 1 ); - } - - if ( ( dump = fopen( argv[ 1 ], "r" ) ) == NULL ) { - fprintf( stderr, "%s: can\'t open %s\n", argv[ 0 ], argv[ 1 ] ); - exit( 1 ); - } - - if ( ( core = ( unsigned char* )malloc( 0x100000 ) ) == NULL ) { - fprintf( stderr, "%s: can\'t malloc %d bytes\n", argv[ 0 ], 0x100000 ); - exit( 1 ); - } - memset( core, 0, 0x100000 ); - - gx = false; - error = false; - while ( 1 ) { - addr = 0; - for ( i = 0; i < 5; i++ ) { - addr <<= 4; - if ( ( ch = fgetc( dump ) ) < 0 ) { - error = true; - break; - } - if ( ch >= '0' && ch <= '9' ) { - addr |= ch - '0'; - } else if ( ch >= 'A' && ch <= 'F' ) { - addr |= ch - 'A' + 10; - } else { - fprintf( stderr, "%s: Illegal char %c at %lx\n", argv[ 0 ], ch, addr ); - error = true; - break; - } - } - if ( error ) - break; - if ( addr >= 0x80000 ) - gx = true; - if ( ( ch = fgetc( dump ) ) < 0 ) { - fprintf( stderr, "%s: Unexpected EOF at %lx\n", argv[ 0 ], addr ); - break; - } - if ( ch != ':' ) { - fprintf( stderr, "%s: Illegal char %c, expected \':\' at %lx\n", argv[ 0 ], ch, addr ); - break; - } - for ( i = 0; i < 16; i++ ) { - if ( ( ch = fgetc( dump ) ) < 0 ) { - fprintf( stderr, "%s: Unexpected EOF at %lx\n", argv[ 0 ], addr ); - error = true; - break; - } - if ( ch >= '0' && ch <= '9' ) { - core[ addr++ ] = ( unsigned char )( ch - '0' ); - } else if ( ch >= 'A' && ch <= 'F' ) { - core[ addr++ ] = ( unsigned char )( ch - 'A' + 10 ); - } else { - fprintf( stderr, "%s: Illegal char %c at %lx\n", argv[ 0 ], ch, addr ); - error = true; - break; - } - } - if ( error ) - break; - if ( ( ch = fgetc( dump ) ) < 0 ) - break; - if ( ch != '\n' ) { - fprintf( stderr, "%s: Illegal char %c, expected \'\\n\' at %lx\n", argv[ 0 ], ch, addr ); - break; - } - } - - if ( !gx && core[ 0x29 ] == 0x0 ) - gx = true; - - if ( gx ) - size = 0x100000; - else - size = 0x80000; - if ( !write_mem_file( DEFAULT_ROM_FILE, core, size ) ) { - fprintf( stderr, "%s: can\'t write to %s\n", argv[ 0 ], DEFAULT_ROM_FILE ); - exit( 1 ); - } - - exit( 0 ); -} diff --git a/src/ui.c b/src/ui.c deleted file mode 100644 index 6865a97..0000000 --- a/src/ui.c +++ /dev/null @@ -1,2346 +0,0 @@ -#include -#include -#include - -#include "config.h" -#include "ui.h" -#include "ui_inner.h" - -int last_annunc_state = -1; - -unsigned char lcd_nibbles_buffer[ DISP_ROWS ][ NIBS_PER_BUFFER_ROW ]; - -letter_t small_font[ 128 ] = { - {0, 0, 0 }, - {nl_gx_width, nl_gx_height, nl_gx_bits }, /* \x01 == \n gx */ - {comma_gx_width, comma_gx_height, comma_gx_bits }, /* \x02 == comma gx */ - {arrow_gx_width, arrow_gx_height, arrow_gx_bits }, /* \x03 == \-> gx */ - {equal_gx_width, equal_gx_height, equal_gx_bits }, /* \x04 == equal gx */ - {pi_gx_width, pi_gx_height, pi_gx_bits }, /* \x05 == pi gx */ - {arrow_width, arrow_height, arrow_bits }, /* \x06 == left arrow */ - {diff_width, diff_height, diff_bits }, /* \x07 == differential */ - {integral_width, integral_height, integral_bits }, /* \x08 == integral */ - {sigma_width, sigma_height, sigma_bits }, /* \x09 == sigma */ - {sqr_width, sqr_height, sqr_bits }, /* \x0a == sqr */ - {root_width, root_height, root_bits }, /* \x0b == root */ - {pow10_width, pow10_height, pow10_bits }, /* \x0c == pow10 */ - {exp_width, exp_height, exp_bits }, /* \x0d == exp */ - {prog_width, prog_height, prog_bits }, /* \x0e == << >> */ - {string_width, string_height, string_bits }, /* \x0f == " " */ - {nl_width, nl_height, nl_bits }, /* \x10 == New Line # 16 */ - {pi_width, pi_height, pi_bits }, /* \x11 == pi */ - {angle_width, angle_height, angle_bits }, /* \x12 == angle */ - {sqr_gx_width, sqr_gx_height, sqr_gx_bits }, /* \x13 == sqr gx */ - {root_gx_width, root_gx_height, root_gx_bits }, /* \x14 == root gx */ - {pow10_gx_width, pow10_gx_height, pow10_gx_bits }, /* \x15 == pow10 gx */ - {exp_gx_width, exp_gx_height, exp_gx_bits }, /* \x16 == exp gx */ - {parens_gx_width, parens_gx_height, parens_gx_bits }, /* \x17 == ( ) gx */ - {hash_gx_width, hash_gx_height, hash_gx_bits }, /* \x18 == # gx */ - {bracket_gx_width, bracket_gx_height, bracket_gx_bits }, /* \x19 == [] gx */ - {under_gx_width, under_gx_height, under_gx_bits }, /* \x1a == _ gx */ - {prog_gx_width, prog_gx_height, prog_gx_bits }, /* \x1b == << >> gx */ - {quote_gx_width, quote_gx_height, quote_gx_bits }, /* \x1c == " " gx */ - {curly_gx_width, curly_gx_height, curly_gx_bits }, /* \x1d == {} gx */ - {colon_gx_width, colon_gx_height, colon_gx_bits }, /* \x1e == :: gx */ - {angle_gx_width, angle_gx_height, angle_gx_bits }, /* \x1f == angle gx */ - {blank_width, blank_height, blank_bits }, /* # 32 */ - {0, 0, 0 }, - {0, 0, 0 }, - {hash_width, hash_height, hash_bits }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {lbrace_width, lbrace_height, lbrace_bits }, - {rbrace_width, rbrace_height, rbrace_bits }, - {0, 0, 0 }, - {0, 0, 0 }, - {comma_width, comma_height, comma_bits }, - {0, 0, 0 }, - {0, 0, 0 }, - {slash_width, slash_height, slash_bits }, - {zero_width, zero_height, zero_bits }, /* # 48 */ - {one_width, one_height, one_bits }, - {two_width, two_height, two_bits }, - {three_width, three_height, three_bits }, - {four_width, four_height, four_bits }, - {five_width, five_height, five_bits }, - {six_width, six_height, six_bits }, - {seven_width, seven_height, seven_bits }, - {eight_width, eight_height, eight_bits }, - {nine_width, nine_height, nine_bits }, - {small_colon_width, small_colon_height, small_colon_bits}, - {0, 0, 0 }, - {0, 0, 0 }, - {equal_width, equal_height, equal_bits }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, /* # 64 */ - {A_width, A_height, A_bits }, - {B_width, B_height, B_bits }, - {C_width, C_height, C_bits }, - {D_width, D_height, D_bits }, - {E_width, E_height, E_bits }, - {F_width, F_height, F_bits }, - {G_width, G_height, G_bits }, - {H_width, H_height, H_bits }, - {I_width, I_height, I_bits }, - {J_width, J_height, J_bits }, - {K_width, K_height, K_bits }, - {L_width, L_height, L_bits }, - {M_width, M_height, M_bits }, - {N_width, N_height, N_bits }, - {O_width, O_height, O_bits }, - {P_width, P_height, P_bits }, /* # 80 */ - {Q_width, Q_height, Q_bits }, - {R_width, R_height, R_bits }, - {S_width, S_height, S_bits }, - {T_width, T_height, T_bits }, - {U_width, U_height, U_bits }, - {V_width, V_height, V_bits }, - {W_width, W_height, W_bits }, - {X_width, X_height, X_bits }, - {Y_width, Y_height, Y_bits }, - {Z_width, Z_height, Z_bits }, - {lbracket_width, lbracket_height, lbracket_bits }, - {0, 0, 0 }, - {rbracket_width, rbracket_height, rbracket_bits }, - {0, 0, 0 }, - {under_width, under_height, under_bits }, - {0, 0, 0 }, /* # 96 */ - {0, 0, 0 }, /* a */ - {0, 0, 0 }, /* b */ - {0, 0, 0 }, /* c */ - {d_width, d_height, d_bits }, - {e_width, e_height, e_bits }, - {0, 0, 0 }, /* f */ - {0, 0, 0 }, /* g */ - {0, 0, 0 }, /* h */ - {i_width, i_height, i_bits }, - {0, 0, 0 }, /* j */ - {0, 0, 0 }, /* k */ - {0, 0, 0 }, /* l */ - {0, 0, 0 }, /* m */ - {0, 0, 0 }, /* n */ - {0, 0, 0 }, /* o */ - {p_width, p_height, p_bits }, - {0, 0, 0 }, /* q */ - {r_width, r_height, r_bits }, - {s_width, s_height, s_bits }, - {t_width, t_height, t_bits }, - {0, 0, 0 }, /* u */ - {v_width, v_height, v_bits }, - {w_width, w_height, w_bits }, - {0, 0, 0 }, /* x */ - {y_width, y_height, y_bits }, - {0, 0, 0 }, /* z */ - {lcurly_width, lcurly_height, lcurly_bits }, - {0, 0, 0 }, - {rcurly_width, rcurly_height, rcurly_bits }, - {0, 0, 0 }, - {0, 0, 0 }, /* 127 */ -}; - -letter_t big_font[ 128 ] = { - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, /* # 16 */ - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, /* # 32 */ - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {big_font_dot_width, big_font_dot_height, big_font_dot_bits}, /* # 46 */ - {0, 0, 0 }, - {big_font_0_width, big_font_0_height, big_font_0_bits }, /* # 48 */ - {big_font_1_width, big_font_1_height, big_font_1_bits }, - {big_font_2_width, big_font_2_height, big_font_2_bits }, - {big_font_3_width, big_font_3_height, big_font_3_bits }, - {big_font_4_width, big_font_4_height, big_font_4_bits }, - {big_font_5_width, big_font_5_height, big_font_5_bits }, - {big_font_6_width, big_font_6_height, big_font_6_bits }, - {big_font_7_width, big_font_7_height, big_font_7_bits }, - {big_font_8_width, big_font_8_height, big_font_8_bits }, - {big_font_9_width, big_font_9_height, big_font_9_bits }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, /* # 64 */ - {big_font_A_width, big_font_A_height, big_font_A_bits }, - {0, 0, 0 }, - {big_font_C_width, big_font_C_height, big_font_C_bits }, - {big_font_D_width, big_font_D_height, big_font_D_bits }, - {big_font_E_width, big_font_E_height, big_font_E_bits }, - {0, 0, 0 }, - {big_font_G_width, big_font_G_height, big_font_G_bits }, - {big_font_H_width, big_font_H_height, big_font_H_bits }, - {big_font_I_width, big_font_I_height, big_font_I_bits }, - {0, 0, 0 }, - {0, 0, 0 }, - {big_font_L_width, big_font_L_height, big_font_L_bits }, - {big_font_M_width, big_font_M_height, big_font_M_bits }, - {big_font_N_width, big_font_N_height, big_font_N_bits }, - {big_font_O_width, big_font_O_height, big_font_O_bits }, - {big_font_P_width, big_font_P_height, big_font_P_bits }, /* # 80 */ - {0, 0, 0 }, - {big_font_R_width, big_font_R_height, big_font_R_bits }, - {big_font_S_width, big_font_S_height, big_font_S_bits }, - {big_font_T_width, big_font_T_height, big_font_T_bits }, - {0, 0, 0 }, - {big_font_V_width, big_font_V_height, big_font_V_bits }, - {0, 0, 0 }, - {big_font_X_width, big_font_X_height, big_font_X_bits }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, /* # 96 */ - {0, 0, 0 }, /* a */ - {0, 0, 0 }, /* b */ - {0, 0, 0 }, /* c */ - {0, 0, 0 }, /* d */ - {0, 0, 0 }, /* e */ - {0, 0, 0 }, /* f */ - {0, 0, 0 }, /* g */ - {0, 0, 0 }, /* h */ - {0, 0, 0 }, /* i */ - {0, 0, 0 }, /* j */ - {0, 0, 0 }, /* k */ - {0, 0, 0 }, /* l */ - {0, 0, 0 }, /* m */ - {0, 0, 0 }, /* n */ - {0, 0, 0 }, /* o */ - {0, 0, 0 }, /* p */ - {0, 0, 0 }, /* q */ - {0, 0, 0 }, /* r */ - {0, 0, 0 }, /* s */ - {0, 0, 0 }, /* t */ - {0, 0, 0 }, /* u */ - {0, 0, 0 }, /* v */ - {0, 0, 0 }, /* w */ - {0, 0, 0 }, /* x */ - {0, 0, 0 }, /* y */ - {0, 0, 0 }, /* z */ - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 }, - {0, 0, 0 } -}; - -color_t colors_sx[ NB_COLORS ] = { - { - /* #ffffff */ - .name = "white", - .r = 0xff, - .g = 0xff, - .b = 0xff, - .mono_rgb = 0xff, - .gray_rgb = 0xff, - }, - { - /* #ffa600 */ - .name = "left", - .r = 0xff, - .g = 0xa6, - .b = 0x00, - .mono_rgb = 0xff, - .gray_rgb = 0xe6, - }, - { - /* #00d2ff */ - .name = "right", - .r = 0x00, - .g = 0xd2, - .b = 0xff, - .mono_rgb = 0xff, - .gray_rgb = 0xa9, - }, - { - /* #6d5d5d */ - .name = "but_top", - .r = 0x6d, - .g = 0x5d, - .b = 0x5d, - .mono_rgb = 0x00, - .gray_rgb = 0x5b, - }, - { - /* #5a4d4d */ - .name = "button", - .r = 0x5a, - .g = 0x4d, - .b = 0x4d, - .mono_rgb = 0x00, - .gray_rgb = 0x51, - }, - { - /* #4c4141 */ - .name = "but_bot", - .r = 0x4c, - .g = 0x41, - .b = 0x41, - .mono_rgb = 0x00, - .gray_rgb = 0x45, - }, - { - /* #cadd5c */ - .name = "lcd_col", - .r = 0xca, - .g = 0xdd, - .b = 0x5c, - .mono_rgb = 0xff, - .gray_rgb = 0xcd, - }, - { - /* #000080 */ - .name = "pix_col", - .r = 0x00, - .g = 0x00, - .b = 0x80, - .mono_rgb = 0x00, - .gray_rgb = 0x14, - }, - { - /* #6d4e4e */ - .name = "pad_top", - .r = 0x6d, - .g = 0x4e, - .b = 0x4e, - .mono_rgb = 0x00, - .gray_rgb = 0x58, - }, - { - /* #5a4040 */ - .name = "pad", - .r = 0x5a, - .g = 0x40, - .b = 0x40, - .mono_rgb = 0x00, - .gray_rgb = 0x49, - }, - { - /* #4c3636 */ - .name = "pad_bot", - .r = 0x4c, - .g = 0x36, - .b = 0x36, - .mono_rgb = 0x00, - .gray_rgb = 0x3c, - }, - { - /* #9b7654 */ - .name = "disp_pad_top", - .r = 0x9b, - .g = 0x76, - .b = 0x54, - .mono_rgb = 0x00, - .gray_rgb = 0x7c, - }, - { - /* #7c5e43 */ - .name = "disp_pad", - .r = 0x7c, - .g = 0x5e, - .b = 0x43, - .mono_rgb = 0x00, - .gray_rgb = 0x63, - }, - { - /* #644b35 */ - .name = "disp_pad_bot", - .r = 0x64, - .g = 0x4b, - .b = 0x35, - .mono_rgb = 0x00, - .gray_rgb = 0x4f, - }, - { - /* #cca96b */ - .name = "logo", - .r = 0xcc, - .g = 0xa9, - .b = 0x6b, - .mono_rgb = 0xff, - .gray_rgb = 0xac, - }, - { - /* #404040 */ - .name = "logo_back", - .r = 0x40, - .g = 0x40, - .b = 0x40, - .mono_rgb = 0x00, - .gray_rgb = 0x41, - }, - { - /* #cab890 */ - .name = "label", - .r = 0xca, - .g = 0xb8, - .b = 0x90, - .mono_rgb = 0xff, - .gray_rgb = 0xb9, - }, - { - /* #000000 */ - .name = "frame", - .r = 0x00, - .g = 0x00, - .b = 0x00, - .mono_rgb = 0xff, - .gray_rgb = 0x00, - }, - { - /* #3c2a2a */ - .name = "underlay", - .r = 0x3c, - .g = 0x2a, - .b = 0x2a, - .mono_rgb = 0x00, - .gray_rgb = 0x30, - }, - { - /* #000000 */ - .name = "black", - .r = 0x00, - .g = 0x00, - .b = 0x00, - .mono_rgb = 0x00, - .gray_rgb = 0x00, - }, -}; - -color_t colors_gx[ NB_COLORS ] = { - { - /* #ffffff */ - .name = "white", - .r = 0xff, - .g = 0xff, - .b = 0xff, - .mono_rgb = 0xff, - .gray_rgb = 0xff, - }, - { - /* #ffbaff */ - .name = "left", - .r = 0xff, - .g = 0xba, - .b = 0xff, - .mono_rgb = 0xff, - .gray_rgb = 0xdc, - }, - { - /* #00ffcc */ - .name = "right", - .r = 0x00, - .g = 0xff, - .b = 0xcc, - .mono_rgb = 0xff, - .gray_rgb = 0xa9, - }, - { - /* #646464 */ - .name = "but_top", - .r = 0x64, - .g = 0x64, - .b = 0x64, - .mono_rgb = 0x00, - .gray_rgb = 0x68, - }, - { - /* #585858 */ - .name = "button", - .r = 0x58, - .g = 0x58, - .b = 0x58, - .mono_rgb = 0x00, - .gray_rgb = 0x58, - }, - { - /* #4a4a4a */ - .name = "but_bot", - .r = 0x4a, - .g = 0x4a, - .b = 0x4a, - .mono_rgb = 0x00, - .gray_rgb = 0x4a, - }, - { - /* #cadd5c */ - .name = "lcd_col", - .r = 0xca, - .g = 0xdd, - .b = 0x5c, - .mono_rgb = 0xff, - .gray_rgb = 0xcd, - }, - { - /* #000080 */ - .name = "pix_col", - .r = 0x00, - .g = 0x00, - .b = 0x80, - .mono_rgb = 0x00, - .gray_rgb = 0x14, - }, - { - /* #585858 */ - .name = "pad_top", - .r = 0x58, - .g = 0x58, - .b = 0x58, - .mono_rgb = 0x00, - .gray_rgb = 0x58, - }, - { - /* #4a4a4a */ - .name = "pad", - .r = 0x4a, - .g = 0x4a, - .b = 0x4a, - .mono_rgb = 0x00, - .gray_rgb = 0x4a, - }, - { - /* #404040 */ - .name = "pad_bot", - .r = 0x40, - .g = 0x40, - .b = 0x40, - .mono_rgb = 0x00, - .gray_rgb = 0x40, - }, - { - /* #808080 */ - .name = "disp_pad_top", - .r = 0x80, - .g = 0x80, - .b = 0x80, - .mono_rgb = 0x00, - .gray_rgb = 0x80, - }, - { - /* #68686E */ - .name = "disp_pad", - .r = 0x68, - .g = 0x68, - .b = 0x6E, - .mono_rgb = 0x00, - .gray_rgb = 0x68, - }, - { - /* #54545a */ - .name = "disp_pad_bot", - .r = 0x54, - .g = 0x54, - .b = 0x5a, - .mono_rgb = 0x00, - .gray_rgb = 0x54, - }, - { - /* #b0b0b8 */ - .name = "logo", - .r = 0xb0, - .g = 0xb0, - .b = 0xb8, - .mono_rgb = 0xff, - .gray_rgb = 0xb0, - }, - { - /* #68686e */ - .name = "logo_back", - .r = 0x68, - .g = 0x68, - .b = 0x6e, - .mono_rgb = 0x00, - .gray_rgb = 0x68, - }, - { - /* #f0f0f0 */ - .name = "label", - .r = 0xf0, - .g = 0xf0, - .b = 0xf0, - .mono_rgb = 0xff, - .gray_rgb = 0xf0, - }, - { - /* #000000 */ - .name = "frame", - .r = 0x00, - .g = 0x00, - .b = 0x00, - .mono_rgb = 0xff, - .gray_rgb = 0x00, - }, - { - /* #68686e */ - .name = "underlay", - .r = 0x68, - .g = 0x68, - .b = 0x6e, - .mono_rgb = 0x00, - .gray_rgb = 0x68, - }, - { - /* #000000 */ - .name = "black", - .r = 0x00, - .g = 0x00, - .b = 0x00, - .mono_rgb = 0x00, - .gray_rgb = 0x00, - }, -}; - -button_t buttons_sx[ NB_KEYS ] = { - {.name = "A", - .x = 0, - .y = 0, - .w = 36, - .h = 23, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = menu_label_width, - .lh = menu_label_height, - .lb = menu_label_bitmap, - .letter = "A", - .left = 0, - .is_menu = 0, - .right = 0, - .sub = 0 }, - {.name = "B", - .x = 50, - .y = 0, - .w = 36, - .h = 23, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = menu_label_width, - .lh = menu_label_height, - .lb = menu_label_bitmap, - .letter = "B", - .left = 0, - .is_menu = 0, - .right = 0, - .sub = 0 }, - {.name = "C", - .x = 100, - .y = 0, - .w = 36, - .h = 23, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = menu_label_width, - .lh = menu_label_height, - .lb = menu_label_bitmap, - .letter = "C", - .left = 0, - .is_menu = 0, - .right = 0, - .sub = 0 }, - {.name = "D", - .x = 150, - .y = 0, - .w = 36, - .h = 23, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = menu_label_width, - .lh = menu_label_height, - .lb = menu_label_bitmap, - .letter = "D", - .left = 0, - .is_menu = 0, - .right = 0, - .sub = 0 }, - {.name = "E", - .x = 200, - .y = 0, - .w = 36, - .h = 23, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = menu_label_width, - .lh = menu_label_height, - .lb = menu_label_bitmap, - .letter = "E", - .left = 0, - .is_menu = 0, - .right = 0, - .sub = 0 }, - {.name = "F", - .x = 250, - .y = 0, - .w = 36, - .h = 23, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = menu_label_width, - .lh = menu_label_height, - .lb = menu_label_bitmap, - .letter = "F", - .left = 0, - .is_menu = 0, - .right = 0, - .sub = 0 }, - - {.name = "MTH", - .x = 0, - .y = 50, - .w = 36, - .h = 26, - .lc = WHITE, - .label = "MTH", - .font_size = 0, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = "G", - .left = "PRINT", - .is_menu = 1, - .right = 0, - .sub = 0 }, - {.name = "PRG", - .x = 50, - .y = 50, - .w = 36, - .h = 26, - .lc = WHITE, - .label = "PRG", - .font_size = 0, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = "H", - .left = "I/O", - .is_menu = 1, - .right = 0, - .sub = 0 }, - {.name = "CST", - .x = 100, - .y = 50, - .w = 36, - .h = 26, - .lc = WHITE, - .label = "CST", - .font_size = 0, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = "I", - .left = "MODES", - .is_menu = 1, - .right = 0, - .sub = 0 }, - {.name = "VAR", - .x = 150, - .y = 50, - .w = 36, - .h = 26, - .lc = WHITE, - .label = "VAR", - .font_size = 0, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = "J", - .left = "MEMORY", - .is_menu = 1, - .right = 0, - .sub = 0 }, - {.name = "UP", - .x = 200, - .y = 50, - .w = 36, - .h = 26, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = up_width, - .lh = up_height, - .lb = up_bitmap, - .letter = "K", - .left = "LIBRARY", - .is_menu = 1, - .right = 0, - .sub = 0 }, - {.name = "NXT", - .x = 250, - .y = 50, - .w = 36, - .h = 26, - .lc = WHITE, - .label = "NXT", - .font_size = 0, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = "L", - .left = "PREV", - .is_menu = 0, - .right = 0, - .sub = 0 }, - - {.name = "QUOTE", - .x = 0, - .y = 100, - .w = 36, - .h = 26, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = quote_width, - .lh = quote_height, - .lb = quote_bitmap, - .letter = "M", - .left = "UP", - .is_menu = 0, - .right = "HOME", - .sub = 0 }, - {.name = "STO", - .x = 50, - .y = 100, - .w = 36, - .h = 26, - .lc = WHITE, - .label = "STO", - .font_size = 0, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = "N", - .left = "DEF", - .is_menu = 0, - .right = "RCL", - .sub = 0 }, - {.name = "EVAL", - .x = 100, - .y = 100, - .w = 36, - .h = 26, - .lc = WHITE, - .label = "EVAL", - .font_size = 0, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = "O", - .left = "\x80Q", - .is_menu = 0, - .right = "\x80NUM", - .sub = 0 }, - {.name = "LEFT", - .x = 150, - .y = 100, - .w = 36, - .h = 26, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = left_width, - .lh = left_height, - .lb = left_bitmap, - .letter = "P", - .left = "GRAPH", - .is_menu = 0, - .right = 0, - .sub = 0 }, - {.name = "DOWN", - .x = 200, - .y = 100, - .w = 36, - .h = 26, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = down_width, - .lh = down_height, - .lb = down_bitmap, - .letter = "Q", - .left = "REVIEW", - .is_menu = 0, - .right = 0, - .sub = 0 }, - {.name = "RIGHT", - .x = 250, - .y = 100, - .w = 36, - .h = 26, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = right_width, - .lh = right_height, - .lb = right_bitmap, - .letter = "R", - .left = "SWAP", - .is_menu = 0, - .right = 0, - .sub = 0 }, - - {.name = "SIN", - .x = 0, - .y = 150, - .w = 36, - .h = 26, - .lc = WHITE, - .label = "SIN", - .font_size = 0, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = "S", - .left = "ASIN", - .is_menu = 0, - .right = "\x07", - .sub = 0 }, - {.name = "COS", - .x = 50, - .y = 150, - .w = 36, - .h = 26, - .lc = WHITE, - .label = "COS", - .font_size = 0, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = "T", - .left = "ACOS", - .is_menu = 0, - .right = "\x08", - .sub = 0 }, - {.name = "TAN", - .x = 100, - .y = 150, - .w = 36, - .h = 26, - .lc = WHITE, - .label = "TAN", - .font_size = 0, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = "U", - .left = "ATAN", - .is_menu = 0, - .right = "\x09", - .sub = 0 }, - {.name = "SQRT", - .x = 150, - .y = 150, - .w = 36, - .h = 26, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = sqrt_width, - .lh = sqrt_height, - .lb = sqrt_bitmap, - .letter = "V", - .left = "\x0a", - .is_menu = 0, - .right = "\x0b", - .sub = 0 }, - {.name = "POWER", - .x = 200, - .y = 150, - .w = 36, - .h = 26, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = power_width, - .lh = power_height, - .lb = power_bitmap, - .letter = "W", - .left = "\x0c", - .is_menu = 0, - .right = "LOG", - .sub = 0 }, - {.name = "INV", - .x = 250, - .y = 150, - .w = 36, - .h = 26, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = inv_width, - .lh = inv_height, - .lb = inv_bitmap, - .letter = "X", - .left = "\x0d", - .is_menu = 0, - .right = "LN", - .sub = 0 }, - - {.name = "ENTER", - .x = 0, - .y = 200, - .w = 86, - .h = 26, - .lc = WHITE, - .label = "ENTER", - .font_size = 2, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = 0, - .left = "EQUATION", - .is_menu = 0, - .right = "MATRIX", - .sub = 0 }, - {.name = "NEG", - .x = 100, - .y = 200, - .w = 36, - .h = 26, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = neg_width, - .lh = neg_height, - .lb = neg_bitmap, - .letter = "Y", - .left = "EDIT", - .is_menu = 0, - .right = "VISIT", - .sub = 0 }, - {.name = "EEX", - .x = 150, - .y = 200, - .w = 36, - .h = 26, - .lc = WHITE, - .label = "EEX", - .font_size = 0, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = "Z", - .left = "2D", - .is_menu = 0, - .right = "3D", - .sub = 0 }, - {.name = "DEL", - .x = 200, - .y = 200, - .w = 36, - .h = 26, - .lc = WHITE, - .label = "DEL", - .font_size = 0, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = 0, - .left = "PURGE", - .is_menu = 0, - .right = 0, - .sub = 0 }, - {.name = "BS", - .x = 250, - .y = 200, - .w = 36, - .h = 26, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = bs_width, - .lh = bs_height, - .lb = bs_bitmap, - .letter = 0, - .left = "DROP", - .is_menu = 0, - .right = "CLR", - .sub = 0 }, - - {.name = "ALPHA", - .x = 0, - .y = 250, - .w = 36, - .h = 26, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = alpha_width, - .lh = alpha_height, - .lb = alpha_bitmap, - .letter = 0, - .left = "USR", - .is_menu = 0, - .right = "ENTRY", - .sub = 0 }, - {.name = "7", - .x = 60, - .y = 250, - .w = 46, - .h = 26, - .lc = WHITE, - .label = "7", - .font_size = 1, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = 0, - .left = "SOLVE", - .is_menu = 1, - .right = 0, - .sub = 0 }, - {.name = "8", - .x = 120, - .y = 250, - .w = 46, - .h = 26, - .lc = WHITE, - .label = "8", - .font_size = 1, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = 0, - .left = "PLOT", - .is_menu = 1, - .right = 0, - .sub = 0 }, - {.name = "9", - .x = 180, - .y = 250, - .w = 46, - .h = 26, - .lc = WHITE, - .label = "9", - .font_size = 1, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = 0, - .left = "ALGEBRA", - .is_menu = 1, - .right = 0, - .sub = 0 }, - {.name = "DIV", - .x = 240, - .y = 250, - .w = 46, - .h = 26, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = div_width, - .lh = div_height, - .lb = div_bitmap, - .letter = 0, - .left = "( )", - .is_menu = 0, - .right = "#", - .sub = 0 }, - - {.name = "SHL", - .x = 0, - .y = 300, - .w = 36, - .h = 26, - .lc = LEFT, - .label = 0, - .font_size = 0, - .lw = shl_width, - .lh = shl_height, - .lb = shl_bitmap, - .letter = 0, - .left = 0, - .is_menu = 0, - .right = 0, - .sub = 0 }, - {.name = "4", - .x = 60, - .y = 300, - .w = 46, - .h = 26, - .lc = WHITE, - .label = "4", - .font_size = 1, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = 0, - .left = "TIME", - .is_menu = 1, - .right = 0, - .sub = 0 }, - {.name = "5", - .x = 120, - .y = 300, - .w = 46, - .h = 26, - .lc = WHITE, - .label = "5", - .font_size = 1, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = 0, - .left = "STAT", - .is_menu = 1, - .right = 0, - .sub = 0 }, - {.name = "6", - .x = 180, - .y = 300, - .w = 46, - .h = 26, - .lc = WHITE, - .label = "6", - .font_size = 1, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = 0, - .left = "UNITS", - .is_menu = 1, - .right = 0, - .sub = 0 }, - {.name = "MUL", - .x = 240, - .y = 300, - .w = 46, - .h = 26, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = mul_width, - .lh = mul_height, - .lb = mul_bitmap, - .letter = 0, - .left = "[ ]", - .is_menu = 0, - .right = "_", - .sub = 0 }, - - {.name = "SHR", - .x = 0, - .y = 350, - .w = 36, - .h = 26, - .lc = RIGHT, - .label = 0, - .font_size = 0, - .lw = shr_width, - .lh = shr_height, - .lb = shr_bitmap, - .letter = 0, - .left = 0, - .is_menu = 0, - .right = 0, - .sub = 0 }, - {.name = "1", - .x = 60, - .y = 350, - .w = 46, - .h = 26, - .lc = WHITE, - .label = "1", - .font_size = 1, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = 0, - .left = "RAD", - .is_menu = 0, - .right = "POLAR", - .sub = 0 }, - {.name = "2", - .x = 120, - .y = 350, - .w = 46, - .h = 26, - .lc = WHITE, - .label = "2", - .font_size = 1, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = 0, - .left = "STACK", - .is_menu = 0, - .right = "ARG", - .sub = 0 }, - {.name = "3", - .x = 180, - .y = 350, - .w = 46, - .h = 26, - .lc = WHITE, - .label = "3", - .font_size = 1, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = 0, - .left = "CMD", - .is_menu = 0, - .right = "MENU", - .sub = 0 }, - {.name = "MINUS", - .x = 240, - .y = 350, - .w = 46, - .h = 26, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = minus_width, - .lh = minus_height, - .lb = minus_bitmap, - .letter = 0, - .left = "\x0e", - .is_menu = 0, - .right = "\x0f", - .sub = 0 }, - - {.name = "ON", - .x = 0, - .y = 400, - .w = 36, - .h = 26, - .lc = WHITE, - .label = "ON", - .font_size = 0, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = 0, - .left = "CONT", - .is_menu = 0, - .right = "OFF", - .sub = "ATTN"}, - {.name = "0", - .x = 60, - .y = 400, - .w = 46, - .h = 26, - .lc = WHITE, - .label = "0", - .font_size = 1, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = 0, - .left = "= ", - .is_menu = 0, - .right = " \x80", - .sub = 0 }, - {.name = "PERIOD", - .x = 120, - .y = 400, - .w = 46, - .h = 26, - .lc = WHITE, - .label = ".", - .font_size = 1, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = 0, - .left = ",", - .is_menu = 0, - .right = " \x10", - .sub = 0 }, - {.name = "SPC", - .x = 180, - .y = 400, - .w = 46, - .h = 26, - .lc = WHITE, - .label = "SPC", - .font_size = 0, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = 0, - .left = "\x11 ", - .is_menu = 0, - .right = " \x12", - .sub = 0 }, - {.name = "PLUS", - .x = 240, - .y = 400, - .w = 46, - .h = 26, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = plus_width, - .lh = plus_height, - .lb = plus_bitmap, - .letter = 0, - .left = "{ }", - .is_menu = 0, - .right = ": :", - .sub = 0 }, -}; - -button_t buttons_gx[ NB_KEYS ] = { - {.name = "A", - .x = 0, - .y = 0, - .w = 36, - .h = 23, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = menu_label_width, - .lh = menu_label_height, - .lb = menu_label_bitmap, - .letter = "A", - .left = 0, - .is_menu = 0, - .right = 0, - .sub = 0 }, - {.name = "B", - .x = 50, - .y = 0, - .w = 36, - .h = 23, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = menu_label_width, - .lh = menu_label_height, - .lb = menu_label_bitmap, - .letter = "B", - .left = 0, - .is_menu = 0, - .right = 0, - .sub = 0 }, - {.name = "C", - .x = 100, - .y = 0, - .w = 36, - .h = 23, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = menu_label_width, - .lh = menu_label_height, - .lb = menu_label_bitmap, - .letter = "C", - .left = 0, - .is_menu = 0, - .right = 0, - .sub = 0 }, - {.name = "D", - .x = 150, - .y = 0, - .w = 36, - .h = 23, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = menu_label_width, - .lh = menu_label_height, - .lb = menu_label_bitmap, - .letter = "D", - .left = 0, - .is_menu = 0, - .right = 0, - .sub = 0 }, - {.name = "E", - .x = 200, - .y = 0, - .w = 36, - .h = 23, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = menu_label_width, - .lh = menu_label_height, - .lb = menu_label_bitmap, - .letter = "E", - .left = 0, - .is_menu = 0, - .right = 0, - .sub = 0 }, - {.name = "F", - .x = 250, - .y = 0, - .w = 36, - .h = 23, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = menu_label_width, - .lh = menu_label_height, - .lb = menu_label_bitmap, - .letter = "F", - .left = 0, - .is_menu = 0, - .right = 0, - .sub = 0 }, - - {.name = "MTH", - .x = 0, - .y = 50, - .w = 36, - .h = 26, - .lc = WHITE, - .label = "MTH", - .font_size = 0, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = "G", - .left = "RAD", - .is_menu = 0, - .right = "POLAR", - .sub = 0 }, - {.name = "PRG", - .x = 50, - .y = 50, - .w = 36, - .h = 26, - .lc = WHITE, - .label = "PRG", - .font_size = 0, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = "H", - .left = 0, - .is_menu = 0, - .right = "CHARS", - .sub = 0 }, - {.name = "CST", - .x = 100, - .y = 50, - .w = 36, - .h = 26, - .lc = WHITE, - .label = "CST", - .font_size = 0, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = "I", - .left = 0, - .is_menu = 0, - .right = "MODES", - .sub = 0 }, - {.name = "VAR", - .x = 150, - .y = 50, - .w = 36, - .h = 26, - .lc = WHITE, - .label = "VAR", - .font_size = 0, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = "J", - .left = 0, - .is_menu = 0, - .right = "MEMORY", - .sub = 0 }, - {.name = "UP", - .x = 200, - .y = 50, - .w = 36, - .h = 26, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = up_width, - .lh = up_height, - .lb = up_bitmap, - .letter = "K", - .left = 0, - .is_menu = 0, - .right = "STACK", - .sub = 0 }, - {.name = "NXT", - .x = 250, - .y = 50, - .w = 36, - .h = 26, - .lc = WHITE, - .label = "NXT", - .font_size = 0, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = "L", - .left = "PREV", - .is_menu = 0, - .right = "MENU", - .sub = 0 }, - - {.name = "QUOTE", - .x = 0, - .y = 100, - .w = 36, - .h = 26, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = quote_width, - .lh = quote_height, - .lb = quote_bitmap, - .letter = "M", - .left = "UP", - .is_menu = 0, - .right = "HOME", - .sub = 0 }, - {.name = "STO", - .x = 50, - .y = 100, - .w = 36, - .h = 26, - .lc = WHITE, - .label = "STO", - .font_size = 0, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = "N", - .left = "DEF", - .is_menu = 0, - .right = "RCL", - .sub = 0 }, - {.name = "EVAL", - .x = 100, - .y = 100, - .w = 36, - .h = 26, - .lc = WHITE, - .label = "EVAL", - .font_size = 0, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = "O", - .left = "\x06NUM", - .is_menu = 0, - .right = "UNDO", - .sub = 0 }, - {.name = "LEFT", - .x = 150, - .y = 100, - .w = 36, - .h = 26, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = left_width, - .lh = left_height, - .lb = left_bitmap, - .letter = "P", - .left = "PICTURE", - .is_menu = 0, - .right = 0, - .sub = 0 }, - {.name = "DOWN", - .x = 200, - .y = 100, - .w = 36, - .h = 26, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = down_width, - .lh = down_height, - .lb = down_bitmap, - .letter = "Q", - .left = "VIEW", - .is_menu = 0, - .right = 0, - .sub = 0 }, - {.name = "RIGHT", - .x = 250, - .y = 100, - .w = 36, - .h = 26, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = right_width, - .lh = right_height, - .lb = right_bitmap, - .letter = "R", - .left = "SWAP", - .is_menu = 0, - .right = 0, - .sub = 0 }, - - {.name = "SIN", - .x = 0, - .y = 150, - .w = 36, - .h = 26, - .lc = WHITE, - .label = "SIN", - .font_size = 0, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = "S", - .left = "ASIN", - .is_menu = 0, - .right = "\x07", - .sub = 0 }, - {.name = "COS", - .x = 50, - .y = 150, - .w = 36, - .h = 26, - .lc = WHITE, - .label = "COS", - .font_size = 0, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = "T", - .left = "ACOS", - .is_menu = 0, - .right = "\x08", - .sub = 0 }, - {.name = "TAN", - .x = 100, - .y = 150, - .w = 36, - .h = 26, - .lc = WHITE, - .label = "TAN", - .font_size = 0, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = "U", - .left = "ATAN", - .is_menu = 0, - .right = "\x09", - .sub = 0 }, - {.name = "SQRT", - .x = 150, - .y = 150, - .w = 36, - .h = 26, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = sqrt_width, - .lh = sqrt_height, - .lb = sqrt_bitmap, - .letter = "V", - .left = "\x13", - .is_menu = 0, - .right = "\x14", - .sub = 0 }, - {.name = "POWER", - .x = 200, - .y = 150, - .w = 36, - .h = 26, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = power_width, - .lh = power_height, - .lb = power_bitmap, - .letter = "W", - .left = "\x15", - .is_menu = 0, - .right = "LOG", - .sub = 0 }, - {.name = "INV", - .x = 250, - .y = 150, - .w = 36, - .h = 26, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = inv_width, - .lh = inv_height, - .lb = inv_bitmap, - .letter = "X", - .left = "\x16", - .is_menu = 0, - .right = "LN", - .sub = 0 }, - - {.name = "ENTER", - .x = 0, - .y = 200, - .w = 86, - .h = 26, - .lc = WHITE, - .label = "ENTER", - .font_size = 2, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = 0, - .left = "EQUATION", - .is_menu = 0, - .right = "MATRIX", - .sub = 0 }, - {.name = "NEG", - .x = 100, - .y = 200, - .w = 36, - .h = 26, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = neg_width, - .lh = neg_height, - .lb = neg_bitmap, - .letter = "Y", - .left = "EDIT", - .is_menu = 0, - .right = "CMD", - .sub = 0 }, - {.name = "EEX", - .x = 150, - .y = 200, - .w = 36, - .h = 26, - .lc = WHITE, - .label = "EEX", - .font_size = 0, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = "Z", - .left = "PURG", - .is_menu = 0, - .right = "ARG", - .sub = 0 }, - {.name = "DEL", - .x = 200, - .y = 200, - .w = 36, - .h = 26, - .lc = WHITE, - .label = "DEL", - .font_size = 0, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = 0, - .left = "CLEAR", - .is_menu = 0, - .right = 0, - .sub = 0 }, - {.name = "BS", - .x = 250, - .y = 200, - .w = 36, - .h = 26, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = bs_width, - .lh = bs_height, - .lb = bs_bitmap, - .letter = 0, - .left = "DROP", - .is_menu = 0, - .right = 0, - .sub = 0 }, - - {.name = "ALPHA", - .x = 0, - .y = 250, - .w = 36, - .h = 26, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = alpha_width, - .lh = alpha_height, - .lb = alpha_bitmap, - .letter = 0, - .left = "USER", - .is_menu = 0, - .right = "ENTRY", - .sub = 0 }, - {.name = "7", - .x = 60, - .y = 250, - .w = 46, - .h = 26, - .lc = WHITE, - .label = "7", - .font_size = 1, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = 0, - .left = "SOLVE", - .is_menu = 1, - .right = 0, - .sub = 0 }, - {.name = "8", - .x = 120, - .y = 250, - .w = 46, - .h = 26, - .lc = WHITE, - .label = "8", - .font_size = 1, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = 0, - .left = "PLOT", - .is_menu = 1, - .right = 0, - .sub = 0 }, - {.name = "9", - .x = 180, - .y = 250, - .w = 46, - .h = 26, - .lc = WHITE, - .label = "9", - .font_size = 1, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = 0, - .left = "SYMBOLIC", - .is_menu = 1, - .right = 0, - .sub = 0 }, - {.name = "DIV", - .x = 240, - .y = 250, - .w = 46, - .h = 26, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = div_width, - .lh = div_height, - .lb = div_bitmap, - .letter = 0, - .left = "\x17 ", - .is_menu = 0, - .right = "\x18", - .sub = 0 }, - - {.name = "SHL", - .x = 0, - .y = 300, - .w = 36, - .h = 26, - .lc = LEFT, - .label = 0, - .font_size = 0, - .lw = shl_width, - .lh = shl_height, - .lb = shl_bitmap, - .letter = 0, - .left = 0, - .is_menu = 0, - .right = 0, - .sub = 0 }, - {.name = "4", - .x = 60, - .y = 300, - .w = 46, - .h = 26, - .lc = WHITE, - .label = "4", - .font_size = 1, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = 0, - .left = "TIME", - .is_menu = 1, - .right = 0, - .sub = 0 }, - {.name = "5", - .x = 120, - .y = 300, - .w = 46, - .h = 26, - .lc = WHITE, - .label = "5", - .font_size = 1, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = 0, - .left = "STAT", - .is_menu = 1, - .right = 0, - .sub = 0 }, - {.name = "6", - .x = 180, - .y = 300, - .w = 46, - .h = 26, - .lc = WHITE, - .label = "6", - .font_size = 1, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = 0, - .left = "UNITS", - .is_menu = 1, - .right = 0, - .sub = 0 }, - {.name = "MUL", - .x = 240, - .y = 300, - .w = 46, - .h = 26, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = mul_width, - .lh = mul_height, - .lb = mul_bitmap, - .letter = 0, - .left = "\x19 ", - .is_menu = 0, - .right = "\x1a", - .sub = 0 }, - - {.name = "SHR", - .x = 0, - .y = 350, - .w = 36, - .h = 26, - .lc = RIGHT, - .label = 0, - .font_size = 0, - .lw = shr_width, - .lh = shr_height, - .lb = shr_bitmap, - .letter = 0, - .left = " ", - .is_menu = 1, - .right = 0, - .sub = 0 }, - {.name = "1", - .x = 60, - .y = 350, - .w = 46, - .h = 26, - .lc = WHITE, - .label = "1", - .font_size = 1, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = 0, - .left = "I/O", - .is_menu = 1, - .right = 0, - .sub = 0 }, - {.name = "2", - .x = 120, - .y = 350, - .w = 46, - .h = 26, - .lc = WHITE, - .label = "2", - .font_size = 1, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = 0, - .left = "LIBRARY", - .is_menu = 1, - .right = 0, - .sub = 0 }, - {.name = "3", - .x = 180, - .y = 350, - .w = 46, - .h = 26, - .lc = WHITE, - .label = "3", - .font_size = 1, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = 0, - .left = "EQ LIB", - .is_menu = 1, - .right = 0, - .sub = 0 }, - {.name = "MINUS", - .x = 240, - .y = 350, - .w = 46, - .h = 26, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = minus_width, - .lh = minus_height, - .lb = minus_bitmap, - .letter = 0, - .left = "\x1b ", - .is_menu = 0, - .right = "\x1c", - .sub = 0 }, - - {.name = "ON", - .x = 0, - .y = 400, - .w = 36, - .h = 26, - .lc = WHITE, - .label = "ON", - .font_size = 0, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = 0, - .left = "CONT", - .is_menu = 0, - .right = "OFF", - .sub = "CANCEL"}, - {.name = "0", - .x = 60, - .y = 400, - .w = 46, - .h = 26, - .lc = WHITE, - .label = "0", - .font_size = 1, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = 0, - .left = "\x04 ", - .is_menu = 0, - .right = "\x03", - .sub = 0 }, - {.name = "PERIOD", - .x = 120, - .y = 400, - .w = 46, - .h = 26, - .lc = WHITE, - .label = ".", - .font_size = 1, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = 0, - .left = "\x02 ", - .is_menu = 0, - .right = "\x01", - .sub = 0 }, - {.name = "SPC", - .x = 180, - .y = 400, - .w = 46, - .h = 26, - .lc = WHITE, - .label = "SPC", - .font_size = 0, - .lw = 0, - .lh = 0, - .lb = 0, - .letter = 0, - .left = "\x05 ", - .is_menu = 0, - .right = "\x1f", - .sub = 0 }, - {.name = "PLUS", - .x = 240, - .y = 400, - .w = 46, - .h = 26, - .lc = WHITE, - .label = 0, - .font_size = 0, - .lw = plus_width, - .lh = plus_height, - .lb = plus_bitmap, - .letter = 0, - .left = "\x1d ", - .is_menu = 0, - .right = "\x1e", - .sub = 0 }, -}; - -ann_struct_t ann_tbl[ NB_ANNUNCIATORS ] = { - {.x = 16, .y = 4, .width = ann_left_width, .height = ann_left_height, .bits = ann_left_bitmap }, - {.x = 61, .y = 4, .width = ann_right_width, .height = ann_right_height, .bits = ann_right_bitmap }, - {.x = 106, .y = 4, .width = ann_alpha_width, .height = ann_alpha_height, .bits = ann_alpha_bitmap }, - {.x = 151, .y = 4, .width = ann_battery_width, .height = ann_battery_height, .bits = ann_battery_bitmap}, - {.x = 196, .y = 4, .width = ann_busy_width, .height = ann_busy_height, .bits = ann_busy_bitmap }, - {.x = 241, .y = 4, .width = ann_io_width, .height = ann_io_height, .bits = ann_io_bitmap }, -}; - -void ( *ui_disp_draw_nibble )( word_20 addr, word_4 val ); -void ( *ui_menu_draw_nibble )( word_20 addr, word_4 val ); -void ( *ui_get_event )( void ); -void ( *ui_update_LCD )( void ); -void ( *ui_refresh_LCD )( void ); -void ( *ui_adjust_contrast )( void ); -void ( *ui_draw_annunc )( void ); - -void ui_init_LCD( void ) { memset( lcd_nibbles_buffer, 0xf0, sizeof( lcd_nibbles_buffer ) ); } - -int SmallTextWidth( const char* string, unsigned int length ) -{ - int w = 0; - for ( unsigned int i = 0; i < length; i++ ) { - if ( small_font[ ( int )string[ i ] ].h != 0 ) - w += small_font[ ( int )string[ i ] ].w + 1; - else { - if ( config.verbose ) - fprintf( stderr, "Unknown small letter 0x00%x\n", ( int )string[ i ] ); - w += 5; - } - } - - return w; -} - -int BigTextWidth( const char* string, unsigned int length ) -{ - int w = 0; - for ( unsigned int i = 0; i < length; i++ ) { - if ( big_font[ ( int )string[ i ] ].h != 0 ) - w += big_font[ ( int )string[ i ] ].w; - else { - if ( config.verbose ) - fprintf( stderr, "Unknown small letter 0x00%x\n", ( int )string[ i ] ); - w += 7; - } - } - - return w; -} - -void start_UI( int argc, char** argv ) -{ - ui_init_LCD(); - - switch ( config.frontend_type ) { -#if defined( HAS_X11 ) - case FRONTEND_X11: - default: - init_x11_ui( argc, argv ); - break; -#endif - -#if defined( HAS_SDL2 ) - case FRONTEND_SDL2: -# if !defined( HAS_X11 ) - default: -# endif - init_sdl2_ui( argc, argv ); - break; -#endif - - case FRONTEND_TEXT: -#if ( !defined( HAS_X11 ) && !defined( HAS_SDL2 ) ) - default: -#endif - init_text_ui( argc, argv ); - break; - } -} - -void ui_stop( void ) -{ - switch ( config.frontend_type ) { -#if defined( HAS_X11 ) - case FRONTEND_X11: - default: - x11_ui_stop(); - break; -#endif - -#if defined( HAS_SDL2 ) - case FRONTEND_SDL2: -# if !defined( HAS_X11 ) - default: -# endif - sdl2_ui_stop(); - break; -#endif - - case FRONTEND_TEXT: -#if ( !defined( HAS_X11 ) && !defined( HAS_SDL2 ) ) - default: -#endif - text_ui_stop(); - break; - } -} - -void close_and_exit( void ) -{ - ui_stop(); - exit_emulator(); - - exit( 0 ); -} diff --git a/src/ui.h b/src/ui.h deleted file mode 100644 index 93234ef..0000000 --- a/src/ui.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef _UI_H -#define _UI_H 1 - -#include "emulator.h" /* word_4; word_20; */ - -#define DISP_ROWS 64 -#define NIBS_PER_BUFFER_ROW ( NIBBLES_PER_ROW + 2 ) - -/*************/ -/* variables */ -/*************/ -extern int last_annunc_state; - -extern unsigned char lcd_nibbles_buffer[ DISP_ROWS ][ NIBS_PER_BUFFER_ROW ]; - -/*************/ -/* functions */ -/*************/ -#ifdef HAS_X11 -extern void init_x11_ui( int argc, char** argv ); -extern void x11_ui_stop( void ); -#endif - -#ifdef HAS_SDL2 -extern void init_sdl2_ui( int argc, char** argv ); -extern void sdl2_ui_stop( void ); -#endif - -extern void init_text_ui( int argc, char** argv ); -extern void text_ui_stop( void ); - -/*************************************************/ -/* public API: if it's there it's used elsewhere */ -/*************************************************/ -/*************************/ -/* used in: emu_memory.c */ -/*************************/ -extern void ( *ui_disp_draw_nibble )( word_20 addr, word_4 val ); -extern void ( *ui_menu_draw_nibble )( word_20 addr, word_4 val ); - -/*****************************************/ -/* used in: emu_emulate.c */ -/*****************************************/ -extern void ( *ui_get_event )( void ); -extern void ( *ui_adjust_contrast )( void ); -extern void ( *ui_draw_annunc )( void ); - -/*****************************************************/ -/* used in: emu_emulate.c, debugger.c */ -/*****************************************************/ -extern void ( *ui_update_LCD )( void ); -extern void ( *ui_refresh_LCD )( void ); - -/*******************/ -/* used in: main.c */ -/*******************/ -extern void ui_stop( void ); -extern void start_UI( int argc, char** argv ); - -extern void close_and_exit( void ); - -#endif /* !_UI_H */ diff --git a/src/ui_bitmaps_big_font.h b/src/ui_bitmaps_big_font.h deleted file mode 100644 index 85b8c46..0000000 --- a/src/ui_bitmaps_big_font.h +++ /dev/null @@ -1,172 +0,0 @@ -#ifndef _UI_BIG_FONT_H -#define _UI_BIG_FONT_H 1 - -#define big_font_dot_width 8 -#define big_font_dot_height 13 -static unsigned char big_font_dot_bits[] = { - 0, 0, 0, 0, 0, 0, 0, 24, 24, 0, 0, 0, 0, -}; - -#define big_font_0_width 8 -#define big_font_0_height 13 -static unsigned char big_font_0_bits[] = { - 24, 60, 102, 102, 195, 195, 195, 195, 195, 102, 102, 60, 24, -}; - -#define big_font_1_width 8 -#define big_font_1_height 13 -static unsigned char big_font_1_bits[] = { - 24, 28, 30, 27, 24, 24, 24, 24, 24, 24, 24, 24, 255, -}; - -#define big_font_2_width 8 -#define big_font_2_height 13 -static unsigned char big_font_2_bits[] = { - 60, 102, 195, 195, 192, 192, 96, 56, 12, 6, 3, 3, 255, -}; - -#define big_font_3_width 8 -#define big_font_3_height 13 -static unsigned char big_font_3_bits[] = { - 60, 102, 195, 195, 192, 96, 56, 96, 192, 195, 195, 102, 60, -}; - -#define big_font_4_width 8 -#define big_font_4_height 13 -static unsigned char big_font_4_bits[] = { - 96, 112, 120, 108, 102, 99, 99, 255, 96, 96, 96, 96, 96, -}; - -#define big_font_5_width 8 -#define big_font_5_height 13 -static unsigned char big_font_5_bits[] = { - 255, 3, 3, 3, 3, 59, 103, 192, 192, 192, 195, 102, 60, -}; - -#define big_font_6_width 8 -#define big_font_6_height 13 -static unsigned char big_font_6_bits[] = { - 60, 102, 67, 3, 3, 59, 103, 195, 195, 195, 195, 102, 60, -}; - -#define big_font_7_width 8 -#define big_font_7_height 13 -static unsigned char big_font_7_bits[] = { - 255, 192, 192, 96, 96, 48, 48, 24, 24, 12, 12, 6, 6, -}; - -#define big_font_8_width 8 -#define big_font_8_height 13 -static unsigned char big_font_8_bits[] = { - 60, 102, 195, 195, 195, 102, 60, 102, 195, 195, 195, 102, 60, -}; - -#define big_font_9_width 8 -#define big_font_9_height 13 -static unsigned char big_font_9_bits[] = { - 62, 195, 195, 195, 195, 195, 230, 220, 192, 192, 194, 102, 60, -}; - -#define big_font_A_width 8 -#define big_font_A_height 10 -static unsigned char big_font_A_bits[] = { - 30, 51, 51, 51, 51, 51, 63, 51, 51, 51, -}; - -#define big_font_C_width 8 -#define big_font_C_height 10 -static unsigned char big_font_C_bits[] = { - 30, 51, 51, 3, 3, 3, 3, 51, 51, 30, -}; - -#define big_font_D_width 8 -#define big_font_D_height 10 -static unsigned char big_font_D_bits[] = { - 15, 27, 51, 51, 51, 51, 51, 51, 27, 15, -}; - -#define big_font_E_width 8 -#define big_font_E_height 10 -static unsigned char big_font_E_bits[] = { - 63, 3, 3, 3, 31, 3, 3, 3, 3, 63, -}; - -#define big_font_G_width 8 -#define big_font_G_height 10 -static unsigned char big_font_G_bits[] = { - 30, 51, 51, 3, 3, 59, 51, 51, 51, 30, -}; - -#define big_font_H_width 8 -#define big_font_H_height 10 -static unsigned char big_font_H_bits[] = { - 51, 51, 51, 51, 63, 51, 51, 51, 51, 51, -}; - -#define big_font_I_width 8 -#define big_font_I_height 10 -static unsigned char big_font_I_bits[] = { - 63, 12, 12, 12, 12, 12, 12, 12, 12, 63, -}; - -#define big_font_L_width 8 -#define big_font_L_height 10 -static unsigned char big_font_L_bits[] = { - 3, 3, 3, 3, 3, 3, 3, 3, 3, 63, -}; - -#define big_font_M_width 8 -#define big_font_M_height 10 -static unsigned char big_font_M_bits[] = { - 33, 51, 51, 63, 63, 51, 51, 51, 51, 51, -}; - -#define big_font_N_width 8 -#define big_font_N_height 10 -static unsigned char big_font_N_bits[] = { - 51, 51, 55, 55, 55, 59, 59, 59, 51, 51, -}; - -#define big_font_O_width 8 -#define big_font_O_height 10 -static unsigned char big_font_O_bits[] = { - 30, 51, 51, 51, 51, 51, 51, 51, 51, 30, -}; - -#define big_font_P_width 8 -#define big_font_P_height 10 -static unsigned char big_font_P_bits[] = { - 31, 51, 51, 51, 51, 31, 3, 3, 3, 3, -}; - -#define big_font_R_width 8 -#define big_font_R_height 10 -static unsigned char big_font_R_bits[] = { - 31, 51, 51, 51, 31, 27, 51, 51, 51, 51, -}; - -#define big_font_S_width 8 -#define big_font_S_height 10 -static unsigned char big_font_S_bits[] = { - 30, 51, 51, 6, 12, 12, 24, 51, 51, 30, -}; - -#define big_font_T_width 8 -#define big_font_T_height 10 -static unsigned char big_font_T_bits[] = { - 63, 12, 12, 12, 12, 12, 12, 12, 12, 12, -}; - -#define big_font_V_width 8 -#define big_font_V_height 10 -static unsigned char big_font_V_bits[] = { - 51, 51, 51, 51, 51, 51, 51, 30, 30, 12, -}; - -#define big_font_X_width 8 -#define big_font_X_height 10 -static unsigned char big_font_X_bits[] = { - 51, 51, 30, 30, 12, 12, 30, 30, 51, 51, -}; - -#endif /* _UI_BIG_FONT_H 1 */ diff --git a/src/ui_bitmaps_misc.h b/src/ui_bitmaps_misc.h deleted file mode 100644 index 4335d8f..0000000 --- a/src/ui_bitmaps_misc.h +++ /dev/null @@ -1,224 +0,0 @@ -#ifndef _UI_BITMAPS_H -#define _UI_BITMAPS_H 1 - -#define hp_width 96 -#define hp_height 24 -static unsigned char hp_bitmap[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xf8, 0x9f, 0xfd, 0x3f, 0x60, 0xcc, 0x6f, 0x66, 0x83, 0xdf, 0xff, 0x3f, 0xfc, 0x9f, 0xf1, 0x7f, 0x60, 0xcc, - 0x60, 0x66, 0x83, 0x01, 0x06, 0x06, 0xfc, 0xc7, 0xc0, 0x7f, 0x60, 0xcc, 0x60, 0x66, 0x83, 0x01, 0x06, 0x06, 0xfc, 0xc3, 0x80, - 0x7f, 0x60, 0xcc, 0x40, 0x26, 0x83, 0x01, 0x06, 0x06, 0xfc, 0x61, 0x00, 0x7f, 0xe0, 0xcf, 0xcf, 0x36, 0x83, 0x1f, 0x06, 0x06, - 0xfc, 0x60, 0x00, 0x7e, 0x60, 0xcc, 0xc0, 0x36, 0x83, 0x01, 0x06, 0x06, 0xfc, 0x30, 0x00, 0x7e, 0x60, 0xcc, 0x80, 0x19, 0x83, - 0x01, 0x06, 0x06, 0x7c, 0xb0, 0x68, 0x7c, 0x60, 0xcc, 0x80, 0x19, 0x83, 0x01, 0x06, 0x06, 0x7c, 0xf8, 0xf9, 0x7c, 0x60, 0xcc, - 0x8f, 0x19, 0xbf, 0x1f, 0x06, 0x06, 0x7c, 0x98, 0xcd, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xcc, 0xcc, - 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xcc, 0x66, 0x7c, 0xe0, 0x87, 0x81, 0x67, 0x0c, 0xc3, 0xcf, 0x0f, - 0x7c, 0x66, 0x66, 0x7c, 0x60, 0xcc, 0xc3, 0x6c, 0x86, 0xc7, 0xd8, 0x18, 0x7c, 0x66, 0x3f, 0x7e, 0x60, 0x4c, 0x62, 0x60, 0x83, - 0xc4, 0xd8, 0x30, 0xfc, 0x00, 0x03, 0x7e, 0x60, 0x6c, 0x66, 0xe0, 0xc1, 0xcc, 0xd8, 0x30, 0xfc, 0x80, 0x01, 0x7f, 0xe0, 0x67, - 0x66, 0xe0, 0xc1, 0xcc, 0xcf, 0x30, 0xfc, 0x81, 0x81, 0x7f, 0x60, 0xe0, 0x67, 0x60, 0xc3, 0xcf, 0xcc, 0x30, 0xfc, 0xc3, 0xc0, - 0x7f, 0x60, 0x30, 0x6c, 0x60, 0x66, 0xd8, 0xd8, 0x30, 0xfc, 0xcf, 0xf0, 0x7f, 0x60, 0x30, 0xcc, 0x6c, 0x6c, 0xd8, 0xd8, 0x18, - 0xf8, 0x6f, 0xfe, 0x3f, 0x60, 0x30, 0x8c, 0x67, 0x78, 0xd8, 0xd8, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - -#define hp48sx_width 42 -#define hp48sx_height 10 -static unsigned char hp48sx_bitmap[] = { 0xe0, 0xf1, 0xc3, 0x3f, 0x87, 0x03, 0xf0, 0xf9, 0xe7, 0x7f, 0xc7, 0x01, 0xf8, 0x39, 0xe7, - 0x70, 0xee, 0x00, 0xdc, 0x39, 0xe7, 0x00, 0x7e, 0x00, 0xee, 0xf0, 0xe3, 0x0f, 0x3c, 0x00, - 0xe7, 0xf8, 0xc1, 0x1f, 0x1c, 0x00, 0xff, 0x9d, 0x03, 0x1c, 0x3e, 0x00, 0xff, 0x9d, 0x3b, - 0x1c, 0x3f, 0x00, 0x70, 0xfc, 0xfb, 0x9f, 0x73, 0x00, 0x70, 0xf8, 0xf1, 0xcf, 0x71, 0x00 }; - -#define hp48gx_width 44 -#define hp48gx_height 14 -static unsigned char hp48gx_bitmap[] = { - 0x00, 0xc3, 0x03, 0x7c, 0x0c, 0x0c, 0x80, 0xe3, 0x07, 0xff, 0x0c, 0x0e, 0xc0, 0x33, 0x86, 0xc3, 0x1c, 0x06, 0xe0, 0x31, 0xc6, - 0xc0, 0x18, 0x03, 0xb0, 0x31, 0xe6, 0x00, 0xb0, 0x01, 0x98, 0x31, 0x63, 0x00, 0xf0, 0x01, 0x8c, 0xe1, 0x61, 0x00, 0xe0, 0x00, - 0xc6, 0xb8, 0x31, 0xfc, 0x70, 0x00, 0xc7, 0x18, 0x33, 0xfc, 0xf8, 0x00, 0xff, 0x0d, 0x33, 0x60, 0xd8, 0x00, 0xff, 0x0d, 0x73, - 0x60, 0x8c, 0x01, 0x60, 0x8c, 0x63, 0x30, 0x86, 0x03, 0x60, 0xfc, 0xe1, 0x3f, 0x07, 0x03, 0x60, 0xf8, 0x80, 0x37, 0x03, 0x03 }; - -#define science_width 131 -#define science_height 8 -static unsigned char science_bitmap[] = { - 0x38, 0x1c, 0xf2, 0x09, 0x7d, 0x79, 0xe2, 0x80, 0x2f, 0xe4, 0x41, 0x08, 0x79, 0x20, 0x3c, 0xc2, 0x07, 0x44, 0x22, 0x12, - 0x08, 0x11, 0x09, 0x12, 0x81, 0x20, 0x22, 0x62, 0x08, 0x89, 0x30, 0x44, 0x42, 0x00, 0x02, 0x01, 0x09, 0x94, 0x88, 0x04, - 0x09, 0x40, 0x40, 0x11, 0x52, 0x94, 0x88, 0x28, 0x42, 0x21, 0x00, 0x1c, 0x01, 0xf9, 0x94, 0x88, 0x3c, 0x09, 0xc0, 0xc7, - 0xf0, 0x51, 0x94, 0x84, 0x28, 0x3e, 0xe1, 0x03, 0xa0, 0x00, 0x09, 0x94, 0x88, 0x04, 0x05, 0x40, 0xc0, 0x10, 0x48, 0x94, - 0x44, 0x24, 0x22, 0x21, 0x00, 0xa1, 0xa0, 0x04, 0xa2, 0x44, 0x82, 0x04, 0x21, 0xa0, 0x08, 0xfc, 0xa2, 0x42, 0x7e, 0xa1, - 0x10, 0x00, 0x91, 0x90, 0x04, 0x42, 0x44, 0x82, 0x84, 0x20, 0x10, 0x09, 0x84, 0x42, 0x22, 0x42, 0xb1, 0x10, 0x00, 0x0e, - 0x8f, 0x7c, 0x42, 0x44, 0x82, 0x78, 0xe0, 0x0b, 0x09, 0x82, 0x42, 0x1e, 0x41, 0x9f, 0xf7, 0x01 }; - -#define gx_128K_ram_x_hot 1 -#define gx_128K_ram_y_hot 8 -#define gx_128K_ram_width 43 -#define gx_128K_ram_height 31 -static unsigned char gx_128K_ram_bitmap[] = { - 0xfe, 0xdf, 0xff, 0xff, 0x03, 0x00, 0xfe, 0xdf, 0xff, 0xff, 0x03, 0x00, 0xfe, 0xdf, 0xff, 0xff, 0x03, 0x00, 0xe2, 0xdf, 0xff, - 0xff, 0x03, 0x00, 0x9c, 0xdf, 0xff, 0xff, 0x03, 0x00, 0x7e, 0xdf, 0xff, 0xff, 0x01, 0x00, 0x7e, 0xdf, 0xff, 0xff, 0x01, 0x00, - 0xfe, 0xde, 0xff, 0xff, 0x02, 0x00, 0xfe, 0xde, 0xff, 0xff, 0x02, 0x00, 0xfe, 0xdd, 0xff, 0x7f, 0x03, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xfe, 0xdd, 0xff, 0xbf, 0x03, 0x00, 0xfe, 0xdb, 0xff, 0xdf, 0x03, 0x00, 0xfe, 0xdb, 0xff, 0xef, 0x03, 0x00, - 0xfe, 0xd7, 0xff, 0xf7, 0x03, 0x00, 0xfe, 0xcf, 0xff, 0xfb, 0x03, 0x00, 0xfe, 0xcf, 0xff, 0xfc, 0x03, 0x00, 0xfe, 0x1f, 0x3f, - 0xff, 0x03, 0x00, 0xfe, 0xdf, 0xc0, 0xff, 0x03, 0x00, 0xfe, 0xdf, 0xff, 0xff, 0x03, 0x00, 0xfe, 0xdf, 0xff, 0xff, 0x03, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xc4, 0x30, 0x12, 0x1c, 0x44, 0x04, 0x27, 0x49, 0x0a, 0x24, 0x46, 0x04, 0x84, 0x39, 0x06, 0x24, 0xc9, 0x06, - 0x62, 0x24, 0x07, 0x9e, 0xaf, 0x06, 0x12, 0x24, 0x09, 0x92, 0xa8, 0x05, 0xf2, 0x18, 0x11, 0x52, 0x28, 0x05 }; - -#define gx_silver_x_hot 0 -#define gx_silver_y_hot 8 -#define gx_silver_width 35 -#define gx_silver_height 21 -static unsigned char gx_silver_bitmap[] = { - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x38, 0x40, 0x00, 0x00, 0x00, 0xc4, - 0x40, 0x00, 0x00, 0x00, 0x02, 0x41, 0x00, 0x00, 0x04, 0x02, 0x41, 0x00, 0x00, 0x04, 0x02, 0x42, 0x00, 0x00, 0x02, 0x01, 0x42, - 0x00, 0x00, 0x02, 0x01, 0x44, 0x00, 0x00, 0x01, 0xfd, 0xff, 0xff, 0xff, 0x07, 0x01, 0x44, 0x00, 0x80, 0x00, 0x01, 0x48, 0x00, - 0x40, 0x00, 0x01, 0x48, 0x00, 0x20, 0x00, 0x00, 0x50, 0x00, 0x10, 0x00, 0x00, 0x60, 0x00, 0x08, 0x00, 0x00, 0x60, 0x00, 0x06, - 0x00, 0x00, 0xc0, 0x81, 0x01, 0x00, 0x00, 0x40, 0x7e, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00 }; - -#define gx_green_x_hot 11 -#define gx_green_y_hot 0 -#define gx_green_width 34 -#define gx_green_height 22 -static unsigned char gx_green_bitmap[] = { - 0xff, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, - 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0xfc, 0x03, 0x00, 0x00, 0x00, 0xfc, 0x03, 0x00, 0x00, 0x00, 0xfc, - 0x03, 0x00, 0x00, 0x00, 0xf0, 0x03, 0x00, 0x00, 0x00, 0xf0, 0x03, 0x00, 0x00, 0x00, 0xf0, 0x03, 0x00, 0x00, 0x00, 0xf0, 0x03, 0x00, - 0x00, 0x00, 0xf0, 0x03, 0x00, 0x00, 0x00, 0xf0, 0x03, 0x00, 0x00, 0x00, 0xf0, 0x03, 0x00, 0x00, 0x00, 0xf0, 0x03, 0x00, 0x00, 0x00, - 0xf0, 0x03, 0x00, 0x00, 0x00, 0xf0, 0x03, 0x00, 0x00, 0x00, 0xf0, 0x03, 0x00, 0x00, 0x00, 0xf0, 0x03, 0x00, 0x00, 0x00, 0xf0, 0x03 }; - -#define ann_alpha_width 15 -#define ann_alpha_height 12 -static unsigned char ann_alpha_bitmap[] = { 0xe0, 0x03, 0x18, 0x44, 0x0c, 0x4c, 0x06, 0x2c, 0x07, 0x2c, 0x07, 0x1c, - 0x07, 0x0c, 0x07, 0x0c, 0x07, 0x0e, 0x0e, 0x4d, 0xf8, 0x38, 0x00, 0x00 }; - -#define ann_battery_width 15 -#define ann_battery_height 12 -static unsigned char ann_battery_bitmap[] = { 0x04, 0x10, 0x02, 0x20, 0x12, 0x24, 0x09, 0x48, 0xc9, 0x49, 0xc9, 0x49, - 0xc9, 0x49, 0x09, 0x48, 0x12, 0x24, 0x02, 0x20, 0x04, 0x10, 0x00, 0x00 }; - -#define ann_busy_width 15 -#define ann_busy_height 12 -static unsigned char ann_busy_bitmap[] = { 0xfc, 0x1f, 0x08, 0x08, 0x08, 0x08, 0xf0, 0x07, 0xe0, 0x03, 0xc0, 0x01, - 0x40, 0x01, 0x20, 0x02, 0x10, 0x04, 0xc8, 0x09, 0xe8, 0x0b, 0xfc, 0x1f }; - -#define ann_io_width 15 -#define ann_io_height 12 -static unsigned char ann_io_bitmap[] = { 0x0c, 0x00, 0x1e, 0x00, 0x33, 0x0c, 0x61, 0x18, 0xcc, 0x30, 0xfe, 0x7f, - 0xfe, 0x7f, 0xcc, 0x30, 0x61, 0x18, 0x33, 0x0c, 0x1e, 0x00, 0x0c, 0x00 }; - -#define ann_left_width 15 -#define ann_left_height 12 -static unsigned char ann_left_bitmap[] = { 0xfe, 0x3f, 0xff, 0x7f, 0x9f, 0x7f, 0xcf, 0x7f, 0xe7, 0x7f, 0x03, 0x78, - 0x03, 0x70, 0xe7, 0x73, 0xcf, 0x73, 0x9f, 0x73, 0xff, 0x73, 0xfe, 0x33 }; - -#define ann_right_width 15 -#define ann_right_height 12 -static unsigned char ann_right_bitmap[] = { 0xfe, 0x3f, 0xff, 0x7f, 0xff, 0x7c, 0xff, 0x79, 0xff, 0x73, 0x0f, 0x60, - 0x07, 0x60, 0xe7, 0x73, 0xe7, 0x79, 0xe7, 0x7c, 0xe7, 0x7f, 0xe6, 0x3f }; - -/* #endif /\* !_ANNUNC_H *\/ */ - -/* #ifndef _BUTTONS_H */ -/* #define _BUTTONS_H 1 */ - -#define menu_label_width 24 -#define menu_label_height 11 -static unsigned char menu_label_bitmap[] = { 0xfe, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0x7f }; - -#define up_width 11 -#define up_height 11 -static unsigned char up_bitmap[] = { 0x20, 0x00, 0x20, 0x00, 0x70, 0x00, 0x70, 0x00, 0xf8, 0x00, 0xf8, - 0x00, 0xfc, 0x01, 0xfc, 0x01, 0xfe, 0x03, 0xfe, 0x03, 0xff, 0x07 }; - -#define down_width 11 -#define down_height 11 -static unsigned char down_bitmap[] = { 0xff, 0x07, 0xfe, 0x03, 0xfe, 0x03, 0xfc, 0x01, 0xfc, 0x01, 0xf8, - 0x00, 0xf8, 0x00, 0x70, 0x00, 0x70, 0x00, 0x20, 0x00, 0x20, 0x00 }; - -#define left_width 11 -#define left_height 11 -static unsigned char left_bitmap[] = { 0x00, 0x04, 0x00, 0x07, 0xc0, 0x07, 0xf0, 0x07, 0xfc, 0x07, 0xff, - 0x07, 0xfc, 0x07, 0xf0, 0x07, 0xc0, 0x07, 0x00, 0x07, 0x00, 0x04 }; - -#define right_width 11 -#define right_height 11 -static unsigned char right_bitmap[] = { 0x01, 0x00, 0x07, 0x00, 0x1f, 0x00, 0x7f, 0x00, 0xff, 0x01, 0xff, - 0x07, 0xff, 0x01, 0x7f, 0x00, 0x1f, 0x00, 0x07, 0x00, 0x01, 0x00 }; - -#define sqrt_width 20 -#define sqrt_height 11 -static unsigned char sqrt_bitmap[] = { 0x00, 0xff, 0x0f, 0x00, 0x01, 0x08, 0x00, 0x01, 0x08, 0x80, 0x8c, 0x01, 0x80, 0x58, 0x01, 0x80, 0x38, - 0x00, 0x47, 0x30, 0x00, 0x4c, 0x30, 0x00, 0x58, 0x78, 0x00, 0x30, 0x6a, 0x01, 0x20, 0xc6, 0x00 }; - -#define power_width 17 -#define power_height 14 -static unsigned char power_bitmap[] = { 0x00, 0x8c, 0x01, 0x00, 0x58, 0x01, 0x00, 0x38, 0x00, 0xc8, 0x30, 0x00, 0x9c, 0x30, - 0x00, 0x98, 0x78, 0x00, 0x58, 0x6a, 0x01, 0x58, 0xc6, 0x00, 0x38, 0x00, 0x00, 0x30, - 0x00, 0x00, 0x10, 0x00, 0x00, 0x08, 0x00, 0x00, 0x05, 0x00, 0x00, 0x03, 0x00, 0x00 }; - -#define inv_width 18 -#define inv_height 13 -static unsigned char inv_bitmap[] = { 0x0c, 0x04, 0x00, 0x0f, 0x06, 0x00, 0x0c, 0x02, 0x00, 0x0c, 0x03, 0x00, 0x0c, - 0x01, 0x00, 0x8c, 0x19, 0x03, 0x8c, 0xb0, 0x02, 0xcc, 0x70, 0x00, 0x40, 0x60, - 0x00, 0x60, 0x60, 0x00, 0x20, 0xf0, 0x00, 0x30, 0xd4, 0x02, 0x10, 0x8c, 0x01 }; - -#define neg_width 21 -#define neg_height 11 -static unsigned char neg_bitmap[] = { 0x18, 0x00, 0x00, 0x18, 0x30, 0x00, 0x18, 0x30, 0x00, 0xff, 0x18, 0x00, 0xff, 0x18, 0x00, 0x18, 0x0c, - 0x00, 0x18, 0x0c, 0x00, 0x18, 0xc6, 0x1f, 0x00, 0xc6, 0x1f, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00 }; - -#define bs_width 11 -#define bs_height 11 -static unsigned char bs_bitmap[] = { 0x20, 0x00, 0x30, 0x00, 0x38, 0x00, 0xfc, 0x07, 0xfe, 0x07, 0xff, - 0x07, 0xfe, 0x07, 0xfc, 0x07, 0x38, 0x00, 0x30, 0x00, 0x20, 0x00 }; - -#define alpha_width 12 -#define alpha_height 10 -static unsigned char alpha_bitmap[] = { 0x78, 0x00, 0x84, 0x08, 0x82, 0x09, 0x83, 0x05, 0x83, 0x05, - 0x83, 0x03, 0x83, 0x01, 0x83, 0x01, 0x46, 0x09, 0x3c, 0x06 }; - -#define div_width 10 -#define div_height 10 -static unsigned char div_bitmap[] = { 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x03, - 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x30, 0x00 }; - -#define shl_width 24 -#define shl_height 14 -static unsigned char shl_bitmap[] = { 0xfe, 0xff, 0x7f, 0xff, 0xfc, 0xff, 0x7f, 0xfc, 0xff, 0x3f, 0xfe, 0xff, 0x1f, 0xff, - 0xff, 0x0f, 0x00, 0xfc, 0x07, 0x00, 0xf8, 0x0f, 0x00, 0xf0, 0x1f, 0xff, 0xf1, 0x3f, - 0xfe, 0xf1, 0x7f, 0xfc, 0xf1, 0xff, 0xfc, 0xf1, 0xff, 0xff, 0xf1, 0xfe, 0xff, 0x71 }; - -#define mul_width 10 -#define mul_height 10 -static unsigned char mul_bitmap[] = { 0x03, 0x03, 0x87, 0x03, 0xce, 0x01, 0xfc, 0x00, 0x78, 0x00, - 0x78, 0x00, 0xfc, 0x00, 0xce, 0x01, 0x87, 0x03, 0x03, 0x03 }; - -#define shr_width 24 -#define shr_height 14 -static unsigned char shr_bitmap[] = { 0xfe, 0xff, 0x7f, 0xff, 0x3f, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0x7f, 0xfc, 0xff, 0xff, - 0xf8, 0x3f, 0x00, 0xf0, 0x1f, 0x00, 0xe0, 0x0f, 0x00, 0xf0, 0x8f, 0xff, 0xf8, 0x8f, - 0x7f, 0xfc, 0x8f, 0x3f, 0xfe, 0x8f, 0x3f, 0xff, 0x8f, 0xff, 0xff, 0x8e, 0xff, 0x7f }; - -#define minus_width 10 -#define minus_height 10 -static unsigned char minus_bitmap[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x03, - 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - -#define plus_width 10 -#define plus_height 10 -static unsigned char plus_bitmap[] = { 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0xff, 0x03, - 0xff, 0x03, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00 }; - -#define quote_width 2 -#define quote_height 10 -static unsigned char quote_bitmap[] = { 0x03, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - -/* Below used only for X11 */ -#define last_width 120 -#define last_height 6 -static unsigned char last_bitmap[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xc6, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x29, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x11, 0x49, 0x08, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x8f, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x29, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0xc9, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80 }; - -#endif /* _UI_BITMAPS_H 1 */ diff --git a/src/ui_bitmaps_small_font.h b/src/ui_bitmaps_small_font.h deleted file mode 100644 index 0a46923..0000000 --- a/src/ui_bitmaps_small_font.h +++ /dev/null @@ -1,423 +0,0 @@ -#ifndef _UI_SMALL_FONT_H -#define _UI_SMALL_FONT_H 1 - -#define blank_width 4 -#define blank_height 7 -static unsigned char blank_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - -#define hash_width 5 -#define hash_height 7 -static unsigned char hash_bits[] = { 0x00, 0x0a, 0x1f, 0x0a, 0x0a, 0x1f, 0x0a }; - -#define lbrace_width 3 -#define lbrace_height 7 -static unsigned char lbrace_bits[] = { 0x04, 0x02, 0x01, 0x01, 0x01, 0x02, 0x04 }; - -#define rbrace_width 3 -#define rbrace_height 7 -static unsigned char rbrace_bits[] = { 0x01, 0x02, 0x04, 0x04, 0x04, 0x02, 0x01 }; - -#define comma_width 3 -#define comma_height 7 -static unsigned char comma_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x03 }; - -#define slash_width 3 -#define slash_height 7 -static unsigned char slash_bits[] = { 0x04, 0x04, 0x02, 0x02, 0x02, 0x01, 0x01 }; - -#define zero_width 5 -#define zero_height 7 -static unsigned char zero_bits[] = { - 14, 17, 25, 21, 19, 17, 14, -}; - -#define one_width 5 -#define one_height 7 -static unsigned char one_bits[] = { - 4, 6, 5, 4, 4, 4, 31, -}; - -#define two_width 5 -#define two_height 7 -static unsigned char two_bits[] = { 0x0e, 0x11, 0x10, 0x08, 0x04, 0x02, 0x1f }; - -#define three_width 5 -#define three_height 7 -static unsigned char three_bits[] = { 0x0e, 0x11, 0x10, 0x0c, 0x10, 0x11, 0x0e }; - -#define four_width 5 -#define four_height 7 -static unsigned char four_bits[] = { - 8, 12, 10, 9, 31, 8, 8, -}; - -#define five_width 5 -#define five_height 7 -static unsigned char five_bits[] = { - 31, 1, 1, 15, 16, 16, 15, -}; - -#define six_width 5 -#define six_height 7 -static unsigned char six_bits[] = { - 14, 17, 1, 15, 17, 17, 14, -}; - -#define seven_width 5 -#define seven_height 7 -static unsigned char seven_bits[] = { - 31, 16, 8, 4, 2, 1, 1, -}; - -#define eight_width 5 -#define eight_height 7 -static unsigned char eight_bits[] = { - 14, 17, 17, 14, 17, 17, 14, -}; - -#define nine_width 5 -#define nine_height 7 -static unsigned char nine_bits[] = { - 14, 17, 17, 30, 16, 17, 14, -}; - -#define small_colon_width 2 -#define small_colon_height 7 -static unsigned char small_colon_bits[] = { 0x00, 0x03, 0x03, 0x00, 0x03, 0x03, 0x00 }; - -#define d_width 5 -#define d_height 7 -static unsigned char d_bits[] = { - 16, 16, 30, 17, 17, 30, 0, -}; - -#define e_width 5 -#define e_height 7 -static unsigned char e_bits[] = { - 0, 14, 17, 15, 1, 14, 0, -}; - -#define i_width 5 -#define i_height 7 -static unsigned char i_bits[] = { - 4, 0, 6, 4, 4, 14, 0, -}; - -#define p_width 5 -#define p_height 7 -static unsigned char p_bits[] = { - 0, 15, 17, 17, 15, 1, 1, -}; - -#define r_width 5 -#define r_height 7 -static unsigned char r_bits[] = { - 0, 29, 3, 1, 1, 1, 0, -}; - -#define s_width 5 -#define s_height 7 -static unsigned char s_bits[] = { - 0, 30, 1, 14, 16, 15, 0, -}; - -#define t_width 5 -#define t_height 7 -static unsigned char t_bits[] = { - 2, 15, 2, 2, 2, 12, 0, -}; - -#define v_width 5 -#define v_height 7 -static unsigned char v_bits[] = { - 0, 17, 17, 10, 10, 4, 0, -}; - -#define w_width 5 -#define w_height 7 -static unsigned char w_bits[] = { - 0, 17, 17, 21, 21, 10, 0, -}; - -#define y_width 5 -#define y_height 7 -static unsigned char y_bits[] = { - 0, 0, 17, 17, 30, 16, 15, -}; - -#define A_width 5 -#define A_height 7 -static unsigned char A_bits[] = { 0x0e, 0x11, 0x11, 0x1f, 0x11, 0x11, 0x11 }; - -#define B_width 5 -#define B_height 7 -static unsigned char B_bits[] = { 0x0f, 0x11, 0x11, 0x0f, 0x11, 0x11, 0x0f }; - -#define C_width 5 -#define C_height 7 -static unsigned char C_bits[] = { 0x0e, 0x11, 0x01, 0x01, 0x01, 0x11, 0x0e }; - -#define D_width 5 -#define D_height 7 -static unsigned char D_bits[] = { 0x0f, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0f }; - -#define E_width 5 -#define E_height 7 -static unsigned char E_bits[] = { 0x1f, 0x01, 0x01, 0x0f, 0x01, 0x01, 0x1f }; - -#define F_width 5 -#define F_height 7 -static unsigned char F_bits[] = { 0x1f, 0x01, 0x01, 0x0f, 0x01, 0x01, 0x01 }; - -#define G_width 5 -#define G_height 7 -static unsigned char G_bits[] = { 0x0e, 0x11, 0x01, 0x01, 0x19, 0x11, 0x0e }; - -#define H_width 5 -#define H_height 7 -static unsigned char H_bits[] = { 0x11, 0x11, 0x11, 0x1f, 0x11, 0x11, 0x11 }; - -#define I_width 1 -#define I_height 7 -static unsigned char I_bits[] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }; - -#define J_width 4 -#define J_height 7 -static unsigned char J_bits[] = { 0x08, 0x08, 0x08, 0x08, 0x08, 0x09, 0x06 }; - -#define K_width 5 -#define K_height 7 -static unsigned char K_bits[] = { 0x11, 0x09, 0x05, 0x03, 0x05, 0x09, 0x11 }; - -#define L_width 4 -#define L_height 7 -static unsigned char L_bits[] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0f }; - -#define M_width 5 -#define M_height 7 -static unsigned char M_bits[] = { 0x11, 0x1b, 0x15, 0x11, 0x11, 0x11, 0x11 }; - -#define N_width 5 -#define N_height 7 -static unsigned char N_bits[] = { 0x11, 0x11, 0x13, 0x15, 0x19, 0x11, 0x11 }; - -#define O_width 5 -#define O_height 7 -static unsigned char O_bits[] = { 0x0e, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0e }; - -#define P_width 5 -#define P_height 7 -static unsigned char P_bits[] = { 0x0f, 0x11, 0x11, 0x0f, 0x01, 0x01, 0x01 }; - -#define Q_width 5 -#define Q_height 7 -static unsigned char Q_bits[] = { 0x0e, 0x11, 0x11, 0x11, 0x15, 0x09, 0x16 }; - -#define R_width 5 -#define R_height 7 -static unsigned char R_bits[] = { 0x0f, 0x11, 0x11, 0x0f, 0x05, 0x09, 0x11 }; - -#define S_width 5 -#define S_height 7 -static unsigned char S_bits[] = { 0x0e, 0x11, 0x01, 0x0e, 0x10, 0x11, 0x0e }; - -#define T_width 5 -#define T_height 7 -static unsigned char T_bits[] = { 0x1f, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 }; - -#define U_width 5 -#define U_height 7 -static unsigned char U_bits[] = { 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0e }; - -#define V_width 5 -#define V_height 7 -static unsigned char V_bits[] = { 0x11, 0x11, 0x11, 0x11, 0x0a, 0x0a, 0x04 }; - -#define W_width 5 -#define W_height 7 -static unsigned char W_bits[] = { 0x11, 0x11, 0x11, 0x11, 0x15, 0x1b, 0x11 }; - -#define X_width 5 -#define X_height 7 -static unsigned char X_bits[] = { 0x11, 0x11, 0x0a, 0x04, 0x0a, 0x11, 0x11 }; - -#define Y_width 5 -#define Y_height 7 -static unsigned char Y_bits[] = { 0x11, 0x11, 0x0a, 0x04, 0x04, 0x04, 0x04 }; - -#define Z_width 5 -#define Z_height 7 -static unsigned char Z_bits[] = { 0x1f, 0x10, 0x08, 0x04, 0x02, 0x01, 0x1f }; - -#define lbracket_width 3 -#define lbracket_height 7 -static unsigned char lbracket_bits[] = { 0x07, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07 }; - -#define rbracket_width 3 -#define rbracket_height 7 -static unsigned char rbracket_bits[] = { 0x07, 0x04, 0x04, 0x04, 0x04, 0x04, 0x07 }; - -#define arrow_width 7 -#define arrow_height 7 -static unsigned char arrow_bits[] = { 0x00, 0x08, 0x18, 0x3f, 0x18, 0x08, 0x00 }; - -#define diff_width 5 -#define diff_height 7 -static unsigned char diff_bits[] = { 0x0e, 0x10, 0x10, 0x1e, 0x11, 0x11, 0x0e }; - -#define integral_width 5 -#define integral_height 8 -static unsigned char integral_bits[] = { 0x0c, 0x12, 0x02, 0x04, 0x04, 0x08, 0x09, 0x06 }; - -#define sigma_width 6 -#define sigma_height 9 -static unsigned char sigma_bits[] = { 0x3f, 0x21, 0x02, 0x04, 0x08, 0x04, 0x02, 0x21, 0x3f }; - -#define sqr_width 11 -#define sqr_height 10 -static unsigned char sqr_bits[] = { 0x00, 0x03, 0x80, 0x04, 0x00, 0x04, 0x00, 0x02, 0x26, 0x01, - 0x94, 0x07, 0x08, 0x00, 0x14, 0x00, 0x53, 0x00, 0x21, 0x00 }; - -#define root_width 18 -#define root_height 13 -static unsigned char root_bits[] = { 0x26, 0x00, 0x00, 0x14, 0x00, 0x00, 0x08, 0xfe, 0x03, 0x14, 0x02, 0x02, 0x53, - 0x02, 0x00, 0x21, 0x99, 0x00, 0x00, 0x91, 0x00, 0x10, 0x91, 0x00, 0xa0, 0x50, - 0x00, 0xc0, 0x60, 0x00, 0x80, 0x20, 0x00, 0x00, 0x14, 0x00, 0x00, 0x0c, 0x00 }; - -#define pow10_width 13 -#define pow10_height 9 -static unsigned char pow10_bits[] = { 0x00, 0x12, 0x00, 0x0c, 0x32, 0x04, 0x4b, 0x0a, 0x4a, - 0x09, 0x4a, 0x00, 0x4a, 0x00, 0x4a, 0x00, 0x32, 0x00 }; - -#define exp_width 11 -#define exp_height 9 -static unsigned char exp_bits[] = { 0x80, 0x04, 0x00, 0x03, 0x00, 0x01, 0x8c, 0x02, 0x52, - 0x02, 0x09, 0x00, 0x07, 0x00, 0x21, 0x00, 0x1e, 0x00 }; - -#define under_width 6 -#define under_height 7 -static unsigned char under_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f }; - -#define prog_width 16 -#define prog_height 7 -static unsigned char prog_bits[] = { 0x48, 0x12, 0x24, 0x24, 0x12, 0x48, 0x09, 0x90, 0x12, 0x48, 0x24, 0x24, 0x48, 0x12 }; - -#define string_width 10 -#define string_height 7 -static unsigned char string_bits[] = { 0x85, 0x02, 0x85, 0x02, 0x85, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - -#define equal_width 5 -#define equal_height 7 -static unsigned char equal_bits[] = { 0x00, 0x1f, 0x00, 0x00, 0x1f, 0x00, 0x00 }; - -#define nl_width 8 -#define nl_height 7 -static unsigned char nl_bits[] = { 0x00, 0x84, 0x86, 0xff, 0x06, 0x04, 0x00 }; - -#define pi_width 6 -#define pi_height 7 -static unsigned char pi_bits[] = { 0x20, 0x1f, 0x12, 0x12, 0x12, 0x12, 0x12 }; - -#define angle_width 8 -#define angle_height 7 -static unsigned char angle_bits[] = { 0x40, 0x20, 0x10, 0x28, 0x44, 0x42, 0xff }; - -#define lcurly_width 5 -#define lcurly_height 7 -static unsigned char lcurly_bits[] = { 0x18, 0x04, 0x04, 0x02, 0x04, 0x04, 0x18 }; - -#define rcurly_width 5 -#define rcurly_height 7 -static unsigned char rcurly_bits[] = { 0x03, 0x04, 0x04, 0x08, 0x04, 0x04, 0x03 }; - -#define sqr_gx_width 11 -#define sqr_gx_height 13 -static unsigned char sqr_gx_bits[] = { 0x00, 0x03, 0x80, 0x04, 0x00, 0x04, 0x00, 0x02, 0x00, 0x01, 0x80, 0x07, 0x00, - 0x00, 0x66, 0x00, 0x14, 0x00, 0x08, 0x00, 0x14, 0x00, 0x53, 0x00, 0x21, 0x00 }; - -#define root_gx_width 18 -#define root_gx_height 15 -static unsigned char root_gx_bits[] = { 0x66, 0x00, 0x00, 0x14, 0x00, 0x00, 0x08, 0x00, 0x00, 0x14, 0x00, 0x00, 0x53, 0xfe, 0x03, - 0x21, 0x02, 0x02, 0x00, 0x02, 0x00, 0x00, 0x99, 0x00, 0x00, 0x91, 0x00, 0x10, 0x91, 0x00, - 0xa0, 0x50, 0x00, 0xc0, 0x60, 0x00, 0x80, 0x20, 0x00, 0x00, 0x14, 0x00, 0x00, 0x0c, 0x00 }; - -#define pow10_gx_width 13 -#define pow10_gx_height 12 -static unsigned char pow10_gx_bits[] = { 0x00, 0x12, 0x00, 0x0c, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x09, 0x32, 0x00, - 0x4b, 0x00, 0x4a, 0x00, 0x4a, 0x00, 0x4a, 0x00, 0x4a, 0x00, 0x32, 0x00 }; - -#define exp_gx_width 13 -#define exp_gx_height 12 -static unsigned char exp_gx_bits[] = { 0x00, 0xfb, 0x00, 0xf6, 0x00, 0xe6, 0x00, 0xf6, 0x80, 0xed, 0x18, 0xe0, - 0x36, 0xe0, 0x36, 0xe0, 0x1f, 0xe0, 0x03, 0xe0, 0x13, 0xe0, 0x0e, 0xe0 }; -#define parens_gx_width 20 -#define parens_gx_height 12 -static unsigned char parens_gx_bits[] = { 0x0c, 0x00, 0x03, 0x06, 0x00, 0x06, 0x06, 0x00, 0x06, 0x03, 0x00, 0x0c, - 0x03, 0x00, 0x0c, 0x03, 0x00, 0x0c, 0x03, 0x00, 0x0c, 0x03, 0x00, 0x0c, - 0x03, 0x00, 0x0c, 0x06, 0x00, 0x06, 0x06, 0x00, 0x06, 0x0c, 0x00, 0x03 }; - -#define hash_gx_width 8 -#define hash_gx_height 12 -static unsigned char hash_gx_bits[] = { 0x00, 0x00, 0x48, 0x48, 0xfe, 0x24, 0x24, 0x7f, 0x12, 0x12, 0x00, 0x00 }; - -#define bracket_gx_width 12 -#define bracket_gx_height 12 -static unsigned char bracket_gx_bits[] = { 0x0f, 0x0f, 0x03, 0x0c, 0x03, 0x0c, 0x03, 0x0c, 0x03, 0x0c, 0x03, 0x0c, - 0x03, 0x0c, 0x03, 0x0c, 0x03, 0x0c, 0x03, 0x0c, 0x03, 0x0c, 0x0f, 0x0f }; - -#define under_gx_width 10 -#define under_gx_height 12 -static unsigned char under_gx_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x03, 0xff, 0x03 }; - -#define prog_gx_width 24 -#define prog_gx_height 12 -static unsigned char prog_gx_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0xc3, 0x18, - 0x8c, 0x81, 0x31, 0xc6, 0x00, 0x63, 0x63, 0x00, 0xc6, 0xc6, 0x00, 0x63, - 0x8c, 0x81, 0x31, 0x18, 0xc3, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - -#define quote_gx_width 12 -#define quote_gx_height 12 -static unsigned char quote_gx_bits[] = { 0x05, 0x0a, 0x05, 0x0a, 0x05, 0x0a, 0x05, 0x0a, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - -#define curly_gx_width 14 -#define curly_gx_height 12 -static unsigned char curly_gx_bits[] = { 0x0c, 0x0c, 0x06, 0x18, 0x06, 0x18, 0x06, 0x18, 0x06, 0x18, 0x03, 0x30, - 0x06, 0x18, 0x06, 0x18, 0x06, 0x18, 0x06, 0x18, 0x06, 0x18, 0x0c, 0x0c }; - -#define colon_gx_width 8 -#define colon_gx_height 12 -static unsigned char colon_gx_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0xc3, 0x00, 0x00, 0xc3, 0xc3, 0x00 }; - -#define angle_gx_width 12 -#define angle_gx_height 12 -static unsigned char angle_gx_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x01, 0xc0, 0x00, 0xe0, 0x01, - 0xb0, 0x03, 0x18, 0x03, 0x0c, 0x03, 0x06, 0x03, 0xff, 0x0f, 0xff, 0x0f }; - -#define pi_gx_width 10 -#define pi_gx_height 12 -static unsigned char pi_gx_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xfe, 0x03, 0xff, 0x01, - 0xcc, 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc, 0x00 }; - -#define nl_gx_width 18 -#define nl_gx_height 12 -static unsigned char nl_gx_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x03, 0xf0, 0x00, 0x03, - 0xfc, 0x00, 0x03, 0xff, 0xff, 0x03, 0xff, 0xff, 0x03, 0xfc, 0x00, 0x00, - 0xf0, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - -#define comma_gx_width 3 -#define comma_gx_height 12 -static unsigned char comma_gx_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x07, 0x04, 0x04, 0x02 }; - -#define arrow_gx_width 18 -#define arrow_gx_height 12 -static unsigned char arrow_gx_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x3c, 0x00, - 0x00, 0xfc, 0x00, 0xff, 0xff, 0x03, 0xff, 0xff, 0x03, 0x00, 0xfc, 0x00, - 0x00, 0x3c, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - -#define equal_gx_width 8 -#define equal_gx_height 12 -static unsigned char equal_gx_bits[] = { 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00 }; - -#endif /* _UI_SMALL_FONT_H 1 */ diff --git a/src/ui_inner.h b/src/ui_inner.h deleted file mode 100644 index 3016ed2..0000000 --- a/src/ui_inner.h +++ /dev/null @@ -1,105 +0,0 @@ -#ifndef _UI_INNER_H -#define _UI_INNER_H 1 - -#include "emulator.h" -#include "ui_bitmaps_misc.h" -#include "ui_bitmaps_small_font.h" -#include "ui_bitmaps_big_font.h" - -// Colors -/* SX GX */ -#define WHITE 0 /* #ffffff #ffffff */ -#define LEFT 1 /* #ffa600 #ffbaff */ -#define RIGHT 2 /* #00d2ff #00ffcc */ -#define BUT_TOP 3 /* #6d5d5d #646464 */ -#define BUTTON 4 /* #5a4d4d #585858 */ -#define BUT_BOT 5 /* #4c4141 #4a4a4a */ -#define LCD 6 /* #cadd5c #cadd5c */ -#define PIXEL 7 /* #000080 #000080 */ -#define PAD_TOP 8 /* #6d4e4e #585858 */ -#define PAD 9 /* #5a4040 #4a4a4a */ -#define PAD_BOT 10 /* #4c3636 #404040 */ -#define DISP_PAD_TOP 11 /* #9b7654 #808080 */ -#define DISP_PAD 12 /* #7c5e43 #68686e */ -#define DISP_PAD_BOT 13 /* #644b35 #54545a */ -#define LOGO 14 /* #cca96b #b0b0b8 */ -#define LOGO_BACK 15 /* #404040 #68686e */ -#define LABEL 16 /* #cab890 #f0f0f0 */ -#define FRAME 17 /* #000000 #000000 */ -#define UNDERLAY 18 /* #3c2a2a #68686e */ -#define BLACK 19 /* #000000 #000000 */ - -#define FIRST_COLOR WHITE -#define LAST_COLOR BLACK -#define NB_COLORS ( LAST_COLOR + 1 ) - -/***********/ -/* typedef */ -/***********/ -typedef struct letter_t { - unsigned int w, h; - unsigned char* bits; -} letter_t; - -typedef struct color_t { - const char* name; - int r, g, b; - int mono_rgb; - int gray_rgb; -} color_t; - -typedef struct button_t { - const char* name; - - int x, y; - int w, h; - - int lc; - const char* label; - short font_size; - unsigned int lw, lh; - unsigned char* lb; - - const char* letter; - - const char* left; - short is_menu; - const char* right; - const char* sub; -} button_t; - -typedef struct ann_struct_t { - int x; - int y; - unsigned int width; - unsigned int height; - unsigned char* bits; -} ann_struct_t; - -/*************/ -/* variables */ -/*************/ -extern letter_t small_font[ 128 ]; -extern letter_t big_font[ 128 ]; - -extern color_t colors_sx[ NB_COLORS ]; -extern color_t colors_gx[ NB_COLORS ]; -#define COLORS ( opt_gx ? colors_gx : colors_sx ) - -extern button_t buttons_sx[ NB_KEYS ]; -extern button_t buttons_gx[ NB_KEYS ]; -#define BUTTONS ( opt_gx ? buttons_gx : buttons_sx ) - -extern ann_struct_t ann_tbl[ NB_ANNUNCIATORS ]; - -#define small_ascent 8 -#define small_descent 4 - -/*************/ -/* functions */ -/*************/ -extern int SmallTextWidth( const char* string, unsigned int length ); -extern int BigTextWidth( const char* string, unsigned int length ); -extern void ui_init_LCD( void ); - -#endif /* _UI_INNER_H */ diff --git a/src/ui_sdl2.c b/src/ui_sdl2.c deleted file mode 100644 index 89b4fb0..0000000 --- a/src/ui_sdl2.c +++ /dev/null @@ -1,1155 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "romio.h" /* opt_gx */ -#include "config.h" -#include "ui.h" -#include "ui_inner.h" - -#define KEYBOARD_HEIGHT ( BUTTONS[ LAST_HPKEY ].y + BUTTONS[ LAST_HPKEY ].h ) -#define KEYBOARD_WIDTH ( BUTTONS[ LAST_HPKEY ].x + BUTTONS[ LAST_HPKEY ].w ) - -#define TOP_SKIP 65 -#define SIDE_SKIP 20 -#define BOTTOM_SKIP 25 -#define DISP_KBD_SKIP 65 -#define KBD_UPLINE 25 - -#define DISPLAY_WIDTH ( 264 + 8 ) -#define DISPLAY_HEIGHT ( 128 + 16 + 8 ) -#define DISPLAY_OFFSET_X ( SIDE_SKIP + ( 286 - DISPLAY_WIDTH ) / 2 ) -#define DISPLAY_OFFSET_Y TOP_SKIP - -#define DISP_FRAME 8 - -#define KEYBOARD_OFFSET_X SIDE_SKIP -#define KEYBOARD_OFFSET_Y ( TOP_SKIP + DISPLAY_HEIGHT + DISP_KBD_SKIP ) - -/***********/ -/* typedef */ -/***********/ -typedef struct on_off_sdl_textures_struct_t { - SDL_Texture* up; - SDL_Texture* down; -} on_off_sdl_textures_struct_t; - -/*************/ -/* variables */ -/*************/ -static int display_offset_x, display_offset_y; - -color_t colors[ NB_COLORS ]; -static on_off_sdl_textures_struct_t buttons_textures[ NB_KEYS ]; -static on_off_sdl_textures_struct_t annunciators_textures[ NB_ANNUNCIATORS ]; - -static SDL_Window* window; -static SDL_Renderer* renderer; -static SDL_Texture* main_texture; - -/****************************/ -/* functions implementation */ -/****************************/ -static inline unsigned color2bgra( int color ) -{ - return 0xff000000 | ( colors[ color ].r << 16 ) | ( colors[ color ].g << 8 ) | colors[ color ].b; -} - -/* - Create a SDL_Texture from binary bitmap data -*/ -static SDL_Texture* bitmap_to_texture( unsigned int w, unsigned int h, unsigned char* data, int color_fg, int color_bg ) -{ - SDL_Surface* surf = SDL_CreateRGBSurface( SDL_SWSURFACE, w, h, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 ); - - SDL_LockSurface( surf ); - - unsigned char* pixels = ( unsigned char* )surf->pixels; - unsigned int pitch = surf->pitch; - unsigned byteperline = w / 8; - if ( byteperline * 8 != w ) - byteperline++; - - for ( unsigned int y = 0; y < h; y++ ) { - unsigned int* lineptr = ( unsigned int* )( pixels + y * pitch ); - for ( unsigned int x = 0; x < w; x++ ) { - // Address the correct byte - char c = data[ y * byteperline + ( x >> 3 ) ]; - // Look for the bit in that byte - char b = c & ( 1 << ( x & 7 ) ); - - lineptr[ x ] = color2bgra( b ? color_fg : color_bg ); - } - } - - SDL_UnlockSurface( surf ); - - SDL_Texture* tex = SDL_CreateTextureFromSurface( renderer, surf ); - SDL_FreeSurface( surf ); - - return tex; -} - -static void __draw_pixel( int x, int y, int color ) -{ - SDL_SetRenderDrawColor( renderer, colors[ color ].r, colors[ color ].g, colors[ color ].b, 0xff ); - SDL_RenderDrawPoint( renderer, x, y ); -} - -static void __draw_line( int x1, int y1, int x2, int y2, int color ) -{ - SDL_SetRenderDrawColor( renderer, colors[ color ].r, colors[ color ].g, colors[ color ].b, 0xff ); - SDL_RenderDrawLine( renderer, x1, y1, x2, y2 ); -} - -static void __draw_rect( int x, int y, int w, int h, int color ) -{ - SDL_Rect rect; - rect.x = x; - rect.y = y; - rect.w = w; - rect.h = h; - - SDL_SetRenderDrawColor( renderer, colors[ color ].r, colors[ color ].g, colors[ color ].b, 0xff ); - SDL_RenderFillRect( renderer, &rect ); -} - -static void __draw_texture( int x, int y, unsigned int w, unsigned int h, SDL_Texture* texture ) -{ - SDL_Rect drect; - drect.x = x; - drect.y = y; - drect.w = w; - drect.h = h; - - SDL_RenderCopy( renderer, texture, NULL, &drect ); -} - -static void __draw_bitmap( int x, int y, unsigned int w, unsigned int h, unsigned char* data, int color_fg, int color_bg ) -{ - __draw_texture( x, y, w, h, bitmap_to_texture( w, h, data, color_fg, color_bg ) ); -} - -static void write_with_small_font( int x, int y, const char* string, int color_fg, int color_bg ) -{ - int c; - for ( unsigned int i = 0; i < strlen( string ); i++ ) { - c = ( int )string[ i ]; - if ( small_font[ c ].h != 0 ) - __draw_bitmap( x - 1, ( int )( y - small_font[ c ].h ), small_font[ c ].w, small_font[ c ].h, small_font[ c ].bits, color_fg, - color_bg ); - - x += SmallTextWidth( &string[ i ], 1 ); - } -} - -static void write_with_big_font( int x, int y, const char* string, int color_fg, int color_bg ) -{ - int c; - for ( unsigned int i = 0; i < strlen( string ); i++ ) { - c = ( int )string[ i ]; - if ( big_font[ c ].h != 0 ) - __draw_bitmap( x, y + ( big_font[ c ].h > 10 ? 0 : 2 ), big_font[ c ].w, big_font[ c ].h, big_font[ c ].bits, color_fg, - color_bg ); - - x += BigTextWidth( &string[ i ], 1 ) - 1; - } -} - -static void colors_setup( void ) -{ - // Adjust the LCD color according to the contrast - int contrast = display.contrast; - if ( contrast < 0x3 ) - contrast = 0x3; - if ( contrast > 0x13 ) - contrast = 0x13; - - for ( unsigned i = FIRST_COLOR; i < LAST_COLOR; i++ ) { - colors[ i ] = COLORS[ i ]; - if ( config.mono ) { - colors[ i ].r = colors[ i ].mono_rgb; - colors[ i ].g = colors[ i ].mono_rgb; - colors[ i ].b = colors[ i ].mono_rgb; - } else if ( config.gray ) { - colors[ i ].r = colors[ i ].gray_rgb; - colors[ i ].g = colors[ i ].gray_rgb; - colors[ i ].b = colors[ i ].gray_rgb; - } - - if ( !config.mono && i == PIXEL ) { - colors[ i ].r = ( 0x13 - contrast ) * ( colors[ LCD ].r / 0x10 ); - colors[ i ].g = ( 0x13 - contrast ) * ( colors[ LCD ].g / 0x10 ); - colors[ i ].b = 128 - ( ( 0x13 - contrast ) * ( ( 128 - colors[ LCD ].b ) / 0x10 ) ); - } - } -} - -// This should be called once to setup the surfaces. Calling it multiple -// times is fine, it won't do anything on subsequent calls. -static void create_annunciators_textures( void ) -{ - for ( int i = 0; i < NB_ANNUNCIATORS; i++ ) { - annunciators_textures[ i ].up = bitmap_to_texture( ann_tbl[ i ].width, ann_tbl[ i ].height, ann_tbl[ i ].bits, PIXEL, LCD ); - annunciators_textures[ i ].down = bitmap_to_texture( ann_tbl[ i ].width, ann_tbl[ i ].height, ann_tbl[ i ].bits, LCD, LCD ); - } -} - -// Find which key is pressed, if any. -// Returns -1 is no key is pressed -static int mouse_click_to_hpkey( unsigned int x, unsigned int y ) -{ - /* return immediatly if the click isn't even in the keyboard area */ - if ( y < KEYBOARD_OFFSET_Y ) - return -1; - - int row = ( y - KEYBOARD_OFFSET_Y ) / ( KEYBOARD_HEIGHT / 9 ); - int column; - switch ( row ) { - case 0: - case 1: - case 2: - case 3: - column = ( x - KEYBOARD_OFFSET_X ) / ( KEYBOARD_WIDTH / 6 ); - return ( row * 6 ) + column; - case 4: /* with [ENTER] key */ - column = ( ( x - KEYBOARD_OFFSET_X ) / ( KEYBOARD_WIDTH / 5 ) ) - 1; - if ( column < 0 ) - column = 0; - return ( 4 * 6 ) + column; - case 5: - case 6: - case 7: - case 8: - column = ( x - KEYBOARD_OFFSET_X ) / ( KEYBOARD_WIDTH / 5 ); - return ( 4 * 6 ) + 5 + ( ( row - 5 ) * 5 ) + column; - - default: - return -1; - } - - return -1; -} - -// Map the keyboard keys to the HP keys -// Returns -1 if there is no mapping -static int sdlkey_to_hpkey( SDL_Keycode k ) -{ - switch ( k ) { - case SDLK_0: - return HPKEY_0; - case SDLK_1: - return HPKEY_1; - case SDLK_2: - return HPKEY_2; - case SDLK_3: - return HPKEY_3; - case SDLK_4: - return HPKEY_4; - case SDLK_5: - return HPKEY_5; - case SDLK_6: - return HPKEY_6; - case SDLK_7: - return HPKEY_7; - case SDLK_8: - return HPKEY_8; - case SDLK_9: - return HPKEY_9; - case SDLK_KP_0: - return HPKEY_0; - case SDLK_KP_1: - return HPKEY_1; - case SDLK_KP_2: - return HPKEY_2; - case SDLK_KP_3: - return HPKEY_3; - case SDLK_KP_4: - return HPKEY_4; - case SDLK_KP_5: - return HPKEY_5; - case SDLK_KP_6: - return HPKEY_6; - case SDLK_KP_7: - return HPKEY_7; - case SDLK_KP_8: - return HPKEY_8; - case SDLK_KP_9: - return HPKEY_9; - case SDLK_a: - return HPKEY_A; - case SDLK_b: - return HPKEY_B; - case SDLK_c: - return HPKEY_C; - case SDLK_d: - return HPKEY_D; - case SDLK_e: - return HPKEY_E; - case SDLK_f: - return HPKEY_F; - case SDLK_g: - return HPKEY_MTH; - case SDLK_h: - return HPKEY_PRG; - case SDLK_i: - return HPKEY_CST; - case SDLK_j: - return HPKEY_VAR; - case SDLK_k: - return HPKEY_UP; - case SDLK_UP: - return HPKEY_UP; - case SDLK_l: - return HPKEY_NXT; - case SDLK_m: - return HPKEY_QUOTE; - case SDLK_n: - return HPKEY_STO; - case SDLK_o: - return HPKEY_EVAL; - case SDLK_p: - return HPKEY_LEFT; - case SDLK_LEFT: - return HPKEY_LEFT; - case SDLK_q: - return HPKEY_DOWN; - case SDLK_DOWN: - return HPKEY_DOWN; - case SDLK_r: - return HPKEY_RIGHT; - case SDLK_RIGHT: - return HPKEY_RIGHT; - case SDLK_s: - return HPKEY_SIN; - case SDLK_t: - return HPKEY_COS; - case SDLK_u: - return HPKEY_TAN; - case SDLK_v: - return HPKEY_SQRT; - case SDLK_w: - return HPKEY_POWER; - case SDLK_x: - return HPKEY_INV; - case SDLK_y: - return HPKEY_NEG; - case SDLK_z: - return HPKEY_EEX; - case SDLK_SPACE: - return HPKEY_SPC; - case SDLK_F1: - case SDLK_RETURN: - case SDLK_KP_ENTER: - return HPKEY_ENTER; - case SDLK_BACKSPACE: - return HPKEY_BS; - case SDLK_DELETE: - return HPKEY_DEL; - case SDLK_PERIOD: - return HPKEY_PERIOD; - case SDLK_KP_PERIOD: - return HPKEY_PERIOD; - case SDLK_PLUS: - return HPKEY_PLUS; - case SDLK_KP_PLUS: - return HPKEY_PLUS; - case SDLK_MINUS: - return HPKEY_MINUS; - case SDLK_KP_MINUS: - return HPKEY_MINUS; - case SDLK_ASTERISK: - return HPKEY_MUL; - case SDLK_KP_MULTIPLY: - return HPKEY_MUL; - case SDLK_SLASH: - return HPKEY_DIV; - case SDLK_KP_DIVIDE: - return HPKEY_DIV; - case SDLK_F5: - case SDLK_ESCAPE: - return HPKEY_ON; - case SDLK_LSHIFT: - if ( !config.leave_shift_keys ) - return HPKEY_SHL; - break; - case SDLK_RSHIFT: - if ( !config.leave_shift_keys ) - return HPKEY_SHR; - break; - case SDLK_F2: - case SDLK_RCTRL: - return HPKEY_SHL; - case SDLK_F3: - case SDLK_LCTRL: - return HPKEY_SHR; - case SDLK_F4: - case SDLK_LALT: - case SDLK_RALT: - return HPKEY_ALPHA; - case SDLK_F7: - case SDLK_F10: - // please_exit = true; - close_and_exit(); - return -1; - default: - return -1; - } - - return -1; -} - -static void _draw_bezel( unsigned int cut, unsigned int offset_y, int keypad_width, int keypad_height ) -{ - // bottom lines - __draw_line( 1, keypad_height - 1, keypad_width - 1, keypad_height - 1, PAD_TOP ); - __draw_line( 2, keypad_height - 2, keypad_width - 2, keypad_height - 2, PAD_TOP ); - - // right lines - __draw_line( keypad_width - 1, keypad_height - 1, keypad_width - 1, cut, PAD_TOP ); - __draw_line( keypad_width - 2, keypad_height - 2, keypad_width - 2, cut, PAD_TOP ); - - // right lines - __draw_line( keypad_width - 1, cut - 1, keypad_width - 1, 1, DISP_PAD_TOP ); - __draw_line( keypad_width - 2, cut - 1, keypad_width - 2, 2, DISP_PAD_TOP ); - - // top lines - __draw_line( 0, 0, keypad_width - 2, 0, DISP_PAD_BOT ); - __draw_line( 1, 1, keypad_width - 3, 1, DISP_PAD_BOT ); - - // left lines - __draw_line( 0, cut - 1, 0, 0, DISP_PAD_BOT ); - __draw_line( 1, cut - 1, 1, 1, DISP_PAD_BOT ); - - // left lines - __draw_line( 0, keypad_height - 2, 0, cut, PAD_BOT ); - __draw_line( 1, keypad_height - 3, 1, cut, PAD_BOT ); - - // lower the menu BUTTONS - - // bottom lines - __draw_line( 3, keypad_height - 3, keypad_width - 3, keypad_height - 3, PAD_TOP ); - __draw_line( 4, keypad_height - 4, keypad_width - 4, keypad_height - 4, PAD_TOP ); - - // right lines - __draw_line( keypad_width - 3, keypad_height - 3, keypad_width - 3, cut, PAD_TOP ); - __draw_line( keypad_width - 4, keypad_height - 4, keypad_width - 4, cut, PAD_TOP ); - - // right lines - __draw_line( keypad_width - 3, cut - 1, keypad_width - 3, offset_y - ( KBD_UPLINE - 1 ), DISP_PAD_TOP ); - __draw_line( keypad_width - 4, cut - 1, keypad_width - 4, offset_y - ( KBD_UPLINE - 2 ), DISP_PAD_TOP ); - - // top lines - __draw_line( 2, offset_y - ( KBD_UPLINE - 0 ), keypad_width - 4, offset_y - ( KBD_UPLINE - 0 ), DISP_PAD_BOT ); - __draw_line( 3, offset_y - ( KBD_UPLINE - 1 ), keypad_width - 5, offset_y - ( KBD_UPLINE - 1 ), DISP_PAD_BOT ); - - // left lines - __draw_line( 2, cut - 1, 2, offset_y - ( KBD_UPLINE - 1 ), DISP_PAD_BOT ); - __draw_line( 3, cut - 1, 3, offset_y - ( KBD_UPLINE - 2 ), DISP_PAD_BOT ); - - // left lines - __draw_line( 2, keypad_height - 4, 2, cut, PAD_BOT ); - __draw_line( 3, keypad_height - 5, 3, cut, PAD_BOT ); - - // lower the keyboard - - // bottom lines - __draw_line( 5, keypad_height - 5, keypad_width - 3, keypad_height - 5, PAD_TOP ); - __draw_line( 6, keypad_height - 6, keypad_width - 4, keypad_height - 6, PAD_TOP ); - - // right lines - __draw_line( keypad_width - 5, keypad_height - 5, keypad_width - 5, cut + 1, PAD_TOP ); - __draw_line( keypad_width - 6, keypad_height - 6, keypad_width - 6, cut + 2, PAD_TOP ); - - // top lines - __draw_line( 4, cut, keypad_width - 6, cut, DISP_PAD_BOT ); - __draw_line( 5, cut + 1, keypad_width - 7, cut + 1, DISP_PAD_BOT ); - - // left lines - __draw_line( 4, keypad_height - 6, 4, cut + 1, PAD_BOT ); - __draw_line( 5, keypad_height - 7, 5, cut + 2, PAD_BOT ); - - // round off the bottom edge - __draw_line( keypad_width - 7, keypad_height - 7, keypad_width - 7, keypad_height - 14, PAD_TOP ); - __draw_line( keypad_width - 8, keypad_height - 8, keypad_width - 8, keypad_height - 11, PAD_TOP ); - __draw_line( keypad_width - 7, keypad_height - 7, keypad_width - 14, keypad_height - 7, PAD_TOP ); - __draw_line( keypad_width - 7, keypad_height - 8, keypad_width - 11, keypad_height - 8, PAD_TOP ); - __draw_pixel( keypad_width - 9, keypad_height - 9, PAD_TOP ); - - __draw_line( 7, keypad_height - 7, 13, keypad_height - 7, PAD_TOP ); - __draw_line( 8, keypad_height - 8, 10, keypad_height - 8, PAD_TOP ); - - __draw_line( 6, keypad_height - 8, 6, keypad_height - 14, PAD_BOT ); - __draw_line( 7, keypad_height - 9, 7, keypad_height - 11, PAD_BOT ); -} - -static void _draw_header( void ) -{ - int x = display_offset_x; - int y; - - // insert the HP Logo - if ( opt_gx ) - x -= 6; - - __draw_bitmap( x, 10, hp_width, hp_height, hp_bitmap, LOGO, LOGO_BACK ); - - if ( !opt_gx ) { - __draw_line( display_offset_x, 9, display_offset_x + hp_width - 1, 9, FRAME ); - __draw_line( display_offset_x - 1, 10, display_offset_x - 1, 10 + hp_height - 1, FRAME ); - __draw_line( display_offset_x, 10 + hp_height, display_offset_x + hp_width - 1, 10 + hp_height, FRAME ); - __draw_line( display_offset_x + hp_width, 10, display_offset_x + hp_width, 10 + hp_height - 1, FRAME ); - } - - // write the name of it - if ( opt_gx ) { - x = display_offset_x + DISPLAY_WIDTH - gx_128K_ram_width + gx_128K_ram_x_hot + 2; - y = 10 + gx_128K_ram_y_hot; - __draw_bitmap( x, y, gx_128K_ram_width, gx_128K_ram_height, gx_128K_ram_bitmap, LABEL, DISP_PAD ); - - x = display_offset_x + hp_width; - y = hp_height + 8 - hp48gx_height; - __draw_bitmap( x, y, hp48gx_width, hp48gx_height, hp48gx_bitmap, LOGO, DISP_PAD ); - - x = display_offset_x + DISPLAY_WIDTH - gx_128K_ram_width + gx_green_x_hot + 2; - y = 10 + gx_green_y_hot; - __draw_bitmap( x, y, gx_green_width, gx_green_height, gx_green_bitmap, RIGHT, DISP_PAD ); - - x = display_offset_x + DISPLAY_WIDTH - gx_128K_ram_width + gx_silver_x_hot + 2; - y = 10 + gx_silver_y_hot; - __draw_bitmap( x, y, gx_silver_width, gx_silver_height, gx_silver_bitmap, LOGO, - 0 ); // Background transparent: draw only silver line - } else { - x = display_offset_x; - y = TOP_SKIP - DISP_FRAME - hp48sx_height - 3; - __draw_bitmap( x, y, hp48sx_width, hp48sx_height, hp48sx_bitmap, LOGO, DISP_PAD ); - - x = display_offset_x + DISPLAY_WIDTH - 1 - science_width; - y = TOP_SKIP - DISP_FRAME - science_height - 4; - __draw_bitmap( x, y, science_width, science_height, science_bitmap, LOGO, DISP_PAD ); - } -} - -static SDL_Texture* create_button_texture( int hpkey, bool is_up ) -{ - bool is_down = !is_up; - int x, y; - int on_key_offset_y = ( hpkey == HPKEY_ON ) ? 1 : 0; - SDL_Texture* texture = - SDL_CreateTexture( renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, BUTTONS[ hpkey ].w, BUTTONS[ hpkey ].h ); - SDL_SetRenderTarget( renderer, texture ); - - // Fill the button and outline - // fix outer-corners color - int outer_color = PAD; - if ( BUTTONS[ hpkey ].is_menu ) - outer_color = UNDERLAY; - if ( hpkey < HPKEY_MTH ) - outer_color = DISP_PAD; - __draw_rect( 0, 0, BUTTONS[ hpkey ].w, BUTTONS[ hpkey ].h, outer_color ); - __draw_rect( 1, 1, BUTTONS[ hpkey ].w - 2, BUTTONS[ hpkey ].h - 2, BUTTON ); - - // draw label in button - if ( BUTTONS[ hpkey ].label != ( char* )0 ) { - /* Button has a text label */ - x = strlen( BUTTONS[ hpkey ].label ) - 1; - x += ( ( BUTTONS[ hpkey ].w - BigTextWidth( BUTTONS[ hpkey ].label, strlen( BUTTONS[ hpkey ].label ) ) ) / 2 ); - y = ( BUTTONS[ hpkey ].h + 1 ) / 2 - 6; - if ( is_down ) - y -= 1; - - write_with_big_font( x, y, BUTTONS[ hpkey ].label, WHITE, BUTTON ); - } else if ( BUTTONS[ hpkey ].lw != 0 ) { - /* Button has a texture */ - x = ( 1 + BUTTONS[ hpkey ].w - BUTTONS[ hpkey ].lw ) / 2; - y = ( 1 + BUTTONS[ hpkey ].h - BUTTONS[ hpkey ].lh ) / 2; - if ( is_up ) - y += 1; - - __draw_bitmap( x, y, BUTTONS[ hpkey ].lw, BUTTONS[ hpkey ].lh, BUTTONS[ hpkey ].lb, BUTTONS[ hpkey ].lc, BUTTON ); - } - - // draw edge of button - // top - __draw_line( 1, 1, BUTTONS[ hpkey ].w - 2, 1, BUT_TOP ); - __draw_line( 2, 2, BUTTONS[ hpkey ].w - 3, 2, BUT_TOP ); - if ( is_up ) { - __draw_line( 3, 3, BUTTONS[ hpkey ].w - 4, 3, BUT_TOP ); - __draw_line( 4, 4, BUTTONS[ hpkey ].w - 5, 4, BUT_TOP ); - } - // top-left - __draw_pixel( 4, 3 + ( is_up ? 2 : 0 ), BUT_TOP ); - // left - __draw_line( 1, 1, 1, BUTTONS[ hpkey ].h - 2, BUT_TOP ); - __draw_line( 2, 2, 2, BUTTONS[ hpkey ].h - 3, BUT_TOP ); - __draw_line( 3, 3, 3, BUTTONS[ hpkey ].h - 4, BUT_TOP ); - // right - __draw_line( BUTTONS[ hpkey ].w - 2, BUTTONS[ hpkey ].h - 2, BUTTONS[ hpkey ].w - 2, 3, BUT_BOT ); - __draw_line( BUTTONS[ hpkey ].w - 3, BUTTONS[ hpkey ].h - 3, BUTTONS[ hpkey ].w - 3, 4, BUT_BOT ); - __draw_line( BUTTONS[ hpkey ].w - 4, BUTTONS[ hpkey ].h - 4, BUTTONS[ hpkey ].w - 4, 5, BUT_BOT ); - __draw_pixel( BUTTONS[ hpkey ].w - 5, BUTTONS[ hpkey ].h - 4, BUT_BOT ); - // bottom - __draw_line( 3, BUTTONS[ hpkey ].h - 2, BUTTONS[ hpkey ].w - 2, BUTTONS[ hpkey ].h - 2, BUT_BOT ); - __draw_line( 4, BUTTONS[ hpkey ].h - 3, BUTTONS[ hpkey ].w - 3, BUTTONS[ hpkey ].h - 3, BUT_BOT ); - - // draw black frame around button - // top - __draw_line( 2, 0, BUTTONS[ hpkey ].w - 3, 0, FRAME ); - // left - __draw_line( 0, 2, 0, BUTTONS[ hpkey ].h - 3, FRAME ); - // right - __draw_line( BUTTONS[ hpkey ].w - 1, BUTTONS[ hpkey ].h - 3, BUTTONS[ hpkey ].w - 1, 2, FRAME ); - // bottom - __draw_line( 2, BUTTONS[ hpkey ].h - 1, BUTTONS[ hpkey ].w - 3, BUTTONS[ hpkey ].h - 1, FRAME ); - // top-left - __draw_pixel( 1, 1, FRAME ); - // top-right - __draw_pixel( BUTTONS[ hpkey ].w - 2, 1, FRAME ); - // bottom-left - __draw_pixel( 1, BUTTONS[ hpkey ].h - 2, FRAME ); - // bottom-right - __draw_pixel( BUTTONS[ hpkey ].w - 2, BUTTONS[ hpkey ].h - 2, FRAME ); - if ( hpkey == HPKEY_ON ) { - // top - __draw_line( 2, 1, BUTTONS[ hpkey ].w - 3, 1, FRAME ); - // top-left - __draw_pixel( 1, 1 + on_key_offset_y, FRAME ); - // top-right - __draw_pixel( BUTTONS[ hpkey ].w - 2, 1 + on_key_offset_y, FRAME ); - } - - if ( is_down ) { - // top - __draw_line( 2, 1 + on_key_offset_y, BUTTONS[ hpkey ].w - 3, 1 + on_key_offset_y, FRAME ); - // left - __draw_line( 1, 2, 1, BUTTONS[ hpkey ].h, FRAME ); - // right - __draw_line( BUTTONS[ hpkey ].w - 2, 2, BUTTONS[ hpkey ].w - 2, BUTTONS[ hpkey ].h, FRAME ); - // top-left - __draw_pixel( 2, 2 + on_key_offset_y, FRAME ); - // top-right - __draw_pixel( BUTTONS[ hpkey ].w - 3, 2 + on_key_offset_y, FRAME ); - } - - return texture; -} - -static void create_buttons_textures( void ) -{ - for ( int i = FIRST_HPKEY; i <= LAST_HPKEY; i++ ) { - buttons_textures[ i ].up = create_button_texture( i, true ); - buttons_textures[ i ].down = create_button_texture( i, false ); - } - - // Give back to renderer as it was - SDL_SetRenderTarget( renderer, main_texture ); -} - -static void _draw_key( int hpkey ) -{ - __draw_texture( KEYBOARD_OFFSET_X + BUTTONS[ hpkey ].x, KEYBOARD_OFFSET_Y + BUTTONS[ hpkey ].y, BUTTONS[ hpkey ].w, BUTTONS[ hpkey ].h, - keyboard[ hpkey ].pressed ? buttons_textures[ hpkey ].down : buttons_textures[ hpkey ].up ); -} - -static void _draw_keypad( void ) -{ - int x, y; - int pw = opt_gx ? 58 : 44; - int ph = opt_gx ? 48 : 9; - int left_label_width, right_label_width; - int space_char_width = SmallTextWidth( " ", 1 ); - int total_top_labels_width; - - for ( int i = FIRST_HPKEY; i <= LAST_HPKEY; i++ ) { - // Background - if ( BUTTONS[ i ].is_menu ) { - x = KEYBOARD_OFFSET_X + BUTTONS[ i ].x; - y = KEYBOARD_OFFSET_Y + BUTTONS[ i ].y - small_ascent - small_descent; - - if ( opt_gx ) { - x -= 6; - y -= 6; - } else - x += ( BUTTONS[ i ].w - pw ) / 2; - - __draw_rect( x, y, pw, ph, UNDERLAY ); - } - - // Letter (small character bottom right of key) - if ( BUTTONS[ i ].letter != ( char* )0 ) { - x = KEYBOARD_OFFSET_X + BUTTONS[ i ].x + BUTTONS[ i ].w; - y = KEYBOARD_OFFSET_Y + BUTTONS[ i ].y + BUTTONS[ i ].h; - - if ( opt_gx ) { - x += 3; - y += 1; - } else { - x -= SmallTextWidth( BUTTONS[ i ].letter, 1 ) / 2 + 5; - y -= 2; - } - - write_with_small_font( x, y, BUTTONS[ i ].letter, WHITE, ( i < HPKEY_MTH ) ? DISP_PAD : PAD ); - } - - // Bottom label: the only one is the cancel button - if ( BUTTONS[ i ].sub != ( char* )0 ) { - x = KEYBOARD_OFFSET_X + BUTTONS[ i ].x + - ( 1 + BUTTONS[ i ].w - SmallTextWidth( BUTTONS[ i ].sub, strlen( BUTTONS[ i ].sub ) ) ) / 2; - y = KEYBOARD_OFFSET_Y + BUTTONS[ i ].y + BUTTONS[ i ].h + small_ascent + 2; - write_with_small_font( x, y, BUTTONS[ i ].sub, WHITE, PAD ); - } - - total_top_labels_width = 0; - // Draw the left labels - if ( BUTTONS[ i ].left != ( char* )0 ) { - x = KEYBOARD_OFFSET_X + BUTTONS[ i ].x; - y = KEYBOARD_OFFSET_Y + BUTTONS[ i ].y - small_descent; - - left_label_width = SmallTextWidth( BUTTONS[ i ].left, strlen( BUTTONS[ i ].left ) ); - total_top_labels_width = left_label_width; - - if ( BUTTONS[ i ].right != ( char* )0 ) { - // label to the left - right_label_width = SmallTextWidth( BUTTONS[ i ].right, strlen( BUTTONS[ i ].right ) ); - total_top_labels_width += space_char_width + right_label_width; - } - - x += ( 1 + BUTTONS[ i ].w - total_top_labels_width ) / 2; - - write_with_small_font( x, y, BUTTONS[ i ].left, LEFT, BUTTONS[ i ].is_menu ? UNDERLAY : PAD ); - } - - // draw the right labels ( .is_menu never have one ) - if ( BUTTONS[ i ].right != ( char* )0 ) { - x = KEYBOARD_OFFSET_X + BUTTONS[ i ].x; - y = KEYBOARD_OFFSET_Y + BUTTONS[ i ].y - small_descent; - - if ( BUTTONS[ i ].left == ( char* )0 ) { - right_label_width = SmallTextWidth( BUTTONS[ i ].right, strlen( BUTTONS[ i ].right ) ); - total_top_labels_width = right_label_width; - } else - x += space_char_width + left_label_width; - - x += ( 1 + BUTTONS[ i ].w - total_top_labels_width ) / 2; - - write_with_small_font( x, y, BUTTONS[ i ].right, RIGHT, PAD ); - } - } - - for ( int i = FIRST_HPKEY; i <= LAST_HPKEY; i++ ) - _draw_key( i ); -} - -static void _draw_bezel_LCD( void ) -{ - for ( int i = 0; i < DISP_FRAME; i++ ) { - __draw_line( display_offset_x - i, display_offset_y + DISPLAY_HEIGHT + 2 * i, display_offset_x + DISPLAY_WIDTH + i, - display_offset_y + DISPLAY_HEIGHT + 2 * i, DISP_PAD_TOP ); - __draw_line( display_offset_x - i, display_offset_y + DISPLAY_HEIGHT + 2 * i + 1, display_offset_x + DISPLAY_WIDTH + i, - display_offset_y + DISPLAY_HEIGHT + 2 * i + 1, DISP_PAD_TOP ); - __draw_line( display_offset_x + DISPLAY_WIDTH + i, display_offset_y - i, display_offset_x + DISPLAY_WIDTH + i, - display_offset_y + DISPLAY_HEIGHT + 2 * i, DISP_PAD_TOP ); - - __draw_line( display_offset_x - i - 1, display_offset_y - i - 1, display_offset_x + DISPLAY_WIDTH + i - 1, display_offset_y - i - 1, - DISP_PAD_BOT ); - __draw_line( display_offset_x - i - 1, display_offset_y - i - 1, display_offset_x - i - 1, - display_offset_y + DISPLAY_HEIGHT + 2 * i - 1, DISP_PAD_BOT ); - } - - // round off corners - __draw_line( display_offset_x - DISP_FRAME, display_offset_y - DISP_FRAME, display_offset_x - DISP_FRAME + 3, - display_offset_y - DISP_FRAME, DISP_PAD ); - __draw_line( display_offset_x - DISP_FRAME, display_offset_y - DISP_FRAME, display_offset_x - DISP_FRAME, - display_offset_y - DISP_FRAME + 3, DISP_PAD ); - __draw_pixel( display_offset_x - DISP_FRAME + 1, display_offset_y - DISP_FRAME + 1, DISP_PAD ); - - __draw_line( display_offset_x + DISPLAY_WIDTH + DISP_FRAME - 4, display_offset_y - DISP_FRAME, - display_offset_x + DISPLAY_WIDTH + DISP_FRAME - 1, display_offset_y - DISP_FRAME, DISP_PAD ); - __draw_line( display_offset_x + DISPLAY_WIDTH + DISP_FRAME - 1, display_offset_y - DISP_FRAME, - display_offset_x + DISPLAY_WIDTH + DISP_FRAME - 1, display_offset_y - DISP_FRAME + 3, DISP_PAD ); - __draw_pixel( display_offset_x + DISPLAY_WIDTH + DISP_FRAME - 2, display_offset_y - DISP_FRAME + 1, DISP_PAD ); - - __draw_line( display_offset_x - DISP_FRAME, display_offset_y + DISPLAY_HEIGHT + 2 * DISP_FRAME - 4, display_offset_x - DISP_FRAME, - display_offset_y + DISPLAY_HEIGHT + 2 * DISP_FRAME - 1, DISP_PAD ); - __draw_line( display_offset_x - DISP_FRAME, display_offset_y + DISPLAY_HEIGHT + 2 * DISP_FRAME - 1, display_offset_x - DISP_FRAME + 3, - display_offset_y + DISPLAY_HEIGHT + 2 * DISP_FRAME - 1, DISP_PAD ); - __draw_pixel( display_offset_x - DISP_FRAME + 1, display_offset_y + DISPLAY_HEIGHT + 2 * DISP_FRAME - 2, DISP_PAD ); - - __draw_line( display_offset_x + DISPLAY_WIDTH + DISP_FRAME - 1, display_offset_y + DISPLAY_HEIGHT + 2 * DISP_FRAME - 4, - display_offset_x + DISPLAY_WIDTH + DISP_FRAME - 1, display_offset_y + DISPLAY_HEIGHT + 2 * DISP_FRAME - 1, DISP_PAD ); - __draw_line( display_offset_x + DISPLAY_WIDTH + DISP_FRAME - 4, display_offset_y + DISPLAY_HEIGHT + 2 * DISP_FRAME - 1, - display_offset_x + DISPLAY_WIDTH + DISP_FRAME - 1, display_offset_y + DISPLAY_HEIGHT + 2 * DISP_FRAME - 1, DISP_PAD ); - __draw_pixel( display_offset_x + DISPLAY_WIDTH + DISP_FRAME - 2, display_offset_y + DISPLAY_HEIGHT + 2 * DISP_FRAME - 2, DISP_PAD ); - - // simulate rounded lcd corners - __draw_line( display_offset_x - 1, display_offset_y + 1, display_offset_x - 1, display_offset_y + DISPLAY_HEIGHT - 2, LCD ); - __draw_line( display_offset_x + 1, display_offset_y - 1, display_offset_x + DISPLAY_WIDTH - 2, display_offset_y - 1, LCD ); - __draw_line( display_offset_x + 1, display_offset_y + DISPLAY_HEIGHT, display_offset_x + DISPLAY_WIDTH - 2, - display_offset_y + DISPLAY_HEIGHT, LCD ); - __draw_line( display_offset_x + DISPLAY_WIDTH, display_offset_y + 1, display_offset_x + DISPLAY_WIDTH, - display_offset_y + DISPLAY_HEIGHT - 2, LCD ); -} - -static void _draw_background( int width, int height, int w_top, int h_top ) -{ - __draw_rect( 0, 0, w_top, h_top, PAD ); - __draw_rect( 0, 0, width, height, DISP_PAD ); -} - -static void _draw_background_LCD( void ) { __draw_rect( display_offset_x, display_offset_y, DISPLAY_WIDTH, DISPLAY_HEIGHT, LCD ); } - -// Show the hp key which is being pressed -static void _show_key( int hpkey ) -{ - if ( config.hide_chrome || hpkey < 0 ) - return; - - SDL_SetRenderTarget( renderer, main_texture ); - - _draw_key( hpkey ); - - SDL_SetRenderTarget( renderer, NULL ); - SDL_RenderCopy( renderer, main_texture, NULL, NULL ); - SDL_RenderPresent( renderer ); - - return; -} - -static void _draw_serial_devices_path( void ) -{ - char text[ 1024 ] = ""; - - if ( config.verbose ) { - fprintf( stderr, "wire_name: %s\n", wire_name ); - fprintf( stderr, "ir_name: %s\n", ir_name ); - } - - if ( wire_name ) { - strcat( text, "wire: " ); - strcat( text, wire_name ); - } - if ( ir_name ) { - if ( strlen( text ) > 0 ) - strcat( text, " | " ); - - strcat( text, "IR: " ); - strcat( text, ir_name ); - } - - if ( strlen( text ) > 0 ) - write_with_small_font( SIDE_SKIP, KEYBOARD_OFFSET_Y - ( DISP_KBD_SKIP / 2 ), text, WHITE, DISP_PAD ); -} - -static void sdl_draw_nibble( int nx, int ny, int val ) -{ - SDL_SetRenderTarget( renderer, main_texture ); - - for ( int x = 0; x < 4; x++ ) { - if ( nx + x >= 131 ) // Clip at 131 pixels - break; - - char pixel = val & ( 1 << ( x & 3 ) ); - - __draw_rect( display_offset_x + 5 + ( 2 * ( nx + x ) ), display_offset_y + 20 + ( 2 * ny ), 2, 2, pixel ? PIXEL : LCD ); - } - - SDL_SetRenderTarget( renderer, NULL ); - SDL_RenderCopy( renderer, main_texture, NULL, NULL ); - SDL_RenderPresent( renderer ); -} - -static inline void draw_nibble( int col, int row, int val ) -{ - val &= 0x0f; - if ( val == lcd_nibbles_buffer[ row ][ col ] ) - return; - - lcd_nibbles_buffer[ row ][ col ] = val; - - int x = col * 4; - if ( row <= display.lines ) - x -= ( 2 * display.offset ); - - sdl_draw_nibble( x, row, val ); -} - -/* Identical in all ui_*.c */ -static inline void draw_row( long addr, int row ) -{ - int line_length = NIBBLES_PER_ROW; - - if ( ( display.offset > 3 ) && ( row <= display.lines ) ) - line_length += 2; - - for ( int i = 0; i < line_length; i++ ) - draw_nibble( i, row, read_nibble( addr + i ) ); -} - -static int sdl_press_key( int hpkey ) -{ - if ( hpkey == -1 || keyboard[ hpkey ].pressed ) - return -1; - - press_key( hpkey ); - _show_key( hpkey ); - - return hpkey; -} - -static int sdl_release_key( int hpkey ) -{ - if ( hpkey == -1 || !keyboard[ hpkey ].pressed ) - return -1; - - release_key( hpkey ); - _show_key( hpkey ); - - return hpkey; -} - -/**********/ -/* public */ -/**********/ -void sdl_get_event( void ) -{ - SDL_Event event; - int hpkey = -1; - static int lasthpkey = -1; // last key that was pressed or -1 for none - static int lastticks = -1; // time at which a key was pressed or -1 if timer expired - - // Iterate as long as there are events - while ( SDL_PollEvent( &event ) ) { - switch ( event.type ) { - case SDL_QUIT: - // please_exit = true; - close_and_exit(); - break; - - case SDL_MOUSEBUTTONDOWN: - hpkey = mouse_click_to_hpkey( event.button.x, event.button.y ); - if ( sdl_press_key( hpkey ) != -1 ) { - if ( lasthpkey == -1 ) { - lasthpkey = hpkey; - // Start timer - lastticks = SDL_GetTicks(); - } else - lasthpkey = lastticks = -1; - } - - break; - case SDL_MOUSEBUTTONUP: - hpkey = mouse_click_to_hpkey( event.button.x, event.button.y ); - if ( lasthpkey != hpkey || lastticks == -1 || ( SDL_GetTicks() - lastticks < 750 ) ) - sdl_release_key( hpkey ); - - lasthpkey = lastticks = -1; - break; - - case SDL_KEYDOWN: - sdl_press_key( sdlkey_to_hpkey( event.key.keysym.sym ) ); - break; - case SDL_KEYUP: - sdl_release_key( sdlkey_to_hpkey( event.key.keysym.sym ) ); - break; - } - } -} - -void sdl_update_LCD( void ) -{ - if ( display.on ) { - int i; - long addr = display.disp_start; - static int old_offset = -1; - static int old_lines = -1; - - if ( display.offset != old_offset ) { - memset( lcd_nibbles_buffer, 0xf0, ( size_t )( ( display.lines + 1 ) * NIBS_PER_BUFFER_ROW ) ); - old_offset = display.offset; - } - if ( display.lines != old_lines ) { - memset( &lcd_nibbles_buffer[ 56 ][ 0 ], 0xf0, ( size_t )( 8 * NIBS_PER_BUFFER_ROW ) ); - old_lines = display.lines; - } - for ( i = 0; i <= display.lines; i++ ) { - draw_row( addr, i ); - addr += display.nibs_per_line; - } - if ( i < DISP_ROWS ) { - addr = display.menu_start; - for ( ; i < DISP_ROWS; i++ ) { - draw_row( addr, i ); - addr += NIBBLES_PER_ROW; - } - } - } else - ui_init_LCD(); -} - -void sdl_refresh_LCD( void ) {} - -void sdl_disp_draw_nibble( word_20 addr, word_4 val ) -{ - long offset = ( addr - display.disp_start ); - int x = offset % display.nibs_per_line; - - if ( x < 0 || x > 35 ) - return; - - if ( display.nibs_per_line != 0 ) { - int y = offset / display.nibs_per_line; - if ( y < 0 || y > 63 ) - return; - - draw_nibble( x, y, val ); - } else - for ( int y = 0; y < display.lines; y++ ) - draw_nibble( x, y, val ); -} - -void sdl_menu_draw_nibble( word_20 addr, word_4 val ) -{ - long offset = ( addr - display.menu_start ); - int x = offset % NIBBLES_PER_ROW; - int y = display.lines + ( offset / NIBBLES_PER_ROW ) + 1; - - draw_nibble( x, y, val ); -} - -void sdl_draw_annunc( void ) -{ - if ( saturn.annunc == last_annunc_state ) - return; - - bool annunc_state; - last_annunc_state = saturn.annunc; - - SDL_SetRenderTarget( renderer, main_texture ); - - for ( int i = 0; i < NB_ANNUNCIATORS; i++ ) { - annunc_state = ( ( annunciators_bits[ i ] & saturn.annunc ) == annunciators_bits[ i ] ); - - __draw_texture( display_offset_x + ann_tbl[ i ].x, display_offset_y + ann_tbl[ i ].y, ann_tbl[ i ].width, ann_tbl[ i ].height, - ( annunc_state ) ? annunciators_textures[ i ].up : annunciators_textures[ i ].down ); - } - - // Always immediately update annunciators - SDL_SetRenderTarget( renderer, NULL ); - SDL_RenderCopy( renderer, main_texture, NULL, NULL ); - SDL_RenderPresent( renderer ); -} - -void sdl_adjust_contrast( void ) -{ - colors_setup(); - - // redraw LCD - ui_init_LCD(); - sdl_update_LCD(); - - // redraw annunc - last_annunc_state = -1; - - create_annunciators_textures(); - sdl_draw_annunc(); -} - -void sdl2_ui_stop( void ) -{ - SDL_DestroyTexture( main_texture ); - SDL_DestroyRenderer( renderer ); - SDL_DestroyWindow( window ); -} - -void init_sdl2_ui( int argc, char** argv ) -{ - if ( config.verbose ) - fprintf( stderr, "UI is sdl2\n" ); - - /* Set public API to this UI's functions */ - ui_disp_draw_nibble = sdl_disp_draw_nibble; - ui_menu_draw_nibble = sdl_menu_draw_nibble; - ui_get_event = sdl_get_event; - ui_update_LCD = sdl_update_LCD; - ui_refresh_LCD = sdl_refresh_LCD; - ui_adjust_contrast = sdl_adjust_contrast; - ui_draw_annunc = sdl_draw_annunc; - - // Initialize SDL - if ( SDL_Init( SDL_INIT_VIDEO ) < 0 ) { - printf( "Couldn't initialize SDL: %s\n", SDL_GetError() ); - exit( 1 ); - } - - // On exit: clean SDL - atexit( SDL_Quit ); - - unsigned int width, height; - display_offset_x = DISPLAY_OFFSET_X; - display_offset_y = DISPLAY_OFFSET_Y; - width = ( BUTTONS[ LAST_HPKEY ].x + BUTTONS[ LAST_HPKEY ].w ) + 2 * SIDE_SKIP; - height = display_offset_y + DISPLAY_HEIGHT + DISP_KBD_SKIP + BUTTONS[ LAST_HPKEY ].y + BUTTONS[ LAST_HPKEY ].h + BOTTOM_SKIP; - - if ( config.hide_chrome ) { - display_offset_x = 0; - display_offset_y = 0; - width = DISPLAY_WIDTH; - height = DISPLAY_HEIGHT; - } - - uint32_t window_flags = SDL_WINDOW_ALLOW_HIGHDPI; - if ( config.show_ui_fullscreen ) - window_flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; - else - window_flags |= SDL_WINDOW_RESIZABLE; - - window = SDL_CreateWindow( config.progname, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width * config.scale, - height * config.scale, window_flags ); - if ( window == NULL ) { - printf( "Couldn't create window: %s\n", SDL_GetError() ); - exit( 1 ); - } - - renderer = SDL_CreateRenderer( window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE ); - if ( renderer == NULL ) - exit( 2 ); - - SDL_RenderSetLogicalSize( renderer, width, height ); - - main_texture = SDL_CreateTexture( renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, width, height ); - - SDL_SetRenderTarget( renderer, main_texture ); - - colors_setup(); - - create_annunciators_textures(); - - if ( !config.hide_chrome ) { - int cut = BUTTONS[ HPKEY_MTH ].y + KEYBOARD_OFFSET_Y - 19; - - create_buttons_textures(); - - _draw_background( width, cut, width, height ); - _draw_bezel( cut, KEYBOARD_OFFSET_Y, width, height ); - _draw_header(); - _draw_bezel_LCD(); - _draw_keypad(); - - _draw_serial_devices_path(); - } - - _draw_background_LCD(); - - SDL_SetRenderTarget( renderer, NULL ); - SDL_RenderCopy( renderer, main_texture, NULL, NULL ); - SDL_RenderPresent( renderer ); -} diff --git a/src/ui_text.c b/src/ui_text.c deleted file mode 100644 index 6c1d6a1..0000000 --- a/src/ui_text.c +++ /dev/null @@ -1,616 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "romio.h" /* opt_gx */ -#include "config.h" /* mono, gray, small, tiny, progname */ -#include "ui.h" /* last_annunc_state, lcd_nibbles_buffer, DISP_ROWS */ -#include "ui_inner.h" - -#define LCD_WIDTH 131 -#define LCD_HEIGHT 64 -#define LCD_OFFSET_X 1 -#define LCD_OFFSET_Y 1 -#define LCD_BOTTOM LCD_OFFSET_Y + ( config.small ? ( LCD_HEIGHT / 2 ) : config.tiny ? ( LCD_HEIGHT / 4 ) : LCD_HEIGHT ) -#define LCD_RIGHT LCD_OFFSET_X + ( ( config.small || config.tiny ) ? ( LCD_WIDTH / 2 ) + 1 : LCD_WIDTH ) - -#define LCD_COLOR_BG 48 -#define LCD_COLOR_FG 49 - -#define LCD_PIXEL_ON 1 -#define LCD_PIXEL_OFF 2 -#define LCD_COLORS_PAIR 3 - -/****************************/ -/* functions implementation */ -/****************************/ - -static inline wchar_t eight_bits_to_braille_char( bool b1, bool b2, bool b3, bool b4, bool b5, bool b6, bool b7, bool b8 ) -{ - /*********/ - /* b1 b4 */ - /* b2 b5 */ - /* b3 b6 */ - /* b7 b8 */ - /*********/ - wchar_t chr = 0x2800; - - if ( b1 ) - chr |= 1; // 0b0000000000000001; - if ( b2 ) - chr |= 2; // 0b0000000000000010; - if ( b3 ) - chr |= 4; // 0b0000000000000100; - if ( b4 ) - chr |= 8; // 0b0000000000001000; - if ( b5 ) - chr |= 16; // 0b0000000000010000; - if ( b6 ) - chr |= 32; // 0b0000000000100000; - if ( b7 ) - chr |= 64; // 0b0000000001000000; - if ( b8 ) - chr |= 128; // 0b0000000010000000; - - return chr; -} - -static inline void ncurses_draw_lcd_tiny( void ) -{ - bool b1, b2, b3, b4, b5, b6, b7, b8; - int nibble_top, nibble_middle_top, nibble_middle_bottom, nibble_bottom; - int step_x = 2; - int step_y = 4; - - wchar_t line[ 66 ]; /* ( LCD_WIDTH / step_x ) + 1 */ - - if ( !config.mono && has_colors() ) - attron( COLOR_PAIR( LCD_COLORS_PAIR ) ); - - for ( int y = 0; y < LCD_HEIGHT; y += step_y ) { - wcscpy( line, L"" ); - - for ( int nibble_x = 0; nibble_x < NIBBLES_PER_ROW - 1; ++nibble_x ) { - nibble_top = lcd_nibbles_buffer[ y ][ nibble_x ]; - nibble_top &= 0x0f; - - nibble_middle_top = lcd_nibbles_buffer[ y + 1 ][ nibble_x ]; - nibble_middle_top &= 0x0f; - - nibble_middle_bottom = lcd_nibbles_buffer[ y + 2 ][ nibble_x ]; - nibble_middle_bottom &= 0x0f; - - nibble_bottom = lcd_nibbles_buffer[ y + 3 ][ nibble_x ]; - nibble_bottom &= 0x0f; - - for ( int bit_x = 0; bit_x < NIBBLES_NB_BITS; bit_x += step_x ) { - b1 = 0 != ( nibble_top & ( 1 << ( bit_x & 3 ) ) ); - b4 = 0 != ( nibble_top & ( 1 << ( ( bit_x + 1 ) & 3 ) ) ); - - b2 = 0 != ( nibble_middle_top & ( 1 << ( bit_x & 3 ) ) ); - b5 = 0 != ( nibble_middle_top & ( 1 << ( ( bit_x + 1 ) & 3 ) ) ); - - b3 = 0 != ( nibble_middle_bottom & ( 1 << ( bit_x & 3 ) ) ); - b6 = 0 != ( nibble_middle_bottom & ( 1 << ( ( bit_x + 1 ) & 3 ) ) ); - - b7 = 0 != ( nibble_bottom & ( 1 << ( bit_x & 3 ) ) ); - b8 = 0 != ( nibble_bottom & ( 1 << ( ( bit_x + 1 ) & 3 ) ) ); - - wchar_t pixels = eight_bits_to_braille_char( b1, b2, b3, b4, b5, b6, b7, b8 ); - wcsncat( line, &pixels, 1 ); - } - } - mvaddwstr( LCD_OFFSET_Y + ( y / step_y ), LCD_OFFSET_X, line ); - } - - if ( !config.mono && has_colors() ) - attroff( COLOR_PAIR( LCD_COLORS_PAIR ) ); - - wrefresh( stdscr ); -} - -static inline wchar_t four_bits_to_quadrant_char( bool top_left, bool top_right, bool bottom_left, bool bottom_right ) -{ - if ( top_left ) { - if ( top_right ) { - if ( bottom_left ) - return bottom_right ? L'█' : L'▛'; /* 0x2588 0x2598 */ - else - return bottom_right ? L'▜' : L'▀'; /* 0x259C 0x2580 */ - } else { - if ( bottom_left ) - return bottom_right ? L'▙' : L'▌'; - else - return bottom_right ? L'▚' : L'▘'; - } - } else { - if ( top_right ) { - if ( bottom_left ) - return bottom_right ? L'▟' : L'▞'; - else - return bottom_right ? L'▐' : L'▝'; - } else { - if ( bottom_left ) - return bottom_right ? L'▄' : L'▖'; - else - return bottom_right ? L'▗' : L' '; - } - } -} - -static inline void ncurses_draw_lcd_small( void ) -{ - bool top_left, top_right, bottom_left, bottom_right; - int nibble_top, nibble_bottom; - int step_x = 2; - int step_y = 2; - - wchar_t line[ 66 ]; /* ( LCD_WIDTH / step_x ) + 1 */ - - if ( !config.mono && has_colors() ) - attron( COLOR_PAIR( LCD_COLORS_PAIR ) ); - - for ( int y = 0; y < LCD_HEIGHT; y += step_y ) { - wcscpy( line, L"" ); - - for ( int nibble_x = 0; nibble_x < NIBBLES_PER_ROW - 1; ++nibble_x ) { - nibble_top = lcd_nibbles_buffer[ y ][ nibble_x ]; - nibble_top &= 0x0f; - nibble_bottom = lcd_nibbles_buffer[ y + 1 ][ nibble_x ]; - nibble_bottom &= 0x0f; - - for ( int bit_x = 0; bit_x < NIBBLES_NB_BITS; bit_x += step_x ) { - top_left = 0 != ( nibble_top & ( 1 << ( bit_x & 3 ) ) ); - top_right = 0 != ( nibble_top & ( 1 << ( ( bit_x + 1 ) & 3 ) ) ); - - bottom_left = 0 != ( nibble_bottom & ( 1 << ( bit_x & 3 ) ) ); - bottom_right = 0 != ( nibble_bottom & ( 1 << ( ( bit_x + 1 ) & 3 ) ) ); - - wchar_t pixels = four_bits_to_quadrant_char( top_left, top_right, bottom_left, bottom_right ); - wcsncat( line, &pixels, 1 ); - } - } - mvaddwstr( LCD_OFFSET_Y + ( y / step_y ), LCD_OFFSET_X, line ); - } - - if ( !config.mono && has_colors() ) - attroff( COLOR_PAIR( LCD_COLORS_PAIR ) ); - - wrefresh( stdscr ); -} - -static inline void ncurses_draw_lcd_fullsize( void ) -{ - bool bit; - int nibble; - int bit_stop; - int init_x; - - wchar_t line[ LCD_WIDTH ]; - - if ( !config.mono && has_colors() ) - attron( COLOR_PAIR( LCD_COLORS_PAIR ) ); - - for ( int y = 0; y < LCD_HEIGHT; ++y ) { - wcscpy( line, L"" ); - - for ( int nibble_x = 0; nibble_x < NIBBLES_PER_ROW; ++nibble_x ) { - nibble = lcd_nibbles_buffer[ y ][ nibble_x ]; - nibble &= 0x0f; - - init_x = nibble_x * NIBBLES_NB_BITS; - bit_stop = ( ( init_x + NIBBLES_NB_BITS >= LCD_WIDTH ) ? LCD_WIDTH - init_x : 4 ); - - for ( int bit_x = 0; bit_x < bit_stop; bit_x++ ) { - bit = 0 != ( nibble & ( 1 << ( bit_x & 3 ) ) ); - - wchar_t pixel = bit ? L'█' : L' '; - wcsncat( line, &pixel, 1 ); - } - } - mvaddwstr( LCD_OFFSET_Y + y, LCD_OFFSET_X, line ); - } - - if ( !config.mono && has_colors() ) - attroff( COLOR_PAIR( LCD_COLORS_PAIR ) ); - - wrefresh( stdscr ); -} - -static inline void ncurses_draw_lcd( void ) -{ - if ( config.tiny ) - ncurses_draw_lcd_tiny(); - else if ( config.small ) - ncurses_draw_lcd_small(); - else - ncurses_draw_lcd_fullsize(); -} - -static inline void draw_nibble( int col, int row, int val ) -{ - val &= 0x0f; - if ( val == lcd_nibbles_buffer[ row ][ col ] ) - return; - - lcd_nibbles_buffer[ row ][ col ] = val; -} - -/* Identical in all ui_*.c */ -static inline void draw_row( long addr, int row ) -{ - int line_length = NIBBLES_PER_ROW; - - if ( ( display.offset > 3 ) && ( row <= display.lines ) ) - line_length += 2; - - for ( int i = 0; i < line_length; i++ ) - draw_nibble( i, row, read_nibble( addr + i ) ); -} - -/**********/ -/* public */ -/**********/ -/* TODO: quasi-duplicate of ui_sdl.c:sdl_update_LCD() */ -void text_update_LCD( void ) -{ - /* First populate lcd_nibbles_buffer */ - if ( display.on ) { - int i; - long addr = display.disp_start; - static int old_offset = -1; - static int old_lines = -1; - - if ( display.offset != old_offset ) { - memset( lcd_nibbles_buffer, 0xf0, ( size_t )( ( display.lines + 1 ) * NIBS_PER_BUFFER_ROW ) ); - - old_offset = display.offset; - } - if ( display.lines != old_lines ) { - memset( &lcd_nibbles_buffer[ 56 ][ 0 ], 0xf0, ( size_t )( 8 * NIBS_PER_BUFFER_ROW ) ); - - old_lines = display.lines; - } - for ( i = 0; i <= display.lines; i++ ) { - draw_row( addr, i ); - addr += display.nibs_per_line; - } - if ( i < DISP_ROWS ) { - addr = display.menu_start; - for ( ; i < DISP_ROWS; i++ ) { - draw_row( addr, i ); - addr += NIBBLES_PER_ROW; - } - } - } else - ui_init_LCD(); - - /* Then actually draw from lcd_nibbles_buffer onto screen */ - ncurses_draw_lcd(); -} - -/* TODO: duplicate of ui_sdl.c:sdl_disp_draw_nibble() */ -void text_disp_draw_nibble( word_20 addr, word_4 val ) -{ - long offset = ( addr - display.disp_start ); - int x = offset % display.nibs_per_line; - - if ( x < 0 || x > 35 ) - return; - if ( display.nibs_per_line != 0 ) { - int y = offset / display.nibs_per_line; - if ( y < 0 || y > 63 ) - return; - - if ( val == lcd_nibbles_buffer[ y ][ x ] ) - return; - - lcd_nibbles_buffer[ y ][ x ] = val; - } else { - for ( int y = 0; y < display.lines; y++ ) { - if ( val == lcd_nibbles_buffer[ y ][ x ] ) - break; - - lcd_nibbles_buffer[ y ][ x ] = val; - } - } -} - -/* TODO: duplicate of ui_sdl.c:sdl_menu_draw_nibble() */ -void text_menu_draw_nibble( word_20 addr, word_4 val ) -{ - long offset = ( addr - display.menu_start ); - int x = offset % NIBBLES_PER_ROW; - int y = display.lines + ( offset / NIBBLES_PER_ROW ) + 1; - - if ( val == lcd_nibbles_buffer[ y ][ x ] ) - return; - - lcd_nibbles_buffer[ y ][ x ] = val; -} - -void text_draw_annunc( void ) -{ - const wchar_t* annunciators_icons[ 6 ] = { L"↰", L"↱", L"α", L"🪫", L"⌛", L"⇄" }; - - if ( saturn.annunc == last_annunc_state ) - return; - - last_annunc_state = saturn.annunc; - - for ( int i = 0; i < NB_ANNUNCIATORS; i++ ) - mvaddwstr( 0, 4 + ( i * 4 ), - ( ( annunciators_bits[ i ] & saturn.annunc ) == annunciators_bits[ i ] ) ? annunciators_icons[ i ] : L" " ); -} - -void text_adjust_contrast( void ) { text_update_LCD(); } - -void text_get_event( void ) -{ - int hpkey = -1; - uint32_t k; - - /* Start fresh and mark all keys as released */ - release_all_keys(); - - /* Iterate over all currently pressed keys and mark them as pressed */ - while ( ( k = getch() ) ) { - if ( k == ( uint32_t )ERR ) - break; - - switch ( k ) { - case '0': - hpkey = HPKEY_0; - break; - case '1': - hpkey = HPKEY_1; - break; - case '2': - hpkey = HPKEY_2; - break; - case '3': - hpkey = HPKEY_3; - break; - case '4': - hpkey = HPKEY_4; - break; - case '5': - hpkey = HPKEY_5; - break; - case '6': - hpkey = HPKEY_6; - break; - case '7': - hpkey = HPKEY_7; - break; - case '8': - hpkey = HPKEY_8; - break; - case '9': - hpkey = HPKEY_9; - break; - case 'a': - hpkey = HPKEY_A; - break; - case 'b': - hpkey = HPKEY_B; - break; - case 'c': - hpkey = HPKEY_C; - break; - case 'd': - hpkey = HPKEY_D; - break; - case 'e': - hpkey = HPKEY_E; - break; - case 'f': - hpkey = HPKEY_F; - break; - case 'g': - hpkey = HPKEY_MTH; - break; - case 'h': - hpkey = HPKEY_PRG; - break; - case 'i': - hpkey = HPKEY_CST; - break; - case 'j': - hpkey = HPKEY_VAR; - break; - case 'k': - case KEY_UP: - hpkey = HPKEY_UP; - break; - case 'l': - hpkey = HPKEY_NXT; - break; - case 'm': - hpkey = HPKEY_QUOTE; - break; - case 'n': - hpkey = HPKEY_STO; - break; - case 'o': - hpkey = HPKEY_EVAL; - break; - case 'p': - case KEY_LEFT: - hpkey = HPKEY_LEFT; - break; - case 'q': - case KEY_DOWN: - hpkey = HPKEY_DOWN; - break; - case 'r': - case KEY_RIGHT: - hpkey = HPKEY_RIGHT; - break; - case 's': - hpkey = HPKEY_SIN; - break; - case 't': - hpkey = HPKEY_COS; - break; - case 'u': - hpkey = HPKEY_TAN; - break; - case 'v': - hpkey = HPKEY_SQRT; - break; - case 'w': - hpkey = HPKEY_POWER; - break; - case 'x': - hpkey = HPKEY_INV; - break; - case 'y': - hpkey = HPKEY_NEG; - break; - case 'z': - hpkey = HPKEY_EEX; - break; - case ' ': - hpkey = HPKEY_SPC; - break; - case KEY_DC: - hpkey = HPKEY_DEL; - break; - case '.': - hpkey = HPKEY_PERIOD; - break; - case '+': - hpkey = HPKEY_PLUS; - break; - case '-': - hpkey = HPKEY_MINUS; - break; - case '*': - hpkey = HPKEY_MUL; - break; - case '/': - hpkey = HPKEY_DIV; - break; - - case KEY_F( 1 ): - case KEY_ENTER: - case '\n': - case ',': - hpkey = HPKEY_ENTER; - break; - case KEY_BACKSPACE: - case 127: - case '\b': - hpkey = HPKEY_BS; - break; - case KEY_F( 2 ): - case '[': - case 339: /* PgUp */ - hpkey = HPKEY_SHL; - break; - case KEY_F( 3 ): - case ']': - case 338: /* PgDn */ - hpkey = HPKEY_SHR; - break; - case KEY_F( 4 ): - case ';': - case KEY_IC: /* Ins */ - hpkey = HPKEY_ALPHA; - break; - case KEY_F( 5 ): - case '\\': - case 27: /* Esc */ - case 262: /* Home */ - hpkey = HPKEY_ON; - break; - - case KEY_F( 7 ): - case '|': /* Shift+\ */ - case KEY_SEND: /* Shift+End */ - case KEY_F( 10 ): - // please_exit = true; - close_and_exit(); - break; - } - - if ( !keyboard[ hpkey ].pressed ) - press_key( hpkey ); - } -} - -void text_ui_stop( void ) -{ - nodelay( stdscr, FALSE ); - echo(); - endwin(); -} - -void init_text_ui( int argc, char** argv ) -{ - if ( config.verbose ) - fprintf( stderr, "UI is ncurses\n" ); - - /* Set public API to this UIs functions */ - ui_disp_draw_nibble = text_disp_draw_nibble; - ui_menu_draw_nibble = text_menu_draw_nibble; - ui_get_event = text_get_event; - ui_update_LCD = text_update_LCD; - ui_refresh_LCD = text_update_LCD; - ui_adjust_contrast = text_adjust_contrast; - ui_draw_annunc = text_draw_annunc; - - setlocale( LC_ALL, "" ); - initscr(); /* initialize the curses library */ - keypad( stdscr, TRUE ); /* enable keyboard mapping */ - nodelay( stdscr, TRUE ); - curs_set( 0 ); - cbreak(); /* take input chars one at a time, no wait for \n */ - noecho(); - nonl(); /* tell curses not to do NL->CR/NL on output */ - - if ( !config.mono && has_colors() ) { - start_color(); - - if ( config.gray ) { - init_color( LCD_COLOR_BG, COLORS[ LCD ].gray_rgb, COLORS[ LCD ].gray_rgb, COLORS[ LCD ].gray_rgb ); - init_color( LCD_COLOR_FG, COLORS[ PIXEL ].gray_rgb, COLORS[ PIXEL ].gray_rgb, COLORS[ PIXEL ].gray_rgb ); - } else { - init_color( LCD_COLOR_BG, COLORS[ LCD ].r, COLORS[ LCD ].g, COLORS[ LCD ].b ); - init_color( LCD_COLOR_FG, COLORS[ PIXEL ].r, COLORS[ PIXEL ].g, COLORS[ PIXEL ].b ); - } - - init_pair( LCD_PIXEL_OFF, LCD_COLOR_BG, LCD_COLOR_BG ); - init_pair( LCD_PIXEL_ON, LCD_COLOR_FG, LCD_COLOR_FG ); - init_pair( LCD_COLORS_PAIR, LCD_COLOR_FG, LCD_COLOR_BG ); - } - - mvaddch( 0, 0, ACS_ULCORNER ); - mvaddch( LCD_BOTTOM, 0, ACS_LLCORNER ); - mvaddch( 0, LCD_RIGHT, ACS_URCORNER ); - mvaddch( LCD_BOTTOM, LCD_RIGHT, ACS_LRCORNER ); - mvhline( 0, 1, ACS_HLINE, LCD_RIGHT - 1 ); - mvhline( LCD_BOTTOM, 1, ACS_HLINE, LCD_RIGHT - 1 ); - mvvline( 1, 0, ACS_VLINE, LCD_BOTTOM - 1 ); - mvvline( 1, LCD_RIGHT, ACS_VLINE, LCD_BOTTOM - 1 ); - - mvprintw( 0, 2, "[ | | | | | ]" ); /* annunciators */ - mvprintw( 0, LCD_RIGHT - 18, "< %s v%i.%i.%i >", config.progname, VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL ); - - mvprintw( LCD_BOTTOM, 2, "[ wire: %s ]-[ IR: %s ]-[ contrast: %i ]", wire_name, ir_name, display.contrast ); - - mvprintw( LCD_BOTTOM + 1, 0, "F1: Enter, F2: Left-Shift, F3: Right-Shift, F4: Alpha, F5: On, F7: Quit" ); -} diff --git a/src/ui_x11.c b/src/ui_x11.c deleted file mode 100644 index 85a6647..0000000 --- a/src/ui_x11.c +++ /dev/null @@ -1,3303 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "romio.h" /* opt_gx */ -#include "config.h" -#include "ui.h" -#include "ui_inner.h" - -#define UPDATE_MENU 1 -#define UPDATE_DISP 2 - -#define KEYBOARD_HEIGHT ( BUTTONS[ LAST_HPKEY ].y + BUTTONS[ LAST_HPKEY ].h ) -#define KEYBOARD_WIDTH ( BUTTONS[ LAST_HPKEY ].x + BUTTONS[ LAST_HPKEY ].w ) - -#define TOP_SKIP 65 -#define SIDE_SKIP 20 -#define BOTTOM_SKIP 25 -#define DISP_KBD_SKIP 65 - -#define DISPLAY_WIDTH ( 264 + 8 ) -#define DISPLAY_HEIGHT ( 128 + 16 + 8 ) -#define DISPLAY_OFFSET_X ( SIDE_SKIP + ( 286 - DISPLAY_WIDTH ) / 2 ) -#define DISPLAY_OFFSET_Y TOP_SKIP - -#define DISP_FRAME 8 - -#define KEYBOARD_OFFSET_X SIDE_SKIP -#define KEYBOARD_OFFSET_Y ( TOP_SKIP + DISPLAY_HEIGHT + DISP_KBD_SKIP ) - -#define COLOR_MODE_MONO 1 -#define COLOR_MODE_GRAY 2 -#define COLOR_MODE_COLOR 3 - -#define COLOR( c ) ( x11_colors[ ( c ) ].pixel ) - -/***********/ -/* bitmaps */ -/***********/ - -#define hp48_icon_width 32 -#define hp48_icon_height 64 -static unsigned char hp48_icon_bitmap[] = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xe0, 0xff, 0xff, 0x07, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x07, 0xff, 0x01, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, - 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, - 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x63, 0x8c, - 0x31, 0xc6, 0x63, 0x8c, 0x31, 0xc6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x63, 0x8c, 0x31, 0xc6, 0x63, 0x8c, 0x31, 0xc6, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x63, 0x8c, 0x31, 0xc6, 0x63, 0x8c, 0x31, 0xc6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x63, 0x8c, 0x31, 0xc6, 0x63, 0x8c, 0x31, 0xc6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x8c, 0x31, 0xc6, - 0x03, 0x8c, 0x31, 0xc6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe3, 0x30, 0x0c, 0xc3, 0xe3, 0x30, 0x0c, 0xc3, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe3, 0x30, 0x0c, 0xc3, 0xe3, 0x30, 0x0c, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xe3, 0x30, 0x0c, 0xc3, 0xe3, 0x30, 0x0c, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe3, 0x30, 0x0c, 0xc3, 0xe3, 0x30, - 0x0c, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; - -#define hp48_top_width 32 -#define hp48_top_height 30 -static unsigned char hp48_top_bitmap[] = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xe0, 0xff, 0xff, 0x07, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x07, 0xff, 0x01, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, - 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, - 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, - 0x07, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x63, 0x8c, 0x31, 0xc6, 0x63, 0x8c, 0x31, 0xc6, 0xff, 0xff, 0xff, 0xff }; - -#define hp48_bottom_width 32 -#define hp48_bottom_height 64 -static unsigned char hp48_bottom_bitmap[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x63, 0x8c, 0x31, 0xc6, 0x63, 0x8c, 0x31, 0xc6, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x63, 0x8c, 0x31, 0xc6, 0x63, 0x8c, 0x31, 0xc6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x63, 0x8c, 0x31, 0xc6, 0x63, 0x8c, 0x31, 0xc6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x8c, 0x31, 0xc6, - 0x03, 0x8c, 0x31, 0xc6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe3, 0x30, 0x0c, 0xc3, 0xe3, 0x30, 0x0c, 0xc3, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe3, 0x30, 0x0c, 0xc3, 0xe3, 0x30, 0x0c, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xe3, 0x30, 0x0c, 0xc3, 0xe3, 0x30, 0x0c, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe3, 0x30, 0x0c, 0xc3, 0xe3, 0x30, - 0x0c, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; - -#define hp48_logo_width 13 -#define hp48_logo_height 4 -static unsigned char hp48_logo_bitmap[] = { 0x00, 0x00, 0x00, 0x00, 0xf8, 0x1f, 0xf8, 0x1f }; - -#define hp48_text_width 29 -#define hp48_text_height 7 -static unsigned char hp48_text_bitmap[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0xfe, 0x1f }; - -#define hp48_disp_width 29 -#define hp48_disp_height 21 -static unsigned char hp48_disp_bitmap[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0x1f, 0xf8, 0xff, 0xff, 0x1f, 0xf8, 0xff, - 0xff, 0x1f, 0xf8, 0xff, 0xff, 0x1f, 0xf8, 0xff, 0xff, 0x1f, 0xf8, 0xff, 0xff, 0x1f, 0xf8, 0xff, 0xff, 0x1f, 0xf8, 0xff, 0xff, - 0x1f, 0xf8, 0xff, 0xff, 0x1f, 0xf8, 0xff, 0xff, 0x1f, 0xf8, 0xff, 0xff, 0x1f, 0xf8, 0xff, 0xff, 0x1f, 0xf8, 0xff, 0xff, 0x1f }; - -#define hp48_keys_width 30 -#define hp48_keys_height 61 -static unsigned char hp48_keys_bitmap[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x9c, 0x73, 0xce, 0x39, 0x9c, 0x73, 0xce, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9c, 0x73, - 0xce, 0x39, 0x9c, 0x73, 0xce, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9c, 0x73, 0xce, 0x39, 0x9c, 0x73, 0xce, - 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9c, 0x73, 0xce, 0x39, 0x9c, 0x73, 0xce, 0x39, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xfc, 0x73, 0xce, 0x39, 0xfc, 0x73, 0xce, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, - 0xcf, 0xf3, 0x3c, 0x1c, 0xcf, 0xf3, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcf, 0xf3, 0x3c, 0x00, 0xcf, - 0xf3, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcf, 0xf3, 0x3c, 0x00, 0xcf, 0xf3, 0x3c, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0xcf, 0xf3, 0x3c, 0x1c, 0xcf, 0xf3, 0x3c }; - -#define hp48_orange_width 5 -#define hp48_orange_height 53 -static unsigned char hp48_orange_bitmap[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x1c }; - -#define hp48_blue_width 5 -#define hp48_blue_height 57 -static unsigned char hp48_blue_bitmap[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x1c }; - -#define hp48_on_width 25 -#define hp48_on_height 19 -static unsigned char hp48_on_bitmap[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe2, 0x00, 0x00, 0x00, 0x13, 0x01, - 0x00, 0x80, 0x12, 0x01, 0x80, 0x48, 0x12, 0x01, 0x80, 0xc8, 0xe7, 0x00, 0x00, 0x05, 0x12, 0x01, - 0x00, 0x02, 0x12, 0x01, 0x00, 0x05, 0x12, 0x01, 0x80, 0x08, 0xe2, 0x00 }; - -#define hp48_top_gx_width 32 -#define hp48_top_gx_height 30 -static unsigned char hp48_top_gx_bitmap[] = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x08, 0xff, 0xe1, 0x07, 0x08, 0xff, 0xe0, 0xff, 0xff, 0xff, 0xf0, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, - 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, - 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, - 0x07, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x63, 0x8c, 0x31, 0xc6, 0x63, 0x8c, 0x31, 0xc6, 0xff, 0xff, 0xff, 0xff }; - -#define hp48_logo_gx_width 16 -#define hp48_logo_gx_height 4 -static unsigned char hp48_logo_gx_bitmap[] = { 0x00, 0x00, 0x00, 0x00, 0xf8, 0xf7, 0xf8, 0xf7 }; - -#define hp48_text_gx_width 29 -#define hp48_text_gx_height 7 -static unsigned char hp48_text_gx_bitmap[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x0f, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f }; - -#define hp48_green_gx_width 29 -#define hp48_green_gx_height 57 -static unsigned char hp48_green_gx_bitmap[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00 }; - -typedef struct x11_keypad_t { - unsigned int width; - unsigned int height; - - Pixmap pixmap; -} x11_keypad_t; - -typedef struct x11_button_t { - Pixmap map; - Pixmap down; - Window xwin; -} x11_button_t; - -typedef struct x11_lcd_t { - Window win; - GC gc; - - int display_update; - XShmSegmentInfo disp_info; - XImage* disp_image; - XShmSegmentInfo menu_info; - XImage* menu_image; -} x11_lcd_t; - -typedef struct icon_map_t { - unsigned int w; - unsigned int h; - int c; - unsigned char* bits; -} icon_map_t; - -static bool mapped; - -static x11_keypad_t keypad; - -static XColor x11_colors[ NB_COLORS ]; - -static int CompletionType = -1; - -static x11_lcd_t lcd; - -static bool shm_flag; - -static Display* dpy; -static int screen; - -static unsigned int depth; -static Colormap cmap; -static GC gc; -static Window mainW; -static Window iconW = 0; - -static Atom wm_delete_window, wm_save_yourself, wm_protocols; -static Atom ol_decor_del, ol_decor_icon_name; -static Atom atom_type; -static Visual* visual; -static Pixmap icon_pix; -static Pixmap icon_text_pix; -static Pixmap icon_disp_pix; -static int last_icon_state = -1; -static bool xerror_flag; - -static bool dynamic_color; -static bool direct_color; -static int color_mode; -static int icon_color_mode; - -static char* res_name; -static char* res_class; - -static x11_button_t x11_buttons[ NB_KEYS ]; - -#define MAX_PASTE 128 -static int paste[ MAX_PASTE * 3 ]; -static int paste_count = 0; -static int paste_size = 0; -static int paste_last_key = 0; - -static int first_key = 0; - -static int last_button = -1; - -#define ICON_MAP 0 -#define ON_MAP 1 -#define DISP_MAP 2 -#define FIRST_MAP 3 -#define LAST_MAP 9 - -static icon_map_t* icon_maps; - -static Pixmap nibble_maps[ 16 ]; - -static unsigned char nibbles[ 16 ][ 2 ] = { - {0x00, 0x00}, /* ---- */ - {0x03, 0x03}, /* *--- */ - {0x0c, 0x0c}, /* -*-- */ - {0x0f, 0x0f}, /* **-- */ - {0x30, 0x30}, /* --*- */ - {0x33, 0x33}, /* *-*- */ - {0x3c, 0x3c}, /* -**- */ - {0x3f, 0x3f}, /* ***- */ - {0xc0, 0xc0}, /* ---* */ - {0xc3, 0xc3}, /* *--* */ - {0xcc, 0xcc}, /* -*-* */ - {0xcf, 0xcf}, /* **-* */ - {0xf0, 0xf0}, /* --** */ - {0xf3, 0xf3}, /* *-** */ - {0xfc, 0xfc}, /* -*** */ - {0xff, 0xff} /* **** */ -}; - -static unsigned char nibble_bitmap[ 16 ]; - -static Pixmap x11_ann_pixmaps[ NB_ANNUNCIATORS ]; - -static icon_map_t icon_maps_sx[] = { - {.w = hp48_icon_width, .h = hp48_icon_height, .c = BLACK, .bits = hp48_icon_bitmap }, - {.w = hp48_on_width, .h = hp48_on_height, .c = PIXEL, .bits = hp48_on_bitmap }, - {.w = hp48_disp_width, .h = hp48_disp_height, .c = LCD, .bits = hp48_disp_bitmap }, - {.w = hp48_top_width, .h = hp48_top_height, .c = DISP_PAD, .bits = hp48_top_bitmap }, - {.w = hp48_bottom_width, .h = hp48_bottom_height, .c = PAD, .bits = hp48_bottom_bitmap}, - {.w = hp48_logo_width, .h = hp48_logo_height, .c = LOGO, .bits = hp48_logo_bitmap }, - {.w = hp48_text_width, .h = hp48_text_height, .c = LABEL, .bits = hp48_text_bitmap }, - {.w = hp48_keys_width, .h = hp48_keys_height, .c = BLACK, .bits = hp48_keys_bitmap }, - {.w = hp48_orange_width, .h = hp48_orange_height, .c = LEFT, .bits = hp48_orange_bitmap}, - {.w = hp48_blue_width, .h = hp48_blue_height, .c = RIGHT, .bits = hp48_blue_bitmap } -}; - -static icon_map_t icon_maps_gx[] = { - {.w = hp48_icon_width, .h = hp48_icon_height, .c = BLACK, .bits = hp48_icon_bitmap }, - {.w = hp48_on_width, .h = hp48_on_height, .c = PIXEL, .bits = hp48_on_bitmap }, - {.w = hp48_disp_width, .h = hp48_disp_height, .c = LCD, .bits = hp48_disp_bitmap }, - {.w = hp48_top_gx_width, .h = hp48_top_gx_height, .c = DISP_PAD, .bits = hp48_top_gx_bitmap }, - {.w = hp48_bottom_width, .h = hp48_bottom_height, .c = PAD, .bits = hp48_bottom_bitmap }, - {.w = hp48_logo_gx_width, .h = hp48_logo_gx_height, .c = LOGO, .bits = hp48_logo_gx_bitmap }, - {.w = hp48_text_gx_width, .h = hp48_text_gx_height, .c = LABEL, .bits = hp48_text_gx_bitmap }, - {.w = hp48_keys_width, .h = hp48_keys_height, .c = BLACK, .bits = hp48_keys_bitmap }, - {.w = hp48_orange_width, .h = hp48_orange_height, .c = LEFT, .bits = hp48_orange_bitmap }, - {.w = hp48_green_gx_width, .h = hp48_green_gx_height, .c = RIGHT, .bits = hp48_green_gx_bitmap} -}; - -static int saved_argc; -static char** saved_argv; - -/************************/ -/* functions prototypes */ -/************************/ -void x11_draw_annunc( void ); -void x11_update_LCD( void ); - -/*************/ -/* functions */ -/*************/ -static inline void fatal_exit( const char* error, const char* advice ) -{ - if ( error[ 0 ] == '\0' ) { - fprintf( stderr, "FATAL ERROR, exit.\n" ); - exit( 1 ); - } - - fprintf( stderr, "FATAL ERROR, exit.\n - %s\n", error ); - - if ( advice[ 0 ] != '\0' ) - fprintf( stderr, " - %s\n", advice ); - - exit( 1 ); -} - -Visual* pick_visual_of_class( Display* local_dpy, int visual_class, unsigned int* local_depth ) -{ - XVisualInfo vi_in, *vi_out; - int out_count; - - vi_in.class = visual_class; - vi_in.screen = DefaultScreen( local_dpy ); - vi_out = XGetVisualInfo( local_dpy, VisualClassMask | VisualScreenMask, &vi_in, &out_count ); - if ( vi_out ) { /* choose the 'best' one, if multiple */ - int i, best; - Visual* local_visual; - for ( i = 0, best = 0; i < out_count; i++ ) - if ( vi_out[ i ].depth > vi_out[ best ].depth ) - best = i; - local_visual = vi_out[ best ].visual; - *local_depth = vi_out[ best ].depth; - XFree( ( char* )vi_out ); - return local_visual; - } else { - *local_depth = DefaultDepth( local_dpy, DefaultScreen( local_dpy ) ); - return DefaultVisual( local_dpy, DefaultScreen( local_dpy ) ); - } -} - -Visual* id_to_visual( Display* local_dpy, int id, unsigned int* local_depth ) -{ - XVisualInfo vi_in, *vi_out; - int out_count; - - vi_in.screen = DefaultScreen( local_dpy ); - vi_in.visualid = id; - vi_out = XGetVisualInfo( local_dpy, VisualScreenMask | VisualIDMask, &vi_in, &out_count ); - if ( vi_out ) { - Visual* v = vi_out[ 0 ].visual; - *local_depth = vi_out[ 0 ].depth; - XFree( ( char* )vi_out ); - return v; - } - return 0; -} - -Visual* get_visual_resource( Display* local_dpy, unsigned int* local_depth ) -{ - char c; - int vclass; - int id; - - if ( !config.x11_visual || !strcmp( config.x11_visual, "default" ) ) - vclass = -1; - else if ( !strcmp( config.x11_visual, "staticgray" ) ) - vclass = StaticGray; - else if ( !strcmp( config.x11_visual, "staticcolor" ) ) - vclass = StaticColor; - else if ( !strcmp( config.x11_visual, "truecolor" ) ) - vclass = TrueColor; - else if ( !strcmp( config.x11_visual, "grayscale" ) ) - vclass = GrayScale; - else if ( !strcmp( config.x11_visual, "pseudocolor" ) ) - vclass = PseudoColor; - else if ( !strcmp( config.x11_visual, "directcolor" ) ) - vclass = DirectColor; - else if ( 1 == sscanf( config.x11_visual, " %d %c", &id, &c ) ) - vclass = -2; - else if ( 1 == sscanf( config.x11_visual, " 0x%d %c", &id, &c ) ) - vclass = -2; - else { - fprintf( stderr, "unrecognized visual \"%s\".\n", config.x11_visual ); - vclass = -1; - } - - if ( vclass == -1 ) { - *local_depth = DefaultDepth( local_dpy, DefaultScreen( local_dpy ) ); - - return DefaultVisual( local_dpy, DefaultScreen( local_dpy ) ); - } else if ( vclass == -2 ) { - Visual* v = id_to_visual( local_dpy, id, local_depth ); - if ( v ) - return v; - - fprintf( stderr, "no visual with id 0x%x.\n", id ); - - *local_depth = DefaultDepth( local_dpy, DefaultScreen( local_dpy ) ); - - return DefaultVisual( local_dpy, DefaultScreen( local_dpy ) ); - } else - return pick_visual_of_class( local_dpy, vclass, local_depth ); -} - -static inline XFontStruct* load_x11_font( Display* local_dpy, char* fontname ) -{ - XFontStruct* f = ( XFontStruct* )0; - - f = XLoadQueryFont( local_dpy, fontname ); - - if ( f == ( XFontStruct* )0 ) { - char errbuf[ 1024 ]; - char fixbuf[ 1024 ]; - sprintf( errbuf, "can\'t load font \'%s\'", fontname ); - sprintf( fixbuf, "Please change resource \'%s\'", config.name ); - fatal_exit( errbuf, fixbuf ); - } - - return f; -} - -static inline void colors_setup( void ) -{ - int c, error, dyn; - int r_shift = 0, g_shift = 0, b_shift = 0; - XSetWindowAttributes xswa; - - error = -1; - dyn = dynamic_color; - - if ( direct_color ) { - while ( !( visual->red_mask & ( 1 << r_shift ) ) ) - r_shift++; - while ( visual->red_mask & ( 1 << r_shift ) ) - r_shift++; - r_shift = 16 - r_shift; - while ( !( visual->green_mask & ( 1 << g_shift ) ) ) - g_shift++; - while ( ( visual->green_mask & ( 1 << g_shift ) ) ) - g_shift++; - g_shift = 16 - g_shift; - while ( !( visual->blue_mask & ( 1 << b_shift ) ) ) - b_shift++; - while ( ( visual->blue_mask & ( 1 << b_shift ) ) ) - b_shift++; - b_shift = 16 - b_shift; - } - - for ( c = FIRST_COLOR; c <= LAST_COLOR; c++ ) { - switch ( color_mode ) { - case COLOR_MODE_MONO: - x11_colors[ c ].red = COLORS[ c ].mono_rgb << 8; - x11_colors[ c ].green = COLORS[ c ].mono_rgb << 8; - x11_colors[ c ].blue = COLORS[ c ].mono_rgb << 8; - break; - case COLOR_MODE_GRAY: - x11_colors[ c ].red = COLORS[ c ].gray_rgb << 8; - x11_colors[ c ].green = COLORS[ c ].gray_rgb << 8; - x11_colors[ c ].blue = COLORS[ c ].gray_rgb << 8; - break; - default: - x11_colors[ c ].red = COLORS[ c ].r << 8; - x11_colors[ c ].green = COLORS[ c ].g << 8; - x11_colors[ c ].blue = COLORS[ c ].b << 8; - break; - } - if ( direct_color ) { - x11_colors[ c ].pixel = ( ( x11_colors[ c ].red >> r_shift ) & visual->red_mask ) | - ( ( x11_colors[ c ].green >> g_shift ) & visual->green_mask ) | - ( ( x11_colors[ c ].blue >> b_shift ) & visual->blue_mask ); - XStoreColor( dpy, cmap, &x11_colors[ c ] ); - } else { - if ( dynamic_color && c == PIXEL ) { - if ( XAllocColorCells( dpy, cmap, True, ( unsigned long* )0, 0, &x11_colors[ c ].pixel, 1 ) == 0 ) { - dyn = 0; - if ( XAllocColor( dpy, cmap, &x11_colors[ c ] ) == 0 ) { - if ( config.verbose ) - fprintf( stderr, "XAllocColor failed.\n" ); - error = c; - break; - } - } else if ( x11_colors[ c ].pixel >= ( unsigned long )( visual->map_entries ) ) { - dyn = 0; - if ( XAllocColor( dpy, cmap, &x11_colors[ c ] ) == 0 ) { - if ( config.verbose ) - fprintf( stderr, "XAllocColor failed.\n" ); - error = c; - break; - } - } else { - XStoreColor( dpy, cmap, &x11_colors[ c ] ); - } - } else { - if ( XAllocColor( dpy, cmap, &x11_colors[ c ] ) == 0 ) { - if ( config.verbose ) - fprintf( stderr, "XAllocColor failed.\n" ); - error = c; - break; - } - } - } - } - - /* - * Can't be reached when visual->class == DirectColor - */ - if ( error != -1 ) { - if ( config.verbose ) - fprintf( stderr, "Using own Colormap.\n" ); - /* - * free colors so far allocated - */ - for ( c = FIRST_COLOR; c < error; c++ ) - XFreeColors( dpy, cmap, &x11_colors[ c ].pixel, 1, 0 ); - - /* - * Create my own Colormap - */ - cmap = XCreateColormap( dpy, mainW, visual, AllocNone ); - if ( cmap == ( Colormap )0 ) - fatal_exit( "can\'t alloc Colormap.\n", "" ); - - xswa.colormap = cmap; - XChangeWindowAttributes( dpy, mainW, CWColormap, &xswa ); - if ( iconW ) - XChangeWindowAttributes( dpy, iconW, CWColormap, &xswa ); - - /* - * Try to allocate colors again - */ - dyn = dynamic_color; - for ( c = FIRST_COLOR; c <= LAST_COLOR; c++ ) { - switch ( color_mode ) { - case COLOR_MODE_MONO: - x11_colors[ c ].red = COLORS[ c ].mono_rgb << 8; - x11_colors[ c ].green = COLORS[ c ].mono_rgb << 8; - x11_colors[ c ].blue = COLORS[ c ].mono_rgb << 8; - break; - case COLOR_MODE_GRAY: - x11_colors[ c ].red = COLORS[ c ].gray_rgb << 8; - x11_colors[ c ].green = COLORS[ c ].gray_rgb << 8; - x11_colors[ c ].blue = COLORS[ c ].gray_rgb << 8; - break; - default: - x11_colors[ c ].red = COLORS[ c ].r << 8; - x11_colors[ c ].green = COLORS[ c ].g << 8; - x11_colors[ c ].blue = COLORS[ c ].b << 8; - break; - } - if ( dynamic_color && c == PIXEL ) { - if ( XAllocColorCells( dpy, cmap, True, ( unsigned long* )0, 0, &x11_colors[ c ].pixel, 1 ) == 0 ) { - dyn = 0; - if ( XAllocColor( dpy, cmap, &x11_colors[ c ] ) == 0 ) - fatal_exit( "can\'t alloc Color.\n", "" ); - - } else if ( x11_colors[ c ].pixel >= ( unsigned long )( visual->map_entries ) ) { - dyn = 0; - if ( XAllocColor( dpy, cmap, &x11_colors[ c ] ) == 0 ) - fatal_exit( "can\'t alloc Color.\n", "" ); - - } else { - XStoreColor( dpy, cmap, &x11_colors[ c ] ); - } - } else { - if ( XAllocColor( dpy, cmap, &x11_colors[ c ] ) == 0 ) - fatal_exit( "can\'t alloc Color.\n", "" ); - } - } - } - - dynamic_color = dyn; -} - -static inline void __write_text( Display* the_dpy, Drawable d, GC the_gc, int x, int y, const char* string, unsigned int length ) -{ - Pixmap pix; - - for ( unsigned int i = 0; i < length; i++ ) { - if ( small_font[ ( int )string[ i ] ].h != 0 ) { - pix = XCreateBitmapFromData( the_dpy, d, ( char* )small_font[ ( int )string[ i ] ].bits, small_font[ ( int )string[ i ] ].w, - small_font[ ( int )string[ i ] ].h ); - XCopyPlane( the_dpy, pix, d, the_gc, 0, 0, small_font[ ( int )string[ i ] ].w, small_font[ ( int )string[ i ] ].h, x, - ( int )( y - small_font[ ( int )string[ i ] ].h ), 1 ); - XFreePixmap( the_dpy, pix ); - } - x += SmallTextWidth( &string[ i ], 1 ); - } -} - -static inline void __create_button( int i, int off_x, int off_y, XFontStruct* f_small, XFontStruct* f_med, XFontStruct* f_big ) -{ - int x, y; - XSetWindowAttributes xswa; - XFontStruct* finfo; - XGCValues val; - unsigned long gc_mask; - Pixmap pix; - XCharStruct xchar; - int dir, fa, fd; - unsigned long pixel; - - if ( i < HPKEY_MTH ) - pixel = COLOR( DISP_PAD ); - else { - if ( opt_gx && BUTTONS[ i ].is_menu ) - pixel = COLOR( UNDERLAY ); - else - pixel = COLOR( PAD ); - } - - /* - * create the buttons subwindows - */ - x11_buttons[ i ].xwin = XCreateSimpleWindow( dpy, mainW, off_x + BUTTONS[ i ].x, off_y + BUTTONS[ i ].y, BUTTONS[ i ].w, BUTTONS[ i ].h, - 0, COLOR( BLACK ), pixel ); - - XDefineCursor( dpy, x11_buttons[ i ].xwin, XCreateFontCursor( dpy, XC_hand1 ) ); - - xswa.event_mask = LeaveWindowMask | ExposureMask | StructureNotifyMask; - xswa.backing_store = Always; - - XChangeWindowAttributes( dpy, x11_buttons[ i ].xwin, CWEventMask | CWBackingStore, &xswa ); - - /* - * draw the released button - */ - x11_buttons[ i ].map = XCreatePixmap( dpy, x11_buttons[ i ].xwin, BUTTONS[ i ].w, BUTTONS[ i ].h, depth ); - - XSetForeground( dpy, gc, pixel ); - XFillRectangle( dpy, x11_buttons[ i ].map, gc, 0, 0, BUTTONS[ i ].w, BUTTONS[ i ].h ); - - XSetForeground( dpy, gc, COLOR( BUTTON ) ); - XFillRectangle( dpy, x11_buttons[ i ].map, gc, 1, 1, BUTTONS[ i ].w - 2, BUTTONS[ i ].h - 2 ); - - if ( BUTTONS[ i ].label != ( char* )0 ) { - /* - * set font size in gc - */ - switch ( BUTTONS[ i ].font_size ) { - case 0: - finfo = f_small; - break; - case 1: - finfo = f_big; - break; - case 2: - finfo = f_med; - break; - default: - finfo = f_small; - break; - } - val.font = finfo->fid; - gc_mask = GCFont; - XChangeGC( dpy, gc, gc_mask, &val ); - - /* - * draw string centered in button - */ - XSetBackground( dpy, gc, COLOR( BUTTON ) ); - XSetForeground( dpy, gc, COLOR( BUTTONS[ i ].lc ) ); - - XTextExtents( finfo, BUTTONS[ i ].label, ( int )strlen( BUTTONS[ i ].label ), &dir, &fa, &fd, &xchar ); - x = ( BUTTONS[ i ].w - xchar.width ) / 2; - y = ( 1 + BUTTONS[ i ].h - ( xchar.ascent + xchar.descent ) ) / 2 + xchar.ascent + 1; - XDrawImageString( dpy, x11_buttons[ i ].map, gc, x, y, BUTTONS[ i ].label, ( int )strlen( BUTTONS[ i ].label ) ); - - XSetBackground( dpy, gc, COLOR( BLACK ) ); - - } else if ( BUTTONS[ i ].lw != 0 ) { - /* - * draw pixmap centered in button - */ - XSetBackground( dpy, gc, COLOR( BUTTON ) ); - XSetForeground( dpy, gc, COLOR( BUTTONS[ i ].lc ) ); - - pix = XCreateBitmapFromData( dpy, x11_buttons[ i ].xwin, ( char* )BUTTONS[ i ].lb, BUTTONS[ i ].lw, BUTTONS[ i ].lh ); - - x = ( 1 + BUTTONS[ i ].w - BUTTONS[ i ].lw ) / 2; - y = ( 1 + BUTTONS[ i ].h - BUTTONS[ i ].lh ) / 2 + 1; - - XCopyPlane( dpy, pix, x11_buttons[ i ].map, gc, 0, 0, BUTTONS[ i ].lw, BUTTONS[ i ].lh, x, y, 1 ); - - XFreePixmap( dpy, pix ); - - XSetBackground( dpy, gc, COLOR( BLACK ) ); - } - - /* - * draw edge of button - */ - XSetForeground( dpy, gc, COLOR( BUT_TOP ) ); - - XDrawLine( dpy, x11_buttons[ i ].map, gc, 1, ( int )( BUTTONS[ i ].h - 2 ), 1, 1 ); - XDrawLine( dpy, x11_buttons[ i ].map, gc, 2, ( int )( BUTTONS[ i ].h - 3 ), 2, 2 ); - XDrawLine( dpy, x11_buttons[ i ].map, gc, 3, ( int )( BUTTONS[ i ].h - 4 ), 3, 3 ); - - XDrawLine( dpy, x11_buttons[ i ].map, gc, 1, 1, ( int )( BUTTONS[ i ].w - 2 ), 1 ); - XDrawLine( dpy, x11_buttons[ i ].map, gc, 2, 2, ( int )( BUTTONS[ i ].w - 3 ), 2 ); - XDrawLine( dpy, x11_buttons[ i ].map, gc, 3, 3, ( int )( BUTTONS[ i ].w - 4 ), 3 ); - XDrawLine( dpy, x11_buttons[ i ].map, gc, 4, 4, ( int )( BUTTONS[ i ].w - 5 ), 4 ); - - XDrawPoint( dpy, x11_buttons[ i ].map, gc, 4, 5 ); - - XSetForeground( dpy, gc, COLOR( BUT_BOT ) ); - - XDrawLine( dpy, x11_buttons[ i ].map, gc, 3, ( int )( BUTTONS[ i ].h - 2 ), ( int )( BUTTONS[ i ].w - 2 ), - ( int )( BUTTONS[ i ].h - 2 ) ); - XDrawLine( dpy, x11_buttons[ i ].map, gc, 4, ( int )( BUTTONS[ i ].h - 3 ), ( int )( BUTTONS[ i ].w - 3 ), - ( int )( BUTTONS[ i ].h - 3 ) ); - - XDrawLine( dpy, x11_buttons[ i ].map, gc, ( int )( BUTTONS[ i ].w - 2 ), ( int )( BUTTONS[ i ].h - 2 ), ( int )( BUTTONS[ i ].w - 2 ), - 3 ); - XDrawLine( dpy, x11_buttons[ i ].map, gc, ( int )( BUTTONS[ i ].w - 3 ), ( int )( BUTTONS[ i ].h - 3 ), ( int )( BUTTONS[ i ].w - 3 ), - 4 ); - XDrawLine( dpy, x11_buttons[ i ].map, gc, ( int )( BUTTONS[ i ].w - 4 ), ( int )( BUTTONS[ i ].h - 4 ), ( int )( BUTTONS[ i ].w - 4 ), - 5 ); - - XDrawPoint( dpy, x11_buttons[ i ].map, gc, ( int )( BUTTONS[ i ].w - 5 ), ( int )( BUTTONS[ i ].h - 4 ) ); - - /* - * draw frame around button - */ - XSetForeground( dpy, gc, COLOR( FRAME ) ); - - XDrawLine( dpy, x11_buttons[ i ].map, gc, 0, ( int )( BUTTONS[ i ].h - 3 ), 0, 2 ); - XDrawLine( dpy, x11_buttons[ i ].map, gc, 2, 0, ( int )( BUTTONS[ i ].w - 3 ), 0 ); - XDrawLine( dpy, x11_buttons[ i ].map, gc, 2, ( int )( BUTTONS[ i ].h - 1 ), ( int )( BUTTONS[ i ].w - 3 ), - ( int )( BUTTONS[ i ].h - 1 ) ); - XDrawLine( dpy, x11_buttons[ i ].map, gc, ( int )( BUTTONS[ i ].w - 1 ), ( int )( BUTTONS[ i ].h - 3 ), ( int )( BUTTONS[ i ].w - 1 ), - 2 ); - - if ( i == HPKEY_ON ) { - XDrawLine( dpy, x11_buttons[ i ].map, gc, 1, 1, ( int )( BUTTONS[ i ].w - 2 ), 1 ); - XDrawPoint( dpy, x11_buttons[ i ].map, gc, 1, 2 ); - XDrawPoint( dpy, x11_buttons[ i ].map, gc, ( int )( BUTTONS[ i ].w - 2 ), 2 ); - } else { - XDrawPoint( dpy, x11_buttons[ i ].map, gc, 1, 1 ); - XDrawPoint( dpy, x11_buttons[ i ].map, gc, ( int )( BUTTONS[ i ].w - 2 ), 1 ); - } - XDrawPoint( dpy, x11_buttons[ i ].map, gc, 1, ( int )( BUTTONS[ i ].h - 2 ) ); - XDrawPoint( dpy, x11_buttons[ i ].map, gc, ( int )( BUTTONS[ i ].w - 2 ), ( int )( BUTTONS[ i ].h - 2 ) ); - - /* - * draw the depressed button - */ - x11_buttons[ i ].down = XCreatePixmap( dpy, x11_buttons[ i ].xwin, BUTTONS[ i ].w, BUTTONS[ i ].h, depth ); - - XSetForeground( dpy, gc, pixel ); - XFillRectangle( dpy, x11_buttons[ i ].down, gc, 0, 0, BUTTONS[ i ].w, BUTTONS[ i ].h ); - - XSetForeground( dpy, gc, COLOR( BUTTON ) ); - XFillRectangle( dpy, x11_buttons[ i ].down, gc, 1, 1, BUTTONS[ i ].w - 2, BUTTONS[ i ].h - 2 ); - - if ( BUTTONS[ i ].label != ( char* )0 ) { - /* - * set small or big font in gc - */ - switch ( BUTTONS[ i ].font_size ) { - case 0: - finfo = f_small; - break; - case 1: - finfo = f_big; - break; - case 2: - finfo = f_med; - break; - default: - finfo = f_small; - break; - } - val.font = finfo->fid; - gc_mask = GCFont; - XChangeGC( dpy, gc, gc_mask, &val ); - - /* - * draw string centered in button - */ - XSetBackground( dpy, gc, COLOR( BUTTON ) ); - XSetForeground( dpy, gc, COLOR( BUTTONS[ i ].lc ) ); - - XTextExtents( finfo, BUTTONS[ i ].label, ( int )strlen( BUTTONS[ i ].label ), &dir, &fa, &fd, &xchar ); - x = ( BUTTONS[ i ].w - xchar.width ) / 2; - y = ( 1 + BUTTONS[ i ].h - ( xchar.ascent + xchar.descent ) ) / 2 + xchar.ascent; - XDrawImageString( dpy, x11_buttons[ i ].down, gc, x, y, BUTTONS[ i ].label, ( int )strlen( BUTTONS[ i ].label ) ); - - XSetBackground( dpy, gc, COLOR( BLACK ) ); - } else { - /* - * draw pixmap centered in button - */ - XSetBackground( dpy, gc, COLOR( BUTTON ) ); - XSetForeground( dpy, gc, COLOR( BUTTONS[ i ].lc ) ); - - pix = XCreateBitmapFromData( dpy, x11_buttons[ i ].xwin, ( char* )BUTTONS[ i ].lb, BUTTONS[ i ].lw, BUTTONS[ i ].lh ); - - x = ( 1 + BUTTONS[ i ].w - BUTTONS[ i ].lw ) / 2; - y = ( 1 + BUTTONS[ i ].h - BUTTONS[ i ].lh ) / 2; - - XCopyPlane( dpy, pix, x11_buttons[ i ].down, gc, 0, 0, BUTTONS[ i ].lw, BUTTONS[ i ].lh, x, y, 1 ); - - XFreePixmap( dpy, pix ); - - XSetBackground( dpy, gc, COLOR( BLACK ) ); - } - - /* - * draw edge of button - */ - XSetForeground( dpy, gc, COLOR( BUT_TOP ) ); - - XDrawLine( dpy, x11_buttons[ i ].down, gc, 2, ( int )( BUTTONS[ i ].h - 4 ), 2, 2 ); - XDrawLine( dpy, x11_buttons[ i ].down, gc, 3, ( int )( BUTTONS[ i ].h - 5 ), 3, 3 ); - - XDrawLine( dpy, x11_buttons[ i ].down, gc, 2, 2, ( int )( BUTTONS[ i ].w - 4 ), 2 ); - XDrawLine( dpy, x11_buttons[ i ].down, gc, 3, 3, ( int )( BUTTONS[ i ].w - 5 ), 3 ); - - XDrawPoint( dpy, x11_buttons[ i ].down, gc, 4, 4 ); - - XSetForeground( dpy, gc, COLOR( BUT_BOT ) ); - - XDrawLine( dpy, x11_buttons[ i ].down, gc, 3, ( int )( BUTTONS[ i ].h - 3 ), ( int )( BUTTONS[ i ].w - 3 ), - ( int )( BUTTONS[ i ].h - 3 ) ); - XDrawLine( dpy, x11_buttons[ i ].down, gc, 4, ( int )( BUTTONS[ i ].h - 4 ), ( int )( BUTTONS[ i ].w - 4 ), - ( int )( BUTTONS[ i ].h - 4 ) ); - - XDrawLine( dpy, x11_buttons[ i ].down, gc, ( int )( BUTTONS[ i ].w - 3 ), ( int )( BUTTONS[ i ].h - 3 ), ( int )( BUTTONS[ i ].w - 3 ), - 3 ); - XDrawLine( dpy, x11_buttons[ i ].down, gc, ( int )( BUTTONS[ i ].w - 4 ), ( int )( BUTTONS[ i ].h - 4 ), ( int )( BUTTONS[ i ].w - 4 ), - 4 ); - - XDrawPoint( dpy, x11_buttons[ i ].down, gc, ( int )( BUTTONS[ i ].w - 5 ), ( int )( BUTTONS[ i ].h - 5 ) ); - - /* - * draw frame around button - */ - XSetForeground( dpy, gc, COLOR( FRAME ) ); - - XDrawLine( dpy, x11_buttons[ i ].down, gc, 0, ( int )( BUTTONS[ i ].h - 3 ), 0, 2 ); - XDrawLine( dpy, x11_buttons[ i ].down, gc, 2, 0, ( int )( BUTTONS[ i ].w - 3 ), 0 ); - XDrawLine( dpy, x11_buttons[ i ].down, gc, 2, ( int )( BUTTONS[ i ].h - 1 ), ( int )( BUTTONS[ i ].w - 3 ), - ( int )( BUTTONS[ i ].h - 1 ) ); - XDrawLine( dpy, x11_buttons[ i ].down, gc, ( int )( BUTTONS[ i ].w - 1 ), ( int )( BUTTONS[ i ].h - 3 ), ( int )( BUTTONS[ i ].w - 1 ), - 2 ); - - if ( i == HPKEY_ON ) { - XDrawLine( dpy, x11_buttons[ i ].down, gc, 1, 1, ( int )( BUTTONS[ i ].w - 2 ), 1 ); - XDrawPoint( dpy, x11_buttons[ i ].down, gc, 1, 2 ); - XDrawPoint( dpy, x11_buttons[ i ].down, gc, ( int )( BUTTONS[ i ].w - 2 ), 2 ); - } else { - XDrawPoint( dpy, x11_buttons[ i ].down, gc, 1, 1 ); - XDrawPoint( dpy, x11_buttons[ i ].down, gc, ( int )( BUTTONS[ i ].w - 2 ), 1 ); - } - XDrawPoint( dpy, x11_buttons[ i ].down, gc, 1, ( int )( BUTTONS[ i ].h - 2 ) ); - XDrawPoint( dpy, x11_buttons[ i ].down, gc, ( int )( BUTTONS[ i ].w - 2 ), ( int )( BUTTONS[ i ].h - 2 ) ); - - if ( i == HPKEY_ON ) { - XDrawRectangle( dpy, x11_buttons[ i ].down, gc, 1, 2, BUTTONS[ i ].w - 3, BUTTONS[ i ].h - 4 ); - XDrawPoint( dpy, x11_buttons[ i ].down, gc, 2, 3 ); - XDrawPoint( dpy, x11_buttons[ i ].down, gc, ( int )( BUTTONS[ i ].w - 3 ), 3 ); - } else { - XDrawRectangle( dpy, x11_buttons[ i ].down, gc, 1, 1, BUTTONS[ i ].w - 3, BUTTONS[ i ].h - 3 ); - XDrawPoint( dpy, x11_buttons[ i ].down, gc, 2, 2 ); - XDrawPoint( dpy, x11_buttons[ i ].down, gc, ( int )( BUTTONS[ i ].w - 3 ), 2 ); - } - XDrawPoint( dpy, x11_buttons[ i ].down, gc, 2, ( int )( BUTTONS[ i ].h - 3 ) ); - XDrawPoint( dpy, x11_buttons[ i ].down, gc, ( int )( BUTTONS[ i ].w - 3 ), ( int )( BUTTONS[ i ].h - 3 ) ); -} - -static inline void __create_keypad( unsigned int offset_y, unsigned int offset_x, x11_keypad_t* local_keypad ) -{ - int i, x, y; - int wl, wr, ws; - Pixmap pix; - unsigned long pixel; - unsigned int pw, ph; - XFontStruct *f_small, *f_med, *f_big; - - f_small = load_x11_font( dpy, config.smallFont ); - f_med = load_x11_font( dpy, config.mediumFont ); - f_big = load_x11_font( dpy, config.largeFont ); - - /* - * draw the character labels - */ - for ( i = FIRST_HPKEY; i <= LAST_HPKEY; i++ ) { - __create_button( i, offset_x, offset_y, f_small, f_med, f_big ); - - pixel = ( i < HPKEY_MTH ) ? COLOR( DISP_PAD ) : COLOR( PAD ); - - if ( BUTTONS[ i ].letter != ( char* )0 ) { - XSetBackground( dpy, gc, pixel ); - XSetForeground( dpy, gc, COLOR( WHITE ) ); - - if ( opt_gx ) { - x = offset_x + BUTTONS[ i ].x + BUTTONS[ i ].w + 3; - y = offset_y + BUTTONS[ i ].y + BUTTONS[ i ].h + 1; - } else { - x = offset_x + BUTTONS[ i ].x + BUTTONS[ i ].w - SmallTextWidth( BUTTONS[ i ].letter, 1 ) / 2 + 5; - y = offset_y + BUTTONS[ i ].y + BUTTONS[ i ].h - 2; - } - - __write_text( dpy, local_keypad->pixmap, gc, x, y, BUTTONS[ i ].letter, 1 ); - } - - /* - * draw the bottom labels - */ - if ( BUTTONS[ i ].sub != ( char* )0 ) { - XSetBackground( dpy, gc, pixel ); - XSetForeground( dpy, gc, COLOR( WHITE ) ); - - x = offset_x + BUTTONS[ i ].x + ( 1 + BUTTONS[ i ].w - SmallTextWidth( BUTTONS[ i ].sub, strlen( BUTTONS[ i ].sub ) ) ) / 2; - y = offset_y + BUTTONS[ i ].y + BUTTONS[ i ].h + small_ascent + 2; - - __write_text( dpy, local_keypad->pixmap, gc, x, y, BUTTONS[ i ].sub, strlen( BUTTONS[ i ].sub ) ); - } - - /* - * draw the left labels - */ - if ( BUTTONS[ i ].left != ( char* )0 ) { - if ( BUTTONS[ i ].is_menu ) { - /* - * draw the dark shade under the label - */ - if ( opt_gx ) { - pw = 58; - ph = 48; - } else { - pw = 46; - ph = 11; - } - - pix = XCreatePixmap( dpy, local_keypad->pixmap, pw, ph, depth ); - - XSetForeground( dpy, gc, COLOR( UNDERLAY ) ); - - XFillRectangle( dpy, pix, gc, 0, 0, pw, ph ); - - XSetBackground( dpy, gc, COLOR( UNDERLAY ) ); - XSetForeground( dpy, gc, COLOR( LEFT ) ); - - x = ( pw + 1 - SmallTextWidth( BUTTONS[ i ].left, strlen( BUTTONS[ i ].left ) ) ) / 2; - y = ( opt_gx ) ? 14 : 9; - - __write_text( dpy, pix, gc, x, y, BUTTONS[ i ].left, strlen( BUTTONS[ i ].left ) ); - - XSetForeground( dpy, gc, pixel ); - - if ( !opt_gx ) { - XDrawPoint( dpy, pix, gc, 0, 0 ); - XDrawPoint( dpy, pix, gc, 0, ph - 1 ); - XDrawPoint( dpy, pix, gc, pw - 1, 0 ); - XDrawPoint( dpy, pix, gc, pw - 1, ph - 1 ); - } - - if ( opt_gx ) { - x = offset_x + BUTTONS[ i ].x - 6; - y = offset_y + BUTTONS[ i ].y - small_ascent - small_descent - 6; - } else { - x = offset_x + BUTTONS[ i ].x + ( BUTTONS[ i ].w - pw ) / 2; - y = offset_y + BUTTONS[ i ].y - small_ascent - small_descent; - } - - XCopyArea( dpy, pix, local_keypad->pixmap, gc, 0, 0, pw, ph, x, y ); - - XFreePixmap( dpy, pix ); - } else { - XSetBackground( dpy, gc, pixel ); - XSetForeground( dpy, gc, COLOR( LEFT ) ); - - if ( BUTTONS[ i ].right == ( char* )0 ) /* centered label */ - x = offset_x + BUTTONS[ i ].x + - ( 1 + BUTTONS[ i ].w - SmallTextWidth( BUTTONS[ i ].left, strlen( BUTTONS[ i ].left ) ) ) / 2; - else { /* label to the left */ - wl = SmallTextWidth( BUTTONS[ i ].left, strlen( BUTTONS[ i ].left ) ); - wr = SmallTextWidth( BUTTONS[ i ].right, strlen( BUTTONS[ i ].right ) ); - ws = SmallTextWidth( " ", 1 ); - - x = offset_x + BUTTONS[ i ].x + ( 1 + BUTTONS[ i ].w - ( wl + wr + ws ) ) / 2; - } - - y = offset_y + BUTTONS[ i ].y - small_descent; - - __write_text( dpy, local_keypad->pixmap, gc, x, y, BUTTONS[ i ].left, strlen( BUTTONS[ i ].left ) ); - } - } - - /* - * draw the right labels - */ - if ( BUTTONS[ i ].right != ( char* )0 ) { - if ( BUTTONS[ i ].is_menu ) { - /* - * draw the dark shade under the label - */ - if ( opt_gx ) { - pw = 58; - ph = 48; - } else { - pw = 44; - ph = 9; - } - - pix = XCreatePixmap( dpy, local_keypad->pixmap, pw, ph, depth ); - - XSetForeground( dpy, gc, COLOR( UNDERLAY ) ); - - XFillRectangle( dpy, pix, gc, 0, 0, pw, ph ); - - XSetBackground( dpy, gc, COLOR( UNDERLAY ) ); - XSetForeground( dpy, gc, COLOR( RIGHT ) ); - - x = ( pw + 1 - SmallTextWidth( BUTTONS[ i ].right, strlen( BUTTONS[ i ].right ) ) ) / 2; - y = ( opt_gx ) ? 14 : 8; - - __write_text( dpy, pix, gc, x, y, BUTTONS[ i ].right, strlen( BUTTONS[ i ].right ) ); - - XSetForeground( dpy, gc, pixel ); - - if ( !opt_gx ) { - XDrawPoint( dpy, pix, gc, 0, 0 ); - XDrawPoint( dpy, pix, gc, 0, ph - 1 ); - XDrawPoint( dpy, pix, gc, pw - 1, 0 ); - XDrawPoint( dpy, pix, gc, pw - 1, ph - 1 ); - } - - if ( opt_gx ) { - x = offset_x + BUTTONS[ i ].x - 6; - y = offset_y + BUTTONS[ i ].y - small_ascent - small_descent - 6; - } else { - x = offset_x + BUTTONS[ i ].x + ( BUTTONS[ i ].w - pw ) / 2; - y = offset_y + BUTTONS[ i ].y - small_ascent - small_descent; - } - - XCopyArea( dpy, pix, local_keypad->pixmap, gc, 0, 0, pw, ph, x, y ); - - XFreePixmap( dpy, pix ); - } else { - XSetBackground( dpy, gc, pixel ); - XSetForeground( dpy, gc, COLOR( RIGHT ) ); - - if ( BUTTONS[ i ].left == ( char* )0 ) /* centered label */ - x = offset_x + BUTTONS[ i ].x + - ( 1 + BUTTONS[ i ].w - SmallTextWidth( BUTTONS[ i ].right, strlen( BUTTONS[ i ].right ) ) ) / 2; - else { /* label to the right */ - wl = SmallTextWidth( BUTTONS[ i ].left, strlen( BUTTONS[ i ].left ) ); - wr = SmallTextWidth( BUTTONS[ i ].right, strlen( BUTTONS[ i ].right ) ); - ws = SmallTextWidth( " ", 1 ); - - x = offset_x + BUTTONS[ i ].x + ( 1 + BUTTONS[ i ].w - ( wl + wr + ws ) ) / 2 + wl + ws; - } - - y = offset_y + BUTTONS[ i ].y - small_descent; - - __write_text( dpy, local_keypad->pixmap, gc, x, y, BUTTONS[ i ].right, strlen( BUTTONS[ i ].right ) ); - } - } - } - - XFreeFont( dpy, f_big ); - XFreeFont( dpy, f_med ); - XFreeFont( dpy, f_small ); - - /* - * at last draw the v--- LAST ---v thing - */ - - if ( !opt_gx ) { - XSetBackground( dpy, gc, COLOR( PAD ) ); - XSetForeground( dpy, gc, COLOR( WHITE ) ); - - pix = XCreateBitmapFromData( dpy, local_keypad->pixmap, ( char* )last_bitmap, last_width, last_height ); - - x = offset_x + BUTTONS[ HPKEY_1 ].x + BUTTONS[ HPKEY_1 ].w + - ( BUTTONS[ HPKEY_2 ].x - BUTTONS[ HPKEY_1 ].x - BUTTONS[ HPKEY_1 ].w ) / 2; - y = offset_y + BUTTONS[ HPKEY_5 ].y + BUTTONS[ HPKEY_5 ].h + 2; - - XCopyPlane( dpy, pix, local_keypad->pixmap, gc, 0, 0, last_width, last_height, x, y, 1 ); - - XFreePixmap( dpy, pix ); - } -} - -static inline void _draw_bezel_LCD( x11_keypad_t* local_keypad ) -{ - int i; - - /* - * draw the frame around the display - */ - XSetForeground( dpy, gc, COLOR( DISP_PAD_TOP ) ); - - for ( i = 0; i < DISP_FRAME; i++ ) { - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )( DISPLAY_OFFSET_X - i ), ( int )( DISPLAY_OFFSET_Y + DISPLAY_HEIGHT + 2 * i ), - ( int )( DISPLAY_OFFSET_X + DISPLAY_WIDTH + i ), ( int )( DISPLAY_OFFSET_Y + DISPLAY_HEIGHT + 2 * i ) ); - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )( DISPLAY_OFFSET_X - i ), ( int )( DISPLAY_OFFSET_Y + DISPLAY_HEIGHT + 2 * i + 1 ), - ( int )( DISPLAY_OFFSET_X + DISPLAY_WIDTH + i ), ( int )( DISPLAY_OFFSET_Y + DISPLAY_HEIGHT + 2 * i + 1 ) ); - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )( DISPLAY_OFFSET_X + DISPLAY_WIDTH + i ), ( int )( DISPLAY_OFFSET_Y - i ), - ( int )( DISPLAY_OFFSET_X + DISPLAY_WIDTH + i ), ( int )( DISPLAY_OFFSET_Y + DISPLAY_HEIGHT + 2 * i ) ); - } - - XSetForeground( dpy, gc, COLOR( DISP_PAD_BOT ) ); - - for ( i = 0; i < DISP_FRAME; i++ ) { - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )( DISPLAY_OFFSET_X - i - 1 ), ( int )( DISPLAY_OFFSET_Y - i - 1 ), - ( int )( DISPLAY_OFFSET_X + DISPLAY_WIDTH + i - 1 ), ( int )( DISPLAY_OFFSET_Y - i - 1 ) ); - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )( DISPLAY_OFFSET_X - i - 1 ), ( int )( DISPLAY_OFFSET_Y - i - 1 ), - ( int )( DISPLAY_OFFSET_X - i - 1 ), ( int )( DISPLAY_OFFSET_Y + DISPLAY_HEIGHT + 2 * i - 1 ) ); - } - - /* - * round off corners - */ - XSetForeground( dpy, gc, COLOR( DISP_PAD ) ); - - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )( DISPLAY_OFFSET_X - DISP_FRAME ), ( int )( DISPLAY_OFFSET_Y - DISP_FRAME ), - ( int )( DISPLAY_OFFSET_X - DISP_FRAME + 3 ), ( int )( DISPLAY_OFFSET_Y - DISP_FRAME ) ); - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )( DISPLAY_OFFSET_X - DISP_FRAME ), ( int )( DISPLAY_OFFSET_Y - DISP_FRAME ), - ( int )( DISPLAY_OFFSET_X - DISP_FRAME ), ( int )( DISPLAY_OFFSET_Y - DISP_FRAME + 3 ) ); - XDrawPoint( dpy, local_keypad->pixmap, gc, ( int )( DISPLAY_OFFSET_X - DISP_FRAME + 1 ), ( int )( DISPLAY_OFFSET_Y - DISP_FRAME + 1 ) ); - - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )( DISPLAY_OFFSET_X + DISPLAY_WIDTH + DISP_FRAME - 4 ), - ( int )( DISPLAY_OFFSET_Y - DISP_FRAME ), ( int )( DISPLAY_OFFSET_X + DISPLAY_WIDTH + DISP_FRAME - 1 ), - ( int )( DISPLAY_OFFSET_Y - DISP_FRAME ) ); - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )( DISPLAY_OFFSET_X + DISPLAY_WIDTH + DISP_FRAME - 1 ), - ( int )( DISPLAY_OFFSET_Y - DISP_FRAME ), ( int )( DISPLAY_OFFSET_X + DISPLAY_WIDTH + DISP_FRAME - 1 ), - ( int )( DISPLAY_OFFSET_Y - DISP_FRAME + 3 ) ); - XDrawPoint( dpy, local_keypad->pixmap, gc, ( int )( DISPLAY_OFFSET_X + DISPLAY_WIDTH + DISP_FRAME - 2 ), - ( int )( DISPLAY_OFFSET_Y - DISP_FRAME + 1 ) ); - - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )( DISPLAY_OFFSET_X - DISP_FRAME ), - ( int )( DISPLAY_OFFSET_Y + DISPLAY_HEIGHT + 2 * DISP_FRAME - 4 ), ( int )( DISPLAY_OFFSET_X - DISP_FRAME ), - ( int )( DISPLAY_OFFSET_Y + DISPLAY_HEIGHT + 2 * DISP_FRAME - 1 ) ); - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )( DISPLAY_OFFSET_X - DISP_FRAME ), - ( int )( DISPLAY_OFFSET_Y + DISPLAY_HEIGHT + 2 * DISP_FRAME - 1 ), ( int )( DISPLAY_OFFSET_X - DISP_FRAME + 3 ), - ( int )( DISPLAY_OFFSET_Y + DISPLAY_HEIGHT + 2 * DISP_FRAME - 1 ) ); - XDrawPoint( dpy, local_keypad->pixmap, gc, ( int )( DISPLAY_OFFSET_X - DISP_FRAME + 1 ), - ( int )( DISPLAY_OFFSET_Y + DISPLAY_HEIGHT + 2 * DISP_FRAME - 2 ) ); - - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )( DISPLAY_OFFSET_X + DISPLAY_WIDTH + DISP_FRAME - 1 ), - ( int )( DISPLAY_OFFSET_Y + DISPLAY_HEIGHT + 2 * DISP_FRAME - 4 ), - ( int )( DISPLAY_OFFSET_X + DISPLAY_WIDTH + DISP_FRAME - 1 ), - ( int )( DISPLAY_OFFSET_Y + DISPLAY_HEIGHT + 2 * DISP_FRAME - 1 ) ); - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )( DISPLAY_OFFSET_X + DISPLAY_WIDTH + DISP_FRAME - 4 ), - ( int )( DISPLAY_OFFSET_Y + DISPLAY_HEIGHT + 2 * DISP_FRAME - 1 ), - ( int )( DISPLAY_OFFSET_X + DISPLAY_WIDTH + DISP_FRAME - 1 ), - ( int )( DISPLAY_OFFSET_Y + DISPLAY_HEIGHT + 2 * DISP_FRAME - 1 ) ); - XDrawPoint( dpy, local_keypad->pixmap, gc, ( int )( DISPLAY_OFFSET_X + DISPLAY_WIDTH + DISP_FRAME - 2 ), - ( int )( DISPLAY_OFFSET_Y + DISPLAY_HEIGHT + 2 * DISP_FRAME - 2 ) ); - - /* - * simulate rounded lcd corners - */ - XSetForeground( dpy, gc, COLOR( LCD ) ); - - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )( DISPLAY_OFFSET_X - 1 ), ( int )( DISPLAY_OFFSET_Y + 1 ), - ( int )( DISPLAY_OFFSET_X - 1 ), ( int )( DISPLAY_OFFSET_Y + DISPLAY_HEIGHT - 2 ) ); - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )( DISPLAY_OFFSET_X + 1 ), ( int )( DISPLAY_OFFSET_Y - 1 ), - ( int )( DISPLAY_OFFSET_X + DISPLAY_WIDTH - 2 ), ( int )( DISPLAY_OFFSET_Y - 1 ) ); - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )( DISPLAY_OFFSET_X + 1 ), ( int )( DISPLAY_OFFSET_Y + DISPLAY_HEIGHT ), - ( int )( DISPLAY_OFFSET_X + DISPLAY_WIDTH - 2 ), ( int )( DISPLAY_OFFSET_Y + DISPLAY_HEIGHT ) ); - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )( DISPLAY_OFFSET_X + DISPLAY_WIDTH ), ( int )( DISPLAY_OFFSET_Y + 1 ), - ( int )( DISPLAY_OFFSET_X + DISPLAY_WIDTH ), ( int )( DISPLAY_OFFSET_Y + DISPLAY_HEIGHT - 2 ) ); -} - -static inline void _draw_bezel( unsigned int offset_y, x11_keypad_t* local_keypad ) -{ - Pixmap pix; - int cut = 0; - int x, y; - - /* - * lower the whole thing - */ - XSetForeground( dpy, gc, COLOR( PAD_TOP ) ); - - /* bottom lines */ - XDrawLine( dpy, local_keypad->pixmap, gc, 1, ( int )( local_keypad->height - 1 ), ( int )( local_keypad->width - 1 ), - ( int )( local_keypad->height - 1 ) ); - XDrawLine( dpy, local_keypad->pixmap, gc, 2, ( int )( local_keypad->height - 2 ), ( int )( local_keypad->width - 2 ), - ( int )( local_keypad->height - 2 ) ); - - /* right lines */ - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )( local_keypad->width - 1 ), ( int )( local_keypad->height - 1 ), - ( int )( local_keypad->width - 1 ), cut ); - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )( local_keypad->width - 2 ), ( int )( local_keypad->height - 2 ), - ( int )( local_keypad->width - 2 ), cut ); - - XSetForeground( dpy, gc, COLOR( DISP_PAD_TOP ) ); - - /* right lines */ - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )( local_keypad->width - 1 ), cut - 1, ( int )( local_keypad->width - 1 ), 1 ); - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )( local_keypad->width - 2 ), cut - 1, ( int )( local_keypad->width - 2 ), 2 ); - - XSetForeground( dpy, gc, COLOR( DISP_PAD_BOT ) ); - - /* top lines */ - XDrawLine( dpy, local_keypad->pixmap, gc, 0, 0, ( int )( local_keypad->width - 2 ), 0 ); - XDrawLine( dpy, local_keypad->pixmap, gc, 1, 1, ( int )( local_keypad->width - 3 ), 1 ); - - /* left lines */ - XDrawLine( dpy, local_keypad->pixmap, gc, 0, cut - 1, 0, 0 ); - XDrawLine( dpy, local_keypad->pixmap, gc, 1, cut - 1, 1, 1 ); - - XSetForeground( dpy, gc, COLOR( PAD_BOT ) ); - - /* left lines */ - XDrawLine( dpy, local_keypad->pixmap, gc, 0, ( int )( local_keypad->height - 2 ), 0, cut ); - XDrawLine( dpy, local_keypad->pixmap, gc, 1, ( int )( local_keypad->height - 3 ), 1, cut ); - - /* - * lower the menu BUTTONS - */ - XSetForeground( dpy, gc, COLOR( PAD_TOP ) ); - - /* bottom lines */ - XDrawLine( dpy, local_keypad->pixmap, gc, 3, ( int )( local_keypad->height - 3 ), ( int )( local_keypad->width - 3 ), - ( int )( local_keypad->height - 3 ) ); - XDrawLine( dpy, local_keypad->pixmap, gc, 4, ( int )( local_keypad->height - 4 ), ( int )( local_keypad->width - 4 ), - ( int )( local_keypad->height - 4 ) ); - - /* right lines */ - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )( local_keypad->width - 3 ), ( int )( local_keypad->height - 3 ), - ( int )( local_keypad->width - 3 ), cut ); - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )( local_keypad->width - 4 ), ( int )( local_keypad->height - 4 ), - ( int )( local_keypad->width - 4 ), cut ); - - XSetForeground( dpy, gc, COLOR( DISP_PAD_TOP ) ); - - /* right lines */ - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )( local_keypad->width - 3 ), cut - 1, ( int )( local_keypad->width - 3 ), - offset_y - 24 ); - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )( local_keypad->width - 4 ), cut - 1, ( int )( local_keypad->width - 4 ), - offset_y - 23 ); - - XSetForeground( dpy, gc, COLOR( DISP_PAD_BOT ) ); - - /* top lines */ - XDrawLine( dpy, local_keypad->pixmap, gc, 2, offset_y - 25, ( int )( local_keypad->width - 4 ), offset_y - 25 ); - XDrawLine( dpy, local_keypad->pixmap, gc, 3, offset_y - 24, ( int )( local_keypad->width - 5 ), offset_y - 24 ); - - /* left lines */ - XDrawLine( dpy, local_keypad->pixmap, gc, 2, cut - 1, 2, offset_y - 24 ); - XDrawLine( dpy, local_keypad->pixmap, gc, 3, cut - 1, 3, offset_y - 23 ); - - XSetForeground( dpy, gc, COLOR( PAD_BOT ) ); - - /* left lines */ - XDrawLine( dpy, local_keypad->pixmap, gc, 2, ( int )( local_keypad->height - 4 ), 2, cut ); - XDrawLine( dpy, local_keypad->pixmap, gc, 3, ( int )( local_keypad->height - 5 ), 3, cut ); - - /* - * lower the keyboard - */ - XSetForeground( dpy, gc, COLOR( PAD_TOP ) ); - - /* bottom lines */ - XDrawLine( dpy, local_keypad->pixmap, gc, 5, ( int )( local_keypad->height - 5 ), ( int )( local_keypad->width - 3 ), - ( int )( local_keypad->height - 5 ) ); - XDrawLine( dpy, local_keypad->pixmap, gc, 6, ( int )( local_keypad->height - 6 ), ( int )( local_keypad->width - 4 ), - ( int )( local_keypad->height - 6 ) ); - - /* right lines */ - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )( local_keypad->width - 5 ), ( int )( local_keypad->height - 5 ), - ( int )( local_keypad->width - 5 ), cut + 1 ); - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )( local_keypad->width - 6 ), ( int )( local_keypad->height - 6 ), - ( int )( local_keypad->width - 6 ), cut + 2 ); - - XSetForeground( dpy, gc, COLOR( DISP_PAD_BOT ) ); - - /* top lines */ - XDrawLine( dpy, local_keypad->pixmap, gc, 4, cut, ( int )( local_keypad->width - 6 ), cut ); - XDrawLine( dpy, local_keypad->pixmap, gc, 5, cut + 1, ( int )( local_keypad->width - 7 ), cut + 1 ); - - XSetForeground( dpy, gc, COLOR( PAD_BOT ) ); - - /* left lines */ - XDrawLine( dpy, local_keypad->pixmap, gc, 4, ( int )( local_keypad->height - 6 ), 4, cut + 1 ); - XDrawLine( dpy, local_keypad->pixmap, gc, 5, ( int )( local_keypad->height - 7 ), 5, cut + 2 ); - - /* - * round off the bottom edge - */ - XSetForeground( dpy, gc, COLOR( PAD_TOP ) ); - - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )( local_keypad->width - 7 ), ( int )( local_keypad->height - 7 ), - ( int )( local_keypad->width - 7 ), ( int )( local_keypad->height - 14 ) ); - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )( local_keypad->width - 8 ), ( int )( local_keypad->height - 8 ), - ( int )( local_keypad->width - 8 ), ( int )( local_keypad->height - 11 ) ); - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )( local_keypad->width - 7 ), ( int )( local_keypad->height - 7 ), - ( int )( local_keypad->width - 14 ), ( int )( local_keypad->height - 7 ) ); - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )( local_keypad->width - 7 ), ( int )( local_keypad->height - 8 ), - ( int )( local_keypad->width - 11 ), ( int )( local_keypad->height - 8 ) ); - XDrawPoint( dpy, local_keypad->pixmap, gc, ( int )( local_keypad->width - 9 ), ( int )( local_keypad->height - 9 ) ); - - XDrawLine( dpy, local_keypad->pixmap, gc, 7, ( int )( local_keypad->height - 7 ), 13, ( int )( local_keypad->height - 7 ) ); - XDrawLine( dpy, local_keypad->pixmap, gc, 8, ( int )( local_keypad->height - 8 ), 10, ( int )( local_keypad->height - 8 ) ); - XSetForeground( dpy, gc, COLOR( PAD_BOT ) ); - XDrawLine( dpy, local_keypad->pixmap, gc, 6, ( int )( local_keypad->height - 8 ), 6, ( int )( local_keypad->height - 14 ) ); - XDrawLine( dpy, local_keypad->pixmap, gc, 7, ( int )( local_keypad->height - 9 ), 7, ( int )( local_keypad->height - 11 ) ); - - /* - * insert the HP Logo - */ - - XSetBackground( dpy, gc, COLOR( LOGO_BACK ) ); - XSetForeground( dpy, gc, COLOR( LOGO ) ); - - pix = XCreateBitmapFromData( dpy, local_keypad->pixmap, ( char* )hp_bitmap, hp_width, hp_height ); - - x = opt_gx ? DISPLAY_OFFSET_X - 6 : DISPLAY_OFFSET_X; - - XCopyPlane( dpy, pix, local_keypad->pixmap, gc, 0, 0, hp_width, hp_height, x, 10, 1 ); - - XFreePixmap( dpy, pix ); - - if ( !opt_gx ) { - XSetForeground( dpy, gc, COLOR( FRAME ) ); - - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )DISPLAY_OFFSET_X, 9, ( int )( DISPLAY_OFFSET_X + hp_width - 1 ), 9 ); - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )( DISPLAY_OFFSET_X - 1 ), 10, ( int )( DISPLAY_OFFSET_X - 1 ), - 10 + hp_height - 1 ); - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )DISPLAY_OFFSET_X, 10 + hp_height, ( int )( DISPLAY_OFFSET_X + hp_width - 1 ), - 10 + hp_height ); - XDrawLine( dpy, local_keypad->pixmap, gc, ( int )( DISPLAY_OFFSET_X + hp_width ), 10, ( int )( DISPLAY_OFFSET_X + hp_width ), - 10 + hp_height - 1 ); - } - - /* - * write the name of it - */ - XSetBackground( dpy, gc, COLOR( DISP_PAD ) ); - XSetForeground( dpy, gc, COLOR( LABEL ) ); - - if ( opt_gx ) { - x = DISPLAY_OFFSET_X + DISPLAY_WIDTH - gx_128K_ram_width + gx_128K_ram_x_hot + 2; - y = 10 + gx_128K_ram_y_hot; - pix = XCreateBitmapFromData( dpy, local_keypad->pixmap, ( char* )gx_128K_ram_bitmap, gx_128K_ram_width, gx_128K_ram_height ); - XCopyPlane( dpy, pix, local_keypad->pixmap, gc, 0, 0, gx_128K_ram_width, gx_128K_ram_height, x, y, 1 ); - XFreePixmap( dpy, pix ); - - XSetForeground( dpy, gc, COLOR( LOGO ) ); - x = DISPLAY_OFFSET_X + hp_width; - y = hp_height + 8 - hp48gx_height; - pix = XCreateBitmapFromData( dpy, local_keypad->pixmap, ( char* )hp48gx_bitmap, hp48gx_width, hp48gx_height ); - XCopyPlane( dpy, pix, local_keypad->pixmap, gc, 0, 0, hp48gx_width, hp48gx_height, x, y, 1 ); - XFreePixmap( dpy, pix ); - - XSetFillStyle( dpy, gc, FillStippled ); - x = DISPLAY_OFFSET_X + DISPLAY_WIDTH - gx_128K_ram_width + gx_silver_x_hot + 2; - y = 10 + gx_silver_y_hot; - pix = XCreateBitmapFromData( dpy, local_keypad->pixmap, ( char* )gx_silver_bitmap, gx_silver_width, gx_silver_height ); - XSetStipple( dpy, gc, pix ); - XSetTSOrigin( dpy, gc, x, y ); - XFillRectangle( dpy, local_keypad->pixmap, gc, x, y, gx_silver_width, gx_silver_height ); - XFreePixmap( dpy, pix ); - - XSetForeground( dpy, gc, COLOR( RIGHT ) ); - x = DISPLAY_OFFSET_X + DISPLAY_WIDTH - gx_128K_ram_width + gx_green_x_hot + 2; - y = 10 + gx_green_y_hot; - pix = XCreateBitmapFromData( dpy, local_keypad->pixmap, ( char* )gx_green_bitmap, gx_green_width, gx_green_height ); - XSetStipple( dpy, gc, pix ); - XSetTSOrigin( dpy, gc, x, y ); - XFillRectangle( dpy, local_keypad->pixmap, gc, x, y, gx_green_width, gx_green_height ); - XFreePixmap( dpy, pix ); - - XSetTSOrigin( dpy, gc, 0, 0 ); - XSetFillStyle( dpy, gc, FillSolid ); - } else { - x = DISPLAY_OFFSET_X; - y = TOP_SKIP - DISP_FRAME - hp48sx_height - 3; - - pix = XCreateBitmapFromData( dpy, local_keypad->pixmap, ( char* )hp48sx_bitmap, hp48sx_width, hp48sx_height ); - - XCopyPlane( dpy, pix, local_keypad->pixmap, gc, 0, 0, hp48sx_width, hp48sx_height, x, y, 1 ); - - XFreePixmap( dpy, pix ); - - x = DISPLAY_OFFSET_X + DISPLAY_WIDTH - 1 - science_width; - y = TOP_SKIP - DISP_FRAME - science_height - 4; - - pix = XCreateBitmapFromData( dpy, local_keypad->pixmap, ( char* )science_bitmap, science_width, science_height ); - - XCopyPlane( dpy, pix, local_keypad->pixmap, gc, 0, 0, science_width, science_height, x, y, 1 ); - } -} - -static void draw_keypad( void ) { XCopyArea( dpy, keypad.pixmap, mainW, gc, 0, 0, keypad.width, keypad.height, 0, 0 ); } - -static inline void draw_button( int i ) -{ - XCopyArea( dpy, ( keyboard[ i ].pressed ) ? x11_buttons[ i ].down : x11_buttons[ i ].map, x11_buttons[ i ].xwin, gc, 0, 0, - BUTTONS[ i ].w, BUTTONS[ i ].h, 0, 0 ); -} - -static inline void _create_icon( void ) -{ - XSetWindowAttributes xswa; - XWindowAttributes xwa; - Pixmap tmp_pix; - int p; - - XGetWindowAttributes( dpy, iconW, &xwa ); - xswa.event_mask = xwa.your_event_mask | ExposureMask; - xswa.backing_store = Always; - XChangeWindowAttributes( dpy, iconW, CWEventMask | CWBackingStore, &xswa ); - - icon_pix = XCreatePixmap( dpy, iconW, hp48_icon_width, hp48_icon_height, depth ); - - /* - * draw the icon pixmap - */ - if ( icon_color_mode == COLOR_MODE_MONO ) { - tmp_pix = - XCreateBitmapFromData( dpy, iconW, ( char* )icon_maps[ ICON_MAP ].bits, icon_maps[ ICON_MAP ].w, icon_maps[ ICON_MAP ].h ); - XSetForeground( dpy, gc, COLOR( BLACK ) ); - XSetBackground( dpy, gc, COLOR( WHITE ) ); - XCopyPlane( dpy, tmp_pix, icon_pix, gc, 0, 0, icon_maps[ ICON_MAP ].w, icon_maps[ ICON_MAP ].h, 0, 0, 1 ); - XFreePixmap( dpy, tmp_pix ); - } else { - XSetFillStyle( dpy, gc, FillStippled ); - for ( p = FIRST_MAP; p <= LAST_MAP; p++ ) { - tmp_pix = XCreateBitmapFromData( dpy, iconW, ( char* )icon_maps[ p ].bits, icon_maps[ p ].w, icon_maps[ p ].h ); - XSetStipple( dpy, gc, tmp_pix ); - XSetForeground( dpy, gc, COLOR( icon_maps[ p ].c ) ); - XFillRectangle( dpy, icon_pix, gc, 0, 0, icon_maps[ p ].w, icon_maps[ p ].h ); - XFreePixmap( dpy, tmp_pix ); - } - XSetFillStyle( dpy, gc, FillSolid ); - - /* - * draw frame around icon - */ - XSetForeground( dpy, gc, COLOR( BLACK ) ); - XDrawRectangle( dpy, icon_pix, gc, 0, 0, icon_maps[ ICON_MAP ].w - 1, icon_maps[ ICON_MAP ].h - 1 ); - } - - /* - * draw the display - */ - XSetFillStyle( dpy, gc, FillStippled ); - icon_disp_pix = - XCreateBitmapFromData( dpy, iconW, ( char* )icon_maps[ DISP_MAP ].bits, icon_maps[ DISP_MAP ].w, icon_maps[ DISP_MAP ].h ); - XSetStipple( dpy, gc, icon_disp_pix ); - if ( icon_color_mode == COLOR_MODE_MONO ) - XSetForeground( dpy, gc, COLOR( WHITE ) ); - else - XSetForeground( dpy, gc, COLOR( icon_maps[ DISP_MAP ].c ) ); - XFillRectangle( dpy, icon_pix, gc, 0, 0, icon_maps[ DISP_MAP ].w, icon_maps[ DISP_MAP ].h ); - - /* - * draw the 'x48' string - */ - icon_text_pix = XCreateBitmapFromData( dpy, iconW, ( char* )icon_maps[ ON_MAP ].bits, icon_maps[ ON_MAP ].w, icon_maps[ ON_MAP ].h ); - XSetStipple( dpy, gc, icon_text_pix ); - if ( icon_color_mode == COLOR_MODE_MONO ) - XSetForeground( dpy, gc, COLOR( BLACK ) ); - else - XSetForeground( dpy, gc, COLOR( icon_maps[ ON_MAP ].c ) ); - XFillRectangle( dpy, icon_pix, gc, 0, 0, icon_maps[ ON_MAP ].w, icon_maps[ ON_MAP ].h ); - XSetFillStyle( dpy, gc, FillSolid ); -} - -static inline void draw_icon( void ) { XCopyArea( dpy, icon_pix, iconW, gc, 0, 0, hp48_icon_width, hp48_icon_height, 0, 0 ); } - -static void refresh_icon( void ) -{ - int icon_state = ( ( display.on && !( ( ANN_IO & saturn.annunc ) == ANN_IO ) ) || - ( display.on && !( ( ANN_ALPHA & saturn.annunc ) == ANN_ALPHA ) ) ); - if ( icon_state == last_icon_state ) - return; - - last_icon_state = icon_state; - XSetFillStyle( dpy, gc, FillStippled ); - if ( icon_state ) { - /* - * draw the 'x48' string - */ - XSetStipple( dpy, gc, icon_text_pix ); - if ( icon_color_mode == COLOR_MODE_MONO ) - XSetForeground( dpy, gc, COLOR( BLACK ) ); - else - XSetForeground( dpy, gc, COLOR( icon_maps[ ON_MAP ].c ) ); - XFillRectangle( dpy, icon_pix, gc, 0, 0, icon_maps[ ON_MAP ].w, icon_maps[ ON_MAP ].h ); - } else { - /* - * clear the display - */ - XSetFillStyle( dpy, gc, FillStippled ); - XSetStipple( dpy, gc, icon_disp_pix ); - if ( icon_color_mode == COLOR_MODE_MONO ) - XSetForeground( dpy, gc, COLOR( WHITE ) ); - else - XSetForeground( dpy, gc, COLOR( icon_maps[ DISP_MAP ].c ) ); - XFillRectangle( dpy, icon_pix, gc, 0, 0, icon_maps[ DISP_MAP ].w, icon_maps[ DISP_MAP ].h ); - } - XSetFillStyle( dpy, gc, FillSolid ); - if ( iconW ) - draw_icon(); -} - -int handle_xerror( Display* _the_dpy, XErrorEvent* _eev ) -{ - xerror_flag = true; - - return 0; -} - -static inline void _create_LCD( void ) -{ - XSetWindowAttributes xswa; - XGCValues val; - unsigned long gc_mask; - static XRectangle rect; - - /* - * create the display subwindow - */ - lcd.win = XCreateSimpleWindow( dpy, mainW, ( int )DISPLAY_OFFSET_X, ( int )DISPLAY_OFFSET_Y, DISPLAY_WIDTH, DISPLAY_HEIGHT, 0, - COLOR( BLACK ), COLOR( LCD ) ); - - mapped = true; - - xswa.event_mask = ExposureMask | StructureNotifyMask; - xswa.backing_store = Always; - - XChangeWindowAttributes( dpy, lcd.win, CWEventMask | CWBackingStore, &xswa ); - - /* - * set up the gc - */ - val.foreground = COLOR( LCD ); - val.background = COLOR( LCD ); - val.function = GXcopy; - gc_mask = GCForeground | GCBackground | GCFunction; - lcd.gc = XCreateGC( dpy, mainW, gc_mask, &val ); - - XSetForeground( dpy, lcd.gc, COLOR( PIXEL ) ); - - lcd.display_update = UPDATE_DISP | UPDATE_MENU; - - xerror_flag = false; - XSetErrorHandler( handle_xerror ); - XFlush( dpy ); - - lcd.disp_image = NULL; - lcd.menu_image = NULL; - if ( shm_flag ) { - /* - * create XShmImage for DISP - */ - lcd.disp_image = XShmCreateImage( dpy, None, 1, XYBitmap, NULL, &lcd.disp_info, 262, 128 ); - if ( lcd.disp_image == NULL ) { - shm_flag = false; - if ( config.verbose ) - fprintf( stderr, "XShm error in XShmCreateImage(DISP), disabling.\n" ); - goto shm_error; - } - - /* - * get ID of shared memory block for DISP - */ - lcd.disp_info.shmid = shmget( IPC_PRIVATE, ( lcd.disp_image->bytes_per_line * lcd.disp_image->height ), IPC_CREAT | 0777 ); - if ( lcd.disp_info.shmid < 0 ) { - XDestroyImage( lcd.disp_image ); - lcd.disp_image = NULL; - shm_flag = false; - if ( config.verbose ) - fprintf( stderr, "XShm error in shmget(DISP), disabling.\n" ); - goto shm_error; - } - - /* - * get address of shared memory block for DISP - */ - lcd.disp_info.shmaddr = ( char* )shmat( lcd.disp_info.shmid, 0, 0 ); - if ( lcd.disp_info.shmaddr == ( ( char* )-1 ) ) { - XDestroyImage( lcd.disp_image ); - lcd.disp_image = NULL; - shm_flag = false; - if ( config.verbose ) - fprintf( stderr, "XShm error in shmat(DISP), disabling.\n" ); - goto shm_error; - } - lcd.disp_image->data = lcd.disp_info.shmaddr; - lcd.disp_info.readOnly = False; - XShmAttach( dpy, &lcd.disp_info ); - - /* - * create XShmImage for MENU - */ - lcd.menu_image = XShmCreateImage( dpy, None, 1, XYBitmap, NULL, &lcd.menu_info, 262, 128 ); - if ( lcd.menu_image == NULL ) { - XDestroyImage( lcd.disp_image ); - lcd.disp_image = NULL; - shm_flag = false; - if ( config.verbose ) - fprintf( stderr, "XShm error in XShmCreateImage(MENU), disabling.\n" ); - goto shm_error; - } - - /* - * get ID of shared memory block for MENU - */ - lcd.menu_info.shmid = shmget( IPC_PRIVATE, ( lcd.menu_image->bytes_per_line * lcd.menu_image->height ), IPC_CREAT | 0777 ); - if ( lcd.menu_info.shmid < 0 ) { - XDestroyImage( lcd.disp_image ); - lcd.disp_image = NULL; - XDestroyImage( lcd.menu_image ); - lcd.menu_image = NULL; - shm_flag = false; - if ( config.verbose ) - fprintf( stderr, "XShm error in shmget(MENU), disabling.\n" ); - goto shm_error; - } - - /* - * get address of shared memory block for MENU - */ - lcd.menu_info.shmaddr = ( char* )shmat( lcd.menu_info.shmid, 0, 0 ); - if ( lcd.menu_info.shmaddr == ( ( char* )-1 ) ) { - XDestroyImage( lcd.disp_image ); - lcd.disp_image = NULL; - XDestroyImage( lcd.menu_image ); - lcd.menu_image = NULL; - shm_flag = false; - if ( config.verbose ) - fprintf( stderr, "XShm error in shmat(MENU), disabling.\n" ); - goto shm_error; - } - lcd.menu_image->data = lcd.menu_info.shmaddr; - lcd.menu_info.readOnly = False; - XShmAttach( dpy, &lcd.menu_info ); - - XFlush( dpy ); - XSync( dpy, 0 ); - sleep( 1 ); - - if ( xerror_flag ) { - XDestroyImage( lcd.disp_image ); - lcd.disp_image = NULL; - XDestroyImage( lcd.menu_image ); - lcd.menu_image = NULL; - shm_flag = false; - if ( config.verbose ) - fprintf( stderr, "XShm error in shmget(MENU), disabling.\n" ); - goto shm_error; - } else { - shmctl( lcd.disp_info.shmid, IPC_RMID, 0 ); - shmctl( lcd.menu_info.shmid, IPC_RMID, 0 ); - } - - memset( lcd.disp_image->data, 0, ( size_t )( lcd.disp_image->bytes_per_line * lcd.disp_image->height ) ); - memset( lcd.menu_image->data, 0, ( size_t )( lcd.menu_image->bytes_per_line * lcd.menu_image->height ) ); - - if ( config.verbose ) - printf( "using XShm extension.\n" ); - - CompletionType = XShmGetEventBase( dpy ) + ShmCompletion; - } - -shm_error: - XSetErrorHandler( NULL ); - XFlush( dpy ); - - if ( !shm_flag ) { - rect.x = 5; - rect.y = 0; - rect.width = 262; - rect.height = DISPLAY_HEIGHT; - XSetClipRectangles( dpy, lcd.gc, 0, 0, &rect, 1, Unsorted ); - } -} - -static void _write_serial_devices( char* wire, char* ir ) -{ - char name[ 128 ]; - int x, y, w, h; - int conn_top = DISPLAY_OFFSET_Y + DISPLAY_HEIGHT + 18; - XFontStruct* finfo = load_x11_font( dpy, config.connFont ); - XGCValues val; - unsigned long gc_mask = GCFont; - XCharStruct xchar; - - val.font = finfo->fid; - XChangeGC( dpy, gc, gc_mask, &val ); - - int dir, fa, fd; - XTextExtents( finfo, "TEST", ( int )strlen( "TEST" ), &dir, &fa, &fd, &xchar ); - w = DISPLAY_WIDTH; - h = fa + fd; - - Pixmap pix = XCreatePixmap( dpy, keypad.pixmap, w, h, depth ); - XSetForeground( dpy, gc, COLOR( DISP_PAD ) ); - XFillRectangle( dpy, pix, gc, 0, 0, w, h ); - - XSetBackground( dpy, gc, COLOR( DISP_PAD ) ); - XSetForeground( dpy, gc, COLOR( LABEL ) ); - - sprintf( name, "wire: %s", wire ? wire : "none" ); - XTextExtents( finfo, name, ( int )strlen( name ), &dir, &fa, &fd, &xchar ); - x = 0; - y = fa; - XDrawImageString( dpy, pix, gc, x, y, name, ( int )strlen( name ) ); - - sprintf( name, "IR: %s", ir ? ir : "none" ); - XTextExtents( finfo, name, ( int )strlen( name ), &dir, &fa, &fd, &xchar ); - x = w - xchar.width - 1; - y = fa; - XDrawImageString( dpy, pix, gc, x, y, name, ( int )strlen( name ) ); - - x = DISPLAY_OFFSET_X; - y = conn_top; - XCopyArea( dpy, pix, keypad.pixmap, gc, 0, 0, w, h, x, y ); /* write pix onto keypad pixmap */ - - draw_keypad(); - - XFreePixmap( dpy, pix ); - XFreeFont( dpy, finfo ); -} - -static inline void _draw_background( int width, int height, int w_top, int h_top, x11_keypad_t* local_keypad ) -{ - XSetBackground( dpy, gc, COLOR( PAD ) ); - XSetForeground( dpy, gc, COLOR( PAD ) ); - - XFillRectangle( dpy, local_keypad->pixmap, gc, 0, 0, w_top, h_top ); - - XSetBackground( dpy, gc, COLOR( DISP_PAD ) ); - XSetForeground( dpy, gc, COLOR( DISP_PAD ) ); - - XFillRectangle( dpy, local_keypad->pixmap, gc, 0, 0, width, height ); -} - -static void key_event( int b, XEvent* xev ) -{ - if ( xev->type == KeyPress ) - press_key( b ); - else - release_key( b ); - - draw_button( b ); -} - -static void decode_key( XEvent* xev, KeySym sym, char* buf, int buflen ) -{ - if ( buflen == 1 ) - switch ( buf[ 0 ] ) { - case '0': - sym = XK_0; - break; - case '1': - sym = XK_1; - break; - case '2': - sym = XK_2; - break; - case '3': - sym = XK_3; - break; - case '4': - sym = XK_4; - break; - case '5': - sym = XK_5; - break; - case '6': - sym = XK_6; - break; - case '7': - sym = XK_7; - break; - case '8': - sym = XK_8; - break; - case '9': - sym = XK_9; - break; - default: - break; - } - - switch ( ( int )sym ) { - case XK_KP_0: - case XK_0: - key_event( HPKEY_0, xev ); - break; - case XK_KP_1: - case XK_1: - key_event( HPKEY_1, xev ); - break; - case XK_KP_2: - case XK_2: - key_event( HPKEY_2, xev ); - break; - case XK_KP_3: - case XK_3: - key_event( HPKEY_3, xev ); - break; - case XK_KP_4: - case XK_4: - key_event( HPKEY_4, xev ); - break; - case XK_KP_5: - case XK_5: - key_event( HPKEY_5, xev ); - break; - case XK_KP_6: - case XK_6: - key_event( HPKEY_6, xev ); - break; - case XK_KP_7: - case XK_7: - key_event( HPKEY_7, xev ); - break; - case XK_KP_8: - case XK_8: - key_event( HPKEY_8, xev ); - break; - case XK_KP_9: - case XK_9: - key_event( HPKEY_9, xev ); - break; - case XK_KP_Add: - case XK_plus: - case XK_equal: - key_event( HPKEY_PLUS, xev ); - break; - case XK_KP_Subtract: - case XK_minus: - key_event( HPKEY_MINUS, xev ); - break; -#ifdef XK_F25 - case XK_F25: -#endif - case XK_KP_Divide: - case XK_slash: - key_event( HPKEY_DIV, xev ); - break; -#ifdef XK_F26 - case XK_F26: -#endif - case XK_KP_Multiply: - case XK_asterisk: - case XK_comma: - key_event( HPKEY_MUL, xev ); - break; - case XK_F1: - case XK_KP_Enter: - case XK_Return: - key_event( HPKEY_ENTER, xev ); - break; - case XK_KP_Decimal: - case XK_KP_Separator: - case XK_period: - key_event( HPKEY_PERIOD, xev ); - break; - case XK_space: - key_event( HPKEY_SPC, xev ); - break; - case XK_Delete: - key_event( HPKEY_DEL, xev ); - break; - case XK_BackSpace: - key_event( HPKEY_BS, xev ); - break; - case XK_F5: - case XK_Escape: - key_event( HPKEY_ON, xev ); - break; - case XK_Shift_L: - if ( !config.leave_shift_keys ) { - key_event( HPKEY_SHL, xev ); - } - break; - case XK_F2: - case XK_Control_R: - key_event( HPKEY_SHL, xev ); - break; - case XK_Shift_R: - if ( !config.leave_shift_keys ) { - key_event( HPKEY_SHR, xev ); - } - break; - case XK_F3: - case XK_Control_L: - key_event( HPKEY_SHR, xev ); - break; - case XK_F4: - case XK_Alt_L: - case XK_Alt_R: - case XK_Meta_L: - case XK_Meta_R: - key_event( HPKEY_ALPHA, xev ); - break; - case XK_a: - case XK_A: - /* case XK_F1: */ - key_event( HPKEY_A, xev ); - break; - case XK_b: - case XK_B: - /* case XK_F2: */ - key_event( HPKEY_B, xev ); - break; - case XK_c: - case XK_C: - /* case XK_F3: */ - key_event( HPKEY_C, xev ); - break; - case XK_d: - case XK_D: - /* case XK_F4: */ - key_event( HPKEY_D, xev ); - break; - case XK_e: - case XK_E: - /* case XK_F5: */ - key_event( HPKEY_E, xev ); - break; - case XK_f: - case XK_F: - /* case XK_F6: */ - key_event( HPKEY_F, xev ); - break; - case XK_g: - case XK_G: - key_event( HPKEY_MTH, xev ); - break; - case XK_h: - case XK_H: - key_event( HPKEY_PRG, xev ); - break; - case XK_i: - case XK_I: - key_event( HPKEY_CST, xev ); - break; - case XK_j: - case XK_J: - key_event( HPKEY_VAR, xev ); - break; - case XK_k: - case XK_K: - case XK_Up: - key_event( HPKEY_UP, xev ); - break; - case XK_l: - case XK_L: - key_event( HPKEY_NXT, xev ); - break; - case XK_m: - case XK_M: - key_event( HPKEY_QUOTE, xev ); - break; - case XK_n: - case XK_N: - key_event( HPKEY_STO, xev ); - break; - case XK_o: - case XK_O: - key_event( HPKEY_EVAL, xev ); - break; - case XK_p: - case XK_P: - case XK_Left: - key_event( HPKEY_LEFT, xev ); - break; - case XK_q: - case XK_Q: - case XK_Down: - key_event( HPKEY_DOWN, xev ); - break; - case XK_r: - case XK_R: - case XK_Right: - key_event( HPKEY_RIGHT, xev ); - break; - case XK_s: - case XK_S: - key_event( HPKEY_SIN, xev ); - break; - case XK_t: - case XK_T: - key_event( HPKEY_COS, xev ); - break; - case XK_u: - case XK_U: - key_event( HPKEY_TAN, xev ); - break; - case XK_v: - case XK_V: - key_event( HPKEY_SQRT, xev ); - break; - case XK_w: - case XK_W: - key_event( HPKEY_POWER, xev ); - break; - case XK_x: - case XK_X: - key_event( HPKEY_INV, xev ); - break; - case XK_y: - case XK_Y: - key_event( HPKEY_NEG, xev ); - break; - case XK_z: - case XK_Z: - key_event( HPKEY_EEX, xev ); - break; - case XK_F7: - case XK_F10: - close_and_exit(); - // please_exit = true; - break; - default: - break; - } -} - -static inline void draw_nibble( int c, int r, int val ) -{ - val &= 0x0f; - if ( val == lcd_nibbles_buffer[ r ][ c ] ) - return; - - lcd_nibbles_buffer[ r ][ c ] = val; - - int y = ( r * 2 ) + 20; - int x = ( c * 8 ) + 5; - if ( r <= display.lines ) - x -= ( 2 * display.offset ); - - XCopyPlane( dpy, nibble_maps[ val ], lcd.win, lcd.gc, 0, 0, 8, 2, x, y, 1 ); -} - -/* Identical in all ui_*.c */ -static inline void draw_row( long addr, int row ) -{ - int line_length = NIBBLES_PER_ROW; - - if ( ( display.offset > 3 ) && ( row <= display.lines ) ) - line_length += 2; - - for ( int i = 0; i < line_length; i++ ) - draw_nibble( i, row, read_nibble( addr + i ) ); -} - -static bool create_window( int argc, char** argv ) -{ - XSizeHints hint, ih; - XWMHints wmh; - XClassHint clh; - unsigned int class; - XGCValues val; - unsigned long gc_mask; - unsigned int mask; - XSetWindowAttributes xswa; - XTextProperty wname, iname; - Atom protocols[ 2 ]; - char *name, *user_geom = NULL, def_geom[ 40 ]; - int info, x, y, w, h; - unsigned int width, height; - - icon_maps = opt_gx ? icon_maps_gx : icon_maps_sx; - - if ( config.netbook ) { - int i; - for ( i = 0; i < 6; i++ ) { - BUTTONS[ i ].x -= 3; - BUTTONS[ i ].y += 300; - } - for ( ; i <= LAST_HPKEY; i++ ) { - BUTTONS[ i ].x += 317; - BUTTONS[ i ].y -= 3; - } - } - - class = InputOutput; - visual = get_visual_resource( dpy, &depth ); - if ( visual != DefaultVisual( dpy, screen ) ) - cmap = XCreateColormap( dpy, RootWindow( dpy, screen ), visual, ( visual->class == DirectColor ) ? AllocAll : AllocNone ); - else - cmap = DefaultColormap( dpy, screen ); - - direct_color = false; - switch ( visual->class ) { - case DirectColor: - direct_color = true; - break; - case GrayScale: - case PseudoColor: - dynamic_color = true; - break; - case StaticGray: - case StaticColor: - case TrueColor: - default: - dynamic_color = false; - break; - } - - if ( ( visual->class == StaticGray ) || ( visual->class == GrayScale ) ) - color_mode = COLOR_MODE_GRAY; - else - color_mode = COLOR_MODE_COLOR; - if ( config.gray ) - color_mode = COLOR_MODE_GRAY; - - if ( config.mono ) - color_mode = COLOR_MODE_MONO; - if ( depth == 1 ) - color_mode = COLOR_MODE_MONO; - - icon_color_mode = color_mode; - if ( config.monoIcon ) - icon_color_mode = COLOR_MODE_MONO; - - clh.res_name = res_name; - clh.res_class = res_class; - if ( !XStringListToTextProperty( &config.progname, 1, &iname ) ) - return false; - - if ( ( name = config.title ) == ( char* )0 ) { - name = ( char* )malloc( 128 ); - if ( name == ( char* )0 ) - fatal_exit( "malloc failed.\n", "" ); - - sprintf( name, "%s-%d.%d.%d", config.progname, saturn.version[ 0 ], saturn.version[ 1 ], saturn.version[ 2 ] ); - } - - if ( !XStringListToTextProperty( &name, 1, &wname ) ) - return false; - - /* - * Set some Window Attributes - */ - xswa.colormap = cmap; - mask = CWColormap; - - /* - * create the window - */ - width = KEYBOARD_WIDTH + 2 * SIDE_SKIP; - if ( config.netbook ) - height = KEYBOARD_HEIGHT; - else - height = DISPLAY_OFFSET_Y + DISPLAY_HEIGHT + DISP_KBD_SKIP + KEYBOARD_HEIGHT + BOTTOM_SKIP; - - mainW = XCreateWindow( dpy, RootWindow( dpy, screen ), 0, 0, width, height, 0, ( int )depth, class, visual, mask, &xswa ); - - if ( mainW == 0 ) - return false; - - /* - * allocate my colors - */ - colors_setup(); - - /* - * parse -geometry ... - */ - hint.x = hint.y = 0; - hint.min_width = hint.max_width = hint.base_width = hint.width = width; - hint.min_height = hint.max_height = hint.base_height = hint.height = height; - hint.win_gravity = NorthWestGravity; - hint.flags = PSize | PMinSize | PMaxSize | PBaseSize | PWinGravity; - - sprintf( def_geom, "%ux%u", width, height ); - - info = XWMGeometry( dpy, screen, user_geom, def_geom, 0, &hint, &x, &y, &w, &h, &hint.win_gravity ); - - if ( info & ( XValue | YValue ) ) { - if ( info & XValue ) - hint.x = x; - if ( info & YValue ) - hint.y = y; - hint.flags |= USPosition; - } - - /* - * check if we start iconic - */ - wmh.initial_state = ( config.iconic ) ? IconicState : NormalState; - wmh.input = True; - wmh.flags = StateHint | InputHint; - - /* - * Set some more Window Attributes - */ - xswa.background_pixel = COLOR( PAD ); - xswa.border_pixel = COLOR( BLACK ); - xswa.backing_store = Always; - xswa.win_gravity = hint.win_gravity; - xswa.bit_gravity = NorthWestGravity; - xswa.event_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | ExposureMask | KeymapStateMask | - EnterWindowMask | StructureNotifyMask | FocusChangeMask; - mask = CWBackPixel | CWBorderPixel | CWBackingStore | CWEventMask | CWBitGravity | CWWinGravity; - XChangeWindowAttributes( dpy, mainW, mask, &xswa ); - XMoveWindow( dpy, mainW, hint.x, hint.y ); - - /* - * create the icon - */ - xswa.colormap = cmap; - mask = CWColormap; - iconW = XCreateWindow( dpy, RootWindow( dpy, screen ), 0, 0, hp48_icon_width, hp48_icon_height, 0, ( int )depth, class, visual, mask, - &xswa ); - - if ( iconW == 0 ) - return false; - - wmh.icon_window = iconW; - wmh.window_group = mainW; - wmh.flags |= ( IconWindowHint | WindowGroupHint ); - - /* - * set icon position if requested - */ - ih.x = ih.y = 0; - ih.min_width = ih.max_width = ih.base_width = ih.width = hp48_icon_width; - ih.min_height = ih.max_height = ih.base_height = ih.height = hp48_icon_height; - ih.win_gravity = NorthWestGravity; - ih.flags = PSize | PMinSize | PMaxSize | PBaseSize | PWinGravity; - - info = XWMGeometry( dpy, screen, user_geom, ( char* )0, 0, &ih, &x, &y, &w, &h, &ih.win_gravity ); - - if ( ( info & XValue ) && ( info & YValue ) ) { - wmh.icon_x = x; - wmh.icon_y = y; - wmh.flags |= IconPositionHint; - } - - /* - * set some more attributes of icon window - */ - xswa.background_pixel = COLOR( BLACK ); - xswa.border_pixel = COLOR( BLACK ); - xswa.backing_store = NotUseful; - xswa.win_gravity = ih.win_gravity; - xswa.bit_gravity = NorthWestGravity; - mask = CWBackPixel | CWBorderPixel | CWBackingStore | CWBitGravity | CWWinGravity; - XChangeWindowAttributes( dpy, iconW, mask, &xswa ); - - /* - * tell window manager all the stuff we dug out - */ - XSetWMProperties( dpy, mainW, &wname, &iname, argv, argc, &hint, &wmh, &clh ); - - /* - * turn on WM_DELETE_WINDOW - */ - wm_delete_window = XInternAtom( dpy, "WM_DELETE_WINDOW", 0 ); - wm_save_yourself = XInternAtom( dpy, "WM_SAVE_YOURSELF", 0 ); - wm_protocols = XInternAtom( dpy, "WM_PROTOCOLS", 0 ); - protocols[ 0 ] = wm_delete_window; - protocols[ 1 ] = wm_save_yourself; - XSetWMProtocols( dpy, mainW, protocols, 2 ); - - /* - * turn off icon name for olwm, olvwm - */ - ol_decor_icon_name = XInternAtom( dpy, "_OL_DECOR_ICON_NAME", 0 ); - ol_decor_del = XInternAtom( dpy, "_OL_DECOR_DEL", 0 ); - atom_type = XInternAtom( dpy, "ATOM", 0 ); - XChangeProperty( dpy, mainW, ol_decor_del, atom_type, 32, PropModeReplace, ( unsigned char* )&ol_decor_icon_name, 1 ); - - /* - * set up the GC's - */ - val.foreground = COLOR( WHITE ); - val.background = COLOR( BLACK ); - val.function = GXcopy; - gc_mask = GCForeground | GCBackground | GCFunction; - gc = XCreateGC( dpy, mainW, gc_mask, &val ); - - /* - * create the icon pixmap for desktops - */ - _create_icon(); - - /* - * create the display - */ - _create_LCD(); - - /* - * create the keypad - */ - /* - * draw the nice labels around the BUTTONS - */ - keypad.width = width; - keypad.height = height; - - keypad.pixmap = XCreatePixmap( dpy, mainW, width, height, depth ); - - int cut; - if ( config.netbook ) { - cut = BUTTONS[ HPKEY_MTH ].y - ( small_ascent + small_descent + 6 + 4 ); - _draw_background( width / 2, height, width, height, &keypad ); - __create_keypad( -cut, KEYBOARD_OFFSET_X, &keypad ); - } else { - cut = BUTTONS[ HPKEY_MTH ].y + KEYBOARD_OFFSET_Y - 19; - _draw_background( width, cut, width, height, &keypad ); - __create_keypad( KEYBOARD_OFFSET_Y, KEYBOARD_OFFSET_X, &keypad ); - } - _draw_bezel( KEYBOARD_OFFSET_Y, &keypad ); - _draw_bezel_LCD( &keypad ); - - /* - * map the window - */ - XMapWindow( dpy, mainW ); - XMapSubwindows( dpy, mainW ); - - for ( int b = FIRST_HPKEY; b <= LAST_HPKEY; b++ ) - draw_button( b ); - draw_icon(); - - _write_serial_devices( wire_name, ir_name ); - - if ( shm_flag ) { - XSetForeground( dpy, lcd.gc, COLOR( PIXEL ) ); - XFillRectangle( dpy, lcd.win, lcd.gc, 5, 20, 262, 128 ); - } - - return true; -} - -/**********/ -/* public */ -/**********/ - -void x11_ui_stop( void ) { XCloseDisplay( dpy ); } - -void x11_get_event( void ) -{ - XEvent xev; - XClientMessageEvent* cm; - int i, bufs = 2; - char buf[ 2 ]; - KeySym sym; - static int release_pending = 0; - static XKeyEvent release_event; - static Time last_release_time = 0; - - if ( paste_last_key ) { - release_key( paste[ paste_count - 1 ] ); - paste_last_key = 0; - return; - } else if ( paste_count < paste_size ) { - press_key( paste[ paste_count ] ); - paste_last_key = 1; - paste_count++; - return; - } - - if ( release_pending ) { - i = XLookupString( &release_event, buf, bufs, &sym, NULL ); - decode_key( ( XEvent* )&release_event, sym, buf, i ); - release_pending = 0; - return; - } - - do { - while ( XPending( dpy ) > 0 ) { - - XNextEvent( dpy, &xev ); - - switch ( ( int )xev.type ) { - - case KeyPress: - release_pending = 0; - if ( ( xev.xkey.time - last_release_time ) <= 1 ) { - release_pending = 0; - break; - } - - i = XLookupString( &xev.xkey, buf, bufs, &sym, NULL ); - decode_key( &xev, sym, buf, i ); - - /* if ( please_exit ) */ - /* return; */ - - first_key = 1; - break; - - case KeyRelease: - i = XLookupString( &xev.xkey, buf, bufs, &sym, NULL ); - first_key = 0; - release_pending = 1; - last_release_time = xev.xkey.time; - memcpy( &release_event, &xev, sizeof( XKeyEvent ) ); - break; - - case NoExpose: - break; - - case Expose: - if ( xev.xexpose.count == 0 ) { - if ( xev.xexpose.window == lcd.win ) { - if ( shm_flag ) { - XShmPutImage( dpy, lcd.win, lcd.gc, lcd.disp_image, 2 * display.offset, 0, 5, 20, 262, - ( unsigned int )( ( 2 * display.lines ) + 2 ), 0 ); - if ( display.lines < 63 ) - XShmPutImage( dpy, lcd.win, lcd.gc, lcd.menu_image, 0, ( 2 * display.lines ) - 110, 5, - 22 + ( 2 * display.lines ), 262, ( unsigned int )( 126 - ( 2 * display.lines ) ), 0 ); - - lcd.display_update = 0; - } else - x11_update_LCD(); - - last_annunc_state = -1; - x11_draw_annunc(); - } else if ( xev.xexpose.window == iconW ) - draw_icon(); - else if ( xev.xexpose.window == mainW ) - draw_keypad(); - else - for ( i = FIRST_HPKEY; i <= LAST_HPKEY; i++ ) { - if ( xev.xexpose.window == x11_buttons[ i ].xwin ) { - draw_button( i ); - break; - } - } - } - break; - - case UnmapNotify: - mapped = false; - break; - - case MapNotify: - if ( !mapped ) { - mapped = true; - x11_update_LCD(); - last_annunc_state = -1; - x11_draw_annunc(); - } - break; - - case ButtonPress: - if ( xev.xbutton.subwindow == lcd.win ) { - if ( xev.xbutton.button == Button2 ) { - if ( xev.xbutton.subwindow == lcd.win ) { - int x; - int flag = 0; - char* paste_in = XFetchBuffer( dpy, &x, 0 ); - - char* p = paste_in; - if ( x > MAX_PASTE ) { - x = 0; - printf( "input too long. limit is %d " - "characters\n", - MAX_PASTE ); - } - paste_count = 0; - paste_size = 0; - while ( x-- ) { - char c = *p++; - switch ( c ) { - case '.': - paste[ paste_size++ ] = HPKEY_PERIOD; - break; - case '0': - paste[ paste_size++ ] = HPKEY_0; - break; - case '1': - paste[ paste_size++ ] = HPKEY_1; - break; - case '2': - paste[ paste_size++ ] = HPKEY_2; - break; - case '3': - paste[ paste_size++ ] = HPKEY_3; - break; - case '4': - paste[ paste_size++ ] = HPKEY_4; - break; - case '5': - paste[ paste_size++ ] = HPKEY_5; - break; - case '6': - paste[ paste_size++ ] = HPKEY_6; - break; - case '7': - paste[ paste_size++ ] = HPKEY_7; - break; - case '8': - paste[ paste_size++ ] = HPKEY_8; - break; - case '9': - paste[ paste_size++ ] = HPKEY_9; - break; - case '\n': - paste[ paste_size++ ] = HPKEY_SHR; - paste[ paste_size++ ] = HPKEY_PERIOD; - break; - case '!': - paste[ paste_size++ ] = HPKEY_ALPHA; - paste[ paste_size++ ] = HPKEY_SHL; - paste[ paste_size++ ] = HPKEY_DEL; - break; - case '+': - paste[ paste_size++ ] = HPKEY_ALPHA; - paste[ paste_size++ ] = HPKEY_PLUS; - break; - case '-': - paste[ paste_size++ ] = HPKEY_ALPHA; - paste[ paste_size++ ] = HPKEY_MINUS; - break; - case '*': - paste[ paste_size++ ] = HPKEY_ALPHA; - paste[ paste_size++ ] = HPKEY_MUL; - break; - case '/': - paste[ paste_size++ ] = HPKEY_ALPHA; - paste[ paste_size++ ] = HPKEY_DIV; - break; - case ' ': - paste[ paste_size++ ] = 47; - break; - case '(': - paste[ paste_size++ ] = HPKEY_SHL; - paste[ paste_size++ ] = HPKEY_DIV; - break; - case '[': - paste[ paste_size++ ] = HPKEY_SHL; - paste[ paste_size++ ] = HPKEY_MUL; - break; - case '<': - if ( x > 1 && *p == '<' ) { - paste[ paste_size++ ] = HPKEY_SHL; - paste[ paste_size++ ] = HPKEY_MINUS; - x--; - p++; - } else { - paste[ paste_size++ ] = HPKEY_ALPHA; - paste[ paste_size++ ] = HPKEY_SHL; - paste[ paste_size++ ] = HPKEY_2; - } - break; - case '{': - paste[ paste_size++ ] = HPKEY_SHL; - paste[ paste_size++ ] = HPKEY_PLUS; - break; - case ')': - case ']': - case '}': - paste[ paste_size++ ] = HPKEY_RIGHT; - break; - case '>': - if ( x > 1 && *p == '>' ) { - paste[ paste_size++ ] = HPKEY_RIGHT; - paste[ paste_size++ ] = HPKEY_RIGHT; - paste[ paste_size++ ] = HPKEY_RIGHT; - x--; - p++; - } else { - paste[ paste_size++ ] = HPKEY_ALPHA; - paste[ paste_size++ ] = HPKEY_SHR; - paste[ paste_size++ ] = HPKEY_2; - } - break; - case '#': - paste[ paste_size++ ] = HPKEY_SHR; - paste[ paste_size++ ] = HPKEY_DIV; - break; - case '_': - paste[ paste_size++ ] = HPKEY_SHR; - paste[ paste_size++ ] = HPKEY_MUL; - break; - case '"': - if ( flag & 1 ) { - flag &= ~1; - paste[ paste_size++ ] = HPKEY_RIGHT; - } else { - flag |= 1; - paste[ paste_size++ ] = HPKEY_SHR; - paste[ paste_size++ ] = HPKEY_MINUS; - } - break; - case ':': - if ( flag & 2 ) { - flag &= ~2; - paste[ paste_size++ ] = HPKEY_RIGHT; - } else { - flag |= 2; - paste[ paste_size++ ] = HPKEY_SHR; - paste[ paste_size++ ] = HPKEY_PLUS; - } - break; - case '\'': - if ( flag & 4 ) { - flag &= ~4; - paste[ paste_size++ ] = HPKEY_RIGHT; - } else { - flag |= 4; - paste[ paste_size++ ] = HPKEY_QUOTE; - } - break; - case 'a': - case 'A': - paste[ paste_size++ ] = HPKEY_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = HPKEY_SHL; - paste[ paste_size++ ] = HPKEY_A; - break; - case 'b': - case 'B': - paste[ paste_size++ ] = HPKEY_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = HPKEY_SHL; - paste[ paste_size++ ] = HPKEY_B; - break; - case 'c': - case 'C': - paste[ paste_size++ ] = HPKEY_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = HPKEY_SHL; - paste[ paste_size++ ] = HPKEY_C; - break; - case 'd': - case 'D': - paste[ paste_size++ ] = HPKEY_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = HPKEY_SHL; - paste[ paste_size++ ] = HPKEY_D; - break; - case 'e': - case 'E': - paste[ paste_size++ ] = HPKEY_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = HPKEY_SHL; - paste[ paste_size++ ] = HPKEY_E; - break; - case 'f': - case 'F': - paste[ paste_size++ ] = HPKEY_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = HPKEY_SHL; - paste[ paste_size++ ] = HPKEY_F; - break; - case 'g': - case 'G': - paste[ paste_size++ ] = HPKEY_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = HPKEY_SHL; - paste[ paste_size++ ] = HPKEY_MTH; - break; - case 'h': - case 'H': - paste[ paste_size++ ] = HPKEY_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = HPKEY_SHL; - paste[ paste_size++ ] = HPKEY_PRG; - break; - case 'i': - case 'I': - paste[ paste_size++ ] = HPKEY_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = HPKEY_SHL; - paste[ paste_size++ ] = HPKEY_CST; - break; - case 'j': - case 'J': - paste[ paste_size++ ] = HPKEY_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = HPKEY_SHL; - paste[ paste_size++ ] = HPKEY_VAR; - break; - case 'k': - case 'K': - paste[ paste_size++ ] = HPKEY_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = HPKEY_SHL; - paste[ paste_size++ ] = HPKEY_UP; - break; - case 'l': - case 'L': - paste[ paste_size++ ] = HPKEY_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = HPKEY_SHL; - paste[ paste_size++ ] = HPKEY_NXT; - break; - - case 'm': - case 'M': - paste[ paste_size++ ] = HPKEY_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = HPKEY_SHL; - paste[ paste_size++ ] = HPKEY_QUOTE; - break; - case 'n': - case 'N': - paste[ paste_size++ ] = HPKEY_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = HPKEY_SHL; - paste[ paste_size++ ] = HPKEY_STO; - break; - case 'o': - case 'O': - paste[ paste_size++ ] = HPKEY_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = HPKEY_SHL; - paste[ paste_size++ ] = HPKEY_EVAL; - break; - case 'p': - case 'P': - paste[ paste_size++ ] = HPKEY_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = HPKEY_SHL; - paste[ paste_size++ ] = HPKEY_LEFT; - break; - case 'q': - case 'Q': - paste[ paste_size++ ] = HPKEY_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = HPKEY_SHL; - paste[ paste_size++ ] = HPKEY_DOWN; - break; - case 'r': - case 'R': - paste[ paste_size++ ] = HPKEY_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = HPKEY_SHL; - paste[ paste_size++ ] = HPKEY_RIGHT; - break; - case 's': - case 'S': - paste[ paste_size++ ] = HPKEY_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = HPKEY_SHL; - paste[ paste_size++ ] = HPKEY_SIN; - break; - case 't': - case 'T': - paste[ paste_size++ ] = HPKEY_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = HPKEY_SHL; - paste[ paste_size++ ] = HPKEY_COS; - break; - case 'u': - case 'U': - paste[ paste_size++ ] = HPKEY_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = HPKEY_SHL; - paste[ paste_size++ ] = HPKEY_TAN; - break; - case 'v': - case 'V': - paste[ paste_size++ ] = HPKEY_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = HPKEY_SHL; - paste[ paste_size++ ] = HPKEY_SQRT; - break; - case 'w': - case 'W': - paste[ paste_size++ ] = HPKEY_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = HPKEY_SHL; - paste[ paste_size++ ] = HPKEY_POWER; - break; - case 'x': - case 'X': - paste[ paste_size++ ] = HPKEY_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = HPKEY_SHL; - paste[ paste_size++ ] = HPKEY_INV; - break; - case 'y': - case 'Y': - paste[ paste_size++ ] = HPKEY_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = HPKEY_SHL; - paste[ paste_size++ ] = HPKEY_NEG; - break; - case 'z': - case 'Z': - paste[ paste_size++ ] = HPKEY_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = HPKEY_SHL; - paste[ paste_size++ ] = HPKEY_EEX; - break; - default: - printf( "unknown %c %d\n", c, *p ); - break; - } - } - if ( paste_in ) - XFree( paste_in ); - if ( paste_size ) - return; - } - } - } else { - if ( xev.xbutton.button == Button1 || xev.xbutton.button == Button2 || xev.xbutton.button == Button3 ) { - for ( i = FIRST_HPKEY; i <= LAST_HPKEY; i++ ) { - if ( xev.xbutton.subwindow == x11_buttons[ i ].xwin ) { - if ( keyboard[ i ].pressed ) { - if ( xev.xbutton.button == Button3 ) { - release_key( i ); - draw_button( i ); - } - } else { - last_button = i; - press_key( i ); - first_key = 1; - draw_button( i ); - } - break; - } - } - } - } - break; - - case ButtonRelease: - first_key = 0; - if ( xev.xbutton.button == Button1 ) { - release_all_keys(); - for ( int b = FIRST_HPKEY; b <= LAST_HPKEY; b++ ) - draw_button( b ); - } - - if ( xev.xbutton.button == Button2 ) { - if ( last_button >= 0 ) { - release_key( last_button ); - draw_button( last_button ); - } - last_button = -1; - } - break; - - case FocusOut: - first_key = 0; - release_all_keys(); - for ( int b = FIRST_HPKEY; b <= LAST_HPKEY; b++ ) - draw_button( b ); - break; - - case MappingNotify: - switch ( xev.xmapping.request ) { - case MappingModifier: - case MappingKeyboard: - XRefreshKeyboardMapping( &xev.xmapping ); - break; - case MappingPointer: - default: - break; - } - break; - - case EnterNotify: - case LeaveNotify: - break; - - case ClientMessage: - cm = ( XClientMessageEvent* )&xev; - - if ( cm->message_type == wm_protocols ) { - if ( cm->data.l[ 0 ] == ( long )wm_delete_window ) { - close_and_exit(); - // please_exit = true; - // return; - } - if ( cm->data.l[ 0 ] == ( long )wm_save_yourself ) { - int wm_argc = 0; - char** wm_argv = ( char** )malloc( ( saved_argc + 5 ) * sizeof( char* ) ); - - if ( wm_argv == ( char** )0 ) { - if ( config.verbose ) - fprintf( stderr, "warning: malloc failed in wm_save_yourself.\n" ); - XSetCommand( dpy, mainW, saved_argv, saved_argc ); - return; - } - - XSetCommand( dpy, mainW, wm_argv, wm_argc ); - } - } - break; - - case KeymapNotify: - case ConfigureNotify: - case ReparentNotify: - default: - break; - } - } - } while ( first_key > 1 ); - - if ( first_key ) - first_key++; -} - -static void x11_refresh_LCD( void ) -{ - if ( !shm_flag ) - return; - - if ( lcd.display_update & UPDATE_DISP ) - XShmPutImage( dpy, lcd.win, lcd.gc, lcd.disp_image, 2 * display.offset, 0, 5, 20, 262, - ( unsigned int )( ( 2 * display.lines ) + 2 ), 0 ); - - if ( ( ( 2 * display.lines ) < 126 ) && ( lcd.display_update & UPDATE_MENU ) ) - XShmPutImage( dpy, lcd.win, lcd.gc, lcd.menu_image, 0, 0, 5, ( int )( ( 2 * display.lines ) + 22 ), 262, - ( unsigned int )( 126 - ( 2 * display.lines ) ), 0 ); - - lcd.display_update = 0; -} - -void x11_adjust_contrast( void ) -{ - int gray = 0; - int r = 0, g = 0, b = 0; - unsigned long old; - - int contrast = display.contrast; - - if ( contrast < 0x3 ) - contrast = 0x3; - if ( contrast > 0x13 ) - contrast = 0x13; - - old = x11_colors[ PIXEL ].pixel; - switch ( color_mode ) { - case COLOR_MODE_MONO: - return; - case COLOR_MODE_GRAY: - gray = ( 0x13 - contrast ) * ( COLORS[ LCD ].gray_rgb / 0x10 ); - x11_colors[ PIXEL ].red = gray << 8; - x11_colors[ PIXEL ].green = gray << 8; - x11_colors[ PIXEL ].blue = gray << 8; - break; - default: - r = ( 0x13 - contrast ) * ( COLORS[ LCD ].r / 0x10 ); - g = ( 0x13 - contrast ) * ( COLORS[ LCD ].g / 0x10 ); - b = 128 - ( ( 0x13 - contrast ) * ( ( 128 - COLORS[ LCD ].b ) / 0x10 ) ); - x11_colors[ PIXEL ].red = r << 8; - x11_colors[ PIXEL ].green = g << 8; - x11_colors[ PIXEL ].blue = b << 8; - break; - } - - if ( direct_color ) { - COLORS[ PIXEL ].gray_rgb = gray; - COLORS[ PIXEL ].r = r; - COLORS[ PIXEL ].g = g; - COLORS[ PIXEL ].b = b; - - colors_setup(); - - XSetForeground( dpy, lcd.gc, COLOR( PIXEL ) ); - - lcd.display_update = UPDATE_DISP | UPDATE_MENU; - - x11_refresh_LCD(); - - last_annunc_state = -1; - x11_draw_annunc(); - - last_icon_state = -1; - refresh_icon(); - } else if ( dynamic_color ) { - XStoreColor( dpy, cmap, &x11_colors[ PIXEL ] ); - } else { - if ( XAllocColor( dpy, cmap, &x11_colors[ PIXEL ] ) == 0 ) { - x11_colors[ PIXEL ].pixel = old; - if ( config.verbose ) - fprintf( stderr, "warning: can\'t alloc new pixel color.\n" ); - } else { - XFreeColors( dpy, cmap, &old, 1, 0 ); - XSetForeground( dpy, lcd.gc, COLOR( PIXEL ) ); - - lcd.display_update = UPDATE_DISP | UPDATE_MENU; - - x11_refresh_LCD(); - - last_annunc_state = -1; - x11_draw_annunc(); - - last_icon_state = -1; - refresh_icon(); - } - } -} - -void x11_update_LCD( void ) -{ - int i, j; - long addr; - static int old_offset = -1; - static int old_lines = -1; - int addr_pad; - int val, line_pad, line_length; - word_20 data_addr, data_addr_2; - - if ( !mapped ) { - refresh_icon(); - return; - } - if ( display.on ) { - addr = display.disp_start; - if ( shm_flag ) { - data_addr = 0; - data_addr_2 = lcd.disp_image->bytes_per_line; - line_length = NIBBLES_PER_ROW; - if ( display.offset > 3 ) - line_length += 2; - line_pad = 2 * lcd.disp_image->bytes_per_line - line_length; - addr_pad = display.nibs_per_line - line_length; - for ( i = 0; i <= display.lines; i++ ) { - for ( j = 0; j < line_length; j++ ) { - val = read_nibble( addr++ ); - lcd.disp_image->data[ data_addr++ ] = nibble_bitmap[ val ]; - lcd.disp_image->data[ data_addr_2++ ] = nibble_bitmap[ val ]; - } - addr += addr_pad; - data_addr += line_pad; - data_addr_2 += line_pad; - } - lcd.display_update |= UPDATE_DISP; - } else { - if ( display.offset != old_offset ) { - memset( lcd_nibbles_buffer, 0xf0, ( size_t )( ( display.lines + 1 ) * NIBS_PER_BUFFER_ROW ) ); - old_offset = display.offset; - } - if ( display.lines != old_lines ) { - memset( &lcd_nibbles_buffer[ 56 ][ 0 ], 0xf0, ( size_t )( 8 * NIBS_PER_BUFFER_ROW ) ); - old_lines = display.lines; - } - for ( i = 0; i <= display.lines; i++ ) { - draw_row( addr, i ); - addr += display.nibs_per_line; - } - } - if ( i < DISP_ROWS ) { - addr = display.menu_start; - if ( shm_flag ) { - data_addr = 0; - data_addr_2 = lcd.menu_image->bytes_per_line; - line_pad = 2 * lcd.menu_image->bytes_per_line - NIBBLES_PER_ROW; - for ( ; i < DISP_ROWS; i++ ) { - for ( j = 0; j < NIBBLES_PER_ROW; j++ ) { - val = read_nibble( addr++ ); - lcd.menu_image->data[ data_addr++ ] = nibble_bitmap[ val ]; - lcd.menu_image->data[ data_addr_2++ ] = nibble_bitmap[ val ]; - } - data_addr += line_pad; - data_addr_2 += line_pad; - } - lcd.display_update |= UPDATE_MENU; - } else - for ( ; i < DISP_ROWS; i++ ) { - draw_row( addr, i ); - addr += NIBBLES_PER_ROW; - } - } - } else { - if ( shm_flag ) { - memset( lcd.disp_image->data, 0, ( size_t )( lcd.disp_image->bytes_per_line * lcd.disp_image->height ) ); - memset( lcd.menu_image->data, 0, ( size_t )( lcd.menu_image->bytes_per_line * lcd.menu_image->height ) ); - lcd.display_update = UPDATE_DISP | UPDATE_MENU; - } else { - ui_init_LCD(); - - for ( i = 0; i < 64; i++ ) - for ( j = 0; j < NIBBLES_PER_ROW; j++ ) - draw_nibble( j, i, 0x00 ); - } - } - - x11_refresh_LCD(); -} - -void x11_disp_draw_nibble( word_20 addr, word_4 val ) -{ - long offset = ( addr - display.disp_start ); - int x = offset % display.nibs_per_line; - - if ( x < 0 || x > 35 ) - return; - - if ( display.nibs_per_line != 0 ) { - int y = offset / display.nibs_per_line; - if ( y < 0 || y > 63 ) - return; - - if ( shm_flag ) { - int shm_addr = ( 2 * y * lcd.disp_image->bytes_per_line ) + x; - lcd.disp_image->data[ shm_addr ] = nibble_bitmap[ val ]; - lcd.disp_image->data[ shm_addr + lcd.disp_image->bytes_per_line ] = nibble_bitmap[ val ]; - lcd.display_update |= UPDATE_DISP; - } else - draw_nibble( x, y, val ); - } else { - if ( shm_flag ) { - int shm_addr = x; - for ( int y = 0; y < display.lines; y++ ) { - lcd.disp_image->data[ shm_addr ] = nibble_bitmap[ val ]; - shm_addr += lcd.disp_image->bytes_per_line; - lcd.disp_image->data[ shm_addr ] = nibble_bitmap[ val ]; - shm_addr += lcd.disp_image->bytes_per_line; - } - lcd.display_update |= UPDATE_DISP; - } else - for ( int y = 0; y < display.lines; y++ ) - draw_nibble( x, y, val ); - } -} - -void x11_menu_draw_nibble( word_20 addr, word_4 val ) -{ - long offset = ( addr - display.menu_start ); - if ( shm_flag ) { - int shm_addr = 2 * ( offset / NIBBLES_PER_ROW ) * lcd.menu_image->bytes_per_line + ( offset % NIBBLES_PER_ROW ); - lcd.menu_image->data[ shm_addr ] = nibble_bitmap[ val ]; - lcd.menu_image->data[ shm_addr + lcd.menu_image->bytes_per_line ] = nibble_bitmap[ val ]; - lcd.display_update |= UPDATE_MENU; - } else { - int x = offset % NIBBLES_PER_ROW; - int y = display.lines + ( offset / NIBBLES_PER_ROW ) + 1; - - draw_nibble( x, y, val ); - } -} - -void x11_draw_annunc( void ) -{ - if ( saturn.annunc == last_annunc_state ) - return; - - last_annunc_state = saturn.annunc; - - for ( int i = 0; i < NB_ANNUNCIATORS; i++ ) - if ( ( annunciators_bits[ i ] & saturn.annunc ) == annunciators_bits[ i ] ) - XCopyPlane( dpy, x11_ann_pixmaps[ i ], lcd.win, lcd.gc, 0, 0, ann_tbl[ i ].width, ann_tbl[ i ].height, ann_tbl[ i ].x, - ann_tbl[ i ].y, 1 ); - else - XClearArea( dpy, lcd.win, ann_tbl[ i ].x, ann_tbl[ i ].y, ann_tbl[ i ].width, ann_tbl[ i ].height, False ); - - refresh_icon(); -} - -void init_x11_ui( int argc, char** argv ) -{ - bool status; - if ( config.verbose ) - fprintf( stderr, "UI is x11\n" ); - - /* Set public API to this UI's functions */ - ui_disp_draw_nibble = x11_disp_draw_nibble; - ui_menu_draw_nibble = x11_menu_draw_nibble; - ui_get_event = x11_get_event; - ui_update_LCD = x11_update_LCD; - ui_refresh_LCD = x11_refresh_LCD; - ui_adjust_contrast = x11_adjust_contrast; - ui_draw_annunc = x11_draw_annunc; - - // save_options - { - int l; - - saved_argc = argc; - saved_argv = ( char** )malloc( ( argc + 2 ) * sizeof( char* ) ); - if ( saved_argv == ( char** )0 ) { - fprintf( stderr, "malloc failed in save_options(), exit\n" ); - exit( 1 ); - } - saved_argv[ argc ] = ( char* )0; - while ( argc-- ) { - l = strlen( argv[ argc ] ) + 1; - saved_argv[ argc ] = ( char* )malloc( l ); - if ( saved_argv[ argc ] == ( char* )0 ) { - fprintf( stderr, "malloc failed in save_options(), exit\n" ); - exit( 1 ); - } - memcpy( saved_argv[ argc ], argv[ argc ], l ); - } - } - - // init_display - /* - * open the display - */ - dpy = XOpenDisplay( NULL ); - if ( dpy == ( Display* )0 ) { - if ( config.verbose ) - fprintf( stderr, "can\'t open display\n" ); - - exit( 1 ); - } - - /* - * Get the default screen - */ - screen = DefaultScreen( dpy ); - - /* - * Try to use XShm-Extension - */ - shm_flag = XShmQueryExtension( dpy ); - if ( config.verbose ) { - if ( shm_flag ) - fprintf( stderr, "Xserver does not support XShm extension.\n" ); - else - fprintf( stderr, "using XShm extension.\n" ); - } - - status = create_window( saved_argc, saved_argv ); - if ( !status ) { - fprintf( stderr, "can\'t create window\n" ); - exit( 1 ); - } - - for ( int i = 0; i < NB_ANNUNCIATORS; i++ ) - x11_ann_pixmaps[ i ] = XCreateBitmapFromData( dpy, lcd.win, ( char* )ann_tbl[ i ].bits, ann_tbl[ i ].width, ann_tbl[ i ].height ); - - /* init nibble_maps */ - for ( int i = 0; i < 16; i++ ) - nibble_maps[ i ] = XCreateBitmapFromData( dpy, lcd.win, ( char* )nibbles[ i ], 8, 2 ); - - if ( !shm_flag ) - return; - - if ( lcd.disp_image->bitmap_bit_order == MSBFirst ) { - nibble_bitmap[ 0x0 ] = 0x00; /* ---- */ - nibble_bitmap[ 0x1 ] = 0xc0; /* *--- */ - nibble_bitmap[ 0x2 ] = 0x30; /* -*-- */ - nibble_bitmap[ 0x3 ] = 0xf0; /* **-- */ - nibble_bitmap[ 0x4 ] = 0x0c; /* --*- */ - nibble_bitmap[ 0x5 ] = 0xcc; /* *-*- */ - nibble_bitmap[ 0x6 ] = 0x3c; /* -**- */ - nibble_bitmap[ 0x7 ] = 0xfc; /* ***- */ - nibble_bitmap[ 0x8 ] = 0x03; /* ---* */ - nibble_bitmap[ 0x9 ] = 0xc3; /* *--* */ - nibble_bitmap[ 0xa ] = 0x33; /* -*-* */ - nibble_bitmap[ 0xb ] = 0xf3; /* **-* */ - nibble_bitmap[ 0xc ] = 0x0f; /* --** */ - nibble_bitmap[ 0xd ] = 0xcf; /* *-** */ - nibble_bitmap[ 0xe ] = 0x3f; /* -*** */ - nibble_bitmap[ 0xf ] = 0xff; /* **** */ - } else { - nibble_bitmap[ 0x0 ] = 0x00; /* ---- */ - nibble_bitmap[ 0x1 ] = 0x03; /* *--- */ - nibble_bitmap[ 0x2 ] = 0x0c; /* -*-- */ - nibble_bitmap[ 0x3 ] = 0x0f; /* **-- */ - nibble_bitmap[ 0x4 ] = 0x30; /* --*- */ - nibble_bitmap[ 0x5 ] = 0x33; /* *-*- */ - nibble_bitmap[ 0x6 ] = 0x3c; /* -**- */ - nibble_bitmap[ 0x7 ] = 0x3f; /* ***- */ - nibble_bitmap[ 0x8 ] = 0xc0; /* ---* */ - nibble_bitmap[ 0x9 ] = 0xc3; /* *--* */ - nibble_bitmap[ 0xa ] = 0xcc; /* -*-* */ - nibble_bitmap[ 0xb ] = 0xcf; /* **-* */ - nibble_bitmap[ 0xc ] = 0xf0; /* --** */ - nibble_bitmap[ 0xd ] = 0xf3; /* *-** */ - nibble_bitmap[ 0xe ] = 0xfc; /* -*** */ - nibble_bitmap[ 0xf ] = 0xff; /* **** */ - } -} diff --git a/tui-screenshot.png b/tui-screenshot.png deleted file mode 100644 index bd8695e..0000000 Binary files a/tui-screenshot.png and /dev/null differ diff --git a/tui-small-screenshot.png b/tui-small-screenshot.png deleted file mode 100644 index 3ca829a..0000000 Binary files a/tui-small-screenshot.png and /dev/null differ diff --git a/tui-tiny-screenshot.png b/tui-tiny-screenshot.png deleted file mode 100644 index 3a53ad3..0000000 Binary files a/tui-tiny-screenshot.png and /dev/null differ diff --git a/x11-screenshot.png b/x11-screenshot.png deleted file mode 100644 index d4a5603..0000000 Binary files a/x11-screenshot.png and /dev/null differ