⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pal_library.cp

📁 Pal Signal generation with 8-Bit microcontroller. PIC18F4620
💻 CP
📖 第 1 页 / 共 2 页
字号:
 }
#line 500 "C:/Users/aykut/Documents/Proje/PIC/pic_pal_tv/PAL_library.c"
 ptr = PAL_screen + (((PAL_lineVideo - PAL_shift_y) & 0b11111110) << 3) ;
#line 505 "C:/Users/aykut/Documents/Proje/PIC/pic_pal_tv/PAL_library.c"
  asm MOVFF _PAL_border, PORTD  ;
#line 511 "C:/Users/aykut/Documents/Proje/PIC/pic_pal_tv/PAL_library.c"
 if(PAL_render && ((PAL_lineVideo >= PAL_shift_y) && (PAL_lineVideo < PAL_max_y)))
 {
#line 517 "C:/Users/aykut/Documents/Proje/PIC/pic_pal_tv/PAL_library.c"
 dummy = *ptr ;

  asm { MOVFF PAL_ISR_ptr_L2, FSR0L } asm { MOVFF PAL_ISR_ptr_L2+1, FSR0H } asm { MOVFF POSTINC0, PORTD }  ;

  asm { INFSNZ PAL_ISR_ptr_L2, 1, 1 } asm { INCF PAL_ISR_ptr_L2+1, 1, 1 } asm { RRCF PORTD, 1, 0 } asm { MOVFF PAL_ISR_ptr_L2, FSR0L } asm { RRCF PORTD, 1, 0 } asm { MOVFF PAL_ISR_ptr_L2+1, FSR0H } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop }  ;  asm { MOVFF POSTINC0, PORTD }  ;
  asm { INFSNZ PAL_ISR_ptr_L2, 1, 1 } asm { INCF PAL_ISR_ptr_L2+1, 1, 1 } asm { RRCF PORTD, 1, 0 } asm { MOVFF PAL_ISR_ptr_L2, FSR0L } asm { RRCF PORTD, 1, 0 } asm { MOVFF PAL_ISR_ptr_L2+1, FSR0H } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop }  ;  asm { MOVFF POSTINC0, PORTD }  ;
  asm { INFSNZ PAL_ISR_ptr_L2, 1, 1 } asm { INCF PAL_ISR_ptr_L2+1, 1, 1 } asm { RRCF PORTD, 1, 0 } asm { MOVFF PAL_ISR_ptr_L2, FSR0L } asm { RRCF PORTD, 1, 0 } asm { MOVFF PAL_ISR_ptr_L2+1, FSR0H } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop }  ;  asm { MOVFF POSTINC0, PORTD }  ;
  asm { INFSNZ PAL_ISR_ptr_L2, 1, 1 } asm { INCF PAL_ISR_ptr_L2+1, 1, 1 } asm { RRCF PORTD, 1, 0 } asm { MOVFF PAL_ISR_ptr_L2, FSR0L } asm { RRCF PORTD, 1, 0 } asm { MOVFF PAL_ISR_ptr_L2+1, FSR0H } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop }  ;  asm { MOVFF POSTINC0, PORTD }  ;
  asm { INFSNZ PAL_ISR_ptr_L2, 1, 1 } asm { INCF PAL_ISR_ptr_L2+1, 1, 1 } asm { RRCF PORTD, 1, 0 } asm { MOVFF PAL_ISR_ptr_L2, FSR0L } asm { RRCF PORTD, 1, 0 } asm { MOVFF PAL_ISR_ptr_L2+1, FSR0H } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop }  ;  asm { MOVFF POSTINC0, PORTD }  ;
  asm { INFSNZ PAL_ISR_ptr_L2, 1, 1 } asm { INCF PAL_ISR_ptr_L2+1, 1, 1 } asm { RRCF PORTD, 1, 0 } asm { MOVFF PAL_ISR_ptr_L2, FSR0L } asm { RRCF PORTD, 1, 0 } asm { MOVFF PAL_ISR_ptr_L2+1, FSR0H } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop }  ;  asm { MOVFF POSTINC0, PORTD }  ;
  asm { INFSNZ PAL_ISR_ptr_L2, 1, 1 } asm { INCF PAL_ISR_ptr_L2+1, 1, 1 } asm { RRCF PORTD, 1, 0 } asm { MOVFF PAL_ISR_ptr_L2, FSR0L } asm { RRCF PORTD, 1, 0 } asm { MOVFF PAL_ISR_ptr_L2+1, FSR0H } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop }  ;  asm { MOVFF POSTINC0, PORTD }  ;
  asm { INFSNZ PAL_ISR_ptr_L2, 1, 1 } asm { INCF PAL_ISR_ptr_L2+1, 1, 1 } asm { RRCF PORTD, 1, 0 } asm { MOVFF PAL_ISR_ptr_L2, FSR0L } asm { RRCF PORTD, 1, 0 } asm { MOVFF PAL_ISR_ptr_L2+1, FSR0H } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop }  ;  asm { MOVFF POSTINC0, PORTD }  ;
  asm { INFSNZ PAL_ISR_ptr_L2, 1, 1 } asm { INCF PAL_ISR_ptr_L2+1, 1, 1 } asm { RRCF PORTD, 1, 0 } asm { MOVFF PAL_ISR_ptr_L2, FSR0L } asm { RRCF PORTD, 1, 0 } asm { MOVFF PAL_ISR_ptr_L2+1, FSR0H } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop }  ;  asm { MOVFF POSTINC0, PORTD }  ;
  asm { INFSNZ PAL_ISR_ptr_L2, 1, 1 } asm { INCF PAL_ISR_ptr_L2+1, 1, 1 } asm { RRCF PORTD, 1, 0 } asm { MOVFF PAL_ISR_ptr_L2, FSR0L } asm { RRCF PORTD, 1, 0 } asm { MOVFF PAL_ISR_ptr_L2+1, FSR0H } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop }  ;  asm { MOVFF POSTINC0, PORTD }  ;
  asm { INFSNZ PAL_ISR_ptr_L2, 1, 1 } asm { INCF PAL_ISR_ptr_L2+1, 1, 1 } asm { RRCF PORTD, 1, 0 } asm { MOVFF PAL_ISR_ptr_L2, FSR0L } asm { RRCF PORTD, 1, 0 } asm { MOVFF PAL_ISR_ptr_L2+1, FSR0H } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop }  ;  asm { MOVFF POSTINC0, PORTD }  ;
  asm { INFSNZ PAL_ISR_ptr_L2, 1, 1 } asm { INCF PAL_ISR_ptr_L2+1, 1, 1 } asm { RRCF PORTD, 1, 0 } asm { MOVFF PAL_ISR_ptr_L2, FSR0L } asm { RRCF PORTD, 1, 0 } asm { MOVFF PAL_ISR_ptr_L2+1, FSR0H } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop }  ;  asm { MOVFF POSTINC0, PORTD }  ;
  asm { INFSNZ PAL_ISR_ptr_L2, 1, 1 } asm { INCF PAL_ISR_ptr_L2+1, 1, 1 } asm { RRCF PORTD, 1, 0 } asm { MOVFF PAL_ISR_ptr_L2, FSR0L } asm { RRCF PORTD, 1, 0 } asm { MOVFF PAL_ISR_ptr_L2+1, FSR0H } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop }  ;  asm { MOVFF POSTINC0, PORTD }  ;
  asm { INFSNZ PAL_ISR_ptr_L2, 1, 1 } asm { INCF PAL_ISR_ptr_L2+1, 1, 1 } asm { RRCF PORTD, 1, 0 } asm { MOVFF PAL_ISR_ptr_L2, FSR0L } asm { RRCF PORTD, 1, 0 } asm { MOVFF PAL_ISR_ptr_L2+1, FSR0H } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop }  ;  asm { MOVFF POSTINC0, PORTD }  ;
  asm { INFSNZ PAL_ISR_ptr_L2, 1, 1 } asm { INCF PAL_ISR_ptr_L2+1, 1, 1 } asm { RRCF PORTD, 1, 0 } asm { MOVFF PAL_ISR_ptr_L2, FSR0L } asm { RRCF PORTD, 1, 0 } asm { MOVFF PAL_ISR_ptr_L2+1, FSR0H } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop }  ;  asm { MOVFF POSTINC0, PORTD }  ;
  asm { INFSNZ PAL_ISR_ptr_L2, 1, 1 } asm { INCF PAL_ISR_ptr_L2+1, 1, 1 } asm { RRCF PORTD, 1, 0 } asm { MOVFF PAL_ISR_ptr_L2, FSR0L } asm { RRCF PORTD, 1, 0 } asm { MOVFF PAL_ISR_ptr_L2+1, FSR0H } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop } asm { RRCF PORTD, 1, 0 } asm { nop }  ;

  asm MOVFF _PAL_border, PORTD  ;
 }
 }
 else
 {
#line 547 "C:/Users/aykut/Documents/Proje/PIC/pic_pal_tv/PAL_library.c"
  PORTE.F0  = (PAL_lineCode & 1) ? 1 : 0 ;
 if(PAL_lineCode & 2) Delay_us( 1 ) ; else Delay_us( 20  - 6) ;

 PAL_linePtr++ ;
 PAL_lineIdx++ ;
 PAL_lineVideo = 0 ;
#line 556 "C:/Users/aykut/Documents/Proje/PIC/pic_pal_tv/PAL_library.c"
 if(PAL_lineIdx == sizeof(PAL_ltype))
 {
 PAL_lineIdx = 0 ;
 PAL_linePtr = PAL_ltype ;
 PAL_frameCtr++ ;
 }

  PORTE.F0  = (PAL_lineCode & 4) ? 1 : 0 ;
 if(PAL_lineCode !=  ( 0b10 )  | ( 0b11  << 2)  | ( 0b01  << 4)  | ( 0b01  << 6) )
 {
 if(PAL_lineCode & 8) Delay_us( 1 ) ; else Delay_us( 20 ) ;

  PORTE.F0  = (PAL_lineCode & 16) ? 1 : 0 ;
 if(PAL_lineCode & 32) Delay_us( 1 ) ; else Delay_us( 20 ) ;

  PORTE.F0  = (PAL_lineCode & 64) ? 1 : 0 ;
 }

 }

 TABLAT = d ;

 INTCON.TMR0IF = 0 ;
 }
 }
