Author: dmeyer
Date: Fri Apr  7 17:27:28 2006
New Revision: 8141

Added:
   trunk/ui/src/games/emu.py
   trunk/ui/src/games/machine.py

Log:
oops, add missing files from patch

Added: trunk/ui/src/games/emu.py
==============================================================================
--- (empty file)
+++ trunk/ui/src/games/emu.py   Fri Apr  7 17:27:28 2006
@@ -0,0 +1,89 @@
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------------
+# emu.py - the Freevo emulator base class
+# -----------------------------------------------------------------------------
+#
+# This is a generic emulator class that all of the supported emulators extend. 
+#
+# -----------------------------------------------------------------------------
+# Freevo - A Home Theater PC framework
+# Copyright (C) 2002-2005 Krister Lagerstrom, Dirk Meyer, et al.
+#
+# First Edition: Dan Casimiro <[EMAIL PROTECTED]>
+# Maintainer:    Dan Casimiro <[EMAIL PROTECTED]>
+#
+# Please see the file doc/CREDITS for a complete list of authors.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
+# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# -----------------------------------------------------------------------------
+import plugin
+import logging
+import config
+
+from application import ChildApp
+from event import *
+
+log = logging.getLogger('games')
+
+
+class Emu(ChildApp):
+    """
+    Code used by all supported emulators
+
+    This is a generic emulator class that all of the supported emulators
+    extend.  It is a nice place to store all the similar code.
+    """
+    def __init__(self, cmdline):
+        ChildApp.__init__(self, cmdline, 'games', True, has_display=True)
+        self.__rom = None
+        self.__cmd = cmdline
+
+    def __get_rom(self):
+        return self.__rom
+
+    def launch(self, rom):
+        self.__rom = rom
+
+        if plugin.is_active('input.joystick'):
+            plugin.getbyname('JOYSTICK').activate(False)
+
+        log.warn(self.__cmd + ' ' + self.title())
+
+        self.child_start(self.__cmd + ' "' + self.title() + '"')
+
+    def eventhandler(self, event):
+        log.debug('The emulator eventhandler got an event: %s' % event)
+        if event == STOP:
+            self.stop()
+            if plugin.is_active('input.joystick'):
+                plugin.getbyname('JOYSTICK').activate(True)
+
+            return True
+
+        return ChildApp.eventhandler(self, event)
+
+    def title(self):
+        return self.item.filename
+
+    item = property(__get_rom, None)
+ 
+
+class UserEmu(Emu):
+    def __init__(self, gameitem):
+        cmdline = config.GAMES_ITEMS[gameitem.gi_ind][3][0][1] + ' ' +\
+                  config.GAMES_ITEMS[gameitem.gi_ind][3][0][2]
+
+        Emu.__init__(self, cmdline)

Added: trunk/ui/src/games/machine.py
==============================================================================
--- (empty file)
+++ trunk/ui/src/games/machine.py       Fri Apr  7 17:27:28 2006
@@ -0,0 +1,126 @@
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------------
+# machine.py - Handles machine definitions that Freevo knows about
+# -----------------------------------------------------------------------------
+#
+# Various utilities and handling functions for different machine types.
+#
+# First Edition: Chris Lack <[EMAIL PROTECTED]>
+# Maintainer:    Chris Lack <[EMAIL PROTECTED]>
+#
+# -----------------------------------------------------------------------------
+# Freevo - A Home Theater PC framework
+# Copyright (C) 2002-2005 Krister Lagerstrom, Dirk Meyer, et al.
+# Please see the file doc/CREDITS for a complete list of authors.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+import config
+from emu import UserEmu
+
+
+def ext(machine):
+    """
+    Returns a list of extensions to search for based on machine type.
+    """
+    extensions = { 'GB' : 'gb',
+                   'GBC' : 'gbc',
+                   'GBA' : 'gba',
+                   'VBOY' : 'vb',
+                   'NES' : 'nes',
+                   'SNES' : 'smc',
+                   'N64' : [ 'rom', 'z64', 'v64' ],
+                   'GG' : [ 'gg' ],
+                   'SG1K' : [ 'sc', 'sg' ],
+                   'SMS' : [ 'sms' ],
+                   'SMD' : [ 'bin', 'smd' ],
+                   'LYNX' : [ 'o', 'lnx' ],
+                   '2600' : 'a26',
+                   '5200' : [ 'bin', 'a52' ],
+                   '7800' : 'a78',
+                   'JAG'  : 'jag',
+                   'PCE'  : 'pce',
+                   'SGX'  : 'pce'
+                 }
+
+    if machine in extensions:
+        return extensions[machine]
+
+    log.warning('Unknown machine type %s' % machine)
+    return None
+
+
+def title(system):
+    """
+    Returns the standard name for a machine type
+    """
+    titles = { 'GB' : 'Nintendo Gameboy (Handheld)',
+               'GBC' : 'Nintendo Gameboy Color (Handheld)',
+               'GBA' : 'Nintendo Gameboy Advance (Handheld)',
+               'VBOY' : 'Nintendo VirtualBoy',
+               'NES' : 'Nintendo Entertainment System',
+               'SNES' : 'Super Nintendo',
+               'N64' : 'Nintendo 64',
+               'GG' : 'Sega Game Gear (Handheld)',
+               'SG1K' : 'Sega SG-1000/SC-3000',
+               'SMS' : 'Sega Master System',
+               'SMD' : 'Sega Megadrive',
+               'LYNX' : 'Atari Lynx (Handheld)',
+               '2600' : 'Atari 2600',
+               '5200' : 'Atari 5200',
+               '7800' : 'Atari 7800',
+               'JAG'  : 'Atari Jaguar',
+               'PCE'  : 'NEC PC-Engine',
+               'SGX'  : 'NEC Supergrafx'
+             }
+
+    if system in titles:
+        return titles[system]
+
+    log.warning('Unknown machine type %s' % system)
+    return None
+
+
+def emu(gameitem):
+    """
+    Determines which emu we're running
+    """
+    emus = {
+             'USER' : UserEmu(gameitem),
+             'GB' : UserEmu(gameitem),
+             'GBC' : UserEmu(gameitem),
+             'GBA' : UserEmu(gameitem),
+             'VBOY' : UserEmu(gameitem),
+             'NES' : UserEmu(gameitem),
+             'SNES' : UserEmu(gameitem),
+             'N64' : UserEmu(gameitem),
+             'GG' : UserEmu(gameitem),
+             'SG1K' : UserEmu(gameitem),
+             'SMS' : UserEmu(gameitem),
+             'SMD' : UserEmu(gameitem),
+             'LYNX' : UserEmu(gameitem),
+             '2600' : UserEmu(gameitem),
+             '5200' : UserEmu(gameitem),
+             '7800' : UserEmu(gameitem),
+             'JAG'  : UserEmu(gameitem),
+             'PCE'  : UserEmu(gameitem),
+             'SGX'  : UserEmu(gameitem)
+           }
+
+    if config.GAMES_ITEMS[gameitem.gi_ind][0] in emus:
+        return emus[config.GAMES_ITEMS[gameitem.gi_ind][0]]
+
+    log.warning('Unknown machine type %s' % gameitem.machine)
+    return None


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to