[MN-dev] [mndiff]: r43 - in trunk/2010: . 2010.cc 2010.h 2_7116.h 2_71x6.cc 2_71x6.h 2_all.h 2_all_a.asm 2_crypt.cc 2_crypt.h 2_file.cc 2_file.h 2_gfunc.cc 2_gfunc.h 2_glob_a.asm 2_grafix.cc 2_grafix.h 2_hw.cc 2_hw.h 2_hw_asm.h 2_hw_mem.cc 2_hw_mem.h 2_menu.cc 2_menu.h 2_mfunc.cc 2_mfunc.h 2_mmx.h 2_mouse.cc 2_mouse.h 2_move.cc 2_move.h 2_nag.cc 2_nag.h 2_nag_a.asm 2_nag_a.h 2_vc.cc 2_vc.h 2_vc_a.asm 2_vc_a.h 2_wins.cc 2_wins.h 2do makefile

michael subversion at mplayerhq.hu
Wed Jul 4 03:08:39 CEST 2007


Author: michael
Date: Wed Jul  4 03:08:39 2007
New Revision: 43

Log:
some old code from february 1998 or earlier


Added:
   trunk/2010/
   trunk/2010/2010.cc
   trunk/2010/2010.h
   trunk/2010/2_7116.h
   trunk/2010/2_71x6.cc
   trunk/2010/2_71x6.h
   trunk/2010/2_all.h
   trunk/2010/2_all_a.asm
   trunk/2010/2_crypt.cc
   trunk/2010/2_crypt.h
   trunk/2010/2_file.cc
   trunk/2010/2_file.h
   trunk/2010/2_gfunc.cc
   trunk/2010/2_gfunc.h
   trunk/2010/2_glob_a.asm
   trunk/2010/2_grafix.cc
   trunk/2010/2_grafix.h
   trunk/2010/2_hw.cc
   trunk/2010/2_hw.h
   trunk/2010/2_hw_asm.h
   trunk/2010/2_hw_mem.cc
   trunk/2010/2_hw_mem.h
   trunk/2010/2_menu.cc
   trunk/2010/2_menu.h
   trunk/2010/2_mfunc.cc
   trunk/2010/2_mfunc.h
   trunk/2010/2_mmx.h
   trunk/2010/2_mouse.cc
   trunk/2010/2_mouse.h
   trunk/2010/2_move.cc
   trunk/2010/2_move.h
   trunk/2010/2_nag.cc
   trunk/2010/2_nag.h
   trunk/2010/2_nag_a.asm
   trunk/2010/2_nag_a.h
   trunk/2010/2_vc.cc
   trunk/2010/2_vc.h
   trunk/2010/2_vc_a.asm
   trunk/2010/2_vc_a.h
   trunk/2010/2_wins.cc
   trunk/2010/2_wins.h
   trunk/2010/2do
   trunk/2010/makefile

Added: trunk/2010/2010.cc
==============================================================================
--- (empty file)
+++ trunk/2010/2010.cc	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,325 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+
+#include <stdlib.h>
+#include <pc.h>
+#include <stdio.h>
+#include <dpmi.h>
+#include <string.h>
+#include <sys/nearptr.h>
+#include <unistd.h>
+#include <conio.h>
+#include <crt0.h>
+#include <signal.h>
+#include "2_all.h"
+#include "2010.h"
+#include "2_hw.h"
+#include "2_hw_mem.h"
+#include "2_mouse.h"
+#include "2_file.h"
+#include "2_menu.h"
+#include "2_grafix.h"
+#include "2_71x6.h"
+
+ extern mouse_sprites cursor;
+ extern int g_mode;
+ extern xxx dispbuf, grab_dispbuf;
+ extern byte *vidbuf;
+ extern int mouse_x, mouse_y, mouse_b;
+ extern volatile int page_flip;
+ extern int xres, yres, xresvb, xresc, vb, mc;
+ extern int active_meteor;
+ extern int me, mx, my;
+ extern int yuvmode;
+ extern byte *mouse_buff[2];
+ extern int single;
+ extern int grabf;
+ extern int mmx;
+
+int _crt0_startup_flags = _CRT0_FLAG_NEARPTR | _CRT0_FLAG_NONMOVE_SBRK;
+ int buttons=0, xpos=0, ypos=0, lxpos=0, lypos=0;
+ int fysize;
+ byte font[4096];
+ int NoInt8=0;
+ int vid=0;
+ int bpp;
+ char *yuv2rgb_lut;
+ int edge_lut[256];
+
+void printg_t(char *text){
+ close_hw();
+ printf(text);
+}
+
+int error(error_code e){
+// asm("int $3\n\t");
+ switch(e){
+  case Lock        : printg_t("\nError (Un)Locking Linear Region!\n");
+                     break;
+  case NoVDS       : printg_t("\nVDS Not Detected!\n");
+                     break;
+  case VDS         : printg_t("\nVDS Error!\n");
+                     break;
+  case NoVESA      : printg_t("\nVESA Not Detected!\n");
+                     break;
+  case FileRead    : printg_t("\nFile-Read Error!\n");
+                     break;
+  case Map         : printg_t("\nCannot Map Physical Address!\n");
+                     break;
+  case VESA        : printg_t("\nError initalizing VESA Mode!\n");
+                     break;
+  case VESAFlip    : printg_t("\nPage Fliping Error!\n");
+                     break;
+  case VESAVer     : printg_t("\nError 2010 needs at least VESA 2.0!\n");
+                     break;
+  case NoMeteor    : printg_t("\nMeteor Not Detected!\n");
+                     break;
+  case DPMI        : printg_t("\nDPMI Error!\n");
+                     break;
+  case NoMouse     : printg_t("\nNo Mouse?!\n");
+                     break;
+  case MouseHand   : printg_t("\nMouse Handler error!\n");
+                     break;
+  case NoFont      : printg_t("\nNo 2010.Fnt?!\n");
+                     break;
+  case Font        : printg_t("\n2010.Fnt is damaged!\n");
+                     break;
+  case NoCursor    : printg_t("\nNo 2010.Cur?!\n");
+                     break;
+  case Cursor      : printg_t("\n2010.Cur is damaged!\n");
+                     break;
+  case FileWrite   : printg_t("\nFile-Write Error!\n");
+                     break;
+  case MemAlloc    : printg_t("\nMemory allocation error!\n");
+                     break;
+  case SAA7196     : printg_t("\nPhilips SAA7196 error!\n");
+                     break;
+  case CommLine    : printg_t("\nCommand-Line error!\n");
+  case Help        : printg_t("\n2010 [<optons>]\n"
+                            "options: -v n (Video-mode)\n"
+                            "         -m n (Meteor Card) in case there are more than 1 (:\n"
+                            "         -NoFlip (Disable Page-Fliping)\n"
+                            "         -NoInt8 (Disable Int8-Handler)\n"
+                            "         -NoMMX  (Disable MMX-Support)\n"
+                            "         -? / -h (This stuff)\n");
+                     break;
+  default          : printg_t("\nUnknown error!");
+                     break;
+ }
+
+ exit(e);
+}
+
+void exitt(void){
+ close_hw();
+}
+
+int main(int argc, char **argv){
+ int NoFlip=0;
+ int key;
+ int i, j;
+ char buf[256];
+ __dpmi_regs r;
+ ModeInfoBlock *mib;
+ VesaInfoBlock *vib;
+ FILE *f;
+ int mc2;
+
+ printf("2010 0.10 Copyright (C) Michael Niedermayer 1998\n");
+
+ atexit(exitt);
+
+ signal(SIGABRT, sig_handler);
+ signal(SIGFPE , sig_handler);
+ signal(SIGILL , sig_handler);
+ signal(SIGINT , sig_handler);
+ signal(SIGSEGV, sig_handler);
+ signal(SIGTRAP, sig_handler);
+
+ for(i=1;i<argc;i++){
+  if(stricmp(argv[i],"-v")==0){
+   i++;
+   sscanf(argv[i],"%d",&vid);
+  }
+  else if(stricmp(argv[i],"-m")==0){
+   i++;
+   sscanf(argv[i],"%d",&active_meteor);
+  }
+  else if(stricmp(argv[i],"-NoFlip")==0){
+   NoFlip=1;
+  }
+  else if(stricmp(argv[i],"-NORGB")==0){
+   yuvmode=2;
+  }
+  else if(stricmp(argv[i],"-Single")==0){
+   single=1;
+  }
+  else if(stricmp(argv[i],"-NoInt8")==0){
+   NoInt8=1;
+  }
+  else if(stricmp(argv[i],"-NoMMX")==0){
+   mmx=0;
+  }
+  else if(stricmp(argv[i],"-?")==0 || stricmp(argv[i],"-H")==0){
+   error(Help);
+  }
+/*  else if(stricmp(argv[i],"-v")==0){
+   i++;
+   if(stricmp(argv[i],"vid")==0) std=vid;
+   else if(stricmp(argv[i],"nagra")==0) std=nagra;
+   else error(CommLine);
+  } */
+  else error(CommLine);
+ }
+
+ if(check_mmx()==0) mmx=0;
+ else{
+  printf("MMX Detected!\n");
+  if(mmx==0) printf(" but not used because -NoMMX\n");
+ }
+
+ printf("2010.Fnt...\n");
+ if((f=fopen("2010.fnt", "rb"))==NULL) error(NoFont);
+ fysize=fsize(f)>>8;
+ if(fysize==0) error(Font);
+ for(i=0; i<256; i++) fread(font+(i<<4),1,fysize,f);
+ fclose(f);
+ 
+ printf("2010.Cur...\n");
+ if((f=fopen("2010.cur", "rb"))==NULL) error(NoCursor);
+ cursor.x=fgetc(f);
+ cursor.y=fgetc(f);
+ cursor.hotx=fgetc(f);
+ cursor.hoty=fgetc(f);
+ cursor.z=fgetc(f);            //ERROR could be readed in struct direct
+ if(cursor.x*cursor.y*cursor.z!=fsize(f)-5) error(Cursor);
+ cursor.data=new byte[cursor.x*cursor.y*cursor.z];
+ fread(cursor.data, 1, cursor.x*cursor.y*cursor.z, f);
+ fclose(f);
+
+ mouse_buff[0]=new byte[cursor.x * cursor.y << 2];
+ mouse_buff[1]=new byte[cursor.x * cursor.y << 2];
+  
+ i=scan_pci_meteors();
+ if(i==0) error(NoMeteor);
+ if(active_meteor>=i) active_meteor=0;
+ printf("%d Meteor(s) Detected!\n", i);
+
+ for(i=0; i<256; i++){
+   j=i-2;
+   if(j<0) j=0;
+
+        if(j>5 ) j=(j>>1) + 3;
+   else if(j>10) j=(j>>2) + 7;
+   else if(j>20) j=13;
+
+   edge_lut[i]=j;
+ }
+
+ printf("Building YUV to RGB LookUp Tables!\n");
+ yuv2rgb_lut=new char[256*4*2];
+ for(i=0; i<256; i++){
+   if(i>=128) j=i-256;
+   else j=i;
+   double d= double(j);
+
+   yuv2rgb_lut[(i<<2)       ]= short( d * ( 1.734375) * 0.5 );
+   yuv2rgb_lut[(i<<2) + 1   ]= short( d * (-0.34375 ) * 0.5 )
+                             + is_pos(yuv2rgb_lut[(i<<2)       ]);
+   yuv2rgb_lut[(i<<2) + 2   ]= is_pos(yuv2rgb_lut[(i<<2) + 1   ]);
+   yuv2rgb_lut[(i<<2) + 3   ]= 0;
+
+   yuv2rgb_lut[(i<<2) + 1024]= 0;
+   yuv2rgb_lut[(i<<2) + 1025]= short( d * (-0.703125) * 0.5  );
+   yuv2rgb_lut[(i<<2) + 1026]= short( d * ( 1.375   ) * 0.5  )
+                             + is_pos(yuv2rgb_lut[(i<<2) + 1025]);
+   yuv2rgb_lut[(i<<2) + 1027]= 0;
+ }
+
+ if((vib=get_vesa_info())==0) error(NoVESA);
+ if(vib->ver < 0x200) error(VESAVer);
+ if(vid==0){
+  printf("VESA %d.%d detected!\n", (vib->ver>>8) & 255, vib->ver & 255);
+ 
+
+  for(i=256;i<512;i++){
+   if((mib=get_mode_info(i))!=0){
+    if((mib->ModeAttrib & (8+16+128))==8+16+128 && (mib->bpp==24 || mib->bpp==32)
+                      && mib->model==6 && (mib->Xres & 0x3F8) == mib->Xres
+                                       && (mib->Yres & 0x3FF) == mib->Yres){
+                                       // FIX ME 3FF statt 3F8 OK?
+     printf("%d = %dx%dx%d",i,mib->Xres,
+                              mib->Yres,
+                              mib->bpp);
+     if(mib->pages==0 || NoFlip==1) printf(" No Page Flipping!");
+     printf("\n");
+    }
+   }
+  }
+  printf("Input Video-Mode Num:\n");
+  buf[0]=255;
+  sscanf((char*)cgets(buf),"%d",&vid);
+  printf("\n");
+ }
+ 
+
+ if((mib=get_mode_info(vid))==0) error(VESA);
+ if(!((mib->ModeAttrib & (8+16+128))==8+16+128 && (mib->bpp==24 || mib->bpp==32)
+                      && mib->model==6 && (mib->Xres & 0x3F8) == mib->Xres
+                                       && (mib->Yres & 0x3FE) == mib->Yres))
+                                                    error(VESA);
+
+
+ xres=mib->Xres;
+ yres=mib->Yres;
+ if(yuvmode!=0) mc=1;
+ else mc=2;
+ if(yuvmode==2) mc2=1;
+ else mc2=2;
+ xresc=xres<<mc;
+ bpp=mib->bpp;
+ vb=bpp>>3;
+ xresvb=xres*vb;
+ if(mib->pages>0 && NoFlip==0) page_flip=1;
+ else page_flip=0;
+
+ printf("Allocating Physical Continous Buffers...\n");
+
+               dispbuf     =alloc_cont(xres * yres << mc2);
+ if(single==0) grab_dispbuf=alloc_cont(xres * yres << mc2);
+ else grab_dispbuf=dispbuf;
+
+ if(page_flip==0) i= xres * yres * vb;
+ else             i= xres * yres * vb << 1;
+
+ vidbuf=(byte*)( map(mib->PhysBase, mib->PhysBase+i) - __djgpp_base_address);
+  
+ r.x.ax=0x4F02;
+ r.x.bx=vid | 16384;
+ __dpmi_int(0x10,&r);
+ if(r.x.ax!=0x4F) error(VESA);
+ g_mode=1;
+  
+ setmenu();
+ init_hw();
+ init_meteor();
+ setmpos();
+
+ key=0;
+ while(key==0){
+  draw_dispbuf();
+ 
+  xpos=mouse_x;
+  ypos=mouse_y;
+  buttons=mouse_b;
+ 
+  m_buttons();
+ 
+  lxpos=xpos;
+  lypos=ypos;
+
+  if(kbhit()) key=getkey();
+  if(key=='g' || key=='G') key=0, grabf=1;
+ }
+ 
+ exit(0);
+}

Added: trunk/2010/2010.h
==============================================================================
--- (empty file)
+++ trunk/2010/2010.h	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,36 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+
+#ifndef n2010_h
+#define n2010_h
+
+typedef enum{
+ CommLine,
+ Help,
+ NoVDS,
+ VDS,
+ NoVESA,
+ VESA,
+ VESAFlip,
+ VESAVer,
+ NoMeteor,
+ DPMI,
+ FileRead,
+ FileWrite,
+ Map,
+ NoMouse,
+ MouseHand,
+ NoFont,
+ Font,
+ NoCursor,
+ Cursor,
+ MemAlloc,
+ FileMax,
+ Lock,
+ SAA7196,
+} error_code;
+
+int error(error_code e);
+void exitt(void);
+void find_dup(int num);
+
+#endif

Added: trunk/2010/2_7116.h
==============================================================================
--- (empty file)
+++ trunk/2010/2_7116.h	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,95 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1997
+#ifndef n2_7116
+#define n2_7116
+
+#define SAA7116_vendev 0x12238086
+
+/*
+ pci_cmd;   //04-05
+ pci_sts;   //06-07
+ rev;       //08
+ classc1;   //09
+ classc2;   //0A-0B
+ res0C;     //0C
+ mlt;       //0D
+ headt;     //0E
+ bist;      //0F
+*/
+
+struct meteor{
+ byte  bus;
+ byte  dev;
+ byte  irq;
+ dword base;
+};
+
+struct eo {
+  u_long even;
+  u_long odd;
+};
+
+struct eo3 {
+  u_long even[3];
+  u_long odd[3];
+};
+
+struct eo4 {
+  u_long even[4];
+  u_long odd[4];
+};
+
+struct rt_mode {
+  unsigned mode:8;		/* 0:7  Pixel format for even fields */
+  unsigned route:24;		/* 8:31 Pixel router mode for even fields */
+};
+
+struct ff_trig {
+  unsigned packed:7;		/* 0:7(0:6) Fifo trigger Packed Mode */
+  unsigned :9;			/* 8:15(7:15) Unused */
+  unsigned planar:7;		/* 16:31(16:22) Fifo trigger Planar Mode */
+  unsigned :9;			/* 23:31 Unused */
+};
+
+struct i2c_stat {
+  unsigned :9;			/* 0:8 Not needed */
+  unsigned d_abort:1;		/* 9:9 Status of i2c write: 0==success */
+  unsigned :14;			/* 10:23 Not needed */
+  unsigned r_data:8;		/* 24:31 Data returned by i2c read */
+};
+
+struct i2c_cmd {
+  unsigned w_data:8;		/* 0:7 Data to be written out */
+  unsigned reg_addr:8;		/* 8:15 Register address in device space */
+  unsigned dev_addr:8;		/* 16:23 16: 0==write; 17:23: Device address */
+  unsigned xfer:1;		/* 24: Set to start write. Clears when done */
+  unsigned :7;			/* 25:31 Unused */
+};
+
+#define v_struct volatile struct
+
+				/* (pointer-addition-values)hex-offset(s) */
+struct saa7116 {
+  struct eo3 dma;               /* ( 0-5 )00-14: Base address, e/o fields */
+  struct eo3 stride;            /* ( 6-11)18-2c: Address stride, e/o fields */
+  struct rt_mode rt_mode_e;	/* (12)30: Route and Mode for even fields */
+  struct rt_mode rt_mode_o;	/* (13)34: Route and Mode for odd fields */
+  struct ff_trig fifo_trigger;	/* (14)38 Fifo triggers: Planar and Packed */
+  u_long field_toggle;		/* (15)3c */
+  volatile u_long capt_ctl;	/* (16)40: Capture control, etc. */
+  u_long retry_wait;		/* (17)44 */
+  volatile u_long ints_ctl;	/* (18)48: Interrupt control and status */
+  struct eo field_mask;         /* (19-20)4c-50 */
+  u_long mask_lengths;		/* (21)54 */
+  u_long fifo_limits;		/* (22)58 */
+  u_long i2c_clocks;		/* (23)5c */
+  v_struct i2c_stat i2c_stat;	/* (24)60 i2c mode control and status */
+  v_struct i2c_cmd i2c_cmd;	/* (25)64 Direct mode command and data */
+  struct eo4 i2c_auto;          /* (26-33)68-84*/
+  u_long i2c_regs_enable;	/* (34)88 */
+  struct eo dma_end;            /* (35-36)8c-90 */
+};
+
+
+int scan_pci_meteors(void);
+
+#endif

