@@ -486,7 +486,7 @@ int pvsSize[4] = { 0, 0, 0, 0 };
486486unsigned char * PVSEncodeTable = NULL ;
487487
488488// [D] [T]
489- void PVSDecode (char * output , char * celldata , ushort sz , int havanaCorruptCellBodge )
489+ void PVSDecode (char * output , u_char * celldata , ushort sz , int havanaCorruptCellBodge )
490490{
491491 u_char * nybblearray ;
492492 int pixelIndex ;
@@ -503,7 +503,7 @@ void PVSDecode(char *output, char *celldata, ushort sz, int havanaCorruptCellBod
503503
504504 // decode byte-swapped array
505505 for (i = 0 ; i < sz ; i ++ )
506- ((ushort * )nybblearray )[i ] = M_SHRT_2 (( u_char ) celldata [i ], ( u_char ) celldata [i ] >> 4 ) & 0xf0f ;
506+ ((ushort * )nybblearray )[i ] = M_SHRT_2 (celldata [i ], celldata [i ] >> 4 ) & 0xf0f ;
507507
508508 pixelIndex = 0 ;
509509 symIndex = 0 ;
@@ -512,15 +512,15 @@ void PVSDecode(char *output, char *celldata, ushort sz, int havanaCorruptCellBod
512512 // decompress image
513513 while (i < sz * 2 )
514514 {
515- int ni ;
516- int sym ;
515+ u_int ni ;
516+ u_int sym ;
517517
518518 ni = nybblearray [i ++ ];
519519 if (ni < 12 )
520520 {
521521 symIndex = ni * 2 ;
522522 spod :
523- sym = M_SHRT_2 (( u_char ) PVSEncodeTable [symIndex ], ( u_char ) PVSEncodeTable [symIndex + 1 ]);
523+ sym = M_SHRT_2 (PVSEncodeTable [symIndex ], PVSEncodeTable [symIndex + 1 ]);
524524 }
525525 else
526526 {
@@ -534,7 +534,8 @@ void PVSDecode(char *output, char *celldata, ushort sz, int havanaCorruptCellBod
534534 goto spod ;
535535 }
536536
537- sym = ((sym & 3 ) * 16 + nybblearray [i ++ ]) * 16 + nybblearray [i ++ + 1 ];
537+ sym = ((sym & 3 ) * 16 + nybblearray [i ]) * 16 + nybblearray [i + 1 ];
538+ i += 2 ;
538539 }
539540
540541 pixelIndex += (sym >> 1 );
@@ -549,22 +550,22 @@ void PVSDecode(char *output, char *celldata, ushort sz, int havanaCorruptCellBod
549550 decodebuf [pvs_square_sq - 1 ] ^= 1 ;
550551
551552 size = pvs_square - 2 ;
552- op = (decodebuf - 1 ) + (size * pvs_square + pvs_square ) ;
553+ op = (decodebuf - 1 ) + (size + 1 ) * pvs_square ;
553554 for (i = size ; i >= 0 ; -- i )
554555 {
555556 for (j = pvs_square ; j > 0 ; -- j , -- op )
556557 {
557- * op = * op ^ op [pvs_square ];
558+ op [ 0 ] ^= op [pvs_square ];
558559 }
559560 }
560561
561562 size = pvs_square - 1 ;
562- op = (decodebuf - 2 ) + (size * pvs_square + pvs_square ) ;
563+ op = (decodebuf - 2 ) + (size + 1 ) * pvs_square ;
563564 for (i = size ; i >= 0 ; -- i , -- op )
564565 {
565566 for (j = pvs_square - 2 ; j >= 0 ; -- j , -- op )
566567 {
567- * op = * op ^ op [1 ];
568+ * op ^= op [1 ];
568569 }
569570 }
570571
@@ -595,8 +596,8 @@ void GetPVSRegionCell2(int source_region, int region, int cell, char *output)
595596{
596597 int k ;
597598 u_int havanaCorruptCellBodge ;
598- char * tbp ;
599- char * bp ;
599+ u_char * tbp ;
600+ u_char * bp ;
600601 ushort length ;
601602
602603#ifndef PSX
@@ -612,17 +613,17 @@ void GetPVSRegionCell2(int source_region, int region, int cell, char *output)
612613
613614 if (regions_unpacked [source_region ] == region && loading_region [source_region ] == -1 )
614615 {
615- bp = PVS_Buffers [source_region ];
616+ bp = ( u_char * ) PVS_Buffers [source_region ];
616617 PVSEncodeTable = (u_char * )(bp + 0x802 );
617618 tbp = bp + cell * 2 ;
618619
619- length = M_SHRT_2 (( u_char ) tbp [2 ], ( u_char ) tbp [3 ]) - M_SHRT_2 (( u_char ) tbp [0 ], ( u_char ) tbp [1 ]) & 0xffff ;
620+ length = M_SHRT_2 (tbp [2 ], tbp [3 ]) - M_SHRT_2 (tbp [0 ], tbp [1 ]);
620621
621622 if (length != 0 )
622623 {
623624 havanaCorruptCellBodge = (regions_unpacked [source_region ] == 158 && cell == 168 );
624625
625- PVSDecode (output , bp + M_SHRT_2 (( u_char ) tbp [0 ], ( u_char ) tbp [1 ]), length , havanaCorruptCellBodge );
626+ PVSDecode (output , bp + M_SHRT_2 (tbp [0 ], tbp [1 ]), length , havanaCorruptCellBodge );
626627 }
627628 else
628629 {
0 commit comments