keep UI and emulator bits needed separate

This commit is contained in:
Gwenhael Le Moine 2024-09-12 08:11:42 +02:00
parent 97dacadb22
commit c39abb2901
No known key found for this signature in database
GPG key ID: FDFE3669426707A7
11 changed files with 1196 additions and 228 deletions

59
.clang-format Normal file
View file

@ -0,0 +1,59 @@
---
Language: Cpp
ColumnLimit: 140
IndentWidth: 4
PPIndentWidth: 2
UseTab: Never
AlignArrayOfStructures: Left
IndentCaseBlocks: true
IndentCaseLabels: true
IndentGotoLabels: false
IndentPPDirectives: AfterHash
IndentWrappedFunctionNames: true
InsertBraces: false
InsertNewlineAtEOF: true
MaxEmptyLinesToKeep: 1
PointerAlignment: Left
ReferenceAlignment: Left
QualifierAlignment: Left
SortIncludes: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesInAngles: true
SpacesInCStyleCastParentheses: true
SpacesInContainerLiterals: true
SpacesInParentheses: true
SpacesInSquareBrackets: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterExternBlock: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
...

View file

@ -8,6 +8,8 @@ MAKEFLAGS +=-j$(NUM_CORES) -l$(NUM_CORES)
DOTOS = src/ui.o \ DOTOS = src/ui.o \
src/ui_sdl2.o \ src/ui_sdl2.o \
src/config.o \
src/emulator.o \
src/main.o src/main.o
cc-option = $(shell if $(CC) $(1) -c -x c /dev/null -o /dev/null > /dev/null 2>&1; \ cc-option = $(shell if $(CC) $(1) -c -x c /dev/null -o /dev/null > /dev/null 2>&1; \

859
src/config.c Normal file
View file

@ -0,0 +1,859 @@
#include <assert.h>
#include <errno.h>
#include <pwd.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include <getopt.h>
#include <lauxlib.h>
#include <lua.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 ); */
return 0;
}

68
src/config.h Normal file
View file

@ -0,0 +1,68 @@
#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 */

67
src/emulator.c Normal file
View file

@ -0,0 +1,67 @@
#include "emulator.h"
hpkey_t keyboard[ 49 ] = {
/* From top left to bottom right */
{0x14, 0},
{0x84, 0},
{0x83, 0},
{0x82, 0},
{0x81, 0},
{0x80, 0},
{0x24, 0},
{0x74, 0},
{0x73, 0},
{0x72, 0},
{0x71, 0},
{0x70, 0},
{0x04, 0},
{0x64, 0},
{0x63, 0},
{0x62, 0},
{0x61, 0},
{0x60, 0},
{0x34, 0},
{0x54, 0},
{0x53, 0},
{0x52, 0},
{0x51, 0},
{0x50, 0},
{0x44, 0},
{0x43, 0},
{0x42, 0},
{0x41, 0},
{0x40, 0},
{0x35, 0},
{0x33, 0},
{0x32, 0},
{0x31, 0},
{0x30, 0},
{0x25, 0},
{0x23, 0},
{0x22, 0},
{0x21, 0},
{0x20, 0},
{0x15, 0},
{0x13, 0},
{0x12, 0},
{0x11, 0},
{0x10, 0},
{0x8000, 0},
{0x03, 0},
{0x02, 0},
{0x01, 0},
{0x00, 0},
};
saturn_t saturn;
display_t display;
int annunciators_bits[ NB_ANNUNCIATORS ] = { ANN_LEFT, ANN_RIGHT, ANN_ALPHA, ANN_BATTERY, ANN_BUSY, ANN_IO };

118
src/emulator.h Normal file
View file

@ -0,0 +1,118 @@
#ifndef _EMULATOR_H
#define _EMULATOR_H 1
#include <stdbool.h>
// Keys
#define HPKEY_A 0
#define HPKEY_B 1
#define HPKEY_C 2
#define HPKEY_D 3
#define HPKEY_E 4
#define HPKEY_F 5
#define HPKEY_MTH 6
#define HPKEY_PRG 7
#define HPKEY_CST 8
#define HPKEY_VAR 9
#define HPKEY_UP 10
#define HPKEY_NXT 11
#define HPKEY_QUOTE 12
#define HPKEY_STO 13
#define HPKEY_EVAL 14
#define HPKEY_LEFT 15
#define HPKEY_DOWN 16
#define HPKEY_RIGHT 17
#define HPKEY_SIN 18
#define HPKEY_COS 19
#define HPKEY_TAN 20
#define HPKEY_SQRT 21
#define HPKEY_POWER 22
#define HPKEY_INV 23
#define HPKEY_ENTER 24
#define HPKEY_NEG 25
#define HPKEY_EEX 26
#define HPKEY_DEL 27
#define HPKEY_BS 28
#define HPKEY_ALPHA 29
#define HPKEY_7 30
#define HPKEY_8 31
#define HPKEY_9 32
#define HPKEY_DIV 33
#define HPKEY_SHL 34
#define HPKEY_4 35
#define HPKEY_5 36
#define HPKEY_6 37
#define HPKEY_MUL 38
#define HPKEY_SHR 39
#define HPKEY_1 40
#define HPKEY_2 41
#define HPKEY_3 42
#define HPKEY_MINUS 43
#define HPKEY_ON 44
#define HPKEY_0 45
#define HPKEY_PERIOD 46
#define HPKEY_SPC 47
#define HPKEY_PLUS 48
#define FIRST_HPKEY HPKEY_A
#define LAST_HPKEY HPKEY_PLUS
#define NB_KEYS ( LAST_HPKEY + 1 )
#define KEYS_BUFFER_SIZE 9
// Annunciators
#define NB_ANNUNCIATORS 6
#define ANN_LEFT 0x81
#define ANN_RIGHT 0x82
#define ANN_ALPHA 0x84
#define ANN_BATTERY 0x88
#define ANN_BUSY 0x90
#define ANN_IO 0xa0
#define NIBBLES_PER_ROW 34
typedef unsigned char word_4;
typedef unsigned char word_8;
typedef long word_20;
typedef struct hpkey_t {
int code;
bool pressed;
} hpkey_t;
typedef struct display_t {
int on;
long disp_start;
long disp_end;
int offset;
int lines;
int nibs_per_line;
int contrast;
long menu_start;
long menu_end;
} display_t;
typedef struct saturn_t {
word_8 annunc;
} saturn_t;
extern hpkey_t keyboard[ 49 ];
extern saturn_t saturn;
extern display_t display;
extern int annunciators_bits[ NB_ANNUNCIATORS ];
#endif /* !_EMULATOR_H */

View file

@ -4,15 +4,17 @@
int main( int argc, char** argv ) int main( int argc, char** argv )
{ {
// start_emulator();
/* (G)UI */ /* (G)UI */
start_UI( argc, argv ); start_UI( argc, argv );
while ( true ) { while ( true ) {
ui_update_LCD(); ui_update_LCD();
ui_get_event(); ui_get_event();
} }
/* Never reached when not using please_exit */
ui_stop();
/* Never reached */
return 0; return 0;
} }

View file

@ -2,7 +2,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
//#include "config.h" #include "config.h"
#include "ui.h" #include "ui.h"
#include "ui_inner.h" #include "ui_inner.h"
@ -2294,8 +2294,8 @@ int SmallTextWidth( const char* string, unsigned int length )
if ( small_font[ ( int )string[ i ] ].h != 0 ) if ( small_font[ ( int )string[ i ] ].h != 0 )
w += small_font[ ( int )string[ i ] ].w + 1; w += small_font[ ( int )string[ i ] ].w + 1;
else { else {
/* if ( config.verbose ) */ if ( config.verbose )
/* fprintf( stderr, "Unknown small letter 0x00%x\n", ( int )string[ i ] ); */ fprintf( stderr, "Unknown small letter 0x00%x\n", ( int )string[ i ] );
w += 5; w += 5;
} }
} }
@ -2310,8 +2310,8 @@ int BigTextWidth( const char* string, unsigned int length )
if ( big_font[ ( int )string[ i ] ].h != 0 ) if ( big_font[ ( int )string[ i ] ].h != 0 )
w += big_font[ ( int )string[ i ] ].w; w += big_font[ ( int )string[ i ] ].w;
else { else {
/* if ( config.verbose ) */ if ( config.verbose )
/* fprintf( stderr, "Unknown small letter 0x00%x\n", ( int )string[ i ] ); */ fprintf( stderr, "Unknown small letter 0x00%x\n", ( int )string[ i ] );
w += 7; w += 7;
} }
} }
@ -2326,15 +2326,13 @@ void start_UI( int argc, char** argv )
init_sdl2_ui( argc, argv ); init_sdl2_ui( argc, argv );
} }
void ui_stop( void ) void ui_stop( void ) { sdl2_ui_stop(); }
{
sdl2_ui_stop();
}
void close_and_exit( void ) void close_and_exit( void )
{ {
ui_stop();
// exit_emulator(); // exit_emulator();
ui_stop();
exit( 0 ); exit( 0 );
} }