Added: trunk/2010/2_71x6.cc
==============================================================================
--- (empty file)
+++ trunk/2010/2_71x6.cc	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,618 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+#include <stdio.h>
+#include <string.h>
+#include <sys/nearptr.h>
+#include <go32.h>
+#include <dpmi.h>
+#include <time.h>
+#include <pc.h>
+#include "2_all.h"
+#include "2_71x6.h"
+#include "2_hw.h"
+#include "2_hw_mem.h"
+#include "2_hw_asm.h"
+#include "2010.h"       
+                 
+//#define wait_time 0.002
+//#define wait_time 0.010
+#define wait_time 0.020
+
+extern meteor meteors[8];
+extern __Go32_Info_Block _go32_info_block;
+extern u_short my_cs;
+extern u_short my_ds;
+extern dword old_intmet_vect_offset;
+extern  word old_intmet_vect_selector;
+extern  byte meteor_handler;
+extern volatile grstate grab_state;
+extern volatile int metmode;
+extern volatile int active_meteor;
+extern int latency;
+extern volatile int addr_errors;
+extern volatile int corr_errors;
+extern volatile int frames, fields;
+extern volatile u_char saa7196_buf[SAA7196_regs];
+extern volatile tv_form std;
+extern volatile crypt_form crypt;
+extern volatile int x_field, y_field, one_field;
+extern volatile int xresc, yuvmode, mc;
+extern volatile xxx dispbuf, grab_dispbuf;
+extern volatile int stride;
+extern int xress, yress, yrest, yresst;
+extern int single;
+extern int init_menu;
+extern int nagra_mode;
+
+extern int xres, yres;
+
+int v_smooth=1;
+
+int bright=0x80, satur=0x40, contr=0x40;
+int scales_x=0x03, scales_y=0x10;
+int scalee_x=0x00, scalee_y=0x00;
+
+int bypass_y=0x0, bypasc_y=0x0;
+
+static inline int write_i2c(u_char dev, u_char reg, u_char data);
+static inline void wait(double);
+static inline void reset_7116(void);
+
+
+int scan_pci_meteors(void){
+ int i, dev, bus;
+ u_long u;
+
+ memset(meteors, -1, sizeof(meteor)*8);
+
+ i=0;
+ for(bus=0; bus<32; bus++){
+   for(dev=0; dev<32; dev++){
+     if(read_pci(bus, dev, 0, PCI_IO_vendev, 4)==SAA7116_vendev){
+       meteors[i].bus=bus;
+       meteors[i].dev=dev;
+       meteors[i].irq=read_pci(bus, dev, 0, PCI_IO_irq, 1);
+       if(meteors[i].irq<8) meteors[i].intt=meteors[i].irq
+           +_go32_info_block.master_interrupt_controller_base;
+       else                 meteors[i].intt=meteors[i].irq
+           +_go32_info_block.slave_interrupt_controller_base-8;
+
+
+       u=read_pci(bus, dev, 0, PCI_IO_command, 2);
+       u|= PCI_command_master | PCI_command_memory;
+       write_pci(bus, dev, 0, PCI_IO_command, 2, u);
+       write_pci(bus, dev, 0, PCI_IO_latency, 1, latency);
+
+       u=read_pci(bus, dev, 0, PCI_IO_base, 4) & (~0xFF);     //fix me 4kb boundray
+       meteors[i].saa7116=(saa7116*)(map(u, u+sizeof(saa7116)) - __djgpp_base_address);
+
+       printf("IRQ: %X INT: %X BUS: %X DEV: %X MemMap: %X\n",meteors[i].irq, meteors[i].intt, bus, dev, int(u));
+//       printf("%X %X\n",_go32_info_block.master_interrupt_controller_base, _go32_info_block.slave_interrupt_controller_base);
+       i++;
+     }
+   }
+ }
+ return i;
+}
+
+static inline void reset_7116(void){
+
+ wait(wait_time);
+
+ meteors[active_meteor].saa7116->ints_ctl=(ints_c){
+       stat_even: 1, stat_odd: 1, stat_start: 1, res1: 0,
+       mask_even: 0, mask_odd: 0, mask_start: 0, res2: 0};
+
+ meteors[active_meteor].saa7116->capt_ctl=(capt_c){
+       cont_even: 0, cont_odd: 0, sing_even: 0, sing_odd: 0,
+       done_even: 0, done_odd: 0, VRSTN:     0, fifo_en:  0,
+       corr_even: 0, corr_odd: 0, aerr_even: 0, aerr_odd: 0,
+       res1:      0, corr_dis: 0, range_en:  0, res2:     0};
+
+ wait(0.02);
+
+ meteors[active_meteor].saa7116->capt_ctl=(capt_c){
+       cont_even: 0, cont_odd: 0, sing_even: 0, sing_odd: 0,
+       done_even: 1, done_odd: 1, VRSTN:     1, fifo_en:  1,
+       corr_even: 1, corr_odd: 1, aerr_even: 1, aerr_odd: 1,
+       res1:      0, corr_dis: 0, range_en:  1, res2:     0};
+ meteors[active_meteor].saa7116->capt_ctl=(capt_c){
+       cont_even: 0, cont_odd: 0, sing_even: 0, sing_odd: 0,
+       done_even: 0, done_odd: 0, VRSTN:     1, fifo_en:  1,
+       corr_even: 0, corr_odd: 0, aerr_even: 0, aerr_odd: 0,
+       res1:      0, corr_dis: 0, range_en:  1, res2:     0};
+ meteors[active_meteor].saa7116->capt_ctl=(capt_c){
+       cont_even: 0, cont_odd: 0, sing_even: 0, sing_odd: 0,
+       done_even: 0, done_odd: 0, VRSTN:     1, fifo_en:  0,
+       corr_even: 0, corr_odd: 0, aerr_even: 0, aerr_odd: 0,
+       res1:      0, corr_dis: 0, range_en:  1, res2:     0};
+
+ wait(0.1);
+
+ meteors[active_meteor].saa7116->capt_ctl=(capt_c){
+       cont_even: 0, cont_odd: 0, sing_even: 0, sing_odd: 0,
+       done_even: 0, done_odd: 0, VRSTN:     1, fifo_en:  1,
+       corr_even: 0, corr_odd: 0, aerr_even: 0, aerr_odd: 0,
+       res1:      0, corr_dis: 0, range_en:  1, res2:     0};
+
+ wait(0.05);
+
+// memset((void*)meteors[active_meteor].saa7116, 0, sizeof(saa7116));
+}
+
+static inline int write_i2c(u_char dev, u_char reg, u_char data){
+
+ meteors[active_meteor].saa7116->i2c_cmd=
+    (i2c_cmd){w_data: data, reg_addr: reg, dev_addr: dev, xfer: 1};
+// printf("%X %X %X / %X %X %X\n", dev, reg, data,
+//                   meteors[active_meteor].saa7116->i2c_cmd.dev_addr,
+//                   meteors[active_meteor].saa7116->i2c_cmd.reg_addr,
+//                   meteors[active_meteor].saa7116->i2c_cmd.w_data);
+ int count=0x1FFFF;
+ while(count > 0 && meteors[active_meteor].saa7116->i2c_cmd.xfer==1) count--;
+
+ if(meteors[active_meteor].saa7116->i2c_stat.d_abort==1){
+   meteors[active_meteor].saa7116->i2c_stat.d_abort=1;
+   return -1;
+ }
+
+ if(count == 0) return -1;
+
+ return 0;
+}
+
+void write_saa7196(u_char reg, u_char data){
+
+ saa7196_buf[reg]=data;
+ if(write_i2c(SAA7196_I2C_W, reg, data)==-1) error(SAA7196);
+}
+
+u_char read_saa7196(u_char reg){
+
+ if(write_i2c(SAA7196_I2C_W, reg, saa7196_buf[reg])==-1) error(SAA7196);
+ if(write_i2c(SAA7196_I2C_R, 0, 0)==-1) error(SAA7196);
+ return meteors[active_meteor].saa7116->i2c_stat.r_data;
+}
+
+static inline void wait(double wt){
+ long u;
+ wt*=UCLOCKS_PER_SEC;
+
+ u=uclock();
+
+ while(uclock() <= u+wt);
+}
+
+void meteor_int_handler(void){
+
+ saa7116 *a_saa7116=(saa7116*)meteors[active_meteor].saa7116;
+ int cap=a_saa7116->capt_ctl_a;
+
+ if(a_saa7116->ints_ctl.stat_even  == 0 &
+    a_saa7116->ints_ctl.stat_odd   == 0 &
+    a_saa7116->ints_ctl.stat_start == 0 ) asm("int $3\n\t"); // VERY BAD (?? WHO called that int)
+
+ if((cap & 0x300) != 0){
+   corr_errors++;
+ }
+ if((cap & 0xC00) != 0){   
+   addr_errors++;
+ }
+
+ if(a_saa7116->ints_ctl.stat_even != 1 || a_saa7116->ints_ctl.stat_odd != 1){
+   frames++;
+   fields++;
+ }
+
+ a_saa7116->capt_ctl_a|=0x0F30;
+ if( (    (one_field==0 && nagra_mode==0)
+       || a_saa7116->ints_ctl.stat_even == 0) && fields>=2){
+   fields=0;
+
+   if(grab_state==Waiting){
+     if(single==1){
+       a_saa7116->capt_ctl=(capt_c){
+           cont_even: 0, cont_odd: 0, sing_even: 0, sing_odd: 0,
+           done_even: 1, done_odd: 1, VRSTN:     1, fifo_en:  1,
+           corr_even: 1, corr_odd: 1, aerr_even: 1, aerr_odd: 1,
+           res1:      0, corr_dis: 0, range_en:  1, res2:     0};
+     }
+     else{
+       volatile xxx temp=dispbuf;
+       dispbuf=grab_dispbuf;
+       grab_dispbuf=temp;
+
+       grab_next();
+     }
+     grab_state=NotReady;
+   }else{
+     if(single==0){
+       a_saa7116->capt_ctl=(capt_c){
+           cont_even: 0, cont_odd: 0, sing_even: 0, sing_odd: 0,
+           done_even: 1, done_odd: 1, VRSTN:     1, fifo_en:  1,
+           corr_even: 1, corr_odd: 1, aerr_even: 1, aerr_odd: 1,
+           res1:      0, corr_dis: 0, range_en:  1, res2:     0};
+       grab_state=Skiped;
+     }
+   }
+ }
+ a_saa7116->ints_ctl_a|=0x7;
+}
+
+void close_meteor(void){
+ __dpmi_paddr address;
+
+ meteors[active_meteor].saa7116->ints_ctl=(ints_c){
+       stat_even: 1, stat_odd: 1, stat_start: 1, res1: 0,
+       mask_even: 0, mask_odd: 0, mask_start: 0, res2: 0};
+ meteors[active_meteor].saa7116->capt_ctl=(capt_c){
+       cont_even: 0, cont_odd: 0, sing_even: 0, sing_odd: 0,
+       done_even: 0, done_odd: 0, VRSTN:     0, fifo_en:  0,
+       corr_even: 0, corr_odd: 0, aerr_even: 0, aerr_odd: 0,
+       res1:      0, corr_dis: 0, range_en:  0, res2:     0};
+ memset((void*)meteors[active_meteor].saa7116, 0, sizeof(saa7116));
+
+ if(metmode==0) return;
+
+   /* mask meteor's IRQ */
+ asm("cli\n\t");
+ if(meteors[active_meteor].irq<8)
+      outportb(0x21, inportb(0x21) | (1 <<  meteors[active_meteor].irq     ));
+ else outportb(0xA1, inportb(0xA1) | (1 << (meteors[active_meteor].irq - 8)));
+ asm("sti\n\t");
+
+ address.offset32=old_intmet_vect_offset;
+ address.selector=old_intmet_vect_selector;
+ __dpmi_set_protected_mode_interrupt_vector(
+                                      meteors[active_meteor].intt, &address);
+
+// unlock(meteor_int_handler, meteor_int_handler_end); FIX ME check if lock can handle multiple
+
+  metmode=0;
+}
+
+void grab_next(void){
+ saa7116 *a_saa7116=(saa7116*)meteors[active_meteor].saa7116;
+
+ a_saa7116->dma_end.even=
+ a_saa7116->dma_end.odd= 0;
+
+ if(one_field==1){
+   a_saa7116->dma.even[0]= a_saa7116->dma.odd [0]= grab_dispbuf.phys;
+ }else{                                               
+   a_saa7116->dma.even[0]= grab_dispbuf.phys;
+   a_saa7116->dma.odd [0]= grab_dispbuf.phys + xresc;
+ }
+
+ a_saa7116->dma_end.even=
+ a_saa7116->dma_end.odd= grab_dispbuf.phys + xresc*yresst - 1;
+
+    
+}
+
+
+void meteor_int_handler_end(void){
+}
+
+
+void setcont(void){
+
+ write_saa7196(0x12, satur);/*7:0  Chrominance saturation control for VRAM port */
+ write_saa7196(0x13, contr);/*7:0  Luminance contract control for VRAM port */
+ write_saa7196(0x19,bright);/*7:0  Luminance brightness control for VRAM port */
+
+}
+
+void setstd_scale(void){
+ saa7116 *a_saa7116=(saa7116*)meteors[active_meteor].saa7116;
+ int i;
+
+ init_menu=1;
+ if(yuvmode!=0) mc=1;
+ else mc=2;
+ xresc=xres<<mc;
+
+ xress=xres;
+
+ if(std==NTSC)
+    y_field=240-scales_y+0x10-scalee_y, x_field=640-scales_x+3-scalee_x;
+ else
+    y_field=288-scales_y+0x10-scalee_y, x_field=768-scales_x+3-scalee_x;
+
+ if(yres-70 <= y_field && nagra_mode==0) one_field=1;
+ else                                    one_field=0;
+
+ if(nagra_mode==0 || yres-70 > y_field) yrest= yres;
+ else                                   yrest= yres << 1;
+
+ if     (one_field==0 && yrest>y_field*2){
+   yresst= y_field*2;
+   xress= int( double(xress) * double(yresst) / double(yrest) );
+ }
+ else if(one_field==1 && yrest>y_field  ){
+   yresst= y_field;
+   xress= int( double(xress) * double(yresst) / double(yrest) );
+ }
+ else{
+   yresst= yrest;
+ }
+
+ if(xress > x_field){
+   yresst= int( double(yresst) * double(x_field) / double(xress) );
+   xress= x_field;
+ }
+
+ xress =(xress  + 7) & 0x3F8;
+ yresst=(yresst + 1) & 0x3FE;
+
+ if(xress  > xres ) xres  -=8;
+ if(yresst > yrest) yresst-=2;
+
+ if(one_field==0) stride=(xres + xres - xress)<<mc;
+ else             stride=(xres        - xress)<<mc;
+
+ if(nagra_mode==0 || yres-70 > y_field) yress= yresst;
+ else                                   yress= yresst >> 1;
+
+
+ if(std==SECAM) write_saa7196(0x0D, 0x85);
+ else           write_saa7196(0x0D, 0x84);
+                           /*   7  VTR/TV mode bit = 1->VTR mode
+                                3  Realtime output mode select bit
+                                2  HREF position select
+                                1  Status byte select
+                                0  SECAM mode bit                          */
+ if(std==SECAM) write_saa7196(0x0F, 0xB0);
+ else           write_saa7196(0x0F, 0x90);
+                           /*   7  Automatic Field detection
+                                6  Field Select 0 = 50hz, 1=60hz
+                                5  SECAM cross-colour reduction
+                                4  Enable sync and clamping pulse
+                              3:1  Luminance delay compensation            */
+ if(yuvmode==0){
+   if(one_field==1) write_saa7196(0x20, 0xF2);
+   else             write_saa7196(0x20, 0x92);
+   a_saa7116->rt_mode_e=a_saa7116->rt_mode_o=
+      (rt_mode){mode: 0x00, route: 0x393939};
+ }
+ else{
+   if(one_field==1) write_saa7196(0x20, 0xF1);
+   else             write_saa7196(0x20, 0x91);
+   a_saa7116->rt_mode_e=a_saa7116->rt_mode_o=
+      (rt_mode){mode: 0x41, route: 0xeeeeee};
+ }
+                           /*   7  ROM table bypass switch
+                              6:5  Set output field mode
+                                4  VRAM port outputs enable
+                              3:2  First pixel position in VRO data
+                              1:0  FIFO output register select             */
+ write_saa7196(0x21, xress & 0xFF);
+                           /* 7:0  [7:0] Pixel number per line on output   */
+ write_saa7196(0x22, x_field & 0xFF);
+                           /* 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;
+ write_saa7196(0x24, i | ((x_field>>6) & 0x0C) | (xress>>8));
+                           /* 7:5  Horizontal decimation filter
+                                4  [8] Horizontal start position of scaling win
+                              3:2  [9:8] Pixel number per line on input
+                              1:0  [9:8] Pixel number per line on output   */
+ if(one_field==1) write_saa7196(0x25,  yresst     & 0xFF);
+ else             write_saa7196(0x25, (yresst>>1) & 0xFF);
+                           /* 7:0  [7:0] Line number per output field      */
+ 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(one_field==1) write_saa7196(0x28, i | ((y_field>>6) & 0x0C) | (yresst>>8));
+ else             write_saa7196(0x28, i | ((y_field>>6) & 0x0C) | (yresst>>9));
+                           /*   7  Adaptive filter switch
+                              6:5  Vertical luminance data processing
+                                4  [8] Vertical start of scaling window 
+                              3:2  [9:8] Line number per input field
+                              1:0  [9:8] Line number per output field      */
+
+ write_saa7196(0x29, bypass_y);/* 7:0  [7:0] Vertical bypass start             */
+ write_saa7196(0x2A, bypasc_y);/* 7:0  [7:0] Vertical bypass count             */
+
+}
+
+void init_meteor(void){
+ __dpmi_paddr address;
+ saa7116 *a_saa7116=(saa7116*)meteors[active_meteor].saa7116;
+
+ if(__dpmi_get_protected_mode_interrupt_vector(
+                      meteors[active_meteor].intt, &address)!=0) error(DPMI);
+ old_intmet_vect_offset  =address.offset32;
+ old_intmet_vect_selector=address.selector;
+
+ metmode=1;
+
+ address.offset32=(u_long)(&meteor_handler);
+ address.selector=my_cs;  
+ if(__dpmi_set_protected_mode_interrupt_vector(
+                     meteors[active_meteor].intt, &address)!=0) error(DPMI);
+
+   /* unmask meteor's IRQ */
+ asm("cli\n\t");
+ if(meteors[active_meteor].irq<8)
+      outportb(0x21, inportb(0x21) & ~(1 <<  meteors[active_meteor].irq     ));
+ else outportb(0xA1, inportb(0xA1) & ~(1 << (meteors[active_meteor].irq - 8)));
+ asm("sti\n\t");
+
+   /* init saa7116 */
+
+ reset_7116();
+ a_saa7116->capt_ctl=(capt_c){
+       cont_even: 0, cont_odd: 0, sing_even: 0, sing_odd: 0,
+       done_even: 0, done_odd: 0, VRSTN:     1, fifo_en:  0,
+       corr_even: 0, corr_odd: 0, aerr_even: 0, aerr_odd: 0,
+       res1:      0, corr_dis: 0, range_en:  0, res2:     0};  /* end reset / range contr */
+ wait(wait_time);
+
+ a_saa7116->dma.even[0]= a_saa7116->dma.odd[0]=
+ a_saa7116->dma.even[1]= a_saa7116->dma.odd[1]= 
+ a_saa7116->dma.even[2]= a_saa7116->dma.odd[2]= 0;
+ a_saa7116->stride.even[0]= a_saa7116->stride.odd[0]= 
+ a_saa7116->stride.even[1]= a_saa7116->stride.odd[1]= 
+ a_saa7116->stride.even[2]= a_saa7116->stride.odd[2]= 0;
+
+ a_saa7116->rt_mode_e= a_saa7116->rt_mode_o=
+       (rt_mode){mode: 0x01, route: 0xEEEEEE};                   /* RGB 16 */
+ a_saa7116->fifo_trigger= (ff_trig){packed: 0x20, planar: 0x20};  /* both 20h */
+ a_saa7116->field_toggle= 0x107;                   /* enab field tog ,reserveds*/
+ a_saa7116->capt_ctl=(capt_c){
+       cont_even: 0, cont_odd: 0, sing_even: 0, sing_odd: 0,
+       done_even: 0, done_odd: 0, VRSTN:     1, fifo_en:  1,
+       corr_even: 0, corr_odd: 0, aerr_even: 0, aerr_odd: 0,
+       res1:      0, corr_dis: 0, range_en:  0, res2:     0}; 
+ a_saa7116->retry_wait= 0;
+ a_saa7116->ints_ctl=(ints_c){
+       stat_even: 1, stat_odd: 1, stat_start: 1, res1: 0,
+       mask_even: 0, mask_odd: 0, mask_start: 0, res2: 0}; /* disable / clear all ints*/
+ a_saa7116->field_mask=(eo){even: 0x1, odd: 0x1};              /* This and */
+ a_saa7116->mask_lengths= 0;               /* that means capture all fields*/
+ a_saa7116->fifo_limits=0x5007C;
+ a_saa7116->i2c_clocks=0x461E1E0F;
+ a_saa7116->i2c_stat_a=0x300;
+ a_saa7116->i2c_cmd_a=0;
+ a_saa7116->i2c_auto.even[0]=  a_saa7116->i2c_auto.odd[0]=
+ a_saa7116->i2c_auto.even[1]=  a_saa7116->i2c_auto.odd[1]=
+ a_saa7116->i2c_auto.even[2]=  a_saa7116->i2c_auto.odd[2]=
+ a_saa7116->i2c_auto.even[3]=  a_saa7116->i2c_auto.odd[3]= 0;
+ a_saa7116->i2c_regs_enable= 0;
+
+ a_saa7116->dma_end=(eo){even: ~0, odd: ~0};
+ meteors[active_meteor].maxRange=
+     (a_saa7116->dma_end.even & a_saa7116->dma_end.odd) | 0xFF;
+ a_saa7116->dma_end=(eo){even: 0, odd: 0};
+ printf("maxRange = %X\n", int(meteors[active_meteor].maxRange));
+
+ frames=corr_errors=addr_errors=0;
+
+ /* init SAA7196 */
+
+ write_saa7196(0x00, 0x50);/* 7:0  Increment Delay                         */
+
+ write_saa7196(0x01, 0x30);/* 7:0  Horizontal Sync Begin for 50hz          */
+ write_saa7196(0x02, 0x00);/* 7:0  Horizontal Sync Stop for 50hz           */
+ write_saa7196(0x03, 0xE8);/* 7:0  Horizontal Sync Clamp Start for 50hz    */
+ 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 */
+
+
+ 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        */
+ 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           */
+ write_saa7196(0x0A, 0x7F);/* 7:0  PAL switch sensitivity                  */
+ write_saa7196(0x0B, 0x7F);/* 7:0  SECAM switch sensitivity                */
+ write_saa7196(0x0C, 0xC0);/*   7  Colour-on bit
+                              6:5  AGC filter                              */
+ write_saa7196(0x0E, 0x38);/*   7  Horizontal clock PLL
+                                5  Select interal/external clock source
+                                4  Output enable of Horizontal/Vertical sync
+                                3  Data output YUV enable
+                                2  S-VHS bit
+                                1  GPSW2
+                                0  GPSW1                                   */
+ write_saa7196(0x10, 0x00); 
+// write_saa7196(0x10, 0x04);
+                           /*   2  Select HREF Position
+                              1:0  Vertical noise reduction                */
+ write_saa7196(0x11, 0x2C);/* 7:0  Chrominance gain conrtol for QAM        */
+ write_saa7196(0x14, 0x34);/* 7:0  Horizontal sync begin for 60hz          */
+//#ifdef notdef
+ write_saa7196(0x15, 0x0A);/* 7:0  Horizontal sync stop for 60hz           */
+ write_saa7196(0x16, 0xF4);/* 7:0  Horizontal clamp begin for 60hz         */
+ write_saa7196(0x17, 0xCE);/* 7:0  Horizontal clamp stop for 60hz          */
+ write_saa7196(0x18, 0xF4);/* 7:0  Horizontal sync start after PH1 for 60hz */
+//#else
+//   0c fb d4 ec             0x0a, 0xf4, 0xce, 0xf4,
+//#endif
+ write_saa7196(0x1A, 0x00);
+ write_saa7196(0x1B, 0x00);
+ write_saa7196(0x1C, 0x00);
+ write_saa7196(0x1D, 0x00);
+ write_saa7196(0x1E, 0x00);
+ write_saa7196(0x1F, 0x00);
+ write_saa7196(0x2B, 0x00);/*   4  [8] Vertical bypass start
+			     2  [8] Vertical bypass count
+			     0	Polarity, internally detected odd even flag */
+ write_saa7196(0x2C, 0x80);/* 7:0  Set lower limit V for colour-keying     */
+ write_saa7196(0x2D, 0x7F);/* 7:0  Set upper limit V for colour-keying     */
+ write_saa7196(0x2E, 0x80);/* 7:0  Set lower limit U for colour-keying     */
+ write_saa7196(0x2F, 0x7F);/* 7:0  Set upper limit U for colour-keying     */
+ write_saa7196(0x30, 0x9F);/*   7  VRAM bus output format
+                                6  Adaptive geometrical filter
+                                5  Luminance limiting value
+                                4  Monochrome and two's complement output data sel
+                                3  Line quailifier flag
+                                2  Pixel qualifier flag
+                                1  Transparent data transfer
+                                0  Extended formats enable bit             */
+
+ setcont();
+ setstd_scale();
+
+// for(int c=0; c<0x30; c++){
+//   printf("%X, %X, %X\n",c, read_saa7196(c), saa7196_buf[c]);
+// }
+
+ start_grab();
+}
+
+void start_grab(void){
+ saa7116 *a_saa7116=(saa7116*)meteors[active_meteor].saa7116;
+
+ a_saa7116->ints_ctl=(ints_c){
+       stat_even: 1, stat_odd: 1, stat_start: 1, res1: 0,
+       mask_even: 0, mask_odd: 0, mask_start: 0, res2: 0};
+
+ wait(wait_time);
+
+ if(one_field==1){
+   a_saa7116->dma.even[0]= a_saa7116->dma.odd [0]=
+   a_saa7116->dma.even[1]= a_saa7116->dma.odd [1]=
+   a_saa7116->dma.even[2]= a_saa7116->dma.odd [2]=
+                                           grab_dispbuf.phys;     
+   a_saa7116->stride.even[0]=a_saa7116->stride.odd[0]= 
+   a_saa7116->stride.even[1]=a_saa7116->stride.odd[1]= 
+   a_saa7116->stride.even[2]=a_saa7116->stride.odd[2]=
+                                                      stride;
+ }else{                                               
+   a_saa7116->dma.even[0]= 
+   a_saa7116->dma.even[1]= 
+   a_saa7116->dma.even[2]=
+                     grab_dispbuf.phys;
+   a_saa7116->dma.odd [0]=
+   a_saa7116->dma.odd [1]=
+   a_saa7116->dma.odd [2]=
+                     grab_dispbuf.phys + xresc;
+   a_saa7116->stride.even[0]=a_saa7116->stride.odd[0]= 
+   a_saa7116->stride.even[1]=a_saa7116->stride.odd[1]= 
+   a_saa7116->stride.even[2]=a_saa7116->stride.odd[2]=
+                                                      stride;
+ }
+ a_saa7116->dma_end.even=
+ a_saa7116->dma_end.odd= grab_dispbuf.phys + xresc*yresst - 1;
+
+  
+
+ wait(wait_time);
+
+ a_saa7116->capt_ctl=(capt_c){
+       cont_even: 1, cont_odd: 1, sing_even: 0, sing_odd: 0,
+       done_even: 1, done_odd: 1, VRSTN:     1, fifo_en:  1,
+       corr_even: 1, corr_odd: 1, aerr_even: 1, aerr_odd: 1,
+       res1:      0, corr_dis: 0, range_en:  1, res2:     0};
+ a_saa7116->ints_ctl=(ints_c){
+       stat_even: 1, stat_odd: 1, stat_start: 1, res1: 0,
+       mask_even: 1, mask_odd: 1, mask_start: 0, res2: 0};
+ 
+}
+

Added: trunk/2010/2_71x6.h
==============================================================================
--- (empty file)
+++ trunk/2010/2_71x6.h	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,226 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+#ifndef n2_71x6
+#define n2_71x6
+
+#define SAA7116_vendev 0x12238086
+
+#define SAA7196_I2C_W 0x40
+#define SAA7196_I2C_R 0x41
+
+#define SAA7196_regs 49
+
+typedef enum{
+ PAL,
+ NTSC,
+ SECAM,
+} tv_form;
+
+typedef enum{
+ nix,
+ vc,
+ nag,
+} crypt_form;
+
+typedef enum{
+ NotReady=0,
+ Skiped,
+ Waiting,
+} grstate;
+
+/*
+ pci_cmd;   //04-05
+ pci_sts;   //06-07
+ rev;       //08
+ classc1;   //09
+ classc2;   //0A-0B
+ res0C;     //0C
+ mlt;       //0D
+ headt;     //0E
+ bist;      //0F
+*/
+
+struct meteor{
+ volatile struct saa7116 *saa7116;   
+ byte   bus;                
+ byte   dev;                
+ byte   irq;                
+ byte   intt;
+ u_long maxRange;
+};
+
+struct eo {
+  u_long even;
+  u_long odd;
+};
+
+struct eo3 {
+  u_long even[3];
+  u_long odd[3];
+};
+
+struct eo4 {
+  u_long even[4];
+  u_long odd[4];
+};
+
+struct rt_mode {
+  unsigned mode:8;		/* 0:7  Pixel format for even fields */
+  unsigned route:24;		/* 8:31 Pixel router mode for even fields */
+};
+
+struct ff_trig {
+  unsigned packed:7;            /* 0:6 Fifo trigger Packed Mode */
+  unsigned :9;                  /* 7:15 Unused */
+  unsigned planar:7;            /* 16:22 Fifo trigger Planar Mode */
+  unsigned :9;			/* 23:31 Unused */
+};
+
+struct capt_c {
+  unsigned cont_even:1;         /* 0  Capture Continous Even Fields */
+  unsigned cont_odd :1;         /* 1  Capture Continous Odd  Fields */
+  unsigned sing_even:1;         /* 2  Capture Single    Even Fields */
+  unsigned sing_odd :1;         /* 3  Capture Single    Odd  Fields */
+  unsigned done_even:1;         /* 4  Even Field Done */
+  unsigned done_odd :1;         /* 5  Odd  Field Done */
+  unsigned VRSTN    :1;         /* 6  ? */
+  unsigned fifo_en  :1;         /* 7  FIFO Enable */
+  unsigned corr_even:1;         /* 8  Even Field Corrupt */
+  unsigned corr_odd :1;         /* 9  Odd  Field Corrupt */
+  unsigned aerr_even:1;         /* 10 Even Field Address Error */
+  unsigned aerr_odd :1;         /* 11 Odd  Field Address Error */
+  unsigned res1:2;              /* 12:13 Unused */
+  unsigned corr_dis :1;         /* 14 Corrupt Disable */
+  unsigned range_en :1;         /* 15 Range Enabler */
+  unsigned res2:16;             /* 16:31 Unused */
+};
+
+struct ints_c {
+  unsigned stat_even :1;         /* 0  Interrupt Status Even     Fields */
+  unsigned stat_odd  :1;         /* 1  Interrupt Status Odd      Fields */
+  unsigned stat_start:1;         /* 2  Interrupt Status start of Fields */
+  unsigned res1:5;               /* 3:7 Unused */
+  unsigned mask_even :1;         /* 8  Interrupt Mask   Even     Fields */
+  unsigned mask_odd  :1;         /* 9  Interrupt Mask   Odd      Fields */
+  unsigned mask_start:1;         /* 10 Interrupt Mask   start of Fields */
+  unsigned res2:21;              /* 11:31 Unused */
+};
+
+struct i2c_stat {
+  unsigned AutoEnable:1;        /* 0:0 AutoEnable */
+  unsigned bypass:1;            /* 1:1 bypass */
+  unsigned SDAOut:1;            /* 2:2 SDA Output */
+  unsigned SCLOut:1;            /* 3:3 SCL Output */
+  unsigned :4;                  /* 4:7 ? */
+  unsigned AutoAbort:1;         /* 8:8 Auto Abort */
+  unsigned d_abort:1;           /* 9:9 Status of i2c write: 0==success  realy auto abort*/
+  unsigned SDAIn:1;             /*10:10 SDA Input */
+  unsigned SCLIn:1;             /*11:11 SCL Input */
+  unsigned :4;                  /*12:15 ? */
+  unsigned AutoAddr:8;          /*16:23 Auto Address */
+  unsigned r_data:8;            /*24:31 Data returned by i2c read */
+};
+
+struct i2c_cmd {
+  unsigned w_data:8;		/* 0:7 Data to be written out */
+  unsigned reg_addr:8;		/* 8:15 Register address in device space */
+  unsigned dev_addr:8;		/* 16:23 16: 0==write; 17:23: Device address */
+  unsigned xfer:1;		/* 24: Set to start write. Clears when done */
+  unsigned :7;			/* 25:31 Unused */
+};
+
+#define v_struct volatile struct
+#define v_u_long volatile u_long
+#define v_union  volatile union
+
+				/* (pointer-addition-values)hex-offset(s) */
+struct saa7116 {
+  v_struct eo3 dma;               /* ( 0-5 )00-14: Base address, e/o fields */
+  v_struct eo3 stride;            /* ( 6-11)18-2c: Address stride, e/o fields */
+  v_struct rt_mode rt_mode_e;     /* (12)30: Route and Mode for even fields */
+  v_struct rt_mode rt_mode_o;     /* (13)34: Route and Mode for odd fields */
+  v_struct ff_trig fifo_trigger;  /* (14)38 Fifo triggers: Planar and Packed */
+  v_u_long field_toggle;          /* (15)3c  bit 8=1 1=1 0=1 2=field_toggle */
+  v_union{
+    v_u_long capt_ctl_a;
+    v_struct capt_c capt_ctl;
+  };                            /* (16)40: Capture control, etc. */
+  v_u_long retry_wait;            /* (17)44 */
+  v_union{
+    v_u_long ints_ctl_a;
+    v_struct ints_c ints_ctl;
+  };                            /* (18)48: Interrupt control and status */
+  v_struct eo field_mask;         /* (19-20)4c-50 */
+  v_u_long mask_lengths;          /* (21)54 */
+  v_u_long fifo_limits;           /* (22)58 */
+  v_u_long i2c_clocks;            /* (23)5c */
+  v_union{
+    v_u_long i2c_stat_a;
+    v_struct i2c_stat i2c_stat;   
+  };                            /* (24)60 i2c mode control and status */
+  v_union{
+    v_u_long i2c_cmd_a;
+    v_struct i2c_cmd i2c_cmd;     
+  };                            /* (25)64 Direct mode command and data */
+  v_struct eo4 i2c_auto;          /* (26-33)68-84*/
+  v_u_long i2c_regs_enable;       /* (34)88 */
+  v_struct eo dma_end;            /* (35-36)8c-90 */
+};
+
+#define SAA7196_IDEL	0x00	/* Increment delay */
+#define SAA7196_HSB5	0x01	/* H-sync begin; 50 hz */
+#define SAA7196_HSS5	0x02	/* H-sync stop; 50 hz */
+#define SAA7196_HCB5	0x03	/* H-clamp begin; 50 hz */
+#define SAA7196_HCS5	0x04	/* H-clamp stop; 50 hz */
+#define SAA7196_HSP5	0x05	/* H-sync after PHI1; 50 hz */
+#define SAA7196_LUMC	0x06	/* Luminance control */
+#define SAA7196_HUEC	0x07	/* Hue control */
+#define SAA7196_CKTQ	0x08	/* Colour Killer Threshold QAM (PAL, NTSC) */
+#define SAA7196_CKTS	0x09	/* Colour Killer Threshold SECAM */
+#define SAA7196_PALS	0x0a	/* PAL switch sensitivity */
+#define SAA7196_SECAMS	0x0b	/* SECAM switch sensitivity */
+#define SAA7196_CGAINC	0x0c	/* Chroma gain control */
+#define SAA7196_STDC	0x0d	/* Standard/Mode control */
+#define SAA7196_IOCC	0x0e	/* I/O and Clock Control */
+#define SAA7196_CTRL1	0x0f	/* Control #1 */
+#define SAA7196_CTRL2	0x10	/* Control #2 */
+#define SAA7196_CGAINR	0x11	/* Chroma Gain Reference */
+#define SAA7196_CSAT	0x12	/* Chroma Saturation */
+#define SAA7196_CONT	0x13	/* Luminance Contrast */
+#define SAA7196_HSB6	0x14	/* H-sync begin; 60 hz */
+#define SAA7196_HSS6	0x15	/* H-sync stop; 60 hz */
+#define SAA7196_HCB6	0x16	/* H-clamp begin; 60 hz */
+#define SAA7196_HCS6	0x17	/* H-clamp stop; 60 hz */
+#define SAA7196_HSP6	0x18	/* H-sync after PHI1; 60 hz */
+#define SAA7196_BRIG	0x19	/* Luminance Brightness */
+#define SAA7196_FMTS	0x20	/* Formats and sequence */
+#define SAA7196_OUTPIX	0x21	/* Output data pixel/line */
+#define SAA7196_INPIX	0x22	/* Input data pixel/line */
+#define SAA7196_HWS	0x23	/* Horiz. window start */
+#define SAA7196_HFILT	0x24	/* Horiz. filter */
+#define SAA7196_OUTLINE	0x25	/* Output data lines/field */
+#define SAA7196_INLINE	0x26	/* Input data lines/field */
+#define SAA7196_VWS	0x27	/* Vertical window start */
+#define SAA7196_VYP	0x28	/* AFS/vertical Y processing */
+#define SAA7196_VBS	0x29	/* Vertical Bypass start */
+#define SAA7196_VBCNT	0x2a	/* Vertical Bypass count */
+#define SAA7196_VBP	0x2b	/* veritcal Bypass Polarity */
+#define SAA7196_VLOW	0x2c	/* Colour-keying lower V limit */
+#define SAA7196_VHIGH	0x2d	/* Colour-keying upper V limit */
+#define SAA7196_ULOW	0x2e	/* Colour-keying lower U limit */
+#define SAA7196_UHIGH	0x2f	/* Colour-keying upper U limit */
+#define SAA7196_DPATH	0x30	/* Data path setting  */
+
+
+int scan_pci_meteors(void);
+void init_meteor(void);
+void close_meteor(void);
+void meteor_int_handler(void);
+void meteor_int_handler_end(void);
+void start_grab(void);
+void write_saa7196(u_char reg, u_char data);
+u_char read_saa7196(u_char reg);
+void setcont(void);
+void setstd_scale(void);
+void grab_next(void);
+
+#endif

Added: trunk/2010/2_all.h
==============================================================================
--- (empty file)
+++ trunk/2010/2_all.h	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,63 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+#ifndef n2_all_h
+#define n2_all_h
+
+#define mabs(a) ((a)<0 ? -(a) : (a))
+#define sign(a)   ((a)<0 ? -1 :  1)
+#define is_neg(a) ((a)<0 ?  0 : -1)
+#define is_pos(a) ((a)<0 ? -1 :  0)
+
+#define u_char unsigned char
+#define u_long unsigned long
+#define u_short unsigned short
+#define byte unsigned char
+#define word unsigned short
+#define dword unsigned long
+#define ll long long
+
+struct s_yuv{
+  byte u, y1, v, y2;
+};
+
+struct s_rgb{
+  byte b, g, r, x;
+};
+
+struct s_cl{
+  byte chrom, lum;
+};
+
+union s_col{
+  s_rgb rgb;
+  s_yuv yuv;
+  u_long a;
+};
+
+struct xxx{
+  union{
+    s_yuv *yuv;
+    s_rgb *rgb;
+    s_cl  *cl;
+    byte  *b;
+  };
+  int phys;
+};
+
+class color{
+ public:
+   s_col c;
+   color(void) { };
+   void init(byte y, byte u, byte v, byte yuv_mode)
+     { if(yuv_mode!=0){
+         c.yuv.y1=c.yuv.y2=y;
+         c.yuv.u=u;
+         c.yuv.v=v;
+       }else{
+         c.rgb.r= (byte)( y + 1.375   *v); 
+         c.rgb.g= (byte)( y - 0.703125*v - 0.34375*u); 
+         c.rgb.b= (byte)( y + 1.734375*u);
+       }
+     };
+} ;
+
+#endif

Added: trunk/2010/2_all_a.asm
==============================================================================
--- (empty file)
+++ trunk/2010/2_all_a.asm	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,17 @@
+; 2010 0.1 Copyright (C) Michael Niedermayer 1998
+
+%define par1 (esp + 28)
+%define par2 (esp + 32)
+%define par3 (esp + 36)
+%define par4 (esp + 40)
+%define par5 (esp + 44)
+%define par6 (esp + 48)
+%define par7 (esp + 52)
+%define par8 (esp + 56)
+
+;%define int3 db 0xCC
+
+%define align2  times ($$-$) & 1  nop
+%define align4  times ($$-$) & 3  nop
+%define align8  times ($$-$) & 7  nop
+%define align16 times ($$-$) & 15 nop

Added: trunk/2010/2_crypt.cc
==============================================================================
--- (empty file)
+++ trunk/2010/2_crypt.cc	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,197 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+
+#include <string.h>
+#include "2_all.h"
+#include "2_crypt.h"
+#include "2_vc.h"
+#include "2_nag.h"
+#include "2_71x6.h"
+
+extern volatile tv_form std;
+extern volatile crypt_form crypt;
+extern xres, yres, xress, yress, y_field, yresst, yrest;
+extern xxx dispbuf;
+extern volatile int scales_x, scalee_x;
+extern volatile int scales_y, scalee_y;
+extern int one_field, v_smooth, yuvmode;
+extern int satur;
+
+static void vsmooth(void);
+static void decomb(void);
+
+int show_points=0;
+
+ asm("__esp: .long 0\n\t");
+
+void decrypt(void){
+
+// if( (crypt == vc || crypt == nag) && satur!=0 ) decomb();
+// decomb();
+
+ if(crypt==vc)       vc_decrypt();
+ else if(crypt==nag) nag_decrypt();
+
+ if(one_field==0 && v_smooth==1) vsmooth();
+
+}
+
+
+static void decomb(void){
+
+ int linep, llinep, line, i, o;
+ int j, k;
+ int temp[max_x];
+ const int yresst1= yresst>>1;
+
+ const int stride=one_field ? (xres<<1) : (xres<<2);
+ const int pass=one_field ? 1 : 2;
+ const int end=one_field ? yresst : yresst1;
+
+ for(o=0; o<pass; o++){
+
+   for(i=0; i<max_x; i++) temp[i]=0;
+
+   linep=stride * end;
+   if(o) linep+=xres<<1;
+   for(line=end-1; line>=0; line--){
+     linep-=stride;
+     for(i=0; i<xress; i++){
+       j = int(dispbuf.b[linep  + (i<<1)]);
+       k = temp[i] & (~1);
+       if(j>127) j= j - 256;
+       j=(j + j) - k;
+       j-=j>>4;
+       temp[i]=j;
+     }
+   }
+  
+   linep=-stride;
+   if(o) linep+=xres<<1;
+   for(line=0; line<end; line++){
+     linep+=stride;
+     for(i=0; i<xress; i++){
+       j = int(dispbuf.b[linep  + (i<<1)]);
+       k = temp[i] & (~1);
+       if(j>127) j= j - 256;
+       j=(j + j) - k;
+       dispbuf.b[linep  + (i<<1)] = (char)(j);
+       j-=j>>4;
+       temp[i] = j;
+     }                                               
+   }
+ }
+
+/*
+ asm(//"int $3                    \n\t"
+     "1:                          \n\t"
+     "movl (%%esi      ), %%eax   \n\t"    //U         LINE-1
+     "movl (%%esi,%%edi), %%ebx   \n\t"    // V 1      LINE
+     "movl %%ebx, %%ecx           \n\t"    //U
+     "andl $0x00FF00FF, %%eax     \n\t"    // V 1
+     "andl $0x00FF00FF, %%ebx     \n\t"    //U
+     "addl $0x00800080, %%eax     \n\t"    // V 1
+     "xorl $0x00800080, %%eax     \n\t"    //U
+     "addl %%ebx, %%ebx           \n\t"    // V 1
+     "orl  $0x02000200, %%ebx     \n\t"    //U
+     "andl $0xFF00FF00, %%ecx     \n\t"    // V 1
+     "subl %%eax, %%ebx           \n\t"    //U
+     "addl $4, %%esi              \n\t"    // V 1 
+     "movl %%ebx, %%eax           \n\t"    //U
+     "andl $0x01F801F8, %%ebx     \n\t"    // V 1
+     "shrl $3, %%ebx              \n\t"    //U
+     "nop                         \n\t"    // V 1 FIX ME
+     "addl $0x00600060, %%ebx     \n\t"    //U
+     "nop                         \n\t"    // V 1 FIX ME
+     "xorl $0x00600060, %%ebx     \n\t"    //U
+     "nop                         \n\t"    // V 1 FIX ME
+     "subl %%ebx, %%eax           \n\t"    //U
+     "nop                         \n\t"    // V 1 FIX ME
+     "andl $0x00FF00FF, %%eax     \n\t"    //U
+     "nop                         \n\t"    // V 1 FIX ME
+     "orl %%ecx, %%eax            \n\t"    //U
+     "decl %%edx                  \n\t"    // V 1
+     "movl %%eax, -4(%%esi, %%edi)\n\t"    //U
+     " jnz 1b                     \n\t"    // V 1
+
+         :
+         : "D" (one_field==1 ? (xres<<1) : (xres<<2)), "S" (dispbuf.b),
+           "d" (xres * yress>>1)
+         : "%eax", "%ebx", "%ecx", "%edx", "%esi");
+ */
+}
+
+static void vsmooth(void){
+/*
+     for(int x=0; x < xress; x++){
+       dispbuf.rgb[x + y*xres].r=(  (dispbuf.rgb[x +  y   *xres].r >> 1)
+                                  + (dispbuf.rgb[x + (y+1)*xres].r     )
+                                  + (dispbuf.rgb[x + (y+2)*xres].r >> 1) ) >> 1;
+       dispbuf.rgb[x + y*xres].g=(  (dispbuf.rgb[x +  y   *xres].g >> 1)
+                                  + (dispbuf.rgb[x + (y+1)*xres].g     )
+                                  + (dispbuf.rgb[x + (y+2)*xres].g >> 1) ) >> 1;
+       dispbuf.rgb[x + y*xres].b=(  (dispbuf.rgb[x +  y   *xres].b >> 1)
+                                  + (dispbuf.rgb[x + (y+1)*xres].b     )
+                                  + (dispbuf.rgb[x + (y+2)*xres].b >> 1) ) >> 1;
+     }
+  */
+
+ if(yuvmode==0){
+   asm(//"int $3                      \n\t"
+       "1:                          \n\t"
+       "movl (%%esi        ), %%eax \n\t"    //U         LINE
+       "movl (%%esi,%%edi,2), %%ebx \n\t"    // V 1      LINE + 2
+       "shrl $2, %%eax              \n\t"    //U
+       "andl $0xFCFCFCFC, %%ebx     \n\t"    // V 1        
+       "shrl $2, %%ebx              \n\t"    //U
+       "andl $0x3F3F3F3F, %%eax     \n\t"    // V 1
+       "addl %%eax, %%ebx           \n\t"    //U
+       "movl (%%esi,%%edi  ), %%eax \n\t"    // V 1      LINE + 1
+       "shrl $1, %%eax              \n\t"    //U
+       "andl $0x7F7F7F7F, %%ebx     \n\t"    // V 1  
+       "andl $0x7F7F7F7F, %%eax     \n\t"    //U
+       "addl $4, %%esi              \n\t"    // V 1
+       "addl %%eax, %%ebx           \n\t"    //U
+       "decl %%ecx                  \n\t"    // V 1
+       "movl %%ebx, -4(%%esi      ) \n\t"    //U         LINE
+       " jnz 1b                     \n\t"    // V 1
+           :
+           : "D" (xres<<2), "S" (dispbuf.b),
+             "c" (xres * (yress-2) ) 
+           : "%eax", "%ebx", "%ecx", "%esi");
+
+ }
+ else{
+   asm(//"int $3                      \n\t"
+       "1:                          \n\t"
+       "movl (%%esi        ), %%eax \n\t"    //U         LINE
+       "movl (%%esi,%%edi,2), %%ebx \n\t"    // V 1      LINE + 2
+       "shrl $2, %%eax              \n\t"    //U
+       "andl $0xFCFCFCFC, %%ebx     \n\t"    // V 1        
+       "shrl $2, %%ebx              \n\t"    //U
+       "andl $0x3F3F3F3F, %%eax     \n\t"    // V 1
+       "addl $0x00200020, %%eax     \n\t"    //U
+       "addl $0x00200020, %%ebx     \n\t"    // V 1
+       "xorl $0x00200020, %%eax     \n\t"    //U
+       "xorl $0x00200020, %%ebx     \n\t"    // V 1
+       "addl %%eax, %%ebx           \n\t"    //U
+       "movl (%%esi,%%edi  ), %%eax \n\t"    // V 1      LINE + 1
+       "shrl $1, %%eax              \n\t"    //U
+       "andl $0x7F7F7F7F, %%ebx     \n\t"    // V 1  
+       "andl $0x7F7F7F7F, %%eax     \n\t"    //U
+       "addl $0x00400040, %%ebx     \n\t"    // V 1
+       "addl $0x00400040, %%eax     \n\t"    //U
+       "xorl $0x00400040, %%ebx     \n\t"    // V 1
+       "xorl $0x00400040, %%eax     \n\t"    //U
+       "addl $4, %%esi              \n\t"    // V 1
+       "addl %%eax, %%ebx           \n\t"    //U
+       "decl %%ecx                  \n\t"    // V 1
+       "movl %%ebx, -4(%%esi      ) \n\t"    //U         LINE
+       " jnz 1b                     \n\t"    // V 1
+           :
+           : "D" (xres<<1), "S" (dispbuf.b),
+             "c" (xres * (yress-2) >> 1) 
+           : "%eax", "%ebx", "%ecx", "%esi");
+
+
+ }
+}

Added: trunk/2010/2_crypt.h
==============================================================================
--- (empty file)
+++ trunk/2010/2_crypt.h	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,10 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+#ifndef n2_crypt_h
+#define n2_crypt_h
+
+#define max_x 900
+#define max_y 700
+
+void decrypt(void);
+
+#endif

Added: trunk/2010/2_file.cc
==============================================================================
--- (empty file)
+++ trunk/2010/2_file.cc	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,76 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+
+#include <stdio.h>
+#include <dos.h>
+#include "2_all.h"
+#include "2010.h"
+#include "2_file.h"
+#include "2_hw.h"
+
+ extern int xres, yres, xress, yress;
+ extern int fysize;
+ extern byte font[4096];
+ extern xxx dispbuf;
+ extern int g_mode;
+ extern int yuvmode;
+ extern char *yuv2rgb_lut;
+
+void grab(void){
+ int i, j;
+ FILE *fg;
+ char grab_name[16];
+ struct time ti;
+ bmp bmpi;
+ byte fwbuf[8];
+
+ gettime(&ti);
+ sprintf(grab_name, "G%02d%02d%02d.BMP", ti.ti_hour, ti.ti_min, ti.ti_sec);
+
+ if((fg=fopen(grab_name, "ab"))==NULL && g_mode==0) error(FileWrite);
+
+ bmpi.magic='B'+('M'<<8);
+ bmpi.lenght=xress * yress * 3 + 54;
+ bmpi.zero1=0;
+ bmpi.datstart=54;
+ bmpi.palstart=40; //??
+ bmpi.xres=xress;
+ bmpi.yres=yress;
+ bmpi.planes=1;
+ bmpi.bits=24;
+ bmpi.comp=0;
+ bmpi.size=xress * yress * 3;
+ bmpi.xpel=0;
+ bmpi.ypel=0;
+ bmpi.clruse=0;
+ bmpi.clrimp=0;
+
+ fwrite(&bmpi, sizeof(bmpi), 1, fg);
+ for(i=yress-1; i>=0; i--){
+   for(j=0; j<xress; j++){
+     if(yuvmode==0) fwrite((void*)(&dispbuf.rgb[j + i*xres]), 1, 3, fg);
+     else {
+       if(j>=xress>>1) break;
+
+       mem2vid(fwbuf, dispbuf.yuv + j + (i*xres>>1), 2, 32);
+
+       fwbuf[3]=fwbuf[4];
+       fwbuf[4]=fwbuf[5];
+       fwbuf[5]=fwbuf[6];
+
+       fwrite(fwbuf, 1, 6, fg);
+     }
+   } 
+ }
+
+ fclose(fg);
+
+}
+
+long fsize(FILE *f){
+ long i,j;
+ i=ftell(f);                                  //get pos
+ fseek(f,0,SEEK_END);                  //find end
+ j=ftell(f);
+ fseek(f,i,SEEK_SET);                         //restore pos
+ return j;
+}

Added: trunk/2010/2_file.h
==============================================================================
--- (empty file)
+++ trunk/2010/2_file.h	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,26 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+#ifndef n2_file_h
+#define n2_file_h
+
+struct bmp{
+  word  magic    __attribute__ ((packed)) ;
+  dword lenght   __attribute__ ((packed)) ;
+  dword zero1    __attribute__ ((packed)) ;
+  dword datstart __attribute__ ((packed)) ;
+  dword palstart __attribute__ ((packed)) ;
+  dword xres     __attribute__ ((packed)) ;
+  dword yres     __attribute__ ((packed)) ;
+  word  planes   __attribute__ ((packed)) ;
+  word  bits     __attribute__ ((packed)) ;
+  dword comp     __attribute__ ((packed)) ;
+  dword size     __attribute__ ((packed)) ;
+  dword xpel     __attribute__ ((packed)) ;
+  dword ypel     __attribute__ ((packed)) ;
+  dword clruse   __attribute__ ((packed)) ;
+  dword clrimp   __attribute__ ((packed)) ;
+};
+
+void grab(void);
+long fsize(FILE *f);
+
+#endif

Added: trunk/2010/2_gfunc.cc
==============================================================================
--- (empty file)
+++ trunk/2010/2_gfunc.cc	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,387 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+
+#include <stdlib.h>
+#include <string.h>
+#include "2_all.h"
+#include "2_gfunc.h"
+
+ extern int xres, yres, xresc;
+ extern int buttons, xpos, ypos, lxpos, lypos;
+ extern int fysize;
+ extern byte font[4096];
+ extern int me, mx, my;
+ extern int g_mode;
+ extern int page_flip;
+ extern xxx dispbuf;
+ extern byte *vidbuf;
+ extern int yuvmode;
+
+static inline void memsetd(void *pt, u_long c, int num);
+
+static inline void memsetd(void *pt, u_long c, int num){
+
+ asm(//"int $3 \n\t"
+     "rep    \n\t"
+     "stosl  \n\t"
+     :
+     : "a" (c), "D" (pt), "c" (num)
+     : "%ecx", "%edi");
+
+
+}
+
+void xcliped_gprint(int xp, int yp, const s_col c, int text){
+ int ix, iy;
+ int t3;
+ byte t1;
+
+ if(yp>0) iy=0;
+ else iy=-yp;
+ for(; iy<fysize && (iy+yp<yres); iy++){
+   t1=font[(text<<4)+iy];
+   t3=xp+(yp+iy)*xres;
+   if(xp>0) ix=0;
+   else ix=-xp;
+   for(; ix<8 && ix+xp<xres; ix++){
+     if(((t1>>(7-ix)) & 1) == 1){
+       if(yuvmode!=0)
+         dispbuf.yuv[(ix+t3)/2]=c.yuv;       //FIX ME
+       else
+         dispbuf.rgb[(ix+t3)]=c.rgb;      
+     }
+   }
+ }
+}
+
+void gprint(int xp, int yp, const s_col c, char *text){
+ static int clipyp, clipym;
+ int i, t=0, tp=0;
+
+ if(xp<0){
+  if(xp+int(strlen(text))*9+1<0) return;
+  i=(-xp+1)/9+1;
+  if(i>int(strlen(text))) return;
+  text+=i;
+  xp+=i*9;
+  xcliped_gprint(xp-9, yp, c, *(text-1));
+ }
+ if(yp<0){
+  if(yp+fysize<=0) return;
+  clipym=-yp;
+ }
+ else clipym=0;
+
+ if(xp+int(strlen(text))*9+1>=xres){
+  if(xp>=xres) return;
+  i=(xres-xp)/9;
+  t=text[i];
+  tp=i;
+  text[i]=0;
+ }
+
+ if(yp+fysize>yres){
+  if(yp>=yres) return;
+  clipyp=yres-yp;
+ }
+ else clipyp=fysize;
+
+ //FIX ME TEST reg, imm is NP
+
+ if(yuvmode!=0){
+   asm(//"int $3\n\t"
+        "pushl %%ebp               \n\t"
+        "pushl %%eax               \n\t"
+        "10:                       \n\t"
+        "movl %4, %%esi            \n\t"
+        "movl %%esi, %%edi         \n\t"
+        "imull %1, %%esi           \n\t"
+        "popl %%ebp                \n\t"
+        "pushl %%ebp               \n\t"
+        "movl %%ebp, %%eax         \n\t"
+        "shrl $16, %%ebp           \n\t"
+        "testl $2, %%edx           \n\t"
+        " jz 0f                    \n\t"
+        "xchgl %%eax, %%ebp        \n\t"
+        "0:                        \n\t"
+        "xorl %%ebx,%%ebx          \n\t"     
+        "movb (%%ecx), %%bl        \n\t"
+        "testb %%bl, %%bl          \n\t"
+        " jz 9f                    \n\t"
+        "shll $4, %%ebx            \n\t"
+        "addl %%edi, %%ebx         \n\t"
+        "addl %2, %%ebx            \n\t"
+        "movb (%%ebx), %%bl        \n\t"
+        "testb $128, %%ebx         \n\t"
+        " jz 1f                    \n\t"
+        "movw %%ax,  (%%edx,%%esi) \n\t"
+        "1:                        \n\t"
+        "testb $64, %%bl           \n\t"
+        " jz 2f                    \n\t"
+        "movw %%bp, 2(%%edx,%%esi) \n\t"
+        "2:                        \n\t"
+        "testb $32, %%bl           \n\t"
+        " jz 3f                    \n\t"
+        "movw %%ax, 4(%%edx,%%esi) \n\t"
+        "3:                        \n\t"
+        "testb $16, %%bl           \n\t"
+        " jz 4f                    \n\t"
+        "movw %%bp, 6(%%edx,%%esi) \n\t"
+        "4:                        \n\t"
+        "testb $8, %%bl            \n\t"
+        " jz 5f                    \n\t"
+        "movw %%ax, 8(%%edx,%%esi) \n\t"
+        "5:                        \n\t"
+        "testb $4, %%bl            \n\t"
+        " jz 6f                    \n\t"
+        "movw %%bp,10(%%edx,%%esi) \n\t"
+        "6:                        \n\t"
+        "testb $2, %%bl            \n\t"
+        " jz 7f                    \n\t"
+        "movw %%ax,12(%%edx,%%esi) \n\t"
+        "7:                        \n\t"
+        "testb $1, %%bl            \n\t"
+        " jz 8f                    \n\t"
+        "movw %%bp,14(%%edx,%%esi) \n\t"
+        "8:                        \n\t"
+        "incl %%edi                \n\t"
+        "addl %1, %%esi            \n\t"
+        "cmpl %3, %%edi            \n\t"
+        " jb 0b                    \n\t"
+        "xchgl %%eax, %%ebp        \n\t"
+        "addl $18, %%edx           \n\t"
+        "incl %%ecx                \n\t"
+        "jmp 10b                   \n\t" 
+        "9:                        \n\t" 
+        "popl %%eax                \n\t"
+        "popl %%ebp                \n\t"
+        :
+        : "m" (fysize), "m"(xresc), "m" (&font), "m" (clipyp), "m" (clipym),
+          "a" (c.yuv), "c" (text), "d" (((u_long)dispbuf.cl)+((xp+yp*xres)<<1))
+        : "%ebx", "%ecx", "%edx", "%esi", "%edi");
+ }else{
+   asm(//"int $3\n\t"
+        "10:                       \n\t"
+        "movl %4, %%esi            \n\t"
+        "movl %%esi, %%edi         \n\t"
+        "imull %1, %%esi           \n\t"
+        "0:                        \n\t"
+        "xorl %%ebx,%%ebx          \n\t"
+        "movb (%%ecx), %%bl        \n\t"
+        "testb %%bl, %%bl          \n\t"
+        " jz 9f                    \n\t"
+        "shll $4, %%ebx            \n\t"
+        "addl %%edi, %%ebx         \n\t"
+        "addl %2, %%ebx            \n\t"
+        "movb (%%ebx), %%bl        \n\t"
+        "testb $128, %%ebx         \n\t"
+        " jz 1f                    \n\t"
+        "movl %%eax,  (%%edx,%%esi)\n\t"
+        "1:                        \n\t"
+        "testb $64, %%bl           \n\t"
+        " jz 2f                    \n\t"
+        "movl %%eax, 4(%%edx,%%esi)\n\t"
+        "2:                        \n\t"
+        "testb $32, %%bl           \n\t"
+        " jz 3f                    \n\t"
+        "movl %%eax, 8(%%edx,%%esi)\n\t"
+        "3:                        \n\t"
+        "testb $16, %%bl           \n\t"
+        " jz 4f                    \n\t"
+        "movl %%eax,12(%%edx,%%esi)\n\t"
+        "4:                        \n\t"
+        "testb $8, %%bl            \n\t"
+        " jz 5f                    \n\t"
+        "movl %%eax,16(%%edx,%%esi)\n\t"
+        "5:                        \n\t"
+        "testb $4, %%bl            \n\t"
+        " jz 6f                    \n\t"
+        "movl %%eax,20(%%edx,%%esi)\n\t"
+        "6:                        \n\t"
+        "testb $2, %%bl            \n\t"
+        " jz 7f                    \n\t"
+        "movl %%eax,24(%%edx,%%esi)\n\t"
+        "7:                        \n\t"
+        "testb $1, %%bl            \n\t"
+        " jz 8f                    \n\t"
+        "movl %%eax,28(%%edx,%%esi)\n\t"
+        "8:                        \n\t"
+        "incl %%edi                \n\t"
+        "addl %1, %%esi            \n\t"
+        "cmpl %3, %%edi            \n\t"
+        " jb 0b                    \n\t"
+        "addl $36, %%edx           \n\t"
+        "incl %%ecx                \n\t"
+        "jmp 10b                   \n\t" 
+        "9:                        \n\t" 
+        :
+        : "m" (fysize), "m"(xresc), "m" (&font), "m" (clipyp), "m" (clipym),
+          "a" (c.rgb), "c" (text), "d" (((u_long)dispbuf.cl)+((xp+yp*xres)<<2))
+        : "%ebx", "%ecx", "%edx", "%esi", "%edi");
+   }
+ if(t!=0){
+  xcliped_gprint(xres - ((xres-xp) % 9), yp, c, t);
+  text[tp]=t;
+ }
+}
+
+void dot(const int x, const int y, const s_col c){
+
+ if(x>0 && x<xres && y>0 && y<yres){
+   if(yuvmode!=0){
+     dispbuf.cl[y*xres+x].lum=c.yuv.y1;
+     dispbuf.cl[(y*xres+x) |   1 ].chrom=c.yuv.v;
+     dispbuf.cl[(y*xres+x) & (~1)].chrom=c.yuv.u;
+   }else{
+     dispbuf.rgb[y*xres+x].r=c.rgb.r;
+     dispbuf.rgb[y*xres+x].g=c.rgb.g;
+     dispbuf.rgb[y*xres+x].b=c.rgb.b;
+   }
+ }
+}
+/*
+void line(int x1, int y1, int x2, int y2, const s_yuv c){
+ int t;
+
+ if(x1<0){
+  if(x2<0) return;
+  else y1=(int)((float)(y1-y2)/((float)(x2-x1)+.1E-4)*(float)x2+y2), x1=0;
+ }
+ else if(x1>=xres){
+  if(x2>=xres) return;
+  else y1=(int)((float)(y1-y2)/((float)(x2-x1)+.1E-4)*(float)(x2-xres+1)+y2), x1=xres-1;
+ }
+ if(x2<0) y2=(int)((float)(y2-y1)/((float)(x1-x2)+.1E-4)*(float)x1+y1), x2=0;
+ else if(x2>=xres)
+    y2=(int)((float)(y2-y1)/((float)(x1-x2)+.1E-4)*(float)(x1-xres+1)+y1), x2=xres-1;
+                                            
+
+ if(y1<0){
+  if(y2<0) return;
+  else x1=(int)((float)(x1-x2)/((float)(y2-y1)+.1E-4)*(float)y2+x2), y1=0;
+ }
+ else if(y1>=yres){
+  if(y2>=yres) return;
+  else 
+   x1=(int)((float)(x1-x2)/((float)(y2-y1)+.1E-4)*(float)(y2-yres+1)+x2), y1=yres-1;
+ }
+ if(y2<0) x2=(int)((float)(x2-x1)/((float)(y1-y2)+.1E-4)*(float)y1+x1), y2=0;
+ else if(y2>=yres)
+    x2=(int)((float)(x2-x1)/((float)(y1-y2)+.1E-4)*(float)(y1-yres+1)+x1), y2=yres-1;
+
+ if(x1==x2 && y1==y2) return;
+
+ if(mabs(x1-x2)>mabs(y1-y2)){
+  register int fl,delta;
+  if(x1>x2) t=x1,x1=x2,x2=t,t=y1,y1=y2,y2=t,t=1;
+  delta=(y1-y2)*(1<<16)/(x1-x2);
+
+  for(fl=y1<<16; x1<x2; x1++){
+   fl+=delta;
+   dispbuf.yuv[(x1+(fl>>16)*xres)>>1]=c; //FIX ME
+  }
+ }else {
+  register int fl,delta;
+  if(y1>y2) t=y1,y1=y2,y2=t,t=x1,x1=x2,x2=t,t=1;
+  delta=(x1-x2)*(1<<10)/(y1-y2) + (xres<<10);
+  fl=(x1+y1*xres)<<10;
+  y2-=y1;
+  for(; y2!=0; y2--){
+   fl+=delta;
+   dispbuf.yuv[(fl>>10)>>1]=c; //FIX ME
+  }
+
+ } 
+}
+  */
+
+void hline(register int x1, int y1, register int x2, const s_yuv c){
+ int t;
+ u_long *a=(u_long *)(&c);
+
+ if(x1>x2) t=x1, x1=x2, x2=t;
+ 
+ if(x1<0){
+  x1=0;
+  if(x2<0) return;
+ }
+ if(x2>=xres){
+  x2=xres-1;
+  if(x1>=xres) return;
+ }
+ if(y1<0 || y1>=yres) return;
+
+ x1+=y1*xres;
+ memset(dispbuf.cl + x1, *a, ((x2+y1*xres)-x1+1)<<1);  //FIX HLINE
+}
+/*
+void vline(const int x1, register int y1, register int y2, const s_yuv c){
+ int t;
+
+ if(y1>y2) t=y1, y1=y2, y2=t;
+ 
+ if(y1<0){
+  y1=0;
+  if(y2<0) return;
+ }
+ if(y2>=yres){
+  y2=yres-1;
+  if(y1>=yres) return;
+ }
+ if(x1<0 || x1>=xres) return;
+
+ y1=y1*xres+x1;
+ y2=(y2-2)*xres+x1;
+ for(; y1<y2; y1+=xres){
+  dispbuf[y1]=c;
+  dispbuf[y1+=xres]=c;
+  dispbuf[y1+=xres]=c;
+  dispbuf[y1+=xres]=c;
+ }
+ y2+=xres<<1;
+ for(; y1<y2; y1+=xres){
+  dispbuf[y1]=c;
+ }
+}
+*/
+
+void rect(int x1, int y1, int x2, int y2, const s_col c){
+ u_long *a=(u_long *)(&c.yuv);
+ int t;
+/*
+ if(x1>x2) t=x1,x1=x2,x2=t;
+ if(y1>y2) t=y1,y1=y2,y2=t;  */
+
+
+ if(x1<0){
+  if(x2<0) return;
+  x1=0;
+ }
+ else if(x2>=xres){
+  if(x1>=xres) return;
+  x2=xres-1;
+ }
+ if(y1<0){
+  if(y2<0) return;
+  y1=0;
+ }
+ else if(y2>=yres){
+  if(y1>=yres)
+  y2=yres-1;
+ }
+ y1*=xresc;
+ y2*=xresc;
+
+ t=x1 & (~1);
+ if(yuvmode!=0){
+   for(; y1<=y2; y1+=xresc){
+     if(x1 & 1 == 1) {}
+     memsetd((byte*)dispbuf.cl +y1 +(t<<1), *a, ((x2-x1)>>1));
+     if(x2 & 1 == 1) {}
+   }
+ }else{
+   for(; y1<=y2; y1+=xresc){
+     memsetd((byte*)dispbuf.cl +y1 +(x1<<2), *a, x2-x1);
+   }
+ }
+
+}

Added: trunk/2010/2_gfunc.h
==============================================================================
--- (empty file)
+++ trunk/2010/2_gfunc.h	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,16 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+#ifndef n2_gfunc_h
+#define n2_gfunc_h
+
+void gprint(int xp, int yp, const s_col c, char *text);
+void xcliped_gprint(int xp, int yp, const s_col c, int text);
+void dot(const int x, const int y, const s_col c);
+void line(int x1, int y1, int x2, int y2, const s_col c);
+
+void hline(register int x1, int y1, register int x2, const s_col c);
+
+void vline(const int x1, register int y1, register int y2, const s_col c);
+
+void rect(int x1, int y1, int x2, int y2, const s_col c);
+
+#endif

Added: trunk/2010/2_glob_a.asm
==============================================================================
--- (empty file)
+++ trunk/2010/2_glob_a.asm	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,22 @@
+;2010 0.1 Copyright (C) Michael Niedermayer 1998
+
+%include "2_all_a.asm"
+
+segment .data
+
+global esp_save
+global _asm_temp
+global _asm_temp2
+global _asm_temp3
+global _asm_temp4
+
+segment .bss
+
+align4
+
+esp_save   resd 1
+_asm_temp  resd 1
+_asm_temp2 resd 1
+_asm_temp3 resd 1
+_asm_temp4 resd 1
+

Added: trunk/2010/2_grafix.cc
==============================================================================
--- (empty file)
+++ trunk/2010/2_grafix.cc	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,83 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+
+#include <stdio.h>
+#include <time.h>
+#include <string.h>
+#include "2_all.h"
+#include "2_grafix.h"
+#include "2_gfunc.h"
+#include "2_hw.h"
+#include "2_menu.h"
+#include "2_file.h"
+#include "2_wins.h"
+#include "2_crypt.h"
+
+ extern int xres, yres, xresc;
+ extern int buttons, xpos, ypos, lxpos, lypos;
+ extern int fysize;
+ extern byte font[4096];
+ extern int me, mx, my;
+ extern int grabf;
+ extern xxx dispbuf, grab_dispbuf;
+ extern menu menu_main[];
+ extern int yuvmode;
+ extern volatile int addr_errors, corr_errors;
+ extern int single;
+ int infox, infoy;
+ int istate=1;
+ int conty_b, conty_s, conty_c, contx_b, contx_s, contx_c;
+ int cstate=1;
+
+ long T1,T2,T3;
+
+void draw_dispbuf(void){
+ char textbuf[256];
+ color c;
+
+ T2=uclock();
+
+ decrypt();
+
+ if(istate==1){
+   T1=uclock();
+   sprintf(textbuf,"%f Decrypt", (float)(T1-T2)/UCLOCKS_PER_SEC);
+   c.init(255, 0, 0, yuvmode);
+   gprint(30, 30, c.c, textbuf);
+
+   sprintf(textbuf,"%f Fps",1/((float)(T1-T3)/UCLOCKS_PER_SEC));
+   c.init(255, 0, 0, yuvmode);
+   gprint(50, 50, c.c, textbuf);
+
+   sprintf(textbuf,"%d Corrupted Fields", corr_errors);
+   c.init(255, 0, 0, yuvmode);
+   gprint(60, 60, c.c, textbuf);
+
+   sprintf(textbuf,"%d Address error's", addr_errors);
+   c.init(255, 0, 0, yuvmode);
+   gprint(70, 70, c.c, textbuf);
+
+   T3=T2=T1;
+ }
+
+ if(grabf==1) grab(), grabf=0;
+
+ if(me!=0) disp_menu(menu_main, mx+4, my+4, 0);   // +4 for mistakely menu hit
+
+ if(me==0 && istate==1){
+  // print info 
+
+ }
+
+ if(cstate==1) drawc();
+
+ if(istate==1){
+   T2=uclock();
+   sprintf(textbuf,"%f Misc",(float)(T2-T1)/UCLOCKS_PER_SEC);
+   c.init(255, 0, 0, yuvmode);
+   gprint(40, 40, c.c, textbuf);
+ }
+
+ copy_vidbuffer();
+
+}
+

Added: trunk/2010/2_grafix.h
==============================================================================
--- (empty file)
+++ trunk/2010/2_grafix.h	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,7 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+#ifndef n2_grafix_h
+#define n2_grafix_h
+
+void draw_dispbuf(void);
+
+#endif

Added: trunk/2010/2_hw.cc
==============================================================================
--- (empty file)
+++ trunk/2010/2_hw.cc	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,651 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+
+#include <stdlib.h>
+#include <stdio.h>  //FIX ME (ONLY TEMP NEEDED)
+#include <pc.h>
+#include <go32.h>
+#include <dpmi.h>
+#include <sys/nearptr.h>
+#include <signal.h>
+#include <errno.h>
+#include "2_all.h"
+#include "2_hw.h"
+#include "2_hw_asm.h"
+#include "2_hw_mem.h"
+#include "2_71x6.h"
+#include "2_mouse.h"
+#include "2_mmx.h"
+#include "2010.h"
+
+ extern int NoInt8;
+
+ extern byte lock_start, lock_end;
+ extern dword old_int8_vect_offset;
+ extern  word old_int8_vect_selector;
+ extern byte int8_handler;
+ extern int bpp;
+
+ extern volatile long timer_count;
+ extern volatile __dpmi_regs mouse_regs;
+ extern volatile int mouse_handler_enable;
+ extern volatile int page_flip;
+ extern volatile int yuvmode;
+ extern volatile AllocList *alloclist;
+ extern volatile grstate grab_state;
+ extern volatile int fresh_cursor;
+ extern volatile xxx dispbuf, grab_dispbuf;
+ extern volatile int one_field;
+ extern volatile int active_meteor;
+ extern volatile meteor meteors[8];
+ extern volatile int fields;
+ extern int mouse_x,  mouse_y,  mouse_b;
+ extern int mouse_lx, mouse_ly;
+ extern byte *vidbuf;
+ extern int xres, yres, xresc, xresvb, vb, mc;
+ extern mouse_sprites cursor;
+ extern char *yuv2rgb_lut;
+ extern byte *mouse_buff[2];
+ extern int amb;    //active_mouse_buffer
+ extern int single;
+ extern int in_int;
+ extern int mouse_tim;
+ extern int mouse_ltim;
+
+ int g_mode=0;
+ int m_mode=0;
+ extern u_short my_cs, my_ds;
+ asm("__esp: .long 0\n\t");
+
+ static inline void setdot(int xx, int yy, s_col c);
+ static inline s_col getdot(int xx, int yy);
+
+void mem2vid(byte *to, s_yuv *from, int num, int bpp){
+ int i;
+
+ if(yuvmode!=0){
+   num>>=1;
+   if(bpp==32){
+/*
+     U Y1 V Y2
+
+     esi from
+     ebp to
+     edi lut
+     ecx counter
+     eax (Y1 Y1 Y1 Y1 + LUT[ U ] + LUT[ V ]) | (Y2 Y2 Y2 Y2 + LUT[ U ] + LUT[ V ])
+     ebx Y1 Y1 Y1 Y1 + LUT[ U ] + LUT[ V ]
+     edx Y2 Y2 Y2 Y2 + LUT[ U ] + LUT[ V ] 
+     esp  
+  */
+     asm(//"int $3                            \n\t"
+         "pushl %%ebp                       \n\t"
+         "movl %%eax, %%ebp                 \n\t"
+         "movl %%esp, (__esp)               \n\t"
+
+         "1:                                \n\t"
+         "nop                               \n\t"       // U
+         "movl (%%esi), %%eax               \n\t"       //  V 1
+         "movl %%eax, %%ebx                 \n\t"       // U
+         "movl %%eax, %%edx                 \n\t"       //  V 1
+         "shrl $16, %%ebx                   \n\t"       // U
+         "andl $0x000000FF, %%eax           \n\t"       //  V 1
+         "andl $0x000000FF, %%ebx           \n\t"       // U
+         "andl $0xFE00FE00, %%edx           \n\t"       //  V 1
+         "shrl $1, %%edx                    \n\t"       // U
+         "movl     (%%edi, %%eax, 4), %%eax \n\t"       //  V 1
+         "movl 1024(%%edi, %%ebx, 4), %%ebx \n\t"       // U
+         "movl %%edx, %%esp                 \n\t"       //  V 1
+         "shrl $8, %%edx                    \n\t"       // U
+         "addl %%ebx, %%eax                 \n\t"       //  V 1
+         "orl %%edx, %%esp                  \n\t"       // U
+         "addl $8, %%ebp                    \n\t"       //  V 1
+         "movl %%esp, %%ebx                 \n\t"       // U
+         "movl %%esp, %%edx                 \n\t"       //  V 1
+         "shll $16, %%ebx                   \n\t"       // U
+         "andl $0x0000FFFF, %%edx           \n\t"       //  V 1
+         "orl %%edx, %%ebx                  \n\t"       // U
+         "movl %%esp, %%edx                 \n\t"       //  V 1
+         "shrl $16, %%edx                   \n\t"       // U
+         "andl $0xFFFF0000, %%esp           \n\t"       //  V 1
+         "orl %%esp, %%edx                  \n\t"       // U
+         "addl %%eax, %%ebx                 \n\t"       //  V 1
+         "addl %%eax, %%edx                 \n\t"       // U
+         "movl %%ebx, %%eax                 \n\t"       //  V 1
+         "orl %%edx, %%eax                  \n\t"       // U
+         "addl $4, %%esi                    \n\t"       //  V 1
+         "test $0x00808080, %%eax           \n\t"       // U
+         " jz 2f                            \n\t"       //  V 1
+
+         "movl %%ebx, %%eax                 \n\t"       // U
+         "nop                               \n\t"       //  V 1
+         "test $0x00800000, %%eax           \n\t"       // U
+         " jz 10f                           \n\t"       //  V 1
+         "test $0x00400000, %%eax           \n\t"       // U
+         " jz 11f                           \n\t"       //  V 1
+         "andl $0xFF00FFFF, %%ebx           \n\t"       // U
+         "jmp 10f                           \n\t"       //  V 1
+         "11:                               \n\t"
+         "orl $0x00FF0000, %%ebx            \n\t"       // U
+         "10:                               \n\t"       
+         "test $0x00008000, %%eax           \n\t"       // U
+         " jz 20f                           \n\t"       //  V 1
+         "test $0x00004000, %%eax           \n\t"       // U
+         " jz 21f                           \n\t"       //  V 1
+         "andl $0xFFFF00FF, %%ebx           \n\t"       // U
+         "jmp 20f                           \n\t"       //  V 1
+         "21:                               \n\t"
+         "orl $0x0000FF00, %%ebx            \n\t"       // U
+         "20:                               \n\t"       
+         "test $0x00000080, %%eax           \n\t"       // U
+         " jz 30f                           \n\t"       //  V 1
+         "test $0x00000040, %%eax           \n\t"       // U
+         " jz 31f                           \n\t"       //  V 1
+         "andl $0xFFFFFF00, %%ebx           \n\t"       // U
+         "jmp 30f                           \n\t"       //  V 1
+         "31:                               \n\t"
+         "orl $0x000000FF, %%ebx            \n\t"       // U
+         "30:                               \n\t"
+         "movl %%edx, %%eax                 \n\t"       // U
+         "nop                               \n\t"       //  V 1
+         "test $0x00800000, %%eax           \n\t"       // U
+         " jz 40f                           \n\t"       //  V 1
+         "test $0x00400000, %%eax           \n\t"       // U
+         " jz 41f                           \n\t"       //  V 1
+         "andl $0xFF00FFFF, %%edx           \n\t"       // U
+         "jmp 40f                           \n\t"       //  V 1
+         "41:                               \n\t"
+         "orl $0x00FF0000, %%edx            \n\t"       // U
+         "40:                               \n\t"       
+         "test $0x00008000, %%eax           \n\t"       // U
+         " jz 50f                           \n\t"       //  V 1
+         "test $0x00004000, %%eax           \n\t"       // U
+         " jz 51f                           \n\t"       //  V 1
+         "andl $0xFFFF00FF, %%edx           \n\t"       // U
+         "jmp 50f                           \n\t"       //  V 1
+         "51:                               \n\t"
+         "orl $0x0000FF00, %%edx            \n\t"       // U
+         "50:                               \n\t"       
+         "test $0x00000080, %%eax           \n\t"       // U
+         " jz 60f                           \n\t"       //  V 1
+         "test $0x00000040, %%eax           \n\t"       // U
+         " jz 61f                           \n\t"       //  V 1
+         "andl $0xFFFFFF00, %%edx           \n\t"       // U
+         "jmp 60f                           \n\t"       //  V 1
+         "61:                               \n\t"
+         "orl $0x000000FF, %%edx            \n\t"       // U
+         "60:                               \n\t"
+
+         "andl $0xFF7F7F7F, %%ebx           \n\t"       // U
+         "andl $0xFF7F7F7F, %%edx           \n\t"       //  V 1
+
+         "2:                                \n\t"
+         "addl %%ebx, %%ebx                 \n\t"       // U
+         "addl %%edx, %%edx                 \n\t"       //  V 1
+         "movl %%ebx, -8(%%ebp)             \n\t"       // U
+         "movl %%edx, -4(%%ebp)             \n\t"       //  V 1
+         "decl %%ecx                        \n\t"       // U
+         " jnz 1b                           \n\t"       //  V 1
+         "movl (__esp), %%esp               \n\t"
+         "popl %%ebp                        \n\t"
+         :
+         : "m" (xres<<1),
+           "D" (yuv2rgb_lut), "S" (from), "a" (to), "c" (num)
+         : "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi");
+
+
+
+
+
+
+   }
+   else{
+     for(i=0; i<num; i++){
+       to[i*6  ]= (byte)( from[i].y1 + yuv2rgb_lut[(int(from[i].u)<<1) + 1  ] );
+       to[i*6+1]= (byte)( from[i].y1 + yuv2rgb_lut[(int(from[i].v)<<1) + 512] + yuv2rgb_lut[int(from[i].u)<<1] ); 
+       to[i*6+2]= (byte)( from[i].y1 + yuv2rgb_lut[(int(from[i].v)<<1) + 513] ); 
+       to[i*6+3]= (byte)( from[i].y2 + yuv2rgb_lut[(int(from[i].u)<<1) + 1  ] ); 
+       to[i*6+4]= (byte)( from[i].y2 + yuv2rgb_lut[(int(from[i].v)<<1) + 512] + yuv2rgb_lut[int(from[i].u)<<1] ); 
+       to[i*6+5]= (byte)( from[i].y2 + yuv2rgb_lut[(int(from[i].v)<<1) + 513] ); 
+     }
+   }
+ }else{
+   if(bpp==32) memcpy(to, from, num<<2);
+   else{
+     if(num>>2==0) return;
+     asm("//int $3                   \n\t"
+           "0:                       \n\t"
+           "movl  (%%esi), %%eax     \n\t"    // U
+           "movl 4(%%esi), %%edx     \n\t"    //  V 1
+           "rorl $8, %%edx           \n\t"    // UV 1
+           "movl %%edx, %%ebx        \n\t"    // U
+           "andl $0xff000000, %%edx  \n\t"    //  V 1
+           "orl %%edx, %%eax         \n\t"    // U
+           "andl $0x0000ffff, %%ebx  \n\t"    //  V 1
+
+           "movl %%eax, (%%edi)      \n\t"    // U
+           "movl 8(%%esi), %%edx     \n\t"    //  V 1
+           "rorl $16, %%edx          \n\t"    // UV 1
+           "movl %%edx, %%eax        \n\t"    // U
+           "andl $0xffff0000, %%edx  \n\t"    //  V 1
+           "orl %%edx, %%ebx         \n\t"    // U
+           "andl $0x000000ff, %%eax  \n\t"    //  V 1
+
+           "movl %%ebx, 4(%%edi)     \n\t"    // U
+           "movl 12(%%esi), %%edx    \n\t"    //  V 1
+           "rorl $24, %%edx          \n\t"    // UV 1
+           "orl %%edx, %%eax         \n\t"    // U
+
+           "addl $16, %%esi          \n\t"    //  V 1
+           "movl %%eax, 8(%%edi)     \n\t"    // U
+           "addl $12, %%edi          \n\t"    //  V 1
+           "decl %%ecx               \n\t"    // U
+           " jnz 0b                  \n\t"    //  V 1
+           :
+           : "S" (from), "D" (to), "c" (num>>2)
+           : "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi");
+
+   }
+ }
+}
+
+void disabled_call_mouse_handler(void){
+
+  if(mouse_handler_enable==0) return;
+  mouse_handler_enable=0;
+  mouse_regs.x.ax=0;
+  mouse_handler();
+  mouse_regs.x.ax=1;
+  mouse_handler_enable=1;
+}
+
+void mouse_handler(void){
+ int i, j, k, l;
+ color c;
+
+ if((mouse_handler_enable==0 && mouse_regs.x.ax!=0) || in_int!=0) return;
+ in_int++;
+
+ mouse_b=mouse_regs.x.bx;
+ mouse_x=mouse_regs.x.cx;
+ mouse_y=mouse_regs.x.dx;
+
+ if(mouse_x>=xres) mouse_x=xres-1;
+ if(mouse_y>=yres) mouse_y=yres-1;
+                          
+ for(j=0; j < cursor.y && mouse_y + j - cursor.hoty < yres; j++){
+   if(j + mouse_y - cursor.hoty>=0){
+     for(i=0  ; i < cursor.x && mouse_x + i - cursor.hotx < xres; i++){
+       if(  i + mouse_x - cursor.hotx>=0){
+         k=cursor.data[i + (j + mouse_tim*cursor.y)*cursor.x];
+   
+         int d_x=mouse_x - mouse_lx + i;
+         int d_y=mouse_y - mouse_ly + j;
+         if(   d_x >= 0 && d_x < cursor.x
+            && d_y >= 0 && d_y < cursor.y && fresh_cursor==0)
+           c.c.a=*(u_long *)(mouse_buff[amb] + (d_x + d_y*cursor.x)*vb);
+         else
+           c.c=getdot(mouse_x + i - cursor.hotx, mouse_y + j - cursor.hoty);
+
+         *(u_long *)(mouse_buff[amb^1] + (i + j*cursor.x)*vb)=c.c.a;
+  
+         if(k!=255)
+           c.c.rgb.r= c.c.rgb.g= c.c.rgb.b= k<<3;
+       
+         setdot(mouse_x + i - cursor.hotx, mouse_y + j - cursor.hoty, c.c);
+  
+       }
+     }
+   }
+ }
+  
+ for(j=0; j < cursor.y && mouse_ly + j - cursor.hoty < yres; j++){
+   if(j + mouse_ly - cursor.hoty>=0){
+     for(i=0; i < cursor.x && mouse_lx + i - cursor.hotx < xres; i++){
+       if(  i + mouse_lx - cursor.hotx>=0){
+         k=i - mouse_x + mouse_lx;
+         l=j - mouse_y + mouse_ly;
+         if(  k<0 || k>=cursor.x
+           || l<0 || l>=cursor.y){
+
+           if(cursor.data[i + (j + mouse_ltim*cursor.y)*cursor.x]!=255
+              && fresh_cursor==0){
+             c.c.a=*(u_long *)(mouse_buff[amb] + (i + j*cursor.x)*vb);
+             setdot(mouse_lx + i - cursor.hotx, mouse_ly + j - cursor.hoty, c.c);             
+           }
+         }
+       }
+     }
+   }
+ }
+
+ amb^=1;
+ fresh_cursor=0;
+ mouse_lx=mouse_x;
+ mouse_ly=mouse_y;
+ mouse_ltim=mouse_tim;
+ mouse_tim=timer_count % cursor.z;
+
+
+ in_int--;
+}
+
+static inline void setdot(int xx, int yy, s_col c){
+ int ppvb=xx*vb + yy*xresvb;             
+
+ if(page_flip==1) ppvb+=xresvb*yres;
+
+  vidbuf[ppvb  ]=c.rgb.b;
+  vidbuf[ppvb+1]=c.rgb.g;
+  vidbuf[ppvb+2]=c.rgb.r;
+}
+
+static inline s_col getdot(int xx, int yy){
+ int ppvb=xx*vb + yy*xresvb;             
+
+ if(page_flip==1) ppvb+=xresvb*yres;
+
+ return *(s_col* )(vidbuf + ppvb);;
+}
+
+void close_hw(void){
+ __dpmi_regs r;
+ __dpmi_paddr address;
+
+ if(m_mode==1){
+  r.x.ax=0;
+  __dpmi_int(0x33, &r);   //reset mouse
+
+  address.offset32=old_int8_vect_offset;
+  address.selector=old_int8_vect_selector;
+  __dpmi_set_protected_mode_interrupt_vector(8, &address);
+
+ }
+ m_mode=0;
+
+ close_meteor();
+ unlockall();
+ unmapall();
+
+ if(g_mode==1){
+   r.x.ax = 0x4F02;
+   r.x.bx = 0x0003;
+   __dpmi_int(0x10, &r);
+   r.x.ax = 0x0003;
+   __dpmi_int(0x10, &r);
+ }
+
+ g_mode=0;
+
+ dpmi_freeall(&alloclist);
+ vds_freeall();
+}
+
+void sig_handler(int i){
+ close_hw();
+ signal(i, SIG_DFL); 
+ raise(i);
+}
+
+void end_func(void){}
+
+void init_hw(void){
+ __dpmi_regs r; 
+ static _go32_dpmi_seginfo mouse_info;
+ __dpmi_paddr address;
+
+ my_cs=_go32_my_cs();
+ my_ds=_go32_my_ds();
+
+ r.x.ax=0;
+ __dpmi_int(0x33, &r);   //reset mouse
+ if(r.x.ax==0) error(NoMouse);
+
+ r.x.ax=7;
+ r.x.cx=0;
+ r.x.dx=xres;
+ __dpmi_int(0x33, &r);   //set horizontal cursor range
+
+ r.x.ax=8;
+ r.x.cx=0;
+ r.x.dx=yres;
+ __dpmi_int(0x33, &r);   //set vertical cursor range
+
+ r.x.ax=4;
+ r.x.cx=0;
+ r.x.dx=0;
+ __dpmi_int(0x33, &r);   //set mouse pos
+
+ // set Mouse Handler 
+
+ save_selectors();
+
+ if(__dpmi_get_protected_mode_interrupt_vector(8, &address)!=0) error(DPMI);
+ old_int8_vect_offset  =address.offset32;
+ old_int8_vect_selector=address.selector;
+
+ m_mode=1;
+
+
+ lock(&lock_start, &lock_end);
+
+ lock(&disabled_call_mouse_handler, &end_func);
+
+ lock(cursor.data   , cursor.data + cursor.x * cursor.y * cursor.z);
+
+ lock(mouse_buff[0] , mouse_buff[0] + (cursor.x * cursor.y<<2) );
+ lock(mouse_buff[1] , mouse_buff[1] + (cursor.x * cursor.y<<2) );
+
+ lock(meteor_int_handler, meteor_int_handler_end);
+
+
+ address.offset32=(unsigned long)(&int8_handler);
+ address.selector=my_cs;
+ if(NoInt8==0)
+  if(__dpmi_set_protected_mode_interrupt_vector(8, &address)!=0) error(DPMI);
+
+
+ mouse_info.pm_offset=(unsigned long) mouse_handler;
+
+ if((_go32_dpmi_allocate_real_mode_callback_retf(&mouse_info, (__dpmi_regs*)(&mouse_regs)))
+    !=0) error(MouseHand);
+
+ r.x.ax=0x0c;
+ r.x.cx=1+2+4+8+16+32+64;
+ r.x.es=mouse_info.rm_segment;
+ r.x.dx=mouse_info.rm_offset;
+ __dpmi_int(0x33, &r);   //set Handler
+
+}
+
+VesaInfoBlock *get_vesa_info(void)
+{
+        static VesaInfoBlock info;
+	__dpmi_regs r;
+
+        strcpy((char *)&info, "VBE2");  //request vbe2-info
+        dosmemput(&info, 4, __tb); // store in buffer
+
+	/* Use the transfer buffer to store the results of VBE call */
+        r.x.ax = 0x4F00;
+	r.x.es = __tb / 16;
+	r.x.di = 0;
+	__dpmi_int(0x10, &r);
+        if(r.x.ax!=0x004F) return 0;
+        dosmemget(__tb, 512, &info);
+        return &info;
+}
+
+ModeInfoBlock *get_mode_info(int mode)
+{
+         static ModeInfoBlock info;
+	__dpmi_regs r;
+
+	/* Use the transfer buffer to store the results of VBE call */
+	r.x.ax = 0x4F01;
+	r.x.cx = mode;
+	r.x.es = __tb / 16;
+	r.x.di = 0;
+	__dpmi_int(0x10, &r);
+        if(r.x.ax!=0x004F) return 0;
+	dosmemget(__tb, sizeof(ModeInfoBlock), &info);
+	return &info;
+}
+
+void set_start_disp(int x, int y){
+ __dpmi_regs r; 
+
+  r.x.ax=0x4F07;            //set/get start of display "window"
+  r.x.cx=x;
+  r.x.dx=y;
+  r.x.bx=0;
+  __dpmi_int(0x10, &r);
+  if(r.x.ax!=0x4F) error(VESAFlip);
+}
+
+void copy_vidbuffer(void){
+ int i, j;
+
+ if(page_flip==0){
+   for(i=0; i<yres; i++){
+     mem2vid(vidbuf + i*xresvb, (s_yuv*)((byte*)(dispbuf.yuv) + i*xresc), xres, bpp); 
+
+     if(mouse_y - cursor.hoty <= i && mouse_y + cursor.y - cursor.hoty > i){
+       disabled_call_mouse_handler();
+       mouse_handler_enable=0;
+       int mouse__x =mouse_x            - cursor.hotx;
+       int mouse__xe=mouse_x + cursor.x - cursor.hotx;
+       int mouse__ye=mouse_y + cursor.y - cursor.hoty;
+
+       if(mouse__x<0) mouse__x=0;
+       else if(mouse__xe>=xres) mouse__xe=xres-1;
+       if(mouse__ye>=yres) mouse__ye=yres-1;
+
+       j=mouse__xe & (~1);
+
+       for(; i < yres && i < mouse__ye; i++ ){
+         mem2vid(vidbuf + i*xresvb, (s_yuv*)((byte*)(dispbuf.yuv) + i*xresc), mouse__x, bpp);
+         mem2vid(vidbuf + i*xresvb + j*vb,
+                   (s_yuv*)((byte*)(dispbuf.yuv) + (i*xresc + (j<<mc))),
+                                                            xres - j - 1, bpp);
+       }
+       i--;
+       mouse_handler_enable=1;
+     }
+   }
+ }else if(page_flip==2){
+   mem2vid(vidbuf+xresvb*yres, dispbuf.yuv, xres*yres, bpp);
+   page_flip=1;
+   fresh_cursor=1;
+   disabled_call_mouse_handler();
+   set_start_disp(0, yres);
+ }else{
+   mem2vid(vidbuf,            dispbuf.yuv, xres*yres, bpp);
+   page_flip=2;
+   fresh_cursor=1;
+   disabled_call_mouse_handler();
+   set_start_disp(0, 0);
+ }
+
+ if(grab_state==Skiped){
+   volatile xxx temp=dispbuf;
+   dispbuf=grab_dispbuf;
+   grab_dispbuf=temp;
+
+   grab_next();
+   fields=0;  //FIX ME ? -1 or what       
+   meteors[active_meteor].saa7116->capt_ctl=(capt_c){
+       cont_even: 1, cont_odd: 1, sing_even: 0, sing_odd: 0,
+       done_even: 1, done_odd: 1, VRSTN:     1, fifo_en:  1,
+       corr_even: 1, corr_odd: 1, aerr_even: 1, aerr_odd: 1,
+       res1:      0, corr_dis: 0, range_en:  1, res2:     0};
+                                    //   0x8FF3 resume grab
+   grab_state=NotReady;
+ }
+ else{
+   meteors[active_meteor].saa7116->capt_ctl=(capt_c){
+       cont_even: 1, cont_odd: 1, sing_even: 0, sing_odd: 0,
+       done_even: 1, done_odd: 1, VRSTN:     1, fifo_en:  1,
+       corr_even: 1, corr_odd: 1, aerr_even: 1, aerr_odd: 1,
+       res1:      0, corr_dis: 0, range_en:  1, res2:     0};
+                                    //   0x8FF3 resume grab
+   grab_state=Waiting;
+   while(grab_state==Waiting);
+
+ }
+/*
+ printf("X\nDMA E0 START %X\n",  meteors[active_meteor].saa7116->dma.even[0]);
+ printf("DMA E1 START %X\n",  meteors[active_meteor].saa7116->dma.even[1]);
+ printf("DMA E2 START %X\n",  meteors[active_meteor].saa7116->dma.even[2]);
+ printf("DMA O0 START %X\n",  meteors[active_meteor].saa7116->dma.odd[0]);
+ printf("DMA O1 START %X\n",  meteors[active_meteor].saa7116->dma.odd[1]);
+ printf("DMA O2 START %X\n",  meteors[active_meteor].saa7116->dma.odd[2]);
+
+ printf("STRIDE E0 %X\n",  meteors[active_meteor].saa7116->stride.even[0]);
+ printf("STRIDE E1 %X\n",  meteors[active_meteor].saa7116->stride.even[1]);
+ printf("STRIDE E2 %X\n",  meteors[active_meteor].saa7116->stride.even[2]);
+ printf("STRIDE O0 %X\n",  meteors[active_meteor].saa7116->stride.odd[0]);
+ printf("STRIDE O1 %X\n",  meteors[active_meteor].saa7116->stride.odd[1]);
+ printf("STRIDE O2 %X\n",  meteors[active_meteor].saa7116->stride.odd[2]);
+
+ printf("DMA E END %X\n",  meteors[active_meteor].saa7116->dma_end.even);
+ printf("DMA O END %X\n",  meteors[active_meteor].saa7116->dma_end.odd);
+  */
+}
+
+u_long read_pci(int bus, int dev, int func, int reg, int size){
+ confadd ca;
+ u_long u;
+
+ ca.a=0;
+ ca.f.enable=1;
+ ca.f.bus=bus;
+ ca.f.dev=dev;
+ ca.f.func=func;
+ ca.f.reg=reg>>2;
+
+ outportl(confadd_port, ca.a);             
+ u=inportl(confdata_port);                 
+ ca.f.enable=0;                            
+ outportl(confadd_port, ca.a);             
+
+ u >>= (reg & 3);
+ u &=0xFFFFFFFF >> (32-(size<<3));
+
+ return u;
+}
+
+void write_pci(int bus, int dev, int func, int reg, int size, u_long dat){
+ confadd ca;
+ u_long u;
+
+ ca.a=0;
+ ca.f.enable=1;
+ ca.f.bus=bus;
+ ca.f.dev=dev;
+ ca.f.func=func;
+ ca.f.reg=reg>>2;
+
+ u=read_pci(bus, dev, func, reg, size);
+
+ outportl(confadd_port, ca.a);
+
+ if(size==4)      outportl(confdata_port             , dat);
+ else if(size==2) outportw(confdata_port + (reg & 3) , dat);
+ else             outportb(confdata_port + (reg & 3) , dat);
+
+ ca.f.enable=0;
+ outportl(confadd_port, ca.a);
+}
+
+int check_mmx(void){
+ int ret;
+ asm("movl $1, %%eax          \n\t"
+     "cpuid                   \n\t" 
+     "andl $0x00800000, %%edx \n\t"
+     "shrl $23, %%edx         \n\t"
+     : "=d"(ret)
+     :
+     : "%eax", "%ebx", "%ecx");
+
+ return ret;
+}

Added: trunk/2010/2_hw.h
==============================================================================
--- (empty file)
+++ trunk/2010/2_hw.h	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,95 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+#ifndef n2_hw_h
+#define n2_hw_h
+
+#define confadd_port  0xCF8
+#define confdata_port 0xCFC 
+                            
+#define PCI_IO_vendev  0x00    
+#define PCI_IO_command 0x04   
+#define PCI_IO_latency 0x0D 
+#define PCI_IO_base    0x10 
+#define PCI_IO_irq     0x3C  
+                             
+#define PCI_command_io     0x1
+#define PCI_command_memory 0x2
+#define PCI_command_master 0x4
+
+union confadd{
+ struct{
+  unsigned res:2;
+  unsigned reg:6;
+  unsigned func:3;
+  unsigned dev:5;
+  unsigned bus:8;
+  unsigned res2:7;
+  unsigned enable:1;
+ }f ;
+ u_long a;
+};
+
+struct ModeInfoBlock {
+  word  ModeAttrib  __attribute__ ((packed));
+  byte  WinAAttrib  __attribute__ ((packed));
+  byte  WinBAttrib  __attribute__ ((packed));
+  word  WinGranul   __attribute__ ((packed));
+  word  WinSize     __attribute__ ((packed));
+  word  SegA        __attribute__ ((packed));
+  word  SegB        __attribute__ ((packed));
+  dword FarFunc     __attribute__ ((packed));
+  word  BLine       __attribute__ ((packed));
+  word  Xres        __attribute__ ((packed));
+  word  Yres        __attribute__ ((packed));
+  byte  Xchar       __attribute__ ((packed));
+  byte  Ychar       __attribute__ ((packed));
+  byte  planes      __attribute__ ((packed));
+  byte  bpp         __attribute__ ((packed));
+  byte  banks       __attribute__ ((packed));
+  byte  model       __attribute__ ((packed));
+  byte  BankSize    __attribute__ ((packed));
+  byte  pages       __attribute__ ((packed));
+  byte  bogus1      __attribute__ ((packed));
+  byte  RSize       __attribute__ ((packed));
+  byte  RPos        __attribute__ ((packed));
+  byte  GSize       __attribute__ ((packed));
+  byte  GPos        __attribute__ ((packed));
+  byte  BSize       __attribute__ ((packed));
+  byte  BPos        __attribute__ ((packed));
+  byte  XSize       __attribute__ ((packed));
+  byte  XPos        __attribute__ ((packed));
+  byte  DirectInfo  __attribute__ ((packed));
+  dword PhysBase    __attribute__ ((packed));
+  byte  bogus2[228] __attribute__ ((packed));
+};
+
+struct VesaInfoBlock{
+  byte   signature[4]    __attribute__ ((packed));
+  word   ver             __attribute__ ((packed));
+  byte  *OemSPointer     __attribute__ ((packed));
+  dword  capab           __attribute__ ((packed));
+  byte  *modes           __attribute__ ((packed));
+  word   mem64k          __attribute__ ((packed));
+  word   oem_ver         __attribute__ ((packed));
+  byte  *oem_vendorname  __attribute__ ((packed));
+  byte  *oem_productname __attribute__ ((packed));
+  byte  *oem_revisionstr __attribute__ ((packed));
+  byte   bogus[478]      __attribute__ ((packed));
+};
+
+void mouse_handler(void);
+void set_start_disp(int x, int y);
+void init_hw(void);
+void setpal(void);
+ModeInfoBlock *get_mode_info(int mode);
+VesaInfoBlock *get_vesa_info(void);
+void close_hw(void);
+void copy_vidbuffer(void);
+void disabled_call_mouse_handler(void);
+void sig_handler(int i);
+void end_func(void);
+u_long read_pci(int,int,int,int,int);
+void write_pci(int,int,int,int,int,u_long);
+void mem2vid(byte *to, s_yuv *from, int num, int bpp);
+int check_mmx(void);
+
+#endif

Added: trunk/2010/2_hw_asm.h
==============================================================================
--- (empty file)
+++ trunk/2010/2_hw_asm.h	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,8 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+#ifndef n2_hw_asm_h
+#define n2_hw_asm_h
+
+void save_selectors(void);
+void real_int(short interrupt, __dpmi_regs *);
+
+#endif

Added: trunk/2010/2_hw_mem.cc
==============================================================================
--- (empty file)
+++ trunk/2010/2_hw_mem.cc	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,443 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <go32.h>
+#include <dpmi.h>
+#include <string.h>
+#include <sys/nearptr.h>
+#include <sys/farptr.h>
+#include "2_all.h"
+#include "2_hw_mem.h"
+#include "2010.h"
+
+ extern volatile xxx dispbuf, last_dispbuf, grab_dispbuf;
+ extern volatile LockList  *locklist;
+ extern volatile AllocList *alloclist;
+ extern volatile VdsList *vdslist;
+ extern volatile MapList *maplist;
+
+ dds g_vds_info={size: 0, offset: 0, selector: 0, id: 0, phys: 0};
+
+void locklin(void *start, void *end){
+ volatile LockList *llp, *llp2;
+ __dpmi_meminfo meminfo;
+
+ llp=new LockList;
+ llp2=locklist;
+ while(llp2!=NULL && llp2->next!=NULL) llp2=llp2->next;
+
+ meminfo.address=(unsigned long)(start);
+ meminfo.size=(unsigned long)(end - start);
+ if(__dpmi_lock_linear_region(&meminfo)!=0) error(Lock);
+
+ if(llp2!=NULL) llp2->next=llp;
+ else locklist=llp2=llp;
+ llp->start=start;
+ llp->end=end;
+ llp->next=NULL;
+}
+
+void unlocklin(void *start, void *end){
+ volatile LockList *llp, *llp2;
+ __dpmi_meminfo meminfo;
+
+ llp=locklist;
+ while(llp!=NULL && (llp->start!=start || llp->end!=end)) llp=llp->next;
+ if(llp==NULL){
+   while(llp!=NULL && ((llp->start!=start && llp->end!=end)
+                    || llp->start>start  || llp->end<end)) llp=llp->next;
+ }
+ if(llp==NULL) error(error_code(-8));
+
+ meminfo.address=(u_long)(start);
+ meminfo.size=(u_long)(end - start);
+ __dpmi_unlock_linear_region(&meminfo);
+
+ if(llp->start<start){
+   llp->end=start;
+ }else if(llp->end>end){
+   llp->start=end;
+ }else{
+   llp2=locklist;
+   while(llp2!=NULL && llp2->next!=llp) llp2=llp2->next;
+   if(llp2!=NULL){
+     llp2->next=llp->next;
+   }else{
+     locklist=llp->next;
+   }
+   delete llp;
+ }
+}
+
+void lock(void *start, void *end){
+ locklin(start + __djgpp_base_address, end + __djgpp_base_address);
+}
+
+void unlock(void *start, void *end){
+ unlocklin(start + __djgpp_base_address, end + __djgpp_base_address);
+}
+
+void unlockall(void){
+ volatile LockList *llp, *llp2;
+ __dpmi_meminfo meminfo;
+
+ llp=locklist;
+ while(llp!=NULL){
+   meminfo.address=(u_long)(llp->start);
+   meminfo.size=(u_long)(llp->end - llp->start);
+   __dpmi_unlock_linear_region(&meminfo);
+   llp2=llp;
+   llp=llp->next;
+   delete llp2;
+ }
+}
+
+void dpmi_addlinlock(volatile AllocList *old, volatile AllocList **al){
+ volatile AllocList *llp, *llp2;
+
+ llp=new AllocList;
+ llp2=*al;
+ while(llp2!=NULL && llp2->next!=NULL && llp2->next->phys<old->phys) llp2=llp2->next;
+
+ if(*al!=NULL && (*al)->phys>old->phys) llp2=NULL;
+
+ *llp=*old;
+ if(llp2==NULL){
+   llp->next=*al;
+   *al=llp;
+ }else{
+   llp->next=llp2->next;  
+   llp2->next=llp;
+ }
+}
+
+u_long dpmi_alloclinlock(volatile AllocList **al){
+ volatile AllocList *llp, *llp2;
+ __dpmi_meminfo meminfo;
+ u_long phys;
+
+ meminfo.size=4096;
+ if(__dpmi_allocate_memory(&meminfo)==-1) return 0;
+ if(__dpmi_lock_linear_region(&meminfo)==-1){
+   __dpmi_free_memory(meminfo.handle);
+   return 0;
+ }
+
+ if((meminfo.address & 4095) != 0) error(error_code(-90));
+
+ phys=getphys(meminfo.address);
+
+ llp=(AllocList *)(meminfo.address - __djgpp_base_address);
+ llp2=*al;
+ while(llp2!=NULL && llp2->next!=NULL && llp2->next->phys<phys) llp2=llp2->next;
+
+ if(*al!=NULL && (*al)->phys>phys) llp2=NULL;
+
+ if(llp2==NULL){
+   llp->next=*al;
+   *al=llp;
+ }else{
+   llp->next=llp2->next;
+   llp2->next=llp;
+ }
+ llp->addr=meminfo.address;
+ llp->hand=meminfo.handle;
+ llp->phys=phys;
+
+ return meminfo.address;
+}
+
+void dpmi_freelinlock(volatile AllocList *old, volatile AllocList **al){
+ volatile AllocList *llp2;
+ __dpmi_meminfo meminfo;
+
+
+ meminfo.address=old->addr;
+ meminfo.size=4096;
+ meminfo.handle=old->hand;
+
+ llp2=*al;
+ while(llp2!=NULL && llp2->next!=old) llp2=llp2->next;
+ if(llp2!=NULL){
+   llp2->next=old->next;
+ }else{
+   *al=old->next;
+ }
+
+ if((u_long)old + __djgpp_base_address != meminfo.address) delete old;
+
+ if(meminfo.handle!=0){
+   __dpmi_unlock_linear_region(&meminfo);
+   __dpmi_free_memory(meminfo.handle);
+ }
+
+}
+
+void dpmi_freeall(volatile AllocList **al){
+ volatile AllocList *llp, *llp2;
+ __dpmi_meminfo meminfo;
+
+ llp=*al;
+ while(llp!=NULL){
+   meminfo.address=llp->addr;
+   meminfo.size=4096;
+   meminfo.handle=llp->hand;
+   llp2=llp;
+   llp=llp->next;
+   if((u_long)llp2 + __djgpp_base_address != meminfo.address) delete llp2;
+   if(meminfo.handle!=0){
+     __dpmi_unlock_linear_region(&meminfo);
+     __dpmi_free_memory(meminfo.handle);
+   }
+ }
+ *al=NULL;
+}
+
+
+xxx alloc_cont(int size){
+ int i=0;
+ xxx ret;
+ u_long lphys, addr, maxaddr;
+ int count, maxcount;
+ volatile AllocList *llp, *llp2, *temp_al=NULL;
+ __dpmi_meminfo meminfo;
+ int length;
+ dds vds_info;
+
+ size= (size + 4095) & (~4095);     //round up to next 4096 boundray
+
+ checkVDS();
+
+ 
+ addr=(u_long)map(2048*1024, 2048*1024 + 1024*1024);  //check if mapping of RAM is ok
+ unmap((void*)addr);
+
+ if(g_vds_info.phys==0 && g_vds_info.size==0){
+   vds_info=vds_alloc(size<<1);
+   if(vds_info.phys==0xFFFFFFFF)
+     vds_info=vds_alloc(size);
+   else
+     g_vds_info=vds_info;
+ }
+ else{
+   vds_info=g_vds_info;
+   vds_info.phys+=size;
+ }
+ if(vds_info.phys==0xFFFFFFFF){
+   length=maxcount=maxaddr=0;
+
+   while(size>maxcount){
+     if(dpmi_alloclinlock(&temp_al)==0){
+       dpmi_freeall(&temp_al);
+       error(MemAlloc);
+     }
+  
+     llp=temp_al;
+     lphys=count=addr=0;
+     while(llp!=NULL){
+       if((lphys + 4096) == llp->phys && (llp->phys & (1024*1024*4-1)) != 0)
+         count+=4096;
+       else{
+         count=0;
+         addr=llp->phys;
+       }
+       if(count>maxcount){
+         maxcount=count;
+         maxaddr=addr;
+       }
+       lphys=llp->phys;
+  
+       llp=llp->next;
+     }
+     length+=4096;
+     printf("Allocated %d, MaxCont %d, at Address %lX\r",length , maxcount, maxaddr);
+     fflush(stdout);
+   }
+   printf("\n");
+  
+   llp=temp_al;
+   while(llp!=NULL){
+     llp2=llp;
+     llp=llp->next;
+     if(llp2->phys<maxaddr){
+       dpmi_freelinlock(llp2, &temp_al);
+     }
+     else if(llp2->phys>maxaddr+maxcount){
+       dpmi_freelinlock(llp2, &temp_al);
+     }
+     else{
+       dpmi_addlinlock(llp2, &alloclist);
+     }
+   }
+ }else{
+   maxaddr=vds_info.phys;
+   printf("AllocatedContVDS %d, at Address %lX\n", size , maxaddr);
+   fflush(stdout);
+ }
+ meminfo.size=size;
+ meminfo.address=maxaddr;
+ ret.b=(byte*)(map(maxaddr, maxaddr+size) - __djgpp_base_address);
+
+ memset(ret.b, 0, size);
+
+ i=~(1024*1024*4-1);
+ if( (maxaddr & i) != ((maxaddr+size) & i) ) error(MemAlloc);
+ //FIX ME (should be retried until ok)
+ ret.phys=maxaddr;
+ return ret;
+
+}
+                                   
+void checkVDS(void){               
+
+ if((_farpeekb(_dos_ds, 0x47B) & 32) != 32) error(NoVDS);
+
+}
+
+u_long getphys(u_long addr){
+__dpmi_regs r;
+dds info;
+
+ info.selector=0;
+ info.size=4096;
+ info.offset=addr;
+
+ dosmemput(&info, sizeof(dds), __tb); // store in buffer
+
+ r.x.ax=0x8103;
+ r.x.dx=4;
+ r.x.es = __tb >> 4;
+ r.x.di = 0;
+ __dpmi_int(0x4B, &r);
+ if((r.x.flags & carry_flag) == carry_flag) error(VDS);
+ dosmemget(__tb, sizeof(dds), &info);
+
+ r.x.ax=0x8104;
+ r.x.dx=0;
+ r.x.es = __tb >> 4;
+ r.x.di = 0;
+ __dpmi_int(0x4B, &r);
+ if((r.x.flags & carry_flag) == carry_flag) error(VDS);
+
+ return info.phys;
+
+}
+
+dds vds_alloc(int size){
+ dds vds_info;
+ __dpmi_regs r;
+ volatile VdsList *vd;
+
+ vds_info.size=size;
+
+ dosmemput(&vds_info, sizeof(dds), __tb); // store in buffer
+
+ r.x.ax=0x8107;
+ r.x.dx=0;
+ r.x.es=__tb >> 4;
+ r.x.di=0;
+
+ __dpmi_int(0x4B, &r);
+ if((r.x.flags & carry_flag) == carry_flag){
+   vds_info.phys=0xFFFFFFFF;
+   return vds_info;
+ };
+ dosmemget(__tb, sizeof(dds), &vds_info);
+
+ vd=vdslist;
+ while(vd!=NULL && vd->next!=NULL) vd=vd->next;
+ if(vd==NULL){
+   vdslist=vd=new VdsList;
+ }else{
+   vd->next=new VdsList;
+   vd=vd->next;
+ }
+
+ vd->vds_info=vds_info;
+ vd->next=NULL;
+
+ return vds_info;
+}
+
+void vds_free(dds){
+
+ error( error_code(-99) );
+ // fix me
+
+}
+
+void vds_freeall(void){
+ __dpmi_regs r;
+ volatile VdsList *vd, *vd2;
+
+ vd=(VdsList*)vdslist;
+ while(vd!=NULL){
+   dosmemput((dds*)(&vd->vds_info), sizeof(dds), __tb); // store in buffer
+   r.x.ax=0x8108;
+   r.x.dx=0;
+   r.x.es=__tb >> 4;
+   r.x.di=0;
+
+   __dpmi_int(0x4B, &r);
+   vd2=vd;
+   vd=vd->next;
+   delete vd2;
+ }
+
+ vdslist=NULL;
+}
+
+void *map(u_long start, u_long end){
+ volatile MapList *llp, *llp2;
+ __dpmi_meminfo meminfo;
+
+ llp=new MapList;
+ llp2=maplist;
+ while(llp2!=NULL && llp2->next!=NULL) llp2=llp2->next;
+
+ meminfo.address=start;
+ meminfo.size=end - start;
+ if(__dpmi_physical_address_mapping(&meminfo)!=0) error(Map);
+
+ if(llp2!=NULL) llp2->next=llp;
+ else maplist=llp2=llp;
+ llp->start=(void*)meminfo.address;
+ llp->next=NULL;
+ return (void*)meminfo.address;
+}
+
+void unmap(void *start){
+ volatile MapList *llp, *llp2;
+ __dpmi_meminfo meminfo;
+
+ llp=maplist;
+ while(llp!=NULL && llp->start!=start) llp=llp->next;
+ if(llp==NULL) error(error_code(-19));
+
+ meminfo.address=(u_long)(start);
+ __dpmi_free_physical_address_mapping(&meminfo);
+
+ llp2=maplist;
+ while(llp2!=NULL && llp2->next!=llp) llp2=llp2->next;
+ if(llp2!=NULL){
+   llp2->next=llp->next;
+ }else{
+   maplist=llp->next;
+ }
+ delete llp;
+}
+
+void unmapall(void){
+ volatile MapList *llp, *llp2;
+ __dpmi_meminfo meminfo;
+
+ llp=maplist;
+ while(llp!=NULL){
+   meminfo.address=(u_long)(llp->start);
+   __dpmi_free_physical_address_mapping(&meminfo);
+   llp2=llp;
+   llp=llp->next;
+   delete llp2;
+ }
+}

