mirror of
https://github.com/dborth/vbagx.git
synced 2024-11-22 10:39:18 +01:00
July 24, 2008 update by theinternetftw
This commit is contained in:
parent
5a65f55992
commit
9644c251ef
@ -38,13 +38,13 @@ bool speedup = false;
|
||||
bool synchronize = true;
|
||||
bool cpuDisableSfx = false;
|
||||
bool cpuIsMultiBoot = false;
|
||||
bool parseDebug = true;
|
||||
bool parseDebug = false;
|
||||
int layerSettings = 0xff00;
|
||||
int layerEnable = 0xff00;
|
||||
bool speedHack = false;
|
||||
int cpuSaveType = 0;
|
||||
bool cpuEnhancedDetection = true;
|
||||
bool cheatsEnabled = true;
|
||||
bool cheatsEnabled = false;
|
||||
|
||||
u8 *bios = NULL;
|
||||
u8 *rom = NULL;
|
||||
|
@ -103,7 +103,6 @@ NGCPad()
|
||||
{
|
||||
float mag,ang;
|
||||
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;
|
||||
|
||||
@ -155,8 +154,7 @@ NGCPad()
|
||||
|
||||
}
|
||||
//user needs a GC remote
|
||||
else
|
||||
{
|
||||
PAD_ScanPads();
|
||||
p = PAD_ButtonsHeld(0);
|
||||
x = PAD_StickX(0);
|
||||
y = PAD_StickY(0);
|
||||
@ -223,7 +221,7 @@ NGCPad()
|
||||
|
||||
if((p & PAD_BUTTON_X) && (p & PAD_BUTTON_Y))
|
||||
menuCalled = 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef GC_BUILD
|
||||
|
@ -44,7 +44,7 @@ static Mtx view;
|
||||
static int vwidth, vheight, oldvwidth, oldvheight;
|
||||
|
||||
#define HASPECT 80
|
||||
#define VASPECT 60
|
||||
#define VASPECT 45
|
||||
|
||||
/* New texture based scaler */
|
||||
typedef struct tagcamera
|
||||
@ -132,11 +132,11 @@ void GX_Start(int width, int height, int haspect, int vaspect)
|
||||
{
|
||||
Mtx p;
|
||||
|
||||
/*** Set new aspect ***/
|
||||
square[0] = square[9] = -haspect;
|
||||
square[3] = square[6] = haspect;
|
||||
square[1] = square[4] = vaspect;
|
||||
square[7] = square[10] = -vaspect;
|
||||
/*** Set new aspect (now with crap AR hack!) ***/
|
||||
square[0] = square[9] = (-haspect - 7);
|
||||
square[3] = square[6] = (haspect + 7);
|
||||
square[1] = square[4] = (vaspect + 7);
|
||||
square[7] = square[10] = (-vaspect - 7);
|
||||
|
||||
/*** Allocate 32byte aligned texture memory ***/
|
||||
texturesize = (width * height) * 2;
|
||||
|
@ -24,8 +24,8 @@ extern int isWiimoteAvailable;
|
||||
|
||||
void setup_controllers()
|
||||
{ /* Doesn't work, either always returns
|
||||
WiimoteAvailable or switches REALLY fast
|
||||
between the two. WTF.
|
||||
WiimoteAvailable only or apparently switches
|
||||
REALLY fast between the two. WTF.
|
||||
|
||||
WPAD_ScanPads();
|
||||
WPADData pad;
|
||||
@ -69,6 +69,7 @@ extern "C"
|
||||
{
|
||||
#include "gx_supp.h"
|
||||
#include "tbtime.h"
|
||||
#include "sdfileio.h"
|
||||
}
|
||||
|
||||
/** VBA **/
|
||||
@ -110,10 +111,13 @@ int srcHeight = 0;
|
||||
int destWidth = 0;
|
||||
int destHeight = 0;
|
||||
int srcPitch = 0;
|
||||
int saveExists = 0;
|
||||
extern int menuCalled;
|
||||
#define WITHGX 1
|
||||
#define DEBUGON 0
|
||||
|
||||
|
||||
|
||||
#if DEBUGON
|
||||
const char *dbg_local_ip = "192.168.1.32";
|
||||
const char *dbg_netmask = "255.255.255.0";
|
||||
@ -133,12 +137,7 @@ void (*dbgOutput)(char *, u32) = debuggerOutput;
|
||||
/**
|
||||
* Locals
|
||||
*/
|
||||
extern "C"
|
||||
{
|
||||
void SDInit( void );
|
||||
int gen_getdir( char *whichdir );
|
||||
};
|
||||
extern char *direntries[1000];
|
||||
|
||||
extern char *MENU_GetLoadFile( char *whichdir );
|
||||
extern void MENU_DrawString( int x, int y, char *msg, int style );
|
||||
|
||||
@ -170,6 +169,13 @@ void doScan(u32 blah)
|
||||
PAD_ScanPads();
|
||||
}
|
||||
|
||||
|
||||
int throttle = 100;
|
||||
u32 throttleLastTime = 0;
|
||||
|
||||
char filename[1024]; //rom file name
|
||||
char batfilename[1024]; //battery save file name
|
||||
char statename[1024]; //savestate file name
|
||||
/****************************************************************************
|
||||
* Initialise Video
|
||||
*
|
||||
@ -192,6 +198,7 @@ Initialise (void)
|
||||
#ifdef WII_BUILD
|
||||
CONF_Init();
|
||||
WPAD_Init();
|
||||
setup_controllers();
|
||||
#endif
|
||||
vmode = VIDEO_GetPreferredMode(NULL);
|
||||
|
||||
@ -223,11 +230,11 @@ Initialise (void)
|
||||
/*** Get the PAD status updated by libogc ***/
|
||||
VIDEO_SetPreRetraceCallback (doScan);
|
||||
VIDEO_SetBlack (0);
|
||||
|
||||
/*
|
||||
int i;
|
||||
u32 *vreg = (u32 *)0xCC002000;
|
||||
for ( i = 0; i < 64; i++ )
|
||||
vreg[i] = vpal60[i];
|
||||
vreg[i] = vpal60[i]; */
|
||||
|
||||
/*** Update the video for next vblank ***/
|
||||
VIDEO_Flush ();
|
||||
@ -242,6 +249,16 @@ void systemMessage(int num, const char *msg, ...)
|
||||
{
|
||||
/*** For now ... do nothing ***/
|
||||
}
|
||||
|
||||
void GC_Sleep(u32 dwMiliseconds)
|
||||
{
|
||||
int nVBlanks = (dwMiliseconds / 16);
|
||||
while (nVBlanks-- > 0)
|
||||
{
|
||||
VIDEO_WaitVSync();
|
||||
}
|
||||
}
|
||||
|
||||
void systemFrame()
|
||||
{}
|
||||
|
||||
@ -252,48 +269,10 @@ void systemShowSpeed(int speed)
|
||||
{}
|
||||
static u32 autoFrameSkipLastTime = 0;
|
||||
static int frameskipadjust = 0;
|
||||
void system1Frame(int rate)
|
||||
{
|
||||
/* if ( cartridgeType == 1 )
|
||||
return;
|
||||
|
||||
u32 time = systemGetClock();
|
||||
u32 diff = time - autoFrameSkipLastTime;
|
||||
int speed = 100;
|
||||
|
||||
if(diff)
|
||||
speed = (1000000/rate)/diff;
|
||||
char temp[512];
|
||||
sprintf(temp,"Speed: %i",speed);
|
||||
MENU_DrawString( -1, 450,temp , 1 );
|
||||
|
||||
if(speed >= 98)
|
||||
void write_save()
|
||||
{
|
||||
frameskipadjust++;
|
||||
|
||||
if(frameskipadjust >= 3)
|
||||
{
|
||||
frameskipadjust=0;
|
||||
if(systemFrameSkip > 0)
|
||||
systemFrameSkip--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(speed < 80)
|
||||
frameskipadjust -= (90 - speed)/5;
|
||||
else if(systemFrameSkip < 9)
|
||||
frameskipadjust--;
|
||||
|
||||
if(frameskipadjust <= -2)
|
||||
{
|
||||
frameskipadjust += 2;
|
||||
if(systemFrameSkip < 9)
|
||||
systemFrameSkip++;
|
||||
}
|
||||
}
|
||||
autoFrameSkipLastTime = time;
|
||||
*/
|
||||
emulator.emuWriteBattery(batfilename);
|
||||
}
|
||||
|
||||
void system10Frames(int rate)
|
||||
@ -309,8 +288,8 @@ void system10Frames(int rate)
|
||||
speed = (1000000/rate)/diff;
|
||||
/* char temp[512];
|
||||
sprintf(temp,"Speed: %i",speed);
|
||||
MENU_DrawString( -1, 450,temp , 1 );
|
||||
*/
|
||||
MENU_DrawString( -1, 450,temp , 1 ); */
|
||||
|
||||
if(speed >= 98)
|
||||
{
|
||||
frameskipadjust++;
|
||||
@ -336,9 +315,29 @@ void system10Frames(int rate)
|
||||
systemFrameSkip++;
|
||||
}
|
||||
}
|
||||
autoFrameSkipLastTime = time;
|
||||
|
||||
if ( cartridgeType == 1 )
|
||||
return;
|
||||
|
||||
|
||||
/*
|
||||
if(systemSaveUpdateCounter) {
|
||||
char temp[512];
|
||||
sprintf(temp,"Writing Save To Disk");
|
||||
MENU_DrawString( -1, 450,temp , 1 );
|
||||
} */
|
||||
|
||||
if(systemSaveUpdateCounter) {
|
||||
if(--systemSaveUpdateCounter <= SYSTEM_SAVE_NOT_UPDATED) {
|
||||
write_save();
|
||||
systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
|
||||
}
|
||||
}
|
||||
|
||||
autoFrameSkipLastTime = time;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void systemUpdateMotionSensor()
|
||||
{}
|
||||
@ -445,7 +444,9 @@ void systemDrawScreen()
|
||||
GX_Render( srcWidth, srcHeight, pix, srcPitch );
|
||||
#endif
|
||||
#ifdef WII_BUILD
|
||||
|
||||
VIDEO_WaitVSync ();
|
||||
|
||||
#endif
|
||||
#ifdef GC_BUILD
|
||||
if ( cartridgeType == 1 )
|
||||
@ -470,10 +471,6 @@ int ShowDir( char *whichdir )
|
||||
while(1);
|
||||
}
|
||||
|
||||
char filename[1024]; //rom file name
|
||||
char batfilename[1024]; //battery save file name
|
||||
|
||||
|
||||
/*
|
||||
Asks user to select a ROM
|
||||
*/
|
||||
@ -490,11 +487,10 @@ void chooseRom() {
|
||||
strncat(batfilename,fname,strlen(fname)-4);
|
||||
strcat(batfilename,".SAV");
|
||||
|
||||
}
|
||||
|
||||
void askSound() {
|
||||
soundOffFlag = false;
|
||||
soundLowPass = true;
|
||||
// construct savestate name
|
||||
strcpy(statename, "/VBA/SAVES/");
|
||||
strncat(statename,fname,strlen(fname)-4);
|
||||
strcat(statename,".SGM");
|
||||
}
|
||||
|
||||
/*
|
||||
@ -502,32 +498,62 @@ void askSound() {
|
||||
If it does, it prompts the user to load it or not
|
||||
*/
|
||||
void checkSave() {
|
||||
|
||||
}
|
||||
void GC_Sleep(u32 dwMiliseconds)
|
||||
{
|
||||
int nVBlanks = (dwMiliseconds / 16);
|
||||
while (nVBlanks-- > 0)
|
||||
{
|
||||
VIDEO_WaitVSync();
|
||||
}
|
||||
}
|
||||
void write_save()
|
||||
{
|
||||
VIDEO_ClearFrameBuffer (vmode, xfb[whichfb], COLOR_BLACK);
|
||||
MENU_DrawString( -1, 250,"Attempting to Save data ..." , 1 );
|
||||
FILE* f = gen_fopen(statename, "rb");
|
||||
if (f != NULL) {
|
||||
gen_fclose(f);
|
||||
whichfb^=1;
|
||||
VIDEO_ClearFrameBuffer (vmode, xfb[whichfb], COLOR_BLACK);
|
||||
if(emulator.emuWriteBattery(batfilename) == true)
|
||||
MENU_DrawString( -1, 250,"Save OK!" , 1 );
|
||||
else
|
||||
MENU_DrawString( -1, 250,"Either no data to save yet or error!" , 1 );
|
||||
MENU_DrawString( 140, 50,"Quick Save State Exists" , 1 );
|
||||
MENU_DrawString( 140, 80,"Do you wish to load it?" , 1 );
|
||||
MENU_DrawString( -1, 170,"(L) or (+) YES" , 1 );
|
||||
MENU_DrawString( -1, 200,"(R) or (-) NO" , 1 );
|
||||
VIDEO_WaitVSync ();
|
||||
VIDEO_SetNextFramebuffer(xfb[whichfb]);
|
||||
VIDEO_Flush();
|
||||
GC_Sleep(2000);
|
||||
|
||||
VIDEO_WaitVSync();
|
||||
while(1) {
|
||||
WPADData *wpad;
|
||||
WPAD_ScanPads();
|
||||
wpad = WPAD_Data(0);
|
||||
if (isWiimoteAvailable) {
|
||||
unsigned short b = wpad->btns_h;
|
||||
if(b & WPAD_BUTTON_PLUS) {
|
||||
saveExists = 1;
|
||||
break;
|
||||
}
|
||||
if(b & WPAD_BUTTON_MINUS) break;
|
||||
}
|
||||
if (isClassicAvailable) {
|
||||
unsigned short b = wpad->exp.classic.btns;
|
||||
if(b & CLASSIC_CTRL_BUTTON_PLUS) {
|
||||
saveExists = 1;
|
||||
break;
|
||||
}
|
||||
if(b & CLASSIC_CTRL_BUTTON_MINUS) break;
|
||||
}
|
||||
u16 buttons = PAD_ButtonsHeld(0);
|
||||
if(buttons & PAD_TRIGGER_R){
|
||||
break;
|
||||
}
|
||||
if(buttons & PAD_TRIGGER_L){
|
||||
saveExists = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
VIDEO_ClearFrameBuffer (vmode, xfb[whichfb], COLOR_BLACK);
|
||||
VIDEO_WaitVSync ();
|
||||
VIDEO_SetNextFramebuffer(xfb[whichfb]);
|
||||
VIDEO_Flush();
|
||||
VIDEO_WaitVSync();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void askSound() {
|
||||
soundOffFlag = false;
|
||||
soundLowPass = true;
|
||||
}
|
||||
|
||||
|
||||
int ingameMenu() {
|
||||
tb_t start,end;
|
||||
@ -542,14 +568,14 @@ int ingameMenu() {
|
||||
#ifdef GC_BUILD
|
||||
MENU_DrawString( 140, 80,"Nintendo Gamecube Port" , 1 );
|
||||
MENU_DrawString( -1, 170,"(B) - Resume play" , 1 );
|
||||
MENU_DrawString( -1, 200,"(L) - Write save" , 1 );
|
||||
MENU_DrawString( -1, 200,"(L) - Write Quicksave" , 1 );
|
||||
MENU_DrawString( -1, 230,"(R) - Reset game" , 1 );
|
||||
MENU_DrawString( -1, 320,"(Z) - Return to loader" , 1 );
|
||||
#endif
|
||||
#ifdef WII_BUILD
|
||||
MENU_DrawString( 140, 80,"Nintendo Wii Port" , 1 );
|
||||
MENU_DrawString( -1, 170,"(B) or (Home) - Resume play" , 1 );
|
||||
MENU_DrawString( -1, 200,"(L) or (+) - Write save" , 1 );
|
||||
MENU_DrawString( -1, 200,"(L) or (+) - Write Quicksave" , 1 );
|
||||
MENU_DrawString( -1, 230,"(R) or (-) - Reset game" , 1 );
|
||||
MENU_DrawString( -1, 320,"(Z) or (A+B) - Return to loader" , 1 );
|
||||
#endif
|
||||
@ -563,15 +589,18 @@ int ingameMenu() {
|
||||
VIDEO_WaitVSync();
|
||||
|
||||
//wait for user to let go of menu calling button
|
||||
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
|
||||
#ifdef WII_BUILD
|
||||
WPADData *wpad;
|
||||
int btn;
|
||||
if(isWiimoteAvailable)
|
||||
do{WPAD_ScanPads(); wpad = WPAD_Data(0); btn = wpad->btns_h;}while(btn & WPAD_BUTTON_HOME);
|
||||
do{WPAD_ScanPads(); wpad = WPAD_Data(0); btn = wpad->btns_h;}
|
||||
while(btn & WPAD_BUTTON_HOME);
|
||||
if(isClassicAvailable)
|
||||
do{WPAD_ScanPads(); wpad = WPAD_Data(0); 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
|
||||
|
||||
while(1){
|
||||
@ -588,7 +617,8 @@ int ingameMenu() {
|
||||
break;
|
||||
}
|
||||
if(b & WPAD_BUTTON_PLUS) { //Write save
|
||||
write_save();
|
||||
emulator.emuWriteState(statename);
|
||||
GC_Sleep(1500);
|
||||
break;
|
||||
}
|
||||
if((b & WPAD_BUTTON_A) && (b & WPAD_BUTTON_B)) { //Return to loader
|
||||
@ -596,9 +626,13 @@ int ingameMenu() {
|
||||
reload();
|
||||
}
|
||||
if(b & WPAD_BUTTON_HOME) { //Resume play
|
||||
do{WPAD_ScanPads(); wpad = WPAD_Data(0); b = wpad->btns_h;}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;
|
||||
}
|
||||
/* if(b & WPAD_BUTTON_2) { //back to menu
|
||||
INSERT BACK-TO-MENU HERE
|
||||
} */
|
||||
}
|
||||
if (isClassicAvailable)
|
||||
{
|
||||
@ -608,7 +642,7 @@ int ingameMenu() {
|
||||
break;
|
||||
}
|
||||
if(b & CLASSIC_CTRL_BUTTON_PLUS) { //Write save
|
||||
write_save();
|
||||
emulator.emuWriteState(statename);
|
||||
break;
|
||||
}
|
||||
if((b & CLASSIC_CTRL_BUTTON_A) && (b & CLASSIC_CTRL_BUTTON_B)) { //Return to loader
|
||||
@ -630,7 +664,7 @@ int ingameMenu() {
|
||||
break;
|
||||
}
|
||||
if(buttons & PAD_TRIGGER_L) { //Write save
|
||||
write_save();
|
||||
emulator.emuWriteState(statename);
|
||||
break;
|
||||
}
|
||||
if(buttons & PAD_TRIGGER_Z) { //Return to loader
|
||||
@ -645,9 +679,9 @@ int ingameMenu() {
|
||||
mftb(&end);
|
||||
loadtimeradjust += tb_diff_msec(&end, &start);
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* main
|
||||
*
|
||||
@ -668,6 +702,7 @@ int main()
|
||||
/** Kick off SD Lib **/
|
||||
SDInit();
|
||||
|
||||
|
||||
/** Build GBPalette **/
|
||||
for( i = 0; i < 24; )
|
||||
{
|
||||
@ -688,9 +723,6 @@ int main()
|
||||
(((i & 0x7c00) >> 10) << systemBlueShift);
|
||||
}
|
||||
|
||||
#ifdef WII_BUILD
|
||||
setup_controllers();
|
||||
#endif
|
||||
//Main loop
|
||||
while(1) {
|
||||
cartridgeType = 0;
|
||||
@ -701,14 +733,14 @@ int main()
|
||||
srcPitch = 0;
|
||||
|
||||
chooseRom();
|
||||
//checkSave();
|
||||
checkSave();
|
||||
|
||||
IMAGE_TYPE type = utilFindType(filename);
|
||||
|
||||
switch( type )
|
||||
{
|
||||
case IMAGE_GBA:
|
||||
// printf("GameBoy Advance Image\n");
|
||||
printf("GameBoy Advance Image\n");
|
||||
cartridgeType = 2;
|
||||
emulator = GBASystem;
|
||||
srcWidth = 240;
|
||||
@ -724,7 +756,7 @@ int main()
|
||||
break;
|
||||
|
||||
case IMAGE_GB:
|
||||
// printf("GameBoy Image\n");
|
||||
printf("GameBoy Image\n");
|
||||
cartridgeType = 1;
|
||||
emulator = GBSystem;
|
||||
srcWidth = 160;
|
||||
@ -739,7 +771,7 @@ int main()
|
||||
break;
|
||||
|
||||
default:
|
||||
// printf("Unknown Image\n");
|
||||
printf("Unknown Image\n");
|
||||
while(1);
|
||||
break;
|
||||
|
||||
@ -756,6 +788,8 @@ int main()
|
||||
GX_Start( srcWidth, srcHeight, hAspect, vAspect );
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
if ( cartridgeType == 1 )
|
||||
{
|
||||
gbSoundReset();
|
||||
@ -768,6 +802,12 @@ int main()
|
||||
CPUReset();
|
||||
}
|
||||
|
||||
emulator.emuReadBattery(batfilename);
|
||||
if (saveExists){
|
||||
emulator.emuReadState(statename);
|
||||
saveExists = 0;
|
||||
}
|
||||
|
||||
soundVolume = 0;
|
||||
systemSoundOn = true;
|
||||
|
||||
@ -778,7 +818,6 @@ int main()
|
||||
/** Start system clock **/
|
||||
mftb(&start);
|
||||
|
||||
emulator.emuReadBattery(batfilename);
|
||||
while ( emulating )
|
||||
{
|
||||
emulator.emuMain(emulator.emuCount);
|
||||
@ -788,7 +827,6 @@ int main()
|
||||
menuCalled = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Never **/
|
||||
|
220
src/zutil.h
Normal file
220
src/zutil.h
Normal file
@ -0,0 +1,220 @@
|
||||
/* 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