#line 597 "C:/Users/aykut/Documents/Proje/PIC/pic_pal_tv/PAL_library.c"
void PAL_init(unsigned char y)
 {
 INTCON.T0IF = 0 ;
 INTCON.T0IE = 0 ;

 T0CON = 0b11000000 ;

 PAL_y = y ;
 PAL_shift_y = 286 / 2 - y ;
 PAL_max_y = y * 2 + PAL_shift_y ;
 }
#line 621 "C:/Users/aykut/Documents/Proje/PIC/pic_pal_tv/PAL_library.c"
void PAL_control(unsigned char st, unsigned char rd)
 {
 if(st)
 {
 INTCON.GIE = 1 ;
 INTCON.T0IE = 1 ;
 }
 else
 {
 INTCON.T0IE = 0 ;
 }

 PAL_render = rd ;
 }
#line 648 "C:/Users/aykut/Documents/Proje/PIC/pic_pal_tv/PAL_library.c"
void PAL_fill(unsigned char c)
 {
 memset(PAL_screen, c,  128  * PAL_y / 8) ;
 }
#line 664 "C:/Users/aykut/Documents/Proje/PIC/pic_pal_tv/PAL_library.c"
void PAL_setBorder(unsigned char border)
 {
 PAL_border = border ;
 }
