hackathon-dev #1

Merged
amy merged 101 commits from hackathon-dev into develop 2019-12-12 13:56:11 -07:00
3 changed files with 14 additions and 10 deletions
Showing only changes of commit 519e58fd77 - Show all commits

View File

@ -1,3 +1,4 @@
#include <stdlib.h>
#include "fbinit.h" #include "fbinit.h"
#include "devctxt.h" #include "devctxt.h"
#include "dc_screen.h" #include "dc_screen.h"
@ -30,7 +31,7 @@ static inline UINT16 apply_rop2(INT32 op, UINT16 disp, UINT16 pen)
return disp & (~pen); return disp & (~pen);
case R2_NOTCOPYPEN: case R2_NOTCOPYPEN:
return ~pen; return ~pen;
case R2_MASKPENNOT; case R2_MASKPENNOT:
return (~disp) & pen; return (~disp) & pen;
case R2_NOT: case R2_NOT:
return ~disp; return ~disp;
@ -55,6 +56,7 @@ static inline UINT16 apply_rop2(INT32 op, UINT16 disp, UINT16 pen)
case R2_WHITE: case R2_WHITE:
return (UINT16)(-1); return (UINT16)(-1);
} }
return pen; /* last ditch default */
} }
static COLORREF screen_set_pixel(PVOID privdata, INT32 x, INT32 y, COLORREF color, INT32 op) static COLORREF screen_set_pixel(PVOID privdata, INT32 x, INT32 y, COLORREF color, INT32 op)
@ -91,7 +93,7 @@ static BOOL screen_line(PVOID privdata, INT32 x1, INT32 y1, INT32 x2, INT32 y2,
} }
loc = loc_from_coords(priv, x1, y1); loc = loc_from_coords(priv, x1, y1);
tmp = x1; tmp = x1;
x1 << 16; x1 <<= 16;
dx = (dx << 16) / dy; dx = (dx << 16) / dy;
while (y1 <= y2) while (y1 <= y2)
{ {
@ -131,11 +133,12 @@ static BOOL screen_line(PVOID privdata, INT32 x1, INT32 y1, INT32 x2, INT32 y2,
++loc; ++loc;
if (tmp != (y1 >> 16)) if (tmp != (y1 >> 16))
{ {
loc += ((((y1 >> 16) - tmp) * priv->pix_per_row); loc += (((y1 >> 16) - tmp) * priv->pix_per_row);
tmp = y1 >> 16; tmp = y1 >> 16;
} }
} }
} }
return TRUE;
} }
static const DCFUNTABLE screen_funtable = { static const DCFUNTABLE screen_funtable = {
@ -159,7 +162,7 @@ PDCTXT DC_CreateScreenContext(void)
if (!priv) if (!priv)
return NULL; return NULL;
priv->pix_per_row = Fb_Info->width; priv->pix_per_row = Fb_Info->width;
priv->pdata = Pb_Ptr; priv->pdata = Fb_Ptr;
rc = _DC_Allocate(&screen_funtable, priv); rc = _DC_Allocate(&screen_funtable, priv);
if (rc) if (rc)

View File

@ -1,4 +1,5 @@
#include <string.h> #include <string.h>
#include <stdlib.h>
#include "gfxtype.h" #include "gfxtype.h"
#include "gfxobj.h" #include "gfxobj.h"
#include "devctxt.h" #include "devctxt.h"
@ -41,7 +42,7 @@ static BOOL line_clip(PINT32 output, INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT
y2 = tmp; y2 = tmp;
tmpb = outcode1; tmpb = outcode1;
outcode1 = outcode2; outcode1 = outcode2;
outcode2 = tmp; outcode2 = tmpb;
} }
if (outcode1 & 0x8) if (outcode1 & 0x8)
{ {
@ -102,7 +103,7 @@ COLORREF DC_SetPixel(PDCTXT pdctxt, INT32 x, INT32 y, COLORREF color)
{ {
if (!G_coords_in_rect(&(pdctxt->cliprect), x, y)) if (!G_coords_in_rect(&(pdctxt->cliprect), x, y))
return (COLORREF)(-1); return (COLORREF)(-1);
return (*(pdctxt->funcs->set_pixel))(pdctxt->privdata, xm, y, colorref, pdctxt->rop2); return (*(pdctxt->funcs->set_pixel))(pdctxt->privdata, x, y, color, pdctxt->rop2);
} }
BOOL DC_LineTo(PDCTXT pdctxt, INT32 x, INT32 y) BOOL DC_LineTo(PDCTXT pdctxt, INT32 x, INT32 y)

View File

@ -203,18 +203,18 @@ static void devctxt_dealloc(DevCtxtObject *self)
static int devctxt_init(DevCtxtObject *self, PyObject *args, PyObject *kwds) static int devctxt_init(DevCtxtObject *self, PyObject *args, PyObject *kwds)
{ {
static char *kwlist[] = { "type" } static char *kwlist[] = { "type" };
char *type; char *type;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|s", kwlist, &type)) if (!PyArg_ParseTupleAndKeywords(args, kwds, "|s", kwlist, &type))
return -1; return -1;
if (stricmp(type, "screen") == 0) if (strcmp(type, "screen") == 0)
{ {
self->pdctxt = DC_CreateScreenContext(); self->pdctxt = DC_CreateScreenContext();
if (!(self->pdctxt)) if (!(self->pdctxt))
{ {
PyErr_SetString(PyExc_RuntimeError, "unable to create screen context"); PyErr_SetString(PyExc_RuntimeError, "unable to create screen context");
return -1 return -1;
} }
} }
else else
@ -237,7 +237,7 @@ static PyTypeObject DevCtxtType = {
.tp_dealloc = (destructor)devctxt_dealloc, .tp_dealloc = (destructor)devctxt_dealloc,
.tp_methods = DevCtxtMethods, .tp_methods = DevCtxtMethods,
.tp_getset = DevCtxtProperties, .tp_getset = DevCtxtProperties,
} };
HRESULT Epython_register_devctxt(PyObject *module) HRESULT Epython_register_devctxt(PyObject *module)
{ {