Mercurial > sdl-ios-xcode
comparison src/video/xbios/SDL_xbios.c @ 735:abec2a842d11
Use new C2P routine
author | Patrice Mandin <patmandin@gmail.com> |
---|---|
date | Wed, 12 Nov 2003 18:46:48 +0000 |
parents | 8be92df64b22 |
children | b8d311d90021 |
comparison
equal
deleted
inserted
replaced
734:0310bb01091f | 735:abec2a842d11 |
---|---|
49 #include "SDL_sysvideo.h" | 49 #include "SDL_sysvideo.h" |
50 #include "SDL_pixels_c.h" | 50 #include "SDL_pixels_c.h" |
51 #include "SDL_events_c.h" | 51 #include "SDL_events_c.h" |
52 | 52 |
53 #include "SDL_ataric2p_s.h" | 53 #include "SDL_ataric2p_s.h" |
54 #include "SDL_ataric2p060_c.h" | |
55 #include "SDL_atarievents_c.h" | 54 #include "SDL_atarievents_c.h" |
56 #include "SDL_atarimxalloc_c.h" | 55 #include "SDL_atarimxalloc_c.h" |
57 #include "SDL_xbios.h" | 56 #include "SDL_xbios.h" |
58 | 57 |
59 #define XBIOS_VID_DRIVER_NAME "xbios" | 58 #define XBIOS_VID_DRIVER_NAME "xbios" |
59 | |
60 /*#define DEBUG_VIDEO_XBIOS 1*/ | |
60 | 61 |
61 /* Initialization/Query functions */ | 62 /* Initialization/Query functions */ |
62 static int XBIOS_VideoInit(_THIS, SDL_PixelFormat *vformat); | 63 static int XBIOS_VideoInit(_THIS, SDL_PixelFormat *vformat); |
63 static SDL_Rect **XBIOS_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); | 64 static SDL_Rect **XBIOS_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); |
64 static SDL_Surface *XBIOS_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); | 65 static SDL_Surface *XBIOS_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); |
183 free(device); | 184 free(device); |
184 } | 185 } |
185 return(0); | 186 return(0); |
186 } | 187 } |
187 memset(device->hidden, 0, (sizeof *device->hidden)); | 188 memset(device->hidden, 0, (sizeof *device->hidden)); |
188 | |
189 atari_test_cpu060_present(); | |
190 | 189 |
191 /* Video functions */ | 190 /* Video functions */ |
192 device->VideoInit = XBIOS_VideoInit; | 191 device->VideoInit = XBIOS_VideoInit; |
193 device->ListModes = XBIOS_ListModes; | 192 device->ListModes = XBIOS_ListModes; |
194 device->SetVideoMode = XBIOS_SetVideoMode; | 193 device->SetVideoMode = XBIOS_SetVideoMode; |
384 /* Update hardware info */ | 383 /* Update hardware info */ |
385 this->info.hw_available = 1; | 384 this->info.hw_available = 1; |
386 this->info.video_mem = (Uint32) Atari_SysMalloc(-1L, MX_STRAM); | 385 this->info.video_mem = (Uint32) Atari_SysMalloc(-1L, MX_STRAM); |
387 | 386 |
388 /* Init chunky to planar routine */ | 387 /* Init chunky to planar routine */ |
389 Atari_C2pInit = Atari_C2pInit8; | 388 SDL_Atari_C2pConvert = SDL_Atari_C2pConvert8; |
390 if (atari_cpu060_avail) { | |
391 Atari_C2pConvert = Atari_C2pConvert8_060; | |
392 } else { | |
393 Atari_C2pConvert = Atari_C2pConvert8; | |
394 } | |
395 Atari_C2pInit(); | |
396 | 389 |
397 /* We're done! */ | 390 /* We're done! */ |
398 return(0); | 391 return(0); |
399 } | 392 } |
400 | 393 |
456 | 449 |
457 /* Allocate needed buffers: simple/double buffer and shadow surface */ | 450 /* Allocate needed buffers: simple/double buffer and shadow surface */ |
458 new_video_mode = XBIOS_videomodes[bpp][mode]; | 451 new_video_mode = XBIOS_videomodes[bpp][mode]; |
459 new_depth = new_video_mode->depth; | 452 new_depth = new_video_mode->depth; |
460 if (new_depth == 4) { | 453 if (new_depth == 4) { |
461 Atari_C2pInit = Atari_C2pInit4; | 454 SDL_Atari_C2pConvert = SDL_Atari_C2pConvert4; |
462 if (atari_cpu060_avail) { | |
463 Atari_C2pConvert = Atari_C2pConvert4_060; | |
464 } else { | |
465 Atari_C2pConvert = Atari_C2pConvert4; | |
466 } | |
467 new_depth=8; | 455 new_depth=8; |
468 modeflags |= SDL_SWSURFACE; | 456 modeflags |= SDL_SWSURFACE; |
469 } else if (new_depth == 8) { | 457 } else if (new_depth == 8) { |
470 Atari_C2pInit = Atari_C2pInit8; | 458 SDL_Atari_C2pConvert = SDL_Atari_C2pConvert8; |
471 if (atari_cpu060_avail) { | |
472 Atari_C2pConvert = Atari_C2pConvert8_060; | |
473 } else { | |
474 Atari_C2pConvert = Atari_C2pConvert8; | |
475 } | |
476 modeflags |= SDL_SWSURFACE|SDL_HWPALETTE; | 459 modeflags |= SDL_SWSURFACE|SDL_HWPALETTE; |
477 } else { | 460 } else { |
478 modeflags |= SDL_HWSURFACE; | 461 modeflags |= SDL_HWSURFACE; |
479 } | 462 } |
480 | 463 |
545 current->pixels = XBIOS_screens[0]; | 528 current->pixels = XBIOS_screens[0]; |
546 | 529 |
547 XBIOS_fbnum = 0; | 530 XBIOS_fbnum = 0; |
548 | 531 |
549 /* Now set the video mode */ | 532 /* Now set the video mode */ |
533 #ifndef DEBUG_VIDEO_XBIOS | |
550 Setscreen(-1,XBIOS_screens[0],-1); | 534 Setscreen(-1,XBIOS_screens[0],-1); |
535 #endif | |
551 | 536 |
552 switch(XBIOS_cvdo >> 16) { | 537 switch(XBIOS_cvdo >> 16) { |
553 case VDO_ST: | 538 case VDO_ST: |
539 #ifndef DEBUG_VIDEO_XBIOS | |
554 Setscreen(-1,-1,new_video_mode->number); | 540 Setscreen(-1,-1,new_video_mode->number); |
541 #endif | |
555 /* Reset palette */ | 542 /* Reset palette */ |
556 for (i=0;i<16;i++) { | 543 for (i=0;i<16;i++) { |
557 int c; | 544 int c; |
558 | 545 |
559 c = ((i>>1)<<8) | ((i>>1)<<4) | (i>>1); | 546 c = ((i>>1)<<8) | ((i>>1)<<4) | (i>>1); |
562 if (i==14) | 549 if (i==14) |
563 c -= 1<<8; | 550 c -= 1<<8; |
564 | 551 |
565 TT_palette[i]= c; | 552 TT_palette[i]= c; |
566 } | 553 } |
554 #ifndef DEBUG_VIDEO_XBIOS | |
567 Setpalette(TT_palette); | 555 Setpalette(TT_palette); |
556 #endif | |
568 break; | 557 break; |
569 case VDO_STE: | 558 case VDO_STE: |
559 #ifndef DEBUG_VIDEO_XBIOS | |
570 Setscreen(-1,-1,new_video_mode->number); | 560 Setscreen(-1,-1,new_video_mode->number); |
561 #endif | |
571 /* Reset palette */ | 562 /* Reset palette */ |
572 for (i=0;i<16;i++) | 563 for (i=0;i<16;i++) |
573 { | 564 { |
574 int c; | 565 int c; |
575 | 566 |
576 c=((i&1)<<3)|((i>>1)&7); | 567 c=((i&1)<<3)|((i>>1)&7); |
577 TT_palette[i]=(c<<8)|(c<<4)|c; | 568 TT_palette[i]=(c<<8)|(c<<4)|c; |
578 } | 569 } |
570 #ifndef DEBUG_VIDEO_XBIOS | |
579 Setpalette(TT_palette); | 571 Setpalette(TT_palette); |
572 #endif | |
580 break; | 573 break; |
581 case VDO_TT: | 574 case VDO_TT: |
575 #ifndef DEBUG_VIDEO_XBIOS | |
582 EsetShift(new_video_mode->number); | 576 EsetShift(new_video_mode->number); |
577 #endif | |
583 break; | 578 break; |
584 case VDO_F30: | 579 case VDO_F30: |
580 #ifndef DEBUG_VIDEO_XBIOS | |
585 Vsetmode(new_video_mode->number); | 581 Vsetmode(new_video_mode->number); |
582 #endif | |
586 break; | 583 break; |
587 } | 584 } |
588 | 585 |
589 Vsync(); | 586 Vsync(); |
590 | 587 |
649 destination = destscr; | 646 destination = destscr; |
650 destination += XBIOS_pitch * rects[i].y; | 647 destination += XBIOS_pitch * rects[i].y; |
651 destination += x1; | 648 destination += x1; |
652 | 649 |
653 /* Convert chunky to planar screen */ | 650 /* Convert chunky to planar screen */ |
654 Atari_C2pConvert( | 651 SDL_Atari_C2pConvert( |
655 source, | 652 source, |
656 destination, | 653 destination, |
657 x2-x1, | 654 x2-x1, |
658 rects[i].h, | 655 rects[i].h, |
659 XBIOS_doubleline, | 656 XBIOS_doubleline, |
661 XBIOS_pitch | 658 XBIOS_pitch |
662 ); | 659 ); |
663 } | 660 } |
664 } | 661 } |
665 | 662 |
663 #ifndef DEBUG_VIDEO_XBIOS | |
666 Setscreen(-1,XBIOS_screens[XBIOS_fbnum],-1); | 664 Setscreen(-1,XBIOS_screens[XBIOS_fbnum],-1); |
665 #endif | |
667 Vsync(); | 666 Vsync(); |
668 | 667 |
669 if ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) { | 668 if ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) { |
670 XBIOS_fbnum ^= 1; | 669 XBIOS_fbnum ^= 1; |
671 if ((surface->format->BitsPerPixel) > 8) { | 670 if ((surface->format->BitsPerPixel) > 8) { |
686 destx = (XBIOS_width - surface->w) >> 1; | 685 destx = (XBIOS_width - surface->w) >> 1; |
687 destx &= ~15; | 686 destx &= ~15; |
688 destscr += destx; | 687 destscr += destx; |
689 | 688 |
690 /* Convert chunky to planar screen */ | 689 /* Convert chunky to planar screen */ |
691 Atari_C2pConvert( | 690 #ifdef DEBUG_VIDEO_XBIOS |
691 printf("C2p:\n"); | |
692 printf(" Source: Adr=0x%08x, Pitch=%d\n", surface->pixels, surface->pitch); | |
693 printf(" Dest: Adr=0x%08x, Pitch=%d\n", destscr, XBIOS_pitch); | |
694 printf(" Size: %dx%d, dblline=%d\n", surface->w, surface->h, XBIOS_doubleline); | |
695 fflush(stdout); | |
696 #endif | |
697 SDL_Atari_C2pConvert( | |
692 surface->pixels, | 698 surface->pixels, |
693 destscr, | 699 destscr, |
694 surface->w, | 700 surface->w, |
695 surface->h, | 701 surface->h, |
696 XBIOS_doubleline, | 702 XBIOS_doubleline, |
697 surface->pitch, | 703 surface->pitch, |
698 XBIOS_pitch | 704 XBIOS_pitch |
699 ); | 705 ); |
700 } | 706 } |
701 | 707 |
708 #ifndef DEBUG_VIDEO_XBIOS | |
702 Setscreen(-1,XBIOS_screens[XBIOS_fbnum],-1); | 709 Setscreen(-1,XBIOS_screens[XBIOS_fbnum],-1); |
710 #endif | |
703 Vsync(); | 711 Vsync(); |
704 | 712 |
705 if ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) { | 713 if ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) { |
706 XBIOS_fbnum ^= 1; | 714 XBIOS_fbnum ^= 1; |
707 if ((surface->format->BitsPerPixel) > 8) { | 715 if ((surface->format->BitsPerPixel) > 8) { |
726 v = colors[i].g; | 734 v = colors[i].g; |
727 b = colors[i].b; | 735 b = colors[i].b; |
728 | 736 |
729 TT_palette[firstcolor+i]=((r*30)+(v*59)+(b*11))/100; | 737 TT_palette[firstcolor+i]=((r*30)+(v*59)+(b*11))/100; |
730 } | 738 } |
731 Atari_C2pConvert4_pal(TT_palette); /* convert the lighting */ | 739 SDL_Atari_C2pConvert4_pal(TT_palette); /* convert the lighting */ |
732 break; | 740 break; |
733 case VDO_TT: | 741 case VDO_TT: |
734 for(i = 0; i < ncolors; i++) | 742 for(i = 0; i < ncolors; i++) |
735 { | 743 { |
736 r = colors[i].r; | 744 r = colors[i].r; |
737 v = colors[i].g; | 745 v = colors[i].g; |
738 b = colors[i].b; | 746 b = colors[i].b; |
739 | 747 |
740 TT_palette[i]=((r>>4)<<8)|((v>>4)<<4)|(b>>4); | 748 TT_palette[i]=((r>>4)<<8)|((v>>4)<<4)|(b>>4); |
741 } | 749 } |
750 #ifndef DEBUG_VIDEO_XBIOS | |
742 EsetPalette(firstcolor,ncolors,TT_palette); | 751 EsetPalette(firstcolor,ncolors,TT_palette); |
752 #endif | |
743 break; | 753 break; |
744 case VDO_F30: | 754 case VDO_F30: |
745 for(i = 0; i < ncolors; i++) | 755 for(i = 0; i < ncolors; i++) |
746 { | 756 { |
747 r = colors[i].r; | 757 r = colors[i].r; |
748 v = colors[i].g; | 758 v = colors[i].g; |
749 b = colors[i].b; | 759 b = colors[i].b; |
750 | 760 |
751 F30_palette[i]=(r<<16)|(v<<8)|b; | 761 F30_palette[i]=(r<<16)|(v<<8)|b; |
752 } | 762 } |
763 #ifndef DEBUG_VIDEO_XBIOS | |
753 VsetRGB(firstcolor,ncolors,F30_palette); | 764 VsetRGB(firstcolor,ncolors,F30_palette); |
765 #endif | |
754 break; | 766 break; |
755 } | 767 } |
756 | 768 |
757 return(1); | 769 return(1); |
758 } | 770 } |