it's most likely broken but it compiles to libx48ng.a

This commit is contained in:
Gwenhael Le Moine 2024-09-12 21:00:40 +02:00
parent 579d9fe0ae
commit 23cb32824c
No known key found for this signature in database
GPG key ID: FDFE3669426707A7
39 changed files with 242 additions and 11233 deletions

View file

@ -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

1
.gitignore vendored
View file

@ -2,3 +2,4 @@ src/*.o
src/legacy_tools/*.o src/legacy_tools/*.o
dist/x48ng* dist/x48ng*
/libx48ng.a

115
Makefile
View file

@ -6,8 +6,7 @@
# The governing license can be found in the LICENSE file or at # The governing license can be found in the LICENSE file or at
# https://opensource.org/license/MIT. # https://opensource.org/license/MIT.
TARGETS = dist/x48ng dist/x48ng-checkrom dist/x48ng-dump2rom TARGETS = libx48ng.a
PREFIX = /usr PREFIX = /usr
DOCDIR = $(PREFIX)/doc/x48ng DOCDIR = $(PREFIX)/doc/x48ng
MANDIR = $(PREFIX)/man MANDIR = $(PREFIX)/man
@ -16,13 +15,10 @@ CFLAGS ?= -g -O2
FULL_WARNINGS = no FULL_WARNINGS = no
LUA_VERSION ?= lua LUA_VERSION ?= lua
PKG_CONFIG ?= pkg-config PKG_CONFIG ?= pkg-config
WITH_X11 ?= yes
WITH_SDL ?= yes
WITH_SDL2 ?= yes
VERSION_MAJOR = 0 VERSION_MAJOR = 0
VERSION_MINOR = 40 VERSION_MINOR = 41
PATCHLEVEL = 2 PATCHLEVEL = 0
DOTOS = src/emu_serial.o \ DOTOS = src/emu_serial.o \
src/emu_emulate.o \ src/emu_emulate.o \
@ -32,11 +28,7 @@ DOTOS = src/emu_serial.o \
src/emu_register.o \ src/emu_register.o \
src/emu_timer.o \ src/emu_timer.o \
src/debugger.o \ src/debugger.o \
src/config.o \
src/romio.o \ src/romio.o \
src/ui_text.o \
src/ui.o \
src/main.o
MAKEFLAGS +=-j$(NUM_CORES) -l$(NUM_CORES) MAKEFLAGS +=-j$(NUM_CORES) -l$(NUM_CORES)
@ -84,72 +76,29 @@ override CPPFLAGS := -I./src/ -D_GNU_SOURCE=1 \
LIBS = -lm LIBS = -lm
### lua # ### lua
override CFLAGS += $(shell "$(PKG_CONFIG)" --cflags $(LUA_VERSION)) # override CFLAGS += $(shell "$(PKG_CONFIG)" --cflags $(LUA_VERSION))
LIBS += $(shell "$(PKG_CONFIG)" --libs $(LUA_VERSION)) # LIBS += $(shell "$(PKG_CONFIG)" --libs $(LUA_VERSION))
### debugger ### debugger
override CFLAGS += $(shell "$(PKG_CONFIG)" --cflags readline) override CFLAGS += $(shell "$(PKG_CONFIG)" --cflags readline)
LIBS += $(shell "$(PKG_CONFIG)" --libs 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 .PHONY: all clean clean-all pretty-code install mrproper
all: $(TARGETS) 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 # Binaries
$(TARGETS): libx48ng.a: $(DOTOS)
$(CC) $^ -o $@ $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(LIBS) ar rcs $@ $^
# Cleaning # Cleaning
clean: clean:
rm -f src/*.o src/legacy_tools/*.o src/*.dep.mk src/legacy_tools/*.dep.mk rm -f src/*.o
mrproper: clean mrproper: clean
rm -f $(TARGETS) rm -f $(TARGETS)
make -C dist/ROMs mrproper # make -C dist/ROMs mrproper
clean-all: mrproper clean-all: mrproper
@ -158,32 +107,32 @@ pretty-code:
clang-format -i src/*.c src/*.h src/legacy_tools/*.c clang-format -i src/*.c src/*.h src/legacy_tools/*.c
# Installing # Installing
get-roms: # get-roms:
make -C dist/ROMs # make -C dist/ROMs
dist/config.lua: dist/x48ng # dist/config.lua: dist/x48ng
$^ --print-config > $@ # $^ --print-config > $@
install: all dist/config.lua # install: all dist/config.lua
install -m 755 -d -- $(DESTDIR)$(PREFIX)/bin # install -m 755 -d -- $(DESTDIR)$(PREFIX)/bin
install -c -m 755 dist/x48ng $(DESTDIR)$(PREFIX)/bin/x48ng # install -c -m 755 dist/x48ng $(DESTDIR)$(PREFIX)/bin/x48ng
install -m 755 -d -- $(DESTDIR)$(PREFIX)/share/x48ng # install -m 755 -d -- $(DESTDIR)$(PREFIX)/share/x48ng
install -c -m 644 dist/hplogo.png $(DESTDIR)$(PREFIX)/share/x48ng/hplogo.png # install -c -m 644 dist/hplogo.png $(DESTDIR)$(PREFIX)/share/x48ng/hplogo.png
cp -R dist/ROMs/ $(DESTDIR)$(PREFIX)/share/x48ng/ # 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 # 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 # chmod 755 $(DESTDIR)$(PREFIX)/share/x48ng/setup-x48ng-home.sh
install -m 755 -d -- $(DESTDIR)$(PREFIX)/libexec # 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-dump2rom $(DESTDIR)$(PREFIX)/libexec/x48ng-dump2rom
install -c -m 755 dist/x48ng-checkrom $(DESTDIR)$(PREFIX)/libexec/x48ng-checkrom # install -c -m 755 dist/x48ng-checkrom $(DESTDIR)$(PREFIX)/libexec/x48ng-checkrom
install -m 755 -d -- $(DESTDIR)$(MANDIR)/man1 # 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 # sed "s|@VERSION@|$(VERSION_MAJOR).$(VERSION_MINOR).$(PATCHLEVEL)|g" dist/x48ng.man.1 > $(DESTDIR)$(MANDIR)/man1/x48ng.1
install -m 755 -d -- $(DESTDIR)$(DOCDIR) # install -m 755 -d -- $(DESTDIR)$(DOCDIR)
cp -R AUTHORS LICENSE README* doc* romdump/ $(DESTDIR)$(DOCDIR) # cp -R AUTHORS LICENSE README* doc* romdump/ $(DESTDIR)$(DOCDIR)
install -c -m 644 dist/config.lua $(DESTDIR)$(DOCDIR)/config.lua # install -c -m 644 dist/config.lua $(DESTDIR)$(DOCDIR)/config.lua
install -m 755 -d -- $(DESTDIR)$(PREFIX)/share/applications # install -m 755 -d -- $(DESTDIR)$(PREFIX)/share/applications
sed "s|@PREFIX@|$(PREFIX)|g" dist/x48ng.desktop > $(DESTDIR)$(PREFIX)/share/applications/x48ng.desktop # sed "s|@PREFIX@|$(PREFIX)|g" dist/x48ng.desktop > $(DESTDIR)$(PREFIX)/share/applications/x48ng.desktop

39
dist/config.lua vendored
View file

@ -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"
--------------------------------------------------------------------------------

BIN
dist/hplogo.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

9
dist/x48ng.desktop vendored
View file

@ -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;

218
dist/x48ng.man.1 vendored
View file

@ -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 <path> \-\-config=<path> use <path> as x48ng's config file (default: ~/.config/x48ng/config.lua)
.br
\-\-config\-dir=<path> use <path> as x48ng's home (default: ~/.config/x48ng/)
.br
\-\-rom=<filename> use <filename> (absolute or relative to <config\-dir>) as ROM (default: rom)
.br
\-\-ram=<filename> use <filename> (absolute or relative to <config\-dir>) as RAM (default: ram)
.br
\-\-state=<filename> use <filename> (absolute or relative to <config\-dir>) as STATE (default: hp48)
.br
\-\-port1=<filename> use <filename> (absolute or relative to <config\-dir>) as PORT1 (default: port1)
.br
\-\-port2=<filename> use <filename> (absolute or relative to <config\-dir>) as PORT2 (default: port2)
.br
\-\-serial\-line=<path> use <path> 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=<float> scale the SDL2 UI by <float>
.br
\-\-netbook make the UI horizontal (default: false)
.br
\-\-visual=<X visual> use visual <X visual> (default: default), possible values: <default | staticgray | staticcolor | truecolor | grayscale | pseudocolor | directcolor | 0xnn | nn>
.br
\-\-small\-font=<fontname> use <fontname> as small font
.br
\-\-medium\-font=<fontname> use <fontname> as medium font
.br
\-\-large\-font=<fontname> use <fontname> as large font
.br
\-\-connection\-font=<fontname> use <fontname> 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 <gam3@gam3.net>

View file

@ -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.

View file

@ -1,230 +0,0 @@
2011-08-08 "G. Allen Morris III" <gam3@gam3.net> 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" <gam3@gam3.net> 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" <gam3@gam3.net> release 0.6.2
* remove setlocal code that was causing a bug.
* removed some debugging code.
2009-06-31 "G. Allen Morris III" <gam3@gam3.net> release 0.6.1
* Fix to XShm to solve the 'LCD' Scramble problem.
2006-04-20 "G. Allen Morris III" <gam3@gam3.net>
* 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" <gam3@gam3.net>
* 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" <gam3@gam3.net>
* added patch [000390] time.h compile bug
* added patch [000391] Arrow key repeat patch
* added ChangeLog file
2005-03-18 "G. Allen Morris III" <gam3@gam3.net>
* 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 <robert@Sneezy.net.ut.ee>
- 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

View file

@ -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'.

View file

@ -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 <robert@Sneezy.net.ut.ee>
- 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 <robert@Sneezy.net.ut.ee>
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 <bson@ai.mit.edu>
-- Mika Heiskanen <mheiskan@vipunen.hut.fi>
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 <lkv@mania.robin.de> 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 <filename>', where <filename> 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.

View file

@ -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.

View file

@ -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)

Binary file not shown.

View file

@ -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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

View file

@ -1,752 +0,0 @@
#include <errno.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdbool.h>
#include <assert.h>
#include <getopt.h>
#include <lua.h>
#include <lauxlib.h>
#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=<path> use <path> as x48ng's config file (default: "
"$XDG_CONFIG_HOME/x48ng/config.lua)\n"
" --config-dir=<path> use <path> as x48ng's home (default: "
"$XDG_CONFIG_HOME/x48ng/)\n"
" --rom=<filename> use <filename> (absolute or relative to "
"<config-dir>) as ROM (default: rom)\n"
" --ram=<filename> use <filename> (absolute or relative to "
"<config-dir>) as RAM (default: ram)\n"
" --state=<filename> use <filename> (absolute or relative "
"to <config-dir>) as STATE (default: hp48)\n"
" --port1=<filename> use <filename> (absolute or relative "
"to <config-dir>) as PORT1 (default: port1)\n"
" --port2=<filename> use <filename> (absolute or relative "
"to <config-dir>) as PORT2 (default: port2)\n"
" --serial-line=<path> use <path> 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=<number> make the UI scale <number> times "
"(default: 1.0)\n"
" --netbook make the UI horizontal (default: "
"false)\n"
" --visual=<X visual> use x11 visual <X visual> (default: "
"default), possible values: "
"<default | staticgray | staticcolor | truecolor | grayscale | "
"pseudocolor | directcolor | 0xnn | nn>\n"
" --small-font=<font> use <X font name> as small "
"font (default: %s)\n"
" --medium-font=<font> use <X font name> as medium "
"font (default: %s)\n"
" --large-font=<font> use <X font name> as large "
"font (default: %s)\n"
" --connection-font=<font> use <X font name> 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 );
}

View file

@ -1,68 +0,0 @@
#ifndef _CONFIG_H
#define _CONFIG_H 1
#include <stdbool.h>
#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 */

