/* COLOR_BLACK */ 0,
};
+void FreeTiles(SimView *view);
+void AllocTiles(SimView *view);
+void DoAdjustPan(struct SimView *view);
+void
ViewToTileCoords(SimView *view, int x, int y, int *outx, int *outy)
{
x = (view->pan_x - ((view->w_width >>1) - x)) >>4;
}
+void
ViewToPixelCoords(SimView *view, int x, int y, int *outx, int *outy)
{
x = view->pan_x - ((view->w_width >>1) - x);
}
-UpdateFlush()
+void
+UpdateFlush(void)
{
struct XDisplay *xd;
}
-DoStopMicropolis()
+void
+DoStopMicropolis(void)
{
(void)XSetErrorHandler(CatchXError);
}
-DoTimeoutListen()
+void
+DoTimeoutListen(void)
{
while (Tk_DoOneEvent(TK_DONT_WAIT)) ;
}
FindXDisplay(Tk_Window tkwin)
{
XDisplay *xd;
- int d = 8;
- unsigned long valuemask = 0;
- XGCValues values;
- XColor rgb, *color;
+ XColor *color;
Display *dpy = Tk_Display(tkwin);
Screen *screen = Tk_Screen(tkwin);
#ifdef IS_LINUX
color->pixel; \
break; \
case 15: \
+ if (xd->visual->red_mask == 0x7c00) { \
xd->pixels[i] = \
(((color->red >> (8 + 3)) & 0x1f) << (5 + 5)) | \
(((color->green >> (8 + 2)) & 0x1f) << (5)) | \
(((color->blue >> (8 + 3)) & 0x1f) << (0)); \
+ } else { \
+ xd->pixels[i] = \
+ (((color->blue >> (8 + 3)) & 0x1f) << (5 + 5)) | \
+ (((color->green >> (8 + 2)) & 0x1f) << (5)) | \
+ (((color->red >> (8 + 3)) & 0x1f) << (0)); \
+ } \
break; \
case 16: \
+ if (xd->visual->red_mask == 0xf800) { \
xd->pixels[i] = \
(((color->red >> (8 + 3)) & 0x1f) << (6 + 5)) | \
(((color->green >> (8 + 2)) & 0x3f) << (5)) | \
(((color->blue >> (8 + 3)) & 0x1f) << (0)); \
+ } else { \
+ xd->pixels[i] = \
+ (((color->blue >> (8 + 3)) & 0x1f) << (6 + 5)) | \
+ (((color->green >> (8 + 2)) & 0x3f) << (5)) | \
+ (((color->red >> (8 + 3)) & 0x1f) << (0)); \
+ } \
break; \
case 24: \
+ case 32: \
+ if (xd->visual->red_mask == 0xff0000) { \
xd->pixels[i] = \
((color->red & 0xff) << 16) | \
((color->green & 0xff) << 8) | \
((color->blue & 0xff) << 0); \
- break; \
- case 32: \
+ } else { \
xd->pixels[i] = \
- ((color->red & 0xff) << 16) | \
+ ((color->blue & 0xff) << 16) | \
((color->green & 0xff) << 8) | \
- ((color->blue & 0xff) << 0); \
+ ((color->red & 0xff) << 0); \
+ } \
break; \
} \
} \
} else {
fprintf(stderr,
"Cool, I found the shared memory extension!\n");
- fprintf(stderr,
- "Disabled SHM, because it is currently broken!\n");
- xd->shared = 0;
+ xd->shared = 1;
}
}
}
}
+void
IncRefDisplay(XDisplay *xd)
{
xd->references++;
}
+void
DecRefDisplay(XDisplay *xd)
{
if ((--xd->references) == 0) {
SimView *
InitNewView(SimView *view, char *title, int class, int w, int h)
{
- int type, i;
int test = 1;
- int d = 8;
- unsigned long valuemask = 0;
char *t;
- struct XDisplay *xd;
- XGCValues values;
- XColor rgb, *color;
t = (char *)ckalloc(strlen(title) + 1);
strcpy(t, title);
view->update_context = 0;
view->auto_goto = 0;
view->auto_going = 0;
- view->auto_x_goal = view->auto_x_goal = 0;
+ view->auto_x_goal = view->auto_y_goal = 0;
view->auto_speed = 75;
view->follow = NULL;
view->sound = 1;
view->type = X_Mem_View;
}
- if ((ImageByteOrder(view->x->dpy) == MSBFirst) == !(*(unsigned char*) (&test)))
- view->x->needs_swap = 0;
- else
- view->x->needs_swap = 1;
+ view->x->needs_swap = !(*(unsigned char*) (&test));
+ view->x->x_big_endian = (ImageByteOrder(view->x->dpy) == MSBFirst);
GetPixmaps(view->x);
view->pan_x = w / 2; view->pan_y = h / 2;
DoResizeView(view, w, h);
- GetViewTiles(view);
-
return (view);
}
+void
DestroyView(SimView *view)
{
SimView **vp;
}
+void
DoResizeView(SimView *view, int w, int h)
{
int resize = 0;
}
view->data = (unsigned char *)shmat(view->shminfo->shmid, 0, 0);
- if ((int)view->data == -1) {
+ if ((char*)view->data == (char*)-1) {
perror("shmat");
fprintf(stderr,
"Darn, Micropolis can't find any memory to share with display \"%s\".\n",
if (!GotXError) {
attached = 1;
view->pixmap = XShmCreatePixmap(view->x->dpy, view->x->root,
- view->data, view->shminfo,
+ (char*)view->data, view->shminfo,
view->m_width, view->m_height,
view->x->depth);
XSync(view->x->dpy, False);
view->pixel_bytes = 2;
view->depth = 15;
bitmap_pad = 16;
- bitmap_depth = 16;
+ bitmap_depth = 15;
view->line_bytes8 =
((view->m_width * view->pixel_bytes) + 3) & (~3);
break;
}
}
}
+
+ GetViewTiles(view);
+
}
+void
DoPanBy(struct SimView *view, int dx, int dy)
{
DoPanTo(view, view->pan_x + dx, view->pan_y + dy);
}
+void
DoPanTo(struct SimView *view, int x, int y)
{
if (view->class != Editor_Class) {
/* #define DEBUG_PAN */
+void
DoAdjustPan(struct SimView *view)
{
int ww2 = view->w_width >>1, wh2 = view->w_height >>1;
int px = view->pan_x, py = view->pan_y;
int last_tile_x = view->tile_x, last_tile_y = view->tile_y;
- int last_tile_width = view->tile_width, last_tile_height = view->tile_height;
int total_width = view->m_width >>4, total_height = view->m_height >>4;
//fprintf(stderr, "DoAdjustPan\n");
}
+void
AllocTiles(SimView *view)
{
int row, col;
}
+void
FreeTiles(SimView *view)
{
int col;
}
+void
FreeInk(Ink *ink)
{
ink->next = OldInk;
}
+void
StartInk(Ink *ink, int x, int y)
{
ink->length = 1;
}
+void
AddInk(Ink *ink, int x, int y)
{
int dx = x - ink->last_x;
ink->points[ink->length].y = dy;
ink->length++;
- ADJUST:
+ /* ADJUST: */
if (x < ink->left)
ink->left = x;
if (x > ink->right)
}
-EraseOverlay()
+void
+EraseOverlay(void)
{
Ink *ink;