COMPACTA/BROWSER.CPP
2021-09-03 17:51:51 +02:00

306 lines
8.5 KiB
C++
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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.

#include <ctype.h>
#include <direct.h>
#include <stdlib.h>
#include <stdio.h>
#include <dir.h>
#include <dos.h>
#include <string.h>
#include <alloc.h>
#include <conio.h> // Para getch();
#include <graphics.h> // Para outtextxy(...); y cleardevice(...);
#include "..\..\jd_lib\f_lib\make_bot.h" // Fuciones de MAKE_BOTON
#define __Modulo_Browser
#include "compacta.h"
extern BROWSER far *Browser;
// ÛßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÛ
// ÛßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÛ
// ÛßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÛ
// ÛßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÛ
// ÛßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÛ
// Û F U N C I O N E S p a r a e l B R O W S E R Û
// ÛÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÛ
// ÛÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÛ
// ÛÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÛ
// ÛÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÛ
// ÛÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÛ
// ÛÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÛ
void ReDraw_Browser(void)
{
int OLD_Brw = BrowserRow;
// 1§ Borramos pantalla de muestreo...
setfillstyle( SOLID_FILL, EGA_BLACK );
setcolor( EGA_BLACK );
// Muestreo de archivos
bar( 9, 9, 153, 173 );
// 3§ Mostramos los nuevos Archivos
for ( BrowserRow = 0; BrowserRow < 16; BrowserRow++)
if ( ( BrowserRow + BrowserTop ) < maxfiles )
ShowHideBrowserRow( HIDE );
BrowserRow = OLD_Brw;
}
void Fill_Directory(void)
{
char Buffer[180];
// Recuadro del directorio
// 1§ Borramos pantalla de muestreo...
setfillstyle( SOLID_FILL, EGA_BLACK );
setcolor( EGA_BLACK );
bar( 5, 182, 179, 195 );
setcolor( EGA_YELLOW );
getcwd( Buffer, 180 );
if ( strlen( Buffer ) > 28 )
{
// Acorta el Buffer poniendo al principio U:\...[DIRECTORIO]
char Buffer1[30];
// Primero copiamos en Buffer1 los 22 ultimos caracteres de Buffer
strncpy( Buffer1, strrev(Buffer), 22 ); Buffer1[22] = NULL;
strrev( Buffer1 );
// Despues conservamos solo de Buffer [Und][:][\]
strrev(Buffer); Buffer[3] = NULL;
// Y agregamos [...]
strcat( Buffer, "..." );
// Ya podemos unirlo todo
strcat( Buffer, Buffer1 );
//
}
settextstyle( SMALL_FONT, HORIZ_DIR, 4 );
outtextxy( 7, 184, Buffer );
}
void ShowHideBrowserRow( char Hide_Show )
{
char Buffer[80];
char Longitud[80];
settextstyle( SMALL_FONT, HORIZ_DIR, 4 );
if ( Hide_Show == HIDE )
{
setfillstyle( SOLID_FILL, EGA_BLACK );
bar( 9, ( 10 + ( BrowserRow * 10 ) ), 153, ( ( 9 + 10 ) + ( BrowserRow * 10 ) ) );
switch( Browser[BrowserTop+BrowserRow].attrs )
{
case FA_DIREC:
setcolor( EGA_CYAN );
break;
case 255:
setcolor( EGA_MAGENTA );
break;
default:
setcolor( EGA_WHITE );
}
} else {
switch( Browser[BrowserTop+BrowserRow].attrs )
{
case FA_DIREC:
setfillstyle( SOLID_FILL, EGA_CYAN );
// setcolor( EGA_CYAN );
break;
case 255:
setfillstyle( SOLID_FILL, EGA_MAGENTA );
// setcolor( EGA_MAGENTA );
break;
default:
setfillstyle( SOLID_FILL, EGA_WHITE );
// setcolor( EGA_WHITE );
}
bar( 9, ( 10 + ( BrowserRow * 10 ) ), 153, ( ( 9 + 10 ) + ( BrowserRow * 10 ) ) );
setcolor( EGA_BLACK );
}
outtextxy( 10, ( 9 + ( BrowserRow * 10 ) ), Browser[BrowserTop+BrowserRow].Fichero );
formatea_long( Browser[BrowserTop+BrowserRow].Longitud, Longitud );
switch( Browser[BrowserTop+BrowserRow].attrs )
{
case FA_DIREC:
sprintf ( Buffer, " DIRECTORIO", Longitud );
break;
case 255:
sprintf ( Buffer, " < UNIDAD >", Longitud );
break;
default:
sprintf ( Buffer, " %10s", Longitud );
}
outtextxy( 10, ( 9 + ( BrowserRow * 10 ) ), Buffer );
}
void DownBrowser(void)
{
// ¨¨ Estoy en la linea fisica 000 ???
if ( (BrowserRow + BrowserTop) != (maxfiles - 1) ) {
// Linea 0, Baja Con retroceso multiple
if ( BrowserRow == 15 ) {
BrowserTop += 16;
if ( (BrowserTop + BrowserRow) > maxfiles ) BrowserRow = 0;
while ( (BrowserTop + BrowserRow) > maxfiles ) BrowserTop--;
BrowserRow = 0;
ReDraw_Browser();
ShowHideBrowserRow( SHOW );
} else {
ShowHideBrowserRow( HIDE );
BrowserRow++;
ShowHideBrowserRow( SHOW );
}
}
}
void UpBrowser(void)
{
// ¨¨ Estoy en la linea fisica 000 ???
if ( (BrowserRow + BrowserTop) != 0 ) {
// Linea 0, Baja Con retroceso multiple
if ( BrowserRow == 0 ) {
BrowserTop -= 16;
if ( BrowserTop < 0 ) BrowserTop = 0;
BrowserRow = 0;
ReDraw_Browser();
BrowserRow = 15;
ShowHideBrowserRow( SHOW );
} else {
ShowHideBrowserRow( HIDE );
BrowserRow--;
ShowHideBrowserRow( SHOW );
}
}
}
int SelectBrowser(void)
{
int RETURN = 1;
switch( Browser[BrowserTop+BrowserRow].attrs )
{
case FA_DIREC:
chdir( Browser[BrowserTop+BrowserRow].Fichero );
BrowserRow = BrowserTop = 0;
// 2§ Realizamos un Scaneo del Directorio
BrowserTop = 0; BrowserRow = 0;
RasterScan();
Fill_Directory();
ReDraw_Browser();
ShowHideBrowserRow( SHOW );
RETURN = 0;
break;
case 255:
erroroccurred=0;
olddisk=getdisk();
setdisk( (Browser[BrowserTop+BrowserRow].Fichero[0] - 'A') );
if (erroroccurred) {
setdisk(olddisk);
} else {
BrowserRow = BrowserTop = 0;
// 2§ Realizamos un Scaneo del Directorio
BrowserTop = 0; BrowserRow = 0;
RasterScan();
Fill_Directory();
ReDraw_Browser();
ShowHideBrowserRow( SHOW );
}
RETURN = 0;
break;
default:
RETURN = 1;
}
return RETURN;
}
unsigned int RasterScan(void) {
struct ffblk ffblk;
char done=0;
unsigned int olddisk;
maxfiles = 0;
unsigned char i;
// build a disk drive availiable list
olddisk=getdisk();
for (i=1;i<27;i++) if (_chdrive(i) == 0)
{
sprintf( Browser[maxfiles].Fichero, "%c:", (char)('A' + i - 1) );
Browser[maxfiles].Longitud=0;
Browser[maxfiles].attrs=255; // Unidad
if (ffblk.ff_attrib & 16) Browser[maxfiles].Longitud=0;
maxfiles++;
}
setdisk(olddisk);
// drivelist[2]='N'; //stop access to B drive until I sort out pahntom dive probs
//Ok, Drive B may be a phantom drive. If you try to access drive B, then
//the program looses controll. Bummer!
// needs debugging. (always ignores drive b...)
// asm int 0x11
// asm mov equipmentlist,ax
// drivelist[2]='N';
// if ((equipmentlist & 16)) drivelist[2]='Y';
done = findfirst("*.*",&ffblk,FA_DIREC);
while (!done) {
if (ffblk.ff_attrib == 0x10) {
strcpy(Browser[maxfiles].Fichero,ffblk.ff_name);
Browser[maxfiles].Longitud=ffblk.ff_fsize;
Browser[maxfiles].attrs=ffblk.ff_attrib;
if (ffblk.ff_attrib & 16) Browser[maxfiles].Longitud=0;
maxfiles++;
}
done = findnext(&ffblk);
if (maxfiles==200) done=!done; //stop to prevent internal crashes.
}
done = findfirst(Comodin,&ffblk,FA_DIREC);
while (!done) {
if (ffblk.ff_attrib != 0x10) {
strcpy(Browser[maxfiles].Fichero,ffblk.ff_name);
Browser[maxfiles].Longitud=ffblk.ff_fsize;
Browser[maxfiles].attrs=ffblk.ff_attrib;
if (ffblk.ff_attrib & 16) Browser[maxfiles].Longitud=0;
maxfiles++;
}
done = findnext(&ffblk);
if (maxfiles==200) done=!done; //stop to prevent internal crashes.
}
return maxfiles;
}
void interrupt critical_error_handler(.../*__CPPARGS*/) {
asm push ax //preserve only modified register
asm mov ax,di //di holds error code ranging from 0 to 0x0c
// asm inc ax
asm mov erroroccurred,ax //increase erroroccurred for ease of programming
asm mov al,0x20
asm out 0x20,al //send interrupt clear flag
// asm pushf // I think I dont need this line in....
asm pop ax //restore ax
}
void startceh() {
old_int24 = _dos_getvect( 0x24 );
_dos_setvect( 0x24, critical_error_handler);
}
void stopceh() {
_dos_setvect(0x24,old_int24);
}
ƒût÷ëƒût÷ûÃût÷눃ût÷ûÃ>ÿtTãRÿ6ž£°SèGQ2À¹è>t¡šÄèêY[&Š"Àt SQè`þY[CâíXPèê€>™t¡š†Äèäé<C3A4>žÃQèöýèè5Yá®