summaryrefslogtreecommitdiff
path: root/apps/plugins/rockboy/lcd.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/rockboy/lcd.c')
-rw-r--r--apps/plugins/rockboy/lcd.c140
1 files changed, 95 insertions, 45 deletions
diff --git a/apps/plugins/rockboy/lcd.c b/apps/plugins/rockboy/lcd.c
index 55ae3eafba..f98b4f6935 100644
--- a/apps/plugins/rockboy/lcd.c
+++ b/apps/plugins/rockboy/lcd.c
@@ -1,5 +1,3 @@
1
2
3#include "rockmacros.h" 1#include "rockmacros.h"
4#include "defs.h" 2#include "defs.h"
5#include "regs.h" 3#include "regs.h"
@@ -102,9 +100,6 @@ fb_data *vdest;
102#define MEMCPY8(d, s) memcpy((d), (s), 8) 100#define MEMCPY8(d, s) memcpy((d), (s), 8)
103#endif 101#endif
104 102
105
106
107
108#ifndef ASM_UPDATEPATPIX 103#ifndef ASM_UPDATEPATPIX
109void updatepatpix(void) 104void updatepatpix(void)
110{ 105{
@@ -901,10 +896,11 @@ void spr_scan(void)
901// if (sprdebug) for (i = 0; i < NS; i++) BUF[i<<1] = 36; 896// if (sprdebug) for (i = 0; i < NS; i++) BUF[i<<1] = 36;
902} 897}
903 898
904 899// Scaling defines
905 900#define DX ((LCD_WIDTH<<16) / 160)
906 901#define DXI ((160<<16) / LCD_WIDTH)
907 902#define DY ((LCD_HEIGHT<<16) / 144)
903#define DYI ((144<<16) / LCD_HEIGHT)
908 904
909void lcd_begin(void) 905void lcd_begin(void)
910{ 906{
@@ -913,23 +909,70 @@ void lcd_begin(void)
913 if (rgb332) pal_set332(); 909 if (rgb332) pal_set332();
914 else pal_expire(); 910 else pal_expire();
915 } 911 }
916 while (scale * 160 > fb.w || scale * 144 > fb.h) scale--; */ 912*/
917 if(options.fullscreen) 913
918 vdest = fb.ptr; 914 if(options.fullscreen)
919 else 915 vdest = fb.ptr;
920 vdest = fb.ptr + ((LCD_HEIGHT-144)/2)*LCD_WIDTH + ((LCD_WIDTH-160)/2); 916 else
917 vdest=fb.ptr+((LCD_HEIGHT-144)/2)*LCD_WIDTH + ((LCD_WIDTH-160)/2);
921 918
922 WY = R_WY; 919 WY = R_WY;
923} 920}
924 921
925char frameout[25]; 922int SCALEWL IDATA_ATTR=DY;
926void lcd_refreshline(void) 923int SCALEWS IDATA_ATTR=DYI;
924int SCALEHL IDATA_ATTR=DY;
925int SCALEHS IDATA_ATTR=DYI;
926int swidth IDATA_ATTR=(160*DY)>>16;
927int sremain IDATA_ATTR=LCD_WIDTH-((160*DY)>>16);
928
929void setvidmode(int mode)
927{ 930{
928#if LCD_HEIGHT>=144 931 switch(mode)
929 int cnt=0, two; 932 {
933 case 1: /* Full screen scale */
934 SCALEWL=DX;
935 SCALEWS=DXI;
936 SCALEHL=DY;
937 SCALEHS=DYI;
938 break;
939 case 2: /* Maintain Ratio */
940 if (DY<DX)
941 {
942 SCALEWL=DY;
943 SCALEWS=DYI;
944 SCALEHL=DY;
945 SCALEHS=DYI;
946 }
947 else
948 {
949 SCALEWL=DX;
950 SCALEWS=DXI;
951 SCALEHL=DX;
952 SCALEHS=DXI;
953 }
954 break;
955 default: /* No Scaling (or fullscreen for smaller screens) */
956#if LCD_WIDTH>160
957 SCALEWL=1<<16;
958 SCALEWS=1<<16;
959 SCALEHL=1<<16;
960 SCALEHS=1<<16;
961#else
962 SCALEWL=DX;
963 SCALEWS=DXI;
964 SCALEHL=DY;
965 SCALEHS=DYI;
930#endif 966#endif
967 }
968 swidth=(160*SCALEWL)>>16;
969 sremain=LCD_WIDTH-swidth;
970}
971
931 972
932 if (!fb.enabled) return; 973char frameout[30];
974void lcd_refreshline(void)
975{
933 if(!insync) { 976 if(!insync) {
934 if(R_LY!=0) 977 if(R_LY!=0)
935 return; 978 return;
@@ -990,44 +1033,51 @@ void lcd_refreshline(void)
990 recolor(BUF+WX, 0x04, 160-WX); 1033 recolor(BUF+WX, 0x04, 160-WX);
991 } 1034 }
992 spr_scan(); 1035 spr_scan();
1036
1037#if !defined(HAVE_LCD_COLOR)
993#if LCD_DEPTH == 1 1038#if LCD_DEPTH == 1
994 if (scanline_ind == 7) 1039 if (scanline_ind == 7)
995#elif LCD_DEPTH == 2 1040#elif LCD_DEPTH == 2
996 if (scanline_ind == 3) 1041 if (scanline_ind == 3)
997#endif 1042#endif
998 { 1043 {
999#if LCD_HEIGHT < 144
1000 if(fb.mode!=3) 1044 if(fb.mode!=3)
1001 vid_update(L); 1045 vid_update(L);
1002 else 1046 else
1003 vid_update(L-((int)(L/9))); 1047 vid_update(L-((int)(L/9)));
1004#else 1048#else
1049 {
1050 /* Universial Scaling pulled from PrBoom and modified for rockboy */
1051 /* Needs some thought for screens smaller than the gameboy though */
1052
1053 static int hpt IDATA_ATTR=0x8000;
1054
1055 while((hpt>>16)<L+1)
1056 {
1057 hpt+=SCALEHS;
1058 register unsigned int srcpt=0x8000;
1059 register unsigned int wcount=swidth;
1060 register unsigned int remain=sremain;
1061 while(wcount--)
1062 {
1063 *vdest++ = scan.pal2[scan.buf[srcpt>>16]];
1064 srcpt+=SCALEWS;
1065 }
1066 vdest+=remain;
1067 }
1068
1069 if(L==143)
1070 {
1071 if(options.showstats)
1072 {
1073 snprintf(frameout,sizeof(frameout),"FPS: %d Frameskip: %d ",options.fps, options.frameskip);
1074 rb->lcd_putsxy(0,LCD_HEIGHT-10,frameout);
1075 }
1076
1077 hpt=0x8000;
1078 rb->lcd_update();
1079 }
1005 1080
1006 for(two=0;two<( (options.showstats ? (L&0x07)==0x05 : (L&0x07)==0x05 || (L&0x0F)==0x08) && options.fullscreen)+1;two++)
1007 {
1008 while (cnt < 160)
1009 {
1010 *vdest++ = scan.pal2[scan.buf[cnt++]];
1011 if( ((cnt&0x03)==0x03 || (cnt&0x07)==0x06) && options.fullscreen ) *vdest++ = scan.pal2[scan.buf[cnt]];
1012 }
1013
1014 if(!options.fullscreen)
1015 vdest+=(LCD_WIDTH-160);
1016 cnt=0;
1017 }
1018
1019 if(L==143)
1020 {
1021 if(options.showstats) {
1022 snprintf(frameout,sizeof(frameout),"FPS: %d \t %d ",options.fps, options.frameskip);
1023 if(options.fullscreen) rb->lcd_putsxy(0,166,frameout);
1024 else rb->lcd_putsxy((LCD_WIDTH-160)/2,(LCD_HEIGHT-144)/2,frameout);
1025 }
1026 if(options.fullscreen)
1027 rb->lcd_update();
1028 else
1029 rb->lcd_update_rect( (LCD_WIDTH-160)/2, (LCD_HEIGHT-144)/2, 160, 144 );
1030 }
1031#endif 1081#endif
1032 } 1082 }
1033#if LCD_DEPTH == 1 1083#if LCD_DEPTH == 1