Post by Paul EdwardsPost by Herbert Kleebauerprinciples (like the jpeg decoder), but for bigger,
BTW, do you have this "dos.c" file available?
D:\devel\pdos\pfp\source>grep dos.c pfp.c
pfp.c: /*unsigned char bgr[3*HBMP*VBMP]; declared in dos.c or win.c */
pfp.c: /*#include "dos.c"*/ /* DOS version */
D:\devel\pdos\pfp\source>
I used the DOS version only for the first test versions.
And the code depends on the graphics card used.
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
dos.c
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
/*
#define TIME 0
*/
#include <stdlib.h>
#define SEEK_SET 0
/**************************************************************************/
unsigned char bgr[3*HBMP*VBMP];
int xpos=0,ypos=0,HWIN,VWIN;
/**************************************************************************/
void crypt(unsigned char*,unsigned int*);
void get_passwd();
int getC();
void init();
void setpict(int);
int decode();
void cleanup();
void ende(int,int);
int get_byte();
int get_word();
void SOI();
void EOI();
void DQT();
void DHT();
void SOF();
void SOS();
void APP0();
void COM();
void UNKNOWN();
void out_string(char*);
void out_byte(int);
void out_bin(int,int);
void out_hex1(int);
void out_hex2(int);
void out_hex4(int);
void out_dec(int);
void print_string(char*);
void print_dec(int);
int get_bits(int);
void zeichne();
void scale1();
void scale2();
void scale3();
void scale4();
void (*scale)() = scale3;
/* 1: no scale 2: fast 3: slower but better 4: best */
/**************************************************************************/
main(nargs,args) int nargs; char *args[];
{int i,dir=0;
char *p,*q;
unsigned long t1,t2,t3;
if (nargs!=2) p="test.jpg";
else p=args[1];
q=filename;
while (*p == ' ') p++; if (*p=='"') p++; i=0;
while ( (*q++ = *p++)>' ' && (i++ < 1024) );
*(--q)=0; if (*(--q)=='"')*q=0;
init();
init_vga(); HWIN=800; VWIN=600;
#ifdef TIME
t1=clock();
#endif
decode(); scale(); zeichne();
loop:
#ifndef TIME
i=0xff&get_key();
#else
i=' ';
#endif
if (i == ' ')
{if (dir<=0) {setpict(pictnr-dir); dir=1; decode(); scale();}
zeichne();
if (decode())
{dir=0;
#ifdef TIME
t2=clock();
cleanup();
reset_vga();
i=t2-t1; printf("\nZeit 1:%d\n",i);
get_key();
exit(0);
#endif
}
scale();
}
else if (i == 'b'|| i == 'B')
{if (dir>=0) {setpict(pictnr-2-dir); dir= -1; decode(); scale();}
zeichne();
if (pictnr==1) dir=0; else {setpict(pictnr-2); decode(); scale();}
}
else if (i == 'x' || i == 'X')
{cleanup(); reset_vga(); exit(0);}
goto loop;
}
/**************************************************************************/
void get_passwd()
{int i,j,k;
goto gk1;
gk0:
printf("\npassword to short\n");
gk1:
printf("Enter password:");
printf("\n------------------------\n");
for (i=0; i<24; i++) if ((passwd[i]=getc(stdin))=='\n') goto gk0;
while (getc(stdin)!='\n');
passwd[25]=0;
}
void zeichne() {disp_rgb(bgr);}
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
gra.s
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
.text
.globl _init_vga
.globl _reset_vga
.globl _disp_rgb
.globl _get_key
.globl _tst_key
_get_key:
xorl %eax,%eax
int $0x16
ret
_tst_key:
xorl %eax,%eax
incb %ah
int $0x16
jnz L_t1
xorl %eax,%eax
decl %eax
L_t1: ret
_init_vga:
pushl %ebx
movw $0x4f02,%ax
movw $0x0114,%bx # 800x600 64k
int $0x10
xorl %eax,%eax
popl %ebx
ret
_reset_vga:
movw $0x03,%ax
int $0x10
xorl %eax,%eax
ret
_disp_rgb:
pushl %ebx
pushl %ecx
pushl %edx
pushl %esi
pushl %edi
movl 4+20(%esp),%esi
movl $800,Ldr100
movw $0,%edx
Ldr20: movl $0x8000,%ecx
Ldr30: movw $0x4f05,%ax
xorl %ebx,%ebx
int $0x10
movl $0,%edi
Ldr10: xorl %eax,%eax
movb 2(%esi),%al
shll $5,%eax
movb 1(%esi),%al
shll $6,%eax
movb (%esi),%al
shrl $3,%eax
movw %ax,0xe00a0000(%edi)
addl $3,%esi
addl $2,%edi
decl Ldr100
jne Ldr11
movl $800,Ldr100
addl $(1024*2-800)*3,%esi
Ldr11: decl %ecx
jne Ldr10
addw $1,%dx /* abhaengig von Graphikkarte */
cmpw $1*14,%dx /* Abfrage durch int 10h ax=4f01 */
/* 16 fuer 4 kByte Granualitaet */
/* 1 fuer 64 kByte Granualitaet usw. */
jc Ldr20
movl $21248,%ecx
je Ldr30
popl %edi
popl %esi
popl %edx
popl %ecx
popl %ebx
xorl %eax,%eax
ret
Ldr100: .long 0