summaryrefslogtreecommitdiff
path: root/apps/plugins/pacbox/arcade.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/pacbox/arcade.c')
-rw-r--r--apps/plugins/pacbox/arcade.c63
1 files changed, 41 insertions, 22 deletions
diff --git a/apps/plugins/pacbox/arcade.c b/apps/plugins/pacbox/arcade.c
index e7bf124700..dc3ea0c9ba 100644
--- a/apps/plugins/pacbox/arcade.c
+++ b/apps/plugins/pacbox/arcade.c
@@ -252,19 +252,19 @@ static unsigned decodePaletteByte( unsigned char value )
252 unsigned bit0, bit1, bit2; 252 unsigned bit0, bit1, bit2;
253 unsigned red, green, blue; 253 unsigned red, green, blue;
254 254
255 bit0 = (value >> 0) & 0x01; 255 bit0 = (value >> 0) & 0x01;
256 bit1 = (value >> 1) & 0x01; 256 bit1 = (value >> 1) & 0x01;
257 bit2 = (value >> 2) & 0x01; 257 bit2 = (value >> 2) & 0x01;
258 red = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; 258 red = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
259 259
260 bit0 = (value >> 3) & 0x01; 260 bit0 = (value >> 3) & 0x01;
261 bit1 = (value >> 4) & 0x01; 261 bit1 = (value >> 4) & 0x01;
262 bit2 = (value >> 5) & 0x01; 262 bit2 = (value >> 5) & 0x01;
263 green = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; 263 green = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
264 264
265 bit0 = 0; 265 bit0 = 0;
266 bit1 = (value >> 6) & 0x01; 266 bit1 = (value >> 6) & 0x01;
267 bit2 = (value >> 7) & 0x01; 267 bit2 = (value >> 7) & 0x01;
268 blue = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; 268 blue = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
269 269
270 return (blue << 16 ) | (green << 8) | red; 270 return (blue << 16 ) | (green << 8) | red;
@@ -428,6 +428,7 @@ inline void drawSprite( unsigned char * buffer, int index )
428{ 428{
429 struct PacmanSprite ps = sprites_[index]; 429 struct PacmanSprite ps = sprites_[index];
430 int x,y; 430 int x,y;
431 char * s, * s2;
431 432
432 // Exit now if sprite not visible at all 433 // Exit now if sprite not visible at all
433 if( (ps.color == 0) || (ps.x >= ScreenWidth) || (ps.y < 16) || (ps.y >= (ScreenHeight-32)) ) { 434 if( (ps.color == 0) || (ps.x >= ScreenWidth) || (ps.y < 16) || (ps.y >= (ScreenHeight-32)) ) {
@@ -436,59 +437,77 @@ inline void drawSprite( unsigned char * buffer, int index )
436 437
437 // Clip the sprite coordinates to cut the parts that fall off the screen 438 // Clip the sprite coordinates to cut the parts that fall off the screen
438 int start_x = (ps.x < 0) ? 0 : ps.x; 439 int start_x = (ps.x < 0) ? 0 : ps.x;
439 int end_x = (ps.x < (ScreenWidth-16)) ? ps.x+16 : ScreenWidth; 440 int end_x = (ps.x < (ScreenWidth-16)) ? ps.x+15 : ScreenWidth-1;
440 441
441 // Prepare variables for drawing 442 // Prepare variables for drawing
442 int color = (ps.color & 0x3F)*4; 443 int color = (ps.color & 0x3F)*4;
443 unsigned char * spritemap_base = spritemap_ + ((ps.n & 0x3F)*256); 444 unsigned char * spritemap_base = spritemap_ + ((ps.n & 0x3F)*256);
444 445
445 buffer += ScreenWidth*ps.y; 446 buffer += ScreenWidth*ps.y;
447 s2 = &spritemap_base[start_x-ps.x];
448
449 dirty_[(start_x >> 3) + (ps.y >> 3)*28] = 1;
450 dirty_[(start_x >> 3) + 1 + (ps.y >> 3)*28] = 1;
451 dirty_[(end_x >> 3) + (ps.y >> 3)*28] = 1;
452 dirty_[(start_x >> 3) + ((ps.y >> 3)+1)*28] = 1;
453 dirty_[(start_x >> 3) + 1 + ((ps.y >> 3)+1)*28] = 1;
454 dirty_[(end_x >> 3) + ((ps.y >> 3)+1)*28] = 1;
455 dirty_[(start_x >> 3) + ((ps.y+15) >> 3)*28] = 1;
456 dirty_[(start_x >> 3) + 1 + ((ps.y+15) >> 3)*28] = 1;
457 dirty_[(end_x >> 3) + ((ps.y+15) >> 3)*28] = 1;
446 458
447 // Draw the 16x16 sprite 459 // Draw the 16x16 sprite
448 if( ps.mode == 0 ) { // Normal 460 if( ps.mode == 0 ) { // Normal
449 // Draw the 16x16 sprite 461 // Draw the 16x16 sprite
450 for( y=0; y<16; y++ ) { 462 for( y=15; y>=0; y-- ) {
451 char* s = &spritemap_base[start_x-ps.x+y*16]; 463 s = s2;
452 for( x=start_x; x<end_x; x++ ) { 464 for( x=start_x; x<=end_x; x++ ) {
453 int c = *(s++); 465 int c = *(s++);
454 if( c ) { 466 if( c ) {
455 buffer[x] = c + color; 467 buffer[x] = c + color;
456 } 468 }
457 } 469 }
458 buffer += ScreenWidth; 470 buffer += ScreenWidth;
471 s2 += 16;
459 } 472 }
460 } else if( ps.mode == 1 ) { // Flip Y 473 } else if( ps.mode == 1 ) { // Flip Y
461 for( y=0; y<16; y++ ) { 474 s2 += 240;
462 char* s = &spritemap_base[start_x-ps.x+(15-y)*16]; 475 for( y=15; y>=0; y-- ) {
463 for( x=start_x; x<end_x; x++ ) { 476 s = s2;
477 for( x=start_x; x<=end_x; x++ ) {
464 int c = *(s++); 478 int c = *(s++);
465 if( c ) { 479 if( c ) {
466 buffer[x] = c + color; 480 buffer[x] = c + color;
467 } 481 }
468 } 482 }
469 buffer += ScreenWidth; 483 buffer += ScreenWidth;
484 s2 -= 16;
470 } 485 }
471 } else if( ps.mode == 2 ) { // Flip X 486 } else if( ps.mode == 2 ) { // Flip X
472 for( y=0; y<16; y++ ) { 487 s2 += 15;
473 char* s = &spritemap_base[15-start_x+ps.x+y*16]; 488 for( y=15; y>=-0; y-- ) {
474 for( x=start_x; x<end_x; x++ ) { 489 s = s2;
490 for( x=start_x; x<=end_x; x++ ) {
475 int c = *(s--); 491 int c = *(s--);
476 if( c ) { 492 if( c ) {
477 buffer[x] = c + color; 493 buffer[x] = c + color;
478 } 494 }
479 } 495 }
480 buffer += ScreenWidth; 496 buffer += ScreenWidth;
497 s2 += 16;
481 } 498 }
482 } else { // Flip X and Y 499 } else { // Flip X and Y
483 for( y=0; y<16; y++ ) { 500 s2 += 255;
484 char* s = &spritemap_base[15-start_x+ps.x+(15-y)*16]; 501 for( y=15; y>=0; y-- ) {
485 for( x=start_x; x<end_x; x++ ) { 502 s = s2;
503 for( x=start_x; x<=end_x; x++ ) {
486 int c = *(s--); 504 int c = *(s--);
487 if( c ) { 505 if( c ) {
488 buffer[x] = c + color; 506 buffer[x] = c + color;
489 } 507 }
490 } 508 }
491 buffer += ScreenWidth; 509 buffer += ScreenWidth;
510 s2 -= 16;
492 } 511 }
493 } 512 }
494} 513}