/* 0.9.7 on Sun Nov  2 00:45:32 2008 */

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "structmember.h"
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#if PY_VERSION_HEX < 0x02050000
  typedef int Py_ssize_t;
  #define PY_SSIZE_T_MAX INT_MAX
  #define PY_SSIZE_T_MIN INT_MIN
  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
  #define PyInt_AsSsize_t(o)	PyInt_AsLong(o)
#endif
#ifndef WIN32
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
#endif
#ifdef __cplusplus
#define __PYX_EXTERN_C extern "C"
#else
#define __PYX_EXTERN_C extern
#endif
#include <math.h>
#include "renpy.h"


typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/
typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/

static PyObject *__pyx_m;
static PyObject *__pyx_b;
static int __pyx_lineno;
static char *__pyx_filename;
static char **__pyx_f;

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/

static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/

static PyObject *__Pyx_UnpackItem(PyObject *); /*proto*/
static int __Pyx_EndUnpack(PyObject *); /*proto*/

static int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/

static void __Pyx_AddTraceback(char *funcname); /*proto*/

/* Declarations from _renpy */

static PyObject *__pyx_k2;
static PyObject *__pyx_k3;
static PyObject *__pyx_k4;
static PyObject *__pyx_k5;
static PyObject *__pyx_k6;
static PyObject *__pyx_k7;
static PyObject *__pyx_k8;
static PyObject *__pyx_k9;
static PyObject *__pyx_k10;


/* Implementation of _renpy */


static PyObject *__pyx_n_pygame;
static PyObject *__pyx_n_Surface;
static PyObject *__pyx_n_PygameSurface;

static PyObject *__pyx_f_6_renpy_version(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_6_renpy_version(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  __pyx_1 = PyInt_FromLong(6007001); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_renpy.version");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

static PyObject *__pyx_k11p;

static char __pyx_k11[] = "save_png requires a pygame Surface as its first argument.";

static PyObject *__pyx_f_6_renpy_save_png(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_6_renpy_save_png(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_surf = 0;
  PyObject *__pyx_v_file = 0;
  PyObject *__pyx_v_compress = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {"surf","file","compress",0};
  __pyx_v_compress = __pyx_k2;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|O", __pyx_argnames, &__pyx_v_surf, &__pyx_v_file, &__pyx_v_compress)) return 0;
  Py_INCREF(__pyx_v_surf);
  Py_INCREF(__pyx_v_file);
  Py_INCREF(__pyx_v_compress);

  /* "/home/tom/ab/renpy/module/_renpy.pyx":100 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_PygameSurface); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; goto __pyx_L1;}
  __pyx_2 = PyObject_IsInstance(__pyx_v_surf,__pyx_1); if (__pyx_2 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_3 = (!__pyx_2);
  if (__pyx_3) {
    __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; goto __pyx_L1;}
    Py_INCREF(__pyx_k11p);
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k11p);
    __pyx_4 = PyObject_CallObject(PyExc_Exception, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":103 */
  __pyx_2 = PyInt_AsLong(__pyx_v_compress); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; goto __pyx_L1;}
  save_png_core(__pyx_v_surf,RWopsFromPython(__pyx_v_file),__pyx_2);

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_renpy.save_png");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_surf);
  Py_DECREF(__pyx_v_file);
  Py_DECREF(__pyx_v_compress);
  return __pyx_r;
}

static PyObject *__pyx_n_get_bitsize;

static PyObject *__pyx_k12p;
static PyObject *__pyx_k13p;
static PyObject *__pyx_k14p;
static PyObject *__pyx_k15p;

static char __pyx_k12[] = "pixellate requires a pygame Surface as its first argument.";
static char __pyx_k13[] = "pixellate requires a pygame Surface as its second argument.";
static char __pyx_k14[] = "pixellate requires a 24 or 32 bit surface.";
static char __pyx_k15[] = "pixellate requires both surfaces have the same bitsize.";

static PyObject *__pyx_f_6_renpy_pixellate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_6_renpy_pixellate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_pysrc = 0;
  PyObject *__pyx_v_pydst = 0;
  PyObject *__pyx_v_avgwidth = 0;
  PyObject *__pyx_v_avgheight = 0;
  PyObject *__pyx_v_outwidth = 0;
  PyObject *__pyx_v_outheight = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  int __pyx_7;
  int __pyx_8;
  static char *__pyx_argnames[] = {"pysrc","pydst","avgwidth","avgheight","outwidth","outheight",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOOOOO", __pyx_argnames, &__pyx_v_pysrc, &__pyx_v_pydst, &__pyx_v_avgwidth, &__pyx_v_avgheight, &__pyx_v_outwidth, &__pyx_v_outheight)) return 0;
  Py_INCREF(__pyx_v_pysrc);
  Py_INCREF(__pyx_v_pydst);
  Py_INCREF(__pyx_v_avgwidth);
  Py_INCREF(__pyx_v_avgheight);
  Py_INCREF(__pyx_v_outwidth);
  Py_INCREF(__pyx_v_outheight);

  /* "/home/tom/ab/renpy/module/_renpy.pyx":108 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_PygameSurface); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; goto __pyx_L1;}
  __pyx_2 = PyObject_IsInstance(__pyx_v_pysrc,__pyx_1); if (__pyx_2 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_3 = (!__pyx_2);
  if (__pyx_3) {
    __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; goto __pyx_L1;}
    Py_INCREF(__pyx_k12p);
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k12p);
    __pyx_4 = PyObject_CallObject(PyExc_Exception, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":111 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_PygameSurface); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; goto __pyx_L1;}
  __pyx_2 = PyObject_IsInstance(__pyx_v_pydst,__pyx_1); if (__pyx_2 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_3 = (!__pyx_2);
  if (__pyx_3) {
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; goto __pyx_L1;}
    Py_INCREF(__pyx_k13p);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k13p);
    __pyx_1 = PyObject_CallObject(PyExc_Exception, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __Pyx_Raise(__pyx_1, 0, 0);
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; goto __pyx_L1;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":114 */
  __pyx_4 = PyObject_GetAttr(__pyx_v_pysrc, __pyx_n_get_bitsize); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; goto __pyx_L1;}
  __pyx_1 = PyObject_CallObject(__pyx_4, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  __pyx_4 = PyInt_FromLong(24); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; goto __pyx_L1;}
  __pyx_5 = PyInt_FromLong(32); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_6, 0, __pyx_4);
  PyTuple_SET_ITEM(__pyx_6, 1, __pyx_5);
  __pyx_4 = 0;
  __pyx_5 = 0;
  __pyx_2 = PySequence_Contains(__pyx_6, __pyx_1); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; goto __pyx_L1;}
  __pyx_2 = !__pyx_2;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  if (__pyx_2) {
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; goto __pyx_L1;}
    Py_INCREF(__pyx_k14p);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k14p);
    __pyx_5 = PyObject_CallObject(PyExc_Exception, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __Pyx_Raise(__pyx_5, 0, 0);
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; goto __pyx_L1;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":117 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_pydst, __pyx_n_get_bitsize); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; goto __pyx_L1;}
  __pyx_6 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_4 = PyObject_GetAttr(__pyx_v_pysrc, __pyx_n_get_bitsize); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; goto __pyx_L1;}
  __pyx_5 = PyObject_CallObject(__pyx_4, 0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  if (PyObject_Cmp(__pyx_6, __pyx_5, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; goto __pyx_L1;}
  __pyx_3 = __pyx_3 != 0;
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  if (__pyx_3) {
    __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; goto __pyx_L1;}
    Py_INCREF(__pyx_k15p);
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k15p);
    __pyx_4 = PyObject_CallObject(PyExc_Exception, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; goto __pyx_L1;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":123 */
  __pyx_6 = PyObject_GetAttr(__pyx_v_pysrc, __pyx_n_get_bitsize); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; goto __pyx_L1;}
  __pyx_5 = PyObject_CallObject(__pyx_6, 0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; goto __pyx_L1;}
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  __pyx_1 = PyInt_FromLong(32); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; goto __pyx_L1;}
  if (PyObject_Cmp(__pyx_5, __pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; goto __pyx_L1;}
  __pyx_2 = __pyx_2 == 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (__pyx_2) {
    __pyx_3 = PyInt_AsLong(__pyx_v_avgwidth); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; goto __pyx_L1;}
    __pyx_2 = PyInt_AsLong(__pyx_v_avgheight); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; goto __pyx_L1;}
    __pyx_7 = PyInt_AsLong(__pyx_v_outwidth); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; goto __pyx_L1;}
    __pyx_8 = PyInt_AsLong(__pyx_v_outheight); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; goto __pyx_L1;}
    pixellate32_core(__pyx_v_pysrc,__pyx_v_pydst,__pyx_3,__pyx_2,__pyx_7,__pyx_8);
    goto __pyx_L6;
  }
  /*else*/ {
    __pyx_3 = PyInt_AsLong(__pyx_v_avgwidth); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; goto __pyx_L1;}
    __pyx_2 = PyInt_AsLong(__pyx_v_avgheight); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; goto __pyx_L1;}
    __pyx_7 = PyInt_AsLong(__pyx_v_outwidth); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; goto __pyx_L1;}
    __pyx_8 = PyInt_AsLong(__pyx_v_outheight); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; goto __pyx_L1;}
    pixellate24_core(__pyx_v_pysrc,__pyx_v_pydst,__pyx_3,__pyx_2,__pyx_7,__pyx_8);
  }
  __pyx_L6:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("_renpy.pixellate");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_pysrc);
  Py_DECREF(__pyx_v_pydst);
  Py_DECREF(__pyx_v_avgwidth);
  Py_DECREF(__pyx_v_avgheight);
  Py_DECREF(__pyx_v_outwidth);
  Py_DECREF(__pyx_v_outheight);
  return __pyx_r;
}

