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.c154
1 files changed, 94 insertions, 60 deletions
diff --git a/apps/plugins/rockboy/lcd.c b/apps/plugins/rockboy/lcd.c
index 7fe531041c..bf44ccf136 100644
--- a/apps/plugins/rockboy/lcd.c
+++ b/apps/plugins/rockboy/lcd.c
@@ -833,40 +833,67 @@ void spr_scan(void)
833#define DY ((LCD_HEIGHT<<16) / 144) 833#define DY ((LCD_HEIGHT<<16) / 144)
834#define DYI ((144<<16) / LCD_HEIGHT) 834#define DYI ((144<<16) / LCD_HEIGHT)
835 835
836#define DXR ((LCD_WIDTH<<16) / 144)
837#define DXIR ((144<<16) / LCD_WIDTH)
838#define DYR ((LCD_HEIGHT<<16) / 160)
839#define DYIR ((160<<16) / LCD_HEIGHT)
840
836void lcd_begin(void) 841void lcd_begin(void)
837{ 842{
838 843
839#if (LCD_WIDTH>=160) && (LCD_HEIGHT>=144) 844#if (LCD_WIDTH>=160) && (LCD_HEIGHT>=144)
840#define S1 ((LCD_HEIGHT-144)/2)*LCD_WIDTH + ((LCD_WIDTH-160)/2) 845#define S1 ((LCD_HEIGHT-144)/2)*LCD_WIDTH + ((LCD_WIDTH-160)/2)
841#define S2 0 846#define S2 0
847#define S1R ((LCD_HEIGHT-160)/2)*LCD_WIDTH + ((LCD_WIDTH-144)/2)+144
848#define S2R (LCD_WIDTH-1)
842 849
843#elif (LCD_WIDTH>=160) && (LCD_HEIGHT<=144) 850#elif (LCD_WIDTH>=160) && (LCD_HEIGHT<=144)
844#define S1 ((LCD_WIDTH-160)/2) 851#define S1 0
845#define S2 ((LCD_WIDTH-160)/2) 852#define S2 0
853#define S1R LCD_WIDTH-1
854#define S2R LCD_WIDTH-1
846 855
847#elif (LCD_WIDTH<=160) && (LCD_HEIGHT>=144) 856#elif (LCD_WIDTH<=160) && (LCD_HEIGHT>=144)
848#define S1 ((LCD_HEIGHT-144)/2)*LCD_WIDTH 857#define S1 ((LCD_HEIGHT-144)/2)*LCD_WIDTH
849#define S2 ((LCD_HEIGHT-144)/2)*LCD_WIDTH 858#define S2 ((LCD_HEIGHT-144)/2)*LCD_WIDTH
859#define S1R LCD_WIDTH-1
860#define S2R LCD_WIDTH-1
850 861
851#else 862#else
852#define S1 0 863#define S1 0
853#define S2 0 864#define S2 0
865#define S1R LCD_WIDTH-1
866#define S2R LCD_WIDTH-1
854#endif 867#endif
855 868
856#if (LCD_WIDTH>LCD_HEIGHT) 869#if (LCD_WIDTH>LCD_HEIGHT)
857#define S3 ((LCD_WIDTH-(160*LCD_HEIGHT/144))/2) 870#define S3 ((LCD_WIDTH-((160*DY)>>16))/2)
871#define S3R LCD_WIDTH-1
858#else 872#else
859#define S3 ((LCD_HEIGHT-(144*LCD_WIDTH/160))/2)*LCD_WIDTH 873#define S3 ((LCD_HEIGHT-((144*DX)>>16))/2)*LCD_WIDTH
874#define S3R ((LCD_HEIGHT-((160*DXR)>>16))/2)*LCD_WIDTH+LCD_WIDTH-1
860#endif 875#endif
861 876
862 set_pal(); 877 set_pal();
863 878
864 if(options.fullscreen == 0) 879 if(options.rotate)
865 vdest=fb.ptr+S1; 880 {
866 else if (options.fullscreen == 1) 881 if(options.fullscreen == 0)
867 vdest=fb.ptr+S2; 882 vdest=fb.ptr+S2R;
883 else if (options.fullscreen == 1)
884 vdest=fb.ptr+S3R;
885 else
886 vdest=fb.ptr+S1R;
887 }
868 else 888 else
869 vdest=fb.ptr+S3; 889 {
890 if(options.fullscreen == 0)
891 vdest=fb.ptr+S2;
892 else if (options.fullscreen == 1)
893 vdest=fb.ptr+S3;
894 else
895 vdest=fb.ptr+S1;
896 }
870 WY = R_WY; 897 WY = R_WY;
871} 898}
872 899
@@ -874,50 +901,63 @@ int SCALEWL IDATA_ATTR=1<<16;
874int SCALEWS IDATA_ATTR=1<<16; 901int SCALEWS IDATA_ATTR=1<<16;
875int SCALEHL IDATA_ATTR=1<<16; 902int SCALEHL IDATA_ATTR=1<<16;
876int SCALEHS IDATA_ATTR=1<<16; 903int SCALEHS IDATA_ATTR=1<<16;
877int swidth IDATA_ATTR=160; 904int swidth IDATA_ATTR=160;
878int sremain IDATA_ATTR=LCD_WIDTH-160; 905int sremain IDATA_ATTR=LCD_WIDTH-160;
879 906
880void setvidmode(int mode) 907void setvidmode(void)
881{ 908{
882 switch(mode) 909 switch(options.fullscreen)
883 { 910 {
884 case 1: 911 case 0:
885#if (LCD_WIDTH>=160) && (LCD_HEIGHT>=144) /* Full screen scale */ 912 if(options.rotate)
886 SCALEWL=DX;
887 SCALEWS=DXI;
888 SCALEHL=DY;
889 SCALEHS=DYI;
890#elif (LCD_WIDTH>=160) && (LCD_HEIGHT<144) /* scale the height */
891 SCALEWL=1<<16;
892 SCALEWS=1<<16;
893 SCALEHL=DY;
894 SCALEHS=DYI;
895#elif (LCD_WIDTH<160) && (LCD_HEIGHT>=144) /* scale the width */
896 SCALEWL=DX;
897 SCALEWS=DXI;
898 SCALEHL=1<<16;
899 SCALEHS=1<<16;
900#else
901 SCALEWL=DX;
902 SCALEWS=DXI;
903 SCALEHL=DY;
904 SCALEHS=DYI;
905#endif
906 break;
907 case 2: /* Maintain Ratio */
908 if (DY<DX)
909 { 913 {
910 SCALEWL=DY; 914 SCALEWL=DYR;
911 SCALEWS=DYI; 915 SCALEWS=DYIR;
912 SCALEHL=DY; 916 SCALEHL=DXR;
913 SCALEHS=DYI; 917 SCALEHS=DXIR;
914 } 918 }
915 else 919 else
916 { 920 {
917 SCALEWL=DX; 921 SCALEWL=DX;
918 SCALEWS=DXI; 922 SCALEWS=DXI;
919 SCALEHL=DX; 923 SCALEHL=DY;
920 SCALEHS=DXI; 924 SCALEHS=DYI;
925 }
926 break;
927 case 1: /* Maintain Ratio */
928 if(options.rotate)
929 {
930 if (DYR<DXR)
931 {
932 SCALEWL=DYR;
933 SCALEWS=DYIR;
934 SCALEHL=DYR;
935 SCALEHS=DYIR;
936 }
937 else
938 {
939 SCALEWL=DXR;
940 SCALEWS=DXIR;
941 SCALEHL=DXR;
942 SCALEHS=DXIR;
943 }
944 }
945 else
946 {
947 if (DY<DX)
948 {
949 SCALEWL=DY;
950 SCALEWS=DYI;
951 SCALEHL=DY;
952 SCALEHS=DYI;
953 }
954 else
955 {
956 SCALEWL=DX;
957 SCALEWS=DXI;
958 SCALEHL=DX;
959 SCALEHS=DXI;
960 }
921 } 961 }
922 break; 962 break;
923 default: 963 default:
@@ -927,7 +967,11 @@ void setvidmode(int mode)
927 SCALEHS=1<<16; 967 SCALEHS=1<<16;
928 } 968 }
929 swidth=(160*SCALEWL)>>16; 969 swidth=(160*SCALEWL)>>16;
930 sremain=LCD_WIDTH-swidth; 970
971 if(options.rotate)
972 sremain=-(((160*SCALEWL)>>16)*LCD_WIDTH+1);
973 else
974 sremain=LCD_WIDTH-swidth;
931} 975}
932 976
933void lcd_refreshline(void) 977void lcd_refreshline(void)
@@ -1015,24 +1059,14 @@ void lcd_refreshline(void)
1015 register unsigned int remain=sremain; 1059 register unsigned int remain=sremain;
1016 while(wcount--) 1060 while(wcount--)
1017 { 1061 {
1018#if LCD_HEIGHT<144 /* cut off the bottom part of the screen that won't fit */ 1062 *vdest = PAL[BUF[srcpt>>16]];
1019 if (options.fullscreen==0 && (hpt>>16)>LCD_HEIGHT) 1063 if (options.rotate)
1020 break; 1064 vdest+=LCD_WIDTH;
1021#endif 1065 else
1066 vdest++;
1022 1067
1023#if LCD_WIDTH<160 /* cut off the right part of the screen that won't fit */
1024 if(options.fullscreen==0 && wcount<(160-LCD_WIDTH)) {
1025 vdest+=wcount;
1026 wcount = 0;
1027 }
1028#endif
1029
1030 *vdest++ = PAL[BUF[srcpt>>16]];
1031 srcpt+=SCALEWS; 1068 srcpt+=SCALEWS;
1032 } 1069 }
1033#if LCD_HEIGHT<144
1034 if (options.fullscreen!=0 || (hpt>>16)<(LCD_HEIGHT))
1035#endif
1036 vdest+=remain; 1070 vdest+=remain;
1037 } 1071 }
1038 1072