📄 md.lst
字号:
542 1 blk_cnt = g1p_md_get_block_count(&detected_ch_num);
543 1 max_diff = g1p_md_get_max_difference();
544 1
545 1 if(is_FirstMdDetected[detected_ch_num])
546 1 {
547 2 is_FirstMdDetected[detected_ch_num] = 0; // At the first case, we just save the current MD reg values
548 2 #ifdef DEBUG_MD_DETECT
printf("\n\rG1PMD= blk[%04x] diff[%02x] ch[%02x]", blk_cnt, (u16)max_diff, (u16)detected_ch_num);
#endif
551 2 }
C51 COMPILER V7.50 MD 12/14/2005 10:05:34 PAGE 10
552 1 else // check the difference from the previous values
553 1 {
554 2 if((s_blk_cnt[detected_ch_num]!= blk_cnt)||(s_diff[detected_ch_num]!= max_diff))
555 2 {
556 3 mdgv_channel_detected = 0x01 << detected_ch_num;
557 3 #ifdef DEBUG_MD_DETECT
printf("\n\rG1PMD: blk[%04x] diff[%02x] ch[%02x]", blk_cnt, (u16)max_diff, (u16)detected_ch_num);
#endif
560 3 }
561 2 }
562 1 // update current blk_cnt number
563 1 s_blk_cnt[detected_ch_num] = blk_cnt;
564 1 s_diff[detected_ch_num] = max_diff;
565 1
566 1 return (mdgv_channel_detected==0)?0:1;
567 1
568 1 }
569
570 //==============================================================================
571 // Access G1P MD register
572 //==============================================================================
573 void g1pMDreg_write(u8 addr, u8 value)
574 {
575 1 MD_ADDRESS_REGISTER = addr;
576 1 MD_DATA_REGISTER = value;
577 1 }
578 u8 g1pMDreg_read(u8 addr)
579 {
580 1 u8 value;
581 1
582 1 MD_ADDRESS_REGISTER = addr;
583 1 value = MD_DATA_REGISTER;
584 1 return value;
585 1 }
586
587 #endif // G1PMD
588
589
590
591 #ifdef TW2804
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
void tw2804_md_reg_set_area(BYTE ch)
{
BYTE i,j,x,y;
#ifdef VY_MD_DEBUG_AREA
WORD temp[2][4];
#endif
BYTE areas[2][4];
BYTE mask[3];
// convert coordination
for(i=0;i<2;i++)
{
for(j=0;j<4;j++)
{
#ifdef VY_MD_DEBUG_AREA
temp[i][j] = (mdgv_md_areas[ch][i][j]+((j&0x02)?1:0))*((j&0x01)?24:16)+((j&0x02)?-1:0);
#endif
areas[i][j] = ((mdgv_md_areas[ch][i][j]+((j&0x02)?1:0))*((j&0x01)?24:16)+((j&0x02)?-1:0))/((j&0x01)?(gv
-_NTSC_PAL?48:40):60);
C51 COMPILER V7.50 MD 12/14/2005 10:05:34 PAGE 11
}
}
#ifdef VY_MD_DEBUG_AREA
for(i=0;i<2;i++)
{
printf("\r\nch %d [%2u,%2u-%2u,%2u] -> [%3u,%3u-%3u,%3u] [%X,%X-%X,%X]",
(WORD)ch,(WORD)mdgv_md_areas[ch][i][0], (WORD)mdgv_md_areas[ch][i][1], (WORD)mdgv_md_areas[ch][i][2], (
-WORD)mdgv_md_areas[ch][i][3],
temp[i][0], temp[i][1], temp[i][2], temp[i][3], (WORD)areas[i][0], (WORD)areas[i][1], (WORD)areas[i][2]
-, (WORD)areas[i][3]);
}
printf("\r\n 0 1 2 3 4 5 6 7 8 9 A B");
#endif
for(i=0;i<6;i++)
{ // process 2 rows at a time covers all 12 lines
// default = masking all blocks
mask[0] = mask[1] = mask[2] = 0xFF;
for(j=0;j<2;j++)
{ // process 2 rows at a time
// calculate row index
y = i*2 + j;
for(x=0;x<12;x++)
{ // sweep a row
if( (areas[0][0]<=x && x<=areas[0][2] && areas[0][1]<=y && y<=areas[0][3]) ||
(areas[1][0]<=x && x<=areas[1][2] && areas[1][1]<=y && y<=areas[1][3]))
{ // when a block should be enabled,
if(x<8)
{
mask[j] &= ~(0x01<<x);
}
else
{
mask[2] &= ~((j?0x10:0x01)<<(x-8));
}
}
}
}
#ifdef VY_MD_DEBUG_AREA
printf("\r\n %c %c %c %c %c %c %c %c %c %c %c %c",
(mask[0]&0x01)?'1':'0', // 0
(mask[0]&0x02)?'1':'0', // 1
(mask[0]&0x04)?'1':'0', // 2
(mask[0]&0x08)?'1':'0', // 3
(mask[0]&0x10)?'1':'0', // 4
(mask[0]&0x20)?'1':'0', // 5
(mask[0]&0x40)?'1':'0', // 6
(mask[0]&0x80)?'1':'0', // 7
(mask[2]&0x01)?'1':'0', // 8
(mask[2]&0x02)?'1':'0', // 9
(mask[2]&0x04)?'1':'0', // 10
(mask[2]&0x08)?'1':'0');// 11
printf("\r\n %c %c %c %c %c %c %c %c %c %c %c %c",
(mask[1]&0x01)?'1':'0', // 0
(mask[1]&0x02)?'1':'0', // 1
(mask[1]&0x04)?'1':'0', // 2
(mask[1]&0x08)?'1':'0', // 3
(mask[1]&0x10)?'1':'0', // 4
(mask[1]&0x20)?'1':'0', // 5
(mask[1]&0x40)?'1':'0', // 6
(mask[1]&0x80)?'1':'0', // 7
C51 COMPILER V7.50 MD 12/14/2005 10:05:34 PAGE 12
(mask[2]&0x10)?'1':'0', // 8
(mask[2]&0x20)?'1':'0', // 9
(mask[2]&0x40)?'1':'0', // 10
(mask[2]&0x80)?'1':'0');// 11
#endif
tw2804_write(MD_2804_REG_CH_BASE+MD_2804_CH_SPACE*ch+MD_2804_MDMASK1+i*3, mask[0]);
tw2804_write(MD_2804_REG_CH_BASE+MD_2804_CH_SPACE*ch+MD_2804_MDMASK1+i*3+1, mask[2]);
tw2804_write(MD_2804_REG_CH_BASE+MD_2804_CH_SPACE*ch+MD_2804_MDMASK1+i*3+2, mask[1]);
}
}
///////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
void tw2804_md_enable(BOOL enable)
{
xdata BYTE ch;
xdata BYTE int_mask;
// clear interrupt if raised
tw2804_write(MD_2804_REG_IRQCLR,0x0F); // clear only MD interrupt
mdgv_md_active_ch_stat = 0;
if(enable)
{
for(ch=0;ch<4;ch++)
{
#ifdef VY_MD_DEBUG_REG_RW
printf("\r\n[ch %u]",(WORD)ch);
#endif
tw2804_write((BYTE)(MD_2804_REG_CH_BASE+MD_2804_CH_SPACE*ch), (BYTE)mdgvp_md_sensitivity_level_set[mdgv
-_md_sensitivity_levels[ch]]);
#ifdef VY_MD_DEBUG_REG_RW
printf("\r\n Sensitivity at 0x%02X, 0x%02X - 0x%02X",
(WORD)MD_2804_REG_CH_BASE+MD_2804_CH_SPACE*ch, (WORD)mdgvp_md_sensitivity_level_set[mdgv_md_sensitivity
-_levels[ch]], (WORD)tw2804_read(MD_2804_REG_CH_BASE+MD_2804_CH_SPACE*ch) );
#endif
tw2804_write((BYTE)(MD_2804_REG_CH_BASE+MD_2804_CH_SPACE*ch+MD_2804_MPERIOD), (BYTE)MD_MPERIOD);
#ifdef VY_MD_DEBUG_REG_RW
printf("\r\n Period at 0x%02X, 0x%02X - 0x%02X",
(WORD)MD_2804_REG_CH_BASE+MD_2804_CH_SPACE*ch+MD_2804_MPERIOD, (WORD)MD_MPERIOD, (WORD)tw2804_read(MD_2
-804_REG_CH_BASE+MD_2804_CH_SPACE*ch+MD_2804_MPERIOD));
#endif
if(mdgv_md_sensitivity_levels[ch])
mdgv_md_active_ch_stat |= (0x01)<<ch;
}
}
tw2804_write(MD_2804_REG_IRQCLR,0x0F); // clear only MD interrupt
int_mask = tw2804_read(MD_2804_REG_IRQENA);
tw2804_write(MD_2804_REG_IRQENA, (mdgv_md_active_ch_stat&0x0F)|(int_mask&0xF0));
mdgvp_channel_enable_mask = mdgv_md_active_ch_stat;
#ifdef VY_MD_DEBUG_REG_RW
printf("\r\n[ENABLE - 0x%02X] 0x%02X - 0x%02X",
(WORD)tw2804_read(MD_2804_REG_IRQCLR), (WORD)mdgv_md_active_ch_stat, (WORD)tw2804_read(MD_2804_REG_IRQENA
-));
#endif
#ifdef DEBUG_MD
{
C51 COMPILER V7.50 MD 12/14/2005 10:05:34 PAGE 13
u8 tmp = tw2804_read(MD_2804_REG_IRQENA);
printf("\n\rMD: IRQENA = %c %c %c %c", (tmp&0x01)?'O':'x', (tmp&0x02)?'O':'x', (tmp&0x04)?'O':'x', (tmp&
-0x08)?'O':'x');
}
#endif
mdgv_md_enabled = enable; // Steve add
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
BOOL tw2804_md_is_detected(void)
{
xdata BYTE temp;
xdata BYTE int_mask;
#ifdef VY_MD_DEBUG_INT
static xdata BYTE counter=0;
#endif
mdgv_channel_detected = 0;
if(INT_2804 == HIGH)
{
#ifdef USE_4954_GP
temp = cs4954_read(0x0A);
#endif
mdgv_channel_detected = mdgv_md_active_ch_stat&(temp>>4);
// clear interrupt
tw2804_write(MD_2804_REG_IRQCLR,mdgv_channel_detected&0x0F);
if(mdgv_channel_detected)
{
mdgvp_channel_enable_mask &= ~mdgv_channel_detected;
// disable detected channel - enabled when recording completed
int_mask = tw2804_read(MD_2804_REG_IRQENA);
tw2804_write(MD_2804_REG_IRQENA, (mdgvp_channel_enable_mask&0x0F)|(int_mask&0xF0));
#ifdef VY_MD_DEBUG_INT
printf("\r\nINT[0x%02X] 4954[0x%02X] channel[0x%02X] [[0x%02X]]",
(WORD)counter++, (WORD)temp, (WORD)mdgv_channel_detected, (WORD)tw2804_read(MD_2804_REG_IRQENA) );
#endif
#ifdef DEBUG_MD
{
u8 tmp = tw2804_read(MD_2804_REG_IRQENA);
printf("\n\rMD: IRQENAi= %c %c %c %c",
(tmp&0x01)?'O':'x',
(tmp&0x02)?'O':'x',
(tmp&0x04)?'O':'x',
(tmp&0x08)?'O':'x'
);
}
#endif
return TRUE;
}
}
return FALSE;
}
#endif // TW2804
787
788
789 #endif //end of VY_MD
C51 COMPILER V7.50 MD 12/14/2005 10:05:34 PAGE 14
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1279 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = 65 34
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -