/********************************************************
 * Demoprogramm zur Demonstation einiger Funktionen der	*
 ********************************************************

/********************************************************
 * Compileroptionen: -3 +l -s				*
 * Mit "cc demo" compilieren, mit "ln demo -lc" linken	*
 ********************************************************/

#include <exec/types.h>
#include <exec/libraries.h>
#include "phoblib.h"
#include "pragmas_azt.h"

struct PhobosBase *PhobosBase;

BYTE c;
int i,x,y;
char buf[2];
long Phobos = 0L;

char txt[80],txt1[80],t1[80];

main(int argc, char **argv[])
{  
/* phobos.library öffnen */
 if(!(PhobosBase = (struct Library *) OpenLibrary("phobos.library",0L))) exit(0);

/* Verbindung zu Phobos aufbauen */
 if(!(Phobos = OpenPhobos(atol(argv[1]))) {CloseLibrary(PhobosBase); exit(0);}

/* Ausgabetext vorbereiten */
 strcpy(txt,">>> phobos.library Demoprogramm <<<");
 strcpy(txt1,"                                   ");

/* Bildschirm löschen */
 ClrScreen(Phobos);

/* Ausgabetext auf Bildschirm ausgeben */
/* ausgeben - löschen - ausgeben */
 for(i=0; i<strlen(txt); i++)
 {
  buf[0] = txt[i];
  buf[1] = 0x00;
  PrintAt(Phobos,24+i,12,buf);
  Delay(1);
 }
 for(i=0; i<strlen(txt1); i++)
 {
  buf[0] = txt1[i];
  buf[1] = 0x00;
  PrintAt(Phobos,24+i,12,buf);
  Delay(1);
 }
 for(i=0; i<strlen(txt); i++)
 {
  buf[0] = txt[i];
  buf[1] = 0x00;
  PrintAt(Phobos,24+i,12,buf);
  Delay(1);
 }
 Delay(100);

/* Ausgabetext vorbereiten */
 strcpy(txt," L b a y g s h i b n v n S F T U H ");
 strcpy(txt1,"  i r r   e c r e e   o   O T O C  ");
 strcpy(t1,"                                   ");

/* Text ausgeben */
 for(y=0; y<12; y++)
 {
  PrintAt(Phobos,24,y,txt);
  PrintAt(Phobos,24,24-y,txt1);
  Delay(2);
  PrintAt(Phobos,24,y,t1);
  PrintAt(Phobos,24,24-y,t1);
 }
 PrintAt(Phobos,24,y," Library geschrieben von SOFTTOUCH ");

 Delay(100);

/* Bildschirm löschen */
 ClrScreen(Phobos);

 PrintAt(Phobos,0,2,"[33mSchreibe nun Text -Testprogramm- unten in das Statuswindow...[0m");

 Delay(100);

/* Text in Phobos Statusanzeige schreiben */
 ShowStatus(Phobos,"Testprogramm");

/* Auf Taste ESC oder Gadget RAUS DA! warten */
 PrintAt(Phobos,0,4,"[33mIch warte jetzt auf Drücken der Taste [34mESC [33moder Gadget [35mRAUD DA![0m");

 while(1)
 {
  if(!(GetCarrier(Phobos))) {PrintAt(Phobos,0,6,"Gadget RAUS DA! gedrückt!"); Delay(100); break;}
  if(c = ChSer(Phobos) == 27) {PrintAt(Phobos,0,6,"Taste Escape gedrückt!"); Delay(100); break;}
 }

 PrintAt(Phobos,0,8,"Nicht erschrecken... schließe in 4 Sekunden kurz den Phobosscreen...");
 Delay(200);

/* Window schließen */
 PhobosWindow(Phobos,0L);

 Delay(100);

/* Window wieder öffnen */
 PhobosWindow(Phobos,1L);

 PrintAt(Phobos,0,10,"[35mTrenne nun Verbindung zu Phobos mit CLOSEPHOBOS()");
 Delay(100);

/* Verbindung zu Phobos trennen */
 ClosePhobos(Phobos);

/* Library wieder schließen */
 if(PhobosBase) CloseLibrary(PhobosBase);
}
