CATALOGO/C_ANIMAC.CPP
2021-09-03 17:43:05 +02:00

263 lines
6.7 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

///////////////////////////////////////////////////////////////////////////
///// Nombre: C_Animac.CPP ///
///// Modulo: Perteneciente a Catalogo.C ///
//// Descripci¢n: Animaci¢n escondida para CATALOGO v4.0 ///
//// ///
//// Autor: Jos David Guilln Dominguez ///
//// Fecha: 23 - 07 - 1994 ///
//// ///
//// Compilador Borland C++ 3.0 ///
///////////////////////////////////////////////////////////////////////////
#include <dos.h>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <graphics.h>
//////////////////////// DECLARACIONES DE FUNCIONES //////////////////////////
int Animacion(void);
extern void BorraViewPort(int view);
extern int sb;
extern int raton;
extern void Sound_SN(char headfile[]);
void lee_ficheros_v(char *j, char *d1, char *d2);
void Lluvia_Dibujo2(char *J);
void Disparos_D_(char *d1, char *d2);
void Disparo(int x, int y, char *d);
// ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
// ±ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ±
// ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
int Animacion(void)
{
union REGS ent, sal;
int OK_NO = 1;
char *j; // J[81][116] // |
char *d1; // Disparo1[20][20] // |- Punteros a las imagenes
char *d2; // Disparo2[20][20] // |
if( (j = (char *)malloc(9600)) != NULL) // |
if( (d1 =(char *)malloc(400)) == NULL) // |- Pide memoria para la Animaci¢n
free(j); else // |
if( (d2 =(char *)malloc(400)) == NULL) // |
{ free(j); free(d1); } else { // |
BorraViewPort(2); // Limpia el VIEW PORT
lee_ficheros_v(j, d1, d2); // Lee la J, y los disparos
Lluvia_Dibujo2(j); // Muestra la J, en forma de FASERS
Disparos_D_(d1, d2); // Realiza los disparos de la D
int b_izq;
do{
if(raton){
ent.x.ax = 3;
int86(0x33, &ent, &sal); // lee posici¢n y estados del bot¢n
b_izq = sal.x.bx & 1;
} else b_izq = 0;
}while( !b_izq && !kbhit() );
// FIN, si se pulsa un boton
free(j); // |
free(d1); // |- Libera la memoria asignada
free(d2); // |
OK_NO = 0; // Todo va bien
}
BorraViewPort(2); // Limpia el View Port
return OK_NO; // Devuelve todo va bien=0 o NO=1
}
// ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
// ±ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ±
// ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
void lee_ficheros_v(char *j, char *d1, char *d2)
{
long tam=0; // | tama¤o de fichero recorrido
unsigned char byte; // | byte obtenido del fichero
int columnas = 0, filas = 0; // | columnas y filas descomprimidas
int contador; // | contador de descompresi¢n
char *Js; // |
char *D1s; // |-Punteros a las imagenes
char *D2s; // |
Js = j; D1s = d1; D2s = d2;
FILE *dbs; // Corriente al archivo
if((dbs = fopen("CATALOG0.IMG", "rb"))==NULL) {
exit(1);
}
while(!feof(dbs) && filas<=121) {
if(tam>=128) {
columnas=0;
while(columnas<=181) {
byte=(unsigned)getc(dbs);
if(byte<=192) {
/////// J ////////
if (columnas>= 0 && columnas<= 81 && filas>= 0 && filas<=116) *Js++ = byte;
/////// Disparo 1 /////
if (columnas>=89 && columnas<=107 && filas>= 4 && filas<= 21) *D1s++ = byte;
/////// Disparo 2 /////
if (columnas>=89 && columnas<=107 && filas>=30 && filas<= 47) *D2s++ = byte;
columnas++;
} else {
contador=byte&63;
byte=getc(dbs);
for(;contador>0;contador--) {
///// J ////////
if (columnas>= 0 && columnas<= 81 && filas>= 0 && filas<=116) *Js++ = byte;
///// Disparo 1 /////
if (columnas>=89 && columnas<=107 && filas>= 4 && filas<=21) *D1s++ = byte;
///// Disparo 2 /////
if (columnas>=89 && columnas<=107 && filas>=30 && filas<=47) *D2s++ = byte;
columnas++;
}
}
}
filas++;
} else {
getc(dbs);
tam++;
}
}
fclose(dbs);
}
// ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
// ±ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ±
// ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
void Lluvia_Dibujo2(char *J) {
int t, i, j;
char *Js;
Js = J;
setcolor(0); setfillstyle(0, 0);
for(i=0; i<=116; i++)
for(j=0; j<=81; j++) {
setcolor( *Js++ );
line(j + 345, i + 40, 40 + 345 /*- j*/, 116 +40);
}
}
// ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
// ±ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ±
// ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
void Disparos_D_(char *d1, char *d2){
int i;
int k=0;
for(i=0; i<=5; i++) {
if (k==1) {
Disparo(125 - k, 0 + i*18, d2);
k=0;
if (sb!=0) Sound_SN("catalogD");
} else {
Disparo(125 + k, 0 + i*18, d1);
k=1;
if (sb!=0) Sound_SN("catalogD");
}
delay(50);
}
Disparo(145, 0, d2);
delay(50);
if (sb!=0) Sound_SN("catalogD");
Disparo(161 + 0 * 18, 0 + 0*18, d1);
if (sb!=0) Sound_SN("catalogD");
delay(50);
Disparo(161 + 1 * 18, 0 + 1*18, d1);
if (sb!=0) Sound_SN("catalogD");
delay(50);
Disparo(161 + 2 * 15, 0 + 2*18, d1);
if (sb!=0) Sound_SN("catalogD");
delay(50);
Disparo(161 + 2 * 15, 0 + 3*18, d1);
if (sb!=0) Sound_SN("catalogD");
delay(50);
Disparo(161 + 1 * 18, 0 + 4*18, d1);
if (sb!=0) Sound_SN("catalogD");
delay(50);
Disparo(161 + 0 * 18, 0 + 5*18, d1);
if (sb!=0) Sound_SN("catalogD");
delay(50);
Disparo(143, 0 + 5*18, d1);
if (sb!=0) Sound_SN("catalogE");
delay(50);
}
// ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
// ±ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ±
// ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
void Disparo(int x, int y, char *d){
char *Ds;
Ds = d;
x += 335;
y += 40;
for(int y1=0; y1<=17; y1++)
for(int x1=0; x1<=18; x1++)
putpixel(x+ x1, y+ y1, *Ds++);
}