mirror of
https://github.com/jmarshall23/CnC_Remastered_Collection.git
synced 2026-08-11 23:50:51 +02:00
Merge pull request #13 from benlankamp/BL/SDL-UserInput-plus-hotfixes
Fix for turrets on destroyers + Add object in map editor
This commit is contained in:
@@ -436,3 +436,130 @@ void Move_Point(short& x, short& y, register DirType dir, unsigned short distanc
|
||||
x += ( cosTable[dir] * distance ) / SHRT_MAX;
|
||||
y += -( sinTable[dir] * distance ) / SHRT_MAX;
|
||||
}
|
||||
|
||||
int __cdecl calcx(signed short param1, short distance)
|
||||
{
|
||||
__asm {
|
||||
|
||||
//#pragma aux calcx parm [ax] [bx] \
|
||||
|
||||
movzx eax, [param1]
|
||||
mov bx, [distance]
|
||||
imul bx
|
||||
shl ax, 1
|
||||
rcl dx, 1
|
||||
mov al, ah
|
||||
mov ah, dl
|
||||
cwd
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int __cdecl calcy(signed short param1, short distance)
|
||||
{
|
||||
__asm {
|
||||
|
||||
//#pragma aux calcy parm [ax] [bx] \
|
||||
|
||||
movzx eax, [param1]
|
||||
mov bx, [distance]
|
||||
imul bx
|
||||
shl ax, 1
|
||||
rcl dx, 1
|
||||
mov al, ah
|
||||
mov ah, dl
|
||||
cwd
|
||||
neg eax
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Normal_Move_Point(short& x, short& y, register DirType dir, unsigned short distance)
|
||||
{
|
||||
static unsigned char const CosTable[256] = {
|
||||
0x00,0x03,0x06,0x09,0x0c,0x0f,0x12,0x15,
|
||||
0x18,0x1b,0x1e,0x21,0x24,0x27,0x2a,0x2d,
|
||||
0x30,0x33,0x36,0x39,0x3b,0x3e,0x41,0x43,
|
||||
0x46,0x49,0x4b,0x4e,0x50,0x52,0x55,0x57,
|
||||
0x59,0x5b,0x5e,0x60,0x62,0x64,0x65,0x67,
|
||||
0x69,0x6b,0x6c,0x6e,0x6f,0x71,0x72,0x74,
|
||||
0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7b,
|
||||
0x7c,0x7d,0x7d,0x7e,0x7e,0x7e,0x7e,0x7e,
|
||||
|
||||
0x7f,0x7e,0x7e,0x7e,0x7e,0x7e,0x7d,0x7d,
|
||||
0x7c,0x7b,0x7b,0x7a,0x79,0x78,0x77,0x76,
|
||||
0x75,0x74,0x72,0x71,0x70,0x6e,0x6c,0x6b,
|
||||
0x69,0x67,0x66,0x64,0x62,0x60,0x5e,0x5b,
|
||||
0x59,0x57,0x55,0x52,0x50,0x4e,0x4b,0x49,
|
||||
0x46,0x43,0x41,0x3e,0x3b,0x39,0x36,0x33,
|
||||
0x30,0x2d,0x2a,0x27,0x24,0x21,0x1e,0x1b,
|
||||
0x18,0x15,0x12,0x0f,0x0c,0x09,0x06,0x03,
|
||||
|
||||
0x00,0xfd,0xfa,0xf7,0xf4,0xf1,0xee,0xeb,
|
||||
0xe8,0xe5,0xe2,0xdf,0xdc,0xd9,0xd6,0xd3,
|
||||
0xd0,0xcd,0xca,0xc7,0xc5,0xc2,0xbf,0xbd,
|
||||
0xba,0xb7,0xb5,0xb2,0xb0,0xae,0xab,0xa9,
|
||||
0xa7,0xa5,0xa2,0xa0,0x9e,0x9c,0x9a,0x99,
|
||||
0x97,0x95,0x94,0x92,0x91,0x8f,0x8e,0x8c,
|
||||
0x8b,0x8a,0x89,0x88,0x87,0x86,0x85,0x85,
|
||||
0x84,0x83,0x83,0x82,0x82,0x82,0x82,0x82,
|
||||
|
||||
0x82,0x82,0x82,0x82,0x82,0x82,0x83,0x83,
|
||||
0x84,0x85,0x85,0x86,0x87,0x88,0x89,0x8a,
|
||||
0x8b,0x8c,0x8e,0x8f,0x90,0x92,0x94,0x95,
|
||||
0x97,0x99,0x9a,0x9c,0x9e,0xa0,0xa2,0xa5,
|
||||
0xa7,0xa9,0xab,0xae,0xb0,0xb2,0xb5,0xb7,
|
||||
0xba,0xbd,0xbf,0xc2,0xc5,0xc7,0xca,0xcd,
|
||||
0xd0,0xd3,0xd6,0xd9,0xdc,0xdf,0xe2,0xe5,
|
||||
0xe8,0xeb,0xee,0xf1,0xf4,0xf7,0xfa,0xfd,
|
||||
};
|
||||
|
||||
static unsigned char const SinTable[256] = {
|
||||
0x7f,0x7e,0x7e,0x7e,0x7e,0x7e,0x7d,0x7d,
|
||||
0x7c,0x7b,0x7b,0x7a,0x79,0x78,0x77,0x76,
|
||||
0x75,0x74,0x72,0x71,0x70,0x6e,0x6c,0x6b,
|
||||
0x69,0x67,0x66,0x64,0x62,0x60,0x5e,0x5b,
|
||||
0x59,0x57,0x55,0x52,0x50,0x4e,0x4b,0x49,
|
||||
0x46,0x43,0x41,0x3e,0x3b,0x39,0x36,0x33,
|
||||
0x30,0x2d,0x2a,0x27,0x24,0x21,0x1e,0x1b,
|
||||
0x18,0x15,0x12,0x0f,0x0c,0x09,0x06,0x03,
|
||||
|
||||
0x00,0xfd,0xfa,0xf7,0xf4,0xf1,0xee,0xeb,
|
||||
0xe8,0xe5,0xe2,0xdf,0xdc,0xd9,0xd6,0xd3,
|
||||
0xd0,0xcd,0xca,0xc7,0xc5,0xc2,0xbf,0xbd,
|
||||
0xba,0xb7,0xb5,0xb2,0xb0,0xae,0xab,0xa9,
|
||||
0xa7,0xa5,0xa2,0xa0,0x9e,0x9c,0x9a,0x99,
|
||||
0x97,0x95,0x94,0x92,0x91,0x8f,0x8e,0x8c,
|
||||
0x8b,0x8a,0x89,0x88,0x87,0x86,0x85,0x85,
|
||||
0x84,0x83,0x83,0x82,0x82,0x82,0x82,0x82,
|
||||
|
||||
0x82,0x82,0x82,0x82,0x82,0x82,0x83,0x83,
|
||||
0x84,0x85,0x85,0x86,0x87,0x88,0x89,0x8a,
|
||||
0x8b,0x8c,0x8e,0x8f,0x90,0x92,0x94,0x95,
|
||||
0x97,0x99,0x9a,0x9c,0x9e,0xa0,0xa2,0xa5,
|
||||
0xa7,0xa9,0xab,0xae,0xb0,0xb2,0xb5,0xb7,
|
||||
0xba,0xbd,0xbf,0xc2,0xc5,0xc7,0xca,0xcd,
|
||||
0xd0,0xd3,0xd6,0xd9,0xdc,0xdf,0xe2,0xe5,
|
||||
0xe8,0xeb,0xee,0xf1,0xf4,0xf7,0xfa,0xfd,
|
||||
|
||||
0x00,0x03,0x06,0x09,0x0c,0x0f,0x12,0x15,
|
||||
0x18,0x1b,0x1e,0x21,0x24,0x27,0x2a,0x2d,
|
||||
0x30,0x33,0x36,0x39,0x3b,0x3e,0x41,0x43,
|
||||
0x46,0x49,0x4b,0x4e,0x50,0x52,0x55,0x57,
|
||||
0x59,0x5b,0x5e,0x60,0x62,0x64,0x65,0x67,
|
||||
0x69,0x6b,0x6c,0x6e,0x6f,0x71,0x72,0x74,
|
||||
0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7b,
|
||||
0x7c,0x7d,0x7d,0x7e,0x7e,0x7e,0x7e,0x7e,
|
||||
};
|
||||
distance = distance; // Keep LINT quiet.
|
||||
|
||||
//
|
||||
// Have to declare table as unsigned otherwise MSVC complains, but we need to treat the actual values as signed.
|
||||
//
|
||||
static const char* _sin_table = (char*)&SinTable[0];
|
||||
static const char* _cos_table = (char*)&CosTable[0];
|
||||
|
||||
x += calcx(_cos_table[dir], distance);
|
||||
|
||||
y += calcy(_sin_table[dir] / 2, distance);
|
||||
}
|
||||
@@ -569,6 +569,7 @@ void Shake_The_Screen(int shakes, HousesType house = HOUSE_NONE);
|
||||
** COORD.CPP
|
||||
*/
|
||||
short const * Coord_Spillage_List(COORDINATE coord, Rect const & rect, bool nocenter=true);
|
||||
void Normal_Move_Point(short& x, short& y, register DirType dir, unsigned short distance);
|
||||
void Move_Point(short &x, short &y, register DirType dir, unsigned short distance);
|
||||
COORDINATE Coord_Move(COORDINATE start, DirType facing, unsigned short distance);
|
||||
COORDINATE Coord_Scatter(COORDINATE coord, unsigned distance, bool lock=false);
|
||||
|
||||
@@ -425,6 +425,12 @@ int MapEditClass::Placement_Dialog(void)
|
||||
*/
|
||||
Call_Back();
|
||||
|
||||
g_globalKeyNumType = KN_NONE;
|
||||
g_globalKeyFlags = 0;
|
||||
UserInput.Process_Input();
|
||||
|
||||
Device_Present();
|
||||
|
||||
/*
|
||||
** Refresh display if needed
|
||||
*/
|
||||
|
||||
@@ -609,19 +609,19 @@ void VesselTypeClass::Turret_Adjust(DirType dir, int & x, int & y) const
|
||||
|
||||
switch (Type) {
|
||||
case VESSEL_CA:
|
||||
Move_Point(xx, yy, dir, 22);
|
||||
Normal_Move_Point(xx, yy, dir, 22);
|
||||
x = xx;
|
||||
y = yy-4;
|
||||
break;
|
||||
|
||||
case VESSEL_PT:
|
||||
Move_Point(xx, yy, dir, 14);
|
||||
Normal_Move_Point(xx, yy, dir, 14);
|
||||
x = xx;
|
||||
y = yy+1;
|
||||
break;
|
||||
|
||||
case VESSEL_DD:
|
||||
Move_Point(xx, yy, dir+DIR_S, 8);
|
||||
Normal_Move_Point(xx, yy, dir+DIR_S, 8);
|
||||
x = xx;
|
||||
y = yy-4;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user