Ejemplo n.º 1
0
int main(int argc, char *argv[])
{
	if (argc != 2)
	{
		std::cout << "Error! Usage dictionary.exe <dictionary.txt>.\n";
		return EXIT_FAILURE;
	}
	std::string nameDictionary = argv[1];
	ProcessMap(nameDictionary);
    return EXIT_SUCCESS;
}
Ejemplo n.º 2
0
int main(int argc, char *argv[])
{
  FILE *map, *bin;
  int argp = 1;

  if (argc != 4 && argc != 5) {
    fprintf(stderr, "%s: [PROGLOAD address] <binary> <map> <output>\n", argv[0]);
    exit(1);
  }

  if (argc == 5 && sscanf(argv[argp++], "%x", &progload) != 1)
  {
    fprintf(stderr, "%s: PROGLOAD parse error: %s\n", argv[0], argv[argp - 1]);
    exit(1);
  }

  bin = fopen(argv[argp++], "r");
  if (bin == NULL) {
    perror(argv[argp - 1]);
    exit(1);
  }
  if (fread(buf, 1, 65536, bin) == 0) {
    fprintf(stderr, "%s: read error on %s\n", argv[0], argv[argp - 1]);
    exit(1);
  }
  fclose(bin);
  map = fopen(argv[argp++], "r");
  if (map == NULL) {
    perror(argv[argp - 1]);
    exit(1);
  }
  ProcessMap(map);
  fclose(map);
  
  bin = fopen(argv[argp++], "w");
  if (bin == NULL) {
    perror(argv[argp - 1]);
    exit(1);
  }
  memcpy(buf + s__INITIALIZED, buf + s__INITIALIZER, l__INITIALIZER);
  /* Write out everything that is data, omit everything that will 
     be zapped */
  if (fwrite(buf + progload, s__DATA - progload, 1, bin) != 1) {
   perror(argv[argp - 1]);
   exit(1);
  }
  fclose(bin);
  exit(0);
}
Ejemplo n.º 3
0
void MapReduceTask::createWorkers() {

    roster = new Worker*[numWorkers];
    for(int i = 0; i < numWorkers; ++i) {
        if(threads) {
            *(roster[i]) = ThreadMap(splitInput[i],this);
        } else {
            *(roster[i]) = ProcessMap(splitInput[i], this);
        }
    }

    for(int i = 0; i < numWorkers; ++i) {
        roster[i] -> run();
    }
}
Ejemplo n.º 4
0
bool cN2Prov0501::RomCallbacks(void)
{
  unsigned int ea=GetPc();
  if(ea&0x8000) ea|=(cr<<16);
  switch(ea) {
    case 0x3840: //MAP Handler
      if(!ProcessMap(a)) return false;
      break;
    default:
      PRINTF(L_SYS_EMU,"%04X: unknown ROM breakpoint %04x",id,ea);
      return false;
    }
  if(ea>=0x8000) PopCr();
  PopPc();
  return true;
}
Ejemplo n.º 5
0
main() {
	LoadMap() ;
	ProcessMap() ;
	WriteMap() ;
}
Ejemplo n.º 6
0
void BemGame::DrawFrame()
{
	AddText( engine );
	int i;

	// The whole demo works because it takes exactly 12 ticks for a 
	// Drone or Brain to walk one tile. So every 12 subticks
	// we calculate a new direction for the actor.
	subtick++;
	tick++;
	teleFrame++;

	if ( subtick == SUBTICK )
	{
		subtick = 0;
		for ( i=0; i<numActors; i++ )
		{
			ProcessMap( &actor[i] );
		}
	}

	// calculate the tinting, from map 4.5,4.5
 	float rad = float( tick ) / 45.0;
 	float fred   = fabs( sin( rad*1.5 ) ) * 0.5;
 	float fgreen = fabs( sin( rad*2.5 ) ) * 0.5;
 	float fblue  = fabs( sin( rad*3.5 ) ) * 0.5;
 	float falpha = fabs( sin( rad ) ) * 0.3;
	
	KrColorTransform gizmoColor;
	gizmoColor.TintRed(   U8( fred * 255.0 ));
	gizmoColor.TintGreen( U8( fgreen * 255.0 ));
	gizmoColor.TintBlue(  U8( fblue * 255.0 ));
	gizmoColor.TintAlpha( U8( falpha * 255.0 ));
	gizmo->SetColor( gizmoColor );

	// update all the actors.
	for( i=0; i<numActors; i++ )
	{
		KrColorTransform actorColor;
		float d = DistanceFromCenter( &actor[i] );
		if ( d < 3.0 )
		{
			float fraction = 1.0 - d / 3.0;
			actorColor.TintRed(   U8( fred * 255.0 * fraction ));
			actorColor.TintGreen( U8( fgreen * 255.0 * fraction ));
			actorColor.TintBlue(  U8( fblue * 255.0 * fraction ));
			actorColor.TintAlpha( U8( falpha * 255.0 * fraction ));
		}
		actor[i].sprite->SetColor( actorColor );

		actor[i].sprite->DoStep();

		// In order to sort with the particles, sort with
		// the world Y.
		GlFixed wx, wy, wz, tx, ty;

		isoMath->ScreenToFlatTile(	actor[i].sprite->X(), 
									actor[i].sprite->Y(),
									0, &tx, &ty );
		isoMath->TileToWorld( tx, ty, 0, &wx, &wy, &wz );
		actor[i].sprite->SetZDepth( -wy.v );
	}

	// The teleport in and out special effect. Done "by hand"
	// counting frames with a switch. Looks cool and tests
	// the visibility stuff.
	if ( teleFrame > 9 && numActors > 0 )
	{
		KrColorTransform cform;

		switch ( teleFrame )
		{
			case 10:
				teleSprite = actor[ random.Rand( numActors ) ].sprite;
				cform.Brighten( 128 );
				break;

			case 11:
				cform.Brighten( 200 );
				cform.SetAlpha( 220 );
				break;

			case 12:
			case 13:
				cform.Brighten( 255 );
				cform.SetAlpha( 200 );
				break;

			case 14:
				{
					GlFixed x, y;
					isoMath->ScreenToFlatTile(	teleSprite->X(),
												teleSprite->Y(),
												0, &x, &y );
					AddParticles( x, y );
					teleSprite->SetVisible( false );
				}
				break;

			case 35:
			case 36:
			case 37:
			case 38:
			case 39:
			case 40:
				teleSprite->SetVisible( true );
				cform.TintBlue( 240 - 30 * ( teleFrame - 35 ) );
				cform.SetAlpha( 100 + 20 * ( teleFrame - 35 ) );
				break;
				
			case 41:
				teleFrame = 0;
				break;

			default:
				break;
		}
		teleSprite->SetColor( cform );
	}

	MoveParticles();

	// Since the map coordinates only change if the subtick rolled
	// over, we only change the mini map every 12 frames.
	if ( subtick == 0 )
		DrawMiniMap();

	if ( UseWindows() )
		ProcessRightWindow();

	engine->Draw();
}
Ejemplo n.º 7
0
int main(int argc, char *argv[])
{
	FILE *map, *bin;
	int tail = 0;
	int start;
	unsigned int end;
	int reloc = 0;
	int pack_discard = 0;
	int base;

	if (argc != 4) {
		fprintf(stderr, "%s: [binary] [map] [output]\n", argv[0]);
		exit(1);
	}
	bin = fopen(argv[1], "r");
	if (bin == NULL) {
		perror(argv[1]);
		exit(1);
	}
	if (fread(buf, 1, 65536, bin) == 0) {
		fprintf(stderr, "%s: read error on %s\n", argv[0],
			argv[1]);
		exit(1);
	}
	fclose(bin);

        /* Start with the output matching the input */
	memcpy(out, buf, 65536);

	map = fopen(argv[2], "r");
	if (map == NULL) {
		perror(argv[2]);
		exit(1);
	}
	ProcessMap(map);
	fclose(map);

	if (s__COMMONMEM > 0xFFFF || s__COMMONMEM + l__COMMONMEM > 0x10000) {
		fprintf(stderr, "Move common down by at least %d bytes\n",
			s__COMMONMEM + l__COMMONMEM - 0x10000);
		exit(1);
	}

	/* linker will allow us to overlap _DISCARD (which may grow)
	   with _COMMONMEM. */
	if(s__DISCARD && s__DISCARD+l__DISCARD > s__COMMONMEM){
		fprintf(stderr, "Move _DISCARD down by at least %d bytes\n",
			s__DISCARD + l__DISCARD - s__COMMONMEM);
		exit(1);
	}

        printf("Scanning data from 0x%x to 0x%x\n",
                s__DATA, s__DATA + l__DATA);
	base = s__DATA;
	while (base < s__DATA + l__DATA) {
	        if (buf[base] && buf[base] != 0xFF) {
	                fprintf(stderr, "0x%04x:0x%02x\n",
	                        base, (unsigned char)buf[base]);
                }
                base++;
        }

	/* Our standard layout begins with the code */
	start = s__CODE;

	/* TODO: Support a proper discardable high discard in other mappings */

	/* In an environment with a single process mapped we put the discard
	   area into process space, so it will be below the kernel in most
	   cases. In that case we start on the DISCARD segment if need be */
	/* Low discard (pure swap model) */
	if (s__DISCARD && s__DISCARD < start) {
		start = s__DISCARD;
		if (s__DISCARD + l__DISCARD > s__CODE) {
			fprintf(stderr,
				"Move discard down by at least %d bytes\n",
				s__DISCARD + l__DISCARD - s__CODE);
			exit(1);
		}
		printf("Discard at %04x (%d bytes), space %d\n",
		       s__DISCARD, l__DISCARD,
		       s__CODE - s__DISCARD - l__DISCARD);
	} else if (s__DISCARD && s__DISCARD < s__COMMONMEM) {
		/* Discard may also be set up high below the common */
	        pack_discard = 1;
        }

	end = s__INITIALIZER;
	if (end < start) {
		/* We are dealing with an unpacked binary where the end
		   will instead be _HEAP */
		end = s__HEAP;
	}

	if (s__CODE2 < 0x10000) {
		/* Move the initialized data into the right spot rather than sdcc's
		   assumption of being ROM code */
		memcpy(out + s__INITIALIZED, buf + s__INITIALIZER,
		       l__INITIALIZED);
		if (l__GSFINAL || l__GSINIT)
			fprintf(stderr, "Warning %s contains gs code.\n",
				argv[1]);
		/* Pack any common memory on the end of the main code/memory if its
		   relocated */
		if (!s__DISCARD || pack_discard) {
		        base = s__DATA;
			tail = l__COMMONMEM;
			memcpy(out + base, buf + s__COMMONMEM,
			       l__COMMONMEM);
			base += l__COMMONMEM;
			/* If we have the font packed high then add it to the image */
			if (l__FONT && s__FONT > s__INITIALIZER) {
				memcpy(out + base, buf + s__FONT, l__FONT);
				tail += l__FONT;
				base += l__FONT;
			}
			end = s__COMMONMEM + l__COMMONMEM + l__FONT;
			if (pack_discard) {
			        memcpy(out + base, buf + s__DISCARD, l__DISCARD);
			        base += l__DISCARD;
			        tail += l__DISCARD;
			        end += l__DISCARD;
                        }
			reloc = 1;
		}

		printf("Code at 0x%04x (%d bytes)\n", s__CODE, l__CODE);
		printf("Code2 at 0x%04x (%d bytes)\n", s__CODE2, l__CODE2);
		printf("Const at 0x%04x (%d bytes)\n", s__CONST, l__CONST);
		printf("Data at 0x%04x (%d bytes)\n", s__DATA,
		       l__DATA + l__INITIALIZED);
		printf("Common at 0x%04x (%d bytes)\n", s__COMMONMEM,
		       l__COMMONMEM);
		if (l__FONT)
			printf("Font at 0x%04x (%d bytes)\n", s__FONT,
			       l__FONT);
		if (l__VIDEO)
			printf("Video at 0x%04x (%d bytes)\n", s__VIDEO,
			       l__VIDEO);
		printf("Discard at 0x%04x (%d bytes)\n", s__DISCARD,
		       l__DISCARD);
		if (s__DATA + l__DATA > s__COMMONMEM &&
		        s__DATA < s__COMMONMEM) {
		        fprintf(stderr, "Data overlaps common by %d bytes.\n",
		                s__DATA + l__DATA - s__COMMONMEM);
                        exit(1);
                }
		if (s__CONST + l__CONST > s__DATA &&
		        s__CONST < s__DATA) {
		        fprintf(stderr, "Const overlaps data by %d bytes.\n",
		                s__CONST + l__CONST - s__DATA);
                        exit(1);
                }
		/* For a complex image we have the initialized data last */
		if (end < s__INITIALIZED +  l__INITIALIZED)
		        end = s__INITIALIZED + l__INITIALIZED;
                /* Common may follow but only if we didn't relocate it */
		if (reloc == 0 && end < s__COMMONMEM +  l__COMMONMEM)
		        end = s__COMMONMEM + l__COMMONMEM;

                /* Packed image with common over data */
		if (!s__DISCARD || pack_discard) {
			end = base;
			printf("\nPacked image %d bytes, for RAM target\n",
			       end);
		}
		else
		        printf("End at 0x%04x\n", end);
	} else {
		printf("ROM target: leaving\n");
		exit(0);
	}
	bin = fopen(argv[3], "w");
	if (bin == NULL) {
		perror(argv[3]);
		exit(1);
	}
	printf("Image file: %04X to %04X\n", start, end);
	if (fwrite(out + start, end - start + 1, 1, bin) !=
	    1) {
		perror(argv[3]);
		exit(1);
	}
	fclose(bin);
	exit(0);
}