Mndiff-dev
Threads by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
July 2007
- 1 participants
- 45 discussions
[mndiff]: r47 - in trunk/2010: 2010.cc 2_71x6.cc 2_all.h 2_crypt.cc 2_hw.cc 2_nag.cc 2_nag.h 2_nag_a.asm 2_vc.cc 2d
by michael 04 Jul '07
by michael 04 Jul '07
04 Jul '07
Author: michael
Date: Wed Jul 4 04:05:15 2007
New Revision: 47
Log:
version from 1998-07-06
Added:
trunk/2010/2d
Modified:
trunk/2010/2010.cc
trunk/2010/2_71x6.cc
trunk/2010/2_all.h
trunk/2010/2_crypt.cc
trunk/2010/2_hw.cc
trunk/2010/2_nag.cc
trunk/2010/2_nag.h
trunk/2010/2_nag_a.asm
trunk/2010/2_vc.cc
Modified: trunk/2010/2010.cc
==============================================================================
--- trunk/2010/2010.cc (original)
+++ trunk/2010/2010.cc Wed Jul 4 04:05:15 2007
@@ -37,8 +37,8 @@
extern int mmx;
extern int *best1;
extern BEST2 *best2;
- extern KEYSLIST *keysList;
- extern bool manualPhaseStart;
+ extern u_short *keysList;
+ extern int *decoLine;
int _crt0_startup_flags = _CRT0_FLAG_NEARPTR | _CRT0_FLAG_NONMOVE_SBRK;
int buttons=0, xpos=0, ypos=0, lxpos=0, lypos=0;
@@ -124,6 +124,7 @@ int error(error_code e){
void exitt(void){
close_hw();
+ delete [] decoLine;
delete [] best1;
delete [] best2;
delete [] keysList;
@@ -344,7 +345,6 @@ int main(int argc, char **argv){
if(kbhit()) key=getkey();
if(key=='g' || key=='G') key=0, grabf=1;
- if(key=='p' || key=='P') key=0, manualPhaseStart^=1;
}
exit(0);
Modified: trunk/2010/2_71x6.cc
==============================================================================
--- trunk/2010/2_71x6.cc (original)
+++ trunk/2010/2_71x6.cc Wed Jul 4 04:05:15 2007
@@ -17,6 +17,7 @@
//#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;
@@ -204,18 +205,22 @@ void meteor_int_handler(void){
// asm("int $3\n\t");
+ int grabbingOne=0;
+ while(doubleBuff[grabbingOne].state != Grabbing && grabbingOne<2)
+ grabbingOne++;
+
+ int emptyOne=0;
+ while(doubleBuff[emptyOne].state!=Empty && emptyOne<2) emptyOne++;
+
+
a_saa7116->capt_ctl_a|=0x0F30;
- if( ( a_saa7116->ints_ctl.stat_odd == 1 && fields>=2 )
- || ( a_saa7116->ints_ctl.stat_start == 1 && fields>=11111 ) ){
+ if( a_saa7116->ints_ctl.stat_odd == 1 && fields<11111
+ && a_saa7116->ints_ctl.stat_even == 0 && fields>=2
+ && a_saa7116->ints_ctl.stat_start == 0 ){
fields=0;
- int grabbingOne=0;
- while(doubleBuff[grabbingOne].state != Grabbing && grabbingOne<2)
- grabbingOne++;
- if(grabbingOne!=2) doubleBuff[grabbingOne].state= Grabbed;
- int emptyOne=0;
- while(doubleBuff[emptyOne].state!=Empty && emptyOne<2) emptyOne++;
+ if(grabbingOne!=2) doubleBuff[grabbingOne].state= Grabbed;
if(emptyOne!=2){
if(single==0){
@@ -226,11 +231,6 @@ void meteor_int_handler(void){
doubleBuff[1].state= Grabbing;
}
grab_next(doubleBuff[emptyOne]);
- 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};
}
else{
fields=11111;
@@ -239,8 +239,18 @@ void meteor_int_handler(void){
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};
+ if(grabbingOne!=2) grab_next(doubleBuff[grabbingOne^1]);
+ else asm("int $3\n\t");
}
}
+ else if( a_saa7116->ints_ctl.stat_start==1 && fields>=11111 && emptyOne!=2){
+ fields=0;
+ 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_a|=0x7;
}
@@ -279,6 +289,9 @@ void close_meteor(void){
void grab_next(xxx x){
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]=
a_saa7116->dma.even[1]= a_saa7116->dma.odd [1]=
@@ -297,21 +310,6 @@ void grab_next(xxx x){
}
-void grab_nix(){
- saa7116 *a_saa7116=(saa7116*)meteors[active_meteor].saa7116;
-
- xxx x= doubleBuff[0];
-
- 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]= x.phys;
-
- a_saa7116->dma_end.even=
- a_saa7116->dma_end.odd= x.phys + xresc*4;
-
-}
-
-
void meteor_int_handler_end(void){
}
Modified: trunk/2010/2_all.h
==============================================================================
--- trunk/2010/2_all.h (original)
+++ trunk/2010/2_all.h Wed Jul 4 04:05:15 2007
@@ -10,6 +10,9 @@
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
+#define limit(a,b,c) if( (a)<(b) || (a)>(c) ) error(-201)
+
+
#define u_char unsigned char
#define u_long unsigned long
#define u_short unsigned short
Modified: trunk/2010/2_crypt.cc
==============================================================================
--- trunk/2010/2_crypt.cc (original)
+++ trunk/2010/2_crypt.cc Wed Jul 4 04:05:15 2007
@@ -25,7 +25,7 @@ int show_points=0;
void decrypt(void){
-// if( (crypt == vc || crypt == nag) && satur!=0 ) decomb();
+// if( crypt == nag && satur!=0 ) decomb();
decomb();
if(crypt==vc) vc_decrypt();
@@ -37,57 +37,72 @@ void decrypt(void){
static void decomb(void){
-
- int linep, llinep, line, i, o;
+ int segs=1;
+ int linep, llinep, line, i;
int j, k;
int temp[max_x];
int amp[max_x];
const int outy1= outy>>1;
const int stride=one_field ? (vgax<<1) : (vgax<<2);
- const int pass=one_field ? 1 : 2;
+ const int o=one_field ? 0 : 1;
const int end=one_field ? outy : outy1;
+ const int segSize= end/segs;
- for(o=0; o<pass; o++){
-
- for(i=0; i<max_x; i++){
- temp[i]=0;
- amp[i]=0;
- }
+ int startp= 0;
+ for(int seg=0; seg<segs; seg++){
- linep=-stride;
- if(o) linep+=vgax<<1;
- for(line=0; line<end; line++){
- linep+=stride;
- for(i=0; i<wndx; i++){
- j = int(dispbuf.b[linep + (i<<1)]);
- k = temp[i];
- if(j>127) j= j - 256;
- j= (j + j) - k;
- temp[i] = j;
- if(line & 1) amp[i]-=j;
- else amp[i]+=j;
- }
- }
+ for(i=0; i<wndx; i++){
+ temp[i]=0;
+ amp[i]=0;
+ }
- for(i=0; i<max_x; i++){
- temp[i]= amp[i]/end;
- }
+ linep= startp;
+ if(o) linep+=vgax<<1;
+ for(line=0; line<segSize; line++){
+ for(i=0; i<wndx; i+=2){
+ j = char(dispbuf.b[linep + (i<<1) ]);
+ j= (j + j) - temp[i];
+ temp[i] = j;
+ if(line & 1) amp[i]-=j;
+ else amp[i]+=j;
+ }
+ linep+=stride;
+ }
- linep=-stride;
- if(o) linep+=vgax<<1;
- for(line=0; line<end; line++){
- linep+=stride;
for(i=0; i<wndx; i++){
- j = int(dispbuf.b[linep + (i<<1)]);
- k = temp[i];
- if(j>127) j= j - 256;
- j=(j + j) - k;
- dispbuf.b[linep + (i<<1)] = (char)(j);
- temp[i] = j;
- }
+ temp[i]= amp[i]/segSize;
+ }
+
+ linep= startp;
+ if(o) linep+=vgax<<1;
+ for(line=0; line<segSize; line++){
+ for(i=0; i<wndx; i++){
+/*
+ j = char(dispbuf.b[linep + (i<<1)]);
+ j=(j + j) - temp[i];
+ temp[i] = j;
+ if (j> 127) j= 127;
+ else if(j<-128) j=-128;
+ dispbuf.b[linep + (i<<1)] = (char)(j);
+ */
+
+ j = char(dispbuf.b[linep + (i<<1)]);
+ j=(j + j) - temp[i];
+ if(j<temp[i]) j++;
+ if (j> 127) j= 127;
+ else if(j<-128) j=-128;
+ temp[i] = j;
+ dispbuf.b[linep + (i<<1)] = (char)(j);
+
+
+
+
+ }
+ linep+=stride;
+ }
+ startp+= segSize*stride;
}
- }
/*
asm(//"int $3 \n\t"
Modified: trunk/2010/2_hw.cc
==============================================================================
--- trunk/2010/2_hw.cc (original)
+++ trunk/2010/2_hw.cc Wed Jul 4 04:05:15 2007
@@ -50,6 +50,7 @@
extern int in_int;
extern int mouse_tim;
extern int mouse_ltim;
+ extern volatile int frames;
int g_mode=0;
int m_mode=0;
@@ -557,9 +558,25 @@ void copy_vidbuffer(void){
int nextOne= workingOne^1;
if(doubleBuff[nextOne].state==Empty) nextOne=0; // not critical
-// meteors[active_meteor].saa7116->ints_ctl_a |= 0x7;
-// meteors[active_meteor].saa7116->capt_ctl_a |= 0x0F30;
+ while(doubleBuff[nextOne].state != Grabbed);
+
+ doubleBuff[nextOne].state= Working;
+ dispbuf= doubleBuff[nextOne];
+ }
+ else{
+ doubleBuff[0].state=
+ doubleBuff[1].state=Empty;
+
+ while(doubleBuff[0].state != Grabbed);
+
+ doubleBuff[0].state=
+ doubleBuff[1].state=Working;
+
+ dispbuf= doubleBuff[0];
+ }
+
+/*
printf("%X, %X\n", meteors[active_meteor].saa7116->capt_ctl_a,
meteors[active_meteor].saa7116->ints_ctl_a );
@@ -582,25 +599,7 @@ void copy_vidbuffer(void){
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);
-
- while(doubleBuff[nextOne].state != Grabbed);
-
- doubleBuff[nextOne].state= Working;
-
- dispbuf= doubleBuff[nextOne];
- }
- else{
- doubleBuff[0].state=
- doubleBuff[1].state=Empty;
-
- while(doubleBuff[0].state != Grabbed);
-
- doubleBuff[0].state=
- doubleBuff[1].state=Working;
-
- dispbuf= doubleBuff[0];
- }
-
+*/
}
Modified: trunk/2010/2_nag.cc
==============================================================================
--- trunk/2010/2_nag.cc (original)
+++ trunk/2010/2_nag.cc Wed Jul 4 04:05:15 2007
@@ -25,15 +25,13 @@ extern u_long asm_temp, asm_temp4;
extern int istate;
extern int yuvmode;
extern bool mmx;
-extern volatile int frames;
-bool manualPhaseStart=false;
-int *decoLine;
+int *decoLine=NULL;
int decoLines;
int keyTable[256];
int *best1=NULL;
-BEST2 *best2=NULL; // FIX DELETE
-KEYSLIST *keysList=NULL;
+BEST2 *best2=NULL;
+u_short *keysList=NULL;
static int outy1;
static int nagStart2;
static int nagEnd2;
@@ -51,17 +49,19 @@ bool checkAlign(void *p, int align){
void *newAlign(int size, int align){ // FIX SHOULD BE SOMEWHERE ELSE
int v= int(new char[size + align + 3]);
+ printf("anew %d\n", v);
int v2= ( (v+align-1+4) & ~(align-1) );
((int*)v2)[-1]= v;
return (void*)v2;
}
void deleteAlign(void *v){ // FIX SHOULD BE SOMEWHERE ELSE
+ printf("adel %d\n", int(((char**)v)[-1]) );
delete [] ((char**)v)[-1];
}
static inline void getPerm(const int key, int * const perm){
- int keyNdx= key >> 7;
+ int keyNdx= (key >> 7) & 0xFF;
const int keyInc= ((key & 0x7F) << 1) + 1;
int buffer[32];
@@ -172,42 +172,62 @@ static inline void doDwnSmp(byte * const
static inline int nagLineLogi2Phys(const int logi){
int phys;
+ if(logi>=287) error(-100);
if(logi<32) phys= nagStart1 + ( logi <<1);
else phys= nagStart2 + ((logi-32)<<1);
+ if(phys>=576) error(-101);
return phys;
}
-void mod4Fix(byte * p, int cleMod4, int encMod4){
- const bool xchg[16]={false, true, false, true,
- true, false, true, false,
- false, true, false, true,
- true, false, true, false };
-
- const byte neg[16]={ 0, 0, 0xFF, 0xFF,
- 0, 0, 0xFF, 0xFF,
- 0xFF, 0xFF, 0, 0,
- 0xFF, 0xFF, 0, 0 };
- const int ndx= cleMod4 | (encMod4<<2);
+static inline void mod4Fix(byte * p, const int type){
+ const bool xchg[4]={false, true, false, true};
+ const int neg [4]={ 0, 0, -1, -1};
for(int x=0; x<(vgax<<1); x+=4){
- byte u= p[x ]; // perhaps u><v
- byte v= p[x+2];
+ const byte u= p[x ]; // perhaps u><v
+ const byte v= p[x+2];
- if(xchg[ndx]){
- const int t=u;
- u=v;
- v=t;
+ if(xchg[type]){
+ p[x ]= (v^neg[type]) - neg[type];
+ p[x+2]= (u^neg[type]) - neg[type];
+ }else{
+ p[x ]= (u^neg[type]) - neg[type];
+ p[x+2]= (v^neg[type]) - neg[type];
}
- p[x ]= (u^neg[ndx]) - neg[ndx];
- p[x+2]= (v^neg[ndx]) - neg[ndx];
}
}
+void corrV(byte * p1, byte * p2, const int type, int *vPhase){
+ const bool xchg[4]={false, true, false, true};
+ const int neg [4]={ 0, 0, -1, -1};
+
+ for(int x=0; x<(vgax<<1); x+=4){
+ int u1= char(p1[x ]); // perhaps u><v
+ int v1= char(p1[x+2]);
+
+ int u2= char(p2[x ]); // perhaps u><v
+ int v2= char(p2[x+2]);
+
+ if(xchg[type]){
+ const int t=u1;
+ u1=v1;
+ v1=t;
+ }
+
+ u1=(u1^neg[type]) - neg[type];
+ v1=(v1^neg[type]) - neg[type];
+
+ *vPhase+= mabs(u1-u2) + mabs(v1-v2);
+ *vPhase-= mabs(u1+u2) + mabs(v1+v2);
+ }
+
+}
+
void nag_decrypt(void){
outy1= outy>>1;
nagStart2= int(double(17+0 - scales_y)/y_field*outy1 + .5)*2+1;
@@ -226,12 +246,9 @@ void nag_decrypt(void){
T1=uclock();
-// if(frames&1) frames++;
- const int vPhase= (((frames & 2)==2) ^ manualPhaseStart) ? 1 : 0;
-
-// printf("%d %d\n", sizeof(KEYSLIST), sizeof(BEST2) );
+ printf("%d %d\n", sizeof(u_short), sizeof(BEST2) );
-// printf("HALLOX\n");
+ printf("HALLOX\n");
static bool first=true;
if(first){
@@ -275,11 +292,11 @@ void nag_decrypt(void){
best1= new int[decoLines * NAG_LINES];
best2= new BEST2[best2Size];
- keysList= new KEYSLIST[keysListSize];
+ keysList= new u_short[keysListSize];
fread(best1, sizeof(int), decoLines * NAG_LINES, f);
fread(best2, sizeof(BEST2), best2Size , f);
- fread(keysList, sizeof(KEYSLIST), keysListSize , f);
+ fread(keysList, sizeof(u_short), keysListSize , f);
badFile:;
fclose(f);
@@ -333,7 +350,7 @@ void nag_decrypt(void){
best1= new int[NAG_LINES * decoLines];
best2= new BEST2[best2Size];
- keysList= new KEYSLIST[keysListSize];
+ keysList= new u_short[keysListSize];
for(int i=0; i<NAG_LINES * decoLines; i++){
best1[i]=-1;
@@ -359,12 +376,12 @@ void nag_decrypt(void){
int keyP=keysTempStart[ndx2];
while(keyP!=-1){
- keysList[keysListPos]=(KEYSLIST){last:0, key:(keyP & (KEYS-1))};
+ keysList[keysListPos]=keyP & (KEYS-1);
keysListPos++;
// printf("KL %d\n", keyP);
keyP=keysTemp[keyP];
}
- if(keysListPos>0) keysList[keysListPos-1].last=1;
+ if(keysListPos>0) keysList[keysListPos-1]|=KEYS;
// printf("KL END\n");
best2Pos++;
@@ -388,7 +405,7 @@ void nag_decrypt(void){
fwrite(best1, sizeof(int), decoLines * NAG_LINES, f);
fwrite(best2, sizeof(BEST2), best2Size , f);
- fwrite(keysList, sizeof(KEYSLIST), keysListSize , f);
+ fwrite(keysList, sizeof(u_short), keysListSize , f);
fclose(f);
@@ -403,12 +420,10 @@ void nag_decrypt(void){
}
byte * const decoLowRes=(byte*) newAlign( (wndx>>dwnSmpSize) * decoLines, 8);
-// printf("%d\n", int(decoLowRes));
for(int dL=0; dL<decoLines; dL++){
byte * const linep= dispbuf.b + nagLineLogi2Phys(decoLine[dL])*(vgax<<1);
byte * const lowResp= decoLowRes + dL*(wndx>>dwnSmpSize);
doDwnSmp(lowResp ,linep);
-// printf("%X\n", int(lowResp)); // FIX alignment (fine now but...)
}
if(istate==1){
@@ -417,8 +432,7 @@ void nag_decrypt(void){
T1=T2;
}
- byte * const lowRes=(byte*) newAlign( (wndx>>dwnSmpSize) * decoLines, 8);
-// printf("%d\n", int(lowRes));
+ byte * const lowRes=(byte*) newAlign( wndx>>dwnSmpSize, 8);
for(int line=0; line<NAG_LINES; line++){
byte * const linep= dispbuf.b + nagLineLogi2Phys(line)*(vgax<<1);
// printf("%d\n", line);
@@ -432,11 +446,11 @@ void nag_decrypt(void){
}
}
if(mmx) asm("emms\n\t");
-// printf("H1\n");
+ printf("H1\n");
deleteAlign(decoLowRes);
deleteAlign(lowRes);
-// printf("H2\n");
+ printf("H2\n");
if(istate==1){
T2=uclock();
@@ -452,6 +466,7 @@ void nag_decrypt(void){
bestCoeffs[dL].line[1]= bestCoeffs[dL].line[0];
bestCoeffs[dL].line[0]= t;
}
+ limit(bestCoeffs[dL].line[0], 0, 285);
int l= best1[ bestCoeffs[dL].line[0] + dL*NAG_LINES ];
int r= best1[ bestCoeffs[dL].line[0] + 1 + dL*NAG_LINES ];
@@ -468,7 +483,7 @@ void nag_decrypt(void){
keysListPos[keysListPoses]= best2[l].keyNdx;
keysListPoses++;
}
-// printf("H3\n");
+ printf("H3\n");
if(istate==1){
T2=uclock();
@@ -482,30 +497,30 @@ void nag_decrypt(void){
int bestNum=0;
do{
didSome=false;
- int lowKey=0xFFFF;
+ u_short lowKey=0xFFFF;
int lowNum=0;
for(int kLP=0; kLP<keysListPoses; kLP++){
if(keysListPos[kLP]==-1) continue;
- if( int(keysList[ keysListPos[kLP] ].key)==lastLowKey ){
- if( keysList[ keysListPos[kLP] ].last==1 ){
+ if( int(keysList[ keysListPos[kLP] ] & (KEYS-1) )==lastLowKey ){
+ if( (keysList[ keysListPos[kLP] ] & KEYS)==KEYS ){
keysListPos[kLP]=-1;
continue;
}
keysListPos[kLP]++;
}
- if( int(keysList[ keysListPos[kLP] ].key) == lowKey ){
+ if( int(keysList[ keysListPos[kLP] ] & (KEYS-1)) == lowKey ){
lowNum++;
}
- if( int(keysList[ keysListPos[kLP] ].key) < lowKey ){
- lowKey= int(keysList[ keysListPos[kLP] ].key);
+ if( int(keysList[ keysListPos[kLP] ] & (KEYS-1)) < lowKey ){
+ lowKey= int(keysList[ keysListPos[kLP] ] & (KEYS-1));
lowNum=0;
}
didSome= true;
}
lastLowKey=lowKey;
-// printf(" %d %d\n", lowNum, lowKey);
+// printf("KEY %d %d\n", lowNum, lowKey);
if(lowNum>bestNum){
bestNum=lowNum;
bestKey=lowKey;
@@ -524,17 +539,41 @@ void nag_decrypt(void){
T1=T2;
}
- sprintf(textbuf[6],"%d %d vPhase", vPhase, int(frames));
+ delete [] bestCoeffs; // kill this
+
+
+
+ byte *lastV[2]={NULL, NULL};
+ int lastVType[2];
+ int vPhase=0;
+ for(int i=0; i<NAG_LINES; i++){
+ if(perm[i]>=32 && mabs(perm[i]-32 - i)<5){
+ const cleMod4= (i ) & 3;
+ const encMod4= (perm[i]) & 3;
+ const type= cleMod4 ^ encMod4;
+
+ if(lastV[type&1^1] != NULL){
+ byte *b=dispbuf.b + nagLineLogi2Phys( perm[i] ) * (vgax<<1);
+ corrV( b, lastV[type&1^1], type ^ lastVType[type&1^1], &vPhase );
+ }
+ lastV[type&1]= dispbuf.b + nagLineLogi2Phys( perm[i] ) * (vgax<<1);
+ lastVType[type&1]= type;
+ }
+ }
+ if(vPhase>0) vPhase=1;
+ else vPhase=0;
+
byte *lowDriftLinep= NULL;
for(int i=0; i<NAG_LINES; i++){
if(perm[i]>=32 && mabs(perm[i]-32 - i)<5){
const cleMod4= (i + vPhase ) & 3;
const encMod4= (perm[i] + vPhase ) & 3;
+ const type= cleMod4 ^ encMod4;
lowDriftLinep= dispbuf.b + nagLineLogi2Phys( perm[i] ) * (vgax<<1);
- if(cleMod4!=encMod4) mod4Fix(lowDriftLinep, cleMod4, encMod4);
+ if(cleMod4!=encMod4) mod4Fix(lowDriftLinep, type);
break;
}
@@ -546,14 +585,16 @@ void nag_decrypt(void){
if(perm[clearLine]>=32 && mabs(perm[clearLine]-32 - clearLine)<5){
const cleMod4= (clearLine + vPhase ) & 3;
const encMod4= (perm[clearLine] + vPhase ) & 3;
+ const type= cleMod4 ^ encMod4;
lowDriftLinep= dispbuf.b + nagLineLogi2Phys( perm[clearLine] ) * (vgax<<1);
- if(cleMod4!=encMod4) mod4Fix(lowDriftLinep, cleMod4, encMod4);
+ if(cleMod4!=encMod4) mod4Fix(lowDriftLinep, type);
}
else{
- for(int x=0; x<(vgax<<1); x+=2){
- linep[x]= lowDriftLinep[x];
+ for(int x=0; x<(vgax<<1); x+=4){
+ linep[x ]= lowDriftLinep[x ];
+ linep[x+2]= lowDriftLinep[x+2];
}
}
}
@@ -566,7 +607,7 @@ void nag_decrypt(void){
T1=T2;
}
-// printf("H4\n");
+ printf("H4\n");
/*
for(int i=0; i<NAG_LINES; i++){
const int p=nagLineLogi2Phys(i);
@@ -586,8 +627,8 @@ void nag_decrypt(void){
*/
delete [] bestCoeffs;
- int enc2cleVec[outy];
- int cle2encVec[outy];
+ int enc2cleVec[max_x];
+ int cle2encVec[max_x];
for(int i=0; i<outy; i++){
enc2cleVec[i]=
@@ -669,8 +710,8 @@ void nag_decrypt(void){
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(140, 140, c.c, textbuf[6]);
+ gprint(150, 150, c.c, textbuf[7]);
gprint(160, 160, c.c, textbuf[8]);
gprint(170, 170, c.c, textbuf[9]);*/
T1=T2;
Modified: trunk/2010/2_nag.h
==============================================================================
--- trunk/2010/2_nag.h (original)
+++ trunk/2010/2_nag.h Wed Jul 4 04:05:15 2007
@@ -11,11 +11,6 @@ struct BEST2{
unsigned keyNdx:23;
};
-struct KEYSLIST{
- unsigned last:1;
- unsigned key:15;
-};
-
struct BESTCOEFFS{
int line[2];
int coeff[2];
Modified: trunk/2010/2_nag_a.asm
==============================================================================
--- trunk/2010/2_nag_a.asm (original)
+++ trunk/2010/2_nag_a.asm Wed Jul 4 04:05:15 2007
@@ -11,15 +11,15 @@ extern _asm_temp2
global _nagraCorr__Fiiiii
-%define buf1 par1
-%define buf2 par2
-%define bufSize par3
-%define best par4
-%define line par5
+%define buf1 par2
+%define buf2 par3
+%define bufSize par4
+%define best par5
+%define line par6
_nagraCorr__Fiiiii:
-; push eax
+ push eax
push ebx
push ecx
@@ -34,13 +34,17 @@ _nagraCorr__Fiiiii:
mov edx, [bufSize]
mov edi, [buf2]
+ and edx, 0xFFFFFFF8
+
+ sub edx, 8
+
add esi, edx
add edi, edx
xor edx, -1
mov eax, [_mmx]
- add edx, 8
+ inc edx
mov ebx, [best]
mov [_asm_temp], ebx
@@ -52,7 +56,7 @@ _nagraCorr__Fiiiii:
mov esp, edx
test eax, eax
- jz NoMMX
+ jz NEAR NoMMX
movq mm3, [mmx_zero]
@@ -80,6 +84,21 @@ MMXloop:
add esp, 8 ; U
jnc MMXloop ; V 1
+ psubusb mm2, mm1
+ psubusb mm1, mm0
+
+ por mm2, mm1
+
+ paddusb mm2, mm6
+
+ movq mm4, mm2
+
+ punpcklbw mm2, mm3
+ punpckhbw mm4, mm3
+
+ paddusw mm5, mm2
+ paddusw mm5, mm4
+
movq mm0, mm5
psrlq mm5, 32
@@ -174,7 +193,7 @@ End:
pop edx
pop ecx
pop ebx
-; pop eax
+ pop eax
ret
Modified: trunk/2010/2_vc.cc
==============================================================================
--- trunk/2010/2_vc.cc (original)
+++ trunk/2010/2_vc.cc Wed Jul 4 04:05:15 2007
@@ -49,6 +49,7 @@ void vc_decrypt(void){
long alg1=0, alg2=0, alg3=0;
color c;
+ show_points=1;
const int vc_endx=wndx;
const int vc_startx=int(double(22-scales_x+3)/double(768-scales_x+scalee_x)*wndx);
Added: trunk/2010/2d
==============================================================================
--- (empty file)
+++ trunk/2010/2d Wed Jul 4 04:05:15 2007
@@ -0,0 +1,2 @@
+fix asm_code in bfd stuff
+deComb overFlow
1
0
[mndiff]: r46 - in trunk/2010: 2010.cc 2010.h 2_71x6.cc 2_71x6.h 2_all.h 2_crypt.cc 2_hw.cc 2_hw_asm.s 2_mfunc.cc 2_nag.cc 2_nag.h 2_nag_a.asm 2_nag_a.h makefile
by michael 04 Jul '07
by michael 04 Jul '07
04 Jul '07
Author: michael
Date: Wed Jul 4 03:59:17 2007
New Revision: 46
Log:
version from july 1998
Modified:
trunk/2010/2010.cc
trunk/2010/2010.h
trunk/2010/2_71x6.cc
trunk/2010/2_71x6.h
trunk/2010/2_all.h
trunk/2010/2_crypt.cc
trunk/2010/2_hw.cc
trunk/2010/2_hw_asm.s
trunk/2010/2_mfunc.cc
trunk/2010/2_nag.cc
trunk/2010/2_nag.h
trunk/2010/2_nag_a.asm
trunk/2010/2_nag_a.h
trunk/2010/makefile
Modified: trunk/2010/2010.cc
==============================================================================
--- trunk/2010/2010.cc (original)
+++ trunk/2010/2010.cc Wed Jul 4 03:59:17 2007
@@ -19,10 +19,11 @@
#include "2_menu.h"
#include "2_grafix.h"
#include "2_71x6.h"
+#include "2_nag.h"
extern mouse_sprites cursor;
extern int g_mode;
- extern xxx dispbuf, grab_dispbuf;
+ extern xxx dispbuf, *doubleBuff;
extern byte *vidbuf;
extern int mouse_x, mouse_y, mouse_b;
extern volatile int page_flip;
@@ -34,6 +35,10 @@
extern int single;
extern int grabf;
extern int mmx;
+ extern int *best1;
+ extern BEST2 *best2;
+ extern KEYSLIST *keysList;
+ extern bool manualPhaseStart;
int _crt0_startup_flags = _CRT0_FLAG_NEARPTR | _CRT0_FLAG_NONMOVE_SBRK;
int buttons=0, xpos=0, ypos=0, lxpos=0, lypos=0;
@@ -93,6 +98,14 @@ int error(error_code e){
break;
case SAA7196 : printg_t("\nPhilips SAA7196 error!\n");
break;
+ case KeyFile : printg_t("\nKeyFile error!\n");
+ break;
+ case DatWrite : printg_t("\nDatWrite error!\n");
+ break;
+ case Align : printg_t("\nAlign error!\n");
+ break;
+ case Nagra : printg_t("\nNagra error!\n");
+ break;
case CommLine : printg_t("\nCommand-Line error!\n");
case Help : printg_t("\n2010 [<optons>]\n"
"options: -v n (Video-mode)\n"
@@ -111,6 +124,9 @@ int error(error_code e){
void exitt(void){
close_hw();
+ delete [] best1;
+ delete [] best2;
+ delete [] keysList;
}
int main(int argc, char **argv){
@@ -290,8 +306,12 @@ int main(int argc, char **argv){
else
a= alloc_cont(vgax * vgay << mc2, 1);
- dispbuf =a[0];
- grab_dispbuf=a[1];
+ doubleBuff=(xxx*)(int(&doubleBuff)+4);
+ dispbuf= // dispbuf just cheap copy
+ doubleBuff[0]= a[0];
+ doubleBuff[1]= a[1];
+ doubleBuff[0].state=
+ doubleBuff[1].state= Empty;
if(page_flip==0) i= vgax * vgay * vb;
else i= vgax * vgay * vb << 1;
@@ -324,6 +344,7 @@ int main(int argc, char **argv){
if(kbhit()) key=getkey();
if(key=='g' || key=='G') key=0, grabf=1;
+ if(key=='p' || key=='P') key=0, manualPhaseStart^=1;
}
exit(0);
Modified: trunk/2010/2010.h
==============================================================================
--- trunk/2010/2010.h (original)
+++ trunk/2010/2010.h Wed Jul 4 03:59:17 2007
@@ -27,6 +27,10 @@ typedef enum{
FileMax,
Lock,
SAA7196,
+ DatWrite,
+ KeyFile,
+ Align,
+ Nagra,
} error_code;
int error(error_code e);
Modified: trunk/2010/2_71x6.cc
==============================================================================
--- trunk/2010/2_71x6.cc (original)
+++ trunk/2010/2_71x6.cc Wed Jul 4 03:59:17 2007
@@ -24,7 +24,6 @@ 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;
@@ -36,7 +35,7 @@ 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 xxx dispbuf, *doubleBuff;
extern volatile int stride;
extern int wndx, wndy, outy;
extern int single;
@@ -58,7 +57,7 @@ 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);
-
+static void start_grab(void);
int scan_pci_meteors(void){
int i, dev, bus;
@@ -200,41 +199,46 @@ void meteor_int_handler(void){
addr_errors++;
}
- if(a_saa7116->ints_ctl.stat_even != 1 || a_saa7116->ints_ctl.stat_odd != 1){
- frames++;
- fields++;
- }
+ fields+= a_saa7116->ints_ctl.stat_even + a_saa7116->ints_ctl.stat_odd;
+ frames+= a_saa7116->ints_ctl.stat_start;
+
+// asm("int $3\n\t");
a_saa7116->capt_ctl_a|=0x0F30;
- if( ( (one_field==0 && nagra_mode==0)
- || a_saa7116->ints_ctl.stat_even == 0) && fields>=2){
+ if( ( a_saa7116->ints_ctl.stat_odd == 1 && fields>=2 )
+ || ( a_saa7116->ints_ctl.stat_start == 1 && fields>=11111 ) ){
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;
+ int grabbingOne=0;
+ while(doubleBuff[grabbingOne].state != Grabbing && grabbingOne<2)
+ grabbingOne++;
+ if(grabbingOne!=2) doubleBuff[grabbingOne].state= Grabbed;
- grab_next();
- }
- grab_state=NotReady;
- }else{
+ int emptyOne=0;
+ while(doubleBuff[emptyOne].state!=Empty && emptyOne<2) emptyOne++;
+
+ if(emptyOne!=2){
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;
+ doubleBuff[emptyOne].state= Grabbing;
+ }
+ else{
+ doubleBuff[0].state=
+ doubleBuff[1].state= Grabbing;
}
+ grab_next(doubleBuff[emptyOne]);
+ 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};
+ }
+ else{
+ fields=11111;
+ 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};
}
}
a_saa7116->ints_ctl_a|=0x7;
@@ -272,23 +276,39 @@ void close_meteor(void){
metmode=0;
}
-void grab_next(void){
+void grab_next(xxx x){
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;
+ 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]= x.phys;
}else{
- a_saa7116->dma.even[0]= grab_dispbuf.phys;
- a_saa7116->dma.odd [0]= grab_dispbuf.phys + xresc;
+ a_saa7116->dma.even[0]=
+ a_saa7116->dma.even[1]=
+ a_saa7116->dma.even[2]= x.phys;
+ a_saa7116->dma.odd [0]=
+ a_saa7116->dma.odd [1]=
+ a_saa7116->dma.odd [2]= x.phys + xresc;
}
a_saa7116->dma_end.even=
- a_saa7116->dma_end.odd= grab_dispbuf.phys + xresc*outy - 1;
+ a_saa7116->dma_end.odd= x.phys + xresc*outy - 1;
+
+}
+
+void grab_nix(){
+ saa7116 *a_saa7116=(saa7116*)meteors[active_meteor].saa7116;
+
+ xxx x= doubleBuff[0];
+
+ 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]= x.phys;
+
+ a_saa7116->dma_end.even=
+ a_saa7116->dma_end.odd= x.phys + xresc*4;
-
}
@@ -575,7 +595,7 @@ write_saa7196(0x10, 0x00); //BAK
start_grab();
}
-void start_grab(void){
+static void start_grab(void){
saa7116 *a_saa7116=(saa7116*)meteors[active_meteor].saa7116;
a_saa7116->ints_ctl=(ints_c){
@@ -584,6 +604,10 @@ void start_grab(void){
wait(wait_time);
+ xxx grab_dispbuf= doubleBuff[0].phys==dispbuf.phys ?
+ doubleBuff[1] : doubleBuff[0];
+
+
if(one_field==1){
a_saa7116->dma.even[0]= a_saa7116->dma.odd [0]=
a_saa7116->dma.even[1]= a_saa7116->dma.odd [1]=
@@ -621,7 +645,34 @@ void start_grab(void){
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};
+ mask_even: 1, mask_odd: 1, mask_start: 1, res2: 0};
}
+void cont_grab(void){
+ saa7116 *a_saa7116=(saa7116*)meteors[active_meteor].saa7116;
+
+ if(one_field==1){
+ 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.odd [0]=
+ a_saa7116->dma.odd [1]=
+ a_saa7116->dma.odd [2]=
+ a_saa7116->dma.even[0] + 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= a_saa7116->dma.even[0] + xresc*outy - 1;
+
+
+
+ wait(wait_time);
+
+}
+
Modified: trunk/2010/2_71x6.h
==============================================================================
--- trunk/2010/2_71x6.h (original)
+++ trunk/2010/2_71x6.h Wed Jul 4 03:59:17 2007
@@ -21,12 +21,6 @@ typedef enum{
nag,
} crypt_form;
-typedef enum{
- NotReady=0,
- Skiped,
- Waiting,
-} grstate;
-
/*
pci_cmd; //04-05
pci_sts; //06-07
@@ -216,11 +210,12 @@ void init_meteor(void);
void close_meteor(void);
void meteor_int_handler(void);
void meteor_int_handler_end(void);
-void start_grab(void);
+void cont_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);
+void grab_next(xxx x);
+void grab_nix();
#endif
Modified: trunk/2010/2_all.h
==============================================================================
--- trunk/2010/2_all.h (original)
+++ trunk/2010/2_all.h Wed Jul 4 03:59:17 2007
@@ -36,6 +36,13 @@ union s_col{
u_long a;
};
+typedef enum{
+ Empty,
+ Working,
+ Grabbing,
+ Grabbed,
+} BUFFSTATE;
+
struct xxx{
union{
s_yuv *yuv;
@@ -44,6 +51,7 @@ struct xxx{
byte *b;
};
int phys;
+ BUFFSTATE state;
};
class color{
Modified: trunk/2010/2_crypt.cc
==============================================================================
--- trunk/2010/2_crypt.cc (original)
+++ trunk/2010/2_crypt.cc Wed Jul 4 03:59:17 2007
@@ -26,7 +26,7 @@ int show_points=0;
void decrypt(void){
// if( (crypt == vc || crypt == nag) && satur!=0 ) decomb();
-// decomb();
+ decomb();
if(crypt==vc) vc_decrypt();
else if(crypt==nag) nag_decrypt();
Modified: trunk/2010/2_hw.cc
==============================================================================
--- trunk/2010/2_hw.cc (original)
+++ trunk/2010/2_hw.cc Wed Jul 4 03:59:17 2007
@@ -8,6 +8,7 @@
#include <sys/nearptr.h>
#include <signal.h>
#include <errno.h>
+#include <time.h>
#include "2_all.h"
#include "2_hw.h"
#include "2_hw_asm.h"
@@ -31,9 +32,8 @@
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 xxx dispbuf, *doubleBuff;
extern volatile int one_field;
extern volatile int active_meteor;
extern volatile meteor meteors[8];
@@ -546,33 +546,26 @@ void copy_vidbuffer(void){
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);
+ if(single==0){
+
+ int workingOne=0;
+ while(doubleBuff[workingOne].state!=Working && workingOne<2) workingOne++;
+ if(workingOne==2) workingOne=0; // should be only at start
+ doubleBuff[workingOne].state=Empty;
+
+ int nextOne= workingOne^1;
+ if(doubleBuff[nextOne].state==Empty) nextOne=0; // not critical
+
+// meteors[active_meteor].saa7116->ints_ctl_a |= 0x7;
+// meteors[active_meteor].saa7116->capt_ctl_a |= 0x0F30;
+
+ printf("%X, %X\n", meteors[active_meteor].saa7116->capt_ctl_a,
+ meteors[active_meteor].saa7116->ints_ctl_a );
+
+ printf("%X, %X\n", doubleBuff[0].state,
+ doubleBuff[1].state );
- }
-/*
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]);
@@ -589,7 +582,26 @@ void copy_vidbuffer(void){
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);
- */
+
+ while(doubleBuff[nextOne].state != Grabbed);
+
+ doubleBuff[nextOne].state= Working;
+
+ dispbuf= doubleBuff[nextOne];
+ }
+ else{
+ doubleBuff[0].state=
+ doubleBuff[1].state=Empty;
+
+ while(doubleBuff[0].state != Grabbed);
+
+ doubleBuff[0].state=
+ doubleBuff[1].state=Working;
+
+ dispbuf= doubleBuff[0];
+ }
+
+
}
u_long read_pci(int bus, int dev, int func, int reg, int size){
Modified: trunk/2010/2_hw_asm.s
==============================================================================
--- trunk/2010/2_hw_asm.s (original)
+++ trunk/2010/2_hw_asm.s Wed Jul 4 03:59:17 2007
@@ -22,8 +22,7 @@
.globl _mouse_b
.globl _page_flip
.globl _dispbuf
-.globl _last_dispbuf
-.globl _grab_dispbuf
+.globl _doubleBuff
.globl _vidbuf
.globl _vgax
.globl _xresvb
@@ -41,7 +40,6 @@
.globl _old_intmet_vect
.globl _old_intmet_vect_offset
.globl _old_intmet_vect_selector
-.globl _grab_state
.globl _metmode
.globl _active_meteor
.globl _latency
@@ -86,10 +84,17 @@ _mouse_b: .long 0
_page_flip: .long 0
_dispbuf: .long 0
.long 0
-_last_dispbuf: .long 0
.long 0
-_grab_dispbuf: .long 0
.long 0
+_doubleBuff: .long 1234
+.long 0
+.long 0
+.long 0
+.long 0
+.long 0
+.long 0
+.long 0
+.long 4321
_vidbuf: .long 0
_vgax: .long 0
_vb: .long 0
@@ -106,7 +111,6 @@ _old_intmet_vect:
_old_intmet_vect_offset: .long 0
_old_intmet_vect_selector: .word 0
.align 4
-_grab_state: .long 0
_metmode: .long 0
_active_meteor: .long 0
_latency: .long 32
Modified: trunk/2010/2_mfunc.cc
==============================================================================
--- trunk/2010/2_mfunc.cc (original)
+++ trunk/2010/2_mfunc.cc Wed Jul 4 03:59:17 2007
@@ -160,6 +160,6 @@ void mstd(int num){
setstd_scale();
- start_grab();
+ cont_grab();
}
Modified: trunk/2010/2_nag.cc
==============================================================================
--- trunk/2010/2_nag.cc (original)
+++ trunk/2010/2_nag.cc Wed Jul 4 03:59:17 2007
@@ -12,6 +12,7 @@
#include "2_gfunc.h"
#include "2_mmx.h"
#include "2_nag_a.h"
+#include "2010.h"
#define dwnSmp 1
@@ -24,30 +25,671 @@ extern u_long asm_temp, asm_temp4;
extern int istate;
extern int yuvmode;
extern bool mmx;
+extern volatile int frames;
+
+bool manualPhaseStart=false;
+int *decoLine;
+int decoLines;
+int keyTable[256];
+int *best1=NULL;
+BEST2 *best2=NULL; // FIX DELETE
+KEYSLIST *keysList=NULL;
+static int outy1;
+static int nagStart2;
+static int nagEnd2;
+static int nagStart1;
+static int nagEnd1;
+static int nagSize1;
+static int nagSize2;
+static int nagSizeAll;
+
+bool checkAlign(void *p, int align){ // FIX SHOULD BE SOMEWHERE ELSE
+ if(int(p) & (align-1)) return false;
+ else return true;
+}
+
+
+void *newAlign(int size, int align){ // FIX SHOULD BE SOMEWHERE ELSE
+ int v= int(new char[size + align + 3]);
+ int v2= ( (v+align-1+4) & ~(align-1) );
+ ((int*)v2)[-1]= v;
+ return (void*)v2;
+}
+
+void deleteAlign(void *v){ // FIX SHOULD BE SOMEWHERE ELSE
+ delete [] ((char**)v)[-1];
+}
+
+static inline void getPerm(const int key, int * const perm){
+ int keyNdx= key >> 7;
+ const int keyInc= ((key & 0x7F) << 1) + 1;
+ int buffer[32];
+
+ for(int i=0; i<32; i++) buffer[i]= i;
+
+ for(int i=0; i<255; i++){
+ perm[i]= buffer[ keyTable[keyNdx] ];
+ buffer[ keyTable[keyNdx] ]= i + 32;
+ keyNdx= (keyNdx + keyInc) & 0xFF;
+ }
+
+ for(int i=0; i<32; i++){
+ perm[i+255]= buffer[i];
+ }
+}
+
+static inline void doDwnSmp(byte * const lowRes, byte * const highRes){
+
+ if(mmx){
+ asm(//"int $3 \n\t"
+ "pushl %%ebp \n\t"
+ "cmpb 3f-1, %%cl \n\t"
+ " je 5f \n\t"
+ "movb %%cl, 3f-1 \n\t"
+ "movl $1, %%eax \n\t"
+ "shll %%cl, %%eax \n\t"
+ "movl %%eax, 4f-4 \n\t"
+
+ "5: \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 $0xFFFF, %%ebp \n\t" // U
+ "4: \n\t"
+ "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 $50, %%ebx \n\t" // U 1
+ "3: \n\t"
+ "decl %%edx \n\t" // V 1
+ "movb %%bl, -1(%%edi) \n\t" // U
+ " jnz 1b \n\t" // V 1
+
+ "popl %%ebp \n\t"
+ :
+ : "c" (dwnSmp),
+ "S" (highRes + 1) ,
+ "d" (wndx>>dwnSmp) ,
+ "D" (lowRes)
+ : "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi");
+
+ }
+ else{
+ asm(//"int $3 \n\t"
+ "pushl %%ebp \n\t"
+ "cmpb 3f-1, %%cl \n\t"
+ " je 5f \n\t"
+ "movb %%cl, 3f-1 \n\t"
+ "movl $1, %%eax \n\t"
+ "shll %%cl, %%eax \n\t"
+ "movl %%eax, 4f-4 \n\t"
+
+ "5: \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 $0xFFFF, %%ebp \n\t" // U
+ "4: \n\t"
+ "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 $50, %%ebx \n\t" // U 1
+ "3: \n\t"
+ "decl %%edx \n\t" // V 1
+ "movw %%bx, -2(%%edi) \n\t" // U
+ " jnz 1b \n\t" // V 1
+
+ "popl %%ebp \n\t"
+ :
+ : "c" (dwnSmp),
+ "S" (highRes + 1) ,
+ "d" (wndx>>dwnSmp) ,
+ "D" (lowRes)
+ : "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi");
+ }
+
+
+
+
+}
+
+static inline int nagLineLogi2Phys(const int logi){
+ int phys;
+
+ if(logi<32) phys= nagStart1 + ( logi <<1);
+ else phys= nagStart2 + ((logi-32)<<1);
+ return phys;
+}
+
+void mod4Fix(byte * p, int cleMod4, int encMod4){
+ const bool xchg[16]={false, true, false, true,
+ true, false, true, false,
+ false, true, false, true,
+ true, false, true, false };
+
+ const byte neg[16]={ 0, 0, 0xFF, 0xFF,
+ 0, 0, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0, 0,
+ 0xFF, 0xFF, 0, 0 };
+ const int ndx= cleMod4 | (encMod4<<2);
+
+ for(int x=0; x<(vgax<<1); x+=4){
+ byte u= p[x ]; // perhaps u><v
+ byte v= p[x+2];
+
+ if(xchg[ndx]){
+ const int t=u;
+ u=v;
+ v=t;
+ }
+
+ p[x ]= (u^neg[ndx]) - neg[ndx];
+ p[x+2]= (v^neg[ndx]) - neg[ndx];
+ }
-int blackThreshold= 4000;
-static int qsort_block(const void *p1, const void *p2);
-static int qsort_block(const void *p1, const void *p2){
- return ( (BLOCK*)(p1) )->limit[0] - ( (BLOCK*)(p2) )->limit[0];
}
void nag_decrypt(void){
+ outy1= outy>>1;
+ nagStart2= int(double(17+0 - scales_y)/y_field*outy1 + .5)*2+1;
+ nagEnd2 = int(double(17+254 - scales_y)/y_field*outy1 + .5)*2+1;
+ nagStart1= int(double(17+255 - scales_y)/y_field*outy1 + .5)*2+2;
+ nagEnd1 = int(double(17+286 - scales_y)/y_field*outy1 + .5)*2+2;
+ nagSize1= (nagEnd1 - nagStart1)/2 + 1;
+ nagSize2= (nagEnd2 - nagStart2)/2 + 1;
+ nagSizeAll= nagSize1 + nagSize2;
char textbuf[10][128];
color c;
- const int outy1= outy>>1;
- const int nagStart2= int(double(17+0 - scales_y)/y_field*outy1 + .5)*2+1;
- const int nagEnd2 = int(double(17+254 - scales_y)/y_field*outy1 + .5)*2+1;
- const int nagStart1= int(double(17+255 - scales_y)/y_field*outy1 + .5)*2+2;
- const int nagEnd1 = int(double(17+286 - scales_y)/y_field*outy1 + .5)*2+2;
- const int nagSize1= (nagEnd1 - nagStart1)/2 + 1;
- const int nagSize2= (nagEnd2 - nagStart2)/2 + 1;
- const int nagSizeAll= nagSize1 + nagSize2;
long T1, T2;
- char lastDwnSmp= 50;
const int dwnSmpSize= mmx ? dwnSmp : dwnSmp-1;
+ if(nagSizeAll!=NAG_LINES) error(Nagra);
+
+ T1=uclock();
+
+// if(frames&1) frames++;
+ const int vPhase= (((frames & 2)==2) ^ manualPhaseStart) ? 1 : 0;
+
+// printf("%d %d\n", sizeof(KEYSLIST), sizeof(BEST2) );
+
+// printf("HALLOX\n");
+ static bool first=true;
+
+ if(first){
+ decoLines=14;
+ decoLine=new int[decoLines];
+ decoLine[ 0]= 91;
+ decoLine[ 1]=103;
+ decoLine[ 2]=112;
+ decoLine[ 3]=124;
+ decoLine[ 4]=131;
+ decoLine[ 5]=145;
+ decoLine[ 6]=152;
+ decoLine[ 7]=163;
+ decoLine[ 8]=175;
+ decoLine[ 9]=181;
+ decoLine[10]=194;
+ decoLine[11]=200;
+ decoLine[12]=213;
+ decoLine[13]=222;
+
+ FILE *f= fopen("key.txt", "r");
+ if(f==NULL) error(KeyFile);
+ for(int i=0; i<256; i++)
+ if( fscanf(f, "%d", &keyTable[i])!=1 ) error(KeyFile);
+ fclose(f);
+
+ f=fopen("2010.dat", "rb");
+ if(f!=NULL){
+ int decoLines2;
+ fread(&decoLines2, sizeof(int), 1, f);
+ if(decoLines2!=decoLines) goto badFile;
+
+ int decoLine2[NAG_LINES];
+ fread(decoLine2, sizeof(int), decoLines2, f);
+ if( memcmp(decoLine, decoLine2, decoLines) ) goto badFile;
+
+ int best2Size;
+ int keysListSize;
+ fread(&best2Size, sizeof(int), 1, f);
+ fread(&keysListSize, sizeof(int), 1, f);
+
+ best1= new int[decoLines * NAG_LINES];
+ best2= new BEST2[best2Size];
+ keysList= new KEYSLIST[keysListSize];
+
+ fread(best1, sizeof(int), decoLines * NAG_LINES, f);
+ fread(best2, sizeof(BEST2), best2Size , f);
+ fread(keysList, sizeof(KEYSLIST), keysListSize , f);
+
+ badFile:;
+ fclose(f);
+ f=NULL;
+ }
+
+ if(best1==NULL){
+
+ bool *state= new bool[NAG_LINES * NAG_LINES * decoLines];
+ int *keysTempStart= new int[NAG_LINES * NAG_LINES * decoLines];
+ int *keysTemp= new int[KEYS * decoLines];
+ int best2Size=0;
+
+ for(int i=0; i<NAG_LINES * NAG_LINES * decoLines; i++){
+ state[i]=false;
+ keysTempStart[i]=-1;
+ }
+
+
+ for(int key=KEYS-1; key>=0; key--){
+ int perm[NAG_LINES];
+ getPerm(key, perm);
+ for(int clearLine=0; clearLine<NAG_LINES; clearLine++){
+ for(int dL=0; dL<decoLines; dL++){
+ if(perm[clearLine]==decoLine[dL]){
+ int goodLine[2]={
+ clearLine>0 ? perm[clearLine-1] : perm[clearLine+2],
+ clearLine<NAG_LINES-1 ? perm[clearLine+1] : perm[clearLine-2] };
+
+ if(goodLine[1]<goodLine[0]){
+ const int t= goodLine[0];
+ goodLine[0]= goodLine[1];
+ goodLine[1]= t;
+ }
+
+ const int ndx=
+ dL*NAG_LINES*NAG_LINES + goodLine[0]*NAG_LINES + goodLine[1];
+
+ if(!state[ndx]) best2Size++;
+ state[ndx]=true;
+ keysTemp[key + dL*KEYS]= keysTempStart[ndx];
+ keysTempStart[ndx]= key + dL*KEYS;
+
+ }
+ }
+ }
+ }
+
+ // fix compression for keysList
+ int keysListSize= KEYS*decoLines;
+
+ best1= new int[NAG_LINES * decoLines];
+ best2= new BEST2[best2Size];
+ keysList= new KEYSLIST[keysListSize];
+
+ for(int i=0; i<NAG_LINES * decoLines; i++){
+ best1[i]=-1;
+ }
+
+ int best2Pos=0;
+ int keysListPos=0;
+
+ for(int dL=0; dL<decoLines; dL++){
+ for(int line0=0; line0<NAG_LINES; line0++){
+ const int ndx1= dL*NAG_LINES + line0;
+ for(int line1=line0; line1<NAG_LINES; line1++){
+ const int ndx2= dL*NAG_LINES*NAG_LINES + line0*NAG_LINES + line1;
+
+ if(best1[ndx1]==-1) best1[ndx1]= best2Pos;
+
+ if(keysTempStart[ndx2] == -1) continue;
+
+ best2[best2Pos]= (BEST2){ line:line1, keyNdx:keysListPos };
+
+// printf("B2 %d %d\n", line1, keysListPos);
+
+
+ int keyP=keysTempStart[ndx2];
+ while(keyP!=-1){
+ keysList[keysListPos]=(KEYSLIST){last:0, key:(keyP & (KEYS-1))};
+ keysListPos++;
+// printf("KL %d\n", keyP);
+ keyP=keysTemp[keyP];
+ }
+ if(keysListPos>0) keysList[keysListPos-1].last=1;
+// printf("KL END\n");
+
+ best2Pos++;
+ }
+// printf("B2 END\n");
+ }
+ }
+
+ delete [] keysTemp;
+ delete [] keysTempStart;
+ delete [] state;
+
+ f=fopen("2010.dat", "wb");
+ if(f==NULL) error(DatWrite);
+
+ fwrite(&decoLines, sizeof(int), 1, f);
+ fwrite(decoLine, sizeof(int), decoLines, f);
+
+ fwrite(&best2Size, sizeof(int), 1, f);
+ fwrite(&keysListSize, sizeof(int), 1, f);
+
+ fwrite(best1, sizeof(int), decoLines * NAG_LINES, f);
+ fwrite(best2, sizeof(BEST2), best2Size , f);
+ fwrite(keysList, sizeof(KEYSLIST), keysListSize , f);
+
+ fclose(f);
+
+ }
+ }
+ first=false;
+
+ BESTCOEFFS *bestCoeffs= new BESTCOEFFS[decoLines];
+ for(int i=0; i<decoLines; i++){
+ bestCoeffs[i].coeff[0]=
+ bestCoeffs[i].coeff[1]=0xFFFFF;
+ }
+
+ byte * const decoLowRes=(byte*) newAlign( (wndx>>dwnSmpSize) * decoLines, 8);
+// printf("%d\n", int(decoLowRes));
+ for(int dL=0; dL<decoLines; dL++){
+ byte * const linep= dispbuf.b + nagLineLogi2Phys(decoLine[dL])*(vgax<<1);
+ byte * const lowResp= decoLowRes + dL*(wndx>>dwnSmpSize);
+ doDwnSmp(lowResp ,linep);
+// printf("%X\n", int(lowResp)); // FIX alignment (fine now but...)
+ }
+
+ if(istate==1){
+ T2=uclock();
+ sprintf(textbuf[0],"%f ReSample decoLines", (float)(T2-T1)/UCLOCKS_PER_SEC);
+ T1=T2;
+ }
+
+ byte * const lowRes=(byte*) newAlign( (wndx>>dwnSmpSize) * decoLines, 8);
+// printf("%d\n", int(lowRes));
+ for(int line=0; line<NAG_LINES; line++){
+ byte * const linep= dispbuf.b + nagLineLogi2Phys(line)*(vgax<<1);
+// printf("%d\n", line);
+ doDwnSmp(lowRes, linep);
+// printf("xxX\n");
+ byte *decoLowResp=decoLowRes;
+ for(int dL=0; dL<decoLines; dL++){
+ if(decoLine[dL]!=line)
+ nagraCorr(int(lowRes), int(decoLowResp), wndx>>dwnSmpSize, int(&bestCoeffs[dL]), line);
+ decoLowResp+= wndx>>dwnSmpSize;
+ }
+ }
+ if(mmx) asm("emms\n\t");
+// printf("H1\n");
+
+ deleteAlign(decoLowRes);
+ deleteAlign(lowRes);
+// printf("H2\n");
+
+ if(istate==1){
+ T2=uclock();
+ sprintf(textbuf[1],"%f Corr", (float)(T2-T1)/UCLOCKS_PER_SEC);
+ T1=T2;
+ }
+
+ int *keysListPos= new int[decoLines];
+ int keysListPoses= 0;
+ for(int dL=0; dL<decoLines; dL++){
+ if(bestCoeffs[dL].line[1] < bestCoeffs[dL].line[0]){
+ const int t= bestCoeffs[dL].line[1];
+ bestCoeffs[dL].line[1]= bestCoeffs[dL].line[0];
+ bestCoeffs[dL].line[0]= t;
+ }
+
+ int l= best1[ bestCoeffs[dL].line[0] + dL*NAG_LINES ];
+ int r= best1[ bestCoeffs[dL].line[0] + 1 + dL*NAG_LINES ];
+ if(l == r) continue;
+ r--;
+
+ while(l != r){
+ if( int(best2[ (l+r)>>1 ].line) < bestCoeffs[dL].line[1] ) l= (l+r+2)>>1;
+ else r= (l+r )>>1;
+ }
+
+ if( int(best2[l].line) != bestCoeffs[dL].line[1] ) continue;
+
+ keysListPos[keysListPoses]= best2[l].keyNdx;
+ keysListPoses++;
+ }
+// printf("H3\n");
+
+ if(istate==1){
+ T2=uclock();
+ sprintf(textbuf[2],"%f GenKeyPointers", (float)(T2-T1)/UCLOCKS_PER_SEC);
+ T1=T2;
+ }
+
+ bool didSome;
+ int lastLowKey=-1;
+ int bestKey=0;
+ int bestNum=0;
+ do{
+ didSome=false;
+ int lowKey=0xFFFF;
+ int lowNum=0;
+ for(int kLP=0; kLP<keysListPoses; kLP++){
+ if(keysListPos[kLP]==-1) continue;
+
+ if( int(keysList[ keysListPos[kLP] ].key)==lastLowKey ){
+ if( keysList[ keysListPos[kLP] ].last==1 ){
+ keysListPos[kLP]=-1;
+ continue;
+ }
+ keysListPos[kLP]++;
+ }
+
+ if( int(keysList[ keysListPos[kLP] ].key) == lowKey ){
+ lowNum++;
+ }
+ if( int(keysList[ keysListPos[kLP] ].key) < lowKey ){
+ lowKey= int(keysList[ keysListPos[kLP] ].key);
+ lowNum=0;
+ }
+ didSome= true;
+ }
+ lastLowKey=lowKey;
+// printf(" %d %d\n", lowNum, lowKey);
+ if(lowNum>bestNum){
+ bestNum=lowNum;
+ bestKey=lowKey;
+ }
+ }while(didSome);
+
+ delete [] keysListPos;
+
+ int perm[NAG_LINES];
+ getPerm(bestKey, perm);
+ printf("%X\n", bestKey);
+
+ if(istate==1){
+ T2=uclock();
+ sprintf(textbuf[3],"%f FindKey", (float)(T2-T1)/UCLOCKS_PER_SEC);
+ T1=T2;
+ }
+
+ sprintf(textbuf[6],"%d %d vPhase", vPhase, int(frames));
+
+ byte *lowDriftLinep= NULL;
+ for(int i=0; i<NAG_LINES; i++){
+ if(perm[i]>=32 && mabs(perm[i]-32 - i)<5){
+ const cleMod4= (i + vPhase ) & 3;
+ const encMod4= (perm[i] + vPhase ) & 3;
+
+ lowDriftLinep= dispbuf.b + nagLineLogi2Phys( perm[i] ) * (vgax<<1);
+
+ if(cleMod4!=encMod4) mod4Fix(lowDriftLinep, cleMod4, encMod4);
+
+ break;
+ }
+ }
+
+ for(int clearLine=0 ;clearLine<NAG_LINES; clearLine++){
+ byte * const linep= dispbuf.b + nagLineLogi2Phys( perm[clearLine] ) * (vgax<<1);
+
+ if(perm[clearLine]>=32 && mabs(perm[clearLine]-32 - clearLine)<5){
+ const cleMod4= (clearLine + vPhase ) & 3;
+ const encMod4= (perm[clearLine] + vPhase ) & 3;
+
+ lowDriftLinep= dispbuf.b + nagLineLogi2Phys( perm[clearLine] ) * (vgax<<1);
+
+ if(cleMod4!=encMod4) mod4Fix(lowDriftLinep, cleMod4, encMod4);
+ }
+ else{
+ for(int x=0; x<(vgax<<1); x+=2){
+ linep[x]= lowDriftLinep[x];
+ }
+ }
+ }
+
+
+
+ if(istate==1){
+ T2=uclock();
+ sprintf(textbuf[5],"%f ColorDeco", (float)(T2-T1)/UCLOCKS_PER_SEC);
+ T1=T2;
+ }
+
+// printf("H4\n");
+/*
+ for(int i=0; i<NAG_LINES; i++){
+ const int p=nagLineLogi2Phys(i);
+ dispbuf.b[p*(vgax<<1)+i*2+1]=255;
+ }
+
+ for(int i=0; i<decoLines; i++){
+ const int p1=nagLineLogi2Phys(decoLine[i]);
+ const int p2=nagLineLogi2Phys(bestCoeffs[i].line[0]);
+ const int p3=nagLineLogi2Phys(bestCoeffs[i].line[1]);
+ for(int j=0; j<20; j++){
+ dispbuf.b[p1*(vgax<<1)+i*20+101+j]=255;
+ dispbuf.b[p2*(vgax<<1)+i*20+101+j]=255;
+ dispbuf.b[p3*(vgax<<1)+i*20+101+j]=255;
+ }
+ }
+*/
+ delete [] bestCoeffs;
+
+ int enc2cleVec[outy];
+ int cle2encVec[outy];
+
+ for(int i=0; i<outy; i++){
+ enc2cleVec[i]=
+ cle2encVec[i]=-1;
+ }
+
+ for(int i=0; i<NAG_LINES; i++){
+ const int encodLine= nagLineLogi2Phys(perm[i]);
+ const int clearLine= i;
+
+ enc2cleVec[ encodLine ]= clearLine;
+ cle2encVec[ clearLine ]= encodLine;
+ }
+
+ byte *copyBuff= new byte[vgax<<1];
+
+ for(int i=0; i<outy; i++){
+ if(cle2encVec[i] == -1 || cle2encVec[i] == i) continue;
+ int k;
+ int j=i;
+ do{
+ k = j;
+ j = enc2cleVec[j];
+ } while(j != i && j != -1);
+ const bool open= (j == -1);
+
+ if(!open){
+ memcpy(copyBuff, dispbuf.cl + i * vgax, wndx << 1);
+ j = i;
+ do{
+ k = j;
+ j = cle2encVec[j];
+ enc2cleVec[k] = k;
+ cle2encVec[k] = k;
+// printf("closed %d %d\n", j, k );
+ if(j != i) memcpy(dispbuf.cl + k * vgax, dispbuf.cl + j * vgax, wndx << 1);
+ } while(j != i);
+ memcpy(dispbuf.cl + k * vgax, copyBuff, wndx << 1);
+ }
+ else{
+ j = k;
+ do{
+ k = j;
+ j = cle2encVec[j];
+ enc2cleVec[k] = k;
+ cle2encVec[k] = k;
+// printf("open %d %d\n", j, k );
+ if(j != -1) memcpy(dispbuf.cl + k * vgax, dispbuf.cl + j * vgax, wndx << 1);
+ } while(j != -1);
+ }
+
+ }
+
+ if(outy == wndy){
+ for(int i=0; i<outy; i+=2){
+ memcpy(dispbuf.cl + (i+1) * vgax, dispbuf.cl + i * vgax, wndx << 1);
+ }
+ }
+
+ delete [] copyBuff;
+
+ if(istate==1){
+ T2=uclock();
+ sprintf(textbuf[4],"%f ReOrder", (float)(T2-T1)/UCLOCKS_PER_SEC);
+ T1=T2;
+ }
+
+
+
+
+
+
+ if(istate==1){
+ T2=uclock();
+ 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]);
+ gprint(170, 170, c.c, textbuf[9]);*/
+ T1=T2;
+ }
+
+
+
+
+#ifdef 0
+
+
+
+
+
+
+
+
+
+
printf("%d %d %d %d %d %d %d\n", nagStart2, nagEnd2, nagStart1, nagEnd1,
nagSize1, nagSize2, nagSizeAll);
@@ -187,11 +829,6 @@ void nag_decrypt(void){
lowResLine+= wndx >> dwnSmpSize;
}
- if(istate==1){
- T2=uclock();
- sprintf(textbuf[9],"%f ReSample", (float)(T2-T1)/UCLOCKS_PER_SEC);
- T1=T2;
- }
printf("HALLO1\n");
@@ -668,24 +1305,6 @@ void nag_decrypt(void){
}
}
- if(istate==1){
- T2=uclock();
- sprintf(textbuf[6],"%f Move", (float)(T2-T1)/UCLOCKS_PER_SEC);
- sprintf(textbuf[7],"%d Blocks", block_noblack);
- sprintf(textbuf[8],"%d Loops", corrLoops);
- 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]);
- gprint(170, 170, c.c, textbuf[9]);
- T1=T2;
- }
delete [] lowRes;
delete [] block;
@@ -694,5 +1313,7 @@ void nag_decrypt(void){
delete [] sortedCoeff;
delete [] bufferInfo;
+#endif
+
}
Modified: trunk/2010/2_nag.h
==============================================================================
--- trunk/2010/2_nag.h (original)
+++ trunk/2010/2_nag.h Wed Jul 4 03:59:17 2007
@@ -2,47 +2,23 @@
#ifndef n2_nag_h
#define n2_nag_h
-#define L_ENT 8
#define MIN_DWN_SMP 1
-#define LAST_MASK 0x8000
-#define NAGRA_BUFFER 32
-#define DO_COEFF 0xFFFE
-#define DONT_COEFF 0xFFFF
-
-enum STATE{
- eBlack,
- eMiddle,
- eSingle,
- eEnd,
-};
-
-struct BLOCK;
-
-struct LINEINF{
- STATE state;
- int block;
- int next[2];
- int nextCoeff[2];
-};
-
-struct BLOCK{
- int end[2];
- int limit[2];
- int ent;
-};
+#define KEYS 32768
+#define NAG_LINES 287
-struct COEFFSLINE{
- int line[L_ENT];
- int coeff[L_ENT];
+struct BEST2{
+ unsigned line:9;
+ unsigned keyNdx:23;
};
-struct TEMPSORT{
- int line[2];
- int coeff;
+struct KEYSLIST{
+ unsigned last:1;
+ unsigned key:15;
};
-struct SORTEDCOEFF{
+struct BESTCOEFFS{
int line[2];
+ int coeff[2];
};
void nag_decrypt(void);
Modified: trunk/2010/2_nag_a.asm
==============================================================================
--- trunk/2010/2_nag_a.asm (original)
+++ trunk/2010/2_nag_a.asm Wed Jul 4 03:59:17 2007
@@ -8,38 +8,17 @@ 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 coeffsLine par6
-%define databuf par7
-
-%define L_ENT 8
-%define ld_L_ENT 3+2+1
-; 1<<3=8 1<<2=4 1<<1=2 ( line + coeff ) * 4 * L_ENT
-%define firstLine 0
-%define firstCoeff (4*L_ENT)
-%define lastLine (4*L_ENT-4)
-%define lastCoeff (8*L_ENT-4)
-
-%define bs1Coeff (4*L_ENT + 2*L_ENT -4)
-%define bs2Coeff (4*L_ENT + L_ENT -4)
-%define bs3Coeff (4*L_ENT + L_ENT/2-4)
+global _nagraCorr__Fiiiii
-%define bs1 (2*L_ENT)
-%define bs2 ( L_ENT)
-%define bs3 ( L_ENT/2)
+%define buf1 par1
+%define buf2 par2
+%define bufSize par3
+%define best par4
+%define line par5
-_nagra_corr__Fiiiiiii:
+_nagraCorr__Fiiiii:
; push eax
push ebx
@@ -50,50 +29,31 @@ _nagra_corr__Fiiiiiii:
push edi
push ebp
- mov ebx, [line2]
-
-loopi:
-
- mov [_asm_temp2], ebx
- mov ebp, [coeffsLine]
-
- shl ebx, ld_L_ENT
- mov edx, [xress_check2]
-
- add ebx, ebp
- mov ecx, [linep2]
-
- mov [_asm_temp3], ebx
- add ecx, edx
-
- mov ebx, [ebx + firstCoeff]
- mov [linep2], ecx
-
- mov esi, [databuf]
- cmp ebx, 0xFFFF
+ mov esi, [buf1]
- mov edi, esi
- jz NEAR End_NoEsp
+ mov edx, [bufSize]
+ mov edi, [buf2]
add esi, edx
add edi, edx
- add esi, ecx
- mov ecx, [linep]
-
xor edx, -1
- add edi, ecx
-
- inc edx
mov eax, [_mmx]
+ add edx, 8
+ mov ebx, [best]
+
+ mov [_asm_temp], ebx
+ mov ebx, [line]
+
+ mov [_asm_temp2], ebx
+
mov [esp_save], esp
mov esp, edx
test eax, eax
jz NoMMX
- int 3
movq mm3, [mmx_zero]
movq mm0, [esp + esi]
@@ -119,7 +79,7 @@ MMXloop:
movq mm2, mm0 ; V 1
add esp, 8 ; U
jnc MMXloop ; V 1
- int 3
+
movq mm0, mm5
psrlq mm5, 32
@@ -183,97 +143,31 @@ NoMMXloop:
EndMMX:
- mov eax, [ebx + lastCoeff] ; U | V 1
- cmp ebp, eax ; U
- jg TryNext ; V 1
-
- mov eax, [ebx + bs1Coeff] ; U 1
- cmp eax, ebp ; U
- mov esp, [_asm_temp2] ; V 1 line2
- sbb ecx, ecx ; U
- mov edx, L_ENT*4-8 ; V 1
- and ecx, bs1 ; U 1
-
- mov eax, [ebx + ecx + bs2Coeff]; U 2 AGI
- cmp eax, ebp ; U 1
- sbb esi, esi ; U 1
- and esi, bs2 ; U 1
- or ecx, esi ; U 1
-
- mov eax, [ebx + ecx + bs3Coeff]; U 2 AGI
- cmp eax, ebp ; U 1
- sbb esi, esi ; U 1
- and esi, bs3 ; U 1
- or ecx, esi ; U 1
-
-Copy1:
- mov esi, [ebx + edx + firstLine] ; U
- mov edi, [ebx + edx + firstCoeff] ; V 1
- mov [ebx + edx + 4 + firstLine], esi ; U
- mov [ebx + edx + 4 + firstCoeff], edi ; V 1
- sub edx, 4 ; U
- cmp edx, ecx ; V 1
- jge Copy1 ; U 1
- mov [ebx + ecx + firstLine], esp ; U
- mov [ebx + ecx + firstCoeff], ebp ; V 1
-
-
-TryNext:
-
-
- mov ebx, [_asm_temp3] ; U 1 line_inf[line2]
-
- mov eax, [ebx + lastCoeff] ; U 2 AGI
+ mov eax, [ebx + 12] ; U | V 1
cmp ebp, eax ; U
jg End ; V 1
- mov eax, [ebx + bs1Coeff] ; U 1
- cmp eax, ebp ; U
- mov esp, [_asm_temp4] ; V 1 line
- sbb ecx, ecx ; U
- mov edx, L_ENT*4-8 ; V 1
- and ecx, bs1 ; U 1
+ mov eax, [ebx + 8 ] ; U
+ mov edx, [_asm_temp2] ; V 1
+ cmp ebp, eax ; U
+ jg JustLast ; V 1
- mov eax, [ebx + ecx + bs2Coeff]; U 2 AGI
- cmp eax, ebp ; U 1
- sbb esi, esi ; U 1
- and esi, bs2 ; U 1
- or ecx, esi ; U 1
+ mov ecx, [ebx ] ; U
+ mov [ebx + 12], eax ; V 1
+ mov [ebx + 4 ], ecx ; U
+ mov [ebx ], edx ; V 1
+ mov [ebx + 8 ], ebp ; U 1
- mov eax, [ebx + ecx + bs3Coeff]; U 2 AGI
- cmp eax, ebp ; U 1
- sbb esi, esi ; U 1
- and esi, bs3 ; U 1
- or ecx, esi ; U 1
+ jmp End ; U 1
+JustLast:
+
+ mov [ebx + 4 ], edx ; U
+ mov [ebx + 12], ebp ; V 1
-Copy2:
- mov esi, [ebx + edx + firstLine] ; U
- mov edi, [ebx + edx + firstCoeff] ; V 1
- mov [ebx + edx + 4 + firstLine], esi ; U
- mov [ebx + edx + 4 + firstCoeff], edi ; V 1
- sub edx, 4 ; U
- cmp edx, ecx ; V 1
- jge Copy2 ; U 1
- mov [ebx + ecx + firstLine], esp ; U
- mov [ebx + ecx + firstCoeff], ebp ; V 1
-
End:
mov esp, [esp_save]
-End_NoEsp:
-
- mov ebx, [line2]
- mov ecx, [line2_end]
-
- inc ebx
-
- cmp ebx, ecx
- mov [line2], ebx
-
- jl NEAR loopi
-
-
pop ebp
pop edi
pop esi
Modified: trunk/2010/2_nag_a.h
==============================================================================
--- trunk/2010/2_nag_a.h (original)
+++ trunk/2010/2_nag_a.h Wed Jul 4 03:59:17 2007
@@ -2,6 +2,6 @@
#ifndef n2_nag_a_h
#define n2_nag_a_h
-void nagra_corr(int, int, int, int, int, int, int);
+void nagraCorr(int, int, int, int, int);
#endif
Modified: trunk/2010/makefile
==============================================================================
--- trunk/2010/makefile (original)
+++ trunk/2010/makefile Wed Jul 4 03:59:17 2007
@@ -20,7 +20,8 @@ O = 2010.o 2_file.o 2_menu.o 2_grafix.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_menu.h 2_mfunc.h 2_move.h 2_71x6.h 2_hw_mem.h\
+ 2_nag.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\
@@ -36,7 +37,8 @@ clean: ; del $(O) 2010
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_nag.o : 2_nag.cc 2_all.h 2_nag.h 2_crypt.h 2_gfunc.h 2_mmx.h 2_nag_a.h\
+ 2010.h
2_hw_asm.o : 2_hw_asm.s
1
0
04 Jul '07
Author: michael
Date: Wed Jul 4 03:45:27 2007
New Revision: 45
Log:
version from june 1998
Added:
trunk/2010/2010.cur (contents, props changed)
Removed:
trunk/2010/2_7116.h
Modified:
trunk/2010/2010.cc
trunk/2010/2010.h
trunk/2010/2_71x6.cc
trunk/2010/2_all.h
trunk/2010/2_crypt.cc
trunk/2010/2_file.cc
trunk/2010/2_gfunc.cc
trunk/2010/2_hw.cc
trunk/2010/2_hw_asm.s
trunk/2010/2_hw_mem.cc
trunk/2010/2_hw_mem.h
trunk/2010/2_menu.cc
trunk/2010/2_mfunc.cc
trunk/2010/2_move.cc
trunk/2010/2_nag.cc
trunk/2010/2_nag.h
trunk/2010/2_nag_a.asm
trunk/2010/2_vc.cc
trunk/2010/2do
trunk/2010/makefile
Modified: trunk/2010/2010.cc
==============================================================================
--- trunk/2010/2010.cc (original)
+++ trunk/2010/2010.cc Wed Jul 4 03:45:27 2007
@@ -1,4 +1,4 @@
-//2010 0.1 Copyright (C) Michael Niedermayer 1998
+//2010 0.1 Copyright (c) 1998 Michael Niedermayer
#include <stdlib.h>
#include <pc.h>
@@ -26,7 +26,7 @@
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 vgax, vgay, xresvb, xresc, vb, mc;
extern int active_meteor;
extern int me, mx, my;
extern int yuvmode;
@@ -124,7 +124,7 @@ int main(int argc, char **argv){
FILE *f;
int mc2;
- printf("2010 0.10 Copyright (C) Michael Niedermayer 1998\n");
+ printf("2010 0.10 Copyright (c) 1998 Michael Niedermayer\n");
atexit(exitt);
@@ -269,27 +269,32 @@ int main(int argc, char **argv){
error(VESA);
- xres=mib->Xres;
- yres=mib->Yres;
+ vgax=mib->Xres;
+ vgay=mib->Yres;
if(yuvmode!=0) mc=1;
else mc=2;
if(yuvmode==2) mc2=1;
else mc2=2;
- xresc=xres<<mc;
+ xresc=vgax<<mc;
bpp=mib->bpp;
vb=bpp>>3;
- xresvb=xres*vb;
+ xresvb=vgax*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;
+ xxx *a;
+ if(single==0)
+ a= alloc_cont(vgax * vgay << mc2, 2);
+ else
+ a= alloc_cont(vgax * vgay << mc2, 1);
- if(page_flip==0) i= xres * yres * vb;
- else i= xres * yres * vb << 1;
+ dispbuf =a[0];
+ grab_dispbuf=a[1];
+
+ if(page_flip==0) i= vgax * vgay * vb;
+ else i= vgax * vgay * vb << 1;
vidbuf=(byte*)( map(mib->PhysBase, mib->PhysBase+i) - __djgpp_base_address);
Added: trunk/2010/2010.cur
==============================================================================
Binary file. No diff available.
Modified: trunk/2010/2010.h
==============================================================================
--- trunk/2010/2010.h (original)
+++ trunk/2010/2010.h Wed Jul 4 03:45:27 2007
@@ -31,6 +31,5 @@ typedef enum{
int error(error_code e);
void exitt(void);
-void find_dup(int num);
#endif
Modified: trunk/2010/2_71x6.cc
==============================================================================
--- trunk/2010/2_71x6.cc (original)
+++ trunk/2010/2_71x6.cc Wed Jul 4 03:45:27 2007
@@ -38,18 +38,20 @@ extern volatile int x_field, y_field, on
extern volatile int xresc, yuvmode, mc;
extern volatile xxx dispbuf, grab_dispbuf;
extern volatile int stride;
-extern int xress, yress, yrest, yresst;
+extern int wndx, wndy, outy;
extern int single;
extern int init_menu;
extern int nagra_mode;
-extern int xres, yres;
+extern int vgax, vgay;
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 scales_x=0x03, scales_y= 0x10; 3 / 574 / 3 nag 800600
+//int scalee_x=0x03, scalee_y= 0x12;
+int scales_x=0x03, scales_y= 0x11;
+int scalee_x=0x03, scalee_y= 0x11;
int bypass_y=0x0, bypasc_y=0x0;
@@ -284,7 +286,7 @@ void grab_next(void){
}
a_saa7116->dma_end.even=
- a_saa7116->dma_end.odd= grab_dispbuf.phys + xresc*yresst - 1;
+ a_saa7116->dma_end.odd= grab_dispbuf.phys + xresc*outy - 1;
}
@@ -309,60 +311,63 @@ void setstd_scale(void){
init_menu=1;
if(yuvmode!=0) mc=1;
else mc=2;
- xresc=xres<<mc;
+ xresc=vgax<<mc;
- xress=xres;
+ wndx=vgax;
if(std==NTSC)
- y_field=240-scales_y+0x10-scalee_y, x_field=640-scales_x+3-scalee_x;
+ y_field=240-scales_y+scalee_y, x_field=640-scales_x+scalee_x;
else
- y_field=288-scales_y+0x10-scalee_y, x_field=768-scales_x+3-scalee_x;
+ y_field=288-scales_y+scalee_y, x_field=768-scales_x+scalee_x;
- if(yres-70 <= y_field && nagra_mode==0) one_field=1;
+ if(vgay-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;
+ int yrest;
+ if(nagra_mode==0 || vgay-70 > y_field) yrest= vgay;
+ else yrest= vgay << 1;
if (one_field==0 && yrest>y_field*2){
- yresst= y_field*2;
- xress= int( double(xress) * double(yresst) / double(yrest) );
+ outy= y_field*2;
+ wndx= int( double(wndx) * double(outy) / double(yrest) );
}
else if(one_field==1 && yrest>y_field ){
- yresst= y_field;
- xress= int( double(xress) * double(yresst) / double(yrest) );
+ outy= y_field;
+ wndx= int( double(wndx) * double(outy) / double(yrest) );
}
else{
- yresst= yrest;
+ outy= yrest;
}
- if(xress > x_field){
- yresst= int( double(yresst) * double(x_field) / double(xress) );
- xress= x_field;
+ if(wndx > vgax){
+// outy= int( double(outy) * double(x_field) / double(vgax) ); // ?! JOKE
+ wndx= vgax;
}
- xress =(xress + 7) & 0x3F8;
- yresst=(yresst + 1) & 0x3FE;
+ if(wndx>x_field) wndx=x_field; // no scaling !?
- if(xress > xres ) xres -=8;
- if(yresst > yrest) yresst-=2;
+ wndx =(wndx + 7) & 0x3F8;
+ outy=(outy + 1) & 0x3FE;
- if(one_field==0) stride=(xres + xres - xress)<<mc;
- else stride=(xres - xress)<<mc;
+ if(wndx > vgax ) vgax -=8;
+ if(outy > yrest) outy-=2;
- if(nagra_mode==0 || yres-70 > y_field) yress= yresst;
- else yress= yresst >> 1;
+ if(one_field==0) stride=(vgax + vgax - wndx)<<mc;
+ else stride=(vgax - wndx)<<mc;
+
+ if(nagra_mode==0 || vgay-70 > y_field) wndy= outy;
+ else wndy= outy >> 1;
if(std==SECAM) write_saa7196(0x0D, 0x85);
- else write_saa7196(0x0D, 0x84);
+ 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);
+ else write_saa7196(0x0F, 0x90);
/* 7 Automatic Field detection
6 Field Select 0 = 50hz, 1=60hz
5 SECAM cross-colour reduction
@@ -385,26 +390,26 @@ void setstd_scale(void){
4 VRAM port outputs enable
3:2 First pixel position in VRO data
1:0 FIFO output register select */
- write_saa7196(0x21, xress & 0xFF);
+ write_saa7196(0x21, wndx & 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));
+ write_saa7196(0x24, i | ((x_field>>6) & 0x0C) | (wndx>>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);
+ if(one_field==1) write_saa7196(0x25, outy & 0xFF);
+ else write_saa7196(0x25, (outy>>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));
+ if(one_field==1) write_saa7196(0x28, i | ((y_field>>6) & 0x0C) | (outy>>8));
+ else write_saa7196(0x28, i | ((y_field>>6) & 0x0C) | (outy>>9));
/* 7 Adaptive filter switch
6:5 Vertical luminance data processing
4 [8] Vertical start of scaling window
@@ -414,6 +419,9 @@ void setstd_scale(void){
write_saa7196(0x29, bypass_y);/* 7:0 [7:0] Vertical bypass start */
write_saa7196(0x2A, bypasc_y);/* 7:0 [7:0] Vertical bypass count */
+ printf("%d %d %d %d %d %d %d %d\n",vgax, vgay , wndx, wndy, outy,
+ y_field , x_field, stride);
+
}
void init_meteor(void){
@@ -500,7 +508,7 @@ void init_meteor(void){
write_saa7196(0x05, 0xF4);/* 7:0 Horizontal Sync Start after PH1 for 50hz */
- write_saa7196(0x06, 0x46);
+ write_saa7196(0x06, 0x46); //46
/* 7 Input mode =0 CVBS, =1 S-Video
6 Pre filter
5:4 Aperture Bandpass characteristics
@@ -520,7 +528,8 @@ void init_meteor(void){
2 S-VHS bit
1 GPSW2
0 GPSW1 */
- write_saa7196(0x10, 0x00);
+write_saa7196(0x10, 0x00); //BAK
+//write_saa7196(0x10, 0x02);
// write_saa7196(0x10, 0x04);
/* 2 Select HREF Position
1:0 Vertical noise reduction */
@@ -599,7 +608,7 @@ void start_grab(void){
stride;
}
a_saa7116->dma_end.even=
- a_saa7116->dma_end.odd= grab_dispbuf.phys + xresc*yresst - 1;
+ a_saa7116->dma_end.odd= grab_dispbuf.phys + xresc*outy - 1;
Modified: trunk/2010/2_all.h
==============================================================================
--- trunk/2010/2_all.h (original)
+++ trunk/2010/2_all.h Wed Jul 4 03:45:27 2007
@@ -7,6 +7,9 @@
#define is_neg(a) ((a)<0 ? 0 : -1)
#define is_pos(a) ((a)<0 ? -1 : 0)
+#define max(a,b) ((a)>(b) ? (a) : (b))
+#define min(a,b) ((a)<(b) ? (a) : (b))
+
#define u_char unsigned char
#define u_long unsigned long
#define u_short unsigned short
Modified: trunk/2010/2_crypt.cc
==============================================================================
--- trunk/2010/2_crypt.cc (original)
+++ trunk/2010/2_crypt.cc Wed Jul 4 03:45:27 2007
@@ -9,7 +9,7 @@
extern volatile tv_form std;
extern volatile crypt_form crypt;
-extern xres, yres, xress, yress, y_field, yresst, yrest;
+extern vgax, vgay, wndx, wndy, y_field, outy;
extern xxx dispbuf;
extern volatile int scales_x, scalee_x;
extern volatile int scales_y, scalee_y;
@@ -41,41 +41,49 @@ static void decomb(void){
int linep, llinep, line, i, o;
int j, k;
int temp[max_x];
- const int yresst1= yresst>>1;
+ int amp[max_x];
+ const int outy1= outy>>1;
- const int stride=one_field ? (xres<<1) : (xres<<2);
+ const int stride=one_field ? (vgax<<1) : (vgax<<2);
const int pass=one_field ? 1 : 2;
- const int end=one_field ? yresst : yresst1;
+ const int end=one_field ? outy : outy1;
for(o=0; o<pass; o++){
- for(i=0; i<max_x; i++) temp[i]=0;
+ for(i=0; i<max_x; i++){
+ temp[i]=0;
+ amp[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+=vgax<<1;
+ for(line=0; line<end; line++){
+ linep+=stride;
+ for(i=0; i<wndx; i++){
+ j = int(dispbuf.b[linep + (i<<1)]);
+ k = temp[i];
+ if(j>127) j= j - 256;
+ j= (j + j) - k;
+ temp[i] = j;
+ if(line & 1) amp[i]-=j;
+ else amp[i]+=j;
+ }
}
-
+
+ for(i=0; i<max_x; i++){
+ temp[i]= amp[i]/end;
+ }
+
linep=-stride;
- if(o) linep+=xres<<1;
+ if(o) linep+=vgax<<1;
for(line=0; line<end; line++){
linep+=stride;
- for(i=0; i<xress; i++){
+ for(i=0; i<wndx; i++){
j = int(dispbuf.b[linep + (i<<1)]);
- k = temp[i] & (~1);
+ k = temp[i];
if(j>127) j= j - 256;
j=(j + j) - k;
dispbuf.b[linep + (i<<1)] = (char)(j);
- j-=j>>4;
temp[i] = j;
}
}
@@ -114,24 +122,24 @@ static void decomb(void){
" jnz 1b \n\t" // V 1
:
- : "D" (one_field==1 ? (xres<<1) : (xres<<2)), "S" (dispbuf.b),
- "d" (xres * yress>>1)
+ : "D" (one_field==1 ? (vgax<<1) : (vgax<<2)), "S" (dispbuf.b),
+ "d" (vgax * wndy>>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;
+ for(int x=0; x < wndx; x++){
+ dispbuf.rgb[x + y*vgax].r=( (dispbuf.rgb[x + y *vgax].r >> 1)
+ + (dispbuf.rgb[x + (y+1)*vgax].r )
+ + (dispbuf.rgb[x + (y+2)*vgax].r >> 1) ) >> 1;
+ dispbuf.rgb[x + y*vgax].g=( (dispbuf.rgb[x + y *vgax].g >> 1)
+ + (dispbuf.rgb[x + (y+1)*vgax].g )
+ + (dispbuf.rgb[x + (y+2)*vgax].g >> 1) ) >> 1;
+ dispbuf.rgb[x + y*vgax].b=( (dispbuf.rgb[x + y *vgax].b >> 1)
+ + (dispbuf.rgb[x + (y+1)*vgax].b )
+ + (dispbuf.rgb[x + (y+2)*vgax].b >> 1) ) >> 1;
}
*/
@@ -155,8 +163,8 @@ static void vsmooth(void){
"movl %%ebx, -4(%%esi ) \n\t" //U LINE
" jnz 1b \n\t" // V 1
:
- : "D" (xres<<2), "S" (dispbuf.b),
- "c" (xres * (yress-2) )
+ : "D" (vgax<<2), "S" (dispbuf.b),
+ "c" (vgax * (wndy-2) )
: "%eax", "%ebx", "%ecx", "%esi");
}
@@ -188,8 +196,8 @@ static void vsmooth(void){
"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)
+ : "D" (vgax<<1), "S" (dispbuf.b),
+ "c" (vgax * (wndy-2) >> 1)
: "%eax", "%ebx", "%ecx", "%esi");
Modified: trunk/2010/2_file.cc
==============================================================================
--- trunk/2010/2_file.cc (original)
+++ trunk/2010/2_file.cc Wed Jul 4 03:45:27 2007
@@ -7,7 +7,7 @@
#include "2_file.h"
#include "2_hw.h"
- extern int xres, yres, xress, yress;
+ extern int vgax, vgay, wndx, wndy;
extern int fysize;
extern byte font[4096];
extern xxx dispbuf;
@@ -29,29 +29,29 @@ void grab(void){
if((fg=fopen(grab_name, "ab"))==NULL && g_mode==0) error(FileWrite);
bmpi.magic='B'+('M'<<8);
- bmpi.lenght=xress * yress * 3 + 54;
+ bmpi.lenght=wndx * wndy * 3 + 54;
bmpi.zero1=0;
bmpi.datstart=54;
bmpi.palstart=40; //??
- bmpi.xres=xress;
- bmpi.yres=yress;
+ bmpi.xres=wndx;
+ bmpi.yres=wndy;
bmpi.planes=1;
bmpi.bits=24;
bmpi.comp=0;
- bmpi.size=xress * yress * 3;
+ bmpi.size=wndx * wndy * 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);
+ for(i=wndy-1; i>=0; i--){
+ for(j=0; j<wndx; j++){
+ if(yuvmode==0) fwrite((void*)(&dispbuf.rgb[j + i*vgax]), 1, 3, fg);
else {
- if(j>=xress>>1) break;
+ if(j>=wndx>>1) break;
- mem2vid(fwbuf, dispbuf.yuv + j + (i*xres>>1), 2, 32);
+ mem2vid(fwbuf, dispbuf.yuv + j + (i*vgax>>1), 2, 32);
fwbuf[3]=fwbuf[4];
fwbuf[4]=fwbuf[5];
Modified: trunk/2010/2_gfunc.cc
==============================================================================
--- trunk/2010/2_gfunc.cc (original)
+++ trunk/2010/2_gfunc.cc Wed Jul 4 03:45:27 2007
@@ -5,7 +5,7 @@
#include "2_all.h"
#include "2_gfunc.h"
- extern int xres, yres, xresc;
+ extern int vgax, vgay, xresc;
extern int buttons, xpos, ypos, lxpos, lypos;
extern int fysize;
extern byte font[4096];
@@ -37,12 +37,12 @@ void xcliped_gprint(int xp, int yp, cons
if(yp>0) iy=0;
else iy=-yp;
- for(; iy<fysize && (iy+yp<yres); iy++){
+ for(; iy<fysize && (iy+yp<vgay); iy++){
t1=font[(text<<4)+iy];
- t3=xp+(yp+iy)*xres;
+ t3=xp+(yp+iy)*vgax;
if(xp>0) ix=0;
else ix=-xp;
- for(; ix<8 && ix+xp<xres; ix++){
+ for(; ix<8 && ix+xp<vgax; ix++){
if(((t1>>(7-ix)) & 1) == 1){
if(yuvmode!=0)
dispbuf.yuv[(ix+t3)/2]=c.yuv; //FIX ME
@@ -71,17 +71,17 @@ void gprint(int xp, int yp, const s_col
}
else clipym=0;
- if(xp+int(strlen(text))*9+1>=xres){
- if(xp>=xres) return;
- i=(xres-xp)/9;
+ if(xp+int(strlen(text))*9+1>=vgax){
+ if(xp>=vgax) return;
+ i=(vgax-xp)/9;
t=text[i];
tp=i;
text[i]=0;
}
- if(yp+fysize>yres){
- if(yp>=yres) return;
- clipyp=yres-yp;
+ if(yp+fysize>vgay){
+ if(yp>=vgay) return;
+ clipyp=vgay-yp;
}
else clipyp=fysize;
@@ -156,7 +156,7 @@ void gprint(int xp, int yp, const s_col
"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))
+ "a" (c.yuv), "c" (text), "d" (((u_long)dispbuf.cl)+((xp+yp*vgax)<<1))
: "%ebx", "%ecx", "%edx", "%esi", "%edi");
}else{
asm(//"int $3\n\t"
@@ -215,26 +215,26 @@ void gprint(int xp, int yp, const s_col
"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))
+ "a" (c.rgb), "c" (text), "d" (((u_long)dispbuf.cl)+((xp+yp*vgax)<<2))
: "%ebx", "%ecx", "%edx", "%esi", "%edi");
}
if(t!=0){
- xcliped_gprint(xres - ((xres-xp) % 9), yp, c, t);
+ xcliped_gprint(vgax - ((vgax-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(x>0 && x<vgax && y>0 && y<vgay){
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;
+ dispbuf.cl[y*vgax+x].lum=c.yuv.y1;
+ dispbuf.cl[(y*vgax+x) | 1 ].chrom=c.yuv.v;
+ dispbuf.cl[(y*vgax+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;
+ dispbuf.rgb[y*vgax+x].r=c.rgb.r;
+ dispbuf.rgb[y*vgax+x].g=c.rgb.g;
+ dispbuf.rgb[y*vgax+x].b=c.rgb.b;
}
}
}
@@ -246,27 +246,27 @@ void line(int x1, int y1, int x2, int y2
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;
+ else if(x1>=vgax){
+ if(x2>=vgax) return;
+ else y1=(int)((float)(y1-y2)/((float)(x2-x1)+.1E-4)*(float)(x2-vgax+1)+y2), x1=vgax-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;
+ else if(x2>=vgax)
+ y2=(int)((float)(y2-y1)/((float)(x1-x2)+.1E-4)*(float)(x1-vgax+1)+y1), x2=vgax-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 if(y1>=vgay){
+ if(y2>=vgay) return;
else
- x1=(int)((float)(x1-x2)/((float)(y2-y1)+.1E-4)*(float)(y2-yres+1)+x2), y1=yres-1;
+ x1=(int)((float)(x1-x2)/((float)(y2-y1)+.1E-4)*(float)(y2-vgay+1)+x2), y1=vgay-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;
+ else if(y2>=vgay)
+ x2=(int)((float)(x2-x1)/((float)(y1-y2)+.1E-4)*(float)(y1-vgay+1)+x1), y2=vgay-1;
if(x1==x2 && y1==y2) return;
@@ -277,13 +277,13 @@ void line(int x1, int y1, int x2, int y2
for(fl=y1<<16; x1<x2; x1++){
fl+=delta;
- dispbuf.yuv[(x1+(fl>>16)*xres)>>1]=c; //FIX ME
+ dispbuf.yuv[(x1+(fl>>16)*vgax)>>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;
+ delta=(x1-x2)*(1<<10)/(y1-y2) + (vgax<<10);
+ fl=(x1+y1*vgax)<<10;
y2-=y1;
for(; y2!=0; y2--){
fl+=delta;
@@ -304,14 +304,14 @@ void hline(register int x1, int y1, regi
x1=0;
if(x2<0) return;
}
- if(x2>=xres){
- x2=xres-1;
- if(x1>=xres) return;
+ if(x2>=vgax){
+ x2=vgax-1;
+ if(x1>=vgax) return;
}
- if(y1<0 || y1>=yres) return;
+ if(y1<0 || y1>=vgay) return;
- x1+=y1*xres;
- memset(dispbuf.cl + x1, *a, ((x2+y1*xres)-x1+1)<<1); //FIX HLINE
+ x1+=y1*vgax;
+ memset(dispbuf.cl + x1, *a, ((x2+y1*vgax)-x1+1)<<1); //FIX HLINE
}
/*
void vline(const int x1, register int y1, register int y2, const s_yuv c){
@@ -323,22 +323,22 @@ void vline(const int x1, register int y1
y1=0;
if(y2<0) return;
}
- if(y2>=yres){
- y2=yres-1;
- if(y1>=yres) return;
+ if(y2>=vgay){
+ y2=vgay-1;
+ if(y1>=vgay) return;
}
- if(x1<0 || x1>=xres) return;
+ if(x1<0 || x1>=vgax) return;
- y1=y1*xres+x1;
- y2=(y2-2)*xres+x1;
- for(; y1<y2; y1+=xres){
+ y1=y1*vgax+x1;
+ y2=(y2-2)*vgax+x1;
+ for(; y1<y2; y1+=vgax){
dispbuf[y1]=c;
- dispbuf[y1+=xres]=c;
- dispbuf[y1+=xres]=c;
- dispbuf[y1+=xres]=c;
+ dispbuf[y1+=vgax]=c;
+ dispbuf[y1+=vgax]=c;
+ dispbuf[y1+=vgax]=c;
}
- y2+=xres<<1;
- for(; y1<y2; y1+=xres){
+ y2+=vgax<<1;
+ for(; y1<y2; y1+=vgax){
dispbuf[y1]=c;
}
}
@@ -356,17 +356,17 @@ void rect(int x1, int y1, int x2, int y2
if(x2<0) return;
x1=0;
}
- else if(x2>=xres){
- if(x1>=xres) return;
- x2=xres-1;
+ else if(x2>=vgax){
+ if(x1>=vgax) return;
+ x2=vgax-1;
}
if(y1<0){
if(y2<0) return;
y1=0;
}
- else if(y2>=yres){
- if(y1>=yres)
- y2=yres-1;
+ else if(y2>=vgay){
+ if(y1>=vgay)
+ y2=vgay-1;
}
y1*=xresc;
y2*=xresc;
Modified: trunk/2010/2_hw.cc
==============================================================================
--- trunk/2010/2_hw.cc (original)
+++ trunk/2010/2_hw.cc Wed Jul 4 03:45:27 2007
@@ -41,7 +41,7 @@
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 int vgax, vgay, xresc, xresvb, vb, mc;
extern mouse_sprites cursor;
extern char *yuv2rgb_lut;
extern byte *mouse_buff[2];
@@ -188,7 +188,7 @@ void mem2vid(byte *to, s_yuv *from, int
"movl (__esp), %%esp \n\t"
"popl %%ebp \n\t"
:
- : "m" (xres<<1),
+ : "m" (vgax<<1),
"D" (yuv2rgb_lut), "S" (from), "a" (to), "c" (num)
: "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi");
@@ -269,12 +269,12 @@ void mouse_handler(void){
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;
+ if(mouse_x>=vgax) mouse_x=vgax-1;
+ if(mouse_y>=vgay) mouse_y=vgay-1;
- for(j=0; j < cursor.y && mouse_y + j - cursor.hoty < yres; j++){
+ for(j=0; j < cursor.y && mouse_y + j - cursor.hoty < vgay; j++){
if(j + mouse_y - cursor.hoty>=0){
- for(i=0 ; i < cursor.x && mouse_x + i - cursor.hotx < xres; i++){
+ for(i=0 ; i < cursor.x && mouse_x + i - cursor.hotx < vgax; i++){
if( i + mouse_x - cursor.hotx>=0){
k=cursor.data[i + (j + mouse_tim*cursor.y)*cursor.x];
@@ -298,9 +298,9 @@ void mouse_handler(void){
}
}
- for(j=0; j < cursor.y && mouse_ly + j - cursor.hoty < yres; j++){
+ for(j=0; j < cursor.y && mouse_ly + j - cursor.hoty < vgay; j++){
if(j + mouse_ly - cursor.hoty>=0){
- for(i=0; i < cursor.x && mouse_lx + i - cursor.hotx < xres; i++){
+ for(i=0; i < cursor.x && mouse_lx + i - cursor.hotx < vgax; i++){
if( i + mouse_lx - cursor.hotx>=0){
k=i - mouse_x + mouse_lx;
l=j - mouse_y + mouse_ly;
@@ -332,7 +332,7 @@ void mouse_handler(void){
static inline void setdot(int xx, int yy, s_col c){
int ppvb=xx*vb + yy*xresvb;
- if(page_flip==1) ppvb+=xresvb*yres;
+ if(page_flip==1) ppvb+=xresvb*vgay;
vidbuf[ppvb ]=c.rgb.b;
vidbuf[ppvb+1]=c.rgb.g;
@@ -342,7 +342,7 @@ static inline void setdot(int xx, int yy
static inline s_col getdot(int xx, int yy){
int ppvb=xx*vb + yy*xresvb;
- if(page_flip==1) ppvb+=xresvb*yres;
+ if(page_flip==1) ppvb+=xresvb*vgay;
return *(s_col* )(vidbuf + ppvb);;
}
@@ -402,12 +402,12 @@ void init_hw(void){
r.x.ax=7;
r.x.cx=0;
- r.x.dx=xres;
+ r.x.dx=vgax;
__dpmi_int(0x33, &r); //set horizontal cursor range
r.x.ax=8;
r.x.cx=0;
- r.x.dx=yres;
+ r.x.dx=vgay;
__dpmi_int(0x33, &r); //set vertical cursor range
r.x.ax=4;
@@ -506,8 +506,8 @@ 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);
+ for(i=0; i<vgay; i++){
+ mem2vid(vidbuf + i*xresvb, (s_yuv*)((byte*)(dispbuf.yuv) + i*xresc), vgax, bpp);
if(mouse_y - cursor.hoty <= i && mouse_y + cursor.y - cursor.hoty > i){
disabled_call_mouse_handler();
@@ -517,29 +517,29 @@ void copy_vidbuffer(void){
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;
+ else if(mouse__xe>=vgax) mouse__xe=vgax-1;
+ if(mouse__ye>=vgay) mouse__ye=vgay-1;
j=mouse__xe & (~1);
- for(; i < yres && i < mouse__ye; i++ ){
+ for(; i < vgay && 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);
+ vgax - j - 1, bpp);
}
i--;
mouse_handler_enable=1;
}
}
}else if(page_flip==2){
- mem2vid(vidbuf+xresvb*yres, dispbuf.yuv, xres*yres, bpp);
+ mem2vid(vidbuf+xresvb*vgay, dispbuf.yuv, vgax*vgay, bpp);
page_flip=1;
fresh_cursor=1;
disabled_call_mouse_handler();
- set_start_disp(0, yres);
+ set_start_disp(0, vgay);
}else{
- mem2vid(vidbuf, dispbuf.yuv, xres*yres, bpp);
+ mem2vid(vidbuf, dispbuf.yuv, vgax*vgay, bpp);
page_flip=2;
fresh_cursor=1;
disabled_call_mouse_handler();
Modified: trunk/2010/2_hw_asm.s
==============================================================================
--- trunk/2010/2_hw_asm.s (original)
+++ trunk/2010/2_hw_asm.s Wed Jul 4 03:45:27 2007
@@ -25,12 +25,12 @@
.globl _last_dispbuf
.globl _grab_dispbuf
.globl _vidbuf
-.globl _xres
+.globl _vgax
.globl _xresvb
.globl _vb
.globl _mc
.globl _xresc
-.globl _yres
+.globl _vgay
.globl _cursor
.globl _yuvmode
.globl _locklist
@@ -60,10 +60,9 @@
.globl _stride
.globl _single
.globl _crypt
-.globl _xress
-.globl _yress
-.globl _yrest
-.globl _yresst
+.globl _wndx
+.globl _wndy
+.globl _outy
.globl _nagra_mode
.globl _mmx
.globl _my_cs
@@ -92,12 +91,12 @@ _last_dispbuf: .long 0
_grab_dispbuf: .long 0
.long 0
_vidbuf: .long 0
-_xres: .long 0
+_vgax: .long 0
_vb: .long 0
_mc: .long 0
_xresvb: .long 0
_xresc: .long 0
-_yres: .long 0
+_vgay: .long 0
_yuvmode: .long 0
_locklist: .long 0
_alloclist: .long 0
@@ -127,10 +126,9 @@ _fresh_cursor: .long 1
_stride: .long 0
_single: .long 0
_crypt: .long 0
-_xress: .long 0
-_yress: .long 0
-_yrest: .long 0
-_yresst: .long 0
+_wndx: .long 0
+_wndy: .long 0
+_outy: .long 0
_nagra_mode: .long 0
_mmx: .long 1
_my_cs: .word 0
Modified: trunk/2010/2_hw_mem.cc
==============================================================================
--- trunk/2010/2_hw_mem.cc (original)
+++ trunk/2010/2_hw_mem.cc Wed Jul 4 03:45:27 2007
@@ -17,8 +17,6 @@
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;
@@ -195,15 +193,9 @@ void dpmi_freeall(volatile AllocList **a
}
-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;
+xxx *alloc_cont(int size, int num){
+ static xxx ret[2];
+ u_long addr;
size= (size + 4095) & (~4095); //round up to next 4096 boundray
@@ -213,80 +205,72 @@ xxx alloc_cont(int size){
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;
+ bool both;
+ if(num==2){
+ both=true;
+ size<<=1;
+ }else
+ both=false;
- 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;
+ dds vds_info;
+ for(int i=0; i<num; i++){
+ int slack=0;
+ for(;;){
+ vds_info= vds_alloc(size + slack);
+
+ if(vds_info.phys==0xFFFFFFFF){
+ if(!both) error(MemAlloc);
+ both=false;
+ size>>=1;
+ slack=0;
+ }else{
+ printf("AllocatedContVDS %d, at Address %lX\n", size + slack , vds_info.phys);
+ fflush(stdout);
+
+ const int j=~(1024*1024*4-1);
+ if(both){
+ if( ( ((vds_info.phys + slack ) & j)
+ ==((vds_info.phys + slack + (size>>1)-1) & j) )
+ && ( ((vds_info.phys + slack + (size>>1) ) & j)
+ ==((vds_info.phys + slack + size -1) & j) ) ) break;
+ }else{
+ if( ((vds_info.phys + slack ) & j)
+ == ((vds_info.phys + slack + size-1) & j) ) break;
}
- lphys=llp->phys;
-
- llp=llp->next;
+
+ printf("4MB Boundray violation!\n");
+ fflush(stdout);
+
+ vds_free(&vds_info);
}
- length+=4096;
- printf("Allocated %d, MaxCont %d, at Address %lX\r",length , maxcount, maxaddr);
- fflush(stdout);
+ slack+=4096;
}
- 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);
- }
+
+ if(both){
+ size>>=1;
+
+ ret[0].b= (byte*)(map(
+ vds_info.phys + slack , vds_info.phys + slack + size)
+ - __djgpp_base_address);
+
+ ret[1].b= (byte*)(map(
+ vds_info.phys + slack + size, vds_info.phys + slack + size + size)
+ - __djgpp_base_address);
+ ret[0].phys= vds_info.phys + slack;
+ ret[1].phys= vds_info.phys + slack + size;
+ break;
+ }else{
+ ret[i].b= (byte*)(map(
+ vds_info.phys + slack , vds_info.phys + slack + size)
+ - __djgpp_base_address);
+ ret[i].phys= vds_info.phys + slack;
}
- }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);
+ if(num==1) ret[1]= ret[0];
- 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){
@@ -360,18 +344,38 @@ dds vds_alloc(int size){
return vds_info;
}
-void vds_free(dds){
+void vds_free(dds *vds_info){
+ __dpmi_regs r;
+ volatile VdsList *vd, *vd2;
- error( error_code(-99) );
- // fix me
+ vd=vdslist;
+ while(vd!=NULL && vd->next!=NULL && vd->next->vds_info.phys!=vds_info->phys)
+ vd=vd->next;
+
+ if(vd==vdslist && vd->vds_info.phys==vds_info->phys ){
+ printf("HALLO1\n");
+ vdslist= vdslist->next;
+ delete vd;
+ }else if(vd!=vdslist && vd->next!=NULL){
+ vd2= vd->next;
+ vd->next= vd->next->next;
+ delete vd2;
+ }
+
+ dosmemput(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);
}
void vds_freeall(void){
__dpmi_regs r;
volatile VdsList *vd, *vd2;
- vd=(VdsList*)vdslist;
+ vd=vdslist;
while(vd!=NULL){
dosmemput((dds*)(&vd->vds_info), sizeof(dds), __tb); // store in buffer
r.x.ax=0x8108;
Modified: trunk/2010/2_hw_mem.h
==============================================================================
--- trunk/2010/2_hw_mem.h (original)
+++ trunk/2010/2_hw_mem.h Wed Jul 4 03:45:27 2007
@@ -44,11 +44,11 @@ void dpmi_addlinlock(volatile AllocList
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);
+xxx *alloc_cont(int size, int num);
void checkVDS(void);
u_long getphys(u_long);
dds vds_alloc(int size);
-void vds_free(dds vds_info);
+void vds_free(dds *vds_info);
void vds_freeall(void);
void *map(u_long start, u_long end);
void unmap(void *start);
Modified: trunk/2010/2_menu.cc
==============================================================================
--- trunk/2010/2_menu.cc (original)
+++ trunk/2010/2_menu.cc Wed Jul 4 03:45:27 2007
@@ -6,7 +6,7 @@
#include "2_mfunc.h"
#include "2_gfunc.h"
- extern int xres, yres;
+ extern int vgax, vgay;
extern int buttons, xpos, ypos, lxpos, lypos;
extern int fysize;
extern int me, mx, my;
@@ -166,17 +166,17 @@ void disp_menu(menu *m, int mx, int my,
l=0;
j=mx;
if(level==1) j += sub_xcorr;
- if(j+mxsize*9>xres){
- j=xres-mxsize*9;
+ if(j+mxsize*9>vgax){
+ j=vgax-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;
+ if((fysize+1)*(mysize)<=vgay){
+ if(k+(fysize+1)*(mysize)-2>vgay){
+ k=vgay-(fysize+1)*(mysize)-2;
sub_y[level-1]=k;
}
else if(my<0){
@@ -184,8 +184,8 @@ void disp_menu(menu *m, int mx, int my,
sub_y[level-1]=k;
}
}else{
- if(my+(fysize+1)*(mysize)-2<=yres){
- k=yres-(fysize+1)*(mysize)-2;
+ if(my+(fysize+1)*(mysize)-2<=vgay){
+ k=vgay-(fysize+1)*(mysize)-2;
sub_y[level-1]=k;
}
@@ -217,7 +217,7 @@ void disp_menu(menu *m, int mx, int my,
if(me==2){
if(m[i].func!=NULL) m[i].func(i);
}
- if(me==3 && sub_m==-1 && level!=1 && (fysize+1)*(mysize)>yres){
+ if(me==3 && sub_m==-1 && level!=1 && (fysize+1)*(mysize)>vgay){
sub_m=level-1;
}
}
Modified: trunk/2010/2_mfunc.cc
==============================================================================
--- trunk/2010/2_mfunc.cc (original)
+++ trunk/2010/2_mfunc.cc Wed Jul 4 03:45:27 2007
@@ -6,7 +6,7 @@
#include "2010.h"
#include "2_71x6.h"
- extern int xres, yres, yrest, y_field, x_field;
+ extern int vgax, y_field, x_field, outy;
extern int buttons, xpos, ypos, lxpos, lypos;
extern int me, mx, my;
extern menu menu_main[mainend+1];
@@ -73,7 +73,7 @@ void hdeci(int num){
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);
+ double d = ( (one_field==0) ? double(outy>>1) : double(outy) ) / double(y_field);
if( d <= 4.0/15.0) vdeci(menuvfil2);
else if( d <= 13.0/15.0) vdeci(menuvfil1);
else vdeci(menuvfilb);
@@ -106,7 +106,7 @@ void vdeci(int num){
i=vdeci_state;
vdeci_state=num;
if(i==menuvfila && hdeci_state==menuhtapa && num!=menuvfila){
- double d = double(xres) / double(x_field);
+ double d = double(vgax) / 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);
Modified: trunk/2010/2_move.cc
==============================================================================
--- trunk/2010/2_move.cc (original)
+++ trunk/2010/2_move.cc Wed Jul 4 03:45:27 2007
@@ -5,8 +5,8 @@
#include "2_all.h"
#include "2010.h"
-extern int xpos, ypos, lxpos, lypos, xres, yres;
-extern int yress, xress;
+extern int xpos, ypos, lxpos, lypos, vgax, vgay;
+extern int wndy;
extern int infox, infoy, istate;
extern int conty_b, conty_s, conty_c, contx_b, contx_s, contx_c, cstate;
extern int fysize;
@@ -41,7 +41,7 @@ void pos_tab::move(int relx, int rely){
xe+=relx;
if(*xs<0 ) xe+=0 - *xs, *xs=0;
- if( xe>xres) *xs+=xres - xe, xe=xres;
+ if( xe>vgax) *xs+=vgax - xe, xe=vgax;
}
if((fixed & 2)==0){
@@ -49,7 +49,7 @@ void pos_tab::move(int relx, int rely){
ye+=rely;
if(*ys<0 ) ye+=0 - *ys, *ys=0;
- if( ye>yres) *ys+=yres - ye, ye=yres;
+ if( ye>vgay) *ys+=vgay - ye, ye=vgay;
}
}
@@ -84,23 +84,23 @@ pos_tab * pos_tab_list::new_tab(int fixe
void setmpos(void){
- infox=xres-20*9;
+ infox=vgax-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;
+ conty_b=wndy - 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;
+ conty_c=wndy - 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;
+ conty_s=wndy - 60;
if(mpos_tab_list.new_tab(2, &contx_s, contx_s + 5,
&conty_s, conty_s + 15,
&cstate, (void (*)())-1) ==NULL) error(MemAlloc);
Modified: trunk/2010/2_nag.cc
==============================================================================
--- trunk/2010/2_nag.cc (original)
+++ trunk/2010/2_nag.cc Wed Jul 4 03:45:27 2007
@@ -13,13 +13,9 @@
#include "2_mmx.h"
#include "2_nag_a.h"
-#define nagra_buff 32
-
-#define check 1
-
-//int check=1; //grrrrrr nix working
+#define dwnSmp 1
-extern xres, yres, xress, yress, yrest, yresst, y_field;
+extern vgax, vgay, wndx, wndy, outy, y_field;
extern xxx dispbuf;
extern volatile int scales_x, scalee_x;
extern volatile int scales_y, scalee_y;
@@ -27,62 +23,89 @@ extern int one_field;
extern u_long asm_temp, asm_temp4;
extern int istate;
extern int yuvmode;
-extern int mmx;
+extern bool mmx;
+
+int blackThreshold= 4000;
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;
+ return ( (BLOCK*)(p1) )->limit[0] - ( (BLOCK*)(p2) )->limit[0];
}
void nag_decrypt(void){
- char textbuf[9][128];
+ char textbuf[10][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];
+ const int outy1= outy>>1;
+ const int nagStart2= int(double(17+0 - scales_y)/y_field*outy1 + .5)*2+1;
+ const int nagEnd2 = int(double(17+254 - scales_y)/y_field*outy1 + .5)*2+1;
+ const int nagStart1= int(double(17+255 - scales_y)/y_field*outy1 + .5)*2+2;
+ const int nagEnd1 = int(double(17+286 - scales_y)/y_field*outy1 + .5)*2+2;
+ const int nagSize1= (nagEnd1 - nagStart1)/2 + 1;
+ const int nagSize2= (nagEnd2 - nagStart2)/2 + 1;
+ const int nagSizeAll= nagSize1 + nagSize2;
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 ):
+ char lastDwnSmp= 50;
+ const int dwnSmpSize= mmx ? dwnSmp : dwnSmp-1;
- const int corr_block= 8000 / ( 3 * ( (xress >> check2 ) + sizeof(l_inf) ) );
+ printf("%d %d %d %d %d %d %d\n", nagStart2, nagEnd2, nagStart1, nagEnd1,
+ nagSize1, nagSize2, nagSizeAll);
+
+ const int corrBlock= 16000 / ( 2*( (wndx >> dwnSmpSize ) + sizeof(COEFFSLINE)) + 100);
T1=uclock();
-// printf("%d\n\n\n", c2end);
+ char *lowRes= (char*) new double[(wndx * nagSizeAll >> dwnSmpSize)/8 + 3]; // align 8
+ LINEINF *lineInf= new LINEINF [nagSizeAll];
+ BLOCK *block= new BLOCK [nagSizeAll];
+ COEFFSLINE *coeffsLine= new COEFFSLINE [nagSizeAll];
+ SORTEDCOEFF *sortedCoeff= new SORTEDCOEFF[nagSizeAll*L_ENT];
+ char *bufferInfo= new char [nagSizeAll];
- linep=( xres<<2 )*( yresst1 - c2end - 1 );
- linep2=-(xress >> check2 );
+ for(int i=0; i<nagSizeAll; i++){
+ if(i<=nagSize2) bufferInfo[i]=1; // 31 free slots
+ else bufferInfo[i]=int(double(i-nagSize2)/nagSize1*NAGRA_BUFFER+.5);
+// printf("%d %d\n", bufferInfo[i],i);
+ }
+
+ int line= ( vgax<<1 ) * nagStart1;
+ int lowResLine= 0;
int blockp;
- for(blockp=0; blockp<yresst1; blockp++){
+ for(blockp=0; blockp<nagSizeAll; 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;
+ block[blockp].end[1]= blockp;
+ block[blockp].limit[0]=
+ block[blockp].limit[1]= blockp-nagSize1+1;
+ block[blockp].ent= 1;
+ lineInf[blockp].block= blockp;
+ lineInf[blockp].next[0]=
+ lineInf[blockp].next[1]= 0xFFFF;
+ lineInf[blockp].nextCoeff[0]=
+ lineInf[blockp].nextCoeff[1]= 0xFFFF;
- linep+=xres<<2;
- linep2+=xress >> check2;
- if(blockp==c2end) linep=xres<<1;
- if(mmx==0){
+ if(blockp==nagSize1) line= ( vgax<<1 ) * nagStart2;
+
+ int avg;
+ if(mmx){
asm(//"int $3 \n\t"
"pushl %%ebp \n\t"
+ "cmpb (%%eax), %%cl \n\t"
+ " je 5f \n\t"
+ "movb %%cl, 3f-1 \n\t"
+ "movb %%cl, (%%eax) \n\t"
+ "movl $1, %%eax \n\t"
+ "shll %%cl, %%eax \n\t"
+ "movl %%eax, 4f-4 \n\t"
+
+ "5: \n\t"
+ "xor %%ecx, %%ecx \n\t"
"1: \n\t"
- "movw (%%edi), %%ax \n\t" // U load 32 byte in L1-cache
+ "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
+ "movl $0xFFFF, %%ebp \n\t" // U
+ "4: \n\t"
"xorl %%eax, %%eax \n\t" // V 1
"2: \n\t"
"addl %%eax, %%ebx \n\t" // U
@@ -91,29 +114,44 @@ void nag_decrypt(void){
"addl $2, %%esi \n\t" // V 1
"decl %%ebp \n\t" // U
" jnz 2b \n\t" // V 1
- "addl $2, %%edi \n\t" // U
+ "incl %%edi \n\t" // U
"addl %%eax, %%ebx \n\t" // V 1
- "shrl %0, %%ebx \n\t" // U
+ "shrl $5, %%ebx \n\t" // U 1
+ "3: \n\t"
+ "addl %%ebx, %%ecx \n\t" // U
"decl %%edx \n\t" // V 1
- "movw %%bx, -2(%%edi) \n\t" // U
+ "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)
+ : "=c" (avg)
+ : "c" (dwnSmp), "a"(&lastDwnSmp),
+ "S" (dispbuf.b + line + 1) ,
+ "d" (wndx>>dwnSmp) ,
+ "D" (lowRes + lowResLine)
: "%eax", "%ebx", "%edx", "%esi", "%edi");
+
}
else{
asm(//"int $3 \n\t"
"pushl %%ebp \n\t"
+ "cmpb (%%eax), %%cl \n\t"
+ " je 5f \n\t"
+ "movb %%cl, 3f-1 \n\t"
+ "movb %%cl, (%%eax) \n\t"
+ "movl $1, %%eax \n\t"
+ "shll %%cl, %%eax \n\t"
+ "movl %%eax, 4f-4 \n\t"
+
+ "5: \n\t"
+ "xor %%ecx, %%ecx \n\t"
+
"1: \n\t"
- "movb (%%edi), %%al \n\t" // U load 32 byte in L1-cache
+ "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
+ "movl $0xFFFF, %%ebp \n\t" // U
+ "4: \n\t"
"xorl %%eax, %%eax \n\t" // V 1
"2: \n\t"
"addl %%eax, %%ebx \n\t" // U
@@ -122,428 +160,454 @@ void nag_decrypt(void){
"addl $2, %%esi \n\t" // V 1
"decl %%ebp \n\t" // U
" jnz 2b \n\t" // V 1
- "incl %%edi \n\t" // U
+ "addl $2, %%edi \n\t" // U
"addl %%eax, %%ebx \n\t" // V 1
- "shrl %0, %%ebx \n\t" // U
+ "shrl $5, %%ebx \n\t" // U 1
+ "3: \n\t"
+ "addl %%ebx, %%ecx \n\t" // U
"decl %%edx \n\t" // V 1
- "movb %%bl, -1(%%edi) \n\t" // U
+ "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)
+ : "=c" (avg)
+ : "c" (dwnSmp), "a"(&lastDwnSmp),
+ "S" (dispbuf.b + line + 1) ,
+ "d" (wndx>>dwnSmp) ,
+ "D" (lowRes + lowResLine)
: "%eax", "%ebx", "%edx", "%esi", "%edi");
-
}
+
+ if(avg>blackThreshold)
+ lineInf[blockp].state= eSingle;
+ else
+ lineInf[blockp].state= eBlack;
+
+ line+= vgax<<2;
+ lowResLine+= wndx >> dwnSmpSize;
}
if(istate==1){
T2=uclock();
- sprintf(textbuf[8],"%f ReSample", (float)(T2-T1)/UCLOCKS_PER_SEC);
+ sprintf(textbuf[9],"%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;
- }
- }
+ printf("HALLO1\n");
- int corr_loops=0;
- long T_corr=0, T_merge=0;
- int blockpl;
+ int corrLoops=0;
+
+ bool first=true;
+ bool didSome;
+ long T_corr=0, T_radix=0, T_merge=0;
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) ;
+ didSome=false;
+
+ /* clear coeffs */
+ for(int i=0; i<nagSizeAll; i++){
+ for(int j=0; j<L_ENT; j++){
+ if(lineInf[i].state>=eSingle)
+ coeffsLine[i].coeff[j]= DO_COEFF;
+ else
+ coeffsLine[i].coeff[j]= DONT_COEFF;
+ coeffsLine[i].line[j]= 0xFFFF;
}
}
+ printf("HALLOA\n");
- int s_line, s_line2;
- int s_linep, s_linep2;
+ /* corr calc */
- 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;
+ int s_line0, s_line1;
+ int s_linep0, s_linep1;
+ int line0, line1;
+ int linep0, linep1;
- for(s_line2= s_line; s_line2 < yresst1; s_line2 += corr_block){
- s_linep2 += (xress >> check2) * corr_block;
+ s_linep0=0;
+ for(s_line0= 0; s_line0 < nagSizeAll; s_line0 += corrBlock){
+ s_linep1 = s_linep0;
- linep = s_linep;
- for(line= s_line; line < yresst1 && line < (s_line + corr_block); line++){
- linep += xress >> check2;
+ for(s_line1= s_line0; s_line1 < nagSizeAll; s_line1 += corrBlock){
- if(line_inf[line].state == 0) continue;
+ linep0 = s_linep1 - (wndx >> dwnSmpSize);
+ for(line0= s_line1; line0 < min(nagSizeAll, s_line1 + corrBlock); line0++){
- if(s_line == s_line2){
- linep2 = linep;
- line2 = line + 1;
+ linep0 += wndx >> dwnSmpSize;
+
+ if(coeffsLine[line0].coeff[0]==DONT_COEFF) continue;
+
+ if(s_line0 == s_line1){
+ linep1 = linep0 + (wndx>>dwnSmpSize);
+ line1 = line0 + 1;
+ if(line1 >= nagSizeAll || line1 >= s_line1 + corrBlock) continue;
}
else{
- linep2 = s_linep2;
- line2 = s_line2;
+ linep1 = s_linep0;
+ line1 = s_line0;
}
- asm_temp=(u_long)(line_inf + line);
- asm_temp4=line;
+ asm_temp=(u_long)(coeffsLine + line0);
+ asm_temp4=line0;
+
+// printf("%d %d %d %d %d %d %d %d %d\n", corrBlock, line0, line1,
+// linep0, linep1, s_line0, s_line1, s_linep0, s_linep1);
+ nagra_corr(min(nagSizeAll, s_line0 + corrBlock),
+ wndx >> dwnSmpSize,
+ linep0,
+ linep1 - (wndx >> dwnSmpSize),
+ line1,
+ int(coeffsLine),
+ int(lowRes) );
- nagra_corr((yresst1 < (s_line2 + corr_block) ) ?
- yresst1 : (s_line2 + corr_block),
- xress >> check2,
- linep,
- linep2,
- line2,
- int(line_inf),
- int(datbuf) );
}
+ s_linep1 += (wndx >> dwnSmpSize) * corrBlock;
+
}
- }
+ s_linep0 += (wndx >> dwnSmpSize) * corrBlock;
- 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(mmx) asm("emms \n\t");
+ printf("HALLOB\n");
if(istate==1){
T2=uclock();
T_corr+=T2-T1;
T1=T2;
}
+ // save line info ...
+ /* radix sort */
+ int coeffSize= 0;
+ int stat[2][257];
+ for(int i=0; i<257; i++){
+ stat[0][i]=
+ stat[1][i]=0;
+ }
+ for(int i=0; i<nagSizeAll; i++){
- int did_some;
- do{
- did_some=0;
+ for(int j=0; j<L_ENT; j++){
+ if(coeffsLine[i].line[j]==0xFFFF) break;
+ stat[0][ ( coeffsLine[i].coeff[j] & 0xFF ) + 1 ]++;
+ stat[1][ ( (coeffsLine[i].coeff[j] >> 8) ) + 1 ]++;
+ coeffSize++;
+ }
+// if(coeffsLine[i].line[min(j, L_ENT-1)]==0xFFFF) continue;
-// printf("START\n\n");
+ if(first){
+ lineInf[i].nextCoeff[0]= coeffsLine[i].coeff[0]; //
+ lineInf[i].nextCoeff[1]= coeffsLine[i].coeff[1]; // for line integration
+ lineInf[i].next[0]= coeffsLine[i].line[0]; //
+ lineInf[i].next[1]= coeffsLine[i].line[1]; //
+ }
+ coeffsLine[i].line[L_ENT-1]|= LAST_MASK; // mark last coeff per line
+
+ }
+ for(int i=2; i<256; i++){
+ stat[0][i]+= stat[0][i-1];
+ stat[1][i]+= stat[1][i-1];
+ }
+ TEMPSORT *tempSort= new TEMPSORT[coeffSize];
+ for(int i=0; i<nagSizeAll; i++){
+ for(int j=0; j<L_ENT; j++){
+ if(coeffsLine[i].line[j]==0xFFFF) break;
+ tempSort[ stat[0][ coeffsLine[i].coeff[j] & 0xFF ] ].coeff=
+ coeffsLine[i].coeff[j];
+ tempSort[ stat[0][ coeffsLine[i].coeff[j] & 0xFF ] ].line[0]=i;
+ tempSort[ stat[0][ coeffsLine[i].coeff[j] & 0xFF ] ].line[1]=
+ coeffsLine[i].line[j];
- for(int blocki=0; blocki<blockp; blocki++){
- if(line_inf[ block[blocki].end[0] ].state == 0) continue;
+ stat[0][ coeffsLine[i].coeff[j] & 0xFF ]++;
+ }
+ }
+ for(int i=0; i<coeffSize; i++){
+ sortedCoeff[ stat[1][ tempSort[i].coeff >> 8 ] ].line[0]=
+ tempSort[i].line[0];
+ sortedCoeff[ stat[1][ tempSort[i].coeff >> 8 ] ].line[1]=
+ tempSort[i].line[1];
- 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];
+ stat[1][ tempSort[i].coeff >> 8 ]++;
+ }
- else if( line_inf[line2].state == 1 &&
- line_inf[line2].line[ backlinei[1] ] == line1 ){
+ delete [] tempSort;
- 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(istate==1){
+ T2=uclock();
+ T_radix+=T2-T1;
+ T1=T2;
+ }
+ printf("HALLOC\n");
- if(backlinei[0] == l_ent){
-// printf("noLines2!\n");
- continue;
- }
+ for(int coeffp=0; coeffp<coeffSize; coeffp++){
+ if( sortedCoeff[coeffp].line[0]==0xFFFF
+ || sortedCoeff[coeffp].line[1]==0xFFFF ) break;
- 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]);
+ int line0= sortedCoeff[coeffp].line[0];
+ int line1= sortedCoeff[coeffp].line[1];
- did_some=1;
+ STATE state0= lineInf[ line0 & (~LAST_MASK) ].state;
+ STATE state1= lineInf[ line1 & (~LAST_MASK) ].state;
- 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;
+ // last_mask is saved in opposit line
+ if(line0 & LAST_MASK){
+ if(state1 >= eSingle) break;
+ }
+ if(line1 & LAST_MASK){
+ if(state0 >= eSingle) break;
+ }
- line_inf[line1].next[1] = line_inf[line1].next[0];
- line_inf[line2].next[1] = line_inf[line2].next[0];
+ line0 &= ~LAST_MASK;
+ line1 &= ~LAST_MASK;
- line_inf[line1].next[0] = line2;
- line_inf[line2].next[0] = line1;
+ // eBlack eMiddle eSingle eEnd
+ if(state0>state1){
+ const STATE tempS= state0;
+ state0= state1;
+ state1= tempS;
+ const int tempL= line0;
+ line0= line1;
+ line1= tempL;
+ }
-// 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]);
+ const int block0= lineInf[ line0 ].block;
+ const int block1= lineInf[ line1 ].block;
- if(blocki != blockp-1){
- line_inf[ block[blockp-1].end[0] ].block = block2;
- line_inf[ block[blockp-1].end[1] ].block = block2;
+ if(state0==eBlack) continue;
- line_inf[ block[block2].end[endi2 ^ 1] ].block = blocki;
-
- block[blocki].end[endi]= block[block2].end[endi2 ^ 1];
+ if(state0==eMiddle){
+ if(state1==eSingle) continue; // fix line integration
+ else continue;
+ }
- block[block2]= block[blockp - 1];
- }
- else{
+ if(line0<0 || line0>=nagSizeAll) printf("line0 %d\n", line0);
+ if(line1<0 || line1>=nagSizeAll) printf("line1 %d\n", line1);
+ if(block0<0 || block0>=blockp ) printf("block0 %d %d\n", block0, blockp);
+ if(block1<0 || block1>=blockp ) printf("block1 %d %d\n", block1, blockp);
- line_inf[ block[blocki].end[endi ^ 1] ].block = block2;
+ if(block1==block0) continue;
- block[block2].end[endi2]= block[blocki].end[endi ^ 1];
- }
-
- blockp--;
-
-
+ // block + line / line + line / block + block
- break;
- }
- endi ^= 1;
+ const int whichEnd[2]= { line0==block[block0].end[0] ? 0 : 1,
+ line1==block[block1].end[0] ? 0 : 1 };
+
+ const int limit[2]= { max(block[block0].limit[ whichEnd[0] ^ 1 ],
+ block[block1].limit[ whichEnd[1] ]
+ -block[block0].ent ),
+ max(block[block1].limit[ whichEnd[1] ^ 1 ],
+ block[block0].limit[ whichEnd[0] ]
+ -block[block1].ent ) };
+
+ const int ori= limit[0] < limit[1] ? 0 : 1;
+
+ const int end=limit[ori] + block[block0].ent + block[block1].ent;
+
+ if(end > nagSizeAll)
+ continue;
+
+ const int start=min( block[block0].limit[0],
+ block[block1].limit[0] );
+
+ int slots=0;
+ {
+ int i;
+ for(i=start; i<end; i++){
+ if( i >= block[block0].limit[0]
+ && i < block[block0].limit[0] + block[block0].ent) slots++;
+ if( i >= block[block1].limit[0]
+ && i < block[block1].limit[0] + block[block1].ent) slots++;
+ if( i >= limit[ori] && i < end ) slots--;
+ if(i>=0 && bufferInfo[i] + slots > NAGRA_BUFFER) break;
}
+ if(i<end) continue;
+ }
+
+ // from here merge is certain
+ for(int i=start; i<end; i++){
+ if( i >= block[block0].limit[0]
+ && i < block[block0].limit[0] + block[block0].ent) slots++;
+ if( i >= block[block1].limit[0]
+ && i < block[block1].limit[0] + block[block1].ent) slots++;
+ if( i >= limit[ori] && i < end ) slots--;
+ if(i>=0) bufferInfo[i]+= slots;
}
+
+ const int newBlock= min(block0, block1);
+ const int freeBlock= max(block0, block1);
- } while(did_some!=0);
+ lineInf[ line0 ].next[1] = lineInf[ line0 ].next[0];
+ lineInf[ line1 ].next[1] = lineInf[ line1 ].next[0];
- if(istate==1){
- T2=uclock();
- T_merge+=T2-T1;
- T1=T2;
- }
+ lineInf[ line0 ].next[0] = line1;
+ lineInf[ line1 ].next[0] = line0;
- corr_loops++;
+ lineInf[ line0 ].state=
+ lineInf[ line1 ].state= eMiddle;
- } while( blockpl > blockp*3 && corr_loops < 2);
+ const int oriBlock[2]= { ori==0 ? block0 : block1,
+ ori==0 ? block1 : block0 };
-// printf("\n%d\n\n", blockp);
+ BLOCK temp;
+ temp.end[0]= block[ oriBlock[0] ].end[ whichEnd[ori ] ^ 1 ];
+ temp.end[1]= block[ oriBlock[1] ].end[ whichEnd[ori ^ 1] ^ 1 ];
- 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;
- }
+ lineInf[ temp.end[0] ].state=
+ lineInf[ temp.end[1] ].state= eEnd;
+ lineInf[ temp.end[0] ].block=
+ lineInf[ temp.end[1] ].block= newBlock;
- for(i=0; i<blockp; i++){
- line= block[i].end[0];
- line2=-1;
+ temp.ent= block[block0].ent + block[block1].ent;
+ temp.limit[0]= limit[ori ];
+ temp.limit[1]= limit[ori ^ 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];
+ block[newBlock]= temp;
+
+ blockp--;
+ if(freeBlock != blockp){
+ block[freeBlock]= block[blockp];
+ lineInf[ block[freeBlock].end[0] ].block= freeBlock;
+ lineInf[ block[freeBlock].end[1] ].block= freeBlock;
}
- if(line == -1) break;
- }
- up_limit2 -=num;
+ didSome= true;
- 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;
+ printf("HALLOD\n");
- if( up_limit < 0 ) up_limit=0;
- if( up_limit + num > yresst1 ) up_limit=0; // FIX ME ?
+ if(istate==1){
+ T2=uclock();
+ T_merge+=T2-T1;
+ T1=T2;
+ }
- if( up_limit > avg ) up_limit = 0;
+ corrLoops++;
+ first= false;
+ }while(didSome==true);
- block[i].up_limit=up_limit;
- block[i].down_limit=yresst1;
- block[i].avg=avg;
- block[i].ent=num;
+ printf("blockp %d\n", blockp);
+ if(istate==1){
+ sprintf(textbuf[0],"%f Corr", (float)(T_corr)/UCLOCKS_PER_SEC);
+ sprintf(textbuf[1],"%f Radix Sort", (float)(T_radix)/UCLOCKS_PER_SEC);
+ sprintf(textbuf[2],"%f Block Handling", (float)(T_merge)/UCLOCKS_PER_SEC);
+ T2=uclock();
+ T1=T2;
}
+ printf("HALLO2\n");
+
if(istate==1){
T2=uclock();
- sprintf(textbuf[2],"%f Stat", (float)(T2-T1)/UCLOCKS_PER_SEC);
+ sprintf(textbuf[3],"%f Stat", (float)(T2-T1)/UCLOCKS_PER_SEC);
T1=T2;
}
- qsort(block, blockp, sizeof(b_inf), qsort_block);
+ qsort(block, blockp, sizeof(BLOCK), qsort_block);
if(istate==1){
T2=uclock();
- sprintf(textbuf[3],"%f Sort", (float)(T2-T1)/UCLOCKS_PER_SEC);
+ sprintf(textbuf[4],"%f Sort", (float)(T2-T1)/UCLOCKS_PER_SEC);
T1=T2;
}
- int forw_vec[yrest];
- int bakw_vec[yrest];
+ int forwVec[outy];
+ int bakwVec[outy];
- for(i=0; i<yrest; i++){
- forw_vec[i]=
- bakw_vec[i]=-1;
+ for(int i=0; i<outy; i++){
+ forwVec[i]=
+ bakwVec[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];
+ int ordLine=0;
+ for(int i=0; i<blockp; i++){
+ int line= block[i].end[0];
+ int linePrev=-3;
+ int trueLine;
+ for(int j=0; j<block[i].ent; j++){
+// printf(" %d %d\n", i, line);
+ if(lineInf[line].next[0] == linePrev){
+ linePrev=line;
+ line= lineInf[line].next[1];
}
else{
- line2=line;
- line= line_inf[line].next[0];
+ linePrev=line;
+ line= lineInf[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);
+ if(linePrev < nagSize1) trueLine=( linePrev <<1) + nagStart1;
+ else trueLine=((linePrev-nagSize1)<<1) + nagStart2;
- forw_vec[tline] = sline;
- bakw_vec[sline] = tline;
+ if(forwVec[trueLine] != -1) printf("fatal forw %d\n", trueLine);
+ if(bakwVec[ordLine ] != -1) printf("fatal bakw %d\n", ordLine);
- if(yres == yrest) sline +=2;
- else sline ++;
+ forwVec[trueLine] = ordLine;
+ bakwVec[ordLine ] = trueLine;
- if(line == -1) break;
+ if(wndy == outy) ordLine +=2;
+ else ordLine ++;
}
}
+ printf("HALLO3\n");
if(istate==1){
T2=uclock();
- sprintf(textbuf[4],"%f Built Vecs", (float)(T2-T1)/UCLOCKS_PER_SEC);
+ sprintf(textbuf[5],"%f Built Vecs", (float)(T2-T1)/UCLOCKS_PER_SEC);
T1=T2;
}
+ // fix stuff below (old)
+ byte copy_buff[max_x<<1];
- for(i=0; i<yrest; i++){
- if(bakw_vec[i] == -1 || bakw_vec[i] == i) continue;
- j=i;
+ for(int i=0; i<outy; i++){
+ if(bakwVec[i] == -1 || bakwVec[i] == i) continue;
+ int k;
+ int j=i;
do{
k = j;
- j = forw_vec[j];
+ j = forwVec[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);
+ memcpy(copy_buff, dispbuf.cl + i * vgax, wndx << 1);
j = i;
do{
k = j;
- j = bakw_vec[j];
- forw_vec[k] = k;
- bakw_vec[k] = k;
+ j = bakwVec[j];
+ forwVec[k] = k;
+ bakwVec[k] = k;
// printf("closed %d %d\n", j, k );
- if(j != i) memcpy(dispbuf.cl + k * xres, dispbuf.cl + j * xres, xress << 1);
+ if(j != i) memcpy(dispbuf.cl + k * vgax, dispbuf.cl + j * vgax, wndx << 1);
} while(j != i);
- memcpy(dispbuf.cl + k * xres, copy_buff, xress << 1);
+ memcpy(dispbuf.cl + k * vgax, copy_buff, wndx << 1);
}
else{
j = k;
do{
k = j;
- j = bakw_vec[j];
- forw_vec[k] = k;
- bakw_vec[k] = k;
+ j = bakwVec[j];
+ forwVec[k] = k;
+ bakwVec[k] = k;
// printf("open %d %d\n", j, k );
- if(j != -1) memcpy(dispbuf.cl + k * xres, dispbuf.cl + j * xres, xress << 1);
+ if(j != -1) memcpy(dispbuf.cl + k * vgax, dispbuf.cl + j * vgax, wndx << 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);
+ if(outy == wndy){
+ for(int i=0; i<outy; i+=2){
+ memcpy(dispbuf.cl + (i+1) * vgax, dispbuf.cl + i * vgax, wndx << 1);
}
}
/*
linep=0;
for(line=0; line<yresst1; line++){
- linep+=xres<<1;
+ linep+=vgax<<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 ];
+ for(i=0; i<wndx; i+=2){
+ register int x=dispbuf.b[ linep + (i<<1) - (vgax<<1) + 2 ];
register int y=dispbuf.b[ linep + (i<<1) + 2 ];
if(x>127) x-=256;
if(y>127) y-=256;
@@ -551,9 +615,9 @@ void nag_decrypt(void){
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){
+ dispbuf.cl[line * vgax + 4 ].lum=255;
+ dispbuf.cl[line * vgax + 5 ].lum=0;
+ for(i=0; i<wndx; i+=2){
register int x=dispbuf.b[ linep + (i<<1) + 2 ];
if(x>127) x-=256;
dispbuf.b[ 2 + linep + (i<<1) ]=char(-x);
@@ -561,14 +625,15 @@ void nag_decrypt(void){
}
}
+ printf("HALLO4\n");
linep=0;
for(line=0; line<yresst1; line++){
- linep+=xres<<1;
+ linep+=vgax<<1;
int allnor=0;
int allinv=0;
- for(i=0; i<xress; i+=2){
- register int x=dispbuf.b[ linep + (i<<1) - (xres<<1) ];
+ for(i=0; i<wndx; i+=2){
+ register int x=dispbuf.b[ linep + (i<<1) - (vgax<<1) ];
register int y=dispbuf.b[ linep + (i<<1) ];
if(x>127) x-=256;
if(y>127) y-=256;
@@ -576,9 +641,9 @@ void nag_decrypt(void){
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){
+ dispbuf.cl[line * vgax + 6 ].lum=255;
+ dispbuf.cl[line * vgax + 7 ].lum=0;
+ for(i=0; i<wndx; i+=2){
register int x=dispbuf.b[ linep + (i<<1) ];
if(x>127) x-=256;
dispbuf.b[ linep + (i<<1) ]=char(-x);
@@ -587,11 +652,27 @@ void nag_decrypt(void){
}
*/
+
+ line=0;
+ int block_noblack= blockp;
+ for(int 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 * vgax ].lum=255;
+ dispbuf.cl[line * vgax + 1 ].lum=0;
+ if(lineInf[ block[i].end[0] ].state == 0){
+ dispbuf.cl[line * vgax + 2 ].lum=255;
+ dispbuf.cl[line * vgax + 3 ].lum=0;
+ block_noblack--;
+ }
+ }
+
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);
+ sprintf(textbuf[6],"%f Move", (float)(T2-T1)/UCLOCKS_PER_SEC);
+ sprintf(textbuf[7],"%d Blocks", block_noblack);
+ sprintf(textbuf[8],"%d Loops", corrLoops);
c.init(255, 0, 0, yuvmode);
gprint(80, 80, c.c, textbuf[0]);
gprint(90, 90, c.c, textbuf[1]);
@@ -602,20 +683,16 @@ void nag_decrypt(void){
gprint(140, 140, c.c, textbuf[6]);
gprint(150, 150, c.c, textbuf[7]);
gprint(160, 160, c.c, textbuf[8]);
+ gprint(170, 170, c.c, textbuf[9]);
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;
+ delete [] lowRes;
+ delete [] block;
+ delete [] lineInf;
+ delete [] coeffsLine;
+ delete [] sortedCoeff;
+ delete [] bufferInfo;
- 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;
- }
- }
}
Modified: trunk/2010/2_nag.h
==============================================================================
--- trunk/2010/2_nag.h (original)
+++ trunk/2010/2_nag.h Wed Jul 4 03:45:27 2007
@@ -2,24 +2,49 @@
#ifndef n2_nag_h
#define n2_nag_h
-#define l_ent 14
+#define L_ENT 8
+#define MIN_DWN_SMP 1
+#define LAST_MASK 0x8000
+#define NAGRA_BUFFER 32
+#define DO_COEFF 0xFFFE
+#define DONT_COEFF 0xFFFF
-struct l_inf{
- int line[l_ent];
- int coeff[l_ent];
- int state;
+enum STATE{
+ eBlack,
+ eMiddle,
+ eSingle,
+ eEnd,
+};
+
+struct BLOCK;
+
+struct LINEINF{
+ STATE state;
int block;
int next[2];
+ int nextCoeff[2];
};
-struct b_inf{
+struct BLOCK{
int end[2];
- int up_limit;
- int down_limit;
- int avg;
+ int limit[2];
int ent;
};
+struct COEFFSLINE{
+ int line[L_ENT];
+ int coeff[L_ENT];
+};
+
+struct TEMPSORT{
+ int line[2];
+ int coeff;
+};
+
+struct SORTEDCOEFF{
+ int line[2];
+};
+
void nag_decrypt(void);
#endif
Modified: trunk/2010/2_nag_a.asm
==============================================================================
--- trunk/2010/2_nag_a.asm (original)
+++ trunk/2010/2_nag_a.asm Wed Jul 4 03:45:27 2007
@@ -18,9 +18,27 @@ global _nagra_corr__Fiiiiiii
%define linep par3
%define linep2 par4
%define line2 par5
-%define line_inf par6
+%define coeffsLine par6
%define databuf par7
+
+%define L_ENT 8
+%define ld_L_ENT 3+2+1
+; 1<<3=8 1<<2=4 1<<1=2 ( line + coeff ) * 4 * L_ENT
+%define firstLine 0
+%define firstCoeff (4*L_ENT)
+%define lastLine (4*L_ENT-4)
+%define lastCoeff (8*L_ENT-4)
+
+%define bs1Coeff (4*L_ENT + 2*L_ENT -4)
+%define bs2Coeff (4*L_ENT + L_ENT -4)
+%define bs3Coeff (4*L_ENT + L_ENT/2-4)
+
+%define bs1 (2*L_ENT)
+%define bs2 ( L_ENT)
+%define bs3 ( L_ENT/2)
+
+
_nagra_corr__Fiiiiiii:
; push eax
push ebx
@@ -37,9 +55,9 @@ _nagra_corr__Fiiiiiii:
loopi:
mov [_asm_temp2], ebx
- mov ebp, [line_inf]
+ mov ebp, [coeffsLine]
- shl ebx, 7
+ shl ebx, ld_L_ENT
mov edx, [xress_check2]
add ebx, ebp
@@ -48,14 +66,14 @@ loopi:
mov [_asm_temp3], ebx
add ecx, edx
- mov ebx, [ebx + 112]
+ mov ebx, [ebx + firstCoeff]
mov [linep2], ecx
mov esi, [databuf]
- test ebx, ebx
+ cmp ebx, 0xFFFF
mov edi, esi
- jz NEAR End
+ jz NEAR End_NoEsp
add esi, edx
add edi, edx
@@ -75,6 +93,7 @@ loopi:
test eax, eax
jz NoMMX
+ int 3
movq mm3, [mmx_zero]
movq mm0, [esp + esi]
@@ -100,7 +119,7 @@ MMXloop:
movq mm2, mm0 ; V 1
add esp, 8 ; U
jnc MMXloop ; V 1
-
+ int 3
movq mm0, mm5
psrlq mm5, 32
@@ -164,45 +183,39 @@ NoMMXloop:
EndMMX:
- mov eax, [ebx + 108] ; U | V 1
+ mov eax, [ebx + lastCoeff] ; U | V 1
cmp ebp, eax ; U
jg TryNext ; V 1
- mov eax, [ebx + 84] ; U 1
+ mov eax, [ebx + bs1Coeff] ; 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 edx, L_ENT*4-8 ; V 1
+ and ecx, bs1 ; U 1
- mov eax, [ebx + ecx + 60] ; U 2 AGI
+ mov eax, [ebx + ecx + bs2Coeff]; U 2 AGI
cmp eax, ebp ; U 1
sbb esi, esi ; U 1
- and esi, 8 ; U 1
+ and esi, bs2 ; U 1
or ecx, esi ; U 1
- mov eax, [ebx + ecx + 56] ; U 2 AGI
+ mov eax, [ebx + ecx + bs3Coeff]; U 2 AGI
cmp eax, ebp ; U 1
sbb esi, esi ; U 1
- and esi, 4 ; U 1
+ and esi, bs3 ; 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
+ mov esi, [ebx + edx + firstLine] ; U
+ mov edi, [ebx + edx + firstCoeff] ; V 1
+ mov [ebx + edx + 4 + firstLine], esi ; U
+ mov [ebx + edx + 4 + firstCoeff], edi ; V 1
+ sub edx, 4 ; U
+ cmp edx, ecx ; V 1
+ jge Copy1 ; U 1
+ mov [ebx + ecx + firstLine], esp ; U
+ mov [ebx + ecx + firstCoeff], ebp ; V 1
TryNext:
@@ -210,51 +223,46 @@ TryNext:
mov ebx, [_asm_temp3] ; U 1 line_inf[line2]
- mov eax, [ebx + 108] ; U 2 AGI
+ mov eax, [ebx + lastCoeff] ; U 2 AGI
cmp ebp, eax ; U
jg End ; V 1
- mov eax, [ebx + 84] ; U 1
+ mov eax, [ebx + bs1Coeff] ; 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 edx, L_ENT*4-8 ; V 1
+ and ecx, bs1 ; U 1
- mov eax, [ebx + ecx + 60] ; U 2 AGI
+ mov eax, [ebx + ecx + bs2Coeff]; U 2 AGI
cmp eax, ebp ; U 1
sbb esi, esi ; U 1
- and esi, 8 ; U 1
+ and esi, bs2 ; U 1
or ecx, esi ; U 1
- mov eax, [ebx + ecx + 56] ; U 2 AGI
+ mov eax, [ebx + ecx + bs3Coeff]; U 2 AGI
cmp eax, ebp ; U 1
sbb esi, esi ; U 1
- and esi, 4 ; U 1
+ and esi, bs3 ; 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
+ mov esi, [ebx + edx + firstLine] ; U
+ mov edi, [ebx + edx + firstCoeff] ; V 1
+ mov [ebx + edx + 4 + firstLine], esi ; U
+ mov [ebx + edx + 4 + firstCoeff], edi ; V 1
+ sub edx, 4 ; U
+ cmp edx, ecx ; V 1
+ jge Copy2 ; U 1
+ mov [ebx + ecx + firstLine], esp ; U
+ mov [ebx + ecx + firstCoeff], ebp ; V 1
-
End:
mov esp, [esp_save]
+End_NoEsp:
+
mov ebx, [line2]
mov ecx, [line2_end]
Modified: trunk/2010/2_vc.cc
==============================================================================
--- trunk/2010/2_vc.cc (original)
+++ trunk/2010/2_vc.cc Wed Jul 4 03:45:27 2007
@@ -15,7 +15,7 @@
#define vc_dead 7.5
#define check 1
-extern xres, yres, xress, yress;
+extern vgax, vgay, wndx, wndy;
extern xxx dispbuf;
extern volatile int scales_x, scalee_x;
extern volatile int scales_y, scalee_y;
@@ -49,12 +49,12 @@ void vc_decrypt(void){
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_endx=wndx;
+ const int vc_startx=int(double(22-scales_x+3)/double(768-scales_x+scalee_x)*wndx);
const int vc_diff=vc_endx - vc_startx;
- int *dir=new int[vc_diff*(yress + 1)];
+ int *dir=new int[vc_diff*(wndy + 1)];
const int mindist=int(double(vc_diff) / vc_dead);
@@ -71,12 +71,12 @@ void vc_decrypt(void){
for(i = 0; i < vc_diff; i++) last_val[i]=1;
- llinep=-(xres<<2);
- linep=-(xres<<1);
+ llinep=-(vgax<<2);
+ linep=-(vgax<<1);
edgep=0;
- for(line=0; line<yress; line++){
- llinep+=xres<<1;
- linep+=xres<<1;
+ for(line=0; line<wndy; line++){
+ llinep+=vgax<<1;
+ linep+=vgax<<1;
bestdiff=0x1FFFFFFF;
diffall=0;
start_step=0;
@@ -159,7 +159,7 @@ void vc_decrypt(void){
cutpoint[line]=bestp;
if(bestdiff==0) bestdiff++;
temp=diffall * addap_start * 32 / (vc_diff * bestdiff);
- if(temp<42) drift=xress;
+ if(temp<42) drift=wndx;
else if(temp<56) drift=addap_end;
else drift=(addap_end>>1) | 1;
@@ -181,7 +181,7 @@ void vc_decrypt(void){
new_val[i]=0;
dir[edgep + i]=best_edge; //FIX ME (not nes)
}
- else if(drift==xress){
+ else if(drift==wndx){
new_val[i]=1;
dir[edgep + i]=best_edge;
}
@@ -247,7 +247,7 @@ void vc_decrypt(void){
}
if(i >= vc_diff && best_edge_val==0){
i=0;
- drift=xress;
+ drift=wndx;
}
}
}
@@ -274,7 +274,7 @@ void vc_decrypt(void){
}
i=best_edge;
- for(line=yress-1; line>0; line--){
+ for(line=wndy-1; line>0; line--){
if(show_points==0){
cutpoint[line]+=i;
if(cutpoint[line] >= vc_diff) cutpoint[line]-= vc_diff;
@@ -282,8 +282,8 @@ void vc_decrypt(void){
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;
+ dispbuf.b[(line * vgax<<1) + ((vc_startx + j)<<1)+1]=255;
+ dispbuf.b[(line * vgax<<1) + ((vc_startx + j)<<1)+3]=0;
}
i=dir[vc_diff*line + i];
}
@@ -294,13 +294,13 @@ void vc_decrypt(void){
T1=T2;
}
- linep=-(xres<<1);
+ linep=-(vgax<<1);
// vc_diff&= ~1;
- for(line=0; line<yress; line++){
+ for(line=0; line<wndy; line++){
// cutpoint[line]&= ~1;
- linep+=xres<<1;
+ linep+=vgax<<1;
if(show_points!=0){
dispbuf.b[linep+(vc_startx<<1)+1]=255;
dispbuf.b[linep+(vc_startx<<1)+3]=0;
Modified: trunk/2010/2do
==============================================================================
--- trunk/2010/2do (original)
+++ trunk/2010/2do Wed Jul 4 03:45:27 2007
@@ -2,23 +2,20 @@ 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)
+ better sorting (no QSort)
c2end +-1 error (up_limit not correct)
- variable check
imp black line det
- up/down limit check in block merge
+ up/down limit and orientation check in block merge
+ keep limit and orintation (or unknowenness) during merge loop
+ keep block list sorted (use linked list)
+ buffer for buffer-freeness (0-32)
imp vc
color ?
@@ -30,3 +27,4 @@ imp vc
fix 24-bits ?
+check modifications during prog
Modified: trunk/2010/makefile
==============================================================================
--- trunk/2010/makefile (original)
+++ trunk/2010/makefile Wed Jul 4 03:45:27 2007
@@ -32,7 +32,7 @@ clean: ; del $(O) 2010
2_71x6.h 2_mmx.h
2_hw_mem.o : 2_hw_mem.cc 2_all.h 2_hw_mem.h 2010.h
2_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_71x6.o : 2_71x6.cc 2_all.h 2_71x6.h 2_hw.h 2_hw_mem.h 2010.h 2_hw_asm.h
2_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
1
0
Author: michael
Date: Wed Jul 4 03:27:11 2007
New Revision: 44
Log:
forgotten in last commit
Added:
trunk/2010/2_hw_asm.s
Added: trunk/2010/2_hw_asm.s
==============================================================================
--- (empty file)
+++ trunk/2010/2_hw_asm.s Wed Jul 4 03:27:11 2007
@@ -0,0 +1,271 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+
+ _lock_start:
+
+.globl _lock_start
+.globl _timer_count
+.globl _old_int8_vect_offset
+.globl _old_int8_vect_selector
+.globl _int8_handler
+.globl _meteor_handler
+.globl _lock_end
+.globl _save_selectors__Fv
+.globl _mouse_regs
+.globl _mouse_handler_enable
+.globl _in_int
+.globl _mouse_lx
+.globl _mouse_ly
+.globl _mouse_tim
+.globl _mouse_ltim
+.globl _mouse_x
+.globl _mouse_y
+.globl _mouse_b
+.globl _page_flip
+.globl _dispbuf
+.globl _last_dispbuf
+.globl _grab_dispbuf
+.globl _vidbuf
+.globl _xres
+.globl _xresvb
+.globl _vb
+.globl _mc
+.globl _xresc
+.globl _yres
+.globl _cursor
+.globl _yuvmode
+.globl _locklist
+.globl _alloclist
+.globl _vdslist
+.globl _maplist
+.globl _meteors
+.globl _old_intmet_vect
+.globl _old_intmet_vect_offset
+.globl _old_intmet_vect_selector
+.globl _grab_state
+.globl _metmode
+.globl _active_meteor
+.globl _latency
+.globl _addr_errors
+.globl _corr_errors
+.globl _frames
+.globl _fields
+.globl _saa7196_buf
+.globl _std
+.globl _x_field
+.globl _y_field
+.globl _one_field
+.globl _amb
+.globl _mouse_buff
+.globl _fresh_cursor
+.globl _stride
+.globl _single
+.globl _crypt
+.globl _xress
+.globl _yress
+.globl _yrest
+.globl _yresst
+.globl _nagra_mode
+.globl _mmx
+.globl _my_cs
+.globl _my_ds
+
+.globl _real_int__FsP11__dpmi_regs
+.globl _real_regs
+
+.align 4
+
+_timer_count: .long 0
+_mouse_handler_enable: .long 1
+_in_int: .long 0
+_mouse_lx: .long 0
+_mouse_ly: .long 0
+_mouse_tim: .long 0
+_mouse_ltim: .long 0
+_mouse_x: .long 0
+_mouse_y: .long 0
+_mouse_b: .long 0
+_page_flip: .long 0
+_dispbuf: .long 0
+.long 0
+_last_dispbuf: .long 0
+.long 0
+_grab_dispbuf: .long 0
+.long 0
+_vidbuf: .long 0
+_xres: .long 0
+_vb: .long 0
+_mc: .long 0
+_xresvb: .long 0
+_xresc: .long 0
+_yres: .long 0
+_yuvmode: .long 0
+_locklist: .long 0
+_alloclist: .long 0
+_vdslist: .long 0
+_maplist: .long 0
+_old_intmet_vect:
+_old_intmet_vect_offset: .long 0
+_old_intmet_vect_selector: .word 0
+.align 4
+_grab_state: .long 0
+_metmode: .long 0
+_active_meteor: .long 0
+_latency: .long 32
+_addr_errors: .long 0
+_corr_errors: .long 0
+_frames: .long 0
+_fields: .long 0
+_saa7196_buf: .space 52, 0
+_std: .long 0
+_x_field: .long 0
+_y_field: .long 0
+_one_field: .long 0
+_amb: .long 0
+_mouse_buff: .long 0
+ .long 0
+_fresh_cursor: .long 1
+_stride: .long 0
+_single: .long 0
+_crypt: .long 0
+_xress: .long 0
+_yress: .long 0
+_yrest: .long 0
+_yresst: .long 0
+_nagra_mode: .long 0
+_mmx: .long 1
+_my_cs: .word 0
+_my_ds: .word 0
+
+_meteors: .space 0x80, 0
+_cursor: .space 0x40, 0
+_mouse_regs: .space 0x40, 0
+
+_ds: .word 0
+_es: .word 0
+_fs: .word 0
+_gs: .word 0
+
+
+.align 4
+_real_regs:
+_r_di: .long 0
+_r_si: .long 0
+_r_bp: .long 0
+_r_sp2: .long 0
+_r_bx: .long 0
+_r_dx: .long 0
+_r_cx: .long 0
+_r_ax: .long 0
+_r_fl: .word 0
+_r_es: .word 0
+_r_ds: .word 0
+_r_fs: .word 0
+_r_gs: .word 0
+_r_ip: .word 0
+_r_cs: .word 0
+_r_sp: .word 0
+_r_ss: .word 0
+
+
+.align 4
+_save_selectors__Fv:
+ movw %ds, _ds
+ movw %es, _es
+ movw %fs, _fs
+ movw %gs, _gs
+ret
+
+ // int num
+.align 4
+_real_int__FsP11__dpmi_regs:
+
+ pushal
+ pushw %es
+
+ movw 38(%esp), %bx
+ movl 42(%esp), %edi
+
+ movw %ds, %ax
+ movw %ax, %es
+
+ movw $0 , (_r_ss - _real_regs)(%edi)
+ movw $0 , (_r_sp - _real_regs)(%edi)
+ movl $0 , (_r_sp2 - _real_regs)(%edi)
+ pushfw
+ popw (_r_fl - _real_regs)(%edi)
+
+ xorw %cx, %cx
+ movw $0x0300, %ax
+ int $0x31
+
+ popw %es
+ popal
+ret
+
+.align 4
+_int8_handler:
+
+ pushal
+ pushw %ds
+ pushw %es
+ pushw %fs
+ pushw %gs
+
+ movw %cs:_ds, %ds
+ movw _es, %es
+ movw _fs, %fs
+ movw _gs, %gs
+
+ incl _timer_count
+
+ call _disabled_call_mouse_handler__Fv
+
+ popw %gs
+ popw %fs
+ popw %es
+ popw %ds
+ popal
+
+.byte 0xEA
+_old_int8_vect:
+_old_int8_vect_offset: .long 0
+_old_int8_vect_selector: .word 0
+
+.align 4
+_meteor_handler:
+// int $3
+
+ pushal
+ pushw %ds
+ pushw %es
+ pushw %fs
+ pushw %gs
+
+// movw $0x00B7, %ax
+// movw %ax, %ds //HACK FIX BUG GRRRR
+// movw %ax, %es //HACK FIX BUG GRRRR
+// movw %ax, %fs //HACK FIX BUG GRRRR
+// movw %ax, %gs //HACK FIX BUG GRRRR
+ movw %cs:_ds, %ds
+ movw _ds, %es
+ movw _ds, %fs
+ movw _ds, %gs // all ds fix hack
+
+ call _meteor_int_handler__Fv
+
+ popw %gs
+ popw %fs
+ popw %es
+ popw %ds
+
+// int $3
+
+ movb $0x20, %al
+ outb %al, $0xA0
+ outb %al, $0x20
+ // FIX this QUICK HACK (? if irq<8)
+ popal
+sti
+iret
+
+_lock_end:
1
0
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
+
1
0