#include <stdio.h>
#include <proto/exec.h>

#include <clib/langmod_protos.h>
#include <libraries/langmod.h>

/* Klingon trans.c*/
/* Program to translate time to klingon words (sad git arn't I)*/
/* Terran (our) dates (days/months/years) are not currently supported by the language */
/* Time is measured in twenty four hour military fashion */
/* 6 am = Six Hundred hours = jav vatlh   rep */
/*                            six hundred hours*/
/* Basic code © Jeremy Silver */


/* Re-written as langmod, Ben Matthew (19.03.97) */

/* The strings.... */


char *klingnums[] = {
     "pagh",/* 0 */
     "wa'",/* 1 */
     "cha'",/* 2 */
     "wej",/* 3 */
     "loS",/* 4 */
     "vagh",/* 5 */
     "jav",/* 6 */
     "Soch",/* 7 */
     "chorgh",/* 8 */
     "Hut",/* 9 */
     "wa'maH",/* 10 */
     "cha'maH",/* 20 */
     "wejmaH",/* 30 */
     "loSmaH",/* 40 */
     "vaghmaH",/* 50 */
     "javmaH"/* 60 */
 };

__asm UBYTE *ECM_GetTimeStr(	register __a0 UBYTE *buffer,
								register __d1 ULONG bufsize,
								register __a1 ULONG *error,
								register __a2 struct EngTime *tm ) {

/* Tried to base as much as poss on original english/digital source langmod. */
/* Any poss of having digital display langmod with klingon style font numerals ->*/
/* & klingon words spoken using my improved klingon accent ?*/


/* surely use of "long" for units of time is overkill?*/

/* or is there some reason for it dictated by the system clock */
/* or your program to grab it ? - */
/* no I am not calling you Shirley ;-) */

	int hours, minutes, response=0, tens;
     char line1[200];



	hours=tm->hours;
	minutes=tm->minutes;

     /* now the "time" is available... */
     /* translate time starting with first & easiest time - midnight*/
     /* Midnight! - or zero hours = "pagh rep" rep will be bunged on the end */
     /* last of all so we dont have to worry about it now */
     if (hours==0&&minutes==0)  
     {
          strcpy(line1,"pagh");
     }
     else /* not Midnight / else no 1*/
     {
          /* Worry about Hours first*/
          if(hours<=9)
          {
               strcpy(line1,klingnums[hours]);
          }

          /* worry about the hours over 9 - now things get complicated*/
          /* in order to index "klingnums" correctly*/
          
          if((hours>=10)&&(hours<=19))
          {
               strcpy(line1,klingnums[10]);
               tens=10;
          }

          if((hours>=20)&&(hours<=23))
          {
               strcpy(line1,klingnums[11]);
               tens=20;
          }
          /* that gets the "tens" part of the number now*/
	  /* worry about units */
	  if((hours-tens)>0)
	  {
		strcat(line1," ");
          	strcat(line1,klingnums[hours-tens]);
          }

          strcat(line1," vatlh "); /* add klingon hundred */

                    
          /* Now Worry about minutes */
          tens=0;
          if(minutes>0)
          {
          	if(minutes<=9)
          	{
               		strcat(line1,klingnums[minutes]);
          	}
          	else /* no 2 */
                {    /*worry about the minutes over 9*/
                    	if(minutes<=19)
                        {
                                strcat(line1,klingnums[10]);
                                tens=10;
                        }
                    	if ((minutes>=20)&&(minutes<=29))
                    	{
                         	strcat(line1,klingnums[11]);
                         	tens=20;
                    	}
                    	if ((minutes>=30)&&(minutes<=39))
                    	{
                         	strcat(line1,klingnums[12]);
                         	tens=30;
                    	}
                    	if ((minutes>=40)&&(minutes<=49))
                    	{
                         	strcat(line1,klingnums[13]);
                         	tens=40;
                    	}
                    	if ((minutes>=50)&&(minutes<=59))
                    	{
                         	strcat(line1,klingnums[14]);
                         	tens=50;
                    	}
                        /* that gets the "tens" part of the number now*/
	                /* worry about units */
			if((minutes-tens)!=0)
                        {
				strcat(line1," ");
                    		strcat(line1,klingnums[minutes-tens]);
                        }
                }/*end of else no 2*/
	 }

     }/* end of else no 1*/

     strcat(line1," rep"); /* append rep (hours) to string */


	strcpy(buffer,line1);
	return(buffer);

} /*end main*/

__asm UBYTE *ECM_GetDateStr(	register __a0 UBYTE *buffer,
								register __d1 ULONG bufsize,
								register __a1 ULONG *error,
								register __a2 struct EngTime *tm) {

	strcpy(buffer,"Not available");
	return(buffer);
}
