📄 misc.lst
字号:
RegBitOut(0x50, 0x00, 0x08); // Gamma off
#endif
245 1 }
246
247
248
249 //
250 // Delay (n) ms
251 //
252 void miscDelay(int n)
253 {
254 1 unsigned int i;
255 1
256 1 while (n--) {
257 2 i = 1000/11 ; // one loop below takes about 11 us
258 2 while (i--);
259 2 }
260 1 }
261
262
263
264 void miscSetADCPhase(unsigned char phase)
265 {
266 1
267 1 RegByteOut(TDA_PHASE, (phase & PHASEMSK)|0x40);
268 1
269 1 RegByteOut(TDA_DIVL, RegByteIn(TDA_DIVL));
270 1
271 1 }
272
273
274 void miscSetADCPitch(unsigned int pitch)
275 {
276 1
277 1 unsigned char data tpitchH;
278 1
279 1 tpitchH = RegByteIn(TDA_DIVH) & 0xf8;
280 1
281 1 RegByteOut(TDA_DIVH, tpitchH | ((unsigned char)(pitch>>8)&0x07));
282 1 RegByteOut(TDA_DIVL, (unsigned char)pitch);
283 1
284 1
285 1 #if (DEBUGMSG>=3)
printf(" Pitch=%d", pitch);
#endif
288 1
289 1 }
290
291
292
293 #if (!MODE_ADJ_BY_CALCULATE)
#if MODE_ADJ_SMALL_STEP
#define mt ival
#define nt ival1
#define NMUL 7
#define MINM 4
#define MAXM 0x3F
C51 COMPILER V6.23a MISC 09/10/2004 16:09:02 PAGE 6
#define MAXN 0x1FF
void miscDClkUp(unsigned char delta)
{
unsigned long F, fs, ft;
unsigned int M, N;
unsigned char i;
M = RegByteIn(0x2B);
N = (((unsigned int)RegByteIn(0x2D)&0x0F)<<8) + RegByteIn(0x2C);
#if (DEBUGMSG >= 3)
printf(" miscDClkUp: %04X/%02X %d",
(unsigned int)N, (unsigned int)M, (unsigned int)((long)1200*N/M));
#endif
for (i = 0; i < delta; i++)
{
F = ((unsigned long)N << NMUL) / M;
fs = 0xFFF << NMUL;
for (mt = MINM; mt <= MAXM; mt++) {
for (nt = (F*mt)>>NMUL; nt <= MAXN; nt++) {
ft = ((unsigned long)nt<<NMUL)/mt;
if (ft > F) {
if (fs > ft-F) {
fs = ft-F; N = nt; M = mt;
}
break;
}
}
}
}
RegByteOut(0x2B, (unsigned char) M);
RegByteOut(0x2C, (unsigned char) N);
RegByteOut(0x2D, (unsigned char) (N>>8) & 0x0F);
#if (DEBUGMSG >= 3)
printf(" -> %04X/%02X %d\n",
(unsigned int)N, (unsigned int)M, (unsigned int)((long)1200*N/M));
#endif
}
void miscDClkDown(unsigned char delta)
{
unsigned long F, fs, ft;
unsigned int M, N;
unsigned char i;
M = RegByteIn(0x2B);
N = (((unsigned int)RegByteIn(0x2D)& 0x0F)<<8) + RegByteIn(0x2C);
#if (DEBUGMSG >= 3)
printf(" miscDClkDown: %04X/%02X %d", N, M, (unsigned int)((long)1200*N/M));
#endif
for (i = 0; i < delta; i++)
{
C51 COMPILER V6.23a MISC 09/10/2004 16:09:02 PAGE 7
F = ((unsigned long)N << NMUL) / M;
fs = 0xFF<<NMUL;
for (mt = MINM; mt <= MAXM; mt++) {
for (nt = ((F*mt)>>NMUL)+1; nt > 2; nt--) {
ft = ((unsigned long)nt<<NMUL)/mt;
if (F > ft) {
if (fs > F-ft) {
fs = F-ft; N = nt; M = mt;
}
break;
}
}
}
}
RegByteOut(0x2B, (unsigned char) M);
RegByteOut(0x2C, (unsigned char) N);
RegByteOut(0x2D, (unsigned char) (N>>8)&0x0F);
#if (DEBUGMSG >= 3)
printf(" -> %04X/%02X %d\n",(unsigned int)N, (unsigned int)M, (unsigned int)((long)1200*N/M));
#endif
}
#else //MODE_ADJ_SMALL_STEP
#define NMUL 7 //6
#define MINM 4 //4
#define MAXM 0x1D //0F
#define MAXN 0xFD //7F
#define ft ival
#define fs ival1
#define F ival2
void miscDClkUp(unsigned char delta)
{
unsigned int mt, nt;
unsigned char M, N;
unsigned char i;
M = RegByteIn(0x2B);
nt = (((unsigned int)RegByteIn(0x2D)&0x0F)<<8) + RegByteIn(0x2C);
#if (DEBUGMSG >= 3)
printf(" miscDClkUp: %04X/%02X %d",(unsigned int)nt, (unsigned int)M, (unsigned int)((long)1200*nt/
-M));
#endif
F = ((unsigned long)nt << NMUL) / M;
fs = 0xFF<<NMUL;
for (i = 0; i < delta; i++)
{
for (mt = MINM; mt <= MAXM; mt++) {
nt = (F*mt)>>NMUL;
if (nt > 0xff) break;
for (; nt <= MAXN; nt++) {
ft = (nt<<NMUL)/mt;
if (ft > F) {
C51 COMPILER V6.23a MISC 09/10/2004 16:09:02 PAGE 8
if (fs >= ft-F) {
fs = ft-F; N = nt; M = mt;
}
break;
}
}
}
F = ((unsigned int)N<<NMUL) / M;
fs = 0xFF<<NMUL;
}
RegByteOut(0x2B, (unsigned char) M);
RegByteOut(0x2C, (unsigned char) N);
RegByteOut(0x2D, (unsigned char) (N>>8) & 0x0F);
#if (DEBUGMSG >= 3)
printf(" -> %04X/%02X %d\n",(unsigned int)N, (unsigned int)M, (unsigned int)((long)1200*N/M));
#endif
}
void miscDClkDown(unsigned char delta)
{
unsigned int mt, nt;
unsigned char M, N;
unsigned char i;
M = RegByteIn(0x2B);
nt = (((unsigned int)RegByteIn(0x2D)& 0x0F)<<8) + RegByteIn(0x2C);
#if (DEBUGMSG >= 3)
printf(" miscDClkDown: %04X/%02X %d",(unsigned int)nt,(unsigned int)M, (unsigned int)((long)1200*nt
-/M));
#endif
F = ((unsigned long)nt<<NMUL) / M;
fs = 0xFF<<NMUL;
for (i = 0; i < delta; i++)
{
for (mt = 1+2; mt <= MAXM; mt++) {
nt = ((F*mt)>>NMUL)+1 ;
if (nt > 0xff) break;
for ( ; nt > 2; nt--) {
ft = (nt<<NMUL)/mt;
if (F > ft) {
if (fs > F-ft) {
fs = F-ft; N = nt; M = mt;
}
break;
}
}
}
F = ((unsigned int)N<<NMUL) / M;
fs = 0xFF<<NMUL;
}
RegByteOut(0x2B, (unsigned char) M);
RegByteOut(0x2C, (unsigned char) N);
RegByteOut(0x2D, (unsigned char) (N>>8)&0x0F);
#if (DEBUGMSG >= 3)
printf(" -> %04X/%02X %d\n",(unsigned int)N, (unsigned int)M, (unsigned int)((long)1200*N/M));
#endif
}
C51 COMPILER V6.23a MISC 09/10/2004 16:09:02 PAGE 9
#undef ft
#undef fs
#undef F
#endif //MODE_ADJ_SMALL_STEP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -