home *** CD-ROM | disk | FTP | other *** search
- // This is our contribution to Scenario party at Lahti!
- // Windows 95 sucks!
- // This simple 'demo' is coded by Dr.Doom/Paranoids 1995
- // Joo, kyllä se siitä!
-
- // 1. Avaus fade out & in logon kanssa ja varit mukaan
- // 2. Logon poisto rivi kerrallaan. (random??)
- // 3. Rotate & zoomer I
- // 4. Rotate & zoomer II
- // 5. Donitsi
- // 6. Tunneli
- // 5. The end screen
-
- #include <stdio.h>
- #include <conio.h>
- #include <dos.h>
- #include <string.h>
- #include <alloc.h>
- #include <assert.h>
-
- #include <midas.h>
-
- #include "ascidemo.h"
- #include "lpage.h"
- extern void rotating_torus(int frame);
-
-
- #define I asm
- #define read_char(x,y) (*(unsigned char far *) MK_FP(0xB800,160*(y)+2*(x)))
- #define read_color(x,y) (*(unsigned char far *) MK_FP(0xB800,160*(y)+2*(x)+1))
- #define put_char(x,y,character) \
- ((*(unsigned char far *) MK_FP(0xb800,160*(y)+2*(x)))=(character))
- #define put_color(x,y,color) \
- ((*(unsigned char far *) MK_FP(0xb800,160*(y)+2*(x)+1))=(color))
-
- extern unsigned _stklen = 4096;
-
- extern unsigned char far colors[65280U];
- extern unsigned char far chars[65280U];
- unsigned int mem2;//=FP_SEG(colors);
- unsigned int mem1;//=FP_SEG(chars);
-
-
-
- volatile unsigned long frameCount = 0;
-
-
- void main (void);
- void logo_color (void);
- void logo_bw (void);
- void shade (void);
-
- // unsigned char *koko_rivi[80];
-
- void waittof(void)
- {
- // unsigned long oldFrameCount = frameCount;
- // while ( frameCount == oldFrameCount ) ;
-
- while (!(inportb(0x3da)&0x8));
- while (inportb(0x3da)&8);
-
- }
-
-
- void poispois (void)
- {
- int cur_rivi=0,cur_sarake;//,mrk_left=0;
- // unsigned char *merkki[2];
- // unsigned char merkki[2];
- int frame=0;
- for (frame=0;frame<100;frame++)
- {
- for (cur_rivi=0;cur_rivi<50;cur_rivi++)
- {
- for (cur_sarake=1;cur_sarake<=79;cur_sarake++)
- {
- put_color(cur_sarake-1,cur_rivi,read_color(cur_sarake,cur_rivi));
- put_char(cur_sarake-1,cur_rivi,read_char(cur_sarake,cur_rivi));
- }
- put_char(79,cur_rivi,' ');
- put_color(79,cur_rivi,0x00);
- cur_rivi++;
- for (cur_sarake=79;cur_sarake>=0;cur_sarake--)
- {
- put_color(cur_sarake+1,cur_rivi,read_color(cur_sarake,cur_rivi));
- put_char(cur_sarake+1,cur_rivi,read_char(cur_sarake,cur_rivi));
- }
- put_char(0,cur_rivi,' ');
- put_color(0,cur_rivi,0x00);
-
- }
- waittof();
- }
- }
-
- void shade(int start,int end,int add)
- {
- int c;
- gotoxy(1,1);
- for (;start!=end;start+=add)
- {
- _CX=765; //765
- _DX=0x03c8;
- _AX=1; // 0
- I out dx,al
- _DX++;
- _AX=start;
- uusi:
- I out dx,al
- I loop uusi
-
- for (c=0;c<=1;c++)
- {
- while (0==(inportb(0x3da)&8));
- while ((inportb(0x3da))&8);
- }
- }
- }
-
- void backscr (void)
- {
- _AX=0x3;
- geninterrupt(0x10);
- }
-
- void logo_bw(void)
- {
- }
-
-
- void logo_color(void)
- {
- _fmemcpy(MK_FP(0xb800,0),(void far *)DEMO_PRELUDE,DEMO_PRELUDE_LENGTH);
- }
-
- void lastpage(void)
- {
- _fmemcpy(MK_FP(0xb800,0),(void far *)LAST_PAGE,LAST_PAGE_LENGTH);
- }
-
-
-
- int sin[1025];
- char sin8[1025];
- #define cosadd (256)
- void optimized_sin()
- {
- long v,x,vc=0,xc=0,AA=340913941L;//357913941;//193948423;
-
- register int i;
- x=-32768L;v=0;
- for (i=0;i<=512;i++) {
- // (*(char far *)MK_FP(0xa000,x/512+160+320*(i/4))) ++;
- // (*(char far *)MK_FP(0xa000,x/512+160+320*((SINTABLESIZE-i)/4)))++;
- // (*(char far *)MK_FP(0xa000,x/512+160+320*((SINTABLESIZE+i)/4)))++;
- sin[(i*2-cosadd)&1023]=sin[(i*2+1-cosadd)&1023]=(int)(x/2);
- sin8[i*2]=sin8[i*2+1]=(x/512)+64;
- //sin8a[i*2]=sin8a[i*2+1]=(x/1024);
-
- _ECX=xc;
- _EAX=x;
- I cdq
- I shld EAX,EDX,16 // THIS CODE SUCKS!! optimized sin routine? :)
- I shr ecx,16 // hahah hahha :)
- I or eax,ecx
- I idiv dword ptr AA
-
- I sub vc,edx
- I sbb v,eax
- _EAX=vc;
- _EDX=v;
- I add xc,eax
- I adc x,edx
- }
- }
-
-
- void rotzoom(int frame,int plane)
- {
- int iszbuffer=0,scale;
- int x1=0,y1=0,x2=0,y2=0,x3=0,
- y3=0,x4=0,y4=0,mdx1=0,mdy1=0,mdx2=0,mdy2=0,y=0,vx=0,
- vy=0,qdx=0,qdy=0,mx1=0,my1=0,mx2=0,my2=0;
- int scry=50;
- int scrx=80;
- int scrxadd=2;
- int scrxo=160;
- int addx,addy;
- static int rotownframe=0,ownangle=0,ownangle1=0,ownangle2=0, speed=2;
- static int addx1=0,addy1=0,addx2=0,addy2=0;
- static int rotplane1,rotplane2;
- unsigned char _seg *dbuffer=(unsigned char _seg *)0xb800;
- //int mem1=0x0;
- //int mem2=0x0; /* segments */
-
- rotplane1++;
- rotplane2-=2;
-
- // PICTURE MUST HAVE WIDTH OF 256!!!!!
-
- // bigscale=3;
-
- //(ownframe<<2);
-
- if (iszbuffer) {
- } else {
- //xaddspeed++;
-
- if (plane) rotownframe=rotplane1; else rotownframe=rotplane2;
- if ((frame&0x1)==0) speed++;
- scale=(sin[(rotownframe<<2)&1023]/120)+160; //148;//+256+128+32;
- _DI=(int)(scrxo*scry-1-plane);
- }
-
- if (plane)
- { addx1+=1; addx=addx1; addy=addy1; }
- else
- { addx2+=1;
- addx=addx2; addy=addy2; }
- speed=25;
- ownangle1+=speed*2;
- ownangle2-=speed;
- if (plane==1) { ownangle=ownangle1; } else { ownangle=ownangle2; }
- //ownangle+=40;
- x1=(sin[(((ownangle>>3))+cosadd*0 )&1023]>>4);
- y1=(sin[(((ownangle>>3))+cosadd*0+cosadd)&1023]>>4);
- x2=(sin[(((ownangle>>3))+cosadd*3 )&1023]>>4);
- y2=(sin[(((ownangle>>3))+cosadd*3+cosadd)&1023]>>4);
- x3=(sin[(((ownangle>>3))+cosadd*1 )&1023]>>4);
- y3=(sin[(((ownangle>>3))+cosadd*1+cosadd)&1023]>>4);
- x4=(sin[(((ownangle>>3))+cosadd*2 )&1023]>>4);
- y4=(sin[(((ownangle>>3))+cosadd*2+cosadd)&1023]>>4);
-
- mdx1=(x2-x1)>>2; mdy1=(y2-y1)>>2; // 3
- mdx2=(x4-x3)>>2; mdy2=(y4-y3)>>2;
-
- mx1=(x1)*16; my1=(y1)*16; // 25
- mx2=(x3)*16; my2=(y3)*16;
-
- _ES=(int)dbuffer;
- //scale=scale-(12-(frame>>6))*25;
- for (y=0;y<scry;y++) {
-
-
- mx1+=mdx1; my1+=mdy1;
- mx2+=mdx2; my2+=mdy2;
-
- doline:
- vx=(mx1/scale+addx)*scrx; vy=(my1/scale+addy)*scrx; //320
- qdx=(mx2-mx1)/scale; qdy=(my2-my1)/scale;
-
- _CX=scrx;
-
- asm push ds
-
- if (plane) _DS=mem1; else _DS=mem2;
-
- if (!iszbuffer) {
-
- I mov ax,vy
- I mov dx,vx
- lineloop:
-
- I add ax,qdy
-
- I mov bl,ah
-
- I add dx,qdx
-
- I mov bh,dh
-
- I mov bl,ds:[bx]
- //asm and bl,0f0h
- // asm or bl,0fh
- I mov es:[di],bl
- I sub di,scrxadd
- //asm dec di new patch
-
- I dec cx
- I jnz lineloop
- //asm loop lineloop
- } else {
-
- }
-
- I pop ds
- }
- }
-
-
- void CALLING preVR(void)
- {
- frameCount++;
- }
-
- void MakePalette(void)
- {
- int i;
- inportb(0x3da);
- outportb(0x3c0,0x30);
- outportb(0x3c0,0x04);
-
- outportb(0x3c8,1);
-
- for(i=0;i<256;i++) {
- outportb(0x3c9,((i&7)*6));
- outportb(0x3c9,((i&7)*3));
- outportb(0x3c9,((i&7)*1));
- }
- //outportb(0x3c9,63);
- //outportb(0x3c9,0);
- //outportb(0x3c9,0);
-
- }
-
- void clearscreen1(int color)
- {
- int i,j;
- for (i=0;i<80;i++)
- {
- for (j=0;j<50;j++) {put_char(i,j,' ');put_color(i,j,color);}
- waittof();
-
- }
- }
- void clearscreen2()
- {
- int i,j,frame;
- for (frame=0;frame<150;frame++)
- {
- for (i=0;i<frame;i++)
- {
- for (j=49;j>0;j--)
- {
- put_char(i,j,read_char(i,j-1));
- put_color(i,j,read_color(i,j-1));
- }
- put_char(i,0,' ');
- put_color(i,j,0x10);
- }
- waittof();
- }
- }
-
-
- void MakePalette2(void)
- {
- int i;
- inportb(0x3da);
- outportb(0x3c0,0x30);
- outportb(0x3c0,0x04);
-
- outportb(0x3c8,1);
-
- for(i=0;i<256;i++) {
- outportb(0x3c9,((i&7)*0));
- outportb(0x3c9,((i&7)*6));
- outportb(0x3c9,((i&7)*8));
- }
- //outportb(0x3c9,63);
- //outportb(0x3c9,0);
- //outportb(0x3c9,0);
-
- }
-
- int mand_point(int x, int y, int x2, int y2, int maxiter, int max)
- {
- int i;
- int x1=x, y1=y, xt1,yt1;
- int xt,yt;
-
- for (i=0;i<=maxiter;i++) // optimoi, jos on tarvetta
- {
- I mov ax,x1
- I mov bx,ax
- I imul bx
- I mov xt1,dx
- I sar ax,11
- I sal dx,5
- I add ax,dx
- I mov xt,ax // xt1=(x1*x1)>>16, xt=x1*x1>>11
-
- I mov ax,y1
- I mov bx,ax
- I imul bx
- I mov yt1,dx
- I sar ax,11
- I sal dx,5
- I add ax,dx
- I mov yt,ax // yt=y1*y1>>16 , yt=y1*y1 >> 11
-
- I mov ax,x1
- I sar ax,5
- I mov bx,y1
- I sar bx,5
- I mul bx
- I add ax,y2
- I mov y1,ax // y1=x1>>5 * y1>>5 + y
-
- I mov ax,xt
- I sub ax,yt
- I add ax,x2
- I mov x1,ax // x1= xt - yt + x
-
- if ( xt1 + yt1 > max ) break;
- }
- return i-1;
- }
-
-
-
- void calcmand(char _seg *addr) {
- int x,c,d,precount;
- for(precount=0;precount<=128;precount++) {
- for(x=0;x<256;x++) {
- c=(x-170)*25; //c=(x-170)*25;
- d=(precount-128)*25;
- //*(scroff+x+(precount*320))=
- *((char _seg *)addr+precount+(x<<8)+128+32768U)=
- *((char _seg *)addr+(255-precount)+((x)<<8)+128+32768U)=
- (mand_point(c,d,c,d,40,0x3000))*2+1;
- }
- }
- }
-
-
- void setmode(void)
- {
- _AX=0x3;geninterrupt(0x10);
- _AH=0x12; _BL=0x30; _AL=2; geninterrupt(0x10);
- _AH=0x11; _AL=2; _BL=0; geninterrupt(0x10);
-
- // if ( (error = tmrGetScrSync(&sync)) != OK )
- // midasError(error);
-
-
- asm {
- mov dx,3d4h
- mov al,09h
- out dx,al
- inc dx
- in al,dx
- and al,01100111b
- or al,00000111b
- out dx,al
-
- dec dx
- mov al,0ah
- out dx,al
- inc dx
- mov al,2
- out dx,al
- dec dx
- mov al,0bh
- inc dx
- in al,dx
- and al,11100000b
- or al,5
- out dx,al
- }
- _setcursortype(_NOCURSOR);
- }
-
- void codechars(char _seg *addr) {
-
- unsigned int a=65535U;
- /* 0123456789012345*/
- char *table="-o$&O@#░▒▓█ ";
-
- while(a!=0) {
- addr[a]=table[addr[a]>>3];
- a--;
- }
- addr[a]=table[addr[a]>>3];
- }
-
- void water(char _seg *dbuffer);
-
- void setframe(unsigned char far *,int plcx, int plcy,unsigned int backcolor);
- void settext(char *);
-
- extern unsigned char FRAME_PIC[];
- extern void credits();
-
- void main (void)
- {
- int i;
- char _seg *scr=(char _seg *)0xb800;
- mpModule *module;
-
- midasSetDefaults();
- midasConfig();
-
- midasInit();
-
- // if ( (error = tmrSyncScr(sync, preVR, NULL, NULL)) != OK )
- // midasError(error);
-
- module = midasLoadModule("shot.mod", &mpMOD, NULL);
- midasPlayModule(module, 0);
-
- shade(0x3f,0,-1);
- _setcursortype(_NOCURSOR);
- textbackground(0);
- textcolor(14);
- setmode();
- logo_color();
-
- mem1=FP_SEG(farmalloc(65535U));
- assert(mem1);
- mem2=FP_SEG(farmalloc(65535U));
- assert(mem2);
-
- calcmand((char _seg *)mem1);
- calcmand((char _seg *)mem2);
- codechars((char _seg *)mem1);
-
- optimized_sin();
- //printf("Setting screen mode");
- //setmode();
- //shade(0,0x3f,1);
- delay(15000);
-
- poispois();
- setmode();
- textbackground(0x0);
- textcolor(15);
- clrscr();
-
- settext(" Single plane "
- " text mode "
- " fractal rotate "
- " zoomer ");
- for(i=0;i<1000 && !kbhit();i++) {
- rotzoom(i,1);
- //rotzoom(i,0);
- setframe((unsigned char far *)MK_FP(0xb800,0),(i/8<40)?i/8-40:0-((i>500)?(i-500)/8:0),15,0x0f);
-
- waittof();
- if ((inport(0x60)&0x7f)==1) goto cleanup;
- }
- while (kbhit()) getch();
-
- poispois();
- setmode();
-
- settext(" "
- " Water "
- " Interference "
- " "
- );
- for(i=0;i<1000 && !kbhit();i++) {
- water((char _seg *)0xb800);
-
- setframe((unsigned char far *)MK_FP(0xb800,0),100-i/8,35,0x0f);
- waittof();
- if ((inport(0x60)&0x7f)==1) goto cleanup;
- }
- while (kbhit()) getch();
- clearscreen1(0x60);
- MakePalette();
- for(i=0;i<80*50;i++) {
- scr[i*2]=176;
- scr[i*2+1]=2;
- }
-
- settext(" Dual-plane rotate"
- " zoomer with "
- " fractal "
- " mapping ");
- for(i=0;i<1000 && !kbhit();i++) {
- rotzoom(i,1);
- rotzoom(i,0);
- setframe((unsigned char far *)MK_FP(0xb800,0),(i/8<40)?i/8-40:0-((i>500)?(i-500)/8:0),38,0x10);
- waittof();
- if ((inport(0x60)&0x7f)==1) goto cleanup;
- }
- while (kbhit()) getch();
-
- clearscreen2();
- MakePalette2();
-
- settext(" Genuine TORUS "
- "with depth shading"
- " and texture "
- " pattern ");
- for (i=0;i<980 && !kbhit();i++) {
- if ((inport(0x60)&0x7f)==1) goto cleanup;
- extern unsigned char buffer[];
- setframe(buffer,i/4-40,15,0x10);
- rotating_torus(i);
- }
-
- cleanup:
- midasStopModule(module);
- midasFreeModule(module);
- midasClose();
- while (kbhit()) getch();
- delay(100);
-
- setmode();
- credits();
-
- };
-
-
- #define FRAME_PIC_WIDTH 20
- #define FRAME_PIC_DEPTH 6
- #define FRAME_PIC_LENGTH 240
- unsigned char FRAME_PIC [] = {
- '┌', 0x0F, '─', 0x0F, '─', 0x0F, '─', 0x0F, '─', 0x0F, '─', 0x0F,
- '─', 0x0F, '─', 0x0F, '─', 0x0F, '─', 0x0F, '─', 0x0F, '─', 0x0F,
- '─', 0x0F, '─', 0x0F, '─', 0x0F, '─', 0x0F, '─', 0x0F, '─', 0x0F,
- '─', 0x0F, '┐', 0x0F, '│', 0x0F, ' ', 0x0F, ' ', 0x0F, ' ', 0x0F,
- ' ', 0x0F, ' ', 0x0F, ' ', 0x0F, ' ', 0x0F, ' ', 0x0F, ' ', 0x0F,
- ' ', 0x0F, ' ', 0x0F, ' ', 0x0F, ' ', 0x0F, ' ', 0x0F, ' ', 0x0F,
- ' ', 0x0F, ' ', 0x0F, ' ', 0x0F, '│', 0x0F, '│', 0x0F, ' ', 0x0F,
- ' ', 0x0F, ' ', 0x0F, ' ', 0x0F, ' ', 0x0F, ' ', 0x0F, ' ', 0x0F,
- ' ', 0x0F, ' ', 0x0F, ' ', 0x0F, ' ', 0x0F, ' ', 0x0F, ' ', 0x0F,
- ' ', 0x0F, ' ', 0x0F, ' ', 0x0F, ' ', 0x0F, ' ', 0x0F, '│', 0x0F,
- '│', 0x0F, ' ', 0x0F, ' ', 0x0F, ' ', 0x0F, ' ', 0x0F, ' ', 0x0F,
- ' ', 0x0F, ' ', 0x0F, ' ', 0x0F, ' ', 0x0F, ' ', 0x0F, ' ', 0x0F,
- ' ', 0x0F, ' ', 0x0F, ' ', 0x0F, ' ', 0x0F, ' ', 0x0F, ' ', 0x0F,
- ' ', 0x0F, '│', 0x0F, '│', 0x0F, ' ', 0x0F, ' ', 0x0F, ' ', 0x0F,
- ' ', 0x0F, ' ', 0x0F, ' ', 0x0F, ' ', 0x0F, ' ', 0x0F, ' ', 0x0F,
- ' ', 0x0F, ' ', 0x0F, ' ', 0x0F, ' ', 0x0F, ' ', 0x0F, ' ', 0x0F,
- ' ', 0x0F, ' ', 0x0F, ' ', 0x0F, '│', 0x0F, '└', 0x0F, '─', 0x0F,
- '─', 0x0F, '─', 0x0F, '─', 0x0F, '─', 0x0F, '─', 0x0F, '─', 0x0F,
- '─', 0x0F, '─', 0x0F, '─', 0x0F, '─', 0x0F, '─', 0x0F, '─', 0x0F,
- '─', 0x0F, '─', 0x0F, '─', 0x0F, '─', 0x0F, '─', 0x0F, '┘', 0x0F};
-
-
- void settext(char *text) {
- char *frame=FRAME_PIC;
- int x,y;
- for(y=1;y<5;y++)
- for(x=1;x<19;x++) {
- frame[y*40+x*2]=*text++;
- }
- }
-
-
- void setframe(unsigned char far *screen,int plcx, int plcy,unsigned int backcolor) {
- int x,y,width=20,height=6;
- char *frame=FRAME_PIC;
- for(y=0;y<height;y++) {
- for(x=0;x<width;x++,frame+=2) {
- if (!((plcx+x)<0||(plcy+y)<0||(plcx+x)>79||(plcy+y)>49))
- *((unsigned int far *)screen+ (plcx+x)+(plcy+y)*80)=*frame+(backcolor<<8);//(*(frame+1)<<8);
- }
- }
- }
-
-
-
- //void scrollline(char *text, int areawidth, int xpos, int ypos, int curplc)
- //{
- // char buf[180];
- // buf[0]=0;
- // if (curplc<0) {
- // int i;
- // for (i=0;i<-curplc;i++) buf[i]=' ';
- // buf[i]=0;
- // }
- // if (curplc>strlen(text)) curplc=strlen(text);
- // gotoxy(xpos,ypos);
- // strncat(buf,text+((curplc>0)?curplc:0),(curplc<0)?areawidth+curplc:areawidth);
- // buf[areawidth]=0;
- // cputs(buf);
- //}
-
- void wwaittof(int count)
- {
- int i;
- for (i=0;i<count;i++) waittof();
- }
-
- void credits(void)
- {
- lastpage();
- getch();
- _AX=3;
- geninterrupt(0x10);
- printf("Thanks for watching Paranoids ASCII demo!\n\n");
- }
-
-
-