Files
lba1-classic/SOURCES/FLIPBOX.C
Gwen Gourevich c5f4f6ba25 Initial commit
2021-10-27 10:34:18 +02:00

141 lines
2.9 KiB
C
Raw 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.
#include "defines.h"
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*
Ûßßßß Û Û ÛßßßÛ ÛßßÛ ÛßßßÛ ßÜ Üß
ÛÛßß ÛÛ ÛÛ ÛÛßßß ÛÛßßÛ ÛÛ Û ÜßÜ
ßß ßßßßß ßß ßß ßßßßß ßßßßß ßßßßß ß ß
*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
extern UBYTE *Screen ; /* background clean */
typedef struct
{
WORD x0 ;
WORD y0 ;
WORD x1 ;
WORD y1 ; } T_PHYSBOX ;
T_PHYSBOX NewListBox[MAX_OBJETS+MAX_EXTRAS] ;
T_PHYSBOX OptListBox[(MAX_OBJETS+MAX_EXTRAS)*2] ;
WORD NbPhysBox = 0 ;
WORD NbOptPhysBox = 0 ;
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
void AddOptBox( WORD x0, WORD y0, WORD x1, WORD y1 )
{
T_PHYSBOX *ptr ;
WORD cx0, cy0, cx1, cy1 ;
WORD n ;
LONG totalsurface ;
LONG surfacecommune ;
LONG surfacetest ;
surfacetest = (x1-x0) * (y1-y0) ;
ptr = OptListBox ;
for( n=0; n<NbOptPhysBox; n++, ptr++ )
{
cx0 = min(ptr->x0,x0) ;
cx1 = max(ptr->x1,x1) ;
cy0 = min(ptr->y0,y0) ;
cy1 = max(ptr->y1,y1) ;
surfacecommune = (LONG)(cx1-cx0) * (cy1-cy0) ;
totalsurface = surfacetest + (ptr->x1-ptr->x0) * (ptr->y1-ptr->y0) ;
if( surfacecommune < totalsurface )
{
ptr->x0 = cx0 ;
ptr->y0 = cy0 ;
ptr->x1 = cx1 ;
ptr->y1 = cy1 ;
return ;
}
}
ptr->x0 = x0 ;
ptr->y0 = y0 ;
ptr->x1 = x1 ;
ptr->y1 = y1 ;
NbOptPhysBox++ ;
}
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
void AddPhysBox( WORD x0, WORD y0, WORD x1, WORD y1 )
{
T_PHYSBOX *ptr ;
if( x0 < 0 ) x0 = 0 ;
if( x1 > 639 ) x1 = 639 ;
if( y0 < 0 ) y0 = 0 ;
if( y1 > 479 ) y1 = 479 ;
if( x1 < x0 ) return ;
if( y1 < y0 ) return ;
ptr = &NewListBox[NbPhysBox] ;
ptr->x0 = x0 ;
ptr->y0 = y0 ;
ptr->x1 = x1 ;
ptr->y1 = y1 ;
NbPhysBox++ ;
AddOptBox( x0, y0, x1, y1 ) ;
}
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
void FlipOptList()
{
WORD n ;
T_PHYSBOX *ptr ;
/* regenere optlistbox pour clear log
puis phys a la prochaine boucle*/
ptr = NewListBox ;
NbOptPhysBox = 0 ;
for( n=0; n<NbPhysBox; n++,ptr++ )
{
AddOptBox( ptr->x0, ptr->y0, ptr->x1, ptr->y1 ) ;
}
}
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
void FlipBoxes()
{
WORD n ;
T_PHYSBOX *ptr ;
/* copie liste optimise vers phys */
ptr = OptListBox ;
for( n=0; n<NbOptPhysBox; n++,ptr++ )
{
CopyBlockPhys( ptr->x0, ptr->y0, ptr->x1, ptr->y1 ) ;
}
FlipOptList() ;
}
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
void ClsBoxes()
{
WORD n ;
T_PHYSBOX *ptr ;
/* efface ecran logique (copy depuis Screen org) */
ptr = OptListBox ;
for( n=0; n<NbOptPhysBox; n++,ptr++ )
{
CopyBlock( ptr->x0, ptr->y0, ptr->x1, ptr->y1, Screen,
ptr->x0, ptr->y0, Log ) ;
/* Box( ptr->x0, ptr->y0, ptr->x1, ptr->y1, 0 ) ; */
}
}