blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 5
146
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
7
| license_type
stringclasses 2
values | repo_name
stringlengths 6
79
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 4
values | visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.07k
426M
⌀ | star_events_count
int64 0
27
| fork_events_count
int64 0
12
| gha_license_id
stringclasses 3
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 6
values | src_encoding
stringclasses 26
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 1
class | length_bytes
int64 20
6.28M
| extension
stringclasses 20
values | content
stringlengths 20
6.28M
| authors
listlengths 1
16
| author_lines
listlengths 1
16
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
104930ac63d3c2c9ea4275afbc764e054214676f | 677f7dc99f7c3f2c6aed68f41c50fd31f90c1a1f | /SolidSBCTestSDK/SolidSBCTestManager.h | 35c98440926234fdbb617650163caa00a62fa4bc | []
| no_license | M0WA/SolidSBC | 0d743c71ec7c6f8cfe78bd201d0eb59c2a8fc419 | 3e9682e90a22650e12338785c368ed69a9cac18b | refs/heads/master | 2020-04-19T14:40:36.625222 | 2011-12-02T01:50:05 | 2011-12-02T01:50:05 | 168,250,374 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,340 | h | #pragma once
#include "SolidSBCTestSDK.h"
class SOLIDSBCTESTSDK_API CSolidSBCTestManager
{
protected:
CSolidSBCTestManager(void);
~CSolidSBCTestManager(void);
public:
int StartTest(const std::string& sXML);
int StopTest (const std::string& sTestName);
int GetTestResults(std::vector<CSolidSBCTestResult*>& vecResults);
CSolidSBCTestConfig* GetTestConfigByName( const std::string& sTestName );
void SetTestConfigByName( const std::string& sTestName, CSolidSBCTestConfig* pConfig );
int GetRegisteredTestCount(void) { return (int)m_vecTestNames.size(); };
int GetTestNames (std::vector<std::string>& vecTestnames);
bool HasTestName ( const std::string& sTestName );
void GetCreateTableStatements(std::string& sStatement);
protected:
void RegisterTest(AFX_THREADPROC pThreadFunc, CSolidSBCTestConfig* pDefaultConfig, CSolidSBCTestResult* pTestResult);
private:
AFX_THREADPROC GetThreadFuncByName(const std::string& sTestName);
std::vector<SSBC_TESTNAME_FUNC_PAIR_TYPE> m_vecTestNames;
SSBC_RESULT_MAP_TYPE m_mapTestResults;
SSBC_CONFIG_MAP_TYPE m_mapTestConfigs;
std::map<std::string,CSolidSBCTestResult*> m_mapTestResultDataTypes;
std::vector<CSolidSBCTestThread*> m_vecRunningTests;
}; | [
"admin@bd7e3521-35e9-406e-9279-390287f868d3"
]
| [
[
[
1,
37
]
]
]
|
e3ea2e9a86f1af9b308815af90c682d93e4a5964 | 6b83c731acb331c4f7ddd167ab5bb562b450d0f2 | /my_inc2/Draw08.cpp | f7651d0c70e489b028a3478e4ef49d84d2591cfa | []
| no_license | weimingtom/toheart2p | fbfb96f6ca8d3102b462ba53d3c9cff16ca509e7 | 560e99c42fdff23e65f16df6d14df9a9f1868d8e | refs/heads/master | 2021-01-10T01:36:31.515707 | 2007-12-20T15:13:51 | 2007-12-20T15:13:51 | 44,464,730 | 2 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 13,987 | cpp |
#include <mm_std.h>
#include "bmp.h"
#include "draw.h"
#include "palette.h"
int DRW_GetStartPointerSrc(int sx, int sy, int sw, int sh, int w, int rparam)
{
int ret;
if (rparam &REV_H)
{
ret = (sy + sh - 1) *w;
}
else
{
ret = sy * w;
}
if (rparam &REV_W)
{
ret += sx + sw - 1;
}
else
{
ret += sx;
}
return ret;
}
//-------------------------------------------------------------------------
BOOL DRW_DrawBMP_BB_Std(BMP_BT *dest, int dest_x, int dest_y, BMP_BT *src, int src_x, int src_y, int w, int h, int nuki,
RECT *clip, int r, int g, int b, int rparam)
{
int x, y;
int inc_x = ((rparam &REV_W) ? - 1: 1), inc_y = ((rparam &REV_H) ? - 1: 1);
int drev = dest->sx - w;
int srev = src->sx *inc_y - w * inc_x;
char *dest_p = dest->buf + dest_y * dest->sx + dest_x;
char *src_p = src->buf + DRW_GetStartPointerSrc(src_x, src_y, w, h, src->sx, rparam);
char bright_index[256];
int i, rr, gg, bb;
if (dest->buf == NULL)
{
DebugPrintf("Ãè»îIÓò¤¬¤¢¤ê¤Þ¤»¤ó\n");
return FALSE;
}
if (src->buf == NULL)
{
DebugPrintf("»ÏñîIÓò¤¬¤¢¤ê¤Þ¤»¤ó\n");
return FALSE;
}
if (r == BRT_NML && g == BRT_NML && b == BRT_NML)
{
if (nuki == - 1)
{
if (!rparam)
{
if (w == dest->sx && w == src->sx)
{
CopyMemory(dest_p, src_p, w *h);
}
else
{
for (y = 0; y < h; y++, dest_p += dest->sx, src_p += src->sx)
{
CopyMemory(dest_p, src_p, w);
}
}
}
else
{
for (y = 0; y < h; y++, dest_p += drev, src_p += srev)
{
for (x = 0; x < w; x++, dest_p++, src_p += inc_x)
{
*dest_p = *src_p;
}
}
}
}
else
{
for (y = 0; y < h; y++, dest_p += drev, src_p += srev)
{
for (x = 0; x < w; x++, dest_p++, src_p += inc_x)
{
if (*src_p != nuki)
{
*dest_p = *src_p;
}
}
}
}
}
else
{
for (i = 0; i < 256; i++)
{
if (r < BRT_NML)
{
rr = (GlobalPal[i].r *r) >> 10;
}
else
{
rr = ((((0xff - GlobalPal[i].r)*(r - BRT_NML)) >> 7) + GlobalPal[i].r) >> 3;
}
if (g < BRT_NML)
{
gg = (GlobalPal[i].g *g) >> 10;
}
else
{
gg = ((((0xff - GlobalPal[i].g)*(g - BRT_NML)) >> 7) + GlobalPal[i].g) >> 3;
}
if (b < BRT_NML)
{
bb = (GlobalPal[i].b *b) >> 10;
}
else
{
bb = ((((0xff - GlobalPal[i].b)*(b - BRT_NML)) >> 7) + GlobalPal[i].b) >> 3;
}
bright_index[i] = PaletteIndex[(rr << 10) | (gg << 5) | bb];
}
if (nuki == - 1)
{
for (y = 0; y < h; y++, dest_p += drev, src_p += srev)
{
for (x = 0; x < w; x++, dest_p++, src_p += inc_x)
{
*dest_p = bright_index[ *src_p];
}
}
}
else
{
for (y = 0; y < h; y++, dest_p += drev, src_p += srev)
{
for (x = 0; x < w; x++, dest_p++, src_p += inc_x)
{
if (*src_p != nuki)
{
*dest_p = bright_index[ *src_p];
}
}
}
}
}
return TRUE;
}
//-------------------------------------------------------------------------
BOOL DRW_DrawBMP_BB_Pal(BMP_BT *dest, int dest_x, int dest_y, BMP_BT *src, int src_x, int src_y, int w, int h, int nuki,
RECT *clip, int r, int g, int b)
{
int x, y;
int drev = dest->sx - w;
int srev = src->sx - w;
char *dest_p = dest->buf + dest_y * dest->sx + dest_x;
char *src_p = src->buf + src_y * src->sx + src_x;
RGB32 *spal = src->pal;
if (dest->buf == NULL)
{
DebugPrintf("Ãè»îIÓò¤¬¤¢¤ê¤Þ¤»¤ó\n");
return FALSE;
}
if (src->buf == NULL)
{
DebugPrintf("»ÏñîIÓò¤¬¤¢¤ê¤Þ¤»¤ó\n");
return FALSE;
}
if (r == BRT_NML && g == BRT_NML && b == BRT_NML)
{
if (nuki == - 1)
{
for (y = 0; y < h; y++, dest_p += drev, src_p += srev)
{
for (x = 0; x < w; x++, dest_p++, src_p++)
{
*dest_p = PaletteIndex[(spal[ *src_p].r >> 3 << 10) | (spal[ *src_p].g >> 3 << 5) | (spal[ *src_p].b >> 3)];
}
}
}
else
{
for (y = 0; y < h; y++, dest_p += drev, src_p += srev)
{
for (x = 0; x < w; x++, dest_p++, src_p++)
{
*dest_p = PaletteIndex[(spal[ *src_p].r >> 3 << 10) | (spal[ *src_p].g >> 3 << 5) | (spal[ *src_p].b >> 3)];
}
}
}
}
return TRUE;
}
//-------------------------------------------------------------------------
BOOL DRW_DrawBMP_BB_Bld(BMP_BT *dest, int dest_x, int dest_y, BMP_BT *src, int src_x, int src_y, int w, int h, int nuki,
RECT *clip, int r, int g, int b, int blnd)
{
int x, y;
int w2 = w / 4;
int drev = dest->sx - w;
int srev = src->sx - w;
char *dest_p = dest->buf + dest_y * dest->sx + dest_x;
char *src_p = src->buf + src_y * src->sx + src_x;
char(*bl_index)[256] = &BlendIndex[blnd / 8][0];
if (blnd == BLD_0P)
{
return 1;
}
if (blnd == BLD_100P)
{
return DRW_DrawBMP_BB_Std(dest, dest_x, dest_y, src, src_x, src_y, w, h, nuki, clip, r, g, b, 0);
}
if (dest->buf == NULL)
{
DebugPrintf("Ãè»îIÓò¤¬¤¢¤ê¤Þ¤»¤ó\n");
return FALSE;
}
if (src->buf == NULL)
{
DebugPrintf("»ÏñîIÓò¤¬¤¢¤ê¤Þ¤»¤ó\n");
return FALSE;
}
if (nuki == - 1)
{
for (y = 0; y < h; y++, dest_p += drev, src_p += srev)
{
for (x = 0; x < w2; x++, dest_p += 4, src_p += 4)
{
*(DWORD*)dest_p = (bl_index[*(dest_p)][*(src_p)]) | (bl_index[*(dest_p + 1)][*(src_p + 1)] << 8) | (bl_index[*
(dest_p + 2)][*(src_p + 2)] << 16) | (bl_index[*(dest_p + 3)][*(src_p + 3)] << 24);
}
}
}
else
{
for (y = 0; y < h; y++, dest_p += drev, src_p += srev)
{
for (x = 0; x < w; x++, dest_p++, src_p++)
{
if (*src_p != nuki)
{
*dest_p = bl_index[ *dest_p][ *src_p];
}
}
}
}
return TRUE;
}
//-------------------------------------------------------------------------
BOOL DRW_DrawBMP_BB_Add(BMP_BT *dest, int dest_x, int dest_y, BMP_BT *src, int src_x, int src_y, int w, int h, int nuki,
RECT *clip, int r, int g, int b)
{
int x, y;
int w2 = w / 4;
int drev = dest->sx - w;
int srev = src->sx - w;
char *dest_p = dest->buf + dest_y * dest->sx + dest_x;
char *src_p = src->buf + src_y * src->sx + src_x;
char(*add_index)[256] = AddIndex;
if (dest->buf == NULL)
{
DebugPrintf("Ãè»îIÓò¤¬¤¢¤ê¤Þ¤»¤ó\n");
return FALSE;
}
if (src->buf == NULL)
{
DebugPrintf("»ÏñîIÓò¤¬¤¢¤ê¤Þ¤»¤ó\n");
return FALSE;
}
if (nuki == - 1)
{
for (y = 0; y < h; y++, dest_p += drev, src_p += srev)
{
for (x = 0; x < w2; x++, dest_p += 4, src_p += 4)
{
*(DWORD*)dest_p = (add_index[*(dest_p)][*(src_p)]) | (add_index[*(dest_p + 1)][*(src_p + 1)] << 8) | (add_index[*
(dest_p + 2)][*(src_p + 2)] << 16) | (add_index[*(dest_p + 3)][*(src_p + 3)] << 24);
}
}
}
else
{
for (y = 0; y < h; y++, dest_p += drev, src_p += srev)
{
for (x = 0; x < w; x++, dest_p++, src_p++)
{
if (*src_p != nuki)
{
*dest_p = add_index[ *dest_p][ *src_p];
}
}
}
}
return TRUE;
}
//-------------------------------------------------------------------------
BOOL DRW_DrawBMP_BB_Sub(BMP_BT *dest, int dest_x, int dest_y, BMP_BT *src, int src_x, int src_y, int w, int h, int nuki,
RECT *clip, int r, int g, int b)
{
int x, y;
int w2 = w / 4;
int drev = dest->sx - w;
int srev = src->sx - w;
char *dest_p = dest->buf + dest_y * dest->sx + dest_x;
char *src_p = src->buf + src_y * src->sx + src_x;
char(*sub_index)[256] = SubIndex;
if (dest->buf == NULL)
{
DebugPrintf("Ãè»îIÓò¤¬¤¢¤ê¤Þ¤»¤ó\n");
return FALSE;
}
if (src->buf == NULL)
{
DebugPrintf("»ÏñîIÓò¤¬¤¢¤ê¤Þ¤»¤ó\n");
return FALSE;
}
if (nuki == - 1)
{
for (y = 0; y < h; y++, dest_p += drev, src_p += srev)
{
for (x = 0; x < w2; x++, dest_p += 4, src_p += 4)
{
*(DWORD*)dest_p = (sub_index[*(dest_p)][*(src_p)]) | (sub_index[*(dest_p + 1)][*(src_p + 1)] << 8) | (sub_index[*
(dest_p + 2)][*(src_p + 2)] << 16) | (sub_index[*(dest_p + 3)][*(src_p + 3)] << 24);
}
}
}
else
{
for (y = 0; y < h; y++, dest_p += drev, src_p += srev)
{
for (x = 0; x < w; x++, dest_p++, src_p++)
{
if (*src_p != nuki)
{
*dest_p = sub_index[ *dest_p][ *src_p];
}
}
}
}
return TRUE;
}
//-------------------------------------------------------------------------
BOOL DRW_DrawBMP_BB_Mul(BMP_BT *dest, int dest_x, int dest_y, BMP_BT *src, int src_x, int src_y, int w, int h, int nuki,
RECT *clip, int r, int g, int b)
{
int x, y;
int w2 = w / 4;
int drev = dest->sx - w;
int srev = src->sx - w;
char *dest_p = dest->buf + dest_y * dest->sx + dest_x;
char *src_p = src->buf + src_y * src->sx + src_x;
char(*mul_index)[256] = MulIndex;
if (dest->buf == NULL)
{
DebugPrintf("Ãè»îIÓò¤¬¤¢¤ê¤Þ¤»¤ó\n");
return FALSE;
}
if (src->buf == NULL)
{
DebugPrintf("»ÏñîIÓò¤¬¤¢¤ê¤Þ¤»¤ó\n");
return FALSE;
}
if (nuki == - 1)
{
for (y = 0; y < h; y++, dest_p += drev, src_p += srev)
{
for (x = 0; x < w2; x++, dest_p += 4, src_p += 4)
{
*(DWORD*)dest_p = (mul_index[*(dest_p)][*(src_p)]) | (mul_index[*(dest_p + 1)][*(src_p + 1)] << 8) | (mul_index[*
(dest_p + 2)][*(src_p + 2)] << 16) | (mul_index[*(dest_p + 3)][*(src_p + 3)] << 24);
}
}
}
else
{
for (y = 0; y < h; y++, dest_p += drev, src_p += srev)
{
for (x = 0; x < w; x++, dest_p++, src_p++)
{
if (*src_p != nuki)
{
*dest_p = mul_index[ *dest_p][ *src_p];
}
}
}
}
return TRUE;
}
//-------------------------------------------------------------------------
BOOL DRW_DrawBMP_BB(BMP_BT *dest, int dest_x, int dest_y, BMP_BT *src, int src_x, int src_y, int w, int h, int nuki,
RECT *clip, int r, int g, int b, DWORD wparam, DWORD rparam)
{
BOOL ret = TRUE;
int blnd = HIWORD(wparam);
int param = LOWORD(wparam);
if (clip != (void*) - 1)
{
if (!ClipRect(&dest_x, &dest_y, dest->sx, dest->sy, &src_x, &src_y, src->sx, src->sy, &w, &h, clip))
{
return 0;
}
}
for (int i = 0; i < 256; i++)
{
dest->pal[i] = src->pal[i];
}
switch (param)
{
default:
case DRW_NML:
DRW_DrawBMP_BB_Std(dest, dest_x, dest_y, src, src_x, src_y, w, h, nuki, clip, r, g, b, rparam);
break;
case DRW_PAL:
DRW_DrawBMP_BB_Pal(dest, dest_x, dest_y, src, src_x, src_y, w, h, nuki, clip, r, g, b);
break;
case DRW_BLD2:
DRW_DrawBMP_BB_Bld(dest, dest_x, dest_y, src, src_x, src_y, w, h, nuki, clip, r, g, b, blnd);
break;
case DRW_ADD:
DRW_DrawBMP_BB_Add(dest, dest_x, dest_y, src, src_x, src_y, w, h, nuki, clip, r, g, b);
break;
case DRW_SUB:
DRW_DrawBMP_BB_Sub(dest, dest_x, dest_y, src, src_x, src_y, w, h, nuki, clip, r, g, b);
break;
case DRW_MUL:
DRW_DrawBMP_BB_Mul(dest, dest_x, dest_y, src, src_x, src_y, w, h, nuki, clip, r, g, b);
break;
}
return TRUE;
}
//-------------------------------------------------------------------------
BOOL DRW_DrawZOOM_BB_Std(BMP_BT *dest, int dx, int dy, int dw, int dh, int dw2, int dh2, BMP_BT *src, int sx, int sy,
int sw, int sh, int sw2, int sh2, int xxx, int yyy, int nuki, int r, int g, int b)
{
int x, y;
char *src_p = src->buf + sy * src->sx + sx, *sss;
char *dest_p = dest->buf + dy * dest->sx + dx;
int drev = dest->sx - dw;
int px, py, wx, wy, xx, yy;
if (sw *2 == dw && sh *2 == dh)
{
if (nuki == - 1 || nuki == - 3){}
}
px = sw2 / dw2;
wx = sw2 % dw2;
py = sh2 / dh2 * src->sx;
wy = sh2 % dh2;
if (r == 0x80 && g == 0x80 && b == 0x80)
{
if (nuki == - 1)
{
yy = yyy;
for (y = 0; y < dh; y++, dest_p += drev)
{
sss = src_p;
xx = xxx;
for (x = 0; x < dw; x++, dest_p++)
{
*dest_p = *sss;
sss += px;
xx += wx;
if (xx >= dw2)
{
xx -= dw2;
sss++;
}
}
src_p += py;
yy += wy;
if (yy >= dh2)
{
yy -= dh2;
src_p += src->sx;
}
}
}
else
{
yy = yyy;
for (y = 0; y < dh; y++, dest_p += drev)
{
sss = src_p;
xx = xxx;
for (x = 0; x < dw; x++, dest_p++)
{
if (((*(long*)sss) &0xffffff) != nuki)
{
*(WORD*)dest_p = *(WORD*)sss;
*(dest_p + 2) = *(sss + 2);
}
sss += px;
xx += wx;
if (xx >= dw2)
{
xx -= dw2;
sss++;
}
}
src_p += py;
yy += wy;
if (yy >= dh2)
{
yy -= dh2;
src_p += src->sx;
}
}
}
}
return TRUE;
}
//-------------------------------------------------------------------------
BOOL DRW_DrawZOOM_BB(BMP_BT *dest, int dx, int dy, int dw, int dh, BMP_BT *src, int sx, int sy, int sw, int sh, int nuki,
RECT *clip, int r, int g, int b, DWORD wparam)
{
BOOL ret = TRUE;
int blnd = HIWORD(wparam);
int param = LOWORD(wparam);
int xx, yy, dw2 = dw, dh2 = dh, sw2 = sw, sh2 = sh;
if (dest->buf == NULL)
{
DebugPrintf("Ãè»îIÓò¤¬¤¢¤ê¤Þ¤»¤ó\n");
return FALSE;
}
if (src->buf == NULL)
{
DebugPrintf("»ÏñîIÓò¤¬¤¢¤ê¤Þ¤»¤ó\n");
return FALSE;
}
if (clip != (void*) - 1)
{
if (!ClipRectZ(&sx, &sy, &sw, &sh, &dx, &dy, &dw, &dh, &xx, &yy, dest->sx, dest->sy, src->sx, src->sy, clip))
{
return 1;
}
}
if (param == DRW_AMI2 || param == DRW_BLD2)
{
if (blnd == BLD_0P)
{
return 1;
}
if (blnd == BLD_100P)
{
param = DRW_NML;
}
}
switch (param)
{
default:
case DRW_NML:
DRW_DrawZOOM_BB_Std(dest, dx, dy, dw, dh, dw2, dh2, src, sx, sy, sw, sh, sw2, sh2, xx, yy, nuki, r, g, b);
break;
}
return TRUE;
}
| [
"pspbter@13f3a943-b841-0410-bae6-1b2c8ac2799f"
]
| [
[
[
1,
618
]
]
]
|
3c58e7f9727694c3ce33e057634253568ab09e6c | 40b507c2dde13d14bb75ee1b3c16b4f3f82912d1 | /sourcepawn/jit/x86/opcode_helpers.cpp | e2f508b2602cbd4ad4ffcc8d913b11aba3ed56b5 | []
| no_license | Nephyrin/-furry-octo-nemesis | 5da2ef75883ebc4040e359a6679da64ad8848020 | dd441c39bd74eda2b9857540dcac1d98706de1de | refs/heads/master | 2016-09-06T01:12:49.611637 | 2008-09-14T08:42:28 | 2008-09-14T08:42:28 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 27,821 | cpp | /**
* vim: set ts=4 :
* =============================================================================
* SourcePawn JIT
* Copyright (C)2004-2007 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This file is not open source and may not be copied without explicit wriiten
* permission of AlliedModders LLC. This file may not be redistributed in whole
* or significant part.
* For information, see LICENSE.txt or http://www.sourcemod.net/license.php
*
* Version: $Id$
*/
#include <limits.h>
#include <string.h>
#include <malloc.h>
#include "jit_x86.h"
#include "opcode_helpers.h"
#include "x86_macros.h"
#define NUM_INFO_PARAMS 5
jitoffs_t Write_Execute_Function(JitWriter *jit)
{
/**
* The variables we're passed in:
* sp_context_t *ctx, uint32_t code_idx, cell_t *result
*/
/**
* !NOTE!
* Currently, we do not accept ctx->frm as the new frame pointer.
* Instead, we copy the frame from the stack pointer.
* This is because we do not support resuming or sleeping!
*/
//push ebp
//mov ebp, esp
IA32_Push_Reg(jit, REG_EBP);
IA32_Mov_Reg_Rm(jit, REG_EBP, REG_ESP, MOD_REG);
//push esi
//push edi
//push ebx
IA32_Push_Reg(jit, REG_ESI);
IA32_Push_Reg(jit, REG_EDI);
IA32_Push_Reg(jit, REG_EBX);
//sub esp, 4*n - reserve info array
//mov esi, esp - save info pointer
IA32_Sub_Rm_Imm8(jit, REG_ESP, 4*NUM_INFO_PARAMS, MOD_REG);
IA32_Mov_Reg_Rm(jit, AMX_REG_INFO, REG_ESP, MOD_REG);
/* Initial memory setup */
//mov eax, [ebp+16] - get result pointer
//mov [esi+8], eax - store into info pointer
//mov eax, [ebp+8] - get context
//mov [esi+12], eax - store context into info pointer
//mov ecx, [eax+<offs>] - get heap pointer
//mov [esi+4], ecx - store heap into info pointer
//mov ebp, [eax+<offs>] - get data pointer
IA32_Mov_Reg_Rm_Disp8(jit, REG_EAX, REG_EBP, 16);
IA32_Mov_Rm_Reg_Disp8(jit, AMX_REG_INFO, REG_EAX, AMX_INFO_RETVAL);
IA32_Mov_Reg_Rm_Disp8(jit, REG_EAX, REG_EBP, 8);
IA32_Mov_Rm_Reg_Disp8(jit, AMX_REG_INFO, REG_EAX, AMX_INFO_CONTEXT);
IA32_Mov_Reg_Rm_Disp8(jit, REG_ECX, REG_EAX, offsetof(sp_context_t, hp));
IA32_Mov_Rm_Reg_Disp8(jit, AMX_REG_INFO, REG_ECX, AMX_INFO_HEAP);
IA32_Mov_Reg_Rm_Disp8(jit, AMX_REG_DAT, REG_EAX, offsetof(sp_context_t, memory));
/* Frame setup */
//mov edi, [eax+<offs>] - get stack pointer
//add edi, ebp - relocate to data section
//mov ebx, edi - copy sp to frm
IA32_Mov_Reg_Rm_Disp8(jit, AMX_REG_STK, REG_EAX, offsetof(sp_context_t, sp));
IA32_Add_Rm_Reg(jit, AMX_REG_STK, AMX_REG_DAT, MOD_REG);
IA32_Mov_Reg_Rm(jit, AMX_REG_FRM, AMX_REG_STK, MOD_REG);
/* Info memory setup */
//mov ecx, [eax+<offs>] - copy memsize to temp var
//add ecx, ebp - relocate
//mov [esi+x], ecx - store relocated
IA32_Mov_Reg_Rm_Disp8(jit, REG_ECX, REG_EAX, offsetof(sp_context_t, mem_size));
IA32_Add_Reg_Rm(jit, AMX_REG_TMP, AMX_REG_DAT, MOD_REG);
IA32_Mov_Rm_Reg_Disp8(jit, AMX_REG_INFO, REG_ECX, AMX_INFO_STACKTOP);
/* Remaining needed vars */
//mov ecx, [esp+(4*(NUM_INFO_PARAMS+3))+12] - get code index (normally esp+12, but we have another array on the stack)
//add ecx, [eax+<offs>] - add code base to index
IA32_Mov_Reg_Esp_Disp8(jit, REG_ECX, 12+(4*(NUM_INFO_PARAMS+3)));
IA32_Add_Reg_Rm_Disp8(jit, REG_ECX, REG_EAX, offsetof(sp_context_t, codebase));
/* by now, everything is set up, so we can call into the plugin */
//call ecx
IA32_Call_Reg(jit, REG_ECX);
/* if the code flow gets to here, there was a normal return */
//mov ecx, [esi+8] - get retval pointer
//mov [ecx], eax - store retval from PRI
//mov eax, SP_ERROR_NONE - set no error
IA32_Mov_Reg_Rm_Disp8(jit, REG_ECX, AMX_REG_INFO, AMX_INFO_RETVAL);
IA32_Mov_Rm_Reg(jit, REG_ECX, AMX_REG_PRI, MOD_MEM_REG);
IA32_Mov_Reg_Imm32(jit, REG_EAX, SP_ERROR_NONE);
/* save where error checking/halting functions should go to */
jitoffs_t offs_return = jit->get_outputpos();
//mov esp, esi - restore stack pointer
IA32_Mov_Reg_Rm(jit, REG_ESP, REG_ESI, MOD_REG);
/* _FOR NOW_ ...
* We are going to restore SP, HP, and FRM for now. This is for
* debugging only, to check for alignment errors. As such:
* :TODO: probably remove this.
*/
//mov ecx, [esi+context]
//sub edi, ebp
//mov edx, [esi+heap]
//mov [ecx+sp], edi
//mov [ecx+hp], edx
IA32_Mov_Reg_Rm_Disp8(jit, REG_ECX, REG_ESI, AMX_INFO_CONTEXT);
IA32_Sub_Reg_Rm(jit, REG_EDI, REG_EBP, MOD_REG);
IA32_Mov_Reg_Rm_Disp8(jit, REG_EDX, REG_ESI, AMX_INFO_HEAP);
IA32_Mov_Rm_Reg_Disp8(jit, REG_ECX, REG_EDI, offsetof(sp_context_t, sp));
IA32_Mov_Rm_Reg_Disp8(jit, REG_ECX, REG_EDX, offsetof(sp_context_t, hp));
//add esp, 4*NUM_INFO_PARAMS
//pop ebx
//pop edi
//pop esi
//pop ebp
//ret
IA32_Add_Rm_Imm8(jit, REG_ESP, 4*NUM_INFO_PARAMS, MOD_REG);
IA32_Pop_Reg(jit, REG_EBX);
IA32_Pop_Reg(jit, REG_EDI);
IA32_Pop_Reg(jit, REG_ESI);
IA32_Pop_Reg(jit, REG_EBP);
IA32_Return(jit);
return offs_return;
}
void Write_BreakDebug(JitWriter *jit)
{
//push edi
//mov edi, ecx
//mov ecx, [esi+ctx]
//cmp [ecx+dbreak], 0
//jnz :nocall
IA32_Push_Reg(jit, REG_EDI);
IA32_Mov_Reg_Rm(jit, REG_EDI, REG_ECX, MOD_REG);
IA32_Mov_Reg_Rm_Disp8(jit, AMX_REG_TMP, AMX_REG_INFO, AMX_INFO_CONTEXT);
IA32_Cmp_Rm_Disp8_Imm8(jit, AMX_REG_TMP, offsetof(sp_context_t, dbreak), 0);
jitoffs_t jmp = IA32_Jump_Cond_Imm8(jit, CC_Z, 0);
//:TODO: align the stack to 16bytes like in sysreq.x
/* NOTE, Hack! PUSHAD pushes EDI last which still has the CIP */
//pushad
//push [esi+frm]
//push ctx
//mov ecx, [ecx+dbreak]
//call ecx
//add esp, 8
//popad
IA32_Pushad(jit);
IA32_Push_Rm_Disp8(jit, AMX_REG_INFO, AMX_INFO_FRAME); //:TODO: move to regs and push? and dont disp for 0
IA32_Push_Reg(jit, AMX_REG_TMP);
IA32_Mov_Reg_Rm_Disp8(jit, AMX_REG_TMP, AMX_REG_TMP, offsetof(sp_context_t, dbreak));
IA32_Call_Reg(jit, AMX_REG_TMP);
IA32_Add_Rm_Imm8(jit, REG_ESP, 4*2, MOD_REG);
IA32_Popad(jit);
//:nocall
//pop edi
//ret
IA32_Pop_Reg(jit, REG_EDI);
IA32_Send_Jump8_Here(jit, jmp);
IA32_Return(jit);
}
void Write_GetError(JitWriter *jit)
{
CompData *data = (CompData *)jit->data;
//mov eax, [esi+info.context]
//mov eax, [eax+ctx.error]
//jmp [jit_return]
IA32_Mov_Reg_Rm_Disp8(jit, REG_EAX, AMX_REG_INFO, AMX_INFO_CONTEXT);
IA32_Mov_Reg_Rm_Disp8(jit, REG_EAX, REG_EAX, offsetof(sp_context_t, n_err));
IA32_Jump_Imm32_Abs(jit, data->jit_return);
}
void Write_SetError(JitWriter *jit, int error)
{
CompData *data = (CompData *)jit->data;
//mov eax, <error>
//jmp [jit_return]
IA32_Mov_Reg_Imm32(jit, REG_EAX, error);
IA32_Jump_Imm32_Abs(jit, data->jit_return);
}
void Write_Check_DivZero(JitWriter *jit, jit_uint8_t reg)
{
//test reg, reg
//jz :error
IA32_Test_Rm_Reg(jit, reg, reg, MOD_REG);
IA32_Jump_Cond_Imm32_Abs(jit, CC_Z, ((CompData *)jit->data)->jit_error_divzero);
}
void Write_CheckHeap_Min(JitWriter *jit)
{
/* Check if the stack went beyond the heap low.
* This usually means there was a compiler error.
* NOTE: Special optimization here.
* The heap low is always known ahead of time! :)
*/
CompData *data = (CompData *)jit->data;
//cmp [esi+info.heap], <heaplow>
//jb :error
IA32_Cmp_Rm_Imm32_Disp8(jit, AMX_REG_INFO, AMX_INFO_HEAP, data->plugin->data_size);
IA32_Jump_Cond_Imm32_Abs(jit, CC_B, data->jit_error_heapmin);
}
void Write_CheckHeap_Low(JitWriter *jit)
{
/* Check if the heap is trying to grow beyond the stack.
*/
//mov ecx, [esi+info.heap]
//lea ecx, [ebp+ecx+STACK_MARGIN]
//cmp ecx, edi
//ja :error ; I think this is right
IA32_Mov_Reg_Rm_Disp8(jit, AMX_REG_TMP, AMX_REG_INFO, AMX_INFO_HEAP);
IA32_Lea_Reg_DispRegMultImm8(jit, AMX_REG_TMP, AMX_REG_DAT, AMX_REG_TMP, NOSCALE, STACK_MARGIN);
IA32_Cmp_Reg_Rm(jit, AMX_REG_TMP, AMX_REG_STK, MOD_REG);
IA32_Jump_Cond_Imm32_Abs(jit, CC_A, ((CompData *)jit->data)->jit_error_heaplow);
}
void Write_CheckStack_Min(JitWriter *jit)
{
/* Check if the stack went beyond the stack top
* This usually means there was a compiler error.
*/
//cmp edi, [esi+info.stacktop]
//jae :error
IA32_Cmp_Reg_Rm_Disp8(jit, AMX_REG_STK, AMX_REG_INFO, AMX_INFO_STACKTOP);
IA32_Jump_Cond_Imm32_Abs(jit, CC_AE, ((CompData *)jit->data)->jit_error_stackmin);
}
void Write_CheckStack_Low(JitWriter *jit)
{
/* Check if the stack went beyond the heap boundary.
* Unfortunately this one isn't as quick as the other check.
* The stack margin check is important for sysreq.n having space.
*/
//mov ecx, [esi+info.heap]
//lea ecx, [ebp+ecx+STACK_MARGIN]
//cmp edi, ecx
//jb :error ; I think this is right
IA32_Mov_Reg_Rm_Disp8(jit, AMX_REG_TMP, AMX_REG_INFO, AMX_INFO_HEAP);
IA32_Lea_Reg_DispRegMultImm8(jit, AMX_REG_TMP, AMX_REG_DAT, AMX_REG_TMP, NOSCALE, STACK_MARGIN);
IA32_Cmp_Reg_Rm(jit, AMX_REG_STK, AMX_REG_TMP, MOD_REG);
IA32_Jump_Cond_Imm32_Abs(jit, CC_B, ((CompData *)jit->data)->jit_error_stacklow);
}
void Write_Check_VerifyAddr(JitWriter *jit, jit_uint8_t reg)
{
CompData *data = (CompData *)jit->data;
/* :TODO: Should this be checking for below heaplow?
* The old JIT did not.
*/
bool call = false;
if (!(data->inline_level & JIT_INLINE_ERRORCHECKS))
{
/* If we're not in the initial generation phase,
* Write a call to the actual routine instead.
*/
if ((reg == REG_EAX) && data->jit_verify_addr_eax)
{
jitoffs_t call = IA32_Call_Imm32(jit, 0);
IA32_Write_Jump32(jit, call, data->jit_verify_addr_eax);
return;
} else if ((reg == REG_EDX) && data->jit_verify_addr_edx) {
jitoffs_t call = IA32_Call_Imm32(jit, 0);
IA32_Write_Jump32(jit, call, data->jit_verify_addr_edx);
return;
}
call = true;
}
/**
* :TODO: If we can't find a nicer way of doing this,
* then scrap it on high optimizations. The second portion is not needed at all!
*/
/* Part 1: Check if we're in the memory bounds */
//cmp <reg>, <stpu>
//jae :error
IA32_Cmp_Rm_Imm32(jit, MOD_REG, reg, ((CompData *)jit->data)->plugin->memory);
IA32_Jump_Cond_Imm32_Abs(jit, CC_AE, ((CompData *)jit->data)->jit_error_memaccess);
/* Part 2: Check if we're in the invalid region between HP and SP */
jitoffs_t jmp;
//cmp <reg>, [esi+info.heap]
//jb :continue
//lea ecx, [ebp+<reg>]
//cmp edi, ecx
//jb :error
//:continue
IA32_Cmp_Reg_Rm_Disp8(jit, reg, AMX_REG_INFO, AMX_INFO_HEAP);
jmp = IA32_Jump_Cond_Imm8(jit, CC_B, 0);
IA32_Lea_Reg_DispRegMultImm8(jit, AMX_REG_TMP, AMX_REG_DAT, reg, NOSCALE, 0);
IA32_Cmp_Reg_Rm(jit, AMX_REG_TMP, AMX_REG_STK, MOD_REG);
IA32_Jump_Cond_Imm32_Abs(jit, CC_B, ((CompData *)jit->data)->jit_error_memaccess);
IA32_Send_Jump8_Here(jit, jmp);
if (call)
{
IA32_Return(jit);
}
}
void Macro_PushN_Addr(JitWriter *jit, int i)
{
//push eax
//mov eax, [esi+frm]
//loop i times:
// lea ecx, [eax+<val>]
// mov [edi-4*i], ecx
//sub edi, 4*N
//pop eax
cell_t val;
int n = 1;
IA32_Push_Reg(jit, AMX_REG_PRI);
IA32_Mov_Reg_Rm(jit, AMX_REG_PRI, AMX_REG_INFO, MOD_MEM_REG);
do
{
val = jit->read_cell();
if (val <= SCHAR_MAX && val >= SCHAR_MIN)
IA32_Lea_DispRegImm8(jit, AMX_REG_TMP, AMX_REG_PRI, (jit_int8_t)val);
else
IA32_Lea_DispRegImm32(jit, AMX_REG_TMP, AMX_REG_PRI, val);
IA32_Mov_Rm_Reg_Disp8(jit, AMX_REG_STK, AMX_REG_TMP, -4*n);
} while (n++ < i);
IA32_Sub_Rm_Imm8(jit, AMX_REG_STK, 4*i, MOD_REG);
IA32_Pop_Reg(jit, AMX_REG_PRI);
}
void Macro_PushN_S(JitWriter *jit, int i)
{
//loop i times:
// mov ecx, [ebx+<val>]
// mov [edi-4*i], ecx
//sub edi, 4*N
cell_t val;
int n = 1;
do
{
val = jit->read_cell();
if (val <= SCHAR_MAX && val >= SCHAR_MIN)
IA32_Mov_Reg_Rm_Disp8(jit, AMX_REG_TMP, AMX_REG_FRM, (jit_int8_t)val);
else
IA32_Mov_Reg_Rm_Disp32(jit, AMX_REG_TMP, AMX_REG_FRM, val);
IA32_Mov_Rm_Reg_Disp8(jit, AMX_REG_STK, AMX_REG_TMP, -4*n);
} while (n++ < i);
IA32_Sub_Rm_Imm8(jit, AMX_REG_STK, 4*i, MOD_REG);
}
void Macro_PushN_C(JitWriter *jit, int i)
{
//loop i times:
// mov [edi-4*i], <val>
//sub edi, 4*N
int n = 1;
do
{
IA32_Mov_Rm_Imm32_Disp8(jit, AMX_REG_STK, jit->read_cell(), -4*n);
} while (n++ < i);
IA32_Sub_Rm_Imm8(jit, AMX_REG_STK, 4*i, MOD_REG);
}
void Macro_PushN(JitWriter *jit, int i)
{
//loop i times:
// mov ecx, [ebp+<val>]
// mov [edi-4*i], ecx
//sub edi, 4*N
cell_t val;
int n = 1;
do
{
val = jit->read_cell();
if (val <= SCHAR_MAX && val >= SCHAR_MIN)
IA32_Mov_Reg_Rm_Disp8(jit, AMX_REG_TMP, AMX_REG_DAT, (jit_int8_t)val);
else
IA32_Mov_Reg_Rm_Disp32(jit, AMX_REG_TMP, AMX_REG_DAT, val);
IA32_Mov_Rm_Reg_Disp8(jit, AMX_REG_STK, AMX_REG_TMP, -4*n);
} while (n++ < i);
IA32_Sub_Rm_Imm8(jit, AMX_REG_STK, 4*i, MOD_REG);
}
void WriteOp_Sysreq_C_Function(JitWriter *jit)
{
/* The small daddy of the big daddy of opcodes.
* ecx - native index
*/
CompData *data = (CompData *)jit->data;
/* save registers we will need */
//push edx
IA32_Push_Reg(jit, AMX_REG_ALT);
/* Align the stack to 16 bytes */
//push ebx
//mov ebx, esp
//and esp, 0xFFFFFF0
//sub esp, 4
IA32_Push_Reg(jit, REG_EBX);
IA32_Mov_Reg_Rm(jit, REG_EBX, REG_ESP, MOD_REG);
IA32_And_Rm_Imm8(jit, REG_ESP, MOD_REG, -16);
IA32_Sub_Rm_Imm8(jit, REG_ESP, 4, MOD_REG);
/* push some callback stuff */
//push edi ; stack
//push ecx ; native index
IA32_Push_Reg(jit, AMX_REG_STK);
IA32_Push_Reg(jit, REG_ECX);
/* Relocate stack, heap, frm information, then store back */
//mov eax, [esi+context]
//mov ecx, [esi+hea]
//sub edi, ebp
//mov [eax+hp], ecx
//mov ecx, [esi]
//mov [eax+sp], edi
//mov [eax+frm], ecx
IA32_Mov_Reg_Rm_Disp8(jit, REG_EAX, AMX_REG_INFO, AMX_INFO_CONTEXT);
IA32_Mov_Reg_Rm_Disp8(jit, AMX_REG_TMP, AMX_REG_INFO, AMX_INFO_HEAP);
IA32_Sub_Reg_Rm(jit, AMX_REG_STK, AMX_REG_DAT, MOD_REG);
IA32_Mov_Rm_Reg_Disp8(jit, REG_EAX, AMX_REG_TMP, offsetof(sp_context_t, hp));
IA32_Mov_Reg_Rm(jit, AMX_REG_TMP, AMX_INFO_FRM, MOD_MEM_REG);
IA32_Mov_Rm_Reg_Disp8(jit, REG_EAX, AMX_REG_STK, offsetof(sp_context_t, sp));
IA32_Mov_Rm_Reg_Disp8(jit, REG_EAX, AMX_REG_TMP, offsetof(sp_context_t, frm));
/* finally, push the last parameter and make the call */
//push eax ; context
//call NativeCallback
IA32_Push_Reg(jit, REG_EAX);
jitoffs_t call = IA32_Call_Imm32(jit, 0);
if (!data->debug)
{
IA32_Write_Jump32_Abs(jit, call, (void *)NativeCallback);
} else {
IA32_Write_Jump32_Abs(jit, call, (void *)NativeCallback_Debug);
}
/* Test for error */
//mov ecx, [esi+context]
//cmp [ecx+err], 0
//jnz :error
IA32_Mov_Reg_Rm_Disp8(jit, AMX_REG_TMP, AMX_REG_INFO, AMX_INFO_CONTEXT);
IA32_Cmp_Rm_Disp8_Imm8(jit, AMX_REG_TMP, offsetof(sp_context_t, n_err), 0);
IA32_Jump_Cond_Imm32_Abs(jit, CC_NZ, data->jit_extern_error);
/* restore what we damaged */
//mov esp, ebx
//pop ebx
//add edi, ebp
//pop edx
IA32_Mov_Reg_Rm(jit, REG_ESP, REG_EBX, MOD_REG);
IA32_Pop_Reg(jit, REG_EBX);
IA32_Add_Reg_Rm(jit, AMX_REG_STK, AMX_REG_DAT, MOD_REG);
IA32_Pop_Reg(jit, AMX_REG_ALT);
//ret
IA32_Return(jit);
}
typedef struct array_creation_s
{
const cell_t *dim_list; /* Dimension sizes */
cell_t dim_count; /* Number of dimensions */
cell_t *data_offs; /* Current offset AFTER the indirection vectors (data) */
cell_t *base; /* array base */
} array_creation_t;
cell_t _GenerateArrayIndirectionVectors(array_creation_t *ar, int dim, cell_t cur_offs)
{
cell_t write_offs = cur_offs;
cell_t *data_offs = ar->data_offs;
cur_offs += ar->dim_list[dim];
/**
* Dimension n-x where x > 2 will have sub-vectors.
* Otherwise, we just need to reference the data section.
*/
if (ar->dim_count > 2 && dim < ar->dim_count - 2)
{
/**
* For each index at this dimension, write offstes to our sub-vectors.
* After we write one sub-vector, we generate its sub-vectors recursively.
* At the end, we're given the next offset we can use.
*/
for (int i = 0; i < ar->dim_list[dim]; i++)
{
ar->base[write_offs] = (cur_offs - write_offs) * sizeof(cell_t);
write_offs++;
cur_offs = _GenerateArrayIndirectionVectors(ar, dim + 1, cur_offs);
}
} else {
/**
* In this section, there are no sub-vectors, we need to write offsets
* to the data. This is separate so the data stays in one big chunk.
* The data offset will increment by the size of the last dimension,
* because that is where the data is finally computed as.
*/
for (int i = 0; i < ar->dim_list[dim]; i++)
{
ar->base[write_offs] = (*data_offs - write_offs) * sizeof(cell_t);
write_offs++;
*data_offs = *data_offs + ar->dim_list[dim + 1];
}
}
return cur_offs;
}
static cell_t calc_indirection(const array_creation_t *ar, cell_t dim)
{
cell_t size = ar->dim_list[dim];
if (dim < ar->dim_count - 2)
{
size += ar->dim_list[dim] * calc_indirection(ar, dim + 1);
}
return size;
}
void GenerateArrayIndirectionVectors(cell_t *arraybase, cell_t dims[], cell_t _dimcount, bool autozero)
{
array_creation_t ar;
cell_t data_offs;
/* Reverse the dimensions */
cell_t dim_list[sDIMEN_MAX];
int cur_dim = 0;
for (int i = _dimcount - 1; i >= 0; i--)
{
dim_list[cur_dim++] = dims[i];
}
ar.base = arraybase;
ar.dim_list = dim_list;
ar.dim_count = _dimcount;
ar.data_offs = &data_offs;
data_offs = calc_indirection(&ar, 0);
_GenerateArrayIndirectionVectors(&ar, 0, 0);
}
/**
* A few notes about this function.
* I was more concerned about efficient use of registers here, rather than
* fine-tuned optimization. The reason is that the code is already complicated,
* and it is very easy to mess up.
*/
void WriteIntrinsic_GenArray(JitWriter *jit)
{
/**
* save important values
*/
//push ebx
//push eax
//push edx
//push ecx ;value is referenced on stack
IA32_Push_Reg(jit, REG_EBX);
IA32_Push_Reg(jit, REG_EAX);
IA32_Push_Reg(jit, REG_EDX);
IA32_Push_Reg(jit, REG_ECX);
/**
* Calculate how many cells will be needed.
*/
//mov edx, [edi] ;get last dimension's count
//mov eax, 1 ;position at second to last dimension
//:loop
//cmp eax, [esp] ;compare to # of params
//jae :done ;end loop if done
//mov ecx, [edi+eax*4] ;get dimension size
//imul edx, ecx ;multiply by size
//add eax, 1 ;increment
//add edx, ecx ;add size (indirection vector)
//jmp :loop ;jump back
//:done
IA32_Mov_Reg_Rm(jit, REG_EDX, AMX_REG_STK, MOD_MEM_REG);
IA32_Mov_Reg_Imm32(jit, REG_EAX, 1);
jitoffs_t loop1 = jit->get_outputpos();
IA32_Cmp_Reg_Rm_ESP(jit, REG_EAX);
jitoffs_t done1 = IA32_Jump_Cond_Imm8(jit, CC_AE, 0);
IA32_Mov_Reg_Rm_Disp_Reg(jit, REG_ECX, AMX_REG_STK, REG_EAX, SCALE4);
IA32_IMul_Reg_Rm(jit, REG_EDX, REG_ECX, MOD_REG);
IA32_Add_Rm_Imm8(jit, REG_EAX, 1, MOD_REG);
IA32_Add_Reg_Rm(jit, REG_EDX, REG_ECX, MOD_REG);
IA32_Write_Jump8(jit, IA32_Jump_Imm8(jit, loop1), loop1);
IA32_Send_Jump8_Here(jit, done1);
/* Test if we have heap space for this */
//mov eax, [esi+info.heap] ;get heap pointer
//lea eax, [eax+edx*4] ;new heap pointer
//cmp eax, <hlw> ;compare to heap low
//jbe :error ;die if we hit this (it should always be >)
//add eax, ebp ;relocate to stack
//cmp eax, edi ;die if above the stack pointer
//jae :error
IA32_Mov_Reg_Rm_Disp8(jit, REG_EAX, AMX_REG_INFO, AMX_INFO_HEAP);
IA32_Lea_Reg_DispRegMult(jit, REG_EAX, REG_EAX, REG_EDX, SCALE4);
IA32_Cmp_Rm_Imm32(jit, MOD_REG, REG_EAX, ((CompData *)jit->data)->plugin->data_size);
IA32_Jump_Cond_Imm32_Abs(jit, CC_BE, ((CompData *)jit->data)->jit_error_array_too_big);
IA32_Add_Reg_Rm(jit, REG_EAX, AMX_REG_DAT, MOD_REG);
IA32_Cmp_Reg_Rm(jit, REG_EAX, AMX_REG_STK, MOD_REG);
IA32_Jump_Cond_Imm32_Abs(jit, CC_AE, ((CompData *)jit->data)->jit_error_array_too_big);
/* Prepare for indirection iteration */
//mov eax, [esi+info.heap] ;get heap pointer
//lea ebx, [eax+edx*4] ;new heap pointer
//mov [esi+info.heap], ebx ;store back
//push eax ;save heap pointer - we need it
IA32_Mov_Reg_Rm_Disp8(jit, REG_EAX, AMX_REG_INFO, AMX_INFO_HEAP);
IA32_Lea_Reg_DispRegMult(jit, REG_EBX, REG_EAX, REG_EDX, SCALE4);
IA32_Mov_Rm_Reg_Disp8(jit, AMX_REG_INFO, REG_EBX, AMX_INFO_HEAP);
IA32_Push_Reg(jit, REG_EAX);
WriteOp_Tracker_Push_Reg(jit, REG_EDX);
/* This part is too messy to do in straight assembly.
* I'm letting the compiler handle it and thus it's in C.
*/
//lea ebx, [ebp+eax] ;get base pointer
//push dword [esp-8] ;push autozero
//push dword [esp-8] ;push dimension count
//push edi ;push dim array
//push ebx
//call GenerateArrayIndirectionVectors
//add esp, 4*4
IA32_Lea_Reg_DispRegMult(jit, REG_EBX, REG_EAX, REG_EBP, NOSCALE);
IA32_Push_Rm_Disp8_ESP(jit, 8);
IA32_Push_Rm_Disp8_ESP(jit, 8);
IA32_Push_Reg(jit, REG_EDI);
IA32_Push_Reg(jit, REG_EBX);
IA32_Write_Jump32_Abs(jit, IA32_Call_Imm32(jit, 0), (void *)&GenerateArrayIndirectionVectors);
IA32_Add_Rm_Imm8(jit, REG_ESP, 4*4, MOD_REG);
/* Store the heap pointer back into the stack */
//pop eax ;restore heap pointer
//pop ecx ;restore param count
//lea edi, [edi+ecx*4-4] ;pop params-4 off the stack
//mov [edi], eax ;store back the heap pointer
IA32_Pop_Reg(jit, REG_EAX);
IA32_Pop_Reg(jit, REG_ECX);
IA32_Lea_Reg_DispRegMultImm8(jit, AMX_REG_STK, AMX_REG_STK, REG_ECX, SCALE4, -4);
IA32_Mov_Rm_Reg(jit, AMX_REG_STK, REG_EAX, MOD_MEM_REG);
/* Return to caller */
//pop edx
//pop eax
//pop ebx
//ret
IA32_Pop_Reg(jit, REG_ECX);
IA32_Pop_Reg(jit, REG_EAX);
IA32_Pop_Reg(jit, REG_EBX);
IA32_Return(jit);
}
void WriteOp_Sysreq_N_Function(JitWriter *jit)
{
/* The big daddy of opcodes.
* eax - num_params
* ecx - native index
*/
CompData *data = (CompData *)jit->data;
/* store the number of parameters on the stack */
//mov [edi-4], eax
//sub edi, 4
IA32_Mov_Rm_Reg_Disp8(jit, AMX_REG_STK, REG_EAX, -4);
IA32_Sub_Rm_Imm8(jit, AMX_REG_STK, 4, MOD_REG);
/* save registers we will need */
//push eax ; num_params for stack popping
//push edx
IA32_Push_Reg(jit, REG_EAX);
IA32_Push_Reg(jit, AMX_REG_ALT);
/* Align the stack to 16 bytes */
//push ebx
//mov ebx, esp
//and esp, 0xFFFFFF0
//sub esp, 4
IA32_Push_Reg(jit, REG_EBX);
IA32_Mov_Reg_Rm(jit, REG_EBX, REG_ESP, MOD_REG);
IA32_And_Rm_Imm8(jit, REG_ESP, MOD_REG, -16);
IA32_Sub_Rm_Imm8(jit, REG_ESP, 4, MOD_REG);
/* push some callback stuff */
//push edi ; stack
//push ecx ; native index
IA32_Push_Reg(jit, AMX_REG_STK);
IA32_Push_Reg(jit, REG_ECX);
/* Relocate stack, heap, frm information, then store back */
//mov eax, [esi+context]
//mov ecx, [esi+hea]
//sub edi, ebp
//mov [eax+hp], ecx
//mov ecx, [esi]
//mov [eax+sp], edi
//mov [eax+frm], ecx
IA32_Mov_Reg_Rm_Disp8(jit, REG_EAX, AMX_REG_INFO, AMX_INFO_CONTEXT);
IA32_Mov_Reg_Rm_Disp8(jit, AMX_REG_TMP, AMX_REG_INFO, AMX_INFO_HEAP);
IA32_Sub_Reg_Rm(jit, AMX_REG_STK, AMX_REG_DAT, MOD_REG);
IA32_Mov_Rm_Reg_Disp8(jit, REG_EAX, AMX_REG_TMP, offsetof(sp_context_t, hp));
IA32_Mov_Reg_Rm(jit, AMX_REG_TMP, AMX_INFO_FRM, MOD_MEM_REG);
IA32_Mov_Rm_Reg_Disp8(jit, REG_EAX, AMX_REG_STK, offsetof(sp_context_t, sp));
IA32_Mov_Rm_Reg_Disp8(jit, REG_EAX, AMX_REG_TMP, offsetof(sp_context_t, frm));
/* finally, push the last parameter and make the call */
//push eax ; context
//call NativeCallback
IA32_Push_Reg(jit, REG_EAX);
jitoffs_t call = IA32_Call_Imm32(jit, 0);
if (!data->debug)
{
IA32_Write_Jump32_Abs(jit, call, (void *)NativeCallback);
} else {
IA32_Write_Jump32_Abs(jit, call, (void *)NativeCallback_Debug);
}
/* Test for error */
//mov ecx, [esi+context]
//cmp [ecx+err], 0
//jnz :error
IA32_Mov_Reg_Rm_Disp8(jit, AMX_REG_TMP, AMX_REG_INFO, AMX_INFO_CONTEXT);
IA32_Cmp_Rm_Disp8_Imm8(jit, AMX_REG_TMP, offsetof(sp_context_t, n_err), 0);
IA32_Jump_Cond_Imm32_Abs(jit, CC_NZ, data->jit_extern_error);
/* restore what we damaged */
//mov esp, ebx
//pop ebx
//add edi, ebp
//pop edx
//pop ecx ; num_params
IA32_Mov_Reg_Rm(jit, REG_ESP, REG_EBX, MOD_REG);
IA32_Pop_Reg(jit, REG_EBX);
IA32_Add_Reg_Rm(jit, AMX_REG_STK, AMX_REG_DAT, MOD_REG);
IA32_Pop_Reg(jit, AMX_REG_ALT);
IA32_Pop_Reg(jit, REG_ECX);
/* pop the AMX stack. do not check the margins.
* Note that this is not a true macro - we don't bother to
* set ALT here because nothing will be using it.
*/
//lea edi, [edi+ecx*4+4]
IA32_Lea_Reg_DispRegMultImm8(jit, AMX_REG_STK, AMX_REG_STK, REG_ECX, SCALE4, 4);
//ret
IA32_Return(jit);
}
void WriteOp_Tracker_Push_Reg(JitWriter *jit, uint8_t reg)
{
CompData *data = (CompData *)jit->data;
/* Save registers that may be damaged by the call */
//push eax
//push ecx
//push edi
//lea edi, [<reg>*4] ; we want the count in bytes not in cells
IA32_Push_Reg(jit, AMX_REG_PRI);
if (reg == REG_ECX)
{
IA32_Push_Reg(jit, AMX_REG_TMP);
}
IA32_Push_Reg(jit, AMX_REG_STK);
IA32_Lea_Reg_RegMultImm32(jit, REG_EDI, reg, SCALE4, 0);
/* Get the context ptr, push it and call the check */
//mov eax, [esi+context]
//push eax
//call JIT_VerifyOrAllocateTracker
IA32_Mov_Reg_Rm_Disp8(jit, REG_EAX, AMX_REG_INFO, AMX_INFO_CONTEXT);
IA32_Push_Reg(jit, REG_EAX);
jitoffs_t call = IA32_Call_Imm32(jit, 0);
IA32_Write_Jump32_Abs(jit, call, (void *)JIT_VerifyOrAllocateTracker);
/* Check for errors */
//cmp eax, 0
//jnz :error
IA32_Cmp_Rm_Imm8(jit, MOD_REG, REG_EAX, 0);
IA32_Jump_Cond_Imm32_Abs(jit, CC_NZ, data->jit_return);
/* Restore */
//pop eax
IA32_Pop_Reg(jit, REG_EAX);
/* Push the register into the stack and increment pCur */
//mov edx, [eax+vm[]]
//mov eax, [edx+pcur]
//add [edx+pcur], 4
//mov [eax], edi
IA32_Mov_Reg_Rm_Disp8(jit, REG_EDX, REG_EAX, offsetof(sp_context_t, vm[JITVARS_TRACKER]));
IA32_Mov_Reg_Rm_Disp8(jit, REG_EAX, REG_EDX, offsetof(tracker_t, pCur));
IA32_Add_Rm_Imm8_Disp8(jit, REG_EDX, 4, offsetof(tracker_t, pCur));
IA32_Mov_Rm_Reg(jit, REG_EAX, REG_EDI, MOD_MEM_REG);
/* Restore PRI, ALT and STK */
//pop edi
//pop ecx
//pop eax
IA32_Pop_Reg(jit, AMX_REG_STK);
if (reg == REG_ECX)
{
IA32_Pop_Reg(jit, AMX_REG_TMP);
}
IA32_Pop_Reg(jit, AMX_REG_PRI);
}
int JIT_VerifyOrAllocateTracker(sp_context_t *ctx)
{
tracker_t *trk = (tracker_t *)(ctx->vm[JITVARS_TRACKER]);
if ((size_t)(trk->pCur - trk->pBase) >= trk->size)
{
return SP_ERROR_TRACKER_BOUNDS;
}
if (trk->pCur+1 - (trk->pBase + trk->size) == 0)
{
size_t disp = trk->size - 1;
trk->size *= 2;
trk->pBase = (ucell_t *)realloc(trk->pBase, trk->size * sizeof(cell_t));
if (!trk->pBase)
{
return SP_ERROR_TRACKER_BOUNDS;
}
trk->pCur = trk->pBase + disp;
}
return SP_ERROR_NONE;
}
int JIT_VerifyLowBoundTracker(sp_context_t *ctx)
{
tracker_t *trk = (tracker_t *)(ctx->vm[JITVARS_TRACKER]);
if (trk->pCur <= trk->pBase)
{
return SP_ERROR_TRACKER_BOUNDS;
}
return SP_ERROR_NONE;
}
void Write_RoundingTable(JitWriter *jit)
{
jit->write_int32(-1);
jit->write_int32(0);
jit->write_int32(1);
}
void AlignMe(JitWriter *jit)
{
jitoffs_t cur_offs = jit->get_outputpos();
jitoffs_t offset = ((cur_offs & 0xFFFFFFF0) + 16) - cur_offs;
if (offset)
{
for (jit_uint32_t i=0; i<offset; i++)
{
jit->write_ubyte(IA32_INT3);
}
}
}
| [
"[email protected]",
"[email protected]",
"[email protected]"
]
| [
[
[
1,
1
],
[
7,
7
],
[
11,
17
],
[
19,
22
],
[
24,
124
],
[
126,
152
],
[
154,
155
],
[
157,
159
],
[
161,
165
],
[
167,
202
],
[
206,
206
],
[
208,
223
],
[
225,
236
],
[
238,
298
],
[
300,
300
],
[
302,
327
],
[
329,
330
],
[
333,
337
],
[
339,
355
],
[
358,
375
],
[
378,
389
],
[
393,
418
],
[
429,
436
],
[
439,
439
],
[
441,
443
],
[
446,
446
],
[
448,
471
],
[
474,
475
],
[
479,
599
],
[
602,
610
],
[
613,
627
],
[
629,
641
],
[
643,
652
],
[
654,
702
],
[
713,
720
],
[
723,
723
],
[
725,
727
],
[
730,
730
],
[
732,
755
],
[
758,
760
],
[
764,
777
],
[
802,
802
],
[
805,
805
],
[
810,
813
],
[
836,
836
],
[
842,
842
],
[
853,
853
],
[
858,
859
],
[
862,
862
],
[
868,
868
],
[
870,
872
]
],
[
[
2,
6
],
[
8,
10
]
],
[
[
18,
18
],
[
23,
23
],
[
125,
125
],
[
153,
153
],
[
156,
156
],
[
160,
160
],
[
166,
166
],
[
203,
205
],
[
207,
207
],
[
224,
224
],
[
237,
237
],
[
299,
299
],
[
301,
301
],
[
328,
328
],
[
331,
332
],
[
338,
338
],
[
356,
357
],
[
376,
377
],
[
390,
392
],
[
419,
428
],
[
437,
438
],
[
440,
440
],
[
444,
445
],
[
447,
447
],
[
472,
473
],
[
476,
478
],
[
600,
601
],
[
611,
612
],
[
628,
628
],
[
642,
642
],
[
653,
653
],
[
703,
712
],
[
721,
722
],
[
724,
724
],
[
728,
729
],
[
731,
731
],
[
756,
757
],
[
761,
763
],
[
778,
801
],
[
803,
804
],
[
806,
809
],
[
814,
835
],
[
837,
841
],
[
843,
852
],
[
854,
857
],
[
860,
861
],
[
863,
867
],
[
869,
869
],
[
873,
893
]
]
]
|
2b287c476602a8284583c3a3b818ded073d148c0 | 39040af0ff84935d083209731dd7343f93fa2874 | /misc/winevent.cpp | 174bf44b7205720883988aee8422c3cb43f63064 | [
"Apache-2.0"
]
| permissive | alanzw/ulib-win | 02f8b7bcd8220b6a057fd3b33e733500294f9b56 | b67f644ed11c849e3c93b909f90d443df7be4e4c | refs/heads/master | 2020-04-06T05:26:54.849486 | 2011-07-23T05:47:17 | 2011-07-23T05:47:17 | 34,505,292 | 5 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 3,156 | cpp |
// public domain
// by Christopher Diggins 2004
// http://www.cdiggins.com
//
// This program demonstrates a technique of static dispatch for event-driven programming
// using template specialization.
#include <windows.h>
#include "winevent.hpp"
#include <time.h>
#include <stdio.h>
int nInt = 0;
int nStart = 0;
int nEnd = 0;
char buf[255];
//////////////////////////////////////////////////////////////////////////////////////
// Event handlers
template<>
LRESULT OnMsg<WM_CREATE>(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
strcpy(buf, "Press any key to start test");
return DefWindowProc(hWnd, WM_CREATE, wParam, lParam);
}
template<>
LRESULT OnMsg<WM_KEYDOWN>(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
nInt = 0;
strcpy(buf, "running test, please wait ...");
InvalidateRect(hWnd, NULL, true);
SendMessage(hWnd, WM_PAINT, 0, 0);
nStart = GetTickCount();
PostMessage(hWnd, WM_TIMER, 0, 0);
return DefWindowProc(hWnd, WM_KEYDOWN, wParam, lParam);
}
template<>
LRESULT OnMsg<WM_TIMER>(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
if (nInt++ < 100000) {
PostMessage(hWnd, WM_TIMER, 0, 0);
} else {
nEnd = GetTickCount();
sprintf(buf, "Time elapsed = %d msec", ((nEnd - nStart) * 1000) / CLOCKS_PER_SEC);
InvalidateRect(hWnd, NULL, true);
}
return 0;
}
template<>
LRESULT OnMsg<WM_DESTROY>(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
PostQuitMessage(0);
return 0;
}
template<>
LRESULT OnMsg<WM_PAINT>(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc;
hdc = BeginPaint(hWnd, &ps);
TextOut(hdc, 100, 100, buf, static_cast<int>(strlen(buf)));
EndPaint(hWnd, &ps);
return DefWindowProc(hWnd, WM_PAINT, wParam, lParam);
}
//////////////////////////////////////////////////////////////////////////////////////
// Entry point for the application.
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int nCmdShow)
{
InitMsgHandlers<NULL>();
static char szAppName[] = "demo";
HWND hwnd;
MSG msg;
WNDCLASSEX wndclass;
wndclass.cbSize = sizeof(wndclass);
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
wndclass.lpszClassName = szAppName;
wndclass.lpszMenuName = NULL;
RegisterClassEx(&wndclass);
hwnd = CreateWindow(szAppName, "Static Dispatch Demo",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hInstance, NULL);
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
while ( GetMessage(&msg, NULL, 0, 0) ) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return static_cast<int>(msg.wParam);
}
| [
"fox000002@48c0247c-a797-11de-8c46-7bd654735883"
]
| [
[
[
1,
118
]
]
]
|
532100393ede44506c397534e7e826a68481ccff | 7b379862f58f587d9327db829ae4c6493b745bb1 | /JuceLibraryCode/modules/juce_core/misc/juce_Result.cpp | f92da69da2534882c8ab971ec658b87de46bd6ba | []
| no_license | owenvallis/Nomestate | 75e844e8ab68933d481640c12019f0d734c62065 | 7fe7c06c2893421a3c77b5180e5f27ab61dd0ffd | refs/heads/master | 2021-01-19T07:35:14.301832 | 2011-12-28T07:42:50 | 2011-12-28T07:42:50 | 2,950,072 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,754 | cpp | /*
==============================================================================
This file is part of the JUCE library - "Jules' Utility Class Extensions"
Copyright 2004-11 by Raw Material Software Ltd.
------------------------------------------------------------------------------
JUCE can be redistributed and/or modified under the terms of the GNU General
Public License (Version 2), as published by the Free Software Foundation.
A copy of the license is included in the JUCE distribution, or can be found
online at www.gnu.org/licenses.
JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
To release a closed-source product which uses JUCE, commercial licenses are
available: visit www.rawmaterialsoftware.com/juce for more information.
==============================================================================
*/
BEGIN_JUCE_NAMESPACE
//==============================================================================
Result::Result (const String& message) noexcept
: errorMessage (message)
{
}
Result::Result (const Result& other)
: errorMessage (other.errorMessage)
{
}
Result& Result::operator= (const Result& other)
{
errorMessage = other.errorMessage;
return *this;
}
#if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
Result::Result (Result&& other) noexcept
: errorMessage (static_cast <String&&> (other.errorMessage))
{
}
Result& Result::operator= (Result&& other) noexcept
{
errorMessage = static_cast <String&&> (other.errorMessage);
return *this;
}
#endif
bool Result::operator== (const Result& other) const noexcept
{
return errorMessage == other.errorMessage;
}
bool Result::operator!= (const Result& other) const noexcept
{
return errorMessage != other.errorMessage;
}
Result Result::ok() noexcept
{
return Result (String::empty);
}
Result Result::fail (const String& errorMessage) noexcept
{
return Result (errorMessage.isEmpty() ? "Unknown Error" : errorMessage);
}
const String& Result::getErrorMessage() const noexcept
{
return errorMessage;
}
bool Result::wasOk() const noexcept { return errorMessage.isEmpty(); }
Result::operator bool() const noexcept { return errorMessage.isEmpty(); }
bool Result::failed() const noexcept { return errorMessage.isNotEmpty(); }
bool Result::operator!() const noexcept { return errorMessage.isNotEmpty(); }
END_JUCE_NAMESPACE
| [
"ow3nskip"
]
| [
[
[
1,
89
]
]
]
|
6f1db6cb08544f257fa26cfd5727c10474114ebb | de2f72b217bc8a9b1f780090bedf425a2ad9587a | /Pangea/Generic/include/Vector3.h | 90651016b70d45cb6262597fab968e1469480d90 | []
| no_license | axelwass/oliveira | 65b32a7f16cb7e00a95cdf3051a731a2004aaf5f | 4c34730a720465311e367f8e25cc1cced46801c7 | refs/heads/master | 2021-01-18T14:18:42.622080 | 2011-04-18T18:39:08 | 2011-04-18T18:39:08 | 32,120,045 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,298 | h | /*
* Vector3.h
*
* Created on: Jan 21, 2010
* Author: Mariano
*/
#ifndef VECTOR3_H_
#define VECTOR3_H_
#include "precision.h"
#include <math.h>
class Vector3 {
private:
/** Holds a 3D vector */
real x, y, z;
public:
real getX() const {
return x;
}
real getY() const {
return y;
}
real getZ() const {
return z;
}
Vector3() :
x(0), y(0), z(0) {
}
Vector3(const real x, const real y, const real z) :
x(x), y(y), z(z) {
}
/** Inverts this vector's components */
void invert();
/** Gets the magnitude of this vector */
real magnitude() const;
/** Gets the squared magnitude of this vector */
real squareMagnitude() const;
/** Turns a non-zero vector into a vector of unit length */
void normalize();
/** Clears the components of the vector */
void clear();
/**
* OPERATORS
*/
// Assign a vector
void operator=(const Vector3& v) {
x = v.x;
y = v.y;
z = v.z;
}
// Equals
bool operator==(const Vector3& v) {
return (x == v.x) && (y == v.y) && (z == v.z);
}
/** Multiplies this vector by the given scalar.*/
void operator*=(const real value);
/** Adds the given vector to this.*/
void operator+=(const Vector3& v);
/**Substracts the given vector from this.*/
void operator-=(const Vector3& v);
/** Returns a copy of this vector scaled to the given value.*/
Vector3 operator*(const real value) const;
/** Returns the value of the given vector added to this*/
Vector3 operator+(const Vector3& v) const;
/** Returns the value of the given vector substracted from this */
Vector3 operator-(const Vector3& v) const;
/** Adds the given vector to this, scaled by the given amount */
void addScaledVector(const Vector3& vector, real scale);
/** Calculates and returns a component-wise product of this
* vector with the given vector */
Vector3 componentProduct(const Vector3& vector) const;
/** Performs a component-wise product with the given vector
* and sets this vector to its result */
void componentProductUpdate(const Vector3& vector);
/** Calculates and returns the scalar product of this vector
* with the given vector. */
real scalarProduct(const Vector3& vector) const;
/** Calculates and returns the scalar product of this vector
* with the given vector */
real operator*(const Vector3& vector) const;
/**
* Calculates and returns the vector product of this vector
* with the given vector.
*/
Vector3 vectorProduct(const Vector3& vectpr) const;
/**
* Updates this vector to be the vector product of its current
* value and the given vector.
*/
void operator%=(const Vector3& vector);
/**
* Calculates and returns the vector product of this vector
* with the given vector.
*/
Vector3 operator%(const Vector3& vector) const;
void set(int pos, real value) {
if (pos == 0)
x = value;
if (pos == 1)
y = value;
if (pos == 2)
z = value;
}
real get(int pos) const {
if (pos == 0)
return x;
if (pos == 1)
return y;
if (pos == 2)
return z;
return 0;
}
};
#endif /* VECTOR3_H_ */
| [
"merchante.mariano@d457d4b0-f835-b411-19da-99c4f284aa10"
]
| [
[
[
1,
148
]
]
]
|
4b30b0d564f6b3c14838734d12de667616382c97 | 3e69b159d352a57a48bc483cb8ca802b49679d65 | /trunk/gerbview/deltrack.cpp | 0da5e22180b1e2ae6860e762aed3635440aad168 | []
| no_license | BackupTheBerlios/kicad-svn | 4b79bc0af39d6e5cb0f07556eb781a83e8a464b9 | 4c97bbde4b1b12ec5616a57c17298c77a9790398 | refs/heads/master | 2021-01-01T19:38:40.000652 | 2006-06-19T20:01:24 | 2006-06-19T20:01:24 | 40,799,911 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,964 | cpp | /*********************************************/
/* Edition des pistes: Routines d'effacement */
/* Effacement de segment, piste, net et zone */
/*********************************************/
#include "fctsys.h"
#include "common.h"
#include "gerbview.h"
#include "protos.h"
/* Routines externes : */
/* Routines Locales */
/* Variables locales */
/*****************************************************************/
TRACK * WinEDA_GerberFrame::Delete_Segment(wxDC * DC, TRACK *Track)
/*****************************************************************/
/* Supprime 1 segment de piste.
2 Cas possibles:
Si On est en trace de nouvelle piste: Effacement du segment en
cours de trace
Sinon : Effacment du segment sous le curseur.
*/
{
if ( Track == NULL ) return NULL;
if(Track->m_Flags & IS_NEW) // Trace en cours, on peut effacer le dernier segment
{
if(g_TrackSegmentCount > 0 )
{
// modification du trace
Track = g_CurrentTrackSegment; g_CurrentTrackSegment = (TRACK*) g_CurrentTrackSegment->Pback;
delete Track; g_TrackSegmentCount--;
if( g_TrackSegmentCount && (g_CurrentTrackSegment->m_StructType == TYPEVIA))
{
Track = g_CurrentTrackSegment; g_CurrentTrackSegment = (TRACK*) g_CurrentTrackSegment->Pback;
delete Track;
g_TrackSegmentCount-- ;
}
if( g_CurrentTrackSegment ) g_CurrentTrackSegment->Pnext = NULL;
Affiche_Status_Box();
if(g_TrackSegmentCount == 0 )
{
GetScreen()->ManageCurseur = NULL;
GetScreen()->ForceCloseManageCurseur = NULL;
return NULL;
}
else
{
if(GetScreen()->ManageCurseur)
GetScreen()->ManageCurseur(DrawPanel, DC, FALSE);
return g_CurrentTrackSegment;
}
}
return NULL;
} // Fin traitement si trace en cours
Trace_Segment(DrawPanel, DC, Track,GR_XOR) ;
SaveItemEfface( Track, 1);
GetScreen()->SetModify();
return NULL;
}
| [
"bokeoa@244deca0-f506-0410-ab94-f4f3571dea26"
]
| [
[
[
1,
76
]
]
]
|
747caa7eaabb3ee01b5a99e577c8e086f55c3c80 | 854ee643a4e4d0b7a202fce237ee76b6930315ec | /arcemu_svn/src/arcemu-world/AddonMgr.h | 5625be615ccec8ef250e137289de3c2c5f7ae3ef | []
| no_license | miklasiak/projekt | df37fa82cf2d4a91c2073f41609bec8b2f23cf66 | 064402da950555bf88609e98b7256d4dc0af248a | refs/heads/master | 2021-01-01T19:29:49.778109 | 2008-11-10T17:14:14 | 2008-11-10T17:14:14 | 34,016,391 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,588 | h | /*
* ArcEmu MMORPG Server
* Copyright (C) 2005-2007 Ascent Team <http://www.ascentemu.com/>
* Copyright (C) 2008 <http://www.ArcEmu.org/>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __ADDONMGR_H
#define __ADDONMGR_H
struct AddonEntry
{
std::string name;
uint64 crc;
bool banned;
bool isNew;
bool showinlist;
};
class AddonMgr : public Singleton < AddonMgr >
{
public:
AddonMgr();
~AddonMgr();
void LoadFromDB();
void SaveToDB();
void SendAddonInfoPacket(WorldPacket *source, uint32 pos, WorldSession *m_session);
bool AppendPublicKey(WorldPacket& data, string AddonName, uint32 CRC);
private:
std::map<std::string, AddonEntry*> KnownAddons;
map<string, ByteBuffer> AddonData;
bool IsAddonBanned(uint64 crc, std::string name = "");
bool IsAddonBanned(std::string name, uint64 crc = 0);
bool ShouldShowInList(std::string name);
};
#define sAddonMgr AddonMgr::getSingleton()
#endif
| [
"[email protected]@3074cc92-8d2b-11dd-8ab4-67102e0efeef",
"[email protected]@3074cc92-8d2b-11dd-8ab4-67102e0efeef"
]
| [
[
[
1,
1
],
[
5,
56
]
],
[
[
2,
4
]
]
]
|
29d9f3d9cae84d7c19d72c45fda5bc3616a01227 | 0c62a303659646fa06db4d5d09c44ecb53ce619a | /Kickapoo/Map.cpp | a99b0cb0f369668767c15d63d0fe0641ade87636 | []
| no_license | gosuwachu/igk-game | 60dcdd8cebf7a25faf60a5cc0f5acd6f698c1c25 | faf2e6f3ec6cfe8ddc7cb1f3284f81753f9745f5 | refs/heads/master | 2020-05-17T21:51:18.433505 | 2010-04-12T12:42:01 | 2010-04-12T12:42:01 | 32,650,596 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,828 | cpp | #include "Common.h"
Map::Map()
{
wall = new Texture;
tower = new Texture;
tower2 = new Texture;
tower_death = new Texture;
playerTexture = new Texture;
playerSelected = new Texture;
player2Texture = new Texture;
player2Selected = new Texture;
wall->load("gfx/wall.png");
tower->load("gfx/tower.png");
tower2->load("gfx/tower2.png");
tower_death->load("gfx/tower_death.png");
playerTexture->load("gfx/player.png");
playerSelected->load("gfx/player_selected.png");
player2Texture->load("gfx/player2.png");
player2Selected->load("gfx/player2_selected.png");
}
Map::~Map()
{
delete wall;
delete tower;
delete tower_death;
delete playerTexture;
delete playerSelected;
delete player2Texture;
delete player2Selected;
}
static void trimr(char * buffer) {
unsigned length = strlen(buffer);
while(buffer[0] && (buffer[length-1] == '\n' || buffer[length-1] == '\r'))
buffer[length-1] = 0;
}
const char* basename(const char* p) {
if(strlen(p) >= 3)
return &p[strlen(p)-3];
return "";
}
Map* Map::load( const std::string& name )
{
FILE* file = fopen(name.c_str(), "rb");
if(!file)
return NULL;
Map* map = new Map;
if(!strcmpi(basename(name.c_str()), "bmp")) {
BITMAPFILEHEADER bmfh;
fread(&bmfh,sizeof(BITMAPFILEHEADER),1,file);
BITMAPINFOHEADER bmih;
fread(&bmih,sizeof(BITMAPINFOHEADER),1,file);
fseek(file, bmfh.bfOffBits, SEEK_SET);
map->width = bmih.biWidth;
map->height = bmih.biHeight;
map->map.resize(map->width * map->height);
assert(bmih.biBitCount == 24);
assert(bmih.biCompression == 0);
unsigned pad = (LONG)((float)map->width*(float)bmih.biBitCount/8.0);
unsigned byteWidth = pad;
//add any extra space to bring each line to a DWORD boundary
while(pad%4!=0) {
pad++;
}
for(unsigned i = map->height; i-- > 0; ) {
byte bytes[3];
for(unsigned j = 0; j < map->width; ++j) {
int index = (map->height - i - 1) * map->width + j;
fread(bytes, 3, 1, file);
std::swap(bytes[0], bytes[2]);
if(bytes[0]>80 && bytes[1]>80 && bytes[2]>80)
continue;
if(bytes[0]>80) {
if(bytes[2] > 80) {
map->map[index] = '$';
} else {
map->map[index] = '@';
}
}
else if(bytes[2]>80) {
map->map[index] = '^';
}
else if(bytes[1]>80) {
map->map[index] = '&';
}
else {
map->map[index] = '#';
}
}
fread(bytes, pad-byteWidth, 1, file);
}
}
else {
fscanf(file, "%i %i", &map->width, &map->height);
while(!feof(file)) {
static char buffer[10000];
fgets(buffer, sizeof(buffer), file);
trimr(buffer);
map->map += buffer;
}
}
assert(map->map.size() == map->width*map->height);
map->blockRandom.resize(map->map.size());
map->towerListMapped.resize(map->map.size());
map->fill();
fclose(file);
return map;
}
void Map::fill()
{
for(int i = 0; i < height; ++i)
{
for(int j = 0; j < width; ++j)
{
char block = map[index(j, i)];
if(block == '#') {
if(blockRandom[index(j, i)] == 0) {
fill_r(j, i, 0.001f);
}
}
}
}
}
void Map::fill_r(int x, int y, float dt)
{
if(map[index(x, y)] != '#')
return;
const float scale = 0.1f;
if(blockRandom[index(x, y)] == 0) {
blockRandom[index(x, y)] = dt;
}
else return;
if(x > 0)
fill_r(x-1, y, dt+scale);
if(x < width-1)
fill_r(x+1, y, dt+scale);
if(y > 0)
fill_r(x, y-1, dt+scale);
if(y < width-1)
fill_r(x, y+1, dt+scale);
}
void Map::loadContent(vector<Player>& playerList, vector<Tower>& towerList)
{
playerList.clear();
towerList.clear();
for(int i = 0; i < height; ++i)
{
for(int j = 0; j < width; ++j)
{
char block = map[index(j, i)];
if(block == '@' || block == '$')
{
Player player;
player.Position.x = j;
player.Position.y = i;
player.hasMissiles = block == '$';
if(block == '$')
{
player.playerTexture = player2Texture;
player.playerSelectedTexture = player2Selected;
}
else
{
player.playerTexture = playerTexture;
player.playerSelectedTexture = playerSelected;
}
playerList.push_back(player);
}
else if(block == '^' || block == '&')
{
Tower tower_;
if(block == '^')
{
tower_.type = ETT_STATIC;
tower_.setAliveTexture(tower2);
}
else if(block == '&')
{
tower_.type = ETT_SHOOTING;
tower_.setAliveTexture(tower);
}
tower_.Position.x = j;
tower_.Position.y = i;
tower_.setDeathTexture(tower_death);
towerList.push_back(tower_);
}
}
}
for(unsigned i = 0; i < towerList.size(); ++i) {
Tower& tower = towerList[i];
towerListMapped[index(tower.Position.x, tower.Position.y)] = &tower;
}
}
void Map::update()
{
for(unsigned i = 0; i < blockRandom.size(); ++i)
blockRandom[i] += g_Timer()->getFrameTime();
}
void Map::draw()
{
for(int i = 0; i < height; ++i)
{
for(int j = 0; j < width; ++j)
{
char block = map[index(j, i)];
if(block == '#')
{
float size = 2+cosf(blockRandom[i * width + j]*6) * 1.0f;
wall->set();
g_Renderer()->drawRect(j*BLOCK_SIZE+size, i*BLOCK_SIZE+size, BLOCK_SIZE-2*size, BLOCK_SIZE-2*size);
}
else {
wall->set();
g_Renderer()->drawRect(j*BLOCK_SIZE+1, i*BLOCK_SIZE+1, BLOCK_SIZE-2, BLOCK_SIZE-2, D3DCOLOR_XRGB(16, 16, 16));
}
/*else if(block == '^')
{
tower->set();
g_Renderer()->drawRect(j*BLOCK_SIZE, i*BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE);
}*/
}
}
for(int i = 0; i < height; ++i)
{
for(int j = 0; j < width-1; ++j)
{
char a = map[index(j, i)];
char b = map[index(j+1, i)];
if(a == '#' && a != b || a != b && b == '#')
{
g_Renderer()->drawLine((j+1)*BLOCK_SIZE-1, i*BLOCK_SIZE,
(j+1)*BLOCK_SIZE-1, (i+1)*BLOCK_SIZE, 2, D3DCOLOR_XRGB(64, 64, 255));
/* float sx = (j+1)*BLOCK_SIZE-1;
float sy = i*BLOCK_SIZE;
float ex = (j+1)*BLOCK_SIZE-1;
float ey = (i+1)*BLOCK_SIZE;
float centerx = (sx + ex) * 0.5f - (ex-sx)*0.5f;
float centery = (sy + ey) * 0.5f - (ey-sy)*0.5f;
wall->set();
g_Renderer()->drawRect( centerx, centery, 4, ey - sy, D3DCOLOR_XRGB(64, 64, 255));
*/}
}
}
for(int i = 0; i < height-1; ++i)
{
for(int j = 0; j < width; ++j)
{
char a = map[index(j, i)];
char b = map[index(j, i+1)];
if(a == '#' && a != b || a != b && b == '#')
{
g_Renderer()->drawLine(j*BLOCK_SIZE, (i+1)*BLOCK_SIZE-1,
(j+1)*BLOCK_SIZE, (i+1)*BLOCK_SIZE-1, 2, D3DCOLOR_XRGB(64, 64, 255));
/* float sx =j*BLOCK_SIZE;
float sy = (i+1)*BLOCK_SIZE-1;
float ex =(j+1)*BLOCK_SIZE;
float ey = (i+1)*BLOCK_SIZE-1;
float centerx = (sx + ex) * 0.5f - (ex-sx)*0.5f;
float centery = (sy + ey) * 0.5f - (ey-sy)*0.5f;
wall->set();
g_Renderer()->drawRect( centerx, centery, ex-sx , 4, D3DCOLOR_XRGB(64, 64, 255));
*/
}
}
}
}
bool Map::collides(const D3DXVECTOR2& v) const {
return blocked(v.x + 0.1f, v.y + 0.1f) || blocked(v.x + 0.9f, v.y + 0.1f) ||
blocked(v.x + 0.1f, v.y + 0.9f) || blocked(v.x + 0.9f, v.y + 0.9f);
}
D3DXVECTOR2 Map::slide(const D3DXVECTOR2& a, const D3DXVECTOR2& b) {
if(!collides(D3DXVECTOR2(b.x, b.y)))
return b;
if(!collides(D3DXVECTOR2(b.x, a.y)))
return D3DXVECTOR2(b.x, a.y);
if(!collides(D3DXVECTOR2(a.x, b.y)))
return D3DXVECTOR2(a.x, b.y);
return a;
}
bool Map::blocked(int x, int y, bool withTower) const {
if(map[index(x, y)] == '#')
return true;
Tower* tower = towerListMapped[index(x, y)];
if(tower && tower->state == ETS_ALIVE)
return withTower;
return false;
} | [
"konrad.rodzik@d16c65a5-d515-2969-3ec5-0ec16041161d",
"[email protected]@d16c65a5-d515-2969-3ec5-0ec16041161d",
"[email protected]@d16c65a5-d515-2969-3ec5-0ec16041161d"
]
| [
[
[
1,
34
],
[
47,
48
],
[
50,
54
],
[
77,
77
],
[
124,
128
],
[
147,
147
],
[
184,
194
],
[
197,
217
],
[
226,
226
],
[
231,
238
],
[
240,
241
],
[
244,
244
],
[
246,
246
],
[
252,
258
]
],
[
[
35,
46
],
[
49,
49
],
[
55,
76
],
[
78,
123
],
[
129,
146
],
[
148,
183
],
[
195,
196
],
[
218,
225
],
[
227,
230
],
[
239,
239
],
[
242,
243
],
[
245,
245
],
[
247,
251
],
[
259,
268
],
[
282,
295
],
[
306,
335
]
],
[
[
269,
281
],
[
296,
305
]
]
]
|
20799166a2ce82a5ddb479c1168770965bbfbfb5 | 011359e589f99ae5fe8271962d447165e9ff7768 | /src/cpu/m6809/m6809.cpp | 47b620cc19fd7c2cf838edd74eb9f6284e34eabc | []
| no_license | PS3emulators/fba-next-slim | 4c753375fd68863c53830bb367c61737393f9777 | d082dea48c378bddd5e2a686fe8c19beb06db8e1 | refs/heads/master | 2021-01-17T23:05:29.479865 | 2011-12-01T18:16:02 | 2011-12-01T18:16:02 | 2,899,840 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 55,976 | cpp | /*** m6809: Portable 6809 emulator ******************************************
Copyright John Butler
References:
6809 Simulator V09, By L.C. Benschop, Eidnhoven The Netherlands.
m6809: Portable 6809 emulator, DS (6809 code in MAME, derived from
the 6809 Simulator V09)
6809 Microcomputer Programming & Interfacing with Experiments"
by Andrew C. Staugaard, Jr.; Howard W. Sams & Co., Inc.
System dependencies: UINT16 must be 16 bit unsigned int
UINT8 must be 8 bit unsigned int
UINT32 must be more than 16 bits
arrays up to 65536 bytes must be supported
machine must be twos complement
History:
991026 HJB:
Fixed missing calls to cpu_changepc() for the TFR and EXG ocpodes.
Replaced m6809_slapstic checks by a macro (CHANGE_PC). ESB still
needs the tweaks.
991024 HJB:
Tried to improve speed: Using bit7 of cycles1/2 as flag for multi
byte opcodes is gone, those opcodes now call fetch_effective_address().
Got rid of the slow/fast flags for stack (S and U) memory accesses.
Minor changes to use 32 bit values as arguments to memory functions
and added defines for that purpose (e.g. X = 16bit XD = 32bit).
990312 HJB:
Added bugfixes according to Aaron's findings.
Reset only sets CC_II and CC_IF, DP to zero and PC from reset vector.
990311 HJB:
Added _info functions. Now uses static m6808_Regs struct instead
of single statics. Changed the 16 bit registers to use the generic
PAIR union. Registers defined using macros. Split the core into
four execution loops for M6802, M6803, M6808 and HD63701.
TST, TSTA and TSTB opcodes reset carry flag.
Modified the read/write stack handlers to push LSB first then MSB
and pull MSB first then LSB.
990228 HJB:
Changed the interrupt handling again. Now interrupts are taken
either right at the moment the lines are asserted or whenever
an interrupt is enabled and the corresponding line is still
asserted. That way the pending_interrupts checks are not
needed anymore. However, the CWAI and SYNC flags still need
some flags, so I changed the name to 'int_state'.
This core also has the code for the old interrupt system removed.
990225 HJB:
Cleaned up the code here and there, added some comments.
Slightly changed the SAR opcodes (similiar to other CPU cores).
Added symbolic names for the flag bits.
Changed the way CWAI/Interrupt() handle CPU state saving.
A new flag M6809_STATE in pending_interrupts is used to determine
if a state save is needed on interrupt entry or already done by CWAI.
Added M6809_IRQ_LINE and M6809_FIRQ_LINE defines to m6809.h
Moved the internal interrupt_pending flags from m6809.h to m6809.c
Changed CWAI cycles2[0x3c] to be 2 (plus all or at least 19 if
CWAI actually pushes the entire state).
Implemented undocumented TFR/EXG for undefined source and mixed 8/16
bit transfers (they should transfer/exchange the constant $ff).
Removed unused jmp/jsr _slap functions from 6809ops.c,
m6809_slapstick check moved into the opcode functions.
*****************************************************************************/
//#include "debugger.h"
#include "burnint.h"
#include "m6809.h"
/* Enable big switch statement for the main opcodes */
#ifndef BIG_SWITCH
#define BIG_SWITCH 1
#endif
#define VERBOSE 0
#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
//extern offs_t m6809_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram);
#define M6809_INLINE static
#define change_pc(newpc) m6809.pc.w.l = (newpc)
#define M6809_CLEAR_LINE 0
#define M6809_INPUT_LINE_NMI 32
M6809_INLINE void fetch_effective_address( void );
/* flag bits in the cc register */
#define CC_C 0x01 /* Carry */
#define CC_V 0x02 /* Overflow */
#define CC_Z 0x04 /* Zero */
#define CC_N 0x08 /* Negative */
#define CC_II 0x10 /* Inhibit IRQ */
#define CC_H 0x20 /* Half (auxiliary) carry */
#define CC_IF 0x40 /* Inhibit FIRQ */
#define CC_E 0x80 /* entire state pushed */
/* 6809 registers */
static m6809_Regs m6809;
#define pPPC m6809.ppc
#define pPC m6809.pc
#define pU m6809.u
#define pS m6809.s
#define pX m6809.x
#define pY m6809.y
#define pD m6809.d
#define PPC m6809.ppc.w.l
#define PC m6809.pc.w.l
#define PCD m6809.pc.d
#define U m6809.u.w.l
#define UD m6809.u.d
#define S m6809.s.w.l
#define SD m6809.s.d
#define X m6809.x.w.l
#define XD m6809.x.d
#define Y m6809.y.w.l
#define YD m6809.y.d
#define D m6809.d.w.l
#define A m6809.d.b.h
#define B m6809.d.b.l
#define DP m6809.dp.b.h
#define DPD m6809.dp.d
#define CC m6809.cc
static PAIR ea; /* effective address */
#define EA ea.w.l
#define EAD ea.d
#define CHANGE_PC change_pc(PCD)
#define M6809_CWAI 8 /* set when CWAI is waiting for an interrupt */
#define M6809_SYNC 16 /* set when SYNC is waiting for an interrupt */
#define M6809_LDS 32 /* set when LDS occured at least once */
#define CHECK_IRQ_LINES \
if( m6809.irq_state[M6809_IRQ_LINE] != M6809_CLEAR_LINE || \
m6809.irq_state[M6809_FIRQ_LINE] != M6809_CLEAR_LINE ) \
m6809.int_state &= ~M6809_SYNC; /* clear SYNC flag */ \
if( m6809.irq_state[M6809_FIRQ_LINE]!=M6809_CLEAR_LINE && !(CC & CC_IF) ) \
{ \
/* fast IRQ */ \
/* HJB 990225: state already saved by CWAI? */ \
if( m6809.int_state & M6809_CWAI ) \
{ \
m6809.int_state &= ~M6809_CWAI; /* clear CWAI */ \
m6809.extra_cycles += 7; /* subtract +7 cycles */ \
} \
else \
{ \
CC &= ~CC_E; /* save 'short' state */ \
PUSHWORD(pPC); \
PUSHBYTE(CC); \
m6809.extra_cycles += 10; /* subtract +10 cycles */ \
} \
CC |= CC_IF | CC_II; /* inhibit FIRQ and IRQ */ \
PCD=RM16(0xfff6); \
CHANGE_PC; \
} \
else \
if( m6809.irq_state[M6809_IRQ_LINE]!=M6809_CLEAR_LINE && !(CC & CC_II) ) \
{ \
/* standard IRQ */ \
/* HJB 990225: state already saved by CWAI? */ \
if( m6809.int_state & M6809_CWAI ) \
{ \
m6809.int_state &= ~M6809_CWAI; /* clear CWAI flag */ \
m6809.extra_cycles += 7; /* subtract +7 cycles */ \
} \
else \
{ \
CC |= CC_E; /* save entire state */ \
PUSHWORD(pPC); \
PUSHWORD(pU); \
PUSHWORD(pY); \
PUSHWORD(pX); \
PUSHBYTE(DP); \
PUSHBYTE(B); \
PUSHBYTE(A); \
PUSHBYTE(CC); \
m6809.extra_cycles += 19; /* subtract +19 cycles */ \
} \
CC |= CC_II; /* inhibit IRQ */ \
PCD=RM16(0xfff8); \
CHANGE_PC; \
}
/* public globals */
static int m6809_ICount;
/* these are re-defined in m6809.h TO RAM, ROM or functions in cpuintrf.c */
#define RM(Addr) M6809_RDMEM(Addr)
#define WM(Addr,Value) M6809_WRMEM(Addr,Value)
#define ROP(Addr) M6809_RDOP(Addr)
#define ROP_ARG(Addr) M6809_RDOP_ARG(Addr)
/* macros to access memory */
#define IMMBYTE(b) b = ROP_ARG(PCD); PC++
#define IMMWORD(w) w.d = (ROP_ARG(PCD)<<8) | ROP_ARG((PCD+1)&0xffff); PC+=2
#define PUSHBYTE(b) --S; WM(SD,b)
#define PUSHWORD(w) --S; WM(SD,w.b.l); --S; WM(SD,w.b.h)
#define PULLBYTE(b) b = RM(SD); S++
#define PULLWORD(w) w = RM(SD)<<8; S++; w |= RM(SD); S++
#define PSHUBYTE(b) --U; WM(UD,b);
#define PSHUWORD(w) --U; WM(UD,w.b.l); --U; WM(UD,w.b.h)
#define PULUBYTE(b) b = RM(UD); U++
#define PULUWORD(w) w = RM(UD)<<8; U++; w |= RM(UD); U++
#define CLR_HNZVC CC&=~(CC_H|CC_N|CC_Z|CC_V|CC_C)
#define CLR_NZV CC&=~(CC_N|CC_Z|CC_V)
#define CLR_NZ CC&=~(CC_N|CC_Z)
#define CLR_HNZC CC&=~(CC_H|CC_N|CC_Z|CC_C)
#define CLR_NZVC CC&=~(CC_N|CC_Z|CC_V|CC_C)
#define CLR_Z CC&=~(CC_Z)
#define CLR_NZC CC&=~(CC_N|CC_Z|CC_C)
#define CLR_ZC CC&=~(CC_Z|CC_C)
/* macros for CC -- CC bits affected should be reset before calling */
#define SET_Z(a) if(!a)SEZ
#define SET_Z8(a) SET_Z((UINT8)a)
#define SET_Z16(a) SET_Z((UINT16)a)
#define SET_N8(a) CC|=((a&0x80)>>4)
#define SET_N16(a) CC|=((a&0x8000)>>12)
#define SET_H(a,b,r) CC|=(((a^b^r)&0x10)<<1)
#define SET_C8(a) CC|=((a&0x100)>>8)
#define SET_C16(a) CC|=((a&0x10000)>>16)
#define SET_V8(a,b,r) CC|=(((a^b^r^(r>>1))&0x80)>>6)
#define SET_V16(a,b,r) CC|=(((a^b^r^(r>>1))&0x8000)>>14)
static const UINT8 flags8i[256]= /* increment */
{
CC_Z,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
CC_N|CC_V,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,
CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,
CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,
CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,
CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,
CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,
CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,
CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N
};
static const UINT8 flags8d[256]= /* decrement */
{
CC_Z,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,CC_V,
CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,
CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,
CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,
CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,
CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,
CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,
CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,
CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N,CC_N
};
#define SET_FLAGS8I(a) {CC|=flags8i[(a)&0xff];}
#define SET_FLAGS8D(a) {CC|=flags8d[(a)&0xff];}
/* combos */
#define SET_NZ8(a) {SET_N8(a);SET_Z(a);}
#define SET_NZ16(a) {SET_N16(a);SET_Z(a);}
#define SET_FLAGS8(a,b,r) {SET_N8(r);SET_Z8(r);SET_V8(a,b,r);SET_C8(r);}
#define SET_FLAGS16(a,b,r) {SET_N16(r);SET_Z16(r);SET_V16(a,b,r);SET_C16(r);}
/* for treating an unsigned byte as a signed word */
#define SIGNED(b) ((UINT16)(b&0x80?b|0xff00:b))
/* macros for addressing modes (postbytes have their own code) */
#define DIRECT EAD = DPD; IMMBYTE(ea.b.l)
#define IMM8 EAD = PCD; PC++
#define IMM16 EAD = PCD; PC+=2
#define EXTENDED IMMWORD(ea)
/* macros to set status flags */
#if defined(SEC)
#undef SEC
#endif
#define SEC CC|=CC_C
#define CLC CC&=~CC_C
#define SEZ CC|=CC_Z
#define CLZ CC&=~CC_Z
#define SEN CC|=CC_N
#define CLN CC&=~CC_N
#define SEV CC|=CC_V
#define CLV CC&=~CC_V
#define SEH CC|=CC_H
#define CLH CC&=~CC_H
/* macros for convenience */
#define DIRBYTE(b) {DIRECT;b=RM(EAD);}
#define DIRWORD(w) {DIRECT;w.d=RM16(EAD);}
#define EXTBYTE(b) {EXTENDED;b=RM(EAD);}
#define EXTWORD(w) {EXTENDED;w.d=RM16(EAD);}
/* macros for branch instructions */
#define BRANCH(f) { \
UINT8 t; \
IMMBYTE(t); \
if( f ) \
{ \
PC += SIGNED(t); \
CHANGE_PC; \
} \
}
#define LBRANCH(f) { \
PAIR t; \
IMMWORD(t); \
if( f ) \
{ \
m6809_ICount -= 1; \
PC += t.w.l; \
CHANGE_PC; \
} \
}
#define NXORV ((CC&CC_N)^((CC&CC_V)<<2))
/* macros for setting/getting registers in TFR/EXG instructions */
#if (!BIG_SWITCH)
/* timings for 1-byte opcodes */
static const UINT8 cycles1[] =
{
/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
/*0*/ 6, 0, 0, 6, 6, 0, 6, 6, 6, 6, 6, 0, 6, 6, 3, 6,
/*1*/ 0, 0, 2, 4, 0, 0, 5, 9, 0, 2, 3, 0, 3, 2, 8, 6,
/*2*/ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
/*3*/ 4, 4, 4, 4, 5, 5, 5, 5, 0, 5, 3, 6,20,11, 0,19,
/*4*/ 2, 0, 0, 2, 2, 0, 2, 2, 2, 2, 2, 0, 2, 2, 0, 2,
/*5*/ 2, 0, 0, 2, 2, 0, 2, 2, 2, 2, 2, 0, 2, 2, 0, 2,
/*6*/ 6, 0, 0, 6, 6, 0, 6, 6, 6, 6, 6, 0, 6, 6, 3, 6,
/*7*/ 7, 0, 0, 7, 7, 0, 7, 7, 7, 7, 7, 0, 7, 7, 4, 7,
/*8*/ 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 4, 7, 3, 0,
/*9*/ 4, 4, 4, 6, 4, 4, 4, 4, 4, 4, 4, 4, 6, 7, 5, 5,
/*A*/ 4, 4, 4, 6, 4, 4, 4, 4, 4, 4, 4, 4, 6, 7, 5, 5,
/*B*/ 5, 5, 5, 7, 5, 5, 5, 5, 5, 5, 5, 5, 7, 8, 6, 6,
/*C*/ 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 3, 0, 3, 3,
/*D*/ 4, 4, 4, 6, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5,
/*E*/ 4, 4, 4, 6, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5,
/*F*/ 5, 5, 5, 7, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6
};
#endif
M6809_INLINE UINT32 RM16( UINT32 Addr )
{
UINT32 result = RM(Addr) << 8;
return result | RM((Addr+1)&0xffff);
}
M6809_INLINE void WM16( UINT32 Addr, PAIR *p )
{
WM( Addr, p->b.h );
WM( (Addr+1)&0xffff, p->b.l );
}
/****************************************************************************
* Get all registers in given buffer
****************************************************************************/
void m6809_get_context(void *dst)
{
if( dst )
*(m6809_Regs*)dst = m6809;
}
/****************************************************************************
* Set all registers to given values
****************************************************************************/
void m6809_set_context(void *src)
{
if( src )
m6809 = *(m6809_Regs*)src;
CHANGE_PC;
CHECK_IRQ_LINES;
}
/****************************************************************************/
/* Reset registers to their initial values */
/****************************************************************************/
void m6809_init(int (*irqcallback)(int))
{
// state_save_register_item("m6809", index, PC);
// state_save_register_item("m6809", index, PPC);
// state_save_register_item("m6809", index, D);
// state_save_register_item("m6809", index, DP);
// state_save_register_item("m6809", index, U);
// state_save_register_item("m6809", index, S);
// state_save_register_item("m6809", index, X);
// state_save_register_item("m6809", index, Y);
// state_save_register_item("m6809", index, CC);
// state_save_register_item_array("m6809", index, m6809.irq_state);
// state_save_register_item("m6809", index, m6809.int_state);
// state_save_register_item("m6809", index, m6809.nmi_state);
m6809.irq_callback = irqcallback;
}
void m6809_reset(void)
{
m6809.int_state = 0;
m6809.nmi_state = M6809_CLEAR_LINE;
m6809.irq_state[0] = M6809_CLEAR_LINE;
m6809.irq_state[1] = M6809_CLEAR_LINE;
DPD = 0; /* Reset direct page register */
CC |= CC_II; /* IRQ disabled */
CC |= CC_IF; /* FIRQ disabled */
PCD = RM16(0xfffe);
CHANGE_PC;
}
/*
static void m6809_exit(void)
{
}
*/
/* Generate interrupts */
/****************************************************************************
* Set IRQ line state
****************************************************************************/
void m6809_set_irq_line(int irqline, int state)
{
if (irqline == M6809_INPUT_LINE_NMI)
{
if (m6809.nmi_state == state) return;
m6809.nmi_state = state;
// LOG(("M6809#%d set_irq_line (NMI) %d\n", cpu_getactivecpu(), state));
if( state == M6809_CLEAR_LINE ) return;
/* if the stack was not yet initialized */
if( !(m6809.int_state & M6809_LDS) ) return;
m6809.int_state &= ~M6809_SYNC;
/* HJB 990225: state already saved by CWAI? */
if( m6809.int_state & M6809_CWAI )
{
m6809.int_state &= ~M6809_CWAI;
m6809.extra_cycles += 7; /* subtract +7 cycles next time */
}
else
{
CC |= CC_E; /* save entire state */
PUSHWORD(pPC);
PUSHWORD(pU);
PUSHWORD(pY);
PUSHWORD(pX);
PUSHBYTE(DP);
PUSHBYTE(B);
PUSHBYTE(A);
PUSHBYTE(CC);
m6809.extra_cycles += 19; /* subtract +19 cycles next time */
}
CC |= CC_IF | CC_II; /* inhibit FIRQ and IRQ */
PCD = RM16(0xfffc);
CHANGE_PC;
}
else if (irqline < 2)
{
// LOG(("M6809#%d set_irq_line %d, %d\n", cpu_getactivecpu(), irqline, state));
m6809.irq_state[irqline] = state;
if (state == M6809_CLEAR_LINE) return;
CHECK_IRQ_LINES;
}
}
/* includes the static function prototypes and the master opcode table */
#include "6809tbl.c"
/* includes the actual opcode implementations */
#include "6809ops.c"
/* execute instructions on this CPU until icount expires */
int m6809_execute(int cycles) /* NS 970908 */
{
m6809_ICount = cycles - m6809.extra_cycles;
m6809.extra_cycles = 0;
if (m6809.int_state & (M6809_CWAI | M6809_SYNC))
{
// debugger_instruction_hook(Machine, PCD);
m6809_ICount = 0;
}
else
{
do
{
pPPC = pPC;
// debugger_instruction_hook(Machine, PCD);
m6809.ireg = ROP(PCD);
PC++;
#if BIG_SWITCH
switch( m6809.ireg )
{
case 0x00: neg_di(); m6809_ICount-= 6; break;
case 0x01: neg_di(); m6809_ICount-= 6; break; /* undocumented */
case 0x02: illegal(); m6809_ICount-= 2; break;
case 0x03: com_di(); m6809_ICount-= 6; break;
case 0x04: lsr_di(); m6809_ICount-= 6; break;
case 0x05: illegal(); m6809_ICount-= 2; break;
case 0x06: ror_di(); m6809_ICount-= 6; break;
case 0x07: asr_di(); m6809_ICount-= 6; break;
case 0x08: asl_di(); m6809_ICount-= 6; break;
case 0x09: rol_di(); m6809_ICount-= 6; break;
case 0x0a: dec_di(); m6809_ICount-= 6; break;
case 0x0b: illegal(); m6809_ICount-= 2; break;
case 0x0c: inc_di(); m6809_ICount-= 6; break;
case 0x0d: tst_di(); m6809_ICount-= 6; break;
case 0x0e: jmp_di(); m6809_ICount-= 3; break;
case 0x0f: clr_di(); m6809_ICount-= 6; break;
case 0x10: pref10(); break;
case 0x11: pref11(); break;
case 0x12: nop(); m6809_ICount-= 2; break;
case 0x13: sync(); m6809_ICount-= 4; break;
case 0x14: illegal(); m6809_ICount-= 2; break;
case 0x15: illegal(); m6809_ICount-= 2; break;
case 0x16: lbra(); m6809_ICount-= 5; break;
case 0x17: lbsr(); m6809_ICount-= 9; break;
case 0x18: illegal(); m6809_ICount-= 2; break;
case 0x19: daa(); m6809_ICount-= 2; break;
case 0x1a: orcc(); m6809_ICount-= 3; break;
case 0x1b: illegal(); m6809_ICount-= 2; break;
case 0x1c: andcc(); m6809_ICount-= 3; break;
case 0x1d: sex(); m6809_ICount-= 2; break;
case 0x1e: exg(); m6809_ICount-= 8; break;
case 0x1f: tfr(); m6809_ICount-= 6; break;
case 0x20: bra(); m6809_ICount-= 3; break;
case 0x21: brn(); m6809_ICount-= 3; break;
case 0x22: bhi(); m6809_ICount-= 3; break;
case 0x23: bls(); m6809_ICount-= 3; break;
case 0x24: bcc(); m6809_ICount-= 3; break;
case 0x25: bcs(); m6809_ICount-= 3; break;
case 0x26: bne(); m6809_ICount-= 3; break;
case 0x27: beq(); m6809_ICount-= 3; break;
case 0x28: bvc(); m6809_ICount-= 3; break;
case 0x29: bvs(); m6809_ICount-= 3; break;
case 0x2a: bpl(); m6809_ICount-= 3; break;
case 0x2b: bmi(); m6809_ICount-= 3; break;
case 0x2c: bge(); m6809_ICount-= 3; break;
case 0x2d: blt(); m6809_ICount-= 3; break;
case 0x2e: bgt(); m6809_ICount-= 3; break;
case 0x2f: ble(); m6809_ICount-= 3; break;
case 0x30: leax(); m6809_ICount-= 4; break;
case 0x31: leay(); m6809_ICount-= 4; break;
case 0x32: leas(); m6809_ICount-= 4; break;
case 0x33: leau(); m6809_ICount-= 4; break;
case 0x34: pshs(); m6809_ICount-= 5; break;
case 0x35: puls(); m6809_ICount-= 5; break;
case 0x36: pshu(); m6809_ICount-= 5; break;
case 0x37: pulu(); m6809_ICount-= 5; break;
case 0x38: illegal(); m6809_ICount-= 2; break;
case 0x39: rts(); m6809_ICount-= 5; break;
case 0x3a: abx(); m6809_ICount-= 3; break;
case 0x3b: rti(); m6809_ICount-= 6; break;
case 0x3c: cwai(); m6809_ICount-=20; break;
case 0x3d: mul(); m6809_ICount-=11; break;
case 0x3e: illegal(); m6809_ICount-= 2; break;
case 0x3f: swi(); m6809_ICount-=19; break;
case 0x40: nega(); m6809_ICount-= 2; break;
case 0x41: illegal(); m6809_ICount-= 2; break;
case 0x42: illegal(); m6809_ICount-= 2; break;
case 0x43: coma(); m6809_ICount-= 2; break;
case 0x44: lsra(); m6809_ICount-= 2; break;
case 0x45: illegal(); m6809_ICount-= 2; break;
case 0x46: rora(); m6809_ICount-= 2; break;
case 0x47: asra(); m6809_ICount-= 2; break;
case 0x48: asla(); m6809_ICount-= 2; break;
case 0x49: rola(); m6809_ICount-= 2; break;
case 0x4a: deca(); m6809_ICount-= 2; break;
case 0x4b: illegal(); m6809_ICount-= 2; break;
case 0x4c: inca(); m6809_ICount-= 2; break;
case 0x4d: tsta(); m6809_ICount-= 2; break;
case 0x4e: illegal(); m6809_ICount-= 2; break;
case 0x4f: clra(); m6809_ICount-= 2; break;
case 0x50: negb(); m6809_ICount-= 2; break;
case 0x51: illegal(); m6809_ICount-= 2; break;
case 0x52: illegal(); m6809_ICount-= 2; break;
case 0x53: comb(); m6809_ICount-= 2; break;
case 0x54: lsrb(); m6809_ICount-= 2; break;
case 0x55: illegal(); m6809_ICount-= 2; break;
case 0x56: rorb(); m6809_ICount-= 2; break;
case 0x57: asrb(); m6809_ICount-= 2; break;
case 0x58: aslb(); m6809_ICount-= 2; break;
case 0x59: rolb(); m6809_ICount-= 2; break;
case 0x5a: decb(); m6809_ICount-= 2; break;
case 0x5b: illegal(); m6809_ICount-= 2; break;
case 0x5c: incb(); m6809_ICount-= 2; break;
case 0x5d: tstb(); m6809_ICount-= 2; break;
case 0x5e: illegal(); m6809_ICount-= 2; break;
case 0x5f: clrb(); m6809_ICount-= 2; break;
case 0x60: neg_ix(); m6809_ICount-= 6; break;
case 0x61: illegal(); m6809_ICount-= 2; break;
case 0x62: illegal(); m6809_ICount-= 2; break;
case 0x63: com_ix(); m6809_ICount-= 6; break;
case 0x64: lsr_ix(); m6809_ICount-= 6; break;
case 0x65: illegal(); m6809_ICount-= 2; break;
case 0x66: ror_ix(); m6809_ICount-= 6; break;
case 0x67: asr_ix(); m6809_ICount-= 6; break;
case 0x68: asl_ix(); m6809_ICount-= 6; break;
case 0x69: rol_ix(); m6809_ICount-= 6; break;
case 0x6a: dec_ix(); m6809_ICount-= 6; break;
case 0x6b: illegal(); m6809_ICount-= 2; break;
case 0x6c: inc_ix(); m6809_ICount-= 6; break;
case 0x6d: tst_ix(); m6809_ICount-= 6; break;
case 0x6e: jmp_ix(); m6809_ICount-= 3; break;
case 0x6f: clr_ix(); m6809_ICount-= 6; break;
case 0x70: neg_ex(); m6809_ICount-= 7; break;
case 0x71: illegal(); m6809_ICount-= 2; break;
case 0x72: illegal(); m6809_ICount-= 2; break;
case 0x73: com_ex(); m6809_ICount-= 7; break;
case 0x74: lsr_ex(); m6809_ICount-= 7; break;
case 0x75: illegal(); m6809_ICount-= 2; break;
case 0x76: ror_ex(); m6809_ICount-= 7; break;
case 0x77: asr_ex(); m6809_ICount-= 7; break;
case 0x78: asl_ex(); m6809_ICount-= 7; break;
case 0x79: rol_ex(); m6809_ICount-= 7; break;
case 0x7a: dec_ex(); m6809_ICount-= 7; break;
case 0x7b: illegal(); m6809_ICount-= 2; break;
case 0x7c: inc_ex(); m6809_ICount-= 7; break;
case 0x7d: tst_ex(); m6809_ICount-= 7; break;
case 0x7e: jmp_ex(); m6809_ICount-= 4; break;
case 0x7f: clr_ex(); m6809_ICount-= 7; break;
case 0x80: suba_im(); m6809_ICount-= 2; break;
case 0x81: cmpa_im(); m6809_ICount-= 2; break;
case 0x82: sbca_im(); m6809_ICount-= 2; break;
case 0x83: subd_im(); m6809_ICount-= 4; break;
case 0x84: anda_im(); m6809_ICount-= 2; break;
case 0x85: bita_im(); m6809_ICount-= 2; break;
case 0x86: lda_im(); m6809_ICount-= 2; break;
case 0x87: sta_im(); m6809_ICount-= 2; break;
case 0x88: eora_im(); m6809_ICount-= 2; break;
case 0x89: adca_im(); m6809_ICount-= 2; break;
case 0x8a: ora_im(); m6809_ICount-= 2; break;
case 0x8b: adda_im(); m6809_ICount-= 2; break;
case 0x8c: cmpx_im(); m6809_ICount-= 4; break;
case 0x8d: bsr(); m6809_ICount-= 7; break;
case 0x8e: ldx_im(); m6809_ICount-= 3; break;
case 0x8f: stx_im(); m6809_ICount-= 2; break;
case 0x90: suba_di(); m6809_ICount-= 4; break;
case 0x91: cmpa_di(); m6809_ICount-= 4; break;
case 0x92: sbca_di(); m6809_ICount-= 4; break;
case 0x93: subd_di(); m6809_ICount-= 6; break;
case 0x94: anda_di(); m6809_ICount-= 4; break;
case 0x95: bita_di(); m6809_ICount-= 4; break;
case 0x96: lda_di(); m6809_ICount-= 4; break;
case 0x97: sta_di(); m6809_ICount-= 4; break;
case 0x98: eora_di(); m6809_ICount-= 4; break;
case 0x99: adca_di(); m6809_ICount-= 4; break;
case 0x9a: ora_di(); m6809_ICount-= 4; break;
case 0x9b: adda_di(); m6809_ICount-= 4; break;
case 0x9c: cmpx_di(); m6809_ICount-= 6; break;
case 0x9d: jsr_di(); m6809_ICount-= 7; break;
case 0x9e: ldx_di(); m6809_ICount-= 5; break;
case 0x9f: stx_di(); m6809_ICount-= 5; break;
case 0xa0: suba_ix(); m6809_ICount-= 4; break;
case 0xa1: cmpa_ix(); m6809_ICount-= 4; break;
case 0xa2: sbca_ix(); m6809_ICount-= 4; break;
case 0xa3: subd_ix(); m6809_ICount-= 6; break;
case 0xa4: anda_ix(); m6809_ICount-= 4; break;
case 0xa5: bita_ix(); m6809_ICount-= 4; break;
case 0xa6: lda_ix(); m6809_ICount-= 4; break;
case 0xa7: sta_ix(); m6809_ICount-= 4; break;
case 0xa8: eora_ix(); m6809_ICount-= 4; break;
case 0xa9: adca_ix(); m6809_ICount-= 4; break;
case 0xaa: ora_ix(); m6809_ICount-= 4; break;
case 0xab: adda_ix(); m6809_ICount-= 4; break;
case 0xac: cmpx_ix(); m6809_ICount-= 6; break;
case 0xad: jsr_ix(); m6809_ICount-= 7; break;
case 0xae: ldx_ix(); m6809_ICount-= 5; break;
case 0xaf: stx_ix(); m6809_ICount-= 5; break;
case 0xb0: suba_ex(); m6809_ICount-= 5; break;
case 0xb1: cmpa_ex(); m6809_ICount-= 5; break;
case 0xb2: sbca_ex(); m6809_ICount-= 5; break;
case 0xb3: subd_ex(); m6809_ICount-= 7; break;
case 0xb4: anda_ex(); m6809_ICount-= 5; break;
case 0xb5: bita_ex(); m6809_ICount-= 5; break;
case 0xb6: lda_ex(); m6809_ICount-= 5; break;
case 0xb7: sta_ex(); m6809_ICount-= 5; break;
case 0xb8: eora_ex(); m6809_ICount-= 5; break;
case 0xb9: adca_ex(); m6809_ICount-= 5; break;
case 0xba: ora_ex(); m6809_ICount-= 5; break;
case 0xbb: adda_ex(); m6809_ICount-= 5; break;
case 0xbc: cmpx_ex(); m6809_ICount-= 7; break;
case 0xbd: jsr_ex(); m6809_ICount-= 8; break;
case 0xbe: ldx_ex(); m6809_ICount-= 6; break;
case 0xbf: stx_ex(); m6809_ICount-= 6; break;
case 0xc0: subb_im(); m6809_ICount-= 2; break;
case 0xc1: cmpb_im(); m6809_ICount-= 2; break;
case 0xc2: sbcb_im(); m6809_ICount-= 2; break;
case 0xc3: addd_im(); m6809_ICount-= 4; break;
case 0xc4: andb_im(); m6809_ICount-= 2; break;
case 0xc5: bitb_im(); m6809_ICount-= 2; break;
case 0xc6: ldb_im(); m6809_ICount-= 2; break;
case 0xc7: stb_im(); m6809_ICount-= 2; break;
case 0xc8: eorb_im(); m6809_ICount-= 2; break;
case 0xc9: adcb_im(); m6809_ICount-= 2; break;
case 0xca: orb_im(); m6809_ICount-= 2; break;
case 0xcb: addb_im(); m6809_ICount-= 2; break;
case 0xcc: ldd_im(); m6809_ICount-= 3; break;
case 0xcd: std_im(); m6809_ICount-= 2; break;
case 0xce: ldu_im(); m6809_ICount-= 3; break;
case 0xcf: stu_im(); m6809_ICount-= 3; break;
case 0xd0: subb_di(); m6809_ICount-= 4; break;
case 0xd1: cmpb_di(); m6809_ICount-= 4; break;
case 0xd2: sbcb_di(); m6809_ICount-= 4; break;
case 0xd3: addd_di(); m6809_ICount-= 6; break;
case 0xd4: andb_di(); m6809_ICount-= 4; break;
case 0xd5: bitb_di(); m6809_ICount-= 4; break;
case 0xd6: ldb_di(); m6809_ICount-= 4; break;
case 0xd7: stb_di(); m6809_ICount-= 4; break;
case 0xd8: eorb_di(); m6809_ICount-= 4; break;
case 0xd9: adcb_di(); m6809_ICount-= 4; break;
case 0xda: orb_di(); m6809_ICount-= 4; break;
case 0xdb: addb_di(); m6809_ICount-= 4; break;
case 0xdc: ldd_di(); m6809_ICount-= 5; break;
case 0xdd: std_di(); m6809_ICount-= 5; break;
case 0xde: ldu_di(); m6809_ICount-= 5; break;
case 0xdf: stu_di(); m6809_ICount-= 5; break;
case 0xe0: subb_ix(); m6809_ICount-= 4; break;
case 0xe1: cmpb_ix(); m6809_ICount-= 4; break;
case 0xe2: sbcb_ix(); m6809_ICount-= 4; break;
case 0xe3: addd_ix(); m6809_ICount-= 6; break;
case 0xe4: andb_ix(); m6809_ICount-= 4; break;
case 0xe5: bitb_ix(); m6809_ICount-= 4; break;
case 0xe6: ldb_ix(); m6809_ICount-= 4; break;
case 0xe7: stb_ix(); m6809_ICount-= 4; break;
case 0xe8: eorb_ix(); m6809_ICount-= 4; break;
case 0xe9: adcb_ix(); m6809_ICount-= 4; break;
case 0xea: orb_ix(); m6809_ICount-= 4; break;
case 0xeb: addb_ix(); m6809_ICount-= 4; break;
case 0xec: ldd_ix(); m6809_ICount-= 5; break;
case 0xed: std_ix(); m6809_ICount-= 5; break;
case 0xee: ldu_ix(); m6809_ICount-= 5; break;
case 0xef: stu_ix(); m6809_ICount-= 5; break;
case 0xf0: subb_ex(); m6809_ICount-= 5; break;
case 0xf1: cmpb_ex(); m6809_ICount-= 5; break;
case 0xf2: sbcb_ex(); m6809_ICount-= 5; break;
case 0xf3: addd_ex(); m6809_ICount-= 7; break;
case 0xf4: andb_ex(); m6809_ICount-= 5; break;
case 0xf5: bitb_ex(); m6809_ICount-= 5; break;
case 0xf6: ldb_ex(); m6809_ICount-= 5; break;
case 0xf7: stb_ex(); m6809_ICount-= 5; break;
case 0xf8: eorb_ex(); m6809_ICount-= 5; break;
case 0xf9: adcb_ex(); m6809_ICount-= 5; break;
case 0xfa: orb_ex(); m6809_ICount-= 5; break;
case 0xfb: addb_ex(); m6809_ICount-= 5; break;
case 0xfc: ldd_ex(); m6809_ICount-= 6; break;
case 0xfd: std_ex(); m6809_ICount-= 6; break;
case 0xfe: ldu_ex(); m6809_ICount-= 6; break;
case 0xff: stu_ex(); m6809_ICount-= 6; break;
}
#else
(*m6809_main[m6809.ireg])();
m6809_ICount -= cycles1[m6809.ireg];
#endif
} while( m6809_ICount > 0 );
m6809_ICount -= m6809.extra_cycles;
m6809.extra_cycles = 0;
}
return cycles - m6809_ICount; /* NS 970908 */
}
M6809_INLINE void fetch_effective_address( void )
{
UINT8 postbyte = ROP_ARG(PCD);
PC++;
switch(postbyte)
{
case 0x00: EA=X; m6809_ICount-=1; break;
case 0x01: EA=X+1; m6809_ICount-=1; break;
case 0x02: EA=X+2; m6809_ICount-=1; break;
case 0x03: EA=X+3; m6809_ICount-=1; break;
case 0x04: EA=X+4; m6809_ICount-=1; break;
case 0x05: EA=X+5; m6809_ICount-=1; break;
case 0x06: EA=X+6; m6809_ICount-=1; break;
case 0x07: EA=X+7; m6809_ICount-=1; break;
case 0x08: EA=X+8; m6809_ICount-=1; break;
case 0x09: EA=X+9; m6809_ICount-=1; break;
case 0x0a: EA=X+10; m6809_ICount-=1; break;
case 0x0b: EA=X+11; m6809_ICount-=1; break;
case 0x0c: EA=X+12; m6809_ICount-=1; break;
case 0x0d: EA=X+13; m6809_ICount-=1; break;
case 0x0e: EA=X+14; m6809_ICount-=1; break;
case 0x0f: EA=X+15; m6809_ICount-=1; break;
case 0x10: EA=X-16; m6809_ICount-=1; break;
case 0x11: EA=X-15; m6809_ICount-=1; break;
case 0x12: EA=X-14; m6809_ICount-=1; break;
case 0x13: EA=X-13; m6809_ICount-=1; break;
case 0x14: EA=X-12; m6809_ICount-=1; break;
case 0x15: EA=X-11; m6809_ICount-=1; break;
case 0x16: EA=X-10; m6809_ICount-=1; break;
case 0x17: EA=X-9; m6809_ICount-=1; break;
case 0x18: EA=X-8; m6809_ICount-=1; break;
case 0x19: EA=X-7; m6809_ICount-=1; break;
case 0x1a: EA=X-6; m6809_ICount-=1; break;
case 0x1b: EA=X-5; m6809_ICount-=1; break;
case 0x1c: EA=X-4; m6809_ICount-=1; break;
case 0x1d: EA=X-3; m6809_ICount-=1; break;
case 0x1e: EA=X-2; m6809_ICount-=1; break;
case 0x1f: EA=X-1; m6809_ICount-=1; break;
case 0x20: EA=Y; m6809_ICount-=1; break;
case 0x21: EA=Y+1; m6809_ICount-=1; break;
case 0x22: EA=Y+2; m6809_ICount-=1; break;
case 0x23: EA=Y+3; m6809_ICount-=1; break;
case 0x24: EA=Y+4; m6809_ICount-=1; break;
case 0x25: EA=Y+5; m6809_ICount-=1; break;
case 0x26: EA=Y+6; m6809_ICount-=1; break;
case 0x27: EA=Y+7; m6809_ICount-=1; break;
case 0x28: EA=Y+8; m6809_ICount-=1; break;
case 0x29: EA=Y+9; m6809_ICount-=1; break;
case 0x2a: EA=Y+10; m6809_ICount-=1; break;
case 0x2b: EA=Y+11; m6809_ICount-=1; break;
case 0x2c: EA=Y+12; m6809_ICount-=1; break;
case 0x2d: EA=Y+13; m6809_ICount-=1; break;
case 0x2e: EA=Y+14; m6809_ICount-=1; break;
case 0x2f: EA=Y+15; m6809_ICount-=1; break;
case 0x30: EA=Y-16; m6809_ICount-=1; break;
case 0x31: EA=Y-15; m6809_ICount-=1; break;
case 0x32: EA=Y-14; m6809_ICount-=1; break;
case 0x33: EA=Y-13; m6809_ICount-=1; break;
case 0x34: EA=Y-12; m6809_ICount-=1; break;
case 0x35: EA=Y-11; m6809_ICount-=1; break;
case 0x36: EA=Y-10; m6809_ICount-=1; break;
case 0x37: EA=Y-9; m6809_ICount-=1; break;
case 0x38: EA=Y-8; m6809_ICount-=1; break;
case 0x39: EA=Y-7; m6809_ICount-=1; break;
case 0x3a: EA=Y-6; m6809_ICount-=1; break;
case 0x3b: EA=Y-5; m6809_ICount-=1; break;
case 0x3c: EA=Y-4; m6809_ICount-=1; break;
case 0x3d: EA=Y-3; m6809_ICount-=1; break;
case 0x3e: EA=Y-2; m6809_ICount-=1; break;
case 0x3f: EA=Y-1; m6809_ICount-=1; break;
case 0x40: EA=U; m6809_ICount-=1; break;
case 0x41: EA=U+1; m6809_ICount-=1; break;
case 0x42: EA=U+2; m6809_ICount-=1; break;
case 0x43: EA=U+3; m6809_ICount-=1; break;
case 0x44: EA=U+4; m6809_ICount-=1; break;
case 0x45: EA=U+5; m6809_ICount-=1; break;
case 0x46: EA=U+6; m6809_ICount-=1; break;
case 0x47: EA=U+7; m6809_ICount-=1; break;
case 0x48: EA=U+8; m6809_ICount-=1; break;
case 0x49: EA=U+9; m6809_ICount-=1; break;
case 0x4a: EA=U+10; m6809_ICount-=1; break;
case 0x4b: EA=U+11; m6809_ICount-=1; break;
case 0x4c: EA=U+12; m6809_ICount-=1; break;
case 0x4d: EA=U+13; m6809_ICount-=1; break;
case 0x4e: EA=U+14; m6809_ICount-=1; break;
case 0x4f: EA=U+15; m6809_ICount-=1; break;
case 0x50: EA=U-16; m6809_ICount-=1; break;
case 0x51: EA=U-15; m6809_ICount-=1; break;
case 0x52: EA=U-14; m6809_ICount-=1; break;
case 0x53: EA=U-13; m6809_ICount-=1; break;
case 0x54: EA=U-12; m6809_ICount-=1; break;
case 0x55: EA=U-11; m6809_ICount-=1; break;
case 0x56: EA=U-10; m6809_ICount-=1; break;
case 0x57: EA=U-9; m6809_ICount-=1; break;
case 0x58: EA=U-8; m6809_ICount-=1; break;
case 0x59: EA=U-7; m6809_ICount-=1; break;
case 0x5a: EA=U-6; m6809_ICount-=1; break;
case 0x5b: EA=U-5; m6809_ICount-=1; break;
case 0x5c: EA=U-4; m6809_ICount-=1; break;
case 0x5d: EA=U-3; m6809_ICount-=1; break;
case 0x5e: EA=U-2; m6809_ICount-=1; break;
case 0x5f: EA=U-1; m6809_ICount-=1; break;
case 0x60: EA=S; m6809_ICount-=1; break;
case 0x61: EA=S+1; m6809_ICount-=1; break;
case 0x62: EA=S+2; m6809_ICount-=1; break;
case 0x63: EA=S+3; m6809_ICount-=1; break;
case 0x64: EA=S+4; m6809_ICount-=1; break;
case 0x65: EA=S+5; m6809_ICount-=1; break;
case 0x66: EA=S+6; m6809_ICount-=1; break;
case 0x67: EA=S+7; m6809_ICount-=1; break;
case 0x68: EA=S+8; m6809_ICount-=1; break;
case 0x69: EA=S+9; m6809_ICount-=1; break;
case 0x6a: EA=S+10; m6809_ICount-=1; break;
case 0x6b: EA=S+11; m6809_ICount-=1; break;
case 0x6c: EA=S+12; m6809_ICount-=1; break;
case 0x6d: EA=S+13; m6809_ICount-=1; break;
case 0x6e: EA=S+14; m6809_ICount-=1; break;
case 0x6f: EA=S+15; m6809_ICount-=1; break;
case 0x70: EA=S-16; m6809_ICount-=1; break;
case 0x71: EA=S-15; m6809_ICount-=1; break;
case 0x72: EA=S-14; m6809_ICount-=1; break;
case 0x73: EA=S-13; m6809_ICount-=1; break;
case 0x74: EA=S-12; m6809_ICount-=1; break;
case 0x75: EA=S-11; m6809_ICount-=1; break;
case 0x76: EA=S-10; m6809_ICount-=1; break;
case 0x77: EA=S-9; m6809_ICount-=1; break;
case 0x78: EA=S-8; m6809_ICount-=1; break;
case 0x79: EA=S-7; m6809_ICount-=1; break;
case 0x7a: EA=S-6; m6809_ICount-=1; break;
case 0x7b: EA=S-5; m6809_ICount-=1; break;
case 0x7c: EA=S-4; m6809_ICount-=1; break;
case 0x7d: EA=S-3; m6809_ICount-=1; break;
case 0x7e: EA=S-2; m6809_ICount-=1; break;
case 0x7f: EA=S-1; m6809_ICount-=1; break;
case 0x80: EA=X; X++; m6809_ICount-=2; break;
case 0x81: EA=X; X+=2; m6809_ICount-=3; break;
case 0x82: X--; EA=X; m6809_ICount-=2; break;
case 0x83: X-=2; EA=X; m6809_ICount-=3; break;
case 0x84: EA=X; break;
case 0x85: EA=X+SIGNED(B); m6809_ICount-=1; break;
case 0x86: EA=X+SIGNED(A); m6809_ICount-=1; break;
case 0x87: EA=0; break; /* ILLEGAL*/
case 0x88: IMMBYTE(EA); EA=X+SIGNED(EA); m6809_ICount-=1; break; /* this is a hack to make Vectrex work. It should be m6809_ICount-=1. Dunno where the cycle was lost :( */
case 0x89: IMMWORD(ea); EA+=X; m6809_ICount-=4; break;
case 0x8a: EA=0; break; /* ILLEGAL*/
case 0x8b: EA=X+D; m6809_ICount-=4; break;
case 0x8c: IMMBYTE(EA); EA=PC+SIGNED(EA); m6809_ICount-=1; break;
case 0x8d: IMMWORD(ea); EA+=PC; m6809_ICount-=5; break;
case 0x8e: EA=0; break; /* ILLEGAL*/
case 0x8f: IMMWORD(ea); m6809_ICount-=5; break;
case 0x90: EA=X; X++; EAD=RM16(EAD); m6809_ICount-=5; break; /* Indirect ,R+ not in my specs */
case 0x91: EA=X; X+=2; EAD=RM16(EAD); m6809_ICount-=6; break;
case 0x92: X--; EA=X; EAD=RM16(EAD); m6809_ICount-=5; break;
case 0x93: X-=2; EA=X; EAD=RM16(EAD); m6809_ICount-=6; break;
case 0x94: EA=X; EAD=RM16(EAD); m6809_ICount-=3; break;
case 0x95: EA=X+SIGNED(B); EAD=RM16(EAD); m6809_ICount-=4; break;
case 0x96: EA=X+SIGNED(A); EAD=RM16(EAD); m6809_ICount-=4; break;
case 0x97: EA=0; break; /* ILLEGAL*/
case 0x98: IMMBYTE(EA); EA=X+SIGNED(EA); EAD=RM16(EAD); m6809_ICount-=4; break;
case 0x99: IMMWORD(ea); EA+=X; EAD=RM16(EAD); m6809_ICount-=7; break;
case 0x9a: EA=0; break; /* ILLEGAL*/
case 0x9b: EA=X+D; EAD=RM16(EAD); m6809_ICount-=7; break;
case 0x9c: IMMBYTE(EA); EA=PC+SIGNED(EA); EAD=RM16(EAD); m6809_ICount-=4; break;
case 0x9d: IMMWORD(ea); EA+=PC; EAD=RM16(EAD); m6809_ICount-=8; break;
case 0x9e: EA=0; break; /* ILLEGAL*/
case 0x9f: IMMWORD(ea); EAD=RM16(EAD); m6809_ICount-=8; break;
case 0xa0: EA=Y; Y++; m6809_ICount-=2; break;
case 0xa1: EA=Y; Y+=2; m6809_ICount-=3; break;
case 0xa2: Y--; EA=Y; m6809_ICount-=2; break;
case 0xa3: Y-=2; EA=Y; m6809_ICount-=3; break;
case 0xa4: EA=Y; break;
case 0xa5: EA=Y+SIGNED(B); m6809_ICount-=1; break;
case 0xa6: EA=Y+SIGNED(A); m6809_ICount-=1; break;
case 0xa7: EA=0; break; /* ILLEGAL*/
case 0xa8: IMMBYTE(EA); EA=Y+SIGNED(EA); m6809_ICount-=1; break;
case 0xa9: IMMWORD(ea); EA+=Y; m6809_ICount-=4; break;
case 0xaa: EA=0; break; /* ILLEGAL*/
case 0xab: EA=Y+D; m6809_ICount-=4; break;
case 0xac: IMMBYTE(EA); EA=PC+SIGNED(EA); m6809_ICount-=1; break;
case 0xad: IMMWORD(ea); EA+=PC; m6809_ICount-=5; break;
case 0xae: EA=0; break; /* ILLEGAL*/
case 0xaf: IMMWORD(ea); m6809_ICount-=5; break;
case 0xb0: EA=Y; Y++; EAD=RM16(EAD); m6809_ICount-=5; break;
case 0xb1: EA=Y; Y+=2; EAD=RM16(EAD); m6809_ICount-=6; break;
case 0xb2: Y--; EA=Y; EAD=RM16(EAD); m6809_ICount-=5; break;
case 0xb3: Y-=2; EA=Y; EAD=RM16(EAD); m6809_ICount-=6; break;
case 0xb4: EA=Y; EAD=RM16(EAD); m6809_ICount-=3; break;
case 0xb5: EA=Y+SIGNED(B); EAD=RM16(EAD); m6809_ICount-=4; break;
case 0xb6: EA=Y+SIGNED(A); EAD=RM16(EAD); m6809_ICount-=4; break;
case 0xb7: EA=0; break; /* ILLEGAL*/
case 0xb8: IMMBYTE(EA); EA=Y+SIGNED(EA); EAD=RM16(EAD); m6809_ICount-=4; break;
case 0xb9: IMMWORD(ea); EA+=Y; EAD=RM16(EAD); m6809_ICount-=7; break;
case 0xba: EA=0; break; /* ILLEGAL*/
case 0xbb: EA=Y+D; EAD=RM16(EAD); m6809_ICount-=7; break;
case 0xbc: IMMBYTE(EA); EA=PC+SIGNED(EA); EAD=RM16(EAD); m6809_ICount-=4; break;
case 0xbd: IMMWORD(ea); EA+=PC; EAD=RM16(EAD); m6809_ICount-=8; break;
case 0xbe: EA=0; break; /* ILLEGAL*/
case 0xbf: IMMWORD(ea); EAD=RM16(EAD); m6809_ICount-=8; break;
case 0xc0: EA=U; U++; m6809_ICount-=2; break;
case 0xc1: EA=U; U+=2; m6809_ICount-=3; break;
case 0xc2: U--; EA=U; m6809_ICount-=2; break;
case 0xc3: U-=2; EA=U; m6809_ICount-=3; break;
case 0xc4: EA=U; break;
case 0xc5: EA=U+SIGNED(B); m6809_ICount-=1; break;
case 0xc6: EA=U+SIGNED(A); m6809_ICount-=1; break;
case 0xc7: EA=0; break; /*ILLEGAL*/
case 0xc8: IMMBYTE(EA); EA=U+SIGNED(EA); m6809_ICount-=1; break;
case 0xc9: IMMWORD(ea); EA+=U; m6809_ICount-=4; break;
case 0xca: EA=0; break; /*ILLEGAL*/
case 0xcb: EA=U+D; m6809_ICount-=4; break;
case 0xcc: IMMBYTE(EA); EA=PC+SIGNED(EA); m6809_ICount-=1; break;
case 0xcd: IMMWORD(ea); EA+=PC; m6809_ICount-=5; break;
case 0xce: EA=0; break; /*ILLEGAL*/
case 0xcf: IMMWORD(ea); m6809_ICount-=5; break;
case 0xd0: EA=U; U++; EAD=RM16(EAD); m6809_ICount-=5; break;
case 0xd1: EA=U; U+=2; EAD=RM16(EAD); m6809_ICount-=6; break;
case 0xd2: U--; EA=U; EAD=RM16(EAD); m6809_ICount-=5; break;
case 0xd3: U-=2; EA=U; EAD=RM16(EAD); m6809_ICount-=6; break;
case 0xd4: EA=U; EAD=RM16(EAD); m6809_ICount-=3; break;
case 0xd5: EA=U+SIGNED(B); EAD=RM16(EAD); m6809_ICount-=4; break;
case 0xd6: EA=U+SIGNED(A); EAD=RM16(EAD); m6809_ICount-=4; break;
case 0xd7: EA=0; break; /*ILLEGAL*/
case 0xd8: IMMBYTE(EA); EA=U+SIGNED(EA); EAD=RM16(EAD); m6809_ICount-=4; break;
case 0xd9: IMMWORD(ea); EA+=U; EAD=RM16(EAD); m6809_ICount-=7; break;
case 0xda: EA=0; break; /*ILLEGAL*/
case 0xdb: EA=U+D; EAD=RM16(EAD); m6809_ICount-=7; break;
case 0xdc: IMMBYTE(EA); EA=PC+SIGNED(EA); EAD=RM16(EAD); m6809_ICount-=4; break;
case 0xdd: IMMWORD(ea); EA+=PC; EAD=RM16(EAD); m6809_ICount-=8; break;
case 0xde: EA=0; break; /*ILLEGAL*/
case 0xdf: IMMWORD(ea); EAD=RM16(EAD); m6809_ICount-=8; break;
case 0xe0: EA=S; S++; m6809_ICount-=2; break;
case 0xe1: EA=S; S+=2; m6809_ICount-=3; break;
case 0xe2: S--; EA=S; m6809_ICount-=2; break;
case 0xe3: S-=2; EA=S; m6809_ICount-=3; break;
case 0xe4: EA=S; break;
case 0xe5: EA=S+SIGNED(B); m6809_ICount-=1; break;
case 0xe6: EA=S+SIGNED(A); m6809_ICount-=1; break;
case 0xe7: EA=0; break; /*ILLEGAL*/
case 0xe8: IMMBYTE(EA); EA=S+SIGNED(EA); m6809_ICount-=1; break;
case 0xe9: IMMWORD(ea); EA+=S; m6809_ICount-=4; break;
case 0xea: EA=0; break; /*ILLEGAL*/
case 0xeb: EA=S+D; m6809_ICount-=4; break;
case 0xec: IMMBYTE(EA); EA=PC+SIGNED(EA); m6809_ICount-=1; break;
case 0xed: IMMWORD(ea); EA+=PC; m6809_ICount-=5; break;
case 0xee: EA=0; break; /*ILLEGAL*/
case 0xef: IMMWORD(ea); m6809_ICount-=5; break;
case 0xf0: EA=S; S++; EAD=RM16(EAD); m6809_ICount-=5; break;
case 0xf1: EA=S; S+=2; EAD=RM16(EAD); m6809_ICount-=6; break;
case 0xf2: S--; EA=S; EAD=RM16(EAD); m6809_ICount-=5; break;
case 0xf3: S-=2; EA=S; EAD=RM16(EAD); m6809_ICount-=6; break;
case 0xf4: EA=S; EAD=RM16(EAD); m6809_ICount-=3; break;
case 0xf5: EA=S+SIGNED(B); EAD=RM16(EAD); m6809_ICount-=4; break;
case 0xf6: EA=S+SIGNED(A); EAD=RM16(EAD); m6809_ICount-=4; break;
case 0xf7: EA=0; break; /*ILLEGAL*/
case 0xf8: IMMBYTE(EA); EA=S+SIGNED(EA); EAD=RM16(EAD); m6809_ICount-=4; break;
case 0xf9: IMMWORD(ea); EA+=S; EAD=RM16(EAD); m6809_ICount-=7; break;
case 0xfa: EA=0; break; /*ILLEGAL*/
case 0xfb: EA=S+D; EAD=RM16(EAD); m6809_ICount-=7; break;
case 0xfc: IMMBYTE(EA); EA=PC+SIGNED(EA); EAD=RM16(EAD); m6809_ICount-=4; break;
case 0xfd: IMMWORD(ea); EA+=PC; EAD=RM16(EAD); m6809_ICount-=8; break;
case 0xfe: EA=0; break; /*ILLEGAL*/
case 0xff: IMMWORD(ea); EAD=RM16(EAD); m6809_ICount-=8; break;
}
}
#if 0
/**************************************************************************
* Generic set_info
**************************************************************************/
static void m6809_set_info(UINT32 state, cpuinfo *info)
{
switch (state)
{
/* --- the following bits of info are set as 64-bit signed integers --- */
case CPUINFO_INT_INPUT_STATE + M6809_IRQ_LINE: set_irq_line(M6809_IRQ_LINE, info->i); break;
case CPUINFO_INT_INPUT_STATE + M6809_FIRQ_LINE: set_irq_line(M6809_FIRQ_LINE, info->i); break;
case CPUINFO_INT_INPUT_STATE + M6809_INPUT_LINE_NMI: set_irq_line(M6809_INPUT_LINE_NMI, info->i); break;
case CPUINFO_INT_PC:
case CPUINFO_INT_REGISTER + M6809_PC: PC = info->i; CHANGE_PC; break;
case CPUINFO_INT_SP:
case CPUINFO_INT_REGISTER + M6809_S: S = info->i; break;
case CPUINFO_INT_REGISTER + M6809_CC: CC = info->i; CHECK_IRQ_LINES; break;
case CPUINFO_INT_REGISTER + M6809_U: U = info->i; break;
case CPUINFO_INT_REGISTER + M6809_A: A = info->i; break;
case CPUINFO_INT_REGISTER + M6809_B: B = info->i; break;
case CPUINFO_INT_REGISTER + M6809_X: X = info->i; break;
case CPUINFO_INT_REGISTER + M6809_Y: Y = info->i; break;
case CPUINFO_INT_REGISTER + M6809_DP: DP = info->i; break;
}
}
/**************************************************************************
* Generic get_info
**************************************************************************/
void m6809_get_info(UINT32 state, cpuinfo *info)
{
switch (state)
{
/* --- the following bits of info are returned as 64-bit signed integers --- */
case CPUINFO_INT_CONTEXT_SIZE: info->i = sizeof(m6809); break;
case CPUINFO_INT_INPUT_LINES: info->i = 2; break;
case CPUINFO_INT_DEFAULT_IRQ_VECTOR: info->i = 0; break;
case CPUINFO_INT_ENDIANNESS: info->i = CPU_IS_BE; break;
case CPUINFO_INT_CLOCK_MULTIPLIER: info->i = 1; break;
case CPUINFO_INT_CLOCK_DIVIDER: info->i = 1; break;
case CPUINFO_INT_MIN_INSTRUCTION_BYTES: info->i = 1; break;
case CPUINFO_INT_MAX_INSTRUCTION_BYTES: info->i = 5; break;
case CPUINFO_INT_MIN_CYCLES: info->i = 2; break;
case CPUINFO_INT_MAX_CYCLES: info->i = 19; break;
case CPUINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_PROGRAM: info->i = 8; break;
case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_PROGRAM: info->i = 16; break;
case CPUINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACE_PROGRAM: info->i = 0; break;
case CPUINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_DATA: info->i = 0; break;
case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_DATA: info->i = 0; break;
case CPUINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACE_DATA: info->i = 0; break;
case CPUINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_IO: info->i = 0; break;
case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_IO: info->i = 0; break;
case CPUINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACE_IO: info->i = 0; break;
case CPUINFO_INT_INPUT_STATE + M6809_IRQ_LINE: info->i = m6809.irq_state[M6809_IRQ_LINE]; break;
case CPUINFO_INT_INPUT_STATE + M6809_FIRQ_LINE: info->i = m6809.irq_state[M6809_FIRQ_LINE]; break;
case CPUINFO_INT_INPUT_STATE + M6809_INPUT_LINE_NMI: info->i = m6809.nmi_state; break;
case CPUINFO_INT_PREVIOUSPC: info->i = PPC; break;
case CPUINFO_INT_PC:
case CPUINFO_INT_REGISTER + M6809_PC: info->i = PC; break;
case CPUINFO_INT_SP:
case CPUINFO_INT_REGISTER + M6809_S: info->i = S; break;
case CPUINFO_INT_REGISTER + M6809_CC: info->i = CC; break;
case CPUINFO_INT_REGISTER + M6809_U: info->i = U; break;
case CPUINFO_INT_REGISTER + M6809_A: info->i = A; break;
case CPUINFO_INT_REGISTER + M6809_B: info->i = B; break;
case CPUINFO_INT_REGISTER + M6809_X: info->i = X; break;
case CPUINFO_INT_REGISTER + M6809_Y: info->i = Y; break;
case CPUINFO_INT_REGISTER + M6809_DP: info->i = DP; break;
/* --- the following bits of info are returned as pointers to data or functions --- */
case CPUINFO_PTR_SET_INFO: info->setinfo = m6809_set_info; break;
case CPUINFO_PTR_GET_CONTEXT: info->getcontext = m6809_get_context; break;
case CPUINFO_PTR_SET_CONTEXT: info->setcontext = m6809_set_context; break;
case CPUINFO_PTR_INIT: info->init = m6809_init; break;
case CPUINFO_PTR_RESET: info->reset = m6809_reset; break;
case CPUINFO_PTR_EXIT: info->exit = m6809_exit; break;
case CPUINFO_PTR_EXECUTE: info->execute = m6809_execute; break;
case CPUINFO_PTR_BURN: info->burn = NULL; break;
case CPUINFO_PTR_DISASSEMBLE: info->disassemble = m6809_dasm; break;
case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &m6809_ICount; break;
/* --- the following bits of info are returned as NULL-terminated strings --- */
case CPUINFO_STR_NAME: strcpy(info->s, "M6809"); break;
case CPUINFO_STR_CORE_FAMILY: strcpy(info->s, "Motorola 6809"); break;
case CPUINFO_STR_CORE_VERSION: strcpy(info->s, "1.11"); break;
case CPUINFO_STR_CORE_FILE: strcpy(info->s, __FILE__); break;
case CPUINFO_STR_CORE_CREDITS: strcpy(info->s, "Copyright John Butler"); break;
case CPUINFO_STR_FLAGS:
sprintf(info->s, "%c%c%c%c%c%c%c%c",
m6809.cc & 0x80 ? 'E':'.',
m6809.cc & 0x40 ? 'F':'.',
m6809.cc & 0x20 ? 'H':'.',
m6809.cc & 0x10 ? 'I':'.',
m6809.cc & 0x08 ? 'N':'.',
m6809.cc & 0x04 ? 'Z':'.',
m6809.cc & 0x02 ? 'V':'.',
m6809.cc & 0x01 ? 'C':'.');
break;
case CPUINFO_STR_REGISTER + M6809_PC: sprintf(info->s, "PC:%04X", m6809.pc.w.l); break;
case CPUINFO_STR_REGISTER + M6809_S: sprintf(info->s, "S:%04X", m6809.s.w.l); break;
case CPUINFO_STR_REGISTER + M6809_CC: sprintf(info->s, "CC:%02X", m6809.cc); break;
case CPUINFO_STR_REGISTER + M6809_U: sprintf(info->s, "U:%04X", m6809.u.w.l); break;
case CPUINFO_STR_REGISTER + M6809_A: sprintf(info->s, "A:%02X", m6809.d.b.h); break;
case CPUINFO_STR_REGISTER + M6809_B: sprintf(info->s, "B:%02X", m6809.d.b.l); break;
case CPUINFO_STR_REGISTER + M6809_X: sprintf(info->s, "X:%04X", m6809.x.w.l); break;
case CPUINFO_STR_REGISTER + M6809_Y: sprintf(info->s, "Y:%04X", m6809.y.w.l); break;
case CPUINFO_STR_REGISTER + M6809_DP: sprintf(info->s, "DP:%02X", m6809.dp.b.h); break;
}
}
/**************************************************************************
* CPU-specific set_info
**************************************************************************/
void m6809e_get_info(UINT32 state, cpuinfo *info)
{
switch (state)
{
/* --- the following bits of info are returned as 64-bit signed integers --- */
case CPUINFO_INT_CLOCK_MULTIPLIER: info->i = 1; break;
case CPUINFO_INT_CLOCK_DIVIDER: info->i = 4; break;
/* --- the following bits of info are returned as NULL-terminated strings --- */
case CPUINFO_STR_NAME: strcpy(info->s, "M6809E"); break;
default: m6809_get_info(state, info); break;
}
}
#endif
| [
"[email protected]"
]
| [
[
[
1,
1217
]
]
]
|
c64f5e7def45bdd2e60c2cbffe94118bb38c76d3 | c2153dcfa8bcf5b6d7f187e5a337b904ad9f91ac | /depends/ClanLib/src/API/Core/XML/dom_text.h | 0b178837f2b6fae98cd46d534fb10743d6171461 | []
| no_license | ptrefall/smn6200fluidmechanics | 841541a26023f72aa53d214fe4787ed7f5db88e1 | 77e5f919982116a6cdee59f58ca929313dfbb3f7 | refs/heads/master | 2020-08-09T17:03:59.726027 | 2011-01-13T22:39:03 | 2011-01-13T22:39:03 | 32,448,422 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,797 | h | /*
** ClanLib SDK
** Copyright (c) 1997-2010 The ClanLib Team
**
** This software is provided 'as-is', without any express or implied
** warranty. In no event will the authors be held liable for any damages
** arising from the use of this software.
**
** Permission is granted to anyone to use this software for any purpose,
** including commercial applications, and to alter it and redistribute it
** freely, subject to the following restrictions:
**
** 1. The origin of this software must not be misrepresented; you must not
** claim that you wrote the original software. If you use this software
** in a product, an acknowledgment in the product documentation would be
** appreciated but is not required.
** 2. Altered source versions must be plainly marked as such, and must not be
** misrepresented as being the original software.
** 3. This notice may not be removed or altered from any source distribution.
**
** Note: Some of the libraries ClanLib may link to may have additional
** requirements or restrictions.
**
** File Author(s):
**
** Magnus Norddahl
*/
/// \addtogroup clanCore_XML clanCore XML
/// \{
#pragma once
#include "../api_core.h"
#include "dom_character_data.h"
/// \brief DOM Text class.
///
/// <p>The Text interface represents the textual content (termed character data
/// in XML) of an Element or Attr. If there is no markup inside an element's content,
/// the text is contained in a single object implementing the Text interface that is
/// the only child of the element. If there is markup, it is parsed into a list of
/// elements and Text nodes that form the list of children of the element.</p>
/// <p>When a document is first made available via the DOM, there is only one Text
/// node for each block of text. Users may create adjacent Text nodes that represent
/// the contents of a given element without any intervening markup, but should be aware
/// that there is no way to represent the separations between these nodes in XML or HTML,
/// so they will not (in general) persist between DOM editing sessions. The normalize()
/// method on Element merges any such adjacent Text objects into a single node for each
/// block of text; this is recommended before employing operations that depend on a
/// particular document structure, such as navigation with XPointers.</p>
/// \xmlonly !group=Core/XML! !header=core.h! \endxmlonly
class CL_API_CORE CL_DomText : public CL_DomCharacterData
{
/// \name Construction
/// \{
public:
/// \brief Constructs a DOM Text handle.
CL_DomText();
/// \brief Constructs a DomText
///
/// \param doc = Dom Document
/// \param data = Dom String
CL_DomText(CL_DomDocument &doc, const CL_DomString &data);
/// \brief Constructs a DomText
///
/// \param impl = Shared Ptr
CL_DomText(const CL_SharedPtr<CL_DomNode_Generic> &impl);
~CL_DomText();
/// \}
/// \name Attributes
/// \{
public:
/// \}
/// \name Operations
/// \{
public:
/// \brief Breaks this Text node into two Text nodes at the specified offset, keeping both in the tree as siblings.
/** <p>node then only contains all the content up to the offset point. And a new Text node, which
is inserted as the next sibling of this node, contains all the content at and after the offset
point.</p>
\param offset The offset at which to split.
retval: The new Text node.*/
CL_DomText split_text(unsigned long offset);
/// \}
/// \name Implementation
/// \{
protected:
/// \brief Constructs a DomText
///
/// \param doc = Dom Document
/// \param node_type = short
CL_DomText(CL_DomDocument &doc, unsigned short node_type);
/// \}
};
/// \}
| [
"[email protected]@c628178a-a759-096a-d0f3-7c7507b30227"
]
| [
[
[
1,
108
]
]
]
|
f07136db4a36eb8aa3273a1088e3bba26af77e14 | 6e4f9952ef7a3a47330a707aa993247afde65597 | /PROJECTS_ROOT/SmartWires/SystemUtils/InternetUtils.h | 0dab0d8c881088194a00684e2b2493ebfa559269 | []
| no_license | meiercn/wiredplane-wintools | b35422570e2c4b486c3aa6e73200ea7035e9b232 | 134db644e4271079d631776cffcedc51b5456442 | refs/heads/master | 2021-01-19T07:50:42.622687 | 2009-07-07T03:34:11 | 2009-07-07T03:34:11 | 34,017,037 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,251 | h | // SupportClasses.h: interface for the SupportClasses class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_InternetUtils_H)
#define AFX_InternetUtils_H
//#include <wininet.h>
#ifndef DWORD_PTR
#define DWORD_PTR DWORD
#endif
typedef LPVOID HINTERNET;
#define FLAG_ICC_FORCE_CONNECTION 0x00000001
typedef BOOL (WINAPI * _HttpQueryInfoA)(HINTERNET,DWORD,LPVOID,LPDWORD,LPDWORD);
typedef HINTERNET (WINAPI * _InternetOpenA)(LPCSTR,DWORD,LPCSTR,LPCSTR,DWORD);
typedef HINTERNET (WINAPI * _InternetOpenUrlA)(HINTERNET,LPCSTR,LPCSTR,DWORD,DWORD,DWORD);
typedef BOOL (WINAPI * _InternetCloseHandle)(HINTERNET);
typedef BOOL (WINAPI * _InternetReadFile)(HINTERNET,LPVOID,DWORD,LPDWORD);
typedef BOOL (WINAPI * _InternetCheckConnectionA)(LPCSTR,DWORD,DWORD);
typedef DWORD (WINAPI * _InternetDialA)(IN HWND hwndParent,IN LPSTR lpszConnectoid,IN DWORD dwFlags,OUT DWORD_PTR *lpdwConnection,IN DWORD dwReserved);
typedef BOOL (WINAPI * _InternetSetOptionA)(IN HINTERNET hInternet OPTIONAL,IN DWORD dwOption,IN LPVOID lpBuffer,IN DWORD dwBufferLength);
class CWebWorld
{
public:
static CString sProxyURL;
static long lProxyPort;
static CString sProxyUser;
static CString sProxyPsw;
BOOL bOnlyCheckConnection;
HINSTANCE hWininet;
CString GetErrorMessage();
void SetErrorMessage(CString s);
CString GetWebPage(const CString& Url);
BOOL GetWebFile(const CString Url, CString sOutFileName, DWORD* dwStatusCode=0);
BOOL TestWebPage(const CString& Url, DWORD dwTimeout, CString* sUrlError=0);
CWebWorld();
virtual ~CWebWorld();
BOOL CheckConnection(LPCSTR lpszUrl, DWORD dwFlags, DWORD dwReserved);
_InternetDialA InternetDial;
_HttpQueryInfoA HttpQueryInfo;
_InternetOpenA InternetOpen;
_InternetOpenUrlA InternetOpenUrl;
_InternetCloseHandle InternetCloseHandle;
_InternetSetOptionA InternetSetOption;
_InternetReadFile InternetReadFile;
_InternetCheckConnectionA InternetCheckConnection;
static void SetProxyInfo(HINTERNET hIn=0);
static const char* GetProxyLine();
private:
CString m_ErrorMessage;
HINTERNET m_Session;
};
#endif // !defined(AFX_SUPPORTCLASSES_H__FEA8409A_05E1_47E0_A213_EFD97DD01639__INCLUDED_)
| [
"wplabs@3fb49600-69e0-11de-a8c1-9da277d31688"
]
| [
[
[
1,
55
]
]
]
|
aac3a685cd3819f48d29f7f8379e73acdcaa4f3d | 91b964984762870246a2a71cb32187eb9e85d74e | /SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/multi_index/test/test_capacity.hpp | f02db35b84e73110daa7ca2f5f6af3d1c1c78180 | [
"BSL-1.0",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | willrebuild/flyffsf | e5911fb412221e00a20a6867fd00c55afca593c7 | d38cc11790480d617b38bb5fc50729d676aef80d | refs/heads/master | 2021-01-19T20:27:35.200154 | 2011-02-10T12:34:43 | 2011-02-10T12:34:43 | 32,710,780 | 3 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 364 | hpp | /* Boost.MultiIndex test for capacity memfuns.
*
* Copyright 2003-2004 Joaquín M López Muñoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/multi_index for library home page.
*/
void test_capacity();
| [
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
]
| [
[
[
1,
11
]
]
]
|
9655ae9cd4b4032e26d0cf49a4fe18664dfdcb21 | e7c45d18fa1e4285e5227e5984e07c47f8867d1d | /Scada/scOPCsrv/OPCSrvr/SrvMngr.h | 875f4767e575191b4e0658a5b9c2ec05095b079f | []
| no_license | abcweizhuo/Test3 | 0f3379e528a543c0d43aad09489b2444a2e0f86d | 128a4edcf9a93d36a45e5585b70dee75e4502db4 | refs/heads/master | 2021-01-17T01:59:39.357645 | 2008-08-20T00:00:29 | 2008-08-20T00:00:29 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,258 | h | //================== SysCAD - Copyright Kenwalt (Pty) Ltd ===================
// $Nokeywords: $
//===========================================================================
#ifndef __SRVMNGR_H
#define __SRVMNGR_H
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#ifndef __SCDVER_H
#include "scdver.h"
#endif
#if WITHOPC
#ifndef __COMMSSRVRBASE_H
#include "CommsSrvrBase.h"
#endif
//--------------------------------------------------------------------------
class CScdOPCCallBack; //derived from CExecObj
class COPCSrvrStatsDlg;
class CScdOPCManager : public CCommsServerManagerBase
{
friend class COPCSrvrStatsDlg;
friend class COPCSrvrOptionsDlg;
friend class CScdOPCCallBack;
public:
static bool sm_bInitOK;
static CScdOPCManager* sm_pTheMngr;
static bool Init(LPCTSTR ExeFile, bool ResetReg, int Server=0);
static bool Stop();
public:
CScdOPCManager(CScdOPCCallBack* pCB);
virtual ~CScdOPCManager();
virtual char* Name() { return "OPC"; };
virtual void LoadOrSaveOptions(CProfINIFile & PF, bool Loading);
virtual bool ServerOK() { return pTheCB!=NULL; };
virtual bool OpenStatusWnd();
virtual bool IsStatusWndOpen() { return (pTheOPCStatsDlg!=NULL); };
virtual bool CloseStatusWnd();
virtual void UpdateStatusWnd(WPARAM wParam=0, LPARAM lParam=0);
virtual bool AllowInvalidTags() { return m_bAllowInvalidTags; }
virtual bool Enabled() { return m_bEnabled; };
virtual bool SetEnable(bool On);
CScdOPCCallBack* OPCExec() { return pTheCB; };
bool LogNotes() { return bDoLogNotes; };
protected:
CScdOPCCallBack* pTheCB;
COPCSrvrStatsDlg* pTheOPCStatsDlg;
bool bShowStatsOnConnect,
bDoLogNotes,
bForceOnStart,
bForceOnStop;
long iForceCnt;
bool m_bEnabled;
bool m_bAllowInvalidTags;
};
//--------------------------------------------------------------------------
#endif
#endif | [
"[email protected]"
]
| [
[
[
1,
69
]
]
]
|
167feb5a560dbc8958e1355ed1a9a370d2c9ab94 | eda410906c2ec64689d8c0b84f3c2862f469144b | /DropSendCore/utils/singleton.h | 19a51e4a38843e3db84172770537f9125d5d7adc | []
| no_license | redbox/Dropsend | 640ea157a2caec88aa145f5bdc7fa85db95203a5 | 8fe4b4478616b9850b55011a506653026a28f7da | refs/heads/master | 2020-06-02T20:54:18.301786 | 2010-09-06T16:16:05 | 2010-09-06T16:16:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 981 | h | #ifndef SINGLETON_H
#define SINGLETON_H
namespace dropsend {
namespace utils {
/**
* @class Singleton.
* @brief Implementation of singleton design pattern.
**/
template <class T>
class Singleton
{
public:
/**
* @brief Gets class instance.
**/
static T* getInstance() {
if (!instance_) {
instance_ = new T;
}
return instance_;
}
protected:
Singleton();
~Singleton();
private:
Singleton(Singleton const&);
Singleton& operator=(Singleton const&);
static T* instance_;
};
/**
* @brief By default, sets instance's value to 0.
**/
template <class T> T* Singleton<T>::instance_ = 0;
}
}
#endif // SINGLETON_H
| [
"[email protected]"
]
| [
[
[
1,
38
]
]
]
|
ee7932c61cba08041e41c2555c03197d24d2153d | 0c5fd443401312fafae18ea6a9d17bac9ee61474 | /code/engine/Core/USPResource.h | 34307bcd1408ff2487f437bae89fc46cc5d1b9c4 | []
| no_license | nurF/Brute-Force-Game-Engine | fcfebc997d6ab487508a5706b849e9d7bc66792d | b930472429ec6d6f691230e36076cd2c868d853d | refs/heads/master | 2021-01-18T09:29:44.038036 | 2011-12-02T17:31:59 | 2011-12-02T17:31:59 | 2,877,061 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,725 | h | /* ___ _________ ____ __
/ _ )/ __/ ___/____/ __/___ ___ _/_/___ ___
/ _ / _// (_ //___/ _/ / _ | _ `/ // _ | -_)
/____/_/ \___/ /___//_//_|_, /_//_//_|__/
/___/
This file is part of the Brute-Force Game Engine, BFG-Engine
For the latest info, see http://www.brute-force-games.com
Copyright (c) 2011 Brute-Force Games GbR
The BFG-Engine is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
The BFG-Engine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the BFG-Engine. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BFG_RESOURCE_H__
#define BFG_RESOURCE_H__
namespace BFG
{
class ResourceHandle
{
typedef InternalType long long;
public:
ResourceHandle(){}
~ResourceHandle(){}
void * asPtr() const { return (void*) m_Value; }
template class<T> as<T>() const { return (T) m_Value; }
template class<T> asPtr<T>() const { return (T*) m_Value; }
template class<T> void set<T>(T t) { m_Value = t; }
private:
/// need native 8-bytes type
/// our resource-Type
InternalType m_Type;
/// the value of this resourceHandle, normally a pointer
InternalType m_Value;
};
}//namespace
#endif // BFG_RESOURCE_H__
| [
"[email protected]"
]
| [
[
[
1,
58
]
]
]
|
e5fadaf6ec6f8e407ddfe0728a6138ca438ce126 | 94c1c7459eb5b2826e81ad2750019939f334afc8 | /source/ManagerStockType.h | 9e85f35fbfc2e0ce740288f9c2651fbf2b418256 | []
| no_license | wgwang/yinhustock | 1c57275b4bca093e344a430eeef59386e7439d15 | 382ed2c324a0a657ddef269ebfcd84634bd03c3a | refs/heads/master | 2021-01-15T17:07:15.833611 | 2010-11-27T07:06:40 | 2010-11-27T07:06:40 | 37,531,026 | 1 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 1,693 | h |
#if !defined(AFX_MANAGERSTOCKTYPE_H__BD1C43A1_5D50_11D4_8829_00400552E583__INCLUDED_)
#define AFX_MANAGERSTOCKTYPE_H__BD1C43A1_5D50_11D4_8829_00400552E583__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CSuperviseSharesBlock : public CDialog
{
public:
CSuperviseSharesBlock(CWnd* pParent = NULL);
protected:
enum { IDD = IDD_MANAGER_STOCKTYPE };
CButtonST m_ok;
CButtonST m_updatestocktype;
CButtonST m_refreshday;
CButtonST m_refresh;
CButtonST m_managerchoose;
CButtonST m_delete;
CButtonST m_add;
CListCtrl m_MyList;
CProgressCtrl m_Progress;
enum { ZGB = 0, LTG = 1, OTHER = 2 };
CTaiShanDoc* m_pDoc;
CImageList* m_pImageList;
CImageList* m_pImageListSmall;
BOOL m_bIsCalc;
protected:
void FillToListCtrlHead();
void RefreshShowData();
public:
void FillToListCtrlItem(STOCKTYPEINFO* pStockType);
//{{AFX_DATA(CSuperviseSharesBlock)
//}}AFX_DATA
protected:
//{{AFX_VIRTUAL(CSuperviseSharesBlock)
virtual void DoDataExchange(CDataExchange* pDX);
virtual BOOL OnInitDialog();
virtual void OnCancel();
virtual void OnOK();
//}}AFX_VIRTUAL
protected:
afx_msg void OnClose();
afx_msg BOOL OnHelpInfo(HELPINFO* pHelpInfo);
//{{AFX_MSG(CSuperviseSharesBlock)
afx_msg void OnImportStockType();
afx_msg void OnAddStockType();
afx_msg void OnUpdateStockType();
afx_msg void OnManagerChoose();
afx_msg void OnDeletestocktype();
afx_msg void OnRefresh();
afx_msg void OnExport();
afx_msg void OnRefreshDayLine();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#endif // !defined(AFX_MANAGERSTOCKTYPE_H__BD1C43A1_5D50_11D4_8829_00400552E583__INCLUDED_)
| [
"[email protected]"
]
| [
[
[
1,
73
]
]
]
|
29d95834274397c729176f44aced48b944483747 | f1d47cd447044e6d892627119c3361e27ac02102 | /src/Ascens/stl_trie_multiset.h | d45ff51d5685c1bea68daa5ea65c1d8acf6e7bff | []
| no_license | ericalbright/ascens | ec35b0bacad19c60f4892e3497ee618cbcda7497 | b3299e86a9b4b9f3230c525222f8e8ee10ae90ab | refs/heads/master | 2020-06-08T05:23:14.472690 | 2008-05-13T05:52:39 | 2008-05-13T05:52:39 | 32,619,796 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,089 | h | /*
* Copyright (c) 1998-2002
* Eric S. Albright
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Eric S. Albright makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
* The trie_multiset implementation stems from a multiset implementation
* which bears the following copyright notices:
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1996,1997
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/* NOTE: This is an internal header file, included by other STL headers.
* You should not attempt to use it directly.
*/
#pragma once
#ifndef __TRIE_INTERNAL_MULTISET_H
#define __TRIE_INTERNAL_MULTISET_H
//#include <concept_checks.h>
namespace trie {
#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
#pragma set woff 1174
#pragma set woff 1375
#endif
#define TRIE_MULTISET trie_multiset<_Key, _SubKeyType, _KeyIterator, _KeySizeType, _KeyBegin, _KeyEnd, _KeySize, _Compare, _Alloc>
#define TRIE_MULTISET_TEMPLATE template <class _Key, class _SubKeyType, class _KeyIterator, class _KeySizeType, class _KeyBegin, class _KeyEnd, class _KeySize, class _Compare, class _Alloc>
// Forward declarations of operators == and <, needed for friend declarations.
template <class _Key,
class _SubKeyType = _Key::value_type,
class _KeyIterator = _Key::const_iterator,
class _KeySizeType = _Key::size_type,
class _KeyBegin = __container_begin<typename _Key, typename _KeyIterator>,
class _KeyEnd = __container_end<typename _Key, typename _KeyIterator>,
class _KeySize = __container_size<typename _Key, typename _KeySizeType>,
class _Compare =std::less<typename _SubKeyType>,
class _Alloc = std::allocator<_Key> >
class trie_multiset;
TRIE_MULTISET_TEMPLATE
inline bool operator==(const TRIE_MULTISET& __x,
const TRIE_MULTISET& __y);
TRIE_MULTISET_TEMPLATE
inline bool operator<(const TRIE_MULTISET& __x,
const TRIE_MULTISET& __y);
TRIE_MULTISET_TEMPLATE
class trie_multiset {
// requirements:
// __STL_CLASS_REQUIRES(_Key, _Assignable);
// __STL_CLASS_BINARY_FUNCTION_CHECK(_Compare, bool, _Key, _Key);
public:
// typedefs:
typedef _Key key_type;
typedef _Key value_type;
typedef _Compare key_compare;
typedef _Compare value_compare;
typedef _KeyIterator key_iterator;
typedef _KeySizeType key_size_type;
typedef _KeyBegin key_begin;
typedef _KeyEnd key_end;
typedef _KeySize key_size;
typedef _SubKeyType sub_key_type;
private:
typedef _b_trie<key_type, value_type, sub_key_type, _Identity<value_type>,
key_iterator, key_size_type, key_begin, key_end, key_size,
key_compare,
_Alloc> rep_type;
rep_type t; // binary trie representing multiset
public:
typedef typename rep_type::const_pointer pointer;
typedef typename rep_type::const_pointer const_pointer;
typedef typename rep_type::const_reference reference;
typedef typename rep_type::const_reference const_reference;
typedef typename rep_type::const_iterator iterator;
typedef typename rep_type::const_iterator const_iterator;
typedef typename rep_type::const_reverse_iterator reverse_iterator;
typedef typename rep_type::const_reverse_iterator const_reverse_iterator;
typedef typename rep_type::size_type size_type;
typedef typename rep_type::difference_type difference_type;
typedef typename rep_type::allocator_type allocator_type;
// allocation/deallocation
trie_multiset()
: t(key_compare(), allocator_type())
{}
explicit trie_multiset(const key_begin& __kb,
const key_end& __ke,
const key_size& __ks,
const key_compare& __comp,
const allocator_type& __a = allocator_type())
: t(__kb, __ke, __ks, __comp, __a)
{}
#if 1 //def __STL_MEMBER_TEMPLATES
template <class _InputIterator>
trie_multiset(_InputIterator first, _InputIterator last)
: t(_Compare(), allocator_type())
{ t.insert_equal(first, last); }
template <class _InputIterator>
trie_multiset(_InputIterator first, _InputIterator last,
const _Compare& __comp,
const allocator_type& __a = allocator_type())
: t(__comp, __a)
{ t.insert_equal(first, last); }
#else
trie_multiset(const value_type* first, const value_type* last)
: t(_Compare(), allocator_type())
{ t.insert_equal(first, last); }
trie_multiset(const value_type* first, const value_type* last,
const _Compare& __comp,
const allocator_type& __a = allocator_type())
: t(__comp, __a)
{ t.insert_equal(first, last); }
trie_multiset(const_iterator first, const_iterator last)
: t(_Compare(), allocator_type())
{ t.insert_equal(first, last); }
trie_multiset(const_iterator first, const_iterator last,
const _Compare& __comp,
const allocator_type& __a = allocator_type())
: t(__comp, __a)
{ t.insert_equal(first, last); }
#endif // __STL_MEMBER_TEMPLATES
trie_multiset(const TRIE_MULTISET& x) : t(x.t) {}
TRIE_MULTISET& operator=(const TRIE_MULTISET& x) {
t = x.t;
return *this;
}
// accessors:
key_compare key_comp() const { return t.key_comp(); }
value_compare value_comp() const { return t.key_comp(); }
allocator_type get_allocator() const { return t.get_allocator(); }
iterator begin() const { return t.begin(); }
iterator end() const { return t.end(); }
reverse_iterator rbegin() const { return t.rbegin(); }
reverse_iterator rend() const { return t.rend(); }
bool empty() const { return t.empty(); }
size_type size() const { return t.size(); }
size_type max_size() const { return t.max_size(); }
void swap(TRIE_MULTISET& x) { t.swap(x.t); }
// insert/erase
iterator insert(const value_type& x) {
return t.insert_equal(x);
}
iterator insert(iterator position, const value_type& x) {
t.insert_equal(x);
return position;
}
#if 1 //def __STL_MEMBER_TEMPLATES
template <class _InputIterator>
void insert(_InputIterator first, _InputIterator last) {
t.insert_equal(first, last);
}
#else
void insert(const value_type* first, const value_type* last) {
t.insert_equal(first, last);
}
void insert(const_iterator first, const_iterator last) {
t.insert_equal(first, last);
}
#endif // __STL_MEMBER_TEMPLATES
void erase(iterator position) {
t.erase((typename rep_type::iterator&)position);
}
size_type erase(const key_type& x) {
return t.erase(x);
}
void erase(iterator first, iterator last) {
t.erase((typename rep_type::iterator&)first,
(typename rep_type::iterator&)last);
}
void clear() { t.clear(); }
// multiset operations:
iterator find(const key_type& __x) const {
assert(t.find(__x) == std::find(begin(), end(), __x));
return t.find(__x);
}
iterator find_if_prefix(const key_type& __x) const {
return t.find_if_prefix(__x);
}
size_type count(const key_type& x) const {
#if _DEBUG
size_type __s = std::count(begin(), end(), x);
assert(__s == t.count(x));
#endif
return t.count(x); }
iterator lower_bound(const key_type& x) const {
assert(t.lower_bound(x) == std::lower_bound(begin(), end(), x));
return t.lower_bound(x);
}
iterator upper_bound(const key_type& x) const {
assert(t.upper_bound(x) == std::upper_bound(begin(), end(), x));
return t.upper_bound(x);
}
std::pair<iterator,iterator> equal_range(const key_type& x) const {
assert(t.equal_range(x) == std::equal_range(begin(), end(), x));
return t.equal_range(x);
}
iterator find(const key_iterator& __begin, const key_iterator& __end) const {
return t.find(__begin, __end);
}
iterator find_if_prefix(const key_iterator& __begin, const key_iterator& __end) const {
return t.find_if_prefix(__begin, __end);
}
size_type count(const key_iterator& __begin, const key_iterator& __end) const {
return t.count(__begin, __end);
}
iterator lower_bound(const key_iterator& __begin, const key_iterator& __end) const {
return t.lower_bound(__begin, __end);
}
iterator upper_bound(const key_iterator& __begin, const key_iterator& __end) const {
return t.upper_bound(__begin, __end);
}
std::pair<iterator,iterator> equal_range(const key_iterator& __begin, const key_iterator& __end) const {
return t.equal_range(__begin, __end);
}
#if 1 /*def __STL_TEMPLATE_FRIENDS*/
TRIE_MULTISET_TEMPLATE
friend bool operator== <> (const TRIE_MULTISET&, const TRIE_MULTISET&);
TRIE_MULTISET_TEMPLATE
friend bool operator< <> (const TRIE_MULTISET&, const TRIE_MULTISET&);
#else /* __STL_TEMPLATE_FRIENDS */
friend bool std:: operator== <> (const trie_multiset&, const trie_multiset&);
friend bool std:: operator< <> (const trie_multiset&, const trie_multiset&);
#endif /* __STL_TEMPLATE_FRIENDS */
// trie operations:
std::vector<iterator> approximate_find(const key_type& x, unsigned int __k=1) const
{ return t.approximate_find(x, __k); }
std::vector<iterator> best_find(const key_type& x, unsigned int __k=TRIE_INFINITY) const
{ return t.best_find(x, __k); }
};
TRIE_MULTISET_TEMPLATE
inline bool operator==(const TRIE_MULTISET& x,
const TRIE_MULTISET& y) {
return x.t == y.t;
}
TRIE_MULTISET_TEMPLATE
inline bool operator<(const TRIE_MULTISET& x,
const TRIE_MULTISET& y) {
return x.t < y.t;
}
#if 1 //def __STL_FUNCTION_TMPL_PARTIAL_ORDER
TRIE_MULTISET_TEMPLATE
inline bool operator!=(const TRIE_MULTISET& __x,
const TRIE_MULTISET& __y) {
return !(__x == __y);
}
TRIE_MULTISET_TEMPLATE
inline bool operator>(const TRIE_MULTISET& __x,
const TRIE_MULTISET& __y) {
return __y < __x;
}
TRIE_MULTISET_TEMPLATE
inline bool operator<=(const TRIE_MULTISET& __x,
const TRIE_MULTISET& __y) {
return !(__y < __x);
}
TRIE_MULTISET_TEMPLATE
inline bool operator>=(const TRIE_MULTISET& __x,
const TRIE_MULTISET& __y) {
return !(__x < __y);
}
TRIE_MULTISET_TEMPLATE
inline void swap(TRIE_MULTISET& x,
TRIE_MULTISET& y) {
x.swap(y);
}
#endif // __STL_FUNCTION_TMPL_PARTIAL_ORDER
#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
#pragma reset woff 1174
#pragma reset woff 1375
#endif
}//trie namespace
#endif // #ifndef __TRIE_INTERNAL_MULTISET_H
| [
"lsu.eric@cde1953e-b737-0410-a653-7d96ffb9ffa0"
]
| [
[
[
1,
348
]
]
]
|
79b3acc89e0f088cdb04a30f515d94aeb104bf26 | 57574cc7192ea8564bd630dbc2a1f1c4806e4e69 | /Poker/Cliente/Ejecutor.h | 260f6534c8c9a944e5d713fa4f77971ab750b815 | []
| no_license | natlehmann/taller-2010-2c-poker | 3c6821faacccd5afa526b36026b2b153a2e471f9 | d07384873b3705d1cd37448a65b04b4105060f19 | refs/heads/master | 2016-09-05T23:43:54.272182 | 2010-11-17T11:48:00 | 2010-11-17T11:48:00 | 32,321,142 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 743 | h | #ifndef _EJECUTOR_H__
#define _EJECUTOR_H__
#include "SDL.h"
#include "Ventana.h"
#include "OperacionUICliente.h"
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string.h>
using namespace std;
class Ejecutor
{
private:
static bool enEjecucion;
static string parametro;
static string idOperacion;
static Ventana* ventana;
static SDL_Thread* thread;
Ejecutor(void);
static int ejecutarAsync(void* data);
public:
virtual ~Ejecutor(void);
static bool isEnEjecucion();
static void ejecutar(string idOperacion, Ventana* ventana);
static void ejecutar(string idOperacion, string parametro, Ventana* ventana);
static SDL_Thread* getThread();
};
#endif //_EJECUTOR_H__
| [
"[email protected]@a9434d28-8610-e991-b0d0-89a272e3a296"
]
| [
[
[
1,
38
]
]
]
|
cb388618526fe3556d7f875227002cd2f8da999b | ee065463a247fda9a1927e978143186204fefa23 | /Src/Engine/GameState/GameStateManager.cpp | e1084aa3e2a3a075d913a6dc0e05d82715cf89df | []
| no_license | ptrefall/hinsimviz | 32e9a679170eda9e552d69db6578369a3065f863 | 9caaacd39bf04bbe13ee1288d8578ece7949518f | refs/heads/master | 2021-01-22T09:03:52.503587 | 2010-09-26T17:29:20 | 2010-09-26T17:29:20 | 32,448,374 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,267 | cpp | #include "GameStateManager.h"
#include "IGameState.h"
#include "GameStateFactory.h"
#include <Engine/Core/CoreManager.h>
#include <Engine/Scene/SceneManager.h>
using namespace Engine;
using namespace GameState;
GameStateManager::GameStateManager(Core::CoreManager *coreMgr)
: gameStateIds(0), currentState(NULL), factory(NULL)
{
this->coreMgr = coreMgr;
}
GameStateManager::~GameStateManager()
{
for(unsigned int i = 0; i < gameStates.size(); i++)
{
IGameState *gs = gameStates[i];
if(gs)
{
delete gs;
gs = NULL;
}
}
gameStates.clear();
}
int GameStateManager::init()
{
factory = new GameStateFactory(coreMgr);
return 0;
}
unsigned int GameStateManager::genGameStateId()
{
gameStateIds++;
return gameStateIds;
}
IGameState *GameStateManager::getGameState(unsigned int id) const
{
IGameState *gameState = NULL;
for(unsigned int i = 0; i < gameStates.size(); i++)
{
if(gameStates[i]->getId() == id)
{
gameState = gameStates[i];
break;
}
}
return gameState;
}
IGameState *GameStateManager::getCurrentState() const
{
return currentState;
}
int GameStateManager::changeState(unsigned int id)
{
if(currentState && (currentState->getId() == id)) //Can't change to same state
return 1;
IGameState *nextState = NULL;
for(unsigned int i = 0; i < gameStates.size(); i++)
{
if(gameStates[i]->getId() == id)
{
nextState = gameStates[i];
break;
}
}
if(nextState == NULL)
return 1;
if(currentState)
{
currentState->cleanup();
}
currentState = nextState;
coreMgr->getSceneMgr()->setGameStateRoot(currentState->getGuiRoot(), currentState->getRoot());
currentState->initScript();
currentState->resume();
return 0;
}
int GameStateManager::pushState(unsigned int id)
{
if(currentState && (currentState->getId() == id)) //Can't change to same state
return 1;
IGameState *nextState = NULL;
for(unsigned int i = 0; i < gameStates.size(); i++)
{
if(gameStates[i]->getId() == id)
{
nextState = gameStates[i];
break;
}
}
if(nextState == NULL)
return 1;
if(currentState)
{
currentState->pause();
gameStateStackHistory.push_back(currentState);
}
currentState = nextState;
coreMgr->getSceneMgr()->setGameStateRoot(currentState->getGuiRoot(), currentState->getRoot());
currentState->init();
currentState->resume();
return 0;
}
int GameStateManager::popState()
{
if(gameStateStackHistory.empty())
return 1;
if(currentState)
{
currentState->pause();
}
currentState = gameStateStackHistory[gameStateStackHistory.size()-1];
gameStateStackHistory.erase(gameStateStackHistory.end()-1);
coreMgr->getSceneMgr()->setGameStateRoot(currentState->getGuiRoot(), currentState->getRoot());
currentState->resume();
return 0;
}
IGameState *GameStateManager::create(const CL_String &name)
{
if(factory == NULL)
return NULL;
//Check if gamestate has already been loaded
for(unsigned int i = 0; i < gameStates.size(); i++)
{
if(gameStates[i]->getName() == name)
{
return gameStates[i];
}
}
IGameState *state = factory->create(name.c_str());
if(state)
gameStates.push_back(state);
return state;
}
| [
"[email protected]@28a56cb3-1e7c-bc60-7718-65c159e1d2df"
]
| [
[
[
1,
157
]
]
]
|
88a5e61bce5d88dab7c64f2c90170a0160eeccad | fad6f9883d4ad2686c196dc532a9ecb9199500ee | /NXP-LPC/CommTest/CommTest/ClientChildFrm.h | a6ea8052f57dedea4896aaf07fd97f531d5413a4 | []
| no_license | aquarius20th/nxp-lpc | fe83d6a140d361a1737d950ff728c6ea9a16a1dd | 4abfb804daf0ac9c59bd90d879256e7a3c1b2f30 | refs/heads/master | 2021-01-10T13:54:40.237682 | 2009-12-22T14:54:59 | 2009-12-22T14:54:59 | 48,420,260 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 959 | h |
// ClientChildFrame.h : CClientChildFrame 类的接口
//
#pragma once
#include "SplitterWndExt.h"
class CClientChildFrame : public CBCGPMDIChildWnd
{
DECLARE_DYNCREATE(CClientChildFrame)
public:
CClientChildFrame();
// 属性
public:
CSplitterWndExt m_wndSplitter1;
CBCGPSplitterWnd m_wndSplitter2;
// 操作
public:
// 重写
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual void ActivateFrame(int nCmdShow);
// 实现
public:
virtual ~CClientChildFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
// 生成的消息映射函数
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
protected:
virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);
public:
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnClose();
afx_msg void OnDestroy();
};
| [
"lijin.unix@13de9a6c-71d3-11de-b374-81e7cb8b6ca2"
]
| [
[
[
1,
46
]
]
]
|
321c5bfb7adf92463c7884ed7eedea5befec62e4 | 847cccd728e768dc801d541a2d1169ef562311cd | /externalLibs/angelscript/source/as_scriptfunction.h | 153eebec0e811ed59d14e85312fc8ba7e68ae29d | []
| no_license | aadarshasubedi/Ocerus | 1bea105de9c78b741f3de445601f7dee07987b96 | 4920b99a89f52f991125c9ecfa7353925ea9603c | refs/heads/master | 2021-01-17T17:50:00.472657 | 2011-03-25T13:26:12 | 2011-03-25T13:26:12 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,916 | h | /*
AngelCode Scripting Library
Copyright (c) 2003-2010 Andreas Jonsson
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
The original version of this library can be located at:
http://www.angelcode.com/angelscript/
Andreas Jonsson
[email protected]
*/
//
// as_scriptfunction.h
//
// A container for a compiled script function
//
#ifndef AS_SCRIPTFUNCTION_H
#define AS_SCRIPTFUNCTION_H
#include "as_config.h"
#include "as_string.h"
#include "as_array.h"
#include "as_datatype.h"
#include "as_atomic.h"
BEGIN_AS_NAMESPACE
class asCScriptEngine;
class asCModule;
class asCConfigGroup;
class asCGlobalProperty;
struct asSScriptVariable
{
asCString name;
asCDataType type;
int stackOffset;
};
const int asFUNC_SYSTEM = 0;
const int asFUNC_SCRIPT = 1;
const int asFUNC_INTERFACE = 2;
const int asFUNC_IMPORTED = 3;
const int asFUNC_VIRTUAL = 4;
const int asFUNC_FUNCDEF = 5;
struct asSSystemFunctionInterface;
// TODO: Need a method for obtaining the function type, so that the application can differenciate between the types
// This should replace the IsClassMethod and IsInterfaceMethod
// TODO: GetModuleName should be removed. A function won't belong to a specific module anymore
// as the function can be removed from the module, but still remain alive. For example
// for dynamically generated functions held by a function pointer.
// TODO: Might be interesting to allow enumeration of accessed global variables, and
// also functions/methods that are being called.
void RegisterScriptFunction(asCScriptEngine *engine);
class asCScriptFunction : public asIScriptFunction
{
public:
// From asIScriptFunction
asIScriptEngine *GetEngine() const;
// Memory management
int AddRef();
int Release();
int GetId() const;
const char *GetModuleName() const;
asIObjectType *GetObjectType() const;
const char *GetObjectName() const;
const char *GetName() const;
const char *GetDeclaration(bool includeObjectName = true) const;
const char *GetScriptSectionName() const;
const char *GetConfigGroup() const;
bool IsClassMethod() const;
bool IsInterfaceMethod() const;
bool IsReadOnly() const;
int GetParamCount() const;
int GetParamTypeId(int index, asDWORD *flags = 0) const;
int GetReturnTypeId() const;
// For JIT compilation
asDWORD *GetByteCode(asUINT *length = 0);
public:
//-----------------------------------
// Internal methods
asCScriptFunction(asCScriptEngine *engine, asCModule *mod, int funcType);
~asCScriptFunction();
void AddVariable(asCString &name, asCDataType &type, int stackOffset);
int GetSpaceNeededForArguments();
int GetSpaceNeededForReturnValue();
asCString GetDeclarationStr(bool includeObjectName = true) const;
int GetLineNumber(int programPosition);
void ComputeSignatureId();
bool IsSignatureEqual(const asCScriptFunction *func) const;
bool IsSignatureExceptNameEqual(const asCScriptFunction *func) const;
void JITCompile();
void AddReferences();
void ReleaseReferences();
asCGlobalProperty *GetPropertyByGlobalVarPtr(void *gvarPtr);
// GC methods
int GetRefCount();
void SetFlag();
bool GetFlag();
void EnumReferences(asIScriptEngine *engine);
void ReleaseAllHandles(asIScriptEngine *engine);
public:
//-----------------------------------
// Properties
asCAtomic refCount;
bool gcFlag;
asCScriptEngine *engine;
asCModule *module;
// Function signature
asCString name;
asCDataType returnType;
asCArray<asCDataType> parameterTypes;
asCArray<asETypeModifiers> inOutFlags;
bool isReadOnly;
bool isPrivate;
asCObjectType *objectType;
int signatureId;
int id;
int funcType;
// Used by asFUNC_SCRIPT
asCArray<asDWORD> byteCode;
asCArray<asCObjectType*> objVariableTypes;
asCArray<int> objVariablePos;
int stackNeeded;
asCArray<int> lineNumbers; // debug info
asCArray<asSScriptVariable*> variables; // debug info
int scriptSectionIdx; // debug info
bool dontCleanUpOnException; // Stub functions don't own the object and parameters
// Used by asFUNC_VIRTUAL
int vfTableIdx;
// Used by asFUNC_SYSTEM
asSSystemFunctionInterface *sysFuncIntf;
// JIT compiled code of this function
asJITFunction jitFunction;
};
END_AS_NAMESPACE
#endif
| [
"[email protected]"
]
| [
[
[
1,
190
]
]
]
|
047bf0a06623afedf7c1a35593e69bb616a8d4fc | 89d2197ed4531892f005d7ee3804774202b1cb8d | /Game/Vector.h | ceba97dccf1685aded0bdd09fa545e656d4bc051 | [
"MIT",
"Zlib"
]
| permissive | hpidcock/gbsfml | ef8172b6c62b1c17d71d59aec9a7ff2da0131d23 | e3aa990dff8c6b95aef92bab3e94affb978409f2 | refs/heads/master | 2020-05-30T15:01:19.182234 | 2010-09-29T06:53:53 | 2010-09-29T06:53:53 | 35,650,825 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,821 | h | //////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2010 Harry Pidcock
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef __VECTOR_H__
#define __VECTOR_H__
class Vector
{
public:
float x, y;
Vector(void) : x(0), y(0)
{
};
Vector(float x, float y) : x(x), y(y)
{
};
Vector(const Vector &other) : x(other.x), y(other.y)
{
};
Vector(const sf::Vector2f &other) : x(other.x), y(other.y)
{
};
Vector(const sf::Vector2i &other) : x((float)other.x), y((float)other.y)
{
};
Vector(const b2Vec2 &other) : x(other.x), y(other.y)
{
};
inline operator sf::Vector2f(void) const
{
return sf::Vector2f(x, y);
};
inline operator sf::Vector2i(void) const
{
return sf::Vector2i((int)x, (int)y);
};
inline operator b2Vec2(void) const
{
return b2Vec2(x, y);
};
inline bool operator<(const Vector &other) const
{
return x < other.x && y < other.y;
};
inline bool operator>(const Vector &other) const
{
return x > other.x && y > other.y;
};
inline bool operator<=(const Vector &other) const
{
return x <= other.x && y <= other.y;
};
inline bool operator>=(const Vector &other) const
{
return x >= other.x && y >= other.y;
};
inline bool operator==(const Vector &other) const
{
return Distance(other) <= 0.0001f;
};
inline bool operator!=(const Vector &other) const
{
return Distance(other) > 0.0001f;
};
inline Vector operator-(const Vector &other) const
{
return Vector(x - other.x, y - other.y);
};
inline Vector operator+(const Vector &other) const
{
return Vector(x + other.x, y + other.y);
};
inline Vector operator*(const Vector &other) const
{
return Vector(x * other.x, y * other.y);
};
inline Vector operator/(const Vector &other) const
{
return Vector(x / other.x, y / other.y);
};
inline Vector operator*(const float other) const
{
return Vector(x * other, y * other);
};
inline Vector operator/(const float other) const
{
return Vector(x / other, y / other);
};
inline Vector &operator-=(const Vector &other)
{
x -= other.x;
y -= other.y;
return (*this);
};
inline Vector &operator+=(const Vector &other)
{
x += other.x;
y += other.y;
return (*this);
};
inline Vector &operator*=(const Vector &other)
{
x *= other.x;
y *= other.y;
return (*this);
};
inline Vector &operator/=(const Vector &other)
{
x /= other.x;
y /= other.y;
return (*this);
};
inline Vector &operator*=(const float other)
{
x *= other;
y *= other;
return (*this);
};
inline Vector &operator/=(const float other)
{
x /= other;
y /= other;
return (*this);
};
inline float Length(void) const
{
return sqrtf(x * x + y * y);
};
inline float Distance(const Vector &other) const
{
return (other - (*this)).Length();
};
inline float DotProduct(const Vector &other) const
{
return x * other.x + y * other.y;
};
inline float AngleBetween(const Vector &other) const
{
return acosf(DotProduct(other)/(Length() * other.Length()));
};
inline Vector Normalise(void) const
{
return (*this) / Length();
};
inline Vector Invert(void) const
{
return (*this) * Vector(-1.0f, -1.0f);
};
};
inline Vector operator*(const float fl, const Vector &vec)
{
return Vector(vec.x * fl, vec.y * fl);
}
inline std::ostream &operator<<(std::ostream &stream, const Vector &vec)
{
stream << "(" << vec.x << ", " << vec.y << ")";
return stream;
}
#endif // __VECTOR_H__ | [
"haza55@5bf3a77f-ad06-ad18-b9fb-7d0f6dabd793"
]
| [
[
[
1,
214
]
]
]
|
42b32ef4d49dcc16cb93e77d16391e7d85f0ec98 | fac8de123987842827a68da1b580f1361926ab67 | /inc/physics/Common/Base/Memory/StackTracer/hkStackTracer.h | 3624c069e62b9e074960971df2882de3caf40c4a | []
| no_license | blockspacer/transporter-game | 23496e1651b3c19f6727712a5652f8e49c45c076 | 083ae2ee48fcab2c7d8a68670a71be4d09954428 | refs/heads/master | 2021-05-31T04:06:07.101459 | 2009-02-19T20:59:59 | 2009-02-19T20:59:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,070 | h | /*
*
* Confidential Information of Telekinesys Research Limited (t/a Havok). Not for disclosure or distribution without Havok's
* prior written consent.This software contains code, techniques and know-how which is confidential and proprietary to Havok.
* Level 2 and Level 3 source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2008 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement.
*
*/
#ifndef HKBASE_STACKTRACER_H
#define HKBASE_STACKTRACER_H
/// An object which can generate stack traces.
/// Some platforms may also be able to associate addresses to
/// function and source file information.
class hkStackTracer : public hkReferencedObject
{
public:
HK_DECLARE_CLASS_ALLOCATOR(HK_MEMORY_CLASS_BASE_CLASS);
hkStackTracer();
~hkStackTracer();
typedef void (HK_CALL *printFunc)(const char*, void* context);
/// Print the stack trace with pfunc.
/// pfunc is called may be called multiple times.
/// The output format is platform specific.
void dumpStackTrace( const hkUlong* trace, int numtrace, printFunc pfunc, void* context=HK_NULL );
/// Write at most maxtrace stack entries into 'trace'.
/// Return the number of entries written.
int getStackTrace( hkUlong* trace, int maxtrace );
};
#endif // HKBASE_STACKTRACER_H
/*
* Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20080529)
*
* Confidential Information of Havok. (C) Copyright 1999-2008
* Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok
* Logo, and the Havok buzzsaw logo are trademarks of Havok. Title, ownership
* rights, and intellectual property rights in the Havok software remain in
* Havok and/or its suppliers.
*
* Use of this software for evaluation purposes is subject to and indicates
* acceptance of the End User licence Agreement for this product. A copy of
* the license is included with this software and is also available at
* www.havok.com/tryhavok
*
*/
| [
"uraymeiviar@bb790a93-564d-0410-8b31-212e73dc95e4"
]
| [
[
[
1,
52
]
]
]
|
9a08f537199cd4cf215c3ee95c4038bf37538595 | f9ed86de48cedc886178f9e8c7ee4fae816ed42d | /src/scenegraph.h | d613fea71882760167febeb18e24289906210c89 | [
"MIT"
]
| permissive | rehno-lindeque/Flower-of-Persia | bf78d144c8e60a6f30955f099fe76e4a694ec51a | b68af415a09b9048f8b8f4a4cdc0c65b46bcf6d2 | refs/heads/master | 2021-01-25T04:53:04.951376 | 2011-01-29T11:41:38 | 2011-01-29T11:41:38 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 368 | h | #ifndef __SCENEGRAPH_H__
#define __SCENEGRAPH_H__
class SceneGraph
{
public:
vector<SceneNode*> nodes;
virtual void draw()
{
//for()
}
~SceneGraph()
{
delete nodes;
}
};
class SceneNode
{
public:
virtual void apply() = 0;
};
class SceneTransformation : public SceneNode
{
public:
void apply();
};
#endif
| [
"[email protected]"
]
| [
[
[
1,
32
]
]
]
|
a95bba0ddb31241d4522d622311279cd551c6b9d | 9a6a9d17dde3e8888d8183618a02863e46f072f1 | /Method.cpp | b571ace7f66b3d6905c886a4a8938e4fbea983f0 | []
| no_license | pritykovskaya/max-visualization | 34266c449fb2c03bed6fd695e0b54f144d78e123 | a3c0879a8030970bb1fee95d2bfc6ccf689972ea | refs/heads/master | 2021-01-21T12:23:01.436525 | 2011-07-06T18:23:38 | 2011-07-06T18:23:38 | 2,006,225 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,793 | cpp | #include "stdafx.h"
#include "Method.h"
#include "R32M.H"
vector< vector<double> > Method::single_element_vector(vector<double> v) {
vector< vector<double> > vv;
vv.push_back(v);
return vv;
}
RandomMethod::RandomMethod (int _steps, double _eps, double _p, int bsteps):
numb_of_steps(_steps),
my_eps(_eps),
p_fall_inside_bound(_p),
my_fail_steps(bsteps)
{}
string RandomMethod::get_method_name() {
return "Random method";
}
int RandomMethod::numb_of_start_points() {
return 1;
}
void RandomMethod::set_steps(int steps) {numb_of_steps = steps;}
void RandomMethod::set_epsilon(double eps) {my_eps = eps;}
void RandomMethod::set_p(double p) {p_fall_inside_bound = p;}
void RandomMethod::set_fail_steps(int fail_steps) {my_fail_steps = fail_steps;}
int RandomMethod::get_steps() const {return numb_of_steps;}
double RandomMethod::get_epsilon() const {return my_eps;}
double RandomMethod::get_p() const {return p_fall_inside_bound;}
int RandomMethod::get_fail_steps() const {return my_fail_steps;}
RandomMethod::~RandomMethod() {}
vector<double> RandomMethod::next_step(Area* area, vector<double> point)
{
double x, rand_numb;
int dim = area -> get_dim();
vector <double> res;
res.reserve(dim);
rand_numb = rnunif();
if (rand_numb < p_fall_inside_bound)
{
for (int i = 0; i < dim; ++i)
{
x = rnunif() * 2 * my_eps + point[i] - my_eps;
if (x >= area -> my_area[2*i] && x <= area -> my_area[2*i+1]) res.push_back(x);
else
{
if (x < area -> my_area[2*i])
res.push_back(area -> my_area[2*i]);
if (x > area -> my_area[2*i+1])
res.push_back(area -> my_area[2*i+1]);
}
}
}
else
{
for (int i = 0; i < dim; ++i)
{
x = rnunif() * (area -> my_area[2*i+1] - area -> my_area[2*i]) + area -> my_area[2*i];
res.push_back(x);
}
}
return res;
}
MethodResult RandomMethod::search_process(Function* f, Area* area, vector< vector<double> > start_points){
string s;
vector<double> start_point = start_points[0];
vector <double> cur_point(start_point);
vector <double> next_point;
next_point.reserve(start_point.size());
vector< vector<double> > cur_traj;
cur_traj.push_back(start_point);
int step_count = 0;
int fail_step_count = 0;
while (1)
{
next_point = next_step(area, cur_point);
if ((*f)(next_point) > (*f)(cur_point))
{
cur_traj.push_back(next_point);
cur_point = next_point;
fail_step_count = 0;
}
else
{
++fail_step_count;
if (fail_step_count >= my_fail_steps)
{
s = "fail steps limit achived";
break;
}
}
++step_count;
if (step_count > numb_of_steps)
{
s = "steps limit achived";
break;
}
}
return MethodResult(cur_traj, s);
}
| [
"[email protected]"
]
| [
[
[
1,
117
]
]
]
|
803847dc15275a4f1bbfcf900228ca195f8ba910 | 12849499e019f653b69e2ce6ab266ab4bfa5871c | /Classes/HelloWorldScene.cpp | 0237d43383a747bbde8534dc2d155ee7faa699de | [
"MIT"
]
| permissive | galexcode/SimpleGamePart3Cocos2D-x | 8413f0bf8ced19b26698b2450d8c9b3135c433c5 | 0e605b72982ed19ba72a784b4d98653f501583eb | refs/heads/master | 2021-01-16T18:23:41.048601 | 2011-08-17T16:29:00 | 2011-08-17T16:29:00 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,030 | cpp | #include "HelloWorldScene.h"
#include "SimpleAudioEngine.h"
#include "GameOverScene.h"
#include "Monster.h"
USING_NS_CC;
HelloWorld::~HelloWorld()
{
if (_targets)
{
_targets->release();
_targets = NULL;
}
if (_projectiles)
{
_projectiles->release();
_projectiles = NULL;
}
if (_player)
{
_player->release();
_player = NULL;
}
// cpp don't need to call super dealloc
// virtual destructor will do this
}
CCScene* HelloWorld::scene()
{
// 'scene' is an autorelease object
CCScene *scene = CCScene::node();
// 'layer' is an autorelease object
HelloWorld *layer = HelloWorld::node();
// add layer as a child to scene
scene->addChild(layer);
// return the scene
return scene;
}
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
if ( !CCColorLayer::initWithColor( ccc4(255,255,255,255) ) ) {
return false;
}
/////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program
// you may modify it.
// add a "close" icon to exit the progress. it's an autorelease object
CCMenuItemImage *pCloseItem = CCMenuItemImage::itemFromNormalImage(
"CloseNormal.png",
"CloseSelected.png",
this,
menu_selector(HelloWorld::menuCloseCallback) );
pCloseItem->setPosition( ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20) );
// create menu, it's an autorelease object
CCMenu* pMenu = CCMenu::menuWithItems(pCloseItem, NULL);
pMenu->setPosition( CCPointZero );
this->addChild(pMenu, 1);
CCSize size = CCDirector::sharedDirector()->getWinSize();
//CCSprite* player = CCSprite::spriteWithFile("Player2.jpg", CCRectMake(0, 0, 27, 40));
// position the sprite on the center of the screen
//player->setPosition( ccp(player->getContentSize().width/2, size.height/2) );
// add the sprite as a child to this layer
//this->addChild(player, 0);
this->schedule( schedule_selector(HelloWorld::gameLogic), 1.0 );
this->setIsTouchEnabled(true);
_targets = new CCMutableArray<CCSprite*>;
_projectiles = new CCMutableArray<CCSprite*>;
_nextProjectile = NULL;
_projectilesDestroyed = 0;
_player = CCSprite::spriteWithFile("Player2.jpg");
_player->retain();
_player->setPosition(CCPointMake(_player->getContentSize().width/2, size.height/2));
this->addChild(_player);
this->schedule(schedule_selector(HelloWorld::update));
CCLOG("Loading music");
CocosDenshion::SimpleAudioEngine::sharedEngine()->playBackgroundMusic("background-music-aac.caf");
return true;
}
void HelloWorld::gameLogic(cocos2d::ccTime dt)
{
this->addTarget();
}
void HelloWorld::addTarget()
{
Monster *target = NULL;
if ((arc4random() % 2) == 0)
{
target = WeakAndFastMonster::monster();
} else
{
target = StrongAndSlowMonster::monster();
}
// Determine where to spawn the target along the Y axis
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
int minY = target->getContentSize().height/2;
int maxY = winSize.height - target->getContentSize().height/2;
int rangeY = maxY - minY;
int actualY = (arc4random() % rangeY) + minY;
// Create the target slightly off-screen along the right edge,
// and along a random position along the Y axis as calculated above
target->setPosition(ccp(winSize.width + target->getContentSize().width/2, actualY));
this->addChild(target);
// Determine speed of the target
int minDuration = target->getMinMoveDuration();
int maxDuration = target->getMaxMoveDuration();
int rangeDuration = maxDuration - minDuration;
int actualDuration = (arc4random() % rangeDuration) + minDuration;
// Create the actions
CCFiniteTimeAction *actionMove = CCMoveTo::actionWithDuration(actualDuration, ccp(-target->getContentSize().width/2, actualY));
CCFiniteTimeAction *actionMoveDone = CCCallFuncN::actionWithTarget(this, callfuncN_selector(HelloWorld::spriteMoveFinished));
target->setTag(1);
_targets->addObject(target);
target->runAction(CCSequence::actions(actionMove, actionMoveDone));
}
void HelloWorld::spriteMoveFinished(CCNode* sender)
{
CCSprite *sprite = (CCSprite *)sender;
this->removeChild(sprite, true);
if (sprite->getTag() == 1)
{ // target
_targets->removeObject(sprite);
GameOverScene *gameOverScene = GameOverScene::node();
gameOverScene->getLayer()->getLabel()->setString("You Lose! :[");
CCDirector::sharedDirector()->replaceScene(gameOverScene);
}
else if (sprite->getTag() == 2)
{ // projectile
_projectiles->removeObject(sprite);
}
}
void HelloWorld::menuCloseCallback(CCObject* pSender)
{
CCDirector::sharedDirector()->end();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
exit(0);
#endif
}
void HelloWorld::finishShoot()
{
// Ok to add now - we've finished rotation!
this->addChild(_nextProjectile);
_projectiles->addObject(_nextProjectile);
// Release
_nextProjectile->release();
_nextProjectile = NULL;
}
void HelloWorld::ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent)
{
if (_nextProjectile != NULL)
{
return;
}
CCTouch *touch = (CCTouch *)pTouches->anyObject();
CCPoint location = touch->locationInView(touch->view());
location = CCDirector::sharedDirector()->convertToGL(location);
// Set up initial location of projectile
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
_nextProjectile = CCSprite::spriteWithFile("Projectile2.jpg", CCRectMake(0, 0, 20, 20));
_nextProjectile->retain();
_nextProjectile->setPosition(ccp(20, winSize.height/2));
// Determine offset of location to projectile
int offX = location.x - _nextProjectile->getPosition().x;
int offY = location.y - _nextProjectile->getPosition().y;
// Bail out if we are shooting down or backwards
if (offX <= 0) return;
// Play a sound!
CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("pew-pew-lei.caf");
// Determine where we wish to shoot the projectile to
int realX = winSize.width + (_nextProjectile->getContentSize().width/2);
float ratio = (float) offY / (float) offX;
int realY = (realX * ratio) + _nextProjectile->getPosition().y;
CCPoint realDest = ccp(realX, realY);
// Determine the length of how far we're shooting
int offRealX = realX - _nextProjectile->getPosition().x;
int offRealY = realY - _nextProjectile->getPosition().y;
float length = sqrtf((offRealX*offRealX)+(offRealY*offRealY));
float velocity = 480/1; // 480pixels/1sec
float realMoveDuration = length/velocity;
// Determine angle to face
float angleRadians = atanf((float)offRealY / (float)offRealX);
float angleDegrees = CC_RADIANS_TO_DEGREES(angleRadians);
float cocosAngle = -1 * angleDegrees;
_player->setRotation(cocosAngle);
float rotateSpeed = 0.5 / M_PI; // Would take 0.5 seconds to rotate 0.5 radians, or half a circle
float rotateDuration = fabs(angleRadians * rotateSpeed);
_player->runAction(CCSequence::actions(CCRotateTo::actionWithDuration(rotateDuration, cocosAngle),
CCCallFunc::actionWithTarget(this, callfunc_selector(HelloWorld::finishShoot)),
NULL));
// Move projectile to actual endpoint
_nextProjectile->runAction(CCSequence::actions(CCMoveTo::actionWithDuration(realMoveDuration, realDest),
CCCallFuncN::actionWithTarget(this, callfuncN_selector(HelloWorld::spriteMoveFinished)),
NULL));
// Add to projectiles array
_nextProjectile->setTag(2);
}
void HelloWorld::update(cocos2d::ccTime dt)
{
CCMutableArray<cocos2d::CCSprite*> *projectilesToDelete = new CCMutableArray<CCSprite *>;
CCMutableArray<CCSprite*>::CCMutableArrayIterator it, jt;
for (it = _projectiles->begin(); it != _projectiles->end(); it++)
{
CCSprite *projectile = *it;
CCRect projectileRect = CCRectMake(
projectile->getPosition().x - (projectile->getContentSize().width/2),
projectile->getPosition().y - (projectile->getContentSize().height/2),
projectile->getContentSize().width,
projectile->getContentSize().height);
bool monsterHit = false;
CCMutableArray<cocos2d::CCSprite*> *targetsToDelete = new CCMutableArray<cocos2d::CCSprite*>;
for (jt = _targets->begin(); jt != _targets->end(); jt++)
{
CCSprite *target = *jt;
CCRect targetRect = CCRectMake(
target->getPosition().x - (target->getContentSize().width/2),
target->getPosition().y - (target->getContentSize().height/2),
target->getContentSize().width,
target->getContentSize().height);
if (CCRect::CCRectIntersectsRect(projectileRect, targetRect)) {
monsterHit = true;
Monster *monster = (Monster *)target;
monster->setCurHp(monster->getCurHp()-1);
CCLOG("Decreasing HP for monster %@ to %d", monster, monster->getCurHp());
if (monster->getCurHp() <= 0)
{
targetsToDelete->addObject(target);
}
else {
CCLOG("derp");
}
break;
}
}
for (jt = targetsToDelete->begin(); jt != targetsToDelete->end(); jt++)
{
_targets->removeObject(*jt);
this->removeChild((*jt), true);
_projectilesDestroyed++;
if (_projectilesDestroyed > 30) {
GameOverScene *gameOverScene = GameOverScene::node();
_projectilesDestroyed = 0;
gameOverScene->getLayer()->getLabel()->setString("You Win!");
CCDirector::sharedDirector()->replaceScene(gameOverScene);
}
}
if (monsterHit) {
projectilesToDelete->addObject(*it);
CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("explosion.caf");
}
targetsToDelete->release();
}
for (it = projectilesToDelete->begin(); it != projectilesToDelete->end(); it++)
{
_projectiles->removeObject(*it);
this->removeChild(*it, true);
}
projectilesToDelete->release();
} | [
"[email protected]"
]
| [
[
[
1,
317
]
]
]
|
446f97a677ec05ecd4cd46057a3446ec753b107d | 7c93f9e101f6bba916bc1a967eb8e787afe9be92 | /7z920/CPP/7zip/Common/MemBlocks.h | 428971cbe6d561585422d79941c88f43caf361da | []
| no_license | ditupao/vx7zip | 95759f909368c14f5b8f9a3cbee18a54dc3eae78 | 13fa94305e8d3491f9d920351e5d1534957a1c06 | refs/heads/master | 2016-08-11T10:55:47.619762 | 2011-06-05T09:50:51 | 2011-06-05T09:50:51 | 47,533,061 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,899 | h | // MemBlocks.h
#ifndef __MEM_BLOCKS_H
#define __MEM_BLOCKS_H
#include "Common/MyVector.h"
#include "Windows/Synchronization.h"
#include "../IStream.h"
class CMemBlockManager
{
void *_data;
size_t _blockSize;
void *_headFree;
public:
CMemBlockManager(size_t blockSize = (1 << 20)): _data(0), _blockSize(blockSize), _headFree(0) {}
~CMemBlockManager() { FreeSpace(); }
bool AllocateSpace(size_t numBlocks);
void FreeSpace();
size_t GetBlockSize() const { return _blockSize; }
void *AllocateBlock();
void FreeBlock(void *p);
};
class CMemBlockManagerMt: public CMemBlockManager
{
NWindows::NSynchronization::CCriticalSection _criticalSection;
public:
// NWindows::NSynchronization::CSemaphore Semaphore;
CMemBlockManagerMt(size_t blockSize = (1 << 20)): CMemBlockManager(blockSize) {}
~CMemBlockManagerMt() { FreeSpace(); }
HRes AllocateSpace(size_t numBlocks, size_t numNoLockBlocks = 0);
HRes AllocateSpaceAlways(size_t desiredNumberOfBlocks, size_t numNoLockBlocks = 0);
void FreeSpace();
void *AllocateBlock();
void FreeBlock(void *p, bool lockMode = true);
HRes ReleaseLockedBlocks(int number) { return 0;}//Semaphore.Release(number); }
};
class CMemBlocks
{
void Free(CMemBlockManagerMt *manager);
public:
CRecordVector<void *> Blocks;
UInt64 TotalSize;
CMemBlocks(): TotalSize(0) {}
void FreeOpt(CMemBlockManagerMt *manager);
HRESULT WriteToStream(size_t blockSize, ISequentialOutStream *outStream) const;
};
struct CMemLockBlocks: public CMemBlocks
{
bool LockMode;
CMemLockBlocks(): LockMode(true) {};
void Free(CMemBlockManagerMt *memManager);
void FreeBlock(int index, CMemBlockManagerMt *memManager);
HRes SwitchToNoLockMode(CMemBlockManagerMt *memManager);
void Detach(CMemLockBlocks &blocks, CMemBlockManagerMt *memManager);
};
#endif
| [
"[email protected]"
]
| [
[
[
1,
71
]
]
]
|
0f13b3d7390cf5200bda212b64f9db5ef404d7ac | a31b42df5677d051e843f32cb536b27ec710cd50 | /Arkane/src/main.cpp | 3dfb55e7518e2dfdcfb7105411b5e2cbbe589569 | []
| no_license | chuckrussell/Project-Volcano | 498ec04deb8a86cbf8c44e612ef24282faa8fa8d | 8f202dfc6bcd65e0523ed52662ed8954c5dda4d2 | refs/heads/master | 2020-04-07T20:45:25.016567 | 2011-02-09T16:20:15 | 2011-02-09T16:20:15 | 1,288,203 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 501 | cpp | #include "System.h"
// the entry point for any Windows program
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
// create the system object
System* system = new System();
// Check if the system object was created.
if(!system) return 0;
// Initialize and run the system object.
if(system->Initialize()) system->Run();
// Shutdown and release the system object.
system->Close();
delete system;
system = 0;
return 0;
} | [
"[email protected]",
"[email protected]",
"[email protected]"
]
| [
[
[
1,
1
],
[
3,
4
],
[
6,
10
],
[
12,
13
],
[
15,
18
],
[
20,
20
]
],
[
[
2,
2
],
[
5,
5
],
[
11,
11
],
[
14,
14
],
[
19,
19
]
],
[
[
21,
21
]
]
]
|
c6e3b72a2ef33c8dfc24397b34013a60367b6285 | aa56ef00377b2c63a9afb2de1132fc7252ce3dde | /procon/SPSC_RingBufferQueue_TryTest.cpp | 02411e2e121ea2b06ad490e82182b8a6e7d8d1bf | []
| no_license | k06a/procon | 5796fdd9e605b93b3d8ba57362d223182ccd5f12 | 56b35da383a9b4b1f5899e1bc09261315c57f49c | refs/heads/master | 2020-04-06T04:36:12.527471 | 2011-12-28T12:28:50 | 2011-12-28T12:28:50 | 32,887,639 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,837 | cpp | #include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "SPSC_RingBufferQueue_Common.h"
#include "SPSC_RingBufferQueue.h"
//////////////////////////////////////////////////////////////////////////
typedef SPSC_RingBufferQueue<int> IntQueue;
struct Context
{
int N;
IntQueue queue;
Context(int N, int bufferSize)
: N(N), queue(bufferSize)
{
}
};
static void producer(void * param)
{
Context * context = (Context*)param;
for(int i = 0; i < context->N; i++)
{
int * val = new int(i);
while (!context->queue.tryPush(val))
;
}
}
static void consumer(void * param)
{
Context * context = (Context*)param;
for(int i = 0; i < context->N; i++)
{
int * val;
while ((val = context->queue.tryPop()) == NULL)
;
EXPECT_EQ(i, *val);
delete val;
}
}
//////////////////////////////////////////////////////////////////////////
TEST(SPSC_RingBufferQueue, TryTryPushPop_1K_via_100)
{
Context * context = new Context(1000,100);
SPSC_RingBufferQueue_Test(producer,consumer,context);
}
TEST(SPSC_RingBufferQueue, TryTryPushPop_1K_via_10)
{
Context * context = new Context(1000,10);
SPSC_RingBufferQueue_Test(producer,consumer,context);
}
TEST(SPSC_RingBufferQueue, TryTryPushPop_1K_via_2)
{
Context * context = new Context(1000,2);
SPSC_RingBufferQueue_Test(producer,consumer,context);
}
TEST(SPSC_RingBufferQueue, TryTryPushPop_1K_via_1)
{
Context * context = new Context(1000,1);
SPSC_RingBufferQueue_Test(producer,consumer,context);
}
//////////////////////////////////////////////////////////////////////////
TEST(SPSC_RingBufferQueue, TryPushPop_100K_via_10K)
{
Context * context = new Context(100000,10000);
SPSC_RingBufferQueue_Test(producer,consumer,context);
}
TEST(SPSC_RingBufferQueue, TryPushPop_100K_via_1K)
{
Context * context = new Context(100000,1000);
SPSC_RingBufferQueue_Test(producer,consumer,context);
}
TEST(SPSC_RingBufferQueue, TryPushPop_100K_via_100)
{
Context * context = new Context(100000,100);
SPSC_RingBufferQueue_Test(producer,consumer,context);
}
TEST(SPSC_RingBufferQueue, TryPushPop_100K_via_10)
{
Context * context = new Context(100000,10);
SPSC_RingBufferQueue_Test(producer,consumer,context);
}
TEST(SPSC_RingBufferQueue, TryPushPop_100K_via_2)
{
Context * context = new Context(100000,2);
SPSC_RingBufferQueue_Test(producer,consumer,context);
}
TEST(SPSC_RingBufferQueue, TryPushPop_100K_via_1)
{
Context * context = new Context(100000,1);
SPSC_RingBufferQueue_Test(producer,consumer,context);
}
//////////////////////////////////////////////////////////////////////////
| [
"[email protected]"
]
| [
[
[
1,
112
]
]
]
|
a6f5f7fef0cf89996b55dcbaa2d03fbf0b5518e0 | cb0268e95542374ff2abf2b9c770d1c106774624 | /modelLoader/Arrays.h | ca0d1d89ac7256cb7814e0236bf9430df5890101 | []
| no_license | xXSingularityXx/Bomber-Rage-3D | a898e046cf93649a052d5c1ad019cc60dd5184ce | 7249c95055ca5df6c05775f8006f307dab5cc856 | refs/heads/master | 2021-01-10T21:20:31.343120 | 2009-12-17T07:54:42 | 2009-12-17T07:54:42 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,641 | h | #include<iostream>
#include<vector>
using namespace std;
template <class T>
class Array2D
{
vector< vector<T> > array2d;
int col;
int row;
public:
// * Construtor;
Array2D(int row_, int col_): array2d(row_,vector<T>(col_))
{
col = col_;
row = row_;
}
~Array2D()
{
}
vector<T> & operator[](int index){
return array2d[index];
}
const vector<T> & operator[](int index) const{
return array2d[index];
}
// * Redimensiona o array;
void resizeArray(int rows, int cols){
array2d.resize(rows);
for (int i=0; i<rows; i++)
array2d[i].resize(cols);
}
// * Retorna a quantidade de linhas do Array;
int countRow(){
return row;
}
// * Retorna a quantidade de colunas do Array;
int countCol(){
return col;
}
};
template <class T>
class Array3D
{
vector< vector <vector <T> > > array3d;
int col;
int row;
int depht;
public:
// * Construtor
Array3D(int row_, int col_, int dep_)
{
col = col_;
row = row_;
depht = dep_;
array3d.resize(row_);
for (int i=0; i<row_; i++)
{
array3d[i].resize(col_);
for (int j=0; j<col_; j++){
array3d[i][j].resize(dep_);
}
}
}
vector <vector<T> > & operator[](int index){
return array3d[index];
}
const vector< vector<T> > & operator[](int index) const{
return array3d[index];
}
// * Retorna a quantidade de linhas do Array;
int countRow(){
return row;
}
// * Retorna a quantidade de colunas do Array;
int countCol(){
return col;
}
// * Return the depht of the Array;
int countDepht(){
return depht;
}
};
| [
"Samuel@matschulat.(none)"
]
| [
[
[
1,
103
]
]
]
|
a61e7a4219144590f131d6f37a696c2c9bc5bb3d | a02276848c2bea89526819874c016ff17fc36104 | /MultiExplosionEmitter.h | 15a8bb8d44aa7cc5504109155c89ee59a102cc0c | []
| no_license | AnupGupta/geometrywarsreloaded | ec85ddc07ffd687d5d53c1c9abd4138f7ffcc141 | f6a615c05423c66433e8a85d3497e8386b618d0d | refs/heads/master | 2016-09-01T11:12:37.197796 | 2008-06-04T14:17:44 | 2008-06-04T14:17:44 | 44,064,867 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 518 | h | #ifndef MULTIEXPLOSIONEMITTER_H
#define MULTIEXPLOSIONEMITTER_H
#include "ParticleEmitter.h"
class Timer;
class MultiExplosionEmitter : public ParticleEmitter
{
public:
MultiExplosionEmitter();
~MultiExplosionEmitter();
private:
Timer* m_pFirstWaveEnd;
Timer* m_pSecondWaveEnd;
unsigned int m_uiWave;
bool InitCustomized();
void UpdateTimeDependentCustomized(float dt);
void SetInitialVelocity(Particle& particle);
void UpdateVelocity(float dt, Particle& particle);
};
#endif | [
"vkalpias@ff6a4cd7-4e4d-0410-b3e6-9b514b4d81ca"
]
| [
[
[
1,
27
]
]
]
|
75faf34a40e39c5717d4e1b861e9025b983313f8 | 3daaefb69e57941b3dee2a616f62121a3939455a | /mgllib/src/audio/MglOgg.h | a32f7a6c53c632110818ea1aca0c491d995e823c | []
| no_license | myun2ext/open-mgl-legacy | 21ccadab8b1569af8fc7e58cf494aaaceee32f1e | 8faf07bad37a742f7174b454700066d53a384eae | refs/heads/master | 2016-09-06T11:41:14.108963 | 2009-12-28T12:06:58 | 2009-12-28T12:06:58 | null | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 1,869 | h | //////////////////////////////////////////////////////////
//
// CMglOgg
// - エラー処理付き
//
//////////////////////////////////////////////////////////
#ifndef __MglOgg_H__
#define __MglOgg_H__
#include "MglBgmBase.h"
#include "Vox.h"
#define VOX_LOOP_MAX (0x7fffffff)
#define VOX_DEFAULT_VOLUME (1.0f)
// クラス宣言
class DLL_EXP CMglOgg : public CMglBgmBase, public CMyuReleaseBase
{
private:
HINSTANCE m_hDll;
Vox* m_pDriver;
BOOL m_loadFlg;
BOOL m_useFlg;
float m_fNowVolume;
// 初期化チェック
void InitCheck() {
if ( m_pDriver == NULL )
Init();
}
void LoadCheck() {
if ( m_loadFlg != TRUE )
MyuThrow( 0, "CMglOgg Load()を先に実行してください。" );
}
public:
CMglOgg();
virtual ~CMglOgg();
// 初期化/終端系
void Init( HWND hWnd = NULL );
void Release();
void Load( const char* szOggFile );
void UnLoad();
void Unload(){ UnLoad(); }
// 再生操作系
void Play( int nLoopCnt );
void Play(){ Play(VOX_LOOP_MAX); }
void LoopPlay( int nLoopCnt=VOX_LOOP_MAX ){
Play(nLoopCnt);
}
void StopLoop();
void Pause();
void SetVolume( float fVolume );
void Fade( float fTargetVolume, int nFadeTimeMs );
void FadeIn( int nFadeTimeMs ) { SetVolume(0); Fade( 1.0f, nFadeTimeMs ); }
void FadeOut( int nFadeTimeMs ) { Fade( 0, nFadeTimeMs ); }
void Stop();
void SetLastLoop(){ StopLoop(); }
void SetVolume( int nVolume=MGL_VOLUME_MAX ){ SetVolume(nVolume/100.0f); }
void SetBalance( int nBalance=MGL_PAN_CENTER ){}
void SeekTo( long nSeekTime, DWORD dwFlg=SEEK_SET );
void Enable() { m_useFlg = TRUE; }
void Disable() { m_useFlg = FALSE; }
Vox* GetVoxPtr() { return m_pDriver; }
};
//typedef CMglOgg CMglOgg;
//class CMglOgg : public CMglOgg{};
//typedef CMglOgg CMglMusic;
#endif//__MglOgg_H__
| [
"myun2@6d62ff88-fa28-0410-b5a4-834eb811a934"
]
| [
[
[
1,
79
]
]
]
|
df77bed0b66637014f83aae21d4548287399d0c4 | b2c66c8de198d9915dfc63b8c60cb82e57643a6b | /WordsCheater/trunk/Dictionary.cpp | 8e6f41d55b35d0d95e328ceeda320df849558419 | []
| no_license | feleio/words-with-friends-exhaustive-cheater | 88d6d401c28ef7bb82099c0cd9d77459828b89ca | bc198ee2677be02fc935fb8bb8e74b580f0540df | refs/heads/master | 2021-01-02T08:54:47.975272 | 2011-05-10T14:51:06 | 2011-05-10T14:51:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,052 | cpp | #include "Dictionary.h"
#include <fstream>
#include <regex>
#include <sstream>
Dictionary::Dictionary( const std::string& dictFilePath )
:m_dictionaryFile( )
{
std::ifstream ifs( dictFilePath );
if( !ifs )
throw std::invalid_argument( __FUNCTION__ "invalid dictionary file path " );
std::stringstream ss;
ss << ifs.rdbuf( );
m_dictionaryFile = ss.str();
ifs.close( );
}
bool Dictionary::IsStringValid( const std::string& str ) const
{
if( str.size() < 2 )
return false;
std::regex ex( std::string("^") + str + "$" );
return std::regex_search( m_dictionaryFile.begin(),
m_dictionaryFile.end(),
ex );
}
bool Dictionary::IsSubStringValid( const std::string& str ) const
{
if( str.size() < 2 )
return false;
std::regex ex( str );
return std::regex_search( m_dictionaryFile.begin(),
m_dictionaryFile.end(),
ex );
}
| [
"[email protected]@2165158a-c2d0-8582-d542-857db5896f79"
]
| [
[
[
1,
38
]
]
]
|
b4555bfc91883661465389c035a7b012dd8da6b4 | 8a3fce9fb893696b8e408703b62fa452feec65c5 | /业余时间学习笔记/IOCP/IOClient/Datablock/DataBlockPool.cpp | ec4f24eebaee9868367f07a2d97a7554030c35e6 | []
| no_license | win18216001/tpgame | bb4e8b1a2f19b92ecce14a7477ce30a470faecda | d877dd51a924f1d628959c5ab638c34a671b39b2 | refs/heads/master | 2021-04-12T04:51:47.882699 | 2011-03-08T10:04:55 | 2011-03-08T10:04:55 | 42,728,291 | 0 | 2 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 574 | cpp | #include "StdAfx.h"
#include "DataBlockPool.h"
CDataBlockPool::CDataBlockPool(long lMaxSize)
{
m_pBase = new BYTE [lMaxSize];
if(NULL == m_pBase)
{
printf(" CDataBlockPool ·ÖÅäÄÚ´æ³ö´í ");
}
m_nMaxSize = lMaxSize;
m_nCurSize = 0;
}
CDataBlockPool::~CDataBlockPool(void)
{
if( m_pBase != NULL)
{
delete [] m_pBase;
m_pBase = NULL;
}
}
void CDataBlockPool::SetCurSize(long lSize)
{
if( lSize < 0 )
m_nCurSize = 0;
else if( lSize > m_nMaxSize )
m_nCurSize = m_nMaxSize;
else
m_nCurSize = lSize;
}
| [
"[email protected]"
]
| [
[
[
1,
35
]
]
]
|
635e38535c00f09b2e7bd289e9367c100f8d6d2e | cd0987589d3815de1dea8529a7705caac479e7e9 | /webkit/WebKit2/UIProcess/Plugins/PluginInfoStore.h | ced2acf19ef11a80aeb51895698726654c8d0fca | []
| no_license | azrul2202/WebKit-Smartphone | 0aab1ff641d74f15c0623f00c56806dbc9b59fc1 | 023d6fe819445369134dee793b69de36748e71d7 | refs/heads/master | 2021-01-15T09:24:31.288774 | 2011-07-11T11:12:44 | 2011-07-11T11:12:44 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,315 | h | /*
* Copyright (C) 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef PluginInfoStore_h
#define PluginInfoStore_h
#include <WebCore/PluginData.h>
namespace WebCore {
class KURL;
}
namespace WebKit {
class PluginInfoStore {
public:
PluginInfoStore();
void setAdditionalPluginsDirectories(const Vector<WTF::String>&);
void refresh();
void getPlugins(Vector<WebCore::PluginInfo>& plugins);
// Represents a single plug-in.
struct Plugin {
WTF::String path;
WebCore::PluginInfo info;
#if PLATFORM(MAC)
cpu_type_t pluginArchitecture;
WTF::String bundleIdentifier;
unsigned versionNumber;
#endif
};
// Returns the info for a plug-in that can handle the given MIME type.
// If the MIME type is null, the file extension of the given url will be used to infer the
// plug-in type. In that case, mimeType will be filled in with the right MIME type.
Plugin findPlugin(WTF::String& mimeType, const WebCore::KURL& url);
private:
Plugin findPluginForMIMEType(const WTF::String& mimeType);
Plugin findPluginForExtension(const WTF::String& extension, WTF::String& mimeType);
void loadPluginsIfNecessary();
void loadPluginsInDirectory(const WTF::String& directory);
void loadPlugin(const WTF::String& pluginPath);
// Platform specific member functions.
static Vector<WTF::String> pluginsDirectories();
static Vector<WTF::String> pluginPathsInDirectory(const WTF::String& directory);
static bool getPluginInfo(const WTF::String& pluginPath, Plugin& plugin);
static bool shouldUsePlugin(const Plugin& plugin, const Vector<Plugin>& loadedPlugins);
static WTF::String getMIMETypeForExtension(const WTF::String& extension);
Vector<WTF::String> m_additionalPluginsDirectories;
Vector<Plugin> m_plugins;
bool m_pluginListIsUpToDate;
};
} // namespace WebKit
#endif // PluginInfoStore_h
| [
"[email protected]"
]
| [
[
[
1,
85
]
]
]
|
2d23663b70863fc6c323aace2f76ff1d5256dc31 | 222bc22cb0330b694d2c3b0f4b866d726fd29c72 | /src/brookbox/wm2/WmlPolynomialRootsDeg4.inl | 997797b67366268784a5a28e815b23e0ba9c080a | [
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | darwin/inferno | 02acd3d05ca4c092aa4006b028a843ac04b551b1 | e87017763abae0cfe09d47987f5f6ac37c4f073d | refs/heads/master | 2021-03-12T22:15:47.889580 | 2009-04-17T13:29:39 | 2009-04-17T13:29:39 | 178,477 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,151 | inl | // Magic Software, Inc.
// http://www.magic-software.com
// http://www.wild-magic.com
// Copyright (c) 2003. All Rights Reserved
//
// The Wild Magic Library (WML) source code is supplied under the terms of
// the license agreement http://www.magic-software.com/License/WildMagic.pdf
// and may not be copied or disclosed except in accordance with the terms of
// that agreement.
//----------------------------------------------------------------------------
template <class Real>
bool PolynomialRoots<Real>::FindA (Real fC0, Real fC1, Real fC2, Real fC3,
Real fC4)
{
if ( Math<Real>::FAbs(fC3) <= m_fEpsilon )
{
// polynomial is cubic
return FindA(fC0,fC1,fC2,fC3);
}
// make polynomial monic, x^4+c3*x^3+c2*x^2+c1*x+c0
Real fInvC4 = ((Real)1.0)/fC4;
fC0 *= fInvC4;
fC1 *= fInvC4;
fC2 *= fInvC4;
fC3 *= fInvC4;
// reduction to resolvent cubic polynomial y^3+r2*y^2+r1*y+r0 = 0
Real fR0 = -fC3*fC3*fC0 + ((Real)4.0)*fC2*fC0 - fC1*fC1;
Real fR1 = fC3*fC1 - ((Real)4.0)*fC0;
Real fR2 = -fC2;
FindA(fR0,fR1,fR2,(Real)1.0); // always produces at least one root
Real fY = m_afRoot[0];
m_iCount = 0;
Real fDiscr = ((Real)0.25)*fC3*fC3 - fC2 + fY;
if ( Math<Real>::FAbs(fDiscr) <= m_fEpsilon )
fDiscr = (Real)0.0;
if ( fDiscr > (Real)0.0 )
{
Real fR = Math<Real>::Sqrt(fDiscr);
Real fT1 = ((Real)0.75)*fC3*fC3 - fR*fR - ((Real)2.0)*fC2;
Real fT2 = (((Real)4.0)*fC3*fC2 - ((Real)8.0)*fC1 - fC3*fC3*fC3) /
(((Real)4.0)*fR);
Real fTplus = fT1+fT2;
Real fTminus = fT1-fT2;
if ( Math<Real>::FAbs(fTplus) <= m_fEpsilon )
fTplus = (Real)0.0;
if ( Math<Real>::FAbs(fTminus) <= m_fEpsilon )
fTminus = (Real)0.0;
if ( fTplus >= (Real)0.0 )
{
Real fD = Math<Real>::Sqrt(fTplus);
m_afRoot[0] = -((Real)0.25)*fC3+((Real)0.5)*(fR+fD);
m_afRoot[1] = -((Real)0.25)*fC3+((Real)0.5)*(fR-fD);
m_iCount += 2;
}
if ( fTminus >= (Real)0.0 )
{
Real fE = Math<Real>::Sqrt(fTminus);
m_afRoot[m_iCount++] = -((Real)0.25)*fC3+((Real)0.5)*(fE-fR);
m_afRoot[m_iCount++] = -((Real)0.25)*fC3-((Real)0.5)*(fE+fR);
}
}
else if ( fDiscr < (Real)0.0 )
{
m_iCount = 0;
}
else
{
Real fT2 = fY*fY-((Real)4.0)*fC0;
if ( fT2 >= -m_fEpsilon )
{
if ( fT2 < (Real)0.0 ) // round to zero
fT2 = (Real)0.0;
fT2 = ((Real)2.0)*Math<Real>::Sqrt(fT2);
Real fT1 = ((Real)0.75)*fC3*fC3 - ((Real)2.0)*fC2;
if ( fT1+fT2 >= m_fEpsilon )
{
Real fD = Math<Real>::Sqrt(fT1+fT2);
m_afRoot[0] = -((Real)0.25)*fC3+((Real)0.5)*fD;
m_afRoot[1] = -((Real)0.25)*fC3-((Real)0.5)*fD;
m_iCount += 2;
}
if ( fT1-fT2 >= m_fEpsilon )
{
Real fE = Math<Real>::Sqrt(fT1-fT2);
m_afRoot[m_iCount++] = -((Real)0.25)*fC3+((Real)0.5)*fE;
m_afRoot[m_iCount++] = -((Real)0.25)*fC3-((Real)0.5)*fE;
}
}
}
return m_iCount > 0;
}
//----------------------------------------------------------------------------
template <class Real>
bool PolynomialRoots<Real>::FindE (Real fC0, Real fC1, Real fC2, Real fC3,
Real fC4, bool bDoBalancing)
{
if ( Math<Real>::FAbs(fC4) <= m_fEpsilon )
{
// polynomial is cubic
return FindA(fC0,fC1,fC2,fC3);
}
// make polynomial monic, x^4+c3*x^3+c2*x^2+c1*x+c0
Real fInvC4 = ((Real)1.0)/fC4;
fC0 *= fInvC4;
fC1 *= fInvC4;
fC2 *= fInvC4;
fC3 *= fInvC4;
// construct the 4-by-4 companion matrix
GMatrix<Real> kMat(4,4); // initialized to zero
kMat[1][0] = (Real)1.0;
kMat[2][1] = (Real)1.0;
kMat[3][2] = (Real)1.0;
kMat[0][3] = -fC0;
kMat[1][3] = -fC1;
kMat[2][3] = -fC2;
kMat[3][3] = -fC3;
if ( bDoBalancing )
BalanceCompanion4(kMat);
return QRIteration4(kMat);
}
//----------------------------------------------------------------------------
template <class Real>
Real PolynomialRoots<Real>::GetBound (Real fC0, Real fC1, Real fC2, Real fC3,
Real fC4)
{
if ( Math<Real>::FAbs(fC4) <= m_fEpsilon )
{
// polynomial is cubic
return GetBound(fC0,fC1,fC2,fC3);
}
Real fInvC4 = ((Real)1.0)/fC4;
Real fMax = Math<Real>::FAbs(fC0)*fInvC4;
Real fTmp = Math<Real>::FAbs(fC1)*fInvC4;
if ( fTmp > fMax )
fMax = fTmp;
fTmp = Math<Real>::FAbs(fC2)*fInvC4;
if ( fTmp > fMax )
fMax = fTmp;
fTmp = Math<Real>::FAbs(fC3)*fInvC4;
if ( fTmp > fMax )
fMax = fTmp;
return (Real)1.0 + fMax;
}
//----------------------------------------------------------------------------
template <class Real>
bool PolynomialRoots<Real>::IsBalancedCompanion4 (Real fA10, Real fA21,
Real fA32, Real fA03, Real fA13, Real fA23, Real fA33)
{
const Real fTolerance = (Real)0.001;
// row/col 0
Real fRowNorm = fA03;
Real fColNorm = fA10;
Real fTest = Math<Real>::FAbs(1.0f - fColNorm/fRowNorm);
if ( fTest > fTolerance )
return false;
// row/col 1
fRowNorm = ( fA10 >= fA13 ? fA10 : fA13 );
fColNorm = fA21;
fTest = Math<Real>::FAbs(1.0f - fColNorm/fRowNorm);
if ( fTest > fTolerance )
return false;
// row/col 2
fRowNorm = ( fA21 >= fA23 ? fA21 : fA23 );
fColNorm = fA32;
fTest = Math<Real>::FAbs(1.0f - fColNorm/fRowNorm);
if ( fTest > fTolerance )
return false;
// row/col 3
fRowNorm = ( fA32 >= fA33 ? fA32 : fA33 );
fColNorm = ( fA03 >= fA13 ? fA03 : fA13 );
if ( fA23 > fColNorm )
fColNorm = fA23;
if ( fA33 > fColNorm )
fColNorm = fA33;
fTest = Math<Real>::FAbs(1.0f - fColNorm/fRowNorm);
return fTest <= fTolerance;
}
//----------------------------------------------------------------------------
template <class Real>
void PolynomialRoots<Real>::BalanceCompanion4 (GMatrix<Real>& rkMat)
{
Real fA10 = Math<Real>::FAbs(rkMat[1][0]);
Real fA21 = Math<Real>::FAbs(rkMat[2][1]);
Real fA32 = Math<Real>::FAbs(rkMat[3][2]);
Real fA03 = Math<Real>::FAbs(rkMat[0][3]);
Real fA13 = Math<Real>::FAbs(rkMat[1][3]);
Real fA23 = Math<Real>::FAbs(rkMat[2][3]);
Real fA33 = Math<Real>::FAbs(rkMat[3][3]);
Real fRowNorm, fColNorm, fScale, fInvScale;
const int iMax = 16;
int i;
for (i = 0; i < iMax; i++)
{
// balance row/col 0
fRowNorm = fA03;
fColNorm = fA10;
fScale = Math<Real>::Sqrt(fColNorm/fRowNorm);
fA03 *= fScale;
fA10 = fA03;
// balance row/col 1
fRowNorm = ( fA10 >= fA13 ? fA10 : fA13 );
fColNorm = fA21;
fScale = Math<Real>::Sqrt(fColNorm/fRowNorm);
fInvScale = ((Real)1.0)/fScale;
fA10 *= fScale;
fA13 *= fScale;
fA21 *= fInvScale;
// balance row/col 2
fRowNorm = ( fA21 >= fA23 ? fA21 : fA23 );
fColNorm = fA32;
fScale = Math<Real>::Sqrt(fColNorm/fRowNorm);
fInvScale = ((Real)1.0)/fScale;
fA21 *= fScale;
fA23 *= fScale;
fA32 *= fInvScale;
// balance row/col 3
fRowNorm = ( fA32 >= fA33 ? fA32 : fA33 );
fColNorm = ( fA03 >= fA13 ? fA03 : fA13 );
if ( fA23 > fColNorm )
fColNorm = fA23;
if ( fA33 > fColNorm )
fColNorm = fA33;
fScale = Math<Real>::Sqrt(fColNorm/fRowNorm);
fInvScale = ((Real)1.0)/fScale;
fA32 *= fScale;
fA03 *= fInvScale;
fA13 *= fInvScale;
fA23 *= fInvScale;
if ( IsBalancedCompanion4(fA10,fA21,fA32,fA03,fA13,fA23,fA33) )
break;
}
assert( i < iMax );
rkMat[1][0] = ( rkMat[1][0] >= (Real)0.0 ? fA10 : -fA10);
rkMat[2][1] = ( rkMat[2][1] >= (Real)0.0 ? fA21 : -fA21);
rkMat[3][2] = ( rkMat[3][2] >= (Real)0.0 ? fA32 : -fA32);
rkMat[0][3] = ( rkMat[0][3] >= (Real)0.0 ? fA03 : -fA03);
rkMat[1][3] = ( rkMat[1][3] >= (Real)0.0 ? fA13 : -fA13);
rkMat[2][3] = ( rkMat[2][3] >= (Real)0.0 ? fA23 : -fA23);
rkMat[3][3] = ( rkMat[3][3] >= (Real)0.0 ? fA33 : -fA33);
}
//----------------------------------------------------------------------------
template <class Real>
bool PolynomialRoots<Real>::QRIteration4 (GMatrix<Real>& rkMat)
{
GVector<Real> kW(4);
GMatrix<Real> kMS(3,3);
Real fRHS, fTrace, fDet, afSaveRoot[2];
int i, j, iSaveCount;
for (i = 0; i < m_iMaxIterations; i++)
{
fRHS = m_fEpsilon*(Math<Real>::FAbs(rkMat[0][0]) +
Math<Real>::FAbs(rkMat[1][1]));
if ( Math<Real>::FAbs(rkMat[1][0]) <= fRHS )
{
// mat[0][0] is a root, reduce the 3-by-3 submatrix
// TO DO: Avoid the copy and pass row/column offsets to the
// FrancisQR method.
kMS[0][0] = rkMat[1][1];
kMS[0][1] = rkMat[1][2];
kMS[0][2] = rkMat[1][3];
kMS[1][0] = rkMat[2][1];
kMS[1][1] = rkMat[2][2];
kMS[1][2] = rkMat[2][3];
kMS[2][0] = rkMat[3][1];
kMS[2][1] = rkMat[3][2];
kMS[2][2] = rkMat[3][3];
QRIteration3(kMS);
m_afRoot[m_iCount++] = rkMat[0][0];
return true;
}
fRHS = m_fEpsilon*(Math<Real>::FAbs(rkMat[1][1]) +
Math<Real>::FAbs(rkMat[2][2]));
if ( Math<Real>::FAbs(rkMat[2][1]) <= fRHS )
{
// The matrix is decoupled into two 2-by-2 blocks. Solve the
// quadratics for the blocks.
fTrace = rkMat[0][0] + rkMat[1][1];
fDet = rkMat[0][0]*rkMat[1][1] - rkMat[0][1]*rkMat[1][0];
FindA(fDet,-fTrace,(Real)1.0);
iSaveCount = m_iCount;
for (j = 0; j < iSaveCount; j++)
afSaveRoot[j] = m_afRoot[j];
fTrace = rkMat[2][2] + rkMat[3][3];
fDet = rkMat[2][2]*rkMat[3][3] - rkMat[2][3]*rkMat[3][2];
FindA(fDet,-fTrace,(Real)1.0);
for (j = 0; j < iSaveCount; j++)
m_afRoot[m_iCount++] = afSaveRoot[j];
return m_iCount > 0;
}
fRHS = m_fEpsilon*(Math<Real>::FAbs(rkMat[2][2]) +
Math<Real>::FAbs(rkMat[3][3]));
if ( Math<Real>::FAbs(rkMat[3][2]) <= fRHS )
{
// mat[3][3] is a root, reduce the 3-by-3 submatrix
// TO DO: Avoid the copy and pass row/column offsets to the
// FrancisQR method.
kMS[0][0] = rkMat[0][0];
kMS[0][1] = rkMat[0][1];
kMS[0][2] = rkMat[0][2];
kMS[1][0] = rkMat[1][0];
kMS[1][1] = rkMat[1][1];
kMS[1][2] = rkMat[1][2];
kMS[2][0] = rkMat[2][0];
kMS[2][1] = rkMat[2][1];
kMS[2][2] = rkMat[2][2];
QRIteration3(kMS);
m_afRoot[m_iCount++] = rkMat[3][3];
return true;
}
FrancisQRStep(rkMat,kW);
}
// TO DO: What to do if the maximum iterations were exceeded? Maybe a
// random perturbation to "kick" the system a bit might work?
//
// If you want to trap exceeding the maximum iterations, uncomment the
// 'assert' line of code.
//
// assert( false );
// For now, decouple the matrix using the smallest subdiagonal entry.
i = 0;
Real fMin = Math<Real>::FAbs(rkMat[1][0]);
Real fAbs = Math<Real>::FAbs(rkMat[2][1]);
if ( fAbs < fMin )
{
fMin = fAbs;
i = 1;
}
fAbs = Math<Real>::FAbs(rkMat[3][2]);
if ( fAbs < fMin )
{
fMin = fAbs;
i = 2;
}
if ( i == 0 )
{
// mat[0][0] is a root, reduce the 3-by-3 submatrix
// TO DO: Avoid the copy and pass row/column offsets to the
// FrancisQR method.
kMS[0][0] = rkMat[1][1];
kMS[0][1] = rkMat[1][2];
kMS[0][2] = rkMat[1][3];
kMS[1][0] = rkMat[2][1];
kMS[1][1] = rkMat[2][2];
kMS[1][2] = rkMat[2][3];
kMS[2][0] = rkMat[3][1];
kMS[2][1] = rkMat[3][2];
kMS[2][2] = rkMat[3][3];
QRIteration3(kMS);
m_afRoot[m_iCount++] = rkMat[0][0];
}
else if ( i == 1 )
{
// The matrix is decoupled into two 2-by-2 blocks. Solve the
// quadratics for the blocks.
fTrace = rkMat[0][0] + rkMat[1][1];
fDet = rkMat[0][0]*rkMat[1][1] - rkMat[0][1]*rkMat[1][0];
FindA(fDet,-fTrace,(Real)1.0);
iSaveCount = m_iCount;
for (j = 0; j < iSaveCount; j++)
afSaveRoot[j] = m_afRoot[j];
fTrace = rkMat[2][2] + rkMat[3][3];
fDet = rkMat[2][2]*rkMat[3][3] - rkMat[2][3]*rkMat[3][2];
FindA(fDet,-fTrace,(Real)1.0);
for (j = 0; j < iSaveCount; j++)
m_afRoot[m_iCount++] = afSaveRoot[j];
}
else // i == 2
{
// mat[3][3] is a root, reduce the 3-by-3 submatrix
// TO DO: Avoid the copy and pass row/column offsets to the
// FrancisQR method.
kMS[0][0] = rkMat[0][0];
kMS[0][1] = rkMat[0][1];
kMS[0][2] = rkMat[0][2];
kMS[1][0] = rkMat[1][0];
kMS[1][1] = rkMat[1][1];
kMS[1][2] = rkMat[1][2];
kMS[2][0] = rkMat[2][0];
kMS[2][1] = rkMat[2][1];
kMS[2][2] = rkMat[2][2];
QRIteration3(kMS);
m_afRoot[m_iCount++] = rkMat[3][3];
}
return m_iCount > 0;
}
//----------------------------------------------------------------------------
| [
"[email protected]"
]
| [
[
[
1,
425
]
]
]
|
63b8c017d00b0bb1e6d17d9524ac20c17bbfafe3 | 836523304390560c1b0b655888a4abef63a1b4a5 | /util/base64util.cpp | 86b4ec1cf98dcf56e02bb3b0687712babaa1398c | []
| no_license | paranoiagu/UDSOnlineEditor | 4675ed403fe5acf437ff034a17f3eaa932e7b780 | 7eaae6fef51a01f09d28021ca6e6f2affa7c9658 | refs/heads/master | 2021-01-11T03:19:59.238691 | 2011-10-03T06:02:35 | 2011-10-03T06:02:35 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 3,855 | cpp | #include "stdafx.h"
#include "base64util.h"
#include <string> // 使用 string 类时须包含这个文件
#include <iostream>
using namespace std;
namespace base64util {
char ntc(unsigned char n){
if (n<26) return 'A'+n;
if (n<52) return 'a'-26+n;
if (n<62) return '0'-52+n;
if (n==62) return '+';
return '/';
}
unsigned char ctn(char c){
if (c=='/') return 63;
if (c=='+') return 62;
if ((c>='A')&&(c<='Z')) return c-'A';
if ((c>='a')&&(c<='z')) return c-'a'+26;
if ((c>='0')&&(c<='9')) return c-'0'+52;
if (c=='=') return 80;
return 100;
}
int b64encode(const char *from,char *to,int length,int quads){
// 3 个byte转换为四个字符
int i =0;
char *tot=to;
int qc=0; // Quadcount
unsigned char c;
unsigned char d;
while(i<length) {
c=from[i];
*to++=ntc(c/4);
c=c*64;
i++;
if (i>=length) {
*to++=ntc(c/4);
*to++='=';
*to++='=';
break;
}
d=from[i];
*to++=ntc(c/4+d/16);
d=d*16;
i++;
if (i>=length) {
*to++=ntc(d/4);
*to++='=';
break;
}
c=from[i];
*to++=ntc(d/4+c/64);
c=c*4;
i++;
*to++=ntc(c/4);
qc++; // qz will never be zero, quads = 0 means no linebreaks
if (qc==quads){
*to++='\n';
qc=0;
}
}
// if ((quads!=0)&&(qc!=0)) *to++='\n'; // Insert last linebreak
return to-tot;
}
int b64decode(char *from,char *to,int length){
unsigned char c,d,e,f;
char A,B,C;
int i;
int add;
char *tot=to;
for (i=0;i+3<length;){
add=0;
A=B=C=0;
c=d=e=f=100;
while ((c==100)&&(i<length)) c=ctn(from[i++]);
while ((d==100)&&(i<length)) d=ctn(from[i++]);
while ((e==100)&&(i<length)) e=ctn(from[i++]);
while ((f==100)&&(i<length)) f=ctn(from[i++]);
if (f==100) return -1; // Not valid end
if (c<64)
{
A+=c*4;
if (d<64)
{
A+=d/16;
B+=d*16;
if (e<64)
{
B+=e/4;
C+=e*64;
if (f<64)
{
C+=f;
to[2]=C;
add+=1;
}
to[1]=B;
add+=1;
}
to[0]=A;
add+=1;
}
}
to+=add;
if (f==80) return to-tot; // end because '=' encountered
}
return to-tot;
}
int b64get_encode_buffer_size(int l,int q){
int ret;
ret = (l/3)*4;
if (l%3!=0) ret +=4;
if (q!=0)
{
ret += (ret/(q*4));
// if (ret%(q/4)!=0) ret ++; // Add space for trailing \n
}
return ret;
}
int b64strip_encoded_buffer(char *buf,int length){
int i;
int ret=0;
for (i=0;i<length;i++) if (ctn(buf[i])!=100) buf[ret++] = buf [i];
return ret;
}
int ToHexString(char *crOut, BYTE *btIn, int size)
{
char hexChars[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F' };
int height = 0;
int low = 0;
//BYTE bh = 0;
//BYTE bl = 0;
//TCHAR ds[100];
for (int i = 0; i < size; i++)
{
height = (btIn[i] & 0xf0) >> 4;
//memset(ds,0, sizeof(ds));
//wsprintf(ds,_T("%d"), height);
//MessageBox(GetForegroundWindow(),ds,_T("亿榕公文交换平台提示"),MB_OK|MB_ICONINFORMATION);
low = btIn[i] & 0x0f;
//memset(ds,0, sizeof(ds));
//wsprintf(ds, _T("%d"), low);
//MessageBox(GetForegroundWindow(),ds,_T("亿榕公文交换平台提示"),MB_OK|MB_ICONINFORMATION);
crOut[i*2] = hexChars[height];
crOut[i*2 + 1] = hexChars[low];
}
return 0;
}
int ToByteArray(BYTE *btOut, char *crIn, int intsize)
{
string str("0123456789ABCDEF");
int len = intsize / 2;
for (int i = 0; i < len; i++)
{
int hpos = str.find(crIn[i*2]);
int lpos = str.find(crIn[i*2 + 1]);
btOut[i] = (BYTE)(hpos << 4 | lpos);
}
return 0;
}
} | [
"[email protected]"
]
| [
[
[
1,
190
]
]
]
|
fa1ae95e52165aa8c93dbbfdd94c414b6bcb5b31 | 6bdb3508ed5a220c0d11193df174d8c215eb1fce | /Codes/Halak/Geom2D.inl | 7c9078d56c58677060b62d6c2c4adfa415e01b1d | []
| no_license | halak/halak-plusplus | d09ba78640c36c42c30343fb10572c37197cfa46 | fea02a5ae52c09ff9da1a491059082a34191cd64 | refs/heads/master | 2020-07-14T09:57:49.519431 | 2011-07-09T14:48:07 | 2011-07-09T14:48:07 | 66,716,624 | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 1,654 | inl | #include <Halak/Math.h>
namespace Halak
{
bool Geom2D::IntersectPointSegment(Vector2 p, Vector2 a, Vector2 b)
{
return GetPointSegmentDistanceSquared(p, a, b) < 0.01f; // ±Ù»ç °ª
}
////////////////////////////////////////////////////////////////////////////////////////////////////
bool Geom2D::IntersectPointBox(Vector2 p, Vector2 origin, Vector2 axisX, Vector2 axisY, Vector2 extension)
{
return Math::Equals(p, GetPointBoxClosestPoint(p, origin, axisX, axisY, extension));
}
Vector2 Geom2D::GetPointBoxClosestPoint(Vector2 p, Vector2 origin, Vector2 axisX, Vector2 axisY, Vector2 extension)
{
const Vector2 d = p - origin;
return origin + (axisX * Math::Clamp(d.Dot(axisX), -extension.X, +extension.X)) + (axisY * Math::Clamp(d.Dot(axisY), -extension.Y, +extension.Y));
}
////////////////////////////////////////////////////////////////////////////////////////////////////
bool Geom2D::IntersectSegmentSegment(Vector2 a, Vector2 b, Vector2 c, Vector2 d)
{
float t = 0.0f;
return IntersectSegmentSegment(a, b, c, d, t);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
bool Geom2D::IntersectAxisAlignedBoxAxisAlignedBox(Vector2 leftTop1, Vector2 rightBottom1, Vector2 leftTop2, Vector2 rightBottom2)
{
if (rightBottom1.X < leftTop2.X || leftTop1.X > rightBottom2.X)
return false;
if (rightBottom1.Y < leftTop2.Y || leftTop1.Y > rightBottom2.Y)
return false;
return true;
}
} | [
"[email protected]"
]
| [
[
[
1,
42
]
]
]
|
641a040a36fc6592d0ff13bae95223ebc0bb7dee | 011359e589f99ae5fe8271962d447165e9ff7768 | /src/burn/zet_c68k.cpp | a3c2922726cb2869320807d159b7520317253b1c | []
| no_license | PS3emulators/fba-next-slim | 4c753375fd68863c53830bb367c61737393f9777 | d082dea48c378bddd5e2a686fe8c19beb06db8e1 | refs/heads/master | 2021-01-17T23:05:29.479865 | 2011-12-01T18:16:02 | 2011-12-01T18:16:02 | 2,899,840 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 21,020 | cpp | // Z80 (Zed Eight-Ty) Interface
#include "burnint.h"
#ifdef EMU_CZ80
#include "cz80.c"
#endif
#ifdef EMU_DOZE
static DozeContext * ZetCPUContext = NULL;
#endif // EMU_DOZE
#ifdef EMU_MAME_Z80
static struct ZetExt * ZetCPUContext = NULL;
static struct ZetExt * lastZetCPUContext = NULL;
#endif
#ifdef EMU_CZ80
static cz80_struc * ZetCPUContext = NULL;
static cz80_struc * lastZetCPUContext = NULL;
#endif
static int nOpenedCPU = -1;
static int nCPUCount = 0;
int nHasZet = -1;
unsigned char __fastcall ZetDummyReadHandler(unsigned short) { return 0; }
void __fastcall ZetDummyWriteHandler(unsigned short, unsigned char) { }
unsigned char __fastcall ZetDummyInHandler(unsigned short) { return 0; }
void __fastcall ZetDummyOutHandler(unsigned short, unsigned char) { }
#ifdef EMU_MAME_Z80
unsigned char __fastcall ZetReadIO(unsigned int a)
{
return lastZetCPUContext->ZetIn(a);
}
void __fastcall ZetWriteIO(unsigned int a, unsigned char d)
{
lastZetCPUContext->ZetOut(a, d);
}
unsigned char __fastcall ZetReadProg(unsigned int a)
{
unsigned char *pr = lastZetCPUContext->pZetMemMap[0x000 + (a >> 8)];
if (pr != NULL) return pr[a & 0xff];
return lastZetCPUContext->ZetRead(a);
}
void __fastcall ZetWriteProg(unsigned int a, unsigned char d)
{
unsigned char *pr = lastZetCPUContext->pZetMemMap[0x100 + (a >> 8)];
if (pr != NULL) {
pr[a & 0xff] = d;
return;
}
lastZetCPUContext->ZetWrite(a, d);
// bprintf(PRINT_NORMAL, _T("Write %x, %x\n"), a, d);
}
unsigned char __fastcall ZetReadOp(unsigned int a)
{
unsigned char *pr = lastZetCPUContext->pZetMemMap[0x200 + (a >> 8)];
if (pr != NULL) return pr[a & 0xff];
bprintf(PRINT_NORMAL, _T("Op Read %x\n"), a);
return 0;
}
unsigned char __fastcall ZetReadOpArg(unsigned int a)
{
unsigned char *pr = lastZetCPUContext->pZetMemMap[0x300 + (a >> 8)];
if (pr != NULL) return pr[a & 0xff];
bprintf(PRINT_NORMAL, _T("Op Arg Read %x\n"), a);
return 0;
}
#endif
#ifdef EMU_DOZE
void ZetSetReadHandler(unsigned char (__fastcall *pHandler)(unsigned short))
{
Doze.ReadHandler = pHandler;
}
void ZetSetWriteHandler(void (__fastcall *pHandler)(unsigned short, unsigned char))
{
Doze.WriteHandler = pHandler;
}
void ZetSetInHandler(unsigned char (__fastcall *pHandler)(unsigned short))
{
Doze.InHandler = pHandler;
}
void ZetSetOutHandler(void (__fastcall *pHandler)(unsigned short, unsigned char))
{
Doze.OutHandler = pHandler;
}
#endif
#ifdef EMU_MAME_Z80
void ZetSetReadHandler(unsigned char (__fastcall *pHandler)(unsigned short))
{
lastZetCPUContext->ZetRead = pHandler;
}
void ZetSetWriteHandler(void (__fastcall *pHandler)(unsigned short, unsigned char))
{
lastZetCPUContext->ZetWrite = pHandler;
}
void ZetSetInHandler(unsigned char (__fastcall *pHandler)(unsigned short))
{
lastZetCPUContext->ZetIn = pHandler;
}
void ZetSetOutHandler(void (__fastcall *pHandler)(unsigned short, unsigned char))
{
lastZetCPUContext->ZetOut = pHandler;
}
#endif
#ifdef EMU_CZ80
void ZetSetReadHandler(unsigned char (__fastcall *pHandler)(unsigned short))
{
lastZetCPUContext->Read_Byte = pHandler;
}
void ZetSetWriteHandler(void (__fastcall *pHandler)(unsigned short, unsigned char))
{
lastZetCPUContext->Write_Byte = pHandler;
}
void ZetSetInHandler(unsigned char (__fastcall *pHandler)(unsigned short))
{
lastZetCPUContext->IN_Port = pHandler;
}
void ZetSetOutHandler(void (__fastcall *pHandler)(unsigned short, unsigned char))
{
lastZetCPUContext->OUT_Port = pHandler;
}
#endif
void ZetNewFrame()
{
#ifdef EMU_DOZE
for (int i = 0; i < nCPUCount; i++) {
ZetCPUContext[i].nCyclesTotal = 0;
}
Doze.nCyclesTotal = 0;
#endif
#ifdef EMU_MAME_Z80
for (int i = 0; i < nCPUCount; i++) {
ZetCPUContext[i].nCyclesTotal = 0;
}
#endif
#ifdef EMU_CZ80
for (int i = 0; i < nCPUCount; i++) {
ZetCPUContext[i].nCyclesTotal = 0;
}
#endif
}
void ZetSetVector(int vector)
{
int Z80Vector = 0;
Z80Vector = vector;
}
int ZetInit(int nCount)
{
#ifdef EMU_DOZE
ZetCPUContext = (DozeContext*)malloc(nCount * sizeof(DozeContext));
if (ZetCPUContext == NULL) {
return 1;
}
memset(ZetCPUContext, 0, nCount * sizeof(DozeContext));
for (int i = 0; i < nCount; i++) {
ZetCPUContext[i].nInterruptLatch = -1;
ZetCPUContext[i].ReadHandler = ZetDummyReadHandler;
ZetCPUContext[i].WriteHandler = ZetDummyWriteHandler;
ZetCPUContext[i].InHandler = ZetDummyInHandler;
ZetCPUContext[i].OutHandler = ZetDummyOutHandler;
ZetCPUContext[i].ppMemFetch = (unsigned char**)malloc(0x0100 * sizeof(char*));
ZetCPUContext[i].ppMemFetchData = (unsigned char**)malloc(0x0100 * sizeof(char*));
ZetCPUContext[i].ppMemRead = (unsigned char**)malloc(0x0100 * sizeof(char*));
ZetCPUContext[i].ppMemWrite = (unsigned char**)malloc(0x0100 * sizeof(char*));
if (ZetCPUContext[i].ppMemFetch == NULL || ZetCPUContext[i].ppMemFetchData == NULL || ZetCPUContext[i].ppMemRead == NULL || ZetCPUContext[i].ppMemWrite == NULL) {
ZetExit();
return 1;
}
for (int j = 0; j < 0x0100; j++) {
ZetCPUContext[i].ppMemFetch[j] = NULL;
ZetCPUContext[i].ppMemFetchData[j] = NULL;
ZetCPUContext[i].ppMemRead[j] = NULL;
ZetCPUContext[i].ppMemWrite[j] = NULL;
}
}
ZetOpen(0);
nCPUCount = nCount;
#endif
#ifdef EMU_MAME_Z80
ZetCPUContext = (struct ZetExt *) malloc(nCount * sizeof(struct ZetExt));
if (ZetCPUContext == NULL) return 1;
memset(ZetCPUContext, 0, nCount * sizeof(struct ZetExt));
Z80Init();
for (int i = 0; i < nCount; i++) {
ZetCPUContext[i].ZetIn = ZetDummyInHandler;
ZetCPUContext[i].ZetOut = ZetDummyOutHandler;
ZetCPUContext[i].ZetRead = ZetDummyReadHandler;
ZetCPUContext[i].ZetWrite = ZetDummyWriteHandler;
// TODO: Z80Init() will set IX IY F regs with default value, so get them ...
Z80GetContext(& (ZetCPUContext[i].reg) );
}
Z80SetIOReadHandler(ZetReadIO);
Z80SetIOWriteHandler(ZetWriteIO);
Z80SetProgramReadHandler(ZetReadProg);
Z80SetProgramWriteHandler(ZetWriteProg);
Z80SetCPUOpReadHandler(ZetReadOp);
Z80SetCPUOpArgReadHandler(ZetReadOpArg);
ZetOpen(0);
nCPUCount = nCount;
#endif
#ifdef EMU_CZ80
ZetCPUContext = (cz80_struc *) malloc(nCount * sizeof(cz80_struc));
if (ZetCPUContext == NULL) return 1;
Cz80_InitFlags();
//memset(ZetCPUContext, 0, nCount * sizeof(cz80_struc));
for (int i = 0; i < nCount; i++) {
Cz80_Init( &ZetCPUContext[i] );
ZetCPUContext[i].nInterruptLatch = -1;
ZetCPUContext[i].IN_Port = ZetDummyInHandler;
ZetCPUContext[i].OUT_Port = ZetDummyOutHandler;
ZetCPUContext[i].Read_Byte = ZetDummyReadHandler;
ZetCPUContext[i].Write_Byte = ZetDummyWriteHandler;
}
ZetOpen(0);
nCPUCount = nCount;
#endif
nHasZet = nCount;
return 0;
}
unsigned char ZetReadByte(unsigned short address)
{
if (nOpenedCPU < 0) return 0;
#ifdef EMU_DOZE
if (ZetCPUContext[nOpenedCPU].ppMemRead[address>>8] != NULL) {
return ZetCPUContext[nOpenedCPU].ppMemRead[address>>8][address];
}
if (ZetCPUContext[nOpenedCPU].ReadHandler != NULL) {
return ZetCPUContext[nOpenedCPU].ReadHandler(address);
}
#endif
return 0;
}
void ZetWriteRom(unsigned short address, unsigned char data)
{
if (nOpenedCPU < 0) return;
}
void ZetWriteByte(unsigned short address, unsigned char data)
{
if (nOpenedCPU < 0) return;
#ifdef EMU_DOZE
if (ZetCPUContext[nOpenedCPU].ppMemWrite[address>>8] != NULL) {
ZetCPUContext[nOpenedCPU].ppMemWrite[address>>8][address] = data;
}
if (ZetCPUContext[nOpenedCPU].WriteHandler != NULL) {
ZetCPUContext[nOpenedCPU].WriteHandler(address, data);
}
#endif
}
void ZetClose()
{
#ifdef EMU_DOZE
ZetCPUContext[nOpenedCPU] = Doze;
#endif
#ifdef EMU_MAME_Z80
// Set handlers here too
if (nOpenedCPU >= 0)
Z80GetContext(&(ZetCPUContext[nOpenedCPU].reg));
#endif
#ifdef EMU_CZ80
//
#endif
nOpenedCPU = -1;
}
int ZetOpen(int nCPU)
{
#ifdef EMU_DOZE
Doze = ZetCPUContext[nCPU];
#endif
#ifdef EMU_MAME_Z80
// Set handlers here too
Z80SetContext(&ZetCPUContext[nCPU].reg);
lastZetCPUContext = &ZetCPUContext[nCPU];
#endif
#ifdef EMU_CZ80
lastZetCPUContext = &ZetCPUContext[nCPU];
#endif
nOpenedCPU = nCPU;
return 0;
}
int ZetGetActive()
{
return nOpenedCPU;
}
int ZetRun(int nCycles)
{
if (nCycles <= 0||ZetCPUContext==0) return 0;
#ifdef EMU_DOZE
Doze.nCyclesTotal += nCycles;
Doze.nCyclesSegment = nCycles;
Doze.nCyclesLeft = nCycles;
DozeRun();
nCycles = Doze.nCyclesSegment - Doze.nCyclesLeft;
Doze.nCyclesTotal -= Doze.nCyclesLeft;
Doze.nCyclesLeft = 0;
Doze.nCyclesSegment = 0;
return nCycles;
#endif
#ifdef EMU_MAME_Z80
lastZetCPUContext->nCyclesTotal += nCycles;
lastZetCPUContext->nCyclesSegment = nCycles;
lastZetCPUContext->nCyclesLeft = nCycles;
nCycles = Z80Execute(nCycles);
lastZetCPUContext->nCyclesLeft = lastZetCPUContext->nCyclesLeft - nCycles;
lastZetCPUContext->nCyclesTotal -= lastZetCPUContext->nCyclesLeft;
lastZetCPUContext->nCyclesLeft = 0;
lastZetCPUContext->nCyclesSegment = 0;
return nCycles;
#endif
#ifdef EMU_CZ80
lastZetCPUContext->nCyclesTotal += nCycles;
lastZetCPUContext->nCyclesSegment = nCycles;
lastZetCPUContext->nCyclesLeft = nCycles;
nCycles = Cz80_Exec(lastZetCPUContext);
//nCycles = Doze.nCyclesSegment - Doze.nCyclesLeft;
lastZetCPUContext->nCyclesTotal -= lastZetCPUContext->nCyclesLeft;
lastZetCPUContext->nCyclesLeft = 0;
lastZetCPUContext->nCyclesSegment = 0;
return nCycles;
#endif
}
void ZetRunAdjust(int nCycles)
{
#ifdef EMU_DOZE
if (nCycles < 0 && Doze.nCyclesLeft < -nCycles) {
nCycles = 0;
}
Doze.nCyclesTotal += nCycles;
Doze.nCyclesSegment += nCycles;
Doze.nCyclesLeft += nCycles;
#endif
#ifdef EMU_MAME_Z80
if (nCycles < 0 && lastZetCPUContext->nCyclesLeft < -nCycles) {
nCycles = 0;
}
lastZetCPUContext->nCyclesTotal += nCycles;
lastZetCPUContext->nCyclesSegment += nCycles;
lastZetCPUContext->nCyclesLeft += nCycles;
#endif
#ifdef EMU_CZ80
if (nCycles < 0 && lastZetCPUContext->nCyclesLeft < -nCycles) {
nCycles = 0;
}
lastZetCPUContext->nCyclesTotal += nCycles;
lastZetCPUContext->nCyclesSegment += nCycles;
lastZetCPUContext->nCyclesLeft += nCycles;
#endif
}
void ZetRunEnd()
{
#ifdef EMU_DOZE
Doze.nCyclesTotal -= Doze.nCyclesLeft;
Doze.nCyclesSegment -= Doze.nCyclesLeft;
Doze.nCyclesLeft = 0;
#endif
#ifdef EMU_MAME_Z80
lastZetCPUContext->nCyclesTotal -= lastZetCPUContext->nCyclesLeft;
lastZetCPUContext->nCyclesSegment -= lastZetCPUContext->nCyclesLeft;
lastZetCPUContext->nCyclesLeft = 0;
#endif
#ifdef EMU_CZ80
lastZetCPUContext->nCyclesTotal -= lastZetCPUContext->nCyclesLeft;
lastZetCPUContext->nCyclesSegment -= lastZetCPUContext->nCyclesLeft;
lastZetCPUContext->nCyclesLeft = 0;
#endif
}
// This function will make an area callback ZetRead/ZetWrite
int ZetMemCallback(int nStart, int nEnd, int nMode)
{
#ifdef EMU_DOZE
nStart >>= 8;
nEnd += 0xff;
nEnd >>= 8;
// Leave the section out of the memory map, so the Doze* callback with be used
for (int i = nStart; i < nEnd; i++) {
switch (nMode) {
case 0:
Doze.ppMemRead[i] = NULL;
break;
case 1:
Doze.ppMemWrite[i] = NULL;
break;
case 2:
Doze.ppMemFetch[i] = NULL;
break;
}
}
#endif
#ifdef EMU_MAME_Z80
unsigned char cStart = (nStart >> 8);
unsigned char **pMemMap = lastZetCPUContext->pZetMemMap;
for (unsigned short i = cStart; i <= (nEnd >> 8); i++) {
switch (nMode) {
case 0:
pMemMap[0 + i] = NULL;
break;
case 1:
pMemMap[0x100 + i] = NULL;
break;
case 2:
pMemMap[0x200 + i] = NULL;
//pMemMap[0x300 + i] = NULL;
break;
}
}
#endif
#ifdef EMU_CZ80
nStart >>= CZ80_FETCH_SFT;
nEnd += CZ80_FETCH_BANK - 1;
nEnd >>= CZ80_FETCH_SFT;
// Leave the section out of the memory map, so the callback with be used
for (int i = nStart; i < nEnd; i++) {
switch (nMode) {
case 0:
lastZetCPUContext->Read[i] = NULL;
break;
case 1:
lastZetCPUContext->Write[i] = NULL;
break;
case 2:
lastZetCPUContext->Fetch[i] = NULL;
break;
}
}
#endif
return 0;
}
int ZetMemEnd()
{
return 0;
}
void ZetExit()
{
#ifdef EMU_DOZE
for (int i = 0; i < nCPUCount; i++) {
free(ZetCPUContext[i].ppMemFetch);
ZetCPUContext[i].ppMemFetch = NULL;
free(ZetCPUContext[i].ppMemFetchData);
ZetCPUContext[i].ppMemFetchData = NULL;
free(ZetCPUContext[i].ppMemRead);
ZetCPUContext[i].ppMemRead = NULL;
free(ZetCPUContext[i].ppMemWrite);
ZetCPUContext[i].ppMemWrite = NULL;
}
free(ZetCPUContext);
ZetCPUContext = NULL;
#endif
#ifdef EMU_MAME_Z80
Z80Exit();
free( ZetCPUContext );
ZetCPUContext = NULL;
lastZetCPUContext = NULL;
#endif
#ifdef EMU_CZ80
free( ZetCPUContext );
ZetCPUContext = NULL;
lastZetCPUContext = NULL;
#endif
nCPUCount = 0;
nHasZet = -1;
}
int ZetMapArea(int nStart, int nEnd, int nMode, unsigned char *Mem)
{
#ifdef EMU_DOZE
int s = nStart >> 8;
int e = (nEnd + 0xFF) >> 8;
// Put this section in the memory map, giving the offset from Z80 memory to PC memory
for (int i = s; i < e; i++) {
switch (nMode) {
case 0:
Doze.ppMemRead[i] = Mem - nStart;
break;
case 1:
Doze.ppMemWrite[i] = Mem - nStart;
break;
case 2:
Doze.ppMemFetch[i] = Mem - nStart;
Doze.ppMemFetchData[i] = Mem - nStart;
break;
}
}
#endif
#ifdef EMU_MAME_Z80
unsigned char cStart = (nStart >> 8);
unsigned char **pMemMap = lastZetCPUContext->pZetMemMap;
for (unsigned short i = cStart; i <= (nEnd >> 8); i++) {
switch (nMode) {
case 0: {
pMemMap[0 + i] = Mem + ((i - cStart) << 8);
break;
}
case 1: {
pMemMap[0x100 + i] = Mem + ((i - cStart) << 8);
break;
}
case 2: {
pMemMap[0x200 + i] = Mem + ((i - cStart) << 8);
pMemMap[0x300 + i] = Mem + ((i - cStart) << 8);
break;
}
}
}
#endif
#ifdef EMU_CZ80
int s = nStart >> CZ80_FETCH_SFT;
int e = (nEnd + CZ80_FETCH_BANK - 1) >> CZ80_FETCH_SFT;
// Put this section in the memory map, giving the offset from Z80 memory to PC memory
for (int i = s; i < e; i++) {
switch (nMode) {
case 0:
lastZetCPUContext->Read[i] = Mem - nStart;
break;
case 1:
lastZetCPUContext->Write[i] = Mem - nStart;
break;
case 2:
lastZetCPUContext->Fetch[i] = Mem - nStart;
lastZetCPUContext->FetchData[i] = Mem - nStart;
break;
}
}
/*
if (nMode == 2) {
s = lastZetCPUContext->PC - lastZetCPUContext->BasePC;
e = s >> CZ80_FETCH_SFT;
lastZetCPUContext->BasePC = (u32) lastZetCPUContext->Fetch[e];
lastZetCPUContext->BasePCData = (u32) lastZetCPUContext->FetchData[e];
lastZetCPUContext->PC = s + lastZetCPUContext->BasePC;
lastZetCPUContext->PCData = s + lastZetCPUContext->BasePCData;
}
*/
#endif
return 0;
}
int ZetMapArea(int nStart, int nEnd, int nMode, unsigned char *Mem01, unsigned char *Mem02)
{
#ifdef EMU_DOZE
int s = nStart >> 8;
int e = (nEnd + 0xFF) >> 8;
if (nMode != 2) {
return 1;
}
// Put this section in the memory map, giving the offset from Z80 memory to PC memory
for (int i = s; i < e; i++) {
Doze.ppMemFetch[i] = Mem01 - nStart;
Doze.ppMemFetchData[i] = Mem02 - nStart;
}
#endif
#ifdef EMU_MAME_Z80
unsigned char cStart = (nStart >> 8);
unsigned char **pMemMap = lastZetCPUContext->pZetMemMap;
if (nMode != 2) {
return 1;
}
for (unsigned short i = cStart; i <= (nEnd >> 8); i++) {
pMemMap[0x200 + i] = Mem01 + ((i - cStart) << 8);
pMemMap[0x300 + i] = Mem02 + ((i - cStart) << 8);
}
#endif
#ifdef EMU_CZ80
int s = nStart >> CZ80_FETCH_SFT;
int e = (nEnd + CZ80_FETCH_BANK - 1) >> CZ80_FETCH_SFT;
if (nMode != 2) {
return 1;
}
// Put this section in the memory map, giving the offset from Z80 memory to PC memory
for (int i = s; i < e; i++) {
lastZetCPUContext->Fetch[i] = Mem01 - nStart;
lastZetCPUContext->FetchData[i] = Mem02 - nStart;
}
/*
s = lastZetCPUContext->PC - lastZetCPUContext->BasePC;
e = s >> CZ80_FETCH_SFT;
lastZetCPUContext->BasePC = (u32) lastZetCPUContext->Fetch[e];
lastZetCPUContext->BasePCData = (u32) lastZetCPUContext->FetchData[e];
lastZetCPUContext->PC = s + lastZetCPUContext->BasePC;
lastZetCPUContext->PCData = s + lastZetCPUContext->BasePCData;
*/
#endif
return 0;
}
int ZetReset()
{
#ifdef EMU_DOZE
DozeReset();
#endif
#ifdef EMU_MAME_Z80
Z80Reset();
#endif
#ifdef EMU_CZ80
Cz80_Reset( lastZetCPUContext );
#endif
return 0;
}
int ZetPc(int n)
{
#ifdef EMU_DOZE
if (n < 0) {
return Doze.pc;
} else {
return ZetCPUContext[n].pc;
}
#endif
#ifdef EMU_MAME_Z80
if (n < 0) {
return lastZetCPUContext->reg.pc.w.l;
} else {
return ZetCPUContext[n].reg.pc.w.l;
}
#endif
#ifdef EMU_CZ80
if (n < 0) {
return Cz80_Get_PC(lastZetCPUContext);
} else {
return Cz80_Get_PC(&ZetCPUContext[n]);
}
#endif
return 0;
}
int ZetBc(int n)
{
#ifdef EMU_DOZE
if (n < 0) {
return Doze.bc;
} else {
return ZetCPUContext[n].bc;
}
#endif
#ifdef EMU_MAME_Z80
if (n < 0) {
return lastZetCPUContext->reg.bc.w.l;
} else {
return ZetCPUContext[n].reg.bc.w.l;
}
#endif
#ifdef EMU_CZ80
if (n < 0) {
return Cz80_Get_BC(lastZetCPUContext);
} else {
return Cz80_Get_BC(&ZetCPUContext[n]);
}
#endif
}
int ZetDe(int n)
{
#ifdef EMU_DOZE
if (n < 0) {
return Doze.de;
} else {
return ZetCPUContext[n].de;
}
#endif
// correct?
#ifdef EMU_MAME_Z80
if (n < 0) {
return lastZetCPUContext->reg.de.w.l;
} else {
return ZetCPUContext[n].reg.de.w.l;
}
#endif
#ifdef EMU_CZ80
if (n < 0) {
return Cz80_Get_DE(lastZetCPUContext);
} else {
return Cz80_Get_DE(&ZetCPUContext[n]);
}
#endif
}
int ZetHL(int n)
{
#ifdef EMU_DOZE
if (n < 0) {
return Doze.hl;
} else {
return ZetCPUContext[n].hl;
}
#endif
#ifdef EMU_MAME_Z80
if (n < 0) {
return lastZetCPUContext->reg.hl.w.l;
} else {
return ZetCPUContext[n].reg.hl.w.l;
}
#endif
#ifdef EMU_CZ80
if (n < 0) {
return Cz80_Get_HL(lastZetCPUContext);
} else {
return Cz80_Get_HL(&ZetCPUContext[n]);
}
#endif
}
int ZetScan(int nAction)
{
if ((nAction & ACB_DRIVER_DATA) == 0) {
return 0;
}
#ifdef EMU_DOZE
char szText[] = "Z80 #0";
for (int i = 0; i < nCPUCount; i++) {
szText[5] = '1' + i;
ScanVar(&ZetCPUContext[i], 32 + 16, szText);
}
#endif
#ifdef EMU_CZ80
char szText[] = "Z80 #0";
for (int i = 0; i < nCPUCount; i++) {
szText[5] = '1' + i;
ScanVar(&ZetCPUContext[i], (unsigned int)&(ZetCPUContext[i].Fetch)-(unsigned int)&ZetCPUContext[i], szText);
}
#endif
return 0;
}
void ZetSetIRQLine(const int line, const int status)
{
#ifdef EMU_DOZE
Doze.nInterruptLatch = line | status;
#endif
#ifdef EMU_MAME_Z80
switch ( status ) {
case ZET_IRQSTATUS_NONE:
Z80SetIrqLine(0, 0);
break;
case ZET_IRQSTATUS_ACK:
Z80SetIrqLine(line, 1);
break;
case ZET_IRQSTATUS_AUTO:
Z80SetIrqLine(line, 1);
Z80Execute(0);
Z80SetIrqLine(0, 0);
break;
}
#endif
#ifdef EMU_CZ80
lastZetCPUContext->nInterruptLatch = line | status;
#endif
}
int ZetNmi()
{
#ifdef EMU_DOZE
int nCycles = DozeNmi();
// Taking an NMI requires 12 cycles
Doze.nCyclesTotal += nCycles;
#endif
#ifdef EMU_MAME_Z80
Z80SetIrqLine(Z80_INPUT_LINE_NMI, 1);
Z80Execute(0);
Z80SetIrqLine(Z80_INPUT_LINE_NMI, 0);
//Z80Execute(0);
int nCycles = 12;
lastZetCPUContext->nCyclesTotal += nCycles;
#endif
#ifdef EMU_CZ80
int nCycles = Cz80_Set_NMI(lastZetCPUContext);
lastZetCPUContext->nCyclesTotal += nCycles;
#endif
return nCycles;
}
int ZetIdle(int nCycles)
{
#ifdef EMU_DOZE
Doze.nCyclesTotal += nCycles;
#endif
#ifdef EMU_MAME_Z80
lastZetCPUContext->nCyclesTotal += nCycles;
#endif
#ifdef EMU_CZ80
lastZetCPUContext->nCyclesTotal += nCycles;
#endif
return nCycles;
}
int ZetSegmentCycles()
{
#ifdef EMU_DOZE
return Doze.nCyclesSegment - Doze.nCyclesLeft;
#endif
#ifdef EMU_MAME_Z80
return lastZetCPUContext->nCyclesSegment - lastZetCPUContext->nCyclesLeft;
#endif
#ifdef EMU_CZ80
return lastZetCPUContext->nCyclesSegment - lastZetCPUContext->nCyclesLeft;
#endif
}
int ZetTotalCycles()
{
#ifdef EMU_DOZE
return Doze.nCyclesTotal - Doze.nCyclesLeft;
#endif
#ifdef EMU_MAME_Z80
return lastZetCPUContext->nCyclesTotal - lastZetCPUContext->nCyclesLeft;
#endif
#ifdef EMU_CZ80
return lastZetCPUContext->nCyclesTotal - lastZetCPUContext->nCyclesLeft;
#endif
}
| [
"[email protected]"
]
| [
[
[
1,
966
]
]
]
|
124dbce470f3c1f1ba216ed423cff41b4fc0ea1d | 6e016fa119b56ecf0ce40625a651ebba74418b2e | /Sample/CreateDesktop/CreateDesktop.cpp | fd812331b9b9b2ff55b55d7de919d04a169493c8 | []
| no_license | smartdj/multi-desktop-manager | 3d382b2b4105d6666a0bfcbebba9e4540868b86f | 98d79b423389b75223affdbd514ea3a45fe42898 | refs/heads/master | 2016-09-05T12:11:27.996006 | 2010-08-01T14:42:39 | 2010-08-01T14:42:39 | 37,246,600 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,148 | cpp | // CreateDesktop.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <windows.h>
#pragma comment(lib,"User32.lib")
_TCHAR _Explorer[520];
void WINAPI CreateNewDesktop( LPVOID lpParam)
{
HWINSTA winsta = GetProcessWindowStation();
SetProcessWindowStation(winsta);
_TCHAR * desktopname = (_TCHAR *)lpParam;
HDESK newdesktop = CreateDesktop(desktopname,NULL,NULL,0,GENERIC_ALL,NULL);
SetThreadDesktop(newdesktop);
STARTUPINFO si;
PROCESS_INFORMATION pi;
memset(&si,0,sizeof(si));
memset(&pi,0,sizeof(pi));
si.cb = sizeof(si);
si.lpDesktop = desktopname;
CreateProcess(NULL,_Explorer,NULL,NULL,FALSE,0, NULL, NULL, &si, &pi);
Sleep(4000);
CloseDesktop(newdesktop);
CloseWindowStation(winsta);
}
int _tmain(int argc, _TCHAR* argv[])
{
if(argc != 2)
{
printf("Usage: CreateDesktop [DesktopName]\n");
return -1;
}
lstrcpy(_Explorer,L"C:\\WINDOWS\\EXPLORER.exe");
CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)CreateNewDesktop,(LPVOID)argv[1],0,NULL);
for( int i = 0 ; i < 10 ; i ++ )
{
printf(".");
Sleep(500);
}
printf("\n");
return 0;
}
| [
"angelipin@7ff612aa-105e-4e35-adfd-5cdac6c44c12"
]
| [
[
[
1,
43
]
]
]
|
51456618ded5fc9c699299c357583793004e1ce7 | 78fb44a7f01825c19d61e9eaaa3e558ce80dcdf5 | /guceCORE/src/CVFSHandleToDataStream.cpp | 566ac89d4a76ef00eb4473574bd6198326a97307 | []
| no_license | LiberatorUSA/GUCE | a2d193e78d91657ccc4eab50fab06de31bc38021 | a4d6aa5421f8799cedc7c9f7dc496df4327ac37f | refs/heads/master | 2021-01-02T08:14:08.541536 | 2011-09-08T03:00:46 | 2011-09-08T03:00:46 | 41,840,441 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,565 | cpp | /*
* guceCORE: GUCE module providing tie-in functionality between systems
* Copyright (C) 2002 - 2008. Dinand Vanvelzen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*-------------------------------------------------------------------------//
// //
// INCLUDES //
// //
//-------------------------------------------------------------------------*/
#ifndef GUCEF_VFS_CVFSHANDLE_H
#include "gucefVFS_CVFSHandle.h" /* vfs file handle */
#define GUCEF_VFS_CVFSHANDLE_H
#endif /* GUCEF_VFS_CVFSHANDLE_H ? */
#ifndef GUCEF_VFS_CVFS_H
#include "gucefVFS_CVFS.h"
#define GUCEF_VFS_CVFS_H
#endif /* GUCEF_VFS_CVFS_H ? */
#ifndef GUCE_CORE_MACROS_H
#include "guceCORE_macros.h" /* guceCORE build config and macros */
#define GUCE_CORE_MACROS_H
#endif /* GUCE_CORE_MACROS_H ? */
#include "CVFSHandleToDataStream.h" /* definition of the class implemented here */
/*-------------------------------------------------------------------------//
// //
// NAMESPACE //
// //
//-------------------------------------------------------------------------*/
namespace GUCE {
namespace CORE {
/*-------------------------------------------------------------------------//
// //
// CLASSES //
// //
//-------------------------------------------------------------------------*/
CVFSHandleToDataStream::CVFSHandleToDataStream( CVFSHandlePtr& vfshandle ,
bool freeonclose /* = false */ )
: CIOAccessToDataStream( vfshandle->GetAccess() ) ,
m_fh( vfshandle ) ,
m_freeonclose( freeonclose )
{GUCE_TRACE;
mName = vfshandle->GetFilename().C_String();
}
/*-------------------------------------------------------------------------*/
CVFSHandleToDataStream::~CVFSHandleToDataStream()
{GUCE_TRACE;
close();
// Important: we must disable access because the resource may no longer
// be available due to unloading as a result of the file handle being released
// at this class level
SetAccess( NULL );
}
/*-------------------------------------------------------------------------*/
void
CVFSHandleToDataStream::close( void )
{GUCE_TRACE;
CIOAccessToDataStream::close();
if ( m_freeonclose )
{
m_fh = NULL;
// Important: we must disable access because the resource may no longer
// be available due to unloading as a result of the file handle being released
// at this class level
SetAccess( NULL );
}
}
/*-------------------------------------------------------------------------//
// //
// NAMESPACE //
// //
//-------------------------------------------------------------------------*/
} /* namespace CORE ? */
} /* namespace GUCE ? */
/*-------------------------------------------------------------------------*/
| [
"[email protected]"
]
| [
[
[
1,
110
]
]
]
|
831f72f66ffd3739186aa47f55756bf028e7feee | c86f787916e295d20607cbffc13c524018888a0f | /tp3/codigo/mainCasoBorde/mainCasoBorde.cpp | e36ade3a67ad82263812078cac954a4ffdaaf9e3 | []
| no_license | federicoemartinez/algo3-2008 | 0039a4bc6d83ab8005fa2169b919e6c03524bad5 | 3b04cbea4583d76d7a97f2aee72493b4b571a77b | refs/heads/master | 2020-06-05T05:56:20.127248 | 2008-08-04T04:59:32 | 2008-08-04T04:59:32 | 32,117,945 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,572 | cpp | #include <iostream>
#include <cstdlib>
#include <string>
#include "FiltroGrafos.h"
#include "SolucionExacta.h"
#include "Grasp.h"
#include "cmdline/CmdLine.h"
using namespace std;
void help() {
cout << "Uso: ./cruces <params>" << endl;
cout << " -i inicio: cantidad de nodos del primer caso a ejecutar" << endl;
cout << " -f fin: cantidad de nodos del ultimo caso a ejecutar" << endl;
cout << " -o file: archivo de salida (se le agrega sufijo del método)" << endl;
cout << "Métodos Posibles:" << endl;
cout << " -e: exacto" << endl;
cout << " -c: constructiva" << endl;
cout << " -l: búsqueda local" << endl;
cout << " -g: grasp" << endl;
cout << " -a: todas las heurísticas" << endl;
cout << " -t: todos los métodos" << endl;
cout << "Método por defecto: -a " << endl;
cout << "Valores por defecto de inicio y fin: 5 y 99 respectivamente" << endl;
cout << "Parametros inicio y fin deben cumplir que: son impares, mayores que 5, y inicio < fin";
cout << endl;
}
void armarCasoBordeConstructiva(vector<nodo>& fijos1, vector<nodo>& fijos2, vector<nodo>& todos1, vector<nodo>& todos2, list<eje>& listaEjes, unsigned int size) {
nodo v = 0;
while (v < (size - 3)/2) {
todos1.push_back(v);
fijos1.push_back(v);
v++;
}
while (v < (size - 3)/2 + 2) {
todos2.push_back(v);
fijos2.push_back(v);
v++;
}
// hay 1 solo movil en la particion 1
todos1.push_back(v);
v++;
while (v < size) {
todos2.push_back(v);
v++;
}
// ahora armo la lista de ejes
vector<nodo>::const_iterator it1 (todos1.begin());
vector<nodo>::const_iterator it2 (todos2.begin());
// salteo los 2 fijos de p2
it2++;
it2++;
for (unsigned int i = 0; i < todos1.size() - 1; i++) {
eje e;
e.primero = *it1;
e.segundo = *it2;
listaEjes.push_back(e);
it1++;
it2++;
}
eje e;
e.primero = *it1;
e.segundo = *(todos2.begin());
listaEjes.push_back(e);
e.segundo = *(todos2.begin() + 1);
listaEjes.push_back(e);
e.segundo = *(todos2.begin() + 2);
listaEjes.push_back(e);
}
int main(int argc, char* argv[]) {
// inicializo el generador de numeros aleatorios
srand(time(NULL));
CCmdLine cmdLine;
bool todas=false, aproximados=false, constructiva=false,local=false,grasp=false,exacta=false;
cout << endl;
cout << "---------------------------------------------------------------------" << endl;
cout << "Constructor de dibujos de grafos bipartitos a partir de un caso borde" << endl;
cout << "González, Martínez, Sainz-Trápaga" << endl;
cout << "Algoritmos y Estructuras de Datos 3 - FCEN, UBA (2008)" << endl;
cout << "---------------------------------------------------------------------" << endl << endl;
if (cmdLine.SplitLine(argc, argv) < 1) {
cout << "Se ejecutan métodos aproximados por defecto." << endl;
cout << "Para ver las opciones utilice el parámetro -h." << endl << endl;
aproximados = true;
} else {
if (cmdLine.HasSwitch("-h")) {
help();
exit(0);
}
if (cmdLine.HasSwitch("-a")) {
aproximados = true;
}
if (cmdLine.HasSwitch("-t")) {
todas = true;
}
if (cmdLine.HasSwitch("-c")) {
constructiva = true;
}
if (cmdLine.HasSwitch("-l")) {
local = true;
}
if (cmdLine.HasSwitch("-g")) {
grasp = true;
}
if (cmdLine.HasSwitch("-e")) {
exacta = true;
}
}
unsigned int desde, hasta;
try {
desde = atoi(cmdLine.GetArgument("-i",0).c_str());
} catch (...) {
desde = 5;
}
try {
hasta = atoi(cmdLine.GetArgument("-f",0).c_str());
} catch (...) {
hasta = 99;
}
if ((desde < 5) || (hasta < 5) || (desde > hasta) || (desde % 2 == 0) || (hasta % 2 == 0)) {
cout << "Parametros inicio y/o fin invalidos. Seteados a valores por defecto." << endl;
desde = 5;
hasta = 99;
}
string o;
try {
o = cmdLine.GetArgument("-o",0);
} catch (...) {
o = "Tp3.out";
}
if (!(todas || aproximados || constructiva || local || grasp || exacta)) {
cout << "Se ejecutan métodos aproximados por defecto." << endl;
cout << "Para ver las opciones utilice el parámetro -h." << endl << endl;
aproximados = true;
}
ofstream outE,outL,outG,outC;
if (todas || exacta) {
string salidaExacta = o;
string :: iterator it = salidaExacta.begin();
while (it != salidaExacta.end() && *it != '.') {
it++;
}
salidaExacta.insert(it,'E');
outE.open(salidaExacta.c_str());
if (!outE.is_open()) {
cout << endl << "ERROR: No se pudo abrir el archivo de salida!" << endl;
help();
return 1;
}
}
if (todas || aproximados || constructiva) {
string salidaConstructiva = o;
string :: iterator it = salidaConstructiva.begin();
while (it != salidaConstructiva.end() && *it != '.') {
it++;
}
salidaConstructiva.insert(it,'C');
outC.open(salidaConstructiva.c_str());
if (!outC.is_open()) {
cout << endl << "ERROR: No se pudo abrir el archivo de salida!" << endl;
help();
return 1;
}
}
if (todas || aproximados || local) {
string salidaLocal = o;
string :: iterator it = salidaLocal.begin();
while (it != salidaLocal.end() && *it != '.') {
it++;
}
salidaLocal.insert(it,'L');
outL.open(salidaLocal.c_str());
if (!outL.is_open()) {
cout << endl << "ERROR: No se pudo abrir el archivo de salida!" << endl;
help();
return 1;
}
}
if (todas || aproximados || grasp) {
string salidaGrasp = o;
string :: iterator it = salidaGrasp.begin();
while (it != salidaGrasp.end() && *it != '.') {
it++;
}
salidaGrasp.insert(it,'G');
outG.open(salidaGrasp.c_str());
if (!outG.is_open()) {
cout << endl << "ERROR: No se pudo abrir el archivo de salida!" << endl;
help();
return 1;
}
}
unsigned lecturas = 0;
for (unsigned int i = desde; i <= hasta; i+=2) {
vector<nodo> fijos1;
vector<nodo> fijos2;
vector<nodo> todos1;
vector<nodo> todos2;
list<eje> listaEjes;
armarCasoBordeConstructiva(fijos1, fijos2, todos1, todos2, listaEjes, i);
GrafoBipartito g (todos1, todos2, listaEjes);
Dibujo d (&g, fijos1, fijos2);
if (todas || exacta) {
if(lecturas != 0){
outE<<endl;
}
SolucionExacta s(d);
Dibujo dib (s.resolver());
cout << "El algoritmo exacto logró: " << dib.contarCruces() << " cruces" << endl;
dib.guardar(outE);
}
if (todas || aproximados || constructiva) {
if (lecturas != 0){
outC<<endl;
}
HeuristicaConstructiva hc(d);
Dibujo dib = hc.construirSolucion(1.0, false);
cout << "La heurística constructiva logró: " << dib.contarCruces() << " cruces" << endl;
dib.guardar(outC);
}
if (todas || aproximados || local) {
if(lecturas != 0){
outL<<endl;
}
HeuristicaConstructiva hc(d);
BusquedaLocal bl(d);
Dibujo dib = hc.construirSolucion(1.0, false);
Dibujo dibu = bl.hallarMinimoLocal(dib);
cout << "La búsqueda local logró: " << dibu.contarCruces() << " cruces" << endl;
dibu.guardar(outL);
}
if (todas || aproximados || grasp) {
if(lecturas != 0){
outG<<endl;
}
Grasp gp(d);
Dibujo dib (gp.resolver());
cout << "Grasp logró: " << dib.contarCruces() << " cruces" << endl;
dib.guardar(outG);
}
lecturas++;
}
if (todas || exacta) {
outE.close();
}
if (todas || aproximados || constructiva) {
outC.close();
}
if (todas || aproximados || local) {
outL.close();
}
if (todas || aproximados || grasp) {
outG.close();
}
cout << endl;
return 0;
}
| [
"HadesKleizer@bfd18afd-6e49-0410-abef-09437ef2666c"
]
| [
[
[
1,
283
]
]
]
|
749cc033cd43f3039b948ed0da68e19b9f4328b8 | 51e4aeb0d5e29ae1e8a9d8cf467797da2054b0f1 | /src/arenaView.hpp | 302bc19cfc449822cb8ff3d43229eaba5dc10ffc | []
| no_license | vashero/tachyon-game | b3340272ee58c11077eef077485f8a01e4c81881 | 5fc2daac314c0b3b19b7336f8eb29d81a5e05729 | refs/heads/master | 2016-09-09T23:47:14.315285 | 2009-05-10T17:47:53 | 2009-05-10T17:47:53 | 32,647,791 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,482 | hpp | /*==============================================================
* Copyright (c) 2009 Blake Fisher. All Rights Reserved.
*
* This software is released under the BSD License
* <http://www.opensource.org/licenses/bsd-license.php>
*==============================================================
*/
#pragma once
#include "shipView.hpp"
#include "shipViewManager.hpp"
#include <Ogre.h>
using namespace Ogre;
// Skybox
const String ARENA_VIEW_SKYBOX_NAME = "Skyboxes/Skybox";
// Lighting
const ColourValue ARENA_VIEW_AMB_LIGHT(0.75, 0.75, 0.75);
const String ARENA_VIEW_DIR_LIGHT_NAME[] = {"Light0", "Light1"};
const Vector3 ARENA_VIEW_DIR_LIGHT_DIR[] = {Vector3(0.1, -1, 0), Vector3(1, 0, 0)};
const ColourValue ARENA_VIEW_DIR_LIGHT_DIFFUSE[] = {ColourValue(1, 1, 1), ColourValue(1, 1, 1)};
const ColourValue ARENA_VIEW_DIR_LIGHT_SPECULAR[] = {ColourValue(1, 1, 1), ColourValue(1, 1, 1)};
// Cameras
const String ARENA_VIEW_CAM_NAME = "Camera";
const Real ARENA_VIEW_CAM_CLIP = 5;
const Vector3 ARENA_VIEW_DEF_CAM_POS(0, -1000, 0);
const Vector3 ARENA_VIEW_DEF_TARGET_POS(0, 0, 0);
const String ARENA_VIEW_TARGET_NODE_NAME = "TargetNode";
const String ARENA_VIEW_CAM_NODE_NAME = "CameraNode";
/**
A generic arena display. Handles skybox, cameras and lighting.
Also holds ships.
*/
class ArenaView
{
public:
/** The default constructor
@param win The window we are rendering in
@param mgrName The name of the scene manager we are creating
*/
ArenaView(RenderWindow *win, const String &shipCfgFilename,
const String &mgrName = StringUtil::BLANK);
/** The destructor */
~ArenaView();
/** Create a scene */
void create_scene(const String &mgrName);
/** Add a ship to the scene */
void add_ship(const ShipViewType &type, const Vector3 &pos, const Radian &yaw);
/** Remove all ships from the view */
void clear_ships();
/** Rotate the camera about the node */
void rotate_camera(const Radian &xAngle, const Radian &yAngle);
protected:
/** The point in space that the camera is located */
Vector3 mCamPos;
/** The point in space that the camera is looking at */
Vector3 mTargetPos;
/** The window we are rendering in */
RenderWindow *mWin;
/** The scene manager that contains all scene components */
SceneManager *mSceneMgr;
/** The ship manager */
ShipViewManager mShipViewMgr;
/** The ships in our view */
vector<ShipView> mShips;
};
| [
"[email protected]@b90cb52e-2f47-11de-8816-6191455234fe"
]
| [
[
[
1,
83
]
]
]
|
474effb1cef10c8782183e6c5ea7989b6ef4be60 | ab582de0495f9b016e4602b578c3e9e2475bec44 | /src/game/client/hl2/c_weapon__stubs_hl2.cpp | 74176d04eb8657847226d48f8c3f1a26530d27b3 | []
| no_license | lion7/millerslake | bf9e36493b10d5ac4619a0d59f4cfb0983bf0470 | 186ec556b5066c306c5735ab7efe136f1ce03019 | refs/heads/master | 2021-04-09T17:14:25.666942 | 2010-12-04T02:13:54 | 2010-12-04T02:13:54 | 32,201,552 | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 2,318 | cpp | //========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#include "cbase.h"
#include "c_weapon__stubs.h"
#include "basehlcombatweapon_shared.h"
#include "c_basehlcombatweapon.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
STUB_WEAPON_CLASS( cycler_weapon, WeaponCycler, C_BaseCombatWeapon );
STUB_WEAPON_CLASS( weapon_binoculars, WeaponBinoculars, C_BaseHLCombatWeapon );
STUB_WEAPON_CLASS( weapon_bugbait, WeaponBugBait, C_BaseHLCombatWeapon );
STUB_WEAPON_CLASS( weapon_flaregun, Flaregun, C_BaseHLCombatWeapon );
STUB_WEAPON_CLASS( weapon_annabelle, WeaponAnnabelle, C_BaseHLCombatWeapon );
STUB_WEAPON_CLASS( weapon_gauss, WeaponGaussGun, C_BaseHLCombatWeapon );
STUB_WEAPON_CLASS( weapon_cubemap, WeaponCubemap, C_BaseCombatWeapon );
STUB_WEAPON_CLASS( weapon_alyxgun, WeaponAlyxGun, C_HLSelectFireMachineGun );
STUB_WEAPON_CLASS( weapon_citizenpackage, WeaponCitizenPackage, C_BaseHLCombatWeapon );
STUB_WEAPON_CLASS( weapon_citizensuitcase, WeaponCitizenSuitcase, C_WeaponCitizenPackage );
STUB_WEAPON_CLASS( weapon_enfield, WeaponEnfield, C_BaseHLCombatWeapon );
#ifndef HL2MP
STUB_WEAPON_CLASS( weapon_ar2, WeaponAR2, C_HLMachineGun );
STUB_WEAPON_CLASS( weapon_frag, WeaponFrag, C_BaseHLCombatWeapon );
STUB_WEAPON_CLASS( weapon_rpg, WeaponRPG, C_BaseHLCombatWeapon );
STUB_WEAPON_CLASS( weapon_pistol, WeaponPistol, C_BaseHLCombatWeapon );
STUB_WEAPON_CLASS( weapon_shotgun, WeaponShotgun, C_BaseHLCombatWeapon );
STUB_WEAPON_CLASS( weapon_smg1, WeaponSMG1, C_HLSelectFireMachineGun );
STUB_WEAPON_CLASS( weapon_357, Weapon357, C_BaseHLCombatWeapon );
STUB_WEAPON_CLASS( weapon_crossbow, WeaponCrossbow, C_BaseHLCombatWeapon );
STUB_WEAPON_CLASS( weapon_slam, Weapon_SLAM, C_BaseHLCombatWeapon );
STUB_WEAPON_CLASS( weapon_crowbar, WeaponCrowbar, C_BaseHLBludgeonWeapon );
#ifdef HL2_EPISODIC
STUB_WEAPON_CLASS( weapon_hopwire, WeaponHopwire, C_BaseHLCombatWeapon );
//STUB_WEAPON_CLASS( weapon_proto1, WeaponProto1, C_BaseHLCombatWeapon );
#endif
#ifdef HL2_LOSTCOAST
STUB_WEAPON_CLASS( weapon_oldmanharpoon, WeaponOldManHarpoon, C_WeaponCitizenPackage );
#endif
#endif
| [
"[email protected]@1b4041a7-fb09-ea03-7d66-d8ed986ac175"
]
| [
[
[
1,
49
]
]
]
|
6c393313fe68f1dfba91ff1e5b47b0c7abdb21bd | fcdddf0f27e52ece3f594c14fd47d1123f4ac863 | /TeCom/src/TdkLayout/Header Files/TdkLayoutBarcodeObject.h | 44aea9d7128b7355fbaa7b651ac04db45cb370d6 | []
| no_license | radtek/terra-printer | 32a2568b1e92cb5a0495c651d7048db6b2bbc8e5 | 959241e52562128d196ccb806b51fda17d7342ae | refs/heads/master | 2020-06-11T01:49:15.043478 | 2011-12-12T13:31:19 | 2011-12-12T13:31:19 | null | 0 | 0 | null | null | null | null | ISO-8859-2 | C++ | false | false | 1,055 | h | /******************************************************************************
* FUNCATE - GIS development team
*
* TerraLib Components - TeCOM
*
* @(#) TdkLayoutBarcodeObject.h
*
*******************************************************************************
*
* $Rev$:
*
* $Author: rui.gregorio $:
*
* $Date: 2010/09/16 17:37:20 $:
*
******************************************************************************/
// Elaborated by Rui Mauricio Gregório
#ifndef __TDK_LAYOUT_BARCODE_OBJECT_H
#define __TDK_LAYOUT_BARCODE_OBJECT_H
//! \class TdkLayoutBarcodeObject
/*! Barcode Class
*/
class TdkLayoutBarcodeObject : public TdkLayoutTextObject
{
protected :
//! \brief registerExtendProperties
/*! Register the extend properties
*/
virtual void registerExtendProperties();
public :
//! \brief Constructor
TdkLayoutBarcodeObject(const unsigned int &id, TdkAbstractCanvasDraw* canvas, const TeBox &box,const std::string textValue="");
//! \brief Destructor
~TdkLayoutBarcodeObject();
};
#endif
| [
"[email protected]@58180da6-ba8b-8960-36a5-00cc02a3ddec"
]
| [
[
[
1,
43
]
]
]
|
8fd9987ea56adf9dcbdb79d0d378ed22ba293bce | 5424018aa2443f3ad7688fb27afc67ffb6172f81 | /cppx/cppx.cpp | e7628758eec28d4a3c490677320582c0afc86f8b | []
| no_license | Amakata/wajima | f9ed0b980df70ca9738bac6d381948e0fa2b318f | 6c58b04efa0c45eb0a2f21d67b79d5058c13f586 | refs/heads/master | 2021-01-17T06:24:37.237575 | 2005-01-09T08:24:04 | 2005-01-09T08:24:04 | null | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 7,516 | cpp | #include <iostream>
#include <vector>
#include <string>
#include <list>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/convenience.hpp>
#include <boost/filesystem/exception.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/regex.hpp>
namespace fs = ::boost::filesystem;
bool zefiro_name( const std::string & name )
{
return
name.size() == 0
|| name == "."
|| name == ".."
|| (::fs::windows_name( name )
&& ::fs::portable_posix_name( name )
&& name[0] != '-');
}
class cppx_operation {
public:
enum op_code {prefix, function};
cppx_operation(op_code op, ::std::string value) : op_code_(op), value_(value) {
}
::std::string get_value() const {
return value_;
}
op_code get_op_code() const {
return op_code_;
}
::std::string str() const {
if (op_code_ == function) {
return ::std::string("FUNCTION :") + value_;
} else {
return ::std::string("PREFIX :") + value_;
}
}
private:
::std::string value_;
op_code op_code_;
};
::std::string get_func_prefix( ::std::list< cppx_operation >& op_stack ) {
::std::list< cppx_operation >::iterator it = op_stack.begin();
::std::list< cppx_operation >::iterator end = op_stack.end();
::std::string result = "";
if (it == end) {
return result;
}
--end;
while (it != end) {
result = result + it->get_value();
++it;
}
return result;
}
::std::string get_static_prefix( ::std::list< cppx_operation >& op_stack ) {
::std::list< cppx_operation >::iterator it = op_stack.begin();
::std::list< cppx_operation >::iterator end = op_stack.end();
::std::string result = "";
if (it == end) {
return result;
}
while (it != end) {
result = result + it->get_value();
++it;
}
return result;
}
void generate_cppx(::fs::path source_path, ::fs::path dest_path, bool modify) {
if (modify) {
::fs::remove(dest_path);
}
::std::list< cppx_operation > op_stack;
::fs::ifstream source_fs(source_path);
::fs::ofstream dest_fs(dest_path);
::fs::ofstream dest_fs_cpp(::fs::change_extension(dest_path,".cpp"));
dest_fs_cpp << "#include \"" << dest_path.leaf() << "\"" << ::std::endl;
::boost::regex cppx_re("^//[\\s]*CPPX");
::boost::regex cppx_begin_re("^_BEGIN[\\s]*([\\w\\s:]*)");
::boost::regex cppx_func_begin_re("^_FUNC_BEGIN[\\s]*");
::boost::regex cppx_func_end_re("^_FUNC_END");
::boost::regex cppx_end_re("^_END");
::boost::regex cppx_static_re("^_STATIC[\\s]*");
::boost::regex cppx_func_tail("\\{[\\s]*$");
::boost::smatch smresult;
while (!source_fs.eof()) {
::std::string line;
::std::getline(source_fs, line);
// ::std::cout << "line " << line << ::std::endl;
if (::boost::regex_search(line, smresult, cppx_re)) {
::std::string suffix = smresult.suffix();
::boost::smatch smresult;
if (::boost::regex_search(suffix, smresult, cppx_begin_re)) {
// スタックを積むだけ
op_stack.push_back(cppx_operation(cppx_operation::prefix, smresult.str(1)));
// ::std::cout << "push() [" << op_stack.back().str() << "]" << ::std::endl;
} else if(::boost::regex_search(suffix, smresult, cppx_func_begin_re)) {
op_stack.push_back(cppx_operation(cppx_operation::function, smresult.suffix()));
// ::std::cout << "push() [" << op_stack.back().str() << "]" << ::std::endl;
// 解析してcpp側に出力
dest_fs_cpp << smresult.suffix().str().replace(smresult.suffix().str().find("$0$"), 3, get_func_prefix(op_stack)) + " {"<< ::std::endl;
::std::getline(source_fs, line);
if (::boost::regex_search(line, smresult, cppx_func_tail)) {
dest_fs << smresult.prefix() << ";" << ::std::endl;
} else {
dest_fs << line << ";" << ::std::endl;
}
} else if(::boost::regex_search(suffix, smresult, cppx_func_end_re)) {
// スタックを戻すだけ。
// ::std::cout << "pop() [" << op_stack.back().str() << "]" << ::std::endl;
op_stack.pop_back();
} else if(::boost::regex_search(suffix, smresult, cppx_end_re)) {
// スタックを戻すだけ。
// ::std::cout << "pop() [" << op_stack.back().str() << "]" << ::std::endl;
op_stack.pop_back();
} else if(::boost::regex_search(suffix, smresult, cppx_static_re)) {
// CPPX_STATICはcpp側に出力
// ::std::cout << " [STATIC :" << smresult.suffix() << "]" << ::std::endl;
// ::std::cout << smresult.suffix().str().find("$0$") << ::std::endl;
dest_fs_cpp << smresult.suffix().str().replace(smresult.suffix().str().find("$0$"), 3, get_static_prefix(op_stack)) << ::std::endl;
}
} else {
if (op_stack.size() > 0 && op_stack.back().get_op_code() == cppx_operation::function ) {
// CPPX_FUNCなのでcpp側に出力
dest_fs_cpp << line << ::std::endl;
} else {
// CPPX_FUNCではないのでhpp側に出力
dest_fs << line << ::std::endl;
}
}
}
source_fs.close();
dest_fs.close();
dest_fs_cpp.close();
}
void generate_cppx_tree(::fs::path source_path, ::fs::path dest_path) {
if ( ::fs::is_directory(source_path)) {
// 目的側にディレクトリが存在していない場合は、コピー
if (!::fs::exists(dest_path)) {
::fs::create_directory(dest_path);
}
// ディレクトリ配下について同様に実行
::fs::directory_iterator it = ::fs::directory_iterator(source_path);
::fs::directory_iterator end = ::fs::directory_iterator();
while (it != end) {
if (it->leaf() != ::std::string(".svn")) {
generate_cppx_tree(*it, dest_path / it->leaf());
}
++it;
}
} else {
// 拡張子がhppかhの以外は終了
if (::fs::extension(source_path) == ::std::string(".hpp") || ::fs::extension(source_path) == ::std::string(".h")) {
// 目的側にファイルが存在しているか?
if (::fs::exists(dest_path)) {
::boost::posix_time::ptime source_ptime = ::boost::posix_time::from_time_t(::fs::last_write_time(source_path));
::boost::posix_time::ptime dest_ptime = ::boost::posix_time::from_time_t(::fs::last_write_time(dest_path));
if (source_ptime > dest_ptime) {
// ソースの方が新しければ処理
generate_cppx(source_path, dest_path , true);
::std::cout << "M " << source_path.native_file_string() << ::std::endl;
} else {
::std::cout << " " << source_path.native_file_string() << ::std::endl;
}
} else {
// 目的側にソースが存在しなければ処理
generate_cppx(source_path, dest_path , false);
::std::cout << "C " << source_path.native_file_string() << ::std::endl;
}
}
}
}
int main(int argc, char* argv[]) try {
if (argc < 2) {
::std::cout << "cppx [source_path] [dest_path]" << ::std::endl;
return 0;
}
::std::cout << "source = [" << argv[1] << "]" << ::std::endl;
::std::cout << "dest = [" << argv[2] << "]" << ::std::endl;
::fs::path::default_name_check(zefiro_name);
::fs::path source_path(argv[1], ::fs::native);
::fs::path dest_path(argv[2], ::fs::native);
::std::cout << "source = " << ::fs::complete(source_path).native_file_string() << ::std::endl;
::std::cout << "dest = " << ::fs::complete(dest_path).native_file_string() << ::std::endl;
generate_cppx_tree(::fs::complete(source_path), ::fs::complete(dest_path));
return 0;
} catch (::fs::filesystem_error &e) {
::std::cerr << e.what() << ::std::endl;
}
| [
"ama@0d65b87a-bfcd-0310-b916-82c895c6ade2"
]
| [
[
[
1,
203
]
]
]
|
7b9ab065bc8738659612cb99e8aa5366c6c044db | 6bdb3508ed5a220c0d11193df174d8c215eb1fce | /Codes/Halak/UISequentialEventHandler.h | f75116c3aa409277ae3b46d36b8ff10d378d1e0c | []
| no_license | halak/halak-plusplus | d09ba78640c36c42c30343fb10572c37197cfa46 | fea02a5ae52c09ff9da1a491059082a34191cd64 | refs/heads/master | 2020-07-14T09:57:49.519431 | 2011-07-09T14:48:07 | 2011-07-09T14:48:07 | 66,716,624 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,387 | h | #pragma once
#ifndef __HALAK_UISEQUENTIALEVENTHANDLER_H__
#define __HALAK_UISEQUENTIALEVENTHANDLER_H__
# include <Halak/FWD.h>
# include <Halak/UIEventHandler.h>
# include <vector>
namespace Halak
{
class UISequentialEventHandler : public UIEventHandler
{
public:
typedef std::vector<UIEventHandlerPtr> HandlerCollection;
public:
UISequentialEventHandler();
UISequentialEventHandler(UIEventHandler* first, UIEventHandler* second);
explicit UISequentialEventHandler(int initialCapacity);
virtual ~UISequentialEventHandler();
virtual bool Invoke(const UIEventArgs& args);
void Add(UIEventHandler* item);
void Insert(int index, UIEventHandler* item);
bool Remove(UIEventHandler* item);
void RemoveAt(int index);
void Clear();
inline const HandlerCollection& GetHandlers() const;
void SetHandlers(const HandlerCollection& value);
void MoveHandlers(HandlerCollection& value);
virtual bool IsSequence() const;
private:
HandlerCollection handlers;
};
}
# include <Halak/UISequentialEventHandler.inl>
#endif | [
"[email protected]"
]
| [
[
[
1,
43
]
]
]
|
14ee5e2b7bb958260fd9c108276007436b56286b | c3a0cf3d0c023cbdb9a1ab8295aa1231543d83e7 | /sln/src/FbgBlock.cpp | 646369d8a4674f38cfcf686bbd0a5360a4f4aa47 | []
| no_license | yakergong/seedcup2008 | 2596cdb5fe404ef8628366cdd2f8003141625264 | e57b92cf576900ba6cb5e0c0f6661bba3e7f75d7 | refs/heads/master | 2016-09-05T11:06:12.717346 | 2008-12-19T13:04:28 | 2008-12-19T13:04:28 | 32,268,668 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 9,714 | cpp | /*
* Falling Block Game
* Copyright (C) 1999-2002 Jared Krinke <http://derajdezine.vze.com/>
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 or (at your option) any later version
* as published by the Free Software Foundation.
*
* This application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307 USA
*
* Jared Krinke
*
* Deraj DeZine
* http://derajdezine.vze.com/
*/
#include "FbgBlock.h"
#include "FbgGame.h"
short FbgBlock::getX()
{
int col;
for (col = 0; col < 4; col++)
{
for (int row = 0; row < 4; row++)
{
if (matrix_[row][col])
return col;
}
}
return -1;
}
//获得矩阵旋转点
short FbgBlock::getX2()
{
int col;
for (col = 3; col >= 0; col--)
{
for (int row = 0; row < 4; row++)
{
if (matrix_[row][col])
return col;
}
}
return -1;
}
short FbgBlock::getY()
{
int row;
for (row = 0; row < 4; row++)
{
for (int col = 0; col < 4; col++)
{
if (matrix_[row][col])
return row;
}
}
return -1;
}
short FbgBlock::getY2()
{
int row;
for (row = 3; row >= 0; row--)
{
for (int col = 0; col < 4; col++)
{
if (matrix_[row][col])
return row;
}
}
return -1;
}
void FbgBlock::shiftLeft()
{
for (int col = 1; col < 4; col++)
{
for (int row = 0; row < 4; row++)
matrix_[row][col - 1] = matrix_[row][col];
}
for (int row = 0; row < 4; row++)
matrix_[row][3] = false;
}
void FbgBlock::shiftRight()
{
for (int col = 2; col >= 0; col--)
{
for (int row = 0; row < 4; row++)
matrix_[row][col + 1] = matrix_[row][col];
}
for (int row = 0; row < 4; row++)
matrix_[row][0] = false;
}
void FbgBlock::shiftUp()
{
for (int row = 1; row < 4; row++)
{
for (int col = 0; col < 4; col++)
matrix_[row - 1][col] = matrix_[row][col];
}
for (int col = 0; col < 4; col++)
matrix_[3][col] = false;
}
void FbgBlock::shiftDown()
{
for (int row = 2; row >= 0; row--)
{
for (int col = 0; col < 4; col++)
matrix_[row + 1][col] = matrix_[row][col];
}
for (int col = 0; col < 4; col++)
matrix_[0][col] = false;
}
void FbgBlock::shift(int targetX, int targetY)
{
int x = getX();
int y = getY();
int width = getWidth();
int height = getHeight();
// Move to Top
while (y > 0)
{
shiftUp();
y--;
}
// Move to old level when possible
while (y < targetY)
{
if (getY2() == 3)
break;
shiftDown();
y++;
}
// Center at X-target when possible
while (x != targetX)
{
if (x < targetX)
{
if (getX2() == 3)
break;
shiftRight();
x++;
}
else if (x > targetX)
{
if (getX() == 0)
break;
shiftLeft();
x--;
}
}
}
void FbgBlock::rotateLeft()
{
int oldX = getX();
int oldY = getY();
bool oldMatrix[4][4];
for (int row = 0; row < 4; row++)
{
for (int col = 0; col < 4; col++)
oldMatrix[row][col] = matrix_[row][col];
}
for (int row = 0; row < 4; row++)
{
for (int col = 0; col < 4; col++)
matrix_[row][col] = oldMatrix[col][3 - row];
}
shift(oldX, oldY);
}
//旋转
void FbgBlock::rotateRight()
{
int oldX2 = getX2();
int oldY = getY();
bool oldMatrix[4][4];
for (int row = 0; row < 4; row++)
{
for (int col = 0; col < 4; col++)
oldMatrix[row][col] = matrix_[row][col];
}
for (int row = 0; row < 4; row++)
{
for (int col = 0; col < 4; col++)
matrix_[row][col] = oldMatrix[3 - col][row];
}
shift(oldX2 - getWidth() + 1, oldY);
}
FbgBlock::FbgBlock(FbgGame * newGame, short newIndex, bool newMatrix[16])
{
game = newGame;
index = newIndex;
posX = 3;
posY = 1;
for (int row = 0; row < 4; row++)
{
for (int col = 0; col < 4; col++)
matrix_[row][col] = newMatrix[row * 4 + col];
}
}
FbgBlock::FbgBlock()
{
posX = 3;
posY = 1;
game = NULL;
index = 0;
for (int row = 0; row < 4; row++)
{
for (int col = 0; col < 4; col++)
matrix_[row][col] = false;
}
}
void FbgBlock::operator=(const FbgBlock & theBlock)
{
game = theBlock.getGame();
posX = theBlock.getPosX();
posY = theBlock.getPosY();
index = theBlock.getIndex();
for (int row = 0; row < 4; row++)
{
for (int col = 0; col < 4; col++)
matrix_[row][col] = theBlock.getMatrixAt(row, col);
}
}
bool FbgBlock::checkBlockPosition() const
{
for (int row = 0; row < 4; row++)
{
for (int col = 0; col < 4; col++)
{
if (matrix_[row][col] && game->getMatrixAt(posY + row, posX + col))
return false;
}
}
return true;
}
bool FbgBlock::moveBlockLeft()
{
if (posX > 0)
{
posX--;
if (checkBlockPosition())
return true;
posX++;
}
else if (getX() > 0)
{
shiftLeft();
if (checkBlockPosition())
return true;
else
shiftRight();
}
return false;
}
bool FbgBlock::moveBlockRight()
{
if (posX < 6)
{
posX++;
if (checkBlockPosition())
return true;
posX--;
}
else if (getX2() < 3)
{
shiftRight();
if (checkBlockPosition())
return true;
else
shiftLeft();
}
return false;
}
bool FbgBlock::moveBlockDown()
{
posY++;
if (posY >= 15 || !checkBlockPosition())
{ // Nudging
posY--;
if (getY2() < 3)
{
shiftDown();
if (checkBlockPosition())
return true;
else
shiftUp();
}
return false;
}
else
return true;
}
bool FbgBlock::moveBlockUp()
{
posY--;
if (posY < 0 || !checkBlockPosition())
{ // Nudging
posY++;
if (getY() > 0)
{
shiftUp();
if (checkBlockPosition())
return true;
else
shiftDown();
}
return false;
}
else
return true;
}
void FbgBlock::rotateBlockLeft()
{
FbgBlock tmp = *this;
tmp.rotateLeft();
if (tmp.checkBlockPosition())
{
*this = tmp;
return;
}
else
{
// Try left
tmp.moveBlockLeft();
if (tmp.checkBlockPosition())
{
*this = tmp;
return;
}
// Try right
tmp = *this;
tmp.rotateLeft();
tmp.moveBlockRight();
if (tmp.checkBlockPosition())
{
*this = tmp;
return;
}
// Try left x2
tmp = *this;
tmp.rotateLeft();
tmp.moveBlockLeft();
tmp.moveBlockLeft();
if (tmp.checkBlockPosition())
{
*this = tmp;
return;
}
// Try down
tmp = *this;
tmp.rotateLeft();
tmp.moveBlockDown();
if (tmp.checkBlockPosition())
{
*this = tmp;
return;
}
}
}
void FbgBlock::rotateBlockRight()
{
FbgBlock tmp = *this;
tmp.rotateRight();
if (tmp.checkBlockPosition())
{
*this = tmp;
return;
}
else
{
// Try Right
tmp.moveBlockRight();
if (tmp.checkBlockPosition())
{
*this = tmp;
return;
}
// Try left
tmp = *this;
tmp.rotateRight();
tmp.moveBlockLeft();
if (tmp.checkBlockPosition())
{
*this = tmp;
return;
}
// Try right x2
tmp = *this;
tmp.rotateRight();
tmp.moveBlockRight();
tmp.moveBlockRight();
if (tmp.checkBlockPosition())
{
*this = tmp;
return;
}
// Try down
tmp = *this;
tmp.rotateRight();
tmp.moveBlockDown();
if (tmp.checkBlockPosition())
{
*this = tmp;
return;
}
}
}
void FbgBlock::copyToMatrix( bool matrix[4][4] )
{
for(int i = 0; i < 4; ++i)
for(int j = 0; j < 4; ++j)
if(matrix_[i][j])
matrix[i][j] = true;
else
matrix[i][j] = false;
} | [
"yakergong@c3067968-ca50-11dd-8ca8-e3ff79f713b6"
]
| [
[
[
1,
445
]
]
]
|
57a2bfb152dbc11c198bab7c5bf2227253098c57 | f55665c5faa3d79d0d6fe91fcfeb8daa5adf84d0 | /Depend/MyGUI/MyGUIEngine/include/MyGUI_ILogListener.h | 2ee237539edd75e68f5d9bb507a8ec820e594e69 | []
| no_license | lxinhcn/starworld | 79ed06ca49d4064307ae73156574932d6185dbab | 86eb0fb8bd268994454b0cfe6419ffef3fc0fc80 | refs/heads/master | 2021-01-10T07:43:51.858394 | 2010-09-15T02:38:48 | 2010-09-15T02:38:48 | 47,859,019 | 2 | 1 | null | null | null | null | WINDOWS-1251 | C++ | false | false | 1,498 | h | /*!
@file
@author Albert Semenov
@date 04/2010
*/
/*
This file is part of MyGUI.
MyGUI is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
MyGUI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __MYGUI_I_LOG_LISTENER_H__
#define __MYGUI_I_LOG_LISTENER_H__
#include "MyGUI_Prerequest.h"
#include "MyGUI_LogLevel.h"
namespace MyGUI
{
class MYGUI_EXPORT ILogListener
{
public:
virtual ~ILogListener() { }
// DESCRIBEME
// открытие подписчика
virtual void open() { }
// DESCRIBEME
// закрытие подписчика
virtual void close() { }
// DESCRIBEME
// запись отложеных событий
virtual void flush() { }
// DESCRIBEME
// запись события
virtual void log(const std::string& _section, LogLevel _level, const struct tm* _time, const std::string& _message, const char* _file, int _line) { }
};
}
#endif // __MYGUI_I_LOG_LISTENER_H__
| [
"albertclass@a94d7126-06ea-11de-b17c-0f1ef23b492c"
]
| [
[
[
1,
50
]
]
]
|
e3b37b68bcc3b4d7f6b03da47cc148aadd9e03d0 | b14d5833a79518a40d302e5eb40ed5da193cf1b2 | /cpp/extern/xercesc++/2.6.0/src/xercesc/validators/datatype/DateDatatypeValidator.cpp | 28524251e1d9226b435b58c29c92ebfaa2e4986b | [
"Apache-2.0"
]
| permissive | andyburke/bitflood | dcb3fb62dad7fa5e20cf9f1d58aaa94be30e82bf | fca6c0b635d07da4e6c7fbfa032921c827a981d6 | refs/heads/master | 2016-09-10T02:14:35.564530 | 2011-11-17T09:51:49 | 2011-11-17T09:51:49 | 2,794,411 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,171 | cpp | /*
* Copyright 2001,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: DateDatatypeValidator.cpp,v 1.11 2004/09/08 13:56:52 peiyongz Exp $
* $Log: DateDatatypeValidator.cpp,v $
* Revision 1.11 2004/09/08 13:56:52 peiyongz
* Apache License Version 2.0
*
* Revision 1.10 2003/12/17 00:18:38 cargilld
* Update to memory management so that the static memory manager (one used to call Initialize) is only for static data.
*
* Revision 1.9 2003/11/06 15:30:07 neilg
* first part of PSVI/schema component model implementation, thanks to David Cargill. This covers setting the PSVIHandler on parser objects, as well as implementing XSNotation, XSSimpleTypeDefinition, XSIDCDefinition, and most of XSWildcard, XSComplexTypeDefinition, XSElementDeclaration, XSAttributeDeclaration and XSAttributeUse.
*
* Revision 1.8 2003/10/02 19:21:06 peiyongz
* Implementation of Serialization/Deserialization
*
* Revision 1.7 2003/10/01 16:32:41 neilg
* improve handling of out of memory conditions, bug #23415. Thanks to David Cargill.
*
* Revision 1.6 2003/08/14 03:00:11 knoaman
* Code refactoring to improve performance of validation.
*
* Revision 1.5 2003/05/18 14:02:07 knoaman
* Memory manager implementation: pass per instance manager.
*
* Revision 1.4 2003/05/15 18:53:26 knoaman
* Partial implementation of the configurable memory manager.
*
* Revision 1.3 2002/12/18 14:17:55 gareth
* Fix to bug #13438. When you eant a vector that calls delete[] on its members you should use RefArrayVectorOf.
*
* Revision 1.2 2002/11/04 14:53:28 tng
* C++ Namespace Support.
*
* Revision 1.1.1.1 2002/02/01 22:22:40 peiyongz
* sane_include
*
* Revision 1.3 2001/11/15 17:09:23 peiyongz
* catch(...) only. (the invoker need to cath XMLException to display proper message)
*
* Revision 1.2 2001/11/14 22:02:25 peiyongz
* rethrow exception with original error message.
*
* Revision 1.1 2001/11/07 19:18:52 peiyongz
* DateTime Port
*
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/validators/datatype/DateDatatypeValidator.hpp>
#include <xercesc/util/OutOfMemoryException.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// Constructors and Destructor
// ---------------------------------------------------------------------------
DateDatatypeValidator::DateDatatypeValidator(MemoryManager* const manager)
:DateTimeValidator(0, 0, 0, DatatypeValidator::Date, manager)
{
setOrdered(XSSimpleTypeDefinition::ORDERED_PARTIAL);
}
DateDatatypeValidator::DateDatatypeValidator(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager)
:DateTimeValidator(baseValidator, facets, finalSet, DatatypeValidator::Date, manager)
{
init(enums, manager);
}
DateDatatypeValidator::~DateDatatypeValidator()
{}
DatatypeValidator* DateDatatypeValidator::newInstance
(
RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager
)
{
return (DatatypeValidator*) new (manager) DateDatatypeValidator(this, facets, enums, finalSet, manager);
}
//
// caller need to release the date created here
//
XMLDateTime* DateDatatypeValidator::parse(const XMLCh* const content, MemoryManager* const manager)
{
XMLDateTime *pRetDate = new (manager) XMLDateTime(content, manager);
try
{
pRetDate->parseDate();
}
catch(const OutOfMemoryException&)
{
throw;
}
catch (...)
{
delete pRetDate;
throw;
}
return pRetDate;
}
void DateDatatypeValidator::parse(XMLDateTime* const pDate)
{
pDate->parseDate();
}
/***
* Support for Serialization/De-serialization
***/
IMPL_XSERIALIZABLE_TOCREATE(DateDatatypeValidator)
void DateDatatypeValidator::serialize(XSerializeEngine& serEng)
{
DateTimeValidator::serialize(serEng);
}
XERCES_CPP_NAMESPACE_END
/**
* End of file DateDatatypeValidator::cpp
*/
| [
"[email protected]"
]
| [
[
[
1,
151
]
]
]
|
15342caa17a90c9954e2a075d0cd00e8a184164f | a6f42311df3830117e9590e446b105db78fdbd3a | /src/framework/base/Math.hpp | 69c4460ceba39ff47333a79eb2267913a529b067 | []
| no_license | wellsoftware/temporal-lightfield-reconstruction | a4009b9da01b93d6d77a4d0d6830c49e0d4e225f | 8d0988b5660ba0e53d65e887a51e220dcbc985ca | refs/heads/master | 2021-01-17T23:49:05.544012 | 2011-09-25T10:47:49 | 2011-09-25T10:47:49 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 66,627 | hpp | /*
* Copyright (c) 2009-2011, NVIDIA Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of NVIDIA Corporation nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include "base/DLLImports.hpp"
#include <math.h>
namespace FW
{
//------------------------------------------------------------------------
FW_CUDA_FUNC F32 sqrt (F32 a) { return ::sqrtf(a); }
FW_CUDA_FUNC F64 sqrt (F64 a) { return ::sqrt(a); }
FW_CUDA_FUNC S32 abs (S32 a) { return (a >= 0) ? a : -a; }
FW_CUDA_FUNC S64 abs (S64 a) { return (a >= 0) ? a : -a; }
FW_CUDA_FUNC F32 abs (F32 a) { return ::fabsf(a); }
FW_CUDA_FUNC F64 abs (F64 a) { return ::abs(a); }
FW_CUDA_FUNC F64 pow (F64 a, F64 b) { return ::pow(a, b); }
FW_CUDA_FUNC F64 exp (F64 a) { return ::exp(a); }
FW_CUDA_FUNC F64 log (F64 a) { return ::log(a); }
FW_CUDA_FUNC F64 sin (F64 a) { return ::sin(a); }
FW_CUDA_FUNC F64 cos (F64 a) { return ::cos(a); }
FW_CUDA_FUNC F64 tan (F64 a) { return ::tan(a); }
FW_CUDA_FUNC F32 asin (F32 a) { return ::asinf(a); }
FW_CUDA_FUNC F64 asin (F64 a) { return ::asin(a); }
FW_CUDA_FUNC F32 acos (F32 a) { return ::acosf(a); }
FW_CUDA_FUNC F64 acos (F64 a) { return ::acos(a); }
FW_CUDA_FUNC F32 atan (F32 a) { return ::atanf(a); }
FW_CUDA_FUNC F64 atan (F64 a) { return ::atan(a); }
FW_CUDA_FUNC F64 atan2 (F64 y, F64 x) { return ::atan2(y, x); }
FW_CUDA_FUNC F32 atan2 (F32 y, F32 x) { return ::atan2f(y, x); }
FW_CUDA_FUNC F32 floor (F32 a) { return ::floorf(a); }
FW_CUDA_FUNC F64 floor (F64 a) { return ::floor(a); }
FW_CUDA_FUNC F32 ceil (F32 a) { return ::ceilf(a); }
FW_CUDA_FUNC F64 ceil (F64 a) { return ::ceil(a); }
FW_CUDA_FUNC U64 doubleToBits (F64 a) { return *(U64*)&a; }
FW_CUDA_FUNC F64 bitsToDouble (U64 a) { return *(F64*)&a; }
#if FW_CUDA
FW_CUDA_FUNC F32 pow (F32 a, F32 b) { return ::__powf(a, b); }
FW_CUDA_FUNC F32 exp (F32 a) { return ::__expf(a); }
FW_CUDA_FUNC F32 exp2 (F32 a) { return ::exp2f(a); }
FW_CUDA_FUNC F64 exp2 (F64 a) { return ::exp2(a); }
FW_CUDA_FUNC F32 log (F32 a) { return ::__logf(a); }
FW_CUDA_FUNC F32 log2 (F32 a) { return ::__log2f(a); }
FW_CUDA_FUNC F64 log2 (F64 a) { return ::log2(a); }
FW_CUDA_FUNC F32 sin (F32 a) { return ::__sinf(a); }
FW_CUDA_FUNC F32 cos (F32 a) { return ::__cosf(a); }
FW_CUDA_FUNC F32 tan (F32 a) { return ::__tanf(a); }
FW_CUDA_FUNC U32 floatToBits (F32 a) { return ::__float_as_int(a); }
FW_CUDA_FUNC F32 bitsToFloat (U32 a) { return ::__int_as_float(a); }
FW_CUDA_FUNC F32 exp2 (int a) { return ::exp2f((F32)a); }
FW_CUDA_FUNC F32 fastMin (F32 a, F32 b) { return ::fminf(a, b); }
FW_CUDA_FUNC F32 fastMax (F32 a, F32 b) { return ::fmaxf(a, b); }
FW_CUDA_FUNC F64 fastMin (F64 a, F64 b) { return ::fmin(a, b); }
FW_CUDA_FUNC F64 fastMax (F64 a, F64 b) { return ::fmax(a, b); }
#else
inline F32 pow (F32 a, F32 b) { return ::powf(a, b); }
inline F32 exp (F32 a) { return ::expf(a); }
inline F32 exp2 (F32 a) { return ::powf(2.0f, a); }
inline F64 exp2 (F64 a) { return ::pow(2.0, a); }
inline F32 log (F32 a) { return ::logf(a); }
inline F32 log2 (F32 a) { return ::logf(a) / ::logf(2.0f); }
inline F64 log2 (F64 a) { return ::log(a) / ::log(2.0); }
inline F32 sin (F32 a) { return ::sinf(a); }
inline F32 cos (F32 a) { return ::cosf(a); }
inline F32 tan (F32 a) { return ::tanf(a); }
inline U32 floatToBits (F32 a) { return *(U32*)&a; }
inline F32 bitsToFloat (U32 a) { return *(F32*)&a; }
inline F32 exp2 (int a) { return bitsToFloat(clamp(a + 127, 1, 254) << 23); }
inline F32 fastMin (F32 a, F32 b) { return (a + b - abs(a - b)) * 0.5f; }
inline F32 fastMax (F32 a, F32 b) { return (a + b + abs(a - b)) * 0.5f; }
inline F64 fastMin (F64 a, F64 b) { return (a + b - abs(a - b)) * 0.5f; }
inline F64 fastMax (F64 a, F64 b) { return (a + b + abs(a - b)) * 0.5f; }
#endif
FW_CUDA_FUNC F32 scale (F32 a, int b) { return a * exp2(b); }
FW_CUDA_FUNC int popc8 (U32 mask);
FW_CUDA_FUNC int popc16 (U32 mask);
FW_CUDA_FUNC int popc32 (U32 mask);
FW_CUDA_FUNC int popc64 (U64 mask);
FW_CUDA_FUNC F32 fastClamp (F32 v, F32 lo, F32 hi) { return fastMin(fastMax(v, lo), hi); }
FW_CUDA_FUNC F64 fastClamp (F64 v, F64 lo, F64 hi) { return fastMin(fastMax(v, lo), hi); }
template <class T> FW_CUDA_FUNC T sqr(const T& a) { return a * a; }
template <class T> FW_CUDA_FUNC T rcp(const T& a) { return (a) ? (T)1 / a : (T)0; }
template <class A, class B> FW_CUDA_FUNC A lerp(const A& a, const A& b, const B& t) { return (A)(a * ((B)1 - t) + b * t); }
//------------------------------------------------------------------------
template <class T, int L> class Vector;
template <class T, int L, class S> class VectorBase
{
public:
FW_CUDA_FUNC VectorBase (void) {}
FW_CUDA_FUNC const T* getPtr (void) const { return ((S*)this)->getPtr(); }
FW_CUDA_FUNC T* getPtr (void) { return ((S*)this)->getPtr(); }
FW_CUDA_FUNC const T& get (int idx) const { FW_ASSERT(idx >= 0 && idx < L); return getPtr()[idx]; }
FW_CUDA_FUNC T& get (int idx) { FW_ASSERT(idx >= 0 && idx < L); return getPtr()[idx]; }
FW_CUDA_FUNC T set (int idx, const T& a) { T& slot = get(idx); T old = slot; slot = a; return old; }
FW_CUDA_FUNC void set (const T& a) { for (int i = 0; i < L; i++) get(i) = a; }
FW_CUDA_FUNC void set (const T* ptr) { FW_ASSERT(ptr); for (int i = 0; i < L; i++) get(i) = ptr[i]; }
FW_CUDA_FUNC void setZero (void) { set((T)0); }
#if !FW_CUDA
void print (void) const { for (int i = 0; i < L; i++) printf("%g\n", (F64)get(i)); }
#endif
FW_CUDA_FUNC bool isZero (void) const { for (int i = 0; i < L; i++) if (get(i) != (T)0) return false; return true; }
FW_CUDA_FUNC T lenSqr (void) const { T r = (T)0; for (int i = 0; i < L; i++) r += sqr(get(i)); return r; }
FW_CUDA_FUNC T length (void) const { return sqrt(lenSqr()); }
FW_CUDA_FUNC S normalized (T len = (T)1) const { return operator*(len * rcp(length())); }
FW_CUDA_FUNC void normalize (T len = (T)1) { set(normalized(len)); }
FW_CUDA_FUNC T min (void) const { T r = get(0); for (int i = 1; i < L; i++) r = FW::min(r, get(i)); return r; }
FW_CUDA_FUNC T max (void) const { T r = get(0); for (int i = 1; i < L; i++) r = FW::max(r, get(i)); return r; }
FW_CUDA_FUNC T sum (void) const { T r = get(0); for (int i = 1; i < L; i++) r += get(i); return r; }
FW_CUDA_FUNC S abs (void) const { S r; for (int i = 0; i < L; i++) r.get(i) = FW::abs(get(i)); return r; }
FW_CUDA_FUNC Vector<T, L + 1> toHomogeneous(void) const { Vector<T, L + 1> r; for (int i = 0; i < L; i++) r.get(i) = get(i); r.get(L) = (T)1; return r; }
FW_CUDA_FUNC Vector<T, L - 1> toCartesian(void) const { Vector<T, L - 1> r; T c = rcp(get(L - 1)); for (int i = 0; i < L - 1; i++) r.get(i) = get(i) * c; return r; }
FW_CUDA_FUNC const T& operator[] (int idx) const { return get(idx); }
FW_CUDA_FUNC T& operator[] (int idx) { return get(idx); }
FW_CUDA_FUNC S& operator= (const T& a) { set(a); return *(S*)this; }
FW_CUDA_FUNC S& operator+= (const T& a) { set(operator+(a)); return *(S*)this; }
FW_CUDA_FUNC S& operator-= (const T& a) { set(operator-(a)); return *(S*)this; }
FW_CUDA_FUNC S& operator*= (const T& a) { set(operator*(a)); return *(S*)this; }
FW_CUDA_FUNC S& operator/= (const T& a) { set(operator/(a)); return *(S*)this; }
FW_CUDA_FUNC S& operator%= (const T& a) { set(operator%(a)); return *(S*)this; }
FW_CUDA_FUNC S& operator&= (const T& a) { set(operator&(a)); return *(S*)this; }
FW_CUDA_FUNC S& operator|= (const T& a) { set(operator|(a)); return *(S*)this; }
FW_CUDA_FUNC S& operator^= (const T& a) { set(operator^(a)); return *(S*)this; }
FW_CUDA_FUNC S& operator<<= (const T& a) { set(operator<<(a)); return *(S*)this; }
FW_CUDA_FUNC S& operator>>= (const T& a) { set(operator>>(a)); return *(S*)this; }
FW_CUDA_FUNC S operator+ (void) const { return *this; }
FW_CUDA_FUNC S operator- (void) const { S r; for (int i = 0; i < L; i++) r.get(i) = -get(i); return r; }
FW_CUDA_FUNC S operator~ (void) const { S r; for (int i = 0; i < L; i++) r.get(i) = ~get(i); return r; }
FW_CUDA_FUNC S operator+ (const T& a) const { S r; for (int i = 0; i < L; i++) r.get(i) = get(i) + a; return r; }
FW_CUDA_FUNC S operator- (const T& a) const { S r; for (int i = 0; i < L; i++) r.get(i) = get(i) - a; return r; }
FW_CUDA_FUNC S operator* (const T& a) const { S r; for (int i = 0; i < L; i++) r.get(i) = get(i) * a; return r; }
FW_CUDA_FUNC S operator/ (const T& a) const { S r; for (int i = 0; i < L; i++) r.get(i) = get(i) / a; return r; }
FW_CUDA_FUNC S operator% (const T& a) const { S r; for (int i = 0; i < L; i++) r.get(i) = get(i) % a; return r; }
FW_CUDA_FUNC S operator& (const T& a) const { S r; for (int i = 0; i < L; i++) r.get(i) = get(i) & a; return r; }
FW_CUDA_FUNC S operator| (const T& a) const { S r; for (int i = 0; i < L; i++) r.get(i) = get(i) | a; return r; }
FW_CUDA_FUNC S operator^ (const T& a) const { S r; for (int i = 0; i < L; i++) r.get(i) = get(i) ^ a; return r; }
FW_CUDA_FUNC S operator<< (const T& a) const { S r; for (int i = 0; i < L; i++) r.get(i) = get(i) << a; return r; }
FW_CUDA_FUNC S operator>> (const T& a) const { S r; for (int i = 0; i < L; i++) r.get(i) = get(i) >> a; return r; }
template <class V> FW_CUDA_FUNC void set (const VectorBase<T, L, V>& v) { set(v.getPtr()); }
template <class V> FW_CUDA_FUNC T dot (const VectorBase<T, L, V>& v) const { T r = (T)0; for (int i = 0; i < L; i++) r += get(i) * v.get(i); return r; }
template <class V> FW_CUDA_FUNC S min (const VectorBase<T, L, V>& v) const { S r; for (int i = 0; i < L; i++) r.get(i) = FW::min(get(i), v.get(i)); return r; }
template <class V> FW_CUDA_FUNC S max (const VectorBase<T, L, V>& v) const { S r; for (int i = 0; i < L; i++) r.get(i) = FW::max(get(i), v.get(i)); return r; }
template <class V, class W> FW_CUDA_FUNC S clamp (const VectorBase<T, L, V>& lo, const VectorBase<T, L, W>& hi) const { S r; for (int i = 0; i < L; i++) r.get(i) = FW::clamp(get(i), lo.get(i), hi.get(i)); return r; }
template <class V> FW_CUDA_FUNC S& operator= (const VectorBase<T, L, V>& v) { set(v); return *(S*)this; }
template <class V> FW_CUDA_FUNC S& operator+= (const VectorBase<T, L, V>& v) { set(operator+(v)); return *(S*)this; }
template <class V> FW_CUDA_FUNC S& operator-= (const VectorBase<T, L, V>& v) { set(operator-(v)); return *(S*)this; }
template <class V> FW_CUDA_FUNC S& operator*= (const VectorBase<T, L, V>& v) { set(operator*(v)); return *(S*)this; }
template <class V> FW_CUDA_FUNC S& operator/= (const VectorBase<T, L, V>& v) { set(operator/(v)); return *(S*)this; }
template <class V> FW_CUDA_FUNC S& operator%= (const VectorBase<T, L, V>& v) { set(operator%(v)); return *(S*)this; }
template <class V> FW_CUDA_FUNC S& operator&= (const VectorBase<T, L, V>& v) { set(operator&(v)); return *(S*)this; }
template <class V> FW_CUDA_FUNC S& operator|= (const VectorBase<T, L, V>& v) { set(operator|(v)); return *(S*)this; }
template <class V> FW_CUDA_FUNC S& operator^= (const VectorBase<T, L, V>& v) { set(operator^(v)); return *(S*)this; }
template <class V> FW_CUDA_FUNC S& operator<<= (const VectorBase<T, L, V>& v) { set(operator<<(v)); return *(S*)this; }
template <class V> FW_CUDA_FUNC S& operator>>= (const VectorBase<T, L, V>& v) { set(operator>>(v)); return *(S*)this; }
template <class V> FW_CUDA_FUNC S operator+ (const VectorBase<T, L, V>& v) const { S r; for (int i = 0; i < L; i++) r.get(i) = get(i) + v.get(i); return r; }
template <class V> FW_CUDA_FUNC S operator- (const VectorBase<T, L, V>& v) const { S r; for (int i = 0; i < L; i++) r.get(i) = get(i) - v.get(i); return r; }
template <class V> FW_CUDA_FUNC S operator* (const VectorBase<T, L, V>& v) const { S r; for (int i = 0; i < L; i++) r.get(i) = get(i) * v.get(i); return r; }
template <class V> FW_CUDA_FUNC S operator/ (const VectorBase<T, L, V>& v) const { S r; for (int i = 0; i < L; i++) r.get(i) = get(i) / v.get(i); return r; }
template <class V> FW_CUDA_FUNC S operator% (const VectorBase<T, L, V>& v) const { S r; for (int i = 0; i < L; i++) r.get(i) = get(i) % v.get(i); return r; }
template <class V> FW_CUDA_FUNC S operator& (const VectorBase<T, L, V>& v) const { S r; for (int i = 0; i < L; i++) r.get(i) = get(i) & v.get(i); return r; }
template <class V> FW_CUDA_FUNC S operator| (const VectorBase<T, L, V>& v) const { S r; for (int i = 0; i < L; i++) r.get(i) = get(i) | v.get(i); return r; }
template <class V> FW_CUDA_FUNC S operator^ (const VectorBase<T, L, V>& v) const { S r; for (int i = 0; i < L; i++) r.get(i) = get(i) ^ v.get(i); return r; }
template <class V> FW_CUDA_FUNC S operator<< (const VectorBase<T, L, V>& v) const { S r; for (int i = 0; i < L; i++) r.get(i) = get(i) << v.get(i); return r; }
template <class V> FW_CUDA_FUNC S operator>> (const VectorBase<T, L, V>& v) const { S r; for (int i = 0; i < L; i++) r.get(i) = get(i) >> v.get(i); return r; }
template <class V> FW_CUDA_FUNC bool operator== (const VectorBase<T, L, V>& v) const { for (int i = 0; i < L; i++) if (get(i) != v.get(i)) return false; return true; }
template <class V> FW_CUDA_FUNC bool operator!= (const VectorBase<T, L, V>& v) const { return (!operator==(v)); }
};
//------------------------------------------------------------------------
template <class T, int L> class Vector : public VectorBase<T, L, Vector<T, L> >
{
public:
FW_CUDA_FUNC Vector (void) { setZero(); }
FW_CUDA_FUNC Vector (T a) { set(a); }
FW_CUDA_FUNC const T* getPtr (void) const { return m_values; }
FW_CUDA_FUNC T* getPtr (void) { return m_values; }
static FW_CUDA_FUNC Vector fromPtr (const T* ptr) { Vector v; v.set(ptr); return v; }
template <class V> FW_CUDA_FUNC Vector(const VectorBase<T, L, V>& v) { set(v); }
template <class V> FW_CUDA_FUNC Vector& operator=(const VectorBase<T, L, V>& v) { set(v); return *this; }
private:
T m_values[L];
};
//------------------------------------------------------------------------
class Vec2i : public VectorBase<S32, 2, Vec2i>, public int2
{
public:
FW_CUDA_FUNC Vec2i (void) { setZero(); }
FW_CUDA_FUNC Vec2i (S32 a) { set(a); }
FW_CUDA_FUNC Vec2i (S32 xx, S32 yy) { x = xx; y = yy; }
FW_CUDA_FUNC const S32* getPtr (void) const { return &x; }
FW_CUDA_FUNC S32* getPtr (void) { return &x; }
static FW_CUDA_FUNC Vec2i fromPtr (const S32* ptr) { return Vec2i(ptr[0], ptr[1]); }
FW_CUDA_FUNC Vec2i perpendicular(void) const { return Vec2i(-y, x); }
template <class V> FW_CUDA_FUNC Vec2i(const VectorBase<S32, 2, V>& v) { set(v); }
template <class V> FW_CUDA_FUNC Vec2i& operator=(const VectorBase<S32, 2, V>& v) { set(v); return *this; }
};
//------------------------------------------------------------------------
class Vec3i : public VectorBase<S32, 3, Vec3i>, public int3
{
public:
FW_CUDA_FUNC Vec3i (void) { setZero(); }
FW_CUDA_FUNC Vec3i (S32 a) { set(a); }
FW_CUDA_FUNC Vec3i (S32 xx, S32 yy, S32 zz) { x = xx; y = yy; z = zz; }
FW_CUDA_FUNC Vec3i (const Vec2i& xy, S32 zz) { x = xy.x; y = xy.y; z = zz; }
FW_CUDA_FUNC const S32* getPtr (void) const { return &x; }
FW_CUDA_FUNC S32* getPtr (void) { return &x; }
static FW_CUDA_FUNC Vec3i fromPtr (const S32* ptr) { return Vec3i(ptr[0], ptr[1], ptr[2]); }
FW_CUDA_FUNC Vec2i getXY (void) const { return Vec2i(x, y); }
template <class V> FW_CUDA_FUNC Vec3i(const VectorBase<S32, 3, V>& v) { set(v); }
template <class V> FW_CUDA_FUNC Vec3i& operator=(const VectorBase<S32, 3, V>& v) { set(v); return *this; }
};
//------------------------------------------------------------------------
class Vec4i : public VectorBase<S32, 4, Vec4i>, public int4
{
public:
FW_CUDA_FUNC Vec4i (void) { setZero(); }
FW_CUDA_FUNC Vec4i (S32 a) { set(a); }
FW_CUDA_FUNC Vec4i (S32 xx, S32 yy, S32 zz, S32 ww) { x = xx; y = yy; z = zz; w = ww; }
FW_CUDA_FUNC Vec4i (const Vec2i& xy, S32 zz, S32 ww) { x = xy.x; y = xy.y; z = zz; w = ww; }
FW_CUDA_FUNC Vec4i (const Vec3i& xyz, S32 ww) { x = xyz.x; y = xyz.y; z = xyz.z; w = ww; }
FW_CUDA_FUNC Vec4i (const Vec2i& xy, const Vec2i& zw) { x = xy.x; y = xy.y; z = zw.x; w = zw.y; }
FW_CUDA_FUNC const S32* getPtr (void) const { return &x; }
FW_CUDA_FUNC S32* getPtr (void) { return &x; }
static FW_CUDA_FUNC Vec4i fromPtr (const S32* ptr) { return Vec4i(ptr[0], ptr[1], ptr[2], ptr[3]); }
FW_CUDA_FUNC Vec2i getXY (void) const { return Vec2i(x, y); }
FW_CUDA_FUNC Vec3i getXYZ (void) const { return Vec3i(x, y, z); }
FW_CUDA_FUNC Vec3i getXYW (void) const { return Vec3i(x, y, w); }
template <class V> FW_CUDA_FUNC Vec4i(const VectorBase<S32, 4, V>& v) { set(v); }
template <class V> FW_CUDA_FUNC Vec4i& operator=(const VectorBase<S32, 4, V>& v) { set(v); return *this; }
};
//------------------------------------------------------------------------
class Vec2f : public VectorBase<F32, 2, Vec2f>, public float2
{
public:
FW_CUDA_FUNC Vec2f (void) { setZero(); }
FW_CUDA_FUNC Vec2f (F32 a) { set(a); }
FW_CUDA_FUNC Vec2f (F32 xx, F32 yy) { x = xx; y = yy; }
FW_CUDA_FUNC Vec2f (const Vec2i& v) { x = (F32)v.x; y = (F32)v.y; }
FW_CUDA_FUNC const F32* getPtr (void) const { return &x; }
FW_CUDA_FUNC F32* getPtr (void) { return &x; }
static FW_CUDA_FUNC Vec2f fromPtr (const F32* ptr) { return Vec2f(ptr[0], ptr[1]); }
FW_CUDA_FUNC operator Vec2i (void) const { return Vec2i((S32)x, (S32)y); }
FW_CUDA_FUNC Vec2f perpendicular(void) const { return Vec2f(-y, x); }
FW_CUDA_FUNC F32 cross (const Vec2f& v) const { return x * v.y - y * v.x; }
template <class V> FW_CUDA_FUNC Vec2f(const VectorBase<F32, 2, V>& v) { set(v); }
template <class V> FW_CUDA_FUNC Vec2f& operator=(const VectorBase<F32, 2, V>& v) { set(v); return *this; }
};
//------------------------------------------------------------------------
class Vec3f : public VectorBase<F32, 3, Vec3f>, public float3
{
public:
FW_CUDA_FUNC Vec3f (void) { setZero(); }
FW_CUDA_FUNC Vec3f (F32 a) { set(a); }
FW_CUDA_FUNC Vec3f (F32 xx, F32 yy, F32 zz) { x = xx; y = yy; z = zz; }
FW_CUDA_FUNC Vec3f (const Vec2f& xy, F32 zz) { x = xy.x; y = xy.y; z = zz; }
FW_CUDA_FUNC Vec3f (const Vec3i& v) { x = (F32)v.x; y = (F32)v.y; z = (F32)v.z; }
FW_CUDA_FUNC const F32* getPtr (void) const { return &x; }
FW_CUDA_FUNC F32* getPtr (void) { return &x; }
static FW_CUDA_FUNC Vec3f fromPtr (const F32* ptr) { return Vec3f(ptr[0], ptr[1], ptr[2]); }
FW_CUDA_FUNC operator Vec3i (void) const { return Vec3i((S32)x, (S32)y, (S32)z); }
FW_CUDA_FUNC Vec2f getXY (void) const { return Vec2f(x, y); }
FW_CUDA_FUNC Vec3f cross (const Vec3f& v) const { return Vec3f(y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x); }
template <class V> FW_CUDA_FUNC Vec3f(const VectorBase<F32, 3, V>& v) { set(v); }
template <class V> FW_CUDA_FUNC Vec3f& operator=(const VectorBase<F32, 3, V>& v) { set(v); return *this; }
};
//------------------------------------------------------------------------
class Vec4f : public VectorBase<F32, 4, Vec4f>, public float4
{
public:
FW_CUDA_FUNC Vec4f (void) { setZero(); }
FW_CUDA_FUNC Vec4f (F32 a) { set(a); }
FW_CUDA_FUNC Vec4f (F32 xx, F32 yy, F32 zz, F32 ww) { x = xx; y = yy; z = zz; w = ww; }
FW_CUDA_FUNC Vec4f (const Vec2f& xy, F32 zz, F32 ww) { x = xy.x; y = xy.y; z = zz; w = ww; }
FW_CUDA_FUNC Vec4f (const Vec3f& xyz, F32 ww) { x = xyz.x; y = xyz.y; z = xyz.z; w = ww; }
FW_CUDA_FUNC Vec4f (const Vec2f& xy, const Vec2f& zw) { x = xy.x; y = xy.y; z = zw.x; w = zw.y; }
FW_CUDA_FUNC Vec4f (const Vec4i& v) { x = (F32)v.x; y = (F32)v.y; z = (F32)v.z; w = (F32)v.w; }
FW_CUDA_FUNC const F32* getPtr (void) const { return &x; }
FW_CUDA_FUNC F32* getPtr (void) { return &x; }
static FW_CUDA_FUNC Vec4f fromPtr (const F32* ptr) { return Vec4f(ptr[0], ptr[1], ptr[2], ptr[3]); }
FW_CUDA_FUNC operator Vec4i (void) const { return Vec4i((S32)x, (S32)y, (S32)z, (S32)w); }
FW_CUDA_FUNC Vec2f getXY (void) const { return Vec2f(x, y); }
FW_CUDA_FUNC Vec3f getXYZ (void) const { return Vec3f(x, y, z); }
FW_CUDA_FUNC Vec3f getXYW (void) const { return Vec3f(x, y, w); }
#if !FW_CUDA
static Vec4f fromABGR (U32 abgr);
U32 toABGR (void) const;
#endif
template <class V> FW_CUDA_FUNC Vec4f(const VectorBase<F32, 4, V>& v) { set(v); }
template <class V> FW_CUDA_FUNC Vec4f& operator=(const VectorBase<F32, 4, V>& v) { set(v); return *this; }
};
//------------------------------------------------------------------------
class Vec2d : public VectorBase<F64, 2, Vec2d>, public double2
{
public:
FW_CUDA_FUNC Vec2d (void) { setZero(); }
FW_CUDA_FUNC Vec2d (F64 a) { set(a); }
FW_CUDA_FUNC Vec2d (F64 xx, F64 yy) { x = xx; y = yy; }
FW_CUDA_FUNC Vec2d (const Vec2i& v) { x = (F64)v.x; y = (F64)v.y; }
FW_CUDA_FUNC Vec2d (const Vec2f& v) { x = v.x; y = v.y; }
FW_CUDA_FUNC const F64* getPtr (void) const { return &x; }
FW_CUDA_FUNC F64* getPtr (void) { return &x; }
static FW_CUDA_FUNC Vec2d fromPtr (const F64* ptr) { return Vec2d(ptr[0], ptr[1]); }
FW_CUDA_FUNC operator Vec2i (void) const { return Vec2i((S32)x, (S32)y); }
FW_CUDA_FUNC operator Vec2f (void) const { return Vec2f((F32)x, (F32)y); }
FW_CUDA_FUNC Vec2d perpendicular(void) const { return Vec2d(-y, x); }
FW_CUDA_FUNC F64 cross (const Vec2d& v) const { return x * v.y - y * v.x; }
template <class V> FW_CUDA_FUNC Vec2d(const VectorBase<F64, 2, V>& v) { set(v); }
template <class V> FW_CUDA_FUNC Vec2d& operator=(const VectorBase<F64, 2, V>& v) { set(v); return *this; }
};
//------------------------------------------------------------------------
class Vec3d : public VectorBase<F64, 3, Vec3d>, public double3
{
public:
FW_CUDA_FUNC Vec3d (void) { setZero(); }
FW_CUDA_FUNC Vec3d (F64 a) { set(a); }
FW_CUDA_FUNC Vec3d (F64 xx, F64 yy, F64 zz) { x = xx; y = yy; z = zz; }
FW_CUDA_FUNC Vec3d (const Vec2d& xy, F64 zz) { x = xy.x; y = xy.y; z = zz; }
FW_CUDA_FUNC Vec3d (const Vec3i& v) { x = (F64)v.x; y = (F64)v.y; z = (F64)v.z; }
FW_CUDA_FUNC Vec3d (const Vec3f& v) { x = v.x; y = v.y; z = v.z; }
FW_CUDA_FUNC const F64* getPtr (void) const { return &x; }
FW_CUDA_FUNC F64* getPtr (void) { return &x; }
static FW_CUDA_FUNC Vec3d fromPtr (const F64* ptr) { return Vec3d(ptr[0], ptr[1], ptr[2]); }
FW_CUDA_FUNC operator Vec3i (void) const { return Vec3i((S32)x, (S32)y, (S32)z); }
FW_CUDA_FUNC operator Vec3f (void) const { return Vec3f((F32)x, (F32)y, (F32)z); }
FW_CUDA_FUNC Vec2d getXY (void) const { return Vec2d(x, y); }
FW_CUDA_FUNC Vec3d cross (const Vec3d& v) const { return Vec3d(y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x); }
template <class V> FW_CUDA_FUNC Vec3d(const VectorBase<F64, 3, V>& v) { set(v); }
template <class V> FW_CUDA_FUNC Vec3d& operator=(const VectorBase<F64, 3, V>& v) { set(v); return *this; }
};
//------------------------------------------------------------------------
class Vec4d : public VectorBase<F64, 4, Vec4d>, public double4
{
public:
FW_CUDA_FUNC Vec4d (void) { setZero(); }
FW_CUDA_FUNC Vec4d (F64 a) { set(a); }
FW_CUDA_FUNC Vec4d (F64 xx, F64 yy, F64 zz, F64 ww) { x = xx; y = yy; z = zz; w = ww; }
FW_CUDA_FUNC Vec4d (const Vec2d& xy, F64 zz, F64 ww) { x = xy.x; y = xy.y; z = zz; w = ww; }
FW_CUDA_FUNC Vec4d (const Vec3d& xyz, F64 ww) { x = xyz.x; y = xyz.y; z = xyz.z; w = ww; }
FW_CUDA_FUNC Vec4d (const Vec2d& xy, const Vec2d& zw) { x = xy.x; y = xy.y; z = zw.x; w = zw.y; }
FW_CUDA_FUNC Vec4d (const Vec4i& v) { x = (F64)v.x; y = (F64)v.y; z = (F64)v.z; w = (F64)v.w; }
FW_CUDA_FUNC Vec4d (const Vec4f& v) { x = v.x; y = v.y; z = v.z; w = v.w; }
FW_CUDA_FUNC const F64* getPtr (void) const { return &x; }
FW_CUDA_FUNC F64* getPtr (void) { return &x; }
static FW_CUDA_FUNC Vec4d fromPtr (const F64* ptr) { return Vec4d(ptr[0], ptr[1], ptr[2], ptr[3]); }
FW_CUDA_FUNC operator Vec4i (void) const { return Vec4i((S32)x, (S32)y, (S32)z, (S32)w); }
FW_CUDA_FUNC operator Vec4f (void) const { return Vec4f((F32)x, (F32)y, (F32)z, (F32)w); }
FW_CUDA_FUNC Vec2d getXY (void) const { return Vec2d(x, y); }
FW_CUDA_FUNC Vec3d getXYZ (void) const { return Vec3d(x, y, z); }
FW_CUDA_FUNC Vec3d getXYW (void) const { return Vec3d(x, y, w); }
template <class V> FW_CUDA_FUNC Vec4d(const VectorBase<F64, 4, V>& v) { set(v); }
template <class V> FW_CUDA_FUNC Vec4d& operator=(const VectorBase<F64, 4, V>& v) { set(v); return *this; }
};
//------------------------------------------------------------------------
template <class T, int L, class S> FW_CUDA_FUNC T lenSqr (const VectorBase<T, L, S>& v) { return v.lenSqr(); }
template <class T, int L, class S> FW_CUDA_FUNC T length (const VectorBase<T, L, S>& v) { return v.length(); }
template <class T, int L, class S> FW_CUDA_FUNC S normalize (const VectorBase<T, L, S>& v, T len = (T)1) { return v.normalized(len); }
template <class T, int L, class S> FW_CUDA_FUNC T min (const VectorBase<T, L, S>& v) { return v.min(); }
template <class T, int L, class S> FW_CUDA_FUNC T max (const VectorBase<T, L, S>& v) { return v.max(); }
template <class T, int L, class S> FW_CUDA_FUNC T sum (const VectorBase<T, L, S>& v) { return v.sum(); }
template <class T, int L, class S> FW_CUDA_FUNC S abs (const VectorBase<T, L, S>& v) { return v.abs(); }
template <class T, int L, class S> FW_CUDA_FUNC S operator+ (const T& a, const VectorBase<T, L, S>& b) { return b + a; }
template <class T, int L, class S> FW_CUDA_FUNC S operator- (const T& a, const VectorBase<T, L, S>& b) { return -b + a; }
template <class T, int L, class S> FW_CUDA_FUNC S operator* (const T& a, const VectorBase<T, L, S>& b) { return b * a; }
template <class T, int L, class S> FW_CUDA_FUNC S operator/ (const T& a, const VectorBase<T, L, S>& b) { S r; for (int i = 0; i < L; i++) r.get(i) = a / b.get(i); return r; }
template <class T, int L, class S> FW_CUDA_FUNC S operator% (const T& a, const VectorBase<T, L, S>& b) { S r; for (int i = 0; i < L; i++) r.get(i) = a % b.get(i); return r; }
template <class T, int L, class S> FW_CUDA_FUNC S operator& (const T& a, const VectorBase<T, L, S>& b) { return b & a; }
template <class T, int L, class S> FW_CUDA_FUNC S operator| (const T& a, const VectorBase<T, L, S>& b) { return b | a; }
template <class T, int L, class S> FW_CUDA_FUNC S operator^ (const T& a, const VectorBase<T, L, S>& b) { return b ^ a; }
template <class T, int L, class S> FW_CUDA_FUNC S operator<< (const T& a, const VectorBase<T, L, S>& b) { S r; for (int i = 0; i < L; i++) r.get(i) = a << b.get(i); return r; }
template <class T, int L, class S> FW_CUDA_FUNC S operator>> (const T& a, const VectorBase<T, L, S>& b) { S r; for (int i = 0; i < L; i++) r.get(i) = a >> b.get(i); return r; }
template <class T, int L, class S, class V> FW_CUDA_FUNC T dot(const VectorBase<T, L, S>& a, const VectorBase<T, L, V>& b) { return a.dot(b); }
FW_CUDA_FUNC Vec2f perpendicular (const Vec2f& v) { return v.perpendicular(); }
FW_CUDA_FUNC Vec2d perpendicular (const Vec2d& v) { return v.perpendicular(); }
FW_CUDA_FUNC F32 cross (const Vec2f& a, const Vec2f& b) { return a.cross(b); }
FW_CUDA_FUNC F64 cross (const Vec2d& a, const Vec2d& b) { return a.cross(b); }
FW_CUDA_FUNC Vec3f cross (const Vec3f& a, const Vec3f& b) { return a.cross(b); }
FW_CUDA_FUNC Vec3d cross (const Vec3d& a, const Vec3d& b) { return a.cross(b); }
#define MINMAX(T) \
FW_CUDA_FUNC T min(const T& a, const T& b) { return a.min(b); } \
FW_CUDA_FUNC T min(T& a, T& b) { return a.min(b); } \
FW_CUDA_FUNC T max(const T& a, const T& b) { return a.max(b); } \
FW_CUDA_FUNC T max(T& a, T& b) { return a.max(b); } \
FW_CUDA_FUNC T min(const T& a, const T& b, const T& c) { return a.min(b).min(c); } \
FW_CUDA_FUNC T min(T& a, T& b, T& c) { return a.min(b).min(c); } \
FW_CUDA_FUNC T max(const T& a, const T& b, const T& c) { return a.max(b).max(c); } \
FW_CUDA_FUNC T max(T& a, T& b, T& c) { return a.max(b).max(c); } \
FW_CUDA_FUNC T min(const T& a, const T& b, const T& c, const T& d) { return a.min(b).min(c).min(d); } \
FW_CUDA_FUNC T min(T& a, T& b, T& c, T& d) { return a.min(b).min(c).min(d); } \
FW_CUDA_FUNC T max(const T& a, const T& b, const T& c, const T& d) { return a.max(b).max(c).max(d); } \
FW_CUDA_FUNC T max(T& a, T& b, T& c, T& d) { return a.max(b).max(c).max(d); } \
FW_CUDA_FUNC T clamp(const T& v, const T& lo, const T& hi) { return v.clamp(lo, hi); } \
FW_CUDA_FUNC T clamp(T& v, T& lo, T& hi) { return v.clamp(lo, hi); }
MINMAX(Vec2i) MINMAX(Vec3i) MINMAX(Vec4i)
MINMAX(Vec2f) MINMAX(Vec3f) MINMAX(Vec4f)
MINMAX(Vec2d) MINMAX(Vec3d) MINMAX(Vec4d)
#undef MINMAX
//------------------------------------------------------------------------
template <class T, int L, class S> class MatrixBase
{
public:
FW_CUDA_FUNC MatrixBase (void) {}
template <class V> static FW_CUDA_FUNC S translate (const VectorBase<T, L - 1, V>& v);
template <class V> static FW_CUDA_FUNC S scale (const VectorBase<T, L - 1, V>& v);
template <class V> static FW_CUDA_FUNC S scale (const VectorBase<T, L, V>& v);
FW_CUDA_FUNC const T* getPtr (void) const { return ((S*)this)->getPtr(); }
FW_CUDA_FUNC T* getPtr (void) { return ((S*)this)->getPtr(); }
FW_CUDA_FUNC const T& get (int idx) const { FW_ASSERT(idx >= 0 && idx < L * L); return getPtr()[idx]; }
FW_CUDA_FUNC T& get (int idx) { FW_ASSERT(idx >= 0 && idx < L * L); return getPtr()[idx]; }
FW_CUDA_FUNC const T& get (int r, int c) const { FW_ASSERT(r >= 0 && r < L && c >= 0 && c < L); return getPtr()[r + c * L]; }
FW_CUDA_FUNC T& get (int r, int c) { FW_ASSERT(r >= 0 && r < L && c >= 0 && c < L); return getPtr()[r + c * L]; }
FW_CUDA_FUNC T set (int idx, const T& a) { T& slot = get(idx); T old = slot; slot = a; return old; }
FW_CUDA_FUNC T set (int r, int c, const T& a) { T& slot = get(r, c); T old = slot; slot = a; return old; }
FW_CUDA_FUNC const Vector<T, L>& col (int c) const { FW_ASSERT(c >= 0 && c < L); return *(const Vector<T, L>*)(getPtr() + c * L); }
FW_CUDA_FUNC Vector<T, L>& col (int c) { FW_ASSERT(c >= 0 && c < L); return *(Vector<T, L>*)(getPtr() + c * L); }
FW_CUDA_FUNC const Vector<T, L>& getCol (int c) const { return col(c); }
FW_CUDA_FUNC Vector<T, L> getRow (int r) const;
FW_CUDA_FUNC void set (const T& a) { for (int i = 0; i < L * L; i++) get(i) = a; }
FW_CUDA_FUNC void set (const T* ptr) { FW_ASSERT(ptr); for (int i = 0; i < L * L; i++) get(i) = ptr[i]; }
FW_CUDA_FUNC void setZero (void) { set((T)0); }
FW_CUDA_FUNC void setIdentity (void) { setZero(); for (int i = 0; i < L; i++) get(i, i) = (T)1; }
#if !FW_CUDA
void print (void) const;
#endif
FW_CUDA_FUNC T det (void) const;
FW_CUDA_FUNC S transposed (void) const;
FW_CUDA_FUNC S inverted (void) const;
FW_CUDA_FUNC void transpose (void) { set(transposed()); }
FW_CUDA_FUNC void invert (void) { set(inverted()); }
FW_CUDA_FUNC const T& operator() (int r, int c) const { return get(r, c); }
FW_CUDA_FUNC T& operator() (int r, int c) { return get(r, c); }
FW_CUDA_FUNC S& operator= (const T& a) { set(a); return *(S*)this; }
FW_CUDA_FUNC S& operator+= (const T& a) { set(operator+(a)); return *(S*)this; }
FW_CUDA_FUNC S& operator-= (const T& a) { set(operator-(a)); return *(S*)this; }
FW_CUDA_FUNC S& operator*= (const T& a) { set(operator*(a)); return *(S*)this; }
FW_CUDA_FUNC S& operator/= (const T& a) { set(operator/(a)); return *(S*)this; }
FW_CUDA_FUNC S& operator%= (const T& a) { set(operator%(a)); return *(S*)this; }
FW_CUDA_FUNC S& operator&= (const T& a) { set(operator&(a)); return *(S*)this; }
FW_CUDA_FUNC S& operator|= (const T& a) { set(operator|(a)); return *(S*)this; }
FW_CUDA_FUNC S& operator^= (const T& a) { set(operator^(a)); return *(S*)this; }
FW_CUDA_FUNC S& operator<<= (const T& a) { set(operator<<(a)); return *(S*)this; }
FW_CUDA_FUNC S& operator>>= (const T& a) { set(operator>>(a)); return *(S*)this; }
FW_CUDA_FUNC S operator+ (void) const { return *this; }
FW_CUDA_FUNC S operator- (void) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = -get(i); return r; }
FW_CUDA_FUNC S operator~ (void) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = ~get(i); return r; }
FW_CUDA_FUNC S operator+ (const T& a) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) + a; return r; }
FW_CUDA_FUNC S operator- (const T& a) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) - a; return r; }
FW_CUDA_FUNC S operator* (const T& a) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) * a; return r; }
FW_CUDA_FUNC S operator/ (const T& a) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) / a; return r; }
FW_CUDA_FUNC S operator% (const T& a) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) % a; return r; }
FW_CUDA_FUNC S operator& (const T& a) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) & a; return r; }
FW_CUDA_FUNC S operator| (const T& a) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) | a; return r; }
FW_CUDA_FUNC S operator^ (const T& a) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) ^ a; return r; }
FW_CUDA_FUNC S operator<< (const T& a) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) << a; return r; }
FW_CUDA_FUNC S operator>> (const T& a) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) >> a; return r; }
template <class V> FW_CUDA_FUNC void setCol (int c, const VectorBase<T, L, V>& v) { col(c) = v; }
template <class V> FW_CUDA_FUNC void setRow (int r, const VectorBase<T, L, V>& v);
template <class V> FW_CUDA_FUNC void set (const MatrixBase<T, L, V>& v) { set(v.getPtr()); }
template <class V> FW_CUDA_FUNC S& operator= (const MatrixBase<T, L, V>& v) { set(v); return *(S*)this; }
template <class V> FW_CUDA_FUNC S& operator+= (const MatrixBase<T, L, V>& v) { set(operator+(v)); return *(S*)this; }
template <class V> FW_CUDA_FUNC S& operator-= (const MatrixBase<T, L, V>& v) { set(operator-(v)); return *(S*)this; }
template <class V> FW_CUDA_FUNC S& operator*= (const MatrixBase<T, L, V>& v) { set(operator*(v)); return *(S*)this; }
template <class V> FW_CUDA_FUNC S& operator/= (const MatrixBase<T, L, V>& v) { set(operator/(v)); return *(S*)this; }
template <class V> FW_CUDA_FUNC S& operator%= (const MatrixBase<T, L, V>& v) { set(operator%(v)); return *(S*)this; }
template <class V> FW_CUDA_FUNC S& operator&= (const MatrixBase<T, L, V>& v) { set(operator&(v)); return *(S*)this; }
template <class V> FW_CUDA_FUNC S& operator|= (const MatrixBase<T, L, V>& v) { set(operator|(v)); return *(S*)this; }
template <class V> FW_CUDA_FUNC S& operator^= (const MatrixBase<T, L, V>& v) { set(operator^(v)); return *(S*)this; }
template <class V> FW_CUDA_FUNC S& operator<<= (const MatrixBase<T, L, V>& v) { set(operator<<(v)); return *(S*)this; }
template <class V> FW_CUDA_FUNC S& operator>>= (const MatrixBase<T, L, V>& v) { set(operator>>(v)); return *(S*)this; }
template <class V> FW_CUDA_FUNC V operator* (const VectorBase<T, L, V>& v) const;
template <class V> FW_CUDA_FUNC V operator* (const VectorBase<T, L - 1, V>& v) const;
template <class V> FW_CUDA_FUNC S operator+ (const MatrixBase<T, L, V>& v) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) + v.get(i); return r; }
template <class V> FW_CUDA_FUNC S operator- (const MatrixBase<T, L, V>& v) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) - v.get(i); return r; }
template <class V> FW_CUDA_FUNC S operator* (const MatrixBase<T, L, V>& v) const;
template <class V> FW_CUDA_FUNC S operator/ (const MatrixBase<T, L, V>& v) const { return operator*(v.inverted()); }
template <class V> FW_CUDA_FUNC S operator% (const MatrixBase<T, L, V>& v) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) % v.get(i); return r; }
template <class V> FW_CUDA_FUNC S operator& (const MatrixBase<T, L, V>& v) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) & v.get(i); return r; }
template <class V> FW_CUDA_FUNC S operator| (const MatrixBase<T, L, V>& v) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) | v.get(i); return r; }
template <class V> FW_CUDA_FUNC S operator^ (const MatrixBase<T, L, V>& v) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) ^ v.get(i); return r; }
template <class V> FW_CUDA_FUNC S operator<< (const MatrixBase<T, L, V>& v) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) << v.get(i); return r; }
template <class V> FW_CUDA_FUNC S operator>> (const MatrixBase<T, L, V>& v) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) >> v.get(i); return r; }
template <class V> FW_CUDA_FUNC bool operator== (const MatrixBase<T, L, V>& v) const { for (int i = 0; i < L * L; i++) if (get(i) != v.get(i)) return false; return true; }
template <class V> FW_CUDA_FUNC bool operator!= (const MatrixBase<T, L, V>& v) const { return (!operator==(v)); }
};
//------------------------------------------------------------------------
template <class T, int L> class Matrix : public MatrixBase<T, L, Matrix<T, L> >
{
public:
FW_CUDA_FUNC Matrix (void) { setIdentity(); }
FW_CUDA_FUNC explicit Matrix (T a) { set(a); }
FW_CUDA_FUNC const T* getPtr (void) const { return m_values; }
FW_CUDA_FUNC T* getPtr (void) { return m_values; }
static FW_CUDA_FUNC Matrix fromPtr (const T* ptr) { Matrix v; v.set(ptr); return v; }
template <class V> FW_CUDA_FUNC Matrix(const MatrixBase<T, L, V>& v) { set(v); }
template <class V> FW_CUDA_FUNC Matrix& operator=(const MatrixBase<T, L, V>& v) { set(v); return *this; }
private:
T m_values[L * L];
};
//------------------------------------------------------------------------
class Mat2f : public MatrixBase<F32, 2, Mat2f>
{
public:
FW_CUDA_FUNC Mat2f (void) { setIdentity(); }
FW_CUDA_FUNC explicit Mat2f (F32 a) { set(a); }
FW_CUDA_FUNC const F32* getPtr (void) const { return &m00; }
FW_CUDA_FUNC F32* getPtr (void) { return &m00; }
static FW_CUDA_FUNC Mat2f fromPtr (const F32* ptr) { Mat2f v; v.set(ptr); return v; }
template <class V> FW_CUDA_FUNC Mat2f(const MatrixBase<F32, 2, V>& v) { set(v); }
template <class V> FW_CUDA_FUNC Mat2f& operator=(const MatrixBase<F32, 2, V>& v) { set(v); return *this; }
public:
F32 m00, m10;
F32 m01, m11;
};
//------------------------------------------------------------------------
class Mat3f : public MatrixBase<F32, 3, Mat3f>
{
public:
FW_CUDA_FUNC Mat3f (void) { setIdentity(); }
FW_CUDA_FUNC explicit Mat3f (F32 a) { set(a); }
FW_CUDA_FUNC const F32* getPtr (void) const { return &m00; }
FW_CUDA_FUNC F32* getPtr (void) { return &m00; }
static FW_CUDA_FUNC Mat3f fromPtr (const F32* ptr) { Mat3f v; v.set(ptr); return v; }
template <class V> FW_CUDA_FUNC Mat3f(const MatrixBase<F32, 3, V>& v) { set(v); }
template <class V> FW_CUDA_FUNC Mat3f& operator=(const MatrixBase<F32, 3, V>& v) { set(v); return *this; }
public:
F32 m00, m10, m20;
F32 m01, m11, m21;
F32 m02, m12, m22;
};
//------------------------------------------------------------------------
class Mat4f : public MatrixBase<F32, 4, Mat4f>
{
public:
FW_CUDA_FUNC Mat4f (void) { setIdentity(); }
FW_CUDA_FUNC explicit Mat4f (F32 a) { set(a); }
FW_CUDA_FUNC const F32* getPtr (void) const { return &m00; }
FW_CUDA_FUNC F32* getPtr (void) { return &m00; }
static FW_CUDA_FUNC Mat4f fromPtr (const F32* ptr) { Mat4f v; v.set(ptr); return v; }
#if !FW_CUDA
Mat3f getXYZ (void) const;
static Mat4f fitToView (const Vec2f& pos, const Vec2f& size, const Vec2f& viewSize);
static Mat4f perspective (F32 fov, F32 nearDist, F32 farDist);
#endif
template <class V> FW_CUDA_FUNC Mat4f(const MatrixBase<F32, 4, V>& v) { set(v); }
template <class V> FW_CUDA_FUNC Mat4f& operator=(const MatrixBase<F32, 4, V>& v) { set(v); return *this; }
public:
F32 m00, m10, m20, m30;
F32 m01, m11, m21, m31;
F32 m02, m12, m22, m32;
F32 m03, m13, m23, m33;
};
//------------------------------------------------------------------------
class Mat2d : public MatrixBase<F64, 2, Mat2d>
{
public:
FW_CUDA_FUNC Mat2d (void) { setIdentity(); }
FW_CUDA_FUNC Mat2d (const Mat2f& a) { for (int i = 0; i < 2 * 2; i++) set(i, (F64)a.get(i)); }
FW_CUDA_FUNC explicit Mat2d (F64 a) { set(a); }
FW_CUDA_FUNC const F64* getPtr (void) const { return &m00; }
FW_CUDA_FUNC F64* getPtr (void) { return &m00; }
static FW_CUDA_FUNC Mat2d fromPtr (const F64* ptr) { Mat2d v; v.set(ptr); return v; }
FW_CUDA_FUNC operator Mat2f (void) const { Mat2f r; for (int i = 0; i < 2 * 2; i++) r.set(i, (F32)get(i)); return r; }
template <class V> FW_CUDA_FUNC Mat2d(const MatrixBase<F64, 2, V>& v) { set(v); }
template <class V> FW_CUDA_FUNC Mat2d& operator=(const MatrixBase<F64, 2, V>& v) { set(v); return *this; }
public:
F64 m00, m10;
F64 m01, m11;
};
//------------------------------------------------------------------------
class Mat3d : public MatrixBase<F64, 3, Mat3d>
{
public:
FW_CUDA_FUNC Mat3d (void) { setIdentity(); }
FW_CUDA_FUNC Mat3d (const Mat3f& a) { for (int i = 0; i < 3 * 3; i++) set(i, (F64)a.get(i)); }
FW_CUDA_FUNC explicit Mat3d (F64 a) { set(a); }
FW_CUDA_FUNC const F64* getPtr (void) const { return &m00; }
FW_CUDA_FUNC F64* getPtr (void) { return &m00; }
static FW_CUDA_FUNC Mat3d fromPtr (const F64* ptr) { Mat3d v; v.set(ptr); return v; }
FW_CUDA_FUNC operator Mat3f (void) const { Mat3f r; for (int i = 0; i < 3 * 3; i++) r.set(i, (F32)get(i)); return r; }
template <class V> FW_CUDA_FUNC Mat3d(const MatrixBase<F64, 3, V>& v) { set(v); }
template <class V> FW_CUDA_FUNC Mat3d& operator=(const MatrixBase<F64, 3, V>& v) { set(v); return *this; }
public:
F64 m00, m10, m20;
F64 m01, m11, m21;
F64 m02, m12, m22;
};
//------------------------------------------------------------------------
class Mat4d : public MatrixBase<F64, 4, Mat4d>
{
public:
FW_CUDA_FUNC Mat4d (void) { setIdentity(); }
FW_CUDA_FUNC Mat4d (const Mat4f& a) { for (int i = 0; i < 4 * 4; i++) set(i, (F64)a.get(i)); }
FW_CUDA_FUNC explicit Mat4d (F64 a) { set(a); }
FW_CUDA_FUNC const F64* getPtr (void) const { return &m00; }
FW_CUDA_FUNC F64* getPtr (void) { return &m00; }
static FW_CUDA_FUNC Mat4d fromPtr (const F64* ptr) { Mat4d v; v.set(ptr); return v; }
FW_CUDA_FUNC operator Mat4f (void) const { Mat4f r; for (int i = 0; i < 4 * 4; i++) r.set(i, (F32)get(i)); return r; }
template <class V> FW_CUDA_FUNC Mat4d(const MatrixBase<F64, 4, V>& v) { set(v); }
template <class V> FW_CUDA_FUNC Mat4d& operator=(const MatrixBase<F64, 4, V>& v) { set(v); return *this; }
public:
F64 m00, m10, m20, m30;
F64 m01, m11, m21, m31;
F64 m02, m12, m22, m32;
F64 m03, m13, m23, m33;
};
//------------------------------------------------------------------------
template <class T, int L, class S> FW_CUDA_FUNC Matrix<T, L> outerProduct(const VectorBase<T, L, S>& a, const VectorBase<T, L, S>& b);
template <class T, int L, class S> FW_CUDA_FUNC T det (const MatrixBase<T, L, S>& v) { return v.det(); }
template <class T, int L, class S> FW_CUDA_FUNC S transpose (const MatrixBase<T, L, S>& v) { return v.transposed(); }
template <class T, int L, class S> FW_CUDA_FUNC S invert (const MatrixBase<T, L, S>& v) { return v.inverted(); }
template <class T, int L, class S> FW_CUDA_FUNC S operator+ (const T& a, const MatrixBase<T, L, S>& b) { return b + a; }
template <class T, int L, class S> FW_CUDA_FUNC S operator- (const T& a, const MatrixBase<T, L, S>& b) { return -b + a; }
template <class T, int L, class S> FW_CUDA_FUNC S operator* (const T& a, const MatrixBase<T, L, S>& b) { return b * a; }
template <class T, int L, class S> FW_CUDA_FUNC S operator/ (const T& a, const MatrixBase<T, L, S>& b) { S r; for (int i = 0; i < L * L; i++) r.get(i) = a / b.get(i); return r; }
template <class T, int L, class S> FW_CUDA_FUNC S operator% (const T& a, const MatrixBase<T, L, S>& b) { S r; for (int i = 0; i < L * L; i++) r.get(i) = a % b.get(i); return r; }
template <class T, int L, class S> FW_CUDA_FUNC S operator& (const T& a, const MatrixBase<T, L, S>& b) { return b & a; }
template <class T, int L, class S> FW_CUDA_FUNC S operator| (const T& a, const MatrixBase<T, L, S>& b) { return b | a; }
template <class T, int L, class S> FW_CUDA_FUNC S operator^ (const T& a, const MatrixBase<T, L, S>& b) { return b ^ a; }
template <class T, int L, class S> FW_CUDA_FUNC S operator<< (const T& a, const MatrixBase<T, L, S>& b) { S r; for (int i = 0; i < L * L; i++) r.get(i) = a << b.get(i); return r; }
template <class T, int L, class S> FW_CUDA_FUNC S operator>> (const T& a, const MatrixBase<T, L, S>& b) { S r; for (int i = 0; i < L * L; i++) r.get(i) = a >> b.get(i); return r; }
//------------------------------------------------------------------------
FW_CUDA_CONST int c_popc8LUT[] =
{
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8,
};
FW_CUDA_FUNC int popc8(U32 mask)
{
FW_ASSERT(mask < (int)FW_ARRAY_SIZE(c_popc8LUT));
return c_popc8LUT[mask];
}
FW_CUDA_FUNC int popc16(U32 mask)
{
FW_ASSERT(mask < 0x00010000u);
return c_popc8LUT[mask & 0xffu] + c_popc8LUT[mask >> 8];
}
FW_CUDA_FUNC int popc32(U32 mask)
{
int result = c_popc8LUT[mask & 0xffu];
result += c_popc8LUT[(mask >> 8) & 0xffu];
result += c_popc8LUT[(mask >> 16) & 0xffu];
result += c_popc8LUT[mask >> 24];
return result;
}
FW_CUDA_FUNC int popc64(U64 mask)
{
U32 lo = (U32)mask;
U32 hi = (U32)(mask >> 32);
int result = c_popc8LUT[lo & 0xffu] + c_popc8LUT[hi & 0xffu];
result += c_popc8LUT[(lo >> 8) & 0xffu] + c_popc8LUT[(hi >> 8) & 0xffu];
result += c_popc8LUT[(lo >> 16) & 0xffu] + c_popc8LUT[(hi >> 16) & 0xffu];
result += c_popc8LUT[lo >> 24] + c_popc8LUT[hi >> 24];
return result;
}
//------------------------------------------------------------------------
template <class T, int L, class S> template <class V> S MatrixBase<T, L, S>::translate(const VectorBase<T, L - 1, V>& v)
{
S r;
for (int i = 0; i < L - 1; i++)
r(i, L - 1) = v[i];
return r;
}
//------------------------------------------------------------------------
template <class T, int L, class S> template <class V> S MatrixBase<T, L, S>::scale(const VectorBase<T, L - 1, V>& v)
{
S r;
for (int i = 0; i < L - 1; i++)
r(i, i) = v[i];
return r;
}
//------------------------------------------------------------------------
template <class T, int L, class S> template <class V> S MatrixBase<T, L, S>::scale(const VectorBase<T, L, V>& v)
{
S r;
for (int i = 0; i < L; i++)
r(i, i) = v[i];
return r;
}
//------------------------------------------------------------------------
template <class T, int L, class S> Vector<T, L> MatrixBase<T, L, S>::getRow(int idx) const
{
Vector<T, L> r;
for (int i = 0; i < L; i++)
r[i] = get(idx, i);
return r;
}
//------------------------------------------------------------------------
#if !FW_CUDA
template <class T, int L, class S> void MatrixBase<T, L, S>::print(void) const
{
for (int i = 0; i < L; i++)
{
for (int j = 0; j < L; j++)
printf("%-16g", (F64)get(i, j));
printf("\n");
}
}
#endif
//------------------------------------------------------------------------
template <class T, int L, class S> FW_CUDA_FUNC T detImpl(const MatrixBase<T, L, S>& v)
{
T r = (T)0;
T s = (T)1;
for (int i = 0; i < L; i++)
{
Matrix<T, L - 1> sub;
for (int j = 0; j < L - 1; j++)
for (int k = 0; k < L - 1; k++)
sub(j, k) = v((j < i) ? j : j + 1, k + 1);
r += sub.det() * v(i, 0) * s;
s = -s;
}
return r;
}
//------------------------------------------------------------------------
template <class T, class S> FW_CUDA_FUNC T detImpl(const MatrixBase<T, 1, S>& v)
{
return v(0, 0);
}
//------------------------------------------------------------------------
template <class T, class S> FW_CUDA_FUNC T detImpl(const MatrixBase<T, 2, S>& v)
{
return v(0, 0) * v(1, 1) - v(0, 1) * v(1, 0);
}
//------------------------------------------------------------------------
template <class T, class S> FW_CUDA_FUNC T detImpl(const MatrixBase<T, 3, S>& v)
{
return v(0, 0) * v(1, 1) * v(2, 2) - v(0, 0) * v(1, 2) * v(2, 1) +
v(1, 0) * v(2, 1) * v(0, 2) - v(1, 0) * v(2, 2) * v(0, 1) +
v(2, 0) * v(0, 1) * v(1, 2) - v(2, 0) * v(0, 2) * v(1, 1);
}
//------------------------------------------------------------------------
template <class T, int L, class S> T MatrixBase<T, L, S>::det(void) const
{
return detImpl(*this);
}
//------------------------------------------------------------------------
template <class T, int L, class S> S MatrixBase<T, L, S>::transposed(void) const
{
S r;
for (int i = 0; i < L; i++)
for (int j = 0; j < L; j++)
r(i, j) = get(j, i);
return r;
}
//------------------------------------------------------------------------
template <class T, int L, class S> S MatrixBase<T, L, S>::inverted(void) const
{
S r;
T d = (T)0;
T si = (T)1;
for (int i = 0; i < L; i++)
{
T sj = si;
for (int j = 0; j < L; j++)
{
Matrix<T, L - 1> sub;
for (int k = 0; k < L - 1; k++)
for (int l = 0; l < L - 1; l++)
sub(k, l) = get((k < j) ? k : k + 1, (l < i) ? l : l + 1);
T dd = sub.det() * sj;
r(i, j) = dd;
d += dd * get(j, i);
sj = -sj;
}
si = -si;
}
return r * rcp(d) * L;
}
//------------------------------------------------------------------------
template <class T, int L, class S> template <class V> void MatrixBase<T, L, S>::setRow(int idx, const VectorBase<T, L, V>& v)
{
for (int i = 0; i < L; i++)
get(idx, i) = v[i];
}
//------------------------------------------------------------------------
template <class T, int L, class S> template<class V> V MatrixBase<T, L, S>::operator*(const VectorBase<T, L, V>& v) const
{
V r;
for (int i = 0; i < L; i++)
{
T rr = (T)0;
for (int j = 0; j < L; j++)
rr += get(i, j) * v[j];
r[i] = rr;
}
return r;
}
//------------------------------------------------------------------------
template <class T, int L, class S> template<class V> V MatrixBase<T, L, S>::operator*(const VectorBase<T, L - 1, V>& v) const
{
T w = get(L - 1, L - 1);
for (int i = 0; i < L - 1; i++)
w += get(L - 1, i) * v[i];
w = rcp(w);
V r;
for (int i = 0; i < L - 1; i++)
{
T rr = get(i, L - 1);
for (int j = 0; j < L - 1; j++)
rr += get(i, j) * v[j];
r[i] = rr * w;
}
return r;
}
//------------------------------------------------------------------------
template <class T, int L, class S> template <class V> S MatrixBase<T, L, S>::operator*(const MatrixBase<T, L, V>& v) const
{
S r;
for (int i = 0; i < L; i++)
{
for (int j = 0; j < L; j++)
{
T rr = (T)0;
for (int k = 0; k < L; k++)
rr += get(i, k) * v(k, j);
r(i, j) = rr;
}
}
return r;
}
//------------------------------------------------------------------------
template <class T, int L, class S> Matrix<T, L> outerProduct(const VectorBase<T, L, S>& a, const VectorBase<T, L, S>& b)
{
Matrix<T, L> res;
for (int i = 0; i < L; i++)
for (int j = 0; j < L; j++)
res.get(i, j) = a.get(i) * b.get(j);
return res;
}
//------------------------------------------------------------------------
}
| [
"[email protected]"
]
| [
[
[
1,
1052
]
]
]
|
1a72d53c97bf6b463e318a5ebf10219a9373c818 | 886d53dfd22fff2dda2e021d0dc8035723ed60ef | /private/tasks/1049/gomilton.cpp | 2d3980aade92906e665e9176fa32fa5eba906d96 | []
| no_license | stden/dm-judge | 0d3a373349bc7c7b7e1a43cb8c451fbba10fea9b | 2dbf7429694441c8447aad09a3d528283d034dfc | refs/heads/master | 2021-01-10T03:28:24.820940 | 2011-01-29T23:02:25 | 2011-01-29T23:02:25 | 45,978,812 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,327 | cpp | #include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include<stdlib.h>
FILE *fin,*fout;
static int count;
static int bestcx,bestcy;
static int record=-1;
static int*arraycol;
static int*arrayrow;
static int firstusel;
struct rebro
{
int exist;
int lenght;
};
int privedenie(rebro*);
int find(rebro*,int& ,int&);
void recur(rebro*,int,int);
int find(rebro*p,int&x,int&y)
{
int summapriv=-1;
for(int i=0;i<count; i++)
for(int j=0; j<count;j++)
{
int bestinrow=100;
int bestincol=100;
if (p[i*count+j].lenght==0&&arrayrow[i]!=1&&arraycol[j]!=1)
{
for(int k=0;k<count; k++)
{
if (p[i*count+k].lenght!=-1&&k!=j&&!arraycol[k])
{
if (p[i*count+k].lenght<bestinrow) bestinrow=p[i*count+k].lenght;
}
if (p[k*count+j].lenght!=-1&&k!=i&&!arrayrow[k])
{
if (p[k*count+j].lenght<bestincol) bestincol=p[k*count+j].lenght;
}
}
if(summapriv<bestinrow+bestincol)
{
y=i;
x=j;
summapriv=bestinrow+bestincol;
}
}
}
if (summapriv==-1)
return 0;
return 1;
}
void recur(rebro*Q,int chislo,int cursumma)
{
rebro *first=new rebro[count*count];
rebro *second=new rebro[count*count];
for(int i=0; i<count*count; i++)
{
first[i]=second[i]=Q[i];
}
int summa1=privedenie(first);
if ((record==-1||cursumma<record)&&chislo==0)
{
record=cursumma;
}
else
{
int bestx,besty;
int luck=find(first,bestx,besty);
if (luck==1)
{
arraycol[bestx]=1;
arrayrow[besty]=1;
if (chislo!=2)
{
first[besty*count+bestx].exist=1;
for(int k=0; k<count; k++)
for(int i=0; i<count;i++)
for (int j=0; j<count; j++)
{
if (first[i*count+j].exist==0)
{
first[i*count+j].exist=first[i*count+k].exist*first[k*count+j].exist;
}
if (first[i*count+j].exist==1)
{
first[j*count+i].lenght=-1;
first[j*count+i].exist=0;
}
}
}
int summa2=privedenie(first);
if (record==-1||cursumma+summa1+summa2<record)
recur(first,chislo-1,cursumma+summa1+summa2);
arraycol[bestx]=0;
arrayrow[besty]=0;
}
delete [] first;
if (luck==1)
{
second[besty*count+bestx].lenght=-1;
second[besty*count+bestx].exist=0;
summa1=privedenie(second);
if (cursumma+summa1<record||record==-1)
recur(second,chislo,cursumma+summa1);
}
delete [] second;
}
}
int privedenie(rebro* p)
{
int best[40];
for(int i=0; i<count; i++)
{
best[i]=100;
}
int summa=0;
for(i=0;i<count; i++)
{
for(int j=0; j<count; j++)
{
if (p[i*count+j].lenght!=-1&&arrayrow[i]!=1&&arraycol[j]!=1)
if (p[i*count+j].lenght<best[i]) best[i]=p[i*count+j].lenght;
}
}
for (i=0; i<count; i++)
{
for (int j=0; j<count; j++)
{
if (p[i*count+j].lenght!=-1&&arrayrow[i]!=1&&arraycol[j]!=1)
p[i*count+j].lenght+=-best[i];
}
if (best[i]!=100)
{
summa+=best[i];
best[i]=100;
}
}
for(int j=0;j<count; j++)
for(int i=0; i<count; i++)
{
if (p[i*count+j].lenght!=-1&&arrayrow[i]!=1&&arraycol[j]!=1)
if (p[i*count+j].lenght<best[j])
best[j]=p[i*count+j].lenght;
}
for (j=0; j<count; j++)
{
for (int i=0; i<count; i++)
{
if (p[i*count+j].lenght!=-1&&arrayrow[i]!=1&&arraycol[j]!=1)
p[i*count+j].lenght+=-best[j];
}
if (best[j]!=100)
summa+=best[j];
}
return summa;
}
void main()
{
clrscr();
fin=fopen("file\\input.txt","r");
fout=fopen("file\\output.txt","w");
int repeat;
fscanf(fin,"%d",&repeat);
for (int s=0; s<repeat; s++)
{
fscanf(fin,"%d",&count);
arraycol=new int[count];
arrayrow=new int[count];
for(int i=0; i<count; i++)
{
arraycol[i]=0;
arrayrow[i]=0;
}
rebro * p=new rebro[count*count];
for(i=0; i<count; i++)
for(int j=0; j<count; j++)
{
fscanf(fin,"%d",&p[i*count+j].lenght);
if (i==j)
p[i*count+j].exist=1;
else
p[i*count+j].exist=0;
}
recur(p,count,0);
delete [] arraycol;
delete [] arrayrow;
delete [] p;
fprintf(fout,"%d\n",record);
record=-1;
}
fclose(fin);
fclose(fout);
} | [
"[email protected]"
]
| [
[
[
1,
195
]
]
]
|
4eb9ae4f1b211db8ca3372368c4af7d33ab91102 | c9390a163ae5f0bc6fdc1560be59939dcbe3eb07 | /TAFadeInOut.h | 3c03d122e71bcfbde01125db667d23c5e4018382 | []
| no_license | trimpage/multifxvst | 2ceae9da1768428288158319fcf03d603ba47672 | 1cb40f8e0cc873f389f2818b2f40665d2ba2b18b | refs/heads/master | 2020-04-06T13:23:41.059632 | 2010-11-04T14:32:54 | 2010-11-04T14:32:54 | null | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 1,049 | h | #pragma once
class CTAFadeInOut
{
public:
CTAFadeInOut(void);
virtual ~CTAFadeInOut(void);
//#### Configuration ####
void SetFadeIn(float start = 1.0,float stop = 0.0);
void SetSampleRate(double samplerate);//futur use
void SetFadeLenght(double lenght_ms) ;//futur use
void SetFadeOut(float start = 0.0,float stop = 1.0);
bool Fade(){return fade;}
//#### Process function ####
//return true si le fondu est atteint completement
bool FonduBuffer(float ** dest,float ** source,float ** afondre,long size);
//copy source dans dest
static void CopyBuffer(float ** dest, float ** source,long size);
//additionne dest et source met le resultat dans dest
static void AddBuffer(float ** dest, float ** source,long size);
//#### Internal members ####
protected:
bool fade; //fade actif
bool fadein; //fade in or fade out
//value between 0.0f and 1.0f
float current; //current fade value
float start; //start fade value
float stop;
float inc; //incrément
//float stop;
};
| [
"CTAF@3e78e570-a0aa-6544-9a6b-7e87a0c009bc"
]
| [
[
[
1,
36
]
]
]
|
df5bd12903acdf77ca4c1060efddc79cdd900c73 | 86c8c65dd5d7c07b46f134f6df76d5127e9428ff | /015.cpp | 748578f53d668e559c7554403b9e271ebee8c212 | []
| no_license | kyokey/MIPT | 2d2fc233475e414b33fe889594929be6af696b92 | f0dcc64731deaf5d0f0949884865216c15c15dbe | refs/heads/master | 2020-04-27T09:10:48.472859 | 2011-01-04T16:35:26 | 2011-01-04T16:35:26 | 1,219,926 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,360 | cpp | #include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define sqr(a) ((a)*(a))
#define rep(i,a,b) for(i=(a);i<(b);i++)
#define REP(i,n) rep(i,0,n)
#define clr(a) memset((a),0,sizeof (a));
#define mabs(a) ((a)>0?(a):(-(a)))
#define inf 1000000000
#define MAXM 1000
#define MAXN 110
#define eps 1e-6
#define MOD 50261
int N,M;
typedef struct node
{
int a,b;
}node;
node c[MAXN];
bool cmp(const node&x,const node &y )
{
return x.a<y.a||x.a==y.a&&x.b<y.b;
}
int main()
{
int i,j,k;
scanf("%d",&N);
REP(k,N) scanf("%d%d",&c[k].a,&c[k].b);
sort(c,c+N,cmp);
int ret=0;
REP(i,101) REP(j,i)
{
int pre=0;
REP(k,N) if(c[k].b>j&&c[k].b<i&&c[k].a>pre)
{
ret=max(ret,(i-j)*(c[k].a-pre));
pre=c[k].a;
}
ret=max(ret,(i-j)*(100-pre));
}
printf("%d\n",ret);
return 0;
}
| [
"pq@pq-laptop.(none)"
]
| [
[
[
1,
66
]
]
]
|
75c8978438187015f9a96295adcec53140398b33 | c0bd82eb640d8594f2d2b76262566288676b8395 | /src/game/AuctionMgr.h | 8056ae29b7b0117e84fbbfdf90d4e8652f35bc70 | [
"FSFUL"
]
| permissive | vata/solution | 4c6551b9253d8f23ad5e72f4a96fc80e55e583c9 | 774fca057d12a906128f9231831ae2e10a947da6 | refs/heads/master | 2021-01-10T02:08:50.032837 | 2007-11-13T22:01:17 | 2007-11-13T22:01:17 | 45,352,930 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 472 | h | #ifndef __AUCTIONMGR_H
#define __AUCTIONMGR_H
class AuctionMgr : public Singleton < AuctionMgr >
{
public:
AuctionMgr();
~AuctionMgr();
void AddAuctionHouse(AuctionHouse* ah);
AuctionHouse* GetAuctionHouseByEntry(uint32 entry);
AuctionHouse* GetAuctionHouse(uint32 ahid);
void LoadFromDB();
void Update();
private:
std::map<uint32,AuctionHouse*>AuctionMap;
};
#define sAuctionMgr AuctionMgr::getSingleton()
#endif
| [
"[email protected]"
]
| [
[
[
1,
21
]
]
]
|
b7f167c408f370db60c4a3b3ae6e87b52b227691 | 7f72fc855742261daf566d90e5280e10ca8033cf | /branches/full-calibration/ground/src/libs/qymodem/src/qymodemsend.h | 7f902d6af1d2532a74ed295dfe86b18fb75b702d | []
| no_license | caichunyang2007/my_OpenPilot_mods | 8e91f061dc209a38c9049bf6a1c80dfccb26cce4 | 0ca472f4da7da7d5f53aa688f632b1f5c6102671 | refs/heads/master | 2023-06-06T03:17:37.587838 | 2011-02-28T10:25:56 | 2011-02-28T10:25:56 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,800 | h | /**
******************************************************************************
*
* @file qymodemsend.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup ymodem_lib
* @{
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef QYMODEMSEND_H
#define QYMODEMSEND_H
#include "qymodem_tx.h"
#include <QString>
#include <QFile>
#include "qymodemfilestream.cpp"
#ifdef Q_OS_WIN
#define _DEVICE_SET_ QIODevice::ReadWrite|QIODevice::Unbuffered
#else
#define _DEVICE_SET_ QIODevice::ReadWrite
#endif
/**
Class for sending a file via Y-Modem transmit protocol.
*/
class QymodemSend:public QymodemTx
{
public:
QymodemSend(QextSerialPort& port);
int SendFile(QString filename);
int SendFileT(QString filename);
private:
void run();
const char* FileName;
void Send();
QymodemFileStream InFile;
QString FileNameT;
};
#endif // QYmodemSend_H
| [
"jonathan@ebee16cc-31ac-478f-84a7-5cbb03baadba"
]
| [
[
[
1,
61
]
]
]
|
84b3919ff99cdf1ed1352f48f80517c87b3fe086 | b67d58bd5bfe13b32bebe83dec22904243a52223 | /FlashDBSimDll_Sample/LRU.cpp | 0388d2bbd0a9c33a8fa30e7a8c6e89ac89036dc1 | []
| no_license | maheshdharhari/flash-sim | b8929efc83a65ee6d5e782b835106ca36228c6c8 | d04eb0e34bb44e7356f5c1b0e1f1af6097339225 | refs/heads/master | 2021-01-10T07:48:37.820361 | 2010-05-22T09:19:20 | 2010-05-22T09:19:20 | 43,440,579 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 10,457 | cpp | #include "stdafx.h"
#include "LRU.h"
LRU::LRU()
{
for (int i = 0; i < DEFBUFSIZE; i++)
{
ftop[i] = -1;
ptob[i] = NULL;
memset(buf[i].field,'\0',FRAMESIZE);
}
lru = NULL;
mru = lru;
hit = 0;
total = 0;
flashreadcount = 0;
flashwritecount = 0;
}
LRU::~LRU()
{
//释放lru链表
LRUElement * p = mru;
while (p != NULL)
{
mru = mru->LessRecent;
delete p;
p = mru;
}
lru = mru = NULL;
//释放控制块节点
LRUBCB * pb= NULL;
LRUBCB * head = NULL;;
for (int i = 0; i<DEFBUFSIZE; i++)
{
head = ptob[i];
pb = head;
while (pb != NULL)
{
head = head->next;
delete pb;
pb = head;
}
}
pb = head = NULL;
maplist.clear();
}
void LRU::Init()
{
//释放lru链表
LRUElement * p = mru;
while (p != NULL)
{
mru = mru->LessRecent;
delete p;
p = mru;
}
lru = mru = NULL;
//释放控制块节点
LRUBCB * pb= NULL;
LRUBCB * head = NULL;;
for (int i = 0; i<DEFBUFSIZE; i++)
{
head = ptob[i];
pb = head;
while (pb != NULL)
{
head = head->next;
delete pb;
pb = head;
}
}
pb = head = NULL;
/*初始化缓冲区*/
for (int i = 0; i < DEFBUFSIZE; i++)
{
ftop[i] = -1;
ptob[i] = NULL;
memset(buf[i].field,'\0',FRAMESIZE);
}
hit = 0;
total = 0;
flashreadcount = 0;
flashwritecount = 0;
}
int LRU::FixPage(int page_id)
{
ASSERT(page_id >= 0);
int frid = -1;
int rv = -1;
int hk = hash(page_id);
LRUBCB* pb = NULL;
pb = PageToLRUBCB(page_id);
/*读计数加1*/
total++;
/*若该页在缓冲区中已存在*/
if (pb != NULL)
{
frid = pb->frame_id;
AdjustLRUList(frid);
/*命中次数加1*/
hit++;
return frid;
}
else // 若该页不在缓冲区中
{
frid = SelectVictim();
/*正常情形下,此时应该从二级存储器读入需要加载的数据*/
rv = f_read_page(page_id,(BYTE *)(buf[frid].field),0,FRAMESIZE);
if(rv == RV_ERROR_INVALID_PAGE_STATE)
{
printf("page readed is invalid\n");
}
if (rv == RV_ERROR_FLASH_BLOCK_BROKEN)
{
printf("the block contained this page is broken \n");
}
flashreadcount++;
ftop[frid] = page_id;
pb = ptob[hk];
/*将新的LRUBCB链接到桶的尾部*/
if ( pb != NULL)
{
while( pb->next != NULL)
{
pb = pb->next;
}
pb->next = new LRUBCB();
pb = pb->next;
}
else //桶为空
{
pb = new LRUBCB();
ptob[hk] = pb;
}
pb->dirty = 0;
pb->frame_id = frid;
pb->page_id = page_id;
pb->next = NULL;
InsertLRUEle(frid);
return frid;
}
}
NewPage LRU::FixNewPage(LBA lba)
{
NewPage np;
np.frame_id = -1;
np.page_id = -1;
int pid = -1;
int frid = -1;
LRUBCB* pb = NULL;
/* 申请分配新数据页 */
f_alloc_page(1, &pid);
if (pid == -1)
printf("there is no free page in the flash memory");
ASSERT(pid >= 0);
/*注册映射项*/
RegistEntry(lba,pid);
/* 在缓冲区中寻找空闲块,用于存储新数据页中的数据*/
frid = SelectVictim();
ftop[frid] = pid;
pb = ptob[hash(pid)];
/*将新的LRUBCB链接到桶的尾部*/
if ( pb != NULL)
{
while( pb->next != NULL)
{
pb = pb->next;
}
pb->next = new LRUBCB();
pb = pb->next;
}
else //桶为空
{
pb = new LRUBCB();
ptob[hash(pid)] = pb;
}
pb->dirty = 0;
pb->frame_id = frid;
pb->page_id = pid;
pb->next = NULL;
InsertLRUEle(frid);
np.frame_id = frid;
np.page_id = pid;
return np;
}
int LRU::UnFixPage(int page_id)
{
ASSERT(page_id >= 0);
LRUBCB *pb = NULL;
pb = PageToLRUBCB(page_id);
int rv = -1;
if(pb->dirty == 1)
{
pb->dirty = 0;
}
rv = f_release_page(page_id);
if (rv == RV_ERROR_INVALID_LBA)
{
printf("Invalid LBA\n");
return rv;
}
return 0;
}
void LRU::ReadFrame(int frame_id,char* buffer)
{
ASSERT(frame_id >= 0 );
ASSERT(buffer != NULL);
memcpy(buffer,buf[frame_id].field,FRAMESIZE);
return;
}
void LRU::WriteFrame(int frame_id,const char* buffer)
{
ASSERT(frame_id >= 0);
ASSERT(buffer != NULL);
memcpy(buf[frame_id].field,buffer,FRAMESIZE);
SetDirty(frame_id);
return;
}
int LRU::WriteDirty()
{
LRUBCB* pb = NULL;
int rv = -1;
for (int i = 0; i < DEFBUFSIZE; i++)
{
pb = ptob[i];
while ( pb != NULL)
{
if (pb->dirty == 1)
{
//程序结束时,我们应该将脏页写回二级存储器
rv = f_write_page(pb->page_id,(BYTE *)(buf[pb->frame_id].field),0,FRAMESIZE);
if (rv == RV_ERROR_FLASH_NO_MEMORY)
{
printf("no more flash memory \n");
return rv;
}
flashwritecount++;
}
pb = pb->next;
}
}
return 0;
}
double LRU::HitRatio()
{
return ((double)(hit)/(double)(total));
}
void LRU::RWInfo()
{
printf("hit is: %d\n",hit);
printf("total is: %d\n",total);
printf("flash read count is: %d\n",flashreadcount);
printf("flash write count is: %d\n",flashwritecount);
return;
}
int LRU::IsLBAValid(LBA lba)
{
ASSERT(lba >= 0);
if(maplist.count(lba))
{
return LBA_IS_VALID;
}
else
{
return LBA_IS_INVALID;
}
}
int LRU::LBAToPID(LBA lba)
{
ASSERT(lba >= 0);
return maplist[lba];
}
void LRU::SetDirty(int frame_id)
{
ASSERT(frame_id >= 0);
int pid = -1;
LRUBCB* pb = NULL;
pid = ftop[frame_id];
pb = PageToLRUBCB(pid);
if (pb->dirty == 0)
{
pb->dirty = 1;
}
return;
}
int LRU::hash(int page_id)
{
ASSERT(page_id >= 0 );
int hk = -1;
hk = page_id % DEFBUFSIZE;
return hk;
}
LRUBCB* LRU::PageToLRUBCB(int page_id)
{
ASSERT(page_id >= 0);
LRUBCB* pb = NULL;
int hk = -1;
hk = hash(page_id);
pb = ptob[hk];
while ( pb != NULL && pb->page_id != page_id)
{
pb = pb->next;
}
return pb;
}
void LRU::RemoveLRUBCB(LRUBCB* pb)
{
ASSERT(pb != NULL);
LRUBCB* head = NULL;
head = ptob[hash(pb->page_id)];
/* 若该LRUBCB正好在桶的首部 */
if (pb == head)
{
/* 如果桶的长度大于1,则需要维护桶的其它部分*/
if ( head->next != NULL)
{
head = head->next;
ptob[hash(pb->page_id)] = head;
ftop[pb->frame_id] = -1;
memset(&(buf[pb->frame_id].field),'\0',FRAMESIZE);
delete pb;
pb = NULL;
head = NULL;
}
else //若桶中只有一个元素
{
ptob[hash(pb->page_id)] = NULL;
ftop[pb->frame_id] = -1;
memset(&(buf[pb->frame_id].field),'\0',FRAMESIZE);
delete pb;
pb = NULL;
}
}
else //在桶内需找LRUBCB的正确位置
{
while ( head->next != pb)
{
head = head->next;
}
head->next = pb->next;
ftop[pb->frame_id] = -1;
memset(&(buf[pb->frame_id].field),'\0',FRAMESIZE);
delete pb;
pb = NULL;
head = NULL;
}
return;
}
/* 在LRU置换策略中,每次只需删除lru指向的元素,这里做一般化处理*/
void LRU::RemoveLRUEle(int frame_id)
{
ASSERT(frame_id >= 0);
LRUElement* elem = NULL;
elem = lru;
if (elem == NULL)
{
return;
}
while( (elem != NULL)&&(elem->frame_id != frame_id))
{
elem = elem->MoreRecent;
}
if (elem == NULL)
{
return; //找不到相应的元素
}
else
{
if ( elem == lru) //lru指向要删除的元素
{
if ( elem == mru) //mru也指向要删除的元素
{
lru = mru = NULL;
delete elem;
}
else
{
lru = lru->MoreRecent;
lru->LessRecent = NULL;
delete elem;
}
}
else //在lru策略中能删除除链尾以外的元素,只出现在多线程访问同一元素时(数据锁)
{
if ( elem == mru ) //mru指向要删除的元素
{
mru = mru->LessRecent;
mru->MoreRecent = NULL;
delete elem;
}
else //删除除链头和链尾的元素
{
elem->MoreRecent->LessRecent = elem->LessRecent;
elem->LessRecent->MoreRecent = elem->MoreRecent;
delete elem;
}
}//end elem == lru
return;
}//end elem == NULL
}
void LRU::InsertLRUEle(int frame_id)
{
ASSERT(frame_id >= 0);
LRUElement* elem = NULL;
elem = new LRUElement();
elem->frame_id = frame_id;
elem->LessRecent = NULL;
elem->MoreRecent = NULL;
/* 若链表为空 */
if ( mru == NULL)
{
mru = elem;
lru = mru;
}
else
{
elem->LessRecent = mru;
mru->MoreRecent = elem;
mru = elem;
}
return;
}
void LRU::AdjustLRUList(int frame_id)
{
ASSERT(frame_id >= 0);
LRUElement* elem = NULL;
elem = mru;
/* 若链表为空*/
if (elem == NULL)
{
return;
}
while ( (elem != NULL)&&(elem->frame_id != frame_id))
{
elem = elem->LessRecent;
}
/*若没找到*/
if (elem == NULL)
{
return;
}
else
{
if (elem == mru) //访问的元素在链首,直接返回
{
return;
}
else //访问的元素在链尾,将其移到链首
{
if( elem == lru ) //若访问的元素为链尾元素
{
lru = lru->MoreRecent;
lru->LessRecent = NULL;
}
else//访问除链首和链尾之外的元素
{
elem->LessRecent->MoreRecent = elem->MoreRecent;
elem->MoreRecent->LessRecent = elem->LessRecent;
}
elem->LessRecent = mru;
mru->MoreRecent = elem;
elem->MoreRecent = NULL;
mru = elem;
return;
} //end elem == mru
} //end elem == NULL
}
int LRU::SelectVictim()
{
LRUBCB* pb = NULL;
LRUElement* elem = NULL;
int frid = -1;
int rv = -1;
/* 若干净页链表和脏页链表都为空,则选择缓冲区中的第一块 */
if ( lru == NULL)
{
return 0;
}
/* 从缓冲区中找空闲块 */
for ( int i = 0; i< DEFBUFSIZE; i++)
{
if ( ftop[i] == -1 )
{
return i;
}
}
/* 若缓冲区已无空闲页,则从中选择置换页(执行置换策略)*/
elem = lru;
lru = lru->MoreRecent;
lru->LessRecent = NULL;
frid = elem->frame_id;
pb = PageToLRUBCB(ftop[frid]);
if ( pb->dirty == 1)
{
//正常情况下,应该将数据写回二级存储器,这里只计数
rv = f_write_page(pb->page_id,(BYTE *)(buf[pb->frame_id].field),0,FRAMESIZE);
if (rv == RV_ERROR_FLASH_NO_MEMORY)
printf("no more flash memory \n");
flashwritecount++;
}
/* 将置换帧的元信息和链表信息删除 */
RemoveLRUEle(frid);
RemoveLRUBCB(pb);
return frid;
}
void LRU::RegistEntry(LBA lba, PID page_id)
{
ASSERT(lba >= 0);
ASSERT(page_id >= 0);
maplist.insert(valType(lba,page_id));
} | [
"hiyoungcat@9895585c-9ddb-11de-bf4a-bd5be0e2b6d7"
]
| [
[
[
1,
576
]
]
]
|
bd6b24066cf80a9cb58c6c2eba8b6bc4e2404849 | c0bd82eb640d8594f2d2b76262566288676b8395 | /src/game/SocialMgr.cpp | a69383acdc99e1127d77d9bdc189802e68b86207 | [
"FSFUL"
]
| permissive | vata/solution | 4c6551b9253d8f23ad5e72f4a96fc80e55e583c9 | 774fca057d12a906128f9231831ae2e10a947da6 | refs/heads/master | 2021-01-10T02:08:50.032837 | 2007-11-13T22:01:17 | 2007-11-13T22:01:17 | 45,352,930 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 20,200 | cpp | // Copyright (C) 2004 WoW Daemon
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "StdAfx.h"
initialiseSingleton( SocialMgr );
SocialMgr::SocialMgr()
{
m_isInFriendList.clear();
m_hasInFriendList.clear();
m_isInIgnoreList.clear();
m_hasInIgnoreList.clear();
m_needsBlockNotice.clear();
}
SocialMgr::~SocialMgr()
{
std::map<uint64, std::list<uint64>*>::iterator iter;
for(iter = m_isInFriendList.begin(); iter != m_isInFriendList.end(); ++iter) {
delete iter->second;
}
m_isInFriendList.clear();
for(iter = m_hasInFriendList.begin(); iter != m_hasInFriendList.end(); ++iter) {
delete iter->second;
}
m_hasInFriendList.clear();
for(iter = m_isInIgnoreList.begin(); iter != m_isInIgnoreList.end(); ++iter) {
delete iter->second;
}
m_isInIgnoreList.clear();
for(iter = m_hasInIgnoreList.begin(); iter != m_hasInIgnoreList.end(); ++iter) {
delete iter->second;
}
m_hasInIgnoreList.clear();
for(iter = m_needsBlockNotice.begin(); iter != m_needsBlockNotice.end(); ++iter) {
delete iter->second;
}
m_needsBlockNotice.clear();
}
void SocialMgr::SendFriendList(Player* plr)
{
if(!plr)
return;
WorldPacket data( SMSG_FRIEND_LIST , 500 );
uint64 plrguid = plr->GetGUID();
std::map<uint64, std::list<uint64>*>::iterator fItr;
fItr = m_hasInFriendList.find(plrguid);
if( fItr == m_hasInFriendList.end() )
{
data << (uint8)0;
if(plr->GetSession())
plr->GetSession()->SendPacket( &data );
return;
}
std::list<uint64>* fList = fItr->second;
std::list<uint64>::iterator itr;
Player* pFriend = NULL;
bool isGm = (plr->GetSession()->GetPermissionCount() > 0);
data << (uint8)fList->size();
for(itr = fList->begin(); itr != fList->end(); itr++)
{
data << uint64(*itr);
pFriend = sObjHolder.GetObject<Player>( *itr );
if(pFriend && (!pFriend->m_isGmInvisible || isGm))
data << uint8(1) << (uint32)pFriend->GetZoneId() << (uint8)pFriend->getLevel() << (uint8)pFriend->getClass();
else
data << uint8(0);
}
plr->GetSession()->SendPacket( &data );
}
void SocialMgr::SendIgnoreList(Player* plr)
{
if(!plr)
return;
WorldPacket data;
data.Initialize( SMSG_IGNORE_LIST );
uint64 plrguid = plr->GetGUID();
std::map<uint64, std::list<uint64>*>::iterator iItr;
iItr = m_hasInIgnoreList.find(plrguid);
if( iItr == m_hasInIgnoreList.end() )
{
data << (uint8)0;
plr->GetSession()->SendPacket( &data );
return;
}
std::list<uint64>* iList = iItr->second;
std::list<uint64>::iterator itr;
data << (uint8)iList->size();
for(itr = iList->begin(); itr != iList->end(); itr++)
{
data << uint64(*itr);
}
plr->GetSession()->SendPacket( &data );
}
void SocialMgr::SendUpdateToFriends(Player* plr)
{
if(!plr)
return;
std::map<uint64, std::list<uint64>*>::iterator Itr;
Itr = m_isInFriendList.find(plr->GetGUID());
if(Itr == m_isInFriendList.end())
return;
std::list<uint64>* iList = Itr->second;
std::list<uint64>::iterator itr;
Player* cPlayer = NULL;
for(itr = iList->begin(); itr != iList->end(); itr++)
{
cPlayer = sObjHolder.GetObject<Player>(*itr);
if(cPlayer)
SendFriendList(cPlayer);
}
}
void SocialMgr::AddFriend(Player* plr, std::string friendName)
{
if(!plr)
return;
WorldPacket data;
data.Initialize( SMSG_FRIEND_STATUS );
PlayerInfo* playerInfo = objmgr.GetPlayerInfo(plr->GetGUID());
PlayerInfo* friendInfo = objmgr.GetPlayerInfoByName(friendName.c_str());
if(playerInfo == NULL)
{ // We shouldn't get here
data << (uint8)FRIEND_DB_ERROR;
plr->GetSession()->SendPacket( &data );
return;
}
if( friendInfo == NULL)
{
sLog.outDetail("WORLD: Guid of %s not found ", friendName.c_str() );
data << (uint8)FRIEND_NOT_FOUND;
plr->GetSession()->SendPacket( &data );
return;
}
if( friendInfo->team != playerInfo->team )
{
sLog.outDebug("SocialMgr: %s tried to add an ennemy to his friendlist", plr->GetName());
data << (uint8)FRIEND_ENEMY << (uint64)friendInfo->guid;
plr->GetSession()->SendPacket( &data );
return;
}
uint64 pGuid = playerInfo->guid;
uint64 fGuid = friendInfo->guid;
Player *pFriend = sObjHolder.GetObject<Player>(fGuid);
if ( pGuid == fGuid )
{
sLog.outDebug("SocialMgr: %s tried to add himself to his friendlist", plr->GetName());
data << (uint8)FRIEND_SELF << (uint64)fGuid;
plr->GetSession()->SendPacket(&data);
return;
}
if( HasFriend(pGuid, fGuid) )
{
sLog.outDebug("SocialMgr: %s tried to add someone who is already in his friendlist", plr->GetName());
data << (uint8)FRIEND_ALREADY << (uint64)fGuid;
plr->GetSession()->SendPacket(&data);
return;
}
sLog.outDebug("SocialMgr: %s added %s to his friendlist", playerInfo->name.c_str(), friendInfo->name.c_str());
if ( pFriend )
{
data << (uint8)FRIEND_ADDED_ONLINE << (uint64)fGuid << (uint8)1;
data << pFriend->GetZoneId() << (uint32)pFriend->getLevel() << (uint32)pFriend->getClass();
}
else
data << (uint8)FRIEND_ADDED_OFFLINE << (uint64)friendInfo->guid;
std::map<uint64, std::list<uint64>*>::iterator fItr;
fItr = m_isInFriendList.find(fGuid);
if( fItr == m_isInFriendList.end() )
m_isInFriendList[fGuid] = new std::list<uint64>;
fItr = m_hasInFriendList.find(pGuid);
if( fItr == m_hasInFriendList.end() )
m_hasInFriendList[pGuid] = new std::list<uint64>;
m_hasInFriendList[pGuid]->push_back(fGuid);
m_isInFriendList[fGuid]->push_back(pGuid);
std::stringstream ss;
ss << "INSERT INTO social(guid,socialguid,flags) VALUES ('"<< pGuid <<"','"<< fGuid <<"','FRIEND')";
sDatabase.Execute( ss.str().c_str() );
plr->GetSession()->SendPacket( &data );
}
void SocialMgr::AddIgnore(Player* plr, std::string ignoreName)
{
if(!plr)
return;
WorldPacket data;
data.Initialize( SMSG_FRIEND_STATUS );
PlayerInfo* playerInfo = objmgr.GetPlayerInfo(plr->GetGUID());
PlayerInfo* ignoreInfo = objmgr.GetPlayerInfoByName(ignoreName.c_str());
if (!ignoreInfo)
{
sLog.outDetail( "WORLD: Guid of %s not found ", ignoreName.c_str() );
data << (uint8)FRIEND_IGNORE_NOT_FOUND;
plr->GetSession()->SendPacket( &data );
return;
}
if(playerInfo == NULL)
{
data << (uint8)FRIEND_DB_ERROR;
plr->GetSession()->SendPacket( &data );
return;
}
uint64 pGuid = playerInfo->guid;
uint64 iGuid = ignoreInfo->guid;
if( pGuid == iGuid )
{
sLog.outDebug("SocialMgr: %s tried to add himself to his friendlist", plr->GetName());
data << (uint8)FRIEND_IGNORE_SELF << (uint64)iGuid;
plr->GetSession()->SendPacket(&data);
return;
}
if( HasIgnore(playerInfo->guid, ignoreInfo->guid) )
{
sLog.outDebug("SocialMgr: %s tried to add someone who is already in his ignorelist", plr->GetName());
data << (uint8)FRIEND_IGNORE_ALREADY << (uint64)iGuid;
plr->GetSession()->SendPacket(&data);
return;
}
sLog.outDebug("SocialMgr: %s added %s to his ignorelist", plr->GetName(), ignoreInfo->name.c_str());
data << (uint8)FRIEND_IGNORE_ADDED << (uint64)iGuid;
std::map<uint64, std::list<uint64>*>::iterator iItr;
iItr = m_isInIgnoreList.find(iGuid);
if( iItr == m_isInIgnoreList.end() )
m_isInIgnoreList[iGuid] = new std::list<uint64>;
iItr = m_hasInIgnoreList.find(pGuid);
if( iItr == m_hasInIgnoreList.end() )
m_hasInIgnoreList[pGuid] = new std::list<uint64>;
iItr = m_needsBlockNotice.find(iGuid);
if( iItr == m_needsBlockNotice.end() )
m_needsBlockNotice[iGuid] = new std::list<uint64>;
m_isInIgnoreList[iGuid]->push_back(pGuid);
m_hasInIgnoreList[pGuid]->push_back(iGuid);
m_needsBlockNotice[iGuid]->push_back(pGuid);
std::stringstream ss;
ss << "INSERT INTO social(guid,socialguid,flags,noticed) VALUES ('"<< pGuid <<"','"<< iGuid <<"','IGNORE','0')";
sDatabase.Execute( ss.str().c_str() );
plr->GetSession()->SendPacket( &data );
}
void SocialMgr::DelFriend(Player* plr, uint64 friendguid)
{
if(!plr)
return;
WorldPacket data;
uint64 plrguid = plr->GetGUID();
sLog.outDebug("SocialMgr: %s is deleting friendguid %d from his friendlist", plr->GetName(), friendguid);
std::stringstream ss;
ss << "DELETE FROM social WHERE guid="<< plrguid <<" AND socialguid="<< friendguid <<" AND flags='FRIEND'";
sDatabase.Execute( ss.str().c_str() );
std::map<uint64, std::list<uint64>*>::iterator fItr;
fItr = m_hasInFriendList.find(plrguid);
if( fItr != m_hasInFriendList.end() )
fItr->second->remove(friendguid);
fItr = m_isInFriendList.find(friendguid);
if( fItr != m_isInFriendList.end() )
fItr->second->remove(plrguid);
data.Initialize( SMSG_FRIEND_STATUS );
data << (uint8)FRIEND_REMOVED << (uint64)friendguid;
plr->GetSession()->SendPacket( &data );
}
void SocialMgr::DelIgnore(Player* plr, uint64 ignoreguid)
{
if(!plr)
return;
WorldPacket data;
uint64 plrguid = plr->GetGUID();
sLog.outDebug("SocialMgr: %s is deleting guid %d from his ignorelist", plr->GetName(), ignoreguid);
std::stringstream ss;
ss << "DELETE FROM social WHERE guid="<< plrguid <<" AND socialguid="<< ignoreguid <<" AND flags='IGNORE'";
sDatabase.Execute( ss.str().c_str() );
std::map<uint64, std::list<uint64>*>::iterator iItr;
iItr = m_hasInIgnoreList.find(plrguid);
if( iItr != m_hasInIgnoreList.end() )
iItr->second->remove(ignoreguid);
iItr = m_isInIgnoreList.find(ignoreguid);
if( iItr != m_isInIgnoreList.end() )
iItr->second->remove(plrguid);
data.Initialize( SMSG_FRIEND_STATUS );
data << (uint8)FRIEND_IGNORE_REMOVED << (uint64)ignoreguid;
plr->GetSession()->SendPacket( &data );
}
bool SocialMgr::IsFriend(uint64 plrguid, uint64 target)
{
if( m_isInFriendList.find(target) == m_isInFriendList.end() )
return false;
for(std::list<uint64>::iterator itr = m_isInFriendList[target]->begin();
itr != m_isInFriendList[target]->end();
itr++ )
{
if( (*itr) == plrguid )
return true;
}
return false;
}
inline bool SocialMgr::HasFriend(uint64 plrguid, uint64 mfriend)
{
std::map<uint64, std::list<uint64>*>::iterator Itr;
Itr = m_hasInFriendList.find(plrguid);
if( Itr == m_hasInFriendList.end() )
return false;
std::list<uint64>::iterator lItr;
for(lItr = Itr->second->begin(); lItr != Itr->second->end(); lItr++)
{
if( (*lItr) == mfriend )
return true;
}
return false;
}
bool SocialMgr::IsIgnore(uint64 plrguid, uint64 target)
{
std::map<uint64, std::list<uint64>*>::iterator Itr;
Itr = m_isInIgnoreList.find(target);
if( Itr == m_isInIgnoreList.end() )
return false;
std::list<uint64>::iterator iter;
for( iter = Itr->second->begin(); iter != Itr->second->end(); iter++ )
{
if( (*iter) == plrguid )
return true;
}
return false;
}
inline bool SocialMgr::HasIgnore(uint64 plrguid, uint64 mignore)
{
std::map<uint64, std::list<uint64>*>::iterator Itr;
Itr = m_hasInIgnoreList.find(plrguid);
if( Itr == m_hasInIgnoreList.end() )
return false;
std::list<uint64>::iterator lItr;
for(lItr = Itr->second->begin(); lItr != Itr->second->end(); lItr++)
{
if( (*lItr) == mignore )
return true;
}
return false;
}
bool SocialMgr::HasIgnore(Player* plr, Player* mignore)
{
std::map<uint64, std::list<uint64>*>::iterator Itr;
uint64 plrguid = plr->GetGUID();
uint64 ignguid = mignore->GetGUID();
if( HasIgnore(plrguid, ignguid) )
{
std::list<uint64>::iterator iter;
Itr = m_needsBlockNotice.find(ignguid);
if( Itr != m_needsBlockNotice.end() )
{
for(iter = Itr->second->begin(); iter != Itr->second->end(); iter++)
{
if( (*iter) == plrguid )
{
std::stringstream ss;
sChatHandler.SystemMessage(mignore->GetSession(), "%s is ignoring you, it isn't possible for you to whisper him/her.", plr->GetName());
Itr->second->erase( iter );
ss << "UPDATE social SET noticed=1 WHERE guid="<< plrguid <<" AND socialguid="<< ignguid <<" AND flags='IGNORE'";
sDatabase.Execute( ss.str().c_str() );
return true;
}
}
}
return true;
}
return false;
}
inline void SocialMgr::SendOnlinePkt(Player* plr, SocialStr* pNfo)
{
if(!plr)
return;
WorldPacket data;
data.Initialize( SMSG_FRIEND_STATUS );
data << (uint8)FRIEND_ONLINE << (uint64)pNfo->pGuid << (uint8)1;
data << pNfo->Area << (uint32)pNfo->Level << (uint32)pNfo->Class;
plr->GetSession()->SendPacket( &data );
}
inline void SocialMgr::SendOfflinePkt(Player* plr, uint64 fGuid)
{
if(!plr || !plr->GetSession())
return;
WorldPacket data(SMSG_FRIEND_STATUS, 10);
data << (uint8)FRIEND_OFFLINE << (uint64)fGuid << (uint8)0;
plr->GetSession()->SendPacket( &data );
}
void SocialMgr::LoggedIn(Player* plr)
{
if(!plr)
return;
SocialStr* pNfo = new SocialStr;
pNfo->pGuid = plr->GetGUID();
std::map<uint64, std::list<uint64>*>::iterator Itr;
Itr = m_isInFriendList.find(pNfo->pGuid);
if( Itr == m_isInFriendList.end() )
{
delete pNfo;
return;
}
pNfo->Level = plr->getLevel();
pNfo->Class = plr->getClass();
pNfo->Area = plr->GetZoneId();
std::list<uint64>::iterator iter;
Player* fPlr = NULL;
for( iter = Itr->second->begin(); iter != Itr->second->end(); iter++ )
{
fPlr = objmgr.GetPlayer(*iter);
if( fPlr )
SendOnlinePkt(fPlr, pNfo);
}
// naughty!
delete pNfo;
}
void SocialMgr::LoggedOut(Player* plr)
{
if(!plr)
return;
uint64 plrguid = plr->GetGUID();
std::map<uint64, std::list<uint64>*>::iterator Itr;
Itr = m_isInFriendList.find(plrguid);
if( Itr == m_isInFriendList.end() )
return;
std::list<uint64>::iterator iter;
Player* fPlr = NULL;
for( iter = Itr->second->begin(); iter != Itr->second->end(); iter++ )
{
fPlr = objmgr.GetPlayer(*iter);
if( fPlr )
SendOfflinePkt(fPlr, plrguid);
}
}
void SocialMgr::RemovePlayer(Player* plr)
{
if(!plr)
return;
uint64 plrguid = plr->GetGUID();
std::map<uint64, std::list<uint64>*>::iterator Itr;
std::map<uint64, std::list<uint64>*>::iterator sItr;
std::list<uint64>::iterator itr;
Itr = m_isInFriendList.find(plrguid);
if( Itr != m_isInFriendList.end() )
{
for(itr = Itr->second->begin(); itr != Itr->second->end(); itr++)
{
sItr = m_hasInFriendList.find( *itr );
if( sItr != m_hasInFriendList.end() )
sItr->second->remove(plrguid);
}
delete Itr->second;
m_isInFriendList.erase(Itr);
}
Itr = m_isInIgnoreList.find(plrguid);
if( Itr != m_isInIgnoreList.end() )
{
for(itr = Itr->second->begin(); itr != Itr->second->end(); itr++)
{
sItr = m_hasInIgnoreList.find( *itr );
if( sItr != m_hasInIgnoreList.end() )
sItr->second->remove(plrguid);
}
delete Itr->second;
m_isInIgnoreList.erase(Itr);
}
Itr = m_needsBlockNotice.find(plrguid);
if( Itr != m_needsBlockNotice.end() )
{
delete Itr->second;
m_needsBlockNotice.erase(Itr);
}
std::stringstream ss;
ss <<"DELETE FROM social WHERE guid="<< plr->GetGUIDLow() <<" OR socialguid="<< plr->GetGUIDLow();
sDatabase.Execute( ss.str().c_str() );
}
void SocialMgr::LoadFromDB()
{
std::map<uint64, std::list<uint64>*>::iterator Itr;
QueryResult *result = sDatabase.Query("SELECT guid,socialguid FROM social WHERE flags='FRIEND'");
int total, num = 0;
if(result)
{
num = 0;
total =(int) result->GetRowCount();
uint64 plrguid=0, friendguid=0;
do
{
Field *field = result->Fetch();
plrguid = field[0].GetUInt64();
friendguid = field[1].GetUInt64();
Itr = m_isInFriendList.find(friendguid);
if( Itr == m_isInFriendList.end() )
m_isInFriendList[friendguid] = new std::list<uint64>;
Itr = m_hasInFriendList.find(plrguid);
if( Itr == m_hasInFriendList.end() )
m_hasInFriendList[plrguid] = new std::list<uint64>;
m_isInFriendList[friendguid]->push_back(plrguid);
m_hasInFriendList[plrguid]->push_back(friendguid);
++num;
if(!(num % 20)) SetProgressBar(num, total, "social");
} while( result->NextRow() );
ClearProgressBar();
delete result;
}
result = sDatabase.Query("SELECT guid,socialguid,noticed FROM social WHERE flags='IGNORE'");
num = 0;
if(result)
{
total =(int) result->GetRowCount();
uint64 plrguid=0, ignoreguid=0;
bool noticed = false;
do
{
Field *field = result->Fetch();
plrguid = field[0].GetUInt64();
ignoreguid = field[1].GetUInt64();
noticed = field[2].GetBool();
Itr = m_isInIgnoreList.find(ignoreguid);
if( Itr == m_isInIgnoreList.end() )
m_isInIgnoreList[ignoreguid] = new std::list<uint64>;
Itr = m_hasInIgnoreList.find(plrguid);
if( Itr == m_hasInIgnoreList.end() )
m_hasInIgnoreList[plrguid] = new std::list<uint64>;
if( !noticed )
{
Itr = m_needsBlockNotice.find(ignoreguid);
if( Itr == m_needsBlockNotice.end() )
m_needsBlockNotice[ignoreguid] = new std::list<uint64>;
m_needsBlockNotice[ignoreguid]->push_back(plrguid);
}
m_isInIgnoreList[ignoreguid]->push_back(plrguid);
m_hasInIgnoreList[plrguid]->push_back(ignoreguid);
++num;
if(!(num % 20)) SetProgressBar(num, total, "social");
} while( result->NextRow() );
delete result;
ClearProgressBar();
}
}
| [
"[email protected]"
]
| [
[
[
1,
637
]
]
]
|
8de1b21e5d37bcc00470fe7e8823f6be15151754 | 49c3e5b830831e11cf2bcd61bb7f421a42c0cda9 | /src/ofxKCore/src/Communication/TUIO.cpp | 3b1ffa326dda158db1e01e4c6f294f0e483b5692 | []
| no_license | presende/KinectCoreVision | 982ac03633a8ec41d25ed52d3ebe0ed49f328d68 | 97127f29f052f8047295a62e11443b9339cb7200 | refs/heads/master | 2021-01-15T20:12:59.723395 | 2011-09-09T14:26:27 | 2011-09-09T14:26:27 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 16,438 | cpp | /*
* TUIO.h
*
*
* Created on 2/2/09.
* Copyright 2009 NUI Group. All rights reserved.
*
*/
#include "TUIO.h"
TUIO::TUIO(){
}
TUIO::~TUIO(){
// this could be useful for whenever we get rid of an object
}
void TUIO::setup(const char* host, int port, int flashport) {
localHost = host;
TUIOPort = port;
TUIOFlashPort = flashport;
frameseq = 0;
//FOR TCP
bIsConnected = m_tcpServer.setup(TUIOFlashPort);
//FOR OSC
TUIOSocket.setup(localHost, TUIOPort);
}
void TUIO::setMode(bool blobs, bool fingers, bool objects) {
bBlobs = true; //bBlobs;
bFingers = fingers;
bObjects = objects;
}
void TUIO::sendTUIO(std::map<int, Blob> * blobBlobs, std::map<int, Blob> * fingerBlobs, std::map<int, Blob> * objectBlobs){
frameseq += 1;
// if sending OSC (not TCP)
if(bOSCMode) {
if(bBlobs){
ofxOscBundle b;
ofxOscMessage alive;
// Sends alive message - saying 'Hey, there's no alive blobs'
alive.setAddress("/tuio/2Dcur");
alive.addStringArg("alive");
// Send fseq message
ofxOscMessage fseq;
fseq.setAddress( "/tuio/2Dcur" );
fseq.addStringArg( "fseq" );
fseq.addIntArg(frameseq);
if(blobBlobs->size() == 0){
b.addMessage( alive ); // add message to bundle
b.addMessage( fseq ); // add message to bundle
TUIOSocket.sendBundle( b ); // send bundle
} else { // actually send the blobs
map<int, Blob>::iterator blob;
for(blob = blobBlobs->begin(); blob != blobBlobs->end(); blob++) {
// omit point (0,0) since this means that we are outside of the range
if(blob->second.centroid.x == 0 && blob->second.centroid.y == 0)
continue;
//Set Message
ofxOscMessage set;
set.setAddress( "/tuio/2Dcur" );
set.addStringArg("set");
set.addIntArg(blob->second.id); // id
set.addFloatArg(blob->second.centroid.x); // x
set.addFloatArg(blob->second.centroid.y); // y
set.addFloatArg(blob->second.D.x); // dX
set.addFloatArg(blob->second.D.y); // dY
set.addFloatArg(blob->second.maccel); // m
if(bHeightWidth){
set.addFloatArg(blob->second.boundingRect.width); // wd
set.addFloatArg(blob->second.boundingRect.height); // ht
}
b.addMessage( set ); // add message to bundle
alive.addIntArg(blob->second.id); // add blob to list of ALL active IDs
}
b.addMessage( alive ); //add message to bundle
b.addMessage( fseq ); //add message to bundle
TUIOSocket.sendBundle( b ); //send bundle
}
}
if(bFingers){
ofxOscBundle b;
ofxOscMessage alive;
// Sends alive message - saying 'Hey, there's no alive blobs'
alive.setAddress("/tuio/2Dcur");
alive.addStringArg("alive");
// Send fseq message
ofxOscMessage fseq;
fseq.setAddress( "/tuio/2Dcur" );
fseq.addStringArg( "fseq" );
fseq.addIntArg(frameseq);
if(fingerBlobs->size() == 0){
b.addMessage( alive ); // add message to bundle
b.addMessage( fseq ); // add message to bundle
TUIOSocket.sendBundle( b ); // send bundle
} else { // actually send the blobs
map<int, Blob>::iterator blob;
for(blob = fingerBlobs->begin(); blob != fingerBlobs->end(); blob++) {
// omit point (0,0) since this means that we are outside of the range
if(blob->second.centroid.x == 0 && blob->second.centroid.y == 0)
continue;
//Set Message
ofxOscMessage set;
set.setAddress( "/tuio/2Dcur" );
set.addStringArg("set");
set.addIntArg(blob->second.id); // id
set.addFloatArg(blob->second.centroid.x); // x
set.addFloatArg(blob->second.centroid.y); // y
set.addFloatArg(blob->second.D.x); // dX
set.addFloatArg(blob->second.D.y); // dY
set.addFloatArg(blob->second.maccel); // m
if(bHeightWidth){
set.addFloatArg(blob->second.boundingRect.width); // wd
set.addFloatArg(blob->second.boundingRect.height); // ht
}
b.addMessage( set ); // add message to bundle
alive.addIntArg(blob->second.id); // add blob to list of ALL active IDs
}
b.addMessage( alive ); //add message to bundle
b.addMessage( fseq ); //add message to bundle
TUIOSocket.sendBundle( b ); //send bundle
}
}
if(bObjects){
ofxOscBundle b_obj;
ofxOscMessage alive_obj;
// Sends alive message - saying 'Hey, there's no alive blobs'
alive_obj.setAddress("/tuio/2Dcur");
alive_obj.addStringArg("alive");
// Send fseq message
ofxOscMessage fseq_obj;
fseq_obj.setAddress( "/tuio/2Dcur" );
fseq_obj.addStringArg( "fseq" );
fseq_obj.addIntArg(frameseq);
if(objectBlobs->size() == 0){
b_obj.addMessage( alive_obj ); // add message to bundle
b_obj.addMessage( fseq_obj ); // add message to bundle
TUIOSocket.sendBundle( b_obj ); // send bundle
} else {
map<int, Blob>::iterator blob_obj;
for(blob_obj = objectBlobs->begin(); blob_obj != objectBlobs->end(); blob_obj++) {
// omit point (0,0) since this means that we are outside of the range
if(blob_obj->second.centroid.x == 0 && blob_obj->second.centroid.y == 0)
continue;
//Set Message
ofxOscMessage set_obj;
set_obj.setAddress( "/tuio/2Dcur" );
set_obj.addStringArg("set");
set_obj.addIntArg(blob_obj->second.id); // id
set_obj.addFloatArg(blob_obj->second.centroid.x); // x
set_obj.addFloatArg(blob_obj->second.centroid.y); // y
set_obj.addFloatArg(blob_obj->second.D.x); // dX
set_obj.addFloatArg(blob_obj->second.D.y); // dY
set_obj.addFloatArg(blob_obj->second.maccel); // m
if(bHeightWidth) {
set_obj.addFloatArg(blob_obj->second.boundingRect.width); // wd
set_obj.addFloatArg(blob_obj->second.boundingRect.height); // ht
}
b_obj.addMessage( set_obj ); // add message to bundle
alive_obj.addIntArg(blob_obj->second.id); // add blob to list of ALL active IDs
}
b_obj.addMessage( alive_obj ); //add message to bundle
b_obj.addMessage( fseq_obj ); //add message to bundle
TUIOSocket.sendBundle( b_obj ); //send bundle
}
}
}
if(bTCPMode) { // else, if TCP (flash) mode {
if(bBlobs || bFingers || bObjects) {
if(blobBlobs->size() == 0 && fingerBlobs->size() == 0 && objectBlobs->size() == 0) {
m_tcpServer.sendToAll("<OSCPACKET ADDRESS=\"127.0.0.1\" PORT=\""+ofToString(TUIOFlashPort)+"\" TIME=\""+ofToString(ofGetElapsedTimef())+"\">" +
"<MESSAGE NAME=\"/tuio/2Dcur\">"+
"<ARGUMENT TYPE=\"s\" VALUE=\"alive\"/>"+
"</MESSAGE>"+
"<MESSAGE NAME=\"/tuio/2Dcur\">"+
"<ARGUMENT TYPE=\"s\" VALUE=\"fseq\"/>"+
"<ARGUMENT TYPE=\"i\" VALUE=\""+ofToString(frameseq)+"\"/>" +
"</MESSAGE>"+
"</OSCPACKET>");
} else {
string setBlobsMsg;
string aliveBeginMsg = "<MESSAGE NAME=\"/tuio/2Dcur\"><ARGUMENT TYPE=\"s\" VALUE=\"alive\"/>";
string aliveEndMsg = "</MESSAGE>";
string aliveBlobsMsg;
//Blob TUIO
map<int, Blob>::iterator blob;
for(blob = blobBlobs->begin(); blob != blobBlobs->end(); blob++){
// omit point (0,0) since this means that we are outside of the range
if(blob->second.centroid.x == 0 && blob->second.centroid.y == 0)
continue;
// if sending height and width
if(bHeightWidth){
setBlobsMsg += "<MESSAGE NAME=\"/tuio/2Dcur\"><ARGUMENT TYPE=\"s\" VALUE=\"set\"/><ARGUMENT TYPE=\"i\" VALUE=\""+ofToString(blob->second.id)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob->second.centroid.x)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob->second.centroid.y)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob->second.D.x)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob->second.D.y)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob->second.maccel)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob->second.boundingRect.width)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob->second.boundingRect.height)+"\"/>"+
"</MESSAGE>";
} else {
setBlobsMsg += "<MESSAGE NAME=\"/tuio/2Dcur\"><ARGUMENT TYPE=\"s\" VALUE=\"set\"/><ARGUMENT TYPE=\"i\" VALUE=\""+ofToString(blob->second.id)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob->second.centroid.x)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob->second.centroid.y)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob->second.D.x)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob->second.D.y)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob->second.maccel)+"\"/>"+
"</MESSAGE>";
}
aliveBlobsMsg += "<ARGUMENT TYPE=\"i\" VALUE=\""+ofToString(blob->second.id)+"\"/>";
}
//Finger TUIO
//map<int, Blob>::iterator blob;
map<int, Blob>::iterator blob_fng;
for(blob_fng = fingerBlobs->begin(); blob_fng != fingerBlobs->end(); blob_fng++){
// omit point (0,0) since this means that we are outside of the range
if(blob_fng->second.centroid.x == 0 && blob_fng->second.centroid.y == 0)
continue;
// if sending height and width
if(bHeightWidth){
setBlobsMsg += "<MESSAGE NAME=\"/tuio/2Dcur\"><ARGUMENT TYPE=\"s\" VALUE=\"set\"/><ARGUMENT TYPE=\"i\" VALUE=\""+ofToString(blob->second.id)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob_fng->second.centroid.x)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob_fng->second.centroid.y)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob_fng->second.D.x)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob_fng->second.D.y)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob_fng->second.maccel)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob_fng->second.boundingRect.width)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob_fng->second.boundingRect.height)+"\"/>"+
"</MESSAGE>";
} else {
setBlobsMsg += "<MESSAGE NAME=\"/tuio/2Dcur\"><ARGUMENT TYPE=\"s\" VALUE=\"set\"/><ARGUMENT TYPE=\"i\" VALUE=\""+ofToString(blob->second.id)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob_fng->second.centroid.x)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob_fng->second.centroid.y)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob_fng->second.D.x)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob_fng->second.D.y)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob_fng->second.maccel)+"\"/>"+
"</MESSAGE>";
}
aliveBlobsMsg += "<ARGUMENT TYPE=\"i\" VALUE=\""+ofToString(blob_fng->second.id)+"\"/>";
}
//Object TUIO
map<int, Blob>::iterator blob_obj;
for(blob_obj = objectBlobs->begin(); blob_obj != objectBlobs->end(); blob_obj++) {
// omit point (0,0) since this means that we are outside of the range
if(blob_obj->second.centroid.x == 0 && blob_obj->second.centroid.y == 0)
continue;
// if sending height and width
if(bHeightWidth) {
setBlobsMsg += "<MESSAGE NAME=\"/tuio/2Dcur\"><ARGUMENT TYPE=\"s\" VALUE=\"set\"/><ARGUMENT TYPE=\"i\" VALUE=\""+ofToString(blob_obj->second.id)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob_obj->second.centroid.x)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob_obj->second.centroid.y)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob_obj->second.D.x)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob_obj->second.D.y)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob_obj->second.maccel)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob_obj->second.boundingRect.width)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob_obj->second.boundingRect.height)+"\"/>"+
"</MESSAGE>";
} else {
setBlobsMsg += "<MESSAGE NAME=\"/tuio/2Dcur\"><ARGUMENT TYPE=\"s\" VALUE=\"set\"/><ARGUMENT TYPE=\"i\" VALUE=\""+ofToString(blob_obj->second.id)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob_obj->second.centroid.x)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob_obj->second.centroid.y)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob_obj->second.D.x)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob_obj->second.D.y)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(blob_obj->second.maccel)+"\"/>"+
"</MESSAGE>";
}
aliveBlobsMsg += "<ARGUMENT TYPE=\"i\" VALUE=\""+ofToString(blob_obj->second.id)+"\"/>";
}
string fseq = "<MESSAGE NAME=\"/tuio/2Dcur\"><ARGUMENT TYPE=\"s\" VALUE=\"fseq\"/><ARGUMENT TYPE=\"i\" VALUE=\""+ofToString(frameseq) + "\"/></MESSAGE>";
m_tcpServer.sendToAll("<OSCPACKET ADDRESS=\"127.0.0.1\" PORT=\"" +
ofToString(TUIOFlashPort) + "\" TIME=\""+ofToString(ofGetElapsedTimef()) + "\">" +
setBlobsMsg + aliveBeginMsg + aliveBlobsMsg + aliveEndMsg + fseq + "</OSCPACKET>");
}
}
}
if (bBinaryMode) { // else, if TCP (binary) mode
if(bBlobs) {
uchar buf[1024*8];
uchar *p = buf;
// Add "CCV" as a data header
*p++ = 'C'; *p++ = 'C'; *p++ = 'V'; *p++ = '\0';
if(blobBlobs->size() == 0){
memset(p, 0, 4);
p += 4;
} else {
int count = 0;
map<int, Blob>::iterator blob;
// count the blobs that are non (0,0)
for(blob = blobBlobs->begin(); blob != blobBlobs->end(); blob++) {
// omit point (0,0) since this means that we are outside of the range
if(blob->second.centroid.x == 0 && blob->second.centroid.y == 0)
continue;
count++;
}
// send blob count first
memcpy(p, &count, 4); p += 4;
// send blob information
for(blob = blobBlobs->begin(); blob != blobBlobs->end(); blob++) {
// omit point (0,0) since this means that we are outside of the range
if(blob->second.centroid.x == 0 && blob->second.centroid.y == 0)
continue;
memcpy(p, &blob->second.id, 4); p += 4;
memcpy(p, &blob->second.centroid.x, 4); p += 4;
memcpy(p, &blob->second.centroid.y, 4); p += 4;
memcpy(p, &blob->second.D.x, 4); p += 4;
memcpy(p, &blob->second.D.y, 4); p += 4;
memcpy(p, &blob->second.maccel, 4); p += 4;
if(bHeightWidth) {
memcpy(p, &blob->second.boundingRect.width, 4); p += 4;
memcpy(p, &blob->second.boundingRect.height, 4); p += 4;
}
}
}
// send blob data to clients
m_tcpServer.sendRawBytesToAll((const char*)buf, p-buf);
}
if(bFingers) {
uchar buf[1024*8];
uchar *p = buf;
// Add "CCV" as a data header
*p++ = 'C'; *p++ = 'C'; *p++ = 'V'; *p++ = '\0';
if(fingerBlobs->size() == 0){
memset(p, 0, 4);
p += 4;
} else {
int count = 0;
map<int, Blob>::iterator blob;
// count the blobs that are non (0,0)
for(blob = fingerBlobs->begin(); blob != fingerBlobs->end(); blob++) {
// omit point (0,0) since this means that we are outside of the range
if(blob->second.centroid.x == 0 && blob->second.centroid.y == 0)
continue;
count++;
}
// send blob count first
memcpy(p, &count, 4); p += 4;
// send blob information
for(blob = fingerBlobs->begin(); blob != fingerBlobs->end(); blob++) {
// omit point (0,0) since this means that we are outside of the range
if(blob->second.centroid.x == 0 && blob->second.centroid.y == 0)
continue;
memcpy(p, &blob->second.id, 4); p += 4;
memcpy(p, &blob->second.centroid.x, 4); p += 4;
memcpy(p, &blob->second.centroid.y, 4); p += 4;
memcpy(p, &blob->second.D.x, 4); p += 4;
memcpy(p, &blob->second.D.y, 4); p += 4;
memcpy(p, &blob->second.maccel, 4); p += 4;
if(bHeightWidth) {
memcpy(p, &blob->second.boundingRect.width, 4); p += 4;
memcpy(p, &blob->second.boundingRect.height, 4); p += 4;
}
}
}
// send blob data to clients
m_tcpServer.sendRawBytesToAll((const char*)buf, p-buf);
}
// bObjects ??????
}
} | [
"[email protected]"
]
| [
[
[
1,
396
]
]
]
|
ee17e83514b3c7e216aff56bb8e39f731f3aec78 | e31046aee3ad2d4600c7f35aaeeba76ee2b99039 | /trunk/libs/bullet/includes/BulletCollision/CollisionDispatch/btCollisionObject.h | ee5fc27f85f0a5d9a9ef1891cb99e83f8ec6f1e6 | []
| no_license | BackupTheBerlios/trinitas-svn | ddea265cf47aff3e8853bf6d46861e0ed3031ea1 | 7d3ff64a7d0e5ba37febda38e6ce0b2d0a4b6cca | refs/heads/master | 2021-01-23T08:14:44.215249 | 2009-02-18T19:37:51 | 2009-02-18T19:37:51 | 40,749,519 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,814 | h | /*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef COLLISION_OBJECT_H
#define COLLISION_OBJECT_H
#include "LinearMath/btTransform.h"
//island management, m_activationState1
#define ACTIVE_TAG 1
#define ISLAND_SLEEPING 2
#define WANTS_DEACTIVATION 3
#define DISABLE_DEACTIVATION 4
#define DISABLE_SIMULATION 5
struct btBroadphaseProxy;
class btCollisionShape;
#include "LinearMath/btMotionState.h"
#include "LinearMath/btAlignedAllocator.h"
/// btCollisionObject can be used to manage collision detection objects.
/// btCollisionObject maintains all information that is needed for a collision detection: Shape, Transform and AABB proxy.
/// They can be added to the btCollisionWorld.
ATTRIBUTE_ALIGNED16(class) btCollisionObject
{
protected:
btTransform m_worldTransform;
///m_interpolationWorldTransform is used for CCD and interpolation
///it can be either previous or future (predicted) transform
btTransform m_interpolationWorldTransform;
//those two are experimental: just added for bullet time effect, so you can still apply impulses (directly modifying velocities)
//without destroying the continuous interpolated motion (which uses this interpolation velocities)
btVector3 m_interpolationLinearVelocity;
btVector3 m_interpolationAngularVelocity;
btBroadphaseProxy* m_broadphaseHandle;
btCollisionShape* m_collisionShape;
///m_rootCollisionShape is temporarily used to store the original collision shape
///The m_collisionShape might be temporarily replaced by a child collision shape during collision detection purposes
///If it is NULL, the m_collisionShape is not temporarily replaced.
btCollisionShape* m_rootCollisionShape;
int m_collisionFlags;
int m_islandTag1;
int m_companionId;
int m_activationState1;
btScalar m_deactivationTime;
btScalar m_friction;
btScalar m_restitution;
///users can point to their objects, m_userPointer is not used by Bullet, see setUserPointer/getUserPointer
void* m_userObjectPointer;
///m_internalType is reserved to distinguish Bullet's btCollisionObject, btRigidBody, btSoftBody etc.
///do not assign your own m_internalType unless you write a new dynamics object class.
int m_internalType;
///time of impact calculation
btScalar m_hitFraction;
///Swept sphere radius (0.0 by default), see btConvexConvexAlgorithm::
btScalar m_ccdSweptSphereRadius;
/// Don't do continuous collision detection if the motion (in one step) is less then m_ccdMotionThreshold
btScalar m_ccdMotionThreshold;
/// If some object should have elaborate collision filtering by sub-classes
bool m_checkCollideWith;
char m_pad[7];
virtual bool checkCollideWithOverride(btCollisionObject* /* co */)
{
return true;
}
public:
BT_DECLARE_ALIGNED_ALLOCATOR();
enum CollisionFlags
{
CF_STATIC_OBJECT= 1,
CF_KINEMATIC_OBJECT= 2,
CF_NO_CONTACT_RESPONSE = 4,
CF_CUSTOM_MATERIAL_CALLBACK = 8//this allows per-triangle material (friction/restitution)
};
enum CollisionObjectTypes
{
CO_COLLISION_OBJECT =1,
CO_RIGID_BODY,
CO_SOFT_BODY
};
SIMD_FORCE_INLINE bool mergesSimulationIslands() const
{
///static objects, kinematic and object without contact response don't merge islands
return ((m_collisionFlags & (CF_STATIC_OBJECT | CF_KINEMATIC_OBJECT | CF_NO_CONTACT_RESPONSE) )==0);
}
SIMD_FORCE_INLINE bool isStaticObject() const {
return (m_collisionFlags & CF_STATIC_OBJECT) != 0;
}
SIMD_FORCE_INLINE bool isKinematicObject() const
{
return (m_collisionFlags & CF_KINEMATIC_OBJECT) != 0;
}
SIMD_FORCE_INLINE bool isStaticOrKinematicObject() const
{
return (m_collisionFlags & (CF_KINEMATIC_OBJECT | CF_STATIC_OBJECT)) != 0 ;
}
SIMD_FORCE_INLINE bool hasContactResponse() const {
return (m_collisionFlags & CF_NO_CONTACT_RESPONSE)==0;
}
btCollisionObject();
virtual ~btCollisionObject();
virtual void setCollisionShape(btCollisionShape* collisionShape)
{
m_collisionShape = collisionShape;
m_rootCollisionShape = collisionShape;
}
SIMD_FORCE_INLINE const btCollisionShape* getCollisionShape() const
{
return m_collisionShape;
}
SIMD_FORCE_INLINE btCollisionShape* getCollisionShape()
{
return m_collisionShape;
}
SIMD_FORCE_INLINE const btCollisionShape* getRootCollisionShape() const
{
return m_rootCollisionShape;
}
SIMD_FORCE_INLINE btCollisionShape* getRootCollisionShape()
{
return m_rootCollisionShape;
}
///Avoid using this internal API call
///internalSetTemporaryCollisionShape is used to temporary replace the actual collision shape by a child collision shape.
void internalSetTemporaryCollisionShape(btCollisionShape* collisionShape)
{
m_collisionShape = collisionShape;
}
int getActivationState() const { return m_activationState1;}
void setActivationState(int newState);
void setDeactivationTime(btScalar time)
{
m_deactivationTime = time;
}
btScalar getDeactivationTime() const
{
return m_deactivationTime;
}
void forceActivationState(int newState);
void activate(bool forceActivation = false);
inline bool isActive() const
{
return ((getActivationState() != ISLAND_SLEEPING) && (getActivationState() != DISABLE_SIMULATION));
}
void setRestitution(btScalar rest)
{
m_restitution = rest;
}
btScalar getRestitution() const
{
return m_restitution;
}
void setFriction(btScalar frict)
{
m_friction = frict;
}
btScalar getFriction() const
{
return m_friction;
}
///reserved for Bullet internal usage
int getInternalType() const
{
return m_internalType;
}
btTransform& getWorldTransform()
{
return m_worldTransform;
}
const btTransform& getWorldTransform() const
{
return m_worldTransform;
}
void setWorldTransform(const btTransform& worldTrans)
{
m_worldTransform = worldTrans;
}
btBroadphaseProxy* getBroadphaseHandle()
{
return m_broadphaseHandle;
}
const btBroadphaseProxy* getBroadphaseHandle() const
{
return m_broadphaseHandle;
}
void setBroadphaseHandle(btBroadphaseProxy* handle)
{
m_broadphaseHandle = handle;
}
const btTransform& getInterpolationWorldTransform() const
{
return m_interpolationWorldTransform;
}
btTransform& getInterpolationWorldTransform()
{
return m_interpolationWorldTransform;
}
void setInterpolationWorldTransform(const btTransform& trans)
{
m_interpolationWorldTransform = trans;
}
void setInterpolationLinearVelocity(const btVector3& linvel)
{
m_interpolationLinearVelocity = linvel;
}
void setInterpolationAngularVelocity(const btVector3& angvel)
{
m_interpolationAngularVelocity = angvel;
}
const btVector3& getInterpolationLinearVelocity() const
{
return m_interpolationLinearVelocity;
}
const btVector3& getInterpolationAngularVelocity() const
{
return m_interpolationAngularVelocity;
}
const int getIslandTag() const
{
return m_islandTag1;
}
void setIslandTag(int tag)
{
m_islandTag1 = tag;
}
const int getCompanionId() const
{
return m_companionId;
}
void setCompanionId(int id)
{
m_companionId = id;
}
const btScalar getHitFraction() const
{
return m_hitFraction;
}
void setHitFraction(btScalar hitFraction)
{
m_hitFraction = hitFraction;
}
const int getCollisionFlags() const
{
return m_collisionFlags;
}
void setCollisionFlags(int flags)
{
m_collisionFlags = flags;
}
///Swept sphere radius (0.0 by default), see btConvexConvexAlgorithm::
btScalar getCcdSweptSphereRadius() const
{
return m_ccdSweptSphereRadius;
}
///Swept sphere radius (0.0 by default), see btConvexConvexAlgorithm::
void setCcdSweptSphereRadius(btScalar radius)
{
m_ccdSweptSphereRadius = radius;
}
btScalar getCcdMotionThreshold() const
{
return m_ccdMotionThreshold;
}
btScalar getCcdSquareMotionThreshold() const
{
return m_ccdMotionThreshold*m_ccdMotionThreshold;
}
/// Don't do continuous collision detection if the motion (in one step) is less then m_ccdMotionThreshold
void setCcdMotionThreshold(btScalar ccdMotionThreshold)
{
m_ccdMotionThreshold = ccdMotionThreshold*ccdMotionThreshold;
}
///users can point to their objects, userPointer is not used by Bullet
void* getUserPointer() const
{
return m_userObjectPointer;
}
///users can point to their objects, userPointer is not used by Bullet
void setUserPointer(void* userPointer)
{
m_userObjectPointer = userPointer;
}
inline bool checkCollideWith(btCollisionObject* co)
{
if (m_checkCollideWith)
return checkCollideWithOverride(co);
return true;
}
};
#endif //COLLISION_OBJECT_H
| [
"paradoxon@ab3bda7c-5b37-0410-9911-e7f4556ba333"
]
| [
[
[
1,
384
]
]
]
|
945fa38c51f41bc0915f649dd70aa11535bc229f | 74c8da5b29163992a08a376c7819785998afb588 | /NetAnimal/Game/wheel/MyWheelDirector/src/DUI/Dan.cpp | a47207636f354d249c6daa989ec5845afb43f088 | []
| no_license | dbabox/aomi | dbfb46c1c9417a8078ec9a516cc9c90fe3773b78 | 4cffc8e59368e82aed997fe0f4dcbd7df626d1d0 | refs/heads/master | 2021-01-13T14:05:10.813348 | 2011-06-07T09:36:41 | 2011-06-07T09:36:41 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 10,068 | cpp | #include "MyWheelDirectorStableHeaders.h"
#include "DUI/Dan.h"
#include "F5TableInterface.h"
#include "LockInterface.h"
#include "CodingFormatInterface.h"
#include "DataServerInterface.h"
#include "GSMInterface.h"
using namespace Orz;
DanLine::DanLine(void)
{
}
DanLine::~DanLine(void)
{
}
void DanLine::push_back(CEGUI::Window * win)
{
_windows.push_back(win);
}
void DanLine::write(int i, const std::string & text)
{
_windows[i]->setText(text);
}
bool Dan::textAccepted(const CEGUI::EventArgs&)
{
if(!check())
return false;
CodingFormatInterface * format = _coding->queryInterface<CodingFormatInterface>();
CEGUI::String text = CEGUI::WindowManager::getSingleton().getWindow("Dan/Bg/Text/Putin")->getText();
if(text.empty())
return true;
if(text.size() <= 9)
{
this->warning(L"输入未满9位");
}else
{
format->clear();
LockInterface * lock = _dataServer->queryInterface<LockInterface>();
DataServerInterface * data = _dataServer->queryInterface<DataServerInterface>();
std::string code = lock->getLockCode2();
format->decode10(code, 60);
unsigned int oCheck = format->getCheck8(60);
if(data->loadCodingData())
{
CodingFormatInterface * lockData = _dataServer->queryInterface<CodingFormatInterface>();
unsigned int oId = lockData->getLockID();
if(format->decode10(std::string(text.c_str()),28))
{
if(format->getBackCheck() != oCheck ||format->getBackID() != (oId%128))
{
warning(L"开机码和报账码不匹配,请重新报账");
}else
{
lockData->setLockLeavings(format->getBackLeavingsIndex());
data->saveCodingData();
unsigned int index = format->getBackLeavingsIndex();
unsigned int profits = format->index2Profits(index);
unsigned int levings = data->getLevingsProfits();
data->setLevingsProfits(levings + profits);
data->cleanCostBackTimeCode2();
data->save();
if(check())
{
warning(L"报账成功");
}
}
}
else
{
warning(L"无效开机码");
}
}else
{
warning(L"内部数据错误,请联系开发商!");
}
}
CEGUI::WindowManager::getSingleton().getWindow("Dan/Bg/Text/Putin")->setText("");
return true;
}
Dan::Dan(DanListener * listener, ComponentPtr dataServer, GSMInterface * gsm):_time(-1.f),_callback(listener), _gsm(gsm)
{
_dataServer = dataServer;
_table = Orz::ComponentFactories::getInstance().create("Table");
_coding = Orz::ComponentFactories::getInstance().create("Format");
/*_lockCoding = Orz::ComponentFactories::getInstance().create("Format");
_lock = Orz::ComponentFactories::getInstance().create("Senselock");*/
LockInterface * lock = _dataServer->queryInterface<LockInterface>();
CodingFormatInterface * format = _coding->queryInterface<CodingFormatInterface>();
DataServerInterface * data = _dataServer->queryInterface<DataServerInterface>();
format->_key = lock->key;
_win= CEGUI::WindowManager::getSingleton().loadWindowLayout("dan.layout");
_win->setAlwaysOnTop(true);
_win->hide();
//CEGUI::Window * f = CEGUI::WindowManager::getSingleton().getWindow("AnimalUI");
//f->addChildWindow(_win);
for(int i = 0; i < 9; i++)
{
std::string n = boost::lexical_cast<std::string>(i);
LinePtr line(new DanLine());
for(int j=0;j<9; ++j)
{
//std::cout<<"Dan/Bg/Line0/Tt" + n + boost::lexical_cast<std::string>(j)<<std::endl;
line->push_back(CEGUI::WindowManager::getSingleton().getWindow("Dan/Bg/Line0/Tt" + n + boost::lexical_cast<std::string>(j)));
}
_lines.push_back(line);
}
}
bool Dan::check(void)
{
LockInterface * lock = _dataServer->queryInterface<LockInterface>();
CodingFormatInterface * lockFormat = _dataServer->queryInterface<CodingFormatInterface>();
CodingFormatInterface * format = _coding->queryInterface<CodingFormatInterface>();
DataServerInterface * data = _dataServer->queryInterface<DataServerInterface>();
if(_gsm->failsOver(3))
{
warning(L"请检查短信猫是否配置正确!",2.0);
return false;
}
bool right = true;
if(!lock->check())
{
warning(L"请检查加密狗是否配置正确!",2.0);
right = false;
}
if(right)
{
lock->update();
std::string code = lock->getLockCode();
if(!lockFormat->decode10(code, 60))
{
srand(time(NULL));
lockFormat->clear();
lockFormat->setLockTimes(0);
lockFormat->setLockID(rand()%128);
lockFormat->setLockLeavings(0);
lockFormat->setLockPass(0);
right = false;
}
if(!data->hasLevings())
{
warning(L"游戏额度已经用光,请重新打码!", 5.0f );
right = false;
}
}
std::wstringstream wss;
if(!right)
{
setText("Dan/Bg/Text/BzmText", L"?????,?????,?????,?????");
wss<<L"无法读取游戏额度";
}else
{
std::string code = lock->getLockCode2();
if(lockFormat->decode10(code, 60))
{
std::wstring wstr;
for(int i=0;i<20; i++)
{
if(i%5 == 0 && i != 0)
wstr.push_back(',');
wstr.push_back(code.at(i));
}
setText("Dan/Bg/Text/BzmText", wstr);
}
wss<<L"距离下次报账还有"<<data->getLevingsProfits()<<L" 个游戏额度";
warning(L"运行正常!", 1.0f);
}
setText("Dan/Bg/Text/ed", wss.str());
return right;
}
void Dan::setText(const std::string & window, const std::wstring & str)
{
CEGUI::WindowManager::getSingleton().getWindow(window.c_str())->setText((CEGUI::utf8*)Ogre::UTFString(str.c_str()).asUTF8_c_str());
}
void Dan::setText(const std::string & window, const std::string & str)
{
CEGUI::WindowManager::getSingleton().getWindow(window.c_str())->setText((CEGUI::utf8*)Ogre::UTFString(str.c_str()).asUTF8_c_str());
}
void Dan::warning(const std::wstring & text, TimeType time)
{
setText("Dan/Bg/W", text);
_time =time;
}
void Dan::write(int i, int j, const std::string & text)
{
_lines[j]->write(i, text);
}
void Dan::show(void)
{
Orz::IInputManager::getSingleton().addKeyListener(this);
check();
refresh();
F5TableInterface * table = _table->queryInterface<F5TableInterface>();
_connection = table->refreshSigConnection(boost::bind(&Dan::refresh,this));
CEGUI::Window * win = CEGUI::System::getSingleton().getGUISheet();
if(win)
{
win->addChildWindow(_win);
}
_win->show();
CEGUI::WindowManager::getSingleton().getWindow("Dan/Bg/Text/Putin")->activate();
static_cast<CEGUI::Editbox*>(CEGUI::WindowManager::getSingleton().getWindow("Dan/Bg/Text/Putin"))->setValidationString("[0-9Xx]*");
static_cast<CEGUI::Editbox*>(CEGUI::WindowManager::getSingleton().getWindow("Dan/Bg/Text/Putin"))->setMaxTextLength(10);
CEGUI::WindowManager::getSingleton().getWindow("Dan/Bg/Text/Putin")->
subscribeEvent(CEGUI::Editbox::EventTextAccepted, CEGUI::Event::Subscriber(&Dan::textAccepted, this));
}
void Dan::hide(void)
{
Orz::IInputManager::getSingleton().removeKeyListener(this);
CEGUI::WindowManager::getSingleton().getWindow("Dan/Bg/Text/Putin")->removeAllEvents();
_win->hide();
_connection.disconnect();
CEGUI::Window * win = CEGUI::System::getSingleton().getGUISheet();
if(win)
{
win->removeChildWindow(_win);
}
_time = -1.0;
}
Dan::~Dan(void)
{
hide();
}
//void Dan::refresh(F5TableInterface::ID id, F5TableInterface::ACCOUNTS_ITEM item)
//{
//
//
// F5TableInterface * table = _table->queryInterface<F5TableInterface>();
// int allData = 0;
// for(int i = 0; i<F5TableInterface::_end; ++i)
// {
// int data = table->getData(F5TableInterface::ID(i), item);
//
// if(i == id)
// write(item, id, boost::lexical_cast<std::string>(data));
// allData+= data;
//
// }
// write(item, F5TableInterface::_all, boost::lexical_cast<std::string>(allData));
//
//}
void Dan::refresh(void)
{
F5TableInterface * table = _table->queryInterface<F5TableInterface>();
for(int j = 0; j<F5TableInterface::END; ++j)
{
int allData = 0;
for(int i = 0; i<F5TableInterface::_end; ++i)
{
int data = table->getData(F5TableInterface::ID(i), F5TableInterface::ACCOUNTS_ITEM(j));
write(j,i,boost::lexical_cast<std::string>(data));
allData+= data;
}
//write(j, F5TableInterface::_all, boost::lexical_cast<std::string>(allData));
}
}
bool Dan::onKeyPressed(const KeyEvent & evt)
{
if(evt.getKey() == Orz::KC_B)
{
LockInterface * lock = _dataServer->queryInterface<LockInterface>();
DataServerInterface * data = _dataServer->queryInterface<DataServerInterface>();
if(check())
{
CodingFormatInterface * format = _coding->queryInterface<CodingFormatInterface>();
format->clear();
format->setCost(data->getCost());
format->setEarn(data->getEarn());
format->setPass(data->getSeconds()/ 3600);
{
if(!data->loadCodingData())
{
data->reset();
}
CodingFormatInterface * lockData = _dataServer->queryInterface<CodingFormatInterface>();
unsigned int times = lockData->getLockTimes();
format->setTimes(times);
lockData->setLockTimes(times +1);
format->setID(lockData->getLockID());
data->saveCodingData();
}
std::string str = format->encode10(60 ,20);
std::wstring wstr;
for(int i=0;i<20; i++)
{
if(i%5 == 0 && i != 0)
wstr.push_back(',');
wstr.push_back(str.at(i));
}
lock->setLockCode2(str);
data->save();
warning(L"报账码生成,成功!");
setText("Dan/Bg/Text/BzmText", wstr);
}/*else
{
setText("Dan/Bg/Text/BzmText", L"?????,?????,?????,?????");
}*/
}
return false;
}
bool Dan::onKeyReleased(const KeyEvent & evt)
{
return false;
}
void Dan::update(TimeType time)
{
if(_time > 0.f)
{
_time -= time;
if( _time <= 0.f)
{
check();
}
}
}
void Dan::result(bool ret)
{
if(ret)
{
this->warning(L"成功");
}
else
this->warning(L"失败");
_time = 1.0;
} | [
"[email protected]"
]
| [
[
[
1,
406
]
]
]
|
df88f466df02e6650b4548756142010684bd4f7e | 3128346a72b842c6dd94f2b854170d5daeeedc6f | /src/CoreDynBody.h | 039f347a8ae5a8e37a6f24b5bf003ae3d2f0ba7f | []
| no_license | Valrandir/Core512 | 42c3ed02f3f5455a9e0d722c014c80bb2bae17ab | af6b45aa2eded3f32964339ffebdab3491b08561 | refs/heads/master | 2021-01-22T04:57:15.719013 | 2011-11-11T05:16:30 | 2011-11-11T05:16:30 | 2,607,600 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 471 | h | #pragma once
#include "CoreBody.h"
class CoreDynBody : public CoreBody
{
BOOL Initialized;
static float GlobalFriction;
CoreVector Velocity;
public:
CoreDynBody();
CoreDynBody(const CoreVector& Center, const CoreTexture& Texture);
void Initialize(const CoreVector& Center, const CoreTexture& Texture);
virtual ~CoreDynBody();
virtual void ApplyForce(const CoreVector& Force);
virtual void HardStop();
virtual void Update(float Delta);
};
| [
"[email protected]"
]
| [
[
[
1,
19
]
]
]
|
cd64a8ee0aff36e9ce5513f925307cd77adaad31 | 13a683bacff74be42a305f22401cf1a25fcab751 | /src/generateHyp.cpp | f7b942aebd486adbab1764c85402e601cdb9f9ae | []
| no_license | ivan444/overlapping-object-recognition | e15b4b5e86cdf7305ff5e710d3b3678f11d275bb | 3638f20bd254a5598ceefc22bf99d9af33d7a452 | refs/heads/master | 2016-09-15T20:33:38.210079 | 2011-01-28T03:28:56 | 2011-01-28T03:28:56 | 33,362,592 | 0 | 0 | null | null | null | null | WINDOWS-1250 | C++ | false | false | 4,341 | cpp | #include <iostream>
#include <string>
#include "imageIO.h"
#include "openCVJpegIO.h"
#include "edgeSegmentator.h"
//#include "paramVector.h"
#include "generateHyp.h"
#include "math.h"
#include "image.h"
#define M_PI 3.14159265358979323846
#define sk 0.1
#define sa 0.1
#define sx 0.1
#define sy 0.1
using namespace std;
int round(double x)
{
int intX = (int) x;
x -= (double) intX;
if (x < 0.5)
return intX;
else
return intX+1;
};
EdgeSegment paramVector::transform(EdgeSegment &orig)
{
PixelCoordinates first = orig.getFirst();
PixelCoordinates last = orig.getLast();
double x = (double)first.x;
double y = (double)first.y;
double new_x = tx + x*kCos - y*kSin;
double new_y = ty + x*kSin + y*kCos;
PixelCoordinates tFirst;
tFirst.x = (unsigned int) round (new_x);
tFirst.y = (unsigned int) round (new_y);
x = (double)last.x;
y = (double)last.y;
new_x = tx + x*kCos - y*kSin;
new_y = ty + x*kSin + y*kCos;
PixelCoordinates tLast;
tLast.x = (unsigned int) round (new_x);
tLast.y = (unsigned int) round (new_y);
EdgeSegment result(tFirst,tLast, "transform" + orig.getImagrID());
return result;
}
bool segmentsCmp( const EdgeSegment &a, const EdgeSegment &b ){
return (a.getLength() > b.getLength());
}
vector<EdgeSegment> GetLongestSegs(int numOfSeg, vector<EdgeSegment> segments){
vector<EdgeSegment> longestSegs;
sort( segments.begin(), segments.end(), segmentsCmp );
if (segments.size() < numOfSeg)//ako ima manje od 10 lin. segmenata
{
numOfSeg = segments.size();
}
for (int i = 0; i <numOfSeg; i++) {
longestSegs.push_back(segments[i]);
}
return longestSegs;
}
bool checkCompatibility(EdgeSegment M, EdgeSegment S, double treshAngle, double treshLength, double k0, double &A, double &r)
{
double angleM = atan(tan(M.getAngle_A()));
if (angleM < 0) angleM += M_PI;
double angleS = atan(tan(S.getAngle_A()));
if (angleS < 0) angleS += M_PI;
A = fabs(angleM - angleS);
r = fabs(S.getLength()/ M.getLength());
if(! (A < treshAngle || fabs(A - M_PI) < treshAngle)) return false;
else if (r - k0 > k0*treshLength) return false; // Zasad nepotrebno...
//else if (k0 > 5 || k0 < 0.3) return false; // @Debug, uklanjanje loših hipoteza (svi objekti su nam približno jednaki)
else if (k0 > 3 || k0 < 0.33) return false; // @Debug, uklanjanje loših hipoteza (svi objekti su nam približno jednaki)
else return true;
}
bool GenerateErrCovMatrix(Hypothesis &hypothesis, EdgeSegment M, EdgeSegment S, double tresholdAngle, double tresholdLength)
{
double A = 0;
double r = 0;
// @Debug
if (S.getMiddleX() == 641 && M.getMiddleX() == 653)
int nesto = 0;
if (M.getAngle_A() > 1.02 && M.getAngle_A() < 1.03)
int nesto = 12843;
double k0 = fabs(S.getLength()/M.getLength()); // zasad nekorisno
double angle = S.getAngle() - M.getAngle();
double tx0 = S.getMiddleX() - k0*(M.getMiddleX()*cos(angle) - M.getMiddleY()*sin(angle));
double ty0 = S.getMiddleY() - k0*(M.getMiddleX()*sin(angle) + M.getMiddleY()*cos(angle));
bool compatible = checkCompatibility(M, S, tresholdAngle, tresholdLength, k0, A, r);
if (!compatible) return false;
paramVector v0(k0, angle, tx0, ty0);
hypothesis.setV(v0);
hypothesis.setMseg(M);
hypothesis.setSseg(S);
hypothesis.setAngleComp(A);
hypothesis.setLengthComp(r);
ublas::matrix<double> matrixS = ublas::identity_matrix<double> (4);
matrixS(0,0) = k0*k0*sin(angle)*sin(angle)*sa*sa + cos(angle)*cos(angle)*sk*sk;
matrixS(1,1) = k0*k0*cos(angle)*cos(angle)*sa*sa + sin(angle)*sin(angle)*sk*sk;
matrixS(0,1) = matrixS(1,0) = sin(angle)*cos(angle)*(sk*sk - k0*k0*sa*sa);
matrixS(2,2) = sx*sx;
matrixS(3,3) = sy*sy;
hypothesis.setMatrixS(matrixS);
return true;
}
bool hypothesisCmp( Hypothesis &a, Hypothesis &b ){
// TODO: Eksperimentirati
return (a.getAngleComp()+a.getLengthComp() < b.getAngleComp()+b.getLengthComp());
}
vector<Hypothesis> getBestHyp(int numOfHyp, vector<Hypothesis> &hyps){
vector<Hypothesis> bestHyps;
sort( hyps.begin(), hyps.end(), hypothesisCmp );
if (hyps.size()< numOfHyp)
{
numOfHyp = hyps.size();
}
for (int i = 0; i <numOfHyp; i++) {
bestHyps.push_back(hyps[i]);
}
//bestHyps = hyps;
return bestHyps;
} | [
"[email protected]@6100b896-52a2-3748-62e0-4fb15095d2ea",
"[email protected]@6100b896-52a2-3748-62e0-4fb15095d2ea",
"ivan.kristo@6100b896-52a2-3748-62e0-4fb15095d2ea"
]
| [
[
[
1,
5
],
[
7,
8
],
[
11,
12
],
[
18,
19
],
[
29,
29
],
[
55,
59
],
[
61,
65
],
[
67,
78
],
[
86,
86
],
[
92,
97
],
[
104,
105
],
[
107,
109
],
[
111,
119
],
[
128,
132
],
[
135,
136
],
[
138,
150
],
[
152,
154
]
],
[
[
6,
6
],
[
9,
9
],
[
13,
17
],
[
20,
28
],
[
30,
54
],
[
60,
60
],
[
85,
85
],
[
89,
90
],
[
99,
100
],
[
120,
127
],
[
137,
137
],
[
151,
151
]
],
[
[
10,
10
],
[
66,
66
],
[
79,
84
],
[
87,
88
],
[
91,
91
],
[
98,
98
],
[
101,
103
],
[
106,
106
],
[
110,
110
],
[
133,
134
]
]
]
|
662a397ae220bfc0ca786837d3030506475d69af | 14a00dfaf0619eb57f1f04bb784edd3126e10658 | /lab4/GUI.h | e9c91babd6b44a2556afa9e310bc0f8eb3303c24 | []
| no_license | SHINOTECH/modanimation | 89f842262b1f552f1044d4aafb3d5a2ce4b587bd | 43d0fde55cf75df9d9a28a7681eddeb77460f97c | refs/heads/master | 2021-01-21T09:34:18.032922 | 2010-04-07T12:23:13 | 2010-04-07T12:23:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,439 | h | /*************************************************************************************************
*
* Modeling and animation (TNM079) 2007
* Code base for lab assignments. Copyright:
* Gunnar Johansson ([email protected])
* Ken Museth ([email protected])
* Michael Bang Nielsen ([email protected])
* Ola Nilsson ([email protected])
* Andreas Sderstrm ([email protected])
*
*************************************************************************************************/
#ifndef __GUI_H__
#define __GUI_H__
#include <vector>
#include <string>
#include "Vector3.h"
#include "Geometry.h"
#include "SimpleMesh.h"
#include "HalfEdgeMesh.h"
#include "SimpleDecimationMesh.h"
#include "QuadricDecimationMesh.h"
#include "CSG.h"
#include "Sphere.h"
#include "Cyclide.h"
#include "Quadric.h"
#include "LevelSet.h"
#include "ScalarCutPlane.h"
#include "VectorCutPlane.h"
#include "ObjIO.h"
#include "SphereFractal.h"
#include "GLMenu.h"
#include "Stopwatch.h"
#include "Util.h"
#include "Camera.h"
#ifdef __APPLE__
#include "GLUT/glut.h"
#else
#include "GL/glut.h"
#endif
class GUI
{
typedef float Real;
typedef short Index;
public:
GUI();
~GUI();
void init();
void update();
void displayFunc();
void winReshapeFunc(GLint newWidth, GLint newHeight);
void mouseFunc(GLint button, GLint action, GLint mouseX, GLint mouseY);
void mouseActiveMotionFunc(GLint mouseX, GLint mouseY);
void mousePassiveMotionFunc(GLint mouseX, GLint mouseY);
void keyboardUpFunc(unsigned char keycode, GLint mouseX, GLint mouseY);
void keyboardFunc(unsigned char keycode, GLint mouseX, GLint mouseY);
void specialFunc(GLint keycode, GLint mouseX, GLint mouseY);
void idleFunc();
static void drawText(const Vector3<float> & pos, const char * str);
private:
void getMouseScreenCoordinates(int mouseX, int mouseY, Real &x, Real &y);
void drawXZplane(int nrOfGridCells, Real width, int subGridLines);
void drawCube(Real angle);
void drawFPS(float fps);
// GUI parameters
unsigned int mWindowHeight;
unsigned int mWindowWidth;
int mMousePos[2];
int mOldMousePos[2];
GLMenu mMenu;
bool mShowMenu;
// Observer position and motion
Camera mCam;
// used to restore window after full-screen mode
int mOldWindowHeight;
int mOldWindowWidth;
// Clocks and time
Real mFrameTimestamp; // timestamp for last draw.. (seconds)
Stopwatch mClockArray[256]; // 256 clocks..
#define GLOBAL_CLOCK 0 // starts running at startup..
#define ANIMATION_CLOCK 1 // Used for camera movement
#define STOPWATCH 255
// Misc variables
bool mDrawXZPlane;
unsigned int mFramecounter;
float mTimeSinceLastFPS;
float mCurrentFPS;
// Geometry list
struct Object {
Object(const std::string & name, Geometry * geometry, int order = 0) {
this->name = name;
this->geometry = geometry;
this->order = order;
}
std::string name;
Geometry * geometry;
int order;
friend bool operator < (const Object & o1, const Object & o2) {
return o1.order < o2.order;
}
};
std::vector<Object> mGeometryList;
void addGeometry(const std::string & name, Geometry * geometry, int order = 0);
template <class T> T * getGeometry(const std::string & name);
};
#endif
| [
"onnepoika@da195381-492e-0410-b4d9-ef7979db4686",
"jpjorge@da195381-492e-0410-b4d9-ef7979db4686"
]
| [
[
[
1,
33
],
[
35,
83
],
[
87,
135
]
],
[
[
34,
34
],
[
84,
86
]
]
]
|
17e31cec2a61f3f2135685e3a74d4f317e9b2bb1 | 45229380094a0c2b603616e7505cbdc4d89dfaee | /ga/gaul-devel-0.1850-0/ess_01/Form1.h | 4378f0fa53b9ff1c15051896f8b819fd24cf5c98 | []
| no_license | xcud/msrds | a71000cc096723272e5ada7229426dee5100406c | 04764859c88f5c36a757dbffc105309a27cd9c4d | refs/heads/master | 2021-01-10T01:19:35.834296 | 2011-11-04T09:26:01 | 2011-11-04T09:26:01 | 45,697,313 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 5,437 | h | #pragma once
#pragma unmanaged
#include "essworld.h"
#pragma managed
namespace ess_01 {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Collections::Generic;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Summary for Form1
///
/// WARNING: If you change the name of this class, you will need to change the
/// 'Resource File Name' property for the managed resource compiler tool
/// associated with all .resx files this class depends on. Otherwise,
/// the designers will not be able to interact properly with localized
/// resources associated with this form.
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::PictureBox^ pictureBox1;
private: System::Windows::Forms::Timer^ timer1;
private: System::Windows::Forms::Button^ button1;
private: System::ComponentModel::IContainer^ components;
protected:
private:
/// <summary>
/// Required designer variable.
/// </summary>
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->components = (gcnew System::ComponentModel::Container());
this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));
this->button1 = (gcnew System::Windows::Forms::Button());
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->pictureBox1))->BeginInit();
this->SuspendLayout();
//
// pictureBox1
//
this->pictureBox1->Location = System::Drawing::Point(212, 32);
this->pictureBox1->Name = L"pictureBox1";
this->pictureBox1->Size = System::Drawing::Size(434, 301);
this->pictureBox1->TabIndex = 0;
this->pictureBox1->TabStop = false;
//
// timer1
//
this->timer1->Tick += gcnew System::EventHandler(this, &Form1::timer1_Tick);
//
// button1
//
this->button1->Location = System::Drawing::Point(582, 403);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(75, 23);
this->button1->TabIndex = 1;
this->button1->Text = L"start";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(7, 12);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(796, 522);
this->Controls->Add(this->button1);
this->Controls->Add(this->pictureBox1);
this->Name = L"Form1";
this->Text = L"Form1";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->pictureBox1))->EndInit();
this->ResumeLayout(false);
}
#pragma endregion
essWorld * pWorld;
population * pop;
Graphics ^_g;
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
pop = new population();
pWorld = new essWorld();
pop->Init(pWorld);
//this->timer1->Start();
_g = this->pictureBox1->CreateGraphics();
_BlackList = gcnew System::Collections::Generic::Queue<int>();
_BlueList = gcnew System::Collections::Generic::Queue<int>();
}
//cli::array<Point^,
System::Collections::Generic::Queue<int> ^ _BlackList ;//= gcnew List<Point>();
System::Collections::Generic::Queue<int> ^ _BlueList ;//= gcnew List<Point>();
void AddValue(int black,int blue)
{
_BlackList->Enqueue(black);
if( _BlackList->Count == 50)
_BlackList->Dequeue();
_BlueList->Enqueue(blue);
if( _BlueList->Count == 50)
_BlueList->Dequeue();
}
private: System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e) {
pop->evaluate();
AddValue(pWorld->_blackCount,pWorld->_blueCount);
pWorld->_blackCount = 0;
pWorld->_blueCount = 0;
_g->Clear(Color::White);
cli::array<int> ^ black = _BlackList->ToArray();
for(int i = 1 ; i < black->Length;i++)
{
_g->DrawLine(gcnew Pen(Color::Red),(i-1)*3,300-black[i-1]*3,i*3,300-black[i]*3);
}
cli::array<int> ^ blue = _BlueList->ToArray();
for(int i = 1 ; i < blue->Length;i++)
{
_g->DrawLine(gcnew Pen(Color::Black),(i-1)*3,300-blue[i-1]*3,i*3,300-blue[i]*3);
}
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
if( this->button1->Text == "start")
{
this->timer1->Start();
this->button1->Text = "stop";
}else
{
this->button1->Text = "start";
this->timer1->Stop();
}
}
};
}
| [
"[email protected]",
"perpet99@cc61708c-8d4c-0410-8fce-b5b73d66a671"
]
| [
[
[
1,
12
],
[
14,
50
],
[
52,
70
],
[
72,
76
],
[
78,
78
],
[
80,
86
],
[
97,
98
],
[
100,
100
],
[
103,
113
],
[
115,
118
],
[
120,
120
],
[
124,
124
],
[
141,
141
],
[
143,
144
],
[
178,
179
],
[
181,
182
]
],
[
[
13,
13
],
[
51,
51
],
[
71,
71
],
[
77,
77
],
[
79,
79
],
[
87,
96
],
[
99,
99
],
[
101,
102
],
[
114,
114
],
[
119,
119
],
[
121,
123
],
[
125,
140
],
[
142,
142
],
[
145,
177
],
[
180,
180
]
]
]
|
c9675cb37142deee1177c359e4b822d560615d2e | a7985fd90271731c73cab45029ee9a9903c8e1a2 | /client/westley.hennigh_cs260/westley.hennigh_cs260/Jobs.cpp | ace33b50f13ebcc4de829ccb393ccc65e9f2c7c1 | []
| no_license | WestleyArgentum/cs260-networking | 129039f7ad2a89b9350ddcac0cc50a17c6f74bf7 | 36d2d34400ad93906e2b4839278e4b33de28ae8b | refs/heads/master | 2021-01-01T05:47:12.910324 | 2010-04-07T07:01:40 | 2010-04-07T07:01:40 | 32,187,121 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,271 | cpp | #include "Jobs.h"
sendJob::sendJob(std::string filename, unsigned filesize, unsigned loPort_, std::string remoteuser, std::string IP_ /*= std::string()*/, unsigned rePort_ /*= 0*/ )
:data(filename, filesize), sSock(NULL), loPort(loPort_), IP(IP_), rePort(rePort_), currChunk(0), remote_user(remoteuser)
{
// set up the data object
data.SplitFile();
}
bool sendJob::update()
{
// construct a message from a chunk of data
FileDataMsg message;
message.data = data.GetChunk(currChunk);
message.chunknum = currChunk;
++currChunk;
// send that message across
if(sSock->Send(&message) == -1)
{
MessageBox(NULL, "I have timed out while waiting for an ack.\nMaybe they left?", "TIMED OUT !!!", MB_OK | MB_ICONHAND);
done = true; // they left... what to do?
}
Sleep(1); // we dont keep a page size so this makes things cleaner
if(currChunk == data.GetSize())
done = true;
return done;
}
void sendJob::SetSocket(SuperSocket* sSock_)
{
sSock = sSock_;
}
sendJob::~sendJob()
{}
std::string sendJob::GetRemoteUser()
{
return remote_user;
}
void sendJob::SetRemoteInfo( std::string IP_, unsigned rePort_ )
{
IP = IP_;
rePort = rePort_;
}
void sendJob::start()
{
// set up our session with the socket
static_cast<ReliableUdpSocet*>(sSock)->Connect(loPort, IP, rePort);
}
void sendJob::end()
{
// terminate
static_cast<ReliableUdpSocet*>(sSock)->Disconnect();
}
recJob::recJob(std::string filename, unsigned loPort_, std::string IP_, unsigned rePort_, unsigned filesize)
:data(filename, filesize), sSock(NULL), loPort(loPort_), IP(IP_), rePort(rePort_), ack(0)
{
}
bool recJob::update()
{
// if it has been more than 25 sec since we got a message they are probably gone...
if(GetTickCount() > timeout + 15000)
{
MessageBox(NULL, "I have timed out while waiting for a packet.", "TIMED OUT !!!", MB_OK | MB_ICONHAND);
done = true;
}
IMessage* mess;
mess = sSock->Recv();
unsigned stuff = data.GetSize();
if(mess)
{
// reset the timeout
timeout = GetTickCount();
if (mess->my_type != FileData_Msg)
{
return false; // something has gone wrong
}
FileDataMsg* fmsg = static_cast<FileDataMsg*>(mess);
// if the packet is new (and therefore relevant)
if(fmsg->chunknum == ack)
{
data.SetChunk(static_cast<FileDataMsg*>(mess)->data, fmsg->chunknum);
char char_percent[32];
float float_percent = ((float)data.GetChunkSize()/(float)data.GetSize())*100.0f;
sprintf(char_percent, "%f Percent", float_percent);
SendMessage(SillyWindow::GetWindow()->progress, WM_SETTEXT, 0, (LPARAM)(char_percent));
// finished check
if(fmsg->chunknum >= data.GetSize()-1)
done = true;
++ack;
}
delete(mess);
}
return done;
}
void recJob::SetSocket(SuperSocket* sSock_)
{
sSock = sSock_;
}
recJob::~recJob()
{}
void recJob::start()
{
// set up our session with the socket
static_cast<ReliableUdpSocet*>(sSock)->Connect(loPort, IP, rePort);
timeout = GetTickCount();
}
void recJob::end()
{
// terminate
static_cast<ReliableUdpSocet*>(sSock)->Disconnect();
// unite!
data.JoinFiles();
}
| [
"knuxjr@1f2afcba-5144-80f4-e828-afee2f9acc6f",
"[email protected]@1f2afcba-5144-80f4-e828-afee2f9acc6f",
"westleyargentum@1f2afcba-5144-80f4-e828-afee2f9acc6f"
]
| [
[
[
1,
1
],
[
3,
5
],
[
8,
8
],
[
11,
12
],
[
15,
16
],
[
27,
35
],
[
62,
63
],
[
65,
66
],
[
77,
78
],
[
80,
81
],
[
95,
95
],
[
98,
101
],
[
107,
110
],
[
113,
118
],
[
137,
137
]
],
[
[
2,
2
],
[
9,
10
],
[
13,
14
],
[
17,
18
],
[
26,
26
],
[
36,
52
],
[
55,
57
],
[
64,
64
],
[
68,
68
],
[
79,
79
],
[
82,
83
],
[
87,
87
],
[
89,
89
],
[
91,
94
],
[
96,
97
],
[
102,
106
],
[
111,
112
],
[
119,
123
],
[
130,
132
],
[
138,
138
]
],
[
[
6,
7
],
[
19,
25
],
[
53,
54
],
[
58,
61
],
[
67,
67
],
[
69,
76
],
[
84,
86
],
[
88,
88
],
[
90,
90
],
[
124,
129
],
[
133,
136
]
]
]
|
bfb3bea20983938429ad47a1de5cec52f33683dd | fac8de123987842827a68da1b580f1361926ab67 | /inc/physics/Common/Base/System/Io/Writer/SubStream/hkSubStreamWriter.h | ab11527e91e0bcc44e1362768a155c0ceab1cb61 | []
| no_license | blockspacer/transporter-game | 23496e1651b3c19f6727712a5652f8e49c45c076 | 083ae2ee48fcab2c7d8a68670a71be4d09954428 | refs/heads/master | 2021-05-31T04:06:07.101459 | 2009-02-19T20:59:59 | 2009-02-19T20:59:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,874 | h | /*
*
* Confidential Information of Telekinesys Research Limited (t/a Havok). Not for disclosure or distribution without Havok's
* prior written consent.This software contains code, techniques and know-how which is confidential and proprietary to Havok.
* Level 2 and Level 3 source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2008 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement.
*
*/
#ifndef HKBASE_SUB_STREAMWRITER_H
#define HKBASE_SUB_STREAMWRITER_H
#include <Common/Base/System/Io/Writer/hkStreamWriter.h>
/// Writer which is a "window" into another stream.
/// Write requests are simply forwarded. Seek/tell
/// requests are offset before forwarding so that the
/// start (tell() == 0) of the substream is at a
/// specified offset in the child stream.
class hkSubStreamWriter : public hkStreamWriter
{
public:
/// Substream starts at the childs current offset.
hkSubStreamWriter( hkStreamWriter* child )
: m_childStream( child )
{
HK_ASSERT( 0xaa36a77f, child );
m_startOffset = m_childStream->tell();
}
/// The zero offset is at the specified offset into child.
hkSubStreamWriter( hkStreamWriter* child, int offset )
: m_childStream( child ), m_startOffset(offset)
{
HK_ASSERT( 0xaa36a77f, child );
}
virtual hkBool isOk() const
{
return m_childStream->isOk();
}
virtual int write(const void* buf, int nbytes)
{
return m_childStream->write( buf, nbytes );
}
virtual void flush()
{
m_childStream->flush();
}
virtual hkBool seekTellSupported() const
{
return m_childStream->seekTellSupported();
}
virtual hkResult seek(int offset, hkStreamWriter::SeekWhence whence)
{
int realOffset = ( whence == STREAM_SET )
? m_startOffset + offset
: offset;
return m_childStream->seek( realOffset, whence );
}
virtual int tell() const
{
return m_childStream->tell() - m_startOffset;
}
protected:
hkStreamWriter* m_childStream;
int m_startOffset;
};
#endif // HKBASE_OFFSET_STREAMWRITER_H
/*
* Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20080529)
*
* Confidential Information of Havok. (C) Copyright 1999-2008
* Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok
* Logo, and the Havok buzzsaw logo are trademarks of Havok. Title, ownership
* rights, and intellectual property rights in the Havok software remain in
* Havok and/or its suppliers.
*
* Use of this software for evaluation purposes is subject to and indicates
* acceptance of the End User licence Agreement for this product. A copy of
* the license is included with this software and is also available at
* www.havok.com/tryhavok
*
*/
| [
"uraymeiviar@bb790a93-564d-0410-8b31-212e73dc95e4"
]
| [
[
[
1,
94
]
]
]
|
1e92487d773f3d3375b0539a80cb97d5e941550d | 1cc5720e245ca0d8083b0f12806a5c8b13b5cf98 | /v106/p1/c.cpp | 8dcef0819b89c7fb6c91a8276ec646699a75462a | []
| no_license | Emerson21/uva-problems | 399d82d93b563e3018921eaff12ca545415fd782 | 3079bdd1cd17087cf54b08c60e2d52dbd0118556 | refs/heads/master | 2021-01-18T09:12:23.069387 | 2010-12-15T00:38:34 | 2010-12-15T00:38:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,532 | cpp | #include <iostream>
#include <string.h>
using namespace std;
int c,l;
int cid[101][101];
int fila[200];
int fs,fe;
int vis[200];
#define empilha(az,t) fila[fe++] = az; vis[az] = t;
#define des() (fila[fs++])
bool start() {
memset(fila,-1,sizeof(fila));
memset(vis,-1,sizeof(vis));
fe = fs = 0;
int s;
int e,d;
cin >> s >> e >> d;
//cout << s << " " << e << " " << d << endl;
s--;e--;
empilha(s, 0);
/* if(s==e && d==0) return true;
if(cid[s][e]==1 && d==1) return true;
if(d==1) return false;*/
int prox;
while(fs!=fe) {
// cout << fe << "," << fs << "," << fila[fs] << endl;
prox = des();
//cout << "visitando " << prox << " em " << vis[prox] << endl;
if(prox==e) {
if(vis[e]==d) {
return true;
} else {
// return false;
}
}
if(vis[prox]==d) {
continue;
}
for(int i=0;i!=c;i++) {
if(cid[prox][i]!=0) {
empilha(i,vis[prox]+1);
}
}
}
return false;
}
void read() {
memset(cid,0,sizeof(cid));
for(int i=0;i!=l;i++) {
int a,b;
cin >> a >> b;
cid[a-1][b-1] = 1;
cid[b-1][a-1] = 1;
//cout << "con " << (a-1) << " e " << (b-1) << endl;
}
/* for(int i=0;i!=c;i++) {
for(int j=0;j!=c;j++) {
cout << cid[i][j] << " ";
}
cout << endl;
}*/
}
int main() {
while(true){
cin >> c >> l;
if(c==0 && l==0) break;
read();
if(start()) {
cout << "Yes, Teobaldo can travel." << endl;
} else {
cout << "No, Teobaldo can not travel." << endl;
}
}
return 0;
}
| [
"[email protected]"
]
| [
[
[
1,
84
]
]
]
|
cc34902a049eab625fc97b7871fb5651b624a5e5 | d60e8cf5de9384449a9b6a643bfe4c1d2339b1ae | /windows/src/nxt++.cpp | d9ddcc07b96d566fb54181dfdecfa4f854ceff91 | []
| no_license | tizar/lego | 165ec2ac333bed642d96a33db77ab7d00ffbfba9 | 351c8824b3457f4735cf65ec4740d1c9fc89dd21 | refs/heads/master | 2016-09-08T05:06:23.607494 | 2011-03-03T10:46:31 | 2011-03-03T10:46:31 | 1,434,570 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 21,885 | cpp | #include "NXT++.h"
using namespace NXT;
using namespace NXT::File;
using namespace NXT::Module;
using namespace NXT::Motor;
using namespace NXT::Sensor;
using namespace NXT::NxtCam;
bool NXT::Open(Comm::NXTComm* comm)
{
return comm->Open();
}
bool NXT::OpenBT(Comm::NXTComm* comm)
{
return comm->OpenBT();
}
void NXT::Close(Comm::NXTComm* comm)
{
comm->Close();
}
void NXT::PlayTone(Comm::NXTComm* comm, int frequency, int duration)
{
// This is a direct command to play a tone.
ViUInt8 directCommandBuffer[] = { 0x03, frequency%256, (frequency-(frequency%256))/256, duration%256, (duration-(duration%256))/256 };
// Send the direct command to the NXT.
comm->SendDirectCommand( false /* a response is not required for this direct command */,
reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ),
NULL /* no response buffer */, 0 /* no response buffer, specify 0 for size */);
}
int NXT::BatteryLevel(Comm::NXTComm* comm)
{
ViUInt8 directCommandBuffer[] = { 0x0B };
ViUInt8 responseBuffer[] = { 0x01, 0x01, 0x01, 0x01 };
// Send the direct command to the NXT.
comm->SendDirectCommand( true, reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ),
reinterpret_cast< ViByte* >( responseBuffer ), sizeof( responseBuffer ));
return responseBuffer[3]*256+responseBuffer[2];
}
double NXT::GetAvailableFlash(Comm::NXTComm* comm)
{
return comm->GetAvailableFlash();
}
void NXT::StopProgram(Comm::NXTComm* comm)
{
ViUInt8 directCommandBuffer[] = { 0x01 };
comm->SendDirectCommand( false, reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ), NULL, 0);
}
double NXT::GetProtocolVersion(Comm::NXTComm* comm)
{
return comm->GetProtocolVersion();
}
double NXT::GetFirmwareVersion(Comm::NXTComm* comm)
{
return comm->GetFirmwareVersion();
}
void NXT::StartProgram(Comm::NXTComm* comm, std::string name)
{
char fname[20];
strcpy(fname, name.c_str());
ViUInt8 directCommandBuffer[21];
directCommandBuffer[0] = 0x00;
for(int i = 0; i < 20; i++)
directCommandBuffer[i+1] = fname[i];
comm->SendDirectCommand( false, reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ), NULL, 0);
}
void NXT::PlaySoundFile(Comm::NXTComm* comm, std::string name, bool loop)
{
char fname[20];
strcpy(fname, name.c_str());
ViUInt8 directCommandBuffer[21];
directCommandBuffer[0] = 0x02;
directCommandBuffer[1] = loop;
for(int i = 0; i < 20; i++)
directCommandBuffer[i+2] = fname[i];
comm->SendDirectCommand( false, reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ), NULL, 0);
}
void NXT::StopSound(Comm::NXTComm* comm)
{
ViUInt8 directCommandBuffer[] = { 0x0C };
comm->SendDirectCommand( false, reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ), NULL, 0);
}
void NXT::SendDirectCommand(Comm::NXTComm* comm, ViBoolean response, ViByte * dc_buf, int dc_buf_size, ViByte *re_buf, int re_buf_size)
{
comm->SendDirectCommand(response, dc_buf, dc_buf_size, re_buf, re_buf_size);
}
void NXT::KeepAlive(Comm::NXTComm* comm)
{
ViUInt8 directCommandBuffer[] = { 0x0D };
comm->SendDirectCommand( false, reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ), NULL, 0);
}
//
int NXT::Motor::GetRotationCount(Comm::NXTComm* comm, int port)
{
ViUInt8 directCommandBuffer[] = { 0x06, port };
ViInt8 responseBuffer[] = { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 };
// Send the direct command to the NXT.
comm->SendDirectCommand( true, reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ),
reinterpret_cast< ViByte* >( responseBuffer ), sizeof( responseBuffer ));
int i = responseBuffer[20];
if(i < 0)
i = 256 + i;
if(responseBuffer[22] == -1)
responseBuffer[22] = 0;
if(responseBuffer[23] == -1)
responseBuffer[23] = 0;
int tacho = responseBuffer[23]*16777216+responseBuffer[22]*65536+responseBuffer[21]*256+i;
return tacho;
}
void NXT::Motor::ResetRotationCount(Comm::NXTComm* comm, int port, bool relative)
{
ViUInt8 directCommandBuffer[] = { 0x0A, port, relative };
comm->SendDirectCommand( false, reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ), NULL, 0);
}
void NXT::Motor::SetForward(Comm::NXTComm* comm, int port, int power)
{
ViUInt8 directCommandBuffer[] = { 0x04, port, power, 0x01 | 0x04, 0x01, 0, 0x20, 0, 0, 0, 0 };
comm->SendDirectCommand( false, reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ), NULL, 0);
}
void NXT::Motor::SetReverse(Comm::NXTComm* comm, int port, int power)
{
ViUInt8 directCommandBuffer[] = { 0x04, port, -power, 0x01 | 0x04, 0x01, 0, 0x20, 0, 0, 0, 0 };
comm->SendDirectCommand( false, reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ), NULL, 0);
}
void NXT::Motor::Stop(Comm::NXTComm* comm, int port, bool brake)
{
if(brake)
{
ViUInt8 directCommandBuffer[] = { 0x04, port, 0, 0x01 | 0x02 | 0x04, 0x01, 0, 0x20, 0, 0, 0, 0 };
comm->SendDirectCommand( false, reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ), NULL, 0);
}
else
{
ViUInt8 directCommandBuffer[] = { 0x04, port, 0, 0x00, 0x00, 0, 0x00, 0, 0, 0, 0};
comm->SendDirectCommand( false, reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ), NULL, 0);
}
}
void NXT::Motor::BrakeOn(Comm::NXTComm* comm, int port)
{
ViUInt8 directCommandBuffer[] = { 0x04, port, 0, 0x01 | 0x02 | 0x04, 0x01, 0, 0x20, 0, 0, 0, 0 };
comm->SendDirectCommand( false, reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ), NULL, 0);
}
void NXT::Motor::BrakeOff(Comm::NXTComm* comm, int port)
{
ViUInt8 directCommandBuffer[] = { 0x04, port, 0, 0x00, 0x00, 0, 0x00, 0, 0, 0, 0};
comm->SendDirectCommand( false, reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ), NULL, 0);
}
void NXT::Motor::GoTo(Comm::NXTComm* comm, int port, int power, int tacho, bool brake)
{
if(tacho >= GetRotationCount(comm, port))
{
SetForward(comm, port, power);
while(GetRotationCount(comm, port) < tacho) {}
Stop(comm, port, brake);
}
else
{
SetReverse(comm, port, power);
while(GetRotationCount(comm, port) > tacho) {}
Stop(comm, port, brake);
}
}
void NXT::Sensor::SetTouch(Comm::NXTComm* comm, int port)
{
ViUInt8 directCommandBuffer[] = { 0x05, port, 0x01, 0x20 };
comm->SendDirectCommand( false, reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ), NULL, 0);
}
void NXT::Sensor::SetSound(Comm::NXTComm* comm, int port)
{
ViUInt8 directCommandBuffer[] = { 0x05, port, 0x07, 0x80 };
comm->SendDirectCommand( false, reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ), NULL, 0);
}
void NXT::Sensor::SetLight(Comm::NXTComm* comm, int port, bool active)
{
if(active)
{
ViUInt8 directCommandBuffer[] = { 0x05, port, 0x05, 0x80 };
comm->SendDirectCommand( false, reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ), NULL, 0);
}
else
{
ViUInt8 directCommandBuffer[] = { 0x05, port, 0x06, 0x80 };
comm->SendDirectCommand( false, reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ), NULL, 0);
}
}
void NXT::Sensor::SetSonar(Comm::NXTComm* comm, int port)
{
ViUInt8 directCommandBuffer[] = { 0x05, port, 0x0B, 0x00 };
comm->SendDirectCommand( false, reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ), NULL, 0);
}
void NXT::Sensor::SetCmpsNx(Comm::NXTComm* comm, int port)
{
ViUInt8 directCommandBuffer[] = { 0x05, port, 0x0B, 0x00 };
comm->SendDirectCommand( false, reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ), NULL, 0);
}
void NXT::Sensor::SetDistNx(Comm::NXTComm* comm, int port)
{
ViUInt8 directCommandBuffer[] = { 0x05, port, 0x0B, 0x00 };
comm->SendDirectCommand( false, reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ), NULL, 0);
ViUInt8 directCommandBuffer2[] = { 0x02, 0x41, 0x34 };
writeI2C(comm, port, directCommandBuffer2, 2, 3);
ViUInt8 directCommandBuffer3[] = { 0x02, 0x41, 0x45 };
writeI2C(comm, port, directCommandBuffer3, 2, 3);
}
void NXT::Sensor::SetRaw(Comm::NXTComm* comm, int port)
{
ViUInt8 directCommandBuffer[] = { 0x05, port, 0x07, 0x00 };
comm->SendDirectCommand( false, reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ), NULL, 0);
}
void NXT::Sensor::Set(Comm::NXTComm* comm, int port, SensorType type)
{
int msgtype, mode;
switch (type)
{
case Touch:
msgtype = 0x01;
mode = 0x20;
break;
case Sound:
msgtype = 0x07;
mode = 0x80;
break;
case Light:
msgtype = 0x06;
mode = 0x80;
break;
case ActiveLight:
msgtype = 0x05;
mode = 0x80;
break;
case Sonar:
msgtype = 0x0B;
mode = 0x00;
break;
}
ViUInt8 directCommandBuffer[] = { 0x05, port, msgtype, mode };
comm->SendDirectCommand( false, reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ), NULL, 0);
}
int NXT::Sensor::GetValue(Comm::NXTComm* comm, int port)
{
ViUInt8 directCommandBuffer[] = { 0x07, port };
ViUInt8 responseBuffer[] = { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 };
comm->SendDirectCommand( true, reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ),
reinterpret_cast< ViByte* >( responseBuffer ), sizeof( responseBuffer ));
return responseBuffer[12]*256+responseBuffer[11];
}
int NXT::Sensor::GetCmpsNxValue(Comm::NXTComm* comm, int port)
{
return GetAvgCmpsNxValue(comm, port, 1, 0);
}
int NXT::Sensor::GetAvgCmpsNxValue(Comm::NXTComm* comm, int port, int numValues, int waitTime)
{
int returnValue = 0;
ViUInt8 Heading = 0;
// This sets the compass into the 0-255 range (within 1.4 degrees, maps to 0-360).
// There is a mode for 0-3600 (within 0.1) but I find it pretty useless, since even in
// the 0-255 range the compass will bounce back and forth between 2-3 degrees so more precision
// gains you nothing
ViUInt8 command[] = { 0x02, 0x41, 0x42};
ViUInt8 command2[] = {0x02, 0x42};
ViUInt8 *response;
double doubleValue = 0.0;
// the compass will oscillate over a 2-3 degree range, so get a few values and average them
// Change the number of values and wait time below for your application
for (int i=0;i<numValues;i++) {
writeI2C(comm, port, command, 2, 3);
int bytesRead = 0;
do {
writeI2C(comm, port, command2, 2, 2);
bytesRead = LSGetStatus(comm, port);
} while (bytesRead < 1);
response = readI2C(comm, port);
Heading = response[4];
doubleValue += ((int)Heading * 1.41);
Wait(waitTime);
}
return (int)(doubleValue/numValues);
}
int NXT::Sensor::GetCleanDistNxValue(Comm::NXTComm* comm, int port)
{
const int numValues = 10;
int total = 0;
int avg = 0;
int values[numValues];
int absPointTotal = 0, pointTotal = 0;
int volatilityRatioThreshold = 1;
int volatilityThreshold = 45;
int volatilityRatio;
int minValue = 0, maxValue = 0;
for (int i=0;i < numValues; i++) {
values[i] = GetDistNxValue(comm, port);
if (minValue == 0) {
minValue = values[i];
maxValue = values[i];
}
if (values[i] < minValue) {
minValue = values[i];
}
if (values[i] > maxValue) {
maxValue = values[i];
}
total += values[i];
printf("value: %d\n",values[i]);
// if (i > 0) {
//
// absPointTotal += abs(values[i - 1] - values[i]);
// pointTotal += (values[i - 1] - values[i]);
// }
}
avg = total/numValues;
// if (pointTotal == 0) {
// return 0;
// }
// volatilityRatio = absPointTotal/abs(pointTotal);
if (((maxValue - minValue) > volatilityThreshold) || avg < 200)
return 0;
else
return avg;
}
int NXT::Sensor::GetDistNxValue(Comm::NXTComm* comm, int port)
{
ViUInt8 command[] = { 0x02, 0x42 };
ViUInt8 *responseBuffer;
int bytesRead = 0;
do {
writeI2C(comm, port, command, 2, 2);
bytesRead = LSGetStatus(comm, port);
} while (bytesRead < 1);
responseBuffer = readI2C(comm, port);
if (responseBuffer[2] == 2)
return (int)responseBuffer[4]*256 + (int)responseBuffer[3];
else
return (int)responseBuffer[3];
}
int NXT::Sensor::LSGetStatus(Comm::NXTComm* comm, int port)
{
ViUInt8 directCommandBuffer[] = {0x0E, port};
ViUInt8 responseBuffer[] = {1,1,1};
comm->SendDirectCommand( true, reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer),
reinterpret_cast< ViByte* >( responseBuffer ), sizeof( responseBuffer ));
return (int)responseBuffer[2];
}
int NXT::Sensor::GetSonarValue(Comm::NXTComm* comm, int port)
{
ViUInt8 directCommandBuffer[] = {0x0F, port, 0x03, 0x00, 0x02, 0x41, 0x02};
ViUInt8 responseBuffer[] = { 1,1};
comm->SendDirectCommand( true, reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ),
reinterpret_cast< ViByte* >( responseBuffer ), sizeof( responseBuffer ));
int bytesRead = 0;
do {
ViUInt8 directCommandBuffer[] = {0x0F, port, 0x02, 0x01, 0x02, 0x42};
ViUInt8 responseBuffer[] = {1, 1};
comm->SendDirectCommand( true, reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ),
reinterpret_cast< ViByte* >( responseBuffer ), sizeof( responseBuffer));
bytesRead = LSGetStatus(comm, port);
} while (bytesRead < 1);
ViUInt8 directCommandBuffer2[] = {0x10, port};
ViUInt8 responseBuffer2[] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
comm->SendDirectCommand( true, reinterpret_cast< ViByte* >( directCommandBuffer2 ), sizeof( directCommandBuffer2 ),
reinterpret_cast< ViByte* >( responseBuffer2 ), sizeof( responseBuffer2 ));
return (int)responseBuffer2[3];
}
void NXT::Sensor::SetSonarOff(Comm::NXTComm* comm, int port)
{
ViUInt8 directCommandBuffer[] = {0x0F, port, 0x03, 0x00, 0x02, 0x41, 0x00};
ViUInt8 responseBuffer[] = { 1,1};
comm->SendDirectCommand( true, reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ),
reinterpret_cast< ViByte* >( responseBuffer ), sizeof( responseBuffer ));
}
void NXT::Sensor::SetSonarSingleShot(Comm::NXTComm* comm, int port)
{
ViUInt8 directCommandBuffer[] = {0x0F, port, 0x03, 0x00, 0x02, 0x41, 0x01};
ViUInt8 responseBuffer[] = { 1,1};
comm->SendDirectCommand( true, reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ),
reinterpret_cast< ViByte* >( responseBuffer ), sizeof( responseBuffer ));
}
void NXT::Sensor::SetSonarContinuous(Comm::NXTComm* comm, int port)
{
ViUInt8 directCommandBuffer[] = {0x0F, port, 0x03, 0x00, 0x02, 0x41, 0x02};
ViUInt8 responseBuffer[] = { 1,1};
comm->SendDirectCommand( true, reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ),
reinterpret_cast< ViByte* >( responseBuffer ), sizeof( responseBuffer ));
}
void NXT::Sensor::SetSonarContinuousInterval(Comm::NXTComm* comm, int port, int interval)
{
ViUInt8 directCommandBuffer[] = {0x0F, port, 0x03, 0x00, 0x02, 0x40, interval};
ViUInt8 responseBuffer[] = { 1,1};
comm->SendDirectCommand( true, reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ),
reinterpret_cast< ViByte* >( responseBuffer ), sizeof( responseBuffer ));
}
void NXT::Sensor::writeI2C(Comm::NXTComm* comm, int port, ViUInt8 command[], int replySz, int tx_length)
{
int i=0;
ViUInt8 commandBuffer[24];
ViUInt8 response[] = { 1,1 };
while(i < tx_length){
commandBuffer[i+4]=command[i];
i++;
}
commandBuffer[0]=0x0F;
commandBuffer[1]=port;
commandBuffer[2]=i;
commandBuffer[3]=replySz;
//Comm::SendDirectCommand(true, reinterpret_cast< ViByte* >( commandBuffer ), sizeof( commandBuffer ),
// reinterpret_cast< ViByte* >( response ), 2);
comm->SendDirectCommand(true, reinterpret_cast< ViByte* >( commandBuffer ), 4 + tx_length,
reinterpret_cast< ViByte* >( response ), 2);
}
ViUInt8* NXT::Sensor::readI2C(Comm::NXTComm* comm, int port)
{
ViUInt8 commandBuffer[] = { 0x10, port };
static ViUInt8 response[19] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
comm->SendDirectCommand( true, reinterpret_cast< ViByte* >( commandBuffer ), sizeof( commandBuffer ),
reinterpret_cast< ViByte* >( response ), sizeof( response ));
return response;
}
//! Retrieves a specific NXT file pointer by name.
int NXT::File::getNXTFile(Comm::NXTComm* comm, std::string filename, NXTFile& file)
{
bool isFatal;
file = comm->GetNXTFile(filename, isFatal);
if (! isFatal)
return 0;
return -1;
}
//! Retrieves NXT file pointers by name.
int NXT::File::getNXTFilesByName(Comm::NXTComm* comm, std::string pattern, NXTFileIterator& iter)
{
bool isFatal;
iter = comm->GetFileIterator(pattern, isFatal);
if (!isFatal)
return 0;
//TODO: tStatus error code tranlation
return IteratorFailed;
}
//! Retrieves NXT file pointers by type.
int NXT::File::getNXTFilesByType(Comm::NXTComm* comm, int fileType, NXTFileIterator& iter)
{
switch(fileType)
{
case ANY:
return getNXTFilesByName(comm, "*.*", iter);
break;
case PROGRAM:
return getNXTFilesByName(comm, "*.rxe", iter);
break;
case SOUND:
return getNXTFilesByName(comm, "*.rso", iter);
break;
case GRAPHICS:
return getNXTFilesByName(comm, "*.ric", iter);
break;
case DATALOG:
return getNXTFilesByName(comm, "*.rdt", iter);
break;
default:
return UnsupportedType;
}
return 0;
}
//! Destroys a file iterator.
void NXT::File::destroyFileIterator(Comm::NXTComm* comm, NXTFileIterator &iter)
{
comm->destroyFileIterator(iter);
}
//! Destroys a file pointer
void NXT::File::destroyFile(Comm::NXTComm* comm, NXTFile& file)
{
comm->destroyFile(file);
}
//! Retrieves NXT module pointers by name.
int NXT::Module::getNXTModules(Comm::NXTComm* comm, std::string pattern, NXTModuleIterator &iter)
{
int status = 0;
iter = comm->GetModuleIterator(pattern, status);
return status;
}
//! Retrieves a specific module pointer by name.
int NXT::Module::getNXTModule(Comm::NXTComm* comm, std::string pattern, int moduleID, int moduleSize,
int ioMapSize, int &status, NXTModule &module)
{
status = 0;
module = comm->GetModule(pattern, moduleID, moduleSize, ioMapSize, status);
return status;
}
void NXT::NxtCam::NxtCamFlush(Comm::NXTComm* comm, int port)
{
int bytesRead = 0;
do {
NXT::Sensor::readI2C(comm, port);
bytesRead = NXT::Sensor::LSGetStatus(comm, port);
} while (bytesRead > 0);
}
void NXT::NxtCam::NxtCamCmd(Comm::NXTComm* comm, int port, ViUInt8 command[], int tx_length)
{
int temp1, temp2, temp3, temp4;
temp1 = command[0];
temp2 = command[1];
temp3 = command[2];
temp4 = command[3];
NXT::Sensor::writeI2C(comm, port, command, 0, tx_length);
int temp = sizeof(command)/sizeof(ViUInt8);
// NxtCamFlush(port);
}
void NXT::NxtCam::NxtCamInit(Comm::NXTComm* comm, int port)
{
ViUInt8 directCommandBuffer[] = { 0x05, port, 0x0B, 0x00 };
int temp;
comm->SendDirectCommand( false, reinterpret_cast< ViByte* >( directCommandBuffer ), sizeof( directCommandBuffer ), NULL, 0);
// sort by size
ViUInt8 command1[] = { 0x02, 0x41, 0x41 };
temp = sizeof(command1)/sizeof(ViUInt8);
NXT::Sensor::writeI2C(comm, port, command1, 0, 3);
// NxtCamFlush(port);
//NxtCamCmd(port, command1);
// start blob tracking
ViUInt8 command2[] = { 0x02, 0x41, 0x45 };
NXT::Sensor::writeI2C(comm, port, command2, 0, 3);
// NxtCamFlush(port);
//NxtCamCmd(port, command2);
}
/*
std::vector<std::vector<int>> NXT::NxtCam::GetNxtCamObjects(Comm::NXTComm* comm, int port, int minArea)
{
int numBlobs = GetNxtCamNumObjects(comm, port);
//printf("Num Objects: %d\n",numBlobs);
ViUInt8 *response;
std::vector<std::vector<int>> blobs(8, std::vector<int>(5));
int x1, x2, y1, y2;
int vectorIndex = 0;
NxtCamFlush(comm, port);
for (int i = 0; i < numBlobs; i++) {
int bytesRead = 0;
do {
ViUInt8 command[] = {0x02, 0x43 + i * 5};
NXT::Sensor::writeI2C(comm, port, command, 5, 2);
bytesRead = NXT::Sensor::LSGetStatus(comm, port);
} while (bytesRead < 1);
response = NXT::Sensor::readI2C(comm, port);
x1 = (int)response[4];
y1 = (int)response[5];
x2 = (int)response[6];
y2 = (int)response[7];
if (((y2 - y1) * (x2 - x1)) > minArea) {
blobs[vectorIndex][0] = (int)response[3];
blobs[vectorIndex][1] = (int)response[4];
blobs[vectorIndex][2] = (int)response[5];
blobs[vectorIndex][3] = (int)response[6];
blobs[vectorIndex++][4] = (int)response[7];
}
}
return blobs;
}
*/
int NXT::NxtCam::GetNxtCamNumObjects(Comm::NXTComm* comm, int port)
{
// NxtCamFlush(port);
ViUInt8 *response;
int temp;
int bytesRead = 0;
do {
ViUInt8 command[] = {0x02, 0x42};
NXT::Sensor::writeI2C(comm, port, command, 1, 2);
bytesRead = NXT::Sensor::LSGetStatus(comm, port);
Wait(100);
} while (bytesRead < 1);
response = NXT::Sensor::readI2C(comm, port);
temp = (int)response[0];
temp = (int)response[1];
temp = (int)response[2];
temp = (int)response[3];
temp = (int)response[4];
return (int)response[3];
}
void Wait(int time)
{
int starttime = clock();
while(clock()-starttime <= time) {}
}
| [
"[email protected]"
]
| [
[
[
1,
719
]
]
]
|
5c06b465ac1a251a91ed17cf06449007579aebca | 8a8873b129313b24341e8fa88a49052e09c3fa51 | /src/ImageEngine.cpp | 6602cc039acc92b142c385bcb419bd7008cd26a1 | []
| no_license | flaithbheartaigh/wapbrowser | ba09f7aa981d65df810dba2156a3f153df071dcf | b0d93ce8517916d23104be608548e93740bace4e | refs/heads/master | 2021-01-10T11:29:49.555342 | 2010-03-08T09:36:03 | 2010-03-08T09:36:03 | 50,261,329 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,835 | cpp | /*
============================================================================
Name : ImageEngine.cpp
Author : 浮生若茶
Version :
Copyright : Your copyright notice
Description : CImageEngine implementation
============================================================================
*/
#include "ImageEngine.h"
#include "WapEngine.h"
#include "WapHttpEngine.h"
#include "Widgets.h"
#include "WapBrowserappui.h"
#include "WapBrowserappview.h"
#include "UtilityTools.h"
_LIT(KTempFileName, "C:\\data\\temp.img");
CImageEngine::CImageEngine(CWapEngine& aWapEngine)
: iWapEngine(aWapEngine)
{
}
CImageEngine::~CImageEngine()
{
CancelAllSession();
delete iWapHttpEngine;
}
CImageEngine* CImageEngine::NewLC(CWapEngine& aWapEngine)
{
CImageEngine* self = new (ELeave)CImageEngine(aWapEngine);
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
CImageEngine* CImageEngine::NewL(CWapEngine& aWapEngine)
{
CImageEngine* self=CImageEngine::NewLC(aWapEngine);
CleanupStack::Pop(); // self;
return self;
}
void CImageEngine::ConstructL()
{
}
//////////////////////////////////////////////////////////////////////////
//MWapHttpEngineObserver
//////////////////////////////////////////////////////////////////////////
void CImageEngine::HttpOk(const TDesC8& aData)
{
UtilityTools::WriteLogsL(_L("CImageEngine::HttpOk"));
iIsRequesting = FALSE;
UpdatePic(aData);
// RequestNextPic();
// UtilityTools::WriteFileL(aData,0,KTempFileName);
//
//
// UtilityTools::DeleteFile(KTempFileName);
UtilityTools::WriteLogsL(_L("CImageEngine::HttpOk End"));
}
void CImageEngine::HttpEmpty()
{
iIsRequesting = FALSE;
}
void CImageEngine::HttpFailed()
{
iIsRequesting = FALSE;
}
//////////////////////////////////////////////////////////////////////////
//public:
//////////////////////////////////////////////////////////////////////////
void CImageEngine::AddPicUrl(const TDesC8& aPicUrl,CPictureWidget* aPictureWidget)
{
_LIT8(KHttpPrefix8, "http://");
HBufC8* url = NULL;
int pos = aPicUrl.Find(KHttpPrefix8); //大小写敏感,
TBool urlValid = TRUE;
if(-1 == pos)
{
const TDesC8& httpPrefix8(KHttpPrefix8);
const TDesC8& referer = iWapEngine.Referer();
int httpPrefixLength = httpPrefix8.Length();
if(referer.Length() <= httpPrefixLength)
{
urlValid = FALSE;
}
else
{
TPtrC8 location;
location.Set(referer.Mid(httpPrefixLength));
int pos = location.LocateReverse(L'/');
if(-1 != pos)
{
int len = httpPrefix8.Length() + pos;
location.Set(referer.Left(len));
}
int len = aPicUrl.Length() + location.Length() + 1;
url = HBufC8::NewL(len);
url->Des().Append(location);
url->Des().Append(_L("/"));
url->Des().Append(aPicUrl);
}
}
else
{
url = aPicUrl.Alloc();
}
if(urlValid)
{
CPicUrlPair* pair = new CPicUrlPair;
pair->iUrl = url;
pair->iWidget = aPictureWidget;
iPicUrlPairs.Append(pair);
}
//iPictureUrls.Append(url);
}
#undef TRACE
#define TRACE UtilityTools::WriteLogsL
void CImageEngine::Remove(CPictureWidget* aPictureWidget)
{
TRACE(_L("CImageEngine::Remove aPictureWidget:%d"),aPictureWidget);
if(iCurPicUrlPair && aPictureWidget == iCurPicUrlPair->iWidget)
{
iCurPicUrlPair->iWidget = NULL;
}
else
{
for (int i = 0 ; i < iPicUrlPairs.Count() ; ++i)
{
CPicUrlPair* pair = iPicUrlPairs[i];
if(aPictureWidget == pair->iWidget)
{
TRACE(_L("CImageEngine::Remove pair->iWidget:%d"),pair->iWidget);
pair->iWidget = NULL;
//iPicUrlPairs.Remove(i);
break;
}
}
}
}
void CImageEngine::CancelAllSession()
{
/*
//取消联网
//清空队列
//iPictureUrls.ResetAndDestroy();
*/
if(iWapHttpEngine)
{
iWapHttpEngine->CancelTransaction();
}
iPicUrlPairs.ResetAndDestroy();
}
void CImageEngine::StartPicSession()
{
RequestNextPic();
}
void CImageEngine::RequestNextPic()
{
//if(!iIsRequesting && iPictureUrls.Count())
if(!iIsRequesting && iPicUrlPairs.Count())
{
//ASSERT(NULL == iCurPicUrlPair); //TODO:不应该屏蔽
iCurPicUrlPair = iPicUrlPairs[0];
iPicUrlPairs.Remove(0);
//HBufC8* url = iCurPicUrlPair->iUrl;
//CleanupStack::PushL(url);
RequestPic(*iCurPicUrlPair->iUrl);
//CleanupStack::PopAndDestroy();
}
}
void CImageEngine::RequestPic(const TDesC8& aPicUrl)
{
if(NULL == iWapHttpEngine)
{
iWapHttpEngine = CWapHttpEngine::NewL();
iWapHttpEngine->SetObserver(this);
}
iIsRequesting = TRUE;
iWapHttpEngine->IssueHTTPGetL(aPicUrl);
}
void CImageEngine::UpdatePic(const TDesC8& aData)
{
//ASSERT(iCurPicUrlPair && iCurPicUrlPair->iWidget);
ASSERT(iCurPicUrlPair);
const TDesC8& url = *iCurPicUrlPair->iUrl;
int pos = url.LocateReverse(L'/');
TPtrC8 fileName;
fileName.Set(url.Mid(pos + 1));
const TDesC& path(_L("C:\\Data\\"));
int fileFullLen = path.Length() + fileName.Length();
HBufC* fileFullName = HBufC::NewLC(fileFullLen);
fileFullName->Des().Copy(fileName);
fileFullName->Des().Insert(0,path);
if(!BaflUtils::FileExists(CCoeEnv::Static()->FsSession(),*fileFullName))
{
SavePic(aData,*fileFullName);
}
if(iCurPicUrlPair->iWidget)
{
TRACE(_L("CImageEngine::UpdatePic iCurPicUrlPair:%d iWidget:%d"),iCurPicUrlPair,iCurPicUrlPair->iWidget);
iCurPicUrlPair->iWidget->SetImage(*fileFullName);
}
CleanupStack::PopAndDestroy(fileFullName);
delete iCurPicUrlPair;
iCurPicUrlPair = NULL;
RequestNextPic();
//通知请求图片的widget
//UpdateWindow();
}
void CImageEngine::SavePic(const TDesC8& aData,const TDesC& aFileName)
{
UtilityTools::WriteFileL(aData,0,aFileName);
}
void CImageEngine::UpdateWindow()
{
iWapEngine.UpdateWindow();
} | [
"sungrass.xp@37a08ede-ebbd-11dd-bd7b-b12b6590754f"
]
| [
[
[
1,
238
]
]
]
|
4efa50c5bc6b3b5038f8afa96d8a2c5ebbc8cff5 | 1c9f99b2b2e3835038aba7ec0abc3a228e24a558 | /Projects/elastix/elastix_sources_v4/src/Components/Optimizers/FiniteDifferenceGradientDescent/itkFiniteDifferenceGradientDescentOptimizer.cxx | d8a03dd03db134f4889b78e588b123db8684efff | []
| no_license | mijc/Diploma | 95fa1b04801ba9afb6493b24b53383d0fbd00b33 | bae131ed74f1b344b219c0ffe0fffcd90306aeb8 | refs/heads/master | 2021-01-18T13:57:42.223466 | 2011-02-15T14:19:49 | 2011-02-15T14:19:49 | 1,369,569 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,067 | cxx | /*======================================================================
This file is part of the elastix software.
Copyright (c) University Medical Center Utrecht. All rights reserved.
See src/CopyrightElastix.txt or http://elastix.isi.uu.nl/legal.php for
details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
======================================================================*/
#ifndef __itkFiniteDifferenceGradientDescentOptimizer_cxx
#define __itkFiniteDifferenceGradientDescentOptimizer_cxx
#include "itkFiniteDifferenceGradientDescentOptimizer.h"
#include "itkCommand.h"
#include "itkEventObject.h"
#include "itkExceptionObject.h"
#include "math.h"
#include "vnl/vnl_math.h"
namespace itk
{
/**
* ************************* Constructor ************************
*/
FiniteDifferenceGradientDescentOptimizer
::FiniteDifferenceGradientDescentOptimizer()
{
itkDebugMacro( "Constructor" );
this->m_NumberOfIterations = 100;
this->m_CurrentIteration = 0;
this->m_Value = 0.0;
this->m_StopCondition = MaximumNumberOfIterations;
this->m_GradientMagnitude = 0.0;
this->m_LearningRate = 0.0;
this->m_ComputeCurrentValue = false;
this->m_Param_a = 1.0;
this->m_Param_c = 1.0;
this->m_Param_A = 1.0;
this->m_Param_alpha = 0.602;
this->m_Param_gamma = 0.101;
} // end Constructor
/**
* ************************* PrintSelf **************************
*/
void
FiniteDifferenceGradientDescentOptimizer
::PrintSelf( std::ostream& os, Indent indent ) const
{
Superclass::PrintSelf( os, indent );
os << indent << "LearningRate: "
<< this->m_LearningRate << std::endl;
os << indent << "NumberOfIterations: "
<< this->m_NumberOfIterations << std::endl;
os << indent << "CurrentIteration: "
<< this->m_CurrentIteration;
os << indent << "Value: "
<< this->m_Value;
os << indent << "StopCondition: "
<< this->m_StopCondition;
os << std::endl;
} // end PrintSelf
/**
* *********************** StartOptimization ********************
*/
void
FiniteDifferenceGradientDescentOptimizer
::StartOptimization(void)
{
itkDebugMacro( "StartOptimization" );
this->m_CurrentIteration = 0;
this->m_Stop = false;
/** Get the number of parameters; checks also if a cost function has been set at all.
* if not: an exception is thrown */
this->GetScaledCostFunction()->GetNumberOfParameters();
/** Initialize the scaledCostFunction with the currently set scales */
this->InitializeScales();
/** Set the current position as the scaled initial position */
this->SetCurrentPosition( this->GetInitialPosition() );
if ( !this->m_Stop )
{
this->ResumeOptimization();
}
} // end StartOptimization
/**
* ********************** ResumeOptimization ********************
*/
void
FiniteDifferenceGradientDescentOptimizer
::ResumeOptimization( void )
{
itkDebugMacro( "ResumeOptimization" );
this->m_Stop = false;
double ck = 1.0;
unsigned int spaceDimension = 1;
ParametersType param;
double valueplus;
double valuemin;
InvokeEvent( StartEvent() );
while( ! this->m_Stop )
{
/** Get the Number of parameters.*/
spaceDimension = this->GetScaledCostFunction()->GetNumberOfParameters();
/** Initialisation.*/
ck = this->Compute_c( m_CurrentIteration );
this->m_Gradient = DerivativeType( spaceDimension );
param = this->GetScaledCurrentPosition();
/** Compute the current value, if desired by interested users */
if ( this->m_ComputeCurrentValue )
{
try
{
this->m_Value = this->GetScaledValue( param );
}
catch( ExceptionObject& err )
{
// An exception has occurred.
// Terminate immediately.
this->m_StopCondition = MetricError;
StopOptimization();
// Pass exception to caller
throw err;
}
if( m_Stop )
{
break;
}
} // if m_ComputeCurrentValue
double sumOfSquaredGradients = 0.0;
/** Calculate the derivative; this may take a while... */
try
{
for ( unsigned int j = 0; j < spaceDimension; j++ )
{
param[j] += ck;
valueplus = this->GetScaledValue( param );
param[j] -= 2.0*ck;
valuemin = this->GetScaledValue( param );
param[j] += ck;
const double gradient = (valueplus - valuemin) / (2.0 * ck);
this->m_Gradient[j] = gradient;
sumOfSquaredGradients += ( gradient * gradient );
} // for j = 0 .. spaceDimension
}
catch( ExceptionObject& err )
{
// An exception has occurred.
// Terminate immediately.
this->m_StopCondition = MetricError;
StopOptimization();
// Pass exception to caller
throw err;
}
if( m_Stop )
{
break;
}
/** Save the gradient magnitude;
* only for interested users... */
this->m_GradientMagnitude = vcl_sqrt( sumOfSquaredGradients );
this->AdvanceOneStep();
this->m_CurrentIteration++;
if( this->m_CurrentIteration >= this->m_NumberOfIterations )
{
this->m_StopCondition = MaximumNumberOfIterations;
StopOptimization();
break;
}
} // while !m_stop
} // end ResumeOptimization
/**
* ********************** StopOptimization **********************
*/
void
FiniteDifferenceGradientDescentOptimizer
::StopOptimization( void )
{
itkDebugMacro( "StopOptimization" );
this->m_Stop = true;
InvokeEvent( EndEvent() );
} // end StopOptimization
/**
* ********************** AdvanceOneStep ************************
*/
void
FiniteDifferenceGradientDescentOptimizer
::AdvanceOneStep( void )
{
itkDebugMacro( "AdvanceOneStep" );
const unsigned int spaceDimension =
this->GetScaledCostFunction()->GetNumberOfParameters();
/** Compute the gain */
double ak = this->Compute_a( this->m_CurrentIteration );
/** Save it for users that are interested */
this->m_LearningRate = ak;
const ParametersType & currentPosition = this->GetScaledCurrentPosition();
ParametersType newPosition( spaceDimension );
for ( unsigned int j = 0; j < spaceDimension; j++ )
{
newPosition[ j ] = currentPosition[ j ] - ak * this->m_Gradient[ j ];
}
this->SetScaledCurrentPosition( newPosition );
this->InvokeEvent( IterationEvent() );
} // end AdvanceOneStep
/**
* ************************** Compute_a *************************
*
* This function computes the parameter a at iteration k, as
* described by Spall.
*/
double FiniteDifferenceGradientDescentOptimizer
::Compute_a( unsigned long k ) const
{
return static_cast<double>(
this->m_Param_a / vcl_pow( this->m_Param_A + k + 1, this->m_Param_alpha ) );
} // end Compute_a
/**
* ************************** Compute_c *************************
*
* This function computes the parameter a at iteration k, as
* described by Spall.
*/
double FiniteDifferenceGradientDescentOptimizer
::Compute_c( unsigned long k ) const
{
return static_cast<double>(
this->m_Param_c / vcl_pow( k + 1, this->m_Param_gamma ) );
} // end Compute_c
} // end namespace itk
#endif // end #ifndef __itkFiniteDifferenceGradientDescentOptimizer_cxx
| [
"[email protected]"
]
| [
[
[
1,
310
]
]
]
|
10703d6df3a1df5ffb7b85fa8eaa42078cbd9de6 | c2a70374051ef8f96105d65c84023d97c90f4806 | /bin/src/loadBmp/common/Filter/plfilterthreshold.cpp | d6464afa40aba660ff14901f58fc08e4ce7ef32a | []
| no_license | haselab-net/SpringheadOne | dcf6f10cb1144b17790a782f519ae25cbe522bb2 | 004335b64ec7bea748ae65a85463c0e85b98edbd | refs/heads/master | 2023-08-04T20:27:17.158435 | 2006-04-15T16:49:35 | 2006-04-15T16:49:35 | 407,701,182 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,445 | cpp | /*
/--------------------------------------------------------------------
|
| $Id: plfilterthreshold.cpp,v 1.7 2004/06/15 10:26:13 uzadow Exp $
|
| Copyright (c) 2000-2001 Iyad Hatem
|
\--------------------------------------------------------------------
*/
#include "plstdpch.h"
#include "plfilterthreshold.h"
#include "plbitmap.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
PLFilterThreshold::PLFilterThreshold(int threshold_min,int threshold_max, int channel)
: PLFilter(),
m_threshold_min(threshold_min),
m_threshold_max(threshold_max),
m_channel(channel)
{
}
PLFilterThreshold::~PLFilterThreshold()
{
}
void PLFilterThreshold::Apply(PLBmpBase * pBmpSource, PLBmp * pBmpDest) const
{
int threshold_min = m_threshold_min;
int threshold_max = m_threshold_max;
int channel = m_channel;
// Only works for 32 bpp bitmaps at the moment.
PLASSERT (pBmpSource->GetBitsPerPixel() == 32);
pBmpDest->Create (pBmpSource->GetWidth(), pBmpSource->GetHeight(), 8,
false, true, NULL, 0, pBmpSource->GetResolution());
PLBYTE ** pSrcLines = pBmpSource->GetLineArray();
PLBYTE ** pDstLines = pBmpDest->GetLineArray();
for (int y = 0; y<pBmpDest->GetHeight(); ++y)
{ // For each line
PLBYTE * pSrcPixel = pSrcLines[y];
PLBYTE * pDstPixel = pDstLines[y];
for (int x = 0; x < pBmpDest->GetWidth(); ++x)
{ // For each pixel
if ((PLBYTE (pSrcPixel[channel]) <= PLBYTE (threshold_min)) ||
(PLBYTE (pSrcPixel[channel]) >= PLBYTE(threshold_max)))
*pDstPixel = 0;
else
*pDstPixel = pSrcPixel[channel];
pSrcPixel += sizeof(PLPixel32);
++pDstPixel;
}
}
}
/*
/--------------------------------------------------------------------
|
| $Log: /Project/Springhead/bin/src/loadBmp/common/Filter/plfilterthreshold.cpp $
*
* 1 04/07/12 13:34 Hase
| Revision 1.7 2004/06/15 10:26:13 uzadow
| Initial nonfunctioning version of plbmpbase.
|
| Revision 1.6 2003/11/05 15:17:26 artcom
| Added ability to specify initial data in PLBitmap::Create()
|
| Revision 1.5 2002/08/04 20:08:01 uzadow
| Added PLBmpInfo class, ability to extract metainformation from images without loading the whole image and proper greyscale support.
|
| Revision 1.4 2001/10/21 17:12:40 uzadow
| Added PSD decoder beta, removed BPPWanted from all decoders, added PLFilterPixel.
|
| Revision 1.3 2001/10/16 17:12:27 uzadow
| Added support for resolution information (Luca Piergentili)
|
| Revision 1.2 2001/10/06 22:37:08 uzadow
| Linux compatibility.
|
| Revision 1.1 2001/09/16 19:03:23 uzadow
| Added global name prefix PL, changed most filenames.
|
| Revision 1.4 2001/02/04 14:31:52 uzadow
| Member initialization list cleanup (Erik Hoffmann).
|
| Revision 1.3 2001/01/15 15:05:31 uzadow
| Added PLBmp::ApplyFilter() and PLBmp::CreateFilteredCopy()
|
| Revision 1.2 2000/12/18 22:42:53 uzadow
| Replaced RGBAPIXEL with PLPixel32.
|
| Revision 1.1 2000/09/26 14:28:47 Administrator
| Added Threshold filter
|
|
|
\--------------------------------------------------------------------
*/
| [
"jumius@05cee5c3-a2e9-0310-9523-9dfc2f93dbe1"
]
| [
[
[
1,
109
]
]
]
|
dc2aab7092837c746902f0a97ed824ef0d60c4f6 | 2491785c62428a8b3d935a57dd71c91919d7a73c | /Exercises/Week01/Jazz/Ex-01-05.cpp | 3c0956672d9dddc257293483cc58cc3ffaad00b1 | []
| no_license | lsk/DTU-ComputerGraphics | 2588cb7c96fff091b3818525eea277e5bb19784c | 57089b4d9ab101748013daf678e5b5656553e326 | refs/heads/master | 2021-01-18T10:48:11.001195 | 2011-09-28T09:50:02 | 2011-09-28T09:50:02 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,886 | cpp | /*
* The program draws a circle.
*
*/
#include <GL/glut.h>
#include <math.h>
#define SEGS 100
#define CENTRE_X 0
#define CENTRE_Y 0
#define RADIUS 5.0
void Init (void);
void Display (void);
void Reshape (int w, int h);
void computeCircleVertices (double, double, float, double [][2], int);
int main (int argc, char **argv){
glutInit (&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (600, 500);
glutInitWindowPosition (10, 10);
glutCreateWindow ("Hello World 2");
glutDisplayFunc (Display);
// This is the function used when the window gets reshaped.
glutReshapeFunc (Reshape);
glutMainLoop ();
return 0;
}
void Init (void) {
glClearColor (0., 0., 0., 0.);
glColor3f (1., 1., 0.);
glShadeModel (GL_SMOOTH);
}
void computeCircleVertices (double x, double y, float radius, double vertices[][2], int segments_count){
int i;
double theta = 0;
for (i = 0; i < segments_count; i++) {
theta = 2.0 * M_PI * ( (double) i / segments_count);
vertices[i][0] = ( cos(theta) * radius ) + x;
vertices[i][1] = ( sin(theta) * radius ) + y;
}
}
void drawAxes (float size_x, float size_y, double primary_scale, double secondary_scale) {
int i, steps;
glVertex2d (size_x, 0.);
glVertex2d (-size_x, 0.);
glVertex2d (0., size_y);
glVertex2d (0., -size_y);
steps = ceil(size_x / primary_scale);
for (i = 1; i <= steps; i++) {
glVertex2d (i * primary_scale, 0.);
glVertex2d (i * primary_scale, 1.);
glVertex2d (i * -primary_scale, 0.);
glVertex2d (i * -primary_scale, 1.);
}
}
void Display (void){
double circle[SEGS][2];
int i;
computeCircleVertices (CENTRE_X, CENTRE_Y, RADIUS, circle, SEGS);
glClear (GL_COLOR_BUFFER_BIT);
glColor3f (1., 1., 0.);
glBegin (GL_LINE_LOOP);
for (i = 0; i < SEGS; i++) {
glVertex2dv (circle[i]);
}
glEnd ();
glBegin (GL_LINES);
glColor3f (0., 0.5, 1.);
glVertex2f (15., 0.);
glVertex2f (-15., 0.);
glVertex2f (0., 15.);
glVertex2f (0., -15.);
glColor3f (1., 0., 0.);
glVertex2f (RADIUS, 2.);
glVertex2f (RADIUS, -2.);
glVertex2f (-RADIUS, 2.);
glVertex2f (-RADIUS, -2.);
glVertex2f (2., RADIUS);
glVertex2f (-2., RADIUS);
glVertex2f (2., -RADIUS);
glVertex2f (-2., -RADIUS);
glEnd ();
glFlush ();
}
void Reshape (int w, int h){
glViewport (0., 0., w, h);
glClearColor (0., 0., 0., 0.);
glColor3f (1., 1., 0.);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
// The h / w is needed to have fixed ratio. We don't want an ellipse
// while trying to draw a circle, right?
gluOrtho2D (-15. , 15., -15. * (float) h / w, 15. * (float) h / w);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
}
| [
"[email protected]"
]
| [
[
[
1,
124
]
]
]
|
679e84675b764df6e2683eb1e4475a5f93966b63 | b8ac0bb1d1731d074b7a3cbebccc283529b750d4 | /Code/controllers/Tcleaner/protocol/packets/GroupPacket.cpp | 8dea8aa12d58b2c7a22e1831088ebadf18f318c3 | []
| no_license | dh-04/tpf-robotica | 5efbac38d59fda0271ac4639ea7b3b4129c28d82 | 10a7f4113d5a38dc0568996edebba91f672786e9 | refs/heads/master | 2022-12-10T18:19:22.428435 | 2010-11-05T02:42:29 | 2010-11-05T02:42:29 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,413 | cpp | // Class automatically generated by Dev-C++ New Class wizard
#include <protocol/packets/GroupPacket.h> // class's header file
#include <string.h>
namespace protocol {
namespace packets {
// class constructor
GroupPacket::GroupPacket(char groupid)
{
this->groupid = groupid;
// insert your code here
}
// class destructor
GroupPacket::~GroupPacket()
{
// insert your code here
}
void GroupPacket::setInit(){
this->setCommand(BP_INIT);
}
void GroupPacket::setReset(){
this->setCommand(BP_RESET);
}
void GroupPacket::setPing(){
this->setCommand(BP_PING);
}
void GroupPacket::setError(){
this->setCommand(BP_ERROR);
}
bool GroupPacket::isError(){
return this->getCommand() == BP_ERROR;
}
char GroupPacket::getErrorCode(){
char * data = this->getData();
return data[0];
}
std::string GroupPacket::getErrorString(){
char * data = this->getData();
char length = this->getDataLength();
char i;
std::string * out = new std::string();
for ( i = 1 ; i < length ; i++ )
out->append(1,data[i]);
return *out;
}
void GroupPacket::prepareToSend(){
this->setDestinationGroup(this->groupid);
this->setOriginGroup(ORIGIN_GROUP);
this->setOriginId(ORIGIN_ID);
this->calculateCRC();
}
void GroupPacket::analysePacket(Packet * p){
memcpy(this->getPacket(),p->getPacket(),p->getActualLength());
this->refresh();
}
}
}
| [
"guicamest@d69ea68a-f96b-11de-8cdf-e97ad7d0f28a",
"nachogoni@d69ea68a-f96b-11de-8cdf-e97ad7d0f28a"
]
| [
[
[
1,
61
],
[
63,
66
],
[
68,
72
]
],
[
[
62,
62
],
[
67,
67
]
]
]
|
c60301fe74dfde830b0e3fc8b998431387ae1483 | 33f59b1ba6b12c2dd3080b24830331c37bba9fe2 | /Depend/Foundation/Distance/Wm4DistLine3Segment3.h | 432113c1d61ac3be2c4d53e2d8ef6db9928f9ca7 | []
| no_license | daleaddink/flagship3d | 4835c223fe1b6429c12e325770c14679c42ae3c6 | 6cce5b1ff7e7a2d5d0df7aa0594a70d795c7979a | refs/heads/master | 2021-01-15T16:29:12.196094 | 2009-11-01T10:18:11 | 2009-11-01T10:18:11 | 37,734,654 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,973 | h | // Geometric Tools, Inc.
// http://www.geometrictools.com
// Copyright (c) 1998-2006. All Rights Reserved
//
// The Wild Magic Version 4 Foundation Library source code is supplied
// under the terms of the license agreement
// http://www.geometrictools.com/License/Wm4FoundationLicense.pdf
// and may not be copied or disclosed except in accordance with the terms
// of that agreement.
#ifndef WM4DISTLINE3SEGMENT3_H
#define WM4DISTLINE3SEGMENT3_H
#include "Wm4FoundationLIB.h"
#include "Wm4Distance.h"
#include "Wm4Line3.h"
#include "Wm4Segment3.h"
namespace Wm4
{
template <class Real>
class WM4_FOUNDATION_ITEM DistLine3Segment3
: public Distance<Real,Vector3<Real> >
{
public:
DistLine3Segment3 (const Line3<Real>& rkLine,
const Segment3<Real>& rkSegment);
// object access
const Line3<Real>& GetLine () const;
const Segment3<Real>& GetSegment () const;
// static distance queries
virtual Real Get ();
virtual Real GetSquared ();
// function calculations for dynamic distance queries
virtual Real Get (Real fT, const Vector3<Real>& rkVelocity0,
const Vector3<Real>& rkVelocity1);
virtual Real GetSquared (Real fT, const Vector3<Real>& rkVelocity0,
const Vector3<Real>& rkVelocity1);
// Information about the closest points.
Real GetLineParameter () const;
Real GetSegmentParameter () const;
private:
using Distance<Real,Vector3<Real> >::m_kClosestPoint0;
using Distance<Real,Vector3<Real> >::m_kClosestPoint1;
const Line3<Real>& m_rkLine;
const Segment3<Real>& m_rkSegment;
// Information about the closest points.
Real m_fLineParameter; // closest0 = line.origin+param*line.direction
Real m_fSegmentParameter; // closest1 = seg.origin+param*seg.direction
};
typedef DistLine3Segment3<float> DistLine3Segment3f;
typedef DistLine3Segment3<double> DistLine3Segment3d;
}
#endif
| [
"yf.flagship@e79fdf7c-a9d8-11de-b950-3d5b5f4ea0aa"
]
| [
[
[
1,
65
]
]
]
|
adcd7794b208544107b691b4222c555eea1f918d | 496843a1f1cfa6de4ba5f776e29fcdd295fbf945 | /FlowDB.cpp | 8d499315ba9f4c295e1c5b0f61c686940c72fa3b | []
| no_license | voov/FlowDB | de4089b8678923a9dc3938d9b0eb0d4ea89a108f | a7e4b1b65412c9b6241067999cb3b225b6b742b1 | refs/heads/master | 2021-01-22T01:28:22.151598 | 2011-04-19T21:13:41 | 2011-04-19T21:13:41 | 1,632,996 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 700 | cpp | // FlowDB.cpp : Defines the entry point for the console application.
//
#include <iostream>
//#include <math.h>
#include "btree.h";
#include "mem.h"
int main(int argc, char* argv[])
{
/*BPTree *bptr = new BPTree();
std::cout << "FlowDB v. 0.0.1" << std::endl;
for(int i=1; i<10; i++) {
bptr->Insert(i, i + 64);
}
std::cout << "Data: " << bptr->FindValue(10) << std::endl;
//*/
BPTree *tree;
ManagedMemory *mem = new ManagedMemory();
tree = (BPTree *)mem->OpenFile("rand_ints.fdb");
if(!tree) tree = new BPTree();
for(int i=1; i<10; i++) {
tree->Insert(i, i + 64);
}
mem->CloseFile();
delete mem;
delete tree;
//std::getchar();
return 0;
}
| [
"[email protected]",
"[email protected]"
]
| [
[
[
1,
4
],
[
8,
11
],
[
13,
17
],
[
33,
34
]
],
[
[
5,
7
],
[
12,
12
],
[
18,
32
]
]
]
|
d589675cb4c483c40df41be532cd16ebf2055dd9 | 6e4f9952ef7a3a47330a707aa993247afde65597 | /PROJECTS_ROOT/WireKeys/WP_Schedule/WP_Schedule.cpp | e2e1e9de962dc5539b966f3bb7677ad7dde45f52 | []
| no_license | meiercn/wiredplane-wintools | b35422570e2c4b486c3aa6e73200ea7035e9b232 | 134db644e4271079d631776cffcedc51b5456442 | refs/heads/master | 2021-01-19T07:50:42.622687 | 2009-07-07T03:34:11 | 2009-07-07T03:34:11 | 34,017,037 | 2 | 1 | null | null | null | null | WINDOWS-1251 | C++ | false | false | 2,713 | cpp | // IconsFont.cpp : Defines the initialization routines for the DLL.
//
#include "stdafx.h"
#include <atlbase.h>
#include "WP_Schedule.h"
#include "HookCode.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#ifdef _DEBUG
#define TRACETHREAD TRACE3("\nCheckpoint: Thread: 0x%04x, file=%s, line=%lu\n",::GetCurrentThreadId(),__FILE__,__LINE__);
#else
#define TRACETHREAD
#endif
#define FORK(func,param) \
{\
DWORD dwThread=0;\
HANDLE hThread=::CreateThread(NULL, 0, func, LPVOID(param), 0, &dwThread);\
::CloseHandle(hThread);\
}
CString _l(const char* szText);
WKCallbackInterface*& WKGetPluginContainer();
extern HANDLE hStopEvent;
extern HINSTANCE g_hinstDll;
extern HANDLE hHookerThread;
extern COptions plgOptions;
extern CRITICAL_SECTION csMainThread;
/*
char* GetSubString(const char* szFrom, const char* szBegin, char cEnd, char* szTarget, const char* szDefaultValue="", int iOutBufLen=16)
{
strcpy(szTarget,szDefaultValue);
char* szPos=strstr(szFrom,szBegin);
if(szPos){
szPos=szPos+strlen(szBegin);
char* szEnd=strchr(szPos,cEnd);
if(szEnd){
int iLen=szEnd-szPos;
if(iLen>iOutBufLen){
iLen=iOutBufLen-1;
}
memcpy(szTarget,szPos,iLen);
szTarget[iLen]=0;
}
}
return szTarget;
}
DWORD WINAPI GlobalHooker_Gestures(LPVOID pData)
{
::EnterCriticalSection(&csMainThread);
char c=0;
CPoint pt0;
GetCursorPos(&pt0);
BOOL bNotStopStart=bNotStop;
while(bNotStopStart==bNotStop){
Sleep(20);
}
CPoint pt1;
GetCursorPos(&pt1);
long lX=pt1.x-pt0.x;
long lY=pt1.y-pt0.y;
CRect rt;
GetWindowRect(GetDesktopWindow(),&rt);
if(max(abs(lX),abs(lY))>max(rt.Width(),rt.Height())/5 && min(abs(lX),abs(lY))<max(rt.Width(),rt.Height())/5){
if(abs(lX)>abs(lY)){
// X
if(pt1.x>pt0.x){
c='0';
}else{
c='1';
}
}else{
// Y
if(pt1.y>pt0.y){
c='2';
}else{
c='3';
}
}
}
// Собрали информацию!!! Обрабатываем
if(c!=0){
char sz[]="MOG0";
sz[3]=c;
WKGetPluginContainer()->NotifyEventStarted(sz);
FORK(DepressKey,c);
}
::LeaveCriticalSection(&csMainThread);
return 0;
}
*/
/*char szHotkeyStrPresentation[32]={0};
int WINAPI WKGetPluginFunctionHints(long iPluginFunction, long lHintCode, void*& pOut)
{
if(iPluginFunction==0){
strcpy(szHotkeyStrPresentation,"%0~-4");
pOut=szHotkeyStrPresentation;
return 1;
}
if(iPluginFunction==1){
strcpy(szHotkeyStrPresentation,"%0@~-4");
pOut=szHotkeyStrPresentation;
return 1;
}
return 0;
};*/
#ifndef NOSTUB_VC6
#define COMPILE_MULTIMON_STUBS
#include <multimon.h>
#endif | [
"wplabs@3fb49600-69e0-11de-a8c1-9da277d31688"
]
| [
[
[
1,
117
]
]
]
|
0d16a367c45afe34d9e857eab306916090d30ef4 | 4f913cc1a50e8e649fd40313631a161234e3c59d | /CAuADXDecoder.h | 808b0d9a419754bf100a8b9d90d293238a3d2af0 | []
| no_license | autch/kpiadx.kpi | abb1f084163478796e202196a7411a049a76116c | f482c3871d948e71a3b3839e9066f845ecdb5915 | refs/heads/master | 2021-12-16T01:22:32.824315 | 2010-12-15T06:34:48 | 2010-12-15T06:34:48 | 1,170,398 | 1 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 12,734 | h |
#pragma once
#define ADXK0 0x7298
#define ADXK1 0x3350
#define DEFAULT_MASTER_VOLUME 0x4000
#define BLOCKS_PER_ONCE (1 << 7)
struct SADX3Header
{
DWORD dwOffsetToSigAndData;
BYTE abyReserved[3];
BYTE byChannels;
DWORD dwSamplesPerSec;
DWORD dwSamples;
WORD wReserved;
BYTE byVersion;
BYTE abyReserved2[9];
DWORD dwLoopStart;
WORD wLoopPointS1;
WORD wLoopPointS2;
DWORD dwLoopEnd;
};
struct SADX4Header
{
DWORD dwOffsetToSigAndData;
BYTE abyReserved[3];
BYTE byChannels;
DWORD dwSamplesPerSec;
DWORD dwSamples;
WORD wReserved;
BYTE byVersion;
BYTE abyReserved2[9];
DWORD dwReserved1;
WORD wLoopPointS1;
WORD wLoopPointS2;
DWORD dwReserved2;
DWORD dwLoopStart;
DWORD dwReserved3;
DWORD dwLoopEnd;
};
typedef union
{
SADX3Header adx3;
SADX4Header adx4;
}SADXHeader;
struct SADXContext
{
int s1;
int s2;
};
class CAuADXDecoder
{
private:
// kpi として必要なもの
HANDLE m_hFile; // = CreateFile(...)
SOUNDINFO m_Info;
SADXHeader m_Header;
Nokomo::UnitConvs::CAuPcmUnitConverter* m_pPuc;
Nokomo::SyncObjects::CAuCriticalSection* m_pCs;
// 都度ヘッダを見るのは面倒なのでここにおいておく
DWORD m_dwSamples; // 総サンプル数
DWORD m_dwLoopStart; // サンプル値
DWORD m_dwLoopEnd; // サンプル値,ループしないとき値は化けるので無視する
DWORD m_dwDataOffset;// バイト値,データ開始オフセット
DWORD m_dwSamplesDecoded;
int m_nMasterVolume;
LPSTR m_szIniFile;
// フィルタで使う二つ前までのサンプル値
SADXContext m_Context[2]; // 最大 2 チャンネル
// Big Endian 32bit から Little Endian DWORD へ
DWORD BEtoLE(DWORD dwBE)
{
// (;´Д`)……
return ((dwBE & 0xff000000) >> 24)
| ((dwBE & 0x00ff0000) >> 8)
| ((dwBE & 0x0000ff00) << 8)
| ((dwBE & 0x000000ff) << 24)
;
}
WORD BEtoLE(WORD wBE)
{
return ((wBE & 0xff00) >> 8)
| ((wBE & 0x00ff) << 8)
;
}
// BYTE* p から Big Endian で 1word 読む.読んだ後 p は自分で += 2 すること
WORD ReadWordBE(BYTE* p)
{
return *p << 8 | *(p + 1);
}
// m_hFile からヘッダを読んで解析
BOOL ReadHeader()
{
DWORD dwBytesRead = 0;
BOOL r;
r = ReadFile(m_hFile, &m_Header, sizeof(SADX4Header), &dwBytesRead, NULL);
if(!r || dwBytesRead != sizeof(SADX4Header)) return FALSE;
// DWORD なメンバのエンディアンネス変換
#define SWAP_DWORD_MEMBER(name) m_Header.adx4.name = BEtoLE(m_Header.adx4.name)
SWAP_DWORD_MEMBER(dwOffsetToSigAndData);
SWAP_DWORD_MEMBER(dwSamplesPerSec);
SWAP_DWORD_MEMBER(dwSamples);
SWAP_DWORD_MEMBER(dwLoopStart);
SWAP_DWORD_MEMBER(dwLoopEnd);
#undef SWAP_DWORD_MEMBER
#define SWAP_WORD_MEMBER(name) m_Header.adx4.name = BEtoLE(m_Header.adx4.name)
SWAP_WORD_MEMBER(wLoopPointS1);
SWAP_WORD_MEMBER(wLoopPointS2);
#undef SWAP_WORD_MEMBER
m_Header.adx3.dwLoopStart = BEtoLE(m_Header.adx3.dwLoopStart);
m_Header.adx3.dwLoopEnd = BEtoLE(m_Header.adx3.dwLoopEnd);
ZeroMemory(&m_Info, sizeof(SOUNDINFO));
DWORD dwSignatureAddress;
dwSignatureAddress = (m_Header.adx4.dwOffsetToSigAndData & 0x7fffffff) - 2;
m_dwDataOffset = (m_Header.adx4.dwOffsetToSigAndData & 0x7fffffff) + 4;
if(m_dwDataOffset >= GetFileSize(m_hFile, NULL)) return FALSE;
// この辺の変な値は KMP が蹴る
m_Info.dwSamplesPerSec = m_Header.adx4.dwSamplesPerSec;
m_Info.dwChannels = m_Header.adx4.byChannels;
m_Info.dwBitsPerSample = 16; // TODO: 16bit 決めうちでいいよね?
m_Info.dwUnitRender = (32 * m_Info.dwChannels * (m_Info.dwBitsPerSample >> 3)) * BLOCKS_PER_ONCE; // 1 ブロック 32 サンプルで 16bit をチャンネル数分
m_Info.dwMultiSongFlag = FALSE;
m_Info.dwSeekable = TRUE; // TODO: 実質シーク不可でも問題なし?
// TODO: このバージョン判定自体怪しいが……
switch(m_Header.adx4.byVersion)
{
case 3:
{
// TODO: ADX v3 ってファイル持ってないの……
m_dwLoopStart = m_Header.adx3.dwLoopStart;
m_dwLoopEnd = m_Header.adx3.dwLoopEnd;
break;
}
case 4:
{
m_dwLoopStart = m_Header.adx4.dwLoopStart;
m_dwLoopEnd = m_Header.adx4.dwLoopEnd;
break;
}
default:
return FALSE;
}
// TODO: FIXME: ループ有無の判定が変.
// データオフセットの値がヘッダを超えた直後なら
// つまりパディングがないということなのでループしない.
// セクタパディングが必要なのはループをするときである.
// しかもバージョンに関係ないらしい
m_dwSamples = m_Header.adx4.dwSamples;
m_Info.dwLoopFlag = (m_dwDataOffset != (sizeof(SADX3Header)) && m_dwDataOffset != (sizeof(SADX4Header)))
&& m_dwLoopStart < m_dwLoopEnd && m_dwLoopEnd <= m_dwSamples;
int nLoopTimes = 2;
if(m_szIniFile)
nLoopTimes = GetPrivateProfileInt("kpiadx", "Loop", 2, m_szIniFile);
if(m_Info.dwLoopFlag)
{
// TODO: FIXME: ループ二回決めうちでいい?
// サンプル単位は簡単にオーバーフローするので 64bit int
Nokomo::QWORD qwSampleLength = m_dwLoopStart // イントロ(ファイル先頭からループ開始まで)
+ (m_dwLoopEnd - m_dwLoopStart) * nLoopTimes; // ループ二回分
m_Info.dwLength = qwSampleLength * 1000 / m_Info.dwSamplesPerSec;
}
else
{
Nokomo::QWORD qwSampleLength = m_dwSamples;
m_Info.dwLength = qwSampleLength * 1000 / m_Info.dwSamplesPerSec;
}
if(m_szIniFile)
m_nMasterVolume = GetPrivateProfileInt("kpiadx", "MasterVolume", DEFAULT_MASTER_VOLUME, m_szIniFile);
return TRUE;
}
// Open() 後,ファイル先頭から再生できるよう準備する
// シークするときにも使う
void Reset()
{
SetFilePointer(m_hFile, m_dwDataOffset, NULL, FILE_BEGIN);
m_dwSamplesDecoded = 0;
ZeroMemory(m_Context, sizeof(SADXContext) * 2);
}
// 1w + 32h 分デコードする
void DecodeBlock(BYTE* pSource, short* pDest, SADXContext& context)
{
int nScale = ReadWordBE(pSource);
int d;
int s0, s1 = context.s1, s2 = context.s2;
int nMasterVolume = m_nMasterVolume;
pSource += 2;
for(int i = 0; i < 16; i++)
{
d = *pSource >> 4;
if(d & 0x08) d -= 0x10;
s0 = (((d * nScale) * nMasterVolume) + ADXK0 * s1 - ADXK1 * s2) >> 14;
if(s0 > 0x7fff) s0 = 0x7fff;
if(s0 < -0x7fff) s0 = -0x7fff;
*pDest++ = s0; s2 = s1; s1 = s0;
d = *pSource & 0x0f;
if(d & 0x08) d -= 0x10;
s0 = (((d * nScale) * nMasterVolume) + ADXK0 * s1 - ADXK1 * s2) >> 14;
if(s0 > 0x7fff) s0 = 0x7fff;
if(s0 < -0x7fff) s0 = -0x7fff;
*pDest++ = s0; s2 = s1; s1 = s0;
pSource++;
}
context.s1 = s1;
context.s2 = s2;
}
// dwSize (% dwUnitRender == 0) の分だけデコードする
DWORD DecodeBuffer(BYTE* pBuffer, DWORD dwSize)
{
DWORD dwBytesDecoded = 0;
DWORD dwBytesRead = 0;
DWORD dwSamplesToCopy;
BOOL r;
DWORD dwBlocksToRead = BLOCKS_PER_ONCE * m_Info.dwChannels;
BYTE* abySource = new BYTE[18 * dwBlocksToRead];
if(m_Info.dwChannels == 1)
{
// モノラル
short sBuffer[32];
while(dwBytesDecoded < dwSize)
{
r = ReadFile(m_hFile, abySource, 18 * dwBlocksToRead, &dwBytesRead, NULL);
if(!r || dwBytesRead < 18) break;
BYTE* pSource = abySource;
while(pSource < abySource + dwBytesRead && dwBytesDecoded < dwSize)
{
DecodeBlock(pSource, sBuffer, m_Context[0]);
pSource += 18;
// 総サンプル数は 32 samples の倍数とは限らないので,
// コピーするサイズはサンプル数で決める
dwSamplesToCopy = (m_dwSamples - m_dwSamplesDecoded) > 32 ? 32 : m_dwSamples - m_dwSamplesDecoded;
if(pBuffer)
CopyMemory(pBuffer, sBuffer, dwSamplesToCopy * 2);
pBuffer += dwSamplesToCopy * 2;
dwBytesDecoded += dwSamplesToCopy * 2;
m_dwSamplesDecoded += dwSamplesToCopy;
if(dwSamplesToCopy != 32) goto BreakDecoding;
}
}
}
else
{
// ステレオ
short sBufferL[32], sBufferR[32];
while(dwBytesDecoded < dwSize)
{
// 左
r = ReadFile(m_hFile, abySource, 18 * dwBlocksToRead, &dwBytesRead, NULL);
if(!r || dwBytesRead < 18) break;
BYTE* pSource = abySource;
while(pSource < abySource + dwBytesRead && dwBytesDecoded < dwSize)
{
DecodeBlock(pSource, sBufferL, m_Context[0]);
pSource += 18;
DecodeBlock(pSource, sBufferR, m_Context[1]);
pSource += 18;
// ADX では各チャンネルのサンプルは 32 samples ごとに
// LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR ...
// と並んでいるので,これを WaveAudio の LRLRLRLR ... 形式に直す
DWORD dwSamplesToCopy = (m_dwSamples - m_dwSamplesDecoded) > 32 ? 32 : m_dwSamples - m_dwSamplesDecoded;
if(pBuffer)
{
short* pStereo = (short*)pBuffer;
for(DWORD i = 0; i < dwSamplesToCopy; i++)
{
*pStereo++ = sBufferL[i];
*pStereo++ = sBufferR[i];
}
}
pBuffer += dwSamplesToCopy * 2 * 2;
dwBytesDecoded += dwSamplesToCopy * 2 * 2;
m_dwSamplesDecoded += dwSamplesToCopy;
if(dwSamplesToCopy != 32) goto BreakDecoding;
}
}
}
BreakDecoding:
delete[] abySource;
return dwBytesDecoded;
}
public:
CAuADXDecoder()
{
m_hFile = NULL;
m_pPuc = NULL;
m_pCs = new Nokomo::SyncObjects::CAuCriticalSection();
m_nMasterVolume = DEFAULT_MASTER_VOLUME;
m_szIniFile = NULL;
}
~CAuADXDecoder()
{
Close();
delete m_pPuc;
delete m_pCs;
}
BOOL Open(LPSTR szFileName, SOUNDINFO* pInfo)
{
Nokomo::SyncObjects::CAuCriticalSectionEx cs(m_pCs);
m_hFile = CreateFile(szFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if(m_hFile)
{
if(ReadHeader())
{
CopyMemory(pInfo, &m_Info, sizeof(SOUNDINFO));
Reset();
return TRUE;
}
Close();
}
return FALSE;
}
// もうこのファイルを使わないとき呼ぶ.あとは delete するだけ
void Close()
{
CloseHandle(m_hFile);
m_hFile = NULL;
}
DWORD SetPosition(DWORD dwPos)
{
Nokomo::SyncObjects::CAuCriticalSectionEx cs(m_pCs);
DWORD dwPosSamples = dwPos / 1000 * m_Info.dwSamplesPerSec;
if(m_Info.dwLoopFlag && dwPosSamples >= m_dwLoopStart)
{
SeekToLoopStartBlock();
return (Nokomo::QWORD)m_dwLoopStart * 1000 / m_Info.dwSamplesPerSec;
}
else
{
Reset();
return 0;
}
}
DWORD Render(BYTE* pBuffer, DWORD dwSize)
{
Nokomo::SyncObjects::CAuCriticalSectionEx cs(m_pCs);
return DecodeBuffer(pBuffer, dwSize);
}
VOID SeekToLoopStartBlock()
{
// ループ始点のブロックはセクタアラインされてるだけでなく
// ループ始点はブロック先頭にアラインされている.
DWORD dwBlockOffset = m_dwDataOffset + (m_dwLoopStart >> 5) * 18 * m_Info.dwChannels;
Reset();
SetFilePointer(m_hFile, dwBlockOffset, NULL, FILE_BEGIN);
// 実はヘッダに入っている.0 で初期化しても体感差なし
m_Context[0].s1 = m_Header.adx4.wLoopPointS1;
m_Context[0].s2 = m_Header.adx4.wLoopPointS2;
m_Context[1].s1 = m_Header.adx4.wLoopPointS1;
m_Context[1].s2 = m_Header.adx4.wLoopPointS2;
m_dwSamplesDecoded = m_dwLoopStart;
}
BOOL GetLoopFlag() const { return m_Info.dwLoopFlag; }
DWORD GetLoopStart() const { return m_dwLoopStart; }
DWORD GetLoopEnd() const { return m_dwLoopEnd; }
DWORD GetCurrentSamplesRendered() const { return m_dwSamplesDecoded; }
VOID SetConfigPath(LPSTR szPath) { m_szIniFile = szPath; }
};
| [
"autch@f88602a7-bc0e-0410-bfba-c07ee007e53c"
]
| [
[
[
1,
385
]
]
]
|
1366aa59578eb200a5e75bcbe443f2c8ab88f926 | 59112a8527fc59e65ac099b00fd1977d2393fdd7 | /WaveCreator.h | 67fc41ee7fdb41f842cbea6b68d99c552db00847 | []
| no_license | viniciusjarina/wave_creator | 4aa3714ee5894b2f47ecb36c236d8e57fcfd86a9 | 05002aa81918da90e248992a06557d1d86216e69 | refs/heads/master | 2020-06-03T01:45:10.300399 | 2010-09-05T02:23:33 | 2010-09-05T02:23:33 | 3,187,789 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 534 | h | // WaveCreator.h : main header file for the PROJECT_NAME application
//
#pragma once
#ifndef __AFXWIN_H__
#error "include 'stdafx.h' before including this file for PCH"
#endif
#include "resource.h" // main symbols
// CWaveCreatorApp:
// See WaveCreator.cpp for the implementation of this class
//
class CWaveCreatorApp : public CWinApp
{
public:
CWaveCreatorApp();
// Overrides
public:
virtual BOOL InitInstance();
// Implementation
DECLARE_MESSAGE_MAP()
};
extern CWaveCreatorApp theApp; | [
"[email protected]"
]
| [
[
[
1,
31
]
]
]
|
a0f69342061380fd87569ab174b44bd81756b537 | 7b4c786d4258ce4421b1e7bcca9011d4eeb50083 | /Learning OpenCV/Chapter 4 - HighGUI/Exercise_4_7.cpp | b2b9332817272cf5722a1f511548554f4e53d843 | []
| no_license | lzq123218/guoyishi-works | dbfa42a3e2d3bd4a984a5681e4335814657551ef | 4e78c8f2e902589c3f06387374024225f52e5a92 | refs/heads/master | 2021-12-04T11:11:32.639076 | 2011-05-30T14:12:43 | 2011-05-30T14:12:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,191 | cpp | /////////////////////////////////////////////////////////////////
// Date: 2009-10-18
// Author: Yishi Guo
// Exercise: 4.7
// Page: 108p
// Content: Perspective transform
// Functions: cvmGet, cvmSet, cvWarpPerspective
// Website: http://meiyou.org/
/////////////////////////////////////////////////////////////////
#include <iostream.h>
#include <cv.h >
#include <highgui.h>
// Get the row and col of the matrix
//
void get_row_col( char key, int& row, int& col, bool& is_shift ) {
// If shift key is not pressed
switch( key ) {
case '1': row = 0; col = 0; break;
case '2': row = 0; col = 1; break;
case '3': row = 0; col = 2; break;
case '4': row = 1; col = 0; break;
case '5': row = 1; col = 1; break;
case '6': row = 1; col = 2; break;
case '7': row = 2; col = 0; break;
case '8': row = 2; col = 1; break;
case '9': row = 2; col = 2; break;
default: row = 0; col = 0; break;
}
if( '1' <= key && key <= '9' ) {
is_shift = false;
return;
} else {
is_shift = true;
}
// If shift key is pressed
//
switch( key ) {
case '!': row = 0; col = 0; break;
case '@': row = 0; col = 1; break;
case '#': row = 0; col = 2; break;
case '$': row = 1; col = 0; break;
case '%': row = 1; col = 1; break;
case '^': row = 1; col = 2; break;
case '&': row = 2; col = 0; break;
case '*': row = 2; col = 1; break;
case '(': row = 2; col = 2; break;
default: row = 0; col = 0; break;
}
}
// Output the matrix
//
void cout_mat( CvMat* matrix ) {
CvSize size = cvGetSize( matrix );
for ( int i = 0; i < size.width; i++ ) {
for ( int j = 0; j < size.height; j++ ) {
cout << cvmGet( matrix, i, j ) << " ";
}
cout << endl;
}
cout << endl;
}
int main( int argc, char** argv ) {
if ( argc >= 2 ) {
// Get two images
//
IplImage* src = cvLoadImage( argv[1] );
if ( !src ) {
return -1;
}
IplImage* dst = cvCloneImage( src );
cvZero( dst );
// Create mat
//
CvMat* warp_matrix = cvCreateMat( 3, 3, CV_32FC1 );
cvZero( warp_matrix );
// Show images
//
cvNamedWindow( "Exercise 4-7 src", CV_WINDOW_AUTOSIZE );
cvNamedWindow( "Exercise 4-7 dst", CV_WINDOW_AUTOSIZE );
cvShowImage( "Exercise 4-7 src", src );
cvShowImage( "Exercise 4-7 dst", dst );
while ( 1 ) {
char key = cvWaitKey(0);
if ( key == 27 ) break;
int row = 0, col = 0;
bool is_shift = false;
// Get row and col
get_row_col( key, row, col, is_shift );
// Get the value at row&col
double value = cvmGet( warp_matrix, row, col );
if ( is_shift ) {
--value;
} else {
++value;
}
cvmSet( warp_matrix, row, col, value );
// For debug
//
cout << key << endl;
cout_mat( warp_matrix ); // Test for the warp matrix
// Process
//
cvWarpPerspective( src, dst, warp_matrix );
cvShowImage( "Exercise 4-7 dst" , dst );
}
cvReleaseMat( &warp_matrix );
cvReleaseImage( &src );
cvReleaseImage( &dst );
cvDestroyWindow( "Exercise 4-7 src" );
cvDestroyWindow( "Exercise 4-7 dst" );
return 0;
}
return -2;
} | [
"baicaibang@70501136-4834-11de-8855-c187e5f49513"
]
| [
[
[
1,
134
]
]
]
|
f29d9a55f2610daf33948483ef598048faab4418 | a70f708a62feb4d1b6f80d0a471b47ac584ea82b | / arxlss --username quangvinh.ph/VLSS/Ex04Dlg.h | b56a0b0be4f108af5efedc8238879424b885ce6d | []
| no_license | presscad/arxlss | ae8a41acba416d20a1ec2aa4485d142912e6787d | d6d201bfc98b0d442c77b37b10ca5ac7ea5efcbb | refs/heads/master | 2021-04-01T22:38:06.710239 | 2009-11-07T02:47:17 | 2009-11-07T02:47:17 | null | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 563 | h | #pragma once
// CEx04Dlg ダイアログ
class CEx04Dlg : public CAcUiDialog
{
DECLARE_DYNAMIC(CEx04Dlg)
public:
CEx04Dlg(CWnd* pParent = NULL); // 標準コンストラクタ
virtual ~CEx04Dlg();
// ダイアログ データ
enum { IDD = IDD_EX04DLG };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV サポート
DECLARE_MESSAGE_MAP()
public:
afx_msg void on_btnCopy_clicked();
afx_msg void on_btnPaste_clicked();
public:
static void RunMe();
CString m_strCopy;
CString m_strPaste;
};
| [
"quangvinh.ph@29354a60-911c-11de-8f34-01a6ee357387"
]
| [
[
[
1,
29
]
]
]
|
1b3221611fb20dbdf40427fa4896ac7b6090bc0a | ad33a51b7d45d8bf1aa900022564495bc08e0096 | /DES/DES_GOBSTG/Class/Fontsys.cpp | 917b16dc56f41f0d6fe9b9507d9055708a3b3acd | []
| no_license | CBE7F1F65/e20671a6add96e9aa3551d07edee6bd4 | 31aff43df2571d334672929c88dfd41315a4098a | f33d52bbb59dfb758b24c0651449322ecd1b56b7 | refs/heads/master | 2016-09-11T02:42:42.116248 | 2011-09-26T04:30:32 | 2011-09-26T04:30:32 | 32,192,691 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,391 | cpp | #include "../header/Fontsys.h"
#include "../header/Main.h"
#include "../header/Scripter.h"
#include "../header/Data.h"
#include "../header/SpriteItemManager.h"
#include "../../../src/hge/HGEExport.h"
list<Fontsys *> Fontsys::fontsys;
HD3DFONT Fontsys::font = NULL;
Fontsys::Fontsys()
{
tar = NULL;
sprite = NULL;
signedup = false;
// ZeroMemory(&quad, sizeof(hgeQuad));
strcpy(text, "");
}
Fontsys::~Fontsys()
{
ReleaseTargetAndSprite();
}
void Fontsys::ReleaseTargetAndSprite()
{
if (tar)
{
hge->Target_Free(tar);
tar = NULL;
}
SpriteItemManager::FreeSprite(&sprite);
}
bool Fontsys::SignOff(bool erase)
{
ReleaseTargetAndSprite();
strcpy(text, "");
if (!erase || !signedup)
{
return true;
}
for (list<Fontsys *>::iterator it=fontsys.begin(); it!= fontsys.end(); it++)
{
if (*it == this)
{
it = fontsys.erase(it);
return true;
}
}
// ZeroMemory(&quad, sizeof(hgeQuad));
return false;
}
void Fontsys::Release()
{
for (list<Fontsys *>::iterator it=fontsys.begin(); it!=fontsys.end();)
{
if ((*it)->SignOff(false))
{
it = fontsys.erase(it);
}
else
{
it++;
}
}
fontsys.clear();
}
void Fontsys::Init(HD3DFONT _font)
{
if (_font != NULL)
{
font = _font;
}
Release();
}
void Fontsys::HeatUp()
{
/*
for (int i=0; i<scr.strdescIndex; i+=(i+1))
{
SignUp(FONTSYS_CHATUSE, strdesc[i]);
}
*/
/*
Fontsys _fs;
for (int i=0; i<PLAYERTYPEMAX; i++)
{
_fs.SignUp(data.getPlayerName(i));
}
for (int i=0; i<ENEMYTYPEMAX; i++)
{
_fs.SignUp(data.getEnemyName(i));
}
_fs.SignOff();
*/
}
bool Fontsys::GfxRestore()
{
for (list<Fontsys *>::iterator it=fontsys.begin(); it!=fontsys.end(); it++)
{
HD3DFONT _usingfont = (*it)->usingfont;
(*it)->SignUp(NULL, _usingfont);
(*it)->sprite->SetTexture(hge->Target_GetTexture((*it)->tar));
}
return true;
}
int Fontsys::strTranslate(char * dtext, const char * stext, int * maxchar)
{
int _lines = 1;
int _maxcharinline = -1;
int lastj = 0;
int j=0;
strcpy(dtext, "");
for(int i=0; i<(int)strlen(stext); i++)
{
if (stext[i] == '\n')
{
if (_maxcharinline < j - lastj)
{
_maxcharinline = j - lastj;
}
lastj = j;
_lines++;
}
if (stext[i]<0)
{
char twchar[3];
twchar[0] = stext[i];
i++;
j+=2;
twchar[1] = stext[i];
twchar[2] = 0;
strcat(dtext, twchar);
continue;
}
if(stext[i] == FONTSYS_TRANSCHAR)
{
i++;
if(stext[i] != FONTSYS_TRANSCHAR)
{
int strcodecon = stext[i] - '0';
if(!strcodecon)
{
int strcodeval = (stext[i+1] - '0') * 10 + (stext[i+2] - '0');
while(j < strcodeval)
{
strcat(dtext, " ");
j++;
}
i += 2;
continue;
}
else
{
int strcodeval1 = (stext[i+1] - '0') * 10 + (stext[i+2] - '0');
int strcodeval2 = (stext[i+3] - '0') * 10 + (stext[i+4] - '0');
while(j < strcodeval1)
{
strcat(dtext, " ");
j++;
}
i += 4;
char buffer[32];
int k = 0;
while(!(stext[i+1] == FONTSYS_TRANSCHAR && stext[i+2] == FONTSYS_CONTROLCHAR))
{
i++;
buffer[k] = stext[i];
k++;
}
buffer[k] = 0;
for(int l=k;l<strcodeval2-strcodeval1;l++)
{
if(strcodecon == 2)
strcat(dtext, "0");
else
strcat(dtext, " ");
j++;
}
strcat(dtext, buffer);
i += 2;
j += k;
continue;
}
}
}
char tbuff[2];
tbuff[0] = stext[i];
tbuff[1] = 0;
strcat(dtext, tbuff);
j++;
}
if (_maxcharinline < j - lastj)
{
_maxcharinline = j - lastj;
}
if (maxchar)
{
*maxchar = _maxcharinline;
}
return _lines;
}
void Fontsys::SignUp(const char * _text, HD3DFONT _font)
{
HTEXTURE tex;
if (_text != NULL)
{
SignOff();
lines = strTranslate(text, _text, &maxcharinline);
}
ReleaseTargetAndSprite();
tar = NULL;//hge->Target_Create(FONTSYS_TARGETWIDTH, FONTSYS_TARGETHEIGHT, false);
if (!_font)
{
_font = font;
}
usingfont = _font;
if (!usingfont)
{
return;
}
tex = hge->Texture_Create(maxcharinline*25, lines*25);
char temptext[M_STRMAX];
strcpy(temptext, text);
int fontheight = 0;
while (strlen(temptext))
{
char tsubtext[M_STRMAX];
int i=0;
for (; i<strlen(temptext); i++)
{
if (temptext[i] == '\n')
{
break;
}
tsubtext[i] = temptext[i];
}
tsubtext[i] = 0;
fontheight += hge->Gfx_RenderTextToTarget(&tex, &tar, _font, tsubtext, 0, fontheight, FONTSYS_TARGETWIDTH, FONTSYS_TARGETHEIGHT);
if (i >= strlen(temptext))
{
break;
}
strcpy(tsubtext, &temptext[i+1]);
strcpy(temptext, tsubtext);
}
// float w = strlen(text) * M_FONTWIDTH;
// float h = lines * M_FONTHEIGHT;
float w = (fontheight / lines) * 0.55f * (maxcharinline+1);
float h = fontheight;
if (w > FONTSYS_TARGETWIDTH)
{
w = FONTSYS_TARGETWIDTH;
}
if (h > FONTSYS_TARGETHEIGHT)
{
h = FONTSYS_TARGETHEIGHT;
}
// float tx = w / FONTSYS_TARGETWIDTH;
// float ty = h / FONTSYS_TARGETHEIGHT;
if (tex)
{
sprite = SpriteItemManager::CreateNullSprite();
SpriteItemManager::SetSpriteData(sprite, tex, 0, 0, w, h, false, false, true);
sprite->SetBlendMode(BLEND_DEFAULT);
}
/*
quad.tex = tex;
quad.blend = BLEND_DEFAULT;
quad.v[0].tx = 0; quad.v[0].ty = 0;
quad.v[1].tx = tx; quad.v[1].ty = 0;
quad.v[2].tx = tx; quad.v[2].ty = ty;
quad.v[3].tx = 0; quad.v[3].ty = ty;
quad.v[0].z = quad.v[1].z = quad.v[2].z = quad.v[3].z = 0;
quad.v[0].x = 0; quad.v[0].y = 0;
quad.v[1].x = w; quad.v[1].y = 0;
quad.v[2].x = w; quad.v[2].y = h;
quad.v[3].x = 0; quad.v[3].y = h;
*/
if (_text)
{
fontsys.push_back(this);
}
signedup = true;
}
void Fontsys::Render(float x, float y, float shadow, float hscale, float vscale, BYTE alignflag)
{
if (!sprite)
{
return;
}
if (shadow)
{
DWORD _col[4];
for (int i=0; i<4; i++)
{
_col[i] = col[i];
}
DWORD __col[4];
for (int i=0; i<4; i++)
{
__col[i] = _col[i] & 0xFF000000;
}
SetColor(__col[0], __col[1], __col[2], __col[3]);
Render(x+shadow*2, y+shadow*2, 0, hscale, vscale, alignflag);
for (int i=0; i<4; i++)
{
__col[i] = (GETA(_col[i]) / 4) << 24 | (_col[i] & 0xFFFFFF);
}
SetColor(__col[0], __col[1], __col[2], __col[3]);
Render(x+shadow, y+shadow, 0, hscale, vscale, alignflag);
Render(x+shadow, y-shadow, 0, hscale, vscale, alignflag);
Render(x-shadow, y-shadow, 0, hscale, vscale, alignflag);
Render(x-shadow, y+shadow, 0, hscale, vscale, alignflag);
SetColor(_col[0], _col[1], _col[2], _col[3]);
}
else
{
SetColor(col[0], col[1], col[2], col[3]);
}
float hotx;
float hoty;
float w = sprite->GetWidth();
float h = sprite->GetHeight();
switch (alignflag & HGETEXT_HORZMASK)
{
case HGETEXT_LEFT:
hotx = 0;
break;
case HGETEXT_CENTER:
hotx = w / 2;
break;
case HGETEXT_RIGHT:
hotx = w;
break;
}
switch (alignflag & HGETEXT_VERTMASK)
{
case HGETEXT_TOP:
hoty = 0;
break;
case HGETEXT_MIDDLE:
hoty = h / 2;
break;
case HGETEXT_BOTTOM:
hoty = h;
break;
}
sprite->SetColor(col[0], col[1], col[2], col[3]);
SpriteItemManager::SetSpriteHotSpot(sprite, hotx, hoty);
// sprite->SetHotSpot(hotx, hoty);
sprite->RenderEx(x, y, 0, hscale, vscale);
/*
float w = quad.v[1].x - quad.v[0].x;
float h = quad.v[2].y - quad.v[0].y;
quad.v[0].col = quad.v[1].col = ucol;
quad.v[2].col = quad.v[3].col = dcol;
quad.v[0].x = x - hext; quad.v[0].y = y - vext;
quad.v[1].x = x + w + hext; quad.v[1].y = y - vext;
quad.v[2].x = x + w + hext; quad.v[2].y = y + h + vext;
quad.v[3].x = x - hext; quad.v[3].y = y + h + vext;
Export::Gfx_RenderQuad(&quad);
quad.v[0].x = x; quad.v[0].y = y;
quad.v[1].x = x + w; quad.v[1].y = y;
quad.v[2].x = x + w; quad.v[2].y = y + h;
quad.v[3].x = x; quad.v[3].y = y + h;
*/
}
void Fontsys::SetColor(DWORD _col, int i)
{
if (i < 0)
{
SetColor(_col, _col, _col, _col);
}
else
{
col[i] = _col;
}
}
void Fontsys::SetColor(DWORD col0, DWORD col1, DWORD col2, DWORD col3)
{
col[0] = col0;
col[1] = col1;
col[2] = col2;
col[3] = col3;
} | [
"CBE7F1F65@b503aa94-de59-8b24-8582-4b2cb17628fa"
]
| [
[
[
1,
413
]
]
]
|
5593f530d453f5ac63243c7823c6d8790ad68f86 | 9a48be80edc7692df4918c0222a1640545384dbb | /Libraries/Boost1.40/libs/wave/test/testwave/testfiles/t_9_004.cpp | d1b07d49268a5d83bccaec8e0ef853044d4830e0 | [
"BSL-1.0"
]
| permissive | fcrick/RepSnapper | 05e4fb1157f634acad575fffa2029f7f655b7940 | a5809843f37b7162f19765e852b968648b33b694 | refs/heads/master | 2021-01-17T21:42:29.537504 | 2010-06-07T05:38:05 | 2010-06-07T05:38:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 936 | cpp | /*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001-2009 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
// Test if invalid or not allowed universal characters are rejected
#define \u00ff ...
//R #line 16 "t_9_004.cpp"
//R ...
\u00ff
//E t_9_004.cpp(19): error: a universal character name cannot designate a character in the basic character set: \u0061
#define \u0061 weird // 0x61 == 'a'
\u0061
//H 10: t_9_004.cpp(12): #define
//H 08: t_9_004.cpp(12): \u00ff=...
//H 01: t_9_004.cpp(12): \u00ff
//H 02: ...
//H 03: ...
//H 18: boost::wave::lexing_exception
| [
"metrix@Blended.(none)"
]
| [
[
[
1,
28
]
]
]
|
2ec827ce3d8a0a3b393cc9274fd1f3b6f2ab29b6 | 9eb49222299e0e92722b38959272c0489d20fab7 | /Option.cpp | 5722f47daf67c59bd7d16a2faf78416bc74a1582 | []
| no_license | kerolldev/copypathx | f86a4bc7f89dff294e012a951bcdba0faa52c437 | 8d76ab1704014fe4e800e69da46ca9bb27971270 | refs/heads/master | 2021-01-10T19:58:53.262997 | 2011-10-28T02:35:32 | 2011-10-28T02:35:32 | 2,509,231 | 2 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 1,323 | cpp | #include "StdAfx.h"
#include "option.h"
///////////////////////////////////////////////////////////////////
//
COption::COption(HMODULE hModule)
{
m_hModule = hModule;
// iniファイルのフルパス名設定
_TCHAR buff[MAX_PATH] = {0};
_TCHAR *pCurrent = NULL;
::ZeroMemory(m_strFile, sizeof(m_strFile));
if(GetModuleFileName(m_hModule, buff,sizeof(buff)) ) {
pCurrent = _tcsrchr(buff, _T('\\') );
_tcsncpy_s(m_strFile, buff, pCurrent - buff + 1);
_tcscat_s(m_strFile, _T("option.ini"));
}
}
///////////////////////////////////////////////////////////////////
//
COption::~COption(void){}
///////////////////////////////////////////////////////////////////
//
void COption::Init(void){}
/*
///////////////////////////////////////////////////////////////////
// int型の設定取得
_TCHAR * pKeyName キー名
int idef デフォルト値
*/
int COption::GetInt(_TCHAR * pKeyName, int idef)
{
return GetPrivateProfileInt(_T("option"), pKeyName, idef, m_strFile);
}
///////////////////////////////////////////////////////////////////
// 文字型の設定取得
void COption::GetString(_TCHAR * pKeyName, _TCHAR * pDefault, _TCHAR * pRetruned, int nSize)
{
GetPrivateProfileString(_T("option"), pKeyName, pDefault, pRetruned, nSize, m_strFile);
} | [
"[email protected]"
]
| [
[
[
1,
45
]
]
]
|
c9c165d5bf05256bdd3a528d6ce838f288f0e6fb | 2dbbca065b62a24f47aeb7ec5cd7a4fd82083dd4 | /OUAN/OUAN/Src/Game/GameObject/GameObjectFog.cpp | 173e538a1e3fccd6728b70403e6e745f1d79efff | []
| no_license | juanjmostazo/once-upon-a-night | 9651dc4dcebef80f0475e2e61865193ad61edaaa | f8d5d3a62952c45093a94c8b073cbb70f8146a53 | refs/heads/master | 2020-05-28T05:45:17.386664 | 2010-10-06T12:49:50 | 2010-10-06T12:49:50 | 38,101,059 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 6,011 | cpp | #include "OUAN_Precompiled.h"
#include "GameObjectFog.h"
#include "../GameWorldManager.h"
using namespace OUAN;
GameObjectFog::GameObjectFog(const std::string& name)
:GameObject(name,GAME_OBJECT_TYPE_FOG)
{
}
GameObjectFog::~GameObjectFog()
{
}
void GameObjectFog::setRenderComponentEntityDreams(RenderComponentEntityPtr pRenderComponentEntity)
{
mRenderComponentEntityDreams=pRenderComponentEntity;
}
void GameObjectFog::setRenderComponentEntityNightmares(RenderComponentEntityPtr pRenderComponentEntity)
{
mRenderComponentEntityNightmares=pRenderComponentEntity;
}
RenderComponentEntityPtr GameObjectFog::getRenderComponentEntityDreams() const
{
return mRenderComponentEntityDreams;
}
RenderComponentEntityPtr GameObjectFog::getRenderComponentEntityNightmares() const
{
return mRenderComponentEntityNightmares;
}
void GameObjectFog::setRenderComponentPositional(RenderComponentPositionalPtr pRenderComponentPositional)
{
mRenderComponentPositional=pRenderComponentPositional;
}
void GameObjectFog::setRenderComponentInitial(RenderComponentInitialPtr pRenderComponentInitial)
{
mRenderComponentInitial=pRenderComponentInitial;
}
RenderComponentPositionalPtr GameObjectFog::getRenderComponentPositional() const
{
return mRenderComponentPositional;
}
RenderComponentInitialPtr GameObjectFog::getRenderComponentInitial() const
{
return mRenderComponentInitial;
}
void GameObjectFog::changeWorldFinished(int newWorld)
{
if (!isEnabled()) return;
switch(newWorld)
{
case DREAMS:
if(mLogicComponent->existsInDreams() && mLogicComponent->existsInNightmares())
{
mRenderComponentEntityDreams->setVisible(true);
mRenderComponentEntityNightmares->setVisible(false);
}
else if(mLogicComponent->existsInDreams()&& !mLogicComponent->existsInNightmares())
{
mRenderComponentEntityDreams->setVisible(true);
}
else if(!mLogicComponent->existsInDreams()&& mLogicComponent->existsInNightmares())
{
mRenderComponentEntityNightmares->setVisible(false);
}
break;
case NIGHTMARES:
if(mLogicComponent->existsInDreams() && mLogicComponent->existsInNightmares())
{
mRenderComponentEntityDreams->setVisible(false);
mRenderComponentEntityNightmares->setVisible(true);
}
else if(mLogicComponent->existsInDreams()&& !mLogicComponent->existsInNightmares())
{
mRenderComponentEntityDreams->setVisible(false);
}
else if(!mLogicComponent->existsInDreams()&& mLogicComponent->existsInNightmares())
{
mRenderComponentEntityNightmares->setVisible(true);
}
break;
default:
break;
}
}
void GameObjectFog::changeWorldStarted(int newWorld)
{
if (!isEnabled()) return;
switch(newWorld)
{
case DREAMS:
break;
case NIGHTMARES:
break;
default:
break;
}
}
void GameObjectFog::changeToWorld(int newWorld, double perc)
{
if (!isEnabled()) return;
switch(newWorld)
{
case DREAMS:
break;
case NIGHTMARES:
break;
default:
break;
}
}
void GameObjectFog::reset()
{
GameObject::reset();
}
bool GameObjectFog::hasPositionalComponent() const
{
return true;
}
RenderComponentPositionalPtr GameObjectFog::getPositionalComponent() const
{
return getRenderComponentPositional();
}
/// Set logic component
void GameObjectFog::setLogicComponent(LogicComponentPtr logicComponent)
{
mLogicComponent=logicComponent;
}
/// return logic component
LogicComponentPtr GameObjectFog::getLogicComponent()
{
return mLogicComponent;
}
void GameObjectFog::setDreamsRender()
{
if (!isEnabled()) return;
if(mLogicComponent->existsInDreams())
{
mRenderComponentEntityDreams->setVisible(true);
mRenderComponentEntityDreams->setDreamsMaterials();
}
if(mLogicComponent->existsInNightmares())
{
mRenderComponentEntityNightmares->setVisible(false);
}
}
void GameObjectFog::setNightmaresRender()
{
if (!isEnabled()) return;
if(mLogicComponent->existsInDreams())
{
mRenderComponentEntityDreams->setVisible(false);
}
if(mLogicComponent->existsInNightmares())
{
mRenderComponentEntityNightmares->setVisible(true);
mRenderComponentEntityNightmares->setNightmaresMaterials();
}
}
void GameObjectFog::setChangeWorldFactor(double factor)
{
if (!isEnabled()) return;
if(mLogicComponent->existsInDreams())
{
mRenderComponentEntityDreams->setChangeWorldFactor(factor);
}
if(mLogicComponent->existsInNightmares())
{
mRenderComponentEntityNightmares->setChangeWorldFactor(factor);
}
}
void GameObjectFog::setChangeWorldRender()
{
if (!isEnabled()) return;
switch(mWorld)
{
case DREAMS:
if(mLogicComponent->existsInDreams())
{
mRenderComponentEntityDreams->setVisible(true);
mRenderComponentEntityDreams->setChangeWorldMaterials();
}
if(mLogicComponent->existsInNightmares())
{
mRenderComponentEntityNightmares->setVisible(false);
}
break;
case NIGHTMARES:
if(mLogicComponent->existsInDreams())
{
mRenderComponentEntityDreams->setVisible(false);
}
if(mLogicComponent->existsInNightmares())
{
mRenderComponentEntityNightmares->setVisible(true);
mRenderComponentEntityNightmares->setChangeWorldMaterials();
}
break;
default:break;
}
}
bool GameObjectFog::hasRenderComponentEntity() const
{
return true;
}
RenderComponentEntityPtr GameObjectFog::getEntityComponent() const
{
return (mWorld==DREAMS)?mRenderComponentEntityDreams:mRenderComponentEntityNightmares;
}
bool GameObjectFog::hasLogicComponent() const
{
return true;
}
LogicComponentPtr GameObjectFog::getLogicComponent() const
{
return mLogicComponent;
}
//-------------------------------------------------------------------------------------------
TGameObjectFogParameters::TGameObjectFogParameters() : TGameObjectParameters()
{
}
TGameObjectFogParameters::~TGameObjectFogParameters()
{
} | [
"wyern1@1610d384-d83c-11de-a027-019ae363d039",
"ithiliel@1610d384-d83c-11de-a027-019ae363d039"
]
| [
[
[
1,
238
],
[
243,
243
],
[
247,
257
]
],
[
[
239,
242
],
[
244,
246
]
]
]
|
a50b364dbabb28d953b50ba64dbef256b6c8967d | 1e5a2230acf1c2edfe8b9d226100438f9374e98a | /src/tabimswitch/InputMethod.cpp | 7f86fcd0d82801c7e7de656b85cc6d256d7fde8e | []
| no_license | lifanxi/tabimswitch | 258860fea291c935d3630abeb61436e20f5dcd09 | f351fc4b04983e59d1ad2b91b85e396e1f4920ed | refs/heads/master | 2020-05-20T10:53:41.990172 | 2008-10-15T11:15:41 | 2008-10-15T11:15:41 | 32,111,854 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,186 | cpp | #pragma warning(disable:4512) // assignment operator could not be generated
#pragma warning(disable:4127) // conditional expression is constant
#include <windows.h>
#include <nsISupports.h>
#include <nsStringApi.h>
#include "InputMethod.h"
#include "NativeCodeLogger.h"
#include "SystemInputMethod.h"
#include "InputMethodContext.h"
#include "KeyboardLayout.h"
#include <sstream>
NS_IMPL_ISUPPORTS1(CInputMethod, IInputMethod)
CInputMethod::CInputMethod()
: m_initialized(false)
, m_enable(false)
, m_convMode(0)
, m_sentMode(0)
#ifdef _USE_IME_FLAGS_FIXUP
, m_isConvModeAlphanum(FALSE)
, m_isSentModeNone(FALSE)
#else
, m_openStatus(FALSE)
#endif
{
LOGGER(LOG_TRACE) << "Created new CInputMethod object " << this << endlog;
}
CInputMethod::~CInputMethod()
{
LOGGER(LOG_TRACE) << "Delete CInputMethod object " << this << endlog;
}
/* readonly attribute AString readableString; */
NS_IMETHODIMP CInputMethod::GetReadableString(nsAString & aReadableString)
{
if ( ! m_initialized )
return NS_OK;
std::wostringstream oss;
oss << (m_enable?'e':'d') << ';'
<< m_keyboardLayout.c_str() << ';'
#ifdef _USE_IME_FLAGS_FIXUP
<< (m_isConvModeAlphanum?'A':'N') << ';'
<< (m_isSentModeNone?'N':'V') << ';'
#else
<< (m_openStatus?'O':'C') << ';'
#endif // _USE_IME_FLAGS_FIXUP
;
struct MaskMapItem { DWORD mask; char openTag; };
static const MaskMapItem convModeMask[] = {
{IME_CMODE_NATIVE, 'N'},
{IME_CMODE_KATAKANA, 'K'},
{IME_CMODE_LANGUAGE, 'L'},
{IME_CMODE_FULLSHAPE, 'F'},
{IME_CMODE_ROMAN, 'R'},
{IME_CMODE_CHARCODE, 'C'},
{IME_CMODE_HANJACONVERT, 'H'},
{IME_CMODE_SOFTKBD, 'S'},
{IME_CMODE_NOCONVERSION, 'n'},
{IME_CMODE_EUDC, 'E'},
{IME_CMODE_SYMBOL, 's'},
{IME_CMODE_FIXED, 'f'}
};
static const MaskMapItem sentModeMask[] = {
{IME_SMODE_PLAURALCLAUSE, 'C'},
{IME_SMODE_SINGLECONVERT, 'S'},
{IME_SMODE_AUTOMATIC, 'A'},
{IME_SMODE_PHRASEPREDICT, 'P'},
{IME_SMODE_CONVERSATION, 'c'}
};
for ( size_t i=0; i<_countof(convModeMask); ++i )
{
if ( (m_convMode & convModeMask[i].mask) == convModeMask[i].mask )
oss << convModeMask[i].openTag;
}
oss << ';';
for ( size_t i=0; i<_countof(sentModeMask); ++i )
{
if ( (m_sentMode & sentModeMask[i].mask) == sentModeMask[i].mask )
oss << sentModeMask[i].openTag;
}
aReadableString = oss.str().c_str();
return NS_OK;
}
/* void useCurrent (); */
NS_IMETHODIMP CInputMethod::UseCurrent()
{
try
{
LOGGER(LOG_TRACE) << "Copy current input method information to " << this << endlog;
SystemInputMethod& sysIME = SystemInputMethod::get();
InputMethodContext& imc = sysIME.getInputMethodContext();
m_enable = imc.isEnabled();
KeyboardLayout& kbl = sysIME.getKeyboardLayout();
m_keyboardLayout = kbl.getCurrent();
#ifndef _USE_IME_FLAGS_FIXUP
imc.getIMEMode(m_convMode, m_sentMode);
m_openStatus = imc.getOpenStatus();
#else // _USE_IME_FLAGS_FIXUP
imc.getIMEMode(m_convMode, m_sentMode, m_isConvModeAlphanum, m_isSentModeNone);
#endif // _USE_IME_FLAGS_FIXUP
m_initialized = true;
return NS_OK;
}
catch ( std::exception& e )
{
LOGGER(LOG_DEBUG) << "Failed to use get Input Method state: " << e.what() << endlog;
}
return NS_ERROR_UNEXPECTED;
}
/* void setAsCurrent (); */
NS_IMETHODIMP CInputMethod::SetAsCurrent()
{
LOGGER(LOG_TRACE) << "Try to use " << this << " as browser input method." << endlog;
if ( ! m_initialized )
return NS_ERROR_NOT_INITIALIZED;
try
{
SystemInputMethod& sysIME = SystemInputMethod::get();
InputMethodContext& imc = sysIME.getInputMethodContext();
if ( m_enable )
imc.enable();
KeyboardLayout& kbl = sysIME.getKeyboardLayout();
kbl.setCurrent(m_keyboardLayout);
#ifdef _USE_IME_FLAGS_FIXUP
imc.setIMEMode(m_convMode, m_sentMode, m_isConvModeAlphanum, m_isSentModeNone);
#else // _USE_IME_FLAGS_FIXUP
imc.setIMEMode(m_convMode, m_sentMode);
imc.setOpenStatus(m_openStatus?true:false);
#endif // _USE_IME_FLAGS_FIXUP
if ( ! m_enable )
imc.disable();
return NS_OK;
}
catch (std::exception& e)
{
LOGGER(LOG_DEBUG) << "Failed to use set Input Method state: " << e.what() << endlog;
}
return NS_ERROR_UNEXPECTED;
}
/* attribute boolean enabled; */
NS_IMETHODIMP CInputMethod::GetEnabled(PRBool *aEnabled)
{
if ( aEnabled == NULL )
return NS_ERROR_NULL_POINTER;
*aEnabled = (m_enable?PR_TRUE:PR_FALSE);
return NS_OK;
}
NS_IMETHODIMP CInputMethod::SetEnabled(PRBool aEnabled)
{
m_enable = (aEnabled?true:false);
return NS_OK;
}
/* attribute AString keyboardLayout; */
NS_IMETHODIMP CInputMethod::GetKeyboardLayout(nsAString & aKeyboardLayout)
{
aKeyboardLayout = m_keyboardLayout.c_str();
return NS_OK;
}
NS_IMETHODIMP CInputMethod::SetKeyboardLayout(const nsAString & aKeyboardLayout)
{
m_keyboardLayout = aKeyboardLayout.BeginReading();
return NS_OK;
}
/* attribute boolean openStatus; */
NS_IMETHODIMP CInputMethod::GetOpenStatus(PRBool *aOpenStatus)
{
if ( aOpenStatus == NULL )
return NS_ERROR_NULL_POINTER;
*aOpenStatus = (m_openStatus?PR_TRUE:PR_FALSE);
return NS_OK;
}
NS_IMETHODIMP CInputMethod::SetOpenStatus(PRBool aOpenStatus)
{
m_openStatus = (aOpenStatus!=PR_FALSE);
return NS_OK;
}
/* attribute long convMode; */
NS_IMETHODIMP CInputMethod::GetConvMode(PRInt32 *aConvMode)
{
if ( NULL == aConvMode )
return NS_ERROR_NULL_POINTER;
*aConvMode = m_convMode;
return NS_OK;
}
NS_IMETHODIMP CInputMethod::SetConvMode(PRInt32 aConvMode)
{
m_convMode = aConvMode;
return NS_OK;
}
/* attribute long sentMode; */
NS_IMETHODIMP CInputMethod::GetSentMode(PRInt32 *aSentMode)
{
if ( NULL == aSentMode )
return NS_ERROR_NULL_POINTER;
*aSentMode = m_sentMode;
return NS_OK;
}
NS_IMETHODIMP CInputMethod::SetSentMode(PRInt32 aSentMode)
{
m_sentMode = aSentMode;
return NS_OK;
}
| [
"ftofficer.zhangc@237747d1-5336-0410-8d3f-2982d197fc3e"
]
| [
[
[
1,
244
]
]
]
|
234e8e6440d7ed00ff4ebe86c5e36d80b61b33e4 | f9acc77870f5a372ee1955e5ac225399d6f841e7 | /lenguajes de Programacion/Archivos cpp Lenguajes/main.cpp | 6dae7d710afe05343779bfa3a949dea7bdbbd828 | []
| no_license | sergiobuj/campari_royal | 3a713cff0fc86837bda4cd69c59f0d8146ffe0e5 | e653b170e5e3ab52e6148242a883b570f216d664 | refs/heads/master | 2016-09-05T21:32:21.092149 | 2011-10-18T22:09:30 | 2011-10-18T22:09:30 | 976,668 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 507 | cpp | #include <cstdlib>
#include <iostream>
#include <iomanip>
using namespace std;
class Rigo{
int filas;
int columnas;
Rigo(int filas,int columnas){
int matrix[filas][columnas];
}
}
int main()
{
int filas;
int columnas;
cout << "ingrese el numero de filas." << endl;
cin>>filas;
cout << "ingrese el numero de columnas." << endl;
cin>>columnas;
Rigo(filas,columnas);
return 0;
}
| [
"[email protected]"
]
| [
[
[
1,
32
]
]
]
|
a99b6401557d7da3e9c3a486bdda8e305a49759a | 7a310d01d1a4361fd06b40a74a2afc8ddc23b4d3 | /src/IniFile.h | d07ca10117123098e75cf5214f2a96a8a2d92990 | []
| no_license | plus7/DonutG | b6fec6111d25b60f9a9ae5798e0ab21bb2fa28f6 | 2d204c36f366d6162eaf02f4b2e1b8bc7b403f6b | refs/heads/master | 2020-06-01T15:30:31.747022 | 2010-08-21T18:51:01 | 2010-08-21T18:51:01 | 767,753 | 1 | 2 | null | null | null | null | SHIFT_JIS | C++ | false | false | 4,814 | h | /**
* @file IniFile.h
* @brief iniファイルの読み書き.
* @note
* MtlPrivateProfile.h を元に作り変えたモノ
*/
#ifndef INIFILE_H
#define INIFILE_H
#pragma once
#include <windows.h>
#include <atlbase.h>
#include <atlapp.h>
#include <atlmisc.h>
#if _ATL_VER >= 0x700
#include <atlsync.h>
#define INISECTION_USE_MUTEX 1 // 0 1 2
#else //+++ atl3で無理やりコンパイルしてみるテスト用.
#define INISECTION_USE_MUTEX 0 // 0 1 2
#endif
///+++ 初期化ファイル(*.ini)の読みこみを行うためのクラス. ※書き込みは これを継承した CIniFileIO で可能にする.
/// @note
/// 注意点(minit) ファイル名はフルパスで与えないとファイルはWindowsディレクトリ辺りに生成される.
class CIniFileI {
public:
CIniFileI(const CString &strFileName, const CString &strSectionName);
//x ~CIniFileI() {;}
virtual void Close();
LONG QueryValue(DWORD& dwValue, LPCTSTR lpszValueName);
LONG QueryValue(int& nValue , LPCTSTR lpszValueName) { return QueryValue(*(DWORD*)&nValue, lpszValueName); }
//LONG QueryValue(LPTSTR szValue, LPCTSTR lpszValueName, DWORD *pdwCount);
LONG QueryString(LPTSTR szValue, LPCTSTR lpszValueName, DWORD *pdwCount);
DWORD GetValue(LPCTSTR lpszValueName, DWORD defalutValue=0);
const CString GetString(LPCTSTR lpszValueName, const TCHAR* pszDefult=0, DWORD dwBufSize = 0);
const CString GetStringUW(LPCTSTR lpszValueName, const TCHAR* pszDefult=0, DWORD dwBufSize = 0);
///+++ セクション名の変更 (多少不細工だが、現状、重要なのはファイル名(の変更)だけなので、これはありにしておく)
void ChangeSectionName(LPCTSTR sectionName) { ATLASSERT(!m_strFileName.IsEmpty()); m_strSectionName = sectionName; }
protected:
enum { cnt_nDefault = 0xABCD0123 }; // magic number
BOOL IsOpen() { return !m_strFileName.IsEmpty(); }
void Open(const CString &strFileName, const CString &strSectionName);
const CString ConvPathNameToAlNumName(const TCHAR* src);
protected:
CString m_strFileName;
CString m_strSectionName;
#if INISECTION_USE_MUTEX == 2 //+++ APIなPrivateProfileを使ってるので無意味かも?だが、念のため mutex で排他制御を試してみる.
CString m_mutexName;
CMutex m_mutex;
CMutexLock* m_mutexLock;
#endif
};
///+++ 初期化ファイル(*.ini)の読み書きを行うためのクラス.
class CIniFileIO : public CIniFileI {
public:
CIniFileIO(const CString &strFileName, const CString &strSectionName = _T(""));
~CIniFileIO() { Close();}
virtual void Close();
LONG SetValue(DWORD dwValue, LPCTSTR lpszValueName);
// LONG SetValue(LPCTSTR lpszValue, LPCTSTR lpszValueName) { return SetString(lpszValue, lpszValueName); }
LONG SetString(LPCTSTR lpszValue, LPCTSTR lpszValueName);
LONG SetStringUW(LPCTSTR lpszValue, LPCTSTR lpszValueName);
LONG DeleteValue(LPCTSTR lpszValueName);
//+++ セクション消去してから書く場合用.
bool DeleteSection();
//+++ iniファイルを.bakにして削除したことにする.
void RemoveFileToBak();
//x void ForceWriteFile(const CString str); //+++ 企画倒れ
private:
#if INISECTION_USE_MUTEX == 1 //+++ APIなPrivateProfileを使ってるので無意味かも?だが、念のため mutex で排他制御を試してみる.
CString m_mutexName;
CMutex m_mutex;
CMutexLock* m_mutexLock;
#endif
};
#ifdef NDEBUG
typedef CIniFileIO CIniFileO;
#else
///+++ 初期化ファイル(*.ini)への書き込みを行うクラス.
class CIniFileO : protected CIniFileIO {
public:
CIniFileO(const CString &strFileName, const CString &strSectionName = _T("")) : CIniFileIO(strFileName, strSectionName) {;}
~CIniFileO() {;}
virtual void Close() { CIniFileIO::Close(); }
LONG SetValue(DWORD dwValue, LPCTSTR lpszValueName) { return CIniFileIO::SetValue(dwValue, lpszValueName); }
//LONG SetValue(LPCTSTR lpszValue, LPCTSTR lpszValueName) { return CIniFileIO::SetValue(lpszValue, lpszValueName); }
LONG SetString(LPCTSTR lpszValue, LPCTSTR lpszValueName) { return CIniFileIO::SetString(lpszValue, lpszValueName); }
LONG SetStringUW(LPCTSTR lpszValue, LPCTSTR lpszValueName) { return CIniFileIO::SetStringUW(lpszValue, lpszValueName); }
LONG DeleteValue(LPCTSTR lpszValueName) { return CIniFileIO::DeleteValue(lpszValueName); }
void ChangeSectionName(LPCTSTR sectionName) { CIniFileI::ChangeSectionName(sectionName); }
//+++ セクション消去してから書く場合用.
bool DeleteSection() { return CIniFileIO::DeleteSection(); }
//+++ iniファイルを.bakにして削除したことにする.
void RemoveFileToBak() { CIniFileIO::RemoveFileToBak(); }
};
#endif
#endif
| [
"[email protected]"
]
| [
[
[
1,
129
]
]
]
|
d799ee9e89eef54e43ae7ddea31e7c24085f526a | 9c62af23e0a1faea5aaa8dd328ba1d82688823a5 | /rl/tags/v0-1/engine/core/src/GameEventManager.cpp | 7b751280abc695e5aa3d95a8988462b77ded6eab | [
"ClArtistic",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
]
| permissive | jacmoe/dsa-hl-svn | 55b05b6f28b0b8b216eac7b0f9eedf650d116f85 | 97798e1f54df9d5785fb206c7165cd011c611560 | refs/heads/master | 2021-04-22T12:07:43.389214 | 2009-11-27T22:01:03 | 2009-11-27T22:01:03 | null | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 4,170 | cpp | /* This source file is part of Rastullahs Lockenpracht.
* Copyright (C) 2003-2005 Team Pantheon. http://www.team-pantheon.de
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the Clarified Artistic License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Clarified Artistic License for more details.
*
* You should have received a copy of the Clarified Artistic License
* along with this program; if not you can get it here
* http://www.jpaulmorrison.com/fbp/artistic2.htm.
*/
#include "GameEventManager.h"
#include "GameAreaTypes.h"
template<> rl::GameEventManager* Ogre::Singleton<rl::GameEventManager>::ms_Singleton = 0;
namespace rl {
GameEventManager& GameEventManager::getSingleton(void)
{
return Ogre::Singleton<GameEventManager>::getSingleton();
}
GameEventManager* GameEventManager::getSingletonPtr(void)
{
return Ogre::Singleton<GameEventManager>::getSingletonPtr();
}
GameEventManager::GameEventManager( ) :
mAreaEventSources(),
mQueuedDeletionSources()
{
}
GameEventManager::~GameEventManager( )
{
GameAreaEventSourceList::iterator it;
for( it = mAreaEventSources.begin(); it != mAreaEventSources.end();++it)
{
GameAreaEventSource* gam = *it;
delete gam->getGameAreaType();
delete gam;
}
mAreaEventSources.clear();
mQueuedDeletionSources.clear();
}
/// @todo Doppelte Aktoren nachnutzen??
void GameEventManager::addSphereAreaListener( Actor* actor, Ogre::Real radius,
GameAreaListener* list, unsigned long queryMask )
{
// Neues Areal erzeugen
GameAreaType* at = new GameSphereAreaType( actor->getWorldPosition(), radius, queryMask );
// Event-Quelle erzeugen
GameAreaEventSource* gam = new GameAreaEventSource( at, actor );
// In die Menge einfügen
mAreaEventSources.insert( gam );
// Und Listener anhängen
gam->addAreaListener( list );
}
void GameEventManager::removeAreaListener( GameAreaListener* list )
{
GameAreaEventSourceList::iterator it;
for( it = mAreaEventSources.begin(); it != mAreaEventSources.end();)
{
GameAreaEventSource* gam = *it;
gam->removeAreaListener( list );
// Sind alle Listener weggeworfen?
if( !gam->hasListeners() )
{
// Später löschen
mQueuedDeletionSources.insert( gam );
}
// Iterieren
++it;
}
}
void GameEventManager::removeAllAreas( Actor* actor )
{
GameAreaEventSourceList::iterator it;
for( it = mAreaEventSources.begin(); it != mAreaEventSources.end();)
{
GameAreaEventSource* gam = *it;
// Ist das der Actor?
if( gam->getActor() == actor )
{
// Später löschen
mQueuedDeletionSources.insert( gam );
}
// Iterieren
++it;
}
}
void GameEventManager::removeQueuedDeletionSources()
{
while(!mQueuedDeletionSources.empty())
{
GameAreaEventSource* gam = *mQueuedDeletionSources.begin();
mAreaEventSources.erase(mAreaEventSources.find(gam));
mQueuedDeletionSources.erase(mQueuedDeletionSources.begin());
// Die Area-Art löschen
delete gam->getGameAreaType();
// Das Objekt löschen
delete gam;
}
}
void GameEventManager::run( Ogre::Real elapsedTime )
{
removeQueuedDeletionSources();
GameAreaEventSourceList::iterator it;
for( it = mAreaEventSources.begin(); it != mAreaEventSources.end();++it)
{
GameAreaEventSource* gam = *it;
gam->performQuery( elapsedTime );
}
}
}
| [
"blakharaz@4c79e8ff-cfd4-0310-af45-a38c79f83013"
]
| [
[
[
1,
135
]
]
]
|
bb9d3e858669435f17d526efb1f4644f5e1ec319 | 94c1c7459eb5b2826e81ad2750019939f334afc8 | /source/SelectStockHsDetail2.cpp | b35fd03e437c92d8b1a72fbbc17f2240e9dd12cc | []
| no_license | wgwang/yinhustock | 1c57275b4bca093e344a430eeef59386e7439d15 | 382ed2c324a0a657ddef269ebfcd84634bd03c3a | refs/heads/master | 2021-01-15T17:07:15.833611 | 2010-11-27T07:06:40 | 2010-11-27T07:06:40 | 37,531,026 | 1 | 3 | null | null | null | null | GB18030 | C++ | false | false | 12,481 | cpp | // SelectStockHsDetail2.cpp : implementation file
//tel:13366898744
#include "stdafx.h"
#include "CTaiShanApp.h"
#include "SelectStockHsDetail2.h"
#include "CSharesDetailDays.h"
#include "MainFrm.h"
#include "CAlertSystem.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#ifdef _UNICODE
#define TOCH(strSource,strDest,nCount) WideCharToMultiByte(CP_ACP,WC_DEFAULTCHAR,(LPCWSTR)strDest,0,strSource,nCount,NULL);
#else
#define TOCH(strSource,strDest,nCount) strcpy(strDest,(LPCSTR)strSource);
#endif
/////////////////////////////////////////////////////////////////////////////
// CSelectStockHsDetail2 dialog
CSelectStockHsDetail2::CSelectStockHsDetail2(CWnd* pParent /*=NULL*/)
: SelectStock(CSelectStockHsDetail2::IDD, pParent)
{
//{{AFX_DATA_INIT(CSelectStockHsDetail2)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CSelectStockHsDetail2::DoDataExchange(CDataExchange* pDX)
{
SelectStock::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSelectStockHsDetail2)
DDX_Control(pDX, IDC_LIST3, m_SelectedStockList);
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSelectStockHsDetail2, SelectStock)
//{{AFX_MSG_MAP(CSelectStockHsDetail2)
ON_BN_CLICKED(IDC_DEL, OnDel)
ON_BN_CLICKED(IDC_CHANGEDAY, OnChangeday)
ON_BN_CLICKED(IDC_ADD2, OnAdd2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
void CSelectStockHsDetail2::OnDel()
{
int nCount=m_SelectedStockList.GetItemCount();
if (nCount<1)
{
if (m_SelectedStockList.GetItemCount()>0)
AfxMessageBox("请选择想要删除的项.");
return;
}
int* nItemArray=new int[nCount];
POSITION pos=m_SelectedStockList.GetFirstSelectedItemPosition();
int i=0;
while(pos)
nItemArray[i++]=m_SelectedStockList.GetNextSelectedItem(pos);
if (nCount>1)
{
if (!QuickSort(nItemArray,0,nCount-1))
{
delete []nItemArray;
return;
}
}
for (i=nCount-1; i>-1; i--)
m_SelectedStockList.DeleteItem(nItemArray[i]);
delete []nItemArray;
}
BOOL CSelectStockHsDetail2::QuickSort(int *nItem, int low, int high)
{
int lo = low;
int hi = high;
if( hi <= lo ) return FALSE;
int pivot=nItem[(low+high)/2];
while( lo <= hi )
{
while (lo<high && nItem[lo]<pivot)
++lo;
while (hi>low && nItem[hi]>pivot)
--hi;
if (lo <= hi)
{
if (nItem[lo]!=nItem[hi])
{
int nTemp=nItem[lo];
nItem[lo]=nItem[hi];
nItem[hi]=nTemp;
}
++lo;
--hi;
}
}
if( low < hi )
QuickSort(nItem, low, hi);
if( lo < high )
QuickSort(nItem, lo, high);
return TRUE;
}
void CSelectStockHsDetail2::OnChangeday()
{
int nCount;
if ((nCount=m_SelectedStockList.GetSelectedCount())<1)
{
if (m_SelectedStockList.GetItemCount()>0)
AfxMessageBox(_T("请选择需要改变天数的项."));
return;
}
CSharesDetailDays dlg;
POSITION pos;
CString strDays;
CString strIncludeToday=_T("否");
char sDays[10];
int nDays;
if (nCount==1)
{
pos=m_SelectedStockList.GetFirstSelectedItemPosition();
int nItem=m_SelectedStockList.GetNextSelectedItem(pos);
strDays=m_SelectedStockList.GetItemText(nItem,2);
TOCH(strDays.GetBuffer(0),sDays,10);
nDays=atoi(sDays);
dlg.SetDays(nDays);
dlg.SetToday(m_SelectedStockList.GetItemText(nItem,3)!=strIncludeToday);
}
if (dlg.DoModal()==IDOK)
{
strDays.Format("%d",dlg.GetDays());
strIncludeToday= dlg.GetToday()==TRUE ? _T("是") : _T("否");
pos=m_SelectedStockList.GetFirstSelectedItemPosition();
while(pos)
{
LV_ITEM lvitem;
lvitem.mask = LVIF_TEXT;
int nItem = m_SelectedStockList.GetNextSelectedItem(pos);
lvitem.iItem = nItem;
lvitem.iSubItem = 2;
lvitem.pszText = strDays.GetBuffer(0);
m_SelectedStockList.SetItem(&lvitem);
lvitem.mask = LVIF_TEXT;
lvitem.iItem = nItem;
lvitem.iSubItem = 3;
lvitem.pszText = strIncludeToday.GetBuffer(0);
m_SelectedStockList.SetItem(&lvitem);
}
}
}
void CSelectStockHsDetail2::OnOK()
{
int nCount=m_SelectedStockList.GetItemCount();
if (nCount>0)
{
m_FileArray.RemoveAll();
CStringArray strTimeArray;
CString strTime;
CString strFile;
CTime t=CTime::GetCurrentTime();
CTimeSpan ts(1,0,0,0);
switch(t.GetDayOfWeek())
{
case 1:
t-=ts;
t-=ts;
strTime.Format("%04d%02d%02d",t.GetYear(),t.GetMonth(),t.GetDay());
strTimeArray.Add(strTime);
t-=ts;
strTime.Format("%04d%02d%02d",t.GetYear(),t.GetMonth(),t.GetDay());
strTimeArray.Add(strTime);
t-=ts;
strTime.Format("%04d%02d%02d",t.GetYear(),t.GetMonth(),t.GetDay());
strTimeArray.Add(strTime);
t-=ts;
strTime.Format("%04d%02d%02d",t.GetYear(),t.GetMonth(),t.GetDay());
strTimeArray.Add(strTime);
break;
case 7:
t-=ts;
strTime.Format("%04d%02d%02d",t.GetYear(),t.GetMonth(),t.GetDay());
strTimeArray.Add(strTime);
t-=ts;
strTime.Format("%04d%02d%02d",t.GetYear(),t.GetMonth(),t.GetDay());
strTimeArray.Add(strTime);
t-=ts;
strTime.Format("%04d%02d%02d",t.GetYear(),t.GetMonth(),t.GetDay());
strTimeArray.Add(strTime);
t-=ts;
strTime.Format("%04d%02d%02d",t.GetYear(),t.GetMonth(),t.GetDay());
strTimeArray.Add(strTime);
break;
case 6:
strTime.Format("%04d%02d%02d",t.GetYear(),t.GetMonth(),t.GetDay());
strTimeArray.Add(strTime);
t-=ts;
strTime.Format("%04d%02d%02d",t.GetYear(),t.GetMonth(),t.GetDay());
strTimeArray.Add(strTime);
t-=ts;
strTime.Format("%04d%02d%02d",t.GetYear(),t.GetMonth(),t.GetDay());
strTimeArray.Add(strTime);
t-=ts;
strTime.Format("%04d%02d%02d",t.GetYear(),t.GetMonth(),t.GetDay());
strTimeArray.Add(strTime);
break;
case 5:
strTime.Format("%04d%02d%02d",t.GetYear(),t.GetMonth(),t.GetDay());
strTimeArray.Add(strTime);
t-=ts;
strTime.Format("%04d%02d%02d",t.GetYear(),t.GetMonth(),t.GetDay());
strTimeArray.Add(strTime);
t-=ts;
strTime.Format("%04d%02d%02d",t.GetYear(),t.GetMonth(),t.GetDay());
strTimeArray.Add(strTime);
t-=ts;
strTime.Format("%04d%02d%02d",t.GetYear(),t.GetMonth(),t.GetDay());
strTimeArray.Add(strTime);
break;
case 4:
strTime.Format("%04d%02d%02d",t.GetYear(),t.GetMonth(),t.GetDay());
strTimeArray.Add(strTime);
t-=ts;
strTime.Format("%04d%02d%02d",t.GetYear(),t.GetMonth(),t.GetDay());
strTimeArray.Add(strTime);
t-=ts;
strTime.Format("%04d%02d%02d",t.GetYear(),t.GetMonth(),t.GetDay());
strTimeArray.Add(strTime);
t-=ts;
t-=ts;
t-=ts;
strTime.Format("%04d%02d%02d",t.GetYear(),t.GetMonth(),t.GetDay());
strTimeArray.Add(strTime);
break;
case 3:
strTime.Format("%04d%02d%02d",t.GetYear(),t.GetMonth(),t.GetDay());
strTimeArray.Add(strTime);
t-=ts;
strTime.Format("%04d%02d%02d",t.GetYear(),t.GetMonth(),t.GetDay());
strTimeArray.Add(strTime);
t-=ts;
t-=ts;
t-=ts;
strTime.Format("%04d%02d%02d",t.GetYear(),t.GetMonth(),t.GetDay());
strTimeArray.Add(strTime);
t-=ts;
strTime.Format("%04d%02d%02d",t.GetYear(),t.GetMonth(),t.GetDay());
strTimeArray.Add(strTime);
break;
case 2:
strTime.Format("%04d%02d%02d",t.GetYear(),t.GetMonth(),t.GetDay());
strTimeArray.Add(strTime);
t-=ts;
t-=ts;
t-=ts;
strTime.Format("%04d%02d%02d",t.GetYear(),t.GetMonth(),t.GetDay());
strTimeArray.Add(strTime);
t-=ts;
strTime.Format("%04d%02d%02d",t.GetYear(),t.GetMonth(),t.GetDay());
strTimeArray.Add(strTime);
t-=ts;
strTime.Format("%04d%02d%02d",t.GetYear(),t.GetMonth(),t.GetDay());
strTimeArray.Add(strTime);
break;
}
CString strDays;
CString strID;
char sDays[3];
int nDays;
for (int i=0;i<nCount;i++)
{
strID=m_SelectedStockList.GetItemText(i,0);
strDays=m_SelectedStockList.GetItemText(i,2);
TOCH(strDays.GetBuffer(0),sDays,3);
nDays=atoi(sDays);
int stkKind = m_SelectedStockList.GetItemData (i);
int nToday=m_SelectedStockList.GetItemText(i,3)==_T("否") ? 1 : 0;
for (int j=nToday;j<(nDays+nToday);j++)
{
strTime=strTimeArray.GetAt(j);
if (CSharesCompute::GetMarketKind(stkKind) == SH_MARKET_EX)
strFile=_T("sh")+strTime+strID+_T(".hst");
else
strFile=_T("sz")+strTime+strID+_T(".hst");
m_FileArray.Add(strFile);
}
}
}
CDialog::OnOK();
}
void CSelectStockHsDetail2::OnCancel()
{
CDialog::OnCancel();
}
void CSelectStockHsDetail2::OnAdd2()
{
SymbolKindArr sSymbolArray;
GetSymbolArray(sSymbolArray);
static CString strDays=_T("1");
static CString strIncludeToday;
CTime t=CTime::GetCurrentTime();
if (t.GetDayOfWeek()>1 && t.GetDayOfWeek()<7 && t.GetHour()>16)
strIncludeToday=_T("是");
else
strIncludeToday=_T("否");
int iItem=0;
int iActualItem;
int nCount=sSymbolArray.GetSize();
for (int i = 0;i<nCount;i++)
{
CString strID=sSymbolArray[i].m_chSymbol ;
CString strName = "";
CReportData* pdt = 0;
if(CMainFrame::m_taiShanDoc ->m_sharesInformation.Lookup(strID.GetBuffer (0),pdt,sSymbolArray[i].m_nSymbolKind))
strName = pdt->name;
if(!pdt)
{
ASSERT(FALSE);
continue;
}
strID.ReleaseBuffer ();
BOOL bFound=FALSE;
int nCount=m_SelectedStockList.GetItemCount();
for (int i=0;i<nCount;i++)
{
if (strID==m_SelectedStockList.GetItemText(i,0))
{
bFound=TRUE;
break;
}
}
if (bFound)
continue;
LV_ITEM lvitem;
lvitem.mask = LVIF_TEXT| LVIF_PARAM;
lvitem.iItem = iItem++;
lvitem.iSubItem = 0;
lvitem.lParam = pdt->kind ;
lvitem.pszText = strID.GetBuffer(0);
iActualItem=m_SelectedStockList.InsertItem(&lvitem);
lvitem.mask = LVIF_TEXT;
lvitem.iItem = iActualItem;
lvitem.iSubItem = 1;
lvitem.pszText = strName.GetBuffer(0);
m_SelectedStockList.SetItem(&lvitem);
lvitem.mask = LVIF_TEXT;
lvitem.iItem = iActualItem;
lvitem.iSubItem = 2;
lvitem.pszText = strDays.GetBuffer(0);
m_SelectedStockList.SetItem(&lvitem);
lvitem.mask = LVIF_TEXT;
lvitem.iItem = iActualItem;
lvitem.iSubItem = 3;
lvitem.pszText = strIncludeToday.GetBuffer(0);
m_SelectedStockList.SetItem(&lvitem);
}
}
void CSelectStockHsDetail2::GetSymbolArray(SymbolKindArr &sSymbolArray)
{
CArrayStockType typeArr;
CTaiShanDoc *m_pDoc = CMainFrame::m_taiShanDoc ;
int n ;
CString s;
SharesNameArr3 stockInfo;
int nCurTab=((CTabCtrl*)GetDlgItem(IDC_TAB_TYPE))->GetCurSel();
if(nCurTab>0)
{
n=m_StockTypeList.GetSelectedCount( ) ;
int temp=m_StockTypeList.GetNextItem( -1, LVNI_SELECTED) ;
int index=0;
while(temp>=0)
{
stockInfo.m_nType =m_StockTypeList.GetItemData(temp);
m_StockTypeList.GetItemText( temp, 0, stockInfo.m_sSymbol, 18);
temp=m_StockTypeList.GetNextItem( temp, LVNI_SELECTED) ;
typeArr.Add(stockInfo);
}
m_StockTypeList.SetSelectionMark(-1 );
}
else
{
n=m_StockList.GetSelectedCount( ) ;
int temp=m_StockList.GetNextItem( -1, LVNI_SELECTED) ;
while(temp>=0)
{
int nKind=m_StockList.GetItemData(temp);
stockInfo.m_nType =-1-nKind;
m_StockList.GetItemText( temp, 1, stockInfo.m_sSymbol, 18);
temp=m_StockList.GetNextItem( temp, LVNI_SELECTED) ;
typeArr.Add(stockInfo);
}
m_StockList.SetSelectionMark(-1 );
}
CAlertSystem::GetSymbolArray(typeArr, sSymbolArray);
}
BOOL CSelectStockHsDetail2::OnInitDialog()
{
SelectStock::OnInitDialog();
CRect rc;
m_SelectedStockList.GetWindowRect(&rc);
m_SelectedStockList.InsertColumn(0,_T("代码"),LVCFMT_LEFT,rc.Width() * 1/6,0);
m_SelectedStockList.InsertColumn(1,_T("名称"),LVCFMT_LEFT,rc.Width() * 1/3,1);
m_SelectedStockList.InsertColumn(2,_T("下载最近天数"),LVCFMT_LEFT,rc.Width() * 1/4,2);
m_SelectedStockList.InsertColumn(3,_T("包括今天"),LVCFMT_LEFT,rc.Width() * 1/4,3);
DWORD dwNewStyle=m_SelectedStockList.GetExtendedStyle()|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES;
m_SelectedStockList.SetExtendedStyle(dwNewStyle);
CenterWindow();
return TRUE;
}
| [
"[email protected]"
]
| [
[
[
1,
465
]
]
]
|
2948d5d0d5358ecee87067805f69b9dfdf2eabf5 | f55665c5faa3d79d0d6fe91fcfeb8daa5adf84d0 | /Depend/MyGUI/MyGUIEngine/include/MyGUI_WidgetInput.h | 329e1547740fb68244c94fe02344bfbe76179e17 | []
| no_license | lxinhcn/starworld | 79ed06ca49d4064307ae73156574932d6185dbab | 86eb0fb8bd268994454b0cfe6419ffef3fc0fc80 | refs/heads/master | 2021-01-10T07:43:51.858394 | 2010-09-15T02:38:48 | 2010-09-15T02:38:48 | 47,859,019 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 11,096 | h | /*!
@file
@author Albert Semenov
@date 11/2007
*/
/*
This file is part of MyGUI.
MyGUI is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
MyGUI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __MYGUI_WIDGET_INPUT_H__
#define __MYGUI_WIDGET_INPUT_H__
#include "MyGUI_Prerequest.h"
#include "MyGUI_Macros.h"
#include "MyGUI_WidgetDefines.h"
#include "MyGUI_WidgetToolTip.h"
#include "MyGUI_MouseButton.h"
#include "MyGUI_KeyCode.h"
#include "MyGUI_MaskPickInfo.h"
#include "MyGUI_Delegate.h"
namespace MyGUI
{
/**
General information about creating delegate for event :
@example "Delegate usage"
@code
void anyFunc(...) { } // global function
class AnyClass
{
public:
static void anyStaticMethod(...) { } // static class method
void anyMethod(...) { } // class method
};
AnyClass anyObject; // class instance
@endcode
delegate creating:
@code
eventAny = MyGUI::newDelegate(anyFunc);
eventAny = MyGUI::newDelegate(AnyClass::anyStaticMethod);
eventAny = MyGUI::newDelegate(&anyObject, &AnyClass::anyMethod);
@endcode
*/
// делегаты для событий виджета
typedef delegates::CMultiDelegate1<Widget*> EventHandle_WidgetVoid;
typedef delegates::CMultiDelegate2<Widget*, Widget*> EventHandle_WidgetWidget;
typedef delegates::CMultiDelegate2<Widget*, bool> EventHandle_WidgetBool;
typedef delegates::CMultiDelegate2<Widget*, int> EventHandle_WidgetInt;
typedef delegates::CMultiDelegate2<Widget*, size_t> EventHandle_WidgetSizeT;
typedef delegates::CMultiDelegate3<Widget*, int, int> EventHandle_WidgetIntInt;
typedef delegates::CMultiDelegate4<Widget*, int, int, MouseButton> EventHandle_WidgetIntIntButton;
typedef delegates::CMultiDelegate2<Widget*, KeyCode> EventHandle_WidgetKeyCode;
typedef delegates::CMultiDelegate3<Widget*, KeyCode, Char> EventHandle_WidgetKeyCodeChar;
typedef delegates::CMultiDelegate2<Widget*, const ToolTipInfo& > EventHandle_WidgetToolTip;
class MYGUI_EXPORT WidgetInput
{
public:
WidgetInput();
virtual ~WidgetInput() { }
/** Set need tool tip mode flag. Enable this if you need tool tip events for widget */
void setNeedToolTip(bool _value)
{
mNeedToolTip = _value;
}
/** Get need tool tip mode flag */
bool getNeedToolTip() const
{
return mNeedToolTip;
}
/** Set mouse pointer for this widget */
void setPointer(const std::string& _value)
{
mPointer = _value;
}
/** Get mouse pointer name for this widget */
const std::string& getPointer() const
{
return mPointer;
}
/** Set need key focus flag */
void setNeedKeyFocus(bool _value)
{
mNeedKeyFocus = _value;
}
/** Is need key focus
If disable this widget won't be reacting on keyboard at all.\n
Enabled (true) by default.
*/
bool getNeedKeyFocus() const
{
return mNeedKeyFocus;
}
/** Set need mouse focus flag */
void setNeedMouseFocus(bool _value)
{
mNeedMouseFocus = _value;
}
/** Is need mouse focus
If disable this widget won't be reacting on mouse at all.\n
Enabled (true) by default.
*/
bool getNeedMouseFocus() const
{
return mNeedMouseFocus;
}
/** Set inherits mode flag
This mode makes all child widgets pickable even if widget don't
need mouse focus (was set setNeedKeyFocus(false) ).\n
Disabled (false) by default.
*/
void setInheritsPick(bool _value)
{
mInheritsPick = _value;
}
/** Get inherits mode flag */
bool getInheritsPick() const
{
return mInheritsPick;
}
/** Set picking mask for widget */
void setMaskPick(const std::string& _filename);
/** Set picking mask for widget */
void setMaskPick(const MaskPickInfo& _info);
bool isMaskPickInside(const IntPoint& _point, const IntCoord& _coord) const;
bool getRootMouseFocus() const
{
return mRootMouseFocus;
}
bool getRootKeyFocus() const
{
return mRootKeyFocus;
}
/** Event : Widget lost mouse focus.\n
signature : void method(MyGUI::Widget* _sender, MyGUI::Widget* _new)\n
@param _sender widget that called this event
@param _new widget with mouse focus or nullptr
*/
EventHandle_WidgetWidget eventMouseLostFocus;
/** Event : Widget got mouse focus.\n
signature : void method(MyGUI::Widget* _sender, MyGUI::Widget* _old)\n
@param _sender widget that called this event
@param _old widget with mouse focus or nullptr
*/
EventHandle_WidgetWidget eventMouseSetFocus;
/** Event : Widget mouse move with captured widget.\n
signature : void method(MyGUI::Widget* _sender, int _left, int _top)\n
@param _sender widget that called this event
@param _left - pointer position
@param _top - pointer position
*/
EventHandle_WidgetIntInt eventMouseDrag;
/** Event : Mouse move over widget.\n
signature : void method(MyGUI::Widget* _sender, int _left, int _top)\n
@param _sender widget that called this event
@param _left - pointer position
@param _top - pointer position
*/
EventHandle_WidgetIntInt eventMouseMove;
/** Event : Mouse wheel over widget.\n
signature : void method(MyGUI::Widget* _sender, int _rel)\n
@param _sender widget that called this event
@param _rel relative wheel position
*/
EventHandle_WidgetInt eventMouseWheel;
/** Event : Mouse button pressed.\n
signature : void method(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id)\n
@param _sender widget that called this event
@param _left - pointer position
@param _top - pointer position
@param _id Mouse button id
*/
EventHandle_WidgetIntIntButton eventMouseButtonPressed;
/** Event : Mouse button released.\n
signature : void method(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id)\n
@param _sender widget that called this event
@param _left - pointer position
@param _top - pointer position
@param _id Mouse button id
*/
EventHandle_WidgetIntIntButton eventMouseButtonReleased;
/** Event : Mouse button pressed and released.\n
signature : void method(MyGUI::Widget* _sender)
@param _sender widget that called this event
*/
EventHandle_WidgetVoid eventMouseButtonClick;
/** Event : Mouse button double click.\n
signature : void method(MyGUI::Widget* _sender)
@param _sender widget that called this event
*/
EventHandle_WidgetVoid eventMouseButtonDoubleClick;
/** Event : Widget lost keyboard focus.\n
signature : void method(MyGUI::Widget* _sender, MyGUI::Widget* _new)\n
@param _sender widget that called this event
@param _new widget with keyboard focus or nullptr
*/
EventHandle_WidgetWidget eventKeyLostFocus;
/** Event : Widget got keyboard focus.\n
signature : void method(MyGUI::Widget* _sender, MyGUI::Widget* _old)\n
@param _sender widget that called this event
@param _old widget with keyboard focus or nullptr
*/
EventHandle_WidgetWidget eventKeySetFocus;
/** Event : Key pressed.\n
signature : void method(MyGUI::Widget* _sender, MyGUI::KeyCode _key, MyGUI::Char _char)\n
@param _sender widget that called this event
@param _key code
@param _char of pressed symbol (for multilanguage applications)
*/
EventHandle_WidgetKeyCodeChar eventKeyButtonPressed;
/** Event : Key released.\n
signature : void method(MyGUI::Widget* _sender, MyGUI::KeyCode _key)\n
@param _sender widget that called this event
@param _key code
*/
EventHandle_WidgetKeyCode eventKeyButtonReleased;
/** Event : Root widget changed mouse focus.\n
info : this event sends only to root widget\n
signature : void method(MyGUI::Widget* _sender, bool _focus);
@param _sender widget that called this event
@param _focus Is widget got mouse focus.
*/
EventHandle_WidgetBool eventRootMouseChangeFocus;
/** Event : Root widget changed keyboard focus.\n
info : this event sends only to root widget\n
signature : void method(MyGUI::Widget* _sender, bool _focus);
@param _sender widget that called this event
@param _focus Is widget got keyboard focus.
*/
EventHandle_WidgetBool eventRootKeyChangeFocus;
/** Event : Event about changing tooltip state.\n
signature : void method(MyGUI::Widget* _sender, const MyGUI::ToolTipInfo& _info);
@param _sender widget that called this event
@param _info about tooltip
*/
EventHandle_WidgetToolTip eventToolTip;
/*internal:*/
void _riseMouseLostFocus(Widget* _new);
void _riseMouseSetFocus(Widget* _old);
void _riseMouseDrag(int _left, int _top);
void _riseMouseMove(int _left, int _top);
void _riseMouseWheel(int _rel);
void _riseMouseButtonPressed(int _left, int _top, MouseButton _id);
void _riseMouseButtonReleased(int _left, int _top, MouseButton _id);
void _riseMouseButtonClick();
void _riseMouseButtonDoubleClick();
void _riseKeyLostFocus(Widget* _new);
void _riseKeySetFocus(Widget* _old);
void _riseKeyButtonPressed(KeyCode _key, Char _char);
void _riseKeyButtonReleased(KeyCode _key);
void _riseMouseChangeRootFocus(bool _focus);
void _riseKeyChangeRootFocus(bool _focus);
void _setRootMouseFocus(bool _value)
{
mRootMouseFocus = _value;
}
void _setRootKeyFocus(bool _value)
{
mRootKeyFocus = _value;
}
protected:
virtual void onMouseLostFocus(Widget* _new) { }
virtual void onMouseSetFocus(Widget* _old) { }
virtual void onMouseDrag(int _left, int _top) { }
virtual void onMouseMove(int _left, int _top) { }
virtual void onMouseWheel(int _rel) { }
virtual void onMouseButtonPressed(int _left, int _top, MouseButton _id) { }
virtual void onMouseButtonReleased(int _left, int _top, MouseButton _id) { }
virtual void onMouseButtonClick() { }
virtual void onMouseButtonDoubleClick() { }
virtual void onKeyLostFocus(Widget* _new) { }
virtual void onKeySetFocus(Widget* _old) { }
virtual void onKeyButtonPressed(KeyCode _key, Char _char) { }
virtual void onKeyButtonReleased(KeyCode _key) { }
virtual void onMouseChangeRootFocus(bool _focus) { }
virtual void onKeyChangeRootFocus(bool _focus) { }
private:
std::string mPointer;
MaskPickInfo mOwnMaskPickInfo;
bool mNeedToolTip;
bool mInheritsPick;
bool mNeedKeyFocus;
bool mNeedMouseFocus;
bool mRootMouseFocus;
bool mRootKeyFocus;
};
} // namespace MyGUI
#endif // __MYGUI_WIDGET_INPUT_H__
| [
"albertclass@a94d7126-06ea-11de-b17c-0f1ef23b492c"
]
| [
[
[
1,
337
]
]
]
|
4e9b9c66860c6cfd365667faebbd46160d754c9a | 74e7667ad65cbdaa869c6e384fdd8dc7e94aca34 | /MicroFrameworkPK_v4_1/BuildOutput/public/Release/Client/stubs/spot_native_Microsoft_SPOT_ResourceUtility_mshl.cpp | 0a77e3b10f9809fb7b17349271a264c38d1a6f92 | [
"BSD-3-Clause",
"OpenSSL",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
]
| permissive | gezidan/NETMF-LPC | 5093ab223eb9d7f42396344ea316cbe50a2f784b | db1880a03108db6c7f611e6de6dbc45ce9b9adce | refs/heads/master | 2021-01-18T10:59:42.467549 | 2011-06-28T08:11:24 | 2011-06-28T08:11:24 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,597 | cpp | //-----------------------------------------------------------------------------
//
// ** DO NOT EDIT THIS FILE! **
// This file was generated by a tool
// re-running the tool will overwrite this file.
//
//-----------------------------------------------------------------------------
#include "spot_native.h"
#include "spot_native_Microsoft_SPOT_ResourceUtility.h"
using namespace Microsoft::SPOT;
HRESULT Library_spot_native_Microsoft_SPOT_ResourceUtility::GetObject___STATIC__OBJECT__mscorlibSystemResourcesResourceManager__mscorlibSystemEnum( CLR_RT_StackFrame& stack )
{
TINYCLR_HEADER(); hr = S_OK;
{
UNSUPPORTED_TYPE param0;
TINYCLR_CHECK_HRESULT( Interop_Marshal_UNSUPPORTED_TYPE( stack, 0, param0 ) );
UNSUPPORTED_TYPE param1;
TINYCLR_CHECK_HRESULT( Interop_Marshal_UNSUPPORTED_TYPE( stack, 1, param1 ) );
UNSUPPORTED_TYPE retVal = ResourceUtility::GetObject( param0, param1, hr );
TINYCLR_CHECK_HRESULT( hr );
SetResult_UNSUPPORTED_TYPE( stack, retVal );
}
TINYCLR_NOCLEANUP();
}
HRESULT Library_spot_native_Microsoft_SPOT_ResourceUtility::set_CurrentUICultureInternal___STATIC__VOID__mscorlibSystemGlobalizationCultureInfo( CLR_RT_StackFrame& stack )
{
TINYCLR_HEADER(); hr = S_OK;
{
UNSUPPORTED_TYPE param0;
TINYCLR_CHECK_HRESULT( Interop_Marshal_UNSUPPORTED_TYPE( stack, 0, param0 ) );
ResourceUtility::set_CurrentUICultureInternal( param0, hr );
TINYCLR_CHECK_HRESULT( hr );
}
TINYCLR_NOCLEANUP();
}
| [
"[email protected]"
]
| [
[
[
1,
45
]
]
]
|
fd71a96f839690eca5e053a67178e7257475a23c | 942b88e59417352fbbb1a37d266fdb3f0f839d27 | /src/filefinder.hxx | b24b2115efb826604515e21bbfbf23fbd8a90abc | [
"BSD-2-Clause"
]
| permissive | take-cheeze/ARGSS... | 2c1595d924c24730cc714d017edb375cfdbae9ef | 2f2830e8cc7e9c4a5f21f7649287cb6a4924573f | refs/heads/master | 2016-09-05T15:27:26.319404 | 2010-12-13T09:07:24 | 2010-12-13T09:07:24 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,054 | hxx | //////////////////////////////////////////////////////////////////////////////////
/// ARGSS - Copyright (c) 2009 - 2010, Alejandro Marzini (vgvgf)
/// All rights reserved.
///
/// Redistribution and use in source and binary forms, with or without
/// modification, are permitted provided that the following conditions are met:
/// * Redistributions of source code must retain the above copyright
/// notice, this list of conditions and the following disclaimer.
/// * Redistributions in binary form must reproduce the above copyright
/// notice, this list of conditions and the following disclaimer in the
/// documentation and/or other materials provided with the distribution.
///
/// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY
/// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
/// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
/// DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
/// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
/// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
/// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
/// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
/// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
/// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//////////////////////////////////////////////////////////////////////////////////
#ifndef _FILEFINDER_HXX_
#define _FILEFINDER_HXX_
#include <stdint.h>
#include <string>
#include <vector>
namespace FileFinder
{
void Init();
std::vector< uint8_t > const& FindImage(std::string const& name);
std::vector< uint8_t > const& FindMusic(std::string const& name);
std::vector< uint8_t > const& FindFont(std::string const& name);
std::vector< uint8_t > const& FindFile(std::string const& name);
} // namespace FileFinder
#endif // _FILEFINDER_HXX_
| [
"takeshi@takeshi-laptop.(none)",
"[email protected]"
]
| [
[
[
1,
24
],
[
27,
27
],
[
41,
41
]
],
[
[
25,
26
],
[
28,
40
],
[
42,
42
]
]
]
|
715d230933da348e478515aed5bed12e3428d7d5 | 07e88c109af86db6aa3194cbb71c41d449f1a805 | /Code/m3alpsshapinglightt0/joint.cpp | 7eabe5b1204126144023dc7871df1f772859c707 | []
| no_license | jbongard/ISCS | 2a7fe528140aa24631022807c5af34d7442a122d | a7f7196a2a729564bd033abc13cdf4acb172edfb | refs/heads/master | 2016-09-05T08:44:10.630025 | 2011-08-17T15:31:58 | 2011-08-17T15:31:58 | 2,222,304 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 6,270 | cpp | #include "stdio.h"
#include "iostream"
#include "fstream"
using namespace std;
#ifndef _JOINT_CPP
#define _JOINT_CPP
#include "joint.h"
#include "robot.h"
extern double ROBOT_STARFISH_JOINT_RANGE;
extern double ROBOT_STARFISH_MOTOR_SPEED;
extern double ROBOT_STARFISH_MOTOR_STRENGTH;
JOINT::JOINT(void) {
containerRobot = NULL;
obj1Index = -1;
obj2Index = -1;
physicalized = false;
}
JOINT::JOINT(ROBOT *cR, int o1Index, int o2Index,
double posX, double posY, double posZ,
double axX, double axY, double axZ,
double maxF, double maxE) {
containerRobot = cR;
obj1Index = o1Index;
obj2Index = o2Index;
x = posX;
y = posY;
z = posZ;
axisX = axX;
axisY = axY;
axisZ = axZ;
maxFlexion = maxF;
maxExtension = maxE;
physicalized = false;
proprioceptiveSensor = NULL;
}
JOINT::JOINT(ROBOT *cR, JOINT *other) {
containerRobot = cR;
obj1Index = other->obj1Index;
obj2Index = other->obj2Index;
x = other->x;
y = other->y;
z = other->z;
axisX = other->axisX;
axisY = other->axisY;
axisZ = other->axisZ;
maxFlexion = other->maxFlexion;
maxExtension = other->maxExtension;
physicalized = false;
if ( other->proprioceptiveSensor )
proprioceptiveSensor = new PROP_SENSOR();
else
proprioceptiveSensor = NULL;
}
JOINT::JOINT(ROBOT *cR, ifstream *inFile) {
containerRobot = cR;
(*inFile) >> obj1Index >> obj2Index;
(*inFile) >> x >> y >> z;
(*inFile) >> axisX >> axisY >> axisZ;
(*inFile) >> maxFlexion >> maxExtension;
int containsProprioceptiveSensor;
(*inFile) >> containsProprioceptiveSensor;
physicalized = false;
if ( containsProprioceptiveSensor )
proprioceptiveSensor = new PROP_SENSOR;
else
proprioceptiveSensor = NULL;
}
JOINT::~JOINT(void) {
if ( physicalized )
Remove_From_Simulator();
if ( containerRobot )
containerRobot = NULL;
if ( proprioceptiveSensor ) {
delete proprioceptiveSensor;
proprioceptiveSensor = NULL;
}
}
void JOINT::Make_Incorporeal(void) {
// Remove the joint from the physical simulator.
if ( !physicalized )
return;
Remove_From_Simulator();
Sensors_Reset();
}
void JOINT::Make_Physical(dWorldID world) {
// Add the joint to the physical simulator.
// Already added to the simulator.
if ( physicalized )
return;
// If the robot doesn't exist...
if ( !containerRobot )
return;
// If the first object doesn't exist...
if ( !containerRobot->objects[obj1Index] )
return;
// If the second object doesn't exist...
if ( !containerRobot->objects[obj2Index] )
return;
physicalized = true;
joint = dJointCreateHinge(world,0);
dJointAttach( joint,
containerRobot->objects[obj1Index]->body,
containerRobot->objects[obj2Index]->body);
dJointSetHingeAnchor(joint,x,y,z);
dJointSetHingeAxis(joint,axisX,axisY,axisZ);
dJointSetHingeParam(joint,dParamLoStop,
Degrees_To_Radians(maxFlexion));
dJointSetHingeParam(joint,dParamHiStop,
Degrees_To_Radians(maxExtension));
}
void JOINT::Move(double motorNeuronValue) {
// This joint will apply torque to the two objects
// it connects, which will cause the robot (of which
// this joint is a part) to move.
dJointSetHingeParam(joint,dParamFMax,ROBOT_STARFISH_MOTOR_STRENGTH); // Motor force
// Scale the motor neuron's value, which is in the range
// [-1,1], to the joint's range of motion.
double desiredAngle = Scale(motorNeuronValue,-1,+1,
-ROBOT_STARFISH_JOINT_RANGE,
+ROBOT_STARFISH_JOINT_RANGE);
// printf("%3.3f %3.3f\n",motorNeuronValue,desiredAngle);
// desiredAngle = Degrees_To_Radians( desiredAngle );
double actualAngle = dJointGetHingeAngle(joint);
double actualRate = dJointGetHingeAngleRate(joint);
double ks = ROBOT_STARFISH_MOTOR_SPEED; // Motor speed
double kd = 0.0;
double error = ks*(desiredAngle - actualAngle) -
kd*actualRate;
dJointSetHingeParam(joint,dParamVel,error);
}
void JOINT::Move(double deltaX, double deltaY, double deltaZ) {
// The robot (of which this joint is a part)
// is being moved by the user.
x = x + deltaX;
y = y + deltaY;
z = z + deltaZ;
}
void JOINT::Save(ofstream *outFile) {
(*outFile) << obj1Index << " " << obj2Index << " \n";
(*outFile) << x << " " << y << " " << z << " \n";
(*outFile) << axisX << " " << axisY << " " << axisZ << " \n";
(*outFile) << maxFlexion << " " << maxExtension << " \n";
if ( proprioceptiveSensor )
(*outFile) << "1 \n";
else
(*outFile) << "0 \n";
}
void JOINT::Sensor_Proprioceptive_Add(void) {
if ( !proprioceptiveSensor ) {
proprioceptiveSensor = new PROP_SENSOR();
}
}
int JOINT::Sensors_Number_Of(void) {
if ( proprioceptiveSensor )
return( 1 );
else
return( 0 );
}
void JOINT::Sensors_Update(void) {
// If the robot isn't physicalized, it cannot generate
// sensor values.
if ( !physicalized )
return;
if ( proprioceptiveSensor ) {
double actualAngle = dJointGetHingeAngle(joint);
actualAngle = Radians_To_Degrees(actualAngle);
actualAngle = Scale( actualAngle,
-ROBOT_STARFISH_JOINT_RANGE,
+ROBOT_STARFISH_JOINT_RANGE,
-1,1);
// Sensor values are always scaled to [-1,1]
proprioceptiveSensor->Update(actualAngle);
}
}
// --------------------- Private methods --------------------
double JOINT::Degrees_To_Radians(double degrees) {
return( (3.14159*degrees)/180.0 );
}
double JOINT::Radians_To_Degrees(double radians) {
return( (180.0*radians)/3.14159 );
}
double JOINT::Rand(double min, double max) {
// Return a random value in [min,max] with
// a uniform distribution.
double zeroToOne = ((double)rand()) / RAND_MAX;
double returnVal;
returnVal = (zeroToOne * (max-min)) + min;
return returnVal;
}
void JOINT::Remove_From_Simulator(void) {
dJointDestroy(joint);
joint = NULL;
physicalized = false;
}
double JOINT::Scale(double value, double min1, double max1,
double min2, double max2) {
if ( min1 < 0 )
value = value - min1;
else
value = value + min1;
return( (value*(max2-min2)/(max1-min1)) + min2 );
}
void JOINT::Sensors_Reset(void) {
if ( proprioceptiveSensor )
proprioceptiveSensor->Reset();
}
#endif
| [
"[email protected]"
]
| [
[
[
1,
320
]
]
]
|
51f4847085ccd5746405393293fade72213a5c75 | c3531ade6396e9ea9c7c9a85f7da538149df2d09 | /Param/src/Numerical/solver.cpp | 6fb35bc4c08236b8b84ef5ff77f71d2b003fac17 | []
| no_license | feengg/MultiChart-Parameterization | ddbd680f3e1c2100e04c042f8f842256f82c5088 | 764824b7ebab9a3a5e8fa67e767785d2aec6ad0a | refs/heads/master | 2020-03-28T16:43:51.242114 | 2011-04-19T17:18:44 | 2011-04-19T17:18:44 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 386 | cpp | #include "solver.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
Solver::Solver(int nb_variables) {
nb_variables_ = nb_variables ;
variable_ = new SolverVariable[nb_variables] ;
}
Solver::~Solver() {
delete[] variable_ ;
variable_ = 0 ;
} | [
"[email protected]"
]
| [
[
[
1,
16
]
]
]
|
daf59dea3a18d5da7c42a5984bb3f73a742b15fa | a352572bc22d863f72020118d8f5b94c69521f3f | /pa2/src/JointTree.cpp | a949fb5b60054b47de9a75733ac83d421f2e7e7c | []
| no_license | mjs513/cs4620-1 | 63345a9a7774279d8d6ab63b1af64d65b14b0ae3 | 419da5df73c5a9c34387b3cd2f7f3c542e0a3c3e | refs/heads/master | 2021-01-10T06:45:47.809907 | 2010-12-10T20:59:46 | 2010-12-10T20:59:46 | 46,994,144 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 597 | cpp | /*
* JointTree.cpp
*
* Created on: Oct 22, 2010
* Author: Roberto
*/
#include "JointTree.h"
#include <algorithm>
JointTree::JointTree(Joint *root)
: _root(root)
{
_iterate(_root);
}
Joint* JointTree::root() const
{
return _root;
}
const std::vector<Joint*>& JointTree::joints() const
{
return _joints;
}
void JointTree::_iterate(Joint *joint)
{
joint->setId(_joints.size());
_joints.push_back(joint);
for(std::vector<Joint*>::const_iterator i = joint->children().begin(); i != joint->children().end(); ++i) {
_iterate(*i);
}
}
| [
"robertorfischer@ebbd4279-5267-bd07-7df5-4dafc36418f6"
]
| [
[
[
1,
38
]
]
]
|
34329ce957bd50c9ceb57d753333f791fae7926f | 216398e30aca5f7874edfb8b72a13f95c22fbb5a | /Healthcare/Client/Test/Network.cpp | d959f84ae4c9ac0ec09f3e0989fd7cdb49b454eb | []
| no_license | markisme/healthcare | 791813ac6ac811870f3f28d1d31c3d5a07fb2fa2 | 7ab5a959deba02e7637da02a3f3c681548871520 | refs/heads/master | 2021-01-10T07:18:42.195610 | 2009-09-09T13:00:10 | 2009-09-09T13:00:10 | 35,987,767 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 6,111 | cpp | #include "stdafx.h"
#include "Network.h"
#include "CommonType.h"
Network Network::_instance;
Network::Network() :
_isSuccessAuth( FALSE ),
_isHost( FALSE )
{
}
Network::~Network()
{
}
void Network::Init( int clientPort, std::string ip, int serverPort )
{
//
RakNetStatistics *rss;
_client=RakNetworkFactory::GetRakPeerInterface();
_client->AllowConnectionResponseIPMigration(false);
//
SocketDescriptor socketDescriptor( clientPort, 0 );
_client->Startup(1,30,&socketDescriptor, 1);
_client->SetOccasionalPing(true);
BOOL b = _client->Connect(ip.c_str(), serverPort, "Rumpelstiltskin", (int) strlen("Rumpelstiltskin"));
if (!b)
{
exit(1);
}
}
void Network::Uninit()
{
//
Sleep(500);
//
_client->Shutdown(300);
RakNetworkFactory::DestroyRakPeerInterface(_client);
}
bool Network::ProcPacket()
{
if( _client == NULL )
{
return FALSE;
}
Sleep(30);
Packet* p;
p = _client->Receive();
if (p==0)
return FALSE;
RakNet::BitStream inStream( p->data, p->length, false );
unsigned char packetIdentifier;
inStream.Read( packetIdentifier );
switch (packetIdentifier)
{
case S2CH_LOGIN_RES:
{
// 패킷 읽기
int isSuccessAuth;
inStream.Read( isSuccessAuth );
int isHost;
inStream.Read( isHost );
int userNo;
inStream.Read( userNo );
// 데이터 저장
Network::GetInstance()._isSuccessAuth = isSuccessAuth;
Network::GetInstance()._isHost = isHost;
_myUserNo = userNo;
}
break;
case S2H_GET_USERINFO_LIST_RES:
{
// 기존 데이터 초기화
_userList.clear();
// 패킷 읽기
int count = 0;
inStream.Read( count );
for( int num = 0; num < count; num++ )
{
UserInfo userInfo;
inStream.Read( userInfo._userNo );
inStream.Read( userInfo._userName );
inStream.Read( userInfo._age );
inStream.Read( userInfo._sex );
inStream.Read( userInfo._tall );
inStream.Read( userInfo._weight );
inStream.Read( userInfo._blood );
inStream.Read( userInfo._tel );
inStream.Read( userInfo._pic );
_userList.push_back( userInfo );
}
// 데이터 갱신
return TRUE;
}
break;
case S2CH_GET_USERDATA_LIST_RES:
{
// 기존 데이터 초기화
_userDataList.clear();
// 패킷 읽기
int count = 0;
inStream.Read( count );
for( int num = 0; num < count; num++ )
{
UserData userData;
inStream.Read( userData._year );
inStream.Read( userData._month );
inStream.Read( userData._day );
inStream.Read( userData._hour );
inStream.Read( userData._min );
inStream.Read( userData._value );
inStream.Read( userData._temp );
_userDataList.push_back( userData );
}
// 데이터 갱신
return TRUE;
}
break;
case S2H_CLIENT_DATA_RES:
{
// 패킷 읽기
int userNo = 0;
inStream.Read( userNo );
int count = 0;
inStream.Read( count );
DataList dataList;
for( int num = 0; num < count; num++ )
{
PacketData data;
inStream.Read( data );
dataList.push_back( data );
}
// 기존 데이터 초기화
DataList & buf = _dataMap[ userNo ];
buf.clear();
// 데이터 갱신
_dataMap[ userNo ] = dataList;
}
break;
default:
{
}
break;
}
_client->DeallocatePacket(p);
}
void Network::ReqLoginSend( std::string id, std::string pass )
{
RakNet::BitStream outBuffer;
outBuffer.Write( (unsigned char)MessageType::CH2S_LOGIN );
outBuffer.Write( id );
outBuffer.Write( pass );
RakPeerInterface * client = Network::GetInstance().GetClient();
if( client )
{
client->Send(&outBuffer, HIGH_PRIORITY, RELIABLE_ORDERED, 0, UNASSIGNED_SYSTEM_ADDRESS, true);
}
}
void Network::ReqClientDataSend()
{
RakNet::BitStream outBuffer;
outBuffer.Write( (unsigned char)MessageType::C2S_CLIENT_DATA );
outBuffer.Write( _myUserNo );
//
DataList & dataLIst = Network::GetInstance().GetDataList( _myUserNo );
//
int count = dataLIst.size();
outBuffer.Write( count );
for( int num = 0; num < count; num++ )
{
PacketData data = dataLIst[ num ];
outBuffer.Write( data );
}
RakPeerInterface * client = Network::GetInstance().GetClient();
if( client )
{
client->Send(&outBuffer, HIGH_PRIORITY, RELIABLE_ORDERED, 0, UNASSIGNED_SYSTEM_ADDRESS, true);
}
}
void Network::ReqGetUserInfoSend()
{
RakNet::BitStream outBuffer;
outBuffer.Write( (unsigned char)MessageType::H2S_GET_USERINFO_LIST );
RakPeerInterface * client = Network::GetInstance().GetClient();
if( client )
{
client->Send(&outBuffer, HIGH_PRIORITY, RELIABLE_ORDERED, 0, UNASSIGNED_SYSTEM_ADDRESS, true);
}
}
void Network::ReqGetUserDataSend( int userNo )
{
RakNet::BitStream outBuffer;
outBuffer.Write( (unsigned char)MessageType::CH2S_GET_USERDATA_LIST );
outBuffer.Write( userNo );
RakPeerInterface * client = Network::GetInstance().GetClient();
if( client )
{
client->Send(&outBuffer, HIGH_PRIORITY, RELIABLE_ORDERED, 0, UNASSIGNED_SYSTEM_ADDRESS, true);
}
}
void Network::ReqAddUserDataSend( UserData & userData )
{
RakNet::BitStream outBuffer;
outBuffer.Write( (unsigned char)MessageType::C2S_ADD_USERDATA );
outBuffer.Write( _myUserNo );
outBuffer.Write( userData._year );
outBuffer.Write( userData._month );
outBuffer.Write( userData._day );
outBuffer.Write( userData._hour );
outBuffer.Write( userData._min );
outBuffer.Write( userData._value );
outBuffer.Write( userData._temp );
RakPeerInterface * client = Network::GetInstance().GetClient();
if( client )
{
client->Send(&outBuffer, HIGH_PRIORITY, RELIABLE_ORDERED, 0, UNASSIGNED_SYSTEM_ADDRESS, true);
}
}
int Network::GetIndexForUserNo( int userNo )
{
int count = _userList.size();
for( int num = 0; num < count; num++ )
{
UserInfo & userInfo = _userList[ num ];
int curUserNo = atoi( userInfo._userNo.c_str() );
if( curUserNo == userNo )
{
return num;
}
}
return -1;
} | [
"naidzzang@cc586c1e-b153-0410-8069-cfc9d6f95ec9"
]
| [
[
[
1,
276
]
]
]
|
24e15168f70fbc85e1c89a0b5fc3013bc9adf3a5 | 5860c104a52cff6d0cc6ce7597cf0e34bfe3cf98 | /plugin/idaswig.cpp | a8e997efcd0bdda749b49378f351686827308c25 | []
| no_license | spoonm/idarub | 7a712e8274176df5481721a99dfaddefa0f6dd2e | 89c9863a18d8705a85c958518296d129427b09b3 | refs/heads/master | 2021-01-22T18:23:07.313066 | 2011-12-05T12:16:50 | 2011-12-05T12:16:50 | 2,686,803 | 13 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 68 | cpp | // ghettoness
#include "idaswig.h"
#include "idaswig_wrap.cpp"
| [
"[email protected]"
]
| [
[
[
1,
4
]
]
]
|
faeab51294efebcaca64f63484eb5bb634ce0e70 | bf278d024957a59c6f1efb36aa8b76069eff22a5 | /dlglog.cpp | df79d5a48defc368dc1b147e01b2bbd8efcf0ce6 | [
"BSD-3-Clause",
"BSL-1.0"
]
| permissive | byplayer/yamy | b84741fe738f5abac33edb934951ea91454fb4ca | 031e57e81caeb881a0a219e2a11429795a59d845 | refs/heads/master | 2020-05-22T12:46:55.516053 | 2010-05-19T15:57:38 | 2010-05-19T15:57:38 | 3,842,546 | 6 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,860 | cpp | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// dlglog.cpp
#include "misc.h"
#include "mayu.h"
#include "mayurc.h"
#include "registry.h"
#include "windowstool.h"
#include "msgstream.h"
#include "layoutmanager.h"
#include "dlglog.h"
#include <windowsx.h>
///
class DlgLog : public LayoutManager
{
HWND m_hwndEdit; ///
HWND m_hwndTaskTray; /// tasktray window
LOGFONT m_lf; ///
HFONT m_hfontOriginal; ///
HFONT m_hfont; ///
tomsgstream *m_log; ///
public:
///
DlgLog(HWND i_hwnd)
: LayoutManager(i_hwnd),
m_hwndEdit(GetDlgItem(m_hwnd, IDC_EDIT_log)),
m_hwndTaskTray(NULL),
m_hfontOriginal(GetWindowFont(m_hwnd)),
m_hfont(NULL) {
}
/// WM_INITDIALOG
BOOL wmInitDialog(HWND /* i_focus */, LPARAM i_lParam) {
DlgLogData *dld = reinterpret_cast<DlgLogData *>(i_lParam);
m_log = dld->m_log;
m_hwndTaskTray = dld->m_hwndTaskTray;
// set icons
setSmallIcon(m_hwnd, IDI_ICON_mayu);
setBigIcon(m_hwnd, IDI_ICON_mayu);
// set font
Registry::read(MAYU_REGISTRY_ROOT, _T("logFont"), &m_lf,
loadString(IDS_logFont));
m_hfont = CreateFontIndirect(&m_lf);
SetWindowFont(m_hwndEdit, m_hfont, false);
// resize
RECT rc;
CHECK_TRUE( GetClientRect(m_hwnd, &rc) );
wmSize(0, (short)rc.right, (short)rc.bottom);
// debug level
bool isChecked =
(IsDlgButtonChecked(m_hwnd, IDC_CHECK_detail) == BST_CHECKED);
m_log->setDebugLevel(isChecked ? 1 : 0);
// set layout manager
typedef LayoutManager LM;
addItem(GetDlgItem(m_hwnd, IDOK),
LM::ORIGIN_LEFT_EDGE, LM::ORIGIN_BOTTOM_EDGE,
LM::ORIGIN_LEFT_EDGE, LM::ORIGIN_BOTTOM_EDGE);
addItem(GetDlgItem(m_hwnd, IDC_EDIT_log),
LM::ORIGIN_LEFT_EDGE, LM::ORIGIN_TOP_EDGE,
LM::ORIGIN_RIGHT_EDGE, LM::ORIGIN_BOTTOM_EDGE);
addItem(GetDlgItem(m_hwnd, IDC_BUTTON_clearLog),
LM::ORIGIN_LEFT_EDGE, LM::ORIGIN_BOTTOM_EDGE,
LM::ORIGIN_LEFT_EDGE, LM::ORIGIN_BOTTOM_EDGE);
addItem(GetDlgItem(m_hwnd, IDC_BUTTON_changeFont),
LM::ORIGIN_LEFT_EDGE, LM::ORIGIN_BOTTOM_EDGE,
LM::ORIGIN_LEFT_EDGE, LM::ORIGIN_BOTTOM_EDGE);
addItem(GetDlgItem(m_hwnd, IDC_CHECK_detail),
LM::ORIGIN_LEFT_EDGE, LM::ORIGIN_BOTTOM_EDGE,
LM::ORIGIN_LEFT_EDGE, LM::ORIGIN_BOTTOM_EDGE);
restrictSmallestSize();
// enlarge window
GetWindowRect(m_hwnd, &rc);
rc.bottom += (rc.bottom - rc.top) * 3;
MoveWindow(m_hwnd, rc.left, rc.top,
rc.right - rc.left, rc.bottom - rc.top, true);
return TRUE;
}
/// WM_DESTROY
BOOL wmDestroy() {
// unset font
SetWindowFont(m_hwndEdit, m_hfontOriginal, false);
DeleteObject(m_hfont);
// unset icons
unsetBigIcon(m_hwnd);
unsetSmallIcon(m_hwnd);
return TRUE;
}
/// WM_CLOSE
BOOL wmClose() {
ShowWindow(m_hwnd, SW_HIDE);
return TRUE;
}
/// WM_COMMAND
BOOL wmCommand(int /* i_notifyCode */, int i_id, HWND /* i_hwndControl */) {
switch (i_id) {
case IDOK: {
ShowWindow(m_hwnd, SW_HIDE);
return TRUE;
}
case IDC_BUTTON_clearLog: {
Edit_SetSel(m_hwndEdit, 0, Edit_GetTextLength(m_hwndEdit));
Edit_ReplaceSel(m_hwndEdit, _T(""));
SendMessage(m_hwndTaskTray, WM_APP_dlglogNotify,
DlgLogNotify_logCleared, 0);
return TRUE;
}
case IDC_BUTTON_changeFont: {
CHOOSEFONT cf;
memset(&cf, 0, sizeof(cf));
cf.lStructSize = sizeof(cf);
cf.hwndOwner = m_hwnd;
cf.lpLogFont = &m_lf;
cf.Flags = CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS;
if (ChooseFont(&cf)) {
HFONT hfontNew = CreateFontIndirect(&m_lf);
SetWindowFont(m_hwnd, hfontNew, true);
DeleteObject(m_hfont);
m_hfont = hfontNew;
Registry::write(MAYU_REGISTRY_ROOT, _T("logFont"), m_lf);
}
return TRUE;
}
case IDC_CHECK_detail: {
bool isChecked =
(IsDlgButtonChecked(m_hwnd, IDC_CHECK_detail) == BST_CHECKED);
m_log->setDebugLevel(isChecked ? 1 : 0);
return TRUE;
}
}
return FALSE;
}
};
//
#ifdef MAYU64
INT_PTR CALLBACK dlgLog_dlgProc(HWND i_hwnd, UINT i_message,
#else
BOOL CALLBACK dlgLog_dlgProc(HWND i_hwnd, UINT i_message,
#endif
WPARAM i_wParam, LPARAM i_lParam)
{
DlgLog *wc;
getUserData(i_hwnd, &wc);
if (!wc)
switch (i_message) {
case WM_INITDIALOG:
wc = setUserData(i_hwnd, new DlgLog(i_hwnd));
return wc->wmInitDialog(reinterpret_cast<HWND>(i_wParam), i_lParam);
}
else
switch (i_message) {
case WM_COMMAND:
return wc->wmCommand(HIWORD(i_wParam), LOWORD(i_wParam),
reinterpret_cast<HWND>(i_lParam));
case WM_CLOSE:
return wc->wmClose();
case WM_DESTROY:
return wc->wmDestroy();
case WM_NCDESTROY:
delete wc;
return TRUE;
default:
return wc->defaultWMHandler(i_message, i_wParam, i_lParam);
}
return FALSE;
}
| [
"[email protected]"
]
| [
[
[
1,
184
]
]
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.