Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string.h>
- #include <stdio.h>
- #include <stdlib.h>
- char *namepart[] = {
- "en" , "la" , "can", "be" ,
- "and", "phi", "eth", "ol" ,
- "ve" , "ho" , "a" , "lia",
- "an" , "ar" , "ur" , "mi" ,
- "in" , "ti" , "qu" , "so" ,
- "ed" , "ess", "ex" , "io" ,
- "ce" , "ze" , "fa" , "ay" ,
- "wa" , "da" , "ack", "gre"
- };
- int SystemParam_0;
- int SystemParam_1;
- unsigned char TheMilkyWay[129];
- unsigned int SystemDensity[] = {
- 0xBF78, 0x5B2F, 0xDF85, 0x3C14, 0xDADD, 0x38DF, 0xE08F, 0x88D7,
- 0xB3AB, 0xEA86, 0x1200, 0x8DB3, 0xFF0D, 0xA593, 0xEC66, 0x1988,
- 0x8500, 0xC1E7, 0x9281, 0xD7EB, 0x5F77, 0xD6A5, 0x310B, 0x2C98,
- 0x906E, 0x2CB6, 0xF137, 0x8ADC, 0x0FC7, 0x76B8, 0xB587, 0x2D1B,
- 0xAD4C, 0x1AEB, 0xB749, 0xC60D, 0xB914, 0x1B3A, 0xAA5E, 0x3764,
- 0xD7A0, 0x650E, 0xDB8D, 0x3E98, 0x1DDD, 0xD3BB, 0x54A4, 0x66BA,
- 0x164F, 0xF3B8, 0x7460, 0xBF9A, 0x7AA7, 0x459C, 0x61EC, 0xF706,
- 0x958C, 0x8B54, 0x86E8, 0xC653, 0x5D7C, 0x6AC9, 0xAD35, 0x8B1F,
- 0x30C6, 0x7EF7, 0x4E4F, 0xD1F3, 0xD042, 0x4AAC, 0x6F5A, 0x15C4,
- 0x4DC3, 0x923C, 0x04E2, 0x2C8B, 0xAB14, 0x9689, 0x5553, 0x92F7,
- 0x3BC6, 0x7C86, 0x5E8D, 0xFF7F, 0x8F5C, 0x0450, 0x0BD3, 0xB01F,
- 0x2744, 0xDF20, 0xE40E, 0x932C, 0x8B90, 0xCF40, 0x6E2B, 0x81BE,
- 0x200B, 0xA64F, 0x2BA4, 0xDCB8, 0xEA35, 0xACC4, 0x1421, 0x9025,
- 0x9A98, 0x4993, 0x99EF, 0xB4FD, 0x0BCF, 0x7434, 0x7287, 0xC67F,
- 0x1967, 0xF486, 0x12AD, 0xDF33, 0xDF74, 0x2913, 0x2FF4, 0xD76B,
- 0x5A2A, 0x8B80, 0xCB01, 0x742B, 0x09B4, 0xC203, 0x56AF, 0xDAD6,
- 0x8000, 0x5555, 0x4000, 0x3333, 0x2AAA, 0x2492, 0x1FF0, 0x1C71,
- 0x1999, 0x1745, 0x1555, 0x13B1, 0x1249, 0x1111, 0x0FF0, 0x0F0F
- };
- unsigned int KnownSpaceCoord[49][2] = {
- 5912,5412, 5913,5412, 5913,5413, 5912,5413, 5911,5413, 5911,5412, 5911,5411,
- 5912,5411, 5913,5411, 5914,5411, 5914,5412, 5914,5413, 5913,5414, 5912,5414,
- 5911,5414, 5910,5413, 5910,5412, 5910,5411, 5911,5410, 5912,5410, 5913,5410,
- 5909,5414, 5917,5414, 5917,5411, 5913,5408, 5916,5416, 5918,5416, 5918,5406,
- 5908,5395, 5906,5372, 5873,5378, 5971,5426, 6004,5418, 5944,5444, 5912,5488,
- 5766,5497, 5908,5422, 5912,5417, 5912,5416, 5913,5418, 5914,5417, 5915,5417,
- 5909,5419, 5909,5406, 5910,5406, 5909,5407, 5908,5407, 5908,5406, 5910,5416 };
- char *KnownSpace[117] = {
- "Sol", // Start of sector (0,0)
- "Alpha Centauri",
- "Wolf 359",
- "Lalande 21185 ",
- "UV Ceti",
- "Ross 128",
- "Tau Ceti",
- "LET 118",
- "Wolf 424",
- "CD-37º15492",
- "Lalande 25372",
- "Sirius", // sector (1,0)
- "Epsilon Eridani",
- "Procyon",
- "BD+5º1668",
- "BD+20º2465",
- "Groombridge 1618", // 1,1
- "Luyten 1159-16",
- "WX Ursa Majoris",
- "+53º1320",
- "Ross 248", // 0,1
- "Groombridge 34",
- "van Maanens Star",
- "Giclas 158-27",
- "61 Cygni", // -1,1
- "Struve 2398",
- "1º4774",
- "Barnards Star", // -1,0
- "Ross 154",
- "Luyten 789-6",
- "Lacaille 9352",
- "Lacaille 8760",
- "Ross 780",
- "Fomalhaut",
- "Epsilon Indi", // -1,-1
- "BD 4523",
- "CD-46º11540",
- "CD-49º13515",
- "CD-44º11909",
- "-11º3759",
- "Kapteyns Star", // 1,-1
- "82 Eridani",
- "Luyten 674-15", // 2,-1
- "Ross 614", // 2,0
- "Omicron Eridani",
- "YZ Canis Minoris",
- "-21º1377",
- "HD 36395",
- "LP 658-2",
- "Ross 986", // 2,1
- "Ross 47",
- "Wolf 294",
- "Stein 2051", // 1,2
- "AC+79º3888", // 0,2
- "Eta Cassiopeia",
- "Krüger 60", // -1,2
- "BD 946",
- "BD+43º4305",
- "Sigma Draconis",
- "+19º5116",
- "Altair", // -2,1
- "FU 46",
- "70 Ophiuchi", // -2,0
- "VB 10",
- "Arcturus",
- "36 Ophiuchi", // -2,1
- "HR 7703",
- "Luyten 347-14",
- "Wolf 630",
- "Delta Pavonis", // -1,-2
- "Luyten 205-128",
- "-40º9712",
- "-45º13677",
- "Luyten 145-41", // 0,-2
- "Beta Hydri",
- "Luyten 97-12", // 1,-2
- "Vega", // -3,2
- "Castor", // 5,2
- "Pollux",
- "Regulus", // 5,-1
- "Achenar", // 1,-4
- "Capella", // 4,4
- "Aldebaran", // 6,4
- "Canopus", // 6,-6
- "Spica", // -4,-17
- "Hadar", // -6,-40
- "Antares", // -39,-34
- "Betelgeuse", // 59,14
- "Rigel", // 92,6
- "Alcyone", // 32,32; the Pleiades
- "Atlas",
- "Electra",
- "Maia",
- "Merope",
- "Taygete",
- "Pleione",
- "Polaris", // 0,76
- "Beta Lyrae", // -146,85
- "Alkaid", // -4,10
- "Mizar", // 0,5
- "Alcor",
- "Alioth", // 0,4
- "Megrez", // 1,6
- "Phekda", // 2,5
- "Merak", // 3,5
- "Dubhe", // -3,7
- "Lave", // -3,-6; some original Elite systems
- "Diso",
- "Riedquat",
- "Leesti",
- "Orerve",
- "Zaonce", // -2,-6
- "Tionisla",
- "Reorte", // -3,-5
- "Uszaa",
- "Orrere",
- "Quator"
- };
- int counter=0;
- int generate_sector (unsigned int coordx, unsigned int coordy, int galaxyScale)
- {
- unsigned long p1,p2,p3,p4;
- unsigned long eax,ebx,ecx,edx,esi,edi;
- int pixelval;
- if (coordx > 0x1fff || coordy > 0x1fff) return 0;
- pixelval = (coordx/64)+2*(coordy & 0x1fc0);
- printf("%i %d\n", counter++, pixelval );
- return 0;
- p1 = TheMilkyWay[pixelval]; // Current center
- p3 = TheMilkyWay[pixelval+128]; // Next row
- p4 = TheMilkyWay[pixelval+129]; // Next row, next column
- p2 = TheMilkyWay[pixelval+1]; // Next column
- coordx = (coordx * 0x200) & 0x7e00;
- coordy = (coordy * 0x200) & 0x7e00;
- ebx = (p2-p1)*coordx + (p3-p1)*coordy; // -0x0FB0400...0x0FB0400
- esi = (coordx*coordy)>>15; // 0..0x7C08
- edi = p4 - p3 - p2 + p1;
- esi *= edi;
- ebx += esi;
- ebx += ebx;
- p1 <<= 16; // p1 is now VVVV.VVVV.0000.0000
- ebx += p1;
- ecx = ebx >> 8;
- if (galaxyScale < 16)
- {
- ebx = coordx + ecx;
- eax =coordx * coordy;
- // (signed long)eax >>= 15;
- eax >>= 15;
- ebx ^= eax;
- // (signed long)ebx >>= 5;
- ebx >>= 5;
- // printf("%d",ebx);
- ebx &= 0x7f;
- eax = SystemDensity[ebx];
- if (galaxyScale)
- {
- edx = 16-galaxyScale;
- edx *= eax;
- // (signed long)edx >>= 5;
- edx >>= 5;
- eax = 0xffff-edx;
- ecx *= eax;
- ecx >>= 16;
- } else
- {
- ecx *= eax;
- ecx >>= 16;
- }
- }
- p1 = ecx;
- p1 >>= 10;
- return (int)p1;
- }
- void rotate_some (void)
- {
- unsigned long Tmp1,Tmp2;
- Tmp1 = (SystemParam_0 << 3) | (SystemParam_0 >> 29);
- Tmp2 = SystemParam_0 + SystemParam_1;
- Tmp1 += Tmp2;
- SystemParam_0 = Tmp1;
- SystemParam_1 = (Tmp2 << 5) | (Tmp2 >> 27);
- }
- int StarChance_Type[] = {
- 0, 0, 0, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 2, 2, 2, 2, 2, 3, 3, 3,
- 3, 4, 4, 4, 5, 6, 7, 8
- };
- char *StarDesc[]={
- "Type'M'flare star", // 0
- "Faint type'M'red star", // 1
- "Type'M'red star", // 2
- "Type'K'orange star", // 3
- "Type'G'yellow star", // 4
- "Type'F'white star", // 5
- "Type'A'hot white star", // 6
- "White dwarf star", // 7
- "Red giant star" // 8
- "Bright giant star", // 9
- "Type'B'hot blue star", // 10
- "Supergiant star", // 11
- "Blue supergiant star", // 12
- "Contact binary star" // 13
- };
- int StarChance_Multiples[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 1, 1, 1, 1, 1,
- 1, 1, 2, 2, 2, 3, 4, 5
- };
- typedef struct {
- signed char x,y,z;
- unsigned char stardesc,multiple;
- } coords_t;
- coords_t coords[64];
- // 64? ah well let's make it a (binary) round number anyway. Though YOU can make it 62 if you like.
- void Shuffle_Coordinates (unsigned int coordx, unsigned int coordy, int number_of_systems)
- {
- int i;
- SystemParam_0 = (coordx<<16)+coordy;
- SystemParam_1 = (coordy<<16)+coordx;
- rotate_some();
- rotate_some();
- rotate_some();
- for (i=0; i<number_of_systems; i++)
- {
- rotate_some();
- coords[i].z = (SystemParam_0 & 0xFF0000)>>16;
- coords[i].y = (SystemParam_0 >> 8);
- coords[i].y /= 2;
- coords[i].x = (SystemParam_0 & 0x0001FE)>> 1;
- coords[i].x /= 2;
- coords[i].multiple = StarChance_Multiples[SystemParam_1 & 0x1f];
- coords[i].stardesc = StarChance_Type[(SystemParam_1 >> 16) & 0x1f];
- }
- }
- int SizeForStar[] = {
- 300, 300, 350, 400,
- 450, 500, 500, 200,
- 700, 900, 800, 1100,
- 1400, 600
- };
- #define RGB(r, g, b) (r<<16)|(g<<8)|b
- int ColorForStar[] = {
- RGB(200, 0, 0), // Type'M'flare star
- RGB(200, 0, 0), // Faint type'M'red star
- RGB(200, 0, 0), // Type'M'red star
- RGB(200,136, 0), // Type'K'orange star
- RGB(200,200, 0), // Type'G'yellow star
- RGB(200,200,200), // Type'F'white star
- RGB(200,200,200), // Type'A'hot white star
- RGB(200,200,200), // White dwarf star
- RGB(200, 0, 0), // Red giant star
- RGB(200,200,200), // Bright giant star
- RGB(168,200,232), // Type'B'hot blue star
- RGB(192,136, 0), // Supergiant star
- RGB(168,200,232), // Blue supergiant star
- RGB(200,200, 0), // Contact binary star
- };
- void GetSystemName(unsigned int coordx,unsigned int coordy, int Sysnum, char *dest)
- {
- coordx += Sysnum;
- coordy += coordx;
- coordx = _rotl (coordx, 3);
- coordx += coordy;
- coordy = _rotl (coordy, 5);
- coordy += coordx;
- coordy = _rotl (coordy, 4);
- coordx = _rotl (coordx, Sysnum);
- coordx += coordy;
- strcpy (dest, namepart[(coordx>>2) & 31]);
- coordx = _rotr (coordx, 5);
- strcat (dest, namepart[(coordx>>2) & 31]);
- coordx = _rotr (coordx, 5);
- strcat (dest, namepart[(coordx>>2) & 31]);
- dest[0] ^= 0x20;
- }
- int main()
- {
- char name[10];
- memset(TheMilkyWay,0, sizeof(TheMilkyWay));
- for (int i=0; i<49; i++)
- {
- GetSystemName(KnownSpaceCoord[i][0], KnownSpaceCoord[i][1], rand(), name);
- printf("%d %s\n",i, name);
- // generate_sector(KnownSpaceCoord[i][0], KnownSpaceCoord[i][1], 1);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement