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]: r76 - in trunk/noe: . Makefile galois.c galois.h noe_internal.h rs.c rs.h test.c
by michael 09 Jul '07
by michael 09 Jul '07
09 Jul '07
Author: michael
Date: Tue Jul 10 00:04:24 2007
New Revision: 76
Log:
forgotten code from 2002-11-21 11:33
Added:
trunk/noe/
trunk/noe/Makefile
trunk/noe/galois.c
trunk/noe/galois.h
trunk/noe/noe_internal.h
trunk/noe/rs.c
trunk/noe/rs.h
trunk/noe/test.c
Added: trunk/noe/Makefile
==============================================================================
--- (empty file)
+++ trunk/noe/Makefile Tue Jul 10 00:04:24 2007
@@ -0,0 +1,20 @@
+OBJS = test.o galois.o rs.o
+SRCS = $(OBJS:.o=.c) $(ASM_OBJS:.o=.s)
+
+CFLAGS = -g -Wall -O4 $(OPTFLAGS) -I. $(EXTRA_INC)
+
+%.o: %.c
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+all: test
+
+test: $(OBJS)
+ $(CC) $(LDFLAGS) -o $@ $(OBJS)
+
+clean:
+ rm -f *.o *.a *~
+
+dep: depend
+
+depend:
+ $(CC) -MM $(CFLAGS) $(SRCS) 1>.depend
Added: trunk/noe/galois.c
==============================================================================
--- (empty file)
+++ trunk/noe/galois.c Tue Jul 10 00:04:24 2007
@@ -0,0 +1,166 @@
+/*
+ * Copyright (C) 2002 Michael Niedermayer <michaelni(a)gmx.at>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <inttypes.h>
+#include <assert.h>
+#include <stdio.h>
+
+#include "noe_internal.h"
+#include "galois.h"
+
+GF2h16Element noe_exp[65536];
+GF2h16Element noe_log[65536];
+uint32_t noe_mod[256];
+
+void noe_init(){
+ GF2h16Element ge= 1;
+ int i;
+
+ for(i=0; i<256; i++){
+ noe_mod[i]= gf2poly_mod(i<<16, PRIMITIVE_POLYNOM);
+ noe_mod[i]^= i<<16;
+ }
+
+ for(i=0; i<SIZE; i++){
+ noe_exp[i]= ge;
+ noe_log[ge]= i;
+ ge= gf2poly_mod(ge+ge, PRIMITIVE_POLYNOM);
+ }
+
+ noe_log[0]= 0xFFFF;
+ noe_log[1]= 0;
+}
+
+//int zech_log(GaloisField gf, GF2Polynom b){
+//}
+
+void noe_gfft(GF2h16Element *src, GF2h16Element *dst){
+
+}
+
+int noe_prodPoly(GF2h16Element *dst, GF2h16Element *src1, GF2h16Element *src2, int order1, int order2){
+ int order= order1 + order2;
+ int i;
+
+ for(i=order; i>=0; i--){
+ int acc=0;
+ int j, end;
+
+ j = NOE_MAX(0, i - order2);
+ end= NOE_MIN(i, order1);
+
+ for(; j<=end; j++){
+ acc^= prod(src1[j], src2[i-j]);
+ }
+ dst[i]= acc;
+ }
+
+ return order;
+}
+
+/**
+ * returns the first order2 coefficients of the product of the 2 polynoms.
+ */
+int noe_partialProdPoly(GF2h16Element *dst, GF2h16Element *src1, GF2h16Element *src2, int order1, int order2){
+ const int order= order2;
+ int i;
+
+ for(i=order; i>=0; i--){
+ int acc=0;
+ int j, end;
+
+ j = NOE_MAX(0, i - order2);
+ end= NOE_MIN(i, order1);
+
+ for(; j<=end; j++){
+ acc^= prod(src1[j], src2[i-j]);
+ }
+ dst[i]= acc;
+ }
+
+ return order;
+}
+
+void noe_printPoly(GF2h16Element *src, int order){
+ int i;
+
+ for(i=order; i>=0; i--){
+ printf(" + %X*x^%d", src[i], i);
+ }
+ printf("\n");
+}
+
+/**
+ * Evaluates the src polynom at x.
+ */
+GF2h16Element noe_evalPoly(GF2h16Element *src, int order, GF2h16Element x){
+ int acc=0;
+ int j;
+
+ for(j=order; j>=0; j--){
+ acc = prod(acc, x) ^ src[j];
+ }
+
+ return acc;
+}
+
+void noe_getDerivative(GF2h16Element *dst, GF2h16Element *src, int order){
+ int i;
+
+ for(i=0; i<order-1; i+=2){
+ dst[i ]= src[i+1];
+ dst[i+1]= 0;
+ }
+ if(i<order)
+ dst[i ]= src[i+1];
+}
+
+static inline int rev(int x){
+ x = (((x & 0xaaaa) >> 1) | ((x & 0x5555) << 1));
+ x = (((x & 0xcccc) >> 2) | ((x & 0x3333) << 2));
+ x = (((x & 0xf0f0) >> 4) | ((x & 0x0f0f) << 4));
+ x = (( x >> 8) | ((x & 0x00ff) << 8));
+ return(x);
+}
+
+void noe_gfft_dit2(GF2h16Element *dst, GF2h16Element *src){
+ int i, j, pass;
+
+ for(i=0; i<SIZE; i++){
+ dst[i]= src[rev(i)];
+ }
+
+ for(pass=0; pass<EXPONENT; pass++){
+ int block;
+ const int np= 1<<pass;
+ const int blockCount= 1<<(EXPONENT-pass-1);
+
+ for(block=0; block<blockCount; block++){
+ int n;
+ const int top= block*np<<1;
+ const int bot= top + np;
+
+ for(n=0; n<np; n++){
+ int a= dst[top + n];
+ int b= dst[bot + n];
+
+ dst[top + n]= a^b;
+ }
+ }
+ }
+}
Added: trunk/noe/galois.h
==============================================================================
--- (empty file)
+++ trunk/noe/galois.h Tue Jul 10 00:04:24 2007
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2002 Michael Niedermayer <michaelni(a)gmx.at>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#define PRIMITIVE_ELEMENT 2
+#define PRIMITIVE_POLYNOM 0x0001002D
+#define EXPONENT 16
+#define SIZE (1<<EXPONENT)
+
+typedef uint16_t GF2h16Element;
+
+typedef uint32_t GF2Polynom;
+
+extern GF2h16Element noe_exp[65536];
+extern GF2h16Element noe_log[65536];
+extern uint32_t noe_mod[256];
+
+int noe_prodPoly(GF2h16Element *dst, GF2h16Element *src1, GF2h16Element *src2, int order1, int order2);
+int noe_partialProdPoly(GF2h16Element *dst, GF2h16Element *src1, GF2h16Element *src2, int order1, int order2);
+void noe_init();
+void noe_printPoly(GF2h16Element *src, int order);
+void noe_getDerivative(GF2h16Element *dst, GF2h16Element *src, int order);
+GF2h16Element noe_evalPoly(GF2h16Element *src, int order, GF2h16Element x);
+
+
+static inline GF2Polynom gf2poly_prod(GF2Polynom a, GF2Polynom b){
+ int i;
+ unsigned int ret=0;
+#if 0
+ if(a&1) ret^=b;
+ b+=b;
+ if(a&2) ret^=b;
+ b+=b;
+ if(a&4) ret^=b;
+ b+=b;
+ if(a&8) ret^=b;
+ b+=b;
+ if(a&16) ret^=b;
+ b+=b;
+ if(a&32) ret^=b;
+ b+=b;
+ if(a&64) ret^=b;
+ b+=b;
+ if(a&128) ret^=b;
+ b+=b;
+ if(a&256) ret^=b;
+ b+=b;
+ if(a&512) ret^=b;
+ b+=b;
+ if(a&1024) ret^=b;
+ b+=b;
+ if(a&2048) ret^=b;
+ b+=b;
+ if(a&4096) ret^=b;
+ b+=b;
+ if(a&8192) ret^=b;
+ b+=b;
+ if(a&16384) ret^=b;
+ b+=b;
+ if(a&32768) ret^=b;
+ return ret;
+#elif 1
+ unsigned int tmp[4];
+ tmp[0]= 0;
+ tmp[1]= b;
+ tmp[2]= b + b;
+ tmp[3]= (b + b) ^ b;
+
+ ret ^= tmp[a&3] ; a>>=2;
+ ret ^= tmp[a&3]<<2 ; a>>=2;
+ ret ^= tmp[a&3]<<4 ; a>>=2;
+ ret ^= tmp[a&3]<<6 ; a>>=2;
+ ret ^= tmp[a&3]<<8 ; a>>=2;
+ ret ^= tmp[a&3]<<10; a>>=2;
+ ret ^= tmp[a&3]<<12; a>>=2;
+ ret ^= tmp[a&3]<<14;
+ return ret;
+#else
+ if(a==0 || b==0) return 0;
+ ret= noe_log[a] + noe_log[b];
+ if(ret >= 0xFFFF) ret-= 0xFFFF;
+ return noe_exp[ret];
+#endif
+}
+
+static inline GF2Polynom gf2poly_mod(GF2Polynom a, GF2Polynom b){
+ int i;
+
+ b<<= EXPONENT - 1;
+
+ for(i=0; i<EXPONENT; i++){
+ if((a^b) < a) a^=b;
+ b>>=1;
+ }
+
+ return a;
+}
+
+static inline GF2Polynom gf2poly_mod_m(GF2Polynom a){
+ a ^= noe_mod[a>>24]<<8;
+ a ^= noe_mod[a>>16];
+
+ return a;
+}
+
+static inline GF2h16Element prod(GF2h16Element a, GF2h16Element b){
+ return gf2poly_mod_m(gf2poly_prod(a, b));
+}
+
+static inline GF2h16Element inv(GF2h16Element a){
+ assert(a!=0);
+
+ return noe_exp[(1<<EXPONENT) - 1 - noe_log[a]];
+}
Added: trunk/noe/noe_internal.h
==============================================================================
--- (empty file)
+++ trunk/noe/noe_internal.h Tue Jul 10 00:04:24 2007
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2002 Michael Niedermayer <michaelni(a)gmx.at>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#define NOE_MAX(a,b) ((a) > (b) ? (a) : (b))
+#define NOE_MIN(a,b) ((a) > (b) ? (b) : (a))
Added: trunk/noe/rs.c
==============================================================================
--- (empty file)
+++ trunk/noe/rs.c Tue Jul 10 00:04:24 2007
@@ -0,0 +1,149 @@
+/*
+ * Copyright (C) 2002 Michael Niedermayer <michaelni(a)gmx.at>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <inttypes.h>
+#include <assert.h>
+#include <malloc.h>
+
+#include "noe_internal.h"
+#include "galois.h"
+#include "rs.h"
+
+/**
+ *
+ */
+void noe_getRsGenerator(GF2h16Element *dst, int first, int order){
+ GF2h16Element factor[2];
+ int i;
+
+ dst[0]= 1;
+
+ factor[0]= noe_exp[first];
+ factor[1]= 1;
+
+ for(i=0; i<order; i++){
+ int j;
+
+ noe_prodPoly(dst, dst, factor, i, 1);
+ factor[0]= prod(factor[0], PRIMITIVE_ELEMENT);
+ }
+}
+
+void noe_getSyndrom(GF2h16Element *syn, GF2h16Element *src, int first, int order){
+ int i;
+ //FIXME use GFFT if order is large
+
+ syn[0]= 1;
+
+ for(i=0; i<order; i++){
+ syn[i+1]= noe_evalPoly(src, (1<<EXPONENT)-2, noe_exp[first + i]);
+ }
+}
+#if 1
+noe_RsEncoder *noe_getRsEncoder(int parityCount){
+ const int dataCount= (1<<EXPONENT) - parityCount - 1;
+ int i;
+ GF2h16Element *locator, *factor;
+ GF2h16Element locatorDerivative[parityCount];
+ noe_RsEncoder *encoder= memalign(16, sizeof(noe_RsEncoder));
+
+ locator= encoder->parityLocator= memalign(16, sizeof(GF2h16Element)*(parityCount+1));
+ factor= encoder->parityFactor = memalign(16, sizeof(GF2h16Element)* parityCount );
+
+ encoder->parityCount= parityCount;
+
+ locator[0]= 1;
+ for(i=0; i<parityCount; i++){
+ GF2h16Element locationFactor[2];
+
+ locationFactor[0] = 1;
+ locationFactor[1] = noe_exp[dataCount + i];
+ noe_prodPoly(locator, locator, locationFactor, i, 1);
+ }
+#if 0
+for(i=0; i<parityCount; i++){
+ if(noe_evalPoly(locator, parityCount, inv(noe_exp[dataCount + i]))){
+ printf("Internal Error 1\n");
+ }
+}
+if(!noe_evalPoly(locator, parityCount, inv(noe_exp[dataCount - 1])))
+ printf("Internal Error 2\n");
+#endif
+ noe_getDerivative(locatorDerivative, locator, parityCount);
+
+ for(i=0; i<parityCount; i++){
+ GF2h16Element X= noe_exp[dataCount + i];
+ GF2h16Element invX= noe_exp[(1<<EXPONENT) - dataCount - i - 1];
+ GF2h16Element denom;
+
+ assert(X == inv(invX));
+
+ denom= noe_evalPoly(locatorDerivative, parityCount-1, invX);
+ factor[i]= prod(X, inv(denom));
+ }
+
+ return encoder;
+}
+
+void noe_freeRsEncoder(noe_RsEncoder *encoder){
+ if(!encoder) return;
+
+ if(encoder->parityLocator) free(encoder->parityLocator);
+ encoder->parityLocator= NULL;
+
+ if(encoder->parityFactor) free(encoder->parityFactor);
+ encoder->parityFactor= NULL;
+
+ free(encoder);
+}
+
+/**
+ *
+ */
+void noe_rsEncode(noe_RsEncoder *encoder, GF2h16Element *data){
+ int i;
+ const int parityCount= encoder->parityCount;
+ const int dataCount= (1<<EXPONENT) - parityCount - 1;
+ GF2h16Element syn[parityCount+1];
+ GF2h16Element omega[2*parityCount+1];
+ GF2h16Element *locator= encoder->parityLocator;
+ GF2h16Element *factor= encoder->parityFactor;
+
+ memset(data + dataCount, 0, parityCount*sizeof(GF2h16Element));
+
+ noe_getSyndrom(syn, data, 1, parityCount);
+
+ if(parityCount < 1000 || 1){
+ noe_partialProdPoly(omega, locator, syn, parityCount, parityCount);
+
+ for(i=0; i<parityCount; i++){
+ GF2h16Element invX= noe_exp[(1<<EXPONENT) - dataCount - i - 1];
+
+ GF2h16Element parity= prod(noe_evalPoly(omega, parityCount, invX), factor[i]);
+
+ data[dataCount + i]= parity;
+ }
+ }else{
+ //FIXME freq domain encoding
+ }
+
+}
+#endif
+
+
+
Added: trunk/noe/rs.h
==============================================================================
--- (empty file)
+++ trunk/noe/rs.h Tue Jul 10 00:04:24 2007
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2002 Michael Niedermayer <michaelni(a)gmx.at>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+typedef struct noe_RsEncoder{
+ int parityCount;
+ GF2h16Element *parityLocator;
+ GF2h16Element *parityFactor;
+}noe_RsEncoder;
+
+void noe_getRsGenerator(GF2h16Element *dst, int first, int order);
+
+/**
+ * gets the syndroms.
+ * @param src a 2^16 entry long polynom
+ * @param syn the syndrom polynom will be stored here
+ */
+void noe_getSyndrom(GF2h16Element *syn, GF2h16Element *src, int first, int order);
+noe_RsEncoder *noe_getRsEncoder(int parityOrder);
+void noe_freeRsEncoder(noe_RsEncoder *encoder);
+
+/**
+ *
+ */
+void noe_rsEncode(noe_RsEncoder *encoder, GF2h16Element *data);
Added: trunk/noe/test.c
==============================================================================
--- (empty file)
+++ trunk/noe/test.c Tue Jul 10 00:04:24 2007
@@ -0,0 +1,171 @@
+/*
+ * Copyright (C) 2002 Michael Niedermayer <michaelni(a)gmx.at>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <inttypes.h>
+#include <assert.h>
+#include <stdio.h>
+#include <time.h>
+#include <stdlib.h>
+
+#include "noe_internal.h"
+#include "galois.h"
+#include "rs.h"
+
+main(){
+ int i, j;
+ GF2Polynom bp=1;
+
+ noe_init();
+
+ printf("Testing GF(2^%d)\n", EXPONENT);
+ for(i=0; i<(1<<EXPONENT)-1; i++){
+ if((bp==1 || bp==0) && i>0){
+ printf("FAIL\n");
+ break;
+ }
+ bp= prod(bp, PRIMITIVE_ELEMENT);
+ }
+ if(bp!=1) printf("FAILED to reach 1\n");
+
+ printf("Testing inverse\n");
+ bp=1;
+ for(i=1; i<(1<<EXPONENT); i++){
+ if(prod(bp, inv(bp)) != 1){
+ printf("FAIL %X %X\n", (int)bp, (int)inv(bp));
+ break;
+ }
+ bp= prod(bp, PRIMITIVE_ELEMENT);
+ }
+
+ srand (time (0));
+
+ printf("Testing generator polynoms");
+ for(i=1; i<20; i++){
+ int n= (1<<EXPONENT) - 1;
+ int k= (1<<EXPONENT) - 1 - i;
+ GF2h16Element syn[i+1];
+ GF2h16Element gen[i+1];
+ GF2h16Element data[k];
+ GF2h16Element code[n];
+
+ for(j=0; j<k; j++)
+ data[j]= rand() & 0xFFFF;
+
+ noe_getRsGenerator(gen, 1, i);
+ j=noe_prodPoly(code, gen, data, i, k-1);
+ assert(j==n-1);
+
+ noe_getSyndrom(syn, code, 1, i);
+
+// noe_printPoly(gen, i);
+// noe_printPoly(syn, i-1);
+
+ for(j=0; j<i; j++){
+ if(syn[j+1]) printf("FAIL generator:%d coefficient:%d\n", i, j);
+ }
+ printf("."); fflush(stdout);
+ }
+
+ printf("\nTesting encoder");
+ for(i=1; i<50; i+=10){
+ int n= (1<<EXPONENT) - 1;
+ int k= (1<<EXPONENT) - 1 - i;
+ GF2h16Element syn[i+1];
+ GF2h16Element gen[i+1];
+ GF2h16Element data[k];
+ GF2h16Element code[n];
+ noe_RsEncoder *encoder;
+ int pass=5;
+
+ encoder= noe_getRsEncoder(i);
+
+ for(pass=5; pass; pass--){
+ for(j=0; j<k; j++)
+ data[j]= rand() & 0xFFFF;
+
+ memcpy(code, data, n*sizeof(GF2h16Element));
+
+ noe_rsEncode(encoder, code);
+
+ noe_getSyndrom(syn, code, 1, i);
+ //FIXME check that code contains data, but its not touched so ...
+
+ // noe_printPoly(gen, i);
+ // noe_printPoly(syn, i-1);
+
+ for(j=0; j<i; j++){
+ if(syn[j+1]) printf("FAIL generator:%d coefficient:%d is %X\n", i, j, syn[j+1]);
+ }
+ printf("."); fflush(stdout);
+ }
+ noe_freeRsEncoder(encoder);
+ }
+
+return 0;
+
+ printf("Testing erasure decoding\n");
+ for(i=1; i<20; i++){
+ int n= (1<<EXPONENT) - 1;
+ int k= (1<<EXPONENT) - 1 - i;
+ GF2h16Element syn[i+1];
+ GF2h16Element gen[i+1];
+ GF2h16Element data[k];
+ GF2h16Element code[n];
+ GF2h16Element locator[i+1];
+ GF2h16Element omega[2*i];
+
+ int locatorOrder=0;
+
+ for(j=0; j<k; j++)
+ data[j]= rand() & 0xFFFF;
+
+ noe_getRsGenerator(gen, 1, i);
+ j=noe_prodPoly(code, gen, data, i, k);
+ assert(j==n);
+
+ locator[0] = 1;
+ for(j=0; j<i; j++){
+ int index;
+ GF2h16Element locationFactor[2];
+
+ if((rand()&7)==0 && j) continue;
+
+ index= rand()%0xFFFF;
+ locationFactor[0] = 1;
+ locationFactor[1] = inv(noe_exp[index]);
+ locatorOrder= noe_prodPoly(locator, locator, locationFactor, j, 1);
+
+ code[index] += rand()&0xFFFF;
+ }
+
+ syn[0] ^= 1;
+
+ noe_getSyndrom(syn, code, 1, i);
+ noe_prodPoly(omega, syn, locator, i-1, locatorOrder);
+// noe_getDeriative(locator, locator, locatorOrder);
+
+
+// noe_printPoly(gen, i);
+// noe_printPoly(syn, i-1);
+
+ for(j=0; j<i; j++){
+ if(syn[j]) printf("FAIL generator:%d coefficient:%d\n", i, j);
+ }
+ }
+ return 0;
+}
1
0
Author: michael
Date: Fri Jul 6 01:36:31 2007
New Revision: 75
Log:
readme ...
Added:
trunk/vga600/README
Added: trunk/vga600/README
==============================================================================
--- (empty file)
+++ trunk/vga600/README Fri Jul 6 01:36:31 2007
@@ -0,0 +1,57 @@
+VGA 600
+-------
+
+
+About:
+------
+Some old DOS/windows TSR i wrote in 1996/1997
+VGA600, does monitor the graphics/text mode currently used and if possible
+improves it by increasing the physical number of lines used similar to the
+line doubling used to display 320x200 with 400 on VGA cards.
+vga600 will hack the registers of the vga card to display 320x200 with 600
+or 800 lines, it will also increase the dot clock and thus refresh rate.
+Together these reduce flicker and the annoying black "lines" vissible
+on modern high resolution monitors when displaying low resolution stuff
+like 640x400 or similar
+
+
+Warning:
+--------
+VGA600 can, like any other tool which plays with your vga card theoretically
+damage your monitor! use at your own risk
+
+
+Requirements:
+-------------
+DOS or windows
+a VGA _compatible_ card which either properly exposes a useable dotclock
+or a card for which vga600 contains code to set the dot clock
+in practice, ET4000 should work, S3 might work (vga600 has code for
+them to set the dot clock)
+mach64 and i810 do not expose useable clocks
+patches to add support for setting dot clocks for cards which arent
+supported is welcome
+
+
+Compilation:
+------------
+dont remember, TASM i guess, i dont have any windows/dos system with TASM
+here to try ...
+a patch porting it to YASM is welcome, so is one porting it to linux :)
+
+
+Portability to non x86:
+----------------------
+under qemu maybe ;)
+
+
+Useage:
+-------
+vga600 /V[0-2] /P
+will probe all clocks and store them in a vga600.clk file, you need to
+run this before anything else
+the rest should be explained by just looking at the vga600 output
+
+License:
+--------
+GPL v2+
\ No newline at end of file
1
0
Author: michael
Date: Fri Jul 6 01:07:15 2007
New Revision: 74
Log:
version from 1997-06-28 20:18
Modified:
trunk/vga600/vga600.asm
Modified: trunk/vga600/vga600.asm
==============================================================================
--- trunk/vga600/vga600.asm (original)
+++ trunk/vga600/vga600.asm Fri Jul 6 01:07:15 2007
@@ -561,29 +561,42 @@ ret
FindSet_V:
mul di ; find new phys_lines
+ push di ; save di
mov [VDE-int10h],ax ; save(phys_lines) as new
mov si,ax ; save(phys_lines) in si
- push ax ; save(phys_lines) to stack
+ mov di,ax ; save(phys_lines) in di
mul [WORD FPx_bor-int10h] ; find right-border-lenght
div [WORD FPx_1_-int10h] ;could be replaced by shrd
+ cmp ax,di ; check if no round-off error
+ jne FPx_bor_Ok
+ inc ax
+FPx_bor_Ok:
mov bp,ax ; save in bp
add si,ax ; add to old phys
mov [VBS-int10h],si ; save in VBS
inc si ; inc it
mov [VSS-int10h],si ; save in VSS
- pop ax
- push ax ;get old phys from stack
+ mov ax,di ;get old phys from di
mul [WORD FPx_VS-int10h] ; find VS-lenght
div [WORD FPx_1_-int10h] ;could be replaced by shrd
+ cmp ax,di ; check if no round-off error
+ jne FPx_VS_Ok
+ inc ax
+FPx_VS_Ok:
add si,ax ;add it
mov [VSE-int10h],si ; save in VSE
- pop ax ;get old phys from stack
+ xchg di,ax ;get old phys from di
mul [WORD FPx_VB-int10h] ; find VB-lenght
div [WORD FPx_1_-int10h] ;could be replaced by shrd
+ cmp ax,di ; check if no round-off error
+ jne FPx_VB_Ok
+ inc ax
+FPx_VB_Ok:
add si,ax ;add it
mov [VBE-int10h],si ; save in VBE
add si,bp ;add left-border-lenght
mov [VT-int10h],si ; save in VT
+ pop di ; restore di
ret
K_1 dw 1000
@@ -654,7 +667,7 @@ GetPath_NDot:
jnz GetPath_Copy
push cs
pop ds ;restore ds
- mov [WORD bx+1],'KL' ;fix COM -> CLK
+ mov [WORD bx+1],'KL'
1
0
Author: michael
Date: Fri Jul 6 01:05:45 2007
New Revision: 73
Log:
version from 1997-06-25 23:06
Modified:
trunk/vga600/vga600.asm
Modified: trunk/vga600/vga600.asm
==============================================================================
--- trunk/vga600/vga600.asm (original)
+++ trunk/vga600/vga600.asm Fri Jul 6 01:05:45 2007
@@ -1,5 +1,3 @@
-;350 text ???VDE =57h
-
;VGA600 ver 0.6 Beta Copyright (C) Michael Niedermayer 1997
;history:
@@ -14,22 +12,24 @@
ideal
P286
-cr equ 0ah
-lf equ 0dh
-paras equ (end10h-int10h)/16+1
-paras_all equ (end_all-start+100h)/16+1
-words equ (end10h-int10h)/2+5
-SC_INDEX equ 03c4h
-CRTC_INDEX equ 03d4h
-MISC_OUTPUT equ 03c2h
-MISC_INPUT equ 03cch
-Attrib_INDEX equ 03c0h
-Grafix_INDEX equ 03ceh
-patch_size equ patch_code_end-patch_code
-delay equ 6
-delay2 equ 12
-FPx equ 12
-FPx_1 equ 1 shl FPx
+cr equ 0ah
+lf equ 0dh
+paras equ (end10h-int10h)/16+1
+paras_all equ (end_all-start+100h)/16+1
+words equ (end10h-int10h)/2+5
+SC_INDEX equ 03c4h
+CRTC_INDEX equ 03d4h
+MISC_OUTPUT equ 03c2h
+MISC_INPUT equ 03cch
+Attrib_INDEX equ 03c0h
+Grafix_INDEX equ 03ceh
+PatchCodeSize equ offset(PatchClockCode_end)-offset(PatchClockCode)
+PatchArgsSize equ offset(PatchArgs_end)-offset(PatchArgs)
+delay equ 6
+delay2 equ 12
+FPx equ 12
+FPx_1 equ 1 shl FPx
+ProbeTimes equ 8
segment code
org 100h
@@ -38,7 +38,7 @@ assume cs:code, ds:code, es:code, ss:cod
start:
jmp install ;jmp to install code
-mcb_name db 'VGA600 ' ;ends up in mcb if it works
+mcb_name db 'VGA..600' ;ends up in mcb if it works
int10h:
cmp ax,020FFh ;check for allredy installed call
jne exit_10
@@ -80,14 +80,13 @@ decr: ;if(X>0) X1
jnz exit_8 ;get out if not zero
mov [BYTE cs:counter-int10h],delay2 ;set new counter
-; call CheckSet
+ call CheckSet
exit_8: ;jmp to old int 8
db 0eah
old_int8h dd 0
CheckSet:
-int 3
pusha
push ds
push es
@@ -99,7 +98,7 @@ push es
mov si,offset(where)-offset(int10h) ;Read and convert Vga-Regs
mov di,offset(what)-offset(int10h)
- mov bx,offset(OF2Real_code)-offset(int10h)
+ mov bx,offset(VSE2Real_code)-offset(int10h)
mov dx,SC_INDEX
mov al,1
@@ -126,6 +125,7 @@ chr_9:
in al,dx
stosb ;save Misc-reg
+int 3
get_regs:
mov dl,low(CRTC_INDEX) ;!dh=3
lodsb ;read index from table1
@@ -134,7 +134,7 @@ get_regs:
out dx,al ;set index
inc dx ;dx= data_port
in al,dx ;get data
- push ax ;save date
+ push ax ;save data
lodsw ;get jmp_table_entry and inc si
cbw ;convert it to word
add bx,ax ;and add it to the last one
@@ -178,74 +178,79 @@ Not2_End_CheckSet:
cmp ax,[MinLines-int10h]
jb End2_CheckSet
+ int 3
mov al,[MSL-int10h]
- mov bl,10011111b
+ and al,10011111b
test [BYTE gm-int10h],1 ;test if text
jnz no_text
- mov bl,10000000b
+ and al,10000000b
no_text:
- and al,bl
+ test al,al
jns no_cgax2 ;test if cga like mode
- mov al,1
+ cmp al,10000001b
+ jae End2_CheckSet ;get out if Real-CGA
+ mov al,1
no_cgax2:
and al,00011111b
- inc ax
+ inc ax ;al=mult (msl=mult-1)
cbw
stosb ;save lm
- mov bx,[VDE-int10h] ;get phys-lines
- xchg ax,bx ;ax=phys-line / bx=line_mult
+ xchg ax,bx ;bx=line_mult
+ mov ax,[VDE-int10h] ;ax=phys-lines
cwd
div bx ;find logical_lines
stosw ;save ll
xchg ax,di ;di=logi-line / bx=line_mult
mov cx,-1 ;cx=-1 (best_clock_index)
+;int 3
FindBest:
inc bx ; inc line_mult
js End_FindBest ; just in case VDE is very strange
cmp bl,3 ;check line_mult<3
jb n3
test [BYTE gm-int10h],1 ;test if text
- jz End_FindBest ;get out if more then *3 + TEXT
+ jz End_FindBest ;get out if more then *2 + TEXT
n3:
mov ax,bx
call FindSet_V ;find and set Vertical nums
cmp si,[MaxLines-int10h]
ja End_FindBest ; get out if toooo much
- mov si,FP8_ClockTable-int10h ;si=pointer to clock_table
+ xor si,si ;si=clock
xor bp,bp ;bp=best_clock (=0)
FindBestClock:
- mov ax,[WORD si] ;get clock
- mul [WORD FP8_1-int10h] ;for more precision
+ mov ax,[WORD si+FP8_ClockTable-int10h] ;get clock
+ test [BYTE SCM-int10h],1000b ;check if dotclk=mstclk/2
+ int 3
+ jz clk_ok ;skip if not
+ shr ax,1 ;"double" ht if yes
+clk_ok:
+ mul [WORD K_1-int10h] ;convert to kHz
div [WORD HT-int10h] ;find line_freq HT MUST >256
- cmp ax,[FP8_MinLineFreq] ;check if < MinLineFreq
+ cmp ax,[FP8_MinLineFreq-int10h] ;check if < MinLineFreq
jb End_FindBestClock
- cmp ax,[FP8_MaxLineFreq] ;check if > MaxLineFreq
+ cmp ax,[FP8_MaxLineFreq-int10h] ;check if > MaxLineFreq
ja End_FindBestClock
- mul [WORD FP8_1-int10h] ;for more precision
+ mul [WORD K_1-int10h] ;convert to Hz
div [WORD VT-int10h] ;find refresh_freq VT>256
- cmp ax,[FP8_MinRefresh] ;check if < MinRefresh
+ cmp ax,[FP8_MinRefresh-int10h] ;check if < MinRefresh
jb End_FindBestClock
- cmp ax,[FP8_MaxRefresh] ;check if > MaxRefresh
+ cmp ax,[FP8_MaxRefresh-int10h] ;check if > MaxRefresh
ja End_FindBestClock
cmp ax,bp ;check if better than best
- jb End_FindBestClock
+ jbe End_FindBestClock
mov bp,ax ;if yes save as best
mov cx,si ;cx=si
- sub cx,offset(FP8_ClockTable-int10h) ;get BYTE FP8_ClockTable[cx]
shr cx,1 ;get WORD FP8_ClockTable[cx]
+ or ch,bl ;ch=line_mult cl=Clock_index
End_FindBestClock:
inc si
inc si ;inc clock_pointer
- cmp si,offset(FP8_ClockTable_end-int10h) ;check if all clocks where tested
- jb FindBestClock
- test bp,bp ;check if nothing found
- jz FindBest_nothing
- or ch,bl ;ch=line_mult cl=Clock_index
-FindBest_nothing:
+ cmp si,offset(FP8_ClockTable_end-FP8_ClockTable);check if all clocks where tested
+ jb FindBestClock ;error ?jbe
jmp FindBest
End_FindBest:
@@ -257,21 +262,23 @@ End_CheckSet:
popa
ret
Not_End_CheckSet:
+; int 3
mov al,ch ;set ax= best line_mult
cbw
call FindSet_V ;set Vertical Nums (in mem)
- mov bx, 0000000001111111b ;set and/or start masks
+ dec ch ;ERROR should be rewritten ch=Mult-1 (for MSL)
+ mov bx, 0000000001011111b ;set and/or start masks(+clear VBS)
test [BYTE gm-int10h],1 ;test if text
jnz no_text2
- cmp cl,2 ;check if *2 & text
+ cmp ch,1 ;check if *2 & text
jne end_SetMSL
mov bh,10000000b ;set cga like doubling
jmp end_SetMSL ;and get out
no_text2:
- mov bl,cl ;set and-mask
- mov bh,cl ;set or-mask
- or bl,01100000b ;correct and-mask
+ mov bl,ch ;set and-mask
+ mov bh,ch ;set or-mask
+ or bl,01000000b ;correct and-mask(+clear VBS)
and bh,00011111b ;correct or-mask (xor bx,xxx...!!! limit line_mult)
end_SetMSL:
and [MSL-int10h],bl
@@ -289,47 +296,46 @@ end_SetMSL:
out dx,al ;write VSE
dec dx
- mov si,offset(where_V)-offset(int10h) ;Read and convert Vga-Regs
- mov di,offset(what_V)-offset(int10h)
- mov bx,offset(Real2HSE_code)-offset(int10h)
+ and [BYTE OF-int10h],00010000b ;clear everithing witch will be set
+
+ mov si,offset(where_backward)-offset(int10h) ;Read and convert Vga-Regs
+ mov di,offset(what_backward)-offset(int10h) ;backwards (hehe)
+ mov bx,offset(Real2VBE_code)-offset(int10h)
+ std
set_regs:
- lodsb ;read index from table1
+ lodsb ;read delta
+ cbw ;convert it to 16-bit
+ add bx,ax ;add it to bx
+ dec si ;skip foreward info
+ lodsb ;get index
test al,al ;check for sign bit
js end_set_regs ;get out is set
out dx,al ;set index
inc dx ;dx= data_port
- inc si ;skip xxx2real_code
- lodsb ;get jmp_table_entry
- cbw ;convert it to word
- add bx,ax ;and add it to the last one
in al,dx ;read (only VSE needs that now)
mov ch,al ;put into ch
mov ax,[di] ;get data
- inc di ;add di,2
- inc di
+ dec di ;sub di,2
+ dec di
mov cl,1 ;cl=1 (needed for some codes)
call bx ;call it
out dx,al ;set data
dec dx ;dx=data_port
jmp set_regs
end_set_regs:
-
- mov al,7
- mov ah,[OF-int10h]
- out dx,ax ;write OF
-
+ cld
pop ax
push offset(End_CheckSet-int10h) ; for return later
-patch_code2:
+PatchClockCode2:
xchg ax,bx
mov ah,bl ;ah=bl=clock
shl ah,2
mov dl,LOW(MISC_INPUT) ;dh=3! dont read from mem (clock_probing)
in al,dx ;al=MiscOutput
mov dl,LOW(MISC_OUTPUT) ;dh=3!
-patch_code:
+PatchClockCode:
et4000_clock:
and ax,0000110011110011b
or al,ah
@@ -386,72 +392,74 @@ et4000_clock:
out dx,al ;ET4000 SUCKs
ret
-patch_code_end:
-
+PatchClockCode_end:
+ db 0FFh ;end-marker \
+ db 0FFh ;end-marker > (for upwards thingy)
+ db 0FFh ;end-marker /
where:
+ db 011h ;VSE / Protect
+ db offset(VSE2Real_code)-offset(VSE2Real_code)
+ db offset(Real2VSE_code)-offset(Real2OF_code)
db 007h ;OF
- db offset(OF2Real_code)-offset(OF2Real_code)
- db offset(Real2OF_code)-offset(Real2OF_code)
+ db offset(OF2Real_code)-offset(VSE2Real_code)
+ db offset(Real2OF_code)-offset(Real2MSL_code)
+ db 009h ;MSL
+ db offset(MSL2Real_code)-offset(OF2Real_code)
+ db offset(Real2MSL_code)-offset(Real2HT_code)
db 000h ;HT
- db offset(HT2Real_code)-offset(OF2Real_code)
- db offset(Real2HT_code)-offset(Real2OF_code)
+ db offset(HT2Real_code)-offset(MSL2Real_code)
+ db offset(Real2HT_code)-offset(Real2HDE_code)
db 001h ;HDE
db offset(HDE2Real_code)-offset(HT2Real_code)
- db offset(Real2HDE_code)-offset(Real2HT_code)
+ db offset(Real2HDE_code)-offset(Real2HBS_code)
db 002h ;HBS
db offset(HBS2Real_code)-offset(HDE2Real_code)
- db offset(Real2HBS_code)-offset(Real2HDE_code)
+ db offset(Real2HBS_code)-offset(Real2HBE_code)
db 003h ;HBE
db offset(HBE2Real_code)-offset(HBS2Real_code)
- db offset(Real2HBE_code)-offset(Real2HBS_code)
+ db offset(Real2HBE_code)-offset(Real2HSS_code)
db 004h ;HSS
db offset(HSS2Real_code)-offset(HBE2Real_code)
- db offset(Real2HSS_code)-offset(Real2HBE_code)
+ db offset(Real2HSS_code)-offset(Real2HSE_code)
db 005h ;HSE
db offset(HSE2Real_code)-offset(HSS2Real_code)
- db offset(Real2HSE_code)-offset(Real2HSS_code)
-where_V:
+ db offset(Real2HSE_code)-offset(Real2VT_code)
db 006h ;VT
db offset(VT2Real_code)-offset(HSE2Real_code)
- db offset(Real2VT_code)-offset(Real2HSE_code)
- db 009h ;MSL
- db offset(MSL2Real_code)-offset(VT2Real_code)
- db offset(Real2MSL_code)-offset(Real2VT_code)
+ db offset(Real2VT_code)-offset(Real2VSS_code)
db 010h ;VSS
- db offset(VSS2Real_code)-offset(MSL2Real_code)
- db offset(Real2VSS_code)-offset(Real2MSL_code)
- db 011h ;VSE / Protect
- db offset(VSE2Real_code)-offset(VSS2Real_code)
- db offset(Real2VSE_code)-offset(Real2VSS_code)
+ db offset(VSS2Real_code)-offset(VT2Real_code)
+ db offset(Real2VSS_code)-offset(Real2VDE_code)
db 012h ;VDE
- db offset(VDE2Real_code)-offset(VSE2Real_code)
- db offset(Real2VDE_code)-offset(Real2VSE_code)
+ db offset(VDE2Real_code)-offset(VSS2Real_code)
+ db offset(Real2VDE_code)-offset(Real2VBS_code)
db 015h ;VBS
db offset(VBS2Real_code)-offset(VDE2Real_code)
- db offset(Real2VBS_code)-offset(Real2VDE_code)
+ db offset(Real2VBS_code)-offset(Real2VBE_code)
db 016h ;VBE
db offset(VBE2Real_code)-offset(VBS2Real_code)
- db offset(Real2VBE_code)-offset(Real2VBS_code)
+where_backward:
+ db offset(Real2VBE_code)-offset(Real2VBE_code)
db 0FFh ;end-marker
what:
SCM db ?
CHR_Clock dw ?
GM db ?
MR db ?
+VSE dw ?
OF dw ?
+MSL dw ?
HT dw ?
HDE dw ?
HBS dw ?
HBE dw ?
HSS dw ?
HSE dw ?
-what_V:
VT dw ?
-MSL dw ?
VSS dw ?
-VSE dw ?
VDE dw ?
VBS dw ?
+what_backward:
VBE dw ?
LM db ?
LL dw ?
@@ -462,14 +470,11 @@ HDE2Real_code:
inc ax
HBS2Real_code:
HSS2Real_code:
- mov cl,[chr_clock-int10h]
- mul cl
+ mul [BYTE chr_clock-int10h]
HBE2Real_code: ;IGNORE FOR NOW
HSE2Real_code: ;IGNORE FOR NOW
OF2Real_code: ;OK
MSL2Real_code: ;OK
-VSE2Real_code: ;OK/NEVER USED
-VBE2Real_code: ;OK/NEVER USED (?REAL OK)
ret
VSS2Real_code:
@@ -478,24 +483,51 @@ VDE2Real_code:
inc cx
VT2Real_code: ;cl must be 1
mov ah,[BYTE OF-int10h]
- shr ah,cl
- pushf
- shr ah,4
- popf
- rcl ah,1
- and ah,00000011b
+ shr ah,cl
+ pushf
+ shr ah,4
+ popf
+ rcl ah,1
+ and ah,00000011b
+VSE2Real_code: ;OK/NEVER USED
+VBE2Real_code: ;OK/NEVER USED (?REAL OK)
inc ax
ret
VBS2Real_code:
mov ah,[BYTE OF-int10h]
mov ch,[BYTE MSL-int10h]
- shr ah,3
- shr ch,4
+ shr ah,3
+ shr ch,4
and ah,00000001b
and ch,00000010b
or ah,ch
-;inc ax ;??
+ inc ax
+ret
+
+Real2VSS_code:
+ inc cx
+Real2VDE_code:
+ inc cx
+Real2VT_code: ;cl must be 1
+ dec ax
+ shr ah,1
+ pushf
+ shl ah,4
+ popf
+ rcl ah,cl
+ or [BYTE of-int10h],ah
+ret
+
+Real2VBS_code:
+ dec ax
+ shl ah,3
+ mov ch,ah
+ and ah,00001000b
+ or [BYTE OF-int10h],ah
+ shl ch,1
+ and ch,00100000b
+ or [BYTE MSL-int10h],ch
ret
Real2HT_code:
@@ -508,40 +540,23 @@ Real2HSS_code:
div cl
Real2HBE_code: ;IGNORE FOR NOW
Real2HSE_code: ;IGNORE FOR NOW
+ pop ax
+ inc ax
+ push ax ;increase ret ip (skip OUT DX,AL)
Real2OF_code: ;OK/NEVER_Called
Real2MSL_code: ;OK
-Real2VBE_code: ;OK
-ret
-
-Real2VSE_code:
-and al,00001111b ;only 0-3 are used
-and ch,01110000b ;preserve 4-6
-or ch,10000000b ;set write-protect-bit
-or al,ch
ret
-Real2VSS_code:
- inc cx
-Real2VDE_code:
- inc cx
-Real2VT_code: ;cl must be 1
+Real2VBE_code: ;OK
dec ax
- shr ah,1
- pushf
- shl ah,4
- popf
- rcl ah,cl
- or [BYTE of-int10h],ah
ret
-Real2VBS_code:
- shl ah,3
- mov ch,ah
- and ah,00001000b
- or [BYTE OF-int10h],ah
- shl ch,1
- and ch,00100000b
- or [BYTE MSL-int10h],ch
+Real2VSE_code:
+ dec ax
+ and al,00001111b ;only 0-3 are used
+ and ch,01110000b ;preserve 4-6
+ or ch,10000000b ;set write-protect-bit
+ or al,ch
ret
FindSet_V:
@@ -549,9 +564,9 @@ FindSet_V:
mov [VDE-int10h],ax ; save(phys_lines) as new
mov si,ax ; save(phys_lines) in si
push ax ; save(phys_lines) to stack
- mul [WORD FPx_1p5-int10h] ; find 1.5%
+ mul [WORD FPx_bor-int10h] ; find right-border-lenght
div [WORD FPx_1_-int10h] ;could be replaced by shrd
- mov bp,ax ; save 1.5% in bp
+ mov bp,ax ; save in bp
add si,ax ; add to old phys
mov [VBS-int10h],si ; save in VBS
inc si ; inc it
@@ -567,29 +582,33 @@ FindSet_V:
div [WORD FPx_1_-int10h] ;could be replaced by shrd
add si,ax ;add it
mov [VBE-int10h],si ; save in VBE
- add si,bp ;add 1.5%
+ add si,bp ;add left-border-lenght
mov [VT-int10h],si ; save in VT
ret
+K_1 dw 1000
-FP8_1 dw 256
+PatchArgs:
+FP8_1 dw 256
FP8_MinRefresh dw 60 shl 8
FP8_MaxRefresh dw 90 shl 8
FP8_MinLineFreq dw 28 shl 8
FP8_MaxLineFreq dw 72 shl 8
-FP8_ClockTable dw 32 dup (?)
-FP8_ClockTable_end:
-
FPx_1_ dw FPx_1
-
-FPx_1p5 dw FPx_1/67 ;1/.015=67
+FPx_bor dw FPx_1/67 ;1/.015=67
FPx_VS dw FPx_1/200 ;1/.005=200
FPx_VB dw FPx_1*7/100 ;1/.070=(100/7)
+MaxLines dw 1023
+MinLines dw 300
+PatchArgs_End:
+
+
+FP8_ClockTable dw 128 dup (?)
+FP8_ClockTable_end:
+
clock_d db 0
-MaxLines dw 1023
-MinLines dw 300
counter db delay2
temp db 0
@@ -602,126 +621,197 @@ install:
cld ;clear dir_falg
mov dx,offset(c_r) ;dx=offset(copy-right)
call wstring ;write it to screen
- mov si,80h ;si=offset(Num_ComLineArgs)
+
+ call chk_600 ;check if installed (copy info from tsr)
+ jne NOT_Read
+ mov ds,bx ;es=cs of TSR
+ mov si,offset(PatchArgs)-offset(int10h)
+ mov di,offset(PatchArgs)
+ mov cx,PatchArgsSize
+ rep movsb ;Copy TSR Variables
+ mov al,[offset(CheckSet)-int10h];get En/Disable state
+ mov [cs:offset(CheckSet)],al ;set En/Disable state
+NOT_Read:
+
+ ;Find corr path to executable
+ mov ds,[cs:02Ch] ;ds=EnvSeg
+ mov si,1
+ mov di,offset(FP8_ClockTable) ;si=Temp Buffer
+GetPath_Loop:
+ dec si
+ lodsw
+ test ax,ax ;find 0,0
+ jnz GetPath_Loop
+ lodsw ;skip 2
+GetPath_Copy:
+ lodsb ;copy until 0
+ stosb
+ cmp al,'.'
+ jnz GetPath_NDot
+ mov bx,di ;bx=last .
+GetPath_NDot:
+ test al,al
+ jnz GetPath_Copy
+ push cs
+ pop ds ;restore ds
+ mov [WORD bx+1],'KL' ;fix COM -> CLK
+
+
+
+ mov di,80h ;di=offset(Num_ComLineArgs)
mov ch,0
- mov cl,[si] ;cx=Num_ComLineArgs
- inc si ;si=offset(ComLineArgsBuffer)
+ mov cl,[di] ;cx=Num_ComLineArgs
+ inc di ;di=offset(ComLineArgsBuffer)
or cx,cx ;check if nothing there
- jz Unk_Command
+ jz MSG_UnkCommand
+ add cx,di ;cx=ComLineEndPointer
xor bp,bp ;set nothing_Specified
-SkipSpace:
- lodsb ;fetch 1-byte from ComLine
- cmp al,' ' ;check if space
-loope SkipSpace ;loop until no space
- je nUnk_Command ;check if not at end
- test bp,bp ;check if no_VgaCardSpecified
- jnz ComLineOK
-Unk_Command: ;print error-msg and exit
- mov dx,offset(u_c)
- call wstring
- int 20h
-nUnk_Command:
+
+CommLine:
+ call SkipSpace
+ mov al,[di] ;fetch byte from CommLine
+ inc di ;and inc pointer
cmp al,'/' ;check if CommLineArg starts with /
jz Ok_Comm ;go on if so
cmp al,'-' ;check if CommLineArg starts with -
- jnz Unk_Command ;get out if not
-Ok_Comm
+ jnz MSG_UnkCommand ;get out if not
+Ok_Comm:
- mov di,si
mov si,offset(CommLineOptionsTable)
- mov bx,offset(CLO_Enable)
+ mov bx,offset(CLO_Enable)
Next_CommLineArg:
+ cmp [BYTE si],0 ;check if end of table reached
+ je MSG_UnkCommand
push di ;Save di
Next_CommLineArgByte:
lodsb ;fetch byte from table
- or al,00100000b ;conv to lower-case
+ or [BYTE di],00100000b ;conv to lower-case
scasb ;compare if same at CommLine
je Next_CommLineArgByte ;if yes check next
- test al,al ;check if end reached
- jnz Unk_Command ;SP not restored !
- dec di ;in case "/A1" instaed of "/A 1"
- mov al,' '
-Check_Space:
- scasb ;skip spaces
- je Check_Space
- dec di
+ test al,al ;check if CommLineEqual
+ jz CommLineArgId
+SkipTillZeroP1:
+ lodsb ;fetch next from Table
+ test al,al ;check if zero
+ jnz SkipTillZeroP1
+ lodsb ;get call address from table
+ cbw ;convert to word
+ add bx,ax ;add to last
+ pop di ;di=old di
+jmp Next_CommLineArg
+CommLineArgId:
+
+ dec di ; for /V1 instaed of /V 1
lodsb ;get call address from table
cbw ;convert to word
add bx,ax ;add to last
call bx ;call it
cbw ;convert to word
or bp,ax ;set bit in bp
- pop di ;restore di
- lodsb ;fetch next
- dec di ;restore di
- test al,al ;check if end reached
- jnz Next_CommLineArg
-jmp SkipSpace ;get next CommLineArg from CommLine
-CommLineOk:
+ pop ax ;corr stack
+jmp CommLine ;get next CommLineArg from CommLine
+
+EndCommLine:
+ test bp,bp ;check if no_VgaCardSpecified
+ jnz ComLineOK
+MSG_UnkCommand: ;print error-msg and exit
+ mov dx,offset(u_c)
+ jmp estring
+
+ComLineOk:
push bp ;save bp
shr bp,2 ;remove OptionFlag and VgaCardSpecifiedFlag
+ test bp,bp ;check if zero (CRASH)
+ jz ZERO_BP ;don't shr if yes
CheckLine:
shr bp,1 ;remove rightmost flag
- jnc CheckLine: ;if flag was 0 try next
+ jnc CheckLine ;if flag was 0 try next
+ZERO_BP:
test bp,bp ;if not zero then error
- jnz UnkCommand
+ jnz MSG_UnkCommand
pop bp ;restore bp
mov ax,bp ;ax=bp
- xor ah,al ;(ah=0) ah=~al
+ mov ah,al
+ not ah ;ah=~al
cmp al,00010000b ;Check for UnInstall
je UnInstall
cmp al,00100001b ;Check for Probe(and vga_card)
- je Probe
- test ax,0000000111111100b ;Check for VgaCard w/o other stuff
+ je Probe2
+ test ax,0000000111110000b ;Check for VgaCard/Options/E/D w/o other stuff
jz GoTSR
test al,11110001b ;Check for Enable/Disable/options w/o other stuff
- jz PassToTSR
- jmp UnkCommand
+ jnz MSG_UnkCommand
+ jmp PassToTSR
+Probe2:
+jmp Probe
+UnInstall:
+ call chk_600 ;check if installed
+ je nMSG_NotInstalled
+MSG_NotInstalled: ;print "Not Installed"
+ mov dx,offset(n_i)
+ jmp estring
+nMSG_NotInstalled:
+push bx
+ mov ax,3510h
+ int 21h ;get int 10
+ pop bx
+ push bx ;bx=cs of TSR
+ mov ax,es ;ax=cs of Int10 Handler
+ cmp ax,bx ;check if equal
+ je nMSG_CantUnload ;get out if not
+MSG_CantUnload: ;print "Not Installed"
+ mov dx,offset(n_u)
+ jmp estring
+nMSG_CantUnload:
- cmp al,33h
- ja Unk_Command
- sub al,30h
- jb Unk_Command
- push si
- mov ah,0
- xchg ax,bx
- add bx,bx ;shl bx,1
- mov si,[WORD bx+code_table]
- mov di,offset(patch_code)
- mov cx,patch_size
- rep movsb ;copy clock_code
- pop si
+ mov ax,3508h
+ int 21h ;get int 8
+ pop bx ;bx=cs of TSR
+ mov ax,es ;ax=cs of Int8 Handler
+ cmp ax,bx ;check if equal
+ jne MSG_CantUnload ;get out if not
- call chk_600
- jne nalready_installed
- mov dx,offset(p_a)
- call wstring
- mov es,bx
- cli
- mov di,offset(patch_code)-int10h
- mov si,offset(patch_code)
- mov cx,patch_size
- rep movsb ;Update TSR Variables
- int 20h
+ mov dx,[es:offset(old_int10h)-int10h]
+ mov ds,[es:offset(old_int10h)-int10h+2]
+ mov ax,2510h
+ int 21h ;set old int 10
+ mov dx,[es:offset(old_int8h)-int10h]
+ mov ds,[es:offset(old_int8h)-int10h+2]
+ mov ax,2508h
+ int 21h ;set old int 8
+ mov ah,49h
+ int 21h ;free mem
+int 20h
-enable_disable:
- call chk_600
- je nnot_inst
- jmp not_inst
-nnot_inst:
- mov dx,offset(p_a)
- call wstring
- mov es,bx
- mov al,[offset(CheckSet)]
- mov [es:CheckSet-int10h],al
- int 20h
+GoTSR:
+ call chk_600 ;check if installed
+ jne n2MSG_AlreadyInstalled
+ jmp MSG_AlreadyInstalled
+n2MSG_AlreadyInstalled:
-nalready_installed:
+ mov ax,3D00h ;open file for read
+ mov dx,offset(FP8_ClockTable) ;CorrPath\vga600.clk
+ int 21h
+ jnc nMSG_FileError2
+MSG_FileError2:
+ mov dx,offset(f_e)
+ jmp estring
+nMSG_FileError2:
+ xchg ax,bx ;bx=file_handle
+
+ mov ah,3Fh ;read from file
+ mov dx,offset(FP8_ClockTable) ;into ClockTable
+ mov cx,128*2 ;128 Words
+ int 21h
+ jc MSG_FileError2
+
+ mov ah,3Fh
+ int 21h ;and close it
mov ax,3510h
int 21h ;get old int 10
@@ -733,20 +823,20 @@ nalready_installed:
mov [offset(old_int8h)],bx
mov [offset(old_int8h)+2],es
- mov sp,offset end_all+0FEh
+ mov sp,offset end_all+0FEh ;shrink stack (less mem needed)
push cs
- pop es
+ pop es ;es=cs
mov ah,04Ah
mov bx,paras_all+010h
- int 21h ;resize us
+ int 21h ;shrink us
jc mem_error
mov ah,048h ;!BX=paras_all+10h
int 21h ;allocate mem for copy
jc mem_error
- mov es,ax
+ mov es,ax ;es=cs of copy
mov cx,offset end_all+0100h
xor di,di
xor si,si
@@ -756,41 +846,45 @@ nalready_installed:
push offset cool_jmp
retf ;mov cs,es
-cool_jmp: ;
+cool_jmp: ;Now We are in the Copy
push cs
- pop ss ;and the stack
+ pop ss ;and the stack Too
mov ax,ds
- cmp [016h],ax
+ cmp [016h],ax ;check if parent process seg addr old=oldcs
jne ok2
- mov [es:016h],es
+ mov [es:016h],es ;if yes set parent process seg addr new=newcs
ok2:
- cmp [034h+2],ax
+ cmp [034h+2],ax ;check if handle array pointer old=oldcs
jne ok3
- mov [es:034h+2],es
+ mov [es:034h+2],es ;if yes set handle array pointer new=newcs
ok3:
mov ah,50h
- mov bx,cs
- int 21h ;set addr of PSP
+ mov bx,cs ;bx=cs of copy
+ int 21h ;set addr of PSP
+
+ mov ax,cs
+ dec ax
+ mov es,ax ;es=cs-1 (MCB-Seg)
+ mov [es:1],cs ;set seg to itself
push ds
pop es
mov ah,49h
- int 21h ;get rid of the old shit
+ int 21h ;get rid of the old shit
- mov ax,cs
- mov ds,ax
- dec ax
- mov es,ax
- mov [es:1],ds ;set seg to itself
+ push cs
+ pop ds ;ds=cs
mov es,[2ch] ;es=env-seg
+ mov ah,49h ;free memory
+ int 21h ;free env-seg
mov bx,paras
- mov ah,4ah
- int 21h ;resize env
- cmp bx,paras
- je nmem_error
+ mov ah,48h ;alloc memory
+ int 21h ;alloc new seg
+ mov es,ax ;es=seg of new seg
+ jnc nmem_error
mem_error:
mov dx,offset(m_e)
call wstring
@@ -816,192 +910,265 @@ nmem_error:
exit_load:
push cs
- pop es
- mov ah,49h
- int 21h
+ pop es ;es=cs
+ mov ah,49h ;free mem
+ int 21h ;free us (hope that doesnt kill us)
mov ah,04ch
int 21h ;get out (cool TSR)
-unload:
- call chk_600
- je nnot_installed
-not_inst:
- mov dx,offset(n_i)
- call wstring
- int 20h
-nnot_installed:
- push bx
- mov ax,3510h
- int 21h ;get int 10
- pop bx
- push bx
- mov ax,es
- cmp ax,bx
- jne not_unload
-
- mov ax,3508h
- int 21h ;get int 8
- pop bx
- mov ax,es
- cmp ax,bx
- jne not_unload
-
- mov dx,[es:offset(old_int10h)-int10h]
- mov ds,[es:offset(old_int10h)-int10h+2]
- mov ax,2510h
- int 21h ;set old int 10
- mov dx,[es:offset(old_int8h)-int10h]
- mov ds,[es:offset(old_int8h)-int10h+2]
- mov ax,2508h
- int 21h ;set old int 8
- mov ah,49h
- int 21h ;free mem
-int 20h
-not_unload:
- mov dx,offset(n_u)
- call wstring
-int 20h
+PassToTSR:
+ call chk_600 ;check if installed
+ je n2MSG_NotInstalled
+ jmp MSG_NotInstalled
+n2MSG_NotInstalled:
+ mov dx,offset(p_a) ;print "passing arguments to TSR"
+ call wstring
+ mov es,bx ;es=cs of TSR
+ cli ;better
+ mov di,offset(PatchArgs)-offset(int10h)
+ mov si,offset(PatchArgs)
+ mov cx,PatchArgsSize
+ rep movsb ;Update TSR Variables
+ mov al,[offset(CheckSet)] ;get En/Disable state
+ mov [es:CheckSet-int10h],al ;set En/Disable state
+ int 20h ;get OUT
probe:
call chk_600
- jne nprobeerror
+MSG_AlreadyInstalled:
+MSG_ProbeError:
+ jne nMSG_ProbeError
mov dx,offset(p_e)
- call wstring
-; int 20h
-nprobeerror:
+ jmp estring
+nMSG_ProbeError:
mov ax,0013h
- int 10h
+ int 10h ;set 320x200 (must be 25MHz)
- mov ax,3508h
- int 21h ;get old int 8
- mov [offset(old_int8xh)],bx
- mov [offset(old_int8xh)+2],es
+ call GetVSyncTime ;wait for end
+ call GetVSyncTime ;get Time
+ mov bp,1
+Probe_FindShift: ;BitScan
+ shl bp,1 ;Double Divider
+ shr dx,1 ;32bit shift
+ rcr ax,1
+ test dx,dx ;max 16bit
+ jnz Probe_FindShift
+ cmp ax,01000h ;max 25*16Mhz
+ jae Probe_FindShift
- mov dx,offset(int8_probe)
- mov ax,2508h
- int 21h ;set new int 8
+
+;MSG_InterError: ;print error-msg and exit
+; mov dx,offset(d_e)
+; jmp estring
+
+ xchg bx,ax ;bx=lenght of refresh at 25Mhz
+
+ mov dx,offset(FP8_ClockTable)
+ xor cx,cx
+ mov ah,3Ch ;create file
+ int 21h
+ jnc nMSG_FileError
+MSG_FileError: ;print error-msg and exit
+ mov dx,offset(f_e)
+ jmp estring
+nMSG_FileError:
+ push ax ;save handle
+
+ mov si,dx
xor di,di
- mov si,offset FP8_ClockTable
probe_loop:
- mov ax,di
- call patch_code2
+ pusha ;save regs
+ xchg ax,di ;ax=clock
+ mov dh,3
+ call PatchClockCode2 ;set clock
+ popa ;restore regs
- mov [WORD int8_counter],-1
-syncint8:
- cmp [WORD int8_counter],0
- js syncint8
+ call GetVSyncTime ;wait for end
+ call GetVSyncTime ;get Time for refresh at 25.175Mhz
+ div bp
- call waitvret
- xor cx,cx
-wait_loop:
- call waitvret
- inc cx
- cmp [WORD int8_counter],18
- jb wait_loop
- shl cx,6 ;mul cx,64
- xchg ax,cx
- mov cl,179
- div cl
- mov [si],al
+ xchg cx,ax ;cx=lenght of refresh
+ mov ax,bx ;ax=lenght of refresh at 25Mhz
+ mov dx,6445 ;25.175*256=6444.8
+ mul dx
+ div cx ;ax=FP8_Clock
+
+ mov [si],ax ;save it
+ inc si ;inc pointer
inc si
- inc di
- cmp di,32
+ inc di ;inc clock num
+ cmp di,128 ;check if end
jb probe_loop
-end1:
- mov ax,0003h
+ mov ax,0003h ;set text mode 3
int 10h
- mov si,offset FP8_ClockTable
+ pop bx ;bx=FileHandle
- mov cx,32
-print_loop:
- test cl,111b
- jnz no_crlf
- mov dx,offset crlf
- call wstring
-no_crlf:
- mov ah,0
- mov al,[si]
- inc si
- call wdez
- mov dx,offset Mhz
- call wstring
- loop print_loop
-end_print:
+ mov ah,40h ;write to file
+ mov cx,128*2 ;how many bytes
+ mov dx,offset FP8_ClockTable ;from where
+ int 21h
+ jc MSG_FileError
+ mov ah,3Fh
+ int 21h
+int 20h
- mov dx,[offset(old_int8xh)]
- mov ds,[offset(old_int8xh)+2]
- mov ax,2508h
- int 21h ;set old int 8
+GetVSyncTime: ;dx:ax=ticks for V-Refresh
+ push cx
+ mov cx,ProbeTimes
+ xor ax,ax
+ xor dx,dx
+WaitVSync:
+ add ax,1 ;inc di:si
+ adc dx,0
+ cmp dx,ProbeTimes*64 ;check if to big
+ ja GetVSyncTimeEnd0
+ push dx
+ push ax
+ mov dx,03dah
+ in al,dx ;get data
+ test al,1000b ;mask v-sync-bit
+ pop ax
+ pop dx
+ jz WaitVSync
+WaitVEndSync:
+ add ax,1 ;inc di:si
+ adc dx,0
+ cmp dx,ProbeTimes*64 ;check if too big
+ ja GetVSyncTimeEnd0
+ push dx
+ push ax
+ mov dx,03dah
+ in al,dx ;get data
+ test al,1000b ;mask v-sync-bit
+ pop ax
+ pop dx
+ jnz WaitVEndSync
+ loop WaitVSync
+GetVSyncTimeEnd0:
+ pop cx
+ret
+estring:
+ call wstring
int 20h
-waitvret:
- pusha
- mov dx,03dah
-waitsvret:
- in al,dx
- mov cl,1000b
- and al,cl
- loope waitsvret
-waitevret:
- in al,dx
- mov cl,1000b
- and al,cl
- loopne waitevret
- popa
+wstring:
+ mov ah,09h
+ int 21h ;print string
ret
-int8_probe:
- inc [WORD cs:int8_counter]
-db 0eah
-old_int8xh dd 0
+;wchar:
+; mov ah,02h
+; int 21h ;print string
+;ret
-wstring:
- mov ah,09h
- int 21h
+;SetNumHex:
+; ror ax,12 ;4 MSB of ax ->al
+; mov cx,4
+;SetNumHex_Next:
+; push ax ;save it
+; and al,0Fh
+; add al,030h ; conv to ascii
+; cmp al,03Ah ; check if A-F
+; jl SetNumHex_NoChar
+; add al,7 ; conv to ascii (A-F)
+;SetNumHex_NoChar:
+; xchg ax,dx ;put in dx
+; call wchar ; write it
+; pop ax ;restore old
+; rol ax,4 ; rol to next
+; loop SetNumHex_Next ; loop if not all written
+;ret
+
+GetNum: ;ds:di !!
+ call SkipSpace
+ push dx
+ push bx ;save bx/dx
+ mov bh,0
+ xor ax,ax ;bh/ax=0
+ mov dh,0FFh ;check if num exist (mul resets dx=0)
+GetNum_NextByte:
+ mov bl,[di] ;bl=ASC(num)
+ cmp bl,' ' ;check for space
+ je GetNum_End
+ cmp di,cx
+ jae GetNum_End
+ inc di
+ sub bl,30h ;bl=num /check for <30h
+ jb xMSG_UnkCommand
+ cmp bl,9 ;check for >39h
+ ja xMSG_UnkCommand
+ mul [n10] ;ax=OldNum*10
+ add ax,bx ;ax=OldNum*10+Num
+jmp GetNum_NextByte
+GetNum_End:
+ test dh,dh ;check if anything there
+ jz n2MSG_UnkCommand
+xMSG_UnkCommand:
+ jmp MSG_UnkCommand
+n2MSG_UnkCommand:
+ pop bx ;restore bx/dx
+ pop dx ;end
ret
-wdez:
- pusha
- mov di,ax
- mov cx,5
- mov si,10000
- mov bx,10
-dez_loop:
- xor dx,dx
- div si
+GetNumFP8: ;ds:di !!
+ call SkipSpace
push dx
- cmp cx,1
- je nnope
- cmp dx,di
- je nope
-nnope:
- xchg ax,dx
- mov ah,2
- add dl,30h
- int 21h
-nope:
- xchg si,ax
- xor dx,dx
- div bx
- xchg si,ax
- pop ax
-loop dez_loop
- popa
+ push bx
+ push bp ;save bx/dx/bp/si
+ push si
+ mov bh,0
+ xor ax,ax ;ch/ax=0
+ mov bp,1
+ mov si,bp ;si=bp=1
+ mov dh,0FFh ;check if num exist (mul resets dx=0)
+GetNumFP8_NextByte:
+ mov bl,[di] ;bl=ASC(num)
+ cmp bl,' ' ;check for space
+ je GetNumFP8_End
+ cmp di,cx
+ jae GetNumFP8_End
+ cmp bl,'.'
+ jne GetNumFP8_NotDot
+ mov si,10
+ inc di
+ jmp GetNumFP8_NextByte
+GetNumFP8_NotDot:
+ inc di
+ sub bl,30h ;bl=num /check for <30h
+ jb xMSG_UnkCommand
+ cmp bl,9 ;check for >39h
+ ja xMSG_UnkCommand
+ xchg ax,bp
+ mul si
+ xchg ax,bp ;mul bp,si
+ mul [n10] ;ax=OldNum*10
+ add ax,bx ;ax=OldNum*10+Num
+jmp GetNumFP8_NextByte
+GetNumFP8_End:
+ test dh,dh ;check if anything there
+ jnz xMSG_UnkCommand
+ mul [FP8_1]
+ div bp
+ pop si
+ pop bp
+ pop bx ;restore bx/dx/bp/si
+ pop dx ;end
ret
+
chk_600:
mov ax,020FFh
int 10h
- cmp ax,00600h
+ cmp ax,00600h ;if equal vga600 already installed
ret
vga_clock:
@@ -1038,12 +1205,6 @@ s3_clock:
out dx,al
ret
-alt_vga_clock:
- and ax,0001110011100011b
- or al,ah
- out dx,al ;0-2
-ret
-
CLO_Enable:
mov [BYTE CheckSet],060h ;set first oppcode to pusha
mov al,00000100b ;set Enable-Flag
@@ -1055,10 +1216,23 @@ CLO_Disable:
ret
CLO_VgaCard:
+ call GetNum ;Get Number
+ pusha
+ cmp ax,2 ;check if >2
+ jna OK_VgaCardNum
+ jmp MSG_UnkCommand ;get out if yes
+OK_VgaCardNum:
+ shl ax,1 ;*2
+ xchg ax,si ;si=num*2
+ mov si,[si+offset(ClockCodeTable)] ;si=ClockCodeTable[num*2]
+ mov di,offset(PatchClockCode)
+ mov cx,PatchCodeSize
+ rep movsb ;copy NewClockCode to PatchClockCode
+ popa
mov al,00000001b ;set Vga_card_specified-flag
ret
-CLO_UnInstatll:
+CLO_UnInstall:
mov al,00010000b ;set UnInstall-Flag
ret
@@ -1102,37 +1276,95 @@ CLO_MinLines:
mov al,00000010b ;set Options-Flag
ret
+CLO_Border:
+ call GetNumFP8
+ pusha
+ mov bx, (FPx_1/256)
+ mul bx
+ mov bx, 100
+ div bx
+ mov [FPx_bor],ax
+ popa
+ mov al,00000010b ;set Options-Flag
+ret
+
+CLO_VSync:
+ call GetNumFP8
+ pusha
+ mov bx, (FPx_1/256)
+ mul bx
+ mov bx, 100
+ div bx
+ mov [FPx_VS],ax
+ popa
+ mov al,00000010b ;set Options-Flag
+ret
+
+CLO_VBlank:
+ call GetNumFP8
+ pusha
+ mov bx, (FPx_1/256)
+ mul bx
+ mov bx, 100
+ div bx
+ mov [FPx_VB],ax
+ popa
+ mov al,00000010b ;set Options-Flag
+ret
+
+SkipSpace: ;!DS:DI
+ push ax
+ mov al,' '
+Check_Space:
+ scasb ;skip spaces
+ je Check_Space
+ dec di
+ pop ax
+ cmp di,cx
+ jae PopEndCommLine
+ret
+PopEndCommLine:
+pop ax
+jmp EndCommLine
+
int8_counter dw 0
-code_table:
+n10 dw 10
+
+ClockCodeTable:
dw offset(vga_clock)
dw offset(et4000_clock)
dw offset(s3_clock)
- dw offset(alt_vga_clock)
CommLineOptionsTable:
- db 'e',0,offset(CLO_Enable)-offset(CLO_Enable)
- db 'd',0,offset(CLO_Disable)-offset(CLO_Enable)
- db 'v',0,offset(CLO_VgaCard)-offset(CLO_Disable)
- db 'u',0,offset(CLO_UnInstall)-offset(CLO_VgaCard)
- db 'p',0,offset(CLO_Probe)-offset(CLO_UnInstall)
+ db 'e',0,offset(CLO_Enable) -offset(CLO_Enable)
+ db 'd',0,offset(CLO_Disable) -offset(CLO_Enable)
+ db 'v',0,offset(CLO_VgaCard) -offset(CLO_Disable)
+ db 'u',0,offset(CLO_UnInstall) -offset(CLO_VgaCard)
+ db 'p',0,offset(CLO_Probe) -offset(CLO_UnInstall)
db 'alf',0,offset(CLO_MaxLineFreq)-offset(CLO_Probe)
db 'ilf',0,offset(CLO_MinLineFreq)-offset(CLO_MaxLineFreq)
- db 'ar',0,offset(CLO_MaxRefresh)-offset(CLO_MinLineFreq)
- db 'ir',0,offset(CLO_MinRefresh)-offset(CLO_MaxRefresh)
- db 'al',0,offset(CLO_MaxLines)-offset(CLO_MinRefresh)
- db 'il',0,offset(CLO_MinLines)-offset(CLO_MaxLines)
+ db 'ar',0,offset(CLO_MaxRefresh) -offset(CLO_MinLineFreq)
+ db 'ir',0,offset(CLO_MinRefresh) -offset(CLO_MaxRefresh)
+ db 'al',0,offset(CLO_MaxLines) -offset(CLO_MinRefresh)
+ db 'il',0,offset(CLO_MinLines) -offset(CLO_MaxLines)
+ db 'bo',0,offset(CLO_Border) -offset(CLO_MinLines)
+ db 'ys',0,offset(CLO_VSync) -offset(CLO_Border)
+ db 'yb',0,offset(CLO_VBlank) -offset(CLO_VSync)
db 0
c_r db 'VGA600 ver 0.6 Beta Copyright (C) Michael Niedermayer 1997',cr,lf,'$'
u_c db 'VGA600 <options>|/U|/E|/D|/P',cr,lf
db ' options: /V n (VgaCard) 0=VGA 1=ET4000 2=S3(untested)',cr,lf
- db ' /ALF n (MaxLineFreq) default=0',cr,lf
- db ' /ILF n (MinLineFreq) default=28',cr,lf
- db ' /AR n (MaxRefresh) default=70',cr,lf
- db ' /IR n (MinRefresh) default=60',cr,lf
- db ' /AL n (MaxLines) default=480',cr,lf
- db ' /IL n (MinLines) default=300',cr,lf
+ db ' /ALF n (MaxLineFreq) default=0.0',cr,lf
+ db ' /ILF n (MinLineFreq) default=28.0',cr,lf
+ db ' /AR n (MaxRefresh) default=70.0',cr,lf
+ db ' /IR n (MinRefresh) default=60.0',cr,lf
+ db ' /AL n (MaxLines) default=480',cr,lf
+ db ' /IL n (MinLines) default=300',cr,lf
+ db ' /BO n (Border) default=1.5',cr,lf
+ db ' /YS n (Vertical-Sync) default=0.5',cr,lf
+ db ' /YB n (Vertical-Blank) default=7.0',cr,lf
db ' /E (Enable)',cr,lf
db ' /D (Disable)',cr,lf
db ' /P (Probe for PixelClocks)',cr,lf
@@ -1142,9 +1374,8 @@ n_u db 'VGA600 is not unloadable!',cr,lf
m_e db 'Mem allocating error!',cr,lf,'$'
p_a db 'Passing arguments to TSR!',cr,lf,'$'
p_e db 'Uninstall VGA600 first!',cr,lf,'$'
-Mhz db 'Mhz $'
-crlf db cr,lf,'$'
-
+d_e db 'Internal Error!',cr,lf,'$'
+f_e db 'Clock Data File Access Error!',cr,lf,'$'
end_all:
ends
end start
1
0
Author: michael
Date: Fri Jul 6 01:00:10 2007
New Revision: 72
Log:
version from 1997-02-19 15:37
Modified:
trunk/vga600/vga600.asm
Modified: trunk/vga600/vga600.asm
==============================================================================
--- trunk/vga600/vga600.asm (original)
+++ trunk/vga600/vga600.asm Fri Jul 6 01:00:10 2007
@@ -173,9 +173,9 @@ Not2_End_CheckSet:
cmp bx,ax
jb End2_CheckSet
- cmp ax,[max_line-int10h] ;check num_lines (300-1000)
+ cmp ax,[MaxLines-int10h] ;check num_lines (300-1000)
ja End2_CheckSet
- cmp ax,[min_line-int10h]
+ cmp ax,[MinLines-int10h]
jb End2_CheckSet
mov al,[MSL-int10h]
@@ -211,7 +211,7 @@ FindBest:
n3:
mov ax,bx
call FindSet_V ;find and set Vertical nums
- cmp si,[max_line-int10h]
+ cmp si,[MaxLines-int10h]
ja End_FindBest ; get out if toooo much
mov si,FP8_ClockTable-int10h ;si=pointer to clock_table
@@ -221,15 +221,15 @@ FindBestClock:
mov ax,[WORD si] ;get clock
mul [WORD FP8_1-int10h] ;for more precision
div [WORD HT-int10h] ;find line_freq HT MUST >256
- cmp ax,[FP8_min_LineFreq] ;check if < min_LineFreq
+ cmp ax,[FP8_MinLineFreq] ;check if < MinLineFreq
jb End_FindBestClock
- cmp ax,[FP8_max_LineFreq] ;check if > max_LineFreq
+ cmp ax,[FP8_MaxLineFreq] ;check if > MaxLineFreq
ja End_FindBestClock
mul [WORD FP8_1-int10h] ;for more precision
div [WORD VT-int10h] ;find refresh_freq VT>256
- cmp ax,[FP8_min_refresh] ;check if < min_refresh
+ cmp ax,[FP8_MinRefresh] ;check if < MinRefresh
jb End_FindBestClock
- cmp ax,[FP8_max_refresh] ;check if > max_refresh
+ cmp ax,[FP8_MaxRefresh] ;check if > MaxRefresh
ja End_FindBestClock
cmp ax,bp ;check if better than best
jb End_FindBestClock
@@ -573,23 +573,23 @@ ret
FP8_1 dw 256
-FP8_min_refresh dw 60 shl 8
-FP8_max_refresh dw 90 shl 8
-FP8_min_LineFreq dw 28 shl 8
-FP8_max_LineFreq dw 72 shl 8
-
-FP8_ClockTable dw 32 dup (?)
+FP8_MinRefresh dw 60 shl 8
+FP8_MaxRefresh dw 90 shl 8
+FP8_MinLineFreq dw 28 shl 8
+FP8_MaxLineFreq dw 72 shl 8
+
+FP8_ClockTable dw 32 dup (?)
FP8_ClockTable_end:
FPx_1_ dw FPx_1
FPx_1p5 dw FPx_1/67 ;1/.015=67
FPx_VS dw FPx_1/200 ;1/.005=200
-FPx_VB dw FPx_1/14 ;1/.070=14 !!!(inacurate)
+FPx_VB dw FPx_1*7/100 ;1/.070=(100/7)
clock_d db 0
-max_line dw 1023
-min_line dw 300
+MaxLines dw 1023
+MinLines dw 300
counter db delay2
temp db 0
@@ -599,51 +599,94 @@ end10h:
install:
- cld
- mov dx,offset(c_r)
- call wstring
- mov si,80h
+ cld ;clear dir_falg
+ mov dx,offset(c_r) ;dx=offset(copy-right)
+ call wstring ;write it to screen
+ mov si,80h ;si=offset(Num_ComLineArgs)
mov ch,0
- mov cl,[si]
- inc si
- or cx,cx
- jz unk_command
+ mov cl,[si] ;cx=Num_ComLineArgs
+ inc si ;si=offset(ComLineArgsBuffer)
+ or cx,cx ;check if nothing there
+ jz Unk_Command
+ xor bp,bp ;set nothing_Specified
-commands:
- lodsb
- cmp al,'/'
-loopne commands
- je nunk_command
-unk_command:
+SkipSpace:
+ lodsb ;fetch 1-byte from ComLine
+ cmp al,' ' ;check if space
+loope SkipSpace ;loop until no space
+ je nUnk_Command ;check if not at end
+ test bp,bp ;check if no_VgaCardSpecified
+ jnz ComLineOK
+Unk_Command: ;print error-msg and exit
mov dx,offset(u_c)
call wstring
int 20h
-nunk_command:
+nUnk_Command:
- lodsb
- or al,00100000b ;conv to lower-case
+ cmp al,'/' ;check if CommLineArg starts with /
+ jz Ok_Comm ;go on if so
+ cmp al,'-' ;check if CommLineArg starts with -
+ jnz Unk_Command ;get out if not
+Ok_Comm
- cmp al,'u'
- jne nunload
- jmp unload
-nunload:
+ mov di,si
+ mov si,offset(CommLineOptionsTable)
+ mov bx,offset(CLO_Enable)
+Next_CommLineArg:
+ push di ;Save di
+Next_CommLineArgByte:
+ lodsb ;fetch byte from table
+ or al,00100000b ;conv to lower-case
+ scasb ;compare if same at CommLine
+ je Next_CommLineArgByte ;if yes check next
+ test al,al ;check if end reached
+ jnz Unk_Command ;SP not restored !
+ dec di ;in case "/A1" instaed of "/A 1"
+ mov al,' '
+Check_Space:
+ scasb ;skip spaces
+ je Check_Space
+ dec di
+ lodsb ;get call address from table
+ cbw ;convert to word
+ add bx,ax ;add to last
+ call bx ;call it
+ cbw ;convert to word
+ or bp,ax ;set bit in bp
+ pop di ;restore di
+ lodsb ;fetch next
+ dec di ;restore di
+ test al,al ;check if end reached
+ jnz Next_CommLineArg
+jmp SkipSpace ;get next CommLineArg from CommLine
+CommLineOk:
- cmp al,'e'
- jne nenable
- mov [BYTE CheckSet],060h
- jmp enable_disable
-nenable:
+ push bp ;save bp
+ shr bp,2 ;remove OptionFlag and VgaCardSpecifiedFlag
+CheckLine:
+ shr bp,1 ;remove rightmost flag
+ jnc CheckLine: ;if flag was 0 try next
+ test bp,bp ;if not zero then error
+ jnz UnkCommand
+ pop bp ;restore bp
+
+ mov ax,bp ;ax=bp
+ xor ah,al ;(ah=0) ah=~al
+ cmp al,00010000b ;Check for UnInstall
+ je UnInstall
+ cmp al,00100001b ;Check for Probe(and vga_card)
+ je Probe
+ test ax,0000000111111100b ;Check for VgaCard w/o other stuff
+ jz GoTSR
+ test al,11110001b ;Check for Enable/Disable/options w/o other stuff
+ jz PassToTSR
+ jmp UnkCommand
- cmp al,'d'
- jne ndisable
- mov [BYTE CheckSet],0C3h
- jmp enable_disable
-ndisable:
cmp al,33h
- ja unk_command
+ ja Unk_Command
sub al,30h
- jb unk_command
+ jb Unk_Command
push si
mov ah,0
xchg ax,bx
@@ -998,7 +1041,65 @@ ret
alt_vga_clock:
and ax,0001110011100011b
or al,ah
- out dx,al ;0-2
+ out dx,al ;0-2
+ret
+
+CLO_Enable:
+ mov [BYTE CheckSet],060h ;set first oppcode to pusha
+ mov al,00000100b ;set Enable-Flag
+ret
+
+CLO_Disable:
+ mov [BYTE CheckSet],0C3h ;set first oppcode to ret
+ mov al,00001000b ;set Disable-Flag
+ret
+
+CLO_VgaCard:
+ mov al,00000001b ;set Vga_card_specified-flag
+ret
+
+CLO_UnInstatll:
+ mov al,00010000b ;set UnInstall-Flag
+ret
+
+CLO_Probe:
+ mov al,00100000b ;set Probe-Flag
+ret
+
+CLO_MaxLineFreq:
+ call GetNumFP8
+ mov [FP8_MaxLineFreq],ax
+ mov al,00000010b ;set Options-Flag
+ret
+
+CLO_MinLineFreq:
+ call GetNumFP8
+ mov [FP8_MinLineFreq],ax
+ mov al,00000010b ;set Options-Flag
+ret
+
+CLO_MaxRefresh:
+ call GetNumFP8
+ mov [FP8_MaxRefresh],ax
+ mov al,00000010b ;set Options-Flag
+ret
+
+CLO_MinRefresh:
+ call GetNumFP8
+ mov [FP8_MinRefresh],ax
+ mov al,00000010b ;set Options-Flag
+ret
+
+CLO_MaxLines:
+ call GetNum
+ mov [MaxLines],ax
+ mov al,00000010b ;set Options-Flag
+ret
+
+CLO_MinLines:
+ call GetNum
+ mov [MinLines],ax
+ mov al,00000010b ;set Options-Flag
ret
int8_counter dw 0
@@ -1009,16 +1110,33 @@ code_table:
dw offset(s3_clock)
dw offset(alt_vga_clock)
+CommLineOptionsTable:
+ db 'e',0,offset(CLO_Enable)-offset(CLO_Enable)
+ db 'd',0,offset(CLO_Disable)-offset(CLO_Enable)
+ db 'v',0,offset(CLO_VgaCard)-offset(CLO_Disable)
+ db 'u',0,offset(CLO_UnInstall)-offset(CLO_VgaCard)
+ db 'p',0,offset(CLO_Probe)-offset(CLO_UnInstall)
+ db 'alf',0,offset(CLO_MaxLineFreq)-offset(CLO_Probe)
+ db 'ilf',0,offset(CLO_MinLineFreq)-offset(CLO_MaxLineFreq)
+ db 'ar',0,offset(CLO_MaxRefresh)-offset(CLO_MinLineFreq)
+ db 'ir',0,offset(CLO_MinRefresh)-offset(CLO_MaxRefresh)
+ db 'al',0,offset(CLO_MaxLines)-offset(CLO_MinRefresh)
+ db 'il',0,offset(CLO_MinLines)-offset(CLO_MaxLines)
+ db 0
+
c_r db 'VGA600 ver 0.6 Beta Copyright (C) Michael Niedermayer 1997',cr,lf,'$'
-u_c db 'VGA600 /vga_card <options>|/U|/E|/D',cr,lf
- db ' vga_card: 0=VGA 1=ET4000 2=S3(untested)',cr,lf
- db ' options: /ALF=x (Max_LineFreq) default=0',cr,lf
- db ' /ILF=x (Min_LineFreq) default=28',cr,lf
- db ' /AR=x (Max_Refresh) default=70',cr,lf
- db ' /IR=x (Min_Refresh) default=60',cr,lf
- db ' /AL=x (Max_Lines) default=480',cr,lf
- db ' /IL=x (Min_Lines) default=300',cr,lf
- db 'ex: VGA600 /1 /ALF=72 /AL=1023 /AR=90',cr,lf,'$'
+u_c db 'VGA600 <options>|/U|/E|/D|/P',cr,lf
+ db ' options: /V n (VgaCard) 0=VGA 1=ET4000 2=S3(untested)',cr,lf
+ db ' /ALF n (MaxLineFreq) default=0',cr,lf
+ db ' /ILF n (MinLineFreq) default=28',cr,lf
+ db ' /AR n (MaxRefresh) default=70',cr,lf
+ db ' /IR n (MinRefresh) default=60',cr,lf
+ db ' /AL n (MaxLines) default=480',cr,lf
+ db ' /IL n (MinLines) default=300',cr,lf
+ db ' /E (Enable)',cr,lf
+ db ' /D (Disable)',cr,lf
+ db ' /P (Probe for PixelClocks)',cr,lf
+ db 'ex: VGA600 /V1 /ALF72 /AL1023 /AR90',cr,lf,'$'
n_i db 'VGA600 is not installed!',cr,lf,'$'
n_u db 'VGA600 is not unloadable!',cr,lf,'$'
m_e db 'Mem allocating error!',cr,lf,'$'
1
0
Author: michael
Date: Fri Jul 6 00:55:01 2007
New Revision: 71
Log:
version from 1997-02-18 01:41
Modified:
trunk/vga600/vga600.asm
Modified: trunk/vga600/vga600.asm
==============================================================================
--- trunk/vga600/vga600.asm (original)
+++ trunk/vga600/vga600.asm Fri Jul 6 00:55:01 2007
@@ -1,6 +1,6 @@
-;350 text ???VDEE =57h
+;350 text ???VDE =57h
-;VGA600 ver 0.5 Copyright (C) Michael Niedermayer 1997
+;VGA600 ver 0.6 Beta Copyright (C) Michael Niedermayer 1997
;history:
; 0.1 initial ver (never released)
@@ -23,153 +23,310 @@ SC_INDEX equ 03c4h
CRTC_INDEX equ 03d4h
MISC_OUTPUT equ 03c2h
MISC_INPUT equ 03cch
+Attrib_INDEX equ 03c0h
+Grafix_INDEX equ 03ceh
patch_size equ patch_code_end-patch_code
delay equ 6
delay2 equ 12
+FPx equ 12
+FPx_1 equ 1 shl FPx
segment code
org 100h
assume cs:code, ds:code, es:code, ss:code
start:
-jmp install
+jmp install ;jmp to install code
-mcb_name db 'VGA600 '
+mcb_name db 'VGA600 ' ;ends up in mcb if it works
int10h:
- cmp ax,020FFh
+ cmp ax,020FFh ;check for allredy installed call
jne exit_10
mov ax,00600h
- mov bx,cs
- iret
+ mov bx,cs ;bx=cs of TSR
+ iret ;get out
exit_10:
push ax
- cmp ax,04F02h
+ cmp ax,04F02h ;check for VESA ModeSet
je mode_set
- test ah,ah
- jnz no_mode_set ;only mode set
+ test ah,ah ;check for Standart ModeSet
+ jnz no_mode_set ;only mode set
and al,7Fh
- cmp al,013h
- je x_mode_set ;only 320x200 (x-modes)
+ cmp al,013h ;check for 320x200x256
+ je x_mode_set ;only 320x200 (x-modes)
mode_set:
- mov [BYTE cs:temp-int10h],1
+ mov [BYTE cs:temp-int10h],1 ;set call_CheckSet_flag
x_mode_set:
- mov [BYTE cs:counter-int10h],delay or 11000000b
+ mov [BYTE cs:counter-int10h],delay or 11000000b ;set delay but disable int 8
no_mode_set:
pop ax
- pushf
+ pushf ;call orginal int 10h
db 09Ah
old_int10h dd 0
pushf
- shr [BYTE cs:temp-int10h],1
- jnc no_check_set
- call check_set
-no_check_set:
- and [BYTE cs:counter-int10h],00111111b
+ shr [BYTE cs:temp-int10h],1 ;check call_CheckSet_flag
+ jnc no_CheckSet
+ call CheckSet
+no_CheckSet:
+ and [BYTE cs:counter-int10h],00111111b ;reaktivate int 8
popf
retf 2
int8h:
- dec [BYTE cs:counter-int10h]
- jns decr
- inc [BYTE cs:counter-int10h]
-decr:
- jnz exit_8
- mov [BYTE cs:counter-int10h],delay2
+ dec [BYTE cs:counter-int10h] ;dec counter
+ jns decr
+ inc [BYTE cs:counter-int10h] ;inc counter if negative
+decr: ;if(X>0) X1=X-1 if(X<1) X1=X if(X=8000h) X1=7FFFh
+ jnz exit_8 ;get out if not zero
+ mov [BYTE cs:counter-int10h],delay2 ;set new counter
- call check_set
+; call CheckSet
-exit_8:
+exit_8: ;jmp to old int 8
db 0eah
old_int8h dd 0
-check_set:
+CheckSet:
+int 3
pusha
push ds
+push es
push cs
pop ds
- mov dx,CRTC_INDEX
- mov al,9
+ push cs
+ pop es
+ cld
+
+ mov si,offset(where)-offset(int10h) ;Read and convert Vga-Regs
+ mov di,offset(what)-offset(int10h)
+ mov bx,offset(OF2Real_code)-offset(int10h)
+
+ mov dx,SC_INDEX
+ mov al,1
out dx,al
inc dx
- in al,dx
- dec dx
- and al,11100111b ;TEXT (25/50)
- mov cl,al
- jns no_cga
- mov ah,al
- add al,al ;shl al,1
- inc ax
- and ax,0110000000011111b
- or al,ah
-no_cga:
- xchg ax,bx ;bl=al
- mov al,12h
+ in al,dx ;get SCM
+ stosb ;save SCM
+ mov cx,9
+ test al,1
+ jz chr_9
+ dec cx
+chr_9:
+ xchg ax,cx
+ stosw ;save chr_clock
+
+ mov dl,low(Grafix_INDEX) ;dh=3!
+ mov al,6
out dx,al
inc dx
+ in al,dx ;get GM
+ stosb ;save Grafix Misc(text/grafix)
+
+ mov dl,low(MISC_INPUT) ;dh=3!
in al,dx
- dec dx
- mov bh,al
- mov ch,al
+ stosb ;save Misc-reg
- cld
- mov si,offset(CRTParms)-int10h-9
-check_loop:
- add si,9
- lodsw
+get_regs:
+ mov dl,low(CRTC_INDEX) ;!dh=3
+ lodsb ;read index from table1
+ test al,al ;check for sign bit
+ js end_get_regs ;get out is set
+ out dx,al ;set index
+ inc dx ;dx= data_port
+ in al,dx ;get data
+ push ax ;save date
+ lodsw ;get jmp_table_entry and inc si
+ cbw ;convert it to word
+ add bx,ax ;and add it to the last one
+ pop ax ;restore data
+ mov cl,1 ;cl=1 (needed for some codes)
+ mov ah,0
+ call bx ;call it
+ stosw ;!ah=0 /write data to table2
+jmp get_regs
+end_get_regs:
+
+ mov ax,[HT-int10h] ;check horizontal coherenzy
+ cmp ax,[FP8_1-int10h] ;check HT<256 (causes div error)
+ jnb Not2_End_CheckSet
+End2_Checkset:
+ jmp End_CheckSet
+Not2_End_CheckSet:
+ mov bx,[HBS-int10h]
cmp ax,bx
- je patch
- test ax,ax
-jnz check_loop
+ jb End2_Checkset
+ mov bx,[HSS-int10h]
+ cmp ax,bx
+ jb End2_CheckSet
+ mov ax,[HDE-int10h]
+ cmp bx,ax
+ jb End2_CheckSet
+
+ mov ax,[VT-int10h] ;check vertical coherenzy
+ mov bx,[VBS-int10h]
+ cmp ax,bx
+ jb End2_CheckSet
+ mov bx,[VSS-int10h]
+ cmp ax,bx
+ jb End2_CheckSet
+ mov ax,[VDE-int10h]
+ cmp bx,ax
+ jb End2_CheckSet
- mov si,offset(TextParms)-int10h-7
-check_loop2:
- add si,9
- lodsw
- cmp ax,cx
-nopi:
- je patch2
- test ax,ax
-jnz check_loop2
-pop ds
-popa
+ cmp ax,[max_line-int10h] ;check num_lines (300-1000)
+ ja End2_CheckSet
+ cmp ax,[min_line-int10h]
+ jb End2_CheckSet
+
+ mov al,[MSL-int10h]
+ mov bl,10011111b
+ test [BYTE gm-int10h],1 ;test if text
+ jnz no_text
+ mov bl,10000000b
+no_text:
+ and al,bl
+ jns no_cgax2 ;test if cga like mode
+ mov al,1
+no_cgax2:
+ and al,00011111b
+ inc ax
+ cbw
+ stosb ;save lm
+
+ mov bx,[VDE-int10h] ;get phys-lines
+ xchg ax,bx ;ax=phys-line / bx=line_mult
+ cwd
+ div bx ;find logical_lines
+ stosw ;save ll
+ xchg ax,di ;di=logi-line / bx=line_mult
+ mov cx,-1 ;cx=-1 (best_clock_index)
+
+FindBest:
+ inc bx ; inc line_mult
+ js End_FindBest ; just in case VDE is very strange
+ cmp bl,3 ;check line_mult<3
+ jb n3
+ test [BYTE gm-int10h],1 ;test if text
+ jz End_FindBest ;get out if more then *3 + TEXT
+n3:
+ mov ax,bx
+ call FindSet_V ;find and set Vertical nums
+ cmp si,[max_line-int10h]
+ ja End_FindBest ; get out if toooo much
+
+ mov si,FP8_ClockTable-int10h ;si=pointer to clock_table
+ xor bp,bp ;bp=best_clock (=0)
+
+FindBestClock:
+ mov ax,[WORD si] ;get clock
+ mul [WORD FP8_1-int10h] ;for more precision
+ div [WORD HT-int10h] ;find line_freq HT MUST >256
+ cmp ax,[FP8_min_LineFreq] ;check if < min_LineFreq
+ jb End_FindBestClock
+ cmp ax,[FP8_max_LineFreq] ;check if > max_LineFreq
+ ja End_FindBestClock
+ mul [WORD FP8_1-int10h] ;for more precision
+ div [WORD VT-int10h] ;find refresh_freq VT>256
+ cmp ax,[FP8_min_refresh] ;check if < min_refresh
+ jb End_FindBestClock
+ cmp ax,[FP8_max_refresh] ;check if > max_refresh
+ ja End_FindBestClock
+ cmp ax,bp ;check if better than best
+ jb End_FindBestClock
+ mov bp,ax ;if yes save as best
+ mov cx,si ;cx=si
+ sub cx,offset(FP8_ClockTable-int10h) ;get BYTE FP8_ClockTable[cx]
+ shr cx,1 ;get WORD FP8_ClockTable[cx]
+End_FindBestClock:
+ inc si
+ inc si ;inc clock_pointer
+ cmp si,offset(FP8_ClockTable_end-int10h) ;check if all clocks where tested
+ jb FindBestClock
+ test bp,bp ;check if nothing found
+ jz FindBest_nothing
+ or ch,bl ;ch=line_mult cl=Clock_index
+FindBest_nothing:
+ jmp FindBest
+End_FindBest:
+
+ test cx,cx ;get out if nothing found
+ jns Not_End_CheckSet
+End_CheckSet:
+ pop es
+ pop ds
+ popa
ret
+Not_End_CheckSet:
+ mov al,ch ;set ax= best line_mult
+ cbw
+ call FindSet_V ;set Vertical Nums (in mem)
-patch2:
- dec si
- dec si
-patch:
+ mov bx, 0000000001111111b ;set and/or start masks
+ test [BYTE gm-int10h],1 ;test if text
+ jnz no_text2
+ cmp cl,2 ;check if *2 & text
+ jne end_SetMSL
+ mov bh,10000000b ;set cga like doubling
+ jmp end_SetMSL ;and get out
+no_text2:
+ mov bl,cl ;set and-mask
+ mov bh,cl ;set or-mask
+ or bl,01100000b ;correct and-mask
+ and bh,00011111b ;correct or-mask (xor bx,xxx...!!! limit line_mult)
+end_SetMSL:
+ and [MSL-int10h],bl
+ or [MSL-int10h],bh ;set MSL
+
+ mov ch,0 ;ch=0 (we no longer need line_mult)
+ push cx ;save Clock_index
+
+ mov dx,CRTC_INDEX
mov al,11h
- out dx,al
+ out dx,al
inc dx
- in al,dx
- and al,7fh
- out dx,al
+ in al,dx ;read VSE
+ and al,7fh ;remove write protect bit
+ out dx,al ;write VSE
dec dx
- mov cx,8
-SetCRT:
- lodsb
- mov ah,al
- mov bx,cx
- mov al,[bx+where-int10h-1]
- cmp al,9 ;MSL (GRRR TEXT 50lines)
- jne no_texti
- out dx,al
- inc dx
- in al,dx
- dec dx
- and al,00001000b
- or ah,al
- mov al,9
-no_texti:
- out dx,ax
- loop SetCRT
- lodsb
+ mov si,offset(where_V)-offset(int10h) ;Read and convert Vga-Regs
+ mov di,offset(what_V)-offset(int10h)
+ mov bx,offset(Real2HSE_code)-offset(int10h)
+
+set_regs:
+ lodsb ;read index from table1
+ test al,al ;check for sign bit
+ js end_set_regs ;get out is set
+ out dx,al ;set index
+ inc dx ;dx= data_port
+ inc si ;skip xxx2real_code
+ lodsb ;get jmp_table_entry
+ cbw ;convert it to word
+ add bx,ax ;and add it to the last one
+ in al,dx ;read (only VSE needs that now)
+ mov ch,al ;put into ch
+ mov ax,[di] ;get data
+ inc di ;add di,2
+ inc di
+ mov cl,1 ;cl=1 (needed for some codes)
+ call bx ;call it
+ out dx,al ;set data
+ dec dx ;dx=data_port
+jmp set_regs
+end_set_regs:
+
+ mov al,7
+ mov ah,[OF-int10h]
+ out dx,ax ;write OF
+
+
+ pop ax
+ push offset(End_CheckSet-int10h) ; for return later
patch_code2:
xchg ax,bx
mov ah,bl ;ah=bl=clock
shl ah,2
- mov dl,LOW(MISC_INPUT) ;dh=3!
+ mov dl,LOW(MISC_INPUT) ;dh=3! dont read from mem (clock_probing)
in al,dx ;al=MiscOutput
mov dl,LOW(MISC_OUTPUT) ;dh=3!
patch_code:
@@ -228,143 +385,211 @@ et4000_clock:
in al,dx
out dx,al ;ET4000 SUCKs
-pop ds
-popa
ret
patch_code_end:
where:
- db 016h ;VBE
- db 015h ;VBS
- db 011h ;VSE / Protect
- db 010h ;VSS
db 007h ;OF
+ db offset(OF2Real_code)-offset(OF2Real_code)
+ db offset(Real2OF_code)-offset(Real2OF_code)
+ db 000h ;HT
+ db offset(HT2Real_code)-offset(OF2Real_code)
+ db offset(Real2HT_code)-offset(Real2OF_code)
+ db 001h ;HDE
+ db offset(HDE2Real_code)-offset(HT2Real_code)
+ db offset(Real2HDE_code)-offset(Real2HT_code)
+ db 002h ;HBS
+ db offset(HBS2Real_code)-offset(HDE2Real_code)
+ db offset(Real2HBS_code)-offset(Real2HDE_code)
+ db 003h ;HBE
+ db offset(HBE2Real_code)-offset(HBS2Real_code)
+ db offset(Real2HBE_code)-offset(Real2HBS_code)
+ db 004h ;HSS
+ db offset(HSS2Real_code)-offset(HBE2Real_code)
+ db offset(Real2HSS_code)-offset(Real2HBE_code)
+ db 005h ;HSE
+ db offset(HSE2Real_code)-offset(HSS2Real_code)
+ db offset(Real2HSE_code)-offset(Real2HSS_code)
+where_V:
db 006h ;VT
- db 012h ;VDEE
+ db offset(VT2Real_code)-offset(HSE2Real_code)
+ db offset(Real2VT_code)-offset(Real2HSE_code)
db 009h ;MSL
+ db offset(MSL2Real_code)-offset(VT2Real_code)
+ db offset(Real2MSL_code)-offset(Real2VT_code)
+ db 010h ;VSS
+ db offset(VSS2Real_code)-offset(MSL2Real_code)
+ db offset(Real2VSS_code)-offset(Real2MSL_code)
+ db 011h ;VSE / Protect
+ db offset(VSE2Real_code)-offset(VSS2Real_code)
+ db offset(Real2VSE_code)-offset(Real2VSS_code)
+ db 012h ;VDE
+ db offset(VDE2Real_code)-offset(VSE2Real_code)
+ db offset(Real2VDE_code)-offset(Real2VSE_code)
+ db 015h ;VBS
+ db offset(VBS2Real_code)-offset(VDE2Real_code)
+ db offset(Real2VBS_code)-offset(Real2VDE_code)
+ db 016h ;VBE
+ db offset(VBE2Real_code)-offset(VBS2Real_code)
+ db offset(Real2VBE_code)-offset(Real2VBS_code)
+ db 0FFh ;end-marker
+what:
+SCM db ?
+CHR_Clock dw ?
+GM db ?
+MR db ?
+OF dw ?
+HT dw ?
+HDE dw ?
+HBS dw ?
+HBE dw ?
+HSS dw ?
+HSE dw ?
+what_V:
+VT dw ?
+MSL dw ?
+VSS dw ?
+VSE dw ?
+VDE dw ?
+VBS dw ?
+VBE dw ?
+LM db ?
+LL dw ?
-CRTParms:
-d1 db 041h ;MSL=41 (?x200 double->triple)
- db 08fh ;VDEE=399
- db 062h ;MSL
- db 057h ;VDEE
- db 087h ;VT
- db 0f0h ;OF
- db 064h ;VSS
- db 086h ;VSE / Protect
- db 05eh ;VBS
- db 079h ;VBE
-c1 db 01h ;Clock=1
+HT2Real_code:
+ add ax,4
+HDE2Real_code:
+ inc ax
+HBS2Real_code:
+HSS2Real_code:
+ mov cl,[chr_clock-int10h]
+ mul cl
+HBE2Real_code: ;IGNORE FOR NOW
+HSE2Real_code: ;IGNORE FOR NOW
+OF2Real_code: ;OK
+MSL2Real_code: ;OK
+VSE2Real_code: ;OK/NEVER USED
+VBE2Real_code: ;OK/NEVER USED (?REAL OK)
+ret
-d2 db 041h ;MSL=41 (?x200 double->quad)
- db 08fh ;VDEE=399
- db 063h ;MSL
- db 01fh ;VDEE
- db 04fh ;VT
- db 0ffh ;OF
- db 02Ch ;VSS
- db 08eh ;VSE / Protect
- db 026h ;VBS
- db 03fh ;VBE
-c2 db 01h ;Clock=1
+VSS2Real_code:
+ inc cx
+VDE2Real_code:
+ inc cx
+VT2Real_code: ;cl must be 1
+ mov ah,[BYTE OF-int10h]
+ shr ah,cl
+ pushf
+ shr ah,4
+ popf
+ rcl ah,1
+ and ah,00000011b
+ inc ax
+ret
-d3 db 041h ;MSL=41 (?x240 double->triple)
- db 0dfh ;VDEE=479
- db 062h ;MSL
- db 0cfh ;VDEE
- db 0ffh ;VT
- db 0f0h ;OF
- db 0dch ;VSS
- db 08eh ;VSE / Protect
- db 0d6h ;VBS
- db 0efh ;VBE
-c3 db 01h ;Clock=1
+VBS2Real_code:
+ mov ah,[BYTE OF-int10h]
+ mov ch,[BYTE MSL-int10h]
+ shr ah,3
+ shr ch,4
+ and ah,00000001b
+ and ch,00000010b
+ or ah,ch
+;inc ax ;??
+ret
-d4 db 041h ;MSL=41 (?x240 double->quad)
- db 0dfh ;VDEE=479
- db 063h ;MSL
- db 0bfh ;VDEE
- db 0efh ;VT
- db 0ffh ;OF
- db 0cch ;VSS
- db 08eh ;VSE / Protect
- db 0c6h ;VBS
- db 0dfh ;VBE
-c4 db 01h ;Clock=1
-
-d5 db 040h ;MSL=40 (?x350 single->double)
- db 05dh ;VDEE=349
- db 061h ;MSL
- db 0bbh ;VDEE
- db 0ebh ;VT
- db 0f0h ;OF
- db 0c8h ;VSS
- db 08ah ;VSE / Protect
- db 0c2h ;VBS
- db 0d6h ;VBE
-c5 db 01h ;Clock=1
+Real2HT_code:
+ sub ax,32
+Real2HDE_code:
+ sub ax,8
+Real2HBS_code:
+Real2HSS_code:
+ mov cl,[chr_clock-int10h]
+ div cl
+Real2HBE_code: ;IGNORE FOR NOW
+Real2HSE_code: ;IGNORE FOR NOW
+Real2OF_code: ;OK/NEVER_Called
+Real2MSL_code: ;OK
+Real2VBE_code: ;OK
+ret
-d6 db 040h ;MSL=41 (?x400 single->double)
- db 08fh ;VDEE=399
- db 061h ;MSL
- db 01fh ;VDEE
- db 04fh ;VT
- db 0ffh ;OF
- db 02Ch ;VSS
- db 08eh ;VSE / Protect
- db 026h ;VBS
- db 03fh ;VBE
-c6 db 01h ;Clock=1
-
-d7 db 040h ;MSL=40 (?x480 single->double)
- db 0dfh ;VDEE=479
- db 061h ;MSL
- db 0bfh ;VDEE
- db 0efh ;VT
- db 0ffh ;OF
- db 0cch ;VSS
- db 08eh ;VSE / Protect
- db 0c6h ;VBS
- db 0dfh ;VBE
-c7 db 01h ;Clock=1
-TextParms:
-d8 db 047h ;MSL=40 TEXT (?x350 single->double)
- db 05dh ;VDEE=349
- db 0e7h ;MSL
- db 0bbh ;VDEE
- db 0ebh ;VT
- db 0f0h ;OF
- db 0c8h ;VSS
- db 08ah ;VSE / Protect
- db 0c2h ;VBS
- db 0d6h ;VBE
-c8 db 01h ;Clock=1
+Real2VSE_code:
+and al,00001111b ;only 0-3 are used
+and ch,01110000b ;preserve 4-6
+or ch,10000000b ;set write-protect-bit
+or al,ch
+ret
-d9 db 047h ;MSL=47 TEXT (?x400 single->double)
- db 08fh ;VDEE=399
- db 0e7h ;MSL
- db 01fh ;VDEE
- db 04fh ;VT
- db 0ffh ;OF
- db 02Ch ;VSS
- db 08eh ;VSE / Protect
- db 026h ;VBS
- db 03fh ;VBE
-c9 db 01h ;Clock=1
+Real2VSS_code:
+ inc cx
+Real2VDE_code:
+ inc cx
+Real2VT_code: ;cl must be 1
+ dec ax
+ shr ah,1
+ pushf
+ shl ah,4
+ popf
+ rcl ah,cl
+ or [BYTE of-int10h],ah
+ret
-da db 047h ;MSL=47 TEXT (?x480 single->double)
- db 0dfh ;VDEE=479
- db 0e7h ;MSL
- db 0bfh ;VDEE
- db 0efh ;VT
- db 0ffh ;OF
- db 0cch ;VSS
- db 08eh ;VSE / Protect
- db 0c6h ;VBS
- db 0dfh ;VBE
-ca db 01h ;Clock=1
+Real2VBS_code:
+ shl ah,3
+ mov ch,ah
+ and ah,00001000b
+ or [BYTE OF-int10h],ah
+ shl ch,1
+ and ch,00100000b
+ or [BYTE MSL-int10h],ch
+ret
-end_pos dd 0
+FindSet_V:
+ mul di ; find new phys_lines
+ mov [VDE-int10h],ax ; save(phys_lines) as new
+ mov si,ax ; save(phys_lines) in si
+ push ax ; save(phys_lines) to stack
+ mul [WORD FPx_1p5-int10h] ; find 1.5%
+ div [WORD FPx_1_-int10h] ;could be replaced by shrd
+ mov bp,ax ; save 1.5% in bp
+ add si,ax ; add to old phys
+ mov [VBS-int10h],si ; save in VBS
+ inc si ; inc it
+ mov [VSS-int10h],si ; save in VSS
+ pop ax
+ push ax ;get old phys from stack
+ mul [WORD FPx_VS-int10h] ; find VS-lenght
+ div [WORD FPx_1_-int10h] ;could be replaced by shrd
+ add si,ax ;add it
+ mov [VSE-int10h],si ; save in VSE
+ pop ax ;get old phys from stack
+ mul [WORD FPx_VB-int10h] ; find VB-lenght
+ div [WORD FPx_1_-int10h] ;could be replaced by shrd
+ add si,ax ;add it
+ mov [VBE-int10h],si ; save in VBE
+ add si,bp ;add 1.5%
+ mov [VT-int10h],si ; save in VT
+ret
+
+
+FP8_1 dw 256
+FP8_min_refresh dw 60 shl 8
+FP8_max_refresh dw 90 shl 8
+FP8_min_LineFreq dw 28 shl 8
+FP8_max_LineFreq dw 72 shl 8
+
+FP8_ClockTable dw 32 dup (?)
+FP8_ClockTable_end:
+
+FPx_1_ dw FPx_1
+
+FPx_1p5 dw FPx_1/67 ;1/.015=67
+FPx_VS dw FPx_1/200 ;1/.005=200
+FPx_VB dw FPx_1/14 ;1/.070=14 !!!(inacurate)
+
+clock_d db 0
+max_line dw 1023
+min_line dw 300
counter db delay2
temp db 0
@@ -386,11 +611,6 @@ install:
commands:
lodsb
- cmp al,'\'
- jne check_ok
- mov [WORD nopi],09090h
- mov al,'/'
-check_ok:
cmp al,'/'
loopne commands
je nunk_command
@@ -410,13 +630,13 @@ nunload:
cmp al,'e'
jne nenable
- mov [BYTE check_set],060h
+ mov [BYTE CheckSet],060h
jmp enable_disable
nenable:
cmp al,'d'
jne ndisable
- mov [BYTE check_set],0C3h
+ mov [BYTE CheckSet],0C3h
jmp enable_disable
ndisable:
@@ -428,49 +648,11 @@ ndisable:
mov ah,0
xchg ax,bx
add bx,bx ;shl bx,1
- add bx,offset(code_table)
- mov si,[bx]
+ mov si,[WORD bx+code_table]
mov di,offset(patch_code)
mov cx,patch_size
rep movsb ;copy clock_code
pop si
- mov di,offset CRTParms
-next_parm:
- xor bx,bx
- mov dl,10
- mov cx,3
- inc si
-loop_dez:
- lodsb
- cmp al,' '
- je no_num
- cmp al,0dh
- je no_num
- cmp al,'-'
- je no_num2
- sub al,30h
- jnb nunk_command2
-probe2:
- jmp probe
-unk_command2:
- jmp unk_command
-nunk_command2:
- cmp al,9h
- ja probe2
- xchg ax,bx
- mul dl
- xchg ax,bx
- add bl,al
- loop loop_dez
-no_num2:
- inc si
- mov [WORD di],-1
-no_num:
- dec si
- mov [di+10],bl
- add di,11
- cmp [WORD di],0
-jne next_parm
call chk_600
jne nalready_installed
@@ -481,13 +663,7 @@ jne next_parm
mov di,offset(patch_code)-int10h
mov si,offset(patch_code)
mov cx,patch_size
- rep movsb
- mov di,offset(CRTParms)-int10h
- mov si,offset(CRTParms)
- mov cx,offset(end_pos)-offset(CRTParms)
- rep movsb
- mov ax,[offset(nopi)]
- mov [es:nopi-int10h],ax
+ rep movsb ;Update TSR Variables
int 20h
enable_disable:
@@ -498,8 +674,8 @@ nnot_inst:
mov dx,offset(p_a)
call wstring
mov es,bx
- mov al,[offset(check_set)]
- mov [es:check_set-int10h],al
+ mov al,[offset(CheckSet)]
+ mov [es:CheckSet-int10h],al
int 20h
nalready_installed:
@@ -665,7 +841,7 @@ nprobeerror:
int 21h ;set new int 8
xor di,di
- mov si,offset clock_buf
+ mov si,offset FP8_ClockTable
probe_loop:
mov ax,di
@@ -697,7 +873,7 @@ end1:
mov ax,0003h
int 10h
- mov si,offset clock_buf
+ mov si,offset FP8_ClockTable
mov cx,32
print_loop:
@@ -789,8 +965,6 @@ vga_clock:
and ax,0000110011110011b
or al,ah
out dx,al ;0-1
-pop ds
-popa
ret
s3_clock:
@@ -819,43 +993,32 @@ s3_clock:
and bl,00001111b
or al,bl
out dx,al
-
- pop ds
- popa
ret
alt_vga_clock:
and ax,0001110011100011b
or al,ah
out dx,al ;0-2
- pop ds
- popa
ret
int8_counter dw 0
-clock_buf db 32 dup (0)
-
code_table:
dw offset(vga_clock)
dw offset(et4000_clock)
dw offset(s3_clock)
dw offset(alt_vga_clock)
-c_r db 'VGA600 ver 0.5 Copyright (C) Michael Niedermayer 1997',cr,lf,'$'
-u_c db 'VGA600 (/|\)vga_card c1 c2 c3 c4 c5 c6 c7 c8 c9 ca|/U|/E|/D',cr,lf
+c_r db 'VGA600 ver 0.6 Beta Copyright (C) Michael Niedermayer 1997',cr,lf,'$'
+u_c db 'VGA600 /vga_card <options>|/U|/E|/D',cr,lf
db ' vga_card: 0=VGA 1=ET4000 2=S3(untested)',cr,lf
- db ' c1: G ?x200(400)->(600) DOT-clock | - if disabled',cr,lf
- db ' c2: G ?x200(400)->(800) DOT-clock | - if disabled',cr,lf
- db ' c3: G ?x240(480)->(720) DOT-clock | - if disabled',cr,lf
- db ' c4: G ?x240(480)->(960) DOT-clock | - if disabled',cr,lf
- db ' c5: G ?x350(350)->(700) DOT-clock | - if disabled',cr,lf
- db ' c6: G ?x400(400)->(800) DOT-clock | - if disabled',cr,lf
- db ' c7: G ?x480(480)->(960) DOT-clock | - if disabled',cr,lf
- db ' c8: T ?x350(350)->(700) DOT-clock | - if disabled',cr,lf
- db ' c9: T ?x400(400)->(800) DOT-clock | - if disabled',cr,lf
- db ' ca: T ?x480(480)->(960) DOT-clock | - if disabled',cr,lf
- db 'ex: VGA600 /1 2 - 4 - 5 6 6 - - -',cr,lf,'$'
+ db ' options: /ALF=x (Max_LineFreq) default=0',cr,lf
+ db ' /ILF=x (Min_LineFreq) default=28',cr,lf
+ db ' /AR=x (Max_Refresh) default=70',cr,lf
+ db ' /IR=x (Min_Refresh) default=60',cr,lf
+ db ' /AL=x (Max_Lines) default=480',cr,lf
+ db ' /IL=x (Min_Lines) default=300',cr,lf
+ db 'ex: VGA600 /1 /ALF=72 /AL=1023 /AR=90',cr,lf,'$'
n_i db 'VGA600 is not installed!',cr,lf,'$'
n_u db 'VGA600 is not unloadable!',cr,lf,'$'
m_e db 'Mem allocating error!',cr,lf,'$'
1
0
Author: michael
Date: Fri Jul 6 00:49:43 2007
New Revision: 70
Log:
vga600 program from 1997-02-10 17:02 (this is the oldest version i found in my mess)
Added:
trunk/vga600/
trunk/vga600/vga600.asm
Added: trunk/vga600/vga600.asm
==============================================================================
--- (empty file)
+++ trunk/vga600/vga600.asm Fri Jul 6 00:49:43 2007
@@ -0,0 +1,869 @@
+;350 text ???VDEE =57h
+
+;VGA600 ver 0.5 Copyright (C) Michael Niedermayer 1997
+
+;history:
+; 0.1 initial ver (never released)
+; 0.2 added 240-line modes and ET4000-clock (never released)
+; 0.3 added 350/400-line modes and S3-clock(untested) (never released)
+; 0.4 added more inteligent activation (never released)
+; 0.5 added clock probeing
+; et4000 clock divide /2 /4
+; mode recorrection WINDOZE 95 SUCKS
+; Loader rewriten
+ideal
+P286
+
+cr equ 0ah
+lf equ 0dh
+paras equ (end10h-int10h)/16+1
+paras_all equ (end_all-start+100h)/16+1
+words equ (end10h-int10h)/2+5
+SC_INDEX equ 03c4h
+CRTC_INDEX equ 03d4h
+MISC_OUTPUT equ 03c2h
+MISC_INPUT equ 03cch
+patch_size equ patch_code_end-patch_code
+delay equ 6
+delay2 equ 12
+
+segment code
+org 100h
+assume cs:code, ds:code, es:code, ss:code
+
+start:
+jmp install
+
+mcb_name db 'VGA600 '
+int10h:
+ cmp ax,020FFh
+ jne exit_10
+ mov ax,00600h
+ mov bx,cs
+ iret
+exit_10:
+ push ax
+ cmp ax,04F02h
+ je mode_set
+ test ah,ah
+ jnz no_mode_set ;only mode set
+ and al,7Fh
+ cmp al,013h
+ je x_mode_set ;only 320x200 (x-modes)
+mode_set:
+ mov [BYTE cs:temp-int10h],1
+x_mode_set:
+ mov [BYTE cs:counter-int10h],delay or 11000000b
+no_mode_set:
+ pop ax
+ pushf
+ db 09Ah
+old_int10h dd 0
+ pushf
+ shr [BYTE cs:temp-int10h],1
+ jnc no_check_set
+ call check_set
+no_check_set:
+ and [BYTE cs:counter-int10h],00111111b
+ popf
+retf 2
+
+int8h:
+ dec [BYTE cs:counter-int10h]
+ jns decr
+ inc [BYTE cs:counter-int10h]
+decr:
+ jnz exit_8
+ mov [BYTE cs:counter-int10h],delay2
+
+ call check_set
+
+exit_8:
+db 0eah
+old_int8h dd 0
+
+check_set:
+pusha
+push ds
+ push cs
+ pop ds
+ mov dx,CRTC_INDEX
+ mov al,9
+ out dx,al
+ inc dx
+ in al,dx
+ dec dx
+ and al,11100111b ;TEXT (25/50)
+ mov cl,al
+ jns no_cga
+ mov ah,al
+ add al,al ;shl al,1
+ inc ax
+ and ax,0110000000011111b
+ or al,ah
+no_cga:
+ xchg ax,bx ;bl=al
+ mov al,12h
+ out dx,al
+ inc dx
+ in al,dx
+ dec dx
+ mov bh,al
+ mov ch,al
+
+ cld
+ mov si,offset(CRTParms)-int10h-9
+check_loop:
+ add si,9
+ lodsw
+ cmp ax,bx
+ je patch
+ test ax,ax
+jnz check_loop
+
+ mov si,offset(TextParms)-int10h-7
+check_loop2:
+ add si,9
+ lodsw
+ cmp ax,cx
+nopi:
+ je patch2
+ test ax,ax
+jnz check_loop2
+pop ds
+popa
+ret
+
+patch2:
+ dec si
+ dec si
+patch:
+ mov al,11h
+ out dx,al
+ inc dx
+ in al,dx
+ and al,7fh
+ out dx,al
+ dec dx
+ mov cx,8
+SetCRT:
+ lodsb
+ mov ah,al
+ mov bx,cx
+ mov al,[bx+where-int10h-1]
+ cmp al,9 ;MSL (GRRR TEXT 50lines)
+ jne no_texti
+ out dx,al
+ inc dx
+ in al,dx
+ dec dx
+ and al,00001000b
+ or ah,al
+ mov al,9
+no_texti:
+ out dx,ax
+ loop SetCRT
+
+ lodsb
+patch_code2:
+ xchg ax,bx
+ mov ah,bl ;ah=bl=clock
+ shl ah,2
+ mov dl,LOW(MISC_INPUT) ;dh=3!
+ in al,dx ;al=MiscOutput
+ mov dl,LOW(MISC_OUTPUT) ;dh=3!
+patch_code:
+et4000_clock:
+ and ax,0000110011110011b
+ or al,ah
+ out dx,al ;0-1
+
+ mov dl,0bfh ;!dh=3
+ mov al,3
+ out dx,al
+ mov dl,0d8h ;!dh=3
+ mov al,0a0h
+ out dx,al ;enable ET4000 ext.
+
+ mov dl,LOW(CRTC_INDEX) ;!dh=3
+ mov al,34h
+ out dx,al
+ inc dx
+ in al,dx
+ mov ah,bl
+ shr ah,1
+ and ax,0000001011111101b
+ or al,ah
+ out dx,al ;2
+
+ dec dx
+ mov al,31h
+ out dx,al
+ inc dx
+ in al,dx
+ mov ah,bl
+ shl ah,3
+ and ax,1100000000111111b
+ or al,ah
+ out dx,al ;3-4
+
+ mov dl,LOW(SC_INDEX)
+ mov al,7h
+ out dx,al
+ inc dx
+ in al,dx
+ mov bh,bl
+ and bx,0100000000100000b
+ shl bl,1
+ shr bh,6
+ or bl,bh
+ and al,10111110b
+ or al,bl
+ out dx,al ;5/6 *double/quad*
+
+ dec dx
+ mov al,6h
+ out dx,al
+ inc dx
+ in al,dx
+ out dx,al ;ET4000 SUCKs
+
+pop ds
+popa
+ret
+patch_code_end:
+
+where:
+ db 016h ;VBE
+ db 015h ;VBS
+ db 011h ;VSE / Protect
+ db 010h ;VSS
+ db 007h ;OF
+ db 006h ;VT
+ db 012h ;VDEE
+ db 009h ;MSL
+
+CRTParms:
+d1 db 041h ;MSL=41 (?x200 double->triple)
+ db 08fh ;VDEE=399
+ db 062h ;MSL
+ db 057h ;VDEE
+ db 087h ;VT
+ db 0f0h ;OF
+ db 064h ;VSS
+ db 086h ;VSE / Protect
+ db 05eh ;VBS
+ db 079h ;VBE
+c1 db 01h ;Clock=1
+
+d2 db 041h ;MSL=41 (?x200 double->quad)
+ db 08fh ;VDEE=399
+ db 063h ;MSL
+ db 01fh ;VDEE
+ db 04fh ;VT
+ db 0ffh ;OF
+ db 02Ch ;VSS
+ db 08eh ;VSE / Protect
+ db 026h ;VBS
+ db 03fh ;VBE
+c2 db 01h ;Clock=1
+
+d3 db 041h ;MSL=41 (?x240 double->triple)
+ db 0dfh ;VDEE=479
+ db 062h ;MSL
+ db 0cfh ;VDEE
+ db 0ffh ;VT
+ db 0f0h ;OF
+ db 0dch ;VSS
+ db 08eh ;VSE / Protect
+ db 0d6h ;VBS
+ db 0efh ;VBE
+c3 db 01h ;Clock=1
+
+d4 db 041h ;MSL=41 (?x240 double->quad)
+ db 0dfh ;VDEE=479
+ db 063h ;MSL
+ db 0bfh ;VDEE
+ db 0efh ;VT
+ db 0ffh ;OF
+ db 0cch ;VSS
+ db 08eh ;VSE / Protect
+ db 0c6h ;VBS
+ db 0dfh ;VBE
+c4 db 01h ;Clock=1
+
+d5 db 040h ;MSL=40 (?x350 single->double)
+ db 05dh ;VDEE=349
+ db 061h ;MSL
+ db 0bbh ;VDEE
+ db 0ebh ;VT
+ db 0f0h ;OF
+ db 0c8h ;VSS
+ db 08ah ;VSE / Protect
+ db 0c2h ;VBS
+ db 0d6h ;VBE
+c5 db 01h ;Clock=1
+
+d6 db 040h ;MSL=41 (?x400 single->double)
+ db 08fh ;VDEE=399
+ db 061h ;MSL
+ db 01fh ;VDEE
+ db 04fh ;VT
+ db 0ffh ;OF
+ db 02Ch ;VSS
+ db 08eh ;VSE / Protect
+ db 026h ;VBS
+ db 03fh ;VBE
+c6 db 01h ;Clock=1
+
+d7 db 040h ;MSL=40 (?x480 single->double)
+ db 0dfh ;VDEE=479
+ db 061h ;MSL
+ db 0bfh ;VDEE
+ db 0efh ;VT
+ db 0ffh ;OF
+ db 0cch ;VSS
+ db 08eh ;VSE / Protect
+ db 0c6h ;VBS
+ db 0dfh ;VBE
+c7 db 01h ;Clock=1
+TextParms:
+d8 db 047h ;MSL=40 TEXT (?x350 single->double)
+ db 05dh ;VDEE=349
+ db 0e7h ;MSL
+ db 0bbh ;VDEE
+ db 0ebh ;VT
+ db 0f0h ;OF
+ db 0c8h ;VSS
+ db 08ah ;VSE / Protect
+ db 0c2h ;VBS
+ db 0d6h ;VBE
+c8 db 01h ;Clock=1
+
+d9 db 047h ;MSL=47 TEXT (?x400 single->double)
+ db 08fh ;VDEE=399
+ db 0e7h ;MSL
+ db 01fh ;VDEE
+ db 04fh ;VT
+ db 0ffh ;OF
+ db 02Ch ;VSS
+ db 08eh ;VSE / Protect
+ db 026h ;VBS
+ db 03fh ;VBE
+c9 db 01h ;Clock=1
+
+da db 047h ;MSL=47 TEXT (?x480 single->double)
+ db 0dfh ;VDEE=479
+ db 0e7h ;MSL
+ db 0bfh ;VDEE
+ db 0efh ;VT
+ db 0ffh ;OF
+ db 0cch ;VSS
+ db 08eh ;VSE / Protect
+ db 0c6h ;VBS
+ db 0dfh ;VBE
+ca db 01h ;Clock=1
+
+end_pos dd 0
+
+counter db delay2
+temp db 0
+
+end10h:
+
+
+
+install:
+ cld
+ mov dx,offset(c_r)
+ call wstring
+ mov si,80h
+ mov ch,0
+ mov cl,[si]
+ inc si
+ or cx,cx
+ jz unk_command
+
+commands:
+ lodsb
+ cmp al,'\'
+ jne check_ok
+ mov [WORD nopi],09090h
+ mov al,'/'
+check_ok:
+ cmp al,'/'
+loopne commands
+ je nunk_command
+unk_command:
+ mov dx,offset(u_c)
+ call wstring
+ int 20h
+nunk_command:
+
+ lodsb
+ or al,00100000b ;conv to lower-case
+
+ cmp al,'u'
+ jne nunload
+ jmp unload
+nunload:
+
+ cmp al,'e'
+ jne nenable
+ mov [BYTE check_set],060h
+ jmp enable_disable
+nenable:
+
+ cmp al,'d'
+ jne ndisable
+ mov [BYTE check_set],0C3h
+ jmp enable_disable
+ndisable:
+
+ cmp al,33h
+ ja unk_command
+ sub al,30h
+ jb unk_command
+ push si
+ mov ah,0
+ xchg ax,bx
+ add bx,bx ;shl bx,1
+ add bx,offset(code_table)
+ mov si,[bx]
+ mov di,offset(patch_code)
+ mov cx,patch_size
+ rep movsb ;copy clock_code
+ pop si
+ mov di,offset CRTParms
+next_parm:
+ xor bx,bx
+ mov dl,10
+ mov cx,3
+ inc si
+loop_dez:
+ lodsb
+ cmp al,' '
+ je no_num
+ cmp al,0dh
+ je no_num
+ cmp al,'-'
+ je no_num2
+ sub al,30h
+ jnb nunk_command2
+probe2:
+ jmp probe
+unk_command2:
+ jmp unk_command
+nunk_command2:
+ cmp al,9h
+ ja probe2
+ xchg ax,bx
+ mul dl
+ xchg ax,bx
+ add bl,al
+ loop loop_dez
+no_num2:
+ inc si
+ mov [WORD di],-1
+no_num:
+ dec si
+ mov [di+10],bl
+ add di,11
+ cmp [WORD di],0
+jne next_parm
+
+ call chk_600
+ jne nalready_installed
+ mov dx,offset(p_a)
+ call wstring
+ mov es,bx
+ cli
+ mov di,offset(patch_code)-int10h
+ mov si,offset(patch_code)
+ mov cx,patch_size
+ rep movsb
+ mov di,offset(CRTParms)-int10h
+ mov si,offset(CRTParms)
+ mov cx,offset(end_pos)-offset(CRTParms)
+ rep movsb
+ mov ax,[offset(nopi)]
+ mov [es:nopi-int10h],ax
+ int 20h
+
+enable_disable:
+ call chk_600
+ je nnot_inst
+ jmp not_inst
+nnot_inst:
+ mov dx,offset(p_a)
+ call wstring
+ mov es,bx
+ mov al,[offset(check_set)]
+ mov [es:check_set-int10h],al
+ int 20h
+
+nalready_installed:
+
+ mov ax,3510h
+ int 21h ;get old int 10
+ mov [offset(old_int10h)],bx
+ mov [offset(old_int10h)+2],es
+
+ mov ax,3508h
+ int 21h ;get old int 8
+ mov [offset(old_int8h)],bx
+ mov [offset(old_int8h)+2],es
+
+ mov sp,offset end_all+0FEh
+
+ push cs
+ pop es
+ mov ah,04Ah
+ mov bx,paras_all+010h
+ int 21h ;resize us
+ jc mem_error
+
+ mov ah,048h ;!BX=paras_all+10h
+ int 21h ;allocate mem for copy
+ jc mem_error
+
+ mov es,ax
+ mov cx,offset end_all+0100h
+ xor di,di
+ xor si,si
+ rep movsb ;copy IT
+
+ push es
+ push offset cool_jmp
+ retf ;mov cs,es
+
+cool_jmp: ;
+ push cs
+ pop ss ;and the stack
+
+ mov ax,ds
+ cmp [016h],ax
+ jne ok2
+ mov [es:016h],es
+ok2:
+ cmp [034h+2],ax
+ jne ok3
+ mov [es:034h+2],es
+ok3:
+
+ mov ah,50h
+ mov bx,cs
+ int 21h ;set addr of PSP
+
+ push ds
+ pop es
+ mov ah,49h
+ int 21h ;get rid of the old shit
+
+ mov ax,cs
+ mov ds,ax
+ dec ax
+ mov es,ax
+ mov [es:1],ds ;set seg to itself
+
+ mov es,[2ch] ;es=env-seg
+ mov bx,paras
+ mov ah,4ah
+ int 21h ;resize env
+ cmp bx,paras
+ je nmem_error
+mem_error:
+ mov dx,offset(m_e)
+ call wstring
+ jmp exit_load
+nmem_error:
+
+ mov ax,es
+ dec ax
+ mov es,ax ;mcb of env-seg
+ inc ax
+ mov [es:1],ax ;set seg to itself
+ mov di,8
+ mov si,offset(mcb_name)
+ mov cx,words
+ rep movsw ;copy name & prog to mcb & mem
+ mov ds,ax
+ xor dx,dx
+ mov ax,2510h
+ int 21h ;set new int 10
+ mov dx,int8h-int10h
+ mov ax,2508h
+ int 21h ;set new int 8
+
+exit_load:
+ push cs
+ pop es
+ mov ah,49h
+ int 21h
+mov ah,04ch
+int 21h ;get out (cool TSR)
+
+unload:
+ call chk_600
+ je nnot_installed
+not_inst:
+ mov dx,offset(n_i)
+ call wstring
+ int 20h
+nnot_installed:
+ push bx
+ mov ax,3510h
+ int 21h ;get int 10
+ pop bx
+ push bx
+ mov ax,es
+ cmp ax,bx
+ jne not_unload
+
+ mov ax,3508h
+ int 21h ;get int 8
+ pop bx
+ mov ax,es
+ cmp ax,bx
+ jne not_unload
+
+ mov dx,[es:offset(old_int10h)-int10h]
+ mov ds,[es:offset(old_int10h)-int10h+2]
+ mov ax,2510h
+ int 21h ;set old int 10
+ mov dx,[es:offset(old_int8h)-int10h]
+ mov ds,[es:offset(old_int8h)-int10h+2]
+ mov ax,2508h
+ int 21h ;set old int 8
+ mov ah,49h
+ int 21h ;free mem
+int 20h
+
+not_unload:
+ mov dx,offset(n_u)
+ call wstring
+int 20h
+
+probe:
+ call chk_600
+ jne nprobeerror
+ mov dx,offset(p_e)
+ call wstring
+; int 20h
+nprobeerror:
+
+ mov ax,0013h
+ int 10h
+
+ mov ax,3508h
+ int 21h ;get old int 8
+ mov [offset(old_int8xh)],bx
+ mov [offset(old_int8xh)+2],es
+
+ mov dx,offset(int8_probe)
+ mov ax,2508h
+ int 21h ;set new int 8
+
+ xor di,di
+ mov si,offset clock_buf
+
+probe_loop:
+ mov ax,di
+ call patch_code2
+
+ mov [WORD int8_counter],-1
+syncint8:
+ cmp [WORD int8_counter],0
+ js syncint8
+
+ call waitvret
+ xor cx,cx
+wait_loop:
+ call waitvret
+ inc cx
+ cmp [WORD int8_counter],18
+ jb wait_loop
+ shl cx,6 ;mul cx,64
+ xchg ax,cx
+ mov cl,179
+ div cl
+ mov [si],al
+ inc si
+ inc di
+ cmp di,32
+ jb probe_loop
+end1:
+
+ mov ax,0003h
+ int 10h
+
+ mov si,offset clock_buf
+
+ mov cx,32
+print_loop:
+ test cl,111b
+ jnz no_crlf
+ mov dx,offset crlf
+ call wstring
+no_crlf:
+ mov ah,0
+ mov al,[si]
+ inc si
+ call wdez
+ mov dx,offset Mhz
+ call wstring
+ loop print_loop
+end_print:
+
+
+
+ mov dx,[offset(old_int8xh)]
+ mov ds,[offset(old_int8xh)+2]
+ mov ax,2508h
+ int 21h ;set old int 8
+
+int 20h
+
+waitvret:
+ pusha
+ mov dx,03dah
+waitsvret:
+ in al,dx
+ mov cl,1000b
+ and al,cl
+ loope waitsvret
+waitevret:
+ in al,dx
+ mov cl,1000b
+ and al,cl
+ loopne waitevret
+ popa
+ret
+
+int8_probe:
+ inc [WORD cs:int8_counter]
+db 0eah
+old_int8xh dd 0
+
+wstring:
+ mov ah,09h
+ int 21h
+ret
+
+wdez:
+ pusha
+ mov di,ax
+ mov cx,5
+ mov si,10000
+ mov bx,10
+dez_loop:
+ xor dx,dx
+ div si
+ push dx
+ cmp cx,1
+ je nnope
+ cmp dx,di
+ je nope
+nnope:
+ xchg ax,dx
+ mov ah,2
+ add dl,30h
+ int 21h
+nope:
+ xchg si,ax
+ xor dx,dx
+ div bx
+ xchg si,ax
+ pop ax
+loop dez_loop
+ popa
+ret
+
+chk_600:
+ mov ax,020FFh
+ int 10h
+ cmp ax,00600h
+ret
+
+vga_clock:
+ and ax,0000110011110011b
+ or al,ah
+ out dx,al ;0-1
+pop ds
+popa
+ret
+
+s3_clock:
+ or al,00001100b ;set std_clock to 3
+ out dx,al
+
+ mov dl,LOW(CRTC_INDEX) ;!dh=3
+ mov al,38h ;unlock registers
+ out dx,al
+ inc dx
+ mov al,48h
+ out dx,al
+ dec dx
+ mov al,39h
+ out dx,al
+ inc dx
+ mov al,0A5h
+ out dx,al
+ dec dx
+
+ mov al,42h
+ out dx,al
+ inc dx
+ in al,dx
+ and al,11110000b
+ and bl,00001111b
+ or al,bl
+ out dx,al
+
+ pop ds
+ popa
+ret
+
+alt_vga_clock:
+ and ax,0001110011100011b
+ or al,ah
+ out dx,al ;0-2
+ pop ds
+ popa
+ret
+
+int8_counter dw 0
+
+clock_buf db 32 dup (0)
+
+code_table:
+ dw offset(vga_clock)
+ dw offset(et4000_clock)
+ dw offset(s3_clock)
+ dw offset(alt_vga_clock)
+
+c_r db 'VGA600 ver 0.5 Copyright (C) Michael Niedermayer 1997',cr,lf,'$'
+u_c db 'VGA600 (/|\)vga_card c1 c2 c3 c4 c5 c6 c7 c8 c9 ca|/U|/E|/D',cr,lf
+ db ' vga_card: 0=VGA 1=ET4000 2=S3(untested)',cr,lf
+ db ' c1: G ?x200(400)->(600) DOT-clock | - if disabled',cr,lf
+ db ' c2: G ?x200(400)->(800) DOT-clock | - if disabled',cr,lf
+ db ' c3: G ?x240(480)->(720) DOT-clock | - if disabled',cr,lf
+ db ' c4: G ?x240(480)->(960) DOT-clock | - if disabled',cr,lf
+ db ' c5: G ?x350(350)->(700) DOT-clock | - if disabled',cr,lf
+ db ' c6: G ?x400(400)->(800) DOT-clock | - if disabled',cr,lf
+ db ' c7: G ?x480(480)->(960) DOT-clock | - if disabled',cr,lf
+ db ' c8: T ?x350(350)->(700) DOT-clock | - if disabled',cr,lf
+ db ' c9: T ?x400(400)->(800) DOT-clock | - if disabled',cr,lf
+ db ' ca: T ?x480(480)->(960) DOT-clock | - if disabled',cr,lf
+ db 'ex: VGA600 /1 2 - 4 - 5 6 6 - - -',cr,lf,'$'
+n_i db 'VGA600 is not installed!',cr,lf,'$'
+n_u db 'VGA600 is not unloadable!',cr,lf,'$'
+m_e db 'Mem allocating error!',cr,lf,'$'
+p_a db 'Passing arguments to TSR!',cr,lf,'$'
+p_e db 'Uninstall VGA600 first!',cr,lf,'$'
+Mhz db 'Mhz $'
+crlf db cr,lf,'$'
+
+end_all:
+ends
+end start
1
0
Author: michael
Date: Wed Jul 4 17:51:21 2007
New Revision: 69
Log:
make it work with yasm
Modified:
trunk/mmm/README
trunk/mmm/mmm_16.asm
Modified: trunk/mmm/README
==============================================================================
--- trunk/mmm/README (original)
+++ trunk/mmm/README Wed Jul 4 17:51:21 2007
@@ -12,6 +12,11 @@ Requirements:
MSDOS, no dosemu does not seem to work, and no i dont know why
+Compilation:
+------------
+yasm -o mmm_16.com mmm_16.asm
+
+
License:
--------
BSD (without the annying GPL incompatible clause)
\ No newline at end of file
Modified: trunk/mmm/mmm_16.asm
==============================================================================
--- trunk/mmm/mmm_16.asm (original)
+++ trunk/mmm/mmm_16.asm Wed Jul 4 17:51:21 2007
@@ -1,5 +1,6 @@
;VER 0.92 75 byte 8086 needed
;reg at start needed AH=0,ahem si=0/bl=0
+org 0x100
incr equ 8
bias equ 1024
mov bh,0A0h ; DS=A000
@@ -8,7 +9,7 @@ bias equ 1024
INT 10h ; "
MOV BP,bias
NEXT:
- ADD [SEM1-bias+bp]w,incr
+ ADD word [SEM1-bias+bp],incr
MOV BH,-192*incr/256
N0:
PUSH si
1
0
Author: michael
Date: Wed Jul 4 17:48:18 2007
New Revision: 68
Log:
a 75 byte program i wrote in 1996 to draw a mandelbrot fractal
Added:
trunk/mmm/
trunk/mmm/README
trunk/mmm/mmm_16.asm
Added: trunk/mmm/README
==============================================================================
--- (empty file)
+++ trunk/mmm/README Wed Jul 4 17:48:18 2007
@@ -0,0 +1,17 @@
+MMM
+---
+
+
+About:
+------
+a 75 byte program i wrote in 1996 to draw a mandelbrot fractal
+
+
+Requirements:
+-------------
+MSDOS, no dosemu does not seem to work, and no i dont know why
+
+
+License:
+--------
+BSD (without the annying GPL incompatible clause)
\ No newline at end of file
Added: trunk/mmm/mmm_16.asm
==============================================================================
--- (empty file)
+++ trunk/mmm/mmm_16.asm Wed Jul 4 17:48:18 2007
@@ -0,0 +1,49 @@
+ ;VER 0.92 75 byte 8086 needed
+ ;reg at start needed AH=0,ahem si=0/bl=0
+incr equ 8
+bias equ 1024
+ mov bh,0A0h ; DS=A000
+ mov ds,bx ; "
+ MOV AL,013h ;V-mode 320x200x256
+ INT 10h ; "
+ MOV BP,bias
+NEXT:
+ ADD [SEM1-bias+bp]w,incr
+ MOV BH,-192*incr/256
+N0:
+ PUSH si
+ MOV CL,150
+ XOR si,si
+ XOR di,di
+N3:
+ MOV AX,di
+ IMUL AX
+ IDIV BP
+ XCHG AX,si
+ XCHG AX,di
+ IMUL di
+ IDIV BP
+ ADD AX,AX
+DB 05h ;add AX,imm16
+SEM1 DW -100*incr
+ XCHG di,AX
+ IMUL AX
+ IDIV BP
+ ADD si,AX
+ ADD AX,AX
+ SUB AX,si
+ ADD AX,BX
+ XCHG AX,si
+
+ TEST AH,11110000b
+ LOOPZ N3
+ POP si
+ CMP BX,BP
+ JGE NEXT
+ MOV [si],CL
+ ADD BX,incr
+ INC si
+ JNZ N0
+ RET
+
+
1
0
Author: michael
Date: Wed Jul 4 14:59:13 2007
New Revision: 67
Log:
found an older version from 1997
Added:
trunk/2010/version_from97.diff
Modified:
trunk/2010/README
Modified: trunk/2010/README
==============================================================================
--- trunk/2010/README (original)
+++ trunk/2010/README Wed Jul 4 14:59:13 2007
@@ -3,7 +3,7 @@
About:
------
-some old code i wrote in 1998-2000 or so, which decodes nagravision,
+some old code i wrote in 1997-2000 or so, which decodes nagravision,
videocrypt, sync suppression and teletext
warning the code is messy, patches to clean it up are welcome!
@@ -14,6 +14,11 @@ shouldnt be hard (patch welcome)
windows/dos something, i dont remember, patches which port it to linux and
v4l(2) are very welcome
+version_from97.diff
+-------------------
+a diff between the first checkin (r43) and an older version (from 1997) which
+i found too late (svn sucks, i wish we had git on mphq)
+
License:
--------
GPL v2+
\ No newline at end of file
Added: trunk/2010/version_from97.diff
==============================================================================
--- (empty file)
+++ trunk/2010/version_from97.diff Wed Jul 4 14:59:13 2007
@@ -0,0 +1,768 @@
+diff -ud ./2010.cc s_bak/2010.cc
+--- ./2010.cc 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2010.cc 1997-10-02 17:55:44.000000000 +0200
+@@ -1,4 +1,4 @@
+-//2010 0.1 Copyright (C) Michael Niedermayer 1998
++//2010 0.1 Copyright (C) Michael Niedermayer 1997
+
+ #include <stdlib.h>
+ #include <pc.h>
+@@ -124,7 +124,7 @@
+ FILE *f;
+ int mc2;
+
+- printf("2010 0.10 Copyright (C) Michael Niedermayer 1998\n");
++ printf("2010 0.10 Copyright (C) Michael Niedermayer 1997\n");
+
+ atexit(exitt);
+
+@@ -215,7 +215,7 @@
+ edge_lut[i]=j;
+ }
+
+- printf("Building YUV to RGB LookUp Tables!\n");
++ printf("Building YUV to RGB LockUp Tables!\n");
+ yuv2rgb_lut=new char[256*4*2];
+ for(i=0; i<256; i++){
+ if(i>=128) j=i-256;
+@@ -308,6 +308,7 @@
+ while(key==0){
+ draw_dispbuf();
+
++
+ xpos=mouse_x;
+ ypos=mouse_y;
+ buttons=mouse_b;
+@@ -316,7 +317,6 @@
+
+ lxpos=xpos;
+ lypos=ypos;
+-
+ if(kbhit()) key=getkey();
+ if(key=='g' || key=='G') key=0, grabf=1;
+ }
+Only in s_bak/: 2010.cur
+Only in s_bak/: 2010.fnt
+diff -ud ./2010.h s_bak/2010.h
+--- ./2010.h 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2010.h 1997-08-03 17:50:12.000000000 +0200
+@@ -1,5 +1,4 @@
+-//2010 0.1 Copyright (C) Michael Niedermayer 1998
+-
++//2010 0.1 Copyright (C) Michael Niedermayer 1997
+ #ifndef n2010_h
+ #define n2010_h
+
+Only in s_bak/: 2_7116.cc
+diff -ud ./2_71x6.cc s_bak/2_71x6.cc
+--- ./2_71x6.cc 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2_71x6.cc 1997-10-01 20:20:26.000000000 +0200
+@@ -1,4 +1,4 @@
+-//2010 0.1 Copyright (C) Michael Niedermayer 1998
++//2010 0.1 Copyright (C) Michael Niedermayer 1997
+ #include <stdio.h>
+ #include <string.h>
+ #include <sys/nearptr.h>
+@@ -10,17 +10,14 @@
+ #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
++#define wait_time 0.010
+
+ 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;
+@@ -101,42 +98,14 @@
+ 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));
+
+- 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));
++ wait(wait_time);
+ }
+
+ static inline int write_i2c(u_char dev, u_char reg, u_char data){
+@@ -187,10 +156,6 @@
+ 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++;
+ }
+@@ -204,10 +169,10 @@
+ }
+
+ 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){
+@@ -235,6 +200,7 @@
+ }
+ }
+ }
++
+ a_saa7116->ints_ctl_a|=0x7;
+ }
+
+@@ -282,11 +248,10 @@
+ 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;
+
+-
++
+ }
+
+
+@@ -428,7 +393,7 @@
+ metmode=1;
+
+ address.offset32=(u_long)(&meteor_handler);
+- address.selector=my_cs;
++ address.selector=my_cs;
+ if(__dpmi_set_protected_mode_interrupt_vector(
+ meteors[active_meteor].intt, &address)!=0) error(DPMI);
+
+@@ -439,47 +404,28 @@
+ else outportb(0xA1, inportb(0xA1) & ~(1 << (meteors[active_meteor].irq - 8)));
+ asm("sti\n\t");
+
+- /* init saa7116 */
++ /* init saa7116 and probe for dma-range */
+
+ 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,
++ 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}; /* end reset / range contr */
++ res1: 0, corr_dis: 0, range_en: 1, 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=
++ a_saa7116->i2c_clocks=0x461E1E0F;
++ 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;
++ //FIX ME perhaps GCC sucks a bit (packed / planar init)
++ a_saa7116->field_toggle= 0x107; /* enab field tog ,etc..*/
+ 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;
++ wait(wait_time);
+
+ a_saa7116->dma_end=(eo){even: ~0, odd: ~0};
+ meteors[active_meteor].maxRange=
+@@ -569,6 +515,11 @@
+ void start_grab(void){
+ saa7116 *a_saa7116=(saa7116*)meteors[active_meteor].saa7116;
+
++ 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: 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};
+ 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};
+@@ -601,8 +552,6 @@
+ 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){
+@@ -613,6 +562,5 @@
+ 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};
+-
+ }
+
+diff -ud ./2_71x6.h s_bak/2_71x6.h
+--- ./2_71x6.h 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2_71x6.h 1997-09-02 05:09:30.000000000 +0200
+@@ -1,4 +1,4 @@
+-//2010 0.1 Copyright (C) Michael Niedermayer 1998
++//2010 0.1 Copyright (C) Michael Niedermayer 1997
+ #ifndef n2_71x6
+ #define n2_71x6
+
+@@ -106,18 +106,10 @@
+ };
+
+ 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 */
++ 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 {
+@@ -129,41 +121,34 @@
+ };
+
+ #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 */
++ 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 bit 8=1 1=1 0=1 2=field_toggle */
+ v_union{
+- v_u_long capt_ctl_a;
++ volatile u_long capt_ctl_a;
+ v_struct capt_c capt_ctl;
+ }; /* (16)40: Capture control, etc. */
+- v_u_long retry_wait; /* (17)44 */
++ u_long retry_wait; /* (17)44 */
+ v_union{
+- v_u_long ints_ctl_a;
++ volatile 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 */
++ 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 */
+ };
+
+ #define SAA7196_IDEL 0x00 /* Increment delay */
+diff -ud ./2_all_a.asm s_bak/2_all_a.asm
+--- ./2_all_a.asm 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2_all_a.asm 1997-10-03 06:08:38.000000000 +0200
+@@ -1,4 +1,4 @@
+-; 2010 0.1 Copyright (C) Michael Niedermayer 1998
++; 2010 0.1 Copyright (C) Michael Niedermayer 1997
+
+ %define par1 (esp + 28)
+ %define par2 (esp + 32)
+diff -ud ./2_all.h s_bak/2_all.h
+--- ./2_all.h 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2_all.h 1997-09-13 19:05:16.000000000 +0200
+@@ -1,4 +1,4 @@
+-//2010 0.1 Copyright (C) Michael Niedermayer 1998
++//2010 0.1 Copyright (C) Michael Niedermayer 1997
+ #ifndef n2_all_h
+ #define n2_all_h
+
+diff -ud ./2_crypt.cc s_bak/2_crypt.cc
+--- ./2_crypt.cc 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2_crypt.cc 1997-10-02 18:53:52.000000000 +0200
+@@ -1,4 +1,4 @@
+-//2010 0.1 Copyright (C) Michael Niedermayer 1998
++//2010 0.1 Copyright (C) Michael Niedermayer 1997
+
+ #include <string.h>
+ #include "2_all.h"
+diff -ud ./2_crypt.h s_bak/2_crypt.h
+--- ./2_crypt.h 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2_crypt.h 1997-08-31 22:03:20.000000000 +0200
+@@ -1,4 +1,4 @@
+-//2010 0.1 Copyright (C) Michael Niedermayer 1998
++//2010 0.1 Copyright (C) Michael Niedermayer 1997
+ #ifndef n2_crypt_h
+ #define n2_crypt_h
+
+diff -ud ./2_file.cc s_bak/2_file.cc
+--- ./2_file.cc 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2_file.cc 1997-09-29 03:42:26.000000000 +0200
+@@ -1,4 +1,4 @@
+-//2010 0.1 Copyright (C) Michael Niedermayer 1998
++//2010 0.1 Copyright (C) Michael Niedermayer 1997
+
+ #include <stdio.h>
+ #include <dos.h>
+diff -ud ./2_file.h s_bak/2_file.h
+--- ./2_file.h 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2_file.h 1997-07-29 19:22:34.000000000 +0200
+@@ -1,4 +1,4 @@
+-//2010 0.1 Copyright (C) Michael Niedermayer 1998
++//2010 0.1 Copyright (C) Michael Niedermayer 1997
+ #ifndef n2_file_h
+ #define n2_file_h
+
+diff -ud ./2_gfunc.cc s_bak/2_gfunc.cc
+--- ./2_gfunc.cc 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2_gfunc.cc 1997-09-13 19:05:08.000000000 +0200
+@@ -1,4 +1,4 @@
+-//2010 0.1 Copyright (C) Michael Niedermayer 1998
++//2010 0.1 Copyright (C) Michael Niedermayer 1997
+
+ #include <stdlib.h>
+ #include <string.h>
+diff -ud ./2_gfunc.h s_bak/2_gfunc.h
+--- ./2_gfunc.h 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2_gfunc.h 1997-07-20 16:10:04.000000000 +0200
+@@ -1,4 +1,4 @@
+-//2010 0.1 Copyright (C) Michael Niedermayer 1998
++//2010 0.1 Copyright (C) Michael Niedermayer 1997
+ #ifndef n2_gfunc_h
+ #define n2_gfunc_h
+
+diff -ud ./2_glob_a.asm s_bak/2_glob_a.asm
+--- ./2_glob_a.asm 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2_glob_a.asm 1997-10-02 23:03:52.000000000 +0200
+@@ -1,4 +1,4 @@
+-;2010 0.1 Copyright (C) Michael Niedermayer 1998
++;2010 0.1 Copyright (C) Michael Niedermayer 1997
+
+ %include "2_all_a.asm"
+
+diff -ud ./2_grafix.cc s_bak/2_grafix.cc
+--- ./2_grafix.cc 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2_grafix.cc 1997-09-02 05:21:24.000000000 +0200
+@@ -1,4 +1,4 @@
+-//2010 0.1 Copyright (C) Michael Niedermayer 1998
++//2010 0.1 Copyright (C) Michael Niedermayer 1997
+
+ #include <stdio.h>
+ #include <time.h>
+@@ -68,7 +68,7 @@
+
+ }
+
+- if(cstate==1) drawc();
++ if(cstate==1) drawc();
+
+ if(istate==1){
+ T2=uclock();
+diff -ud ./2_grafix.h s_bak/2_grafix.h
+--- ./2_grafix.h 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2_grafix.h 1997-07-10 03:35:34.000000000 +0200
+@@ -1,4 +1,4 @@
+-//2010 0.1 Copyright (C) Michael Niedermayer 1998
++//2010 0.1 Copyright (C) Michael Niedermayer 1997
+ #ifndef n2_grafix_h
+ #define n2_grafix_h
+
+diff -ud ./2_hw_asm.h s_bak/2_hw_asm.h
+--- ./2_hw_asm.h 2007-07-04 11:36:59.000000000 +0200
++++ s_bak/2_hw_asm.h 1997-07-10 03:35:44.000000000 +0200
+@@ -1,4 +1,4 @@
+-//2010 0.1 Copyright (C) Michael Niedermayer 1998
++//2010 0.1 Copyright (C) Michael Niedermayer 1997
+ #ifndef n2_hw_asm_h
+ #define n2_hw_asm_h
+
+Only in s_bak/: 2_hw_asm.s
+diff -ud ./2_hw.cc s_bak/2_hw.cc
+--- ./2_hw.cc 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2_hw.cc 1997-09-17 05:26:32.000000000 +0200
+@@ -1,4 +1,4 @@
+-//2010 0.1 Copyright (C) Michael Niedermayer 1998
++//2010 0.1 Copyright (C) Michael Niedermayer 1997
+
+ #include <stdlib.h>
+ #include <stdio.h> //FIX ME (ONLY TEMP NEEDED)
+@@ -53,7 +53,7 @@
+
+ int g_mode=0;
+ int m_mode=0;
+- extern u_short my_cs, my_ds;
++ u_short my_cs=_go32_my_cs();
+ asm("__esp: .long 0\n\t");
+
+ static inline void setdot(int xx, int yy, s_col c);
+@@ -393,8 +393,6 @@
+ 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
+@@ -555,8 +553,8 @@
+ 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,
++ 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};
+ // 0x8FF3 resume grab
+ grab_state=NotReady;
+@@ -564,32 +562,13 @@
+ 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,
++ 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};
+ // 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){
+diff -ud ./2_hw.h s_bak/2_hw.h
+--- ./2_hw.h 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2_hw.h 1997-09-14 19:53:52.000000000 +0200
+@@ -1,4 +1,4 @@
+-//2010 0.1 Copyright (C) Michael Niedermayer 1998
++//2010 0.1 Copyright (C) Michael Niedermayer 1997
+ #ifndef n2_hw_h
+ #define n2_hw_h
+
+diff -ud ./2_hw_mem.cc s_bak/2_hw_mem.cc
+--- ./2_hw_mem.cc 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2_hw_mem.cc 1997-09-13 18:57:32.000000000 +0200
+@@ -1,4 +1,4 @@
+-//2010 0.1 Copyright (C) Michael Niedermayer 1998
++//2010 0.1 Copyright (C) Michael Niedermayer 1997
+
+ #include <stdlib.h>
+ #include <stdio.h>
+@@ -283,7 +283,7 @@
+
+ i=~(1024*1024*4-1);
+ if( (maxaddr & i) != ((maxaddr+size) & i) ) error(MemAlloc);
+- //FIX ME (should be retried until ok)
++ //FIX ME (should be retryed until ok)
+ ret.phys=maxaddr;
+ return ret;
+
+diff -ud ./2_hw_mem.h s_bak/2_hw_mem.h
+--- ./2_hw_mem.h 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2_hw_mem.h 1997-07-30 21:41:10.000000000 +0200
+@@ -1,4 +1,4 @@
+-//2010 0.1 Copyright (C) Michael Niedermayer 1998
++//2010 0.1 Copyright (C) Michael Niedermayer 1997
+ #ifndef n2_hw_mem_h
+ #define n2_hw_mem_h
+
+diff -ud ./2_menu.cc s_bak/2_menu.cc
+--- ./2_menu.cc 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2_menu.cc 1997-08-31 21:27:46.000000000 +0200
+@@ -1,4 +1,4 @@
+-//2010 0.1 Copyright (C) Michael Niedermayer 1998
++//2010 0.1 Copyright (C) Michael Niedermayer 1997
+
+ #include <stdlib.h>
+ #include "2_all.h"
+diff -ud ./2_menu.h s_bak/2_menu.h
+--- ./2_menu.h 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2_menu.h 1997-08-31 21:22:52.000000000 +0200
+@@ -1,4 +1,4 @@
+-//2010 0.1 Copyright (C) Michael Niedermayer 1998
++//2010 0.1 Copyright (C) Michael Niedermayer 1997
+ #ifndef n2_menu_h
+ #define n2_menu_h
+
+diff -ud ./2_mfunc.cc s_bak/2_mfunc.cc
+--- ./2_mfunc.cc 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2_mfunc.cc 1997-09-08 17:21:04.000000000 +0200
+@@ -1,4 +1,4 @@
+-//2010 0.1 Copyright (C) Michael Niedermayer 1998
++//2010 0.1 Copyright (C) Michael Niedermayer 1997
+
+ #include "2_all.h"
+ #include "2_mfunc.h"
+diff -ud ./2_mfunc.h s_bak/2_mfunc.h
+--- ./2_mfunc.h 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2_mfunc.h 1997-08-31 21:23:10.000000000 +0200
+@@ -1,4 +1,4 @@
+-//2010 0.1 Copyright (C) Michael Niedermayer 1998
++//2010 0.1 Copyright (C) Michael Niedermayer 1997
+ #ifndef n2_mfunc_h
+ #define n2_mfunc_h
+
+diff -ud ./2_mmx.h s_bak/2_mmx.h
+--- ./2_mmx.h 2007-07-04 11:36:59.000000000 +0200
++++ s_bak/2_mmx.h 1997-09-15 04:41:14.000000000 +0200
+@@ -1,4 +1,4 @@
+-//2010 0.1 Copyright (C) Michael Niedermayer 1998
++//2010 0.1 Copyright (C) Michael Niedermayer 1997
+ #ifndef n2_mmx_h
+ #define n2_mmx_h
+
+diff -ud ./2_mouse.cc s_bak/2_mouse.cc
+--- ./2_mouse.cc 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2_mouse.cc 1997-08-08 20:57:40.000000000 +0200
+@@ -1,4 +1,4 @@
+-//2010 0.1 Copyright (C) Michael Niedermayer 1998
++//2010 0.1 Copyright (C) Michael Niedermayer 1997
+
+ #include <stdlib.h>
+ #include "2_all.h"
+diff -ud ./2_mouse.h s_bak/2_mouse.h
+--- ./2_mouse.h 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2_mouse.h 1997-07-10 03:35:52.000000000 +0200
+@@ -1,4 +1,4 @@
+-//2010 0.1 Copyright (C) Michael Niedermayer 1998
++//2010 0.1 Copyright (C) Michael Niedermayer 1997
+ #ifndef n2_mouse_h
+ #define n2_mouse_h
+
+diff -ud ./2_move.cc s_bak/2_move.cc
+--- ./2_move.cc 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2_move.cc 1997-09-29 04:40:30.000000000 +0200
+@@ -1,4 +1,4 @@
+-//2010 0.1 Copyright (C) Michael Niedermayer 1998
++//2010 0.1 Copyright (C) Michael Niedermayer 1997
+
+ #include <stdlib.h>
+ #include "2_move.h"
+diff -ud ./2_move.h s_bak/2_move.h
+--- ./2_move.h 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2_move.h 1997-08-08 20:58:50.000000000 +0200
+@@ -1,4 +1,4 @@
+-//2010 0.1 Copyright (C) Michael Niedermayer 1998
++//2010 0.1 Copyright (C) Michael Niedermayer 1997
+ #ifndef n2_move_h
+ #define n2_move_h
+
+diff -ud ./2_nag_a.asm s_bak/2_nag_a.asm
+--- ./2_nag_a.asm 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2_nag_a.asm 1997-10-03 06:09:20.000000000 +0200
+@@ -1,4 +1,4 @@
+-;2010 0.1 Copyright (C) Michael Niedermayer 1998
++;2010 0.1 Copyright (C) Michael Niedermayer 1997
+
+ %include "2_all_a.asm"
+
+diff -ud ./2_nag_a.h s_bak/2_nag_a.h
+--- ./2_nag_a.h 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2_nag_a.h 1997-09-16 21:54:18.000000000 +0200
+@@ -1,4 +1,4 @@
+-//2010 0.1 Copyright (C) Michael Niedermayer 1998
++//2010 0.1 Copyright (C) Michael Niedermayer 1997
+ #ifndef n2_nag_a_h
+ #define n2_nag_a_h
+
+diff -ud ./2_nag.cc s_bak/2_nag.cc
+--- ./2_nag.cc 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2_nag.cc 1997-10-01 20:58:18.000000000 +0200
+@@ -1,4 +1,4 @@
+-//2010 0.1 Copyright (C) Michael Niedermayer 1998
++//2010 0.1 Copyright (C) Michael Niedermayer 1997
+
+ #include <string.h>
+ #include <stdlib.h>
+@@ -266,7 +266,7 @@
+ 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
++ const int endi2= block[block2].end[0] == line2 ? 0 : 1;
+
+ int backlinei[2]={l_ent, l_ent};
+ for(j=0; j<l_ent; j++){
+diff -ud ./2_nag.h s_bak/2_nag.h
+--- ./2_nag.h 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2_nag.h 1997-09-20 05:40:44.000000000 +0200
+@@ -1,4 +1,4 @@
+-//2010 0.1 Copyright (C) Michael Niedermayer 1998
++//2010 0.1 Copyright (C) Michael Niedermayer 1997
+ #ifndef n2_nag_h
+ #define n2_nag_h
+
+diff -ud ./2_vc_a.asm s_bak/2_vc_a.asm
+--- ./2_vc_a.asm 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2_vc_a.asm 1997-10-03 06:16:48.000000000 +0200
+@@ -1,4 +1,4 @@
+-;2010 0.1 Copyright (C) Michael Niedermayer 1998
++;2010 0.1 Copyright (C) Michael Niedermayer 1997
+
+ %include "2_all_a.asm"
+
+@@ -16,6 +16,7 @@
+ %define count2 par6
+
+ _vc_corr__Fiiiiii:
++ int3
+ push ebx
+
+ push ecx
+diff -ud ./2_vc_a.h s_bak/2_vc_a.h
+--- ./2_vc_a.h 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2_vc_a.h 1997-10-02 22:50:10.000000000 +0200
+@@ -1,4 +1,4 @@
+-//2010 0.1 Copyright (C) Michael Niedermayer 1998
++//2010 0.1 Copyright (C) Michael Niedermayer 1997
+ #ifndef n2_vc_a_h
+ #define n2_vc_a_h
+
+Only in .: 2_vc.cc
+diff -ud ./2_vc.h s_bak/2_vc.h
+--- ./2_vc.h 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2_vc.h 1997-08-16 18:05:56.000000000 +0200
+@@ -1,4 +1,4 @@
+-//2010 0.1 Copyright (C) Michael Niedermayer 1998
++//2010 0.1 Copyright (C) Michael Niedermayer 1997
+ #ifndef n2_vc_h
+ #define n2_vc_h
+
+diff -ud ./2_wins.cc s_bak/2_wins.cc
+--- ./2_wins.cc 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2_wins.cc 1997-08-09 04:54:14.000000000 +0200
+@@ -1,4 +1,4 @@
+-//2010 0.1 Copyright (C) Michael Niedermayer 1998
++//2010 0.1 Copyright (C) Michael Niedermayer 1997
+
+ #include <stdio.h>
+ #include <string.h>
+diff -ud ./2_wins.h s_bak/2_wins.h
+--- ./2_wins.h 2007-07-04 14:36:15.000000000 +0200
++++ s_bak/2_wins.h 1997-08-08 21:49:36.000000000 +0200
+@@ -1,4 +1,4 @@
+-//2010 0.1 Copyright (C) Michael Niedermayer 1998
++//2010 0.1 Copyright (C) Michael Niedermayer 1997
+ #ifndef n2_wins_h
+ #define n2_wins_h
+
+Only in .: s_bak
+Only in .: .svn
+Only in .: version_from97.diff
1
0