View file

@ -7,11 +7,11 @@
#include <readline/history.h> #include <readline/history.h>
#include <readline/readline.h> #include <readline/readline.h>
#include "config.h" //#include "config.h"
#include "emulator.h" #include "emulator.h"
#include "emulator_for_debugger.h" #include "emulator_for_debugger.h"
#include "romio.h" #include "romio.h"
#include "ui.h" /* ui_update_LCD(); */ //#include "ui.h" /* ui_update_LCD(); */
#include "debugger.h" #include "debugger.h"
#define MAX_ARGS 16 #define MAX_ARGS 16
@ -3529,7 +3529,7 @@ static void cmd_load( int argc, char** argv )
free( tmp_saturn.port2 ); free( tmp_saturn.port2 );
/* After reloading state we need to refresh the UI's LCD */ /* After reloading state we need to refresh the UI's LCD */
ui_update_LCD(); /* ui_update_LCD(); */
} else { } else {
printf( "Loading emulator-state from files failed.\n" ); printf( "Loading emulator-state from files failed.\n" );
if ( saturn.rom ) if ( saturn.rom )
@ -3572,7 +3572,7 @@ static void cmd_exit( int argc, char** argv )
save_before_exit = false; save_before_exit = false;
// please_exit = true; // 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; save_before_exit = true;
// please_exit = true; // please_exit = true;
close_and_exit(); /* close_and_exit(); */
} }
} }
@ -4064,35 +4064,35 @@ int debug( void )
/* /*
* do we want to debug ??? * do we want to debug ???
*/ */
if ( !config.useDebugger ) { /* if ( !config.useDebugger ) { */
if ( enter_debugger & ILLEGAL_INSTRUCTION ) { /* if ( enter_debugger & ILLEGAL_INSTRUCTION ) { */
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "reset (illegal instruction at 0x%.5lX)\n", saturn.PC ); /* fprintf( stderr, "reset (illegal instruction at 0x%.5lX)\n", saturn.PC ); */
saturn.PC = 0; /* saturn.PC = 0; */
} /* } */
if ( enter_debugger & USER_INTERRUPT ) /* if ( enter_debugger & USER_INTERRUPT ) */
if ( config.verbose ) /* if ( config.verbose ) */
printf( "usnterrupt (SIGINT) ignored\n" ); /* printf( "usnterrupt (SIGINT) ignored\n" ); */
// please_exit = true; /* // please_exit = true; */
if ( enter_debugger & BREAKPOINT_HIT ) /* if ( enter_debugger & BREAKPOINT_HIT ) */
if ( config.verbose ) /* if ( config.verbose ) */
printf( "breakpoint hit at 0x%.5lX ignored\n", saturn.PC ); /* printf( "breakpoint hit at 0x%.5lX ignored\n", saturn.PC ); */
if ( enter_debugger & TRAP_INSTRUCTION ) /* if ( enter_debugger & TRAP_INSTRUCTION ) */
if ( config.verbose ) /* if ( config.verbose ) */
printf( "trap instruction at 0x%.5lX ignored\n", saturn.PC ); /* printf( "trap instruction at 0x%.5lX ignored\n", saturn.PC ); */
enter_debugger = 0; /* enter_debugger = 0; */
return 0; /* return 0; */
} /* } */
/* /*
* update the lcd if necessary * update the lcd if necessary
*/ */
if ( device.display_touched ) { if ( device.display_touched ) {
device.display_touched = 0; device.display_touched = 0;
ui_update_LCD(); /* ui_update_LCD(); */
} }
/* /*

View file

@ -6,8 +6,8 @@
#include "debugger.h" /* enter_debugger, TRAP_INSTRUCTION, ILLEGAL_INSTRUCTION */ #include "debugger.h" /* enter_debugger, TRAP_INSTRUCTION, ILLEGAL_INSTRUCTION */
#include "emulator.h" #include "emulator.h"
#include "emulator_inner.h" #include "emulator_inner.h"
#include "config.h" /* throttle */ //#include "config.h" /* throttle */
#include "ui.h" /* ui_get_event(); ui_adjust_contrast(); ui_update_LCD(); ui_draw_annunc(); */ //#include "ui.h" /* ui_get_event(); ui_adjust_contrast(); ui_update_LCD(); ui_draw_annunc(); */
#include "debugger.h" /* in_debugger, enter_debugger */ #include "debugger.h" /* in_debugger, enter_debugger */
@ -1252,7 +1252,7 @@ static bool step_instruction_080( void )
break; break;
case 7: /* SHUTDN */ case 7: /* SHUTDN */
saturn.PC += 3; saturn.PC += 3;
if ( config.inhibit_shutdown ) /* if ( config.inhibit_shutdown ) */
break; break;
/***************************/ /***************************/
@ -1297,7 +1297,7 @@ static bool step_instruction_080( void )
if ( device.display_touched ) { if ( device.display_touched ) {
device.display_touched = 0; device.display_touched = 0;
ui_refresh_LCD(); //ui_refresh_LCD();
} }
stop_timer( RUN_TIMER ); stop_timer( RUN_TIMER );
@ -1318,7 +1318,7 @@ static bool step_instruction_080( void )
if ( sigalarm_triggered ) { if ( sigalarm_triggered ) {
sigalarm_triggered = false; sigalarm_triggered = false;
ui_refresh_LCD(); /* ui_refresh_LCD(); */
ticks = get_t1_t2(); ticks = get_t1_t2();
if ( saturn.t2_ctrl & 0x01 ) if ( saturn.t2_ctrl & 0x01 )
@ -1328,7 +1328,7 @@ static bool step_instruction_080( void )
set_t1 = ticks.t1_ticks; set_t1 = ticks.t1_ticks;
interrupt_called = false; interrupt_called = false;
ui_get_event(); /* ui_get_event(); */
if ( interrupt_called ) if ( interrupt_called )
wake = true; wake = true;
@ -2857,17 +2857,17 @@ void schedule( void )
// TODO: move this out into ui_*.c // TODO: move this out into ui_*.c
if ( device.display_touched > 0 && device.display_touched-- == 1 ) { if ( device.display_touched > 0 && device.display_touched-- == 1 ) {
device.display_touched = 0; device.display_touched = 0;
ui_update_LCD(); // ui_update_LCD();
} }
if ( device.display_touched > 0 ) if ( device.display_touched > 0 )
device_check = true; device_check = true;
if ( device.contrast_touched ) { if ( device.contrast_touched ) {
device.contrast_touched = false; device.contrast_touched = false;
ui_adjust_contrast(); /* ui_adjust_contrast(); */
} }
if ( device.ann_touched ) { if ( device.ann_touched ) {
device.ann_touched = false; device.ann_touched = false;
ui_draw_annunc(); /* ui_draw_annunc(); */
} }
/* serial */ /* serial */
@ -3011,8 +3011,8 @@ void schedule( void )
if ( sigalarm_triggered ) { if ( sigalarm_triggered ) {
sigalarm_triggered = false; sigalarm_triggered = false;
ui_refresh_LCD(); /* ui_refresh_LCD(); */
ui_get_event(); /* ui_get_event(); */
} }
} }

