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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
b463e41312a16d70592cb4be3f176fcb0efa902f | a84b013cd995870071589cefe0ab060ff3105f35 | /webdriver/branches/chrome_extension/third_party/gecko-1.9.0.11/win32/include/nsIDOMHTMLMetaElement.h | f5a2d88528aff3fcad13e1114aaeb033a89695c4 | [
"Apache-2.0"
] | permissive | vdt/selenium | 137bcad58b7184690b8785859d77da0cd9f745a0 | 30e5e122b068aadf31bcd010d00a58afd8075217 | refs/heads/master | 2020-12-27T21:35:06.461381 | 2009-08-18T15:56:32 | 2009-08-18T15:56:32 | 13,650,409 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,531 | h | /*
* DO NOT EDIT. THIS FILE IS GENERATED FROM e:/xr19rel/WINNT_5.2_Depend/mozilla/dom/public/idl/html/nsIDOMHTMLMetaElement.idl
*/
#ifndef __gen_nsIDOMHTMLMetaElement_h__
#define __gen_nsIDOMHTMLMetaElement_h__
#ifndef __gen_nsIDOMHTMLElement_h__
#include "nsIDOMHTMLElement.h"
#endif
/* For IDL files that don't want to include root IDL files. */
#ifndef NS_NO_VTABLE
#define NS_NO_VTABLE
#endif
/* starting interface: nsIDOMHTMLMetaElement */
#define NS_IDOMHTMLMETAELEMENT_IID_STR "a6cf908a-15b3-11d2-932e-00805f8add32"
#define NS_IDOMHTMLMETAELEMENT_IID \
{0xa6cf908a, 0x15b3, 0x11d2, \
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 }}
/**
* The nsIDOMHTMLMetaElement interface is the interface to a [X]HTML
* meta element.
*
* For more information on this interface please see
* http://www.w3.org/TR/DOM-Level-2-HTML/
*
* @status FROZEN
*/
class NS_NO_VTABLE NS_SCRIPTABLE nsIDOMHTMLMetaElement : public nsIDOMHTMLElement {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOMHTMLMETAELEMENT_IID)
/* attribute DOMString content; */
NS_SCRIPTABLE NS_IMETHOD GetContent(nsAString & aContent) = 0;
NS_SCRIPTABLE NS_IMETHOD SetContent(const nsAString & aContent) = 0;
/* attribute DOMString httpEquiv; */
NS_SCRIPTABLE NS_IMETHOD GetHttpEquiv(nsAString & aHttpEquiv) = 0;
NS_SCRIPTABLE NS_IMETHOD SetHttpEquiv(const nsAString & aHttpEquiv) = 0;
/* attribute DOMString name; */
NS_SCRIPTABLE NS_IMETHOD GetName(nsAString & aName) = 0;
NS_SCRIPTABLE NS_IMETHOD SetName(const nsAString & aName) = 0;
/* attribute DOMString scheme; */
NS_SCRIPTABLE NS_IMETHOD GetScheme(nsAString & aScheme) = 0;
NS_SCRIPTABLE NS_IMETHOD SetScheme(const nsAString & aScheme) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIDOMHTMLMetaElement, NS_IDOMHTMLMETAELEMENT_IID)
/* Use this macro when declaring classes that implement this interface. */
#define NS_DECL_NSIDOMHTMLMETAELEMENT \
NS_SCRIPTABLE NS_IMETHOD GetContent(nsAString & aContent); \
NS_SCRIPTABLE NS_IMETHOD SetContent(const nsAString & aContent); \
NS_SCRIPTABLE NS_IMETHOD GetHttpEquiv(nsAString & aHttpEquiv); \
NS_SCRIPTABLE NS_IMETHOD SetHttpEquiv(const nsAString & aHttpEquiv); \
NS_SCRIPTABLE NS_IMETHOD GetName(nsAString & aName); \
NS_SCRIPTABLE NS_IMETHOD SetName(const nsAString & aName); \
NS_SCRIPTABLE NS_IMETHOD GetScheme(nsAString & aScheme); \
NS_SCRIPTABLE NS_IMETHOD SetScheme(const nsAString & aScheme);
/* Use this macro to declare functions that forward the behavior of this interface to another object. */
#define NS_FORWARD_NSIDOMHTMLMETAELEMENT(_to) \
NS_SCRIPTABLE NS_IMETHOD GetContent(nsAString & aContent) { return _to GetContent(aContent); } \
NS_SCRIPTABLE NS_IMETHOD SetContent(const nsAString & aContent) { return _to SetContent(aContent); } \
NS_SCRIPTABLE NS_IMETHOD GetHttpEquiv(nsAString & aHttpEquiv) { return _to GetHttpEquiv(aHttpEquiv); } \
NS_SCRIPTABLE NS_IMETHOD SetHttpEquiv(const nsAString & aHttpEquiv) { return _to SetHttpEquiv(aHttpEquiv); } \
NS_SCRIPTABLE NS_IMETHOD GetName(nsAString & aName) { return _to GetName(aName); } \
NS_SCRIPTABLE NS_IMETHOD SetName(const nsAString & aName) { return _to SetName(aName); } \
NS_SCRIPTABLE NS_IMETHOD GetScheme(nsAString & aScheme) { return _to GetScheme(aScheme); } \
NS_SCRIPTABLE NS_IMETHOD SetScheme(const nsAString & aScheme) { return _to SetScheme(aScheme); }
/* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
#define NS_FORWARD_SAFE_NSIDOMHTMLMETAELEMENT(_to) \
NS_SCRIPTABLE NS_IMETHOD GetContent(nsAString & aContent) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetContent(aContent); } \
NS_SCRIPTABLE NS_IMETHOD SetContent(const nsAString & aContent) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetContent(aContent); } \
NS_SCRIPTABLE NS_IMETHOD GetHttpEquiv(nsAString & aHttpEquiv) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetHttpEquiv(aHttpEquiv); } \
NS_SCRIPTABLE NS_IMETHOD SetHttpEquiv(const nsAString & aHttpEquiv) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetHttpEquiv(aHttpEquiv); } \
NS_SCRIPTABLE NS_IMETHOD GetName(nsAString & aName) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetName(aName); } \
NS_SCRIPTABLE NS_IMETHOD SetName(const nsAString & aName) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetName(aName); } \
NS_SCRIPTABLE NS_IMETHOD GetScheme(nsAString & aScheme) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetScheme(aScheme); } \
NS_SCRIPTABLE NS_IMETHOD SetScheme(const nsAString & aScheme) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetScheme(aScheme); }
#if 0
/* Use the code below as a template for the implementation class for this interface. */
/* Header file */
class nsDOMHTMLMetaElement : public nsIDOMHTMLMetaElement
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMHTMLMETAELEMENT
nsDOMHTMLMetaElement();
private:
~nsDOMHTMLMetaElement();
protected:
/* additional members */
};
/* Implementation file */
NS_IMPL_ISUPPORTS1(nsDOMHTMLMetaElement, nsIDOMHTMLMetaElement)
nsDOMHTMLMetaElement::nsDOMHTMLMetaElement()
{
/* member initializers and constructor code */
}
nsDOMHTMLMetaElement::~nsDOMHTMLMetaElement()
{
/* destructor code */
}
/* attribute DOMString content; */
NS_IMETHODIMP nsDOMHTMLMetaElement::GetContent(nsAString & aContent)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsDOMHTMLMetaElement::SetContent(const nsAString & aContent)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute DOMString httpEquiv; */
NS_IMETHODIMP nsDOMHTMLMetaElement::GetHttpEquiv(nsAString & aHttpEquiv)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsDOMHTMLMetaElement::SetHttpEquiv(const nsAString & aHttpEquiv)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute DOMString name; */
NS_IMETHODIMP nsDOMHTMLMetaElement::GetName(nsAString & aName)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsDOMHTMLMetaElement::SetName(const nsAString & aName)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute DOMString scheme; */
NS_IMETHODIMP nsDOMHTMLMetaElement::GetScheme(nsAString & aScheme)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsDOMHTMLMetaElement::SetScheme(const nsAString & aScheme)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* End of implementation class template. */
#endif
#endif /* __gen_nsIDOMHTMLMetaElement_h__ */
| [
"simon.m.stewart@07704840-8298-11de-bf8c-fd130f914ac9"
] | [
[
[
1,
168
]
]
] |
3dc8cfb9be30f5a3a4c3b6c83ce61e236f94648c | cfb009d5d5bb4b10515436815b6af0c6e4ca79cc | /src/paintservers/color.cpp | a5fe4002b2ffc2543eeb5f926de8cb3b473e0851 | [] | no_license | johanvdb/wxCairoSVG | 5efd56134665c300c05b7f2d6a5aae29e6043efb | 4d305a92bb6c8ca59b6ca79b1efac21a8da757f9 | refs/heads/master | 2021-01-01T18:17:13.933247 | 2011-06-03T21:07:11 | 2011-06-03T21:07:11 | 1,814,269 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,409 | cpp | /*
* color.cpp
*
* Created on: Apr 11, 2011
* Author: johanvdb
*/
#include "wx/svg/cairo/paintservers/color.h"
#include "wx/log.h"
#include "wx/tokenzr.h"
IMPLEMENT_ABSTRACT_CLASS(wxCairoSVGColor, wxCairoSVGPaintServer)
wxCairoSVGColor::wxCairoSVGColor(wxCairoSVGContext* context): wxCairoSVGPaintServer(context) {
}
wxCairoSVGColor::~wxCairoSVGColor() {
}
void wxCairoSVGColor::Init() {
m_ok = false;
m_r = 0;
m_g = 0;
m_b = 0;
}
unsigned char wxCairoSVGColor::ParseHex(wxChar c) {
if ((c >= '0') && (c <= '9')) {
return c - '0';
}
if ((c >= 'A') && (c <= 'F')) {
return c - 'A' + 10;
}
if ((c >= 'a') && (c <= 'f')) {
return c - 'a' + 10;
}
return 0;
}
void wxCairoSVGColor::SetSource(cairo_t* cairo_image) {
double r = (double) m_r / 255;
double g = (double) m_g / 255;
double b = (double) m_b / 255;
wxLogTrace(_T("svg"), _T("wxCairoSVGColor::SetSource %s %f %f %f"), (m_ok)? _T("true"):_T("false"), r, g, b);
if (m_ok)
cairo_set_source_rgb(cairo_image, r, g, b);
}
void wxCairoSVGColor::SetColor(const wxString& value) {
int r, b, g = 0;
wxLogTrace(_T("svg"), _T("Set color ") + value + _T(" (%f %f %f)"), m_r, m_g, m_b);
}
void wxCairoSVGColor::SetColor(int r, int g, int b) {
m_r = r;
m_g = g;
m_b = b;
m_ok = true;
}
double wxCairoSVGColor::GetRed() {
return m_r;
}
double wxCairoSVGColor::GetGreen() {
return m_g;
}
double wxCairoSVGColor::GetBlue() {
return m_b;
}
wxCairoSVGColor* wxCairoSVGColor::FromString(wxCairoSVGContext* context, const wxString& value) {
int r = 0; int g = 0; int b = 0;
if (FromString(value, &r, &g, &b)) {
wxCairoSVGColor* color = new wxCairoSVGColor(context);
color->SetColor(r, g, b);
return color;
} else {
return NULL;
}
}
bool wxCairoSVGColor::FromString(const wxString& value, int *r_out, int *g_out, int *b_out) {
bool ok = false;
int r = 0; int b = 0; int g = 0;
if (value.StartsWith(_T("#")) && value.length() == 7) {
r = (ParseHex(value[1]) << 4) + ParseHex(value[2]);
g = (ParseHex(value[3]) << 4) + ParseHex(value[4]);
b = (ParseHex(value[5]) << 4) + ParseHex(value[6]);
ok = true;
}
else if (value.StartsWith(_T("#")) && value.length() == 4) {
r = (ParseHex(value[1]) << 4) + ParseHex(value[1]);
g = (ParseHex(value[2]) << 4) + ParseHex(value[2]);
b = (ParseHex(value[3]) << 4) + ParseHex(value[3]);
ok = true;
}
else if (value == _T("black")) { r = 0; g = 0; b = 0; ok = true; }
else if (value == _T("silver")) { r = 192; g = 192; b = 192; ok = true; }
else if (value == _T("gray")) { r = 128; g = 128; b = 128; ok = true; }
else if (value == _T("white")) { r = 255; g = 255; b = 255; ok = true; }
else if (value == _T("maroon")) { r = 128; g = 0; b = 0; ok = true; }
else if (value == _T("red")) { r = 255; g = 0; b = 0; ok = true; }
else if (value == _T("purple")) { r = 128; g = 0; b = 128; ok = true; }
else if (value == _T("fuchsia")) { r = 255; g = 0; b = 255; ok = true; }
else if (value == _T("green")) { r = 0; g = 128; b = 0; ok = true; }
else if (value == _T("lime")) { r = 0; g = 255; b = 0; ok = true; }
else if (value == _T("olive")) { r = 128; g = 128; b = 0; ok = true; }
else if (value == _T("yellow")) { r = 255; g = 255; b = 0; ok = true; }
else if (value == _T("navy")) { r = 0; g = 0; b = 128; ok = true; }
else if (value == _T("blue")) { r = 0; g = 0; b = 255; ok = true; }
else if (value == _T("teal")) { r = 0; g = 128; b = 128; ok = true; }
else if (value == _T("aqua")) { r = 0; g = 255; b = 255; ok = true; }
else if (value.Matches(_T("rgb(*,*,*)"))) {
wxArrayString values = wxStringTokenize(value.Mid(4, value.Length() - 5), _T(","));
double r_double, g_double, b_double;
values[0].ToDouble(&r_double);
values[1].ToDouble(&g_double);
values[2].ToDouble(&b_double);
if (values[0].Contains(_T("%"))) r = 256.0 * r_double / 100.0; else r = (int) r_double;
if (values[0].Contains(_T("%"))) g = 256.0 * r_double / 100.0; else g = (int) g_double;
if (values[0].Contains(_T("%"))) b = 256.0 * r_double / 100.0; else b = (int) b_double;
ok = true;
}
if (ok) {
*r_out = r;
*g_out = g;
*b_out = b;
}
wxLogTrace(_T("svg"), _T("wxCairoSVGColor::FromString %s %d %d %d"), value.c_str(), r, g, b);
return ok;
}
bool wxCairoSVGColor::IsOk() {
return m_ok;
}
| [
"[email protected]"
] | [
[
[
1,
142
]
]
] |
b0640f791fc261403f62a6c6265e409de11f3b37 | 12203ea9fe0801d613bbb2159d4f69cab3c84816 | /Export/cpp/windows/obj/include/nme/display/MovieClip.h | a40776b8605a8849c407d9fe8bbccbaa0469b26c | [] | no_license | alecmce/haxe_game_of_life | 91b5557132043c6e9526254d17fdd9bcea9c5086 | 35ceb1565e06d12c89481451a7bedbbce20fa871 | refs/heads/master | 2016-09-16T00:47:24.032302 | 2011-10-10T12:38:14 | 2011-10-10T12:38:14 | 2,547,793 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,891 | h | #ifndef INCLUDED_nme_display_MovieClip
#define INCLUDED_nme_display_MovieClip
#ifndef HXCPP_H
#include <hxcpp.h>
#endif
#include <nme/display/Sprite.h>
HX_DECLARE_CLASS2(nme,display,DisplayObject)
HX_DECLARE_CLASS2(nme,display,DisplayObjectContainer)
HX_DECLARE_CLASS2(nme,display,IBitmapDrawable)
HX_DECLARE_CLASS2(nme,display,InteractiveObject)
HX_DECLARE_CLASS2(nme,display,MovieClip)
HX_DECLARE_CLASS2(nme,display,Sprite)
HX_DECLARE_CLASS2(nme,events,EventDispatcher)
HX_DECLARE_CLASS2(nme,events,IEventDispatcher)
namespace nme{
namespace display{
class MovieClip_obj : public ::nme::display::Sprite_obj{
public:
typedef ::nme::display::Sprite_obj super;
typedef MovieClip_obj OBJ_;
MovieClip_obj();
Void __construct();
public:
static hx::ObjectPtr< MovieClip_obj > __new();
static Dynamic __CreateEmpty();
static Dynamic __Create(hx::DynamicArray inArgs);
~MovieClip_obj();
HX_DO_RTTI;
static void __boot();
static void __register();
void __Mark(HX_MARK_PARAMS);
::String __ToString() const { return HX_CSTRING("MovieClip"); }
virtual ::String nmeGetType( );
Dynamic nmeGetType_dyn();
bool enabled; /* REM */
int currentFrame; /* REM */
int framesLoaded; /* REM */
int totalFrames; /* REM */
int mCurrentFrame; /* REM */
int mTotalFrames; /* REM */
virtual int GetTotalFrames( );
Dynamic GetTotalFrames_dyn();
virtual int GetCurrentFrame( );
Dynamic GetCurrentFrame_dyn();
virtual Void gotoAndPlay( Dynamic frame,::String scene);
Dynamic gotoAndPlay_dyn();
virtual Void gotoAndStop( Dynamic frame,::String scene);
Dynamic gotoAndStop_dyn();
virtual Void play( );
Dynamic play_dyn();
virtual Void stop( );
Dynamic stop_dyn();
};
} // end namespace nme
} // end namespace display
#endif /* INCLUDED_nme_display_MovieClip */
| [
"[email protected]"
] | [
[
[
1,
72
]
]
] |
1f4bfded21ba18159ef8161e8b039d8159b56826 | 9678f45d262f11bc0e4c814f73e3210cce592c8c | /include/External/ExcelFormat/BasicExcel.hpp | 72d029a1cab60a6f38c27bf6d8e76e5a432bf0eb | [] | no_license | tuxmark5/RSys | 9aaa210fd780a01c2b973321beec85089c801773 | a92a8645e76eab4ac53beedb22f5e8428393db60 | refs/heads/master | 2021-01-23T22:07:09.246031 | 2011-12-27T22:35:08 | 2011-12-27T22:35:08 | 2,438,907 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 64,717 | hpp | // Created by Yap Chun Wei
// Version 1.0 (20 April 2006)
// Version 1.1 (22 April 2006)
// - Fixed bugs with compound files not being able to write files more than 65535 bytes.
// - Fixed bugs with reading and writing to Excel files containing many strings.
// Version 1.2 (30 April 2006)
// - Added operator<< to pass BasicExcelCell to an output stream.
// - Added Print() to BasicExcelWorksheet to print the worksheet to an output stream.
// - Change BasicExcelCell Get functions to const functions.
// - Rename BasicExcelWorksheet functions RenameWorkSheet() to Rename().
// Version 1.3 (10 May 2006)
// - Fixed bugs with reading from Excel files containing Asian characters.
// Version 1.4 (13 May 2006)
// - Fixed bugs with reading and writing to Excel files containing many strings.
// Version 1.5 (15 May 2006)
// - Remove code for ExtSST because it was causing problems with reading and writing to Excel files containing many strings.
// Version 1.6 (16 May 2006)
// - Optimized code for reading and writing.
// Version 1.7 (22 May 2006)
// - Fixed code to remove some warnings.
// - Fixed bug with BasicExcelWorksheet::Cell.
// - Fixed bug with BasicExcel::UpdateWorksheets().
// Version 1.8 (23 May 2006)
// - Fixed bug with reading Excel files containing many unicode strings.
// - Fixed code to remove some warnings.
// - Fixed variable code_ duplication in BoolErr.
// - Minor changes to BasicExcelCell:Set functions.
// Version 1.9 (24 May 2006)
// - Changed name_ in Style from SmallString to LargeString.
// - Fixed bug in BasicExcelCell::GetString and BasicExcelCell::GetWString.
// - Minor changes to functions in BasicExcel and BasicExcelWorksheet which checks for unicode.
// - Minor change to SmallString::Read.
// Version 1.10 (30 May 2006)
// - Fixed bug with reading Excel files containing many strings.
// - Remove memory leaks.
// Version 1.11 (2 June 2006)
// - Fixed bug with reading and writing Excel files containing many unicode and ANSI strings.
// Version 1.12 (6 June 2006)
// - Fixed bug with reading and writing Excel files containing many unicode and ANSI strings.
// Version 1.13 (1 August 2006)
// - Changed BasicExcelCell::Get() so that it will get a stored double as an integer or vice versa if necessary.
// - Changed BasicExcelCell::Get() so that it will not cause any errors if a string is empty.
// - Changed BasicExcelCell::SetString() and BasicExcelCell::SetWString() so that it will not save an empty string.
// Version 1.14 (6 August 2006)
// - Fixed bug with reading Excel files that contain a null string.
// Version 2.0 (September 2009, Martin Fuchs)
// - extended to maintain font and format information when reading and writing Excel sheets
// - XLSFormatManager, ExcelFont and CellFormat to edit fonts and formats
// Version 2.1 (04.10.2009, Martin Fuchs)
// - fixed memory leak in XLSFormatManager::get_font_idx()
// - define macros and constants for cell and font properties
// Version 2.2 (07.11.2009, Martin Fuchs)
// - fixed VS2008 problem when reading sheets with formula fields
// - added BasicExcel::Close()
// - added CellFormat::get/set_text_props() and get/set_borderlines()
// Version 2.3 (05.01.2010, Ami Castonguay/Martin Fuchs)
// - fixed reference counting of Formula data structs
// - support for shared formulas
// - support for merged cells
// - save formatting even if cell is empty
// - flush fstream instead of closing it followed by open to prevent races in conjunction with virus scanners
// - enable reading of XLS files exported by MacOS Numbers.app
// Version 2.4 (24.01.2010, Long Wenbiao/Martin Fuchs)
// - add second set_borderlines() overload
// - add ExcelFont::set_italic(), CellFormat::set_wrapping()
// - handle COLINFO
// - miscellaneous fixes
// Version 2.5 (01.01.2011, Martin Fuchs)
// - dynamically allocate memory for unexpected high row/column values
// - Unicode overloads for Load() and SaveAs()
// - adjust to RKValues written by OpenOffice Calc
// Version 3.0 (23.01.2011, Martin Fuchs)
// - portability fixes to enable using the code in 64 Bit development environments
// - in a Windows environment use the Windows API instead of the old CompoundFile class to access compound document files
// - reduced memory consumption in BasicExcel data handling
// - return current value string from formula cells
// - don't preserve empty rows/columns at the end of sheets
#ifndef BASICEXCEL_HPP
#define BASICEXCEL_HPP
//MF
#if defined(_MSC_VER) && _MSC_VER<=1200 // VC++ 6.0
#pragma warning(disable: 4786)
#define LONGINT __int64
#define LONGINT_CONST(x) x
#define COMPOUNDFILE
#else // newer Microsoft compilers
#define LONGINT long long
#define LONGINT_CONST(x) x##LL
#define COMPOUNDFILE CompoundFile::
#ifdef _DEBUG
#define _ITERATOR_DEBUG_LEVEL 0 // speedup iterator operations while debugging
#endif
#endif
//MF type definitions of the Windows Compound Binary File Format (CBF) Specification
typedef unsigned char BYTE; // 8 bit unsigned integer
typedef unsigned short WORD; // 16 bit unsigned integer
typedef short SHORT; // 16 bit signed integer
typedef unsigned short USHORT; // 16 bit unsigned integer
#ifdef _MSC_VER
typedef unsigned long DWORD; // 32 bit unsigned integer
typedef long LONG; // 32 bit signed integer
typedef unsigned long ULONG; // 32 bit unsigned integer
#else
typedef unsigned int DWORD; // 32 bit unsigned integer
typedef int LONG; // 32 bit signed integer
typedef unsigned int ULONG; // 32 bit unsigned integer
#endif
typedef short OFFSET;
typedef ULONG SECT;
typedef ULONG FSINDEX;
typedef USHORT FSOFFSET;
typedef ULONG DFSIGNATURE;
typedef WORD DFPROPTYPE;
typedef ULONG CBF_SID; // renamed SID because of ambiguity with windows header files
#ifndef GUID_DEFINED
#define GUID_DEFINED
typedef struct _GUID {
ULONG Data1;
USHORT Data2;
USHORT Data3;
BYTE Data4[8];
} GUID;
#endif
typedef GUID CLSID; // 16 bytes
struct TIME_T { // FILETYPE
DWORD dwLowDateTime;
DWORD dwHighDateTime;
};
#define DIFSECT 0xFFFFFFFC
#define FATSECT 0xFFFFFFFD
#define ENDOFCHAIN 0xFFFFFFFE
#define FREESECT 0xFFFFFFFF
#ifndef NATIVE_WIN32
enum STGTY {
STGTY_INVALID = 0,
STGTY_STORAGE = 1,
STGTY_STREAM = 2,
STGTY_LOCKBYTES = 3,
STGTY_PROPERTY = 4,
STGTY_ROOT = 5
};
#endif
enum DECOLOR {
DE_RED = 0,
DE_BLACK = 1
};
#if _MSC_VER>=1400 // VS 2005
#define _CRT_SECURE_NO_WARNINGS //MF
#define _SCL_SECURE_NO_WARNINGS //MF
#endif
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <map>
#include <vector>
#include <string> //MF
using namespace std;
// get facet from locale for GCC
#ifndef _USE
#define _USE(loc, fac) use_facet<fac >(loc)
#endif
#include <assert.h> //MF
#ifndef _MSC_VER
#include <string.h>
#endif
#define UTF16
#ifdef UTF16
#define SIZEOFWCHAR_T 2
#else
#define SIZEOFWCHAR_T sizeof(wchar_t)
#endif
//MF string conversion functions
// Courtesy of Tom Widmer (VC++ MVP)
inline std::string narrow_string(const std::wstring& str)
{
std::string ret;
if (!str.empty()) {
ret.resize(str.length());
typedef std::ctype<wchar_t> CT;
CT const& ct = std::_USE(std::locale(), CT);
ct.narrow(&str[0], &*str.begin()+str.size(), '?', &ret[0]);
}
return ret;
}
inline std::wstring widen_string(const std::string& str)
{
std::wstring ret;
if (!str.empty()) {
ret.resize(str.length());
typedef std::ctype<wchar_t> CT;
CT const& ct = std::_USE(std::locale(), CT);
ct.widen(&str[0], &*str.begin()+str.size(), &ret[0]);
}
return ret;
}
#ifdef NATIVE_WIN32
#include <objbase.h>
#pragma comment(lib, "ole32")
// MF
namespace WinCompFiles
{
enum CF_RESULT {
INVALID_SIZE = -6,
FILE_NOT_FOUND = -4,
DIRECTORY_NOT_EMPTY = -3,
DIRECTORY_NOT_FOUND = -2,
INVALID_PATH = -1,
SUCCESS = 1
};
struct CompoundFile
{
CompoundFile();
~CompoundFile();
// Compound File functions
bool Create(const wchar_t* filename);
bool Open(const wchar_t* filename, ios_base::openmode mode=ios_base::in|ios_base::out);
bool Close();
bool IsOpen();
// File functions
CF_RESULT MakeFile(const wchar_t* path);
CF_RESULT FileSize(const wchar_t* path, ULONGLONG& size);
CF_RESULT ReadFile(const wchar_t* path, char* data, ULONG size);
CF_RESULT ReadFile(const wchar_t* path, vector<char>&data);
CF_RESULT WriteFile(const wchar_t* path, const char* data, ULONG size);
CF_RESULT WriteFile(const wchar_t* path, const vector<char>&data, ULONG size);
// ANSI char functions
bool Create(const char* filename);
bool Open(const char* filename, ios_base::openmode mode=ios_base::in|ios_base::out);
CF_RESULT MakeFile(const char* path);
CF_RESULT FileSize(const char* path, ULONGLONG& size);
CF_RESULT ReadFile(const char* path, char* data, ULONG size);
CF_RESULT ReadFile(const char* path, vector<char>& data);
CF_RESULT WriteFile(const char* path, const char* data, ULONG size);
CF_RESULT WriteFile(const char* path, const vector<char>& data, ULONG size);
private:
IStorage* _pStg;
};
} // namespace WinCompFiles
#endif
namespace YCompoundFiles
{
struct LittleEndian
{
#if defined(_MSC_VER) && _MSC_VER<=1200 // VC++ 6.0
#define READWRITE(Type) \
static void Read(const char* buffer, Type& retVal, size_t pos=0, int bytes=0) \
{ \
retVal = Type(0); \
if (bytes == 0) bytes = sizeof(Type); \
for (size_t i=0; i<bytes; ++i) \
{ \
retVal |= ((Type)((unsigned char)buffer[pos+i])) << 8*i; \
} \
} \
static void ReadString(const char* buffer, Type* str, size_t pos=0, int bytes=0) \
{ \
for (size_t i=0; i<bytes; ++i) Read(buffer, str[i], pos+i*sizeof(Type)); \
} \
static void Write(char* buffer, Type val, size_t pos=0, int bytes=0) \
{ \
if (bytes == 0) bytes = sizeof(Type); \
for (size_t i=0; i<bytes; ++i) \
{ \
buffer[pos+i] = (unsigned char)val; \
val >>= 8; \
} \
} \
static void WriteString(char* buffer, Type* str, size_t pos=0, int bytes=0) \
{ \
for (size_t i=0; i<bytes; ++i) Write(buffer, str[i], pos+i*sizeof(Type)); \
} \
static void Read(const vector<char>& buffer, Type& retVal, size_t pos=0, int bytes=0) \
{ \
retVal = Type(0); \
if (bytes == 0) bytes = sizeof(Type); \
for (size_t i=0; i<bytes; ++i) \
{ \
retVal |= ((Type)((unsigned char)buffer[pos+i])) << 8*i; \
} \
} \
static void ReadString(const vector<char>& buffer, Type* str, size_t pos=0, int bytes=0) \
{ \
for (size_t i=0; i<bytes; ++i) Read(buffer, str[i], pos+i*sizeof(Type)); \
} \
static void Write(vector<char>& buffer, Type val, size_t pos=0, int bytes=0) \
{ \
if (bytes == 0) bytes = sizeof(Type); \
for (size_t i=0; i<bytes; ++i) \
{ \
buffer[pos+i] = (unsigned char)val; \
val >>= 8; \
} \
} \
static void WriteString(vector<char>& buffer, Type* str, size_t pos=0, int bytes=0) \
{ \
for (size_t i=0; i<bytes; ++i) Write(buffer, str[i], pos+i*sizeof(Type)); \
} \
READWRITE(char)
READWRITE(unsigned char)
READWRITE(short)
READWRITE(int)
READWRITE(unsigned int)
READWRITE(long)
READWRITE(unsigned long)
READWRITE(__int64)
READWRITE(unsigned __int64)
#undef READWRITE
static void Read(const char* buffer, wchar_t& retVal, size_t pos=0, int bytes=0)
{
retVal = wchar_t(0);
if (bytes == 0)
bytes = SIZEOFWCHAR_T;
for (int i=0; i<bytes; ++i)
retVal |= ((wchar_t)((unsigned char)buffer[pos+i])) << 8*i;
}
static void ReadString(const char* buffer, wchar_t* str, size_t pos=0, int bytes=0)
{
for (int i=0; i<bytes; ++i)
Read(buffer, str[i], pos+i*SIZEOFWCHAR_T);
}
static void Write(char* buffer, wchar_t val, size_t pos=0, int bytes=0)
{
if (bytes == 0)
bytes = SIZEOFWCHAR_T;
for (int i=0; i<bytes; ++i) {
buffer[pos+i] = (unsigned char)val;
val >>= 8;
}
}
static void WriteString(char* buffer, wchar_t* str, size_t pos=0, int bytes=0)
{
for (int i=0; i<bytes; ++i)
Write(buffer, str[i], pos+i*SIZEOFWCHAR_T);
}
static void Read(const vector<char>& buffer, wchar_t& retVal, size_t pos=0, int bytes=0)
{
retVal = wchar_t(0);
if (bytes == 0) bytes = SIZEOFWCHAR_T;
for (int i=0; i<bytes; ++i)
{
if (pos+i < buffer.size()) //MF
retVal |= ((wchar_t)((unsigned char)buffer[pos+i])) << 8*i;
}
}
static void ReadString(const vector<char>& buffer, wchar_t* str, size_t pos=0, int bytes=0)
{
for (int i=0; i<bytes; ++i) Read(buffer, str[i], pos+i*SIZEOFWCHAR_T);
}
static void Write(vector<char>& buffer, wchar_t val, size_t pos=0, int bytes=0)
{
if (bytes == 0)
bytes = SIZEOFWCHAR_T;
for (int i=0; i<bytes; ++i) {
buffer[pos+i] = (unsigned char)val;
val >>= 8;
}
}
static void WriteString(vector<char>& buffer, wchar_t* str, size_t pos=0, int bytes=0)
{
for (int i=0; i<bytes; ++i)
Write(buffer, str[i], pos+i*SIZEOFWCHAR_T);
}
#else
template<typename Type>
static void Read(const char* buffer, Type& retVal, size_t pos=0, int bytes=0)
{
retVal = Type(0);
if (bytes == 0)
bytes = sizeof(Type);
for (int i=0; i<bytes; ++i)
retVal |= ((Type)((unsigned char)buffer[pos+i])) << 8*i;
}
template<typename Type>
static void ReadString(const char* buffer, Type* str, size_t pos=0, int bytes=0)
{
for (int i=0; i<bytes; ++i)
Read(buffer, str[i], pos+i*sizeof(Type));
}
template<typename Type>
static void Write(char* buffer, Type val, size_t pos=0, int bytes=0)
{
if (bytes == 0)
bytes = sizeof(Type);
for (int i=0; i<bytes; ++i) {
buffer[pos+i] = (unsigned char)val;
val >>= 8;
}
}
template<typename Type>
static void WriteString(char* buffer, Type* str, size_t pos=0, int bytes=0)
{
for (int i=0; i<bytes; ++i)
Write(buffer, str[i], pos+i*sizeof(Type));
}
template<typename Type>
static void Read(const vector<char>& buffer, Type& retVal, size_t pos=0, int bytes=0)
{
retVal = Type(0);
if (bytes == 0)
bytes = sizeof(Type);
for (int i=0; i<bytes; ++i)
retVal |= ((Type)((unsigned char)buffer[pos+i])) << 8*i;
}
template<typename Type>
static void ReadString(const vector<char>& buffer, Type* str, size_t pos=0, int bytes=0)
{
for (int i=0; i<bytes; ++i)
Read(buffer, str[i], pos+i*sizeof(Type));
}
template<typename Type>
static void Write(vector<char>& buffer, Type val, size_t pos=0, int bytes=0)
{
if (bytes == 0)
bytes = sizeof(Type);
for (int i=0; i<bytes; ++i) {
buffer[pos+i] = (unsigned char)val;
val >>= 8;
}
}
template<typename Type>
static void WriteString(vector<char>& buffer, Type* str, size_t pos=0, int bytes=0)
{
for (int i=0; i<bytes; ++i) Write(buffer, str[i], pos+i*sizeof(Type));
}
static void Read(const char* buffer, wchar_t& retVal, size_t pos=0, int bytes=0)
{
retVal = wchar_t(0);
if (bytes == 0)
bytes = SIZEOFWCHAR_T;
for (int i=0; i<bytes; ++i)
retVal |= ((wchar_t)((unsigned char)buffer[pos+i])) << 8*i;
}
static void ReadString(const char* buffer, wchar_t* str, size_t pos=0, int bytes=0)
{
for (int i=0; i<bytes; ++i)
Read(buffer, str[i], pos+i*SIZEOFWCHAR_T);
}
static void Write(char* buffer, wchar_t val, size_t pos=0, int bytes=0)
{
if (bytes == 0)
bytes = SIZEOFWCHAR_T;
for (int i=0; i<bytes; ++i) {
buffer[pos+i] = (unsigned char)val;
val >>= 8;
}
}
static void WriteString(char* buffer, wchar_t* str, size_t pos=0, int bytes=0)
{
for (int i=0; i<bytes; ++i) Write(buffer, str[i], pos+i*SIZEOFWCHAR_T);
}
static void Read(const vector<char>& buffer, wchar_t& retVal, size_t pos=0, int bytes=0)
{
retVal = wchar_t(0);
if (bytes == 0)
bytes = SIZEOFWCHAR_T;
for (int i=0; i<bytes; ++i) {
if (int(pos+i) < (int)buffer.size()) //MF
retVal |= ((wchar_t)((unsigned char)buffer[pos+i])) << 8*i;
}
}
static void ReadString(const vector<char>& buffer, wchar_t* str, size_t pos=0, int bytes=0)
{
for (int i=0; i<bytes; ++i) Read(buffer, str[i], pos+i*SIZEOFWCHAR_T);
}
static void Write(vector<char>& buffer, wchar_t val, size_t pos=0, int bytes=0)
{
if (bytes == 0)
bytes = SIZEOFWCHAR_T;
for (int i=0; i<bytes; ++i) {
buffer[pos+i] = (unsigned char)val;
val >>= 8;
}
}
static void WriteString(vector<char>& buffer, wchar_t* str, size_t pos=0, int bytes=0)
{
for (int i=0; i<bytes; ++i)
Write(buffer, str[i], pos+i*SIZEOFWCHAR_T);
}
#endif
};
#ifndef NATIVE_WIN32
class Block
// PURPOSE: In charge of handling blocks of data from a file
{
public:
Block();
// File handling functions
bool Create(const wchar_t* filename);
bool Open(const wchar_t* filename, ios_base::openmode mode=ios_base::in | ios_base::out);
bool Close();
bool IsOpen();
// Block handling functions
bool Read(SECT index, char* block);
bool Write(SECT index, const char* block);
bool Swap(SECT index1, SECT index2);
bool Move(SECT from, SECT to);
bool Insert(SECT index, const char* block);
bool Erase(SECT index);
bool Erase(vector<SECT>& indices);
// Misc functions
ULONG GetBlockSize() const {return blockSize_;}
void SetBlockSize(ULONG size)
{
blockSize_ = size;
indexEnd_ = fileSize_/blockSize_ + (fileSize_%blockSize_? 1: 0);
}
protected:
vector<char> filename_;
ios_base::openmode mode_;
fstream file_;
ULONG blockSize_;
SECT indexEnd_;
ULONG fileSize_;
};
enum {
DUPLICATE_PROPERTY=-6,
NAME_TOO_LONG=-5, FILE_NOT_FOUND=-4,
DIRECTORY_NOT_EMPTY=-3, DIRECTORY_NOT_FOUND=-2,
INVALID_PATH=-1,
SUCCESS=1
};
class CompoundFile
{
public:
CompoundFile();
~CompoundFile();
// User accessible functions
public:
// Compound File functions
bool Create(const wchar_t* filename);
bool Open(const wchar_t* filename, ios_base::openmode mode=ios_base::in | ios_base::out);
bool Close();
bool IsOpen();
// Directory functions
int ChangeDirectory(const wchar_t* path);
int MakeDirectory(const wchar_t* path);
// File functions
int MakeFile(const wchar_t* path);
int FileSize(const wchar_t* path, ULONG& size);
int ReadFile(const wchar_t* path, char* data);
int ReadFile(const wchar_t* path, vector<char>&data);
int WriteFile(const wchar_t* path, const char* data, ULONG size);
int WriteFile(const wchar_t* path, const vector<char>&data, ULONG size);
// ANSI char functions
bool Create(const char* filename);
bool Open(const char* filename, ios_base::openmode mode=ios_base::in | ios_base::out);
int ChangeDirectory(const char* path);
int MakeDirectory(const char* path);
int MakeFile(const char* path);
int FileSize(const char* path, ULONG& size);
int ReadFile(const char* path, char* data);
int ReadFile(const char* path, vector<char>& data);
int WriteFile(const char* path, const char* data, ULONG size);
int WriteFile(const char* path, const vector<char>& data, ULONG size);
// Protected functions and data members
protected:
// General functions and data members
void IncreaseLocationReferences(vector<SECT> indices);
void DecreaseLocationReferences(vector<SECT> indices);
void SplitPath(const wchar_t* path, wchar_t*& parentpath, wchar_t*& propertyname);
vector<char> block_;
Block file_;
// Header related functions and data members
bool LoadHeader();
void SaveHeader();
class Header
{
public:
Header();
void Write(char* block);
void Read(char* block);
LONGINT _abSig; // 0x0000 Magic number identifying this as a compound file system
CLSID _clid; // 0x0008 class id (set with WriteClassStgm retrieved with GetClassFile/ReadClassStg)
USHORT _ulMinorVersion; // 0x0018 minor version of the format: 33 is written by reference implementation
USHORT _uDllVersion; // 0x001A major version of the dll/format: 3 is written by reference implementation
USHORT _uByteOrder; // 0x001C 0xFFFE: indicates Intel byte ordering
USHORT _uSectorShift; // 0x001E size of sectors in power-of-two, typically 9, indicating 512-byte sectors
USHORT _uMiniSectorShift; // 0x0020 size of mini-sectors in power-of-two, typically 67, indicating 64-byte mini-sectors
USHORT _usReserved; // 0x0022 reserved, must be zero
ULONG _ulReserved1; // 0x0024 reserved, must be zero
ULONG _ulReserved2; // 0x0028 reserved, must be zero
FSINDEX _csectFat; // 0x002C number of SECTs in the FAT chain / "Number of elements in the BAT array"
SECT _sectDirStat; // 0x0030 first SECT in the directory chain / "Block index of the first block of the property table"
DFSIGNATURE _signature; // 0x0034 signature used for transactioning: must be zero, not supported by reference implementation
ULONG _ulMiniSectorCutOff;// 0x0038 maximum size for mini-streams: typically 4096 bytes
SECT _sectMiniFatStart; // 0x003C first SECT in the mini-FAT chain / "Block index of first big block containing the small block allocation table (SBAT)"
FSINDEX _csectMiniFat; // 0x0040 number of SECTs in the mini-FAT chain / "Number of big blocks holding the SBAT"
SECT _sectDifStart; // 0x0044 first SECT in the DIFG chain / "Block index of the first block in the Extended Block Allocation Table (XBAT)"
FSINDEX _csectDif; // 0x0048 number of SECTs in the DIF chain / "Number of elements in the Extended Block Allocation Table (to be added to the BAT)"
SECT _sectFat[109]; // 0x004C..0x01FF the SECTs of the first 109 FAT sectors / "Array of block indices constituting the Block Allocation Table (BAT)"
ULONG bigBlockSize_;
ULONG smallBlockSize_;
private:
void Initialize();
};
Header header_;
// BAT related functions and data members
void LoadBAT();
void SaveBAT();
ULONG DataSize(SECT startIndex, bool isBig);
ULONG ReadData(SECT startIndex, char* data, bool isBig);
SECT WriteData(const char* data, ULONG size, SECT startIndex, bool isBig);
void GetBlockIndices(SECT startIndex, vector<SECT>& indices, bool isBig);
SECT GetFreeBlockIndex(bool isBig);
void ExpandBATArray(bool isBig);
void LinkBlocks(SECT from, SECT to, bool isBig);
void FreeBlocks(vector<SECT>& indices, bool isBig);
vector<SECT> blocksIndices_;
vector<SECT> sblocksIndices_;
// Properties related functions and data members
class DirectoryEntry // struct StructuredStorageDirectoryEntry
{
public:
DirectoryEntry();
void Write(char* block);
void Read(char* block);
friend bool operator==(const COMPOUNDFILE DirectoryEntry& lhs, const COMPOUNDFILE DirectoryEntry& rhs)
{
return (!wcscmp(lhs.name_, rhs.name_));
}
friend bool operator< (const COMPOUNDFILE DirectoryEntry& lhs, const COMPOUNDFILE DirectoryEntry& rhs)
{
size_t maxLen1 = wcslen(lhs.name_);
size_t maxLen2 = wcslen(rhs.name_);
if (maxLen1 < maxLen2) return true;
else if (maxLen1 > maxLen2) return false;
else
{
int result = wcscmp(lhs.name_, rhs.name_);
if (result <= 0) return true;
else return false;
}
}
friend bool operator!=(const COMPOUNDFILE DirectoryEntry& lhs, const COMPOUNDFILE DirectoryEntry& rhs) {return !(lhs == rhs);}
friend bool operator> (const COMPOUNDFILE DirectoryEntry& lhs, const COMPOUNDFILE DirectoryEntry& rhs) {return (rhs < lhs);}
friend bool operator<=(const COMPOUNDFILE DirectoryEntry& lhs, const COMPOUNDFILE DirectoryEntry& rhs) {return !(rhs < lhs);}
friend bool operator>=(const COMPOUNDFILE DirectoryEntry& lhs, const COMPOUNDFILE DirectoryEntry& rhs) {return !(lhs < rhs);}
wchar_t name_[32]; // 0x00..0x3E the element name in Unicode, padded with zeros to fill the array / "A unicode null-terminated uncompressed 16bit string (lblocke the high bytes) containing the name of the property"
WORD _cb_namesize; // 0x40 length of the element name in characters, not bytes / "Number of characters in the NAME field"
BYTE _mse; // 0x42 type of object: value taken from the STGTY enumeration / "DirectoryEntry type (directory, file, or root) Byte 1 (directory), 2 (file), or 5 (root entry)"
BYTE _bflags; // 0x43 value taken form DECOLOR enumeration / "Node color"
CBF_SID _sidLeftSib; // 0x44 SID of the left-sibling of this entry in the directory tree / "Previous property index"
CBF_SID _sidRightSib; // 0x48 SID of the right-sibling of this entry in the directroy tree / "Next property index"
CBF_SID _sidChild; // 0x4C SID of the child acting as the root of all the children of this element (if _mse=STGTY_STORAGE) / "First child property index"
GUID _clsId; // 0x50 CLSID if this storage (if _mse=STGTY_STORAGE)
DWORD _dwUserFlags; // 0x60 user flags of this storage (if _mse=STGTY_STORAGE)
TIME_T _time[2]; // 0x64 create/modify time stamps (if _mse=STGTY_STORAGE)
SECT _sectStart; // 0x74 starting SECT of the stream (if _mse=STGTY_STORAGE) / "Starting block of the file, used as the first block in the file and the pointer to the next block from the BAT"
ULONG _ulSize; // 0x78 size of stream in bytes (if _mse=STGTY_STORAGE) / "Actual size of the file this property points to. (used to truncate the blocks to the real size)."
DFPROPTYPE _dptPropType; // 0x7C reserved for future use, must be zero
};
class PropertyTree
{
public:
PropertyTree();
~PropertyTree();
PropertyTree* parent_;
DirectoryEntry* self_;
SECT index_;
vector<PropertyTree*> children_;
};
void LoadProperties();
void SaveProperties();
int MakeProperty(const wchar_t* path, DirectoryEntry* property);
PropertyTree* FindProperty(SECT index);
PropertyTree* FindProperty(const wchar_t* path);
PropertyTree* FindProperty(PropertyTree* parentTree, wchar_t* name);
void InsertPropertyTree(PropertyTree* parentTree, DirectoryEntry* property, SECT index);
void DeletePropertyTree(PropertyTree* tree);
void UpdateChildrenIndices(PropertyTree* parentTree);
void IncreasePropertyReferences(PropertyTree* parentTree, SECT index);
void DecreasePropertyReferences(PropertyTree* parentTree, SECT index);
PropertyTree* propertyTrees_;
PropertyTree* currentDirectory_;
vector<DirectoryEntry*> dirEntries_;
vector<PropertyTree*> previousDirectories_;
};
#endif // _WIN32
} // namespace YCompoundFiles
// reference counting to implement smart pointers
namespace RefCount
{
// reference counter for SmartPtr managed objects
struct RefCnt
{
// On construction the reference counter is initialized with an usage count of 0.
RefCnt()
: _ref_cnt(0)
{
}
int _ref_cnt;
};
// reference counting smart pointer
template<typename T> struct SmartPtr
{
// default constructor
SmartPtr()
: _ptr(NULL)
{
}
// The initialized SmartPtr constructor increments the reference counter in struct RefCnt.
SmartPtr(T* p)
: _ptr(p)
{
if (p)
++_ptr->_ref_cnt;
}
// The copy constructor increments the reference counter.
SmartPtr(const SmartPtr& other)
: _ptr(other._ptr)
{
if (_ptr)
++_ptr->_ref_cnt;
}
// The destructor decreases the reference counter and
// frees the managed memory as the counter reaches zero.
~SmartPtr()
{
if (_ptr) {
if (!--_ptr->_ref_cnt)
delete _ptr;
}
}
// The assignment operator increments the reference counter.
SmartPtr& operator=(T* p)
{
if (_ptr) {
if (!--_ptr->_ref_cnt)
delete _ptr;
_ptr = NULL;
}
if (p) {
_ptr = p;
++_ptr->_ref_cnt;
}
return *this;
}
// operator bool() to check for non-empty smart pointers
operator bool() const {return _ptr != NULL;}
// operator!() to check for empty smart pointers
bool operator!() const {return !_ptr;}
// operator->() to access the managed objects
T* operator->() {return _ptr;}
const T* operator->() const {return _ptr;}
// Derefence pointed memory
T& operator*() {return *_ptr;}
const T& operator*() const {return *_ptr;}
private:
T* _ptr;
};
} // namespace RefCount
//MF
namespace ExcelFormat {
struct CellFormat;
}
namespace YExcel
{
using namespace YCompoundFiles;
#ifdef NATIVE_WIN32
using namespace WinCompFiles;
#endif
struct CODE
{
enum { FORMULA=0x0006, //Token array and the result of a formula cell.
YEOF=0x000A, //End of a record block with leading BOF record.
CALCCOUNT=0x000C, //Maximum number of times the forumlas should be iteratively calculated
CALCMODE=0x000D, //Calculate formulas manually, automatically, or automatically except for multiple table operations
PRECISION=0x000E, //Whether formulas use the real cell values for calculation or the values displayed on the screen.
REFMODE=0x000F, //Method used to show cell addresses in formulas.
DELTA=0x0010, //Maximum change of the result to exit an iteration.
ITERATION=0x0011, //Whether iterations are allowed while calculating recursive formulas.
PROTECT=0x0012, //Whether worksheet or a workbook is protected against modification.
PASSWORD=0x0013, //16-bit hash value, calculated from the worksheet or workbook protection password.
HEADER=0x0014, //Page header string for the current worksheet.
FOOTER=0x0015, //Page footer string for the current worksheet.
EXTERNSHEET=0x0017, //List with indexes to SUPBOOK records
NAME=0x0018, //Name and token array of an internal defined name.
WINDOWPROTECT=0x0019, //Whether the window configuration of the document is protected.
SELECTION=0x001D, //Addresses of all selected cell ranges and position of the active cell for a pane in the current sheet.
DATEMODE=0x0022, //Base date for displaying date values.
EXTERNNAME=0x0023, //Name of an external defined name, name of an add-in function, a DDE item or an OLE object storage identifier.
LEFTMARGIN=0x0026, //Left page margin of the current worksheet.
RIGHTMARGIN=0x0027, //Right page margin of the current worksheet.
TOPMARGIN=0x0028, //Top page margin of the current worksheet.
BOTTOMMARGIN=0x0029, //Bottom page margin of current worksheet
PRINTHEADERS=0x002A, //Whether row and column headers (the areas with row numbers and column letters) will be printed.
PRINTGRIDLINES=0x002B, //Whether sheet grid lines will be printed.
FILEPASS=0x002F, //Information about the read/write password of the file.
FONT=0x0031, //Information about a used font, including character formatting.
TABLE=0x0036, //Information about a multiple operation table in the sheet.
CONTINUE=0x003C, //Continue from previous record
WINDOW1=0x003D, //General settings for the workbook global settings.
BACKUP=0x0040, //Make backup of file while saving?
PANE=0x0041, //Position of window panes.
CODEPAGE=0x0042, //Text encoding used to encode byte strings
DCONREF=0x0051,
DEFCOLWIDTH=0x0055, //Default column width for columns that do not have a specific width set
XCT=0x0059, //Number of immediately following CRN records.
CRN=0x005A, //Contents of an external cell or cell range.
FILESHARING=0x005B, //Information about write protection, for instance the write protection password.
WRITEACCESS=0x005C, //Name of the user that has saved the file.
UNCALCED=0x005E, //Formulas have not been recalculated before the document was saved.
SAVERECALC=0x005F, //"Recalculate before save" option
OBJECTPROTECT=0x0063, //Whether objects of the current sheet are protected.
COLINFO=0x007D, //Width for a given range of columns
GUTS=0x0080, //Layout of outline symbols.
WSBOOL=0x0081, //16-bit value with boolean options for the current sheet.
GRIDSET=0x0082, //Whether option to print sheet grid lines has ever been changed.
HCENTER=0x0083, //Sheet is centred horizontally when printed.
VCENTER=0x0084, //Whether sheet is centred vertically when printed.
BOUNDSHEET=0x0085, //Sheet inside of the workbook
WRITEPROT=0x0086, //Whether file is write protected.
COUNTRY=0x008C, //User interface language of the Excel version that has saved the file, system regional settings at the time the file was saved.
HIDEOBJ=0x008D, //Whether and how to show objects in the workbook.
SORT=0x0090, //Last settings from the "Sort" dialogue for each sheet.
PALETTE=0x0092, //Definition of all user-defined colours available for cell and object formatting.
SETUP=0x00A1, //Page format settings of the current sheet.
SHRFMLA=0x00BC, //Token array of a shared formula.
MULRK=0x00BD, //Cell range containing RK value cells. All cells are located in the same row.
MULBLANK=0x00BE, //Cell range of empty cells. All cells are located in the same row.
DBCELL=0x00D7, //Relative offsets to calculate stream position of the first cell record for each row.
BOOKBOOL=0x00DA, //Save values linked from external workbooks records and XCT records?
SCENPROTECT=0x00DD, //Whether scenarios of the current sheet are protected.
XF=0x00E0, //Formatting information for cells, rows, columns or styles.
MERGECELLS=0x00E5, //All merged cell ranges of the current sheet.
SST=0x00FC, //List of all strings used anywhere in the workbook.
LABELSST=0x00FD, //Cell that contains a string.
EXTSST=0x00FF, //Create a hash table with stream offsets to the SST record to optimise string search operations.
LABELRANGES=0x015F, //Addresses of all row and column label ranges in the current sheet.
USESELFS=0x0160, //Whether formulas in the workbook can use "natural language formulas".
DSF=0x0161, //Whether file contains an addition BIFF5/BIFF7 workbook stream.
SUPBOOK=0x01AE, //URL of an external document and a list of sheet names inside this document.
CONDFMT=0x01B0, //List of cell range addresses for all cells with equal conditional formatting.
CF=0x01B1, //Condition and the formatting attributes applied to the cells specified in the CONDFMT record, if the condition is met
DVAL=0x01B2, //List header of the data validity table in the current sheet.
HLINK=0x01B8, //One cell address or a cell range where all cells contain the same hyperlink.
DV=0x01BE, //Data validity settings and a list of cell ranges which contain these settings.
DIMENSIONS=0x0200, //Range address of the used area in the current sheet.
BLANK=0x0201, //Empty cell, contains cell address and formatting information
NUMBER=0x0203, //Cell that contains a floating-point value.
BOOLERR=0x0205, //Error value cell
STRING=0x0207, //Result of a string formula.
ROW=0x0208, //Properties of a single row in the sheet.
INDEX=0x020B, //Range of used rows and stream positions of several records of the current sheet.
ARRAY=0x0221, //Token array of an array formula
WINDOW2=0x023E, //Additional settings for the window of a specific worksheet.
RK=0x027E, //Cell that contains an RK value (encoded integer or floating point value).
STYLE=0x0293, //Name of a user-defined cell style or specific options for a built-in cell style.
FORMAT=0x041E, //Number format.
SHRFMLA1=0x04BC, //Token array of a shared formula (added).
QUICKTIP=0x0800, //Cell range and text for a tool tip.
BOF=0x0809, //Beginning of file
SHEETLAYOUT=0x0862, //Colour of the tab below the sheet containing the sheet name.
SHEETPROTECTION=0x0867, //Additional options for sheet protection.
RANGEPROTECTION=0x0868, //Information about special protected ranges in a protected sheet.
SXFORMULA=0x0103, //PivotTable Formula Record
};
};
class Record
{
public:
Record();
virtual ~Record();
virtual ULONG Read(const char* data);
virtual ULONG Write(char* data);
virtual ULONG DataSize();
virtual ULONG RecordSize();
USHORT code_;
vector<char> data_;
ULONG dataSize_;
ULONG recordSize_;
vector<ULONG> continueIndices_;
};
struct BOF : public Record
{
BOF();
virtual ULONG Read(const char* data);
virtual ULONG Write(char* data);
USHORT version_;
USHORT type_;
USHORT buildIdentifier_;
USHORT buildYear_;
ULONG fileHistoryFlags_;
ULONG lowestExcelVersion_;
};
struct YEOF : public Record
{
YEOF();
};
// String with 1 byte length field
struct SmallString
{
SmallString();
~SmallString();
SmallString(const SmallString& s);
SmallString& operator=(const SmallString& s);
const SmallString& operator=(const char* str);
const SmallString& operator=(const wchar_t* str);
void Reset();
ULONG Read(const char* data);
ULONG Write(char* data);
ULONG DataSize();
ULONG RecordSize();
ULONG StringSize();
wchar_t* wname_;
char* name_;
char unicode_;
};
// String with 2 byte length field
struct LargeString
{
LargeString();
~LargeString();
LargeString(const LargeString& s);
LargeString& operator=(const LargeString& s);
const LargeString& operator=(const char* str);
const LargeString& operator=(const wchar_t* str);
void Reset();
ULONG Read(const char* data);
ULONG ContinueRead(const char* data, int size);
ULONG Write(char* data);
ULONG DataSize();
ULONG RecordSize();
ULONG StringSize();
vector<wchar_t> wname_;
vector<char> name_;
char unicode_;
USHORT richtext_;
ULONG phonetic_;
};
//MF string conversion functions
inline std::string narrow_string(const vector<wchar_t>& wstr)
{
return ::narrow_string(wstring(&*wstr.begin(), wstr.size()));
}
inline std::wstring widen_string(const vector<char>& wstr)
{
return ::widen_string(string(&*wstr.begin(), wstr.size()));
}
inline string stringFromSmallString(const SmallString& ss)
{
if (ss.unicode_)
return ::narrow_string(ss.wname_);
else
return ss.name_;
}
inline string stringFromLargeString(const LargeString& ls)
{
if (ls.unicode_)
return narrow_string(ls.wname_);
else
return string(&*ls.name_.begin(), ls.name_.size());
}
inline wstring wstringFromSmallString(const SmallString& ss)
{
if (ss.unicode_)
return ss.wname_;
else
return ::widen_string(ss.name_);
}
inline wstring wstringFromLargeString(const LargeString& ls)
{
if (ls.unicode_)
return wstring(&*ls.wname_.begin(), ls.wname_.size());
else
return widen_string(ls.name_);
}
class Workbook
{
public:
Workbook();
public:
struct FileProtection;
struct CodePage;
struct DSF;
struct TabID;
struct FnGroupCount;
struct WorkbookProtection;
struct Window1 : public Record
{
Window1();
virtual ULONG Read(const char* data);
virtual ULONG Write(char* data);
USHORT horizontalPos_;
USHORT verticalPos_;
USHORT width_;
USHORT height_;
USHORT options_;
USHORT activeWorksheetIndex_;
USHORT firstVisibleTabIndex_;
USHORT selectedWorksheetNo_;
USHORT worksheetTabBarWidth_;
};
struct Backup;
struct HideObj;
struct DateMode;
struct Precision;
struct RefreshAll;
struct BookBool;
struct Font : public Record
{
Font();
virtual ULONG Read(const char* data);
virtual ULONG Write(char* data);
virtual ULONG DataSize();
virtual ULONG RecordSize();
USHORT height_;
USHORT options_;
USHORT colourIndex_;
USHORT weight_;
USHORT escapementType_;
BYTE underlineType_;
BYTE family_;
BYTE characterSet_;
BYTE unused_;
SmallString name_;
};
struct Format : public Record
{
//MF
Format();
virtual ULONG Read(const char* data);
virtual ULONG Write(char* data);
virtual ULONG DataSize();
virtual ULONG RecordSize();
USHORT index_;
LargeString fmtstring_;
};
struct XF : public Record
{
XF();
virtual ULONG Read(const char* data);
virtual ULONG Write(char* data);
USHORT fontRecordIndex_;
USHORT formatRecordIndex_;
USHORT protectionType_;
BYTE alignment_; // 0x08: 1 = Text is wrapped at right border
BYTE rotation_;
BYTE textProperties_;
BYTE usedAttributes_;
ULONG borderLines_;
ULONG colour1_;
USHORT colour2_;
};
struct Style : public Record
{
Style();
virtual ULONG Read(const char* data);
virtual ULONG Write(char* data);
virtual ULONG DataSize();
virtual ULONG RecordSize();
USHORT XFRecordIndex_;
BYTE identifier_;
BYTE level_;
LargeString name_;
};
struct Palette;
struct UseSelfs;
struct BoundSheet : public Record
{
BoundSheet();
virtual ULONG Read(const char* data);
virtual ULONG Write(char* data);
virtual ULONG DataSize();
virtual ULONG RecordSize();
ULONG BOFpos_;
BYTE visibility_;
BYTE type_;
SmallString name_;
};
struct Country;
struct LinkTable;
struct SharedStringTable : public Record
{
SharedStringTable();
virtual ULONG Read(const char* data);
virtual ULONG Write(char* data);
virtual ULONG DataSize();
virtual ULONG RecordSize();
ULONG stringsTotal_;
ULONG uniqueStringsTotal_;
vector<LargeString> strings_;
};
struct ExtSST : public Record
{
ExtSST();
virtual ULONG Read(const char* data);
virtual ULONG Write(char* data);
virtual ULONG DataSize();
virtual ULONG RecordSize();
USHORT stringsTotal_;
vector<ULONG> streamPos_;
vector<USHORT> firstStringPos_;
vector<USHORT> unused_;
};
ULONG Read(const char* data);
ULONG Write(char* data);
ULONG DataSize();
ULONG RecordSize();
BOF bof_;
Window1 window1_;
vector<Font> fonts_;
vector<XF> XFs_;
vector<Style> styles_;
vector<Format> formats_; //MF
vector<BoundSheet> boundSheets_;
SharedStringTable sst_; // shared string table
ExtSST extSST_;
YEOF eof_;
};
//MF: exception to handle unexpected YEOF records
struct EXCEPTION_YEOF
{
EXCEPTION_YEOF(ULONG bytesRead)
: _bytesRead(bytesRead)
{
}
ULONG _bytesRead;
};
//MF
using namespace RefCount;
class Worksheet
{
public:
Worksheet();
public:
struct Uncalced;
struct Index : public Record
{
Index();
virtual ULONG Read(const char* data);
virtual ULONG Write(char* data);
virtual ULONG DataSize();
virtual ULONG RecordSize();
ULONG unused1_;
size_t firstUsedRowIndex_;
size_t firstUnusedRowIndex_;
ULONG unused2_;
vector<ULONG> DBCellPos_;
};
struct CalculationSettings
{
struct CalcCount;
struct CalcMode;
struct RefMode;
struct Delta;
struct Iteration;
struct SafeRecalc;
};
struct PrintHeaders;
struct PrintGridlines;
struct Gridset;
struct Guts;
struct DefaultRowHeight;
struct WSBool;
struct PageSettings
{
struct Header;
struct Footer;
struct HCenter;
struct VCenter;
struct LeftMargin;
struct RightMargin;
struct TopMargin;
struct BottomMargin;
struct PLS;
struct Setup;
};
struct WorksheetProtection;
struct DefColWidth;
struct ColInfo : public Record
{
ColInfo();
virtual ULONG Read(const char* data);
virtual ULONG Write(char* data);
USHORT firstColumnIndex_;
USHORT lastColumnIndex_;
USHORT columnWidth_;
USHORT XFRecordIndex_;
USHORT options_;
USHORT unused_;
};
struct Sort;
struct ColInfos : public Record
{
virtual ULONG Read(const char* data);
virtual ULONG Write(char* data);
virtual ULONG RecordSize();
vector<ColInfo> colinfo_;
};
struct Dimensions : public Record
{
Dimensions();
virtual ULONG Read(const char* data);
virtual ULONG Write(char* data);
ULONG firstUsedRowIndex_;
ULONG lastUsedRowIndexPlusOne_;
USHORT firstUsedColIndex_;
USHORT lastUsedColIndexPlusOne_;
USHORT unused_;
};
struct CellTable
{
struct RowBlock
{
struct Row : public Record
{
Row();
virtual ULONG Read(const char* data);
virtual ULONG Write(char* data);
USHORT rowIndex_;
USHORT firstCellColIndex_;
USHORT lastCellColIndexPlusOne_;
USHORT height_;
USHORT unused1_;
USHORT unused2_;
ULONG options_;
};
struct CellBlock : public RefCnt
{
struct Blank : public Record
{
Blank();
virtual ULONG Read(const char* data);
virtual ULONG Write(char* data);
USHORT rowIndex_;
USHORT colIndex_;
USHORT XFRecordIndex_;
};
struct BoolErr : public Record
{
BoolErr();
virtual ULONG Read(const char* data);
virtual ULONG Write(char* data);
USHORT rowIndex_;
USHORT colIndex_;
USHORT XFRecordIndex_;
BYTE value_;
BYTE error_;
};
struct LabelSST : public Record
{
LabelSST();
virtual ULONG Read(const char* data);
virtual ULONG Write(char* data);
USHORT rowIndex_;
USHORT colIndex_;
USHORT XFRecordIndex_;
size_t SSTRecordIndex_; // shared string table index
};
struct MulBlank : public Record
{
MulBlank();
virtual ULONG Read(const char* data);
virtual ULONG Write(char* data);
virtual ULONG DataSize();
virtual ULONG RecordSize();
USHORT rowIndex_;
USHORT firstColIndex_;
vector<USHORT> XFRecordIndices_;
USHORT lastColIndex_;
};
struct MulRK : public Record
{
MulRK();
virtual ULONG Read(const char* data);
virtual ULONG Write(char* data);
virtual ULONG DataSize();
virtual ULONG RecordSize();
struct XFRK
{
XFRK();
void Read(const char* data);
void Write(char* data);
USHORT XFRecordIndex_;
LONG RKValue_;
};
USHORT rowIndex_;
USHORT firstColIndex_;
vector<XFRK> XFRK_;
USHORT lastColIndex_;
};
struct Number : public Record
{
Number();
virtual ULONG Read(const char* data);
virtual ULONG Write(char* data);
USHORT rowIndex_;
USHORT colIndex_;
USHORT XFRecordIndex_;
double value_;
private:
union
{
LONGINT intvalue_;
double doublevalue_;
} intdouble_;
};
struct RK : public Record
{
RK();
virtual ULONG Read(const char* data);
virtual ULONG Write(char* data);
USHORT rowIndex_;
USHORT colIndex_;
USHORT XFRecordIndex_;
ULONG value_;
};
struct Formula : public Record
{
struct Array : public Record
{
Array();
virtual ULONG Read(const char* data);
virtual ULONG Write(char* data);
virtual ULONG DataSize();
virtual ULONG RecordSize();
USHORT firstRowIndex_;
USHORT lastRowIndex_;
BYTE firstColIndex_;
BYTE lastColIndex_;
USHORT options_;
ULONG unused_;
vector<char> formula_;
};
struct ShrFmla : public Record
{
ShrFmla();
virtual ULONG Read(const char* data);
virtual ULONG Write(char* data);
virtual ULONG DataSize();
virtual ULONG RecordSize();
USHORT firstRowIndex_;
USHORT lastRowIndex_;
BYTE firstColIndex_;
BYTE lastColIndex_;
USHORT unused_;
vector<char> formula_;
};
struct ShrFmla1 : public Record
{
ShrFmla1();
virtual ULONG Read(const char* data);
virtual ULONG Write(char* data);
virtual ULONG DataSize();
virtual ULONG RecordSize();
USHORT firstRowIndex_;
USHORT lastRowIndex_;
BYTE firstColIndex_;
BYTE lastColIndex_;
USHORT unused_;
vector<char> formula_;
};
struct Table : public Record
{
Table();
virtual ULONG Read(const char* data);
virtual ULONG Write(char* data);
USHORT firstRowIndex_;
USHORT lastRowIndex_;
BYTE firstColIndex_;
BYTE lastColIndex_;
USHORT options_;
USHORT inputCellRowIndex_;
USHORT inputCellColIndex_;
USHORT inputCellColumnInputRowIndex_;
USHORT inputCellColumnInputColIndex_;
};
struct String : public Record
{
String();
~String();
virtual ULONG Read(const char* data);
virtual ULONG Write(char* data);
virtual ULONG DataSize();
virtual ULONG RecordSize();
bool empty() {return !wstr_;}
void Reset();
char flag_; // 0 = compressed unicode string 1 = uncompressed unicode string
// From BIFF8 on, strings are always stored using UTF-16LE text encoding, optionally compressed (see compressed field)
wchar_t* wstr_;
};
Formula();
virtual ULONG Read(const char* data);
virtual ULONG Write(char* data);
virtual ULONG DataSize();
virtual ULONG RecordSize();
USHORT rowIndex_;
USHORT colIndex_;
USHORT XFRecordIndex_;
BYTE result_[8]; // formula result (IEEE 754 floating-point value, 64-bit double precision or other special values)
USHORT options_; // 1 = Recalculate always 2 = Calculate on open 8 = Part of a shared formula
ULONG unused_; // chn field
vector<char> RPNtoken_; // 2 length bytes, followed by a variable length structure
USHORT type_;
Array array_;
ShrFmla shrfmla_;
ShrFmla1 shrfmla1_;
Table table_;
String string_;
};
CellBlock();
~CellBlock();
void Reset();
void SetType(int type);
ULONG Read(const char* data);
ULONG Write(char* data);
ULONG DataSize();
ULONG RecordSize();
USHORT RowIndex();
USHORT ColIndex();
USHORT LastColIndex();
SHORT type_;
//MF
union CellBlockUnion {
void* void_;
Blank* blank_;
MulBlank* mulblank_;
BoolErr* boolerr_;
LabelSST* labelsst_;
MulRK* mulrk_;
Number* number_;
RK* rk_;
Formula* formula_;
} _union;
};
struct DBCell : public Record
{
DBCell();
virtual ULONG Read(const char* data);
virtual ULONG Write(char* data);
virtual ULONG DataSize();
virtual ULONG RecordSize();
ULONG firstRowOffset_;
vector<USHORT> offsets_;
};
ULONG Read(const char* data);
ULONG Write(char* data);
ULONG DataSize();
ULONG RecordSize();
vector<Row> rows_;
vector<SmartPtr<CellBlock> > cellBlocks_;
DBCell dbcell_;
};
ULONG Read(const char* data);
ULONG Write(char* data);
ULONG DataSize();
ULONG RecordSize();
vector<RowBlock> rowBlocks_;
};
struct Window2 : public Record
{
Window2();
virtual ULONG Read(const char* data);
virtual ULONG Write(char* data);
USHORT options_;
USHORT firstVisibleRowIndex_;
USHORT firstVisibleColIndex_;
USHORT gridLineColourIndex_;
USHORT unused1_;
USHORT magnificationFactorPageBreakPreview_;
USHORT magnificationFactorNormalView_;
ULONG unused2_;
};
struct SCL;
struct Pane;
struct Selection;
struct MergedCells
{
struct MergedCell
{
MergedCell();
virtual ULONG Read(const char* data);
virtual ULONG Write(char* data);
ULONG DataSize();
ULONG RecordSize();
USHORT firstRow_;
USHORT lastRow_;
USHORT firstColumn_;
USHORT lastColumn_;
};
ULONG Read(const char* data);
ULONG Write(char* data);
ULONG DataSize();
ULONG RecordSize();
vector<MergedCell> mergedCellsVector_;
};
struct LabelRanges;
struct ConditionalFormattingTable;
struct HyperlinkTable;
struct SheetLayout;
struct SheetProtection;
struct RangeProtection;
ULONG Read(const char* data);
ULONG Write(char* data);
ULONG DataSize();
ULONG RecordSize();
BOF bof_;
Index index_;
ColInfos colinfos_;
Dimensions dimensions_;
CellTable cellTable_;
Window2 window2_;
MergedCells mergedCells_;
YEOF eof_;
};
double GetDoubleFromRKValue(LONG rkValue); ///< Convert a rk value to a double.
int GetIntegerFromRKValue(LONG rkValue); ///< Convert a rk value to an integer.
LONG GetRKValueFromDouble(double value); ///< Convert a double to a rk value.
LONG GetRKValueFromInteger(int value); ///< Convert an integer to a rk value.
bool CanStoreAsRKValue(double value); ///< Returns true if the supplied double can be stored as a rk value.
// Forward declarations
class BasicExcel;
class BasicExcelWorksheet;
class BasicExcelCell;
/*******************************************************************************************************/
/* Actual classes to read and write to Excel files */
/*******************************************************************************************************/
class BasicExcel
{
public:
BasicExcel();
BasicExcel(const char* filename);
~BasicExcel();
public: // File functions.
void New(int sheets=3); ///< Create a new Excel workbook with a given number of spreadsheets (Minimum 1).
bool Load(const char* filename); ///< Load an Excel workbook from a file.
bool Load(const wchar_t* filename); ///< Load an Excel workbook from a file.
bool Save(); ///< Save current Excel workbook to opened file.
bool SaveAs(const char* filename); ///< Save current Excel workbook to a file.
bool SaveAs(const wchar_t* filename); ///< Save current Excel workbook to a file.
void Close();
public: // Worksheet functions.
int GetTotalWorkSheets(); ///< Total number of Excel worksheets in current Excel workbook.
BasicExcelWorksheet* GetWorksheet(int sheetIndex); ///< Get a pointer to an Excel worksheet at the given index. Index starts from 0. Returns 0 if index is invalid.
BasicExcelWorksheet* GetWorksheet(const char* name); ///< Get a pointer to an Excel worksheet that has given ANSI name. Returns 0 if there is no Excel worksheet with the given name.
BasicExcelWorksheet* GetWorksheet(const wchar_t* name); ///< Get a pointer to an Excel worksheet that has given Unicode name. Returns 0 if there is no Excel worksheet with the given name.
BasicExcelWorksheet* AddWorksheet(int sheetIndex=-1); ///< Add a new Excel worksheet to the given index. Name given to worksheet is SheetX, where X is a number which starts from 1. Index starts from 0. Worksheet is added to the last position if sheetIndex == -1. Returns a pointer to the worksheet if successful, 0 if otherwise.
BasicExcelWorksheet* AddWorksheet(const char* name, int sheetIndex=-1); ///< Add a new Excel worksheet with given ANSI name to the given index. Index starts from 0. Worksheet is added to the last position if sheetIndex == -1. Returns a pointer to the worksheet if successful, 0 if otherwise.
BasicExcelWorksheet* AddWorksheet(const wchar_t* name, int sheetIndex=-1); ///< Add a new Excel worksheet with given Unicode name to the given index. Index starts from 0. Worksheet is added to the last position if sheetIndex == -1. Returns a pointer to the worksheet if successful, 0 if otherwise.
bool DeleteWorksheet(int sheetIndex); ///< Delete an Excel worksheet at the given index. Index starts from 0. Returns true if successful, false if otherwise.
bool DeleteWorksheet(const char* name); ///< Delete an Excel worksheet that has given ANSI name. Returns true if successful, false if otherwise.
bool DeleteWorksheet(const wchar_t* name); ///< Delete an Excel worksheet that has given Unicode name. Returns true if successful, false if otherwise.
char* GetAnsiSheetName(int sheetIndex); ///< Get the worksheet name at the given index. Index starts from 0. Returns 0 if name is in Unicode format.
wchar_t* GetUnicodeSheetName(int sheetIndex); ///< Get the worksheet name at the given index. Index starts from 0. Returns 0 if name is in Ansi format.
bool GetSheetName(int sheetIndex, char* name); ///< Get the worksheet name at the given index. Index starts from 0. Returns false if name is in Unicode format.
bool GetSheetName(int sheetIndex, wchar_t* name); ///< Get the worksheet name at the given index. Index starts from 0. Returns false if name is in Ansi format.
bool RenameWorksheet(int sheetIndex, const char* to); ///< Rename an Excel worksheet at the given index to the given ANSI name. Index starts from 0. Returns true if successful, false if otherwise.
bool RenameWorksheet(int sheetIndex, const wchar_t* to); ///< Rename an Excel worksheet at the given index to the given Unicode name. Index starts from 0. Returns true if successful, false if otherwise.
bool RenameWorksheet(const char* from, const char* to); ///< Rename an Excel worksheet that has given ANSI name to another ANSI name. Returns true if successful, false if otherwise.
bool RenameWorksheet(const wchar_t* from, const wchar_t* to); ///< Rename an Excel worksheet that has given Unicode name to another Unicode name. Returns true if successful, false if otherwise.
private: // Functions to read and write raw Excel format.
size_t Read(const char* data, size_t dataSize);
size_t Write(char* data);
void AdjustStreamPositions();
void AdjustBoundSheetBOFPositions();
void AdjustDBCellPositions();
void AdjustExtSSTPositions();
enum {WORKBOOK_GLOBALS=0x0005, VISUAL_BASIC_MODULE=0x0006,
WORKSHEET=0x0010, CHART=0x0020};
private: // Internal functions
void UpdateYExcelWorksheet(); ///< Update yesheets_ using information from worksheets_.
void UpdateWorksheets(); ///< Update worksheets_ using information from yesheets_.
public:
CompoundFile file_; ///< Compound file handler.
Workbook workbook_; ///< Raw Workbook.
vector<Worksheet> worksheets_; ///< Raw Worksheets.
vector<SmartPtr<BasicExcelWorksheet> > yesheets_; ///< Parsed Worksheets.
};
class BasicExcelWorksheet : public RefCount::RefCnt
{
friend class BasicExcel;
public:
BasicExcelWorksheet(BasicExcel* excel, int sheetIndex);
public: // Worksheet functions
char* GetAnsiSheetName(); ///< Get the current worksheet name. Returns 0 if name is in Unicode format.
wchar_t* GetUnicodeSheetName(); ///< Get the current worksheet name. Returns 0 if name is in Ansi format.
bool GetSheetName(char* name); ///< Get the current worksheet name. Returns false if name is in Unicode format.
bool GetSheetName(wchar_t* name); ///< Get the current worksheet name. Returns false if name is in Ansi format.
bool Rename(const char* to); ///< Rename current Excel worksheet to another ANSI name. Returns true if successful, false if otherwise.
bool Rename(const wchar_t* to); ///< Rename current Excel worksheet to another Unicode name. Returns true if successful, false if otherwise.
void Print(ostream& os, char delimiter=',', char textQualifier='\0') const; ///< Print entire worksheet to an output stream, separating each column with the defined delimiter and enclosing text using the defined textQualifier. Leave out the textQualifier argument if do not wish to have any text qualifiers.
public: // Cell functions
int GetTotalRows() const; ///< Total number of rows in current Excel worksheet.
int GetTotalCols() const; ///< Total number of columns in current Excel worksheet.
BasicExcelCell* Cell(int row, int col); ///< Return a pointer to an Excel cell. row and col starts from 0. Returns 0 if row exceeds 65535 or col exceeds 255.
const BasicExcelCell* Cell(int row, int col) const; ///< Return a pointer to an Excel cell. row and col starts from 0. Returns 0 if row exceeds 65535 or col exceeds 255.
bool EraseCell(int row, int col); ///< Erase content of a cell. row and col starts from 0. Returns true if successful, false if row or col exceeds range.
void SetColWidth(const int colindex , const USHORT colwidth);
USHORT GetColWidth(const int colindex);
void MergeCells(int row, int col, USHORT rowRange, USHORT colRange);
private: // Internal functions
void UpdateCells(); ///< Update cells using information from BasicExcel.worksheets_.
private:
BasicExcel* excel_; ///< Pointer to instance of BasicExcel.
int sheetIndex_; ///< Index of worksheet in workbook.
int maxRows_; ///< Total number of rows in worksheet.
int maxCols_; ///< Total number of columns in worksheet.
vector<vector<BasicExcelCell> > cells_; ///< Cells matrix.
Worksheet::ColInfos colInfos_; /// used to record column info
};
class BasicExcelCell
{
public:
BasicExcelCell();
enum {UNDEFINED, INT, DOUBLE, STRING, WSTRING, FORMULA/*MF*/};
int Type() const; ///< Get type of value stored in current Excel cell. Returns one of the above enums.
bool Get(int& val) const; ///< Get an integer value. Returns false if cell does not contain an integer or a double.
bool Get(double& val) const; ///< Get a double value. Returns false if cell does not contain a double or an integer.
size_t GetStringLength() const; ///< Return length of ANSI or Unicode string (excluding null character).
int GetInteger() const; ///< Get an integer value. Returns 0 if cell does not contain an integer.
double GetDouble() const; ///< Get a double value. Returns 0.0 if cell does not contain a double.
const char* GetString() const; ///< Get an ANSI string. Returns 0 if cell does not contain an ANSI string.
const wchar_t* GetWString() const; ///< Get an Unicode string. Returns 0 if cell does not contain an Unicode string.
friend ostream& operator<<(ostream& os, const BasicExcelCell& cell); ///< Print cell to output stream. Print a null character if cell is undefined.
void Set(int val); ///< Set content of current Excel cell to an integer.
void Set(double val); ///< Set content of current Excel cell to a double.
void Set(const char* str); ///< Set content of current Excel cell to an ANSI string.
void Set(const wchar_t* str); ///< Set content of current Excel cell to an Unicode string.
void SetInteger(int val); ///< Set content of current Excel cell to an integer.
void SetDouble(double val); ///< Set content of current Excel cell to a double.
void SetRKValue(int rkValue); ///< Set content of current Excel cell to a double or integer value.
void SetString(const char* str); ///< Set content of current Excel cell to an ANSI string.
void SetWString(const wchar_t* str);///< Set content of current Excel cell to an Unicode string.
void SetFormula(const Worksheet::CellTable::RowBlock::CellBlock::Formula& f);//MF
int GetXFormatIdx() const {return _xf_idx;} //MF
void SetXFormatIdx(int xf_idx) {_xf_idx = xf_idx;} //MF
void SetFormat(const ExcelFormat::CellFormat& fmt); //MF
void EraseContents(); ///< Erase the content of current Excel cell. Set type to UNDEFINED.
USHORT GetMergedRows() const {return mergedRows_;}
USHORT GetMergedColumns() const {return mergedColumns_;}
void SetMergedRows(USHORT mergedRows) {mergedRows_ = mergedRows;}
void SetMergedColumns(USHORT mergedColumns) {mergedColumns_ = mergedColumns;}
private:
int type_; ///< Type of value stored in current Excel cell. Contains one of the above enums.
int ival_; ///< Integer value stored in current Excel cell.
double dval_; ///< Double value stored in current Excel cell.
vector<char> str_; ///< ANSI string stored in current Excel cell. Include null character.
vector<wchar_t> wstr_; ///< Unicode string stored in current Excel cell. Include null character.
USHORT mergedRows_; ///< Number of rows merged to this cell. 1 means only itself.
USHORT mergedColumns_; ///< Number of columns merged to this cell. 1 means only itself.
bool Get(char* str) const; ///< Get an ANSI string. Returns false if cell does not contain an ANSI string.
bool Get(wchar_t* str) const; ///< Get an Unicode string. Returns false if cell does not contain an Unicode string.
//MF extensions for formating and formulas ...
int _xf_idx; //MF
friend class BasicExcel;
friend class BasicExcelWorksheet; // for Get(w/char*);
struct Formula : public RefCount::RefCnt
{
Formula(const Worksheet::CellTable::RowBlock::CellBlock::Formula& f);
int _formula_type;
vector<char> _formula;
unsigned char _result[8]; // formula result (IEEE 754 floating-point value, 64-bit double precision or other special values)
std::wstring wstr_; // formula result in case of strings, stored as UTF-16LE string
std::string str_; // formula result in case of strings, stored as ANSI string
//shrfmla1_
USHORT firstRowIndex_;
USHORT lastRowIndex_;
char firstColIndex_;
char lastColIndex_;
USHORT unused_;
vector<char> shrformula_;
};
SmartPtr<Formula> _pFormula;
bool get_formula(Worksheet::CellTable::RowBlock::CellBlock* pCell) const;
};
} // namespace YExcel
#endif
| [
"[email protected]"
] | [
[
[
1,
1913
]
]
] |
a7f4d6d140b74dd8a8fbb0260050a5265b117a87 | a0155e192c9dc2029b231829e3db9ba90861f956 | /Libs/mwnlm/Libraries/MSL C++/Include/stringfwd.h | 18563a8d01ddf7aa5fe239756d376c5976cd81cb | [] | no_license | zeha/mailfilter | d2de4aaa79bed2073cec76c93768a42068cfab17 | 898dd4d4cba226edec566f4b15c6bb97e79f8001 | refs/heads/master | 2021-01-22T02:03:31.470739 | 2010-08-12T23:51:35 | 2010-08-12T23:51:35 | 81,022,257 | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 608 | h | /* Metrowerks Standard Library
* Copyright © 1995-2002 Metrowerks Corporation. All rights reserved.
*
* $Date: 2002/07/01 21:13:37 $
* $Revision: 1.2 $
*/
// stringfwd.h
// WARNING
//
// stringfwd.h is a non-standard, non-portable header.
//
// WARNING
#ifndef _STRINGFWD_H
#define _STRINGFWD_H
#include <stringfwd>
#ifndef _MSL_NO_CPP_NAMESPACE
using std::allocator;
using std::char_traits;
using std::basic_string;
using std::string;
#ifndef _MSL_NO_WCHART_CPP_SUPPORT
using std::wstring;
#endif
#endif
#endif // _STRINGFWD_H
// hh 991114 Created
| [
"[email protected]"
] | [
[
[
1,
35
]
]
] |
225e03e1eafaf5d8d8cda86113b1cf380a1340e4 | ab2777854d7040cc4029edcd1eccc6d48ca55b29 | /Algorithm/KiriKiri/Kirikiri.h | 96a0553dbe5a105edfc628a6fe490ab0611ad537 | [] | no_license | adrix89/araltrans03 | f9c79f8e5e62a23bbbd41f1cdbcaf43b3124719b | 6aa944d1829006a59d0f7e4cf2fef83e3f256481 | refs/heads/master | 2021-01-10T19:56:34.730964 | 2009-12-21T16:21:45 | 2009-12-21T16:21:45 | 38,417,581 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 2,367 | h | // Kirikiri.h : Kirikiri DLL의 기본 헤더 파일입니다.
//
#pragma once
#ifndef __AFXWIN_H__
#error "PCH에 대해 이 파일을 포함하기 전에 'stdafx.h'를 포함합니다."
#endif
#include "resource.h" // 주 기호입니다.
#include "OptionMgr.h"
#include "KAGScriptMgr.h"
#include "../../Common/DefStruct.h" // AralTrans 함수 및 구조체가 정의된 헤더 파일 Include
using namespace std;
// 스트링관련 오리지널 함수 엔트리
typedef DWORD (__stdcall * PROC_GetGlyphOutline)(HDC, UINT, UINT, LPGLYPHMETRICS, DWORD, LPVOID, CONST MAT2*);
typedef int (__stdcall * PROC_WideCharToMultiByte)(UINT,DWORD,LPCWSTR,int,LPSTR,int,LPCSTR,LPBOOL);
typedef int (__stdcall * PROC_MultiByteToWideChar)(UINT,DWORD,LPCSTR,int,LPWSTR,int);
typedef struct _TEXT_FUNCTION_ENTRY
{
PROC_WideCharToMultiByte pfnOrigWideCharToMultiByte;
PROC_MultiByteToWideChar pfnOrigMultiByteToWideChar;
} TEXT_FUNCTION_ENTRY, *PTEXT_FUNCTION_ENTRY;
// CKirikiriApp
// 이 클래스의 구현을 보려면 Kirikiri.cpp를 참조하십시오.
//
class CKirikiriApp : public CWinApp
{
private:
HMODULE m_hContainer;
HWND m_hContainerWnd;
LPWSTR m_wszOptionString;
COptionNode m_optionRoot;
UINT_PTR m_pCodePoint;
BYTE m_byteRegister;
LPCWSTR m_cwszOrigScript;
LPWSTR m_wszScriptBuf;
CKAGScriptMgr2 m_ScriptMgr;
BOOL m_bUseCodePoint2;
int m_nCodePoint2Type;
UINT_PTR m_pCodePoint2;
void ResetOption();
BOOL AdjustOption(COptionNode* pRootNode);
BOOL HookKirikiri();
BOOL HookKirikiri2();
void UnhookKiriKiri2();
void OnScriptLoad(REGISTER_ENTRY* pRegisters);
void OnArrayLoad(REGISTER_ENTRY* pRegisters);
static void PointCallback(LPVOID pHookedPoint, REGISTER_ENTRY* pRegisters);
public:
CONTAINER_PROC_ENTRY m_sATCTNR3;
TEXT_FUNCTION_ENTRY m_sTextFunc;
CKirikiriApp();
~CKirikiriApp();
BOOL ApplyOption( COptionNode* pRootNode );
BOOL ClearCache();
CKAGScriptMgr* GetKAGScriptMgr(){ return &m_ScriptMgr; };
LPCWSTR GetOriginalScript(){ return m_cwszOrigScript; };
LPWSTR GetScriptBuffer(){ return m_wszScriptBuf; };
BOOL Init(HWND hAralWnd, LPWSTR wszPluginOption);
BOOL Option();
BOOL Close();
virtual BOOL InitInstance();
virtual BOOL ExitInstance();
DECLARE_MESSAGE_MAP()
};
| [
"arallab3@883913d8-bf2b-11de-8cd0-f941f5a20a08"
] | [
[
[
1,
84
]
]
] |
d4a9f6e428827827b59a2e114f4cbf3c4f074483 | ae028b72ebee6160043284f61aa0414c23cbfd0a | /Examples/Compile/CPP/EasyHelloWorld/Src/Hello.cpp | 069c43a28c0609ebe32e6d7c1d2796273b1d9923 | [] | no_license | XueHL/wudoo | c7aa60a93e1eabd2dc97987f5866582a2108bce2 | e46761a02364bf453542b4f2cb919fb310d6ac02 | refs/heads/master | 2021-01-10T14:35:48.452210 | 2009-12-31T21:00:00 | 2009-12-31T21:00:00 | 50,088,931 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 100 | cpp | #include "Hello.h"
Hello::Hello( int i )
{
}
char * Hello::Get()
{
return "Hello\n";
}
| [
"rchbiu@localhost"
] | [
[
[
1,
10
]
]
] |
8a151f0e16a40367c2e4a544875aa8f134064e29 | 36d0ddb69764f39c440089ecebd10d7df14f75f3 | /プログラム/Game/Object/GameScene/PlayerParameter.h | 954309618330e448380ca5c992a5a25a34f58571 | [] | no_license | weimingtom/tanuki-mo-issyo | 3f57518b4e59f684db642bf064a30fc5cc4715b3 | ab57362f3228354179927f58b14fa76b3d334472 | refs/heads/master | 2021-01-10T01:36:32.162752 | 2009-04-19T10:37:37 | 2009-04-19T10:37:37 | 48,733,344 | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 3,074 | h | /*******************************************************************************/
/**
* @file PlayerParameter.h.
*
* @brief プレイヤーパラメータークラスヘッダ定義.
*
* @date 2008/12/18.
*
* @version 1.00.
*
* @author Jun Futagawa.
*/
/*******************************************************************************/
#ifndef _PLAYERPARAMETER_H_
#define _PLAYERPARAMETER_H_
#include "IGameDevice.h"
#include "Manager/Object/ObjectManager.h"
#include "Object/ObjectBase.h"
#include "Scene/GameSceneState.h"
#include "Manager/Scene/Option/Option.h"
class PlayerParameter
{
public:
/*=========================================================================*/
/**
* @brief コンストラクタ.
*
*/
PlayerParameter(int hp, int skillPoint[], int maxPlayerTime, int playerTime,
int characterID, int score, int playerID,
int playerLV, int playerAttack, int playerDefence,
int playerType, int cblock, int mblock,int maxHp);
/*=========================================================================*/
/**
* @brief デストラクタ.
*
*/
~PlayerParameter();
int GetHp();
void SetHp(int hp);
int* GetSkillPoint();
void SetSkillPoint(int skillPoint[]);
int GetPlayerTime();
void SetPlayerTime(int playerTime);
int GetCharacterID();
void SetCharacterID(int characterID);
int GetScore();
void SetScore(int Score);
int GetPlayerID();
void SetPlayerID(int playerID);
int GetPlayerLV();
void SetPlayerLV(int playerLV);
int GetPlayerAttack();
void SetPlayerAttack(int playerAttack);
int GetPlayerDefence();
void SetPlayerDefence(int playerDefence);
int GetPlayerType();
void SetPlayerType(int playerType);
int GetNextCBlock();
int GetNextMBlock();
void SetNextBlock(int cblock, int mblock);
int GetMaxHp();
void SetMaxHp(int maxHp);
int GetMaxPlayerTime();
void SetMaxPlayerTime(int maxPlayerTime);
int GetPlayerJudge();
void SetPlayerJudge(int judge);
bool GetIsCreateBlock();
void SetIsCreateBlock(bool flag);
int GetEffectCount();
void AddEffectCount();
void SubEffectCount();
private:
/** HP */
int m_hp;
/** スキルポイント */
int m_skillPoint[4];
/** プレイヤータイム */
int m_playerTime;
/** キャラクターID */
int m_characterID;
/** スコア */
int m_score;
/** プレイヤーID */
int m_playerID;
/** プレイヤーLV */
int m_playerLV;
/** プレイヤー攻撃力 */
int m_playerAttack;
/** プレイヤー防御力 */
int m_playerDefence;
/** プレイヤー属性 */
int m_playerType;
/** 次のブロックの軸ID */
int m_nextCBlock;
/** 次のブロックのサブID */
int m_nextMBlock;
/** マックスHP */
int m_maxHp;
/** プレイヤータイム最大値 */
int m_maxPlayerTime;
/** プレイヤー勝敗状態 */
int m_playerJudge;
/** 次のブロック生成可能状態フラグ */
bool m_isCreateBlock;
int m_effectCount;
};
#endif | [
"rs.drip@aa49b5b2-a402-11dd-98aa-2b35b7097d33"
] | [
[
[
1,
133
]
]
] |
cc0b9f60c13270fbfc77af0380259609c2b374ac | 3472e587cd1dff88c7a75ae2d5e1b1a353962d78 | /ytk_bak/sqlitebrowser/debug/moc_sqllogform.cpp | a05338da9753fb4cbe75e767d3f09a486a7d7e10 | [] | no_license | yewberry/yewtic | 9624d05d65e71c78ddfb7bd586845e107b9a1126 | 2468669485b9f049d7498470c33a096e6accc540 | refs/heads/master | 2021-01-01T05:40:57.757112 | 2011-09-14T12:32:15 | 2011-09-14T12:32:15 | 32,363,059 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,418 | cpp | /****************************************************************************
** Meta object code from reading C++ file 'sqllogform.h'
**
** Created: Sun Jan 3 14:58:42 2010
** by: The Qt Meta Object Compiler version 61 (Qt 4.5.2)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "../sqllogform.h"
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'sqllogform.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 61
#error "This file was generated using the moc from 4.5.2. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
static const uint qt_meta_data_sqlLogForm[] = {
// content:
2, // revision
0, // classname
0, 0, // classinfo
7, 12, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
// signals: signature, parameters, type, tag, flags
12, 11, 11, 11, 0x05,
30, 24, 11, 11, 0x05,
// slots: signature, parameters, type, tag, flags
44, 11, 11, 11, 0x0a,
87, 69, 11, 11, 0x0a,
105, 24, 11, 11, 0x0a,
127, 11, 11, 11, 0x0a,
138, 11, 11, 11, 0x09,
0 // eod
};
static const char qt_meta_stringdata_sqlLogForm[] = {
"sqlLogForm\0\0goingAway()\0dirty\0"
"dbState(bool)\0closeEvent(QCloseEvent*)\0"
"statement,msgtype\0log(QString&,int)\0"
"msgDBDirtyState(bool)\0clearLog()\0"
"languageChange()\0"
};
const QMetaObject sqlLogForm::staticMetaObject = {
{ &QDialog::staticMetaObject, qt_meta_stringdata_sqlLogForm,
qt_meta_data_sqlLogForm, 0 }
};
const QMetaObject *sqlLogForm::metaObject() const
{
return &staticMetaObject;
}
void *sqlLogForm::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_sqlLogForm))
return static_cast<void*>(const_cast< sqlLogForm*>(this));
if (!strcmp(_clname, "Ui::sqlLogForm"))
return static_cast< Ui::sqlLogForm*>(const_cast< sqlLogForm*>(this));
return QDialog::qt_metacast(_clname);
}
int sqlLogForm::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QDialog::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
switch (_id) {
case 0: goingAway(); break;
case 1: dbState((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 2: closeEvent((*reinterpret_cast< QCloseEvent*(*)>(_a[1]))); break;
case 3: log((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
case 4: msgDBDirtyState((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 5: clearLog(); break;
case 6: languageChange(); break;
default: ;
}
_id -= 7;
}
return _id;
}
// SIGNAL 0
void sqlLogForm::goingAway()
{
QMetaObject::activate(this, &staticMetaObject, 0, 0);
}
// SIGNAL 1
void sqlLogForm::dbState(bool _t1)
{
void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
QMetaObject::activate(this, &staticMetaObject, 1, _a);
}
QT_END_MOC_NAMESPACE
| [
"yew1998@5ddc4e96-dffd-11de-b4b3-6d349e4f6f86"
] | [
[
[
1,
106
]
]
] |
5dadc12e4cdd124a520d59550adb8cef8129f721 | 4b9e292f5caa0e9d5612ce916d6e2c2d94ab3c0b | /StickFigure.cpp | b4990bd29b2cff9dd503e06d4ff3c30762ef2be2 | [] | no_license | pkmital/StickFigureOSC | 696cdb2bacaf590967aa5c6f182492c1e9ee5b31 | 9eaae70dfa2e09bf67d5f4930fbfc9a6b39dbdaa | refs/heads/master | 2021-01-10T18:35:14.967176 | 2011-01-24T21:29:10 | 2011-01-24T21:29:10 | 1,289,135 | 5 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 40,084 | cpp | /****************************************************************************
* *
* Nite 1.3 - Stick Figure Sample *
* *
* Author: Oz Magal, Ilan Atias, Alon Haber *
* Based on PrimeSense EE Sample 3DViewer, by Ziv Hendel *
* *
****************************************************************************/
/****************************************************************************
* *
* Nite 1.3 *
* Copyright (C) 2006 PrimeSense Ltd. All Rights Reserved. *
* *
* This file has been provided pursuant to a License Agreement containing *
* restrictions on its use. This data contains valuable trade secrets *
* and proprietary information of PrimeSense Ltd. and is protected by law. *
* *
****************************************************************************/
// Application Usage:
// 1 � Top right perspective camera view.
// 2 � Front camera view.
// 3 � Top camera view.
// 4 � Side camera view.
// s � Enable/Disable stick figure.
// p � Show the laser pointer and the cutoff parameters.
// m � Enable/Disable the mirror mode.
// c � Recalibrate first user (White user).
// C - Recalibrate second user (Black user).
// z - Enable/Disable 3D points view.
// o - Enable/Disable orientation drawing.
// b - Enable/Disable background.
// k - Start/Stop recording. (to Data\recording.xns)
// q � Decrease the minimum depth cutoff by 1.
// Q � Decrease the minimum depth cutoff by 50.
// w � Increase the minimum depth cutoff by 1.
// W � Increase the minimum depth cutoff by 50.
// e � Decrease the maximum depth cutoff by 1.
// E � Decrease the maximum depth cutoff by 50.
// r � Increase the maximum depth cutoff by 1.
// R � Increase the maximum depth cutoff by 50.
// + - Increase the GL point size by 1.
// - - Decrease the GL point size by 1.
// ESC � exit.
// --------------------------------
// Includes
// --------------------------------
#include <XnOpenNI.h>
#include <XnList.h>
#include <XnCppWrapper.h>
#include <XnCodecIDs.h>
#define GLH_EXT_SINGLE_FILE
#include "glh/glh_extensions.h"
#include "glh/glh_obs.h"
#include "glh/glh_glut2.h"
#include "glh/glh_glut_text.h"
using namespace glh;
// [parag]: OSC stuff
// --------------------------------
#include "ofxOsc.h"
#define HOST "localhost"
#define PORT 12345
bool bSendOSC = true;
ofxOscSender sender;
void sendOSCMarker(string prefix, XnSkeletonJointPosition &pos, XnSkeletonJointOrientation &ori);
#ifndef max(a,b)
#define max(a,b) (a) > (b) ? (a) : (b)
#endif
// --------------------------------
// Defines
// --------------------------------
#define GLSX -1.0
#define GLSY -1.0
#define GLSZ 1.0
#define GLUX 2.0
#define GLVY 2.0
#define WIN_SIZE_X 1280
#define WIN_SIZE_Y 1024
// [parag]: I've moved the sample data files into the root of the project folder in a
// directory called Data
#define RECORD_FILE "../../../Data/Recording.oni"
#define SAMPLE_XML_PATH "../../../Data/Sample-User.xml"
// --------------------------------
// Global Variables
// --------------------------------
glut_callbacks cb;
glut_simple_mouse_interactor camera, light, room, object;
glut_perspective_reshaper reshaper;
display_list face;
tex_object_2D wall;
bool b[256];
vec4f light_position(1,1,1,1);
float room_ambient = .4;
bool bDoRGBFix = true;
bool bStaticFilter = false;
bool bRealWorld = true;
bool bShowPointer = false;
bool g_bDrawOrientations = false;
bool g_bPrintFrameID = false;
int nGLPointSize = 5;
bool g_bDrawPointCloud = true;
bool g_verbose = false;
bool g_bRecord = false;
xn::Recorder* g_pRecorder;
int nPointerX;
int nPointerY;
int nPointerDiffX;
int nPointerDiffY;
XnUInt64 nCutOffMin;
XnUInt64 nCutOffMax;
short* PointCloudShadowArr;
float fXRes;
float fYRes;
float fMaxDepth;
xn::Context g_Context;
xn::DepthGenerator g_DepthGenerator;
xn::UserGenerator g_UserGenerator;
double g_LastSmoothingFactor = 0.0;
XnBool g_bCalibrate1 = false, g_bCalibrate2 = false;
XnBool g_bShowBG = false;
XnBool g_IsSkeletonEnabled = true;
// --------------------------------
// Function Declaration
// --------------------------------
void display();
void key(unsigned char k, int x, int y);
void draw_pointcloud();
void draw_mesh(float size, int tess);
void draw_cube();
void draw_room(bool do_diffuse);
void idle();
void init_opengl();
void init_model();
void glPrintString(void *font, char *str);
// --------------------------------
// Code
// --------------------------------
void glPrintString(void *font, char *str)
{
int i,l = strlen(str);
for(i=0; i<l; i++)
{
glutBitmapCharacter(font,*str++);
}
}
void MotionCallback(int x, int y)
{
nPointerX = x / nPointerDiffX;
nPointerY = y / nPointerDiffY;
}
// [parag]: I completely hacked this i had no idea what the original return values were all about
// but now they are just int and void *... this does crash occasionally when there
// are multiple skeletons being tracked!!!
/*
DWORD WINAPI EEThreadProc(LPVOID lpThreadParameter)
{
{
g_Context.WaitAndUpdateAll();
if (g_bRecord)
{
g_pRecorder->Record();
}
}
return 0;
}
*/
int EEThreadProc(void *lpThreadParameter)
{
{
g_Context.WaitAndUpdateAll();
if (g_bRecord)
{
g_pRecorder->Record();
}
}
return 0;
}
void XN_CALLBACK_TYPE NewUser(xn::UserGenerator& generator, XnUserID user, void* pCookie)
{
printf("New user identified: %d\n", user);
g_UserGenerator.GetPoseDetectionCap().StartPoseDetection("Psi", user);
}
void XN_CALLBACK_TYPE LostUser(xn::UserGenerator& generator, XnUserID user, void* pCookie)
{
printf("User %d lost\n", user);
}
void XN_CALLBACK_TYPE CalibrationStart(xn::SkeletonCapability& skeleton, XnUserID user, void* pCookie)
{
printf("Calibration start for user %d\n", user);
}
void XN_CALLBACK_TYPE CalibrationEnd(xn::SkeletonCapability& skeleton, XnUserID user, XnBool bSuccess, void* pCookie)
{
printf("Calibration complete for user %d: %s\n", user, bSuccess?"Success":"Failure");
if (bSuccess)
{
skeleton.StartTracking(user);
}
else
{
g_UserGenerator.GetPoseDetectionCap().StartPoseDetection("Psi", user);
}
}
void XN_CALLBACK_TYPE PoseDetected(xn::PoseDetectionCapability& poseDetection, const XnChar* strPose, XnUserID nId, void* pCookie)
{
printf("Pose '%s' detected for user %d\n", strPose, nId);
g_UserGenerator.GetSkeletonCap().RequestCalibration(nId, FALSE);
g_UserGenerator.GetPoseDetectionCap().StopPoseDetection(nId);
}
#define CHECK_RC(rc, what) \
if (rc != XN_STATUS_OK) \
{ \
printf("%s failed: %s\n", what, xnGetStatusString(rc)); \
return rc; \
}
#include <XnLog.h>
int main(int argc, char **argv)
{
sender.setup(HOST, PORT);
XnStatus rc = XN_STATUS_OK;
rc = g_Context.InitFromXmlFile(SAMPLE_XML_PATH);
CHECK_RC(rc, "InitFromXml");
rc = g_Context.FindExistingNode(XN_NODE_TYPE_DEPTH, g_DepthGenerator);
CHECK_RC(rc, "Find depth generator");
rc = g_Context.FindExistingNode(XN_NODE_TYPE_USER, g_UserGenerator);
CHECK_RC(rc, "Find user generator");
XnCallbackHandle h;
g_UserGenerator.RegisterUserCallbacks(NewUser, LostUser, NULL, h);
g_UserGenerator.GetSkeletonCap().SetSkeletonProfile(XN_SKEL_PROFILE_ALL);
XnCallbackHandle hCalib;
XnCallbackHandle hPose;
g_UserGenerator.GetSkeletonCap().RegisterCalibrationCallbacks(&CalibrationStart, &CalibrationEnd, NULL, hCalib);
g_UserGenerator.GetPoseDetectionCap().RegisterToPoseCallbacks(&PoseDetected, NULL, NULL, hPose);
rc = g_Context.StartGeneratingAll();
CHECK_RC(rc, "StartGenerating");
xn::DepthMetaData depthMD;
g_DepthGenerator.GetMetaData(depthMD);
fXRes = depthMD.XRes();
fYRes = depthMD.YRes();
fMaxDepth = depthMD.ZRes();
nCutOffMin = 0;
nCutOffMax = fMaxDepth;
nPointerX = fXRes / 2;
nPointerY = fXRes / 2;
nPointerDiffX = (WIN_SIZE_X / fXRes / 2) + 1;
nPointerDiffY = (WIN_SIZE_Y / fXRes / 2) + 1;
if (argc == 2)
{
nCutOffMax = atol(argv[1]);
}
srand(XnUInt32(time(NULL)));
glutInit(&argc, argv);
glutInitDisplayString("stencil depth>16 double rgb samples=0");
glutInitWindowSize(WIN_SIZE_X, WIN_SIZE_Y);
glutCreateWindow("Prime Sense Stick Figure Sample");
glutSetCursor(GLUT_CURSOR_NONE);
init_opengl();
glut_helpers_initialize();
cb.passive_motion_function = MotionCallback;
cb.keyboard_function = key;
camera.configure_buttons(0);
camera.set_camera_mode(true);
camera.set_parent_rotation( & camera.trackball.r);
camera.enable();
object.configure_buttons(1);
object.translator.t[2] = -1;
object.translator.scale *= .1f;
object.trackball.r = rotationf(vec3f(2.0,0.01,0.01), to_radians(180));
object.set_parent_rotation( & camera.trackball.r);
object.disable();
light.configure_buttons(0);
light.translator.t = vec3f(.5, .5, -1);
light.set_parent_rotation( & camera.trackball.r);
light.disable();
reshaper.zNear = 1;
reshaper.zFar = 100;
// make sure all interactors get glut events
glut_add_interactor(&cb);
glut_add_interactor(&camera);
glut_add_interactor(&reshaper);
glut_add_interactor(&light);
glut_add_interactor(&object);
camera.translator.t = vec3f(0, 0, 0);
camera.trackball.r = rotationf(vec3f(0, 0, 0), to_radians(0));
light.translator.t = vec3f (0, 1.13, -2.41);
light.trackball.r = rotationf(vec3f(0.6038, -0.1955, -0.4391), to_radians(102));
glutIdleFunc(idle);
glutDisplayFunc(display);
// Per frame code is in display
glutMainLoop();
return (0);
}
void init_opengl()
{
glClearStencil(128);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glEnable(GL_NORMALIZE);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
GLfloat ambient[] = {0.5, 0.5, 0.5, 1};
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
glLightf (GL_LIGHT0, GL_QUADRATIC_ATTENUATION, 0.1);
face.new_list(GL_COMPILE);
draw_mesh(20, 40);
face.end_list();
wall.bind();
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
GLfloat * tex = new GLfloat[32*32];
{
for(int i=0; i < 32; i++)
{
for(int j=0; j < 32; j++)
{
if(i>>4 ^ j>>4)
tex[i+j*32] = 1;
else
tex[i+j*32] = .9;
}
}
}
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_LUMINANCE, GL_FLOAT, tex);
delete [] tex;
}
void idle()
{
// [parag]: What is this function!?
EEThreadProc(NULL);
glutPostRedisplay();
}
void StopCapture()
{
g_bRecord = false;
if (g_pRecorder != NULL)
{
g_pRecorder->RemoveNodeFromRecording(g_DepthGenerator);
g_pRecorder->Unref();
delete g_pRecorder;
}
g_pRecorder = NULL;
}
#define START_CAPTURE_CHECK_RC(rc, what) \
if (nRetVal != XN_STATUS_OK) \
{ \
printf("Failed to %s: %s\n", what, xnGetStatusString(rc)); \
StopCapture(); \
return ; \
}
void StartCapture()
{
char recordFile[256] = {0};
time_t rawtime;
struct tm *timeinfo;
time(&rawtime);
timeinfo = localtime(&rawtime);
XnUInt32 size;
xnOSStrFormat(recordFile, sizeof(recordFile)-1, &size,
"%d_%02d_%02d[%02d_%02d_%02d].oni",
timeinfo->tm_year + 1900, timeinfo->tm_mon + 1, timeinfo->tm_mday, timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
if (g_pRecorder != NULL)
{
StopCapture();
}
XnStatus nRetVal = XN_STATUS_OK;
g_pRecorder = new xn::Recorder;
nRetVal = g_Context.CreateAnyProductionTree(XN_NODE_TYPE_RECORDER, NULL, *g_pRecorder);
START_CAPTURE_CHECK_RC(nRetVal, "Create recorder");
nRetVal = g_pRecorder->SetDestination(XN_RECORD_MEDIUM_FILE, recordFile);
START_CAPTURE_CHECK_RC(nRetVal, "set destination");
nRetVal = g_pRecorder->AddNodeToRecording(g_DepthGenerator, XN_CODEC_16Z_EMB_TABLES);
START_CAPTURE_CHECK_RC(nRetVal, "add node");
g_bRecord = true;
}
void Cleanup()
{
if (g_pRecorder)
g_pRecorder->RemoveNodeFromRecording(g_DepthGenerator);
StopCapture();
g_Context.Shutdown();
}
void key(unsigned char k, int x, int y)
{
b[k] = !b[k];
if(k==27)
{
Cleanup();
exit(0);
}
else if('1' == k) // Camera view
{
camera.translator.t = vec3f(1.518, 0.916, -0.959);
camera.trackball.r = rotationf(vec3f(-0.392,0.883,0.191), to_radians(50));
}
else if('2' == k) // Front view
{
camera.translator.t = vec3f(0, 0, 0);
camera.trackball.r = rotationf(vec3f(0, 0, 0), to_radians(0));
}
else if('3' == k) // Top view
{
camera.translator.t = vec3f(0, 3.5, -2);
camera.trackball.r = rotationf(vec3f(-0.5, 0, 0), to_radians(90));
}
else if('4' == k) // Side view
{
camera.translator.t = vec3f(4, 0, -2);
camera.trackball.r = rotationf(vec3f(0, 0.5, 0), to_radians(90));
}
else if('p' == k) // Laser pointer
{
bShowPointer = !bShowPointer;
}
else if('m' == k) // Mirror
{
XnBool bMirror = g_DepthGenerator.GetMirrorCap().IsMirrored();
bMirror = !bMirror;
g_DepthGenerator.GetMirrorCap().SetMirror(bMirror);
}
else if('+' == k) // Point
{
nGLPointSize++;
}
else if('-' == k) // Point
{
nGLPointSize--;
}
else if('z' == k) // draw "zippel" point cloud
{
g_bDrawPointCloud = !g_bDrawPointCloud;
}
else if ('o' == k)
{
g_bDrawOrientations = !g_bDrawOrientations;
}
else if ('b' == k)
{
g_bShowBG = !g_bShowBG;
}
else if ('f' == k)
{
g_bPrintFrameID = !g_bPrintFrameID;
}
else if ('s' == k)
{
XnUserID Users[10];
XnUInt16 nUsers = 10;
g_UserGenerator.GetUsers(Users, nUsers);
g_IsSkeletonEnabled = !g_IsSkeletonEnabled;
for (int i = 0; i < nUsers; ++i)
g_UserGenerator.GetSkeletonCap().StopTracking(Users[i]);
}
else if ('k' == k)
{
if (g_bRecord)
{
// Stop capture
StopCapture();
}
else
{
StartCapture();
// Start capture
}
}
glutPostRedisplay();
}
#define DrawSinglePointRW(point, corner) \
{ \
float fX = (point.X / corner.X); \
float fY = -(point.Y / corner.X); \
float fU = fX + 0.5; \
float fV = fY + 0.5; \
glVertex3f(GLSX + (fU*GLUX), GLSY + (fV*GLVY), point.Z/1000); \
}
#define MAX_DEPTH 10000
float g_pDepthHist[MAX_DEPTH];
XnFloat g_r = 0, g_g = 0, g_b = 0;
void drawStickPoint(XnSkeletonJointPosition p, XnPoint3D corner)
{
float fX = 0;
float fY = 0;
float fU = 0;
float fV = 0;
if (bRealWorld)
{
DrawSinglePointRW(p.position, corner);
}
else
{
XnPoint3D point = p.position;
g_DepthGenerator.ConvertRealWorldToProjective(1, &point, &point);
fU = point.X / fXRes;
fV = point.Y / fYRes;
}
}
void drawStickLine(XnUserID user, xn::UserGenerator userGenerator, XnSkeletonJoint joint1, XnSkeletonJoint joint2, const XnPoint3D& corner)
{
XnSkeletonJointPosition pos1, pos2;
userGenerator.GetSkeletonCap().GetSkeletonJointPosition(user, joint1, pos1);
userGenerator.GetSkeletonCap().GetSkeletonJointPosition(user, joint2, pos2);
if (pos1.fConfidence == 1 &&
pos2.fConfidence == 1)
{
glColor3f(g_r,g_g, g_b);
}
else
{
glColor3f(0.5,0.5,0.5);
if ((pos1.position.X == 0 && pos1.position.Y == 0 && pos1.position.Z == 0) ||
(pos2.position.X == 0 && pos2.position.Y == 0 && pos2.position.Z == 0))
{
return;
}
}
drawStickPoint(pos1, corner);
drawStickPoint(pos2, corner);
}
void drawOrientation(XnUserID user, xn::UserGenerator userGenerator, XnSkeletonJoint joint, const XnPoint3D& corner)
{
XnSkeletonJointOrientation orientation;
XnSkeletonJointPosition position;
userGenerator.GetSkeletonCap().GetSkeletonJointPosition(user, joint, position);
userGenerator.GetSkeletonCap().GetSkeletonJointOrientation(user, joint, orientation);
if (position.fConfidence != 1 &&
orientation.fConfidence != 1)
{
return;
}
XnSkeletonJointPosition virt1, virt2;
virt1.fConfidence = virt2.fConfidence = 1;
glColor3f(1,0,0);
virt1.position = position.position;
virt2.position = xnCreatePoint3D(100*orientation.orientation.elements[0],
100*orientation.orientation.elements[3],
100*orientation.orientation.elements[6]);
drawStickPoint(virt1, corner);
drawStickPoint(virt2, corner);
glColor3f(0,1,0);
virt1.position = position.position;
virt2.position = xnCreatePoint3D(100*orientation.orientation.elements[1],
100*orientation.orientation.elements[4],
100*orientation.orientation.elements[7]);
drawStickPoint(virt1, corner);
drawStickPoint(virt2, corner);
glColor3f(0,0,1);
virt1.position = position.position;
virt2.position = xnCreatePoint3D(100*orientation.orientation.elements[2],
100*orientation.orientation.elements[5],
100*orientation.orientation.elements[8]);
drawStickPoint(virt1, corner);
drawStickPoint(virt2, corner);
}
XnFloat Colors[][3] =
{
{1,0,1},
{1,1,0},
{1,0.5,0},
{0,1,1},
{0,0.5,1},
{1,0,0.5},
{1,1,1}
};
XnUInt32 nColors = 6;
void DrawSingleUser(XnUserID user, xn::UserGenerator g_UserGenerator, const XnPoint3D& corner)
{
glPushMatrix();
object.apply_transform();
glLineWidth(3.0);
glBegin(GL_LINES);
g_r = 1-Colors[user][0];
g_g = 1-Colors[user][1];
g_b = 1-Colors[user][2];
drawStickLine(user, g_UserGenerator, XN_SKEL_LEFT_HAND, XN_SKEL_LEFT_ELBOW, corner);
drawStickLine(user, g_UserGenerator, XN_SKEL_LEFT_HAND, XN_SKEL_LEFT_ELBOW, corner);
drawStickLine(user, g_UserGenerator, XN_SKEL_LEFT_ELBOW, XN_SKEL_LEFT_SHOULDER, corner);
drawStickLine(user, g_UserGenerator, XN_SKEL_LEFT_SHOULDER, XN_SKEL_TORSO, corner);
drawStickLine(user, g_UserGenerator, XN_SKEL_LEFT_SHOULDER, XN_SKEL_RIGHT_SHOULDER, corner);
drawStickLine(user, g_UserGenerator, XN_SKEL_TORSO, XN_SKEL_RIGHT_SHOULDER, corner);
drawStickLine(user, g_UserGenerator, XN_SKEL_RIGHT_SHOULDER, XN_SKEL_RIGHT_ELBOW, corner);
drawStickLine(user, g_UserGenerator, XN_SKEL_RIGHT_ELBOW, XN_SKEL_RIGHT_HAND, corner);
drawStickLine(user, g_UserGenerator, XN_SKEL_NECK, XN_SKEL_HEAD, corner);
drawStickLine(user, g_UserGenerator, XN_SKEL_TORSO, XN_SKEL_LEFT_HIP, corner);
drawStickLine(user, g_UserGenerator, XN_SKEL_TORSO, XN_SKEL_RIGHT_HIP, corner);
drawStickLine(user, g_UserGenerator, XN_SKEL_LEFT_HIP, XN_SKEL_RIGHT_HIP, corner);
drawStickLine(user, g_UserGenerator, XN_SKEL_LEFT_HIP, XN_SKEL_LEFT_KNEE, corner);
drawStickLine(user, g_UserGenerator, XN_SKEL_LEFT_KNEE, XN_SKEL_LEFT_FOOT, corner);
drawStickLine(user, g_UserGenerator, XN_SKEL_RIGHT_HIP, XN_SKEL_RIGHT_KNEE, corner);
drawStickLine(user, g_UserGenerator, XN_SKEL_RIGHT_KNEE, XN_SKEL_RIGHT_FOOT, corner);
XnSkeletonJointPosition leftShoulder;
XnSkeletonJointPosition rightShoulder;
XnSkeletonJointPosition neck;
XnSkeletonJointPosition midShoulder;
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(user, XN_SKEL_LEFT_SHOULDER, leftShoulder);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(user, XN_SKEL_RIGHT_SHOULDER, rightShoulder);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(user, XN_SKEL_NECK, neck);
midShoulder.position = xnCreatePoint3D((leftShoulder.position.X + rightShoulder.position.X) / 2,
(leftShoulder.position.Y + rightShoulder.position.Y) / 2,
(leftShoulder.position.Z + rightShoulder.position.Z) / 2);
midShoulder.fConfidence = (leftShoulder.fConfidence + rightShoulder.fConfidence) / 2;
drawStickPoint(neck, corner);
drawStickPoint(midShoulder, corner);
if (g_bDrawOrientations)
{
drawOrientation(user, g_UserGenerator, XN_SKEL_TORSO, corner);
drawOrientation(user, g_UserGenerator, XN_SKEL_HEAD, corner);
drawOrientation(user, g_UserGenerator, XN_SKEL_LEFT_SHOULDER, corner);
drawOrientation(user, g_UserGenerator, XN_SKEL_RIGHT_SHOULDER, corner);
drawOrientation(user, g_UserGenerator, XN_SKEL_LEFT_ELBOW, corner);
drawOrientation(user, g_UserGenerator, XN_SKEL_RIGHT_ELBOW, corner);
drawOrientation(user, g_UserGenerator, XN_SKEL_NECK, corner);
drawOrientation(user, g_UserGenerator, XN_SKEL_LEFT_HAND, corner);
drawOrientation(user, g_UserGenerator, XN_SKEL_RIGHT_HAND, corner);
drawOrientation(user, g_UserGenerator, XN_SKEL_LEFT_HIP, corner);
drawOrientation(user, g_UserGenerator, XN_SKEL_RIGHT_HIP, corner);
drawOrientation(user, g_UserGenerator, XN_SKEL_LEFT_KNEE, corner);
drawOrientation(user, g_UserGenerator, XN_SKEL_RIGHT_KNEE, corner);
drawOrientation(user, g_UserGenerator, XN_SKEL_LEFT_FOOT, corner);
drawOrientation(user, g_UserGenerator, XN_SKEL_RIGHT_FOOT, corner);
}
if(bSendOSC)
{
XnSkeletonJointPosition leftShoulder;
XnSkeletonJointPosition rightShoulder;
XnSkeletonJointPosition neck;
XnSkeletonJointPosition midShoulder;
XnSkeletonJointPosition torso;
XnSkeletonJointPosition head;
XnSkeletonJointPosition leftElbow;
XnSkeletonJointPosition rightElbow;
XnSkeletonJointPosition leftHand;
XnSkeletonJointPosition rightHand;
XnSkeletonJointPosition leftHip;
XnSkeletonJointPosition rightHip;
XnSkeletonJointPosition leftKnee;
XnSkeletonJointPosition rightKnee;
XnSkeletonJointPosition leftFoot;
XnSkeletonJointPosition rightFoot;
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(user, XN_SKEL_LEFT_SHOULDER, leftShoulder);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(user, XN_SKEL_RIGHT_SHOULDER, rightShoulder);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(user, XN_SKEL_NECK, neck);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(user, XN_SKEL_TORSO, torso);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(user, XN_SKEL_HEAD, head);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(user, XN_SKEL_LEFT_ELBOW, leftElbow);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(user, XN_SKEL_RIGHT_ELBOW, rightElbow);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(user, XN_SKEL_LEFT_HAND, leftHand);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(user, XN_SKEL_RIGHT_HAND, rightHand);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(user, XN_SKEL_LEFT_HIP, leftHip);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(user, XN_SKEL_RIGHT_HIP, rightHip);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(user, XN_SKEL_LEFT_KNEE, leftKnee);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(user, XN_SKEL_RIGHT_KNEE, rightKnee);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(user, XN_SKEL_LEFT_FOOT, leftFoot);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(user, XN_SKEL_RIGHT_FOOT, rightFoot);
midShoulder.position = xnCreatePoint3D((leftShoulder.position.X + rightShoulder.position.X) / 2,
(leftShoulder.position.Y + rightShoulder.position.Y) / 2,
(leftShoulder.position.Z + rightShoulder.position.Z) / 2);
XnSkeletonJointOrientation leftShoulderO;
XnSkeletonJointOrientation rightShoulderO;
XnSkeletonJointOrientation neckO;
XnSkeletonJointOrientation midShoulderO;
XnSkeletonJointOrientation torsoO;
XnSkeletonJointOrientation headO;
XnSkeletonJointOrientation leftElbowO;
XnSkeletonJointOrientation rightElbowO;
XnSkeletonJointOrientation leftHandO;
XnSkeletonJointOrientation rightHandO;
XnSkeletonJointOrientation leftHipO;
XnSkeletonJointOrientation rightHipO;
XnSkeletonJointOrientation leftKneeO;
XnSkeletonJointOrientation rightKneeO;
XnSkeletonJointOrientation leftFootO;
XnSkeletonJointOrientation rightFootO;
g_UserGenerator.GetSkeletonCap().GetSkeletonJointOrientation(user, XN_SKEL_LEFT_SHOULDER, leftShoulderO);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointOrientation(user, XN_SKEL_RIGHT_SHOULDER, rightShoulderO);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointOrientation(user, XN_SKEL_NECK, neckO);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointOrientation(user, XN_SKEL_TORSO, torsoO);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointOrientation(user, XN_SKEL_HEAD, headO);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointOrientation(user, XN_SKEL_LEFT_ELBOW, leftElbowO);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointOrientation(user, XN_SKEL_RIGHT_ELBOW, rightElbowO);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointOrientation(user, XN_SKEL_LEFT_HAND, leftHandO);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointOrientation(user, XN_SKEL_RIGHT_HAND, rightHandO);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointOrientation(user, XN_SKEL_LEFT_HIP, leftHipO);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointOrientation(user, XN_SKEL_RIGHT_HIP, rightHipO);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointOrientation(user, XN_SKEL_LEFT_KNEE, leftKneeO);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointOrientation(user, XN_SKEL_RIGHT_KNEE, rightKneeO);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointOrientation(user, XN_SKEL_LEFT_FOOT, leftFootO);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointOrientation(user, XN_SKEL_RIGHT_FOOT, rightFootO);
sendOSCMarker("/body/head", head, headO);
sendOSCMarker("/body/torso", torso, torsoO);
sendOSCMarker("/body/neck", neck, neckO);
sendOSCMarker("/body/leftShoulder", leftShoulder, leftShoulderO);
sendOSCMarker("/body/rightShoulder", rightShoulder, rightShoulderO);
sendOSCMarker("/body/midShoulder", midShoulder, midShoulderO);
sendOSCMarker("/body/leftElbow", leftElbow, leftElbowO);
sendOSCMarker("/body/rightElbow", rightElbow, rightElbowO);
sendOSCMarker("/body/leftHand", leftHand, leftHandO);
sendOSCMarker("/body/rightHand", rightHand, rightHandO);
sendOSCMarker("/body/leftHip", leftHip, leftHipO);
sendOSCMarker("/body/rightHip", rightHip, rightHipO);
sendOSCMarker("/body/leftKnee", leftKnee, leftKneeO);
sendOSCMarker("/body/rightKnee", rightKnee, rightKneeO);
sendOSCMarker("/body/leftFoot", leftFoot, leftFootO);
sendOSCMarker("/body/rightFoot", rightFoot, rightFootO);
}
glEnd();
glPopMatrix();
}
void sendOSCMarker(string prefix, XnSkeletonJointPosition &pos, XnSkeletonJointOrientation &ori)
{
ofxOscMessage m;
m.setAddress(prefix);
m.addFloatArg(pos.position.X);
m.addFloatArg(pos.position.Y);
m.addFloatArg(pos.position.Z);
float m00 = ori.orientation.elements[0],
m01 = ori.orientation.elements[1],
m02 = ori.orientation.elements[2],
m10 = ori.orientation.elements[3],
m11 = ori.orientation.elements[4],
m12 = ori.orientation.elements[5],
m20 = ori.orientation.elements[6],
m21 = ori.orientation.elements[7],
m22 = ori.orientation.elements[8];
float x, y, z, w;
w = sqrt( max( 0, 1 + m00 + m11 + m22 ) ) / 2.0f;
x = sqrt( max( 0, 1 + m00 - m11 - m22 ) ) / 2.0f;
y = sqrt( max( 0, 1 - m00 + m11 - m22 ) ) / 2.0f;
z = sqrt( max( 0, 1 - m00 - m11 + m22 ) ) / 2.0f;
x = copysign( x, m21 - m12 );
y = copysign( y, m02 - m20 );
z = copysign( z, m10 - m01 );
//m.addFloatArg(x);
//m.addFloatArg(y);
//m.addFloatArg(z);
//m.addFloatArg(w);
sender.sendMessage(m);
}
void draw_stickfigure()
{
XnUInt16 nXRes;
XnUInt16 nYRes;
xn::DepthMetaData dm;
g_DepthGenerator.GetMetaData(dm);
XnPoint3D corner = xnCreatePoint3D(dm.XRes(), dm.YRes(), dm.ZRes());
g_DepthGenerator.ConvertProjectiveToRealWorld(1, &corner, &corner);
nXRes = dm.XRes();
nYRes = dm.YRes();
glDisable(GL_LIGHTING);
XnUserID users[10];
XnUInt16 nUsers = 10;
g_UserGenerator.GetUsers(users, nUsers);
for (int i = 0; i < nUsers; ++i)
{
if (g_UserGenerator.GetSkeletonCap().IsTracking(users[i]))
{
DrawSingleUser(users[i], g_UserGenerator, corner);
}
}
glEnable(GL_LIGHTING);
}
void draw_pointcloud()
{
float fValueH = 0;
float fX = 0;
float fY = 0;
float fU = 0;
float fV = 0;
float fNewColor = 0;
XnUInt16 nXRes;
XnUInt16 nYRes;
XnDepthPixel nMaxDepth;
xn::DepthMetaData dm;
g_DepthGenerator.GetMetaData(dm);
nXRes = dm.XRes();
nYRes = dm.YRes();
nMaxDepth = dm.ZRes();
const XnDepthPixel* pDepth = dm.Data();
memset(g_pDepthHist, 0, MAX_DEPTH*sizeof(float));
int nNumberOfPoints = 0;
XnDepthPixel nValue;
for (XnUInt16 nY=0; nY<nYRes; nY++)
{
for (XnUInt16 nX=0; nX<nXRes; nX++)
{
nValue = *pDepth;
if (nValue != 0)
{
g_pDepthHist[nValue]++;
nNumberOfPoints++;
}
pDepth++;
}
}
XnUInt32 nIndex;
for (nIndex=1; nIndex<MAX_DEPTH; nIndex++)
{
g_pDepthHist[nIndex] += g_pDepthHist[nIndex-1];
}
for (nIndex=1; nIndex<MAX_DEPTH; nIndex++)
{
if (g_pDepthHist[nIndex] != 0)
{
g_pDepthHist[nIndex] = (nNumberOfPoints-g_pDepthHist[nIndex]) / nNumberOfPoints;
}
}
pDepth = dm.Data();
// GL Transform
glPushMatrix();
object.apply_transform();
// Point cloud
float zero[] = {0,0,0,0};
float dim[] = {.2,.2,.2,.2};
glLightfv(GL_LIGHT0, GL_DIFFUSE, dim);
glLightfv(GL_LIGHT0, GL_SPECULAR, zero);
glPolygonOffset(0,-2);
glPushAttrib(GL_ENABLE_BIT);
glEnable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glDisable(GL_COLOR_MATERIAL);
glPointSize (nGLPointSize);
glBegin(GL_POINTS);
XnPoint3D corner = xnCreatePoint3D(dm.XRes(), dm.YRes(), dm.ZRes());
g_DepthGenerator.ConvertProjectiveToRealWorld(1, &corner, &corner);
XnBool bLabelsExists = false;
const XnLabel* pLabels = NULL;
xn::SceneMetaData smd;
if (g_UserGenerator.GetUserPixels(0, smd) == XN_STATUS_OK)
{
bLabelsExists = TRUE;
pLabels = smd.Data();
}
nIndex = 0;
for (XnUInt16 nY = 0; nY < nYRes; nY++)
{
for (XnUInt16 nX = 0; nX < nXRes; nX++, nIndex++, pLabels++)
{
fValueH = pDepth[nIndex];
if (pDepth[nIndex] == 0)
continue;
XnUInt32 nColorID = nColors;
if (bLabelsExists)
{
nColorID = *pLabels % nColors;
if (*pLabels == 0)
{
if (!g_bShowBG)
{
continue;
}
nColorID = nColors;
}
}
else if (!g_bShowBG)
{
continue;
}
glColor3f(
g_pDepthHist[pDepth[nIndex]] * Colors[nColorID][0],
g_pDepthHist[pDepth[nIndex]] * Colors[nColorID][1],
g_pDepthHist[pDepth[nIndex]] * Colors[nColorID][2]);
if (bRealWorld != TRUE)
{
fX = nX;
fY = nY;
fU = fX / fXRes;
fV = fY / fXRes;
}
else
{
XnPoint3D point = xnCreatePoint3D(nX, nY, fValueH);
g_DepthGenerator.ConvertProjectiveToRealWorld(1, &point, &point);
DrawSinglePointRW(point, corner);
}
}
}
glEnd();
// Pointer
if (bShowPointer)
{
glBegin(GL_POINTS);
if (nPointerY < 0)
nPointerY = 0;
if (nPointerY >= nYRes)
nPointerY = nYRes - 1;
if (nPointerX < 0)
nPointerX = 0;
if (nPointerX >= nXRes)
nPointerX = nXRes - 1;
fValueH = pDepth[(nPointerY * nXRes) + nPointerX] - 30;
fU = nPointerX / fXRes;
fV = nPointerY / fXRes;
glColor3f(1,0,0);
glVertex3f(GLSX + (fU*GLUX), GLSY + (fV*GLVY), fValueH/1000);
glEnd();
}
glPopAttrib();
// Undo GL Transform
glPopMatrix();
}
void draw_mesh(float size, int tess)
{
float hsize = size/2;
float delta = size/(tess-1);
glPushMatrix();
glTranslatef(-hsize, -hsize, hsize);
glNormal3f(0,0,-1);
float x = 0;
for(int i=0; i < tess-1; i++)
{
float y = 0;
glBegin(GL_QUAD_STRIP);
for(int j=0; j < tess; j++)
{
glTexCoord2f( x, y);
glVertex2f( x, y);
glTexCoord2f(x+delta, y);
glVertex2f(x+delta, y);
y += delta;
}
glEnd();
x += delta;
}
glPopMatrix();
}
void draw_cube()
{
wall.bind();
wall.enable();
glPushMatrix();
room.apply_transform();
face.call_list();
glRotatef(90, 1, 0, 0);
face.call_list();
glRotatef(90, 1, 0, 0);
face.call_list();
glRotatef(90, 1, 0, 0);
face.call_list();
glRotatef(90, 1, 0, 0);
glRotatef(90, 0, 1, 0);
face.call_list();
glRotatef(180, 0, 1, 0);
face.call_list();
glPopMatrix();
wall.disable();
}
void draw_room(bool do_diffuse)
{
float zero[] = {0,0,0,0};
float a[4];
a[0] = room_ambient;
a[1] = room_ambient;
a[2] = room_ambient;
a[3] = 1;
float d1[] = {.1,.1,.1,.1};
float d2[] = {.7,.7,.7,.7};
float s[] = {.7,.7,.7,.7};
float emission[4];
float ambient[4];
float diffuse[4];
float specular[4];
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, a);
if (g_bRecord)
{
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, vec4f(0.8, 0.0, 0.0, 1).v);
}
else
{
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, vec4f(0.8, 0.8, 0.8, 1).v);
}
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, vec4f(0.4, 0.4, 0.4, 1).v);
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 64.f);
if(! do_diffuse)
{
glGetLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
glLightfv(GL_LIGHT0, GL_DIFFUSE, d1);
glGetLightfv(GL_LIGHT0, GL_SPECULAR, specular);
glLightfv(GL_LIGHT0, GL_SPECULAR, zero);
glStencilFunc(GL_ALWAYS, 128, ~0);
}
else
{
glGetMaterialfv(GL_FRONT, GL_EMISSION, emission);
glMaterialfv(GL_FRONT, GL_EMISSION, zero);
glGetLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
glLightfv(GL_LIGHT0, GL_AMBIENT, zero);
glLightfv(GL_LIGHT0, GL_DIFFUSE, d2);
glLightfv(GL_LIGHT0, GL_SPECULAR, s);
glBlendFunc(GL_ONE, GL_ONE);
glEnable(GL_BLEND);
glStencilFunc(GL_EQUAL, 128, ~0);
glDepthFunc(GL_EQUAL);
}
glPushMatrix();
glTranslatef(0,9,0);
glEnable(GL_LIGHTING);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
glEnable(GL_STENCIL_TEST);
draw_cube();
glStencilFunc(GL_ALWAYS, 128, ~0);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
glDisable(GL_LIGHTING);
glPopMatrix();
if(! do_diffuse)
{
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
glLightfv(GL_LIGHT0, GL_SPECULAR, specular);
}
else
{
glMaterialfv(GL_FRONT, GL_EMISSION, emission);
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
glDisable(GL_BLEND);
glDepthFunc(GL_LESS);
}
}
// The infinite frustum set-up code.
matrix4f infinite_frustum(float left, float right,
float bottom, float top,
float zNear)
{
matrix4f m;
m.make_identity();
m(0,0) = (2*zNear) / (right - left);
m(0,2) = (right + left) / (right - left);
m(1,1) = (2*zNear) / (top - bottom);
m(1,2) = (top + bottom) / (top - bottom);
float nudge = 1.0;
if(b['j']) // nudge infinity in some in case of lsb slop
nudge = 0.999;
m(2,2) = -1 * nudge;
m(2,3) = -2*zNear * nudge;
m(3,2) = -1;
m(3,3) = 0;
return m;
}
inline matrix4f infinite_frustum_inverse(float left, float right,
float bottom, float top,
float zNear)
{
matrix4f m;
m.make_identity();
m(0,0) = (right - left) / (2 * zNear);
m(0,3) = (right + left) / (2 * zNear);
m(1,1) = (top - bottom) / (2 * zNear);
m(1,3) = (top + bottom) / (2 * zNear);
m(2,2) = 0;
m(2,3) = -1;
m(3,2) = -1 / (2 * zNear);
m(3,3) = 1 / (2 * zNear);
return m;
}
matrix4f infinite_perspective(float fovy, float aspect, float zNear)
{
double tangent = tan(to_radians(fovy/2.0));
float y = tangent * zNear;
float x = aspect * y;
return infinite_frustum(-x, x, -y, y, zNear);
}
inline matrix4f infinite_perspective_inverse(float fovy, float aspect, float zNear)
{
double tangent = tan(to_radians(fovy/2.0));
float y = tangent * zNear;
float x = aspect * y;
return infinite_frustum_inverse(-x, x, -y, y, zNear);
}
void apply_infinite_perspective(glut_perspective_reshaper & r)
{
r.aspect = r.aspect_factor * float(r.width)/float(r.height);
if ( r.aspect < 1 )
{
float fovx = r.fovy;
float real_fov = to_degrees(2 * atan(tan(to_radians(fovx/2))/r.aspect));
glMultMatrixf(infinite_perspective(real_fov, r.aspect, r.zNear).m);
}
else
glMultMatrixf(infinite_perspective(r.fovy, r.aspect, r.zNear).m);
}
void display()
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
apply_infinite_perspective(reshaper);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
light.apply_transform();
glLightfv(GL_LIGHT0, GL_POSITION, light_position.v);
glPopMatrix();
glEnable(GL_LIGHT0);
glPushMatrix();
camera.apply_inverse_transform();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glDisable(GL_DEPTH_TEST);
draw_room(false);
if (g_bDrawPointCloud)
{
draw_pointcloud();
}
draw_room(true);
draw_stickfigure();
glPopMatrix();
// Print the Scale + "Laser Pointer"
if (bShowPointer)
{
// Setup the opengl env for fixed location view
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0,WIN_SIZE_X,0,WIN_SIZE_Y,-1.0,1.0);
glDisable(GL_DEPTH_TEST);
// Dark back
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBegin(GL_QUAD_STRIP);
glColor4f(0,0,0,0.85);
glVertex3f(0, 0, 0);
glVertex3f(1050, 0, 0);
glVertex3f(0, 115, 0);
glVertex3f(1050, 115, 0);
glEnd();
glDisable(GL_BLEND);
// Print the scale black background
glPointSize(15);
glColor3f(0, 0, 0);
glBegin(GL_POINTS);
for (int i=0; i<fMaxDepth; i+=1)
{
glVertex3f(1024-(i*2), 23, 1);
glVertex3f(1024-(i*2), 70, 1);
}
glEnd();
const XnDepthPixel* pDepth = g_DepthGenerator.GetDepthMap();
// Print the scale data
glBegin(GL_POINTS);
for (int i=0; i<fMaxDepth; i+=1)
{
float fNewColor = g_pDepthHist[pDepth[i]];
if ((fNewColor > 0.004) && (fNewColor < 0.996))
{
glColor3f(fNewColor, fNewColor, 0);
glVertex3f((i*2), 23, 1);
}
}
glEnd();
// Print the pointer scale data
glBegin(GL_POINTS);
int nPointerValue = pDepth[(nPointerY * (int)fXRes) + nPointerX];
glColor3f(1,0,0);
glVertex3f((nPointerValue*2), 70, 1);
glEnd();
// Print the scale texts
char buf[80];
for (int i=0; i<fMaxDepth; i+=1)
{
if (i % 25 == 0)
{
sprintf(buf, "%d", i);
glRasterPos2i(10+(i*2),40);
glPrintString(GLUT_BITMAP_HELVETICA_18,buf);
}
}
// Print the pointer text
if (nPointerValue != fMaxDepth)
{
sprintf(buf, "Pointer Value: %.1f (X:%d Y:%d) Cutoff: %d-%d", (float)nPointerValue/10, nPointerX, nPointerY, nCutOffMin, nCutOffMax);
}
else
{
sprintf(buf, "Pointer Value: - (X:%d Y:%d)) Cutoff: %d-%d", nPointerX, nPointerY, nCutOffMin, nCutOffMax);
}
glRasterPos2i(10,88);
glPrintString(GLUT_BITMAP_TIMES_ROMAN_24,buf);
// Undo the opengl env settings
glEnable(GL_DEPTH_TEST);
glPopMatrix();
}
if (g_bPrintFrameID)
{
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0,WIN_SIZE_X,0,WIN_SIZE_Y,-1.0,1.0);
glDisable(GL_DEPTH_TEST);
XnChar strLabel[20];
XnUInt32 nFrameID = g_DepthGenerator.GetFrameID();
sprintf(strLabel, "%d", nFrameID);
glColor4f(1,0,0,1);
glRasterPos2i(20, WIN_SIZE_Y-20);
glPrintString(GLUT_BITMAP_HELVETICA_18, strLabel);
// Undo the opengl env settings
glEnable(GL_DEPTH_TEST);
glPopMatrix();
}
glutSwapBuffers();
}
| [
"[email protected]"
] | [
[
[
1,
1432
]
]
] |
e9b01e522551e601956001bf339977400427f560 | 96e96a73920734376fd5c90eb8979509a2da25c0 | /BulletPhysics/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuCollisionShapes.cpp | ce1b6b700b9b93e923ce89c6fdf47590484c2d9e | [] | no_license | lianlab/c3de | 9be416cfbf44f106e2393f60a32c1bcd22aa852d | a2a6625549552806562901a9fdc083c2cacc19de | refs/heads/master | 2020-04-29T18:07:16.973449 | 2009-11-15T10:49:36 | 2009-11-15T10:49:36 | 32,124,547 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 17,886 | cpp | /*
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.
*/
#include "SpuCollisionShapes.h"
///not supported on IBM SDK, until we fix the alignment of btVector3
#if defined (__CELLOS_LV2__) && defined (__SPU__)
#include <spu_intrinsics.h>
static inline vec_float4 vec_dot3( vec_float4 vec0, vec_float4 vec1 )
{
vec_float4 result;
result = spu_mul( vec0, vec1 );
result = spu_madd( spu_rlqwbyte( vec0, 4 ), spu_rlqwbyte( vec1, 4 ), result );
return spu_madd( spu_rlqwbyte( vec0, 8 ), spu_rlqwbyte( vec1, 8 ), result );
}
#endif //__SPU__
btVector3 localGetSupportingVertexWithoutMargin(int shapeType, void* shape, const btVector3& localDir,struct SpuConvexPolyhedronVertexData* convexVertexData)//, int *featureIndex)
{
switch (shapeType)
{
case SPHERE_SHAPE_PROXYTYPE:
{
return btVector3(0,0,0);
}
case BOX_SHAPE_PROXYTYPE:
{
// spu_printf("SPU: getSupport BOX_SHAPE_PROXYTYPE\n");
btConvexInternalShape* convexShape = (btConvexInternalShape*)shape;
const btVector3& halfExtents = convexShape->getImplicitShapeDimensions();
return btVector3(
localDir.getX() < 0.0f ? -halfExtents.x() : halfExtents.x(),
localDir.getY() < 0.0f ? -halfExtents.y() : halfExtents.y(),
localDir.getZ() < 0.0f ? -halfExtents.z() : halfExtents.z());
}
case TRIANGLE_SHAPE_PROXYTYPE:
{
btVector3 dir(localDir.getX(),localDir.getY(),localDir.getZ());
btVector3* vertices = (btVector3*)shape;
btVector3 dots(dir.dot(vertices[0]), dir.dot(vertices[1]), dir.dot(vertices[2]));
btVector3 sup = vertices[dots.maxAxis()];
return btVector3(sup.getX(),sup.getY(),sup.getZ());
break;
}
case CYLINDER_SHAPE_PROXYTYPE:
{
btCylinderShape* cylShape = (btCylinderShape*)shape;
//mapping of halfextents/dimension onto radius/height depends on how cylinder local orientation is (upAxis)
btVector3 halfExtents = cylShape->getImplicitShapeDimensions();
btVector3 v(localDir.getX(),localDir.getY(),localDir.getZ());
int cylinderUpAxis = cylShape->getUpAxis();
int XX(1),YY(0),ZZ(2);
switch (cylinderUpAxis)
{
case 0:
{
XX = 1;
YY = 0;
ZZ = 2;
break;
}
case 1:
{
XX = 0;
YY = 1;
ZZ = 2;
break;
}
case 2:
{
XX = 0;
YY = 2;
ZZ = 1;
break;
}
default:
btAssert(0);
//printf("SPU:localGetSupportingVertexWithoutMargin unknown Cylinder up-axis\n");
};
btScalar radius = halfExtents[XX];
btScalar halfHeight = halfExtents[cylinderUpAxis];
btVector3 tmp;
btScalar d ;
btScalar s = btSqrt(v[XX] * v[XX] + v[ZZ] * v[ZZ]);
if (s != btScalar(0.0))
{
d = radius / s;
tmp[XX] = v[XX] * d;
tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight;
tmp[ZZ] = v[ZZ] * d;
return btVector3(tmp.getX(),tmp.getY(),tmp.getZ());
}
else
{
tmp[XX] = radius;
tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight;
tmp[ZZ] = btScalar(0.0);
return btVector3(tmp.getX(),tmp.getY(),tmp.getZ());
}
}
case CAPSULE_SHAPE_PROXYTYPE:
{
//spu_printf("SPU: todo: getSupport CAPSULE_SHAPE_PROXYTYPE\n");
btVector3 vec0(localDir.getX(),localDir.getY(),localDir.getZ());
btCapsuleShape* capsuleShape = (btCapsuleShape*)shape;
btVector3 halfExtents = capsuleShape->getImplicitShapeDimensions();
btScalar halfHeight = capsuleShape->getHalfHeight();
int capsuleUpAxis = capsuleShape->getUpAxis();
btScalar radius = capsuleShape->getRadius();
btVector3 supVec(0,0,0);
btScalar maxDot(btScalar(-BT_LARGE_FLOAT));
btVector3 vec = vec0;
btScalar lenSqr = vec.length2();
if (lenSqr < btScalar(0.0001))
{
vec.setValue(1,0,0);
} else
{
btScalar rlen = btScalar(1.) / btSqrt(lenSqr );
vec *= rlen;
}
btVector3 vtx;
btScalar newDot;
{
btVector3 pos(0,0,0);
pos[capsuleUpAxis] = halfHeight;
vtx = pos +vec*(radius);
newDot = vec.dot(vtx);
if (newDot > maxDot)
{
maxDot = newDot;
supVec = vtx;
}
}
{
btVector3 pos(0,0,0);
pos[capsuleUpAxis] = -halfHeight;
vtx = pos +vec*(radius);
newDot = vec.dot(vtx);
if (newDot > maxDot)
{
maxDot = newDot;
supVec = vtx;
}
}
return btVector3(supVec.getX(),supVec.getY(),supVec.getZ());
break;
};
case CONVEX_HULL_SHAPE_PROXYTYPE:
{
//spu_printf("SPU: todo: getSupport CONVEX_HULL_SHAPE_PROXYTYPE\n");
#if defined (__CELLOS_LV2__) && defined (__SPU__)
vec_float4 v_distMax = {-FLT_MAX,0,0,0};
vec_int4 v_idxMax = {-999,0,0,0};
int v=0;
int numverts = convexVertexData->gNumConvexPoints;
btVector3* points = convexVertexData->gConvexPoints;
for(;v<(int)numverts-4;v+=4) {
vec_float4 p0 = vec_dot3(points[v ].get128(),localDir.get128());
vec_float4 p1 = vec_dot3(points[v+1].get128(),localDir.get128());
vec_float4 p2 = vec_dot3(points[v+2].get128(),localDir.get128());
vec_float4 p3 = vec_dot3(points[v+3].get128(),localDir.get128());
const vec_int4 i0 = {v ,0,0,0};
const vec_int4 i1 = {v+1,0,0,0};
const vec_int4 i2 = {v+2,0,0,0};
const vec_int4 i3 = {v+3,0,0,0};
vec_uint4 retGt01 = spu_cmpgt(p0,p1);
vec_float4 pmax01 = spu_sel(p1,p0,retGt01);
vec_int4 imax01 = spu_sel(i1,i0,retGt01);
vec_uint4 retGt23 = spu_cmpgt(p2,p3);
vec_float4 pmax23 = spu_sel(p3,p2,retGt23);
vec_int4 imax23 = spu_sel(i3,i2,retGt23);
vec_uint4 retGt0123 = spu_cmpgt(pmax01,pmax23);
vec_float4 pmax0123 = spu_sel(pmax23,pmax01,retGt0123);
vec_int4 imax0123 = spu_sel(imax23,imax01,retGt0123);
vec_uint4 retGtMax = spu_cmpgt(v_distMax,pmax0123);
v_distMax = spu_sel(pmax0123,v_distMax,retGtMax);
v_idxMax = spu_sel(imax0123,v_idxMax,retGtMax);
}
for(;v<(int)numverts;v++) {
vec_float4 p = vec_dot3(points[v].get128(),localDir.get128());
const vec_int4 i = {v,0,0,0};
vec_uint4 retGtMax = spu_cmpgt(v_distMax,p);
v_distMax = spu_sel(p,v_distMax,retGtMax);
v_idxMax = spu_sel(i,v_idxMax,retGtMax);
}
int ptIndex = spu_extract(v_idxMax,0);
const btVector3& supVec= points[ptIndex];
#else
btVector3* points = 0;
int numPoints = 0;
points = convexVertexData->gConvexPoints;
numPoints = convexVertexData->gNumConvexPoints;
// spu_printf("numPoints = %d\n",numPoints);
int ptIndex = 0;
btScalar newDot,maxDot = btScalar(-BT_LARGE_FLOAT);
btVector3 vec0(localDir.getX(),localDir.getY(),localDir.getZ());
btVector3 vec = vec0;
btScalar lenSqr = vec.length2();
if (lenSqr < btScalar(0.0001))
{
vec.setValue(1,0,0);
} else
{
btScalar rlen = btScalar(1.) / btSqrt(lenSqr );
vec *= rlen;
}
for (int i=0;i<numPoints;i++)
{
const btVector3& vtx = points[i];// * m_localScaling;
newDot = vec.dot(vtx);
if (newDot > maxDot)
{
maxDot = newDot;
ptIndex = i;
}
}
const btVector3& supVec= points[ptIndex];
#endif
return btVector3(supVec.getX(),supVec.getY(),supVec.getZ());
break;
};
default:
//spu_printf("SPU:(type %i) missing support function\n",shapeType);
#if __ASSERT
// spu_printf("localGetSupportingVertexWithoutMargin() - Unsupported bound type: %d.\n", shapeType);
#endif // __ASSERT
return btVector3(0.f, 0.f, 0.f);
}
}
void computeAabb (btVector3& aabbMin, btVector3& aabbMax, btConvexInternalShape* convexShape, ppu_address_t convexShapePtr, int shapeType, const btTransform& xform)
{
//calculate the aabb, given the types...
switch (shapeType)
{
case CYLINDER_SHAPE_PROXYTYPE:
/* fall through */
case BOX_SHAPE_PROXYTYPE:
{
btScalar margin=convexShape->getMarginNV();
btVector3 halfExtents = convexShape->getImplicitShapeDimensions();
halfExtents += btVector3(margin,margin,margin);
const btTransform& t = xform;
btMatrix3x3 abs_b = t.getBasis().absolute();
btVector3 center = t.getOrigin();
btVector3 extent = btVector3(abs_b[0].dot(halfExtents),abs_b[1].dot(halfExtents),abs_b[2].dot(halfExtents));
aabbMin = center - extent;
aabbMax = center + extent;
break;
}
case CAPSULE_SHAPE_PROXYTYPE:
{
btScalar margin=convexShape->getMarginNV();
btVector3 halfExtents = convexShape->getImplicitShapeDimensions();
//add the radius to y-axis to get full height
btScalar radius = halfExtents[0];
halfExtents[1] += radius;
halfExtents += btVector3(margin,margin,margin);
#if 0
int capsuleUpAxis = convexShape->getUpAxis();
btScalar halfHeight = convexShape->getHalfHeight();
btScalar radius = convexShape->getRadius();
halfExtents[capsuleUpAxis] = radius + halfHeight;
#endif
const btTransform& t = xform;
btMatrix3x3 abs_b = t.getBasis().absolute();
btVector3 center = t.getOrigin();
btVector3 extent = btVector3(abs_b[0].dot(halfExtents),abs_b[1].dot(halfExtents),abs_b[2].dot(halfExtents));
aabbMin = center - extent;
aabbMax = center + extent;
break;
}
case SPHERE_SHAPE_PROXYTYPE:
{
btScalar radius = convexShape->getImplicitShapeDimensions().getX();// * convexShape->getLocalScaling().getX();
btScalar margin = radius + convexShape->getMarginNV();
const btTransform& t = xform;
const btVector3& center = t.getOrigin();
btVector3 extent(margin,margin,margin);
aabbMin = center - extent;
aabbMax = center + extent;
break;
}
case CONVEX_HULL_SHAPE_PROXYTYPE:
{
ATTRIBUTE_ALIGNED16(char convexHullShape0[sizeof(btConvexHullShape)]);
cellDmaGet(&convexHullShape0, convexShapePtr , sizeof(btConvexHullShape), DMA_TAG(1), 0, 0);
cellDmaWaitTagStatusAll(DMA_MASK(1));
btConvexHullShape* localPtr = (btConvexHullShape*)&convexHullShape0;
const btTransform& t = xform;
btScalar margin = convexShape->getMarginNV();
localPtr->getNonvirtualAabb(t,aabbMin,aabbMax,margin);
//spu_printf("SPU convex aabbMin=%f,%f,%f=\n",aabbMin.getX(),aabbMin.getY(),aabbMin.getZ());
//spu_printf("SPU convex aabbMax=%f,%f,%f=\n",aabbMax.getX(),aabbMax.getY(),aabbMax.getZ());
break;
}
default:
{
// spu_printf("SPU: unsupported shapetype %d in AABB calculation\n");
}
};
}
void dmaBvhShapeData (bvhMeshShape_LocalStoreMemory* bvhMeshShape, btBvhTriangleMeshShape* triMeshShape)
{
register int dmaSize;
register ppu_address_t dmaPpuAddress2;
dmaSize = sizeof(btTriangleIndexVertexArray);
dmaPpuAddress2 = reinterpret_cast<ppu_address_t>(triMeshShape->getMeshInterface());
// spu_printf("trimeshShape->getMeshInterface() == %llx\n",dmaPpuAddress2);
#ifdef __SPU__
cellDmaGet(&bvhMeshShape->gTriangleMeshInterfaceStorage, dmaPpuAddress2 , dmaSize, DMA_TAG(1), 0, 0);
bvhMeshShape->gTriangleMeshInterfacePtr = &bvhMeshShape->gTriangleMeshInterfaceStorage;
#else
bvhMeshShape->gTriangleMeshInterfacePtr = (btTriangleIndexVertexArray*)cellDmaGetReadOnly(&bvhMeshShape->gTriangleMeshInterfaceStorage, dmaPpuAddress2 , dmaSize, DMA_TAG(1), 0, 0);
#endif
//cellDmaWaitTagStatusAll(DMA_MASK(1));
///now DMA over the BVH
dmaSize = sizeof(btOptimizedBvh);
dmaPpuAddress2 = reinterpret_cast<ppu_address_t>(triMeshShape->getOptimizedBvh());
//spu_printf("trimeshShape->getOptimizedBvh() == %llx\n",dmaPpuAddress2);
cellDmaGet(&bvhMeshShape->gOptimizedBvh, dmaPpuAddress2 , dmaSize, DMA_TAG(2), 0, 0);
//cellDmaWaitTagStatusAll(DMA_MASK(2));
cellDmaWaitTagStatusAll(DMA_MASK(1) | DMA_MASK(2));
}
void dmaBvhIndexedMesh (btIndexedMesh* IndexMesh, IndexedMeshArray& indexArray, int index, uint32_t dmaTag)
{
cellDmaGet(IndexMesh, (ppu_address_t)&indexArray[index] , sizeof(btIndexedMesh), DMA_TAG(dmaTag), 0, 0);
}
void dmaBvhSubTreeHeaders (btBvhSubtreeInfo* subTreeHeaders, ppu_address_t subTreePtr, int batchSize, uint32_t dmaTag)
{
cellDmaGet(subTreeHeaders, subTreePtr, batchSize * sizeof(btBvhSubtreeInfo), DMA_TAG(dmaTag), 0, 0);
}
void dmaBvhSubTreeNodes (btQuantizedBvhNode* nodes, const btBvhSubtreeInfo& subtree, QuantizedNodeArray& nodeArray, int dmaTag)
{
cellDmaGet(nodes, reinterpret_cast<ppu_address_t>(&nodeArray[subtree.m_rootNodeIndex]) , subtree.m_subtreeSize* sizeof(btQuantizedBvhNode), DMA_TAG(2), 0, 0);
}
///getShapeTypeSize could easily be optimized, but it is not likely a bottleneck
int getShapeTypeSize(int shapeType)
{
switch (shapeType)
{
case CYLINDER_SHAPE_PROXYTYPE:
{
int shapeSize = sizeof(btCylinderShape);
btAssert(shapeSize < MAX_SHAPE_SIZE);
return shapeSize;
}
case BOX_SHAPE_PROXYTYPE:
{
int shapeSize = sizeof(btBoxShape);
btAssert(shapeSize < MAX_SHAPE_SIZE);
return shapeSize;
}
case SPHERE_SHAPE_PROXYTYPE:
{
int shapeSize = sizeof(btSphereShape);
btAssert(shapeSize < MAX_SHAPE_SIZE);
return shapeSize;
}
case TRIANGLE_MESH_SHAPE_PROXYTYPE:
{
int shapeSize = sizeof(btBvhTriangleMeshShape);
btAssert(shapeSize < MAX_SHAPE_SIZE);
return shapeSize;
}
case CAPSULE_SHAPE_PROXYTYPE:
{
int shapeSize = sizeof(btCapsuleShape);
btAssert(shapeSize < MAX_SHAPE_SIZE);
return shapeSize;
}
case CONVEX_HULL_SHAPE_PROXYTYPE:
{
int shapeSize = sizeof(btConvexHullShape);
btAssert(shapeSize < MAX_SHAPE_SIZE);
return shapeSize;
}
case COMPOUND_SHAPE_PROXYTYPE:
{
int shapeSize = sizeof(btCompoundShape);
btAssert(shapeSize < MAX_SHAPE_SIZE);
return shapeSize;
}
default:
btAssert(0);
//unsupported shapetype, please add here
return 0;
}
}
void dmaConvexVertexData (SpuConvexPolyhedronVertexData* convexVertexData, btConvexHullShape* convexShapeSPU)
{
convexVertexData->gNumConvexPoints = convexShapeSPU->getNumPoints();
if (convexVertexData->gNumConvexPoints>MAX_NUM_SPU_CONVEX_POINTS)
{
btAssert(0);
// spu_printf("SPU: Error: MAX_NUM_SPU_CONVEX_POINTS(%d) exceeded: %d\n",MAX_NUM_SPU_CONVEX_POINTS,convexVertexData->gNumConvexPoints);
return;
}
register int dmaSize = convexVertexData->gNumConvexPoints*sizeof(btVector3);
ppu_address_t pointsPPU = (ppu_address_t) convexShapeSPU->getUnscaledPoints();
cellDmaGet(&convexVertexData->g_convexPointBuffer[0], pointsPPU , dmaSize, DMA_TAG(2), 0, 0);
}
void dmaCollisionShape (void* collisionShapeLocation, ppu_address_t collisionShapePtr, uint32_t dmaTag, int shapeType)
{
register int dmaSize = getShapeTypeSize(shapeType);
cellDmaGet(collisionShapeLocation, collisionShapePtr , dmaSize, DMA_TAG(dmaTag), 0, 0);
//cellDmaWaitTagStatusAll(DMA_MASK(dmaTag));
}
void dmaCompoundShapeInfo (CompoundShape_LocalStoreMemory* compoundShapeLocation, btCompoundShape* spuCompoundShape, uint32_t dmaTag)
{
register int dmaSize;
register ppu_address_t dmaPpuAddress2;
int childShapeCount = spuCompoundShape->getNumChildShapes();
dmaSize = childShapeCount * sizeof(btCompoundShapeChild);
dmaPpuAddress2 = (ppu_address_t)spuCompoundShape->getChildList();
cellDmaGet(&compoundShapeLocation->gSubshapes[0], dmaPpuAddress2, dmaSize, DMA_TAG(dmaTag), 0, 0);
}
void dmaCompoundSubShapes (CompoundShape_LocalStoreMemory* compoundShapeLocation, btCompoundShape* spuCompoundShape, uint32_t dmaTag)
{
int childShapeCount = spuCompoundShape->getNumChildShapes();
int i;
// DMA all the subshapes
for ( i = 0; i < childShapeCount; ++i)
{
btCompoundShapeChild& childShape = compoundShapeLocation->gSubshapes[i];
dmaCollisionShape (&compoundShapeLocation->gSubshapeShape[i],(ppu_address_t)childShape.m_childShape, dmaTag, childShape.m_childShapeType);
}
}
void spuWalkStacklessQuantizedTree(btNodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax,const btQuantizedBvhNode* rootNode,int startNodeIndex,int endNodeIndex)
{
int curIndex = startNodeIndex;
int walkIterations = 0;
#ifdef BT_DEBUG
int subTreeSize = endNodeIndex - startNodeIndex;
#endif
int escapeIndex;
unsigned int aabbOverlap, isLeafNode;
while (curIndex < endNodeIndex)
{
//catch bugs in tree data
btAssert (walkIterations < subTreeSize);
walkIterations++;
aabbOverlap = spuTestQuantizedAabbAgainstQuantizedAabb(quantizedQueryAabbMin,quantizedQueryAabbMax,rootNode->m_quantizedAabbMin,rootNode->m_quantizedAabbMax);
isLeafNode = rootNode->isLeafNode();
if (isLeafNode && aabbOverlap)
{
//printf("overlap with node %d\n",rootNode->getTriangleIndex());
nodeCallback->processNode(0,rootNode->getTriangleIndex());
// spu_printf("SPU: overlap detected with triangleIndex:%d\n",rootNode->getTriangleIndex());
}
if (aabbOverlap || isLeafNode)
{
rootNode++;
curIndex++;
} else
{
escapeIndex = rootNode->getEscapeIndex();
rootNode += escapeIndex;
curIndex += escapeIndex;
}
}
}
| [
"caiocsabino@7e2be596-0d54-0410-9f9d-cf4183935158"
] | [
[
[
1,
542
]
]
] |
f1cecfd57d0352a3ae9f6a5f494ed2c1881e8cc4 | 7b4c786d4258ce4421b1e7bcca9011d4eeb50083 | /C++Primer中文版(第4版)/第一次-代码集合-20090414/第九章 顺序容器/20090209_习题9.12_在vector对象中寻找给定的int型数值.cpp | cb876d44d7f04c448fd06263aa5ea1b3945ac147 | [] | 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 | 213 | cpp | bool findInt (vector<int>::iterator beg, vector<int>::iterator end, int ival)
{
while (beg != end)
if (*beg == ival)
break;
else
++beg;
if (beg != end)
return true;
else
return false;
} | [
"baicaibang@70501136-4834-11de-8855-c187e5f49513"
] | [
[
[
1,
12
]
]
] |
3a1dcba19037c45c79fa6ef91729df1240a3bec7 | 4aadb120c23f44519fbd5254e56fc91c0eb3772c | /Source/mgf/applications/prototypes/console/main.cpp | e0efe168741a3c51f9cfb16b56298d10d531250c | [] | no_license | janfietz/edunetgames | d06cfb021d8f24cdcf3848a59cab694fbfd9c0ba | 04d787b0afca7c99b0f4c0692002b4abb8eea410 | refs/heads/master | 2016-09-10T19:24:04.051842 | 2011-04-17T11:00:09 | 2011-04-17T11:00:09 | 33,568,741 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 567 | cpp | // testConsole.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
#include <mgf/core/Object.h>
#include <mgf/memory/MemoryTracker.h>
// install debug memory tracking facility
mgf::MemoryDebug memoryDebug;
#define MGF_TEST_LEAK 1
//-----------------------------------------------------------------------------
int _tmain(int argc, _TCHAR* argv[])
{
mgf::Object* o = MGF_NEW mgf::Object;
#if MGF_TEST_LEAK
#else
MGF_DELETE o;
#endif
return 0;
}
| [
"janfietz@localhost"
] | [
[
[
1,
27
]
]
] |
5271d8bd5d683d212694f5251d4d56db59ea0485 | 91b964984762870246a2a71cb32187eb9e85d74e | /SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/boost/xpressive/detail/dynamic/matchable.hpp | 198bcaa7e492f2c99da6cc548504cbb732aceb1b | [
"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 | UTF-8 | C++ | false | false | 4,740 | hpp | ///////////////////////////////////////////////////////////////////////////////
// matchable.hpp
//
// Copyright 2004 Eric Niebler. 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)
#ifndef BOOST_XPRESSIVE_DETAIL_DYNAMIC_MATCHABLE_HPP_EAN_10_04_2005
#define BOOST_XPRESSIVE_DETAIL_DYNAMIC_MATCHABLE_HPP_EAN_10_04_2005
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
#include <utility>
#include <boost/assert.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/xpressive/detail/core/state.hpp>
#include <boost/xpressive/detail/core/quant_style.hpp>
#include <boost/xpressive/regex_error.hpp>
namespace boost { namespace xpressive { namespace detail
{
template<typename BidiIter>
struct matchable;
///////////////////////////////////////////////////////////////////////////////
// sequence
//
template<typename BidiIter>
struct sequence
: std::pair
<
shared_ptr<matchable<BidiIter> const>
, shared_ptr<matchable<BidiIter> const> *
>
{
typedef shared_ptr<matchable<BidiIter> const> matchable_ptr_t;
typedef std::pair<matchable_ptr_t, matchable_ptr_t *> base_t;
explicit sequence(matchable_ptr_t head = matchable_ptr_t(), matchable_ptr_t *tail_ptr = 0)
: base_t(head, tail_ptr)
{
}
bool is_empty() const
{
return !this->first;
}
sequence &operator +=(sequence that)
{
if(is_empty())
{
*this = that;
}
else if(!that.is_empty())
{
*this->second = that.first;
this->second = that.second;
}
return *this;
}
};
//////////////////////////////////////////////////////////////////////////
// quant_spec
//
struct quant_spec
{
unsigned int min_;
unsigned int max_;
bool greedy_;
};
///////////////////////////////////////////////////////////////////////////////
// matchable
//
template<typename BidiIter>
struct matchable
: xpression_base
{
typedef typename iterator_value<BidiIter>::type char_type;
virtual ~matchable() {}
virtual bool match(state_type<BidiIter> &state) const = 0;
virtual std::size_t get_width(state_type<BidiIter> *state) const = 0;
virtual void link(xpression_linker<char_type> &) const {}
virtual void peek(xpression_peeker<char_type> &peeker) const
{
peeker.fail();
}
virtual sequence<BidiIter> quantify
(
quant_spec const & //spec
, std::size_t & //hidden_mark_count
, sequence<BidiIter> //seq
, alternates_factory<BidiIter> const &//factory
) const
{
throw regex_error(regex_constants::error_badrepeat, "expression cannot be quantified");
}
virtual bool is_quantifiable() const
{
BOOST_ASSERT(false);
throw regex_error(regex_constants::error_internal, "internal error, sorry!");
}
///////////////////////////////////////////////////////////////////////////////////////////////
// The following 4 functions (push_match, top_match, pop_match and skip_match) are
// used to implement looping and branching across the matchers. Call push_match to record
// a position. Then, another matcher further down the xpression chain has the
// option to call either top_match, pop_match or skip_match. top_match and pop_match will
// jump back to the place recorded by push_match, whereas skip_match will skip the jump and
// pass execution down the xpression chain. top_match will leave the xpression on top of the
// stack, whereas pop_match will remove it. Each function comes in 2 flavors: one for
// statically bound xpressions and one for dynamically bound xpressions.
//
template<typename Top>
bool push_match(state_type<BidiIter> &state) const
{
BOOST_MPL_ASSERT((is_same<Top, matchable<BidiIter> >));
return this->match(state);
}
static bool top_match(state_type<BidiIter> &state, xpression_base const *top)
{
return static_cast<matchable<BidiIter> const *>(top)->match(state);
}
static bool pop_match(state_type<BidiIter> &state, xpression_base const *top)
{
return static_cast<matchable<BidiIter> const *>(top)->match(state);
}
bool skip_match(state_type<BidiIter> &state) const
{
return this->match(state);
}
};
}}} // namespace boost::xpressive::detail
#endif
| [
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
] | [
[
[
1,
155
]
]
] |
2a4c1edb38cdbb80383fed155449959e41daca70 | 868fa61394c4baf898c2304bdf0d73b3e2e87b45 | /USACO/ride/C++/ride.cpp | e7188feb106d79fd203b381c4d49aeeb36313ab8 | [] | no_license | running770/justincode | 5a0f05666c4ba59358bba78d12ab02b37460ac17 | 164c8eb800cb207f00d21485f69761847e4c34fe | refs/heads/master | 2020-04-06T04:32:39.505721 | 2010-03-05T10:59:32 | 2010-03-05T10:59:32 | 34,300,795 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,051 | cpp | /*
ID: running1
PROG: ride
LANG: C++
*/
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
#define CHAR_VAL(ACHAR) (ACHAR - 'A' + 1)
int
main(int argc, char **argv)
{
ofstream fout ("ride.out");
ifstream fin ("ride.in");
string cometName, groupName;
char *p;
int cometVal, groupVal;
while (fin >> cometName >> groupName)
{
cometVal = 1;
groupVal = 1;
//cout << "comet name:" << cometName << endl;
//cout << "group name:" << groupName << endl;
for (p = &cometName[0]; *p; p++)
{
// cout << "char:" << *p << "val:" << CHAR_VAL(*p) << endl;
cometVal *= CHAR_VAL(*p);
// cout << "comet value:" << cometVal << endl;
}
for (p = &groupName[0]; *p; p++)
{
// cout << "char:" << *p << "val:" << CHAR_VAL(*p) << endl;
groupVal *= CHAR_VAL(*p);
// cout << "group value:" << groupVal << endl;
}
if (cometVal%47 == groupVal%47)
fout << "GO" << endl;
else
fout << "STAY" << endl;
}
fout.close();
fin.close();
return 0;
}
| [
"running770@23fc9e22-fa95-11dd-a7be-4b3ef3b0700c"
] | [
[
[
1,
49
]
]
] |
cc743033cd8a6edcf03b54cd75cae39ff5a44f90 | 105cc69f4207a288be06fd7af7633787c3f3efb5 | /HovercraftUniverse/CoreEngine/BasicEntityEvent.cpp | e6bb3a2505af0921861881ccc7d02126986626e5 | [] | no_license | allenjacksonmaxplayio/uhasseltaacgua | 330a6f2751e1d6675d1cf484ea2db0a923c9cdd0 | ad54e9aa3ad841b8fc30682bd281c790a997478d | refs/heads/master | 2020-12-24T21:21:28.075897 | 2010-06-09T18:05:23 | 2010-06-09T18:05:23 | 56,725,792 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,067 | cpp | #include "BasicEntityEvent.h"
#include <OgreLogManager.h>
namespace HovUni {
BasicEntityEvent::BasicEntityEvent(bool forward, bool backward, bool left, bool right, bool reset) :
ControllerEvent(BasicEntity), mForward(forward), mBackward(backward), mLeft(left), mRight(right), mReset(reset) {
}
BasicEntityEvent::BasicEntityEvent() : ControllerEvent(BasicEntity), mForward(false), mBackward(false), mLeft(false), mRight(false), mReset(false) {
}
BasicEntityEvent::~BasicEntityEvent() {
}
bool BasicEntityEvent::operator==(const BasicEntityEvent& event) {
if ((mForward == event.mForward) &&
(mBackward == event.mBackward) &&
(mLeft == event.mLeft) &&
(mRight == event.mRight)&&
(mReset == event.mReset)) {
return true;
} else {
return false;
}
}
bool BasicEntityEvent::moveForward() const {
return mForward;
}
bool BasicEntityEvent::moveBackward() const {
return mBackward;
}
bool BasicEntityEvent::moveLeft() const {
return mLeft;
}
bool BasicEntityEvent::moveRight() const {
return mRight;
}
bool BasicEntityEvent::reset() const {
return mReset;
}
void BasicEntityEvent::clear() {
mForward = false;
mBackward = false;
mLeft = false;
mReset = false;
mRight = false;
}
void BasicEntityEvent::write(ZCom_BitStream* stream) const {
// Write information for controller event
ControllerEvent::write(stream);
// Write own information
stream->addBool(mForward);
stream->addBool(mBackward);
stream->addBool(mLeft);
stream->addBool(mRight);
stream->addBool(mReset);
}
void BasicEntityEvent::read(ZCom_BitStream* stream) {
// Read information for controller event
ControllerEvent::read(stream);
// Read own information
mForward = stream->getBool();
mBackward = stream->getBool();
mLeft = stream->getBool();
mRight = stream->getBool();
mReset = stream->getBool();
}
BasicEntityEvent* BasicEntityEvent::parse(ZCom_BitStream* stream) {
BasicEntityEvent* e = new BasicEntityEvent();
e->deserialize(stream);
return e;
}
}
| [
"berghmans.olivier@2d55a33c-0a8f-11df-aac0-2d4c26e34a4c",
"pintens.pieterjan@2d55a33c-0a8f-11df-aac0-2d4c26e34a4c",
"tobias.vanbladel@2d55a33c-0a8f-11df-aac0-2d4c26e34a4c"
] | [
[
[
1,
5
],
[
8,
10
],
[
12,
22
],
[
25,
46
],
[
59,
67
],
[
69,
79
],
[
81,
89
]
],
[
[
6,
7
],
[
11,
11
],
[
23,
24
],
[
47,
50
],
[
55,
55
],
[
68,
68
],
[
80,
80
]
],
[
[
51,
54
],
[
56,
58
]
]
] |
bc5c6ab9f5df1693776e1e25a106439f28c69d18 | e6e9b356ad29b66f736e7b20fd41f59d6538dba3 | /win32/contextMenu/cpp/IContextMenu_JNI.cpp | 8d7654f98fcb00df09c658446ede180ee0e62bb8 | [] | no_license | rbywater/idea-trinkets | 7a64aa7cf730806b211abf893e39934c2fb96d64 | bb3b6d5b55a7d0bf5a99603a24d402b308b6b202 | refs/heads/master | 2021-01-01T17:36:46.798804 | 2011-11-27T21:48:09 | 2011-11-27T21:48:09 | 33,279,639 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 290 | cpp | // IContextMenu_JNI.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
| [
"aefimov.box@1a844c48-401d-0410-96c1-69ea7aaf0d43"
] | [
[
[
1,
13
]
]
] |
4c72954856e4a3e531b6ad4290802a7373a2897b | be61812d21a5dbe59e92f5eadd605d48bb9e5c86 | /examples/map.cc | 1371aabce71dfa000ccb9afdb36c456f0c42f3a8 | [
"MIT"
] | permissive | google-code-export/libfov | 71b7ccfa7c8b2f58163d8b8da66ba2037ed7df32 | dd7e8649b35a1edf5af389ef9e5091312571185b | refs/heads/master | 2020-11-26T17:06:58.373556 | 2009-09-20T00:09:15 | 2009-09-20T00:09:15 | 32,134,758 | 0 | 2 | null | null | null | null | ISO-8859-1 | C++ | false | false | 2,533 | cc | /*
* RECURSIVE SHADOWCASTING
*
* map.cpp part of rscfovdemo
*
* implementation of simple map
*
* Author: Björn Bergström
* e-mail: [email protected]
*
* 2002-01-25: Greg McIntyre - stdlib.h included for rand()
*
*/
#include "map.h"
#include <cstdlib>
MAP::MAP(unsigned seed)
{
srand(seed);
// fill the map with blocking cells and set all cells to not seen
for(int x=0; x<MAPWIDTH; x++)
{
for(int y=0; y<MAPHEIGHT; y++)
{
this->cells[x][y].tile='.';
this->cells[x][y].seen=false;
}
}
// generate a game of life like cave
for(int fill=0; fill<(MAPWIDTH*MAPHEIGHT*0.55); fill++)
{
this->cells[(int)(((float)rand()/RAND_MAX) * MAPWIDTH)][(int)(((float)rand()/RAND_MAX) * MAPHEIGHT)].tile='#';
}
int count=0;
for(int apply=0; apply<1; apply++)
{
for(int x=0; x<MAPWIDTH; x++)
{
for(int y=0; y<MAPHEIGHT; y++)
{
count=0;
if(this->blockLOS(x-1,y-1)) count++; // NW
if(this->blockLOS(x,y-1)) count++; // N
if(this->blockLOS(x+1,y-1)) count++; // NE
if(this->blockLOS(x+1,y)) count++; // E
if(this->blockLOS(x+1,y+1)) count++; // SE
if(this->blockLOS(x,y+1)) count++; // S
if(this->blockLOS(x-1,y+1)) count++; // SW
if(this->blockLOS(x-1,y)) count++; // W
// a wall is removed if there are less than four adjacent walls
if(this->blockLOS(x,y))
{
if(count<4) this->cells[x][y].tile='.';
}
// a wall is created if there more than four adjacent walls
else
{
if(count>4) this->cells[x][y].tile='#';
}
}
}
}
for(int y=0; y<20; y++)
this->cells[y][20].tile='#';
}
bool MAP::onMap(unsigned int x, unsigned int y)
{
return (x<MAPWIDTH && y<MAPHEIGHT);
}
bool MAP::blockLOS(unsigned int x, unsigned int y)
{
if(!onMap(x,y)) return true;
return (this->cells[x][y].tile == '#');
}
void MAP::setSeen(unsigned int x, unsigned int y)
{
if(!onMap(x,y)) return;
this->cells[x][y].seen=true;
this->cells[x][y].remembered=true;
}
void MAP::display(void)
{
for(int x=0; x<MAPWIDTH; x++)
{
for(int y=0; y<MAPHEIGHT; y++)
{
if (this->cells[x][y].seen)
display_put_char(this->cells[x][y].tile, x, y, 0xFF, 0xFF, 0xFF);
else if (this->cells[x][y].remembered)
display_put_char(this->cells[x][y].tile, x, y, 0xFF/3, 0xFF/3, 0xFF/3);
//else
//display_put_char(this->cells[x][y].tile, x, y, 0xFF/4, 0xFF/4, 0xFF/4);
this->cells[x][y].seen=false;
}
}
}
| [
"blue.puyo@ed8892e6-304f-0410-a18f-fd75bd1fb240"
] | [
[
[
1,
108
]
]
] |
062b4823460923d347adf35d656a49cb646a1eb1 | b9c9a4c5e7952e080a53c81a0781180a9bf80257 | /src/document/Chat.h | ab993073791d97b01c0b2f3b2370960428b99515 | [] | no_license | kaelspencer/confero | 296aa9cd87c0254a662be136a571ffb9675d9fe9 | a41c71fe082017c316bc2f79e00c2b9e3a8ef7eb | refs/heads/master | 2021-01-19T17:47:44.444616 | 2011-06-12T00:25:25 | 2011-06-12T00:25:25 | 1,777,702 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 862 | h | #ifndef CHAT_H
#define CHAT_H
#include <QtGui/QTabWidget>
#include <QtGui/QTextEdit>
#include <QtGui/QLineEdit>
#include <Qsci/qsciscintilla.h>
#include "Edit.h"
#include "../net/ConferoNet.h"
extern const int SC_MOD_INSERTTEXT;
class Chat : public QObject
{
Q_OBJECT
private:
QTabWidget * m_tabWidget;
QWidget * m_tab;
QTextEdit * m_display;
QLineEdit * m_enter;
//this is used as the host
QString m_remoteName;
ConferoNet * m_cnet;
bool m_visible;
Chat();
Chat(const Chat & rhs);
Chat & operator=(const Chat & rhs);
void SendEdit(const QString & text);
private slots:
void returnPressed();
public:
Chat(QTabWidget * tabWidget, const QString & remoteName, ConferoNet * cnet);
void AddChat(Edit * ed);
void Show();
void Hide();
};
#endif
| [
"kael@euler"
] | [
[
[
1,
43
]
]
] |
11a356241e8134e580800e058df6016eeec153dc | b2155efef00dbb04ae7a23e749955f5ec47afb5a | /demo/demo_cartoon/CartoonApp.h | b7cb22335355a37532b9355ac2bd5552366ff7bd | [] | no_license | zjhlogo/originengine | 00c0bd3c38a634b4c96394e3f8eece86f2fe8351 | a35a83ed3f49f6aeeab5c3651ce12b5c5a43058f | refs/heads/master | 2021-01-20T13:48:48.015940 | 2011-04-21T04:10:54 | 2011-04-21T04:10:54 | 32,371,356 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 636 | h | /*!
* \file CartoonApp.h
* \date 11-2-2010 22:02:10
*
*
* \author zjhlogo ([email protected])
*/
#ifndef __CARTOONAPP_H__
#define __CARTOONAPP_H__
#include "../common/BaseApp.h"
#include <OECore/IOEModel.h>
#include <libOEMsg/OEMsgShaderParam.h>
class CCartoonApp : public CBaseApp
{
public:
CCartoonApp();
virtual ~CCartoonApp();
virtual bool UserDataInit();
virtual void UserDataTerm();
virtual void Update(float fDetailTime);
private:
void Init();
void Destroy();
bool OnSetupShaderParam(COEMsgShaderParam& msg);
private:
IOEModel* m_pModel;
};
#endif // __CARTOONAPP_H__
| [
"zjhlogo@fdcc8808-487c-11de-a4f5-9d9bc3506571"
] | [
[
[
1,
36
]
]
] |
9b0b6f5aea2871a82678b3df4a31d31c02cef61c | 1a5b43c98479a5c44c6da4b01fa35af95c6d7bcd | /CFGGen/UniqueObjectIdMgr.h | 09e37b44bd001e04ddb7f883ce969b51d110a38c | [] | no_license | eknowledger/mcfromc | 827641a5f670d18ee2a7e1d8d76b783d37d33004 | 41b6ba1065b27a8468d3b70c3698cbcef0dc698b | refs/heads/master | 2016-09-05T12:11:29.137266 | 2010-08-08T05:11:43 | 2010-08-08T05:11:43 | 34,752,799 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 941 | h | #pragma once
//////////////////////////////////////////////////////////////////////////
/// A a factory for unique numeric IDs given to Flow Points,
/// MC's and Undefined Values.
//////////////////////////////////////////////////////////////////////////
class UniqueObjectIdMgr
{
public:
static unsigned int NewFlowPointId()
{
return the().newFlowPointIdInternal();
}
static unsigned int NewMCId()
{
return the().newMCIdInternal();
}
static size_t NewUndefinedValueId()
{
return the().newUndefinedValueIdInternal();
}
static void Reset()
{
the().resetInternal();
}
private:
static UniqueObjectIdMgr& the();
unsigned int newFlowPointIdInternal();
unsigned int newMCIdInternal();
size_t newUndefinedValueIdInternal();
void resetInternal();
UniqueObjectIdMgr(void);
unsigned int m_flowPointIdCounter;
unsigned int m_MCIdCounter;
size_t m_UndefinedValueCounter;
};
| [
"man701@46565ccc-2a3b-0f42-2bc5-e45c9856c86c"
] | [
[
[
1,
41
]
]
] |
950e0ee5d392102cc35b9be08e9c1123aaf3cacc | afd610f0d62541d28f8d3b0a04bbb1ab3379b375 | /trunk/MarioDSFlipPuzzle/src/MarioDSFlipPuzzleDlg.h | 9fc547cd776ab73aec2dfd04c91673ac64203eb9 | [] | no_license | yoiang/Google-Code-Dump | d252f978eb787a2f1ce5bb64a453438671545326 | e505b1ef9fe4f822abc44afd16d818f0e387fc2d | refs/heads/master | 2021-01-18T20:20:23.263456 | 2008-07-23T21:17:25 | 2008-07-23T21:17:25 | 23,433,560 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,369 | h | #ifndef INCLUDED_MarioDSFlipPuzzleDlg
#define INCLUDED_MarioDSFlipPuzzleDlg
#include <afxwin.h>
#include "MarioDSFlipPuzzleBoard.h"
#include <vector>
class CMarioDSFlipPuzzleDlg : public CDialog
{
// Construction
public:
CMarioDSFlipPuzzleDlg(CWnd* pParent = NULL); // standard constructor
~CMarioDSFlipPuzzleDlg();
// Dialog Data
//{{AFX_DATA(CMarioDSFlipPuzzleDlg)
enum { IDD = IDD_MARIODSFLIPPUZZLE_DIALOG };
CStatic m_csStepsCount;
CButton m_cgMatchingArea;
CButton m_ccLinkDimensions;
CButton m_cgWorkingArea;
CButton m_cgBeforeArea;
CButton m_cgAfterArea;
CEdit m_ceWidthValue;
CEdit m_ceHeightValue;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMarioDSFlipPuzzleDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
enum
{
IMAGE_WIDTH = 15,
IMAGE_HEIGHT = 15,
IMAGE_LEFT_SPACING = 5,
IMAGE_TOP_SPACING = 15,
IMAGE_WIDTH_SPACING = 5,
IMAGE_HEIGHT_SPACING = 5,
};
// Implementation
protected:
HICON m_hIcon;
MarioDSFlipPuzzleBoard *m_pBefore, *m_pAfter, *m_pWorking;
WINDOWPLACEMENT m_BeforePlacement, m_AfterPlacement, m_WorkingPlacement;
bool m_bChanging;
std::vector<CPoint> m_vSteps;
// Generated message map functions
//{{AFX_MSG(CMarioDSFlipPuzzleDlg)
virtual BOOL OnInitDialog();
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnChangeWidthValue();
afx_msg void OnChangeHeightValue();
afx_msg void OnClickLinkDimensions();
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnClickSetToBefore();
afx_msg void OnClickUndo();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
void OnOK();
void UpdateBoardSizes();
void UpdateDialogSize();
void UpdateMatchingStatus();
void UpdateStepsCount();
void DisplayBoards();
void DisplayBoard( MarioDSFlipPuzzleBoard *pDisplay, int iX, int iY );
void DisplaySpace( int iX, int iY, int iSpaceX, int iSpaceY, bool bFacing );
void DisplaySpace( int iX, int iY, bool bFacing );
bool IsWithin( WINDOWPLACEMENT *pArea, CPoint *pPoint );
bool FindSpace( WINDOWPLACEMENT *pArea, CPoint *pPoint, int &iXSpace, int &iYSpace );
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif
| [
"yo.ian.g@d559ecde-2541-0410-ba37-b79e5d9e5dcd"
] | [
[
[
1,
84
]
]
] |
73179f0d1702aeda96ceb8228cf192bba194e238 | f5b309f76238ca822b03ccfeebc16d7bce2229a8 | / pppoe-killer/lib/hippolib/hippolib/util/base64.hpp | b26fef106881ddb667f7cea389f67b9aee53103a | [] | no_license | mluis/pppoe-killer | 41e043dfeaf65bab70ca9abb2693f8c78ce2f99d | 015efa47e10127336860712a5fcd6c664c43c56a | refs/heads/master | 2021-06-04T11:06:26.219992 | 2008-09-09T06:44:14 | 2008-09-09T06:44:14 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,548 | hpp | #ifndef _HIPPOLIB_BASE64_H
#define _HIPPOLIB_BASE64_H
#include <string>
namespace hippolib
{
class base64
{
public:
static std::string Encode(const std::string & src)
{
using namespace std;
string ret;
size_t bsize;
char *bdata;
ret = "";
if(src.size() == 0)
return "";
bsize = b64_encode(NULL, src.size(), NULL, 0);
bdata = new char[bsize];
if(b64_encode(src.data(), src.size(), bdata, bsize) == 0)
{
delete bdata;
throw bad_alloc();
}
ret.assign(bdata, bsize);
delete bdata;
return ret;
}
static std::string Decode(const std::string & src)
{
using namespace std;
string ret;
size_t bsize;
char *bdata;
if(src.size() == 0)
return "";
bsize = b64_decode(NULL, src.size(), NULL, 0);
bdata = new char[bsize];
if((bsize = b64_decode(src.data(), src.size(), bdata, bsize)) == 0)
{
delete bdata;
throw bad_alloc();
}
ret.assign(bdata, bsize);
delete bdata;
return ret;
}
private:
/**
The following codes is the b64 library from Synesis Software
Website: http://www.synesis.com.au/software/b64.html
*/
enum B64_FLAGS
{
B64_F_LINE_LEN_USE_PARAM = 0x0000 /*!< Uses the lineLen parameter to b64_encode2(). Ignored by b64_decode2(). */
, B64_F_LINE_LEN_INFINITE = 0x0001 /*!< Ignores the lineLen parameter to b64_encode2(). Line length is infinite. Ignored by b64_decode2(). */
, B64_F_LINE_LEN_64 = 0x0002 /*!< Ignores the lineLen parameter to b64_encode2(). Line length is 64. Ignored by b64_decode2(). */
, B64_F_LINE_LEN_76 = 0x0003 /*!< Ignores the lineLen parameter to b64_encode2(). Line length is 76. Ignored by b64_decode2(). */
, B64_F_LINE_LEN_MASK = 0x000f /*!< Mask for testing line length flags to b64_encode2(). Ignored by b64_encode2(). */
, B64_F_STOP_ON_NOTHING = 0x0000 /*!< Decoding ignores all invalid characters in the input data. Ignored by b64_encode2(). */
, B64_F_STOP_ON_UNKNOWN_CHAR = 0x0100 /*!< Causes decoding to break if any non-Base-64 [a-zA-Z0-9=+/], non-whitespace character is encountered. Ignored by b64_encode2(). */
, B64_F_STOP_ON_UNEXPECTED_WS = 0x0200 /*!< Causes decoding to break if any unexpected whitespace is encountered. Ignored by b64_encode2(). */
, B64_F_STOP_ON_BAD_CHAR = 0x0300 /*!< Causes decoding to break if any non-Base-64 [a-zA-Z0-9=+/] character is encountered. Ignored by b64_encode2(). */
};
#define NUM_PLAIN_DATA_BYTES (3)
#define NUM_ENCODED_DATA_BYTES (4)
static size_t b64_encode(void const *src, size_t srcSize, char *dest, size_t destLen)
{
return b64_encode_((unsigned char const*)src, srcSize, dest, destLen, 0);
}
static size_t b64_encode_( unsigned char const *src
, size_t srcSize
, char *const dest
, size_t destLen
, unsigned lineLen)
{
static const char b64_chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
size_t total = ((srcSize + (NUM_PLAIN_DATA_BYTES - 1)) / NUM_PLAIN_DATA_BYTES) * NUM_ENCODED_DATA_BYTES;
if(lineLen > 0)
{
unsigned numLines = (total + (lineLen - 1)) / lineLen;
total += 2 * (numLines - 1);
}
if(NULL == dest)
return total;
else if(destLen < total)
return 0;
else
{
char *p = dest;
char *end = dest + destLen;
size_t len = 0;
for(; NUM_PLAIN_DATA_BYTES <= srcSize; srcSize -= NUM_PLAIN_DATA_BYTES)
{
char characters[NUM_ENCODED_DATA_BYTES];
/*
*
* | 0 | 1 | 2 |
*
* | | | |
* | | | | | | |
* | | | | | | | | | | | | |
* | | | | | | | | | | | | | | | | | | | | | | | | |
*
* | 0 | 1 | 2 | 3 |
*
*/
/* characters[0] is the 6 left-most bits of src[0] */
characters[0] = (char)((src[0] & 0xfc) >> 2);
/* characters[0] is the right-most 2 bits of src[0] and the left-most 4 bits of src[1] */
characters[1] = (char)(((src[0] & 0x03) << 4) + ((src[1] & 0xf0) >> 4));
/* characters[0] is the right-most 4 bits of src[1] and the 2 left-most bits of src[2] */
characters[2] = (char)(((src[1] & 0x0f) << 2) + ((src[2] & 0xc0) >> 6));
/* characters[3] is the right-most 6 bits of src[2] */
characters[3] = (char)(src[2] & 0x3f);
#ifndef __WATCOMC__
assert(characters[0] >= 0 && characters[0] < 64);
assert(characters[1] >= 0 && characters[1] < 64);
assert(characters[2] >= 0 && characters[2] < 64);
assert(characters[3] >= 0 && characters[3] < 64);
#endif /* __WATCOMC__ */
src += NUM_PLAIN_DATA_BYTES;
*p++ = b64_chars[(unsigned char)characters[0]];
assert(NULL != strchr(b64_chars, *(p-1)));
++len;
assert(len != lineLen);
*p++ = b64_chars[(unsigned char)characters[1]];
assert(NULL != strchr(b64_chars, *(p-1)));
++len;
assert(len != lineLen);
*p++ = b64_chars[(unsigned char)characters[2]];
assert(NULL != strchr(b64_chars, *(p-1)));
++len;
assert(len != lineLen);
*p++ = b64_chars[(unsigned char)characters[3]];
assert(NULL != strchr(b64_chars, *(p-1)));
if( ++len == lineLen &&
p != end)
{
*p++ = '\r';
*p++ = '\n';
len = 0;
}
}
if(0 != srcSize)
{
/* Deal with the overspill, by boosting it up to three bytes (using 0s)
* and then appending '=' for any missing characters.
*
* This is done into a temporary buffer, so we can call ourselves and
* have the output continue to be written direct to the destination.
*/
unsigned char dummy[NUM_PLAIN_DATA_BYTES];
size_t i;
for(i = 0; i < srcSize; ++i)
{
dummy[i] = *src++;
}
for(; i < NUM_PLAIN_DATA_BYTES; ++i)
{
dummy[i] = '\0';
}
b64_encode_(&dummy[0], NUM_PLAIN_DATA_BYTES, p, NUM_ENCODED_DATA_BYTES * (1 + 2), 0);
for(p += 1 + srcSize; srcSize++ < NUM_PLAIN_DATA_BYTES; )
{
*p++ = '=';
}
}
return total;
}
}
static size_t b64_decode(char const *src, size_t srcLen, void *dest, size_t destSize)
{
char const *badChar_;
return b64_decode_(src, srcLen, (unsigned char*)dest, destSize, B64_F_STOP_ON_NOTHING, &badChar_);
}
static size_t b64_decode_( char const *src
, size_t srcLen
, unsigned char *dest
, size_t destSize
, unsigned flags
, char const **badChar)
{
static const signed char b64_indexes[] =
{
/* 0 - 31 / 0x00 - 0x1f */
-1, -1, -1, -1, -1, -1, -1, -1
, -1, -1, -1, -1, -1, -1, -1, -1
, -1, -1, -1, -1, -1, -1, -1, -1
, -1, -1, -1, -1, -1, -1, -1, -1
/* 32 - 63 / 0x20 - 0x3f */
, -1, -1, -1, -1, -1, -1, -1, -1
, -1, -1, -1, 62, -1, -1, -1, 63 /* ... , '+', ... '/' */
, 52, 53, 54, 55, 56, 57, 58, 59 /* '0' - '7' */
, 60, 61, -1, -1, -1, -1, -1, -1 /* '8', '9', ... */
/* 64 - 95 / 0x40 - 0x5f */
, -1, 0, 1, 2, 3, 4, 5, 6 /* ..., 'A' - 'G' */
, 7, 8, 9, 10, 11, 12, 13, 14 /* 'H' - 'O' */
, 15, 16, 17, 18, 19, 20, 21, 22 /* 'P' - 'W' */
, 23, 24, 25, -1, -1, -1, -1, -1 /* 'X', 'Y', 'Z', ... */
/* 96 - 127 / 0x60 - 0x7f */
, -1, 26, 27, 28, 29, 30, 31, 32 /* ..., 'a' - 'g' */
, 33, 34, 35, 36, 37, 38, 39, 40 /* 'h' - 'o' */
, 41, 42, 43, 44, 45, 46, 47, 48 /* 'p' - 'w' */
, 49, 50, 51, -1, -1, -1, -1, -1 /* 'x', 'y', 'z', ... */
, -1, -1, -1, -1, -1, -1, -1, -1
, -1, -1, -1, -1, -1, -1, -1, -1
, -1, -1, -1, -1, -1, -1, -1, -1
, -1, -1, -1, -1, -1, -1, -1, -1
, -1, -1, -1, -1, -1, -1, -1, -1
, -1, -1, -1, -1, -1, -1, -1, -1
, -1, -1, -1, -1, -1, -1, -1, -1
, -1, -1, -1, -1, -1, -1, -1, -1
, -1, -1, -1, -1, -1, -1, -1, -1
, -1, -1, -1, -1, -1, -1, -1, -1
, -1, -1, -1, -1, -1, -1, -1, -1
, -1, -1, -1, -1, -1, -1, -1, -1
, -1, -1, -1, -1, -1, -1, -1, -1
, -1, -1, -1, -1, -1, -1, -1, -1
, -1, -1, -1, -1, -1, -1, -1, -1
, -1, -1, -1, -1, -1, -1, -1, -1
};
const size_t wholeChunks = (srcLen / NUM_ENCODED_DATA_BYTES);
const size_t remainderBytes = (srcLen % NUM_ENCODED_DATA_BYTES);
size_t maxTotal = (wholeChunks + (0 != remainderBytes)) * NUM_PLAIN_DATA_BYTES;
unsigned char *dest_ = dest;
((void)remainderBytes);
assert(NULL != badChar);
*badChar = NULL;
if(NULL == dest)
{
return maxTotal;
}
else if(destSize < maxTotal)
{
return 0;
}
else
{
/* Now we iterate through the src, collecting together four characters
* at a time from the Base-64 alphabet, until the end-point is reached.
*
*
*/
char const *begin = src;
char const *const end = begin + srcLen;
size_t currIndex = 0;
size_t numPads = 0;
signed char indexes[NUM_ENCODED_DATA_BYTES]; /* 4 */
for(; begin != end; ++begin)
{
const char ch = *begin;
if('=' == ch)
{
assert(currIndex < NUM_ENCODED_DATA_BYTES);
indexes[currIndex++] = '\0';
++numPads;
}
else
{
signed char index = b64_indexes[(unsigned char)ch];
if(-1 == index)
{
switch(ch)
{
case ' ':
case '\t':
case '\b':
case '\v':
if(B64_F_STOP_ON_UNEXPECTED_WS & flags)
{
*badChar = begin;
return 0;
}
else
{
/* Fall through */
}
case '\r':
case '\n':
continue;
default:
if(B64_F_STOP_ON_UNKNOWN_CHAR & flags)
{
*badChar = begin;
return 0;
}
else
{
continue;
}
}
}
else
{
numPads = 0;
assert(currIndex < NUM_ENCODED_DATA_BYTES);
indexes[currIndex++] = index;
}
}
if(NUM_ENCODED_DATA_BYTES == currIndex)
{
unsigned char bytes[NUM_PLAIN_DATA_BYTES]; /* 3 */
bytes[0] = (unsigned char)((indexes[0] << 2) + ((indexes[1] & 0x30) >> 4));
currIndex = 0;
*dest++ = bytes[0];
if(2 != numPads)
{
bytes[1] = (unsigned char)(((indexes[1] & 0xf) << 4) + ((indexes[2] & 0x3c) >> 2));
*dest++ = bytes[1];
if(1 != numPads)
{
bytes[2] = (unsigned char)(((indexes[2] & 0x3) << 6) + indexes[3]);
*dest++ = bytes[2];
}
}
if(0 != numPads)
{
break;
}
}
}
return (size_t)(dest - dest_);
}
}
};
}
#endif
| [
"ptthippo@b4fe46aa-e838-0410-827a-8b5f5aca3737"
] | [
[
[
1,
394
]
]
] |
23bcc1b3648576dc51c6b47b8cbc8350be9e0fc2 | db0d644f1992e5a82e22579e6287f45a8f8d357a | /Caster/Dispatcher/Dispatcher.h | cc54ec6e182d67ccdf2763a1ec8210e91c54a10b | [] | no_license | arnout/nano-cast | 841a6dc394bfb30864134bce70e11d29b77c2411 | 5d11094da4dbb5027ce0a3c870b6a6cc9fcc0179 | refs/heads/master | 2021-01-01T05:14:29.996348 | 2011-01-15T17:27:48 | 2011-01-15T17:27:48 | 58,049,740 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,251 | h | #ifndef DispatcherIncluded
#define DispatcherIncluded
/////////////////////////////////////////////////////////////////////////////////////
//
// A Dispatcher manages network and timer events.
// It invokes a code "fragment" when an event occurs
// and cleans up fragements which have exited.
//
// By being event driven and using finite-state "fragments" of code,
// the Dispatcher avoids having to create a thread for each connection.
// The total memory requirements are minimal, and there is no need
// to deal with contention.
//
////////////////////////////////////////////////////////////////////////////////////////////////
// Fragment and Dispatcher must go together to support
// inlining of some of the Fragment functions.
#include "List.h"
#include "Util.h"
class CallBack;
class Dispatcher {
public:
static Status Init();
static Status Cleanup();
static Status Run();
static Status Stop();
static void Call(CallBack *h, Status status);
// Protected
// Note: we use a FifoList to prevent starvation
static FifoList<CallBack> runList;
static bool done; // flag telling us when to stop
};
#endif // DispatcherIncluded
| [
"[email protected]"
] | [
[
[
1,
40
]
]
] |
3a242bb42bc32c26091ac409ae05b9b832aa3d72 | 918c8a14d31946cef59d68420d0f4a8ed4752001 | /waveletshadow/src/CObjLoader.cpp | 840ada24bcdeafc2795c80e43ca16fc339968726 | [] | no_license | rroc/ibrproject | a67b2565402c1eed0c14363633a52c0a81974c0b | 69dbaea6e2de7c00e82d9d08fab20341ba21fac5 | refs/heads/master | 2021-01-01T16:06:46.943270 | 2009-04-03T20:14:15 | 2009-04-03T20:14:15 | 34,713,409 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 15,172 | cpp | #include "CObjLoader.h"
ObjModel::ObjModel()
: iNumNormal(0)
, iNumTexCoord(0)
, iNumTriangle(0)
, iNumVertex(0)
{
this->iNormalArray.clear();
this->iTexCoordArray.clear();
this->iTriangleArray.clear();
this->iVertexArray.clear();
}
ObjModel::~ObjModel()
{
iNormalArray.clear();
iTexCoordArray.clear();
iTriangleArray.clear();
iVertexArray.clear();
}
ObjModel::ObjModel(const ObjModel &aCopy)
{
//make room for the new data
iNumNormal = aCopy.iNumNormal;
iNumTexCoord = aCopy.iNumTexCoord;
iNumTriangle = aCopy.iNumTriangle;
iNumVertex = aCopy.iNumVertex;
iNormalArray.clear();
iTexCoordArray.clear();
iTriangleArray.clear();
iVertexArray.clear();
//Copy data
for(int i = 0; i < iNumNormal; i++)
iNormalArray.push_back( aCopy.iNormalArray.at(i) );
for(int i = 0; i < iNumTexCoord; i++)
iTexCoordArray.push_back( aCopy.iTexCoordArray.at(i) );
for(int i = 0; i < iNumTriangle; i++)
iTriangleArray.push_back( aCopy.iTriangleArray.at(i) );
for(int i = 0; i < iNumVertex; i++)
iVertexArray.push_back( aCopy.iVertexArray.at(i) );
}
//Object Loader
//--------------
CObjLoader::CObjLoader()
{
}
CObjLoader::~CObjLoader()
{
FreeObj();
}
void CObjLoader::FreeObj()
{
for(int i=0, j=iMeshes.size(); i<j; i++)
{
if( iMeshes.at(i) != NULL )
{
delete iMeshes.at(i);
iMeshes.at(i) = NULL;
}
}
iMeshes.clear();
iObj = NULL;
}
//Extract the 3ds data to mesh
CMesh* CObjLoader::GetMesh( int aIndex, float aScale )
{
//select the group
iObj = iMeshes.at( aIndex );
CMesh* mesh = new CMesh();
mesh->iMin.set( 0,0,0 );
mesh->iMax.set( 0,0,0 );
mesh->iName = iObj->iName;
// printf("MESH:\"%s\"(%d),MAT:\"%s\"(%d),\tVRT: ", mesh->iName.c_str(), aIndex, iDataInfo->iMaterials[iDataInfo->iMeshes[aIndex].iGroups[0].iMat].iName, iDataInfo->iMeshes[aIndex].iGroups[0].iMat );
mesh->iMaterialColor = iObj->iObjectColor;
//COPY VERTICES
printf("COPYING Object(%d):\"%s\" v:%d, n:%d, tx:%d, t:%d\n", aIndex, mesh->iName.c_str(), iObj->iNumVertex, iObj->iNumNormal, iObj->iNumTexCoord, iObj->iNumTriangle);
printf("- Mesh Color: (%f, %f, %f, %f)\n", mesh->iMaterialColor.iR, mesh->iMaterialColor.iG, mesh->iMaterialColor.iB, mesh->iMaterialColor.iA );
printf("- Copy vertices: ");
TVector3 vectorData;
if ( 0 == iObj->iVertexArray.size() )
{
printf("\n\nUnsupported .obj file\n");
exit(-1);
}
TVector3 objMin( iObj->iVertexArray[0].X, iObj->iVertexArray[0].Y, iObj->iVertexArray[0].Z );
TVector3 objMax( iObj->iVertexArray[0].X, iObj->iVertexArray[0].Y, iObj->iVertexArray[0].Z );
for( int i=0, j=iObj->iNumVertex; i<j; i++)
{
printf("\b\b\b\b\b\b%6d", i+1 );
//Texture coordinates
//container.iTextureCoords.set(
// ( *iDataInfo->iMeshes[aIndex].iTexCoords+(i*2) )[0]
//, ( *iDataInfo->iMeshes[aIndex].iTexCoords+(i*2) )[1]
//);
//Vertices
vectorData.set( iObj->iVertexArray[i].X * aScale
,iObj->iVertexArray[i].Y * aScale
,iObj->iVertexArray[i].Z * aScale
);
mesh->addVertex( vectorData );
//Mins and Maxs
if( objMin.iX > vectorData.iX ) objMin.iX = vectorData.iX;
if( objMax.iX < vectorData.iX ) objMax.iX = vectorData.iX;
if( objMin.iY > vectorData.iY ) objMin.iY = vectorData.iY;
if( objMax.iY < vectorData.iY ) objMax.iY = vectorData.iY;
if( objMin.iZ > vectorData.iZ ) objMin.iZ = vectorData.iZ;
if( objMax.iZ < vectorData.iZ ) objMax.iZ = vectorData.iZ;
// printf("[%f, %f, %f]\n", vectorData.iX, vectorData.iY, vectorData.iZ );
//normals
/*
vectorData.set( iObj->iNormalArray[i].X
, iObj->iNormalArray[i].Y
, iObj->iNormalArray[i].Z
);
mesh->iVertexNormals.push_back( vectorData );
*/
}
mesh->iMin = objMin;
mesh->iMax = objMax;
//COPY TRIANGLES
int v1, v2, v3;
int n1, n2, n3;
printf(", TRI: ");
// printf("\n");
//Fill normals empty
TVector3 empty(0,0,0);
mesh->iVertexNormals.resize( iObj->iNumVertex, empty );
int verticesAdded(0);
for( int i=0, j=iObj->iNumTriangle; i<j; i++ )
{
printf("\b\b\b\b\b\b\b\b%8d", i+1 );
//VertexIndex indices
v1 = iObj->iTriangleArray.at(i).VertexIndex[0];
v2 = iObj->iTriangleArray.at(i).VertexIndex[1];
v3 = iObj->iTriangleArray.at(i).VertexIndex[2];
// printf("v[%d, %d, %d]\n", v1,v2,v3);
//normal indices
n1 = iObj->iTriangleArray.at(i).NormalIndex[0];
n2 = iObj->iTriangleArray.at(i).NormalIndex[1];
n3 = iObj->iTriangleArray.at(i).NormalIndex[2];
// printf("n[%d, %d, %d]\n\n", n1,n2,n3);
//Normal 1
//---------
vectorData.set( iObj->iNormalArray.at(n1).X
, iObj->iNormalArray.at(n1).Y
, iObj->iNormalArray.at(n1).Z
);
if( mesh->iVertexNormals.at( v1 ) != empty
&& mesh->iVertexNormals.at( v1 ) != vectorData )
{
// printf("d1(%d)",v1);
//this vertex has to be duplicated, and another normal added
mesh->addVertex( mesh->iVertices.at(v1) );
v1 = ( mesh->iVertices.size() - 1 );
mesh->iVertexNormals.push_back( vectorData );
verticesAdded++;
}
else
{
mesh->iVertexNormals.at( v1 ).set( vectorData );
}
//Normal 2
//---------
vectorData.set( iObj->iNormalArray.at(n2).X
, iObj->iNormalArray.at(n2).Y
, iObj->iNormalArray.at(n2).Z
);
if( mesh->iVertexNormals.at( v2 ) != empty
&& mesh->iVertexNormals.at( v2 ) != vectorData )
{
// printf("d2(%d)",v2);
//this vertex has to be duplicated, and another normal added
mesh->addVertex( mesh->iVertices.at(v2) );
v2 = ( mesh->iVertices.size() - 1 );
mesh->iVertexNormals.push_back( vectorData );
verticesAdded++;
}
else
{
mesh->iVertexNormals.at( v2 ).set( vectorData );
}
//Normal 3
//---------
vectorData.set( iObj->iNormalArray.at(n3).X
, iObj->iNormalArray.at(n3).Y
, iObj->iNormalArray.at(n3).Z
);
if( mesh->iVertexNormals.at( v3 ) != empty
&& mesh->iVertexNormals.at( v3 ) != vectorData )
{
// printf("d3(%d)",v3);
//this vertex has to be duplicated, and another normal added
mesh->addVertex( mesh->iVertices.at(v3) );
v3 = ( mesh->iVertices.size() - 1 );
mesh->iVertexNormals.push_back( vectorData );
verticesAdded++;
}
else
{
mesh->iVertexNormals.at( v3 ).set( vectorData );
}
mesh->addTriangle( TTriangle( v1, v2, v3 ) );
// printf("\nT: v[%d, %d, %d] n[%d, %d, %d]\n", v1, v2, v3, n1, n2, n3 );
}
printf("\nVertices Added: %d\nTotal: %d\n---------------------------------\n", verticesAdded, mesh->iVertices.size() );
// system("pause");
return mesh;
}
int CObjLoader::LoadObj(string file)
{
// FreeObj();
iFileName = file;
return ReadData();
}
int CObjLoader::ReadData()
{
printf("Start loading...\n");
string buffer;
string matFileName;
iObj = new ObjModel();
iMeshes.clear();
ifstream input(iFileName.c_str());
//make sure we got the file opened up ok...
if( !input.is_open() )
{
printf("\nERROR FILE:\"%s\" not found!\n", iFileName.c_str() );
return -1;
}
// printf("File found ok...\nCheck Data");
//Setup our ObjModel arrays...
//read one line at a time of the file...
/* while( !input.eof() )
{
// printf(".");
getline(input, buffer);
if(buffer.substr(0,2) == "vn")
iObj->iNumNormal++;
else if(buffer.substr(0,2) == "vt")
iObj->iNumTexCoord++;
else if(buffer.substr(0,1) == "v")
iObj->iNumVertex++;
else if(buffer.substr(0,1) == "f")
iObj->iNumTriangle++;
}
*/
//Make the arrays the right size...
//iObj->iNormalArray = new ObjVertex[iObj->iNumNormal];
//iObj->iTexCoordArray = new ObjTexCoord[iObj->iNumTexCoord];
//iObj->iTriangleArray = new ObjTriangle[iObj->iNumTriangle];
//iObj->iVertexArray = new ObjVertex[iObj->iNumVertex];
// printf("\nDATA: vert: %d, norm: %d, tri: %d", iObj->iNumVertex, iObj->iNumNormal, iObj->iNumTriangle);
//close the file...
// input.close();
//reopen it...
// input.open(iFileName->c_str());
// input.clear();
//make sure we got the file opened up ok...
// if( !input.is_open() )
// return -1;
printf("\nRead in data\n");
ObjTriangle tri;
iObj->iName = "empty";
int vertCount(0);
int normCount(0);
int texcCount(0);
int vertCount2(0);
int normCount2(0);
int texcCount2(0);
//read in line by line
while( !input.eof() )
{
//printf(".");
getline(input, buffer);
istringstream line(buffer);
string temp;
string f1, f2, f3;
//Group name
if(buffer.substr(0,1) == "g")
{
// printf("g ");
if(iObj->iName != "empty")
{
vertCount2 = vertCount;
normCount2 = normCount;
texcCount2 = texcCount;
iObj->iNumNormal = iObj->iNormalArray.size();
iObj->iNumTexCoord = iObj->iTexCoordArray.size();
iObj->iNumVertex = iObj->iVertexArray.size();
iObj->iNumTriangle = iObj->iTriangleArray.size();
iMeshes.push_back( iObj );
iObj = new ObjModel();
}
line >> temp >> f1;
iObj->iName = f1;
}
//vertex normals
else if(buffer.substr(0,2) == "vn")
{
// printf("vn ");
normCount++;
line >> temp >> f1 >> f2 >> f3;
ObjVertex norm = {atof(f1.c_str()),atof(f2.c_str()),atof(f3.c_str())};
iObj->iNormalArray.push_back( norm );
//iObj->iNormalArray[nC].X = atof(f1.c_str());
//iObj->iNormalArray[nC].Y = atof(f2.c_str());
//iObj->iNormalArray[nC].Z = atof(f3.c_str());
//sscanf(buffer.c_str(), "vn %f %f %f", iObj->iNormalArray[nC].X,
// iObj->iNormalArray[nC].Y, iObj->iNormalArray[nC].Z);
}
//vertex texturecoords
else if(buffer.substr(0,2) == "vt")
{
// printf("vt ");
texcCount++;
line >> temp >> f1 >> f2;
ObjTexCoord texc = { atof(f1.c_str()), atof(f2.c_str()) };
iObj->iTexCoordArray.push_back( texc );
//iObj->iTexCoordArray[tC].U = atof(f1.c_str());
//iObj->iTexCoordArray[tC].V = atof(f2.c_str());
//sscanf(buffer.c_str(), "vt %f %f", iObj->iTexCoordArray[tC].U,
// iObj->iTexCoordArray[tC].V);
}
//vertices
else if(buffer.substr(0,1) == "v")
{
// printf("v ");
vertCount++;
line >> temp >> f1 >> f2 >> f3;
ObjVertex vert = {atof(f1.c_str()),atof(f2.c_str()),atof(f3.c_str())};
iObj->iVertexArray.push_back( vert );
//iObj->iVertexArray[vC].X = atof(f1.c_str());
//iObj->iVertexArray[vC].Y = atof(f2.c_str());
//iObj->iVertexArray[vC].Z = atof(f3.c_str());
//sscanf(buffer.c_str(), "v %f %f %f", iObj->iVertexArray[vC].X,
// iObj->iVertexArray[vC].Y, iObj->iVertexArray[vC].Z);
}
//faces (triangles)
else if(buffer.substr(0,1) == "f")
{
// printf("f ");
line >> temp >> f1 >> f2 >> f3;
int sPos = 0;
int ePos = sPos;
string temp2;
ePos = f1.find_first_of("/");
//we have a line with the format of "f %d/%d/%d %d/%d/%d %d/%d/%d"
if(ePos != string::npos)
{
temp2 = f1.substr(sPos, ePos - sPos);
tri.VertexIndex[0] = (atoi(temp2.c_str()) - 1) -vertCount2;
sPos = ePos+1;
ePos = f1.find("/", sPos);
temp2 = f1.substr(sPos, ePos - sPos);
tri.TexCoordIndex[0] = (atoi(temp2.c_str()) - 1) -texcCount2;
sPos = ePos+1;
ePos = f1.length();
temp2 = f1.substr(sPos, ePos - sPos);
tri.NormalIndex[0] = (atoi(temp2.c_str()) - 1) -normCount2;
}
sPos = 0;
ePos = f2.find_first_of("/");
//we have a line with the format of "f %d/%d/%d %d/%d/%d %d/%d/%d"
if(ePos != string::npos)
{
temp2 = f2.substr(sPos, ePos - sPos);
tri.VertexIndex[1] = (atoi(temp2.c_str()) - 1) -vertCount2;
sPos = ePos + 1;
ePos = f2.find("/", sPos+1);
temp2 = f2.substr(sPos, ePos - sPos);
tri.TexCoordIndex[1] = (atoi(temp2.c_str()) - 1) -texcCount2;
sPos = ePos + 1;
ePos = f2.length();
temp2 = f2.substr(sPos, ePos - sPos);
tri.NormalIndex[1] = (atoi(temp2.c_str()) - 1) -normCount2;
}
sPos = 0;
ePos = f3.find_first_of("/");
//we have a line with the format of "f %d/%d/%d %d/%d/%d %d/%d/%d"
if(ePos != string::npos)
{
temp2 = f3.substr(sPos, ePos - sPos);
tri.VertexIndex[2] = (atoi(temp2.c_str()) - 1) -vertCount2;
sPos = ePos + 1;
ePos = f3.find("/", sPos+1);
temp2 = f3.substr(sPos, ePos - sPos);
tri.TexCoordIndex[2] = (atoi(temp2.c_str()) - 1) -texcCount2;
sPos = ePos + 1;
ePos = f3.length();
temp2 = f3.substr(sPos, ePos - sPos);
tri.NormalIndex[2] = (atoi(temp2.c_str()) - 1) -normCount2;
}
iObj->iTriangleArray.push_back( tri );
}
//material filename
else if(buffer.substr(0,6) == "mtllib")
{
// printf("mtllib ");
line >> temp >> f1;
matFileName = f1;
}
//material
else if( (buffer.substr(0,6) == "usemtl" ) && (0<matFileName.length()) )
{
// printf("usemtl ");
//read desired meterial name
line >> temp >> f1;
ifstream inputMat( matFileName.c_str() );
if( !inputMat.is_open() )
{
printf("\nERROR: material file not found!\n" );
// return -1;
}
else
{
// printf("Material file: %s\n", matFileName.c_str() );
while( !inputMat.eof() )
{
// printf(",");
getline(inputMat, buffer);
istringstream line(buffer);
//Material type
if(buffer.substr(0,6) == "newmtl")
{
// printf("newmtl ");
line >> temp >> f2;
//Correct material name
if( f1 == f2 )
{
// printf("Match: %s\n", f2.c_str() );
while( !inputMat.eof() )
{
getline(inputMat, buffer);
istringstream line(buffer);
//read diffuse color
if(buffer.substr(0,2) == "Kd")
{
// printf("kd");
line >> temp >> f1 >> f2 >> f3;
iObj->iObjectColor.iR = atof(f1.c_str());
iObj->iObjectColor.iG = atof(f2.c_str());
iObj->iObjectColor.iB = atof(f3.c_str());
}
//dissolve (=alpha)
else if(buffer.substr(0,1) == "d")
{
// printf("d");
line >> temp >> f1;
iObj->iObjectColor.iA = atof(f1.c_str());
break;
}
//already at the next material
else if(buffer.substr(0,6) == "newmtl")
{
break;
}
}
}
}
}
}
inputMat.close();
}
}// end while read
// printf("e");
input.close();
if(iObj->iName != "empty")
{
iObj->iNumNormal = iObj->iNormalArray.size();
iObj->iNumTexCoord = iObj->iTexCoordArray.size();
iObj->iNumVertex = iObj->iVertexArray.size();
iObj->iNumTriangle = iObj->iTriangleArray.size();
iMeshes.push_back( iObj );
}
//all should be good
printf("\n Read OK.\n");
return iMeshes.size();
}
/* //
//-----------------------------------------------------------------*/
| [
"onnepoika@5699bb8f-202d-0410-a568-af645a74364e"
] | [
[
[
1,
569
]
]
] |
1ad65396548175591f3ff4642829f4916762bde7 | 0033659a033b4afac9b93c0ac80b8918a5ff9779 | /game/server/so2/so_zombie_spawner_rallypoint.cpp | bddc6729246a7fbc1cabe8d40acb9640acc3066c | [] | no_license | jonnyboy0719/situation-outbreak-two | d03151dc7a12a97094fffadacf4a8f7ee6ec7729 | 50037e27e738ff78115faea84e235f865c61a68f | refs/heads/master | 2021-01-10T09:59:39.214171 | 2011-01-11T01:15:33 | 2011-01-11T01:15:33 | 53,858,955 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 533 | cpp | // Add a custom rally point entity for NPC spawners
#include "cbase.h"
#include "so_zombie_spawner_rallypoint.h"
#include "ai_basenpc.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
LINK_ENTITY_TO_CLASS( so_zombie_spawner_rallypoint, CNPCRallyPoint );
CNPCRallyPoint::CNPCRallyPoint()
{
}
void CNPCRallyPoint::Spawn()
{
Precache();
SetSolid( SOLID_NONE );
AddSpawnFlags( SF_NPC_FALL_TO_GROUND );
AddEffects( EF_NODRAW );
SetMoveType( MOVETYPE_NONE );
}
| [
"MadKowa@ec9d42d2-91e1-33f0-ec5d-f2a905d45d61",
"madman.marcanthony@ec9d42d2-91e1-33f0-ec5d-f2a905d45d61"
] | [
[
[
1,
10
]
],
[
[
11,
25
]
]
] |
e3000e4b798a7fce891c93b463d86a07c221d535 | cc97070bb192c613fae05f301713a9ed47e89278 | /utils.cpp | 302c401350b74c1690e4c865002696570e5fee10 | [] | no_license | username0x0a/facebook-protocol | 257f39264ad801b3108d5d97c6ec7216d34053e3 | a97982e0187330326f1c40c709cba5eef60ceea9 | refs/heads/master | 2021-06-15T06:45:42.371823 | 2011-04-20T02:16:48 | 2011-04-20T02:16:48 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,385 | cpp | /*
Facebook plugin for Miranda Instant Messenger
_____________________________________________
Copyright � 2009-11 Michal Zelinka
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, see <http://www.gnu.org/licenses/>.
File name : $HeadURL: https://[email protected]/svn/trunk/facebook/utils.cpp $
Revision : $Revision: 91 $
Last change by : $Author: n3weRm0re.ewer $
Last change on : $Date: 2011-01-08 11:10:34 +0100 (Sat, 08 Jan 2011) $
*/
#include "common.h"
std::string utils::url::encode(const std::string &s)
{
char *encoded = reinterpret_cast<char*>(CallService( MS_NETLIB_URLENCODE,
0,reinterpret_cast<LPARAM>(s.c_str()) ));
std::string ret = encoded;
HeapFree(GetProcessHeap(),0,encoded);
return ret;
}
std::string utils::time::unix_timestamp( )
{
time_t in = ::time( NULL );
return utils::conversion::to_string( ( void* )&in, C_TIME_T );
}
std::string utils::time::mili_timestamp( )
{
SYSTEMTIME st;
std::string timestamp = utils::time::unix_timestamp();
GetSystemTime(&st);
timestamp.append(utils::conversion::to_string( ( void* )&st.wMilliseconds, C_UNSIGNED | C_SHORT ));
return timestamp;
}
std::string utils::conversion::to_string( const void* data, unsigned short flag )
{
std::ostringstream out;
unsigned short type = flag & 0x0FFF;
switch ( type )
{
case C_BOOLEAN:
if ( (*( bool* )data) == true ) return "true";
return "false";
case C_CHAR:
if (FLAG_CONTAINS(flag,C_UNSIGNED)) out << 0+(*( unsigned char* )data);
else out << 0+(*( char* )data);
break;
case C_SHORT:
if (FLAG_CONTAINS(flag,C_UNSIGNED)) out << 0+(*( unsigned short* )data);
else out << 0+(*( short* )data);
break;
case C_INTEGER:
if (FLAG_CONTAINS(flag,C_UNSIGNED)) out << (*( unsigned int* )data);
else out << (*( int* )data);
break;
case C_INTEGER64:
if (FLAG_CONTAINS(flag,C_UNSIGNED)) out << (*( unsigned long long* )data);
else out << (*( long long* )data);
break;
// http://upload.wikimedia.org/wikipedia/commons/d/d2/Float_example.svg
case C_FLOAT:
out << std::setprecision(std::numeric_limits<float>::digits10+5) << (*( float* )data);
break;
// http://upload.wikimedia.org/wikipedia/commons/a/a9/IEEE_754_Double_Floating_Point_Format.svg
case C_DOUBLE:
out << std::setprecision(std::numeric_limits<double>::digits10+2) << (*( double* )data);
break;
// http://upload.wikimedia.org/wikipedia/commons/2/26/IEEE_754_Extended_Floating_Point_Format.svg
case C_LONGDOUBLE:
out << std::setprecision(std::numeric_limits<long double>::digits10+2) << (*( long double* )data);
break;
case C_TIME_T:
out << (*( time_t* )data);
break;
}
return out.str( );
}
void utils::text::replace_first( std::string* data, std::string from, std::string to )
{
std::string::size_type position = 0;
if ( ( position = data->find(from, position) ) != std::string::npos )
{
data->replace( position, from.size(), to );
position++;
}
}
void utils::text::replace_all( std::string* data, std::string from, std::string to )
{
std::string::size_type position = 0;
while ( ( position = data->find( from, position ) ) != std::string::npos )
{
data->replace( position, from.size(), to );
position++;
}
}
unsigned int utils::text::count_all( std::string* data, std::string term )
{
unsigned int count = 0;
std::string::size_type position = 0;
while ( ( position = data->find( term, position ) ) != std::string::npos )
{
count++;
position++;
}
return count;
}
std::string utils::text::special_expressions_decode( std::string data )
{
utils::text::replace_all( &data, "&", "&" );
utils::text::replace_all( &data, """, "\"" );
utils::text::replace_all( &data, "'", "'" );
utils::text::replace_all( &data, "<", "<" );
utils::text::replace_all( &data, ">", ">" );
utils::text::replace_all( &data, "♥", "\xE2\x99\xA5" ); // direct byte replacement
// utils::text::replace_all( &data, "♥", "\\u2665" ); // indirect slashu replacement
utils::text::replace_all( &data, "\\/", "/" );
utils::text::replace_all( &data, "\\\\", "\\" );
utils::text::replace_all( &data, "\\n", "\n" );
// TODO: Add more to comply general usage
// http://www.utexas.edu/learn/html/spchar.html
// http://www.webmonkey.com/reference/Special_Characters
// http://www.degraeve.com/reference/specialcharacters.php
// http://www.chami.com/tips/internet/050798i.html
// http://www.w3schools.com/tags/ref_entities.asp
// http://www.natural-innovations.com/wa/doc-charset.html
// http://webdesign.about.com/library/bl_htmlcodes.htm
return data;
}
std::string utils::text::remove_html( std::string data )
{
std::string new_string = "";
for ( std::string::size_type i = 0; i < data.length( ); i++ )
{
if ( data.at(i) == '<' && data.at(i+1) != ' ' )
{
i = data.find( ">", i );
continue;
}
new_string += data.at(i);
}
return new_string;
}
std::string utils::text::slashu_to_utf8( std::string data )
{
std::string new_string = "";
for ( std::string::size_type i = 0; i < data.length( ); i++ )
{
if ( data.at(i) == '\\' && data.at(i+1) == 'u' )
{
unsigned int udn = strtol( data.substr( i + 2, 4 ).c_str(), NULL, 16 );
if ( udn >= 128 && udn <= 2047 ) // U+0080 .. U+07FF
{
new_string += ( char )( 192 + ( udn / 64 ) );
new_string += ( char )( 128 + ( udn % 64 ) );
}
else if ( udn >= 2048 && udn <= 65535 ) // U+0800 .. U+FFFF
{
new_string += ( char )( 224 + ( udn / 4096 ) );
new_string += ( char )( 128 + ( ( udn / 64 ) % 64 ) );
new_string += ( char )( 128 + ( udn % 64 ) );
}
else if ( udn <= 127 ) // U+0000 .. U+007F (should not appear)
new_string += ( char )udn;
i += 5;
continue;
}
new_string += data.at(i);
}
return new_string;
}
std::string utils::text::trim( std::string data )
{
std::string spaces = " \t"; // TODO: include "nbsp"
std::string::size_type begin = data.find_first_not_of( spaces );
std::string::size_type end = data.find_last_not_of( spaces ) + 1;
return (begin != std::string::npos) ? data.substr( begin, end - begin ) : "";
}
std::string utils::text::source_get_value( std::string* data, unsigned int argument_count, ... )
{
va_list arg;
std::string ret = "";
std::string::size_type start = 0, end = 0;
va_start( arg, argument_count );
for ( unsigned int i = argument_count; i > 0; i-- ) {
if ( i == 1 ) {
end = data->find( va_arg( arg, char* ), start );
if ( start == std::string::npos || end == std::string::npos )
break;
ret = data->substr( start, end - start );
} else {
std::string term = va_arg( arg, char* );
start = data->find( term, start );
if ( start == std::string::npos )
break;
start += term.length();
}
}
va_end( arg );
return ret;
}
int utils::number::random( )
{
srand( ::time( NULL ) );
return rand( );
}
void utils::debug::info( const char* info, HWND parent )
{
CreateDialogParam( g_hInstance, MAKEINTRESOURCE( IDD_INFO ),
parent, FBInfoDialogProc, ( LPARAM )mir_strdup(info) );
}
void utils::debug::test( FacebookProto* fbp )
{
return;
}
int utils::debug::log(std::string file_name, std::string text)
{
char szFile[MAX_PATH];
GetModuleFileNameA(g_hInstance, szFile, SIZEOF(szFile));
std::string path = szFile;
path = path.substr( 0, path.rfind( "\\" ) );
path = path.substr( 0, path.rfind( "\\" ) + 1 );
path = path + file_name.c_str() + ".txt";
SYSTEMTIME time;
GetSystemTime( &time );
std::ofstream out( path.c_str(), std::ios_base::out | std::ios_base::app | std::ios_base::ate );
out << "[" << (time.wHour < 10 ? "0" : "") << time.wHour << ":" << (time.wMinute < 10 ? "0" : "") << time.wMinute << ":" << (time.wSecond < 10 ? "0" : "") << time.wSecond << "] " << text << std::endl;
out.close( );
return EXIT_SUCCESS;
}
void __fastcall utils::mem::detract(char** str )
{
utils::mem::detract( ( void** )str );
}
void __fastcall utils::mem::detract(void** p)
{
utils::mem::detract((void*)(*p));
}
void __fastcall utils::mem::detract(void* p)
{
mir_free(p);
}
void* __fastcall utils::mem::allocate(size_t size)
{
void* p = NULL;
if (size)
{
p = malloc(size);
if (p)
ZeroMemory(p, size);
}
return p;
}
int ext_to_format(const std::string &ext)
{
for(size_t i=0; i<SIZEOF(formats); i++)
{
if(ext == formats[i].ext)
return formats[i].fmt;
}
return PA_FORMAT_UNKNOWN;
}
// OBSOLETE
void MB( const char* m )
{
MessageBoxA( NULL, m, NULL, MB_OK );
}
void MBI( int a )
{
char b[32];
itoa( a, b, 10 );
MB( b );
}
| [
"[email protected]"
] | [
[
[
1,
351
]
]
] |
da88c0543c68eaf0155b4a806dea4179f7c639ce | 2fb3f424bb5deea982290820b0cb4a6d7fd2957f | /USBJoystick.cpp | 22ab714b5be42a075c5729d883fb68145d2ee6b9 | [] | no_license | johnnyquad/RCEncodeUSB2 | 09bfa1a527d15976c9ea1bc9a0fea3dd9aad1e1f | 5de38f04e9a2ee59129d71a7b9b28ebdcb776115 | refs/heads/master | 2021-01-19T18:55:39.327028 | 2011-09-01T19:12:04 | 2011-09-01T19:12:04 | 2,290,722 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,881 | cpp | // Ardrone.cpp
//
// USB Interface to USB joystick/game pad, such as Logitech 'Dual Action' game pad
/// \author Mike McCauley ([email protected])
///
// Copyright (C) 2011 Mike McCauley
// $Id: USBJoystick.cpp,v 1.1 2011/03/14 06:05:34 mikem Exp mikem $
#include "USBJoystick.h"
#include <Usb.h>
USB Usb;
/* keyboard data taken from configuration descriptor */
#define KBD_ADDR 1
#define KBD_EP 1
#define KBD_IF 0
#define EP_MAXPKTSIZE 8
#define EP_POLL 0x0a
// Masks and offsets for contents of USB read for Logitech
// gamepad joystick.
#define JOY_INDEX_LEFT_X 0
#define JOY_INDEX_LEFT_Y 1
#define JOY_INDEX_RIGHT_X 2
#define JOY_INDEX_RIGHT_Y 3
#define JOY_INDEX_BUTTONS_1 4
#define JOY_INDEX_BUTTONS_2 5
#define JOY_INDEX_BUTTONS_3 6
// Masks for buf index 4
#define JOY_MASK_BUTTON_1 0x10
#define JOY_MASK_BUTTON_2 0x20
#define JOY_MASK_BUTTON_3 0x40
#define JOY_MASK_BUTTON_4 0x80
#define JOY_MASK_HAT 0x0f
// Masks for buf index 5
#define JOY_MASK_BUTTON_5 0x1
#define JOY_MASK_BUTTON_6 0x2
#define JOY_MASK_BUTTON_7 0x4
#define JOY_MASK_BUTTON_8 0x8
#define JOY_MASK_BUTTON_9 0x10
#define JOY_MASK_BUTTON_10 0x20
#define JOY_MASK_BUTTON_LEFT_STICK 0x40
#define JOY_MASK_BUTTON_RIGHT_STICK 0x80
// Masks for buf index 6
#define JOY_MASK_BUTTON_MODE 0x8
/////////////////////////////////////////////////////////////////////
USBJoystick::USBJoystick()
{
// Initialise stick, button and hat states
uint8_t i;
for (i = 0; i < USBJOYSTICK_NUM_STICKS; i++)
_stick_value[i] = 0x80;
for (i = 0; i < USBJOYSTICK_NUM_BUTTONS; i++)
_button_value[i] = false;
for (i = 0; i < USBJOYSTICK_NUM_HATS; i++)
_hat_value[i] = USBJOYSTICK_HAT_POS_IDLE;
// Clear callback pointers
_stick_new_value_cb = 0;
_button_new_value_cb = 0;
_hat_new_value_cb = 0;
_stick_value_did_change_cb = 0;
_button_value_did_change_cb = 0;
_hat_value_did_change_cb = 0;
}
void USBJoystick::init()
{
Usb.powerOn();
}
boolean USBJoystick::device_init()
{
byte rcode = 0; //return code
/* Initialize data structures */
ep_record[0] = *(Usb.getDevTableEntry(0, 0)); // copy endpoint 0 parameters
ep_record[1].MaxPktSize = EP_MAXPKTSIZE;
ep_record[1].Interval = EP_POLL;
ep_record[1].sndToggle = bmSNDTOG0;
ep_record[1].rcvToggle = bmRCVTOG0;
Usb.setDevTableEntry(1, ep_record); // plug kbd.endpoint parameters to devtable
// Configure device
if (Usb.setConf(KBD_ADDR, 0, 1))
return false;
// Set boot protocol
if (Usb.setProto(KBD_ADDR, 0, 0, 0))
return false;
return true;
}
void USBJoystick::run()
{
unsigned long current_t = millis();
static unsigned long next_t = 0;
if (current_t > next_t)
{
Usb.Task();
if (Usb.getUsbTaskState() == USB_STATE_CONFIGURING)
{
//wait for addressing state
if (device_init())
Usb.setUsbTaskState(USB_STATE_RUNNING);
}
else if (Usb.getUsbTaskState() == USB_STATE_RUNNING)
poll();
next_t = current_t + USBJOYSTICK_POLL_INTERVAL;
}
}
void USBJoystick::poll()
{
unsigned long currentTime = micros();
if (Usb.inTransfer(KBD_ADDR, KBD_EP, 8, (char*)&data/*buf*/, USB_NAK_NOWAIT) == 0)
{
uint8_t i;
#if 0
//uint8_t *tmp_buf = (uint8_t*)&data;
// Print raw input
for (i = 0; i < 8; i++)
{
showbits(buf[i]);
//Serial.print(buf[i], BIN);
Serial.print(" ");
}
Serial.println("");
#endif
// Stick values
for (i = 0; i < 4; i++)
stickNewValue(i, buf[i]);
// Button values
// We call the mode button 0
buttonNewValue(USBJOYSTICK_BUTTON_MODE, (buf[JOY_INDEX_BUTTONS_3] & JOY_MASK_BUTTON_MODE) ? true : false);
buttonNewValue(USBJOYSTICK_BUTTON_1, (buf[JOY_INDEX_BUTTONS_1] & JOY_MASK_BUTTON_1) ? true : false);
buttonNewValue(USBJOYSTICK_BUTTON_2, (buf[JOY_INDEX_BUTTONS_1] & JOY_MASK_BUTTON_2) ? true : false);
buttonNewValue(USBJOYSTICK_BUTTON_3, (buf[JOY_INDEX_BUTTONS_1] & JOY_MASK_BUTTON_3) ? true : false);
buttonNewValue(USBJOYSTICK_BUTTON_4, (buf[JOY_INDEX_BUTTONS_1] & JOY_MASK_BUTTON_4) ? true : false);
buttonNewValue(USBJOYSTICK_BUTTON_5, (buf[JOY_INDEX_BUTTONS_2] & JOY_MASK_BUTTON_5) ? true : false);
buttonNewValue(USBJOYSTICK_BUTTON_6, (buf[JOY_INDEX_BUTTONS_2] & JOY_MASK_BUTTON_6) ? true : false);
buttonNewValue(USBJOYSTICK_BUTTON_7, (buf[JOY_INDEX_BUTTONS_2] & JOY_MASK_BUTTON_7) ? true : false);
buttonNewValue(USBJOYSTICK_BUTTON_8, (buf[JOY_INDEX_BUTTONS_2] & JOY_MASK_BUTTON_8) ? true : false);
buttonNewValue(USBJOYSTICK_BUTTON_9, (buf[JOY_INDEX_BUTTONS_2] & JOY_MASK_BUTTON_9) ? true : false);
buttonNewValue(USBJOYSTICK_BUTTON_10, (buf[JOY_INDEX_BUTTONS_2] & JOY_MASK_BUTTON_10) ? true : false);
// We call the left and right stick buttons 11 and 12 respectively
buttonNewValue(USBJOYSTICK_BUTTON_LEFT_STICK, (buf[JOY_INDEX_BUTTONS_2] & JOY_MASK_BUTTON_LEFT_STICK) ? true : false);
buttonNewValue(USBJOYSTICK_BUTTON_RIGHT_STICK, (buf[JOY_INDEX_BUTTONS_2] & JOY_MASK_BUTTON_RIGHT_STICK) ? true : false);
hatNewValue(USBJOYSTICK_HAT_1, buf[JOY_INDEX_BUTTONS_1] & JOY_MASK_HAT);
}
unsigned long delta = micros() -currentTime ;
//Serial.println (delta);
}
uint8_t USBJoystick::stickValue(uint8_t stick)
{
return _stick_value[stick];
}
boolean USBJoystick::buttonValue(uint8_t button)
{
return _button_value[button];
}
uint8_t USBJoystick::hatValue(uint8_t hat)
{
return _hat_value[hat];
}
void USBJoystick::stickNewValue(uint8_t stick, uint8_t value)
{
// Call the callback
if (_stick_new_value_cb)
(*_stick_new_value_cb)(stick, value);
uint8_t old_value = _stick_value[stick];
_stick_value[stick] = value;
if (old_value != value)
stickValueDidChange(stick, value);
}
void USBJoystick::buttonNewValue(uint8_t button, boolean value)
{
// Call the callback
if (_button_new_value_cb)
(*_button_new_value_cb)(button, value);
uint8_t old_value = _button_value[button];
_button_value[button] = value;
if (old_value != value)
buttonValueDidChange(button, value);
}
void USBJoystick::hatNewValue(uint8_t hat, uint8_t value)
{
// Call the callback
if (_hat_new_value_cb)
(*_hat_new_value_cb)(hat, value);
uint8_t old_value = _hat_value[hat];
_hat_value[hat] = value;
if (old_value != value)
hatValueDidChange(hat, value);
}
void USBJoystick::stickValueDidChange(uint8_t stick, uint8_t value)
{
// Call the callback
if (_stick_value_did_change_cb)
(*_stick_value_did_change_cb)(stick, value);
}
void USBJoystick::buttonValueDidChange(uint8_t button, boolean value)
{
// Call the callback
if (_button_value_did_change_cb)
(*_button_value_did_change_cb)(button, value);
}
void USBJoystick::hatValueDidChange(uint8_t hat, uint8_t value)
{
// Call the callback
if (_hat_value_did_change_cb)
(*_hat_value_did_change_cb)(hat, value);
}
void USBJoystick::setStickNewValueCallback(void (*cb)(uint8_t stick, uint8_t value))
{
_stick_new_value_cb = cb;
}
void USBJoystick::setButtonNewValueCallback(void (*cb)(uint8_t button, uint8_t value))
{
_button_new_value_cb = cb;
}
void USBJoystick::setHatNewValueCallback(void (*cb)(uint8_t hat, uint8_t value))
{
_hat_new_value_cb = cb;
}
void USBJoystick::setStickValueDidChangeCallback(void (*cb)(uint8_t stick, uint8_t value))
{
_stick_value_did_change_cb = cb;
}
void USBJoystick::setButtonValueDidChangeCallback(void (*cb)(uint8_t button, uint8_t value))
{
_button_value_did_change_cb = cb;
}
void USBJoystick::setHatValueDidChangeCallback(void (*cb)(uint8_t hat, uint8_t value))
{
_hat_value_did_change_cb = cb;
}
joystick_data USBJoystick::getJoyStickData(void)
{
return data;
}
| [
"[email protected]"
] | [
[
[
1,
271
]
]
] |
c75128c53c1ee29b47dc29848f49af7000a006c5 | b957e10ed5376dbe85c07bdef1f510f641984a1a | /Waypoint.cpp | 6a12f179f01502c4d848e63a3bb72d82d9dc6af8 | [] | no_license | alexjshank/motors | 063245c206df936a886f72a22f0f15c78e1129cb | 7193b729466d8caece267f0b8ddbf16d99c13f8a | refs/heads/master | 2016-09-10T15:47:20.906269 | 2009-11-04T18:41:21 | 2009-11-04T18:41:21 | 33,394,870 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 554 | cpp | #include ".\waypoint.h"
#include "graphics.h"
#include "input.h"
extern Input *input;
Waypoint::Waypoint(void)
{
type = E_WAYPOINT;
family = EF_ENVIRONMENT;
}
Waypoint::~Waypoint(void)
{
}
void Waypoint::render() {
if (input->inputContext == EditMode) {
glPushAttrib(GL_ALL_ATTRIB_BITS);
glDisable(GL_DEPTH_TEST);
glDisable(GL_BLEND);
glBegin(GL_LINES);
glColor3f(1,1,1);
glVertex3f(position.x,position.y,position.z);
glVertex3f(position.x,position.y+10.0f,position.z);
glEnd();
glPopAttrib();
}
} | [
"alexjshank@0c9e2a0d-1447-0410-93de-f5a27bb8667b"
] | [
[
[
1,
29
]
]
] |
398bb3a12a9dd6688f9f6b76ad7b15a1d21758f2 | d4b316c5dfe18916d6747e564a6bb8e814d4413a | /date_checker/kupjak/maska/maska/maska.cpp | 9a7919a9e28ed92919a40129307df232a5056700 | [] | no_license | artemshynkarenko/ilsdev | 3c8b485beb66cd9d33c9b844758bf2e79c5ea94f | e6cc62f14aae409cc1e462ba03b8dcb2c1a6aa02 | refs/heads/master | 2016-09-06T08:30:25.052724 | 2009-06-19T16:35:14 | 2009-06-19T16:35:14 | 32,579,868 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 605 | cpp | #include <iostream>
#include <string>
#include <vector>
#include "date.h"
using namespace std;
int main(){
DateTime now;
cout<<"all digit is in range [0, ...]"<<endl;
cout<<"now is "<<now<<endl;
string mask[5];
cout<<"enter masks: (min, hour, day, month, day of week)"<<endl;
for (int i=0; i<5; ++i)
cin>>mask[i];
Condition cond(mask);
if (!cond.valid())
cout<<"Masks is not correct."<<endl;
else{
DateTime next;
if (cond.find_date(now, next, 80*366))
cout<<"next date is "<<next<<endl;
else
cout<<"ther is not next date"<<endl;
}
return 0;
} | [
"artem.shynkarenko@0d0ad13b-7e51-0410-977d-d3f3eabcdc60",
"kupjak@0d0ad13b-7e51-0410-977d-d3f3eabcdc60"
] | [
[
[
1,
2
],
[
5,
11
],
[
15,
15
],
[
18,
18
],
[
29,
31
]
],
[
[
3,
4
],
[
12,
14
],
[
16,
17
],
[
19,
28
]
]
] |
9de161a7619a2eb787ad4a69899e72911de45b48 | ec5bf5236fa8219e2e872bd107e631f9167ad2a7 | /include/guichan/directx3d/directx3dimage.hpp | 3586a5bca7847fa084a13c3849618765f7e4a8fc | [
"BSD-3-Clause"
] | permissive | sanyaade-g2g-repos/guichan | 3412d02644d0d2aeaa0ca7ed9c8f010f6b4ca516 | aac6dda283bf77d4f7838c4a11ca8fa6325837c4 | refs/heads/master | 2020-06-05T22:22:43.864976 | 2009-04-13T10:29:58 | 2009-04-13T10:29:58 | 42,453,067 | 0 | 0 | null | null | null | null | ISO-8859-2 | C++ | false | false | 6,731 | hpp | /* _______ __ __ __ ______ __ __ _______ __ __
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
*
* Copyright (c) 2004, 2005, 2006, 2007 Olof Naessén and Per Larsson
*
* Js_./
* Per Larsson a.k.a finalman _RqZ{a<^_aa
* Olof Naessén a.k.a jansem/yakslem _asww7!uY`> )\a//
* _Qhm`] _f "'c 1!5m
* Visit: http://guichan.darkbits.org )Qk<P ` _: :+' .' "{[
* .)j(] .d_/ '-( P . S
* License: (BSD) <Td/Z <fP"5(\"??"\a. .L
* Redistribution and use in source and _dV>ws?a-?' ._/L #'
* binary forms, with or without )4d[#7r, . ' )d`)[
* modification, are permitted provided _Q-5'5W..j/?' -?!\)cam'
* that the following conditions are met: j<<WP+k/);. _W=j f
* 1. Redistributions of source code must .$%w\/]Q . ."' . mj$
* retain the above copyright notice, ]E.pYY(Q]>. a J@\
* this list of conditions and the j(]1u<sE"L,. . ./^ ]{a
* following disclaimer. 4'_uomm\. )L);-4 (3=
* 2. Redistributions in binary form must )_]X{Z('a_"a7'<a"a, ]"[
* reproduce the above copyright notice, #}<]m7`Za??4,P-"'7. ).m
* this list of conditions and the ]d2e)Q(<Q( ?94 b- LQ/
* following disclaimer in the <B!</]C)d_, '(<' .f. =C+m
* documentation and/or other materials .Z!=J ]e []('-4f _ ) -.)m]'
* provided with the distribution. .w[5]' _[ /.)_-"+? _/ <W"
* 3. Neither the name of Guichan nor the :$we` _! + _/ . j?
* names of its contributors may be used =3)= _f (_yQmWW$#( "
* to endorse or promote products derived - W, sQQQQmZQ#Wwa]..
* from this software without specific (js, \[QQW$QWW#?!V"".
* prior written permission. ]y:.<\.. .
* -]n w/ ' [.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT )/ )/ !
* HOLDERS AND CONTRIBUTORS "AS IS" AND ANY < (; sac , '
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, ]^ .- %
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF c < r
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR aga< <La
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 5% )P'-3L
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR _bQf` y`..)a
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ,J?4P'.P"_(\?d'.,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES _Pa,)!f/<[]/ ?"
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT _2-..:. .r+_,.. .
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ?a.<%"' " -'.a_ _,
* 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 GCN_DIRECTX3DIMAGE_HPP
#define GCN_DIRECTX3DIMAGE_HPP
#include <d3d9.h>
#include <d3dx9.h>
#include <string>
#include "guichan/color.hpp"
#include "guichan/platform.hpp"
#include "guichan/image.hpp"
namespace gcn
{
/**
* DirectX implementation of Image.
*/
class GCN_EXTENSION_DECLSPEC DirectX3DImage : public Image
{
public:
/**
* Constructor. Load an image from a DirectX surface.
*
* @param surface The surface from which to load.
* @param device The D3D device to use when converting the image to display format.
* @param autoFree True if the surface should automatically be deleted.
*/
DirectX3DImage(LPDIRECT3DSURFACE9 surface,
LPDIRECT3DDEVICE9 device,
int width,
int height,
bool autoFree);
/**
* Destructor.
*/
virtual ~DirectX3DImage();
/**
* Gets the D3D texture for the image.
*
* @return The D3D texture handle for the image.
*/
virtual LPDIRECT3DTEXTURE9 getTexture() const;
/**
* Gets the D3D texture width of the image.
*
* @return The D3D texture width of the image.
*/
virtual int getTextureWidth() const;
/**
* Gets the D3D texture height of the image.
*
* @return The D3D texture height of the image.
*/
virtual int getTextureHeight() const;
// Inherited from Image
virtual void free();
virtual int getWidth() const;
virtual int getHeight() const;
virtual Color getPixel(int x, int y);
virtual void putPixel(int x, int y, const Color& color);
virtual void convertToDisplayFormat();
protected:
/**
* Holds the surface image. This surface is NULL after the image
* has been converted to display format.
*/
LPDIRECT3DSURFACE9 mSurface;
/**
* Holds the texture of the image. This texture isn't initialized until
* the image is converted to display format.
*/
LPDIRECT3DTEXTURE9 mTexture;
/**
* Holds the D3D device used when converting the image to display format.
*/
LPDIRECT3DDEVICE9 mDevice;
/**
* True if the image should be auto freed.
*/
bool mAutoFree;
/**
* Holds the width of the image.
*/
int mWidth;
/**
* Holds the height of the image.
*/
int mHeight;
/**
* Holds the texture width of the image.
*/
int mTextureWidth;
/**
* Holds the texture height of the image.
*/
int mTextureHeight;
};
}
#endif // end GCN_DIRECTX3DIMAGE_HPP
| [
"olof.naessen@9b4f5164-5a2d-0410-9de4-b3417c078dbe"
] | [
[
[
1,
177
]
]
] |
5ab220f8b6aaa9d153c683c45ab1effc39a732e4 | 1741474383f0b3bc3518d7935a904f7903f40506 | /A5/List.h | 4b5943ac44598d9a10982dbc50b31eb00e4aedab | [] | no_license | osecki/drexelgroupwork | 739df86f361e00528a6b03032985288d64b464aa | 7c3bde253a50cab42c22d286c80cad72348b4fcf | refs/heads/master | 2020-05-31T02:25:57.734312 | 2009-06-03T18:34:59 | 2009-06-03T18:34:59 | 32,121,248 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 866 | h | /**
* Program: List.h
* Authors: Group 7: Jordan Osecki, Geoff Oxholm, Alimoor Reza
* Class: CS550, Assignment 5, Spring 2009
**/
#ifndef LIST_H_
#define LIST_H_
#include <iostream>
#include <list>
#include <map>
#include "Element.h"
using namespace std;
class Proc;
class List : public Element {
public:
// default constructor
List();
// constructor with sequence
List (list<Expr*> *s);
// copy constructor
List (List* other);
// destructor
virtual ~List();
// Functions for A2
Expr* getFirst();
Expr* getRest();
void concatenate(List* other);
void cons (Expr* e);
virtual int listp();
int nullp();
virtual string toString(map<string,Element*> NT) const;
virtual Element* eval(map<string,Element*> &NT) const;
private:
list<Expr*> *elements;
};
#endif
| [
"alimurreza@c6e0ff0a-2120-11de-a108-cd2f117ce590",
"jordan.osecki@c6e0ff0a-2120-11de-a108-cd2f117ce590"
] | [
[
[
1,
3
],
[
5,
49
]
],
[
[
4,
4
]
]
] |
b15892529e7750a346f404a479bf8c5f35874265 | e109ae97b8a43dbf4f4a42a40f8c8da0641237a5 | /Sergeant.h | 46960e13a5c782ad3e68fa246b791143c9ac4587 | [] | no_license | mtturner/strategoo-code | 8346d48e7b5c038d53843a5195fecd1dc0a4fec9 | 6bdd46fdbd8cc77eca1afdd0bc9e1d293e59e882 | refs/heads/master | 2016-09-06T15:57:20.713674 | 2011-05-06T03:36:15 | 2011-05-06T03:36:15 | 32,553,378 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 476 | h | /******************************************************
Sergeant.h
This is the header file for the Sergeant class.
******************************************************/
#ifndef SERGEANT_H
#define SERGEANT_H
#include"Piece.h"
class Sergeant : public Piece
{
public:
//constructors
Sergeant(int xPos = 0, int yPos = 0, int boardSpace = -1);
Sergeant(std::string filename);
//move
virtual Piece* move(Piece* const destination);
};
#endif
| [
"cakeeater07@28384a92-424b-c9e9-0b9a-6d5e880deeca",
"[email protected]@28384a92-424b-c9e9-0b9a-6d5e880deeca"
] | [
[
[
1,
6
],
[
10,
12
],
[
14,
20
]
],
[
[
7,
9
],
[
13,
13
],
[
21,
23
]
]
] |
47d2e2ba5dca4326885bca0300dd79ef001fccfd | 57855d23617d6a65298c2ae3485ba611c51809eb | /Zen/Enterprise/AppServer/src/I_ApplicationServer.cpp | 92782f371f7148b6b876657f8b69158e23d6cd1c | [] | no_license | Azaezel/quillus-daemos | 7ff4261320c29e0125843b7da39b7b53db685cd5 | 8ee6eac886d831eec3acfc02f03c3ecf78cc841f | refs/heads/master | 2021-01-01T20:35:04.863253 | 2011-04-08T13:46:40 | 2011-04-08T13:46:40 | 32,132,616 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,985 | cpp | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
// Zen Enterprise Framework
//
// Copyright (C) 2001 - 2008 Tony Richards
//
// 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.
//
// Tony Richards [email protected]
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
#include "../I_ApplicationServer.hpp"
#include "ApplicationServer.hpp"
#include <Zen/Core/Threading/MutexFactory.hpp>
#include <Zen/Core/Threading/I_Mutex.hpp>
#include <Zen/Core/Threading/CriticalSection.hpp>
#include <map>
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
namespace Zen {
namespace Enterprise {
namespace AppServer {
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
I_ApplicationServer::I_ApplicationServer()
{
}
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
I_ApplicationServer::~I_ApplicationServer()
{
}
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
static std::map<std::string, I_ApplicationServer*> sm_servers;
static Threading::I_Mutex* sm_pServerGuard = Threading::MutexFactory::create();
namespace { class gc { public: ~gc() { Threading::MutexFactory::destroy(sm_pServerGuard); } }; }
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
I_ApplicationServer&
I_ApplicationServer::getInstance(const std::string& _instanceName)
{
Threading::CriticalSection lock(sm_pServerGuard);
std::map<std::string, I_ApplicationServer*>::iterator iter = sm_servers.find(_instanceName);
if (iter == sm_servers.end())
{
I_ApplicationServer* pServer = new ApplicationServer();
sm_servers[_instanceName] = pServer;
return *pServer;
}
else
{
return *iter->second;
}
}
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
} // namespace AppServer
} // namespace Enterprise
} // namespace Zen
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
| [
"sgtflame@Sullivan"
] | [
[
[
1,
75
]
]
] |
c46eba0492b5d79c148acc1769cce5aef1911116 | b1103db432398a5f99f7fde434852c084457519a | /classes/SMSSender.cpp | 3bd5ff0952411157b2e7f65661558e29299b35fb | [] | no_license | ForjaOMF/OMF-SymbianSDK | 73fa00e8104c0874e44b05ad30af671dde3d7152 | 47d2343dd00636f34707a3518a5737a4f60a14db | refs/heads/master | 2020-12-24T15:49:06.004551 | 2009-10-27T12:35:48 | 2009-10-27T12:35:48 | 351,291 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 16,284 | cpp | /*
* ============================================================================
* Name : CSMSSender of SMSSender.cpp
* Part of : symbian sdk
* Created : 05/06/2008
* Version : 1.0
* Copyright:
* ============================================================================
*/
#include <avkon.hrh>
#include <aknnotewrappers.h>
#include <uri8.h>
#include <http.h>
#include <chttpformencoder.h>
#include <HttpStringConstants.h>
#include <http\RHTTPTransaction.h>
#include <http\RHTTPSession.h>
#include <http\RHTTPHeaders.h>
#include <SMSSenderExample.rsg>
#include <COMMDB.H> //Communications database
#include <CDBPREFTABLE.H> //Connection Preferences table
#include <CommDbConnPref.h>
#include "SMSSender.h"
// Used user agent for requests
_LIT8(KUserAgent, "SimpleClient 1.0");
// headers
_LIT8(KAccept, "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*");
_LIT8(KContentType, "application/x-www-form-urlencoded");
_LIT8(KHost, "opensms.movistar.es");
_LIT8(KConnection, "Keep-Alive");
_LIT8(KEncoding, "gzip, deflate");
// url
_LIT8(KUrl, "https://opensms.movistar.es/aplicacionpost/loginEnvio.jsp");
_LIT8(KNull, "");
const TInt KStatustextBufferSize = 32;
const TInt KInfotextBufferSize = 64;
const TInt KURIBufferSize = 128;
const TInt KDefaultBufferSize = 256;
// ----------------------------------------------------------------------------
// CSMSSender::NewL()
//
// Creates instance of CSMSSender.
// ----------------------------------------------------------------------------
CSMSSender* CSMSSender::NewL()
{
CSMSSender* self = CSMSSender::NewLC();
CleanupStack::Pop(self);
return self;
}
// ----------------------------------------------------------------------------
// CSMSSender::NewLC()
//
// Creates instance of CSMSSender.
// ----------------------------------------------------------------------------
CSMSSender* CSMSSender::NewLC()
{
CSMSSender* self = new (ELeave) CSMSSender();
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
// ----------------------------------------------------------------------------
// CSMSSender::CSMSSender()
//
// First phase constructor.
// ----------------------------------------------------------------------------
CSMSSender::CSMSSender()
: iPostData(NULL),
iRunning(EFalse)
{
}
// ----------------------------------------------------------------------------
// CSMSSender::~CSMSSender()
//
// Destructor.
// ----------------------------------------------------------------------------
CSMSSender::~CSMSSender()
{
iSession.Close();
// and finally close handles
iConnection.Close();
iSocketServ.Close();
delete iPostData;
}
// ----------------------------------------------------------------------------
// CSMSSender::ConstructL()
//
// Second phase construction.
// ----------------------------------------------------------------------------
void CSMSSender::ConstructL()
{
// Open RHTTPSession with default protocol ("HTTP/TCP")
TRAPD(err, iSession.OpenL());
if(err != KErrNone)
{
// Most common error; no access point configured, and session creation
// leaves with KErrNotFound.
_LIT(KErrMsg,
"Cannot create session. Is internet access point configured?");
_LIT(KExitingApp, "Exiting app.");
CEikonEnv::Static()->InfoWinL(KErrMsg, KExitingApp);
User::Leave(err);
}
// Install this class as the callback for authentication requests. When
// page requires authentication the framework calls GetCredentialsL to get
// user name and password.
InstallAuthenticationL(iSession);
iResponse = (KNull);
}
// ----------------------------------------------------------------------------
// CSMSSender::SetHeaderL()
//
// Used to set header value to HTTP request
// ----------------------------------------------------------------------------
void CSMSSender::SetHeaderL(RHTTPHeaders aHeaders,
TInt aHdrField,
const TDesC8& aHdrValue)
{
RStringF valStr = iSession.StringPool().OpenFStringL(aHdrValue);
CleanupClosePushL(valStr);
THTTPHdrVal val(valStr);
aHeaders.SetFieldL(iSession.StringPool().StringF(aHdrField,
RHTTPSession::GetTable()), val);
CleanupStack::PopAndDestroy(); // valStr
}
// ----------------------------------------------------------------------------
// CSMSSender::SendMessage()
//
// Starts a new SMS send transaction.
// ----------------------------------------------------------------------------
TBuf8<1024> CSMSSender::SendMessage(const TDesC8& aLogin,
const TDesC8& aPwd,
const TDesC8& aDest,
const TDesC8& aMsg)
{
SetupConnectionL();
// mount the body
TBuf8<KDefaultBufferSize> text;
// Login
text=(_L8( "TM_ACTION=AUTHENTICATE&TM_LOGIN="));
text+= (aLogin);
// password
text+=(_L8("&TM_PASSWORD="));
text+= (aPwd);
// to
text+=(_L8("&to="));
text+= (aDest);
// messsage
text+=(_L8("&message="));
text+= (aMsg);
// Parse string to URI
TUriParser8 uri;
uri.Parse(KUrl);
// Get request method string for HTTP POST
RStringF method = iSession.StringPool().StringF(HTTP::EPOST,
RHTTPSession::GetTable());
// Open transaction with previous method and parsed uri. This class will
// receive transaction events in MHFRunL and MHFRunError.
iTransaction = iSession.OpenTransactionL(uri, *this, method);
// Set headers for request
RHTTPHeaders hdr = iTransaction.Request().GetHeaderCollection();
SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent);
SetHeaderL(hdr, HTTP::EAccept, KAccept);
SetHeaderL(hdr, HTTP::EContentType, KContentType);
SetHeaderL(hdr, HTTP::EHost, KHost);
SetHeaderL(hdr, HTTP::EConnection, KConnection);
// Copy data to be posted into member variable; iPostData is used later in
// methods inherited from MHTTPDataSupplier.
delete iPostData;
iPostData = text.AllocL();
// Set this class as an data supplier. Inherited MHTTPDataSupplier methods
// are called when framework needs to send body data.
MHTTPDataSupplier* dataSupplier = this;
iTransaction.Request().SetBody(*dataSupplier);
// Submit the transaction. After this the framework will give transaction
// events via MHFRunL and MHFRunError.
iTransaction.SubmitL();
iRunning = ETrue;
iResponse.Copy(KNull);
iSchedulerWait.Start();
return iResponse;
}
// ----------------------------------------------------------------------------
// CSMSSender::CancelTransaction()
//
// Cancels currently running transaction and frees resources related to it.
// ----------------------------------------------------------------------------
void CSMSSender::CancelTransaction()
{
if(!iRunning)
return;
// Close() also cancels transaction (Cancel() can also be used but
// resources allocated by transaction must be still freed with Close())
iTransaction.Close();
// Not running anymore
iRunning = EFalse;
iSchedulerWait.AsyncStop();
}
// ----------------------------------------------------------------------------
// CSMSSender::MHFRunL()
//
// Inherited from MHTTPTransactionCallback
// Called by framework to pass transaction events.
// ----------------------------------------------------------------------------
void CSMSSender::MHFRunL(RHTTPTransaction aTransaction,
const THTTPEvent& aEvent)
{
switch (aEvent.iStatus)
{
case THTTPEvent::EGotResponseBodyData:
{
// Part (or all) of response's body data received. Use
// aTransaction.Response().Body()->GetNextDataPart() to get the actual
// body data.
// Get the body data supplier
MHTTPDataSupplier* body = aTransaction.Response().Body();
TPtrC8 dataChunk;
// GetNextDataPart() returns ETrue, if the received part is the last
// one.
body->GetNextDataPart(dataChunk);
iResponse.Append(dataChunk);
// Always remember to release the body data.
body->ReleaseData();
}
break;
case THTTPEvent::ESucceeded:
{
// Transaction can be closed now. It's not needed anymore.
aTransaction.Close();
iRunning = EFalse;
iSchedulerWait.AsyncStop();
}
break;
case THTTPEvent::EFailed:
{
// Transaction completed with failure.
aTransaction.Close();
iRunning = EFalse;
iSchedulerWait.AsyncStop();
}
break;
default:
// There are more events in THTTPEvent, but they are not usually
// needed. However, event status smaller than zero should be handled
// correctly since it's error.
{
TBuf<KInfotextBufferSize> text;
if (aEvent.iStatus < 0)
{
_LIT(KErrorStr, "Error: %d");
text.Format(KErrorStr, aEvent.iStatus);
// Just close the transaction on errors
aTransaction.Close();
iRunning = EFalse;
iSchedulerWait.AsyncStop();
}
}
break;
}
}
// ----------------------------------------------------------------------------
// CSMSSender::MHFRunError()
//
// Inherited from MHTTPTransactionCallback
// Called by framework when *leave* occurs in handling of transaction event.
// These errors must be handled, or otherwise HTTP-CORE 6 panic is thrown.
// ----------------------------------------------------------------------------
TInt CSMSSender::MHFRunError(TInt aError,
RHTTPTransaction /*aTransaction*/,
const THTTPEvent& /*aEvent*/)
{
// Just notify about the error and return KErrNone.
return KErrNone;
}
// ----------------------------------------------------------------------------
// CSMSSender::GetNextDataPart()
//
// Inherited from MHTTPDataSupplier
// Called by framework when next part of the body is needed. In this
// this provides data for HTTP post.
// ----------------------------------------------------------------------------
TBool CSMSSender::GetNextDataPart(TPtrC8& aDataPart)
{
if(iPostData)
{
// Provide pointer to next chunk of data (return ETrue, if last chunk)
// Usually only one chunk is needed, but sending big file could require
// loading the file in small parts.
aDataPart.Set(iPostData->Des());
}
return ETrue;
}
// ----------------------------------------------------------------------------
// CSMSSender::ReleaseData()
//
// Inherited from MHTTPDataSupplier
// Called by framework. Allows us to release resources needed for previous
// chunk. (e.g. free buffers)
// ----------------------------------------------------------------------------
void CSMSSender::ReleaseData()
{
// It's safe to delete iPostData now.
delete iPostData;
iPostData = NULL;
}
// ----------------------------------------------------------------------------
// CSMSSender::Reset()
//
// Inherited from MHTTPDataSupplier
// Called by framework to reset the data supplier. Indicates to the data
// supplier that it should return to the first part of the data.
// In practise an error has occured while sending data, and framework needs to
// resend data.
// ----------------------------------------------------------------------------
TInt CSMSSender::Reset()
{
// Nothing needed since iPostData still exists and contains all the data.
// (If a file is used and read in small parts we should seek to beginning
// of file and provide the first chunk again in GetNextDataPart() )
return KErrNone;
}
// ----------------------------------------------------------------------------
// CSMSSender::OverallDataSize()
//
// Inherited from MHTTPDataSupplier
// Called by framework. We should return the expected size of data to be sent.
// If it's not know we can return KErrNotFound (it's allowed and does not cause
// problems, since HTTP protocol allows multipart bodys without exact content
// length in header).
// ----------------------------------------------------------------------------
TInt CSMSSender::OverallDataSize()
{
if(iPostData)
return iPostData->Length();
else
return KErrNotFound ;
}
// ----------------------------------------------------------------------------
// CSMSSender::GetCredentialsL()
//
// Inherited from MHTTPAuthenticationCallback
// Called by framework when we requested authenticated page and framework
// needs to know username and password.
// ----------------------------------------------------------------------------
TBool CSMSSender::GetCredentialsL(const TUriC8& aURI,
RString aRealm,
RStringF aAuthenticationType,
RString& aUsername,
RString& aPassword)
{
// aURI, aReal and aAuthenticationType are informational only. We only need
// to set aUsername and aPassword and return ETrue, if aUsername and
// aPassword are provided by user.
// Informational only
TBuf<KURIBufferSize> authType;
TBuf<KURIBufferSize> uri;
TBuf<KDefaultBufferSize> authText;
authType.Copy(aAuthenticationType.DesC());
uri.Copy(aURI.UriDes());
_LIT(KAuthRequired, "%S requires %S authentication.");
authText.Format(KAuthRequired, &uri, &authType);
_LIT(KAuthNote, "Authentication required.");
CEikonEnv::Static()->InfoWinL(KAuthNote, authText);
// Query user name and password
TBuf<KDefaultBufferSize> userName;
TBuf<KDefaultBufferSize> password;
// Set aUsername and aPassword
TBuf8<KDefaultBufferSize> temp;
temp.Copy(userName);
TRAPD(err, aUsername = aRealm.Pool().OpenStringL(temp));
if (!err)
{
temp.Copy(password);
TRAP(err, aPassword = aRealm.Pool().OpenStringL(temp));
if (!err) return ETrue;
}
// Return ETrue if user has given credentials (username and password),
// otherwise EFlase
return EFalse;
}
// ----------------------------------------------------------------------------
// CSMSSender::SetupConnectionL()
//
// The method set the internet access point and connection setups.
// ----------------------------------------------------------------------------
void CSMSSender::SetupConnectionL()
{
if( iConnectionSetupDone )
return;
iConnectionSetupDone = ETrue;
//open socket server and start the connection
User::LeaveIfError(iSocketServ.Connect());
User::LeaveIfError(iConnection.Open(iSocketServ));
// open the IAP communications database
CCommsDatabase* commDB = CCommsDatabase::NewL(EDatabaseTypeIAP);
CleanupStack::PushL(commDB);
// initialize a view
CCommsDbConnectionPrefTableView* commDBView =
commDB->OpenConnectionPrefTableInRankOrderLC(ECommDbConnectionDirectionUnknown);
// go to the first record
User::LeaveIfError(commDBView->GotoFirstRecord());
// Declare a prefTableView Object.
CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref;
// read the connection preferences
commDBView->ReadConnectionPreferenceL(pref);
TUint32 iapID = pref.iBearer.iIapId;
// pop and destroy the IAP View
CleanupStack::PopAndDestroy(commDBView);
// pop and destroy the database object
CleanupStack::PopAndDestroy(commDB);
// Now we have the iap Id. Use it to connect for the connection.
// Create a connection preference variable.
TCommDbConnPref connectPref;
// setup preferences
connectPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
connectPref.SetDirection(ECommDbConnectionDirectionUnknown);
connectPref.SetBearerSet(ECommDbBearerGPRS);
//Sets the CommDb ID of the IAP to use for this connection
connectPref.SetIapId(iapID);
User::LeaveIfError(iConnection.Start(connectPref));
//set the sessions connection info
RStringPool strPool = iSession.StringPool();
RHTTPConnectionInfo connInfo = iSession.ConnectionInfo();
//to use our socket server and connection
connInfo.SetPropertyL ( strPool.StringF(HTTP::EHttpSocketServ,
RHTTPSession::GetTable() ), THTTPHdrVal (iSocketServ.Handle()) );
connInfo.SetPropertyL ( strPool.StringF(HTTP::EHttpSocketConnection,
RHTTPSession::GetTable() ),
THTTPHdrVal (REINTERPRET_CAST(TInt, &(iConnection))) );
}
// end of file | [
"[email protected]"
] | [
[
[
1,
515
]
]
] |
2547a96bbd8c380bf692e0accb51b185a8b8f5a1 | 2391d12c7d1de6f0b542c2c3b171fa286d84f433 | /CHavokManager.h | 5c57132cb9140b3b01407e19529a557cb9c770a4 | [] | no_license | DadyaIgor/ddblivion | cc0405cb062c7ec8e019c4fd820a6cdd34e4dfec | 4450e54ae55e6888e5feda6b6550c8943c274fb1 | refs/heads/master | 2021-01-10T18:03:02.470209 | 2010-05-05T08:49:53 | 2010-05-05T08:49:53 | 46,456,895 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,752 | h | #ifndef HAVOKMANAGER
#define HAVOKMANAGER
class HavokSampledHeightMap : public hkpSampledHeightFieldShape
{
public:
HavokSampledHeightMap(const hkpSampledHeightFieldBaseCinfo& ci,float *_land_heights) : hkpSampledHeightFieldShape(ci)
{
land_heights=_land_heights;
}
virtual void collideSpheres( const CollideSpheresInput& input, SphereCollisionOutput* outputArray) const
{
return hkSampledHeightFieldShape_collideSpheres(*this, input, outputArray);
}
HK_FORCE_INLINE hkReal getHeightAtImpl( int x, int z ) const
{
return land_heights[(z*m_xRes)+x];
}
HK_FORCE_INLINE hkBool getTriangleFlipImpl() const { return false; }
protected:
float *land_heights;
};
class CHavokManager
{
public:
//Constructors and Destructors(empty atm)
CHavokManager();
~CHavokManager();
//The initialization
void Init();
//Step the physics world
void UpdateHavokState();
//Add a rigid body to the physics world
void AddRigidBody(hkpRigidBody *);
//Setup the character
void SetupCharacterProxy();
//Create a rigid body from landscape
hkpRigidBody *CreateLandscapeRigid(float *,float,float);
//Create a hkMemoryRouter for a thread
void CreateThreadMemoryRouter(hkMemoryRouter &);
protected:
//Hardware havok stuff
hkJobThreadPool* threadPool;
hkJobQueue* jobQueue;
//The magical world where physics become true
hkpWorld* physicsWorld;
//The phantom of the character
hkpShapePhantom* m_char_phantom;
//The character proxy
hkpCharacterProxy* m_characterProxy;
//Shape of standing character
hkpShape* m_standShape;
//Not sure what this is...
hkpCharacterContext* m_characterContext;
//Critical section for the havok world
CRITICAL_SECTION *crit_hkWorld;
};
#endif | [
"[email protected]"
] | [
[
[
1,
64
]
]
] |
9602a7db9ca487eeab8e3dca8f47121056eaf97d | 6477cf9ac119fe17d2c410ff3d8da60656179e3b | /Projects/openredalert/src/ui/Cursor.h | 5cd2d24698c0e53ccede4334e6831009989d319d | [] | no_license | crutchwalkfactory/motocakerteam | 1cce9f850d2c84faebfc87d0adbfdd23472d9f08 | 0747624a575fb41db53506379692973e5998f8fe | refs/heads/master | 2021-01-10T12:41:59.321840 | 2010-12-13T18:19:27 | 2010-12-13T18:19:27 | 46,494,539 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,567 | h | // Cursor.h
// 1.0
// This file is part of OpenRedAlert.
//
// OpenRedAlert 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, version 2 of the License.
//
// OpenRedAlert 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 OpenRedAlert. If not, see <http://www.gnu.org/licenses/>.
#ifndef CURSOR_H
#define CURSOR_H
#include <string>
#include "SDL/SDL_types.h"
#include "SDL/SDL_video.h"
#include "RA_Label.h"
/// @todo Move these hardcoded values
#define MAX_CURS_IN_ANIM 24
#define CUR_NOANIM 1
#define CUR_STANDARD 0
#define CUR_SCROLLUP 1
#define CUR_SCROLLUR 2
#define CUR_SCROLLRIGHT 3
#define CUR_SCROLLDR 4
#define CUR_SCROLLDOWN 5
#define CUR_SCROLLDL 6
#define CUR_SCROLLLEFT 7
#define CUR_SCROLLUL 8
#define CUR_NOSCROLL_OFFSET 129
#define CUR_RA_NOSCROLL_OFFSET 123
#define CUR_PLACE 250
class CursorInfo;
class CursorPool;
class Dune2Image;
class TemplateImage;
class RA_Label;
using std::string;
/**
* Cursor
*/
class Cursor
{
public:
Cursor();
~Cursor();
void setCursor(Uint16 cursornum, Uint8 animimages);
void setCursor(const char* curname);
void setPlaceCursor(Uint8 stw, Uint8 sth, Uint8 *icn);
SDL_Surface *getCursor();/*{return image[curimg];}*/
Uint16 getX();
Uint16 getY();
void setXY(Uint16 nx, Uint16 ny);
static Uint8 getNoScrollOffset();
void reloadImages();
SDL_Surface* getTooltip();
void setTooltip(string TipText);
private:
Uint16 currentcursor;
Uint16 x;
Uint16 y;
Uint16 old_x;
Uint16 old_y;
Uint8 curimg;
Uint8 nimgs;
/** Either CUR_RA_NOSCROLL_OFFSET or CUR_NOSCROLL_OFFSET */
static Uint8 nsoff;
SDL_Surface *image[24];
Dune2Image *cursorimg;
/** Image for building placement in game */
TemplateImage *transicn;
Sint16 cursor_offset;
CursorPool* cursorpool;
CursorInfo* ci;
SDL_Surface* transw;
SDL_Surface* transy;
SDL_Surface* transr;
/** Used by place cursor */
Uint32 oldptr;
RA_Label ToolTipLabel[2];
// std::string ToolTipText;
SDL_Surface *TooltipSurface;
Uint32 FG_color;
Uint32 BG_color;
Uint32 CK_color;
};
#endif //CURSOR_H
| [
"[email protected]"
] | [
[
[
1,
118
]
]
] |
90aa9df03ddf50e7b2405282789969e5426af3c7 | 22b6d8a368ecfa96cb182437b7b391e408ba8730 | /engine/include/qvElementViewTypes.h | 1fb4cd4108a6363dee98110511fe27a0deaba783 | [
"MIT"
] | permissive | drr00t/quanticvortex | 2d69a3e62d1850b8d3074ec97232e08c349e23c2 | b780b0f547cf19bd48198dc43329588d023a9ad9 | refs/heads/master | 2021-01-22T22:16:50.370688 | 2010-12-18T12:06:33 | 2010-12-18T12:06:33 | 85,525,059 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,033 | h | /**************************************************************************************************
//This code is part of QuanticVortex for latest information, see http://www.quanticvortex.org
//
//Copyright (c) 2009-2010 QuanticMinds Software Ltda.
//
//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 __ELEMENT_VIEW_TYPES_H_
#define __ELEMENT_VIEW_TYPES_H_
#include <vector>
#include "qvSHashedString.h"
namespace qv
{
namespace views
{
typedef qv::SHashedString EVI_ELEMENT_VIEW_ID;
typedef qv::SHashedString EVT_ELEMENT_VIEW_TYPE;
typedef std::vector<qv::views::EVT_ELEMENT_VIEW_TYPE> ElementViewTypesArray;
static const EVT_ELEMENT_VIEW_TYPE EVT_ELEMENT_VIEW_SCENE("EVT_ELEMENT_VIEW_SCENE");
/// scene elements manager
static const EVT_ELEMENT_VIEW_TYPE EVT_ELEMENT_VIEW_GUI("EVT_ELEMENT_VIEW_GUI");
/// scene gui elements managers
}
}
#endif
| [
"[email protected]"
] | [
[
[
1,
55
]
]
] |
b9ebca9a5a56259e97ef2e31c43d849d4bddf9aa | 59166d9d1eea9b034ac331d9c5590362ab942a8f | /XMLTree2Geom/osg/nodes/osgNodeBranch.cpp | 1d5edb36ff7237a42ee0b80e38d29f0ee5ef07d6 | [] | no_license | seafengl/osgtraining | 5915f7b3a3c78334b9029ee58e6c1cb54de5c220 | fbfb29e5ae8cab6fa13900e417b6cba3a8c559df | refs/heads/master | 2020-04-09T07:32:31.981473 | 2010-09-03T15:10:30 | 2010-09-03T15:10:30 | 40,032,354 | 0 | 3 | null | null | null | null | WINDOWS-1251 | C++ | false | false | 5,437 | cpp | #include "osgNodeBranch.h"
#include "xmlTree.h"
#include <osg/Geometry>
#include <osg/Geode>
#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include <osg/Image>
#include <osgDB/FileUtils>
#include <osg/Texture2D>
#include <osg/AlphaFunc>
#include <osg/CullFace>
#include <osg/Node>
#include <osg/Group>
#include <osg/Drawable>
#include <sstream>
osgNodeBranch::osgNodeBranch()
{
}
osgNodeBranch::~osgNodeBranch()
{
}
void osgNodeBranch::LODSave()
{
//сохранить ствол по LOD'ам
binBranch &branch = xmlTree::Instance().GetBranch();
//количество LOD'ов ствола
int numLOD = branch.m_vBranch.size();
for ( int i = 0 ; i < numLOD ; ++i )
{
osg::ref_ptr< osg::Group > nodeBranch = new osg::Group;
//инициировать корневой узел данными
nodeBranch->addChild( InitBranchGeode( i ).get() );
//добавить текстуру
AddTexture( nodeBranch->getOrCreateStateSet() );
std::stringstream ss;
ss << "branch" << i;
std::string sStl = ss.str() + ".stl";
std::string sFlt = ss.str() + ".flt";
std::string sObj = ss.str() + ".obj";
std::string s3Ds = ss.str() + ".3ds";
bool resStl = osgDB::writeNodeFile( *nodeBranch , sStl.c_str() );
bool resFlt = osgDB::writeNodeFile( *nodeBranch , sFlt.c_str() );
bool resObj = osgDB::writeNodeFile( *nodeBranch , sObj.c_str() );
bool res3Ds = osgDB::writeNodeFile( *nodeBranch , s3Ds.c_str() );
int a = 1;
}
}
osg::ref_ptr< osg::Geode > osgNodeBranch::InitBranchGeode( int iLOD )
{
//инициировать корневой узел данными
osg::ref_ptr< osg::Geode > geode = new osg::Geode;
// Create an object to store geometry in.
osg::ref_ptr< osg::Geometry > geom = new osg::Geometry;
// Create an array of vertices.
osg::ref_ptr<osg::Vec3Array> v = new osg::Vec3Array;
// Create an array of normals.
osg::ref_ptr<osg::Vec3Array> n = new osg::Vec3Array;
// Create a Vec2Array of texture coordinates for texture unit 0
// and attach it to the geom.
osg::ref_ptr<osg::Vec2Array> tc = new osg::Vec2Array;
//получить ссылку на данные ствола
binBranch &branch = xmlTree::Instance().GetBranch();
//копируем координаты
for ( int i = 0 ; i < branch.m_vBranch[ iLOD ].m_vVertex.size() / 3 ; ++i )
{
osg::Vec3 coord( branch.m_vBranch[ iLOD ].m_vVertex[ i * 3 ] ,
branch.m_vBranch[ iLOD ].m_vVertex[ i * 3 + 1 ] ,
branch.m_vBranch[ iLOD ].m_vVertex[ i * 3 + 2 ] );
v->push_back( coord );
osg::Vec3 normal( branch.m_vBranch[ iLOD ].m_vNormal[ i * 3 ] ,
branch.m_vBranch[ iLOD ].m_vNormal[ i * 3 + 1 ] ,
branch.m_vBranch[ iLOD ].m_vNormal[ i * 3 + 2 ] );
n->push_back( normal );
osg::Vec2 tex0( branch.m_vBranch[ iLOD ].m_vTexCoord[ i * 2 ] ,
branch.m_vBranch[ iLOD ].m_vTexCoord[ i * 2 + 1 ] );
tc->push_back( tex0 );
}
geom->setVertexArray( v.get() );
geom->setNormalArray( n.get() );
geom->setNormalBinding( osg::Geometry::BIND_PER_VERTEX );
geom->setTexCoordArray( 0, tc.get() );
for ( int i = 0 ; i < branch.m_vBranch[ iLOD ].m_vvIndex.size() ; ++i )
{
geom->addPrimitiveSet( new osg::DrawElementsUShort(
osg::PrimitiveSet::TRIANGLE_STRIP, branch.m_vBranch[ iLOD ].m_vvIndex[ i ].size() , &branch.m_vBranch[ iLOD ].m_vvIndex[ i ][ 0 ] ) );
}
geode->addDrawable( geom.get() );
//настроить альфа канал
SetupAlfaFunc( geode.get() , iLOD );
return geode.get();
}
void osgNodeBranch::SetupAlfaFunc( osg::ref_ptr< osg::Geode > geode , int iLOD )
{
//настроить альфа канал
//получить ссылку на данные ствола
binBranch &branch = xmlTree::Instance().GetBranch();
if ( branch.m_vBranch[ iLOD ].m_fAlfa > 0.0f)
{
//настройка атрибутов состояния LOD ствола
osg::StateSet* state = geode->getOrCreateStateSet();
//помечаем объект как имеющий прозрачность
state->setRenderingHint( osg::StateSet::TRANSPARENT_BIN );
// Turn on alpha testing
osg::AlphaFunc* af = new osg::AlphaFunc(
osg::AlphaFunc::GREATER, branch.m_vBranch[ iLOD ].m_fAlfa );
state->setAttributeAndModes( af );
}
}
void osgNodeBranch::AddTexture( osg::StateSet* state )
{
//добавить текстуру
//получить ссылку на данные веток
binBranch &branch = xmlTree::Instance().GetBranch();
// Load the texture image
osg::ref_ptr<osg::Image> image0 = osgDB::readImageFile( branch.m_sTexture.c_str() );
// Attach the image in a Texture2D object
osg::ref_ptr<osg::Texture2D> tex0 = new osg::Texture2D;
tex0->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR_MIPMAP_LINEAR);
tex0->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR_MIPMAP_LINEAR);
tex0->setWrap(osg::Texture::WRAP_S,osg::Texture::REPEAT);
tex0->setWrap(osg::Texture::WRAP_T,osg::Texture::REPEAT);
tex0->setImage( image0.get() );
// Attach the 2D texture attribute and enable GL_TEXTURE_2D,
// both on texture unit 0.
state->setTextureAttributeAndModes( 0, tex0.get() );
//включаем отсечение нелицевых граней
osg::CullFace* cf = new osg::CullFace( osg::CullFace::BACK );
state->setAttributeAndModes( cf );
} | [
"asmzx79@3290fc28-3049-11de-8daa-cfecb5f7ff5b"
] | [
[
[
1,
170
]
]
] |
1e92bed10fcfcb6be169e5ab23c988c6b3ed3ee6 | 21da454a8f032d6ad63ca9460656c1e04440310e | /src/net/worldscale/pimap/server/wscMethodExecutor.h | 974fafbf3e520ddf3f61b6a1943b247ea5520bc6 | [] | no_license | merezhang/wcpp | d9879ffb103513a6b58560102ec565b9dc5855dd | e22eb48ea2dd9eda5cd437960dd95074774b70b0 | refs/heads/master | 2021-01-10T06:29:42.908096 | 2009-08-31T09:20:31 | 2009-08-31T09:20:31 | 46,339,619 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 878 | h | #pragma once
#include "wsiMethodExecutor.h"
#include <wcpp/lang/wscObject.h>
#include <net/worldscale/pimap/wsiPimapMethodsUp.h>
#define WS_ClassName_OF_wscMethodExecutor "net.worldscale.pimap.server.wscMethodExecutor"
class wscMethodExecutor : public wscObject , public wsiMethodExecutor , public wsiPimapMethodsUp
{
WS_IMPL_QUERY_INTERFACE_BEGIN( wscMethodExecutor )
WS_IMPL_QUERY_INTERFACE_BODY( wsiMethodExecutor )
WS_IMPL_QUERY_INTERFACE_END()
public:
static const ws_char * const s_class_name;
private:
TransactionContext * m_ptc;
public:
wscMethodExecutor(void);
~wscMethodExecutor(void);
protected:
WS_METHOD( ws_result , Execute )( TransactionContext & tc );
protected:
WS_METHOD( ws_result , Login )(wsiString * username, wsiString * psw);
WS_METHOD( ws_result , Logout )(void);
};
| [
"xukun0217@98f29a9a-77f1-11de-91f8-ab615253d9e8"
] | [
[
[
1,
29
]
]
] |
746bace9791feaa5b38a766dd464b4d1fd0fd00c | 63db2a4036ba87e5da35bca4925464002c3c19d6 | /big_exercise/qt/myqt/3-dialog/fader-3.3/main.cpp | 808bcf828ab2df1d28786222d69dfbe242496899 | [] | no_license | gicsfree/exercise_aka | 6c6ae3ef737e1a3da23001871a3b8c4dea9e7713 | d831bc14d719fcd90a06e29d1832c5ea20abb988 | refs/heads/master | 2022-05-09T11:29:33.265928 | 2011-09-23T11:48:10 | 2011-09-23T11:48:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 411 | cpp |
#include <QApplication>
#include <QTranslator>
#include "configdialog.h"
int main(int argc, char *argv[])
{
// Q_INIT_RESOURCE(configdialog);
QApplication app(argc, argv);
QFont f("AR PL KaitiM GB",12);
app.setFont(f);
QTranslator translator;
translator.load("fader_zh");
app.installTranslator(&translator);
ConfigDialog dialog;
return dialog.exec();
}
| [
"[email protected]"
] | [
[
[
1,
19
]
]
] |
6eaed85a3116c29500b32632ab6d7e0864f2e8da | 27d5670a7739a866c3ad97a71c0fc9334f6875f2 | /CPP/Modules/UiCtrl/AudioCtrlCs.cpp | c9a22a6d7a65b11438b91d6c183650aa9477d33b | [
"BSD-3-Clause"
] | permissive | ravustaja/Wayfinder-S60-Navigator | ef506c418b8c2e6498ece6dcae67e583fb8a4a95 | 14d1b729b2cea52f726874687e78f17492949585 | refs/heads/master | 2021-01-16T20:53:37.630909 | 2010-06-28T09:51:10 | 2010-06-28T09:51:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,428 | cpp | /*
Copyright (c) 1999 - 2010, Vodafone Group Services Ltd
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 the Vodafone Group Services Ltd 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 THE COPYRIGHT HOLDER OR 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.
*/
#include "AudioCtrlCs.h"
#include "RouteEnums.h"
#include "AudioClipsEnum.h"
/* ******************
This is the syntax implemented by the class AudioCtrlLanguageCs:
SoundListNormal := |
FirstCrossing
FirstCrossing AdditionalCrossing
FirstCrossing := ActionAndWhen
AdditionalCrossing := <AndThen> ActionAndWhen
SoundListPriority := |
<DuKorAtFelHall> |
<DuHarAvvikitFranRutten> |
<DuArFrammeVidDinDest>
ActionAndWhen := Action When |
Action
Action := <SvangVanster> |
<SvangHoger> |
<HallVanster> |
<HallHoger> |
<KorRaktFram> |
<VidDestinationen> |
<SvangVanster> <IRondellen> |
<SvangHoger> <IRondellen> |
<KorRaktFram> <IRondellen> |
<KorUr>
RoundaboutExit
RoundaboutExit := <KorUr> |
<Ta> NumberedExit <Utfarten> <IRondellen>
When := <Haer> |
<Om[Distance]> (Distance = 25, 50, 100, 200, 500 meter, 1, 2 km)
********************* */
namespace isab{
using namespace RouteEnums;
using namespace AudioClipsEnum;
AudioCtrlLanguageCs::AudioCtrlLanguageCs() : AudioCtrlLanguageStd()
{
}
class AudioCtrlLanguage* AudioCtrlLanguageCs::New()
{
return new AudioCtrlLanguageCs();
}
int AudioCtrlLanguageCs::newCameraSoundList(
DistanceInfo &deadlines,
SoundClipsList &soundClips)
{
deadlines.sayAtDistance = -1;
deadlines.abortTooShortDistance = -1;
deadlines.abortTooFarDistance = -1;
m_soundState.soundClips = &soundClips;
m_soundState.truncPoint = 0;
m_soundState.noMoreSounds = false;
appendClip(CsSoundCamera);
appendClip(SoundEnd);
resetState();
m_soundState.soundClips = NULL;
return 0;
}
int AudioCtrlLanguageCs::supportsFeetMiles()
{
return 1;
}
int AudioCtrlLanguageCs::supportsYardsMiles()
{
return 1;
}
void AudioCtrlLanguageCs::Distance()
{
switch (m_nextXing.spokenDist) {
/* Metric units */
case 2000:
appendClip(CsSoundPo2Kilometrech);
break;
case 1000:
appendClip(CsSoundPo1Kilometru);
break;
case 500:
appendClip(CsSoundPo500Metrech);
break;
case 200:
appendClip(CsSoundPo200Metrech);
break;
case 100:
appendClip(CsSoundPo100Metrech);
break;
case 50:
appendClip(CsSoundPo50Metrech);
break;
case 25:
appendClip(CsSoundPo25Metrech);
break;
/* Imperial units - miles */
case 3219:
appendClip(CsSoundPo2Milich);
break;
case 1609:
appendClip(CsSoundPo1Mili);
break;
case 803:
appendClip(CsSoundPoPulMile);
break;
case 402:
appendClip(CsSoundPoCtvrtMile);
break;
/* Imperial units - feet */
case 152:
appendClip(CsSoundPo500Stopach);
break;
case 61:
appendClip(CsSoundPo200Stopach);
break;
case 31:
appendClip(CsSoundPo100Stopach);
break;
/* Imperial units - yards */
case 182:
appendClip(CsSoundPo200Yardech);
break;
case 91:
appendClip(CsSoundPo100Yardech);
break;
case 46:
appendClip(CsSoundPo50Yardech);
break;
case 23:
appendClip(CsSoundPo25Yardech);
break;
/* Here */
case 0:
// Should never happen
appendClip(CsSoundZde);
break;
default:
// Internal error, kill the whole sound.
truncateThisCrossing();
}
}
void AudioCtrlLanguageCs::When()
{
if (m_nextXing.spokenDist == 0) {
if (m_nextXing.crossingNum == 1) {
appendClip(CsSoundZde);
} else {
appendClip(CsSoundIhned);
}
} else {
Distance();
}
if (m_nextXing.setTimingMarker) {
appendClip(SoundTimingMarker);
}
}
void AudioCtrlLanguageCs::NumberedExit()
{
if ( (m_nextXing.xing->exitCount < 1) ||
(m_nextXing.xing->exitCount > 8) ) {
// Impossible, can not code that many exits - do nothing
return;
}
appendClip(CsSoundPrvnim + m_nextXing.xing->exitCount - 1);
}
void AudioCtrlLanguageCs::RoundaboutExit()
{
if (m_nextXing.spokenDist == 0) {
appendClip(CsSoundVyjedte);
} else {
appendClip(CsSoundJedte);
NumberedExit();
appendClip(CsSoundVyjezdem);
appendClip(CsSoundNaKruhovemObjezdu);
}
}
void AudioCtrlLanguageCs::ActionAndWhen()
{
if ( (m_nextXing.spokenDist == 0) ||
(RouteAction(m_nextXing.xing->action) == Finally)
) {
Action();
When();
} else {
When();
Action();
}
if (m_nextXing.setTimingMarker) {
appendClip(SoundTimingMarker);
}
}
void AudioCtrlLanguageCs::Action()
{
switch (RouteAction(m_nextXing.xing->action)) {
case InvalidAction:
case Delta:
case RouteActionMax:
case End:
case Start:
/* Should never occur */
truncateThisCrossing();
return;
case EnterRdbt:
case Ahead:
case On: /* Enter highway from ramp */
case ParkCar:
case FollowRoad:
case EnterFerry:
case ChangeFerry:
/* No sound on purpose. */
truncateThisCrossing();
return;
case Left:
appendClip(CsSoundOdbocteVlevo);
break;
case Right:
appendClip(CsSoundOdbocteVpravo);
break;
case Finally:
appendClip(CsSoundVCili);
// NB! No distance info added to this sound if spokenDist==0
break;
case ExitRdbt:
RoundaboutExit();
break;
case AheadRdbt:
if (m_nextXing.spokenDist == 0) {
appendClip(CsSoundVyjedte);
} else {
appendClip(CsSoundJedtePrimo);
appendClip(CsSoundNaKruhovemObjezdu);
}
break;
case LeftRdbt:
if (m_nextXing.spokenDist == 0) {
appendClip(CsSoundVyjedte);
} else {
appendClip(CsSoundOdbocteVlevo);
appendClip(CsSoundNaKruhovemObjezdu);
}
break;
case RightRdbt:
if (m_nextXing.spokenDist == 0) {
appendClip(CsSoundVyjedte);
} else {
appendClip(CsSoundOdbocteVpravo);
appendClip(CsSoundNaKruhovemObjezdu);
}
break;
case ExitAt:
case OffRampLeft:
case OffRampRight:
appendClip(CsSoundVyjedte);
break;
case KeepLeft:
appendClip(CsSoundDrzteSeVlevo);
break;
case KeepRight:
appendClip(CsSoundDrzteSeVpravo);
break;
case UTurn:
appendClip(CsSoundProsimOtocteSe);
break;
case StartWithUTurn:
appendClip(CsSoundOtocteSeAzJeToMozne);
break;
case UTurnRdbt:
if (m_nextXing.spokenDist == 0) {
appendClip(CsSoundVyjedte);
} else {
appendClip(CsSoundProsimOtocteSe);
appendClip(CsSoundNaKruhovemObjezdu);
}
break;
default:
// Make no sound for unknown turns.
truncateThisCrossing();
return;
}
}
void AudioCtrlLanguageCs::FirstCrossing()
{
ActionAndWhen();
}
void AudioCtrlLanguageCs::AdditionalCrossing()
{
appendClip(CsSoundAPotom);
ActionAndWhen();
}
void AudioCtrlLanguageCs::genericDeviatedFromRoute()
{
appendClip(CsSoundNyniJsteMimoTrasu);
}
void AudioCtrlLanguageCs::genericReachedDest()
{
appendClip(CsSoundJsteVCili);
}
} /* namespace isab */
| [
"[email protected]"
] | [
[
[
1,
347
]
]
] |
6aabe540136429168e2ff6568409254cc9e40aa1 | f177993b13e97f9fecfc0e751602153824dfef7e | /ImProSln/MyLib/LEADTOOL/Include/Filters/ILMVIOvLy2.h | 0f5843f1ea5f15ee01397048148fb5af92777061 | [] | no_license | svn2github/imtophooksln | 7bd7412947d6368ce394810f479ebab1557ef356 | bacd7f29002135806d0f5047ae47cbad4c03f90e | refs/heads/master | 2020-05-20T04:00:56.564124 | 2010-09-24T09:10:51 | 2010-09-24T09:10:51 | 11,787,598 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 30,485 | h |
/* this ALWAYS GENERATED file contains the definitions for the interfaces */
/* File created by MIDL compiler version 7.00.0500 */
/* at Thu Nov 05 12:41:58 2009
*/
/* Compiler settings for .\IVOvrLy.idl:
Oicf, W1, Zp8, env=Win32 (32b run)
protocol : dce , ms_ext, c_ext, robust
error checks: allocation ref bounds_check enum stub_data
VC __declspec() decoration level:
__declspec(uuid()), __declspec(selectany), __declspec(novtable)
DECLSPEC_UUID(), MIDL_INTERFACE()
*/
//@@MIDL_FILE_HEADING( )
#pragma warning( disable: 4049 ) /* more than 64k source lines */
/* verify that the <rpcndr.h> version is high enough to compile this file*/
#ifndef __REQUIRED_RPCNDR_H_VERSION__
#define __REQUIRED_RPCNDR_H_VERSION__ 475
#endif
#include "rpc.h"
#include "rpcndr.h"
#ifndef __RPCNDR_H_VERSION__
#error this stub requires an updated version of <rpcndr.h>
#endif // __RPCNDR_H_VERSION__
#ifndef __ILMVIOvLy2_h__
#define __ILMVIOvLy2_h__
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
/* Forward Declarations */
#ifndef __ILMVIOvLy_FWD_DEFINED__
#define __ILMVIOvLy_FWD_DEFINED__
typedef interface ILMVIOvLy ILMVIOvLy;
#endif /* __ILMVIOvLy_FWD_DEFINED__ */
#ifndef __LMVIOvLy_FWD_DEFINED__
#define __LMVIOvLy_FWD_DEFINED__
#ifdef __cplusplus
typedef class LMVIOvLy LMVIOvLy;
#else
typedef struct LMVIOvLy LMVIOvLy;
#endif /* __cplusplus */
#endif /* __LMVIOvLy_FWD_DEFINED__ */
/* header files for imported files */
#include "oaidl.h"
#include "ocidl.h"
#ifdef __cplusplus
extern "C"{
#endif
#ifndef __LMVIOvLyLib_LIBRARY_DEFINED__
#define __LMVIOvLyLib_LIBRARY_DEFINED__
/* library LMVIOvLyLib */
/* [helpstring][version][uuid] */
#ifndef __IIOvLy2_H__
#define __IIOvLy2_H__
static const GUID LIBID_LMVIOvLyLib = {0xe2b7df62, 0x38c5, 0x11d5, {0x91, 0xf6, 0x00, 0x10, 0x4b, 0xdb, 0x8f, 0xf9}};
static const GUID CLSID_LMVIOvLy = {0xe2b7df63, 0x38c5, 0x11d5, {0x91, 0xf6, 0x00, 0x10, 0x4b, 0xdb, 0x8f, 0xf9}};
static const GUID CLSID_LMVIOvLyPropertyPage = {0xe2b7df64, 0x38c5, 0x11d5, {0x91, 0xf6, 0x00, 0x10, 0x4b, 0xdb, 0x8f, 0xf9}};
static const GUID CLSID_LMVAboutIOvLy = {0xe2b7df65, 0x38c5, 0x11d5, {0x91, 0xf6, 0x00, 0x10, 0x4b, 0xdb, 0x8f, 0xf9}};
static const GUID IID_ILMVIOvLy = {0xe2b7df66, 0x38c5, 0x11d5, {0x91, 0xf6, 0x00, 0x10, 0x4b, 0xdb, 0x8f, 0xf9}};
#endif
typedef /* [v1_enum] */
enum RegionConstants
{ REGION_NONE = 0,
REGION_RECT = 1,
REGION_ROUNDRECT = 2,
REGION_ELLIPSE = 3
} RegionConstants;
typedef /* [v1_enum] */
enum LayerTypeConstants
{ LAYERTYPE_BACKGROUND = 0,
LAYERTYPE_VIDEO = 1,
LAYERTYPE_OVERLAYIMAGE = 2
} LayerTypeConstants;
EXTERN_C const IID LIBID_LMVIOvLyLib;
#ifndef __ILMVIOvLy_INTERFACE_DEFINED__
#define __ILMVIOvLy_INTERFACE_DEFINED__
/* interface ILMVIOvLy */
/* [unique][helpstring][uuid][local][object] */
EXTERN_C const IID IID_ILMVIOvLy;
#if defined(__cplusplus) && !defined(CINTERFACE)
MIDL_INTERFACE("E2B7DF66-38C5-11D5-91F6-00104BDB8FF9")
ILMVIOvLy : public IDispatch
{
public:
virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ActiveLayersCount(
/* [retval][out] */ long *pCount) = 0;
virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_IsLayerActive(
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ VARIANT_BOOL *pActive) = 0;
virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_LayerOrder(
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ long *pIndex) = 0;
virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_LayerOrder(
/* [in] */ LayerTypeConstants LayerType,
/* [in] */ long Index) = 0;
virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetLayerInfo(
/* [in] */ LayerTypeConstants LayerType,
/* [out] */ long *pWidth,
/* [out] */ long *pHeight,
/* [out] */ long *pBitsPerPixel) = 0;
virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_OverlayImageFileName(
/* [retval][out] */ BSTR *pImageFileName) = 0;
virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_OverlayImageFileName(
/* [in] */ BSTR ImageFileName) = 0;
virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_OverlayImageDIBPointer(
/* [in] */ long pDIB) = 0;
virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_IsOverlayImageLoaded(
/* [retval][out] */ VARIANT_BOOL *pLoaded) = 0;
virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_BkLayerColor(
/* [retval][out] */ long *pColor) = 0;
virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_BkLayerColor(
/* [in] */ long Color) = 0;
virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_EnableMaskBitmap(
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ VARIANT_BOOL *pEnable) = 0;
virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_EnableMaskBitmap(
/* [in] */ LayerTypeConstants LayerType,
/* [in] */ VARIANT_BOOL Enable) = 0;
virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_MaskImageFileName(
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ BSTR *pMaskImageFileName) = 0;
virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_MaskImageFileName(
/* [in] */ LayerTypeConstants LayerType,
/* [in] */ BSTR MaskImageFileName) = 0;
virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_MaskImageDIBPointer(
/* [in] */ LayerTypeConstants LayerType,
/* [in] */ long pDIB) = 0;
virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_IsMaskImageLoaded(
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ VARIANT_BOOL *pLoaded) = 0;
virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_EnableOpacity(
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ VARIANT_BOOL *pEnable) = 0;
virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_EnableOpacity(
/* [in] */ LayerTypeConstants LayerType,
/* [in] */ VARIANT_BOOL Enable) = 0;
virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_Opacity(
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ long *pOpacity) = 0;
virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_Opacity(
/* [in] */ LayerTypeConstants LayerType,
/* [in] */ long Opacity) = 0;
virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_EnableTransparency(
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ VARIANT_BOOL *pEnable) = 0;
virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_EnableTransparency(
/* [in] */ LayerTypeConstants LayerType,
/* [in] */ VARIANT_BOOL bEnable) = 0;
virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_TransparentColor(
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ long *pColor) = 0;
virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_TransparentColor(
/* [in] */ LayerTypeConstants LayerType,
/* [in] */ long Color) = 0;
virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_XPos(
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ long *pXPos) = 0;
virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_XPos(
/* [in] */ LayerTypeConstants LayerType,
/* [in] */ long XPos) = 0;
virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_YPos(
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ long *pYPos) = 0;
virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_YPos(
/* [in] */ LayerTypeConstants LayerType,
/* [in] */ long YPos) = 0;
virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_Region(
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ RegionConstants *pRegion) = 0;
virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_Region(
/* [in] */ LayerTypeConstants LayerType,
/* [in] */ RegionConstants Region) = 0;
virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_RgnLeft(
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ long *pLeft) = 0;
virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_RgnLeft(
/* [in] */ LayerTypeConstants LayerType,
/* [in] */ long Left) = 0;
virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_RgnTop(
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ long *pTop) = 0;
virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_RgnTop(
/* [in] */ LayerTypeConstants LayerType,
/* [in] */ long Top) = 0;
virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_RgnRight(
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ long *pRight) = 0;
virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_RgnRight(
/* [in] */ LayerTypeConstants LayerType,
/* [in] */ long Right) = 0;
virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_RgnBottom(
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ long *pBottom) = 0;
virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_RgnBottom(
/* [in] */ LayerTypeConstants LayerType,
/* [in] */ long Bottom) = 0;
virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_RgnRoundRectEllipseWidth(
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ long *pWidth) = 0;
virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_RgnRoundRectEllipseWidth(
/* [in] */ LayerTypeConstants LayerType,
/* [in] */ long Width) = 0;
virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_RgnRoundRectEllipseHeight(
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ long *pHeight) = 0;
virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_RgnRoundRectEllipseHeight(
/* [in] */ LayerTypeConstants LayerType,
/* [in] */ long Height) = 0;
};
#else /* C style interface */
typedef struct ILMVIOvLyVtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
ILMVIOvLy * This,
/* [in] */ REFIID riid,
/* [iid_is][out] */
__RPC__deref_out void **ppvObject);
ULONG ( STDMETHODCALLTYPE *AddRef )(
ILMVIOvLy * This);
ULONG ( STDMETHODCALLTYPE *Release )(
ILMVIOvLy * This);
HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )(
ILMVIOvLy * This,
/* [out] */ UINT *pctinfo);
HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )(
ILMVIOvLy * This,
/* [in] */ UINT iTInfo,
/* [in] */ LCID lcid,
/* [out] */ ITypeInfo **ppTInfo);
HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )(
ILMVIOvLy * This,
/* [in] */ REFIID riid,
/* [size_is][in] */ LPOLESTR *rgszNames,
/* [range][in] */ UINT cNames,
/* [in] */ LCID lcid,
/* [size_is][out] */ DISPID *rgDispId);
/* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )(
ILMVIOvLy * This,
/* [in] */ DISPID dispIdMember,
/* [in] */ REFIID riid,
/* [in] */ LCID lcid,
/* [in] */ WORD wFlags,
/* [out][in] */ DISPPARAMS *pDispParams,
/* [out] */ VARIANT *pVarResult,
/* [out] */ EXCEPINFO *pExcepInfo,
/* [out] */ UINT *puArgErr);
/* [helpstring][id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_ActiveLayersCount )(
ILMVIOvLy * This,
/* [retval][out] */ long *pCount);
/* [helpstring][id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_IsLayerActive )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ VARIANT_BOOL *pActive);
/* [helpstring][id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_LayerOrder )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ long *pIndex);
/* [helpstring][id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_LayerOrder )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [in] */ long Index);
/* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE *GetLayerInfo )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [out] */ long *pWidth,
/* [out] */ long *pHeight,
/* [out] */ long *pBitsPerPixel);
/* [helpstring][id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_OverlayImageFileName )(
ILMVIOvLy * This,
/* [retval][out] */ BSTR *pImageFileName);
/* [helpstring][id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_OverlayImageFileName )(
ILMVIOvLy * This,
/* [in] */ BSTR ImageFileName);
/* [helpstring][id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_OverlayImageDIBPointer )(
ILMVIOvLy * This,
/* [in] */ long pDIB);
/* [helpstring][id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_IsOverlayImageLoaded )(
ILMVIOvLy * This,
/* [retval][out] */ VARIANT_BOOL *pLoaded);
/* [helpstring][id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_BkLayerColor )(
ILMVIOvLy * This,
/* [retval][out] */ long *pColor);
/* [helpstring][id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_BkLayerColor )(
ILMVIOvLy * This,
/* [in] */ long Color);
/* [helpstring][id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_EnableMaskBitmap )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ VARIANT_BOOL *pEnable);
/* [helpstring][id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_EnableMaskBitmap )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [in] */ VARIANT_BOOL Enable);
/* [helpstring][id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_MaskImageFileName )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ BSTR *pMaskImageFileName);
/* [helpstring][id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_MaskImageFileName )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [in] */ BSTR MaskImageFileName);
/* [helpstring][id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_MaskImageDIBPointer )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [in] */ long pDIB);
/* [helpstring][id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_IsMaskImageLoaded )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ VARIANT_BOOL *pLoaded);
/* [helpstring][id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_EnableOpacity )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ VARIANT_BOOL *pEnable);
/* [helpstring][id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_EnableOpacity )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [in] */ VARIANT_BOOL Enable);
/* [helpstring][id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_Opacity )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ long *pOpacity);
/* [helpstring][id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_Opacity )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [in] */ long Opacity);
/* [helpstring][id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_EnableTransparency )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ VARIANT_BOOL *pEnable);
/* [helpstring][id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_EnableTransparency )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [in] */ VARIANT_BOOL bEnable);
/* [helpstring][id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_TransparentColor )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ long *pColor);
/* [helpstring][id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_TransparentColor )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [in] */ long Color);
/* [helpstring][id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_XPos )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ long *pXPos);
/* [helpstring][id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_XPos )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [in] */ long XPos);
/* [helpstring][id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_YPos )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ long *pYPos);
/* [helpstring][id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_YPos )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [in] */ long YPos);
/* [helpstring][id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_Region )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ RegionConstants *pRegion);
/* [helpstring][id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_Region )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [in] */ RegionConstants Region);
/* [helpstring][id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_RgnLeft )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ long *pLeft);
/* [helpstring][id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_RgnLeft )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [in] */ long Left);
/* [helpstring][id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_RgnTop )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ long *pTop);
/* [helpstring][id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_RgnTop )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [in] */ long Top);
/* [helpstring][id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_RgnRight )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ long *pRight);
/* [helpstring][id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_RgnRight )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [in] */ long Right);
/* [helpstring][id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_RgnBottom )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ long *pBottom);
/* [helpstring][id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_RgnBottom )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [in] */ long Bottom);
/* [helpstring][id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_RgnRoundRectEllipseWidth )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ long *pWidth);
/* [helpstring][id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_RgnRoundRectEllipseWidth )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [in] */ long Width);
/* [helpstring][id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_RgnRoundRectEllipseHeight )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [retval][out] */ long *pHeight);
/* [helpstring][id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_RgnRoundRectEllipseHeight )(
ILMVIOvLy * This,
/* [in] */ LayerTypeConstants LayerType,
/* [in] */ long Height);
END_INTERFACE
} ILMVIOvLyVtbl;
interface ILMVIOvLy
{
CONST_VTBL struct ILMVIOvLyVtbl *lpVtbl;
};
#ifdef COBJMACROS
#define ILMVIOvLy_QueryInterface(This,riid,ppvObject) \
( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
#define ILMVIOvLy_AddRef(This) \
( (This)->lpVtbl -> AddRef(This) )
#define ILMVIOvLy_Release(This) \
( (This)->lpVtbl -> Release(This) )
#define ILMVIOvLy_GetTypeInfoCount(This,pctinfo) \
( (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) )
#define ILMVIOvLy_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \
( (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) )
#define ILMVIOvLy_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \
( (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) )
#define ILMVIOvLy_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \
( (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) )
#define ILMVIOvLy_get_ActiveLayersCount(This,pCount) \
( (This)->lpVtbl -> get_ActiveLayersCount(This,pCount) )
#define ILMVIOvLy_get_IsLayerActive(This,LayerType,pActive) \
( (This)->lpVtbl -> get_IsLayerActive(This,LayerType,pActive) )
#define ILMVIOvLy_get_LayerOrder(This,LayerType,pIndex) \
( (This)->lpVtbl -> get_LayerOrder(This,LayerType,pIndex) )
#define ILMVIOvLy_put_LayerOrder(This,LayerType,Index) \
( (This)->lpVtbl -> put_LayerOrder(This,LayerType,Index) )
#define ILMVIOvLy_GetLayerInfo(This,LayerType,pWidth,pHeight,pBitsPerPixel) \
( (This)->lpVtbl -> GetLayerInfo(This,LayerType,pWidth,pHeight,pBitsPerPixel) )
#define ILMVIOvLy_get_OverlayImageFileName(This,pImageFileName) \
( (This)->lpVtbl -> get_OverlayImageFileName(This,pImageFileName) )
#define ILMVIOvLy_put_OverlayImageFileName(This,ImageFileName) \
( (This)->lpVtbl -> put_OverlayImageFileName(This,ImageFileName) )
#define ILMVIOvLy_put_OverlayImageDIBPointer(This,pDIB) \
( (This)->lpVtbl -> put_OverlayImageDIBPointer(This,pDIB) )
#define ILMVIOvLy_get_IsOverlayImageLoaded(This,pLoaded) \
( (This)->lpVtbl -> get_IsOverlayImageLoaded(This,pLoaded) )
#define ILMVIOvLy_get_BkLayerColor(This,pColor) \
( (This)->lpVtbl -> get_BkLayerColor(This,pColor) )
#define ILMVIOvLy_put_BkLayerColor(This,Color) \
( (This)->lpVtbl -> put_BkLayerColor(This,Color) )
#define ILMVIOvLy_get_EnableMaskBitmap(This,LayerType,pEnable) \
( (This)->lpVtbl -> get_EnableMaskBitmap(This,LayerType,pEnable) )
#define ILMVIOvLy_put_EnableMaskBitmap(This,LayerType,Enable) \
( (This)->lpVtbl -> put_EnableMaskBitmap(This,LayerType,Enable) )
#define ILMVIOvLy_get_MaskImageFileName(This,LayerType,pMaskImageFileName) \
( (This)->lpVtbl -> get_MaskImageFileName(This,LayerType,pMaskImageFileName) )
#define ILMVIOvLy_put_MaskImageFileName(This,LayerType,MaskImageFileName) \
( (This)->lpVtbl -> put_MaskImageFileName(This,LayerType,MaskImageFileName) )
#define ILMVIOvLy_put_MaskImageDIBPointer(This,LayerType,pDIB) \
( (This)->lpVtbl -> put_MaskImageDIBPointer(This,LayerType,pDIB) )
#define ILMVIOvLy_get_IsMaskImageLoaded(This,LayerType,pLoaded) \
( (This)->lpVtbl -> get_IsMaskImageLoaded(This,LayerType,pLoaded) )
#define ILMVIOvLy_get_EnableOpacity(This,LayerType,pEnable) \
( (This)->lpVtbl -> get_EnableOpacity(This,LayerType,pEnable) )
#define ILMVIOvLy_put_EnableOpacity(This,LayerType,Enable) \
( (This)->lpVtbl -> put_EnableOpacity(This,LayerType,Enable) )
#define ILMVIOvLy_get_Opacity(This,LayerType,pOpacity) \
( (This)->lpVtbl -> get_Opacity(This,LayerType,pOpacity) )
#define ILMVIOvLy_put_Opacity(This,LayerType,Opacity) \
( (This)->lpVtbl -> put_Opacity(This,LayerType,Opacity) )
#define ILMVIOvLy_get_EnableTransparency(This,LayerType,pEnable) \
( (This)->lpVtbl -> get_EnableTransparency(This,LayerType,pEnable) )
#define ILMVIOvLy_put_EnableTransparency(This,LayerType,bEnable) \
( (This)->lpVtbl -> put_EnableTransparency(This,LayerType,bEnable) )
#define ILMVIOvLy_get_TransparentColor(This,LayerType,pColor) \
( (This)->lpVtbl -> get_TransparentColor(This,LayerType,pColor) )
#define ILMVIOvLy_put_TransparentColor(This,LayerType,Color) \
( (This)->lpVtbl -> put_TransparentColor(This,LayerType,Color) )
#define ILMVIOvLy_get_XPos(This,LayerType,pXPos) \
( (This)->lpVtbl -> get_XPos(This,LayerType,pXPos) )
#define ILMVIOvLy_put_XPos(This,LayerType,XPos) \
( (This)->lpVtbl -> put_XPos(This,LayerType,XPos) )
#define ILMVIOvLy_get_YPos(This,LayerType,pYPos) \
( (This)->lpVtbl -> get_YPos(This,LayerType,pYPos) )
#define ILMVIOvLy_put_YPos(This,LayerType,YPos) \
( (This)->lpVtbl -> put_YPos(This,LayerType,YPos) )
#define ILMVIOvLy_get_Region(This,LayerType,pRegion) \
( (This)->lpVtbl -> get_Region(This,LayerType,pRegion) )
#define ILMVIOvLy_put_Region(This,LayerType,Region) \
( (This)->lpVtbl -> put_Region(This,LayerType,Region) )
#define ILMVIOvLy_get_RgnLeft(This,LayerType,pLeft) \
( (This)->lpVtbl -> get_RgnLeft(This,LayerType,pLeft) )
#define ILMVIOvLy_put_RgnLeft(This,LayerType,Left) \
( (This)->lpVtbl -> put_RgnLeft(This,LayerType,Left) )
#define ILMVIOvLy_get_RgnTop(This,LayerType,pTop) \
( (This)->lpVtbl -> get_RgnTop(This,LayerType,pTop) )
#define ILMVIOvLy_put_RgnTop(This,LayerType,Top) \
( (This)->lpVtbl -> put_RgnTop(This,LayerType,Top) )
#define ILMVIOvLy_get_RgnRight(This,LayerType,pRight) \
( (This)->lpVtbl -> get_RgnRight(This,LayerType,pRight) )
#define ILMVIOvLy_put_RgnRight(This,LayerType,Right) \
( (This)->lpVtbl -> put_RgnRight(This,LayerType,Right) )
#define ILMVIOvLy_get_RgnBottom(This,LayerType,pBottom) \
( (This)->lpVtbl -> get_RgnBottom(This,LayerType,pBottom) )
#define ILMVIOvLy_put_RgnBottom(This,LayerType,Bottom) \
( (This)->lpVtbl -> put_RgnBottom(This,LayerType,Bottom) )
#define ILMVIOvLy_get_RgnRoundRectEllipseWidth(This,LayerType,pWidth) \
( (This)->lpVtbl -> get_RgnRoundRectEllipseWidth(This,LayerType,pWidth) )
#define ILMVIOvLy_put_RgnRoundRectEllipseWidth(This,LayerType,Width) \
( (This)->lpVtbl -> put_RgnRoundRectEllipseWidth(This,LayerType,Width) )
#define ILMVIOvLy_get_RgnRoundRectEllipseHeight(This,LayerType,pHeight) \
( (This)->lpVtbl -> get_RgnRoundRectEllipseHeight(This,LayerType,pHeight) )
#define ILMVIOvLy_put_RgnRoundRectEllipseHeight(This,LayerType,Height) \
( (This)->lpVtbl -> put_RgnRoundRectEllipseHeight(This,LayerType,Height) )
#endif /* COBJMACROS */
#endif /* C style interface */
#endif /* __ILMVIOvLy_INTERFACE_DEFINED__ */
EXTERN_C const CLSID CLSID_LMVIOvLy;
#ifdef __cplusplus
class DECLSPEC_UUID("E2B7DF63-38C5-11D5-91F6-00104BDB8FF9")
LMVIOvLy;
#endif
#endif /* __LMVIOvLyLib_LIBRARY_DEFINED__ */
/* Additional Prototypes for ALL interfaces */
/* end of Additional Prototypes */
#ifdef __cplusplus
}
#endif
#endif
| [
"ndhumuscle@fa729b96-8d43-11de-b54f-137c5e29c83a"
] | [
[
[
1,
740
]
]
] |
685b45062e362e30eab2d73c3fcda749991bded1 | b4d726a0321649f907923cc57323942a1e45915b | /CODE/INETFILE/inetgetfile.cpp | 5130a55020d0fc278d764d2585623043bbf4155c | [] | no_license | chief1983/Imperial-Alliance | f1aa664d91f32c9e244867aaac43fffdf42199dc | 6db0102a8897deac845a8bd2a7aa2e1b25086448 | refs/heads/master | 2016-09-06T02:40:39.069630 | 2010-10-06T22:06:24 | 2010-10-06T22:06:24 | 967,775 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,806 | cpp | /*
* Copyright (C) Volition, Inc. 1999. All rights reserved.
*
* All source code herein is the property of Volition, Inc. You may not sell
* or otherwise commercially exploit the source or things you created based on the
* source.
*
*/
/*
* $Logfile: /Freespace2/code/Inetfile/inetgetfile.cpp $
* $Revision: 1.1.1.1 $
* $Date: 2004/08/13 22:47:41 $
* $Author: Spearhawk $
*
* InternetGetFile Class
*
* $Log: inetgetfile.cpp,v $
* Revision 1.1.1.1 2004/08/13 22:47:41 Spearhawk
* no message
*
* Revision 1.1.1.1 2004/08/13 20:50:30 Darkhill
* no message
*
* Revision 2.1 2002/08/01 01:41:06 penguin
* The big include file move
*
* Revision 2.0 2002/06/03 04:02:24 penguin
* Warpcore CVS sync
*
* Revision 1.2 2002/05/08 02:35:09 mharris
* porting
*
* Revision 1.1 2002/05/02 18:03:08 mharris
* Initial checkin - converted filenames and includes to lower case
*
*
* 4 8/22/99 1:19p Dave
* Fixed up http proxy code. Cleaned up scoring code. Reverse the order in
* which d3d cards are detected.
*
* 3 6/16/99 10:27a Andsager
* Make directory if it does not already exist.
*
* 2 4/20/99 6:39p Dave
* Almost done with artillery targeting. Added support for downloading
* images on the PXO screen.
*
* 1 4/20/99 4:37p Dave
*
* Initial version
*
* $NoKeywords: $
*/
#include <windows.h>
#include <stdio.h>
#include <direct.h>
#include <string.h>
#include "globalincs/pstypes.h"
#include "inetfile/cftp.h"
#include "inetfile/chttpget.h"
#include "inetfile/inetgetfile.h"
#define INET_STATE_CONNECTING 1
#define INET_STATE_ERROR 2
#define INET_STATE_RECEIVING 3
#define INET_STATE_GOT_FILE 4
void InetGetFile::AbortGet()
{
if(m_bUseHTTP)
{
http->AbortGet();
}
else
{
ftp->AbortGet();
}
}
InetGetFile::InetGetFile(char *URL,char *localfile)
{
m_HardError = 0;
http=NULL;
ftp=NULL;
if ((URL==NULL)||(localfile==NULL)) {
m_HardError = INET_ERROR_BADPARMS;
}
// create directory if not already there.
char dir_name[256], *end;
// make sure localfile has \ in it or we'll be here a long time.
if (strstr(localfile, "\\")) {
strcpy(dir_name, localfile);
int len = strlen(localfile);
end = dir_name + len;
// start from end of localfile and go to first \ to get dirname
while ( *end != '\\' ) {
end--;
}
*end = '\0';
if ( _mkdir(dir_name)==0 ) {
mprintf(( "CFILE: Created new directory '%s'\n", dir_name ));
}
}
if (strstr(URL,"http:")) {
m_bUseHTTP = TRUE;
// using http proxy?
extern char Multi_options_proxy[512];
extern ushort Multi_options_proxy_port;
if(strlen(Multi_options_proxy) > 0){
http = new ChttpGet(URL, localfile, Multi_options_proxy, Multi_options_proxy_port);
} else {
http = new ChttpGet(URL, localfile);
}
if (http==NULL) {
m_HardError = INET_ERROR_NO_MEMORY;
}
} else if (strstr(URL,"ftp:")) {
m_bUseHTTP = FALSE;
ftp = new CFtpGet(URL,localfile);
if (ftp==NULL) {
m_HardError = INET_ERROR_NO_MEMORY;
}
} else {
m_HardError = INET_ERROR_CANT_PARSE_URL;
}
Sleep(1000);
}
InetGetFile::~InetGetFile()
{
if(http!=NULL) delete http;
if(ftp!=NULL) delete ftp;
}
BOOL InetGetFile::IsConnecting()
{
int state;
if(m_bUseHTTP)
{
state = http->GetStatus();
}
else
{
state = ftp->GetStatus();
}
if(state == FTP_STATE_CONNECTING)
{
return TRUE;
}
else
{
return FALSE;
}
}
BOOL InetGetFile::IsReceiving()
{
int state;
if(m_bUseHTTP)
{
state = http->GetStatus();
}
else
{
state = ftp->GetStatus();
}
if(state == FTP_STATE_RECEIVING)
{
return TRUE;
}
else
{
return FALSE;
}
}
BOOL InetGetFile::IsFileReceived()
{
int state;
if(m_bUseHTTP)
{
state = http->GetStatus();
}
else
{
state = ftp->GetStatus();
}
if(state == FTP_STATE_FILE_RECEIVED)
{
return TRUE;
}
else
{
return FALSE;
}
}
BOOL InetGetFile::IsFileError()
{
int state;
if(m_HardError) return TRUE;
if(m_bUseHTTP)
{
state = http->GetStatus();
}
else
{
state = ftp->GetStatus();
}
switch(state)
{
case FTP_STATE_URL_PARSING_ERROR:
case FTP_STATE_HOST_NOT_FOUND:
case FTP_STATE_DIRECTORY_INVALID:
case FTP_STATE_FILE_NOT_FOUND:
case FTP_STATE_CANT_CONNECT:
case FTP_STATE_LOGIN_ERROR:
case FTP_STATE_INTERNAL_ERROR:
case FTP_STATE_SOCKET_ERROR:
case FTP_STATE_UNKNOWN_ERROR:
case FTP_STATE_RECV_FAILED:
case FTP_STATE_CANT_WRITE_FILE:
return TRUE;
case FTP_STATE_CONNECTING:
return FALSE;
default:
return FALSE;
}
}
int InetGetFile::GetErrorCode()
{
int state;
if(m_HardError) return m_HardError;
if(m_bUseHTTP)
{
state = http->GetStatus();
}
else
{
state = ftp->GetStatus();
}
switch(state)
{
case FTP_STATE_URL_PARSING_ERROR:
return INET_ERROR_CANT_PARSE_URL;
case FTP_STATE_HOST_NOT_FOUND:
return INET_ERROR_HOST_NOT_FOUND;
case FTP_STATE_DIRECTORY_INVALID:
case FTP_STATE_FILE_NOT_FOUND:
return INET_ERROR_BAD_FILE_OR_DIR;
case FTP_STATE_CANT_CONNECT:
case FTP_STATE_LOGIN_ERROR:
case FTP_STATE_INTERNAL_ERROR:
case FTP_STATE_SOCKET_ERROR:
case FTP_STATE_UNKNOWN_ERROR:
case FTP_STATE_RECV_FAILED:
return INET_ERROR_UNKNOWN_ERROR;
case FTP_STATE_CANT_WRITE_FILE:
return INET_ERROR_CANT_WRITE_FILE;
default:
return INET_ERROR_NO_ERROR;
}
}
int InetGetFile::GetTotalBytes()
{
if(m_bUseHTTP)
{
return http->GetTotalBytes();
}
else
{
return ftp->GetTotalBytes();
}
}
int InetGetFile::GetBytesIn()
{
if(m_bUseHTTP)
{
return http->GetBytesIn();
}
else
{
return ftp->GetBytesIn();
}
}
| [
"[email protected]"
] | [
[
[
1,
308
]
]
] |
12978078045bd1816b919e4511a9e9f77d4c59ef | 6327ac79f3294817895d5ef859509145bc0c28a9 | /win/Render/RenderSystem.cpp | b6356d4757b79f90a34614a74008c630fc5f1375 | [] | no_license | corpsofengineers/ffed3d | c8da1cb6e58f8b37b138d6f7d7ac0faa585e961b | 8b6df7c081fd9ec4cf86220e8561439a8340d59b | refs/heads/master | 2021-01-10T13:17:57.882726 | 2011-12-05T22:24:07 | 2011-12-05T22:24:07 | 49,797,267 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 5,896 | cpp | #include "RenderSystem.h"
#include <assert.h>
class RenderSystem* renderSystem;
RenderSystem::RenderSystem()
{
lpD3D = NULL;
lpD3DDevice = NULL;
}
RenderSystem::~RenderSystem()
{
}
bool RenderSystem::Initialize(int xScr,int yScr,int mode,HWND hWnd,int RefreshRateInHz/* =0 */)
{
memset(renderStates,0xEF,sizeof(renderStates));
hWnd_ = hWnd;
if(!lpD3D)
lpD3D=Direct3DCreate9(D3D_SDK_VERSION);
if(!lpD3D)
{
MessageBox (NULL, "Failed Direct3DCreate9",
"WinFFE startup error", MB_OK | MB_ICONWARNING);
return false;
}
D3DDISPLAYMODE d3ddm;
if(FAILED(lpD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&d3ddm)))
{
MessageBox (NULL, "Failed GetAdapterDisplayMode",
"WinFFE startup error", MB_OK | MB_ICONWARNING);
return false;
}
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory(&d3dpp, sizeof(d3dpp));
if (mode&RENDER_WINDOWED) {
d3dpp.Windowed = true;
d3dpp.SwapEffect = D3DSWAPEFFECT_COPY ;
d3dpp.BackBufferFormat = d3ddm.Format;
} else {
d3dpp.Windowed = false;
d3dpp.SwapEffect = D3DSWAPEFFECT_COPY;
d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8;
d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
d3dpp.BackBufferWidth = xScr;
d3dpp.BackBufferHeight = yScr;
d3dpp.BackBufferCount = 1;
d3dpp.FullScreen_RefreshRateInHz = RefreshRateInHz;
//d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
}
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;
if(FAILED(lpD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED, &d3dpp, &lpD3DDevice)))
{
if(FAILED(lpD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED, &d3dpp, &lpD3DDevice)))
{
if(FAILED(lpD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_REF, hWnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED, &d3dpp, &lpD3DDevice))) {
MessageBox (NULL, "Failed CreateDevice",
"WinFFE startup error", MB_OK | MB_ICONWARNING);
return false;
}
}
}
for(unsigned int i = 0; i < vertexDeclarations.size(); ++i)
lpD3DDevice->CreateVertexDeclaration(vertexDeclarations[i].second, vertexDeclarations[i].first);
return true;
}
int RenderSystem::BeginScene()
{
HRESULT hr = lpD3DDevice->BeginScene();
return hr;
}
int RenderSystem::EndScene()
{
HRESULT hr = lpD3DDevice->EndScene();
if(hr != D3D_OK)
return hr;
hr=lpD3DDevice->Present(NULL,NULL,hWnd_,NULL);
return hr;
}
void* RenderSystem::LockVertexBuffer(sVertexBuffer &vb,int vertexNum, int size,bool readonly)
{
void *p=0;
assert(size>0);
vb.vb->Lock(vertexNum*vb.vertexSize,size,&p,(readonly?D3DLOCK_READONLY:0));
return p;
}
void RenderSystem::UnlockVertexBuffer(sVertexBuffer &vb)
{
vb.vb->Unlock();
}
HRESULT RenderSystem::SetRenderState(D3DRENDERSTATETYPE State,DWORD Value)
{
if(renderStates[State]!=Value)
return lpD3DDevice->SetRenderState(State,renderStates[State]=Value);
return D3D_OK;
}
DWORD RenderSystem::GetRenderState(D3DRENDERSTATETYPE State)
{
return renderStates[State];
}
void RenderSystem::SetVertexDeclaration(IDirect3DVertexDeclaration9* declaration)
{
if(declaration != currentDeclaration)
{
HRESULT hr = lpD3DDevice->SetVertexDeclaration(currentDeclaration = declaration);
assert(hr==D3D_OK);
}
}
IDirect3DVertexDeclaration9* RenderSystem::GetVertexDeclaration()
{
return currentDeclaration;
}
void RenderSystem::SetVertexDeclaration(sVertexBuffer& vb)
{
SetVertexDeclaration(vb.declaration);
}
inline void RenderSystem::SetIndices(LPDIRECT3DINDEXBUFFER9 indexBuffer)
{
if(indexBuffer != currentIndexBuffer)
{
currentIndexBuffer = indexBuffer;
HRESULT hr = lpD3DDevice->SetIndices(indexBuffer);
assert(hr==D3D_OK);
}
}
inline void RenderSystem::SetIndices(sIndexBuffer& indexBuffer)
{
SetIndices(indexBuffer.ib);
}
void RenderSystem::SetStreamSource(sVertexBuffer& vb)
{
HRESULT hr = lpD3DDevice->SetStreamSource(0,vb.vb,0,vb.vertexSize);
assert(hr==D3D_OK);
}
void RenderSystem::DrawIndexedPrimitive(sVertexBuffer& vb, int offestVertex, int nVertex, sIndexBuffer& ib, int offsetPolygon, int nPolygon)
{
SetVertexDeclaration(vb);
SetIndices(ib);
SetStreamSource(vb);
HRESULT hr = lpD3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,offestVertex,nVertex,3*offsetPolygon,nPolygon);
assert(hr== D3D_OK);
}
void RenderSystem::CreateVertexDeclaration(D3DVERTEXELEMENT9* pVertexElements,IDirect3DVertexDeclaration9** ppDecl)
{
HRESULT hr = lpD3DDevice->CreateVertexDeclaration(pVertexElements,ppDecl);
assert(hr==D3D_OK);
}
int RenderSystem::GetSizeFromDeclaration(IDirect3DVertexDeclaration9* declaration)
{
if(!declaration)
return 0;
D3DVERTEXELEMENT9 elements[256];
memset(elements, 0, sizeof(elements));
unsigned int elementsCount = 0;
declaration->GetDeclaration(elements, &elementsCount);
return D3DXGetDeclVertexSize(&elements[0],0);
}
void RenderSystem::CreateVertexBuffer(sVertexBuffer& vb, int numVertex, IDirect3DVertexDeclaration9* declaration)
{
int size = GetSizeFromDeclaration(declaration);
vb.vertexSize = size;
vb.declaration = declaration;
HRESULT hr = lpD3DDevice->CreateVertexBuffer(numVertex*size,0,0,D3DPOOL_MANAGED,&vb.vb,NULL);
assert(hr==D3D_OK);
}
void RenderSystem::CreateIndexBuffer(sIndexBuffer& ib,int NumberPolygon)
{
lpD3DDevice->CreateIndexBuffer(NumberPolygon*(3*sizeof(WORD)),D3DUSAGE_WRITEONLY,D3DFMT_INDEX16,D3DPOOL_MANAGED,&ib.ib,NULL);
}
void RenderSystem::RegisterVertexDeclaration(IDirect3DVertexDeclaration9*& declaration, D3DVERTEXELEMENT9* elements)
{
//int old_size = vertexDeclarations.size();
vertexDeclarations.push_back(std::make_pair(&declaration, elements));
}
| [
"dreamonzzz@a43015ce-51b6-2c96-052f-f15b0ecaca65"
] | [
[
[
1,
207
]
]
] |
93b4a76d91346fd90d3798f427df118fe4df56f9 | 842997c28ef03f8deb3422d0bb123c707732a252 | /src/uslscore/USFilename.h | 67a9c264f8bfe108bd5ae46ad0e08f884a820325 | [] | no_license | bjorn/moai-beta | e31f600a3456c20fba683b8e39b11804ac88d202 | 2f06a454d4d94939dc3937367208222735dd164f | refs/heads/master | 2021-01-17T11:46:46.018377 | 2011-06-10T07:33:55 | 2011-06-10T07:33:55 | 1,837,561 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,821 | h | // Copyright (c) 2010-2011 Zipline Games, Inc. All Rights Reserved.
// http://getmoai.com
#ifndef FILENAME_H
#define FILENAME_H
#include <uslscore/STLString.h>
//================================================================//
// USFilename
//================================================================//
class USFilename {
private:
//----------------------------------------------------------------//
char* Normalize ( cc8* path );
public:
int mLength;
int mNameIdx;
int mExtIdx;
char mBuffer [ PATH_MAX ];
//----------------------------------------------------------------//
void Append ( char c );
void Append ( cc8* str );
char* Bless ( cc8* path );
void Clear ();
u32 ComparePath ( USFilename& filename );
char* ConvertToPath ();
void Copy ( USFilename& filename );
char* Expand ( cc8* filename );
char* ExpandPath ( cc8* filename );
char* GetCurrentPath ();
char* GetExt ( cc8* filename );
char* GetName ( cc8* filename );
char* GetNameNoExt ( cc8* filename );
char* GetPath ( cc8* filename );
char* GetRelativePath ( cc8* path );
USFilename ();
~USFilename ();
};
//================================================================//
// USPathOps
//================================================================//
namespace USPathOps {
//----------------------------------------------------------------//
char Bless ( char c );
STLString Bless ( cc8* path );
u32 ComparePaths ( cc8* p0, cc8* p1 );
STLString GetExt ( cc8* filename );
STLString GetName ( cc8* filename );
STLString GetNameNoExt ( cc8* filename );
STLString GetPath ( cc8* filename, bool expand = false );
bool IsSeparator ( const char c );
}
#endif
| [
"[email protected]"
] | [
[
[
1,
61
]
]
] |
19473d5f0956fb43a9af1e00d38755f13aa68152 | ce148b48b453a58d84664ec979eb64e4813a83c8 | /Faeried/SpinBoxDelegate.cpp | 799577ab213541e4e3ee7174fab1be7a7d252921 | [] | no_license | theyoprst/Faeried | e8945f8cb21c317eeeb1b05f0d12b297b63621fe | d20bd990e7f91c8c03857d81e08b8f7f2dee3541 | refs/heads/master | 2020-04-09T16:04:47.472907 | 2011-02-21T16:38:02 | 2011-02-21T16:38:02 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,137 | cpp | #include "SpinBoxDelegate.h"
#include <QtGui/QSpinBox>
SpinBoxDelegate::SpinBoxDelegate(int min, int max)
: QItemDelegate(NULL)
, _min(min)
, _max(max)
{
}
QWidget *SpinBoxDelegate::createEditor(QWidget *parent,
const QStyleOptionViewItem &/* option */,
const QModelIndex &/* index */) const
{
QSpinBox *editor = new QSpinBox(parent);
editor->setMinimum(_min);
editor->setMaximum(_max);
return editor;
}
void SpinBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const {
int value = index.model()->data(index, Qt::EditRole).toInt();
QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
spinBox->setValue(value);
}
void SpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const {
QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
spinBox->interpretText();
int value = spinBox->value();
model->setData(index, value, Qt::EditRole);
}
void SpinBoxDelegate::updateEditorGeometry(QWidget *editor,
const QStyleOptionViewItem &option,
const QModelIndex &/* index */) const
{
editor->setGeometry(option.rect);
}
| [
"[email protected]"
] | [
[
[
1,
40
]
]
] |
4c148d684b37760f21a8383247f5b40bbb2e8aa1 | dc4b6ab7b120262779e29d8b2d96109517f35551 | /Dialog/FunctionPage.cpp | c2d2fce5240e056f608cd49cc6d86a401e3ca664 | [] | no_license | cnsuhao/wtlhelper9 | 92daef29b61f95f44a10e3277d8835c2dd620616 | 681df3a014fc71597e9380b0a60bd3cd23e22efe | refs/heads/master | 2021-07-17T19:59:07.143192 | 2009-05-18T14:24:48 | 2009-05-18T14:24:48 | 108,361,858 | 0 | 1 | null | null | null | null | WINDOWS-1251 | C++ | false | false | 31,717 | cpp | ////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2004 Sergey Solozhentsev
// Author: Sergey Solozhentsev e-mail: [email protected]
// Product: WTL Helper
// File: FunctionPage.cpp
// Created: 16.11.2004 8:55
//
// Using this software in commercial applications requires an author
// permission. The permission will be granted to everyone excluding the cases
// when someone simply tries to resell the code.
// This file may be redistributed by any means PROVIDING it is not sold for
// profit without the authors written consent, and providing that this notice
// and the authors name is included.
// This file is provided "as is" with no expressed or implied warranty. The
// author accepts no liability if it causes any damage to you or your computer
// whatsoever.
//
////////////////////////////////////////////////////////////////////////////////
// FunctionPage.cpp : Implementation of CFunctionPage
#include "stdafx.h"
#include "../VSElements.h"
#include "FunctionPage.h"
#include "HandlerDlg.h"
#include "HandlerIDDlg.h"
#include "AddMemberVar.h"
#include ".\functionpage.h"
#include "../InsertPoint.h"
#include "AddAltMapDlg.h"
LPCTSTR RegPath = _T("Software\\Salos\\WtlHelper");
LPCTSTR FunctionName = _T("Messages");
void CFunctionPage::CreateControls()
{
m_ClassCombo.Attach(GetDlgItem(IDC_COMBO_CLASSES));
CRect r1;
HFONT hFont = GetFont();
m_ClassCombo.GetWindowRect(&r1);
ScreenToClient(&r1);
m_SplitMessages.Create(m_hWnd, rcDefault, NULL,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
m_SplitMessages.SetSplitterExtendedStyle(0);
m_MessagesContainer.Create(m_SplitMessages, _T("Messages"));
m_MessagesContainer.SetPaneContainerExtendedStyle(PANECNT_NOCLOSEBUTTON, PANECNT_NOCLOSEBUTTON);
m_Messages.Create(m_MessagesContainer, NULL, NULL, WS_VISIBLE | WS_CHILD | TVS_HASBUTTONS |
TVS_HASLINES | WS_TABSTOP, WS_EX_CLIENTEDGE, IDC_MESSAGES);
m_Messages.SetFont(hFont);
m_MessagesContainer.SetClient(m_Messages);
m_SplitFunctions.Create(m_SplitMessages, rcDefault, NULL,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
m_SplitMessages.SetSplitterExtendedStyle(0);
m_HandlerContaner.Create(m_SplitFunctions, _T("Handlers"));
m_HandlerContaner.SetPaneContainerExtendedStyle(PANECNT_NOCLOSEBUTTON, PANECNT_NOCLOSEBUTTON);
m_Handlers.Create(m_HandlerContaner, NULL, NULL, 0, 0, IDC_HANDLERS_LIST);
m_Handlers.SendMessage(CCM_SETVERSION, 5);
m_Handlers.SetFont(hFont);
m_HandlerContaner.SetClient(m_Handlers);
m_FunctionContainer.Create(m_SplitFunctions, _T("Functions"));
m_FunctionContainer.SetPaneContainerExtendedStyle(PANECNT_NOCLOSEBUTTON, PANECNT_NOCLOSEBUTTON);
m_Functions.Create(m_FunctionContainer, NULL, NULL, WS_CHILD | WS_VISIBLE | LBS_SORT |
LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP | LBS_NOTIFY | LBS_WANTKEYBOARDINPUT, WS_EX_CLIENTEDGE, IDC_FUNCTION_LIST);
m_Functions.SetFont(hFont);
m_FunctionContainer.SetClient(m_Functions);
m_SplitFunctions.SetSplitterPanes(m_HandlerContaner, m_FunctionContainer);
m_SplitMessages.SetSplitterPanes(m_MessagesContainer, m_SplitFunctions);
}
void CFunctionPage::FillTreeView(HTREEITEM hRootItem, MessageStruct* pMes)
{
if ((int)_AtlModule.m_eWTLVersion < eWTL75 && pMes->Type & REFLECTION_MESSAGE)
return;
TVITEM* tvi;
TVINSERTSTRUCT tvis;
ZeroMemory(&tvis, sizeof(tvis));
tvi = &tvis.item;
tvi->mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
tvi->lParam = (LPARAM)pMes;
CString Name = pMes->Message;
LPTSTR pName = Name.LockBuffer();
tvi->pszText = pName;
tvi->cchTextMax = Name.GetLength() + 1;
int Type = pMes->Type & TYPE_MASK;
if (pMes->IconIndex == -1)
{
if (Type == ROOT_PLACE)
{
tvi->iImage = 0;
tvi->iSelectedImage = 0;
}
else
{
tvi->iImage = 2;
tvi->iSelectedImage = 2;
}
}
else
{
tvi->iSelectedImage = tvi->iImage = pMes->IconIndex;
}
tvi->cChildren = 0;
tvis.hParent = hRootItem;
int Flags = pMes->Type & FLAGS_MASK;
if (Flags & CUSTOM_MESSAGE)
{
tvis.hInsertAfter = TVI_LAST;
}
else
{
tvis.hInsertAfter = TVI_SORT;
}
HTREEITEM NewItem = m_Messages.InsertItem(&tvis);
Name.UnlockBuffer();
if (Type == ROOT_PLACE)
{
for (size_t i = 0; i < pMes->Children.GetCount(); i++)
{
FillTreeView(NewItem, pMes->Children[i]);
}
}
}
void CFunctionPage::FillTreeView()
{
MessageStruct* pMes = CMessageManager::m_sHandlerManager.GetRootMessage();
ATLASSERT(pMes);
if (pMes) {
FillTreeView(NULL, pMes);
}
}
CString CFunctionPage::LoadToolTip(int ID)
{
CString str;
str.LoadString(ID);
return str;
}
void CFunctionPage::LoadSettings()
{
CRegArchive RegSettings;
if (RegSettings.Open(HKEY_CURRENT_USER, RegPath, false))
{
if (!CSettings<CFunctionPage>::LoadSettings(RegSettings, FunctionName))
{
RegSettings.Close();
return;
}
RegSettings.Close();
}
}
void CFunctionPage::SaveSettings()
{
if (m_bShowWindow)
{
m_WindowSettings.m_FuncSplitPos = m_SplitFunctions.GetSplitterPos();
m_WindowSettings.m_MesSpitPos = m_SplitMessages.GetSplitterPos();
m_WindowSettings.m_HandlerHeaderWidth = m_Handlers.GetColumnWidth(0);
CRegArchive RegArchive;
if (RegArchive.Open(HKEY_CURRENT_USER, RegPath, true))
{
m_WindowSettings.SaveSettings(RegArchive, FunctionName);
RegArchive.Close();
}
}
}
void CFunctionPage::LoadGeneralResources()
{
m_GeneralResources.RemoveAll();
m_pResManager->GetMenuIds(m_GeneralResources);
m_pResManager->GetAcceleratorIds(m_GeneralResources);
m_pResManager->GetToolbarIds(m_GeneralResources);
//сортировка
SortStringArray(m_GeneralResources);
//удаление повторяющихся идентификаторов
CString PrevWord;
for (int i = (int)m_GeneralResources.GetCount() - 1; i >= 0; i--)
{
if (m_GeneralResources[i] == PrevWord)
{
m_GeneralResources.RemoveAt(i);
}
else
{
PrevWord = m_GeneralResources[i];
}
}
}
TBBUTTON CFunctionPage::s_FuncButtons[FUNC_BUTTON_COUNT];
void CFunctionPage::FillFuncButtons()
{
memset(s_FuncButtons, 0, FUNC_BUTTON_COUNT * sizeof(TBBUTTON));
s_FuncButtons[0].idCommand = ID_ADD_HANDLER;
s_FuncButtons[0].iBitmap = 0;
s_FuncButtons[0].fsState = TBSTATE_ENABLED;
s_FuncButtons[0].fsStyle = TBSTYLE_BUTTON;
s_FuncButtons[1].idCommand = ID_DELETE_HANDLER;
s_FuncButtons[1].iBitmap = 1;
s_FuncButtons[1].fsState = TBSTATE_ENABLED;
s_FuncButtons[1].fsStyle = TBSTYLE_BUTTON;
s_FuncButtons[2].idCommand = ID_SEPARATOR;
s_FuncButtons[2].iBitmap = -1;
s_FuncButtons[2].fsStyle = TBSTYLE_SEP;
s_FuncButtons[3].idCommand = ID_ADD_FUNC;
s_FuncButtons[3].iBitmap = 2;
s_FuncButtons[3].fsState = TBSTATE_ENABLED;
s_FuncButtons[3].fsStyle = TBSTYLE_BUTTON;
s_FuncButtons[4].idCommand = ID_DELETE_FUNC;
s_FuncButtons[4].iBitmap = 3;
s_FuncButtons[4].fsState = TBSTATE_ENABLED;
s_FuncButtons[4].fsStyle = TBSTYLE_BUTTON;
s_FuncButtons[5].idCommand = ID_ADD_SPEC_FUNC;
s_FuncButtons[5].iBitmap = 4;
s_FuncButtons[5].fsState = TBSTATE_ENABLED;
s_FuncButtons[5].fsStyle = BTNS_WHOLEDROPDOWN;
s_FuncButtons[6].idCommand = ID_SEPARATOR;
s_FuncButtons[6].iBitmap = -1;
s_FuncButtons[6].fsStyle = TBSTYLE_SEP;
s_FuncButtons[7].idCommand = ID_ADD_MAP;
s_FuncButtons[7].iBitmap = 5;
s_FuncButtons[7].fsState = TBSTATE_ENABLED;
s_FuncButtons[7].fsStyle = TBSTYLE_BUTTON;
s_FuncButtons[8].idCommand = ID_DELETE_MAP;
s_FuncButtons[8].iBitmap = 6;
s_FuncButtons[8].fsState = TBSTATE_ENABLED;
s_FuncButtons[8].fsStyle = TBSTYLE_BUTTON;
}
void CFunctionPage::UpdateToolBar(HWND hWndToolBar)
{
CToolBarCtrl ToolBar(hWndToolBar);
ToolBar.SetImageList(m_ToolbarImgList);
int Count = ToolBar.GetButtonCount();
int i;
int nSeps = 0;
for (i = 0; i < min(Count, FUNC_BUTTON_COUNT); i++)
{
TBBUTTONINFO tb;
tb.cbSize = sizeof(tb);
tb.dwMask = 0;
if (s_FuncButtons[i].fsStyle != TBSTYLE_SEP)
{
tb.dwMask = TBIF_IMAGE;
tb.iImage = s_FuncButtons[i].iBitmap;
}
tb.fsStyle = s_FuncButtons[i].fsStyle;
tb.dwMask |= TBIF_STYLE | TBIF_BYINDEX | TBIF_COMMAND;
tb.idCommand = s_FuncButtons[i].idCommand;
ToolBar.SetButtonInfo(i, &tb);
}
if (Count < FUNC_BUTTON_COUNT)
{
int Delta = FUNC_BUTTON_COUNT - Count;
ToolBar.AddButtons(Delta, &s_FuncButtons[Count]);
}
if (Count > FUNC_BUTTON_COUNT)
{
for (i = Count - 1; i >= FUNC_BUTTON_COUNT; i--)
{
ToolBar.DeleteButton(i);
}
}
ToolBar.Detach();
}
LRESULT CFunctionPage::OnSetActive(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
int iCurSel = m_ClassCombo.GetCurSel();
if (iCurSel != *m_piCurrentClass)
{
m_ClassCombo.SetCurSel(*m_piCurrentClass);
OnCbnSelchangeComboClass(CBN_SELCHANGE, 0, NULL, bHandled);
}
UpdateToolBar((HWND)wParam);
return 0;
}
void CFunctionPage::SetModified(BOOL bModified /* = TRUE */)
{
GetParent().GetParent().SendMessage(WTLH_SETMODIFIED, bModified);
}
LRESULT CFunctionPage::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
bHandled = TRUE;
START_PROFILE(FuncInit);
m_MessageMaps.Attach(GetDlgItem(IDC_COMBO_MESSAGEMAP));
m_MessageManager.Init(m_hWnd, m_pResManager, &m_GeneralResources);
m_FunctionManager.Init(m_hWnd);
CreateControls();
CImageList ImageList;
ImageList.Create(16, 16, ILC_COLOR24 | ILC_MASK, 3, 2);
ImageList.AddIcon(LoadIcon(_AtlModule.GetResourceInstance(), MAKEINTRESOURCE(IDI_ICON_CLOSE)));
ImageList.AddIcon(LoadIcon(_AtlModule.GetResourceInstance(), MAKEINTRESOURCE(IDI_ICON_OPEN)));
ImageList.AddIcon(LoadIcon(_AtlModule.GetResourceInstance(), MAKEINTRESOURCE(IDI_ICON_MESSAGE)));
ImageList.Add(LoadBitmap(_AtlModule.GetResourceInstance(), MAKEINTRESOURCE(IDB_BITMAP_ICONS)), 0x7C00FF);
m_Messages.SetImageList(ImageList.Detach(), TVSIL_NORMAL);
FillTreeView();
//построение дерева
HTREEITEM hRoot = m_Messages.GetRootItem();
m_Messages.Expand(hRoot);
HTREEITEM hRootChild = m_Messages.GetChildItem(hRoot);
while(hRootChild)
{
m_Messages.Expand(hRootChild);
hRootChild = m_Messages.GetNextSiblingItem(hRootChild);
}
CRect r;
m_Handlers.GetWindowRect(r);
int width = m_WindowSettings.m_HandlerHeaderWidth; //(r.Width() * 5) / 11;
m_Handlers.InsertColumn(0, _T("Handler"), LVCFMT_LEFT, width, 0);
m_Handlers.InsertColumn(1, _T("Message"), LVCFMT_LEFT, r.Width() - width-5, 1);
m_Handlers.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);
if (m_pClassVector->GetCount())
{
int iCurClass = 0;
for (size_t i = 0; i < m_pClassVector->GetCount(); i++)
{
int iPos = m_ClassCombo.AddString((*m_pClassVector)[i]->Name);
m_ClassCombo.SetItemData(iPos, i);
if (i == *m_piCurrentClass)
iCurClass = iPos;
}
m_ClassCombo.SetCurSel(iCurClass);
UpdateClass();
}
LoadGeneralResources();
m_ToolbarImgList.CreateFromImage(IDB_BITMAP_MESSAGE, 18, 6, RGB(197, 200,201), IMAGE_BITMAP, LR_CREATEDIBSECTION);
InitToolTip();
m_ToolTip.SetMaxTipWidth(400);
if ((int)_AtlModule.m_eWTLVersion < eWTL75)
{
GetDlgItem(IDC_CHECK_REFLECT_EX).ShowWindow(SW_HIDE);
}
m_SplitMessages.SetFocus();
END_PROFILE(FuncInit, _T("CFunctionPage::OnInitDialog"));
return 0;
}
LRESULT CFunctionPage::OnTvnItemExpanded(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
{
NMTREEVIEW* pnmtv = (NMTREEVIEW*)pnmh;
MessageStruct* pMes = (MessageStruct*)m_Messages.GetItemData(pnmtv->itemNew.hItem);
if (pMes->IconIndex == -1)
{
if (pnmtv->action == TVE_COLLAPSE)
{
m_Messages.SetItemImage(pnmtv->itemNew.hItem, 0, 0);
}
if (pnmtv->action == TVE_EXPAND)
{
m_Messages.SetItemImage(pnmtv->itemNew.hItem, 1, 1);
}
}
return 1;
}
LRESULT CFunctionPage::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
if (wParam == SIZE_RESTORED)
{
CRect rc, rc2;
CWindow wnd = GetDlgItem(IDC_COMBO_CLASSES);
wnd.GetWindowRect(rc);
ScreenToClient(rc);
CSize NewSize(LOWORD(lParam), HIWORD(lParam));
CRect CheckRc(0, 0, 1,12);
MapDialogRect(CheckRc);
rc2.left = 0;
rc2.right = NewSize.cx;
rc2.top = rc.bottom + CheckRc.Height();
rc2.bottom = NewSize.cy;
m_SplitMessages.MoveWindow(rc2);
if (!m_bShowWindow && lParam)
{
m_bShowWindow = true;
m_SplitMessages.SetSplitterPos(m_WindowSettings.m_MesSpitPos);
m_SplitFunctions.SetSplitterPos(m_WindowSettings.m_FuncSplitPos);
}
}
return 0;
}
LRESULT CFunctionPage::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
SaveSettings();
m_Messages.DeleteAllItems();
bHandled = TRUE;
return 1;
}
LRESULT CFunctionPage::OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
m_Messages.SetFocus();
return 0;
}
LRESULT CFunctionPage::OnBnClickedButtonAddFunc(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
if (wNotifyCode == BN_CLICKED)
{
VSFunction* pFunc = m_FunctionManager.AddFunction();
if (pFunc)
{
int k1 = m_Functions.AddString(pFunc->Name);
m_Functions.SetItemDataPtr(k1, pFunc);
}
}
bHandled = TRUE;
return 1;
}
LRESULT CFunctionPage::OnBnClickedButtonDelFunc(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
bHandled = TRUE;
if (wNotifyCode == BN_CLICKED)
{
int n = m_Functions.GetCurSel();
if (n == -1)
{
MessageBox(_T("No selected Items"));
return 1;
}
if (MessageBox(_T("Are you realy want to delete function"), _T(""), MB_YESNO) == IDYES)
{
VSFunction* pListEntry = (VSFunction*)m_Functions.GetItemDataPtr(n);
if (m_FunctionManager.DeleteFunction(pListEntry))
{
m_Functions.DeleteString(n);
SetModified(TRUE);
}
}
}
return 1;
}
//////////////////////////////////////////////////////////////////////////
//Получаем выбранное сообщение, проверяем нет ли его уже в карте.
//После этого создаем новый обьект VSMapEntry и VSFunction.
//Указатели на них копируются и в список функций (MapEntries) и в массив
//добавленных элементов для данного класса. При реальном добавлении
//просто получаем нужные обекты среды в уже созданные обьекты
//////////////////////////////////////////////////////////////////////////
LRESULT CFunctionPage::OnBnClickedButtonAddHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
bHandled = FALSE;
if (wNotifyCode == BN_CLICKED)
{
HTREEITEM hItem = m_Messages.GetSelectedItem();
if (!hItem)
return 1;
MessageStruct* pMes = (MessageStruct*) m_Messages.GetItemData(hItem);
if (!pMes)
{
MessageBox(_T("No selected items"));
return 1;
}
if ((pMes->Type & TYPE_MASK) == ROOT_PLACE)
return 1;
if (CMessageManager::m_sHandlerManager.IsHandlerExist(pMes, m_pMessageMap))
{
MessageBox(_T("Handler for this message allready exists"));
return 1;
}
if (!m_pMessageMap)
{
if (!m_MessageManager.AddMessageMap())
return 1;
m_pMessageMap = (VSMessageMap*)(*m_pClassVector)[*m_piCurrentClass]->GetMap(CString(_T("MSG")));
}
HandlerStruct Handler;
switch(pMes->Type & TYPE_MASK)
{
case CUSTOM_MESSAGE_HANDLER:
case STD_MESSAGE_HANDLER:
if (m_MessageManager.InsertWindowsMessageHandler(pMes, Handler))
{
AddHandler(CMessageManager::m_sHandlerManager.AddHandler(&Handler), true);
SetModified(TRUE);
}
break;
case STD_COMMAND_HANDLER:
case CUSTOM_COMMAND_HANDLER:
if (m_MessageManager.InsertCommandMessageHandler(pMes, Handler))
{
AddHandler(CMessageManager::m_sHandlerManager.AddHandler(&Handler), true);
SetModified(TRUE);
}
break;
case STD_NOTIFY_HANDLER:
case CUSTOM_NOTIFY_HANDLER:
if (m_MessageManager.InsertNotifyMessageHandler(pMes, Handler))
{
AddHandler(CMessageManager::m_sHandlerManager.AddHandler(&Handler), true);
SetModified(TRUE);
}
break;
case CUSTOM_NOTIFY_REFLECTION_HANDLER:
case CUSTOM_COMMAND_REFLECTION_HANDLER:
case CUSTOM_REFLECTION_HANDLER:
if (m_MessageManager.InsertReflectionHandler(pMes, Handler))
{
AddHandler(CMessageManager::m_sHandlerManager.AddHandler(&Handler), true);
SetModified(TRUE);
}
break;
default:
ATLASSERT(0);
}
}
return 1;
}
LRESULT CFunctionPage::OnBnClickedButtonDelHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
bHandled = TRUE;
if (wNotifyCode == BN_CLICKED)
{
int n = m_Handlers.GetSelectedIndex();
if (n == -1)
{
MessageBox(_T("No selected items"));
return 1;
}
if (MessageBox(_T("Are you realy want to delete handler"), _T(""), MB_YESNO) == IDYES)
{
HandlerStruct* pHandler = (HandlerStruct*)m_Handlers.GetItemData(n);
if (m_MessageManager.DeleteHandler(pHandler))
{
m_Handlers.DeleteItem(n);
SetModified(TRUE);
}
}
}
return 1;
}
LRESULT CFunctionPage::OnCbnSelchangeComboClass(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
if (wNotifyCode == CBN_SELCHANGE)
{
int iCurSel = m_ClassCombo.GetCurSel();
if (iCurSel != -1)
{
(*m_piCurrentClass) = (int)m_ClassCombo.GetItemData(iCurSel);
UpdateClass();
}
}
bHandled = TRUE;
return 1;
}
LRESULT CFunctionPage::OnCbnSelchangeComboMessagemap(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
int iSel = m_MessageMaps.GetCurSel();
VSClass* pClass = (*m_pClassVector)[*m_piCurrentClass];
VSMessageMap* pRootMap = (VSMessageMap*)pClass->GetMap(CString(_T("MSG")));
if (!pRootMap)
return 0;
if (iSel == 0)
{
m_pMessageMap = pRootMap;
m_MessageManager.SetMessageMap(m_pMessageMap);
}
else
{
if (pRootMap->AltMaps.GetCount())
{
if (iSel - 1 < (int)pRootMap->AltMaps.GetCount())
{
m_pMessageMap = pRootMap->AltMaps[iSel - 1];
m_MessageManager.SetMessageMap(m_pMessageMap);
}
}
if (iSel == pRootMap->AltMaps.GetCount() + 1)
{
if (m_MessageManager.InsertAltMap())
{
m_pMessageMap = pRootMap->AltMaps[iSel - 1];
m_MessageManager.SetMessageMap(m_pMessageMap);
m_MessageMaps.InsertString(m_MessageMaps.GetCount() - 1, m_pMessageMap->Name);
m_MessageMaps.SetCurSel(iSel);
}
else
{
m_MessageMaps.SetCurSel(0);
m_pMessageMap = pRootMap;
m_MessageManager.SetMessageMap(m_pMessageMap);
}
}
}
m_Handlers.DeleteAllItems();
bool bForward = false, bReflect = false;
for (size_t j = 0; j != m_pMessageMap->MapEntries.GetCount(); j++)
{
if (m_pMessageMap->MapEntries[j]->Name == _T("FORWARD_NOTIFICATIONS"))
{
bForward = true;
continue;
}
if (m_pMessageMap->MapEntries[j]->Name == _T("REFLECT_NOTIFICATIONS"))
{
bReflect = true;
continue;
}
HandlerStruct* pHandler = CMessageManager::m_sHandlerManager.GetHandler(m_pMessageMap->MapEntries[j]);
if (pHandler)
AddHandler(pHandler);
}
if (bForward)
{
GetDlgItem(IDC_CHECK_FORWARD).SendMessage(BM_SETCHECK, BST_CHECKED);
}
else
{
GetDlgItem(IDC_CHECK_FORWARD).SendMessage(BM_SETCHECK, BST_UNCHECKED);
}
if (bReflect)
{
GetDlgItem(IDC_CHECK_REFLECT).SendMessage(BM_SETCHECK, BST_CHECKED);
}
else
{
GetDlgItem(IDC_CHECK_REFLECT).SendMessage(BM_SETCHECK, BST_UNCHECKED);
}
return 0;
}
LRESULT CFunctionPage::OnLbnDblclkMessagesList(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
{
return OnBnClickedButtonAddHandler(BN_CLICKED, 0, 0, bHandled);
}
LRESULT CFunctionPage::OnAddMap(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
if (m_pMessageMap)
{
MessageBox(_T("Message map already exists!"), NULL, MB_OK |MB_ICONINFORMATION);
}
else
{
m_MessageManager.AddMessageMap();
}
return 0;
}
LRESULT CFunctionPage::OnDeleteMap(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
int Res = MessageBox(_T("Are you realy want to delete message map?"), NULL, MB_YESNO | MB_ICONQUESTION);
if (Res == IDYES)
{
m_MessageManager.DeleteMap(m_pMessageMap);
UpdateClass();
}
return 0;
}
bool CFunctionPage::GetModify()
{
for (size_t i = 0; i < (*m_pModifications).GetCount(); i++)
{
if ((*m_pModifications)[i].InsertPoints.GetCount() || (*m_pModifications)[i].DeletePoint.GetCount())
return true;
}
return false;
}
void CFunctionPage::AddHandler(HandlerStruct* pHandler, bool bNew /* = false */)
{
ATLASSERT(pHandler);
if (!pHandler)
return;
int iNext = m_Handlers.GetItemCount();
CString FirstStr, SecondStr;
FirstStr = pHandler->HandlerName;
COLORREF BackColor;
COLORREF TextColor;
if (pHandler->Type & (HANDLER_TYPE_MESSAGE | HANDLER_TYPE_CRACK_MESSAGE))
{
SecondStr = pHandler->Message;
BackColor = m_clWindowsBack;
TextColor = m_clWindowsText;
}
else
{
if (pHandler->Type & HANDLER_TYPE_COMMAND_MESSAGE)
{
BackColor = m_clCommandBack;
TextColor = m_clCommandText;
}
if (pHandler->Type & HANDLER_TYPE_NOTIFY_MESSAGE)
{
BackColor = m_clNotifyBack;
TextColor = m_clNotifyText;
}
if (pHandler->Type & HANDLER_REFLECTION_MESSAGE ||
pHandler->Type & HANDLER_REFLECTION_COMMAND ||
pHandler->Type & HANDLER_REFLECTION_NOTIFY)
{
BackColor = m_clReflectBack;
TextColor = m_clReflectText;
}
CString ID;
if (pHandler->Type & HANDLER_RANGE)
{
ID.Format(_T("[%s .. %s]"), pHandler->FirstId, pHandler->LastId);
}
else
{
if (pHandler->Type & HANDLER_ID)
ID = pHandler->FirstId;
if (pHandler->Type & HANDLER_HWND)
ID = pHandler->HWND;
}
if (ID.IsEmpty())
{
if (!pHandler->Code.IsEmpty())
{
SecondStr = pHandler->Code + _T(" - ") + pHandler->Message;
}
else
{
SecondStr = pHandler->Message;
}
}
else
{
if (pHandler->Code.IsEmpty())
{
if (!pHandler->Message.IsEmpty())
SecondStr = ID + _T(" - ") + pHandler->Message;
else
SecondStr = ID;
}
else
{
SecondStr = ID + _T(" - ") + pHandler->Code;
}
}
}
int k1 = m_Handlers.InsertItem(LVIF_TEXT | LVIF_PARAM, iNext, FirstStr, 0, 0, 0, (LPARAM)pHandler);
m_Handlers.SetItem(k1 ,1, LVIF_TEXT, SecondStr, 0, 0, 0, 0);
MyCustomDrawStruct mds;
if (bNew)
{
mds.dwMask = MCDS_BACKCOLOR | MCDS_TEXTCOLOR | MCDS_STYLE;
mds.dwStyle = SLC_STYLE_ITALIC;
}
else
{
mds.dwMask = MCDS_BACKCOLOR | MCDS_TEXTCOLOR;
mds.dwStyle = 0;
}
mds.BackColor = BackColor;
mds.TextColor = TextColor;
m_Handlers.SetDrawStruct(k1, &mds);
}
void CFunctionPage::UpdateClass(void)
{
//save previous FORWARD_NOTIFICATIONS, REFLECT_NOTIFICATIONS[_EX] for class
if (m_pMessageMap)
UpdateForwardReflect();
m_Handlers.DeleteAllItems();
m_Functions.ResetContent();
m_MessageMaps.ResetContent();
m_HandlersMap.RemoveAll();
if ((*m_piCurrentClass) == -1)
return;
VSClass* pClass = (*m_pClassVector)[(*m_piCurrentClass)];
if (m_MessageManager.SetClass(pClass, &(*m_pModifications)[(*m_piCurrentClass)]))
{
SetModified(TRUE);
}
m_FunctionManager.SetClass(pClass, &(*m_pModifications)[(*m_piCurrentClass)]);
//добавление сообщений
m_pMessageMap = NULL;
m_pMessageMap = (VSMessageMap*)pClass->GetMap(CString(_T("MSG")));
if (m_pMessageMap)
{
m_MessageMaps.EnableWindow();
GetDlgItem(IDC_CHECK_FORWARD).EnableWindow();
GetDlgItem(IDC_CHECK_REFLECT).EnableWindow();
GetDlgItem(IDC_CHECK_DEF_HANDLER).EnableWindow();
m_MessageMaps.AddString(_T("Default"));
for (size_t j = 0; j != m_pMessageMap->MapEntries.GetCount(); j++)
{
HandlerStruct* pHandler = CMessageManager::m_sHandlerManager.AddMapEntry(m_pMessageMap->MapEntries[j]);
if (pHandler)
{
AddHandler(pHandler);
}
}
// check Forward notifications
if (CMessageManager::m_sHandlerManager.m_bForwardNotifications)
{
GetDlgItem(IDC_CHECK_FORWARD).SendMessage(BM_SETCHECK, BST_CHECKED);
}
else
{
GetDlgItem(IDC_CHECK_FORWARD).SendMessage(BM_SETCHECK, BST_UNCHECKED);
}
//check reflect notifications
if (CMessageManager::m_sHandlerManager.m_bReflectNotifications)
{
GetDlgItem(IDC_CHECK_REFLECT).SendMessage(BM_SETCHECK, BST_CHECKED);
GetDlgItem(IDC_CHECK_REFLECT_EX).EnableWindow();
if (CMessageManager::m_sHandlerManager.m_bReflectNotificationsEx)
{
GetDlgItem(IDC_CHECK_REFLECT_EX).SendMessage(BM_SETCHECK, BST_CHECKED);
}
else
{
GetDlgItem(IDC_CHECK_REFLECT_EX).SendMessage(BM_SETCHECK, BST_UNCHECKED);
}
}
else
{
GetDlgItem(IDC_CHECK_REFLECT).SendMessage(BM_SETCHECK, BST_UNCHECKED);
GetDlgItem(IDC_CHECK_REFLECT_EX).EnableWindow(FALSE);
GetDlgItem(IDC_CHECK_REFLECT_EX).SendMessage(BM_SETCHECK, BST_UNCHECKED);
}
//check default reflection handler
if (CMessageManager::m_sHandlerManager.m_bDefReflectHandler)
{
GetDlgItem(IDC_CHECK_DEF_HANDLER).SendMessage(BM_SETCHECK, BST_CHECKED);
}
else
{
GetDlgItem(IDC_CHECK_DEF_HANDLER).SendMessage(BM_SETCHECK, BST_UNCHECKED);
}
// fill message maps
for (size_t i = 0; i < m_pMessageMap->AltMaps.GetCount(); i++)
{
VSMessageMap* pAltMap = m_pMessageMap->AltMaps[i];
m_MessageMaps.AddString(pAltMap->Name);
for (size_t j = 0; j != pAltMap->MapEntries.GetCount(); j++)
{
CMessageManager::m_sHandlerManager.AddMapEntry(pAltMap->MapEntries[j]);
}
}
m_MessageMaps.AddString(_T("Create new ALT map"));
m_MessageMaps.SetCurSel(0);
}
else
{
m_MessageMaps.EnableWindow(FALSE);
GetDlgItem(IDC_CHECK_FORWARD).SendMessage(BM_SETCHECK, BST_UNCHECKED);
GetDlgItem(IDC_CHECK_FORWARD).EnableWindow(FALSE);
GetDlgItem(IDC_CHECK_REFLECT).SendMessage(BM_SETCHECK, BST_UNCHECKED);
GetDlgItem(IDC_CHECK_REFLECT).EnableWindow(FALSE);
GetDlgItem(IDC_CHECK_REFLECT_EX).SendMessage(BM_SETCHECK, BST_UNCHECKED);
GetDlgItem(IDC_CHECK_REFLECT_EX).EnableWindow(FALSE);
GetDlgItem(IDC_CHECK_DEF_HANDLER).SendMessage(BM_SETCHECK, BST_UNCHECKED);
GetDlgItem(IDC_CHECK_DEF_HANDLER).EnableWindow(FALSE);
}
//добавление функций
for (size_t i2 = 0; i2 != pClass->Functions.GetCount(); i2++)
{
if (!CMessageManager::m_sHandlerManager.IsHandler((int)i2))
{
int k1 = m_Functions.AddString((pClass->Functions[i2])->Name);
m_Functions.SetItemDataPtr(k1, pClass->Functions[i2]);
}
}
}
void CFunctionPage::UpdateForwardReflect()
{
CString Name;
Name = _T("FORWARD_NOTIFICATIONS");
int Res = (int)GetDlgItem(IDC_CHECK_FORWARD).SendMessage(BM_GETCHECK);
if (Res == BST_CHECKED)
{
if (!CMessageManager::m_sHandlerManager.m_bForwardNotifications)
m_MessageManager.AddForwardReflect(Name);
}
else
{
if (CMessageManager::m_sHandlerManager.m_bForwardNotifications)
m_MessageManager.DeleteForwardReflect(Name);
}
Name = _T("DEFAULT_REFLECTION_HANDLER");
Res = (int)GetDlgItem(IDC_CHECK_DEF_HANDLER).SendMessage(BM_GETCHECK);
if (Res == BST_CHECKED)
{
if (!CMessageManager::m_sHandlerManager.m_bDefReflectHandler)
{
m_MessageManager.AddForwardReflect(Name);
}
}
else
{
if (CMessageManager::m_sHandlerManager.m_bDefReflectHandler)
m_MessageManager.DeleteForwardReflect(Name);
}
// reflections
int ReflectionOld = 0;
if (CMessageManager::m_sHandlerManager.m_bReflectNotifications)
{
ReflectionOld++;
if (CMessageManager::m_sHandlerManager.m_bReflectNotificationsEx)
ReflectionOld++;
}
int ReflectionNew = 0;
Res = (int)GetDlgItem(IDC_CHECK_REFLECT).SendMessage(BM_GETCHECK);
if (Res == BST_CHECKED)
{
ReflectionNew++;
Res = (int)GetDlgItem(IDC_CHECK_REFLECT_EX).SendMessage(BM_GETCHECK);
if (Res == BST_CHECKED)
{
ReflectionNew++;
}
}
if (ReflectionNew != ReflectionOld)
{
if (ReflectionOld == 1)
{
m_MessageManager.DeleteForwardReflect(_T("REFLECT_NOTIFICATIONS"));
}
if (ReflectionOld == 2)
{
m_MessageManager.DeleteForwardReflect(_T("REFLECT_NOTIFICATIONS_EX"));
}
if (ReflectionNew == 1)
{
m_MessageManager.AddForwardReflect(_T("REFLECT_NOTIFICATIONS"));
}
if (ReflectionNew == 2)
{
m_MessageManager.AddForwardReflect(_T("REFLECT_NOTIFICATIONS_EX"), _T("<atlwinx.h>"));
}
}
}
LRESULT CFunctionPage::OnHandlerListNmDblclk(LPNMHDR pnmh)
{
//for ListView - (LPNMITEMACTIVATE)pnmh
//for StatusBar - (LPNMMOUSE)pnmh
LPNMITEMACTIVATE pnia = (LPNMITEMACTIVATE)pnmh;
HandlerStruct* pHandler = (HandlerStruct*)m_Handlers.GetItemData(pnia->iItem);
g_pSelectedFunction = pHandler->pFunction;
GetParent().GetParent().SendMessage(WM_COMMAND, MAKELONG(IDOK, BN_CLICKED), 0);
return 0;
}
LRESULT CFunctionPage::OnHdnEndTrack(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
{
int HandlerHeaderID = m_Handlers.GetHeader().GetWindowLong(GWL_ID);
if (idCtrl == HandlerHeaderID)
{
LPNMHEADER lpHeader = (LPNMHEADER)pnmh;
if (lpHeader->iItem == 0)
{
CRect rc;
m_Handlers.GetClientRect(rc);
int Width = m_Handlers.GetColumnWidth(0);
m_Handlers.SetColumnWidth(1, rc.Width() - Width - 5);
}
}
return 0;
}
LRESULT CFunctionPage::OnHandlerListlvnKeyDown(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
{
LPNMLVKEYDOWN lpnmkey = (LPNMLVKEYDOWN)pnmh;
if (lpnmkey->wVKey == VK_DELETE)
{
return OnBnClickedButtonDelHandler(BN_CLICKED, 0, NULL, bHandled);
}
bHandled = FALSE;
return 0;
}
LRESULT CFunctionPage::OnToolbarDropDown(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
{
LPNMTOOLBAR lpnmtb = (LPNMTOOLBAR) pnmh;
CMenu Menu = m_FunctionManager.CreateSpecFunctionDropMenu();
CToolBarCtrl Toolbar(lpnmtb->hdr.hwndFrom);
CRect r = lpnmtb->rcButton;
Toolbar.ClientToScreen(r);
Toolbar.Detach();
int ID = Menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RETURNCMD, r.left, r.bottom, m_hWnd);
if (!ID)
return 0;
CAtlArray<MessageStruct*> Messages;
VSFunction* pFunc = m_FunctionManager.AddSpecFunction(ID, Messages);
if (pFunc)
{
for (size_t i = 0; i < Messages.GetCount(); i++)
{
HandlerStruct Handler;
if (m_MessageManager.InsertWindowsMessageHandler(Messages[i], Handler))
{
AddHandler(&Handler);
}
}
int k = m_Functions.AddString(pFunc->Name);
m_Functions.SetItemDataPtr(k, pFunc);
}
return 0;
}
LRESULT CFunctionPage::OnReflectBnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
if (GetDlgItem(IDC_CHECK_REFLECT).SendMessage(BM_GETCHECK) == BST_CHECKED)
{
GetDlgItem(IDC_CHECK_REFLECT_EX).EnableWindow();
}
else
{
GetDlgItem(IDC_CHECK_REFLECT_EX).EnableWindow(FALSE);
GetDlgItem(IDC_CHECK_REFLECT_EX).SendMessage(BM_SETCHECK, BST_UNCHECKED);
}
return 0;
}
LRESULT CFunctionPage::OnFunctionListLbnDblclk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
int iItem = m_Functions.GetCurSel();
VSFunction* pFunc = (VSFunction*)m_Functions.GetItemData(iItem);
g_pSelectedFunction = pFunc;
GetParent().GetParent().SendMessage(WM_COMMAND, MAKELONG(IDOK, BN_CLICKED), 0);
return 0;
}
LRESULT CFunctionPage::OnVkeytoitem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
UINT vk = LOWORD(wParam);
if (vk == VK_DELETE)
{
OnBnClickedButtonDelFunc(BN_CLICKED, 0, NULL, bHandled);
}
return TRUE;
} | [
"free2000fly@eea8f18a-16fd-41b0-b60a-c1204a6b73d1"
] | [
[
[
1,
1106
]
]
] |
9fcf6134e3726b2f61b806d27eb1e5b759f9745d | 81a3611bfa4e9022e1194295a8f314bafa744f69 | /HGRASS/src/grass/inc/Enumerator.h | 1eb99de6e0ef6cd929065dd2b7150f0547324154 | [] | no_license | ominux/sjtuedaacgrass | 65c02f6a1db52e8194157fd1622b73124220a27c | 463b1926b1eddcc06ff2253b3077aad1bca7e37b | refs/heads/master | 2016-09-15T16:14:00.747072 | 2010-05-18T13:20:08 | 2010-05-18T13:20:08 | 32,243,113 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,547 | h | /* ../CFDD2/Enumerator.h
* The Enumerator class works as the enumeration engine.
* Its key method is Minty(), which reads a graph file, and enumerates
* the product terms in sequence.
* GShi, 04/06/04
*/
#ifndef ENUMERATOR_H
#define ENUMERATOR_H
#include "ToGraph.h"
#include "SDD_Aid.h"
#include "..\inc\dddbase.h" // For accessing DDD.
#include "cfdd_global.h"
#include <iostream>
class Enumerator{
private:
int E, N; // Num of edges and nodes
int term_cnt; // Count of terms
int symb_cnt;
// Total num of symbols (count multiplicitty) in all terms.
Edge *EList; // A list of edges
int *ZList; // A list of Z edge numbers
int Nsymb; // Num of symbols
SymbNode *SymbList; // A list of symbol nodes.
SymbNode **symbarray; // An array of SymbNode pointers.
DDDmanager *ddd;
SDD_Aid *sdd_aid; // For SDD manipulation
DDDnode *sdd_root; // root of the SDD
DDDnode *ddd_root, *ddd_curr;
// Stacks:
int
**NStackL, // Size [E][N], stores nodeL[N] of kth graph-copy.
**NStackR, // Size [E][N], stores nodeR[N] of kth graph-copy.
**EStack; // Size [E][E], stores edge marks of kth graph-copy.
// Note the number of graph-copies in stack will not exceed the
// number of edges.
int *E0Stack; // Size [E].
// The number of the first unprocessed edge in the graph-copy.
DDDnode **DDStack; // Size [E]. Each points to a sub-SDD.
int stk_cnt;
public:
Enumerator();
Enumerator(int n_edge, int n_node, Edge_g *edge_list);
~Enumerator();
// E = num of edges, N = num of nodes.
int ReadGraph(char *graph_file);
int CreateEdgeList(Edge_g *edge_list);
void InitSDD_Aid(); // Initilaize SDD_Aid.
void AddSymbol(Edge *p_edge);
void SetSymbValue(double freq);
int Minty(); // Returns the total number of terms.
inline int GetNumEdge() { return E; }
inline int GetNumNode() { return N; }
inline int GetNsymb() { return Nsymb; }
inline int GetTotalSymb() { return symb_cnt; }
inline DDDnode *GetSDD() { return sdd_root; }
inline char *GetSymbName(int index) \
{ return symbarray[index-1]->name; }
inline double GetValue(int index) \
{ return symbarray[index-1]->value; }
inline double GetImaginary(int index) \
{ return symbarray[index-1]->imag; }
// The indexes of "X", "+" and "-" symbols.
inline int XIndex() { return Nsymb; } // "X" (unknown)
inline int PIndex() { return Nsymb-1; } // "+" (plus)
inline int MIndex() { return Nsymb-2; } // "-" (minus)
void PrintZList();
void MakeSymbList();
void PrintSymbList();
void ExtractSets() { sdd_aid->PrintSDDSets(sdd_root, cout); }
void CheckSDDInfo() { sdd_aid->PrintSDDInfo(sdd_root); }
void PrintSDD() { sdd_aid->PrintSDD(sdd_root); }
void GarbageCollectSDD() { sdd_aid->GarbageCollect(sdd_root); }
void PrintGraph(std::ostream &out);
private:
void SortEdge();
void SetPairing();
// Check whether a loop is formed by coloring the edge (n1, n2).
int CheckLoop(int *node, int n1, int n2, int &cmp_cnt);
void PushStacks(int *edge, int *nodeL, int *nodeR,
int e0, DDDnode *DDcurr);
void PopStacks(int *edge, int *nodeL, int *nodeR,
int &ccntL, int &ccntR, int &e0, DDDnode *&DDcurr);
void PrintTree(int *treeL, int *treeR);
void PrintTerm(int *treeL, int *treeR, int *edge);
int GetSign(int *treeL, int *treeR, int *edge);
int CountEdge(int *edge);
int CheckTree(int *edge, int *nodeL, int *nodeR,
int *treeL, int *treeR);
};
#endif
| [
"wontian@ecd5914e-0e2d-11df-9afa-8babb764c599"
] | [
[
[
1,
105
]
]
] |
55f6b4aa5dbb33ad29670555c2cb8b5ae7ea7b6e | 823afcea9ac0705f6262ccffdff65d687822fe93 | /RayTracing/Src/ColorRGBub.h | 530b2604a0036fce67cebd132487e1ef92e0ab7d | [] | no_license | shourav9884/raytracing99999 | 02b405759edf7eb5021496f87af8fa8157e972be | 19c5e3a236dc1356f6b4ec38efcc05827acb9e04 | refs/heads/master | 2016-09-10T03:30:54.820034 | 2006-10-15T21:49:19 | 2006-10-15T21:49:19 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 562 | h | #pragma once
#include "ColorRGBf.h"
class ColorRGBub
{
public:
typedef unsigned char intensity;
public:
intensity r;
intensity g;
intensity b;
public:
inline ColorRGBub()
: r(125), g(125), b(125)
{
}
inline ColorRGBub( intensity aR, intensity aG, intensity aB )
: r(aR), g(aG), b(aB)
{
}
inline ColorRGBf toColorRGBf()
{
return ColorRGBf( this->r/255.0f, this->g/255.0f, this->b/255.0f );
}
inline static intensity putInRange( float aValue )
{
return static_cast<intensity>((aValue*255) + 0.5);
}
}; | [
"saulopessoa@34b68867-b01b-0410-ab61-0f167d00cb52"
] | [
[
[
1,
34
]
]
] |
b2a6f1827e3482f493516b70a5e64690f71beb83 | ec593cdbcb75afa0e1d49a9d5f992d929f5b131b | /UiSingleOption.h | 764fb9a73371232f866e9b49e349076bef07a95e | [] | no_license | jemyzhang/MzCommon_deprecated | 10873a31b4c240bcdb8d31f7cf7d546c193b59a7 | 99f44847355882edf40329bc17420a5414a59389 | refs/heads/master | 2016-09-01T17:09:08.785822 | 2010-01-18T02:09:09 | 2010-01-18T02:09:09 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 3,000 | h | #pragma once
/*
* @filename UiSingleOption.h
* @note 单选列表
* @author JEMYZHANG
* @date 2009.10.16
* @ver. 1.0
* @changelog
* ver.1.0 初始化程序
*/
// include the MZFC library header file
#include <mzfc_inc.h>
#include <list>
#include "UiImage.h"
//form height = 170 * (n+1)
#define MZ_MW_TEXT_EDITED MZFC_WM_MESSAGE+0x80
class UiSelectionList : public UiList
{
public:
UiSelectionList();
public:
void DrawItem(HDC hdcDst, int nIndex, RECT* prcItem, RECT *prcWin, RECT *prcUpdate);
private:
CMzString preStr;
ImagingHelper* imgSplit;
};
class UiBG : public UiWin
{
protected:
virtual void PaintWin(HDC hdcDst, RECT* prcWin, RECT* prcUpdate){
UiWin::PaintWin(hdcDst, prcWin, prcUpdate);
MzDrawGridDlgBG(hdcDst,prcWin);
}
};
class Ui_SingleOptionWnd : public CMzWndEx
{
MZ_DECLARE_DYNAMIC(Ui_SingleOptionWnd);
public:
Ui_SingleOptionWnd(void);
~Ui_SingleOptionWnd(void);
public:
UiBG m_bg;
UiImage m_splitter_top;
UiSelectionList m_OptionList;
// UiButton m_BtnOK;
UiButton m_BtnCancel;
UiStatic m_Title;
public:
void AppendOptionItem(LPTSTR item){
if(item == NULL) return;
ListItem li;
li.Text = item;
m_OptionList.AddItem(li);
}
void SetSelectedIndex(int nIndex){
if(nIndex >= m_OptionList.GetItemCount()) nIndex = 0;
m_OptionList.SetSelectedIndex(nIndex);
}
int GetSelectedIndex(){
return m_OptionList.GetSelectedIndex();
}
LPTSTR GetSelectedText(){
int nIndex = m_OptionList.GetSelectedIndex();
if(nIndex == -1) return NULL;
return m_OptionList.GetItem(nIndex)->Text.C_Str();
}
void SetTitleText(LPTSTR title);
void PaintWin(HDC hdc, RECT* prcUpdate = NULL){
if(bUpdateBgWin == TRUE){
bUpdateBgWin = FALSE;
bgWin = ::ScreenSnapshot();
}
RECT rectWin = {0,0,0,0};
rectWin.right = this->GetWidth();
rectWin.bottom = this->GetHeight();
::BitmapTransBlt(hdc,&rectWin,bgWin,&rectCopy,RGB(128,128,128));
CMzWndEx::PaintWin(hdc,prcUpdate);
}
virtual BOOL Create(int xPos, int yPos, int width, int height, HWND hwndParent=NULL, int uID = NULL, DWORD style=WS_CHILD, DWORD exstyle=0){
rectCopy.left = xPos;
rectCopy.top = yPos;
rectCopy.right = xPos + width;
rectCopy.bottom = yPos + height;
return CMzWndEx::Create(xPos,yPos,width,height,hwndParent,uID,style,exstyle);
}
protected:
// Initialization of the window (dialog)
virtual BOOL OnInitDialog();
// override the MZFC window messages handler
virtual LRESULT MzDefWndProc(UINT message, WPARAM wParam, LPARAM lParam);
// override the MZFC command handler
virtual void OnMzCommand(WPARAM wParam, LPARAM lParam);
private:
LPTSTR m_title;
HBITMAP bgWin;
BOOL bUpdateBgWin;
RECT rectCopy;
//resource
ImagingHelper* imgSplit_top;
};
| [
"jemyzhang@53aff7d1-dc1e-0346-9cbd-63131b65f07d"
] | [
[
[
1,
107
]
]
] |
a67494f7635518dc57c4e8f749f7044cedae4a28 | 2bc723334d2de050f5226a9cd25afa65dac53d6e | /TextPrint.cpp | 2eab27f605ce5b360162fdd07a4261ae1147e3df | [] | no_license | shengpengwu/PlanetWars_Merge | d1950e5d8a7e559a5efb9c8a38e14f53642dbec9 | 154b90738de65e1d73effa27ea0339073b5cc48c | refs/heads/master | 2020-05-18T10:08:58.038235 | 2011-12-21T01:13:05 | 2011-12-21T01:13:05 | 2,990,232 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,705 | cpp |
#ifdef TARGET_OS_MAC
#include <OpenGL/OpenGL.h>
#include <GLUT/GLUT.h>
#endif
#ifdef __linux__
// Linux Includes Here
#error Can't be compiled on Linux yet
#endif
#ifdef _WIN32 || _WIN64
#include <GL\freeglut.h>
#include <GL\GL.h>
#endif
#include "TextPrint.h"
TextPrint::TextPrint(void)
{
}
TextPrint::~TextPrint(void)
{
}
/*
GLUT_BITMAP_8_BY_13
GLUT_BITMAP_9_BY_15
GLUT_BITMAP_TIMES_ROMAN_10
GLUT_BITMAP_TIMES_ROMAN_24
GLUT_BITMAP_HELVETICA_10
GLUT_BITMAP_HELVETICA_12
GLUT_BITMAP_HELVETICA_18
*/
/*
* Prints characters from GLUT in the 3d world which will always face the screen.
* Do not push or pop matrices before this!
*/
void TextPrint::bitText(int x, int y, int z,
float r, float g, float b, void * font, char *string)
{
glColor3f( r, g, b );
glRasterPos3f(x, y, z);
int len, i;
len = (int)strlen(string);
for (i = 0; i < len; i++) {
glutBitmapCharacter(font, string[i]);
}
}
// Standalone function that will automatically place words in a HUD.
void TextPrint::hudText(int x, int y, int z,
float r, float g, float b, void * font, char *string)
{
glColor3f( r, g, b );
glRasterPos3f(x, y, z);
int len, i;
len = (int)strlen(string);
for (i = 0; i < len; i++) {
glutBitmapCharacter(font, string[i]);
}
}
/* Stroke fonts:
GLUT_STROKE_ROMAN
GLUT_STROKE_MONO_ROMAN
*/
void TextPrint::strokePrint(int x, int y, int z,
float r, float g, float b, char *string)
{
char *p;
glPushMatrix();
glColor3f(r,g,b);
glTranslatef(x, y, z);
for (p = string; *p; p++)
glutStrokeCharacter(GLUT_STROKE_ROMAN, *p);
glPopMatrix();
} | [
"[email protected]",
"[email protected]",
"[email protected]"
] | [
[
[
1,
1
],
[
16,
27
],
[
38,
72
],
[
74,
83
],
[
85,
89
]
],
[
[
2,
15
],
[
28,
37
],
[
73,
73
],
[
84,
84
]
],
[
[
90,
90
]
]
] |
7479cc47e51c172a2e8edd1d21c3c9e247535664 | 5e61787e7adba6ed1c2b5e40d38098ebdf9bdee8 | /sans/models/c_models/CHollowCylinderModel.cpp | aa24710c803c8ee0b75b60f1d6d95ce7c4fa1270 | [] | no_license | mcvine/sansmodels | 4dcba43d18c930488b0e69e8afb04139e89e7b21 | 618928810ee7ae58ec35bbb839eba2a0117c4611 | refs/heads/master | 2021-01-22T13:12:22.721492 | 2011-09-30T14:01:06 | 2011-09-30T14:01:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 26,136 | cpp | /**
This software was developed by the University of Tennessee as part of the
Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
project funded by the US National Science Foundation.
If you use DANSE applications to do scientific research that leads to
publication, we ask that you acknowledge the use of the software with the
following sentence:
"This work benefited from DANSE software developed under NSF award DMR-0520547."
copyright 2008, University of Tennessee
*/
/** CHollowCylinderModel
*
* C extension
*
* WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
* DO NOT MODIFY THIS FILE, MODIFY hollow_cylinder.h
* AND RE-RUN THE GENERATOR SCRIPT
*
*/
#define NO_IMPORT_ARRAY
#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
extern "C" {
#include <Python.h>
#include <arrayobject.h>
#include "structmember.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include "hollow_cylinder.h"
}
#include "models.hh"
#include "dispersion_visitor.hh"
/// Error object for raised exceptions
static PyObject * CHollowCylinderModelError = NULL;
// Class definition
typedef struct {
PyObject_HEAD
/// Parameters
PyObject * params;
/// Dispersion parameters
PyObject * dispersion;
/// Underlying model object
HollowCylinderModel * model;
/// Log for unit testing
PyObject * log;
} CHollowCylinderModel;
static void
CHollowCylinderModel_dealloc(CHollowCylinderModel* self)
{
Py_DECREF(self->params);
Py_DECREF(self->dispersion);
Py_DECREF(self->log);
delete self->model;
self->ob_type->tp_free((PyObject*)self);
}
static PyObject *
CHollowCylinderModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
CHollowCylinderModel *self;
self = (CHollowCylinderModel *)type->tp_alloc(type, 0);
return (PyObject *)self;
}
static int
CHollowCylinderModel_init(CHollowCylinderModel *self, PyObject *args, PyObject *kwds)
{
if (self != NULL) {
// Create parameters
self->params = PyDict_New();
self->dispersion = PyDict_New();
self->model = new HollowCylinderModel();
// Initialize parameter dictionary
PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
PyDict_SetItemString(self->params,"sldCyl",Py_BuildValue("d",0.000006300000));
PyDict_SetItemString(self->params,"core_radius",Py_BuildValue("d",20.000000000000));
PyDict_SetItemString(self->params,"axis_theta",Py_BuildValue("d",90.000000000000));
PyDict_SetItemString(self->params,"length",Py_BuildValue("d",400.000000000000));
PyDict_SetItemString(self->params,"axis_phi",Py_BuildValue("d",0.000000000000));
PyDict_SetItemString(self->params,"sldSolv",Py_BuildValue("d",0.000001000000));
PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.010000000000));
PyDict_SetItemString(self->params,"radius",Py_BuildValue("d",30.000000000000));
// Initialize dispersion / averaging parameter dict
DispersionVisitor* visitor = new DispersionVisitor();
PyObject * disp_dict;
disp_dict = PyDict_New();
self->model->core_radius.dispersion->accept_as_source(visitor, self->model->core_radius.dispersion, disp_dict);
PyDict_SetItemString(self->dispersion, "core_radius", disp_dict);
disp_dict = PyDict_New();
self->model->radius.dispersion->accept_as_source(visitor, self->model->radius.dispersion, disp_dict);
PyDict_SetItemString(self->dispersion, "radius", disp_dict);
disp_dict = PyDict_New();
self->model->length.dispersion->accept_as_source(visitor, self->model->length.dispersion, disp_dict);
PyDict_SetItemString(self->dispersion, "length", disp_dict);
disp_dict = PyDict_New();
self->model->axis_theta.dispersion->accept_as_source(visitor, self->model->axis_theta.dispersion, disp_dict);
PyDict_SetItemString(self->dispersion, "axis_theta", disp_dict);
disp_dict = PyDict_New();
self->model->axis_phi.dispersion->accept_as_source(visitor, self->model->axis_phi.dispersion, disp_dict);
PyDict_SetItemString(self->dispersion, "axis_phi", disp_dict);
// Create empty log
self->log = PyDict_New();
}
return 0;
}
static PyMemberDef CHollowCylinderModel_members[] = {
{"params", T_OBJECT, offsetof(CHollowCylinderModel, params), 0,
"Parameters"},
{"dispersion", T_OBJECT, offsetof(CHollowCylinderModel, dispersion), 0,
"Dispersion parameters"},
{"log", T_OBJECT, offsetof(CHollowCylinderModel, log), 0,
"Log"},
{NULL} /* Sentinel */
};
/** Read double from PyObject
@param p PyObject
@return double
*/
double CHollowCylinderModel_readDouble(PyObject *p) {
if (PyFloat_Check(p)==1) {
return (double)(((PyFloatObject *)(p))->ob_fval);
} else if (PyInt_Check(p)==1) {
return (double)(((PyIntObject *)(p))->ob_ival);
} else if (PyLong_Check(p)==1) {
return (double)PyLong_AsLong(p);
} else {
return 0.0;
}
}
/**
* Function to call to evaluate model
* @param args: input numpy array q[]
* @return: numpy array object
*/
static PyObject *evaluateOneDim(HollowCylinderModel* model, PyArrayObject *q){
PyArrayObject *result;
// Check validity of array q , q must be of dimension 1, an array of double
if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
{
//const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
//PyErr_SetString(PyExc_ValueError , message);
return NULL;
}
result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions),
PyArray_DOUBLE);
if (result == NULL) {
const char * message= "Could not create result ";
PyErr_SetString(PyExc_RuntimeError , message);
return NULL;
}
for (int i = 0; i < q->dimensions[0]; i++){
double q_value = *(double *)(q->data + i*q->strides[0]);
double *result_value = (double *)(result->data + i*result->strides[0]);
*result_value =(*model)(q_value);
}
return PyArray_Return(result);
}
/**
* Function to call to evaluate model
* @param args: input numpy array [x[],y[]]
* @return: numpy array object
*/
static PyObject * evaluateTwoDimXY( HollowCylinderModel* model,
PyArrayObject *x, PyArrayObject *y)
{
PyArrayObject *result;
int i,j, x_len, y_len, dims[1];
//check validity of input vectors
if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
|| y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
|| y->dimensions[0] != x->dimensions[0]){
const char * message= "evaluateTwoDimXY expect 2 numpy arrays";
PyErr_SetString(PyExc_ValueError , message);
return NULL;
}
if (PyArray_Check(x) && PyArray_Check(y)) {
x_len = dims[0]= x->dimensions[0];
y_len = dims[0]= y->dimensions[0];
// Make a new double matrix of same dims
result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
if (result == NULL){
const char * message= "Could not create result ";
PyErr_SetString(PyExc_RuntimeError , message);
return NULL;
}
/* Do the calculation. */
for ( i=0; i< x_len; i++) {
double x_value = *(double *)(x->data + i*x->strides[0]);
double y_value = *(double *)(y->data + i*y->strides[0]);
double *result_value = (double *)(result->data +
i*result->strides[0]);
*result_value = (*model)(x_value, y_value);
}
return PyArray_Return(result);
}else{
PyErr_SetString(CHollowCylinderModelError,
"CHollowCylinderModel.evaluateTwoDimXY couldn't run.");
return NULL;
}
}
/**
* evalDistribution function evaluate a model function with input vector
* @param args: input q as vector or [qx, qy] where qx, qy are vectors
*
*/
static PyObject * evalDistribution(CHollowCylinderModel *self, PyObject *args){
PyObject *qx, *qy;
PyArrayObject * pars;
int npars ,mpars;
// Get parameters
// Reader parameter dictionary
self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
self->model->sldCyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldCyl") );
self->model->core_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_radius") );
self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") );
self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") );
self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
// Read in dispersion parameters
PyObject* disp_dict;
DispersionVisitor* visitor = new DispersionVisitor();
disp_dict = PyDict_GetItemString(self->dispersion, "core_radius");
self->model->core_radius.dispersion->accept_as_destination(visitor, self->model->core_radius.dispersion, disp_dict);
disp_dict = PyDict_GetItemString(self->dispersion, "radius");
self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
disp_dict = PyDict_GetItemString(self->dispersion, "length");
self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
disp_dict = PyDict_GetItemString(self->dispersion, "axis_theta");
self->model->axis_theta.dispersion->accept_as_destination(visitor, self->model->axis_theta.dispersion, disp_dict);
disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi");
self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict);
// Get input and determine whether we have to supply a 1D or 2D return value.
if ( !PyArg_ParseTuple(args,"O",&pars) ) {
PyErr_SetString(CHollowCylinderModelError,
"CHollowCylinderModel.evalDistribution expects a q value.");
return NULL;
}
// Check params
if(PyArray_Check(pars)==1) {
// Length of list should 1 or 2
npars = pars->nd;
if(npars==1) {
// input is a numpy array
if (PyArray_Check(pars)) {
return evaluateOneDim(self->model, (PyArrayObject*)pars);
}
}else{
PyErr_SetString(CHollowCylinderModelError,
"CHollowCylinderModel.evalDistribution expect numpy array of one dimension.");
return NULL;
}
}else if( PyList_Check(pars)==1) {
// Length of list should be 2 for I(qx,qy)
mpars = PyList_GET_SIZE(pars);
if(mpars!=2) {
PyErr_SetString(CHollowCylinderModelError,
"CHollowCylinderModel.evalDistribution expects a list of dimension 2.");
return NULL;
}
qx = PyList_GET_ITEM(pars,0);
qy = PyList_GET_ITEM(pars,1);
if (PyArray_Check(qx) && PyArray_Check(qy)) {
return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
(PyArrayObject*)qy);
}else{
PyErr_SetString(CHollowCylinderModelError,
"CHollowCylinderModel.evalDistribution expect 2 numpy arrays in list.");
return NULL;
}
}
PyErr_SetString(CHollowCylinderModelError,
"CHollowCylinderModel.evalDistribution couln't be run.");
return NULL;
}
/**
* Function to call to evaluate model
* @param args: input q or [q,phi]
* @return: function value
*/
static PyObject * run(CHollowCylinderModel *self, PyObject *args) {
double q_value, phi_value;
PyObject* pars;
int npars;
// Get parameters
// Reader parameter dictionary
self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
self->model->sldCyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldCyl") );
self->model->core_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_radius") );
self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") );
self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") );
self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
// Read in dispersion parameters
PyObject* disp_dict;
DispersionVisitor* visitor = new DispersionVisitor();
disp_dict = PyDict_GetItemString(self->dispersion, "core_radius");
self->model->core_radius.dispersion->accept_as_destination(visitor, self->model->core_radius.dispersion, disp_dict);
disp_dict = PyDict_GetItemString(self->dispersion, "radius");
self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
disp_dict = PyDict_GetItemString(self->dispersion, "length");
self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
disp_dict = PyDict_GetItemString(self->dispersion, "axis_theta");
self->model->axis_theta.dispersion->accept_as_destination(visitor, self->model->axis_theta.dispersion, disp_dict);
disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi");
self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict);
// Get input and determine whether we have to supply a 1D or 2D return value.
if ( !PyArg_ParseTuple(args,"O",&pars) ) {
PyErr_SetString(CHollowCylinderModelError,
"CHollowCylinderModel.run expects a q value.");
return NULL;
}
// Check params
if( PyList_Check(pars)==1) {
// Length of list should be 2 for I(q,phi)
npars = PyList_GET_SIZE(pars);
if(npars!=2) {
PyErr_SetString(CHollowCylinderModelError,
"CHollowCylinderModel.run expects a double or a list of dimension 2.");
return NULL;
}
// We have a vector q, get the q and phi values at which
// to evaluate I(q,phi)
q_value = CHollowCylinderModel_readDouble(PyList_GET_ITEM(pars,0));
phi_value = CHollowCylinderModel_readDouble(PyList_GET_ITEM(pars,1));
// Skip zero
if (q_value==0) {
return Py_BuildValue("d",0.0);
}
return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
} else {
// We have a scalar q, we will evaluate I(q)
q_value = CHollowCylinderModel_readDouble(pars);
return Py_BuildValue("d",(*(self->model))(q_value));
}
}
/**
* Function to call to calculate_ER
* @return: effective radius value
*/
static PyObject * calculate_ER(CHollowCylinderModel *self) {
PyObject* pars;
int npars;
// Get parameters
// Reader parameter dictionary
self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
self->model->sldCyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldCyl") );
self->model->core_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_radius") );
self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") );
self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") );
self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
// Read in dispersion parameters
PyObject* disp_dict;
DispersionVisitor* visitor = new DispersionVisitor();
disp_dict = PyDict_GetItemString(self->dispersion, "core_radius");
self->model->core_radius.dispersion->accept_as_destination(visitor, self->model->core_radius.dispersion, disp_dict);
disp_dict = PyDict_GetItemString(self->dispersion, "radius");
self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
disp_dict = PyDict_GetItemString(self->dispersion, "length");
self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
disp_dict = PyDict_GetItemString(self->dispersion, "axis_theta");
self->model->axis_theta.dispersion->accept_as_destination(visitor, self->model->axis_theta.dispersion, disp_dict);
disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi");
self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict);
return Py_BuildValue("d",(*(self->model)).calculate_ER());
}
/**
* Function to call to evaluate model in cartesian coordinates
* @param args: input q or [qx, qy]]
* @return: function value
*/
static PyObject * runXY(CHollowCylinderModel *self, PyObject *args) {
double qx_value, qy_value;
PyObject* pars;
int npars;
// Get parameters
// Reader parameter dictionary
self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
self->model->sldCyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldCyl") );
self->model->core_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_radius") );
self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") );
self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") );
self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
// Read in dispersion parameters
PyObject* disp_dict;
DispersionVisitor* visitor = new DispersionVisitor();
disp_dict = PyDict_GetItemString(self->dispersion, "core_radius");
self->model->core_radius.dispersion->accept_as_destination(visitor, self->model->core_radius.dispersion, disp_dict);
disp_dict = PyDict_GetItemString(self->dispersion, "radius");
self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
disp_dict = PyDict_GetItemString(self->dispersion, "length");
self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
disp_dict = PyDict_GetItemString(self->dispersion, "axis_theta");
self->model->axis_theta.dispersion->accept_as_destination(visitor, self->model->axis_theta.dispersion, disp_dict);
disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi");
self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict);
// Get input and determine whether we have to supply a 1D or 2D return value.
if ( !PyArg_ParseTuple(args,"O",&pars) ) {
PyErr_SetString(CHollowCylinderModelError,
"CHollowCylinderModel.run expects a q value.");
return NULL;
}
// Check params
if( PyList_Check(pars)==1) {
// Length of list should be 2 for I(qx, qy))
npars = PyList_GET_SIZE(pars);
if(npars!=2) {
PyErr_SetString(CHollowCylinderModelError,
"CHollowCylinderModel.run expects a double or a list of dimension 2.");
return NULL;
}
// We have a vector q, get the qx and qy values at which
// to evaluate I(qx,qy)
qx_value = CHollowCylinderModel_readDouble(PyList_GET_ITEM(pars,0));
qy_value = CHollowCylinderModel_readDouble(PyList_GET_ITEM(pars,1));
return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
} else {
// We have a scalar q, we will evaluate I(q)
qx_value = CHollowCylinderModel_readDouble(pars);
return Py_BuildValue("d",(*(self->model))(qx_value));
}
}
static PyObject * reset(CHollowCylinderModel *self, PyObject *args) {
return Py_BuildValue("d",0.0);
}
static PyObject * set_dispersion(CHollowCylinderModel *self, PyObject *args) {
PyObject * disp;
const char * par_name;
if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
PyErr_SetString(CHollowCylinderModelError,
"CHollowCylinderModel.set_dispersion expects a DispersionModel object.");
return NULL;
}
void *temp = PyCObject_AsVoidPtr(disp);
DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
// Ugliness necessary to go from python to C
// TODO: refactor this
if (!strcmp(par_name, "core_radius")) {
self->model->core_radius.dispersion = dispersion;
} else if (!strcmp(par_name, "radius")) {
self->model->radius.dispersion = dispersion;
} else if (!strcmp(par_name, "length")) {
self->model->length.dispersion = dispersion;
} else if (!strcmp(par_name, "axis_theta")) {
self->model->axis_theta.dispersion = dispersion;
} else if (!strcmp(par_name, "axis_phi")) {
self->model->axis_phi.dispersion = dispersion;
} else {
PyErr_SetString(CHollowCylinderModelError,
"CHollowCylinderModel.set_dispersion expects a valid parameter name.");
return NULL;
}
DispersionVisitor* visitor = new DispersionVisitor();
PyObject * disp_dict = PyDict_New();
dispersion->accept_as_source(visitor, dispersion, disp_dict);
PyDict_SetItemString(self->dispersion, par_name, disp_dict);
return Py_BuildValue("i",1);
}
static PyMethodDef CHollowCylinderModel_methods[] = {
{"run", (PyCFunction)run , METH_VARARGS,
"Evaluate the model at a given Q or Q, phi"},
{"runXY", (PyCFunction)runXY , METH_VARARGS,
"Evaluate the model at a given Q or Qx, Qy"},
{"calculate_ER", (PyCFunction)calculate_ER , METH_VARARGS,
"Evaluate the model at a given Q or Q, phi"},
{"evalDistribution", (PyCFunction)evalDistribution , METH_VARARGS,
"Evaluate the model at a given Q or Qx, Qy vector "},
{"reset", (PyCFunction)reset , METH_VARARGS,
"Reset pair correlation"},
{"set_dispersion", (PyCFunction)set_dispersion , METH_VARARGS,
"Set the dispersion model for a given parameter"},
{NULL}
};
static PyTypeObject CHollowCylinderModelType = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
"CHollowCylinderModel", /*tp_name*/
sizeof(CHollowCylinderModel), /*tp_basicsize*/
0, /*tp_itemsize*/
(destructor)CHollowCylinderModel_dealloc, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_compare*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash */
0, /*tp_call*/
0, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
"CHollowCylinderModel objects", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
CHollowCylinderModel_methods, /* tp_methods */
CHollowCylinderModel_members, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)CHollowCylinderModel_init, /* tp_init */
0, /* tp_alloc */
CHollowCylinderModel_new, /* tp_new */
};
//static PyMethodDef module_methods[] = {
// {NULL}
//};
/**
* Function used to add the model class to a module
* @param module: module to add the class to
*/
void addCHollowCylinderModel(PyObject *module) {
PyObject *d;
if (PyType_Ready(&CHollowCylinderModelType) < 0)
return;
Py_INCREF(&CHollowCylinderModelType);
PyModule_AddObject(module, "CHollowCylinderModel", (PyObject *)&CHollowCylinderModelType);
d = PyModule_GetDict(module);
CHollowCylinderModelError = PyErr_NewException("CHollowCylinderModel.error", NULL, NULL);
PyDict_SetItemString(d, "CHollowCylinderModelError", CHollowCylinderModelError);
}
| [
"[email protected]",
"[email protected]"
] | [
[
[
1,
23
],
[
26,
28
],
[
30,
91
],
[
101,
107
],
[
110,
155
],
[
186,
186
],
[
207,
207
],
[
209,
209
],
[
313,
316
],
[
318,
332
],
[
334,
337
],
[
339,
339
],
[
341,
345
],
[
348,
390
],
[
425,
425
],
[
430,
443
],
[
445,
448
],
[
450,
450
],
[
452,
456
],
[
459,
521
],
[
524,
548
],
[
554,
603
],
[
607,
625
]
],
[
[
24,
25
],
[
29,
29
],
[
92,
100
],
[
108,
109
],
[
156,
185
],
[
187,
206
],
[
208,
208
],
[
210,
312
],
[
317,
317
],
[
333,
333
],
[
338,
338
],
[
340,
340
],
[
346,
347
],
[
391,
424
],
[
426,
429
],
[
444,
444
],
[
449,
449
],
[
451,
451
],
[
457,
458
],
[
522,
523
],
[
549,
553
],
[
604,
606
]
]
] |
a569743be2459fa1bd39fa55adc6556b03e1e6e3 | bd89d3607e32d7ebb8898f5e2d3445d524010850 | /adaptationlayer/tsy/nokiatsy_dll/inc/cmmcustommesshandler.h | c00032cc1188eaf91a7d81c0f2a7b78ca9a1a226 | [] | no_license | wannaphong/symbian-incubation-projects.fcl-modemadaptation | 9b9c61ba714ca8a786db01afda8f5a066420c0db | 0e6894da14b3b096cffe0182cedecc9b6dac7b8d | refs/heads/master | 2021-05-30T05:09:10.980036 | 2010-10-19T10:16:20 | 2010-10-19T10:16:20 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 48,712 | h | /*
* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of the License "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/
#ifndef _CMMCUSTOMMESSHANDLER_H
#define _CMMCUSTOMMESSHANDLER_H
// INCLUDES
#include "mmmmesshandlerbase.h"
#include "cmmphonetreceiver.h"
#include "muiccoperationbase.h"
#include "cmmuiccmesshandler.h"
// for internal testing
#include "nokiatsy_internal_variation.h"
#include <ctsy/rmmcustomapi.h>
// CONSTANTS
// Length of Sim info isi msg buffer
const TUint8 KSimInfoBufferSize = 20;
// Time related constants
const TUint16 KSecsInHour = 3600;
const TUint8 KMinsInHour = 60;
// Length if Gss Cs isi msg buffer
const TUint8 KGssCsBufferSize = 6;
// Call property buffer size
const TUint8 KCallPropBuffSize = 4;
// Value for information which value is not needed.
const TUint8 KZero = 0x00;
// Default length for product profile reading request
const TUint8 KDefaultPPlength = 0x01;
// Max length of network proveder name
const TUint8 KNwProviderNameLength = 0x19;
// Constants for remote address length
const TUint8 KRemoteAddressBcdSize = 18;
const TUint8 KRemoteAddressAsciiSize = 34;
const TUint8 KRemoteAddressConversionSize = 36;
// SS Request Complete Notifivation SS Status
const TUint8 KCustomApiSsGsmActive = 0x01;
const TUint8 KCustomApiSsGsmRegistered = 0x02;
const TUint8 KCustomApiSsGsmProvisioned = 0x04;
const TUint8 KCustomApiSsGsmQuiescent = 0x08;
const TUint8 KinfoPpTwoDigitDial = 0x0F;
//value for information which value is two
const TUint8 KTwo = 0x02;
//value for information which value is three
const TUint8 KThree = 0x03;
//value for information which value is four
const TUint8 KFour = 0x04;
//value for information which value is six
const TUint8 KSix = 0x06;
const TUint8 KCustomPadding = 0x00; //Padding byte
// Call Life Timer Constants
const TUint8 KCallLifeTimerDataAmount = 0x04;
const TInt KCallLifeTimerNotSet = -1;
const TUint8 KPmmGroupNokiaTsySize = 100;
// Maximum number of re-trials when requesting data from PMM.
const TUint8 KMaxPMMReadRequests = 0x03;
// These constants are needed for Viag Home Zone
const TUint8 KLengthOfSMSCNumber = 15;
const TUint8 KLengthOfSCPNumber = 15;
const TUint8 KLengthOfHzCzTag = 13;
const TUint8 KHomeZoneActiveBit = 0x01;
const TUint8 KCityZoneActiveBit = 0x02;
const TUint16 KUnusedCbMsgId = 0xffff;
const TUint8 KCustomTransId = 6;
// MACROS
//None
// DATA TYPES
//None
// EXTERNAL DATA STRUCTURES
//None
// FUNCTION PROTOTYPES
//None
// FORWARD DECLARATIONS
class CMmSecurityMessHandler;
class CMmNetMessHandler;
class CMmPhoNetSender;
class TIsiReceiveC;
class CMmMessageRouter;
class CMmUiccMessHandler;
// CLASS DECLARATION
/**
* CMmCustomMessHandler is used to create and send GSM specific
* custom ISI messages to PhoNet via PhoNetSender.
*/
class CMmCustomMessHandler :
public CBase,
public MMmMessHandlerBase,
public MMmMessageReceiver,
public MUiccOperationBase
{
public:
// Used for saving the ciphering information.
struct TCiphListEntry
{
TBool iCiphStatus;
TUint8 iTraId;
};
// Used for saving the enhanced cell information.
class TECIDInfo
{
public: // data
RMmCustomAPI::TMmCellInfo iCellInfo; // Cell Information
TUint iMCC; // Mobile Country Code
TUint iMNC; // Mobile Network Code
TUint iCID; // Location area code
TUint iLAC; // Cell identity
};
// This enumeration is needed because different Product Profile
// requests can be made using the same INFO_PP_READ_REQ/RESP
// messages. Used as a transaction ID.
enum TProductProfileRequestType
{
EGetAlsPPSupport = 0,
ECheckTwoDigitDialSupport
};
// This enumeration is needed because a SIM_READ_CI_RESP can come
// as a response to a GetCipheringInfo-request, or triggered by
// a NET_CIPHERING_IND indication which makes the same request.
// Used as a transaction ID.
enum TCipheringInfoRequestType
{
EGetCipheringInfo = 0,
ENotifyCipheringInfo
};
// The SIM operations are grouped into the following types.
// Used as ISA transaction IDs.
enum TSIMOperationType
{
ESIMOperationTypeReadSimTopics = 0,
ESIMOperationTypeDeleteSimTopic
};
enum TUiccSapIfStatus
{
EUiccSapIfStatus1 = 1,
EUiccSapIfStatus2,
EUiccSapIfStatus3
};
public: // Constructors and destructor
/**
* Creates a new GSM specific MessageHandler object instance.
* @param aPhoNetSender: a pointer to a Phonet Sender object
* @param aPhoNetReceiver:
* @param aNetMessHandler: a pointer to the Net message handler
* @param aSecurityMessHandler: a pointer to the security mess handler
* @param aMessageRouter: a pointer to the message router
* @return void
*/
static CMmCustomMessHandler* NewL(
CMmPhoNetSender* aPhoNetSender,
CMmPhoNetReceiver* aPhoNetReceiver,
CMmNetMessHandler* aNetMessHandler,
CMmSecurityMessHandler* aSecurityMessHandler,
CMmMessageRouter* aMessageRouter,
CMmUiccMessHandler* aUiccMessHandler);
/**
* Destructor.
* @return void
*/
~CMmCustomMessHandler();
public: // New Functions
/**
* Creates CallReleaseReq ISI message and sends it to Phonet.
* @param TUint8 aTransactionId: unique transaction id
* @param TUint8 aCallId: Call ID of this call (NOS Call ID)
* @param TUint8 aCause: cause of releasing
* @return TInt: success/failure value
*/
TInt CallReleaseReq(
TUint8 aTransactionId,
TUint8 aCallId,
TUint8 aCause );
/**
* Breaks received CallReleaseResp ISI message.
* @param const TIsiReceiveC& aIsiMsg: The received ISI message
* @return void : None
*/
void CallReleaseResp( const TIsiReceiveC& aIsiMsg );
/**
* MO alert indication, used for Remote Alerting Tone in Custom TSY
* @param const TIsiReceiveC& aIsiMsg: The received ISI message
* @return TInt: void : None
*/
void CallMoAlertInd( const TIsiReceiveC& aIsiMsg );
/**
* Creates a NET_CS_WAKEUP_REQ ISI message and sends it to Phonet
* @param TUint8 aTransId: transaction Id
* @return TInt: success/failure value
*/
TInt NetCsWakeupReq( TUint8 aTransId );
/**
* Breaks received NET_CS_WAKEUP_RESP ISI message
* @param None
* @return void : None
*/
void NetCsWakeupResp();
/**
* Breaks received NET_CIPHERING_IND ISI message
* @param TIsiReceiveC& aIsiMsg: The received ISI message
* @return void : None
*/
void NetCipheringInd( const TIsiReceiveC& aIsiMsg );
/**
* Breaks received NET_MODEM_REG_STATUS_IND ISI message
* @param TIsiReceiveC& aIsiMsg: The received ISI message
* @return void : None
*/
void NetModemRegStatusInd( const TIsiReceiveC& aIsiMsg );
/**
* Read dynamic flags 2
* @return void
*/
TInt UiccReadDynamic2FlagsReq();
/**
* Read dynamic flags 2 response
* @param aStatus Status
* @param aFileData File data
* @return void
*/
void UiccReadDynamic2FlagsResp(
TInt aStatus,
const TDesC8& aFileData );
/**
* Write dynamic flags 2
* @param aInfo Flags 2 data
* @return void
*/
TInt UiccWriteDynamic2FlagsReq( TUint8 aInfo );
/**
* Write dynamic flags 2 response
* @param aInfo Flags 2 data
* @return void
*/
void UiccWriteDynamic2FlagsResp( TInt aStatus );
/**
* Breaks received CALL_TERMINATE_IND ISI messages
* @param const TIsiReceiveC& aIsiMsg: The received ISI message
* @return void : None
*/
void CallTerminateInd( const TIsiReceiveC& aIsiMsg );
/**
* Breaks received CALL_RELEASE_IND ISI messages
* @param const TIsiReceiveC& aIsiMsg: The received ISI message
* @return void : None
*/
void CallReleaseInd( const TIsiReceiveC& aIsiMsg );
/**
* Creates a INFO_PP_READ_REQ ISI messages and sends it to phone
* @param TProductProfileRequestType aReqType: request type (used
* as transaction id)
* @return void : KErrNone / Error value from phonet
*/
TInt InfoPpReadReq( TProductProfileRequestType aReqType );
/**
* Breaks a INFO_PP_READ_RESP message
* @param CIsiMsg* aIsiMsg: The received ISI message
* @return void : None
*/
void InfoPpReadResp( const TIsiReceiveC& aIsiMessage );
/**
* Creates a CALL_GSM_BLACKLIST_CLEAR_REQ ISI message and sends it to
* Phonet
* @param TUint8 aTransId: transaction Id
* @return TInt : KErrNone or error code
*/
TInt CallGsmBlackListClearReq( TUint8 aTransId );
/**
* Breaks received CALL_GSM_BLACKLIST_CLEAR_RESP ISI message
* @return void : None
*/
void CallGsmBlackListClearResp();
/**
* Breaks received SS_SERVICE_COMPLETED_IND ISI message
* @param const TIsiReceiveC& aIsiMessage: The received ISI message
* @return void : None
*/
void SsServiceCompletedInd ( const TIsiReceiveC& aIsiMessage );
/**
* Creates a CALL_EMERGENCY_NBR_CHECK_REQ ISI messages and sends it to
* phonet
* @param TUint8 aTransId: Transaction Id
* @param TMobileTelNumber&: telnumber
* @param TCheckMode aCheckMode; check mode
* @return TInt : KErrNone / Error value from phonet
*/
TInt CallEmergencyNbrCheckReq( TUint8 aTransId,
RMmCustomAPI::TMobileTelNumber& aNumber,
RMmCustomAPI::TCheckMode aCheckMode );
/**
* Breaks a CALL_EMERGENCY_NBR_CHECK_RESP message
* @param const TIsiReceiveC& aIsiMsg: The received ISI message
* @return void : None
*/
void CallEmergencyNbrCheckResp( const TIsiReceiveC& aIsiMsg );
/**
* Creates a SS_GSM_USSD_SEND_REQ ISI messages and sends it to IsaApi
* @param TUint8 aTransId: Transaction Id
* @return TInt : KErrNone / Error value from IsaApi
*/
TInt SsGsmUssdSendReq( TUint8 aTransId );
/**
* Forwards a execution of SS_CANCEL_USSD_SEND_RESP message
* @param const TIsiReceiveC& aIsiMessage: The received ISI message
* @return void : None
*/
void SsGsmUssdSendResp( const TIsiReceiveC& aIsiMessage );
/**
* Construct a NET_MODEM_REG_STATUS_GET_REQ ISI message and send
* it through phonet.
* @param TUint8 aTransId: Transaction Id
* @return TInt: KErrNone / Error value from phonet
*/
TInt NetModemRegStatusGetReq( TUint8 aTransId );
/**
* Construct a NET_SET_REQ message and send it through phonet.
* @param TUint8 aTransId: Transaction Id
* @return TInt: KErrNone / Error value from phonet
*/
TInt NetSetReq( TUint8 aTransId );
/**
* Handles SsRequestComplete response ISI message
* @return void : None
*/
void SsRequestComplete();
/**
* Read field from SIM/USIM
* @param aSimFileInfo File info
* @return Error code
*/
TInt UiccReadFieldReq( RMmCustomAPI::TSimFileInfo& aSimFileInfo );
/**
* Response to read field request
* @param aStatus Status
* @param aFileData File data
* @return void
*/
void UiccReadFieldResp( TUint8 aStatus, const TDesC8& aFileData );
/**
* Read ciphering indicator status from SIM/USIM
* @param aTrId Transaction ID
* @return Error code
*/
TInt UiccReadCiReq( TInt aTrId );
/**
* Response to read CI request
* @param aStatus Status
* @param aTrId Transaction ID
* @param aFileData File data
* @return void
*/
void UiccReadCiResp(
TInt aStatus,
TInt aTrId,
const TDesC8& aFileData );
/**
* Read operator name from SIM/USIM
* @return Error code
*/
TInt UiccOperatorReq();
/**
* Response to read operator name request
* @param aStatus Status
* @param aFileData File data
* @return none
*/
void UiccOperatorResp( TUint8 aStatus, const TDesC8& aFileData );
/**
* Disconnects UICC server from smartcard and
* activates UICC SAP APDU interface
* @return Error code
*/
TInt UiccSimPowerOffReq();
/**
* Handles responses to SIM power off
* @param aStatus Status
* @return none
*/
void UiccSimPowerOffResp( TInt aStatus );
/**
* Requests SIM warm reset
* @return Error code
*/
TInt UiccSimWarmResetReq();
/**
* Response to SIM warm reset
* @param aStatus Status
* @return none
*/
void UiccSimWarmResetResp( TInt aStatus );
/**
* Requests Get ATR
* @return Error code
*/
TInt UiccSimGetAtrReq();
/**
* Handles responses to SIM Get ATR
* @param aStatus Status
* @param aFileData File data
* @return none
*/
void UiccSimGetAtrResp( TInt aStatus, const TDesC8& aFileData );
/**
* Connects UICC server to smartcard and
* deactivates UICC SAP APDU interface
* @return Error code
*/
TInt UiccSimPowerOnReq();
/**
* Handles responses to SIM power off
* @param aStatus Status
* @return none
*/
void UiccSimPowerOnResp( TInt aStatus );
/**
* Sends APDU to UICC
* @param aApduParameters APDU parameters
* @param aTraId transaction id
* @return Error code
*/
TInt UiccSendAPDUReq(
const RMmCustomAPI::TApduParameters& aApduParameters,
TInt aTraId );
/**
* Handles responses to UICC_APDU_RESP
* @param aStatus Status
* @param aFileData File data
* @param aTraId transaction id
* @return none
*/
void UiccSendAPDUResp(
TInt aStatus,
const TDesC8& aFileData,
TInt aTraId );
/**
* Sends UICC_CARD_REQ
* @return Error code
*/
TInt UiccCardReaderStatusReq();
/**
* Handles responses for Card Reader Status req
* @param aStatus Status
* @param aFileData File data
* @return none
*/
void UiccCardReaderStatusResp( TInt aStatus, const TDesC8& aFileData );
/**
* Handles UICC_CARD_IND
* @param aIsiMessage Received ISI message
* @return void
*/
void UiccCardInd( const TIsiReceiveC& aIsiMessage );
/**
* Read CB message IDs from UICC
* @param aTraId Transaction identification
* @return Error code
*/
TInt UiccReadCbMsgIdsReq( TUiccTrId aTrId );
/**
* Response to read CB message IDs from UICC
* @param aStatus Status
* @param aTraId Transaction ID
* @param aFileData File data
* @return void
*/
void UiccReadCbMsgIdsResp(
TUint8 aStatus,
TInt aTraId,
const TDesC8& aFileData );
/**
* Response to delete CB message ID request
* @param aStatus Status
* @return void
*/
void UiccDeleteCbMsgIdResp( TUint8 aStatus );
/**
* Read home zone parameters from UICC
* @return Error code
*/
TInt UiccReadViagHomeZoneParametersReq();
/**
* Response read home zone parameters request
* @param aStatus Status
* @param aFileData File data
* @return void
*/
void UiccReadViagHomeZoneParametersResp(
TUint8 aStatus,
const TDesC8& aFileData );
/**
* Read home zone cache from UICC
* @params aRecordId Record identifier
* @return Error code
*/
TInt UiccReadViagHomeZoneCacheReq(
const RMmCustomAPI::TViagCacheRecordId& aRecordId );
/**
* Response to read home zone cache request
* @param aStatus Status
* @param aFileData File data
* @return void
*/
void UiccReadViagHomeZoneCacheResp(
TUint8 aStatus,
const TDesC8& aFileData );
/**
* Request to write home zone settings
* @param aUhziuiSettings UHZIUI settings
* @return void
*/
TInt UiccWriteViagHomeZoneUhziueSettingsReq(
const RMmCustomAPI::TViagUHZIUESettings& aUhziuiSettings );
/**
* Response to write home zone settings
* @param aStatus Status
* @return void
*/
void UiccWriteViagHomeZoneUhziueSettingsResp( TUint8 aStatus );
/**
* Write Viag Home Zone cache from UICC
* @params aRecordId Record identifier
* @params aViagRecordContent Record content
* @return error code
*/
TInt UiccWriteViagHomeZoneCacheReq(
const RMmCustomAPI::TViagCacheRecordId& aRecordId,
const RMmCustomAPI::TViagCacheRecordContent& aViagRecordContent );
/**
* Response Write Viag Home Zone cache request
* @param aStatus Status
* @return void
*/
void UiccWriteViagHomeZoneCacheResp( TUint8 aStatus );
public: // Functions from base classes
/**
* ISI message for CustomMessageHandler received
* @param const TIsiReceiveC& aIsiMessage: reference to received ISI message
*/
void ReceiveMessageL( const TIsiReceiveC& aIsiMessage );
/**
* Handles errors comes from PhoNetReceiver RunError
* @param TIsiReceiveC& aIsiMessage: reference to received ISI message
* @param TInt aError: Error code
*/
void HandleError( const TIsiReceiveC& aIsiMessage, TInt aError );
/**
* From MMmMessHandlerBase. This method is the single entry point for
* requests coming from the Symbian OS layer to this message handler
* @since ?Series60_version
* @param aIpc IPC number of the request
* @return TInt KErrNone or error code
*/
TInt ExtFuncL( TInt aIpc, const CMmDataPackage* aDataPackage );
/**
* Handle UICC response messages
* @param aTraId Transaction ID
* @param aFileData Descriptor for file data
* @return KErrNone or error code
*/
TInt ProcessUiccMsg(
TInt aTraId,
TInt aStatus,
TUint8 aDetails,
const TDesC8& aFileData );
protected: // New functions
//None
protected: // Functions from base classes
//None
private:
/**
* C++ default constructor.
* @return void
*/
CMmCustomMessHandler();
/**
* Initialises object attributes.
* By default Symbian 2nd phase constructor is private.
* @return void
*/
void ConstructL();
/**
* Breaks a CALL_GSM_NOTIFICATION_IND ISI-message.
* @param const TIsiReceiveC& aIsiMsg: Received ISI message
* @return None
*/
void CallGsmNotificationInd( const TIsiReceiveC& aIsiMsg );
/**
* Handles Forwarding data from a CALL_GSM_NOTIFICATION_IND
* @param TUint16 aSsCode,
* @param const TIsiReceiveC& aIsiMsg,
* @param RMmCustomAPI::TSsTypeAndMode& aSsTypeAndMode
* @return None
*/
void HandleForwarding(
TUint16 aSsCode,
const TIsiReceiveC& aIsiMsg,
RMmCustomAPI::TSsTypeAndMode& aSsTypeAndMode ) const;
/**
* Handles Barring data from a CALL_GSM_NOTIFICATION_IND
* @param TUint16 aSsCode,
* @param const TIsiReceiveC& aIsiMsg,
* @param RMmCustomAPI::TSsTypeAndMode& aSsTypeAndMode
* @return None
*/
void HandleBarring(
TUint16 aSsCode,
const TIsiReceiveC& aIsiMsg,
RMmCustomAPI::TSsTypeAndMode& aSsTypeAndMode ) const;
/**
* Match function for making finds in the Ciphering list
* @param TCiphListEntry& aArg1: first argument for match
* @param TCiphListEntry& aArg2: secnd argument for the match
* @return TBool: if both arguments match
*/
static TBool Match(
const TCiphListEntry& aArg1,
const TCiphListEntry& aArg2 );
/**
* Breaks received NET_MODEM_REG_STATUS_GET_RESP ISI message
* @param TIsiReceiveC& aIsiMsg: The received ISI message
* @return void : None
*/
void NetModemRegStatusGetResp( const TIsiReceiveC& aIsiMsg );
/**
* Breaks received NET_SET_RESP ISI message
* @param TIsiReceiveC& aIsiMsg: The received ISI message
* @return void : None
*/
void NetSetResp( const TIsiReceiveC& aIsiMsg );
/**
* Breaks received SS_SERVICE_FAILED_RESP ISI message
* @param const TIsiReceiveC& aIsiMessage: The received ISI message
* @return void : None
*/
void SsServiceFailedResp( const TIsiReceiveC& aIsiMessage );
/**
* Construct a NET_RAT_REQ message and send it through phonet.
* @param TUint8 aTransId: Transaction Id
* @param TBool aCurrentRats: Use Current RAT setting
* @return TInt: KErrNone / Error value from phonet
*/
TInt NetRatReq( TUint8 aTransId, TBool aCurrentRats );
/**
* Breaks received NET_RAT_RESP ISI message
* @param TIsiReceiveC& aIsiMsg: The received ISI message
* @return void : None
*/
void NetRatResp( const TIsiReceiveC& aIsiMsg );
/**
* Construct a GSS_CS_SERVICE_REQ message and send it through phonet.
* @param TUint8 aTransId: Transaction Id
* @param RMmCustomAPI::TNetworkModeCaps: System network mode to set.
* @return TInt: KErrNone / Error value from phonet
*/
TInt GssCsServiceReq(
TUint8 aTransId,
RMmCustomAPI::TNetworkModeCaps aNetworkModeCaps );
/**
* Request for current RAT
* @param TUInt8 aTransId: Transaction Id
* @return TInt : result
*/
TInt GssCsServiceReq( TUint8 aTransId );
/**
* Breaks received GSS_CS_SERVICE_RESP ISI message
* @param const TIsiReceiveC& aIsiMessage: The received ISI message
* @return void : None
*/
void GssCsServiceResp( const TIsiReceiveC& aIsiMessage );
/**
* Breaks received GSS_CS_SERVICE_FAIL_RESP ISI message
* @param const TIsiReceiveC& aIsiMessage: The received ISI message
* @return void : None
*/
void GssCsServiceFailResp( const TIsiReceiveC& aIsiMessage );
/**
* Handles the ReadViagHomeZoneParamsResp response message.
* @param const TIsiReceiveC& aIsiMessage: a pointer to incoming message
* @return void
*/
void ReadViagHomeZoneParamsRespL( const TIsiReceiveC& aIsiMessage );
/**
* Handles the ReadViagHomeZoneCacheResp response message.
* @param const TIsiReceiveC& aIsiMessage: a pointer to incoming message
* @return void
*/
void ReadViagHomeZoneCacheResp( const TIsiReceiveC& aIsiMessage );
/**
* Handles the WriteViagHomeZoneCacheResp response message.
* @param const TIsiReceiveC& aIsiMessage: a pointer to incoming message
* @return void
*/
void WriteViagHomeZoneCacheResp( const TIsiReceiveC& aIsiMessage );
/**
* Construct and send to phonet GSS_HSXPA_USER_SETTING_WRITE_REQ
* ISI message.
* @param TUint8 aTraId: a transaction identification
* @param THSxPAStatus status:
* @return TInt: error code
*/
TInt WriteHSxPAStatusReq(
TUint8 aTraId,
RMmCustomAPI::THSxPAStatus status );
/**
* Breaks GSS_HSXPA_USER_SETTING_WRITE_RESP ISI message
* @param const TIsiReceiveC& aIsiMessage: the incoming message
* @return void
*/
void WriteHSxPAStatusResp( const TIsiReceiveC& aIsiMessage );
/**
* Construct and send to phonet GSS_HSXPA_USER_SETTING_READ_REQ
* ISI message.
* @param TUint8 aTraId: a transaction identification
* @return TInt: error code
*/
TInt ReadHSxPAStatusReq( TUint8 aTraId );
/**
* Breaks GSS_HSXPA_USER_SETTING_READ_RESP ISI message
* @param const TIsiReceiveC& aIsiMessage: the incoming message
* @return void
*/
void ReadHSxPAStatusResp( const TIsiReceiveC& aIsiMessage );
/**
* Breaks received GSS_HSXPA_SETTING_IND ISI messages
* @param const TIsiReceiveC& aIsiMsg: The received ISI message
* @return void : None
*/
void HSxPASettingInd( const TIsiReceiveC& aIsiMsg );
/**
* Construct a NET_NEIGHBOUR_CELLS_REQ message and send it through phonet.
* @param TUint8 aTraId: a transaction identification
* @return TInt: error code
*/
TInt NetNeighbourCellsReq( const TUint8 aTraId );
/**
* Breaks received NET_NEIGHBOUR_CELLS_RESP ISI messages.
* @param const TIsiReceiveC& aIsiMsg: The received ISI message
* @return void: None
*/
void NetNeighbourCellsResp( const TIsiReceiveC& aIsiMessage );
/**
* Breaks received NET_REG_STATUS_IND or NET_REG_STATUS_IND
* message and checks if enhanced cell information is chaged
* ( => needs to be requested/updated).
* @param const TIsiReceiveC& aIsiMessage: The received ISI message
* @return void: None
*/
void CheckECIDInfo( const TIsiReceiveC& aIsiMessage );
// Not suppoted for S60 ver 3.2
#if ( NCP_COMMON_S60_VERSION_SUPPORT != S60_VERSION_32 )
/**
* Construct a GSS_CS_SERVICE_REQ message including selected
* band mode and send it through phonet.
* @param TUint8 aTransId: Transaction Id
* @param RMmCustomAPI::TNetworkModeCaps: System network mode to set.
* @param RMmCustomAPI::TBandSelection: Selected band mode.
* @return TInt: KErrNone / Error value from phonet
*/
TInt GssCsServiceSetBandReq(
TUint8 aTransId,
RMmCustomAPI::TNetworkModeCaps aNetworkModeCaps,
RMmCustomAPI::TBandSelection aBandSelection );
/**
* Construct a GSS_CS_SERVICE_REQ message to get selected
* band mode.
* @param TUint8 aTransId: Transaction Id
* @return TInt: KErrNone / Error value from phonet
*/
TInt GssCsServiceGetBandReq( TUint8 aTransId );
/**
* Breaks received GSS_SELECTED_BANDS_READ operation.
* @param const TIsiReceiveC& aIsiMessage: The received ISI message
* @return void: None
*/
void CompleteGetBandSelection( const TIsiReceiveC& aIsiMessage );
#endif // NCP_COMMON_S60_VERSION_SUPPORT
/**
* Construcst PERM_PM_RECORD_READ_REQ message sends it through
* phonet.
* @param TUint8 aTransId: Transaction id.
* @return TInt: KErrNone / Error value from phonet.
*/
TInt ReadLifeTimerFromPermanentMemory( const TUint8 aTransId );
/**
* Breaks a PERM_PM_RECORD_READ_RESP ISI-message.
* @param const TIsiReceiveC& aIsiMessage: Received isi message.
* @return void: none
*/
void LifeTimerFromPermanentMemoryReadResponse(
const TIsiReceiveC& aIsiMessage );
/**
* Construcst PERM_PM_RECORD_WRITE_REQ message sends it through
* phonet.
* @param TUint8 aTransId: Transaction id.
* @return TInt: KErrNone / Error value from phonet / KErrNotReady if PMM
* has not been able to be read.
*/
TInt WriteLifeTimerToPermanentMemory(
const TUint8 aTransId,
TTimeIntervalSeconds aTime );
/**
* Breaks a PERM_PM_RECORD_WRITE_RESP ISI-message.
* @param const TIsiReceiveC& aIsiMessage: Received isi message.
* @return void: none
*/
void LifeTimerToPermanentMemoryWriteResponse(
const TIsiReceiveC& aIsiMessage );
/**
* Reads total call life timer value and returns it in complete.
* If
* @param none
* @return TInt: KErrNone / KErrNotReady if PMM has not been able to be
* read.
*/
TInt GetTotalLifeTimerValue();
/**
* Constructs and sends AUTHENTICATE APDU to the UICC
* @param aDataPackage: data containing authentication parameters
* @return TInt: KErrNone / Error value from phonet
*/
TInt CMmCustomMessHandler::UiccSendAuthenticateApdu(
const CMmDataPackage& aDataPackage );
/**
* Constructs RUN GSM ALGORITHM APDU. Used when authentication
* is done for ICC card
* @param aParams: parameter where the apdu is constructed
* @param aRand: RAND value inserted to the APDU
* @param aTraId: tr id used in UICC request
* @return void: none
*/
void UiccCreateRunGsmAlgorithmApdu(
TUiccSendApdu& aParams,
const TDesC8& aRand,
TUiccTrId aTraId );
/**
* Handles response APDU for RUN GSM ALGORITHM APDU
* @param aTraId: transaction id of received message
* @param aStatus: status of the response
* @param aFileData: response apdu
* @return void: none
*/
void UiccRunGsmAlgorithmApduResp(
TInt aTraId,
TInt aStatus,
const TDesC8& aFileData );
/**
* Constructs GSM context AUTHENTICATE APDU
* @param params: parameter where the apdu is constructed
* @param aDataPackage: data containing authentication parameters
* @return void: none
*/
void UiccCreateGsmSecurityContextApdu(
TUiccSendApdu& params,
const CMmDataPackage& aDataPackage );
/**
* Handles response APDU for GSM security context AUTHENTICATE APDU
* @param aTraId: transaction id of received message
* @param aStatus: status of the response
* @param aFileData: response apdu
* @return void: none
*/
void UiccGsmSecurityContextApduResp(
TInt aTraId,
TInt aStatus,
const TDesC8& aFileData );
/**
* Constructs 3G security context AUTHENTICATE APDU
* @param aParams: parameter where the apdu is constructed
* @param aRand: RAND value inserted to the APDU
* @param aAuth: AUTH value inserted to the APDU
* @param aTraId: tr id used in UICC request
* @return void: none
*/
void UiccCreate3GSecurityContextApdu(
TUiccSendApdu& aParams,
const TDesC8& aRand,
const TDesC8& aAuth,
TUiccTrId aTraId );
/**
* Handles response APDU for 3G security context AUTHENTICATE APDU
* @param aTraId: transaction id of received message
* @param aStatus: status of the response
* @param aFileData: response apdu
* @return void: none
*/
void Uicc3GSecurityContextApduResp(
TInt aTraId,
TInt aStatus,
const TDesC8& aFileData );
/**
* Constructs GBA security context AUTHENTICATE APDU (bootstrapping mode)
* @param aParams: parameter where the apdu is constructed
* @param aDataPackage: data containing authentication parameters
* @return void: none
*/
void UiccCreateGBABootstrappingApdu(
TUiccSendApdu& aParams,
const CMmDataPackage& aDataPackage );
/**
* Handles response APDU for GBA security context AUTHENTICATE
* APDU (bootstrapping mode)
* @param aTraId: transaction id of received message
* @param aStatus: status of the response
* @param aFileData: response apdu
* @return void: none
*/
void UiccGBABootstrappingApduResp(
TInt aTraId,
TInt aStatus,
const TDesC8& aFileData );
/**
* Starts GBA bootstrap operation by reading elementary file EFgba. After reading
* is done, B-Tid and keylifetime is updated to EFgba
* @param aDataPackage: data containing parameters going to be written
* to the EFgba
* @return void: none
*/
void UiccGBABootstrapUpdate(
const CMmDataPackage& aDataPackage );
/**
* Handles response for EFgba read operation
* @param aStatus: status of the response
* @param aFileData: file data
* @return void: none
*/
void UiccGBABootstrapReadResp(
TInt aStatus,
const TDesC8& aFileData );
/**
* Handles response for EFgba write operation
* @param aStatus: status of the response
* @return void: none
*/
void UiccGBABootstrapUpdateResp( TInt aStatus );
/**
* Constructs GBA security context AUTHENTICATE APDU
* (NAF derivation mode)
* @param aParams: parameter where the apdu is constructed
* @param aDataPackage: data containing authentication parameters
* @return void: none
*/
void UiccCreateGBABootstrapNafDerivationApdu(
TUiccSendApdu& aParams,
const CMmDataPackage& aDataPackage );
/**
* Handles response APDU for GBA security context AUTHENTICATE
* APDU (NAF derivation mode)
* @param aTraId: transaction id of received message
* @param aStatus: status of the response
* @param aFileData: response apdu
* @return void: none
*/
void UiccGBANafDerivationApduResp(
TInt aTraId,
TInt aStatus,
const TDesC8& aFileData );
/**
* Constructs MBMS security context AUTHENTICATE APDU
* (MSK Update Mode)
* @param params: parameter where the apdu is constructed
* @param aDataPackage: data containing authentication parameters
* @return void: none
*/
void UiccCreateMbmsMskUpdateApdu(
TUiccSendApdu& params,
const CMmDataPackage& aDataPackage );
/**
* Handles response APDU for MBMS security context AUTHENTICATE
* APDU (MSK Update Mode)
* @param aTraId: transaction id of received message
* @param aStatus: status of the response
* @param aFileData: response apdu
* @return void: none
*/
void UiccMbmsMskUpdateApduResp(
TInt aStatus,
const TDesC8& aFileData );
/**
* Constructs MBMS security context AUTHENTICATE APDU
* (MTK Generation Mode)
* @param params: parameter where the apdu is constructed
* @param aDataPackage: data containing authentication parameters
* @return void: none
*/
void UiccCreateMbmsMtkGenerationApdu(
TUiccSendApdu& params,
const CMmDataPackage& aDataPackage );
/**
* Handles response APDU for MBMS security context AUTHENTICATE
* APDU (MTK Generation Mode)
* @param aStatus: status of the response
* @param aFileData: response apdu
* @return void: none
*/
void UiccMbmsMtkGenerationApduResp(
TInt aStatus,
const TDesC8& aFileData );
/**
* Constructs MBMS security context AUTHENTICATE APDU
* (MSK Deletion Mode)
* @param params: parameter where the apdu is constructed
* @param aDataPackage: data containing authentication parameters
* @return void: none
*/
void UiccCreateMbmsMskDeletionApdu(
TUiccSendApdu& params,
const CMmDataPackage& aDataPackage );
/**
* Handles response APDU for MBMS security context AUTHENTICATE
* APDU (MSK Deletion Mode)
* @param aStatus: status of the response
* @param aFileData: response apdu
* @return void: none
*/
void UiccMbmsMskDeletionApduResp(
TInt aStatus,
const TDesC8& aFileData );
/**
* Constructs APDU to get first block of authenticate response data
* in case of odd ins code
* @return void: none
*/
void CMmCustomMessHandler::UiccCreateFirstBlockOfAuthRespApdu( TUiccTrId aTrId );
/**
* Maps sw1 and sw2 from response authenticate apdu to result
* @param sw1: status of the response
* @param sw2: response apdu
* @return TUint8: command result
*/
TUint8 MapSw1Sw2ToAuthenticateResult( TUint8 sw1, TUint8 sw2 );
/**
* Validates received apdu
* @param aTraId: Identifies the apdu
* @param aApdu: APDU to be verified
* @return TUint8: KApduOk if verified successfully,
* otherwise KApduNok
*/
TUint8 ValidateReceivedAuthenticateApdu(
TInt aTraId,
const TDesC8& aApdu );
/**
* Validates received gsm security context apdu for authenticate
* @param aApdu: APDU to be verified
* @return TUint8: KApduOk if verified successfully,
* otherwise KApduNok
*/
TUint8 ValidateGsmSecurityContextApduResp( const TDesC8& aApdu );
/**
* Validates received 3G security context apdu for authenticate
* @param aApdu: APDU to be verified
* @return TUint8: KApduOk if verified successfully,
* otherwise KApduNok
*/
TUint8 Validate3GSecurityContextApduResp( const TDesC8& aApdu );
/**
* Validates received GBA security context apdu (GBA bootstrapping mode)
* for authenticate
* @param aApdu: APDU to be verified
* @return TUint8: KApduOk if verified successfully,
* otherwise KApduNok
*/
TUint8 ValidateGBABootstrappingApduResp( const TDesC8& aApdu );
/**
* Validates received GBA security context apdu (GBA NAF derivation mode)
* for authenticate
* @param aApdu: APDU to be verified
* @return TUint8: KApduOk if verified successfully,
* otherwise KApduNok
*/
TUint8 ValidateGBANafDerivationApduResp( const TDesC8& aApdu );
/**
* Validates received RUN GSM ALGORITHM apdu for authenticate
* @param aApdu: APDU to be verified
* @return TUint8: KApduOk if verified successfully,
* otherwise KApduNok
*/
TUint8 ValidateRunGsmAlgorithmApduResp( const TDesC8& aApdu );
/**
* Handles MBMS operation data from received MSK Update
* authenticate APDU
* @param aMskUpdate: parameters from MBMS operation data are
* inserted to aMskUpdate
* @param aMbmsData: MBMS data got from MSK Update authenticate
* APDU
* @return void: none
*/
void UiccMskUpdateHandleMbmsOperationData(
RMmCustomAPI::TSimAuthenticationMgvMskUpdate& aMskUpdate,
TDesC8& aMbmsData );
/**
* Handles OMA BCAST operation data from received authenticate
* APDU
* @param aMskUpdate: parameters from MBMS operation data are
* inserted to aMskUpdate
* @param aMbmsData: APDU data
* @return void: none
*/
void UiccMskUpdateHandleOMABcastOperationData(
RMmCustomAPI::TSimAuthenticationMgvMskUpdate& aMskUpdate,
TDesC8& aMbmsData );
/**
* Handles MBMS operation data from received MTK Generation
* authenticate APDU
* @param aMskUpdate: parameters from MBMS operation data are
* inserted to aMskUpdate
* @param aMbmsData: APDU data
* @return void: none
*/
void UiccMtkGenHandleMbmsOperationData(
RMmCustomAPI::TSimAuthenticationMgvMtkGeneration& aMtkGen,
TDesC8& aMbmsData );
/**
* Handles OMA BCAST operation data from received MTK Generation
* authenticate APDU
* @param aMtkGen: parameters from MBMS operation data are
* inserted to aMtkGen
* @param aMbmsData: APDU data
* @return void: none
*/
void UiccMtkGenHandleOMABcastOperationData(
RMmCustomAPI::TSimAuthenticationMgvMtkGeneration& aMtkGen,
TDesC8& aMbmsData );
/**
* Finds tlv objects from BER TLV object
* @param aTlvTag: tag of teh tlv object to be search
* @param aBerTlv: BER TLV object where to search
* @param aTlvObject: tlv object data is copied to this
* parameter, if it's found
* @return TBool: ETrue if tlv object found, otherwise EFalse
*/
TBool FindTlvObject(
TUint8 aTlvTag,
const TDesC8& aBerTlv,
TDes8& aTlvObject );
/**
* calculates the UMTS Ciphering Key (CK) from the GSM
* Ciphering Key (Kc). This is done by using the c4 algorithm defined in
* 3GPP TS 33.102 v3.8.0 (Release 1999).
* @param aCk: Result is inserted to this parameter
* @param aKc: Kc which is used in calculation
* @return void: none
*/
void DeriveCkFromKc(
TDes8& aCk,
const TDesC8& aKc );
/** derives the UMTS Integrity Key (IK) from the GSM
* Ciphering Key (Kc). This is done by using the c5 algorithm defined in
* 3GPP TS 33.102 v3.8.0 (release 1999).
* @param aEapAka: Result is inserted to this parameter
* @param aKc: Kc which is used in calculation
* @return void: none
*/
void DeriveIkFromKc(
TDes8& aIk,
const TDesC8& aKc );
/** Handles the IMS authentication
* @param aDataPackage: data containing authentication parameters
* @return TInt: KErrNone / Error value from phonet
*/
TInt UiccHandleImsAuthentication( const CMmDataPackage& aDataPackage );
/**
* Handles response for ISim application activation
* @param aStatus: status of the response
* @return void: none
*/
void UiccHandleIsimActivationResp( TInt aStatus );
/**
* Collects cellbroadcast topic IDs into array. Leaves if nothig found
* @param aFileData elementary file data
* @return array with topic IDs
*/
CArrayFixFlat<RMmCustomAPI::TSimCbTopic>* CollectCbTopicIdsL(
const TDesC16& aTopicIds ) const;
protected: // Data
// Pointer to the PhonetSender
CMmPhoNetSender* iPhoNetSender;
private: // Data
// Pointer to the Message router
CMmMessageRouter* iMessageRouter;
// Pointer to the Net message handler
CMmNetMessHandler* iNetMessHandler;
// Pointer to the Security message handler
CMmSecurityMessHandler* iSecurityMessHandler;
// Release cause value sent
TUint8 iReleaseCauseValueSent;
// List of Ciphering values, for buffering purpose
RArray<TCiphListEntry> *iListOfCiphValues;
// Is indication a refresh indication
TBool iIsRefresh;
// Emergency number checking mode
RMmCustomAPI::TCheckMode iUsedEmergencyNbrCheckMode;
// Lenght of the emergency number to be checked
TInt iEmergencyNumberLength;
// Buffer to hold RAND_PARAMS subblock data
TBuf8<20> iRandBuf;
// Buffer to hold AUTN_PARAMS subblock data
TBuf8<20> iAutnBuf;
// Buffer to hold B-Tid data
TBuf8<256> iBTidBuf;
// Buffer to hold keylifetime data
TBuf8<256> iKeyLifetimeBuf;
// Buffer to hold SIM_SB_AM_GBA_NAF_ID_ID subblock data
TBuf8<254> iNafIdBuf;
// Buffer to hold SIM_SB_IMS_PRIVATE_USER_ID subblock data
TBuf8<254> iImpiBuf;
// Buffer for Mikey data.
RMmCustomAPI::TMikey iMikey;
// Buffer for key domain id data
RMmCustomAPI::TKeyDomainId iKeyDomainId;
// Buffer for key group id data
RMmCustomAPI::TKeyGroupId iKeyGroupIdPart;
// Viag Home Zone Parameters
RMmCustomAPI::TViagParams iViagParams;
// Cb msg ids max count
TInt iCbMsgIdsMaxCount;
// Saves the SIM CB topic number for deletion
TUint16 iSimCBTopicToBeDeleted;
// Is the SIM topic is being deleted (ETrue ) or not (EFalse)
TBool iTopicInSimMemoryDelete;
// Enhanced Cell Information
TECIDInfo iECIDInfo;
// Is ECIDInfo requested
TBool iECIDInfoRequested;
// Call Life Timer;
TInt iCallLifeTimer;
// Conter for record retries from PMM during read.
TUint8 iPMMReadRetryCounter;
// Pointer to UICC message handler
CMmUiccMessHandler* iMmUiccMessHandler;
//keeps track...
TUint8 iSapApduIfState;
// is Isim application already activated
TBool iIsimApplActivated;
public: // Friend classes
//None
protected: // Friend classes
//None
private: // Friend classes
//None
};
#endif // _CMMCUSTOMMESSHANDLER_H
// End of File
| [
"dalarub@localhost",
"mikaruus@localhost",
"[email protected]"
] | [
[
[
1,
1
],
[
3,
13
],
[
15,
97
],
[
99,
99
],
[
102,
213
],
[
215,
416
],
[
418,
449
],
[
451,
520
],
[
522,
564
],
[
566,
573
],
[
575,
588
],
[
590,
606
],
[
608,
622
],
[
624,
639
],
[
641,
641
],
[
643,
674
],
[
676,
785
],
[
793,
966
],
[
968,
972
],
[
974,
985
],
[
987,
1007
],
[
1010,
1031
],
[
1035,
1056
],
[
1058,
1060
],
[
1062,
1073
],
[
1075,
1100
],
[
1102,
1107
],
[
1109,
1111
],
[
1113,
1124
],
[
1126,
1131
],
[
1133,
1135
],
[
1137,
1147
],
[
1149,
1154
],
[
1156,
1158
],
[
1160,
1169
],
[
1171,
1176
],
[
1178,
1180
],
[
1182,
1198
],
[
1200,
1209
],
[
1211,
1212
],
[
1215,
1219
],
[
1221,
1227
],
[
1229,
1236
],
[
1238,
1245
],
[
1247,
1253
],
[
1255,
1279
],
[
1281,
1291
],
[
1293,
1303
],
[
1305,
1311
],
[
1313,
1328
],
[
1330,
1356
],
[
1365,
1429
],
[
1431,
1466
]
],
[
[
2,
2
],
[
98,
98
],
[
214,
214
],
[
417,
417
],
[
450,
450
],
[
565,
565
],
[
574,
574
],
[
589,
589
],
[
607,
607
],
[
623,
623
],
[
640,
640
],
[
642,
642
],
[
1357,
1364
],
[
1430,
1430
]
],
[
[
14,
14
],
[
100,
101
],
[
521,
521
],
[
675,
675
],
[
786,
792
],
[
967,
967
],
[
973,
973
],
[
986,
986
],
[
1008,
1009
],
[
1032,
1034
],
[
1057,
1057
],
[
1061,
1061
],
[
1074,
1074
],
[
1101,
1101
],
[
1108,
1108
],
[
1112,
1112
],
[
1125,
1125
],
[
1132,
1132
],
[
1136,
1136
],
[
1148,
1148
],
[
1155,
1155
],
[
1159,
1159
],
[
1170,
1170
],
[
1177,
1177
],
[
1181,
1181
],
[
1199,
1199
],
[
1210,
1210
],
[
1213,
1214
],
[
1220,
1220
],
[
1228,
1228
],
[
1237,
1237
],
[
1246,
1246
],
[
1254,
1254
],
[
1280,
1280
],
[
1292,
1292
],
[
1304,
1304
],
[
1312,
1312
],
[
1329,
1329
]
]
] |
8a6b20f7142cb95938a1a9eaef6126127ebace72 | d8f64a24453c6f077426ea58aaa7313aafafc75c | /BinaryHeap.cpp | 3d453384b18ad33850ac165422d4f662782ee069 | [] | no_license | dotted/wfto | 5b98591645f3ddd72cad33736da5def09484a339 | 6eebb66384e6eb519401bdd649ae986d94bcaf27 | refs/heads/master | 2021-01-20T06:25:20.468978 | 2010-11-04T21:01:51 | 2010-11-04T21:01:51 | 32,183,921 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,107 | cpp | #include "BinaryHeap.h"
//Reset the heap
void BinaryHeap::ResetHeap()
{
lSize = 0;
Heap.resize(lSize+1);
Heap.reserve(85*85*sizeof(BinHeapData));
}
//Remove the Root Object from the heap
void BinaryHeap::RemoveRoot()
{
//If only the root exists
if(lSize <= 1)
{
ResetHeap();
return;
}
//First copy the very bottom object to the top
Heap[1] = Heap[lSize];
//Resize the count
lSize -= 1;
//Shrink the array
Heap.pop_back();
//Sort the top item to it's correct position
int Parent = 1;
int ChildIndex = 1;
//Sink the item to it's correct location
while(true)
{
ChildIndex = Parent;
if(2 * ChildIndex + 1 <= lSize)
{
//Find the lowest value of the 2 child nodes
if (Heap[ChildIndex].Score >= Heap[2 * ChildIndex].Score)
Parent = 2 * ChildIndex;
if(Heap[Parent].Score >= Heap[2 * ChildIndex + 1].Score)
Parent = 2 * ChildIndex + 1;
}
else //Just process the one node
{
if(2 * ChildIndex <= lSize)
{
if(Heap[ChildIndex].Score >= Heap[2 * ChildIndex].Score)
Parent = 2 * ChildIndex;
}
}
//Swap out the child/parent
if(Parent != ChildIndex)
{
BinHeapData tHeap = Heap[ChildIndex];
Heap[ChildIndex] = Heap[Parent];
Heap[Parent] = tHeap;
}
else
{
return;
}
}
}
//Add the new element to the heap
void BinaryHeap::Add(int inScore,int inX, int inY)
{
//**We will be ignoring the (0) place in the heap array because
//**it's easier to handle the heap with a base of (1..?)
//Increment the array count
lSize += 1;
BinHeapData tmp;
tmp.Score = inScore;
tmp.X = inX;
tmp.Y = inY;
//Heap.resize(lSize);
//Heap[lSize].Score = inScore;
//Heap[lSize].X = inX;
//Heap[lSize].Y = inY;
Heap.push_back(tmp);
//Bubble the item to its correct location
int sPos = lSize;
while(sPos != 1)
{
if(Heap[sPos].Score <= Heap[sPos / 2].Score)
{
BinHeapData tHeap = Heap[sPos / 2];
Heap[sPos / 2] = Heap[sPos];
Heap[sPos] = tHeap;
sPos /= 2;
}
else
{
return;
}
}
} | [
"[email protected]"
] | [
[
[
1,
104
]
]
] |
5fac9322a4649916f76c26039c4b72a68aabb06f | c2153dcfa8bcf5b6d7f187e5a337b904ad9f91ac | /depends/ClanLib/src/Core/System/console_window.cpp | 383eb3054125904f78a8bd005459d22325bbbb23 | [] | 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 | 1,916 | cpp | /*
** 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
** (if your name is missing here, please add it)
*/
#include "precomp.h"
#include "API/Core/System/console_window.h"
#include "console_window_generic.h"
/////////////////////////////////////////////////////////////////////////////
// CL_ConsoleWindow construction:
CL_ConsoleWindow::CL_ConsoleWindow(
const CL_StringRef &title,
int width,
int height)
: impl(NULL)
{
impl = new CL_ConsoleWindow_Generic(title, width, height);
}
CL_ConsoleWindow::~CL_ConsoleWindow()
{
delete impl;
}
/////////////////////////////////////////////////////////////////////////////
// CL_ConsoleWindow operations:
void CL_ConsoleWindow::wait_for_key()
{
impl->wait_for_key();
}
void CL_ConsoleWindow::display_close_message()
{
impl->display_close_message();
}
| [
"[email protected]@c628178a-a759-096a-d0f3-7c7507b30227"
] | [
[
[
1,
62
]
]
] |
2d87d30d46765b5807b0b0731c718570ba0581a5 | 2e5fd1fc05c0d3b28f64abc99f358145c3ddd658 | /fixlib/source/Subscription.cpp | d2f940a6935b17d906459d56c7a3beaea0363bce | [] | no_license | indraj/fixfeed | 9365c51e2b622eaff4ce5fac5b86bea86415c1e4 | 5ea71aab502c459da61862eaea2b78859b0c3ab3 | refs/heads/master | 2020-12-25T10:41:39.427032 | 2011-02-15T13:38:34 | 2011-02-15T20:50:08 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 29 | cpp | #include "Subscription.h"
| [
"[email protected]"
] | [
[
[
1,
2
]
]
] |
0825456739787a1a575e946d2e284f54183924dc | 14e30c5f520f0ed28117914101d9bdf2f3d5dac7 | /project/source/renderer/renderer.h | b50abe1b5e855b08461353ee19471a8432bedb56 | [] | no_license | danielePiracci/arlight | f356eb5a162d0cd62a759720cbc6da41a820642f | 15a68c4c80c97f2fe7458e7ddf03f3e1063e25a4 | refs/heads/master | 2016-08-11T13:45:35.252916 | 2011-01-24T20:22:50 | 2011-01-24T20:22:50 | 44,962,821 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,398 | h | /// \file renderer/renderer.h
/// \author Juan Carlos De Abreu ([email protected])
/// \date 2009/11/07
/// \version 1.0
///
/// \brief This file declares the DissertationProject::Renderer class,
/// which implement the basic functionalities of a renderer.
#ifndef RENDERER_H__
#define RENDERER_H__
#include "global.h"
#include "math/vector.h"
#include "texture/texture_manager.h"
#include "renderer/mesh_renderer.h"
#include "vector"
BEGIN_PROJECT_NAMESPACE();
// Forward-declare the Camera, Light Material and Mesh classes.
class Camera;
class Light;
class Material;
class Renderer {
public:
/// \brief Standard constructor.
Renderer();
/// \brief Default destructor.
virtual ~Renderer();
/// \brrief Method to get a new texture object.
virtual boost::shared_ptr<Texture> GetNewTexture() const = 0;
/// \brief Method to get a new mesh renderer object.
virtual boost::shared_ptr<MeshRenderer> GetNewMeshRenderer() const = 0;
/*
/// \brief Method to start the render.
virtual void BeginRender() = 0;
/// \brief Method to finish the render.
virtual void EndRender() = 0;
/// \brief Method to clear the renderer buffers.
/// \param[in] color Default color for the color buffer.
virtual void ClearBuffer(const vec4i& color) = 0;
/// \brief Method to load a mesh.
/// \param[in] file_path Mesh file path.
virtual void LoadMesh(const std::string& file_path) = 0;
/// \brief Method to set up a camera.
/// \param[in] camera Camera to be used in the renderer.
virtual void SetCamera(const Camera& camera) = 0;
/// \brief Method to display a mesh.
/// \param[in] mesh file path of the mesh that will be rendered.
/// \param[in] apply_material Flag to know if the mesh will apply the
/// material.
virtual void RenderMesh(const std::string& file_path,
bool apply_material = true) = 0;
///// \brief Method to display a mesh.
///// \param[in] mesh Mesh that will be rendered.
///// \param[in] apply_material Flag to know if the mesh will apply the
///// material.
//virtual void RenderMesh(Mesh<MeshHandler>& mesh,
// bool apply_material = true) = 0;
/// \brief Method to render a box.
virtual void RenderBox() = 0;
/// \brief Method to start the use of a light.
/// \param[in] light Light that will be enable.
virtual void EnableLight(const Light& light) = 0;
/// \brief Method to stop the use of a light.
/// \param[in] light Light that will be disable.
virtual void DisableLight(const Light& light) = 0;
/// \brief Method to start the use of a material.
/// \param[in] material Material that will be enable.
virtual void EnableMaterial(const Material& material) = 0;
/// \brief Method to stop the use of a material.
/// \param[in] material Material that will be disable.
virtual void DisableMaterial(const Material& material) = 0;
/// \brief Method to enable the use of the depth buffer.
virtual void EnableDepthBuffer() = 0;
/// \brief Method to disable the use of the depth buffer.
virtual void DisableDepthBuffer() = 0;
/// \brief Method to enable the use of alpha blending.
virtual void EnableAlphaBlending() = 0;
/// \brief Method to disable the use of alpha blending.
virtual void DisableAlphaBlending() = 0;
/// \brief Method to enable the use of the stencil buffer.
virtual void EnableStencilBuffer() = 0;
/// \brief Method to disable the use of the stencil buffer.
virtual void DisableStencilBuffer() = 0;
/// \brief Method to start the use of stencil shadows.
virtual void EnableStencilShadow() = 0;
/// \brief Method to stop the use of stencil shadows.
virtual void DisableStencilShadow() = 0;
/// \brief Method to start the use of stencil for reflexion.
virtual void EnableStencilReflexion() = 0;
/// \brief Method to stop the use of stencil for reflexion.
virtual void DisableStencilReflexion() = 0;
/// \brief Method to set the current matrix as identity.
virtual void LoadIdentity() = 0;
/// \brief Method to apply the current matrix.
virtual void ApplyTransformations() = 0;
/// \brief Method to apply a scale to the current matrix.
/// \param[in] x Scale factor in x axis.
/// \param[in] y Scale factor in y axis.
/// \param[in] z Scale factor in z axis.
virtual void Scale(float x, float y, float z) = 0;
/// \brief Method to apply a tranlation to the current matrix.
/// \param[in] x Translate factor in x axis.
/// \param[in] y Translate factor in y axis.
/// \param[in] z Translate factor in z axis.
virtual void Translate(float x, float y, float z) = 0;
/// \brief Method to apply a rotation over the x axis.
/// \param[in] angle Angle of rotation over the x axis.
virtual void RotateX(float angle) = 0;
/// \brief Method to apply a rotation over the y axis.
/// \param[in] angle Angle of rotation over the y axis.
virtual void RotateY(float angle) = 0;
/// \brief Method to apply a rotation over the z axis.
/// \param[in] angle Angle of rotation over the z axis.
virtual void RotateZ(float angle) = 0;
/// \brief Method to multiply the matrix by the current matrix.
/// \param[in] matrix Matrix to multiply by the current matrix.
virtual void Multiply(const float* matrix) = 0;
/// \brief Method to create a shadow matrix and then multiply it by the
/// current matrix.
/// \param[in] light Light used to calculate the shadow matrix.
/// \param[in] plane Plane used to calculate the shadow matrix.
virtual void ShadowMatrix(const vec4f& light, const vec4f& plane) = 0;
/// \brief Method to push the current matrix in the matrixes list.
virtual void PushMatrix() = 0;
/// \brief Method to pop the last matrix in the matrixes list.
virtual void PopMatrix() = 0;
/// \brief Method to render a text message.
virtual void DrawText(int left, int top, int height, int width, const std::string& message) = 0;
/// \brief Method to set the render fill mode.
virtual void SetFillMode(int fill_mode) = 0;
*/
enum FillMode {
FILL_POINT = 1,
FILL_WIREFRAME = 2,
FILL_SOLID = 3,
};
private:
DISALLOW_COPY_AND_ASSIGN(Renderer);
};
END_PROJECT_NAMESPACE();
#endif // RENDERER_H__
| [
"jcabreur@db05138c-34b8-7cfb-67b9-2db12d2e1ab0"
] | [
[
[
1,
185
]
]
] |
9805816eddb823f31d9273b645357a3e18a7d892 | c1c3866586c56ec921cd8c9a690e88ac471adfc8 | /Practise_2005/DXDigitalClock/main.cpp | bf6faffe54e87b101a13c4dfbc418b716b0edc1c | [] | no_license | rtmpnewbie/lai3d | 0802dbb5ebe67be2b28d9e8a4d1cc83b4f36b14f | b44c9edfb81fde2b40e180a651793fec7d0e617d | refs/heads/master | 2021-01-10T04:29:07.463289 | 2011-03-22T17:51:24 | 2011-03-22T17:51:24 | 36,842,700 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,725 | cpp | #include "DXDigitalClock.h"
CDXDigitalClock* pClock = NULL;
CDXDigitalClock* pClockAnother = NULL;
//-----------------------------------------------------------------------------
// Name: InitD3D()
// Desc: Initializes Direct3D
//-----------------------------------------------------------------------------
HRESULT InitD3D( HWND hWnd )
{
// Create the D3D object.
if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
return E_FAIL;
// Set up the structure used to create the D3DDevice
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory( &d3dpp, sizeof(d3dpp) );
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
// Create the D3DDevice
if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp, &g_pd3dDevice ) ) )
{
return E_FAIL;
}
// Device state would normally be set here
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: Cleanup()
// Desc: Releases all previously initialized objects
//-----------------------------------------------------------------------------
VOID Cleanup()
{
if( g_pVB != NULL )
g_pVB->Release();
if( g_pd3dDevice != NULL )
g_pd3dDevice->Release();
if( g_pD3D != NULL )
g_pD3D->Release();
if (pClock != NULL)
{
delete pClock;
}
if (pClockAnother != NULL)
{
delete pClockAnother;
}
}
//-----------------------------------------------------------------------------
// Name: Render()
// Desc: Draws the scene
//-----------------------------------------------------------------------------
VOID Render()
{
// Clear the backbuffer to a blue color
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0 );
// Begin the scene
if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
{
if (pClock)
{
pClock->Scale(2.0f);
pClock->DrawTime(30.0f,30.0f);
pClock->Scale(0.5f);
pClock->DrawTime(30.0f,330.0f);
}
if (pClockAnother)
{
pClockAnother->DrawTime(0.0f, 0.0f);
}
g_pd3dDevice->EndScene();
}
// Present the backbuffer contents to the display
g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
//-----------------------------------------------------------------------------
// Name: MsgProc()
// Desc: The window's message handler
//-----------------------------------------------------------------------------
LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch( msg )
{
case WM_DESTROY:
Cleanup();
PostQuitMessage( 0 );
return 0;
}
return DefWindowProc( hWnd, msg, wParam, lParam );
}
VOID SetupMatrices()
{
D3DXMATRIXA16 matWorld;
FLOAT fAngle = 90 * (2.0f * D3DX_PI) / 360.0f;
D3DXMatrixRotationZ( &matWorld, fAngle );
g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
D3DXVECTOR3 vEyePt( 0.0f, 3.0f,-5.0f );
D3DXVECTOR3 vLookatPt( 0.0f, 0.0f, 0.0f );
D3DXVECTOR3 vUpVec( 0.0f, 1.0f, 0.0f );
D3DXMATRIXA16 matView;
D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec );
g_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
D3DXMATRIXA16 matProj;
D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.0f, 1.0f, 100.0f );
g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
}
//-----------------------------------------------------------------------------
// Name: WinMain()
// Desc: The application's entry point
//-----------------------------------------------------------------------------
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT )
{
// Register the window class
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L,
GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
"D3D Tutorial", NULL };
RegisterClassEx( &wc );
// Create the application's window
HWND hWnd = CreateWindow( "D3D Tutorial", "DxDigitalClock",
WS_OVERLAPPEDWINDOW, 100, 100, 800, 600,
NULL, NULL, wc.hInstance, NULL );
// Initialize Direct3D
if( SUCCEEDED( InitD3D( hWnd ) ) )
{
pClock = new CDXDigitalClock();
pClock->Scale(2.0f);
pClockAnother = new CDXDigitalClock();
pClockAnother->Scale(0.3f);
SetupMatrices();
// Show the window
ShowWindow( hWnd, SW_SHOWDEFAULT );
UpdateWindow( hWnd );
// Enter the message loop
MSG msg;
ZeroMemory( &msg, sizeof(msg) );
while( msg.message!=WM_QUIT )
{
if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
else
Render();
}
}
UnregisterClass( "D3D Tutorial", wc.hInstance );
return 0;
} | [
"laiyanlin@27d9c402-1b7e-11de-9433-ad2e3fad96c5"
] | [
[
[
1,
179
]
]
] |
a65c4d5b95e6f10200eadf10f4783696a874e796 | 0508304aeb1d50db67a090eecb7436b13f06583d | /nemo/headers/private/print/libprint/Transport.h | 8e0b5369c61c629b94a10a61e7d1503e79140939 | [] | no_license | BackupTheBerlios/nemo | 229a7c64901162cf8359f7ddb3a7dd4d05763196 | 1511021681e9efd91e394191bb00313f0112c628 | refs/heads/master | 2016-08-03T16:33:46.947041 | 2004-04-28T01:51:58 | 2004-04-28T01:51:58 | 40,045,282 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,236 | h | /*
* Transport.h
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/
#ifndef __TRANSPORT_H
#define __TRANSPORT_H
#include <image.h>
#include <string>
class BDataIO;
class PrinterData;
#if (!__MWERKS__ || defined(MSIPL_USING_NAMESPACE))
using namespace std;
#else
#define std
#endif
extern "C" {
typedef BDataIO *(*PFN_init_transport)(BMessage *);
typedef void (*PFN_exit_transport)(void);
}
class TransportException {
private:
string __str;
public:
TransportException(const string &what_arg) : __str(what_arg) {}
const char *what() const { return __str.c_str(); }
};
class Transport {
public:
Transport(const PrinterData *printer_data);
~Transport();
void write(const void *buffer, size_t size) throw(TransportException);
bool check_abort() const;
const string &last_error() const;
protected:
void set_last_error(const char *e);
Transport(const Transport &);
Transport &operator = (const Transport &);
private:
image_id __image;
PFN_init_transport __init_transport;
PFN_exit_transport __exit_transport;
BDataIO *__data_stream;
bool __abort;
string __last_error_string;
};
#endif // __TRANSPORT_H
| [
"fadi_edward"
] | [
[
[
1,
56
]
]
] |
1743563356c67a1b0f6ad26b5e334f2710b94148 | 91b964984762870246a2a71cb32187eb9e85d74e | /SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/iostreams/test/detail/utf8_codecvt_facet.cpp | 977ff60a6f249039497618fddd51de99b64a8b28 | [
"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 | WINDOWS-1252 | C++ | false | false | 12,109 | cpp | /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// utf8_codecvt_facet.cpp
// Copyright © 2001 Ronald Garcia, Indiana University ([email protected])
// Andrew Lumsdaine, Indiana University ([email protected]).
// Distributed under the Boost Software License, Version 1.0. (See accompany-
// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org/libs/iostreams for documentation.
//#include <cstdlib> // for multi-byte converson routines
// Jonathan Turkanis:
// - Replaced test for BOOST_NO_STD_WSTREAMBUF with test for
// BOOST_IOSTREAMS_NO_WIDE_STREAMS;
// - Derived from codecvt_helper instead of codecvt.
#include <boost/config.hpp>
#include <boost/iostreams/detail/config/wide_streams.hpp>
#ifdef BOOST_IOSTREAMS_NO_LOCALES
# error "C++ locales not supported on this platform"
#else
#include <cassert>
#include <cstddef>
#include <boost/detail/workaround.hpp>
#include "./utf8_codecvt_facet.hpp"
#if BOOST_WORKAROUND(__BORLANDC__, <= 0x600)
# pragma warn -sig // Conversion may lose significant digits
# pragma warn -rng // Constant is out of range in comparison
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// implementation for wchar_t
// Translate incoming UTF-8 into UCS-4
std::codecvt_base::result utf8_codecvt_facet_wchar_t::do_in(
std::mbstate_t&,
const char * from,
const char * from_end,
const char * & from_next,
wchar_t * to,
wchar_t * to_end,
wchar_t * & to_next
) const {
// Basic algorithm: The first octet determines how many
// octets total make up the UCS-4 character. The remaining
// "continuing octets" all begin with "10". To convert, subtract
// the amount that specifies the number of octets from the first
// octet. Subtract 0x80 (1000 0000) from each continuing octet,
// then mash the whole lot together. Note that each continuing
// octet only uses 6 bits as unique values, so only shift by
// multiples of 6 to combine.
while (from != from_end && to != to_end) {
// Error checking on the first octet
if (invalid_leading_octet(*from)){
from_next = from;
to_next = to;
return std::codecvt_base::error;
}
// The first octet is adjusted by a value dependent upon
// the number of "continuing octets" encoding the character
const int cont_octet_count = get_cont_octet_count(*from);
const wchar_t octet1_modifier_table[] = {
0x00, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc
};
// The unsigned char conversion is necessary in case char is
// signed (I learned this the hard way)
wchar_t ucs_result =
(unsigned char)(*from++) - octet1_modifier_table[cont_octet_count];
// Invariants :
// 1) At the start of the loop, 'i' continuing characters have been
// processed
// 2) *from points to the next continuing character to be processed.
int i = 0;
while(i != cont_octet_count && from != from_end) {
// Error checking on continuing characters
if (invalid_continuing_octet(*from)) {
from_next = from;
to_next = to;
return std::codecvt_base::error;
}
ucs_result *= (1 << 6);
// each continuing character has an extra (10xxxxxx)b attached to
// it that must be removed.
ucs_result += (unsigned char)(*from++) - 0x80;
++i;
}
// If the buffer ends with an incomplete unicode character...
if (from == from_end && i != cont_octet_count) {
// rewind "from" to before the current character translation
from_next = from - (i+1);
to_next = to;
return std::codecvt_base::partial;
}
*to++ = ucs_result;
}
from_next = from;
to_next = to;
// Were we done converting or did we run out of destination space?
if(from == from_end) return std::codecvt_base::ok;
else return std::codecvt_base::partial;
}
std::codecvt_base::result utf8_codecvt_facet_wchar_t::do_out(
std::mbstate_t &,
const wchar_t * from,
const wchar_t * from_end,
const wchar_t * & from_next,
char * to,
char * to_end,
char * & to_next
) const
{
// RG - consider merging this table with the other one
const wchar_t octet1_modifier_table[] = {
0x00, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc
};
while (from != from_end && to != to_end) {
#define BOOST_NULL // Prevent macro expansion
// Check for invalid UCS-4 character
if (*from > std::numeric_limits<wchar_t>::max BOOST_NULL ()) {
from_next = from;
to_next = to;
return std::codecvt_base::error;
}
#undef BOOST_NULL
int cont_octet_count = get_cont_octet_out_count(*from);
// RG - comment this formula better
int shift_exponent = (cont_octet_count) * 6;
// Process the first character
*to++ = octet1_modifier_table[cont_octet_count] +
(unsigned char)(*from / (1 << shift_exponent));
// Process the continuation characters
// Invariants: At the start of the loop:
// 1) 'i' continuing octets have been generated
// 2) '*to' points to the next location to place an octet
// 3) shift_exponent is 6 more than needed for the next octet
int i = 0;
while (i != cont_octet_count && to != to_end) {
shift_exponent -= 6;
*to++ = 0x80 + ((*from / (1 << shift_exponent)) % (1 << 6));
++i;
}
// If we filled up the out buffer before encoding the character
if(to == to_end && i != cont_octet_count) {
from_next = from;
to_next = to - (i+1);
return std::codecvt_base::partial;
}
*from++;
}
from_next = from;
to_next = to;
// Were we done or did we run out of destination space
if(from == from_end) return std::codecvt_base::ok;
else return std::codecvt_base::partial;
}
// How many char objects can I process to get <= max_limit
// wchar_t objects?
int utf8_codecvt_facet_wchar_t::do_length(
BOOST_IOSTREAMS_CODECVT_CV_QUALIFIER std::mbstate_t &,
const char * from,
const char * from_end,
std::size_t max_limit
) const throw()
{
// RG - this code is confusing! I need a better way to express it.
// and test cases.
// Invariants:
// 1) last_octet_count has the size of the last measured character
// 2) char_count holds the number of characters shown to fit
// within the bounds so far (no greater than max_limit)
// 3) from_next points to the octet 'last_octet_count' before the
// last measured character.
int last_octet_count=0;
std::size_t char_count = 0;
const char* from_next = from;
// Use "<" because the buffer may represent incomplete characters
while (from_next+last_octet_count <= from_end && char_count <= max_limit) {
from_next += last_octet_count;
last_octet_count = (get_octet_count(*from_next));
++char_count;
}
return from_next-from_end;
}
unsigned int utf8_codecvt_facet_wchar_t::get_octet_count(
unsigned char lead_octet
){
// if the 0-bit (MSB) is 0, then 1 character
if (lead_octet <= 0x7f) return 1;
// Otherwise the count number of consecutive 1 bits starting at MSB
assert(0xc0 <= lead_octet && lead_octet <= 0xfd);
if (0xc0 <= lead_octet && lead_octet <= 0xdf) return 2;
else if (0xe0 <= lead_octet && lead_octet <= 0xef) return 3;
else if (0xf0 <= lead_octet && lead_octet <= 0xf7) return 4;
else if (0xf8 <= lead_octet && lead_octet <= 0xfb) return 5;
else return 6;
}
namespace {
template<std::size_t s>
int get_cont_octet_out_count_impl(wchar_t word){
if (word < 0x80) {
return 0;
}
if (word < 0x800) {
return 1;
}
return 2;
}
// note the following code will generate on some platforms where
// wchar_t is defined as UCS2. The warnings are superfluous as
// the specialization is never instantitiated with such compilers.
template<>
int get_cont_octet_out_count_impl<4>(wchar_t word){
if (word < 0x80) {
return 0;
}
if (word < 0x800) {
return 1;
}
if (word < 0x10000) {
return 2;
}
if (word < 0x200000) {
return 3;
}
if (word < 0x4000000) {
return 4;
}
return 5;
}
} // namespace anonymous
// How many "continuing octets" will be needed for this word
// == total octets - 1.
int utf8_codecvt_facet_wchar_t::get_cont_octet_out_count(
wchar_t word
) const {
return get_cont_octet_out_count_impl<sizeof(wchar_t)>(word);
}
#if 0 // not used?
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// implementation for char
std::codecvt_base::result utf8_codecvt_facet_char::do_in(
std::mbstate_t & state,
const char * from,
const char * from_end,
const char * & from_next,
char * to,
char * to_end,
char * & to_next
) const
{
while(from_next < from_end){
wchar_t w;
wchar_t *wnext = & w;
utf8_codecvt_facet_wchar_t::result ucs4_result;
ucs4_result = base_class::do_in(
state,
from, from_end, from_next,
wnext, wnext + 1, wnext
);
if(codecvt_base::ok != ucs4_result)
return ucs4_result;
// if the conversion succeeds.
int length = std::wctomb(to_next, w);
assert(-1 != length);
to_next += length;
}
return codecvt_base::ok;
}
std::codecvt_base::result utf8_codecvt_facet_char::do_out(
mbstate_t & state,
const char * from,
const char * from_end,
const char * & from_next,
char * to,
char * to_end,
char * & to_next
) const
{
while(from_next < from_end){
wchar_t w;
int result = std::mbtowc(&w, from_next, MB_LENGTH_MAX);
assert(-1 != result);
from_next += result;
utf8_codecvt_facet_wchar_t::result ucs4_result;
const wchar_t *wptr = & w;
ucs4_result = base_class::do_out(
state,
wptr, wptr+1, wptr,
to_next, to_end, to_next
);
if(codecvt_base::ok != ucs4_result)
return ucs4_result;
}
return codecvt_base::ok;
}
// How many bytes objects can I process to get <= max_limit
// char objects?
int utf8_codecvt_facet_char::do_length(
// it seems that the standard doesn't use const so these librarires
// would be in error
BOOST_IOSTREAMS_CODECVT_CV_QUALIFIER
utf8_codecvt_facet_wchar_t::mbstate_t & initial_state,
const char * from_next,
const char * from_end,
std::size_t max_limit
) const
{
int total_length = 0;
const char *from = from_next;
mbstate_t state = initial_state;
while(from_next < from_end){
wchar_t w;
wchar_t *wnext = & w;
utf8_codecvt_facet_wchar_t::result ucs4_result;
ucs4_result = base_class::do_in(
state,
from_next, from_end, from_next,
wnext, wnext + 1, wnext
);
if(codecvt_base::ok != ucs4_result)
break;
char carray[MB_LENGTH_MAX];
std::size_t count = wctomb(carray, w);
if(count > max_limit)
break;
max_limit -= count;
total_length = from_next - from;
}
return total_length;
}
#endif
#endif //BOOST_IOSTREAMS_NO_WIDE_STREAMS
| [
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
] | [
[
[
1,
370
]
]
] |
178667bd429af0be0e3aec2e02cc9e5e6a2b9fbe | 46b3500c9ab98883091eb9d4ca49a6854451d76b | /ghost/packed.cpp | 57f47756b3ce5fae4ad080e3c77e17b6435ec6e6 | [
"Apache-2.0"
] | permissive | kr4uzi/pyghost | 7baa511fa05ddaba57880d2c7483694d5c5816b7 | 35e5bdd838cb21ad57b3c686349251eb277d2e6a | refs/heads/master | 2020-04-25T21:05:20.995556 | 2010-11-21T13:57:49 | 2010-11-21T13:57:49 | 42,011,079 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,790 | cpp | /*
Copyright [2008] [Trevor Hogan]
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.
CODE PORTED FROM THE ORIGINAL GHOST PROJECT: http://ghost.pwner.org/
*/
#include "ghost.h"
#include "util.h"
#include "crc32.h"
#include "packed.h"
#include <zlib.h>
// we can't use zlib's uncompress function because it expects a complete compressed buffer
// however, we're going to be passing it chunks of incomplete data
// this custom tzuncompress function will do the job
int tzuncompress( Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen )
{
z_stream stream;
int err;
stream.next_in = (Bytef*)source;
stream.avail_in = (uInt)sourceLen;
/* Check for source > 64K on 16-bit machine: */
if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
stream.next_out = dest;
stream.avail_out = (uInt)*destLen;
if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
stream.zalloc = (alloc_func)0;
stream.zfree = (free_func)0;
err = inflateInit(&stream);
if (err != Z_OK) return err;
err = inflate(&stream, Z_SYNC_FLUSH);
if (err != Z_STREAM_END && err != Z_OK) {
inflateEnd(&stream);
if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0))
return Z_DATA_ERROR;
return err;
}
*destLen = stream.total_out;
err = inflateEnd(&stream);
return err;
}
//
// CPacked
//
CPacked :: CPacked( ) : m_Valid( true ), m_HeaderSize( 0 ), m_CompressedSize( 0 ), m_HeaderVersion( 0 ), m_DecompressedSize( 0 ), m_NumBlocks( 0 ), m_War3Identifier( 0 ), m_War3Version( 0 ), m_BuildNumber( 0 ), m_Flags( 0 ), m_ReplayLength( 0 )
{
m_CRC = new CCRC32( );
m_CRC->Initialize( );
}
CPacked :: ~CPacked( )
{
delete m_CRC;
}
void CPacked :: Load( string fileName, bool allBlocks )
{
m_Valid = true;
CONSOLE_Print( "[PACKED] loading data from file [" + fileName + "]" );
m_Compressed = UTIL_FileRead( fileName );
Decompress( allBlocks );
}
bool CPacked :: Save( bool TFT, string fileName )
{
Compress( TFT );
if( m_Valid )
{
CONSOLE_Print( "[PACKED] saving data to file [" + fileName + "]" );
return UTIL_FileWrite( fileName, (unsigned char *)m_Compressed.c_str( ), m_Compressed.size( ) );
}
else
return false;
}
bool CPacked :: Extract( string inFileName, string outFileName )
{
m_Valid = true;
CONSOLE_Print( "[PACKED] extracting data from file [" + inFileName + "] to file [" + outFileName + "]" );
m_Compressed = UTIL_FileRead( inFileName );
Decompress( true );
if( m_Valid )
return UTIL_FileWrite( outFileName, (unsigned char *)m_Decompressed.c_str( ), m_Decompressed.size( ) );
else
return false;
}
bool CPacked :: Pack( bool TFT, string inFileName, string outFileName )
{
m_Valid = true;
CONSOLE_Print( "[PACKET] packing data from file [" + inFileName + "] to file [" + outFileName + "]" );
m_Decompressed = UTIL_FileRead( inFileName );
Compress( TFT );
if( m_Valid )
return UTIL_FileWrite( outFileName, (unsigned char *)m_Compressed.c_str( ), m_Compressed.size( ) );
else
return false;
}
void CPacked :: Decompress( bool allBlocks )
{
CONSOLE_Print( "[PACKED] decompressing data" );
// format found at http://www.thehelper.net/forums/showthread.php?t=42787
m_Decompressed.clear( );
istringstream ISS( m_Compressed );
string GarbageString;
// read header
getline( ISS, GarbageString, '\0' );
if( GarbageString != "Warcraft III recorded game\x01A" )
{
CONSOLE_Print( "[PACKED] not a valid packed file" );
m_Valid = false;
return;
}
ISS.read( (char *)&m_HeaderSize, 4 ); // header size
ISS.read( (char *)&m_CompressedSize, 4 ); // compressed file size
ISS.read( (char *)&m_HeaderVersion, 4 ); // header version
ISS.read( (char *)&m_DecompressedSize, 4 ); // decompressed file size
ISS.read( (char *)&m_NumBlocks, 4 ); // number of blocks
if( m_HeaderVersion == 0 )
{
ISS.seekg( 2, ios :: cur ); // unknown
ISS.seekg( 2, ios :: cur ); // version number
CONSOLE_Print( "[PACKED] header version is too old" );
m_Valid = false;
return;
}
else
{
ISS.read( (char *)&m_War3Identifier, 4 ); // version identifier
ISS.read( (char *)&m_War3Version, 4 ); // version number
}
ISS.read( (char *)&m_BuildNumber, 2 ); // build number
ISS.read( (char *)&m_Flags, 2 ); // flags
ISS.read( (char *)&m_ReplayLength, 4 ); // replay length
ISS.seekg( 4, ios :: cur ); // CRC
if( ISS.fail( ) )
{
CONSOLE_Print( "[PACKED] failed to read header" );
m_Valid = false;
return;
}
if( allBlocks )
CONSOLE_Print( "[PACKED] reading " + UTIL_ToString( m_NumBlocks ) + " blocks" );
else
CONSOLE_Print( "[PACKED] reading 1/" + UTIL_ToString( m_NumBlocks ) + " blocks" );
// read blocks
for( uint32_t i = 0; i < m_NumBlocks; ++i )
{
uint16_t BlockCompressed;
uint16_t BlockDecompressed;
// read block header
ISS.read( (char *)&BlockCompressed, 2 ); // block compressed size
ISS.read( (char *)&BlockDecompressed, 2 ); // block decompressed size
ISS.seekg( 4, ios :: cur ); // checksum
if( ISS.fail( ) )
{
CONSOLE_Print( "[PACKED] failed to read block header" );
m_Valid = false;
return;
}
// read block data
uLongf BlockCompressedLong = BlockCompressed;
uLongf BlockDecompressedLong = BlockDecompressed;
unsigned char *CompressedData = new unsigned char[BlockCompressed];
unsigned char *DecompressedData = new unsigned char[BlockDecompressed];
ISS.read( (char*)CompressedData, BlockCompressed );
if( ISS.fail( ) )
{
CONSOLE_Print( "[PACKED] failed to read block data" );
delete [] DecompressedData;
delete [] CompressedData;
m_Valid = false;
return;
}
// decompress block data
int Result = tzuncompress( DecompressedData, &BlockDecompressedLong, CompressedData, BlockCompressedLong );
if( Result != Z_OK )
{
CONSOLE_Print( "[PACKED] tzuncompress error " + UTIL_ToString( Result ) );
delete [] DecompressedData;
delete [] CompressedData;
m_Valid = false;
return;
}
if( BlockDecompressedLong != (uLongf)BlockDecompressed )
{
CONSOLE_Print( "[PACKED] block decompressed size mismatch, actual = " + UTIL_ToString( BlockDecompressedLong ) + ", expected = " + UTIL_ToString( BlockDecompressed ) );
delete [] DecompressedData;
delete [] CompressedData;
m_Valid = false;
return;
}
m_Decompressed += string( (char *)DecompressedData, BlockDecompressedLong );
delete [] DecompressedData;
delete [] CompressedData;
// stop after one iteration if not decompressing all blocks
if( !allBlocks )
break;
}
CONSOLE_Print( "[PACKED] decompressed " + UTIL_ToString( m_Decompressed.size( ) ) + " bytes" );
if( allBlocks || m_NumBlocks == 1 )
{
if( m_DecompressedSize > m_Decompressed.size( ) )
{
CONSOLE_Print( "[PACKED] not enough decompressed data" );
m_Valid = false;
return;
}
// the last block is padded with zeros, discard them
CONSOLE_Print( "[PACKED] discarding " + UTIL_ToString( m_Decompressed.size( ) - m_DecompressedSize ) + " bytes" );
m_Decompressed.erase( m_DecompressedSize );
}
}
void CPacked :: Compress( bool TFT )
{
CONSOLE_Print( "[PACKED] compressing data" );
// format found at http://www.thehelper.net/forums/showthread.php?t=42787
m_Compressed.clear( );
// compress data into blocks of size 8192 bytes
// use a buffer of size 8213 bytes because in the worst case zlib will grow the data 0.1% plus 12 bytes
uint32_t CompressedSize = 0;
string Padded = m_Decompressed;
Padded.append( 8192 - ( Padded.size( ) % 8192 ), 0 );
vector<string> CompressedBlocks;
string :: size_type Position = 0;
unsigned char *CompressedData = new unsigned char[8213];
while( Position < Padded.size( ) )
{
uLongf BlockCompressedLong = 8213;
int Result = compress( CompressedData, &BlockCompressedLong, (const Bytef *)Padded.c_str( ) + Position, 8192 );
if( Result != Z_OK )
{
CONSOLE_Print( "[PACKED] compress error " + UTIL_ToString( Result ) );
delete [] CompressedData;
m_Valid = false;
return;
}
CompressedBlocks.push_back( string( (char *)CompressedData, BlockCompressedLong ) );
CompressedSize += BlockCompressedLong;
Position += 8192;
}
delete [] CompressedData;
// build header
uint32_t HeaderSize = 68;
uint32_t HeaderCompressedSize = HeaderSize + CompressedSize + CompressedBlocks.size( ) * 8;
uint32_t HeaderVersion = 1;
BYTEARRAY Header;
UTIL_AppendByteArray( Header, "Warcraft III recorded game\x01A" );
UTIL_AppendByteArray( Header, HeaderSize, false );
UTIL_AppendByteArray( Header, HeaderCompressedSize, false );
UTIL_AppendByteArray( Header, HeaderVersion, false );
UTIL_AppendByteArray( Header, (uint32_t)m_Decompressed.size( ), false );
UTIL_AppendByteArray( Header, (uint32_t)CompressedBlocks.size( ), false );
if( TFT )
{
Header.push_back( 'P' ); // "W3XP"
Header.push_back( 'X' );
Header.push_back( '3' );
Header.push_back( 'W' );
}
else
{
Header.push_back( '3' ); // "WAR3"
Header.push_back( 'R' );
Header.push_back( 'A' );
Header.push_back( 'W' );
}
UTIL_AppendByteArray( Header, m_War3Version, false );
UTIL_AppendByteArray( Header, m_BuildNumber, false );
UTIL_AppendByteArray( Header, m_Flags, false );
UTIL_AppendByteArray( Header, m_ReplayLength, false );
// append zero header CRC
// the header CRC is calculated over the entire header with itself set to zero
// we'll overwrite the zero header CRC after we calculate it
UTIL_AppendByteArray( Header, (uint32_t)0, false );
// calculate header CRC
string HeaderString = string( Header.begin( ), Header.end( ) );
uint32_t CRC = m_CRC->FullCRC( (unsigned char *)HeaderString.c_str( ), HeaderString.size( ) );
// overwrite the (currently zero) header CRC with the calculated CRC
Header.erase( Header.end( ) - 4, Header.end( ) );
UTIL_AppendByteArray( Header, CRC, false );
// append header
m_Compressed += string( Header.begin( ), Header.end( ) );
// append blocks
for( vector<string> :: iterator i = CompressedBlocks.begin( ); i != CompressedBlocks.end( ); ++i )
{
BYTEARRAY BlockHeader;
UTIL_AppendByteArray( BlockHeader, (uint16_t)(*i).size( ), false );
UTIL_AppendByteArray( BlockHeader, (uint16_t)8192, false );
// append zero block header CRC
UTIL_AppendByteArray( BlockHeader, (uint32_t)0, false );
// calculate block header CRC
string BlockHeaderString = string( BlockHeader.begin( ), BlockHeader.end( ) );
uint32_t CRC1 = m_CRC->FullCRC( (unsigned char *)BlockHeaderString.c_str( ), BlockHeaderString.size( ) );
CRC1 = CRC1 ^ ( CRC1 >> 16 );
uint32_t CRC2 = m_CRC->FullCRC( (unsigned char *)(*i).c_str( ), (*i).size( ) );
CRC2 = CRC2 ^ ( CRC2 >> 16 );
uint32_t BlockCRC = ( CRC1 & 0xFFFF ) | ( CRC2 << 16 );
// overwrite the block header CRC with the calculated CRC
BlockHeader.erase( BlockHeader.end( ) - 4, BlockHeader.end( ) );
UTIL_AppendByteArray( BlockHeader, BlockCRC, false );
// append block header and data
m_Compressed += string( BlockHeader.begin( ), BlockHeader.end( ) );
m_Compressed += *i;
}
}
#include <boost/python.hpp>
void CPacked :: RegisterPythonClass( )
{
using namespace boost::python;
class_<CPacked>("packed")
.def_readonly("CRC", &CPacked::m_CRC)
.def_readonly("valid", &CPacked::m_Valid)
.def_readonly("compressed", &CPacked::m_Compressed)
.def_readonly("decompressed", &CPacked::m_Decompressed)
.def_readonly("headerSize", &CPacked::m_HeaderSize)
.def_readonly("compressedSize", &CPacked::m_CompressedSize)
.def_readonly("headerVersion", &CPacked::m_HeaderVersion)
.def_readonly("decompressedSize", &CPacked::m_DecompressedSize)
.def_readonly("numBlocks", &CPacked::m_NumBlocks)
.def_readonly("war3Identifier", &CPacked::m_War3Identifier)
.def_readonly("war3Version", &CPacked::m_War3Version)
.def_readonly("buildNumber", &CPacked::m_BuildNumber)
.def_readonly("flags", &CPacked::m_Flags)
.def_readonly("replayLength", &CPacked::m_ReplayLength)
.def("getValid", &CPacked::GetValid)
.def("getHeaderSize", &CPacked::GetHeaderSize)
.def("getCompressedSize", &CPacked::GetCompressedSize)
.def("getHeaderVersion", &CPacked::GetHeaderVersion)
.def("getDecompressedSize", &CPacked::GetDecompressedSize)
.def("getNumBlocks", &CPacked::GetNumBlocks)
.def("getWar3Identifier", &CPacked::GetWar3Identifier)
.def("getWar3Version", &CPacked::GetWar3Version)
.def("getBuildNumber", &CPacked::GetBuildNumber)
.def("getFlags", &CPacked::GetFlags)
.def("getReplayLength", &CPacked::GetReplayLength)
.def("setWar3Version", &CPacked::SetWar3Version)
.def("setBuildNumber", &CPacked::SetBuildNumber)
.def("setFlags", &CPacked::SetFlags)
.def("setReplayLength", &CPacked::SetReplayLength)
.def("load", &CPacked::Load)
.def("save", &CPacked::Save)
.def("extract", &CPacked::Extract)
.def("pack", &CPacked::Pack)
.def("decompress", &CPacked::Decompress)
.def("compress", &CPacked::Compress)
;
}
| [
"kr4uzi@88aed30e-2b04-91ce-7a47-0ae997e79d63"
] | [
[
[
1,
440
]
]
] |
424405670a146b88cc5ca6f6b2e6a89e6491bec0 | 0dfa7f23c2384251443da0cb129f79e3ea4d6b52 | /serverManager/ServerManager.cpp | 4b4e5cba1b554d3c2b3efa4c5ba39740b8066138 | [] | no_license | TeamFirst/Galcon | b908a1df4e161b3e726084a6e8054cbfa95d3ec4 | f7ccb7f0bb27820d2246529a577be2e89de248e4 | refs/heads/master | 2020-12-25T15:40:04.411443 | 2011-06-14T14:25:38 | 2011-06-14T14:25:38 | 1,810,650 | 6 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,002 | cpp | #include <QDebug>
#include <QString>
#include "ServerManager.h"
namespace ServerManagerDecl
{
/// constructor
CServerManager::CServerManager():
m_timerConfirm(this)
{
m_connectToServer = false;
m_ePhaseMessage = CParser::eUnknown;
m_timerConfirm.setInterval(1000);
connect(&m_timerConfirm, SIGNAL(timeout()), this, SLOT(slotTimeStartOut()));
}
CServerManager::~CServerManager()
{
}
/// private function
void CServerManager::connectToServer(const std::string& serverIP,
const unsigned int m_serverPort)
{
m_tcpSocket = new QTcpSocket(this);
m_tcpSocket->connectToHost(QString(serverIP.c_str()), m_serverPort);
connect(m_tcpSocket, SIGNAL(connected()), this, SLOT(slotConnected()));
connect(m_tcpSocket, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
connect(m_tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
this,SLOT(slotError(QAbstractSocket::SocketError)));
}
void CServerManager::disconnectFromServer()
{
m_connectToServer = false;
m_tcpSocket->waitForDisconnected(0);
m_tcpSocket->disconnectFromHost();
disconnect(m_tcpSocket, SIGNAL(connected()), this, SLOT(slotConnected()));
disconnect(m_tcpSocket, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
disconnect(m_tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
this,SLOT(slotError(QAbstractSocket::SocketError)));
delete m_tcpSocket;
qDebug("Disconnect from server - end");
}
void CServerManager::sendToServer(const Message::IMessagePtr pMessage)
{
QByteArray arrBlock;
QDataStream out(&arrBlock, QIODevice::WriteOnly);
out.setVersion(QDataStream::Qt_4_7);
out << quint16(0) << QString(pMessage->toString().c_str()).toUtf8();
out.device()->seek(0);
out << quint16(arrBlock.size() - sizeof(quint16));
m_tcpSocket->write(arrBlock);
}
void CServerManager::parseStrFromServer(const std::string& sMes)
{
try
{
switch(m_parser.CheckTypeMessage(sMes))
{
case CParser::eConfirmConnect :
if(m_ePhaseMessage == CParser::eUnknown)
{
m_timerConfirm.stop();
m_ePhaseMessage = CParser::eConfirmConnect;
emit SendConfirmConnect(m_parser.ParseMConfirmConnect(sMes));
}
else
{
throw std::string("Error, Server send error message");
}
break;
case CParser::eError :
emit SendError(m_parser.ParseMError(sMes));
break;
case CParser::eFinishGame :
if(m_ePhaseMessage == CParser::eStartGame)
{
disconnectFromServer();
m_ePhaseMessage = CParser::eUnknown;
emit SendFinishGame(m_parser.ParseMFinishGame(sMes));
}
else
{
throw std::string("Error, Server send error message");
}
break;
case CParser::eStartGame :
if(m_ePhaseMessage == CParser::eTimeToStart)
{
m_ePhaseMessage = CParser::eStartGame;
emit SendStartGame(m_parser.ParseMStartMapGame(sMes));
}
else
{
throw std::string("Error, Server send error message");
}
break;
case CParser::eStateMap :
if(m_ePhaseMessage == CParser::eStartGame)
{
emit SendStateMap(m_parser.ParseMStateMap(sMes));
}
else
{
throw std::string("Error, Server send error message");
}
break;
case CParser::eTimeToStart :
if(m_ePhaseMessage == CParser::eConfirmConnect)
{
m_ePhaseMessage = CParser::eTimeToStart;
emit SendTimeToStart(m_parser.ParseMTimeToStartGame(sMes));
}
else
{
throw std::string("Error, Server send error message");
}
break;
case CParser::eUnknown :
throw std::string("Error, Server send unknown message");
break;
}
}
catch(std::string str)
{
Message::CMessageInformationPtr ptr(new Message::CMessageInformation);
ptr->m_typeInformation = Message::CMessageInformation::eMessageFromServer;
ptr->m_strInformation = str;
emit SendInInformation(ptr);
}
}
/// slots connect to server
void CServerManager::slotConnected()
{
m_connectToServer = true;
Message::CMessageInformationPtr ptr(new Message::CMessageInformation);
ptr->m_typeInformation = Message::CMessageInformation::eConnectionToServer;
ptr->m_strInformation = "Connected";
emit SendInInformation(ptr);
}
void CServerManager::slotReadyRead()
{
QDataStream in(m_tcpSocket);
in.setVersion(QDataStream::Qt_4_7);
qint16 nextBlockSize = 0;
for (;;)
{
if (m_tcpSocket->bytesAvailable() < sizeof(quint16))
{
break;
}
in >> nextBlockSize;
if (m_tcpSocket->bytesAvailable() < nextBlockSize)
{
break;
}
QByteArray str;
in >> str;
nextBlockSize = 0;
Message::CMessageInformationPtr ptr(new Message::CMessageInformation);
ptr->m_typeInformation = Message::CMessageInformation::eMessageFromServer;
ptr->m_strInformation = QString(str).toStdString();
emit SendInInformation(ptr);
qDebug(QString(str).toAscii());
parseStrFromServer(QString(str).toStdString());
}
}
void CServerManager::slotError(QAbstractSocket::SocketError)
{
m_connectToServer = false;
Message::CMessageErrorPtr ptr(
new Message::CMessageError);
ptr->m_strError = "Error connection";
emit SendError(ptr);
}
void CServerManager::slotTimeStartOut()
{
qDebug("Network - stop timer");
m_timerConfirm.stop();
Message::CMessageInformationPtr ptr(new Message::CMessageInformation);
ptr->m_typeInformation = Message::CMessageInformation::eConnectionToServer;
ptr->m_strInformation = "Error, time wait confirmation from server - out";
emit SendInInformation(ptr);
disconnectFromServer();
}
/// public slots
void CServerManager::TakeServerConnect(const Message::CMessageConnectToServerPtr pMessage)
{
if(!m_connectToServer)
{
connectToServer(pMessage->m_serverIP, pMessage->m_serverPort);
sendToServer(pMessage);
qDebug("Network - start wait confirm timer");
m_timerConfirm.start();
}
else
{
Message::CMessageInformationPtr ptr(new Message::CMessageInformation);
ptr->m_typeInformation = Message::CMessageInformation::eConnectionToServer;
ptr->m_strInformation = "Error, You again trying connect to server";
emit SendInInformation(ptr);
}
}
void CServerManager::TakeStepPlayer(const Message::CMessageStepPlayerPtr pMessage)
{
if(m_connectToServer)
{
sendToServer(pMessage);
}
else
{
Message::CMessageInformationPtr ptr(new Message::CMessageInformation);
ptr->m_typeInformation = Message::CMessageInformation::eConnectionToServer;
ptr->m_strInformation = "Error, No connection to server";
emit SendInInformation(ptr);
}
}
void CServerManager::TakeExit()
{
disconnectFromServer();
}
} // namespace ServerManagerDecl
| [
"GrafAllukard",
"vlad@vlad-laptop.(none)",
"[email protected]"
] | [
[
[
1,
2
],
[
10,
11
],
[
13,
16
],
[
29,
33
],
[
36,
51
],
[
57,
57
],
[
60,
60
],
[
67,
67
],
[
69,
141
],
[
149,
152
],
[
159,
159
],
[
162,
162
],
[
179,
185
],
[
194,
197
],
[
200,
214
],
[
222,
225
],
[
228,
232
],
[
243,
247
],
[
251,
255
]
],
[
[
3,
9
],
[
12,
12
],
[
17,
23
],
[
25,
28
],
[
34,
35
],
[
52,
56
],
[
58,
59
],
[
61,
64
],
[
66,
66
],
[
68,
68
],
[
142,
148
],
[
153,
158
],
[
160,
161
],
[
163,
178
],
[
187,
193
],
[
198,
199
],
[
215,
221
],
[
226,
227
],
[
233,
242
],
[
248,
250
],
[
256,
256
]
],
[
[
24,
24
],
[
65,
65
],
[
186,
186
]
]
] |
8159e4b80fc25ab32d8025a879489fe0e10d30cf | 444a151706abb7bbc8abeb1f2194a768ed03f171 | /trunk/ENIGMAsystem/SHELL/Universal_System/terminal_io.cpp | 7d1ad506841818cc493e51fed572f94f3da1d859 | [] | no_license | amorri40/Enigma-Game-Maker | 9d01f70ab8de42f7c80af9a0f8c7a66e412d19d6 | c6b701201b6037f2eb57c6938c184a5d4ba917cf | refs/heads/master | 2021-01-15T11:48:39.834788 | 2011-11-22T04:09:28 | 2011-11-22T04:09:28 | 1,855,342 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,405 | cpp | /** Copyright (C) 2010-2011 Josh Ventura
***
*** This file is a part of the ENIGMA Development Environment.
***
*** ENIGMA 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, version 3 of the license or any later version.
***
*** This application and its source code is distributed AS-IS, 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 code. If not, see <http://www.gnu.org/licenses/>
**/
#include <stdio.h>
#include <string>
using namespace std;
#include "terminal_io.h"
void cons_show_message(string message) {
puts(message.c_str());
}
void cons_print_overwritable(string message) {
printf("%s\r",message.c_str());
}
char cons_get_byte()
{
int c, first;
first = c = getchar();
while (c != '\n' && c != EOF)
c = getchar();
return first;
}
string cons_get_char()
{
int c, first;
first = c = getchar();
while (c != '\n' && c != EOF)
c = getchar();
return string(first,1);
}
string cons_get_string()
{
string res;
int c = getchar();
while (c != '\n' && c != EOF)
{
res += char(c);
c = getchar();
}
return res;
}
| [
"[email protected]"
] | [
[
[
1,
55
]
]
] |
2685ab23e8d14b3b549acc2c144330a93217e337 | 9152cb31fbe4e82c22092bb3071b2ec8c6ae86ab | /demos/acm/caps-conv/conv/conv.cpp | a20c626127b7b941ac768405d066355482278acd | [] | no_license | zzjs2001702/sfsipua-svn | ca3051b53549066494f6264e8f3bf300b8090d17 | e8768338340254aa287bf37cf620e2c68e4ff844 | refs/heads/master | 2022-01-09T20:02:20.777586 | 2006-03-29T13:24:02 | 2006-03-29T13:24:02 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,342 | cpp | // conv.cpp
//
// convert a PCM wave to some other format
#include <windows.h>
#include <mmsystem.h>
#include <mmreg.h> // Multimedia registration
#include <msacm.h> // Audio Compression Manager
#include <stdio.h>
#include <math.h>
// Locate a driver that supports a given format and return its ID
typedef struct {
HACMDRIVERID hadid;
WORD wFormatTag;
} FIND_DRIVER_INFO;
// callback function for format enumeration
BOOL CALLBACK find_format_enum(HACMDRIVERID hadid, LPACMFORMATDETAILS pafd, DWORD dwInstance, DWORD fdwSupport)
{
FIND_DRIVER_INFO* pdi = (FIND_DRIVER_INFO*) dwInstance;
if (pafd->dwFormatTag == (DWORD)pdi->wFormatTag) {
// found it
pdi->hadid = hadid;
return FALSE; // stop enumerating
}
return TRUE; // continue enumerating
}
// callback function for driver enumeration
BOOL CALLBACK find_driver_enum(HACMDRIVERID hadid, DWORD dwInstance, DWORD fdwSupport)
{
FIND_DRIVER_INFO* pdi = (FIND_DRIVER_INFO*) dwInstance;
// open the driver
HACMDRIVER had = NULL;
MMRESULT mmr = acmDriverOpen(&had, hadid, 0);
if (mmr) {
// some error
return FALSE; // stop enumerating
}
// enumerate the formats it supports
DWORD dwSize = 0;
mmr = acmMetrics(had, ACM_METRIC_MAX_SIZE_FORMAT, &dwSize);
if (dwSize < sizeof(WAVEFORMATEX)) dwSize = sizeof(WAVEFORMATEX); // for MS-PCM
WAVEFORMATEX* pwf = (WAVEFORMATEX*) malloc(dwSize);
memset(pwf, 0, dwSize);
pwf->cbSize = LOWORD(dwSize) - sizeof(WAVEFORMATEX);
pwf->wFormatTag = pdi->wFormatTag;
ACMFORMATDETAILS fd;
memset(&fd, 0, sizeof(fd));
fd.cbStruct = sizeof(fd);
fd.pwfx = pwf;
fd.cbwfx = dwSize;
fd.dwFormatTag = pdi->wFormatTag;
mmr = acmFormatEnum(had, &fd, find_format_enum, (DWORD)(VOID*)pdi, 0);
free(pwf);
acmDriverClose(had, 0);
if (pdi->hadid || mmr) {
// found it or some error
return FALSE; // stop enumerating
}
return TRUE; // continue enumeration
}
// locate the first driver that supports a given format tag
HACMDRIVERID find_driver(WORD wFormatTag)
{
FIND_DRIVER_INFO fdi;
fdi.hadid = NULL;
fdi.wFormatTag = wFormatTag;
MMRESULT mmr = acmDriverEnum(find_driver_enum, (DWORD)(VOID*)&fdi, 0);
if (mmr) return NULL;
return fdi.hadid;
}
// get a description of the first format supported for a given tag
WAVEFORMATEX* get_driver_format(HACMDRIVERID hadid, WORD wFormatTag)
{
// open the driver
HACMDRIVER had = NULL;
MMRESULT mmr = acmDriverOpen(&had, hadid, 0);
if (mmr) {
return NULL;
}
// allocate a structure for the info
DWORD dwSize = 0;
mmr = acmMetrics(had, ACM_METRIC_MAX_SIZE_FORMAT, &dwSize);
if (dwSize < sizeof(WAVEFORMATEX)) dwSize = sizeof(WAVEFORMATEX); // for MS-PCM
WAVEFORMATEX* pwf = (WAVEFORMATEX*) malloc(dwSize);
memset(pwf, 0, dwSize);
pwf->cbSize = LOWORD(dwSize) - sizeof(WAVEFORMATEX);
pwf->wFormatTag = wFormatTag;
ACMFORMATDETAILS fd;
memset(&fd, 0, sizeof(fd));
fd.cbStruct = sizeof(fd);
fd.pwfx = pwf;
fd.cbwfx = dwSize;
fd.dwFormatTag = wFormatTag;
// set up a struct to control the enumeration
FIND_DRIVER_INFO fdi;
fdi.hadid = NULL;
fdi.wFormatTag = wFormatTag;
mmr = acmFormatEnum(had, &fd, find_format_enum, (DWORD)(VOID*)&fdi, 0);
acmDriverClose(had, 0);
if ((fdi.hadid == NULL) || mmr) {
free(pwf);
return NULL;
}
return pwf;
}
int main(int argc, char* argv[])
{
// First we create a wave that might have been just recorded.
// The format is 11.025 kHz, 8 bit mono PCM which is a recording
// format available on all machines.
// our sample wave will be 1 second long and will be a sine wave
// of 1kHz which is exactly 1,000 cycles
WAVEFORMATEX wfSrc;
memset(&wfSrc, 0, sizeof(wfSrc));
wfSrc.cbSize = 0;
wfSrc.wFormatTag = WAVE_FORMAT_PCM; // pcm
wfSrc.nChannels = 1; // mono
wfSrc.nSamplesPerSec = 11025; // 11.025 kHz
wfSrc.wBitsPerSample = 8; // 8 bit
wfSrc.nBlockAlign = wfSrc.nChannels * wfSrc.wBitsPerSample / 8;
wfSrc.nAvgBytesPerSec = wfSrc.nSamplesPerSec * wfSrc.nBlockAlign;
DWORD dwSrcSamples = wfSrc.nSamplesPerSec;
BYTE* pSrcData = new BYTE [dwSrcSamples]; // 1 second duration
BYTE* pData = pSrcData;
double f = 1000.0;
double pi = 4.0 * atan(1.0);
double w = 2.0 * pi * f;
for (DWORD dw = 0; dw < dwSrcSamples; dw++) {
double t = (double) dw / (double) wfSrc.nSamplesPerSec;
*pData++ = 128 + (BYTE)(127.0 * sin(w * t));
}
// Select a format to convert to
// WORD wFormatTag = WAVE_FORMAT_ADPCM;
// WORD wFormatTag = WAVE_FORMAT_IMA_ADPCM;
// WORD wFormatTag = WAVE_FORMAT_GSM610;
// WORD wFormatTag = WAVE_FORMAT_ALAW;
// WORD wFormatTag = WAVE_FORMAT_MULAW;
// WORD wFormatTag = 0x32; // MSN
WORD wFormatTag = WAVE_FORMAT_DSPGROUP_TRUESPEECH;
// Now we locate a CODEC that supports the destination format tag
HACMDRIVERID hadid = find_driver(wFormatTag);
if (hadid == NULL) {
printf("No driver found\n");
exit(1);
}
printf("Driver found (hadid: %4.4lXH)\n", hadid);
// show some information about the driver
ACMDRIVERDETAILS dd;
dd.cbStruct = sizeof(dd);
MMRESULT mmr = acmDriverDetails(hadid, &dd, 0);
printf(" Short name: %s\n", dd.szShortName);
printf(" Long name: %s\n", dd.szLongName);
printf(" Copyright: %s\n", dd.szCopyright);
printf(" Licensing: %s\n", dd.szLicensing);
printf(" Features: %s\n", dd.szFeatures);
// get the details of the format
// Note: this is just the first of one or more possible formats for the given tag
WAVEFORMATEX* pwfDrv = get_driver_format(hadid, wFormatTag);
if (pwfDrv == NULL) {
printf("Error getting format info\n");
exit(1);
}
printf("Driver format: %u bits, %lu samples per second\n", pwfDrv->wBitsPerSample, pwfDrv->nSamplesPerSec);
// get a PCM format tag the driver supports
// Note: we just pick the first supported PCM format which might not really
// be the best choice.
WAVEFORMATEX* pwfPCM = get_driver_format(hadid, WAVE_FORMAT_PCM);
if (pwfPCM == NULL) {
printf("Error getting PCM format info\n");
exit(1);
}
printf("PCM format: %u bits, %lu samples per second\n", pwfPCM->wBitsPerSample, pwfPCM->nSamplesPerSec);
////////////////////////////////////////////////////////////////////////////////
// convert the source wave to the PCM format supported by the CODEC
// we use any driver that can do the PCM to PCM conversion
HACMSTREAM hstr = NULL;
mmr = acmStreamOpen(&hstr,
NULL, // any driver
&wfSrc, // source format
pwfPCM, // destination format
NULL, // no filter
NULL, // no callback
0, // instance data (not used)
ACM_STREAMOPENF_NONREALTIME); // flags
if (mmr) {
printf("Failed to open a stream to do PCM to PCM conversion\n");
exit(1);
}
// allocate a buffer for the result of the conversion.
DWORD dwSrcBytes = dwSrcSamples * wfSrc.wBitsPerSample / 8;
DWORD dwDst1Samples = dwSrcSamples * pwfPCM->nSamplesPerSec / wfSrc.nSamplesPerSec;
DWORD dwDst1Bytes = dwDst1Samples * pwfPCM->wBitsPerSample / 8;
BYTE* pDst1Data = new BYTE [dwDst1Bytes];
#ifdef _DEBUG
// fill the dest buffer with zeroes just so we can see if anything got
// converted in the debugger
memset(pDst1Data, 0, dwDst1Bytes);
#endif
// fill in the conversion info
ACMSTREAMHEADER strhdr;
memset(&strhdr, 0, sizeof(strhdr));
strhdr.cbStruct = sizeof(strhdr);
strhdr.pbSrc = pSrcData; // the source data to convert
strhdr.cbSrcLength = dwSrcBytes;
strhdr.pbDst = pDst1Data;
strhdr.cbDstLength = dwDst1Bytes;
// prep the header
mmr = acmStreamPrepareHeader(hstr, &strhdr, 0);
// convert the data
printf("Converting to intermediate PCM format...\n");
mmr = acmStreamConvert(hstr, &strhdr, 0);
if (mmr) {
printf("Failed to do PCM to PCM conversion\n");
exit(1);
}
printf("Converted OK\n");
// close the stream
acmStreamClose(hstr, 0);
///////////////////////////////////////////////////////////////////////////////////
// convert the intermediate PCM format to the final format
// open the driver
HACMDRIVER had = NULL;
mmr = acmDriverOpen(&had, hadid, 0);
if (mmr) {
printf("Failed to open driver\n");
exit(1);
}
// open the conversion stream
// Note the use of the ACM_STREAMOPENF_NONREALTIME flag. Without this
// some software compressors will report error 512 - not possible
mmr = acmStreamOpen(&hstr,
had, // driver handle
pwfPCM, // source format
pwfDrv, // destination format
NULL, // no filter
NULL, // no callback
0, // instance data (not used)
ACM_STREAMOPENF_NONREALTIME); // flags
if (mmr) {
printf("Failed to open a stream to do PCM to driver format conversion\n");
exit(1);
}
// allocate a buffer for the result of the conversion.
// compute the output buffer size based on the average byte rate
// and add a bit for randomness
// the IMA_ADPCM driver fails the conversion without this extra space
DWORD dwDst2Bytes = pwfDrv->nAvgBytesPerSec * dwDst1Samples / pwfPCM->nSamplesPerSec;
dwDst2Bytes = dwDst2Bytes * 3 / 2; // add a little room
BYTE* pDst2Data = new BYTE [dwDst2Bytes];
#ifdef _DEBUG
// fill the dest buffer with zeroes just so we can see if anything got
// converted in the debugger
memset(pDst2Data, 0, dwDst2Bytes);
#endif
// fill in the conversion info
ACMSTREAMHEADER strhdr2;
memset(&strhdr2, 0, sizeof(strhdr2));
strhdr2.cbStruct = sizeof(strhdr2);
strhdr2.pbSrc = pDst1Data; // the source data to convert
strhdr2.cbSrcLength = dwDst1Bytes;
strhdr2.pbDst = pDst2Data;
strhdr2.cbDstLength = dwDst2Bytes;
// prep the header
mmr = acmStreamPrepareHeader(hstr, &strhdr2, 0);
// convert the data
printf("Converting to final format...\n");
mmr = acmStreamConvert(hstr, &strhdr2, 0);
if (mmr) {
printf("Failed to do PCM to driver format conversion\n");
exit(1);
}
printf("Converted OK\n");
// close the stream and driver
mmr = acmStreamClose(hstr, 0);
mmr = acmDriverClose(had, 0);
// show the conversion stats
printf("Source wave had %lu bytes\n", dwSrcBytes);
printf("Converted wave has %lu bytes\n", strhdr2.cbDstLengthUsed);
printf("Compression ratio is %f\n", (double) dwSrcBytes / (double) strhdr2.cbDstLengthUsed);
return 0;
}
| [
"yippeesoft@5dda88da-d10c-0410-ac74-cc18da35fedd"
] | [
[
[
1,
324
]
]
] |
b6c03d6b3f33d7771e02ed55838a7120d2ca6dc0 | cd07acbe92f87b59260478f62a6f8d7d1e218ba9 | /src/View3.h | 5df326ddd343f7d5baa702da587d80c031b9f6dc | [] | no_license | niepp/sperm-x | 3a071783e573d0c4bae67c2a7f0fe9959516060d | e8f578c640347ca186248527acf82262adb5d327 | refs/heads/master | 2021-01-10T06:27:15.004646 | 2011-09-24T03:33:21 | 2011-09-24T03:33:21 | 46,690,957 | 1 | 1 | null | null | null | null | GB18030 | C++ | false | false | 2,605 | h | #if !defined(AFX_VIEW3_H__CDBA7A0F_08EE_4B6A_8AE3_376E9CA3E088__INCLUDED_)
#define AFX_VIEW3_H__CDBA7A0F_08EE_4B6A_8AE3_376E9CA3E088__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// View3.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CView3 form view
#ifndef __AFXEXT_H__
#include <afxext.h>
#endif
#include "LiveDetectDLG.h"
#include "MorphaDetectDLG.h"
class CView3 : public CFormView
{
protected:
CView3(); // protected constructor used by dynamic creation
DECLARE_DYNCREATE(CView3)
// Form Data
public:
//{{AFX_DATA(CView3)
enum { IDD = IDD_DIALOG_BUTTON };
CString m_strDetectNO;
CString m_strPatientName;
CString m_sTotalSpermNum; //视野中精子总数
CString m_sMovementSpermNum; //活动精子数目
CString m_sActiveSpermNum; //活跃精子数目
CString m_sGradeA;
CString m_sGradeB;
CString m_sGradeC;
CString m_sGradeD;
CString m_sLineMoveSpermNum; //直线运动精子数
CString m_sCurveMoveSpermNum;//曲线运动精子数
CString m_sActiveSpermDensity; // 活跃精子密度
CString m_sTotalSpermDensity; // 总精子密度
CString m_sMovementSpermRatio; // 活动精子比率,即存活率
//}}AFX_DATA
// Attributes
public:
enum DETECTMODE{CAMERA=0X100,VIDEO=0X1000,AVI=0X1,BMP=0X10,
CAMERAAVI=0X101,CAMERABMP=0X110,VIDEOAVI=0X1001,VIDEOBMP=0X1010,MORPHAIMAGE=0X1111
} m_eDetectMode;
public:
bool state;
CLiveDetectDLG* m_pwndLiveDetectDlg;
CMorphaDetectDLG* m_pwndMorphaDetDlg;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CView3)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CView3();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
// Generated message map functions
//{{AFX_MSG(CView3)
afx_msg void OnBtnLiveDetected();
afx_msg void OnPatient();
afx_msg void OnButtonMorphadetect();
afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
afx_msg void OnBtnPatientInfoQuery();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_VIEW3_H__CDBA7A0F_08EE_4B6A_8AE3_376E9CA3E088__INCLUDED_)
| [
"harithchen@e030fd90-5f31-5877-223c-63bd88aa7192"
] | [
[
[
1,
92
]
]
] |
63ab639e8e417979193ef3001c1a80b04640ee35 | 011359e589f99ae5fe8271962d447165e9ff7768 | /src/burn/misc/post90s/d_aerofgt.cpp | c0b94949cd81dbf4fe8cb11a5d794d33af10d00e | [] | 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 | 153,056 | cpp | /*
* Aero Fighters driver for FB Alpha 0.2.96.71
* Port by OopsWare. 2007
* http://oopsware.googlepages.com
* http://oopsware.ys168.com
*
* 6.13.2007
* Add driver Spinal Breakers (spinlbrk)
*
* 6.12.2007
* Add driver Karate Blazers (karatblz)
*
* 6.11.2007
* Add driver Turbo Force (turbofrc)
*
* 6.10.2007
* Add BurnHighCol support, and add BDF_16BIT_ONLY into driver. thanks to KEV
*
*/
#include "burnint.h"
#include "burn_ym2610.h"
#define USE_BURN_HIGHCOL 1
static unsigned char DrvButton[8] = {0, 0, 0, 0, 0, 0, 0, 0};
static unsigned char DrvButton2[8] = {0, 0, 0, 0, 0, 0, 0, 0};
static unsigned char DrvJoy1[8] = {0, 0, 0, 0, 0, 0, 0, 0};
static unsigned char DrvJoy2[8] = {0, 0, 0, 0, 0, 0, 0, 0};
static unsigned char DrvJoy3[8] = {0, 0, 0, 0, 0, 0, 0, 0};
static unsigned char DrvJoy4[8] = {0, 0, 0, 0, 0, 0, 0, 0};
static unsigned char DrvInput[10] = {0, 0, 0, 0, 0, 0, 0, 0};
static unsigned char DrvReset = 0;
static unsigned char *Mem = NULL, *MemEnd = NULL;
static unsigned char *RamStart, *RamEnd;
static unsigned char *Rom01;
static unsigned char *RomZ80;
static unsigned char *RomBg;
static unsigned char *RomSpr1;
static unsigned char *RomSpr2;
static unsigned char *RomSnd1;
static unsigned char *RomSnd2;
static unsigned char *RamPal;
static unsigned short *RamRaster;
static unsigned short *RamBg1V, *RamBg2V;
static unsigned short *RamSpr1;
static unsigned short *RamSpr2;
static unsigned short *RamSpr3;
static unsigned char *Ram01;
static unsigned char *RamZ80;
//static int nCyclesDone[2];
static int nCyclesTotal[2];
//static int nCyclesSegment;
static unsigned char RamGfxBank[8];
static unsigned int *RamCurPal;
static unsigned char *DeRomBg;
static unsigned char *DeRomSpr1;
static unsigned char *DeRomSpr2;
static unsigned int RamSpr1SizeMask;
static unsigned int RamSpr2SizeMask;
static unsigned int RomSpr1SizeMask;
static unsigned int RomSpr2SizeMask;
static int pending_command = 0;
static int RomSndSize1, RomSndSize2;
static unsigned short bg1scrollx, bg2scrollx;
static unsigned short bg1scrolly, bg2scrolly;
static int nAerofgtZ80Bank;
static unsigned char nSoundlatch;
// Pal routines
#if USE_BURN_HIGHCOL
static inline unsigned int CalcCol(unsigned short nColour)
{
int r, g, b;
r = (nColour & 0x001F) << 3; // Red
r |= r >> 5;
g = (nColour & 0x03E0) >> 2; // Green
g |= g >> 5;
b = (nColour & 0x7C00) >> 7; // Blue
b |= b >> 5;
return BurnHighCol(b, g, r, 0);
}
#else
static inline unsigned int CalcCol(unsigned short nColour)
{
return (nColour & 0x001F) | ((nColour & 0x7FE0) << 1);
}
#endif
static inline int aerofgtPalUpdate()
{
int i;
unsigned short* ps;
unsigned int* pd;
for (i = 0, ps = (unsigned short*)RamPal, pd = RamCurPal; i < 1024; i++, ps++, pd++) {
*pd = CalcCol(*ps);
}
return 0;
}
static struct BurnInputInfo aerofgtInputList[] = {
{"P1 Coin", BIT_DIGITAL, DrvButton + 0, "p1 coin"},
{"P1 Start", BIT_DIGITAL, DrvButton + 2, "p1 start"},
{"P1 Up", BIT_DIGITAL, DrvJoy1 + 0, "p1 up"},
{"P1 Down", BIT_DIGITAL, DrvJoy1 + 1, "p1 down"},
{"P1 Left", BIT_DIGITAL, DrvJoy1 + 2, "p1 left"},
{"P1 Right", BIT_DIGITAL, DrvJoy1 + 3, "p1 right"},
{"P1 Button 1", BIT_DIGITAL, DrvJoy1 + 4, "p1 fire 1"},
{"P1 Button 2", BIT_DIGITAL, DrvJoy1 + 5, "p1 fire 2"},
{"P2 Coin", BIT_DIGITAL, DrvButton + 1, "p2 coin"},
{"P2 Start", BIT_DIGITAL, DrvButton + 3, "p2 start"},
{"P2 Up", BIT_DIGITAL, DrvJoy2 + 0, "p2 up"},
{"P2 Down", BIT_DIGITAL, DrvJoy2 + 1, "p2 down"},
{"P2 Left", BIT_DIGITAL, DrvJoy2 + 2, "p2 left"},
{"P2 Right", BIT_DIGITAL, DrvJoy2 + 3, "p2 right"},
{"P2 Button 1", BIT_DIGITAL, DrvJoy2 + 4, "p2 fire 1"},
{"P2 Button 2", BIT_DIGITAL, DrvJoy2 + 5, "p2 fire 2"},
{"Reset", BIT_DIGITAL, &DrvReset, "reset"},
{"Service", BIT_DIGITAL, DrvButton + 6, "service"},
{"Dip A", BIT_DIPSWITCH, DrvInput + 3, "dip"},
{"Dip B", BIT_DIPSWITCH, DrvInput + 4, "dip"},
{"Dip C", BIT_DIPSWITCH, DrvInput + 5, "dip"},
};
STDINPUTINFO(aerofgt)
static struct BurnDIPInfo sonicwiDIPList[] = {
// Defaults
{0x12, 0xFF, 0xFF, 0x00, NULL},
{0x13, 0xFF, 0xFF, 0x02, NULL},
// DIP 1
{0, 0xFE, 0, 2, "Coin slot"},
{0x12, 0x82, 0x01, 0x00, "Same"},
{0x12, 0x00, 0xFF, 0xFF, NULL},
{0x12, 0x82, 0x01, 0x01, "Individual"},
{0x12, 0x00, 0xFF, 0xFF, NULL},
{0, 0xFE, 0, 9, "Coin 1"},
{0x12, 0x82, 0x0E, 0x00, "1 coin 1 credit"},
{0x12, 0x00, 0xFF, 0xFF, NULL},
{0x12, 0x82, 0x0E, 0x02, "2 coins 1 credit"},
{0x12, 0x00, 0xFF, 0xFF, NULL},
{0x12, 0x82, 0x0E, 0x04, "3 coins 1 credit"},
{0x12, 0x00, 0xFF, 0xFF, NULL},
{0x12, 0x82, 0x0E, 0x06, "1 coin 2 credits"},
{0x12, 0x00, 0xFF, 0xFF, NULL},
{0x12, 0x82, 0x0E, 0x08, "1 coin 3 credits"},
{0x12, 0x00, 0xFF, 0xFF, NULL},
{0x12, 0x82, 0x0E, 0x0A, "1 coin 4 credits"},
{0x12, 0x00, 0xFF, 0xFF, NULL},
{0x12, 0x82, 0x0E, 0x0C, "1 coin 5 credits"},
{0x12, 0x00, 0xFF, 0xFF, NULL},
{0x12, 0x82, 0x0E, 0x0E, "1 coin 6 credits"},
{0x12, 0x00, 0xFF, 0xFF, NULL},
{0x12, 0x01, 0xFF, 0xFF, "Free play"},
{0, 0xFE, 0, 9, "Coin 2"},
{0x12, 0x82, 0x70, 0x00, "1 coin 1 credit"},
{0x12, 0x00, 0xFF, 0xFF, NULL},
{0x12, 0x82, 0x70, 0x10, "2 coins 1 credit"},
{0x12, 0x00, 0xFF, 0xFF, NULL},
{0x12, 0x82, 0x70, 0x20, "3 coins 1 credit"},
{0x12, 0x00, 0xFF, 0xFF, NULL},
{0x12, 0x82, 0x70, 0x30, "1 coin 2 credits"},
{0x12, 0x00, 0xFF, 0xFF, NULL},
{0x12, 0x82, 0x70, 0x40, "1 coin 3 credits"},
{0x12, 0x00, 0xFF, 0xFF, NULL},
{0x12, 0x82, 0x70, 0x50, "1 coin 4 credits"},
{0x12, 0x00, 0xFF, 0xFF, NULL},
{0x12, 0x82, 0x70, 0x60, "1 coin 5 credits"},
{0x12, 0x00, 0xFF, 0xFF, NULL},
{0x12, 0x82, 0x70, 0x70, "1 coin 6 credits"},
{0x12, 0x00, 0xFF, 0xFF, NULL},
{0x12, 0x01, 0xFF, 0xFF, "Free play"},
{0, 0xFE, 0, 2, "2 coins to start, 1 to continue"},
{0x12, 0x82, 0x80, 0x00, "Off"},
{0x12, 0x00, 0xFF, 0xFF, NULL},
{0x12, 0x82, 0x80, 0x80, "On"},
{0x12, 0x00, 0xFF, 0xFF, NULL},
// DIP 2
{0, 0xFE, 0, 2, "Screen flip"},
{0x13, 0x01, 0x01, 0x00, "Off"},
{0x13, 0x01, 0x01, 0x01, "On"},
{0, 0xFE, 0, 2, "Demo sound"},
{0x13, 0x01, 0x02, 0x00, "Off"},
{0x13, 0x01, 0x02, 0x02, "On"},
{0, 0xFE, 0, 4, "Difficulty"},
{0x13, 0x01, 0x0C, 0x00, "Normal"},
{0x13, 0x01, 0x0C, 0x04, "Easy"},
{0x13, 0x01, 0x0C, 0x08, "Hard"},
{0x13, 0x01, 0x0C, 0x0C, "Hardest"},
{0, 0xFE, 0, 4, "Lives"},
{0x13, 0x01, 0x30, 0x00, "3"},
{0x13, 0x01, 0x30, 0x10, "1"},
{0x13, 0x01, 0x30, 0x20, "2"},
{0x13, 0x01, 0x30, 0x30, "4"},
{0, 0xFE, 0, 2, "Bonus life"},
{0x13, 0x01, 0x40, 0x00, "200000"},
{0x13, 0x01, 0x40, 0x40, "300000"},
{0, 0xFE, 0, 2, "Service mode"},
{0x13, 0x01, 0x80, 0x00, "Off"},
{0x13, 0x01, 0x80, 0x80, "On"},
};
static struct BurnDIPInfo aerofgtDIPList[] = {
// Defaults
{0x14, 0xFF, 0xFF, 0x03, NULL},
// DIP 3
{0, 0xFE, 0, 5, "Region"},
{0x14, 0x01, 0x0F, 0x00, "USA / Canada"},
{0x14, 0x01, 0x0F, 0x01, "Korea"},
{0x14, 0x01, 0x0F, 0x02, "Hong Kong"},
{0x14, 0x01, 0x0F, 0x03, "World"},
{0x14, 0x01, 0x0F, 0x04, "Taiwan"},
};
static struct BurnDIPInfo aerofgtbDIPList[] = {
// Defaults
{0x14, 0xFF, 0xFF, 0x00, NULL},
// DIP 3
{0, 0xFE, 0, 4, "Region"},
{0x14, 0x01, 0x0F, 0x00, "USA / Canada"},
{0x14, 0x01, 0x0F, 0x01, "Korea"},
{0x14, 0x01, 0x0F, 0x02, "Hong Kong"},
{0x14, 0x01, 0x0F, 0x03, "Taiwan"},
{0x14, 0x01, 0x0F, 0x04, "Taiwan"},
};
STDDIPINFO(sonicwi)
STDDIPINFOEXT(aerofgt, sonicwi, aerofgt)
STDDIPINFOEXT(aerofgtb, sonicwi, aerofgtb)
// Rom information
static struct BurnRomInfo aerofgtRomDesc[] = {
{ "1.u4", 0x080000, 0x6fdff0a2, BRF_ESS | BRF_PRG }, // 68000 code swapped
{ "538a54.124", 0x080000, 0x4d2c4df2, BRF_GRA }, // graphics
{ "1538a54.124", 0x080000, 0x286d109e, BRF_GRA },
{ "538a53.u9", 0x100000, 0x630d8e0b, BRF_GRA }, //
{ "534g8f.u18", 0x080000, 0x76ce0926, BRF_GRA },
{ "2.153", 0x020000, 0xa1ef64ec, BRF_ESS | BRF_PRG }, // Sound CPU
{ "it-19-01", 0x040000, 0x6d42723d, BRF_SND }, // samples
{ "it-19-06", 0x100000, 0xcdbbdb1d, BRF_SND },
};
STD_ROM_PICK(aerofgt)
STD_ROM_FN(aerofgt)
static int MemIndex()
{
unsigned char *Next; Next = Mem;
Rom01 = Next; Next += 0x080000; // 68000 ROM
RomZ80 = Next; Next += 0x030000; // Z80 ROM
RomBg = Next; Next += 0x200040; // Background, 1M 8x8x4bit decode to 2M + 64Byte safe
DeRomBg = RomBg + 0x000040;
RomSpr1 = Next; Next += 0x200000; // Sprite 1 , 1M 16x16x4bit decode to 2M + 256Byte safe
RomSpr2 = Next; Next += 0x100100; // Sprite 2
DeRomSpr1 = RomSpr1 + 0x000100;
DeRomSpr2 = RomSpr2 += 0x000100;
RomSnd1 = Next; Next += 0x040000; // ADPCM data
RomSndSize1 = 0x040000;
RomSnd2 = Next; Next += 0x100000; // ADPCM data
RomSndSize2 = 0x100000;
RamStart = Next;
RamPal = Next; Next += 0x000800; // 1024 of X1R5G5B5 Palette
RamRaster = (unsigned short *)Next; Next += 0x001000; // 0x1b0000~0x1b07ff, Raster
// 0x1b0800~0x1b0801, NOP
// 0x1b0ff0~0x1b0fff, stack area during boot
RamBg1V = (unsigned short *)Next; Next += 0x002000; // BG1 Video Ram
RamBg2V = (unsigned short *)Next; Next += 0x002000; // BG2 Video Ram
RamSpr1 = (unsigned short *)Next; Next += 0x008000; // Sprite 1 Ram
RamSpr2 = (unsigned short *)Next; Next += 0x002000; // Sprite 2 Ram
Ram01 = Next; Next += 0x010000; // Work Ram
RamZ80 = Next; Next += 0x000800; // Z80 Ram 2K
RamEnd = Next;
RamCurPal = (unsigned int *)Next; Next += 0x000800 * sizeof(unsigned int); // 1024 colors
MemEnd = Next;
return 0;
}
static void DecodeBg()
{
for (int c=0x8000-1; c>=0; c--) {
for (int y=7; y>=0; y--) {
DeRomBg[(c * 64) + (y * 8) + 7] = RomBg[0x00002 + (y * 4) + (c * 32)] & 0x0f;
DeRomBg[(c * 64) + (y * 8) + 6] = RomBg[0x00002 + (y * 4) + (c * 32)] >> 4;
DeRomBg[(c * 64) + (y * 8) + 5] = RomBg[0x00003 + (y * 4) + (c * 32)] & 0x0f;
DeRomBg[(c * 64) + (y * 8) + 4] = RomBg[0x00003 + (y * 4) + (c * 32)] >> 4;
DeRomBg[(c * 64) + (y * 8) + 3] = RomBg[0x00000 + (y * 4) + (c * 32)] & 0x0f;
DeRomBg[(c * 64) + (y * 8) + 2] = RomBg[0x00000 + (y * 4) + (c * 32)] >> 4;
DeRomBg[(c * 64) + (y * 8) + 1] = RomBg[0x00001 + (y * 4) + (c * 32)] & 0x0f;
DeRomBg[(c * 64) + (y * 8) + 0] = RomBg[0x00001 + (y * 4) + (c * 32)] >> 4;
}
}
}
static void DecodeSpr(unsigned char *d, unsigned char *s, int cnt)
{
for (int c=cnt-1; c>=0; c--)
for (int y=15; y>=0; y--) {
d[(c * 256) + (y * 16) + 15] = s[0x00006 + (y * 8) + (c * 128)] & 0x0f;
d[(c * 256) + (y * 16) + 14] = s[0x00006 + (y * 8) + (c * 128)] >> 4;
d[(c * 256) + (y * 16) + 13] = s[0x00007 + (y * 8) + (c * 128)] & 0x0f;
d[(c * 256) + (y * 16) + 12] = s[0x00007 + (y * 8) + (c * 128)] >> 4;
d[(c * 256) + (y * 16) + 11] = s[0x00004 + (y * 8) + (c * 128)] & 0x0f;
d[(c * 256) + (y * 16) + 10] = s[0x00004 + (y * 8) + (c * 128)] >> 4;
d[(c * 256) + (y * 16) + 9] = s[0x00005 + (y * 8) + (c * 128)] & 0x0f;
d[(c * 256) + (y * 16) + 8] = s[0x00005 + (y * 8) + (c * 128)] >> 4;
d[(c * 256) + (y * 16) + 7] = s[0x00002 + (y * 8) + (c * 128)] & 0x0f;
d[(c * 256) + (y * 16) + 6] = s[0x00002 + (y * 8) + (c * 128)] >> 4;
d[(c * 256) + (y * 16) + 5] = s[0x00003 + (y * 8) + (c * 128)] & 0x0f;
d[(c * 256) + (y * 16) + 4] = s[0x00003 + (y * 8) + (c * 128)] >> 4;
d[(c * 256) + (y * 16) + 3] = s[0x00000 + (y * 8) + (c * 128)] & 0x0f;
d[(c * 256) + (y * 16) + 2] = s[0x00000 + (y * 8) + (c * 128)] >> 4;
d[(c * 256) + (y * 16) + 1] = s[0x00001 + (y * 8) + (c * 128)] & 0x0f;
d[(c * 256) + (y * 16) + 0] = s[0x00001 + (y * 8) + (c * 128)] >> 4;
}
}
static int LoadRoms()
{
// Load 68000 ROM
if (BurnLoadRom(Rom01, 0, 1)) {
return 1;
}
// Load Graphic
BurnLoadRom(RomBg, 1, 1);
BurnLoadRom(RomBg+0x80000, 2, 1);
DecodeBg();
BurnLoadRom(RomSpr1+0x000000, 3, 1);
BurnLoadRom(RomSpr1+0x100000, 4, 1);
DecodeSpr(DeRomSpr1, RomSpr1, 8192+4096);
// Load Z80 ROM
if (BurnLoadRom(RomZ80+0x10000, 5, 1)) return 1;
memcpy(RomZ80, RomZ80+0x10000, 0x10000);
BurnLoadRom(RomSnd1, 6, 1);
BurnLoadRom(RomSnd2, 7, 1);
return 0;
}
unsigned char __fastcall aerofgtReadByte(unsigned int sekAddress)
{
switch (sekAddress) {
case 0xFFFFA1:
return ~DrvInput[0];
case 0xFFFFA3:
return ~DrvInput[1];
case 0xFFFFA5:
return ~DrvInput[2];
case 0xFFFFA7:
return ~DrvInput[3];
case 0xFFFFA9:
return ~DrvInput[4];
case 0xFFFFAD:
//printf("read pending_command %d addr %08x\n", pending_command, sekAddress);
return pending_command;
case 0xFFFFAF:
return ~DrvInput[5];
// default:
// printf("Attempt to read byte value of location %x\n", sekAddress);
}
return 0;
}
/*
unsigned short __fastcall aerofgtReadWord(unsigned int sekAddress)
{
switch (sekAddress) {
default:
printf("Attempt to read word value of location %x\n", sekAddress);
}
return 0;
}
*/
static void SoundCommand(unsigned char nCommand)
{
// bprintf(PRINT_NORMAL, _T(" - Sound command sent (0x%02X).\n"), nCommand);
int nCycles = ((long long)SekTotalCycles() * nCyclesTotal[1] / nCyclesTotal[0]);
if (nCycles <= ZetTotalCycles()) return;
BurnTimerUpdate(nCycles);
nSoundlatch = nCommand;
ZetNmi();
}
void __fastcall aerofgtWriteByte(unsigned int sekAddress, unsigned char byteValue)
{
if (( sekAddress & 0xFF0000 ) == 0x1A0000) {
sekAddress &= 0xFFFF;
if (sekAddress < 0x800) {
RamPal[sekAddress^1] = byteValue;
// palette byte write at boot self-test only ?!
// if (sekAddress & 1)
// RamCurPal[sekAddress>>1] = CalcCol( *((unsigned short *)&RamPal[sekAddress]) );
}
return;
}
switch (sekAddress) {
case 0xFFFFC1:
pending_command = 1;
SoundCommand(byteValue);
break;
/*
case 0xFFFFB9:
case 0xFFFFBB:
case 0xFFFFBD:
case 0xFFFFBF:
break;
case 0xFFFFAD:
// NOP
break;
default:
printf("Attempt to write byte value %x to location %x\n", byteValue, sekAddress);
*/
}
}
void __fastcall aerofgtWriteWord(unsigned int sekAddress, unsigned short wordValue)
{
if (( sekAddress & 0xFF0000 ) == 0x1A0000) {
sekAddress &= 0xFFFF;
if (sekAddress < 0x800)
*((unsigned short *)&RamPal[sekAddress]) = wordValue;
RamCurPal[sekAddress>>1] = CalcCol( wordValue );
return;
}
switch (sekAddress) {
case 0xFFFF80:
RamGfxBank[0] = wordValue >> 0x08;
RamGfxBank[1] = wordValue & 0xFF;
break;
case 0xFFFF82:
RamGfxBank[2] = wordValue >> 0x08;
RamGfxBank[3] = wordValue & 0xFF;
break;
case 0xFFFF84:
RamGfxBank[4] = wordValue >> 0x08;
RamGfxBank[5] = wordValue & 0xFF;
break;
case 0xFFFF86:
RamGfxBank[6] = wordValue >> 0x08;
RamGfxBank[7] = wordValue & 0xFF;
break;
case 0xFFFF88:
bg1scrolly = (wordValue);
break;
case 0xFFFF90:
bg2scrolly = (wordValue);
break;
/*
case 0xFFFF40:
case 0xFFFF42:
case 0xFFFF44:
case 0xFFFF48:
case 0xFFFF4A:
case 0xFFFF4C:
case 0xFFFF50:
case 0xFFFF52:
case 0xFFFF60:
break;
default:
printf("Attempt to write word value %x to location %x\n", wordValue, sekAddress);
*/
}
}
static void aerofgtFMIRQHandler(int, int nStatus)
{
// bprintf(PRINT_NORMAL, _T(" - IRQ -> %i.\n"), nStatus);
if (nStatus) {
ZetSetIRQLine(0xFF, ZET_IRQSTATUS_ACK);
} else {
ZetSetIRQLine(0, ZET_IRQSTATUS_NONE);
}
}
static int aerofgtSynchroniseStream(int nSoundRate)
{
return (long long)ZetTotalCycles() * nSoundRate / 4000000;
}
static double aerofgtGetTime()
{
return (double)ZetTotalCycles() / 4000000.0;
}
/*
static unsigned char __fastcall aerofgtZ80Read(unsigned short a)
{
switch (a) {
default:
printf("Z80 Attempt to read word value of location %04x\n", a);
}
return 0;
}
static void __fastcall aerofgtZ80Write(unsigned short a,unsigned char v)
{
switch (a) {
default:
printf("Attempt to write word value %x to location %x\n", v, a);
}
}
*/
static void aerofgtSndBankSwitch(unsigned char v)
{
/*
UINT8 *rom = memory_region(REGION_CPU2) + 0x10000;
memory_set_bankptr(1,rom + (data & 0x03) * 0x8000);
*/
v &= 0x03;
if (v != nAerofgtZ80Bank) {
unsigned char* nStartAddress = RomZ80 + 0x10000 + (v << 15);
ZetMapArea(0x8000, 0xFFFF, 0, nStartAddress);
ZetMapArea(0x8000, 0xFFFF, 2, nStartAddress);
nAerofgtZ80Bank = v;
}
}
unsigned char __fastcall aerofgtZ80PortRead(unsigned short p)
{
switch (p & 0xFF) {
case 0x00:
return BurnYM2610Read(0);
case 0x02:
return BurnYM2610Read(2);
case 0x0C:
return nSoundlatch;
// default:
// printf("Z80 Attempt to read port %04x\n", p);
}
return 0;
}
void __fastcall aerofgtZ80PortWrite(unsigned short p, unsigned char v)
{
switch (p & 0x0FF) {
case 0x00:
case 0x01:
case 0x02:
case 0x03:
BurnYM2610Write(p & 3, v);
break;
case 0x04:
aerofgtSndBankSwitch(v);
break;
case 0x08:
pending_command = 0;
break;
// default:
// printf("Z80 Attempt to write %02x to port %04x\n", v, p);
}
}
static int DrvDoReset()
{
nAerofgtZ80Bank = -1;
SekOpen(0);
//nIRQPending = 0;
SekSetIRQLine(0, SEK_IRQSTATUS_NONE);
SekReset();
SekClose();
ZetOpen(0);
ZetReset();
aerofgtSndBankSwitch(0);
ZetClose();
BurnYM2610Reset();
memset(RamGfxBank, 0 , sizeof(RamGfxBank));
return 0;
}
static int aerofgtInit()
{
Mem = NULL;
MemIndex();
int nLen = MemEnd - (unsigned char *)0;
if ((Mem = (unsigned char *)malloc(nLen)) == NULL) {
return 1;
}
memset(Mem, 0, nLen); // blank all memory
MemIndex();
// Load the roms into memory
if (LoadRoms()) {
return 1;
}
{
SekInit(0, 0x68000); // Allocate 68000
SekOpen(0);
// Map 68000 memory:
SekMapMemory(Rom01, 0x000000, 0x07FFFF, SM_ROM); // CPU 0 ROM
SekMapMemory(RamPal, 0x1A0000, 0x1A07FF, SM_ROM); // Palette
SekMapMemory((unsigned char *)RamRaster,
0x1B0000, 0x1B0FFF, SM_RAM); // Raster / MRA_NOP / MRA_BANK7
SekMapMemory((unsigned char *)RamBg1V,
0x1B2000, 0x1B3FFF, SM_RAM);
SekMapMemory((unsigned char *)RamBg2V,
0x1B4000, 0x1B5FFF, SM_RAM);
SekMapMemory((unsigned char *)RamSpr1,
0x1C0000, 0x1C7FFF, SM_RAM);
SekMapMemory((unsigned char *)RamSpr2,
0x1D0000, 0x1D1FFF, SM_RAM);
SekMapMemory(Ram01, 0xFEF000, 0xFFEFFF, SM_RAM); // 64K Work RAM
// SekSetReadWordHandler(0, aerofgtReadWord);
SekSetReadByteHandler(0, aerofgtReadByte);
SekSetWriteWordHandler(0, aerofgtWriteWord);
SekSetWriteByteHandler(0, aerofgtWriteByte);
SekClose();
}
{
ZetInit(1);
ZetOpen(0);
ZetMapArea(0x0000, 0x77FF, 0, RomZ80);
ZetMapArea(0x0000, 0x77FF, 2, RomZ80);
ZetMapArea(0x7800, 0x7FFF, 0, RamZ80);
ZetMapArea(0x7800, 0x7FFF, 1, RamZ80);
ZetMapArea(0x7800, 0x7FFF, 2, RamZ80);
ZetMemEnd();
//ZetSetReadHandler(aerofgtZ80Read);
//ZetSetWriteHandler(aerofgtZ80Write);
ZetSetInHandler(aerofgtZ80PortRead);
ZetSetOutHandler(aerofgtZ80PortWrite);
ZetClose();
}
BurnYM2610Init(8000000, RomSnd2, &RomSndSize2, RomSnd1, &RomSndSize1, &aerofgtFMIRQHandler, aerofgtSynchroniseStream, aerofgtGetTime, 0);
BurnTimerAttachZet(5000000);
DrvDoReset(); // Reset machine
return 0;
}
static int DrvExit()
{
BurnYM2610Exit();
ZetExit();
SekExit();
free(Mem);
Mem = NULL;
return 0;
}
static void drawgfxzoom(int bank,unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,int scalex,int scaley)
{
if (!scalex || !scaley) return;
unsigned short * p = (unsigned short *) pBurnDraw;
unsigned char * q;
unsigned int * pal;
if (bank) {
q = DeRomSpr2 + (code) * 256;
pal = RamCurPal + 768;
} else {
q = DeRomSpr1 + (code) * 256;
pal = RamCurPal + 512;
}
p += sy * 320 + sx;
if (sx < 0 || sx >= 304 || sy < 0 || sy >= 208 ) {
if ((sx <= -16) || (sx >= 320) || (sy <= -16) || (sy >= 224))
return;
if (flipy) {
p += 320 * 15;
if (flipx) {
for (int i=15;i>=0;i--) {
if (((sy+i)>=0) && ((sy+i)<224)) {
if (q[ 0] != 15 && ((sx + 15) >= 0) && ((sx + 15)<320)) p[15] = pal[ q[ 0] | color];
if (q[ 1] != 15 && ((sx + 14) >= 0) && ((sx + 14)<320)) p[14] = pal[ q[ 1] | color];
if (q[ 2] != 15 && ((sx + 13) >= 0) && ((sx + 13)<320)) p[13] = pal[ q[ 2] | color];
if (q[ 3] != 15 && ((sx + 12) >= 0) && ((sx + 12)<320)) p[12] = pal[ q[ 3] | color];
if (q[ 4] != 15 && ((sx + 11) >= 0) && ((sx + 11)<320)) p[11] = pal[ q[ 4] | color];
if (q[ 5] != 15 && ((sx + 10) >= 0) && ((sx + 10)<320)) p[10] = pal[ q[ 5] | color];
if (q[ 6] != 15 && ((sx + 9) >= 0) && ((sx + 9)<320)) p[ 9] = pal[ q[ 6] | color];
if (q[ 7] != 15 && ((sx + 8) >= 0) && ((sx + 8)<320)) p[ 8] = pal[ q[ 7] | color];
if (q[ 8] != 15 && ((sx + 7) >= 0) && ((sx + 7)<320)) p[ 7] = pal[ q[ 8] | color];
if (q[ 9] != 15 && ((sx + 6) >= 0) && ((sx + 6)<320)) p[ 6] = pal[ q[ 9] | color];
if (q[10] != 15 && ((sx + 5) >= 0) && ((sx + 5)<320)) p[ 5] = pal[ q[10] | color];
if (q[11] != 15 && ((sx + 4) >= 0) && ((sx + 4)<320)) p[ 4] = pal[ q[11] | color];
if (q[12] != 15 && ((sx + 3) >= 0) && ((sx + 3)<320)) p[ 3] = pal[ q[12] | color];
if (q[13] != 15 && ((sx + 2) >= 0) && ((sx + 2)<320)) p[ 2] = pal[ q[13] | color];
if (q[14] != 15 && ((sx + 1) >= 0) && ((sx + 1)<320)) p[ 1] = pal[ q[14] | color];
if (q[15] != 15 && ((sx + 0) >= 0) && ((sx + 0)<320)) p[ 0] = pal[ q[15] | color];
}
p -= 320;
q += 16;
}
} else {
for (int i=15;i>=0;i--) {
if (((sy+i)>=0) && ((sy+i)<224)) {
if (q[ 0] != 15 && ((sx + 0) >= 0) && ((sx + 0)<320)) p[ 0] = pal[ q[ 0] | color];
if (q[ 1] != 15 && ((sx + 1) >= 0) && ((sx + 1)<320)) p[ 1] = pal[ q[ 1] | color];
if (q[ 2] != 15 && ((sx + 2) >= 0) && ((sx + 2)<320)) p[ 2] = pal[ q[ 2] | color];
if (q[ 3] != 15 && ((sx + 3) >= 0) && ((sx + 3)<320)) p[ 3] = pal[ q[ 3] | color];
if (q[ 4] != 15 && ((sx + 4) >= 0) && ((sx + 4)<320)) p[ 4] = pal[ q[ 4] | color];
if (q[ 5] != 15 && ((sx + 5) >= 0) && ((sx + 5)<320)) p[ 5] = pal[ q[ 5] | color];
if (q[ 6] != 15 && ((sx + 6) >= 0) && ((sx + 6)<320)) p[ 6] = pal[ q[ 6] | color];
if (q[ 7] != 15 && ((sx + 7) >= 0) && ((sx + 7)<320)) p[ 7] = pal[ q[ 7] | color];
if (q[ 8] != 15 && ((sx + 8) >= 0) && ((sx + 8)<320)) p[ 8] = pal[ q[ 8] | color];
if (q[ 9] != 15 && ((sx + 9) >= 0) && ((sx + 9)<320)) p[ 9] = pal[ q[ 9] | color];
if (q[10] != 15 && ((sx + 10) >= 0) && ((sx + 10)<320)) p[10] = pal[ q[10] | color];
if (q[11] != 15 && ((sx + 11) >= 0) && ((sx + 11)<320)) p[11] = pal[ q[11] | color];
if (q[12] != 15 && ((sx + 12) >= 0) && ((sx + 12)<320)) p[12] = pal[ q[12] | color];
if (q[13] != 15 && ((sx + 13) >= 0) && ((sx + 13)<320)) p[13] = pal[ q[13] | color];
if (q[14] != 15 && ((sx + 14) >= 0) && ((sx + 14)<320)) p[14] = pal[ q[14] | color];
if (q[15] != 15 && ((sx + 15) >= 0) && ((sx + 15)<320)) p[15] = pal[ q[15] | color];
}
p -= 320;
q += 16;
}
}
} else {
if (flipx) {
for (int i=0;i<16;i++) {
if (((sy+i)>=0) && ((sy+i)<224)) {
if (q[ 0] != 15 && ((sx + 15) >= 0) && ((sx + 15)<320)) p[15] = pal[ q[ 0] | color];
if (q[ 1] != 15 && ((sx + 14) >= 0) && ((sx + 14)<320)) p[14] = pal[ q[ 1] | color];
if (q[ 2] != 15 && ((sx + 13) >= 0) && ((sx + 13)<320)) p[13] = pal[ q[ 2] | color];
if (q[ 3] != 15 && ((sx + 12) >= 0) && ((sx + 12)<320)) p[12] = pal[ q[ 3] | color];
if (q[ 4] != 15 && ((sx + 11) >= 0) && ((sx + 11)<320)) p[11] = pal[ q[ 4] | color];
if (q[ 5] != 15 && ((sx + 10) >= 0) && ((sx + 10)<320)) p[10] = pal[ q[ 5] | color];
if (q[ 6] != 15 && ((sx + 9) >= 0) && ((sx + 9)<320)) p[ 9] = pal[ q[ 6] | color];
if (q[ 7] != 15 && ((sx + 8) >= 0) && ((sx + 8)<320)) p[ 8] = pal[ q[ 7] | color];
if (q[ 8] != 15 && ((sx + 7) >= 0) && ((sx + 7)<320)) p[ 7] = pal[ q[ 8] | color];
if (q[ 9] != 15 && ((sx + 6) >= 0) && ((sx + 6)<320)) p[ 6] = pal[ q[ 9] | color];
if (q[10] != 15 && ((sx + 5) >= 0) && ((sx + 5)<320)) p[ 5] = pal[ q[10] | color];
if (q[11] != 15 && ((sx + 4) >= 0) && ((sx + 4)<320)) p[ 4] = pal[ q[11] | color];
if (q[12] != 15 && ((sx + 3) >= 0) && ((sx + 3)<320)) p[ 3] = pal[ q[12] | color];
if (q[13] != 15 && ((sx + 2) >= 0) && ((sx + 2)<320)) p[ 2] = pal[ q[13] | color];
if (q[14] != 15 && ((sx + 1) >= 0) && ((sx + 1)<320)) p[ 1] = pal[ q[14] | color];
if (q[15] != 15 && ((sx + 0) >= 0) && ((sx + 0)<320)) p[ 0] = pal[ q[15] | color];
}
p += 320;
q += 16;
}
} else {
for (int i=0;i<16;i++) {
if (((sy+i)>=0) && ((sy+i)<224)) {
if (q[ 0] != 15 && ((sx + 0) >= 0) && ((sx + 0)<320)) p[ 0] = pal[ q[ 0] | color];
if (q[ 1] != 15 && ((sx + 1) >= 0) && ((sx + 1)<320)) p[ 1] = pal[ q[ 1] | color];
if (q[ 2] != 15 && ((sx + 2) >= 0) && ((sx + 2)<320)) p[ 2] = pal[ q[ 2] | color];
if (q[ 3] != 15 && ((sx + 3) >= 0) && ((sx + 3)<320)) p[ 3] = pal[ q[ 3] | color];
if (q[ 4] != 15 && ((sx + 4) >= 0) && ((sx + 4)<320)) p[ 4] = pal[ q[ 4] | color];
if (q[ 5] != 15 && ((sx + 5) >= 0) && ((sx + 5)<320)) p[ 5] = pal[ q[ 5] | color];
if (q[ 6] != 15 && ((sx + 6) >= 0) && ((sx + 6)<320)) p[ 6] = pal[ q[ 6] | color];
if (q[ 7] != 15 && ((sx + 7) >= 0) && ((sx + 7)<320)) p[ 7] = pal[ q[ 7] | color];
if (q[ 8] != 15 && ((sx + 8) >= 0) && ((sx + 8)<320)) p[ 8] = pal[ q[ 8] | color];
if (q[ 9] != 15 && ((sx + 9) >= 0) && ((sx + 9)<320)) p[ 9] = pal[ q[ 9] | color];
if (q[10] != 15 && ((sx + 10) >= 0) && ((sx + 10)<320)) p[10] = pal[ q[10] | color];
if (q[11] != 15 && ((sx + 11) >= 0) && ((sx + 11)<320)) p[11] = pal[ q[11] | color];
if (q[12] != 15 && ((sx + 12) >= 0) && ((sx + 12)<320)) p[12] = pal[ q[12] | color];
if (q[13] != 15 && ((sx + 13) >= 0) && ((sx + 13)<320)) p[13] = pal[ q[13] | color];
if (q[14] != 15 && ((sx + 14) >= 0) && ((sx + 14)<320)) p[14] = pal[ q[14] | color];
if (q[15] != 15 && ((sx + 15) >= 0) && ((sx + 15)<320)) p[15] = pal[ q[15] | color];
}
p += 320;
q += 16;
}
}
}
return;
}
if (flipy) {
p += 320 * 15;
if (flipx) {
for (int i=0;i<16;i++) {
if (q[ 0] != 15) p[15] = pal[ q[ 0] | color];
if (q[ 1] != 15) p[14] = pal[ q[ 1] | color];
if (q[ 2] != 15) p[13] = pal[ q[ 2] | color];
if (q[ 3] != 15) p[12] = pal[ q[ 3] | color];
if (q[ 4] != 15) p[11] = pal[ q[ 4] | color];
if (q[ 5] != 15) p[10] = pal[ q[ 5] | color];
if (q[ 6] != 15) p[ 9] = pal[ q[ 6] | color];
if (q[ 7] != 15) p[ 8] = pal[ q[ 7] | color];
if (q[ 8] != 15) p[ 7] = pal[ q[ 8] | color];
if (q[ 9] != 15) p[ 6] = pal[ q[ 9] | color];
if (q[10] != 15) p[ 5] = pal[ q[10] | color];
if (q[11] != 15) p[ 4] = pal[ q[11] | color];
if (q[12] != 15) p[ 3] = pal[ q[12] | color];
if (q[13] != 15) p[ 2] = pal[ q[13] | color];
if (q[14] != 15) p[ 1] = pal[ q[14] | color];
if (q[15] != 15) p[ 0] = pal[ q[15] | color];
p -= 320;
q += 16;
}
} else {
for (int i=0;i<16;i++) {
if (q[ 0] != 15) p[ 0] = pal[ q[ 0] | color];
if (q[ 1] != 15) p[ 1] = pal[ q[ 1] | color];
if (q[ 2] != 15) p[ 2] = pal[ q[ 2] | color];
if (q[ 3] != 15) p[ 3] = pal[ q[ 3] | color];
if (q[ 4] != 15) p[ 4] = pal[ q[ 4] | color];
if (q[ 5] != 15) p[ 5] = pal[ q[ 5] | color];
if (q[ 6] != 15) p[ 6] = pal[ q[ 6] | color];
if (q[ 7] != 15) p[ 7] = pal[ q[ 7] | color];
if (q[ 8] != 15) p[ 8] = pal[ q[ 8] | color];
if (q[ 9] != 15) p[ 9] = pal[ q[ 9] | color];
if (q[10] != 15) p[10] = pal[ q[10] | color];
if (q[11] != 15) p[11] = pal[ q[11] | color];
if (q[12] != 15) p[12] = pal[ q[12] | color];
if (q[13] != 15) p[13] = pal[ q[13] | color];
if (q[14] != 15) p[14] = pal[ q[14] | color];
if (q[15] != 15) p[15] = pal[ q[15] | color];
p -= 320;
q += 16;
}
}
} else {
if (flipx) {
for (int i=0;i<16;i++) {
if (q[ 0] != 15) p[15] = pal[ q[ 0] | color];
if (q[ 1] != 15) p[14] = pal[ q[ 1] | color];
if (q[ 2] != 15) p[13] = pal[ q[ 2] | color];
if (q[ 3] != 15) p[12] = pal[ q[ 3] | color];
if (q[ 4] != 15) p[11] = pal[ q[ 4] | color];
if (q[ 5] != 15) p[10] = pal[ q[ 5] | color];
if (q[ 6] != 15) p[ 9] = pal[ q[ 6] | color];
if (q[ 7] != 15) p[ 8] = pal[ q[ 7] | color];
if (q[ 8] != 15) p[ 7] = pal[ q[ 8] | color];
if (q[ 9] != 15) p[ 6] = pal[ q[ 9] | color];
if (q[10] != 15) p[ 5] = pal[ q[10] | color];
if (q[11] != 15) p[ 4] = pal[ q[11] | color];
if (q[12] != 15) p[ 3] = pal[ q[12] | color];
if (q[13] != 15) p[ 2] = pal[ q[13] | color];
if (q[14] != 15) p[ 1] = pal[ q[14] | color];
if (q[15] != 15) p[ 0] = pal[ q[15] | color];
p += 320;
q += 16;
}
} else {
for (int i=0;i<16;i++) {
if (q[ 0] != 15) p[ 0] = pal[ q[ 0] | color];
if (q[ 1] != 15) p[ 1] = pal[ q[ 1] | color];
if (q[ 2] != 15) p[ 2] = pal[ q[ 2] | color];
if (q[ 3] != 15) p[ 3] = pal[ q[ 3] | color];
if (q[ 4] != 15) p[ 4] = pal[ q[ 4] | color];
if (q[ 5] != 15) p[ 5] = pal[ q[ 5] | color];
if (q[ 6] != 15) p[ 6] = pal[ q[ 6] | color];
if (q[ 7] != 15) p[ 7] = pal[ q[ 7] | color];
if (q[ 8] != 15) p[ 8] = pal[ q[ 8] | color];
if (q[ 9] != 15) p[ 9] = pal[ q[ 9] | color];
if (q[10] != 15) p[10] = pal[ q[10] | color];
if (q[11] != 15) p[11] = pal[ q[11] | color];
if (q[12] != 15) p[12] = pal[ q[12] | color];
if (q[13] != 15) p[13] = pal[ q[13] | color];
if (q[14] != 15) p[14] = pal[ q[14] | color];
if (q[15] != 15) p[15] = pal[ q[15] | color];
p += 320;
q += 16;
}
}
}
}
static void aerofgt_drawsprites(int priority)
{
priority <<= 12;
int offs = 0;
while (offs < 0x0400 && (swapWord(RamSpr2[offs]) & 0x8000) == 0) {
int attr_start = (swapWord(RamSpr2[offs]) & 0x03ff) * 4;
/* is the way I handle priority correct? Or should I just check bit 13? */
if ((swapWord(RamSpr2[attr_start + 2]) & 0x3000) == priority) {
int map_start;
int ox,oy,x,y,xsize,ysize,zoomx,zoomy,flipx,flipy,color;
ox = swapWord(RamSpr2[attr_start + 1]) & 0x01ff;
xsize = (swapWord(RamSpr2[attr_start + 1]) & 0x0e00) >> 9;
zoomx = (swapWord(RamSpr2[attr_start + 1]) & 0xf000) >> 12;
oy = swapWord(RamSpr2[attr_start + 0]) & 0x01ff;
ysize = (swapWord(RamSpr2[attr_start + 0]) & 0x0e00) >> 9;
zoomy = (swapWord(RamSpr2[attr_start + 0]) & 0xf000) >> 12;
flipx = swapWord(RamSpr2[attr_start + 2]) & 0x4000;
flipy = swapWord(RamSpr2[attr_start + 2]) & 0x8000;
color = (swapWord(RamSpr2[attr_start + 2]) & 0x0f00) >> 4;
map_start = swapWord(RamSpr2[attr_start + 3]) & 0x3fff;
ox += (xsize*zoomx+2)/4;
oy += (ysize*zoomy+2)/4;
zoomx = 32 - zoomx;
zoomy = 32 - zoomy;
for (y = 0;y <= ysize;y++) {
int sx,sy;
if (flipy) sy = ((oy + zoomy * (ysize - y)/2 + 16) & 0x1ff) - 16;
else sy = ((oy + zoomy * y / 2 + 16) & 0x1ff) - 16;
for (x = 0;x <= xsize;x++) {
if (flipx) sx = ((ox + zoomx * (xsize - x) / 2 + 16) & 0x1ff) - 16;
else sx = ((ox + zoomx * x / 2 + 16) & 0x1ff) - 16;
//if (map_start < 0x2000)
int code = swapWord(RamSpr1[map_start]) & 0x1fff;
drawgfxzoom(map_start&0x2000,code,color,flipx,flipy,sx,sy,zoomx<<11, zoomy<<11);
map_start++;
}
}
}
offs++;
}
}
/*
* aerofgt Background Tile
* 16-bit tile code in RamBg1V and RamBg2V
* 0xE000 shr 13 is Color
* 0x1800 shr 11 is Gfx Bank
* 0x07FF shr 0 or Tile element index (low part)
*
*/
static void TileBackground_1(unsigned short *bg, unsigned int *pal)
{
int offs, mx, my, x, y;
mx = -1;
my = 0;
for (offs = 0; offs < 64*64; offs++) {
mx++;
if (mx == 64) {
mx = 0;
my++;
}
x = mx * 8 - swapWord(RamRaster[0x0000]) + 18;
if (x <= -192) x += 512;
y = my * 8 - (bg1scrolly & 0x1FF);
if (y <= (224-512)) y += 512;
if ( x<=-8 || x>=320 || y<=-8 || y>= 224 )
continue;
else
if ( x >=0 && x < 312 && y >= 0 && y < 216) {
unsigned char *d = DeRomBg + ( (swapWord(bg[offs]) & 0x07FF) + ( RamGfxBank[((swapWord(bg[offs]) & 0x1800) >> 11)] << 11 ) ) * 64;
unsigned short c = (swapWord(bg[offs]) & 0xE000) >> 9;
unsigned short * p = (unsigned short *) pBurnDraw + y * 320 + x;
for (int k=0;k<8;k++) {
p[0] = pal[ d[0] | c ];
p[1] = pal[ d[1] | c ];
p[2] = pal[ d[2] | c ];
p[3] = pal[ d[3] | c ];
p[4] = pal[ d[4] | c ];
p[5] = pal[ d[5] | c ];
p[6] = pal[ d[6] | c ];
p[7] = pal[ d[7] | c ];
d += 8;
p += 320;
}
} else {
unsigned char *d = DeRomBg + ( (swapWord(bg[offs]) & 0x07FF) + ( RamGfxBank[((swapWord(bg[offs]) & 0x1800) >> 11)] << 11 ) ) * 64;
unsigned short c = (swapWord(bg[offs]) & 0xE000) >> 9;
unsigned short * p = (unsigned short *) pBurnDraw + y * 320 + x;
for (int k=0;k<8;k++) {
if ( (y+k)>=0 && (y+k)<224 ) {
if ((x + 0) >= 0 && (x + 0)<320) p[0] = pal[ d[0] | c ];
if ((x + 1) >= 0 && (x + 1)<320) p[1] = pal[ d[1] | c ];
if ((x + 2) >= 0 && (x + 2)<320) p[2] = pal[ d[2] | c ];
if ((x + 3) >= 0 && (x + 3)<320) p[3] = pal[ d[3] | c ];
if ((x + 4) >= 0 && (x + 4)<320) p[4] = pal[ d[4] | c ];
if ((x + 5) >= 0 && (x + 5)<320) p[5] = pal[ d[5] | c ];
if ((x + 6) >= 0 && (x + 6)<320) p[6] = pal[ d[6] | c ];
if ((x + 7) >= 0 && (x + 7)<320) p[7] = pal[ d[7] | c ];
}
d += 8;
p += 320;
}
}
}
}
static void TileBackground_2(unsigned short *bg, unsigned int *pal)
{
int offs, mx, my, x, y;
mx = -1;
my = 0;
for (offs = 0; offs < 64*64; offs++) {
mx++;
if (mx == 64) {
mx = 0;
my++;
}
x = mx * 8 - swapWord(RamRaster[0x0200]) + 20;
if (x <= -192) x += 512;
y = my * 8 - (bg2scrolly & 0x1FF);
if (y <= (224-512)) y += 512;
if ( x<=-8 || x>=320 || y<=-8 || y>= 224 )
continue;
else
if ( x >=0 && x < 312 && y >= 0 && y < 216) {
unsigned char *d = DeRomBg + ( (swapWord(bg[offs]) & 0x07FF) + ( RamGfxBank[((swapWord(bg[offs]) & 0x1800) >> 11) + 4] << 11 ) ) * 64;
unsigned short c = (swapWord(bg[offs]) & 0xE000) >> 9;
unsigned short * p = (unsigned short *) pBurnDraw + y * 320 + x;
for (int k=0;k<8;k++) {
if (d[0] != 15) p[0] = pal[ d[0] | c ];
if (d[1] != 15) p[1] = pal[ d[1] | c ];
if (d[2] != 15) p[2] = pal[ d[2] | c ];
if (d[3] != 15) p[3] = pal[ d[3] | c ];
if (d[4] != 15) p[4] = pal[ d[4] | c ];
if (d[5] != 15) p[5] = pal[ d[5] | c ];
if (d[6] != 15) p[6] = pal[ d[6] | c ];
if (d[7] != 15) p[7] = pal[ d[7] | c ];
d += 8;
p += 320;
}
} else {
unsigned char *d = DeRomBg + ( (swapWord(bg[offs]) & 0x07FF) + ( RamGfxBank[((swapWord(bg[offs]) & 0x1800) >> 11) + 4] << 11 ) ) * 64;
unsigned short c = (swapWord(bg[offs]) & 0xE000) >> 9;
unsigned short * p = (unsigned short *) pBurnDraw + y * 320 + x;
for (int k=0;k<8;k++) {
if ( (y+k)>=0 && (y+k)<224 ) {
if (d[0] != 15 && (x + 0) >= 0 && (x + 0)<320) p[0] = pal[ d[0] | c ];
if (d[1] != 15 && (x + 1) >= 0 && (x + 1)<320) p[1] = pal[ d[1] | c ];
if (d[2] != 15 && (x + 2) >= 0 && (x + 2)<320) p[2] = pal[ d[2] | c ];
if (d[3] != 15 && (x + 3) >= 0 && (x + 3)<320) p[3] = pal[ d[3] | c ];
if (d[4] != 15 && (x + 4) >= 0 && (x + 4)<320) p[4] = pal[ d[4] | c ];
if (d[5] != 15 && (x + 5) >= 0 && (x + 5)<320) p[5] = pal[ d[5] | c ];
if (d[6] != 15 && (x + 6) >= 0 && (x + 6)<320) p[6] = pal[ d[6] | c ];
if (d[7] != 15 && (x + 7) >= 0 && (x + 7)<320) p[7] = pal[ d[7] | c ];
}
d += 8;
p += 320;
}
}
}
}
static int DrvDraw()
{
// update palette
aerofgtPalUpdate();
// background 1
TileBackground_1(RamBg1V, RamCurPal);
aerofgt_drawsprites(0);
aerofgt_drawsprites(1);
// background 2
TileBackground_2(RamBg2V, RamCurPal + 256);
aerofgt_drawsprites(2);
aerofgt_drawsprites(3);
return 0;
}
static int DrvFrame()
{
if (DrvReset) { // Reset machine
DrvDoReset();
}
// Compile digital inputs
DrvInput[0] = 0x00; // Joy1
DrvInput[1] = 0x00; // Joy2
DrvInput[2] = 0x00; // Buttons
for (int i = 0; i < 8; i++) {
DrvInput[0] |= (DrvJoy1[i] & 1) << i;
DrvInput[1] |= (DrvJoy2[i] & 1) << i;
DrvInput[2] |= (DrvButton[i] & 1) << i;
}
SekNewFrame();
ZetNewFrame();
nCyclesTotal[0] = (int)((long long)10000000 * nBurnCPUSpeedAdjust / (0x0100 * 60));
nCyclesTotal[1] = (int)(5000000 / 60);
// SekSetCyclesScanline(nCyclesTotal[0] / 262);
SekOpen(0);
ZetOpen(0);
SekRun(nCyclesTotal[0]);
SekSetIRQLine(1, SEK_IRQSTATUS_AUTO);
BurnTimerEndFrame(nCyclesTotal[1]);
BurnYM2610Update(pBurnSoundOut, nBurnSoundLen);
ZetClose();
SekClose();
if (pBurnDraw) DrvDraw();
return 0;
}
static int DrvScan(int nAction,int *pnMin)
{
struct BurnArea ba;
if (pnMin) { // Return minimum compatible version
*pnMin = 0x029671;
}
if (nAction & ACB_MEMORY_RAM) { // Scan all memory, devices & variables
memset(&ba, 0, sizeof(ba));
ba.Data = RamStart;
ba.nLen = RamEnd-RamStart;
ba.szName = "All Ram";
BurnAcb(&ba);
if (nAction & ACB_WRITE) {
// update palette while loaded
unsigned short* ps = (unsigned short*) RamPal;
unsigned int* pd = RamCurPal;
for (int i=0; i<1024; i++, ps++, pd++)
*pd = CalcCol(*ps);
}
}
if (nAction & ACB_DRIVER_DATA) {
SekScan(nAction); // Scan 68000 state
ZetOpen(0);
ZetScan(nAction); // Scan Z80 state
ZetClose();
BurnYM2610Scan(nAction, pnMin);
SCAN_VAR(nSoundlatch);
SCAN_VAR(nAerofgtZ80Bank);
SCAN_VAR(RamGfxBank);
SCAN_VAR(RamCurPal);
SCAN_VAR(DrvInput);
if (nAction & ACB_WRITE) {
int nBank = nAerofgtZ80Bank;
nAerofgtZ80Bank = -1;
aerofgtSndBankSwitch(nBank);
}
}
return 0;
}
struct BurnDriver BurnDrvAerofgt = {
"aerofgt", NULL, NULL, "1992",
"Aero Fighters\0", NULL, "Video System Co.", "Video System",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_16BIT_ONLY, 2, HARDWARE_MISC_MISC,
NULL, aerofgtRomInfo, aerofgtRomName, aerofgtInputInfo, aerofgtDIPInfo,
aerofgtInit,DrvExit,DrvFrame,DrvDraw,DrvScan,
NULL,224,320,3,4
};
// ------------------------------------------------------
static struct BurnInputInfo turbofrcInputList[] = {
{"P1 Coin", BIT_DIGITAL, DrvButton + 0, "p1 coin"},
{"P1 Start", BIT_DIGITAL, DrvButton + 2, "p1 start"},
{"P1 Up", BIT_DIGITAL, DrvJoy1 + 0, "p1 up"},
{"P1 Down", BIT_DIGITAL, DrvJoy1 + 1, "p1 down"},
{"P1 Left", BIT_DIGITAL, DrvJoy1 + 2, "p1 left"},
{"P1 Right", BIT_DIGITAL, DrvJoy1 + 3, "p1 right"},
{"P1 Button 1", BIT_DIGITAL, DrvJoy1 + 4, "p1 fire 1"},
{"P2 Coin", BIT_DIGITAL, DrvButton + 1, "p2 coin"},
{"P2 Start", BIT_DIGITAL, DrvButton + 3, "p2 start"},
{"P2 Up", BIT_DIGITAL, DrvJoy2 + 0, "p2 up"},
{"P2 Down", BIT_DIGITAL, DrvJoy2 + 1, "p2 down"},
{"P2 Left", BIT_DIGITAL, DrvJoy2 + 2, "p2 left"},
{"P2 Right", BIT_DIGITAL, DrvJoy2 + 3, "p2 right"},
{"P2 Button 1", BIT_DIGITAL, DrvJoy2 + 4, "p2 fire 1"},
{"P3 Coin", BIT_DIGITAL, DrvButton + 7, "p3 coin"},
{"P3 Start", BIT_DIGITAL, DrvJoy3 + 7, "p3 start"},
{"P3 Up", BIT_DIGITAL, DrvJoy3 + 0, "p3 up"},
{"P3 Down", BIT_DIGITAL, DrvJoy3 + 1, "p3 down"},
{"P3 Left", BIT_DIGITAL, DrvJoy3 + 2, "p3 left"},
{"P3 Right", BIT_DIGITAL, DrvJoy3 + 3, "p3 right"},
{"P3 Button 1", BIT_DIGITAL, DrvJoy3 + 4, "p3 fire 1"},
{"Reset", BIT_DIGITAL, &DrvReset, "reset"},
// {"Service", BIT_DIGITAL, DrvButton + 6, "service"}, // Service + p3 coin
// {"Test", BIT_DIGITAL, DrvButton + 4, "diag"},
// {"Tilt", BIT_DIGITAL, DrvButton + 5, "tilt"},
{"Dip A", BIT_DIPSWITCH, DrvInput + 4, "dip"},
{"Dip B", BIT_DIPSWITCH, DrvInput + 5, "dip"},
};
STDINPUTINFO(turbofrc)
static struct BurnDIPInfo turbofrcDIPList[] = {
// Defaults
{0x16, 0xFF, 0xFF, 0x70, NULL},
{0x17, 0xFF, 0xFF, 0x06, NULL},
// DIP 1
{0, 0xFE, 0, 8, "Coinage"},
{0x16, 0x82, 0x07, 0x00, "1 coin 1 credit"},
{0x16, 0x00, 0x08, 0x08, NULL},
{0x16, 0x82, 0x07, 0x01, "2 coins 1 credit"},
{0x16, 0x00, 0x08, 0x08, NULL},
{0x16, 0x82, 0x07, 0x02, "3 coins 1 credit"},
{0x16, 0x00, 0x08, 0x08, NULL},
{0x16, 0x82, 0x07, 0x03, "4 coins 1 credit"},
{0x16, 0x00, 0x08, 0x08, NULL},
{0x16, 0x82, 0x07, 0x04, "1 coin 2 credits"},
{0x16, 0x00, 0x08, 0x08, NULL},
{0x16, 0x82, 0x07, 0x05, "1 coin 3 credits"},
{0x16, 0x00, 0x08, 0x08, NULL},
{0x16, 0x82, 0x07, 0x06, "1 coin 5 credits"},
{0x16, 0x00, 0x08, 0x08, NULL},
{0x16, 0x82, 0x07, 0x07, "1 coin 6 credits"},
{0x16, 0x00, 0x08, 0x08, NULL},
{0, 0xFE, 0, 2, "2 coins to start, 1 to continue"},
{0x16, 0x01, 0x08, 0x00, "Off"},
{0x16, 0x01, 0x08, 0x08, "On"},
{0, 0xFE, 0, 2, "Coin slot"},
{0x16, 0x01, 0x10, 0x00, "Same"},
{0x16, 0x01, 0x10, 0x10, "Individual"},
{0, 0xFE, 0, 2, "Play mode"},
{0x16, 0x01, 0x20, 0x00, "2 players"},
{0x16, 0x01, 0x20, 0x20, "3 players"},
{0, 0xFE, 0, 2, "Demo sounds"},
{0x16, 0x01, 0x40, 0x00, "Off"},
{0x16, 0x01, 0x40, 0x40, "On"},
{0, 0xFE, 0, 2, "Service mode"},
{0x16, 0x01, 0x80, 0x00, "Off"},
{0x16, 0x01, 0x80, 0x80, "On"},
// DIP 2
{0, 0xFE, 0, 2, "Screen flip"},
{0x17, 0x01, 0x01, 0x00, "Off"},
{0x17, 0x01, 0x01, 0x01, "On"},
{0, 0xFE, 0, 8, "Difficulty"},
{0x17, 0x01, 0x0E, 0x00, "1 (Easiest)"},
{0x17, 0x01, 0x0E, 0x02, "2"},
{0x17, 0x01, 0x0E, 0x04, "3"},
{0x17, 0x01, 0x0E, 0x06, "4 (Normal)"},
{0x17, 0x01, 0x0E, 0x08, "5"},
{0x17, 0x01, 0x0E, 0x0A, "6"},
{0x17, 0x01, 0x0E, 0x0C, "7"},
{0x17, 0x01, 0x0E, 0x0E, "8 (Hardest)"},
{0, 0xFE, 0, 2, "Lives"},
{0x17, 0x01, 0x10, 0x10, "2"},
{0x17, 0x01, 0x10, 0x00, "3"},
{0, 0xFE, 0, 2, "Bonus life"},
{0x17, 0x01, 0x20, 0x00, "200000"},
{0x17, 0x01, 0x20, 0x20, "300000"},
};
STDDIPINFO(turbofrc)
static struct BurnRomInfo turbofrcRomDesc[] = {
{ "tfrc2.bin", 0x040000, 0x721300ee, BRF_ESS | BRF_PRG }, // 68000 code swapped
{ "tfrc1.bin", 0x040000, 0x6cd5312b, BRF_ESS | BRF_PRG },
{ "tfrc3.bin", 0x040000, 0x63f50557, BRF_ESS | BRF_PRG },
{ "tfrcu94.bin", 0x080000, 0xbaa53978, BRF_GRA }, // gfx1
{ "tfrcu95.bin", 0x020000, 0x71a6c573, BRF_GRA },
{ "tfrcu105.bin", 0x080000, 0x4de4e59e, BRF_GRA }, // gfx2
{ "tfrcu106.bin", 0x020000, 0xc6479eb5, BRF_GRA },
{ "tfrcu116.bin", 0x080000, 0xdf210f3b, BRF_GRA }, // gfx3
{ "tfrcu118.bin", 0x040000, 0xf61d1d79, BRF_GRA },
{ "tfrcu117.bin", 0x080000, 0xf70812fd, BRF_GRA },
{ "tfrcu119.bin", 0x040000, 0x474ea716, BRF_GRA },
{ "tfrcu134.bin", 0x080000, 0x487330a2, BRF_GRA }, // gfx4
{ "tfrcu135.bin", 0x080000, 0x3a7e5b6d, BRF_GRA },
{ "tfrcu166.bin", 0x020000, 0x2ca14a65, BRF_ESS | BRF_PRG }, // Sound CPU
{ "tfrcu180.bin", 0x020000, 0x39c7c7d5, BRF_SND }, // samples
{ "tfrcu179.bin", 0x100000, 0x60ca0333, BRF_SND },
};
STD_ROM_PICK(turbofrc)
STD_ROM_FN(turbofrc)
unsigned char __fastcall turbofrcReadByte(unsigned int sekAddress)
{
sekAddress &= 0x0FFFFF;
switch (sekAddress) {
case 0x0FF000:
return ~DrvInput[3];
case 0x0FF001:
return ~DrvInput[0];
case 0x0FF002:
return 0xFF;
case 0x0FF003:
return ~DrvInput[1];
case 0x0FF004:
return ~DrvInput[5];
case 0x0FF005:
return ~DrvInput[4];
case 0x0FF007:
return pending_command;
case 0x0FF009:
return ~DrvInput[2];
// default:
// printf("Attempt to read byte value of location %x\n", sekAddress);
}
return 0;
}
/*
unsigned short __fastcall turbofrcReadWord(unsigned int sekAddress)
{
// sekAddress &= 0x0FFFFF;
// switch (sekAddress) {
// default:
// printf("Attempt to read word value of location %x\n", sekAddress);
// }
return 0;
}
*/
void __fastcall turbofrcWriteByte(unsigned int sekAddress, unsigned char byteValue)
{
if (( sekAddress & 0x0FF000 ) == 0x0FE000) {
sekAddress &= 0x07FF;
RamPal[sekAddress^1] = byteValue;
// palette byte write at boot self-test only ?!
//if (sekAddress & 1)
// RamCurPal[sekAddress>>1] = CalcCol( *((unsigned short *)&RamPal[sekAddress & 0xFFE]) );
return;
}
sekAddress &= 0x0FFFFF;
switch (sekAddress) {
case 0x0FF00E:
pending_command = 1;
SoundCommand(byteValue);
break;
// default:
// printf("Attempt to write byte value %x to location %x\n", byteValue, sekAddress);
}
}
void __fastcall turbofrcWriteWord(unsigned int sekAddress, unsigned short wordValue)
{
if (( sekAddress & 0x0FF000 ) == 0x0FE000) {
sekAddress &= 0x07FE;
*((unsigned short *)&RamPal[sekAddress]) = wordValue;
RamCurPal[sekAddress>>1] = CalcCol( wordValue );
return;
}
sekAddress &= 0x0FFFFF;
switch (sekAddress) {
case 0x0FF002:
bg1scrolly = (wordValue);
break;
case 0x0FF004:
bg2scrollx = (wordValue);
break;
case 0x0FF006:
bg2scrolly = (wordValue);
break;
case 0x0FF008:
RamGfxBank[0] = ((wordValue) >> 0) & 0x0f;
RamGfxBank[1] = ((wordValue) >> 4) & 0x0f;
RamGfxBank[2] = ((wordValue) >> 8) & 0x0f;
RamGfxBank[3] = ((wordValue) >> 12) & 0x0f;
break;
case 0x0FF00A:
RamGfxBank[4] = ((wordValue) >> 0) & 0x0f;
RamGfxBank[5] = ((wordValue) >> 4) & 0x0f;
RamGfxBank[6] = ((wordValue) >> 8) & 0x0f;
RamGfxBank[7] = ((wordValue) >> 12) & 0x0f;
break;
case 0x0FF00C:
// NOP
break;
// default:
// printf("Attempt to write word value %x to location %x\n", wordValue, sekAddress);
}
}
unsigned char __fastcall turbofrcZ80PortRead(unsigned short p)
{
switch (p & 0xFF) {
case 0x14:
return nSoundlatch;
case 0x18:
return BurnYM2610Read(0);
case 0x1A:
return BurnYM2610Read(2);
// default:
// printf("Z80 Attempt to read port %04x\n", p);
}
return 0;
}
void __fastcall turbofrcZ80PortWrite(unsigned short p, unsigned char v)
{
switch (p & 0x0FF) {
case 0x18:
case 0x19:
case 0x1A:
case 0x1B:
BurnYM2610Write((p - 0x18) & 3, v);
break;
case 0x00:
aerofgtSndBankSwitch(v);
break;
case 0x14:
pending_command = 0;
break;
// default:
// printf("Z80 Attempt to write %02x to port %04x\n", v, p);
}
}
static int turbofrcMemIndex()
{
unsigned char *Next; Next = Mem;
Rom01 = Next; Next += 0x0C0000; // 68000 ROM
RomZ80 = Next; Next += 0x030000; // Z80 ROM
RomBg = Next; Next += 0x280040; //
DeRomBg = RomBg + 0x000040;
RomSpr1 = Next; Next += 0x400000; // Sprite 1
RomSpr2 = Next; Next += 0x200100; // Sprite 2
DeRomSpr1 = RomSpr1 + 0x000100;
DeRomSpr2 = RomSpr2 += 0x000100;
RomSnd1 = Next; Next += 0x020000; // ADPCM data
RomSndSize1 = 0x020000;
RomSnd2 = Next; Next += 0x100000; // ADPCM data
RomSndSize2 = 0x100000;
RamStart = Next;
RamBg1V = (unsigned short *)Next; Next += 0x002000; // BG1 Video Ram
RamBg2V = (unsigned short *)Next; Next += 0x002000; // BG2 Video Ram
RamSpr1 = (unsigned short *)Next; Next += 0x004000; // Sprite 1 Ram
RamSpr2 = (unsigned short *)Next; Next += 0x004000; // Sprite 2 Ram
RamSpr3 = (unsigned short *)Next; Next += 0x000800; // Sprite 3 Ram
RamRaster = (unsigned short *)Next; Next += 0x001000; // Raster Ram
RamSpr1SizeMask = 0x1FFF;
RamSpr2SizeMask = 0x1FFF;
RomSpr1SizeMask = 0x3FFF;
RomSpr2SizeMask = 0x1FFF;
Ram01 = Next; Next += 0x014000; // Work Ram
RamPal = Next; Next += 0x000800; // 1024 of X1R5G5B5 Palette
RamZ80 = Next; Next += 0x000800; // Z80 Ram 2K
RamEnd = Next;
RamCurPal = (unsigned int *)Next; Next += 0x000800 * sizeof(unsigned int);
MemEnd = Next;
return 0;
}
static void pspikesDecodeBg(int cnt)
{
for (int c=cnt-1; c>=0; c--) {
for (int y=7; y>=0; y--) {
DeRomBg[(c * 64) + (y * 8) + 7] = RomBg[0x00003 + (y * 4) + (c * 32)] >> 4;
DeRomBg[(c * 64) + (y * 8) + 6] = RomBg[0x00003 + (y * 4) + (c * 32)] & 0x0f;
DeRomBg[(c * 64) + (y * 8) + 5] = RomBg[0x00002 + (y * 4) + (c * 32)] >> 4;
DeRomBg[(c * 64) + (y * 8) + 4] = RomBg[0x00002 + (y * 4) + (c * 32)] & 0x0f;
DeRomBg[(c * 64) + (y * 8) + 3] = RomBg[0x00001 + (y * 4) + (c * 32)] >> 4;
DeRomBg[(c * 64) + (y * 8) + 2] = RomBg[0x00001 + (y * 4) + (c * 32)] & 0x0f;
DeRomBg[(c * 64) + (y * 8) + 1] = RomBg[0x00000 + (y * 4) + (c * 32)] >> 4;
DeRomBg[(c * 64) + (y * 8) + 0] = RomBg[0x00000 + (y * 4) + (c * 32)] & 0x0f;
}
}
}
static void pspikesDecodeSpr(unsigned char *d, unsigned char *s, int cnt)
{
for (int c=cnt-1; c>=0; c--)
for (int y=15; y>=0; y--) {
d[(c * 256) + (y * 16) + 15] = s[0x00007 + (y * 8) + (c * 128)] >> 4;
d[(c * 256) + (y * 16) + 14] = s[0x00007 + (y * 8) + (c * 128)] & 0x0f;
d[(c * 256) + (y * 16) + 13] = s[0x00005 + (y * 8) + (c * 128)] >> 4;
d[(c * 256) + (y * 16) + 12] = s[0x00005 + (y * 8) + (c * 128)] & 0x0f;
d[(c * 256) + (y * 16) + 11] = s[0x00006 + (y * 8) + (c * 128)] >> 4;
d[(c * 256) + (y * 16) + 10] = s[0x00006 + (y * 8) + (c * 128)] & 0x0f;
d[(c * 256) + (y * 16) + 9] = s[0x00004 + (y * 8) + (c * 128)] >> 4;
d[(c * 256) + (y * 16) + 8] = s[0x00004 + (y * 8) + (c * 128)] & 0x0f;
d[(c * 256) + (y * 16) + 7] = s[0x00003 + (y * 8) + (c * 128)] >> 4;
d[(c * 256) + (y * 16) + 6] = s[0x00003 + (y * 8) + (c * 128)] & 0x0f;
d[(c * 256) + (y * 16) + 5] = s[0x00001 + (y * 8) + (c * 128)] >> 4;
d[(c * 256) + (y * 16) + 4] = s[0x00001 + (y * 8) + (c * 128)] & 0x0f;
d[(c * 256) + (y * 16) + 3] = s[0x00002 + (y * 8) + (c * 128)] >> 4;
d[(c * 256) + (y * 16) + 2] = s[0x00002 + (y * 8) + (c * 128)] & 0x0f;
d[(c * 256) + (y * 16) + 1] = s[0x00000 + (y * 8) + (c * 128)] >> 4;
d[(c * 256) + (y * 16) + 0] = s[0x00000 + (y * 8) + (c * 128)] & 0x0f;
}
}
static int turbofrcInit()
{
Mem = NULL;
turbofrcMemIndex();
int nLen = MemEnd - (unsigned char *)0;
if ((Mem = (unsigned char *)malloc(nLen)) == NULL) return 1;
memset(Mem, 0, nLen);
turbofrcMemIndex();
// Load 68000 ROM
if (BurnLoadRom(Rom01+0x00000, 0, 1)) return 1;
if (BurnLoadRom(Rom01+0x40000, 1, 1)) return 1;
if (BurnLoadRom(Rom01+0x80000, 2, 1)) return 1;
// Load Graphic
BurnLoadRom(RomBg+0x000000, 3, 1);
BurnLoadRom(RomBg+0x080000, 4, 1);
BurnLoadRom(RomBg+0x0A0000, 5, 1);
BurnLoadRom(RomBg+0x120000, 6, 1);
pspikesDecodeBg(0x14000);
BurnLoadRom(RomSpr1+0x000000, 7, 2);
BurnLoadRom(RomSpr1+0x000001, 9, 2);
BurnLoadRom(RomSpr1+0x100000, 8, 2);
BurnLoadRom(RomSpr1+0x100001, 10, 2);
BurnLoadRom(RomSpr1+0x200000, 11, 2);
BurnLoadRom(RomSpr1+0x200001, 12, 2);
pspikesDecodeSpr(DeRomSpr1, RomSpr1, 0x6000);
// Load Z80 ROM
if (BurnLoadRom(RomZ80+0x10000, 13, 1)) return 1;
memcpy(RomZ80, RomZ80+0x10000, 0x10000);
BurnLoadRom(RomSnd1, 14, 1);
BurnLoadRom(RomSnd2, 15, 1);
{
SekInit(0, 0x68000); // Allocate 68000
SekOpen(0);
// Map 68000 memory:
SekMapMemory(Rom01, 0x000000, 0x0BFFFF, SM_ROM); // CPU 0 ROM
SekMapMemory(Ram01, 0x0C0000, 0x0CFFFF, SM_RAM); // 64K Work RAM
SekMapMemory((unsigned char *)RamBg1V,
0x0D0000, 0x0D1FFF, SM_RAM);
SekMapMemory((unsigned char *)RamBg2V,
0x0D2000, 0x0D3FFF, SM_RAM);
SekMapMemory((unsigned char *)RamSpr1,
0x0E0000, 0x0E3FFF, SM_RAM);
SekMapMemory((unsigned char *)RamSpr2,
0x0E4000, 0x0E7FFF, SM_RAM);
SekMapMemory(Ram01+0x10000, 0x0F8000, 0x0FBFFF, SM_RAM); // Work RAM
SekMapMemory(Ram01+0x10000, 0xFF8000, 0xFFBFFF, SM_RAM); // Work RAM
SekMapMemory((unsigned char *)RamSpr3,
0x0FC000, 0x0FC7FF, SM_RAM);
SekMapMemory((unsigned char *)RamSpr3,
0xFFC000, 0xFFC7FF, SM_RAM);
SekMapMemory((unsigned char *)RamRaster,
0x0FD000, 0x0FDFFF, SM_RAM);
SekMapMemory((unsigned char *)RamRaster,
0xFFD000, 0xFFDFFF, SM_RAM);
SekMapMemory(RamPal, 0x0FE000, 0x0FE7FF, SM_ROM); // Palette
// SekSetReadWordHandler(0, turbofrcReadWord);
SekSetReadByteHandler(0, turbofrcReadByte);
SekSetWriteWordHandler(0, turbofrcWriteWord);
SekSetWriteByteHandler(0, turbofrcWriteByte);
SekClose();
}
{
ZetInit(1);
ZetOpen(0);
ZetMapArea(0x0000, 0x77FF, 0, RomZ80);
ZetMapArea(0x0000, 0x77FF, 2, RomZ80);
ZetMapArea(0x7800, 0x7FFF, 0, RamZ80);
ZetMapArea(0x7800, 0x7FFF, 1, RamZ80);
ZetMapArea(0x7800, 0x7FFF, 2, RamZ80);
ZetMemEnd();
ZetSetInHandler(turbofrcZ80PortRead);
ZetSetOutHandler(turbofrcZ80PortWrite);
ZetClose();
}
BurnYM2610Init(8000000, RomSnd2, &RomSndSize2, RomSnd1, &RomSndSize1, &aerofgtFMIRQHandler, aerofgtSynchroniseStream, aerofgtGetTime, 0);
BurnTimerAttachZet(5000000);
DrvDoReset();
return 0;
}
static void turbofrcTileBackground_1(unsigned short *bg, unsigned char *BgGfx, unsigned int *pal)
{
int offs, mx, my, x, y;
mx = -1;
my = 0;
for (offs = 0; offs < 64*64; offs++) {
mx++;
if (mx == 64) {
mx = 0;
my++;
}
x = mx * 8 - (swapWord(RamRaster[7]) & 0x1FF) - 11;
if (x <= (352-512)) x += 512;
y = my * 8 - (bg1scrolly & 0x1FF) - 2;
if (y <= (240-512)) y += 512;
if ( x<=-8 || x>=352 || y<=-8 || y>= 240 )
continue;
else
if ( x >=0 && x < (352-8) && y >= 0 && y < (240-8)) {
unsigned char *d = BgGfx + ( (swapWord(bg[offs]) & 0x07FF) + ( RamGfxBank[((swapWord(bg[offs]) & 0x1800) >> 11)] << 11 ) ) * 64;
unsigned short c = (swapWord(bg[offs]) & 0xE000) >> 9;
unsigned short * p = (unsigned short *) pBurnDraw + y * 352 + x;
for (int k=0;k<8;k++) {
p[0] = pal[ d[0] | c ];
p[1] = pal[ d[1] | c ];
p[2] = pal[ d[2] | c ];
p[3] = pal[ d[3] | c ];
p[4] = pal[ d[4] | c ];
p[5] = pal[ d[5] | c ];
p[6] = pal[ d[6] | c ];
p[7] = pal[ d[7] | c ];
d += 8;
p += 352;
}
} else {
unsigned char *d = BgGfx + ( (swapWord(bg[offs]) & 0x07FF) + ( RamGfxBank[((swapWord(bg[offs]) & 0x1800) >> 11)] << 11 ) ) * 64;
unsigned short c = (swapWord(bg[offs]) & 0xE000) >> 9;
unsigned short * p = (unsigned short *) pBurnDraw + y * 352 + x;
for (int k=0;k<8;k++) {
if ( (y+k)>=0 && (y+k)<240 ) {
if ((x + 0) >= 0 && (x + 0)<352) p[0] = pal[ d[0] | c ];
if ((x + 1) >= 0 && (x + 1)<352) p[1] = pal[ d[1] | c ];
if ((x + 2) >= 0 && (x + 2)<352) p[2] = pal[ d[2] | c ];
if ((x + 3) >= 0 && (x + 3)<352) p[3] = pal[ d[3] | c ];
if ((x + 4) >= 0 && (x + 4)<352) p[4] = pal[ d[4] | c ];
if ((x + 5) >= 0 && (x + 5)<352) p[5] = pal[ d[5] | c ];
if ((x + 6) >= 0 && (x + 6)<352) p[6] = pal[ d[6] | c ];
if ((x + 7) >= 0 && (x + 7)<352) p[7] = pal[ d[7] | c ];
}
d += 8;
p += 352;
}
}
}
}
static void turbofrcTileBackground_2(unsigned short *bg, unsigned char *BgGfx, unsigned int *pal)
{
int offs, mx, my, x, y;
mx = -1;
my = 0;
for (offs = 0; offs < 64*64; offs++) {
mx++;
if (mx == 64) {
mx = 0;
my++;
}
x = mx * 8 - (bg2scrollx & 0x1FF) + 7;
if (x <= (352-512)) x += 512;
y = my * 8 - (bg2scrolly & 0x1FF) - 2;
if (y <= (240-512)) y += 512;
if ( x<=-8 || x>=352 || y<=-8 || y>= 240 )
continue;
else
if ( x >=0 && x < (352-8) && y >= 0 && y < (240-8)) {
unsigned char *d = BgGfx + ( (swapWord(bg[offs]) & 0x07FF) + ( RamGfxBank[((swapWord(bg[offs]) & 0x1800) >> 11) + 4] << 11 ) ) * 64;
unsigned short c = (swapWord(bg[offs]) & 0xE000) >> 9;
unsigned short * p = (unsigned short *) pBurnDraw + y * 352 + x;
for (int k=0;k<8;k++) {
if (d[0] != 15) p[0] = pal[ d[0] | c ];
if (d[1] != 15) p[1] = pal[ d[1] | c ];
if (d[2] != 15) p[2] = pal[ d[2] | c ];
if (d[3] != 15) p[3] = pal[ d[3] | c ];
if (d[4] != 15) p[4] = pal[ d[4] | c ];
if (d[5] != 15) p[5] = pal[ d[5] | c ];
if (d[6] != 15) p[6] = pal[ d[6] | c ];
if (d[7] != 15) p[7] = pal[ d[7] | c ];
d += 8;
p += 352;
}
} else {
unsigned char *d = BgGfx + ( (swapWord(bg[offs]) & 0x07FF) + ( RamGfxBank[((swapWord(bg[offs]) & 0x1800) >> 11) + 4] << 11 ) ) * 64;
unsigned short c = (swapWord(bg[offs]) & 0xE000) >> 9;
unsigned short * p = (unsigned short *) pBurnDraw + y * 352 + x;
for (int k=0;k<8;k++) {
if ( (y+k)>=0 && (y+k)<240 ) {
if (d[0] != 15 && (x + 0) >= 0 && (x + 0)<352) p[0] = pal[ d[0] | c ];
if (d[1] != 15 && (x + 1) >= 0 && (x + 1)<352) p[1] = pal[ d[1] | c ];
if (d[2] != 15 && (x + 2) >= 0 && (x + 2)<352) p[2] = pal[ d[2] | c ];
if (d[3] != 15 && (x + 3) >= 0 && (x + 3)<352) p[3] = pal[ d[3] | c ];
if (d[4] != 15 && (x + 4) >= 0 && (x + 4)<352) p[4] = pal[ d[4] | c ];
if (d[5] != 15 && (x + 5) >= 0 && (x + 5)<352) p[5] = pal[ d[5] | c ];
if (d[6] != 15 && (x + 6) >= 0 && (x + 6)<352) p[6] = pal[ d[6] | c ];
if (d[7] != 15 && (x + 7) >= 0 && (x + 7)<352) p[7] = pal[ d[7] | c ];
}
d += 8;
p += 352;
}
}
}
}
static void pdrawgfxzoom(int bank,unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,int scalex,int scaley)
{
if (!scalex || !scaley) return;
unsigned short * p = (unsigned short *) pBurnDraw;
unsigned char * q;
unsigned int * pal;
if (bank) {
//if (code > RomSpr2SizeMask)
code &= RomSpr2SizeMask;
q = DeRomSpr2 + (code) * 256;
pal = RamCurPal + 768;
} else {
//if (code > RomSpr1SizeMask)
code &= RomSpr1SizeMask;
q = DeRomSpr1 + (code) * 256;
pal = RamCurPal + 512;
}
p += sy * 352 + sx;
if (sx < 0 || sx >= (352-16) || sy < 0 || sy >= (240-16) ) {
if ((sx <= -16) || (sx >= 352) || (sy <= -16) || (sy >= 240))
return;
if (flipy) {
p += 352 * 15;
if (flipx) {
for (int i=15;i>=0;i--) {
if (((sy+i)>=0) && ((sy+i)<240)) {
if (q[ 0] != 15 && ((sx + 15) >= 0) && ((sx + 15)<352)) p[15] = pal[ q[ 0] | color];
if (q[ 1] != 15 && ((sx + 14) >= 0) && ((sx + 14)<352)) p[14] = pal[ q[ 1] | color];
if (q[ 2] != 15 && ((sx + 13) >= 0) && ((sx + 13)<352)) p[13] = pal[ q[ 2] | color];
if (q[ 3] != 15 && ((sx + 12) >= 0) && ((sx + 12)<352)) p[12] = pal[ q[ 3] | color];
if (q[ 4] != 15 && ((sx + 11) >= 0) && ((sx + 11)<352)) p[11] = pal[ q[ 4] | color];
if (q[ 5] != 15 && ((sx + 10) >= 0) && ((sx + 10)<352)) p[10] = pal[ q[ 5] | color];
if (q[ 6] != 15 && ((sx + 9) >= 0) && ((sx + 9)<352)) p[ 9] = pal[ q[ 6] | color];
if (q[ 7] != 15 && ((sx + 8) >= 0) && ((sx + 8)<352)) p[ 8] = pal[ q[ 7] | color];
if (q[ 8] != 15 && ((sx + 7) >= 0) && ((sx + 7)<352)) p[ 7] = pal[ q[ 8] | color];
if (q[ 9] != 15 && ((sx + 6) >= 0) && ((sx + 6)<352)) p[ 6] = pal[ q[ 9] | color];
if (q[10] != 15 && ((sx + 5) >= 0) && ((sx + 5)<352)) p[ 5] = pal[ q[10] | color];
if (q[11] != 15 && ((sx + 4) >= 0) && ((sx + 4)<352)) p[ 4] = pal[ q[11] | color];
if (q[12] != 15 && ((sx + 3) >= 0) && ((sx + 3)<352)) p[ 3] = pal[ q[12] | color];
if (q[13] != 15 && ((sx + 2) >= 0) && ((sx + 2)<352)) p[ 2] = pal[ q[13] | color];
if (q[14] != 15 && ((sx + 1) >= 0) && ((sx + 1)<352)) p[ 1] = pal[ q[14] | color];
if (q[15] != 15 && ((sx + 0) >= 0) && ((sx + 0)<352)) p[ 0] = pal[ q[15] | color];
}
p -= 352;
q += 16;
}
} else {
for (int i=15;i>=0;i--) {
if (((sy+i)>=0) && ((sy+i)<240)) {
if (q[ 0] != 15 && ((sx + 0) >= 0) && ((sx + 0)<352)) p[ 0] = pal[ q[ 0] | color];
if (q[ 1] != 15 && ((sx + 1) >= 0) && ((sx + 1)<352)) p[ 1] = pal[ q[ 1] | color];
if (q[ 2] != 15 && ((sx + 2) >= 0) && ((sx + 2)<352)) p[ 2] = pal[ q[ 2] | color];
if (q[ 3] != 15 && ((sx + 3) >= 0) && ((sx + 3)<352)) p[ 3] = pal[ q[ 3] | color];
if (q[ 4] != 15 && ((sx + 4) >= 0) && ((sx + 4)<352)) p[ 4] = pal[ q[ 4] | color];
if (q[ 5] != 15 && ((sx + 5) >= 0) && ((sx + 5)<352)) p[ 5] = pal[ q[ 5] | color];
if (q[ 6] != 15 && ((sx + 6) >= 0) && ((sx + 6)<352)) p[ 6] = pal[ q[ 6] | color];
if (q[ 7] != 15 && ((sx + 7) >= 0) && ((sx + 7)<352)) p[ 7] = pal[ q[ 7] | color];
if (q[ 8] != 15 && ((sx + 8) >= 0) && ((sx + 8)<352)) p[ 8] = pal[ q[ 8] | color];
if (q[ 9] != 15 && ((sx + 9) >= 0) && ((sx + 9)<352)) p[ 9] = pal[ q[ 9] | color];
if (q[10] != 15 && ((sx + 10) >= 0) && ((sx + 10)<352)) p[10] = pal[ q[10] | color];
if (q[11] != 15 && ((sx + 11) >= 0) && ((sx + 11)<352)) p[11] = pal[ q[11] | color];
if (q[12] != 15 && ((sx + 12) >= 0) && ((sx + 12)<352)) p[12] = pal[ q[12] | color];
if (q[13] != 15 && ((sx + 13) >= 0) && ((sx + 13)<352)) p[13] = pal[ q[13] | color];
if (q[14] != 15 && ((sx + 14) >= 0) && ((sx + 14)<352)) p[14] = pal[ q[14] | color];
if (q[15] != 15 && ((sx + 15) >= 0) && ((sx + 15)<352)) p[15] = pal[ q[15] | color];
}
p -= 352;
q += 16;
}
}
} else {
if (flipx) {
for (int i=0;i<16;i++) {
if (((sy+i)>=0) && ((sy+i)<240)) {
if (q[ 0] != 15 && ((sx + 15) >= 0) && ((sx + 15)<352)) p[15] = pal[ q[ 0] | color];
if (q[ 1] != 15 && ((sx + 14) >= 0) && ((sx + 14)<352)) p[14] = pal[ q[ 1] | color];
if (q[ 2] != 15 && ((sx + 13) >= 0) && ((sx + 13)<352)) p[13] = pal[ q[ 2] | color];
if (q[ 3] != 15 && ((sx + 12) >= 0) && ((sx + 12)<352)) p[12] = pal[ q[ 3] | color];
if (q[ 4] != 15 && ((sx + 11) >= 0) && ((sx + 11)<352)) p[11] = pal[ q[ 4] | color];
if (q[ 5] != 15 && ((sx + 10) >= 0) && ((sx + 10)<352)) p[10] = pal[ q[ 5] | color];
if (q[ 6] != 15 && ((sx + 9) >= 0) && ((sx + 9)<352)) p[ 9] = pal[ q[ 6] | color];
if (q[ 7] != 15 && ((sx + 8) >= 0) && ((sx + 8)<352)) p[ 8] = pal[ q[ 7] | color];
if (q[ 8] != 15 && ((sx + 7) >= 0) && ((sx + 7)<352)) p[ 7] = pal[ q[ 8] | color];
if (q[ 9] != 15 && ((sx + 6) >= 0) && ((sx + 6)<352)) p[ 6] = pal[ q[ 9] | color];
if (q[10] != 15 && ((sx + 5) >= 0) && ((sx + 5)<352)) p[ 5] = pal[ q[10] | color];
if (q[11] != 15 && ((sx + 4) >= 0) && ((sx + 4)<352)) p[ 4] = pal[ q[11] | color];
if (q[12] != 15 && ((sx + 3) >= 0) && ((sx + 3)<352)) p[ 3] = pal[ q[12] | color];
if (q[13] != 15 && ((sx + 2) >= 0) && ((sx + 2)<352)) p[ 2] = pal[ q[13] | color];
if (q[14] != 15 && ((sx + 1) >= 0) && ((sx + 1)<352)) p[ 1] = pal[ q[14] | color];
if (q[15] != 15 && ((sx + 0) >= 0) && ((sx + 0)<352)) p[ 0] = pal[ q[15] | color];
}
p += 352;
q += 16;
}
} else {
for (int i=0;i<16;i++) {
if (((sy+i)>=0) && ((sy+i)<240)) {
if (q[ 0] != 15 && ((sx + 0) >= 0) && ((sx + 0)<352)) p[ 0] = pal[ q[ 0] | color];
if (q[ 1] != 15 && ((sx + 1) >= 0) && ((sx + 1)<352)) p[ 1] = pal[ q[ 1] | color];
if (q[ 2] != 15 && ((sx + 2) >= 0) && ((sx + 2)<352)) p[ 2] = pal[ q[ 2] | color];
if (q[ 3] != 15 && ((sx + 3) >= 0) && ((sx + 3)<352)) p[ 3] = pal[ q[ 3] | color];
if (q[ 4] != 15 && ((sx + 4) >= 0) && ((sx + 4)<352)) p[ 4] = pal[ q[ 4] | color];
if (q[ 5] != 15 && ((sx + 5) >= 0) && ((sx + 5)<352)) p[ 5] = pal[ q[ 5] | color];
if (q[ 6] != 15 && ((sx + 6) >= 0) && ((sx + 6)<352)) p[ 6] = pal[ q[ 6] | color];
if (q[ 7] != 15 && ((sx + 7) >= 0) && ((sx + 7)<352)) p[ 7] = pal[ q[ 7] | color];
if (q[ 8] != 15 && ((sx + 8) >= 0) && ((sx + 8)<352)) p[ 8] = pal[ q[ 8] | color];
if (q[ 9] != 15 && ((sx + 9) >= 0) && ((sx + 9)<352)) p[ 9] = pal[ q[ 9] | color];
if (q[10] != 15 && ((sx + 10) >= 0) && ((sx + 10)<352)) p[10] = pal[ q[10] | color];
if (q[11] != 15 && ((sx + 11) >= 0) && ((sx + 11)<352)) p[11] = pal[ q[11] | color];
if (q[12] != 15 && ((sx + 12) >= 0) && ((sx + 12)<352)) p[12] = pal[ q[12] | color];
if (q[13] != 15 && ((sx + 13) >= 0) && ((sx + 13)<352)) p[13] = pal[ q[13] | color];
if (q[14] != 15 && ((sx + 14) >= 0) && ((sx + 14)<352)) p[14] = pal[ q[14] | color];
if (q[15] != 15 && ((sx + 15) >= 0) && ((sx + 15)<352)) p[15] = pal[ q[15] | color];
}
p += 352;
q += 16;
}
}
}
return;
}
if (flipy) {
p += 352 * 15;
if (flipx) {
for (int i=0;i<16;i++) {
if (q[ 0] != 15) p[15] = pal[ q[ 0] | color];
if (q[ 1] != 15) p[14] = pal[ q[ 1] | color];
if (q[ 2] != 15) p[13] = pal[ q[ 2] | color];
if (q[ 3] != 15) p[12] = pal[ q[ 3] | color];
if (q[ 4] != 15) p[11] = pal[ q[ 4] | color];
if (q[ 5] != 15) p[10] = pal[ q[ 5] | color];
if (q[ 6] != 15) p[ 9] = pal[ q[ 6] | color];
if (q[ 7] != 15) p[ 8] = pal[ q[ 7] | color];
if (q[ 8] != 15) p[ 7] = pal[ q[ 8] | color];
if (q[ 9] != 15) p[ 6] = pal[ q[ 9] | color];
if (q[10] != 15) p[ 5] = pal[ q[10] | color];
if (q[11] != 15) p[ 4] = pal[ q[11] | color];
if (q[12] != 15) p[ 3] = pal[ q[12] | color];
if (q[13] != 15) p[ 2] = pal[ q[13] | color];
if (q[14] != 15) p[ 1] = pal[ q[14] | color];
if (q[15] != 15) p[ 0] = pal[ q[15] | color];
p -= 352;
q += 16;
}
} else {
for (int i=0;i<16;i++) {
if (q[ 0] != 15) p[ 0] = pal[ q[ 0] | color];
if (q[ 1] != 15) p[ 1] = pal[ q[ 1] | color];
if (q[ 2] != 15) p[ 2] = pal[ q[ 2] | color];
if (q[ 3] != 15) p[ 3] = pal[ q[ 3] | color];
if (q[ 4] != 15) p[ 4] = pal[ q[ 4] | color];
if (q[ 5] != 15) p[ 5] = pal[ q[ 5] | color];
if (q[ 6] != 15) p[ 6] = pal[ q[ 6] | color];
if (q[ 7] != 15) p[ 7] = pal[ q[ 7] | color];
if (q[ 8] != 15) p[ 8] = pal[ q[ 8] | color];
if (q[ 9] != 15) p[ 9] = pal[ q[ 9] | color];
if (q[10] != 15) p[10] = pal[ q[10] | color];
if (q[11] != 15) p[11] = pal[ q[11] | color];
if (q[12] != 15) p[12] = pal[ q[12] | color];
if (q[13] != 15) p[13] = pal[ q[13] | color];
if (q[14] != 15) p[14] = pal[ q[14] | color];
if (q[15] != 15) p[15] = pal[ q[15] | color];
p -= 352;
q += 16;
}
}
} else {
if (flipx) {
for (int i=0;i<16;i++) {
if (q[ 0] != 15) p[15] = pal[ q[ 0] | color];
if (q[ 1] != 15) p[14] = pal[ q[ 1] | color];
if (q[ 2] != 15) p[13] = pal[ q[ 2] | color];
if (q[ 3] != 15) p[12] = pal[ q[ 3] | color];
if (q[ 4] != 15) p[11] = pal[ q[ 4] | color];
if (q[ 5] != 15) p[10] = pal[ q[ 5] | color];
if (q[ 6] != 15) p[ 9] = pal[ q[ 6] | color];
if (q[ 7] != 15) p[ 8] = pal[ q[ 7] | color];
if (q[ 8] != 15) p[ 7] = pal[ q[ 8] | color];
if (q[ 9] != 15) p[ 6] = pal[ q[ 9] | color];
if (q[10] != 15) p[ 5] = pal[ q[10] | color];
if (q[11] != 15) p[ 4] = pal[ q[11] | color];
if (q[12] != 15) p[ 3] = pal[ q[12] | color];
if (q[13] != 15) p[ 2] = pal[ q[13] | color];
if (q[14] != 15) p[ 1] = pal[ q[14] | color];
if (q[15] != 15) p[ 0] = pal[ q[15] | color];
p += 352;
q += 16;
}
} else {
for (int i=0;i<16;i++) {
if (q[ 0] != 15) p[ 0] = pal[ q[ 0] | color];
if (q[ 1] != 15) p[ 1] = pal[ q[ 1] | color];
if (q[ 2] != 15) p[ 2] = pal[ q[ 2] | color];
if (q[ 3] != 15) p[ 3] = pal[ q[ 3] | color];
if (q[ 4] != 15) p[ 4] = pal[ q[ 4] | color];
if (q[ 5] != 15) p[ 5] = pal[ q[ 5] | color];
if (q[ 6] != 15) p[ 6] = pal[ q[ 6] | color];
if (q[ 7] != 15) p[ 7] = pal[ q[ 7] | color];
if (q[ 8] != 15) p[ 8] = pal[ q[ 8] | color];
if (q[ 9] != 15) p[ 9] = pal[ q[ 9] | color];
if (q[10] != 15) p[10] = pal[ q[10] | color];
if (q[11] != 15) p[11] = pal[ q[11] | color];
if (q[12] != 15) p[12] = pal[ q[12] | color];
if (q[13] != 15) p[13] = pal[ q[13] | color];
if (q[14] != 15) p[14] = pal[ q[14] | color];
if (q[15] != 15) p[15] = pal[ q[15] | color];
p += 352;
q += 16;
}
}
}
}
static void turbofrc_drawsprites(int chip,int chip_disabled_pri)
{
int attr_start,base,first;
base = chip * 0x0200;
first = 4 * swapWord(RamSpr3[0x1fe + base]);
//for (attr_start = base + 0x0200-8;attr_start >= first + base;attr_start -= 4) {
for (attr_start = first + base; attr_start <= base + 0x0200-8; attr_start += 4) {
int map_start;
int ox,oy,x,y,xsize,ysize,zoomx,zoomy,flipx,flipy,color,pri;
// some other drivers still use this wrong table, they have to be upgraded
// int zoomtable[16] = { 0,7,14,20,25,30,34,38,42,46,49,52,54,57,59,61 };
if (!(swapWord(RamSpr3[attr_start + 2]) & 0x0080)) continue;
pri = swapWord(RamSpr3[attr_start + 2]) & 0x0010;
if ( chip_disabled_pri & !pri) continue;
if (!chip_disabled_pri & (pri>>4)) continue;
ox = swapWord(RamSpr3[attr_start + 1]) & 0x01ff;
xsize = (swapWord(RamSpr3[attr_start + 2]) & 0x0700) >> 8;
zoomx = (swapWord(RamSpr3[attr_start + 1]) & 0xf000) >> 12;
oy = swapWord(RamSpr3[attr_start + 0]) & 0x01ff;
ysize = (swapWord(RamSpr3[attr_start + 2]) & 0x7000) >> 12;
zoomy = (swapWord(RamSpr3[attr_start + 0]) & 0xf000) >> 12;
flipx = swapWord(RamSpr3[attr_start + 2]) & 0x0800;
flipy = swapWord(RamSpr3[attr_start + 2]) & 0x8000;
color = (swapWord(RamSpr3[attr_start + 2]) & 0x000f) << 4; // + 16 * spritepalettebank;
map_start = swapWord(RamSpr3[attr_start + 3]);
// aerofgt has this adjustment, but doing it here would break turbo force title screen
// ox += (xsize*zoomx+2)/4;
// oy += (ysize*zoomy+2)/4;
zoomx = 32 - zoomx;
zoomy = 32 - zoomy;
for (y = 0;y <= ysize;y++) {
int sx,sy;
if (flipy) sy = ((oy + zoomy * (ysize - y)/2 + 16) & 0x1ff) - 16;
else sy = ((oy + zoomy * y / 2 + 16) & 0x1ff) - 16;
for (x = 0;x <= xsize;x++) {
int code;
if (flipx) sx = ((ox + zoomx * (xsize - x) / 2 + 16) & 0x1ff) - 16 - 8;
else sx = ((ox + zoomx * x / 2 + 16) & 0x1ff) - 16 - 8;
if (chip == 0) code = swapWord(RamSpr1[map_start & RamSpr1SizeMask]);
else code = swapWord(RamSpr2[map_start & RamSpr2SizeMask]);
pdrawgfxzoom(chip,code,color,flipx,flipy,sx,sy,zoomx << 11, zoomy << 11);
map_start++;
}
if (xsize == 2) map_start += 1;
if (xsize == 4) map_start += 3;
if (xsize == 5) map_start += 2;
if (xsize == 6) map_start += 1;
}
}
}
static int turbofrcDraw()
{
// update palette
aerofgtPalUpdate();
turbofrcTileBackground_1(RamBg1V, DeRomBg, RamCurPal);
turbofrcTileBackground_2(RamBg2V, DeRomBg + 0x140000, RamCurPal + 256);
/*
// we use the priority buffer so sprites are drawn front to back
turbofrc_drawsprites(0,-1); //enemy
turbofrc_drawsprites(0, 0); //enemy
turbofrc_drawsprites(1,-1); //ship
turbofrc_drawsprites(1, 0); //intro
*/
// in MAME it use a pri-buf control render to draw sprites from front to back
// i'm not use it, is right ???
turbofrc_drawsprites(0, 0);
turbofrc_drawsprites(0,-1);
turbofrc_drawsprites(1, 0);
turbofrc_drawsprites(1,-1);
return 0;
}
static int turbofrcFrame()
{
if (DrvReset) DrvDoReset();
// Compile digital inputs
DrvInput[0] = 0x00; // Joy1
DrvInput[1] = 0x00; // Joy2
DrvInput[2] = 0x00; // Joy3
DrvInput[3] = 0x00; // Buttons
for (int i = 0; i < 8; i++) {
DrvInput[0] |= (DrvJoy1[i] & 1) << i;
DrvInput[1] |= (DrvJoy2[i] & 1) << i;
DrvInput[2] |= (DrvJoy3[i] & 1) << i;
DrvInput[3] |= (DrvButton[i] & 1) << i;
}
SekNewFrame();
ZetNewFrame();
nCyclesTotal[0] = (int)((long long)10000000 * nBurnCPUSpeedAdjust / (0x0100 * 60));
nCyclesTotal[1] = (int)(5000000 / 60);
SekOpen(0);
ZetOpen(0);
SekRun(nCyclesTotal[0]);
SekSetIRQLine(1, SEK_IRQSTATUS_AUTO);
BurnTimerEndFrame(nCyclesTotal[1]);
BurnYM2610Update(pBurnSoundOut, nBurnSoundLen);
ZetClose();
SekClose();
if (pBurnDraw) turbofrcDraw();
return 0;
}
struct BurnDriver BurnDrvTurbofrc = {
"turbofrc", NULL, NULL, "1991",
"Turbo Force\0", NULL, "Video System Co.", "Video System",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_16BIT_ONLY, 3, HARDWARE_MISC_MISC,
NULL, turbofrcRomInfo, turbofrcRomName, turbofrcInputInfo, turbofrcDIPInfo,
turbofrcInit,DrvExit,turbofrcFrame,turbofrcDraw,DrvScan,
NULL,240,352,3,4
};
// ------------------------------------------------------------
static struct BurnInputInfo karatblzInputList[] = {
{"P1 Coin", BIT_DIGITAL, DrvButton + 0, "p1 coin"},
{"P1 Start", BIT_DIGITAL, DrvButton + 2, "p1 start"},
{"P1 Up", BIT_DIGITAL, DrvJoy1 + 0, "p1 up"},
{"P1 Down", BIT_DIGITAL, DrvJoy1 + 1, "p1 down"},
{"P1 Left", BIT_DIGITAL, DrvJoy1 + 2, "p1 left"},
{"P1 Right", BIT_DIGITAL, DrvJoy1 + 3, "p1 right"},
{"P1 Button 1", BIT_DIGITAL, DrvJoy1 + 4, "p1 fire 1"},
{"P1 Button 2", BIT_DIGITAL, DrvJoy1 + 5, "p1 fire 2"},
{"P1 Button 3", BIT_DIGITAL, DrvJoy1 + 6, "p1 fire 3"},
{"P1 Button 4", BIT_DIGITAL, DrvJoy1 + 7, "p1 fire 4"},
{"P2 Coin", BIT_DIGITAL, DrvButton + 1, "p2 coin"},
{"P2 Start", BIT_DIGITAL, DrvButton + 3, "p2 start"},
{"P2 Up", BIT_DIGITAL, DrvJoy2 + 0, "p2 up"},
{"P2 Down", BIT_DIGITAL, DrvJoy2 + 1, "p2 down"},
{"P2 Left", BIT_DIGITAL, DrvJoy2 + 2, "p2 left"},
{"P2 Right", BIT_DIGITAL, DrvJoy2 + 3, "p2 right"},
{"P2 Button 1", BIT_DIGITAL, DrvJoy2 + 4, "p2 fire 1"},
{"P2 Button 2", BIT_DIGITAL, DrvJoy2 + 5, "p2 fire 2"},
{"P2 Button 3", BIT_DIGITAL, DrvJoy2 + 6, "p2 fire 3"},
{"P2 Button 4", BIT_DIGITAL, DrvJoy2 + 7, "p2 fire 4"},
{"P3 Coin", BIT_DIGITAL, DrvButton2 + 0, "p3 coin"},
{"P3 Start", BIT_DIGITAL, DrvButton2 + 2, "p3 start"},
{"P3 Up", BIT_DIGITAL, DrvJoy3 + 0, "p3 up"},
{"P3 Down", BIT_DIGITAL, DrvJoy3 + 1, "p3 down"},
{"P3 Left", BIT_DIGITAL, DrvJoy3 + 2, "p3 left"},
{"P3 Right", BIT_DIGITAL, DrvJoy3 + 3, "p3 right"},
{"P3 Button 1", BIT_DIGITAL, DrvJoy3 + 4, "p3 fire 1"},
{"P3 Button 2", BIT_DIGITAL, DrvJoy3 + 5, "p3 fire 2"},
{"P3 Button 3", BIT_DIGITAL, DrvJoy3 + 6, "p3 fire 3"},
{"P3 Button 4", BIT_DIGITAL, DrvJoy3 + 7, "p3 fire 4"},
{"P4 Coin", BIT_DIGITAL, DrvButton2 + 1, "p4 coin"},
{"P4 Start", BIT_DIGITAL, DrvButton2 + 3, "p4 start"},
{"P4 Up", BIT_DIGITAL, DrvJoy4 + 0, "p4 up"},
{"P4 Down", BIT_DIGITAL, DrvJoy4 + 1, "p4 down"},
{"P4 Left", BIT_DIGITAL, DrvJoy4 + 2, "p4 left"},
{"P4 Right", BIT_DIGITAL, DrvJoy4 + 3, "p4 right"},
{"P4 Button 1", BIT_DIGITAL, DrvJoy4 + 4, "p4 fire 1"},
{"P4 Button 2", BIT_DIGITAL, DrvJoy4 + 5, "p4 fire 2"},
{"P4 Button 3", BIT_DIGITAL, DrvJoy4 + 6, "p4 fire 3"},
{"P4 Button 4", BIT_DIGITAL, DrvJoy4 + 7, "p4 fire 4"},
{"Reset", BIT_DIGITAL, &DrvReset, "reset"},
{"Service 1", BIT_DIGITAL, DrvButton + 6, "service"},
{"Service 2", BIT_DIGITAL, DrvButton2 + 6, ""},
{"Dip A", BIT_DIPSWITCH, DrvInput + 6, "dip"},
{"Dip B", BIT_DIPSWITCH, DrvInput + 7, "dip"},
};
STDINPUTINFO(karatblz)
static struct BurnDIPInfo karatblzDIPList[] = {
// Defaults
{0x2B, 0xFF, 0xFF, 0x00, NULL},
{0x2C, 0xFF, 0xFF, 0x40, NULL},
// DIP 1
{0, 0xFE, 0, 8, "Coinage"},
{0x2B, 0x82, 0x07, 0x00, "1 coin 1 credit"},
{0x2B, 0x00, 0x08, 0x08, NULL},
{0x2B, 0x82, 0x07, 0x01, "2 coins 1 credit"},
{0x2B, 0x00, 0x08, 0x08, NULL},
{0x2B, 0x82, 0x07, 0x02, "3 coins 1 credit"},
{0x2B, 0x00, 0x08, 0x08, NULL},
{0x2B, 0x82, 0x07, 0x03, "4 coins 1 credit"},
{0x2B, 0x00, 0x08, 0x08, NULL},
{0x2B, 0x82, 0x07, 0x04, "1 coin 2 credits"},
{0x2B, 0x00, 0x08, 0x08, NULL},
{0x2B, 0x82, 0x07, 0x05, "1 coin 3 credits"},
{0x2B, 0x00, 0x08, 0x08, NULL},
{0x2B, 0x82, 0x07, 0x06, "1 coin 5 credits"},
{0x2B, 0x00, 0x08, 0x08, NULL},
{0x2B, 0x82, 0x07, 0x07, "1 coin 6 credits"},
{0x2B, 0x00, 0x08, 0x08, NULL},
{0, 0xFE, 0, 2, "2 coins to start, 1 to continue"},
{0x2B, 0x01, 0x08, 0x00, "Off"},
{0x2B, 0x01, 0x08, 0x08, "On"},
{0, 0xFE, 0, 2, "Lives"},
{0x2B, 0x01, 0x10, 0x00, "2"},
{0x2B, 0x01, 0x10, 0x10, "1"},
{0, 0xFE, 0, 4, "Cabinet"},
{0x2B, 0x01, 0x60, 0x00, "2 players"},
{0x2B, 0x01, 0x60, 0x20, "3 players"},
{0x2B, 0x01, 0x60, 0x40, "4 players"},
{0x2B, 0x01, 0x60, 0x60, "4 players (Team)"},
{0, 0xFE, 0, 2, "Coin slot"},
{0x2B, 0x01, 0x80, 0x00, "Same"},
{0x2B, 0x01, 0x80, 0x80, "Individual"},
// DIP 2
{0, 0xFE, 0, 2, "Service mode"},
{0x2C, 0x01, 0x01, 0x00, "Off"},
{0x2C, 0x01, 0x01, 0x01, "On"},
{0, 0xFE, 0, 4, "Number of enemies"},
{0x2C, 0x01, 0x06, 0x00, "Normal"},
{0x2C, 0x01, 0x06, 0x02, "Easy"},
{0x2C, 0x01, 0x06, 0x04, "Hard"},
{0x2C, 0x01, 0x06, 0x06, "Hardest"},
{0, 0xFE, 0, 4, "Strength of enemies"},
{0x2C, 0x01, 0x18, 0x00, "Normal"},
{0x2C, 0x01, 0x18, 0x08, "Easy"},
{0x2C, 0x01, 0x18, 0x10, "Hard"},
{0x2C, 0x01, 0x18, 0x18, "Hardest"},
{0, 0xFE, 0, 2, "Freeze"},
{0x2C, 0x01, 0x20, 0x00, "Off"},
{0x2C, 0x01, 0x20, 0x20, "On"},
{0, 0xFE, 0, 2, "Demo sound"},
{0x2C, 0x01, 0x40, 0x00, "Off"},
{0x2C, 0x01, 0x40, 0x40, "On"},
{0, 0xFE, 0, 2, "Flip screen"},
{0x2C, 0x01, 0x80, 0x00, "Off"},
{0x2C, 0x01, 0x80, 0x80, "On"},
};
STDDIPINFO(karatblz)
static struct BurnRomInfo karatblzRomDesc[] = {
{ "rom2v3", 0x040000, 0x01f772e1, BRF_ESS | BRF_PRG }, // 68000 code swapped
{ "1.u15", 0x040000, 0xd16ee21b, BRF_ESS | BRF_PRG },
{ "gha.u55", 0x080000, 0x3e0cea91, BRF_GRA }, // gfx1
{ "gh9.u61", 0x080000, 0x5d1676bd, BRF_GRA }, // gfx2
{ "u42", 0x100000, 0x65f0da84, BRF_GRA }, // gfx3
{ "3.u44", 0x020000, 0x34bdead2, BRF_GRA },
{ "u43", 0x100000, 0x7b349e5d, BRF_GRA },
{ "4.u45", 0x020000, 0xbe4d487d, BRF_GRA },
{ "u59.ghb", 0x080000, 0x158c9cde, BRF_GRA }, // gfx4
{ "ghd.u60", 0x080000, 0x73180ae3, BRF_GRA },
{ "5.u92", 0x020000, 0x97d67510, BRF_ESS | BRF_PRG }, // Sound CPU
{ "u105.gh8", 0x080000, 0x7a68cb1b, BRF_SND }, // samples
{ "u104", 0x100000, 0x5795e884, BRF_SND },
};
STD_ROM_PICK(karatblz)
STD_ROM_FN(karatblz)
static struct BurnRomInfo karatblzuRomDesc[] = {
{ "2.u14", 0x040000, 0x202e6220, BRF_ESS | BRF_PRG }, // 68000 code swapped
{ "1.u15", 0x040000, 0xd16ee21b, BRF_ESS | BRF_PRG },
{ "gha.u55", 0x080000, 0x3e0cea91, BRF_GRA }, // gfx1
{ "gh9.u61", 0x080000, 0x5d1676bd, BRF_GRA }, // gfx2
{ "u42", 0x100000, 0x65f0da84, BRF_GRA }, // gfx3
{ "3.u44", 0x020000, 0x34bdead2, BRF_GRA },
{ "u43", 0x100000, 0x7b349e5d, BRF_GRA },
{ "4.u45", 0x020000, 0xbe4d487d, BRF_GRA },
{ "u59.ghb", 0x080000, 0x158c9cde, BRF_GRA }, // gfx4
{ "ghd.u60", 0x080000, 0x73180ae3, BRF_GRA },
{ "5.u92", 0x020000, 0x97d67510, BRF_ESS | BRF_PRG }, // Sound CPU
{ "u105.gh8", 0x080000, 0x7a68cb1b, BRF_SND }, // samples
{ "u104", 0x100000, 0x5795e884, BRF_SND },
};
STD_ROM_PICK(karatblzu)
STD_ROM_FN(karatblzu)
static struct BurnRomInfo karatblzjRomDesc[] = {
{ "2tecmo.u14", 0x040000, 0x57e52654, BRF_ESS | BRF_PRG }, // 68000 code swapped
{ "1.u15", 0x040000, 0xd16ee21b, BRF_ESS | BRF_PRG },
{ "gha.u55", 0x080000, 0x3e0cea91, BRF_GRA }, // gfx1
{ "gh9.u61", 0x080000, 0x5d1676bd, BRF_GRA }, // gfx2
{ "u42", 0x100000, 0x65f0da84, BRF_GRA }, // gfx3
{ "3.u44", 0x020000, 0x34bdead2, BRF_GRA },
{ "u43", 0x100000, 0x7b349e5d, BRF_GRA },
{ "4.u45", 0x020000, 0xbe4d487d, BRF_GRA },
{ "u59.ghb", 0x080000, 0x158c9cde, BRF_GRA }, // gfx4
{ "ghd.u60", 0x080000, 0x73180ae3, BRF_GRA },
{ "5.u92", 0x020000, 0x97d67510, BRF_ESS | BRF_PRG }, // Sound CPU
{ "u105.gh8", 0x080000, 0x7a68cb1b, BRF_SND }, // samples
{ "u104", 0x100000, 0x5795e884, BRF_SND },
};
STD_ROM_PICK(karatblzj)
STD_ROM_FN(karatblzj)
unsigned char __fastcall karatblzReadByte(unsigned int sekAddress)
{
sekAddress &= 0x0FFFFF;
switch (sekAddress) {
case 0x0FF000:
return ~DrvInput[4];
case 0x0FF001:
return ~DrvInput[0];
case 0x0FF002:
return 0xFF;
case 0x0FF003:
return ~DrvInput[1];
case 0x0FF004:
return ~DrvInput[5];
case 0x0FF005:
return ~DrvInput[2];
case 0x0FF006:
return 0xFF;
case 0x0FF007:
return ~DrvInput[3];
case 0x0FF008:
return ~DrvInput[7];
case 0x0FF009:
return ~DrvInput[6];
case 0x0FF00B:
return pending_command;
// default:
// printf("Attempt to read byte value of location %x\n", sekAddress);
}
return 0;
}
/*
unsigned short __fastcall karatblzReadWord(unsigned int sekAddress)
{
sekAddress &= 0x0FFFFF;
switch (sekAddress) {
default:
printf("Attempt to read word value of location %x\n", sekAddress);
}
return 0;
}
*/
void __fastcall karatblzWriteByte(unsigned int sekAddress, unsigned char byteValue)
{
sekAddress &= 0x0FFFFF;
switch (sekAddress) {
case 0x0FF000:
case 0x0FF401:
case 0x0FF403:
break;
case 0x0FF002:
//if (ACCESSING_MSB) {
// setbank(bg1_tilemap,0,(data & 0x0100) >> 8);
// setbank(bg2_tilemap,1,(data & 0x0800) >> 11);
//}
RamGfxBank[0] = (byteValue & 0x1);
RamGfxBank[1] = (byteValue & 0x8) >> 3;
break;
case 0x0FF007:
pending_command = 1;
SoundCommand(byteValue);
break;
// default:
// printf("Attempt to write byte value %x to location %x\n", byteValue, sekAddress);
}
}
void __fastcall karatblzWriteWord(unsigned int sekAddress, unsigned short wordValue)
{
if (( sekAddress & 0x0FF000 ) == 0x0FE000) {
sekAddress &= 0x07FF;
*((unsigned short *)&RamPal[sekAddress]) = wordValue;
RamCurPal[sekAddress>>1] = CalcCol( wordValue );
return;
}
sekAddress &= 0x0FFFFF;
switch (sekAddress) {
case 0x0ff008:
bg1scrollx = (wordValue);
break;
case 0x0ff00A:
bg1scrolly = (wordValue);
break;
case 0x0ff00C:
bg2scrollx = (wordValue);
break;
case 0x0ff00E:
bg2scrolly = (wordValue);
break;
// default:
// printf("Attempt to write word value %x to location %x\n", wordValue, sekAddress);
}
}
static int karatblzMemIndex()
{
unsigned char *Next; Next = Mem;
Rom01 = Next; Next += 0x080000; // 68000 ROM
RomZ80 = Next; Next += 0x030000; // Z80 ROM
RomBg = Next; Next += 0x200040; // Background, 1M 8x8x4bit decode to 2M + 64Byte safe
DeRomBg = RomBg + 0x000040;
RomSpr1 = Next; Next += 0x800000; // Sprite 1 , 1M 16x16x4bit decode to 2M + 256Byte safe
RomSpr2 = Next; Next += 0x200100; // Sprite 2
DeRomSpr1 = RomSpr1 + 0x000100;
DeRomSpr2 = RomSpr2 += 0x000100;
RomSnd1 = Next; Next += 0x080000; // ADPCM data
RomSndSize1 = 0x080000;
RomSnd2 = Next; Next += 0x100000; // ADPCM data
RomSndSize2 = 0x100000;
RamStart = Next;
RamBg1V = (unsigned short *)Next; Next += 0x002000; // BG1 Video Ram
RamBg2V = (unsigned short *)Next; Next += 0x002000; // BG2 Video Ram
RamSpr1 = (unsigned short *)Next; Next += 0x010000; // Sprite 1 Ram
RamSpr2 = (unsigned short *)Next; Next += 0x010000; // Sprite 2 Ram
RamSpr3 = (unsigned short *)Next; Next += 0x000800; // Sprite 3 Ram
Ram01 = Next; Next += 0x014000; // Work Ram 1 + Work Ram 1
RamPal = Next; Next += 0x000800; // 1024 of X1R5G5B5 Palette
RamZ80 = Next; Next += 0x000800; // Z80 Ram 2K
RamSpr1SizeMask = 0x7FFF;
RamSpr2SizeMask = 0x7FFF;
RomSpr1SizeMask = 0x7FFF;
RomSpr2SizeMask = 0x1FFF;
RamEnd = Next;
RamCurPal = (unsigned int *)Next; Next += 0x000800 * sizeof(unsigned int);
MemEnd = Next;
return 0;
}
static int karatblzInit()
{
Mem = NULL;
karatblzMemIndex();
int nLen = MemEnd - (unsigned char *)0;
if ((Mem = (unsigned char *)malloc(nLen)) == NULL) return 1;
memset(Mem, 0, nLen);
karatblzMemIndex();
// Load 68000 ROM
if (BurnLoadRom(Rom01+0x00000, 0, 1)) return 1;
if (BurnLoadRom(Rom01+0x40000, 1, 1)) return 1;
// Load Graphic
BurnLoadRom(RomBg+0x00000, 2, 1);
BurnLoadRom(RomBg+0x80000, 3, 1);
pspikesDecodeBg(0x10000);
BurnLoadRom(RomSpr1+0x000000, 4, 2);
BurnLoadRom(RomSpr1+0x000001, 6, 2);
BurnLoadRom(RomSpr1+0x200000, 5, 2);
BurnLoadRom(RomSpr1+0x200001, 7, 2);
BurnLoadRom(RomSpr1+0x400000, 8, 2);
BurnLoadRom(RomSpr1+0x400001, 9, 2);
pspikesDecodeSpr(DeRomSpr1, RomSpr1, 0xA000);
// Load Z80 ROM
if (BurnLoadRom(RomZ80+0x10000, 10, 1)) return 1;
memcpy(RomZ80, RomZ80+0x10000, 0x10000);
BurnLoadRom(RomSnd1, 11, 1);
BurnLoadRom(RomSnd2, 12, 1);
{
SekInit(0, 0x68000); // Allocate 68000
SekOpen(0);
// Map 68000 memory:
SekMapMemory(Rom01, 0x000000, 0x07FFFF, SM_ROM); // CPU 0 ROM
SekMapMemory((unsigned char *)RamBg1V,
0x080000, 0x081FFF, SM_RAM);
SekMapMemory((unsigned char *)RamBg2V,
0x082000, 0x083FFF, SM_RAM);
SekMapMemory((unsigned char *)RamSpr1,
0x0A0000, 0x0AFFFF, SM_RAM);
SekMapMemory((unsigned char *)RamSpr2,
0x0B0000, 0x0BFFFF, SM_RAM);
SekMapMemory(Ram01, 0x0C0000, 0x0CFFFF, SM_RAM); // 64K Work RAM
SekMapMemory(Ram01+0x10000, 0x0F8000, 0x0FBFFF, SM_RAM); // Work RAM
SekMapMemory(Ram01+0x10000, 0xFF8000, 0xFFBFFF, SM_RAM); // Work RAM
SekMapMemory((unsigned char *)RamSpr3,
0x0FC000, 0x0FC7FF, SM_RAM);
SekMapMemory(RamPal, 0x0FE000, 0x0FE7FF, SM_ROM); // Palette
// SekSetReadWordHandler(0, karatblzReadWord);
SekSetReadByteHandler(0, karatblzReadByte);
SekSetWriteWordHandler(0, karatblzWriteWord);
SekSetWriteByteHandler(0, karatblzWriteByte);
SekClose();
}
{
ZetInit(1);
ZetOpen(0);
ZetMapArea(0x0000, 0x77FF, 0, RomZ80);
ZetMapArea(0x0000, 0x77FF, 2, RomZ80);
ZetMapArea(0x7800, 0x7FFF, 0, RamZ80);
ZetMapArea(0x7800, 0x7FFF, 1, RamZ80);
ZetMapArea(0x7800, 0x7FFF, 2, RamZ80);
ZetMemEnd();
ZetSetInHandler(turbofrcZ80PortRead);
ZetSetOutHandler(turbofrcZ80PortWrite);
ZetClose();
}
BurnYM2610Init(8000000, RomSnd2, &RomSndSize2, RomSnd1, &RomSndSize1, &aerofgtFMIRQHandler, aerofgtSynchroniseStream, aerofgtGetTime, 0);
BurnTimerAttachZet(4000000);
DrvDoReset();
return 0;
}
static void karatblzTileBackground_1(unsigned short *bg, unsigned char *BgGfx, unsigned int *pal)
{
int offs, mx, my, x, y;
mx = -1;
my = 0;
for (offs = 0; offs < 64*64; offs++) {
mx++;
if (mx == 64) {
mx = 0;
my++;
}
x = mx * 8 - (((signed short)bg1scrollx + 8)& 0x1FF);
if (x <= (352-512)) x += 512;
y = my * 8 - (bg1scrolly & 0x1FF);
if (y <= (240-512)) y += 512;
if ( x<=-8 || x>=352 || y<=-8 || y>= 240 )
continue;
else
if ( x >=0 && x < (352-8) && y >= 0 && y < (240-8)) {
unsigned char *d = BgGfx + ( (swapWord(bg[offs]) & 0x1FFF) + ((RamGfxBank[0]) << 13 ) ) * 64;
unsigned short c = (swapWord(bg[offs]) & 0xE000) >> 9;
unsigned short * p = (unsigned short *) pBurnDraw + y * 352 + x;
for (int k=0;k<8;k++) {
p[0] = (pal[ d[0] | c ]);
p[1] = (pal[ d[1] | c ]);
p[2] = (pal[ d[2] | c ]);
p[3] = (pal[ d[3] | c ]);
p[4] = (pal[ d[4] | c ]);
p[5] = (pal[ d[5] | c ]);
p[6] = (pal[ d[6] | c ]);
p[7] = (pal[ d[7] | c ]);
d += 8;
p += 352;
}
} else {
unsigned char *d = BgGfx + ( (swapWord(bg[offs]) & 0x1FFF) + ((RamGfxBank[0]) << 13 ) ) * 64;
unsigned short c = (swapWord(bg[offs]) & 0xE000) >> 9;
unsigned short * p = (unsigned short *) pBurnDraw + y * 352 + x;
for (int k=0;k<8;k++) {
if ( (y+k)>=0 && (y+k)<240 ) {
if ((x + 0) >= 0 && (x + 0)<352) p[0] = pal[ d[0] | c ];
if ((x + 1) >= 0 && (x + 1)<352) p[1] = pal[ d[1] | c ];
if ((x + 2) >= 0 && (x + 2)<352) p[2] = pal[ d[2] | c ];
if ((x + 3) >= 0 && (x + 3)<352) p[3] = pal[ d[3] | c ];
if ((x + 4) >= 0 && (x + 4)<352) p[4] = pal[ d[4] | c ];
if ((x + 5) >= 0 && (x + 5)<352) p[5] = pal[ d[5] | c ];
if ((x + 6) >= 0 && (x + 6)<352) p[6] = pal[ d[6] | c ];
if ((x + 7) >= 0 && (x + 7)<352) p[7] = pal[ d[7] | c ];
}
d += 8;
p += 352;
}
}
}
}
static void karatblzTileBackground_2(unsigned short *bg, unsigned char *BgGfx, unsigned int *pal)
{
int offs, mx, my, x, y;
mx = -1;
my = 0;
for (offs = 0; offs < 64*64; offs++) {
mx++;
if (mx == 64) {
mx = 0;
my++;
}
x = mx * 8 - ( ((signed short)bg2scrollx + 4) & 0x1FF);
if (x <= (352-512)) x += 512;
y = my * 8 - (bg2scrolly & 0x1FF);
if (y <= (240-512)) y += 512;
if ( x<=-8 || x>=352 || y<=-8 || y>= 240 )
continue;
else
if ( x >=0 && x < (352-8) && y >= 0 && y < (240-8)) {
unsigned char *d = BgGfx + ( (swapWord(bg[offs]) & 0x1FFF) + ((RamGfxBank[1]) << 13 ) ) * 64;
unsigned short c = (swapWord(bg[offs]) & 0xE000) >> 9;
unsigned short * p = (unsigned short *) pBurnDraw + y * 352 + x;
for (int k=0;k<8;k++) {
if (d[0] != 15) p[0] = pal[ d[0] | c ];
if (d[1] != 15) p[1] = pal[ d[1] | c ];
if (d[2] != 15) p[2] = pal[ d[2] | c ];
if (d[3] != 15) p[3] = pal[ d[3] | c ];
if (d[4] != 15) p[4] = pal[ d[4] | c ];
if (d[5] != 15) p[5] = pal[ d[5] | c ];
if (d[6] != 15) p[6] = pal[ d[6] | c ];
if (d[7] != 15) p[7] = pal[ d[7] | c ];
d += 8;
p += 352;
}
} else {
unsigned char *d = BgGfx + ( (swapWord(bg[offs]) & 0x1FFF) + ((RamGfxBank[1]) << 13 ) ) * 64;
unsigned short c = (swapWord(bg[offs]) & 0xE000) >> 9;
unsigned short * p = (unsigned short *) pBurnDraw + y * 352 + x;
for (int k=0;k<8;k++) {
if ( (y+k)>=0 && (y+k)<240 ) {
if (d[0] != 15 && (x + 0) >= 0 && (x + 0)<352) p[0] = pal[ d[0] | c ];
if (d[1] != 15 && (x + 1) >= 0 && (x + 1)<352) p[1] = pal[ d[1] | c ];
if (d[2] != 15 && (x + 2) >= 0 && (x + 2)<352) p[2] = pal[ d[2] | c ];
if (d[3] != 15 && (x + 3) >= 0 && (x + 3)<352) p[3] = pal[ d[3] | c ];
if (d[4] != 15 && (x + 4) >= 0 && (x + 4)<352) p[4] = pal[ d[4] | c ];
if (d[5] != 15 && (x + 5) >= 0 && (x + 5)<352) p[5] = pal[ d[5] | c ];
if (d[6] != 15 && (x + 6) >= 0 && (x + 6)<352) p[6] = pal[ d[6] | c ];
if (d[7] != 15 && (x + 7) >= 0 && (x + 7)<352) p[7] = pal[ d[7] | c ];
}
d += 8;
p += 352;
}
}
}
}
static int karatblzDraw()
{
// update palette
aerofgtPalUpdate();
karatblzTileBackground_1(RamBg1V, DeRomBg, RamCurPal);
karatblzTileBackground_2(RamBg2V, DeRomBg + 0x100000, RamCurPal + 256);
/*
turbofrc_drawsprites(1,-1);
turbofrc_drawsprites(1, 0);
turbofrc_drawsprites(0,-1);
turbofrc_drawsprites(0, 0);
*/
turbofrc_drawsprites(0, 0);
turbofrc_drawsprites(0,-1);
turbofrc_drawsprites(1, 0);
turbofrc_drawsprites(1,-1);
return 0;
}
static int karatblzFrame()
{
if (DrvReset) DrvDoReset();
// Compile digital inputs
DrvInput[0] = 0x00; // Joy1
DrvInput[1] = 0x00; // Joy2
DrvInput[2] = 0x00; // Joy3
DrvInput[3] = 0x00; // Joy4
DrvInput[4] = 0x00; // Buttons1
DrvInput[5] = 0x00; // Buttons2
for (int i = 0; i < 8; i++) {
DrvInput[0] |= (DrvJoy1[i] & 1) << i;
DrvInput[1] |= (DrvJoy2[i] & 1) << i;
DrvInput[2] |= (DrvJoy3[i] & 1) << i;
DrvInput[3] |= (DrvJoy4[i] & 1) << i;
DrvInput[4] |= (DrvButton[i] & 1) << i;
DrvInput[5] |= (DrvButton2[i] & 1) << i;
}
/* for (int i = 0; i < 4; i++) {
DrvInput[4] |= (DrvButton[i] & 1) << i;
DrvInput[5] |= (DrvButton[i+4] & 1) << i;
}*/
SekNewFrame();
ZetNewFrame();
nCyclesTotal[0] = (int)((long long)10000000 * nBurnCPUSpeedAdjust / (0x0100 * 60));
nCyclesTotal[1] = (int)(4000000 / 60);
SekOpen(0);
ZetOpen(0);
SekRun(nCyclesTotal[0]);
SekSetIRQLine(1, SEK_IRQSTATUS_AUTO);
BurnTimerEndFrame(nCyclesTotal[1]);
BurnYM2610Update(pBurnSoundOut, nBurnSoundLen);
ZetClose();
SekClose();
if (pBurnDraw) karatblzDraw();
return 0;
}
struct BurnDriver BurnDrvKaratblz = {
"karatblz", NULL, NULL, "1991",
"Karate Blazers (World)\0", NULL, "Video System Co.", "Video System",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_16BIT_ONLY, 4, HARDWARE_MISC_MISC,
NULL, karatblzRomInfo, karatblzRomName, karatblzInputInfo, karatblzDIPInfo,
karatblzInit,DrvExit,karatblzFrame,karatblzDraw,DrvScan,
NULL,352,240,4,3
};
struct BurnDriver BurnDrvKaratblzu = {
"karatblzu", "karatblz", NULL, "1991",
"Karate Blazers (US)\0", NULL, "Video System Co.", "Video System",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_CLONE | BDF_16BIT_ONLY, 4, HARDWARE_MISC_MISC,
NULL, karatblzuRomInfo, karatblzuRomName, karatblzInputInfo, karatblzDIPInfo,
karatblzInit,DrvExit,karatblzFrame,karatblzDraw,DrvScan,
NULL,352,240,4,3
};
struct BurnDriver BurnDrvKaratblzj = {
"karatblzj", "karatblz", NULL, "1991",
"Karate Blazers (Japan)\0", NULL, "Video System Co.", "Video System",
L"\u95D8\u795E Blazers (Japan)\0", NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_CLONE | BDF_16BIT_ONLY, 4, HARDWARE_MISC_MISC,
NULL, karatblzjRomInfo, karatblzjRomName, karatblzInputInfo, karatblzDIPInfo,
karatblzInit,DrvExit,karatblzFrame,karatblzDraw,DrvScan,
NULL,352,240,4,3
};
// -----------------------------------------------------------
static struct BurnInputInfo spinlbrkInputList[] = {
{"P1 Coin", BIT_DIGITAL, DrvButton + 0, "p1 coin"},
{"P1 Start", BIT_DIGITAL, DrvButton + 2, "p1 start"},
{"P1 Up", BIT_DIGITAL, DrvJoy1 + 0, "p1 up"},
{"P1 Down", BIT_DIGITAL, DrvJoy1 + 1, "p1 down"},
{"P1 Left", BIT_DIGITAL, DrvJoy1 + 2, "p1 left"},
{"P1 Right", BIT_DIGITAL, DrvJoy1 + 3, "p1 right"},
{"P1 Button 1", BIT_DIGITAL, DrvJoy1 + 4, "p1 fire 1"},
{"P1 Button 2", BIT_DIGITAL, DrvJoy1 + 5, "p1 fire 2"},
{"P1 Button 3", BIT_DIGITAL, DrvJoy1 + 6, "p1 fire 3"},
{"P2 Coin", BIT_DIGITAL, DrvButton + 1, "p2 coin"},
{"P2 Start", BIT_DIGITAL, DrvButton + 3, "p2 start"},
{"P2 Up", BIT_DIGITAL, DrvJoy2 + 0, "p2 up"},
{"P2 Down", BIT_DIGITAL, DrvJoy2 + 1, "p2 down"},
{"P2 Left", BIT_DIGITAL, DrvJoy2 + 2, "p2 left"},
{"P2 Right", BIT_DIGITAL, DrvJoy2 + 3, "p2 right"},
{"P2 Button 1", BIT_DIGITAL, DrvJoy2 + 4, "p2 fire 1"},
{"P2 Button 2", BIT_DIGITAL, DrvJoy2 + 5, "p2 fire 2"},
{"P2 Button 3", BIT_DIGITAL, DrvJoy2 + 6, "p2 fire 3"},
{"Reset", BIT_DIGITAL, &DrvReset, "reset"},
{"Service", BIT_DIGITAL, DrvButton + 6, "service"},
{"Dip A", BIT_DIPSWITCH, DrvInput + 3, "dip"},
{"Dip B", BIT_DIPSWITCH, DrvInput + 4, "dip"},
};
STDINPUTINFO(spinlbrk)
static struct BurnDIPInfo spinlbrkDIPList[] = {
// Defaults
{0x14, 0xFF, 0xFF, 0x00, NULL},
{0x15, 0xFF, 0xFF, 0x00, NULL},
// DIP 1
// Coin slot Individual condition
{0, 0xFE, 0, 16, "Coin A"},
{0x14, 0x02, 0x0F, 0x00, "1 coin 1 health pack"},
{0x15, 0x00, 0x04, 0x00, NULL},
{0x14, 0x02, 0x0F, 0x01, "1 coin 2 health packs"},
{0x15, 0x00, 0x04, 0x00, NULL},
{0x14, 0x02, 0x0F, 0x02, "1 coin 3 health packs"},
{0x15, 0x00, 0x04, 0x00, NULL},
{0x14, 0x02, 0x0F, 0x03, "1 coin 4 health packs"},
{0x15, 0x00, 0x04, 0x00, NULL},
{0x14, 0x02, 0x0F, 0x04, "1 coin 5 health packs"},
{0x15, 0x00, 0x04, 0x00, NULL},
{0x14, 0x02, 0x0F, 0x05, "1 coin 6 health packs"},
{0x15, 0x00, 0x04, 0x00, NULL},
{0x14, 0x02, 0x0F, 0x06, "2 coins 1 health pack"},
{0x15, 0x00, 0x04, 0x00, NULL},
{0x14, 0x02, 0x0F, 0x07, "3 coins 1 health pack"},
{0x15, 0x00, 0x04, 0x00, NULL},
{0x14, 0x02, 0x0F, 0x08, "4 coins 1 health pack"},
{0x15, 0x00, 0x04, 0x00, NULL},
{0x14, 0x02, 0x0F, 0x09, "5 coins 1 health pack"},
{0x15, 0x00, 0x04, 0x00, NULL},
{0x14, 0x02, 0x0F, 0x0A, "2 coins 3 health packs"},
{0x15, 0x00, 0x04, 0x00, NULL},
{0x14, 0x02, 0x0F, 0x0B, "2-2-1-1 coins 1-1-1-1 health pack"},
{0x15, 0x00, 0x04, 0x00, NULL},
{0x14, 0x02, 0x0F, 0x0C, "2-2 coins 1-2 health packs"},
{0x15, 0x00, 0x04, 0x00, NULL},
{0x14, 0x02, 0x0F, 0x0D, "1-1-1-1-1 coin 1-1-1-1-2 health packs"},
{0x15, 0x00, 0x04, 0x00, NULL},
{0x14, 0x02, 0x0F, 0x0E, "1-1-1-1 coin 1-1-1-2 health packs"},
{0x15, 0x00, 0x04, 0x00, NULL},
{0x14, 0x02, 0x0F, 0x0F, "1-1 coin 1-2 health packs"},
{0x15, 0x00, 0x04, 0x00, NULL},
{0, 0xFE, 0, 16, "Coin B"},
{0x14, 0x02, 0xF0, 0x00, "1 coin 1 health pack"},
{0x15, 0x00, 0x04, 0x00, NULL},
{0x14, 0x02, 0xF0, 0x10, "1 coin 2 health packs"},
{0x15, 0x00, 0x04, 0x00, NULL},
{0x14, 0x02, 0xF0, 0x20, "1 coin 3 health packs"},
{0x15, 0x00, 0x04, 0x00, NULL},
{0x14, 0x02, 0xF0, 0x30, "1 coin 4 health packs"},
{0x15, 0x00, 0x04, 0x00, NULL},
{0x14, 0x02, 0xF0, 0x40, "1 coin 5 health packs"},
{0x15, 0x00, 0x04, 0x00, NULL},
{0x14, 0x02, 0xF0, 0x50, "1 coin 6 health packs"},
{0x15, 0x00, 0x04, 0x00, NULL},
{0x14, 0x02, 0xF0, 0x60, "2 coins 1 health pack"},
{0x15, 0x00, 0x04, 0x00, NULL},
{0x14, 0x02, 0xF0, 0x70, "3 coins 1 health pack"},
{0x15, 0x00, 0x04, 0x00, NULL},
{0x14, 0x02, 0xF0, 0x80, "4 coins 1 health pack"},
{0x15, 0x00, 0x04, 0x00, NULL},
{0x14, 0x02, 0xF0, 0x90, "5 coins 1 health pack"},
{0x15, 0x00, 0x04, 0x00, NULL},
{0x14, 0x02, 0xF0, 0xA0, "2 coins 3 health packs"},
{0x15, 0x00, 0x04, 0x00, NULL},
{0x14, 0x02, 0xF0, 0xB0, "2-2-1-1 coins 1-1-1-1 health pack"},
{0x15, 0x00, 0x04, 0x00, NULL},
{0x14, 0x02, 0xF0, 0xC0, "2-2 coins 1-2 health packs"},
{0x15, 0x00, 0x04, 0x00, NULL},
{0x14, 0x02, 0xF0, 0xD0, "1-1-1-1-1 coin 1-1-1-1-2 health packs"},
{0x15, 0x00, 0x04, 0x00, NULL},
{0x14, 0x02, 0xF0, 0xE0, "1-1-1-1 coin 1-1-1-2 health packs"},
{0x15, 0x00, 0x04, 0x00, NULL},
{0x14, 0x02, 0xF0, 0xF0, "1-1 coin 1-2 health packs"},
{0x15, 0x00, 0x04, 0x00, NULL},
// Coin slot Same condition
{0, 0xFE, 0, 16, "Coin A"},
{0x14, 0x02, 0x0F, 0x00, "1 coin 1 credit"},
{0x15, 0x00, 0x04, 0x04, NULL},
{0x14, 0x02, 0x0F, 0x01, "1 coin 2 credits"},
{0x15, 0x00, 0x04, 0x04, NULL},
{0x14, 0x02, 0x0F, 0x02, "1 coin 3 credits"},
{0x15, 0x00, 0x04, 0x04, NULL},
{0x14, 0x02, 0x0F, 0x03, "1 coin 4 credits"},
{0x15, 0x00, 0x04, 0x04, NULL},
{0x14, 0x02, 0x0F, 0x04, "1 coin 5 credits"},
{0x15, 0x00, 0x04, 0x04, NULL},
{0x14, 0x02, 0x0F, 0x05, "1 coin 6 credits"},
{0x15, 0x00, 0x04, 0x04, NULL},
{0x14, 0x02, 0x0F, 0x06, "2 coins 1 credit"},
{0x15, 0x00, 0x04, 0x04, NULL},
{0x14, 0x02, 0x0F, 0x07, "3 coins 1 credit"},
{0x15, 0x00, 0x04, 0x04, NULL},
{0x14, 0x02, 0x0F, 0x08, "4 coins 1 credit"},
{0x15, 0x00, 0x04, 0x04, NULL},
{0x14, 0x02, 0x0F, 0x09, "5 coins 1 credit"},
{0x15, 0x00, 0x04, 0x04, NULL},
{0x14, 0x02, 0x0F, 0x0A, "2 coins 3 credits"},
{0x15, 0x00, 0x04, 0x04, NULL},
{0x14, 0x02, 0x0F, 0x0B, "2-2-1-1 coins 1-1-1-1 credit"},
{0x15, 0x00, 0x04, 0x04, NULL},
{0x14, 0x02, 0x0F, 0x0C, "2-2 coins 1-2 credits"},
{0x15, 0x00, 0x04, 0x04, NULL},
{0x14, 0x02, 0x0F, 0x0D, "1-1-1-1-1 coin 1-1-1-1-2 credits"},
{0x15, 0x00, 0x04, 0x04, NULL},
{0x14, 0x02, 0x0F, 0x0E, "1-1-1-1 coin 1-1-1-2 credits"},
{0x15, 0x00, 0x04, 0x04, NULL},
{0x14, 0x02, 0x0F, 0x0F, "1-1 coin 1-2 credits"},
{0x15, 0x00, 0x04, 0x04, NULL},
{0, 0xFE, 0, 16, "Coin B"},
{0x14, 0x02, 0xF0, 0x00, "1 coin 1 credit"},
{0x15, 0x00, 0x04, 0x04, NULL},
{0x14, 0x02, 0xF0, 0x10, "1 coin 2 credits"},
{0x15, 0x00, 0x04, 0x04, NULL},
{0x14, 0x02, 0xF0, 0x20, "1 coin 3 credits"},
{0x15, 0x00, 0x04, 0x04, NULL},
{0x14, 0x02, 0xF0, 0x30, "1 coin 4 credits"},
{0x15, 0x00, 0x04, 0x04, NULL},
{0x14, 0x02, 0xF0, 0x40, "1 coin 5 credits"},
{0x15, 0x00, 0x04, 0x04, NULL},
{0x14, 0x02, 0xF0, 0x50, "1 coin 6 credits"},
{0x15, 0x00, 0x04, 0x04, NULL},
{0x14, 0x02, 0xF0, 0x60, "2 coins 1 credit"},
{0x15, 0x00, 0x04, 0x04, NULL},
{0x14, 0x02, 0xF0, 0x70, "3 coins 1 credit"},
{0x15, 0x00, 0x04, 0x04, NULL},
{0x14, 0x02, 0xF0, 0x80, "4 coins 1 credit"},
{0x15, 0x00, 0x04, 0x04, NULL},
{0x14, 0x02, 0xF0, 0x90, "5 coins 1 credit"},
{0x15, 0x00, 0x04, 0x04, NULL},
{0x14, 0x02, 0xF0, 0xA0, "2 coins 3 credits"},
{0x15, 0x00, 0x04, 0x04, NULL},
{0x14, 0x02, 0xF0, 0xB0, "2-2-1-1 coins 1-1-1-1 credit"},
{0x15, 0x00, 0x04, 0x04, NULL},
{0x14, 0x02, 0xF0, 0xC0, "2-2 coins 1-2 credits"},
{0x15, 0x00, 0x04, 0x04, NULL},
{0x14, 0x02, 0xF0, 0xD0, "1-1-1-1-1 coin 1-1-1-1-2 credits"},
{0x15, 0x00, 0x04, 0x04, NULL},
{0x14, 0x02, 0xF0, 0xE0, "1-1-1-1 coin 1-1-1-2 credits"},
{0x15, 0x00, 0x04, 0x04, NULL},
{0x14, 0x02, 0xF0, 0xF0, "1-1 coin 1-2 credits"},
{0x15, 0x00, 0x04, 0x04, NULL},
// DIP 2
{0, 0xFE, 0, 4, "Difficulty"},
{0x15, 0x01, 0x03, 0x00, "Normal"},
{0x15, 0x01, 0x03, 0x01, "Easy"},
{0x15, 0x01, 0x03, 0x02, "Hard"},
{0x15, 0x01, 0x03, 0x03, "Hardest"},
{0, 0xFE, 0, 2, "Coin slot"},
{0x15, 0x01, 0x04, 0x04, "Same"},
{0x15, 0x01, 0x04, 0x00, "Individual"},
{0, 0xFE, 0, 2, "Flip screen"},
{0x15, 0x01, 0x08, 0x00, "Off"},
{0x15, 0x01, 0x08, 0x08, "On"},
{0, 0xFE, 0, 2, "Lever type"},
{0x15, 0x01, 0x10, 0x00, "Digital"},
{0x15, 0x01, 0x10, 0x10, "Analog"},
{0, 0xFE, 0, 2, "Service mode"},
{0x15, 0x01, 0x20, 0x00, "Off"},
{0x15, 0x01, 0x20, 0x20, "On"},
};
static struct BurnDIPInfo spinlbrk_DIPList[] = {
{0, 0xFE, 0, 2, "Health pack"},
{0x15, 0x01, 0x40, 0x00, "32 hitpoints"},
{0x15, 0x01, 0x40, 0x40, "40 hitpoints"},
{0, 0xFE, 0, 2, "Life restoration"},
{0x15, 0x01, 0x80, 0x00, "10 points"},
{0x15, 0x01, 0x80, 0x80, "5 points"},
};
static struct BurnDIPInfo spinlbrkuDIPList[] = {
{0, 0xFE, 0, 2, "Health pack"},
{0x15, 0x01, 0x40, 0x00, "20 hitpoints"},
{0x15, 0x01, 0x40, 0x40, "32 hitpoints"},
{0, 0xFE, 0, 2, "Life restoration"},
{0x15, 0x01, 0x80, 0x00, "10 points"},
{0x15, 0x01, 0x80, 0x80, "5 points"},
};
static struct BurnDIPInfo spinlbrkjDIPList[] = {
// Defaults
{0x14, 0xFF, 0xFF, 0x00, NULL},
{0x15, 0xFF, 0xFF, 0x00, NULL},
// DIP 1
{0, 0xFE, 0, 16, "Coin A"},
{0x14, 0x01, 0x0F, 0x00, "1 coin 1 credit"},
{0x14, 0x01, 0x0F, 0x01, "1 coin 2 credits"},
{0x14, 0x01, 0x0F, 0x02, "1 coin 3 credits"},
{0x14, 0x01, 0x0F, 0x03, "1 coin 4 credits"},
{0x14, 0x01, 0x0F, 0x04, "1 coin 5 credits"},
{0x14, 0x01, 0x0F, 0x05, "1 coin 6 credits"},
{0x14, 0x01, 0x0F, 0x06, "2 coins 1 credit"},
{0x14, 0x01, 0x0F, 0x07, "3 coins 1 credit"},
{0x14, 0x01, 0x0F, 0x08, "4 coins 1 credit"},
{0x14, 0x01, 0x0F, 0x09, "5 coins 1 credit"},
{0x14, 0x01, 0x0F, 0x0A, "2 coins 3 credits"},
{0x14, 0x01, 0x0F, 0x0B, "2-2-1-1 coins 1-1-1-1 credit"},
{0x14, 0x01, 0x0F, 0x0C, "2-2 coins 1-2 credits"},
{0x14, 0x01, 0x0F, 0x0D, "1-1-1-1-1 coin 1-1-1-1-2 credits"},
{0x14, 0x01, 0x0F, 0x0E, "1-1-1-1 coin 1-1-1-2 credits"},
{0x14, 0x01, 0x0F, 0x0F, "1-1 coin 1-2 credits"},
{0, 0xFE, 0, 16, "Coin B"},
{0x14, 0x01, 0xF0, 0x00, "1 coin 1 credit"},
{0x14, 0x01, 0xF0, 0x10, "1 coin 2 credits"},
{0x14, 0x01, 0xF0, 0x20, "1 coin 3 credits"},
{0x14, 0x01, 0xF0, 0x30, "1 coin 4 credits"},
{0x14, 0x01, 0xF0, 0x40, "1 coin 5 credits"},
{0x14, 0x01, 0xF0, 0x50, "1 coin 6 credits"},
{0x14, 0x01, 0xF0, 0x60, "2 coins 1 credit"},
{0x14, 0x01, 0xF0, 0x70, "3 coins 1 credit"},
{0x14, 0x01, 0xF0, 0x80, "4 coins 1 credit"},
{0x14, 0x01, 0xF0, 0x90, "5 coins 1 credit"},
{0x14, 0x01, 0xF0, 0xA0, "2 coins 3 credits"},
{0x14, 0x01, 0xF0, 0xB0, "2-2-1-1 coins 1-1-1-1 credit"},
{0x14, 0x01, 0xF0, 0xC0, "2-2 coins 1-2 credits"},
{0x14, 0x01, 0xF0, 0xD0, "1-1-1-1-1 coin 1-1-1-1-2 credits"},
{0x14, 0x01, 0xF0, 0xE0, "1-1-1-1 coin 1-1-1-2 credits"},
{0x14, 0x01, 0xF0, 0xF0, "1-1 coin 1-2 credits"},
// DIP 2
{0, 0xFE, 0, 4, "Difficulty"},
{0x15, 0x01, 0x03, 0x00, "Normal"},
{0x15, 0x01, 0x03, 0x01, "Easy"},
{0x15, 0x01, 0x03, 0x02, "Hard"},
{0x15, 0x01, 0x03, 0x03, "Hardest"},
{0, 0xFE, 0, 2, "Continue"},
{0x15, 0x01, 0x04, 0x00, "Unlimited"},
{0x15, 0x01, 0x04, 0x04, "6 times"},
{0, 0xFE, 0, 2, "Flip screen"},
{0x15, 0x01, 0x08, 0x00, "Off"},
{0x15, 0x01, 0x08, 0x08, "On"},
{0, 0xFE, 0, 2, "Lever type"},
{0x15, 0x01, 0x10, 0x00, "Digital"},
{0x15, 0x01, 0x10, 0x10, "Analog"},
{0, 0xFE, 0, 2, "Service mode"},
{0x15, 0x01, 0x20, 0x00, "Off"},
{0x15, 0x01, 0x20, 0x20, "On"},
{0, 0xFE, 0, 2, "Health pack"},
{0x15, 0x01, 0x40, 0x00, "32 hitpoints"},
{0x15, 0x01, 0x40, 0x40, "40 hitpoints"},
{0, 0xFE, 0, 2, "Life restoration"},
{0x15, 0x01, 0x80, 0x00, "10 points"},
{0x15, 0x01, 0x80, 0x80, "5 points"},
};
STDDIPINFOEXT(spinlbrk, spinlbrk, spinlbrk_)
STDDIPINFOEXT(spinlbrku, spinlbrk, spinlbrku)
STDDIPINFO(spinlbrkj)
static struct BurnRomInfo spinlbrkRomDesc[] = {
{ "ic98", 0x010000, 0x36c2bf70, BRF_ESS | BRF_PRG }, // 68000 code swapped
{ "ic104", 0x010000, 0x34a7e158, BRF_ESS | BRF_PRG },
{ "ic93", 0x010000, 0x726f4683, BRF_ESS | BRF_PRG },
{ "ic94", 0x010000, 0xc4385e03, BRF_ESS | BRF_PRG },
{ "ic15", 0x080000, 0xe318cf3a, BRF_GRA }, // gfx 1
{ "ic9", 0x080000, 0xe071f674, BRF_GRA },
{ "ic17", 0x080000, 0xa63d5a55, BRF_GRA }, // gfx 2
{ "ic11", 0x080000, 0x7dcc913d, BRF_GRA },
{ "ic16", 0x080000, 0x0d84af7f, BRF_GRA },
{ "ic12", 0x080000, 0xd63fac4e, BRF_GRA }, // gfx 3
{ "ic18", 0x080000, 0x5a60444b, BRF_GRA },
{ "ic14", 0x080000, 0x1befd0f3, BRF_GRA }, // gfx 4
{ "ic20", 0x080000, 0xc2f84a61, BRF_GRA },
{ "ic35", 0x080000, 0xeba8e1a3, BRF_GRA },
{ "ic40", 0x080000, 0x5ef5aa7e, BRF_GRA },
{ "ic19", 0x010000, 0xdb24eeaa, BRF_GRA }, // gfx 5, hardcoded sprite maps
{ "ic13", 0x010000, 0x97025bf4, BRF_GRA },
{ "ic117", 0x008000, 0x625ada41, BRF_ESS | BRF_PRG }, // Sound CPU
{ "ic118", 0x010000, 0x1025f024, BRF_ESS | BRF_PRG },
{ "ic166", 0x080000, 0x6e0d063a, BRF_SND }, // samples
{ "ic163", 0x080000, 0xe6621dfb, BRF_SND },
{ "epl16p8bp.ic133", 0x107, 0x00000000, BRF_OPT | BRF_NODUMP }, // read protected
{ "epl16p8bp.ic127", 0x107, 0x00000000, BRF_OPT | BRF_NODUMP },
{ "epl16p8bp.ic99", 0x107, 0x00000000, BRF_OPT | BRF_NODUMP },
{ "epl16p8bp.ic100", 0x107, 0x00000000, BRF_OPT | BRF_NODUMP },
{ "gal16v8a.ic95", 0x107, 0x00000000, BRF_OPT | BRF_NODUMP },
{ "gal16v8a.ic114", 0x107, 0x00000000, BRF_OPT | BRF_NODUMP },
};
STD_ROM_PICK(spinlbrk)
STD_ROM_FN(spinlbrk)
static struct BurnRomInfo spinlbrkuRomDesc[] = {
{ "ic98.u5", 0x010000, 0x3a0f7667, BRF_ESS | BRF_PRG }, // 68000 code swapped
{ "ic104.u6", 0x010000, 0xa0e0af31, BRF_ESS | BRF_PRG },
{ "ic93.u4", 0x010000, 0x0cf73029, BRF_ESS | BRF_PRG },
{ "ic94.u3", 0x010000, 0x5cf7c426, BRF_ESS | BRF_PRG },
{ "ic15", 0x080000, 0xe318cf3a, BRF_GRA }, // gfx 1
{ "ic9", 0x080000, 0xe071f674, BRF_GRA },
{ "ic17", 0x080000, 0xa63d5a55, BRF_GRA }, // gfx 2
{ "ic11", 0x080000, 0x7dcc913d, BRF_GRA },
{ "ic16", 0x080000, 0x0d84af7f, BRF_GRA },
{ "ic12", 0x080000, 0xd63fac4e, BRF_GRA }, // gfx 3
{ "ic18", 0x080000, 0x5a60444b, BRF_GRA },
{ "ic14", 0x080000, 0x1befd0f3, BRF_GRA }, // gfx 4
{ "ic20", 0x080000, 0xc2f84a61, BRF_GRA },
{ "ic35", 0x080000, 0xeba8e1a3, BRF_GRA },
{ "ic40", 0x080000, 0x5ef5aa7e, BRF_GRA },
{ "ic19", 0x010000, 0xdb24eeaa, BRF_GRA }, // gfx 5, hardcoded sprite maps
{ "ic13", 0x010000, 0x97025bf4, BRF_GRA },
{ "ic117", 0x008000, 0x625ada41, BRF_ESS | BRF_PRG }, // Sound CPU
{ "ic118", 0x010000, 0x1025f024, BRF_ESS | BRF_PRG },
{ "ic166", 0x080000, 0x6e0d063a, BRF_SND }, // samples
{ "ic163", 0x080000, 0xe6621dfb, BRF_SND },
{ "epl16p8bp.ic133", 0x107, 0x00000000, BRF_OPT | BRF_NODUMP }, // read protected
{ "epl16p8bp.ic127", 0x107, 0x00000000, BRF_OPT | BRF_NODUMP },
{ "epl16p8bp.ic99", 0x107, 0x00000000, BRF_OPT | BRF_NODUMP },
{ "epl16p8bp.ic100", 0x107, 0x00000000, BRF_OPT | BRF_NODUMP },
{ "gal16v8a.ic95", 0x107, 0x00000000, BRF_OPT | BRF_NODUMP },
{ "gal16v8a.ic114", 0x107, 0x00000000, BRF_OPT | BRF_NODUMP },
};
STD_ROM_PICK(spinlbrku)
STD_ROM_FN(spinlbrku)
static struct BurnRomInfo spinlbrkjRomDesc[] = {
{ "j5", 0x010000, 0x6a3d690e, BRF_ESS | BRF_PRG }, // 68000 code swapped
{ "j6", 0x010000, 0x869593fa, BRF_ESS | BRF_PRG },
{ "j4", 0x010000, 0x33e33912, BRF_ESS | BRF_PRG },
{ "j3", 0x010000, 0x16ca61d0, BRF_ESS | BRF_PRG },
{ "ic15", 0x080000, 0xe318cf3a, BRF_GRA }, // gfx 1
{ "ic9", 0x080000, 0xe071f674, BRF_GRA },
{ "ic17", 0x080000, 0xa63d5a55, BRF_GRA }, // gfx 2
{ "ic11", 0x080000, 0x7dcc913d, BRF_GRA },
{ "ic16", 0x080000, 0x0d84af7f, BRF_GRA },
{ "ic12", 0x080000, 0xd63fac4e, BRF_GRA }, // gfx 3
{ "ic18", 0x080000, 0x5a60444b, BRF_GRA },
{ "ic14", 0x080000, 0x1befd0f3, BRF_GRA }, // gfx 4
{ "ic20", 0x080000, 0xc2f84a61, BRF_GRA },
{ "ic35", 0x080000, 0xeba8e1a3, BRF_GRA },
{ "ic40", 0x080000, 0x5ef5aa7e, BRF_GRA },
{ "ic19", 0x010000, 0xdb24eeaa, BRF_GRA }, // gfx 5, hardcoded sprite maps
{ "ic13", 0x010000, 0x97025bf4, BRF_GRA },
{ "ic117", 0x008000, 0x625ada41, BRF_ESS | BRF_PRG }, // Sound CPU
{ "ic118", 0x010000, 0x1025f024, BRF_ESS | BRF_PRG },
{ "ic166", 0x080000, 0x6e0d063a, BRF_SND }, // samples
{ "ic163", 0x080000, 0xe6621dfb, BRF_SND },
{ "epl16p8bp.ic133", 0x107, 0x00000000, BRF_OPT | BRF_NODUMP }, // read protected
{ "epl16p8bp.ic127", 0x107, 0x00000000, BRF_OPT | BRF_NODUMP },
{ "epl16p8bp.ic99", 0x107, 0x00000000, BRF_OPT | BRF_NODUMP },
{ "epl16p8bp.ic100", 0x107, 0x00000000, BRF_OPT | BRF_NODUMP },
{ "gal16v8a.ic95", 0x107, 0x00000000, BRF_OPT | BRF_NODUMP },
{ "gal16v8a.ic114", 0x107, 0x00000000, BRF_OPT | BRF_NODUMP },
};
STD_ROM_PICK(spinlbrkj)
STD_ROM_FN(spinlbrkj)
/*
unsigned char __fastcall spinlbrkReadByte(unsigned int sekAddress)
{
switch (sekAddress) {
default:
printf("Attempt to read byte value of location %x\n", sekAddress);
}
return 0;
}
*/
unsigned short __fastcall spinlbrkReadWord(unsigned int sekAddress)
{
switch (sekAddress) {
case 0xFFF000:
return ~(DrvInput[0] | (DrvInput[2] << 8));
case 0xFFF002:
return ~(DrvInput[1]);
case 0xFFF004:
return ~(DrvInput[3] | (DrvInput[4] << 8));
// default:
// printf("Attempt to read word value of location %x\n", sekAddress);
}
return 0;
}
void __fastcall spinlbrkWriteByte(unsigned int sekAddress, unsigned char byteValue)
{
switch (sekAddress) {
case 0xFFF401:
case 0xFFF403:
// NOP
break;
case 0xFFF007:
pending_command = 1;
SoundCommand(byteValue);
break;
// default:
// printf("Attempt to write byte value %x to location %x\n", byteValue, sekAddress);
}
}
void __fastcall spinlbrkWriteWord(unsigned int sekAddress, unsigned short wordValue)
{
if (( sekAddress & 0xFFF000 ) == 0xFFE000) {
sekAddress &= 0x07FF;
*((unsigned short *)&RamPal[sekAddress]) = wordValue;
RamCurPal[sekAddress>>1] = CalcCol( wordValue );
return;
}
switch (sekAddress) {
case 0xFFF000:
RamGfxBank[0] = (wordValue & 0x07);
RamGfxBank[1] = (wordValue & 0x38) >> 3;
break;
case 0xFFF002:
bg2scrollx = wordValue;
break;
case 0xFFF008:
// NOP
break;
// default:
// printf("Attempt to write word value %x to location %x\n", wordValue, sekAddress);
}
}
static int spinlbrkMemIndex()
{
unsigned char *Next; Next = Mem;
Rom01 = Next; Next += 0x040000; // 68000 ROM
RomZ80 = Next; Next += 0x030000; // Z80 ROM
RomBg = Next; Next += 0x500040; // Background, 2.5M 8x8x4bit
DeRomBg = RomBg + 0x000040;
RomSpr1 = Next; Next += 0x200000; // Sprite 1
RomSpr2 = Next; Next += 0x400100; // Sprite 2
DeRomSpr1 = RomSpr1 + 0x000100;
DeRomSpr2 = RomSpr2 += 0x000100;
RomSnd2 = Next; Next += 0x100000; // ADPCM data
RomSnd1 = RomSnd2;
RomSndSize1 = 0x100000;
RomSndSize2 = 0x100000;
RamSpr2 = (unsigned short *)Next; Next += 0x020000; // Sprite 2 Ram
RamSpr1 = (unsigned short *)Next; Next += 0x004000; // Sprite 1 Ram
RamStart = Next;
RamBg1V = (unsigned short *)Next; Next += 0x001000; // BG1 Video Ram
RamBg2V = (unsigned short *)Next; Next += 0x002000; // BG2 Video Ram
Ram01 = Next; Next += 0x004000; // Work Ram
RamSpr3 = (unsigned short *)Next; Next += 0x000800; // Sprite 3 Ram
RamRaster = (unsigned short *)Next; Next += 0x000200; // Raster
RamPal = Next; Next += 0x000800; // 1024 of X1R5G5B5 Palette
RamZ80 = Next; Next += 0x000800; // Z80 Ram 2K
RamSpr1SizeMask = 0x1FFF;
RamSpr2SizeMask = 0xFFFF;
RomSpr1SizeMask = 0x1FFF;
RomSpr2SizeMask = 0x3FFF;
RamEnd = Next;
RamCurPal = (unsigned int *)Next; Next += 0x000800 * sizeof(unsigned int);
MemEnd = Next;
return 0;
}
static int spinlbrkInit()
{
Mem = NULL;
spinlbrkMemIndex();
int nLen = MemEnd - (unsigned char *)0;
if ((Mem = (unsigned char *)malloc(nLen)) == NULL) return 1;
memset(Mem, 0, nLen);
spinlbrkMemIndex();
// Load 68000 ROM
if (BurnLoadRom(Rom01+0x00001, 0, 2)) return 1;
if (BurnLoadRom(Rom01+0x00000, 1, 2)) return 1;
if (BurnLoadRom(Rom01+0x20001, 2, 2)) return 1;
if (BurnLoadRom(Rom01+0x20000, 3, 2)) return 1;
// Load Graphic
BurnLoadRom(RomBg+0x000000, 4, 1);
BurnLoadRom(RomBg+0x080000, 5, 1);
BurnLoadRom(RomBg+0x100000, 6, 1);
BurnLoadRom(RomBg+0x180000, 7, 1);
BurnLoadRom(RomBg+0x200000, 8, 1);
pspikesDecodeBg(0x14000);
BurnLoadRom(RomSpr1+0x000000, 9, 2);
BurnLoadRom(RomSpr1+0x000001, 10, 2);
BurnLoadRom(RomSpr1+0x100000, 11, 2);
BurnLoadRom(RomSpr1+0x100001, 13, 2);
BurnLoadRom(RomSpr1+0x200000, 12, 2);
BurnLoadRom(RomSpr1+0x200001, 14, 2);
pspikesDecodeSpr(DeRomSpr1, RomSpr1, 0x6000);
BurnLoadRom((unsigned char *)RamSpr2+0x000001, 15, 2);
BurnLoadRom((unsigned char *)RamSpr2+0x000000, 16, 2);
// Load Z80 ROM
if (BurnLoadRom(RomZ80+0x00000, 17, 1)) return 1;
if (BurnLoadRom(RomZ80+0x08000, 17, 1)) return 1;
if (BurnLoadRom(RomZ80+0x10000, 18, 1)) return 1;
BurnLoadRom(RomSnd2+0x00000, 19, 1);
BurnLoadRom(RomSnd2+0x80000, 20, 1);
{
SekInit(0, 0x68000); // Allocate 68000
SekOpen(0);
// Map 68000 memory:
SekMapMemory(Rom01, 0x000000, 0x04FFFF, SM_ROM); // CPU 0 ROM
SekMapMemory((unsigned char *)RamBg1V,
0x080000, 0x080FFF, SM_RAM);
SekMapMemory((unsigned char *)RamBg2V,
0x082000, 0x083FFF, SM_RAM);
SekMapMemory(Ram01, 0xFF8000, 0xFFBFFF, SM_RAM); // Work RAM
SekMapMemory((unsigned char *)RamSpr3,
0xFFC000, 0xFFC7FF, SM_RAM);
SekMapMemory((unsigned char *)RamRaster,
0xFFD000, 0xFFD1FF, SM_RAM);
SekMapMemory(RamPal, 0xFFE000, 0xFFE7FF, SM_ROM); // Palette
SekSetReadWordHandler(0, spinlbrkReadWord);
// SekSetReadByteHandler(0, spinlbrkReadByte);
SekSetWriteWordHandler(0, spinlbrkWriteWord);
SekSetWriteByteHandler(0, spinlbrkWriteByte);
SekClose();
}
{
ZetInit(1);
ZetOpen(0);
ZetMapArea(0x0000, 0x77FF, 0, RomZ80);
ZetMapArea(0x0000, 0x77FF, 2, RomZ80);
ZetMapArea(0x7800, 0x7FFF, 0, RamZ80);
ZetMapArea(0x7800, 0x7FFF, 1, RamZ80);
ZetMapArea(0x7800, 0x7FFF, 2, RamZ80);
ZetMemEnd();
ZetSetInHandler(turbofrcZ80PortRead);
ZetSetOutHandler(turbofrcZ80PortWrite);
ZetClose();
}
BurnYM2610Init(8000000, RomSnd2, &RomSndSize2, RomSnd1, &RomSndSize1, &aerofgtFMIRQHandler, aerofgtSynchroniseStream, aerofgtGetTime, 0);
BurnTimerAttachZet(4000000);
bg2scrollx = 0; //
for (unsigned short i=0; i<0x2000;i++)
RamSpr1[i] = i;
DrvDoReset();
return 0;
}
static void spinlbrkTileBackground_1(unsigned short *bg, unsigned char *BgGfx, unsigned int *pal)
{
int offs, mx, my, x, y;
mx = -1;
my = 0;
for (offs = 0; offs < 64*64; offs++) {
mx++;
if (mx == 64) {
mx = 0;
my++;
}
x = mx * 8 - (swapWord(RamRaster[my*8]) & 0x1FF); // + 8
if (x <= (352-512)) x += 512;
y = my * 8;
if ( x<=-8 || x>=352 || y<=-8 || y>= 240 )
continue;
else
if ( x >=0 && x < (352-8) && y >= 0 && y < (240-8)) {
unsigned char *d = BgGfx + ( (swapWord(bg[offs]) & 0x0FFF) + ( swapWord(RamGfxBank[0]) << 12 ) ) * 64;
unsigned short c = (swapWord(bg[offs]) & 0xF000) >> 8;
unsigned short * p = (unsigned short *) pBurnDraw + y * 352 + x;
for (int k=0;k<8;k++) {
p[0] = pal[ d[0] | c ];
p[1] = pal[ d[1] | c ];
p[2] = pal[ d[2] | c ];
p[3] = pal[ d[3] | c ];
p[4] = pal[ d[4] | c ];
p[5] = pal[ d[5] | c ];
p[6] = pal[ d[6] | c ];
p[7] = pal[ d[7] | c ];
d += 8;
p += 352;
}
} else {
unsigned char *d = BgGfx + ( (swapWord(bg[offs]) & 0x0FFF) + ( swapWord(RamGfxBank[0]) << 12 ) ) * 64;
unsigned short c = (swapWord(bg[offs]) & 0xF000) >> 8;
unsigned short * p = (unsigned short *) pBurnDraw + y * 352 + x;
for (int k=0;k<8;k++) {
if ( (y+k)>=0 && (y+k)<240 ) {
if ((x + 0) >= 0 && (x + 0)<352) p[0] = pal[ d[0] | c ];
if ((x + 1) >= 0 && (x + 1)<352) p[1] = pal[ d[1] | c ];
if ((x + 2) >= 0 && (x + 2)<352) p[2] = pal[ d[2] | c ];
if ((x + 3) >= 0 && (x + 3)<352) p[3] = pal[ d[3] | c ];
if ((x + 4) >= 0 && (x + 4)<352) p[4] = pal[ d[4] | c ];
if ((x + 5) >= 0 && (x + 5)<352) p[5] = pal[ d[5] | c ];
if ((x + 6) >= 0 && (x + 6)<352) p[6] = pal[ d[6] | c ];
if ((x + 7) >= 0 && (x + 7)<352) p[7] = pal[ d[7] | c ];
}
d += 8;
p += 352;
}
}
}
}
static int spinlbrkDraw()
{
// update palette
aerofgtPalUpdate();
spinlbrkTileBackground_1(RamBg1V, DeRomBg, RamCurPal);
karatblzTileBackground_2(RamBg2V, DeRomBg + 0x200000, RamCurPal + 256);
turbofrc_drawsprites(1,-1); // enemy(near far)
turbofrc_drawsprites(1, 0); // enemy(near) fense
turbofrc_drawsprites(0, 0); // avatar , post , bullet
turbofrc_drawsprites(0,-1);
/*
unsigned short *ps = RamCurPal;
unsigned short *pd = (unsigned short *)pBurnDraw;
for (int j=0;j<32;j++) {
for (int i=0;i<32;i++) {
*pd = *ps;
pd ++;
ps ++;
}
pd += 352 - 32;
}
*/
return 0;
}
static int spinlbrkFrame()
{
if (DrvReset) DrvDoReset();
// Compile digital inputs
DrvInput[0] = 0x00; // Joy1
DrvInput[1] = 0x00; // Joy2
DrvInput[2] = 0x00; // Buttons
for (int i = 0; i < 8; i++) {
DrvInput[0] |= (DrvJoy1[i] & 1) << i;
DrvInput[1] |= (DrvJoy2[i] & 1) << i;
DrvInput[2] |= (DrvButton[i] & 1) << i;
}
SekNewFrame();
ZetNewFrame();
nCyclesTotal[0] = (int)((long long)10000000 * nBurnCPUSpeedAdjust / (0x0100 * 60));
nCyclesTotal[1] = (int)(4000000 / 60);
SekOpen(0);
ZetOpen(0);
SekRun(nCyclesTotal[0]);
SekSetIRQLine(1, SEK_IRQSTATUS_AUTO);
BurnTimerEndFrame(nCyclesTotal[1]);
BurnYM2610Update(pBurnSoundOut, nBurnSoundLen);
ZetClose();
SekClose();
if (pBurnDraw) spinlbrkDraw();
return 0;
}
struct BurnDriver BurnDrvSpinlbrk = {
"spinlbrk", NULL, NULL, "1990",
"Spinal Breakers (World)\0", NULL, "Video System Co.", "Video System",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_16BIT_ONLY, 2, HARDWARE_MISC_MISC,
NULL, spinlbrkRomInfo, spinlbrkRomName, spinlbrkInputInfo, spinlbrkDIPInfo,
spinlbrkInit,DrvExit,spinlbrkFrame,spinlbrkDraw,DrvScan,
NULL,352,240,4,3
};
struct BurnDriver BurnDrvSpinlbrku = {
"spinlbrku", "spinlbrk", NULL, "1990",
"Spinal Breakers (US)\0", NULL, "Video System Co.", "Video System",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_CLONE | BDF_16BIT_ONLY, 2, HARDWARE_MISC_MISC,
NULL, spinlbrkuRomInfo, spinlbrkuRomName, spinlbrkInputInfo, spinlbrkuDIPInfo,
spinlbrkInit,DrvExit,spinlbrkFrame,spinlbrkDraw,DrvScan,
NULL,352,240,4,3
};
struct BurnDriver BurnDrvSpinlbrkj = {
"spinlbrkj", "spinlbrk", NULL, "1990",
"Spinal Breakers (Japan)\0", NULL, "Video System Co.", "Video System",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_CLONE | BDF_16BIT_ONLY, 2, HARDWARE_MISC_MISC,
NULL, spinlbrkjRomInfo, spinlbrkjRomName, spinlbrkInputInfo, spinlbrkjDIPInfo,
spinlbrkInit,DrvExit,spinlbrkFrame,spinlbrkDraw,DrvScan,
NULL,352,240,4,3
};
// -------------------------------------------------------
static struct BurnRomInfo aerofgtbRomDesc[] = {
{ "v2", 0x040000, 0x5c9de9f0, BRF_ESS | BRF_PRG }, // 68000 code swapped
{ "v1", 0x040000, 0x89c1dcf4, BRF_ESS | BRF_PRG }, // 68000 code swapped
{ "it-19-03", 0x080000, 0x85eba1a4, BRF_GRA }, // graphics
{ "it-19-02", 0x080000, 0x4f57f8ba, BRF_GRA },
{ "it-19-04", 0x080000, 0x3b329c1f, BRF_GRA }, //
{ "it-19-05", 0x080000, 0x02b525af, BRF_GRA }, //
{ "g27", 0x040000, 0x4d89cbc8, BRF_GRA },
{ "g26", 0x040000, 0x8072c1d2, BRF_GRA },
{ "v3", 0x020000, 0xcbb18cf4, BRF_ESS | BRF_PRG }, // Sound CPU
{ "it-19-01", 0x040000, 0x6d42723d, BRF_SND }, // samples
{ "it-19-06", 0x100000, 0xcdbbdb1d, BRF_SND },
};
STD_ROM_PICK(aerofgtb)
STD_ROM_FN(aerofgtb)
static struct BurnRomInfo aerofgtcRomDesc[] = {
{ "v2.149", 0x040000, 0xf187aec6, BRF_ESS | BRF_PRG }, // 68000 code swapped
{ "v1.111", 0x040000, 0x9e684b19, BRF_ESS | BRF_PRG }, // 68000 code swapped
{ "it-19-03", 0x080000, 0x85eba1a4, BRF_GRA }, // graphics
{ "it-19-02", 0x080000, 0x4f57f8ba, BRF_GRA },
{ "it-19-04", 0x080000, 0x3b329c1f, BRF_GRA }, //
{ "it-19-05", 0x080000, 0x02b525af, BRF_GRA }, //
{ "g27", 0x040000, 0x4d89cbc8, BRF_GRA },
{ "g26", 0x040000, 0x8072c1d2, BRF_GRA },
{ "2.153", 0x020000, 0xa1ef64ec, BRF_ESS | BRF_PRG }, // Sound CPU
{ "it-19-01", 0x040000, 0x6d42723d, BRF_SND }, // samples
{ "it-19-06", 0x100000, 0xcdbbdb1d, BRF_SND },
};
STD_ROM_PICK(aerofgtc)
STD_ROM_FN(aerofgtc)
static struct BurnRomInfo sonicwiRomDesc[] = {
{ "2.149", 0x040000, 0x3d1b96ba, BRF_ESS | BRF_PRG }, // 68000 code swapped
{ "1.111", 0x040000, 0xa3d09f94, BRF_ESS | BRF_PRG }, // 68000 code swapped
{ "it-19-03", 0x080000, 0x85eba1a4, BRF_GRA }, // graphics
{ "it-19-02", 0x080000, 0x4f57f8ba, BRF_GRA },
{ "it-19-04", 0x080000, 0x3b329c1f, BRF_GRA }, //
{ "it-19-05", 0x080000, 0x02b525af, BRF_GRA }, //
{ "g27", 0x040000, 0x4d89cbc8, BRF_GRA },
{ "g26", 0x040000, 0x8072c1d2, BRF_GRA },
{ "2.153", 0x020000, 0xa1ef64ec, BRF_ESS | BRF_PRG }, // Sound CPU
{ "it-19-01", 0x040000, 0x6d42723d, BRF_SND }, // samples
{ "it-19-06", 0x100000, 0xcdbbdb1d, BRF_SND },
};
STD_ROM_PICK(sonicwi)
STD_ROM_FN(sonicwi)
unsigned char __fastcall aerofgtbReadByte(unsigned int sekAddress)
{
switch (sekAddress) {
case 0x0FE000:
return ~DrvInput[2];
case 0x0FE001:
return ~DrvInput[0];
case 0x0FE002:
return 0xFF;
case 0x0FE003:
return ~DrvInput[1];
case 0x0FE004:
return ~DrvInput[4];
case 0x0FE005:
return ~DrvInput[3];
case 0x0FE007:
return pending_command;
case 0x0FE009:
return ~DrvInput[5];
default:
printf("Attempt to read byte value of location %x\n", sekAddress);
}
return 0;
}
unsigned short __fastcall aerofgtbReadWord(unsigned int sekAddress)
{
// switch (sekAddress) {
// default:
// printf("Attempt to read word value of location %x\n", sekAddress);
// }
return 0;
}
void __fastcall aerofgtbWriteByte(unsigned int sekAddress, unsigned char byteValue)
{
if (( sekAddress & 0x0FF000 ) == 0x0FD000) {
sekAddress &= 0x07FF;
RamPal[sekAddress^1] = byteValue;
// palette byte write at boot self-test only ?!
//if (sekAddress & 1)
// RamCurPal[sekAddress>>1] = CalcCol( *((unsigned short *)&RamPal[sekAddress & 0xFFE]) );
return;
}
switch (sekAddress) {
case 0x0FE001:
case 0x0FE401:
case 0x0FE403:
// NOP
break;
case 0x0FE00E:
pending_command = 1;
SoundCommand(byteValue);
break;
default:
printf("Attempt to write byte value %x to location %x\n", byteValue, sekAddress);
}
}
void __fastcall aerofgtbWriteWord(unsigned int sekAddress, unsigned short wordValue)
{
if (( sekAddress & 0x0FF000 ) == 0x0FD000) {
sekAddress &= 0x07FE;
*((unsigned short *)&RamPal[sekAddress]) = wordValue;
RamCurPal[sekAddress>>1] = CalcCol( wordValue );
return;
}
switch (sekAddress) {
case 0x0FE002:
bg1scrolly = (wordValue);
break;
case 0x0FE004:
bg2scrollx = (wordValue);
break;
case 0x0FE006:
bg2scrolly = (wordValue);
break;
case 0x0FE008:
RamGfxBank[0] = ((wordValue) >> 0) & 0x0f;
RamGfxBank[1] = ((wordValue) >> 4) & 0x0f;
RamGfxBank[2] = ((wordValue) >> 8) & 0x0f;
RamGfxBank[3] = ((wordValue) >> 12) & 0x0f;
break;
case 0x0FE00A:
RamGfxBank[4] = ((wordValue) >> 0) & 0x0f;
RamGfxBank[5] = ((wordValue) >> 4) & 0x0f;
RamGfxBank[6] = ((wordValue) >> 8) & 0x0f;
RamGfxBank[7] = ((wordValue) >> 12) & 0x0f;
break;
case 0x0FE00C:
// NOP
break;
default:
printf("Attempt to write word value %x to location %x\n", wordValue, sekAddress);
}
}
static int aerofgtbMemIndex()
{
unsigned char *Next; Next = Mem;
Rom01 = Next; Next += 0x080000; // 68000 ROM
RomZ80 = Next; Next += 0x030000; // Z80 ROM
RomBg = Next; Next += 0x200040; // Background, 1M 8x8x4bit decode to 2M + 64Byte safe
DeRomBg = RomBg + 0x000040;
RomSpr1 = Next; Next += 0x200000; // Sprite 1 , 1M 16x16x4bit decode to 2M + 256Byte safe
RomSpr2 = Next; Next += 0x100100; // Sprite 2
DeRomSpr1 = RomSpr1 + 0x000100;
DeRomSpr2 = RomSpr2 += 0x000100;
RomSnd1 = Next; Next += 0x040000; // ADPCM data
RomSndSize1 = 0x040000;
RomSnd2 = Next; Next += 0x100000; // ADPCM data
RomSndSize2 = 0x100000;
RamStart = Next;
Ram01 = Next; Next += 0x014000; // Work Ram
RamBg1V = (unsigned short *)Next; Next += 0x002000; // BG1 Video Ram
RamBg2V = (unsigned short *)Next; Next += 0x002000; // BG2 Video Ram
RamSpr1 = (unsigned short *)Next; Next += 0x004000; // Sprite 1 Ram
RamSpr2 = (unsigned short *)Next; Next += 0x004000; // Sprite 2 Ram
RamSpr3 = (unsigned short *)Next; Next += 0x000800; // Sprite 3 Ram
RamPal = Next; Next += 0x000800; // 1024 of X1R5G5B5 Palette
RamRaster = (unsigned short *)Next; Next += 0x001000; // Raster
RamSpr1SizeMask = 0x1FFF;
RamSpr2SizeMask = 0x1FFF;
RomSpr1SizeMask = 0x1FFF;
RomSpr2SizeMask = 0x0FFF;
RamZ80 = Next; Next += 0x000800; // Z80 Ram 2K
RamEnd = Next;
RamCurPal = (unsigned int *)Next; Next += 0x000800 * sizeof(unsigned int); // 1024 colors
MemEnd = Next;
return 0;
}
static void aerofgtbDecodeSpr(unsigned char *d, unsigned char *s, int cnt)
{
for (int c=cnt-1; c>=0; c--)
for (int y=15; y>=0; y--) {
d[(c * 256) + (y * 16) + 15] = s[0x00005 + (y * 8) + (c * 128)] >> 4;
d[(c * 256) + (y * 16) + 14] = s[0x00005 + (y * 8) + (c * 128)] & 0x0f;
d[(c * 256) + (y * 16) + 13] = s[0x00007 + (y * 8) + (c * 128)] >> 4;
d[(c * 256) + (y * 16) + 12] = s[0x00007 + (y * 8) + (c * 128)] & 0x0f;
d[(c * 256) + (y * 16) + 11] = s[0x00004 + (y * 8) + (c * 128)] >> 4;
d[(c * 256) + (y * 16) + 10] = s[0x00004 + (y * 8) + (c * 128)] & 0x0f;
d[(c * 256) + (y * 16) + 9] = s[0x00006 + (y * 8) + (c * 128)] >> 4;
d[(c * 256) + (y * 16) + 8] = s[0x00006 + (y * 8) + (c * 128)] & 0x0f;
d[(c * 256) + (y * 16) + 7] = s[0x00001 + (y * 8) + (c * 128)] >> 4;
d[(c * 256) + (y * 16) + 6] = s[0x00001 + (y * 8) + (c * 128)] & 0x0f;
d[(c * 256) + (y * 16) + 5] = s[0x00003 + (y * 8) + (c * 128)] >> 4;
d[(c * 256) + (y * 16) + 4] = s[0x00003 + (y * 8) + (c * 128)] & 0x0f;
d[(c * 256) + (y * 16) + 3] = s[0x00000 + (y * 8) + (c * 128)] >> 4;
d[(c * 256) + (y * 16) + 2] = s[0x00000 + (y * 8) + (c * 128)] & 0x0f;
d[(c * 256) + (y * 16) + 1] = s[0x00002 + (y * 8) + (c * 128)] >> 4;
d[(c * 256) + (y * 16) + 0] = s[0x00002 + (y * 8) + (c * 128)] & 0x0f;
}
}
static int aerofgtbInit()
{
Mem = NULL;
aerofgtbMemIndex();
int nLen = MemEnd - (unsigned char *)0;
if ((Mem = (unsigned char *)malloc(nLen)) == NULL) {
return 1;
}
memset(Mem, 0, nLen); // blank all memory
aerofgtbMemIndex();
// Load the roms into memory
// Load 68000 ROM
if (BurnLoadRom(Rom01 + 0x00001, 0, 2)) return 1;
if (BurnLoadRom(Rom01 + 0x00000, 1, 2)) return 1;
// Load Graphic
BurnLoadRom(RomBg+0x00000, 2, 1);
BurnLoadRom(RomBg+0x80000, 3, 1);
pspikesDecodeBg(0x8000);
BurnLoadRom(RomSpr1+0x000000, 4, 2);
BurnLoadRom(RomSpr1+0x000001, 5, 2);
BurnLoadRom(RomSpr1+0x100000, 6, 2);
BurnLoadRom(RomSpr1+0x100001, 7, 2);
aerofgtbDecodeSpr(DeRomSpr1, RomSpr1, 0x3000);
// Load Z80 ROM
if (BurnLoadRom(RomZ80+0x10000, 8, 1)) return 1;
memcpy(RomZ80, RomZ80+0x10000, 0x10000);
BurnLoadRom(RomSnd1, 9, 1);
BurnLoadRom(RomSnd2, 10, 1);
{
SekInit(0, 0x68000); // Allocate 68000
SekOpen(0);
// Map 68000 memory:
SekMapMemory(Rom01, 0x000000, 0x07FFFF, SM_ROM); // CPU 0 ROM
SekMapMemory(Ram01, 0x0C0000, 0x0CFFFF, SM_RAM); // 64K Work RAM
SekMapMemory((unsigned char *)RamBg1V,
0x0D0000, 0x0D1FFF, SM_RAM);
SekMapMemory((unsigned char *)RamBg2V,
0x0D2000, 0x0D3FFF, SM_RAM);
SekMapMemory((unsigned char *)RamSpr1,
0x0E0000, 0x0E3FFF, SM_RAM);
SekMapMemory((unsigned char *)RamSpr2,
0x0E4000, 0x0E7FFF, SM_RAM);
SekMapMemory(Ram01+0x10000, 0x0F8000, 0x0FBFFF, SM_RAM); // Work RAM
SekMapMemory((unsigned char *)RamSpr3,
0x0FC000, 0x0FC7FF, SM_RAM);
SekMapMemory(RamPal, 0x0FD000, 0x0FD7FF, SM_ROM); // Palette
SekMapMemory((unsigned char *)RamRaster,
0x0FF000, 0x0FFFFF, SM_RAM); // Raster
SekSetReadWordHandler(0, aerofgtbReadWord);
SekSetReadByteHandler(0, aerofgtbReadByte);
SekSetWriteWordHandler(0, aerofgtbWriteWord);
SekSetWriteByteHandler(0, aerofgtbWriteByte);
SekClose();
}
{
ZetInit(1);
ZetOpen(0);
ZetMapArea(0x0000, 0x77FF, 0, RomZ80);
ZetMapArea(0x0000, 0x77FF, 2, RomZ80);
ZetMapArea(0x7800, 0x7FFF, 0, RamZ80);
ZetMapArea(0x7800, 0x7FFF, 1, RamZ80);
ZetMapArea(0x7800, 0x7FFF, 2, RamZ80);
ZetMemEnd();
//ZetSetReadHandler(aerofgtZ80Read);
//ZetSetWriteHandler(aerofgtZ80Write);
ZetSetInHandler(aerofgtZ80PortRead);
ZetSetOutHandler(aerofgtZ80PortWrite);
ZetClose();
}
BurnYM2610Init(8000000, RomSnd2, &RomSndSize2, RomSnd1, &RomSndSize1, &aerofgtFMIRQHandler, aerofgtSynchroniseStream, aerofgtGetTime, 0);
BurnTimerAttachZet(4000000);
DrvDoReset(); // Reset machine
return 0;
}
static void aerofgtbTileBackground_1(unsigned short *bg, unsigned char *BgGfx, unsigned int *pal)
{
int offs, mx, my, x, y;
mx = -1;
my = 0;
for (offs = 0; offs < 64*64; offs++) {
mx++;
if (mx == 64) {
mx = 0;
my++;
}
x = mx * 8 - (swapWord(RamRaster[7]) & 0x1FF);
if (x <= (320-512)) x += 512;
y = my * 8 - (((signed short)bg1scrolly + 2) & 0x1FF);
if (y <= (224-512)) y += 512;
if ( x<=-8 || x>=320 || y<=-8 || y>= 224 )
continue;
else
if ( x >=0 && x < (320-8) && y >= 0 && y < (224-8)) {
unsigned char *d = BgGfx + ( (swapWord(bg[offs]) & 0x07FF) + ( RamGfxBank[((swapWord(bg[offs]) & 0x1800) >> 11)] << 11 ) ) * 64;
unsigned short c = (swapWord(bg[offs]) & 0xE000) >> 9;
unsigned short * p = (unsigned short *) pBurnDraw + y * 320 + x;
for (int k=0;k<8;k++) {
p[0] = pal[ d[0] | c ];
p[1] = pal[ d[1] | c ];
p[2] = pal[ d[2] | c ];
p[3] = pal[ d[3] | c ];
p[4] = pal[ d[4] | c ];
p[5] = pal[ d[5] | c ];
p[6] = pal[ d[6] | c ];
p[7] = pal[ d[7] | c ];
d += 8;
p += 320;
}
} else {
unsigned char *d = BgGfx + ( (swapWord(bg[offs]) & 0x07FF) + ( RamGfxBank[((swapWord(bg[offs]) & 0x1800) >> 11)] << 11 ) ) * 64;
unsigned short c = (swapWord(bg[offs]) & 0xE000) >> 9;
unsigned short * p = (unsigned short *) pBurnDraw + y * 320 + x;
for (int k=0;k<8;k++) {
if ( (y+k)>=0 && (y+k)<224 ) {
if ((x + 0) >= 0 && (x + 0)<320) p[0] = pal[ d[0] | c ];
if ((x + 1) >= 0 && (x + 1)<320) p[1] = pal[ d[1] | c ];
if ((x + 2) >= 0 && (x + 2)<320) p[2] = pal[ d[2] | c ];
if ((x + 3) >= 0 && (x + 3)<320) p[3] = pal[ d[3] | c ];
if ((x + 4) >= 0 && (x + 4)<320) p[4] = pal[ d[4] | c ];
if ((x + 5) >= 0 && (x + 5)<320) p[5] = pal[ d[5] | c ];
if ((x + 6) >= 0 && (x + 6)<320) p[6] = pal[ d[6] | c ];
if ((x + 7) >= 0 && (x + 7)<320) p[7] = pal[ d[7] | c ];
}
d += 8;
p += 320;
}
}
}
}
static void aerofgtbTileBackground_2(unsigned short *bg, unsigned char *BgGfx, unsigned int *pal)
{
int offs, mx, my, x, y;
//printf(" %5d%5d%5d%5d\n", (signed short)RamRaster[7],(signed short)bg1scrolly, (signed short)bg2scrollx,(signed short)bg2scrolly);
mx = -1;
my = 0;
for (offs = 0; offs < 64*64; offs++) {
mx++;
if (mx == 64) {
mx = 0;
my++;
}
x = mx * 8 - (((signed short)bg2scrollx + 5) & 0x1FF);
if (x <= (320-512)) x += 512;
y = my * 8 - (((signed short)bg2scrolly + 2) & 0x1FF);
if (y <= (224-512)) y += 512;
if ( x<=-8 || x>=320 || y<=-8 || y>= 224 )
continue;
else
if ( x >=0 && x < (320-8) && y >= 0 && y < (224-8)) {
unsigned char *d = BgGfx + ( (swapWord(bg[offs]) & 0x07FF) + ( RamGfxBank[((swapWord(bg[offs]) & 0x1800) >> 11) + 4] << 11 ) ) * 64;
unsigned short c = (swapWord(bg[offs]) & 0xE000) >> 9;
unsigned short * p = (unsigned short *) pBurnDraw + y * 320 + x;
for (int k=0;k<8;k++) {
if (d[0] != 15) p[0] = pal[ d[0] | c ];
if (d[1] != 15) p[1] = pal[ d[1] | c ];
if (d[2] != 15) p[2] = pal[ d[2] | c ];
if (d[3] != 15) p[3] = pal[ d[3] | c ];
if (d[4] != 15) p[4] = pal[ d[4] | c ];
if (d[5] != 15) p[5] = pal[ d[5] | c ];
if (d[6] != 15) p[6] = pal[ d[6] | c ];
if (d[7] != 15) p[7] = pal[ d[7] | c ];
d += 8;
p += 320;
}
} else {
unsigned char *d = BgGfx + ( (swapWord(bg[offs]) & 0x07FF) + ( RamGfxBank[((swapWord(bg[offs]) & 0x1800) >> 11) + 4] << 11 ) ) * 64;
unsigned short c = (swapWord(bg[offs]) & 0xE000) >> 9;
unsigned short * p = (unsigned short *) pBurnDraw + y * 320 + x;
for (int k=0;k<8;k++) {
if ( (y+k)>=0 && (y+k)<224 ) {
if (d[0] != 15 && (x + 0) >= 0 && (x + 0)<352) p[0] = pal[ d[0] | c ];
if (d[1] != 15 && (x + 1) >= 0 && (x + 1)<352) p[1] = pal[ d[1] | c ];
if (d[2] != 15 && (x + 2) >= 0 && (x + 2)<352) p[2] = pal[ d[2] | c ];
if (d[3] != 15 && (x + 3) >= 0 && (x + 3)<352) p[3] = pal[ d[3] | c ];
if (d[4] != 15 && (x + 4) >= 0 && (x + 4)<352) p[4] = pal[ d[4] | c ];
if (d[5] != 15 && (x + 5) >= 0 && (x + 5)<352) p[5] = pal[ d[5] | c ];
if (d[6] != 15 && (x + 6) >= 0 && (x + 6)<352) p[6] = pal[ d[6] | c ];
if (d[7] != 15 && (x + 7) >= 0 && (x + 7)<352) p[7] = pal[ d[7] | c ];
}
d += 8;
p += 320;
}
}
}
}
static void aerofgtb_pdrawgfxzoom(int bank,unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,int scalex,int scaley)
{
if (!scalex || !scaley) return;
unsigned short * p = (unsigned short *) pBurnDraw;
unsigned char * q;
unsigned int * pal;
if (bank) {
//if (code > RomSpr2SizeMask)
code &= RomSpr2SizeMask;
q = DeRomSpr2 + (code) * 256;
pal = RamCurPal + 768;
} else {
//if (code > RomSpr1SizeMask)
code &= RomSpr1SizeMask;
q = DeRomSpr1 + (code) * 256;
pal = RamCurPal + 512;
}
p += sy * 320 + sx;
if (sx < 0 || sx >= (320-16) || sy < 0 || sy >= (224-16) ) {
if ((sx <= -16) || (sx >= 320) || (sy <= -16) || (sy >= 224))
return;
if (flipy) {
p += 320 * 15;
if (flipx) {
for (int i=15;i>=0;i--) {
if (((sy+i)>=0) && ((sy+i)<224)) {
if (q[ 0] != 15 && ((sx + 15) >= 0) && ((sx + 15)<320)) p[15] = pal[ q[ 0] | color];
if (q[ 1] != 15 && ((sx + 14) >= 0) && ((sx + 14)<320)) p[14] = pal[ q[ 1] | color];
if (q[ 2] != 15 && ((sx + 13) >= 0) && ((sx + 13)<320)) p[13] = pal[ q[ 2] | color];
if (q[ 3] != 15 && ((sx + 12) >= 0) && ((sx + 12)<320)) p[12] = pal[ q[ 3] | color];
if (q[ 4] != 15 && ((sx + 11) >= 0) && ((sx + 11)<320)) p[11] = pal[ q[ 4] | color];
if (q[ 5] != 15 && ((sx + 10) >= 0) && ((sx + 10)<320)) p[10] = pal[ q[ 5] | color];
if (q[ 6] != 15 && ((sx + 9) >= 0) && ((sx + 9)<320)) p[ 9] = pal[ q[ 6] | color];
if (q[ 7] != 15 && ((sx + 8) >= 0) && ((sx + 8)<320)) p[ 8] = pal[ q[ 7] | color];
if (q[ 8] != 15 && ((sx + 7) >= 0) && ((sx + 7)<320)) p[ 7] = pal[ q[ 8] | color];
if (q[ 9] != 15 && ((sx + 6) >= 0) && ((sx + 6)<320)) p[ 6] = pal[ q[ 9] | color];
if (q[10] != 15 && ((sx + 5) >= 0) && ((sx + 5)<320)) p[ 5] = pal[ q[10] | color];
if (q[11] != 15 && ((sx + 4) >= 0) && ((sx + 4)<320)) p[ 4] = pal[ q[11] | color];
if (q[12] != 15 && ((sx + 3) >= 0) && ((sx + 3)<320)) p[ 3] = pal[ q[12] | color];
if (q[13] != 15 && ((sx + 2) >= 0) && ((sx + 2)<320)) p[ 2] = pal[ q[13] | color];
if (q[14] != 15 && ((sx + 1) >= 0) && ((sx + 1)<320)) p[ 1] = pal[ q[14] | color];
if (q[15] != 15 && ((sx + 0) >= 0) && ((sx + 0)<320)) p[ 0] = pal[ q[15] | color];
}
p -= 320;
q += 16;
}
} else {
for (int i=15;i>=0;i--) {
if (((sy+i)>=0) && ((sy+i)<224)) {
if (q[ 0] != 15 && ((sx + 0) >= 0) && ((sx + 0)<320)) p[ 0] = pal[ q[ 0] | color];
if (q[ 1] != 15 && ((sx + 1) >= 0) && ((sx + 1)<320)) p[ 1] = pal[ q[ 1] | color];
if (q[ 2] != 15 && ((sx + 2) >= 0) && ((sx + 2)<320)) p[ 2] = pal[ q[ 2] | color];
if (q[ 3] != 15 && ((sx + 3) >= 0) && ((sx + 3)<320)) p[ 3] = pal[ q[ 3] | color];
if (q[ 4] != 15 && ((sx + 4) >= 0) && ((sx + 4)<320)) p[ 4] = pal[ q[ 4] | color];
if (q[ 5] != 15 && ((sx + 5) >= 0) && ((sx + 5)<320)) p[ 5] = pal[ q[ 5] | color];
if (q[ 6] != 15 && ((sx + 6) >= 0) && ((sx + 6)<320)) p[ 6] = pal[ q[ 6] | color];
if (q[ 7] != 15 && ((sx + 7) >= 0) && ((sx + 7)<320)) p[ 7] = pal[ q[ 7] | color];
if (q[ 8] != 15 && ((sx + 8) >= 0) && ((sx + 8)<320)) p[ 8] = pal[ q[ 8] | color];
if (q[ 9] != 15 && ((sx + 9) >= 0) && ((sx + 9)<320)) p[ 9] = pal[ q[ 9] | color];
if (q[10] != 15 && ((sx + 10) >= 0) && ((sx + 10)<320)) p[10] = pal[ q[10] | color];
if (q[11] != 15 && ((sx + 11) >= 0) && ((sx + 11)<320)) p[11] = pal[ q[11] | color];
if (q[12] != 15 && ((sx + 12) >= 0) && ((sx + 12)<320)) p[12] = pal[ q[12] | color];
if (q[13] != 15 && ((sx + 13) >= 0) && ((sx + 13)<320)) p[13] = pal[ q[13] | color];
if (q[14] != 15 && ((sx + 14) >= 0) && ((sx + 14)<320)) p[14] = pal[ q[14] | color];
if (q[15] != 15 && ((sx + 15) >= 0) && ((sx + 15)<320)) p[15] = pal[ q[15] | color];
}
p -= 320;
q += 16;
}
}
} else {
if (flipx) {
for (int i=0;i<16;i++) {
if (((sy+i)>=0) && ((sy+i)<224)) {
if (q[ 0] != 15 && ((sx + 15) >= 0) && ((sx + 15)<320)) p[15] = pal[ q[ 0] | color];
if (q[ 1] != 15 && ((sx + 14) >= 0) && ((sx + 14)<320)) p[14] = pal[ q[ 1] | color];
if (q[ 2] != 15 && ((sx + 13) >= 0) && ((sx + 13)<320)) p[13] = pal[ q[ 2] | color];
if (q[ 3] != 15 && ((sx + 12) >= 0) && ((sx + 12)<320)) p[12] = pal[ q[ 3] | color];
if (q[ 4] != 15 && ((sx + 11) >= 0) && ((sx + 11)<320)) p[11] = pal[ q[ 4] | color];
if (q[ 5] != 15 && ((sx + 10) >= 0) && ((sx + 10)<320)) p[10] = pal[ q[ 5] | color];
if (q[ 6] != 15 && ((sx + 9) >= 0) && ((sx + 9)<320)) p[ 9] = pal[ q[ 6] | color];
if (q[ 7] != 15 && ((sx + 8) >= 0) && ((sx + 8)<320)) p[ 8] = pal[ q[ 7] | color];
if (q[ 8] != 15 && ((sx + 7) >= 0) && ((sx + 7)<320)) p[ 7] = pal[ q[ 8] | color];
if (q[ 9] != 15 && ((sx + 6) >= 0) && ((sx + 6)<320)) p[ 6] = pal[ q[ 9] | color];
if (q[10] != 15 && ((sx + 5) >= 0) && ((sx + 5)<320)) p[ 5] = pal[ q[10] | color];
if (q[11] != 15 && ((sx + 4) >= 0) && ((sx + 4)<320)) p[ 4] = pal[ q[11] | color];
if (q[12] != 15 && ((sx + 3) >= 0) && ((sx + 3)<320)) p[ 3] = pal[ q[12] | color];
if (q[13] != 15 && ((sx + 2) >= 0) && ((sx + 2)<320)) p[ 2] = pal[ q[13] | color];
if (q[14] != 15 && ((sx + 1) >= 0) && ((sx + 1)<320)) p[ 1] = pal[ q[14] | color];
if (q[15] != 15 && ((sx + 0) >= 0) && ((sx + 0)<320)) p[ 0] = pal[ q[15] | color];
}
p += 320;
q += 16;
}
} else {
for (int i=0;i<16;i++) {
if (((sy+i)>=0) && ((sy+i)<224)) {
if (q[ 0] != 15 && ((sx + 0) >= 0) && ((sx + 0)<320)) p[ 0] = pal[ q[ 0] | color];
if (q[ 1] != 15 && ((sx + 1) >= 0) && ((sx + 1)<320)) p[ 1] = pal[ q[ 1] | color];
if (q[ 2] != 15 && ((sx + 2) >= 0) && ((sx + 2)<320)) p[ 2] = pal[ q[ 2] | color];
if (q[ 3] != 15 && ((sx + 3) >= 0) && ((sx + 3)<320)) p[ 3] = pal[ q[ 3] | color];
if (q[ 4] != 15 && ((sx + 4) >= 0) && ((sx + 4)<320)) p[ 4] = pal[ q[ 4] | color];
if (q[ 5] != 15 && ((sx + 5) >= 0) && ((sx + 5)<320)) p[ 5] = pal[ q[ 5] | color];
if (q[ 6] != 15 && ((sx + 6) >= 0) && ((sx + 6)<320)) p[ 6] = pal[ q[ 6] | color];
if (q[ 7] != 15 && ((sx + 7) >= 0) && ((sx + 7)<320)) p[ 7] = pal[ q[ 7] | color];
if (q[ 8] != 15 && ((sx + 8) >= 0) && ((sx + 8)<320)) p[ 8] = pal[ q[ 8] | color];
if (q[ 9] != 15 && ((sx + 9) >= 0) && ((sx + 9)<320)) p[ 9] = pal[ q[ 9] | color];
if (q[10] != 15 && ((sx + 10) >= 0) && ((sx + 10)<320)) p[10] = pal[ q[10] | color];
if (q[11] != 15 && ((sx + 11) >= 0) && ((sx + 11)<320)) p[11] = pal[ q[11] | color];
if (q[12] != 15 && ((sx + 12) >= 0) && ((sx + 12)<320)) p[12] = pal[ q[12] | color];
if (q[13] != 15 && ((sx + 13) >= 0) && ((sx + 13)<320)) p[13] = pal[ q[13] | color];
if (q[14] != 15 && ((sx + 14) >= 0) && ((sx + 14)<320)) p[14] = pal[ q[14] | color];
if (q[15] != 15 && ((sx + 15) >= 0) && ((sx + 15)<320)) p[15] = pal[ q[15] | color];
}
p += 320;
q += 16;
}
}
}
return;
}
if (flipy) {
p += 320 * 15;
if (flipx) {
for (int i=0;i<16;i++) {
if (q[ 0] != 15) p[15] = pal[ q[ 0] | color];
if (q[ 1] != 15) p[14] = pal[ q[ 1] | color];
if (q[ 2] != 15) p[13] = pal[ q[ 2] | color];
if (q[ 3] != 15) p[12] = pal[ q[ 3] | color];
if (q[ 4] != 15) p[11] = pal[ q[ 4] | color];
if (q[ 5] != 15) p[10] = pal[ q[ 5] | color];
if (q[ 6] != 15) p[ 9] = pal[ q[ 6] | color];
if (q[ 7] != 15) p[ 8] = pal[ q[ 7] | color];
if (q[ 8] != 15) p[ 7] = pal[ q[ 8] | color];
if (q[ 9] != 15) p[ 6] = pal[ q[ 9] | color];
if (q[10] != 15) p[ 5] = pal[ q[10] | color];
if (q[11] != 15) p[ 4] = pal[ q[11] | color];
if (q[12] != 15) p[ 3] = pal[ q[12] | color];
if (q[13] != 15) p[ 2] = pal[ q[13] | color];
if (q[14] != 15) p[ 1] = pal[ q[14] | color];
if (q[15] != 15) p[ 0] = pal[ q[15] | color];
p -= 320;
q += 16;
}
} else {
for (int i=0;i<16;i++) {
if (q[ 0] != 15) p[ 0] = pal[ q[ 0] | color];
if (q[ 1] != 15) p[ 1] = pal[ q[ 1] | color];
if (q[ 2] != 15) p[ 2] = pal[ q[ 2] | color];
if (q[ 3] != 15) p[ 3] = pal[ q[ 3] | color];
if (q[ 4] != 15) p[ 4] = pal[ q[ 4] | color];
if (q[ 5] != 15) p[ 5] = pal[ q[ 5] | color];
if (q[ 6] != 15) p[ 6] = pal[ q[ 6] | color];
if (q[ 7] != 15) p[ 7] = pal[ q[ 7] | color];
if (q[ 8] != 15) p[ 8] = pal[ q[ 8] | color];
if (q[ 9] != 15) p[ 9] = pal[ q[ 9] | color];
if (q[10] != 15) p[10] = pal[ q[10] | color];
if (q[11] != 15) p[11] = pal[ q[11] | color];
if (q[12] != 15) p[12] = pal[ q[12] | color];
if (q[13] != 15) p[13] = pal[ q[13] | color];
if (q[14] != 15) p[14] = pal[ q[14] | color];
if (q[15] != 15) p[15] = pal[ q[15] | color];
p -= 320;
q += 16;
}
}
} else {
if (flipx) {
for (int i=0;i<16;i++) {
if (q[ 0] != 15) p[15] = pal[ q[ 0] | color];
if (q[ 1] != 15) p[14] = pal[ q[ 1] | color];
if (q[ 2] != 15) p[13] = pal[ q[ 2] | color];
if (q[ 3] != 15) p[12] = pal[ q[ 3] | color];
if (q[ 4] != 15) p[11] = pal[ q[ 4] | color];
if (q[ 5] != 15) p[10] = pal[ q[ 5] | color];
if (q[ 6] != 15) p[ 9] = pal[ q[ 6] | color];
if (q[ 7] != 15) p[ 8] = pal[ q[ 7] | color];
if (q[ 8] != 15) p[ 7] = pal[ q[ 8] | color];
if (q[ 9] != 15) p[ 6] = pal[ q[ 9] | color];
if (q[10] != 15) p[ 5] = pal[ q[10] | color];
if (q[11] != 15) p[ 4] = pal[ q[11] | color];
if (q[12] != 15) p[ 3] = pal[ q[12] | color];
if (q[13] != 15) p[ 2] = pal[ q[13] | color];
if (q[14] != 15) p[ 1] = pal[ q[14] | color];
if (q[15] != 15) p[ 0] = pal[ q[15] | color];
p += 320;
q += 16;
}
} else {
for (int i=0;i<16;i++) {
if (q[ 0] != 15) p[ 0] = pal[ q[ 0] | color];
if (q[ 1] != 15) p[ 1] = pal[ q[ 1] | color];
if (q[ 2] != 15) p[ 2] = pal[ q[ 2] | color];
if (q[ 3] != 15) p[ 3] = pal[ q[ 3] | color];
if (q[ 4] != 15) p[ 4] = pal[ q[ 4] | color];
if (q[ 5] != 15) p[ 5] = pal[ q[ 5] | color];
if (q[ 6] != 15) p[ 6] = pal[ q[ 6] | color];
if (q[ 7] != 15) p[ 7] = pal[ q[ 7] | color];
if (q[ 8] != 15) p[ 8] = pal[ q[ 8] | color];
if (q[ 9] != 15) p[ 9] = pal[ q[ 9] | color];
if (q[10] != 15) p[10] = pal[ q[10] | color];
if (q[11] != 15) p[11] = pal[ q[11] | color];
if (q[12] != 15) p[12] = pal[ q[12] | color];
if (q[13] != 15) p[13] = pal[ q[13] | color];
if (q[14] != 15) p[14] = pal[ q[14] | color];
if (q[15] != 15) p[15] = pal[ q[15] | color];
p += 320;
q += 16;
}
}
}
}
static void aerofgtb_drawsprites(int chip,int chip_disabled_pri)
{
int attr_start,base,first;
base = chip * 0x0200;
first = 4 * swapWord(RamSpr3[0x1fe + base]);
//for (attr_start = base + 0x0200-8;attr_start >= first + base;attr_start -= 4) {
for (attr_start = first + base; attr_start <= base + 0x0200-8; attr_start += 4) {
int map_start;
int ox,oy,x,y,xsize,ysize,zoomx,zoomy,flipx,flipy,color,pri;
// some other drivers still use this wrong table, they have to be upgraded
// int zoomtable[16] = { 0,7,14,20,25,30,34,38,42,46,49,52,54,57,59,61 };
if (!(swapWord(RamSpr3[attr_start + 2]) & 0x0080)) continue;
pri = swapWord(RamSpr3[attr_start + 2]) & 0x0010;
if ( chip_disabled_pri & !pri) continue;
if (!chip_disabled_pri & (pri>>4)) continue;
ox = swapWord(RamSpr3[attr_start + 1]) & 0x01ff;
xsize = (swapWord(RamSpr3[attr_start + 2]) & 0x0700) >> 8;
zoomx = (swapWord(RamSpr3[attr_start + 1]) & 0xf000) >> 12;
oy = swapWord(RamSpr3[attr_start + 0]) & 0x01ff;
ysize = (swapWord(RamSpr3[attr_start + 2]) & 0x7000) >> 12;
zoomy = (swapWord(RamSpr3[attr_start + 0]) & 0xf000) >> 12;
flipx = swapWord(RamSpr3[attr_start + 2]) & 0x0800;
flipy = swapWord(RamSpr3[attr_start + 2]) & 0x8000;
color = (swapWord(RamSpr3[attr_start + 2]) & 0x000f) << 4; // + 16 * spritepalettebank;
map_start = swapWord(RamSpr3[attr_start + 3]);
// aerofgt has this adjustment, but doing it here would break turbo force title screen
// ox += (xsize*zoomx+2)/4;
// oy += (ysize*zoomy+2)/4;
zoomx = 32 - zoomx;
zoomy = 32 - zoomy;
for (y = 0;y <= ysize;y++) {
int sx,sy;
if (flipy) sy = ((oy + zoomy * (ysize - y)/2 + 16) & 0x1ff) - 16 - 1;
else sy = ((oy + zoomy * y / 2 + 16) & 0x1ff) - 16 - 1;
for (x = 0;x <= xsize;x++) {
int code;
if (flipx) sx = ((ox + zoomx * (xsize - x) / 2 + 16) & 0x1ff) - 16 - 8;
else sx = ((ox + zoomx * x / 2 + 16) & 0x1ff) - 16 - 8;
if (chip == 0) code = swapWord(RamSpr1[map_start & RamSpr1SizeMask]);
else code = swapWord(RamSpr2[map_start & RamSpr2SizeMask]);
aerofgtb_pdrawgfxzoom(chip,code,color,flipx,flipy,sx,sy,zoomx << 11, zoomy << 11);
map_start++;
}
if (xsize == 2) map_start += 1;
if (xsize == 4) map_start += 3;
if (xsize == 5) map_start += 2;
if (xsize == 6) map_start += 1;
}
}
}
static int aerofgtbDraw()
{
// update palette
aerofgtPalUpdate();
aerofgtbTileBackground_1(RamBg1V, DeRomBg, RamCurPal);
aerofgtbTileBackground_2(RamBg2V, DeRomBg + 0x100000, RamCurPal + 256);
aerofgtb_drawsprites(0, 0);
aerofgtb_drawsprites(0,-1);
aerofgtb_drawsprites(1, 0);
aerofgtb_drawsprites(1,-1);
return 0;
}
static int aerofgtbFrame()
{
if (DrvReset) DrvDoReset();
// Compile digital inputs
DrvInput[0] = 0x00; // Joy1
DrvInput[1] = 0x00; // Joy2
DrvInput[2] = 0x00; // Buttons
for (int i = 0; i < 8; i++) {
DrvInput[0] |= (DrvJoy1[i] & 1) << i;
DrvInput[1] |= (DrvJoy2[i] & 1) << i;
DrvInput[2] |= (DrvButton[i] & 1) << i;
}
SekNewFrame();
ZetNewFrame();
nCyclesTotal[0] = (int)((long long)10000000 * nBurnCPUSpeedAdjust / (0x0100 * 60));
nCyclesTotal[1] = (int)(4000000 / 60);
SekOpen(0);
ZetOpen(0);
SekRun(nCyclesTotal[0]);
SekSetIRQLine(1, SEK_IRQSTATUS_AUTO);
BurnTimerEndFrame(nCyclesTotal[1]);
BurnYM2610Update(pBurnSoundOut, nBurnSoundLen);
ZetClose();
SekClose();
if (pBurnDraw) aerofgtbDraw();
return 0;
}
struct BurnDriver BurnDrvAerofgtb = {
"aerofgtb", "aerofgt", NULL, "1992",
"Aero Fighters (Turbo Force hardware set 1)\0", NULL, "Video System Co.", "Video System",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL | BDF_16BIT_ONLY, 2, HARDWARE_MISC_MISC,
NULL, aerofgtbRomInfo, aerofgtbRomName, aerofgtInputInfo, aerofgtbDIPInfo,
aerofgtbInit,DrvExit,aerofgtbFrame,aerofgtbDraw,DrvScan,
NULL,224,320,3,4
};
struct BurnDriver BurnDrvAerofgtc = {
"aerofgtc", "aerofgt", NULL, "1992",
"Aero Fighters (Turbo Force hardware set 2)\0", NULL, "Video System Co.", "Video System",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL | BDF_16BIT_ONLY, 2, HARDWARE_MISC_MISC,
NULL, aerofgtcRomInfo, aerofgtcRomName, aerofgtInputInfo, aerofgtbDIPInfo,
aerofgtbInit,DrvExit,aerofgtbFrame,aerofgtbDraw,DrvScan,
NULL,224,320,3,4
};
struct BurnDriver BurnDrvSonicwi = {
"sonicwi", "aerofgt", NULL, "1992",
"Sonic Wings (Japan)\0", NULL, "Video System Co.", "Video System",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL | BDF_16BIT_ONLY, 2, HARDWARE_MISC_MISC,
NULL, sonicwiRomInfo, sonicwiRomName, aerofgtInputInfo, sonicwiDIPInfo,
aerofgtbInit,DrvExit,aerofgtbFrame,aerofgtbDraw,DrvScan,
NULL,224,320,3,4
};
| [
"[email protected]"
] | [
[
[
1,
4615
]
]
] |
f7703928b4a92da6c7e1e5f075200fc5514e8427 | 3bfe835203f793ee00bdf261c26992b1efea69ed | /spring08/cs350/A3/lib/framework.cpp | da3e3078356936b08908b9f34134d7fdd2d3400f | [] | no_license | yxrkt/DigiPen | 0bdc1ed3ee06e308b4942a0cf9de70831c65a3d3 | e1bb773d15f63c88ab60798f74b2e424bcc80981 | refs/heads/master | 2020-06-04T20:16:05.727685 | 2009-11-18T00:26:56 | 2009-11-18T00:26:56 | 814,145 | 1 | 3 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 5,757 | cpp | ///////////////////////////////////////////////////////////////////////
// $Id: framework.cpp 1210 2008-02-05 17:45:17Z gherron $
//
// Provides the framework for graphics projects. Opens a window and
// hooks up all GUI callbacks.
//
// Gary Herron
//
// Copyright © 2007 DigiPen Institute of Technology
////////////////////////////////////////////////////////////////////////
#include "framework.h"
#include "geomlib.h"
#include "transformation.h"
#include "scenelib.h"
// Some globals used by the GUI framework.
int mouseX, mouseY;
bool leftDown = false;
bool middleDown = false;
bool rightDown = false;
float spin = -135.0;
float tilt = -60.0;
float translatex = 0.0;
float translatey = 0.0;
float zoom = 0.25;
Scene scene;
////////////////////////////////////////////////////////////////////////
// Sets the scene's viewing and projection matrices AND their inverses
// according to the parameters controlled by mouse interactions.
void BuildProjection(Scene& scene, int width, int height)
{
double sx, sy;
if(width < height) {
sx = 0.4f;
sy = sx * height / width; }
else {
sy = 0.4f;
sx = sy * width / height; }
scene.projection.Identity();
scene.projection.Perspective(sx, sy, 0.1, 100.0);
scene.projection.ComputeInverse();
scene.viewing.Identity();
scene.viewing.Translate(0.0, 0.0, -3.0);
scene.viewing.Translate(0.01*translatex, -0.01*translatey, 0.25*zoom);
scene.viewing.RotateX(tilt);
scene.viewing.RotateZ(spin);
scene.viewing.ComputeInverse();
}
////////////////////////////////////////////////////////////////////////
// Displays the current scene as described by the VertexTable vertices
// and the PolygonTable polygons and transformed by values spin and
// tilt.
void ReDrawScene()
{
int viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);
int width = viewport[2];
int height = viewport[3];
glClearColor(1.0,1.0, 1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, width, 0, height, 0, -1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
BuildProjection(scene, width, height);
glDisable(GL_DEPTH_TEST);
DrawScene(scene, width, height);
glutSwapBuffers();
}
void Update()
{
ReDrawScene();
glutIdleFunc(NULL);
}
////////////////////////////////////////////////////////////////////////
// Called by GLut when the window size is changed.
void ReshapeWindow(int w, int h)
{
if (w && h) {
glViewport(0, 0, w, h); }
}
////////////////////////////////////////////////////////////////////////
// Called by GLut when there are keyboard messages.
void KeyboardInput(unsigned char key, int, int)
{
switch(key) {
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
sceneID = key - '0';
scene.Clear();
CreateScene(scene);
PreprocessScene(scene);
glutIdleFunc(&Update);
break;
case 'g':
scene.UseOpenGLRendering = !scene.UseOpenGLRendering;
glutIdleFunc(&Update);
break;
case 'a':
scene.UseAntiAliasing = !scene.UseAntiAliasing;
glutIdleFunc(&Update);
break;
case 27: // Escape key
case 'q':
exit(EXIT_SUCCESS);
}
}
////////////////////////////////////////////////////////////////////////
// Called by GLut when a mouse button changes state.
// button: 0 (GL_LEFT_BUTTON) for a left button click
// 1 (GL_MIDDLE_BUTTON) for a wheel click
// 2 (GL_RIGHT_BUTTON) for a right button click
// 3 for a wheel roll up
// 4 for a wheel roll down
//
// state: 0 button went down
// 1 button went up
//
// x,y: The position of the mouse.
//
// Note: a scroll wheel action will generate two calls here, the first
// with state == 0 and the second with state == 1, and both with
// button equal to 3 or 4 depending on the direction of scroll.
void MouseButton(int button, int state, int x, int y)
{
if (button == GLUT_LEFT_BUTTON)
leftDown = (state == GLUT_DOWN);
if (button == GLUT_MIDDLE_BUTTON)
middleDown = (state == GLUT_DOWN);
if (button == GLUT_RIGHT_BUTTON)
rightDown = (state == GLUT_DOWN);
if (button == 3)
zoom += 1;
if (button == 4)
zoom -= 1;
mouseX = x;
mouseY = y;
scene.UseFastRendering = leftDown || middleDown || rightDown;
glutIdleFunc(&Update);
}
////////////////////////////////////////////////////////////////////////
// Called by GLut when a mouse moves (while a button is down)
void MouseMotion(int x, int y)
{
// This uses changes in x mouse position to spin the model around
// its z axis, and changes in the y axis to tilt the model forward
// or backward.
if(leftDown) {
spin += (x - mouseX);
tilt += (y - mouseY); }
if(rightDown) {
translatex += (x - mouseX);
translatey += (y - mouseY); }
// Record this position
mouseX = x;
mouseY = y;
// Draw the scene, transformed by the new spin and tilt values.
glutIdleFunc(&Update);
}
////////////////////////////////////////////////////////////////////////
// Called once by the main program to do the OpenGL/GLut setup and
// then enter the interactive loop.
int main(int argc, char** argv)
{
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(200, 200);//480 480
glutInit(&argc, argv);
glutCreateWindow("Class Framework");
glutDisplayFunc(&ReDrawScene);
glutReshapeFunc(&ReshapeWindow);
glutKeyboardFunc(&KeyboardInput);
glutMouseFunc(&MouseButton);
glutMotionFunc(&MouseMotion);
glutIdleFunc(&Update);
CreateScene(scene);
PreprocessScene(scene);
// This function enters an event loop, and never returns.
glutMainLoop();
}
| [
"[email protected]"
] | [
[
[
1,
221
]
]
] |
47dc8469ac09de86cf195d5ffc9f6a226c780a35 | 0f8559dad8e89d112362f9770a4551149d4e738f | /Wall_Destruction/Havok/Source/Common/Base/Math/SweptTransform/hkSweptTransformUtil.inl | eca5a8c35cbf7573c10bc53f809a900f7c774d56 | [] | no_license | TheProjecter/olafurabertaymsc | 9360ad4c988d921e55b8cef9b8dcf1959e92d814 | 456d4d87699342c5459534a7992f04669e75d2e1 | refs/heads/master | 2021-01-10T15:15:49.289873 | 2010-09-20T12:58:48 | 2010-09-20T12:58:48 | 45,933,002 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,625 | inl | /*
*
* 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-2009 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement.
*
*/
void HK_CALL hkSweptTransformUtil::_lerp2( const hkSweptTransform& sweptTrans, hkReal t, hkQuaternion& quatOut )
{
hkVector4 rot0 = sweptTrans.m_rotation0.m_vec;
hkVector4 rot1 = sweptTrans.m_rotation1.m_vec;
{
quatOut.m_vec.setAdd4( rot0, rot1 );
#ifdef HK_PS2
quatOut.normalize();
#else
hkReal len2 = quatOut.m_vec.lengthSquared4();
hkReal r = 0.75f - 0.125f * len2;
r = r * (1.5f - 0.5f * len2 * r * r);
quatOut.m_vec.mul4(r);
#endif
}
if ( t < 0.5f )
{
quatOut.m_vec.setInterpolate4( rot0, quatOut.m_vec, 2.0f * t);
}
else
{
quatOut.m_vec.setInterpolate4( quatOut.m_vec, rot1, 2.0f * t - 1.0f);
}
quatOut.m_vec.normalize4();
}
void HK_CALL hkSweptTransformUtil::_lerp2( const hkSweptTransform& sweptTrans, hkReal t, hkTransform& transformOut )
{
hkQuaternion qt;
_lerp2( sweptTrans, t, qt );
transformOut.setRotation( qt );
transformOut.getTranslation().setInterpolate4( sweptTrans.m_centerOfMass0, sweptTrans.m_centerOfMass1, t);
hkVector4 centerShift;
centerShift._setRotatedDir( transformOut.getRotation(), sweptTrans.m_centerOfMassLocal);
transformOut.getTranslation().sub4( centerShift );
}
void HK_CALL hkSweptTransformUtil::calcTransAtT0( const hkSweptTransform& sweptTrans, hkTransform& transformOut )
{
const hkQuaternion& qt = sweptTrans.m_rotation0;
transformOut.setRotation( qt );
hkVector4 centerShift;
centerShift._setRotatedDir( transformOut.getRotation(), sweptTrans.m_centerOfMassLocal);
transformOut.getTranslation().setSub4( sweptTrans.m_centerOfMass0, centerShift );
}
void HK_CALL hkSweptTransformUtil::calcTransAtT1( const hkSweptTransform& sweptTrans, hkTransform& transformOut )
{
const hkQuaternion& qt = sweptTrans.m_rotation1;
transformOut.setRotation( qt );
hkVector4 centerShift;
centerShift._setRotatedDir( transformOut.getRotation(), sweptTrans.m_centerOfMassLocal);
transformOut.getTranslation().setSub4( sweptTrans.m_centerOfMass1, centerShift );
}
void HK_CALL hkSweptTransformUtil::_clipVelocities( const hkMotionState& motionState, hkVector4& linearVelocity, hkVector4& angularVelocity )
{
hkReal linVelSq = linearVelocity.lengthSquared3();
hkReal angVelSq = angularVelocity.lengthSquared3();
const hkReal maxLinear = motionState.m_maxLinearVelocity * motionState.m_maxLinearVelocity;
const hkReal maxAngular = motionState.m_maxAngularVelocity * motionState.m_maxAngularVelocity;
if ( (linVelSq > maxLinear) || (linVelSq!=linVelSq) )
{
hkReal f = motionState.m_maxLinearVelocity * hkMath::sqrtInverse( linVelSq );
linearVelocity.mul4( f );
if ( linVelSq!=linVelSq )
{
linearVelocity = hkTransform::getIdentity().getColumn(0);
HK_WARN(0xf0124242, "Nan velocity detected, something is seriously wrong (probably bad inertia tensors)");
}
}
if ( (angVelSq > maxAngular) || ( angVelSq != angVelSq ))
{
hkReal f = motionState.m_maxAngularVelocity * hkMath::sqrtInverse( angVelSq );
angularVelocity.mul4( f );
if ( angVelSq!=angVelSq )
{
angularVelocity = hkTransform::getIdentity().getColumn(0);
HK_WARN(0xf0143243, "Nan velocity detected, something is seriously wrong (probably bad inertia tensors ");
}
}
}
void HK_CALL hkSweptTransformUtil::_stepMotionState( const hkStepInfo& info,
hkVector4& linearVelocity, hkVector4& angularVelocity,
hkMotionState& motionState )
{
#ifdef HK_DEBUG
{
if ( motionState.getSweptTransform().getInvDeltaTime() != 0.0f)
{
hkReal motionEndTime = motionState.getSweptTransform().getBaseTime() + 1.0f / motionState.getSweptTransform().getInvDeltaTime();
HK_ASSERT(0xf0f0083, hkMath::equal(info.m_startTime, motionEndTime ) ) ;
}
}
#endif
// check for nans in velocities
// fix nans to 100
{
hkVector4 absLin; absLin.setAbs4( linearVelocity );
hkVector4 absAng; absAng.setAbs4( angularVelocity );
hkVector4 maxVel; maxVel.getQuad() = _stepMotionStateMaxVelf;
int mask = absLin.compareLessThan4( maxVel ).getMask() & absAng.compareLessThan4( maxVel ).getMask();
mask &= linearVelocity.compareEqual4( linearVelocity ).getMask() & angularVelocity.compareEqual4( angularVelocity ).getMask();
if ( (mask & hkVector4Comparison::MASK_XYZ) != hkVector4Comparison::MASK_XYZ )
{
// velocity to a 'random' non zero velocity
HK_WARN(0xf0123244, "Nan velocity or velocity > 1e6f detected, something is seriously wrong (probably bad inertia tensors ");
linearVelocity = hkTransform::getIdentity().getColumn(0);
angularVelocity = hkTransform::getIdentity().getColumn(0);
}
}
motionState.getSweptTransform().m_centerOfMass0 = motionState.getSweptTransform().m_centerOfMass1;
motionState.getSweptTransform().m_centerOfMass0(3) = info.m_startTime;
hkReal linVelSq = linearVelocity.lengthSquared3();
if ( linVelSq > motionState.m_maxLinearVelocity * motionState.m_maxLinearVelocity )
{
//HK_WARN_ONCE(0xf0327683, "Object exceeding maximum velocity, velocity clipped" );
hkReal f = motionState.m_maxLinearVelocity * hkMath::sqrtInverse( linVelSq );
linearVelocity.mul4( f );
}
motionState.getSweptTransform().m_centerOfMass1.addMul4(info.m_deltaTime.val(), linearVelocity);
motionState.getSweptTransform().m_centerOfMass1(3) = info.m_invDeltaTime;
hkQuaternion newRotation = motionState.getSweptTransform().m_rotation1;
motionState.getSweptTransform().m_rotation0 = newRotation;
//
// Calculate a new rotation, the fabs angle and angle squared
//
hkReal angle;
{
hkQuaternion dq; dq.m_vec.setMul4( info.m_deltaTime * 0.5f, angularVelocity );
const hkReal pi = HK_REAL_PI;
hkReal dx2 = hkReal(dq.m_vec.lengthSquared3()) * (4.0f/ (pi*pi));
// do a little sin(alpha * 0.5f) approximation
const hkReal a = 0.822948f;
const hkReal b = 0.130529f;
const hkReal c = 0.044408f;
const hkReal maxAnglePerStep = hkMath::min2( 0.9f, info.m_deltaTime.val() * motionState.m_maxAngularVelocity );
// clipping angular velocity to be between [0, PI*0.9/dt]
// info: was "<", is "<=" -- works ok for zero dt now.
if ( dx2 <= maxAnglePerStep * maxAnglePerStep )
{
const hkReal dx4 = dx2 * dx2;
const hkReal w = 1.0f - a*dx2 - b*dx4 - c*dx2*dx4;
dq.m_vec(3) = w;
}
else
{
hkReal factor = maxAnglePerStep * hkMath::sqrtInverse( dx2 );
angularVelocity.mul4( factor );
dq.m_vec.mul4( factor );
dx2 = maxAnglePerStep*maxAnglePerStep;
const hkReal dx4 = dx2 * dx2;
const hkReal w = 1.0f - a*dx2 - b*dx4 - c*dx2*dx4;
dq.m_vec(3) = w;
}
newRotation.setMul( dq, newRotation );
newRotation.normalize();
motionState.m_deltaAngle.setAdd4( dq.m_vec, dq.m_vec );
angle = hkMath::sqrt(dx2) * pi;
motionState.m_deltaAngle(3) = angle;
}
motionState.getSweptTransform().m_rotation1 = newRotation;
calcTransAtT1( motionState.getSweptTransform(), motionState.getTransform());
}
void HK_CALL hkSweptTransformUtil::deactivate( hkMotionState& ms )
{
hkSweptTransform& sweptTransform = ms.getSweptTransform();
ms.m_deltaAngle.setZero4();
sweptTransform.m_rotation0 = sweptTransform.m_rotation1;
sweptTransform.m_centerOfMass0 = sweptTransform.m_centerOfMass1;
sweptTransform.m_centerOfMass1(3) = 0.0f;
}
//void HK_CALL hkSweptTransformUtil::calcTimInfo( const hkMotionState& ms0, const hkMotionState& ms1, hkVector4& timOut)
//{
// HK_ASSERT2(0xad44d321, st0.getInvDeltaTime() == st1.getInvDeltaTime(), "Internal error: hkSweptTransform's must correspond to the same deltaTime in order to use void HK_CALL hkSweptTransformUtil::calcTimInfo( const hkMotionState& ms0, const hkMotionState& ms1, hkVector4& timOut)");
//
// const hkSweptTransform& st0 = ms0.getSweptTransform();
// const hkSweptTransform& st1 = ms1.getSweptTransform();
//
// hkVector4 diff0; diff0.setSub4( st0.m_centerOfMass0, st0.m_centerOfMass1 );
// hkVector4 diff1; diff1.setSub4( st1.m_centerOfMass1, st1.m_centerOfMass0 );
//
// timOut.setAdd4( diff0, diff1 );
//
// timOut(3) = ms0.m_deltaAngle(3) * ms0.m_objectRadius + ms1.m_deltaAngle(3) * ms1.m_objectRadius;
//
//}
void HK_CALL hkSweptTransformUtil::calcTimInfo( const hkMotionState& ms0, const hkMotionState& ms1, hkReal deltaTime, hkVector4& timOut)
{
const hkSweptTransform& st0 = ms0.getSweptTransform();
const hkSweptTransform& st1 = ms1.getSweptTransform();
hkVector4 diff0; diff0.setSub4( st0.m_centerOfMass0, st0.m_centerOfMass1 );
hkVector4 diff1; diff1.setSub4( st1.m_centerOfMass1, st1.m_centerOfMass0 );
hkReal f0 = deltaTime * st0.getInvDeltaTime();
hkReal f1 = deltaTime * st1.getInvDeltaTime();
HK_ASSERT2(0xad56daaa, f0 <= 1.01f && f1 <= 1.01f, "Internal error: input for TIM calculation may be corrupted.");
timOut.setMul4( f0, diff0 );
timOut.addMul4( f1, diff1 );
timOut(3) = f0 * ms0.m_deltaAngle(3) * ms0.m_objectRadius + f1 * ms1.m_deltaAngle(3) * ms1.m_objectRadius;
// we don't project angular velocity just to keep it simple ( no cross products)
}
// Calculates angular distance (angVelocity * dt) travelled by the bodies.
void HK_CALL hkSweptTransformUtil::calcAngularTimInfo( const hkMotionState& ms0, const hkMotionState& ms1, hkReal deltaTime, hkVector4* HK_RESTRICT deltaAngleOut0, hkVector4* HK_RESTRICT deltaAngleOut1)
{
const hkSweptTransform& st0 = ms0.getSweptTransform();
const hkSweptTransform& st1 = ms1.getSweptTransform();
hkReal f0 = deltaTime * st0.getInvDeltaTime();
hkReal f1 = deltaTime * st1.getInvDeltaTime();
hkVector4 ang0; ang0.setMul4( f0, ms0.m_deltaAngle );
hkVector4 ang1; ang1.setMul4( f1, ms1.m_deltaAngle );
deltaAngleOut0[0] = ang0;
deltaAngleOut1[0] = ang1;
}
void HK_CALL hkSweptTransformUtil::calcCenterOfMassAt( const hkMotionState& ms, hkTime t, hkVector4& centerOut )
{
hkReal iv = ms.getSweptTransform().getInterpolationValue( t );
centerOut.setInterpolate4( ms.getSweptTransform().m_centerOfMass0, ms.getSweptTransform().m_centerOfMass1, iv );
}
void HK_CALL hkSweptTransformUtil::getVelocity( const hkMotionState& ms, hkVector4& linearVelOut, hkVector4& angularVelOut )
{
linearVelOut.setSub4 (ms.getSweptTransform().m_centerOfMass1, ms.getSweptTransform().m_centerOfMass0);
linearVelOut.mul4( ms.getSweptTransform().getInvDeltaTime() );
angularVelOut.setMul4( ms.getSweptTransform().getInvDeltaTime(), ms.m_deltaAngle );
}
/*
* Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20091222)
*
* Confidential Information of Havok. (C) Copyright 1999-2009
* 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.
*
*/
| [
"[email protected]"
] | [
[
[
1,
298
]
]
] |
3cdc3f5733bdae6da5b372fea7d68b71f71d1cc2 | b999131a99dbbe85b256ed64700fc8651f69eb98 | /VNE_SOURCE/vne_engine/CameraControl.cpp | 54635c87f2e375965b77e3fad095c584f323e5ec | [] | no_license | liukan12/vne | 71ba2a63ade36b638107f2800ae6d9a3b3b56d52 | e896cc57af75c72ee5b52530ee9d9d1e7cfe73be | refs/heads/master | 2020-12-24T20:15:21.148998 | 2008-08-01T05:55:10 | 2008-08-01T05:55:10 | 56,172,273 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,567 | cpp | #include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <iostream>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include <math.h>
//#include "VNEWorld.h"
//#include "VNEObject.h"
#include "CameraControl.h"
#include <valarray>
CameraControl::CameraControl( )//VNEWorld* aWorld)
{
atx = 0.0;
aty = 0.0;
atz = 0.0;
// world = aWorld;
this->bIsAttached = false; // am I attached to an object now?
}
CameraControl::~CameraControl()
{
}
CameraControl::CameraControl(double ex, double ey, double ez, double minz, double maxz)
{
eyex = ex;
eyey = ey;
eyez = ez;
atx = 0.0;
aty = 0.0;
atz = 0.0;
initx = ex;
inity = ey;
initz = ez;
bIsAttached = false;
zmin = minz;
zmax = maxz;
}
/*
void CameraControl::AttachToObject( VNEObject* obj )
{
this->targetObj = obj;
bIsAttached = true;
UpdateAttachedCamera();
}*/
void CameraControl::ResetPosition( )
{
eyex = this->initx;
eyey = this->inity;
eyez = this->initz;
atx = 0.0;
aty = 0.0;
atz = 0.0;
if( this->bIsAttached )
this->Detach();
ResizeCallbackHandler( this->iWindowW, this->iWindowH );
}
void CameraControl::UpdateAttachedCamera()
{
if( this->bIsAttached ) {
this->ResizeCallbackHandler(this->iWindowW, this->iWindowH);
}
else;
this->ResizeCallbackHandler(this->iWindowW, this->iWindowH);
}
void CameraControl::TranslateTo( double x, double y, double z )
{
eyex = x;
eyey = y;
eyez = z;
ResizeCallbackHandler( this->iWindowW, this->iWindowH );
}
void CameraControl::TranslateBy( double dx, double dy, double dz)
{
this->eyex += dx;
this->eyey += dy;
this->eyez += dz;
this->ResizeCallbackHandler(iWindowW,iWindowH);
}
void CameraControl::PointAt( double x, double y, double z )
{
atx = x;
aty = y;
atz = z;
ResizeCallbackHandler( this->iWindowW, this->iWindowH );
}
void CameraControl::ResizeCallbackHandler(int w, int h)
{
if( w == -1 )
{
w = iWindowW;
h = iWindowH;
}
iWindowW = w;
iWindowH = h;
glViewport(0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, (GLfloat) w / (GLfloat) h, 1.0, abs(zmax-zmin));
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(eyex, eyey, eyez, atx, aty, atz, 0.0, 1.0, 0.0);
}
void CameraControl::ModelView()
{
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(eyex, eyey, eyez, atx, aty, atz, 0.0, 1.0, 0.0);
}
void CameraControl::GetWH( int* w, int* h )
{
*w = iWindowW;
*h = iWindowH;
} | [
"karasevpa@60124b6e-824b-0410-a204-ab2e215a433f"
] | [
[
[
1,
128
]
]
] |
35a372af724b04ba4e02c962328922c87a18fb73 | cbb40e1d71bc4585ad3a58d32024090901487b76 | /trunk/tokamaksrc/src/boxcylinder.cpp | c13eac35639f50ed4603ec6192032734a1ce2cc7 | [] | no_license | huangleon/tokamak | c0dee7b8182ced6b514b37cf9c526934839c6c2e | 0218e4d17dcf93b7ab476e3e8bd4026f390f82ca | refs/heads/master | 2021-01-10T10:11:42.617076 | 2011-08-22T02:32:16 | 2011-08-22T02:32:16 | 50,816,154 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,386 | cpp | /*************************************************************************
* *
* Tokamak Physics Engine, Copyright (C) 2002-2007 David Lam. *
* All rights reserved. Email: [email protected] *
* Web: www.tokamakphysics.com *
* *
* 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 files *
* LICENSE.TXT for more details. *
* *
*************************************************************************/
#include "tokamak.h"
#include "containers.h"
#include "scenery.h"
#include "collision.h"
#include "collision2.h"
#include "constraint.h"
#include "rigidbody.h"
#include <assert.h>
#include <stdio.h>
namespace Tokamak {
neBool BoxTestParam::CylinderFaceTest(ConvexTestResult & res, TConvex & cylinderB, neT3 & transB, s32 whichFace)
{
neV3 diff = trans->pos - transB.pos;
neV3 dir = trans->rot[whichFace];
f32 dot = dir.Dot(diff);
if (dot > 0.0f)
{
dot *= -1.0f;
}
else
{
dir *= -1.0f;
}
f32 depth = dot + convex->BoxSize(whichFace);
neV3 contactPoint = transB.pos;
neV3 tmp = transB.rot[1] * cylinderB.CylinderHalfHeight();
dot = tmp.Dot(dir);
if (dot > 0.0f)
{
depth += dot;
contactPoint += tmp;
}
else
{
depth -= dot;
contactPoint -= tmp;
}
depth += cylinderB.CylinderRadius();
if (depth <= 0.0f)
return false;
if (depth >= res.depth)
return true;
contactPoint += dir * cylinderB.CylinderRadius();
neV3 project = contactPoint - dir * depth;
s32 otherAxis1 = neNextDim1[whichFace];
s32 otherAxis2 = neNextDim2[whichFace];
neV3 sub = project - trans->pos;
dot = neAbs(sub.Dot(trans->rot[otherAxis1]));
if (dot > (convex->BoxSize(otherAxis1) * 1.001f))
return true;// not false ???? no it is true!!!
dot = neAbs(sub.Dot(trans->rot[otherAxis2]));
if (dot > (convex->BoxSize(otherAxis2) * 1.001f))
return true;// not false ???? no it is true!!!
res.contactA = project;
res.contactB = contactPoint;
res.contactNormal = dir;
res.depth = depth;
res.valid = true;
return true;
}
neBool BoxTestParam::CylinderEdgeTest(ConvexTestResult & res, TConvex & cylinderB, neT3 & transB, s32 whichEdge)
{
neV3 diff = trans->pos - transB.pos;
neV3 dir = trans->rot[whichEdge].Cross(transB.rot[1]);
f32 len = dir.Length();
if (neIsConsiderZero(len))
return true;
dir *= (1.0f / len);
f32 dot = dir.Dot(diff);
if (dot > 0.0f)
{
dot *= -1.0f;
}
else
{
dir *= -1.0f;
}
f32 depth = dot + cylinderB.CylinderRadius();
neV3 contactPoint = trans->pos;
s32 i;
for (i = 0; i < 3; i++)
{
if (i == whichEdge)
continue;
dot = dir.Dot(radii[i]);
if (dot > 0.0f)
{
depth += dot;
contactPoint -= radii[i];
}
else
{
depth -= dot;
contactPoint += radii[i];
}
}
if (depth <= 0.0f)
return false;
ConvexTestResult cr;
cr.edgeA[0] = contactPoint + radii[whichEdge];
cr.edgeA[1] = contactPoint - radii[whichEdge];
cr.edgeB[0] = transB.pos + transB.rot[1] * cylinderB.CylinderHalfHeight();
cr.edgeB[1] = transB.pos - transB.rot[1] * cylinderB.CylinderHalfHeight();
f32 au, bu;
// A is the box, B is the cylinder
cr.ComputerEdgeContactPoint2(au, bu);
if (cr.depth >= res.depth)
return true;
if (cr.valid)
{
depth = cylinderB.CylinderRadius() - cr.depth;
if (depth <= 0.0f)
return false;
if (depth >= res.depth)
return true;;
res.valid = true;
res.contactNormal = dir;
res.contactA = cr.contactA;
res.contactB = cr.contactB + res.contactNormal * cylinderB.CylinderRadius();
res.depth = depth;
}
else
{
// A is the box, B is the cylinder
if (au > 0.0 && au < 1.0f)
{
// box edge and cylinder end
neV3 cylinderVert;
if (bu <= 0.0f)
{
cylinderVert = cr.edgeB[0];
}
else
{
cylinderVert = cr.edgeB[1];
}
neV3 project;
f32 dist = cylinderVert.GetDistanceFromLine2(project, cr.edgeA[0], cr.edgeA[1]);
f32 depth = cylinderB.CylinderRadius() - dist;
if (depth <= 0.0f)
return true;
if (depth >= res.depth)
return true;
res.depth = depth;
res.valid = true;
res.contactNormal = project - cylinderVert;
res.contactNormal.Normalize();
res.contactA = project;
res.contactB = cylinderVert + res.contactNormal * cylinderB.CylinderRadius();
}
else
{
neV3 boxVert;
if (au <= 0.0f)
{
boxVert = cr.edgeA[0];
}
else // au >= 1.0f
{
boxVert = cr.edgeA[1];
}
if (bu > 0.0f && bu < 1.0f)
{
// boxVert and cylinder edge
neV3 project;
f32 depth = boxVert.GetDistanceFromLine2(project, cr.edgeB[0], cr.edgeB[1]);
depth = cylinderB.CylinderRadius() - depth;
if (depth <= 0.0f)
return true;
if (depth >= res.depth)
return true;
res.depth = depth;
res.valid = true;
res.contactA = boxVert;
res.contactNormal = boxVert - project;
res.contactNormal.Normalize();
res.contactB = project + res.contactNormal * cylinderB.CylinderRadius();
}
else
{
// box vert and cylinder end
neV3 cylinderVert;
if (bu <= 0.0f)
{
cylinderVert = cr.edgeB[0];
}
else
{
cylinderVert = cr.edgeB[1];
}
neV3 diff = boxVert - cylinderVert;
f32 depth = diff.Dot(diff);
if (depth >= cylinderB.CylinderRadiusSq())
return true;
depth = sqrtf(depth);
depth = cylinderB.CylinderRadius() - depth;
if (depth >= res.depth)
return true;
res.depth = depth;
res.valid = true;
res.contactNormal = diff;
res.contactNormal.Normalize();
res.contactA = boxVert;
res.contactB = cylinderVert + res.contactNormal * cylinderB.CylinderRadius();
}
}
}
return true;
}
} | [
"[email protected]"
] | [
[
[
1,
306
]
]
] |
c476a7963cc1f550348406a47af309902474bbd7 | c9630df0e019e54a19edd09e0ae2736102709d62 | /jacobi/trunk/jacobiCUDA/stdafx.cpp | 14b6808fb6a7bc6ee479c589a023b026c449ac12 | [] | no_license | shaowei-su/jacobi-in-parallel | 45df2fdab6e32083b486ac088e1036fd085d4c1c | 8c772afd412945735d15f771f200c6cff30bdae3 | refs/heads/master | 2021-01-13T01:31:07.625534 | 2010-04-13T10:46:20 | 2010-04-13T10:46:20 | 33,940,298 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 272 | cpp | // stdafx.cpp : 只包括标准包含文件的源文件
// 2DheatSerial.pch 将作为预编译头
// stdafx.obj 将包含预编译类型信息
#include "stdafx.h"
// TODO: 在 STDAFX.H 中
// 引用任何所需的附加头文件,而不是在此文件中引用
| [
"snigoal@aed88cc7-7f53-aada-5582-5968519015a4"
] | [
[
[
1,
8
]
]
] |
27e28d0acadcbff4252b582c74e83f520c0668a2 | 3dfebcfc2ed973d609d2279ba2f42766b483d799 | /LocalJS_Runtime/LocalJSBootstrap/LocalJSBootstrap/LocalJSBootstrap.cpp | 9647edce9016903a04359f95db808d4203ce3f18 | [] | no_license | odaba/localjs | 70dd5f333dd39d42a5f2a0d9a288654a2018a9cc | 8501b9fa5f670ca6cf35cb72eabf488fca0d8525 | refs/heads/master | 2020-05-30T21:33:41.575710 | 2011-01-22T12:28:52 | 2011-01-22T12:28:52 | 40,529,549 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,402 | cpp | // LocalJSBootstrap.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include "WebBrowserWindow.h"
#include "Resource.h"
using namespace GroundBase;
using namespace GroundBase::LocalBrowser;
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int /*nCmdShow*/)
{
// Usage: LocalJSBootstrap.exe start_html_file_name
// Check command line parameter first
WCHAR start_html_file_name[MAX_PATH];
start_html_file_name[0] = L'\0';
static LPCWSTR MESSAGE_CAPTION = L"LocalJS Bootstrap";
int num_args = 0;
LPWSTR * args = CommandLineToArgvW(GetCommandLineW(), &num_args);
if (args)
{
if (num_args > 1 && wcslen(args[1]) < DIM(start_html_file_name))
{
WCHAR path[MAX_PATH];
GetModuleFileNameW(NULL, path, DIM(path));
PathRemoveFileSpecW(path);
PathCombineW(start_html_file_name, path, args[1]);
if (!PathFileExistsW(start_html_file_name))
start_html_file_name[0] = L'\0';
}
LocalFree(args);
}
// if the file given by command line is not found,
// try a file having same name as the exe file with html filename extension,
// and locates at same folder
if (!start_html_file_name[0])
{
GetModuleFileNameW(NULL, start_html_file_name, DIM(start_html_file_name));
PathRemoveExtensionW(start_html_file_name);
wcscat(start_html_file_name, L".html");
}
if (PathFileExistsW(start_html_file_name))
{
// An optional icon
HICON hIcon = (HICON) LoadImage(hInstance, MAKEINTRESOURCE(IDI_ICON1), IMAGE_ICON, 32, 32, LR_DEFAULTCOLOR);
CWebBrowserWindow::initializeLocalJS(hInstance, hIcon, hIcon);
// window position / style can be changed in javascript when HTML is loaded. so here we can give any valid value.
{
// make sure dlgInit destructed before LocalJS::UninitializeLocalJS
CWebBrowserWindow dlgInit;
dlgInit.dialogBox(WS_POPUP | WS_VISIBLE | WS_SYSMENU,
(GetSystemMetrics(SM_CXSCREEN) >> 1) - 5, (GetSystemMetrics(SM_CYSCREEN) >> 1) - 5, 10, 10,
NULL, start_html_file_name, NULL, NULL);
}
CWebBrowserWindow::uninitializeLocalJS();
DestroyIcon(hIcon);
}
else
{
WCHAR buf[MAX_PATH + 64];
swprintf(buf, L"LocalJS bootstrap file %s doesn't exist.", start_html_file_name);
MessageBoxW(NULL, buf, MESSAGE_CAPTION, MB_OK | MB_TOPMOST | MB_ICONERROR);
}
return 0;
}
| [
"[email protected]"
] | [
[
[
1,
76
]
]
] |
f94c9fb4b0a37980e2f9941731467c8203470d4c | 9c62af23e0a1faea5aaa8dd328ba1d82688823a5 | /rl/branches/persistence2/engine/core/src/MergeableMeshObject.cpp | 2b6ee6de703c5c7fdac243e782eee32d32bcd48d | [
"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 | UTF-8 | C++ | false | false | 5,483 | cpp | /* This source file is part of Rastullahs Lockenpracht.
* Copyright (C) 2003-2008 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 "stdinc.h" //precompiled header
#include "MergeableMeshObject.h"
#include <MeshMergeTool.h>
#include "CoreSubsystem.h"
#include "World.h"
using namespace Ogre;
using meshmagick::MeshMergeTool;
namespace rl
{
MergeableMeshObject::MergeableMeshObject(const Ogre::String& name, const Ogre::String& meshname)
: MeshObject(name, meshname),
mMeshes(),
mCombinedMeshName()
{
mBaseMesh = getEntity()->getMesh();
}
MergeableMeshObject::~MergeableMeshObject()
{
}
void MergeableMeshObject::addSubmesh(const Ogre::String& partname, const Ogre::String& meshfile)
{
mMeshes[partname] = meshfile;
updateMesh();
}
void MergeableMeshObject::updateMesh()
{
Ogre::String newMeshName = "";
for (MeshPartMap::const_iterator it = mMeshes.begin(); it != mMeshes.end(); ++it)
{
newMeshName += "-" + (*it).second;
}
if (mCombinedMeshName != newMeshName)
{
MeshPtr newMesh = MeshManager::getSingleton().getByName(newMeshName);
if (newMesh.isNull())
{
MeshMergeTool mm;
for (MeshPartMap::const_iterator it = mMeshes.begin(); it != mMeshes.end(); ++it)
{
String curMeshfile = (*it).second;
MeshPtr meshToAdd = MeshManager::getSingleton().getByName(curMeshfile);
if (!meshToAdd.isNull())
{
meshToAdd->load();
try
{
mm.addMesh(meshToAdd);
}
catch (const std::logic_error& ex)
{
LOG_ERROR(Logger::CORE, ex.what());
}
}
else
{
LOG_ERROR(Logger::CORE, "Mesh '" + curMeshfile + "' could not be found for merging.");
}
}
newMesh = mm.bake(newMeshName);
}
switchTo(newMesh);
mCombinedMeshName = newMeshName;
}
}
void MergeableMeshObject::setBaseMeshPart(const Ogre::String& partname)
{
mMeshes[partname] = mBaseMesh->getName();
}
void MergeableMeshObject::replaceSubmesh(const Ogre::String& partToReplace, const Ogre::String& substituteMeshname)
{
///@todo check if submesh exists
mMeshes[partToReplace] = substituteMeshname;
updateMesh();
}
void MergeableMeshObject::removeSubmesh(const Ogre::String& partToRemove)
{
MeshPartMap::iterator it = mMeshes.find(partToRemove);
if (it != mMeshes.end())
{
mMeshes.erase(it);
updateMesh();
}
else
{
LOG_ERROR(
Logger::CORE,
"Could not remove part '"
+ partToRemove + "' from mergeable mesh '"
+ getMeshName() + "'. Part not found.");
}
}
void MergeableMeshObject::switchTo(const MeshPtr& newMesh)
{
///@todo reactivate running animations?
stopAllAnimations();
Entity* oldEnt = getEntity();
Entity* newEnt = CoreSubsystem::getSingletonPtr()->getWorld()
->getSceneManager()->createEntity(oldEnt->getName()+"_", newMesh->getName());
// queryflags uebernehmen
newEnt->setQueryFlags( oldEnt->getQueryFlags() );
TagPoint* parentTp = dynamic_cast<TagPoint*>(oldEnt->getParentNode());
if (parentTp)
{
parentTp->setChildObject(newEnt);
}
SceneNode* parentSceneNode = oldEnt->getParentSceneNode();
if (parentSceneNode != NULL)
{
parentSceneNode->detachObject(oldEnt);
parentSceneNode->attachObject(newEnt);
}
std::map<Ogre::String, Ogre::MovableObject*> childObjectMap;
for (Entity::ChildObjectListIterator it = oldEnt->getAttachedObjectIterator();
it.hasMoreElements();)
{
MovableObject* mo = it.peekNextValue();
//go upwards to tagpoint (all attached objects must have a tagpoint as parent)
TagPoint* parent = dynamic_cast<TagPoint*>(mo->getParentNode());
if (parent)
{
//tagpoints are children of a bone
Bone* bone = dynamic_cast<Bone*>(parent->getParent());
Ogre::String key = bone->getName();
childObjectMap[key] = mo;
}
it.moveNext();
}
for (std::map<Ogre::String, Ogre::MovableObject*>::const_iterator itChild = childObjectMap.begin();
itChild != childObjectMap.end(); ++itChild)
{
oldEnt->detachObjectFromBone(itChild->second);
newEnt->attachObjectToBone(itChild->first, itChild->second);
}
mMovableObject = newEnt;
CoreSubsystem::getSingletonPtr()->getWorld()
->getSceneManager()->destroyEntity(oldEnt);
}
}
| [
"timm@4c79e8ff-cfd4-0310-af45-a38c79f83013"
] | [
[
[
1,
183
]
]
] |
cce74854b80664dd21a54d4b8ca2bf701ac645d2 | 5e72c94a4ea92b1037217e31a66e9bfee67f71dd | /old/src/ThroughputModePanel.h | 15ff479998349b7d4eb6714ab3cdecf7c8f51ab2 | [] | no_license | stein1/bbk | 1070d2c145e43af02a6df14b6d06d9e8ed85fc8a | 2380fc7a2f5bcc9cb2b54f61e38411468e1a1aa8 | refs/heads/master | 2021-01-17T23:57:37.689787 | 2011-05-04T14:50:01 | 2011-05-04T14:50:01 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,784 | h | #pragma once
#include "main.h"
#include "TestPanel.h"
class ThroughputModePanel : public TestPanel
{
public:
ThroughputModePanel(wxWindow *parent);
~ThroughputModePanel(void);
static void OnTestCompleted_Wrapper(void* obj, bool arg);
void OnTestCompleted(bool abort);
void RefreshResultList(void);
void RefreshSettingsList(void);
void RefreshGUI(void);
void OnSettingsListItemSelected(wxListEvent& event);
void OnCheckBoxEnable(wxCommandEvent &event);
void OnCheckBoxTPTest(wxCommandEvent &event);
void OnCheckBoxHTTP(wxCommandEvent &event);
void OnCheckBoxFTP(wxCommandEvent &event);
void FocusList(void);
void OnRemoveResult(wxCommandEvent& event);
bool ExecuteTest(void);
static bool ExecuteTest_Wrapper(void* obj);
void OnResultDetail(wxListEvent& event);
private:
wxNotebook *m_BookResult;
wxNotebookPage *m_PageSettings;
wxNotebookPage *m_PageTextResult;
wxNotebookPage *m_PageGraphTPTestDownResult;
wxNotebookPage *m_PageGraphTPTestUpResult;
wxNotebookPage *m_PageGraphHTTPResult;
wxNotebookPage *m_PageGraphFTPResult;
wxBoxSizer *m_SizerPageSettingsEdit;
wxBoxSizer *m_SizerPageSettings;
wxBoxSizer *m_SizerPageTextResult;
wxBoxSizer *m_SizerPageGraphTPTestDownResult;
wxBoxSizer *m_SizerPageGraphTPTestUpResult;
wxBoxSizer *m_SizerPageGraphHTTPResult;
wxBoxSizer *m_SizerPageGraphFTPResult;
wxCheckBox *m_CheckBoxEnable;
wxCheckBox *m_CheckBoxEnableTPTest;
wxCheckBox *m_CheckBoxEnableHTTP;
wxCheckBox *m_CheckBoxEnableFTP;
Server *m_SelectedSettingsServer;
int m_SelectedSettingsServerIndex;
ServerList *m_ServerList;
bool m_Initialized;
DECLARE_EVENT_TABLE()
public:
void OnPageChanged(wxNotebookEvent& event);
};
| [
"[email protected]"
] | [
[
[
1,
63
]
]
] |
2b91fd8304f8ed92a78594da71410e5ee583b60f | cd0987589d3815de1dea8529a7705caac479e7e9 | /webkit/WebKit2/WebProcess/WebCoreSupport/win/WebErrorsWin.cpp | 52d061c4df25534b0d735b9497d53f94e4b607d9 | [] | 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 | 5,680 | cpp | /*
* 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.
*/
#include "WebErrors.h"
#include <WebCore/ResourceRequest.h>
#include <WebCore/ResourceResponse.h>
using namespace WebCore;
namespace WebKit {
#define WebURLErrorDomain TEXT("CFURLErrorDomain")
enum {
WebURLErrorUnknown = -1,
WebURLErrorCancelled = -999,
WebURLErrorBadURL = -1000,
WebURLErrorTimedOut = -1001,
WebURLErrorUnsupportedURL = -1002,
WebURLErrorCannotFindHost = -1003,
WebURLErrorCannotConnectToHost = -1004,
WebURLErrorNetworkConnectionLost = -1005,
WebURLErrorDNSLookupFailed = -1006,
WebURLErrorHTTPTooManyRedirects = -1007,
WebURLErrorResourceUnavailable = -1008,
WebURLErrorNotConnectedToInternet = -1009,
WebURLErrorRedirectToNonExistentLocation = -1010,
WebURLErrorBadServerResponse = -1011,
WebURLErrorUserCancelledAuthentication = -1012,
WebURLErrorUserAuthenticationRequired = -1013,
WebURLErrorZeroByteResource = -1014,
WebURLErrorFileDoesNotExist = -1100,
WebURLErrorFileIsDirectory = -1101,
WebURLErrorNoPermissionsToReadFile = -1102,
WebURLErrorSecureConnectionFailed = -1200,
WebURLErrorServerCertificateHasBadDate = -1201,
WebURLErrorServerCertificateUntrusted = -1202,
WebURLErrorServerCertificateHasUnknownRoot = -1203,
WebURLErrorServerCertificateNotYetValid = -1204,
WebURLErrorClientCertificateRejected = -1205,
WebURLErrorClientCertificateRequired = -1206,
WebURLErrorCannotLoadFromNetwork = -2000,
// Download and file I/O errors
WebURLErrorCannotCreateFile = -3000,
WebURLErrorCannotOpenFile = -3001,
WebURLErrorCannotCloseFile = -3002,
WebURLErrorCannotWriteToFile = -3003,
WebURLErrorCannotRemoveFile = -3004,
WebURLErrorCannotMoveFile = -3005,
WebURLErrorDownloadDecodingFailedMidStream = -3006,
WebURLErrorDownloadDecodingFailedToComplete =-3007,
};
#define WebKitErrorDomain TEXT("WebKitErrorDomain")
enum {
WebKitErrorCannotShowMIMEType = 100,
WebKitErrorCannotShowURL = 101,
WebKitErrorFrameLoadInterruptedByPolicyChange = 102,
WebKitErrorCannotUseRestrictedPort = 103,
};
enum {
WebKitErrorCannotFindPlugIn = 200,
WebKitErrorCannotLoadPlugIn = 201,
WebKitErrorJavaUnavailable = 202,
};
enum {
WebKitErrorGeolocationLocationUnknown = 300,
};
#define WebKitErrorMIMETypeKey TEXT("WebKitErrorMIMETypeKey")
#define WebKitErrorPlugInNameKey TEXT("WebKitErrorPlugInNameKey")
#define WebKitErrorPlugInPageURLStringKey TEXT("WebKitErrorPlugInPageURLStringKey")
#define WebPOSIXErrorDomain TEXT("NSPOSIXErrorDomain")
#define WebPOSIXErrorECONNRESET 54
ResourceError cancelledError(const ResourceRequest& request)
{
return ResourceError(String(WebURLErrorDomain), WebURLErrorCancelled, request.url().string(), String());
}
ResourceError blockedError(const ResourceRequest& request)
{
return ResourceError(String(WebKitErrorDomain), WebKitErrorCannotUseRestrictedPort, request.url().string(), String());
}
ResourceError cannotShowURLError(const ResourceRequest& request)
{
return ResourceError(String(WebKitErrorDomain), WebKitErrorCannotShowURL, request.url().string(), String());
}
ResourceError interruptForPolicyChangeError(const ResourceRequest& request)
{
return ResourceError(String(WebKitErrorDomain), WebKitErrorFrameLoadInterruptedByPolicyChange, request.url().string(), String());
}
ResourceError cannotShowMIMETypeError(const ResourceResponse& response)
{
return ResourceError();
}
ResourceError fileDoesNotExistError(const ResourceResponse& response)
{
return ResourceError();
}
} // namespace WebKit
| [
"[email protected]"
] | [
[
[
1,
134
]
]
] |
ce17dab7bbebf4091a5219fd7a19ce634e73d344 | 260c113e54a8194a20af884e7fd7e3cadb1cf610 | /branches/RAAAAGGEEE/sllabzzuf/src/Block.cpp | b6ddab55e53bf62d93f01246910cd2f736f56d4f | [] | no_license | weimingtom/sllabzzuf | 8ce0205cc11ff5cdb569e8b2a629eb6cbbfebfc6 | 5f22cc5686068b179b3c17010d948ff05f16724c | refs/heads/master | 2020-06-09T01:02:00.944446 | 2011-04-07T05:34:22 | 2011-04-07T05:34:22 | 38,219,985 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,031 | cpp | #include "Block.h"
Block::Block(int startx, int starty){
x=startx;
y=starty;
w=64;
h=64;
y_acceleration=0;
y_velocity=0;
}
SDL_Rect Block::get_bounds(){
SDL_Rect bounds;
bounds.x=x;
bounds.y=y;
bounds.w=w;
bounds.h=h;
return bounds;
}
void Block::draw(SDL_Surface *screen, SDL_Rect *camera){
SDL_Rect portion;
portion.x=0;
portion.y=0;
portion.w=w;
portion.h=h;
SDL_BlitSurface( sprite, &portion, screen, &getScreenCoord(camera));
}
SDL_Rect Block::getScreenCoord(SDL_Rect* camera){
SDL_Rect screenCoord;
screenCoord.x = x - camera->x;
screenCoord.y = y - camera->y;
return screenCoord;
}
bool Block::test_spot(int type, int tile_x, int tile_y){
if(type!=0){
if((tile_y + 32 > y)&&(tile_y < y+h)&&(tile_x+32>x)&&(tile_x<x+w)){
return true;
}
}
return false;
}
bool Block::move_y(int amount, int current_x, int current_y, std::vector<Tile*> tiles, int mapwidthpx, int mapheightpx){
current_y += amount;
int type;
int tile_x = (x/32)*32;
int tile_y = (y/32)*32;
//int relative_x= x+(w/3)-tile_x;
//int relative_y= y-tile_y;
//int relative_w= x+(2*w/3)-tile_x;
//int relative_h= y+h-tile_y;
if((x< 0) || (x+w > mapwidthpx) || (y<0) || (y+h >= mapheightpx)){
return false;
}
type=tiles[tile_x/32 + (((tile_y)/32+1)*(mapwidthpx/32))]->get_type();
if(test_spot(type, tile_x, tile_y+32)){
type = tiles[x/32 + 1 + ((y/32+1)*(mapwidthpx/32))]->get_type();
if(test_spot(type, tile_x+32, tile_y+32)){
y += amount;
return true;
}
}
return false;
}
void Block::update(int gravity, std::vector<Tile*> tiles, int mapwidthpx, int mapheightpx){
y_acceleration=gravity;
if(y_acceleration<-10)
y_acceleration=-10;
if(y_acceleration>10)
y_acceleration=10;
y_velocity=y_velocity+y_acceleration;
if(y_velocity<-15)
y_velocity=-15;
if(y_velocity>15)
y_velocity=15;
int y_moved = 0;
int previous_y_moved=-1;
while(y_moved > previous_y_moved){
previous_y_moved=y_moved;
if(y_moved< y_velocity){
if(y_velocity>0 && move_y(1, x, y, tiles, mapwidthpx, mapheightpx)){
y_moved+=1;
}
}
}if(!move_y(1, x, y, tiles, mapwidthpx, mapheightpx)){
y_acceleration=0;
y_velocity=0;
}
}
void Block::load_sprite(){
rawsprite = IMG_Load("sprites/iceblock.png");
if( rawsprite != NULL )
{
sprite = SDL_DisplayFormat( rawsprite );
SDL_FreeSurface( rawsprite );
if( sprite != NULL )
{
SDL_SetColorKey( sprite, SDL_SRCCOLORKEY, SDL_MapRGB( sprite->format, 0xFF, 0, 0xFF ) );
}else{
std::cout << "Player's sprite is still NULL!\n";
}
}else{
std::cout << "Player's rawsprite is still NULL!\n";
}
}
| [
"[email protected]"
] | [
[
[
1,
109
]
]
] |
f9028da204a2f1cd6f2681b1377e7786c8021daa | a5cbc2c1c12b3df161d9028791c8180838fbf2fb | /Heimdall/heimdall/source/Packet.h | 33469f1726cd086a6900ecbb17a02517fe701131 | [
"MIT"
] | permissive | atinm/Heimdall | e8659fe869172baceb590bc445f383d8bcb72b82 | 692cda38c99834384c4f0c7687c209f432300993 | refs/heads/master | 2020-03-27T12:29:58.609089 | 2010-12-03T19:25:19 | 2010-12-03T19:25:19 | 1,136,137 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,667 | h | /* Copyright (c) 2010 Benjamin Dobell, Glass Echidna
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 PACKET_H
#define PACKET_H
// C++ Standard Library
#include <cstring>
namespace Heimdall
{
class Packet
{
private:
unsigned int size;
protected:
unsigned char *data;
public:
Packet(unsigned int size)
{
this->size = size;
data = new unsigned char[size];
memset(data, 0, size);
}
~Packet()
{
delete [] data;
}
int GetSize(void) const
{
return (size);
}
unsigned char *GetData(void)
{
return (data);
}
};
}
#endif
| [
"[email protected]"
] | [
[
[
1,
65
]
]
] |
c5f2fd66f71213db61407f2aa113b12df1ebe887 | 037faae47a5b22d3e283555e6b5ac2a0197faf18 | /pcsx2v2/x86/iCOP2.cpp | d002d1b949dff9ae1df7e0803d96ebd8aa7fe492 | [] | no_license | isabella232/pcsx2-sourceforge | 6e5aac8d0b476601bfc8fa83ded66c1564b8c588 | dbb2c3a010081b105a8cba0c588f1e8f4e4505c6 | refs/heads/master | 2023-03-18T22:23:15.102593 | 2008-11-17T20:10:17 | 2008-11-17T20:10:17 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 28,382 | cpp | /* Pcsx2 - Pc Ps2 Emulator
* Copyright (C) 2002-2008 Pcsx2 Team
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdlib.h>
#include <string.h>
#include "Common.h"
#include "InterTables.h"
#include "ix86/ix86.h"
#include "iR5900.h"
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "Common.h"
#include "DebugTools/Debug.h"
#include "R5900.h"
#include "InterTables.h"
#include "VUmicro.h"
#include "iVU0micro.h"
#include "iVUmicro.h"
#ifdef _WIN32
#pragma warning(disable:4244)
#pragma warning(disable:4761)
#endif
// cycle cycles statusflag macflag clipflag
_vuopinfo g_cop2info = {0, 0, 1, 1, 1, 0, 0};
#define _Ft_ _Rt_
#define _Fs_ _Rd_
#define _Fd_ _Sa_
#define _Fsf_ ((cpuRegs.code >> 21) & 0x03)
#define _Ftf_ ((cpuRegs.code >> 23) & 0x03)
#define _Cc_ (cpuRegs.code & 0x03)
#define REC_COP2_FUNC(f, delreg) \
void f(); \
void rec##f() { \
SysPrintf("cop2 "#f" called\n"); \
X86_32CODE(SetFPUstate()); \
MOV32ItoM((uptr)&cpuRegs.code, cpuRegs.code); \
MOV32ItoM((uptr)&cpuRegs.pc, pc); \
iFlushCall(FLUSH_NOCONST); \
CALLFunc((uptr)f); \
_freeX86regs(); \
branch = 2; \
}
#define INTERPRETATE_COP2_FUNC(f) \
void recV##f() { \
MOV32ItoM((uptr)&cpuRegs.code, cpuRegs.code); \
MOV32ItoM((uptr)&cpuRegs.pc, pc); \
iFlushCall(FLUSH_EVERYTHING); \
CALLFunc((uptr)V##f); \
_freeX86regs(); \
}
#define REC_COP2_VU0(f) \
void recV##f() { \
recVU0MI_##f(); \
_freeX86regs(); \
}
extern u32 dumplog;
#define REC_COP2_VU0_Q(f) \
void recV##f() { \
recVU0MI_##f(); \
_freeX86regs(); \
}
void rec_C2UNK()
{
SysPrintf("Cop2 bad opcode:%x\n",cpuRegs.code);
}
void _vuRegs_C2UNK(VURegs * VU, _VURegsNum *VUregsn)
{
SysPrintf("Cop2 bad _vuRegs code:%x\n",cpuRegs.code);
}
void _vuRegsCOP22(VURegs * VU, _VURegsNum *VUregsn);
//void (*recCOP2t[32])();
//void (*recCOP2_BC2t[32])();
//void (*recCOP2SPECIAL1t[64])();
//void (*recCOP2SPECIAL2t[128])();
void recCOP2();
void recCOP2_SPECIAL();
void recCOP2_BC2();
void recCOP2_SPECIAL2();
extern void _vu0WaitMicro();
static void recCFC2()
{
int mmreg = 0;
if (cpuRegs.code & 1) {
iFlushCall(IS_X8664?(FLUSH_FREE_VU0|FLUSH_FREE_TEMPX86):FLUSH_NOCONST);
CALLFunc((uptr)_vu0WaitMicro);
}
if(!_Rt_) return;
_deleteGPRtoXMMreg(_Rt_, 2);
#ifdef __x86_64__
mmreg = _allocX86reg(-1, X86TYPE_GPR, _Rt_, MODE_WRITE);
if( (creg = _checkX86reg(X86TYPE_VI, _Fs_, MODE_READ)) >= 0 ) {
if(EEINST_ISLIVE1(_Rt_)) {
if( _Fs_ < 16 ) {
// zero extending
MOVZX64R16toR(mmreg, creg);
}
else {
// sign extend, use full 32 bits
MOV32RtoR(mmreg, creg);
SHL64ItoR(mmreg, 32);
SAR64ItoR(mmreg, 32);
}
}
else {
// just move
MOV32RtoR(mmreg, creg);
EEINST_RESETHASLIVE1(_Rt_);
}
}
else {
if(EEINST_ISLIVE1(_Rt_)) {
if( _Fs_ < 16 ) {
// zero extending
MOVZX64M16toR(mmreg, (uptr)&VU0.VI[ _Fs_ ].UL);
}
else {
// sign extend, use full 32 bits
MOV32MtoR(RAX, (uptr)&VU0.VI[ _Fs_ ].UL);
CDQE();
MOV64RtoR(mmreg, RAX);
}
}
else {
// just move
MOV32MtoR(mmreg, (uptr)&VU0.VI[ _Fs_ ].UL);
EEINST_RESETHASLIVE1(_Rt_);
}
}
#else
if( (mmreg = _checkMMXreg(MMX_GPR+_Rt_, MODE_WRITE)) >= 0 ) {
if( _Fs_ >= 16 ) {
MOVDMtoMMX(mmreg, (uptr)&VU0.VI[ _Fs_ ].UL);
if( EEINST_ISLIVE1(_Rt_) ) {
_signExtendGPRtoMMX(mmreg, _Rt_, 0);
}
else {
EEINST_RESETHASLIVE1(_Rt_);
}
}
else {
MOVDMtoMMX(mmreg, (uptr)&VU0.VI[ _Fs_ ].UL);
}
SetMMXstate();
}
else {
MOV32MtoR(EAX, (uptr)&VU0.VI[ _Fs_ ].UL);
MOV32RtoM((uptr)&cpuRegs.GPR.r[_Rt_].UL[0],EAX);
if(EEINST_ISLIVE1(_Rt_)) {
if( _Fs_ < 16 ) {
// no sign extending
MOV32ItoM((uptr)&cpuRegs.GPR.r[_Rt_].UL[1],0);
}
else {
CDQ();
MOV32RtoM((uptr)&cpuRegs.GPR.r[_Rt_].UL[1], EDX);
}
}
else {
EEINST_RESETHASLIVE1(_Rt_);
}
}
#endif
_eeOnWriteReg(_Rt_, 1);
}
static void recCTC2()
{
if (cpuRegs.code & 1) {
iFlushCall(IS_X8664?(FLUSH_FREE_VU0|FLUSH_FREE_TEMPX86):FLUSH_NOCONST);
CALLFunc((uptr)_vu0WaitMicro);
}
if(!_Fs_) return;
if( GPR_IS_CONST1(_Rt_) ) {
switch(_Fs_) {
case REG_MAC_FLAG: // read-only
case REG_TPC: // read-only
case REG_VPU_STAT: // read-only
break;
case REG_FBRST:
if( g_cpuConstRegs[_Rt_].UL[0] & 0x202 )
iFlushCall(FLUSH_FREE_TEMPX86);
_deleteX86reg(X86TYPE_VI, REG_FBRST, 2);
if( g_cpuConstRegs[_Rt_].UL[0] & 2 ) {
CALLFunc((uptr)vu0ResetRegs);
}
if( g_cpuConstRegs[_Rt_].UL[0] & 0x200 ) {
CALLFunc((uptr)vu1ResetRegs);
}
MOV16ItoM((uptr)&VU0.VI[REG_FBRST].UL,g_cpuConstRegs[_Rt_].UL[0]&0x0c0c);
break;
case REG_CMSAR1: // REG_CMSAR1
iFlushCall(IS_X8664?FLUSH_FREE_TEMPX86:FLUSH_NOCONST); // since CALLFunc
assert( _checkX86reg(X86TYPE_VI, REG_VPU_STAT, 0) < 0 &&
_checkX86reg(X86TYPE_VI, REG_TPC, 0) < 0 );
// ignore if VU1 is operating
/*TEST32ItoM((uptr)&VU0.VI[REG_VPU_STAT].UL, 0x100);
j8Ptr[0] = JNZ8(0);
MOV32ItoM((uptr)&VU1.VI[REG_TPC].UL, g_cpuConstRegs[_Rt_].UL[0]&0xffff);*/
// Execute VU1 Micro SubRoutine
#ifdef __x86_64__
_callFunctionArg1((uptr)FreezeXMMRegs_, MEM_CONSTTAG, 1);
#else
/*PUSH32I(1);
CALLFunc((uptr)FreezeXMMRegs_);*/
#endif
_callFunctionArg1((uptr)vu1ExecMicro, MEM_CONSTTAG, g_cpuConstRegs[_Rt_].UL[0]&0xffff);
#ifdef __x86_64__
_callFunctionArg1((uptr)FreezeXMMRegs_, MEM_CONSTTAG, 0);
#else
/*PUSH32I(0);
CALLFunc((uptr)FreezeXMMRegs_);*/
//ADD32ItoR(ESP, 4);
#endif
//x86SetJ8( j8Ptr[0] );
break;
default:
if( _Fs_ < 16 )
assert( (g_cpuConstRegs[_Rt_].UL[0]&0xffff0000)==0);
#ifdef __x86_64__
if( (mmreg = _checkX86reg(X86TYPE_VI, _Fs_, MODE_WRITE)) >= 0 )
MOV32ItoR(mmreg, g_cpuConstRegs[_Rt_].UL[0]);
else
#else
MOV32ItoM((uptr)&VU0.VI[_Fs_].UL,g_cpuConstRegs[_Rt_].UL[0]);
#endif
// a lot of games have vu0 spinning on some integer
// then they modify the register and expect vu0 to stop spinning within 10 cycles (donald duck)
iFlushCall(IS_X8664?(FLUSH_FREE_TEMPX86|FLUSH_FREE_VU0):FLUSH_NOCONST);
/* TEST32ItoM((uptr)&VU0.VI[REG_VPU_STAT].UL, 1);
j8Ptr[0] = JZ8(0);*/
#ifdef __x86_64__
_callFunctionArg1((uptr)FreezeXMMRegs_, MEM_CONSTTAG, 1);
#else
/*PUSH32I(1);
CALLFunc((uptr)FreezeXMMRegs_);*/
#endif
CALLFunc((uptr)Cpu->ExecuteVU0Block);
#ifdef __x86_64__
_callFunctionArg1((uptr)FreezeXMMRegs_, MEM_CONSTTAG, 0);
#else
/*PUSH32I(0);
CALLFunc((uptr)FreezeXMMRegs_);*/
//ADD32ItoR(ESP, 4);
#endif
//x86SetJ8(j8Ptr[0]);
break;
}
}
else {
switch(_Fs_) {
case REG_MAC_FLAG: // read-only
case REG_TPC: // read-only
case REG_VPU_STAT: // read-only
break;
case REG_FBRST:
iFlushCall(FLUSH_FREE_TEMPX86);
assert( _checkX86reg(X86TYPE_VI, REG_FBRST, 0) < 0 );
_eeMoveGPRtoR(EAX, _Rt_);
TEST32ItoR(EAX,0x2);
j8Ptr[0] = JZ8(0);
CALLFunc((uptr)vu0ResetRegs);
_eeMoveGPRtoR(EAX, _Rt_);
x86SetJ8(j8Ptr[0]);
TEST32ItoR(EAX,0x200);
j8Ptr[0] = JZ8(0);
CALLFunc((uptr)vu1ResetRegs);
_eeMoveGPRtoR(EAX, _Rt_);
x86SetJ8(j8Ptr[0]);
AND32ItoR(EAX,0x0C0C);
MOV16RtoM((uptr)&VU0.VI[REG_FBRST].UL,EAX);
break;
case REG_CMSAR1: // REG_CMSAR1
iFlushCall(IS_X8664?FLUSH_FREE_TEMPX86:FLUSH_NOCONST); // since CALLFunc
// ignore if VU1 is operating
/*TEST32ItoM((uptr)&VU0.VI[REG_VPU_STAT].UL, 0x100);
j8Ptr[0] = JNZ8(0);*/
_eeMoveGPRtoR(EAX, _Rt_);
//MOV16RtoM((uptr)&VU1.VI[REG_TPC].UL,EAX);
/*FreezeXMMRegs(1);*/
_callFunctionArg1((uptr)vu1ExecMicro, MEM_X86TAG|EAX, 0); // Execute VU1 Micro SubRoutine
/*FreezeXMMRegs(0);*/
//x86SetJ8( j8Ptr[0] );
break;
default:
#ifdef __x86_64__
if( (mmreg = _checkX86reg(X86TYPE_VI, _Fs_, MODE_WRITE)) >= 0 )
_eeMoveGPRtoR(mmreg, _Rt_);
else
#else
_eeMoveGPRtoM((uptr)&VU0.VI[_Fs_].UL,_Rt_);
#endif
// a lot of games have vu0 spinning on some integer
// then they modify the register and expect vu0 to stop spinning within 10 cycles (donald duck)
iFlushCall(IS_X8664?(FLUSH_FREE_VU0|FLUSH_FREE_TEMPX86):FLUSH_NOCONST);
/*TEST32ItoM((uptr)&VU0.VI[REG_VPU_STAT].UL, 1);
j8Ptr[0] = JZ8(0);*/
#ifdef __x86_64__
_callFunctionArg1((uptr)FreezeXMMRegs_, MEM_CONSTTAG, 1);
#else
/*PUSH32I(1);
CALLFunc((uptr)FreezeXMMRegs_);*/
#endif
// CALLFunc((uptr)Cpu->ExecuteVU0Block);
#ifdef __x86_64__
_callFunctionArg1((uptr)FreezeXMMRegs_, MEM_CONSTTAG, 0);
#else
/*PUSH32I(0);
CALLFunc((uptr)FreezeXMMRegs_);*/
//ADD32ItoR(ESP, 4);
#endif
// x86SetJ8(j8Ptr[0]);
break;
}
}
}
static void recQMFC2(void)
{
int t0reg, fsreg;
_xmmregs temp;
if (cpuRegs.code & 1) {
iFlushCall(IS_X8664?(FLUSH_FREE_VU0|FLUSH_FREE_TEMPX86):FLUSH_NOCONST);
CALLFunc((uptr)_vu0WaitMicro);
}
if(!_Rt_) return;
#ifndef __x86_64__
_deleteMMXreg(MMX_GPR+_Rt_, 2);
#endif
_deleteX86reg(X86TYPE_GPR, _Rt_, 2);
_eeOnWriteReg(_Rt_, 0);
// could 'borrow' the reg
fsreg = _checkXMMreg(XMMTYPE_VFREG, _Fs_, MODE_READ);
if( fsreg >= 0 ) {
if( xmmregs[fsreg].mode & MODE_WRITE ) {
t0reg = _allocGPRtoXMMreg(-1, _Rt_, MODE_WRITE);
SSEX_MOVDQA_XMM_to_XMM(t0reg, fsreg);
// change regs
temp = xmmregs[t0reg];
xmmregs[t0reg] = xmmregs[fsreg];
xmmregs[fsreg] = temp;
}
else {
// swap regs
t0reg = _allocGPRtoXMMreg(-1, _Rt_, MODE_WRITE);
xmmregs[fsreg] = xmmregs[t0reg];
xmmregs[t0reg].inuse = 0;
}
}
else {
t0reg = _allocGPRtoXMMreg(-1, _Rt_, MODE_WRITE);
if( t0reg >= 0 ) {
SSE_MOVAPS_M128_to_XMM( t0reg, (uptr)&VU0.VF[_Fs_].UD[0]);
}
else {
_recMove128MtoM((uptr)&cpuRegs.GPR.r[_Rt_].UL[0], (uptr)&VU0.VF[_Fs_].UL[0]);
}
}
_clearNeededXMMregs();
}
static void recQMTC2()
{
int mmreg, fsreg;
if (cpuRegs.code & 1) {
iFlushCall(IS_X8664?(FLUSH_FREE_VU0|FLUSH_FREE_TEMPX86):FLUSH_NOCONST);
CALLFunc((uptr)_vu0WaitMicro);
}
if(!_Fs_) return;
if( (mmreg = _checkXMMreg(XMMTYPE_GPRREG, _Rt_, MODE_READ)) >= 0) {
fsreg = _checkXMMreg(XMMTYPE_VFREG, _Fs_, MODE_WRITE);
if( fsreg >= 0 ) {
if( (xmmregs[mmreg].mode&MODE_WRITE) && (g_pCurInstInfo->regs[_Rt_]&(EEINST_LIVE0|EEINST_LIVE1|EEINST_LIVE2)) ) {
SSE_MOVAPS_XMM_to_XMM(fsreg, mmreg);
}
else {
// swap regs
if( (xmmregs[mmreg].mode&MODE_WRITE) && (g_pCurInstInfo->regs[_Rt_]&(EEINST_LIVE0|EEINST_LIVE1|EEINST_LIVE2)) )
SSE_MOVAPS_XMM_to_M128((uptr)&cpuRegs.GPR.r[_Rt_], mmreg);
xmmregs[mmreg] = xmmregs[fsreg];
xmmregs[mmreg].mode = MODE_WRITE;
xmmregs[fsreg].inuse = 0;
g_xmmtypes[mmreg] = XMMT_FPS;
}
}
else {
if( (xmmregs[mmreg].mode&MODE_WRITE) && (g_pCurInstInfo->regs[_Rt_]&(EEINST_LIVE0|EEINST_LIVE1|EEINST_LIVE2)) )
SSE_MOVAPS_XMM_to_M128((uptr)&cpuRegs.GPR.r[_Rt_], mmreg);
// swap regs
xmmregs[mmreg].type = XMMTYPE_VFREG;
xmmregs[mmreg].VU = 0;
xmmregs[mmreg].reg = _Fs_;
xmmregs[mmreg].mode = MODE_WRITE;
g_xmmtypes[mmreg] = XMMT_FPS;
}
}
else {
fsreg = _allocVFtoXMMreg(&VU0, -1, _Fs_, MODE_WRITE);
if( fsreg >= 0 ) {
#ifdef __x86_64__
if( (mmreg = _checkX86reg(X86TYPE_GPR, _Rt_, MODE_READ)) >= 0) {
SSE2_MOVQ_R_to_XMM(fsreg, mmreg);
SSE_MOVHPS_M64_to_XMM(fsreg, (uptr)&cpuRegs.GPR.r[_Rt_].UL[2]);
}
#else
if( (mmreg = _checkMMXreg(MMX_GPR+_Rt_, MODE_READ)) >= 0) {
SetMMXstate();
SSE2_MOVQ2DQ_MM_to_XMM(fsreg, mmreg);
SSE_MOVHPS_M64_to_XMM(fsreg, (uptr)&cpuRegs.GPR.r[_Rt_].UL[2]);
}
#endif
else {
if( GPR_IS_CONST1( _Rt_ ) ) {
assert( _checkXMMreg(XMMTYPE_GPRREG, _Rt_, MODE_READ) == -1 );
_flushConstReg(_Rt_);
}
SSE_MOVAPS_M128_to_XMM(fsreg, (uptr)&cpuRegs.GPR.r[ _Rt_ ].UL[ 0 ]);
}
}
else {
_deleteEEreg(_Rt_, 0);
_recMove128MtoM((uptr)&VU0.VF[_Fs_].UL[0], (uptr)&cpuRegs.GPR.r[_Rt_].UL[0]);
}
}
_clearNeededXMMregs();
}
void _cop2AnalyzeOp(EEINST* pinst, int dostalls)
{
_vuRegsCOP22(&VU0, &pinst->vuregs);
if( !dostalls ) return;
_recvuTestLowerStalls(&VU0, &pinst->vuregs);
switch(VU0.code & 0x3f) {
case 0x10: case 0x11: case 0x12: case 0x13:
case 0x14: case 0x15: case 0x16: case 0x17:
case 0x1d: case 0x1f:
case 0x2b: case 0x2f:
break;
case 0x3c:
switch ((VU0.code >> 6) & 0x1f) {
case 0x4: case 0x5:
break;
default:
pinst->vuregs.VIwrite |= (1<<REG_MAC_FLAG);
break;
}
break;
case 0x3d:
switch ((VU0.code >> 6) & 0x1f) {
case 0x4: case 0x5: case 0x7:
break;
default:
pinst->vuregs.VIwrite |= (1<<REG_MAC_FLAG);
break;
}
break;
case 0x3e:
switch ((VU0.code >> 6) & 0x1f) {
case 0x4: case 0x5:
break;
default:
pinst->vuregs.VIwrite |= (1<<REG_MAC_FLAG);
break;
}
break;
case 0x3f:
switch ((VU0.code >> 6) & 0x1f) {
case 0x4: case 0x5: case 0x7: case 0xb:
break;
default:
pinst->vuregs.VIwrite |= (1<<REG_MAC_FLAG);
break;
}
break;
default:
pinst->vuregs.VIwrite |= (1<<REG_MAC_FLAG);
break;
}
if (pinst->vuregs.VIwrite & (1 << REG_CLIP_FLAG)) {
_recAddWriteBack(vucycle+4, 1<<REG_CLIP_FLAG, pinst);
}
if (pinst->vuregs.VIwrite & (1 << REG_Q)) {
_recAddWriteBack(vucycle+pinst->vuregs.cycles, 1<<REG_Q, pinst);
}
pinst->cycle = vucycle;
_recvuAddLowerStalls(&VU0, &pinst->vuregs);
_recvuTestPipes(&VU0);
vucycle++;
}
//////////////////////////////////////////////////////////////////////////
// BC2: Instructions
//////////////////////////////////////////////////////////////////////////
REC_COP2_FUNC(BC2F, 0);
REC_COP2_FUNC(BC2T, 0);
REC_COP2_FUNC(BC2FL, 0);
REC_COP2_FUNC(BC2TL, 0);
//////////////////////////////////////////////////////////////////////////
// Special1 instructions
//////////////////////////////////////////////////////////////////////////
//TODO: redirect all the opcodes to the ivu0micro same functions
REC_COP2_VU0(IADD);
REC_COP2_VU0(IADDI);
REC_COP2_VU0(ISUB);
REC_COP2_VU0(IOR);
REC_COP2_VU0(IAND);
REC_COP2_VU0(OPMSUB);
REC_COP2_VU0(MADDq);
REC_COP2_VU0(MADDi);
REC_COP2_VU0(MSUBq);
REC_COP2_VU0(MSUBi);
REC_COP2_VU0(SUBi);
REC_COP2_VU0(SUBq);
REC_COP2_VU0(MULi);
REC_COP2_VU0(MULq);
REC_COP2_VU0(MAXi);
REC_COP2_VU0(MINIi);
REC_COP2_VU0(MUL);
REC_COP2_VU0(MAX);
REC_COP2_VU0(MADD);
REC_COP2_VU0(MSUB);
REC_COP2_VU0(MINIx);
REC_COP2_VU0(MINIy);
REC_COP2_VU0(MINIz);
REC_COP2_VU0(MINIw);
REC_COP2_VU0(MAXx);
REC_COP2_VU0(MAXy);
REC_COP2_VU0(MAXz);
REC_COP2_VU0(MAXw);
REC_COP2_VU0(MULx);
REC_COP2_VU0(MULy);
REC_COP2_VU0(MULz);
REC_COP2_VU0(MULw);
REC_COP2_VU0(ADD);
REC_COP2_VU0(ADDi);
REC_COP2_VU0(ADDq);
REC_COP2_VU0(ADDx);
REC_COP2_VU0(ADDy);
REC_COP2_VU0(ADDz);
REC_COP2_VU0(ADDw);
REC_COP2_VU0(SUBx);
REC_COP2_VU0(SUBy);
REC_COP2_VU0(SUBz);
REC_COP2_VU0(SUBw);
REC_COP2_VU0(MADDx);
REC_COP2_VU0(MADDy);
REC_COP2_VU0(MADDz);
REC_COP2_VU0(MADDw);
REC_COP2_VU0(MSUBx);
REC_COP2_VU0(MSUBy);
REC_COP2_VU0(MSUBz);
REC_COP2_VU0(MSUBw);
REC_COP2_VU0(SUB);
REC_COP2_VU0(MINI);
//////////////////////////////////////////////////////////////////////////
// Special2 instructions
//////////////////////////////////////////////////////////////////////////
REC_COP2_VU0(CLIP);
REC_COP2_VU0(LQI);
REC_COP2_VU0(SQI);
REC_COP2_VU0(LQD);
REC_COP2_VU0(SQD);
REC_COP2_VU0(MTIR);
REC_COP2_VU0(MFIR);
REC_COP2_VU0(ILWR);
REC_COP2_VU0(ISWR);
REC_COP2_VU0(RINIT);
REC_COP2_VU0(RXOR);
REC_COP2_VU0(RNEXT);
REC_COP2_VU0(RGET);
REC_COP2_VU0(ITOF0);
REC_COP2_VU0(ITOF4);
REC_COP2_VU0(ITOF12);
REC_COP2_VU0(ITOF15);
REC_COP2_VU0(FTOI0);
REC_COP2_VU0(FTOI4);
REC_COP2_VU0(FTOI12);
REC_COP2_VU0(FTOI15);
REC_COP2_VU0(MADDA);
REC_COP2_VU0(MSUBA);
REC_COP2_VU0(MADDAi);
REC_COP2_VU0(MADDAq);
REC_COP2_VU0(MADDAx);
REC_COP2_VU0(MADDAy);
REC_COP2_VU0(MADDAz);
REC_COP2_VU0(MADDAw);
REC_COP2_VU0(MSUBAi);
REC_COP2_VU0(MSUBAq);
REC_COP2_VU0(MSUBAx);
REC_COP2_VU0(MSUBAy);
REC_COP2_VU0(MSUBAz);
REC_COP2_VU0(MSUBAw);
REC_COP2_VU0(ADDAi);
REC_COP2_VU0(ADDA);
REC_COP2_VU0(SUBA);
REC_COP2_VU0(MULA);
REC_COP2_VU0(ADDAq);
REC_COP2_VU0(ADDAx);
REC_COP2_VU0(ADDAy);
REC_COP2_VU0(ADDAz);
REC_COP2_VU0(ADDAw);
REC_COP2_VU0(SUBAi);
REC_COP2_VU0(SUBAq);
REC_COP2_VU0(SUBAx);
REC_COP2_VU0(SUBAy);
REC_COP2_VU0(SUBAz);
REC_COP2_VU0(SUBAw);
REC_COP2_VU0(MULAi);
REC_COP2_VU0(MULAq);
REC_COP2_VU0(MULAx);
REC_COP2_VU0(MULAy);
REC_COP2_VU0(MULAz);
REC_COP2_VU0(MULAw);
REC_COP2_VU0(OPMULA);
REC_COP2_VU0(MOVE);
REC_COP2_VU0_Q(DIV);
REC_COP2_VU0_Q(SQRT);
REC_COP2_VU0_Q(RSQRT);
REC_COP2_VU0(MR32);
REC_COP2_VU0(ABS);
void recVNOP(){}
void recVWAITQ(){}
INTERPRETATE_COP2_FUNC(CALLMS);
INTERPRETATE_COP2_FUNC(CALLMSR);
void _vuRegsCOP2_SPECIAL(VURegs * VU, _VURegsNum *VUregsn);
void _vuRegsCOP2_SPECIAL2(VURegs * VU, _VURegsNum *VUregsn);
// information
void _vuRegsQMFC2(VURegs * VU, _VURegsNum *VUregsn) {
VUregsn->VFread0 = _Fs_;
VUregsn->VFr0xyzw= 0xf;
}
void _vuRegsCFC2(VURegs * VU, _VURegsNum *VUregsn) {
VUregsn->VIread = 1<<_Fs_;
}
void _vuRegsQMTC2(VURegs * VU, _VURegsNum *VUregsn) {
VUregsn->VFwrite = _Fs_;
VUregsn->VFwxyzw= 0xf;
}
void _vuRegsCTC2(VURegs * VU, _VURegsNum *VUregsn) {
VUregsn->VIwrite = 1<<_Fs_;
}
void (*_vuRegsCOP2t[32])(VURegs * VU, _VURegsNum *VUregsn) = {
_vuRegs_C2UNK, _vuRegsQMFC2, _vuRegsCFC2, _vuRegs_C2UNK, _vuRegs_C2UNK, _vuRegsQMTC2, _vuRegsCTC2, _vuRegs_C2UNK,
_vuRegsNOP, _vuRegs_C2UNK, _vuRegs_C2UNK, _vuRegs_C2UNK, _vuRegs_C2UNK, _vuRegs_C2UNK, _vuRegs_C2UNK, _vuRegs_C2UNK,
_vuRegsCOP2_SPECIAL,_vuRegsCOP2_SPECIAL,_vuRegsCOP2_SPECIAL,_vuRegsCOP2_SPECIAL,_vuRegsCOP2_SPECIAL,_vuRegsCOP2_SPECIAL,_vuRegsCOP2_SPECIAL,_vuRegsCOP2_SPECIAL,
_vuRegsCOP2_SPECIAL,_vuRegsCOP2_SPECIAL,_vuRegsCOP2_SPECIAL,_vuRegsCOP2_SPECIAL,_vuRegsCOP2_SPECIAL,_vuRegsCOP2_SPECIAL,_vuRegsCOP2_SPECIAL,_vuRegsCOP2_SPECIAL,
};
void (*_vuRegsCOP2SPECIAL1t[64])(VURegs * VU, _VURegsNum *VUregsn) = {
_vuRegsADDx, _vuRegsADDy, _vuRegsADDz, _vuRegsADDw, _vuRegsSUBx, _vuRegsSUBy, _vuRegsSUBz, _vuRegsSUBw,
_vuRegsMADDx, _vuRegsMADDy, _vuRegsMADDz, _vuRegsMADDw, _vuRegsMSUBx, _vuRegsMSUBy, _vuRegsMSUBz, _vuRegsMSUBw,
_vuRegsMAXx, _vuRegsMAXy, _vuRegsMAXz, _vuRegsMAXw, _vuRegsMINIx, _vuRegsMINIy, _vuRegsMINIz, _vuRegsMINIw,
_vuRegsMULx, _vuRegsMULy, _vuRegsMULz, _vuRegsMULw, _vuRegsMULq, _vuRegsMAXi, _vuRegsMULi, _vuRegsMINIi,
_vuRegsADDq, _vuRegsMADDq, _vuRegsADDi, _vuRegsMADDi, _vuRegsSUBq, _vuRegsMSUBq, _vuRegsSUBi, _vuRegsMSUBi,
_vuRegsADD, _vuRegsMADD, _vuRegsMUL, _vuRegsMAX, _vuRegsSUB, _vuRegsMSUB, _vuRegsOPMSUB, _vuRegsMINI,
_vuRegsIADD, _vuRegsISUB, _vuRegsIADDI, _vuRegs_C2UNK, _vuRegsIAND, _vuRegsIOR, _vuRegs_C2UNK, _vuRegs_C2UNK,
_vuRegsNOP, _vuRegsNOP, _vuRegs_C2UNK, _vuRegs_C2UNK, _vuRegsCOP2_SPECIAL2,_vuRegsCOP2_SPECIAL2,_vuRegsCOP2_SPECIAL2,_vuRegsCOP2_SPECIAL2,
};
void (*_vuRegsCOP2SPECIAL2t[128])(VURegs * VU, _VURegsNum *VUregsn) = {
_vuRegsADDAx ,_vuRegsADDAy ,_vuRegsADDAz ,_vuRegsADDAw ,_vuRegsSUBAx ,_vuRegsSUBAy ,_vuRegsSUBAz ,_vuRegsSUBAw,
_vuRegsMADDAx ,_vuRegsMADDAy ,_vuRegsMADDAz ,_vuRegsMADDAw ,_vuRegsMSUBAx ,_vuRegsMSUBAy ,_vuRegsMSUBAz ,_vuRegsMSUBAw,
_vuRegsITOF0 ,_vuRegsITOF4 ,_vuRegsITOF12 ,_vuRegsITOF15 ,_vuRegsFTOI0 ,_vuRegsFTOI4 ,_vuRegsFTOI12 ,_vuRegsFTOI15,
_vuRegsMULAx ,_vuRegsMULAy ,_vuRegsMULAz ,_vuRegsMULAw ,_vuRegsMULAq ,_vuRegsABS ,_vuRegsMULAi ,_vuRegsCLIP,
_vuRegsADDAq ,_vuRegsMADDAq ,_vuRegsADDAi ,_vuRegsMADDAi ,_vuRegsSUBAq ,_vuRegsMSUBAq ,_vuRegsSUBAi ,_vuRegsMSUBAi,
_vuRegsADDA ,_vuRegsMADDA ,_vuRegsMULA ,_vuRegs_C2UNK ,_vuRegsSUBA ,_vuRegsMSUBA ,_vuRegsOPMULA ,_vuRegsNOP,
_vuRegsMOVE ,_vuRegsMR32 ,_vuRegs_C2UNK ,_vuRegs_C2UNK ,_vuRegsLQI ,_vuRegsSQI ,_vuRegsLQD ,_vuRegsSQD,
_vuRegsDIV ,_vuRegsSQRT ,_vuRegsRSQRT ,_vuRegsWAITQ ,_vuRegsMTIR ,_vuRegsMFIR ,_vuRegsILWR ,_vuRegsISWR,
_vuRegsRNEXT ,_vuRegsRGET ,_vuRegsRINIT ,_vuRegsRXOR ,_vuRegs_C2UNK ,_vuRegs_C2UNK ,_vuRegs_C2UNK ,_vuRegs_C2UNK,
_vuRegs_C2UNK ,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,
_vuRegs_C2UNK ,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,
_vuRegs_C2UNK ,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,
_vuRegs_C2UNK ,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,
_vuRegs_C2UNK ,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,
_vuRegs_C2UNK ,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,
_vuRegs_C2UNK ,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,_vuRegs_C2UNK,
};
void _vuRegsCOP22(VURegs * VU, _VURegsNum *VUregsn)
{
_vuRegsCOP2t[_Rs_](VU, VUregsn);
}
void _vuRegsCOP2_SPECIAL(VURegs * VU, _VURegsNum *VUregsn)
{
_vuRegsCOP2SPECIAL1t[_Funct_](VU, VUregsn);
}
void _vuRegsCOP2_SPECIAL2(VURegs * VU, _VURegsNum *VUregsn)
{
int opc=(cpuRegs.code & 0x3) | ((cpuRegs.code >> 4) & 0x7c);
_vuRegsCOP2SPECIAL2t[opc](VU, VUregsn);
}
// recompilation
void (*recCOP2t[32])() = {
rec_C2UNK, recQMFC2, recCFC2, rec_C2UNK, rec_C2UNK, recQMTC2, recCTC2, rec_C2UNK,
recCOP2_BC2, rec_C2UNK, rec_C2UNK, rec_C2UNK, rec_C2UNK, rec_C2UNK, rec_C2UNK, rec_C2UNK,
recCOP2_SPECIAL,recCOP2_SPECIAL,recCOP2_SPECIAL,recCOP2_SPECIAL,recCOP2_SPECIAL,recCOP2_SPECIAL,recCOP2_SPECIAL,recCOP2_SPECIAL,
recCOP2_SPECIAL,recCOP2_SPECIAL,recCOP2_SPECIAL,recCOP2_SPECIAL,recCOP2_SPECIAL,recCOP2_SPECIAL,recCOP2_SPECIAL,recCOP2_SPECIAL,
};
void (*recCOP2_BC2t[32])() = {
recBC2F, recBC2T, recBC2FL, recBC2TL, rec_C2UNK, rec_C2UNK, rec_C2UNK, rec_C2UNK,
rec_C2UNK, rec_C2UNK, rec_C2UNK, rec_C2UNK, rec_C2UNK, rec_C2UNK, rec_C2UNK, rec_C2UNK,
rec_C2UNK, rec_C2UNK, rec_C2UNK, rec_C2UNK, rec_C2UNK, rec_C2UNK, rec_C2UNK, rec_C2UNK,
rec_C2UNK, rec_C2UNK, rec_C2UNK, rec_C2UNK, rec_C2UNK, rec_C2UNK, rec_C2UNK, rec_C2UNK,
};
void (*recCOP2SPECIAL1t[64])() = {
recVADDx, recVADDy, recVADDz, recVADDw, recVSUBx, recVSUBy, recVSUBz, recVSUBw,
recVMADDx, recVMADDy, recVMADDz, recVMADDw, recVMSUBx, recVMSUBy, recVMSUBz, recVMSUBw,
recVMAXx, recVMAXy, recVMAXz, recVMAXw, recVMINIx, recVMINIy, recVMINIz, recVMINIw,
recVMULx, recVMULy, recVMULz, recVMULw, recVMULq, recVMAXi, recVMULi, recVMINIi,
recVADDq, recVMADDq, recVADDi, recVMADDi, recVSUBq, recVMSUBq, recVSUBi, recVMSUBi,
recVADD, recVMADD, recVMUL, recVMAX, recVSUB, recVMSUB, recVOPMSUB, recVMINI,
recVIADD, recVISUB, recVIADDI, rec_C2UNK, recVIAND, recVIOR, rec_C2UNK, rec_C2UNK,
recVCALLMS, recVCALLMSR, rec_C2UNK, rec_C2UNK, recCOP2_SPECIAL2,recCOP2_SPECIAL2,recCOP2_SPECIAL2,recCOP2_SPECIAL2,
};
void (*recCOP2SPECIAL2t[128])() = {
recVADDAx ,recVADDAy ,recVADDAz ,recVADDAw ,recVSUBAx ,recVSUBAy ,recVSUBAz ,recVSUBAw,
recVMADDAx ,recVMADDAy ,recVMADDAz ,recVMADDAw ,recVMSUBAx ,recVMSUBAy ,recVMSUBAz ,recVMSUBAw,
recVITOF0 ,recVITOF4 ,recVITOF12 ,recVITOF15 ,recVFTOI0 ,recVFTOI4 ,recVFTOI12 ,recVFTOI15,
recVMULAx ,recVMULAy ,recVMULAz ,recVMULAw ,recVMULAq ,recVABS ,recVMULAi ,recVCLIP,
recVADDAq ,recVMADDAq ,recVADDAi ,recVMADDAi ,recVSUBAq ,recVMSUBAq ,recVSUBAi ,recVMSUBAi,
recVADDA ,recVMADDA ,recVMULA ,rec_C2UNK ,recVSUBA ,recVMSUBA ,recVOPMULA ,recVNOP,
recVMOVE ,recVMR32 ,rec_C2UNK ,rec_C2UNK ,recVLQI ,recVSQI ,recVLQD ,recVSQD,
recVDIV ,recVSQRT ,recVRSQRT ,recVWAITQ ,recVMTIR ,recVMFIR ,recVILWR ,recVISWR,
recVRNEXT ,recVRGET ,recVRINIT ,recVRXOR ,rec_C2UNK ,rec_C2UNK ,rec_C2UNK ,rec_C2UNK,
rec_C2UNK ,rec_C2UNK,rec_C2UNK,rec_C2UNK,rec_C2UNK,rec_C2UNK,rec_C2UNK,rec_C2UNK,
rec_C2UNK ,rec_C2UNK,rec_C2UNK,rec_C2UNK,rec_C2UNK,rec_C2UNK,rec_C2UNK,rec_C2UNK,
rec_C2UNK ,rec_C2UNK,rec_C2UNK,rec_C2UNK,rec_C2UNK,rec_C2UNK,rec_C2UNK,rec_C2UNK,
rec_C2UNK ,rec_C2UNK,rec_C2UNK,rec_C2UNK,rec_C2UNK,rec_C2UNK,rec_C2UNK,rec_C2UNK,
rec_C2UNK ,rec_C2UNK,rec_C2UNK,rec_C2UNK,rec_C2UNK,rec_C2UNK,rec_C2UNK,rec_C2UNK,
rec_C2UNK ,rec_C2UNK,rec_C2UNK,rec_C2UNK,rec_C2UNK,rec_C2UNK,rec_C2UNK,rec_C2UNK,
rec_C2UNK ,rec_C2UNK,rec_C2UNK,rec_C2UNK,rec_C2UNK,rec_C2UNK,rec_C2UNK,rec_C2UNK,
};
void recCOP22()
{
cinfo = &g_cop2info;
g_VUregs = &g_pCurInstInfo->vuregs;
VU0.code = cpuRegs.code;
g_pCurInstInfo->vuregs.pipe = 0xff; // to notify eeVURecompileCode that COP2
recCOP2t[_Rs_]();
#ifndef __x86_64__
_freeX86regs();
#endif
}
void recCOP2_SPECIAL()
{
recCOP2SPECIAL1t[_Funct_]();
}
void recCOP2_BC2()
{
recCOP2_BC2t[_Rt_]();
}
void recCOP2_SPECIAL2()
{
int opc=(cpuRegs.code & 0x3) | ((cpuRegs.code >> 4) & 0x7c);
recCOP2SPECIAL2t[opc]();
}
| [
"saqibakhtar@23c756db-88ba-2448-99d7-e6e4c676ec84"
] | [
[
[
1,
877
]
]
] |
eca8e679977c15bfd77cfd4c029989a2591ddaab | 3182b05c41f13237825f1ee59d7a0eba09632cd5 | /T3D/fx/particle.cpp | 4a7e1cabb6537f46614ea7a3c485f2168247151b | [] | no_license | adhistac/ee-client-2-0 | 856e8e6ce84bfba32ddd8b790115956a763eec96 | d225fc835fa13cb51c3e0655cb025eba24a8cdac | refs/heads/master | 2021-01-17T17:13:48.618988 | 2010-01-04T17:35:12 | 2010-01-04T17:35:12 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 18,187 | cpp | //-----------------------------------------------------------------------------
// Torque 3D
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
#include "particle.h"
#include "console/consoleTypes.h"
#include "core/stream/bitStream.h"
#include "math/mRandom.h"
#include "math/mathIO.h"
static ParticleData gDefaultParticleData;
IMPLEMENT_CO_DATABLOCK_V1(ParticleData);
//-----------------------------------------------------------------------------
// Constructor
//-----------------------------------------------------------------------------
ParticleData::ParticleData()
{
dragCoefficient = 0.0f;
windCoefficient = 1.0f;
gravityCoefficient = 0.0f;
inheritedVelFactor = 0.0f;
constantAcceleration = 0.0f;
lifetimeMS = 1000;
lifetimeVarianceMS = 0;
spinSpeed = 1.0;
spinRandomMin = 0.0;
spinRandomMax = 0.0;
useInvAlpha = false;
animateTexture = false;
numFrames = 1;
framesPerSec = numFrames;
S32 i;
for( i=0; i<PDC_NUM_KEYS; i++ )
{
colors[i].set( 1.0, 1.0, 1.0, 1.0 );
sizes[i] = 1.0;
}
times[0] = 0.0f;
times[1] = 1.0f;
times[2] = 2.0f;
times[3] = 2.0f;
texCoords[0].set(0.0,0.0); // texture coords at 4 corners
texCoords[1].set(0.0,1.0); // of particle quad
texCoords[2].set(1.0,1.0); // (defaults to entire particle)
texCoords[3].set(1.0,0.0);
animTexTiling.set(0,0); // tiling dimensions
animTexFramesString = NULL; // string of animation frame indices
animTexUVs = NULL; // array of tile vertex UVs
textureName = NULL; // texture filename
textureHandle = NULL; // loaded texture handle
}
//-----------------------------------------------------------------------------
// Destructor
//-----------------------------------------------------------------------------
ParticleData::~ParticleData()
{
if (animTexUVs)
{
delete [] animTexUVs;
}
}
//-----------------------------------------------------------------------------
// initPersistFields
//-----------------------------------------------------------------------------
void ParticleData::initPersistFields()
{
addField("dragCoefficient", TypeF32, Offset(dragCoefficient, ParticleData));
addField("windCoefficient", TypeF32, Offset(windCoefficient, ParticleData));
addField("gravityCoefficient", TypeF32, Offset(gravityCoefficient, ParticleData));
addField("inheritedVelFactor", TypeF32, Offset(inheritedVelFactor, ParticleData));
addField("constantAcceleration", TypeF32, Offset(constantAcceleration, ParticleData));
addField("lifetimeMS", TypeS32, Offset(lifetimeMS, ParticleData));
addField("lifetimeVarianceMS", TypeS32, Offset(lifetimeVarianceMS, ParticleData));
addField("spinSpeed", TypeF32, Offset(spinSpeed, ParticleData));
addField("spinRandomMin", TypeF32, Offset(spinRandomMin, ParticleData));
addField("spinRandomMax", TypeF32, Offset(spinRandomMax, ParticleData));
addField("useInvAlpha", TypeBool, Offset(useInvAlpha, ParticleData));
addField("animateTexture", TypeBool, Offset(animateTexture, ParticleData));
addField("framesPerSec", TypeS32, Offset(framesPerSec, ParticleData));
addField("textureCoords", TypePoint2F, Offset(texCoords, ParticleData), 4);
addField("animTexTiling", TypePoint2I, Offset(animTexTiling, ParticleData));
addField("animTexFrames", TypeString, Offset(animTexFramesString,ParticleData));
addField("textureName", TypeFilename, Offset(textureName, ParticleData));
addField("animTexName", TypeFilename, Offset(textureName, ParticleData));
// Interpolation variables
addField("colors", TypeColorF, Offset(colors, ParticleData), PDC_NUM_KEYS );
addField("sizes", TypeF32, Offset(sizes, ParticleData), PDC_NUM_KEYS );
addField("times", TypeF32, Offset(times, ParticleData), PDC_NUM_KEYS );
Parent::initPersistFields();
}
//-----------------------------------------------------------------------------
// Pack data
//-----------------------------------------------------------------------------
void ParticleData::packData(BitStream* stream)
{
Parent::packData(stream);
stream->writeFloat(dragCoefficient / 5, 10);
if(stream->writeFlag(windCoefficient != gDefaultParticleData.windCoefficient))
stream->write(windCoefficient);
if (stream->writeFlag(gravityCoefficient != 0.0f))
stream->writeSignedFloat(gravityCoefficient / 10, 12);
stream->writeFloat(inheritedVelFactor, 9);
if(stream->writeFlag(constantAcceleration != gDefaultParticleData.constantAcceleration))
stream->write(constantAcceleration);
stream->write( lifetimeMS );
stream->write( lifetimeVarianceMS );
if(stream->writeFlag(spinSpeed != gDefaultParticleData.spinSpeed))
stream->write(spinSpeed);
if(stream->writeFlag(spinRandomMin != gDefaultParticleData.spinRandomMin || spinRandomMax != gDefaultParticleData.spinRandomMax))
{
stream->writeInt((S32)(spinRandomMin + 1000), 11);
stream->writeInt((S32)(spinRandomMax + 1000), 11);
}
stream->writeFlag(useInvAlpha);
S32 i, count;
// see how many frames there are:
for(count = 0; count < 3; count++)
if(times[count] >= 1)
break;
count++;
stream->writeInt(count-1, 2);
for( i=0; i<count; i++ )
{
stream->writeFloat( colors[i].red, 7);
stream->writeFloat( colors[i].green, 7);
stream->writeFloat( colors[i].blue, 7);
stream->writeFloat( colors[i].alpha, 7);
stream->writeFloat( sizes[i]/MaxParticleSize, 14);
stream->writeFloat( times[i], 8);
}
if (stream->writeFlag(textureName && textureName[0]))
stream->writeString(textureName);
for (i = 0; i < 4; i++)
mathWrite(*stream, texCoords[i]);
if (stream->writeFlag(animateTexture))
{
if (stream->writeFlag(animTexFramesString && animTexFramesString[0]))
{
stream->writeString(animTexFramesString);
}
mathWrite(*stream, animTexTiling);
stream->writeInt(framesPerSec, 8);
}
}
//-----------------------------------------------------------------------------
// Unpack data
//-----------------------------------------------------------------------------
void ParticleData::unpackData(BitStream* stream)
{
Parent::unpackData(stream);
dragCoefficient = stream->readFloat(10) * 5;
if(stream->readFlag())
stream->read(&windCoefficient);
else
windCoefficient = gDefaultParticleData.windCoefficient;
if (stream->readFlag())
gravityCoefficient = stream->readSignedFloat(12)*10;
else
gravityCoefficient = 0.0f;
inheritedVelFactor = stream->readFloat(9);
if(stream->readFlag())
stream->read(&constantAcceleration);
else
constantAcceleration = gDefaultParticleData.constantAcceleration;
stream->read( &lifetimeMS );
stream->read( &lifetimeVarianceMS );
if(stream->readFlag())
stream->read(&spinSpeed);
else
spinSpeed = gDefaultParticleData.spinSpeed;
if(stream->readFlag())
{
spinRandomMin = (F32)(stream->readInt(11) - 1000);
spinRandomMax = (F32)(stream->readInt(11) - 1000);
}
else
{
spinRandomMin = gDefaultParticleData.spinRandomMin;
spinRandomMax = gDefaultParticleData.spinRandomMax;
}
useInvAlpha = stream->readFlag();
S32 i;
S32 count = stream->readInt(2) + 1;
for(i = 0;i < count; i++)
{
colors[i].red = stream->readFloat(7);
colors[i].green = stream->readFloat(7);
colors[i].blue = stream->readFloat(7);
colors[i].alpha = stream->readFloat(7);
sizes[i] = stream->readFloat(14) * MaxParticleSize;
times[i] = stream->readFloat(8);
}
textureName = (stream->readFlag()) ? stream->readSTString() : 0;
for (i = 0; i < 4; i++)
mathRead(*stream, &texCoords[i]);
animateTexture = stream->readFlag();
if (animateTexture)
{
animTexFramesString = (stream->readFlag()) ? stream->readSTString() : 0;
mathRead(*stream, &animTexTiling);
framesPerSec = stream->readInt(8);
}
}
//-----------------------------------------------------------------------------
// onAdd
//-----------------------------------------------------------------------------
bool ParticleData::onAdd()
{
if (Parent::onAdd() == false)
return false;
if (dragCoefficient < 0.0) {
Con::warnf(ConsoleLogEntry::General, "ParticleData(%s) drag coeff less than 0", getName());
dragCoefficient = 0.0f;
}
if (lifetimeMS < 1) {
Con::warnf(ConsoleLogEntry::General, "ParticleData(%s) lifetime < 1 ms", getName());
lifetimeMS = 1;
}
if (lifetimeVarianceMS >= lifetimeMS) {
Con::warnf(ConsoleLogEntry::General, "ParticleData(%s) lifetimeVariance >= lifetime", getName());
lifetimeVarianceMS = lifetimeMS - 1;
}
if (spinSpeed > 10000.0 || spinSpeed < -10000.0) {
Con::warnf(ConsoleLogEntry::General, "ParticleData(%s) spinSpeed invalid", getName());
return false;
}
if (spinRandomMin > 10000.0 || spinRandomMin < -10000.0) {
Con::warnf(ConsoleLogEntry::General, "ParticleData(%s) spinRandomMin invalid", getName());
spinRandomMin = -360.0;
return false;
}
if (spinRandomMin > spinRandomMax) {
Con::warnf(ConsoleLogEntry::General, "ParticleData(%s) spinRandomMin greater than spinRandomMax", getName());
spinRandomMin = spinRandomMax - (spinRandomMin - spinRandomMax );
return false;
}
if (spinRandomMax > 10000.0 || spinRandomMax < -10000.0) {
Con::warnf(ConsoleLogEntry::General, "ParticleData(%s) spinRandomMax invalid", getName());
spinRandomMax = 360.0;
return false;
}
if (framesPerSec > 255)
{
Con::warnf(ConsoleLogEntry::General, "ParticleData(%s) framesPerSec > 255, too high", getName());
framesPerSec = 255;
return false;
}
times[0] = 0.0f;
for (U32 i = 1; i < 4; i++) {
if (times[i] < times[i-1]) {
Con::warnf(ConsoleLogEntry::General, "ParticleData(%s) times[%d] < times[%d]", getName(), i, i-1);
times[i] = times[i-1];
}
}
// Here we validate parameters
if (animateTexture)
{
// Tiling dimensions must be positive and non-zero
if (animTexTiling.x <= 0 || animTexTiling.y <= 0)
{
Con::warnf(ConsoleLogEntry::General,
"ParticleData(%s) bad value(s) for animTexTiling [%d or %d <= 0], invalid datablock",
animTexTiling.x, animTexTiling.y, getName());
return false;
}
// Indices must fit into a byte so these are also bad
if (animTexTiling.x * animTexTiling.y > 256)
{
Con::warnf(ConsoleLogEntry::General,
"ParticleData(%s) bad values for animTexTiling [%d*%d > %d], invalid datablock",
animTexTiling.x, animTexTiling.y, 256, getName());
return false;
}
// A list of frames is required
if (!animTexFramesString || !animTexFramesString[0])
{
Con::warnf(ConsoleLogEntry::General, "ParticleData(%s) no animTexFrames, invalid datablock", getName());
return false;
}
// The frame list cannot be too long.
if (animTexFramesString && dStrlen(animTexFramesString) > 255)
{
Con::errorf(ConsoleLogEntry::General, "ParticleData(%s) animTexFrames string too long [> 255 chars]", getName());
return false;
}
}
return true;
}
//-----------------------------------------------------------------------------
// preload
//-----------------------------------------------------------------------------
bool ParticleData::preload(bool server, String &errorStr)
{
if (Parent::preload(server, errorStr) == false)
return false;
bool error = false;
#ifdef CLIENT_ONLY_CODE
#else
if(!server)
#endif
{
// Here we attempt to load the particle's texture if specified. An undefined
// texture is *not* an error since the emitter may provide one.
if (textureName && textureName[0])
{
textureHandle = GFXTexHandle(textureName, &GFXDefaultStaticDiffuseProfile, avar("%s() - textureHandle (line %d)", __FUNCTION__, __LINE__));
if (!textureHandle)
{
errorStr = String::ToString("Missing particle texture: %s", textureName);
error = true;
}
}
if (animateTexture)
{
// Here we parse animTexFramesString into byte-size frame numbers in animTexFrames.
// Each frame token must be separated by whitespace.
// A frame token must be a positve integer frame number or a range of frame numbers
// separated with a '-'.
// The range separator, '-', cannot have any whitspace around it.
// Ranges can be specified to move through the frames in reverse as well as forward.
// Frame numbers exceeding the number of tiles will wrap.
// example:
// "0-16 20 19 18 17 31-21"
S32 n_tiles = animTexTiling.x * animTexTiling.y;
AssertFatal(n_tiles > 0 && n_tiles <= 256, "Error, bad animTexTiling setting." );
animTexFrames.clear();
char* tokCopy = new char[dStrlen(animTexFramesString) + 1];
dStrcpy(tokCopy, animTexFramesString);
char* currTok = dStrtok(tokCopy, " \t");
while (currTok != NULL)
{
char* minus = dStrchr(currTok, '-');
if (minus)
{
// add a range of frames
*minus = '\0';
S32 range_a = dAtoi(currTok);
S32 range_b = dAtoi(minus+1);
if (range_b < range_a)
{
// reverse frame range
for (S32 i = range_a; i >= range_b; i--)
animTexFrames.push_back((U8)(i % n_tiles));
}
else
{
// forward frame range
for (S32 i = range_a; i <= range_b; i++)
animTexFrames.push_back((U8)(i % n_tiles));
}
}
else
{
// add one frame
animTexFrames.push_back((U8)(dAtoi(currTok) % n_tiles));
}
currTok = dStrtok(NULL, " \t");
}
// Here we pre-calculate the UVs for each frame tile, which are
// tiled inside the UV region specified by texCoords. Since the
// UVs are calculated using bilinear interpolation, the texCoords
// region does *not* have to be an axis-aligned rectangle.
if (animTexUVs)
delete [] animTexUVs;
animTexUVs = new Point2F[(animTexTiling.x+1)*(animTexTiling.y+1)];
// interpolate points on the left and right edge of the uv quadrangle
Point2F lf_pt = texCoords[0];
Point2F rt_pt = texCoords[3];
// per-row delta for left and right interpolated points
Point2F lf_d = (texCoords[1] - texCoords[0])/(F32)animTexTiling.y;
Point2F rt_d = (texCoords[2] - texCoords[3])/(F32)animTexTiling.y;
S32 idx = 0;
for (S32 yy = 0; yy <= animTexTiling.y; yy++)
{
Point2F p = lf_pt;
Point2F dp = (rt_pt - lf_pt)/(F32)animTexTiling.x;
for (S32 xx = 0; xx <= animTexTiling.x; xx++)
{
animTexUVs[idx++] = p;
p += dp;
}
lf_pt += lf_d;
rt_pt += rt_d;
}
// cleanup
delete [] tokCopy;
numFrames = animTexFrames.size();
}
}
return !error;
}
//-----------------------------------------------------------------------------
// Initialize particle
//-----------------------------------------------------------------------------
void ParticleData::initializeParticle(Particle* init, const Point3F& inheritVelocity)
{
init->dataBlock = this;
// Calculate the constant accleration...
init->vel += inheritVelocity * inheritedVelFactor;
init->acc = init->vel * constantAcceleration;
// Calculate this instance's lifetime...
init->totalLifetime = lifetimeMS;
if (lifetimeVarianceMS != 0)
init->totalLifetime += S32(gRandGen.randI() % (2 * lifetimeVarianceMS + 1)) - S32(lifetimeVarianceMS);
// assign spin amount
init->spinSpeed = spinSpeed * gRandGen.randF( spinRandomMin, spinRandomMax );
}
bool ParticleData::reload(char errorBuffer[256])
{
bool error = false;
if (textureName && textureName[0])
{
textureHandle = GFXTexHandle(textureName, &GFXDefaultStaticDiffuseProfile, avar("%s() - textureHandle (line %d)", __FUNCTION__, __LINE__));
if (!textureHandle)
{
dSprintf(errorBuffer, 256, "Missing particle texture: %s", textureName);
error = true;
}
}
/*
numFrames = 0;
for( int i=0; i<PDC_MAX_TEX; i++ )
{
if( textureNameList[i] && textureNameList[i][0] )
{
textureList[i] = TextureHandle( textureNameList[i], MeshTexture );
if (!textureList[i].getName())
{
dSprintf(errorBuffer, 256, "Missing particle texture: %s", textureNameList[i]);
error = true;
}
numFrames++;
}
}
*/
return !error;
}
ConsoleMethod(ParticleData, reload, void, 2, 2, "(void)"
"Reloads this particle")
{
char errorBuffer[256];
object->reload(errorBuffer);
}
| [
"[email protected]"
] | [
[
[
1,
503
]
]
] |
23e84d4f5b8494812f3556544058f82ee4638260 | 8fb9ccf49a324a586256bb08c22edc92e23affcf | /src/Engine/Adsr.h | 25af00f05ab03d52fa85cd4e04234e3001f96f83 | [] | no_license | eriser/tal-noisemak3r | 76468c98db61dfa28315284b4a5b1acfeb9c1ff6 | 1043c8f237741ea7beb89b5bd26243f8891cb037 | refs/heads/master | 2021-01-18T18:29:56.446225 | 2010-08-05T20:51:35 | 2010-08-05T20:51:35 | 62,891,642 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,301 | h | /*
==============================================================================
This file is part of Tal-NoiseMaker by Patrick Kunz.
Copyright(c) 2005-2010 Patrick Kunz, TAL
Togu Audio Line, Inc.
http://kunz.corrupt.ch
This file may be licensed under the terms of of the
GNU General Public License Version 2 (the ``GPL'').
Software distributed under the License is distributed
on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
express or implied. See the GPL for the specific language
governing rights and limitations.
You should have received a copy of the GPL along with this
program. If not, go to http://www.gnu.org/licenses/gpl.html
or write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
==============================================================================
*/
#if !defined(__ADSR_h)
#define __ADSR_h
class Adsr
{
private:
float attackReal;
float attack;
float decayReal;
float decay;
float sustainReal;
float sustain;
float release;
float sampleRateFactor;
float tmp;
int state;
float actualValue;
public:
Adsr(float sampleRate)
{
state = 0;
actualValue = 0.0f;
sampleRateFactor = 0.004f * 44100.0f / sampleRate;
attack = 0.0f;
decay = 0.0f;
sustain = 1.0f;
release = 0.0f;
sustainReal = 1.0f;
decayReal = 0.0f;
attackReal = 0.0f;
}
private:
float scaleValue(float value)
{
value = 1.0f - value * 0.5f;
return 0.0003f * sampleRateFactor + sampleRateFactor * powf(value, 22.0f) * 2.0f;
}
float scaleValueAttack(float value)
{
value = 1.0f - value * 0.5f;
return 0.0003f * sampleRateFactor + sampleRateFactor * powf(value, 24.0f) * 7.0f;
}
float scaleValueDecay(float value)
{
value = 1.0f - value * 0.5f;
return 0.0003f * sampleRateFactor + sampleRateFactor * powf(value, 23.0f) * 7.0f;
}
public:
void setAttack(float value)
{
this->attackReal = value;
this->attack = this->scaleValueAttack(value);
}
void setDecay(float value)
{
this->decayReal = value;
this->decay = this->scaleValueDecay(value);
}
void setSustain(float value)
{
this->sustainReal = value;
this->sustain = this->scaleValue(value);
}
void setRelease(float value)
{
this->release = this->scaleValue(value) * 8.0f;
}
inline float tick(bool noteOn, bool isAttackExp)
{
float returnValue = 0.0f;
if (!noteOn && actualValue > 0.0f)
{
state = 3;
}
if (!noteOn && actualValue <= 0.0f)
{
state = 4;
}
switch (state)
{
case 0:
if (isAttackExp)
{
actualValue += attack * (actualValue + sampleRateFactor);
}
else
{
actualValue += attack * sampleRateFactor * 200.0f * (1.04f + this->attackReal * 0.5f - actualValue);
}
if (actualValue > 1.0f)
{
actualValue = 1.0f;
state = 1;
}
if (isAttackExp)
{
returnValue = actualValue * actualValue * actualValue * actualValue * actualValue;
}
else
{
returnValue = actualValue;
}
break;
case 1:
actualValue -= decay * (actualValue + sampleRateFactor);
tmp = actualValue;
if (tmp <= sustainReal)
{
tmp = sustainReal;
state = 2;
}
returnValue = tmp;
break;
case 2:
actualValue = sustainReal;
returnValue = sustainReal;
break;
case 3:
actualValue -= release * (actualValue + sampleRateFactor);
if (actualValue < 0.0f)
{
actualValue = 0.0f;
state = 4;
}
returnValue = actualValue;
break;
case 4:
returnValue = actualValue = 0.0f;
break;
}
return returnValue;
}
bool isNotePlaying(bool noteOn)
{
return noteOn || actualValue > 0;
}
void resetState()
{
state = 0;
}
float getValueFasterAttack()
{
if (state == 0 && this->attackReal == 0.0f)
{
return 1.0f;
}
return actualValue;
}
void resetAll()
{
actualValue = 0.0f;
state = 0;
}
};
#endif
| [
"patrickkunzch@1672e8fc-9579-4a43-9460-95afed9bdb0b"
] | [
[
[
1,
198
]
]
] |
7e386d013a25a059d8c66ea5a2de06dbe95146e8 | cd0987589d3815de1dea8529a7705caac479e7e9 | /webkit/WebKit2/UIProcess/API/C/WKURL.cpp | 02766ac4553f3b565e7af6f68986a5d29a7a5da1 | [] | 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 | 1,525 | cpp | /*
* 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.
*/
#include "WKURL.h"
#include "WKAPICast.h"
using namespace WebKit;
WKTypeID WKURLGetTypeID()
{
return toRef(WebURL::APIType);
}
| [
"[email protected]"
] | [
[
[
1,
35
]
]
] |
7d0f34eabec74d8e3dcc4c5e53e0fdf21eecbc86 | d8e1a65a5863ea5a111c8304a040f1c797f8ebbf | / mtktest --username qq413187589/N65/N65_V1/plutommi/Customer/ResGenerator/mtk_resgenerator.cpp | 6f9b549a42bf29902fff8b2104749dde4fe05f70 | [] | no_license | manoj-gupta5/mtktest | a6b627cde8c9a543d473a99f778fd6f587a8d053 | 98370766a36fffb8b0dde1cc6dd144599ea184f6 | refs/heads/master | 2020-12-25T21:12:59.596045 | 2010-07-18T05:06:14 | 2010-07-18T05:06:14 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 46,236 | cpp | /*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2005
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*******************************************************************************
* Filename:
* ---------
* mtk_resgenerator.cpp
*
* Project:
* --------
* MAUI
*
* Description:
* ------------
* To Generator Resource C files.
*
* Author:
* -------
* -------
*
*==============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================== *******************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include "pixteldatatypes.h"
#include "CustDataRes.h"
#include "CustMenuRes.h"
#include "CustResDef.h"
#include "mmi_features.h"
/* buffer size for shell command */
#define SHELL_CMD_BUFLEN (MAX_FILENAME_LEN + 100)
/* buffer size for unzip command */
#define UNZIP_CMD_BUFLEN 256
/* type definition */
typedef struct
{
U16 Num;
} CUSTOM_ID_MAP;
typedef struct
{
U16 minId;
U16 maxId;
U16 index;
} CUSTOM_ID_SEARCH_MAP;
typedef struct
{
S8 filename[MAX_FILENAME_LEN];
} CUSTOM_NAME_LIST;
/* Extern variable */
extern "C" CUSTOM_IMAGE nCustImageNames[];
extern "C" CUSTOM_IMAGE_MAP ImageIdMap[];
extern "C" CUSTOM_IMAGE_SEARCH_MAP ImageIdSearchMap[];
extern "C" IMAGENAME_LIST ImageNameList[];
extern "C" CUSTOM_IMAGE_MAP ImageIdMapEXT[];
extern "C" CUSTOM_IMAGE_SEARCH_MAP ImageIdSearchMapEXT[];
extern "C" IMAGENAME_LIST ImageNameListEXT[];
extern "C" CUSTOM_AUDIO nCustAudioNames[];
extern "C" CUSTOM_AUDIO_MAP AudioIdMap[];
extern "C" CUSTOM_AUDIO_SEARCH_MAP AudioIdSearchMap[];
extern "C" AUDIONAME_LIST AudioNameList[];
extern "C" CUSTOM_AUDIO_MAP AudioIdMapEXT[];
extern "C" CUSTOM_AUDIO_SEARCH_MAP AudioIdSearchMapEXT[];
extern "C" AUDIONAME_LIST AudioNameListEXT[];
extern "C" CUSTOM_MENU nCustMenus[];
extern "C" unsigned short CurrMaxMenuItemIndex; //Max menu Ids
extern "C" unsigned short CurrMaxImageId; //Max String Ids
extern "C" unsigned short CurrMaxSearchImageId; //Max String Ids
extern "C" unsigned short CurrMaxImageNum; //Max Number Ids
extern "C" unsigned short CurrMaxImageIdEXT;
extern "C" unsigned short CurrMaxSearchImageIdEXT;
extern "C" unsigned short CurrMaxImageNumEXT;
extern "C" image_type_enum ExtImageFlag;
extern "C" unsigned short CurrMaxAudioId; //Max String Ids
extern "C" unsigned short CurrMaxSearchAudioId; //Max String Ids
extern "C" unsigned short CurrMaxAudioNum; //Max Number Ids
extern "C" unsigned short CurrMaxAudioIdEXT;
extern "C" unsigned short CurrMaxSearchAudioIdEXT;
extern "C" unsigned short CurrMaxAudioNumEXT;
extern "C" BOOL ExtAudioFlag;
extern "C" FILE* dest_file;
extern "C" int toolFlag;
extern "C" int resultFailFlag;
extern "C" unsigned short CurrMaxENFBAssociatedIDNum;
extern "C" CUSTOM_ENFB_STR ENFBAssociatedIDList[];
/* Extern functions */
extern "C" void PopulateResData(void);
extern "C" void Extract_Name(S8 *dest, S8* src, U32 res_type);
extern "C" void InitStrPopulate();
extern "C" int MergeStrRes(void);
extern "C" int GenerateStrResFile(void);
/*****************************************************************************
* FUNCTION
* GenerateENFBAssociatedIDFile
* DESCRIPTION
* generate ENFB associated ID map file
* PARAMETERS
* void
* RETURNS
* MMI_BOOL
*****************************************************************************/
static MMI_BOOL GenerateENFBAssociatedIDFile(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
FILE *fp;
CUSTOM_ENFB_STR *enfb;
int i, j;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/* open file */
fp = fopen(ENFB_DATA_FILENAME, "w");
if(fp == NULL)
{
return MMI_FALSE;
}
/* print copyright */
fprintf(fp, "/**\n * Copyright Notice\n * ?2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,\n * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.\n * (It is illegal to remove this copyright notice from this software or any\n * portion of it)\n */\n");
fprintf(fp, "\n/************************************************************** \n FILENAME\t: CustENFBAssociatedMap.c \n PURPOSE\t: ENFB associated list file. \n REMARKS\t: nil \n AUTHOR\t\t: Customization Tool \n DATE\t\t: . \n **************************************************************/\n");
/* print include file */
fprintf(fp, "#include \"CustDataRes.h\"\n\n");
/* dump extern variable */
for (i = 1; i <= (int)CurrMaxENFBAssociatedIDNum; i++)
{
enfb = (CUSTOM_ENFB_STR *)&ENFBAssociatedIDList[i];
for (j = 0; j < (int)enfb->count; j++)
{
fprintf(fp, "extern const U8 %s[];\n", enfb->Ptr[j]);
}
}
fprintf(fp, "\n");
/* print list count */
fprintf(fp, "const U32 CurrMaxENFBAssociatedIDNum = %d;\n\n", CurrMaxENFBAssociatedIDNum + 1);
/* dump ID list */
for (i = 1; i <= (int)CurrMaxENFBAssociatedIDNum; i++)
{
enfb = (CUSTOM_ENFB_STR *)&ENFBAssociatedIDList[i];
fprintf(fp, "const U16 Associated_IDs_%d[] = {", i);
for (j = 0; j < (int)enfb->count - 1; j++)
{
fprintf(fp, "%d, ", enfb->IDs[j]);
}
fprintf(fp, "%d};\n", enfb->IDs[enfb->count - 1]);
}
fprintf(fp, "\n");
/* dump ptr list */
for (i = 1; i <= (int)CurrMaxENFBAssociatedIDNum; i++)
{
enfb = (CUSTOM_ENFB_STR *)&ENFBAssociatedIDList[i];
fprintf(fp, "const CUSTOM_IMAGE Associated_Ptr_%d[] = {\n", i);
for (j = 0; j < (int)enfb->count - 1; j++)
{
fprintf(fp, "\t(U8*)&%s,\n", enfb->Ptr[j]);
}
fprintf(fp, "\t(U8*)&%s\n};\n", enfb->Ptr[enfb->count - 1]);
}
fprintf(fp, "\n");
/* dump CUSTOM_ENFB list */
fprintf(fp, "const CUSTOM_ENFB AssociatedID_map[] = \n{\n");
if (CurrMaxENFBAssociatedIDNum > 0)
{
fprintf(fp, "\t{0, 0, 0},\n");
}
else
{
fprintf(fp, "\t{0, 0, 0}\n");
}
if (CurrMaxENFBAssociatedIDNum > 0)
{
for (i = 1; i < (int)CurrMaxENFBAssociatedIDNum; i++)
{
enfb = (CUSTOM_ENFB_STR *)&ENFBAssociatedIDList[i];
fprintf(fp, "\t{%d, (U16 *)&Associated_IDs_%d, (CUSTOM_IMAGE *)&Associated_Ptr_%d},\n", enfb->count, i, i);
}
fprintf(fp, "\t{%d, (U16 *)&Associated_IDs_%d, (CUSTOM_IMAGE *)&Associated_Ptr_%d}\n",
ENFBAssociatedIDList[CurrMaxENFBAssociatedIDNum].count,
CurrMaxENFBAssociatedIDNum, CurrMaxENFBAssociatedIDNum);
}
fprintf(fp, "};\n");
/* free memory */
for (i = 1; i <= (int)CurrMaxENFBAssociatedIDNum; i++)
{
enfb = (CUSTOM_ENFB_STR *)&ENFBAssociatedIDList[i];
free(enfb->IDs);
for (j = 0; j < (int)enfb->count; j++)
{
free(enfb->Ptr[j]);
}
free(enfb->Ptr);
}
fprintf(stderr, "Output CustENFBImgMap.c... done\n");
fclose(fp);
return MMI_TRUE;
}
/*****************************************************************************
* FUNCTION
* UnzipImage
* DESCRIPTION
* unzip image to the destination folder
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
static void UnzipImage(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
char tempCommand[UNZIP_CMD_BUFLEN];
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
sprintf(tempCommand,"rd /S/Q %s\\mainlcd\\", CUST_IMG_PATH);
system(tempCommand);
sprintf(tempCommand,"rd /S/Q %s\\sublcd\\", CUST_IMG_PATH);
system(tempCommand);
sprintf(tempCommand, "7za.exe x -y %s\\image.zip -o%s\\", CUST_IMG_PATH, CUST_IMG_PATH);
system(tempCommand);
#ifndef __OPTR_NONE__
sprintf(tempCommand, "7za.exe x -y %s\\operator_image.zip -o%s\\", CUST_OPERATOR_IMG_PATH, CUST_IMG_PATH);
system(tempCommand);
#endif /* __OPTR_NONE__ */
#if defined(CUST_SUBLCD_PATH)
sprintf(tempCommand, "7za.exe x -y %s\\image.zip -o%s\\", CUST_SUBLCD_PATH, CUST_IMG_PATH);
system(tempCommand);
#ifndef __OPTR_NONE__
sprintf(tempCommand, "7za.exe x -y %s\\operator_image.zip -o%s\\", CUST_OPERATOR_SUBLCD_PATH, CUST_IMG_PATH);
system(tempCommand);
#endif /* __OPTR_NONE__ */
#endif /* defined (CUST_SUBLCD_PATH) */
}
/*****************************************************************************
* FUNCTION
* UnzipAudio
* DESCRIPTION
* unzip audio to the destination folder
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
static void UnzipAudio(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
char tempCommand[UNZIP_CMD_BUFLEN];
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
sprintf(tempCommand, "7za.exe x -y %s\\audio.zip -o%s\\", CUST_ADO_PATH, CUST_ADO_PATH);
system(tempCommand);
#ifndef __OPTR_NONE__
sprintf(tempCommand, "7za.exe x -y %s\\operator_audio.zip -o%s\\", CUST_OPERATOR_ADO_PATH, CUST_ADO_PATH);
system(tempCommand);
#endif /* __OPTR_NONE__ */
}
/*****************************************************************************
* FUNCTION
* Trace
* DESCRIPTION
*
* PARAMETERS
* fmt [IN]
* RETURNS
* void
*****************************************************************************/
extern "C" void Trace(char *fmt,...)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
va_list MyList;
char nPrintableStr[1000]; //Assumed..this can chane if need to dump more bytes
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
va_start(MyList,fmt);
vsprintf(nPrintableStr,fmt,MyList);
va_end(MyList);
printf(nPrintableStr);
}
/*****************************************************************************
* FUNCTION
* PopulateSearchMap_Ext
* DESCRIPTION
* populate search map
* PARAMETERS
* pIdMap [IN] ID map
* pIdSearchMap [OUT] ID search map
* pCurrMaxId [OUT] current max ID
* pCurrMaxSearchId [OUT] current max search ID
* MaxIdSize [IN] max ID
* RETURNS
* void
*****************************************************************************/
static void PopulateSearchMap_Ext(
CUSTOM_ID_MAP *pIdMap,
CUSTOM_ID_SEARCH_MAP *pIdSearchMap,
unsigned short *pCurrMaxId,
unsigned short *pCurrMaxSearchId,
U16 MaxIdSize)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U16 i = 0, j = 0;
U16 index = 0, start = 0;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
for (i = 0; i < MaxIdSize; i++)
{
if (pIdMap[i].Num != ((U16) - 1))
{
if (!start)
{
pIdSearchMap[j].minId = pIdSearchMap[j].maxId = i;
pIdSearchMap[j].index = index;
index++;
start = 1;
}
else
{
pIdSearchMap[j].maxId = i;
index++;
}
}
else
{
if (start)
{
j++;
start = 0;
}
}
}
*pCurrMaxSearchId = j;
j = 0;
for (i = 0; i < MaxIdSize; i++)
{
if (pIdMap[i].Num != (U16)-1)
{
if (i != j)
{
pIdMap[j].Num = pIdMap[i].Num;
pIdMap[i].Num = -1;
}
j++;
}
}
*pCurrMaxId = j;
}
/*****************************************************************************
* FUNCTION
* PopulateImageSearch
* DESCRIPTION
* populate image search map
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
static void PopulateImageSearch(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
PopulateSearchMap_Ext(
(CUSTOM_ID_MAP *)ImageIdMap,
(CUSTOM_ID_SEARCH_MAP *)ImageIdSearchMap,
(unsigned short *)&CurrMaxImageId,
(unsigned short *)&CurrMaxSearchImageId,
MAX_IMAGE_IDS_SIZE);
PopulateSearchMap_Ext(
(CUSTOM_ID_MAP *)ImageIdMapEXT,
(CUSTOM_ID_SEARCH_MAP *)ImageIdSearchMapEXT,
(unsigned short *)&CurrMaxImageIdEXT,
(unsigned short *)&CurrMaxSearchImageIdEXT,
MAX_IMAGE_IDS_SIZE);
}
/*****************************************************************************
* FUNCTION
* PopulateAudioSearch
* DESCRIPTION
* populate audio search map
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
static void PopulateAudioSearch(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
PopulateSearchMap_Ext(
(CUSTOM_ID_MAP *)AudioIdMap,
(CUSTOM_ID_SEARCH_MAP *)AudioIdSearchMap,
(unsigned short *)&CurrMaxAudioId,
(unsigned short *)&CurrMaxSearchAudioId,
MAX_AUDIO_IDS_SIZE);
PopulateSearchMap_Ext(
(CUSTOM_ID_MAP *)AudioIdMapEXT,
(CUSTOM_ID_SEARCH_MAP *)AudioIdSearchMapEXT,
(unsigned short *)&CurrMaxAudioIdEXT,
(unsigned short *)&CurrMaxSearchAudioIdEXT,
MAX_AUDIO_IDS_SIZE);
}
/*****************************************************************************
* FUNCTION
* GenerateResFile_Ext
* DESCRIPTION
* generate resource file
* PARAMETERS
* flag [IN] CustPack or not
* type [IN] image or audio
* pName [IN] resource name list
* nSize [IN] size
* str_CustDataHW [IN] output header name
* str_mtk_CurrMaxNum [IN] output variable name
* str_CurrMaxNum [IN] output variable name
* str_mtk_nCustNames [IN] output variable name
* str_nCustNames [IN] output variable name
* str_NameList [IN] output variable name
* str_CustType [IN] output type name
* curr_data_filename [IN] output file name
* RETURNS
* void
*****************************************************************************/
static void GenerateResFile_Ext(
BOOL flag,
RESOURCE_TYPE_LIST type,
CUSTOM_NAME_LIST *pName,
U16 nSize,
char *str_CustDataHW,
char *str_mtk_CurrMaxNum,
char *str_CurrMaxNum,
char *str_mtk_nCustNames,
char *str_nCustNames,
char *str_NameList,
char *str_CustType,
char *curr_data_filename)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
FILE *pFile;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if(pFile = fopen(curr_data_filename, "w"))
{
fprintf(pFile, "/**\n * Copyright Notice\n * ?2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,\n * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.\n * (It is illegal to remove this copyright notice from this software or any\n * portion of it)\n */\n");
fprintf(pFile, "\n/************************************************************** \n FILENAME : \n PURPOSE : Resource file. \n REMARKS : nil \n AUTHOR : Customization Tool \n DATE : . \n **************************************************************/\n");
fprintf(pFile, "#include \"CustDataRes.h\"\n");
if((type == RES_IMAGE) && (flag == FALSE))
{
fprintf ( pFile, "#include \"CustGameDataHW.h\"\n");
}
fprintf(pFile, "#include \"%s\"\n", str_CustDataHW);
fprintf(pFile, "#include \"CustResDef.h\"\n\n");
if(type == RES_IMAGE)
{
if(flag == FALSE)
{
fprintf(pFile, "const S8 CustImgPath[]=CUST_IMG_PATH;\n");
}
else
{
fprintf(pFile, "\/\/const S8 CustImgPath[]=CUST_IMG_PATH;\n");
}
}
if(type == RES_AUDIO)
{
if(flag == FALSE)
{
fprintf(pFile, "const S8 CustAdoPath[]=CUST_ADO_PATH;\n");
}
else
{
fprintf(pFile, "\/\/const S8 CustAdoPath[]=CUST_ADO_PATH;\n");
}
}
#ifdef __MULTI_BIN_LOAD__
fprintf(pFile, "const unsigned short %s=%d;\n", str_mtk_CurrMaxNum, nSize);
#else
fprintf(pFile, "unsigned short %s=%d;\n", str_CurrMaxNum, nSize);
#endif
/* writing the image filename inside the file. */
if(nSize)
{
int i = 0;
#ifdef __MULTI_BIN_LOAD__
fprintf(pFile, "const %s %s[]={\n", str_CustType, str_mtk_nCustNames);
#else
fprintf(pFile, "const %s %s[]={\n", str_CustType, str_nCustNames);
#endif
for(i = 0; i < nSize; i++)
{
S8 pBuffName[200];
Extract_Name(pBuffName, pName[i].filename, type);
fprintf(pFile, "(U8*)&%s,\n", pBuffName);
}
fprintf(pFile, "};\n\n\n\n");
}
else
{
#ifdef __MULTI_BIN_LOAD__
fprintf(pFile, "const %s %s[];\n", str_CustType, str_mtk_nCustNames);
#else
fprintf(pFile, "const %s %s[];\n", str_CustType, str_nCustNames);
#endif
}
if(flag == TRUE)
{
if(type == RES_IMAGE)
{
#ifdef __MULTI_BIN_LOAD__
fprintf(pFile, "const CUSTPACK_IMAGE_HEADER mtk_image_header={%d, (%s *)%s};", nSize, str_CustType, str_mtk_nCustNames);
#else
fprintf(pFile, "const CUSTPACK_IMAGE_HEADER mtk_image_header={%d, (%s *)%s};", nSize, str_CustType, str_nCustNames);
#endif
}
if(type == RES_AUDIO)
{
#ifdef __MULTI_BIN_LOAD__
fprintf(pFile, "const CUSTPACK_AUDIO_HEADER mtk_audio_header={%d, (%s *)%s};", nSize, str_CustType, str_mtk_nCustNames);
#else
fprintf(pFile, "const CUSTPACK_AUDIO_HEADER mtk_audio_header={%d, (%s *)%s};", nSize, str_CustType, str_nCustNames);
#endif
}
}
fclose(pFile);
}
}
/*****************************************************************************
* FUNCTION
* GenerateImageResFile
* DESCRIPTION
* generate image resource file
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
static void GenerateImageResFile(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
ExtImageFlag = SYSTEM_IMAGE;
GenerateResFile_Ext(
FALSE,
RES_IMAGE,
(CUSTOM_NAME_LIST *)ImageNameList,
CurrMaxImageNum,
"CustImgDataHW.h",
"mtk_CurrMaxImageNum",
"CurrMaxImageNum",
"mtk_nCustImageNames",
"nCustImageNames",
"ImageNameList",
"CUSTOM_IMAGE",
IMG_DATA_FILENAME);
ExtImageFlag = EXT_IMAGE;
GenerateResFile_Ext(
TRUE,
RES_IMAGE,
(CUSTOM_NAME_LIST *)ImageNameListEXT,
CurrMaxImageNumEXT,
"CustImgDataHWExt.h",
"mtk_CurrMaxImageNumEXT",
"CurrMaxImageNumEXT",
"mtk_nCustImageNamesEXT",
"nCustImageNamesEXT",
"ImageNameListEXT",
"CUSTOM_IMAGE",
IMG_DATA_FILENAME_EXT);
}
/*****************************************************************************
* FUNCTION
* GenerateAudioResFile
* DESCRIPTION
* generate aurio resource file
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
static void GenerateAudioResFile(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
ExtAudioFlag = FALSE;
GenerateResFile_Ext(
FALSE,
RES_AUDIO,
(CUSTOM_NAME_LIST *)AudioNameList,
CurrMaxAudioNum,
"CustAdoDataHW.h",
"mtk_CurrMaxAudioNum",
"CurrMaxAudioNum",
"mtk_nCustAudioNames",
"nCustAudioNames",
"AudioNameList",
"CUSTOM_AUDIO",
ADO_DATA_FILENAME);
ExtAudioFlag = TRUE;
GenerateResFile_Ext(
TRUE,
RES_AUDIO,
(CUSTOM_NAME_LIST *)AudioNameListEXT,
CurrMaxAudioNumEXT,
"CustAdoDataHWExt.h",
"mtk_CurrMaxAudioNumEXT",
"CurrMaxAudioNumEXT",
"mtk_nCustAudioNamesEXT",
"nCustAudioNamesEXT",
"AudioNameListEXT",
"CUSTOM_AUDIO",
ADO_DATA_FILENAME_EXT);
}
/*****************************************************************************
* FUNCTION
* GenerateMapFile_Ext
* DESCRIPTION
* generate ID map file
* PARAMETERS
* pMap [IN] ID map
* nSize [IN] size
* str_IdMap [IN] output variable name
* str_CustMap [IN] output variable name
* str_CurrMaxId [IN] output variable name
* str_CustType [IN] output variable name
* curr_map_filename [IN] output file name
* RETURNS
* void
*****************************************************************************/
static void GenerateMapFile_Ext(
CUSTOM_ID_MAP *pMap,
U16 nSize,
char *str_IdMap,
char *str_CustMap,
char *str_CurrMaxId,
char *str_CustType,
char *curr_map_filename)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
FILE *pFile;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if(pFile = fopen(curr_map_filename, "w"))
{
fprintf(pFile, "/**\n * Copyright Notice\n * ?2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,\n * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.\n * (It is illegal to remove this copyright notice from this software or any\n * portion of it)\n */\n");
fprintf(pFile, "\n/************************************************************** \n FILENAME : %s \n PURPOSE : Resource Map file. \n REMARKS : nil \n AUTHOR : Customization Tool \n DATE : . \n **************************************************************/\n", str_CustMap);
fprintf(pFile, "#include \"CustDataRes.h\"\n\n\n");
fprintf(pFile, "unsigned short %s=%d;\n", str_CurrMaxId, nSize);
/* writing the map array inside the file. */
if(nSize)
{
int i;
fprintf(pFile, "const %s %s[]={\n", str_CustType, str_IdMap);
for(i = 0; i < nSize; i++)
{
fprintf(pFile,"\t{%d},\n", pMap[i].Num);
}
fprintf(pFile, "};\n\n\n\n");
}
else
{
fprintf(pFile, "const %s %s[1];\n", str_CustType, str_IdMap);
}
fclose(pFile);
}
}
/*****************************************************************************
* FUNCTION
* GenerateImageMapFile
* DESCRIPTION
* generate image ID map file
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
static void GenerateImageMapFile(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
ExtImageFlag = SYSTEM_IMAGE;
GenerateMapFile_Ext(
(CUSTOM_ID_MAP *)ImageIdMap,
CurrMaxImageId,
"ImageIdMap",
"CustImageMap.c",
"CurrMaxImageId",
"CUSTOM_IMAGE_MAP",
IMG_MAP_FILENAME);
ExtImageFlag = EXT_IMAGE;
GenerateMapFile_Ext(
(CUSTOM_ID_MAP *)ImageIdMapEXT,
CurrMaxImageIdEXT,
"ImageIdMapEXT",
"CustImageMapExt.c",
"CurrMaxImageIdEXT",
"CUSTOM_IMAGE_MAP",
IMG_MAP_FILENAME_EXT);
}
/*****************************************************************************
* FUNCTION
* GenerateAudioMapFile
* DESCRIPTION
* generate audio ID map file
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
static void GenerateAudioMapFile(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
ExtAudioFlag = FALSE;
GenerateMapFile_Ext(
(CUSTOM_ID_MAP *)AudioIdMap,
CurrMaxAudioId,
"AudioIdMap",
"CustAudioMap.c",
"CurrMaxAudioId",
"CUSTOM_AUDIO_MAP",
ADO_MAP_FILENAME);
ExtAudioFlag = TRUE;
GenerateMapFile_Ext(
(CUSTOM_ID_MAP *)AudioIdMapEXT,
CurrMaxAudioIdEXT,
"AudioIdMapEXT",
"CustAudioMapExt.c",
"CurrMaxAudioIdEXT",
"CUSTOM_AUDIO_MAP",
ADO_MAP_FILENAME_EXT);
}
/*****************************************************************************
* FUNCTION
* GenerateMapSearchFile_Ext
* DESCRIPTION
* generate ID search map file
* PARAMETERS
* pMap [IN] ID search map
* nSize [IN] size
* str_CurrMaxSearchId [IN] output variable name
* str_IdSearchMap [IN] output variable name
* str_CustType [IN] output variable name
* curr_map_filename [IN] output file name
* RETURNS
* void
*****************************************************************************/
static void GenerateMapSearchFile_Ext(
CUSTOM_ID_SEARCH_MAP *pMap,
U16 nSize,
char *str_CurrMaxSearchId,
char *str_IdSearchMap,
char *str_CustType,
char *curr_map_filename)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
FILE *pFile;
int i;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if(pFile = fopen(curr_map_filename, "a"))
{
fprintf(pFile, "unsigned short %s=%d;\n", str_CurrMaxSearchId, nSize);
/* writing the search map array inside the file. */
if(nSize)
{
fprintf(pFile, "const %s %s[]={\n", str_CustType, str_IdSearchMap);
for(i = 0; i < nSize; i++)
{
fprintf(pFile, "\t{%d,%d,%d},\n", pMap[i].minId, pMap[i].maxId, pMap[i].index);
}
fprintf(pFile, "};\n\n\n\n");
}
else
{
fprintf(pFile, "%s %s[1];", str_CustType, str_IdSearchMap);
}
fclose(pFile);
}
}
/*****************************************************************************
* FUNCTION
* GenerateImageMapSearchFile
* DESCRIPTION
* generate image search map file
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
static void GenerateImageMapSearchFile(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
ExtImageFlag = SYSTEM_IMAGE;
GenerateMapSearchFile_Ext(
(CUSTOM_ID_SEARCH_MAP *)ImageIdSearchMap,
CurrMaxSearchImageId,
"CurrMaxSearchImageId",
"ImageIdSearchMap",
"CUSTOM_IMAGE_SEARCH_MAP",
IMG_MAP_FILENAME);
ExtImageFlag = EXT_IMAGE;
GenerateMapSearchFile_Ext(
(CUSTOM_ID_SEARCH_MAP *)ImageIdSearchMapEXT,
CurrMaxSearchImageIdEXT,
"CurrMaxSearchImageIdEXT",
"ImageIdSearchMapEXT",
"CUSTOM_IMAGE_SEARCH_MAP",
IMG_MAP_FILENAME_EXT);
}
/*****************************************************************************
* FUNCTION
* GenerateAudioMapSearchFile
* DESCRIPTION
* generate audio search map file
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
static void GenerateAudioMapSearchFile(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
ExtAudioFlag = FALSE;
GenerateMapSearchFile_Ext(
(CUSTOM_ID_SEARCH_MAP *)AudioIdSearchMap,
CurrMaxSearchAudioId,
"CurrMaxSearchAudioId",
"AudioIdSearchMap",
"CUSTOM_AUDIO_SEARCH_MAP",
ADO_MAP_FILENAME);
ExtAudioFlag = TRUE;
GenerateMapSearchFile_Ext(
(CUSTOM_ID_SEARCH_MAP *)AudioIdSearchMapEXT,
CurrMaxSearchAudioIdEXT,
"CurrMaxSearchAudioIdEXT",
"AudioIdSearchMapEXT",
"CUSTOM_AUDIO_SEARCH_MAP",
ADO_MAP_FILENAME_EXT);
}
/*****************************************************************************
* FUNCTION
* GenerateMenuFile
* DESCRIPTION
* generate menu resource file
* PARAMETERS
* nSize [IN] size
* RETURNS
* int
*****************************************************************************/
static int GenerateMenuFile(U16 nSize)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
FILE* pFile;
CUSTOM_MENU* pCustMenu = (CUSTOM_MENU*)nCustMenus;
S8 nItemData[100]; /* Assumed ..*/
S8 MenuItemString[500]; /* Assumed ..*/
int i,j;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if(pFile = fopen(MENU_DATA_FILENAME, "w"))
{
fprintf(pFile, "/**\n * Copyright Notice\n * ?2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,\n * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.\n * (It is illegal to remove this copyright notice from this software or any\n * portion of it)\n */\n");
fprintf(pFile, "\n/************************************************************** \n FILENAME : CustMenuRes.c \n PURPOSE : Menu Resource file. \n REMARKS : nil \n AUTHOR : Customization Tool \n DATE : . \n **************************************************************/\n");
/* put the headers needed here */
fprintf(pFile, "#include \"CustMenuRes.h\"\n\n\n");
fprintf(pFile, "unsigned short CurrMaxMenuItemIndex=%d;\n", nSize);
/* writing the string array inside the file. */
if(nSize)
{
for(i = 0; i < nSize; i++)
{
if(pCustMenu[i].nNumofMenuItem)
{
sprintf(MenuItemString, "const U16 nOrderMenuItem_%d[]={", i);
for(j = 0; j < (pCustMenu[i].nNumofMenuItem - 1); j++)
{
sprintf(nItemData, "%d,", pCustMenu[i].nOrderMenuItemId[j]);
strcat(MenuItemString, nItemData);
}
sprintf(nItemData, "%d};", pCustMenu[i].nOrderMenuItemId[j]);
strcat(MenuItemString, nItemData);
fprintf(pFile, "%s\n", MenuItemString);
}
}
fprintf(pFile, "\n const CUSTOM_MENU mtk_nCustMenus[]={\n");
for(i = 0; i < nSize; i++)
{
if(pCustMenu[i].nNumofMenuItem)
sprintf(MenuItemString, "{%d,%d,%d,%d,%d,%d,%d,%d,(U16 *)nOrderMenuItem_%d},", pCustMenu[i].nMenuItemId, pCustMenu[i].nParentId, pCustMenu[i].nNumofMenuItem, pCustMenu[i].nHideFlag, pCustMenu[i].nMovable, pCustMenu[i].nDispAttribute, pCustMenu[i].nStrId, pCustMenu[i].nImageId, i);
else
sprintf(MenuItemString, "{%d,%d,%d,%d,%d,%d,%d,%d,(U16 *)0},", pCustMenu[i].nMenuItemId, pCustMenu[i].nParentId, pCustMenu[i].nNumofMenuItem, pCustMenu[i].nHideFlag, pCustMenu[i].nMovable, pCustMenu[i].nDispAttribute, pCustMenu[i].nStrId, pCustMenu[i].nImageId);
fprintf(pFile, "%s\n", MenuItemString);
}
fprintf(pFile, "};\n");
}
else
{
fprintf(pFile, "const CUSTOM_MENU nCustMenus[1];");
}
fclose(pFile);
}
else
{
return 0;
}
return 1;
}
extern "C" void ToolPopulateInitial(void);
extern "C" void ToolPopulateDone(void);
extern "C" MMI_BOOL Iload(S8 *string, U16* pType);
extern "C" MMI_BOOL Aload(S8 *string, U16* pType);
extern "C" S8 ToUpper(S8 ch);
#ifdef __MMI_RESOURCE_ENFB_SUPPORT__
extern "C" int disableENFB;
#endif
/*****************************************************************************
* FUNCTION
* main
* DESCRIPTION
* main function of mtk_resgenerator
* PARAMETERS
*
* RETURNS
* int
*****************************************************************************/
int main(int argc, char *argv[])
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
char tempCommand[SHELL_CMD_BUFLEN];
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if(argc == 5) //Check if run by CustPack tool
{
if(strcmp(argv[1], "-f")==0 && (strcmp(argv[2], "-i")==0 || strcmp(argv[2], "-a")==0))//-i: image, -a: audio
{
U16 nType;
S16 nStrlen;
S8 upperFileName[MAX_FILENAME_LEN];
dest_file = fopen(argv[4], "wb");
if (dest_file == NULL){
resultFailFlag = 1;
printf("dest_file could not open!\n");
}
toolFlag = 1;
ToolPopulateInitial();
nStrlen = strlen(argv[3]) ;
while (nStrlen>=0)
{
upperFileName[nStrlen] = ToUpper(argv[3][nStrlen]);
--nStrlen;
}
#ifdef __MMI_RESOURCE_ENFB_SUPPORT__
disableENFB = 1;
#endif
if(strcmp(argv[2], "-i")==0)
{
Iload(upperFileName, &nType);
}
else if(strcmp(argv[2], "-a")==0)
{
Aload(upperFileName, &nType);
}
#ifdef __MMI_RESOURCE_ENFB_SUPPORT__
disableENFB = 0;
#endif
//ToolPopulateDone();
if(dest_file != NULL)
{
fclose(dest_file);
}
if(resultFailFlag==1)
{
sprintf(tempCommand, "del -F %s", argv[4]);
system(tempCommand);
}
}
else
{
printf("Usage: mtk_resgenerator.exe -f [-i or -a] ImageFilename OutputFilename\n");
}
return 1;
}
if(argc==3)
{
if(strcmp(argv[1], "-g")==0 && strcmp(argv[2], "-x")==0)
{
UnzipImage();
UnzipAudio();
}
else
{
printf("Usage: mtk_resgenerator.exe -g -x\n");
return 0;
}
}
if((argc==2 || argc==3) && strcmp(argv[1], "-g")==0)
{
printf("MediaTek Resource Generate System 0.1\n");
InitStrPopulate();
PopulateResData();
PopulateImageSearch();
GenerateImageResFile();
GenerateImageMapFile();
GenerateImageMapSearchFile();
PopulateAudioSearch();
GenerateAudioResFile();
GenerateAudioMapFile();
GenerateAudioMapSearchFile();
GenerateMenuFile(CurrMaxMenuItemIndex);
GenerateENFBAssociatedIDFile();
if (MergeStrRes() == 0)
GenerateStrResFile();
return 1;
}
printf("Usage: mtk_resgenerator.exe -g\n");
return 0;
}
| [
"qq413187589@046de88f-2cd9-6c0a-3028-073e08bc931c"
] | [
[
[
1,
1311
]
]
] |
299f6ac8aec9aa328aead925d8115de521cbfa9b | b22c254d7670522ec2caa61c998f8741b1da9388 | /common/MapInfoXmlWriter.cpp | bbbe7f4592b11cbf656cb9fe96d35f9e06e10920 | [] | no_license | ldaehler/lbanet | 341ddc4b62ef2df0a167caff46c2075fdfc85f5c | ecb54fc6fd691f1be3bae03681e355a225f92418 | refs/heads/master | 2021-01-23T13:17:19.963262 | 2011-03-22T21:49:52 | 2011-03-22T21:49:52 | 39,529,945 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 24,051 | cpp | /*
------------------------[ Lbanet Source ]-------------------------
Copyright (C) 2009
Author: Vivien Delage [Rincevent_123]
Email : [email protected]
-------------------------------[ GNU License ]-------------------------------
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, see <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------------------
*/
#include "MapInfoXmlWriter.h"
#include "tinyxml.h"
#include "TextActor.h"
#include "LadderActor.h"
#include "ExitActor.h"
#include "DoorActor.h"
#include "ContainerActor.h"
#include "UpExitActor.h"
#include "SwitchActor.h"
#include "FloorSwitch.h"
#include "AreaSwitch.h"
#include "GameEvents.h"
#include "ScriptableActor.h"
#include "HurtArea.h"
#include "NPCActor.h"
#include "ScriptedZoneActor.h"
#include "MailboxActor.h"
#include <fstream>
// save world information into file
void MapInfoXmlWriter::SaveWorld(const std::string Filename, const WorldInfo & wi)
{
TiXmlDocument doc;
TiXmlComment * comment;
std::string s;
TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "", "" );
doc.LinkEndChild( decl );
TiXmlElement * root = new TiXmlElement("World");
doc.LinkEndChild( root );
root->SetAttribute("name", wi.Name);
root->SetAttribute("firstmap", wi.FirstMap);
root->SetAttribute("firstsparea", wi.FirstSpawning);
TiXmlElement * desc = new TiXmlElement( "description" );
root->LinkEndChild(desc);
desc->LinkEndChild(new TiXmlText(wi.Description));
// block: teleport
{
comment = new TiXmlComment();
s="Define the place it is possible to teleport to, the first place is the place where we arrive in the world";
comment->SetValue(s.c_str());
root->LinkEndChild( comment );
TiXmlElement * tps = new TiXmlElement( "teleports" );
root->LinkEndChild(tps);
std::map<std::string, TPInfo>::const_iterator it = wi.Teleports.begin();
std::map<std::string, TPInfo>::const_iterator end = wi.Teleports.end();
for(; it != end; ++it)
{
TiXmlElement * tp = new TiXmlElement( "teleport" );
tps->LinkEndChild(tp);
tp->SetAttribute("name", it->second.Name);
tp->SetAttribute("map", it->second.NewMap);
tp->SetAttribute("sparea", it->second.Spawning);
}
}
// file info block
{
TiXmlElement * files = new TiXmlElement( "files" );
root->LinkEndChild(files);
std::map<std::string, std::string>::const_iterator it2 = wi.Files.begin();
std::map<std::string, std::string>::const_iterator end2 = wi.Files.end();
for(; it2 != end2; ++it2)
{
TiXmlElement * file = new TiXmlElement( "file" );
files->LinkEndChild(file);
file->SetAttribute("name", it2->first);
file->SetAttribute("path", it2->second);
}
}
TiXmlElement * maps = new TiXmlElement( "maps" );
root->LinkEndChild(maps);
std::map<std::string, MapInfo>::const_iterator it = wi.Maps.begin();
std::map<std::string, MapInfo>::const_iterator end = wi.Maps.end();
for(; it != end; ++it)
{
comment = new TiXmlComment();
s="Map of "+it->second.Description;
comment->SetValue(s.c_str());
maps->LinkEndChild( comment );
TiXmlElement * map = new TiXmlElement( "Map" );
maps->LinkEndChild(map);
map->SetAttribute("name", it->first);
map->SetAttribute("type", it->second.Type);
map->SetAttribute("music", it->second.Music);
map->SetAttribute("repeatmusic", it->second.MusicLoop);
TiXmlElement * descm = new TiXmlElement( "description" );
map->LinkEndChild(descm);
descm->LinkEndChild(new TiXmlText(it->second.Description));
// file info block
{
comment = new TiXmlComment();
s="Give the path of the files containing the island information to be loaded";
comment->SetValue(s.c_str());
map->LinkEndChild( comment );
TiXmlElement * files = new TiXmlElement( "files" );
map->LinkEndChild(files);
std::map<std::string, std::string>::const_iterator it2 = it->second.Files.begin();
std::map<std::string, std::string>::const_iterator end2 = it->second.Files.end();
for(; it2 != end2; ++it2)
{
TiXmlElement * file = new TiXmlElement( "file" );
files->LinkEndChild(file);
file->SetAttribute("name", it2->first);
file->SetAttribute("path", it2->second);
}
}
// light info block
{
comment = new TiXmlComment();
s="Describe the lights present in the scene";
comment->SetValue(s.c_str());
map->LinkEndChild( comment );
TiXmlElement * lights = new TiXmlElement( "lights" );
map->LinkEndChild(lights);
std::map<std::string, LighInfo>::const_iterator it2 = it->second.Lights.begin();
std::map<std::string, LighInfo>::const_iterator end2 = it->second.Lights.end();
for(; it2 != end2; ++it2)
{
TiXmlElement * light = new TiXmlElement( "light" );
lights->LinkEndChild(light);
light->SetAttribute("name", it2->first);
light->SetAttribute("type", it2->second.Type);
light->SetAttribute("posX", it2->second.PosX);
light->SetAttribute("posY", it2->second.PosY);
light->SetAttribute("posZ", it2->second.PosZ);
light->SetAttribute("dirX", it2->second.DirX);
light->SetAttribute("dirY", it2->second.DirY);
light->SetAttribute("dirZ", it2->second.DirZ);
}
}
// spawning areas info block
{
comment = new TiXmlComment();
s="Describe the possible spawning areas of the main character";
comment->SetValue(s.c_str());
map->LinkEndChild( comment );
TiXmlElement * spareas = new TiXmlElement( "spareas" );
map->LinkEndChild(spareas);
std::map<std::string, SpawningInfo>::const_iterator it2 = it->second.Spawnings.begin();
std::map<std::string, SpawningInfo>::const_iterator end2 = it->second.Spawnings.end();
for(; it2 != end2; ++it2)
{
TiXmlElement * sparea = new TiXmlElement( "sparea" );
spareas->LinkEndChild(sparea);
sparea->SetAttribute("name", it2->first);
sparea->SetDoubleAttribute("posX", it2->second.PosX);
sparea->SetDoubleAttribute("posY", it2->second.PosY);
sparea->SetDoubleAttribute("posZ", it2->second.PosZ);
sparea->SetAttribute("RotationAtArrival", it2->second.Rotation);
}
}
// map exit info block
{
comment = new TiXmlComment();
s="Describe the possible map exit places using square areas from TopLeft point to BottomRight point";
comment->SetValue(s.c_str());
map->LinkEndChild( comment );
TiXmlElement * exits = new TiXmlElement( "exits" );
map->LinkEndChild(exits);
std::map<std::string, ExitInfo>::const_iterator it2 = it->second.Exits.begin();
std::map<std::string, ExitInfo>::const_iterator end2 = it->second.Exits.end();
for(; it2 != end2; ++it2)
{
TiXmlElement * exit = new TiXmlElement( "exit" );
exits->LinkEndChild(exit);
exit->SetAttribute("name", it2->first);
exit->SetDoubleAttribute("TopRightX", it2->second.TopRightX);
exit->SetDoubleAttribute("TopRightY", it2->second.TopRightY);
exit->SetDoubleAttribute("TopRightZ", it2->second.TopRightZ);
exit->SetDoubleAttribute("BottomLeftX", it2->second.BottomLeftX);
exit->SetDoubleAttribute("BottomLeftY", it2->second.BottomLeftY);
exit->SetDoubleAttribute("BottomLeftZ", it2->second.BottomLeftZ);
exit->SetAttribute("newMap", it2->second.NewMap);
exit->SetAttribute("spawning", it2->second.Spawning);
}
}
}
doc.SaveFile(Filename);
}
// save world information into file
void MapInfoXmlWriter::SaveTexts(const std::string Filename, const std::map<long, std::string> &txts)
{
TiXmlDocument doc;
TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "UTF8", "" );
doc.LinkEndChild( decl );
TiXmlElement * root = new TiXmlElement("texts");
doc.LinkEndChild( root );
std::map<long, std::string>::const_iterator it = txts.begin();
std::map<long, std::string>::const_iterator end = txts.end();
for(; it != end; ++it)
{
TiXmlElement * txt = new TiXmlElement( "text" );
txt->SetAttribute("id", it->first);
root->LinkEndChild(txt);
txt->LinkEndChild(new TiXmlText(it->second));
}
doc.SaveFile(Filename);
}
// save map actors into memory
void MapInfoXmlWriter::SaveActors(const std::string &Filename, std::map<long, Actor *> * vec)
{
TiXmlDocument doc;
TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "UTF8", "" );
doc.LinkEndChild( decl );
TiXmlElement * root = new TiXmlElement("actors");
doc.LinkEndChild( root );
std::map<long, Actor *>::const_iterator it = vec->begin();
std::map<long, Actor *>::const_iterator end = vec->end();
for(; it != end; ++it)
{
TiXmlElement * act = new TiXmlElement( "actor" );
root->LinkEndChild(act);
act->SetAttribute("id", it->second->GetId());
act->SetAttribute("type", it->second->GetType());
act->SetDoubleAttribute("posX", it->second->GetPosX());
act->SetDoubleAttribute("posY", it->second->GetPosY());
act->SetDoubleAttribute("posZ", it->second->GetPosZ());
act->SetDoubleAttribute("sizeX", it->second->GetSizeX());
act->SetDoubleAttribute("sizeY", it->second->GetSizeY());
act->SetDoubleAttribute("sizeZ", it->second->GetSizeZ());
act->SetDoubleAttribute("offsetsizeY", it->second->GetOffsetSizeY());
act->SetDoubleAttribute("rotation", it->second->GetRotation());
act->SetAttribute("passable", it->second->IsPassable());
act->SetAttribute("depthmask", it->second->IsDepthMask());
act->SetAttribute("movable", it->second->IsMovable());
act->SetAttribute("outputsignal", it->second->GetSignal());
act->SetAttribute("attachedsound", it->second->GetAttachedSound());
act->SetAttribute("collidable", it->second->GetCollidable());
act->SetAttribute("actif", it->second->GetActif());
act->SetAttribute("allowfreemove", it->second->GetAllowFreeMove());
{
std::vector<long> vect = it->second->GetTargets();
std::stringstream str;
if(vect.size() > 0)
str<<vect[0];
for(size_t i=1; i<vect.size(); ++i)
str<<","<<vect[i];
act->SetAttribute("signaltargets", str.str());
}
if(it->second->GetRenderer() != NULL)
{
act->SetAttribute("renderertype", it->second->GetRendererType());
std::vector<long> vect = it->second->GetRendererTarget();
std::stringstream str;
if(vect.size() > 0)
str<<vect[0];
for(size_t i=1; i<vect.size(); ++i)
str<<","<<vect[i];
act->SetAttribute("renderertarget", str.str());
}
switch(it->second->GetType())
{
case 1: //text actor class
{
{
TextActor * tmpa = static_cast<TextActor *>(it->second);
act->SetDoubleAttribute("activationdistance", tmpa->GetActivationDistance());
act->SetAttribute("textid", tmpa->GetTextId());
act->SetAttribute("activationtype", tmpa->GetActivationType());
}
}
break;
case 2: //ladder actor class
{
{
LadderActor * tmpa = static_cast<LadderActor *>(it->second);
act->SetDoubleAttribute("activationdistance", tmpa->GetActivationDistance());
act->SetDoubleAttribute("deltaX", tmpa->GetDX());
act->SetDoubleAttribute("deltaY", tmpa->GetDY());
act->SetDoubleAttribute("deltaZ", tmpa->GetDZ());
act->SetAttribute("direction", tmpa->GetDir());
act->SetAttribute("activationtype", tmpa->GetActivationType());
}
}
break;
case 3: //exit actor class
{
{
ExitActor * tmpa = static_cast<ExitActor *>(it->second);
act->SetDoubleAttribute("activationdistance", tmpa->GetActivationDistance());
act->SetDoubleAttribute("deltaX", tmpa->GetDX());
act->SetDoubleAttribute("deltaY", tmpa->GetDY());
act->SetDoubleAttribute("deltaZ", tmpa->GetDZ());
act->SetAttribute("direction", tmpa->GetDir());
act->SetAttribute("activationtype", tmpa->GetActivationType());
}
}
break;
case 4: //door actor class
{
{
DoorActor * tmpa = static_cast<DoorActor *>(it->second);
act->SetDoubleAttribute("zoneSizeX", tmpa->GetZoneX());
act->SetDoubleAttribute("zoneSizeY", tmpa->GetZoneY());
act->SetDoubleAttribute("zoneSizeZ", tmpa->GetZoneZ());
act->SetAttribute("locked", tmpa->GetLocked());
act->SetAttribute("keyid", tmpa->GetKeyId());
act->SetAttribute("hide", tmpa->GetHide());
act->SetAttribute("destroykey", tmpa->GetDesKey());
act->SetDoubleAttribute("OpenTransX", tmpa->GetOpenTransX());
act->SetDoubleAttribute("OpenTransY", tmpa->GetOpenTransY());
act->SetDoubleAttribute("OpenTransZ", tmpa->GetOpenTransZ());
act->SetDoubleAttribute("OpenTransSpeedX", tmpa->GetOpenTransSpeedX());
act->SetDoubleAttribute("OpenTransSpeedY", tmpa->GetOpenTransSpeedY());
act->SetDoubleAttribute("OpenTransSpeedZ", tmpa->GetOpenTransSpeedZ());
}
}
break;
case 5: //container actor class
{
{
ContainerActor * tmpa = static_cast<ContainerActor *>(it->second);
act->SetDoubleAttribute("zonesizeX", tmpa->GetZoneX());
act->SetDoubleAttribute("zonesizeY", tmpa->GetZoneY());
act->SetDoubleAttribute("zonesizeZ", tmpa->GetZoneZ());
act->SetAttribute("activationtype", tmpa->GetActivationType());
const std::vector<ItemGroup> & lootlist = tmpa->GetLootList();
for(size_t cci=0; cci<lootlist.size(); ++cci)
{
TiXmlElement * grit = new TiXmlElement( "itemgroup" );
grit->SetDoubleAttribute("respawnTimeInMs", lootlist[cci].RespawningTime);
act->LinkEndChild(grit);
for(size_t ccj=0; ccj<lootlist[cci].groupelements.size(); ++ccj)
{
TiXmlElement * grelem = new TiXmlElement( "item" );
grelem->SetDoubleAttribute("id", lootlist[cci].groupelements[ccj].id);
grelem->SetDoubleAttribute("number", lootlist[cci].groupelements[ccj].number);
grelem->SetDoubleAttribute("probability", lootlist[cci].groupelements[ccj].probability);
grit->LinkEndChild(grelem);
}
}
}
}
break;
case 6: //up exit actor class
{
{
UpExitActor * tmpa = static_cast<UpExitActor *>(it->second);
act->SetDoubleAttribute("activationdistance", tmpa->GetActivationDistance());
act->SetAttribute("direction", tmpa->GetDir());
act->SetAttribute("activationtype", tmpa->GetActivationType());
}
}
break;
case 7: //switch actor class
{
{
SwitchActor * tmpa = static_cast<SwitchActor *>(it->second);
act->SetDoubleAttribute("activationdistance", tmpa->GetActivationDistance());
act->SetAttribute("activationtype", tmpa->GetActivationType());
}
}
break;
case 8: //area switch actor class
{
{
AreaSwitch * tmpa = static_cast<AreaSwitch *>(it->second);
act->SetDoubleAttribute("zonesizeX", tmpa->GetZoneX());
act->SetDoubleAttribute("zonesizeY", tmpa->GetZoneY());
act->SetDoubleAttribute("zonesizeZ", tmpa->GetZoneZ());
act->SetAttribute("QuestToTriggerEnd", tmpa->GetQuestToTriggerEnd());
}
}
break;
case 9: //floor switch actor class
{
{
FloorSwitch * tmpa = static_cast<FloorSwitch *>(it->second);
act->SetDoubleAttribute("zonesizeX", tmpa->GetZoneX());
act->SetDoubleAttribute("zonesizeY", tmpa->GetZoneY());
act->SetDoubleAttribute("zonesizeZ", tmpa->GetZoneZ());
act->SetAttribute("activationtype", tmpa->GetActivationType());
}
}
break;
case 10: //lift actor class
{
{
ScriptableActor * tmpa = static_cast<ScriptableActor *>(it->second);
act->SetAttribute("autoattach", tmpa->GetAutoAttach());
const std::vector<PlayerScriptPart> & scriptsV = tmpa->GetScripts();
if(scriptsV.size() > 0)
{
TiXmlElement * scripts = new TiXmlElement( "scripts" );
act->LinkEndChild(scripts);
for(size_t cci=0; cci<scriptsV.size(); ++cci)
{
TiXmlElement * script = new TiXmlElement( "script" );
scripts->LinkEndChild(script);
script->SetAttribute("type", scriptsV[cci].Type);
script->SetDoubleAttribute("ValueA", scriptsV[cci].ValueA);
script->SetDoubleAttribute("ValueB", scriptsV[cci].ValueB);
script->SetDoubleAttribute("ValueC", scriptsV[cci].ValueC);
script->SetDoubleAttribute("Speed", scriptsV[cci].Speed);
script->SetAttribute("Sound", scriptsV[cci].Sound);
script->SetAttribute("SoundNum", scriptsV[cci].SoundNum);
script->SetAttribute("Animation", scriptsV[cci].Animation);
script->SetAttribute("Flag", scriptsV[cci].Flag);
}
}
}
}
break;
case 11: //hurt area class
{
{
HurtArea * tmpa = static_cast<HurtArea *>(it->second);
act->SetDoubleAttribute("zonesizeX", tmpa->GetZoneX());
act->SetDoubleAttribute("zonesizeY", tmpa->GetZoneY());
act->SetDoubleAttribute("zonesizeZ", tmpa->GetZoneZ());
act->SetDoubleAttribute("lifetaken", tmpa->GetLifeTaken());
}
}
break;
case 12: //NPC actor class
{
{
NPCActor * tmpa = static_cast<NPCActor *>(it->second);
act->SetAttribute("NPCType", tmpa->GetNPCType());
act->SetDoubleAttribute("activationdistance", tmpa->GetActivationDistance());
act->SetAttribute("Name", tmpa->GetName());
const std::vector<PlayerScriptPart> & scriptsV = tmpa->GetScripts();
if(scriptsV.size() > 0)
{
TiXmlElement * scripts = new TiXmlElement( "scripts" );
act->LinkEndChild(scripts);
for(size_t cci=0; cci<scriptsV.size(); ++cci)
{
TiXmlElement * script = new TiXmlElement( "script" );
scripts->LinkEndChild(script);
script->SetAttribute("type", scriptsV[cci].Type);
script->SetDoubleAttribute("ValueA", scriptsV[cci].ValueA);
script->SetDoubleAttribute("ValueB", scriptsV[cci].ValueB);
script->SetDoubleAttribute("ValueC", scriptsV[cci].ValueC);
script->SetDoubleAttribute("Speed", scriptsV[cci].Speed);
script->SetAttribute("Sound", scriptsV[cci].Sound);
script->SetAttribute("SoundNum", scriptsV[cci].SoundNum);
script->SetAttribute("Animation", scriptsV[cci].Animation);
script->SetAttribute("Flag", scriptsV[cci].Flag);
}
}
}
}
break;
case 13: //scripted zone actor
{
{
ScriptedZoneActor * tmpa = static_cast<ScriptedZoneActor *>(it->second);
act->SetDoubleAttribute("zonesizeX", tmpa->GetZoneX());
act->SetDoubleAttribute("zonesizeY", tmpa->GetZoneY());
act->SetDoubleAttribute("zonesizeZ", tmpa->GetZoneZ());
act->SetAttribute("activationtype", tmpa->GetActivationType());
act->SetAttribute("neededitem", tmpa->GetNeededItemId());
act->SetAttribute("destroyitem", tmpa->GetDesItem());
act->SetAttribute("abortedmessage", tmpa->GetAbortedMessage());
TiXmlElement * scripts = new TiXmlElement( "scripts" );
act->LinkEndChild(scripts);
const std::vector<PlayerScriptPart> & scriptsV = tmpa->GetScripts();
for(size_t cci=0; cci<scriptsV.size(); ++cci)
{
TiXmlElement * script = new TiXmlElement( "script" );
scripts->LinkEndChild(script);
script->SetAttribute("type", scriptsV[cci].Type);
script->SetDoubleAttribute("ValueA", scriptsV[cci].ValueA);
script->SetDoubleAttribute("ValueB", scriptsV[cci].ValueB);
script->SetDoubleAttribute("ValueC", scriptsV[cci].ValueC);
script->SetDoubleAttribute("Speed", scriptsV[cci].Speed);
script->SetAttribute("Sound", scriptsV[cci].Sound);
script->SetAttribute("SoundNum", scriptsV[cci].SoundNum);
script->SetAttribute("Animation", scriptsV[cci].Animation);
script->SetAttribute("Flag", scriptsV[cci].Flag);
script->SetAttribute("newMap", scriptsV[cci].NewMap);
script->SetAttribute("spawning", scriptsV[cci].Spawning);
}
}
}
break;
case 14: //mailbox class
{
{
MailboxActor * tmpa = static_cast<MailboxActor *>(it->second);
act->SetDoubleAttribute("activationdistance", tmpa->GetActivationDistance());
act->SetAttribute("activationtype", tmpa->GetActivationType());
}
}
break;
}
}
doc.SaveFile(Filename);
}
// save all sprites info
void MapInfoXmlWriter::SaveSprites(const std::string &Filename, std::map<long, SpriteInfo> *vec)
{
TiXmlDocument doc;
TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "UTF8", "" );
doc.LinkEndChild( decl );
TiXmlElement * root = new TiXmlElement("sprites");
doc.LinkEndChild( root );
std::map<long, SpriteInfo>::const_iterator it = vec->begin();
std::map<long, SpriteInfo>::const_iterator end = vec->end();
for(; it != end; ++it)
{
TiXmlElement * act = new TiXmlElement( "sprite" );
root->LinkEndChild(act);
act->SetAttribute("id", it->first);
act->SetAttribute("filename", it->second.filename);
std::vector<QuadImageInfo>::const_iterator itq = it->second.quadsInfo.begin();
std::vector<QuadImageInfo>::const_iterator endq = it->second.quadsInfo.end();
for(; itq != endq; ++itq)
{
TiXmlElement * quad = new TiXmlElement( "textpart" );
act->LinkEndChild(quad);
quad->SetAttribute("UseFullImage", itq->UseFullImage);
quad->SetDoubleAttribute("BottomLeftCornerX", itq->BottomLeftCornerX);
quad->SetDoubleAttribute("BottomLeftCornerY", itq->BottomLeftCornerY);
quad->SetDoubleAttribute("BottomLeftCornerZ", itq->BottomLeftCornerZ);
quad->SetDoubleAttribute("TopRightCornerX", itq->TopRightCornerX);
quad->SetDoubleAttribute("TopRightCornerY", itq->TopRightCornerY);
quad->SetDoubleAttribute("TopRightCornerZ", itq->TopRightCornerZ);
quad->SetDoubleAttribute("BottomRightCornerX", itq->BottomRightCornerX);
quad->SetDoubleAttribute("BottomRightCornerY", itq->BottomRightCornerY);
quad->SetDoubleAttribute("BottomRightCornerZ", itq->BottomRightCornerZ);
quad->SetDoubleAttribute("TopLeftCornerX", itq->TopLeftCornerX);
quad->SetDoubleAttribute("TopLeftCornerY", itq->TopLeftCornerY);
quad->SetDoubleAttribute("TopLeftCornerZ", itq->TopLeftCornerZ);
//quad->SetDoubleAttribute("BottomRightCornerX",itq->TopRightCornerX);//itq->BottomRightCornerX);
//quad->SetDoubleAttribute("BottomRightCornerY",itq->BottomLeftCornerY);//itq->BottomRightCornerY);
//quad->SetDoubleAttribute("BottomRightCornerZ",itq->TopRightCornerZ);//itq->BottomRightCornerZ);
//quad->SetDoubleAttribute("TopLeftCornerX",itq->BottomLeftCornerX);//itq->TopLeftCornerX);
//quad->SetDoubleAttribute("TopLeftCornerY",itq->TopRightCornerY);//itq->TopLeftCornerY);
//quad->SetDoubleAttribute("TopLeftCornerZ",itq->BottomLeftCornerZ);//itq->TopLeftCornerZ);
quad->SetAttribute("BottomLeftTextcoordX", itq->BottomLeftTextcoordX);
quad->SetAttribute("BottomLeftTextcoordY", itq->BottomLeftTextcoordY);
quad->SetAttribute("BottomRightTextcoordX", itq->BottomRightTextcoordX);
quad->SetAttribute("BottomRightTextcoordY", itq->BottomRightTextcoordY);
quad->SetAttribute("TopLeftTextcoordX", itq->TopLeftTextcoordX);
quad->SetAttribute("TopLeftTextcoordY", itq->TopLeftTextcoordY);
quad->SetAttribute("TopRightTextcoordX", itq->TopRightTextcoordX);
quad->SetAttribute("TopRightTextcoordY", itq->TopRightTextcoordY);
}
}
doc.SaveFile(Filename);
} | [
"vdelage@3806491c-8dad-11de-9a8c-6d5b7d1e4d13"
] | [
[
[
1,
680
]
]
] |
9292810948e232afdcd8b5c4840af678e4f47882 | 5fb8a3390a3bf748a1c902724d6fe20f6524c4b7 | /Dogfight2D/src/InputListener.h | f7275af3b7ecea53884bbe7dbc83ec4606db0b9a | [] | no_license | DavidVondras/charlydogfightgame | 7e7d46cd4830afca8dade4e19751cdc5bf10b685 | 1631adf036da607318e833ab7322af0b57d52e35 | refs/heads/master | 2016-09-07T18:49:31.344404 | 2011-01-01T20:37:22 | 2011-01-01T20:37:22 | 41,377,758 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 440 | h | #pragma once
#include <SFML\Graphics.hpp>
namespace df
{
class InputListener
{
protected:
virtual void ProcessEvent(sf::Event inputEvent, sf::RenderWindow &renderWindow) = 0;
virtual void OnListenCalled(sf::RenderWindow &renderWindow) = 0;
public:
InputListener(void);
~InputListener(void);
virtual bool IsGameListener(void) const { return false; }
void Listen(sf::RenderWindow &renderWindow);
};
}
| [
"charles.hetier@2e9598b8-afb8-4876-edc4-84008ec66e72"
] | [
[
[
1,
20
]
]
] |
9c2acde3f4d0cedecdb385fb8b879fe0a38c4d89 | c5534a6df16a89e0ae8f53bcd49a6417e8d44409 | /trunk/nGENE Proj/MeshLoadPolicyCollada.cpp | 53c47219f325dbcd84929995e0fe95d71069b3c9 | [] | no_license | svn2github/ngene | b2cddacf7ec035aa681d5b8989feab3383dac012 | 61850134a354816161859fe86c2907c8e73dc113 | refs/heads/master | 2023-09-03T12:34:18.944872 | 2011-07-27T19:26:04 | 2011-07-27T19:26:04 | 78,163,390 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 28,214 | cpp | /*
---------------------------------------------------------------------------
This source file is part of nGENE Tech.
Copyright (c) 2006- Wojciech Toman
This program is free software.
File: MeshLoadPolicyCollada.cpp
Version: 0.08
Author: Thomas Enzenebner
Revisor: Wojciech Toman
---------------------------------------------------------------------------
*/
#include "PrecompiledHeaders.h"
#include "MeshLoadPolicyCollada.h"
#include "AABB.h"
#include "FileNarrow.h"
#include "FuncSplit.h"
#include "Point.h"
#include "Quaternion.h"
#include "Vertex.h"
#include "VertexBuffer.h"
#include "VertexBufferManager.h"
#include "XMLDocument.h"
#include "XMLNode.h"
#include "XMLParser.h"
namespace nGENE
{
// Initialize static members
TypeInfo MeshLoadPolicyCollada::Type(L"MeshLoadPolicyCollada", NULL);
vector <Surface> MeshLoadPolicyCollada::loadMesh(const wstring& _fileName,
const Matrix4x4& _transform, bool _moveToCentre)
{
m_matTransform = _transform;
m_bMoveToCentre = _moveToCentre;
const string assetSectionName = "asset";
vector <Surface> vPolicySurfaces;
// Open file
File* m_pFile = static_cast<File*>(FileManager::getSingleton().openFile(_fileName, OPEN_READ));
wstring temp = m_pFile->getBuffer();
FileManager::getSingleton().closeFile(_fileName);
XMLDocument* pDocument = XMLParser::getSingleton().parse(temp, false);
XMLDocument* pChild = pDocument->getFirstChild();
XMLDocument* m_pCurrentNode = NULL;
while(pChild)
{
string nodeName = pChild->getTagName();
if(nodeName == "asset")
{
loadAsset(pChild->getFirstChild());
}
else if(nodeName == "library_geometries")
{
loadGeometry(pChild->getFirstChild(), vPolicySurfaces);
}
else if(nodeName == "library_images")
{
loadImages(pChild->getFirstChild());
}
else if(nodeName == "library_materials")
{
loadMaterials(pChild->getFirstChild());
}
else if(nodeName == "library_visual_scenes")
{
loadScenes(pChild->getFirstChild(), vPolicySurfaces);
}
m_pCurrentNode = pChild;
pChild = pChild->getNextSibling();
NGENE_DELETE(m_pCurrentNode);
}
NGENE_DELETE(pDocument);
return vPolicySurfaces;
}
//----------------------------------------------------------------------
void MeshLoadPolicyCollada::loadScene(XMLDocument* _node, vector <Surface>& _surfaces)
{
XMLDocument* pNode = _node;
XMLDocument* pTemp = _node;
while(pNode)
{
string tagName = pNode->getTagName();
if(tagName == "node")
{
string stNodeId = pNode->getAttribute("id");
string stNodeName = pNode->getAttribute("name");
string stType = pNode->getAttribute("type");
if(stNodeName == "" && stNodeId != "")
stNodeName = stNodeId;
loadNode(pNode->getFirstChild(), stNodeId, _surfaces, stType, "", "", NULL);
}
pTemp = pNode;
pNode = pNode->getNextSibling();
NGENE_DELETE(pTemp);
}
}
//----------------------------------------------------------------------
void MeshLoadPolicyCollada::loadNode(XMLDocument* _node, const string& _nodeName,
vector <Surface>& _surfaces, const string& _type, const string& _parentName,
const string& _parentType, const Matrix4x4* _parentTransform)
{
XMLDocument* pNode = _node;
XMLDocument* pTemp = _node;
Matrix4x4 matTrans;
Matrix4x4 matRot;
Matrix4x4 matScale;
Quaternion quatX, quatY, quatZ;
bool bBakedMatrices = false;
Vector3 vecEulerAngles;
SModel* pModel = NULL;
while(pNode)
{
string tagName = pNode->getTagName();
// <translate> tells translation of the node
if(tagName == "translate")
{
string trans = pNode->getValue();
vector <string> splitArray;
splitStr(splitArray, trans, " \n\r\t", true, true);
Vector3 vecTrans;
if(m_Asset.upVector == CUV_Y)
{
vecTrans.set(atof(splitArray[0].c_str()),
atof(splitArray[1].c_str()),
atof(splitArray[2].c_str()));
}
else
{
vecTrans.set(atof(splitArray[0].c_str()),
atof(splitArray[2].c_str()),
atof(splitArray[1].c_str()));
}
matTrans.translate(vecTrans);
}
// <rotate> tells the rotation about x, y and z axes
else if(tagName == "rotate")
{
// X axis
string sid = pNode->getAttribute("sid");
if(sid.find("X") != string::npos)
{
string rot = pNode->getValue();
vector <string> splitArray;
splitStr(splitArray, rot, " \n\r\t", true, true);
vecEulerAngles.x = Maths::degToRad(atof(splitArray[3].c_str()));
quatX.set(Vector3::UNIT_X, vecEulerAngles.x);
}
// Y axis
else if(sid.find("Y") != string::npos)
{
string rot = pNode->getValue();
vector <string> splitArray;
splitStr(splitArray, rot, " \n\r\t", true, true);
if(m_Asset.upVector == CUV_Y)
{
vecEulerAngles.y = Maths::degToRad(atof(splitArray[3].c_str()));
quatY.set(Vector3::UNIT_Y, vecEulerAngles.y);
}
else
{
vecEulerAngles.z = Maths::degToRad(atof(splitArray[3].c_str()));
quatZ.set(Vector3::UNIT_Z, vecEulerAngles.z);
}
}
// Z axis
else if(sid.find("Z") != string::npos)
{
string rot = pNode->getValue();
vector <string> splitArray;
splitStr(splitArray, rot, " \n\r\t", true, true);
if(m_Asset.upVector == CUV_Y)
{
vecEulerAngles.z = Maths::degToRad(atof(splitArray[3].c_str()));
quatZ.set(Vector3::UNIT_Z, vecEulerAngles.z);
}
else
{
vecEulerAngles.y = Maths::degToRad(atof(splitArray[3].c_str()));
quatY.set(Vector3::UNIT_Y, vecEulerAngles.y);
}
}
}
// <scale> tag tells scaling of the node
else if(tagName == "scale")
{
string scale = pNode->getValue();
vector <string> splitArray;
splitStr(splitArray, scale, " \n\r\t", true, true);
Vector3 vecScale;
if(m_Asset.upVector == CUV_Y)
{
vecScale.set(atof(splitArray[0].c_str()),
atof(splitArray[1].c_str()),
atof(splitArray[2].c_str()));
}
else
{
vecScale.set(atof(splitArray[0].c_str()),
atof(splitArray[2].c_str()),
atof(splitArray[1].c_str()));
}
matScale.scale(vecScale);
}
// <matrix> have transformation data baked in
else if(tagName == "matrix")
{
string matrix = pNode->getValue();
vector <string> splitArray;
splitStr(splitArray, matrix, " \n\r\t", true, true);
for(uint i = 0; i < 16; ++i)
matTrans.m[i] = atof(splitArray[i].c_str());
if(m_Asset.upVector == CUV_Z)
{
float fTmp = matTrans._m42;
matTrans._m42 = matTrans._m43;
matTrans._m43 = fTmp;
}
matTrans.transpose();
bBakedMatrices = true;
}
// <instance_geometry> binds this node with existing mesh
else if(tagName == "instance_geometry")
{
string name = pNode->getAttribute("url");
name = name.substr(1, name.size() - 1);
pModel = &m_Models[name];
}
// <node> can have child nodes
else if(tagName == "node")
{
string stNodeId = pNode->getAttribute("id");
string stNodeName = pNode->getAttribute("name");
string stType = pNode->getAttribute("type");
if(stNodeName == "" && stNodeId != "")
stNodeName = stNodeId;
matRot.rotateYawPitchRoll(vecEulerAngles);
Matrix4x4 matTransform = matScale * matRot * matTrans;
loadNode(pNode->getFirstChild(), stNodeId, _surfaces, stType, _nodeName, _type,
&matTransform);
}
pTemp = pNode;
pNode = pNode->getNextSibling();
NGENE_DELETE(pTemp);
}
Quaternion quatRot = quatZ * quatY * quatX;//quatZ * quatY * quatX;
matRot = quatRot.toMatrix();
//matRot.rotateYawPitchRoll(vecEulerAngles);
Matrix4x4 matTransform;
if(bBakedMatrices)
matTransform = matTrans;
else
matTransform = matScale * matRot * matTrans;
// Create Collada node
processNodeType(_type, pModel, matTransform, _surfaces, _nodeName, _parentName, _parentType,
_parentTransform);
}
//----------------------------------------------------------------------
void MeshLoadPolicyCollada::loadAsset(XMLDocument* _node)
{
XMLDocument* pNode = _node;
XMLDocument* pTemp = _node;
while(pNode)
{
string tagName = pNode->getTagName();
if(tagName == "contributor")
{
SAssetContributor tempContributor;
pTemp = pNode->getFirstChild();
while(pTemp)
{
if(pTemp->getTagName() == "author")
tempContributor.stAuthor = pTemp->getValue();
if(pTemp->getTagName() == "authoring_tool")
tempContributor.stAuthoringTool = pTemp->getValue();
if(pTemp->getTagName() == "comments")
tempContributor.stComments = pTemp->getValue();
if(pTemp->getTagName() == "copyright")
tempContributor.stCopyright = pTemp->getValue();
if(pTemp->getTagName() == "source_data")
tempContributor.stSourceData = pTemp->getValue();
pTemp = pTemp->getNextSibling();
}
m_Asset.pContributor.push_back(tempContributor);
}
else if(tagName == "created")
m_Asset.stCreated = pNode->getValue();
else if(tagName == "modified")
m_Asset.stModified = pNode->getValue();
else if(tagName == "unit")
{
m_Asset.stUnitMeter = pNode->getAttribute("meter");
m_Asset.stUnitName = pNode->getAttribute("name");
}
else if(tagName == "up_axis")
{
string upAxis = pNode->getValue();
if(upAxis == "Y_UP")
m_Asset.upVector = CUV_Y;
else
m_Asset.upVector = CUV_Z;
}
pTemp = pNode;
pNode = pNode->getNextSibling();
NGENE_DELETE(pTemp);
}
}
//----------------------------------------------------------------------
void MeshLoadPolicyCollada::loadImages(XMLDocument* _node)
{
}
//----------------------------------------------------------------------
void MeshLoadPolicyCollada::loadScenes(XMLDocument* _node, vector <Surface>& _surfaces)
{
XMLDocument* pNode = _node;
XMLDocument* pTemp = _node;
while(pNode)
{
string tagName = pNode->getTagName();
if(tagName == "visual_scene")
{
loadScene(pNode->getFirstChild(), _surfaces);
}
pTemp = pNode;
pNode = pNode->getNextSibling();
NGENE_DELETE(pTemp);
}
}
//----------------------------------------------------------------------
void MeshLoadPolicyCollada::loadMaterials(XMLDocument* _node)
{
}
//----------------------------------------------------------------------
void MeshLoadPolicyCollada::loadGeometry(XMLDocument* _node, vector <Surface>& _surfaces)
{
XMLDocument* pNode = _node;
XMLDocument* pTemp = _node;
while(pNode)
{
if(pNode->getTagName() == "geometry")
{
stMeshId = pNode->getAttribute("id");
stMeshName = pNode->getAttribute("name");
if(stMeshName == "" && stMeshId != "")
stMeshName = stMeshId;
else if(stMeshName == "" && stMeshId == "")
{
stringstream buffer;
buffer << "Surface_" << _surfaces.size();
stMeshName = buffer.str();
}
pTemp = pNode->getFirstChild();
while(pTemp)
{
if(pTemp->getTagName() == "mesh")
{
//<mesh><source id="" name=""> name: position, normal, map1
processMeshNode(pTemp->getFirstChild(), _surfaces);
}
if(pTemp->getTagName() == "extra")
{
bDoubleSided = true;
}
pTemp = pTemp->getNextSibling();
}
}
pTemp = pNode;
pNode = pNode->getNextSibling();
NGENE_DELETE(pTemp);
}
}
//----------------------------------------------------------------------
void MeshLoadPolicyCollada::processMeshNode(XMLDocument* _node, vector<Surface>& _surfaces)
{
XMLDocument* pNode = _node;
XMLDocument* pTemp = NULL;
// Create model object
SModel model;
while(pNode)
{
string tagName = pNode->getTagName();
if(tagName == "source")
{
string id = pNode->getAttribute("id");
string name = pNode->getAttribute("name");
processSourceNode(pNode->getFirstChild(), id, name);
}
else if(tagName == "vertices")
{
VertexPositionSource = pNode->getFirstChild()->getNextSibling()->getAttribute("source");
VertexPositionSource = VertexPositionSource.substr(1, VertexPositionSource.size()); // We delete the first '#'
model.vertexSource = VertexPositionSource;
}
else if(tagName == "triangles" || tagName == "polygons")
{
Surface surface;
wstring stName(stMeshName.begin(), stMeshName.end());
uint index = stName.find_first_of(L"-");
stName = stName.substr(0, index);
wstringstream buffer;
buffer << stName << "_" << model.surfaces.size();
surface.setName(buffer.str());
model.surfaces.push_back(surface);
index = model.surfaces.size() - 1;
STriangleSet set;
memset(&set, 0, sizeof(STriangleSet));
processTriangles(pNode->getFirstChild(), &set, model.surfaces[index], pNode->getTagName());
model.sets.push_back(set);
}
else if(tagName == "polylist")
{
Surface surface;
wstring stName(stMeshName.begin(), stMeshName.end());
uint index = stName.find_first_of(L"-");
stName = stName.substr(0, index);
wstringstream buffer;
buffer << stName << "_" << model.surfaces.size();
surface.setName(buffer.str());
model.surfaces.push_back(surface);
index = model.surfaces.size() - 1;
STriangleSet set;
memset(&set, 0, sizeof(STriangleSet));
processTriangles(pNode->getFirstChild(), &set, model.surfaces[index], pNode->getTagName());
model.sets.push_back(set);
}
pTemp = pNode;
pNode = pNode->getNextSibling();
NGENE_DELETE(pTemp);
}
if(model.surfaces.size())
m_Models[stMeshName] = model;
}
//----------------------------------------------------------------------
void MeshLoadPolicyCollada::readArray(XMLDocument* _node, SSource* _source)
{
XMLDocument* pNode = _node;
XMLDocument* pTemp = NULL;
vector <string> splitArray;
string tempValues;
while(pNode)
{
string nodeName = pNode->getTagName();
if(nodeName.find("array") != string::npos) // float_array, int_array,...
{
_source->Array.Id = pNode->getAttribute("id");
tempValues = pNode->getValue();
}
else if(nodeName == "technique_common")
{
if(pNode->getFirstChild()->getNextSibling()->getTagName() == "accessor")
{
XMLDocument* accessorNode = pNode->getFirstChild()->getNextSibling();
_source->Accessors.Count = (uint)atoi(accessorNode->getAttribute("count").c_str());
_source->Accessors.Stride = (uint)atoi(accessorNode->getAttribute("stride").c_str());
XMLDocument* parameterNode = accessorNode->getFirstChild();
while(parameterNode)
{
if(parameterNode->getTagName() == "param")
{
SColladaParam param;
param.Name = parameterNode->getAttribute("name");
param.Type = parameterNode->getAttribute("type");
_source->Accessors.Parameters.push_back(param);
}
parameterNode = parameterNode->getNextSibling();
}
}
}
pTemp = pNode;
pNode = pNode->getNextSibling();
NGENE_DELETE(pTemp);
}
splitStr(splitArray, tempValues, " \n\r\t", true, true);
for(uint i = 0; i < splitArray.size(); ++i)
{
_source->Array.Data.push_back(atof(splitArray[i].c_str()));
}
}
//----------------------------------------------------------------------
void MeshLoadPolicyCollada::processSourceNode(XMLDocument* _node, string id, string name)
{
SSource sourceNode;
sourceNode.Id = id;
sourceNode.Name = name;
readArray(_node, &sourceNode);
m_ColladaSource[sourceNode.Id] = sourceNode;
}
//----------------------------------------------------------------------
void MeshLoadPolicyCollada::processTriangles(XMLDocument* _node, STriangleSet* _model,
Surface& _surface, string geometryType)
{
XMLDocument* pNode = _node;
XMLDocument* pTemp = NULL;
string& indicesArray = _model->indicesArray;
vector <string> pVertex;
vector <string> verticesPerPolygon;
uint attributesNum = 0;
while(pNode)
{
string tagName = pNode->getTagName();
// <input> information about data sources, their type, offset etc.
if(tagName == "input")
{
SColladaSemantic tempSemantic;
tempSemantic.offset = (unsigned)atoi(pNode->getAttribute("offset").c_str());
tempSemantic.source = pNode->getAttribute("source");
tempSemantic.source = tempSemantic.source.substr(1, tempSemantic.source.size()); // We delete the first '#'
tempSemantic.set = (unsigned)atoi(pNode->getAttribute("set").c_str());
string semantic = pNode->getAttribute("semantic");
if(semantic == "VERTEX")
tempSemantic.type = COLLADA_SEMANTIC_VERTEX;
else if(semantic == "NORMAL")
tempSemantic.type = COLLADA_SEMANTIC_NORMAL;
else if(semantic == "TEXCOORD")
tempSemantic.type = COLLADA_SEMANTIC_TEXCOORD;
else if(semantic == "TEXTANGENT")
tempSemantic.type = COLLADA_SEMANTIC_TEXTANGENT;
else if(semantic == "TEXBINORMAL")
tempSemantic.type = COLLADA_SEMANTIC_TEXBINORMAL;
_model->semanticMapping.push_back(tempSemantic);
++attributesNum;
}
// <vcount> tag specifies number of vertices for each of the polygons
else if(tagName == "vcount")
{
FuncSplit <string> tokenizer;
tokenizer(pNode->getValue(), verticesPerPolygon, " ");
}
// <p> tag stands for primitives
else if(tagName == "p")
{
if(geometryType == "triangles")
indicesArray.append(pNode->getValue());
else if(geometryType == "polylist" || geometryType == "polygons")
{
vector <string> tempPrimitive;
splitStr(tempPrimitive, pNode->getValue(), " \n\r\t", true, true);
uint triangleIndex = 0;
uint startIndex = 0;
for(uint j = 0; j < verticesPerPolygon.size(); ++j)
{
uint vertices = (uint)atoi(verticesPerPolygon[triangleIndex++].c_str());
if(vertices == 3)
{
for(uint i = 0; i < vertices * attributesNum; ++i)
{
indicesArray.append(tempPrimitive[startIndex++]);
indicesArray.append(" ");
}
}
else if(vertices == 4)
{
for(uint attr = 0; attr < attributesNum; ++attr)
{
indicesArray.append(tempPrimitive[startIndex + attr]);
indicesArray.append(" ");
}
for(uint attr = 0; attr < attributesNum; ++attr)
{
indicesArray.append(tempPrimitive[startIndex + attributesNum + attr]);
indicesArray.append(" ");
}
for(uint attr = 0; attr < attributesNum; ++attr)
{
indicesArray.append(tempPrimitive[startIndex + 3 * attributesNum + attr]);
indicesArray.append(" ");
}
for(uint attr = 0; attr < attributesNum; ++attr)
{
indicesArray.append(tempPrimitive[startIndex + 2 * attributesNum + attr]);
indicesArray.append(" ");
}
for(uint attr = 0; attr < attributesNum; ++attr)
{
indicesArray.append(tempPrimitive[startIndex + 3 * attributesNum + attr]);
indicesArray.append(" ");
}
for(uint attr = 0; attr < attributesNum; ++attr)
{
indicesArray.append(tempPrimitive[startIndex + attributesNum + attr]);
indicesArray.append(" ");
}
startIndex += 4 * attributesNum;
}
}
}
}
pTemp = pNode;
pNode = pNode->getNextSibling();
NGENE_DELETE(pTemp);
}
}
//----------------------------------------------------------------------
void MeshLoadPolicyCollada::processPrimitives(XMLDocument* _node, vector <ushort> _indicesArray)
{
}
//----------------------------------------------------------------------
void MeshLoadPolicyCollada::createMesh(SModel* _model, STriangleSet* _set, Surface& _surface,
const Matrix4x4& _transform)
{
vector <string> splitArray;
uint indicesCount = splitStr(splitArray, _set->indicesArray, " \n\r\t", true, true);
_set->nIndicesCount = indicesCount / 3;
vector <string>::const_iterator iter = splitArray.begin();
HashTable <string, SVertexKey> key;
// We need to build a new list of vertices and indices
// for this we set some variables to 0
ushort indexIncrementer = 0;
_set->nVerticesCount = 0;
_set->nIndicesCount = 0;
vector <SColladaSemantic>& semanticMapping = _set->semanticMapping;
string positionSource = _model->vertexSource;
for(uint i = 0; i < indicesCount;)
{
// Build the single SVertex
SVertexKey tempKey;
memset(&tempKey, 0, sizeof(SVertexKey));
string tempKeyString = "";
for(uint ii = 0; ii < _set->semanticMapping.size(); ++ii, i++)
{
nGENE_COLLADA_SEMANTIC_TYPE type = semanticMapping[ii].type;
switch(type)
{
case COLLADA_SEMANTIC_VERTEX:
tempKey.nVertexIndex = (ushort)atoi(splitArray[i].c_str());
break;
case COLLADA_SEMANTIC_NORMAL:
tempKey.nNormalIndex = (ushort)atoi(splitArray[i].c_str());
break;
case COLLADA_SEMANTIC_TEXCOORD:
tempKey.nTextureIndex = (ushort)atoi(splitArray[i].c_str());
break;
case COLLADA_SEMANTIC_TEXTANGENT:
tempKey.nTextureTangent = (ushort)atoi(splitArray[i].c_str());
break;
case COLLADA_SEMANTIC_TEXBINORMAL:
tempKey.nTextureBinormal = (ushort)atoi(splitArray[i].c_str());
break;
}
tempKeyString.append(splitArray[i]);
}
if(key.find(tempKeyString) != key.end())
{
// Already in the list, retrieve the value and set the index
_set->pIndices.push_back(key[tempKeyString].index);
_set->nIndicesCount++;
}
else
{
// The key is unique, so we need to insert it
tempKey.index = indexIncrementer; // We set a new unique index value, afterwards we increment it
key[tempKeyString] = tempKey;
indexIncrementer++;
SVertex tempSurface;
memset(&tempSurface, 0, sizeof(SVertex));
for(uint ii = 0; ii < semanticMapping.size(); ++ii)
{
nGENE_COLLADA_SEMANTIC_TYPE type = semanticMapping[ii].type;
// Position
if(type == COLLADA_SEMANTIC_VERTEX)
{
uint position = tempKey.nVertexIndex * m_ColladaSource[positionSource].Accessors.Stride;
Vector4 pos;
if(m_Asset.upVector == CUV_Y)
{
//-x,y,z
pos.x = -m_ColladaSource[positionSource].Array.Data[position];
pos.y = m_ColladaSource[positionSource].Array.Data[position + 1];
pos.z = m_ColladaSource[positionSource].Array.Data[position + 2];
}
else
{
pos.x = m_ColladaSource[positionSource].Array.Data[position];
pos.z = m_ColladaSource[positionSource].Array.Data[position + 1];
pos.y = m_ColladaSource[positionSource].Array.Data[position + 2];
}
pos.w = 1.0f;
pos *= _transform;
tempSurface.vecPosition = Vector3(pos.x, pos.y, pos.z);
if(!m_matTransform.isIdentity())
{
Vector4 vecPos(tempSurface.vecPosition, 0.0f);
vecPos.multiply(m_matTransform);
tempSurface.vecPosition.set(vecPos.x, vecPos.y, vecPos.z);
}
}
// Normal vector
else if(type == COLLADA_SEMANTIC_NORMAL)
{
uint position = tempKey.nNormalIndex * m_ColladaSource[semanticMapping[ii].source].Accessors.Stride;
tempSurface.vecNormal.x = m_ColladaSource[semanticMapping[ii].source].Array.Data[position];
tempSurface.vecNormal.y = m_ColladaSource[semanticMapping[ii].source].Array.Data[position + 1];
tempSurface.vecNormal.z = m_ColladaSource[semanticMapping[ii].source].Array.Data[position + 2];
}
// Texture coordinate
else if(type == COLLADA_SEMANTIC_TEXCOORD)
{
uint position = tempKey.nTextureIndex * m_ColladaSource[semanticMapping[ii].source].Accessors.Stride;
tempSurface.vecTexCoord.x = m_ColladaSource[semanticMapping[ii].source].Array.Data[position];
tempSurface.vecTexCoord.y = 1.0f - m_ColladaSource[semanticMapping[ii].source].Array.Data[position + 1];
}
}
_set->pSurface.push_back(tempSurface);
_set->pIndices.push_back(tempKey.index); // We set the old value of the index so we can get it back later and build the indices
_set->nIndicesCount++;
_set->nVerticesCount++;
}
}
SVertexSkinning* pArray = &(*_set->pSurface2.begin());
if(m_bMoveToCentre)
{
AABB box;
dword dwVerticesCount = _set->pSurface2.size();
box.construct(pArray, dwVerticesCount, sizeof(SVertex), 0);
Vector3 vecCentre = box.getCentre();
for(uint i = 0; i < dwVerticesCount; ++i)
{
pArray[i].position -= vecCentre;
}
}
IndexedBuffer* ivb;
VertexBuffer* vb;
VertexBufferManager& manager = VertexBufferManager::getSingleton();
VERTEXBUFFER_DESC vbDesc;
vbDesc.vertices = pArray;
vbDesc.verticesNum = _set->nVerticesCount;
vbDesc.primitivesNum = _set->nIndicesCount / 3;
vbDesc.vertexDeclaration = manager.getVertexDeclaration(L"Default");
vb = manager.createVertexBuffer(vbDesc);
_surface.setVertexBuffer(vb);
if(_set->nIndicesCount)
{
INDEXEDBUFFER_DESC ivbDesc;
ivbDesc.indices = &(*_set->pIndices.begin());
ivbDesc.indicesNum = _set->nIndicesCount;
ivb = manager.createIndexedBuffer(ivbDesc);
vb->setIndexedBuffer(ivb);
}
}
//----------------------------------------------------------------------
int MeshLoadPolicyCollada::splitStr(vector <string>& L, const string& seq,
const string& _1cdelim, bool keeptoken, bool _removews)
{
typedef string::size_type ST;
string delims = _1cdelim;
string STR;
if(delims.empty())
delims = "\n\r";
ST pos = 0, LEN = seq.size();
while(pos < LEN)
{
STR = ""; // Init/clear the STR token buffer
// remove any delimiters including optional (white)spaces
while((delims.find(seq[pos]) != string::npos) && (pos < LEN))
++pos;
// leave if @eos
if(pos == LEN)
return L.size();
// Save token data
while((delims.find(seq[pos]) == string::npos) && (pos < LEN))
STR += seq[pos++];
if(!STR.empty())
L.push_back(STR);
}
return L.size();
}
//----------------------------------------------------------------------
void MeshLoadPolicyCollada::processNodeType(const string& _type, SModel* _model,
const Matrix4x4& _transform, vector <Surface>& _surfaces, const string& _nodeName,
const string& _parentName, const string& _parentType, const Matrix4x4* _parentTransform)
{
if(_type == "" || _type == "NODE")
processNodeTypeNode(_model, _transform, _surfaces);
}
//----------------------------------------------------------------------
void MeshLoadPolicyCollada::processNodeTypeNode(SModel* _model, const Matrix4x4& _transform,
vector <Surface>& _surfaces)
{
if(!_model)
{
HashTable <string, SModel>::iterator iter;
for(iter = m_Models.begin(); iter != m_Models.end(); ++iter)
{
_model = &iter->second;
break;
}
}
if(_model && _model->surfaces.size())
{
uint surfacesNum = _model->surfaces.size();
for(uint i = 0; i < surfacesNum; ++i)
{
createMesh(_model, &_model->sets[i], _model->surfaces[i], _transform);
_surfaces.push_back(_model->surfaces[i]);
_model->sets[i].semanticMapping.clear();
}
_model->surfaces.clear();
}
}
//----------------------------------------------------------------------
MeshLoadPolicyCollada::MeshLoadPolicyCollada():
m_pDocument(NULL)
{
}
//----------------------------------------------------------------------
}
| [
"Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57"
] | [
[
[
1,
967
]
]
] |
3cd80cf5811538448f82994f034d5313cb847213 | 789bfae90cbb728db537b24eb9ab21c88bda2786 | /source/GameLostVisibleWaitStateClass.cpp | 2e235e0c20a2ceeb048031cc3abc5a2af1690809 | [
"MIT"
] | permissive | Izhido/bitsweeper | b89db2c2050cbc82ea60d31d2f31b041a1e913a3 | a37902c5b9ae9c25ee30694c2ba0974fd235090e | refs/heads/master | 2021-01-23T11:49:21.723909 | 2011-12-24T22:43:30 | 2011-12-24T22:43:30 | 34,614,275 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 2,741 | cpp | #include "GameLostVisibleWaitStateClass.h"
#include "CommonDataClass.h"
#include <nds/arm9/input.h>
#include "StateMachineClass.h"
#include "GameLostDisappearStateClass.h"
#include "GameLostVanishStateClass.h"
#include "BoardCellClass.h"
#include "OperationsClass.h"
GameLostVisibleWaitStateClass::GameLostVisibleWaitStateClass()
: StateClass()
{
}
void GameLostVisibleWaitStateClass::Start(CommonDataClass* CommonData)
{
Count = 0;
}
void GameLostVisibleWaitStateClass::Run(CommonDataClass* CommonData)
{
Count++;
if(Count >= 60)
{
CommonData->StateMachine->Switch(GAME_LOST_DISAPPEAR_STATE);
};
if((CommonData->TouchX >= 64) && (CommonData->TouchX < 192) && (CommonData->TouchY >= 64) && (CommonData->TouchY < 128))
{
CommonData->StateMachine->Switch(GAME_LOST_VANISH_STATE);
};
if(((CommonData->IsLeftHanded)&&(((CommonData->KeysHeld & KEY_LEFT) != 0)||((CommonData->KeysHeld & KEY_RIGHT) != 0)))||((!(CommonData->IsLeftHanded))&&(((CommonData->KeysHeld & KEY_A) != 0)||((CommonData->KeysHeld & KEY_Y) != 0))))
{
CommonData->StateMachine->Switch(GAME_LOST_VANISH_STATE);
};
if(((CommonData->IsLeftHanded)&&(((CommonData->KeysHeld & KEY_UP) != 0)||((CommonData->KeysHeld & KEY_DOWN) != 0)))||((!(CommonData->IsLeftHanded))&&(((CommonData->KeysHeld & KEY_B) != 0)||((CommonData->KeysHeld & KEY_X) != 0))))
{
CommonData->StateMachine->Switch(GAME_LOST_VANISH_STATE);
};
Operations::DoBoardScrolling(CommonData);
Operations::UpdateBoardCellBorders(CommonData);
}
void GameLostVisibleWaitStateClass::Draw(CommonDataClass* CommonData)
{
int Top;
int Bottom;
Operations::DrawSmallUpperLeftLogo(CommonData);
glBindTexture(0, CommonData->Textures[YOU_LOSE_IMG]);
glBegin(GL_QUADS);
glTexCoord2t16(inttot16(0), inttot16(0));
glVertex3f(-0.05 + CommonData->LocationX, 0.001, -0.075 + CommonData->LocationZ);
glTexCoord2t16(inttot16(0), inttot16(64));
glVertex3f(-0.05 + CommonData->LocationX, 0.001, -0.125 + CommonData->LocationZ);
glTexCoord2t16(inttot16(128), inttot16(64));
glVertex3f(0.05 + CommonData->LocationX, 0.001, -0.125 + CommonData->LocationZ);
glTexCoord2t16(inttot16(128), inttot16(0));
glVertex3f(0.05 + CommonData->LocationX, 0.001, -0.075 + CommonData->LocationZ);
glEnd();
if(CommonData->ToBottomScreen)
{
Top = CommonData->LowerTopCell;
Bottom = CommonData->LowerBottomCell;
} else
{
Top = CommonData->UpperTopCell;
Bottom = CommonData->UpperBottomCell;
};
glBindTexture(0, 0);
Operations::DrawEmptyCells(CommonData, Top, Bottom);
Operations::DrawNonEmptyCells(CommonData, Top, Bottom);
Operations::DrawCellBorders(CommonData, Top, Bottom);
Operations::DrawSmallUpperRightClock(CommonData);
}
| [
"[email protected]@66f87ebb-1a6f-337b-3a26-6cadc16acdcf"
] | [
[
[
1,
74
]
]
] |
3d3d8b575981496f5af5c08ca78d85f2f6a874f2 | 5538995540daab77560b7e0de84f001fd51c1618 | /SDHumming/SMelody.cpp | 61bbadd178581eecad84fdea934efb98ec7266eb | [] | no_license | cloudtrends/dsp-sdhumming | 9fb3001d927d0a791db78a0c2d448b1703817dbb | aa0dcb369528aabf95c623e8e0ab8cf3471907aa | refs/heads/master | 2021-01-01T18:54:41.697774 | 2011-12-05T01:52:44 | 2011-12-05T01:52:44 | 32,958,169 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 10,088 | cpp | /*
* SMelody.cpp SDHumming Melody Extraction routines
*
* Copyright (c) 2010 Shanda Interactive Entertainment Limited.
*
* 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
* any later version. See the COPYRIGHT.txt for more details.
*/
#include "SDSP.h"
#include "SMelody.h"
#include <math.h>
#include <stdio.h>
/* extract pitch contour of the input sound file */
int SPitchExtraction(SWaveDataStru mySWaveDataStru, float pendiente, float fmin, float fmax,
float fcutinf, float fcutsup, float*& fPitchData, int &nPitchLen){
int fs; /* sampling rate */
int nDataLen; /* total samples */
int nFrmShtLen; /* samples for frame shift */
int nFrmWinLen; /* samples for frame windows */
int nIndexMax, nIndexMin;
int nFrameSpan;
int nTotalFrms; /* total frames */
float* fCutFreq=new float[2];
fs = mySWaveDataStru.fs;
nDataLen = mySWaveDataStru.nDataLen;
nFrmWinLen = (int)floor(fs*FRAME_LEN_MS/1000.0f)-1;
nFrmShtLen = (int)floor(fs*FRAME_SHT_MS/1000.0f);
nIndexMax = (int)ceil(fs/fmin);
nIndexMin = (int)floor(fs/fmax);
nFrameSpan = nFrmWinLen + nIndexMax + 1;
nTotalFrms = (int)floor((float)((nDataLen-(nFrameSpan+nFrmShtLen))/nFrmShtLen))+1;
/* compute energy curve */
float *pEnergy=NULL;
int nFrmNum=0;
float fMean=SGetEnergyVec(mySWaveDataStru.fDataBuf, mySWaveDataStru.nDataLen,nFrmShtLen,pEnergy,nFrmNum);
/* butterworth filtering, order 4 */
double* acoef=NULL;
double* bcoef=NULL;
fCutFreq[0] = fcutinf/fs;
fCutFreq[1] = fcutsup/fs;
SProSignal(4, 2, fCutFreq,acoef,bcoef);
SFilter(mySWaveDataStru.fDataBuf, mySWaveDataStru.nDataLen,acoef,bcoef,9);
delete[] acoef;
delete[] bcoef;
int i = 0;
/* use the energy to detect the silence, the silence frame is not considered */
float fEnergyThres = 0.3f * fMean; /* energy threshold */
fPitchData=new float[nTotalFrms];
nPitchLen=nTotalFrms;
while (i < nTotalFrms){
if (pEnergy[i] > fEnergyThres){
float *fIndexData=new float[nIndexMax+1];
SCalcDifFunction(mySWaveDataStru.fDataBuf+nFrmShtLen*i,nFrmWinLen, nIndexMax, pendiente,fIndexData);
fPitchData[i]=SCalcPitchValue(fIndexData, nIndexMax, pendiente,nIndexMax, nIndexMin, fs);
delete[] fIndexData;
}
else{
fPitchData[i]=0.0f;
}
i++;
}
delete[] pEnergy;
return 0;
}
/* normalize the input data */
void NormalizeData(float *data, int nLen, float max){
float fMaxTemp=-1;
long ind;
int i=0;
for( i=0;i<nLen;i++){
if(fMaxTemp<fabsf(data[i])){
fMaxTemp=fabsf(data[i]);
ind=i;
}
}
for( i=0;i<nLen;i++){
data[i]*=max / fMaxTemp;
}
}
/* read wave data from file */
int WaveRead(char* filename, SWaveDataStru &mySWaveDataStru){
WAVE_HEADER szHeader;
int nRead=0;
int nLen=0;
short *pBuffer=NULL;
FILE *fp = fopen(filename, "rb");
if (!fp) {
return ERROR_CODE_FILE_CANNOT_OPEN;
}
fseek(fp, 0, SEEK_END);
nLen = (ftell(fp)-44)/2;
pBuffer = new short[nLen];
if (!pBuffer) {
return ERROR_CODE_CANNOT_ALLOC_MEM;
}
fseek(fp, 0, SEEK_SET);
nRead=fread(&szHeader, sizeof(WAVE_HEADER), 1, fp);
nRead=fread(pBuffer, sizeof(short), nLen, fp);
fclose(fp);
mySWaveDataStru.fs=szHeader.SamplePerSec;
mySWaveDataStru.nDataLen=nLen;
mySWaveDataStru.fDataBuf=new float[nLen];
if (!mySWaveDataStru.fDataBuf) {
return ERROR_CODE_CANNOT_ALLOC_MEM;
}
for(int i=0;i<nLen;i++){
mySWaveDataStru.fDataBuf[i]=pBuffer[i]/32768.0f;
}
NormalizeData(mySWaveDataStru.fDataBuf, mySWaveDataStru.nDataLen,0.9f);
delete[] pBuffer;
return 0;
}
/* extract pitch contour of the input sound file */
int SPitchContourExtraction(char* filename,float*& fPitchData,int &nFrm){
SWaveDataStru mySWaveDataStru;
if(WaveRead(filename,mySWaveDataStru)!=0){
printf("Error on WaveRead\n");
return -1;
}
mySWaveDataStru.fs=8000;
SPitchExtraction(mySWaveDataStru, 0.0015f, MIN_PITCH_VALUE, MAX_PITCH_VALUE, 50, 500,fPitchData,nFrm);
delete[] mySWaveDataStru.fDataBuf;
return 0;
}
/* compute the mean value of the input array, and the zero value is not used */
float GetMean(float *fArray, int nLen){
float RetVal=0.0f;
int nCountValid=0;
float fSum=0.0f;
for(int i=0;i<nLen;i++){
if(fArray[i]>0){
fSum+=fArray[i];
nCountValid++;
}
}
if(nCountValid>0)
RetVal=fSum/nCountValid;
else
RetVal=0;
return RetVal;
}
/* smooth and normalize the input pitch vector */
void SProcessQuery(float* fPitchArray,int& Len){
int i;
float MeanVal;
for (i=1;i<Len-1;i++){
if (fPitchArray[i-1]<2 && fPitchArray[i]>2 && fPitchArray[i+1]<2)
fPitchArray[i]=0;
}
int nCountFrm=0;
for (i=0;i<Len-5;i++){
if (i%5==0){
fPitchArray[i/5]=GetMean(fPitchArray+i,5);
nCountFrm++;
}
}
Len=nCountFrm;
float LastVal=0.0;
for (i=1;i<Len-1;i++){
if (fPitchArray[i-1]<2 && fabs(fPitchArray[i]-LastVal)>0.3*LastVal && fPitchArray[i+1]<2)
fPitchArray[i]=0;
if (fPitchArray[i]>2)
LastVal=fPitchArray[i];
}
/* remove the silence frame*/
float temppitch=0;
int vadCount=0;
int nStartTag=0;
int nStart=0;
for (i=0;i<Len;i++){
if(nStartTag==0){
if(fPitchArray[i]<2)
nStart=i;
else
nStartTag=1;
}
if (fPitchArray[i]>2){
fPitchArray[i]=(float)(log10(fPitchArray[i])/log10(2.0f));
if(i>3)
temppitch=GetMean(fPitchArray+i-3,3);
else
temppitch=fPitchArray[i];
vadCount=0;
}else{
vadCount++;
if (temppitch>0)
fPitchArray[i]=temppitch;
}
}
for(i=0;i<Len-nStart-1;i++){
fPitchArray[i]=fPitchArray[i+nStart+1];
}
Len-=(nStart+1);
MeanVal=0;
int VadSize=0;
for (i=0;i<Len;i++){
if (fPitchArray[i]>6.3){
MeanVal+=fPitchArray[i];
VadSize++;
}
}
float me=0.0f;
if(VadSize<1){
Len=0;
return ;
}
else
me=MeanVal/VadSize;
for (i=0; i<Len; i++){
fPitchArray[i]=fPitchArray[i]-me+PITCH_NORMALIZE_VALUE;
if (fPitchArray[i]>8)
fPitchArray[i]=fPitchArray[i]-1;
if (fPitchArray[i]<6.35)
fPitchArray[i]=fPitchArray[i]+1;
}
}
/* note transcription, the inpyt is pitch vector, and the note sequence is generated */
int STranscribeQueryNote(float* fPitchArray,int& Len,SNote *&Query, int &nNoteLen){
int i;
int startindex=0;
for (i=1;i<Len-1;i++){
/* remove the pitch jitter and the transition pitch value */
if (((fPitchArray[i]-fPitchArray[i-1])>0.01 && (fPitchArray[i+1]-fPitchArray[i])>0.01)
|| ((fPitchArray[i]-fPitchArray[i-1])<-0.01 && (fPitchArray[i+1]-fPitchArray[i])<-0.01)){
float DistPre=(float)fabs(fPitchArray[i]-fPitchArray[i-1]);
float DistAfter=(float)fabs(fPitchArray[i]-fPitchArray[i+1]);
if (DistPre<DistAfter)
fPitchArray[i]=fPitchArray[i-1];
else
fPitchArray[i]=fPitchArray[i+1];
}
}
/* combine the note by significant pitch change */
for (i=0;i<Len;i++){
if (fabs(fPitchArray[i+1]-fPitchArray[i])>0.05 || i==Len-1) {
int nth=i+1-startindex;
float *fTempMedian=new float[nth];
memcpy(fTempMedian,fPitchArray+startindex,sizeof(float)*nth);
if(nth>2){
qsort(fTempMedian,nth, sizeof(float),_compareFloat);
for(int j=0;j<nth;j++){
fPitchArray[startindex+j]=fTempMedian[(nth+1)/2];
}
}
startindex=i+1;
delete[] fTempMedian;
}
}
SNoteSequenceStru *retVal=new SNoteSequenceStru;
retVal->Next=NULL;
SNoteSequenceStru *CurrentNote=retVal;
SNote Note;
float OldPitch;
Note.fNoteValue=fPitchArray[0];
OldPitch=Note.fNoteValue;
Note.fNoteDuration=1;
/* post processing the note sequence */
for (i=1;i<Len;i++){
if (!FLOAT_EQUAL(fPitchArray[i],OldPitch)){
if (Note.fNoteDuration<=2){
float PrePitch;
if (NULL==retVal->Next)
PrePitch=(float)MAX_NUMBER;
else{
SNoteSequenceStru *tmp=retVal;
while(NULL!=tmp->Next){
tmp=tmp->Next;
}
PrePitch=tmp->fNote.fNoteValue;
}
float OldPitch=fPitchArray[i];
/* combine with the following note */
if (fabs(Note.fNoteValue-PrePitch)<fabs(Note.fNoteValue-OldPitch)){
SNoteSequenceStru *tmp=retVal;
while(NULL!=tmp->Next){
tmp=tmp->Next;
}
tmp->fNote.fNoteDuration+=Note.fNoteDuration;
float TempVal=tmp->fNote.fNoteValue;
for(int j=i-(int)Note.fNoteDuration;j<i;j++){
fPitchArray[j]=TempVal;
}
Note.fNoteValue=fPitchArray[i];
Note.fNoteDuration=1;
}else{/* combine with the previous note */
Note.fNoteValue=fPitchArray[i];
for(int j=i-(int)Note.fNoteDuration;j<i;j++){
fPitchArray[j]=Note.fNoteValue;
}
Note.fNoteDuration+=1;
}
}else{
/* new note begin */
SNoteSequenceStru *tmpNotes=new SNoteSequenceStru;
tmpNotes->fNote=Note;
tmpNotes->Next=NULL;
CurrentNote->Next=tmpNotes;
CurrentNote=CurrentNote->Next;
Note.fNoteValue=fPitchArray[i];
Note.fNoteDuration=1;
nNoteLen++;
}
OldPitch=fPitchArray[i];
}else
Note.fNoteDuration+=1;
}
SNoteSequenceStru *tmpNotes=new SNoteSequenceStru;
tmpNotes->fNote=Note;
tmpNotes->Next=NULL;
CurrentNote->Next=tmpNotes;
nNoteLen++;
Query=new SNote[nNoteLen];
nNoteLen=0;
/* convert the note sequence into MIDI format */
CurrentNote=retVal->Next;
if (Note.fNoteValue>0 && Note.fNoteValue<10){
while(NULL!=CurrentNote){
CurrentNote->fNote.fNoteValue=(float)(12.0f*(CurrentNote->fNote.fNoteValue-log(440.0f)/log(2.0f))+69.0f);
Query[nNoteLen].fNoteValue=CurrentNote->fNote.fNoteValue;
Query[nNoteLen].fNoteDuration=CurrentNote->fNote.fNoteDuration;
CurrentNote=CurrentNote->Next;
nNoteLen++;
}
}
return 0;
} | [
"[email protected]@ab1771c7-a60c-faa4-7819-1464de3013ac"
] | [
[
[
1,
368
]
]
] |
9c3889bd7045cf68d15ef20ead9093e3f0f83651 | 17083b919f058848c3eb038eae37effd1a5b0759 | /SimpleGL/src/GL/GLShader.cpp | d8e9bdbff5c9342ce5122d175e4b219bbfc17063 | [] | no_license | BackupTheBerlios/sgl | e1ce68dfc2daa011bdcf018ddce744698cc7bc5f | 2ab6e770dfaf5268c1afa41a77c04ad7774a70ed | refs/heads/master | 2021-01-21T12:39:59.048415 | 2011-10-28T16:14:29 | 2011-10-28T16:14:29 | 39,894,148 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,488 | cpp | #include "GL/GLCommon.h"
#include "GL/GLDevice.h"
#include "GL/GLShader.h"
#include <cstring>
namespace {
using namespace sgl;
/// bind shader type to sgl value
GLenum SHADER_TYPE_BINDINGS[] =
{
GL_VERTEX_SHADER,
GL_FRAGMENT_SHADER
#ifndef SIMPLE_GL_ES
, GL_GEOMETRY_SHADER
#endif
};
} // anonymous namespace
namespace sgl {
GLShader::GLShader( GLDevice* device_,
const DESC& desc ) :
device(device_),
type(desc.type)
{
// create shader
shader = glCreateShader( SHADER_TYPE_BINDINGS[desc.type] );
// set data
GLsizei size = strlen(desc.source);
glShaderSource(shader, 1, (const char**)&desc.source, &size);
// compile
GLint compileStatus;
glCompileShader(shader);
glGetShaderiv(shader, GL_COMPILE_STATUS, &compileStatus);
// error
if (compileStatus != GL_TRUE)
{
GLsizei errLength;
std::string log;
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &errLength);
log.resize(errLength);
glGetShaderInfoLog(shader, errLength, &errLength, &log[0]);
glDeleteShader(shader);
sglSetError( SGLERR_INVALID_CALL, ("Shader compilation log: " + log).c_str() );
throw gl_error("Shader compilation error", SGLERR_INVALID_CALL);
}
}
GLShader::~GLShader()
{
if ( device->Valid() ) {
glDeleteShader(shader);
}
}
} // namespace sgl
| [
"devnull@localhost"
] | [
[
[
1,
64
]
]
] |
c99810083f2c9883c2d6212c03ad26e7b7b04a54 | 7b4c786d4258ce4421b1e7bcca9011d4eeb50083 | /_统计专用/C++Primer中文版(第4版)/第一次-代码集合-20090414/第五章 表达式/20090120_习题5.18_输出每个string的内容及其相应的长度.cpp | 410434902a5056ffc01ffbc0b170183ca712f90b | [] | 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 | 563 | cpp | #include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
vector<string*> spvec;
//get vector
string str;
cout << "Enter some strings(Ctrl+Z to end)" << endl;
while(cin >> str){
string *pstr = new string;
*pstr = str;
spvec.push_back(pstr);
}
//
vector<string*>::iterator iter = spvec.begin();
while(iter != spvec.end()){
cout << **iter << (**iter).size() << endl;
iter++;
}
//
iter = spvec.begin();
while(iter != spvec.end()){
delete *iter;
iter++;
}
return 0;
} | [
"baicaibang@70501136-4834-11de-8855-c187e5f49513"
] | [
[
[
1,
34
]
]
] |
ad9aa41811c6af80bf364472d024ad4c689891e8 | ff24756dc4add027f5953a4954a4855d824a5a63 | /TabItemTools.h | 54ef2a1c6fe89fcf51bfedf8c4c5bc15976b596f | [] | no_license | weekydy/molt-asb-bigz-sont-dans-un-bateau | 640b4170b0ed9e07ca08641add9f57198bc2e8a6 | 2f116842bf604125ecbdd10226f79d0b085d0b4f | refs/heads/master | 2021-01-09T21:54:53.848431 | 2010-06-17T07:24:26 | 2010-06-17T07:24:26 | 55,782,366 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 497 | h | #ifndef TABITEMTOOLS_H
#define TABITEMTOOLS_H
#include <QtCore>
#include <QtGui>
#include <QtSql>
#include "Commons.h"
#include "TabItemTools.h"
class TabItemTools : public QWidget
{
Q_OBJECT
public:
TabItemTools(QWidget *parent = 0);
private:
QTextEdit *te_request;
QPushButton *btn_execute;
QSqlQueryModel *model;
QTableView *view;
QSortFilterProxyModel *proxyModel;
private slots:
void refreshList();
};
#endif // TABITEMUSER_H
| [
"adrien.gavignet@df1d4e54-f2be-1ee4-b4f2-52395a1b115b"
] | [
[
[
1,
30
]
]
] |
26cc4ce1944b3f0e85b4df3c74727bbe353ac8b5 | 1c9f99b2b2e3835038aba7ec0abc3a228e24a558 | /Projects/elastix/elastix_sources_v4/src/Components/FixedImagePyramids/FixedSmoothingPyramid/elxFixedSmoothingPyramid.hxx | dc13c1b58b999b5b9bd9a1a82b25fb5bf3bac5c6 | [] | 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 | 830 | hxx | /*======================================================================
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 __elxFixedSmoothingPyramid_hxx
#define __elxFixedSmoothingPyramid_hxx
#include "elxFixedSmoothingPyramid.h"
namespace elastix
{
using namespace itk;
} // end namespace elastix
#endif //#ifndef __elxFixedSmoothingPyramid_hxx
| [
"[email protected]"
] | [
[
[
1,
28
]
]
] |
b1a0ffd4a7a181f2db4355aae986a38681b94ade | ce1b0d027c41f70bc4cfa13cb05f09bd4edaf6a2 | / edge2d --username [email protected]/include/EdgeArchiveManager.h | d5ae0a2410b7c9b211873d7697cf2c4fa1e05689 | [] | no_license | ratalaika/edge2d | 11189c41b166960d5d7d5dbcf9bfaf833a41c079 | 79470a0fa6e8f5ea255df1696da655145bbf83ff | refs/heads/master | 2021-01-10T04:59:22.495428 | 2010-02-19T13:45:03 | 2010-02-19T13:45:03 | 36,088,756 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,421 | h | /*
-----------------------------------------------------------------------------
This source file is part of EDGE
(A very object-oriented and plugin-based 2d game engine)
For the latest info, see http://edge2d.googlecode.com
Copyright (c) 2007-2008 The EDGE Team
Also see acknowledgements in Readme.html
This program 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 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser 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, or go to
http://www.gnu.org/copyleft/lesser.txt.
-----------------------------------------------------------------------------
*/
#ifndef EDGE_ARCHIVEMANAGER_H
#define EDGE_ARCHIVEMANAGER_H
#include "EdgeCompile.h"
#include <string>
#include <map>
#include "EdgeDataStream.h"
#include "EdgeSingleton.h"
#include "EdgeArchive.h"
using std::map;
using std::string;
namespace Edge
{
/**
* ArchiveManager manages load/unload Archives using ArchiveFactory, you can
* regisgter your own ArchiveFactory and so you can create your own Archive.
* And this object will also store all archives it creates.
*
* @remarks this is the only class you should pay attention to in IO module.
* Usually you can use an ArchiveManager to create an Archive, and later use
* the Archive to create a DataStream, a DataStream usually implements a file.
* @par you donot need to create an ArchiveManager yourself. And ArchiveManager
* is a basic module and it's created by EdgeEngine.Anytime you can access the manager
* by EdgeEngine::getSingleton().getArchiveManager, all ArchiveManager::getSingleton
*/
class EDGE_EXPORT ArchiveManager : public Singleton<ArchiveManager>
{
public:
/**
* Constructor
*
*/
ArchiveManager();
/**
* Destructor
*
*/
~ArchiveManager();
/**
* addArchiveFactory, you create an ArchiveFactory and register it in the manager
*
* @remarks When you create your own Archive plugin, you can register it using this
* function.
*/
void addArchiveFactory( ArchiveFactory *archiveFactory );
/**
* removeArchiveFactory
*
* this function just remove the archive factory from the list, and will not
* delete the archive factory.
*/
void removeArchiveFactory( ArchiveFactory *archiveFactory );
/**
* createArchive, it will create an archive using the exist ArchiveFactory
* so , you can NOT delete an archive yourself, instead you must call
* destroyArchive to delete an archive.
* Also when the ArchiveManager is deleted, it will automatically delete
* all the archives it stores.
*
* @remarks If the archive has already been created, this function will return the precreated archive.
* You can specify some other data to create the archive by pInData.
*/
Archive *createArchive( const string &name, const string &type, void *pInData = 0 );
/**
* destroyArchive
*
*/
void destroyArchive( Archive *archive );
void destroyArchive( const string &name );
/**
* destroyAllArchives, it will called by the destructor
*
*/
void destroyAllArchives();
/**
* getArchive
*
* @warning if the archive is not exist, this function will throw an exception.
*/
Archive *getArchive( const string &name );
private:
/**
* selfGetArchive, this class will use it to check whether the archive is already exist.
*
*/
Archive *_selfGetArchive( const string &name );
/**
* modify the name to the correct format
*
*/
void _modifyName( string &name );
private:
typedef map<string, ArchiveFactory*> ArchiveFactoryMap;
typedef map<string, Archive*> ArchiveMap;
private:
/// archive factory list
ArchiveFactoryMap mArchiveFactories;
/// created archive list
ArchiveMap mArchives;
};
}
#endif
| [
"[email protected]@539dfdeb-0f3d-0410-9ace-d34ff1985647"
] | [
[
[
1,
141
]
]
] |
60f2b65d7c9f45f869c5e5494d69c4a633c481a1 | 478570cde911b8e8e39046de62d3b5966b850384 | /apicompatanamdw/bcdrivers/mw/classicui/uifw/apps/S60_SDK3.1/bctestlocation/inc/bctestlocationcontainer.h | 7917bd98ae4aecd8e521261e711e85ef25587c5e | [] | no_license | SymbianSource/oss.FCL.sftools.ana.compatanamdw | a6a8abf9ef7ad71021d43b7f2b2076b504d4445e | 1169475bbf82ebb763de36686d144336fcf9d93b | refs/heads/master | 2020-12-24T12:29:44.646072 | 2010-11-11T14:03:20 | 2010-11-11T14:03:20 | 72,994,432 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,010 | h | /*
* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: container
*
*/
#ifndef BCTEST_LOCATIONCONTAINER_H
#define BCTEST_LOCATIONCONTAINER_H
#include <coecntrl.h>
/**
* container class
*/
class CBCTestLocationContainer: public CCoeControl
{
public: // constructor and destructor
/**
* C++ default constructor
*/
CBCTestLocationContainer();
/**
* Destructor
*/
virtual ~CBCTestLocationContainer();
/**
* Symbian 2nd constructor
*/
void ConstructL( const TRect& aRect );
public: // new functions
/**
* Set component control, and container will own the control
* @param aControl pointer to a control.
*/
void SetControl( CCoeControl* aControl );
/**
* Delete control
*/
void ResetControl();
public: // from CCoeControl
/**
* Return count of component controls
*/
TInt CountComponentControls() const;
/**
* Return pointer to component control specified by index
* @param aIndex, a index to specify a component control
*/
CCoeControl* ComponentControl( TInt aIndex ) const;
private: // from CCoeControl
/**
* From CCoeControl, Draw.
* Fills the window's rectangle.
* @param aRect Region of the control to be (re)drawn.
*/
void Draw( const TRect& aRect ) const;
private: // data
/**
* Pointer to component control.
* own
*/
CCoeControl* iControl;
};
#endif // BCTEST_LOCATIONCONTAINER_H | [
"none@none"
] | [
[
[
1,
90
]
]
] |
5bf243446f0c1f5b5d6a95911c6991679a40eb24 | be2e23022d2eadb59a3ac3932180a1d9c9dee9c2 | /AiModule/source/FactSet.cpp | fc809ffa1ed44130f4def088efe1bd133f7ac73d | [] | no_license | cronoszeu/revresyksgpr | 78fa60d375718ef789042c452cca1c77c8fa098e | 5a8f637e78f7d9e3e52acdd7abee63404de27e78 | refs/heads/master | 2020-04-16T17:33:10.793895 | 2010-06-16T12:52:45 | 2010-06-16T12:52:45 | 35,539,807 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 8,112 | cpp | #include "windows.h"
#include "Fact.h"
#include "SymbolTable.h"
#include "FactSet.h"
#include "i_mydb.h"
#include "Syntax.h"
#include "ruleset.h"
#include "AiCenter.h"
MYHEAP_IMPLEMENTATION(CFactObj,s_heap)
bool CFactObj::Create(CSymbolTable* pSymbolTable, OBJID id, OBJID idRecord, StringRef strFact, int nPriority, DWORD dwDateTime, int nDurable)
{
m_id = id;
m_idRecord = idRecord;
m_bDirty = false;
if(!::AnalyzeFact(pSymbolTable, strFact, &m_cFact))
return false;
m_nPriority = nPriority;
m_tDurable.Startup(dwDateTime, nDurable);
return true;
}
bool CFactObj::Create(CSymbolTable* pSymbolTable, OBJID id, StringRef strFact, int nPriority, int nNow, int nDurable, CFact* pModelFact) // return pModelFact
{
m_id = id;
m_idRecord = ID_NONE;
m_bDirty = true;
if(!::AnalyzeFact(pSymbolTable, strFact, &m_cFact, pModelFact)) // return pModelFact
return false;
m_nPriority = nPriority;
m_tDurable.Startup(nNow, nDurable);
VarTypeSet::ConstIterator pParam = GetParamSet().NewEnum();
while(pParam.Next())
{
IF_NOT(pParam->IsIntType() || pParam->IsStringType())
return false;
}
return true;
}
bool CFactObj::Create(CSymbolTable* pSymbolTable, OBJID id, CFactRef cFact, int nPriority, int nNow, int nDurable)
{
m_id = id;
m_idRecord = ID_NONE;
m_bDirty = true;
m_cFact = cFact;
m_nPriority = nPriority;
m_tDurable.Startup(nNow, nDurable);
if(!cFact.IsLogicNot())
{
VarTypeSet::ConstIterator pParam = GetParamSet().NewEnum();
while(pParam.Next())
{
IF_NOT(pParam->IsIntType() || pParam->IsStringType())
return false;
}
}
return true;
}
bool CFactObj::IsValid()
{
VarTypeSet::ConstIterator pParam = GetParamSet().NewEnum();
while(pParam.Next())
{
IF_NOT(pParam->IsIntType() || pParam->IsStringType())
return false;
}
return true;
}
bool CFactObj::IsLikeModel(CFactRef cPattern)
{
if(cPattern.GetType() != this->GetType())
return false;
if(cPattern.GetParamSet().Size() != this->GetParamSet().Size())
return false;
for(int i = 0; i < this->GetParamSet().Size(); i++)
{
VarTypeRef obj = cPattern.GetParamSet().At(i);
if(obj.IsValid())
{
if(obj != this->GetParamSet().At(i))
return false;
}
}
return true;
}
void CFactObj::GetFactString(String& strFact, CSymbolTable* pSymbolTable)
{
// logic not
if(IsLogicNot())
strFact.QueryString() += LOGIC_NOT_CHAR;
// type
LPCTSTR ptr = pSymbolTable->FindSymbolByID(GetType());
IF_OK(ptr)
strFact.QueryString() += ptr;
// <
strFact.QueryString() += KEY_PARAM_CHAR;
// param set
bool bSeparator = false;
VarTypeSet::ConstIterator pParam = GetParamSet().NewEnum();
while(pParam.Next())
{
// ,
if(bSeparator)
strFact.QueryString() += SEPARATOR_CHAR;
bSeparator = true;
IF_OK(pParam->IsValid())
{
if(!pParam->IsValid())
strFact += "(null)";
else if(pParam->IsIntType())
strFact += String().FormatLong(static_cast<int>(*pParam));
else
strFact += static_cast<String>(*pParam);
}
}
// >
strFact.QueryString() += KEY_PARAM_CHAR2;
}
bool CFactSet::AddFactQueue(CFactRef cFact, int nPriority, int nNow, int nDurable)
{
if(!cFact.IsLogicNot())
{
CFactObj* pFact = CFactObj::CreateNew();
IF_OK(pFact)
{
IF_OK(pFact->Create(QuerySymbolTable(), SpawnFactID(), cFact, nPriority, nNow, nDurable))
{
CHECKF(pFact->GetID() >= FACT_ID_FIRST);
m_setFact->AddObj(pFact);
LOGDUMP("add fact: %s", (LPCTSTR)::DumpString(*pFact));
return true;
}
else
pFact->Release();
}
}
else
{
ClearAlikeFact(cFact);
return true;
}
return false;
}
void CFactSet::CombineQueue()
{
}
CFactSet::CFactSet()
{
m_setFact = FACT_SET::CreateNew(true);
m_idLast = FACT_ID_FIRST;
}
CFactSet::~CFactSet()
{
}
bool CFactSet::Create(CAiCenter* pOwner, IDatabase* pDb, int nNow)
{
m_pOwner = pOwner;
char buf[256];
sprintf(buf, "SELECT * FROM %s WHERE owner_id=%u", _TBL_FACT, pOwner->QueryAgent()->GetID());
IRecordset* pRes = pDb->CreateNewRecordset(buf, false);
for(int i = 0; i < pRes->RecordCount(); i++,pRes->MoveNext())
{
if(nNow < pRes->GetInt(FACTDATA_DATETIME) + pRes->GetInt(FACTDATA_DURABLE))
{
AddFact(pRes->GetInt(FACTDATA_ID_),
pRes->GetStr(FACTDATA_FACT),
pRes->GetInt(FACTDATA_PRIORITY),
pRes->GetInt(FACTDATA_DATETIME),
pRes->GetInt(FACTDATA_DURABLE) );
LOGDUMP("Load All Facts: %s", pRes->GetStr(FACTDATA_FACT));
}
}
pRes->Release();
return true;
}
bool CFactSet::Persistent(IDatabase *pDb, int nNow)
{
char szSQL[1024];
sprintf(szSQL, "SELECT * FROM %s WHERE id=0 LIMIT 1", _TBL_FACT);
IRecordset* pRes = pDb->CreateNewRecordset(szSQL, false);
FACT_SET::Iterator pFact = m_setFact->NewEnum();
while(pFact.Next())
{
if(pFact && pFact->IsDirty() && pFact->IsAlive(nNow))
{
String strFact;
pFact->GetFactString(strFact, QuerySymbolTable());
pRes->SetStr(FACTDATA_FACT, strFact, MAX_FIELDSIZE);
pRes->SetInt(FACTDATA_PRIORITY, pFact->GetPriority());
pRes->SetInt(FACTDATA_DATETIME, pFact->GetDateTime());
if(pFact->GetRecordID() != ID_NONE)
{
pRes->SetInt(FACTDATA_ID_, pFact->GetRecordID());
pRes->UpdateRecord();
}
else
{
OBJID id = pRes->InsertRecord();
pFact->SetRecordID(id);
}
}
}
pRes->Release();
return true;
}
bool CFactSet::AddFact(OBJID idRecord, StringRef strFact, int nPriority, DWORD dwDateTime, int nDurable)
{
CFactObj* pFact = CFactObj::CreateNew();
IF_OK(pFact)
{
IF_OK(pFact->Create(QuerySymbolTable(), SpawnFactID(), idRecord, strFact, nPriority, dwDateTime, nDurable))
{
CHECKF(!pFact->IsLogicNot());
m_setFact->AddObj(pFact);
#ifdef DUMP_DEBUG_MSG
String str;
pFact->GetFactString(str, QuerySymbolTable());
LOGDUMP("Add Fact: %s,%s,%s,%s", (LPCTSTR)str, (LPCTSTR)::DumpString(nPriority), (LPCTSTR)::DumpString(dwDateTime), (LPCTSTR)::DumpString(nDurable));
#endif
return true;
}
else
{
pFact->ReleaseByOwner();
}
}
return false;
}
bool CFactSet::AddFact(StringRef strFact, int nPriority, int nNow, int nDurable)
{
CFactObj* pFact = CFactObj::CreateNew();
IF_OK(pFact)
{
CFact cModelFact;
IF_OK(pFact->Create(QuerySymbolTable(), SpawnFactID(), strFact, nPriority, nNow, nDurable, &cModelFact)) // return faceModel
{
LOGDUMP("add fact: %s - %s", (const char*)strFact, (LPCTSTR)::DumpString(cModelFact));
ClearAlikeFact(cModelFact);
if(!pFact->IsLogicNot())
{
m_setFact->AddObj(pFact);
#ifdef DUMP_DEBUG_MSG
String str;
pFact->GetFactString(str, QuerySymbolTable());
// LOGDUMP("Add Fact: %s,%s,%s,%s:", (LPCTSTR)str, (LPCTSTR)::DumpString(nPriority), (LPCTSTR)::DumpString(nNow), (LPCTSTR)::DumpString(nDurable));
#endif
}
return true;
}
else
{
pFact->ReleaseByOwner();
}
}
return false;
}
/*
bool CFactSet::AddFact(CFactRef cFact, int nPriority, int nNow, int nDurable)
{
CFactObj* pFact = CFactObj::CreateNew();
IF_OK(pFact)
{
CFact cModelFact;
IF_OK(pFact->Create(QuerySymbolTable(), SpawnFactID(), cFact, nPriority, nNow, nDurable))
{
if(!pFact->IsLogicNot())
{
m_setFact->AddObj(pFact);
#ifdef DUMP_DEBUG_MSG
String str;
pFact->GetFactString(str, QuerySymbolTable());
LOGDUMP("Add Fact: %s,%s,%s,%s+", (LPCTSTR)str, (LPCTSTR)::DumpString(nPriority), (LPCTSTR)::DumpString(nNow), (LPCTSTR)::DumpString(nDurable));
#endif
}
return true;
}
else
{
pFact->ReleaseByOwner();
}
}
return false;
}
*/
void CFactSet::ClearAlikeFact(CFactRef cModelFact)
{
FACT_SET::Iterator pFact = m_setFact->NewEnum();
while(pFact.Next())
{
if(pFact->IsLikeModel(cModelFact))
{
LOGDUMP("Del alike fact: %s", (const char*)pFact->Dump());
m_setFact->DelObj(pFact);
}
}
}
CSymbolTable* CFactSet::QuerySymbolTable() { return m_pOwner->QuerySymbolTable(); }
| [
"rpgsky.com@cc92e6ba-efcf-11de-bf31-4dec8810c1c1"
] | [
[
[
1,
332
]
]
] |
78701f3e40e6d224aa13475cac7cdb7bec7ea1a6 | 835dedf0be327cf97588b5aca88dd0294719d7a5 | /vragen_lijst/vragen_lijstMain.cpp | 32410ac70117b1ac6a07560d75de27208201c7d0 | [] | no_license | SonyAndLG/eerste-ding | fdd3728133905c4ae6d069824ca00e934ab75ed7 | d717d1ccffffe72ac1db86c6796a48738544fe26 | refs/heads/master | 2016-09-05T10:31:24.704770 | 2011-10-29T12:37:53 | 2011-10-29T12:37:53 | 2,670,623 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,551 | cpp | /***************************************************************
* Name: vragen_lijstMain.cpp
* Purpose: Code for Application Frame
* Author: Tom ploeg ([email protected])
* Created: 2011-10-29
* Copyright: Tom ploeg (www.stichting-scn.nl)
* License:
**************************************************************/
#ifdef WX_PRECOMP
#include "wx_pch.h"
#endif
#ifdef __BORLANDC__
#pragma hdrstop
#endif //__BORLANDC__
#include "vragen_lijstMain.h"
#include <wx/wx.h>
//helper functions
enum wxbuildinfoformat {
short_f, long_f };
wxString wxbuildinfo(wxbuildinfoformat format)
{
wxString wxbuild(wxVERSION_STRING);
if (format == long_f )
{
#if defined(__WXMSW__)
wxbuild << _T("-Windows");
#elif defined(__WXMAC__)
wxbuild << _T("-Mac");
#elif defined(__UNIX__)
wxbuild << _T("-Linux");
#endif
#if wxUSE_UNICODE
wxbuild << _T("-Unicode build");
#else
wxbuild << _T("-ANSI build");
#endif // wxUSE_UNICODE
}
return wxbuild;
}
vragen_lijstFrame::vragen_lijstFrame(wxFrame *frame)
: GUIFrame(frame)
{
#if wxUSE_STATUSBAR
statusBar->SetStatusText(_("Hello Code::Blocks user!"), 0);
statusBar->SetStatusText(wxbuildinfo(short_f), 1);
#endif
}
vragen_lijstFrame::~vragen_lijstFrame()
{
}
wxString vragen[6]=
{
"Dit is de eerste vraag: \nWie is de koningin van Nederland?",
"Dit is de tweede vraag: \nWaar ligt Nederland?",
"Dit is de derde vraag: \nHoeveel voedsel produceert de wereld (per dag)?",
"Dit is de vierde vraag: \nHoeveel mensen wonen er op de wereld?",
"Dit is de laaste vraag: \nWat is de staats schuld van Amirika?",
"lol"
};
wxString antwordenL[6]=
{
"Beatrix",
"In Azie",
"Genoeg om wel 9 miljard mensen te voeden",
"7 miljard mensen",
"9 miljoen euro",
"ol"
};
wxString antwordenR[6]=
{
"Maxima",
"In Europa",
"Genoeg om wel 11 miljard mensen te voeden",
"8 miljard mensen",
"9 miljard euro",
"lo"
};
int teller=0;
void vragen_lijstFrame::OnClose(wxCloseEvent &event)
{
Destroy();
}
void vragen_lijstFrame::OnQuit(wxCommandEvent &event)
{
Destroy();
}
void vragen_lijstFrame::OnAbout(wxCommandEvent &event)
{
wxString msg = wxbuildinfo(long_f);
wxMessageBox(msg, _("Welcome to..."));
}
void vragen_lijstFrame::Onvraag_1Click( wxCommandEvent& event)
{
vraag1->SetValue(vragen[teller]);
Antwoord2->SetLabel(antwordenL[teller]);
Antwoord3->SetLabel(antwordenR[teller]);
}
void vragen_lijstFrame::OnAntwoord2Click( wxCommandEvent& event )
{
if (teller==3||teller==0)
{
wxMessageBox("je had het goed!!!!!!","goed");
teller=teller+1;
}
else
{
wxMessageBox("je had het fout!!!!!!","fout");
teller=0;
}
if (teller==5)
{
Destroy();
}
vraag1->SetValue(vragen[teller]);
Antwoord2->SetLabel(antwordenL[teller]);
Antwoord3->SetLabel(antwordenR[teller]);
}
void vragen_lijstFrame::OnAntwoord3Click( wxCommandEvent& event )
{
if (teller==3||teller==0)
{
wxMessageBox("je had het fout!!!!!!","fout");
teller=0;
}
else
{
wxMessageBox("je had het goed!!!!!!","goed");
teller=teller+1;
}
if (teller==5)
{
Destroy();
}
vraag1->SetValue(vragen[teller]);
Antwoord2->SetLabel(antwordenL[teller]);
Antwoord3->SetLabel(antwordenR[teller]);
}
| [
"[email protected]"
] | [
[
[
1,
210
]
]
] |
982a8ae48c10e42e7db7005e9066be25f32dba7a | 6bdb3508ed5a220c0d11193df174d8c215eb1fce | /Codes/Halak/ParticleEmitter.cpp | 37b0b90ccdfa1c88e1ada200e53f458419b4d52c | [] | 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 | 2,450 | cpp | #include <Halak/PCH.h>
#include <Halak/ParticleEmitter.h>
#include <Halak/CloningContext.h>
#include <Halak/IFloatEvaluable.h>
#include <Halak/ISpatial.h>
#include <Halak/ParticleSpawnPoints.h>
namespace Halak
{
ParticleEmitter::ParticleEmitter()
: origin(nullptr),
spawnPeriod(nullptr),
spawnPoint(nullptr),
spawnTime(0.0f)
{
}
///^ParticleEmitter::ParticleEmitter(const ParticleEmitter& original, CloningContext& context)
///^ : origin(context.Clone(original.origin)),
///^ spawnPeriod(context.Clone(original.spawnPeriod)),
///^ spawnPoint(original.spawnPoint ? original.spawnPoint->Clone() : nullptr),
///^ spawnTime(original.spawnTime)
///^{
///^}
ParticleEmitter::~ParticleEmitter()
{
delete spawnPoint;
}
void ParticleEmitter::Update(float dt, uint timestamp)
{
if (spawnPeriod == nullptr || origin == nullptr)
return;
if (updateableSpawnPeriod)
updateableSpawnPeriod->Update(dt, timestamp);
const Vector3 position = origin->GetPosition();
const Quaternion rotation = origin->GetRotation();
const float scale = origin->GetScale();
const float spawnPeriodValue = spawnPeriod->Evaluate();
spawnTime += dt;
while (spawnTime > spawnPeriodValue)
{
spawnTime -= spawnPeriodValue;
Spawn(spawnTime, spawnPoint ? spawnPoint->Spawn(position, rotation, scale) : position);
}
}
ISpatial* ParticleEmitter::GetOrigin() const
{
return origin;
}
void ParticleEmitter::SetOrigin(ISpatialPtr value)
{
origin = value;
}
IFloatEvaluable* ParticleEmitter::GetSpawnPeriod() const
{
return spawnPeriod;
}
void ParticleEmitter::SetSpawnPeriod(IFloatEvaluablePtr value)
{
if (spawnPeriod != value)
{
spawnPeriod = value;
updateableSpawnPeriod = DynamicCast<IUpdateable>(value);
}
}
ParticleSpawnPoint* ParticleEmitter::GetSpawnPonit() const
{
return spawnPoint;
}
void ParticleEmitter::SetSpawnPoint(ParticleSpawnPoint* value)
{
ParticleSpawnPoint* deletingSpawnPoint = spawnPoint;
spawnPoint = value;
delete deletingSpawnPoint;
}
} | [
"[email protected]"
] | [
[
[
1,
86
]
]
] |
9dce970587c7bccdad4100aa85325f951e8dedc5 | 5ed707de9f3de6044543886ea91bde39879bfae6 | /ASMember/Shared/Source/ASMemberDB.cpp | b26369b86fc4d76f75f5ab2ae1fbb59d742f6921 | [] | no_license | grtvd/asifantasysports | 9e472632bedeec0f2d734aa798b7ff00148e7f19 | 76df32c77c76a76078152c77e582faa097f127a8 | refs/heads/master | 2020-03-19T02:25:23.901618 | 1999-12-31T16:00:00 | 2018-05-31T19:48:19 | 135,627,290 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,111 | cpp | /* ASMemberDB.cpp */
/******************************************************************************/
/******************************************************************************/
#include "CBldVCL.h"
#pragma hdrstop
#include "CommDB.h"
#include "ASMemberDB.h"
namespace asmember
{
/******************************************************************************/
static void LoadParticVectorByWhereStr(const char* whereStr,
TParticVector& particVector);
/******************************************************************************/
/******************************************************************************/
double GamePrice(const TMemberID memberID,bool isPremium)
{
TParticVector particVector;
if(!memberID.isUndefined())
{
if(ParticGamePriceAllowedForMembers())
{
if(isPremium)
return(GamePriceParticPremium());
return(GamePriceParticStandard());
}
LoadParticVectorByMemberIDGameID(memberID,CurrentGameID(),particVector);
if(particVector.size() > 0)
{
if(isPremium)
return(GamePriceParticPremium());
return(GamePriceParticStandard());
}
}
if(isPremium)
return(GamePriceMemberPremium());
return(GamePriceMemberStandard());
}
/******************************************************************************/
double UpgradePrice(const TParticPtr particPtr)
{
TParticVector particVector;
double gamePrice = GamePriceMemberPremium();
LoadParticVectorByMemberIDGameID(particPtr->getMemberID(),CurrentGameID(),
particVector);
particVector.sortByID();
if(particVector.size() > 0) //should never equal 0
if(particVector[0]->getParticID() != particPtr->getParticID())
gamePrice = GamePriceParticPremium();
return(gamePrice - particPtr->getGamePrice()); //deduct already paid
}
/******************************************************************************/
/******************************************************************************/
void LoadParticVectorByWhereStr(const char* whereStr,TParticVector& particVector)
{
TQuery* pQuery = NULL;
CStrVar str;
TParticPtr particPtr;
// Find all Partics
try
{
particVector.erase(particVector.begin(),particVector.end());
str.copy("select * from Partic");
if(tStrHasLen(whereStr))
str.concatVarg(" where %s",whereStr);
pQuery = OpenQuery(MemberDatabaseName(),str.c_str());
pQuery->First();
while(!pQuery->Eof)
{
particPtr = TPartic::newInstance();
particPtr->load(*pQuery);
particVector.push_back(particPtr);
pQuery->Next();
}
CloseQuery(pQuery);
}
catch(const Exception& e)
{
CloseQuery(pQuery);
throw ASIException(e.Message.c_str());
}
catch(...)
{
CloseQuery(pQuery);
throw;
}
}
/******************************************************************************/
void LoadParticVectorByParticIDVector(const TParticIDVector& particIDVector,
TParticVector& particVector)
{
TParticIDVector::const_iterator iter;
CStrVar str;
CStrVar idStr;
if(particIDVector.size() == 0)
{
particVector.erase(particVector.begin(),particVector.end());
return;
}
for(iter = particIDVector.begin(); iter != particIDVector.end(); iter++)
{
if(idStr.hasLen())
idStr.concat(",");
idStr.concat((*iter).c_str());
}
str.copyVarg("ParticID in (%s)",idStr.c_str());
LoadParticVectorByWhereStr(str,particVector);
}
/******************************************************************************/
void LoadParticVectorByMemberIDGameID(const TMemberID memberID,
const TGameID gameID,TParticVector& particVector)
{
CStrVar str;
str.copyVarg("((MemberID = \"%s\")",memberID.c_str());
str.concatVarg("and (GameID = \"%s\"))",gameID.c_str());
LoadParticVectorByWhereStr(str,particVector);
}
/******************************************************************************/
}; // namespace asmember
/******************************************************************************/
/******************************************************************************/
| [
"[email protected]"
] | [
[
[
1,
158
]
]
] |
776b7ba58a9548d0c4f68c989979a5077a4c9633 | 08c7de4d101008cb44841fa781c94f5bc17d8e20 | /src/configuration.cpp | eedbc9087d47dfd3d0a986d94b70c418cb8aefc5 | [] | no_license | CowboyCoders/cow_player | 1a661067b070b18b377db136e35aefa3bc035149 | ac0f5ba408459fb509105ddac99424e5afeefd22 | refs/heads/master | 2020-05-20T05:30:34.968270 | 2010-08-28T12:49:10 | 2010-08-28T12:49:10 | 868,351 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,776 | cpp | #include "configuration.h"
#include "tinyxml.h"
static const std::string configuration_property_tag_name = "property";
static const std::string configuration_property_name_attribute = "name";
static const std::string configuration_property_type_attribute = "type";
using namespace cow_player::configuration;
base_configuration::base_configuration()
{
}
base_configuration::base_configuration(const std::string& fileName)
{
load(fileName);
}
void base_configuration::load(const std::string& fileName)
{
TiXmlDocument document;
if (!document.LoadFile(fileName)) {
throw exceptions::load_config_error("Failed to open the configuration file.");
}
TiXmlElement* root = document.RootElement();
for (TiXmlElement* elem = root->FirstChildElement();
elem != NULL; elem = elem->NextSiblingElement())
{
if (elem->ValueStr() == configuration_property_tag_name) {
const std::string* property_name = elem->Attribute(configuration_property_name_attribute);
if (!property_name) {
throw exceptions::load_config_error("Property element is missing name attribute.");
}
const std::string* property_type = elem->Attribute(configuration_property_type_attribute);
if (!property_type) {
throw exceptions::load_config_error("Property element is missing type attribute.");
}
const char* text = elem->GetText();
std::string property_value(text ? text : "");
property_map_[*property_name] = std::make_pair(*property_type, property_value);
}
}
}
void base_configuration::save(const std::string& fileName) const
{
TiXmlDocument document;
TiXmlElement root("properties");
document.InsertEndChild(TiXmlDeclaration("1.0", "utf-8", ""));
cow_player::property_map::const_iterator it = property_map_.begin();
for (; it != property_map_.end(); ++it) {
// Create a property element
TiXmlElement property_node(configuration_property_tag_name);
// Set property attributes
property_node.SetAttribute(configuration_property_name_attribute, it->first);
property_node.SetAttribute(configuration_property_type_attribute, it->second.first);
// Add property value
property_node.InsertEndChild(TiXmlText(it->second.second));
// Insert property element in the tree
root.InsertEndChild(property_node);
}
// Insert root element into the document
document.InsertEndChild(root);
if (!document.SaveFile(fileName)) {
throw exceptions::save_config_error("Failed to save the configuration file to disk.");
}
}
| [
"[email protected]",
"devnull@localhost"
] | [
[
[
1,
3
],
[
7,
41
],
[
44,
79
]
],
[
[
4,
6
],
[
42,
43
]
]
] |
a818b296c0de816a468d5ac8fe6784cf4bcd1307 | f317b6eba86e00052f684e2001e1ea81f5357ee9 | /face_pickup/trunk/face_pickup/RequestHandler.cpp | 3b7e78bf0b7058112342a7c463fa2638caceba06 | [] | no_license | Habib120/apmayfes2011-kao | 2ef24ff490511a6a08606f3ab05d4152069721b8 | cb167c9ab6182ad13077c9ffe851bdc5be6f4256 | refs/heads/master | 2016-09-01T17:54:20.659856 | 2011-10-06T03:47:33 | 2011-10-06T03:47:33 | 33,204,831 | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 1,827 | cpp | #include "network.h"
#include "connection.h"
#include "photo.h"
#include "cv.h"
#include <boost/format.hpp>
#include <ctime>
#include <windows.h>
#define MOULIN_PHOTO_SAVE_DIR "C:\\photo\\"
#define MOULIN_PHOTO_LATEST_DIR "C:\\photo\\latest\\"
int latestcount = 0;
void RequestHandler::Handle(std::string msg)
{
std::vector<std::string> results;
std::string::size_type index = msg.find("||");
std::string header, body;
if (index == std::string::npos)
{
header = msg;
}
else
{
header = msg.substr(0, index);
body = msg.substr(index + 2);
}
std::cout << "header : " << header << " body : " << body << std::endl;
if (header == "take_photo")
{
IplImage* camimage = this->tracker->GetCurrentCamImage();
FaceComDetector detector;
std::vector<FaceComDetectionResult> results = detector.Detect(camimage);
IplImage* photo = MoulinPhotoMaker::GetMoulinPhoto(camimage, results);
//顔画像データの保存
time_t t = time(0);
tm *x = localtime(&t);
std::string dirname(MOULIN_PHOTO_SAVE_DIR);
std::string dirname_tmp(MOULIN_PHOTO_LATEST_DIR);
std::stringstream stream;
stream << "photo_" << 1900 + x->tm_year << "_" << 1 + x->tm_mon << "_"
<< x->tm_mday << "_" << x->tm_hour << "_" << x->tm_min
<< "_" << x->tm_sec << ".jpg";
std::string filename = stream.str();
filename = dirname + filename;
cvSaveImage(filename.c_str(), photo);
int latestnum = latestcount % 5;
std::stringstream stream_tmp;
stream_tmp << "photo_latest_" << latestnum << ".jpg";
latestcount++;
std::string filename_tmp = stream_tmp.str();
filename_tmp = dirname_tmp + filename_tmp;
cvSaveImage(filename_tmp.c_str(), photo);
cvReleaseImage(&camimage);
cvReleaseImage(&photo);
}
else if (header == "reset_game")
{
}
} | [
"[email protected]@4f86e157-8500-1dc0-33fe-d8cc54530173",
"[email protected]@4f86e157-8500-1dc0-33fe-d8cc54530173",
"[email protected]@4f86e157-8500-1dc0-33fe-d8cc54530173"
] | [
[
[
1,
6
],
[
8,
9
],
[
13,
40
],
[
42,
42
],
[
46,
48
],
[
58,
63
],
[
65,
66
]
],
[
[
7,
7
],
[
43,
45
],
[
64,
64
]
],
[
[
10,
12
],
[
41,
41
],
[
49,
57
]
]
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.