Work on bug #13

parent 2a769051
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: true
AlignConsecutiveAssignments: true
AlignEscapedNewlinesLeft: false
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackArguments: true
BinPackParameters: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
ColumnLimit: 100
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IndentCaseLabels: false
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 4
UseTab: Never
...
......@@ -43,22 +43,22 @@
/* --------------------------------------------------------------------------- */
extern void * globaldata ;
extern void * localdata ;
extern int local_size ;
extern int * localstr ;
extern int local_strings ;
extern void *globaldata;
extern void *localdata;
extern int local_size;
extern int *localstr;
extern int local_strings;
extern PROCDEF * procs ;
extern PROCDEF * mainproc ;
extern int procdef_count ;
extern PROCDEF *procs;
extern PROCDEF *mainproc;
extern int procdef_count;
extern char *appname;
extern char *appexename;
extern char *appexepath;
extern char *appexefullpath;
extern int debug ; /* 1 if running in debug mode */
extern int debug; /* 1 if running in debug mode */
/* Trace */
extern int debug_mode;
......@@ -70,22 +70,22 @@ extern int force_debug;
extern int debug_next;
extern int trace_sentence;
extern INSTANCE * trace_instance;
extern INSTANCE *trace_instance;
/* --------------------------------------------------------------------------- */
extern int bgdrtm_strncmpi( char * str1, char * str2, int sz );
extern int bgdrtm_strncmpi(char *str1, char *str2, int sz);
extern int dcb_load( const char * filename ) ;
extern int dcb_load_from( file * fp, const char * dcbname, int offset ) ;
extern int dcb_load(const char *filename);
extern int dcb_load_from(file *fp, const char *dcbname, int offset);
extern char * getid_name( unsigned int code );
extern char *getid_name(unsigned int code);
extern void mnemonic_dump( int i, int param );
extern void mnemonic_dump(int i, int param);
/* --------------------------------------------------------------------------- */
extern void bgdrtm_entry( int argc, char * argv[] );
extern void bgdrtm_exit( int n );
extern void bgdrtm_entry(int argc, char *argv[]);
extern void bgdrtm_exit(int n);
/* --------------------------------------------------------------------------- */
......
......@@ -39,41 +39,41 @@
/* ---------------------------------------------------------------------- */
extern char * sysproc_name( int code ) ;
extern char *sysproc_name(int code);
/* ---------------------------------------------------------------------- */
extern HOOK * handler_hook_list ;
extern int handler_hook_allocated ;
extern int handler_hook_count ;
extern HOOK *handler_hook_list;
extern int handler_hook_allocated;
extern int handler_hook_count;
extern INSTANCE_HOOK * instance_pre_execute_hook_list ;
extern int instance_pre_execute_hook_allocated ;
extern int instance_pre_execute_hook_count ;
extern INSTANCE_HOOK *instance_pre_execute_hook_list;
extern int instance_pre_execute_hook_allocated;
extern int instance_pre_execute_hook_count;
extern INSTANCE_HOOK * instance_pos_execute_hook_list ;
extern int instance_pos_execute_hook_allocated ;
extern int instance_pos_execute_hook_count ;
extern INSTANCE_HOOK *instance_pos_execute_hook_list;
extern int instance_pos_execute_hook_allocated;
extern int instance_pos_execute_hook_count;
extern INSTANCE_HOOK * instance_create_hook_list ;
extern int instance_create_hook_allocated ;
extern int instance_create_hook_count ;
extern INSTANCE_HOOK *instance_create_hook_list;
extern int instance_create_hook_allocated;
extern int instance_create_hook_count;
extern INSTANCE_HOOK * instance_destroy_hook_list ;
extern int instance_destroy_hook_allocated ;
extern int instance_destroy_hook_count ;
extern INSTANCE_HOOK *instance_destroy_hook_list;
extern int instance_destroy_hook_allocated;
extern int instance_destroy_hook_count;
extern INSTANCE_HOOK * process_exec_hook_list ;
extern int process_exec_hook_allocated ;
extern int process_exec_hook_count ;
extern INSTANCE_HOOK *process_exec_hook_list;
extern int process_exec_hook_allocated;
extern int process_exec_hook_count;
extern FN_HOOK * module_initialize_list ;
extern int module_initialize_allocated ;
extern int module_initialize_count ;
extern FN_HOOK *module_initialize_list;
extern int module_initialize_allocated;
extern int module_initialize_count;
extern FN_HOOK * module_finalize_list ;
extern int module_finalize_allocated ;
extern int module_finalize_count ;
extern FN_HOOK *module_finalize_list;
extern int module_finalize_allocated;
extern int module_finalize_count;
/* ---------------------------------------------------------------------- */
......
......@@ -44,7 +44,7 @@
#include "xstrings.h"
#include "bgdrtm.h"
static int copytype( void * dst, void * src, DCB_TYPEDEF * var );
static int copytype(void *dst, void *src, DCB_TYPEDEF *var);
/*
* FUNCTION : copyvars
......@@ -63,22 +63,19 @@ static int copytype( void * dst, void * src, DCB_TYPEDEF * var );
*
*/
int copyvars( void * dst, void * src, DCB_VAR * var, int nvars )
{
int copyvars(void *dst, void *src, DCB_VAR *var, int nvars) {
int result = 0;
int partial;
for ( ; nvars > 0; nvars--, var++ )
{
partial = copytype( dst, src, &var->Type );
src = (( uint8_t* )src ) + partial;
dst = (( uint8_t* )dst ) + partial;
for (; nvars > 0; nvars--, var++) {
partial = copytype(dst, src, &var->Type);
src = ((uint8_t *)src) + partial;
dst = ((uint8_t *)dst) + partial;
result += partial;
}
return result;
}
/*
* FUNCTION : copytypes
*
......@@ -95,23 +92,20 @@ int copyvars( void * dst, void * src, DCB_VAR * var, int nvars )
*
*/
int copytypes( void * dst, void * src, DCB_TYPEDEF * var, int nvars, int reps )
{
int copytypes(void *dst, void *src, DCB_TYPEDEF *var, int nvars, int reps) {
int result = 0;
int partial;
DCB_TYPEDEF * _var = var;
int _nvars = nvars ;
DCB_TYPEDEF *_var = var;
int _nvars = nvars;
for ( ; reps > 0; reps-- )
{
var = _var;
for (; reps > 0; reps--) {
var = _var;
nvars = _nvars;
for ( ; nvars > 0; nvars--, var++ )
{
partial = copytype( dst, src, var );
for (; nvars > 0; nvars--, var++) {
partial = copytype(dst, src, var);
result += partial;
src = (( uint8_t* )src ) + partial;
dst = (( uint8_t* )dst ) + partial;
src = ((uint8_t *)src) + partial;
dst = ((uint8_t *)dst) + partial;
}
}
return result;
......@@ -132,65 +126,61 @@ int copytypes( void * dst, void * src, DCB_TYPEDEF * var, int nvars, int reps )
*
*/
static int copytype( void * dst, void * src, DCB_TYPEDEF * var )
{
static int copytype(void *dst, void *src, DCB_TYPEDEF *var) {
int count = 1;
int result = 0;
int n = 0;
for ( ;; )
{
switch ( var->BaseType[n] )
{
case TYPE_FLOAT:
case TYPE_INT:
case TYPE_DWORD:
case TYPE_POINTER:
memcpy( dst, src, 4 * count );
return 4 * count;
case TYPE_WORD:
case TYPE_SHORT:
memcpy( dst, src, 2 * count );
return 2 * count;
case TYPE_BYTE:
case TYPE_SBYTE:
case TYPE_CHAR:
memcpy( dst, src, count );
return count;
case TYPE_STRING:
while ( count-- )
{
string_discard( *( int * )dst );
string_use( *( int * )src );
*(( int * )dst ) = *(( int * )src );
dst = (( int * )dst ) + 1;
src = (( int * )src ) + 1;
result += 4;
}
return result;
case TYPE_ARRAY:
count *= var->Count[n];
n++;
continue;
case TYPE_STRUCT:
for ( ; count ; count-- )
{
int partial = copyvars( dst, src, dcb.varspace_vars[var->Members], dcb.varspace[var->Members].NVars );
src = (( uint8_t* )src ) + partial;
dst = (( uint8_t* )dst ) + partial;
result += partial;
}
break;
default:
fprintf( stderr, "ERROR: Runtime error - Could not copy datatype\n" ) ;
exit( 1 );
break;
for (;;) {
switch (var->BaseType[n]) {
case TYPE_FLOAT:
case TYPE_INT:
case TYPE_DWORD:
case TYPE_POINTER:
memcpy(dst, src, 4 * count);
return 4 * count;
case TYPE_WORD:
case TYPE_SHORT:
memcpy(dst, src, 2 * count);
return 2 * count;
case TYPE_BYTE:
case TYPE_SBYTE:
case TYPE_CHAR:
memcpy(dst, src, count);
return count;
case TYPE_STRING:
while (count--) {
string_discard(*(int *)dst);
string_use(*(int *)src);
*((int *)dst) = *((int *)src);
dst = ((int *)dst) + 1;
src = ((int *)src) + 1;
result += 4;
}
return result;
case TYPE_ARRAY:
count *= var->Count[n];
n++;
continue;
case TYPE_STRUCT:
for (; count; count--) {
int partial = copyvars(dst, src, dcb.varspace_vars[var->Members],
dcb.varspace[var->Members].NVars);
src = ((uint8_t *)src) + partial;
dst = ((uint8_t *)dst) + partial;
result += partial;
}
break;
default:
fprintf(stderr, "ERROR: Runtime error - Could not copy datatype\n");
exit(1);
break;
}
break;
}
......@@ -203,25 +193,22 @@ static int copytype( void * dst, void * src, DCB_TYPEDEF * var )
* Copy struct data from src to dst, using the information varspace given
**/
int bgd_copy_struct( INSTANCE * my, int * params )
{
return ( int ) copytypes(( void * )params[0], ( void * )params[1], ( DCB_TYPEDEF * )params[2], params[3], params[4] );
int bgd_copy_struct(INSTANCE *my, int *params) {
return (int)copytypes((void *)params[0], (void *)params[1], (DCB_TYPEDEF *)params[2], params[3],
params[4]);
}
int bgd_internal_memcopy( INSTANCE * my, int * params )
{
memmove(( void * )params[0], ( void * )params[1], params[2] ) ;
return 1 ;
int bgd_internal_memcopy(INSTANCE *my, int *params) {
memmove((void *)params[0], (void *)params[1], params[2]);
return 1;
}
int bgd_internal_copy_string_array( INSTANCE * my, int * params )
{
int n = params[ 2 ];
while( n-- )
{
((int *)( params[ 0 ] )) [ n ] = ((int *)( params[ 1 ] )) [ n ];
string_use( ((int *)( params[ 0 ] )) [ n ] );
int bgd_internal_copy_string_array(INSTANCE *my, int *params) {
int n = params[2];
while (n--) {
((int *)(params[0]))[n] = ((int *)(params[1]))[n];
string_use(((int *)(params[0]))[n]);
}
return 1 ;
return 1;
}
This diff is collapsed.
This diff is collapsed.
......@@ -38,112 +38,109 @@
//#define FIXED_PREC 12
#define FIXED_PREC 10000
#define FIXED_PREC 10000
//#define FIXED_PREC_MED 5000
//#define FIXED_PREC_DEC 1000
/* --------------------------------------------------------------------------- */
static fixed * cos_table = NULL ;
static fixed *cos_table = NULL;
/* --------------------------------------------------------------------------- */
fixed ftofix( float x )
{
return ( long )( x * FIXED_PREC );
fixed ftofix(float x) {
return (long)(x * FIXED_PREC);
}
/* --------------------------------------------------------------------------- */
float fixtof( fixed x )
{
return ( ( float ) x ) / FIXED_PREC ;
float fixtof(fixed x) {
return ((float)x) / FIXED_PREC;
}
/* --------------------------------------------------------------------------- */
fixed itofix( int x )
{
return x * FIXED_PREC ;
fixed itofix(int x) {
return x * FIXED_PREC;
}
/* --------------------------------------------------------------------------- */
int fixtoi( fixed x )
{
return x / FIXED_PREC ;
int fixtoi(fixed x) {
return x / FIXED_PREC;
}
/* --------------------------------------------------------------------------- */
int fixceil( fixed x )
{
int fixceil(fixed x) {
int xd;
if ( x < 0 )
{
xd = x % FIXED_PREC ;
x -= ( FIXED_PREC + xd ) ;
}
else if ( x > 0 )
{
xd = x % FIXED_PREC ;
x += ( FIXED_PREC - xd ) ;
if (x < 0) {
xd = x % FIXED_PREC;
x -= (FIXED_PREC + xd);
} else if (x > 0) {
xd = x % FIXED_PREC;
x += (FIXED_PREC - xd);
}
return x ;
return x;
}
/* --------------------------------------------------------------------------- */
fixed fcos( int x )
{
if ( x < 0 ) x = -x ;
if ( x > 360000 ) x %= 360000 ;
if ( x > 270000 ) return cos_table[360000 - x] ;
if ( x > 180000 ) return -cos_table[x - 180000] ;
if ( x > 90000 ) return -cos_table[180000 - x] ;
return cos_table[x] ;
fixed fcos(int x) {
if (x < 0)
x = -x;
if (x > 360000)
x %= 360000;
if (x > 270000)
return cos_table[360000 - x];
if (x > 180000)
return -cos_table[x - 180000];
if (x > 90000)
return -cos_table[180000 - x];
return cos_table[x];
}
/* --------------------------------------------------------------------------- */
fixed fsin( int x )
{
if ( x < 0 ) return -fsin( -x ) ;
if ( x > 360000 ) x %= 360000 ;
if ( x > 270000 ) return -cos_table[x - 270000] ;
if ( x > 180000 ) return -cos_table[270000 - x] ;
if ( x > 90000 ) return cos_table[x - 90000] ;
return cos_table[90000 - x] ;
fixed fsin(int x) {
if (x < 0)
return -fsin(-x);
if (x > 360000)
x %= 360000;
if (x > 270000)
return -cos_table[x - 270000];
if (x > 180000)
return -cos_table[270000 - x];
if (x > 90000)
return cos_table[x - 90000];
return cos_table[90000 - x];
}
/* --------------------------------------------------------------------------- */
fixed fmul( int x, int y )
{
return ftofix( fixtof( x ) * fixtof( y ) ) ;
fixed fmul(int x, int y) {
return ftofix(fixtof(x) * fixtof(y));
}
/* --------------------------------------------------------------------------- */
fixed fdiv( int x, int y )
{
return ftofix( fixtof( x ) / fixtof( y ) ) ;
fixed fdiv(int x, int y) {
return ftofix(fixtof(x) / fixtof(y));
}
/* --------------------------------------------------------------------------- */
void init_cos_tables()
{
int i ;
void init_cos_tables() {
int i;
if ( !cos_table ) cos_table = ( fixed * ) malloc( 90001 * sizeof( fixed ) );
if (!cos_table)
cos_table = (fixed *)malloc(90001 * sizeof(fixed));
for ( i = 0 ; i <= 90000 ; i++ )
{
cos_table[i] = ftofix( cos( i * M_PI / 180000.0 ) ) ;
for (i = 0; i <= 90000; i++) {
cos_table[i] = ftofix(cos(i * M_PI / 180000.0));
}
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -48,100 +48,100 @@
/* --------------------------------------------------------------------------- */
char * appname = NULL;
char * appexename = NULL;
char * appexepath = NULL;
char * appexefullpath = NULL;
char *appname = NULL;
char *appexename = NULL;
char *appexepath = NULL;
char *appexefullpath = NULL;
/* --------------------------------------------------------------------------- */
int debug = 0; /* 1 if running in debug mode */
int debug = 0; /* 1 if running in debug mode */
/* --------------------------------------------------------------------------- */
/* os versions */
#ifdef _WIN32
#define _OS_ID OS_WIN32
#define _OS_ID OS_WIN32
#endif
#ifdef __linux__
#define _OS_ID OS_LINUX
#define _OS_ID OS_LINUX
#endif
#ifdef TARGET_BEOS
#define _OS_ID OS_BEOS
#define _OS_ID OS_BEOS
#endif
#ifdef __APPLE__
#define _OS_ID OS_MACOS
#define _OS_ID OS_MACOS
#endif
#ifdef TARGET_GP32
#define _OS_ID OS_GP32
#define _OS_ID OS_GP32
#endif
#ifdef TARGET_DC
#define _OS_ID OS_DC
#define _OS_ID OS_DC
#endif
#ifdef TARGET_BSD
#define _OS_ID OS_BSD
#define _OS_ID OS_BSD
#endif
#ifdef TARGET_GP2X
#ifdef _OS_ID
#undef _OS_ID
#endif
#define _OS_ID OS_GP2X
#define _OS_ID OS_GP2X
#endif
#ifdef TARGET_GP2X_WIZ
#ifdef _OS_ID
#undef _OS_ID
#endif
#define _OS_ID OS_GP2X_WIZ
#define _OS_ID OS_GP2X_WIZ
#endif
#ifdef TARGET_CAANOO
#ifdef _OS_ID
#undef _OS_ID
#endif
#define _OS_ID OS_CAANOO
#define _OS_ID OS_CAANOO
#endif
#ifdef TARGET_DINGUX_A320
#ifdef _OS_ID
#undef _OS_ID
#endif
#define _OS_ID OS_DINGUX_A320
#define _OS_ID OS_DINGUX_A320
#endif
#ifdef TARGET_WII
#ifdef _OS_ID
#undef _OS_ID
#endif
#define _OS_ID OS_WII
#define _OS_ID OS_WII
#endif
#ifdef TARGET_PSP
#ifdef _OS_ID
#undef _OS_ID
#endif
#define _OS_ID OS_PSP
#define _OS_ID OS_PSP
#endif
#if (defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR))