lcdlib.c
上传用户:zbk8730
上传日期:2017-08-10
资源大小:12168k
文件大小:27k
源码类别:

uCOS

开发平台:

C/C++

  1. //====================================================================
  2. // File Name : LCDlib.c
  3. // Function  : S3C2440 LCD configuration low-level codes
  4. // Program   : 
  5. // Date      : March 13, 2002
  6. // Version   : 0.0
  7. // History
  8. // -2410
  9. //   0.0 : Programming start ????
  10. // -2440
  11. //   R0.0 (20030421): Modified for 2440. -> Junon
  12. //====================================================================
  13. #include <string.h>
  14. #include "def.h"
  15. #include "2440addr.h"
  16. #include "2440lib.h"
  17. //#include "option.h"
  18. //#include "24xslib.h" 
  19. #include "lcdlib.h"
  20. //Mono STN
  21. U32 (*frameBuffer1Bit)[SCR_XSIZE_STN/32];
  22. //Gray
  23. U32 (*frameBuffer2Bit)[SCR_XSIZE_STN/16];
  24. U32 (*frameBuffer4Bit)[SCR_XSIZE_STN/8];
  25. //Color STN
  26. U32 (*frameBuffer8Bit)[SCR_XSIZE_CSTN/4];
  27. U32 (*frameBuffer12Bit)[SCR_XSIZE_CSTN*3/8];
  28. U32 (*frameBuffer16Bit)[SCR_XSIZE_CSTN/2]; // for 2440A
  29. //TFT 240320
  30. U32 (*frameBuffer8BitTft240320)[SCR_XSIZE_TFT_240320/4];
  31. U32 (*frameBuffer16BitTft240320)[SCR_XSIZE_TFT_240320/2];
  32. U32 (*frameBuffer24BitTft240320)[SCR_XSIZE_TFT_240320];
  33. //TFT 640480
  34. U32 (*frameBuffer1BitTft640480)[SCR_XSIZE_TFT_640480/32];
  35. U32 (*frameBuffer8BitTft640480)[SCR_XSIZE_TFT_640480/4];
  36. U32 (*frameBuffer16BitTft640480)[SCR_XSIZE_TFT_640480/2];
  37. U32 (*frameBuffer24BitTft640480)[SCR_XSIZE_TFT_640480];
  38. //TFT 800600
  39. U32 (*frameBuffer1BitTft800600)[SCR_XSIZE_TFT_800600/32];
  40. U32 (*frameBuffer8BitTft800600)[SCR_XSIZE_TFT_800600/4];
  41. U32 (*frameBuffer16BitTft800600)[SCR_XSIZE_TFT_800600/2];
  42. void Lcd_Init(int type)
  43. {
  44.     switch(type)
  45.     {
  46.     case MODE_STN_1BIT:
  47.         frameBuffer1Bit=(U32 (*)[SCR_XSIZE_STN/32])LCDFRAMEBUFFER;
  48. rLCDCON1=(CLKVAL_STN_MONO<<8)|(MVAL_USED<<7)|(1<<5)|(0<<1)|0; 
  49.     // 4-bit single scan,1bpp STN,ENVID=off
  50. rLCDCON2=(0<<24)|(LINEVAL_STN<<14)|(0<<6)|(0<<0); // It is not TFT LCD. So,.....    
  51. rLCDCON3=(WDLY_STN<<19)|(HOZVAL_STN<<8)|(LINEBLANK_MONO<<0);
  52. rLCDCON4=(MVAL<<8)|(WLH_STN<<0);
  53. rLCDCON5=0;
  54. //BPP24BL:x,FRM565:x,INVVCLK:x,INVVLINE:x,INVVFRAME:x,INVVD:x,
  55. //INVVDEN:x,INVPWREN:x,INVLEND:x,PWREN:x,ENLEND:x,BSWP:x,HWSWP:x
  56. rLCDSADDR1=(((U32)frameBuffer1Bit>>22)<<21)|M5D((U32)frameBuffer1Bit>>1);
  57. rLCDSADDR2=M5D( ((U32)frameBuffer1Bit+(SCR_XSIZE_STN*LCD_YSIZE_STN/8))>>1 );
  58. rLCDSADDR3=(((SCR_XSIZE_STN-LCD_XSIZE_STN)/16)<<11)|(LCD_XSIZE_STN/16);
  59.     break;
  60.     case MODE_STN_2BIT:
  61.      frameBuffer2Bit=(U32 (*)[SCR_XSIZE_STN/16])LCDFRAMEBUFFER;
  62.      rLCDCON1=(CLKVAL_STN_GRAY<<8)|(MVAL_USED<<7)|(1<<5)|(1<<1)|0;
  63.     // 4-bit single scan,2bpp STN,ENVID=off
  64.      rLCDCON2=(0<<24)|(LINEVAL_STN<<14)|(0<<6)|(0<<0);
  65.      rLCDCON3=(WDLY_STN<<19)|(HOZVAL_STN<<8)|(LINEBLANK_GRAY<<0);
  66.      rLCDCON4=(MVAL<<8)|(WLH_STN<<0);
  67.      rLCDCON5=0;
  68. //BPP24BL:x,FRM565:x,INVVCLK:x,INVVLINE:x,INVVFRAME:x,INVVD:x,
  69. //INVVDEN:x,INVPWREN:x,INVLEND:x,PWREN:x,ENLEND:x,BSWP:x,HWSWP:x
  70.      rLCDSADDR1=(((U32)frameBuffer2Bit>>22)<<21)|M5D((U32)frameBuffer2Bit>>1);
  71.      rLCDSADDR2=M5D( ((U32)frameBuffer2Bit+(SCR_XSIZE_STN*LCD_YSIZE_STN/4))>>1);
  72.      rLCDSADDR3=(((SCR_XSIZE_STN-LCD_XSIZE_STN)/8)<<11)|(LCD_XSIZE_STN/8);
  73. rDITHMODE=0x0;
  74. rBLUELUT =0xf950; // 4-Gray only
  75.     break;
  76.     
  77.     case MODE_STN_4BIT:
  78.      frameBuffer4Bit=(U32 (*)[SCR_XSIZE_STN/8])LCDFRAMEBUFFER;
  79.      rLCDCON1=(CLKVAL_STN_GRAY<<8)|(MVAL_USED<<7)|(1<<5)|(2<<1)|0;
  80.      // 4-bit single scan,4bpp STN,ENVID=off
  81. rLCDCON2=(0<<24)|(LINEVAL_STN<<14)|(0<<6)|(0<<0);
  82. rLCDCON3=(WDLY_STN<<19)|(HOZVAL_STN<<8)|(LINEBLANK_GRAY<<0);
  83. rLCDCON4=(MVAL<<8)|(WLH_STN<<0);
  84. rLCDCON5=0;
  85. //BPP24BL:x,FRM565:x,INVVCLK:x,INVVLINE:x,INVVFRAME:x,INVVD:x,
  86. //INVVDEN:x,INVPWREN:x,INVLEND:x,PWREN:x,ENLEND:x,BSWP:x,HWSWP:x
  87. rLCDSADDR1=(((U32)frameBuffer4Bit>>22)<<21)|M5D((U32)frameBuffer4Bit>>1);
  88. rLCDSADDR2=M5D( ((U32)frameBuffer4Bit+(SCR_XSIZE_STN*LCD_YSIZE_STN/2))>>1 );
  89. rLCDSADDR3=(((SCR_XSIZE_STN-LCD_XSIZE_STN)/4)<<11)|(LCD_XSIZE_STN/4);
  90. rDITHMODE=0x0;
  91.     break;
  92.     case MODE_CSTN_8BIT:
  93.      frameBuffer8Bit=(U32 (*)[SCR_XSIZE_CSTN/4])LCDFRAMEBUFFER;
  94. rLCDCON1=(CLKVAL_CSTN<<8)|(MVAL_USED<<7)|(2<<5)|(3<<1)|0;
  95.      // 8-bit single scan,8bpp CSTN,ENVID=off
  96. rLCDCON2=(0<<24)|(LINEVAL_CSTN<<14)|(0<<6)|(0<<0);
  97. rLCDCON3=(WDLY_CSTN<<19)|(HOZVAL_CSTN<<8)|(LINEBLANK_CSTN<<0);
  98. rLCDCON4=(MVAL<<8)|(WLH_CSTN<<0);
  99. rLCDCON5=0;
  100. //BPP24BL:x,FRM565:x,INVVCLK:x,INVVLINE:x,INVVFRAME:x,INVVD:x,
  101. //INVVDEN:x,INVPWREN:x,INVLEND:x,PWREN:x,ENLEND:x,BSWP:x,HWSWP:x
  102. rLCDSADDR1=(((U32)frameBuffer8Bit>>22)<<21 )|M5D((U32)frameBuffer8Bit>>1);
  103. rLCDSADDR2=M5D( ((U32)frameBuffer8Bit+(SCR_XSIZE_CSTN*LCD_YSIZE_CSTN/1))>>1 );
  104. rLCDSADDR3=(((SCR_XSIZE_CSTN-LCD_XSIZE_CSTN)/2)<<11)|(LCD_XSIZE_CSTN/2);
  105. rDITHMODE=0x0;
  106. rREDLUT  =0xfdb96420;
  107. rGREENLUT=0xfdb96420;
  108. rBLUELUT =0xfb40;
  109.     break;
  110.     case MODE_CSTN_12BIT:
  111.      frameBuffer12Bit=(U32 (*)[SCR_XSIZE_CSTN*3/8])LCDFRAMEBUFFER;
  112.      // Packed Type : The L.C.M of 12 and 32 is 96.
  113.      rLCDCON1=(CLKVAL_CSTN<<8)|(MVAL_USED<<7)|(2<<5)|(4<<1)|0;
  114.      // 8-bit single scan,12bpp CSTN,ENVID=off
  115.      rLCDCON2=(0<<24)|(LINEVAL_CSTN<<14)|(0<<6)|0;
  116.      rLCDCON3=(WDLY_CSTN<<19)|(HOZVAL_CSTN<<8)|(LINEBLANK_CSTN<<0);
  117.      rLCDCON4=(MVAL<<8)|(WLH_CSTN<<0);
  118.      rLCDCON5=0;
  119.      //BPP24BL:x,FRM565:x,INVVCLK:x,INVVLINE:x,INVVFRAME:x,INVVD:x,
  120. //INVVDEN:x,INVPWREN:x,INVLEND:x,PWREN:x,ENLEND:x,BSWP:x,HWSWP:x
  121.      rLCDSADDR1=(((U32)frameBuffer12Bit>>22)<<21)|M5D((U32)frameBuffer12Bit>>1);
  122.      rLCDSADDR2=M5D(((U32)frameBuffer12Bit+((SCR_XSIZE_CSTN*3/2)*LCD_YSIZE_CSTN))>>1);
  123.      rLCDSADDR3=(((SCR_XSIZE_CSTN-LCD_XSIZE_CSTN)*3/4)<<11)|(LCD_XSIZE_CSTN*3/4);
  124. rDITHMODE=0;
  125.     break;
  126. case MODE_CSTN_12BIT_UP: // for 2440A
  127. frameBuffer16Bit=(U32 (*)[SCR_XSIZE_CSTN/2])LCDFRAMEBUFFER;
  128. // Unpacked Type : 12
  129. rLCDCON1=(CLKVAL_CSTN<<8)|(MVAL_USED<<7)|(2<<5)|(5<<1)|0;
  130. // 8-bit single scan,16bpp CSTN,ENVID=off
  131. rLCDCON2=(0<<24)|(LINEVAL_CSTN<<14)|(0<<6)|0;
  132. rLCDCON3=(WDLY_CSTN<<19)|(HOZVAL_CSTN<<8)|(LINEBLANK_CSTN<<0);
  133. rLCDCON4=(MVAL<<8)|(WLH_CSTN<<0);
  134. rLCDCON5=0;
  135. //BPP24BL:x,FRM565:x,INVVCLK:x,INVVLINE:x,INVVFRAME:x,INVVD:x,
  136. //INVVDEN:x,INVPWREN:x,INVLEND:x,PWREN:x,ENLEND:x,BSWP:x,HWSWP:x
  137. rLCDSADDR1=(((U32)frameBuffer16Bit>>22)<<21)|M5D((U32)frameBuffer16Bit>>1);
  138. rLCDSADDR2=M5D(((U32)frameBuffer16Bit+(SCR_XSIZE_CSTN*LCD_YSIZE_CSTN*2))>>1);
  139. rLCDSADDR3=((SCR_XSIZE_CSTN-LCD_XSIZE_CSTN)<<11)|(LCD_XSIZE_CSTN);
  140. rDITHMODE=0;
  141. break;
  142. case MODE_CSTN_16BIT: // for 2440A
  143. frameBuffer16Bit=(U32 (*)[SCR_XSIZE_CSTN/2])LCDFRAMEBUFFER;
  144. // Packed Type : 16.
  145. rLCDCON1=(CLKVAL_CSTN<<8)|(MVAL_USED<<7)|(2<<5)|(6<<1)|0;
  146. // 8-bit single scan,16bpp CSTN,ENVID=off
  147. rLCDCON2=(0<<24)|(LINEVAL_CSTN<<14)|(0<<6)|0;
  148. rLCDCON3=(WDLY_CSTN<<19)|(HOZVAL_CSTN<<8)|(LINEBLANK_CSTN<<0);
  149. rLCDCON4=(MVAL<<8)|(WLH_CSTN<<0);
  150. rLCDCON5=0;
  151. //BPP24BL:x,FRM565:x,INVVCLK:x,INVVLINE:x,INVVFRAME:x,INVVD:x,
  152. //INVVDEN:x,INVPWREN:x,INVLEND:x,PWREN:x,ENLEND:x,BSWP:x,HWSWP:x
  153. rLCDSADDR1=(((U32)frameBuffer16Bit>>22)<<21)|M5D((U32)frameBuffer16Bit>>1);
  154. rLCDSADDR2=M5D(((U32)frameBuffer16Bit+(SCR_XSIZE_CSTN*LCD_YSIZE_CSTN*2))>>1);
  155. rLCDSADDR3=((SCR_XSIZE_CSTN-LCD_XSIZE_CSTN)<<11)|(LCD_XSIZE_CSTN);
  156. rDITHMODE=0;
  157. break;
  158.     case MODE_TFT_8BIT_240320:
  159. frameBuffer8BitTft240320=(U32 (*)[SCR_XSIZE_TFT_240320/4])LCDFRAMEBUFFER;
  160. rLCDCON1=(CLKVAL_TFT_240320<<8)|(MVAL_USED<<7)|(3<<5)|(11<<1)|0;
  161.         // TFT LCD panel,8bpp TFT,ENVID=off
  162. rLCDCON2=(VBPD_240320<<24)|(LINEVAL_TFT_240320<<14)|(VFPD_240320<<6)|(VSPW_240320);
  163. rLCDCON3=(HBPD_240320<<19)|(HOZVAL_TFT_240320<<8)|(HFPD_240320);
  164. rLCDCON4=(MVAL<<8)|(HSPW_240320);
  165. rLCDCON5=(1<<11)|(1<<9)|(1<<8); //FRM5:6:5,HSYNC and VSYNC are inverted
  166. rLCDSADDR1=(((U32)frameBuffer8BitTft240320>>22)<<21)|M5D((U32)frameBuffer8BitTft240320>>1);
  167. rLCDSADDR2=M5D( ((U32)frameBuffer8BitTft240320+(SCR_XSIZE_TFT_240320*LCD_YSIZE_TFT_240320/1))>>1 );
  168. rLCDSADDR3=(((SCR_XSIZE_TFT_240320-LCD_XSIZE_TFT_240320)/2)<<11)|(LCD_XSIZE_TFT_240320/2);
  169. rLCDINTMSK|=(3); // MASK LCD Sub Interrupt
  170. rTCONSEL&=(~7); // Disable LPC3600
  171. rTPAL=0; // Disable Temp Palette
  172.     break;
  173.     
  174.     case MODE_TFT_16BIT_240320:
  175. frameBuffer16BitTft240320=(U32 (*)[SCR_XSIZE_TFT_240320/2])LCDFRAMEBUFFER;
  176. rLCDCON1=(CLKVAL_TFT_240320<<8)|(MVAL_USED<<7)|(3<<5)|(12<<1)|0;
  177.      // TFT LCD panel,12bpp TFT,ENVID=off
  178. rLCDCON2=(VBPD_240320<<24)|(LINEVAL_TFT_240320<<14)|(VFPD_240320<<6)|(VSPW_240320);
  179. rLCDCON3=(HBPD_240320<<19)|(HOZVAL_TFT_240320<<8)|(HFPD_240320);
  180. rLCDCON4=(MVAL<<8)|(HSPW_240320);
  181. rLCDCON5=(1<<11)|(1<<9)|(1<<8); //FRM5:6:5,HSYNC and VSYNC are inverted
  182. rLCDSADDR1=(((U32)frameBuffer16BitTft240320>>22)<<21)|M5D((U32)frameBuffer16BitTft240320>>1);
  183. rLCDSADDR2=M5D( ((U32)frameBuffer16BitTft240320+(SCR_XSIZE_TFT_240320*LCD_YSIZE_TFT_240320*2))>>1 );
  184. rLCDSADDR3=(((SCR_XSIZE_TFT_240320-LCD_XSIZE_TFT_240320)/1)<<11)|(LCD_XSIZE_TFT_240320/1);
  185. rLCDINTMSK|=(3); // MASK LCD Sub Interrupt
  186. rTCONSEL&=(~7); // Disable LPC3600
  187. rTPAL=0; // Disable Temp Palette
  188.     break;
  189. case MODE_TFT_24BIT_240320:
  190. frameBuffer24BitTft240320=(U32 (*)[SCR_XSIZE_TFT_240320])LCDFRAMEBUFFER;
  191. rLCDCON1=(CLKVAL_TFT_240320<<8)|(MVAL_USED<<7)|(3<<5)|(13<<1)|0;
  192. // TFT LCD panel,12bpp TFT,ENVID=off
  193. rLCDCON2=(VBPD_240320<<24)|(LINEVAL_TFT_240320<<14)|(VFPD_240320<<6)|(VSPW_240320);
  194. rLCDCON3=(HBPD_240320<<19)|(HOZVAL_TFT_240320<<8)|(HFPD_240320);
  195. rLCDCON4=(MVAL<<8)|(HSPW_240320);
  196. rLCDCON5=(0<12)|(1<<9)|(1<<8); //BPP24:MSB,HSYNC and VSYNC are inverted
  197. rLCDSADDR1=(((U32)frameBuffer24BitTft240320>>22)<<21)|M5D((U32)frameBuffer24BitTft240320>>1);
  198. rLCDSADDR2=M5D( ((U32)frameBuffer24BitTft240320+(SCR_XSIZE_TFT_240320*LCD_YSIZE_TFT_240320*4))>>1 );
  199. rLCDSADDR3=(((SCR_XSIZE_TFT_240320-LCD_XSIZE_TFT_240320)*2)<<11)|(LCD_XSIZE_TFT_240320*2);
  200. rLCDINTMSK|=(3); // MASK LCD Sub Interrupt
  201. rTCONSEL&=(~7); // Disable LPC3600
  202. rTPAL=0; // Disable Temp Palette
  203. break;
  204.  
  205.     case MODE_TFT_1BIT_640480:
  206.     frameBuffer1BitTft640480=(U32 (*)[SCR_XSIZE_TFT_640480/32])LCDFRAMEBUFFER;
  207. rLCDCON1=(CLKVAL_TFT_640480<<8)|(MVAL_USED<<7)|(3<<5)|(8<<1)|0;
  208. rLCDCON2=(VBPD_640480<<24)|(LINEVAL_TFT_640480<<14)|(VFPD_640480<<6)|(VSPW_640480);
  209. rLCDCON3=(HBPD_640480<<19)|(HOZVAL_TFT_640480<<8)|(HFPD_640480);
  210. rLCDCON4=(MVAL<<8)|(HSPW_640480);
  211. rLCDCON5=(1<<11)|(1<<9)|(1<<8); //FRM5:6:5,HSYNC and VSYNC are inverted
  212. rLCDSADDR1=(((U32)frameBuffer1BitTft640480>>22)<<21)|M5D((U32)frameBuffer1BitTft640480>>1);
  213. rLCDSADDR2=M5D( ((U32)frameBuffer1BitTft640480+(SCR_XSIZE_TFT_640480*LCD_YSIZE_TFT_640480/8))>>1 );
  214. rLCDSADDR3=(((SCR_XSIZE_TFT_640480-LCD_XSIZE_TFT_640480)/16)<<11)|(LCD_XSIZE_TFT_640480/16);
  215. rLCDINTMSK|=(3); // MASK LCD Sub Interrupt
  216. rTCONSEL&=(~7); // Disable LPC3600
  217. rTPAL=0; // Disable Temp Palette
  218.     break;
  219.     case MODE_TFT_8BIT_640480:
  220.     frameBuffer8BitTft640480=(U32 (*)[SCR_XSIZE_TFT_640480/4])LCDFRAMEBUFFER;
  221. rLCDCON1=(CLKVAL_TFT_640480<<8)|(MVAL_USED<<7)|(3<<5)|(11<<1)|0;
  222.     // TFT LCD panel,8bpp TFT,ENVID=off
  223. rLCDCON2=(VBPD_640480<<24)|(LINEVAL_TFT_640480<<14)|(VFPD_640480<<6)|(VSPW_640480);
  224. rLCDCON3=(HBPD_640480<<19)|(HOZVAL_TFT_640480<<8)|(HFPD_640480);
  225. rLCDCON4=(MVAL<<8)|(HSPW_640480);
  226. rLCDCON5=(1<<11)|(1<<9)|(1<<8); //FRM5:6:5,HSYNC and VSYNC are inverted
  227. rLCDSADDR1=(((U32)frameBuffer8BitTft640480>>22)<<21)|M5D((U32)frameBuffer8BitTft640480>>1);
  228. rLCDSADDR2=M5D( ((U32)frameBuffer8BitTft640480+(SCR_XSIZE_TFT_640480*LCD_YSIZE_TFT_640480/1))>>1 );
  229. rLCDSADDR3=(((SCR_XSIZE_TFT_640480-LCD_XSIZE_TFT_640480)/2)<<11)|(LCD_XSIZE_TFT_640480/2);
  230. rLCDINTMSK|=(3); // MASK LCD Sub Interrupt
  231. rTCONSEL&=(~7); // Disable LPC3600
  232. rTPAL=0; // Disable Temp Palette
  233.     break;
  234.     
  235.     case MODE_TFT_16BIT_640480:
  236.     frameBuffer16BitTft640480=(U32 (*)[SCR_XSIZE_TFT_640480/2])LCDFRAMEBUFFER;
  237. rLCDCON1=(CLKVAL_TFT_640480<<8)|(MVAL_USED<<7)|(3<<5)|(12<<1)|0;
  238.         // TFT LCD panel,16bpp TFT,ENVID=off
  239. rLCDCON2=(VBPD_640480<<24)|(LINEVAL_TFT_640480<<14)|(VFPD_640480<<6)|(VSPW_640480);
  240. rLCDCON3=(HBPD_640480<<19)|(HOZVAL_TFT_640480<<8)|(HFPD_640480);
  241. rLCDCON4=(MVAL<<8)|(HSPW_640480);
  242. rLCDCON5=(1<<11)|(1<<9)|(1<<8); //FRM5:6:5,HSYNC and VSYNC are inverted
  243. rLCDSADDR1=(((U32)frameBuffer16BitTft640480>>22)<<21)|M5D((U32)frameBuffer16BitTft640480>>1);
  244. rLCDSADDR2=M5D( ((U32)frameBuffer16BitTft640480+(SCR_XSIZE_TFT_640480*LCD_YSIZE_TFT_640480*2))>>1 );
  245. rLCDSADDR3=(((SCR_XSIZE_TFT_640480-LCD_XSIZE_TFT_640480)/1)<<11)|(LCD_XSIZE_TFT_640480/1);
  246. rLCDINTMSK|=(3); // MASK LCD Sub Interrupt
  247. rTCONSEL&=(~7); // Disable LPC3600
  248. rTPAL=0; // Disable Temp Palette
  249.     break;
  250.     case MODE_TFT_24BIT_640480:
  251.     frameBuffer24BitTft640480=(U32 (*)[SCR_XSIZE_TFT_640480])LCDFRAMEBUFFER;
  252. rLCDCON1=(CLKVAL_TFT_640480<<8)|(MVAL_USED<<7)|(3<<5)|(13<<1)|0;
  253.         // TFT LCD panel,24bpp TFT,ENVID=off
  254. rLCDCON2=(VBPD_640480<<24)|(LINEVAL_TFT_640480<<14)|(VFPD_640480<<6)|(VSPW_640480);
  255. rLCDCON3=(HBPD_640480<<19)|(HOZVAL_TFT_640480<<8)|(HFPD_640480);
  256. rLCDCON4=(MVAL<<8)|(HSPW_640480);
  257. rLCDCON5=(1<<12)|(1<<9)|(1<<8); // BPP24:MSB,HSYNC and VSYNC are inverted
  258. rLCDSADDR1=(((U32)frameBuffer24BitTft640480>>22)<<21)|M5D((U32)frameBuffer24BitTft640480>>1);
  259. rLCDSADDR2=M5D( ((U32)frameBuffer24BitTft640480+(SCR_XSIZE_TFT_640480*LCD_YSIZE_TFT_640480*4))>>1 );
  260. rLCDSADDR3=(((SCR_XSIZE_TFT_640480-LCD_XSIZE_TFT_640480)*2)<<11)|(LCD_XSIZE_TFT_640480*2);
  261. rLCDINTMSK|=(3); // MASK LCD Sub Interrupt
  262. rTCONSEL&=(~7); // Disable LPC3600
  263. rTPAL=0; // Disable Temp Palette
  264.     break;
  265.     case MODE_TFT_1BIT_800600:
  266. frameBuffer1BitTft800600=(U32 (*)[SCR_XSIZE_TFT_800600/32])LCDFRAMEBUFFER;
  267.     rLCDCON1=(CLKVAL_TFT_800600<<8)|(MVAL_USED<<7)|(3<<5)|(8<<1)|0;
  268.         // TFT LCD panel,1bpp TFT,ENVID=off
  269. rLCDCON2=(VBPD_800600<<24)|(LINEVAL_TFT_800600<<14)|(VFPD_800600<<6)|(VSPW_800600);
  270. rLCDCON3=(HBPD_800600<<19)|(HOZVAL_TFT_800600<<8)|(HFPD_800600);
  271. rLCDCON4=(MVAL<<8)|(HSPW_800600);
  272. rLCDCON5=(1<<9)|(1<<8);
  273.     //BPP24BL:x,FRM565:x,INVVCLK:x,INVVLINE:o,INVVFRAME:o,INVVD:x,
  274. //INVVDEN:x,INVPWREN:x,INVLEND:x,PWREN:x,ENLEND:x,BSWP:x,HWSWP:x
  275. rLCDSADDR1=(((U32)frameBuffer1BitTft800600>>22)<<21)|M5D((U32)frameBuffer1BitTft800600>>1);
  276. rLCDSADDR2=M5D( ((U32)frameBuffer1BitTft800600+(SCR_XSIZE_TFT_800600*LCD_YSIZE_TFT_800600/8))>>1 );
  277. rLCDSADDR3=(((SCR_XSIZE_TFT_800600-LCD_XSIZE_TFT_800600)/16)<<11)|(LCD_XSIZE_TFT_800600/16);
  278. rLCDINTMSK|=(3); // MASK LCD Sub Interrupt
  279. rTCONSEL&=(~7); // Disable LPC3600
  280. rTPAL=0; // Disable Temp Palette
  281.     break;
  282.     case MODE_TFT_8BIT_800600:
  283. frameBuffer8BitTft800600=(U32 (*)[SCR_XSIZE_TFT_800600/4])LCDFRAMEBUFFER;
  284.     rLCDCON1=(CLKVAL_TFT_800600<<8)|(MVAL_USED<<7)|(3<<5)|(11<<1)|0;
  285.         // TFT LCD panel,8bpp TFT,ENVID=off
  286. rLCDCON2=(VBPD_800600<<24)|(LINEVAL_TFT_800600<<14)|(VFPD_800600<<6)|(VSPW_800600);
  287. rLCDCON3=(HBPD_800600<<19)|(HOZVAL_TFT_800600<<8)|(HFPD_800600);
  288. rLCDCON4=(MVAL<<8)|(HSPW_800600);
  289. rLCDCON5=(1<<9)|(1<<8);
  290. //BPP24BL:x,FRM565:x,INVVCLK:x,INVVLINE:o,INVVFRAME:o,INVVD:x,
  291. //INVVDEN:x,INVPWREN:x,INVLEND:x,PWREN:x,ENLEND:x,BSWP:x,HWSWP:x
  292. rLCDSADDR1=(((U32)frameBuffer8BitTft800600>>22)<<21)|M5D((U32)frameBuffer8BitTft800600>>1);
  293. rLCDSADDR2=M5D( ((U32)frameBuffer8BitTft800600+(SCR_XSIZE_TFT_800600*LCD_YSIZE_TFT_800600/1))>>1 );
  294. rLCDSADDR3=(((SCR_XSIZE_TFT_800600-LCD_XSIZE_TFT_800600)/2)<<11)|(LCD_XSIZE_TFT_800600/2);
  295. rLCDINTMSK|=(3); // MASK LCD Sub Interrupt
  296. rTCONSEL&=(~7); // Disable LPC3600
  297. rTPAL=0; // Disable Temp Palette
  298.     break;
  299.     
  300.     case MODE_TFT_16BIT_800600:
  301. frameBuffer16BitTft800600=(U32 (*)[SCR_XSIZE_TFT_800600/2])LCDFRAMEBUFFER;
  302.     rLCDCON1=(CLKVAL_TFT_800600<<8)|(MVAL_USED<<7)|(3<<5)|(12<<1)|0;
  303.         // TFT LCD panel,16bpp TFT,ENVID=off
  304. rLCDCON2=(VBPD_800600<<24)|(LINEVAL_TFT_800600<<14)|(VFPD_800600<<6)|(VSPW_800600);
  305. rLCDCON3=(HBPD_800600<<19)|(HOZVAL_TFT_800600<<8)|(HFPD_800600);
  306. rLCDCON4=(MVAL<<8)|(HSPW_800600);
  307. rLCDCON5=(1<<11)|(1<<10)|(1<<9)|(1<<8);
  308. //BPP24BL:x,FRM565:o,INVVCLK:x,INVVLINE:o,INVVFRAME:o,INVVD:x,
  309. //INVVDEN:x,INVPWREN:x,INVLEND:x,PWREN:x,ENLEND:x,BSWP:x,HWSWP:x
  310. rLCDSADDR1=(((U32)frameBuffer16BitTft800600>>22)<<21)|M5D((U32)frameBuffer16BitTft800600>>1);
  311. rLCDSADDR2=M5D( ((U32)frameBuffer16BitTft800600+(SCR_XSIZE_TFT_800600*LCD_YSIZE_TFT_800600*2))>>1 );
  312. rLCDSADDR3=(((SCR_XSIZE_TFT_800600-LCD_XSIZE_TFT_800600)/1)<<11)|(LCD_XSIZE_TFT_800600/1);
  313. rLCDINTMSK|=(3); // MASK LCD Sub Interrupt
  314. rTCONSEL&=(~7); // Disable LPC3600
  315. rTPAL=0; // Disable Temp Palette
  316.     break;
  317.     default:
  318.     break;
  319.     }
  320. }
  321. /*
  322. void Lcd_Palette_Init(void)
  323. {
  324.     unsigned char cdata, p_red, p_green, p_blue;
  325.     U32 *palette;
  326.     
  327.     palette=(U32 *)PALETTE;
  328.     *palette++=0; //black
  329.     for(cdata=1;cdata<255;cdata++)
  330.     {
  331. p_red=(cdata & 0xe0);
  332. p_green=(cdata & 0x1c);
  333. p_blue=(cdata & 0x03);
  334.      *palette++=((U32)((p_red<<8)|(p_green<<6)|(p_blue<<3)));
  335.     }
  336.     *palette=0xffff; //white
  337. }
  338. */
  339. void Lcd_CstnOnOff(int onoff)
  340. {
  341.     // 1:CSTN Panel on  0:CSTN Panel off //
  342.     if(onoff==1)
  343.      rLCDCON1|=1; // ENVID=ON
  344.     else
  345. rLCDCON1 =rLCDCON1 & 0x3fffe; // ENVID Off
  346.     rGPBUP=rGPBUP|(1<<5); // Pull-up disable
  347.     rGPBDAT=rGPBDAT&(~(1<<5))|(onoff<<5); // GPB5=On or Off
  348.     rGPBCON=rGPBCON&(~(3<<10))|(1<<10);    //GPD9=output
  349. }    
  350. void Lcd_EnvidOnOff(int onoff)
  351. {
  352.     if(onoff==1)
  353. rLCDCON1|=1; // ENVID=ON
  354.     else
  355. rLCDCON1 =rLCDCON1 & 0x3fffe; // ENVID Off
  356. }    
  357. void Lcd_Lpc3600Enable(void)
  358. {
  359.     //rTCONSEL&=~(7);
  360.     rTCONSEL=(rTCONSEL|7)&(~(1<<4)); // 240320,Enable LPC3600, Disable LCC3600
  361. }    
  362. void Lcd_Lcc3600Enable(void)
  363. {
  364.     rTCONSEL=(rTCONSEL|(1<<4))&(~1); // Enable LCC3600, Disable LPC3600
  365. }    
  366. void Lcd_TconDisable(void)
  367. {
  368.     rTCONSEL&=~((1<<4)|1); // Disable LCC3600, LPC3600
  369. }    
  370. void Lcd_PowerEnable(int invpwren,int pwren)
  371. {
  372.     //GPG4 is setted as LCD_PWREN
  373.     rGPGUP=rGPGUP&(~(1<<4))|(1<<4); // Pull-up disable
  374.     rGPGCON=rGPGCON&(~(3<<8))|(3<<8); //GPG4=LCD_PWREN
  375.     //Enable LCD POWER ENABLE Function
  376.     rLCDCON5=rLCDCON5&(~(1<<3))|(pwren<<3);   // PWREN
  377.     rLCDCON5=rLCDCON5&(~(1<<5))|(invpwren<<5);   // INVPWREN
  378. }    
  379. void MoveViewPort(int type)
  380. {
  381.     int vx=0,vy=0,vd;
  382. // minimum movement offset
  383. vd= (type==MODE_STN_1BIT)*16+(type==MODE_STN_2BIT)*8+(type==MODE_STN_4BIT)*4
  384.         +(type==MODE_CSTN_8BIT)*2+(type==MODE_CSTN_12BIT)*4+(type==MODE_CSTN_12BIT_UP)*1+(type==MODE_CSTN_16BIT)*1
  385.         +(type==MODE_TFT_1BIT_240320)*16+(type==MODE_TFT_8BIT_240320)*2+(type==MODE_TFT_16BIT_240320)*1
  386.         +(type==MODE_TFT_1BIT_640480)*16+(type==MODE_TFT_8BIT_640480)*2+(type==MODE_TFT_16BIT_640480)*1+(type==MODE_TFT_24BIT_640480)/2
  387.         +(type==MODE_TFT_1BIT_800600)*16+(type==MODE_TFT_8BIT_800600)*2+(type==MODE_TFT_16BIT_800600)*1;        
  388.     while(1)
  389.     {
  390.      switch(Uart_Getch())
  391.      {
  392.      case 'i':
  393.     if(vy>=vd)vy-=vd;        
  394.         break;
  395.      case 'j':
  396.          if(vx>=vd)vx-=vd;
  397.      break;
  398.      case 'k':
  399.     //if((type==MODE_TFT_1BIT_800600)|(type==MODE_TFT_8BIT_800600)|(type==MODE_TFT_16BIT_800600))   
  400.     if((type&0x4000)&&(type&0x400))   
  401.     {
  402.             if(vx<=(SCR_XSIZE_TFT_800600-LCD_XSIZE_TFT_800600-vd))vx+=vd;        
  403.     }
  404.     //else if((type==MODE_TFT_1BIT_640480)|(type==MODE_TFT_8BIT_640480)|(type==MODE_TFT_16BIT_640480)|(type==MODE_TFT_24BIT_640480))   
  405.     else if((type&0x4000)&&(type&0x200))   
  406.     {
  407.             if(vx<=(SCR_XSIZE_TFT_640480-LCD_XSIZE_TFT_640480-vd))vx+=vd;        
  408.     }
  409.             //else if((type==MODE_TFT_8BIT_240320)|(type==MODE_TFT_16BIT_240320))   
  410.     else if((type&0x4000)&&(type&0x100)) 
  411.     {
  412.             if(vx<=(SCR_XSIZE_TFT_240320-LCD_XSIZE_TFT_240320-vd))vx+=vd;        
  413.     }
  414.             //else if((type==MODE_CSTN_8BIT)|(type==MODE_CSTN_12BIT))   
  415.         else if(type&0x2000)   
  416.         {
  417.             if(vx<=(SCR_XSIZE_CSTN-LCD_XSIZE_CSTN-vd))vx+=vd;        
  418.         }
  419.         else
  420.         {
  421.             if(vx<=(SCR_XSIZE_STN-LCD_XSIZE_STN-vd))vx+=vd;        
  422.         }
  423.         break;
  424.      case 'm':
  425.      if((type&0x4000)&&(type&0x400))
  426.             {
  427.                 if(vy<=(SCR_YSIZE_TFT_800600-LCD_YSIZE_TFT_800600-vd))vy+=vd; 
  428.                 else if(vy=592)vy+=8;
  429.             }
  430.     else if((type&0x4000)&&(type&0x200))
  431.             {
  432.                 if(vy<=(SCR_YSIZE_TFT_640480-LCD_YSIZE_TFT_640480-vd))vy+=vd;        
  433.             }
  434.     else if((type&0x4000)&&(type&0x100))
  435.             {
  436.                 if(vy<=(SCR_YSIZE_TFT_240320-LCD_YSIZE_TFT_240320-vd))vy+=vd;        
  437.             }
  438.             else if(type&0x2000)   
  439.             {
  440.                 if(vy<=(SCR_YSIZE_CSTN-LCD_YSIZE_CSTN-vd))vy+=vd;        
  441.             }
  442.             else
  443.             {
  444.                 if(vy<=(SCR_YSIZE_STN-LCD_YSIZE_STN-vd))vy+=vd;        
  445.             }
  446.         break;
  447.      case 'r':
  448.         return;
  449.      default:
  450.     break;
  451. }
  452. Uart_Printf("vx=%3d,vy=%3dn",vx,vy);
  453. Lcd_MoveViewPort(vx,vy,type);
  454.     }
  455. }
  456. void Lcd_MoveViewPort(int vx,int vy,int type)
  457. {
  458.     U32 addr;
  459.     switch(type)
  460.     {
  461.     case MODE_STN_1BIT:
  462.      // LCDBASEU,LCDBASEL register has to be changed before 12 words before the end of VLINE.
  463.      // In mono mode, x=320 is 10 words, So, We can't change LCDBASEU,LCDBASEL 
  464.      // during LINECNT=1~0 at mono mode. 
  465. // The processor mode should be superviser mode.  
  466.      SET_IF();
  467. #if (LCD_XSIZE_STN<512)
  468.          while((rLCDCON1>>18)<=1); // if x<512
  469.     #else
  470.          while((rLCDCON1>>18)==0); // if x>512 ((12+4)*32) 
  471.      #endif
  472. addr=(U32)frameBuffer1Bit+(vx/8)+vy*(SCR_XSIZE_STN/8);
  473. rLCDSADDR1= ( (addr>>22)<<21 ) | M5D(addr>>1);
  474. rLCDSADDR2= M5D( ((addr+(SCR_XSIZE_STN*LCD_YSIZE_STN/8))>>1) );
  475. CLR_IF();
  476.     break;
  477.     case MODE_STN_2BIT:
  478. SET_IF(); 
  479. #if (LCD_XSIZE_STN<256)
  480.         while((rLCDCON1>>18)<=1); // if x<256
  481. #else
  482.          while((rLCDCON1>>18)==0); // if x>256
  483. #endif
  484.         addr=(U32)frameBuffer2Bit+(vx/4)+vy*(SCR_XSIZE_STN/4);
  485. rLCDSADDR1= ( (addr>>22)<<21 ) | M5D(addr>>1);
  486. rLCDSADDR2= M5D(((addr+(SCR_XSIZE_STN*LCD_YSIZE_STN/4))>>1));
  487. CLR_IF();
  488.     break;
  489.     case MODE_STN_4BIT:
  490. SET_IF(); 
  491.      #if (LCD_XSIZE_STN<128)
  492.          while((rLCDCON1>>18)<=1); // if x<128
  493. #else
  494.          while((rLCDCON1>>18)==0); // if x>128
  495. #endif
  496.         addr=(U32)frameBuffer4Bit+(vx/2)+vy*(SCR_XSIZE_STN/2);
  497. rLCDSADDR1= ( (addr>>22)<<21 ) | M5D(addr>>1);
  498. rLCDSADDR2= M5D(((addr+(SCR_XSIZE_STN*LCD_YSIZE_STN/2))>>1));
  499. CLR_IF();
  500.     break;
  501.     case MODE_CSTN_8BIT:
  502. SET_IF(); 
  503. #if (LCD_XSIZE_CSTN<64)
  504.          while((rLCDCON1>>18)<=1); // if x<64
  505. #else
  506.       while((rLCDCON1>>18)==0); // if x>64
  507. #endif
  508.         addr=(U32)frameBuffer8Bit+(vx/1)+vy*(SCR_XSIZE_CSTN/1);
  509. rLCDSADDR1= ( (addr>>22)<<21 ) | M5D(addr>>1);
  510. rLCDSADDR2= M5D(((addr+(SCR_XSIZE_CSTN*LCD_YSIZE_CSTN))>>1));
  511. CLR_IF();
  512.     break;
  513.     case MODE_CSTN_12BIT:
  514.      SET_IF(); 
  515. #if (LCD_XSIZE_CSTN<43)
  516.          while((rLCDCON1>>18)<=1); // if x<43
  517. #else
  518.          while((rLCDCON1>>18)==0); // if x>43
  519. #endif
  520.      addr=(U32)frameBuffer12Bit+(vx*3/2)+vy*(SCR_XSIZE_CSTN*3/2); // Move 6Byte(4pixel)
  521. rLCDSADDR1= ( (addr>>22)<<21 ) | M5D(addr>>1);
  522. rLCDSADDR2= M5D(((addr+(SCR_XSIZE_CSTN*LCD_YSIZE_CSTN*3/2))>>1));
  523. CLR_IF();
  524.     break;
  525.     
  526. case MODE_CSTN_12BIT_UP:
  527. case MODE_CSTN_16BIT:
  528. SET_IF(); 
  529. #if (LCD_XSIZE_CSTN<32)
  530. while((rLCDCON1>>18)<=1); // if x<32
  531. #else 
  532. while((rLCDCON1>>18)==0); // if x>32
  533. #endif
  534. addr=(U32)frameBuffer16Bit+(vx*2)+vy*(SCR_XSIZE_CSTN*2); 
  535. rLCDSADDR1= ( (addr>>22)<<21 ) | M5D(addr>>1);
  536. rLCDSADDR2= M5D(((addr+(SCR_XSIZE_CSTN*LCD_YSIZE_CSTN*2))>>1));
  537. CLR_IF();
  538. break;
  539.     case MODE_TFT_1BIT_240320:
  540.      SET_IF(); 
  541. #if (LCD_XSIZE_TFT_240320<512)
  542.      while((rLCDCON1>>18)<=1); // if x<512
  543. #else
  544.     while((rLCDCON1>>18)==0); // if x>512
  545. #endif
  546.         addr=(U32)frameBuffer8BitTft240320+(vx/8)+vy*(SCR_XSIZE_TFT_240320/8);
  547. rLCDSADDR1= ( (addr>>22)<<21 ) | M5D(addr>>1);
  548. rLCDSADDR2= M5D(((addr+(SCR_XSIZE_TFT_240320*LCD_YSIZE_TFT_240320/8))>>1));
  549. CLR_IF();
  550.     break;
  551.     case MODE_TFT_8BIT_240320:
  552.      SET_IF(); 
  553. #if (LCD_XSIZE_TFT_240320<64)
  554.          while((rLCDCON1>>18)<=1); // if x<64
  555. #else
  556.     while((rLCDCON1>>18)==0); // if x>64
  557. #endif
  558.         addr=(U32)frameBuffer8BitTft240320+(vx/1)+vy*(SCR_XSIZE_TFT_240320/1);
  559. rLCDSADDR1= ( (addr>>22)<<21 ) | M5D(addr>>1);
  560. rLCDSADDR2= M5D(((addr+(SCR_XSIZE_TFT_240320*LCD_YSIZE_TFT_240320))>>1));
  561. CLR_IF();
  562.     break;
  563.     case MODE_TFT_16BIT_240320:
  564.      SET_IF(); 
  565. #if (LCD_XSIZE_TFT_240320<32)
  566.          while((rLCDCON1>>18)<=1); // if x<32
  567. #else
  568.          while((rLCDCON1>>18)==0); // if x>32
  569. #endif
  570.         addr=(U32)frameBuffer16BitTft240320+(vx*2)+vy*(SCR_XSIZE_TFT_240320*2);
  571. rLCDSADDR1= ( (addr>>22)<<21 ) | M5D(addr>>1);
  572. rLCDSADDR2= M5D(((addr+(SCR_XSIZE_TFT_240320*LCD_YSIZE_TFT_240320*2))>>1));
  573. CLR_IF();
  574.     break;
  575.     case MODE_TFT_1BIT_640480:
  576.      SET_IF();
  577. #if (LCD_XSIZE_TFT_640480<512)
  578.          while((rLCDCON1>>18)<=1); // if x<512
  579. #else
  580.          while((rLCDCON1>>18)==0); // if x>512 ((12+4)*32) 
  581. #endif
  582.         addr=(U32)frameBuffer1BitTft640480+(vx/8)+vy*(SCR_XSIZE_TFT_640480/8);
  583. rLCDSADDR1= ( (addr>>22)<<21 ) | M5D(addr>>1);
  584. rLCDSADDR2= M5D( ((addr+(SCR_XSIZE_TFT_640480*LCD_YSIZE_TFT_640480/8))>>1) );
  585. CLR_IF();
  586.     break;
  587.     case MODE_TFT_8BIT_640480:
  588.      SET_IF(); 
  589. #if (LCD_XSIZE_TFT_640480<64)
  590.          while((rLCDCON1>>18)<=1); // if x<64
  591. #else
  592.     while((rLCDCON1>>18)==0); // if x>64
  593. #endif
  594.         addr=(U32)frameBuffer8BitTft640480+(vx/1)+vy*(SCR_XSIZE_TFT_640480/1);
  595. rLCDSADDR1= ( (addr>>22)<<21 ) | M5D(addr>>1);
  596. rLCDSADDR2= M5D(((addr+(SCR_XSIZE_TFT_640480*LCD_YSIZE_TFT_640480))>>1));
  597. CLR_IF();
  598.     break;
  599.     case MODE_TFT_16BIT_640480:
  600.      SET_IF(); 
  601. #if (LCD_XSIZE_TFT_640480<32)
  602.          while((rLCDCON1>>18)<=1); // if x<32
  603. #else
  604.          while((rLCDCON1>>18)==0); // if x>32
  605. #endif
  606.         addr=(U32)frameBuffer16BitTft640480+(vx*2)+vy*(SCR_XSIZE_TFT_640480*2);
  607. rLCDSADDR1= ( (addr>>22)<<21 ) | M5D(addr>>1);
  608. rLCDSADDR2= M5D(((addr+(SCR_XSIZE_TFT_640480*LCD_YSIZE_TFT_640480*2))>>1));
  609. CLR_IF();
  610.     break;
  611.     case MODE_TFT_24BIT_640480:
  612.      SET_IF(); 
  613. #if (LCD_XSIZE_TFT_640480<16)
  614.          while((rLCDCON1>>18)<=1); // if x<16
  615. #else
  616.          while((rLCDCON1>>18)==0); // if x>16
  617. #endif
  618.         addr=(U32)frameBuffer24BitTft640480+(vx*4)+vy*(SCR_XSIZE_TFT_640480*4);
  619. rLCDSADDR1= ( (addr>>22)<<21 ) | M5D(addr>>1);
  620. rLCDSADDR2= M5D(((addr+(SCR_XSIZE_TFT_640480*LCD_YSIZE_TFT_640480*4))>>1));
  621. CLR_IF();
  622.     break;
  623.     case MODE_TFT_1BIT_800600:
  624.      SET_IF();
  625. #if (LCD_XSIZE_TFT_800600<512)
  626.          while((rLCDCON1>>18)<=1); // if x<512
  627. #else
  628.          while((rLCDCON1>>18)==0); // if x>512 ((12+4)*32) 
  629. #endif
  630.         addr=(U32)frameBuffer1BitTft800600+(vx/8)+vy*(SCR_XSIZE_TFT_800600/8);
  631. rLCDSADDR1= ( (addr>>22)<<21 ) | M5D(addr>>1);
  632. rLCDSADDR2= M5D( ((addr+(SCR_XSIZE_TFT_800600*LCD_YSIZE_TFT_800600/8))>>1) );
  633. CLR_IF();
  634.     break;
  635.     case MODE_TFT_8BIT_800600:
  636.      SET_IF(); 
  637. #if (LCD_XSIZE_TFT_800600<64)
  638.          while((rLCDCON1>>18)<=1); // if x<64
  639. #else
  640.     while((rLCDCON1>>18)==0); // if x>64
  641. #endif
  642.         addr=(U32)frameBuffer8BitTft800600+(vx/1)+vy*(SCR_XSIZE_TFT_800600/1);
  643. rLCDSADDR1= ( (addr>>22)<<21 ) | M5D(addr>>1);
  644. rLCDSADDR2= M5D(((addr+(SCR_XSIZE_TFT_800600*LCD_YSIZE_TFT_800600))>>1));
  645. CLR_IF();
  646.     break;
  647.     case MODE_TFT_16BIT_800600:
  648.      SET_IF(); 
  649. #if (LCD_XSIZE_TFT_800600<32)
  650.          while((rLCDCON1>>18)<=1); // if x<32
  651. #else
  652.          while((rLCDCON1>>18)==0); // if x>32
  653. #endif
  654.         addr=(U32)frameBuffer16BitTft800600+(vx*2)+vy*(SCR_XSIZE_TFT_800600*2);
  655. rLCDSADDR1= ( (addr>>22)<<21 ) | M5D(addr>>1);
  656. rLCDSADDR2= M5D(((addr+(SCR_XSIZE_TFT_800600*LCD_YSIZE_TFT_800600*2))>>1));
  657. CLR_IF();
  658.     break;
  659.     default:
  660.     break;
  661.     }   
  662. }    
  663.