summaryrefslogtreecommitdiff
path: root/gfxtest.c
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2011-06-09 13:46:28 +0000
committerIan C <ianc@noddybox.co.uk>2011-06-09 13:46:28 +0000
commita9022b5972dc49d86f617a27940fafe9c4d0e7e7 (patch)
tree61405aa4ade91ed1057f863ddf118ceb38e14f8e /gfxtest.c
Initial import of (very old) vidoom sources.
Diffstat (limited to 'gfxtest.c')
-rw-r--r--gfxtest.c862
1 files changed, 862 insertions, 0 deletions
diff --git a/gfxtest.c b/gfxtest.c
new file mode 100644
index 0000000..2392f90
--- /dev/null
+++ b/gfxtest.c
@@ -0,0 +1,862 @@
+/*
+
+ viDOOM - level editor for DOOM
+
+ Copyright (C) 2000 Ian Cowburn (ianc@noddybox.demon.co.uk)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ -------------------------------------------------------------------------
+
+ Test program for GFX interface
+*/
+static const char rcs_id[]="$Id$";
+
+#include "config.h"
+#include "globals.h"
+#include <stdio.h>
+#include <ctype.h>
+#include <time.h>
+#include "gfx.h"
+#include "platgui.h"
+#include "editvar.h"
+#include "mem.h"
+
+#define SCRW 640
+#define SCRH 480
+
+#define RND(x) (rand()%(x))
+#define RCOL V_RGB(RND(255),RND(255),RND(255))
+
+void TestPrint(void)
+{
+ int f;
+
+ GFX_clear(BLACK);
+
+ GFX_print(0,0,WHITE,"Top left");
+ GFX_print(0,SCRH-GFX_fh(),WHITE,"Bottom left");
+ GFX_print(SCRW-GFX_fw()*strlen("Top right"),0,WHITE,"Top right");
+ GFX_print(SCRW-GFX_fw()*strlen("Bottom right"),
+ SCRH-GFX_fh(),WHITE,"Bottom right");
+
+ for(f=1;f<4;f++)
+ GFX_print(0,100+f*GFX_fh(),WHITE,"Row %d",f);
+
+ GFX_redraw();
+ GFX_waitkey(NULL);
+}
+
+
+void TestMouse(void)
+{
+ GFXEvent e;
+ int q;
+ int f;
+
+ GFX_clear(BLACK);
+
+ q=FALSE;
+
+ while(!q)
+ {
+ GFX_redraw();
+ GFX_await_input_full(&e);
+
+ switch(e.type)
+ {
+ case GFX_KEY_EVENT:
+ if (e.key.code==GFX_ESC)
+ q=TRUE;
+
+ if (e.key.code==GFX_ENTER)
+ GFX_clear(BLACK);
+ break;
+
+ case GFX_MOUSE_EVENT:
+ f=0;
+ if (e.mouse.b&GFX_BUTLEFT)
+ f|=0xff0000;
+ if (e.mouse.b&GFX_BUTMIDDLE)
+ f|=0xff00;
+ if (e.mouse.b&GFX_BUTRIGHT)
+ f|=0xff;
+
+ if (f==0)
+ f=0x808080;
+
+ GFX_frect(0,0,SCRW,GFX_fh(),BLACK);
+ GFX_print(0,0,WHITE,"x:%-4d y:%-4d b:%c%c%c",
+ e.mouse.x,e.mouse.y,
+ e.mouse.b&GFX_BUTLEFT ? 'L':' ',
+ e.mouse.b&GFX_BUTMIDDLE ? 'M':' ',
+ e.mouse.b&GFX_BUTRIGHT ? 'R':' ');
+
+ GFX_plot(e.mouse.x,e.mouse.y,f);
+ break;
+ }
+ }
+}
+
+
+void TestRect(void)
+{
+ int f,w;
+ int ox,oy;
+
+ ox=20;
+ oy=100;
+
+ for(w=3;w>-4;w--)
+ {
+ GFX_clear(BLACK);
+
+ GFX_print(0,0,WHITE,"Width/height %d",w);
+
+ for(f=0;f<5;f++)
+ {
+ GFX_plot(ox+f*20,oy+20,WHITE);
+ GFX_rect(ox+f*20+10,oy+20,w,w,WHITE);
+
+ GFX_plot(ox+f*20,oy+40,WHITE);
+ GFX_frect(ox+f*20+10,oy+40,w,w,WHITE);
+
+ GFX_plot(ox+f*20,oy+60,WHITE);
+ GFX_rect(ox+f*20+10,oy+60,w,w*2,WHITE);
+
+ GFX_plot(ox+f*20,oy+80,WHITE);
+ GFX_frect(ox+f*20+10,oy+80,w,w*2,WHITE);
+
+ GFX_plot(ox+f*20,oy+100,WHITE);
+ GFX_rect(ox+f*20+10,oy+100,w*2,w,WHITE);
+
+ GFX_plot(ox+f*20,oy+120,WHITE);
+ GFX_frect(ox+f*20+10,oy+120,w*2,w,WHITE);
+ }
+
+ GFX_redraw();
+ GFX_waitkey(NULL);
+ }
+}
+
+
+void TestDim(void)
+{
+ GFX_clear(BLACK);
+
+ GFX_line(0,0,SCRW-1,0,WHITE);
+ GFX_line(0,SCRH-1,SCRW-1,SCRH-1,WHITE);
+
+ GFX_line(0,0,0,SCRH-1,WHITE);
+ GFX_line(SCRW-1,0,SCRW-1,SCRH-1,WHITE);
+
+ GFX_line(0,0,SCRW-1,SCRH-1,WHITE);
+ GFX_line(SCRW-1,0,0,SCRH-1,WHITE);
+
+ GFX_print(20,SCRH/2,WHITE,"GFX_line()");
+
+ GFX_redraw();
+ GFX_waitkey(NULL);
+
+ GFX_clear(BLACK);
+
+ GFX_rect(0,0,SCRW,SCRH,WHITE);
+ GFX_print(20,SCRH/2,WHITE,"GFX_rect()");
+
+ GFX_redraw();
+ GFX_waitkey(NULL);
+
+ GFX_clear(BLACK);
+
+ GFX_frect(0,0,SCRW,SCRH,RED);
+ GFX_print(20,SCRH/2,WHITE,"GFX_frect()");
+
+ GFX_redraw();
+ GFX_waitkey(NULL);
+}
+
+
+void TestCol(void)
+{
+ GFX_clear(BLACK);
+
+ GFX_frect(0,0,SCRW,10,WHITE);
+ GFX_print(0,10,WHITE,"WHITE");
+
+ GFX_frect(0,20,SCRW,10,RED);
+ GFX_print(0,30,RED,"RED");
+
+ GFX_frect(0,40,SCRW,10,BLUE);
+ GFX_print(0,50,BLUE,"BLUE");
+
+ GFX_frect(0,60,SCRW,10,GREEN);
+ GFX_print(0,70,GREEN,"GREEN");
+
+ GFX_frect(0,80,SCRW,10,GREY(128));
+ GFX_print(0,90,GREY(128),"GREY(128)");
+
+ GFX_redraw();
+ GFX_waitkey(NULL);
+}
+
+static void TestDraw(void)
+{
+ int f;
+
+ GFX_clear(BLACK);
+
+ for(f=0;f<100;f++)
+ GFX_plot(f,10,WHITE);
+ GFX_print(0,22,WHITE,"GFX_plot()");
+
+ GFX_line(0,40,99,40,WHITE);
+ GFX_print(0,42,WHITE,"GFX_line()");
+
+ GFX_rect(0,60,100,10,WHITE);
+ GFX_print(0,70,WHITE,"GFX_rect()");
+
+ GFX_frect(0,80,100,10,WHITE);
+ GFX_print(0,90,WHITE,"GFX_frect()");
+
+ GFX_circle(50,150,50,WHITE);
+ GFX_print(50,150,WHITE,"GFX_circle()");
+
+ GFX_fcircle(50,250,50,GREEN);
+ GFX_print(50,250,WHITE,"GFX_fircle()");
+
+ for(f=101;f>=99;f--)
+ {
+ GFX_line(f,0,f,100,RED);
+ GFX_redraw();
+ GFX_waitkey(NULL);
+ }
+}
+
+
+static void TestBm(void)
+{
+ static unsigned char data[64]=
+ {
+ 0,0,0,0,0,0,0,0,
+ 0,1,1,1,1,1,1,0,
+ 0,1,2,2,0,0,1,0,
+ 0,1,2,2,0,0,1,1,
+ 0,1,0,0,2,2,1,1,
+ 0,1,0,0,2,2,1,0,
+ 0,1,1,1,1,1,1,0,
+ 0,0,0,1,1,0,0,0,
+ };
+ GFX_IMAGE i;
+ GFX_BITMAP bm;
+ int f;
+
+ bm.w=8;
+ bm.h=8;
+ bm.pal[0]=BLACK;
+ bm.pal[1]=RED;
+ bm.pal[2]=WHITE;
+ bm.data=data;
+
+ i=GFX_create_image(&bm);
+ GFX_clear(GREEN);
+
+ for(f=0;f<100;f++)
+ {
+ GFX_draw_image(i,f,f);
+ GFX_redraw();
+ }
+
+ GFX_waitkey(NULL);
+ GFX_fill_screen(i);
+ GFX_redraw();
+ GFX_waitkey(NULL);
+
+ GFX_destroy_image(i);
+}
+
+
+void TestKey(void)
+{
+ GFXEvent e;
+ int q;
+
+ q=FALSE;
+
+ GFX_clear(BLACK);
+
+ while(!q)
+ {
+ GFX_print(0,0,WHITE,"Press key or mouse button to quit");
+ GFX_redraw();
+ GFX_clear(BLACK);
+ GFX_await_input(&e);
+
+ switch(e.type)
+ {
+ case GFX_KEY_EVENT:
+ GFX_print(0,100,WHITE,".code %d",e.key.code);
+ GFX_print(0,100+GFX_fh()*2,WHITE,".ascii %d (%c)",e.key.ascii,
+ isprint(e.key.ascii) ? e.key.ascii : '?');
+
+ GFX_print(0,100+GFX_fh()*4,WHITE,".modif %c%c%c",
+ e.key.shift ? 'S':' ',
+ e.key.ctrl ? 'C':' ',
+ e.key.alt ? 'A':' ');
+ break;
+
+ case GFX_MOUSE_EVENT:
+ q=TRUE;
+ break;
+ }
+ }
+}
+
+
+void TestGui(void)
+{
+ static PLAT_PICKLIST cpl[]=
+ {
+ {"CPL 1",1},
+ {"CPL 2",2},
+ {"CPL 23",23},
+ {"CPL 10",10},
+ {"CPL 0",0},
+ {NULL,0},
+ };
+
+ static char *pl_short[]=
+ {
+ "Picklist entry 0",
+ "Picklist entry 1", "Picklist entry 2", "Picklist entry 3",
+ NULL
+ };
+
+ static char *pl_d_short[]=
+ {
+ "Picklist entry 0", "Picklist entry 1",
+ NULL
+ };
+
+ static char *pl[]=
+ {
+ "Picklist entry 0",
+ "Picklist entry 1", "Picklist entry 2", "Picklist entry 3",
+ "Picklist entry 4", "Picklist entry 5", "Picklist entry 6",
+ "Picklist entry 7", "Picklist entry 8", "Picklist entry 9",
+ "Picklist entry 10", "Picklist entry 11", "Picklist entry 12",
+ "Picklist entry 13", "Picklist entry 14", "Picklist entry 15",
+ "Picklist entry 16", "Picklist entry 17", "Picklist entry 18",
+ "Picklist entry 19", "Picklist entry 20", "Picklist entry 21",
+ "Picklist entry 22", "Picklist entry 23", "Picklist entry 24",
+ "Picklist entry 25", "Picklist entry 26", "Picklist entry 27",
+ "Picklist entry 28", "Picklist entry 29", "Picklist entry 30",
+ "Picklist entry 31", "Picklist entry 32", "Picklist entry 33",
+ "Picklist entry 34", "Picklist entry 35", "Picklist entry 36",
+ "Picklist entry 37", "Picklist entry 38", "Picklist entry 39",
+ "Picklist entry 40", "Picklist entry 41", "Picklist entry 42",
+ "Picklist entry 43", "Picklist entry 44", "Picklist entry 45",
+ "Picklist entry 46", "Picklist entry 47", "Picklist entry 48",
+ "Picklist entry 49", "Picklist entry 50", "Picklist entry 51",
+ "Picklist entry 52", "Picklist entry 53", "Picklist entry 54",
+ "Picklist entry 55", "Picklist entry 56", "Picklist entry 57",
+ "Picklist entry 58", "Picklist entry 59", "Picklist entry 60",
+ "Picklist entry 61", "Picklist entry 62", "Picklist entry 63",
+ "Picklist entry 64", "Picklist entry 65", "Picklist entry 66",
+ "Picklist entry 67", "Picklist entry 68", "Picklist entry 69",
+ "Picklist entry 70", "Picklist entry 71", "Picklist entry 72",
+ "Picklist entry 73", "Picklist entry 74", "Picklist entry 75",
+ "Picklist entry 76", "Picklist entry 77", "Picklist entry 78",
+ "Picklist entry 79", "Picklist entry 80", "Picklist entry 81",
+ "Picklist entry 82", "Picklist entry 83", "Picklist entry 84",
+ "Picklist entry 85", "Picklist entry 86", "Picklist entry 87",
+ "Picklist entry 88", "Picklist entry 89", "Picklist entry 90",
+ "Picklist entry 91", "Picklist entry 92", "Picklist entry 93",
+ "Picklist entry 94", "Picklist entry 95", "Picklist entry 96",
+ "Picklist entry 97", "Picklist entry 98", "Picklist entry 99",
+ NULL
+ };
+
+ static PLAT_IMG_PICKLIST ipl[]=
+ {
+ {"IPL 1 (BLUE)",NULL,1},
+ {"IPL 2",NULL,2},
+ {"IPL 23 (GREEN)",NULL,23},
+ {"IPL 10",NULL,10},
+ {"IPL 0 (RED)",NULL,0},
+ {NULL,NULL,0},
+ };
+
+ static PLAT_MENU ch2[]= {
+ {"Opt3",3,NULL},
+ {"Opt4",4,NULL},
+ {NULL,0,NULL},
+ };
+
+ static PLAT_MENU ch1[]= {
+ {"Opt1",1,NULL},
+ {"Opt2",2,NULL},
+ {"Child 2",0,ch2},
+ {NULL,0,NULL},
+ };
+
+ static char *pl_text[17]={"Opt 1","Opt 2","Opt 3","Opt 4","Opt 5",
+ "Opt 6","Opt 7","Opt 8","Opt 9","Opt 10",
+ "Opt 11","Opt 12","Opt 13","Opt 14","Opt 15",
+ "Opt 16",
+ "A very very very very long option"};
+
+ static PLAT_DIALOG dialog[6]={
+ {"String",PLAT_DIAL_STRING,{0}},
+ {"Integer",PLAT_DIAL_INTEGER,{0}},
+ {"Double",PLAT_DIAL_DOUBLE,{0}},
+ {"Picklist 1",PLAT_DIAL_PICKLIST,{0}},
+ {"Picklist 2",PLAT_DIAL_PICKLIST,{0}},
+ {"Picklist 3",PLAT_DIAL_PICKLIST,{0}},
+ };
+
+ static PLAT_RADIO radio[]= {
+ {"Radio 0",0},
+ {"Radio 2",2},
+ {"Radio 4",4},
+ {"Radio 8",8},
+ {"Radio -33",-33},
+ {NULL,0}
+ };
+
+ int cur_radio=4;
+
+ static PLAT_MULTI multi[]= {
+ {"Opt 1",0,TRUE},
+ {"Opt 2",0,FALSE},
+ {"Opt 3",0,FALSE},
+ {"Group 1.1",1,TRUE},
+ {"Group 1.2",1,FALSE},
+ {"Group 1.3",1,FALSE},
+ {"Opt 4",0,FALSE},
+ {"Group 2.1",2,FALSE},
+ {"Group 2.2",2,TRUE},
+ {"Opt 5",0,FALSE},
+ {NULL,0,0}
+ };
+
+ PLAT_DIALOG work_dial[6];
+
+ static PLAT_MENU menu[]={
+ {"Recursive",0,menu},
+ {"Child 1",0,ch1},
+ {"Test fsel and file_view",100,NULL},
+ {"Test text edit",101,NULL},
+ {"Test picklist",102,NULL},
+ {"Test client data picklist",103,NULL},
+ {"Test client data image picklist",104,NULL},
+ {"Test DIALOG",105,NULL},
+ {"Test GUI_alert()",106,NULL},
+ {"Test GUI_yesno()",107,NULL},
+ {"Test GUI_yesno_all()",108,NULL},
+ {"Test GUI_radio_box()",109,NULL},
+ {"Test GUI_multi_box()",110,NULL},
+ {"Quit",999,NULL},
+ {NULL,0,NULL},
+ };
+ static char *text=NULL;
+
+ int opt;
+ char s[80];
+ char *path;
+ char *new;
+ int ret;
+
+ strcpy(dialog[0].data.s,"String");
+ dialog[1].data.i=123;
+ dialog[2].data.d=1.23;
+
+ dialog[3].data.pl.no=17;
+ dialog[3].data.pl.current=0;
+ dialog[3].data.pl.text=pl_text;
+
+ dialog[4].data.pl.no=2;
+ dialog[4].data.pl.current=0;
+ dialog[4].data.pl.text=pl_d_short;
+
+ dialog[5].data.pl.no=100;
+ dialog[5].data.pl.current=0;
+ dialog[5].data.pl.text=pl;
+
+ opt=0;
+
+ if (!text)
+ {
+ GFX_BITMAP bm;
+ int c;
+ int f;
+
+ text=Strdup("Test text\nof two lines follwed by\n"
+ "a big line (nnA - nnP):\n"
+ "123456790A 123456790B 123456790C 123456790D "
+ "123456790E 123456790F 123456790G 123456790H "
+ "123456790I 123456790J 123456790K 123456790L "
+ "123456790M 123456790N 123456790O 123456790P <END>"
+ );
+ bm.pal[0]=BLACK;
+
+ c=0xff;
+
+ for(f=0;f<3;f++)
+ {
+ int w,h;
+
+ w=256-(f)*64;
+ h=256-(f)*64;
+ bm.w=w;
+ bm.h=h;
+ bm.pal[1]=c;
+ bm.data=Grab(w*h);
+
+ memset(bm.data,1,w*h);
+ ipl[f*2].img=GFX_create_image(&bm);
+ Release(bm.data);
+ c=c<<8;
+ }
+ }
+
+ while(opt!=999)
+ {
+ opt=GUI_menu("Menu",10,10,menu,-1);
+
+ switch(opt)
+ {
+ case 100:
+ if (GUI_yesno("Use filter?"))
+ path=GUI_fsel("File selector","",".c");
+ else
+ path=GUI_fsel("File selector","",NULL);
+
+ if (path)
+ {
+ GUI_view_file(path,path);
+ Release(path);
+ }
+
+ break;
+
+ case 101:
+ new=GUI_text_edit("Test",text);
+
+ if (new)
+ {
+ Release(text);
+ text=new;
+ }
+ break;
+
+ case 102:
+ ret=GUI_picklist("Long Picklist",pl);
+ sprintf(s,"You chose option|%d",ret);
+ GUI_yesno(s);
+
+ ret=GUI_picklist("Short Picklist",pl_short);
+ sprintf(s,"You chose option|%d",ret);
+ GUI_yesno(s);
+ break;
+
+ case 103:
+ ret=GUI_client_picklist("Client Picklist",cpl,-1);
+ sprintf(s,"You chose option|%d",ret);
+ GUI_yesno(s);
+ break;
+
+ case 104:
+ ret=GUI_image_picklist("Image Picklist",ipl,-1);
+ sprintf(s,"You chose option|%d",ret);
+ GUI_yesno(s);
+ break;
+
+ case 105:
+ memcpy(&work_dial,&dialog,sizeof(dialog));
+
+ if (GUI_dialog("Dialog",6,work_dial))
+ memcpy(&dialog,&work_dial,sizeof(dialog));
+ break;
+
+ case 106:
+ GUI_alert("This is a long title","Text1","OK");
+ GUI_alert("T","Longer text 1|Longer text 2","OK");
+ GUI_alert("T","Text1","Longer button text");
+ break;
+
+ case 107:
+ if (GUI_yesno("Pick"))
+ GUI_alert("Answer","YES","OK");
+ else
+ GUI_alert("Answer","NO","OK");
+
+ if (GUI_yesno("With a much much much MUCH longer string|"
+ "and some multiple|lines"))
+ GUI_alert("Answer","YES","OK");
+ else
+ GUI_alert("Answer","NO","OK");
+
+ break;
+
+ case 108:
+ GUI_start_yesno_all();
+
+ if (GUI_yesno_all("Pick"))
+ GUI_alert("Pick","YES","OK");
+ else
+ GUI_alert("Pick","NO","OK");
+
+ if (GUI_yesno_all("With a much much much MUCH longer string|"
+ "and some multiple|lines"))
+ GUI_alert("Long string","YES","OK");
+ else
+ GUI_alert("Long string","NO","OK");
+
+ if (GUI_yesno_all("Pick 2"))
+ GUI_alert("Pick 2","YES","OK");
+ else
+ GUI_alert("Pick 2","NO","OK");
+
+ if (GUI_yesno_all("Pick 3"))
+ GUI_alert("Pick 3","YES","OK");
+ else
+ GUI_alert("Pick 3","NO","OK");
+
+ break;
+
+ case 109:
+ ret=GUI_radio_box("Radio Box",radio,cur_radio,-666);
+ sprintf(s,"You chose option|%d",ret);
+ GUI_yesno(s);
+ cur_radio=ret;
+ break;
+
+ case 110:
+ GUI_multi_box("Multi Box",multi);
+ break;
+
+ case 999:
+ break;
+
+ default:
+ sprintf(s,"You chose option|%d",opt);
+ GUI_alert("Other",s,"OK");
+ break;
+ }
+ }
+}
+
+#define PERF_COUNT 1000000
+
+time_t PerfClr(time_t start)
+{
+ int f;
+
+ for(f=0;f<PERF_COUNT;f++)
+ GFX_clear(BLACK);
+
+ return time(NULL)-start;
+}
+
+
+time_t PerfRect(time_t start)
+{
+ int f;
+
+ for(f=0;f<PERF_COUNT;f++)
+ GFX_rect(10,10,600,600,WHITE);
+
+ return time(NULL)-start;
+}
+
+
+time_t PerfFRect(time_t start)
+{
+ int f;
+
+ for(f=0;f<PERF_COUNT;f++)
+ GFX_frect(10,10,600,600,WHITE);
+
+ return time(NULL)-start;
+}
+
+
+time_t PerfPlot(time_t start)
+{
+ int f;
+
+ for(f=0;f<PERF_COUNT;f++)
+ GFX_plot(10,10,WHITE);
+
+ return time(NULL)-start;
+}
+
+
+time_t PerfLine(time_t start)
+{
+ int f;
+
+ for(f=0;f<PERF_COUNT;f++)
+ GFX_line(10,10,610,610,WHITE);
+
+ return time(NULL)-start;
+}
+
+
+time_t PerfLRect(time_t start)
+{
+ int f;
+
+ for(f=0;f<PERF_COUNT;f++)
+ {
+ GFX_line(10,10,610,610,WHITE);
+ GFX_line(610,610,610,610,WHITE);
+ GFX_line(610,610,10,610,WHITE);
+ GFX_line(10,610,10,10,WHITE);
+ }
+
+ return time(NULL)-start;
+}
+
+
+time_t PerfCirc(time_t start)
+{
+ int f;
+
+ for(f=0;f<PERF_COUNT;f++)
+ GFX_circle(10,10,600,WHITE);
+
+ return time(NULL)-start;
+}
+
+
+void TestPerformance(void)
+{
+ static struct
+ {
+ char *t;
+ time_t (*func)(time_t);
+ } test[]= {
+ {"Clear screen",PerfClr},
+ {"Rectangles",PerfRect},
+ {"Filled rectangles",PerfFRect},
+ {"Plot",PerfPlot},
+ {"Line",PerfLine},
+ {"Rectangles using GFX_line",PerfLRect},
+ {"Circles",PerfCirc},
+ {NULL,NULL}
+ };
+
+ PLAT_MENU pm[32];
+ int quit;
+ time_t t;
+ int f;
+
+ quit=FALSE;
+
+ GFX_clear(BLACK);
+ GFX_print(0,0,RED,"Select:");
+
+ while(!quit)
+ {
+ f=0;
+ while(test[f].t)
+ {
+ pm[f].text=test[f].t;
+ pm[f].client_index=f;
+ pm[f].child=NULL;
+ f++;
+ }
+
+ pm[f].text=NULL;
+
+ GFX_redraw();
+
+ if ((f=GUI_menu("Performance",16,16,pm,-1))==-1)
+ quit=TRUE;
+ else
+ {
+ t=time(NULL);
+ while (time(NULL)==t);
+
+ t=test[f].func(time(NULL));
+
+ GFX_clear(BLACK);
+ GFX_print(0,0,WHITE,"Test %s completed in %ld seconds",test[f].t,t);
+ GFX_redraw();
+ }
+ }
+}
+
+
+
+
+int viDOOM(int argc,char *argv[])
+{
+ static struct
+ {
+ char *t;
+ void (*func)(void);
+ } test[]= {
+ {"Test printing",TestPrint},
+ {"Test mouse",TestMouse},
+ {"Test rectangles",TestRect},
+ {"Test screen dimensions",TestDim},
+ {"Test colours",TestCol},
+ {"Test drawing",TestDraw},
+ {"Test bitmap",TestBm},
+ {"Test keyboard",TestKey},
+ {"Test GUI",TestGui},
+ {"Test Performance",TestPerformance},
+ {NULL,NULL}
+ };
+
+ PLAT_MENU pm[32];
+ int quit;
+ int f;
+
+ INI_Load("vidoom.ini");
+ GFX_init();
+ GFX_open(SCRW,SCRH);
+ GUI_setscreen(SCRW,SCRH);
+
+ quit=FALSE;
+
+ while(!quit)
+ {
+ GFX_clear(BLACK);
+ GFX_print(0,0,RED,"Select:");
+
+ f=0;
+ while(test[f].t)
+ {
+ pm[f].text=test[f].t;
+ pm[f].client_index=f;
+ pm[f].child=NULL;
+ f++;
+ }
+
+ pm[f].text=NULL;
+
+ GFX_redraw();
+
+ if ((f=GUI_menu("GFXTEST",16,16,pm,-1))==-1)
+ quit=TRUE;
+ else
+ test[f].func();
+ }
+
+ return(EXIT_SUCCESS);
+}