mirror of
https://github.com/dborth/vbagx.git
synced 2024-11-23 02:59:17 +01:00
July 14, 2008 update by theinternetftw
This commit is contained in:
parent
64546f8550
commit
5a65f55992
@ -3,6 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Nintendo GameCube Joypad Wrapper
|
* Nintendo GameCube Joypad Wrapper
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <gccore.h>
|
#include <gccore.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
@ -55,14 +56,14 @@ NGCPad()
|
|||||||
int padcal = 90;
|
int padcal = 90;
|
||||||
float t;
|
float t;
|
||||||
|
|
||||||
|
|
||||||
#ifdef WII_BUILD
|
#ifdef WII_BUILD
|
||||||
//wiimote
|
//wiimote
|
||||||
|
WPADData *wpad;
|
||||||
|
WPAD_ScanPads();
|
||||||
|
wpad = WPAD_Data(0);
|
||||||
if (isWiimoteAvailable)
|
if (isWiimoteAvailable)
|
||||||
{
|
{
|
||||||
WPADData wpad;
|
unsigned short b = wpad->btns_h;
|
||||||
WPAD_Read(0, &wpad);
|
|
||||||
unsigned short b = wpad.btns_d;
|
|
||||||
|
|
||||||
if (b & WPAD_BUTTON_2)
|
if (b & WPAD_BUTTON_2)
|
||||||
res |= VBA_BUTTON_A;
|
res |= VBA_BUTTON_A;
|
||||||
@ -100,9 +101,23 @@ NGCPad()
|
|||||||
//classic controller
|
//classic controller
|
||||||
if (isClassicAvailable)
|
if (isClassicAvailable)
|
||||||
{
|
{
|
||||||
WPADData wpad;
|
float mag,ang;
|
||||||
WPAD_Read(0, &wpad);
|
int b = wpad->exp.classic.btns;
|
||||||
int b = wpad.exp.classic.btns;
|
/* Stolen Shamelessly out of Falco's unofficial SNES9x update */
|
||||||
|
ang = wpad->exp.classic.ljs.ang;
|
||||||
|
mag = wpad->exp.classic.ljs.mag;
|
||||||
|
|
||||||
|
if (mag > 0.4) {
|
||||||
|
if (ang > 292.5 | ang <= 67.5)
|
||||||
|
res |= VBA_UP;
|
||||||
|
if (ang > 22.5 & ang <= 157.5)
|
||||||
|
res |= VBA_RIGHT;
|
||||||
|
if (ang > 113.5 & ang <= 247.5)
|
||||||
|
res |= VBA_DOWN;
|
||||||
|
if (ang > 203.5 & ang <= 337.5)
|
||||||
|
res |= VBA_LEFT;
|
||||||
|
}
|
||||||
|
|
||||||
int x_s = 0; //getStickValue(&wpad.exp.classic.ljs, STICK_X, 127);
|
int x_s = 0; //getStickValue(&wpad.exp.classic.ljs, STICK_X, 127);
|
||||||
int y_s = 0; //getStickValue(&wpad.exp.classic.ljs, STICK_Y, 127);
|
int y_s = 0; //getStickValue(&wpad.exp.classic.ljs, STICK_Y, 127);
|
||||||
if (b & CLASSIC_CTRL_BUTTON_A)
|
if (b & CLASSIC_CTRL_BUTTON_A)
|
||||||
@ -140,7 +155,7 @@ NGCPad()
|
|||||||
|
|
||||||
}
|
}
|
||||||
//user needs a GC remote
|
//user needs a GC remote
|
||||||
else if((!(isWiimoteAvailable)) && (!(isClassicAvailable)))
|
else
|
||||||
{
|
{
|
||||||
p = PAD_ButtonsHeld(0);
|
p = PAD_ButtonsHeld(0);
|
||||||
x = PAD_StickX(0);
|
x = PAD_StickX(0);
|
||||||
|
@ -151,11 +151,12 @@ char *MENU_GetLoadFile( char *whichdir )
|
|||||||
printf("No ROM files in %s\n", whichdir);
|
printf("No ROM files in %s\n", whichdir);
|
||||||
while(1);
|
while(1);
|
||||||
}
|
}
|
||||||
|
#ifdef WII_BUILD
|
||||||
|
setup_controllers();
|
||||||
|
#endif
|
||||||
if ( count == 1 )
|
if ( count == 1 )
|
||||||
return (char*)direntries[0];
|
return (char*)direntries[0];
|
||||||
|
|
||||||
|
|
||||||
/* Do menu */
|
/* Do menu */
|
||||||
while ( !quit )
|
while ( !quit )
|
||||||
{
|
{
|
||||||
@ -170,39 +171,43 @@ char *MENU_GetLoadFile( char *whichdir )
|
|||||||
redraw = 0;
|
redraw = 0;
|
||||||
}
|
}
|
||||||
#ifdef WII_BUILD
|
#ifdef WII_BUILD
|
||||||
setup_controllers();
|
WPAD_ScanPads();
|
||||||
WPADData wpad;
|
WPADData *wpad;
|
||||||
WPAD_Read(0, &wpad);
|
wpad = WPAD_Data(0);
|
||||||
if(isClassicAvailable)
|
int b = wpad->exp.classic.btns;
|
||||||
{
|
unsigned short b1 = wpad->btns_d;
|
||||||
int b = wpad.exp.classic.btns;
|
if (isClassicAvailable){
|
||||||
if (b & CLASSIC_CTRL_BUTTON_DOWN){
|
if (b & CLASSIC_CTRL_BUTTON_DOWN){
|
||||||
do_DOWN = 1;
|
do_DOWN = 1;
|
||||||
do{WPAD_Read(0, &wpad); b = wpad.exp.classic.btns;}while(b & CLASSIC_CTRL_BUTTON_DOWN);
|
do{WPAD_ScanPads(); wpad = WPAD_Data(0);}
|
||||||
|
while (WPAD_ButtonsHeld(0));
|
||||||
}
|
}
|
||||||
else if (b & CLASSIC_CTRL_BUTTON_UP){
|
else if (b & CLASSIC_CTRL_BUTTON_UP){
|
||||||
do_UP = 1;
|
do_UP = 1;
|
||||||
do{WPAD_Read(0, &wpad); b = wpad.exp.classic.btns;}while(b & CLASSIC_CTRL_BUTTON_UP);
|
do{WPAD_ScanPads(); wpad = WPAD_Data(0);}
|
||||||
|
while (WPAD_ButtonsHeld(0));
|
||||||
}
|
}
|
||||||
else if (b & CLASSIC_CTRL_BUTTON_A){
|
else if (b & CLASSIC_CTRL_BUTTON_A){
|
||||||
do_A = 1;
|
do_A = 1;
|
||||||
do{WPAD_Read(0, &wpad); b = wpad.exp.classic.btns;}while(b & CLASSIC_CTRL_BUTTON_A);
|
do{WPAD_ScanPads(); wpad = WPAD_Data(0);}
|
||||||
|
while (WPAD_ButtonsHeld(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(isWiimoteAvailable)
|
if (isWiimoteAvailable){
|
||||||
{
|
if (b1 & WPAD_BUTTON_LEFT){
|
||||||
unsigned short b = wpad.btns_d;
|
|
||||||
if(b & WPAD_BUTTON_LEFT){
|
|
||||||
do_DOWN = 1;
|
do_DOWN = 1;
|
||||||
do{WPAD_Read(0, &wpad); b = wpad.btns_d;}while(b & WPAD_BUTTON_LEFT);
|
do{WPAD_ScanPads(); wpad = WPAD_Data(0);}
|
||||||
|
while (WPAD_ButtonsHeld(0));
|
||||||
}
|
}
|
||||||
else if (b & WPAD_BUTTON_RIGHT){
|
else if (b1 & WPAD_BUTTON_RIGHT){
|
||||||
do_UP = 1;
|
do_UP = 1;
|
||||||
do{WPAD_Read(0, &wpad); b = wpad.btns_d;}while(b & WPAD_BUTTON_RIGHT);
|
do{WPAD_ScanPads(); wpad = WPAD_Data(0);}
|
||||||
|
while (WPAD_ButtonsHeld(0));
|
||||||
}
|
}
|
||||||
else if (b & WPAD_BUTTON_2){
|
else if (b1 & WPAD_BUTTON_2){
|
||||||
do_A = 1;
|
do_A = 1;
|
||||||
do{WPAD_Read(0, &wpad); b = wpad.btns_d;}while(b & WPAD_BUTTON_2);
|
do{WPAD_ScanPads(); wpad = WPAD_Data(0);}
|
||||||
|
while (WPAD_ButtonsHeld(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -23,18 +23,15 @@ extern int isClassicAvailable;
|
|||||||
extern int isWiimoteAvailable;
|
extern int isWiimoteAvailable;
|
||||||
|
|
||||||
void setup_controllers()
|
void setup_controllers()
|
||||||
{
|
{ /* Doesn't work, either always returns
|
||||||
WPADData wpad;
|
WiimoteAvailable or switches REALLY fast
|
||||||
WPAD_Read(0, &wpad);
|
between the two. WTF.
|
||||||
// User will have to use a GC controller
|
|
||||||
if(wpad.err == WPAD_ERR_NO_CONTROLLER)
|
WPAD_ScanPads();
|
||||||
{
|
WPADData pad;
|
||||||
isClassicAvailable = 0;
|
WPAD_ReadEvent(0, &pad);
|
||||||
isWiimoteAvailable = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// User can use just wiimote
|
// User can use just wiimote
|
||||||
if(wpad.err == WPAD_ERR_NONE && wpad.exp.type == WPAD_EXP_NONE)
|
if(pad.exp.type == WPAD_EXP_NONE)
|
||||||
{
|
{
|
||||||
isClassicAvailable = 0;
|
isClassicAvailable = 0;
|
||||||
isWiimoteAvailable = 1;
|
isWiimoteAvailable = 1;
|
||||||
@ -42,13 +39,23 @@ void setup_controllers()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// User can use a Classic controller
|
// User can use a Classic controller
|
||||||
if(wpad.err == WPAD_ERR_NONE && wpad.exp.type == WPAD_EXP_CLASSIC)
|
else if(pad.exp.type == WPAD_EXP_CLASSIC)
|
||||||
{
|
{
|
||||||
isClassicAvailable = 1;
|
isClassicAvailable = 1;
|
||||||
WPAD_SetDataFormat(0, WPAD_FMT_CORE);
|
WPAD_SetDataFormat(0, WPAD_FMT_BTNS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// User will have to use a GC controller
|
||||||
|
else
|
||||||
|
{
|
||||||
|
isClassicAvailable = 0;
|
||||||
|
isWiimoteAvailable = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
isClassicAvailable = 1;
|
||||||
|
isWiimoteAvailable = 1;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -186,10 +193,7 @@ Initialise (void)
|
|||||||
CONF_Init();
|
CONF_Init();
|
||||||
WPAD_Init();
|
WPAD_Init();
|
||||||
#endif
|
#endif
|
||||||
vmode = &TVNtsc480IntDf;
|
vmode = VIDEO_GetPreferredMode(NULL);
|
||||||
|
|
||||||
/*** Let libogc configure the mode ***/
|
|
||||||
VIDEO_Configure (vmode);
|
|
||||||
|
|
||||||
/*** Now configure the framebuffer.
|
/*** Now configure the framebuffer.
|
||||||
Really a framebuffer is just a chunk of memory
|
Really a framebuffer is just a chunk of memory
|
||||||
@ -206,6 +210,9 @@ Initialise (void)
|
|||||||
console_init (xfb[0], 20, 64, vmode->fbWidth, vmode->xfbHeight,
|
console_init (xfb[0], 20, 64, vmode->fbWidth, vmode->xfbHeight,
|
||||||
vmode->fbWidth * 2);
|
vmode->fbWidth * 2);
|
||||||
|
|
||||||
|
/*** Let libogc configure the mode ***/
|
||||||
|
VIDEO_Configure (vmode);
|
||||||
|
|
||||||
/*** Clear framebuffer to black ***/
|
/*** Clear framebuffer to black ***/
|
||||||
VIDEO_ClearFrameBuffer (vmode, xfb[0], COLOR_BLACK);
|
VIDEO_ClearFrameBuffer (vmode, xfb[0], COLOR_BLACK);
|
||||||
VIDEO_ClearFrameBuffer (vmode, xfb[1], COLOR_BLACK);
|
VIDEO_ClearFrameBuffer (vmode, xfb[1], COLOR_BLACK);
|
||||||
@ -559,22 +566,23 @@ int ingameMenu() {
|
|||||||
do{buttons = PAD_ButtonsHeld(0);}while((buttons & PAD_BUTTON_A)||(buttons & PAD_BUTTON_B));
|
do{buttons = PAD_ButtonsHeld(0);}while((buttons & PAD_BUTTON_A)||(buttons & PAD_BUTTON_B));
|
||||||
//wait for user to let go of home button
|
//wait for user to let go of home button
|
||||||
#ifdef WII_BUILD
|
#ifdef WII_BUILD
|
||||||
WPADData wpad;
|
WPADData *wpad;
|
||||||
int btn;
|
int btn;
|
||||||
if(isWiimoteAvailable)
|
if(isWiimoteAvailable)
|
||||||
do{WPAD_Read(0, &wpad); btn = wpad.btns_d;}while(btn & WPAD_BUTTON_HOME);
|
do{WPAD_ScanPads(); wpad = WPAD_Data(0); btn = wpad->btns_h;}while(btn & WPAD_BUTTON_HOME);
|
||||||
if(isClassicAvailable)
|
if(isClassicAvailable)
|
||||||
do{WPAD_Read(0, &wpad); btn = wpad.exp.classic.btns;}while(btn & CLASSIC_CTRL_BUTTON_HOME);
|
do{WPAD_ScanPads(); wpad = WPAD_Data(0); btn = wpad->exp.classic.btns;}while(btn & CLASSIC_CTRL_BUTTON_HOME);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while(1){
|
while(1){
|
||||||
|
|
||||||
#ifdef WII_BUILD
|
#ifdef WII_BUILD
|
||||||
WPADData wpad;
|
WPADData *wpad;
|
||||||
WPAD_Read(0, &wpad);
|
WPAD_ScanPads();
|
||||||
|
wpad = WPAD_Data(0);
|
||||||
if (isWiimoteAvailable)
|
if (isWiimoteAvailable)
|
||||||
{
|
{
|
||||||
unsigned short b = wpad.btns_d;
|
unsigned short b = wpad->btns_h;
|
||||||
if(b & WPAD_BUTTON_MINUS){ //Reset game
|
if(b & WPAD_BUTTON_MINUS){ //Reset game
|
||||||
emulator.emuReset();
|
emulator.emuReset();
|
||||||
break;
|
break;
|
||||||
@ -588,13 +596,13 @@ int ingameMenu() {
|
|||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
if(b & WPAD_BUTTON_HOME) { //Resume play
|
if(b & WPAD_BUTTON_HOME) { //Resume play
|
||||||
do{WPAD_Read(0, &wpad); b = wpad.btns_d;}while(b & WPAD_BUTTON_HOME); //wait for home
|
do{WPAD_ScanPads(); wpad = WPAD_Data(0); b = wpad->btns_h;}while(b & WPAD_BUTTON_HOME); //wait for home
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isClassicAvailable)
|
if (isClassicAvailable)
|
||||||
{
|
{
|
||||||
int b = wpad.exp.classic.btns;
|
int b = wpad->exp.classic.btns;
|
||||||
if(b & CLASSIC_CTRL_BUTTON_MINUS){ //Reset game
|
if(b & CLASSIC_CTRL_BUTTON_MINUS){ //Reset game
|
||||||
emulator.emuReset();
|
emulator.emuReset();
|
||||||
break;
|
break;
|
||||||
@ -608,7 +616,8 @@ int ingameMenu() {
|
|||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
if(b & CLASSIC_CTRL_BUTTON_HOME) { //Resume play
|
if(b & CLASSIC_CTRL_BUTTON_HOME) { //Resume play
|
||||||
do{WPAD_Read(0, &wpad);}while(wpad.exp.classic.btns & CLASSIC_CTRL_BUTTON_HOME); //wait for home button
|
do{WPAD_ScanPads(); wpad = WPAD_Data(0); b = wpad->exp.classic.btns;}
|
||||||
|
while(b & CLASSIC_CTRL_BUTTON_HOME); //wait for home button
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
220
src/zutil.h
220
src/zutil.h
@ -1,220 +0,0 @@
|
|||||||
/* zutil.h -- internal interface and configuration of the compression library
|
|
||||||
* Copyright (C) 1995-1998 Jean-loup Gailly.
|
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* WARNING: this file should *not* be used by applications. It is
|
|
||||||
part of the implementation of the compression library and is
|
|
||||||
subject to change. Applications should only use zlib.h.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* @(#) $Id: zutil.h,v 1.2 2004/01/17 23:07:32 kxu Exp $ */
|
|
||||||
|
|
||||||
#ifndef _Z_UTIL_H
|
|
||||||
#define _Z_UTIL_H
|
|
||||||
|
|
||||||
#include <zlib.h>
|
|
||||||
|
|
||||||
#ifdef STDC
|
|
||||||
# include <stddef.h>
|
|
||||||
# include <string.h>
|
|
||||||
# include <stdlib.h>
|
|
||||||
#endif
|
|
||||||
#ifdef NO_ERRNO_H
|
|
||||||
extern int errno;
|
|
||||||
#else
|
|
||||||
# include <errno.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef local
|
|
||||||
# define local static
|
|
||||||
#endif
|
|
||||||
/* compile with -Dlocal if your debugger can't find static symbols */
|
|
||||||
|
|
||||||
typedef unsigned char uch;
|
|
||||||
typedef uch FAR uchf;
|
|
||||||
typedef unsigned short ush;
|
|
||||||
typedef ush FAR ushf;
|
|
||||||
typedef unsigned long ulg;
|
|
||||||
|
|
||||||
extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
|
|
||||||
/* (size given to avoid silly warnings with Visual C++) */
|
|
||||||
|
|
||||||
#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
|
|
||||||
|
|
||||||
#define ERR_RETURN(strm,err) \
|
|
||||||
return (strm->msg = (char*)ERR_MSG(err), (err))
|
|
||||||
/* To be used only when the state is known to be valid */
|
|
||||||
|
|
||||||
/* common constants */
|
|
||||||
|
|
||||||
#ifndef DEF_WBITS
|
|
||||||
# define DEF_WBITS MAX_WBITS
|
|
||||||
#endif
|
|
||||||
/* default windowBits for decompression. MAX_WBITS is for compression only */
|
|
||||||
|
|
||||||
#if MAX_MEM_LEVEL >= 8
|
|
||||||
# define DEF_MEM_LEVEL 8
|
|
||||||
#else
|
|
||||||
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
|
|
||||||
#endif
|
|
||||||
/* default memLevel */
|
|
||||||
|
|
||||||
#define STORED_BLOCK 0
|
|
||||||
#define STATIC_TREES 1
|
|
||||||
#define DYN_TREES 2
|
|
||||||
/* The three kinds of block type */
|
|
||||||
|
|
||||||
#define MIN_MATCH 3
|
|
||||||
#define MAX_MATCH 258
|
|
||||||
/* The minimum and maximum match lengths */
|
|
||||||
|
|
||||||
#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
|
|
||||||
|
|
||||||
/* target dependencies */
|
|
||||||
|
|
||||||
#ifdef MSDOS
|
|
||||||
# define OS_CODE 0x00
|
|
||||||
# if defined(__TURBOC__) || defined(__BORLANDC__)
|
|
||||||
# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
|
|
||||||
/* Allow compilation with ANSI keywords only enabled */
|
|
||||||
void _Cdecl farfree( void *block );
|
|
||||||
void *_Cdecl farmalloc( unsigned long nbytes );
|
|
||||||
# else
|
|
||||||
# include <alloc.h>
|
|
||||||
# endif
|
|
||||||
# else /* MSC or DJGPP */
|
|
||||||
# include <malloc.h>
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef OS2
|
|
||||||
# define OS_CODE 0x06
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef WIN32 /* Window 95 & Windows NT */
|
|
||||||
# define OS_CODE 0x0b
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(VAXC) || defined(VMS)
|
|
||||||
# define OS_CODE 0x02
|
|
||||||
# define F_OPEN(name, mode) \
|
|
||||||
fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef AMIGA
|
|
||||||
# define OS_CODE 0x01
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(ATARI) || defined(atarist)
|
|
||||||
# define OS_CODE 0x05
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(MACOS) || defined(TARGET_OS_MAC)
|
|
||||||
# define OS_CODE 0x07
|
|
||||||
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
|
|
||||||
# include <unix.h> /* for fdopen */
|
|
||||||
# else
|
|
||||||
# ifndef fdopen
|
|
||||||
# define fdopen(fd,mode) NULL /* No fdopen() */
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __50SERIES /* Prime/PRIMOS */
|
|
||||||
# define OS_CODE 0x0F
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef TOPS20
|
|
||||||
# define OS_CODE 0x0a
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(_BEOS_) || defined(RISCOS)
|
|
||||||
# define fdopen(fd,mode) NULL /* No fdopen() */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (defined(_MSC_VER) && (_MSC_VER > 600))
|
|
||||||
# define fdopen(fd,type) _fdopen(fd,type)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* Common defaults */
|
|
||||||
|
|
||||||
#ifndef OS_CODE
|
|
||||||
# define OS_CODE 0x03 /* assume Unix */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef F_OPEN
|
|
||||||
# define F_OPEN(name, mode) fopen((name), (mode))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* functions */
|
|
||||||
|
|
||||||
#ifdef HAVE_STRERROR
|
|
||||||
extern char *strerror OF((int));
|
|
||||||
# define zstrerror(errnum) strerror(errnum)
|
|
||||||
#else
|
|
||||||
# define zstrerror(errnum) ""
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(pyr)
|
|
||||||
# define NO_MEMCPY
|
|
||||||
#endif
|
|
||||||
#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
|
|
||||||
/* Use our own functions for small and medium model with MSC <= 5.0.
|
|
||||||
* You may have to use the same strategy for Borland C (untested).
|
|
||||||
* The __SC__ check is for Symantec.
|
|
||||||
*/
|
|
||||||
# define NO_MEMCPY
|
|
||||||
#endif
|
|
||||||
#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
|
|
||||||
# define HAVE_MEMCPY
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_MEMCPY
|
|
||||||
# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
|
|
||||||
# define zmemcpy _fmemcpy
|
|
||||||
# define zmemcmp _fmemcmp
|
|
||||||
# define zmemzero(dest, len) _fmemset(dest, 0, len)
|
|
||||||
# else
|
|
||||||
# define zmemcpy memcpy
|
|
||||||
# define zmemcmp memcmp
|
|
||||||
# define zmemzero(dest, len) memset(dest, 0, len)
|
|
||||||
# endif
|
|
||||||
#else
|
|
||||||
extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
|
|
||||||
extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
|
|
||||||
extern void zmemzero OF((Bytef* dest, uInt len));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Diagnostic functions */
|
|
||||||
#ifdef DEBUG
|
|
||||||
# include <stdio.h>
|
|
||||||
extern int z_verbose;
|
|
||||||
extern void z_error OF((char *m));
|
|
||||||
# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
|
|
||||||
# define Trace(x) {if (z_verbose>=0) fprintf x ;}
|
|
||||||
# define Tracev(x) {if (z_verbose>0) fprintf x ;}
|
|
||||||
# define Tracevv(x) {if (z_verbose>1) fprintf x ;}
|
|
||||||
# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
|
|
||||||
# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
|
|
||||||
#else
|
|
||||||
# define Assert(cond,msg)
|
|
||||||
# define Trace(x)
|
|
||||||
# define Tracev(x)
|
|
||||||
# define Tracevv(x)
|
|
||||||
# define Tracec(c,x)
|
|
||||||
# define Tracecv(c,x)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
typedef uLong (ZEXPORT *check_func) OF((uLong check, const Bytef *buf,
|
|
||||||
uInt len));
|
|
||||||
voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
|
|
||||||
void zcfree OF((voidpf opaque, voidpf ptr));
|
|
||||||
|
|
||||||
#define ZALLOC(strm, items, size) \
|
|
||||||
(*((strm)->zalloc))((strm)->opaque, (items), (size))
|
|
||||||
#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
|
|
||||||
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
|
|
||||||
|
|
||||||
#endif /* _Z_UTIL_H */
|
|
Loading…
Reference in New Issue
Block a user