#ifdef DEBUG
#include <stdio.h>
#endif

#include "intlong.h"
char last_mode = '|';
bit16 last_col = 7; // white
// static char hex_chars[] = "0123456789ABCDEF";

// BBC Micro-dependent

void vdu(int code, int arg, int x, int y)
{ // low-level graphics calls on Beeb
#ifdef DEBUG
  printf("Vdu %d,%d, %d, %d\n", code, arg, x, y);
#endif
#ifdef BBC
  putchar(code); putchar(arg);
  x = x*4; y = y*4;
  putchar(x & 255); putchar((x >> 8) & 255); 
  putchar(y & 255); putchar((y >> 8) & 255); 
#endif
}

void inigraf(void)
{
  vdu(22,0,0,0); // CLS
}

void plot(bit16 x, bit16 y)
{
  vdu(25,4,x,y); // moveto
  vdu(25,5,x,y); // lineto same point
}

void vector(bit16 x1, bit16 y1, bit16 x2, bit16 y2, char mode, bit16 col)
{
  if(col != last_col) {
    last_col = col;
  }
  if(mode != last_mode) {
    last_mode = mode;
    switch(mode) {
      case '|':
                vdu(18,0,1,0); // OR mode
                break;
      case '^':
                vdu(18,4,1,0); // EXOR mode
                break;
    }
  };
  vdu(25,4,x1,y1); // move to
  vdu(25,5,x2,y2); // line to
}