View file

@ -1,15 +1,11 @@
#ifndef _UI_H #ifndef _UI_H
#define _UI_H 1 #define _UI_H 1
#define NIBBLES_PER_ROW 0x22 #include "emulator.h"
#define DISP_ROWS 64 #define DISP_ROWS 64
#define NIBS_PER_BUFFER_ROW ( NIBBLES_PER_ROW + 2 ) #define NIBS_PER_BUFFER_ROW ( NIBBLES_PER_ROW + 2 )
typedef unsigned char word_4;
typedef unsigned char word_8;
typedef long word_20;
/*************/ /*************/
/* variables */ /* variables */
/*************/ /*************/

View file

@ -1,7 +1,8 @@
#ifndef _UI_INNER_H #ifndef _UI_INNER_H
#define _UI_INNER_H 1 #define _UI_INNER_H 1
//#include "emulator.h" #include "emulator.h"
#include "ui_bitmaps_misc.h" #include "ui_bitmaps_misc.h"
#include "ui_bitmaps_small_font.h" #include "ui_bitmaps_small_font.h"
#include "ui_bitmaps_big_font.h" #include "ui_bitmaps_big_font.h"
@ -33,81 +34,6 @@
#define LAST_COLOR BLACK #define LAST_COLOR BLACK
#define NB_COLORS ( LAST_COLOR + 1 ) #define NB_COLORS ( LAST_COLOR + 1 )
// Keys
#define HPKEY_A 0
#define HPKEY_B 1
#define HPKEY_C 2
#define HPKEY_D 3
#define HPKEY_E 4
#define HPKEY_F 5
#define HPKEY_MTH 6
#define HPKEY_PRG 7
#define HPKEY_CST 8
#define HPKEY_VAR 9
#define HPKEY_UP 10
#define HPKEY_NXT 11
#define HPKEY_QUOTE 12
#define HPKEY_STO 13
#define HPKEY_EVAL 14
#define HPKEY_LEFT 15
#define HPKEY_DOWN 16
#define HPKEY_RIGHT 17
#define HPKEY_SIN 18
#define HPKEY_COS 19
#define HPKEY_TAN 20
#define HPKEY_SQRT 21
#define HPKEY_POWER 22
#define HPKEY_INV 23
#define HPKEY_ENTER 24
#define HPKEY_NEG 25
#define HPKEY_EEX 26
#define HPKEY_DEL 27
#define HPKEY_BS 28
#define HPKEY_ALPHA 29
#define HPKEY_7 30
#define HPKEY_8 31
#define HPKEY_9 32
#define HPKEY_DIV 33
#define HPKEY_SHL 34
#define HPKEY_4 35
#define HPKEY_5 36
#define HPKEY_6 37
#define HPKEY_MUL 38
#define HPKEY_SHR 39
#define HPKEY_1 40
#define HPKEY_2 41
#define HPKEY_3 42
#define HPKEY_MINUS 43
#define HPKEY_ON 44
#define HPKEY_0 45
#define HPKEY_PERIOD 46
#define HPKEY_SPC 47
#define HPKEY_PLUS 48
#define FIRST_HPKEY HPKEY_A
#define LAST_HPKEY HPKEY_PLUS
#define NB_KEYS ( LAST_HPKEY + 1 )
#define KEYS_BUFFER_SIZE 9
// Annunciators
#define NB_ANNUNCIATORS 6
#define ANN_LEFT 0x81
#define ANN_RIGHT 0x82
#define ANN_ALPHA 0x84
#define ANN_BATTERY 0x88
#define ANN_BUSY 0x90
#define ANN_IO 0xa0
/***********/ /***********/
/* typedef */ /* typedef */
/***********/ /***********/

