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

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