mirror of
https://github.com/dborth/vbagx.git
synced 2024-11-26 04:24:16 +01:00
July 14, 2008 update by theinternetftw
This commit is contained in:
parent
64546f8550
commit
5a65f55992
@ -1,289 +1,304 @@
|
||||
/****************************************************************************
|
||||
* VisualBoyAdvance 1.7.2
|
||||
*
|
||||
* Nintendo GameCube Joypad Wrapper
|
||||
****************************************************************************/
|
||||
#include <gccore.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#define VBA_BUTTON_A 1
|
||||
#define VBA_BUTTON_B 2
|
||||
#define VBA_BUTTON_SELECT 4
|
||||
#define VBA_BUTTON_START 8
|
||||
#define VBA_RIGHT 16
|
||||
#define VBA_LEFT 32
|
||||
#define VBA_UP 64
|
||||
#define VBA_DOWN 128
|
||||
#define VBA_BUTTON_R 256
|
||||
#define VBA_BUTTON_L 512
|
||||
#define VBA_SPEED 1024
|
||||
#define VBA_CAPTURE 2048
|
||||
|
||||
#ifdef WII_BUILD
|
||||
#include <math.h>
|
||||
#include <wiiuse/wpad.h>
|
||||
int isClassicAvailable = 0;
|
||||
int isWiimoteAvailable = 0;
|
||||
/*
|
||||
#ifndef PI
|
||||
#define PI 3.14159f
|
||||
#endif
|
||||
|
||||
enum { STICK_X, STICK_Y };
|
||||
static int getStickValue(joystick_t* j, int axis, int maxAbsValue){
|
||||
double angle = PI * j->ang/180.0f;
|
||||
double magnitude = (j->mag > 1.0f) ? 1.0f :
|
||||
(j->mag < -1.0f) ? -1.0f : j->mag;
|
||||
double value;
|
||||
if(axis == STICK_X)
|
||||
value = magnitude * sin( angle );
|
||||
else
|
||||
value = magnitude * cos( angle );
|
||||
return (int)(value * maxAbsValue);
|
||||
}*/
|
||||
|
||||
#endif
|
||||
int menuCalled = 0;
|
||||
u32
|
||||
NGCPad()
|
||||
{
|
||||
u32 res = 0;
|
||||
short p;
|
||||
signed char x,
|
||||
y;
|
||||
int padcal = 90;
|
||||
float t;
|
||||
|
||||
|
||||
#ifdef WII_BUILD
|
||||
//wiimote
|
||||
if(isWiimoteAvailable)
|
||||
{
|
||||
WPADData wpad;
|
||||
WPAD_Read(0, &wpad);
|
||||
unsigned short b = wpad.btns_d;
|
||||
|
||||
if (b & WPAD_BUTTON_2)
|
||||
res |= VBA_BUTTON_A;
|
||||
|
||||
if (b & WPAD_BUTTON_1)
|
||||
res |= VBA_BUTTON_B;
|
||||
|
||||
if (b & WPAD_BUTTON_MINUS)
|
||||
res |= VBA_BUTTON_SELECT;
|
||||
|
||||
if (b & WPAD_BUTTON_PLUS)
|
||||
res |= VBA_BUTTON_START;
|
||||
|
||||
if (b & WPAD_BUTTON_RIGHT)
|
||||
res |= VBA_UP;
|
||||
|
||||
if (b & WPAD_BUTTON_LEFT)
|
||||
res |= VBA_DOWN;
|
||||
|
||||
if (b & WPAD_BUTTON_UP)
|
||||
res |= VBA_LEFT;
|
||||
|
||||
if (b & WPAD_BUTTON_DOWN)
|
||||
res |= VBA_RIGHT;
|
||||
|
||||
if (b & WPAD_BUTTON_A)
|
||||
res |= VBA_BUTTON_L;
|
||||
|
||||
if (b & WPAD_BUTTON_B)
|
||||
res |= VBA_BUTTON_R;
|
||||
|
||||
if (b & WPAD_BUTTON_HOME)
|
||||
menuCalled = 1;
|
||||
}
|
||||
//classic controller
|
||||
if(isClassicAvailable)
|
||||
{
|
||||
WPADData wpad;
|
||||
WPAD_Read(0, &wpad);
|
||||
int b = wpad.exp.classic.btns;
|
||||
int x_s = 0; //getStickValue(&wpad.exp.classic.ljs, STICK_X, 127);
|
||||
int y_s = 0; //getStickValue(&wpad.exp.classic.ljs, STICK_Y, 127);
|
||||
if (b & CLASSIC_CTRL_BUTTON_A)
|
||||
res |= VBA_BUTTON_A;
|
||||
|
||||
if (b & CLASSIC_CTRL_BUTTON_B)
|
||||
res |= VBA_BUTTON_B;
|
||||
|
||||
if (b & CLASSIC_CTRL_BUTTON_MINUS)
|
||||
res |= VBA_BUTTON_SELECT;
|
||||
|
||||
if (b & CLASSIC_CTRL_BUTTON_PLUS)
|
||||
res |= VBA_BUTTON_START;
|
||||
|
||||
if ((b & CLASSIC_CTRL_BUTTON_UP) || (y_s > 0))
|
||||
res |= VBA_UP;
|
||||
|
||||
if ((b & CLASSIC_CTRL_BUTTON_DOWN) || (y_s < 0))
|
||||
res |= VBA_DOWN;
|
||||
|
||||
if ((b & CLASSIC_CTRL_BUTTON_LEFT) || (x_s < 0))
|
||||
res |= VBA_LEFT;
|
||||
|
||||
if ((b & CLASSIC_CTRL_BUTTON_RIGHT) || (x_s > 0))
|
||||
res |= VBA_RIGHT;
|
||||
|
||||
if (b & CLASSIC_CTRL_BUTTON_FULL_L)
|
||||
res |= VBA_BUTTON_L;
|
||||
|
||||
if (b & CLASSIC_CTRL_BUTTON_FULL_R)
|
||||
res |= VBA_BUTTON_R;
|
||||
|
||||
if (b & CLASSIC_CTRL_BUTTON_HOME)
|
||||
menuCalled = 1;
|
||||
|
||||
}
|
||||
//user needs a GC remote
|
||||
else if((!(isWiimoteAvailable)) && (!(isClassicAvailable)))
|
||||
{
|
||||
p = PAD_ButtonsHeld(0);
|
||||
x = PAD_StickX(0);
|
||||
y = PAD_StickY(0);
|
||||
if (x * x + y * y > padcal * padcal)
|
||||
{
|
||||
if (x > 0 && y == 0)
|
||||
res |= VBA_RIGHT;
|
||||
if (x < 0 && y == 0)
|
||||
res |= VBA_LEFT;
|
||||
if (x == 0 && y > 0)
|
||||
res |= VBA_UP;
|
||||
if (x == 0 && y < 0)
|
||||
res |= VBA_DOWN;
|
||||
|
||||
/*** Recalc left / right ***/
|
||||
t = (float) y / x;
|
||||
if (t >= -2.41421356237 && t < 2.41421356237)
|
||||
{
|
||||
if (x >= 0)
|
||||
res |= VBA_RIGHT;
|
||||
else
|
||||
res |= VBA_LEFT;
|
||||
}
|
||||
|
||||
/*** Recalc up / down ***/
|
||||
t = (float) x / y;
|
||||
if (t >= -2.41421356237 && t < 2.41421356237)
|
||||
{
|
||||
if (y >= 0)
|
||||
res |= VBA_UP;
|
||||
else
|
||||
res |= VBA_DOWN;
|
||||
}
|
||||
}
|
||||
if (p & PAD_BUTTON_A)
|
||||
res |= VBA_BUTTON_A;
|
||||
|
||||
if (p & PAD_BUTTON_B)
|
||||
res |= VBA_BUTTON_B;
|
||||
|
||||
if (p & PAD_TRIGGER_Z)
|
||||
res |= VBA_BUTTON_SELECT;
|
||||
|
||||
if (p & PAD_BUTTON_START)
|
||||
res |= VBA_BUTTON_START;
|
||||
|
||||
if (p & PAD_BUTTON_UP)
|
||||
res |= VBA_UP;
|
||||
|
||||
if (p & PAD_BUTTON_DOWN)
|
||||
res |= VBA_DOWN;
|
||||
|
||||
if (p & PAD_BUTTON_LEFT)
|
||||
res |= VBA_LEFT;
|
||||
|
||||
if (p & PAD_BUTTON_RIGHT)
|
||||
res |= VBA_RIGHT;
|
||||
|
||||
if (p & PAD_TRIGGER_L)
|
||||
res |= VBA_BUTTON_L;
|
||||
|
||||
if (p & PAD_TRIGGER_R)
|
||||
res |= VBA_BUTTON_R;
|
||||
|
||||
if((p & PAD_BUTTON_X) && (p & PAD_BUTTON_Y))
|
||||
menuCalled = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef GC_BUILD
|
||||
p = PAD_ButtonsHeld(0);
|
||||
x = PAD_StickX(0);
|
||||
y = PAD_StickY(0);
|
||||
if (x * x + y * y > padcal * padcal)
|
||||
{
|
||||
if (x > 0 && y == 0)
|
||||
res |= VBA_RIGHT;
|
||||
if (x < 0 && y == 0)
|
||||
res |= VBA_LEFT;
|
||||
if (x == 0 && y > 0)
|
||||
res |= VBA_UP;
|
||||
if (x == 0 && y < 0)
|
||||
res |= VBA_DOWN;
|
||||
|
||||
/*** Recalc left / right ***/
|
||||
t = (float) y / x;
|
||||
if (t >= -2.41421356237 && t < 2.41421356237)
|
||||
{
|
||||
if (x >= 0)
|
||||
res |= VBA_RIGHT;
|
||||
else
|
||||
res |= VBA_LEFT;
|
||||
}
|
||||
|
||||
/*** Recalc up / down ***/
|
||||
t = (float) x / y;
|
||||
if (t >= -2.41421356237 && t < 2.41421356237)
|
||||
{
|
||||
if (y >= 0)
|
||||
res |= VBA_UP;
|
||||
else
|
||||
res |= VBA_DOWN;
|
||||
}
|
||||
}
|
||||
if (p & PAD_BUTTON_A)
|
||||
res |= VBA_BUTTON_A;
|
||||
|
||||
if (p & PAD_BUTTON_B)
|
||||
res |= VBA_BUTTON_B;
|
||||
|
||||
if (p & PAD_TRIGGER_Z)
|
||||
res |= VBA_BUTTON_SELECT;
|
||||
|
||||
if (p & PAD_BUTTON_START)
|
||||
res |= VBA_BUTTON_START;
|
||||
|
||||
if ((p & PAD_BUTTON_UP))
|
||||
res |= VBA_UP;
|
||||
|
||||
if ((p & PAD_BUTTON_DOWN))
|
||||
res |= VBA_DOWN;
|
||||
|
||||
if ((p & PAD_BUTTON_LEFT))
|
||||
res |= VBA_LEFT;
|
||||
|
||||
if ((p & PAD_BUTTON_RIGHT))
|
||||
res |= VBA_RIGHT;
|
||||
|
||||
if (p & PAD_TRIGGER_L)
|
||||
res |= VBA_BUTTON_L;
|
||||
|
||||
if (p & PAD_TRIGGER_R)
|
||||
res |= VBA_BUTTON_R;
|
||||
|
||||
if((p & PAD_BUTTON_X) && (p & PAD_BUTTON_Y))
|
||||
menuCalled = 1;
|
||||
#endif
|
||||
|
||||
if ((res & 48) == 48)
|
||||
res &= ~16;
|
||||
if ((res & 192) == 192)
|
||||
res &= ~128;
|
||||
|
||||
return res;
|
||||
}
|
||||
/****************************************************************************
|
||||
* VisualBoyAdvance 1.7.2
|
||||
*
|
||||
* Nintendo GameCube Joypad Wrapper
|
||||
****************************************************************************/
|
||||
|
||||
#include <gccore.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#define VBA_BUTTON_A 1
|
||||
#define VBA_BUTTON_B 2
|
||||
#define VBA_BUTTON_SELECT 4
|
||||
#define VBA_BUTTON_START 8
|
||||
#define VBA_RIGHT 16
|
||||
#define VBA_LEFT 32
|
||||
#define VBA_UP 64
|
||||
#define VBA_DOWN 128
|
||||
#define VBA_BUTTON_R 256
|
||||
#define VBA_BUTTON_L 512
|
||||
#define VBA_SPEED 1024
|
||||
#define VBA_CAPTURE 2048
|
||||
|
||||
#ifdef WII_BUILD
|
||||
#include <math.h>
|
||||
#include <wiiuse/wpad.h>
|
||||
int isClassicAvailable = 0;
|
||||
int isWiimoteAvailable = 0;
|
||||
/*
|
||||
#ifndef PI
|
||||
#define PI 3.14159f
|
||||
#endif
|
||||
|
||||
enum { STICK_X, STICK_Y };
|
||||
static int getStickValue(joystick_t* j, int axis, int maxAbsValue){
|
||||
double angle = PI * j->ang/180.0f;
|
||||
double magnitude = (j->mag > 1.0f) ? 1.0f :
|
||||
(j->mag < -1.0f) ? -1.0f : j->mag;
|
||||
double value;
|
||||
if(axis == STICK_X)
|
||||
value = magnitude * sin( angle );
|
||||
else
|
||||
value = magnitude * cos( angle );
|
||||
return (int)(value * maxAbsValue);
|
||||
}*/
|
||||
|
||||
#endif
|
||||
int menuCalled = 0;
|
||||
u32
|
||||
NGCPad()
|
||||
{
|
||||
u32 res = 0;
|
||||
short p;
|
||||
signed char x,
|
||||
y;
|
||||
int padcal = 90;
|
||||
float t;
|
||||
|
||||
#ifdef WII_BUILD
|
||||
//wiimote
|
||||
WPADData *wpad;
|
||||
WPAD_ScanPads();
|
||||
wpad = WPAD_Data(0);
|
||||
if (isWiimoteAvailable)
|
||||
{
|
||||
unsigned short b = wpad->btns_h;
|
||||
|
||||
if (b & WPAD_BUTTON_2)
|
||||
res |= VBA_BUTTON_A;
|
||||
|
||||
if (b & WPAD_BUTTON_1)
|
||||
res |= VBA_BUTTON_B;
|
||||
|
||||
if (b & WPAD_BUTTON_MINUS)
|
||||
res |= VBA_BUTTON_SELECT;
|
||||
|
||||
if (b & WPAD_BUTTON_PLUS)
|
||||
res |= VBA_BUTTON_START;
|
||||
|
||||
if (b & WPAD_BUTTON_RIGHT)
|
||||
res |= VBA_UP;
|
||||
|
||||
if (b & WPAD_BUTTON_LEFT)
|
||||
res |= VBA_DOWN;
|
||||
|
||||
if (b & WPAD_BUTTON_UP)
|
||||
res |= VBA_LEFT;
|
||||
|
||||
if (b & WPAD_BUTTON_DOWN)
|
||||
res |= VBA_RIGHT;
|
||||
|
||||
if (b & WPAD_BUTTON_A)
|
||||
res |= VBA_BUTTON_L;
|
||||
|
||||
if (b & WPAD_BUTTON_B)
|
||||
res |= VBA_BUTTON_R;
|
||||
|
||||
if (b & WPAD_BUTTON_HOME)
|
||||
menuCalled = 1;
|
||||
}
|
||||
//classic controller
|
||||
if (isClassicAvailable)
|
||||
{
|
||||
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;
|
||||
|
||||
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 y_s = 0; //getStickValue(&wpad.exp.classic.ljs, STICK_Y, 127);
|
||||
if (b & CLASSIC_CTRL_BUTTON_A)
|
||||
res |= VBA_BUTTON_A;
|
||||
|
||||
if (b & CLASSIC_CTRL_BUTTON_B)
|
||||
res |= VBA_BUTTON_B;
|
||||
|
||||
if (b & CLASSIC_CTRL_BUTTON_MINUS)
|
||||
res |= VBA_BUTTON_SELECT;
|
||||
|
||||
if (b & CLASSIC_CTRL_BUTTON_PLUS)
|
||||
res |= VBA_BUTTON_START;
|
||||
|
||||
if ((b & CLASSIC_CTRL_BUTTON_UP) || (y_s > 0))
|
||||
res |= VBA_UP;
|
||||
|
||||
if ((b & CLASSIC_CTRL_BUTTON_DOWN) || (y_s < 0))
|
||||
res |= VBA_DOWN;
|
||||
|
||||
if ((b & CLASSIC_CTRL_BUTTON_LEFT) || (x_s < 0))
|
||||
res |= VBA_LEFT;
|
||||
|
||||
if ((b & CLASSIC_CTRL_BUTTON_RIGHT) || (x_s > 0))
|
||||
res |= VBA_RIGHT;
|
||||
|
||||
if (b & CLASSIC_CTRL_BUTTON_FULL_L)
|
||||
res |= VBA_BUTTON_L;
|
||||
|
||||
if (b & CLASSIC_CTRL_BUTTON_FULL_R)
|
||||
res |= VBA_BUTTON_R;
|
||||
|
||||
if (b & CLASSIC_CTRL_BUTTON_HOME)
|
||||
menuCalled = 1;
|
||||
|
||||
}
|
||||
//user needs a GC remote
|
||||
else
|
||||
{
|
||||
p = PAD_ButtonsHeld(0);
|
||||
x = PAD_StickX(0);
|
||||
y = PAD_StickY(0);
|
||||
if (x * x + y * y > padcal * padcal)
|
||||
{
|
||||
if (x > 0 && y == 0)
|
||||
res |= VBA_RIGHT;
|
||||
if (x < 0 && y == 0)
|
||||
res |= VBA_LEFT;
|
||||
if (x == 0 && y > 0)
|
||||
res |= VBA_UP;
|
||||
if (x == 0 && y < 0)
|
||||
res |= VBA_DOWN;
|
||||
|
||||
/*** Recalc left / right ***/
|
||||
t = (float) y / x;
|
||||
if (t >= -2.41421356237 && t < 2.41421356237)
|
||||
{
|
||||
if (x >= 0)
|
||||
res |= VBA_RIGHT;
|
||||
else
|
||||
res |= VBA_LEFT;
|
||||
}
|
||||
|
||||
/*** Recalc up / down ***/
|
||||
t = (float) x / y;
|
||||
if (t >= -2.41421356237 && t < 2.41421356237)
|
||||
{
|
||||
if (y >= 0)
|
||||
res |= VBA_UP;
|
||||
else
|
||||
res |= VBA_DOWN;
|
||||
}
|
||||
}
|
||||
if (p & PAD_BUTTON_A)
|
||||
res |= VBA_BUTTON_A;
|
||||
|
||||
if (p & PAD_BUTTON_B)
|
||||
res |= VBA_BUTTON_B;
|
||||
|
||||
if (p & PAD_TRIGGER_Z)
|
||||
res |= VBA_BUTTON_SELECT;
|
||||
|
||||
if (p & PAD_BUTTON_START)
|
||||
res |= VBA_BUTTON_START;
|
||||
|
||||
if (p & PAD_BUTTON_UP)
|
||||
res |= VBA_UP;
|
||||
|
||||
if (p & PAD_BUTTON_DOWN)
|
||||
res |= VBA_DOWN;
|
||||
|
||||
if (p & PAD_BUTTON_LEFT)
|
||||
res |= VBA_LEFT;
|
||||
|
||||
if (p & PAD_BUTTON_RIGHT)
|
||||
res |= VBA_RIGHT;
|
||||
|
||||
if (p & PAD_TRIGGER_L)
|
||||
res |= VBA_BUTTON_L;
|
||||
|
||||
if (p & PAD_TRIGGER_R)
|
||||
res |= VBA_BUTTON_R;
|
||||
|
||||
if((p & PAD_BUTTON_X) && (p & PAD_BUTTON_Y))
|
||||
menuCalled = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef GC_BUILD
|
||||
p = PAD_ButtonsHeld(0);
|
||||
x = PAD_StickX(0);
|
||||
y = PAD_StickY(0);
|
||||
if (x * x + y * y > padcal * padcal)
|
||||
{
|
||||
if (x > 0 && y == 0)
|
||||
res |= VBA_RIGHT;
|
||||
if (x < 0 && y == 0)
|
||||
res |= VBA_LEFT;
|
||||
if (x == 0 && y > 0)
|
||||
res |= VBA_UP;
|
||||
if (x == 0 && y < 0)
|
||||
res |= VBA_DOWN;
|
||||
|
||||
/*** Recalc left / right ***/
|
||||
t = (float) y / x;
|
||||
if (t >= -2.41421356237 && t < 2.41421356237)
|
||||
{
|
||||
if (x >= 0)
|
||||
res |= VBA_RIGHT;
|
||||
else
|
||||
res |= VBA_LEFT;
|
||||
}
|
||||
|
||||
/*** Recalc up / down ***/
|
||||
t = (float) x / y;
|
||||
if (t >= -2.41421356237 && t < 2.41421356237)
|
||||
{
|
||||
if (y >= 0)
|
||||
res |= VBA_UP;
|
||||
else
|
||||
res |= VBA_DOWN;
|
||||
}
|
||||
}
|
||||
if (p & PAD_BUTTON_A)
|
||||
res |= VBA_BUTTON_A;
|
||||
|
||||
if (p & PAD_BUTTON_B)
|
||||
res |= VBA_BUTTON_B;
|
||||
|
||||
if (p & PAD_TRIGGER_Z)
|
||||
res |= VBA_BUTTON_SELECT;
|
||||
|
||||
if (p & PAD_BUTTON_START)
|
||||
res |= VBA_BUTTON_START;
|
||||
|
||||
if ((p & PAD_BUTTON_UP))
|
||||
res |= VBA_UP;
|
||||
|
||||
if ((p & PAD_BUTTON_DOWN))
|
||||
res |= VBA_DOWN;
|
||||
|
||||
if ((p & PAD_BUTTON_LEFT))
|
||||
res |= VBA_LEFT;
|
||||
|
||||
if ((p & PAD_BUTTON_RIGHT))
|
||||
res |= VBA_RIGHT;
|
||||
|
||||
if (p & PAD_TRIGGER_L)
|
||||
res |= VBA_BUTTON_L;
|
||||
|
||||
if (p & PAD_TRIGGER_R)
|
||||
res |= VBA_BUTTON_R;
|
||||
|
||||
if((p & PAD_BUTTON_X) && (p & PAD_BUTTON_Y))
|
||||
menuCalled = 1;
|
||||
#endif
|
||||
|
||||
if ((res & 48) == 48)
|
||||
res &= ~16;
|
||||
if ((res & 192) == 192)
|
||||
res &= ~128;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
525
src/ngc/menu.cpp
525
src/ngc/menu.cpp
@ -1,260 +1,265 @@
|
||||
/****************************************************************************
|
||||
* File Selection Menu
|
||||
*
|
||||
****************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <gccore.h>
|
||||
#include "sdfileio.h"
|
||||
|
||||
extern GXRModeObj *vmode; /*** Graphics Mode Object ***/
|
||||
extern u32 *xfb[2]; /*** Framebuffers ***/
|
||||
extern int whichfb; /*** Frame buffer toggle ***/
|
||||
|
||||
/** Bits from SD lib **/
|
||||
|
||||
#define PAGE_SIZE 14
|
||||
|
||||
/*** Use OGC built in font ***/
|
||||
extern u8 console_font_8x16[];
|
||||
|
||||
static u32 forecolour = COLOR_WHITE;
|
||||
static u32 backcolour = COLOR_BLACK;
|
||||
|
||||
/****************************************************************************
|
||||
* MENU_DrawChar
|
||||
****************************************************************************/
|
||||
void MENU_DrawChar( int x, int y, char c, int style )
|
||||
{
|
||||
u8 bits;
|
||||
int offset;
|
||||
int h,w;
|
||||
u32 colour[2];
|
||||
u32 scroffs;
|
||||
|
||||
offset = c << 4;
|
||||
scroffs = ( y * 320 ) + ( x >> 1 );
|
||||
|
||||
for( h = 0; h < 16; h++ )
|
||||
{
|
||||
bits = console_font_8x16[ offset++ ];
|
||||
|
||||
if ( style )
|
||||
{
|
||||
for( w = 0; w < 8; w++ )
|
||||
{
|
||||
xfb[whichfb][scroffs + w] = ( bits & 0x80 ) ? forecolour : backcolour;
|
||||
bits <<= 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( w = 0; w < 4; w++ )
|
||||
{
|
||||
colour[0] = ( bits & 0x80 ) ? forecolour : backcolour;
|
||||
colour[1] = ( bits & 0x40 ) ? forecolour : backcolour;
|
||||
|
||||
xfb[whichfb][scroffs + w] = ( colour[0] & 0xFFFF00FF ) | ( colour[1] & 0x0000FF00 );
|
||||
bits <<= 2;
|
||||
}
|
||||
}
|
||||
|
||||
scroffs += 320;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* MENU_DrawString
|
||||
****************************************************************************/
|
||||
void MENU_DrawString( int x, int y, char *msg, int style )
|
||||
{
|
||||
int i,len;
|
||||
|
||||
/* Centred ? */
|
||||
if ( x == -1 )
|
||||
{
|
||||
if ( style )
|
||||
x = strlen(msg) << 4;
|
||||
else
|
||||
x = strlen(msg) << 3;
|
||||
|
||||
x = ( 640 - x ) >> 1;
|
||||
}
|
||||
if((int)strlen(msg) < 36)
|
||||
len = (int)strlen(msg);
|
||||
else
|
||||
len = 36;
|
||||
for ( i = 0; i < len; i++ )
|
||||
{
|
||||
MENU_DrawChar(x,y,msg[i],style);
|
||||
x += ( style ? 16 : 8 );
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* MENU_Draw
|
||||
****************************************************************************/
|
||||
int MENU_Draw( int max, int current, int offset )
|
||||
{
|
||||
int i;
|
||||
int ypos = 30;
|
||||
int xpos = 30;
|
||||
|
||||
for ( i = offset; i < max && ( ( i - offset ) < PAGE_SIZE ); i++ )
|
||||
{
|
||||
if ( i == current )
|
||||
{
|
||||
forecolour = COLOR_BLACK;
|
||||
backcolour = COLOR_WHITE;
|
||||
}
|
||||
else
|
||||
{
|
||||
forecolour = COLOR_WHITE;
|
||||
backcolour = COLOR_BLACK;
|
||||
}
|
||||
MENU_DrawString( xpos, ypos, direntries[i], 1);
|
||||
ypos += 16;
|
||||
}
|
||||
}
|
||||
#ifdef WII_BUILD
|
||||
#include <math.h>
|
||||
#include <wiiuse/wpad.h>
|
||||
extern int isClassicAvailable;
|
||||
extern int isWiimoteAvailable;
|
||||
extern void setup_controllers();
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* MENU_GetLoadFile
|
||||
*
|
||||
* Returns the filename of the selected file
|
||||
***************************************************************************/
|
||||
char *MENU_GetLoadFile( char *whichdir )
|
||||
{
|
||||
int count;
|
||||
char *p = NULL;
|
||||
int quit = 0;
|
||||
int redraw = 1;
|
||||
int current = 0;
|
||||
int offset = 0;
|
||||
u16 buttons;
|
||||
int do_DOWN = 0;
|
||||
int do_UP = 0;
|
||||
int do_A = 0;
|
||||
|
||||
count = gen_getdir( whichdir );
|
||||
|
||||
|
||||
if ( count == 0 )
|
||||
{
|
||||
printf("No ROM files in %s\n", whichdir);
|
||||
while(1);
|
||||
}
|
||||
|
||||
if ( count == 1 )
|
||||
return (char*)direntries[0];
|
||||
|
||||
|
||||
/* Do menu */
|
||||
while ( !quit )
|
||||
{
|
||||
if ( redraw )
|
||||
{
|
||||
whichfb ^= 1;
|
||||
VIDEO_ClearFrameBuffer(vmode, xfb[whichfb], COLOR_BLACK);
|
||||
MENU_Draw( count, current, offset );
|
||||
VIDEO_SetNextFramebuffer(xfb[whichfb]);
|
||||
VIDEO_Flush();
|
||||
VIDEO_WaitVSync();
|
||||
redraw = 0;
|
||||
}
|
||||
#ifdef WII_BUILD
|
||||
setup_controllers();
|
||||
WPADData wpad;
|
||||
WPAD_Read(0, &wpad);
|
||||
if(isClassicAvailable)
|
||||
{
|
||||
int b = wpad.exp.classic.btns;
|
||||
if (b & CLASSIC_CTRL_BUTTON_DOWN){
|
||||
do_DOWN = 1;
|
||||
do{WPAD_Read(0, &wpad); b = wpad.exp.classic.btns;}while(b & CLASSIC_CTRL_BUTTON_DOWN);
|
||||
}
|
||||
else if (b & CLASSIC_CTRL_BUTTON_UP){
|
||||
do_UP = 1;
|
||||
do{WPAD_Read(0, &wpad); b = wpad.exp.classic.btns;}while(b & CLASSIC_CTRL_BUTTON_UP);
|
||||
}
|
||||
else if (b & CLASSIC_CTRL_BUTTON_A){
|
||||
do_A = 1;
|
||||
do{WPAD_Read(0, &wpad); b = wpad.exp.classic.btns;}while(b & CLASSIC_CTRL_BUTTON_A);
|
||||
}
|
||||
}
|
||||
if(isWiimoteAvailable)
|
||||
{
|
||||
unsigned short b = wpad.btns_d;
|
||||
if(b & WPAD_BUTTON_LEFT){
|
||||
do_DOWN = 1;
|
||||
do{WPAD_Read(0, &wpad); b = wpad.btns_d;}while(b & WPAD_BUTTON_LEFT);
|
||||
}
|
||||
else if (b & WPAD_BUTTON_RIGHT){
|
||||
do_UP = 1;
|
||||
do{WPAD_Read(0, &wpad); b = wpad.btns_d;}while(b & WPAD_BUTTON_RIGHT);
|
||||
}
|
||||
else if (b & WPAD_BUTTON_2){
|
||||
do_A = 1;
|
||||
do{WPAD_Read(0, &wpad); b = wpad.btns_d;}while(b & WPAD_BUTTON_2);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
buttons = PAD_ButtonsDown(0);
|
||||
if(buttons & PAD_BUTTON_DOWN)
|
||||
do_DOWN = 1;
|
||||
else if(buttons & PAD_BUTTON_UP)
|
||||
do_UP = 1;
|
||||
else if(buttons & PAD_BUTTON_A)
|
||||
do_A = 1;
|
||||
if (do_DOWN)
|
||||
{
|
||||
do_DOWN=0;
|
||||
current++;
|
||||
if ( current == count )
|
||||
current = 0;
|
||||
|
||||
if ( ( current % PAGE_SIZE ) == 0 )
|
||||
offset = current;
|
||||
|
||||
redraw = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( do_UP )
|
||||
{
|
||||
do_UP=0;
|
||||
current--;
|
||||
if ( current < 0 ) current = count - 1;
|
||||
offset = ( current / PAGE_SIZE ) * PAGE_SIZE;
|
||||
redraw = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( do_A )
|
||||
{
|
||||
do_A=0;
|
||||
quit = 1;
|
||||
p = (char*)direntries[current];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
whichfb ^= 1;
|
||||
VIDEO_ClearFrameBuffer(vmode, xfb[whichfb], COLOR_BLACK);
|
||||
forecolour = COLOR_WHITE;
|
||||
backcolour = COLOR_BLACK;
|
||||
MENU_DrawString(-1, 240, "Loading ... Wait", 1);
|
||||
VIDEO_SetNextFramebuffer(xfb[whichfb]);
|
||||
VIDEO_Flush();
|
||||
VIDEO_WaitVSync();
|
||||
return p;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* File Selection Menu
|
||||
*
|
||||
****************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <gccore.h>
|
||||
#include "sdfileio.h"
|
||||
|
||||
extern GXRModeObj *vmode; /*** Graphics Mode Object ***/
|
||||
extern u32 *xfb[2]; /*** Framebuffers ***/
|
||||
extern int whichfb; /*** Frame buffer toggle ***/
|
||||
|
||||
/** Bits from SD lib **/
|
||||
|
||||
#define PAGE_SIZE 14
|
||||
|
||||
/*** Use OGC built in font ***/
|
||||
extern u8 console_font_8x16[];
|
||||
|
||||
static u32 forecolour = COLOR_WHITE;
|
||||
static u32 backcolour = COLOR_BLACK;
|
||||
|
||||
/****************************************************************************
|
||||
* MENU_DrawChar
|
||||
****************************************************************************/
|
||||
void MENU_DrawChar( int x, int y, char c, int style )
|
||||
{
|
||||
u8 bits;
|
||||
int offset;
|
||||
int h,w;
|
||||
u32 colour[2];
|
||||
u32 scroffs;
|
||||
|
||||
offset = c << 4;
|
||||
scroffs = ( y * 320 ) + ( x >> 1 );
|
||||
|
||||
for( h = 0; h < 16; h++ )
|
||||
{
|
||||
bits = console_font_8x16[ offset++ ];
|
||||
|
||||
if ( style )
|
||||
{
|
||||
for( w = 0; w < 8; w++ )
|
||||
{
|
||||
xfb[whichfb][scroffs + w] = ( bits & 0x80 ) ? forecolour : backcolour;
|
||||
bits <<= 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( w = 0; w < 4; w++ )
|
||||
{
|
||||
colour[0] = ( bits & 0x80 ) ? forecolour : backcolour;
|
||||
colour[1] = ( bits & 0x40 ) ? forecolour : backcolour;
|
||||
|
||||
xfb[whichfb][scroffs + w] = ( colour[0] & 0xFFFF00FF ) | ( colour[1] & 0x0000FF00 );
|
||||
bits <<= 2;
|
||||
}
|
||||
}
|
||||
|
||||
scroffs += 320;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* MENU_DrawString
|
||||
****************************************************************************/
|
||||
void MENU_DrawString( int x, int y, char *msg, int style )
|
||||
{
|
||||
int i,len;
|
||||
|
||||
/* Centred ? */
|
||||
if ( x == -1 )
|
||||
{
|
||||
if ( style )
|
||||
x = strlen(msg) << 4;
|
||||
else
|
||||
x = strlen(msg) << 3;
|
||||
|
||||
x = ( 640 - x ) >> 1;
|
||||
}
|
||||
if((int)strlen(msg) < 36)
|
||||
len = (int)strlen(msg);
|
||||
else
|
||||
len = 36;
|
||||
for ( i = 0; i < len; i++ )
|
||||
{
|
||||
MENU_DrawChar(x,y,msg[i],style);
|
||||
x += ( style ? 16 : 8 );
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* MENU_Draw
|
||||
****************************************************************************/
|
||||
int MENU_Draw( int max, int current, int offset )
|
||||
{
|
||||
int i;
|
||||
int ypos = 30;
|
||||
int xpos = 30;
|
||||
|
||||
for ( i = offset; i < max && ( ( i - offset ) < PAGE_SIZE ); i++ )
|
||||
{
|
||||
if ( i == current )
|
||||
{
|
||||
forecolour = COLOR_BLACK;
|
||||
backcolour = COLOR_WHITE;
|
||||
}
|
||||
else
|
||||
{
|
||||
forecolour = COLOR_WHITE;
|
||||
backcolour = COLOR_BLACK;
|
||||
}
|
||||
MENU_DrawString( xpos, ypos, direntries[i], 1);
|
||||
ypos += 16;
|
||||
}
|
||||
}
|
||||
#ifdef WII_BUILD
|
||||
#include <math.h>
|
||||
#include <wiiuse/wpad.h>
|
||||
extern int isClassicAvailable;
|
||||
extern int isWiimoteAvailable;
|
||||
extern void setup_controllers();
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* MENU_GetLoadFile
|
||||
*
|
||||
* Returns the filename of the selected file
|
||||
***************************************************************************/
|
||||
char *MENU_GetLoadFile( char *whichdir )
|
||||
{
|
||||
int count;
|
||||
char *p = NULL;
|
||||
int quit = 0;
|
||||
int redraw = 1;
|
||||
int current = 0;
|
||||
int offset = 0;
|
||||
u16 buttons;
|
||||
int do_DOWN = 0;
|
||||
int do_UP = 0;
|
||||
int do_A = 0;
|
||||
|
||||
count = gen_getdir( whichdir );
|
||||
|
||||
|
||||
if ( count == 0 )
|
||||
{
|
||||
printf("No ROM files in %s\n", whichdir);
|
||||
while(1);
|
||||
}
|
||||
#ifdef WII_BUILD
|
||||
setup_controllers();
|
||||
#endif
|
||||
if ( count == 1 )
|
||||
return (char*)direntries[0];
|
||||
|
||||
/* Do menu */
|
||||
while ( !quit )
|
||||
{
|
||||
if ( redraw )
|
||||
{
|
||||
whichfb ^= 1;
|
||||
VIDEO_ClearFrameBuffer(vmode, xfb[whichfb], COLOR_BLACK);
|
||||
MENU_Draw( count, current, offset );
|
||||
VIDEO_SetNextFramebuffer(xfb[whichfb]);
|
||||
VIDEO_Flush();
|
||||
VIDEO_WaitVSync();
|
||||
redraw = 0;
|
||||
}
|
||||
#ifdef WII_BUILD
|
||||
WPAD_ScanPads();
|
||||
WPADData *wpad;
|
||||
wpad = WPAD_Data(0);
|
||||
int b = wpad->exp.classic.btns;
|
||||
unsigned short b1 = wpad->btns_d;
|
||||
if (isClassicAvailable){
|
||||
if (b & CLASSIC_CTRL_BUTTON_DOWN){
|
||||
do_DOWN = 1;
|
||||
do{WPAD_ScanPads(); wpad = WPAD_Data(0);}
|
||||
while (WPAD_ButtonsHeld(0));
|
||||
}
|
||||
else if (b & CLASSIC_CTRL_BUTTON_UP){
|
||||
do_UP = 1;
|
||||
do{WPAD_ScanPads(); wpad = WPAD_Data(0);}
|
||||
while (WPAD_ButtonsHeld(0));
|
||||
}
|
||||
else if (b & CLASSIC_CTRL_BUTTON_A){
|
||||
do_A = 1;
|
||||
do{WPAD_ScanPads(); wpad = WPAD_Data(0);}
|
||||
while (WPAD_ButtonsHeld(0));
|
||||
}
|
||||
}
|
||||
if (isWiimoteAvailable){
|
||||
if (b1 & WPAD_BUTTON_LEFT){
|
||||
do_DOWN = 1;
|
||||
do{WPAD_ScanPads(); wpad = WPAD_Data(0);}
|
||||
while (WPAD_ButtonsHeld(0));
|
||||
}
|
||||
else if (b1 & WPAD_BUTTON_RIGHT){
|
||||
do_UP = 1;
|
||||
do{WPAD_ScanPads(); wpad = WPAD_Data(0);}
|
||||
while (WPAD_ButtonsHeld(0));
|
||||
}
|
||||
else if (b1 & WPAD_BUTTON_2){
|
||||
do_A = 1;
|
||||
do{WPAD_ScanPads(); wpad = WPAD_Data(0);}
|
||||
while (WPAD_ButtonsHeld(0));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
buttons = PAD_ButtonsDown(0);
|
||||
if(buttons & PAD_BUTTON_DOWN)
|
||||
do_DOWN = 1;
|
||||
else if(buttons & PAD_BUTTON_UP)
|
||||
do_UP = 1;
|
||||
else if(buttons & PAD_BUTTON_A)
|
||||
do_A = 1;
|
||||
if (do_DOWN)
|
||||
{
|
||||
do_DOWN=0;
|
||||
current++;
|
||||
if ( current == count )
|
||||
current = 0;
|
||||
|
||||
if ( ( current % PAGE_SIZE ) == 0 )
|
||||
offset = current;
|
||||
|
||||
redraw = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( do_UP )
|
||||
{
|
||||
do_UP=0;
|
||||
current--;
|
||||
if ( current < 0 ) current = count - 1;
|
||||
offset = ( current / PAGE_SIZE ) * PAGE_SIZE;
|
||||
redraw = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( do_A )
|
||||
{
|
||||
do_A=0;
|
||||
quit = 1;
|
||||
p = (char*)direntries[current];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
whichfb ^= 1;
|
||||
VIDEO_ClearFrameBuffer(vmode, xfb[whichfb], COLOR_BLACK);
|
||||
forecolour = COLOR_WHITE;
|
||||
backcolour = COLOR_BLACK;
|
||||
MENU_DrawString(-1, 240, "Loading ... Wait", 1);
|
||||
VIDEO_SetNextFramebuffer(xfb[whichfb]);
|
||||
VIDEO_Flush();
|
||||
VIDEO_WaitVSync();
|
||||
return p;
|
||||
}
|
||||
|
||||
|
1589
src/ngc/vba172.cpp
1589
src/ngc/vba172.cpp
File diff suppressed because it is too large
Load Diff
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