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

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