static PyObject *__pyx_n_get_size;

static PyObject *__pyx_k16p;
static PyObject *__pyx_k17p;
static PyObject *__pyx_k18p;
static PyObject *__pyx_k19p;
static PyObject *__pyx_k20p;

static char __pyx_k16[] = "map requires a pygame Surface as its first argument.";
static char __pyx_k17[] = "map requires a pygame Surface as its second argument.";
static char __pyx_k18[] = "map requires a 24 or 32 bit surface.";
static char __pyx_k19[] = "map requires both surfaces have the same bitsize.";
static char __pyx_k20[] = "map requires both surfaces have the same size.";

static PyObject *__pyx_f_6_renpy_map(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_6_renpy_map(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_pysrc = 0;
  PyObject *__pyx_v_pydst = 0;
  PyObject *__pyx_v_r = 0;
  PyObject *__pyx_v_g = 0;
  PyObject *__pyx_v_b = 0;
  PyObject *__pyx_v_a = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  char *__pyx_7;
  char *__pyx_8;
  char *__pyx_9;
  char *__pyx_10;
  static char *__pyx_argnames[] = {"pysrc","pydst","r","g","b","a",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOOOOO", __pyx_argnames, &__pyx_v_pysrc, &__pyx_v_pydst, &__pyx_v_r, &__pyx_v_g, &__pyx_v_b, &__pyx_v_a)) return 0;
  Py_INCREF(__pyx_v_pysrc);
  Py_INCREF(__pyx_v_pydst);
  Py_INCREF(__pyx_v_r);
  Py_INCREF(__pyx_v_g);
  Py_INCREF(__pyx_v_b);
  Py_INCREF(__pyx_v_a);

  /* "/home/tom/ab/renpy/module/_renpy.pyx":138 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_PygameSurface); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; goto __pyx_L1;}
  __pyx_2 = PyObject_IsInstance(__pyx_v_pysrc,__pyx_1); if (__pyx_2 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_3 = (!__pyx_2);
  if (__pyx_3) {
    __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; goto __pyx_L1;}
    Py_INCREF(__pyx_k16p);
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k16p);
    __pyx_4 = PyObject_CallObject(PyExc_Exception, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":141 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_PygameSurface); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; goto __pyx_L1;}
  __pyx_2 = PyObject_IsInstance(__pyx_v_pydst,__pyx_1); if (__pyx_2 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_3 = (!__pyx_2);
  if (__pyx_3) {
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; goto __pyx_L1;}
    Py_INCREF(__pyx_k17p);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k17p);
    __pyx_1 = PyObject_CallObject(PyExc_Exception, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __Pyx_Raise(__pyx_1, 0, 0);
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; goto __pyx_L1;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":144 */
  __pyx_4 = PyObject_GetAttr(__pyx_v_pysrc, __pyx_n_get_bitsize); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; goto __pyx_L1;}
  __pyx_1 = PyObject_CallObject(__pyx_4, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  __pyx_4 = PyInt_FromLong(24); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; goto __pyx_L1;}
  __pyx_5 = PyInt_FromLong(32); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_6, 0, __pyx_4);
  PyTuple_SET_ITEM(__pyx_6, 1, __pyx_5);
  __pyx_4 = 0;
  __pyx_5 = 0;
  __pyx_2 = PySequence_Contains(__pyx_6, __pyx_1); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; goto __pyx_L1;}
  __pyx_2 = !__pyx_2;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  if (__pyx_2) {
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; goto __pyx_L1;}
    Py_INCREF(__pyx_k18p);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k18p);
    __pyx_5 = PyObject_CallObject(PyExc_Exception, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __Pyx_Raise(__pyx_5, 0, 0);
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; goto __pyx_L1;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":147 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_pydst, __pyx_n_get_bitsize); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}
  __pyx_6 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_4 = PyObject_GetAttr(__pyx_v_pysrc, __pyx_n_get_bitsize); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}
  __pyx_5 = PyObject_CallObject(__pyx_4, 0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  if (PyObject_Cmp(__pyx_6, __pyx_5, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}
  __pyx_3 = __pyx_3 != 0;
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  if (__pyx_3) {
    __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; goto __pyx_L1;}
    Py_INCREF(__pyx_k19p);
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k19p);
    __pyx_4 = PyObject_CallObject(PyExc_Exception, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; goto __pyx_L1;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":150 */
  __pyx_6 = PyObject_GetAttr(__pyx_v_pydst, __pyx_n_get_size); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; goto __pyx_L1;}
  __pyx_5 = PyObject_CallObject(__pyx_6, 0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; goto __pyx_L1;}
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  __pyx_1 = PyObject_GetAttr(__pyx_v_pysrc, __pyx_n_get_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; goto __pyx_L1;}
  __pyx_4 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (PyObject_Cmp(__pyx_5, __pyx_4, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; goto __pyx_L1;}
  __pyx_2 = __pyx_2 != 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  if (__pyx_2) {
    __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; goto __pyx_L1;}
    Py_INCREF(__pyx_k20p);
    PyTuple_SET_ITEM(__pyx_6, 0, __pyx_k20p);
    __pyx_1 = PyObject_CallObject(PyExc_Exception, __pyx_6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; goto __pyx_L1;}
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    __Pyx_Raise(__pyx_1, 0, 0);
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; goto __pyx_L1;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":156 */
  __pyx_5 = PyObject_GetAttr(__pyx_v_pysrc, __pyx_n_get_bitsize); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; goto __pyx_L1;}
  __pyx_4 = PyObject_CallObject(__pyx_5, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_6 = PyInt_FromLong(32); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; goto __pyx_L1;}
  if (PyObject_Cmp(__pyx_4, __pyx_6, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; goto __pyx_L1;}
  __pyx_3 = __pyx_3 == 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  if (__pyx_3) {
    __pyx_7 = PyString_AsString(__pyx_v_r); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; goto __pyx_L1;}
    __pyx_8 = PyString_AsString(__pyx_v_g); if (!__pyx_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; goto __pyx_L1;}
    __pyx_9 = PyString_AsString(__pyx_v_b); if (!__pyx_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; goto __pyx_L1;}
    __pyx_10 = PyString_AsString(__pyx_v_a); if (!__pyx_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; goto __pyx_L1;}
    map32_core(__pyx_v_pysrc,__pyx_v_pydst,__pyx_7,__pyx_8,__pyx_9,__pyx_10);
    goto __pyx_L7;
  }
  /*else*/ {
    __pyx_7 = PyString_AsString(__pyx_v_r); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; goto __pyx_L1;}
    __pyx_8 = PyString_AsString(__pyx_v_g); if (!__pyx_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; goto __pyx_L1;}
    __pyx_9 = PyString_AsString(__pyx_v_b); if (!__pyx_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; goto __pyx_L1;}
    map24_core(__pyx_v_pysrc,__pyx_v_pydst,__pyx_7,__pyx_8,__pyx_9);
  }
  __pyx_L7:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("_renpy.map");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_pysrc);
  Py_DECREF(__pyx_v_pydst);
  Py_DECREF(__pyx_v_r);
  Py_DECREF(__pyx_v_g);
  Py_DECREF(__pyx_v_b);
  Py_DECREF(__pyx_v_a);
  return __pyx_r;
}

static PyObject *__pyx_k21p;
static PyObject *__pyx_k22p;
static PyObject *__pyx_k23p;
static PyObject *__pyx_k24p;
static PyObject *__pyx_k25p;

static char __pyx_k21[] = "map requires a pygame Surface as its first argument.";
static char __pyx_k22[] = "map requires a pygame Surface as its second argument.";
static char __pyx_k23[] = "map requires a 24 or 32 bit surface.";
static char __pyx_k24[] = "map requires both surfaces have the same bitsize.";
static char __pyx_k25[] = "map requires both surfaces have the same size.";

