initial import
[picodrive.git] / platform / s60 / S60v3video.inl
diff --git a/platform/s60/S60v3video.inl b/platform/s60/S60v3video.inl
new file mode 100644 (file)
index 0000000..00e65b6
--- /dev/null
@@ -0,0 +1,371 @@
+static int EmulateScanFull16(unsigned int scan,unsigned short *data)\r
+{\r
+       unsigned short *ps=NULL,*end=NULL;\r
+       unsigned short *pd=NULL;\r
+       unsigned short *pdSrc1 = NULL;\r
+       unsigned short *pdSrc2 = NULL;\r
+       int screenScan;\r
+\r
+       int index = 0;\r
+       int xpitch=0;\r
+       TInt retValue = 0;\r
+       if(scan<224)\r
+               retValue = 1-(gLineTable[scan+1]-gLineTable[scan]);\r
+       screenScan = gLineTable[scan];\r
+       \r
+       if ((int)screenScan< 0) return 0; // Out of range\r
+       if ((int)screenScan>=Targ.view.iBr.iY) return 0; // Out of range\r
+       \r
+       pd=(unsigned short*)(Targ.screen+screenScan*2+Targ.screen_offset);\r
+       pdSrc1 = pd;\r
+       \r
+       xpitch=-(Targ.scanline_length>>1);\r
+       if((Pico.video.reg[12]&1))\r
+       {\r
+               ps=data; end=ps+320;\r
+               do\r
+               {\r
+                       if(gColumnStepTable[index]>1)\r
+                       {\r
+                               *pd = gColorMapTab[*ps];\r
+                               pd+=xpitch;\r
+                               *pd = ((gColorMapTab[*ps]+gColorMapTab[*(ps+1)])>>1);   \r
+                               index++;\r
+                               ps++;\r
+                       }\r
+                       else if(gColumnStepTable[index]>0)\r
+                       {\r
+                               *pd = gColorMapTab[*ps];\r
+                               index++;\r
+                               ps++;                           \r
+                       }\r
+                       else\r
+                       {\r
+                               *pd = ((gColorMapTab[*ps]+gColorMapTab[*(ps+1)])>>1);\r
+                               ps+=2;\r
+                               index+=2;\r
+                       }\r
+                       pd+=xpitch;\r
+               }\r
+               while (ps<end);\r
+       }\r
+       else\r
+       {\r
+               ps=data+32; end=ps+256;\r
+               \r
+               // Reduce 10 pixels into 7\r
+               do\r
+               {\r
+                       if(gNarrowColumnStepTable[index]>1)\r
+                       {\r
+                               *pd = gColorMapTab[*ps];\r
+                               pd+=xpitch;\r
+                               *pd = ((gColorMapTab[*ps]+gColorMapTab[*(ps+1)])>>1);           \r
+                               index++;\r
+                       }\r
+                       else if(gNarrowColumnStepTable[index]>0)\r
+                       {\r
+                               *pd = gColorMapTab[*ps];\r
+                               ps++;\r
+                               index++;\r
+                       }\r
+                       else\r
+                       {\r
+                               *pd = ((gColorMapTab[*ps]+gColorMapTab[*(ps+1)])>>1);\r
+                               ps+=2;\r
+                               index+=2;\r
+                       }\r
+                       pd+=xpitch;             \r
+               }\r
+               while (ps<end);         \r
+       }\r
+\r
+       if(scan>0 && screenScan != gLineTable[scan-1]+1)\r
+               {               \r
+                       pdSrc2 = pdSrc1-2;\r
+                       pd = pdSrc1-1;\r
+\r
+                       for(TInt loop=0;loop<Targ.view.iBr.iY;loop++)\r
+                       {\r
+                               *pd=((*pdSrc1+*pdSrc2)>>1);\r
+                               pd+=xpitch;\r
+                               pdSrc1+=xpitch;\r
+                               pdSrc2+=xpitch;\r
+                       }\r
+                       \r
+               }\r
+\r
+       return retValue;\r
+}\r
+\r
+static int EmulateScanFullRight16(unsigned int scan,unsigned short *data)\r
+{\r
+       unsigned short *ps=NULL,*end=NULL;\r
+       unsigned short *pd=NULL;\r
+       unsigned short *pdSrc1 = NULL;\r
+       unsigned short *pdSrc2 = NULL;\r
+       int screenScan;\r
+       int xpitch=0;\r
+       int retValue = 0;\r
+       int index = 0;\r
+       if(scan<224)\r
+               retValue = 1-(gLineTable[scan+1]-gLineTable[scan]);\r
+       screenScan = gLineTable[scan];\r
+\r
+       if ((int)screenScan< 0) return 0; // Out of range\r
+       if ((int)screenScan>=Targ.view.iBr.iY) return 0; // Out of range\r
+       \r
+       pd=(unsigned short*)(Targ.screen+Targ.scanline_length-screenScan*2);\r
+       pdSrc1 = pd;\r
+       \r
+       xpitch=+(Targ.scanline_length>>1);\r
+       if((Pico.video.reg[12]&1))\r
+       {\r
+               ps=data; end=ps+320;\r
+               do\r
+               {\r
+                       if(gColumnStepTable[index]>1)\r
+                       {\r
+                               *pd = gColorMapTab[*ps];\r
+                               pd+=xpitch;\r
+                               *pd = ((gColorMapTab[*ps]+gColorMapTab[*(ps+1)])>>1);   \r
+                               index++;\r
+                               ps++;\r
+                       }\r
+                       else if(gColumnStepTable[index]>0)\r
+                       {\r
+                               *pd = gColorMapTab[*ps];\r
+                               index++;\r
+                               ps++;                           \r
+                       }\r
+                       else\r
+                       {\r
+                               *pd = ((gColorMapTab[*ps]+gColorMapTab[*(ps+1)])>>1);\r
+                               ps+=2;\r
+                               index+=2;\r
+                       }\r
+                       pd+=xpitch;\r
+               }\r
+               while (ps<end);\r
+       }\r
+       else\r
+       {\r
+               ps=data+32; end=ps+256;\r
+               \r
+               // Reduce 10 pixels into 7\r
+               do\r
+               {\r
+                       if(gNarrowColumnStepTable[index]>1)\r
+                       {\r
+                               *pd = gColorMapTab[*ps];\r
+                               pd+=xpitch;\r
+                               *pd = ((gColorMapTab[*ps]+gColorMapTab[*(ps+1)])>>1);           \r
+                               index++;\r
+                       }\r
+                       else if(gNarrowColumnStepTable[index]>0)\r
+                       {\r
+                               *pd = gColorMapTab[*ps];\r
+                               ps++;\r
+                               index++;\r
+                       }\r
+                       else\r
+                       {\r
+                               *pd = ((gColorMapTab[*ps]+gColorMapTab[*(ps+1)])>>1);\r
+                               ps+=2;\r
+                               index+=2;\r
+                       }\r
+                       pd+=xpitch;             \r
+               }\r
+               while (ps<end);         \r
+       }\r
+\r
+       if(scan>0 && screenScan != gLineTable[scan-1]+1)\r
+               {               \r
+                       pdSrc2 = pdSrc1+2;\r
+                       pd = pdSrc1+1;\r
+\r
+                       for(TInt loop=0;loop<Targ.view.iBr.iY;loop++)\r
+                       {\r
+                               *pd=((*pdSrc1+*pdSrc2)>>1);\r
+                               pd+=xpitch;\r
+                               pdSrc1+=xpitch;\r
+                               pdSrc2+=xpitch;\r
+                       }\r
+                       \r
+               }\r
+       \r
+       return retValue;\r
+}\r
+\r
+\r
+\r
+static int EmulateScan16(unsigned int scan,unsigned short *data)\r
+{\r
+       //  int len=0;\r
+       unsigned short *ps=NULL,*end=NULL;\r
+       unsigned short *pd=NULL;\r
+       int xpitch=0;\r
+       int retValue = 0;\r
+       int index = 0;\r
+\r
+       if(scan<224)\r
+               retValue = 1-(gLineTable[scan+1]-gLineTable[scan]);\r
+       scan = gLineTable[scan];\r
+       \r
+       if ((int)scan< 0) return 0; // Out of range\r
+       if ((int)scan>=Targ.view.iBr.iY) return 0; // Out of range\r
+       \r
+       pd=(unsigned short*)(Targ.screen+scan*Targ.scanline_length);\r
+       \r
+       xpitch=2;\r
+       if((Pico.video.reg[12]&1))\r
+       {\r
+               ps=data; end=ps+320;\r
+               do\r
+               {\r
+                       if(gColumnStepTable[index]>0)\r
+                       {\r
+                       *pd = gColorMapTab[*ps];\r
+                       ps++;\r
+               \r
+                       index++;\r
+                       }\r
+                       else\r
+                       {\r
+                       *pd = ((gColorMapTab[*ps]+gColorMapTab[*(ps+1)])>>1);\r
+                       ps+=2;\r
+                       index+=2;\r
+                       }\r
+                       pd++;\r
+               \r
+               }\r
+               while (ps<end);\r
+       } \r
+       else\r
+       {\r
+               ps=data+32; end=ps+256;\r
+               // Reduce 10 pixels into 7\r
+               do\r
+               {\r
+                       if(gNarrowColumnStepTable[index]>0)\r
+                       {\r
+                               *pd = gColorMapTab[*ps];\r
+                               ps++;\r
+                               index++;\r
+                       }\r
+                       else\r
+                       {\r
+                               *pd = ((gColorMapTab[*ps]+gColorMapTab[*(ps+1)])>>1);\r
+                               ps+=2;\r
+                               index+=2;\r
+                       }\r
+                       pd++;           \r
+               }\r
+               while (ps<end);\r
+       \r
+       }\r
+       \r
+       return retValue;\r
+}\r
+\r
+static int EmulateStretchScan16(unsigned int scan,unsigned short *data)\r
+{\r
+       unsigned short *ps=NULL,*end=NULL;\r
+       unsigned short *pd=NULL;\r
+       unsigned short *pdSrc1 = NULL;\r
+       unsigned short *pdSrc2 = NULL;\r
+\r
+       int retValue = 0;\r
+       int index = 0;\r
+       int screenScan;\r
+       if(scan<224)\r
+               retValue = 1-(gLineTable[scan+1]-gLineTable[scan]);\r
+       screenScan = gLineTable[scan];\r
+\r
+       if ((int)screenScan<0) \r
+               return 0; // Out of range\r
+       if ((int)screenScan>=Targ.view.iBr.iY) \r
+               return 0; // Out of range\r
+       \r
+       pd=(unsigned short*)(Targ.screen+screenScan*Targ.scanline_length);\r
+       pdSrc1 = pd;\r
+\r
+       if((Pico.video.reg[12]&1))\r
+       {\r
+               ps=data; end=ps+320;            \r
+               do\r
+               {\r
+                       if(gColumnStepTable[index]>1)\r
+                       {\r
+                               *pd = gColorMapTab[*ps];\r
+                               pd++;\r
+                               *pd = ((gColorMapTab[*ps]+gColorMapTab[*(ps+1)])>>1);   \r
+                               index++;\r
+                               ps++;\r
+                       }\r
+                       else if(gColumnStepTable[index]>0)\r
+                       {\r
+                               *pd = gColorMapTab[*ps];\r
+                               index++;\r
+                               ps++;                           \r
+                       }\r
+                       else\r
+                       {\r
+                               *pd = ((gColorMapTab[*ps]+gColorMapTab[*(ps+1)])>>1);\r
+                               ps+=2;\r
+                               index+=2;\r
+                       }\r
+                       pd++;\r
+               }\r
+               while (ps<end);\r
+\r
+               \r
+       \r
+       }\r
+       else\r
+       {\r
+               ps=data+32; end=ps+256;\r
+               // Reduce 10 pixels into 7\r
+               do\r
+               {\r
+                       if(gNarrowColumnStepTable[index]>1)\r
+                       {\r
+                               *pd = gColorMapTab[*ps];\r
+                               pd++;\r
+                               *pd = ((gColorMapTab[*ps]+gColorMapTab[*(ps+1)])>>1);           \r
+                               index++;\r
+                       }\r
+                       else if(gNarrowColumnStepTable[index]>0)\r
+                       {\r
+                               *pd = gColorMapTab[*ps];\r
+                               ps++;\r
+                               index++;\r
+                       }\r
+                       else\r
+                       {\r
+                               *pd = ((gColorMapTab[*ps]+gColorMapTab[*(ps+1)])>>1);\r
+                               ps+=2;\r
+                               index+=2;\r
+                       }\r
+                       pd++;           \r
+               }\r
+               while (ps<end);         \r
+       }\r
+\r
+       if(scan>0 && screenScan != gLineTable[scan-1]+1)\r
+               {               \r
+                       pdSrc2 = pdSrc1-Targ.scanline_length;\r
+                       pd = pdSrc1-(Targ.scanline_length>>1);\r
+\r
+                       for(TInt loop=0;loop<Targ.view.iBr.iX;loop++)\r
+                       {\r
+                               *pd=((*pdSrc1+*pdSrc2)>>1);\r
+                               pd++;\r
+                               pdSrc1++;\r
+                               pdSrc2++;\r
+                       }\r
+                       \r
+               }\r
+       \r
+       return retValue;\r
+}\r