| 1 | /* Mednafen - Multi-system Emulator |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License as published by |
| 5 | * the Free Software Foundation; either version 2 of the License, or |
| 6 | * (at your option) any later version. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this program; if not, write to the Free Software |
| 15 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 16 | */ |
| 17 | |
| 18 | #include "../mednafen.h"cxx . . $ `<file>/mednafen/mednafen.h`/ |
| 19 | #include "surface.h"cxx . . $ `<file>/mednafen/video/surface.h`/ |
| 20 | |
| 21 | #ifdef DISABLE_EXCEPTIONS |
| 22 | #define throw (void)0, |
| 23 | #endif |
| 24 | |
| 25 | |
| 26 | MDFN_PixelFormatcxx . . $ MDFN_PixelFormat#::MDFN_PixelFormatcxx . . $ MDFN_PixelFormat#MDFN_PixelFormat(49f6e7a06ebc5aa8).() |
| 27 | { |
| 28 | bppcxx . . $ MDFN_PixelFormat#bpp. = 0; |
| 29 | colorspacecxx . . $ MDFN_PixelFormat#colorspace. = 0; |
| 30 | |
| 31 | Rshiftcxx . . $ MDFN_PixelFormat#$anonymous_type_2#Rshift. = 0; |
| 32 | Gshiftcxx . . $ MDFN_PixelFormat#$anonymous_type_3#Gshift. = 0; |
| 33 | Bshiftcxx . . $ MDFN_PixelFormat#$anonymous_type_4#Bshift. = 0; |
| 34 | Ashiftcxx . . $ MDFN_PixelFormat#Ashift. = 0; |
| 35 | } |
| 36 | |
| 37 | MDFN_PixelFormatcxx . . $ MDFN_PixelFormat#::MDFN_PixelFormatcxx . . $ MDFN_PixelFormat#MDFN_PixelFormat(fc65991e97fa879e).(const unsigned int p_colorspace, const uint8cxx . . $ uint8# p_rs, const uint8cxx . . $ uint8# p_gs, const uint8cxx . . $ uint8# p_bs, const uint8cxx . . $ uint8# p_as) |
| 38 | { |
| 39 | #if defined(WANT_16BPP) |
| 40 | bpp = 16; |
| 41 | #else |
| 42 | bppcxx . . $ MDFN_PixelFormat#bpp. = 32; |
| 43 | #endif |
| 44 | colorspacecxx . . $ MDFN_PixelFormat#colorspace. = p_colorspace; |
| 45 | |
| 46 | Rshiftcxx . . $ MDFN_PixelFormat#$anonymous_type_2#Rshift. = p_rs; |
| 47 | Gshiftcxx . . $ MDFN_PixelFormat#$anonymous_type_3#Gshift. = p_gs; |
| 48 | Bshiftcxx . . $ MDFN_PixelFormat#$anonymous_type_4#Bshift. = p_bs; |
| 49 | Ashiftcxx . . $ MDFN_PixelFormat#Ashift. = p_as; |
| 50 | } |
| 51 | |
| 52 | MDFN_Surfacecxx . . $ MDFN_Surface#::MDFN_Surfacecxx . . $ MDFN_Surface#MDFN_Surface(49f6e7a06ebc5aa8).() |
| 53 | { |
| 54 | memset(&formatcxx . . $ MDFN_Surface#format., 0, sizeof(formatcxx . . $ MDFN_Surface#format.)); |
| 55 | |
| 56 | pixelscxx . . $ MDFN_Surface#pixels. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 57 | pixels16cxx . . $ MDFN_Surface#pixels16. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 58 | pitchinpixcxx . . $ MDFN_Surface#$anonymous_type_5#pitchinpix. = 0; |
| 59 | wcxx . . $ MDFN_Surface#w. = 0; |
| 60 | hcxx . . $ MDFN_Surface#h. = 0; |
| 61 | } |
| 62 | |
| 63 | MDFN_Surfacecxx . . $ MDFN_Surface#::MDFN_Surfacecxx . . $ MDFN_Surface#MDFN_Surface(82b88fc256abb892).(void *const p_pixels, const uint32cxx . . $ uint32# p_width, const uint32cxx . . $ uint32# p_height, const uint32cxx . . $ uint32# p_pitchinpix, const MDFN_PixelFormatcxx . . $ MDFN_PixelFormat# &nf) |
| 64 | { |
| 65 | Initcxx . . $ MDFN_Surface#Init(82b88fc256abb892).(p_pixels, p_width, p_height, p_pitchinpix, nf); |
| 66 | } |
| 67 | |
| 68 | void MDFN_Surfacecxx . . $ MDFN_Surface#::Initcxx . . $ MDFN_Surface#Init(82b88fc256abb892).(void *const p_pixels, const uint32cxx . . $ uint32# p_width, const uint32cxx . . $ uint32# p_height, const uint32cxx . . $ uint32# p_pitchinpix, const MDFN_PixelFormatcxx . . $ MDFN_PixelFormat# &nf) |
| 69 | { |
| 70 | void *rpix = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 71 | assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(nf.bpp == 16 || nf.bpp == 32); |
| 72 | |
| 73 | formatcxx . . $ MDFN_Surface#format. =cxx . . $ MDFN_PixelFormat#`operator=`(56287c69832f2fa8). nf; |
| 74 | |
| 75 | pixels16cxx . . $ MDFN_Surface#pixels16. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 76 | pixelscxx . . $ MDFN_Surface#pixels. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 77 | #if defined(WANT_8BPP) |
| 78 | palette = NULL; |
| 79 | #endif |
| 80 | |
| 81 | if(!(rpix = calloccxx . . $ calloc(95acc9b79bb49189).(1, p_pitchinpix * p_height * (nf.bppcxx . . $ MDFN_PixelFormat#bpp. / 8)))) |
| 82 | throw(1); |
| 83 | |
| 84 | #if defined(WANT_8BPP) |
| 85 | //if(nf.bpp == 8) |
| 86 | { |
| 87 | pixels8 = (uint8 *)rpix; |
| 88 | palette = (MDFN_PaletteEntry*)calloc(sizeof(MDFN_PaletteEntry), 256); |
| 89 | } |
| 90 | #elif defined(WANT_16BPP) |
| 91 | //if(nf.bpp == 16) |
| 92 | pixels16 = (uint16 *)rpix; |
| 93 | #elif defined(WANT_32BPPcxx . . $ `<built-in>:480:9`!) |
| 94 | //else |
| 95 | pixelscxx . . $ MDFN_Surface#pixels. = (uint32cxx . . $ uint32# *)rpix; |
| 96 | #endif |
| 97 | |
| 98 | wcxx . . $ MDFN_Surface#w. = p_width; |
| 99 | hcxx . . $ MDFN_Surface#h. = p_height; |
| 100 | |
| 101 | pitchinpixcxx . . $ MDFN_Surface#$anonymous_type_5#pitchinpix. = p_pitchinpix; |
| 102 | } |
| 103 | |
| 104 | // When we're converting, only convert the w*h area(AKA leave the last part of the line, pitch32 - w, alone), |
| 105 | // for places where we store auxillary information there(graphics viewer in the debugger), and it'll be faster |
| 106 | // to boot. |
| 107 | void MDFN_Surfacecxx . . $ MDFN_Surface#::SetFormatcxx . . $ MDFN_Surface#SetFormat(ddcbab6c6d8fc277).(const MDFN_PixelFormatcxx . . $ MDFN_PixelFormat# &nf, bool convert) |
| 108 | { |
| 109 | formatcxx . . $ MDFN_Surface#format. =cxx . . $ MDFN_PixelFormat#`operator=`(56287c69832f2fa8). nf; |
| 110 | } |
| 111 | |
| 112 | MDFN_Surfacecxx . . $ MDFN_Surface#::~cxx . . $ MDFN_Surface#`~MDFN_Surface`(ced63f7c635d850d).MDFN_Surfacecxx . . $ MDFN_Surface#() |
| 113 | { |
| 114 | #if defined(WANT_16BPP) |
| 115 | if(pixels16) |
| 116 | free(pixels16); |
| 117 | #elif defined(WANT_32BPPcxx . . $ `<built-in>:480:9`!) |
| 118 | if(pixelscxx . . $ MDFN_Surface#pixels.) |
| 119 | freecxx . . $ free(bd21765a0afc8e3c).(pixelscxx . . $ MDFN_Surface#pixels.); |
| 120 | #elif defined(WANT_8BPP) |
| 121 | pixels8 = NULL; |
| 122 | if(palette) |
| 123 | free(palette); |
| 124 | palette = NULL; |
| 125 | #endif |
| 126 | } |
| 127 |