static PyObject *__pyx_f_6_renpy_linmap(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_6_renpy_linmap(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_pysrc = 0;
  PyObject *__pyx_v_pydst = 0;
  PyObject *__pyx_v_r = 0;
  PyObject *__pyx_v_g = 0;
  PyObject *__pyx_v_b = 0;
  PyObject *__pyx_v_a = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  int __pyx_7;
  int __pyx_8;
  static char *__pyx_argnames[] = {"pysrc","pydst","r","g","b","a",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOOOOO", __pyx_argnames, &__pyx_v_pysrc, &__pyx_v_pydst, &__pyx_v_r, &__pyx_v_g, &__pyx_v_b, &__pyx_v_a)) return 0;
  Py_INCREF(__pyx_v_pysrc);
  Py_INCREF(__pyx_v_pydst);
  Py_INCREF(__pyx_v_r);
  Py_INCREF(__pyx_v_g);
  Py_INCREF(__pyx_v_b);
  Py_INCREF(__pyx_v_a);

  /* "/home/tom/ab/renpy/module/_renpy.pyx":170 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_PygameSurface); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; goto __pyx_L1;}
  __pyx_2 = PyObject_IsInstance(__pyx_v_pysrc,__pyx_1); if (__pyx_2 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_3 = (!__pyx_2);
  if (__pyx_3) {
    __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; goto __pyx_L1;}
    Py_INCREF(__pyx_k21p);
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k21p);
    __pyx_4 = PyObject_CallObject(PyExc_Exception, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":173 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_PygameSurface); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; goto __pyx_L1;}
  __pyx_2 = PyObject_IsInstance(__pyx_v_pydst,__pyx_1); if (__pyx_2 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_3 = (!__pyx_2);
  if (__pyx_3) {
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; goto __pyx_L1;}
    Py_INCREF(__pyx_k22p);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k22p);
    __pyx_1 = PyObject_CallObject(PyExc_Exception, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __Pyx_Raise(__pyx_1, 0, 0);
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; goto __pyx_L1;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":176 */
  __pyx_4 = PyObject_GetAttr(__pyx_v_pysrc, __pyx_n_get_bitsize); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; goto __pyx_L1;}
  __pyx_1 = PyObject_CallObject(__pyx_4, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  __pyx_4 = PyInt_FromLong(24); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; goto __pyx_L1;}
  __pyx_5 = PyInt_FromLong(32); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_6, 0, __pyx_4);
  PyTuple_SET_ITEM(__pyx_6, 1, __pyx_5);
  __pyx_4 = 0;
  __pyx_5 = 0;
  __pyx_2 = PySequence_Contains(__pyx_6, __pyx_1); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; goto __pyx_L1;}
  __pyx_2 = !__pyx_2;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  if (__pyx_2) {
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;}
    Py_INCREF(__pyx_k23p);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k23p);
    __pyx_5 = PyObject_CallObject(PyExc_Exception, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __Pyx_Raise(__pyx_5, 0, 0);
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":179 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_pydst, __pyx_n_get_bitsize); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; goto __pyx_L1;}
  __pyx_6 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_4 = PyObject_GetAttr(__pyx_v_pysrc, __pyx_n_get_bitsize); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; goto __pyx_L1;}
  __pyx_5 = PyObject_CallObject(__pyx_4, 0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  if (PyObject_Cmp(__pyx_6, __pyx_5, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; goto __pyx_L1;}
  __pyx_3 = __pyx_3 != 0;
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  if (__pyx_3) {
    __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; goto __pyx_L1;}
    Py_INCREF(__pyx_k24p);
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k24p);
    __pyx_4 = PyObject_CallObject(PyExc_Exception, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; goto __pyx_L1;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":182 */
  __pyx_6 = PyObject_GetAttr(__pyx_v_pydst, __pyx_n_get_size); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; goto __pyx_L1;}
  __pyx_5 = PyObject_CallObject(__pyx_6, 0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; goto __pyx_L1;}
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  __pyx_1 = PyObject_GetAttr(__pyx_v_pysrc, __pyx_n_get_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; goto __pyx_L1;}
  __pyx_4 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (PyObject_Cmp(__pyx_5, __pyx_4, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; goto __pyx_L1;}
  __pyx_2 = __pyx_2 != 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  if (__pyx_2) {
    __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; goto __pyx_L1;}
    Py_INCREF(__pyx_k25p);
    PyTuple_SET_ITEM(__pyx_6, 0, __pyx_k25p);
    __pyx_1 = PyObject_CallObject(PyExc_Exception, __pyx_6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; goto __pyx_L1;}
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    __Pyx_Raise(__pyx_1, 0, 0);
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; goto __pyx_L1;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":188 */
  __pyx_5 = PyObject_GetAttr(__pyx_v_pysrc, __pyx_n_get_bitsize); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; goto __pyx_L1;}
  __pyx_4 = PyObject_CallObject(__pyx_5, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_6 = PyInt_FromLong(32); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; goto __pyx_L1;}
  if (PyObject_Cmp(__pyx_4, __pyx_6, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; goto __pyx_L1;}
  __pyx_3 = __pyx_3 == 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  if (__pyx_3) {
    __pyx_2 = PyInt_AsLong(__pyx_v_r); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; goto __pyx_L1;}
    __pyx_3 = PyInt_AsLong(__pyx_v_g); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; goto __pyx_L1;}
    __pyx_7 = PyInt_AsLong(__pyx_v_b); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; goto __pyx_L1;}
    __pyx_8 = PyInt_AsLong(__pyx_v_a); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; goto __pyx_L1;}
    linmap32_core(__pyx_v_pysrc,__pyx_v_pydst,__pyx_2,__pyx_3,__pyx_7,__pyx_8);
    goto __pyx_L7;
  }
  /*else*/ {
    __pyx_2 = PyInt_AsLong(__pyx_v_r); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; goto __pyx_L1;}
    __pyx_3 = PyInt_AsLong(__pyx_v_g); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; goto __pyx_L1;}
    __pyx_7 = PyInt_AsLong(__pyx_v_b); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; goto __pyx_L1;}
    linmap24_core(__pyx_v_pysrc,__pyx_v_pydst,__pyx_2,__pyx_3,__pyx_7);
  }
  __pyx_L7:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("_renpy.linmap");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_pysrc);
  Py_DECREF(__pyx_v_pydst);
  Py_DECREF(__pyx_v_r);
  Py_DECREF(__pyx_v_g);
  Py_DECREF(__pyx_v_b);
  Py_DECREF(__pyx_v_a);
  return __pyx_r;
}

static PyObject *__pyx_k26p;
static PyObject *__pyx_k27p;
static PyObject *__pyx_k28p;
static PyObject *__pyx_k29p;
static PyObject *__pyx_k30p;

static char __pyx_k26[] = "alpha_munge requires a pygame Surface as its first argument.";
static char __pyx_k27[] = "alpha_munge requires a pygame Surface as its second argument.";
static char __pyx_k28[] = "alpha_munge requires a 24 or 32 bit surface.";
static char __pyx_k29[] = "alpha_munge requires both surfaces have the same bitsize.";
static char __pyx_k30[] = "alpha_munge requires both surfaces have the same size.";

