Subversion Repositories Games.Carmageddon

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. #include "pmmem.h"
  2. #include "CORE/FW/object.h"
  3. #include "CORE/FW/resource.h"
  4. #include "CORE/FW/tokenval.h"
  5. #include "CORE/PIXELMAP/genclip.h"
  6. #include "CORE/PIXELMAP/pmgen.h"
  7. #include "CORE/PIXELMAP/pmmemops.h"
  8. #include "CORE/PIXELMAP/pmsetup.h"
  9. #include "harness/trace.h"
  10. #include <stddef.h>
  11. #include <stdlib.h>
  12. #include <string.h>
  13.  
  14. br_tv_template_entry matchTemplateEntries[6] = {
  15.     { BRT_USE_T, NULL, 0, 2, 3, 0, 0 },
  16.     { BRT_PIXEL_TYPE_U8, NULL, 4, 2, 3, 0, 0 },
  17.     { BRT_PIXEL_BITS_I32, NULL, 8, 2, 3, 0, 0 },
  18.     { BRT_RENDERER_O, NULL, 20, 2, 3, 0, 0 },
  19.     { BRT_WIDTH_I32, NULL, 12, 2, 3, 0, 0 },
  20.     { BRT_HEIGHT_I32, NULL, 16, 2, 3, 0, 0 }
  21. };
  22. br_device_pixelmap_dispatch devicePixelmapDispatch = {
  23.     NULL,
  24.     NULL,
  25.     NULL,
  26.     NULL,
  27.     (void*)_M_br_device_pixelmap_mem_free,
  28.     (void*)_M_br_device_pixelmap_mem_identifier,
  29.     (void*)_M_br_device_pixelmap_mem_type,
  30.     (void*)_M_br_device_pixelmap_mem_isType,
  31.     (void*)_M_br_device_pixelmap_mem_device,
  32.     (void*)_M_br_device_pixelmap_mem_space,
  33.     (void*)_M_br_device_pixelmap_mem_queryTemplate,
  34.     (void*)_M_br_object_query,
  35.     (void*)_M_br_object_queryBuffer,
  36.     (void*)_M_br_object_queryMany,
  37.     (void*)_M_br_object_queryManySize,
  38.     (void*)_M_br_object_queryAll,
  39.     (void*)_M_br_object_queryAllSize,
  40.     (void*)_M_br_device_pixelmap_mem_validSource,
  41.     _M_br_device_pixelmap_mem_resize,
  42.     _M_br_device_pixelmap_mem_match,
  43.     _M_br_device_pixelmap_mem_allocateSub,
  44.     _M_br_device_pixelmap_mem_copyTo,
  45.     _M_br_device_pixelmap_mem_copyTo,
  46.     _M_br_device_pixelmap_mem_copyFrom,
  47.     _M_br_device_pixelmap_mem_fill,
  48.     _M_br_device_pixelmap_gen_doubleBuffer,
  49.     _M_br_device_pixelmap_gen_copyDirty,
  50.     _M_br_device_pixelmap_gen_copyToDirty,
  51.     _M_br_device_pixelmap_gen_copyFromDirty,
  52.     _M_br_device_pixelmap_gen_fillDirty,
  53.     _M_br_device_pixelmap_gen_doubleBufferDirty,
  54.     _M_br_device_pixelmap_gen_rectangle,
  55.     _M_br_device_pixelmap_gen_rectangle2,
  56.     _M_br_device_pixelmap_mem_rectangleCopyTo,
  57.     _M_br_device_pixelmap_mem_rectangleCopyTo,
  58.     _M_br_device_pixelmap_mem_rectangleCopyFrom,
  59.     _M_br_device_pixelmap_mem_rectangleStretchCopyTo,
  60.     _M_br_device_pixelmap_mem_rectangleStretchCopyTo,
  61.     _M_br_device_pixelmap_mem_rectangleStretchCopyFrom,
  62.     _M_br_device_pixelmap_mem_rectangleFill,
  63.     _M_br_device_pixelmap_mem_pixelSet,
  64.     _M_br_device_pixelmap_mem_line,
  65.     _M_br_device_pixelmap_mem_copyBits,
  66.     _M_br_device_pixelmap_gen_text,
  67.     _M_br_device_pixelmap_gen_textBounds,
  68.     _M_br_device_pixelmap_mem_rowSize,
  69.     (void*)_M_br_device_pixelmap_mem_rowSet,
  70.     (void*)_M_br_device_pixelmap_mem_rowQuery,
  71.     _M_br_device_pixelmap_mem_pixelQuery,
  72.     _M_br_device_pixelmap_mem_pixelAddressQuery,
  73.     _M_br_device_pixelmap_mem_pixelAddressSet,
  74.     _M_br_device_pixelmap_mem_originSet,
  75.     _M_br_device_pixelmap_mem_flush,
  76.     _M_br_device_pixelmap_mem_synchronise,
  77.     _M_br_device_pixelmap_mem_directLock,
  78.     _M_br_device_pixelmap_mem_directUnlock,
  79.  };
  80.  
  81. br_tv_template_entry devicePixelmapTemplateEntries[4];
  82. pm_type_info pmTypeInfo[30] = {
  83.     { 1u, 1u, 32u, 1u },
  84.     { 2u, 1u, 16u, 1u },
  85.     { 4u, 1u, 8u, 1u },
  86.     { 8u, 1u, 4u, 1u },
  87.     { 16u, 2u, 2u, 2u },
  88.     { 16u, 2u, 2u, 2u },
  89.     { 24u, 3u, 4u, 2u },
  90.     { 32u, 4u, 1u, 2u },
  91.     { 32u, 4u, 1u, 10u },
  92.     { 16u, 1u, 2u, 16u },
  93.     { 32u, 1u, 1u, 16u },
  94.     { 16u, 2u, 4u, 4u },
  95.     { 32u, 4u, 4u, 4u },
  96.     { 8u, 1u, 4u, 8u },
  97.     { 16u, 2u, 2u, 9u },
  98.     { 54u, 0u, 0u, 0u },
  99.     { 4u, 0u, 5u, 3u },
  100.     { 0u, 0u, 0u, 0u },
  101.     { 69u, 0u, 0u, 0u },
  102.     { 52u, 0u, 5u, 13u },
  103.     { 0u, 0u, 0u, 0u },
  104.     { 72u, 0u, 0u, 0u },
  105.     { 54u, 0u, 5u, 13u },
  106.     { 0u, 0u, 0u, 0u },
  107.     { 75u, 0u, 0u, 0u },
  108.     { 44u, 0u, 5u, 12u },
  109.     { 0u, 0u, 0u, 0u },
  110.     { 1u, 0u, 0u, 0u },
  111.     { 0u, 0u, 0u, 0u },
  112.     { 0u, 0u, 0u, 0u }
  113. };
  114.  
  115. // IDA: br_device_pixelmap* __usercall DevicePixelmapMemAllocate@<EAX>(br_uint_8 type@<EAX>, br_uint_16 w@<EDX>, br_uint_16 h@<EBX>, void *pixels@<ECX>, int flags)
  116. br_device_pixelmap* DevicePixelmapMemAllocate(br_uint_8 type, br_uint_16 w, br_uint_16 h, void* pixels, int flags) {
  117.     br_device_pixelmap* pm;
  118.     pm_type_info* tip;
  119.  
  120.     tip = &pmTypeInfo[type];
  121.     pm = BrResAllocate(_pixelmap.res, sizeof(br_device_pixelmap), BR_MEMORY_PIXELMAP);
  122.     // pm->dispatch = &devicePixelmapDispatch;
  123.     pm->pm_identifier = NULL;
  124.     pm->pm_map = NULL;
  125.     pm->pm_flags = BR_PMF_LINEAR;
  126.     pm->pm_copy_function = BR_PMCOPY_NORMAL;
  127.     pm->pm_base_x = 0;
  128.     pm->pm_base_y = 0;
  129.  
  130.     pm->pm_origin_x = 0;
  131.     pm->pm_origin_y = 0;
  132.     pm->pm_type = type;
  133.     pm->pm_width = w;
  134.     pm->pm_height = h;
  135.     // 8 bits, 1, 4 align, 1
  136.  
  137.     // v11 = (tip->align + w - 1) / tip->align * tip->align * tip->bits;
  138.     // pm->pm_row_bytes = (v11 - (__CFSHL__(v11 >> 31, 3) + 8 * (v11 >> 31))) >> 3;
  139.     //  TODO: calculate this differently
  140.     pm->pm_row_bytes = w;
  141.     pm->pm_row_bytes = tip->bits * tip->align * ((w + tip->align - 1) / tip->align) / 8;
  142.  
  143.     if ((8 * pm->pm_row_bytes % tip->bits) == 0) {
  144.         pm->pm_flags |= BR_PMF_ROW_WHOLEPIXELS;
  145.     }
  146.     if (!(flags & BR_PMAF_NO_PIXELS)) {
  147.         if (pixels != NULL) {
  148.             pm->pm_pixels = pixels;
  149.         } else {
  150.             pm->pm_pixels = BrResAllocate(pm, pm->pm_height * pm->pm_row_bytes, BR_MEMORY_PIXELS);
  151.         }
  152.     }
  153.     // TODO: not sure we need this
  154.     // pm->pm_pixels_qualifier = (unsigned __int16)_GetSysQual();
  155.     if (flags & BR_PMAF_INVERTED) {
  156.         pm->pm_pixels = (char*)pm->pm_pixels + (pm->pm_height - 1) * pm->pm_row_bytes;
  157.         pm->pm_row_bytes *= -1;
  158.     }
  159.     return pm;
  160. }
  161.  
  162. void CheckDispatch(br_device_pixelmap* pm) {
  163.     if (pm->dispatch == NULL) {
  164.         pm->dispatch = &devicePixelmapDispatch;
  165.     }
  166. }
  167.  
  168. // IDA: br_error __cdecl _M_br_device_pixelmap_mem_allocateSub(br_device_pixelmap *self, br_device_pixelmap **newpm, br_rectangle *rect)
  169. br_error _M_br_device_pixelmap_mem_allocateSub(br_device_pixelmap* self, br_device_pixelmap** newpm, br_rectangle* rect) {
  170.     br_device_pixelmap* pm;
  171.     br_rectangle out;
  172.     LOG_TRACE("(%p, %p, %p)", self, newpm, rect);
  173.  
  174.     if (PixelmapRectangleClip(&out, rect, (br_pixelmap*)self) == BR_CLIP_REJECT) {
  175.         return 4098;
  176.     }
  177.  
  178.     pm = (br_device_pixelmap*)BrResAllocate(_pixelmap.res, sizeof(br_pixelmap), BR_MEMORY_PIXELMAP);
  179.     memcpy(pm, self, sizeof(br_pixelmap));
  180.     pm->pm_base_x += out.x;
  181.     pm->pm_base_y += out.y;
  182.     pm->pm_width = out.w;
  183.     pm->pm_height = out.h;
  184.     pm->pm_origin_x = 0;
  185.     pm->pm_origin_y = 0;
  186.     pm->pm_stored = 0;
  187.     pm->dispatch = &devicePixelmapDispatch;
  188.     if (pm->pm_width != self->pm_width) {
  189.         pm->pm_flags &= ~BR_PMF_LINEAR;
  190.     }
  191.     *newpm = pm;
  192.     return 0;
  193. }
  194.  
  195. // IDA: void __cdecl _M_br_device_pixelmap_mem_free(br_device_pixelmap *self)
  196. void _M_br_device_pixelmap_mem_free(br_device_pixelmap* self) {
  197.     BrResFree(self);
  198. }
  199.  
  200. // IDA: char* __cdecl _M_br_device_pixelmap_mem_identifier(br_device_pixelmap *self)
  201. char* _M_br_device_pixelmap_mem_identifier(br_device_pixelmap* self) {
  202.     LOG_TRACE("(%p)", self);
  203.  
  204.     return self->pm_identifier;
  205. }
  206.  
  207. // IDA: br_token __cdecl _M_br_device_pixelmap_mem_type(br_device_pixelmap *self)
  208. br_token _M_br_device_pixelmap_mem_type(br_device_pixelmap* self) {
  209.     LOG_TRACE("(%p)", self);
  210.  
  211.     return BRT_DEVICE_PIXELMAP;
  212. }
  213.  
  214. // IDA: br_boolean __cdecl _M_br_device_pixelmap_mem_isType(br_device_pixelmap *self, br_token t)
  215. br_boolean _M_br_device_pixelmap_mem_isType(br_device_pixelmap* self, br_token t) {
  216.     LOG_TRACE("(%p, %d)", self, t);
  217.  
  218.     return t == BRT_DEVICE_PIXELMAP || t == BRT_OBJECT;
  219. }
  220.  
  221. // IDA: br_device* __cdecl _M_br_device_pixelmap_mem_device(br_device_pixelmap *self)
  222. br_device* _M_br_device_pixelmap_mem_device(br_device_pixelmap* self) {
  223.     LOG_TRACE("(%p)", self);
  224.  
  225.     return NULL;
  226. }
  227.  
  228. // IDA: br_int_32 __cdecl _M_br_device_pixelmap_mem_space(br_device_pixelmap *self)
  229. br_int_32 _M_br_device_pixelmap_mem_space(br_device_pixelmap* self) {
  230.     LOG_TRACE("(%p)", self);
  231.  
  232.     return BrResSizeTotal(self);
  233. }
  234.  
  235. // IDA: br_tv_template* __cdecl _M_br_device_pixelmap_mem_queryTemplate(br_device_pixelmap *self)
  236. br_tv_template* _M_br_device_pixelmap_mem_queryTemplate(br_device_pixelmap* self) {
  237.     LOG_TRACE("(%p)", self);
  238.     NOT_IMPLEMENTED();
  239. }
  240.  
  241. // IDA: br_error __cdecl _M_br_device_pixelmap_mem_validSource(br_device_pixelmap *self, br_object *h)
  242. br_error _M_br_device_pixelmap_mem_validSource(br_device_pixelmap* self, br_object* h) {
  243.     LOG_TRACE("(%p, %p)", self, h);
  244.  
  245.     return 0;
  246. }
  247.  
  248. // IDA: br_error __cdecl _M_br_device_pixelmap_mem_resize(br_device_pixelmap *self, br_int_32 width, br_int_32 height)
  249. br_error _M_br_device_pixelmap_mem_resize(br_device_pixelmap* self, br_int_32 width, br_int_32 height) {
  250.     //char* pixels; // Pierre-Marie Baty -- unused variable
  251.     //pm_type_info* tip; // Pierre-Marie Baty -- unused variable
  252.     //br_int_16 old_row_bytes; // Pierre-Marie Baty -- unused variable
  253.     LOG_TRACE("(%p, %d, %d)", self, width, height);
  254.     NOT_IMPLEMENTED();
  255. }
  256.  
  257. // IDA: br_error __cdecl _M_br_device_pixelmap_mem_match(br_device_pixelmap *self, br_device_pixelmap **newpm, br_token_value *tv)
  258. br_error _M_br_device_pixelmap_mem_match(br_device_pixelmap* self, br_device_pixelmap** newpm, br_token_value* tv) {
  259.     match_tokens mt;
  260.     br_int_32 count;
  261.     br_device_pixelmap* pm;
  262.     br_int_32 bytes;
  263.     br_int_32 r;
  264.     LOG_TRACE("(%p, %p, %p)", self, newpm, tv);
  265.  
  266.     if (!_pixelmap.pixelmap_match_template) {
  267.         _pixelmap.pixelmap_match_template = BrTVTemplateAllocate(_pixelmap.res, matchTemplateEntries, 6);
  268.         if (!_pixelmap.pixelmap_match_template) {
  269.             LOG_WARN("x");
  270.             return 4098;
  271.         }
  272.     }
  273.     mt.pixel_type = self->pm_type;
  274.     mt.width = self->pm_width;
  275.     mt.height = self->pm_height;
  276.  
  277.     // TOOD: We haven't implemented BrTokenValueSetMany - just emulate enough for now
  278.     mt.use = tv[1].t; // se BrPixelmapMatch
  279.     mt.pixel_bits = 16;
  280.  
  281.     BrTokenValueSetMany(&mt, &count, 0, tv, _pixelmap.pixelmap_match_template);
  282.     // if ( (unsigned int)mt.use < 0x64 )
  283.     // {
  284.     //     if ( mt.use != 84 )
  285.     //         return 4098;
  286.     //     if ( mt.pixel_bits < 0x10u )
  287.     //     {
  288.     //         if ( mt.pixel_bits )
  289.     //             return 4098;
  290.     //     }
  291.     //     else if ( mt.pixel_bits > 0x10u )
  292.     //     {
  293.     //         if ( mt.pixel_bits != 32 )
  294.     //             return 4098;
  295.     //         mt.pixel_type = 12;
  296.     //         goto LABEL_18;
  297.     //     }
  298.     //     mt.pixel_type = 11;
  299.     //     goto LABEL_18;
  300.     // }
  301.     // if ( (unsigned int)mt.use > 0x66 )
  302.     // {
  303.     //     if ( (unsigned int)mt.use >= 0x116 )
  304.     //     {
  305.     //         if ( (unsigned int)mt.use > 0x116 && mt.use != 379 )
  306.     //             return 4098;
  307.     //         goto LABEL_18;
  308.     //     }
  309.     //     return 4098;
  310.     // }
  311.  
  312.     if (mt.use == BRT_DEPTH) {
  313.  
  314.         // TODO: hack this to make it work
  315.         mt.pixel_type = BR_PMT_DEPTH_16;
  316.         pm = DevicePixelmapMemAllocate(mt.pixel_type, mt.width, mt.height, NULL, (self->pm_row_bytes < 0) | BR_PMAF_NO_PIXELS);
  317.         r = abs(self->pm_row_bytes);
  318.         bytes = (signed int)pmTypeInfo[self->pm_type].bits >> 3;
  319.         pm->pm_row_bytes = ((signed int)pmTypeInfo[pm->pm_type].bits >> 3) * (unsigned int)((bytes + r - 1) / bytes);
  320.         pm->pm_pixels = BrResAllocate(pm, pm->pm_height * pm->pm_row_bytes, BR_MEMORY_PIXELS);
  321.         if (pm->pm_width * ((signed int)pmTypeInfo[pm->pm_type].bits >> 3) == pm->pm_row_bytes)
  322.             pm->pm_flags |= BR_PMF_LINEAR;
  323.         else {
  324.             pm->pm_flags &= 0xFDu;
  325.         }
  326.         if (self->pm_row_bytes < 0) {
  327.             pm->pm_row_bytes = -pm->pm_row_bytes;
  328.             // TODO: is this a bug in the original code? We say row_bytes is positive, but still set the pixels pointer to the bottom
  329.             // of the data
  330.             pm->pm_pixels = (char*)pm->pm_pixels + (pm->pm_height - 1) * pm->pm_row_bytes;
  331.         }
  332.     } else {
  333.         pm = DevicePixelmapMemAllocate(mt.pixel_type, mt.width, mt.height, NULL, self->pm_row_bytes < 0);
  334.     }
  335.     pm->pm_origin_x = self->pm_origin_x;
  336.     pm->pm_origin_y = self->pm_origin_y;
  337.     // self->dispatch = pm;
  338.     *newpm = pm;
  339.     return 0;
  340.  
  341.     // br_pixelmap* ret = BrPixelmapAllocate(src->type, src->width, src->height, NULL, BR_PMAF_NORMAL);
  342.  
  343.     // if (match_type == BR_PMMATCH_DEPTH_16) {
  344.     //     ret->type = BR_PMT_DEPTH_16;
  345.     //     ret->flags |= BR_PMAF_DEPTHBUFFER;
  346.     // } else {
  347.     //     ret->flags |= BR_PMAF_OFFSCREEN;
  348.     // }
  349. }
  350.  
  351. // IDA: br_error __cdecl _M_br_device_pixelmap_mem_copyTo(br_device_pixelmap *self, br_device_pixelmap *src)
  352. br_error _M_br_device_pixelmap_mem_copyTo(br_device_pixelmap* self, br_device_pixelmap* src) {
  353.     //br_int_8 bytes; // Pierre-Marie Baty -- unused variable
  354.     LOG_TRACE("(%p, %p)", self, src);
  355.     NOT_IMPLEMENTED();
  356. }
  357.  
  358. // IDA: br_error __cdecl _M_br_device_pixelmap_mem_copyFrom(br_device_pixelmap *self, br_device_pixelmap *dest)
  359. br_error _M_br_device_pixelmap_mem_copyFrom(br_device_pixelmap* self, br_device_pixelmap* dest) {
  360.     //br_int_8 bytes; // Pierre-Marie Baty -- unused variable
  361.     LOG_TRACE("(%p, %p)", self, dest);
  362.     NOT_IMPLEMENTED();
  363. }
  364.  
  365. // IDA: br_error __cdecl _M_br_device_pixelmap_mem_fill(br_device_pixelmap *self, br_uint_32 colour)
  366. br_error _M_br_device_pixelmap_mem_fill(br_device_pixelmap* self, br_uint_32 colour) {
  367.     br_int_8 bytes;
  368.     LOG_TRACE("(%p, %d)", self, colour);
  369.  
  370.     bytes = pmTypeInfo[self->pm_type].bits >> 3;
  371.     if ((self->pm_flags & (BR_PMF_ROW_WHOLEPIXELS | BR_PMF_LINEAR)) == (BR_PMF_ROW_WHOLEPIXELS | BR_PMF_LINEAR)) {
  372.         if (self->pm_row_bytes > 0) {
  373.             pm_mem_fill_colour((br_uint_8*)self->pm_pixels + self->pm_base_y * self->pm_row_bytes + self->pm_base_x * bytes, self->pm_pixels_qualifier,
  374.                 self->pm_width * self->pm_height, bytes, colour);
  375.         } else {
  376.             pm_mem_fill_colour((br_uint_8*)self->pm_pixels + (self->pm_base_y + self->pm_height - 1) * self->pm_row_bytes + self->pm_base_x * bytes,
  377.                 self->pm_pixels_qualifier, self->pm_width * self->pm_height, bytes, colour);
  378.         }
  379.     } else if ((self->pm_row_bytes & 7) == 0) {
  380.         pm_mem_fill_colour_rect((br_uint_8*)self->pm_pixels + self->pm_base_y * self->pm_row_bytes + self->pm_base_x * bytes, self->pm_pixels_qualifier,
  381.             self->pm_width, self->pm_height, self->pm_row_bytes, bytes, colour);
  382.     } else {
  383.         int i;
  384.         for (i = 0; i < self->pm_height; i++) {
  385.             pm_mem_fill_colour((br_uint_8*)self->pm_pixels + (i + self->pm_base_y) * self->pm_row_bytes + self->pm_base_x * bytes, self->pm_pixels_qualifier,
  386.                 self->pm_width, bytes, colour);
  387.         }
  388.     }
  389.     return 0;
  390. }
  391.  
  392. // IDA: br_error __cdecl _M_br_device_pixelmap_mem_doubleBuffer(br_device_pixelmap *self, br_device_pixelmap *src)
  393. br_error _M_br_device_pixelmap_mem_doubleBuffer(br_device_pixelmap* self, br_device_pixelmap* src) {
  394.     LOG_TRACE("(%p, %p)", self, src);
  395.     NOT_IMPLEMENTED();
  396. }
  397.  
  398. // IDA: br_error __cdecl _M_br_device_pixelmap_mem_copyDirty(br_device_pixelmap *self, br_device_pixelmap *src, br_rectangle *dirty, br_int_32 num_rects)
  399. br_error _M_br_device_pixelmap_mem_copyDirty(br_device_pixelmap* self, br_device_pixelmap* src, br_rectangle* dirty, br_int_32 num_rects) {
  400.     LOG_TRACE("(%p, %p, %p, %d)", self, src, dirty, num_rects);
  401.     NOT_IMPLEMENTED();
  402. }
  403.  
  404. // IDA: br_error __cdecl _M_br_device_pixelmap_mem_copyToDirty(br_device_pixelmap *self, br_device_pixelmap *src, br_rectangle *dirty, br_int_32 num_rects)
  405. br_error _M_br_device_pixelmap_mem_copyToDirty(br_device_pixelmap* self, br_device_pixelmap* src, br_rectangle* dirty, br_int_32 num_rects) {
  406.     LOG_TRACE("(%p, %p, %p, %d)", self, src, dirty, num_rects);
  407.     NOT_IMPLEMENTED();
  408. }
  409.  
  410. // IDA: br_error __cdecl _M_br_device_pixelmap_mem_copyFromDirty(br_device_pixelmap *self, br_device_pixelmap *src, br_rectangle *dirty, br_int_32 num_rects)
  411. br_error _M_br_device_pixelmap_mem_copyFromDirty(br_device_pixelmap* self, br_device_pixelmap* src, br_rectangle* dirty, br_int_32 num_rects) {
  412.     LOG_TRACE("(%p, %p, %p, %d)", self, src, dirty, num_rects);
  413.     NOT_IMPLEMENTED();
  414. }
  415.  
  416. // IDA: br_error __cdecl _M_br_device_pixelmap_mem_fillDirty(br_device_pixelmap *self, br_uint_32 colour, br_rectangle *dirty, br_int_32 num_rects)
  417. br_error _M_br_device_pixelmap_mem_fillDirty(br_device_pixelmap* self, br_uint_32 colour, br_rectangle* dirty, br_int_32 num_rects) {
  418.     LOG_TRACE("(%p, %d, %p, %d)", self, colour, dirty, num_rects);
  419.     NOT_IMPLEMENTED();
  420. }
  421.  
  422. // IDA: br_error __cdecl _M_br_device_pixelmap_mem_doubleBufferDirty(br_device_pixelmap *self, br_device_pixelmap *src, br_rectangle *dirty, br_int_32 num_rects)
  423. br_error _M_br_device_pixelmap_mem_doubleBufferDirty(br_device_pixelmap* self, br_device_pixelmap* src, br_rectangle* dirty, br_int_32 num_rects) {
  424.     LOG_TRACE("(%p, %p, %p, %d)", self, src, dirty, num_rects);
  425.     NOT_IMPLEMENTED();
  426. }
  427.  
  428. // IDA: br_error __cdecl _M_br_device_pixelmap_mem_rectangleCopyTo(br_device_pixelmap *self, br_point *p, br_device_pixelmap *src, br_rectangle *r)
  429. br_error _M_br_device_pixelmap_mem_rectangleCopyTo(br_device_pixelmap* self, br_point* p, br_device_pixelmap* src, br_rectangle* r) {
  430.     int bytes;
  431.     br_rectangle ar;
  432.     br_point ap;
  433.     int i;  // Added by DethRace
  434.     LOG_TRACE("(%p, %p, %p, %p)", self, p, src, r);
  435.  
  436.     if (PixelmapRectangleClipTwo(&ar, &ap, r, p, (br_pixelmap*)self, (br_pixelmap*)src) == BR_CLIP_REJECT) {
  437.         return 0;
  438.     }
  439.     bytes = pmTypeInfo[self->pm_type].bits >> 3;
  440.     if (self->pm_width == ar.w) {
  441.         if (src->pm_row_bytes == self->pm_row_bytes && (self->pm_flags & (BR_PMF_ROW_WHOLEPIXELS | BR_PMF_LINEAR)) == (BR_PMF_ROW_WHOLEPIXELS | BR_PMF_LINEAR)) {
  442.             if (self->pm_row_bytes > 0) {
  443.                 pm_mem_copy_colour((br_uint_8*)self->pm_pixels + (self->pm_base_y + ap.y) * self->pm_row_bytes + (self->pm_base_x + ap.x) * bytes, self->pm_pixels_qualifier,
  444.                     (br_uint_8*)src->pm_pixels + (src->pm_base_y + ar.y) * src->pm_row_bytes + (src->pm_base_x + ar.x) * bytes, src->pm_pixels_qualifier,
  445.                     ar.w * ar.h, bytes);
  446.                 return 0;
  447.             } else {
  448.                 pm_mem_copy_colour((br_uint_8*)self->pm_pixels + (self->pm_base_y + ap.y + ar.h - 1) * self->pm_row_bytes + (self->pm_base_x + ap.x) * bytes, self->pm_pixels_qualifier,
  449.                     (br_uint_8*)src->pm_pixels + (src->pm_base_y + ar.y + ar.h - 1) * src->pm_row_bytes + (src->pm_base_x + ar.x) * bytes, src->pm_pixels_qualifier,
  450.                     ar.w * ar.h, bytes);
  451.                 return 0;
  452.             }
  453.         }
  454.     }
  455.     if (self->pm_row_bytes % 8 == 0) {
  456.         pm_mem_copy_colour_rect((br_uint_8*)self->pm_pixels + (self->pm_base_y + ap.y) * self->pm_row_bytes + (self->pm_base_x + ap.x) * bytes, self->pm_pixels_qualifier,
  457.             (br_uint_8*)src->pm_pixels + (src->pm_base_y + ar.y) * src->pm_row_bytes + (src->pm_base_x + ar.x) * bytes, src->pm_pixels_qualifier,
  458.             ar.w, ar.h, self->pm_row_bytes, src->pm_row_bytes, bytes);
  459.         return 0;
  460.     }
  461.     for (i = 0; i < ar.h; i++) {
  462.         pm_mem_copy_colour((br_uint_8*)self->pm_pixels + (self->pm_base_y + ap.y + i) * self->pm_row_bytes + (self->pm_base_x + ap.x) * bytes, self->pm_pixels_qualifier,
  463.             (br_uint_8*)src->pm_pixels + (src->pm_base_y + ar.y + i) * src->pm_row_bytes + (src->pm_base_x + ar.x) * bytes, src->pm_pixels_qualifier,
  464.             ar.w, bytes);
  465.     }
  466.     return 0;
  467. }
  468.  
  469. // IDA: br_error __cdecl _M_br_device_pixelmap_mem_rectangleCopyFrom(br_device_pixelmap *self, br_point *p, br_device_pixelmap *dest, br_rectangle *r)
  470. br_error _M_br_device_pixelmap_mem_rectangleCopyFrom(br_device_pixelmap* self, br_point* p, br_device_pixelmap* dest, br_rectangle* r) {
  471.     //int bytes; // Pierre-Marie Baty -- unused variable
  472.     //br_rectangle ar; // Pierre-Marie Baty -- unused variable
  473.     //br_point ap; // Pierre-Marie Baty -- unused variable
  474.     LOG_TRACE("(%p, %p, %p, %p)", self, p, dest, r);
  475.     NOT_IMPLEMENTED();
  476. }
  477.  
  478. // IDA: br_error __cdecl _M_br_device_pixelmap_mem_rectangleStretchCopyTo(br_device_pixelmap *self, br_rectangle *destinationRectangle, br_device_pixelmap *src, br_rectangle *sourceRectangle)
  479. br_error _M_br_device_pixelmap_mem_rectangleStretchCopyTo(br_device_pixelmap* self, br_rectangle* destinationRectangle, br_device_pixelmap* src, br_rectangle* sourceRectangle) {
  480.     LOG_TRACE("(%p, %p, %p, %p)", self, destinationRectangle, src, sourceRectangle);
  481.     NOT_IMPLEMENTED();
  482. }
  483.  
  484. // IDA: br_error __cdecl _M_br_device_pixelmap_mem_rectangleStretchCopyFrom(br_device_pixelmap *self, br_rectangle *d, br_device_pixelmap *src, br_rectangle *s)
  485. br_error _M_br_device_pixelmap_mem_rectangleStretchCopyFrom(br_device_pixelmap* self, br_rectangle* d, br_device_pixelmap* src, br_rectangle* s) {
  486.     LOG_TRACE("(%p, %p, %p, %p)", self, d, src, s);
  487.     NOT_IMPLEMENTED();
  488. }
  489.  
  490. // IDA: br_error __cdecl _M_br_device_pixelmap_mem_rectangleFill(br_device_pixelmap *self, br_rectangle *rect, br_uint_32 colour)
  491. br_error _M_br_device_pixelmap_mem_rectangleFill(br_device_pixelmap* self, br_rectangle* rect, br_uint_32 colour) {
  492.     //br_rectangle arect; // Pierre-Marie Baty -- unused variable
  493.     //br_int_8 bytes; // Pierre-Marie Baty -- unused variable
  494.     LOG_TRACE("(%p, %p, %d)", self, rect, colour);
  495.     NOT_IMPLEMENTED();
  496. }
  497.  
  498. // IDA: br_error __cdecl _M_br_device_pixelmap_mem_pixelSet(br_device_pixelmap *self, br_point *p, br_uint_32 colour)
  499. br_error _M_br_device_pixelmap_mem_pixelSet(br_device_pixelmap* self, br_point* p, br_uint_32 colour) {
  500.     br_point ap;
  501.     br_int_8 bytes;
  502.     LOG_TRACE("(%p, %p, %d)", self, p, colour);
  503.  
  504.     if (PixelmapPointClip(&ap, p, (br_pixelmap*)self) == BR_CLIP_REJECT) {
  505.         return 0;
  506.     }
  507.     bytes = pmTypeInfo[self->pm_type].bits >> 3;
  508.     pm_mem_set_colour((br_uint_8*)self->pm_pixels + (self->pm_base_y + ap.y) * self->pm_row_bytes + (self->pm_base_x + ap.x) * bytes, self->pm_pixels_qualifier, bytes, colour);
  509.     return 0;
  510. }
  511.  
  512. // IDA: br_error __cdecl _M_br_device_pixelmap_mem_line(br_device_pixelmap *self, br_point *s, br_point *e, br_uint_32 colour)
  513. br_error _M_br_device_pixelmap_mem_line(br_device_pixelmap* self, br_point* s, br_point* e, br_uint_32 colour) {
  514.     //int dx; // Pierre-Marie Baty -- unused variable
  515.     //int dy; // Pierre-Marie Baty -- unused variable
  516.     //int incr1; // Pierre-Marie Baty -- unused variable
  517.     //int incr2; // Pierre-Marie Baty -- unused variable
  518.     //int D; // Pierre-Marie Baty -- unused variable
  519.     //int x; // Pierre-Marie Baty -- unused variable
  520.     //int y; // Pierre-Marie Baty -- unused variable
  521.     //int xend; // Pierre-Marie Baty -- unused variable
  522.     //int c; // Pierre-Marie Baty -- unused variable
  523.     //int pixels_left; // Pierre-Marie Baty -- unused variable
  524.     //int x1; // Pierre-Marie Baty -- unused variable
  525.     //int y1; // Pierre-Marie Baty -- unused variable
  526.     //int sign_x; // Pierre-Marie Baty -- unused variable
  527.     //int sign_y; // Pierre-Marie Baty -- unused variable
  528.     //int step; // Pierre-Marie Baty -- unused variable
  529.     //int reverse; // Pierre-Marie Baty -- unused variable
  530.     //int i; // Pierre-Marie Baty -- unused variable
  531.     //char* dest; // Pierre-Marie Baty -- unused variable
  532.     //int bytes; // Pierre-Marie Baty -- unused variable
  533.     //br_point as; // Pierre-Marie Baty -- unused variable
  534.     //br_point ae; // Pierre-Marie Baty -- unused variable
  535.     LOG_TRACE("(%p, %p, %p, %d)", self, s, e, colour);
  536.     NOT_IMPLEMENTED();
  537. }
  538.  
  539.  
  540. // IDA: br_error __cdecl _M_br_device_pixelmap_mem_copyBits(br_device_pixelmap *self, br_point *point, br_uint_8 *src, br_uint_16 s_stride, br_rectangle *bit_rect, br_uint_32 colour)
  541. br_error _M_br_device_pixelmap_mem_copyBits(br_device_pixelmap* self, br_point* point, br_uint_8* src, br_uint_16 s_stride, br_rectangle* bit_rect, br_uint_32 colour) {
  542.     int bytes;
  543.     int bit;
  544.     br_rectangle ar;
  545.     br_point ap;
  546.     LOG_TRACE("(%p, %p, %p, %d, %p, %d)", self, point, src, s_stride, bit_rect, colour);
  547.  
  548.     if (PixelmapCopyBitsClip(&ar, &ap, bit_rect, point, (br_pixelmap*)self) == BR_CLIP_REJECT) {
  549.         return 0;
  550.     }
  551.     bytes = pmTypeInfo[self->pm_type].bits >> 3;
  552.     bit = ar.x & 0x7;
  553.  
  554.     pm_mem_copy_bits((br_uint_8*)self->pm_pixels + (self->pm_base_y + ap.y) * self->pm_row_bytes + (self->pm_base_x + ap.x + (ar.x & ~0x7) - bit) * bytes, self->pm_pixels_qualifier,
  555.         self->pm_row_bytes, src + ar.y * s_stride, s_stride, bit, bit + ar.w, ar.h, bytes, colour);
  556.     return 0;
  557. }
  558.  
  559. // IDA: br_error __cdecl _M_br_device_pixelmap_mem_pixelQuery(br_device_pixelmap *self, br_uint_32 *pcolour, br_point *p)
  560. br_error _M_br_device_pixelmap_mem_pixelQuery(br_device_pixelmap* self, br_uint_32* pcolour, br_point* p) {
  561.     //br_point ap; // Pierre-Marie Baty -- unused variable
  562.     //br_int_8 bytes; // Pierre-Marie Baty -- unused variable
  563.     LOG_TRACE("(%p, %p, %p)", self, pcolour, p);
  564.     NOT_IMPLEMENTED();
  565. }
  566.  
  567. // IDA: br_error __cdecl _M_br_device_pixelmap_mem_pixelAddressQuery(br_device_pixelmap *self, void **pptr, br_uint_32 *pqual, br_point *p)
  568. br_error _M_br_device_pixelmap_mem_pixelAddressQuery(br_device_pixelmap* self, void** pptr, br_uint_32* pqual, br_point* p) {
  569.     //br_int_8 bytes; // Pierre-Marie Baty -- unused variable
  570.     //br_point ap; // Pierre-Marie Baty -- unused variable
  571.     LOG_TRACE("(%p, %p, %p, %p)", self, pptr, pqual, p);
  572.     NOT_IMPLEMENTED();
  573. }
  574.  
  575. // IDA: br_error __cdecl _M_br_device_pixelmap_mem_pixelAddressSet(br_device_pixelmap *self, void *ptr, br_uint_32 *qual)
  576. br_error _M_br_device_pixelmap_mem_pixelAddressSet(br_device_pixelmap* self, void* ptr, br_uint_32* qual) {
  577.     LOG_TRACE("(%p, %p, %p)", self, ptr, qual);
  578.     NOT_IMPLEMENTED();
  579. }
  580.  
  581. // IDA: br_error __cdecl _M_br_device_pixelmap_mem_originSet(br_device_pixelmap *self, br_point *p)
  582. br_error _M_br_device_pixelmap_mem_originSet(br_device_pixelmap* self, br_point* p) {
  583.     LOG_TRACE("(%p, %p)", self, p);
  584.     NOT_IMPLEMENTED();
  585. }
  586.  
  587. // IDA: br_error __cdecl _M_br_device_pixelmap_mem_rowSize(br_device_pixelmap *self, br_size_t *sizep)
  588. br_error _M_br_device_pixelmap_mem_rowSize(br_device_pixelmap* self, br_size_t* sizep) {
  589.     LOG_TRACE("(%p, %p)", self, sizep);
  590.     NOT_IMPLEMENTED();
  591. }
  592.  
  593. // IDA: br_error __cdecl _M_br_device_pixelmap_mem_rowQuery(br_device_pixelmap *self, void *buffer, br_size_t buffer_size, br_int_32 row)
  594. br_error _M_br_device_pixelmap_mem_rowQuery(br_device_pixelmap* self, void* buffer, br_size_t buffer_size, br_int_32 row) {
  595.     LOG_TRACE("(%p, %p, %d, %d)", self, buffer, buffer_size, row);
  596.     NOT_IMPLEMENTED();
  597. }
  598.  
  599. // IDA: br_error __cdecl _M_br_device_pixelmap_mem_rowSet(br_device_pixelmap *self, void *buffer, br_size_t buffer_size, br_int_32 row)
  600. br_error _M_br_device_pixelmap_mem_rowSet(br_device_pixelmap* self, void* buffer, br_size_t buffer_size, br_int_32 row) {
  601.     LOG_TRACE("(%p, %p, %d, %d)", self, buffer, buffer_size, row);
  602.     NOT_IMPLEMENTED();
  603. }
  604.  
  605. // IDA: br_error __cdecl _M_br_device_pixelmap_mem_flush(br_device_pixelmap *self)
  606. br_error _M_br_device_pixelmap_mem_flush(br_device_pixelmap* self) {
  607.     LOG_TRACE("(%p)", self);
  608.     NOT_IMPLEMENTED();
  609. }
  610.  
  611. // IDA: br_error __cdecl _M_br_device_pixelmap_mem_synchronise(br_device_pixelmap *self, br_token sync_type, br_boolean block)
  612. br_error _M_br_device_pixelmap_mem_synchronise(br_device_pixelmap* self, br_token sync_type, br_boolean block) {
  613.     LOG_TRACE("(%p, %d, %d)", self, sync_type, block);
  614.     NOT_IMPLEMENTED();
  615. }
  616.  
  617. // IDA: br_error __cdecl _M_br_device_pixelmap_mem_directLock(br_device_pixelmap *self, br_boolean block)
  618. br_error _M_br_device_pixelmap_mem_directLock(br_device_pixelmap* self, br_boolean block) {
  619.     LOG_TRACE("(%p, %d)", self, block);
  620.  
  621.     return 0;
  622. }
  623.  
  624. // IDA: br_error __cdecl _M_br_device_pixelmap_mem_directUnlock(br_device_pixelmap *self)
  625. br_error _M_br_device_pixelmap_mem_directUnlock(br_device_pixelmap* self) {
  626.     LOG_TRACE("(%p)", self);
  627.  
  628.     return 0;
  629. }
  630.