#line 682 "C:/Users/aykut/Documents/Proje/PIC/pic_pal_tv/PAL_library.c"
void PAL_setPixel(char x, char y, unsigned char mode)
 {
 unsigned char *ptr ;
 unsigned char mask ;
#line 690 "C:/Users/aykut/Documents/Proje/PIC/pic_pal_tv/PAL_library.c"
 if(x < 0) return ;
 if(y < 0) return ;
 if(x >=  128 ) return ;
 if(y >= PAL_y) return ;

 ptr = PAL_screen + (((y << 7) + x) >> 3) ;
 mask = 1 << (x & 7) ;

 switch(mode)
 {
 case  0 :
 *ptr &= ~mask ;
 break ;
 case  1 :
 *ptr |= mask ;
 break ;
 default:
 *ptr ^= mask ;
 break ;
 }
 }
#line 725 "C:/Users/aykut/Documents/Proje/PIC/pic_pal_tv/PAL_library.c"
void PAL_line(char x0, char y0, char x1, char y1, unsigned char pcolor)
 {
 int dy ;
 int dx ;
 int stepx, stepy ;

 dy = y1 - y0 ;
 dx = x1 - x0 ;

 if(dy < 0)
 {
 dy = -dy ;
 stepy = -1 ;
 }
 else
 {
 stepy = 1 ;
 }

 if(dx < 0)
 {
 dx = -dx ;
 stepx = -1 ;
 }
 else
 {
 stepx = 1 ;
 }

 dy <<= 1 ;
 dx <<= 1 ;

 PAL_setPixel(x0, y0, pcolor) ;

 if(dx > dy)
 {
 int fraction = dy - (dx >> 1) ;

 while(x0 != x1)
 {
 if(fraction >= 0)
 {
 y0 += stepy ;
 fraction -= dx ;
 }
 x0 += stepx ;
 fraction += dy ;
 PAL_setPixel(x0, y0, pcolor) ;
 }
 }
 else
 {
 int fraction = dx - (dy >> 1) ;

 while(y0 != y1)
 {
 if(fraction >= 0)
 {
 x0 += stepx ;
 fraction -= dy ;
 }
 y0 += stepy ;
 fraction += dx ;
 PAL_setPixel(x0, y0, pcolor) ;
 }
 }
 }