Added: trunk/2010/2_hw_mem.h
==============================================================================
--- (empty file)
+++ trunk/2010/2_hw_mem.h	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,57 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+#ifndef n2_hw_mem_h
+#define n2_hw_mem_h
+
+#define carry_flag 1
+
+struct dds{
+ dword size;
+ dword offset;
+ word  selector;
+ word  id;
+ dword phys;
+};
+
+struct VdsList{
+ dds vds_info;
+ volatile VdsList *next;
+};
+
+struct LockList{
+ void *start;
+ void *end;
+ volatile LockList *next;
+};
+
+struct MapList{
+ void *start;
+ volatile MapList *next;
+};
+
+struct AllocList{
+ u_long addr;
+ u_long phys;
+ int hand;
+ volatile AllocList *next;
+};
+
+void locklin(void *, void *);
+void unlocklin(void *, void *);
+void lock(void *, void *);
+void unlock(void *, void *);
+void unlockall(void);
+void dpmi_addlinlock(volatile AllocList *old, volatile AllocList **al);
+u_long dpmi_alloclinlock(volatile AllocList **al);
+void dpmi_freelinlock(volatile AllocList *old, volatile AllocList **al);
+void dpmi_freeall(volatile AllocList **al);
+xxx alloc_cont(int size);
+void checkVDS(void);
+u_long getphys(u_long);
+dds vds_alloc(int size);
+void vds_free(dds vds_info);
+void vds_freeall(void);
+void *map(u_long start, u_long end);
+void unmap(void *start);
+void unmapall(void);
+
+#endif

Added: trunk/2010/2_menu.cc
==============================================================================
--- (empty file)
+++ trunk/2010/2_menu.cc	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,244 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+
+#include <stdlib.h>
+#include "2_all.h"
+#include "2_menu.h"
+#include "2_mfunc.h"
+#include "2_gfunc.h"
+
+ extern int xres, yres;
+ extern int buttons, xpos, ypos, lxpos, lypos;
+ extern int fysize;
+ extern int me, mx, my;
+ extern int infox, infoy, istate;
+ extern int cstate;
+ extern int yuvmode;
+ extern int v_smooth;
+
+ menu menu_main[mainend+1];
+ menu menu_config[end_config+1];
+ menu menu_hdeci[end_hdeci+1];
+ menu menu_vdeci[end_vdeci+1];
+ menu menu_std[end_std+1];
+
+ int grabf=0;
+ int init_menu=1;
+ menu *submenu[8]={0,0,0,0,0,0,0,0};  // max 7 levels of submenus 
+ int sub_x[8],  sub_y[8];
+ int sub_m=-1,  sub_my;
+ int sub_xcorr=0;
+ int sub_i[8]={-1,-1,-1,-1,-1,-1,-1,-1};
+
+void setmenu(void){
+ int i;
+
+ if(init_menu==1){
+  init_menu=0;
+
+  for(i=0; i<=mainend; i++){
+   menu_main[i].submenu=NULL;
+   menu_main[i].func=NULL;
+  }
+
+  for(i=0; i<=end_config; i++){
+   menu_config[i].submenu=NULL;
+   menu_config[i].func=NULL;
+   menu_config[i].c.init(menuinfocolor);
+  }
+  for(i=0; i<end_hdeci; i++){
+   menu_hdeci[i].submenu=NULL;
+   menu_hdeci[i].func=hdeci;
+  }
+  menu_hdeci[i].func=NULL;
+
+  for(i=0; i<end_vdeci; i++){
+   menu_vdeci[i].submenu=NULL;
+   menu_vdeci[i].func=vdeci;
+  }
+  menu_vdeci[i].func=NULL;
+
+  for(i=0; i<end_std; i++){
+   menu_std[i].submenu=NULL;
+   menu_std[i].func=mstd;
+  }
+  menu_std[i].func=NULL;
+
+  strcpy(menu_main[menuconfig].text,  "Config         ");
+  menu_main[menuconfig].submenu=menu_config;
+  menu_main[menuconfig].c.init(menuinfocolor);
+
+  menu_config[menuinfo].func=infoonoff;
+  menu_config[menucont].func=contonoff;
+  menu_config[menuvsmooth].func=vsmoothonoff;
+
+  menu_config[menuhdeci].func=menuf_hdeci;
+  menu_config[menuhdeci].submenu=menu_hdeci;
+  strcpy(menu_config[menuhdeci].text, "H-Decimation   ");
+
+  strcpy(menu_hdeci[menuhtapa].text, "Auto");
+  strcpy(menu_hdeci[menuhtapb].text, "Bypass");
+  strcpy(menu_hdeci[menuhtap2].text, "2-Tap Filter");
+  strcpy(menu_hdeci[menuhtap3].text, "3-Tap Filter");
+  strcpy(menu_hdeci[menuhtap4].text, "4-Tap Filter");
+  strcpy(menu_hdeci[menuhtap5].text, "5-Tap Filter");
+  strcpy(menu_hdeci[menuhtap8].text, "8-Tap Filter");
+  strcpy(menu_hdeci[menuhtap9].text, "9-Tap Filter");
+
+  menu_config[menuvdeci].func=menuf_vdeci;
+  menu_config[menuvdeci].submenu=menu_vdeci;
+  strcpy(menu_config[menuvdeci].text, "V-Decimation   ");
+
+  strcpy(menu_vdeci[menuvfila].text, "Auto");
+  strcpy(menu_vdeci[menuvfilb].text, "Bypass");
+  strcpy(menu_vdeci[menuvfil1].text, "Filter 1");
+  strcpy(menu_vdeci[menuvfil2].text, "Filter 2");
+
+  menu_config[menustd].func=menuf_std;
+  menu_config[menustd].submenu=menu_std;
+  strcpy(menu_config[menustd].text, "TV - Standart  ");
+
+  strcpy(menu_std[menupal]  .text, "PAL");
+  strcpy(menu_std[menuntsc] .text, "NTSC");
+  strcpy(menu_std[menusecam].text, "SECAM");
+  strcpy(menu_std[menuvc]   .text, "VideoCrypt");
+  strcpy(menu_std[menunag]  .text, "Nagravision");
+
+  strcpy(menu_main[menugrab].text, "Save as BMP");
+  menu_main[menugrab].func=grabm;
+  menu_main[menugrab].c.init(menugrabcolor);
+
+  strcpy(menu_main[menuexit].text, "Exit / Quit");
+  menu_main[menuexit].func=exit;
+  menu_main[menuexit].c.init(menugrabcolor);
+
+ }
+
+ if(istate==1)
+  strcpy(menu_config[menuinfo].text, "Info Off");
+ else
+  strcpy(menu_config[menuinfo].text, "Info On");
+
+ if(v_smooth==1)
+  strcpy(menu_config[menuvsmooth].text, "V-Smooth Off");
+ else
+  strcpy(menu_config[menuvsmooth].text, "V-Smooth On");
+
+ if(cstate==1)
+  strcpy(menu_config[menucont].text, "Control Off");
+ else
+  strcpy(menu_config[menucont].text, "Control On");
+}
+
+int find_menu_ysize(menu *m){
+ int i;
+
+ for(i=0; m[i].func!=NULL || m[i].submenu!=NULL; i++);
+ return i;
+}
+
+int find_menu_xsize(menu *m){
+ int i,j=0;
+
+ for(i=0; m[i].func!=NULL || m[i].submenu!=NULL; i++){
+  if(int(strlen(m[i].text))>j) j=strlen(m[i].text);
+ }
+ return j;
+}
+
+void disp_menu(menu *m, int mx, int my, int level){
+ int i, j, k, l, mysize, mxsize;
+ color c;
+
+ level++;
+ setmenu();
+ mysize=find_menu_ysize(m);
+ mxsize=find_menu_xsize(m);
+
+ if(level==1){
+  if(sub_m==-1 || me!=3){
+   sub_my=ypos;
+  }else{
+   sub_y[sub_m]-=sub_my-ypos;
+   sub_my=ypos;
+  }
+ }
+
+ l=0;
+ j=mx;
+ if(level==1) j += sub_xcorr;
+ if(j+mxsize*9>xres){
+  j=xres-mxsize*9;
+  k=sub_xcorr;
+  sub_xcorr+=j-mx;
+  for(i=0; i<level; i++) sub_x[i]+=sub_xcorr-k;
+ }
+
+ k=my;
+ if((fysize+1)*(mysize)<=yres){
+  if(k+(fysize+1)*(mysize)-2>yres){
+   k=yres-(fysize+1)*(mysize)-2;
+   sub_y[level-1]=k;
+  }
+  else if(my<0){
+   k=0;
+   sub_y[level-1]=k;
+  }
+ }else{
+  if(my+(fysize+1)*(mysize)-2<=yres){
+   k=yres-(fysize+1)*(mysize)-2;
+   sub_y[level-1]=k;
+  }
+
+  else if(my>=0){
+   k=0;
+   sub_y[level-1]=k;
+  }
+ }
+ for(i=0 ;m[i].func!=NULL || m[i].submenu!=NULL; i++){
+  rect(j-1, k+(fysize+1)*i, j+mxsize*9, k+(fysize+1)*(i+1)-2, m[i].c.c);
+  if(xpos>=j-1 && xpos<=j+mxsize*9 && ypos>=k+(fysize+1)*i
+                                   && ypos<=k+(fysize+1)*(i+1)-2){
+   c.c=m[i].c.c;
+   if(yuvmode!=0) c.c.yuv.y1=c.c.yuv.y2= c.c.yuv.y1+64;
+   else{          c.c.rgb.r+=64; c.c.rgb.g+=64; c.c.rgb.b+=64; }
+   gprint(j, k+(fysize+1)*i, c.c, m[i].text);
+   l=1;
+   if(m[i].submenu!=NULL){
+    sub_x[level]=j+mxsize*9+3;
+    sub_y[level]=k+(fysize+1)*i;
+    l=0;
+    if(m[i].func!=NULL && sub_i[level]!=i) m[i].func(i);
+    sub_i[level]=i;
+    submenu[level+1]=0;
+    sub_i[level+1]=-1;
+    submenu[level]=m[i].submenu;
+    sub_m=-1;
+   }
+   if(me==2){
+    if(m[i].func!=NULL) m[i].func(i);
+   }
+   if(me==3 && sub_m==-1 && level!=1 && (fysize+1)*(mysize)>yres){
+    sub_m=level-1;
+   }
+  }
+  else{
+   c.c=m[i].c.c;
+   if(yuvmode!=0) c.c.yuv.y1=c.c.yuv.y2= c.c.yuv.y1-64;
+   else{          c.c.rgb.r-=64; c.c.rgb.g-=64; c.c.rgb.b-=64; }
+   gprint(j, k+(fysize+1)*i, c.c, m[i].text);
+  }
+ }
+ if(l==0 && submenu[level]!=0){
+  disp_menu(submenu[level], sub_x[level], sub_y[level], level);
+ }else{
+  submenu[level]=0;
+  sub_i[level]=-1;
+ }
+
+ if(me==2){
+  submenu[level]=0;
+  sub_i[level]=-1;
+  sub_m=-1;
+  sub_xcorr=0;
+ }
+}

Added: trunk/2010/2_menu.h
==============================================================================
--- (empty file)
+++ trunk/2010/2_menu.h	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,74 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+#ifndef n2_menu_h
+#define n2_menu_h
+
+// leave colors for later use
+#define menugrabcolor     100, 50, 0 , yuvmode
+#define menuinfocolor     100, 0 , 50, yuvmode
+                          
+#define menuencolor       128, 0, 0, yuvmode
+#define menudiscolor      64 , 0, 0, yuvmode
+
+enum {
+ menuconfig,
+ menugrab,
+ menuexit,          
+ mainend,          
+};
+
+enum {
+ menuinfo,
+ menustd,
+ menucont,
+ menuvsmooth,
+ menuhdeci,
+ menuvdeci,
+ end_config,
+};
+
+enum {
+ menupal,
+ menuntsc,
+ menusecam,
+ menuvc,
+ menunag,
+ end_std,
+};
+
+enum {
+ menuhtap2,
+ menuhtap3,
+ menuhtap5,
+ menuhtap9,
+ menuhtapb,
+ menuhtapa,
+ menuhtap8,
+ menuhtap4,
+ end_hdeci,
+};
+
+enum {
+ menuvfilb,
+ menuvfila,
+ menuvfil1,
+ menuvfil2,
+ end_vdeci,
+};
+
+struct n_menu {
+ char text[32];
+ color c;
+ struct n_menu *submenu;
+ void (*func)(int);
+};
+
+typedef struct n_menu menu;
+
+void setmpos(void);
+void setmenu(void);
+int find_menu_xsize(menu *m);
+int find_menu_ysize(menu *m);
+void disp_menu(menu *m, int mx, int my, int level);
+
+
+#endif

Added: trunk/2010/2_mfunc.cc
==============================================================================
--- (empty file)
+++ trunk/2010/2_mfunc.cc	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,165 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+
+#include "2_all.h"
+#include "2_mfunc.h"
+#include "2_menu.h"
+#include "2010.h"
+#include "2_71x6.h"
+
+ extern int xres, yres, yrest, y_field, x_field;
+ extern int buttons, xpos, ypos, lxpos, lypos;
+ extern int me, mx, my;
+ extern menu menu_main[mainend+1];
+ extern menu menu_hdeci[end_hdeci+1];
+ extern menu menu_vdeci[end_vdeci+1];
+ extern menu menu_std[end_std+1];
+ extern int grabf;
+ extern int istate, cstate;
+ extern int yuvmode;
+ extern tv_form std;
+ extern crypt_form crypt;
+ extern int nagra_mode, one_field, v_smooth;
+
+ extern volatile u_char saa7196_buf[SAA7196_regs];
+ extern int v_smooth;
+
+ int hdeci_state=menuhtapa;
+ int vdeci_state=menuvfila;
+ int   std_state=menupal;
+
+void grabm(int){
+ grabf=1;
+}
+
+void infoonoff(int){
+ istate^=1;
+}
+
+void vsmoothonoff(int){
+ v_smooth^=1;
+}
+
+void contonoff(int){
+ cstate^=1;
+}
+
+void menuf_hdeci(int){
+
+ for(int i=0; i<end_hdeci; i++){
+   menu_hdeci[i].c.init(menudiscolor);
+ }
+ menu_hdeci[hdeci_state].c.init(menuencolor);
+}
+
+void menuf_vdeci(int){
+
+ for(int i=0; i<end_vdeci; i++){
+   menu_vdeci[i].c.init(menudiscolor);
+ }
+ menu_vdeci[vdeci_state].c.init(menuencolor);
+}
+
+void menuf_std(int){
+
+ for(int i=0; i<end_std; i++){
+   menu_std[i].c.init(menudiscolor);
+ }
+ menu_std[std_state].c.init(menuencolor);
+}
+
+void hdeci(int num){
+ int i;
+ 
+ i=hdeci_state;
+ hdeci_state=num;
+ if(i==menuhtapa && vdeci_state==menuvfila && num!=menuhtapa){
+   double d = ( (one_field==0) ? double(yrest>>1) : double(yrest) ) / double(y_field);
+        if( d <=  4.0/15.0) vdeci(menuvfil2);
+   else if( d <= 13.0/15.0) vdeci(menuvfil1);
+   else                     vdeci(menuvfilb);
+ }
+
+ if(num==menuhtapa) vdeci_state=menuvfila;
+
+
+ if(num==menuhtapa) i=0x80;
+ else               i=0   ;
+
+ write_saa7196(0x28, (saa7196_buf[0x28] & 0x7F) | i );
+                           /*   7  Adaptive filter switch
+                              6:5  Vertical luminance data processing
+                                4  [8] Vertical start of scaling window 
+                              3:2  [9:8] Line number per input field
+                              1:0  [9:8] Line number per output field      */
+
+ write_saa7196(0x24, (saa7196_buf[0x24] & 0x1F) | (num<<5) );
+                           /* 7:5  Horizontal decimation filter
+                                4  [8] Horizontal start position of scaling win
+                              3:2  [9:8] Pixel number per line on input
+                              1:0  [9:8] Pixel number per line on output   */
+
+}
+
+void vdeci(int num){
+ int i;
+ 
+ i=vdeci_state;
+ vdeci_state=num;
+ if(i==menuvfila && hdeci_state==menuhtapa && num!=menuvfila){
+   double d = double(xres) / double(x_field);
+        if( d <=  3.0/15.0) hdeci(menuhtap9);
+   else if( d <=  7.0/15.0) hdeci(menuhtap5);
+   else if( d <= 11.0/15.0) hdeci(menuhtap4);
+   else if( d <= 14.0/15.0) hdeci(menuhtap2);
+   else                     hdeci(menuhtapb);
+ }
+
+ if(num==menuvfila) hdeci_state=menuhtapa;
+
+ if(num==menuvfila) i=0x80;
+ else               i=num<<5;
+
+ write_saa7196(0x28, (saa7196_buf[0x28] & 0x1F) | i );
+                           /*   7  Adaptive filter switch
+                              6:5  Vertical luminance data processing
+                                4  [8] Vertical start of scaling window 
+                              3:2  [9:8] Line number per input field
+                              1:0  [9:8] Line number per output field      */
+}
+
+void mstd(int num){
+ int y=0, f=0, n=0;
+
+ std_state=num;
+
+ if(num==menupal)        std=PAL,   crypt=nix, y=0, f=0, n=0;
+ else if(num==menuntsc)  std=NTSC,  crypt=nix, y=0, f=0, n=0;
+ else if(num==menusecam) std=SECAM, crypt=nix, y=0, f=0, n=0;
+ else if(num==menuvc)    std=PAL,   crypt=vc , y=1, f=1, n=0;
+ else if(num==menunag)   std=PAL,   crypt=nag, y=1, f=1, n=1;
+
+ if(y==0 && yuvmode==1) yuvmode=0;
+ if(y==1 && yuvmode==0) yuvmode=1;
+
+ if(f==1){
+   vdeci(menuvfilb);
+   v_smooth=0;
+ }
+
+ if(n==1){
+   if(one_field==1 && yuvmode==2) error(MemAlloc);
+   nagra_mode=1;
+ }
+ else
+   nagra_mode=0;
+
+ for(int i=0; i<end_std; i++){
+   if(num!=i) menu_std[i].c.init(menudiscolor);
+   else       menu_std[i].c.init(menuencolor);
+ }
+
+ setstd_scale();
+
+ start_grab();
+
+}

Added: trunk/2010/2_mfunc.h
==============================================================================
--- (empty file)
+++ trunk/2010/2_mfunc.h	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,16 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+#ifndef n2_mfunc_h
+#define n2_mfunc_h
+
+void grabm(int num);
+void vsmoothonoff(int num);
+void infoonoff(int num);
+void contonoff(int num);
+void hdeci(int num);
+void vdeci(int num);
+void mstd(int num);
+void menuf_hdeci(int);
+void menuf_vdeci(int);
+void menuf_std(int);
+
+#endif

Added: trunk/2010/2_mmx.h
==============================================================================
--- (empty file)
+++ trunk/2010/2_mmx.h	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,13 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+#ifndef n2_mmx_h
+#define n2_mmx_h
+
+asm(".macro cpuid \n\t"
+    ".word 0xA20F \n\t"
+    ".endm        \n\t");
+
+asm(".macro emms  \n\t"
+    ".word 0x770F \n\t"
+    ".endm        \n\t");
+
+#endif

Added: trunk/2010/2_mouse.cc
==============================================================================
--- (empty file)
+++ trunk/2010/2_mouse.cc	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,61 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+
+#include <stdlib.h>
+#include "2_all.h"
+#include "2_mouse.h"
+#include "2_move.h"
+
+extern int buttons;
+extern int xpos, ypos, lxpos, lypos, xres, yres;
+extern pos_tab_list mpos_tab_list;
+
+int me=0, mx, my, pe=0;
+pos_tab *bpos_tab=NULL;
+
+void m_buttons(void){
+ pos_tab *pt;
+
+ pt=mpos_tab_list.start;
+ while(pt!=NULL && me==0 && pe==0){
+   if(pt->inside(xpos, ypos)) bpos_tab=pt;
+   pt=pt->next;
+ }
+
+ if(buttons==0) bpos_tab=NULL, pe=0;
+
+ if(me==0) mx=xpos, my=ypos;
+
+ if(bpos_tab==NULL){
+  if((buttons & 2) == 2 && me==0){
+   pe=-1;
+  }else if((buttons & 1) == 1){
+   if((buttons & 2) == 2) me=3;
+   else                   me=1;
+  }else{
+   if(me==1 || me==3) me=2;
+   else               me=0;
+  }
+ }else{
+
+  if((buttons & 3) == 1){
+    if(bpos_tab->l_but==(void*)-1){
+      if(pe==1){
+        bpos_tab->move(xpos-lxpos, ypos-lypos);
+      }
+    }
+    else{
+      if(pe==0) bpos_tab->press_l();
+    }
+    pe=1;
+  }
+  else if((buttons & 2) == 2){
+    if(pe==1){
+      bpos_tab->move(xpos-lxpos, ypos-lypos);
+    }
+    pe=1;
+
+  }else{
+    pe=0;
+  }
+ }
+}

Added: trunk/2010/2_mouse.h
==============================================================================
--- (empty file)
+++ trunk/2010/2_mouse.h	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,16 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+#ifndef n2_mouse_h
+#define n2_mouse_h
+
+struct mouse_sprites{
+ int x;
+ int y;
+ int hotx;
+ int hoty;
+ int z;
+ u_char *data;
+};
+
+void m_buttons(void);
+
+#endif

Added: trunk/2010/2_move.cc
==============================================================================
--- (empty file)
+++ trunk/2010/2_move.cc	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,107 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+
+#include <stdlib.h>
+#include "2_move.h"
+#include "2_all.h"
+#include "2010.h"
+
+extern int xpos, ypos, lxpos, lypos, xres, yres;
+extern int yress, xress;
+extern int infox, infoy, istate;
+extern int conty_b, conty_s, conty_c, contx_b, contx_s, contx_c, cstate;
+extern int fysize;
+extern int bright, satur, contr;
+
+pos_tab_list mpos_tab_list;
+
+pos_tab::pos_tab(int fixed2, int *xs2, int xe2,
+                             int *ys2, int ye2, int *state2,
+                            void (*l_but2)(void), pos_tab *prev2){
+
+ fixed=fixed2;
+ xs=xs2;
+ ys=ys2;
+ ye=ye2;
+ xe=xe2;
+ state=state2;
+ l_but=l_but2;
+ next=NULL;
+ prev=prev2;
+}
+
+int pos_tab::inside(int xp, int yp){
+ 
+  return (*xs    <=xp && xe>=xp && *ys    <=yp && ye>=yp); //fix me do that inline
+}
+
+void pos_tab::move(int relx, int rely){
+
+ if((fixed & 1)==0){
+   *xs+=relx;
+    xe+=relx;
+
+    if(*xs<0   )  xe+=0    - *xs, *xs=0;
+    if( xe>xres) *xs+=xres -  xe,  xe=xres;
+
+ }
+ if((fixed & 2)==0){
+   *ys+=rely;
+    ye+=rely;
+
+    if(*ys<0   )  ye+=0    - *ys, *ys=0;
+    if( ye>yres) *ys+=yres -  ye,  ye=yres;
+ }
+}
+
+void pos_tab::press_l(void){
+
+ if(l_but==NULL){
+  (*state)^=1;
+ }else{
+  l_but();
+ }
+}
+
+pos_tab * pos_tab_list::new_tab(int fixed2, int *xs2, int xe2,
+                                            int *ys2, int ye2, int *state2,
+                                          void (*l_but2)(void)){
+ pos_tab *temp;
+
+ temp=new pos_tab(fixed2, xs2, xe2,
+                          ys2, ye2, state2, l_but2, end);
+ if(temp!=NULL){
+
+  if(start==NULL) start=end=temp;
+  else{
+   end->next=temp;
+   end=temp;
+  }
+
+ }
+ return temp;
+}
+
+
+void setmpos(void){
+
+ infox=xres-20*9;
+ infoy=2;
+ if(mpos_tab_list.new_tab(0, &infox, infox -1,
+                             &infoy, infoy -1,
+                          &istate, NULL)           ==NULL) error(MemAlloc);
+ contx_b=bright;
+ conty_b=yress - 20;
+ if(mpos_tab_list.new_tab(2, &contx_b, contx_b + 5,
+                             &conty_b, conty_b + 15,
+                          &cstate, (void (*)())-1)           ==NULL) error(MemAlloc);
+ contx_c=contr;
+ conty_c=yress - 40;
+ if(mpos_tab_list.new_tab(2, &contx_c, contx_c + 5,
+                             &conty_c, conty_c + 15,
+                          &cstate, (void (*)())-1)           ==NULL) error(MemAlloc);
+ contx_s=satur;
+ conty_s=yress - 60;
+ if(mpos_tab_list.new_tab(2, &contx_s, contx_s + 5,
+                             &conty_s, conty_s + 15,
+                          &cstate, (void (*)())-1)           ==NULL) error(MemAlloc);
+}

Added: trunk/2010/2_move.h
==============================================================================
--- (empty file)
+++ trunk/2010/2_move.h	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,32 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+#ifndef n2_move_h
+#define n2_move_h
+
+class pos_tab {
+  int *xs, xe;
+  int *ys, ye;
+  int *state;
+ public:
+  void (*l_but)(void);
+  int fixed;
+  pos_tab *next;
+  pos_tab *prev;
+  pos_tab(int fixed2, int *xs2, int xe2,
+                      int *ys2, int ye2, int *state2,
+                     void (*l_but2)(void), pos_tab *prev2);
+  int inside(int xp, int yp);
+  void press_l(void);
+  void move(int relx, int rely);
+};
+
+class pos_tab_list {
+ public:
+  pos_tab *start;
+  pos_tab *end;
+  pos_tab_list(void) { start=NULL; end=NULL;};
+  pos_tab *new_tab(int fixed2, int *xs2, int xe2,
+                               int *ys2, int ye2, int *state2,
+                              void (*l_but2)(void));
+};
+
+#endif