static PyObject *__pyx_f_6_renpy_alpha_munge(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_6_renpy_alpha_munge(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_pysrc = 0;
  PyObject *__pyx_v_pydst = 0;
  PyObject *__pyx_v_srcchan = 0;
  PyObject *__pyx_v_dstchan = 0;
  PyObject *__pyx_v_amap = 0;
  PyObject *__pyx_v_bytes;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  int __pyx_7;
  char *__pyx_8;
  static char *__pyx_argnames[] = {"pysrc","pydst","srcchan","dstchan","amap",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOOOO", __pyx_argnames, &__pyx_v_pysrc, &__pyx_v_pydst, &__pyx_v_srcchan, &__pyx_v_dstchan, &__pyx_v_amap)) return 0;
  Py_INCREF(__pyx_v_pysrc);
  Py_INCREF(__pyx_v_pydst);
  Py_INCREF(__pyx_v_srcchan);
  Py_INCREF(__pyx_v_dstchan);
  Py_INCREF(__pyx_v_amap);
  __pyx_v_bytes = Py_None; Py_INCREF(Py_None);

  /* "/home/tom/ab/renpy/module/_renpy.pyx":199 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_PygameSurface); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; goto __pyx_L1;}
  __pyx_2 = PyObject_IsInstance(__pyx_v_pysrc,__pyx_1); if (__pyx_2 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_3 = (!__pyx_2);
  if (__pyx_3) {
    __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; goto __pyx_L1;}
    Py_INCREF(__pyx_k26p);
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k26p);
    __pyx_4 = PyObject_CallObject(PyExc_Exception, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":202 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_PygameSurface); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; goto __pyx_L1;}
  __pyx_2 = PyObject_IsInstance(__pyx_v_pydst,__pyx_1); if (__pyx_2 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_3 = (!__pyx_2);
  if (__pyx_3) {
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; goto __pyx_L1;}
    Py_INCREF(__pyx_k27p);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k27p);
    __pyx_1 = PyObject_CallObject(PyExc_Exception, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __Pyx_Raise(__pyx_1, 0, 0);
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; goto __pyx_L1;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":205 */
  __pyx_4 = PyObject_GetAttr(__pyx_v_pysrc, __pyx_n_get_bitsize); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; goto __pyx_L1;}
  __pyx_1 = PyObject_CallObject(__pyx_4, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  __pyx_4 = PyInt_FromLong(24); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; goto __pyx_L1;}
  __pyx_5 = PyInt_FromLong(32); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_6, 0, __pyx_4);
  PyTuple_SET_ITEM(__pyx_6, 1, __pyx_5);
  __pyx_4 = 0;
  __pyx_5 = 0;
  __pyx_2 = PySequence_Contains(__pyx_6, __pyx_1); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; goto __pyx_L1;}
  __pyx_2 = !__pyx_2;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  if (__pyx_2) {
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; goto __pyx_L1;}
    Py_INCREF(__pyx_k28p);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k28p);
    __pyx_5 = PyObject_CallObject(PyExc_Exception, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __Pyx_Raise(__pyx_5, 0, 0);
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; goto __pyx_L1;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":208 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_pydst, __pyx_n_get_bitsize); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; goto __pyx_L1;}
  __pyx_6 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_4 = PyObject_GetAttr(__pyx_v_pysrc, __pyx_n_get_bitsize); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; goto __pyx_L1;}
  __pyx_5 = PyObject_CallObject(__pyx_4, 0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  if (PyObject_Cmp(__pyx_6, __pyx_5, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; goto __pyx_L1;}
  __pyx_3 = __pyx_3 != 0;
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  if (__pyx_3) {
    __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; goto __pyx_L1;}
    Py_INCREF(__pyx_k29p);
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k29p);
    __pyx_4 = PyObject_CallObject(PyExc_Exception, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; goto __pyx_L1;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":211 */
  __pyx_6 = PyObject_GetAttr(__pyx_v_pydst, __pyx_n_get_size); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;}
  __pyx_5 = PyObject_CallObject(__pyx_6, 0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;}
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  __pyx_1 = PyObject_GetAttr(__pyx_v_pysrc, __pyx_n_get_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;}
  __pyx_4 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (PyObject_Cmp(__pyx_5, __pyx_4, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;}
  __pyx_2 = __pyx_2 != 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  if (__pyx_2) {
    __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; goto __pyx_L1;}
    Py_INCREF(__pyx_k30p);
    PyTuple_SET_ITEM(__pyx_6, 0, __pyx_k30p);
    __pyx_1 = PyObject_CallObject(PyExc_Exception, __pyx_6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; goto __pyx_L1;}
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    __Pyx_Raise(__pyx_1, 0, 0);
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; goto __pyx_L1;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":215 */
  __pyx_5 = PyObject_GetAttr(__pyx_v_pysrc, __pyx_n_get_bitsize); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; goto __pyx_L1;}
  __pyx_4 = PyObject_CallObject(__pyx_5, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_6 = PyInt_FromLong(24); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; goto __pyx_L1;}
  if (PyObject_Cmp(__pyx_4, __pyx_6, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; goto __pyx_L1;}
  __pyx_3 = __pyx_3 == 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  if (__pyx_3) {
    __pyx_1 = PyInt_FromLong(3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; goto __pyx_L1;}
    Py_DECREF(__pyx_v_bytes);
    __pyx_v_bytes = __pyx_1;
    __pyx_1 = 0;
    goto __pyx_L7;
  }
  /*else*/ {
    __pyx_5 = PyInt_FromLong(4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; goto __pyx_L1;}
    Py_DECREF(__pyx_v_bytes);
    __pyx_v_bytes = __pyx_5;
    __pyx_5 = 0;
  }
  __pyx_L7:;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":223 */
  __pyx_2 = PyInt_AsLong(__pyx_v_bytes); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;}
  __pyx_3 = PyInt_AsLong(__pyx_v_srcchan); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;}
  __pyx_7 = PyInt_AsLong(__pyx_v_dstchan); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;}
  __pyx_8 = PyString_AsString(__pyx_v_amap); if (!__pyx_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;}
  alphamunge_core(__pyx_v_pysrc,__pyx_v_pydst,__pyx_2,__pyx_3,__pyx_7,__pyx_8);

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("_renpy.alpha_munge");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_bytes);
  Py_DECREF(__pyx_v_pysrc);
  Py_DECREF(__pyx_v_pydst);
  Py_DECREF(__pyx_v_srcchan);
  Py_DECREF(__pyx_v_dstchan);
  Py_DECREF(__pyx_v_amap);
  return __pyx_r;
}

static PyObject *__pyx_k31p;
static PyObject *__pyx_k32p;
static PyObject *__pyx_k33p;
static PyObject *__pyx_k34p;

static char __pyx_k31[] = "bilinear requires a pygame Surface as its first argument.";
static char __pyx_k32[] = "bilinear requires a pygame Surface as its second argument.";
static char __pyx_k33[] = "bilinear requires a 24 or 32 bit surface.";
static char __pyx_k34[] = "bilinear requires both surfaces have the same bitsize.";

static PyObject *__pyx_f_6_renpy_bilinear(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_6_renpy_bilinear(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_pysrc = 0;
  PyObject *__pyx_v_pydst = 0;
  PyObject *__pyx_v_source_xoff = 0;
  PyObject *__pyx_v_source_yoff = 0;
  PyObject *__pyx_v_source_width = 0;
  PyObject *__pyx_v_source_height = 0;
  PyObject *__pyx_v_dest_xoff = 0;
  PyObject *__pyx_v_dest_yoff = 0;
  PyObject *__pyx_v_dest_width = 0;
  PyObject *__pyx_v_dest_height = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  float __pyx_7;
  float __pyx_8;
  float __pyx_9;
  float __pyx_10;
  float __pyx_11;
  float __pyx_12;
  float __pyx_13;
  float __pyx_14;
  static char *__pyx_argnames[] = {"pysrc","pydst","source_xoff","source_yoff","source_width","source_height","dest_xoff","dest_yoff","dest_width","dest_height",0};
  __pyx_v_source_xoff = __pyx_k3;
  __pyx_v_source_yoff = __pyx_k4;
  __pyx_v_source_width = __pyx_k5;
  __pyx_v_source_height = __pyx_k6;
  __pyx_v_dest_xoff = __pyx_k7;
  __pyx_v_dest_yoff = __pyx_k8;
  __pyx_v_dest_width = __pyx_k9;
  __pyx_v_dest_height = __pyx_k10;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|OOOOOOOO", __pyx_argnames, &__pyx_v_pysrc, &__pyx_v_pydst, &__pyx_v_source_xoff, &__pyx_v_source_yoff, &__pyx_v_source_width, &__pyx_v_source_height, &__pyx_v_dest_xoff, &__pyx_v_dest_yoff, &__pyx_v_dest_width, &__pyx_v_dest_height)) return 0;
  Py_INCREF(__pyx_v_pysrc);
  Py_INCREF(__pyx_v_pydst);
  Py_INCREF(__pyx_v_source_xoff);
  Py_INCREF(__pyx_v_source_yoff);
  Py_INCREF(__pyx_v_source_width);
  Py_INCREF(__pyx_v_source_height);
  Py_INCREF(__pyx_v_dest_xoff);
  Py_INCREF(__pyx_v_dest_yoff);
  Py_INCREF(__pyx_v_dest_width);
  Py_INCREF(__pyx_v_dest_height);

  /* "/home/tom/ab/renpy/module/_renpy.pyx":286 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_PygameSurface); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; goto __pyx_L1;}
  __pyx_2 = PyObject_IsInstance(__pyx_v_pysrc,__pyx_1); if (__pyx_2 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_3 = (!__pyx_2);
  if (__pyx_3) {
    __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; goto __pyx_L1;}
    Py_INCREF(__pyx_k31p);
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k31p);
    __pyx_4 = PyObject_CallObject(PyExc_Exception, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":289 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_PygameSurface); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;}
  __pyx_2 = PyObject_IsInstance(__pyx_v_pydst,__pyx_1); if (__pyx_2 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_3 = (!__pyx_2);
  if (__pyx_3) {
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;}
    Py_INCREF(__pyx_k32p);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k32p);
    __pyx_1 = PyObject_CallObject(PyExc_Exception, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __Pyx_Raise(__pyx_1, 0, 0);
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":292 */
  __pyx_4 = PyObject_GetAttr(__pyx_v_pysrc, __pyx_n_get_bitsize); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; goto __pyx_L1;}
  __pyx_1 = PyObject_CallObject(__pyx_4, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  __pyx_4 = PyInt_FromLong(24); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; goto __pyx_L1;}
  __pyx_5 = PyInt_FromLong(32); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_6, 0, __pyx_4);
  PyTuple_SET_ITEM(__pyx_6, 1, __pyx_5);
  __pyx_4 = 0;
  __pyx_5 = 0;
  __pyx_2 = PySequence_Contains(__pyx_6, __pyx_1); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; goto __pyx_L1;}
  __pyx_2 = !__pyx_2;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  if (__pyx_2) {
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; goto __pyx_L1;}
    Py_INCREF(__pyx_k33p);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k33p);
    __pyx_5 = PyObject_CallObject(PyExc_Exception, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __Pyx_Raise(__pyx_5, 0, 0);
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; goto __pyx_L1;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":295 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_pydst, __pyx_n_get_bitsize); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; goto __pyx_L1;}
  __pyx_6 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_4 = PyObject_GetAttr(__pyx_v_pysrc, __pyx_n_get_bitsize); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; goto __pyx_L1;}
  __pyx_5 = PyObject_CallObject(__pyx_4, 0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  if (PyObject_Cmp(__pyx_6, __pyx_5, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; goto __pyx_L1;}
  __pyx_3 = __pyx_3 != 0;
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  if (__pyx_3) {
    __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; goto __pyx_L1;}
    Py_INCREF(__pyx_k34p);
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k34p);
    __pyx_4 = PyObject_CallObject(PyExc_Exception, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; goto __pyx_L1;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":298 */
  __pyx_2 = __pyx_v_source_width == Py_None;
  if (!__pyx_2) {
    __pyx_2 = __pyx_v_source_height == Py_None;
  }
  if (__pyx_2) {
    __pyx_6 = PyObject_GetAttr(__pyx_v_pysrc, __pyx_n_get_size); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; goto __pyx_L1;}
    __pyx_5 = PyObject_CallObject(__pyx_6, 0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; goto __pyx_L1;}
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    __pyx_1 = PyObject_GetIter(__pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __pyx_4 = __Pyx_UnpackItem(__pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; goto __pyx_L1;}
    Py_DECREF(__pyx_v_source_width);
    __pyx_v_source_width = __pyx_4;
    __pyx_4 = 0;
    __pyx_6 = __Pyx_UnpackItem(__pyx_1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; goto __pyx_L1;}
    Py_DECREF(__pyx_v_source_height);
    __pyx_v_source_height = __pyx_6;
    __pyx_6 = 0;
    if (__Pyx_EndUnpack(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":301 */
  __pyx_3 = __pyx_v_dest_width == Py_None;
  if (!__pyx_3) {
    __pyx_3 = __pyx_v_dest_height == Py_None;
  }
  if (__pyx_3) {
    __pyx_5 = PyObject_GetAttr(__pyx_v_pydst, __pyx_n_get_size); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; goto __pyx_L1;}
    __pyx_4 = PyObject_CallObject(__pyx_5, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __pyx_6 = PyObject_GetIter(__pyx_4); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_1 = __Pyx_UnpackItem(__pyx_6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; goto __pyx_L1;}
    Py_DECREF(__pyx_v_dest_width);
    __pyx_v_dest_width = __pyx_1;
    __pyx_1 = 0;
    __pyx_5 = __Pyx_UnpackItem(__pyx_6); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; goto __pyx_L1;}
    Py_DECREF(__pyx_v_dest_height);
    __pyx_v_dest_height = __pyx_5;
    __pyx_5 = 0;
    if (__Pyx_EndUnpack(__pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; goto __pyx_L1;}
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":307 */
  __pyx_4 = PyObject_GetAttr(__pyx_v_pysrc, __pyx_n_get_bitsize); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; goto __pyx_L1;}
  __pyx_1 = PyObject_CallObject(__pyx_4, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  __pyx_5 = PyInt_FromLong(32); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; goto __pyx_L1;}
  if (PyObject_Cmp(__pyx_1, __pyx_5, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; goto __pyx_L1;}
  __pyx_2 = __pyx_2 == 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  if (__pyx_2) {
    __pyx_7 = PyFloat_AsDouble(__pyx_v_source_xoff); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; goto __pyx_L1;}
    __pyx_8 = PyFloat_AsDouble(__pyx_v_source_yoff); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; goto __pyx_L1;}
    __pyx_9 = PyFloat_AsDouble(__pyx_v_source_width); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; goto __pyx_L1;}
    __pyx_10 = PyFloat_AsDouble(__pyx_v_source_height); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; goto __pyx_L1;}
    __pyx_11 = PyFloat_AsDouble(__pyx_v_dest_xoff); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; goto __pyx_L1;}
    __pyx_12 = PyFloat_AsDouble(__pyx_v_dest_yoff); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; goto __pyx_L1;}
    __pyx_13 = PyFloat_AsDouble(__pyx_v_dest_width); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; goto __pyx_L1;}
    __pyx_14 = PyFloat_AsDouble(__pyx_v_dest_height); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; goto __pyx_L1;}
    scale32_core(__pyx_v_pysrc,__pyx_v_pydst,__pyx_7,__pyx_8,__pyx_9,__pyx_10,__pyx_11,__pyx_12,__pyx_13,__pyx_14);
    goto __pyx_L8;
  }
  /*else*/ {
    __pyx_7 = PyFloat_AsDouble(__pyx_v_source_xoff); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; goto __pyx_L1;}
    __pyx_8 = PyFloat_AsDouble(__pyx_v_source_yoff); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; goto __pyx_L1;}
    __pyx_9 = PyFloat_AsDouble(__pyx_v_source_width); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; goto __pyx_L1;}
    __pyx_10 = PyFloat_AsDouble(__pyx_v_source_height); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; goto __pyx_L1;}
    __pyx_11 = PyFloat_AsDouble(__pyx_v_dest_xoff); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; goto __pyx_L1;}
    __pyx_12 = PyFloat_AsDouble(__pyx_v_dest_yoff); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; goto __pyx_L1;}
    __pyx_13 = PyFloat_AsDouble(__pyx_v_dest_width); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; goto __pyx_L1;}
    __pyx_14 = PyFloat_AsDouble(__pyx_v_dest_height); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; goto __pyx_L1;}
    scale24_core(__pyx_v_pysrc,__pyx_v_pydst,__pyx_7,__pyx_8,__pyx_9,__pyx_10,__pyx_11,__pyx_12,__pyx_13,__pyx_14);
  }
  __pyx_L8:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("_renpy.bilinear");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_pysrc);
  Py_DECREF(__pyx_v_pydst);
  Py_DECREF(__pyx_v_source_xoff);
  Py_DECREF(__pyx_v_source_yoff);
  Py_DECREF(__pyx_v_source_width);
  Py_DECREF(__pyx_v_source_height);
  Py_DECREF(__pyx_v_dest_xoff);
  Py_DECREF(__pyx_v_dest_yoff);
  Py_DECREF(__pyx_v_dest_width);
  Py_DECREF(__pyx_v_dest_height);
  return __pyx_r;
}

static PyObject *__pyx_k35p;
static PyObject *__pyx_k36p;

static char __pyx_k35[] = "Surface must be a pygame surface.";
static char __pyx_k36[] = "Surface must be 32-bit.";

static PyObject *__pyx_f_6_renpy_check(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_6_renpy_check(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_surf = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {"surf",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_surf)) return 0;
  Py_INCREF(__pyx_v_surf);

  /* "/home/tom/ab/renpy/module/_renpy.pyx":323 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_PygameSurface); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; goto __pyx_L1;}
  __pyx_2 = PyObject_IsInstance(__pyx_v_surf,__pyx_1); if (__pyx_2 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_3 = (!__pyx_2);
  if (__pyx_3) {
    __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; goto __pyx_L1;}
    Py_INCREF(__pyx_k35p);
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k35p);
    __pyx_4 = PyObject_CallObject(PyExc_Exception, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":326 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_surf, __pyx_n_get_bitsize); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;}
  __pyx_4 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyInt_FromLong(32); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;}
  if (PyObject_Cmp(__pyx_4, __pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;}
  __pyx_2 = __pyx_2 != 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (__pyx_2) {
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; goto __pyx_L1;}
    Py_INCREF(__pyx_k36p);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k36p);
    __pyx_1 = PyObject_CallObject(PyExc_Exception, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __Pyx_Raise(__pyx_1, 0, 0);
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; goto __pyx_L1;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_renpy.check");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_surf);
  return __pyx_r;
}

static PyObject *__pyx_n_check;

static PyObject *__pyx_f_6_renpy_transform(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_6_renpy_transform(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_pysrc = 0;
  PyObject *__pyx_v_pydst = 0;
  PyObject *__pyx_v_corner_x = 0;
  PyObject *__pyx_v_corner_y = 0;
  PyObject *__pyx_v_xdx = 0;
  PyObject *__pyx_v_ydx = 0;
  PyObject *__pyx_v_xdy = 0;
  PyObject *__pyx_v_ydy = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  float __pyx_4;
  float __pyx_5;
  float __pyx_6;
  float __pyx_7;
  float __pyx_8;
  float __pyx_9;
  static char *__pyx_argnames[] = {"pysrc","pydst","corner_x","corner_y","xdx","ydx","xdy","ydy",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOOOOOOO", __pyx_argnames, &__pyx_v_pysrc, &__pyx_v_pydst, &__pyx_v_corner_x, &__pyx_v_corner_y, &__pyx_v_xdx, &__pyx_v_ydx, &__pyx_v_xdy, &__pyx_v_ydy)) return 0;
  Py_INCREF(__pyx_v_pysrc);
  Py_INCREF(__pyx_v_pydst);
  Py_INCREF(__pyx_v_corner_x);
  Py_INCREF(__pyx_v_corner_y);
  Py_INCREF(__pyx_v_xdx);
  Py_INCREF(__pyx_v_ydx);
  Py_INCREF(__pyx_v_xdy);
  Py_INCREF(__pyx_v_ydy);

  /* "/home/tom/ab/renpy/module/_renpy.pyx":334 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_check); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; goto __pyx_L1;}
  Py_INCREF(__pyx_v_pysrc);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_pysrc);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":335 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_check); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; goto __pyx_L1;}
  Py_INCREF(__pyx_v_pydst);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_pydst);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":340 */
  __pyx_4 = PyFloat_AsDouble(__pyx_v_corner_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; goto __pyx_L1;}
  __pyx_5 = PyFloat_AsDouble(__pyx_v_corner_y); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; goto __pyx_L1;}
  __pyx_6 = PyFloat_AsDouble(__pyx_v_xdx); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; goto __pyx_L1;}
  __pyx_7 = PyFloat_AsDouble(__pyx_v_ydx); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; goto __pyx_L1;}
  __pyx_8 = PyFloat_AsDouble(__pyx_v_xdy); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; goto __pyx_L1;}
  __pyx_9 = PyFloat_AsDouble(__pyx_v_ydy); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; goto __pyx_L1;}
  transform32_core(__pyx_v_pysrc,__pyx_v_pydst,__pyx_4,__pyx_5,__pyx_6,__pyx_7,__pyx_8,__pyx_9);

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_renpy.transform");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_pysrc);
  Py_DECREF(__pyx_v_pydst);
  Py_DECREF(__pyx_v_corner_x);
  Py_DECREF(__pyx_v_corner_y);
  Py_DECREF(__pyx_v_xdx);
  Py_DECREF(__pyx_v_ydx);
  Py_DECREF(__pyx_v_xdy);
  Py_DECREF(__pyx_v_ydy);
  return __pyx_r;
}

