seta010 fixes

op01, op04, op05
This commit is contained in:
kps501 2018-06-24 11:54:47 -05:00 committed by GitHub
parent dfaae04670
commit 54f5c1f35c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 280 additions and 372 deletions

View File

@ -231,72 +231,72 @@ static const int16 ST010_SinTable[256] =
-0x18f8, -0x15e2, -0x12c8, -0x0fab, -0x0c8b, -0x096a, -0x0647, -0x0324
};
static const uint8 ST010_ArcTan[32][32] =
static const uint8 ST010_ArcTan[32][32] =
{
{ 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 },
{ 0x80, 0xa0, 0xad, 0xb3, 0xb6, 0xb8, 0xb9, 0xba, 0xbb, 0xbb, 0xbc, 0xbc, 0xbd, 0xbd, 0xbd, 0xbd,
0xbd, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbf, 0xbf, 0xbf, 0xbf },
{ 0x80, 0x93, 0xa0, 0xa8, 0xad, 0xb0, 0xb3, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xb9, 0xba, 0xba, 0xbb,
0xbb, 0xbb, 0xbb, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd },
{ 0x80, 0x8d, 0x98, 0xa0, 0xa6, 0xaa, 0xad, 0xb0, 0xb1, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb7, 0xb8,
0xb8, 0xb9, 0xb9, 0xba, 0xba, 0xba, 0xba, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbc, 0xbc, 0xbc, 0xbc },
{ 0x80, 0x8a, 0x93, 0x9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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x40, 0x20, 0x13, 0x0D, 0x0A, 0x08, 0x07, 0x06, 0x05, 0x05, 0x04, 0x04, 0x03, 0x03, 0x03, 0x03,
0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01 },
{ 0x40, 0x2D, 0x20, 0x18, 0x13, 0x10, 0x0D, 0x0B, 0x0A, 0x09, 0x08, 0x07, 0x07, 0x06, 0x06, 0x05,
0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 },
{ 0x40, 0x33, 0x28, 0x20, 0x1A, 0x16, 0x13, 0x10, 0x0F, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x09, 0x08,
0x08, 0x07, 0x07, 0x06, 0x06, 0x06, 0x06, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04 },
{ 0x40, 0x36, 0x2D, 0x26, 0x20, 0x1B, 0x18, 0x15, 0x13, 0x11, 0x10, 0x0E, 0x0D, 0x0C, 0x0B, 0x0B,
0x0A, 0x09, 0x09, 0x08, 0x08, 0x08, 0x07, 0x07, 0x07, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x05 },
{ 0x40, 0x38, 0x30, 0x2A, 0x25, 0x20, 0x1C, 0x19, 0x17, 0x15, 0x13, 0x11, 0x10, 0x0F, 0x0E, 0x0D,
0x0C, 0x0C, 0x0B, 0x0A, 0x0A, 0x0A, 0x09, 0x09, 0x08, 0x08, 0x08, 0x07, 0x07, 0x07, 0x07, 0x07 },
{ 0x40, 0x39, 0x33, 0x2D, 0x28, 0x24, 0x20, 0x1D, 0x1A, 0x18, 0x16, 0x14, 0x13, 0x12, 0x10, 0x10,
0x0F, 0x0E, 0x0D, 0x0C, 0x0C, 0x0B, 0x0B, 0x0A, 0x0A, 0x0A, 0x09, 0x09, 0x09, 0x08, 0x08, 0x08 },
{ 0x40, 0x3A, 0x35, 0x30, 0x2B, 0x27, 0x23, 0x20, 0x1D, 0x1B, 0x19, 0x17, 0x16, 0x14, 0x13, 0x12,
0x11, 0x10, 0x0F, 0x0E, 0x0E, 0x0D, 0x0D, 0x0C, 0x0C, 0x0B, 0x0B, 0x0A, 0x0A, 0x0A, 0x09, 0x09 },
{ 0x40, 0x3B, 0x36, 0x31, 0x2D, 0x29, 0x26, 0x23, 0x20, 0x1E, 0x1B, 0x1A, 0x18, 0x16, 0x15, 0x14,
0x13, 0x12, 0x11, 0x10, 0x10, 0x0F, 0x0E, 0x0E, 0x0D, 0x0D, 0x0C, 0x0C, 0x0B, 0x0B, 0x0B, 0x0A },
{ 0x40, 0x3B, 0x37, 0x33, 0x2F, 0x2B, 0x28, 0x25, 0x22, 0x20, 0x1E, 0x1C, 0x1A, 0x19, 0x17, 0x16,
0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 0x10, 0x0F, 0x0F, 0x0E, 0x0E, 0x0D, 0x0D, 0x0C, 0x0C, 0x0C },
{ 0x40, 0x3C, 0x38, 0x34, 0x30, 0x2D, 0x2A, 0x27, 0x25, 0x20, 0x20, 0x1E, 0x1C, 0x1B, 0x19, 0x18,
0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x11, 0x10, 0x10, 0x0F, 0x0E, 0x0E, 0x0E, 0x0D, 0x0D },
{ 0x40, 0x3C, 0x39, 0x35, 0x32, 0x2F, 0x2C, 0x29, 0x26, 0x24, 0x22, 0x20, 0x1E, 0x1D, 0x1B, 0x1A,
0x19, 0x17, 0x16, 0x15, 0x14, 0x14, 0x13, 0x12, 0x12, 0x11, 0x10, 0x10, 0x0F, 0x0F, 0x0E, 0x0E },
{ 0x40, 0x3D, 0x39, 0x36, 0x33, 0x30, 0x2D, 0x2A, 0x28, 0x26, 0x24, 0x22, 0x20, 0x1E, 0x1D, 0x1B,
0x1A, 0x19, 0x18, 0x17, 0x16, 0x15, 0x14, 0x14, 0x13, 0x12, 0x12, 0x11, 0x10, 0x10, 0x10, 0x0F },
{ 0x40, 0x3D, 0x3A, 0x37, 0x34, 0x31, 0x2E, 0x2C, 0x2A, 0x27, 0x25, 0x23, 0x22, 0x20, 0x1E, 0x1D,
0x1C, 0x1B, 0x19, 0x18, 0x17, 0x17, 0x16, 0x15, 0x14, 0x14, 0x13, 0x12, 0x12, 0x11, 0x11, 0x10 },
{ 0x40, 0x3D, 0x3A, 0x37, 0x35, 0x32, 0x30, 0x2D, 0x2B, 0x29, 0x27, 0x25, 0x23, 0x22, 0x20, 0x1F,
0x1D, 0x1C, 0x1B, 0x1A, 0x19, 0x18, 0x17, 0x16, 0x16, 0x15, 0x14, 0x13, 0x13, 0x12, 0x12, 0x11 },
{ 0x40, 0x3D, 0x3B, 0x38, 0x35, 0x33, 0x30, 0x2E, 0x2C, 0x2A, 0x28, 0x26, 0x25, 0x23, 0x21, 0x20,
0x1F, 0x1D, 0x1C, 0x1B, 0x1A, 0x19, 0x18, 0x18, 0x17, 0x16, 0x15, 0x15, 0x14, 0x13, 0x13, 0x12 },
{ 0x40, 0x3D, 0x3B, 0x38, 0x36, 0x34, 0x31, 0x2F, 0x2D, 0x2B, 0x29, 0x27, 0x26, 0x24, 0x23, 0x21,
0x20, 0x1F, 0x1E, 0x1D, 0x1B, 0x1B, 0x1A, 0x19, 0x18, 0x17, 0x16, 0x16, 0x15, 0x15, 0x14, 0x13 },
{ 0x40, 0x3E, 0x3B, 0x39, 0x37, 0x34, 0x32, 0x30, 0x2E, 0x2C, 0x2A, 0x29, 0x27, 0x25, 0x24, 0x23,
0x21, 0x20, 0x1F, 0x1E, 0x1D, 0x1C, 0x1B, 0x1A, 0x19, 0x18, 0x18, 0x17, 0x16, 0x16, 0x15, 0x14 },
{ 0x40, 0x3E, 0x3B, 0x39, 0x37, 0x35, 0x33, 0x31, 0x2F, 0x2D, 0x2B, 0x2A, 0x28, 0x27, 0x25, 0x24,
0x22, 0x21, 0x20, 0x1F, 0x1E, 0x1D, 0x1C, 0x1B, 0x1A, 0x19, 0x19, 0x18, 0x17, 0x17, 0x16, 0x15 },
{ 0x40, 0x3E, 0x3C, 0x3A, 0x38, 0x36, 0x34, 0x32, 0x30, 0x2E, 0x2C, 0x2B, 0x29, 0x28, 0x26, 0x25,
0x23, 0x22, 0x21, 0x20, 0x1F, 0x1E, 0x1D, 0x1C, 0x1B, 0x1A, 0x1A, 0x19, 0x18, 0x18, 0x17, 0x16 },
{ 0x40, 0x3E, 0x3C, 0x3A, 0x38, 0x36, 0x34, 0x32, 0x30, 0x2F, 0x2D, 0x2C, 0x2A, 0x29, 0x27, 0x26,
0x25, 0x23, 0x22, 0x21, 0x20, 0x1F, 0x1E, 0x1D, 0x1C, 0x1B, 0x1B, 0x1A, 0x19, 0x19, 0x18, 0x17 },
{ 0x40, 0x3E, 0x3C, 0x3A, 0x38, 0x36, 0x35, 0x33, 0x31, 0x30, 0x2E, 0x2C, 0x2B, 0x29, 0x28, 0x27,
0x25, 0x24, 0x23, 0x22, 0x21, 0x20, 0x1F, 0x1E, 0x1D, 0x1C, 0x1C, 0x1B, 0x1A, 0x1A, 0x19, 0x18 },
{ 0x40, 0x3E, 0x3C, 0x3A, 0x39, 0x37, 0x35, 0x33, 0x32, 0x30, 0x2F, 0x2D, 0x2C, 0x2A, 0x29, 0x28,
0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0x20, 0x1F, 0x1E, 0x1D, 0x1D, 0x1C, 0x1B, 0x1A, 0x1A, 0x19 },
{ 0x40, 0x3E, 0x3C, 0x3B, 0x39, 0x37, 0x36, 0x34, 0x32, 0x31, 0x2F, 0x2E, 0x2C, 0x2B, 0x2A, 0x28,
0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0x20, 0x1F, 0x1E, 0x1E, 0x1D, 0x1C, 0x1B, 0x1B, 0x1A },
{ 0x40, 0x3E, 0x3D, 0x3B, 0x39, 0x38, 0x36, 0x34, 0x33, 0x31, 0x30, 0x2E, 0x2D, 0x2C, 0x2A, 0x29,
0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0x20, 0x1F, 0x1E, 0x1E, 0x1D, 0x1C, 0x1B, 0x1B },
{ 0x40, 0x3E, 0x3D, 0x3B, 0x3A, 0x38, 0x36, 0x35, 0x33, 0x32, 0x30, 0x2F, 0x2E, 0x2C, 0x2B, 0x2A,
0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0x20, 0x1F, 0x1E, 0x1E, 0x1D, 0x1C, 0x1C },
{ 0x40, 0x3E, 0x3D, 0x3B, 0x3A, 0x38, 0x37, 0x35, 0x34, 0x32, 0x31, 0x30, 0x2E, 0x2D, 0x2C, 0x2B,
0x2A, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x22, 0x21, 0x20, 0x1F, 0x1E, 0x1E, 0x1D, 0x1C },
{ 0x40, 0x3E, 0x3D, 0x3B, 0x3A, 0x39, 0x37, 0x36, 0x34, 0x33, 0x32, 0x30, 0x2F, 0x2E, 0x2D, 0x2B,
0x2A, 0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x22, 0x21, 0x20, 0x1F, 0x1F, 0x1E, 0x1D },
{ 0x40, 0x3F, 0x3D, 0x3C, 0x3A, 0x39, 0x37, 0x36, 0x35, 0x33, 0x32, 0x31, 0x30, 0x2E, 0x2D, 0x2C,
0x2B, 0x2A, 0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x22, 0x21, 0x20, 0x1F, 0x1F, 0x1E },
{ 0x40, 0x3F, 0x3D, 0x3C, 0x3A, 0x39, 0x38, 0x36, 0x35, 0x34, 0x32, 0x31, 0x30, 0x2F, 0x2E, 0x2D,
0x2B, 0x2A, 0x29, 0x28, 0x27, 0x26, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0x21, 0x20, 0x1F, 0x1F },
{ 0x40, 0x3F, 0x3D, 0x3C, 0x3B, 0x39, 0x38, 0x37, 0x35, 0x34, 0x33, 0x32, 0x30, 0x2F, 0x2E, 0x2D,
0x2C, 0x2B, 0x2A, 0x29, 0x28, 0x27, 0x26, 0x25, 0x25, 0x24, 0x23, 0x22, 0x21, 0x21, 0x20, 0x1F },
{ 0x40, 0x3F, 0x3D, 0x3C, 0x3B, 0x39, 0x38, 0x37, 0x35, 0x34, 0x33, 0x32, 0x31, 0x30, 0x2F, 0x2E,
0x2D, 0x2C, 0x2B, 0x2A, 0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x24, 0x23, 0x22, 0x21, 0x21, 0x20 }
};
// Mode 7 scaling constants for all raster lines
@ -331,6 +331,7 @@ static const int16 ST010_M7Scale[176] =
#endif
#define ST010_WORD(offset) (Memory.SRAM[offset + 1] << 8) | Memory.SRAM[offset]
#define ST010_DWORD(offset) (Memory.SRAM[offset + 3] << 24) | (Memory.SRAM[offset + 2] << 16) | (Memory.SRAM[offset + 1] << 8) | Memory.SRAM[offset]
static int16 ST010_Sin (int16 Theta)
@ -343,47 +344,43 @@ static int16 ST010_Cos (int16 Theta)
return (ST010_SinTable[((Theta + 0x4000) >> 8) & 0xff]);
}
static void ST010_OP01 (int16 x0, int16 y0, int16 &x1, int16 &y1, int16 &Quadrant, int16 &Theta)
{
if ((x0 < 0) && (y0 < 0))
{
void ST010_Compass(int16 x0, int16 y0, int16 &x1, int16 &y1, int16 &Quadrant, int16 &Theta)
{
if ((x0 <= 0) && (y0 < 0))
{
x1 = -x0;
y1 = -y0;
Quadrant = -0x8000;
}
else
if (x0 < 0)
else if (x0 < 0)
{
x1 = y0;
x1 = y0;
y1 = -x0;
Quadrant = -0x4000;
}
else
if (y0 < 0)
else if (y0 < 0)
{
x1 = -y0;
y1 = x0;
Quadrant = 0x4000;
y1 = x0;
Quadrant = 0x4000;
}
else
{
x1 = x0;
y1 = y0;
Quadrant = 0x0000;
x1 = x0;
y1 = y0;
Quadrant = 0x0000;
}
while ((x1 > 0x1f) || (y1 > 0x1f))
while ((x1 > 0x1f) || (y1 > 0x1f))
{
if (x1 > 1)
x1 >>= 1;
if (y1 > 1)
y1 >>= 1;
if (x1 > 1) x1 >>= 1;
if (y1 > 1) y1 >>= 1;
}
if (y1 == 0)
Quadrant += 0x4000;
Theta = ST010_ArcTan[x1 & 0x1f][y1 & 0x1f] << 8;
Theta = (Theta | Quadrant) ^ 0x8000;
Theta = (ST010_ArcTan[y1][x1] << 8) ^ Quadrant;
if ((x0 == 0) && (y0 < 0)) Quadrant = 0x4000;
}
static void ST010_Scale (int16 Multiplier, int16 X0, int16 Y0, int32 &X1, int32 &Y1)
@ -436,17 +433,108 @@ static void ST010_SortDrivers (uint16 Positions, uint16 Places[32], uint16 Drive
}
}
/*
static void SETA_Distance (int16 Y0, int16 X0, int16 &Distance)
static void ST010_Raster(int16 Theta)
{
if (X0 < 0)
X0 = -X0;
if (Y0 < 0)
Y0 = -Y0;
int16 data;
int offset = 0;
Distance = ((X0 * 0x7af0) + 0x4000) >> 15;
for (int i = 0; i < 176; i++)
{
data = ST010_M7Scale[i] * ST010_Cos(Theta) >> 15;
Memory.SRAM[0x00f0 + offset] = data;
Memory.SRAM[0x00f1 + offset] = data >> 8;
Memory.SRAM[0x0510 + offset] = data;
Memory.SRAM[0x0511 + offset] = data >> 8;
data = ST010_M7Scale[i] * ST010_Sin(Theta) >> 15;
Memory.SRAM[0x0250 + offset] = data;
Memory.SRAM[0x0251 + offset] = data >> 8;
if (data) data = ~data;
Memory.SRAM[0x03b0 + offset] = data;
Memory.SRAM[0x03b1 + offset] = data >> 8;
offset += 2;
}
}
static void ST010_Distance(int16 x0, int16 y0, int16 &Distance)
{
int32 Product;
x0 = (x0 < 0) ? -x0 : x0;
y0 = (y0 < 0) ? -y0 : y0;
if((uint16) x0 >= ((uint16) y0))
Product = ((x0 * 0x3d78 << 1) + (y0 * 0x1976 << 1)) << 1;
else
Product = ((y0 * 0x3d78 << 1) + (x0 * 0x1976 << 1)) << 1;
Distance = (Product + 0x8000) >> 16;
}
static void ST010_Navigation(int16 &MaxX, int16 &MaxY, int32 &x0, int32 &y0, int16 &Theta0, int16 &Theta1, int16 &x1, int16 &y1, uint16 &Radius, uint16 Increment, uint16 MaxRadius, int16 &Compass, int16 &Flags, int16 NewMaxX, int16 NewMaxY)
{
int16 dummy1,dummy2,dummy3;
uint16 utemp16;
int32 temp32;
x1 = MaxX - (x0 >> 16);
y1 = MaxY - (y0 >> 16);
ST010_Compass(x1, y1, dummy1, dummy2, dummy3, Theta1);
Theta1 -= Theta0;
if (Theta1 & 0xff00)
Theta0 += (Theta1 & 0x8000) ? 0xfd80 : 0x0280;
// compiler notice: -0x8000 ==> +0x8000
utemp16 = ((Theta1 < 0) ? (int16) -Theta1 : Theta1) >> 4;
if (utemp16 < 0x0100)
{
temp32 = Radius + Increment;
Radius = (temp32 >= MaxRadius) ? MaxRadius : (uint16) temp32;
}
else
{
temp32 = Radius - utemp16;
Radius = (temp32 <= 0) ? 0 : (uint16) temp32;
}
x0 -= ((ST010_Sin(Theta0) >> 5) * (Radius >> 8)) << 1;
y0 -= ((ST010_Cos(Theta0) >> 5) * (Radius >> 8)) << 1;
x0 &= 0x1fffffff;
y0 &= 0x1fffffff;
int16 MaxRadiusX, MaxRadiusY;
if (Compass & 0x8000)
{
MaxRadiusX = 0x0008;
MaxRadiusY = 0x0080;
}
else
{
MaxRadiusX = 0x0080;
MaxRadiusY = 0x0008;
}
if ((abs(x1) < MaxRadiusX) && (abs(y1) < MaxRadiusY))
{
MaxX = NewMaxX;
MaxY = NewMaxY & 0x0fff;
Compass = (NewMaxY & 0x8000) ? 0xffff : 0x0000;
Flags |= 0x0008;
}
}
*/
uint8 S9xGetST010 (uint32 Address)
{
@ -486,16 +574,32 @@ void S9xSetST010 (uint32 Address, uint8 Byte)
{
switch (ST010.op_reg)
{
// Heading
case 0x01:
{
Memory.SRAM[0x0006] = Memory.SRAM[0x0002];
Memory.SRAM[0x0007] = Memory.SRAM[0x0003];
#ifdef FAST_LSB_WORD_ACCESS
ST010_Compass(*(int16 *) &Memory.SRAM[0x0000], *(int16 *) &Memory.SRAM[0x0002], (int16 &) Memory.SRAM[0x0000], (int16 &) Memory.SRAM[0x0002], (int16 &) Memory.SRAM[0x0004], (int16 &) Memory.SRAM[0x0010]);
#else
int16 x1, y1, Quadrant, Theta;
ST010_Compass(ST010_WORD(0x0000), ST010_WORD(0x0002), x1, y1, Quadrant, Theta);
Memory.SRAM[0x0000] = (uint8) (x1);
Memory.SRAM[0x0001] = (uint8) (x1 >> 8);
Memory.SRAM[0x0002] = (uint8) (y1);
Memory.SRAM[0x0003] = (uint8) (y1 >> 8);
Memory.SRAM[0x0004] = (uint8) (Quadrant);
Memory.SRAM[0x0005] = (uint8) (Quadrant >> 8);
Memory.SRAM[0x0010] = (uint8) (Theta);
Memory.SRAM[0x0011] = (uint8) (Theta >> 8);
#endif
break;
}
// Sorts Driver Placements
//
// Input
// 0x0024-0x0025 : Positions
// 0x0040-0x007f : Places
// 0x0080-0x00ff : Drivers
// Output
// 0x0040-0x007f : Places
// 0x0080-0x00ff : Drivers
//
case 0x02:
{
#ifdef FAST_LSB_WORD_ACCESS
@ -528,15 +632,6 @@ void S9xSetST010 (uint32 Address, uint8 Byte)
}
// Two Dimensional Coordinate Scale
//
// Input
// 0x0000-0x0001 : X0 (signed)
// 0x0002-0x0003 : Y0 (signed)
// 0x0004-0x0005 : Multiplier (signed)
// Output
// 0x0010-0x0013 : X1 (signed)
// 0x0014-0x0017 : Y1 (signed)
//
case 0x03:
{
#ifdef FAST_LSB_WORD_ACCESS
@ -558,14 +653,74 @@ void S9xSetST010 (uint32 Address, uint8 Byte)
break;
}
// calculate the vector length of (x, y)
case 0x04:
{
#ifdef FAST_LSB_WORD_ACCESS
ST010_Distance(*(int16 *) &Memory.SRAM[0x0000], *(int16 *) &Memory.SRAM[0x0002], (int16 &) Memory.SRAM[0x0010]);
#else
int16 square;
ST010_Distance(ST010_WORD(0x0000), ST010_WORD(0x0002), square);
Memory.SRAM[0x10] = (uint8) (square);
Memory.SRAM[0x11] = (uint8) (square >> 8);
#endif
break;
}
// calculate AI orientation based on specific guidelines
case 0x05:
{
#ifdef FAST_LSB_WORD_ACCESS
ST010_Navigation((int16 &) Memory.SRAM[0x00c0], (int16 &) Memory.SRAM[0x00c2], (int32 &) Memory.SRAM[0x00c4], (int32 &) Memory.SRAM[0x00c8], (int16 &) Memory.SRAM[0x00cc], (int16 &) Memory.SRAM[0x00ce], (int16 &) Memory.SRAM[0x00d0], (int16 &) Memory.SRAM[0x00d2], (uint16 &) Memory.SRAM[0x00d4], *(uint16 *) &Memory.SRAM[0x00d6], *(uint16 *) &Memory.SRAM[0x00d8], (int16 &) Memory.SRAM[0x00da], (int16 &) Memory.SRAM[0x00dc], *(int16 *) &Memory.SRAM[0x00de], *(int16 *) &Memory.SRAM[0x00e0]);
#else
int32 x0,y0;
int16 MaxX,MaxY,Theta0,Theta1,x1,y1,Compass,Flags;
uint16 Radius;
MaxX = ST010_WORD(0x00c0);
MaxY = ST010_WORD(0x00c2);
x0 = ST010_DWORD(0x00c4);
y0 = ST010_DWORD(0x00c8);
Theta0 = ST010_WORD(0x00cc);
Radius = ST010_WORD(0x00d4);
Compass = ST010_WORD(0x00da);
Flags = ST010_WORD(0x00dc);
ST010_Navigation(MaxX, MaxY, x0, y0, Theta0, Theta1, x1, y1, Radius, ST010_WORD(0x00d6), ST010_WORD(0x00d8), Compass, Flags, ST010_WORD(0x00de), ST010_WORD(0x00e0));
Memory.SRAM[0x00c0] = (uint8) (MaxX);
Memory.SRAM[0x00c1] = (uint8) (MaxX >> 8);
Memory.SRAM[0x00c2] = (uint8) (MaxY);
Memory.SRAM[0x00c3] = (uint8) (MaxY >> 8);
Memory.SRAM[0x00c4] = (uint8) (x0);
Memory.SRAM[0x00c5] = (uint8) (x0 >> 8);
Memory.SRAM[0x00c6] = (uint8) (x0 >> 16);
Memory.SRAM[0x00c7] = (uint8) (x0 >> 24);
Memory.SRAM[0x00c8] = (uint8) (y0);
Memory.SRAM[0x00c9] = (uint8) (y0 >> 8);
Memory.SRAM[0x00ca] = (uint8) (y0 >> 16);
Memory.SRAM[0x00cb] = (uint8) (y0 >> 24);
Memory.SRAM[0x00cc] = (uint8) (Theta0);
Memory.SRAM[0x00cd] = (uint8) (Theta0 >> 8);
Memory.SRAM[0x00ce] = (uint8) (Theta1);
Memory.SRAM[0x00cf] = (uint8) (Theta1 >> 8);
Memory.SRAM[0x00d0] = (uint8) (x1);
Memory.SRAM[0x00d1] = (uint8) (x1 >> 8);
Memory.SRAM[0x00d2] = (uint8) (y1);
Memory.SRAM[0x00d3] = (uint8) (y1 >> 8);
Memory.SRAM[0x00d4] = (uint8) (Radius);
Memory.SRAM[0x00d5] = (uint8) (Radius >> 8);
Memory.SRAM[0x00da] = (uint8) (Compass);
Memory.SRAM[0x00db] = (uint8) (Compass >> 8);
Memory.SRAM[0x00dc] = (uint8) (Flags);
Memory.SRAM[0x00dd] = (uint8) (Flags >> 8);
#endif
break;
}
// 16-bit Multiplication
//
// Input
// 0x0000-0x0001 : Multiplcand (signed)
// 0x0002-0x0003 : Multiplier (signed)
// Output
// 0x0010-0x0013 : Product (signed)
//
case 0x06:
{
#ifdef FAST_LSB_WORD_ACCESS
@ -584,45 +739,13 @@ void S9xSetST010 (uint32 Address, uint8 Byte)
}
// Mode 7 Raster Data Calculation
//
// Input
// 0x0000-0x0001 : Angle (signed)
// Output
// 0x00f0-0x024f : Mode 7 Matrix A
// 0x0250-0x03af : Mode 7 Matrix B
// 0x03b0-0x050f : Mode 7 Matrix C
// 0x0510-0x066f : Mode 7 Matrix D
//
case 0x07:
{
int16 data;
int32 offset = 0;
int16 Theta = ST010_WORD(0x0000);
for (int32 line = 0; line < 176; line++)
{
// Calculate Mode 7 Matrix A/D data
data = ST010_M7Scale[line] * ST010_Cos(Theta) >> 15;
Memory.SRAM[0x00f0 + offset] = (uint8) (data);
Memory.SRAM[0x00f1 + offset] = (uint8) (data >> 8);
Memory.SRAM[0x0510 + offset] = (uint8) (data);
Memory.SRAM[0x0511 + offset] = (uint8) (data >> 8);
// Calculate Mode 7 Matrix B/C data
data = ST010_M7Scale[line] * ST010_Sin(Theta) >> 15;
Memory.SRAM[0x0250 + offset] = (uint8) (data);
Memory.SRAM[0x0251 + offset] = (uint8) (data >> 8);
if (data)
data = ~data;
Memory.SRAM[0x03b0 + offset] = (uint8) (data);
Memory.SRAM[0x03b1 + offset] = (uint8) (data >> 8);
offset += 2;
}
#ifdef FAST_LSB_WORD_ACCESS
ST010_Raster(*(int16 *) &Memory.SRAM[0x0000]);
#else
ST010_Raster(ST010_WORD(0x0000));
#endif
// Shift Angle for use with Lookup table
Memory.SRAM[0x00] = Memory.SRAM[0x01];
@ -632,15 +755,6 @@ void S9xSetST010 (uint32 Address, uint8 Byte)
}
// Two dimensional Coordinate Rotation
//
// Input
// 0x0000-0x0001 : X0 (signed)
// 0x0002-0x0003 : Y0 (signed)
// 0x0004-0x0005 : Angle (signed)
// Output
// 0x0010-0x0011 : X1 (signed)
// 0x0012-0x0013 : Y1 (signed)
//
case 0x08:
{
#ifdef FAST_LSB_WORD_ACCESS
@ -658,212 +772,6 @@ void S9xSetST010 (uint32 Address, uint8 Byte)
break;
}
// Input
// 0x0000-0x0001 : DX (signed)
// 0x0002-0x0003 : DY (signed)
// Output
// 0x0010-0x0011 : Angle (signed)
//
case 0x01:
{
Memory.SRAM[0x0006] = Memory.SRAM[0x0002];
Memory.SRAM[0x0007] = Memory.SRAM[0x0003];
#ifdef FAST_LSB_WORD_ACCESS
ST010_OP01(*(int16 *) &Memory.SRAM[0x0000], *(int16 *) &Memory.SRAM[0x0002], (int16 &) Memory.SRAM[0x0000], (int16 &) Memory.SRAM[0x0002], (int16 &) Memory.SRAM[0x0004], (int16 &) Memory.SRAM[0x0010]);
#else
int16 x1, y1, Quadrant, Theta;
ST010_OP01(ST010_WORD(0x0000), ST010_WORD(0x0002), x1, y1, Quadrant, Theta);
Memory.SRAM[0x0000] = (uint8) (x1);
Memory.SRAM[0x0001] = (uint8) (x1 >> 8);
Memory.SRAM[0x0002] = (uint8) (y1);
Memory.SRAM[0x0003] = (uint8) (y1 >> 8);
Memory.SRAM[0x0004] = (uint8) (Quadrant);
Memory.SRAM[0x0005] = (uint8) (Quadrant >> 8);
Memory.SRAM[0x0010] = (uint8) (Theta);
Memory.SRAM[0x0011] = (uint8) (Theta >> 8);
#endif
break;
}
// calculate the vector length of (x, y)
case 0x04:
{
int16 square, x, y;
#ifdef FAST_LSB_WORD_ACCESS
x = *((int16 *) Memory.SRAM);
y = *((int16 *) &Memory.SRAM[2]);
#else
x = Memory.SRAM[0] | (Memory.SRAM[1] << 8);
y = Memory.SRAM[2] | (Memory.SRAM[3] << 8);
#endif
square = (int16) sqrt((double) (y * y + x * x));
//SETA_Distance(x, y, square);
#ifdef FAST_LSB_WORD_ACCESS
*((int16 *) &Memory.SRAM[0x10]) = square;
#else
Memory.SRAM[0x10] = (uint8) (square);
Memory.SRAM[0x11] = (uint8) (square >> 8);
#endif
break;
}
// calculate AI orientation based on specific guidelines
case 0x05:
{
int32 dx, dy;
int16 a1, b1, c1;
uint16 o1;
bool wrap = false;
// target (x, y) coordinates
int16 ypos_max = ST010_WORD(0x00C0);
int16 xpos_max = ST010_WORD(0x00C2);
// current coordinates and direction
int32 ypos = Memory.SRAM[0xC4] | (Memory.SRAM[0xC5] << 8) | (Memory.SRAM[0xC6] << 16) | (Memory.SRAM[0xC7] << 24);
int32 xpos = Memory.SRAM[0xC8] | (Memory.SRAM[0xC9] << 8) | (Memory.SRAM[0xCA] << 16) | (Memory.SRAM[0xCB] << 24);
uint16 rot = Memory.SRAM[0xCC] | (Memory.SRAM[0xCD] << 8);
// physics
uint16 speed = ST010_WORD(0x00D4);
uint16 accel = ST010_WORD(0x00D6);
uint16 speed_max = ST010_WORD(0x00D8);
// special condition acknowledgment
int16 system = ST010_WORD(0x00DA);
int16 flags = ST010_WORD(0x00DC);
// new target coordinates
int16 ypos_new = ST010_WORD(0x00DE);
int16 xpos_new = ST010_WORD(0x00E0);
// mask upper bit
xpos_new &= 0x7FFF;
// get the current distance
dx = xpos_max - (xpos >> 16);
dy = ypos_max - (ypos >> 16);
// quirk: clear and move in9
Memory.SRAM[0xD2] = 0xFF;
Memory.SRAM[0xD3] = 0xFF;
Memory.SRAM[0xDA] = 0;
Memory.SRAM[0xDB] = 0;
// grab the target angle
ST010_OP01(dy, dx, a1, b1, c1, (int16 &) o1);
// check for wrapping
//if ((o1 < 0x6000 && rot > 0xA000) || (rot < 0x6000 && o1 > 0xA000))
//if (o1 < rot)
if (abs(o1 - rot) > 0x8000)
{
o1 += 0x8000;
rot += 0x8000;
wrap = true;
}
//o1 = 0x0000;
//rot = 0xFF00;
uint16 old_speed;
old_speed = speed;
// special case
if (abs(o1 - rot) == 0x8000)
speed = 0x100;
// slow down for sharp curves
else
if (abs(o1 - rot) >= 0x1000)
{
uint32 slow = abs(o1 - rot);
slow >>= 4; // scaling
speed -= slow;
}
// otherwise accelerate
else
{
speed += accel;
if (speed > speed_max)
{
// clip speed
speed = speed_max;
}
}
// prevent negative/positive overflow
if (abs(old_speed - speed) > 0x8000)
{
if (old_speed < speed)
speed = 0;
else
speed = 0xff00;
}
// adjust direction by so many degrees
// be careful of negative adjustments
if ((o1 > rot && (o1 - rot) > 0x80) || (o1 < rot && (rot - o1) >= 0x80))
{
if (o1 < rot)
rot -= 0x280;
else
if (o1 > rot)
rot += 0x280;
}
// turn off wrapping
if (wrap)
rot -= 0x8000;
// now check the distances (store for later)
dx = (xpos_max << 16) - xpos;
dy = (ypos_max << 16) - ypos;
dx >>= 16;
dy >>= 16;
// if we're in so many units of the target, signal it
if ((system && (dy <= 6 && dy >= -8) && (dx <= 126 && dx >= -128)) || (!system && (dx <= 6 && dx >= -8) && (dy <= 126 && dy >= -128)))
{
// announce our new destination and flag it
xpos_max = xpos_new & 0x7FFF;
ypos_max = ypos_new;
flags |= 0x08;
}
// update position
xpos -= (ST010_Cos(rot) * 0x400 >> 15) * (speed >> 8) << 1;
ypos -= (ST010_Sin(rot) * 0x400 >> 15) * (speed >> 8) << 1;
// quirk: mask upper byte
xpos &= 0x1FFFFFFF;
ypos &= 0x1FFFFFFF;
Memory.SRAM[0x00C0] = (uint8) (ypos_max);
Memory.SRAM[0x00C1] = (uint8) (ypos_max >> 8);
Memory.SRAM[0x00C2] = (uint8) (xpos_max);
Memory.SRAM[0x00C3] = (uint8) (xpos_max >> 8);
Memory.SRAM[0x00C4] = (uint8) (ypos);
Memory.SRAM[0x00C5] = (uint8) (ypos >> 8);
Memory.SRAM[0x00C6] = (uint8) (ypos >> 16);
Memory.SRAM[0x00C7] = (uint8) (ypos >> 24);
Memory.SRAM[0x00C8] = (uint8) (xpos);
Memory.SRAM[0x00C9] = (uint8) (xpos >> 8);
Memory.SRAM[0x00CA] = (uint8) (xpos >> 16);
Memory.SRAM[0x00CB] = (uint8) (xpos >> 24);
Memory.SRAM[0x00CC] = (uint8) (rot);
Memory.SRAM[0x00CD] = (uint8) (rot >> 8);
Memory.SRAM[0x00D4] = (uint8) (speed);
Memory.SRAM[0x00D5] = (uint8) (speed >> 8);
Memory.SRAM[0x00DC] = (uint8) (flags);
Memory.SRAM[0x00DD] = (uint8) (flags >> 8);
break;
}
default:
#ifdef DEBUGGER
printf("Unknown Op\n");