View file

@ -10,7 +10,7 @@
#include "emulator.h" #include "emulator.h"
#include "emulator_inner.h" #include "emulator_inner.h"
#include "romio.h" #include "romio.h"
#include "config.h" /* #include "config.h" */
#define X48_MAGIC 0x48503438 #define X48_MAGIC 0x48503438
#define NB_CONFIG 8 #define NB_CONFIG 8
@ -18,6 +18,8 @@
#define RAM_SIZE_SX 0x10000 #define RAM_SIZE_SX 0x10000
#define RAM_SIZE_GX 0x40000 #define RAM_SIZE_GX 0x40000
#define MAX_LENGTH_FILENAME 1024
// bool please_exit = false; // bool please_exit = false;
bool save_before_exit = true; bool save_before_exit = true;
@ -148,8 +150,8 @@ int read_8( FILE* fp, word_8* var )
unsigned char tmp; unsigned char tmp;
if ( fread( &tmp, 1, 1, fp ) != 1 ) { if ( fread( &tmp, 1, 1, fp ) != 1 ) {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "can\'t read word_8\n" ); /* fprintf( stderr, "can\'t read word_8\n" ); */
return 0; return 0;
} }
*var = tmp; *var = tmp;
@ -161,8 +163,8 @@ int read_char( FILE* fp, char* var )
char tmp; char tmp;
if ( fread( &tmp, 1, 1, fp ) != 1 ) { if ( fread( &tmp, 1, 1, fp ) != 1 ) {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "can\'t read char\n" ); /* fprintf( stderr, "can\'t read char\n" ); */
return 0; return 0;
} }
*var = tmp; *var = tmp;
@ -174,8 +176,8 @@ int read_16( FILE* fp, word_16* var )
unsigned char tmp[ 2 ]; unsigned char tmp[ 2 ];
if ( fread( &tmp[ 0 ], 1, 2, fp ) != 2 ) { if ( fread( &tmp[ 0 ], 1, 2, fp ) != 2 ) {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "can\'t read word_16\n" ); /* fprintf( stderr, "can\'t read word_16\n" ); */
return 0; return 0;
} }
*var = tmp[ 0 ] << 8; *var = tmp[ 0 ] << 8;
@ -188,8 +190,8 @@ int read_32( FILE* fp, word_32* var )
unsigned char tmp[ 4 ]; unsigned char tmp[ 4 ];
if ( fread( &tmp[ 0 ], 1, 4, fp ) != 4 ) { if ( fread( &tmp[ 0 ], 1, 4, fp ) != 4 ) {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "can\'t read word_32\n" ); /* fprintf( stderr, "can\'t read word_32\n" ); */
return 0; return 0;
} }
*var = tmp[ 0 ] << 24; *var = tmp[ 0 ] << 24;
@ -204,8 +206,8 @@ int read_u_long( FILE* fp, unsigned long* var )
unsigned char tmp[ 4 ]; unsigned char tmp[ 4 ];
if ( fread( &tmp[ 0 ], 1, 4, fp ) != 4 ) { if ( fread( &tmp[ 0 ], 1, 4, fp ) != 4 ) {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "can\'t read unsigned long\n" ); /* fprintf( stderr, "can\'t read unsigned long\n" ); */
return 0; return 0;
} }
*var = tmp[ 0 ] << 24; *var = tmp[ 0 ] << 24;
@ -390,14 +392,12 @@ int read_mem_file( char* name, word_4* mem, int size )
int i, j; int i, j;
if ( NULL == ( fp = fopen( name, "r" ) ) ) { if ( NULL == ( fp = fopen( name, "r" ) ) ) {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "ct open %s\n", name ); /* fprintf( stderr, "ct open %s\n", name ); */
return 0; return 0;
} }
if ( stat( name, &st ) < 0 ) { if ( stat( name, &st ) < 0 ) {
if ( config.verbose )
fprintf( stderr, "can\'t stat %s\n", name );
return 0; 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 * size is same as memory size, old version file
*/ */
if ( fread( mem, 1, ( size_t )size, fp ) != ( unsigned long )size ) { if ( fread( mem, 1, ( size_t )size, fp ) != ( unsigned long )size ) {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "can\'t read %s\n", name ); /* fprintf( stderr, "can\'t read %s\n", name ); */
fclose( fp ); fclose( fp );
return 0; return 0;
} }
@ -417,8 +417,8 @@ int read_mem_file( char* name, word_4* mem, int size )
*/ */
if ( st.st_size != size / 2 ) { if ( st.st_size != size / 2 ) {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "strange size %s, expected %d, found %ld\n", name, size / 2, st.st_size ); /* fprintf( stderr, "strange size %s, expected %d, found %ld\n", name, size / 2, st.st_size ); */
fclose( fp ); fclose( fp );
return 0; 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 ) ) ) { if ( NULL == ( tmp_mem = ( word_8* )malloc( ( size_t )st.st_size ) ) ) {
for ( i = 0, j = 0; i < size / 2; i++ ) { for ( i = 0, j = 0; i < size / 2; i++ ) {
if ( 1 != fread( &byte, 1, 1, fp ) ) { if ( 1 != fread( &byte, 1, 1, fp ) ) {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "can\'t read %s\n", name ); /* fprintf( stderr, "can\'t read %s\n", name ); */
fclose( fp ); fclose( fp );
return 0; return 0;
} }
@ -436,8 +436,8 @@ int read_mem_file( char* name, word_4* mem, int size )
} }
} else { } else {
if ( fread( tmp_mem, 1, ( size_t )size / 2, fp ) != ( unsigned long )( size / 2 ) ) { if ( fread( tmp_mem, 1, ( size_t )size / 2, fp ) != ( unsigned long )( size / 2 ) ) {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "can\'t read %s\n", name ); /* fprintf( stderr, "can\'t read %s\n", name ); */
fclose( fp ); fclose( fp );
free( tmp_mem ); free( tmp_mem );
return 0; return 0;
@ -454,13 +454,13 @@ int read_mem_file( char* name, word_4* mem, int size )
fclose( fp ); fclose( fp );
if ( config.verbose ) /* if ( config.verbose ) */
printf( "read %s\n", name ); /* printf( "read %s\n", name ); */
return 1; 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; */ /* unsigned long v1, v2; */
int i; int i;
@ -476,8 +476,8 @@ int read_files( void )
if ( !read_rom_file( normalized_rom_path, &saturn.rom, &rom_size ) ) if ( !read_rom_file( normalized_rom_path, &saturn.rom, &rom_size ) )
return 0; return 0;
if ( config.verbose ) /* if ( config.verbose ) */
printf( "read %s\n", normalized_rom_path ); /* printf( "read %s\n", normalized_rom_path ); */
rom_is_new = false; rom_is_new = false;
@ -485,8 +485,8 @@ int read_files( void )
/* 2. read saved state from ~/.x48ng/state into fp */ /* 2. read saved state from ~/.x48ng/state into fp */
/**************************************************/ /**************************************************/
if ( NULL == ( fp = fopen( normalized_state_path, "r" ) ) ) { if ( NULL == ( fp = fopen( normalized_state_path, "r" ) ) ) {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "can\'t open %s\n", normalized_state_path ); /* fprintf( stderr, "can\'t open %s\n", normalized_state_path ); */
return 0; return 0;
} }
@ -509,8 +509,8 @@ int read_files( void )
read_version = true; read_version = true;
for ( i = 0; i < 4; i++ ) { for ( i = 0; i < 4; i++ ) {
if ( !read_char( fp, &saturn.version[ i ] ) ) { if ( !read_char( fp, &saturn.version[ i ] ) ) {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "can\'t read version\n" ); /* fprintf( stderr, "can\'t read version\n" ); */
read_version = false; read_version = false;
} }
} }
@ -528,11 +528,11 @@ int read_files( void )
* try to read latest version file * try to read latest version file
*/ */
if ( !read_state_file( fp ) ) { if ( !read_state_file( fp ) ) {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "can't handle %s\n", normalized_state_path ); /* fprintf( stderr, "can't handle %s\n", normalized_state_path ); */
init_saturn(); init_saturn();
} else if ( config.verbose ) } /* else if ( config.verbose ) */
printf( "read %s\n", normalized_state_path ); /* printf( "read %s\n", normalized_state_path ); */
} }
} }
fclose( fp ); fclose( fp );
@ -545,8 +545,8 @@ int read_files( void )
saturn.ram = ( word_4* )NULL; saturn.ram = ( word_4* )NULL;
if ( NULL == ( saturn.ram = ( word_4* )malloc( ram_size ) ) ) { if ( NULL == ( saturn.ram = ( word_4* )malloc( ram_size ) ) ) {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "can\'t malloc RAM[%d]\n", ram_size ); /* fprintf( stderr, "can\'t malloc RAM[%d]\n", ram_size ); */
exit( 1 ); exit( 1 );
} }
@ -554,8 +554,8 @@ int read_files( void )
/* 3. read RAM from ~/.x48ng/ram into saturn.ram */ /* 3. read RAM from ~/.x48ng/ram into saturn.ram */
/*************************************************/ /*************************************************/
if ( ( fp = fopen( normalized_ram_path, "r" ) ) == NULL ) { if ( ( fp = fopen( normalized_ram_path, "r" ) ) == NULL ) {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "can\'t open %s\n", normalized_ram_path ); /* fprintf( stderr, "can\'t open %s\n", normalized_ram_path ); */
return 0; return 0;
} }
if ( !read_mem_file( normalized_ram_path, saturn.ram, ram_size ) ) 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; port1_size = 2 * st.st_size;
if ( ( port1_size == 0x10000 ) || ( port1_size == 0x40000 ) ) { if ( ( port1_size == 0x10000 ) || ( port1_size == 0x40000 ) ) {
if ( NULL == ( saturn.port1 = ( word_4* )malloc( port1_size ) ) ) { if ( NULL == ( saturn.port1 = ( word_4* )malloc( port1_size ) ) ) {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "can\'t malloc PORT1[%ld]\n", port1_size ); /* fprintf( stderr, "can\'t malloc PORT1[%ld]\n", port1_size ); */
} else if ( !read_mem_file( normalized_port1_path, saturn.port1, port1_size ) ) { } else if ( !read_mem_file( normalized_port1_path, saturn.port1, port1_size ) ) {
port1_size = 0; port1_size = 0;
port1_is_ram = false; port1_is_ram = false;
@ -611,8 +611,8 @@ int read_files( void )
if ( ( opt_gx && ( ( port2_size % 0x40000 ) == 0 ) ) || if ( ( opt_gx && ( ( port2_size % 0x40000 ) == 0 ) ) ||
( !opt_gx && ( ( port2_size == 0x10000 ) || ( port2_size == 0x40000 ) ) ) ) { ( !opt_gx && ( ( port2_size == 0x10000 ) || ( port2_size == 0x40000 ) ) ) ) {
if ( NULL == ( saturn.port2 = ( word_4* )malloc( port2_size ) ) ) { if ( NULL == ( saturn.port2 = ( word_4* )malloc( port2_size ) ) ) {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "can\'t malloc PORT2[%ld]\n", port2_size ); /* fprintf( stderr, "can\'t malloc PORT2[%ld]\n", port2_size ); */
} else if ( !read_mem_file( normalized_port2_path, saturn.port2, port2_size ) ) { } else if ( !read_mem_file( normalized_port2_path, saturn.port2, port2_size ) ) {
port2_size = 0; port2_size = 0;
port2_is_ram = false; port2_is_ram = false;
@ -647,8 +647,8 @@ int write_8( FILE* fp, word_8* var )
tmp = *var; tmp = *var;
if ( fwrite( &tmp, 1, 1, fp ) != 1 ) { if ( fwrite( &tmp, 1, 1, fp ) != 1 ) {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "can\'t write word_8\n" ); /* fprintf( stderr, "can\'t write word_8\n" ); */
return 0; return 0;
} }
return 1; return 1;
@ -660,8 +660,8 @@ int write_char( FILE* fp, char* var )
tmp = *var; tmp = *var;
if ( fwrite( &tmp, 1, 1, fp ) != 1 ) { if ( fwrite( &tmp, 1, 1, fp ) != 1 ) {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "can\'t write char\n" ); /* fprintf( stderr, "can\'t write char\n" ); */
return 0; return 0;
} }
return 1; return 1;
@ -674,8 +674,8 @@ int write_16( FILE* fp, word_16* var )
tmp[ 0 ] = ( *var >> 8 ) & 0xff; tmp[ 0 ] = ( *var >> 8 ) & 0xff;
tmp[ 1 ] = *var & 0xff; tmp[ 1 ] = *var & 0xff;
if ( fwrite( &tmp[ 0 ], 1, 2, fp ) != 2 ) { if ( fwrite( &tmp[ 0 ], 1, 2, fp ) != 2 ) {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "can\'t write word_16\n" ); /* fprintf( stderr, "can\'t write word_16\n" ); */
return 0; return 0;
} }
return 1; return 1;
@ -690,8 +690,8 @@ int write_32( FILE* fp, word_32* var )
tmp[ 2 ] = ( *var >> 8 ) & 0xff; tmp[ 2 ] = ( *var >> 8 ) & 0xff;
tmp[ 3 ] = *var & 0xff; tmp[ 3 ] = *var & 0xff;
if ( fwrite( &tmp[ 0 ], 1, 4, fp ) != 4 ) { if ( fwrite( &tmp[ 0 ], 1, 4, fp ) != 4 ) {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "can\'t write word_32\n" ); /* fprintf( stderr, "can\'t write word_32\n" ); */
return 0; return 0;
} }
return 1; return 1;
@ -706,8 +706,8 @@ int write_u_long( FILE* fp, unsigned long* var )
tmp[ 2 ] = ( *var >> 8 ) & 0xff; tmp[ 2 ] = ( *var >> 8 ) & 0xff;
tmp[ 3 ] = *var & 0xff; tmp[ 3 ] = *var & 0xff;
if ( fwrite( &tmp[ 0 ], 1, 4, fp ) != 4 ) { if ( fwrite( &tmp[ 0 ], 1, 4, fp ) != 4 ) {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "can\'t write unsigned long\n" ); /* fprintf( stderr, "can\'t write unsigned long\n" ); */
return 0; return 0;
} }
return 1; return 1;
@ -721,8 +721,8 @@ int write_mem_file( char* name, word_4* mem, int size )
int i, j; int i, j;
if ( NULL == ( fp = fopen( name, "w" ) ) ) { if ( NULL == ( fp = fopen( name, "w" ) ) ) {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "can\'t open %s\n", name ); /* fprintf( stderr, "can\'t open %s\n", name ); */
return 0; return 0;
} }
@ -731,8 +731,8 @@ int write_mem_file( char* name, word_4* mem, int size )
byte = ( mem[ j++ ] & 0x0f ); byte = ( mem[ j++ ] & 0x0f );
byte |= ( mem[ j++ ] << 4 ) & 0xf0; byte |= ( mem[ j++ ] << 4 ) & 0xf0;
if ( 1 != fwrite( &byte, 1, 1, fp ) ) { if ( 1 != fwrite( &byte, 1, 1, fp ) ) {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "can\'t write %s\n", name ); /* fprintf( stderr, "can\'t write %s\n", name ); */
fclose( fp ); fclose( fp );
return 0; 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 ( fwrite( tmp_mem, 1, ( size_t )size / 2, fp ) != ( unsigned long )size / 2 ) {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "can\'t write %s\n", name ); /* fprintf( stderr, "can\'t write %s\n", name ); */
fclose( fp ); fclose( fp );
free( tmp_mem ); free( tmp_mem );
return 0; return 0;
@ -756,8 +756,8 @@ int write_mem_file( char* name, word_4* mem, int size )
fclose( fp ); fclose( fp );
if ( config.verbose ) /* if ( config.verbose ) */
printf( "wrote %s\n", name ); /* printf( "wrote %s\n", name ); */
return 1; return 1;
} }
@ -768,8 +768,8 @@ int write_state_file( char* filename )
FILE* fp; FILE* fp;
if ( ( fp = fopen( filename, "w" ) ) == NULL ) { if ( ( fp = fopen( filename, "w" ) ) == NULL ) {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "can\'t open %s, no saving done\n", filename ); /* fprintf( stderr, "can\'t open %s, no saving done\n", filename ); */
return 0; return 0;
} }
@ -868,58 +868,58 @@ int write_state_file( char* filename )
fclose( fp ); fclose( fp );
if ( config.verbose ) /* if ( config.verbose ) */
printf( "wrote %s\n", filename ); /* printf( "wrote %s\n", filename ); */
return 1; 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; struct stat st;
bool make_dir = false; /* bool make_dir = false; */
int ram_size = opt_gx ? RAM_SIZE_GX : RAM_SIZE_SX; int ram_size = opt_gx ? RAM_SIZE_GX : RAM_SIZE_SX;
if ( stat( normalized_config_path, &st ) == -1 ) { /* if ( stat( normalized_config_path, &st ) == -1 ) { */
if ( errno == ENOENT ) { /* if ( errno == ENOENT ) { */
make_dir = true; /* make_dir = true; */
} else { /* } else { */
if ( config.verbose ) /* /\* if ( config.verbose ) *\/ */
fprintf( stderr, "can\'t stat %s, saving to /tmp\n", normalized_config_path ); /* /\* fprintf( stderr, "can\'t stat %s, saving to /tmp\n", normalized_config_path ); *\/ */
strcpy( normalized_config_path, "/tmp" ); /* strcpy( normalized_config_path, "/tmp" ); */
} /* } */
} else { /* } else { */
if ( !S_ISDIR( st.st_mode ) ) { /* if ( !S_ISDIR( st.st_mode ) ) { */
if ( config.verbose ) /* /\* if ( config.verbose ) *\/ */
fprintf( stderr, "%s is no directory, saving to /tmp\n", normalized_config_path ); /* /\* fprintf( stderr, "%s is no directory, saving to /tmp\n", normalized_config_path ); *\/ */
strcpy( normalized_config_path, "/tmp" ); /* strcpy( normalized_config_path, "/tmp" ); */
} /* } */
} /* } */
if ( make_dir ) { /* if ( make_dir ) { */
if ( mkdir( normalized_config_path, 0777 ) == -1 ) { /* if ( mkdir( normalized_config_path, 0777 ) == -1 ) { */
if ( config.verbose ) /* /\* if ( config.verbose ) *\/ */
fprintf( stderr, "can\'t mkdir %s, saving to /tmp\n", normalized_config_path ); /* /\* fprintf( stderr, "can\'t mkdir %s, saving to /tmp\n", normalized_config_path ); *\/ */
strcpy( normalized_config_path, "/tmp" ); /* strcpy( normalized_config_path, "/tmp" ); */
} /* } */
} /* } */
if ( !write_state_file( normalized_state_path ) ) /* if ( !write_state_file( normalized_state_path ) ) */
return 0; /* return 0; */
rom_is_new = make_dir; /* rom_is_new = make_dir; */
if ( rom_is_new ) { /* if ( rom_is_new ) { */
char new_rom_path[ MAX_LENGTH_FILENAME ]; /* char new_rom_path[ MAX_LENGTH_FILENAME ]; */
strcpy( new_rom_path, normalized_config_path ); /* strcpy( new_rom_path, normalized_config_path ); */
strcat( new_rom_path, "rom" ); /* strcat( new_rom_path, "rom" ); */
if ( !write_mem_file( new_rom_path, saturn.rom, rom_size ) ) /* if ( !write_mem_file( new_rom_path, saturn.rom, rom_size ) ) */
return 0; /* return 0; */
if ( config.verbose ) /* /\* if ( config.verbose ) *\/ */
printf( "wrote %s\n", new_rom_path ); /* /\* printf( "wrote %s\n", new_rom_path ); *\/ */
} /* } */
if ( !write_mem_file( normalized_ram_path, saturn.ram, ram_size ) ) if ( !write_mem_file( normalized_ram_path, saturn.ram, ram_size ) )
return 0; return 0;
@ -944,16 +944,16 @@ int read_rom( const char* fname )
if ( !read_rom_file( fname, &saturn.rom, &rom_size ) ) if ( !read_rom_file( fname, &saturn.rom, &rom_size ) )
return 0; return 0;
if ( config.verbose ) /* if ( config.verbose ) */
printf( "read %s\n", fname ); /* printf( "read %s\n", fname ); */
dev_memory_init(); dev_memory_init();
ram_size = opt_gx ? RAM_SIZE_GX : RAM_SIZE_SX; ram_size = opt_gx ? RAM_SIZE_GX : RAM_SIZE_SX;
if ( NULL == ( saturn.ram = ( word_4* )malloc( ram_size ) ) ) { if ( NULL == ( saturn.ram = ( word_4* )malloc( ram_size ) ) ) {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "can\'t malloc RAM\n" ); /* fprintf( stderr, "can\'t malloc RAM\n" ); */
return 0; return 0;
} }
@ -999,22 +999,32 @@ void init_display( void )
display.contrast |= ( ( saturn.disp_test & 0x1 ) << 4 ); 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; // please_exit = false;
save_before_exit = true; save_before_exit = true;
/* If files are successfully read => return and let's go */ /* If files are successfully read => return and let's go */
if ( read_files() ) { if ( read_files(n_rom_path, n_ram_path, n_state_path, n_port1_path, n_port2_path) ) {
if ( config.resetOnStartup ) /* if ( config.resetOnStartup ) */
saturn.PC = 0x00000; /* saturn.PC = 0x00000; */
} else { } else {
/* if files were not readable => initialize */ /* if files were not readable => initialize */
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "initialization of %s\n", normalized_config_path ); /* fprintf( stderr, "initialization of %s\n", n_config_path ); */
init_saturn(); init_saturn();
if ( !read_rom( normalized_rom_path ) ) if ( !read_rom( n_rom_path ) )
exit( 1 ); /* can't read ROM */ exit( 1 ); /* can't read ROM */
} }
@ -1022,8 +1032,8 @@ void start_emulator( void )
init_display(); init_display();
} }
void exit_emulator( void ) void exit_emulator( )
{ {
if ( save_before_exit ) if ( save_before_exit )
write_files(); write_files(normalized_rom_path, normalized_ram_path, normalized_state_path, normalized_port1_path, normalized_port2_path);
} }

