source: abuse/trunk/src/setup.cpp @ 39

Last change on this file since 39 was 39, checked in by Sam Hocevar, 14 years ago
  • Fix almost 2,000 warnings by using proper "const" keywords where needed.
File size: 5.0 KB
Line 
1#ifdef __WATCOMC__
2
3#include "specs.hpp"
4#include "id.hpp"
5#include "jwindow.hpp"
6#include "sound.hpp"
7#include "guistat.hpp"
8#include "timing.hpp"
9#include "video.hpp"
10#include "input.hpp"
11#include "scroller.hpp"
12#include "lisp.hpp"
13#include "lisp_gc.hpp"
14#include "dprint.hpp"
15#include "cache.hpp"
16
17
18extern int sosEZGetConfig(char *szName);
19
20extern window_manager *eh;
21extern palette *lastl;
22
23extern unsigned char fnt6x13[192*104];
24
25/*int card_ids[] =
26{  _ADLIB_GOLD_8_MONO,
27   _ADLIB_GOLD_8_MONO,
28   _SOUNDSCAPE_8_MONO,
29   _ESS_AUDIODRIVE_8_MONO,
30   _GUS_8_MONO,
31   _GUS_MAX_8_MONO,
32   _MICROSOFT_8_MONO,
33   _MV_PAS_8_MONO,
34   _MV_PAS_8_MONO,
35   _RAP10_8_MONO,
36   _SOUND_BLASTER_8_MONO,          // SB
37   _SOUND_BLASTER_8_MONO,          // SB pro
38   _SB16_8_MONO,
39   _SB16_8_MONO,
40   _SOUND_MASTER_II_8_MONO,
41   _SOUND_BLASTER_8_MONO,
42   _SOUND_BLASTER_8_MONO };
43*/
44
45
46
47int get_option(char const *name);
48
49JCFont *cfg_font;
50
51static  int highest_help=0;
52
53
54extern int jmalloc_max_size;
55
56void setup(int argc, char **argv)
57{
58
59  char tmp_name[200];
60  if (get_filename_prefix())
61    sprintf(tmp_name,"%s%s",get_filename_prefix(),"sndcard.cfg");
62  else strcpy(tmp_name,"sndcard.cfg");
63
64  FILE *fp=fopen(tmp_name,"rb");
65 
66  if (!fp)
67  {
68    fp=fopen("setup.exe","rb");
69    if (!fp)
70    {
71      dprintf("Sound not configured and no setup program, cannot play sound\n");
72      return ;
73    }
74    fclose(fp);
75    system("setup.exe");
76  } else fclose(fp);
77   
78  sosEZGetConfig(tmp_name);
79
80
81/*  short *port_list,*irq_list,*dma_list;
82  get_card_info(0,port_list,irq_list,dma_list);
83
84  jmalloc_init(0x150000);         // make sure user has enough memory to run game
85  jmalloc_uninit();
86
87  jmalloc_max_size=500000;        // use a small amount of memory so SOS has some space to work with
88  jmalloc_init(400000);
89  lisp_init(0xf000,0xf000);
90
91  char *cfg_command="(load \"snd_cfg.lsp\")";
92  char *cs=cfg_command;
93  if (!eval(compile(cs)) || get_option("-setup"))
94  {
95    int i;
96    for (i=1;i<argc;i++)
97      if (!strcmp(argv[i],"-nosound"))
98      {
99        sound_init(argc,argv);  // let the sound system know there will be no sound
100        dprintf("not runnign setup because -nosound option is on\n");
101        return ;                // go no further with sound
102      }
103
104    char *cfg_start_command="(load \"lisp/config.lsp\")";
105    char *cs=cfg_start_command;
106    if (!eval(compile(cs)))
107    {
108      dprintf("Missing lisp/config.lsp, make sure you unzipped with -d\n"
109              "skipping sound configuration\n");
110      char *s[2];  s[0]=argv[0]; s[1]="-nosound";
111      sound_init(1,s);                                 // initialize with -nosound as only command-line arg
112      return;
113    }
114
115
116
117    stat_man=new text_status_manager();
118    image_init();
119
120    palette pal;  // create a usable palette, we can't load one because the file might not be there,
121                  // we are not connect to a server yet.
122
123    memset(pal.addr(),0,768);
124    for (i=0;i<64;i++)
125      pal.set(i,i*3,i*3,i*3);
126    for (i=64;i<128;i++)
127      pal.set(i,(i-64)*3,0,0);
128
129    pal.set(32,200,190,240);
130    set_mode(0x13,argc,argv);
131    pal.load();
132
133
134    JCFont fnt(new image(192,104,fnt6x13));
135    eh=new window_manager(screen,&pal,50,40,20,
136                          &fnt); 
137
138    timer_init();
139
140
141    int x=0;
142    int card=-1;    // none
143    int irq=-1;
144    int dma=-1;
145    int port=-1;
146   
147    cfg_font=eh->font();
148    for (;!get_option("-nosound") && x==0;)
149    {
150      x=l_menu(symbol_value(make_find_symbol("cfg_main_menu")));
151      if (x==0)    // select card
152      {
153        int c=l_menu(symbol_value(make_find_symbol("card_menu")));
154        if (c==0)
155          card=0;
156        else if (c>0)
157        {
158          card=c-1;
159          int sos_card_id=card_ids[c];
160          short *port_list,*irq_list,*dma_list;
161          get_card_info(sos_card_id,port_list,irq_list,dma_list);
162         
163          int p=l_menu(make_menu("port_title","port_prefix",port_list));
164          if (p>0)
165          {
166            port=port_list[p];
167            int i=l_menu(make_menu("irq_title","irq_prefix",irq_list));
168            if (i>0)
169            {
170              irq=irq_list[i];
171              int d=l_menu(make_menu("dma_title","dma_prefix",dma_list));
172              if (d>0)
173                dma=dma_list[d];
174            }
175          }
176          jfree(port_list);
177          jfree(irq_list);
178          jfree(dma_list);
179
180        }
181      }
182    }
183    if (get_option("-nosound"))
184      card=irq=port=dma=-1;
185    else if (dma!=-1)
186    {
187      FILE *fp=fopen("snd_cfg.lsp","wb");
188      if (!fp)
189        dprintf("Unable to open snd_cfg.lsp for writing\n"
190                "cannot save sound configuration\n");
191      else
192      {
193        fprintf(fp,
194                "(setq sound_card_type %d)\n"
195                "(setq sound_card_port %d)\n"
196                "(setq sound_card_irq %d)\n"
197                "(setq sound_card_dma %d)\n",
198                card,port,irq,port,dma);
199      }
200    }
201   
202    delete eh;
203
204    close_graphics();
205    timer_uninit();
206    image_uninit();
207    delete stat_man;
208    delete lastl;
209
210    cash.empty();
211    cash.create_lcache();   
212  } else
213  {
214        if (DEFINEDP(symbol_value(make_find_symbol("sound_card_type"))))
215
216
217
218  }
219 
220  lisp_uninit();
221  l_user_stack.clean_up();
222  l_ptr_stack.clean_up();
223
224  crc_man.clean_up();
225  mem_report("end.mem");
226  jmalloc_uninit();
227
228  jmalloc_max_size=4000000; */
229}
230 
231 
232#else
233
234void setup(int argc, char **argv)
235{ ; }
236
237
238#endif
Note: See TracBrowser for help on using the repository browser.