static PyObject *__pyx_f_6_renpy_blend(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_6_renpy_blend(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_pysrca = 0;
  PyObject *__pyx_v_pysrcb = 0;
  PyObject *__pyx_v_pydst = 0;
  PyObject *__pyx_v_alpha = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  static char *__pyx_argnames[] = {"pysrca","pysrcb","pydst","alpha",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOOO", __pyx_argnames, &__pyx_v_pysrca, &__pyx_v_pysrcb, &__pyx_v_pydst, &__pyx_v_alpha)) return 0;
  Py_INCREF(__pyx_v_pysrca);
  Py_INCREF(__pyx_v_pysrcb);
  Py_INCREF(__pyx_v_pydst);
  Py_INCREF(__pyx_v_alpha);

  /* "/home/tom/ab/renpy/module/_renpy.pyx":351 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_check); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; goto __pyx_L1;}
  Py_INCREF(__pyx_v_pysrca);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_pysrca);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":352 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_check); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; goto __pyx_L1;}
  Py_INCREF(__pyx_v_pysrcb);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_pysrcb);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":353 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_check); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;}
  Py_INCREF(__pyx_v_pydst);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_pydst);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":359 */
  __pyx_4 = PyInt_AsLong(__pyx_v_alpha); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; goto __pyx_L1;}
  blend32_core(__pyx_v_pysrca,__pyx_v_pysrcb,__pyx_v_pydst,__pyx_4);

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_renpy.blend");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_pysrca);
  Py_DECREF(__pyx_v_pysrcb);
  Py_DECREF(__pyx_v_pydst);
  Py_DECREF(__pyx_v_alpha);
  return __pyx_r;
}

static PyObject *__pyx_f_6_renpy_imageblend(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_6_renpy_imageblend(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_pysrca = 0;
  PyObject *__pyx_v_pysrcb = 0;
  PyObject *__pyx_v_pydst = 0;
  PyObject *__pyx_v_pyimg = 0;
  PyObject *__pyx_v_aoff = 0;
  PyObject *__pyx_v_amap = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  char *__pyx_5;
  static char *__pyx_argnames[] = {"pysrca","pysrcb","pydst","pyimg","aoff","amap",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOOOOO", __pyx_argnames, &__pyx_v_pysrca, &__pyx_v_pysrcb, &__pyx_v_pydst, &__pyx_v_pyimg, &__pyx_v_aoff, &__pyx_v_amap)) return 0;
  Py_INCREF(__pyx_v_pysrca);
  Py_INCREF(__pyx_v_pysrcb);
  Py_INCREF(__pyx_v_pydst);
  Py_INCREF(__pyx_v_pyimg);
  Py_INCREF(__pyx_v_aoff);
  Py_INCREF(__pyx_v_amap);

  /* "/home/tom/ab/renpy/module/_renpy.pyx":366 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_check); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; goto __pyx_L1;}
  Py_INCREF(__pyx_v_pysrca);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_pysrca);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":367 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_check); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; goto __pyx_L1;}
  Py_INCREF(__pyx_v_pysrcb);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_pysrcb);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":368 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_check); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; goto __pyx_L1;}
  Py_INCREF(__pyx_v_pydst);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_pydst);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":369 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_check); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; goto __pyx_L1;}
  Py_INCREF(__pyx_v_pyimg);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_pyimg);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":376 */
  __pyx_4 = PyInt_AsLong(__pyx_v_aoff); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; goto __pyx_L1;}
  __pyx_5 = PyString_AsString(__pyx_v_amap); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; goto __pyx_L1;}
  imageblend32_core(__pyx_v_pysrca,__pyx_v_pysrcb,__pyx_v_pydst,__pyx_v_pyimg,__pyx_4,__pyx_5);

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_renpy.imageblend");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_pysrca);
  Py_DECREF(__pyx_v_pysrcb);
  Py_DECREF(__pyx_v_pydst);
  Py_DECREF(__pyx_v_pyimg);
  Py_DECREF(__pyx_v_aoff);
  Py_DECREF(__pyx_v_amap);
  return __pyx_r;
}

static PyObject *__pyx_f_6_renpy_colormatrix(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_6_renpy_colormatrix(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_pysrc = 0;
  PyObject *__pyx_v_pydst = 0;
  PyObject *__pyx_v_c00 = 0;
  PyObject *__pyx_v_c01 = 0;
  PyObject *__pyx_v_c02 = 0;
  PyObject *__pyx_v_c03 = 0;
  PyObject *__pyx_v_c04 = 0;
  PyObject *__pyx_v_c10 = 0;
  PyObject *__pyx_v_c11 = 0;
  PyObject *__pyx_v_c12 = 0;
  PyObject *__pyx_v_c13 = 0;
  PyObject *__pyx_v_c14 = 0;
  PyObject *__pyx_v_c20 = 0;
  PyObject *__pyx_v_c21 = 0;
  PyObject *__pyx_v_c22 = 0;
  PyObject *__pyx_v_c23 = 0;
  PyObject *__pyx_v_c24 = 0;
  PyObject *__pyx_v_c30 = 0;
  PyObject *__pyx_v_c31 = 0;
  PyObject *__pyx_v_c32 = 0;
  PyObject *__pyx_v_c33 = 0;
  PyObject *__pyx_v_c34 = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  float __pyx_4;
  float __pyx_5;
  float __pyx_6;
  float __pyx_7;
  float __pyx_8;
  float __pyx_9;
  float __pyx_10;
  float __pyx_11;
  float __pyx_12;
  float __pyx_13;
  float __pyx_14;
  float __pyx_15;
  float __pyx_16;
  float __pyx_17;
  float __pyx_18;
  float __pyx_19;
  float __pyx_20;
  float __pyx_21;
  float __pyx_22;
  float __pyx_23;
  static char *__pyx_argnames[] = {"pysrc","pydst","c00","c01","c02","c03","c04","c10","c11","c12","c13","c14","c20","c21","c22","c23","c24","c30","c31","c32","c33","c34",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOOOOOOOOOOOOOOOOOOOOO", __pyx_argnames, &__pyx_v_pysrc, &__pyx_v_pydst, &__pyx_v_c00, &__pyx_v_c01, &__pyx_v_c02, &__pyx_v_c03, &__pyx_v_c04, &__pyx_v_c10, &__pyx_v_c11, &__pyx_v_c12, &__pyx_v_c13, &__pyx_v_c14, &__pyx_v_c20, &__pyx_v_c21, &__pyx_v_c22, &__pyx_v_c23, &__pyx_v_c24, &__pyx_v_c30, &__pyx_v_c31, &__pyx_v_c32, &__pyx_v_c33, &__pyx_v_c34)) return 0;
  Py_INCREF(__pyx_v_pysrc);
  Py_INCREF(__pyx_v_pydst);
  Py_INCREF(__pyx_v_c00);
  Py_INCREF(__pyx_v_c01);
  Py_INCREF(__pyx_v_c02);
  Py_INCREF(__pyx_v_c03);
  Py_INCREF(__pyx_v_c04);
  Py_INCREF(__pyx_v_c10);
  Py_INCREF(__pyx_v_c11);
  Py_INCREF(__pyx_v_c12);
  Py_INCREF(__pyx_v_c13);
  Py_INCREF(__pyx_v_c14);
  Py_INCREF(__pyx_v_c20);
  Py_INCREF(__pyx_v_c21);
  Py_INCREF(__pyx_v_c22);
  Py_INCREF(__pyx_v_c23);
  Py_INCREF(__pyx_v_c24);
  Py_INCREF(__pyx_v_c30);
  Py_INCREF(__pyx_v_c31);
  Py_INCREF(__pyx_v_c32);
  Py_INCREF(__pyx_v_c33);
  Py_INCREF(__pyx_v_c34);

  /* "/home/tom/ab/renpy/module/_renpy.pyx":389 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_check); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; goto __pyx_L1;}
  Py_INCREF(__pyx_v_pysrc);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_pysrc);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":390 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_check); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; goto __pyx_L1;}
  Py_INCREF(__pyx_v_pydst);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_pydst);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":395 */
  __pyx_4 = PyFloat_AsDouble(__pyx_v_c00); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; goto __pyx_L1;}
  __pyx_5 = PyFloat_AsDouble(__pyx_v_c01); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; goto __pyx_L1;}
  __pyx_6 = PyFloat_AsDouble(__pyx_v_c02); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; goto __pyx_L1;}
  __pyx_7 = PyFloat_AsDouble(__pyx_v_c03); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; goto __pyx_L1;}
  __pyx_8 = PyFloat_AsDouble(__pyx_v_c04); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; goto __pyx_L1;}
  __pyx_9 = PyFloat_AsDouble(__pyx_v_c10); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}
  __pyx_10 = PyFloat_AsDouble(__pyx_v_c11); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}
  __pyx_11 = PyFloat_AsDouble(__pyx_v_c12); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}
  __pyx_12 = PyFloat_AsDouble(__pyx_v_c13); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}
  __pyx_13 = PyFloat_AsDouble(__pyx_v_c14); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}
  __pyx_14 = PyFloat_AsDouble(__pyx_v_c20); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; goto __pyx_L1;}
  __pyx_15 = PyFloat_AsDouble(__pyx_v_c21); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; goto __pyx_L1;}
  __pyx_16 = PyFloat_AsDouble(__pyx_v_c22); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; goto __pyx_L1;}
  __pyx_17 = PyFloat_AsDouble(__pyx_v_c23); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; goto __pyx_L1;}
  __pyx_18 = PyFloat_AsDouble(__pyx_v_c24); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; goto __pyx_L1;}
  __pyx_19 = PyFloat_AsDouble(__pyx_v_c30); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;}
  __pyx_20 = PyFloat_AsDouble(__pyx_v_c31); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;}
  __pyx_21 = PyFloat_AsDouble(__pyx_v_c32); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;}
  __pyx_22 = PyFloat_AsDouble(__pyx_v_c33); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;}
  __pyx_23 = PyFloat_AsDouble(__pyx_v_c34); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;}
  colormatrix32_core(__pyx_v_pysrc,__pyx_v_pydst,__pyx_4,__pyx_5,__pyx_6,__pyx_7,__pyx_8,__pyx_9,__pyx_10,__pyx_11,__pyx_12,__pyx_13,__pyx_14,__pyx_15,__pyx_16,__pyx_17,__pyx_18,__pyx_19,__pyx_20,__pyx_21,__pyx_22,__pyx_23);

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_renpy.colormatrix");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_pysrc);
  Py_DECREF(__pyx_v_pydst);
  Py_DECREF(__pyx_v_c00);
  Py_DECREF(__pyx_v_c01);
  Py_DECREF(__pyx_v_c02);
  Py_DECREF(__pyx_v_c03);
  Py_DECREF(__pyx_v_c04);
  Py_DECREF(__pyx_v_c10);
  Py_DECREF(__pyx_v_c11);
  Py_DECREF(__pyx_v_c12);
  Py_DECREF(__pyx_v_c13);
  Py_DECREF(__pyx_v_c14);
  Py_DECREF(__pyx_v_c20);
  Py_DECREF(__pyx_v_c21);
  Py_DECREF(__pyx_v_c22);
  Py_DECREF(__pyx_v_c23);
  Py_DECREF(__pyx_v_c24);
  Py_DECREF(__pyx_v_c30);
  Py_DECREF(__pyx_v_c31);
  Py_DECREF(__pyx_v_c32);
  Py_DECREF(__pyx_v_c33);
  Py_DECREF(__pyx_v_c34);
  return __pyx_r;
}

