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

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