Added: trunk/2010/2_nag.cc
==============================================================================
--- (empty file)
+++ trunk/2010/2_nag.cc	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,621 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <time.h>
+#include "2_all.h"
+#include "2_crypt.h"
+#include "2_vc.h"
+#include "2_nag.h"
+#include "2_71x6.h"
+#include "2_gfunc.h"
+#include "2_mmx.h"
+#include "2_nag_a.h"
+
+#define nagra_buff 32
+
+#define check 1
+
+//int check=1;     //grrrrrr nix working
+
+extern xres, yres, xress, yress, yrest, yresst, y_field;
+extern xxx dispbuf;
+extern volatile int scales_x, scalee_x;
+extern volatile int scales_y, scalee_y;
+extern int one_field;
+extern u_long asm_temp, asm_temp4;
+extern int istate;
+extern int yuvmode;
+extern int mmx;
+
+static int qsort_block(const void *p1, const void *p2);
+
+static int qsort_block(const void *p1, const void *p2){
+  return ( (b_inf*)(p1) )->up_limit - ( (b_inf*)(p2) )->up_limit;
+}
+
+void nag_decrypt(void){
+ char textbuf[9][128];
+ color c;
+ const int yresst1=yresst>>1;
+ const int c2end=int(double(nagra_buff-scales_y+0x10)/double(288-scales_y+0x10-scalee_y) * yresst1 + .5);
+ byte copy_buff[max_x<<1];
+ int i, j, k;
+ int line, line2;
+ int linep, linep2;
+ l_inf line_inf[max_y];
+ b_inf block   [max_y];
+ long T1, T2;
+ const int check2= (mmx==0) ? check-1 : check;
+ union{
+   char datbuf[(xress * yresst1 >> check2) + 16]; // + 16 for out of array thingy
+   double nixnixnix; // for alignment
+ };
+ nixnixnix=0; // for error det ):
+
+ const int corr_block= 8000 / ( 3 * ( (xress >> check2 ) + sizeof(l_inf) ) );
+
+ T1=uclock();
+
+// printf("%d\n\n\n", c2end);
+
+ linep=( xres<<2 )*( yresst1 - c2end - 1 );
+ linep2=-(xress >> check2 );
+ int blockp;
+ for(blockp=0; blockp<yresst1; blockp++){
+   block[blockp].end[0]=
+   block[blockp].end[1]=blockp;
+   line_inf[blockp].state=1;
+   line_inf[blockp].block=blockp;
+   line_inf[blockp].next[0]=
+   line_inf[blockp].next[1]=-1;
+
+   linep+=xres<<2;
+   linep2+=xress >> check2;
+   if(blockp==c2end) linep=xres<<1;
+
+   if(mmx==0){
+     asm(//"int $3 \n\t"
+         "pushl %%ebp          \n\t"
+
+         "1:                   \n\t"
+         "movw (%%edi), %%ax   \n\t"   // U        load 32 byte in L1-cache
+         "xorl %%ebx, %%ebx    \n\t"   //  V 1
+         "movl %1, %%ebp       \n\t"   // U
+         "xorl %%eax, %%eax    \n\t"   //  V 1
+         "2:                   \n\t"
+         "addl %%eax, %%ebx    \n\t"   // U
+         "xorl %%eax, %%eax    \n\t"   //  V 1
+         "movb (%%esi), %%al   \n\t"   // U
+         "addl $2, %%esi       \n\t"   //  V 1
+         "decl %%ebp           \n\t"   // U
+         " jnz 2b              \n\t"   //  V 1
+         "addl $2, %%edi       \n\t"   // U
+         "addl %%eax, %%ebx    \n\t"   //  V 1
+         "shrl %0, %%ebx       \n\t"   // U 
+         "decl %%edx           \n\t"   //  V 1
+         "movw %%bx, -2(%%edi) \n\t"   // U
+         " jnz 1b              \n\t"   //  V 1
+    
+         "popl %%ebp            \n\t"
+          : 
+          : "I" (check), "i" (1<<check),
+            "S" (dispbuf.b + linep + 1) ,
+            "d" (xress>>check) ,
+            "D" (datbuf + linep2) 
+          : "%eax", "%ebx", "%edx", "%esi", "%edi");
+   }
+   else{
+     asm(//"int $3 \n\t"
+         "pushl %%ebp          \n\t"
+
+         "1:                   \n\t"
+         "movb (%%edi), %%al   \n\t"   // U        load 32 byte in L1-cache
+         "xorl %%ebx, %%ebx    \n\t"   //  V 1
+         "movl %1, %%ebp       \n\t"   // U
+         "xorl %%eax, %%eax    \n\t"   //  V 1
+         "2:                   \n\t"
+         "addl %%eax, %%ebx    \n\t"   // U
+         "xorl %%eax, %%eax    \n\t"   //  V 1
+         "movb (%%esi), %%al   \n\t"   // U
+         "addl $2, %%esi       \n\t"   //  V 1
+         "decl %%ebp           \n\t"   // U
+         " jnz 2b              \n\t"   //  V 1
+         "incl %%edi           \n\t"   // U
+         "addl %%eax, %%ebx    \n\t"   //  V 1
+         "shrl %0, %%ebx       \n\t"   // U 
+         "decl %%edx           \n\t"   //  V 1
+         "movb %%bl, -1(%%edi) \n\t"   // U
+         " jnz 1b              \n\t"   //  V 1
+    
+         "popl %%ebp            \n\t"
+          : 
+          : "I" (check), "i" (1<<check),
+            "S" (dispbuf.b + linep + 1) ,
+            "d" (xress>>check) ,
+            "D" (datbuf + linep2) 
+          : "%eax", "%ebx", "%edx", "%esi", "%edi");
+
+   }
+ }
+
+ if(istate==1){
+   T2=uclock();
+   sprintf(textbuf[8],"%f ReSample", (float)(T2-T1)/UCLOCKS_PER_SEC);
+   T1=T2;
+ }
+
+ for(i=0; i<yresst1; i++){               
+   for(j=0; j<l_ent; j++){
+     line_inf[i].coeff[j]= 0x7FFFFFF;
+//     line_inf[i].line[j]= 1;
+   }
+ }
+
+ int corr_loops=0;
+ long T_corr=0, T_merge=0;
+ int blockpl;
+ do{
+   blockpl= blockp;
+   for(i=0; i<max_y; i++){
+     const int temp=line_inf[i].coeff[l_ent-1];       
+     for(j=0; j<l_ent; j++){
+       line_inf[i].coeff[j]=temp + (temp>>1) ;
+     }
+   }
+
+   int s_line, s_line2;
+   int s_linep, s_linep2;
+
+   s_linep= -((xress >> check2) * (corr_block + 1) );
+   for(s_line= 0; s_line < yresst1; s_line += corr_block){
+     s_linep2 = s_linep;
+     s_linep += (xress >> check2) * corr_block;
+
+     for(s_line2= s_line; s_line2 < yresst1; s_line2 += corr_block){
+       s_linep2 += (xress >> check2) * corr_block;
+
+       linep = s_linep;
+       for(line= s_line; line < yresst1 && line < (s_line + corr_block); line++){
+         linep += xress >> check2;
+
+         if(line_inf[line].state == 0) continue;
+
+         if(s_line == s_line2){
+           linep2 = linep;
+           line2 = line + 1;
+         }
+         else{
+           linep2 = s_linep2;
+           line2 = s_line2;
+         }
+
+         asm_temp=(u_long)(line_inf + line);
+         asm_temp4=line;
+
+         nagra_corr((yresst1 < (s_line2  + corr_block) ) ?
+                     yresst1 : (s_line2  + corr_block),
+                    xress >> check2,
+                    linep,
+                    linep2,
+                    line2,
+                    int(line_inf),
+                    int(datbuf)                             );
+       }
+     }
+   }
+
+   j=100000 / ( xress>>check );
+   for(i=0; i<yresst1; i++){
+     const int x1 = line_inf[i].coeff[0      ] * j;
+     const int x2 = line_inf[i].coeff[l_ent-1] * j;
+     if(x1+x2 < 500000 && x2-x1 < 30000) line_inf[i].state=0;
+   }
+
+   if(mmx!=0) asm("emms  \n\t");
+
+   if(istate==1){
+     T2=uclock();
+     T_corr+=T2-T1;
+     T1=T2;
+   }
+
+   int did_some;
+   do{
+     did_some=0;
+
+//   printf("START\n\n");
+
+     for(int blocki=0; blocki<blockp; blocki++){
+       if(line_inf[ block[blocki].end[0] ].state == 0) continue;
+
+       int endlinei[2]={l_ent, l_ent};
+       for(i=0; i<l_ent; i++){
+         if( endlinei[0]==l_ent &&
+             line_inf[ line_inf[ block[blocki].end[0] ].line[i] ].state != 0 &&
+                       line_inf[ block[blocki].end[0] ].line[i] != block[blocki].end[1] ){
+           endlinei[0]=i;
+         }  
+         if( endlinei[1]==l_ent &&
+             line_inf[ line_inf[ block[blocki].end[1] ].line[i] ].state != 0 &&
+                       line_inf[ block[blocki].end[1] ].line[i] != block[blocki].end[0] ){
+           endlinei[1]=i;
+         }  
+       }
+  
+       if(endlinei[0]==l_ent && endlinei[1]==l_ent){
+//         printf("noLines!\n");
+         continue;
+       }
+               // can't handle line + block 
+       if(block[blocki].end[0] == block[blocki].end[1]
+          && line_inf[ line_inf[ block[blocki].end[0] ].line[ endlinei[0] ]
+                      ].state == 2)
+         continue;
+  
+       int endi=0;
+       if(endlinei[0]==l_ent || ( endlinei[1]!=l_ent &&
+            line_inf[ block[blocki].end[0] ].coeff[ endlinei[0] ] >
+            line_inf[ block[blocki].end[1] ].coeff[ endlinei[1] ]   ) ) endi=1;
+       if(endlinei[0]==l_ent || endlinei[1]==l_ent ||
+          block[blocki].end[0] == block[blocki].end[1]) i=1;
+       else                                             i=0;
+       for(; i<2; i++){
+         const int line1= block[blocki].end[endi];
+         const int line2= line_inf[line1].line[ endlinei[endi] ];
+  
+         const int block2= line_inf[line2].block;    //FIX THIS (CRASHED)
+         const int endi2= block[block2].end[0] == line2 ? 0 : 1;   //FIX THIS CRASHED 
+  
+         int backlinei[2]={l_ent, l_ent};
+         for(j=0; j<l_ent; j++){
+           if( backlinei[0]!=l_ent && 
+               line_inf[ line_inf[ line2 ].line[j] ].state != 0 &&
+               line_inf[ line2 ].line[j] != block[block2].end[endi2 ^ 1] ){
+             backlinei[1]=j;
+             break;
+           }  
+           if( backlinei[0]==l_ent && 
+               line_inf[ line_inf[ line2 ].line[j] ].state != 0 &&
+               line_inf[ line2 ].line[j] != block[block2].end[endi2 ^ 1] ){
+             backlinei[0]=j;
+             if(line_inf[ line2 ].line[j] == line1) break;
+           }  
+         }
+         if(backlinei[1] == l_ent) backlinei[1] = backlinei[0];
+
+         else if( line_inf[line2].state == 1 &&
+                  line_inf[line2].line[ backlinei[1] ] == line1 ){
+
+           const int line3=  line_inf[ line2 ].line[ backlinei[0] ];
+           const int block3= line_inf[ line3 ].block;
+           const int endi3=  block[block3].end[0] == line3 ? 0 : 1;
+           for(j=0; j<l_ent; j++){
+             if( line_inf[ line_inf[ line3 ].line[j] ].state != 0 &&
+                 line_inf[ line3 ].line[j] != block[block3].end[endi3 ^ 1] ){
+               if(line_inf[ line3 ].line[j] == line2) backlinei[0]= l_ent;
+               break;
+             }  
+           }
+         }
+
+         if(backlinei[0] == l_ent){
+//           printf("noLines2!\n");
+           continue;
+         }
+
+         if(line_inf[line2].line[ backlinei[0] ] == line1 ||
+            ( line_inf[line2].state == 1 &&
+              line_inf[line2].line[ backlinei[1] ] == line1 ) ){
+     
+//           printf("%d %d  %d %d  %d %d  %d %d\n", line1, line2, blocki, block2,
+//           line_inf[line1].state, line_inf[line2].state,
+//           block[blocki].end[0], block[blocki].end[1]);
+     
+//           printf("%d %d  %d %d\n",
+//           line_inf[line1].next[1], line_inf[line1].next[0],
+//           line_inf[line2].next[1], line_inf[line2].next[0]);
+
+           did_some=1;
+
+           line_inf[line1].state++;
+           line_inf[line2].state++;
+           if(line_inf[line1].state == 3) line_inf[line1].state= 0;
+           if(line_inf[line2].state == 3) line_inf[line2].state= 0;
+
+           line_inf[line1].next[1] = line_inf[line1].next[0];
+           line_inf[line2].next[1] = line_inf[line2].next[0];
+
+           line_inf[line1].next[0] = line2;
+           line_inf[line2].next[0] = line1;
+
+//           printf("%d %d  %d %d\n",
+//           line_inf[line1].next[1], line_inf[line1].next[0],
+//           line_inf[line2].next[1], line_inf[line2].next[0]);
+
+           if(blocki != blockp-1){
+             line_inf[ block[blockp-1].end[0] ].block = block2;
+             line_inf[ block[blockp-1].end[1] ].block = block2;
+
+             line_inf[ block[block2].end[endi2 ^ 1] ].block = blocki;
+ 
+             block[blocki].end[endi]= block[block2].end[endi2 ^ 1];
+
+             block[block2]= block[blockp - 1];
+           }
+           else{
+
+             line_inf[ block[blocki].end[endi ^ 1] ].block = block2;
+
+             block[block2].end[endi2]= block[blocki].end[endi ^ 1];
+           }
+ 
+           blockp--;
+ 
+ 
+
+           break;
+         }
+         endi ^= 1;
+       }
+
+     }
+
+   } while(did_some!=0);
+
+   if(istate==1){
+     T2=uclock();
+     T_merge+=T2-T1;
+     T1=T2;
+   }
+
+   corr_loops++;
+
+ } while( blockpl > blockp*3  &&  corr_loops < 2);
+
+// printf("\n%d\n\n", blockp);
+
+ if(istate==1){
+   sprintf(textbuf[0],"%f Corr", (float)(T_corr)/UCLOCKS_PER_SEC);
+   sprintf(textbuf[1],"%f Block Handling", (float)(T_merge)/UCLOCKS_PER_SEC);
+   T2=uclock();
+   T1=T2;
+ }
+
+
+ for(i=0; i<blockp; i++){
+   line= block[i].end[0];
+   line2=-1;
+
+   int avg=0;
+   int num=0;
+   int up_limit=0, up_limit2=0;
+   while(0==0){
+     avg+=line;
+     if(line - num >= up_limit ){
+       up_limit  = line - num;
+     }
+     if(line + num >= up_limit2){
+       up_limit2  = line + num;
+     }
+     num++;
+     if(line_inf[line].next[0] == line2){
+       line2=line;
+       line= line_inf[line].next[1];
+     }
+     else{
+       line2=line;
+       line= line_inf[line].next[0];
+     }
+     if(line == -1) break;
+   }
+
+   up_limit2 -=num;
+
+   avg/=num;
+//   printf("%d %d    %d %d\n", num, avg,  up_limit,  up_limit2);
+   if(up_limit > up_limit2){
+     line= block[i].end[1];
+     block[i].end[0]= line;
+     block[i].end[1]= block[i].end[0];
+     up_limit=up_limit2;
+   }
+   up_limit -= c2end + 6;
+
+   if( up_limit < 0 ) up_limit=0;
+   if( up_limit + num > yresst1 ) up_limit=0;  // FIX ME ?
+
+   if( up_limit > avg ) up_limit = 0;
+
+   block[i].up_limit=up_limit;
+   block[i].down_limit=yresst1;
+   block[i].avg=avg;
+   block[i].ent=num;
+
+ }
+
+ if(istate==1){
+   T2=uclock();
+   sprintf(textbuf[2],"%f Stat", (float)(T2-T1)/UCLOCKS_PER_SEC);
+   T1=T2;
+ }
+
+ qsort(block, blockp, sizeof(b_inf), qsort_block);
+
+ if(istate==1){
+   T2=uclock();
+   sprintf(textbuf[3],"%f Sort", (float)(T2-T1)/UCLOCKS_PER_SEC);
+   T1=T2;
+ }
+
+ int forw_vec[yrest];
+ int bakw_vec[yrest];
+
+ for(i=0; i<yrest; i++){
+   forw_vec[i]=
+   bakw_vec[i]=-1;
+ }
+
+ int sline=0;
+ for(i=0; i<blockp; i++){
+   line= block[i].end[0];
+   line2=-1;
+   int tline;
+   while(0==0){
+     if(line_inf[line].next[0] == line2){
+       line2=line;
+       line= line_inf[line].next[1];
+     }
+     else{
+       line2=line;
+       line= line_inf[line].next[0];
+     }
+     if(line2 < c2end) tline=  (line2 + yresst1 - c2end)<<1;
+     else              tline=( (line2 - c2end          )<<1 ) + 1;
+
+     if(forw_vec[tline] != -1) printf("fatal forw %d\n", tline);
+     if(bakw_vec[sline] != -1) printf("fatal bakw %d\n", sline);
+
+     forw_vec[tline] = sline;
+     bakw_vec[sline] = tline;
+
+     if(yres == yrest) sline +=2;
+     else              sline ++;
+
+     if(line == -1) break;
+   }
+ }
+
+ if(istate==1){
+   T2=uclock();
+   sprintf(textbuf[4],"%f Built Vecs", (float)(T2-T1)/UCLOCKS_PER_SEC);
+   T1=T2;
+ }
+
+
+ for(i=0; i<yrest; i++){
+   if(bakw_vec[i] == -1 || bakw_vec[i] == i) continue;
+   j=i;
+   do{
+     k = j;
+     j = forw_vec[j];
+   } while(j != i && j != -1);
+   const int open= ( (j == -1)   ?    1 : 0 );
+
+   if(open == 0){
+     memcpy(copy_buff, dispbuf.cl + i * xres, xress << 1);
+     j = i;
+     do{
+       k = j;
+       j = bakw_vec[j];
+       forw_vec[k] = k;
+       bakw_vec[k] = k;
+//       printf("closed %d %d\n", j, k );
+       if(j != i)  memcpy(dispbuf.cl + k * xres, dispbuf.cl + j * xres, xress << 1);
+     } while(j != i);
+     memcpy(dispbuf.cl + k * xres, copy_buff, xress << 1);
+   }
+   else{
+     j = k;
+     do{
+       k = j;
+       j = bakw_vec[j];
+       forw_vec[k] = k;
+       bakw_vec[k] = k;
+//       printf("open %d %d\n", j, k );
+       if(j != -1) memcpy(dispbuf.cl + k * xres, dispbuf.cl + j * xres, xress << 1);
+     } while(j != -1);
+   }
+
+ }
+
+ if(yrest == yres){
+   for(i=0; i<yrest; i+=2){
+     memcpy(dispbuf.cl + (i+1) * xres, dispbuf.cl + i * xres, xress << 1);
+   }
+ }
+
+/*
+ linep=0;
+ for(line=0; line<yresst1; line++){
+   linep+=xres<<1;
+   int allnor=0;
+   int allinv=0;
+   for(i=0; i<xress; i+=2){
+     register int x=dispbuf.b[ linep + (i<<1) - (xres<<1) + 2 ];
+     register int y=dispbuf.b[ linep + (i<<1)             + 2 ];
+     if(x>127) x-=256;
+     if(y>127) y-=256;
+     allnor+=mabs(x-y);
+     allinv+=mabs(x+y);
+   }
+   if(allinv < allnor){
+     dispbuf.cl[line  * xres + 4          ].lum=255;
+     dispbuf.cl[line  * xres + 5          ].lum=0;
+     for(i=0; i<xress; i+=2){
+       register int x=dispbuf.b[ linep + (i<<1) + 2 ];
+       if(x>127) x-=256;
+       dispbuf.b[ 2 + linep + (i<<1) ]=char(-x);
+     } 
+   }
+
+ }
+
+ linep=0;
+ for(line=0; line<yresst1; line++){
+   linep+=xres<<1;
+   int allnor=0;
+   int allinv=0;
+   for(i=0; i<xress; i+=2){
+     register int x=dispbuf.b[ linep + (i<<1) - (xres<<1) ];
+     register int y=dispbuf.b[ linep + (i<<1)             ];
+     if(x>127) x-=256;
+     if(y>127) y-=256;
+     allnor+=mabs(x-y);
+     allinv+=mabs(x+y);
+   }
+   if(allinv < allnor){
+     dispbuf.cl[line  * xres + 6          ].lum=255;
+     dispbuf.cl[line  * xres + 7          ].lum=0;
+     for(i=0; i<xress; i+=2){
+       register int x=dispbuf.b[ linep + (i<<1) ];
+       if(x>127) x-=256;
+       dispbuf.b[ linep + (i<<1) ]=char(-x);
+     } 
+   }
+
+ }
+*/  
+ if(istate==1){
+   T2=uclock();
+   sprintf(textbuf[5],"%f Move", (float)(T2-T1)/UCLOCKS_PER_SEC);
+   sprintf(textbuf[6],"%d Blocks", blockp);
+   sprintf(textbuf[7],"%d Loops", corr_loops);
+   c.init(255, 0, 0, yuvmode);
+   gprint(80,  80,  c.c, textbuf[0]);
+   gprint(90,  90,  c.c, textbuf[1]);
+   gprint(100, 100, c.c, textbuf[2]);
+   gprint(110, 110, c.c, textbuf[3]);
+   gprint(120, 120, c.c, textbuf[4]);
+   gprint(130, 130, c.c, textbuf[5]);
+   gprint(140, 140, c.c, textbuf[6]);
+   gprint(150, 150, c.c, textbuf[7]);
+   gprint(160, 160, c.c, textbuf[8]);
+   T1=T2;
+ }
+
+ line=0;
+ for(i=0; i<blockp; i++){
+//   printf("%d %d %d\n", i, block[i].up_limit, block[i].avg);
+   line+= block[i].ent;
+
+   dispbuf.cl[line  * xres              ].lum=255;
+   dispbuf.cl[line  * xres + 1          ].lum=0;
+   if(line_inf[ block[i].end[0] ].state == 0){
+     dispbuf.cl[line  * xres + 2          ].lum=255;
+     dispbuf.cl[line  * xres + 3          ].lum=0;
+   }
+ }
+}
+

Added: trunk/2010/2_nag.h
==============================================================================
--- (empty file)
+++ trunk/2010/2_nag.h	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,25 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+#ifndef n2_nag_h
+#define n2_nag_h
+
+#define l_ent 14
+
+struct l_inf{
+ int line[l_ent];
+ int coeff[l_ent];
+ int state;
+ int block;
+ int next[2];
+};
+
+struct b_inf{
+ int end[2];
+ int up_limit;
+ int down_limit;
+ int avg;
+ int ent;
+};
+
+void nag_decrypt(void);
+
+#endif

Added: trunk/2010/2_nag_a.asm
==============================================================================
--- (empty file)
+++ trunk/2010/2_nag_a.asm	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,283 @@
+;2010 0.1 Copyright (C) Michael Niedermayer 1998
+
+%include "2_all_a.asm"
+
+segment .data
+
+extern _mmx
+extern esp_save   
+extern _asm_temp  
+extern _asm_temp2 
+extern _asm_temp3 
+extern _asm_temp4 
+
+global _nagra_corr__Fiiiiiii
+
+%define line2_end    par1
+%define xress_check2 par2
+%define linep        par3
+%define linep2       par4
+%define line2        par5
+%define line_inf     par6
+%define databuf      par7
+
+_nagra_corr__Fiiiiiii:
+; push eax
+ push ebx
+
+ push ecx
+ push edx
+
+ push esi
+ push edi
+
+ push ebp
+ mov ebx, [line2]
+
+loopi:
+
+ mov [_asm_temp2], ebx
+ mov ebp, [line_inf]
+
+ shl ebx, 7
+ mov edx, [xress_check2]
+
+ add ebx, ebp
+ mov ecx, [linep2]
+
+ mov [_asm_temp3], ebx
+ add ecx, edx
+
+ mov ebx, [ebx + 112]
+ mov [linep2], ecx
+
+ mov esi, [databuf]
+ test ebx, ebx
+
+ mov edi, esi
+  jz NEAR End
+
+ add esi, edx
+ add edi, edx
+
+ add esi, ecx
+ mov ecx, [linep]
+
+ xor edx, -1
+ add edi, ecx
+
+ inc edx
+ mov eax, [_mmx]
+
+ mov [esp_save], esp
+ mov esp, edx
+
+ test eax, eax
+  jz NoMMX
+
+ movq mm3, [mmx_zero]
+
+ movq mm0, [esp + esi]
+ movq mm5, mm3
+
+ movq mm1, [esp + edi]
+ movq mm2, mm0
+
+ movq mm6, [mmx_clip]
+
+MMXloop:
+ psubusb mm2, mm1            ; U
+ psubusb mm1, mm0            ;  V 1
+ movq mm0, [esp + esi + 8]   ; U
+ por mm2, mm1                ;  V 1
+ movq mm1, [esp + edi + 8]   ; U
+ paddusb mm2, mm6            ;  V 1
+ movq mm4, mm2               ; U
+ punpcklbw mm2, mm3          ;  V 1
+ punpckhbw mm4, mm3          ; U
+ paddusw mm5, mm2            ;  V 1
+ paddusw mm5, mm4            ; U
+ movq mm2, mm0               ;  V 1
+ add esp, 8                  ; U
+  jnc MMXloop                ;  V 1
+
+ movq mm0, mm5
+ psrlq mm5, 32
+
+ paddusw mm5, mm0
+
+ movq mm0, mm5
+ psrlq mm5, 16
+
+ paddusw mm5, mm0
+
+ movd ebp, mm5
+
+ mov ebx, [_asm_temp]
+ and ebp, 0xFFFF
+
+ jmp EndMMX       
+NoMMX:
+
+ xor ebp, ebp           
+ xor edx, edx           
+ xor ecx, ecx           
+
+ mov eax, [esp + esi]
+ mov ebx, [esp + edi]
+ or eax, 0x80008000        
+
+NoMMXloop:            
+ sub edx, ecx                ; U
+ sub eax, ebx                ;  V 1 
+ and edx, 0x00FF00FF         ; U
+ add ebp, edx                ;  V 1 
+ mov ebx, eax                ; U
+ and eax, 0xFF00FF00         ;  V 1
+ shr eax, 8                  ; U
+ mov ecx, [esp + esi + 4]    ;  V 1
+ xor eax, 0x00800080         ; U
+ or  ecx, 0x80008000         ;  V 1
+ xor ebx, eax                ; U
+ mov edx, [esp + edi + 4]    ;  V 1
+ sub ebx, eax                ; U
+ sub ecx, edx                ;  V 1
+ and ebx, 0x00FF00FF         ; U
+ mov edx, ecx                ;  V 1
+ add ebp, ebx                ; U 
+ and ecx, 0xFF00FF00         ;  V 1
+ shr ecx, 8                  ; U
+ mov eax, [esp + esi + 8]    ;  V 1
+ xor ecx, 0x00800080         ; U
+ or  eax, 0x80008000         ;  V 1
+ xor edx, ecx                ; U
+ mov ebx, [esp + edi + 8]    ;  V 1
+ add esp, 8                  ; U
+  jnc NoMMXloop              ;  V 1
+
+
+ mov ebx, [_asm_temp]        ; U    line_inf[line]
+ mov eax, ebp                ;  V 1
+ shr eax, 16                 ; U
+ and ebp, 0x0000FFFF         ;  V 1
+ add ebp, eax                ; U
+
+EndMMX: 
+
+ mov eax, [ebx + 108]        ; U | V 1
+ cmp ebp, eax                ; U
+  jg TryNext                 ;  V 1
+
+ mov eax, [ebx + 84]         ; U 1
+ cmp eax, ebp                ; U 
+ mov esp, [_asm_temp2]       ;  V 1  line2
+ sbb ecx, ecx                ; U 
+ mov edx, 48                 ;  V 1
+ and ecx, 32                 ; U 1
+
+ mov eax, [ebx + ecx + 68]   ; U 2 AGI 
+ cmp eax, ebp                ; U 1
+ sbb esi, esi                ; U 1
+ and esi, 16                 ; U 1
+ or  ecx, esi                ; U 1
+
+ mov eax, [ebx + ecx + 60]   ; U 2 AGI 
+ cmp eax, ebp                ; U 1
+ sbb esi, esi                ; U 1
+ and esi, 8                  ; U 1
+ or  ecx, esi                ; U 1
+
+ mov eax, [ebx + ecx + 56]   ; U 2 AGI 
+ cmp eax, ebp                ; U 1
+ sbb esi, esi                ; U 1
+ and esi, 4                  ; U 1
+ or  ecx, esi                ; U 1
+
+Copy1:  
+ mov esi, [ebx + edx     ]    ; U
+ mov edi, [ebx + edx + 56]    ;  V 1
+ mov [ebx + edx + 4 ], esi    ; U
+ mov [ebx + edx + 60], edi    ;  V 1
+ sub edx, 4                   ; U
+ cmp edx, ecx                 ;  V 1
+  jge Copy1                   ; U  1
+ mov [ebx + ecx     ], esp    ; U
+ mov [ebx + ecx + 56], ebp    ;  V 1
+    
+
+TryNext:  
+ 
+
+ mov ebx, [_asm_temp3]       ; U 1  line_inf[line2]
+
+ mov eax, [ebx + 108]        ; U 2  AGI
+ cmp ebp, eax                ; U
+  jg End                     ;  V 1
+
+ mov eax, [ebx + 84]         ; U 1
+ cmp eax, ebp                ; U 
+ mov esp, [_asm_temp4]       ;  V 1  line
+ sbb ecx, ecx                ; U 
+ mov edx, 48                 ;  V 1
+ and ecx, 32                 ; U 1
+
+ mov eax, [ebx + ecx + 68]   ; U 2 AGI 
+ cmp eax, ebp                ; U 1
+ sbb esi, esi                ; U 1
+ and esi, 16                 ; U 1
+ or  ecx, esi                ; U 1
+
+ mov eax, [ebx + ecx + 60]   ; U 2 AGI 
+ cmp eax, ebp                ; U 1
+ sbb esi, esi                ; U 1
+ and esi, 8                  ; U 1
+ or  ecx, esi                ; U 1
+
+ mov eax, [ebx + ecx + 56]   ; U 2 AGI 
+ cmp eax, ebp                ; U 1
+ sbb esi, esi                ; U 1
+ and esi, 4                  ; U 1
+ or  ecx, esi                ; U 1
+
+Copy2:  
+ mov esi, [ebx + edx     ]    ; U
+ mov edi, [ebx + edx + 56]    ;  V 1
+ mov [ebx + edx + 4 ], esi    ; U
+ mov [ebx + edx + 60], edi    ;  V 1
+ sub edx, 4                   ; U
+ cmp edx, ecx                 ;  V 1
+  jge Copy2                   ; U  1
+ mov [ebx + ecx     ], esp    ; U
+ mov [ebx + ecx + 56], ebp    ;  V 1
+    
+
+End:  
+ 
+ mov esp, [esp_save]
+
+ mov ebx, [line2]
+ mov ecx, [line2_end]
+
+ inc ebx
+
+ cmp ebx, ecx
+ mov [line2], ebx
+
+  jl NEAR loopi
+
+
+ pop ebp
+ pop edi
+ pop esi
+ pop edx
+ pop ecx
+ pop ebx
+; pop eax
+
+ret
+
+xyz times 8 dd 0
+
+align8
+mmx_zero times 2 dd 0
+mmx_clip times 8 db 0

