/***************************************************************************

  Crazy Climber arcade machine emulator

  Usage:

  cclimber [name of the game to run] [options]

  options:
  -vesa   use standard 640x480x256 VESA mode instead of custom video mode
  -nosound  turn off sound

  Information about the machine hardware (including palette) and ROM
  encryption scheme provided by Lionel Theunissen (lionelth@ozemail.com.au).
  Thank you Lionel! This wouldn't have been possible without you!
  Z80 engine by Marat Fayzulin and Marcel de Kogel
  Emulator written by Nicola Salmoria (MC6489@mclink.it)
  Sound Implementation by Nicola Salmoria and Lionel Theunissen.
  Thanks to Andy Milne (andy@canetics.com) for the information on the sound
  roms.
  AY-3-8910 emulation by Ville Hallik (ville@physic.ut.ee) and Michael Cuddy
  (mcuddy@FensEnde.com).
  Video mode created using Tweak 1.6b by Robert Schmidt, who also wrote
  TwkUser.c.
  256x256 video mode (Mode Q) definition by Gary Shepherdson
  (od67@dial.pipex.com)


  If you find out something useful, don't hesitate to submit it to :
  The arcade emultion programming repository.

  So it will be available to everyone at :
  http://valhalla.ph.tn.tudelft.nl/emul8

  Send it by email to :
  avdbas@wi.leidenuniv.nl


  Known issues:
  - The sound emulation is limited to digital sound, and is wrong in places,
    but it's a start.

  - I'm open to suggestions for a better way to map the 2 joysticks of the
    real game to the keyboard.

***************************************************************************/

#include <stdio.h>
#include <string.h>
#include "machine.h"
#include "osdepend.h"

#define DEFAULT_NAME "ckong"


int main(int argc,char **argv)
{
	if (init_machine(argc > 1 && argv[1][0] != '-' ? argv[1] : DEFAULT_NAME) == 0)
	{
		printf("\nPLEASE DO NOT DISTRIBUTE THE SOURCE FILES OR THE EXECUTABLE WITH ROM IMAGES.\n"
			   "DOING SO WILL HARM FURTHER EMULATOR DEVELOPMENT AND WILL CONSIDERABLY ANNOY\n"
			   "THE RIGHTFUL COPYRIGHT HOLDERS OF THOSE ROM IMAGES AND CAN RESULT IN LEGAL\n"
			   "ACTION UNDERTAKEN BY EARLIER MENTIONED COPYRIGHT HOLDERS.\n"
			   "\n\n"
			   "Quick keys : 3       Insert coin\n"
			   "             1       Start 1 player game\n"
			   "             2       Start 2 player game\n"
			   "             E,S,D,F Left joystick\n"
			   "             I,J,K,L Right joystick\n"
			   "             F1      Skip level\n"
			   "             F2      Reset\n"
			   "             Tab     Change dip switch settings\n"
			   "             P       Pause\n"
			   "             F12     Save a screen snapshot\n"
			   "             ESC     Exit emulator\n"
			   "\n\n"
			   "Press <ENTER> to continue.\n");

		getchar();

                // my debug
                printf("osd_init()\n");
                // my debug

		if (osd_init(argc,argv) == 0)
		{
                // my debug
                // printf("run_machine()\n");
                // my debug 
                	if (run_machine(argc > 1 && argv[1][0] != '-' ? argv[1] : DEFAULT_NAME) != 0)
				printf("Unable to start emulation\n");

			osd_exit();
		}
		else printf("Unable to initialize system\n");
	}
	else printf("Unable to initialize machine emulation\n");

	exit(0);
}
