@@ -12,21 +12,19 @@ BResourceManager gResourceManager((TAny *)Resources_start);
1212
1313#include < stdio.h>
1414
15-
1615#ifdef __linux__
1716
1817// LINUX TARGET
1918asm (
20- " .section .rodata\n "
21- " .global binary_Resources_bin_start\n "
22- " .global binary_Resources_bin_end\n "
23- " .balign 16\n "
24- " binary_Resources_bin_start:\n "
25- " .incbin \" Resources.bin\"\n "
26- " binary_Resources_bin_end:\n "
27- " .byte 0\n "
28- " .align 4\n "
29- );
19+ " .section .rodata\n "
20+ " .global binary_Resources_bin_start\n "
21+ " .global binary_Resources_bin_end\n "
22+ " .balign 16\n "
23+ " binary_Resources_bin_start:\n "
24+ " .incbin \" Resources.bin\"\n "
25+ " binary_Resources_bin_end:\n "
26+ " .byte 0\n "
27+ " .align 4\n " );
3028// extern TUint8 binary_Resources_bin_end[];\n"
3129extern __attribute ((aligned(16 ))) TUint8 binary_Resources_bin_start[];
3230// extern TUint8 binary_Resources_bin_start[];
@@ -35,60 +33,59 @@ extern __attribute((aligned(16))) TUint8 binary_Resources_bin_start[];
3533
3634// MAC TARGET
3735asm (
38- " .section .rodata,.rodata\n "
39- " .global _binary_Resources_bin_start\n "
40- " .global _binary_Resources_bin_end\n "
41- " .align 4\n "
42- " _binary_Resources_bin_start:\n "
43- " .incbin \" Resources.bin\"\n "
44- " _binary_Resources_bin_end:\n "
45- " .byte 0\n "
46- " .align 4\n "
47- );
36+ " .section .rodata,.rodata\n "
37+ " .global _binary_Resources_bin_start\n "
38+ " .global _binary_Resources_bin_end\n "
39+ " .align 4\n "
40+ " _binary_Resources_bin_start:\n "
41+ " .incbin \" Resources.bin\"\n "
42+ " _binary_Resources_bin_end:\n "
43+ " .byte 0\n "
44+ " .align 4\n " );
4845extern " C" {
4946extern TUint8 binary_Resources_bin_start[];
5047extern TUint8 binary_Resources_bin_end[];
5148// extern TUint8 binary_Resources_bin_start[];
5249}
5350
54- #endif // MAC TARGET
51+ #endif // MAC TARGET
5552
5653BResourceManager gResourceManager (binary_Resources_bin_start);
5754
58- #endif // LINUX OR MAC TARGET
55+ #endif // LINUX OR MAC TARGET
5956
6057struct BitmapSlot {
6158 BitmapSlot (TInt16 aResourceId, TInt16 aImageType, BBitmap *aBitmap, TBool aCached = EFalse) {
6259 mResourceId = aResourceId;
63- mImageType = aImageType;
64- mBitmap = aBitmap;
65- mCached = aCached;
60+ mImageType = aImageType;
61+ mBitmap = aBitmap;
62+ mCached = aCached;
6663 }
6764
68- TInt16 mResourceId ;
69- TInt16 mImageType ;
65+ TInt16 mResourceId ;
66+ TInt16 mImageType ;
7067 BBitmap *mBitmap ;
71- TBool mCached ;
68+ TBool mCached ;
7269};
7370
7471struct RawSlot {
7572 RawSlot (TInt16 aResourceId, BRaw *aRaw, TBool aCached = EFalse) {
7673 mResourceId = aResourceId;
77- mCached = aCached;
78- mRaw = aRaw;
74+ mCached = aCached;
75+ mRaw = aRaw;
7976 }
8077
8178 TInt16 mResourceId ;
82- BRaw *mRaw ;
83- TBool mCached ;
79+ BRaw *mRaw ;
80+ TBool mCached ;
8481};
8582
8683BResourceManager::BResourceManager (TAny *aROM) {
87- TUint32 *ptr = (TUint32 *) aROM;
88- this ->mPtr = aROM;
89- this ->mNumResources = *ptr++;
84+ TUint32 *ptr = (TUint32 *)aROM;
85+ this ->mPtr = aROM;
86+ this ->mNumResources = *ptr++;
9087 this ->mResourceTable = ptr;
91- this ->mROM = (TUint8 *) &ptr[this ->mNumResources ];
88+ this ->mROM = (TUint8 *)&ptr[this ->mNumResources ];
9289 for (TInt i = 0 ; i < MAX_BITMAP_SLOTS ; i++) {
9390 mBitmapSlots [i] = ENull;
9491 }
@@ -98,7 +95,7 @@ BResourceManager::BResourceManager(TAny *aROM) {
9895 for (TInt i = 0 ; i < MAX_RAW_SLOTS ; i++) {
9996 mRawSlots [i] = ENull;
10097 }
101- // Dump();
98+ // Dump();
10299}
103100
104101BResourceManager::~BResourceManager () {
@@ -110,21 +107,20 @@ BResourceManager::~BResourceManager() {
110107TPalette *BResourceManager::LoadPalette (TInt16 aPaletteId) {
111108 TUint8 *rom = &this ->mROM [this ->mResourceTable [aPaletteId]];
112109 TPalette *p = new TPalette[256 ];
113- for (TInt c= 0 ; c< 256 ; c++) {
110+ for (TInt c = 0 ; c < 256 ; c++) {
114111 p[c].r = *rom++;
115112 p[c].g = *rom++;
116113 p[c].b = *rom++;
117114 }
118115 return p;
119116}
120117
121-
122118void BResourceManager::FreePalette (TPalette *aPalette) {
123- delete [] aPalette;
119+ delete[] aPalette;
124120}
125121
126122BBitmap *BResourceManager::LoadBitmap (TInt16 aResourceId) {
127- return new BBitmap (&this ->mROM [this ->mResourceTable [aResourceId]]);
123+ return BBitmap::CreateBBitmap (&this ->mROM [this ->mResourceTable [aResourceId]]);
128124}
129125
130126BTileMap *BResourceManager::LoadTileMap (TInt16 aResourceId, TInt16 aTilesetId) {
@@ -142,7 +138,7 @@ TBool BResourceManager::LoadBitmap(TInt16 aResourceId, TInt16 aSlotId, TInt16 aI
142138 mBitmapSlots [aSlotId] = new BitmapSlot (aResourceId, aImageType, bm);
143139 }
144140 else {
145- auto *bm = new BBitmap (&this ->mROM [this ->mResourceTable [aResourceId]]);
141+ auto *bm = BBitmap::CreateBBitmap (&this ->mROM [this ->mResourceTable [aResourceId]]);
146142 mBitmapSlots [aSlotId] = new BitmapSlot (aResourceId, aImageType, bm);
147143 }
148144 return ETrue;
@@ -152,7 +148,7 @@ TBool BResourceManager::PreloadBitmap(TInt16 aResourceId) {
152148 if (mPreloadedBitmaps [aResourceId]) {
153149 delete mPreloadedBitmaps [aResourceId];
154150 }
155- auto *bm = new BBitmap (&this ->mROM [this ->mResourceTable [aResourceId]]);
151+ auto *bm = BBitmap::CreateBBitmap (&this ->mROM [this ->mResourceTable [aResourceId]]);
156152 mPreloadedBitmaps [aResourceId] = bm;
157153 return ETrue;
158154}
@@ -225,7 +221,7 @@ TInt BResourceManager::BitmapWidth(TInt aSlotId) {
225221 64 , 128 , 64 , 256 ,
226222 128 , 256 , 256
227223 };
228- BitmapSlot *slot = mBitmapSlots [aSlotId];
224+ BitmapSlot *slot = mBitmapSlots [aSlotId];
229225 if (!slot) {
230226 return 0 ;
231227 }
@@ -242,7 +238,7 @@ TInt BResourceManager::BitmapHeight(TInt aSlotId) {
242238 128 , 64 , 256 , 64 ,
243239 128 , 256 , 256
244240 };
245- BitmapSlot *slot = mBitmapSlots [aSlotId];
241+ BitmapSlot *slot = mBitmapSlots [aSlotId];
246242 if (!slot) {
247243 return 0 ;
248244 }
@@ -302,21 +298,20 @@ BRaw *BResourceManager::GetRaw(TInt16 aSlotId) {
302298 return slot->mRaw ;
303299}
304300
305-
306301void BResourceManager::Dump () {
307- // #ifndef PRODUCTION
308- // #if (defined(__XTENSA__) && defined(DEBUGME)) || !defined(__XTENSA__)
302+ // #ifndef PRODUCTION
303+ // #if (defined(__XTENSA__) && defined(DEBUGME)) || !defined(__XTENSA__)
309304 printf (" BResourceManager Dump\n " );
310305 printf (" mNumResources: %d\n " , mNumResources );
311306 printf (" OFFSETS:\n " );
312307 for (TInt i = 0 ; i < mNumResources ; i++) {
313308 printf (" %8d: " , mResourceTable [i]);
314- TUint8 *ptr = &mROM [mResourceTable [i]];
315- for (TInt j = 0 ; j < 16 ; j++) {
309+ TUint8 *ptr = &mROM [mResourceTable [i]];
310+ for (TInt j = 0 ; j < 16 ; j++) {
316311 printf (" %02x " , *ptr++);
317312 }
318313 printf (" \n " );
319314 }
320- // #endif
321- // #endif
315+ // #endif
316+ // #endif
322317}
0 commit comments