home *** CD-ROM | disk | FTP | other *** search
- /* Old V1.1 colournoise and whitenoise loaders combined into one.
- Jolyon - 19-1-95
-
- Updated for devdoc examples 30-3-95.
-
- */
-
- #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 <clib/pgs_protos.h>
- #include <pragmas/pgs_pragmas.h>
- #include <photogenics/gio.h>
-
- /* prototypes */
- __asm ULONG GioExamine(register __a0 struct GIOData *giodata);
- __asm ULONG GioRead(register __a0 struct GIOData *giodata);
- __asm ULONG GioWrite(register __a0 struct GIOData *giodata);
- /* end of prototypes */
-
- //------------------------ CODE COMES HERE -------------------------
-
- __asm ULONG GioInfo(void)
- {
- // return(GIOF_LOADER8|GIOF_LOADER24|GIOF_SAVER8|GIOF_SAVER24|GIOF_LOADFILE|GIOF_SAVEFILE)
- return(GIOF_LOADER24|GIOF_EXTENDED|GIOF_LOADPREFS);
- }
-
- #define PgsBase giodata->PgsBase
-
- ULONG width = 320;
- ULONG height = 256;
- ULONG cmode = 0;
-
- __asm ULONG GioExamine(register __a0 struct GIOData *giodata)
- {
- giodata->Flags = GioInfo();
-
- switch(cmode = ThreeButtonReq("Noise loader","Type of Noise image to create","Colour Noise","White Noise","Cancel"))
- {
- case 3:
- giodata->Error = LOAD_ABORTED;
- goto err;
- break;
- case 0:
- giodata->Error = LOAD_ABORTED;
- goto err;
- break;
- }
-
- switch(GetDimensions("Size of new Noise image",&width,&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->Width = width;
- giodata->Height = height;
- giodata->Depth = 24;
- giodata->Error = LOAD_OK;
- err:
- return(giodata->Error);
- }
-
- __asm ULONG GioRead(register __a0 struct GIOData *giodata)
- {
- int x,y;
- UBYTE colr;
- UBYTE *poker;
-
- InitRandom(0); // initialise random number generator
-
- SetProgress("Creating Noise 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);
- if(cmode==1)
- {
- for(x=0;x<giodata->Width;x++)
- {
- *poker++=Random(1)%0xff;
- *poker++=Random(1)%0xff;
- *poker++=Random(1)%0xff;
- }
- } else {
- for(x=0;x<giodata->Width;x++)
- {
- colr=Random(1)%0xff;
- *poker++=colr;
- *poker++=colr;
- *poker++=colr;
- }
- }
- ReleaseLine(giodata,y);
- }
- giodata->Error = NULL;
- err:
- return(giodata->Error);
- }
-
- __asm ULONG GioWrite(register __a0 struct GIOData *giodata)
- {
- /* we can't write a noise file! */
-
- giodata->Error=LOAD_WRONGTYPE;
- return(giodata->Error);
- }
-
-
- __asm void GioCleanUp(register __a0 struct GIOData *giodata)
- {
- }
-
- __asm void GioSavePrefs(register __a0 struct GIOData *giodata)
- {
- }
-
- __asm void GioLoadPrefs(register __a0 struct GIOData *giodata)
- {
- // This allows user to set default dimensions.
- GetDimensions("Select default size for Noise Loader",&width,&height);
- }
-
-