mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
set svn:eol-type=native for **.c
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1439 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
+212
-212
@@ -1,213 +1,213 @@
|
||||
//
|
||||
// Pseudo C
|
||||
//
|
||||
|
||||
//
|
||||
// DSP:
|
||||
//
|
||||
|
||||
// Memory USAGE
|
||||
|
||||
|
||||
|
||||
0x0B80 to 0x0C40 CurrentPB
|
||||
|
||||
0x0B87
|
||||
|
||||
0x0E15 SrcSelectFunction // perhaps CMD0 setups some kind of jmp table at this addresses
|
||||
0x0E16 CoefFunction
|
||||
0x0E14 MixCtrlFunction
|
||||
|
||||
0x0e17 TmpBuffer exceptions
|
||||
0x0e18 TmpBuffer exceptions
|
||||
0x0e19 TmpBuffer exceptions
|
||||
|
||||
// instrcution memory
|
||||
0x0B31 to 0x0B33 some kind of JMP-Table to handle srcSelect ???
|
||||
0x0B34 to 0x0B36 some kind of JMP-Table to handle coefSelect ???
|
||||
0x0B11 to 0x0B1F some kind of JMP-Table to handle mixerCtrl ???
|
||||
|
||||
void CMD2()
|
||||
{
|
||||
// 0x1BC
|
||||
int_addrPB = (*r00 << 16) | *(r00+1)
|
||||
DMA_From_Memory(0x0B80, _addrPB, 0xC0); // read first PB to 0x0B80
|
||||
|
||||
// 0x1C7
|
||||
*0x0E08 = 0x0000
|
||||
*0x0E09 = 0x0140
|
||||
*0x0E0A = 0x0280
|
||||
*0x0E0B = 0x0400
|
||||
*0x0E0C = 0x0540
|
||||
*0x0E0D = 0x0680
|
||||
*0x0E0E = 0x07C0
|
||||
*0x0E0F = 0x0900
|
||||
*0x0E10 = 0x0A40
|
||||
|
||||
// 0x1E4
|
||||
WaitForDMATransfer()
|
||||
|
||||
// 0x1E6
|
||||
Addr = (*0x0BA7 << 16) | *0x0BA8
|
||||
DMA_From_Memory(0x03C0, Addr, 0x80); // Copy Update Data to 0x03C0 (AXPBUPDATE dataHi, dataLo)
|
||||
|
||||
// 0x1F4
|
||||
R03 = (*0x0B84) + 0x0B31 // AXPB->srcSelect + 0x0B31 ??? some kind of flag handling ??? SRCSEL can be 0x0 to 0x2
|
||||
AC0.M = *R03
|
||||
*0x0E15 = *AC0.M
|
||||
|
||||
// 0x1FD
|
||||
R03 = (*0x0B85) + 0x0B34 // AXPB->coefSelect + 0x0B34 ??? some kind of flag handling ??? COEF can be 0x0 to 0x2
|
||||
AC0.M = *R03
|
||||
*0x0E16 = *AC0.M
|
||||
|
||||
// 0x206
|
||||
R03 = (*0x0B86) + 0x0B11 // AXPB->mixerCtrl + 0x0B36 ??? some kind of flag handling ??? MIXCTRL can be 0x0 to 0xE
|
||||
AC0.M = *R03
|
||||
*0x0E14 = *AC0.M
|
||||
|
||||
// 0x20F
|
||||
if (*0x0B9B == 0) // AXPBITD->flag (on or off for this voice)
|
||||
{
|
||||
// jmp to 0x23a
|
||||
*0x0E42 = 0x0CE0
|
||||
*0x0E40 = 0x0CE0
|
||||
*0x0E41 = 0x0CE0
|
||||
*0x0E43 = 0x0CE0
|
||||
|
||||
WaitForDMATransfer()
|
||||
}
|
||||
else
|
||||
{
|
||||
// code at 0x216
|
||||
*0x0E40 = *0x0B9E + 0x0CC0 // AXPBITD->shiftL
|
||||
*0x0E41 = *0x0B9F + 0x0CC0 // AXPBITD->shiftR
|
||||
*0x0E42 = 0xCE0
|
||||
*0x0E43 = 0xCE0
|
||||
|
||||
WaitForDMATransfer()
|
||||
|
||||
// 0x22a
|
||||
Addr = (*0x0B9C << 16) | *0x0B9D
|
||||
DMA_From_Memory(0x0CC0, Addr, 0x40); // (AXPBITD->bufferHi << 16 | AXPBITD->bufferLo) -> 0xCC0
|
||||
WaitForDMATransfer()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CMD0()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CMD3()
|
||||
{
|
||||
|
||||
0x0E07 = R00
|
||||
R00 = 0x0BA2 // AXPBUPDATE->updNum
|
||||
R01 = 0x03C0
|
||||
*0x0E04 = 0x05
|
||||
|
||||
AC1 = 0
|
||||
AC0 = 0
|
||||
AX0.H = *R00++ // AXPBUPDATE->updNum[0]
|
||||
AC1.M = 0x0B80
|
||||
|
||||
// 0x256
|
||||
for (i=0; i<AX0.H; i++)
|
||||
{
|
||||
AC0.M = *R01++
|
||||
AC0.M = AC0.M + AC1.M
|
||||
AX1.L = *R01++
|
||||
R02 = AC0.M
|
||||
*R02 = AX1.L
|
||||
}
|
||||
|
||||
// 0x25c
|
||||
R03 = 0x0E05
|
||||
*R03++ = R01
|
||||
*R03++ = R02
|
||||
|
||||
// 0x260
|
||||
AC0.M = *0x0B87 // AXPB->state
|
||||
|
||||
if (AC0.M == 1)
|
||||
{
|
||||
// JMP 0x267 (AX_PB_STATE_RUN)
|
||||
*0x0E1C = *0x0E42
|
||||
|
||||
CALLR *0x0E15 // Load Sample (SrcSelectFunction)
|
||||
|
||||
// 0x270
|
||||
AC0.M = *0xBB3 // AXPBVE->currentDelta (.15 volume at start of frame)
|
||||
AC1.M = *0xBB2 // AXPBVE->currentVolume
|
||||
|
||||
// 0x278
|
||||
AX0.L = AC1.M
|
||||
AC1.M = AC1.M + AC0.M
|
||||
AC0.M = AC0.M << 1
|
||||
|
||||
SET15 // ????
|
||||
|
||||
AX1.H = AC0.M
|
||||
AC0.M = AX0.L
|
||||
|
||||
AX0.L = 0x8000
|
||||
R00 = 0x0E44
|
||||
|
||||
// 0x27f
|
||||
// scale volume table
|
||||
.
|
||||
.
|
||||
.
|
||||
/* for (int i=0; i<32; i++)
|
||||
{
|
||||
*R00++ = AC0.M;
|
||||
prod = AX0.L * AX1.H
|
||||
|
||||
*R00++ = AC1.M;
|
||||
AC0 = AC0 + prod
|
||||
prod = AX0.L * AX1.H
|
||||
|
||||
*R00++ = AC0.M;
|
||||
AC1 = AC1 + prod
|
||||
prod = AX0.L * AX1.H
|
||||
}*/
|
||||
|
||||
// 0x29f
|
||||
*0xBB2 = CurrentVolume
|
||||
|
||||
|
||||
// 0x2a1
|
||||
// mutiply volume with sample
|
||||
.
|
||||
.
|
||||
.
|
||||
|
||||
|
||||
// 0x2ea
|
||||
// Call mixer
|
||||
|
||||
// 0x02f0
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// JMP 0x332
|
||||
.
|
||||
.
|
||||
.
|
||||
.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ===============================================================
|
||||
void Func_0x065D()
|
||||
{
|
||||
|
||||
|
||||
//
|
||||
// Pseudo C
|
||||
//
|
||||
|
||||
//
|
||||
// DSP:
|
||||
//
|
||||
|
||||
// Memory USAGE
|
||||
|
||||
|
||||
|
||||
0x0B80 to 0x0C40 CurrentPB
|
||||
|
||||
0x0B87
|
||||
|
||||
0x0E15 SrcSelectFunction // perhaps CMD0 setups some kind of jmp table at this addresses
|
||||
0x0E16 CoefFunction
|
||||
0x0E14 MixCtrlFunction
|
||||
|
||||
0x0e17 TmpBuffer exceptions
|
||||
0x0e18 TmpBuffer exceptions
|
||||
0x0e19 TmpBuffer exceptions
|
||||
|
||||
// instrcution memory
|
||||
0x0B31 to 0x0B33 some kind of JMP-Table to handle srcSelect ???
|
||||
0x0B34 to 0x0B36 some kind of JMP-Table to handle coefSelect ???
|
||||
0x0B11 to 0x0B1F some kind of JMP-Table to handle mixerCtrl ???
|
||||
|
||||
void CMD2()
|
||||
{
|
||||
// 0x1BC
|
||||
int_addrPB = (*r00 << 16) | *(r00+1)
|
||||
DMA_From_Memory(0x0B80, _addrPB, 0xC0); // read first PB to 0x0B80
|
||||
|
||||
// 0x1C7
|
||||
*0x0E08 = 0x0000
|
||||
*0x0E09 = 0x0140
|
||||
*0x0E0A = 0x0280
|
||||
*0x0E0B = 0x0400
|
||||
*0x0E0C = 0x0540
|
||||
*0x0E0D = 0x0680
|
||||
*0x0E0E = 0x07C0
|
||||
*0x0E0F = 0x0900
|
||||
*0x0E10 = 0x0A40
|
||||
|
||||
// 0x1E4
|
||||
WaitForDMATransfer()
|
||||
|
||||
// 0x1E6
|
||||
Addr = (*0x0BA7 << 16) | *0x0BA8
|
||||
DMA_From_Memory(0x03C0, Addr, 0x80); // Copy Update Data to 0x03C0 (AXPBUPDATE dataHi, dataLo)
|
||||
|
||||
// 0x1F4
|
||||
R03 = (*0x0B84) + 0x0B31 // AXPB->srcSelect + 0x0B31 ??? some kind of flag handling ??? SRCSEL can be 0x0 to 0x2
|
||||
AC0.M = *R03
|
||||
*0x0E15 = *AC0.M
|
||||
|
||||
// 0x1FD
|
||||
R03 = (*0x0B85) + 0x0B34 // AXPB->coefSelect + 0x0B34 ??? some kind of flag handling ??? COEF can be 0x0 to 0x2
|
||||
AC0.M = *R03
|
||||
*0x0E16 = *AC0.M
|
||||
|
||||
// 0x206
|
||||
R03 = (*0x0B86) + 0x0B11 // AXPB->mixerCtrl + 0x0B36 ??? some kind of flag handling ??? MIXCTRL can be 0x0 to 0xE
|
||||
AC0.M = *R03
|
||||
*0x0E14 = *AC0.M
|
||||
|
||||
// 0x20F
|
||||
if (*0x0B9B == 0) // AXPBITD->flag (on or off for this voice)
|
||||
{
|
||||
// jmp to 0x23a
|
||||
*0x0E42 = 0x0CE0
|
||||
*0x0E40 = 0x0CE0
|
||||
*0x0E41 = 0x0CE0
|
||||
*0x0E43 = 0x0CE0
|
||||
|
||||
WaitForDMATransfer()
|
||||
}
|
||||
else
|
||||
{
|
||||
// code at 0x216
|
||||
*0x0E40 = *0x0B9E + 0x0CC0 // AXPBITD->shiftL
|
||||
*0x0E41 = *0x0B9F + 0x0CC0 // AXPBITD->shiftR
|
||||
*0x0E42 = 0xCE0
|
||||
*0x0E43 = 0xCE0
|
||||
|
||||
WaitForDMATransfer()
|
||||
|
||||
// 0x22a
|
||||
Addr = (*0x0B9C << 16) | *0x0B9D
|
||||
DMA_From_Memory(0x0CC0, Addr, 0x40); // (AXPBITD->bufferHi << 16 | AXPBITD->bufferLo) -> 0xCC0
|
||||
WaitForDMATransfer()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CMD0()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CMD3()
|
||||
{
|
||||
|
||||
0x0E07 = R00
|
||||
R00 = 0x0BA2 // AXPBUPDATE->updNum
|
||||
R01 = 0x03C0
|
||||
*0x0E04 = 0x05
|
||||
|
||||
AC1 = 0
|
||||
AC0 = 0
|
||||
AX0.H = *R00++ // AXPBUPDATE->updNum[0]
|
||||
AC1.M = 0x0B80
|
||||
|
||||
// 0x256
|
||||
for (i=0; i<AX0.H; i++)
|
||||
{
|
||||
AC0.M = *R01++
|
||||
AC0.M = AC0.M + AC1.M
|
||||
AX1.L = *R01++
|
||||
R02 = AC0.M
|
||||
*R02 = AX1.L
|
||||
}
|
||||
|
||||
// 0x25c
|
||||
R03 = 0x0E05
|
||||
*R03++ = R01
|
||||
*R03++ = R02
|
||||
|
||||
// 0x260
|
||||
AC0.M = *0x0B87 // AXPB->state
|
||||
|
||||
if (AC0.M == 1)
|
||||
{
|
||||
// JMP 0x267 (AX_PB_STATE_RUN)
|
||||
*0x0E1C = *0x0E42
|
||||
|
||||
CALLR *0x0E15 // Load Sample (SrcSelectFunction)
|
||||
|
||||
// 0x270
|
||||
AC0.M = *0xBB3 // AXPBVE->currentDelta (.15 volume at start of frame)
|
||||
AC1.M = *0xBB2 // AXPBVE->currentVolume
|
||||
|
||||
// 0x278
|
||||
AX0.L = AC1.M
|
||||
AC1.M = AC1.M + AC0.M
|
||||
AC0.M = AC0.M << 1
|
||||
|
||||
SET15 // ????
|
||||
|
||||
AX1.H = AC0.M
|
||||
AC0.M = AX0.L
|
||||
|
||||
AX0.L = 0x8000
|
||||
R00 = 0x0E44
|
||||
|
||||
// 0x27f
|
||||
// scale volume table
|
||||
.
|
||||
.
|
||||
.
|
||||
/* for (int i=0; i<32; i++)
|
||||
{
|
||||
*R00++ = AC0.M;
|
||||
prod = AX0.L * AX1.H
|
||||
|
||||
*R00++ = AC1.M;
|
||||
AC0 = AC0 + prod
|
||||
prod = AX0.L * AX1.H
|
||||
|
||||
*R00++ = AC0.M;
|
||||
AC1 = AC1 + prod
|
||||
prod = AX0.L * AX1.H
|
||||
}*/
|
||||
|
||||
// 0x29f
|
||||
*0xBB2 = CurrentVolume
|
||||
|
||||
|
||||
// 0x2a1
|
||||
// mutiply volume with sample
|
||||
.
|
||||
.
|
||||
.
|
||||
|
||||
|
||||
// 0x2ea
|
||||
// Call mixer
|
||||
|
||||
// 0x02f0
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// JMP 0x332
|
||||
.
|
||||
.
|
||||
.
|
||||
.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ===============================================================
|
||||
void Func_0x065D()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
Vendored
+25
-25
@@ -57,7 +57,7 @@ static void classic_ctrl_pressed_buttons(struct classic_ctrl_t* cc, short now);
|
||||
* @return Returns 1 if handshake was successful, 0 if not.
|
||||
*/
|
||||
int classic_ctrl_handshake(struct wiimote_t* wm, struct classic_ctrl_t* cc, byte* data, unsigned short len) {
|
||||
int i;
|
||||
int i;
|
||||
int offset = 0;
|
||||
|
||||
cc->btns = 0;
|
||||
@@ -69,30 +69,30 @@ int classic_ctrl_handshake(struct wiimote_t* wm, struct classic_ctrl_t* cc, byte
|
||||
/* decrypt data */
|
||||
for (i = 0; i < len; ++i)
|
||||
data[i] = (data[i] ^ 0x17) + 0x17;
|
||||
|
||||
if (data[offset] == 0xFF) {
|
||||
/*
|
||||
* Sometimes the data returned here is not correct.
|
||||
* This might happen because the wiimote is lagging
|
||||
* behind our initialization sequence.
|
||||
* To fix this just request the handshake again.
|
||||
*
|
||||
* Other times it's just the first 16 bytes are 0xFF,
|
||||
* but since the next 16 bytes are the same, just use
|
||||
* those.
|
||||
*/
|
||||
if (data[offset + 16] == 0xFF) {
|
||||
/* get the calibration data */
|
||||
byte* handshake_buf = malloc(EXP_HANDSHAKE_LEN * sizeof(byte));
|
||||
|
||||
WIIUSE_DEBUG("Classic controller handshake appears invalid, trying again.");
|
||||
wiiuse_read_data_cb(wm, handshake_expansion, handshake_buf, WM_EXP_MEM_CALIBR, EXP_HANDSHAKE_LEN);
|
||||
|
||||
return 0;
|
||||
} else
|
||||
offset += 16;
|
||||
}
|
||||
|
||||
|
||||
if (data[offset] == 0xFF) {
|
||||
/*
|
||||
* Sometimes the data returned here is not correct.
|
||||
* This might happen because the wiimote is lagging
|
||||
* behind our initialization sequence.
|
||||
* To fix this just request the handshake again.
|
||||
*
|
||||
* Other times it's just the first 16 bytes are 0xFF,
|
||||
* but since the next 16 bytes are the same, just use
|
||||
* those.
|
||||
*/
|
||||
if (data[offset + 16] == 0xFF) {
|
||||
/* get the calibration data */
|
||||
byte* handshake_buf = malloc(EXP_HANDSHAKE_LEN * sizeof(byte));
|
||||
|
||||
WIIUSE_DEBUG("Classic controller handshake appears invalid, trying again.");
|
||||
wiiuse_read_data_cb(wm, handshake_expansion, handshake_buf, WM_EXP_MEM_CALIBR, EXP_HANDSHAKE_LEN);
|
||||
|
||||
return 0;
|
||||
} else
|
||||
offset += 16;
|
||||
}
|
||||
|
||||
|
||||
/* joystick stuff */
|
||||
cc->ljs.max.x = data[0 + offset] / 4;
|
||||
|
||||
Vendored
+7
-7
@@ -107,12 +107,12 @@ void calculate_orientation(struct accel_t* ac, struct vec3b_t* accel, struct ori
|
||||
orient->pitch = y;
|
||||
orient->a_pitch = y;
|
||||
}
|
||||
|
||||
/* smooth the angles if enabled */
|
||||
if (smooth) {
|
||||
apply_smoothing(ac, orient, SMOOTH_ROLL);
|
||||
apply_smoothing(ac, orient, SMOOTH_PITCH);
|
||||
}
|
||||
|
||||
/* smooth the angles if enabled */
|
||||
if (smooth) {
|
||||
apply_smoothing(ac, orient, SMOOTH_ROLL);
|
||||
apply_smoothing(ac, orient, SMOOTH_PITCH);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -191,7 +191,7 @@ void calc_joystick_state(struct joystick_t* js, float x, float y) {
|
||||
void apply_smoothing(struct accel_t* ac, struct orient_t* orient, int type) {
|
||||
switch (type) {
|
||||
case SMOOTH_ROLL:
|
||||
{
|
||||
{
|
||||
/* it's possible last iteration was nan or inf, so set it to 0 if that happened */
|
||||
if (isnan(ac->st_roll) || isinf(ac->st_roll))
|
||||
ac->st_roll = 0.0f;
|
||||
|
||||
Vendored
+823
-823
File diff suppressed because it is too large
Load Diff
+24
-24
@@ -57,7 +57,7 @@ static void guitar_hero_3_pressed_buttons(struct guitar_hero_3_t* gh3, short now
|
||||
* @return Returns 1 if handshake was successful, 0 if not.
|
||||
*/
|
||||
int guitar_hero_3_handshake(struct wiimote_t* wm, struct guitar_hero_3_t* gh3, byte* data, unsigned short len) {
|
||||
int i;
|
||||
int i;
|
||||
int offset = 0;
|
||||
|
||||
/*
|
||||
@@ -74,29 +74,29 @@ int guitar_hero_3_handshake(struct wiimote_t* wm, struct guitar_hero_3_t* gh3, b
|
||||
/* decrypt data */
|
||||
for (i = 0; i < len; ++i)
|
||||
data[i] = (data[i] ^ 0x17) + 0x17;
|
||||
|
||||
if (data[offset] == 0xFF) {
|
||||
/*
|
||||
* Sometimes the data returned here is not correct.
|
||||
* This might happen because the wiimote is lagging
|
||||
* behind our initialization sequence.
|
||||
* To fix this just request the handshake again.
|
||||
*
|
||||
* Other times it's just the first 16 bytes are 0xFF,
|
||||
* but since the next 16 bytes are the same, just use
|
||||
* those.
|
||||
*/
|
||||
if (data[offset + 16] == 0xFF) {
|
||||
/* get the calibration data */
|
||||
byte* handshake_buf = malloc(EXP_HANDSHAKE_LEN * sizeof(byte));
|
||||
|
||||
WIIUSE_DEBUG("Guitar Hero 3 handshake appears invalid, trying again.");
|
||||
wiiuse_read_data_cb(wm, handshake_expansion, handshake_buf, WM_EXP_MEM_CALIBR, EXP_HANDSHAKE_LEN);
|
||||
|
||||
return 0;
|
||||
} else
|
||||
offset += 16;
|
||||
}
|
||||
|
||||
if (data[offset] == 0xFF) {
|
||||
/*
|
||||
* Sometimes the data returned here is not correct.
|
||||
* This might happen because the wiimote is lagging
|
||||
* behind our initialization sequence.
|
||||
* To fix this just request the handshake again.
|
||||
*
|
||||
* Other times it's just the first 16 bytes are 0xFF,
|
||||
* but since the next 16 bytes are the same, just use
|
||||
* those.
|
||||
*/
|
||||
if (data[offset + 16] == 0xFF) {
|
||||
/* get the calibration data */
|
||||
byte* handshake_buf = malloc(EXP_HANDSHAKE_LEN * sizeof(byte));
|
||||
|
||||
WIIUSE_DEBUG("Guitar Hero 3 handshake appears invalid, trying again.");
|
||||
wiiuse_read_data_cb(wm, handshake_expansion, handshake_buf, WM_EXP_MEM_CALIBR, EXP_HANDSHAKE_LEN);
|
||||
|
||||
return 0;
|
||||
} else
|
||||
offset += 16;
|
||||
}
|
||||
|
||||
/* joystick stuff */
|
||||
gh3->js.max.x = GUITAR_HERO_3_JS_MAX_X;
|
||||
|
||||
Vendored
+14
-14
@@ -59,8 +59,8 @@ void wiiuse_handshake(struct wiimote_t* wm, byte* data, unsigned short len) {
|
||||
case 0:
|
||||
{
|
||||
/* send request to wiimote for accelerometer calibration */
|
||||
byte* buf;
|
||||
|
||||
byte* buf;
|
||||
|
||||
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE);
|
||||
wiiuse_set_leds(wm, WIIMOTE_LED_NONE);
|
||||
|
||||
@@ -68,8 +68,8 @@ void wiiuse_handshake(struct wiimote_t* wm, byte* data, unsigned short len) {
|
||||
wiiuse_read_data_cb(wm, wiiuse_handshake, buf, WM_MEM_OFFSET_CALIBRATION, 7);
|
||||
wm->handshake_state++;
|
||||
|
||||
wiiuse_set_leds(wm, WIIMOTE_LED_NONE);
|
||||
|
||||
wiiuse_set_leds(wm, WIIMOTE_LED_NONE);
|
||||
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
@@ -94,23 +94,23 @@ void wiiuse_handshake(struct wiimote_t* wm, byte* data, unsigned short len) {
|
||||
accel->cal_zero.x, accel->cal_zero.y, accel->cal_zero.z,
|
||||
accel->cal_g.x, accel->cal_g.y, accel->cal_g.z);
|
||||
|
||||
|
||||
/* request the status of the wiimote to see if there is an expansion */
|
||||
wiiuse_status(wm);
|
||||
|
||||
|
||||
/* request the status of the wiimote to see if there is an expansion */
|
||||
wiiuse_status(wm);
|
||||
|
||||
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE);
|
||||
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE_COMPLETE);
|
||||
wm->handshake_state++;
|
||||
|
||||
/* now enable IR if it was set before the handshake completed */
|
||||
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_IR)) {
|
||||
wm->handshake_state++;
|
||||
|
||||
/* now enable IR if it was set before the handshake completed */
|
||||
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_IR)) {
|
||||
WIIUSE_DEBUG("Handshake finished, enabling IR.");
|
||||
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_IR);
|
||||
wiiuse_set_ir(wm, 1);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
default:
|
||||
{
|
||||
break;
|
||||
|
||||
Vendored
+15
-15
@@ -32,14 +32,14 @@
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <windows.h>
|
||||
#include <hidsdi.h>
|
||||
#include <setupapi.h>
|
||||
|
||||
|
||||
#include "definitions.h"
|
||||
#include "wiiuse_internal.h"
|
||||
#include "io.h"
|
||||
@@ -176,8 +176,8 @@ int wiiuse_io_read(struct wiimote_t* wm) {
|
||||
|
||||
if (!ReadFile(wm->dev_handle, wm->event_buf, sizeof(wm->event_buf), &b, &wm->hid_overlap)) {
|
||||
/* partial read */
|
||||
b = GetLastError();
|
||||
|
||||
b = GetLastError();
|
||||
|
||||
if ((b == ERROR_HANDLE_EOF) || (b == ERROR_DEVICE_NOT_CONNECTED)) {
|
||||
/* remote disconnect */
|
||||
wiiuse_disconnected(wm);
|
||||
@@ -186,11 +186,11 @@ int wiiuse_io_read(struct wiimote_t* wm) {
|
||||
|
||||
r = WaitForSingleObject(wm->hid_overlap.hEvent, wm->timeout);
|
||||
if (r == WAIT_TIMEOUT) {
|
||||
/* timeout - cancel and continue */
|
||||
|
||||
if (*wm->event_buf)
|
||||
WIIUSE_WARNING("Packet ignored. This may indicate a problem (timeout is %i ms).", wm->timeout);
|
||||
|
||||
/* timeout - cancel and continue */
|
||||
|
||||
if (*wm->event_buf)
|
||||
WIIUSE_WARNING("Packet ignored. This may indicate a problem (timeout is %i ms).", wm->timeout);
|
||||
|
||||
CancelIo(wm->dev_handle);
|
||||
ResetEvent(wm->hid_overlap.hEvent);
|
||||
return 0;
|
||||
@@ -203,25 +203,25 @@ int wiiuse_io_read(struct wiimote_t* wm) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ResetEvent(wm->hid_overlap.hEvent);
|
||||
ResetEvent(wm->hid_overlap.hEvent);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int wiiuse_io_write(struct wiimote_t* wm, byte* buf, int len) {
|
||||
DWORD bytes;
|
||||
int i;
|
||||
|
||||
int i;
|
||||
|
||||
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
|
||||
switch (wm->stack) {
|
||||
case WIIUSE_STACK_UNKNOWN:
|
||||
{
|
||||
/* try to auto-detect the stack type */
|
||||
if (i = WriteFile(wm->dev_handle, buf, 22, &bytes, &wm->hid_overlap)) {
|
||||
/* bluesoleil will always return 1 here, even if it's not connected */
|
||||
wm->stack = WIIUSE_STACK_BLUESOLEIL;
|
||||
wm->stack = WIIUSE_STACK_BLUESOLEIL;
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
Vendored
+32
-32
@@ -53,9 +53,9 @@ static void nunchuk_pressed_buttons(struct nunchuk_t* nc, byte now);
|
||||
* @return Returns 1 if handshake was successful, 0 if not.
|
||||
*/
|
||||
int nunchuk_handshake(struct wiimote_t* wm, struct nunchuk_t* nc, byte* data, unsigned short len) {
|
||||
int i;
|
||||
int offset = 0;
|
||||
|
||||
int i;
|
||||
int offset = 0;
|
||||
|
||||
nc->btns = 0;
|
||||
nc->btns_held = 0;
|
||||
nc->btns_released = 0;
|
||||
@@ -66,29 +66,29 @@ int nunchuk_handshake(struct wiimote_t* wm, struct nunchuk_t* nc, byte* data, un
|
||||
|
||||
/* decrypt data */
|
||||
for (i = 0; i < len; ++i)
|
||||
data[i] = (data[i] ^ 0x17) + 0x17;
|
||||
|
||||
if (data[offset] == 0xFF) {
|
||||
/*
|
||||
* Sometimes the data returned here is not correct.
|
||||
* This might happen because the wiimote is lagging
|
||||
* behind our initialization sequence.
|
||||
* To fix this just request the handshake again.
|
||||
*
|
||||
* Other times it's just the first 16 bytes are 0xFF,
|
||||
* but since the next 16 bytes are the same, just use
|
||||
* those.
|
||||
*/
|
||||
if (data[offset + 16] == 0xFF) {
|
||||
/* get the calibration data */
|
||||
byte* handshake_buf = malloc(EXP_HANDSHAKE_LEN * sizeof(byte));
|
||||
|
||||
WIIUSE_DEBUG("Nunchuk handshake appears invalid, trying again.");
|
||||
wiiuse_read_data_cb(wm, handshake_expansion, handshake_buf, WM_EXP_MEM_CALIBR, EXP_HANDSHAKE_LEN);
|
||||
|
||||
return 0;
|
||||
} else
|
||||
offset += 16;
|
||||
data[i] = (data[i] ^ 0x17) + 0x17;
|
||||
|
||||
if (data[offset] == 0xFF) {
|
||||
/*
|
||||
* Sometimes the data returned here is not correct.
|
||||
* This might happen because the wiimote is lagging
|
||||
* behind our initialization sequence.
|
||||
* To fix this just request the handshake again.
|
||||
*
|
||||
* Other times it's just the first 16 bytes are 0xFF,
|
||||
* but since the next 16 bytes are the same, just use
|
||||
* those.
|
||||
*/
|
||||
if (data[offset + 16] == 0xFF) {
|
||||
/* get the calibration data */
|
||||
byte* handshake_buf = malloc(EXP_HANDSHAKE_LEN * sizeof(byte));
|
||||
|
||||
WIIUSE_DEBUG("Nunchuk handshake appears invalid, trying again.");
|
||||
wiiuse_read_data_cb(wm, handshake_expansion, handshake_buf, WM_EXP_MEM_CALIBR, EXP_HANDSHAKE_LEN);
|
||||
|
||||
return 0;
|
||||
} else
|
||||
offset += 16;
|
||||
}
|
||||
|
||||
nc->accel_calib.cal_zero.x = data[offset + 0];
|
||||
@@ -103,16 +103,16 @@ int nunchuk_handshake(struct wiimote_t* wm, struct nunchuk_t* nc, byte* data, un
|
||||
nc->js.max.y = data[offset + 11];
|
||||
nc->js.min.y = data[offset + 12];
|
||||
nc->js.center.y = data[offset + 13];
|
||||
|
||||
|
||||
/* default the thresholds to the same as the wiimote */
|
||||
nc->orient_threshold = wm->orient_threshold;
|
||||
nc->accel_threshold = wm->accel_threshold;
|
||||
|
||||
/* handshake done */
|
||||
wm->exp.type = EXP_NUNCHUK;
|
||||
|
||||
#ifdef WIN32
|
||||
wm->timeout = WIIMOTE_DEFAULT_TIMEOUT;
|
||||
/* handshake done */
|
||||
wm->exp.type = EXP_NUNCHUK;
|
||||
|
||||
#ifdef WIN32
|
||||
wm->timeout = WIIMOTE_DEFAULT_TIMEOUT;
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
|
||||
Vendored
+703
-703
File diff suppressed because it is too large
Load Diff
+196
-196
@@ -1,196 +1,196 @@
|
||||
/*****************************************************************************
|
||||
** Name: extended.c
|
||||
** Purpose: IEEE Extended<->Double routines to save floats to file
|
||||
** Maintainer: Ryan Norton
|
||||
** Modified by:
|
||||
** Created: 11/24/04
|
||||
** RCS-ID: $Id: extended.c 36952 2006-01-18 10:25:04Z JS $
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
#if defined(_WIN32_WCE)
|
||||
/* eVC cause warnings in its own headers: stdlib.h and winnt.h */
|
||||
#pragma warning (disable:4115)
|
||||
#pragma warning (disable:4214)
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if defined(_WIN32_WCE)
|
||||
#pragma warning (default:4115)
|
||||
#pragma warning (default:4214)
|
||||
#endif
|
||||
|
||||
#if wxUSE_APPLE_IEEE
|
||||
|
||||
#include "wx/math.h"
|
||||
|
||||
/* Copyright (C) 1989-1991 Ken Turkowski. <turk@computer.org>
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Warranty Information
|
||||
* Even though I have reviewed this software, I make no warranty
|
||||
* or representation, either express or implied, with respect to this
|
||||
* software, its quality, accuracy, merchantability, or fitness for a
|
||||
* particular purpose. As a result, this software is provided "as is,"
|
||||
* and you, its user, are assuming the entire risk as to its quality
|
||||
* and accuracy.
|
||||
*
|
||||
* This code may be used and freely distributed as long as it includes
|
||||
* this copyright notice and the above warranty information.
|
||||
*
|
||||
* Machine-independent I/O routines for IEEE floating-point numbers.
|
||||
*
|
||||
* NaN's and infinities are converted to HUGE_VAL or HUGE, which
|
||||
* happens to be infinity on IEEE machines. Unfortunately, it is
|
||||
* impossible to preserve NaN's in a machine-independent way.
|
||||
* Infinities are, however, preserved on IEEE machines.
|
||||
*
|
||||
* These routines have been tested on the following machines:
|
||||
* Apple Macintosh, MPW 3.1 C compiler
|
||||
* Apple Macintosh, THINK C compiler
|
||||
* Silicon Graphics IRIS, MIPS compiler
|
||||
* Cray X/MP and Y/MP
|
||||
* Digital Equipment VAX
|
||||
* Sequent Balance (Multiprocesor 386)
|
||||
* NeXT
|
||||
*
|
||||
*
|
||||
* Implemented by Malcolm Slaney and Ken Turkowski.
|
||||
*
|
||||
* Malcolm Slaney contributions during 1988-1990 include big- and little-
|
||||
* endian file I/O, conversion to and from Motorola's extended 80-bit
|
||||
* floating-point format, and conversions to and from IEEE single-
|
||||
* precision floating-point format.
|
||||
*
|
||||
* In 1991, Ken Turkowski implemented the conversions to and from
|
||||
* IEEE double-precision format, added more precision to the extended
|
||||
* conversions, and accommodated conversions involving +/- infinity,
|
||||
* NaN's, and denormalized numbers.
|
||||
*/
|
||||
|
||||
#ifndef HUGE_VAL
|
||||
# define HUGE_VAL HUGE
|
||||
#endif /*HUGE_VAL*/
|
||||
|
||||
|
||||
/****************************************************************
|
||||
* The following two routines make up for deficiencies in many
|
||||
* compilers to convert properly between unsigned integers and
|
||||
* floating-point. Some compilers which have this bug are the
|
||||
* THINK_C compiler for the Macintosh and the C compiler for the
|
||||
* Silicon Graphics MIPS-based Iris.
|
||||
****************************************************************/
|
||||
|
||||
#ifdef applec /* The Apple C compiler works */
|
||||
# define FloatToUnsigned(f) ((wxUint32)(f))
|
||||
# define UnsignedToFloat(u) ((wxFloat64)(u))
|
||||
#else /*applec*/
|
||||
# define FloatToUnsigned(f) ((wxUint32)(((wxInt32)((f) - 2147483648.0)) + 2147483647L) + 1)
|
||||
# define UnsignedToFloat(u) (((wxFloat64)((wxInt32)((u) - 2147483647L - 1))) + 2147483648.0)
|
||||
#endif /*applec*/
|
||||
|
||||
|
||||
|
||||
/****************************************************************
|
||||
* Extended precision IEEE floating-point conversion routines.
|
||||
* Extended is an 80-bit number as defined by Motorola,
|
||||
* with a sign bit, 15 bits of exponent (offset 16383?),
|
||||
* and a 64-bit mantissa, with no hidden bit.
|
||||
****************************************************************/
|
||||
|
||||
wxFloat64 ConvertFromIeeeExtended(const wxInt8 *bytes)
|
||||
{
|
||||
wxFloat64 f;
|
||||
wxInt32 expon;
|
||||
wxUint32 hiMant, loMant;
|
||||
|
||||
expon = ((bytes[0] & 0x7F) << 8) | (bytes[1] & 0xFF);
|
||||
hiMant = ((wxUint32)(bytes[2] & 0xFF) << 24)
|
||||
| ((wxUint32)(bytes[3] & 0xFF) << 16)
|
||||
| ((wxUint32)(bytes[4] & 0xFF) << 8)
|
||||
| ((wxUint32)(bytes[5] & 0xFF));
|
||||
loMant = ((wxUint32)(bytes[6] & 0xFF) << 24)
|
||||
| ((wxUint32)(bytes[7] & 0xFF) << 16)
|
||||
| ((wxUint32)(bytes[8] & 0xFF) << 8)
|
||||
| ((wxUint32)(bytes[9] & 0xFF));
|
||||
|
||||
if (expon == 0 && hiMant == 0 && loMant == 0) {
|
||||
f = 0;
|
||||
}
|
||||
else {
|
||||
if (expon == 0x7FFF) { /* Infinity or NaN */
|
||||
f = HUGE_VAL;
|
||||
}
|
||||
else {
|
||||
expon -= 16383;
|
||||
f = ldexp(UnsignedToFloat(hiMant), expon-=31);
|
||||
f += ldexp(UnsignedToFloat(loMant), expon-=32);
|
||||
}
|
||||
}
|
||||
|
||||
if (bytes[0] & 0x80)
|
||||
return -f;
|
||||
else
|
||||
return f;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************/
|
||||
|
||||
|
||||
void ConvertToIeeeExtended(wxFloat64 num, wxInt8 *bytes)
|
||||
{
|
||||
wxInt32 sign;
|
||||
wxInt32 expon;
|
||||
wxFloat64 fMant, fsMant;
|
||||
wxUint32 hiMant, loMant;
|
||||
|
||||
if (num < 0) {
|
||||
sign = 0x8000;
|
||||
num *= -1;
|
||||
} else {
|
||||
sign = 0;
|
||||
}
|
||||
|
||||
if (num == 0) {
|
||||
expon = 0; hiMant = 0; loMant = 0;
|
||||
}
|
||||
else {
|
||||
fMant = frexp(num, &expon);
|
||||
if ((expon > 16384) || !(fMant < 1)) { /* Infinity or NaN */
|
||||
expon = sign|0x7FFF; hiMant = 0; loMant = 0; /* infinity */
|
||||
}
|
||||
else { /* Finite */
|
||||
expon += 16382;
|
||||
if (expon < 0) { /* denormalized */
|
||||
fMant = ldexp(fMant, expon);
|
||||
expon = 0;
|
||||
}
|
||||
expon |= sign;
|
||||
fMant = ldexp(fMant, 32); fsMant = floor(fMant); hiMant = FloatToUnsigned(fsMant);
|
||||
fMant = ldexp(fMant - fsMant, 32); fsMant = floor(fMant); loMant = FloatToUnsigned(fsMant);
|
||||
}
|
||||
}
|
||||
|
||||
bytes[0] = expon >> 8;
|
||||
bytes[1] = expon;
|
||||
bytes[2] = hiMant >> 24;
|
||||
bytes[3] = hiMant >> 16;
|
||||
bytes[4] = hiMant >> 8;
|
||||
bytes[5] = hiMant;
|
||||
bytes[6] = loMant >> 24;
|
||||
bytes[7] = loMant >> 16;
|
||||
bytes[8] = loMant >> 8;
|
||||
bytes[9] = loMant;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* wxUSE_APPLE_IEEE */
|
||||
/*****************************************************************************
|
||||
** Name: extended.c
|
||||
** Purpose: IEEE Extended<->Double routines to save floats to file
|
||||
** Maintainer: Ryan Norton
|
||||
** Modified by:
|
||||
** Created: 11/24/04
|
||||
** RCS-ID: $Id: extended.c 36952 2006-01-18 10:25:04Z JS $
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
#if defined(_WIN32_WCE)
|
||||
/* eVC cause warnings in its own headers: stdlib.h and winnt.h */
|
||||
#pragma warning (disable:4115)
|
||||
#pragma warning (disable:4214)
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if defined(_WIN32_WCE)
|
||||
#pragma warning (default:4115)
|
||||
#pragma warning (default:4214)
|
||||
#endif
|
||||
|
||||
#if wxUSE_APPLE_IEEE
|
||||
|
||||
#include "wx/math.h"
|
||||
|
||||
/* Copyright (C) 1989-1991 Ken Turkowski. <turk@computer.org>
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Warranty Information
|
||||
* Even though I have reviewed this software, I make no warranty
|
||||
* or representation, either express or implied, with respect to this
|
||||
* software, its quality, accuracy, merchantability, or fitness for a
|
||||
* particular purpose. As a result, this software is provided "as is,"
|
||||
* and you, its user, are assuming the entire risk as to its quality
|
||||
* and accuracy.
|
||||
*
|
||||
* This code may be used and freely distributed as long as it includes
|
||||
* this copyright notice and the above warranty information.
|
||||
*
|
||||
* Machine-independent I/O routines for IEEE floating-point numbers.
|
||||
*
|
||||
* NaN's and infinities are converted to HUGE_VAL or HUGE, which
|
||||
* happens to be infinity on IEEE machines. Unfortunately, it is
|
||||
* impossible to preserve NaN's in a machine-independent way.
|
||||
* Infinities are, however, preserved on IEEE machines.
|
||||
*
|
||||
* These routines have been tested on the following machines:
|
||||
* Apple Macintosh, MPW 3.1 C compiler
|
||||
* Apple Macintosh, THINK C compiler
|
||||
* Silicon Graphics IRIS, MIPS compiler
|
||||
* Cray X/MP and Y/MP
|
||||
* Digital Equipment VAX
|
||||
* Sequent Balance (Multiprocesor 386)
|
||||
* NeXT
|
||||
*
|
||||
*
|
||||
* Implemented by Malcolm Slaney and Ken Turkowski.
|
||||
*
|
||||
* Malcolm Slaney contributions during 1988-1990 include big- and little-
|
||||
* endian file I/O, conversion to and from Motorola's extended 80-bit
|
||||
* floating-point format, and conversions to and from IEEE single-
|
||||
* precision floating-point format.
|
||||
*
|
||||
* In 1991, Ken Turkowski implemented the conversions to and from
|
||||
* IEEE double-precision format, added more precision to the extended
|
||||
* conversions, and accommodated conversions involving +/- infinity,
|
||||
* NaN's, and denormalized numbers.
|
||||
*/
|
||||
|
||||
#ifndef HUGE_VAL
|
||||
# define HUGE_VAL HUGE
|
||||
#endif /*HUGE_VAL*/
|
||||
|
||||
|
||||
/****************************************************************
|
||||
* The following two routines make up for deficiencies in many
|
||||
* compilers to convert properly between unsigned integers and
|
||||
* floating-point. Some compilers which have this bug are the
|
||||
* THINK_C compiler for the Macintosh and the C compiler for the
|
||||
* Silicon Graphics MIPS-based Iris.
|
||||
****************************************************************/
|
||||
|
||||
#ifdef applec /* The Apple C compiler works */
|
||||
# define FloatToUnsigned(f) ((wxUint32)(f))
|
||||
# define UnsignedToFloat(u) ((wxFloat64)(u))
|
||||
#else /*applec*/
|
||||
# define FloatToUnsigned(f) ((wxUint32)(((wxInt32)((f) - 2147483648.0)) + 2147483647L) + 1)
|
||||
# define UnsignedToFloat(u) (((wxFloat64)((wxInt32)((u) - 2147483647L - 1))) + 2147483648.0)
|
||||
#endif /*applec*/
|
||||
|
||||
|
||||
|
||||
/****************************************************************
|
||||
* Extended precision IEEE floating-point conversion routines.
|
||||
* Extended is an 80-bit number as defined by Motorola,
|
||||
* with a sign bit, 15 bits of exponent (offset 16383?),
|
||||
* and a 64-bit mantissa, with no hidden bit.
|
||||
****************************************************************/
|
||||
|
||||
wxFloat64 ConvertFromIeeeExtended(const wxInt8 *bytes)
|
||||
{
|
||||
wxFloat64 f;
|
||||
wxInt32 expon;
|
||||
wxUint32 hiMant, loMant;
|
||||
|
||||
expon = ((bytes[0] & 0x7F) << 8) | (bytes[1] & 0xFF);
|
||||
hiMant = ((wxUint32)(bytes[2] & 0xFF) << 24)
|
||||
| ((wxUint32)(bytes[3] & 0xFF) << 16)
|
||||
| ((wxUint32)(bytes[4] & 0xFF) << 8)
|
||||
| ((wxUint32)(bytes[5] & 0xFF));
|
||||
loMant = ((wxUint32)(bytes[6] & 0xFF) << 24)
|
||||
| ((wxUint32)(bytes[7] & 0xFF) << 16)
|
||||
| ((wxUint32)(bytes[8] & 0xFF) << 8)
|
||||
| ((wxUint32)(bytes[9] & 0xFF));
|
||||
|
||||
if (expon == 0 && hiMant == 0 && loMant == 0) {
|
||||
f = 0;
|
||||
}
|
||||
else {
|
||||
if (expon == 0x7FFF) { /* Infinity or NaN */
|
||||
f = HUGE_VAL;
|
||||
}
|
||||
else {
|
||||
expon -= 16383;
|
||||
f = ldexp(UnsignedToFloat(hiMant), expon-=31);
|
||||
f += ldexp(UnsignedToFloat(loMant), expon-=32);
|
||||
}
|
||||
}
|
||||
|
||||
if (bytes[0] & 0x80)
|
||||
return -f;
|
||||
else
|
||||
return f;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************/
|
||||
|
||||
|
||||
void ConvertToIeeeExtended(wxFloat64 num, wxInt8 *bytes)
|
||||
{
|
||||
wxInt32 sign;
|
||||
wxInt32 expon;
|
||||
wxFloat64 fMant, fsMant;
|
||||
wxUint32 hiMant, loMant;
|
||||
|
||||
if (num < 0) {
|
||||
sign = 0x8000;
|
||||
num *= -1;
|
||||
} else {
|
||||
sign = 0;
|
||||
}
|
||||
|
||||
if (num == 0) {
|
||||
expon = 0; hiMant = 0; loMant = 0;
|
||||
}
|
||||
else {
|
||||
fMant = frexp(num, &expon);
|
||||
if ((expon > 16384) || !(fMant < 1)) { /* Infinity or NaN */
|
||||
expon = sign|0x7FFF; hiMant = 0; loMant = 0; /* infinity */
|
||||
}
|
||||
else { /* Finite */
|
||||
expon += 16382;
|
||||
if (expon < 0) { /* denormalized */
|
||||
fMant = ldexp(fMant, expon);
|
||||
expon = 0;
|
||||
}
|
||||
expon |= sign;
|
||||
fMant = ldexp(fMant, 32); fsMant = floor(fMant); hiMant = FloatToUnsigned(fsMant);
|
||||
fMant = ldexp(fMant - fsMant, 32); fsMant = floor(fMant); loMant = FloatToUnsigned(fsMant);
|
||||
}
|
||||
}
|
||||
|
||||
bytes[0] = expon >> 8;
|
||||
bytes[1] = expon;
|
||||
bytes[2] = hiMant >> 24;
|
||||
bytes[3] = hiMant >> 16;
|
||||
bytes[4] = hiMant >> 8;
|
||||
bytes[5] = hiMant;
|
||||
bytes[6] = loMant >> 24;
|
||||
bytes[7] = loMant >> 16;
|
||||
bytes[8] = loMant >> 8;
|
||||
bytes[9] = loMant;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* wxUSE_APPLE_IEEE */
|
||||
|
||||
+45
-45
@@ -1,45 +1,45 @@
|
||||
/****************************************************************************
|
||||
* Name: winestub.cpp
|
||||
* Purpose: wxWINE module mapping main() to WinMain()
|
||||
* Author: Robert Roebling
|
||||
* Created: 04/01/98
|
||||
* RCS-ID: $Id: winestub.c 29038 2004-09-07 11:11:05Z ABX $
|
||||
* Copyright: (c) Robert Roebling
|
||||
* Licence: wxWidgets Licence
|
||||
*****************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
#include "winuser.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
extern int PASCAL WinMain( HINSTANCE, HINSTANCE, LPSTR, int );
|
||||
extern HINSTANCE MAIN_WinelibInit( int *argc, char *argv[] );
|
||||
|
||||
/* Most Windows C/C++ compilers use something like this to */
|
||||
/* access argc and argv globally: */
|
||||
int _ARGC;
|
||||
char **_ARGV;
|
||||
|
||||
int main( int argc, char *argv [] )
|
||||
{
|
||||
HINSTANCE hInstance;
|
||||
LPSTR lpszCmdParam;
|
||||
int i, len = 0;
|
||||
_ARGC = argc;
|
||||
_ARGV = (char **)argv;
|
||||
|
||||
if (!(hInstance = MAIN_WinelibInit( &argc, argv ))) return 0;
|
||||
|
||||
/* Alloc szCmdParam */
|
||||
for (i = 1; i < argc; i++) len += strlen(argv[i]) + 1;
|
||||
lpszCmdParam = (LPSTR) xmalloc(len + 1);
|
||||
/* Concatenate arguments */
|
||||
if (argc > 1) strcpy(lpszCmdParam, argv[1]);
|
||||
else lpszCmdParam[0] = '\0';
|
||||
for (i = 2; i < argc; i++) strcat(strcat(lpszCmdParam, " "), argv[i]);
|
||||
|
||||
return WinMain (hInstance, /* hInstance */
|
||||
0, /* hPrevInstance */
|
||||
lpszCmdParam, /* lpszCmdParam */
|
||||
SW_NORMAL); /* nCmdShow */
|
||||
}
|
||||
/****************************************************************************
|
||||
* Name: winestub.cpp
|
||||
* Purpose: wxWINE module mapping main() to WinMain()
|
||||
* Author: Robert Roebling
|
||||
* Created: 04/01/98
|
||||
* RCS-ID: $Id: winestub.c 29038 2004-09-07 11:11:05Z ABX $
|
||||
* Copyright: (c) Robert Roebling
|
||||
* Licence: wxWidgets Licence
|
||||
*****************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
#include "winuser.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
extern int PASCAL WinMain( HINSTANCE, HINSTANCE, LPSTR, int );
|
||||
extern HINSTANCE MAIN_WinelibInit( int *argc, char *argv[] );
|
||||
|
||||
/* Most Windows C/C++ compilers use something like this to */
|
||||
/* access argc and argv globally: */
|
||||
int _ARGC;
|
||||
char **_ARGV;
|
||||
|
||||
int main( int argc, char *argv [] )
|
||||
{
|
||||
HINSTANCE hInstance;
|
||||
LPSTR lpszCmdParam;
|
||||
int i, len = 0;
|
||||
_ARGC = argc;
|
||||
_ARGV = (char **)argv;
|
||||
|
||||
if (!(hInstance = MAIN_WinelibInit( &argc, argv ))) return 0;
|
||||
|
||||
/* Alloc szCmdParam */
|
||||
for (i = 1; i < argc; i++) len += strlen(argv[i]) + 1;
|
||||
lpszCmdParam = (LPSTR) xmalloc(len + 1);
|
||||
/* Concatenate arguments */
|
||||
if (argc > 1) strcpy(lpszCmdParam, argv[1]);
|
||||
else lpszCmdParam[0] = '\0';
|
||||
for (i = 2; i < argc; i++) strcat(strcat(lpszCmdParam, " "), argv[i]);
|
||||
|
||||
return WinMain (hInstance, /* hInstance */
|
||||
0, /* hPrevInstance */
|
||||
lpszCmdParam, /* lpszCmdParam */
|
||||
SW_NORMAL); /* nCmdShow */
|
||||
}
|
||||
|
||||
Vendored
+826
-826
File diff suppressed because it is too large
Load Diff
+295
-295
File diff suppressed because it is too large
Load Diff
+5408
-5408
File diff suppressed because it is too large
Load Diff
Vendored
+934
-934
File diff suppressed because it is too large
Load Diff
Vendored
+595
-595
File diff suppressed because it is too large
Load Diff
+1573
-1573
File diff suppressed because it is too large
Load Diff
+1453
-1453
File diff suppressed because it is too large
Load Diff
Vendored
+161
-161
@@ -1,161 +1,161 @@
|
||||
|
||||
/* pngrio.c - functions for data input
|
||||
*
|
||||
* libpng 1.2.7 - September 12, 2004
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2004 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
* This file provides a location for all input. Users who need
|
||||
* special handling are expected to write a function that has the same
|
||||
* arguments as this and performs a similar function, but that possibly
|
||||
* has a different input method. Note that you shouldn't change this
|
||||
* function, but rather write a replacement function and then make
|
||||
* libpng use it at run time with png_set_read_fn(...).
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
#include "png.h"
|
||||
|
||||
/* Read the data from whatever input you are using. The default routine
|
||||
reads from a file pointer. Note that this routine sometimes gets called
|
||||
with very small lengths, so you should implement some kind of simple
|
||||
buffering if you are using unbuffered reads. This should never be asked
|
||||
to read more then 64K on a 16 bit machine. */
|
||||
void /* PRIVATE */
|
||||
png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_debug1(4,"reading %d bytes\n", (int)length);
|
||||
if (png_ptr->read_data_fn != NULL)
|
||||
(*(png_ptr->read_data_fn))(png_ptr, data, length);
|
||||
else
|
||||
png_error(png_ptr, "Call to NULL read function");
|
||||
}
|
||||
|
||||
#if !defined(PNG_NO_STDIO)
|
||||
/* This is the function that does the actual reading of data. If you are
|
||||
not reading from a standard C stream, you should create a replacement
|
||||
read_data function and use it at run time with png_set_read_fn(), rather
|
||||
than changing the library. */
|
||||
#ifndef USE_FAR_KEYWORD
|
||||
void PNGAPI
|
||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_size_t check;
|
||||
|
||||
/* fread() returns 0 on error, so it is OK to store this in a png_size_t
|
||||
* instead of an int, which is what fread() actually returns.
|
||||
*/
|
||||
#if defined(_WIN32_WCE)
|
||||
if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) )
|
||||
check = 0;
|
||||
#else
|
||||
check = (png_size_t)fread(data, (png_size_t)1, length,
|
||||
(png_FILE_p)png_ptr->io_ptr);
|
||||
#endif
|
||||
|
||||
if (check != length)
|
||||
png_error(png_ptr, "Read Error");
|
||||
}
|
||||
#else
|
||||
/* this is the model-independent version. Since the standard I/O library
|
||||
can't handle far buffers in the medium and small models, we have to copy
|
||||
the data.
|
||||
*/
|
||||
|
||||
#define NEAR_BUF_SIZE 1024
|
||||
#define MIN(a,b) (a <= b ? a : b)
|
||||
|
||||
static void /* PRIVATE */
|
||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
int check;
|
||||
png_byte *n_data;
|
||||
png_FILE_p io_ptr;
|
||||
|
||||
/* Check if data really is near. If so, use usual code. */
|
||||
n_data = (png_byte *)CVT_PTR_NOCHECK(data);
|
||||
io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
|
||||
if ((png_bytep)n_data == data)
|
||||
{
|
||||
#if defined(_WIN32_WCE)
|
||||
if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) )
|
||||
check = 0;
|
||||
#else
|
||||
check = fread(n_data, 1, length, io_ptr);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
png_byte buf[NEAR_BUF_SIZE];
|
||||
png_size_t read, remaining, err;
|
||||
check = 0;
|
||||
remaining = length;
|
||||
do
|
||||
{
|
||||
read = MIN(NEAR_BUF_SIZE, remaining);
|
||||
#if defined(_WIN32_WCE)
|
||||
if ( !ReadFile((HANDLE)(io_ptr), buf, read, &err, NULL) )
|
||||
err = 0;
|
||||
#else
|
||||
err = fread(buf, (png_size_t)1, read, io_ptr);
|
||||
#endif
|
||||
png_memcpy(data, buf, read); /* copy far buffer to near buffer */
|
||||
if(err != read)
|
||||
break;
|
||||
else
|
||||
check += err;
|
||||
data += read;
|
||||
remaining -= read;
|
||||
}
|
||||
while (remaining != 0);
|
||||
}
|
||||
if ((png_uint_32)check != (png_uint_32)length)
|
||||
png_error(png_ptr, "read Error");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* This function allows the application to supply a new input function
|
||||
for libpng if standard C streams aren't being used.
|
||||
|
||||
This function takes as its arguments:
|
||||
png_ptr - pointer to a png input data structure
|
||||
io_ptr - pointer to user supplied structure containing info about
|
||||
the input functions. May be NULL.
|
||||
read_data_fn - pointer to a new input function that takes as its
|
||||
arguments a pointer to a png_struct, a pointer to
|
||||
a location where input data can be stored, and a 32-bit
|
||||
unsigned int that is the number of bytes to be read.
|
||||
To exit and output any fatal error messages the new write
|
||||
function should call png_error(png_ptr, "Error msg"). */
|
||||
void PNGAPI
|
||||
png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||
png_rw_ptr read_data_fn)
|
||||
{
|
||||
png_ptr->io_ptr = io_ptr;
|
||||
|
||||
#if !defined(PNG_NO_STDIO)
|
||||
if (read_data_fn != NULL)
|
||||
png_ptr->read_data_fn = read_data_fn;
|
||||
else
|
||||
png_ptr->read_data_fn = png_default_read_data;
|
||||
#else
|
||||
png_ptr->read_data_fn = read_data_fn;
|
||||
#endif
|
||||
|
||||
/* It is an error to write to a read device */
|
||||
if (png_ptr->write_data_fn != NULL)
|
||||
{
|
||||
png_ptr->write_data_fn = NULL;
|
||||
png_warning(png_ptr,
|
||||
"It's an error to set both read_data_fn and write_data_fn in the ");
|
||||
png_warning(png_ptr,
|
||||
"same structure. Resetting write_data_fn to NULL.");
|
||||
}
|
||||
|
||||
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
|
||||
png_ptr->output_flush_fn = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* pngrio.c - functions for data input
|
||||
*
|
||||
* libpng 1.2.7 - September 12, 2004
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2004 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
* This file provides a location for all input. Users who need
|
||||
* special handling are expected to write a function that has the same
|
||||
* arguments as this and performs a similar function, but that possibly
|
||||
* has a different input method. Note that you shouldn't change this
|
||||
* function, but rather write a replacement function and then make
|
||||
* libpng use it at run time with png_set_read_fn(...).
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
#include "png.h"
|
||||
|
||||
/* Read the data from whatever input you are using. The default routine
|
||||
reads from a file pointer. Note that this routine sometimes gets called
|
||||
with very small lengths, so you should implement some kind of simple
|
||||
buffering if you are using unbuffered reads. This should never be asked
|
||||
to read more then 64K on a 16 bit machine. */
|
||||
void /* PRIVATE */
|
||||
png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_debug1(4,"reading %d bytes\n", (int)length);
|
||||
if (png_ptr->read_data_fn != NULL)
|
||||
(*(png_ptr->read_data_fn))(png_ptr, data, length);
|
||||
else
|
||||
png_error(png_ptr, "Call to NULL read function");
|
||||
}
|
||||
|
||||
#if !defined(PNG_NO_STDIO)
|
||||
/* This is the function that does the actual reading of data. If you are
|
||||
not reading from a standard C stream, you should create a replacement
|
||||
read_data function and use it at run time with png_set_read_fn(), rather
|
||||
than changing the library. */
|
||||
#ifndef USE_FAR_KEYWORD
|
||||
void PNGAPI
|
||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_size_t check;
|
||||
|
||||
/* fread() returns 0 on error, so it is OK to store this in a png_size_t
|
||||
* instead of an int, which is what fread() actually returns.
|
||||
*/
|
||||
#if defined(_WIN32_WCE)
|
||||
if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) )
|
||||
check = 0;
|
||||
#else
|
||||
check = (png_size_t)fread(data, (png_size_t)1, length,
|
||||
(png_FILE_p)png_ptr->io_ptr);
|
||||
#endif
|
||||
|
||||
if (check != length)
|
||||
png_error(png_ptr, "Read Error");
|
||||
}
|
||||
#else
|
||||
/* this is the model-independent version. Since the standard I/O library
|
||||
can't handle far buffers in the medium and small models, we have to copy
|
||||
the data.
|
||||
*/
|
||||
|
||||
#define NEAR_BUF_SIZE 1024
|
||||
#define MIN(a,b) (a <= b ? a : b)
|
||||
|
||||
static void /* PRIVATE */
|
||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
int check;
|
||||
png_byte *n_data;
|
||||
png_FILE_p io_ptr;
|
||||
|
||||
/* Check if data really is near. If so, use usual code. */
|
||||
n_data = (png_byte *)CVT_PTR_NOCHECK(data);
|
||||
io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
|
||||
if ((png_bytep)n_data == data)
|
||||
{
|
||||
#if defined(_WIN32_WCE)
|
||||
if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) )
|
||||
check = 0;
|
||||
#else
|
||||
check = fread(n_data, 1, length, io_ptr);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
png_byte buf[NEAR_BUF_SIZE];
|
||||
png_size_t read, remaining, err;
|
||||
check = 0;
|
||||
remaining = length;
|
||||
do
|
||||
{
|
||||
read = MIN(NEAR_BUF_SIZE, remaining);
|
||||
#if defined(_WIN32_WCE)
|
||||
if ( !ReadFile((HANDLE)(io_ptr), buf, read, &err, NULL) )
|
||||
err = 0;
|
||||
#else
|
||||
err = fread(buf, (png_size_t)1, read, io_ptr);
|
||||
#endif
|
||||
png_memcpy(data, buf, read); /* copy far buffer to near buffer */
|
||||
if(err != read)
|
||||
break;
|
||||
else
|
||||
check += err;
|
||||
data += read;
|
||||
remaining -= read;
|
||||
}
|
||||
while (remaining != 0);
|
||||
}
|
||||
if ((png_uint_32)check != (png_uint_32)length)
|
||||
png_error(png_ptr, "read Error");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* This function allows the application to supply a new input function
|
||||
for libpng if standard C streams aren't being used.
|
||||
|
||||
This function takes as its arguments:
|
||||
png_ptr - pointer to a png input data structure
|
||||
io_ptr - pointer to user supplied structure containing info about
|
||||
the input functions. May be NULL.
|
||||
read_data_fn - pointer to a new input function that takes as its
|
||||
arguments a pointer to a png_struct, a pointer to
|
||||
a location where input data can be stored, and a 32-bit
|
||||
unsigned int that is the number of bytes to be read.
|
||||
To exit and output any fatal error messages the new write
|
||||
function should call png_error(png_ptr, "Error msg"). */
|
||||
void PNGAPI
|
||||
png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||
png_rw_ptr read_data_fn)
|
||||
{
|
||||
png_ptr->io_ptr = io_ptr;
|
||||
|
||||
#if !defined(PNG_NO_STDIO)
|
||||
if (read_data_fn != NULL)
|
||||
png_ptr->read_data_fn = read_data_fn;
|
||||
else
|
||||
png_ptr->read_data_fn = png_default_read_data;
|
||||
#else
|
||||
png_ptr->read_data_fn = read_data_fn;
|
||||
#endif
|
||||
|
||||
/* It is an error to write to a read device */
|
||||
if (png_ptr->write_data_fn != NULL)
|
||||
{
|
||||
png_ptr->write_data_fn = NULL;
|
||||
png_warning(png_ptr,
|
||||
"It's an error to set both read_data_fn and write_data_fn in the ");
|
||||
png_warning(png_ptr,
|
||||
"same structure. Resetting write_data_fn to NULL.");
|
||||
}
|
||||
|
||||
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
|
||||
png_ptr->output_flush_fn = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
+4177
-4177
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user