home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
d
/
dmenu1.zip
/
DM10SRC.ZIP
/
SETUP.C
< prev
Wrap
Text File
|
1991-10-15
|
8KB
|
333 lines
/***************************************************************************/
void Break_Off(void)
{
_asm push ds
_asm push cs
_asm pop ds
_asm mov dx, offset DUMMY_IRET
_asm mov ah,25h ; DOS Function 25 - set interrupt vector
_asm mov al,23h ; Select interrupt 23H
_asm int 21h
_asm pop ds
return;
DUMMY_IRET:
_asm mov ah,02;
_asm sub bh,bh;
_asm sub dx,dx;
_asm int 10h;
_asm iret
}
/****************************************************************************/
void Monochrome_Defaults()
{
color_monitor = NO;
default_palette = 8;
header_palette = 9;
error_palette = 9;
message_palette = 9;
backdrop_color = 7;
footer_color = 15;
}
/***************************************************************************/
void Get_Video_Info()
{
color_monitor = YES;
default_palette = 0;
header_palette = 1;
error_palette = 2;
message_palette = 3;
backdrop_color = 19;
footer_color = 31;
_asm mov ax, 1a00h
_asm int 10h
_asm cmp ah,1ah
_asm jne not_vga_or_mcga_or_ps
_asm and ah,01h
_asm je find_video_start
Monochrome_Defaults();
goto find_video_start;
not_vga_or_mcga_or_ps:
_asm mov ah, 12h
_asm mov bl, 10h
_asm int 10h
_asm cmp bl,10h
_asm jne find_video_start
_asm cmp bh,01h
_asm jne find_video_start
Monochrome_Defaults();
find_video_start:
video_start = (int far * ) 0xb8000000;
_asm mov ax,0F00h;
_asm int 10h;
_asm cmp al,07h;
_asm jne find_video_dimensions
video_start = (int far * ) 0xb0000000;
Monochrome_Defaults();
find_video_dimensions:
max_screen_y = *((char far *) 0x00400084L);
max_screen_x = *((char far *) 0x0040004AL);
if (max_screen_y == 0){
max_screen_x = 80;
max_screen_y = 24;
}
}
/***************************************************************************/
void Display_Title_Screen()
{
Fill_Screen(' ',7);
if (first_run){
Put_Cursor(0,7);
puts("\t\t\tWelcome to DougMenu. (c) Copyright 1991\n\n");
puts("This program is freeware product, and is to be distributed at no charge.\n\n");
puts("\t\tSee the file 'TERMS' for the terms of usage.");
}
}
/***************************************************************************/
void Set_Up_Enviroment()
/* this routine changes the enviroment var's as needed and gets the path
of the temporary batch file from there */
{
char temp_bat_ext[] = ".BAT";
long int psp_segment;
long int env_segment;
int far *ptr;
char far *cptr;
byte i;
_asm mov ax,6200h
_asm int 21h
_asm mov psp_segment,bx;
/* go to the oldest enviroment space */
while (ptr !=(ptr = (int far *) ((psp_segment << 16) + 0x16)));
psp_segment = *ptr;
ptr = (int far *) ((psp_segment << 16) + 0x2c);
env_segment = *ptr;
cptr = (char far *) (env_segment <<16);
/* find proper entry */
while ( *cptr != 0 || *(cptr+1) != 'T' || *(cptr+2) != '='){
if ( *cptr == 0 && *(cptr+1) ==0)
Critical_Error(ENVIROMENT,"Missing 'T' enviroment variable");
cptr++;
}
cptr +=3;
temp_bat = cptr;
while (*cptr != '\0')
cptr++;
cptr--;
if (*cptr != 'T') first_run = YES;
cptr-=3;
if ( *cptr != '.')
Critical_Error(ENVIROMENT,"Improper enviroment variable");
/* fill in name at the end of the path */
for (i=3;i>0;i--)
*(cptr+i) = temp_bat_ext[i];
}
/***************************************************************************/
void Set_Up_Mouse()
{
int max_x,max_y;
max_x = (max_screen_x -1 ) * 8;
max_y = max_screen_y * 8;
_asm sub ax,ax /* intitalize mouse */
_asm int 33h
_asm mov dx,max_x /* Pixels horizontally */
_asm mov ax,7 /* mouse driver function 7 -- set max x range */
_asm sub cx,cx /* Minimum range */
_asm int 33h
_asm mov dx,max_y /* Pixels veritcally */
_asm mov ax,8 /* mouse driver function 8 -- set max y range */
_asm sub cx,cx /* Minimum range */
_asm int 33h
_asm mov ax,4 /* set current mouse position 0,0 */
_asm sub bx,bx
_asm sub cx,cx
_asm sub dx,dx
_asm int 33h
Hide_Mouse();
}
/***************************************************************************/
void Draw_Backdrop(void)
{
FILE *Backdrop;
register char ch;
Fill_Screen(backdrop_char,backdrop_color);
if (backdrop_file[0] != '\0'){
if ( ( Backdrop = fopen(backdrop_file, "r" ) ) != NULL ){
ch = getc(Backdrop);
while ( ch != EOF)
putchar( ch = getc(Backdrop) );
fclose(Backdrop);
}
}
}
/***************************************************************************/
void Draw_Header()
{
char title[] = " DougMenu v1.0";
byte x;
byte back = palette[header_palette][ BACK ] << 4;
byte text = palette[header_palette][ TEXT ] | back;
byte border = palette[header_palette][ HIGHLIGHT ] | back;
/* draw top */
x=0;
Draw(x, 0, '┌', border);
for (x++; x < (byte)(max_screen_x-1); x++)
Draw(x, 0, '─', border);
Draw(x, 0,'┐', border);
/* draw filling */
x=0;
Draw(x++, 1, '│', border);
while (title[x] != '\0')
Draw(x++,1,title[x],text);
while (x< (byte)(max_screen_x-1) )
Draw(x++, 1, ' ', text);
Draw(x, 1, '│', border);
/* draw bottom */
x = 0;
Draw(x, 2, '└', border);
for(x++; x < (byte)(max_screen_x-1); x++)
Draw(x, 2, '─', border);
Draw(x, 2, '┘', border);
Update_Time();
}
/***************************************************************************/
void Draw_Footer()
{
register byte x,i,ch;
x=0;
for ( i=1; i < 11 ; i++){
if (function_key[i] != NULL){
Draw (x++,max_screen_y,' ',footer_color);
Draw (x++,max_screen_y,'F',footer_color);
if ( i == 10 ){
Draw (x++,max_screen_y,'1',footer_color);
Draw (x++,max_screen_y,'0',footer_color);
}
else
Draw (x++,max_screen_y,(byte)(i+48),footer_color);
Draw (x++,max_screen_y,'=',footer_color);
Draw (x++,max_screen_y,' ',footer_color);
ch =0;
while ( function_key[i]->title[ch] != '\0' )
Draw (x++,max_screen_y,function_key[i]->title[ch++],footer_color);
function_key[i]->title_length = x;
Draw (x++,max_screen_y,' ',footer_color);
}
}
if (x > 0){
while (x < max_screen_x)
Draw (x++,max_screen_y,' ',footer_color);
}
}
/***************************************************************************/
void Set_Up_Screen()
{
char temp_line[MAX_LINE];
register byte ch;
FILE *Old_Bat;
char old_bat[MAX_FILE_NAME];
temp_line[0] = '\n';
if (!first_run){
/* read enviroment variable */
for (ch=0; *(temp_bat+ch) != '\0';ch++)
old_bat[ch] = *(temp_bat+ch);
old_bat[ch]='\0';
if ( ( Old_Bat = fopen(old_bat, "r" ) ) != NULL ){
while ( ch = getc(Old_Bat) != ':' && ch != EOF);
if (ch != EOF)
fscanf(Old_Bat,"%s\n",temp_line);
fclose(Old_Bat);
}
}
remove(old_bat);
Draw_Backdrop();
Draw_Header();
Draw_Footer();
if (shadow){
shad_buf = (byte *) malloc ( max_screen_x + max_screen_y );
}
win_index = 255; /* we are now at the -1st menu */
if (!Windowfy_Menu(first_menu))
Critical_Error(DISPLAY,NULL);
if (temp_line[0] != '\n') for(;;){
Win[win_index].item = current_item = Number_To_Item( (byte) (temp_line[(win_index*2)] - 64) );
Display_Menu(current_item);
ch = temp_line[(win_index*2)+1];
if ( ch == DO_ITEM+64)
Win[win_index].event = DO_ITEM;
else if ( ch >= FUNCTION_KEY+64){
Win[win_index].event = ch - 64;
current_item = function_key[ch-FUNCTION_KEY-64];
}
else break;
if( current_item->first_line->text_line[0] != '%' ||
!Windowfy_Menu( Find_Menu( current_item->first_line->text_line ) ) )
break;
}
Display_Menu(NULL);
Select(current_item);
}