~ubuntu-branches/debian/squeeze/stella/squeeze

« back to all changes in this revision

Viewing changes to src/emucore/OSystem.hxx

  • Committer: Bazaar Package Importer
  • Author(s): Stephen Kitt
  • Date: 2010-07-12 23:49:36 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20100712234936-juawrr3etzhr2qpv
Tags: 3.1.2-1
* New maintainer (closes: #532039).
* New upstream version (closes: #461121):
  - includes launcher (closes: #396058).
* Fix the reference to the X Window System in the description (closes:
  #411815).
* Move to main, DFSG-free ROMs are available (see README.Debian).
* Enhance the package description.
* Drop the libslang2-dev dependency (closes: #560274).
* Remove the Encoding entry from stella.desktop.
* Avoid ignoring errors when cleaning.
* Add ${misc:Depends} to the package dependencies.
* Provide a doc-base file to install the documentation using doc-base.
* Switch to debhelper 7 with a simplified rules file.
* Use autotools-dev to provide updated configuration files.
* Update to Standards-Version 3.9.0:
  - Move to menu section Applications/Emulators.
  - Move the homepage declaration.
* Re-write the manpage.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
//  SS  SS   tt   ee      ll   ll  aa  aa
9
9
//   SSSS     ttt  eeeee llll llll  aaaaa
10
10
//
11
 
// Copyright (c) 1995-2008 by Bradford W. Mott and the Stella team
 
11
// Copyright (c) 1995-2010 by Bradford W. Mott, Stephen Anthony
 
12
// and the Stella Team
12
13
//
13
 
// See the file "license" for information on usage and redistribution of
 
14
// See the file "License.txt" for information on usage and redistribution of
14
15
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
15
16
//
16
 
// $Id: OSystem.hxx,v 1.66 2008/05/19 21:16:58 stephena Exp $
 
17
// $Id: OSystem.hxx 2029 2010-04-29 12:46:07Z stephena $
17
18
//============================================================================
18
19
 
19
20
#ifndef OSYSTEM_HXX
56
57
  other objects belong.
57
58
 
58
59
  @author  Stephen Anthony
59
 
  @version $Id: OSystem.hxx,v 1.66 2008/05/19 21:16:58 stephena Exp $
 
60
  @version $Id: OSystem.hxx 2029 2010-04-29 12:46:07Z stephena $
60
61
*/
61
62
class OSystem
62
63
{
183
184
#endif
184
185
 
185
186
    /**
 
187
      Get the small font object of the system
 
188
 
 
189
      @return The font reference
 
190
    */
 
191
    inline const GUI::Font& smallFont() const { return *mySmallFont; }
 
192
 
 
193
    /**
186
194
      Get the font object of the system
187
195
 
188
196
      @return The font reference
231
239
    /**
232
240
      Get the maximum dimensions of a window for the video hardware.
233
241
    */
234
 
    const uInt32 desktopWidth() const  { return myDesktopWidth; }
235
 
    const uInt32 desktopHeight() const { return myDesktopHeight; }
 
242
    inline uInt32 desktopWidth() const  { return myDesktopWidth; }
 
243
    inline uInt32 desktopHeight() const { return myDesktopHeight; }
236
244
 
237
245
    /**
238
246
      Get the supported fullscreen resolutions for the video hardware.
242
250
    const ResolutionList& supportedResolutions() const { return myResolutions; }
243
251
 
244
252
    /**
245
 
      Return the default directory for storing data.
 
253
      Return the default full/complete directory name for storing data.
246
254
    */
247
255
    const string& baseDir() const { return myBaseDir; }
248
256
 
249
257
    /**
250
 
      Return the directory for storing state files.
 
258
      Return the full/complete directory name for storing state files.
251
259
    */
252
260
    const string& stateDir() const { return myStateDir; }
253
261
 
254
262
    /**
255
 
      Return the directory for storing PNG snapshots.
 
263
      Return the full/complete directory name for storing PNG snapshots.
256
264
    */
257
265
    const string& snapshotDir() const { return mySnapshotDir; }
258
266
 
259
267
    /**
 
268
      Return the full/complete directory name for storing EEPROM files.
 
269
    */
 
270
    const string& eepromDir() const { return myEEPROMDir; }
 
271
 
 
272
    /**
260
273
      This method should be called to get the full path of the cheat file.
261
274
 
262
275
      @return String representing the full path of the cheat filename.
295
308
    const string& romFile() const { return myRomFile; }
296
309
 
297
310
    /**
298
 
      Switches between software and OpenGL framebuffer modes.
299
 
    */
300
 
    void toggleFrameBuffer();
301
 
 
302
 
    /**
303
 
      Creates a new game console from the specified romfile.
 
311
      Creates a new game console from the specified romfile, and correctly
 
312
      initializes the system state to start emulation of the Console.
304
313
 
305
314
      @param romfile  The full pathname of the ROM to use
306
315
      @param md5      The MD5sum of the ROM
317
326
 
318
327
    /**
319
328
      Creates a new ROM launcher, to select a new ROM to emulate.
 
329
 
 
330
      @return  True on successful creation, otherwise false
320
331
    */
321
 
    void createLauncher();
 
332
    bool createLauncher();
322
333
 
323
334
    /**
324
335
      Gets all possible info about the ROM by creating a temporary
337
348
    const string& features() const { return myFeatures; }
338
349
 
339
350
    /**
340
 
      Open the given ROM and return an array containing its contents.
341
 
 
342
 
      @param rom    The absolute pathname of the ROM file
343
 
      @param md5    The md5 calculated from the ROM file
344
 
      @param image  A pointer to store the ROM data
345
 
                      Note, the calling method is responsible for deleting this
346
 
      @param size   The amount of data read into the image array
347
 
 
348
 
      @return  False on any errors, else true
 
351
      The build information for Stella (SDL version, architecture, etc).
 
352
 
 
353
      @return  The build info
349
354
    */
350
 
    bool openROM(const string& rom, string& md5, uInt8** image, int* size);
351
 
 
352
 
    /**
353
 
      Is this a valid ROM filename (does it have a valid extension?).
354
 
 
355
 
      @param filename  Filename of potential ROM file
356
 
      @param extension The extension extracted from the given file
357
 
     */
358
 
    bool isValidRomName(const string& filename, string& extension);
 
355
    const string& buildInfo() const { return myBuildInfo; }
359
356
 
360
357
    /**
361
358
      Calculate the MD5sum of the given file.
362
359
 
363
360
      @param filename  Filename of potential ROM file
364
 
     */
 
361
    */
365
362
    string MD5FromFile(const string& filename);
366
363
 
367
364
    /**
369
366
    */
370
367
    void quit() { myQuitLoop = true; }
371
368
 
 
369
    /**
 
370
      Output a message to the a log (normally stdout).
 
371
 
 
372
      @param message  The message to be output
 
373
      @param level    If 0, always output the message, only output when
 
374
                      level is less than or equal to that in 'showinfo'
 
375
    */
 
376
    void logMessage(const string& message, uInt8 level);
 
377
 
372
378
  public:
373
379
    //////////////////////////////////////////////////////////////////////
374
380
    // The following methods are system-specific and must be implemented
379
385
 
380
386
      @return Current time in microseconds.
381
387
    */
382
 
    virtual uInt32 getTicks() const = 0;
 
388
    virtual uInt64 getTicks() const;
383
389
 
384
390
    //////////////////////////////////////////////////////////////////////
385
391
    // The following methods are system-specific and can be overrided in
432
438
    /**
433
439
      Query the OSystem video hardware for resolution information.
434
440
    */
435
 
    virtual void queryVideoHardware();
 
441
    virtual bool queryVideoHardware();
436
442
 
437
443
    /**
438
444
      Set the base directory for all Stella files (these files may be
443
449
    /**
444
450
      Set the locations of config file
445
451
    */
446
 
    void setConfigFile(const string& file) { myConfigFile = file; }
 
452
    void setConfigFile(const string& file);
447
453
 
448
454
  protected:
449
455
    // Pointer to the EventHandler object
505
511
    string myBaseDir;
506
512
    string myStateDir;
507
513
    string mySnapshotDir;
 
514
    string myEEPROMDir;
508
515
 
509
516
    string myCheatFile;
510
517
    string myConfigFile;
512
519
    string myPropertiesFile;
513
520
 
514
521
    string myRomFile;
 
522
    string myRomMD5;
515
523
 
516
524
    string myFeatures;
 
525
    string myBuildInfo;
 
526
 
 
527
    // The font object to use when space is very limited
 
528
    GUI::Font* mySmallFont;
517
529
 
518
530
    // The font object to use for the normal in-game GUI
519
531
    GUI::Font* myFont;
526
538
 
527
539
    // Indicates whether the main processing loop should proceed
528
540
    struct TimingInfo {
529
 
      uInt32 start;
530
 
      uInt32 current;
531
 
      uInt32 virt;
532
 
      uInt32 totalTime;
533
 
      uInt32 totalFrames;
 
541
      uInt64 start;
 
542
      uInt64 current;
 
543
      uInt64 virt;
 
544
      uInt64 totalTime;
 
545
      uInt64 totalFrames;
534
546
    };
535
547
    TimingInfo myTimingInfo;
536
548
 
540
552
  private:
541
553
    /**
542
554
      Creates the various framebuffers/renderers available in this system
543
 
      (for now, that means either 'software' or 'opengl').
 
555
      (for now, that means either 'software' or 'opengl').  Note that
 
556
      it will only create one type per run of Stella.
544
557
 
545
558
      @return Success or failure of the framebuffer creation
546
559
    */
547
 
    bool createFrameBuffer(bool showmessage = false);
 
560
    bool createFrameBuffer();
548
561
 
549
562
    /**
550
563
      Creates the various sound devices available in this system
553
566
    void createSound();
554
567
 
555
568
    /**
556
 
      Query valid info for creating a valid console.
557
 
 
558
 
      @return Success or failure for a valid console
559
 
    */
560
 
    bool queryConsoleInfo(const uInt8* image, uInt32 size, const string& md5,
561
 
                          Cartridge** cart, Properties& props);
 
569
      Creates an actual Console object based on the given info.
 
570
 
 
571
      @param romfile  The full pathname of the ROM to use
 
572
      @param md5      The MD5sum of the ROM
 
573
      @param type     The bankswitch type of the ROM
 
574
      @param id       The additional id (if any) used by the ROM
 
575
 
 
576
      @return  The actual Console object, otherwise NULL
 
577
               (calling method is responsible for deleting it)
 
578
    */
 
579
    Console* openConsole(const string& romfile, string& md5, string& type, string& id);
 
580
 
 
581
    /**
 
582
      Open the given ROM and return an array containing its contents.
 
583
      Also, the properties database is updated with a valid ROM name
 
584
      for this ROM (if necessary).
 
585
 
 
586
      @param rom    The absolute pathname of the ROM file
 
587
      @param md5    The md5 calculated from the ROM file
 
588
                    (will be recalculated if necessary)
 
589
      @param size   The amount of data read into the image array
 
590
 
 
591
      @return  Pointer to the array, with size >=0 indicating valid data
 
592
               (calling method is responsible for deleting it)
 
593
    */
 
594
    uInt8* openROM(string rom, string& md5, uInt32& size);
 
595
 
 
596
    /**
 
597
      Gets all possible info about the given console.
 
598
 
 
599
      @param console  The console to use
 
600
      @return  Some information about this console
 
601
    */
 
602
    string getROMInfo(const Console* console);
562
603
 
563
604
    /**
564
605
      Initializes the timing so that the mainloop is reset to its