View file

@ -16,7 +16,8 @@ bool opt_gx = true;
char* wire_name = "/dummy/wire"; char* wire_name = "/dummy/wire";
char* ir_name = "/dummy/ir"; char* ir_name = "/dummy/ir";
//#include "config.h" #include "config.h"
#include "emulator.h"
#include "ui.h" #include "ui.h"
#include "ui_inner.h" #include "ui_inner.h"
@ -48,134 +49,9 @@ typedef struct on_off_sdl_textures_struct_t {
SDL_Texture* down; SDL_Texture* down;
} on_off_sdl_textures_struct_t; } on_off_sdl_textures_struct_t;
typedef struct hpkey_t {
int code;
bool pressed;
} hpkey_t;
typedef struct {
char* progname;
bool verbose;
bool leave_shift_keys;
bool inhibit_shutdown;
bool mono;
bool gray;
/* sdl */
bool hide_chrome;
bool show_ui_fullscreen;
double scale;
} config_t;
typedef struct display_t {
int on;
long disp_start;
long disp_end;
int offset;
int lines;
int nibs_per_line;
int contrast;
long menu_start;
long menu_end;
} display_t;
typedef struct saturn_t {
word_8 annunc;
} saturn_t;
/*************/ /*************/
/* variables */ /* variables */
/*************/ /*************/
config_t config = {
.progname = ( char* )"hp48-sdl2",
.verbose = false,
.leave_shift_keys = false,
.inhibit_shutdown = false,
.mono = false,
.gray = false,
/* sdl */
.hide_chrome = false,
.show_ui_fullscreen = false,
.scale = 1.0,
};
hpkey_t keyboard[ 49 ] = {
/* From top left to bottom right */
{0x14, 0},
{0x84, 0},
{0x83, 0},
{0x82, 0},
{0x81, 0},
{0x80, 0},
{0x24, 0},
{0x74, 0},
{0x73, 0},
{0x72, 0},
{0x71, 0},
{0x70, 0},
{0x04, 0},
{0x64, 0},
{0x63, 0},
{0x62, 0},
{0x61, 0},
{0x60, 0},
{0x34, 0},
{0x54, 0},
{0x53, 0},
{0x52, 0},
{0x51, 0},
{0x50, 0},
{0x44, 0},
{0x43, 0},
{0x42, 0},
{0x41, 0},
{0x40, 0},
{0x35, 0},
{0x33, 0},
{0x32, 0},
{0x31, 0},
{0x30, 0},
{0x25, 0},
{0x23, 0},
{0x22, 0},
{0x21, 0},
{0x20, 0},
{0x15, 0},
{0x13, 0},
{0x12, 0},
{0x11, 0},
{0x10, 0},
{0x8000, 0},
{0x03, 0},
{0x02, 0},
{0x01, 0},
{0x00, 0},
};
saturn_t saturn;
display_t display;
int annunciators_bits[ NB_ANNUNCIATORS ] = { ANN_LEFT, ANN_RIGHT, ANN_ALPHA, ANN_BATTERY, ANN_BUSY, ANN_IO };
static int display_offset_x, display_offset_y; static int display_offset_x, display_offset_y;
color_t colors[ NB_COLORS ]; color_t colors[ NB_COLORS ];
@ -189,10 +65,7 @@ static SDL_Texture* main_texture;
/****************************/ /****************************/
/* functions implementation */ /* functions implementation */
/****************************/ /****************************/
int read_nibble( long addr ) int read_nibble( long addr ) { return 1; }
{
return 1;
}
void press_key( int hpkey ) void press_key( int hpkey )
{ {