home *** CD-ROM | disk | FTP | other *** search
- /* white noise loader © Almathera 1994, All Rights Reserved */
-
- #include <exec/types.h>
- #include <clib/exec_protos.h>
- #include <clib/dos_protos.h>
- #include <clib/intuition_protos.h>
- #include <dos/dos.h>
- #include <pragmas/exec_pragmas.h>
- #include <pragmas/dos_pragmas.h>
- #include <pragmas/intuition_pragmas.h>
- #include "pgs_protos.h"
- #include "pgs_pragmas.h"
-
- #include "gio.h"
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
-
- /* prototypes */
- __asm ULONG __saveds GioExamine(register __a0 struct GIOData *giodata);
- __asm ULONG __saveds GioRead(register __a0 struct GIOData *giodata);
- __asm ULONG __saveds GioWrite(register __a0 struct GIOData *giodata);
- /* end of prototypes */
-
- //------------------------ CODE COMES HERE -------------------------
-
- __asm ULONG __saveds GioInfo(void)
- {
- // return(GIOF_LOADER8|GIOF_LOADER24|GIOF_SAVER8|GIOF_SAVER24|GIOF_LOADFILE|GIOF_SAVEFILE)
- return(GIOF_LOADER8);
-
- }
-
-
- #define PgsBase giodata->PgsBase
-
- __asm ULONG __saveds GioExamine(register __a0 struct GIOData *giodata)
- {
-
- giodata->Flags = GioInfo();
- giodata->Width = 320;
- giodata->Height = 256;
-
- if(PgsBase)
- {
-
- switch(GetDimensions("Size of new White Noise image",&giodata->Width,&giodata->Height))
- {
- case 1:
- break;
- case 2:
- giodata->Error = LOAD_RAMERR;
- goto err;
- case 0:
- giodata->Error = LOAD_ABORTED;
- goto err;
- default:
- giodata->Error = LOAD_SYSERR;
- goto err;
- }
- }
-
- giodata->Depth = 8;
- srand(time(NULL)); // seed random number
- giodata->Error = LOAD_OK;
-
- err:
- return(giodata->Error);
- }
-
- __asm ULONG __saveds GioRead(register __a0 struct GIOData *giodata)
- {
- int x,y;
- UBYTE col;
- UBYTE *poker;
-
- SetProgress("Creating image...",0);
- for(y=0;y<giodata->Height;y++)
- {
- if(!(y%16))
- if(SetProgress(0,y*100/giodata->Height)!=1)
- {
- giodata->Error = LOAD_ABORTED;
- goto err;
- }
-
- poker=GetLine(giodata,y);
-
- for(x=0;x<giodata->Width;x++)
- {
- col=rand()%0xff;
- *poker++=col;
- }
- ReleaseLine(giodata,y);
- }
-
- poker=giodata->Palette;
- for(x=0;x<256;x++)
- {
- *poker++=x; *poker++=x; *poker++=x;
- }
-
- giodata->Error = NULL;
- err:
- return(giodata->Error);
- }
-
- __asm ULONG __saveds GioWrite(register __a0 struct GIOData *giodata)
- {
- giodata->Error=LOAD_WRONGTYPE;
- return(giodata->Error);
- }
-
-