[MN-dev] [mndiff]: r55 - in trunk/2010: 2010.cc 2010.h 2_71x6.cc 2_all.h 2_crypt.cc 2_crypt.h 2_gfunc.cc 2_grafix.cc 2_hw.cc 2_txt.cc 2_txt.h 2_vc.cc makefile

michael subversion at mplayerhq.hu
Wed Jul 4 09:50:51 CEST 2007


Author: michael
Date: Wed Jul  4 09:50:51 2007
New Revision: 55

Log:
next version (unknown date)


Added:
   trunk/2010/2_txt.cc
   trunk/2010/2_txt.h
Modified:
   trunk/2010/2010.cc
   trunk/2010/2010.h
   trunk/2010/2_71x6.cc
   trunk/2010/2_all.h
   trunk/2010/2_crypt.cc
   trunk/2010/2_crypt.h
   trunk/2010/2_gfunc.cc
   trunk/2010/2_grafix.cc
   trunk/2010/2_hw.cc
   trunk/2010/2_vc.cc
   trunk/2010/makefile

Modified: trunk/2010/2010.cc
==============================================================================
--- trunk/2010/2010.cc	(original)
+++ trunk/2010/2010.cc	Wed Jul  4 09:50:51 2007
@@ -45,6 +45,8 @@
  extern bool iState;
  extern bool helpState;
  extern bool allowDrop;
+ extern int reqPage, reqSubPage, reqChanNum;
+ extern char *reqChanStr;
 
  int maxBuf=2;
  int some=0;
@@ -113,6 +115,8 @@ int error(error_code e){
                      break;
   case KeyFile     : printg_t("\nKeyFile error!\n");
                      break;
+  case TxtFile     : printg_t("\nTxtFile error!\n");
+                     break;
   case DatWrite    : printg_t("\nDatWrite error!\n");
                      break;
   case Align       : printg_t("\nAlign error!\n");
@@ -405,6 +409,30 @@ int main(int argc, char **argv){
                        case 'd'  :
                        case 'D'  : allowDrop= !allowDrop;
                        break;
+                       case '+'  : reqPage++;
+                       break;
+                       case '-'  : reqPage--;
+                       break;
+                       case K_Up : reqChanNum++;
+                       break;
+                       case K_Down           : reqChanNum--;
+                       break;
+                       case K_Right          : reqSubPage++;
+                       break;
+                       case K_Left           : reqSubPage--;
+                       break;
+                       case K_Control_KPPlus : reqPage+=10;
+                       break;
+                       case K_Control_KPDash : reqPage-=10;
+                       break;
+                       case K_Control_Up     : reqChanNum+=10;
+                       break;
+                       case K_Control_Down   : reqChanNum-=10;
+                       break;
+                       case K_Control_Right  : reqSubPage+=10;
+                       break;
+                       case K_Control_Left   : reqSubPage-=10;
+                       break;
                        case '1'  : delay++;
                        break;
                        case '2'  : delay--; if(delay<0) delay=0;

Modified: trunk/2010/2010.h
==============================================================================
--- trunk/2010/2010.h	(original)
+++ trunk/2010/2010.h	Wed Jul  4 09:50:51 2007
@@ -27,11 +27,14 @@ enum error_code{
  KeyFile,
  Align,
  Nagra,
+ TxtFile,
 };
 
 enum MENULEVEL{
   mLNorm,
   mLTVStd,
+  mLTXTPage,
+  mLTXTChan,
 };
 
 int error(error_code e);

Modified: trunk/2010/2_71x6.cc
==============================================================================
--- trunk/2010/2_71x6.cc	(original)
+++ trunk/2010/2_71x6.cc	Wed Jul  4 09:50:51 2007
@@ -318,14 +318,17 @@ void setStdScale(void){
  int i;
 
  mc=1;
- xresc=vgax<<mc;
-
- wndx=vgax;
 
- if(TVStd==TXTPAL)
-   scales_y=0x1 , scalee_y=0x1;
- else 
+ if(TVStd==TXTPAL){
+   scales_y=0x0 , scalee_y=0x0 -288 + 20;
+   xresc=vgax<<(mc+2);
+   wndx=768;
+ }
+ else{ 
    scales_y=0x11, scalee_y=0x11;
+   xresc=vgax<<mc;
+   wndx=vgax;
+ }
 
  if(TVStd==NTSC)
     y_field=240-scales_y+scalee_y, x_field=640-scales_x+scalee_x;
@@ -336,8 +339,9 @@ void setStdScale(void){
  else                                                       oneField=false;
 
  int yrest;
- if((cryptStd!=nag && TVStd!=TXTPAL) || vgay-70 > y_field) yrest= vgay;
- else                                                      yrest= vgay << 1;
+ if(TVStd==TXTPAL)                           yrest= 40;
+ else if(cryptStd!=nag || vgay-70 > y_field) yrest= vgay;
+ else                                        yrest= vgay << 1;
 
  if     (!oneField && yrest>y_field*2){
    outy= y_field*2;
@@ -351,28 +355,35 @@ void setStdScale(void){
    outy= yrest;
  }
 
- if(TVStd==TXTPAL) wndx=vgax;
-
- if(wndx > vgax){
+ if(wndx > vgax && TVStd!=TXTPAL){
 //   outy= int( double(outy) * double(x_field) / double(vgax) ); // ?! JOKE
    wndx= vgax;
  }
 
  if(wndx>x_field) wndx=x_field; // no scaling !?
 
- wndx =(wndx  + 7) & 0x3F8;
- outy=(outy + 1) & 0x3FE;
+ wndx =(wndx + 7) & 0x3F8;
+ outy =(outy + 1) & 0x3FE;
 
- if(wndx > vgax ) vgax  -=8;
+ if(wndx > vgax ) wndx-=8;
  if(outy > yrest) outy-=2;
 
- if(!oneField) stride=(vgax + vgax - wndx)<<mc;
- else          stride=(vgax        - wndx)<<mc;
+ if(TVStd==TXTPAL)  stride=((vgax<<3) - wndx)<<mc;
+ else if(!oneField) stride=((vgax<<1) - wndx)<<mc;
+ else               stride=( vgax     - wndx)<<mc;
 
  if((cryptStd!=nag && TVStd!=TXTPAL) || vgay-70 > y_field) wndy= outy;
  else                                                      wndy= outy >> 1;
 
 
+ if(TVStd==TXTPAL) write_saa7196(0x06, 0xC6);            
+ else              write_saa7196(0x06, 0x46);            
+                           /*   7  Input mode =0 CVBS, =1 S-Video
+                                6  Pre filter
+                              5:4  Aperture Bandpass characteristics
+                              3:2  Coring range for high freq
+                              1:0  Aperture bandpass filter weights        */
+
  if(TVStd==SECAM) write_saa7196(0x0D, 0x85);
  else             write_saa7196(0x0D, 0x84);  
                            /*   7  VTR/TV mode bit = 1->VTR mode
@@ -414,7 +425,7 @@ void setStdScale(void){
                            /* 7:0  [7:0] Pixel number per line on input    */
  write_saa7196(0x23, scales_x);/* 7:0  [7:0] Horizontal start position of scaling win*/
  i=saa7196_buf[0x24] & 0xE0;
- i=(some<<5) & 0xE0;
+ if(TVStd==TXTPAL) i=4;
  write_saa7196(0x24, i | ((x_field>>6) & 0x0C) | (wndx>>8));
                            /* 7:5  Horizontal decimation filter
                                 4  [8] Horizontal start position of scaling win
@@ -426,9 +437,8 @@ void setStdScale(void){
  write_saa7196(0x26, y_field & 0xFF);
                            /* 7:0  [7:0] Line number per input field       */
  write_saa7196(0x27, scales_y);/* 7:0  [7:0] Vertical start of scaling window  */
-// i=saa7196_buf[0x28] & 0xE0;
  if(TVStd==TXTPAL) i=0;
- else              i=0x80;
+ else              i=saa7196_buf[0x28] & 0xE0;
  if(oneField) write_saa7196(0x28, i | ((y_field>>6) & 0x0C) | (outy>>8));
  else         write_saa7196(0x28, i | ((y_field>>6) & 0x0C) | (outy>>9));
                            /*   7  Adaptive filter switch
@@ -529,17 +539,6 @@ void init_meteor(void){
  write_saa7196(0x04, 0xB6);/* 7:0  Horizontal Sync Clamp Stop for 50hz     */
  write_saa7196(0x05, 0xF4);/* 7:0  Horizontal Sync Start after PH1 for 50hz */
 
-
-#ifndef NoColorDeco
- write_saa7196(0x06, 0x46);             //46
-#else
- write_saa7196(0x06, 0xC6);             //46
-#endif
-                           /*   7  Input mode =0 CVBS, =1 S-Video
-                                6  Pre filter
-                              5:4  Aperture Bandpass characteristics
-                              3:2  Coring range for high freq
-                              1:0  Aperture bandpass filter weights        */
  write_saa7196(0x07, 0x00);/* 7:0  Hue                                     */
  write_saa7196(0x08, 0x7F);/* 7:3  Colour-killer threshold QAM (PAL, NTSC) */
  write_saa7196(0x09, 0x7F);/* 7:3  Colour-killer threshold SECAM           */
@@ -554,12 +553,8 @@ void init_meteor(void){
                                 2  S-VHS bit
                                 1  GPSW2
                                 0  GPSW1                                   */
-//write_saa7196(0x10, 0x02);   
-#ifndef NoColorDeco
+// write_saa7196(0x10, 0x04);
  write_saa7196(0x10, 0x00);
-#else
- write_saa7196(0x10, 0x04);
-#endif
                            /*   2  Select HREF Position
                               1:0  Vertical noise reduction                */
  write_saa7196(0x11, 0x2C);/* 7:0  Chrominance gain conrtol for QAM        */

Modified: trunk/2010/2_all.h
==============================================================================
--- trunk/2010/2_all.h	(original)
+++ trunk/2010/2_all.h	Wed Jul  4 09:50:51 2007
@@ -68,15 +68,48 @@ class color{
  public:
    COL col;
    color(void) { };
+   color(int y, int u, int v, byte yuv_mode) {init(y,u,v,yuv_mode);};
    void init(int y, int u, int v, byte yuv_mode){       // fix (yuv_mode==0)
-     col.yuv=   u | (y<<8) | (v<<16) | (y<<24);
      col.r=minmax(0, int( y + 1.375   *v             ), 255);
-     col.g=minmax(0, int( y - 0.703125*v - 0.34375*u ), 255);
+     col.g=minmax(0, int( y - 0.703125*v - 0.34375 *u), 255);
      col.b=minmax(0, int( y              + 1.734375*u), 255);
      const int r5= ((col.r>>3) & 0x1F);
      const int g6= ((col.g>>2) & 0x3F); 
      const int b5= ((col.b>>3) & 0x1F);
+/*
+     r=y + (+ 1.375   )*v             
+     g=y + (- 0.703125)*v + (- 0.34375 )*u
+     b=y                  + (+ 1.734375)*u
+
+         r    =y + (+ 1.375   )*v
+     (-1)r + g=  + (- 2.078125)*v + (- 0.34375 )*u 
+     (-1)r + b=  + (- 1.375   )*v + (+ 1.734375)*u 
+
+                r               =y + (+ 1.375   )*v
+            (-1)r +            g=  + (- 2.078125)*v + (- 0.34375 )*u 
+            (-1)r +            b=  + (- 1.375   )*v + (+ 1.734375)*u 
+     (+ .481203)r + (- .481203)g=  +              v + (+ 0.165414)*u
+
+                r               =y + (+ 1.375   )*v
+            (-1)r +            g=  + (- 2.078125)*v + (- 0.34375 )*u 
+            (-1)r +            b=  + (- 1.375   )*v + (+ 1.734375)*u 
+     (+ .481203)r + (- .481203)g=  +              v + (+ 0.165414)*u
+     (+ .661654)r + (- .661664)g=  +  (+ 1.375   )v + (+ 0.227444)*u
+     (- .661654)r + (+ .661664)g=  +  (- 1.375   )v + (- 0.227444)*u
+
+     (+ .338346)r + (+ .661664)g +          =y +   + (- 0.227444)*u
+     (+ .481203)r + (- .481203)g +          =  + v + (+ 0.165414)*u
+     (- .338346)r + (- .661664)g +         b=  +   + (+ 1.961819)*u
+
+     (+ .338346)r + (+ .661664)g +              =y +   + (- 0.227444)*u
+     (+ .481203)r + (- .481203)g +              =  + v + (+ 0.165414)*u
+     (- .172465)r + (- .337271)g + (+ 0.509731)b=  +   +              u
+     (- .172465)(- 0.227444)r + (- .337271)(- 0.227444)g + (+ 0.509731)(- 0.227444)b=  +   +              u(- 0.227444)
+     (- .172465)(+ 0.165414)r + (- .337271)(+ 0.165414)g + (+ 0.509731)(+ 0.165414)b=  +   +              u(+ 0.165414)
+  */
+
      col.rgb16= b5 | (g6<<5) | (r5<<11);
+     col.yuv=   u | (y<<8) | (v<<16) | (y<<24);
    };
 } ;
 

Modified: trunk/2010/2_crypt.cc
==============================================================================
--- trunk/2010/2_crypt.cc	(original)
+++ trunk/2010/2_crypt.cc	Wed Jul  4 09:50:51 2007
@@ -7,6 +7,7 @@
 #include "2_crypt.h"
 #include "2_vc.h"
 #include "2_nag.h"
+#include "2_txt.h"
 #include "2_71x6.h"
 #include "2_gfunc.h"
 
@@ -52,6 +53,7 @@ void decrypt(void){
 
  if(cryptStd==vc)       vc_decrypt();
  else if(cryptStd==nag) nag_decrypt();
+ else if(TVStd==TXTPAL) txt_decrypt();
 
  if(iState){
    T2=uclock();

Modified: trunk/2010/2_crypt.h
==============================================================================
--- trunk/2010/2_crypt.h	(original)
+++ trunk/2010/2_crypt.h	Wed Jul  4 09:50:51 2007
@@ -5,6 +5,10 @@
 #define max_x 900
 #define max_y 700
 
+#define FREQ_CHROM     4433618.75
+#define FREQ_HS        15625.0
+#define FREQ_PIX       (FREQ_HS * 1888.0 * 0.5)
+
 void decrypt(void);
 
 #endif

Modified: trunk/2010/2_gfunc.cc
==============================================================================
--- trunk/2010/2_gfunc.cc	(original)
+++ trunk/2010/2_gfunc.cc	Wed Jul  4 09:50:51 2007
@@ -5,7 +5,7 @@
 #include "2_all.h"
 #include "2_gfunc.h"
 
- extern int vgax, vgay, xresc;
+ extern int vgax, vgay, xresc, mc;
  extern int fysize;
  extern byte font[4096];
  extern int g_mode;
@@ -86,6 +86,8 @@ void gprint(int xp, int yp, const COL c,
 
  //FIX ME TEST reg, imm is NP
 
+ static int vgaxmc;
+ vgaxmc= vgax<<mc;
  if(yuvmode!=0){
    asm(//"int $3\n\t"
         "pushl %%ebp               \n\t"
@@ -154,7 +156,7 @@ void gprint(int xp, int yp, const COL c,
         "popl %%eax                \n\t"
         "popl %%ebp                \n\t"
         :
-        : "m" (fysize), "m"(xresc), "m" (&font), "m" (clipyp), "m" (clipym),
+        : "m" (fysize), "m"(vgaxmc), "m" (&font), "m" (clipyp), "m" (clipym),
           "a" (c.yuv), "c" (text), "d" (((u_long)actVid2MemBufp->b)+((xp+yp*vgax)<<1))
         : "%ebx", "%ecx", "%edx", "%esi", "%edi");
  }else{
@@ -213,7 +215,7 @@ void gprint(int xp, int yp, const COL c,
         "jmp 10b                   \n\t" 
         "9:                        \n\t" 
         :
-        : "m" (fysize), "m"(xresc), "m" (&font), "m" (clipyp), "m" (clipym),
+        : "m" (fysize), "m"(vgaxmc), "m" (&font), "m" (clipyp), "m" (clipym),
           "a" (c.rgb16), "c" (text), "d" (((u_long)actVid2MemBufp->b)+((xp+yp*vgax)<<1))
         : "%ebx", "%ecx", "%edx", "%esi", "%edi");
    }

Modified: trunk/2010/2_grafix.cc
==============================================================================
--- trunk/2010/2_grafix.cc	(original)
+++ trunk/2010/2_grafix.cc	Wed Jul  4 09:50:51 2007
@@ -35,13 +35,19 @@ void showStuff(void){
  color c;
 
  if(helpState){
-   char text[6][256]={ "F1/F2 Brightness     s TVStandart",
-                       "F3/F4 Contrast       i debugInfo",
-                       "F5/F6 Saturation     h Help",
-                       "g     ScreenShot     q Quit",
-                       "v     smoothIterlace p Pause",
-                       "d     allowDrop"};
-   for(int i=0; i<6; i++){
+   char text[11][256]={ "F1/F2 Brightness     s TVStandart",
+                        "F3/F4 Contrast       i debugInfo",
+                        "F5/F6 Saturation     h Help", 
+                        "g     ScreenShot     q Quit",
+                        "v     smoothIterlace p Pause",
+                        "d     allowDrop",
+                        "            TELETXT:", 
+                        "+     Page+      -     Page-",
+                        "right subPage+   left  subPage-",
+                        "up    Channel+   down  Channel-",
+                        "c txt Channel    a num Page" };
+
+   for(int i=0; i<11; i++){
      c.init(255, 0, 0, yuvmode);
      gprint(infoPosX, infoPosY+=10, c.col, text[i]);
    }

Modified: trunk/2010/2_hw.cc
==============================================================================
--- trunk/2010/2_hw.cc	(original)
+++ trunk/2010/2_hw.cc	Wed Jul  4 09:50:51 2007
@@ -39,6 +39,7 @@
  extern bool strangeRgb16;
  extern bool iState;
  extern int infoPosX, infoPosY;
+ extern TVSTD TVStd;
 
  bool drop=false;
  bool allowDrop=true;
@@ -309,25 +310,27 @@ void copy_vidbuffer(void){
  }
 
  if(!drop || !allowDrop){
+   const int goodx= TVStd!=TXTPAL ? wndx : vgax;
+   const int goody= TVStd!=TXTPAL ? wndy : vgay;
 
    if(page_flip==0){
      int p=0;
-     for(int y=0; y<wndy; y++){
-       mem2vid(vidbuf+p,              actVid2MemBufp->b+p, wndx, bpp);
+     for(int y=0; y<goody; y++){
+       mem2vid(vidbuf+p,              actVid2MemBufp->b+p, goodx, bpp);
        p+=vgax<<1;
      }
    }else if(page_flip==2){
      int p=0;
-     for(int y=0; y<wndy; y++){
-       mem2vid(vidbuf+xresvb*vgay+p,  actVid2MemBufp->b+p, wndx, bpp);
+     for(int y=0; y<goody; y++){
+       mem2vid(vidbuf+xresvb*vgay+p,  actVid2MemBufp->b+p, goodx, bpp);
        p+=vgax<<1;
      }
      page_flip=1;
      set_start_disp(0, vgay);
    }else{
      int p=0;
-     for(int y=0; y<wndy; y++){
-       mem2vid(vidbuf+p,              actVid2MemBufp->b+p, wndx, bpp);
+     for(int y=0; y<goody; y++){
+       mem2vid(vidbuf+p,              actVid2MemBufp->b+p, goodx, bpp);
        p+=vgax<<1;
      }
      page_flip=2;

Added: trunk/2010/2_txt.cc
==============================================================================
--- (empty file)
+++ trunk/2010/2_txt.cc	Wed Jul  4 09:50:51 2007
@@ -0,0 +1,378 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+
+#include <string.h>
+#include <stdio.h>
+#include <math.h>
+#include <ctype.h>
+#include "2_all.h"
+#include "2010.h"
+#include "2_crypt.h"
+#include "2_gfunc.h"
+#include "2_txt.h"
+
+extern int vgax, vgay, wndx, wndy, mc, x_field;
+extern bool iState, helpState;
+extern volatile scales_x, scalee_x;
+extern volatile scales_y, scalee_y;
+extern VID2MEMBUF *actVid2MemBufp;
+extern int some;
+extern int yuvmode;
+extern int infoPosX, infoPosY;
+
+#define FREQ_TXT 6.9375E6
+#define FIXP_SH 16
+#define ONE_FIXP (1<<FIXP_SH)
+#define BYTES 42
+
+char reqChanStr[16];
+int reqChanNum=0;
+int reqPage=0x100;
+int reqSubPage=0;
+
+static inline float atan3(const float f1, const float f2){
+  float out;
+                     // ?! atan2 crashes 
+  asm(//"int $3\n\t"
+      "fpatan \n\t"
+      : "=t"(out)
+      : "0"(f2), "u"(f1)
+      : "st(1)"
+                          );
+
+  return out;
+}
+
+static signed char corrHamm48[256]={
+  0x01, 0xff, 0x01, 0x01, 0xff, 0x00, 0x01, 0xff,  0xff, 0x02, 0x01, 0xff, 0x0a, 0xff, 0xff, 0x07, 
+  0xff, 0x00, 0x01, 0xff, 0x00, 0x00, 0xff, 0x00,  0x06, 0xff, 0xff, 0x0b, 0xff, 0x00, 0x03, 0xff, 
+  0xff, 0x0c, 0x01, 0xff, 0x04, 0xff, 0xff, 0x07,  0x06, 0xff, 0xff, 0x07, 0xff, 0x07, 0x07, 0x07, 
+  0x06, 0xff, 0xff, 0x05, 0xff, 0x00, 0x0d, 0xff,  0x06, 0x06, 0x06, 0xff, 0x06, 0xff, 0xff, 0x07, 
+  0xff, 0x02, 0x01, 0xff, 0x04, 0xff, 0xff, 0x09,  0x02, 0x02, 0xff, 0x02, 0xff, 0x02, 0x03, 0xff, 
+  0x08, 0xff, 0xff, 0x05, 0xff, 0x00, 0x03, 0xff,  0xff, 0x02, 0x03, 0xff, 0x03, 0xff, 0x03, 0x03, 
+  0x04, 0xff, 0xff, 0x05, 0x04, 0x04, 0x04, 0xff,  0xff, 0x02, 0x0f, 0xff, 0x04, 0xff, 0xff, 0x07, 
+  0xff, 0x05, 0x05, 0x05, 0x04, 0xff, 0xff, 0x05,  0x06, 0xff, 0xff, 0x05, 0xff, 0x0e, 0x03, 0xff, 
+  0xff, 0x0c, 0x01, 0xff, 0x0a, 0xff, 0xff, 0x09,  0x0a, 0xff, 0xff, 0x0b, 0x0a, 0x0a, 0x0a, 0xff, 
+  0x08, 0xff, 0xff, 0x0b, 0xff, 0x00, 0x0d, 0xff,  0xff, 0x0b, 0x0b, 0x0b, 0x0a, 0xff, 0xff, 0x0b, 
+  0x0c, 0x0c, 0xff, 0x0c, 0xff, 0x0c, 0x0d, 0xff,  0xff, 0x0c, 0x0f, 0xff, 0x0a, 0xff, 0xff, 0x07, 
+  0xff, 0x0c, 0x0d, 0xff, 0x0d, 0xff, 0x0d, 0x0d,  0x06, 0xff, 0xff, 0x0b, 0xff, 0x0e, 0x0d, 0xff, 
+  0x08, 0xff, 0xff, 0x09, 0xff, 0x09, 0x09, 0x09,  0xff, 0x02, 0x0f, 0xff, 0x0a, 0xff, 0xff, 0x09, 
+  0x08, 0x08, 0x08, 0xff, 0x08, 0xff, 0xff, 0x09,  0x08, 0xff, 0xff, 0x0b, 0xff, 0x0e, 0x03, 0xff, 
+  0xff, 0x0c, 0x0f, 0xff, 0x04, 0xff, 0xff, 0x09,  0x0f, 0xff, 0x0f, 0x0f, 0xff, 0x0e, 0x0f, 0xff, 
+  0x08, 0xff, 0xff, 0x05, 0xff, 0x0e, 0x0d, 0xff,  0xff, 0x0e, 0x0f, 0xff, 0x0e, 0x0e, 0xff, 0x0e };
+
+static signed char fixParity[256];
+
+static inline int sample(byte *b, int fixpPos){
+  const int ndx  = fixpPos>>FIXP_SH;
+  const int frac = fixpPos & (ONE_FIXP-1);
+
+  const int a1= int(b[ ndx<<1     ]) * (ONE_FIXP - frac); 
+  const int a2= int(b[(ndx<<1) + 2]) * (           frac);
+
+  return (a1+a2) >> FIXP_SH;
+}
+
+
+void txt_decrypt(void){
+  char textbuf[9][128];
+  color c;
+
+  static int hammErr=0;
+
+  const double freqPix2= double(wndx) / double(x_field) * FREQ_PIX;
+  const int delta= int(freqPix2/FREQ_TXT*ONE_FIXP);
+  const double angDelta= FREQ_TXT/freqPix2*PI;
+
+//  byte rawMagic[16]={255,   0, 255,   0, 255,   0, 255,   0,
+//                     255, 255, 255,   0,   0, 255,   0,   0 };
+
+  static CACHE1 *cache1=new CACHE1[1024];
+  static int cache1Size=0;
+  static bool first=true;
+  static color txtCol[8];
+  if(first){
+    FILE *f= fopen("chaninf.txt", "rb");
+    if(f==NULL) error(TxtFile);
+    while(!feof(f)){
+      fscanf(f, "%11[^\n]\n", cache1[cache1Size].chan);
+      cache1[cache1Size].pt= NULL;
+      cache1Size++;
+    }
+
+    for(int i=0; i<256; i++){
+      int j=i&0x7F;                 
+      j^= j+j;                      
+      j^= j<<2;                     
+      j^= j<<4;                     
+      fixParity[i]= i ^ (j&0x80) ^ 0x80;  
+    }
+    // FIX OVERFLOWS ...
+    txtColor[0].init(  0,  0,  0, yuvmode);
+    txtColor[1].init(255,  0,  0, yuvmode);
+    txtColor[2].init(255,  0,  0, yuvmode);
+    txtColor[3].init(255,  0,  0, yuvmode);
+    txtColor[4].init(255,  0,  0, yuvmode);
+    txtColor[5].init(255,  0,  0, yuvmode);
+    txtColor[6].init(255,  0,  0, yuvmode);
+    txtColor[7].init(255,  0,  0, yuvmode);
+    first=false;
+  }
+
+  static CACHE2 *mag[8]={NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
+
+  byte data[64];
+
+  int linep=-(vgax<<4);
+  for(int line=0; line<40; line++){
+    linep+=vgax<<4;
+    if(line==20) linep=vgax<<3;
+
+
+    int avg=0;
+    for(int x=0; x<50; x++){
+      avg+=actVid2MemBufp->b[linep + (x<<1) + 1];
+    }
+    avg/=50;
+
+        // FIX ? optimize in fixp and lut ...
+    double si=0, co=0;
+    double ang=0;
+    for(int x=0; x<10; x++){
+      const int amp= actVid2MemBufp->b[linep + (x<<1) + 1];
+      si+= sin(ang)*(amp-avg);
+      co+= cos(ang)*(amp-avg);
+      ang+= angDelta;
+    }
+    int xFixp= int(atan3(si,co)/PI*freqPix2/FREQ_TXT*ONE_FIXP);
+
+
+    const int magic= 0xAAE4;
+
+    int r=0;
+    int x=xFixp>>FIXP_SH;
+    while(x < 70){
+      r=(r<<1) & 0xFFFF;
+
+      int score= sample( &actVid2MemBufp->b[linep + 1], xFixp );
+
+      if(score > avg) r|=1;
+      actVid2MemBufp->b[linep + (x<<1) + 1]= (r&1)*255;
+      xFixp+=delta;
+      x=xFixp>>FIXP_SH;
+      if(r==magic) break;
+    }
+
+    if(x>=70) continue;
+   
+/*  
+    actVid2MemBufp->b[linep + (x<<1)    ]= 128;
+    actVid2MemBufp->b[linep + (x<<1) + 1]= 255;
+    actVid2MemBufp->b[linep + (x<<1) + 2]= 0  ;
+    actVid2MemBufp->b[linep + (x<<1) + 3]= 255;
+    
+    continue;
+*/
+    r=0;
+
+    for(int decoded=1; decoded<=(BYTES<<3); decoded++){
+      r>>=1;
+
+      int score= sample( &actVid2MemBufp->b[linep + 1], xFixp );
+
+      if(score > avg) r|=0x80;
+      actVid2MemBufp->b[linep + (x<<1) + 1]= (r&0x80)/0x80*255;
+
+      if(!(decoded & 0x07)){
+        data[(decoded>>3) - 1]=r;
+        r=0;
+      }
+
+      xFixp+=delta;
+      x=xFixp>>FIXP_SH;
+    }
+
+    const int d0= corrHamm48[ data[0] ];
+    const int d1= corrHamm48[ data[1] ];
+
+    if(d0<0 || d1<0){ hammErr++; continue;}
+
+    const int magAddr= d0 & 0x7;
+    const int rowAddr= (d0>>3) | (d1<<1);       
+
+    if(rowAddr==0){
+      const int d2= corrHamm48[ data[2] ];
+      const int d3= corrHamm48[ data[3] ];
+      const int d4= corrHamm48[ data[4] ];
+      const int d5= corrHamm48[ data[5] ];
+      const int d6= corrHamm48[ data[6] ];
+      const int d7= corrHamm48[ data[7] ];
+      const int d8= corrHamm48[ data[8] ];
+      const int d9= corrHamm48[ data[9] ];
+
+      if(d2<0 || d3<0 || d4<0 || d5<0 || d6<0 || d7<0 || d8<0 || d9<0){ hammErr++; continue;}
+
+      const int lsPage = d2 | (d3<<4);
+      const int subPage=(d4 | (d5<<4) | (d6<<8) | (d7<<12)) & 0x3F7F;
+      const int page   =(magAddr<<8) | lsPage;
+
+      for(int i=10; i<BYTES; i++){
+        data[i]= fixParity[ data[i] ];
+      }
+
+      int bestLen=0;
+      int best=0;
+      int cache1Ndx;       
+      for(cache1Ndx=0; cache1Ndx<cache1Size; cache1Ndx++){
+        for(int tryp=10; tryp<BYTES-8; tryp++){
+          for(int pos=0;; pos++){
+            if(pos+tryp>=BYTES-8) break;
+            if(cache1[cache1Ndx].chan[pos] == 0) {
+              if(pos>bestLen){
+                bestLen=pos;
+                best=cache1Ndx;
+              }
+              break;
+            }
+            if(   toupper(cache1[cache1Ndx].chan[pos]) != toupper(data[tryp+pos])
+               && cache1[cache1Ndx].chan[pos] != 0x20
+               && cache1[cache1Ndx].chan[pos] != 0x0D) break;
+          }
+        }
+      }
+
+      if(bestLen==0){
+        printf(" ERR Unknown Stuff: %32s\n", &data[10]);
+        mag[magAddr]=NULL;
+        continue;
+      }
+      cache1Ndx=best;
+             
+      if(cache1[cache1Ndx].pt==NULL){
+        cache1[cache1Ndx].pt= new CACHE2*[0x800];
+        for(int i=0; i<0x800; i++) cache1[cache1Ndx].pt[i]=NULL;
+      }
+
+      if(cache1[cache1Ndx].pt[page]==NULL){
+        cache1[cache1Ndx].pt[page]= new CACHE2;
+        cache1[cache1Ndx].pt[page]->next=NULL;
+        cache1[cache1Ndx].pt[page]->seen=false;
+        memset(cache1[cache1Ndx].pt[page]->text, ' ', 40*LINES);
+        mag[magAddr]= cache1[cache1Ndx].pt[page];
+      }
+      else{
+        CACHE2 *p=cache1[cache1Ndx].pt[page];
+        while(p->next!=NULL && p->next->sub<=subPage) p=p->next;
+
+        if(p->sub==subPage) mag[magAddr]= p;        
+        else{
+          CACHE2 *temp= new CACHE2;
+          memset(temp->text, ' ', 40*LINES);
+
+          if(p->sub<subPage){
+            temp->next= p->next;
+            p->next= temp;
+          }
+          else{
+            temp->next= cache1[cache1Ndx].pt[page];
+            cache1[cache1Ndx].pt[page]= temp;
+          }
+
+          temp->seen=false;
+          mag[magAddr]= temp;
+        }
+      }
+
+      mag[magAddr]->sub=subPage;
+      memcpy(&mag[magAddr]->text[rowAddr*40], data+10, 32);
+
+    }
+    else if(rowAddr<LINES){
+      if(mag[magAddr]==NULL) continue;
+
+      for(int i=2; i<BYTES; i++){
+        data[i]= fixParity[ data[i] ];
+      }
+      memcpy(&mag[magAddr]->text[rowAddr*40], data+2, 40);
+
+    }
+
+
+  }
+
+
+  memset(actVid2MemBufp->b, 0, vgax*vgay<<mc);
+
+  if(iState || helpState) return;
+
+  static int lastReqPage=-1, lastReqSubPage=-1, lastReqChanNum=-1;
+
+    // FIX reqChanStr
+    // FIX add noAutoSeek
+
+  const int seekChanDelta=    (reqChanNum < lastReqChanNum) ? -1 : 1;
+  const int seekPageDelta=    (reqPage    < lastReqPage   ) ? -1 : 1;
+  const int seekSubPageDelta= (reqSubPage < lastReqSubPage) ? -1 : 1;
+
+  reqPage&=0x7FF;
+  if(reqSubPage<0) reqSubPage=0;
+  if(reqChanNum<0) reqChanNum=0;
+  if(reqChanNum>=cache1Size) reqChanNum=cache1Size-1;
+
+  int start=reqChanNum;
+  do{
+    if(cache1[reqChanNum].pt!=NULL) break;
+    reqChanNum+= seekChanDelta;
+    if(reqChanNum<0          ) reqChanNum= cache1Size-1;
+    if(reqChanNum>=cache1Size) reqChanNum= 0;
+  }while(start!=reqChanNum);
+
+  if(cache1[reqChanNum].pt==NULL) return;
+
+  start=reqPage;
+  do{
+    if(cache1[reqChanNum].pt[reqPage]!=NULL) break;
+    reqPage+= seekPageDelta;
+    reqPage&= 0x7FF;
+  }while(start!=reqPage);
+
+  if(cache1[reqChanNum].pt[reqPage]==NULL) return;
+
+  CACHE2 *p=cache1[reqChanNum].pt[reqPage];
+  CACHE2 *largep=p, *smallp=p;
+
+  while(p!=NULL){
+    if(p->sub==reqSubPage) break;
+    largep=p;
+    p=p->next;
+  }
+
+  if(p==NULL || p->sub!=reqSubPage){
+    if(largep->sub<reqSubPage) largep=smallp;
+    if(smallp->sub>reqSubPage) smallp=largep;
+    if(seekSubPageDelta>0) p=largep;
+    else                   p=smallp;
+  }
+
+  reqSubPage=p->sub;
+
+  for(int i=0; i<LINES; i++){
+//    int colorNdx=
+
+    sprintf(textbuf[0],"%40s", &p->text[i*40]);
+    c.init(255, 0, 0, yuvmode);
+    gprint(10, infoPosY+=10,  c.col, textbuf[0]);
+
+  }
+//  printf("bad ham's %d\n", hammErr);
+
+
+  lastReqPage=   reqPage;
+  lastReqSubPage=reqSubPage;
+  lastReqChanNum=reqChanNum;
+
+  infoPosY+=5;
+
+}
+
+
+

Added: trunk/2010/2_txt.h
==============================================================================
--- (empty file)
+++ trunk/2010/2_txt.h	Wed Jul  4 09:50:51 2007
@@ -0,0 +1,21 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+#ifndef n2_txt_h
+#define n2_txt_h
+
+#define LINES 25
+
+struct CACHE2{
+  int sub;
+  bool seen;
+  char text[LINES*40];
+  CACHE2 *next;
+};
+
+struct CACHE1{
+  char chan[12];
+  CACHE2 **pt;
+};
+
+void txt_decrypt(void);
+
+#endif

Modified: trunk/2010/2_vc.cc
==============================================================================
--- trunk/2010/2_vc.cc	(original)
+++ trunk/2010/2_vc.cc	Wed Jul  4 09:50:51 2007
@@ -14,9 +14,6 @@
 #include "2010.h"
                       
 #define FREQ_SMP       2.1e7
-#define FREQ_CHROM     4433618.75
-#define FREQ_HS        15625.0
-#define FREQ_PIX       (FREQ_HS * 1888.0 * 0.5)
 #define POINT_LAND     765.0
 #define NO_POINT_LAND1 145.0              // GUESSED! 
 #define NO_POINT_LAND2 145.0              // GUESSED! 

Modified: trunk/2010/makefile
==============================================================================
--- trunk/2010/makefile	(original)
+++ trunk/2010/makefile	Wed Jul  4 09:50:51 2007
@@ -14,7 +14,7 @@ AFLAGS = -f coff
 
 O = 2010.o 2_file.o 2_grafix.o 2_hw.o 2_gfunc.o \
     2_hw_asm.o 2_71x6.o 2_hw_mem.o 2_crypt.o 2_vc.o 2_nag.o\
-    2_nag_a.o 2_vc_a.o 2_glob_a.o
+    2_nag_a.o 2_vc_a.o 2_glob_a.o 2_txt.o
 
 2010 : $(O) ; gcc $(CFLAGS) -o 2010 $(O)
 clean: ; del $(O) 2010
@@ -28,10 +28,11 @@ clean: ; del $(O) 2010
                              2_71x6.h 2_mmx.h
 2_hw_mem.o : 2_hw_mem.cc 2_all.h 2_hw_mem.h 2010.h 
 2_71x6.o   : 2_71x6.cc   2_all.h 2_71x6.h 2_hw.h 2_hw_mem.h 2010.h 2_hw_asm.h
-2_crypt.o  : 2_crypt.cc  2_all.h 2_crypt.h 2_71x6.h 2_vc.h 2_nag.h
+2_crypt.o  : 2_crypt.cc  2_all.h 2_crypt.h 2_71x6.h 2_vc.h 2_nag.h 2_txt.h
 2_vc.o     : 2_vc.cc     2_all.h 2_vc.h 2_crypt.h 2_gfunc.h 2_vc_a.h
 2_nag.o    : 2_nag.cc    2_all.h 2_nag.h 2_crypt.h 2_gfunc.h 2_mmx.h 2_nag_a.h\
                              2010.h 2_hw_mem.h
+2_txt.o    : 2_txt.cc    2_all.h 2_txt.h 2_crypt.h 2_gfunc.h 2010.h
 
 2_hw_asm.o : 2_hw_asm.s
 



More information about the Mndiff-dev mailing list