#line 806 "C:/Users/aykut/Documents/Proje/PIC/pic_pal_tv/PAL_library.c"
void PAL_circle(char x, char y, char r, unsigned char pcolor)
 {
 long px, py, opx, opy ;
 int a ;

 for(a = 0 ; a <= 360 ; a += 15)
 {
#line 816 "C:/Users/aykut/Documents/Proje/PIC/pic_pal_tv/PAL_library.c"
 px = (long)sinE3(a) * r ;
 px /= 1000 ;
 px += x ;
#line 823 "C:/Users/aykut/Documents/Proje/PIC/pic_pal_tv/PAL_library.c"
 py = (long)cosE3(a) * r ;
 py /= 1000 ;
 py += y ;
#line 830 "C:/Users/aykut/Documents/Proje/PIC/pic_pal_tv/PAL_library.c"
 if(a > 0)
 {
 PAL_line(opx, opy, px, py, pcolor) ;
 }
 opx = px ;
 opy = py ;
 }
 }
#line 852 "C:/Users/aykut/Documents/Proje/PIC/pic_pal_tv/PAL_library.c"
void PAL_box(char x0, char y0, char x1, char y1, unsigned char pcolor)
 {
#line 857 "C:/Users/aykut/Documents/Proje/PIC/pic_pal_tv/PAL_library.c"
 while(x0 != x1)
 {
 PAL_line(x0, y0, x0, y1, pcolor) ;
 x0++ ;
 }
 }
