/* basic.c : routines to emulate various BASIC functions,
 *            with a few useful extras.
 *           Most are #defined in basic.h to use bbc_*
 */

#include "os.h"
#include "bbc.h"
#define NULL 0

/* Read monotonic time. Equiv. to TIME */
int bbc_time(void) {
  os_regset r;
  os_error *e;

  if (e = os_swix(0x42, &r), e != NULL) {
    return 0;
  }
  return r.r[0];
}

/* Draw a line from x1,y1 to x2,y2 */
void draw_line(int x1, int y1, int x2, int y2) {
  bbc_move(x1, y1);
  bbc_draw(x2, y2);
}

/* Draw a rectangle from x1,y1 to x2,y2 */
void draw_rect(int x1, int y1, int x2, int y2) {
  int w, h;

  w = x2-x1;
  h = y2-y1;
  bbc_rectangle(x1, y1, w, h);
}