static PyObject *__pyx_f_6_renpy_staticgray(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_6_renpy_staticgray(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_pysrc = 0;
  PyObject *__pyx_v_pydst = 0;
  PyObject *__pyx_v_rmul = 0;
  PyObject *__pyx_v_gmul = 0;
  PyObject *__pyx_v_bmul = 0;
  PyObject *__pyx_v_amul = 0;
  PyObject *__pyx_v_shift = 0;
  PyObject *__pyx_v_vmap = 0;
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  int __pyx_3;
  int __pyx_4;
  int __pyx_5;
  char *__pyx_6;
  static char *__pyx_argnames[] = {"pysrc","pydst","rmul","gmul","bmul","amul","shift","vmap",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOOOOOOO", __pyx_argnames, &__pyx_v_pysrc, &__pyx_v_pydst, &__pyx_v_rmul, &__pyx_v_gmul, &__pyx_v_bmul, &__pyx_v_amul, &__pyx_v_shift, &__pyx_v_vmap)) return 0;
  Py_INCREF(__pyx_v_pysrc);
  Py_INCREF(__pyx_v_pydst);
  Py_INCREF(__pyx_v_rmul);
  Py_INCREF(__pyx_v_gmul);
  Py_INCREF(__pyx_v_bmul);
  Py_INCREF(__pyx_v_amul);
  Py_INCREF(__pyx_v_shift);
  Py_INCREF(__pyx_v_vmap);

  /* "/home/tom/ab/renpy/module/_renpy.pyx":406 */
  PyErr_Clear();

  /* "/home/tom/ab/renpy/module/_renpy.pyx":407 */
  __pyx_1 = PyInt_AsLong(__pyx_v_rmul); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; goto __pyx_L1;}
  __pyx_2 = PyInt_AsLong(__pyx_v_gmul); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; goto __pyx_L1;}
  __pyx_3 = PyInt_AsLong(__pyx_v_bmul); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; goto __pyx_L1;}
  __pyx_4 = PyInt_AsLong(__pyx_v_amul); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; goto __pyx_L1;}
  __pyx_5 = PyInt_AsLong(__pyx_v_shift); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; goto __pyx_L1;}
  __pyx_6 = PyString_AsString(__pyx_v_vmap); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; goto __pyx_L1;}
  staticgray_core(__pyx_v_pysrc,__pyx_v_pydst,__pyx_1,__pyx_2,__pyx_3,__pyx_4,__pyx_5,__pyx_6);

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_renpy.staticgray");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_pysrc);
  Py_DECREF(__pyx_v_pydst);
  Py_DECREF(__pyx_v_rmul);
  Py_DECREF(__pyx_v_gmul);
  Py_DECREF(__pyx_v_bmul);
  Py_DECREF(__pyx_v_amul);
  Py_DECREF(__pyx_v_shift);
  Py_DECREF(__pyx_v_vmap);
  return __pyx_r;
}

static __Pyx_InternTabEntry __pyx_intern_tab[] = {
  {&__pyx_n_PygameSurface, "PygameSurface"},
  {&__pyx_n_Surface, "Surface"},
  {&__pyx_n_check, "check"},
  {&__pyx_n_get_bitsize, "get_bitsize"},
  {&__pyx_n_get_size, "get_size"},
  {&__pyx_n_pygame, "pygame"},
  {0, 0}
};

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_k11p, __pyx_k11, sizeof(__pyx_k11)},
  {&__pyx_k12p, __pyx_k12, sizeof(__pyx_k12)},
  {&__pyx_k13p, __pyx_k13, sizeof(__pyx_k13)},
  {&__pyx_k14p, __pyx_k14, sizeof(__pyx_k14)},
  {&__pyx_k15p, __pyx_k15, sizeof(__pyx_k15)},
  {&__pyx_k16p, __pyx_k16, sizeof(__pyx_k16)},
  {&__pyx_k17p, __pyx_k17, sizeof(__pyx_k17)},
  {&__pyx_k18p, __pyx_k18, sizeof(__pyx_k18)},
  {&__pyx_k19p, __pyx_k19, sizeof(__pyx_k19)},
  {&__pyx_k20p, __pyx_k20, sizeof(__pyx_k20)},
  {&__pyx_k21p, __pyx_k21, sizeof(__pyx_k21)},
  {&__pyx_k22p, __pyx_k22, sizeof(__pyx_k22)},
  {&__pyx_k23p, __pyx_k23, sizeof(__pyx_k23)},
  {&__pyx_k24p, __pyx_k24, sizeof(__pyx_k24)},
  {&__pyx_k25p, __pyx_k25, sizeof(__pyx_k25)},
  {&__pyx_k26p, __pyx_k26, sizeof(__pyx_k26)},
  {&__pyx_k27p, __pyx_k27, sizeof(__pyx_k27)},
  {&__pyx_k28p, __pyx_k28, sizeof(__pyx_k28)},
  {&__pyx_k29p, __pyx_k29, sizeof(__pyx_k29)},
  {&__pyx_k30p, __pyx_k30, sizeof(__pyx_k30)},
  {&__pyx_k31p, __pyx_k31, sizeof(__pyx_k31)},
  {&__pyx_k32p, __pyx_k32, sizeof(__pyx_k32)},
  {&__pyx_k33p, __pyx_k33, sizeof(__pyx_k33)},
  {&__pyx_k34p, __pyx_k34, sizeof(__pyx_k34)},
  {&__pyx_k35p, __pyx_k35, sizeof(__pyx_k35)},
  {&__pyx_k36p, __pyx_k36, sizeof(__pyx_k36)},
  {0, 0, 0}
};