Added: trunk/2010/2_nag_a.h
==============================================================================
--- (empty file)
+++ trunk/2010/2_nag_a.h	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,7 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+#ifndef n2_nag_a_h
+#define n2_nag_a_h
+
+void nagra_corr(int, int, int, int, int, int, int);
+
+#endif

Added: trunk/2010/2_vc.cc
==============================================================================
--- (empty file)
+++ trunk/2010/2_vc.cc	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,343 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+
+#include <stdio.h>
+#include <time.h>
+#include <string.h>
+#include "2_all.h"
+#include "2_crypt.h"
+#include "2_vc.h"
+#include "2_71x6.h"
+#include "2_gfunc.h"
+#include "2_vc_a.h"
+
+#define addap_start 16
+#define addap_end 2
+#define vc_dead 7.5
+#define check 1
+
+extern xres, yres, xress, yress;
+extern xxx dispbuf;
+extern volatile int scales_x, scalee_x;
+extern volatile int scales_y, scalee_y;
+extern int one_field;
+extern int show_points;
+extern int istate;
+extern int yuvmode;
+extern int edge_lut[256];
+
+
+static int *new_val=new int[max_x], *last_val=new int[max_x];
+
+static byte copy_buff[max_x<<1];
+
+
+void vc_decrypt(void){
+ int i, j, k=0, l;
+ int line, cutp, diff, linep, llinep, add_step, start_step;
+ int edgep;
+ int bestp=0, bestdiff;
+ int diffall;
+ int temp;
+ int cutpoint[max_y];
+ int addap_buff[max_x];
+ int drift;
+ int best_edge=0;
+ int best_val, best_edge_val;
+ int best_dir=0;
+ char textbuf[9][128];
+ long T1=0, T2;
+ long alg1=0, alg2=0, alg3=0;
+ color c;
+
+ const int vc_endx=xress;
+ const int vc_startx=int(double(22-scales_x+3)/double(768-scales_x+3-scalee_x)*xress);
+
+ const int vc_diff=vc_endx - vc_startx;
+
+ int *dir=new int[vc_diff*(yress + 1)];
+
+ const int mindist=int(double(vc_diff) / vc_dead);
+
+ cutpoint[0]=0;
+
+ char *datbuf[2];
+
+ datbuf[0]= new char[vc_diff];
+ datbuf[1]= new char[vc_diff];
+
+ if(istate==1){
+   T1=uclock();
+ }
+
+ for(i = 0; i < vc_diff; i++) last_val[i]=1;
+
+ llinep=-(xres<<2);
+ linep=-(xres<<1);
+ edgep=0;
+ for(line=0; line<yress; line++){
+   llinep+=xres<<1;
+   linep+=xres<<1;
+   bestdiff=0x1FFFFFFF;
+   diffall=0;
+   start_step=0;
+
+   char *dtemp = datbuf[0];
+   datbuf[0] = datbuf[1];
+   datbuf[1] = dtemp;
+
+   asm(//"int $3 \n\t"
+       "pushl %%ebp          \n\t"
+
+       "1:                   \n\t"
+       "movw (%%edi), %%ax   \n\t"   // U        load 32 byte in L1-cache
+       "xorl %%ebx, %%ebx    \n\t"   //  V 1
+       "movl %1, %%ebp       \n\t"   // U
+       "xorl %%eax, %%eax    \n\t"   //  V 1
+       "2:                   \n\t"
+       "addl %%eax, %%ebx    \n\t"   // U
+       "xorl %%eax, %%eax    \n\t"   //  V 1
+       "movb (%%esi), %%al   \n\t"   // U
+       "addl $2, %%esi       \n\t"   //  V 1
+       "decl %%ebp           \n\t"   // U
+       " jnz 2b              \n\t"   //  V 1
+       "addl $2, %%edi       \n\t"   // U
+       "addl %%eax, %%ebx    \n\t"   //  V 1
+       "shrl %0, %%ebx       \n\t"   // U 
+       "decl %%edx           \n\t"   //  V 1
+       "movw %%bx, -2(%%edi) \n\t"   // U
+       " jnz 1b              \n\t"   //  V 1
+  
+       "popl %%ebp            \n\t"
+        : 
+        : "I" (check), "i" (1<<check),
+          "S" (dispbuf.b + linep + 1 + (vc_startx<<1)) ,
+          "d" (vc_diff>>check) ,
+          "D" (datbuf[1]) 
+        : "%eax", "%ebx", "%edx", "%esi", "%edi");
+
+
+   if(istate==1){
+     T2=uclock();
+     alg3+=T2-T1;
+     T1=T2;
+   }
+
+   if(line==0) continue;
+
+   for(add_step=addap_start; add_step>addap_end; add_step>>=1){
+     start_step>>=1;
+     if(add_step==(addap_start>>1) && start_step==0){
+       add_step=addap_start;
+       start_step=addap_start>>1;
+     }
+     for(cutp=start_step; cutp<vc_diff; cutp+=add_step){
+       if(cutp==start_step || start_step==0 || cutp+add_step>=vc_diff
+          || bestdiff+(bestdiff>>1) > addap_buff[cutp - (add_step>>1)]
+          || bestdiff+(bestdiff>>1) > addap_buff[cutp + (add_step>>1)]){
+
+
+         diff = vc_corr(
+               int(datbuf[1] + (((                  + cutp) << (1-check))&~1)),
+               int(datbuf[0] + ((( - cutp + vc_diff + cutp) << (1-check))&~1)),
+                  -(( cutp << (1-check) ) & ~1),
+               int(datbuf[1] + (((   cutp + vc_diff - cutp) << (1-check))&~1)),
+               int(datbuf[0] + (((        + vc_diff - cutp) << (1-check))&~1)),
+                  -(( (vc_diff-cutp) << (1-check) ) & ~1) ) ;
+
+         if(bestdiff>diff){
+           bestdiff=diff;
+           bestp=cutp;
+         }
+         addap_buff[cutp]=diff;
+         if(start_step==0) diffall+=diff;
+       }
+       else addap_buff[cutp]=0x7FFFFFFF;
+     }
+   }
+   bestp+= cutpoint[line-1];
+   if(bestp>=vc_diff) bestp-=vc_diff;
+   cutpoint[line]=bestp;
+   if(bestdiff==0) bestdiff++;
+   temp=diffall * addap_start * 32 / (vc_diff * bestdiff);
+        if(temp<42) drift=xress;
+   else if(temp<56) drift=addap_end;
+   else             drift=(addap_end>>1) | 1;
+
+
+   if(istate==1){
+     T2=uclock();
+     alg1+=T2-T1;
+     T1=T2;
+   }
+
+   edgep +=vc_diff;
+
+   best_edge_val=0;
+
+   for(i = 0; i < vc_diff; i++){
+     l= i + cutpoint[line];
+     if(l >= vc_diff) l-=vc_diff;
+     if(l < mindist || l >= vc_diff - mindist){
+       new_val[i]=0;
+       dir[edgep + i]=best_edge;    //FIX ME (not nes)
+     }
+     else if(drift==xress){
+       new_val[i]=1;
+       dir[edgep + i]=best_edge;
+     }
+     else{
+
+       diff=0;
+       int edge_x= l == 0 ? (l - 2) + vc_diff : (l - 2);
+       do{
+         if((edge_x++) >= vc_diff) edge_x-= vc_diff;
+         diff+= dispbuf.b[linep + ((vc_startx + edge_x)<<1) + 1];
+       }while( edge_x != l );
+       do{
+         if((edge_x++) >= vc_diff) edge_x-= vc_diff;
+         diff-= dispbuf.b[linep + ((vc_startx + edge_x)<<1) + 1];
+       }while( edge_x != l + 2);
+
+       diff= edge_lut[ mabs(diff) ];
+
+       new_val[i]= diff;
+
+       best_val=0;
+
+       for(j = i - (drift<<2); j <  i + (drift<<2); j++){
+         k=j;
+         int drift_p;
+         const int drift_t=mabs(j - i);
+              if(drift_t <=     1   ) drift_p= 0;
+         else if(drift_t <= drift   ) drift_p= 2;
+         else if(drift_t <= drift<<1) drift_p=10;
+         else if(drift_t <= drift*3 ) drift_p=20;
+         else                         drift_p=40;
+
+              if(k <  0      ) k+= vc_diff;
+         else if(k >= vc_diff) k-= vc_diff;
+
+         if(last_val[k] - drift_p > best_val){
+           best_val=last_val[k] - drift_p;
+           best_dir=k;
+           if(best_edge_val < best_val){
+             best_edge_val=best_val;
+             best_edge=best_dir;
+           }
+         }
+
+       }
+
+       if(best_val!=0){
+         new_val[i]+= best_val;
+         dir[edgep + i]= best_dir;
+       }else{
+         new_val[i]=0;
+         dir[edgep + i]= 0;    //FIX ME (Not Nes)
+         for(j=k+1; i<vc_diff ; j++){
+           if(j >= vc_diff) j-=vc_diff;
+           if(last_val[j]==0){
+             i++;
+             l= i + cutpoint[line];
+             if(l >= vc_diff) l-=vc_diff;
+             new_val[i]=0;
+             dir[edgep + i]= 0;    //FIX ME (Not Nes)
+           }
+           else break;
+         }              
+         if(i >=  vc_diff && best_edge_val==0){
+           i=0;
+           drift=xress;
+         }
+       }
+     }
+   }
+
+   int *temp_val=last_val;
+   last_val=new_val;
+   new_val=temp_val;
+
+   if(istate==1){
+     T2=uclock();
+     alg2+=T2-T1;
+     T1=T2;
+   }
+
+ }
+
+ if(istate==1){
+   T2=uclock();
+   sprintf(textbuf[0],"%f Corr", (float)(alg1)/UCLOCKS_PER_SEC);
+   sprintf(textbuf[1],"%f Edge-Search", (float)(alg2)/UCLOCKS_PER_SEC);
+   sprintf(textbuf[2],"%f ReSample", (float)(alg3)/UCLOCKS_PER_SEC);
+   T1=T2;
+ }
+
+ i=best_edge;
+ for(line=yress-1; line>0; line--){
+   if(show_points==0){
+     cutpoint[line]+=i;
+     if(cutpoint[line] >= vc_diff) cutpoint[line]-= vc_diff;
+   }
+   else{
+     j=cutpoint[line]+i;
+     if(j >= vc_diff) j-= vc_diff;
+     dispbuf.b[(line * xres<<1) + ((vc_startx + j)<<1)+1]=255;
+     dispbuf.b[(line * xres<<1) + ((vc_startx + j)<<1)+3]=0;
+   }
+   i=dir[vc_diff*line + i];
+ }
+
+ if(istate==1){
+   T2=uclock();
+   sprintf(textbuf[3],"%f Misc", (float)(T2-T1)/UCLOCKS_PER_SEC);
+   T1=T2;
+ }
+
+ linep=-(xres<<1);
+// vc_diff&= ~1;
+ for(line=0; line<yress; line++){
+
+//   cutpoint[line]&= ~1;
+
+   linep+=xres<<1;
+   if(show_points!=0){
+     dispbuf.b[linep+(vc_startx<<1)+1]=255;
+     dispbuf.b[linep+(vc_startx<<1)+3]=0;
+   }
+   memcpy(copy_buff, dispbuf.b + linep + (vc_startx<<1), vc_diff<<1);
+   memcpy(dispbuf.b + linep + (vc_startx<<1), copy_buff + (cutpoint[line]<<1),
+                                                 (vc_diff-cutpoint[line])<<1);
+   memcpy(dispbuf.b + linep + (vc_startx<<1) + ((vc_diff-cutpoint[line])<<1),
+                                                                   copy_buff,
+                                                         cutpoint[line]<<1);
+/*
+   if(show_points!=0){
+     for(i=0; i<vc_diff; i++){
+       j=dir[line * vc_diff + i];
+       if(j<0 || j>=vc_diff) j=0;
+
+       dispbuf.b[linep + ((vc_startx + j) <<1)+1]=255;
+     }
+   }   
+     */
+ }
+
+ if(istate==1){
+   T2=uclock();
+   sprintf(textbuf[4],"%f Rotate", (float)(T2-T1)/UCLOCKS_PER_SEC);
+   c.init(255, 0, 0, yuvmode);
+   gprint(80,  80,  c.c, textbuf[0]);
+   gprint(90,  90,  c.c, textbuf[1]);
+   gprint(100, 100, c.c, textbuf[2]);
+   gprint(110, 110, c.c, textbuf[3]);
+   gprint(120, 120, c.c, textbuf[4]);
+   T1=T2;
+ }
+
+
+  delete [] dir;
+  delete [] datbuf[0];
+  delete [] datbuf[1];
+}
+

Added: trunk/2010/2_vc.h
==============================================================================
--- (empty file)
+++ trunk/2010/2_vc.h	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,7 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+#ifndef n2_vc_h
+#define n2_vc_h
+
+void vc_decrypt(void);
+
+#endif

Added: trunk/2010/2_vc_a.asm
==============================================================================
--- (empty file)
+++ trunk/2010/2_vc_a.asm	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,143 @@
+;2010 0.1 Copyright (C) Michael Niedermayer 1998
+
+%include "2_all_a.asm"
+
+segment .data
+
+extern esp_save
+extern _asm_temp
+global _vc_corr__Fiiiiii
+
+%define line1a       par1
+%define line1b       par2
+%define count1       par3
+%define line2a       par4
+%define line2b       par5
+%define count2       par6
+
+_vc_corr__Fiiiiii:
+ push ebx
+
+ push ecx
+ push edx
+
+ push esi
+ push edi
+
+ push ebp
+ mov esi, [line1a]
+
+ mov edi, [line1b]
+ mov [esp_save], esp
+
+ xor ecx, ecx
+ mov esp, [count1]
+
+ xor ebp, ebp
+ xor edx, edx
+
+ cmp esp, 4
+  jb skip1
+
+ mov eax, [esp + esi]
+ mov ebx, [esp + edi]
+ or eax, 0x80008000        
+
+NoMMXloop:            
+ sub edx, ecx                ; U
+ sub eax, ebx                ;  V 1 
+ and edx, 0x00FF00FF         ; U
+ add ebp, edx                ;  V 1 
+ mov ebx, eax                ; U
+ and eax, 0xFF00FF00         ;  V 1
+ shr eax, 8                  ; U
+ mov ecx, [esp + esi + 4]    ;  V 1
+ xor eax, 0x00800080         ; U
+ or  ecx, 0x80008000         ;  V 1
+ xor ebx, eax                ; U
+ mov edx, [esp + edi + 4]    ;  V 1
+ sub ebx, eax                ; U
+ sub ecx, edx                ;  V 1
+ and ebx, 0x00FF00FF         ; U
+ mov edx, ecx                ;  V 1
+ add ebp, ebx                ; U 
+ and ecx, 0xFF00FF00         ;  V 1
+ shr ecx, 8                  ; U
+ mov eax, [esp + esi + 8]    ;  V 1
+ xor ecx, 0x00800080         ; U
+ or  eax, 0x80008000         ;  V 1
+ xor edx, ecx                ; U
+ mov ebx, [esp + edi + 8]    ;  V 1
+ add esp, 8                  ; U
+  jnc NoMMXloop              ;  V 1
+
+skip1:
+
+ mov esp, [esp_save]
+ xor ecx, ecx
+
+ mov esi, [line2a]           ; AGI
+ mov edi, [line2b]
+
+ mov esp, [count2]
+ xor edx, edx
+
+ cmp esp, 4
+  jb skip2
+
+ mov eax, [esp + esi]       
+ mov ebx, [esp + edi]
+ or eax, 0x80008000        
+
+NoMMXloop2:
+ sub edx, ecx                ; U
+ sub eax, ebx                ;  V 1 
+ and edx, 0x00FF00FF         ; U
+ add ebp, edx                ;  V 1 
+ mov ebx, eax                ; U
+ and eax, 0xFF00FF00         ;  V 1
+ shr eax, 8                  ; U
+ mov ecx, [esp + esi + 4]    ;  V 1
+ xor eax, 0x00800080         ; U
+ or  ecx, 0x80008000         ;  V 1
+ xor ebx, eax                ; U
+ mov edx, [esp + edi + 4]    ;  V 1
+ sub ebx, eax                ; U
+ sub ecx, edx                ;  V 1
+ and ebx, 0x00FF00FF         ; U
+ mov edx, ecx                ;  V 1
+ add ebp, ebx                ; U 
+ and ecx, 0xFF00FF00         ;  V 1
+ shr ecx, 8                  ; U
+ mov eax, [esp + esi + 8]    ;  V 1
+ xor ecx, 0x00800080         ; U
+ or  eax, 0x80008000         ;  V 1
+ xor edx, ecx                ; U
+ mov ebx, [esp + edi + 8]    ;  V 1
+ add esp, 8                  ; U
+  jnc NoMMXloop2             ;  V 1
+
+skip2:
+
+ mov esp, [esp_save]
+ mov eax, ebp                ;  
+
+ shr eax, 16                 ;
+ and ebp, 0x0000FFFF         ;
+
+ add eax, ebp                ;
+ pop ebp
+
+ pop edi
+ pop esi
+
+ pop edx
+ pop ecx
+
+ pop ebx
+
+ret
+
+
+
+

Added: trunk/2010/2_vc_a.h
==============================================================================
--- (empty file)
+++ trunk/2010/2_vc_a.h	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,7 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+#ifndef n2_vc_a_h
+#define n2_vc_a_h
+
+int vc_corr(int, int, int, int, int, int);
+
+#endif

Added: trunk/2010/2_wins.cc
==============================================================================
--- (empty file)
+++ trunk/2010/2_wins.cc	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,49 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+
+#include <stdio.h>
+#include <string.h>
+//#include <sys/movedata.h>
+#include "2_all.h"
+#include "2_wins.h"
+#include "2_gfunc.h"
+#include "2_71x6.h"
+
+ extern int xres, yres;
+ extern int buttons, xpos, ypos, lxpos, lypos;
+ extern int infox, infoy;
+ extern int conty_b, conty_s, conty_c, contx_b, contx_s, contx_c;
+ extern int me;
+ extern int fysize;
+ extern int yuvmode;
+ extern int bright, satur, contr;
+
+void drawc(void){
+ color c;
+ int i;
+
+ if(contx_b>255) contx_b=255;
+ if(contx_s>127) contx_s=127;
+ if(contx_c>127) contx_c=127;
+
+ i=0;
+ if(bright!=contx_b) bright=contx_b, i=1;
+ if(contr !=contx_c) contr =contx_c, i=1;
+ if(satur !=contx_s) satur =contx_s, i=1;
+
+ if(i!=0) setcont();
+
+ c.init(bright_col2);
+ rect(contx_b  , conty_b  , contx_b+8, conty_b+15, c.c);
+ c.init(bright_col1);
+ rect(contx_b+2, conty_b+2, contx_b+6, conty_b+13, c.c);
+
+ c.init(contr_col2);
+ rect(contx_c  , conty_c  , contx_c+8, conty_c+15, c.c);
+ c.init(contr_col1);
+ rect(contx_c+2, conty_c+2, contx_c+6, conty_c+13, c.c);
+                 
+ c.init(satur_col2);
+ rect(contx_s  , conty_s  , contx_s+8, conty_s+15, c.c);
+ c.init(satur_col1);
+ rect(contx_s+2, conty_s+2, contx_s+6, conty_s+13, c.c);
+}

Added: trunk/2010/2_wins.h
==============================================================================
--- (empty file)
+++ trunk/2010/2_wins.h	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,14 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+#ifndef n2_wins_h
+#define n2_wins_h
+
+#define bright_col1 255,  0,  0, yuvmode
+#define bright_col2 128,  0,  0, yuvmode
+#define contr_col1   64,  0,  0, yuvmode
+#define contr_col2    0,  0,  0, yuvmode
+#define satur_col1  128,  0, 64, yuvmode
+#define satur_col2   64,  0, 32, yuvmode
+
+void drawc(void);
+
+#endif

Added: trunk/2010/2do
==============================================================================
--- (empty file)
+++ trunk/2010/2do	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,32 @@
+clear boarder
+center pic if not xres x yres
+fix all yuv g_funcs
+add mil cont buf
+fix dpmi no page alignes
+vds mem not checked for 4mb violations
+switch between inputs
+teletext
+load pix for decoding
+fix no page flips
+  mouse out at buttom freezes everything
+  mouse area not updated
+fix mouse if int 8
+imp nagra
+ color ?
+ block integration
+ better sorting (no QSort)
+ c2end +-1 error (up_limit not correct)
+ variable check
+ imp black line det
+ up/down limit check in block merge
+
+imp vc
+ color ?
+ FFT
+ use chroma and luma for edge det
+ asm opt
+
+
+fix 24-bits   ?
+
+

Added: trunk/2010/makefile
==============================================================================
--- (empty file)
+++ trunk/2010/makefile	Wed Jul  4 03:08:39 2007
@@ -0,0 +1,46 @@
+.SUFFIXES: .c .cc .h .o .asm .S .s
+
+CFLAGS = -g
+CFLAGS = -O3 -m486 -fomit-frame-pointer -g -Wall -Wstrict-prototypes -malign-double -ffast-math -funroll-loops -fno-default-inline
+AFLAGS = -f coff
+
+.c.o:   ; gcc $(CFLAGS) -c $<
+
+.cc.o:  ; gcc $(CFLAGS) -c $<
+
+.S.o:   ; gcc $(CFLAGS) -c $<
+
+.asm.o: ; nasm $(AFLAGS) $<
+
+O = 2010.o 2_file.o 2_menu.o 2_grafix.o 2_hw.o 2_mfunc.o 2_mouse.o 2_gfunc.o \
+    2_move.o 2_hw_asm.o 2_71x6.o 2_hw_mem.o 2_wins.o 2_crypt.o 2_vc.o 2_nag.o\
+    2_nag_a.o 2_vc_a.o 2_glob_a.o
+
+2010 : $(O) ; gcc $(CFLAGS) -o 2010 $(O)
+clean: ; del $(O) 2010
+
+2010.o     : 2010.cc     2_all.h 2010.h 2_file.h 2_mouse.h 2_hw.h 2_grafix.h\
+                             2_menu.h 2_mfunc.h 2_move.h 2_71x6.h 2_hw_mem.h
+2_file.o   : 2_file.cc   2_all.h 2_file.h 2010.h 2_hw.h
+2_gfunc.o  : 2_gfunc.cc  2_all.h 2_gfunc.h 2010.h 
+2_grafix.o : 2_grafix.cc 2_all.h 2_grafix.h 2_gfunc.h 2_menu.h 2_hw.h 2_file.h\
+                             2_wins.h
+2_menu.o   : 2_menu.cc   2_all.h 2_menu.h 2_mfunc.h 2_gfunc.h
+2_mfunc.o  : 2_mfunc.cc  2_all.h 2_mfunc.h 2_menu.h 2_71x6.h 2010.h
+2_mouse.o  : 2_mouse.cc  2_all.h 2_mouse.h 2_move.h
+2_hw.o     : 2_hw.cc     2_all.h 2_hw.h 2010.h 2_mouse.h 2_hw_asm.h 2_hw_mem.h\
+                             2_71x6.h 2_mmx.h
+2_hw_mem.o : 2_hw_mem.cc 2_all.h 2_hw_mem.h 2010.h 
+2_move.o   : 2_move.cc   2_all.h 2_move.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_wins.o   : 2_wins.cc   2_all.h 2_wins.h 2_gfunc.h 2_71x6.h
+2_crypt.o  : 2_crypt.cc  2_all.h 2_crypt.h 2_71x6.h 2_vc.h 2_nag.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
+
+2_hw_asm.o : 2_hw_asm.s
+
+2_glob_a.o : 2_glob_a.asm 2_all_a.asm
+2_nag_a.o  : 2_nag_a.asm  2_all_a.asm
+2_vc_a.o   : 2_vc_a.asm   2_all_a.asm
+



More information about the Mndiff-dev mailing list