mirror of
https://github.com/david-schmidt/gsport.git
synced 2024-12-28 03:30:05 +00:00
Merge in changes from activegs
This commit is contained in:
parent
ad70b6bd8d
commit
5dc39a808f
@ -135,4 +135,6 @@ uilib.o: tfe/uilib.c tfe/uilib.h tfe/tfe_protos.h
|
||||
macdriver.o: macdriver.c defc.h defcomm.h iwm.h protos.h protos_macdriver.h
|
||||
macsnd_driver.o: macsnd_driver.c defc.h defcomm.h iwm.h protos.h sound.h
|
||||
windriver.o: windriver.c defc.h defcomm.h iwm.h protos.h protos_windriver.h winresource.h gsport32.o
|
||||
win_console.o: win_console.c defc.h defcomm.h iwm.h protos.h protos_windriver.h winresource.h
|
||||
win_generic.o: win_generic.c defc.h defcomm.h iwm.h protos.h protos_windriver.h winresource.h
|
||||
win32snd_driver.o: win32snd_driver.c defc.h defcomm.h iwm.h protos.h sound.h
|
||||
|
19
src/adb.c
19
src/adb.c
@ -197,6 +197,11 @@ adb_init()
|
||||
adb_reset();
|
||||
}
|
||||
|
||||
// OG Added adb_shut()
|
||||
void adb_shut()
|
||||
{
|
||||
g_adb_init = 0;
|
||||
}
|
||||
|
||||
void
|
||||
adb_reset()
|
||||
@ -796,9 +801,14 @@ adb_write_c026(int val)
|
||||
}
|
||||
break;
|
||||
default:
|
||||
halt_printf("ADB ucontroller cmd %02x unknown!\n", val);
|
||||
/* The Gog's says ACS Demo 2 has a bug and writes to */
|
||||
/* c026 */
|
||||
// OG
|
||||
if (val==0x84)
|
||||
printf("ACS Demo2 (3: Colum& Music scroll) : discarding unknown controller command\n");
|
||||
else
|
||||
halt_printf("ADB ucontroller cmd %02x unknown!\n", val);
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -1714,6 +1724,8 @@ adb_physical_key_update(int a2code, int is_up)
|
||||
|
||||
if(special && !is_up) {
|
||||
switch(special) {
|
||||
// OG Disabled special keys (but warp)
|
||||
#ifndef ACTIVEGS
|
||||
case 0x04: /* F4 - Emulator config panel */
|
||||
cfg_toggle_config_panel();
|
||||
break;
|
||||
@ -1729,6 +1741,7 @@ adb_physical_key_update(int a2code, int is_up)
|
||||
printf("g_fast_disk_emul is now %d\n",
|
||||
g_fast_disk_emul);
|
||||
break;
|
||||
#endif
|
||||
case 0x08: /* F8 - warp pointer */
|
||||
g_warp_pointer = !g_warp_pointer;
|
||||
if(g_hide_pointer != g_warp_pointer) {
|
||||
@ -1736,6 +1749,7 @@ adb_physical_key_update(int a2code, int is_up)
|
||||
x_hide_pointer(g_hide_pointer);
|
||||
}
|
||||
break;
|
||||
#ifndef ACTIVEGS
|
||||
case 0x09: /* F9 - swap paddles */
|
||||
if(SHIFT_DOWN) {
|
||||
g_swap_paddles = !g_swap_paddles;
|
||||
@ -1754,6 +1768,7 @@ adb_physical_key_update(int a2code, int is_up)
|
||||
g_fullscreen = !g_fullscreen;
|
||||
x_full_screen(g_fullscreen);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
return;
|
||||
@ -1768,7 +1783,7 @@ adb_physical_key_update(int a2code, int is_up)
|
||||
if(ascii > 0x30 && ascii <= 0x39) {
|
||||
g_keypad_key_is_down[ascii - 0x30] = !is_up;
|
||||
}
|
||||
if(g_joystick_type == 0) {
|
||||
if(g_joystick_type == JOYSTICK_TYPE_KEYPAD) {
|
||||
/* If Joystick type is keypad, then do not let these */
|
||||
/* keypress pass on further, except for cmd/opt */
|
||||
if(ascii == 0x30) {
|
||||
|
@ -141,7 +141,9 @@ const int a2_key_to_ascii[][4] = {
|
||||
{ 0x67, 0x800b, 0x1067, -1 }, /* F11 */
|
||||
|
||||
{ 0x68, -1, -1, -1 },
|
||||
{ 0x69, 0x800d, 0x1069, -1 }, /* F13 */
|
||||
// { 0x69, 0x800d, 0x1069, -1 }, /* F13 */
|
||||
// OG remap F13 to reset
|
||||
{ 0x69, 0x800c, 0x1069, -1 }, /* F13 */
|
||||
{ 0x6a, -1, -1, -1 },
|
||||
{ 0x6b, 0x800e, 0x106b, -1 }, /* F14 */
|
||||
{ 0x6c, -1, -1, -1 },
|
||||
|
230
src/arch/win32/dirent-win32.h
Normal file
230
src/arch/win32/dirent-win32.h
Normal file
@ -0,0 +1,230 @@
|
||||
/*****************************************************************************
|
||||
* dirent.h - dirent API for Microsoft Visual Studio
|
||||
*
|
||||
* Copyright (C) 2006 Toni Ronkko
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* ``Software''), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL TONI RONKKO BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Dec 15, 2009, John Cunningham
|
||||
* Added rewinddir member function
|
||||
*
|
||||
* Jan 18, 2008, Toni Ronkko
|
||||
* Using FindFirstFileA and WIN32_FIND_DATAA to avoid converting string
|
||||
* between multi-byte and unicode representations. This makes the
|
||||
* code simpler and also allows the code to be compiled under MingW. Thanks
|
||||
* to Azriel Fasten for the suggestion.
|
||||
*
|
||||
* Mar 4, 2007, Toni Ronkko
|
||||
* Bug fix: due to the strncpy_s() function this file only compiled in
|
||||
* Visual Studio 2005. Using the new string functions only when the
|
||||
* compiler version allows.
|
||||
*
|
||||
* Nov 2, 2006, Toni Ronkko
|
||||
* Major update: removed support for Watcom C, MS-DOS and Turbo C to
|
||||
* simplify the file, updated the code to compile cleanly on Visual
|
||||
* Studio 2005 with both unicode and multi-byte character strings,
|
||||
* removed rewinddir() as it had a bug.
|
||||
*
|
||||
* Aug 20, 2006, Toni Ronkko
|
||||
* Removed all remarks about MSVC 1.0, which is antiqued now. Simplified
|
||||
* comments by removing SGML tags.
|
||||
*
|
||||
* May 14 2002, Toni Ronkko
|
||||
* Embedded the function definitions directly to the header so that no
|
||||
* source modules need to be included in the Visual Studio project. Removed
|
||||
* all the dependencies to other projects so that this very header can be
|
||||
* used independently.
|
||||
*
|
||||
* May 28 1998, Toni Ronkko
|
||||
* First version.
|
||||
*****************************************************************************/
|
||||
#ifndef DIRENT_H
|
||||
#define DIRENT_H
|
||||
|
||||
#include <windows.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
typedef struct dirent
|
||||
{
|
||||
char d_name[MAX_PATH + 1]; /* current dir entry (multi-byte char string) */
|
||||
WIN32_FIND_DATAA data; /* file attributes */
|
||||
} dirent;
|
||||
|
||||
|
||||
typedef struct DIR
|
||||
{
|
||||
dirent current; /* Current directory entry */
|
||||
int cached; /* Indicates un-processed entry in memory */
|
||||
HANDLE search_handle; /* File search handle */
|
||||
char patt[MAX_PATH + 3]; /* search pattern (3 = pattern + "\\*\0") */
|
||||
} DIR;
|
||||
|
||||
|
||||
/* Forward declarations */
|
||||
static DIR *opendir (const char *dirname);
|
||||
static struct dirent *readdir (DIR *dirp);
|
||||
static int closedir (DIR *dirp);
|
||||
static void rewinddir(DIR* dirp);
|
||||
|
||||
|
||||
/* Use the new safe string functions introduced in Visual Studio 2005 */
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1400
|
||||
# define STRNCPY(dest,src,size) strncpy_s((dest),(size),(src),_TRUNCATE)
|
||||
#else
|
||||
# define STRNCPY(dest,src,size) strncpy((dest),(src),(size))
|
||||
#endif
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Open directory stream DIRNAME for read and return a pointer to the
|
||||
* internal working area that is used to retrieve individual directory
|
||||
* entries.
|
||||
*/
|
||||
static DIR *opendir(const char *dirname)
|
||||
{
|
||||
DIR *dirp;
|
||||
assert (dirname != NULL);
|
||||
assert (strlen (dirname) < MAX_PATH);
|
||||
|
||||
/* construct new DIR structure */
|
||||
dirp = (DIR*) malloc (sizeof (struct DIR));
|
||||
if (dirp != NULL) {
|
||||
char *p;
|
||||
|
||||
/* take directory name... */
|
||||
STRNCPY (dirp->patt, dirname, sizeof(dirp->patt));
|
||||
dirp->patt[MAX_PATH] = '\0';
|
||||
|
||||
/* ... and append search pattern to it */
|
||||
p = strchr (dirp->patt, '\0');
|
||||
if (dirp->patt < p && *(p-1) != '\\' && *(p-1) != ':') {
|
||||
*p++ = '\\';
|
||||
}
|
||||
*p++ = '*';
|
||||
*p = '\0';
|
||||
|
||||
/* open stream and retrieve first file */
|
||||
dirp->search_handle = FindFirstFileA (dirp->patt, &dirp->current.data);
|
||||
if (dirp->search_handle == INVALID_HANDLE_VALUE) {
|
||||
/* invalid search pattern? */
|
||||
free (dirp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* there is an un-processed directory entry in memory now */
|
||||
dirp->cached = 1;
|
||||
}
|
||||
|
||||
return dirp;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Read a directory entry, and return a pointer to a dirent structure
|
||||
* containing the name of the entry in d_name field. Individual directory
|
||||
* entries returned by this very function include regular files,
|
||||
* sub-directories, pseudo-directories "." and "..", but also volume labels,
|
||||
* hidden files and system files may be returned.
|
||||
*/
|
||||
static struct dirent *readdir(DIR *dirp)
|
||||
{
|
||||
assert (dirp != NULL);
|
||||
|
||||
if (dirp->search_handle == INVALID_HANDLE_VALUE) {
|
||||
/* directory stream was opened/rewound incorrectly or ended normally */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* get next directory entry */
|
||||
if (dirp->cached != 0) {
|
||||
/* a valid directory entry already in memory */
|
||||
dirp->cached = 0;
|
||||
} else {
|
||||
/* read next directory entry from disk */
|
||||
if (FindNextFileA (dirp->search_handle, &dirp->current.data) == FALSE) {
|
||||
/* the very last file has been processed or an error occured */
|
||||
FindClose (dirp->search_handle);
|
||||
dirp->search_handle = INVALID_HANDLE_VALUE;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* copy as a multibyte character string */
|
||||
STRNCPY ( dirp->current.d_name,
|
||||
dirp->current.data.cFileName,
|
||||
sizeof(dirp->current.d_name) );
|
||||
dirp->current.d_name[MAX_PATH] = '\0';
|
||||
|
||||
return &dirp->current;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Close directory stream opened by opendir() function. Close of the
|
||||
* directory stream invalidates the DIR structure as well as any previously
|
||||
* read directory entry.
|
||||
*/
|
||||
static int closedir(DIR *dirp)
|
||||
{
|
||||
assert (dirp != NULL);
|
||||
|
||||
/* release search handle */
|
||||
if (dirp->search_handle != INVALID_HANDLE_VALUE) {
|
||||
FindClose (dirp->search_handle);
|
||||
dirp->search_handle = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
/* release directory handle */
|
||||
free (dirp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Resets the position of the directory stream to which dirp refers to the
|
||||
* beginning of the directory. It also causes the directory stream to refer
|
||||
* to the current state of the corresponding directory, as a call to opendir()
|
||||
* would have done. If dirp does not refer to a directory stream, the effect
|
||||
* is undefined.
|
||||
*/
|
||||
static void rewinddir(DIR* dirp)
|
||||
{
|
||||
/* release search handle */
|
||||
if (dirp->search_handle != INVALID_HANDLE_VALUE) {
|
||||
FindClose (dirp->search_handle);
|
||||
dirp->search_handle = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
/* open new search handle and retrieve first file */
|
||||
dirp->search_handle = FindFirstFileA (dirp->patt, &dirp->current.data);
|
||||
if (dirp->search_handle == INVALID_HANDLE_VALUE) {
|
||||
/* invalid search pattern? */
|
||||
free (dirp);
|
||||
return;
|
||||
}
|
||||
|
||||
/* there is an un-processed directory entry in memory now */
|
||||
dirp->cached = 1;
|
||||
}
|
||||
|
||||
|
||||
#endif /*DIRENT_H*/
|
34
src/clock.c
34
src/clock.c
@ -29,7 +29,7 @@
|
||||
#endif
|
||||
|
||||
extern int Verbose;
|
||||
extern int g_vbl_count;
|
||||
extern word32 g_vbl_count; // OG change int to word32
|
||||
extern int g_rom_version;
|
||||
extern int g_config_gsport_update_needed;
|
||||
|
||||
@ -106,7 +106,7 @@ micro_sleep(double dtime)
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
Sleep(dtime * 1000);
|
||||
Sleep((DWORD)(dtime * 1000));
|
||||
#else
|
||||
Timer.tv_sec = 0;
|
||||
Timer.tv_usec = (dtime * 1000000.0);
|
||||
@ -139,14 +139,13 @@ clk_bram_set(int bram_num, int offset, int val)
|
||||
g_bram[bram_num][offset] = val;
|
||||
}
|
||||
|
||||
|
||||
extern void x_clk_setup_bram_version();
|
||||
|
||||
void
|
||||
clk_setup_bram_version()
|
||||
{
|
||||
if(g_rom_version < 3) {
|
||||
g_bram_ptr = (&g_bram[0][0]); // ROM 01
|
||||
} else {
|
||||
g_bram_ptr = (&g_bram[1][0]); // ROM 03
|
||||
}
|
||||
x_clk_setup_bram_version();
|
||||
}
|
||||
|
||||
void
|
||||
@ -173,14 +172,29 @@ update_cur_time()
|
||||
time_t cur_time;
|
||||
unsigned int secs, secs2;
|
||||
|
||||
|
||||
#ifdef UNDER_CE // OG Not supported on WIndows CE
|
||||
/*
|
||||
SYSTEMTIME stime;
|
||||
FILETIME ftime;
|
||||
GetLocalTime(&stime);
|
||||
SystemTimeToFileTime(&stime,&ftime);
|
||||
cur_time = ftime.dwLowDateTime;
|
||||
*/
|
||||
cur_time = time(0);
|
||||
|
||||
secs=0;
|
||||
secs2=0;
|
||||
|
||||
#else
|
||||
cur_time = time(0);
|
||||
|
||||
/* Figure out the timezone (effectively) by diffing two times. */
|
||||
/* this is probably not right for a few hours around daylight savings*/
|
||||
/* time transition */
|
||||
secs2 = mktime(gmtime(&cur_time));
|
||||
secs2 = (unsigned int)mktime(gmtime(&cur_time));
|
||||
tm_ptr = localtime(&cur_time);
|
||||
secs = mktime(tm_ptr);
|
||||
secs = (unsigned int)mktime(tm_ptr);
|
||||
|
||||
#ifdef MAC
|
||||
/* Mac OS X's mktime function modifies the tm_ptr passed in for */
|
||||
@ -195,7 +209,7 @@ update_cur_time()
|
||||
secs += 3600;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* add in secs to make date based on Apple Jan 1, 1904 instead of */
|
||||
/* Unix's Jan 1, 1970 */
|
||||
/* So add in 66 years and 17 leap year days (1904 is a leap year) */
|
||||
|
@ -19,4 +19,4 @@
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
char g_compile_time[] = "Compiled: " __DATE__ " " __TIME__ ;
|
||||
char g_compile_time[] = "Compiled: " __DATE__ " " __TIME__ ;
|
||||
|
38
src/config.c
38
src/config.c
@ -168,11 +168,14 @@ Cfg_menu g_cfg_disk_menu[] = {
|
||||
{ 0, 0, 0, 0, 0 },
|
||||
};
|
||||
|
||||
// OG Use define instead of const for joystick_types
|
||||
#define STRINGIFY(x) #x
|
||||
#define TOSTRING(x) STRINGIFY(x)
|
||||
|
||||
Cfg_menu g_cfg_joystick_menu[] = {
|
||||
{ "Joystick Configuration", g_cfg_joystick_menu, 0, 0, CFGTYPE_MENU },
|
||||
{ "Joystick Emulation,0,Keypad Joystick,1,Mouse Joystick,2,Native Joystick 1,"
|
||||
"3,Native Joystick 2,4,Disable Joystick",
|
||||
KNMP(g_joystick_type), CFGTYPE_INT },
|
||||
{ "Joystick Emulation,"TOSTRING(JOYSTICK_TYPE_KEYPAD)",Keypad Joystick,"TOSTRING(JOYSTICK_TYPE_MOUSE)",Mouse Joystick,"TOSTRING(JOYSTICK_TYPE_NATIVE_1)",Native Joystick 1,"
|
||||
TOSTRING(JOYSTICK_TYPE_NATIVE_2)",Native Joystick 2,"TOSTRING(JOYSTICK_TYPE_NONE)",No Joystick", KNMP(g_joystick_type), CFGTYPE_INT },
|
||||
{ "Joystick Scale X,0x100,Standard,0x119,+10%,0x133,+20%,"
|
||||
"0x150,+30%,0xb0,-30%,0xcd,-20%,0xe7,-10%",
|
||||
KNMP(g_joystick_scale_factor_x), CFGTYPE_INT },
|
||||
@ -2140,9 +2143,9 @@ cfg_parse_menu(Cfg_menu *menuptr, int menu_pos, int highlight_pos, int change)
|
||||
defval = -1;
|
||||
curstr = 0;
|
||||
if(type == CFGTYPE_INT) {
|
||||
iptr = menuptr->ptr;
|
||||
iptr = (int*)menuptr->ptr; // OG Added cast
|
||||
curval = *iptr;
|
||||
iptr = menuptr->defptr;
|
||||
iptr = (int*)menuptr->defptr; // OG Added cast
|
||||
defval = *iptr;
|
||||
if(curval == defval) {
|
||||
g_cfg_opt_buf[3] = 'D'; /* checkmark */
|
||||
@ -2454,10 +2457,10 @@ cfg_file_add_dirent(Cfg_listhdr *listhdrptr, const char *nameptr, int is_dir,
|
||||
inc_amt = MAX(64, listhdrptr->max);
|
||||
inc_amt = MIN(inc_amt, 1024);
|
||||
listhdrptr->max += inc_amt;
|
||||
listhdrptr->direntptr = realloc(listhdrptr->direntptr,
|
||||
listhdrptr->direntptr = (Cfg_dirent*)realloc(listhdrptr->direntptr,
|
||||
listhdrptr->max * sizeof(Cfg_dirent));
|
||||
}
|
||||
ptr = malloc(namelen+1+is_dir);
|
||||
ptr = (char*)malloc(namelen+1+is_dir); // OG Added cast
|
||||
strncpy(ptr, nameptr, namelen+1);
|
||||
if(is_dir) {
|
||||
strcat(ptr, "/");
|
||||
@ -2483,10 +2486,10 @@ cfg_dirent_sortfn(const void *obj1, const void *obj2)
|
||||
/* Called by qsort to sort directory listings */
|
||||
direntptr1 = (const Cfg_dirent *)obj1;
|
||||
direntptr2 = (const Cfg_dirent *)obj2;
|
||||
#if defined(_WIN32)
|
||||
ret = _stricmp(direntptr1->name, direntptr2->name);
|
||||
#elif defined(MAC)
|
||||
ret = strcasecmp(direntptr1->name, direntptr2->name);
|
||||
#if defined(MAC) || defined(_WIN32)
|
||||
// OG
|
||||
ret = 0;
|
||||
// ret = strcasecmp(direntptr1->name, direntptr2->name);
|
||||
#else
|
||||
ret = strcmp(direntptr1->name, direntptr2->name);
|
||||
#endif
|
||||
@ -2921,7 +2924,7 @@ cfg_file_update_ptr(char *str)
|
||||
char *newstr;
|
||||
int len;
|
||||
len = strlen(str) + 1;
|
||||
newstr = malloc(len);
|
||||
newstr = (char*)malloc(len);
|
||||
memcpy(newstr, str, len);
|
||||
if(g_cfg_file_strptr) {
|
||||
if(*g_cfg_file_strptr) {
|
||||
@ -3280,3 +3283,14 @@ config_control_panel()
|
||||
g_full_refresh_needed = -1;
|
||||
g_a2_screen_buffer_changed = -1;
|
||||
}
|
||||
|
||||
extern byte g_bram[2][256];
|
||||
extern byte* g_bram_ptr;
|
||||
void x_clk_setup_bram_version()
|
||||
{
|
||||
if(g_rom_version < 3) {
|
||||
g_bram_ptr = (&g_bram[0][0]); // ROM 01
|
||||
} else {
|
||||
g_bram_ptr = (&g_bram[1][0]); // ROM 03
|
||||
}
|
||||
}
|
||||
|
56
src/defc.h
56
src/defc.h
@ -21,6 +21,15 @@
|
||||
|
||||
#include "defcomm.h"
|
||||
|
||||
// OG redirect printf to console
|
||||
#ifdef ACTIVEGS
|
||||
#include <stdio.h>
|
||||
extern "C" int outputInfo(const char* format,...);
|
||||
extern "C" int fOutputInfo(FILE*,const char* format,...);
|
||||
#define printf outputInfo
|
||||
#define fprintf fOutputInfo
|
||||
#endif
|
||||
|
||||
#define STRUCT(a) typedef struct _ ## a a; struct _ ## a
|
||||
|
||||
typedef unsigned char byte;
|
||||
@ -67,20 +76,52 @@ void U_STACK_TRACE();
|
||||
# include <libc.h>
|
||||
#endif
|
||||
|
||||
#if !defined(_WIN32) && !defined (__OS2__)
|
||||
#if !defined(_WIN32) && !defined (__OS2__) && !defined(UNDER_CE) // OG
|
||||
# include <unistd.h>
|
||||
# include <sys/ioctl.h>
|
||||
# include <sys/wait.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifndef UNDER_CE // OG CE SPecific
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
// OG Adding support for open
|
||||
#ifdef WIN32
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
#else
|
||||
extern int errno;
|
||||
extern int open(const char* name,int,...);
|
||||
extern int read(int,char*,int);
|
||||
extern int close(int);
|
||||
extern int write( int fd, const void *buffer, unsigned int count );
|
||||
extern int lseek(int,int,int);
|
||||
struct stat { int st_size; };
|
||||
extern int stat(const char* name, struct stat*);
|
||||
extern int fstat(int, struct stat*);
|
||||
#define O_RDWR 1
|
||||
#define O_BINARY 2
|
||||
#define O_RDONLY 4
|
||||
#define O_WRONLY 8
|
||||
#define O_CREAT 16
|
||||
#define O_TRUNC 32
|
||||
#define EAGAIN 11
|
||||
#define EINTR 4
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HPUX
|
||||
# include <machine/inline.h> /* for GET_ITIMER */
|
||||
#endif
|
||||
@ -320,3 +361,10 @@ STRUCT(Emustate_word32list) {
|
||||
|
||||
#include "iwm.h"
|
||||
#include "protos.h"
|
||||
// OG Added define for joystick
|
||||
#define JOYSTICK_TYPE_KEYPAD 0
|
||||
#define JOYSTICK_TYPE_MOUSE 1
|
||||
#define JOYSTICK_TYPE_NATIVE_1 2
|
||||
#define JOYSTICK_TYPE_NATIVE_2 3
|
||||
#define JOYSTICK_TYPE_NONE 4 // OG Added Joystick None
|
||||
#define NB_JOYSTICK_TYPE 5
|
||||
|
@ -35,6 +35,8 @@
|
||||
|
||||
|
||||
#define HALT_EVENT 0x10
|
||||
#define HALT_WANTTOQUIT 0x20 // OG : added WANTTOQUIT event
|
||||
#define HALT_WANTTOBRK 0x40 // OG : added WANTTOBRK event
|
||||
|
||||
#define MAX_BREAK_POINTS 0x20
|
||||
|
||||
@ -146,8 +148,11 @@
|
||||
|
||||
#define BORDER_WIDTH 32
|
||||
|
||||
#define EFF_BORDER_WIDTH (BORDER_WIDTH + (640-560))
|
||||
//#define EFF_BORDER_WIDTH (BORDER_WIDTH + (640-560))
|
||||
|
||||
// OG Eff_border_widht == border side in A2 mode
|
||||
#define EFF_BORDER_WIDTH (BORDER_WIDTH + (640-560)/2)
|
||||
|
||||
/* BASE_MARGIN_BOTTOM+MARGIN_TOP must equal 62. There are 262 scan lines */
|
||||
/* at 60Hz (15.7KHz line rate) and so we just make 62 border lines */
|
||||
#define BASE_MARGIN_TOP 32
|
||||
|
15
src/dis.c
15
src/dis.c
@ -61,7 +61,8 @@ char *line_ptr;
|
||||
int mode,old_mode;
|
||||
int got_num;
|
||||
|
||||
int g_quit_sim_now = 0;
|
||||
// OG replaced by HALT_WANTTOQUIT
|
||||
//int g_quit_sim_now = 0;
|
||||
|
||||
int
|
||||
get_num()
|
||||
@ -176,7 +177,9 @@ do_debug_intfc()
|
||||
g_fullscreen = 0;
|
||||
x_full_screen(0);
|
||||
|
||||
if(g_quit_sim_now) {
|
||||
// OG use HALT_WANTTOQUIT instead of g_quit_sim_now
|
||||
if (halt_sim&HALT_WANTTOQUIT)
|
||||
{
|
||||
printf("Exiting immediately\n");
|
||||
return;
|
||||
}
|
||||
@ -859,15 +862,15 @@ do_debug_unix()
|
||||
}
|
||||
if(load) {
|
||||
if(a1bank >= 0xe0 && a1bank < 0xe2) {
|
||||
ret = read(fd,&g_slow_memory_ptr[((a1bank & 1)<<16)+a1],len);
|
||||
ret = read(fd,(char*)&g_slow_memory_ptr[((a1bank & 1)<<16)+a1],len);
|
||||
} else {
|
||||
ret = read(fd,&g_memory_ptr[(a1bank << 16) + a1],len);
|
||||
ret = read(fd,(char*)&g_memory_ptr[(a1bank << 16) + a1],len);
|
||||
}
|
||||
} else {
|
||||
if(a1bank >= 0xe0 && a1bank < 0xe2) {
|
||||
ret = write(fd,&g_slow_memory_ptr[((a1bank & 1)<<16)+a1],len);
|
||||
ret = write(fd,(char*)&g_slow_memory_ptr[((a1bank & 1)<<16)+a1],len);
|
||||
} else {
|
||||
ret = write(fd,&g_memory_ptr[(a1bank << 16) + a1],len);
|
||||
ret = write(fd,(char*)&g_memory_ptr[(a1bank << 16) + a1],len);
|
||||
}
|
||||
}
|
||||
printf("Read/write: addr %06x for %04x bytes, ret: %x bytes\n",
|
||||
|
@ -55,6 +55,13 @@ extern int g_c068_statereg;
|
||||
unsigned char ioslotsel = 0;
|
||||
unsigned char iostrobe = 0;
|
||||
|
||||
// OG Need allocated memory
|
||||
extern byte *g_slow_memory_ptr_allocated;
|
||||
extern byte *g_memory_ptr_allocated;
|
||||
extern byte *g_rom_fc_ff_ptr_allocated;
|
||||
extern byte *g_rom_cards_ptr_allocated;
|
||||
extern byte *g_dummy_memory1_ptr_allocated;
|
||||
|
||||
extern int g_num_breakpoints;
|
||||
extern word32 g_breakpts[];
|
||||
|
||||
@ -572,8 +579,8 @@ get_memory16_c(word32 addr, int cycs)
|
||||
double fcycs;
|
||||
|
||||
fcycs = 0;
|
||||
return get_memory_c(addr, fcycs) +
|
||||
(get_memory_c(addr+1, fcycs) << 8);
|
||||
return get_memory_c(addr, (int)fcycs) +
|
||||
(get_memory_c(addr+1, (int)fcycs) << 8);
|
||||
}
|
||||
|
||||
word32
|
||||
@ -582,9 +589,9 @@ get_memory24_c(word32 addr, int cycs)
|
||||
double fcycs;
|
||||
|
||||
fcycs = 0;
|
||||
return get_memory_c(addr, fcycs) +
|
||||
(get_memory_c(addr+1, fcycs) << 8) +
|
||||
(get_memory_c(addr+2, fcycs) << 16);
|
||||
return get_memory_c(addr, (int)fcycs) +
|
||||
(get_memory_c(addr+1, (int)fcycs) << 8) +
|
||||
(get_memory_c(addr+2, (int)fcycs) << 16);
|
||||
}
|
||||
|
||||
void
|
||||
@ -737,10 +744,11 @@ fixed_memory_ptrs_init()
|
||||
/* set g_slow_memory_ptr, g_rom_fc_ff_ptr, g_dummy_memory1_ptr, */
|
||||
/* and rom_cards_ptr */
|
||||
|
||||
g_slow_memory_ptr = memalloc_align(128*1024, 0, 0);
|
||||
g_dummy_memory1_ptr = memalloc_align(256, 1024, 0);
|
||||
g_rom_fc_ff_ptr = memalloc_align(256*1024, 512, 0);
|
||||
g_rom_cards_ptr = memalloc_align(16*256, 256, 0);
|
||||
// OG Filled allocated ptr parameter to free the memory
|
||||
g_slow_memory_ptr = memalloc_align(128*1024, 0, (void**)&g_slow_memory_ptr_allocated);
|
||||
g_dummy_memory1_ptr = memalloc_align(256, 1024, (void**)&g_dummy_memory1_ptr_allocated);
|
||||
g_rom_fc_ff_ptr = memalloc_align(256*1024, 512, (void**)&g_rom_fc_ff_ptr_allocated);
|
||||
g_rom_cards_ptr = memalloc_align(16*256, 256, (void**)&g_rom_cards_ptr_allocated);
|
||||
|
||||
#if 0
|
||||
printf("g_memory_ptr: %08x, dummy_mem: %08x, slow_mem_ptr: %08x\n",
|
||||
@ -754,6 +762,21 @@ fixed_memory_ptrs_init()
|
||||
#endif
|
||||
}
|
||||
|
||||
// OG added fixed_memory_ptrs_shut
|
||||
void fixed_memory_ptrs_shut()
|
||||
{
|
||||
|
||||
free(g_slow_memory_ptr_allocated);
|
||||
free(g_dummy_memory1_ptr_allocated);
|
||||
free(g_rom_fc_ff_ptr_allocated);
|
||||
free(g_rom_cards_ptr_allocated);
|
||||
g_slow_memory_ptr=g_slow_memory_ptr_allocated= NULL;
|
||||
g_dummy_memory1_ptr = g_dummy_memory1_ptr_allocated = NULL;
|
||||
g_rom_fc_ff_ptr = g_rom_fc_ff_ptr_allocated = NULL;
|
||||
g_rom_cards_ptr = g_rom_cards_ptr = NULL;
|
||||
}
|
||||
|
||||
|
||||
word32
|
||||
get_itimer()
|
||||
{
|
||||
@ -877,8 +900,7 @@ get_remaining_operands(word32 addr, word32 opcode, word32 psr, Fplus *fplus_ptr)
|
||||
if((addr & 0xfffff0) == 0x00c700) { \
|
||||
if(addr == 0xc700) { \
|
||||
FINISH(RET_C700, 0); \
|
||||
} else \
|
||||
if(addr == 0xc70a) { \
|
||||
} else if(addr == 0xc70a) { \
|
||||
FINISH(RET_C70A, 0); \
|
||||
} else if(addr == 0xc70d) { \
|
||||
FINISH(RET_C70D, 0); \
|
||||
|
60
src/iwm.c
60
src/iwm.c
@ -22,7 +22,7 @@
|
||||
#include "defc.h"
|
||||
|
||||
extern int Verbose;
|
||||
extern int g_vbl_count;
|
||||
extern word32 g_vbl_count; // OG change int to word32
|
||||
extern int g_c036_val_speed;
|
||||
|
||||
const byte phys_to_dos_sec[] = {
|
||||
@ -175,6 +175,24 @@ iwm_init()
|
||||
iwm_reset();
|
||||
}
|
||||
|
||||
// OG Added shut function to IWM
|
||||
// Free the memory, and more important free the open handle onto the disk
|
||||
void
|
||||
iwm_shut()
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < 2; i++) {
|
||||
eject_disk(&iwm.drive525[i]);
|
||||
eject_disk(&iwm.drive35[i]);
|
||||
}
|
||||
|
||||
for(i = 0; i < MAX_C7_DISKS; i++) {
|
||||
eject_disk(&iwm.smartport[i]);
|
||||
}
|
||||
|
||||
from_disk_byte_valid = 0;
|
||||
}
|
||||
|
||||
void
|
||||
iwm_reset()
|
||||
{
|
||||
@ -217,6 +235,19 @@ draw_iwm_status(int line, char *buf)
|
||||
flag[apple35_sel][iwm.drive_select] = "*";
|
||||
}
|
||||
|
||||
#ifdef ACTIVEGS // OG Pass monitoring info
|
||||
{
|
||||
extern void ki_loading(int _motorOn,int _slot,int _drive, int _curtrack);
|
||||
int curtrack=0;
|
||||
if (apple35_sel)
|
||||
curtrack = iwm.drive35[iwm.drive_select].cur_qtr_track ;
|
||||
else
|
||||
curtrack = iwm.drive525[iwm.drive_select].cur_qtr_track >> 2 ;
|
||||
|
||||
ki_loading(g_iwm_motor_on,apple35_sel?5:6,iwm.drive_select+1,curtrack);
|
||||
}
|
||||
#endif
|
||||
|
||||
sprintf(buf, "s6d1:%2d%s s6d2:%2d%s s5d1:%2d/%d%s "
|
||||
"s5d2:%2d/%d%s fast_disk_emul:%d,%d c036:%02x",
|
||||
iwm.drive525[0].cur_qtr_track >> 2, flag[0][0],
|
||||
@ -311,7 +342,7 @@ iwm_vbl_update(int doit_3_persec)
|
||||
int i;
|
||||
|
||||
if(iwm.motor_on && iwm.motor_off) {
|
||||
if(iwm.motor_off_vbl_count <= g_vbl_count) {
|
||||
if((word32)iwm.motor_off_vbl_count <= g_vbl_count) {
|
||||
printf("Disk timer expired, drive off: %08x\n",
|
||||
g_vbl_count);
|
||||
iwm.motor_on = 0;
|
||||
@ -724,6 +755,12 @@ iwm_do_action35(double dcycs)
|
||||
break;
|
||||
case 0x0d: /* eject disk */
|
||||
eject_disk(dsk);
|
||||
#ifdef ACTIVEGS // OG : pass eject info to the Control (ActiveX specific)
|
||||
{
|
||||
extern void ejectDisk(int slot,int disk);
|
||||
ejectDisk(dsk->disk_525?6:5,dsk->drive+1);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case 0x02:
|
||||
case 0x07:
|
||||
@ -1612,6 +1649,7 @@ iwm_denib_track35(Disk *dsk, Trk *trk, int qtr_track, byte *outbuf)
|
||||
int
|
||||
disk_track_to_unix(Disk *dsk, int qtr_track, byte *outbuf)
|
||||
{
|
||||
int i;
|
||||
Trk *trk;
|
||||
int disk_525;
|
||||
|
||||
@ -1632,8 +1670,24 @@ disk_track_to_unix(Disk *dsk, int qtr_track, byte *outbuf)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(disk_525) {
|
||||
if(disk_525)
|
||||
{
|
||||
// OG
|
||||
// Add support for .nib file
|
||||
if (dsk->image_type!=DSK_TYPE_NIB)
|
||||
return iwm_denib_track525(dsk, trk, qtr_track, outbuf);
|
||||
else
|
||||
{
|
||||
int len = trk->track_len;
|
||||
byte* trk_ptr = trk->nib_area+1;
|
||||
byte* nib_ptr = outbuf;
|
||||
for(i = 0; i < len; i += 2)
|
||||
{
|
||||
*nib_ptr++ = *trk_ptr;
|
||||
trk_ptr+=2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
return iwm_denib_track35(dsk, trk, qtr_track, outbuf);
|
||||
}
|
||||
|
@ -271,4 +271,9 @@ void
|
||||
joystick_update_buttons()
|
||||
{
|
||||
}
|
||||
|
||||
// OG
|
||||
void joystick_shut()
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
@ -20,9 +20,17 @@
|
||||
*/
|
||||
|
||||
#include "defc.h"
|
||||
#include "sound.h"
|
||||
|
||||
#ifdef ACTIVEIPHONE
|
||||
void child_sound_init_mac() {}
|
||||
void macsnd_init(word32 *shmaddr) {}
|
||||
int mac_send_audio(byte *ptr, int in_size) {}
|
||||
#else
|
||||
|
||||
#include <Carbon/Carbon.h>
|
||||
|
||||
|
||||
#include "sound.h"
|
||||
#include <unistd.h>
|
||||
|
||||
#define MACSND_REBUF_SIZE (64*1024)
|
||||
@ -67,7 +75,7 @@ mac_snd_callback(SndChannelPtr snd_chan_ptr, SndCommand *in_sndcmd)
|
||||
g_macsnd_playing = 1;
|
||||
g_snd_hdr.numFrames = samps;
|
||||
g_snd_hdr.loopEnd = samps;
|
||||
g_snd_hdr.samplePtr = (byte *)g_macsnd_rebuf_cur;
|
||||
g_snd_hdr.samplePtr = (char *)g_macsnd_rebuf_cur; // OG Cast from byte* to ,char*
|
||||
|
||||
g_snd_cmd.cmd = bufferCmd;
|
||||
g_snd_cmd.param1 = 0;
|
||||
@ -161,3 +169,4 @@ macsnd_init(word32 *shmaddr)
|
||||
mac_printf("macsnd_init called\n");
|
||||
child_sound_loop(-1, -1, shmaddr);
|
||||
}
|
||||
#endif
|
||||
|
230
src/moremem.c
230
src/moremem.c
@ -146,6 +146,109 @@ Emustate_word32list g_emustate_word32list[] = {
|
||||
halt_printf("UNIMP WRITE to addr %08x, val: %04x\n", loc, val); \
|
||||
return;
|
||||
|
||||
|
||||
//#ifdef _WINDOWS
|
||||
// OG Added Transwarp ROM
|
||||
#define TRANSWARP
|
||||
int transwarp_low_val = 0;
|
||||
#ifdef _WIN32
|
||||
__declspec(align(256))
|
||||
#endif
|
||||
unsigned char transwarpcode[][32]
|
||||
#ifndef _WIN32
|
||||
__attribute__ ((aligned(256)))
|
||||
#endif
|
||||
={
|
||||
{
|
||||
/*0xBCFF00*/ 'T','W','G','S',0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
/*0xBCFF10*/ 0x5C,0x40,0xFF,0xBC, // JMP GetMaxSpeed
|
||||
/*0xBCFF14*/ 0x5C,0x60,0xFF,0xBC, // JMP GetNumISpeed
|
||||
/*0xBCFF18*/ 0x6B,0x00,0x00,0x00, // ???
|
||||
/*0xBCFF1C*/ 0x6B,0x00,0x00,0x00 // ???
|
||||
},
|
||||
{
|
||||
/*0xBCFF20*/ 0x5C,0x80,0xFF,0xBC, // JMP GetCurSpeed
|
||||
/*0xBCFF24*/ 0x5C,0xA0,0xFF,0xBC, // JMP SetCurSpeed
|
||||
/*0xBCFF28*/ 0x5C,0xC0,0xFF,0xBC, // JMP GetCurISpeed
|
||||
/*0xBCFF2C*/ 0x5C,0xE0,0xFF,0xBC, // JMP SetCurISpeed
|
||||
/*0xBCFF30*/ 0x6B,0x00,0x00,0x00, // ???
|
||||
/*0xBCFF34*/ 0x6B,0x00,0x00,0x00, // ???
|
||||
/*0xBCFF38*/ 0x6B,0x00,0x00,0x00, // ???
|
||||
/*0xBCFF3C*/ 0x6B,0x00,0x00,0x00 // GetTWConfig
|
||||
},
|
||||
{
|
||||
/* 0xBCFF40*/ // GetMaxSpeed
|
||||
#define ZIP_SPEED 8000
|
||||
|
||||
0xA9, ZIP_SPEED & 0xFF, (ZIP_SPEED >> 8) &0xFF, // LDA 0x1F40 // Max Speed = 8.0Mhz
|
||||
0x6B, // RTL
|
||||
0x00,0x00,0x00,0x00, //4
|
||||
0x00,0x00,0x00,0x00, //8
|
||||
0x6B,0x00,0x00,0x00, //C Space Shark calls this address ???
|
||||
},
|
||||
{
|
||||
/* 0xBCFF60*/ //GetNumISpeed
|
||||
0xA9,0x02,0x00, // LDA 0x0002 // 0=slow, 1=normal, 2=warp
|
||||
0x6B, // RTL
|
||||
},
|
||||
{
|
||||
/* 0xBCFF80*/ //GetCurSpeed
|
||||
0xAF, 0x6A, 0xC0, 0x00, // LDA 0xC06A (/6B)
|
||||
0x6B, // RTL
|
||||
},
|
||||
{
|
||||
/* 0xBCFFA0*/ //SetCurSpeed
|
||||
0x8F, 0x6A, 0xC0, 0x00, // STA 0xC06A (/6B)
|
||||
0x6B, // RTL
|
||||
},
|
||||
{
|
||||
/* 0xBCFFC0*/ //GetCurISpeed
|
||||
0x48, // PHA
|
||||
0xAF, 0x6C, 0xC0, 0x00, // LDA 0xC06C (/6D)
|
||||
0xAA, // TAX
|
||||
0x68, // PLA
|
||||
0x6B, // RTL
|
||||
},
|
||||
{
|
||||
/* 0xBCFFE0*/ //SetCurISpeed
|
||||
0x48, // PHA
|
||||
0x8A, // TXA
|
||||
0x8F, 0x6C, 0xC0, 0x00, // STA 0xC06C (/6D)
|
||||
0x68, // PLA
|
||||
0x6B, // RTL
|
||||
}
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
// OG Added moremem_init()
|
||||
void moremem_init()
|
||||
{
|
||||
g_em_emubyte_cnt = 0;
|
||||
g_paddle_buttons = 0;
|
||||
g_irq_pending = 0;
|
||||
|
||||
g_c023_val = 0;
|
||||
g_c029_val_some = 0x41;
|
||||
g_c02b_val = 0x08;
|
||||
g_c02d_int_crom = 0;
|
||||
g_c031_disk35 = 0;
|
||||
g_c034_val = 0;
|
||||
g_c035_shadow_reg = 0x08;
|
||||
g_c036_val_speed = 0x80;
|
||||
g_c03ef_doc_ptr = 0;
|
||||
g_c041_val = 0; /* C041_EN_25SEC_INTS, C041_EN_MOVE_INTS */
|
||||
g_c046_val = 0;
|
||||
g_c05x_annuncs = 0;
|
||||
g_c068_statereg = 0;
|
||||
g_c08x_wrdefram = 0;
|
||||
g_zipgs_unlock = 0;
|
||||
g_zipgs_reg_c059 = 0x5f;
|
||||
g_zipgs_reg_c05a = 0x0f;
|
||||
g_zipgs_reg_c05b = 0x40;
|
||||
g_zipgs_reg_c05c = 0x00;
|
||||
}
|
||||
|
||||
void
|
||||
fixup_brks()
|
||||
{
|
||||
@ -689,55 +792,55 @@ fixup_rdrom()
|
||||
void
|
||||
set_statereg(double dcycs, int val)
|
||||
{
|
||||
int xor;
|
||||
int _xor; // OG renamed xor to _xor
|
||||
|
||||
xor = val ^ g_c068_statereg;
|
||||
_xor = val ^ g_c068_statereg;
|
||||
g_c068_statereg = val;
|
||||
if(xor == 0) {
|
||||
if(_xor == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(xor & 0x80) {
|
||||
if(_xor & 0x80) {
|
||||
/* altzp */
|
||||
fixup_altzp();
|
||||
}
|
||||
if(xor & 0x40) {
|
||||
if(_xor & 0x40) {
|
||||
/* page2 */
|
||||
g_cur_a2_stat = (g_cur_a2_stat & ~ALL_STAT_PAGE2) |
|
||||
(val & ALL_STAT_PAGE2);
|
||||
fixup_page2(dcycs);
|
||||
}
|
||||
|
||||
if(xor & 0x20) {
|
||||
if(_xor & 0x20) {
|
||||
/* RAMRD */
|
||||
fixup_ramrd();
|
||||
}
|
||||
|
||||
if(xor & 0x10) {
|
||||
if(_xor & 0x10) {
|
||||
/* RAMWRT */
|
||||
fixup_ramwrt();
|
||||
}
|
||||
|
||||
if(xor & 0x08) {
|
||||
if(_xor & 0x08) {
|
||||
/* RDROM */
|
||||
fixup_rdrom();
|
||||
}
|
||||
|
||||
if(xor & 0x04) {
|
||||
if(_xor & 0x04) {
|
||||
/* LCBANK2 */
|
||||
fixup_lcbank2();
|
||||
}
|
||||
|
||||
if(xor & 0x02) {
|
||||
if(_xor & 0x02) {
|
||||
/* ROMBANK */
|
||||
halt_printf("Just set rombank = %d\n", ROMB);
|
||||
}
|
||||
|
||||
if(xor & 0x01) {
|
||||
if(_xor & 0x01) {
|
||||
fixup_intcx();
|
||||
}
|
||||
|
||||
if(xor) {
|
||||
if(_xor) {
|
||||
fixup_brks();
|
||||
}
|
||||
}
|
||||
@ -907,42 +1010,42 @@ fixup_shadow_iolc()
|
||||
void
|
||||
update_shadow_reg(int val)
|
||||
{
|
||||
int xor;
|
||||
int _xor;
|
||||
|
||||
if(g_c035_shadow_reg == val) {
|
||||
return;
|
||||
}
|
||||
|
||||
xor = g_c035_shadow_reg ^ val;
|
||||
_xor = g_c035_shadow_reg ^ val;
|
||||
g_c035_shadow_reg = val;
|
||||
|
||||
if(xor & 8) {
|
||||
if(_xor & 8) {
|
||||
fixup_shadow_hires1();
|
||||
fixup_shadow_hires2();
|
||||
fixup_shadow_shr();
|
||||
xor = xor & (~0x16);
|
||||
_xor = _xor & (~0x16);
|
||||
}
|
||||
if(xor & 0x10) {
|
||||
if(_xor & 0x10) {
|
||||
fixup_shadow_hires1();
|
||||
fixup_shadow_hires2();
|
||||
xor = xor & (~0x6);
|
||||
_xor = _xor & (~0x6);
|
||||
}
|
||||
if(xor & 2) {
|
||||
if(_xor & 2) {
|
||||
fixup_shadow_hires1();
|
||||
}
|
||||
if(xor & 4) {
|
||||
if(_xor & 4) {
|
||||
fixup_shadow_hires2();
|
||||
}
|
||||
if(xor & 1) {
|
||||
if(_xor & 1) {
|
||||
fixup_shadow_txt1();
|
||||
}
|
||||
if((xor & 0x20) && ((g_rom_version >= 3) || g_user_page2_shadow)) {
|
||||
if((_xor & 0x20) && ((g_rom_version >= 3) || g_user_page2_shadow)) {
|
||||
fixup_shadow_txt2();
|
||||
}
|
||||
if(xor & 0x40) {
|
||||
if(_xor & 0x40) {
|
||||
fixup_shadow_iolc();
|
||||
}
|
||||
if(xor) {
|
||||
if(_xor) {
|
||||
fixup_brks();
|
||||
}
|
||||
}
|
||||
@ -1033,6 +1136,10 @@ setup_pageinfo()
|
||||
fixup_shadow_shr();
|
||||
fixup_shadow_iolc();
|
||||
fixup_brks();
|
||||
|
||||
#ifdef TRANSWARP // OG adding Transwarp code
|
||||
SET_PAGE_INFO_RD(0xBCFF,transwarpcode);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
@ -1417,9 +1524,30 @@ io_read(word32 loc, double *cyc_ptr)
|
||||
case 0x69: /* 0xc069 */
|
||||
/* Reserved reg, return 0 */
|
||||
return 0;
|
||||
// OG Transwarp Read Interface
|
||||
#ifdef TRANSWARP
|
||||
case 0x6a: /* 0xc06a */
|
||||
{
|
||||
extern double g_zip_pmhz;
|
||||
return (int)(g_zip_pmhz*1000)&0xFF;
|
||||
}
|
||||
case 0x6b: /* 0xc06b */
|
||||
{
|
||||
extern double g_zip_pmhz;
|
||||
return (((int)(g_zip_pmhz*1000))>>8)&0xFF;
|
||||
}
|
||||
case 0x6c: /* 0xc06c */
|
||||
{
|
||||
extern double g_zip_pmhz;
|
||||
if (g_zip_pmhz==1.0) return 0; // slow
|
||||
else if (g_zip_pmhz>=2.6) return 2; // warp
|
||||
else return 1; // zip
|
||||
}
|
||||
#else
|
||||
case 0x6a: /* 0xc06a */
|
||||
case 0x6b: /* 0xc06b */
|
||||
case 0x6c: /* 0xc06c */
|
||||
#endif
|
||||
case 0x6d: /* 0xc06d */
|
||||
case 0x6e: /* 0xc06e */
|
||||
case 0x6f: /* 0xc06f */
|
||||
@ -1580,13 +1708,12 @@ io_read(word32 loc, double *cyc_ptr)
|
||||
}
|
||||
UNIMPL_READ;
|
||||
case 0xf:
|
||||
if((loc & 0xfff) == 0xfff) {
|
||||
return g_rom_fc_ff_ptr[0x3cfff];
|
||||
}
|
||||
|
||||
if(INTCX || ((g_c02d_int_crom & (1 << 3)) == 0)) {
|
||||
return(g_rom_fc_ff_ptr[0x3c000 + (loc & 0xfff)]);
|
||||
}
|
||||
if((loc & 0xfff) == 0xfff) {
|
||||
return g_rom_fc_ff_ptr[0x3cfff];
|
||||
}
|
||||
UNIMPL_READ;
|
||||
}
|
||||
|
||||
@ -2088,9 +2215,53 @@ io_write(word32 loc, int val, double *cyc_ptr)
|
||||
case 0x69: /* 0xc069 */
|
||||
/* just ignore, someone writing c068 with m=0 */
|
||||
return;
|
||||
|
||||
|
||||
#ifdef TRANSWARP
|
||||
// OG writeTranswarp pseudo-register
|
||||
case 0x6a: /* 0xc06a */
|
||||
transwarp_low_val = val;
|
||||
return ;
|
||||
case 0x6b: /* 0xc06b */
|
||||
val = (val<<8) + transwarp_low_val;
|
||||
if ((val==2600) || (val==0x0028)) // Bug for demo ...
|
||||
{
|
||||
printf("Disabling Transwarp!\n");
|
||||
g_zipgs_reg_c05b |= 0x10; // disable
|
||||
set_halt(HALT_EVENT);
|
||||
}
|
||||
else if (val==8000)
|
||||
{
|
||||
printf("Enabling Transwarp!\n");
|
||||
g_zipgs_reg_c05b &= ~0x10; // enable
|
||||
set_halt(HALT_EVENT);
|
||||
}
|
||||
else
|
||||
printf("unknown twgs speed:%d\n",val);
|
||||
return;
|
||||
case 0x6c: /* 0xc06c */
|
||||
if (val==0)
|
||||
; // set slow ?
|
||||
else if (val==1)
|
||||
{
|
||||
// disable zip
|
||||
g_zipgs_reg_c05b |= 0x10; // disable
|
||||
set_halt(HALT_EVENT);
|
||||
}
|
||||
else if (val==2)
|
||||
{
|
||||
// enable zip
|
||||
g_zipgs_reg_c05b &= ~0x10; // enable
|
||||
set_halt(HALT_EVENT);
|
||||
}
|
||||
else
|
||||
printf("unknown twgs index:%d\n",val);
|
||||
return ;
|
||||
#else
|
||||
case 0x6a: /* 0xc06a */
|
||||
case 0x6b: /* 0xc06b */
|
||||
case 0x6c: /* 0xc06c */
|
||||
#endif
|
||||
case 0x6d: /* 0xc06d */
|
||||
case 0x6e: /* 0xc06e */
|
||||
case 0x6f: /* 0xc06f */
|
||||
@ -2158,8 +2329,7 @@ io_write(word32 loc, int val, double *cyc_ptr)
|
||||
return;
|
||||
|
||||
/* 0xc090 - 0xc09f */
|
||||
case 0x90:
|
||||
case 0x91: case 0x92: case 0x93:
|
||||
case 0x90: case 0x91: case 0x92: case 0x93:
|
||||
case 0x94: case 0x95: case 0x96: case 0x97:
|
||||
case 0x98: case 0x99: case 0x9a: case 0x9b:
|
||||
case 0x9c: case 0x9d: case 0x9e: case 0x9f:
|
||||
|
@ -32,7 +32,7 @@ int g_joystick_scale_factor_y = 0x100;
|
||||
int g_joystick_trim_amount_x = 0;
|
||||
int g_joystick_trim_amount_y = 0;
|
||||
|
||||
int g_joystick_type = 0; /* 0 = Keypad Joystick */
|
||||
int g_joystick_type = JOYSTICK_TYPE_NATIVE_1; // OG Trying to set native joystick as default
|
||||
int g_joystick_native_type1 = -1;
|
||||
int g_joystick_native_type2 = -1;
|
||||
int g_joystick_native_type = -1;
|
||||
@ -50,16 +50,18 @@ void
|
||||
paddle_fixup_joystick_type()
|
||||
{
|
||||
/* If g_joystick_type points to an illegal value, change it */
|
||||
if(g_joystick_type == 2) {
|
||||
if(g_joystick_type == JOYSTICK_TYPE_NATIVE_1) {
|
||||
g_joystick_native_type = g_joystick_native_type1;
|
||||
if(g_joystick_native_type1 < 0) {
|
||||
g_joystick_type = 0;
|
||||
g_joystick_type = JOYSTICK_TYPE_KEYPAD;
|
||||
printf("no joy 1 --- switching to keypad\n");
|
||||
}
|
||||
}
|
||||
if(g_joystick_type == 3) {
|
||||
if(g_joystick_type == JOYSTICK_TYPE_NATIVE_2) {
|
||||
g_joystick_native_type = g_joystick_native_type2;
|
||||
if(g_joystick_native_type2 < 0) {
|
||||
g_joystick_type = 0;
|
||||
g_joystick_type = JOYSTICK_TYPE_KEYPAD;
|
||||
printf("no joy 2 --- switching to keypad\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -74,10 +76,13 @@ paddle_trigger(double dcycs)
|
||||
paddle_fixup_joystick_type();
|
||||
|
||||
switch(g_joystick_type) {
|
||||
case 0: /* Keypad Joystick */
|
||||
case JOYSTICK_TYPE_KEYPAD: /* Keypad Joystick */
|
||||
paddle_trigger_keypad(dcycs);
|
||||
break;
|
||||
case 1: /* Mouse Joystick */
|
||||
case JOYSTICK_TYPE_MOUSE: /* Mouse Joystick */
|
||||
paddle_trigger_mouse(dcycs);
|
||||
break;
|
||||
case JOYSTICK_TYPE_NONE: /* Mouse Joystick */
|
||||
paddle_trigger_mouse(dcycs);
|
||||
break;
|
||||
default:
|
||||
|
@ -49,6 +49,7 @@ void do_gen_test(int got_num, int base_seed);
|
||||
|
||||
/* engine.s and engine_c.c */
|
||||
void fixed_memory_ptrs_init();
|
||||
void fixed_memory_ptrs_shut(); // OG Added shut to smoothly free up allocated memory
|
||||
word32 get_itimer(void);
|
||||
|
||||
word32 get_memory_c(word32 addr, int cycs);
|
||||
@ -91,6 +92,7 @@ void joystick_update_buttons(void);
|
||||
|
||||
/* adb.c */
|
||||
void adb_init(void);
|
||||
void adb_shut(); // OG Added adb_shut()
|
||||
void adb_reset(void);
|
||||
void adb_log(word32 addr, int val);
|
||||
void show_adb_log(void);
|
||||
@ -294,6 +296,7 @@ void scc_socket_do_answer(int port, double dcycs);
|
||||
void iwm_init_drive(Disk *dsk, int smartport, int drive, int disk_525);
|
||||
void disk_set_num_tracks(Disk *dsk, int num_tracks);
|
||||
void iwm_init(void);
|
||||
void iwm_shut(void); //OG
|
||||
void iwm_reset(void);
|
||||
void draw_iwm_status(int line, char *buf);
|
||||
void iwm_flush_disk_to_unix(Disk *dsk);
|
||||
@ -334,6 +337,7 @@ void iwm_show_a_track(Trk *trk);
|
||||
|
||||
|
||||
/* moremem.c */
|
||||
void moremem_init(); // OG Added moremem_init()
|
||||
void fixup_brks(void);
|
||||
void fixup_hires_on(void);
|
||||
void fixup_bank0_2000_4000(void);
|
||||
@ -392,8 +396,10 @@ void do_reset(void);
|
||||
void check_engine_asm_defines(void);
|
||||
byte *memalloc_align(int size, int skip_amt, void **alloc_ptr);
|
||||
void memory_ptr_init(void);
|
||||
void memory_ptr_shut(void); // OG Added shut
|
||||
int gsportmain(int argc, char **argv);
|
||||
void load_roms_init_memory(void);
|
||||
void load_roms_shut_memory(void); // OG Added shut
|
||||
void gsport_expand_path(char *out_ptr, const char *in_ptr, int maxlen);
|
||||
void setup_gsport_file(char *outname, int maxlen, int ok_if_missing, int can_create_file, const char **name_ptr);
|
||||
void initialize_events(void);
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
/* windriver.c */
|
||||
int win_update_mouse(int x, int y, int button_states, int buttons_valid);
|
||||
void win_event_mouse(WPARAM wParam, LPARAM lParam);
|
||||
void win_event_mouse(int umsg,WPARAM wParam, LPARAM lParam);
|
||||
void win_event_key(HWND hwnd, UINT raw_vk, BOOL down, int repeat, UINT flags);
|
||||
void win_event_quit(HWND hwnd);
|
||||
void win_event_redraw(void);
|
||||
|
@ -21,6 +21,10 @@
|
||||
|
||||
#include "defc.h"
|
||||
|
||||
#ifdef UNDER_CE
|
||||
#define vsnprintf _vsnprintf
|
||||
#endif
|
||||
|
||||
extern int Verbose;
|
||||
extern int g_code_yellow;
|
||||
extern double g_cur_dcycs;
|
||||
@ -1122,7 +1126,7 @@ scc_add_to_readbufv(int port, double dcycs, const char *fmt, ...)
|
||||
int i;
|
||||
|
||||
va_start(ap, fmt);
|
||||
bufptr = malloc(4096);
|
||||
bufptr = (char*)malloc(4096); // OG cast added
|
||||
bufptr[0] = 0;
|
||||
ret = vsnprintf(bufptr, 4090, fmt, ap);
|
||||
len = strlen(bufptr);
|
||||
|
@ -79,7 +79,7 @@ scc_serial_mac_change_params(int port)
|
||||
|
||||
scc_ptr = &(scc_stat[port]);
|
||||
|
||||
fd = (int)scc_ptr->host_handle;
|
||||
fd = (intptr_t)scc_ptr->host_handle;
|
||||
printf("scc_serial_mac_change_parms port: %d, fd: %d\n", port, fd);
|
||||
if(fd <= 0) {
|
||||
return;
|
||||
@ -149,7 +149,7 @@ scc_serial_mac_fill_readbuf(int port, int space_left, double dcycs)
|
||||
|
||||
scc_ptr = &(scc_stat[port]);
|
||||
|
||||
fd = (int)scc_ptr->host_handle;
|
||||
fd = (intptr_t)scc_ptr->host_handle;
|
||||
if(fd <= 0) {
|
||||
return;
|
||||
}
|
||||
@ -179,7 +179,7 @@ scc_serial_mac_empty_writebuf(int port)
|
||||
|
||||
scc_ptr = &(scc_stat[port]);
|
||||
|
||||
fd = (int)scc_ptr->host_handle;
|
||||
fd = (intptr_t)scc_ptr->host_handle;
|
||||
if(fd <= 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -23,12 +23,17 @@
|
||||
|
||||
#include "defc.h"
|
||||
#include "scc.h"
|
||||
#ifndef UNDER_CE //OG
|
||||
#include <signal.h>
|
||||
|
||||
#endif
|
||||
extern Scc scc_stat[2];
|
||||
extern int g_serial_modem[];
|
||||
|
||||
//extern int h_errno;
|
||||
#ifndef _MSC_VER //OG
|
||||
extern int h_errno;
|
||||
#else
|
||||
#define socklen_t int
|
||||
#endif
|
||||
int g_wsastartup_called = 0;
|
||||
|
||||
/* Usage: scc_socket_init() called to init socket mode */
|
||||
@ -195,7 +200,7 @@ scc_socket_open_outgoing(int port, double dcycs)
|
||||
memset(&sa_in, 0, sizeof(sa_in));
|
||||
sa_in.sin_family = AF_INET;
|
||||
sa_in.sin_port = htons(23);
|
||||
hostentptr = gethostbyname(&scc_ptr->modem_cmd_str[0]);
|
||||
hostentptr = gethostbyname((const char*)&scc_ptr->modem_cmd_str[0]); // OG Added Cast
|
||||
if(hostentptr == 0) {
|
||||
#if defined(_WIN32) || defined (__OS2__)
|
||||
fatal_printf("Lookup host %s failed\n",
|
||||
@ -352,8 +357,8 @@ scc_accept_socket(int port, double dcycs)
|
||||
return; /* just give up */
|
||||
}
|
||||
if(scc_ptr->rdwrfd == -1) {
|
||||
rdwrfd = accept(scc_ptr->sockfd, scc_ptr->host_handle,
|
||||
&(scc_ptr->host_aux1));
|
||||
rdwrfd = accept(scc_ptr->sockfd, (sockaddr*)scc_ptr->host_handle,
|
||||
(socklen_t*)&(scc_ptr->host_aux1));
|
||||
if(rdwrfd < 0) {
|
||||
return;
|
||||
}
|
||||
@ -448,7 +453,7 @@ scc_socket_fill_readbuf(int port, int space_left, double dcycs)
|
||||
|
||||
/* Try reading some bytes */
|
||||
space_left = MIN(space_left, 256);
|
||||
ret = recv(rdwrfd, tmp_buf, space_left, 0);
|
||||
ret = recv(rdwrfd, (char*)tmp_buf, space_left, 0); // OG Added cast
|
||||
if(ret > 0) {
|
||||
for(i = 0; i < ret; i++) {
|
||||
if(tmp_buf[i] == 0) {
|
||||
@ -740,7 +745,7 @@ scc_socket_empty_writebuf(int port, double dcycs)
|
||||
}
|
||||
|
||||
#if defined(_WIN32) || defined (__OS2__)
|
||||
ret = send(rdwrfd, &(scc_ptr->out_buf[rdptr]), len, 0);
|
||||
ret = send(rdwrfd, (const char*)&(scc_ptr->out_buf[rdptr]), len, 0); // OG Added Cast
|
||||
# else
|
||||
/* ignore SIGPIPE around writes to the socket, so we */
|
||||
/* can catch a closed socket and prepare to accept */
|
||||
@ -800,7 +805,7 @@ scc_socket_modem_write(int port, int c, double dcycs)
|
||||
}
|
||||
|
||||
modem_mode = scc_ptr->modem_mode;
|
||||
str = &(scc_ptr->modem_cmd_str[0]);
|
||||
str = (char*)&(scc_ptr->modem_cmd_str[0]); // OG Added Cast
|
||||
|
||||
#if 0
|
||||
printf("M: %02x\n", c);
|
||||
@ -864,7 +869,7 @@ scc_socket_do_cmd_str(int port, double dcycs)
|
||||
|
||||
scc_ptr = &(scc_stat[port]);
|
||||
|
||||
str = &(scc_ptr->modem_cmd_str[0]);
|
||||
str = (char*)&(scc_ptr->modem_cmd_str[0]); // OG Added cast
|
||||
printf("Got modem string :%s:=%02x %02x %02x\n", str, str[0], str[1],
|
||||
str[2]);
|
||||
|
||||
@ -1102,7 +1107,7 @@ scc_socket_modem_do_ring(int port, double dcycs)
|
||||
num_rings = 0;
|
||||
}
|
||||
scc_ptr->socket_num_rings = num_rings;
|
||||
scc_ptr->socket_last_ring_dcycs = dcycs;
|
||||
scc_ptr->socket_last_ring_dcycs = (int)dcycs;
|
||||
if(num_rings <= 0) {
|
||||
/* decide on answering */
|
||||
if(scc_ptr->modem_s0_val || (g_serial_modem[port]==0)) {
|
||||
|
@ -24,6 +24,10 @@
|
||||
#include "defc.h"
|
||||
#include "scc.h"
|
||||
|
||||
#ifdef UNDER_CE
|
||||
#define vsnprintf _vsnprintf
|
||||
#endif
|
||||
|
||||
extern Scc scc_stat[2];
|
||||
extern word32 g_c025_val;
|
||||
|
||||
@ -32,7 +36,7 @@ int
|
||||
scc_serial_win_init(int port)
|
||||
{
|
||||
COMMTIMEOUTS commtimeouts;
|
||||
char str_buf[8];
|
||||
TCHAR str_buf[8];
|
||||
Scc *scc_ptr;
|
||||
HANDLE host_handle;
|
||||
int state;
|
||||
@ -42,8 +46,11 @@ scc_serial_win_init(int port)
|
||||
|
||||
scc_ptr->state = 0; /* mark as failed */
|
||||
|
||||
#ifdef UNICODE
|
||||
wsprintf(&str_buf[0], _T("COM%d"), port+1);
|
||||
#else
|
||||
sprintf(&str_buf[0], "COM%d", port+1);
|
||||
|
||||
#endif
|
||||
host_handle = CreateFile(&str_buf[0], GENERIC_READ | GENERIC_WRITE,
|
||||
0, NULL, OPEN_EXISTING, 0, NULL);
|
||||
|
||||
@ -88,7 +95,7 @@ scc_serial_win_change_params(int port)
|
||||
scc_ptr = &(scc_stat[port]);
|
||||
|
||||
host_handle = scc_ptr->host_handle;
|
||||
dcbptr = scc_ptr->host_handle2;
|
||||
dcbptr = (DCB*)scc_ptr->host_handle2; // OG Added cast
|
||||
if(host_handle == 0) {
|
||||
return;
|
||||
}
|
||||
@ -166,7 +173,7 @@ scc_serial_win_fill_readbuf(int port, int space_left, double dcycs)
|
||||
Scc *scc_ptr;
|
||||
HANDLE host_handle;
|
||||
DWORD bytes_read;
|
||||
int i;
|
||||
DWORD i;
|
||||
int ret;
|
||||
|
||||
scc_ptr = &(scc_stat[port]);
|
||||
|
226
src/sim65816.c
226
src/sim65816.c
@ -29,8 +29,16 @@
|
||||
#ifdef HAVE_PARALLEL
|
||||
#include "printer.h"
|
||||
#endif
|
||||
|
||||
#ifdef UNDER_CE
|
||||
#define vsnprintf _vsnprintf
|
||||
#endif
|
||||
|
||||
#define PC_LOG_LEN (8*1024)
|
||||
|
||||
int g_speed_fast ; // OG Expose fast parameter
|
||||
int g_initialized = 0; // OG To know if the emulator has finalized its initialization
|
||||
int g_accept_events = 0; // OG To know if the emulator is ready to accept external events
|
||||
|
||||
char g_argv0_path[256] = "./";
|
||||
|
||||
@ -129,6 +137,7 @@ char* g_printer_font_ocra = "ocra.ttf";
|
||||
|
||||
int g_config_iwm_vbl_count = 0;
|
||||
const char g_gsport_version_str[] = "0.1";
|
||||
int g_pause=0; // OG Added pause
|
||||
|
||||
#define START_DCYCS (0.0)
|
||||
|
||||
@ -185,6 +194,13 @@ byte *g_dummy_memory1_ptr = 0;
|
||||
byte *g_rom_fc_ff_ptr = 0;
|
||||
byte *g_rom_cards_ptr = 0;
|
||||
|
||||
// OG Added allocated pointers
|
||||
byte *g_slow_memory_ptr_allocated = 0;
|
||||
byte *g_memory_ptr_allocated = 0;
|
||||
byte *g_dummy_memory1_ptr_allocated = 0;
|
||||
byte *g_rom_fc_ff_ptr_allocated = 0;
|
||||
byte *g_rom_cards_ptr_allocated = 0;
|
||||
|
||||
void *g_memory_alloc_ptr = 0; /* for freeing memory area */
|
||||
|
||||
Page_info page_info_rd_wr[2*65536 + PAGE_INFO_PAD_SIZE];
|
||||
@ -200,7 +216,70 @@ Data_log *g_log_data_ptr = &(g_data_log_array[0]);
|
||||
Data_log *g_log_data_start_ptr = &(g_data_log_array[0]);
|
||||
Data_log *g_log_data_end_ptr = &(g_data_log_array[PC_LOG_LEN]);
|
||||
|
||||
// OG Added sim65816_initglobals()
|
||||
void sim65816_initglobals()
|
||||
{
|
||||
|
||||
g_fcycles_stop = 0.0;
|
||||
halt_sim = 0;
|
||||
enter_debug = 0;
|
||||
g_rom_version = -1;
|
||||
g_user_halt_bad = 0;
|
||||
g_halt_on_bad_read = 0;
|
||||
g_ignore_bad_acc = 1;
|
||||
g_ignore_halts = 1;
|
||||
g_code_red = 0;
|
||||
g_code_yellow = 0;
|
||||
g_use_alib = 0;
|
||||
g_raw_serial = 1;
|
||||
g_iw2_emul = 0;
|
||||
g_serial_out_masking = 0;
|
||||
//g_serial_modem[2] = { 0, 1 };
|
||||
|
||||
g_config_iwm_vbl_count = 0;
|
||||
|
||||
g_pause=0;
|
||||
|
||||
g_last_vbl_dcycs = START_DCYCS;
|
||||
g_cur_dcycs = START_DCYCS;
|
||||
|
||||
g_last_vbl_dadjcycs = 0.0;
|
||||
g_dadjcycs = 0.0;
|
||||
|
||||
|
||||
g_wait_pending = 0;
|
||||
g_stp_pending = 0;
|
||||
|
||||
g_num_irq = 0;
|
||||
g_num_brk = 0;
|
||||
g_num_cop = 0;
|
||||
g_num_enter_engine = 0;
|
||||
g_io_amt = 0;
|
||||
g_engine_action = 0;
|
||||
g_engine_halt_event = 0;
|
||||
g_engine_scan_int = 0;
|
||||
g_engine_doc_int = 0;
|
||||
|
||||
g_testing = 0;
|
||||
g_testing_enabled = 0;
|
||||
|
||||
g_debug_file_fd = -1;
|
||||
g_fatal_log = -1;
|
||||
|
||||
g_25sec_cntr = 0;
|
||||
g_1sec_cntr = 0;
|
||||
|
||||
g_dnatcycs_1sec = 0.0;
|
||||
g_natcycs_lastvbl = 0;
|
||||
|
||||
Verbose = 0;
|
||||
Halt_on = 0;
|
||||
|
||||
g_mem_size_base = 256*1024; /* size of motherboard memory */
|
||||
g_mem_size_exp = 8*1024*1024; /* size of expansion RAM card */
|
||||
g_mem_size_total = 256*1024; /* Total contiguous RAM from 0 */
|
||||
}
|
||||
|
||||
void
|
||||
show_pc_log()
|
||||
{
|
||||
@ -329,7 +408,7 @@ toolbox_debug_c(word32 xreg, word32 stack, double *cyc_ptr)
|
||||
pos = g_toolbox_log_pos;
|
||||
|
||||
stack += 9;
|
||||
g_toolbox_log_array[pos][0] = g_last_vbl_dcycs + *cyc_ptr;
|
||||
g_toolbox_log_array[pos][0] = (word32)(g_last_vbl_dcycs + *cyc_ptr);
|
||||
g_toolbox_log_array[pos][1] = stack+1;
|
||||
g_toolbox_log_array[pos][2] = xreg;
|
||||
g_toolbox_log_array[pos][3] = toolbox_debug_4byte(stack+1);
|
||||
@ -620,15 +699,31 @@ show_regs()
|
||||
show_regs_act(&engine);
|
||||
}
|
||||
|
||||
void
|
||||
my_exit(int ret)
|
||||
//OG for regular exit, use quitEmulator()
|
||||
|
||||
void quitEmulator()
|
||||
{
|
||||
end_screen();
|
||||
printf("set_halt(HALT_WANTTOQUIT)\n");
|
||||
set_halt(HALT_WANTTOQUIT);
|
||||
}
|
||||
|
||||
//OG change exit to fatal_exit()
|
||||
|
||||
#ifndef ACTIVEGS
|
||||
// use standard exit function
|
||||
#define fatalExit exit
|
||||
#else
|
||||
extern void fatalExit(int);
|
||||
#endif
|
||||
|
||||
void my_exit(int ret)
|
||||
{
|
||||
end_screen();
|
||||
#ifdef HAVE_PARALLEL
|
||||
printer_close();
|
||||
#endif
|
||||
printf("exiting\n");
|
||||
exit(ret);
|
||||
printf("exiting (ret=%d)\n",ret);
|
||||
fatalExit(ret);
|
||||
}
|
||||
|
||||
|
||||
@ -668,6 +763,14 @@ do_reset()
|
||||
|
||||
g_stepping = 0;
|
||||
|
||||
// OG Cleared remaining IRQS on RESET
|
||||
extern int g_irq_pending;
|
||||
extern int g_scan_int_events ;
|
||||
extern int g_c023_val;
|
||||
|
||||
if (g_irq_pending)
|
||||
halt_printf("*** irq remainings...\n");
|
||||
|
||||
}
|
||||
|
||||
#define CHECK(start, var, value, var1, var2) \
|
||||
@ -730,7 +833,7 @@ memalloc_align(int size, int skip_amt, void **alloc_ptr)
|
||||
word32 offset;
|
||||
|
||||
skip_amt = MAX(256, skip_amt);
|
||||
bptr = calloc(size + skip_amt, 1);
|
||||
bptr = (byte*)calloc(size + skip_amt + 256, 1); // OG Added cast
|
||||
if(alloc_ptr) {
|
||||
/* Save allocation address */
|
||||
*alloc_ptr = bptr;
|
||||
@ -755,16 +858,34 @@ memory_ptr_init()
|
||||
/* changes this will be called */
|
||||
mem_size = MIN(0xdf0000, g_mem_size_base + g_mem_size_exp);
|
||||
g_mem_size_total = mem_size;
|
||||
|
||||
// OG using memory_ptr_shut() instead
|
||||
memory_ptr_shut();
|
||||
/*
|
||||
if(g_memory_alloc_ptr) {
|
||||
free(g_memory_alloc_ptr);
|
||||
g_memory_alloc_ptr = 0;
|
||||
}
|
||||
*/
|
||||
g_memory_ptr = memalloc_align(mem_size, 256, &g_memory_alloc_ptr);
|
||||
|
||||
printf("RAM size is 0 - %06x (%.2fMB)\n", mem_size,
|
||||
(double)mem_size/(1024.0*1024.0));
|
||||
}
|
||||
|
||||
// OG Added memory_ptr_shut
|
||||
void
|
||||
memory_ptr_shut()
|
||||
{
|
||||
if(g_memory_alloc_ptr)
|
||||
{
|
||||
free(g_memory_alloc_ptr);
|
||||
g_memory_alloc_ptr = 0;
|
||||
}
|
||||
g_memory_ptr = 0;
|
||||
}
|
||||
|
||||
|
||||
extern int g_screen_redraw_skip_amt;
|
||||
extern int g_use_shmem;
|
||||
extern int g_use_dhr140;
|
||||
@ -778,14 +899,22 @@ int g_screen_depth = 8;
|
||||
int
|
||||
gsportmain(int argc, char **argv)
|
||||
{
|
||||
int skip_amt;
|
||||
int diff;
|
||||
|
||||
// OG Restoring globals
|
||||
sim65816_initglobals();
|
||||
moremem_init();
|
||||
|
||||
//OG Disabling argument parsing
|
||||
#ifndef ACTIVEGS
|
||||
|
||||
int skip_amt;
|
||||
int tmp1;
|
||||
int i;
|
||||
char *final_arg = 0;
|
||||
|
||||
/* parse args */
|
||||
for(i = 1; i < argc; i++) {
|
||||
for(i = 1; i < argc; i++) {
|
||||
if(!strcmp("-badrd", argv[i])) {
|
||||
printf("Halting on bad reads\n");
|
||||
g_halt_on_bad_read = 2;
|
||||
@ -897,8 +1026,8 @@ gsportmain(int argc, char **argv)
|
||||
exit(3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
check_engine_asm_defines();
|
||||
fixed_memory_ptrs_init();
|
||||
|
||||
@ -987,12 +1116,33 @@ gsportmain(int argc, char **argv)
|
||||
|
||||
do_reset();
|
||||
g_stepping = 0;
|
||||
|
||||
// OG Notify emulator has been initialized and ready to accept external events
|
||||
g_initialized = 1;
|
||||
g_accept_events = 1;
|
||||
|
||||
do_go();
|
||||
|
||||
/* If we get here, we hit a breakpoint, call debug intfc */
|
||||
do_debug_intfc();
|
||||
|
||||
my_exit(0);
|
||||
// OG Notify emulator is being closed, and cannot accept events anymore
|
||||
g_accept_events = 0;
|
||||
|
||||
sound_shutdown();
|
||||
|
||||
|
||||
// OG Cleaning up
|
||||
adb_shut();
|
||||
iwm_shut();
|
||||
fixed_memory_ptrs_shut();
|
||||
load_roms_shut_memory();
|
||||
clear_fatal_logs();
|
||||
|
||||
// OG Not needed anymore : the emulator will quit gently
|
||||
//my_exit(0);
|
||||
end_screen();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1017,6 +1167,14 @@ load_roms_init_memory()
|
||||
set_memory16_c(0xe115fe, 0, 0);
|
||||
}
|
||||
|
||||
// OG Added load_roms_shut_memory
|
||||
void load_roms_shut_memory()
|
||||
{
|
||||
memory_ptr_shut();
|
||||
}
|
||||
|
||||
#ifndef ACTIVEGS
|
||||
|
||||
void
|
||||
gsport_expand_path(char *out_ptr, const char *in_ptr, int maxlen)
|
||||
{
|
||||
@ -1154,6 +1312,8 @@ setup_gsport_file(char *outname, int maxlen, int ok_if_missing,
|
||||
my_exit(2);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Event g_event_list[MAX_EVENTS];
|
||||
Event g_event_free;
|
||||
Event g_event_start;
|
||||
@ -1486,10 +1646,13 @@ run_prog()
|
||||
|
||||
while(1) {
|
||||
fflush(stdout);
|
||||
|
||||
// OG Disabling control panel
|
||||
#ifndef ACTIVEGS
|
||||
if(g_config_control_panel) {
|
||||
config_control_panel();
|
||||
}
|
||||
|
||||
#endif
|
||||
if(g_irq_pending && !(engine.psr & 0x4)) {
|
||||
irq_printf("taking an irq!\n");
|
||||
take_irq(0);
|
||||
@ -1503,7 +1666,8 @@ run_prog()
|
||||
zip_follow_cps = ((g_zipgs_reg_c059 & 0x8) != 0);
|
||||
zip_speed_0tof_new = g_zipgs_reg_c05a & 0xf0;
|
||||
fast = (g_c036_val_speed & 0x80) || (zip_en && !zip_follow_cps);
|
||||
|
||||
// OG Make fast parameter public
|
||||
g_speed_fast = fast;
|
||||
if(zip_speed_0tof_new != zip_speed_0tof) {
|
||||
zip_speed_0tof = zip_speed_0tof_new;
|
||||
setup_zip_speeds();
|
||||
@ -1518,7 +1682,11 @@ run_prog()
|
||||
zip_speed = faster_than_28 &&
|
||||
((zip_speed_0tof != 0) || (limit_speed == 3) ||
|
||||
(g_zipgs_unlock >= 4) );
|
||||
unl_speed = faster_than_28 && !zip_speed;
|
||||
|
||||
// OG unlimited speed should not be affected by zip.
|
||||
// unl_speed = faster_than_28 && !zip_speed;
|
||||
unl_speed = (limit_speed == 0) && faster_than_28;
|
||||
|
||||
if(unl_speed) {
|
||||
/* use unlimited speed */
|
||||
fspeed_mult = g_projected_pmhz;
|
||||
@ -1928,6 +2096,13 @@ update_60hz(double dcycs, double dtime_now)
|
||||
default: sp_str = "Unlimited"; break;
|
||||
}
|
||||
|
||||
// OG Pass speed info to the control (ActiveX specific)
|
||||
#ifdef ACTIVEGS
|
||||
{
|
||||
extern void updateInfo(const char* target,const char *speed);
|
||||
updateInfo(sp_str,total_mhz_ptr);
|
||||
}
|
||||
#endif
|
||||
sprintf(status_buf, "dcycs:%9.1f sim MHz:%s "
|
||||
"Eff MHz:%s, sec:%1.3f vol:%02x pal:%x, Limit:%s",
|
||||
dcycs/(1000.0*1000.0), sim_mhz_ptr, total_mhz_ptr,
|
||||
@ -2156,7 +2331,17 @@ update_60hz(double dcycs, double dtime_now)
|
||||
}
|
||||
|
||||
iwm_vbl_update(doit_3_persec);
|
||||
|
||||
// OG Disabling config update
|
||||
#ifndef ACTIVEGS
|
||||
config_vbl_update(doit_3_persec);
|
||||
#else
|
||||
// OG Added disk update
|
||||
{
|
||||
extern void checkImages();
|
||||
checkImages();
|
||||
}
|
||||
#endif
|
||||
|
||||
video_update();
|
||||
sound_update(dcycs);
|
||||
@ -2249,7 +2434,7 @@ check_scan_line_int(double dcycs, int cur_video_line)
|
||||
}
|
||||
if(g_slow_memory_ptr[0x19d00+i] & 0x40) {
|
||||
irq_printf("Adding scan_int for line %d\n", i);
|
||||
delay = (DCYCS_IN_16MS/262.0) * ((double)line);
|
||||
delay = (int)( (DCYCS_IN_16MS/262.0) * ((double)line) );
|
||||
add_event_entry(g_last_vbl_dcycs + delay, EV_SCAN_INT +
|
||||
(line << 8));
|
||||
g_scan_int_events = 1;
|
||||
@ -2465,12 +2650,15 @@ gsport_vprintf(const char *fmt, va_list ap)
|
||||
int len;
|
||||
int ret;
|
||||
|
||||
bufptr = malloc(4096);
|
||||
bufptr = (char*)malloc(4096); // OG Added Cast
|
||||
ret = vsnprintf(bufptr, 4090, fmt, ap);
|
||||
|
||||
// OG Display warning
|
||||
printf("Warning:%s",bufptr);
|
||||
|
||||
len = strlen(bufptr);
|
||||
if(g_fatal_log >= 0 && g_fatal_log < MAX_FATAL_LOGS) {
|
||||
buf2ptr = malloc(len+1);
|
||||
buf2ptr = (char*)malloc(len+1); // OG Added Cast
|
||||
memcpy(buf2ptr, bufptr, len+1);
|
||||
g_fatal_log_strs[g_fatal_log++] = buf2ptr;
|
||||
}
|
||||
@ -2521,7 +2709,7 @@ gsport_malloc_str(char *in_str)
|
||||
int len;
|
||||
|
||||
len = strlen(in_str) + 1;
|
||||
str = malloc(len);
|
||||
str = (char*)malloc(len); // OG Added cast
|
||||
memcpy(str, in_str, len);
|
||||
|
||||
return str;
|
||||
|
57
src/sound.c
57
src/sound.c
@ -231,6 +231,31 @@ sound_init()
|
||||
rptr->last_samp_val = 0;
|
||||
}
|
||||
|
||||
// OG sound globals initialization
|
||||
g_num_c030_fsamps = 0;
|
||||
g_sound_shm_pos = 0;
|
||||
g_queued_samps = 0;
|
||||
g_queued_nonsamps = 0;
|
||||
|
||||
doc_sound_ctl = 0;
|
||||
doc_saved_val = 0;
|
||||
g_doc_num_osc_en = 1;
|
||||
g_dcycs_per_doc_update = 1.0;
|
||||
g_dupd_per_dcyc = 1.0;
|
||||
g_drecip_osc_en_plus_2 = 1.0 / (double)(1 + 2);
|
||||
|
||||
doc_reg_e0 = 0xff;
|
||||
g_audio_rate = 0;
|
||||
g_daudio_rate = 0.0;
|
||||
g_drecip_audio_rate = 0.0;
|
||||
g_dsamps_per_dcyc = 0.0;
|
||||
g_dcycs_per_samp = 0.0;
|
||||
g_fsamps_per_dcyc = 0.0;
|
||||
|
||||
g_doc_vol = 2;
|
||||
|
||||
g_last_sound_play_dsamp = 0.0;
|
||||
|
||||
sound_init_general();
|
||||
}
|
||||
|
||||
@ -288,7 +313,7 @@ sound_init_general()
|
||||
}
|
||||
#else
|
||||
/* windows and mac */
|
||||
shmaddr = malloc(size);
|
||||
shmaddr = (word32*)malloc(size);
|
||||
memset(shmaddr, 0, size);
|
||||
#endif
|
||||
|
||||
@ -364,7 +389,7 @@ parent_sound_get_sample_rate(int read_fd)
|
||||
word32 tmp;
|
||||
int ret;
|
||||
|
||||
ret = read(read_fd, &tmp, 4);
|
||||
ret = read(read_fd, (char*)&tmp, 4);
|
||||
if(ret != 4) {
|
||||
printf("parent could not get audio sample rate from child, disabling sound.\n");
|
||||
printf("ret: %d, fd: %d errno:%d\n", ret, read_fd, errno);
|
||||
@ -408,13 +433,19 @@ sound_reset(double dcycs)
|
||||
}
|
||||
g_num_osc_interrupting = 0;
|
||||
|
||||
// OG No reason to reset the number of active oscillo on reset : this should only be done on startup.
|
||||
/*
|
||||
g_doc_num_osc_en = 1;
|
||||
UPDATE_G_DCYCS_PER_DOC_UPDATE(1);
|
||||
*/
|
||||
}
|
||||
|
||||
void
|
||||
sound_shutdown()
|
||||
{
|
||||
// OG stop sound and free memory on sound_shutdown
|
||||
sound_reset(g_cur_dcycs);
|
||||
|
||||
#ifdef _WIN32
|
||||
win32snd_shutdown();
|
||||
#elif defined(__OS2__)
|
||||
@ -423,6 +454,14 @@ sound_shutdown()
|
||||
close(g_pipe_fd[1]);
|
||||
}
|
||||
#endif
|
||||
|
||||
// OG Free up allocated memory
|
||||
if (g_sound_shm_addr)
|
||||
{
|
||||
free(g_sound_shm_addr);
|
||||
g_sound_shm_addr = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -819,7 +858,7 @@ sound_play(double dsamps)
|
||||
|
||||
if(c030_state) {
|
||||
/* add in fractional time */
|
||||
ftmp = (int)(fsampnum + (float)1.0);
|
||||
ftmp = (float)(int)(fsampnum + 1.0f); //OG added cast
|
||||
fpercent += (ftmp - fsampnum);
|
||||
}
|
||||
|
||||
@ -1548,7 +1587,10 @@ doc_write_ctl_reg(int osc, int val, double dsamps)
|
||||
if(old_halt != 0) {
|
||||
/* start sound */
|
||||
DOC_LOG("ctl_sound_play", osc, eff_dsamps, val);
|
||||
sound_play(eff_dsamps);
|
||||
|
||||
// OG If the sound_play is executed, it may restart a oscillo we thought was stopped at time,
|
||||
// hence crashing the start_sound function (cf. game Arrgh!)
|
||||
//sound_play(eff_dsamps);
|
||||
g_doc_regs[osc].ctl = val;
|
||||
|
||||
start_sound(osc, eff_dsamps, dsamps);
|
||||
@ -1597,7 +1639,8 @@ doc_recalc_sound_parms(int osc, double eff_dcycs, double dsamps)
|
||||
res = wave_size & 7;
|
||||
|
||||
shifted_size = size << SND_PTR_SHIFT;
|
||||
cur_start = (rptr->waveptr << (8 + SND_PTR_SHIFT)) & (-shifted_size);
|
||||
|
||||
cur_start = (rptr->waveptr << (8 + SND_PTR_SHIFT)) & (-(int)shifted_size); // OG
|
||||
|
||||
dtmp1 = dfreq * (DOC_SCAN_RATE * g_drecip_audio_rate);
|
||||
dacc = (double)(1 << (20 - (17 - sz + res)));
|
||||
@ -1899,6 +1942,10 @@ doc_write_c03d(int val, double dcycs)
|
||||
g_doc_num_osc_en = tmp;
|
||||
UPDATE_G_DCYCS_PER_DOC_UPDATE(tmp);
|
||||
|
||||
// OG Update any oscs that were running to take care of the new numbers of oscillo
|
||||
for(i = 0; i<g_doc_num_osc_en; i++)
|
||||
doc_recalc_sound_parms(i,0.0,0.0);
|
||||
|
||||
/* Stop any oscs that were running but now */
|
||||
/* are disabled */
|
||||
for(i = g_doc_num_osc_en; i < 0x20; i++) {
|
||||
|
@ -34,7 +34,9 @@
|
||||
# include <sys/socket.h>
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
#ifndef UNDER_CE
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
|
||||
extern int Verbose;
|
||||
@ -165,7 +167,7 @@ child_sound_loop(int read_fd, int write_fd, word32 *shm_addr)
|
||||
|
||||
while(1) {
|
||||
errno = 0;
|
||||
ret = read(read_fd, &tmp, 4);
|
||||
ret = read(read_fd, (char*)&tmp, 4);
|
||||
if(ret <= 0) {
|
||||
printf("child dying from ret: %d, errno: %d\n",
|
||||
ret, errno);
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
TARGET = gsport.exe
|
||||
TFEOBJ = tfe/tfe.o arch/win32/tfearch.o tfe/tfesupp.o
|
||||
OBJECTS = $(OBJECTS1) $(TFEOBJ) scc_windriver.o win32snd_driver.o windriver.o
|
||||
OBJECTS = $(OBJECTS1) $(TFEOBJ) scc_windriver.o win32snd_driver.o win_console.o win_generic.o
|
||||
CCOPTS = -O2 -DGSPORT_LITTLE_ENDIAN -DHAVE_TFE
|
||||
SUFFIX = ".exe"
|
||||
NAME = gsport
|
||||
|
234
src/video.c
234
src/video.c
@ -81,7 +81,7 @@ Kimage g_mainwin_kimage;
|
||||
extern double g_last_vbl_dcycs;
|
||||
|
||||
double g_video_dcycs_check_input = 0.0;
|
||||
int g_video_extra_check_inputs = 0;
|
||||
int g_video_extra_check_inputs = 0; // OG Not recommended to use it (or apps might miss mouse changes)
|
||||
int g_video_act_margin_left = BASE_MARGIN_LEFT;
|
||||
int g_video_act_margin_right = BASE_MARGIN_RIGHT;
|
||||
int g_video_act_margin_top = BASE_MARGIN_TOP;
|
||||
@ -192,7 +192,7 @@ const byte g_dhires_colors_16[] = {
|
||||
0x0f/* 0xf white */
|
||||
};
|
||||
|
||||
const int g_lores_colors[] = {
|
||||
int g_lores_colors[] = {
|
||||
/* rgb */
|
||||
0x000, /* 0x0 black */
|
||||
0xd03, /* 0x1 deep red */
|
||||
@ -311,7 +311,7 @@ const word32 g_hires_convert[64] = {
|
||||
BIGEND(0x0f0f0f0f), /* 11,1111 = white ,white, white, white */
|
||||
};
|
||||
|
||||
const int g_screen_index[] = {
|
||||
int g_screen_index[] = {
|
||||
0x000, 0x080, 0x100, 0x180, 0x200, 0x280, 0x300, 0x380,
|
||||
0x028, 0x0a8, 0x128, 0x1a8, 0x228, 0x2a8, 0x328, 0x3a8,
|
||||
0x050, 0x0d0, 0x150, 0x1d0, 0x250, 0x2d0, 0x350, 0x3d0
|
||||
@ -334,24 +334,89 @@ video_init()
|
||||
int i, j;
|
||||
/* Initialize video system */
|
||||
|
||||
for(i = 0; i < 200; i++) {
|
||||
g_a2_line_kimage[i] = (void *)0;
|
||||
g_a2_line_stat[i] = -1;
|
||||
g_a2_line_left_edge[i] = 0;
|
||||
g_a2_line_right_edge[i] = 0;
|
||||
}
|
||||
for(i = 0; i < 200; i++) {
|
||||
g_a2_new_all_stat[i] = 0;
|
||||
g_a2_cur_all_stat[i] = 1;
|
||||
for(j = 0; j < 8; j++) {
|
||||
g_saved_line_palettes[i][j] = (word32)-1;
|
||||
}
|
||||
}
|
||||
for(i = 0; i < 262; i++) {
|
||||
g_cur_border_colors[i] = -1;
|
||||
}
|
||||
// OG Reinit globals
|
||||
g_a2_screen_buffer_changed = (word32)-1;
|
||||
g_full_refresh_needed = (word32)-1;
|
||||
g_cycs_in_40col = 0;
|
||||
g_cycs_in_xredraw = 0;
|
||||
g_refresh_bytes_xfer = 0;
|
||||
|
||||
g_new_a2_stat_cur_line = 0;
|
||||
g_video_dcycs_check_input = 0.0;
|
||||
//g_video_extra_check_inputs = 0;
|
||||
g_video_act_margin_left = BASE_MARGIN_LEFT;
|
||||
g_video_act_margin_right = BASE_MARGIN_RIGHT;
|
||||
g_video_act_margin_top = BASE_MARGIN_TOP;
|
||||
g_video_act_margin_bottom = BASE_MARGIN_BOTTOM;
|
||||
g_video_act_width = X_A2_WINDOW_WIDTH;
|
||||
g_video_act_height = X_A2_WINDOW_HEIGHT;
|
||||
|
||||
g_need_redraw = 1;
|
||||
g_palette_change_summary = 0;
|
||||
|
||||
g_border_sides_refresh_needed = 1;
|
||||
g_border_special_refresh_needed = 1;
|
||||
g_border_line24_refresh_needed = 1;
|
||||
g_status_refresh_needed = 1;
|
||||
|
||||
g_vbl_border_color = 0;
|
||||
g_border_last_vbl_changes = 0;
|
||||
|
||||
g_use_dhr140 = 0;
|
||||
g_use_bw_hires = 0;
|
||||
|
||||
g_new_a2_stat_cur_line = 0;
|
||||
g_vid_update_last_line = 0;
|
||||
|
||||
g_cur_a2_stat = ALL_STAT_TEXT | ALL_STAT_ANNUNC3 |(0xf << BIT_ALL_STAT_TEXT_COLOR);
|
||||
|
||||
|
||||
g_a2vid_palette = 0xe;
|
||||
g_installed_full_superhires_colormap = 0;
|
||||
|
||||
Max_color_size = 256;
|
||||
|
||||
g_saved_a2vid_palette = -1;
|
||||
|
||||
g_cycs_in_refresh_line = 0;
|
||||
g_cycs_in_refresh_ximage = 0;
|
||||
|
||||
g_num_lines_superhires = 0;
|
||||
g_num_lines_superhires640 = 0;
|
||||
g_num_lines_prev_superhires = 0;
|
||||
g_num_lines_prev_superhires640 = 0;
|
||||
|
||||
/*
|
||||
g_red_mask = 0xff;
|
||||
g_green_mask = 0xff;
|
||||
g_blue_mask = 0xff;
|
||||
g_red_left_shift = 16;
|
||||
g_green_left_shift = 8;
|
||||
g_blue_left_shift = 0;
|
||||
g_red_right_shift = 0;
|
||||
g_green_right_shift = 0;
|
||||
g_blue_right_shift = 0;
|
||||
*/
|
||||
|
||||
/* Initialize video system */
|
||||
|
||||
for(i = 0; i < 200; i++) {
|
||||
g_a2_line_kimage[i] = (Kimage *)0; // OG Changed from void* to kimage*
|
||||
g_a2_line_stat[i] = -1;
|
||||
g_a2_line_left_edge[i] = 0;
|
||||
g_a2_line_right_edge[i] = 0;
|
||||
}
|
||||
for(i = 0; i < 200; i++) {
|
||||
g_a2_new_all_stat[i] = 0;
|
||||
g_a2_cur_all_stat[i] = 1;
|
||||
for(j = 0; j < 8; j++) {
|
||||
g_saved_line_palettes[i][j] = (word32)-1;
|
||||
}
|
||||
}
|
||||
for(i = 0; i < 262; i++) {
|
||||
g_cur_border_colors[i] = -1;
|
||||
}
|
||||
|
||||
g_new_a2_stat_cur_line = 0;
|
||||
|
||||
dev_video_init();
|
||||
|
||||
@ -523,11 +588,24 @@ int g_screen_redraw_skip_amt = -1;
|
||||
|
||||
word32 g_cycs_in_check_input = 0;
|
||||
|
||||
void
|
||||
video_update()
|
||||
int g_needfullrefreshfornextframe = 1 ;
|
||||
|
||||
void video_update()
|
||||
{
|
||||
int did_video;
|
||||
|
||||
// OG g_needfullrefreshfornextframe
|
||||
if (g_needfullrefreshfornextframe)
|
||||
{
|
||||
g_full_refresh_needed = -1;
|
||||
g_a2_screen_buffer_changed = -1;
|
||||
g_status_refresh_needed = 1;
|
||||
g_border_sides_refresh_needed = 1;
|
||||
g_border_special_refresh_needed = 1;
|
||||
g_needfullrefreshfornextframe = 0;
|
||||
}
|
||||
|
||||
|
||||
update_border_info();
|
||||
|
||||
video_check_input_events();
|
||||
@ -554,10 +632,19 @@ video_update()
|
||||
|
||||
if(did_video) {
|
||||
g_new_a2_stat_cur_line = 0;
|
||||
g_a2_new_all_stat[0] = g_cur_a2_stat;
|
||||
g_vid_update_last_line = 0;
|
||||
video_update_through_line(0);
|
||||
g_a2_new_all_stat[0] = g_cur_a2_stat;
|
||||
g_vid_update_last_line = 0;
|
||||
video_update_through_line(0);
|
||||
}
|
||||
|
||||
|
||||
// OG Notify host that video has been uodated
|
||||
#if defined(ACTIVEGSPLUGIN) && defined(MAC)
|
||||
{
|
||||
extern void x_need2refresh();
|
||||
x_need2refresh();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -789,6 +876,8 @@ STRUCT(Border_changes) {
|
||||
int val;
|
||||
};
|
||||
|
||||
int g_border_color = 0; // OG Expose border color
|
||||
|
||||
Border_changes g_border_changes[MAX_BORDER_CHANGES];
|
||||
int g_num_border_changes = 0;
|
||||
|
||||
@ -797,8 +886,10 @@ change_border_color(double dcycs, int val)
|
||||
{
|
||||
int pos;
|
||||
|
||||
g_border_color = val; // OG Expose border color
|
||||
|
||||
pos = g_num_border_changes;
|
||||
g_border_changes[pos].fcycs = dcycs - g_last_vbl_dcycs;
|
||||
g_border_changes[pos].fcycs = (float)(dcycs - g_last_vbl_dcycs);
|
||||
g_border_changes[pos].val = val;
|
||||
|
||||
pos++;
|
||||
@ -810,6 +901,8 @@ change_border_color(double dcycs, int val)
|
||||
}
|
||||
}
|
||||
|
||||
extern int first;
|
||||
|
||||
void
|
||||
update_border_info()
|
||||
{
|
||||
@ -2895,10 +2988,16 @@ refresh_border()
|
||||
/**ZZZZ***/
|
||||
}
|
||||
|
||||
// OG Added video_release_kimages proto
|
||||
void video_release_kimages();
|
||||
|
||||
void
|
||||
end_screen()
|
||||
{
|
||||
printf("In end_screen\n");
|
||||
|
||||
// OG Free up allocated images
|
||||
video_release_kimages();
|
||||
xdriver_end();
|
||||
}
|
||||
|
||||
@ -3016,6 +3115,21 @@ video_get_kimages()
|
||||
g_screen_mdepth);
|
||||
}
|
||||
|
||||
// OG Added video_release_kimages (to match video_get_kimages)
|
||||
void video_release_kimages()
|
||||
{
|
||||
extern void x_release_kimage(Kimage *kimage_ptr);
|
||||
|
||||
x_release_kimage(&g_kimage_text[0]);
|
||||
x_release_kimage(&g_kimage_text[1]);
|
||||
x_release_kimage(&g_kimage_hires[0]);
|
||||
x_release_kimage(&g_kimage_hires[1]);
|
||||
x_release_kimage(&g_kimage_superhires);
|
||||
x_release_kimage(&g_kimage_border_special);
|
||||
x_release_kimage(&g_kimage_border_sides);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
video_convert_kimage_depth(Kimage *kim_in, Kimage *kim_out, int startx,
|
||||
int starty, int width, int height)
|
||||
@ -3077,6 +3191,14 @@ video_push_lines(Kimage *kimage_ptr, int start_line, int end_line, int left_pix,
|
||||
{
|
||||
int mdepth_mismatch;
|
||||
int srcy;
|
||||
int center = 0; // OG added variable to center screen
|
||||
|
||||
//OG add null pointer check when emulator is restarted
|
||||
if (!kimage_ptr)
|
||||
{
|
||||
printf("warning : video_push_lines(kimage_ptr=null)\n");
|
||||
return ;
|
||||
}
|
||||
|
||||
if(left_pix >= right_pix || left_pix < 0 || right_pix <= 0) {
|
||||
halt_printf("video_push_lines: lines %d to %d, pix %d to %d\n",
|
||||
@ -3098,7 +3220,14 @@ video_push_lines(Kimage *kimage_ptr, int start_line, int end_line, int left_pix,
|
||||
g_refresh_bytes_xfer += 2*(end_line - start_line) *
|
||||
(right_pix - left_pix);
|
||||
|
||||
x_push_kimage(kimage_ptr, g_video_act_margin_left + left_pix,
|
||||
// OG Calculating new center
|
||||
if (g_cur_a2_stat & ALL_STAT_SUPER_HIRES)
|
||||
center=0;
|
||||
else
|
||||
center=EFF_BORDER_WIDTH - BORDER_WIDTH;
|
||||
|
||||
// OG shifting image to the center
|
||||
x_push_kimage(kimage_ptr, g_video_act_margin_left + left_pix + center,
|
||||
g_video_act_margin_top + srcy, left_pix, srcy,
|
||||
(right_pix - left_pix), 2*(end_line - start_line));
|
||||
}
|
||||
@ -3162,7 +3291,28 @@ video_push_border_sides()
|
||||
#endif
|
||||
|
||||
/* redraw left sides */
|
||||
video_push_border_sides_lines(0, 0, BORDER_WIDTH, 0, 200);
|
||||
// OG Left side can alos be "jagged" as a2 screen is now being centered
|
||||
|
||||
//video_push_border_sides_lines(0, 0, BORDER_WIDTH, 0, 200);
|
||||
|
||||
prev_line = -1;
|
||||
old_width = -1;
|
||||
for(i = 0; i < 200; i++) {
|
||||
mode = (g_a2_line_stat[i] >> 4) & 7;
|
||||
width = EFF_BORDER_WIDTH;
|
||||
if(mode == MODE_SUPER_HIRES) {
|
||||
width = BORDER_WIDTH;
|
||||
}
|
||||
if(width != old_width) {
|
||||
video_push_border_sides_lines(BORDER_WIDTH,
|
||||
0, old_width,
|
||||
prev_line, i);
|
||||
prev_line = i;
|
||||
old_width = width;
|
||||
}
|
||||
}
|
||||
video_push_border_sides_lines(0/*BORDER_WIDTH*/,
|
||||
0, old_width, prev_line, 200);
|
||||
|
||||
/* right side--can be "jagged" */
|
||||
prev_line = -1;
|
||||
@ -3182,7 +3332,7 @@ video_push_border_sides()
|
||||
}
|
||||
}
|
||||
|
||||
video_push_border_sides_lines(BORDER_WIDTH,
|
||||
video_push_border_sides_lines(0/*BORDER_WIDTH*/,
|
||||
X_A2_WINDOW_WIDTH - old_width, old_width, prev_line, 200);
|
||||
}
|
||||
|
||||
@ -3226,6 +3376,9 @@ video_push_border_special()
|
||||
}
|
||||
}
|
||||
|
||||
// OG Added window ratio support
|
||||
extern int x_calc_ratio(float ratiox,float ratioy);
|
||||
|
||||
void
|
||||
video_push_kimages()
|
||||
{
|
||||
@ -3254,6 +3407,28 @@ video_push_kimages()
|
||||
|
||||
GET_ITIMER(start_time);
|
||||
|
||||
float ratiox,ratioy;
|
||||
|
||||
if (x_calc_ratio(ratiox,ratioy))
|
||||
{
|
||||
line = 0;
|
||||
while (1)
|
||||
{
|
||||
start = line;
|
||||
cur_kim = g_a2_line_kimage[line];
|
||||
while(line < 200 && g_a2_line_kimage[line] == cur_kim) line++;
|
||||
if (cur_kim == &g_kimage_superhires)
|
||||
right = 640;
|
||||
else
|
||||
right = 560;
|
||||
|
||||
video_push_lines(cur_kim, start, line,0,right);
|
||||
if (line==200) break;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
start = -1;
|
||||
last_kim = (Kimage *)-1;
|
||||
cur_kim = (Kimage *)0;
|
||||
@ -3309,6 +3484,7 @@ video_push_kimages()
|
||||
if(start >= 0) {
|
||||
video_push_lines(last_kim, start, 200, left_pix, right_pix);
|
||||
}
|
||||
}
|
||||
|
||||
g_a2_screen_buffer_changed = 0;
|
||||
g_full_refresh_needed = 0;
|
||||
|
@ -22,11 +22,8 @@
|
||||
#include "defc.h"
|
||||
#include "sound.h"
|
||||
|
||||
#ifndef __CYGWIN__
|
||||
# include <windows.h>
|
||||
# include <mmsystem.h>
|
||||
#endif
|
||||
//#include <unistd.h>
|
||||
|
||||
extern int Verbose;
|
||||
|
||||
@ -37,10 +34,8 @@ void check_wave_error(int res, char *str);
|
||||
|
||||
#define NUM_WAVE_HEADERS 8
|
||||
|
||||
#ifndef __CYGWIN__
|
||||
HWAVEOUT g_wave_handle;
|
||||
HWAVEOUT g_wave_handle = NULL; // OG Default value must be set
|
||||
WAVEHDR g_wavehdr[NUM_WAVE_HEADERS];
|
||||
#endif
|
||||
|
||||
extern int g_audio_enable;
|
||||
extern word32 *g_sound_shm_addr;
|
||||
@ -57,18 +52,39 @@ win32snd_init(word32 *shmaddr)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// OG Added global to free the dedicated win32 sound memory
|
||||
byte *bptr = NULL;
|
||||
|
||||
// OG shut win32 sound resources
|
||||
void
|
||||
win32snd_shutdown()
|
||||
{
|
||||
/* hmm */
|
||||
|
||||
if (g_wave_handle)
|
||||
{
|
||||
MMRESULT res = waveOutReset(g_wave_handle);
|
||||
if (res!=MMSYSERR_NOERROR )
|
||||
printf("waveOutReset Failed");
|
||||
|
||||
res = waveOutClose(g_wave_handle);
|
||||
if (res!=MMSYSERR_NOERROR )
|
||||
printf("waveOutClose Failed");
|
||||
g_wave_handle=NULL;
|
||||
}
|
||||
// OG Free dedicated sound memory
|
||||
if (bptr)
|
||||
{
|
||||
free(bptr);
|
||||
bptr = NULL;
|
||||
}
|
||||
|
||||
#ifndef __CYGWIN__
|
||||
}
|
||||
|
||||
|
||||
void CALLBACK
|
||||
handle_wav_snd(HWAVEOUT hwo, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1,
|
||||
DWORD_PTR dwParam2)
|
||||
handle_wav_snd(HWAVEOUT hwo, UINT uMsg, DWORD dwInstance, DWORD dwParam1,
|
||||
DWORD dwParam2)
|
||||
{
|
||||
LPWAVEHDR lpwavehdr;
|
||||
|
||||
@ -85,7 +101,7 @@ handle_wav_snd(HWAVEOUT hwo, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1
|
||||
void
|
||||
check_wave_error(int res, char *str)
|
||||
{
|
||||
char buf[256];
|
||||
TCHAR buf[256];
|
||||
|
||||
if(res == MMSYSERR_NOERROR) {
|
||||
return;
|
||||
@ -101,7 +117,9 @@ child_sound_init_win32()
|
||||
{
|
||||
WAVEFORMATEX wavefmt;
|
||||
WAVEOUTCAPS caps;
|
||||
byte *bptr;
|
||||
|
||||
// OG Moved as global variable (to rename)
|
||||
// byte *bptr;
|
||||
int bits_per_sample, channels, block_align;
|
||||
int blen;
|
||||
int res;
|
||||
@ -110,11 +128,17 @@ child_sound_init_win32()
|
||||
memset(&wavefmt, 0, sizeof(WAVEFORMATEX));
|
||||
|
||||
wavefmt.wFormatTag = WAVE_FORMAT_PCM;
|
||||
#ifndef UNDER_CE
|
||||
bits_per_sample = 16;
|
||||
wavefmt.nSamplesPerSec = g_audio_rate;
|
||||
#else
|
||||
bits_per_sample = 16;
|
||||
wavefmt.nSamplesPerSec = 12000;
|
||||
#endif
|
||||
|
||||
channels = 2;
|
||||
wavefmt.wBitsPerSample = bits_per_sample;
|
||||
wavefmt.nChannels = channels;
|
||||
wavefmt.nSamplesPerSec = g_audio_rate;
|
||||
block_align = channels * (bits_per_sample / 8);
|
||||
wavefmt.nBlockAlign = block_align;
|
||||
wavefmt.nAvgBytesPerSec = block_align * g_audio_rate;
|
||||
@ -129,7 +153,7 @@ child_sound_init_win32()
|
||||
}
|
||||
|
||||
res = waveOutOpen(&g_wave_handle, WAVE_MAPPER, &wavefmt,
|
||||
(DWORD_PTR)handle_wav_snd, 0, CALLBACK_FUNCTION | WAVE_ALLOWSYNC);
|
||||
(DWORD)handle_wav_snd, 0, CALLBACK_FUNCTION | WAVE_ALLOWSYNC);
|
||||
|
||||
if(res != MMSYSERR_NOERROR) {
|
||||
printf("Cannot register audio\n");
|
||||
@ -141,7 +165,7 @@ child_sound_init_win32()
|
||||
|
||||
blen = (SOUND_SHM_SAMP_SIZE * 4 * 2) / NUM_WAVE_HEADERS;
|
||||
g_win32snd_buflen = blen;
|
||||
bptr = malloc(blen * NUM_WAVE_HEADERS);
|
||||
bptr = (byte*)malloc(blen * NUM_WAVE_HEADERS); // OG Added cast
|
||||
if(bptr == NULL) {
|
||||
printf("Unabled to allocate sound buffer\n");
|
||||
exit(1);
|
||||
@ -150,7 +174,7 @@ child_sound_init_win32()
|
||||
for(i = 0; i < NUM_WAVE_HEADERS; i++) {
|
||||
memset(&g_wavehdr[i], 0, sizeof(WAVEHDR));
|
||||
g_wavehdr[i].dwUser = FALSE;
|
||||
g_wavehdr[i].lpData = &(bptr[i*blen]);
|
||||
g_wavehdr[i].lpData = (LPSTR)&(bptr[i*blen]); // OG Added cast
|
||||
g_wavehdr[i].dwBufferLength = blen;
|
||||
g_wavehdr[i].dwFlags = 0;
|
||||
g_wavehdr[i].dwLoops = 0;
|
||||
@ -220,5 +244,3 @@ win32_send_audio(byte *ptr, int in_size)
|
||||
|
||||
return in_size;
|
||||
}
|
||||
|
||||
#endif /* __CYGWIN */
|
||||
|
183
src/win_console.c
Normal file
183
src/win_console.c
Normal file
@ -0,0 +1,183 @@
|
||||
/*
|
||||
GSport - an Apple //gs Emulator
|
||||
Copyright (C) 2010 by GSport contributors
|
||||
|
||||
Based on the KEGS emulator written by and Copyright (C) 2003 Kent Dickey
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <mmsystem.h>
|
||||
#include <winsock.h>
|
||||
//#include <commctrl.h>
|
||||
|
||||
#include "defc.h"
|
||||
#include "protos_windriver.h"
|
||||
|
||||
|
||||
extern void gsportinit(HWND _hwnd);
|
||||
extern void gsportshut();
|
||||
extern HWND g_hwnd_main;
|
||||
|
||||
extern char *g_status_ptrs[MAX_STATUS_LINES];
|
||||
|
||||
|
||||
int
|
||||
win_nonblock_read_stdin(int fd, char *bufptr, int len)
|
||||
{
|
||||
|
||||
|
||||
HANDLE oshandle;
|
||||
DWORD dwret;
|
||||
int ret;
|
||||
|
||||
errno = EAGAIN;
|
||||
oshandle = (HANDLE)_get_osfhandle(fd); // get stdin handle
|
||||
dwret = WaitForSingleObject(oshandle, 1); // wait 1msec for data
|
||||
ret = -1;
|
||||
if(dwret == WAIT_OBJECT_0) {
|
||||
ret = read(fd, bufptr, len);
|
||||
}
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
x_dialog_create_gsport_conf(const char *str)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
x_show_alert(int is_fatal, const char *str)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int WINAPI WinMain (
|
||||
HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPSTR lpCmdLine,
|
||||
int nShowCmd)
|
||||
{
|
||||
return main(0,0);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
// InitCommonControls();
|
||||
|
||||
WNDCLASS wndclass;
|
||||
RECT rect;
|
||||
int height;
|
||||
|
||||
|
||||
wndclass.style = 0;
|
||||
wndclass.lpfnWndProc = (WNDPROC)win_event_handler;
|
||||
wndclass.cbClsExtra = 0;
|
||||
wndclass.cbWndExtra = 0;
|
||||
wndclass.hInstance = GetModuleHandle(NULL);
|
||||
wndclass.hIcon = LoadIcon((HINSTANCE)NULL, IDI_APPLICATION);
|
||||
wndclass.hCursor = LoadCursor((HINSTANCE) NULL, IDC_ARROW);
|
||||
wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); // OG Added cast
|
||||
wndclass.lpszMenuName = NULL;
|
||||
wndclass.lpszClassName = "gsport";
|
||||
|
||||
// Register the window
|
||||
if(!RegisterClass(&wndclass)) {
|
||||
printf("Registering window failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
height = X_A2_WINDOW_HEIGHT + (MAX_STATUS_LINES * 16) + 32;
|
||||
// g_main_height = height;
|
||||
|
||||
|
||||
HWND hwnd = CreateWindow("gsport", "GSport - Apple //gs Emulator",
|
||||
WS_TILED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
X_A2_WINDOW_WIDTH, height,
|
||||
NULL, NULL, GetModuleHandle(NULL), NULL);
|
||||
|
||||
printf("g_hwnd_main = %p, height = %d\n", hwnd, height);
|
||||
GetWindowRect(hwnd, &rect);
|
||||
printf("...rect is: %ld, %ld, %ld, %ld\n", rect.left, rect.top,
|
||||
rect.right, rect.bottom);
|
||||
|
||||
gsportinit(hwnd);
|
||||
int ret = gsportmain(argc, argv);
|
||||
|
||||
UnregisterClass(wndclass.lpszClassName,GetModuleHandle(NULL));
|
||||
|
||||
gsportshut();
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
x_check_input_events()
|
||||
{
|
||||
|
||||
MSG msg;
|
||||
|
||||
while(PeekMessage(&msg, g_hwnd_main, 0, 0, PM_NOREMOVE)) {
|
||||
if(GetMessage(&msg, g_hwnd_main, 0, 0) > 0) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
} else {
|
||||
printf("GetMessage returned <= 0\n");
|
||||
my_exit(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
x_redraw_status_lines()
|
||||
{
|
||||
COLORREF oldtextcolor, oldbkcolor;
|
||||
char *buf;
|
||||
int line;
|
||||
int len;
|
||||
int height;
|
||||
int margin;
|
||||
|
||||
height = 16;
|
||||
margin = 0;
|
||||
|
||||
HDC localdc = GetDC(g_hwnd_main); // OG Use on the fly DC
|
||||
oldtextcolor = SetTextColor(localdc, 0);
|
||||
oldbkcolor = SetBkColor(localdc, 0xffffff);
|
||||
for(line = 0; line < MAX_STATUS_LINES; line++) {
|
||||
buf = g_status_ptrs[line];
|
||||
if(buf != 0) {
|
||||
len = strlen(buf);
|
||||
TextOut(localdc, 10, X_A2_WINDOW_HEIGHT +
|
||||
height*line + margin, buf, len);
|
||||
}
|
||||
}
|
||||
SetTextColor(localdc, oldtextcolor);
|
||||
SetBkColor(localdc, oldbkcolor);
|
||||
ReleaseDC(g_hwnd_main,localdc);
|
||||
}
|
||||
|
||||
int x_calc_ratio(float ratiox,float ratioy)
|
||||
{
|
||||
return 0; // not stretched
|
||||
}
|
||||
|
||||
|
825
src/win_generic.c
Normal file
825
src/win_generic.c
Normal file
@ -0,0 +1,825 @@
|
||||
/*
|
||||
GSport - an Apple //gs Emulator
|
||||
Copyright (C) 2010 by GSport contributors
|
||||
|
||||
Based on the KEGS emulator written by and Copyright (C) 2003 Kent Dickey
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN /* Tell windows we want less header gunk */
|
||||
#define STRICT /* Tell Windows we want compile type checks */
|
||||
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <mmsystem.h>
|
||||
#include <winsock.h>
|
||||
#include <commctrl.h>
|
||||
#include <shellapi.h>
|
||||
|
||||
#include "defc.h"
|
||||
#include "protos.h"
|
||||
#include "protos_windriver.h"
|
||||
|
||||
extern int Verbose;
|
||||
|
||||
extern int g_pause; // OG Added Pause
|
||||
|
||||
extern int g_warp_pointer;
|
||||
extern int g_screen_depth;
|
||||
extern int g_force_depth;
|
||||
int g_screen_mdepth = 0;
|
||||
|
||||
// OG replaced g_quit_sim_now by quitEmulator
|
||||
// extern int g_quit_sim_now;
|
||||
extern void quitEmulator();
|
||||
|
||||
int g_use_shmem = 1;
|
||||
int g_has_focus = 0;
|
||||
int g_auto_repeat_on = -1;
|
||||
|
||||
extern Kimage g_mainwin_kimage;
|
||||
|
||||
//HDC g_main_dc; // OG dc cannot be a global
|
||||
HDC g_main_cdc;
|
||||
//int g_main_height = 0;
|
||||
|
||||
int g_win_capslock_down = 0;
|
||||
|
||||
extern word32 g_palette_8to1624[256];
|
||||
extern word32 g_a2palette_8to1624[256];
|
||||
|
||||
extern word32 g_full_refresh_needed;
|
||||
|
||||
extern int g_border_sides_refresh_needed;
|
||||
extern int g_border_special_refresh_needed;
|
||||
extern int g_status_refresh_needed;
|
||||
|
||||
extern int g_lores_colors[];
|
||||
extern int g_cur_a2_stat;
|
||||
|
||||
extern int g_a2vid_palette;
|
||||
|
||||
extern int g_installed_full_superhires_colormap;
|
||||
|
||||
extern int g_screen_redraw_skip_amt;
|
||||
|
||||
extern word32 g_a2_screen_buffer_changed;
|
||||
|
||||
HWND g_hwnd_main;
|
||||
BITMAPINFO *g_bmapinfo_ptr = 0;
|
||||
volatile BITMAPINFOHEADER *g_bmaphdr_ptr = 0;
|
||||
|
||||
int g_num_a2_keycodes = 0;
|
||||
|
||||
|
||||
int g_win_button_states = 0;
|
||||
|
||||
// OG Added calc_ratio
|
||||
int x_calc_ratio(float ratiox, float ratioy);
|
||||
|
||||
/* this table is used to search for the Windows VK_* in col 1 or 2 */
|
||||
/* flags bit 8 is or'ed into the VK, so we can distinguish keypad keys */
|
||||
/* regardless of numlock */
|
||||
int g_a2_key_to_wsym[][3] = {
|
||||
{ 0x35, VK_ESCAPE, 0 },
|
||||
{ 0x7a, VK_F1, 0 },
|
||||
{ 0x78, VK_F2, 0 }, // OG Was 7B but F2 is defined has 0x78 in a2_key_to_ascii
|
||||
{ 0x63, VK_F3, 0 },
|
||||
{ 0x76, VK_F4, 0 },
|
||||
{ 0x60, VK_F5, 0 },
|
||||
{ 0x61, VK_F6, 0 },
|
||||
{ 0x62, VK_F7, 0 },
|
||||
{ 0x64, VK_F8, 0 },
|
||||
{ 0x65, VK_F9, 0 },
|
||||
{ 0x6d, VK_F10, 0 },
|
||||
{ 0x67, VK_F11, 0 },
|
||||
{ 0x6f, VK_F12, 0 },
|
||||
{ 0x69, VK_F13, 0 },
|
||||
{ 0x6b, VK_F14, 0 },
|
||||
{ 0x71, VK_F15, 0 },
|
||||
{ 0x7f, VK_PAUSE, VK_CANCEL+0x100 },
|
||||
|
||||
{ 0x32, 0xc0, 0 }, /* '`' */
|
||||
{ 0x12, '1', 0 },
|
||||
{ 0x13, '2', 0 },
|
||||
{ 0x14, '3', 0 },
|
||||
{ 0x15, '4', 0 },
|
||||
{ 0x17, '5', 0 },
|
||||
{ 0x16, '6', 0 },
|
||||
{ 0x1a, '7', 0 },
|
||||
{ 0x1c, '8', 0 },
|
||||
{ 0x19, '9', 0 },
|
||||
{ 0x1d, '0', 0 },
|
||||
{ 0x1b, 0xbd, 0 }, /* '-' */
|
||||
{ 0x18, 0xbb, 0 }, /* '=' */
|
||||
{ 0x33, VK_BACK, 0 }, /* backspace */
|
||||
{ 0x72, VK_INSERT+0x100, 0 }, /* Insert key */
|
||||
/* { 0x73, XK_Home, 0 }, alias VK_HOME to be KP_Equal! */
|
||||
{ 0x74, VK_PRIOR+0x100, 0 }, /* pageup */
|
||||
{ 0x47, VK_NUMLOCK, VK_NUMLOCK+0x100 }, /* clear */
|
||||
{ 0x51, VK_HOME+0x100, 0 }, /* KP_equal is HOME key */
|
||||
{ 0x4b, VK_DIVIDE, VK_DIVIDE+0x100 },
|
||||
{ 0x43, VK_MULTIPLY, VK_MULTIPLY+0x100 },
|
||||
|
||||
{ 0x30, VK_TAB, 0 },
|
||||
{ 0x0c, 'Q', 0 },
|
||||
{ 0x0d, 'W', 0 },
|
||||
{ 0x0e, 'E', 0 },
|
||||
{ 0x0f, 'R', 0 },
|
||||
{ 0x11, 'T', 0 },
|
||||
{ 0x10, 'Y', 0 },
|
||||
{ 0x20, 'U', 0 },
|
||||
{ 0x22, 'I', 0 },
|
||||
{ 0x1f, 'O', 0 },
|
||||
{ 0x23, 'P', 0 },
|
||||
{ 0x21, 0xdb, 0 }, /* [ */
|
||||
{ 0x1e, 0xdd, 0 }, /* ] */
|
||||
{ 0x2a, 0xdc, 0 }, /* backslash, bar */
|
||||
{ 0x75, VK_DELETE+0x100, 0 },
|
||||
{ 0x77, VK_END+0x100, VK_END },
|
||||
{ 0x79, VK_NEXT+0x100, 0 },
|
||||
{ 0x59, VK_NUMPAD7, VK_HOME },
|
||||
{ 0x5b, VK_NUMPAD8, VK_UP },
|
||||
{ 0x5c, VK_NUMPAD9, VK_PRIOR },
|
||||
{ 0x4e, VK_SUBTRACT, VK_SUBTRACT+0x100 },
|
||||
|
||||
// { 0x39, VK_CAPITAL, 0 }, // Handled specially!
|
||||
{ 0x00, 'A', 0 },
|
||||
{ 0x01, 'S', 0 },
|
||||
{ 0x02, 'D', 0 },
|
||||
{ 0x03, 'F', 0 },
|
||||
{ 0x05, 'G', 0 },
|
||||
{ 0x04, 'H', 0 },
|
||||
{ 0x26, 'J', 0 },
|
||||
{ 0x28, 'K', 0 },
|
||||
{ 0x25, 'L', 0 },
|
||||
{ 0x29, 0xba, 0 }, /* ; */
|
||||
{ 0x27, 0xde, 0 }, /* single quote */
|
||||
{ 0x24, VK_RETURN, 0 },
|
||||
{ 0x56, VK_NUMPAD4, VK_LEFT },
|
||||
{ 0x57, VK_NUMPAD5, VK_CLEAR },
|
||||
{ 0x58, VK_NUMPAD6, VK_RIGHT },
|
||||
{ 0x45, VK_ADD, 0 },
|
||||
|
||||
{ 0x38, VK_SHIFT, 0 },
|
||||
{ 0x06, 'Z', 0 },
|
||||
{ 0x07, 'X', 0 },
|
||||
{ 0x08, 'C', 0 },
|
||||
{ 0x09, 'V', 0 },
|
||||
{ 0x0b, 'B', 0 },
|
||||
{ 0x2d, 'N', 0 },
|
||||
{ 0x2e, 'M', 0 },
|
||||
{ 0x2b, 0xbc, 0 }, /* , */
|
||||
{ 0x2f, 0xbe, 0 }, /* . */
|
||||
{ 0x2c, 0xbf, 0 }, /* / */
|
||||
{ 0x3e, VK_UP+0x100, 0 },
|
||||
{ 0x53, VK_NUMPAD1, VK_END },
|
||||
{ 0x54, VK_NUMPAD2, VK_DOWN },
|
||||
{ 0x55, VK_NUMPAD3, VK_NEXT },
|
||||
|
||||
{ 0x36, VK_CONTROL, VK_CONTROL+0x100 },
|
||||
{ 0x3a, VK_SNAPSHOT+0x100, VK_MENU+0x100 },/* Opt=prntscrn or alt-r */
|
||||
|
||||
// OG ActiveGS map OA-CA to Win & AltKey
|
||||
#ifndef ACTIVEGS
|
||||
{ 0x37, VK_SCROLL, VK_MENU }, /* Command=scr_lock or alt-l */
|
||||
#else
|
||||
{ 0x7f, VK_CANCEL, 0 },
|
||||
{ 0x3A, VK_LWIN+0x100, VK_LWIN },
|
||||
{ 0x37, VK_MENU, 0 }, /* Command=alt-l */
|
||||
{ 0x37, VK_LMENU, 0 }, /* Command=alt-l */
|
||||
{ 0x7F, VK_SCROLL,0 }, /* RESET */
|
||||
{ 0x36, VK_LCONTROL, 0 }, // CTRL
|
||||
#endif
|
||||
|
||||
{ 0x31, ' ', 0 },
|
||||
{ 0x3b, VK_LEFT+0x100, 0 },
|
||||
{ 0x3d, VK_DOWN+0x100, 0 },
|
||||
{ 0x3c, VK_RIGHT+0x100, 0 },
|
||||
{ 0x52, VK_NUMPAD0, VK_INSERT },
|
||||
{ 0x41, VK_DECIMAL, VK_DECIMAL },
|
||||
{ 0x4c, VK_RETURN+0x100, 0 },
|
||||
{ -1, -1, -1 }
|
||||
};
|
||||
|
||||
extern int g_config_control_panel;
|
||||
|
||||
int
|
||||
win_update_mouse(int x, int y, int button_states, int buttons_valid)
|
||||
{
|
||||
int buttons_changed;
|
||||
|
||||
#ifdef ACTIVEGS
|
||||
if (g_config_control_panel) // OG ignore input events while in debugger
|
||||
return 0;
|
||||
|
||||
buttons_valid &= 1; // filter out middle & right button
|
||||
|
||||
#endif
|
||||
|
||||
buttons_changed = ((g_win_button_states & buttons_valid) !=
|
||||
button_states);
|
||||
g_win_button_states = (g_win_button_states & ~buttons_valid) |
|
||||
(button_states & buttons_valid);
|
||||
if(g_warp_pointer && (x == A2_WINDOW_WIDTH/2) &&
|
||||
(y == A2_WINDOW_HEIGHT/2) && (!buttons_changed) ) {
|
||||
/* tell adb routs to recenter but ignore this motion */
|
||||
update_mouse(x, y, 0, -1);
|
||||
return 0;
|
||||
}
|
||||
return update_mouse(x, y, button_states, buttons_valid & 7);
|
||||
}
|
||||
|
||||
|
||||
// OG Added asynchronous key & mouse handler
|
||||
#define ASYNCEVENT
|
||||
|
||||
#ifndef ASYNCEVENT
|
||||
#define WIN_EVENT_MOUSE win_event_mouse
|
||||
#define WIN_EVENT_KEY win_event_key
|
||||
#else
|
||||
extern void add_event_mouse(int umsg,WPARAM wParam, LPARAM lParam);
|
||||
extern void add_event_key(HWND hwnd, UINT raw_vk, BOOL down, int repeat, UINT flags);
|
||||
#define WIN_EVENT_MOUSE add_event_mouse
|
||||
#define WIN_EVENT_KEY add_event_key
|
||||
#endif
|
||||
|
||||
struct win32_mouse
|
||||
{
|
||||
int umsg;
|
||||
int wparam;
|
||||
int lparam;
|
||||
};
|
||||
|
||||
struct win32_key
|
||||
{
|
||||
UINT raw_vk;
|
||||
BOOL down;
|
||||
int repeat;
|
||||
UINT flags;
|
||||
};
|
||||
|
||||
int last_win32_mouse=0;
|
||||
int next_win32_mouse=0;
|
||||
|
||||
int nb_win32_key=0;
|
||||
|
||||
#define MAX_EVENT 1024
|
||||
struct win32_mouse win32_mouses[MAX_EVENT];
|
||||
struct win32_key win32_keys[MAX_EVENT];
|
||||
|
||||
extern int g_config_control_panel; // OG Expose g_config_control_panel
|
||||
|
||||
// OG Push Mouse Event
|
||||
|
||||
void add_event_mouse(int umsg,WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
|
||||
#ifdef ACTIVEGS
|
||||
if (g_config_control_panel) // OG ignore input events while in debugger
|
||||
return ;
|
||||
#endif
|
||||
|
||||
win32_mouses[next_win32_mouse].umsg = umsg;
|
||||
win32_mouses[next_win32_mouse].wparam = wParam;
|
||||
win32_mouses[next_win32_mouse].lparam = lParam;
|
||||
next_win32_mouse = (next_win32_mouse+1)%MAX_EVENT;
|
||||
|
||||
// ASSERT (next_win32_mouse==last_win32_mouse)
|
||||
}
|
||||
|
||||
// OG Push Key Event
|
||||
|
||||
void
|
||||
add_event_key(HWND hwnd, UINT raw_vk, BOOL down, int repeat, UINT flags)
|
||||
{
|
||||
|
||||
#ifdef ACTIVEGS
|
||||
if (g_config_control_panel) // OG ignore input events while in debugger
|
||||
return ;
|
||||
#endif
|
||||
|
||||
if (nb_win32_key>=MAX_EVENT)
|
||||
return ;
|
||||
|
||||
win32_keys[nb_win32_key].raw_vk = raw_vk;
|
||||
win32_keys[nb_win32_key].down = down;
|
||||
win32_keys[nb_win32_key].repeat = repeat;
|
||||
win32_keys[nb_win32_key].flags = flags;
|
||||
|
||||
nb_win32_key++;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
win_event_mouse(int umsg,WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
POINT pt;
|
||||
word32 flags;
|
||||
int buttons;
|
||||
int x, y;
|
||||
int motion;
|
||||
|
||||
x = LOWORD(lParam);
|
||||
y = HIWORD(lParam);
|
||||
|
||||
|
||||
// OG Reformat the mouse coordinates
|
||||
float ratiox = 0.0, ratioy = 0.0;
|
||||
if (!g_warp_pointer && x_calc_ratio(ratiox,ratioy))
|
||||
{
|
||||
x = (int)((float)(x)/ratiox);
|
||||
y = (int)((float)(y)/ratioy);
|
||||
}
|
||||
|
||||
flags = wParam;
|
||||
x -= BASE_MARGIN_LEFT;
|
||||
y -= BASE_MARGIN_TOP;
|
||||
|
||||
buttons = (flags & 1) +
|
||||
(((flags >> 1) & 1) << 2) +
|
||||
(((flags >> 4) & 1) << 1);
|
||||
#if 0
|
||||
if (umsg!=WM_MOUSEMOVE)
|
||||
printf("Mouse at %d, %d fl: %08x, but: %d\n", x, y, flags, buttons);
|
||||
#endif
|
||||
motion = win_update_mouse(x, y, buttons, 7);
|
||||
|
||||
if(motion && g_warp_pointer) {
|
||||
/* move mouse to center of screen */
|
||||
pt.x = BASE_MARGIN_LEFT + A2_WINDOW_WIDTH/2;
|
||||
pt.y = BASE_MARGIN_TOP + A2_WINDOW_HEIGHT/2;
|
||||
ClientToScreen(g_hwnd_main, &pt);
|
||||
SetCursorPos(pt.x, pt.y);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
win_event_key(HWND hwnd, UINT raw_vk, BOOL down, int repeat, UINT flags)
|
||||
{
|
||||
word32 vk;
|
||||
int a2code;
|
||||
int is_up;
|
||||
int capslock_down;
|
||||
int i;
|
||||
|
||||
if((flags & 0x4000) && down) {
|
||||
/* auto-repeating, just ignore it */
|
||||
return;
|
||||
}
|
||||
|
||||
vk = raw_vk + (flags & 0x100);
|
||||
#if 0
|
||||
printf("Key event, vk=%04x, down:%d, repeat: %d, flags: %08x\n",
|
||||
vk, down, repeat, flags);
|
||||
#endif
|
||||
|
||||
/* remap a few keys here.. sigh */
|
||||
if((vk & 0xff) == VK_APPS) {
|
||||
/* remap to command */
|
||||
vk = VK_MENU;
|
||||
}
|
||||
|
||||
if((vk & 0xff) == VK_CAPITAL) {
|
||||
// Windows gives us up-and-down events of the actual key
|
||||
// Use GetKeyState to get the true toggle state, and pass
|
||||
// that on to the adb interface
|
||||
capslock_down = GetKeyState(VK_CAPITAL) & 0x01;
|
||||
if(capslock_down != g_win_capslock_down) {
|
||||
g_win_capslock_down = capslock_down;
|
||||
adb_physical_key_update(0x39, !capslock_down);
|
||||
}
|
||||
|
||||
return; // Do no more processing!
|
||||
}
|
||||
|
||||
/* search a2key_to_wsym to find wsym in col 1 or 2 */
|
||||
i = 0;
|
||||
is_up = !down;
|
||||
for(i = g_num_a2_keycodes-1; i >= 0; i--) {
|
||||
a2code = g_a2_key_to_wsym[i][0];
|
||||
if((vk == g_a2_key_to_wsym[i][1]) ||
|
||||
(vk == g_a2_key_to_wsym[i][2])) {
|
||||
vid_printf("Found vk:%04x = %02x\n", vk, a2code);
|
||||
adb_physical_key_update(a2code, is_up);
|
||||
return;
|
||||
}
|
||||
}
|
||||
printf("VK: %04x unknown\n", vk);
|
||||
}
|
||||
|
||||
void
|
||||
win_event_quit(HWND hwnd)
|
||||
{
|
||||
quitEmulator();
|
||||
}
|
||||
|
||||
extern int g_needfullrefreshfornextframe ;
|
||||
|
||||
void
|
||||
win_event_redraw()
|
||||
{
|
||||
// outputInfo("win_event_redraw()\n");
|
||||
g_needfullrefreshfornextframe = 1;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK
|
||||
win_event_handler(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
int i;
|
||||
int numDraggedFiles;
|
||||
int szFilename;
|
||||
LPTSTR lpszFile;
|
||||
|
||||
switch(umsg) {
|
||||
case WM_MOUSEMOVE:
|
||||
case WM_LBUTTONDOWN:
|
||||
case WM_LBUTTONUP:
|
||||
case WM_MBUTTONDOWN:
|
||||
case WM_MBUTTONUP:
|
||||
case WM_RBUTTONDOWN:
|
||||
case WM_RBUTTONUP:
|
||||
case WM_LBUTTONDBLCLK: // OG Added dblclk as WM_LBUTTONDOWN
|
||||
WIN_EVENT_MOUSE(umsg,wParam, lParam);
|
||||
return 0;
|
||||
case WM_PAINT:
|
||||
win_event_redraw();
|
||||
break;
|
||||
case WM_DROPFILES:
|
||||
numDraggedFiles = DragQueryFile((HDROP)wParam, 0xFFFFFFFF, NULL, 0);
|
||||
for (i = 0; i < numDraggedFiles; i++) {
|
||||
szFilename = DragQueryFile((HDROP)wParam, i, NULL, 0);
|
||||
lpszFile = malloc(szFilename + 1);
|
||||
szFilename = DragQueryFile((HDROP)wParam, i, lpszFile, szFilename + 1);
|
||||
cfg_inspect_maybe_insert_file(lpszFile);
|
||||
free(lpszFile);
|
||||
}
|
||||
DragFinish((HDROP)wParam);
|
||||
break;
|
||||
}
|
||||
switch(umsg) {
|
||||
HANDLE_MSG(hwnd, WM_KEYUP, WIN_EVENT_KEY);
|
||||
HANDLE_MSG(hwnd, WM_KEYDOWN, WIN_EVENT_KEY);
|
||||
HANDLE_MSG(hwnd, WM_SYSKEYUP, WIN_EVENT_KEY);
|
||||
HANDLE_MSG(hwnd, WM_SYSKEYDOWN, WIN_EVENT_KEY);
|
||||
HANDLE_MSG(hwnd, WM_DESTROY, win_event_quit);
|
||||
}
|
||||
|
||||
#if 0
|
||||
switch(umsg) {
|
||||
case WM_NCACTIVATE:
|
||||
case WM_NCHITTEST:
|
||||
case WM_NCMOUSEMOVE:
|
||||
case WM_SETCURSOR:
|
||||
case WM_LBUTTONDOWN:
|
||||
case WM_LBUTTONUP:
|
||||
case WM_RBUTTONDOWN:
|
||||
case WM_CONTEXTMENU:
|
||||
case WM_RBUTTONUP:
|
||||
case WM_MBUTTONDOWN:
|
||||
case WM_MBUTTONUP:
|
||||
case WM_PAINT:
|
||||
|
||||
break;
|
||||
default:
|
||||
printf("Got umsg2: %d\n", umsg);
|
||||
}
|
||||
#endif
|
||||
|
||||
return DefWindowProc(hwnd, umsg, wParam, lParam);
|
||||
}
|
||||
|
||||
// OG Added Generic gsportinit/gsportshut functions
|
||||
|
||||
void gsportinit(HWND _hwnd)
|
||||
{
|
||||
g_hwnd_main = _hwnd;
|
||||
|
||||
HDC localdc = GetDC(g_hwnd_main);
|
||||
SetTextColor(localdc, 0);
|
||||
SetBkColor(localdc, 0xFFFFFF);
|
||||
|
||||
g_main_cdc = CreateCompatibleDC(localdc);
|
||||
ReleaseDC(g_hwnd_main,localdc);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void gsportshut()
|
||||
{
|
||||
if (g_main_cdc)
|
||||
{
|
||||
DeleteDC(g_main_cdc);
|
||||
g_main_cdc = NULL;
|
||||
}
|
||||
g_hwnd_main = NULL;
|
||||
}
|
||||
|
||||
extern void x_check_input_events();
|
||||
|
||||
void
|
||||
check_input_events()
|
||||
{
|
||||
|
||||
x_check_input_events();
|
||||
|
||||
// OG Unstack Mouse Events
|
||||
int i=last_win32_mouse;
|
||||
while(i!=next_win32_mouse)
|
||||
{
|
||||
win_event_mouse(win32_mouses[i].umsg,win32_mouses[i].wparam,win32_mouses[i].lparam);
|
||||
int lb = win32_mouses[i].wparam&1;
|
||||
i = (i+1)%MAX_EVENT;
|
||||
if (lb != (win32_mouses[i].wparam&1))
|
||||
break; // don't send up & down event at the same time
|
||||
}
|
||||
last_win32_mouse=i;
|
||||
|
||||
for(i=0;i<nb_win32_key;i++)
|
||||
win_event_key(NULL,win32_keys[i].raw_vk ,win32_keys[i].down,win32_keys[i].repeat , win32_keys[i].flags );
|
||||
nb_win32_key=0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
x_update_color(int col_num, int red, int green, int blue, word32 rgb)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
x_update_physical_colormap()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
show_xcolor_array()
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < 256; i++) {
|
||||
printf("%02x: %08x\n", i, g_palette_8to1624[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// OG Add function to clear all get_images loaded (dev dependent)
|
||||
void x_release_kimage(Kimage *kimage_ptr)
|
||||
{
|
||||
if ((int)kimage_ptr->dev_handle != -1)
|
||||
{
|
||||
DeleteObject(kimage_ptr->dev_handle);
|
||||
kimage_ptr->dev_handle = (void*)-1;
|
||||
}
|
||||
else
|
||||
if (kimage_ptr->data_ptr)
|
||||
{
|
||||
free(kimage_ptr->data_ptr);
|
||||
kimage_ptr->data_ptr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// OG Free video global memory
|
||||
void
|
||||
xdriver_end() // Should be renamed to dev_video_shut() ???
|
||||
{
|
||||
|
||||
x_release_kimage(&g_mainwin_kimage);
|
||||
|
||||
GlobalFree(g_bmapinfo_ptr); // allocated in dev_video_init
|
||||
g_bmapinfo_ptr = 0;
|
||||
|
||||
printf("win32 video driver end\n");
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
x_get_kimage(Kimage *kimage_ptr)
|
||||
{
|
||||
byte *ptr;
|
||||
int width;
|
||||
int height;
|
||||
int depth, mdepth;
|
||||
int size;
|
||||
|
||||
width = kimage_ptr->width_req;
|
||||
height = kimage_ptr->height;
|
||||
depth = kimage_ptr->depth;
|
||||
mdepth = kimage_ptr->mdepth;
|
||||
|
||||
size = 0;
|
||||
if(depth == g_screen_depth) {
|
||||
/* Use g_bmapinfo_ptr, adjusting width, height */
|
||||
g_bmaphdr_ptr->biWidth = width;
|
||||
g_bmaphdr_ptr->biHeight = -height;
|
||||
|
||||
HDC localdc = GetDC(g_hwnd_main); // OG Use on the fly DC
|
||||
kimage_ptr->dev_handle = CreateDIBSection(localdc,
|
||||
g_bmapinfo_ptr, DIB_RGB_COLORS,
|
||||
(VOID **)&(kimage_ptr->data_ptr), NULL, 0);
|
||||
ReleaseDC(g_hwnd_main,localdc);
|
||||
} else {
|
||||
/* allocate buffers for video.c to draw into */
|
||||
|
||||
size = (width*height*mdepth) >> 3;
|
||||
ptr = (byte *)malloc(size);
|
||||
|
||||
if(ptr == 0) {
|
||||
printf("malloc for data failed, mdepth: %d\n", mdepth);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
kimage_ptr->data_ptr = ptr;
|
||||
|
||||
kimage_ptr->dev_handle = (void *)-1;
|
||||
|
||||
}
|
||||
printf("kim: %p, dev:%p data: %p, size: %08x\n", kimage_ptr,
|
||||
kimage_ptr->dev_handle, kimage_ptr->data_ptr, size);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
dev_video_init()
|
||||
{
|
||||
int extra_size;
|
||||
int lores_col;
|
||||
int i;
|
||||
|
||||
printf("Preparing graphics system\n");
|
||||
|
||||
// OG fix g_num_a2_keycodes identification
|
||||
g_num_a2_keycodes = sizeof(g_a2_key_to_wsym)/3/sizeof(int);
|
||||
g_num_a2_keycodes--; // last entry=-1
|
||||
|
||||
/*
|
||||
g_num_a2_keycodes = 0;
|
||||
for(i = 0; i < maxcode; i++) {
|
||||
int a2code = g_a2_key_to_wsym[i][0];
|
||||
if(a2code < 0) {
|
||||
g_num_a2_keycodes = i;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// OG Forcing 16bits depth for WiNCE
|
||||
#ifndef UNDER_CE
|
||||
g_screen_depth = 24;
|
||||
g_screen_mdepth = 32;
|
||||
#else
|
||||
g_screen_depth = 16;
|
||||
g_screen_mdepth = 16;
|
||||
|
||||
|
||||
extern word32 g_red_mask ;
|
||||
extern word32 g_green_mask ;
|
||||
extern word32 g_blue_mask ;
|
||||
extern int g_red_left_shift;
|
||||
extern int g_green_left_shift;
|
||||
extern int g_blue_left_shift ;
|
||||
extern int g_red_right_shift ;
|
||||
extern int g_green_right_shift ;
|
||||
extern int g_blue_right_shift ;
|
||||
|
||||
|
||||
g_red_mask = 0xff;
|
||||
g_green_mask = 0xff;
|
||||
g_blue_mask = 0xff;
|
||||
g_red_left_shift = 10;
|
||||
g_green_left_shift = 5;
|
||||
g_blue_left_shift = 0;
|
||||
g_red_right_shift = 3;
|
||||
g_green_right_shift = 3;
|
||||
g_blue_right_shift = 3;
|
||||
#endif
|
||||
|
||||
|
||||
extra_size = sizeof(RGBQUAD);
|
||||
if(g_screen_depth == 8) {
|
||||
extra_size = 256 * sizeof(RGBQUAD);
|
||||
}
|
||||
g_bmapinfo_ptr = (BITMAPINFO *)GlobalAlloc(GPTR,
|
||||
sizeof(BITMAPINFOHEADER) + extra_size);
|
||||
|
||||
g_bmaphdr_ptr = (BITMAPINFOHEADER *)g_bmapinfo_ptr;
|
||||
g_bmaphdr_ptr->biSize = sizeof(BITMAPINFOHEADER);
|
||||
g_bmaphdr_ptr->biWidth = A2_WINDOW_WIDTH;
|
||||
g_bmaphdr_ptr->biHeight = -A2_WINDOW_HEIGHT;
|
||||
g_bmaphdr_ptr->biPlanes = 1;
|
||||
g_bmaphdr_ptr->biBitCount = g_screen_mdepth;
|
||||
g_bmaphdr_ptr->biCompression = BI_RGB;
|
||||
g_bmaphdr_ptr->biClrUsed = 0;
|
||||
|
||||
video_get_kimages();
|
||||
|
||||
if(g_screen_depth != 8) {
|
||||
// Allocate g_mainwin_kimage
|
||||
video_get_kimage(&g_mainwin_kimage, 0, g_screen_depth,
|
||||
g_screen_mdepth);
|
||||
}
|
||||
|
||||
for(i = 0; i < 256; i++) {
|
||||
lores_col = g_lores_colors[i & 0xf];
|
||||
video_update_color_raw(i, lores_col);
|
||||
g_a2palette_8to1624[i] = g_palette_8to1624[i];
|
||||
}
|
||||
|
||||
g_installed_full_superhires_colormap = 1;
|
||||
|
||||
#ifndef UNDER_CE
|
||||
ShowWindow(g_hwnd_main, SW_SHOWDEFAULT);
|
||||
#else
|
||||
ShowWindow(g_hwnd_main, SW_SHOW);
|
||||
#endif
|
||||
UpdateWindow(g_hwnd_main);
|
||||
|
||||
printf("Done with dev_video_init\n");
|
||||
fflush(stdout);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void
|
||||
x_push_kimage(Kimage *kimage_ptr, int destx, int desty, int srcx, int srcy,
|
||||
int width, int height)
|
||||
{
|
||||
void *bitm_old;
|
||||
POINT point;
|
||||
|
||||
point.x = 0;
|
||||
point.y = 0;
|
||||
ClientToScreen(g_hwnd_main, &point);
|
||||
|
||||
HDC localdc = GetDC(g_hwnd_main);
|
||||
HDC localcdc = g_main_cdc; //CreateCompatibleDC(g_main_dc);
|
||||
|
||||
bitm_old = SelectObject(localcdc, kimage_ptr->dev_handle);
|
||||
|
||||
float ratiox = 0.0, ratioy = 0.0;
|
||||
int isStretched = x_calc_ratio(ratiox,ratioy);
|
||||
if (!isStretched)
|
||||
BitBlt(localdc, destx, desty, width, height, localcdc, srcx, srcy, SRCCOPY);
|
||||
else
|
||||
{
|
||||
float xdest = (destx)*ratiox;
|
||||
float ydest = (desty)*ratioy;
|
||||
float wdest = (width)*ratiox;
|
||||
float hdest = (height)*ratioy;
|
||||
|
||||
BOOL err=StretchBlt(localdc,(int)xdest,(int)ydest,(int)wdest,(int)hdest,localcdc, srcx, srcy,width,height, SRCCOPY);
|
||||
}
|
||||
|
||||
SelectObject(localcdc, bitm_old);
|
||||
ReleaseDC(g_hwnd_main,localdc);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
x_push_done()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
x_auto_repeat_on(int must)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
x_auto_repeat_off(int must)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
x_hide_pointer(int do_hide)
|
||||
{
|
||||
if(do_hide) {
|
||||
ShowCursor(0);
|
||||
} else {
|
||||
ShowCursor(1);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
x_full_screen(int do_full)
|
||||
{
|
||||
return;
|
||||
}
|
208
src/windriver.c
208
src/windriver.c
@ -38,22 +38,26 @@
|
||||
|
||||
extern int Verbose;
|
||||
|
||||
extern int g_pause; // OG Added Pause
|
||||
|
||||
extern int g_warp_pointer;
|
||||
extern int g_screen_depth;
|
||||
extern int g_force_depth;
|
||||
int g_screen_mdepth = 0;
|
||||
|
||||
extern int g_quit_sim_now;
|
||||
|
||||
// OG replaced g_quit_sim_now by quitEmulator
|
||||
// extern int g_quit_sim_now;
|
||||
extern void quitEmulator();
|
||||
|
||||
int g_use_shmem = 1;
|
||||
int g_has_focus = 0;
|
||||
int g_auto_repeat_on = -1;
|
||||
|
||||
extern Kimage g_mainwin_kimage;
|
||||
|
||||
HDC g_main_dc;
|
||||
//HDC g_main_dc; // OG dc cannot be a global
|
||||
HDC g_main_cdc;
|
||||
int g_main_height = 0;
|
||||
//int g_main_height = 0;
|
||||
|
||||
int g_win_capslock_down = 0;
|
||||
|
||||
@ -87,6 +91,8 @@ extern char *g_status_ptrs[MAX_STATUS_LINES];
|
||||
|
||||
int g_win_button_states = 0;
|
||||
|
||||
// OG Added calc_ratio
|
||||
int x_calc_ratio(float& ratiox,float& ratioy);
|
||||
|
||||
/* this table is used to search for the Windows VK_* in col 1 or 2 */
|
||||
/* flags bit 8 is or'ed into the VK, so we can distinguish keypad keys */
|
||||
@ -94,7 +100,7 @@ int g_win_button_states = 0;
|
||||
int g_a2_key_to_wsym[][3] = {
|
||||
{ 0x35, VK_ESCAPE, 0 },
|
||||
{ 0x7a, VK_F1, 0 },
|
||||
{ 0x7b, VK_F2, 0 },
|
||||
{ 0x78, VK_F2, 0 }, // OG Was 7B but F2 is defined has 0x78 in a2_key_to_ascii
|
||||
{ 0x63, VK_F3, 0 },
|
||||
{ 0x76, VK_F4, 0 },
|
||||
{ 0x60, VK_F5, 0 },
|
||||
@ -190,7 +196,19 @@ int g_a2_key_to_wsym[][3] = {
|
||||
|
||||
{ 0x36, VK_CONTROL, VK_CONTROL+0x100 },
|
||||
{ 0x3a, VK_SNAPSHOT+0x100, VK_MENU+0x100 },/* Opt=prntscrn or alt-r */
|
||||
|
||||
// OG ActiveGS map OA-CA to Win & AltKey
|
||||
#ifndef ACTIVEGS
|
||||
{ 0x37, VK_SCROLL, VK_MENU }, /* Command=scr_lock or alt-l */
|
||||
#else
|
||||
{ 0x7f, VK_CANCEL, 0 },
|
||||
{ 0x3A, VK_LWIN+0x100, VK_LWIN },
|
||||
{ 0x37, VK_MENU, 0 }, /* Command=alt-l */
|
||||
{ 0x37, VK_LMENU, 0 }, /* Command=alt-l */
|
||||
{ 0x7F, VK_SCROLL,0 }, /* RESET */
|
||||
{ 0x36, VK_LCONTROL, 0 }, // CTRL
|
||||
#endif
|
||||
|
||||
{ 0x31, ' ', 0 },
|
||||
{ 0x3b, VK_LEFT+0x100, 0 },
|
||||
{ 0x3d, VK_DOWN+0x100, 0 },
|
||||
@ -201,39 +219,21 @@ int g_a2_key_to_wsym[][3] = {
|
||||
{ -1, -1, -1 }
|
||||
};
|
||||
|
||||
int
|
||||
win_nonblock_read_stdin(int fd, char *bufptr, int len)
|
||||
{
|
||||
HANDLE oshandle;
|
||||
DWORD dwret;
|
||||
int ret;
|
||||
|
||||
errno = EAGAIN;
|
||||
oshandle = (HANDLE)_get_osfhandle(fd); // get stdin handle
|
||||
dwret = WaitForSingleObject(oshandle, 1); // wait 1msec for data
|
||||
ret = -1;
|
||||
if(dwret == WAIT_OBJECT_0) {
|
||||
ret = read(fd, bufptr, len);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
x_dialog_create_gsport_conf(const char *str)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
x_show_alert(int is_fatal, const char *str)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
extern int g_config_control_panel;
|
||||
|
||||
int
|
||||
win_update_mouse(int x, int y, int button_states, int buttons_valid)
|
||||
{
|
||||
int buttons_changed;
|
||||
|
||||
#ifdef ACTIVEGS
|
||||
if (g_config_control_panel) // OG ignore input events while in debugger
|
||||
return 0;
|
||||
|
||||
buttons_valid &= 1; // filter out middle & right button
|
||||
|
||||
#endif
|
||||
|
||||
buttons_changed = ((g_win_button_states & buttons_valid) !=
|
||||
button_states);
|
||||
g_win_button_states = (g_win_button_states & ~buttons_valid) |
|
||||
@ -247,8 +247,90 @@ win_update_mouse(int x, int y, int button_states, int buttons_valid)
|
||||
return update_mouse(x, y, button_states, buttons_valid & 7);
|
||||
}
|
||||
|
||||
|
||||
// OG Added asynchronous key & mouse handler
|
||||
#define ASYNCEVENT
|
||||
|
||||
#ifndef ASYNCEVENT
|
||||
#define WIN_EVENT_MOUSE win_event_mouse
|
||||
#define WIN_EVENT_KEY win_event_key
|
||||
#else
|
||||
extern void add_event_mouse(int umsg,WPARAM wParam, LPARAM lParam);
|
||||
extern void add_event_key(HWND hwnd, UINT raw_vk, BOOL down, int repeat, UINT flags);
|
||||
#define WIN_EVENT_MOUSE add_event_mouse
|
||||
#define WIN_EVENT_KEY add_event_key
|
||||
#endif
|
||||
|
||||
struct win32_mouse
|
||||
{
|
||||
int umsg;
|
||||
int wparam;
|
||||
int lparam;
|
||||
};
|
||||
|
||||
struct win32_key
|
||||
{
|
||||
UINT raw_vk;
|
||||
BOOL down;
|
||||
int repeat;
|
||||
UINT flags;
|
||||
};
|
||||
|
||||
int last_win32_mouse=0;
|
||||
int next_win32_mouse=0;
|
||||
|
||||
int nb_win32_key=0;
|
||||
|
||||
#define MAX_EVENT 1024
|
||||
struct win32_mouse win32_mouses[MAX_EVENT];
|
||||
struct win32_key win32_keys[MAX_EVENT];
|
||||
|
||||
extern int g_config_control_panel; // OG Expose g_config_control_panel
|
||||
|
||||
// OG Push Mouse Event
|
||||
|
||||
void add_event_mouse(int umsg,WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
|
||||
#ifdef ACTIVEGS
|
||||
if (g_config_control_panel) // OG ignore input events while in debugger
|
||||
return ;
|
||||
#endif
|
||||
|
||||
win32_mouses[next_win32_mouse].umsg = umsg;
|
||||
win32_mouses[next_win32_mouse].wparam = wParam;
|
||||
win32_mouses[next_win32_mouse].lparam = lParam;
|
||||
next_win32_mouse = (next_win32_mouse+1)%MAX_EVENT;
|
||||
|
||||
// ASSERT (next_win32_mouse==last_win32_mouse)
|
||||
}
|
||||
|
||||
// OG Push Key Event
|
||||
|
||||
void
|
||||
add_event_key(HWND hwnd, UINT raw_vk, BOOL down, int repeat, UINT flags)
|
||||
{
|
||||
|
||||
#ifdef ACTIVEGS
|
||||
if (g_config_control_panel) // OG ignore input events while in debugger
|
||||
return ;
|
||||
#endif
|
||||
|
||||
if (nb_win32_key>=MAX_EVENT)
|
||||
return ;
|
||||
|
||||
win32_keys[nb_win32_key].raw_vk = raw_vk;
|
||||
win32_keys[nb_win32_key].down = down;
|
||||
win32_keys[nb_win32_key].repeat = repeat;
|
||||
win32_keys[nb_win32_key].flags = flags;
|
||||
|
||||
nb_win32_key++;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
win_event_mouse(WPARAM wParam, LPARAM lParam)
|
||||
win_event_mouse(int umsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
POINT pt;
|
||||
word32 flags;
|
||||
@ -256,14 +338,27 @@ win_event_mouse(WPARAM wParam, LPARAM lParam)
|
||||
int x, y;
|
||||
int motion;
|
||||
|
||||
x = LOWORD(lParam);
|
||||
y = HIWORD(lParam);
|
||||
|
||||
|
||||
// OG Reformat the mouse coordinates
|
||||
float ratiox,ratioy;
|
||||
if (!g_warp_pointer && x_calc_ratio(ratiox,ratioy))
|
||||
{
|
||||
x = (int)((float)(x)/ratiox);
|
||||
y = (int)((float)(y)/ratioy);
|
||||
}
|
||||
|
||||
flags = wParam;
|
||||
x = LOWORD(lParam) - BASE_MARGIN_LEFT;
|
||||
y = HIWORD(lParam) - BASE_MARGIN_TOP;
|
||||
x -= BASE_MARGIN_LEFT;
|
||||
y -= BASE_MARGIN_TOP;
|
||||
|
||||
buttons = (flags & 1) +
|
||||
(((flags >> 1) & 1) << 2) +
|
||||
(((flags >> 4) & 1) << 1);
|
||||
#if 0
|
||||
if (umsg!=WM_MOUSEMOVE)
|
||||
printf("Mouse at %d, %d fl: %08x, but: %d\n", x, y, flags, buttons);
|
||||
#endif
|
||||
motion = win_update_mouse(x, y, buttons, 7);
|
||||
@ -334,18 +429,16 @@ win_event_key(HWND hwnd, UINT raw_vk, BOOL down, int repeat, UINT flags)
|
||||
void
|
||||
win_event_quit(HWND hwnd)
|
||||
{
|
||||
g_quit_sim_now = 1;
|
||||
my_exit(0);
|
||||
quitEmulator();
|
||||
}
|
||||
|
||||
extern int g_needfullrefreshfornextframe ;
|
||||
|
||||
void
|
||||
win_event_redraw()
|
||||
{
|
||||
g_full_refresh_needed = -1;
|
||||
g_a2_screen_buffer_changed = -1;
|
||||
g_status_refresh_needed = 1;
|
||||
g_border_sides_refresh_needed = 1;
|
||||
g_border_special_refresh_needed = 1;
|
||||
// outputInfo("win_event_redraw()\n");
|
||||
g_needfullrefreshfornextframe = 1;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK
|
||||
@ -364,7 +457,7 @@ LPTSTR lpszFile;
|
||||
case WM_MBUTTONUP:
|
||||
case WM_RBUTTONDOWN:
|
||||
case WM_RBUTTONUP:
|
||||
win_event_mouse(wParam, lParam);
|
||||
win_event_mouse(umsg, wParam, lParam);
|
||||
return 0;
|
||||
case WM_PAINT:
|
||||
win_event_redraw();
|
||||
@ -510,10 +603,33 @@ show_xcolor_array()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
xdriver_end()
|
||||
// OG Add function to clear all get_images loaded (dev dependent)
|
||||
void x_release_kimage(Kimage *kimage_ptr)
|
||||
{
|
||||
printf("xdriver_end\n");
|
||||
if ((int)kimage_ptr->dev_handle != -1)
|
||||
{
|
||||
DeleteObject(kimage_ptr->dev_handle);
|
||||
kimage_ptr->dev_handle = (void*)-1;
|
||||
}
|
||||
else
|
||||
if (kimage_ptr->data_ptr)
|
||||
{
|
||||
free(kimage_ptr->data_ptr);
|
||||
kimage_ptr->data_ptr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// OG Free video global memory
|
||||
void
|
||||
xdriver_end() // Should be renamed to dev_video_shut() ???
|
||||
{
|
||||
|
||||
x_release_kimage(&g_mainwin_kimage);
|
||||
|
||||
GlobalFree(g_bmapinfo_ptr); // allocated in dev_video_init
|
||||
g_bmapinfo_ptr = 0;
|
||||
|
||||
printf("win32 video driver end\n");
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user