OpenCores
URL https://opencores.org/ocsvn/eco32/eco32/trunk

Subversion Repositories eco32

[/] [eco32/] [trunk/] [sim/] [graph.c] - Diff between revs 8 and 251

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 8 Rev 251
Line 14... Line 14...
#include "except.h"
#include "except.h"
#include "graph.h"
#include "graph.h"
 
 
 
 
static Bool debug = false;
static Bool debug = false;
static volatile Bool installed = false;
static Bool volatile installed = false;
 
 
 
 
/**************************************************************/
/**************************************************************/
/**************************************************************/
/**************************************************************/
 
 
Line 38... Line 38...
#define WINDOW_POS_X            100
#define WINDOW_POS_X            100
#define WINDOW_POS_Y            100
#define WINDOW_POS_Y            100
 
 
 
 
#define C2B(c,ch)               (((((c) & 0xFF) * ch.scale) >> 8) * ch.factor)
#define C2B(c,ch)               (((((c) & 0xFF) * ch.scale) >> 8) * ch.factor)
#define RGB2PIXEL(r,g,b)        (C2B(r, vga.red) | \
#define RGB2PIXEL(r,g,b)        (0xFF000000 | \
 
                                 C2B(r, vga.red) | \
                                 C2B(g, vga.green) | \
                                 C2B(g, vga.green) | \
                                 C2B(b, vga.blue))
                                 C2B(b, vga.blue))
 
 
 
 
typedef struct {
typedef struct {
Line 217... Line 218...
  /* prepare shutdown event */
  /* prepare shutdown event */
  vga.shutdown.type = ClientMessage;
  vga.shutdown.type = ClientMessage;
  vga.shutdown.display = vga.display;
  vga.shutdown.display = vga.display;
  vga.shutdown.window = vga.win;
  vga.shutdown.window = vga.win;
  vga.shutdown.message_type = XA_WM_COMMAND;
  vga.shutdown.message_type = XA_WM_COMMAND;
  vga.shutdown.format = 32;
  vga.shutdown.format = 8;
  vga.shutdown.data.l[0] = 0xDEADBEEF;
 
  /* say that the graphics controller is installed */
  /* say that the graphics controller is installed */
  XSync(vga.display, False);
  XSync(vga.display, False);
  installed = true;
  installed = true;
}
}
 
 
Line 260... Line 260...
                  event.xexpose.x, event.xexpose.y,
                  event.xexpose.x, event.xexpose.y,
                  event.xexpose.width, event.xexpose.height);
                  event.xexpose.width, event.xexpose.height);
        break;
        break;
      case ClientMessage:
      case ClientMessage:
        if (event.xclient.message_type == XA_WM_COMMAND &&
        if (event.xclient.message_type == XA_WM_COMMAND &&
            event.xclient.format == 32 &&
            event.xclient.format == 8) {
            event.xclient.data.l[0] == 0xDEADBEEF) {
 
          run = false;
          run = false;
        }
        }
        break;
        break;
      default:
      default:
        break;
        break;
Line 279... Line 278...
/**************************************************************/
/**************************************************************/
 
 
/* refresh timer */
/* refresh timer */
 
 
 
 
static Bool refreshRunning = false;
static Bool volatile refreshRunning = false;
 
 
 
 
static void *refresh(void *ignore) {
static void *refresh(void *ignore) {
  struct timespec delay;
  struct timespec delay;
 
 
Line 307... Line 306...
static char *myArgv[] = {
static char *myArgv[] = {
  "eco32",
  "eco32",
  NULL
  NULL
};
};
 
 
 
static pthread_t monitorThread;
 
static pthread_t refreshThread;
 
 
static void vgaInit(void) {
 
  pthread_attr_t attr;
 
  pthread_t thread;
 
 
 
 
static void vgaInit(void) {
  /* start monitor server in a separate thread */
  /* start monitor server in a separate thread */
  vga.argc = myArgc;
  vga.argc = myArgc;
  vga.argv = myArgv;
  vga.argv = myArgv;
  pthread_attr_init(&attr);
  if (pthread_create(&monitorThread, NULL, server, NULL) != 0) {
  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
 
  if (pthread_create(&thread, &attr, server, NULL) != 0) {
 
    error("cannot start monitor server");
    error("cannot start monitor server");
  }
  }
  while (!installed) sleep(1);
  while (!installed) ;
  /* start refresh timer in another thread */
  /* start refresh timer in another thread */
  refreshRunning = true;
  refreshRunning = true;
  pthread_attr_init(&attr);
  if (pthread_create(&refreshThread, NULL, refresh, NULL) != 0) {
  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
 
  if (pthread_create(&thread, &attr, refresh, NULL) != 0) {
 
    error("cannot start refresh timer");
    error("cannot start refresh timer");
  }
  }
}
}
 
 
 
 
static void vgaExit(void) {
static void vgaExit(void) {
  refreshRunning = false;
  refreshRunning = false;
  sleep(1);
  pthread_join(refreshThread, NULL);
  XSendEvent(vga.display, vga.win, False, 0, (XEvent *) &vga.shutdown);
  XSendEvent(vga.display, vga.win, False, 0, (XEvent *) &vga.shutdown);
  XSync(vga.display, False);
  XSync(vga.display, False);
  while (installed) sleep(1);
  pthread_join(monitorThread, NULL);
}
}
 
 
 
 
static void vgaWrite(int x, int y, int r, int g, int b) {
static void vgaWrite(int x, int y, int r, int g, int b) {
  XPutPixel(vga.image, x, y, RGB2PIXEL(r, g, b));
  XPutPixel(vga.image, x, y, RGB2PIXEL(r, g, b));

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.