View file

@ -7,8 +7,8 @@
#include "emulator.h" #include "emulator.h"
#include "emulator_inner.h" #include "emulator_inner.h"
#include "romio.h" #include "romio.h"
#include "config.h" /* #include "config.h" */
#include "ui.h" /* ui_disp_draw_nibble(); ui_menu_draw_nibble(); */ /* #include "ui.h" /\* ui_disp_draw_nibble(); ui_menu_draw_nibble(); *\/ */
#define MCTL_MMIO_SX 0 #define MCTL_MMIO_SX 0
#define MCTL_SysRAM_SX 1 #define MCTL_SysRAM_SX 1
@ -264,8 +264,8 @@ void write_dev_mem( long addr, int val )
device.t2_touched = true; device.t2_touched = true;
return; return;
default: default:
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "%.5lx: UNKNOWN DEVICE WRITE AT 0x%lx !!!\n", saturn.PC, addr ); /* fprintf( stderr, "%.5lx: UNKNOWN DEVICE WRITE AT 0x%lx !!!\n", saturn.PC, addr ); */
return; return;
} }
} }
@ -379,8 +379,8 @@ int read_dev_mem( long addr )
case 0x13f: case 0x13f:
return ( saturn.timer2 >> ( ( addr - 0x138 ) * 4 ) ) & 0xf; return ( saturn.timer2 >> ( ( addr - 0x138 ) * 4 ) ) & 0xf;
default: default:
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "%.5lx: UNKNOWN DEVICE READ AT 0x%lx !!!\n", saturn.PC, addr ); /* fprintf( stderr, "%.5lx: UNKNOWN DEVICE READ AT 0x%lx !!!\n", saturn.PC, addr ); */
return 0x00; return 0x00;
} }
} }
@ -469,14 +469,14 @@ void write_nibble_sx( long addr, int val )
if ( device.display_touched ) if ( device.display_touched )
return; return;
if ( addr >= display.disp_start && addr < display.disp_end ) /* if ( addr >= display.disp_start && addr < display.disp_end ) */
ui_disp_draw_nibble( addr, val ); /* ui_disp_draw_nibble( addr, val ); */
if ( display.lines == 63 ) if ( display.lines == 63 )
return; return;
if ( addr >= display.menu_start && addr < display.menu_end ) /* if ( addr >= display.menu_start && addr < display.menu_end ) */
ui_menu_draw_nibble( addr, val ); /* ui_menu_draw_nibble( addr, val ); */
} }
void write_nibble_gx( long addr, int 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 ) if ( device.display_touched )
return; return;
if ( addr >= display.disp_start && addr < display.disp_end ) /* if ( addr >= display.disp_start && addr < display.disp_end ) */
ui_disp_draw_nibble( addr, val ); /* ui_disp_draw_nibble( addr, val ); */
if ( display.lines == 63 ) if ( display.lines == 63 )
return; return;
if ( addr >= display.menu_start && addr < display.menu_end ) /* if ( addr >= display.menu_start && addr < display.menu_end ) */
ui_menu_draw_nibble( addr, val ); /* ui_menu_draw_nibble( addr, val ); */
} }
int read_nibble_sx( long addr ) int read_nibble_sx( long addr )

