#include <stdio.h>
#include <i86.h> // delay()
#include <conio.h>// getch()
#include <process.h>


#include "standard.h"
#include "tools.h"
#include "file.h"
#include "error.h"
#include "vesa.h"
#include "bild.h"
#include "pcx.h"
#include "help.h"
#include "edit.h"

#ifndef __MSDOS__
#define __MSDOS__
#include <vesavbe.h>
#include <svga.h>
#include <pmode.h>
#undef __MSDOS__
#else
#include <vesavbe.h>
#include <svga.h>
#include <pmode.h>
#endif

extern T_ULONG linestartpos[];
extern SV_devCtx *svdc;

T_INT test_tasten_funktion(PARAMETER *parameter)
{
 switch (parameter->taste)
 {
  case KEY_PLUS:
  {
   clear_screen();
   ((T_PUCHAR)svdc->videoMem)++;
   zeige_pcx_bild("test.pcx",0,0);
   parameter->executed=PARAMETER_EXECUTED;
   break;
  }
  case KEY_MINUS:
  {
   clear_screen();
   ((T_PUCHAR)svdc->videoMem)--;
   zeige_pcx_bild("test.pcx",0,0);
  parameter->executed=PARAMETER_EXECUTED;
   break;
  }
  default:
  {
   break;
  }
 }
 return parameter->ebene;
}

int main(void)
{
 T_UCHAR*test;
 e_verbose=E_VERBOSE_HIGH;               // debug settings
 p_verbosity = 0;                        // parser verbosity
 function_history=T_FALSE;               // debug settings
 function_timing=T_FALSE;                // debug settings
 current_error_level=39;                 // debug settings
 protocol_variant=ERROR_NUMBER_EXACT;    // debug settings
// protocol_variant=ERROR_NUMBER_HIGHER; // debug settings
// protocol_variant=ERROR_SPECIFIC;      // debug settings

// vesa_force_bank=TRUE;                 // vesa setting
 init_error();
 init_tools();
 if (tool_error==TOOL_INIT_ERROR)
 {
  tool_exit(TOOL_INIT_ERROR);
  printf("\n Konnte Tool-Library aus irgendeinem Grund nicht initialisieren...\n");
  return 2;
 }
 if (vesa_karte_da()==T_OK)
 if (vesa_existiert_modus(SVGA640X480)==T_OK)
 {
  vesa_alten_modus_speichern();
  vesa_setze_modus(SVGA640X480);
  vesa_mouse_init();
  vesa_load_mehrere_dac(224, "tool.dat\\16colors.col");
  init_colors();
  fKBDbuffering(T_FALSE);

  zeige_pcx_bild("test.pcx",0,0);
  test=svdc->videoMem;
  default_tasten_funktion= test_tasten_funktion;
  PROGRAMM_INIT
  svdc->videoMem=test;
  vesa_mouse_deinit();
  vesa_alten_modus_setzen();
 }
/**************/
 de_init_tools();
 return 0;
}


