home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 9
/
FreshFishVol9-CD2.bin
/
bbs
/
util
/
superdark-2.1a.lha
/
SuperDark
/
programmer
/
prog
/
proc_main_debug.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-06-23
|
13KB
|
537 lines
#include <stdio.h>
#include <exec/types.h>
#include <exec/tasks.h>
#include <exec/ports.h>
#include <exec/memory.h>
#include <exec/tasks.h>
#include <graphics/displayinfo.h>
#include <graphics/displayinfo.h>
#include <graphics/gfxmacros.h>
#include <dos/dosextens.h>
#include <clib/exec_protos.h>
#include <hardware/custom.h>
#include <hardware/dmabits.h>
#include <intuition/intuitionbase.h>
#include <intuition/screens.h>
#include "/includes/struct.h"
#include "/includes/tom_gadget.h"
#ifndef custom
#define custom (*(struct Custom *)0xDFF000)
#endif /* custom */
#define DEF_MODE 0
#define DEF_MODE_NAME "HighRes"
static int s2depth,width,height;
struct my_data *p_info;
struct appel_proc *p_data_proc;
struct appel_proc data_proc;
struct BitMap b;
static struct Screen *s;
static struct Window *wnd;
static int flg_end=FALSE;
UWORD chip null_pointer[]={0,0,0,0,0,0};
struct IntuitionBase *IntuitionBase;
struct Library *GfxBase;
extern struct tom_gadget my_gadg[];
extern void __saveds dark();
extern void proc_init();
extern void proc_end();
extern char *p_text_info;
struct ExtNewScreen newscreen = {
0,0,0,0,0,0,0,NULL,CUSTOMSCREEN|CUSTOMBITMAP,NULL,(UBYTE *)" ",NULL,NULL
};
char pr_buff[100];
/* Note: The folloing SPrintF Routine is taken from the program "FracBlank " */
/* by: */
UWORD PutChar[2] = {0x16C0,0x4E75};
/* dirty hack to avoid assembler part :-)
16C0: move.b d0,(a3)+
4E75: rts
*/
#define VOID_STDARGS void __stdargs
/************************************************************************/
/* This exactly the same function than printf, but printf() can't be */
/* used in a blanker. Use the utility program show_info to see the result */
/* NOTE: Always use long with number, like %ld,%lx and NOT %x or %d */
/************************************************************************/
VOID_STDARGS SDprintf(char *FormatString,...)
{
char buffer[100];
if(hd){
RawDoFmt (FormatString,(APTR)((LONG *)&FormatString+1L),
(void *)PutChar,buffer);
MyWrite(buffer);
}
}
/************************************************************************/
/* Some variouse function used for debugging..use them at your own risk */
/* but do not use any printf function */
/************************************************************************/
VOID_STDARGS SPrintF(char *pr_buff,char *FormatString,...)
{
RawDoFmt (FormatString,(APTR)((LONG *)&FormatString+1L),
(void *)PutChar,pr_buff);
}
/************************************************************************/
mystrlen(char *pc)
{
int ret;
ret=0;
while(*pc++!=0){
ret++;
}
return ret;
}
/************************************************************************/
void MyWrite(char *pc)
{
if(hd!=0)Write(hd,pc,mystrlen(pc));
}
void My_Print(struct RastPort *rp,UWORD x,UWORD y,char *pc)
{
Move(rp,x,y);
Text(rp,pc,mystrlen(pc));
}
/****************************************************************/
/* This old function should not be used now... */
/****************************************************************/
int find_res(USHORT flg_depth,SHORT *p_depth,SHORT *p_tx,SHORT *p_ty,ULONG *p_d_id)
{
struct ModeNode *ModeNode;
struct ModeNode *ModeNodeFound;
ModeNode=(struct ModeNode *)p_data_proc->ml->lh_Head;
ModeNodeFound=ModeNode;
while (ModeNode->mn_Node.ln_Succ)
{
if(flg_depth){
if(*p_depth<ModeNode->MaxDepth){
*p_depth=ModeNode->MaxDepth;
if(*p_tx<=ModeNode->MaxX){
*p_tx=ModeNode->MaxX;
if(*p_ty<=ModeNode->MaxY){
*p_ty=ModeNode->MaxY;
}
}
ModeNodeFound=ModeNode;
}
}else{
if(*p_tx<=ModeNode->MaxX){
*p_tx=ModeNode->MaxX;
if(*p_ty<=ModeNode->MaxY){
*p_ty=ModeNode->MaxY;
if(*p_depth<ModeNode->MaxDepth){
*p_depth=ModeNode->MaxDepth;
}
}
ModeNodeFound=ModeNode;
}
}
ModeNode=(struct ModeNode *)ModeNode->mn_Node.ln_Succ;
}
*p_depth=ModeNodeFound->MaxDepth;
*p_tx=ModeNodeFound->MaxX;
*p_ty=ModeNodeFound->MaxY;
*p_d_id=ModeNodeFound->DisplayID;
return TRUE;
}
/********************************************************** get_modes() *****/
/********************************************************/
/* We get the current modes availables in this computer */
/********************************************************/
struct List *get_modes()
{
struct List *ModeList;
ULONG DisplayID;
struct DimensionInfo DimInfo;
struct NameInfo NameInfo;
struct ModeNode *ModeNode;
if (ModeList=AllocMem(sizeof(struct List),MEMF_PUBLIC)) NewList (ModeList);
else return NULL;
DisplayID=INVALID_ID;
while ((DisplayID=NextDisplayInfo(DisplayID))!=INVALID_ID){
if ((DisplayID&MONITOR_ID_MASK)&&(ModeNotAvailable(DisplayID)==0L)){
if (GetDisplayInfoData(NULL,(UBYTE *)&DimInfo,sizeof(struct DimensionInfo),
DTAG_DIMS,DisplayID)){
if (DimInfo.MaxDepth>1){
if (GetDisplayInfoData(NULL,(UBYTE *)&NameInfo,sizeof(struct NameInfo),
DTAG_NAME,DisplayID)){
if (ModeNode=AllocMem(sizeof(struct ModeNode),MEMF_PUBLIC))
{
ModeNode->MaxDepth=DimInfo.MaxDepth;
ModeNode->MinX=DimInfo.Nominal.MinX+1;
ModeNode->MaxX=DimInfo.Nominal.MaxX+1;
ModeNode->MinY=DimInfo.Nominal.MinY+1;
ModeNode->MaxY=DimInfo.Nominal.MaxY+1;
(void)strcpy(ModeNode->Name,
NameInfo.Name);
ModeNode->mn_Node.ln_Name=ModeNode->Name;
ModeNode->DisplayID=DisplayID;
printf("%20s ",NameInfo.Name);
printf("M.depth:%d mx:%02d my:%02d MX:%03d MY:%03d ",DimInfo.MaxDepth,
DimInfo.Nominal.MinX,
DimInfo.Nominal.MinY,
DimInfo.Nominal.MaxX,
DimInfo.Nominal.MaxY);
printf("Flags:%lx\n",ModeNode->DisplayID);
AddTail (ModeList,&ModeNode->mn_Node);
}
}
}
}
}
}
if (ModeList->lh_Head->ln_Succ==NULL)
if (ModeNode=AllocMem(sizeof(struct ModeNode),MEMF_PUBLIC))
{
(void)strcpy(ModeNode->Name,
DEF_MODE_NAME);
ModeNode->mn_Node.ln_Name=ModeNode->Name;
ModeNode->DisplayID=DEF_MODE;
ModeNode->MaxX=640;
ModeNode->MaxY=256;
ModeNode->MaxDepth=4;
AddTail (ModeList,&ModeNode->mn_Node);
}
else
{
FreeMem ((APTR)ModeList,sizeof(struct List));
return NULL;
}
return ModeList;
}
/************************************************************* free_modes() */
/***********************************************/
/* We delete the liste of the available modes */
/***********************************************/
void free_modes(struct List *ModeList)
{
struct ModeNode *ModeNode;
while (ModeList->lh_Head->ln_Succ){
ModeNode=(struct ModeNode *)ModeList->lh_Head;
RemHead (ModeList);
FreeMem ((APTR)ModeNode,sizeof(struct ModeNode));
}
FreeMem ((APTR)ModeList,sizeof(struct List));
}
/*******************************************************************/
/* This function is used instead of CloseScreen, because if we are */
/* in the random mode, we don't close immediatly the screen, but */
/* we give it back to superdark, so he can use it to create next */
/* screen */
/*******************************************************************/
DCloseScreen(struct Screen *s)
{
if(s){
while(s->FirstWindow)CloseWindow(s->FirstWindow);
CloseScreen(s);
}
}
/*******************************************************************/
int blank()
{
int i,col;
struct Screen *s2;
struct ViewPort *vp2;
static struct TagItem screen_item[2]={{SA_DisplayID,0},TAG_END};
/* We set the sprite off, with 2 different methodes: */
/* Software (not always work) and Hardware (tricky..) */
/*
if (my_gadg[GID_SPRITE].value){
*/
OFF_SPRITE
for (i=0L; i<8L; i++){
custom.spr[i].ctl=0;
}
/*
}else{
*/
/*
}
*/
data_proc.s=0;
s2 = IntuitionBase->FirstScreen;
vp2 = &s2->ViewPort;
s2depth = s2->BitMap.Depth;
newscreen.Type|=NS_EXTENDED;
newscreen.LeftEdge = s2->LeftEdge;
newscreen.TopEdge = s2->TopEdge;
newscreen.Width = s2->Width;
newscreen.Height = s2->Height;
newscreen.DetailPen = s2->DetailPen;
newscreen.BlockPen = s2->BlockPen;
newscreen.Depth = s2depth;
newscreen.ViewModes = vp2->Modes;
newscreen.DefaultTitle=NULL;
newscreen.Extension=screen_item;
width=news