#line 877 "C:/Users/aykut/Documents/Proje/PIC/pic_pal_tv/PAL_library.c"
void PAL_rectangle(char x0, char y0, char x1, char y1, unsigned char pcolor)
 {
#line 882 "C:/Users/aykut/Documents/Proje/PIC/pic_pal_tv/PAL_library.c"
 PAL_line(x0, y0, x1, y0, pcolor) ;
 PAL_line(x1, y0, x1, y1, pcolor) ;
 PAL_line(x1, y1, x0, y1, pcolor) ;
 PAL_line(x0, y1, x0, y0, pcolor) ;
 }
#line 901 "C:/Users/aykut/Documents/Proje/PIC/pic_pal_tv/PAL_library.c"
void PAL_char(unsigned char x, unsigned char y, unsigned char c, unsigned char size)
 {
 unsigned char i, j ;
 unsigned char px, py ;
 unsigned char sx, sy ;
 unsigned char mx, my ;
 const char *ptr ;
#line 912 "C:/Users/aykut/Documents/Proje/PIC/pic_pal_tv/PAL_library.c"
 mx = size & 0x0f ;
 my = size >> 4 ;
#line 918 "C:/Users/aykut/Documents/Proje/PIC/pic_pal_tv/PAL_library.c"
 ptr = PAL_charTable + c * 6 ;
#line 923 "C:/Users/aykut/Documents/Proje/PIC/pic_pal_tv/PAL_library.c"
 for(i = 0 ; i < 6 ; i++)
 {
 px = x + i * mx ;
 c = *ptr++ ;
 py = y ;
#line 932 "C:/Users/aykut/Documents/Proje/PIC/pic_pal_tv/PAL_library.c"
 for(j = 0 ; j < 8 ; j++)
 {
 for(sx = 0 ; sx < mx ; sx++)
 {
 for(sy = 0 ; sy < my ; sy++)
 {
 PAL_setPixel(px + sx, py + sy, c & 1) ;
 }
 }
 c >>= 1 ;
 py += my ;
 }
 }
 }
#line 961 "C:/Users/aykut/Documents/Proje/PIC/pic_pal_tv/PAL_library.c"
void PAL_write(unsigned char lig, unsigned char col, unsigned char *s, unsigned char size)
 {
 unsigned char c ;
#line 968 "C:/Users/aykut/Documents/Proje/PIC/pic_pal_tv/PAL_library.c"
 lig <<= 3 ;
 col *= 6 ;

 while(c = *s++)
 {
 PAL_char(col, lig, c, size) ;
 col += 6 *(size & 0x0f) ;
 }
 }
#line 992 "C:/Users/aykut/Documents/Proje/PIC/pic_pal_tv/PAL_library.c"
void PAL_constWrite(unsigned char lig, unsigned char col, const unsigned char *s, unsigned char size)
 {
 unsigned char c ;

 lig <<= 3 ;
 col *= 6 ;
 while(c = *s++)
 {
 PAL_char(col, lig, c, size) ;
 col += 6 *(size & 0x0f) ;
 }
 }
#line 1020 "C:/Users/aykut/Documents/Proje/PIC/pic_pal_tv/PAL_library.c"
void PAL_picture(unsigned char x, unsigned char y, const unsigned char *bm, unsigned char sx, unsigned char sy)
 {
 unsigned char i, j, k ;
 unsigned char px ;
 unsigned int py ;
 unsigned char c ;

 sx /= 8 ;
 x /= 8 ;
 for(j = 0 ; j < sy ; j++)
 {
 py = (y + j) << 4 ;
 for(i = 0 ; i < sx ; i++)
 {
 unsigned char rc ;

 px = x + i ;
 c = *bm++ ;
 for(k = 0 ; k < 8 ; k++)
 {
 rc <<= 1 ;
 rc |= c & 1 ;
 c >>= 1 ;
 }

 PAL_screen[px + py] = rc ;
 }
 }
 }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -