initial commit

This commit is contained in:
R-type
2015-12-14 14:00:35 +01:00
commit 5a96c0ca66
377 changed files with 149124 additions and 0 deletions
File diff suppressed because it is too large Load Diff
+287
View File
@@ -0,0 +1,287 @@
/*
* atari_wince.c - WinCE port specific code
*
* Copyright (C) 2001 Vasyl Tsvirkunov
* Copyright (C) 2001-2014 Atari800 development team (see DOC/CREDITS)
*
* This file is part of the Atari800 emulator project which emulates
* the Atari 400, 800, 800XL, 130XE, and 5200 8-bit computers.
*
* Atari800 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.
*
* Atari800 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 Atari800; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* Based on Win32 port by Krzysztof Nikiel */
#include "config.h"
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include "atari.h"
#include "input.h"
#include "platform.h"
#include "screen.h"
#include "sound.h"
#include "ui.h"
#include "pokeysnd.h"
#include "keyboard.h"
#include "main.h"
#include "screen_wince.h"
static int kbjoy = 1;
DWORD REG_bat, REG_ac, REG_disp, bat_timeout;
/* XXX: don't define Log_print, use a platform-specific output in log.c */
void Log_print(char *format, ... )
{
#ifdef DEBUG
char tmp1[512];
TCHAR tmp2[512];
va_list va;
va_start(va, format);
_vsnprintf(tmp1, 512, format, va);
va_end(va);
MultiByteToWideChar(CP_ACP, 0, tmp1, strlen(tmp1) + 1, tmp2, sizeof(tmp2));
OutputDebugString(tmp2);
#endif
}
void Log_flushlog(void) {}
static DWORD reg_access(TCHAR *key, TCHAR *val, DWORD data)
{
HKEY regkey;
DWORD tmpval, cbdata;
if (RegOpenKeyEx(HKEY_CURRENT_USER, key, 0, 0, &regkey) != ERROR_SUCCESS)
return data;
cbdata = sizeof(DWORD);
if (RegQueryValueEx(regkey, val, NULL, NULL, (LPBYTE) &tmpval, &cbdata) != ERROR_SUCCESS)
{
RegCloseKey(regkey);
return data;
}
cbdata = sizeof(DWORD);
if (RegSetValueEx(regkey, val, 0, REG_DWORD, (LPBYTE) &data, cbdata) != ERROR_SUCCESS)
{
RegCloseKey(regkey);
return data;
}
RegCloseKey(regkey);
return tmpval;
}
static void backlight_xchg(void)
{
HANDLE h;
REG_bat = reg_access(_T("ControlPanel\\BackLight"), _T("BatteryTimeout"), REG_bat);
REG_ac = reg_access(_T("ControlPanel\\BackLight"), _T("ACTimeout"), REG_ac);
REG_disp = reg_access(_T("ControlPanel\\Power"), _T("Display"), REG_disp);
h = CreateEvent(NULL, FALSE, FALSE, _T("BackLightChangeEvent"));
if (h)
{
SetEvent(h);
CloseHandle(h);
}
}
int PLATFORM_Keyboard(void)
{
int keycode;
prockb();
keycode = get_last_key();
return keycode;
}
int PLATFORM_Initialise(int *argc, char *argv[])
{
#ifdef SOUND
if (!Sound_Initialise(argc, argv))
return FALSE;
#endif
if (gron(argc, argv))
{
perror("Graphics initialization failed");
exit(1);
}
if(initinput())
{
perror("Input initialization failed");
exit(1);
}
/* backlight */
REG_bat = REG_ac = REG_disp = 2 * 60 * 60 * 1000; /* 2hrs should do it */
backlight_xchg();
SystemParametersInfo(SPI_GETBATTERYIDLETIMEOUT, 0, (void *) &bat_timeout, 0);
SystemParametersInfo(SPI_SETBATTERYIDLETIMEOUT, 60 * 60 * 2, NULL, SPIF_SENDCHANGE);
clearkb();
return TRUE;
}
int PLATFORM_Exit(int run_monitor)
{
backlight_xchg(); /* restore backlight settings */
SystemParametersInfo(SPI_SETBATTERYIDLETIMEOUT, bat_timeout, NULL, SPIF_SENDCHANGE);
/* monitor is not avaliable in this port */
if(run_monitor)
return 1;
#ifdef BUFFERED_LOG
Log_flushlog();
#endif
uninitinput();
groff();
return 0;
}
void PLATFORM_DisplayScreen(void)
{
refreshv((UBYTE *) Screen_atari + 24);
}
int PLATFORM_PORT(int num)
{
if (num == 0)
return stick0;
else
return 0xff;
}
int PLATFORM_TRIG(int num)
{
if (num == 0)
return trig0;
else
return 1;
}
void PLATFORM_ConfigInit(void)
{
enable_new_pokey = 0;
Screen_visible_x1 = 24;
Screen_visible_y1 = 10;
Screen_visible_x2 = 344;
Screen_visible_y2 = 230;
Screen_show_disk_led = 1;
Screen_show_sector_counter = 1;
Screen_show_atari_speed = 1;
}
int PLATFORM_Configure(char* option, char *parameters)
{
if (strcmp(option, "WCE_LINEAR_FILTER") == 0)
{
sscanf(parameters, "%d", &smooth_filter);
return 1;
}
else if (strcmp(option, "WCE_VIRTUAL_JOYSTICK") == 0)
{
sscanf(parameters, "%d", &virtual_joystick);
return 1;
}
else if (strcmp(option, "WCE_SMARTPHONE_KBHACK") == 0)
{
sscanf(parameters, "%d", &smkeyhack);
return 1;
}
return 0;
}
void PLATFORM_ConfigSave(FILE *fp)
{
fprintf(fp, "WCE_LINEAR_FILTER=%d\n", smooth_filter);
fprintf(fp, "WCE_VIRTUAL_JOYSTICK=%d\n", virtual_joystick);
}
void AboutPocketAtari(void)
{
ui_driver->fInfoScreen("About Pocket Atari", issmartphone ?
"Pocket Atari for Smartphones\0"
"Built on: " __DATE__ "\0"
"\0"
"Ported by Kostas Nakos\0"
"(knakos@gmail.com)\0"
"http://pocketatari.atari.org"
"\0"
"\0"
"\0"
"Based on the PocketPC/WinCE port\0"
"by Vasyl Tsvirkunov\0"
"http://pocketatari.retrogames.com\0"
"\0"
"\0"
"Atari core for this version\0"
Atari800_TITLE "\0"
"http://atari800.sf.net\0"
"\n"
:
"Pocket Atari v.1.2 (" __DATE__ ")\0"
"by Vasyl Tsvirkunov (C) 2002\0"
"http://pocketatari.retrogames.com\0"
"\0"
"\0"
"This port is based on\0"
Atari800_TITLE "\0"
"http://atari800.sf.net\0"
"\0"
"PocketPC port update and\0"
"Smartphone port by Kostas Nakos\0"
"(knakos@gmail.com)\0"
"http://pocketatari.atari.org"
"\0"
"\n"
);
}
int wince_main(int argc, char **argv)
{
/* initialise Atari800 core */
if (!Atari800_Initialise(&argc, argv))
return 3;
/* main loop */
for (;;)
{
if (emulator_active)
{
INPUT_key_code = PLATFORM_Keyboard();
Atari800_Frame();
if (Atari800_display_screen)
PLATFORM_DisplayScreen();
}
else
{
Sleep(100);
}
}
}
+433
View File
@@ -0,0 +1,433 @@
/* config.h for Windows CE version of Atari800. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* Include Windows CE workarounds for each file of the emulator core */
#include "missing.h"
/* Define to use back slash as directory separator. */
#define BACK_SLASH 1
/* Target: standard I/O. */
#undef BASIC
/* Define to use buffered debug output. */
#undef BUFFERED_LOG
/* Define to allow sound clipping. */
#define CLIP_SOUND 1
/* Define to 1 if the `closedir' function returns void instead of `int'. */
#undef CLOSEDIR_VOID
/* Define to allow console sound (keyboard clicks). */
#undef CONSOLE_SOUND
/* Define to activate crash menu after CIM instruction. */
#define CRASH_MENU 1
/* Define to disable bitmap graphics emulation in CURSES target. */
#undef CURSES_BASIC
/* Alternate config filename due to 8+3 fs limit. */
#define DEFAULT_CFG_NAME "atari800.cfg"
/* Target: Windows with DirectX. */
#undef DIRECTX
/* Target: DOS VGA. */
#undef DOSVGA
/* Define to enable DOS style drives support. */
#undef DOS_DRIVES
/* Target: Atari Falcon system. */
#undef FALCON
/* Define to use m68k assembler CPU core for Falcon target. */
#undef FALCON_CPUASM
/* Define to 1 if you have the <arpa/inet.h> header file. */
#undef HAVE_ARPA_INET_H
/* Define to 1 if you have the `atexit' function. */
#undef HAVE_ATEXIT
/* Define to 1 if you have the `chmod' function. */
#undef HAVE_CHMOD
/* Define to 1 if you have the `clock' function. */
#undef HAVE_CLOCK
/* Define to 1 if you have the <direct.h> header file. */
#undef HAVE_DIRECT_H
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
*/
#undef HAVE_DIRENT_H
/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
#undef HAVE_DOPRNT
/* Define to 1 if you have the <errno.h> header file. */
#undef HAVE_ERRNO_H
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define to 1 if you have the `fdopen' function. */
#undef HAVE_FDOPEN
/* Define to 1 if you have the `fflush' function. */
#define HAVE_FFLUSH 1
/* Define to 1 if you have the <file.h> header file. */
#undef HAVE_FILE_H
/* Define to 1 if you have the `floor' function. */
#define HAVE_FLOOR 1
/* Define to 1 if you have the `fstat' function. */
#undef HAVE_FSTAT
/* Define to 1 if you have the `getcwd' function. */
#define HAVE_GETCWD 1
/* Define to 1 if you have the `gethostbyaddr' function. */
#undef HAVE_GETHOSTBYADDR
/* Define to 1 if you have the `gethostbyname' function. */
#undef HAVE_GETHOSTBYNAME
/* Define to 1 if you have the `gettimeofday' function. */
#undef HAVE_GETTIMEOFDAY
/* Define to 1 if you have the `inet_ntoa' function. */
#undef HAVE_INET_NTOA
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the `png' library (-lpng). */
#undef HAVE_LIBPNG
/* Define to 1 if you have the `z' library (-lz). */
#define HAVE_LIBZ 1
/* Define to 1 if you have the `localtime' function. */
#undef HAVE_LOCALTIME
/* Define to 1 if you have the `memmove' function. */
#define HAVE_MEMMOVE 1
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the `memset' function. */
#define HAVE_MEMSET 1
/* Define to 1 if you have the `mkdir' function. */
#undef HAVE_MKDIR
/* Define to 1 if you have the `mkstemp' function. */
#undef HAVE_MKSTEMP
/* Define to 1 if you have the `mktemp' function. */
#undef HAVE_MKTEMP
/* Define to 1 if you have the `modf' function. */
#define HAVE_MODF 1
/* Define to 1 if you have the `nanosleep' function. */
#undef HAVE_NANOSLEEP
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
#undef HAVE_NDIR_H
/* Define to 1 if you have the <netdb.h> header file. */
#undef HAVE_NETDB_H
/* Define to 1 if you have the <netinet/in.h> header file. */
#undef HAVE_NETINET_IN_H
/* Define to 1 if you have the `opendir' function. */
#undef HAVE_OPENDIR
/* Define to 1 if you have the `rename' function. */
#undef HAVE_RENAME
/* Define to 1 if you have the `rewind' function. */
#undef HAVE_REWIND
/* Define to 1 if you have the `rmdir' function. */
#undef HAVE_RMDIR
/* Define to 1 if you have the `select' function. */
#define HAVE_SELECT 1
/* Define to 1 if you have the `signal' function. */
#undef HAVE_SIGNAL
/* Define to 1 if you have the <signal.h> header file. */
#undef HAVE_SIGNAL_H
/* Define to 1 if you have the `snprintf' function. */
#undef HAVE_SNPRINTF
/* Define to 1 if you have the `socket' function. */
#undef HAVE_SOCKET
/* Define to 1 if you have the `stat' function. */
#undef HAVE_STAT
/* Define to 1 if `stat' has the bug that it succeeds when given the
zero-length file name argument. */
#undef HAVE_STAT_EMPTY_STRING_BUG
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the `strcasecmp' function. */
#undef HAVE_STRCASECMP
/* Define to 1 if you have the `strchr' function. */
#define HAVE_STRCHR 1
/* Define to 1 if you have the `strdup' function. */
#undef HAVE_STRDUP
/* Define to 1 if you have the `strerror' function. */
#undef HAVE_STRERROR
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the `strrchr' function. */
#define HAVE_STRRCHR 1
/* Define to 1 if you have the `strspn' function. */
#define HAVE_STRSPN 1
/* Define to 1 if you have the `strstr' function. */
#define HAVE_STRSTR 1
/* Define to 1 if you have the `strtol' function. */
#define HAVE_STRTOL 1
/* Define to 1 if you have the `system' function. */
#undef HAVE_SYSTEM
/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
*/
#undef HAVE_SYS_DIR_H
/* Define to 1 if you have the <sys/ioctl.h> header file. */
#undef HAVE_SYS_IOCTL_H
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
*/
#undef HAVE_SYS_NDIR_H
/* Define to 1 if you have the <sys/select.h> header file. */
#undef HAVE_SYS_SELECT_H
/* Define to 1 if you have the <sys/socket.h> header file. */
#undef HAVE_SYS_SOCKET_H
/* Define to 1 if you have the <sys/soundcard.h> header file. */
#undef HAVE_SYS_SOUNDCARD_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/time.h> header file. */
#undef HAVE_SYS_TIME_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <termios.h> header file. */
#undef HAVE_TERMIOS_H
/* Define to 1 if you have the `time' function. */
#undef HAVE_TIME
/* Define to 1 if you have the <time.h> header file. */
#undef HAVE_TIME_H
/* Define to 1 if you have the `tmpnam' function. */
#define HAVE_TMPNAM 1
/* Define to 1 if you have the `uclock' function. */
#undef HAVE_UCLOCK
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if you have the <unixio.h> header file. */
#undef HAVE_UNIXIO_H
/* Define to 1 if you have the `unlink' function. */
#undef HAVE_UNLINK
/* Define to 1 if you have the `vprintf' function. */
#define HAVE_VPRINTF 1
/* Define to 1 if you have the `vsnprintf' function. */
#undef HAVE_VSNPRINTF
/* Define to allow sound interpolation. */
#undef INTERPOLATE_SOUND
/* Define to use LINUX joystick. */
#undef LINUX_JOYSTICK
/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
slash. */
#undef LSTAT_FOLLOWS_SLASHED_SYMLINK
/* Define to activate assembler in monitor. */
#undef MONITOR_ASSEMBLER
/* Define to activate BREAK command in monitor. */
#undef MONITOR_BREAK
/* Define to activate hints in disassembler. */
#undef MONITOR_HINTS
/* Target: X11 with Motif. */
#undef MOTIF
/* Define to allow new cycle-exact scanline routines. */
#undef NEW_CYCLE_EXACT
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to use page-based attribute array. */
#undef PAGED_ATTRIB
/* Define as the return type of signal handlers (`int' or `void'). */
#undef RETSIGTYPE
/* Define to use R: device. */
#undef R_IO_DEVICE
/* Target: SDL library. */
#undef SDL
/* Define to the type of arg 1 for `select'. */
#define SELECT_TYPE_ARG1 int
/* Define to the type of args 2, 3 and 4 for `select'. */
#define SELECT_TYPE_ARG234 fd_set
/* Define to the type of arg 5 for `select'. */
#define SELECT_TYPE_ARG5 const struct timeval
/* Define to allow serial in/out sound. */
#undef SERIO_SOUND
/* Target: X11 with shared memory extensions. */
#undef SHM
/* The size of a `long', as computed by sizeof. */
#define SIZEOF_LONG 4
/* Define to activate sound support. */
#define SOUND 1
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define to allow stereo sound. */
#undef STEREO_SOUND
/* Save additional config file options. */
#define SUPPORTS_ATARI_CONFIGSAVE 1
/* Additional config file options. */
#define SUPPORTS_ATARI_CONFIGURE 1
/* Target: Linux with SVGALib. */
#undef SVGALIB
/* Define to use Toshiba Joystick Mouse support. */
#undef SVGA_JOYMOUSE
/* Define for drawing every 1/50 sec only 1/refresh of screen. */
#undef SVGA_SPEEDUP
/* Alternate system-wide config file for non-Unix OS. */
#undef SYSTEM_WIDE_CFG_FILE
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
#undef TM_IN_SYS_TIME
/* Define to use clock() instead of gettimeofday(). */
#undef USE_CLOCK
/* Target: Curses-compatible library. */
#undef USE_CURSES
/* Define for using cursor/ctrl keys for keyboard joystick. */
#undef USE_CURSORBLOCK
/* Target: Ncurses library. */
#undef USE_NCURSES
/* Define to use very slow computer support (faster -refresh). */
#undef VERY_SLOW
/* Define to allow volume only sound. */
#define VOL_ONLY_SOUND 1
/* Define to 1 if your processor stores words with the most significant byte
first (like Motorola and SPARC, unlike Intel and VAX). */
#undef WORDS_BIGENDIAN
/* Define if unaligned word access is ok. */
#undef WORDS_UNALIGNED_OK
/* Target: Standard X11. */
#undef X11
/* Target: X11 with XView. */
#undef XVIEW
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
/* Define as `__inline' if that's what the C compiler calls it, or to nothing
if it is not supported. */
#define inline __inline
/* Define to `unsigned' if <sys/types.h> does not define. */
#undef size_t
/* Define to empty if the keyword `volatile' does not work. Warning: valid
code using `volatile' can become incorrect without. Disable with care. */
#undef volatile
/* Define to 1 for the alternate host syncing scheme. */
#define ALTERNATE_SYNC_WITH_HOST 1
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

+936
View File
@@ -0,0 +1,936 @@
/*
* atari_wince.c - WinCE port specific code
*
* Copyright (C) 2001 Vasyl Tsvirkunov
* Copyright (C) 2001-2006 Atari800 development team (see DOC/CREDITS)
*
* This file is part of the Atari800 emulator project which emulates
* the Atari 400, 800, 800XL, 130XE, and 5200 8-bit computers.
*
* Atari800 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.
*
* Atari800 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 Atari800; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <windows.h>
#include "gx.h"
extern "C"
{
#include "input.h"
#include "akey.h"
#include "main.h"
#include "keyboard.h"
#include "screen_wince.h"
#include "ui.h"
int virtual_joystick = 0;
int smkeyhack = 0;
extern HWND hWndMain;
};
int currentKeyboardMode = 4;
int currentKeyboardColor = 0;
int ui_clearkey = FALSE;
int kbui_timerset = FALSE;
int stylus_down = 0;
unsigned long* kbd_image;
/* Assumed to be 240x80 packed bitmap with buttons in 5 rows */
unsigned long kbd_image_800[] =
{
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x0000ffff,
0x10004001, 0x31000400, 0x07100040, 0x40010004, 0x04001000, 0x00400100, 0x00040010, 0x00008000,
0xd00c403d, 0xf903340c, 0x0d903340, 0x407900c4, 0x64039038, 0x03401d06, 0x033440d3, 0x0000801c,
0xd00c400d, 0x0d07fc0c, 0x07101b40, 0x40cd00c4, 0x9407101c, 0x2558c964, 0xf3344d52, 0x00008f98,
0xd00c403d, 0x7903340c, 0x03900c40, 0x40ed00c4, 0x1406100c, 0x554549a4, 0x9bf554d2, 0x00009999,
0x100c400d, 0xc1033400, 0x1ed00640, 0x40ed0004, 0x1406100c, 0x35494924, 0xfb34c552, 0x00009999,
0x100040fd, 0x7d07fc00, 0x0cd03340, 0x400d0004, 0x9407101c, 0x15514924, 0x1b354552, 0x00008f98,
0x100c4031, 0x31033400, 0x1b903140, 0x40f90004, 0x64039038, 0x634d5d2e, 0xf33644d7, 0x000081bc,
0x100040f1, 0x01000400, 0x00100040, 0x40010004, 0x04001000, 0x00400d03, 0x00040010, 0x00008180,
0x900c4001, 0x6103f407, 0x07903f40, 0x407903f4, 0x8407901e, 0x00401901, 0x00040010, 0x00008000,
0xd00e4001, 0x7101840c, 0x00d00340, 0x40cd0304, 0xc40cd033, 0x00403100, 0x00040010, 0x00008000,
0x100c4001, 0x7900c406, 0x07d01f40, 0x40790184, 0x640ed03e, 0x00406100, 0x00040010, 0x00008000,
0x100c4001, 0x6d018403, 0x0cd03040, 0x40cd00c4, 0xc40dd030, 0x00403100, 0x00040010, 0x00008000,
0x900c4001, 0xfd033401, 0x0cd03340, 0x40cd0064, 0x840cd018, 0x00401901, 0x00040010, 0x00008000,
0xd03f4001, 0x6101e40f, 0x07901e40, 0x40790064, 0x0407900e, 0x00400d03, 0x00040010, 0x00008000,
0x10004001, 0x01000400, 0x00100040, 0x40010004, 0x04001000, 0x00400100, 0x00040010, 0x00008000,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x0000ffff,
0x00200001, 0x80020008, 0x08002000, 0x00800200, 0x00080020, 0x20008002, 0x00040000, 0x00008000,
0x0f20c07d, 0x81fa0c68, 0x681fa03e, 0x7e819a06, 0x03e80f20, 0x20188062, 0x61e40000, 0x00008c00,
0x19a0cf31, 0x801a0c68, 0x68062066, 0x18819a06, 0x066819a0, 0x201880f2, 0xf8340000, 0x0000bf7d,
0x19a7d831, 0x80fa0d68, 0xc8062066, 0x18819a03, 0x066819a0, 0x201881fa, 0x61e43000, 0x00008c4c,
0x19acdf31, 0x801a0fe8, 0x8806203e, 0x18819a01, 0x03e819a0, 0x207e8062, 0x63043000, 0x00008c0c,
0x0dacd9b1, 0x801a0ee8, 0x88062036, 0x18819a01, 0x006819a0, 0x203c8062, 0x63043000, 0x00008c0c,
0x1b27df31, 0x81fa0c68, 0x88062066, 0x7e81fa01, 0x00680f20, 0x20188062, 0xc1e43000, 0x0000b80d,
0x00200001, 0x80020008, 0x08002000, 0x00800200, 0x00080020, 0x20008002, 0x00043030, 0x00008000,
0x00200001, 0x80020008, 0x08002000, 0x00800200, 0x00080020, 0x20008002, 0x00043018, 0x00008000,
0x00200001, 0x80020008, 0x08002000, 0x00800200, 0x00080020, 0x207e8002, 0x00043ffc, 0x00008000,
0x00200001, 0x80020008, 0x08002000, 0x00800200, 0x00080020, 0x200081fa, 0x00040018, 0x00008000,
0x00200001, 0x80020008, 0x08002000, 0x00800200, 0x00080020, 0x20008002, 0x00040030, 0x00008000,
0x00200001, 0x80020008, 0x08002000, 0x00800200, 0x00080020, 0x207e8002, 0x00040000, 0x00008000,
0x00200001, 0x80020008, 0x08002000, 0x00800200, 0x00080020, 0x20008002, 0x00040000, 0x00008000,
0x00200001, 0x80020008, 0x08002000, 0x00800200, 0x00080020, 0x20008002, 0x00040000, 0x00008000,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x0000ffff,
0x02000001, 0x00200080, 0x80020008, 0x08002000, 0x00800200, 0x00080020, 0x00040002, 0x00008000,
0x62006089, 0x07a03c80, 0x81f207e8, 0x68182066, 0x00801a06, 0x01880620, 0x39e40012, 0x00008300,
0xf2004dd5, 0x0da00680, 0x801a0068, 0x68182066, 0x18801a03, 0x03080320, 0x3034002a, 0x00008fde,
0x9a005485, 0x19a03c81, 0x801a03e8, 0xe818207e, 0x18801a01, 0x07e81fa0, 0x31e5998a, 0x00008303,
0x9a004485, 0x19a06081, 0x81da0068, 0xe8182066, 0x00801a01, 0x03080320, 0x33046a0a, 0x00008303,
0xfa004495, 0x0da06081, 0x819a0068, 0x6819a066, 0x18801a03, 0x01880620, 0x3304ab0a, 0x00008303,
0x9a004509, 0x07a03c81, 0x81f20068, 0x680f2066, 0x1881fa06, 0x00080020, 0x79e51aaa, 0x00008e1e,
0x02000001, 0x00200080, 0x80020008, 0x08002000, 0x00800200, 0x00080020, 0x0004cb12, 0x00008000,
0x02000001, 0x00200080, 0x80020008, 0x08002000, 0x00800200, 0x0cc80620, 0x00040802, 0x00008000,
0x02000001, 0x00200080, 0x80020008, 0x08002000, 0x18800200, 0x07880620, 0x00040002, 0x00008000,
0x02000001, 0x00200080, 0x80020008, 0x08002000, 0x18800200, 0x1fe81fa0, 0x00040002, 0x00008000,
0x02000001, 0x00200080, 0x80020008, 0x08002000, 0x00800200, 0x07880620, 0x00040002, 0x00008000,
0x02000001, 0x00200080, 0x80020008, 0x08002000, 0x18800200, 0x0cc80620, 0x00040002, 0x00008000,
0x02000001, 0x00200080, 0x80020008, 0x08002000, 0x18800200, 0x00080020, 0x00040002, 0x00008000,
0x02000001, 0x00200080, 0x80020008, 0x08002000, 0x0c800200, 0x00080020, 0x00040002, 0x00008000,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x0000ffff,
0x40000001, 0x04001000, 0x00400100, 0x00040010, 0x10004001, 0x00000400, 0x00040010, 0x00008000,
0x40024899, 0xe40cd03f, 0x1f40cd01, 0x06340cd0, 0x900f40f1, 0x09226407, 0x01e40fd0, 0x00008030,
0x40022085, 0x340cd018, 0x3340cd03, 0x07740dd0, 0xd00c4031, 0x0882140c, 0xfb340bd0, 0x000080fc,
0x40076999, 0x3407900c, 0x1f40cd00, 0x07f40fd0, 0x100c4031, 0x1da66406, 0x9b3409d0, 0x00008031,
0x40022aa1, 0x34079006, 0x3340cd00, 0x06b40fd0, 0x100c4031, 0x08aa8403, 0x9b3408d0, 0x00008031,
0x40022aa1, 0x340cd003, 0x33407903, 0x06340ed0, 0x100c4031, 0x08aa8400, 0xfb340850, 0x00008030,
0x40042a99, 0xe40cd03f, 0x1f403101, 0x06340cd0, 0x100f40f1, 0x10aa6403, 0x19e40fd0, 0x000080e0,
0x40000001, 0x04001000, 0x00400100, 0x00040010, 0x10004001, 0x00000400, 0x18040010, 0x00008000,
0x40000001, 0x04001000, 0x00400100, 0x00040010, 0x10004001, 0x0000040c, 0x00040010, 0x00008000,
0x40000001, 0x04001000, 0x00400100, 0x00040010, 0x10004001, 0x00000406, 0x00040010, 0x00008000,
0x40000001, 0x04001000, 0x00400100, 0x00040010, 0x10004001, 0x00000403, 0x00040010, 0x00008000,
0x40000001, 0x04001000, 0x00400100, 0x00040010, 0x90004001, 0x00000401, 0x00040010, 0x00008000,
0x40000001, 0x04001000, 0x00400100, 0x00040010, 0xd00c4031, 0x00000400, 0x00040010, 0x00008000,
0x40000001, 0x04001000, 0x00400100, 0x00040010, 0x500c4031, 0x00000400, 0x00040010, 0x00008000,
0x40000001, 0x04001000, 0x00400100, 0x00040010, 0x10004019, 0x00000400, 0x00040010, 0x00008000,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x0000ffff,
0x00000000, 0x00000400, 0x00000000, 0x00000000, 0x00000000, 0x00000040, 0x00000000, 0x00000000,
0x00000000, 0x00000400, 0x00000000, 0x00000000, 0x00000000, 0x00000040, 0x00000100, 0x00000000,
0x00000000, 0x00000400, 0x00000000, 0x00000000, 0x00000000, 0xffc00040, 0x7ff00181, 0x00003ff8,
0x00000000, 0x00000400, 0x00000000, 0x00000000, 0x00000000, 0x00400040, 0x7ff001c1, 0x00002008,
0x00000000, 0x00000400, 0x00000000, 0x00000000, 0x00000000, 0x00400040, 0x7ff0ffe1, 0x00002828,
0x00000000, 0x00000400, 0x00000000, 0x00000000, 0x00000000, 0x80400040, 0x7ff0c1c1, 0x00002448,
0x00000000, 0x00000400, 0x00000000, 0x00000000, 0x00000000, 0x08400040, 0x7ff0c181, 0x00002288,
0x00000000, 0x00000400, 0x00000000, 0x00000000, 0x00000000, 0x1c400040, 0x4010c101, 0x00002108,
0x00000000, 0x00000400, 0x00000000, 0x00000000, 0x00000000, 0x08400040, 0x4010c001, 0x00002288,
0x00000000, 0x00000400, 0x00000000, 0x00000000, 0x00000000, 0x00400040, 0x4010c001, 0x00002448,
0x00000000, 0x00000400, 0x00000000, 0x00000000, 0x00000000, 0x08400040, 0x4010c001, 0x00002828,
0x00000000, 0x00000400, 0x00000000, 0x00000000, 0x00000000, 0x08400040, 0x4010ffe1, 0x00002008,
0x00000000, 0x00000400, 0x00000000, 0x00000000, 0x00000000, 0xffc00040, 0x7ff0ffe1, 0x00003ff8,
0x00000000, 0x00000400, 0x00000000, 0x00000000, 0x00000000, 0x00000040, 0x00000000, 0x00000000,
0x00000000, 0xfffffc00, 0xffffffff, 0xffffffff, 0xffffffff, 0x0000007f, 0x00000000, 0x00000000,
};
unsigned long kbd_image_5200[] =
{
0xc0000000, 0xffffffff, 0xfc0001ff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x0000000f,
0x40000000, 0x04001000, 0x04000100, 0x00000000, 0x00000080, 0x00200000, 0x00000000, 0x00000008,
0x40000000, 0x04001000, 0x04000100, 0x00000000, 0x00000080, 0x00200000, 0x00000000, 0x00000008,
0x40000000, 0x04001000, 0x04000100, 0x00000000, 0x00000080, 0x00200000, 0x00000000, 0x00000008,
0x40000000, 0x04001000, 0x04000100, 0x00000000, 0x00000080, 0x00200000, 0x00000000, 0x00000008,
0x40000000, 0x04001000, 0x04000100, 0x00000000, 0x00000080, 0x00200000, 0x00000000, 0x00000008,
0x40000000, 0x843c1060, 0x0400011f, 0x6000030f, 0x0007c080, 0xf8200000, 0x06000000, 0x00000008,
0x40000000, 0x04661070, 0x8400010c, 0xf9f3cfc1, 0x33ccc081, 0x982079f3, 0x1f9e7c79, 0x00000008,
0x40000000, 0x04301060, 0x04000106, 0x6336030f, 0x360cc080, 0x9820cc1b, 0x063306cd, 0x00000008,
0x40000000, 0x04181060, 0x0400010c, 0x6037c318, 0x37c7c080, 0xf820fcf3, 0x063f3cfc, 0x00000008,
0x40000000, 0x840c1060, 0x04000119, 0x60366318, 0x3660c080, 0xd8200d83, 0x0603600c, 0x00000008,
0x40000000, 0x047e11f8, 0x0400010f, 0xc037ce0f, 0xe7c0c081, 0x982078fb, 0x1c1e3e79, 0x00000008,
0x40000000, 0x04001000, 0x04000100, 0x00000000, 0x00000080, 0x00200000, 0x00000000, 0x00000008,
0x40000000, 0x04001000, 0x04000100, 0x00000000, 0x00000080, 0x00200000, 0x00000000, 0x00000008,
0x40000000, 0x04001000, 0x04000100, 0x00000000, 0x00000080, 0x00200000, 0x00000000, 0x00000008,
0x40000000, 0x04001000, 0x04000100, 0x00000000, 0x00000080, 0x00200000, 0x00000000, 0x00000008,
0xc0000000, 0xffffffff, 0xfc0001ff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x0000000f,
0x40000000, 0x04001000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x04001000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x04001000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x04001000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x04001000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x047e10c0, 0x0000010f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x840610e0, 0x00000101, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x843e10f0, 0x0000010f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x846010d8, 0x00000119, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x846611f8, 0x00000119, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x043c10c0, 0x0000010f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x04001000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x04001000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x04001000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x04001000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0xc0000000, 0xffffffff, 0x000001ff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x04001000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x04001000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x04001000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x04001000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x04001000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x043c11f8, 0x0000010f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x84661180, 0x00000119, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x043c10c0, 0x0000011f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x04661060, 0x00000118, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x04661030, 0x0000010c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x043c1030, 0x00000107, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x04001000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x04001000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x04001000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x04001000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0xc0000000, 0xffffffff, 0x000001ff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x04001000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x04001000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x04001000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x04001000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x04001000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x843c1198, 0x00000119, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0xc46610f0, 0x0000013f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x847613fc, 0x00000119, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x846e10f0, 0x00000119, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0xc4661198, 0x0000013f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x843c1000, 0x00000119, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x04001000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x04001000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x04001000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x40000000, 0x04001000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0xc0000000, 0xffffffff, 0x000001ff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffc00000, 0x7ff00181, 0x00003ff8,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00400000, 0x7ff001c1, 0x00002008,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00400000, 0x7ff0ffe1, 0x00002828,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x80400000, 0x7ff0c1c1, 0x00002448,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x08400000, 0x7ff0c181, 0x00002288,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1c400000, 0x4010c101, 0x00002108,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x08400000, 0x4010c001, 0x00002288,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00400000, 0x4010c001, 0x00002448,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x08400000, 0x4010c001, 0x00002828,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x08400000, 0x4010ffe1, 0x00002008,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffc00000, 0x7ff0ffe1, 0x00003ff8,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
};
struct sKeydata
{
short offset;
short key;
};
#define KBD_ROTATE -100
#define KBD_NEGATE -101
#define KBD_HIDE -102
sKeydata* kbd_struct;
int keys;
sKeydata kbd_struct_800[] =
{
/* first row */
{0,AKEY_ESCAPE},{14,AKEY_1},{28,AKEY_2},{42,AKEY_3},
{56,AKEY_4},{70,AKEY_5},{84,AKEY_6},{98,AKEY_7},
{112,AKEY_8},{126,AKEY_9},{140,AKEY_0},{154,AKEY_LESS},
{168,AKEY_GREATER},{182,AKEY_BACKSPACE},{196,AKEY_BREAK},{210,AKEY_HELP},
/* second row */
{240,AKEY_TAB},{261,AKEY_q},{275,AKEY_w},{289,AKEY_e},
{303,AKEY_r},{317,AKEY_t},{331,AKEY_y},{345,AKEY_u},
{359,AKEY_i},{373,AKEY_o},{387,AKEY_p},{401,AKEY_MINUS},
{415,AKEY_EQUAL},{429,AKEY_RETURN},{450,AKEY_F4},
/* third row */
{480,AKEY_CTRL},{505,AKEY_a},{519,AKEY_s},{533,AKEY_d},
{547,AKEY_f},{561,AKEY_g},{575,AKEY_h},{589,AKEY_j},
{603,AKEY_k},{617,AKEY_l},{631,AKEY_SEMICOLON},{645,AKEY_PLUS},
{659,AKEY_ASTERISK},{673,AKEY_CAPSTOGGLE},{690,AKEY_F3},
/* fourth row */
{720,AKEY_SHFT},{750,AKEY_z},{764,AKEY_x},{778,AKEY_c},
{792,AKEY_v},{806,AKEY_b},{820,AKEY_n},{834,AKEY_m},
{848,AKEY_COMMA},{862,AKEY_FULLSTOP},{876,AKEY_SLASH},{890,AKEY_SHFT},
{916,AKEY_ATARI},{930,AKEY_F2},
/* fifth row */
{960,AKEY_NONE},{975,AKEY_NONE},{1002,AKEY_SPACE},{1126,AKEY_NONE},
{1140,AKEY_UI},{1155,KBD_ROTATE},{1169,KBD_NEGATE},{1184,KBD_HIDE},
{1200, AKEY_NONE}
};
sKeydata kbd_struct_5200[] =
{
{0,AKEY_NONE}, {30,0x3f}, {44,0x3d}, {58,0x3b}, {72,AKEY_NONE},
{90,0x39},{135,0x31},{181,0x29},{227,AKEY_NONE},
{240,AKEY_NONE},{270,0x37},{284,0x35},{298,0x33},{312,AKEY_NONE},
{480,AKEY_NONE},{510,0x2f},{524,0x2d},{538,0x2b},{552,AKEY_NONE},
{720,AKEY_NONE},{750,0x27},{764,0x25},{778,0x23},{792,AKEY_NONE},
{960,AKEY_NONE},{975,AKEY_NONE},{1140,AKEY_UI},{1155,KBD_ROTATE},
{1169,KBD_NEGATE},{1184,KBD_HIDE},
{1200,AKEY_NONE}
};
// Keyboard translation table
struct sKeyTranslation
{
short winKey;
short aKey;
};
sKeyTranslation kbd_translation[] =
{
// Mappable entries
{0, AKEY_NONE}, // 5 joystick entries
{0, AKEY_NONE},
{0, AKEY_NONE},
{0, AKEY_NONE},
{0, AKEY_NONE},
{0, AKEY_UI},
{0, AKEY_F1},
{0, AKEY_F2},
{0, AKEY_F3},
{0, AKEY_F4},
{0, AKEY_HELP},
{0, AKEY_WARMSTART},
{0, AKEY_COLDSTART},
{0, AKEY_BREAK},
{VK_RETURN, AKEY_RETURN},
// Non-mappable entries
{VK_SHIFT, AKEY_SHFT},
{VK_CONTROL, AKEY_CTRL},
{'0', AKEY_0},
{'1', AKEY_1},
{'2', AKEY_2},
{'3', AKEY_3},
{'4', AKEY_4},
{'5', AKEY_5},
{'6', AKEY_6},
{'7', AKEY_7},
{'8', AKEY_8},
{'9', AKEY_9},
{'A', AKEY_a},
{'B', AKEY_b},
{'C', AKEY_c},
{'D', AKEY_d},
{'E', AKEY_e},
{'F', AKEY_f},
{'G', AKEY_g},
{'H', AKEY_h},
{'I', AKEY_i},
{'J', AKEY_j},
{'K', AKEY_k},
{'L', AKEY_l},
{'M', AKEY_m},
{'N', AKEY_n},
{'O', AKEY_o},
{'P', AKEY_p},
{'Q', AKEY_q},
{'R', AKEY_r},
{'S', AKEY_s},
{'T', AKEY_t},
{'U', AKEY_u},
{'V', AKEY_v},
{'W', AKEY_w},
{'X', AKEY_x},
{'Y', AKEY_y},
{'Z', AKEY_z},
{VK_LWIN, AKEY_HELP},
{VK_BACK, AKEY_BACKSPACE},
{VK_ESCAPE, AKEY_ESCAPE},
{VK_BACKQUOTE, AKEY_ATARI},
{VK_CAPITAL, AKEY_CAPSTOGGLE},
{VK_TAB, AKEY_TAB},
{VK_SPACE, AKEY_SPACE},
{VK_LBRACKET, AKEY_LESS},
{VK_RBRACKET, AKEY_GREATER},
{VK_EQUAL, AKEY_EQUAL},
{VK_SUBTRACT, AKEY_MINUS},
{VK_ADD, AKEY_PLUS},
{VK_MULTIPLY, AKEY_ASTERISK},
{VK_DIVIDE, AKEY_SLASH},
{VK_SEMICOLON, AKEY_SEMICOLON},
{VK_COMMA, AKEY_COMMA},
{VK_PERIOD, AKEY_FULLSTOP},
{VK_UP, AKEY_UP},
{VK_DOWN, AKEY_DOWN},
{VK_LEFT, AKEY_LEFT},
{VK_RIGHT, AKEY_RIGHT},
{VK_RETURN, AKEY_RETURN} // fallthrough case
};
#define KBDT_TRIGGER 0
#define KBDT_JOYUP 1
#define KBDT_JOYDOWN 2
#define KBDT_JOYLEFT 3
#define KBDT_JOYRIGHT 4
#define KBDT_UI 5
#define KBDT_F1 6
#define KBDT_F2 7
#define KBDT_F3 8
#define KBDT_F4 9
#define KBDT_HELP 10
#define KBDT_WARMSTART 11
#define KBDT_COLDSTART 12
#define KBDT_BREAK 13
#define KBDT_RETURN 14
void reset_kbd()
{
if(Atari800_machine_type == Atari800_MACHINE_5200)
{
kbd_image = kbd_image_5200;
kbd_struct = kbd_struct_5200;
keys = sizeof(kbd_struct_5200)/sizeof(kbd_struct_5200[0]);
}
else
{
kbd_image = kbd_image_800;
kbd_struct = kbd_struct_800;
keys = sizeof(kbd_struct_800)/sizeof(kbd_struct_800[0]);
}
}
short get_keypress(short x, short y)
{
int offset;
int i;
if(currentKeyboardMode == 4 && get_screen_mode())
return AKEY_NONE;
offset = x + (y/16)*240;
if(offset < 0)
return AKEY_NONE;
for(i=1; i<keys; i++)
if(offset < kbd_struct[i].offset)
return kbd_struct[i-1].key;
return AKEY_NONE;
}
static GXKeyList klist;
/* map joystick direction to expected key code by screen orientation */
short joykey_map[3][4];
int activeKey;
int activeMod;
int stick0;
int trig0;
void push_key(short akey);
void release_key(short akey);
void hitbutton(short code)
{
int kbcode = AKEY_NONE;
if(UI_is_active)
{
trig0 = 1;
stick0 = 0xff;
if(code == joykey_map[get_screen_mode()][0])
kbcode = AKEY_UP;
else if(code == joykey_map[get_screen_mode()][1])
kbcode = AKEY_DOWN;
else if(code == joykey_map[get_screen_mode()][2])
kbcode = AKEY_LEFT;
else if(code == joykey_map[get_screen_mode()][3])
kbcode = AKEY_RIGHT;
else if(code == klist.vkStart && !issmartphone)
kbcode = AKEY_BACKSPACE;
else if(code == klist.vkA)
kbcode = AKEY_SPACE;
else if(code == klist.vkB)
kbcode = AKEY_RETURN;
else if(code == klist.vkC)
kbcode = AKEY_ESCAPE;
else
for(int i=0; i<sizeof(kbd_translation)/sizeof(kbd_translation[0]); i++)
if(code == kbd_translation[i].winKey)
{
kbcode = kbd_translation[i].aKey;
break;
}
}
else
{
if(code == joykey_map[get_screen_mode()][0])
stick0 &= ~1;
else if(code == joykey_map[get_screen_mode()][1])
stick0 &= ~2;
else if(code == joykey_map[get_screen_mode()][2])
stick0 &= ~4;
else if(code == joykey_map[get_screen_mode()][3])
stick0 &= ~8;
else if(code == klist.vkA || code == klist.vkB || ((code == '4' || code == '6') && issmartphone))
trig0 = 0;
else if(code == klist.vkC)
{
if (!kbui_timerset)
{
SetTimer(hWndMain, 1, 1000, NULL);
kbui_timerset = TRUE;
}
}
else if ((code == VK_F3) && (issmartphone))
set_screen_mode(get_screen_mode()+1);
else
for(int i=0; i<sizeof(kbd_translation)/sizeof(kbd_translation[0]); i++)
if(code == kbd_translation[i].winKey)
{
kbcode = kbd_translation[i].aKey;
break;
}
}
if(kbcode != AKEY_NONE)
push_key(kbcode);
}
void releasebutton(short code)
{
int kbcode = AKEY_NONE, temp_ui = -1;
if(UI_is_active)
release_key(kbcode);
else
{
if(code == joykey_map[get_screen_mode()][0])
stick0 |= 1;
else if(code == joykey_map[get_screen_mode()][1])
stick0 |= 2;
else if(code == joykey_map[get_screen_mode()][2])
stick0 |= 4;
else if(code == joykey_map[get_screen_mode()][3])
stick0 |= 8;
else if(code == klist.vkA || code == klist.vkB || ((code == '4' || code == '6') && issmartphone))
trig0 = 1;
else if(code == klist.vkC)
if (kbui_timerset)
{
KillTimer(hWndMain, 1);
kbui_timerset = FALSE;
set_screen_mode(0);
kbcode = AKEY_UI;
push_key(kbcode);
ui_clearkey = TRUE;
return;
}
}
release_key(kbcode); // always release or the ui gets stuck
}
void Start_KBUI(void)
{
int kbcode, temp_ui;
KillTimer(hWndMain, 1);
kbui_timerset = FALSE;
temp_ui = UI_is_active;
UI_is_active = TRUE;
kbcode = UI_BASIC_OnScreenKeyboard("Select Atari key to inject once", Atari800_machine_type);
if (kbcode != AKEY_NONE)
push_key(kbcode);
else
release_key(AKEY_NONE);
UI_is_active = temp_ui;
return;
}
void tapscreen(short x, short y)
{
short kbcode;
stylus_down = 1;
/* On-screen joystick */
if(virtual_joystick && !UI_is_active && currentKeyboardMode == 4 && y < 240)
{
stick0 = 0xff;
trig0 = 1;
if(y < 90) /* up */
stick0 &= ~1;
if(y >= 150) /* down */
stick0 &= ~2;
if(x < 120) /* left */
stick0 &= ~4;
if(x >= 200) /* right */
stick0 &= ~8;
if(x >= 60 && x < 260 && y >= 45 && y < 195)
trig0 = 0;
return;
}
translate_kbd(&x, &y);
/* In landscape - show keyboard if clicked bottom right corner */
if(get_screen_mode() && currentKeyboardMode == 4 && x > 300 && y > 220)
return;
kbcode = get_keypress(x, y);
/* Special keys */
switch(kbcode)
{
case KBD_ROTATE:
case KBD_NEGATE:
case KBD_HIDE:
return;
}
/* The way current UI works, it is not compatible with keyboard implementation
in landscape mode */
if(kbcode == AKEY_UI)
set_screen_mode(0);
/* Special translation to make on-screen UI easier to use */
if(UI_is_active)
{
if(Atari800_machine_type == Atari800_MACHINE_5200)
{
switch(kbcode)
{
case 0x3d: /* 2 */
kbcode = AKEY_UP;
break;
case 0x2d: /* 8 */
kbcode = AKEY_DOWN;
break;
case 0x37: /* 4 */
kbcode = AKEY_LEFT;
break;
case 0x33: /* 6 */
kbcode = AKEY_RIGHT;
break;
case 0x39: /* Start */
kbcode = AKEY_RETURN;
break;
case 0x27: /* * */
kbcode = AKEY_ESCAPE;
break;
case 0x31: /* Pause */
kbcode = AKEY_TAB;
break;
case 0x23: /* # */
kbcode = AKEY_SPACE;
break;
}
}
else
{
switch(kbcode)
{
case AKEY_MINUS:
kbcode = AKEY_UP;
break;
case AKEY_EQUAL:
kbcode = AKEY_DOWN;
break;
case AKEY_PLUS:
kbcode = AKEY_LEFT;
break;
case AKEY_ASTERISK:
kbcode = AKEY_RIGHT;
break;
}
}
}
push_key(kbcode);
}
void untapscreen(short x, short y)
{
int kbcode;
stylus_down = 0;
/* On-screen joystick */
if(virtual_joystick && !UI_is_active && currentKeyboardMode == 4 && y < 240)
{
stick0 = 0xff;
trig0 = 1;
return;
}
translate_kbd(&x, &y);
/* Special tricks */
/* In landscape - show keyboard if clicked bottom right corner */
if(get_screen_mode() && currentKeyboardMode == 4)
{
if(x > 300 && y > 220 && !UI_is_active)
currentKeyboardMode = 3;
else if(UI_is_active)
set_screen_mode(0);
return;
}
/* In landscape -- move keyboard if clicked outside of it */
int newKeyboardMode = currentKeyboardMode;
if(get_screen_mode() && currentKeyboardMode != 4)
{
if(x<0 || x>=240)
newKeyboardMode = newKeyboardMode ^ 1;
if(y<0 || y>=80)
newKeyboardMode = newKeyboardMode ^ 2;
}
if(newKeyboardMode != currentKeyboardMode)
{
currentKeyboardMode = newKeyboardMode;
return;
}
kbcode = get_keypress(x, y);
/* Special keys */
switch(kbcode)
{
case KBD_ROTATE:
if(!UI_is_active)
set_screen_mode(get_screen_mode()+1);
return;
case KBD_NEGATE:
currentKeyboardColor = 1-currentKeyboardColor;
return;
case KBD_HIDE:
if(get_screen_mode())
currentKeyboardMode = 4;
return;
}
/* Special translation to make on-screen UI easier to use */
if(UI_is_active)
{
if(Atari800_machine_type == Atari800_MACHINE_5200)
{
switch(kbcode)
{
case 0x3d: /* 2 */
kbcode = AKEY_UP;
break;
case 0x2d: /* 8 */
kbcode = AKEY_DOWN;
break;
case 0x37: /* 4 */
kbcode = AKEY_LEFT;
break;
case 0x33: /* 6 */
kbcode = AKEY_RIGHT;
break;
case 0x39: /* Start */
kbcode = AKEY_RETURN;
break;
case 0x27: /* * */
kbcode = AKEY_ESCAPE;
break;
case 0x31: /* Pause */
kbcode = AKEY_TAB;
break;
case 0x23: /* # */
kbcode = AKEY_SPACE;
break;
}
}
else
{
switch(kbcode)
{
case AKEY_MINUS:
kbcode = AKEY_UP;
break;
case AKEY_EQUAL:
kbcode = AKEY_DOWN;
break;
case AKEY_PLUS:
kbcode = AKEY_LEFT;
break;
case AKEY_ASTERISK:
kbcode = AKEY_RIGHT;
break;
}
}
}
release_key(kbcode);
}
void dragscreen(short x, short y)
{
if(stylus_down && virtual_joystick && !UI_is_active && currentKeyboardMode == 4 && y < 240)
{
translate_kbd(&x, &y);
/* On-screen joystick trigger (in portrait or in landscape if no keyboard */
if(virtual_joystick && currentKeyboardMode == 4)
{
stick0 = 0xff;
trig0 = 1;
if(y < 90) /* up */
stick0 &= ~1;
if(y >= 150) /* down */
stick0 &= ~2;
if(x < 120) /* left */
stick0 &= ~4;
if(x >= 200) /* right */
stick0 &= ~8;
if(x >= 60 && x < 260 && y >= 45 && y < 195)
trig0 = 0;
return;
}
}
}
void push_key(short akey)
{
switch(akey)
{
case AKEY_NONE:
case AKEY_UI:
activeKey = akey;
activeMod = 0;
break;
case AKEY_SHFT:
activeMod ^= 0x40;
break;
case AKEY_CTRL:
activeMod ^= 0x80;
break;
case AKEY_F2:
case AKEY_OPTION:
INPUT_key_consol &= ~INPUT_CONSOL_OPTION;
break;
case AKEY_F3:
case AKEY_SELECT:
INPUT_key_consol &= ~INPUT_CONSOL_SELECT;
break;
case AKEY_F4:
case AKEY_START:
INPUT_key_consol &= ~INPUT_CONSOL_START;
break;
default:
activeKey = akey|activeMod;
activeMod = 0;
INPUT_key_shift = (activeKey & AKEY_SHFT) || (activeKey & AKEY_SHFTCTRL);
}
}
void release_key(short akey)
{
activeKey = AKEY_NONE;
INPUT_key_consol = INPUT_CONSOL_NONE;
INPUT_key_shift = 0;
}
int get_last_key()
{
if (ui_clearkey)
{
ui_clearkey = FALSE;
release_key(AKEY_UI);
return AKEY_UI;
}
else if(activeKey != AKEY_BREAK)
return activeKey;
else
{
/* There is special case */
release_key(AKEY_BREAK);
return AKEY_BREAK;
}
}
int prockb(void)
{
static int framectr = 0;
#ifndef MULTITHREADED
MsgPump();
#endif
/* UI.C violates the rest of architecture */
if(UI_is_active && framectr++ == 5)
{
reset_kbd();
refresh_kbd();
framectr = 0;
}
return 0;
}
void uninitinput(void)
{
/* To prevent start key leak to OS */
while(GetAsyncKeyState(klist.vkStart) & 0x8000)
#ifndef MULTITHREADED
MsgPump();
#else
Sleep(10);
#endif
GXCloseInput();
}
int initinput(void)
{
GXOpenInput();
klist = GXGetDefaultKeys(GX_NORMALKEYS);
joykey_map[0][0] = klist.vkUp;
joykey_map[0][1] = klist.vkDown;
joykey_map[0][2] = klist.vkLeft;
joykey_map[0][3] = klist.vkRight;
joykey_map[1][0] = klist.vkLeft;
joykey_map[1][1] = klist.vkRight;
joykey_map[1][2] = klist.vkDown;
joykey_map[1][3] = klist.vkUp;
joykey_map[2][0] = klist.vkRight;
joykey_map[2][1] = klist.vkLeft;
joykey_map[2][2] = klist.vkUp;
joykey_map[2][3] = klist.vkDown;
if (smkeyhack)
{
klist.vkB ^= klist.vkC;
klist.vkC ^= klist.vkB;
klist.vkB ^= klist.vkC;
}
if (issmartphone)
{
kbd_translation[KBDT_F3].winKey = '8';
kbd_translation[KBDT_F2].winKey = '7';
kbd_translation[KBDT_UI].winKey = klist.vkC;
kbd_translation[KBDT_F4].winKey = '9';
kbd_translation[KBDT_RETURN].winKey = '0';
}
else
{
kbd_translation[KBDT_F3].winKey = klist.vkA;
kbd_translation[KBDT_F2].winKey = klist.vkB;
kbd_translation[KBDT_UI].winKey = klist.vkC;
}
kbd_image = kbd_image_800;
kbd_struct = kbd_struct_800;
keys = sizeof(kbd_struct_800)/sizeof(kbd_struct_800[0]);
clearkb();
stylus_down = 0;
return 0;
}
void clearkb(void)
{
activeKey = AKEY_NONE;
activeMod = 0;
INPUT_key_consol = INPUT_CONSOL_NONE;
stick0 = 0xff;
trig0 = 1;
}
+38
View File
@@ -0,0 +1,38 @@
#ifndef _KEYBOARD_H_
#define _KEYBOARD_H_
int prockb(void);
int initinput(void);
void uninitinput(void);
void clearkb(void);
void hitbutton(short);
void releasebutton(short);
void tapscreen(short x, short y);
void untapscreen(short x, short y);
void dragscreen(short x, short y);
void Start_KBUI();
extern int console;
extern int trig0;
extern int stick0;
int get_last_key();
/* 0 to 3 - overlay in landscape, 4 - not visible or portrait mode*/
extern int currentKeyboardMode;
/* 1 for negative image */
extern int currentKeyboardColor;
/* Packed bitmap 240x80 - five rows of buttons */
extern unsigned long* kbd_image;
/* Use virtual joystick */
extern int virtual_joystick;
/* Swap vkB + vkC keys for some smartphones */
extern int smkeyhack;
#endif /* _KEYBOARD_H_ */
+258
View File
@@ -0,0 +1,258 @@
/*
* main.c - WinCE port specific code
*
* Copyright (C) 2001 Vasyl Tsvirkunov
* Copyright (C) 2001-2006 Atari800 development team (see DOC/CREDITS)
*
* This file is part of the Atari800 emulator project which emulates
* the Atari 400, 800, 800XL, 130XE, and 5200 8-bit computers.
*
* Atari800 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.
*
* Atari800 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 Atari800; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* Based on Win32 port by Krzysztof Nikiel */
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include "config.h"
#include "main.h"
#include "screen_wince.h"
#include "keyboard.h"
#include "sound.h"
#include "ui.h"
LPTSTR myname = TEXT("Pocket Atari");
char* mynameb = "Pocket Atari";
HWND hWndMain;
HINSTANCE myInstance;
char issmartphone = 0;
extern int wince_main(int argc, char **argv);
extern void Screen_EntireDirty(void);
extern UBYTE *Screen_dirty;
//extern void OrientationChanged(void);
static char **gargv = NULL;
static int gargc = 0;
void __cdecl atari_exit(int code)
{
#ifdef MULTITHREADED
ExitThread(code);
#else
MsgPump();
#endif
}
void wce_perror(char* s)
{
TCHAR sUnc[100];
gr_suspend();
MultiByteToWideChar(CP_ACP, 0, s, -1, sUnc, 100);
MessageBox(hWndMain, sUnc, TEXT("Error"), MB_OK|MB_ICONERROR);
gr_resume();
}
DWORD WINAPI vloop(LPVOID p)
{
srand(GetTickCount());
wince_main(gargc, gargv);
atari_exit(0);
return 0;
}
static long FAR PASCAL WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static POINT lastClick;
static PAINTSTRUCT ps;
switch (message)
{
/* All right, I don't understand this. PPC2000 throws VK_LWIN every time button
is pressed and PPC2002 adds VK_F21 after each joystick press */
case WM_KEYDOWN:
if(wParam != VK_LWIN && wParam != VK_F21) // huh?
hitbutton((short)wParam);
return 0;
case WM_KEYUP:
if(wParam != VK_LWIN && wParam != VK_F21) // huh?
releasebutton((short)wParam);
return 0;
case WM_LBUTTONDOWN:
lastClick.x = LOWORD(lParam);
lastClick.y = HIWORD(lParam);
ClientToScreen(hWnd, &lastClick);
tapscreen((short)lastClick.x, (short)lastClick.y);
SetCapture(hWnd);
return 0;
case WM_LBUTTONUP:
untapscreen((short)lastClick.x, (short)lastClick.y);
ReleaseCapture();
return 0;
case WM_MOUSEMOVE:
lastClick.x = LOWORD(lParam);
lastClick.y = HIWORD(lParam);
ClientToScreen(hWnd, &lastClick);
dragscreen((short)lastClick.x, (short)lastClick.y);
return 0;
case WM_PAINT:
BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_SETFOCUS:
case WM_ACTIVATE:
if (Screen_dirty) Screen_EntireDirty();
gr_resume();
return 0;
case WM_KILLFOCUS:
case WM_HIBERNATE:
gr_suspend();
return 0;
case WM_SETTINGCHANGE:
OrientationChanged();
break;
case WM_TIMER:
Start_KBUI();
return 0;
}
/* In the first version all other events were merrily dropped on floor in singlethreaded
model. That caused some troubles with debugging and suspected to cause spurious key up
messages. Nevertheless, this call does not affect performance in any noticeable way and
it is much nicer to the OS. */
return DefWindowProc(hWnd, message, wParam, lParam);
}
#ifndef MULTITHREADED
void MsgPump()
{
MSG msg;
while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
WindowProc(msg.hwnd, msg.message, msg.wParam, msg.lParam);
}
#endif
static BOOL initwin(HINSTANCE hInstance, int nCmdShow)
{
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WindowProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = NULL;
wc.hCursor = NULL;
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = myname;
RegisterClass(&wc);
hWndMain = CreateWindow(myname,
myname,
WS_VISIBLE,
0,
0,
GetSystemMetrics(SM_CXSCREEN),
GetSystemMetrics(SM_CYSCREEN),
NULL,
NULL,
hInstance,
NULL);
if(!hWndMain)
return 1;
SetWindowPos(hWndMain, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
UpdateWindow(hWndMain);
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
{
#ifdef MULTITHREADED
MSG msg;
HANDLE hth;
#endif
int i;
static int argc = 0;
static char args[0x400];
static char *argv[100];
TCHAR platform[100];
myInstance = hInstance;
if(initwin(hInstance, nCmdShow))
{
return 1;
}
#ifndef MULTITHREADED
MsgPump();
#endif
if (SystemParametersInfo(SPI_GETPLATFORMTYPE, 100, platform, 0))
{
if (wcsstr(platform, _T("mart")))
issmartphone = 1;
}
else
issmartphone = 1; /* it probably is a smartphone */
if(lpCmdLine)
WideCharToMultiByte(CP_ACP, 0, lpCmdLine, -1, args, 0x400, NULL, NULL);
else
args[0] = 0;
argv[argc++] = mynameb;
for(i = 0; i < (sizeof(args) - 1) && args[i]; i++)
{
while(args[i] == ' ' && i < (sizeof(args) - 1))
i++;
if(args[i] && i < (sizeof(args) - 1))
{
argv[argc++] = &args[i];
if((argc + 1) >= (sizeof(argv) / sizeof(argv[0])))
break;
}
while(args[i] != ' ' && args[i] && i < (sizeof(args) - 1))
i++;
args[i] = 0;
}
argv[argc] = NULL;
gargv = argv;
gargc = argc;
#ifdef MULTITHREADED
if((hth = CreateThread(NULL, 0x10000, vloop, NULL, 0, NULL)) == NULL)
return 1;
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
/* wait for the other thread to exit */
WaitForSingleObject((HANDLE)hth, INFINITE);
return msg.wParam;
#else
vloop(NULL);
return 0;
#endif
}
+17
View File
@@ -0,0 +1,17 @@
#ifndef _MAIN_H_
#define _MAIN_H_
extern LPTSTR myname;
extern HWND hWndMain;
extern HINSTANCE myInstance;
extern char issmartphone;
// Multi-threaded implementation has no benefit over single threaded and it
// has very odd codepath. I will leave code in place anyway */
//#define MULTITHREADED
#ifndef MULTITHREADED
void MsgPump();
#endif
#endif /* _MAIN_H_ */
+97
View File
@@ -0,0 +1,97 @@
#include <windows.h>
#include <tchar.h>
#include <string.h>
#include "config.h"
char *getcwd(char *buffer, int maxlen);
char *tmpnam(char *string)
{
TCHAR pTemp[MAX_PATH+1], cwdw[MAX_PATH+1];
static char buffer[MAX_PATH+1], *fname;
char cwd[MAX_PATH+1];
getcwd(cwd, MAX_PATH);
MultiByteToWideChar(CP_ACP, 0, cwd, -1, cwdw, MAX_PATH);
GetTempFileName(cwdw, TEXT("A8_"), 0, pTemp);
WideCharToMultiByte(CP_ACP, 0, pTemp, -1, buffer, MAX_PATH, NULL, NULL);
fname = strrchr(buffer, '\\');
if (!fname)
fname = buffer;
else
fname++;
if(string)
{
strncpy(string, fname, FILENAME_MAX);
return string;
}
else
return fname;
}
FILE *tmpfile()
{
TCHAR pTemp[MAX_PATH+1], cwdw[MAX_PATH+1];
char cwd[MAX_PATH+1];
getcwd(cwd, MAX_PATH);
MultiByteToWideChar(CP_ACP, 0, cwd, -1, cwdw, MAX_PATH);
GetTempFileName(cwdw, TEXT("A8_"), 0, pTemp);
return _wfopen(pTemp, TEXT("w+b"));
}
char cwd[MAX_PATH+1];
char *getcwd(char *buffer, int maxlen)
{
TCHAR fileUnc[MAX_PATH+1];
char* plast;
if(cwd[0] == 0)
{
GetModuleFileName(NULL, fileUnc, MAX_PATH);
WideCharToMultiByte(CP_ACP, 0, fileUnc, -1, cwd, MAX_PATH, NULL, NULL);
plast = strrchr(cwd, '\\');
if(plast)
*plast = 0;
/* Special trick to keep start menu clean... */
if(_stricmp(cwd, "\\windows\\start menu") == 0)
strcpy(cwd, "\\Atari800");
}
if(buffer)
strncpy(buffer, cwd, maxlen);
return cwd;
}
/*
Windows CE fopen has non-standard behavior -- not
fully qualified paths refer to root folder rather
than current folder (concept not implemented in CE).
*/
#undef fopen
FILE* wce_fopen(const char* fname, const char* fmode)
{
char fullname[MAX_PATH+1];
if(!fname || fname[0] == '\0')
return NULL;
if(fname[0] != '\\' && fname[0] != '/')
{
getcwd(fullname, MAX_PATH);
strncat(fullname, "\\", MAX_PATH-strlen(fullname)-1);
strncat(fullname, fname, MAX_PATH-strlen(fullname)-strlen(fname));
return fopen(fullname, fmode);
}
else
return fopen(fname, fmode);
}
/* The only environment variable used by Atari800 at this point is HOME */
char* getenv(const char* varname)
{
if(strcmp(varname, "HOME") == 0)
return getcwd(NULL, 0);
else
return NULL;
}
+32
View File
@@ -0,0 +1,32 @@
/* Missing types and forward declarations for windows ce port */
#ifndef _WCEMISSING_H_
#define _WCEMISSING_H_
#include <stdlib.h>
#include <stdio.h>
/* some extra defines not covered in config.h */
#define NO_YPOS_BREAK_FLICKER 1
#define DIRTYRECT 1
#define SUPPORTS_ATARI_CONFIGINIT 1
#ifndef HAVE_WINDOWS_H
#define HAVE_WINDOWS_H 1
#endif
#define USE_UI_BASIC_ONSCREEN_KEYBOARD 1
#define perror(s) wce_perror(s)
void wce_perror(char *s);
FILE * __cdecl wce_fopen(const char *fname, const char *fmode);
#define fopen wce_fopen
/* forward declarations of missing functions */
char *tmpnam(char *string);
FILE *tmpfile();
char *getcwd(char *buffer, int maxlen);
char *getenv(const char *varname);
#endif
+26
View File
@@ -0,0 +1,26 @@
/*
* resource.rc - WinCE port specific code
*
* Copyright (C) 2001 Vasyl Tsvirkunov
* Copyright (C) 2001-2006 Atari800 development team (see DOC/CREDITS)
*
* This file is part of the Atari800 emulator project which emulates
* the Atari 400, 800, 800XL, 130XE, and 5200 8-bit computers.
*
* Atari800 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.
*
* Atari800 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 Atari800; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
101 ICON DISCARDABLE icon1.ico
HI_RES_AWARE CEUX {1}
File diff suppressed because it is too large Load Diff
+29
View File
@@ -0,0 +1,29 @@
#ifndef _SCREEN_WINCE_H_
#define _SCREEN_WINCE_H_
#include "atari.h"
int gron(int *argc, char *argv[]);
void groff(void);
void palette(int ent, UBYTE r, UBYTE g, UBYTE b);
void refreshv(UBYTE * scr_ptr);
void refresh_kbd();
void palette_update();
void gr_suspend();
void gr_resume();
void OrientationChanged(void);
/* meaning: 0 - portrait, 1 - left hand landscape, 2 - right hand landscape */
void set_screen_mode(int mode);
int get_screen_mode();
/* translate physical coordinates to logical keyboard coordinates */
void translate_kbd(short* px, short* py);
extern int smooth_filter;
extern int filter_available;
extern int emulator_active;
#endif /* _SCREEN_WINCE_H_ */
+267
View File
@@ -0,0 +1,267 @@
/*
* sound.c - WinCE port specific code
*
* Copyright (C) 2000 Krzysztof Nikiel
* Copyright (C) 2000-2006 Atari800 development team (see DOC/CREDITS)
*
* This file is part of the Atari800 emulator project which emulates
* the Atari 400, 800, 800XL, 130XE, and 5200 8-bit computers.
*
* Atari800 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.
*
* Atari800 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 Atari800; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config.h"
#ifdef SOUND
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include "sound.h"
#include "main.h"
#include "pokeysnd.h"
#include "atari.h"
#include "log.h"
#define WAVSHIFT 9
#define WAVSIZE (1 << WAVSHIFT)
int buffers = 0;
enum {SOUND_NONE, SOUND_WAV};
static int issound = SOUND_NONE;
static int dsprate = 22050;
static int snddelay = 40; /* delay in milliseconds */
static int snddelaywav = 100;
#ifdef STEREO_SOUND
static int stereo = TRUE;
#else
static int stereo = FALSE;
#endif
static HANDLE event;
static HWAVEOUT wout;
static WAVEHDR *waves;
static void uninitsound_wav(void)
{
int i;
MMRESULT err;
if (issound != SOUND_WAV)
return;
l0:
for (i = 0; i < buffers; i++)
{
if (!(waves[i].dwFlags & WHDR_DONE))
{
WaitForSingleObject(event, 5000);
ResetEvent(event);
goto l0;
}
}
waveOutReset (wout);
for (i = 0; i < buffers; i++)
{
err = waveOutUnprepareHeader(wout, &waves[i], sizeof (waves[i]));
if (err != MMSYSERR_NOERROR)
{
fprintf(stderr, "warning: cannot unprepare wave header (%x)\n", err);
}
free(waves[i].lpData);
}
free(waves);
waveOutClose(wout);
CloseHandle(event);
issound = SOUND_NONE;
}
static int initsound_wav(void)
{
int i;
WAVEFORMATEX wf;
MMRESULT err;
event = CreateEvent(NULL, TRUE, FALSE, NULL);
memset(&wf, 0, sizeof(wf));
wf.wFormatTag = WAVE_FORMAT_PCM;
wf.nChannels = stereo ? 2 : 1;
wf.nSamplesPerSec = dsprate;
wf.nAvgBytesPerSec = dsprate * wf.nChannels;
wf.nBlockAlign = 2;
wf.wBitsPerSample = 8;
wf.cbSize = 0;
err = waveOutOpen(&wout, WAVE_MAPPER, &wf, (int)event, 0, CALLBACK_EVENT);
if (err == WAVERR_BADFORMAT)
{
Log_print("wave output parameters unsupported\n");
return 1;
}
if (err != MMSYSERR_NOERROR)
{
Log_print("cannot open wave output (%x)\n", err);
return 1;
}
buffers = ((wf.nAvgBytesPerSec * snddelaywav / 1000) >> WAVSHIFT) + 1;
waves = malloc(buffers * sizeof(*waves));
for (i = 0; i < buffers; i++)
{
memset(&waves[i], 0, sizeof (waves[i]));
if (!(waves[i].lpData = (uint8 *)malloc(WAVSIZE)))
{
Log_print("could not get wave buffer memory\n");
return 1;
}
waves[i].dwBufferLength = WAVSIZE;
err = waveOutPrepareHeader(wout, &waves[i], sizeof(waves[i]));
if (err != MMSYSERR_NOERROR)
{
Log_print("cannot prepare wave header (%x)\n", err);
return 1;
}
memset(waves[i].lpData, 0, WAVSIZE); // kill clicking sounds at startup
waves[i].dwFlags |= WHDR_DONE;
}
POKEYSND_Init(FREQ_17_EXACT,(uint16) dsprate, 1, 0);
issound = SOUND_WAV;
return 0;
}
int Sound_Initialise(int *argc, char *argv[])
{
int i, j;
int help_only = FALSE;
int usesound = TRUE;
if (issound != SOUND_NONE)
return TRUE;
for (i = j = 1; i < *argc; i++)
{
int i_a = (i + 1 < *argc); /* is argument available? */
int a_m = FALSE; /* error, argument missing! */
if (strcmp(argv[i], "-sound") == 0)
usesound = TRUE;
else if (strcmp(argv[i], "-nosound") == 0)
usesound = FALSE;
else if (strcmp(argv[i], "-dsprate") == 0)
{
if (i_a)
sscanf(argv[++i], "%d", &dsprate);
else a_m = TRUE;
}
else if (strcmp(argv[i], "-snddelay") == 0)
{
if (i_a)
{
sscanf(argv[++i], "%d", &snddelay);
snddelaywav = snddelay;
}
else a_m = TRUE;
}
else
{
if (strcmp(argv[i], "-help") == 0)
{
help_only = TRUE;
Log_print("\t-sound enable sound\n"
"\t-nosound disable sound\n"
"\t-dsprate <rate> set dsp rate\n"
"\t-snddelay <milliseconds> set sound delay\n"
);
}
argv[j++] = argv[i];
}
if (a_m) {
Log_print("Missing argument for '%s'", argv[i]);
usesound = FALSE;
return FALSE;
}
}
*argc = j;
if (help_only || !usesound) {
usesound = FALSE;
return TRUE;
}
initsound_wav();
return TRUE;
}
void Sound_Exit(void)
{
if (issound == SOUND_WAV)
uninitsound_wav();
issound = SOUND_NONE;
}
static WAVEHDR *getwave(void)
{
int i;
for (i = 0; i < buffers; i++)
{
if (waves[i].dwFlags & WHDR_DONE)
{
waves[i].dwFlags &= ~WHDR_DONE;
return &waves[i];
}
}
return NULL;
}
void Sound_Update(void)
{
WAVEHDR *wh;
int i;
if (issound == SOUND_WAV)
{
for (i=0; i<buffers; i++)
if (waves[i].dwFlags & WHDR_DONE)
{
wh = &waves[i];
POKEYSND_Process(wh->lpData, wh->dwBufferLength);
waveOutWrite(wout, wh, sizeof(*wh));
}
}
}
void Sound_Pause(void)
{
}
void Sound_Continue(void)
{
}
#endif /* SOUND */