static struct PyMethodDef __pyx_methods[] = {
  {"version", (PyCFunction)__pyx_f_6_renpy_version, METH_VARARGS|METH_KEYWORDS, 0},
  {"save_png", (PyCFunction)__pyx_f_6_renpy_save_png, METH_VARARGS|METH_KEYWORDS, 0},
  {"pixellate", (PyCFunction)__pyx_f_6_renpy_pixellate, METH_VARARGS|METH_KEYWORDS, 0},
  {"map", (PyCFunction)__pyx_f_6_renpy_map, METH_VARARGS|METH_KEYWORDS, 0},
  {"linmap", (PyCFunction)__pyx_f_6_renpy_linmap, METH_VARARGS|METH_KEYWORDS, 0},
  {"alpha_munge", (PyCFunction)__pyx_f_6_renpy_alpha_munge, METH_VARARGS|METH_KEYWORDS, 0},
  {"bilinear", (PyCFunction)__pyx_f_6_renpy_bilinear, METH_VARARGS|METH_KEYWORDS, 0},
  {"check", (PyCFunction)__pyx_f_6_renpy_check, METH_VARARGS|METH_KEYWORDS, 0},
  {"transform", (PyCFunction)__pyx_f_6_renpy_transform, METH_VARARGS|METH_KEYWORDS, 0},
  {"blend", (PyCFunction)__pyx_f_6_renpy_blend, METH_VARARGS|METH_KEYWORDS, 0},
  {"imageblend", (PyCFunction)__pyx_f_6_renpy_imageblend, METH_VARARGS|METH_KEYWORDS, 0},
  {"colormatrix", (PyCFunction)__pyx_f_6_renpy_colormatrix, METH_VARARGS|METH_KEYWORDS, 0},
  {"staticgray", (PyCFunction)__pyx_f_6_renpy_staticgray, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static void __pyx_init_filenames(void); /*proto*/

PyMODINIT_FUNC init_renpy(void); /*proto*/
PyMODINIT_FUNC init_renpy(void) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  __pyx_init_filenames();
  __pyx_m = Py_InitModule4("_renpy", __pyx_methods, 0, 0, PYTHON_API_VERSION);
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; goto __pyx_L1;};
  Py_INCREF(__pyx_m);
  __pyx_b = PyImport_AddModule("__builtin__");
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; goto __pyx_L1;};
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; goto __pyx_L1;};
  if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; goto __pyx_L1;};
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; goto __pyx_L1;};

  /* "/home/tom/ab/renpy/module/_renpy.pyx":90 */
  __pyx_1 = __Pyx_Import(__pyx_n_pygame, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_pygame, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":92 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_pygame); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_Surface); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_PygameSurface, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":98 */
  __pyx_1 = PyInt_FromLong((-1)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; goto __pyx_L1;}
  __pyx_k2 = __pyx_1;
  __pyx_1 = 0;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":282 */
  __pyx_2 = PyFloat_FromDouble(0.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; goto __pyx_L1;}
  __pyx_k3 = __pyx_2;
  __pyx_2 = 0;
  __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; goto __pyx_L1;}
  __pyx_k4 = __pyx_3;
  __pyx_3 = 0;
  Py_INCREF(Py_None);
  __pyx_k5 = Py_None;
  Py_INCREF(Py_None);
  __pyx_k6 = Py_None;
  __pyx_4 = PyFloat_FromDouble(0.0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; goto __pyx_L1;}
  __pyx_k7 = __pyx_4;
  __pyx_4 = 0;
  __pyx_5 = PyFloat_FromDouble(0.0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; goto __pyx_L1;}
  __pyx_k8 = __pyx_5;
  __pyx_5 = 0;
  Py_INCREF(Py_None);
  __pyx_k9 = Py_None;
  Py_INCREF(Py_None);
  __pyx_k10 = Py_None;

  /* "/home/tom/ab/renpy/module/_renpy.pyx":412 */
  core_init();
  return;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_renpy");
}

static char *__pyx_filenames[] = {
  "_renpy.pyx",
};

/* Runtime support code */

static void __pyx_init_filenames(void) {
  __pyx_f = __pyx_filenames;
}

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
    PyObject *__import__ = 0;
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    __import__ = PyObject_GetAttrString(__pyx_b, "__import__");
    if (!__import__)
        goto bad;
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    module = PyObject_CallFunction(__import__, "OOOO",
        name, global_dict, empty_dict, list);
bad:
    Py_XDECREF(empty_list);
    Py_XDECREF(__import__);
    Py_XDECREF(empty_dict);
    return module;
}

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
    PyObject *result;
    result = PyObject_GetAttr(dict, name);
    if (!result)
        PyErr_SetObject(PyExc_NameError, name);
    return result;
}

static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
    Py_XINCREF(type);
    Py_XINCREF(value);
    Py_XINCREF(tb);
    /* First, check the traceback argument, replacing None with NULL. */
    if (tb == Py_None) {
        Py_DECREF(tb);
        tb = 0;
    }
    else if (tb != NULL && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto raise_error;
    }
    /* Next, replace a missing value with None */
    if (value == NULL) {
        value = Py_None;
        Py_INCREF(value);
    }
    #if PY_VERSION_HEX < 0x02050000
    if (!PyClass_Check(type))
    #else
    if (!PyType_Check(type))
    #endif
    {
        /* Raising an instance.  The value should be a dummy. */
        if (value != Py_None) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        /* Normalize to raise <class>, <instance> */
        Py_DECREF(value);
        value = type;
        #if PY_VERSION_HEX < 0x02050000
            if (PyInstance_Check(type)) {
                type = (PyObject*) ((PyInstanceObject*)type)->in_class;
                Py_INCREF(type);
            }
            else {
                PyErr_SetString(PyExc_TypeError,
                    "raise: exception must be an old-style class or instance");
                goto raise_error;
            }
        #else
            type = (PyObject*) type->ob_type;
            Py_INCREF(type);
            if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
                PyErr_SetString(PyExc_TypeError,
                    "raise: exception class must be a subclass of BaseException");
                goto raise_error;
            }
        #endif
    }
    PyErr_Restore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}

static void __Pyx_UnpackError(void) {
    PyErr_SetString(PyExc_ValueError, "unpack sequence of wrong size");
}

static PyObject *__Pyx_UnpackItem(PyObject *iter) {
    PyObject *item;
    if (!(item = PyIter_Next(iter))) {
        if (!PyErr_Occurred())
            __Pyx_UnpackError();
    }
    return item;
}

static int __Pyx_EndUnpack(PyObject *iter) {
    PyObject *item;
    if ((item = PyIter_Next(iter))) {
        Py_DECREF(item);
        __Pyx_UnpackError();
        return -1;
    }
    else if (!PyErr_Occurred())
        return 0;
    else
        return -1;
}

static int __Pyx_InternStrings(__Pyx_InternTabEntry *t) {
    while (t->p) {
        *t->p = PyString_InternFromString(t->s);
        if (!*t->p)
            return -1;
        ++t;
    }
    return 0;
}

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        if (!*t->p)
            return -1;
        ++t;
    }
    return 0;
}

#include "compile.h"
#include "frameobject.h"
#include "traceback.h"

static void __Pyx_AddTraceback(char *funcname) {
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    PyObject *py_globals = 0;
    PyObject *empty_tuple = 0;
    PyObject *empty_string = 0;
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;
    
    py_srcfile = PyString_FromString(__pyx_filename);
    if (!py_srcfile) goto bad;
    py_funcname = PyString_FromString(funcname);
    if (!py_funcname) goto bad;
    py_globals = PyModule_GetDict(__pyx_m);
    if (!py_globals) goto bad;
    empty_tuple = PyTuple_New(0);
    if (!empty_tuple) goto bad;
    empty_string = PyString_FromString("");
    if (!empty_string) goto bad;
    py_code = PyCode_New(
        0,            /*int argcount,*/
        0,            /*int nlocals,*/
        0,            /*int stacksize,*/
        0,            /*int flags,*/
        empty_string, /*PyObject *code,*/
        empty_tuple,  /*PyObject *consts,*/
        empty_tuple,  /*PyObject *names,*/
        empty_tuple,  /*PyObject *varnames,*/
        empty_tuple,  /*PyObject *freevars,*/
        empty_tuple,  /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        __pyx_lineno,   /*int firstlineno,*/
        empty_string  /*PyObject *lnotab*/
    );
    if (!py_code) goto bad;
    py_frame = PyFrame_New(
        PyThreadState_Get(), /*PyThreadState *tstate,*/
        py_code,             /*PyCodeObject *code,*/
        py_globals,          /*PyObject *globals,*/
        0                    /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    py_frame->f_lineno = __pyx_lineno;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    Py_XDECREF(empty_tuple);
    Py_XDECREF(empty_string);
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}
