static uae_u8 *sector_buffer_info_1, *sector_buffer_info_2;
static int unitnum = -1;
+static int cdromok = 0;
+
static uae_u8 frombcd (uae_u8 v)
{
static uae_thread_id akiko_tid;
+static void akiko_cdrom_free (void)
+{
+ if (unitnum >= 0)
+ sys_cddev_close ();
+ unitnum = -1;
+ free (sector_buffer_1);
+ free (sector_buffer_2);
+ free (sector_buffer_info_1);
+ free (sector_buffer_info_2);
+ sector_buffer_1 = 0;
+ sector_buffer_2 = 0;
+ sector_buffer_info_1 = 0;
+ sector_buffer_info_2 = 0;
+ cdromok = 0;
+}
+
void akiko_reset (void)
{
cdaudiostop ();
Sleep (10);
akiko_thread_running = 0;
}
+ akiko_cdrom_free ();
}
extern uae_u32 extendedkickmemory;
write_log ("couldn't patch extended rom\n");
}
-static int cdromok = 0;
-
void akiko_free (void)
{
akiko_reset ();
- if (unitnum >= 0)
- sys_cddev_close ();
- unitnum = -1;
- free (sector_buffer_1);
- free (sector_buffer_2);
- free (sector_buffer_info_1);
- free (sector_buffer_info_2);
- sector_buffer_1 = 0;
- sector_buffer_2 = 0;
- sector_buffer_info_1 = 0;
- sector_buffer_info_2 = 0;
- cdromok = 0;
+ akiko_cdrom_free ();
}
int akiko_init (void)
int v = i == 0 ? p->jport0 : p->jport1;
char tmp1[100], tmp2[50];
if (v < JSEM_JOYS)
- sprintf (tmp2, "kbd%d", v);
+ sprintf (tmp2, "kbd%d", v + 1);
else if (v < JSEM_MICE)
- sprintf (tmp2, "joy%d", v - JSEM_JOYS);
+ sprintf (tmp2, "joy%d", v - JSEM_JOYS + 1);
else
- sprintf (tmp2, "mouse%d", v - JSEM_MICE);
+ sprintf (tmp2, "mouse%d", v - JSEM_MICE + 1);
sprintf (tmp1, "joyport%d=%s\n", i, tmp2);
cfgfile_write (f, tmp1);
}
if (strcmp (option, "joyport0") == 0 || strcmp (option, "joyport1") == 0) {
int port = strcmp (option, "joyport0") == 0 ? 0 : 1;
int start = -1;
- int kbdl = 0;
char *pp = 0;
if (strncmp (value, "kbd", 3) == 0) {
start = JSEM_KBDLAYOUT;
pp = value + 3;
- kbdl = 1;
} else if (strncmp (value, "joy", 3) == 0) {
start = JSEM_JOYS;
pp = value + 3;
pp = value + 5;
}
if (pp) {
- start += atol (pp);
- if (kbdl && start > 0)
- start--;
- if (port)
- p->jport1 = start;
- else
- p->jport0 = start;
+ int v = atol (pp);
+ if (start >= 0 && v > 0) {
+ v--;
+ start += v;
+ if (port)
+ p->jport1 = start;
+ else
+ p->jport0 = start;
+ }
}
return 1;
}
p->optcount[5] = 0;
}
p->gfx_framerate = 1;
- p->gfx_width_win = p->gfx_width_fs = 800;
- p->gfx_height_win = p->gfx_height_fs = 600;
+ p->gfx_width_fs = 800;
+ p->gfx_height_fs = 600;
+ p->gfx_width_win = 720;
+ p->gfx_height_win = 568;
p->gfx_lores = 0;
p->gfx_linedbl = 1;
p->gfx_afullscreen = 0;
{
int roms[4];
- roms[0] = 23;
- roms[1] = 24;
+ roms[0] = 24;
+ roms[1] = 23;
roms[2] = -1;
p->chipset_mask = 0;
p->bogomem_size = 0;
#include "inputdevice.h"
#include "zfile.h"
#include "ar.h"
+#include "parallel.h"
#ifdef CD32
#include "akiko.h"
#endif
volatile frame_time_t vsynctime, vsyncmintime;
-int ievent_alive = 0;
#ifdef JIT
extern uae_u8* compiled_code;
#endif
init_hardware_frame ();
- if (ievent_alive > 0)
- ievent_alive--;
if (timehack_alive > 0)
timehack_alive--;
inputdevice_vsync ();
vpos = 0;
- if (needmousehack ()) {
-#if 0
- mousehack_set (mousehack_follow);
-#else
- mousehack_set (mousehack_dontcare);
-#endif
- } else {
- mousehack_set (mousehack_normal);
- }
- ievent_alive = 0;
+ inputdevice_reset ();
timehack_alive = 0;
curr_sprite_entries = 0;
};
#undef DEFEVENT
-enum mousestate { mousehack_unknown, mousehack_normal, mousehack_dontcare, mousehack_follow };
-
extern void handle_cd32_joystick_cia (uae_u8, uae_u8);
extern uae_u8 handle_parport_joystick (int port, uae_u8 pra, uae_u8 dra);
extern uae_u8 handle_joystick_buttons (uae_u8);
extern int getbuttonstate (int joy, int button);
extern int getjoystate (int joy);
+enum mousestate { mousehack_unknown, mousehack_normal, mousehack_dontcare, mousehack_follow };
+
extern void mousehack_set (enum mousestate);
extern int mousehack_get (void);
extern uae_u32 mousehack_helper (void);
extern void mousehack_handle (int sprctl, int sprpos);
+extern int needmousehack (void);
+extern void togglemouse (void);
+extern int mousehack_alive (void);
+extern int mousehack_allowed (void);
extern void setmousebuttonstateall (int mouse, uae_u32 buttonbits, uae_u32 buttonmask);
extern void setjoybuttonstateall (int joy, uae_u32 buttonbits, uae_u32 buttonmask);
extern void inputdevice_vsync (void);
extern void inputdevice_hsync (void);
+extern void inputdevice_reset (void);
extern void write_inputdevice_config (struct uae_prefs *p, FILE *f);
extern void read_inputdevice_config (struct uae_prefs *p, char *option, char *value);
extern void inputdevice_close (void);
extern void inputdevice_default_prefs (struct uae_prefs *p);
-extern void inputdevice_acquire (int);
+extern void inputdevice_acquire (void);
extern void inputdevice_unacquire (void);
extern void indicator_leds (int num, int state);
extern int jsem_isjoy (int port, struct uae_prefs *p);
extern int jsem_ismouse (int port, struct uae_prefs *p);
extern int jsem_iskbdjoy (int port, struct uae_prefs *p);
+
extern struct romdata *getromdatabycrc (uae_u32 crc32);
extern struct romdata *getromdatabydata (uae_u8 *rom, int size);
extern struct romdata *getromdatabyid (int id);
+extern struct romdata *getromdatabyzfile (struct zfile *f);
extern void getromname (struct romdata*, char*);
extern struct romdata *getromdatabyname (char*);
extern void romlist_add (char *path, struct romdata *rd);
extern xcolnr xcolors[4096];
-extern int buttonstate[3];
-extern int newmousecounters;
-extern int lastmx, lastmy;
-extern int ievent_alive;
-
extern int graphics_setup (void);
extern int graphics_init (void);
extern void graphics_leave (void);
extern void unlockscr (void);
extern int debuggable (void);
-extern int needmousehack (void);
-extern void togglemouse (void);
extern void LED (int);
extern void screenshot (int);
static int lastspr0x,lastspr0y,lastdiffx,lastdiffy,spr0pos,spr0ctl;
static int mstepx,mstepy,xoffs=defxoffs,yoffs=defyoffs;
static int sprvbfl;
+static int ievent_alive = 0;
static enum mousestate mousestate;
{
if (mousestate == mousehack_dontcare)
return;
-
write_log ("Don't care mouse mode set\n");
mousestate = mousehack_dontcare;
lastspr0x = lastmx; lastspr0y = lastmy;
{
if (mousestate == mousehack_follow)
return;
+ if (!mousehack_allowed ()) {
+ mousehack_set (mousehack_normal);
+ return;
+ }
write_log ("Follow sprite mode set\n");
mousestate = mousehack_follow;
lastdiffx = lastdiffy = 0;
void mousehack_set (int state)
{
+ int oldstate = mousestate;
+
switch (state)
{
case mousehack_dontcare:
mousestate = state;
break;
}
+ if ((oldstate == mousehack_follow && state != mousehack_follow) ||
+ (oldstate != mousehack_follow && state == mousehack_follow))
+ inputdevice_acquire ();
}
int mousehack_get (void)
return mousestate;
}
+int mousehack_alive (void)
+{
+ return ievent_alive > 0;
+}
+
uae_u32 mousehack_helper (void)
{
int mousexpos, mouseypos;
return ievent_alive ? -1 : needmousehack ();
case 1:
ievent_alive = 10;
+ if (!mousehack_allowed ())
+ return 0;
return mousexpos;
case 2:
+ if (!mousehack_allowed ())
+ return 0;
return mouseypos;
}
return 0;
uae_u8 handle_joystick_buttons (uae_u8 dra)
{
uae_u8 but = 0;
- if (!getbuttonstate (0, JOYBUTTON_1) && !getbuttonstate (0, JOYBUTTON_CD32_RED))
- but |= 0x40;
- if (!getbuttonstate (1, JOYBUTTON_1) && !getbuttonstate (1, JOYBUTTON_CD32_RED))
- but |= 0x80;
- //write_log("%02.2X %02.2X %08.8X\n", but, dra, m68k_getpc());
+ int i;
+
+ for (i = 0; i < 2; i++) {
+ if (cd32_pad_enabled[i]) {
+ uae_u16 p5dir = 0x0200 << (i * 4);
+ uae_u16 p5dat = 0x0100 << (i * 4);
+ but |= 0x40 << i;
+ /* Red button is connected to fire when p5 is 1 or floating */
+ if (!(potgo_value & p5dir) || ((potgo_value & p5dat) && (potgo_value & p5dir))) {
+ if (getbuttonstate (i, JOYBUTTON_CD32_RED))
+ but &= ~(0x40 << i);
+ }
+ } else if (!getbuttonstate (i, JOYBUTTON_1)) {
+ but |= 0x40 << i;
+ }
+ }
return but;
}
void handle_cd32_joystick_cia (uae_u8 pra, uae_u8 dra)
{
static int oldstate[2];
- if ((dra & 0x80) && (pra & 0x80) != oldstate[1]) {
- if (!(pra & 0x80))
- cd32_shifter[1]--;
- if (cd32_shifter[1] < 0)
- cd32_shifter[1] = 8;
- oldstate[1] = pra & 0x80;
- }
- if ((dra & 0x40) && (pra & 0x40) != oldstate[0]) {
- if (!(pra & 0x40))
- cd32_shifter[0]--;
- if (cd32_shifter[0] < 0)
- cd32_shifter[0] = 8;
- oldstate[0] = pra & 0x40;
- }
-}
-
-/* joystick port 1 button 3 is used as a output for clearing shift register */
-static void handle_cd32_joystick_potgo (uae_u16 potgo)
-{
-
- if (potgo & 0x2000) {
- if (!(potgo & 0x1000))
- cd32_shifter[1] = 8;
- }
- if (potgo & 0x0200) {
- if (!(potgo & 0x0100))
- cd32_shifter[0] = 8;
- }
-#if 0
- int v;
- static int oldstate[2];
- if (potgo & 0x2000) {
- v = potgo & 0x1000;
- if (v != oldstate[1]) {
- if (v == 0x0000)
- cd32_shifter[1] = 8;
- oldstate[1] = v;
- }
- }
- if (potgo & 0x0200) {
- v = potgo & 0x0100;
- if (v != oldstate[0]) {
- if (v == 0x0000)
- cd32_shifter[0] = 8;
- oldstate[0] = v;
+ int i;
+
+ for (i = 0; i < 2; i++) {
+ uae_u8 but = 0x40 << i;
+ uae_u16 p5dir = 0x0200 << (i * 4); /* output enable P5 */
+ uae_u16 p5dat = 0x0100 << (i * 4); /* data P5 */
+ if (!(potgo_value & p5dir) || !(potgo_value & p5dat)) {
+ if ((dra & but) && (pra & but) != oldstate[i]) {
+ if (!(pra & but)) {
+ cd32_shifter[i]--;
+ if (cd32_shifter[i] < 0)
+ cd32_shifter[i] = 0;
+ }
+ }
}
+ oldstate[i] = pra & but;
}
-#endif
}
/* joystick port 1 button 2 is input for button state */
int i;
for (i = 0; i < 2; i++) {
- uae_u16 mask8 = 0x0800 << (i * 4);
- uae_u16 mask4 = 0x0400 << (i * 4);
- uae_u16 mask2 = 0x0200 << (i * 4);
- uae_u16 mask1 = 0x0100 << (i * 4);
+ uae_u16 p9dir = 0x0800 << (i * 4); /* output enable P9 */
+ uae_u16 p9dat = 0x0400 << (i * 4); /* data P9 */
+ uae_u16 p5dir = 0x0200 << (i * 4); /* output enable P5 */
+ uae_u16 p5dat = 0x0100 << (i * 4); /* data P5 */
if (mouse_port[i]) {
/* mouse has pull-up resistors in button lines */
- if (!(potgor & mask2))
- potgor |= mask1;
- if (!(potgor & mask8))
- potgor |= mask4;
+ if (!(potgo_value & p5dir))
+ potgor |= p5dir;
+ if (!(potgo_value & p9dir))
+ potgor |= p9dat;
}
if (potgo_hsync < 0) {
/* first 10 or so lines after potgo has started
* forces input-lines to zero
*/
- if (!(potgor & mask2))
- potgor &= ~mask1;
- if (!(potgor & mask8))
- potgor &= ~mask4;
+ if (!(potgo_value & p5dir))
+ potgor &= ~p5dir;
+ if (!(potgo_value & p9dir))
+ potgor &= ~p9dat;
}
if (cd32_pad_enabled[i]) {
- if (!(potgor & mask8))
- potgor |= mask4;
- if (!(potgor & mask1) || !(potgor & mask8)) {
- if (cd32_shifter[i] <= 0)
- potgor &= ~mask4;
- if (cd32_shifter[i] >= 2 && (joybutton[i] & ((1 << JOYBUTTON_CD32_PLAY) << (cd32_shifter[i] - 2))))
- potgor &= ~mask4;
- }
+ /* p5 is floating in input-mode */
+ potgor &= ~p5dat;
+ potgor |= potgo_value & p5dat;
+ if (!(potgo_value & p9dir))
+ potgor |= p9dat;
+ /* P5 output and 1 -> shift register is kept reset (Blue button) */
+ if ((potgo_value & p5dir) && (potgo_value & p5dat))
+ cd32_shifter[i] = 8;
+ /* shift at zero == return one, >1 = return button states */
+ if (cd32_shifter[i] == 0)
+ potgor &= ~p9dat; /* shift at one == return zero */
+ if (cd32_shifter[i] >= 2 && (joybutton[i] & ((1 << JOYBUTTON_CD32_PLAY) << (cd32_shifter[i] - 2))))
+ potgor &= ~p9dat;
+ //write_log ("%d:%04.4X %08.8X\n", cd32_shifter[i], potgor, m68k_getpc());
} else {
if (getbuttonstate (i, JOYBUTTON_3))
- potgor &= ~mask1;
+ potgor &= ~p5dir;
+ if (getbuttonstate (i, JOYBUTTON_2))
+ potgor &= ~p9dat;
}
- if (getbuttonstate (i, JOYBUTTON_2) || getbuttonstate (i, JOYBUTTON_CD32_BLUE))
- potgor &= ~mask4;
}
return potgor;
}
potgo_value |= v & data;
}
}
+ for (i = 0; i < 2; i++) {
+ if (cd32_pad_enabled[i]) {
+ uae_u16 p5dir = 0x0200 << (i * 4); /* output enable P5 */
+ uae_u16 p5dat = 0x0100 << (i * 4); /* data P5 */
+ if ((potgo_value & p5dir) && (potgo_value & p5dat))
+ cd32_shifter[i] = 8;
+ }
+ }
if (v & 1) {
potdats[0] = potdats[1] = 0;
potgo_hsync = -15;
}
- handle_cd32_joystick_potgo (v);
}
uae_u16 POTGOR (void)
input_read = 1;
input_vpos = 0;
inputdevice_handle_inputcode ();
+ if (ievent_alive > 0)
+ ievent_alive--;
+}
+
+void inputdevice_reset (void)
+{
+ if (needmousehack ())
+ mousehack_set (mousehack_dontcare);
+ else
+ mousehack_set (mousehack_normal);
+ ievent_alive = 0;
}
static void setbuttonstateall (struct uae_input_device *id, struct uae_input_device2 *id2, int button, int state)
}
}
+#ifdef CD32
+static void setcd32 (int joy, int n)
+{
+ joysticks[joy].eventid[ID_BUTTON_OFFSET + 0][0] = n ? INPUTEVENT_JOY2_CD32_RED : INPUTEVENT_JOY1_CD32_RED;
+ joysticks[joy].eventid[ID_BUTTON_OFFSET + 1][0] = n ? INPUTEVENT_JOY2_CD32_BLUE : INPUTEVENT_JOY1_CD32_BLUE;
+ joysticks[joy].eventid[ID_BUTTON_OFFSET + 2][0] = n ? INPUTEVENT_JOY2_CD32_YELLOW : INPUTEVENT_JOY1_CD32_YELLOW;
+ joysticks[joy].eventid[ID_BUTTON_OFFSET + 3][0] = n ? INPUTEVENT_JOY2_CD32_GREEN : INPUTEVENT_JOY1_CD32_GREEN;
+ joysticks[joy].eventid[ID_BUTTON_OFFSET + 4][0] = n ? INPUTEVENT_JOY2_CD32_FFW : INPUTEVENT_JOY1_CD32_FFW;
+ joysticks[joy].eventid[ID_BUTTON_OFFSET + 5][0] = n ? INPUTEVENT_JOY2_CD32_RWD : INPUTEVENT_JOY1_CD32_RWD;
+ joysticks[joy].eventid[ID_BUTTON_OFFSET + 6][0] = n ? INPUTEVENT_JOY2_CD32_PLAY : INPUTEVENT_JOY1_CD32_PLAY;
+}
+#endif
+
int compatibility_device[2];
static void compatibility_mode (struct uae_prefs *prefs)
{
joysticks[joy].eventid[ID_AXIS_OFFSET + 0][0] = INPUTEVENT_JOY2_HORIZ;
joysticks[joy].eventid[ID_AXIS_OFFSET + 1][0] = INPUTEVENT_JOY2_VERT;
used[joy] = 1;
+ joysticks[joy].eventid[ID_BUTTON_OFFSET + 0][0] = INPUTEVENT_JOY2_FIRE_BUTTON;
+ joysticks[joy].eventid[ID_BUTTON_OFFSET + 1][0] = INPUTEVENT_JOY2_2ND_BUTTON;
+ joysticks[joy].eventid[ID_BUTTON_OFFSET + 2][0] = INPUTEVENT_JOY2_3RD_BUTTON;
#ifdef CD32
- if (cd32_enabled) {
- joysticks[joy].eventid[ID_BUTTON_OFFSET + 0][0] = INPUTEVENT_JOY2_FIRE_BUTTON;
- joysticks[joy].eventid[ID_BUTTON_OFFSET + 1][0] = INPUTEVENT_JOY2_CD32_RED;
- joysticks[joy].eventid[ID_BUTTON_OFFSET + 2][0] = INPUTEVENT_JOY2_CD32_BLUE;
- joysticks[joy].eventid[ID_BUTTON_OFFSET + 3][0] = INPUTEVENT_JOY2_CD32_YELLOW;
- joysticks[joy].eventid[ID_BUTTON_OFFSET + 4][0] = INPUTEVENT_JOY2_CD32_GREEN;
- joysticks[joy].eventid[ID_BUTTON_OFFSET + 5][0] = INPUTEVENT_JOY2_CD32_FFW;
- joysticks[joy].eventid[ID_BUTTON_OFFSET + 6][0] = INPUTEVENT_JOY2_CD32_RWD;
- joysticks[joy].eventid[ID_BUTTON_OFFSET + 7][0] = INPUTEVENT_JOY2_CD32_PLAY;
- } else {
-#endif
- joysticks[joy].eventid[ID_BUTTON_OFFSET + 0][0] = INPUTEVENT_JOY2_FIRE_BUTTON;
- joysticks[joy].eventid[ID_BUTTON_OFFSET + 1][0] = INPUTEVENT_JOY2_2ND_BUTTON;
- joysticks[joy].eventid[ID_BUTTON_OFFSET + 2][0] = INPUTEVENT_JOY2_3RD_BUTTON;
-#ifdef CD32
- }
+ if (cd32_enabled)
+ setcd32 (joy, 1);
#endif
joysticks[joy].enabled = 1;
}
-
+
joy = jsem_isjoy (0, prefs);
if (joy >= 0) {
used[joy] = 1;
joysticks[joy].eventid[ID_BUTTON_OFFSET + 0][0] = INPUTEVENT_JOY2_FIRE_BUTTON;
joysticks[joy].eventid[ID_BUTTON_OFFSET + 1][0] = INPUTEVENT_JOY2_2ND_BUTTON;
joysticks[joy].eventid[ID_BUTTON_OFFSET + 2][0] = INPUTEVENT_JOY2_3RD_BUTTON;
+#ifdef CD32
+ if (cd32_enabled)
+ setcd32 (joy, 1);
+#endif
joysticks[joy].enabled = 1;
used[joy] = 1;
compatibility_device[1] = joy;
memcpy (p->keyboard_settings[dst], p->keyboard_settings[src], sizeof (struct uae_input_device) * MAX_INPUT_DEVICES);
}
-void inputdevice_acquire (int exclusive)
+void inputdevice_acquire (void)
{
int i;
d = data - (int)(*oldm_p);
*oldm_p = data;
*mouse_p += d;
- if (mouse == 0) {
+ if (mousehack_allowed () && needmousehack ()) {
if (axis == 0)
lastmx = data;
else
{ 0 }
};
+void decode_cloanto_rom_do (uae_u8 *mem, int size, int real_size, uae_u8 *key, int keysize)
+{
+ long cnt, t;
+ for (t = cnt = 0; cnt < size; cnt++, t = (t + 1) % keysize) {
+ mem[cnt] ^= key[t];
+ if (real_size == cnt + 1)
+ t = keysize - 1;
+ }
+}
+
+uae_u8 *load_keyfile (struct uae_prefs *p, char *path, int *size)
+{
+ struct zfile *f;
+ uae_u8 *keybuf = 0;
+ int keysize = 0;
+ char tmp[MAX_PATH];
+
+ tmp[0] = 0;
+ if (path)
+ strcpy (tmp, path);
+ strcat (tmp, "rom.key");
+ f = zfile_fopen (tmp, "rb");
+ if (!f) {
+ struct romdata *rd = getromdatabyid (0);
+ char *s = romlist_get (rd);
+ if (s)
+ f = zfile_fopen (s, "rb");
+ if (!f) {
+ strcpy (tmp, p->path_rom);
+ strcat (tmp, "rom.key");
+ f = zfile_fopen (tmp, "rb");
+ if (!f) {
+ f = zfile_fopen ("roms\\rom.key", "rb");
+ if (!f) {
+ strcpy (tmp, start_path);
+ strcat (tmp, "rom.key");
+ f = zfile_fopen(tmp, "rb");
+ if (!f) {
+ strcpy (tmp, start_path);
+ strcat (tmp, "..\\shared\\rom\\rom.key");
+ f = zfile_fopen(tmp, "rb");
+ }
+ }
+ }
+ }
+ }
+ if (f) {
+ zfile_fseek (f, 0, SEEK_END);
+ keysize = zfile_ftell (f);
+ if (keysize > 0) {
+ zfile_fseek (f, 0, SEEK_SET);
+ keybuf = xmalloc (keysize);
+ zfile_fread (keybuf, 1, keysize, f);
+ }
+ zfile_fclose (f);
+ }
+ *size = keysize;
+ return keybuf;
+}
+void free_keyfile (uae_u8 *key)
+{
+ xfree (key);
+}
+
+static int decode_cloanto_rom (uae_u8 *mem, int size, int real_size)
+{
+ uae_u8 *p;
+ int keysize;
+
+ p = load_keyfile (&currprefs, NULL, &keysize);
+ if (!p) {
+#ifndef SINGLEFILE
+ notify_user (NUMSG_NOROMKEY);
+#endif
+ return 0;
+ }
+ decode_cloanto_rom_do (mem, size, real_size, p, keysize);
+ free_keyfile (p);
+ return 1;
+}
+
struct romdata *getromdatabyname (char *name)
{
char tmp[MAX_PATH];
int i;
uae_u32 crc32a, crc32b, crc32c;
uae_u8 tmp[4];
-
+ uae_u8 *tmpbuf = NULL;
+
+ if (size > 11 && !memcmp (rom, "AMIROMTYPE1", 11)) {
+ uae_u8 *tmpbuf = xmalloc (size);
+ int tmpsize = size - 11;
+ memcpy (tmpbuf, rom + 11, tmpsize);
+ decode_cloanto_rom (tmpbuf, tmpsize, tmpsize);
+ rom = tmpbuf;
+ size = tmpsize;
+ }
crc32a = get_crc32 (rom, size);
crc32b = get_crc32 (rom, size / 2);
/* ignore AR IO-port range until we have full dump */
return &roms[i];
i++;
}
+ xfree (tmpbuf);
return 0;
}
+struct romdata *getromdatabyzfile (struct zfile *f)
+{
+ int pos, size;
+ uae_u8 *p;
+ struct romdata *rd;
+
+ pos = zfile_ftell (f);
+ zfile_fseek (f, 0, SEEK_END);
+ size = zfile_ftell (f);
+ p = xmalloc (size);
+ if (!p)
+ return 0;
+ memset (p, 0, size);
+ zfile_fseek (f, 0, SEEK_SET);
+ zfile_fread (p, 1, size, f);
+ zfile_fseek (f, pos, SEEK_SET);
+ rd = getromdatabydata (p, size);
+ xfree (p);
+ return rd;
+}
+
void getromname (struct romdata *rd, char *name)
{
strcpy (name, rd->name);
extendedkickmem_xlate, extendedkickmem_check, NULL
};
-void decode_cloanto_rom_do (uae_u8 *mem, int size, int real_size, uae_u8 *key, int keysize)
-{
- long cnt, t;
- for (t = cnt = 0; cnt < size; cnt++, t = (t + 1) % keysize) {
- mem[cnt] ^= key[t];
- if (real_size == cnt + 1)
- t = keysize - 1;
- }
-}
-
-uae_u8 *load_keyfile (struct uae_prefs *p, char *path, int *size)
-{
- struct zfile *f;
- uae_u8 *keybuf = 0;
- int keysize = 0;
- char tmp[MAX_PATH];
-
- tmp[0] = 0;
- if (path)
- strcpy (tmp, path);
- strcat (tmp, "rom.key");
- f = zfile_fopen (tmp, "rb");
- if (!f) {
- struct romdata *rd = getromdatabyid (0);
- char *s = romlist_get (rd);
- if (s)
- f = zfile_fopen (s, "rb");
- if (!f) {
- strcpy (tmp, p->path_rom);
- strcat (tmp, "rom.key");
- f = zfile_fopen (tmp, "rb");
- if (!f) {
- f = zfile_fopen ("roms\\rom.key", "rb");
- if (!f) {
- strcpy (tmp, start_path);
- strcat (tmp, "rom.key");
- f = zfile_fopen(tmp, "rb");
- if (!f) {
- strcpy (tmp, start_path);
- strcat (tmp, "..\\shared\\rom\\rom.key");
- f = zfile_fopen(tmp, "rb");
- }
- }
- }
- }
- }
- if (f) {
- zfile_fseek (f, 0, SEEK_END);
- keysize = zfile_ftell (f);
- if (keysize > 0) {
- zfile_fseek (f, 0, SEEK_SET);
- keybuf = xmalloc (keysize);
- zfile_fread (keybuf, 1, keysize, f);
- }
- zfile_fclose (f);
- }
- *size = keysize;
- return keybuf;
-}
-void free_keyfile (uae_u8 *key)
-{
- xfree (key);
-}
-
-static int decode_cloanto_rom (uae_u8 *mem, int size, int real_size)
-{
- uae_u8 *p;
- int keysize;
-
- p = load_keyfile (&currprefs, NULL, &keysize);
- if (!p) {
-#ifndef SINGLEFILE
- notify_user (NUMSG_NOROMKEY);
-#endif
- return 0;
- }
- decode_cloanto_rom_do (mem, size, real_size, p, keysize);
- free_keyfile (p);
- return 1;
-}
-
static int kickstart_checksum (uae_u8 *mem, int size)
{
uae_u32 cksum = 0, prevck = 0;
static int stopoutput;
static HANDLE kbhandle = INVALID_HANDLE_VALUE;
static int oldleds, oldusedleds, newleds, usbledmode, oldusbleds;
-static int normalmouse, supermouse, rawmouse, winmouse, winmousenumber;
+static int normalmouse, supermouse, rawmouse, winmouse, winmousenumber, winmousemode;
static int normalkb, superkb, rawkb;
int no_rawinput;
return winmousenumber;
return -1;
}
+int dinput_winmousemode (void)
+{
+ if (winmouse)
+ return winmousemode;
+ return 0;
+}
typedef BOOL (CALLBACK* REGISTERRAWINPUTDEVICES)
(PCRAWINPUTDEVICE, UINT, UINT);
static void initialize_windowsmouse (void)
{
struct didata *did = di_mouse;
- char tmp[100];
- int j;
+ char tmp[100], *name;
+ int i, j;
- if (num_mouse >= MAX_INPUT_DEVICES)
- return;
did += num_mouse;
- num_mouse++;
- did->name = my_strdup ("Windows mouse");
- did->sortname = my_strdup ("Windows mouse");
- did->buttons = GetSystemMetrics (SM_CMOUSEBUTTONS);
- if (did->buttons > 5)
- did->buttons = 5; /* no non-direcinput support for >5 buttons */
- if (did->buttons > 3 && !os_winnt)
- did->buttons = 3; /* Windows 98/ME support max 3 non-DI buttons */
- did->axles = GetSystemMetrics (SM_MOUSEWHEELPRESENT) ? 3 : 2;
- did->axistype[0] = 1;
- did->axissort[0] = 0;
- did->axisname[0] = my_strdup ("X-Axis");
- did->axistype[1] = 1;
- did->axissort[1] = 1;
- did->axisname[1] = my_strdup ("Y-Axis");
- if (did->axles > 2) {
- did->axistype[2] = 1;
- did->axissort[2] = 2;
- did->axisname[2] = my_strdup ("Wheel");
- }
- for (j = 0; j < did->buttons; j++) {
- did->buttonsort[j] = j;
- sprintf (tmp, "Button %d", j + 1);
- did->buttonname[j] = my_strdup (tmp);
+ for (i = 0; i < 2; i++) {
+ if (num_mouse >= MAX_INPUT_DEVICES)
+ return;
+ num_mouse++;
+ name = (i == 0) ? "Windows mouse" : "Mousehack mouse";
+ did->name = my_strdup (i ? "Mousehack mouse" : "Windows mouse");
+ did->sortname = my_strdup (i ? "Windowsmouse2" : "Windowsmouse1");
+ did->buttons = GetSystemMetrics (SM_CMOUSEBUTTONS);
+ if (did->buttons > 5)
+ did->buttons = 5; /* no non-direcinput support for >5 buttons */
+ if (did->buttons > 3 && !os_winnt)
+ did->buttons = 3; /* Windows 98/ME support max 3 non-DI buttons */
+ did->axles = GetSystemMetrics (SM_MOUSEWHEELPRESENT) ? 3 : 2;
+ did->axistype[0] = 1;
+ did->axissort[0] = 0;
+ did->axisname[0] = my_strdup ("X-Axis");
+ did->axistype[1] = 1;
+ did->axissort[1] = 1;
+ did->axisname[1] = my_strdup ("Y-Axis");
+ if (did->axles > 2) {
+ did->axistype[2] = 1;
+ did->axissort[2] = 2;
+ did->axisname[2] = my_strdup ("Wheel");
+ }
+ for (j = 0; j < did->buttons; j++) {
+ did->buttonsort[j] = j;
+ sprintf (tmp, "Button %d", j + 1);
+ did->buttonname[j] = my_strdup (tmp);
+ }
+ did->priority = 2;
+ did->wininput = i + 1;
+ did++;
}
- did->priority = 2;
- did->wininput = 1;
}
static void handle_rawinput_2 (RAWINPUT *raw)
static int acquire_mouse (int num, int flags)
{
LPDIRECTINPUTDEVICE8 lpdi = di_mouse[num].lpdi;
+ struct didata *did = &di_mouse[num];
DIPROPDWORD dipdw;
HRESULT hr;
unacquire (lpdi, "mouse");
- if (mousehack_get () == mousehack_follow)
- return 0;
if (lpdi) {
setcoop (lpdi, flags ? (DISCL_FOREGROUND | DISCL_EXCLUSIVE) : (DISCL_BACKGROUND | DISCL_NONEXCLUSIVE), "mouse");
dipdw.diph.dwSize = sizeof(DIPROPDWORD);
else if (di_mouse[num].wininput) {
winmouse++;
winmousenumber = num;
+ winmousemode = di_mouse[num].wininput == 2;
} else
normalmouse++;
}
}
}
}
- if (i == 0 && dimofs == DIMOFS_BUTTON2 && state) {
- if (currprefs.win32_middle_mouse) {
- if (isfullscreen ())
- minimizewindow ();
- if (mouseactive)
- setmouseactive(0);
- }
+ if (currprefs.win32_middle_mouse && dimofs == DIMOFS_BUTTON2 && state) {
+ if (isfullscreen ())
+ minimizewindow ();
+ if (mouseactive)
+ setmouseactive(0);
}
}
}
#define IDS_ROMSCANNOROMS 324
#define IDS_NUMSG_KICKREP 325
#define IDS_NUMSG_KICKREPNO 326
-#define IDS_STRING19 327
#define IDS_NUMSG_NOROM 327
#define IDS_QS_MODELS 1000
#define IDS_QS_MODEL_A500 1001
#define IDC_DF1Q 1679
#define IDC_QUICKSTART_HOSTCONFIG 1679
#define IDC_DF1QQ 1680
+#define IDC_DF1QQ2 1681
+#define IDC_QUICKSTART_SETCONFIG 1681
#define IDC_CONFIGAUTO 1682
#define IDC_DF0TEXTQ 1683
#define IDC_CONFIGNOLINK 1683
GROUPBOX "Compatibility vs required CPU power ",
IDC_QUICKSTART_COMPA,3,56,294,33
GROUPBOX "Mode",IDC_STATIC,190,211,107,27,BS_LEFT
+ PUSHBUTTON "Set Configuration",IDC_QUICKSTART_SETCONFIG,9,219,72,15,
+ NOT WS_VISIBLE
END
SetCursorPos (amigawin_rect.left + x, amigawin_rect.top + y);
}
-static void movehackmouse (int x, int y)
-{
- setmousestate (0, 0, x, 1);
- setmousestate (0, 1, y, 1);
-}
-
void setmouseactive (int active)
{
int oldactive = mouseactive;
static int mousecapture, showcursor;
char txt[100], txt2[110];
- if (active > 0 && ievent_alive > 0) {
+ if (active > 0 && mousehack_allowed () && mousehack_alive ()) {
mousehack_set (mousehack_follow);
if (!isfullscreen ())
return;
mousehack_set (mousehack_dontcare);
}
inputdevice_unacquire ();
- //mousehack_width = GetSystemMetrics (SM_CXVIRTUALSCREEN);
- //mousehack_height = GetSystemMetrics (SM_CYVIRTUALSCREEN);
mouseactive = active;
strcpy (txt, "WinUAE");
}
setcursor (-1, -1);
}
- inputdevice_acquire (mouseactive);
+ inputdevice_acquire ();
}
}
if (WIN32GFX_IsPicassoScreen ())
WIN32GFX_EnablePicasso();
getcapslock ();
- inputdevice_acquire (mouseactive);
+ inputdevice_acquire ();
wait_keyrelease ();
- inputdevice_acquire (mouseactive);
+ inputdevice_acquire ();
if (isfullscreen())
setmouseactive (1);
manual_palette_refresh_needed = 1;
break;
}
if (v != minimized) {
+ minimized = v;
if (v)
winuae_inactive (hWnd, wParam == SIZE_MINIMIZED);
else
winuae_active (hWnd, minimized);
}
- minimized = v;
return 0;
}
}
return 0;
} else if (LOWORD (wParam) == WA_INACTIVE) {
minimized = 1;
+ if (isfullscreen ())
+ winuae_inactive (hWnd, minimized);
if (ignorenextactivateapp > 0)
ignorenextactivateapp--;
} else if (!minimized && LOWORD (wParam) != WA_INACTIVE) {
exit_gui (0);
setmouseactive (0);
} else {
+ if (minimized) {
+ minimized = 0;
+ winuae_active (hWnd, minimized);
+ }
if (!ignorenextactivateapp && isfullscreen () && is3dmode ()) {
WIN32GFX_DisplayChangeRequested ();
ignorenextactivateapp = 3;
return 0;
case WM_LBUTTONUP:
- if (dinput_winmouse () > 0 || mousehack_get () == mousehack_follow)
+ if (dinput_winmouse () >= 0)
setmousebuttonstate (dinput_winmouse(), 0, 0);
return 0;
case WM_LBUTTONDOWN:
if (!mouseactive && !isfullscreen()) {
setmouseactive (1);
}
- if (dinput_winmouse () > 0 || mousehack_get () == mousehack_follow)
+ if (dinput_winmouse () >= 0)
setmousebuttonstate (dinput_winmouse(), 0, 1);
return 0;
case WM_RBUTTONUP:
- if (dinput_winmouse () > 0 || mousehack_get () == mousehack_follow)
+ if (dinput_winmouse () >= 0)
setmousebuttonstate (dinput_winmouse(), 1, 0);
return 0;
case WM_RBUTTONDOWN:
case WM_RBUTTONDBLCLK:
- if (dinput_winmouse () > 0 || mousehack_get () == mousehack_follow)
+ if (dinput_winmouse () >= 0)
setmousebuttonstate (dinput_winmouse(), 1, 1);
return 0;
case WM_MBUTTONUP:
- if (dinput_winmouse () > 0 || mousehack_get () == mousehack_follow)
+ if (dinput_winmouse () >= 0)
setmousebuttonstate (dinput_winmouse(), 2, 0);
return 0;
case WM_MBUTTONDOWN:
case WM_MBUTTONDBLCLK:
- if (dinput_winmouse () > 0 || mousehack_get () == mousehack_follow)
+ if (dinput_winmouse () >= 0)
setmousebuttonstate (dinput_winmouse(), 2, 1);
return 0;
case WM_XBUTTONUP:
- if (dinput_winmouse () > 0 || mousehack_get () == mousehack_follow) {
+ if (dinput_winmouse () >= 0) {
handleXbutton (wParam, 0);
return TRUE;
}
return 0;
case WM_XBUTTONDOWN:
case WM_XBUTTONDBLCLK:
- if (dinput_winmouse () > 0 || mousehack_get () == mousehack_follow) {
+ if (dinput_winmouse () >= 0) {
handleXbutton (wParam, 1);
return TRUE;
}
return 0;
case WM_MOUSEWHEEL:
- if (dinput_winmouse () > 0 || mousehack_get () == mousehack_follow)
+ if (dinput_winmouse () >= 0)
setmousestate (dinput_winmouse(), 2, ((short)HIWORD(wParam)), 0);
return 0;
case WM_MOUSEMOVE:
mx = (signed short) LOWORD (lParam);
my = (signed short) HIWORD (lParam);
- if (mousehack_get () == mousehack_follow) {
- movehackmouse (mx, my);
- return 0;
- } else if (dinput_winmouse () > 0) {
- int mxx = (amigawin_rect.right - amigawin_rect.left) / 2;
- int myy = (amigawin_rect.bottom - amigawin_rect.top) / 2;
- mx = mx - mxx;
- my = my - myy;
- setmousestate (dinput_winmouse (), 0, mx, 0);
- setmousestate (dinput_winmouse (), 1, my, 0);
+ if (dinput_winmouse () >= 0) {
+ if (dinput_winmousemode ()) {
+ /* absolete + mousehack */
+ setmousestate (dinput_winmouse (), 0, mx, 1);
+ setmousestate (dinput_winmouse (), 1, my, 1);
+ return 0;
+ } else {
+ /* relative */
+ int mxx = (amigawin_rect.right - amigawin_rect.left) / 2;
+ int myy = (amigawin_rect.bottom - amigawin_rect.top) / 2;
+ mx = mx - mxx;
+ my = my - myy;
+ setmousestate (dinput_winmouse (), 0, mx, 0);
+ setmousestate (dinput_winmouse (), 1, my, 0);
+ }
} else if ((!mouseactive && !isfullscreen())) {
setmousestate (0, 0, mx, 1);
setmousestate (0, 1, my, 1);
{
return 1;
}
+int mousehack_allowed (void)
+{
+ return dinput_winmouse () > 0 && dinput_winmousemode ();
+}
void logging_init( void )
{
extern int dinput_wmkey (uae_u32 key);
extern int dinput_winmouse (void);
+extern int dinput_winmousemode (void);
void systray (HWND hwnd, int remove);
void systraymenu (HWND hwnd);
init_hz ();
pause_sound ();
resume_sound ();
- inputdevice_acquire (mouseactive);
+ inputdevice_acquire ();
return 1;
}
if (currprefs.gfx_correct_aspect != changed_prefs.gfx_correct_aspect ||
currprefs.keyboard_leds_in_use = currprefs.keyboard_leds[0] | currprefs.keyboard_leds[1] | currprefs.keyboard_leds[2];
pause_sound ();
resume_sound ();
- inputdevice_acquire (mouseactive);
+ inputdevice_acquire ();
#ifndef _DEBUG
setpriority (&priorities[currprefs.win32_active_priority]);
#endif
dr.right -= mi.rcMonitor.left;
dr.bottom -= mi.rcMonitor.top;
- w = currentmode->current_width; // * (currprefs.gfx_filter_horiz_zoom + 100) / 100;
- h = currentmode->current_height; // * (currprefs.gfx_filter_vert_zoom + 100) / 100;
+ w = currentmode->current_width;
+ h = currentmode->current_height;
sr.left = 0;
sr.top = 0;
inputdevice_copyconfig (&changed_prefs, &currprefs);
inputdevice_config_change_test ();
clearallkeys ();
- inputdevice_acquire (mouseactive);
+ inputdevice_acquire ();
#ifdef CD32
akiko_exitgui ();
#endif
{
int v = quickstart_ok && quickstart_ok_floppy ? TRUE : FALSE;
EnableWindow (GetDlgItem (guiDlg, IDC_RESETAMIGA), !full_property_sheet ? TRUE : FALSE);
+ ShowWindow (GetDlgItem (hDlg, IDC_QUICKSTART_SETCONFIG), quickstart ? SW_HIDE : SW_SHOW);
}
static void load_quickstart (HWND hDlg, int romcheck)
WIN32GUI_LoadUIString (messageid, tmp, sizeof (tmp));
gui_message (tmp);
}
- if (reload) {
+ if (reload && quickstart) {
load_quickstart (hDlg, 1);
init_quickstartdlg (hDlg);
}
case WM_INITDIALOG:
pages[QUICKSTART_ID] = hDlg;
currentpage = QUICKSTART_ID;
+ enable_for_quickstart (hDlg);
doinit = 1;
break;
case WM_NULL:
addfloppytype (hDlg, 0);
addfloppytype (hDlg, 1);
init_quickstartdlg (hDlg);
- enable_for_quickstart (hDlg);
}
doinit = 0;
recursive--;
if (i != quickstart_model) {
quickstart_model = i;
init_quickstartdlg (hDlg);
- load_quickstart (hDlg, 1);
+ if (quickstart)
+ load_quickstart (hDlg, 1);
if (quickstart && !full_property_sheet)
qs_request_reset = 2;
}
if (val != CB_ERR && val != quickstart_conf) {
quickstart_conf = val;
init_quickstartdlg (hDlg);
- load_quickstart (hDlg, 1);
+ if (quickstart)
+ load_quickstart (hDlg, 1);
if (quickstart && !full_property_sheet)
qs_request_reset = 2;
}
init_quickstartdlg (hDlg);
load_quickstart (hDlg, 0);
}
+ enable_for_quickstart (hDlg);
break;
}
}
case IDC_DF1QQ:
ret = FloppyDlgProc (hDlg, msg, wParam, lParam);
break;
- }
+ case IDC_QUICKSTART_SETCONFIG:
+ load_quickstart (hDlg, 1);
+ break;
+ }
recursive--;
case WM_HSCROLL:
if (recursive > 0)
if (val >= 0 && val != quickstart_compa) {
quickstart_compa = val;
init_quickstartdlg (hDlg);
- load_quickstart (hDlg, 0);
+ if (quickstart)
+ load_quickstart (hDlg, 0);
}
recursive--;
break;
IDC_PORT1_JOYSC, IDC_PORT1_KBDA, IDC_PORT1_KBDB, IDC_PORT1_KBDC,
IDC_PORT1_JOYS, -1
};
-static int joy0previous = -1, joy1previous = -1;
+static int joy0previous, joy1previous;
static BOOL bNoMidiIn = FALSE;
}
if (joy0previous < 0)
- joy0previous = inputdevice_get_device_total (IDTYPE_JOYSTICK);
+ joy0previous = inputdevice_get_device_total (IDTYPE_JOYSTICK) + 1;
if (joy1previous < 0)
- joy1previous = 0;
+ joy1previous = 1;
for (i = 0; i < 2; i++) {
+ int total = 0;
int idx = i == 0 ? joy0previous : joy1previous;
int id1 = i == 0 ? IDC_PORT0_JOYS : IDC_PORT1_JOYS;
int id2 = i == 0 ? IDC_PORT0_JOYSC : IDC_PORT1_JOYSC;
int v = i == 0 ? workprefs.jport0 : workprefs.jport1;
SendDlgItemMessage (hDlg, id1, CB_RESETCONTENT, 0, 0L);
SendDlgItemMessage (hDlg, id1, CB_ADDSTRING, 0, (LPARAM)"");
- for (j = 0; j < inputdevice_get_device_total (IDTYPE_JOYSTICK); j++)
+ for (j = 0; j < inputdevice_get_device_total (IDTYPE_JOYSTICK); j++, total++)
SendDlgItemMessage (hDlg, id1, CB_ADDSTRING, 0, (LPARAM)inputdevice_get_device_name(IDTYPE_JOYSTICK, j));
- for (j = 0; j < inputdevice_get_device_total (IDTYPE_MOUSE); j++)
+ for (j = 0; j < inputdevice_get_device_total (IDTYPE_MOUSE); j++, total++)
SendDlgItemMessage (hDlg, id1, CB_ADDSTRING, 0, (LPARAM)inputdevice_get_device_name(IDTYPE_MOUSE, j));
if (v >= JSEM_MICE)
idx = inputdevice_get_device_total (IDTYPE_JOYSTICK) + (v - JSEM_MICE) + 1;
else if (v >= JSEM_JOYS)
idx = v - JSEM_JOYS + 1;
+ if (idx >= total)
+ idx = 0;
SendDlgItemMessage (hDlg, id1, CB_SETCURSEL, idx, 0);
}
}
int port, portcnt, numdevs;
COMMCONFIG cc;
DWORD size = sizeof(COMMCONFIG);
-
MIDIOUTCAPS midiOutCaps;
MIDIINCAPS midiInCaps;
+ joy0previous = joy1previous = -1;
SendDlgItemMessage (hDlg, IDC_SERIAL, CB_RESETCONTENT, 0, 0L);
SendDlgItemMessage (hDlg, IDC_SERIAL, CB_ADDSTRING, 0, (LPARAM)szNone );
portcnt = 0;
z = zfile_fopen (file, "rb");
if (z) {
int type = zfile_gettype (z);
+ struct romdata *rd = getromdatabyzfile (z);
zfile_fclose (z);
switch (type)
{
}
break;
case ZFILE_ROM:
- strcpy (prefs->romfile, file);
+ if (rd) {
+ if (rd->type == ROMTYPE_KICK || rd->type == ROMTYPE_KICKCD32)
+ strcpy (prefs->romfile, file);
+ if (rd->type == ROMTYPE_EXTCD32 || rd->type == ROMTYPE_EXTCDTV)
+ strcpy (prefs->romextfile, file);
+ if (rd->type == ROMTYPE_AR)
+ strcpy (prefs->cartfile, file);
+ } else {
+ strcpy (prefs->romfile, file);
+ }
break;
case ZFILE_NVR:
strcpy (prefs->flashfile, file);
uae_u32 zfile_crc32 (struct zfile *f)
{
uae_u8 *p;
- int pos = f->seek;
+ int pos, size;
uae_u32 crc;
if (!f)
return 0;
if (f->data)
return get_crc32 (f->data, f->size);
- p = xmalloc (f->size);
+ pos = zfile_ftell (f);
+ zfile_fseek (f, 0, SEEK_END);
+ size = zfile_ftell (f);
+ p = xmalloc (size);
if (!p)
return 0;
+ memset (p, 0, size);
zfile_fseek (f, 0, SEEK_SET);
- zfile_fread (p, 1, f->size, f);
+ zfile_fread (p, 1, size, f);
zfile_fseek (f, pos, SEEK_SET);
- crc = get_crc32 (f->data, f->size);
+ crc = get_crc32 (p, size);
xfree (p);
return crc;
}