📄 dsp68k.c
字号:
#include "HA_TypeDef.h"
#include "hardware.h"
#include "hardware_reg.h"
#include "lcd68k.h"
#include "vramop.h"
#include "lmalloc.h"
#include "gpc.h"
extern void DebugInROMMode( int num );
// add by hc 2002-09-20
//#define NORMAL_MODE
void TurnOnBackLight(void);
void TurnOffBackLight(void);
/*
void seWrite2LCD( VRAM *vram, BYTE bitOffset)
{
*(unsigned long *)(0xFFFFFA00) = vram->ad; //(LSSA)设置写入的内存区的首地址
*(unsigned char *)(0xFFFFFA05) = vram->widthInPixel>>3; //(LVPW)
*(unsigned char *)(0xFFFFF42B) |=0x40;
*(unsigned char *)(0xFFFFF428) |=0x40;
*(unsigned char *)(0xFFFFF429) |= 0x40; // LCD turn on
}
*/
GRAMPALETTE *GRAMPalette = NULL;
VRAM *GRAM = NULL;
void init_LCD( void )
{
////gfd lcdc
*(RP)LECR = 0x00000000; //disable the LCDC
#ifdef GIII
*(RP)PORTE_SEL = 0X1<<11; //GPIO to select lcd_backlight
*(RP)PORTE_DATA =( 0X1 << 11);
#else
*(RP)PORTA_SEL |= 0x10; //background light
#endif
/* config the register of lcdc */
////*(RP)SSA = VS_BASE;
*(RP)SIZE = 0x00F00140; //the size of display is 240*320
#ifdef COLOR_PDA
*(RP)PCR = 0xc808008d;
*(RP)HCR = 0x34000804;
*(RP)VCR = 0x14001503;
*(RP)PWMR = 0x00000280; //use LP as clock source,64 clocks
*(RP)DMACR = 0x80070003; //burst length is fixed at 7 words,when 3 words in buffer burst is triggered
*(RP)LCDICR = 0x00000000;
#else
*(RP)PCR = 0x22080009;
//*(RP)PCR = 0x22080003;//0x220c0003; //_2bpp, one eighth of AMBA frequency
*(RP)HCR = 0xc80008b4;//;0xc80008ab;
//*(RP)HCR = 0x08000812;//;0xc80008ab; //H_WAIT_1=10, H_WAIT_2=10
*(RP)VCR = 0x14000304;//0x14000304; //V_WAIT_1=4, V_WAIT_1=4
*(RP)PWMR = 0x00000113;//0x00000114; //select the Pixel clock
*(RP)DMACR = 0x80070003;//0x80070003; //burst=0
*(RP)LCDICR = 0x00000000;
/* to config the grey */
*(RP)LGPMR = 0x00000000;
*(RP)(LGPMR+1*4) = 0x00000004;
*(RP)(LGPMR+2*4) = 0x0000000a;
*(RP)(LGPMR+3*4) = 0x0000000f;
#endif
*(RP)LECR = 0x0000001; //enable the LCDC
////gfd end
{
DWORD size;
GRAM = GetGRAM( LCD_WIDTH, LCD_HEIGHT );
if( GRAM == NULL )
{
return; // 内存不够
}
size = GetVRAMSize( GRAM );
if( size > 0x27000 )
{
return; // GRAM大小超过156K
}
/*
if( ( ((DWORD)GRAM->ad) & 0x1ffff ) + size > 0x1ffff )
{
VRAM *temp = GRAM;
// GRAM越过156K内存边界,需重新申请
GRAM = GetGRAM( LCD_WIDTH, LCD_HEIGHT );
FreeVRAM( temp );
if( GRAM == NULL )
{
return; // 内存不够
}
}
*/ ////gfd del
*(RP)SSA = (DWORD)(GRAM->ad); //设置写入的内存区的首地址
////*(unsigned long *)(LSSA) = (DWORD)(GRAM->ad); //(LSSA)设置写入的内存区的首地址
////*(unsigned char *)(LVPW) = GRAM->widthInPixel>>3; //(LVPW)
}
TurnOnLCD();
InitialPalette( );
/* {
extern BYTE array_memory[Heapsize];
unsigned long i, j;
unsigned char *p = array_memory;
*(unsigned char *)(LVPW) = 0x14;
for( i = 0; i < Heapsize/0x4000; i++ )
{
*(unsigned long *)(LSSA) = (DWORD)p;
p += 0x4000;
for( j = 0; j < 10000; j++ );
}
}
*/
}
void TurnOffLCD(void)
{
/*
// *(unsigned char *)(0xFFFFF429) &= 0xBF; // LCD turn off
*(unsigned char *)(LCKCON) = 0x0; //disable LCDC
*(unsigned char *)(PFSEL) |= 0x80;
*(unsigned char *)(PFDIR) |= 0x80;
*(unsigned char *)(PFDATA) &= ~0x80; //关电源
#ifdef NORMAL_MODE
TurnOffBackLight(); // add by hc for test 2002-09-20
#endif
*/
}
/*********************************************************************************/
void TurnOnLCD(void)
{
/*
#ifdef SOLIVE_DRAM_16M
*(unsigned char *)(LCKCON) = 0x82; //enable LCDC,每次读4个时钟周期的数据
#else
*(unsigned char *)(LCKCON) = 0xC2; //enable LCDC,每次读4个时钟周期的数据
#endif
*(unsigned char *)(PFSEL) |=0x80;
*(unsigned char *)(PFDIR) |=0x80;
*(unsigned char *)(PFDATA) |= 0x80; //开电源
#ifdef NORMAL_MODE
TurnOnBackLight(); // add by hc for test 2002-09-20
#endif
*/
}
//-------------------------------------------------------------------------
// Function name :void seWrite2LCD()
//
// Description : write specified rectangular image area to lcd
//
// Parameters:
// x1: Top left x-coordinate of the rectangular image area
// y1: Top left y-coordinate of the rectangular image area
// x2: Bottom right x-coordinate of the rectangular image area
// y2: Bottom right y-coordinate of the rectangular image area
// initAd: the initial address of the rectangular image area in the vram
// Lwidth: the width of the logical display width
//
//
// No return value
//-------------------------------------------------------------------------
void seWrite2LCD( VRAM *vram, BYTE bitOffset)
{
// *(unsigned long *)(LSSA) = (DWORD)(vram->ad); //(LSSA)设置写入的内存区的首地址
// *(unsigned char *)(LVPW) = vram->widthInPixel>>3; //(LVPW)
/*
#ifdef SOLIVE_DRAM_16M
*(unsigned char *)(LCKCON) = 0x82; //enable LCDC,每次读4个时钟周期的数据
#else
*(unsigned char *)(LCKCON) = 0xC2; //enable LCDC,每次读4个时钟周期的数据
#endif
*(unsigned char *)(PFSEL) |=0x40;
*(unsigned char *)(PFDIR) |=0x40;
*(unsigned char *)(PFDATA) |= 0x40; // 开中断
*/
}
BOOL Write2LCD( WORD x1, WORD y1, WORD x2, WORD y2, VRAM *vram )
{
PIXEL *srcAd, *desAd;
CHAR srcBitOffset, desBitOffset;
GetPixelPosition( &srcAd, &srcBitOffset, vram, (WORD)(vram->lcdx + x1), (WORD)(vram->lcdy + y1) );
GetPixelPosition( &desAd, &desBitOffset, GRAM, x1, y1 );
BlockOp( desAd, desBitOffset, srcAd, srcBitOffset, (WORD)(x2-x1+1), (WORD)(y2-y1+1), GPC_REPLACE_STYLE, GRAM, vram );
return TRUE;
}
BOOL InitialPalette( )
{
PIXEL index;
GRAMPIXEL color;
DWORD i, palSize = 1;
palSize = ( palSize << BITS_PER_PIXEL );
GRAMPalette = ( GRAMPALETTE * )SysLmalloc( palSize * sizeof(GRAMPALETTE) );
if( GRAMPalette == NULL )
return FALSE;
for( index=0, i = 1; i <= palSize; i++, index++ )
{
#if ( BITS_PER_PIXEL >= 8 )
//// color = IndexToRGB( index );
color = ( index ); ////in garfield: index = RGB
#else
{
DWORD grayIndex;
grayIndex = ( i * i * 2550 ) >> ( BITS_PER_PIXEL <<1 );
color = PixelMask - index;
GRAMPalette[index].threshold = grayIndex;
}
#endif
GRAMPalette[index].rgb = color;
}
return TRUE;
}
void FreePalette( )
{
SysLfree( GRAMPalette );
}
void TurnOnEL(void)
{
/* *(unsigned char *)0xfffff433 |= 0x02;
*(unsigned char *)0xfffff432 &= 0xfd;
*(unsigned char *)0xfffff430 &= 0xfd;
*(unsigned char *)0xfffff431 &= 0xfd;
*/
}
// add by hc 2002-09-20
void TurnOnBackLight(void)
{
/*
*(unsigned char *)0xfffff430 |= 0x02;
*(unsigned char *)0xfffff433 |= 0x02;
*(unsigned char *)0xfffff432 &= 0xfd;
*(unsigned char *)0xfffff431 &= 0xfd;
*/
}
void TurnOffBackLight(void)
{
/*
*(unsigned char *)0xfffff430 |= 0x02;
*(unsigned char *)0xfffff433 |= 0x02;
*(unsigned char *)0xfffff432 &= 0xfd;
*(unsigned char *)0xfffff431 |= 0x02;
*/
}
void DebugInROMMode( int num )
{
CHAR bitOffset;
PIXEL *pixelPos;
long i;
GetPixelPosition( &pixelPos, &bitOffset, GRAM, 5, num*8 );
BlockUnicolorOp( pixelPos, bitOffset, 128, 4, 0x3, GPC_XOR_STYLE, GRAM );
for( i = 0; i < 1000000; i++ )
num = ~num;
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -