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

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