View file

@ -8,7 +8,7 @@
#include <unistd.h> #include <unistd.h>
#include "emulator_inner.h" /* saturn, do_interupt() */ #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 wire_fd;
static int ir_fd; static int ir_fd;
@ -40,7 +40,7 @@ int init_serial( void )
wire_fd = -1; wire_fd = -1;
ttyp = -1; ttyp = -1;
if ( config.useTerminal ) { /* if ( config.useTerminal ) { */
/* Unix98 PTY (Preferred) */ /* Unix98 PTY (Preferred) */
if ( ( wire_fd = open( "/dev/ptmx", O_RDWR | O_NONBLOCK, 0666 ) ) >= 0 ) { if ( ( wire_fd = open( "/dev/ptmx", O_RDWR | O_NONBLOCK, 0666 ) ) >= 0 ) {
grantpt( wire_fd ); grantpt( wire_fd );
@ -50,8 +50,8 @@ int init_serial( void )
exit( -1 ); exit( -1 );
} }
if ( ( ttyp = open( tty_dev_name, O_RDWR | O_NDELAY, 0666 ) ) >= 0 ) { if ( ( ttyp = open( tty_dev_name, O_RDWR | O_NDELAY, 0666 ) ) >= 0 ) {
if ( config.verbose ) /* if ( config.verbose ) */
printf( "wire connection on %s\n", tty_dev_name ); /* printf( "wire connection on %s\n", tty_dev_name ); */
wire_name = strdup( 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 ) { if ( ( wire_fd = open( tty_dev_name, O_RDWR | O_EXCL | O_NDELAY, 0666 ) ) >= 0 ) {
ttyp = wire_fd; ttyp = wire_fd;
sprintf( tty_dev_name, "/dev/tty%c%x", c, n ); sprintf( tty_dev_name, "/dev/tty%c%x", c, n );
if ( config.verbose ) /* if ( config.verbose ) */
printf( "wire connection on %s\n", tty_dev_name ); /* printf( "wire connection on %s\n", tty_dev_name ); */
wire_name = strdup( tty_dev_name ); wire_name = strdup( tty_dev_name );
break; break;
} }
@ -73,7 +73,7 @@ int init_serial( void )
c++; c++;
} while ( ( wire_fd < 0 ) && ( errno != ENOENT ) ); } while ( ( wire_fd < 0 ) && ( errno != ENOENT ) );
} }
} /* } */
if ( ttyp >= 0 ) { if ( ttyp >= 0 ) {
#if defined( TCSANOW ) #if defined( TCSANOW )
@ -82,8 +82,8 @@ int init_serial( void )
if ( ioctl( ttyp, TCGETS, ( char* )&ttybuf ) < 0 ) if ( ioctl( ttyp, TCGETS, ( char* )&ttybuf ) < 0 )
#endif #endif
{ {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "ioctl(wire, TCGETS) failed, errno = %d\n", errno ); /* fprintf( stderr, "ioctl(wire, TCGETS) failed, errno = %d\n", errno ); */
wire_fd = -1; wire_fd = -1;
ttyp = -1; ttyp = -1;
} }
@ -105,22 +105,22 @@ int init_serial( void )
if ( ioctl( ttyp, TCSETS, ( char* )&ttybuf ) < 0 ) if ( ioctl( ttyp, TCSETS, ( char* )&ttybuf ) < 0 )
#endif #endif
{ {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "ioctl(wire, TCSETS) failed, errno = %d\n", errno ); /* fprintf( stderr, "ioctl(wire, TCSETS) failed, errno = %d\n", errno ); */
wire_fd = -1; wire_fd = -1;
ttyp = -1; ttyp = -1;
} }
} }
ir_fd = -1; ir_fd = -1;
if ( config.useSerial ) { /* if ( config.useSerial ) { */
sprintf( tty_dev_name, "%s", config.serialLine ); /* sprintf( tty_dev_name, "%s", config.serialLine ); */
if ( ( ir_fd = open( tty_dev_name, O_RDWR | O_NDELAY ) ) >= 0 ) { /* if ( ( ir_fd = open( tty_dev_name, O_RDWR | O_NDELAY ) ) >= 0 ) { */
if ( config.verbose ) /* /\* if ( config.verbose ) *\/ */
printf( "IR connection on %s\n", tty_dev_name ); /* /\* printf( "IR connection on %s\n", tty_dev_name ); *\/ */
ir_name = strdup( tty_dev_name ); /* ir_name = strdup( tty_dev_name ); */
} /* } */
} /* } */
if ( ir_fd >= 0 ) { if ( ir_fd >= 0 ) {
#if defined( TCSANOW ) #if defined( TCSANOW )
@ -129,8 +129,8 @@ int init_serial( void )
if ( ioctl( ir_fd, TCGETS, ( char* )&ttybuf ) < 0 ) if ( ioctl( ir_fd, TCGETS, ( char* )&ttybuf ) < 0 )
#endif #endif
{ {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "ioctl(IR, TCGETS) failed, errno = %d\n", errno ); /* fprintf( stderr, "ioctl(IR, TCGETS) failed, errno = %d\n", errno ); */
ir_fd = -1; ir_fd = -1;
} }
} }
@ -151,8 +151,8 @@ int init_serial( void )
if ( ioctl( ir_fd, TCSETS, ( char* )&ttybuf ) < 0 ) if ( ioctl( ir_fd, TCSETS, ( char* )&ttybuf ) < 0 )
#endif #endif
{ {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "ioctl(IR, TCSETS) failed, errno = %d\n", errno ); /* fprintf( stderr, "ioctl(IR, TCSETS) failed, errno = %d\n", errno ); */
ir_fd = -1; ir_fd = -1;
} }
@ -173,8 +173,8 @@ void serial_baud( int baud )
if ( ioctl( ir_fd, TCGETS, ( char* )&ttybuf ) < 0 ) if ( ioctl( ir_fd, TCGETS, ( char* )&ttybuf ) < 0 )
#endif #endif
{ {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "ioctl(IR, TCGETS) failed, errno = %d\n", errno ); /* fprintf( stderr, "ioctl(IR, TCGETS) failed, errno = %d\n", errno ); */
ir_fd = -1; ir_fd = -1;
error = 1; error = 1;
@ -225,8 +225,8 @@ void serial_baud( int baud )
} }
if ( ( ir_fd >= 0 ) && ( ( ttybuf.c_cflag & CBAUD ) == 0 ) ) { if ( ( ir_fd >= 0 ) && ( ( ttybuf.c_cflag & CBAUD ) == 0 ) ) {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "can\'t set baud rate, using 9600\n" ); /* fprintf( stderr, "can\'t set baud rate, using 9600\n" ); */
ttybuf.c_cflag |= B9600; ttybuf.c_cflag |= B9600;
} }
@ -238,8 +238,8 @@ void serial_baud( int baud )
if ( ioctl( ir_fd, TCSETS, ( char* )&ttybuf ) < 0 ) if ( ioctl( ir_fd, TCSETS, ( char* )&ttybuf ) < 0 )
#endif #endif
{ {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "ioctl(IR, TCSETS) failed, errno = %d\n", errno ); /* fprintf( stderr, "ioctl(IR, TCSETS) failed, errno = %d\n", errno ); */
ir_fd = -1; ir_fd = -1;
error = 1; error = 1;
@ -253,8 +253,8 @@ void serial_baud( int baud )
if ( ioctl( ttyp, TCGETS, ( char* )&ttybuf ) < 0 ) if ( ioctl( ttyp, TCGETS, ( char* )&ttybuf ) < 0 )
#endif #endif
{ {
if ( config.verbose ) /* if ( config.verbose ) */
fprintf( stderr, "ioctl(wire, TCGETS) failed, errno = %d\n", errno ); /* fprintf( stderr, "ioctl(wire, TCGETS) failed, errno = %d\n", errno ); */
wire_fd = -1; wire_fd = -1;
ttyp = -1; ttyp = -1;
@ -305,8 +305,8 @@ void transmit_char( void )
if ( saturn.io_ctrl & 0x04 ) if ( saturn.io_ctrl & 0x04 )
do_interupt(); do_interupt();
} else { } else {
if ( errno != EAGAIN && config.verbose ) /* if ( errno != EAGAIN && config.verbose ) */
fprintf( stderr, "serial write error: %d\n", errno ); /* fprintf( stderr, "serial write error: %d\n", errno ); */
saturn.tcs &= 0x0e; saturn.tcs &= 0x0e;
if ( saturn.io_ctrl & 0x04 ) if ( saturn.io_ctrl & 0x04 )

View file

@ -290,7 +290,7 @@ extern int annunciators_bits[ NB_ANNUNCIATORS ];
// extern bool please_exit; // extern bool please_exit;
extern bool save_before_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 */ extern void exit_emulator( void ); /* used in debugger.c; ui_*.c */
/********************/ /********************/

View file

@ -1,86 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <unistd.h>
#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;
}

View file

@ -1,149 +0,0 @@
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdbool.h>
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 );
}

2346
src/ui.c

File diff suppressed because it is too large Load diff

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

File diff suppressed because it is too large Load diff

View file

@ -1,616 +0,0 @@
#include <ctype.h>
#include <fcntl.h>
#include <pwd.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/utsname.h>
#include <unistd.h>
#include <locale.h>
#include <wchar.h>
#include <curses.h>
#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" );
}

File diff suppressed because it is too large Load diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB