@@ -86,7 +86,7 @@ void bgAddTileToTotal(REDUCTION *reduction, int *pxBlock, BGTILE *tile) {
86
86
for (int y = 0 ; y < 8 ; y ++ ) {
87
87
for (int x = 0 ; x < 8 ; x ++ ) {
88
88
COLOR32 col = tile -> px [x + y * 8 ];
89
-
89
+
90
90
int x2 = (tile -> flipMode & TILE_FLIPX ) ? (7 - x ) : x ;
91
91
int y2 = (tile -> flipMode & TILE_FLIPY ) ? (7 - y ) : y ;
92
92
int * dest = pxBlock + 4 * (x2 + y2 * 8 );
@@ -199,7 +199,7 @@ void tdlReset(TILE_DIFF_LIST *list) {
199
199
}
200
200
201
201
int performCharacterCompression (BGTILE * tiles , int nTiles , int nBits , int nMaxChars , COLOR32 * palette , int paletteSize , int nPalettes ,
202
- int paletteBase , int paletteOffset , int balance , int colorBalance , int * progress ) {
202
+ int paletteBase , int paletteOffset , int balance , int colorBalance , int * progress ) {
203
203
int nChars = nTiles ;
204
204
float * diffBuff = (float * ) calloc (nTiles * nTiles , sizeof (float ));
205
205
unsigned char * flips = (unsigned char * ) calloc (nTiles * nTiles , 1 ); //how must each tile be manipulated to best match its partner
@@ -239,7 +239,7 @@ int performCharacterCompression(BGTILE *tiles, int nTiles, int nBits, int nMaxCh
239
239
}
240
240
}
241
241
nChars -- ;
242
- if (nTiles > nMaxChars ) * progress = 500 + (int ) (500 * sqrt ((float ) (nTiles - nChars ) / (nTiles - nMaxChars )));
242
+ if (nTiles > nMaxChars ) * progress = 500 + (int ) (500 * sqrt ((float ) (nTiles - nChars ) / (nTiles - nMaxChars )));
243
243
}
244
244
}
245
245
}
@@ -275,7 +275,7 @@ int performCharacterCompression(BGTILE *tiles, int nTiles, int nBits, int nMaxCh
275
275
tdlAdd (& tdl , j , i , thisError );
276
276
}
277
277
}
278
-
278
+
279
279
//now merge tiles while we can
280
280
int tile1 , tile2 ;
281
281
while (tdl .diffBuffLength > 0 && nChars > nMaxChars ) {
@@ -375,7 +375,7 @@ int performCharacterCompression(BGTILE *tiles, int nTiles, int nBits, int nMaxCh
375
375
376
376
//now, match colors to indices.
377
377
COLOR32 * pal = palette + (bestPalette << nBits );
378
- ditherImagePaletteEx (tile -> px , NULL , 8 , 8 , pal + paletteOffset + !paletteOffset ,
378
+ ditherImagePaletteEx (tile -> px , NULL , 8 , 8 , pal + paletteOffset + !paletteOffset ,
379
379
paletteSize - !paletteOffset , 0 , 1 , 0 , 0.0f , balance , colorBalance , 0 );
380
380
for (int j = 0 ; j < 64 ; j ++ ) {
381
381
COLOR32 col = tile -> px [j ];
@@ -384,7 +384,7 @@ int performCharacterCompression(BGTILE *tiles, int nTiles, int nBits, int nMaxCh
384
384
index = closestPalette (col , pal + paletteOffset + !paletteOffset , paletteSize - !paletteOffset )
385
385
+ !paletteOffset + paletteOffset ;
386
386
}
387
-
387
+
388
388
tile -> indices [j ] = index ;
389
389
tile -> px [j ] = index ? (pal [index ] | 0xFF000000 ) : 0 ;
390
390
}
@@ -444,10 +444,10 @@ void setupBgTilesEx(BGTILE *tiles, int nTiles, int nBits, COLOR32 *palette, int
444
444
COLOR32 col = tile -> px [j ];
445
445
int index = 0 ;
446
446
if (((col >> 24 ) & 0xFF ) > 127 ) {
447
- index = closestPalette (col , pal + paletteOffset + !paletteOffset , paletteSize - !paletteOffset )
447
+ index = closestPalette (col , pal + paletteOffset + !paletteOffset , paletteSize - !paletteOffset )
448
448
+ !paletteOffset + paletteOffset ;
449
449
}
450
-
450
+
451
451
tile -> indices [j ] = index ;
452
452
tile -> px [j ] = index ? (pal [index ] | 0xFF000000 ) : 0 ;
453
453
@@ -464,12 +464,12 @@ void setupBgTilesEx(BGTILE *tiles, int nTiles, int nBits, COLOR32 *palette, int
464
464
}
465
465
466
466
void bgGenerate (COLOR32 * imgBits , int width , int height , int nBits , int dither , float diffuse ,
467
- COLOR * * pOutPalette , unsigned char * * pOutChars , unsigned short * * pOutScreen ,
468
- int * outPalSize , int * outCharSize , int * outScreenSize ,
469
- int paletteBase , int nPalettes , int fmt , int tileBase , int mergeTiles ,
470
- int paletteSize , int paletteOffset , int rowLimit , int nMaxChars ,
471
- int balance , int colorBalance , int enhanceColors ,
472
- int * progress1 , int * progress1Max , int * progress2 , int * progress2Max ) {
467
+ COLOR * * pOutPalette , unsigned char * * pOutChars , unsigned short * * pOutScreen ,
468
+ int * outPalSize , int * outCharSize , int * outScreenSize ,
469
+ int paletteBase , int nPalettes , int fmt , int tileBase , int mergeTiles ,
470
+ int paletteSize , int paletteOffset , int rowLimit , int nMaxChars ,
471
+ int balance , int colorBalance , int enhanceColors ,
472
+ int * progress1 , int * progress1Max , int * progress2 , int * progress2Max ) {
473
473
474
474
//cursory sanity checks
475
475
if (nBits == 4 ) {
@@ -502,7 +502,7 @@ void bgGenerate(COLOR32 *imgBits, int width, int height, int nBits, int dither,
502
502
//initialize progress
503
503
* progress1Max = nTiles * 2 ; //2 passes
504
504
* progress2Max = 1000 ;
505
-
505
+
506
506
COLOR32 * palette = (COLOR32 * ) calloc (256 , 4 );
507
507
if (nBits < 5 ) nBits = 4 ;
508
508
else nBits = 8 ;
@@ -520,7 +520,7 @@ void bgGenerate(COLOR32 *imgBits, int width, int height, int nBits, int dither,
520
520
}
521
521
}
522
522
* progress1 = nTiles * 2 ; //make sure it's done
523
-
523
+
524
524
//split image into 8x8 tiles.
525
525
for (int y = 0 ; y < tilesY ; y ++ ) {
526
526
for (int x = 0 ; x < tilesX ; x ++ ) {
@@ -543,7 +543,7 @@ void bgGenerate(COLOR32 *imgBits, int width, int height, int nBits, int dither,
543
543
//match tiles to each other
544
544
int nChars = nTiles ;
545
545
if (mergeTiles ) {
546
- nChars = performCharacterCompression (tiles , nTiles , nBits , nMaxChars , palette , paletteSize , nPalettes , paletteBase ,
546
+ nChars = performCharacterCompression (tiles , nTiles , nBits , nMaxChars , palette , paletteSize , nPalettes , paletteBase ,
547
547
paletteOffset , balance , colorBalance , progress2 );
548
548
}
549
549
0 commit comments