Ticket #8837: branch-0-11-0-ps2.patch

File branch-0-11-0-ps2.patch, 135.2 KB (added by sunmax, 16 years ago)

PlayStation2 ScummVM-0.11.1 patch

  • backends/fs/ps2/ps2-fs-factory.cpp

    diff -u -N -r branch-0-11-0/backends/fs/ps2/ps2-fs-factory.cpp branch-0-11-0-ps2/backends/fs/ps2/ps2-fs-factory.cpp
    old new  
    3636}
    3737
    3838AbstractFilesystemNode *Ps2FilesystemFactory::makeFileNodePath(const String &path) const {
    39         return new Ps2FilesystemNode(path);
     39        // return new Ps2FilesystemNode(path);
     40
     41        Ps2FilesystemNode *nf = new Ps2FilesystemNode(path, true);
     42/*
     43        int fd = fio.dopen(path.c_str());
     44        if (fd < 0) {
     45                nf->_isDirectory = false;
     46        }
     47        else {
     48                fio.dclose(fd);
     49        }
     50*/
     51        return nf; // new Ps2FilesystemNode(path, true);
    4052}
  • backends/fs/ps2/ps2-fs.cpp

    diff -u -N -r branch-0-11-0/backends/fs/ps2/ps2-fs.cpp branch-0-11-0-ps2/backends/fs/ps2/ps2-fs.cpp
    old new  
    1818 * along with this program; if not, write to the Free Software
    1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    2020 *
    21  * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-11-0/backends/fs/ps2/ps2-fs.cpp $
    22  * $Id: ps2-fs.cpp 29159 2007-10-07 00:28:38Z david_corrales $
     21 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/tags/release-0-11-0/backends/fs/ps2/ps2-fs.cpp $
     22 * $Id: ps2-fs.cpp 30459 2008-01-12 23:07:51Z sev $
    2323 */
    2424
    2525#include "backends/fs/abstract-fs.h"
    2626#include <kernel.h>
    2727#include <stdio.h>
    2828#include <stdlib.h>
     29#include <unistd.h>
    2930#include "asyncfio.h"
     31#include "fileio.h"
     32
    3033#include "systemps2.h"
    3134
     35#define DEFAULT_MODE (FIO_S_IRUSR | FIO_S_IWUSR | FIO_S_IRGRP | FIO_S_IWGRP | FIO_S_IROTH | FIO_S_IWOTH)
     36
     37FILE *ps2_fopen(const char *fname, const char *mode);
     38int ps2_fclose(FILE *stream);
     39// extern int fileXioChdir(const char* pathname);
     40
     41#include <fileXio_rpc.h>
     42
     43
    3244extern AsyncFio fio;
    3345extern OSystem_PS2 *g_systemPs2;
    3446
     
    3850 * Parts of this class are documented in the base interface class, AbstractFilesystemNode.
    3951 */
    4052class Ps2FilesystemNode : public AbstractFilesystemNode {
     53
     54friend class Ps2FilesystemFactory;
     55
    4156protected:
    4257        String _displayName;
    4358        String _path;
     
    5671         * @param path String with the path the new node should point to.
    5772         */
    5873        Ps2FilesystemNode(const String &path);
     74        Ps2FilesystemNode(const String &path, bool verify);
    5975       
    6076        /**
    6177         * Copy constructor.
    6278         */
    6379        Ps2FilesystemNode(const Ps2FilesystemNode *node);
     80       
     81        virtual bool exists() const {
     82                int fd;
     83
     84                printf("Q: Does %s exist ?\n", _path.c_str());
     85
     86                if (_path[4] != ':') { // don't bother for relative path...
     87                                       //  ...they always fail on PS2!
     88                        printf("A: nope -> skip relative path\n");
     89                        return false;
     90                }
     91
     92                if (_path[0] == 'h') { // bypass host
     93                        printf("A: nope -> skip host\n");
     94                        return false;
     95                }
     96
     97                if ((fd = fio.open(_path.c_str(), O_RDONLY)) >= 0) { /* it's a file */
     98                        fio.close(fd);
     99                        printf("A: yep -> file\n");
     100                        return true;
     101                }
     102
     103                   /* romeo's black magic */
     104                fd = fio.open(_path.c_str(), O_RDONLY, DEFAULT_MODE | FIO_S_IFDIR);
     105                if (fd == -EISDIR) {
     106                        printf("A: yep -> dir\n");
     107                        return true;
     108                }
     109                /* NOTE: it cannot be a file cause it would have been caught by
     110                         the previous test, so no need to close it ;-)          */
     111
     112                printf("A: nope\n");
     113                return false;
     114        }
    64115
    65         virtual bool exists() const { return true; }            //FIXME: this is just a stub
    66116        virtual String getDisplayName() const { return _displayName; }
    67117        virtual String getName() const { return _displayName; }
    68118        virtual String getPath() const { return _path; }
    69         virtual bool isDirectory() const { return _isDirectory; }
    70         virtual bool isReadable() const { return true; }        //FIXME: this is just a stub
    71         virtual bool isWritable() const { return true; }        //FIXME: this is just a stub
     119        virtual bool isDirectory() const {
     120
     121                printf("Q: Is %s a dir?\n", _path.c_str());
     122
     123#if 0
     124                int fd;
     125
     126                if (_path.empty()) {
     127                        printf("A: yep -> top level\n");
     128                        return true; // top level
     129                }
     130
     131                if (_path.lastChar() == ':' ||
     132                        (_path.lastChar() == '/' && _path[_path.size()-2] == ':')) {
     133                        printf("A: yep -> device\n");
     134                        return true; // device
     135                }
     136
     137                fd = fio.open(_path.c_str(), O_RDONLY, DEFAULT_MODE | FIO_S_IFDIR);
     138                if (fd == -EISDIR) {
     139                        printf("A: yep\n");
     140                        return true;
     141                }
     142
     143                if (fd >= 0)
     144                        fio.close(fd);
     145
     146                printf("A: nope\n");
     147                return false;
     148#else
     149                if (_isDirectory)
     150                        printf("A: yep -> _isDirectory == 1\n");
     151                else
     152                        printf("A: nope -> _isDirectory == 0\n");
     153
     154                return _isDirectory;
     155#endif
     156        }
     157
     158        virtual bool isReadable() const {
     159                int fd;
     160                if ((fd = fio.open(_path.c_str(), O_RDONLY)) >= 0) {
     161                        fio.close(fd);
     162                        return true;
     163                }
     164                return false;
     165        }
     166
     167        virtual bool isWritable() const {
     168                int fd;
     169                if ((fd =  fio.open(_path.c_str(), O_WRONLY)) >= 0) {
     170                        fio.close(fd);
     171                        return true;
     172                }
     173                return false;
     174        }
    72175
    73176        virtual AbstractFilesystemNode *clone() const { return new Ps2FilesystemNode(this); }
    74177        virtual AbstractFilesystemNode *getChild(const String &n) const;
     
    83186 * @return Pointer to the first char of the last component inside str.
    84187 */
    85188const char *lastPathComponent(const Common::String &str) {
    86         //FIXME: implement this method properly.
    87         // This code is probably around the constructors,
    88         // but I couldn't figure it out without having
    89         // doubts on the correctness of my assumptions.
    90         // Therefore, I leave it to the porter to correctly
    91         // implement this method.
    92         assert(false);
     189        if (str.empty())
     190                return "";
     191
     192        const char *start = str.c_str();
     193        const char *cur = start + str.size() - 2;
     194
     195        while (cur >= start && *cur != '/' && *cur != ':') {
     196                --cur;
     197        }
     198
     199        printf("romeo : lastPathComponent = %s\n", cur + 1);
     200
     201        return cur + 1;
    93202}
    94203
    95204Ps2FilesystemNode::Ps2FilesystemNode() {
     
    124233        }
    125234}
    126235
     236Ps2FilesystemNode::Ps2FilesystemNode(const String &path, bool verify) {
     237        _path = path;
     238        _isDirectory = true;
     239
     240        if (strcmp(path.c_str(), "") == 0) {
     241                _isRoot = true;
     242                _displayName = String("PlayStation 2");
     243                verify = false; /* root is always a dir*/
     244        } else {
     245                _isRoot = false;
     246                const char *dsplName = NULL, *pos = path.c_str();
     247                while (*pos)
     248                        if (*pos++ == '/')
     249                                dsplName = pos;
     250                if (dsplName)
     251                        _displayName = String(dsplName);
     252                else {
     253                        if (strncmp(path.c_str(), "cdfs", 4) == 0)
     254                                _displayName = "DVD Drive";
     255                        else if (strncmp(path.c_str(), "mass", 4) == 0)
     256                                _displayName = "USB Mass Storage";
     257                        else
     258                                _displayName = "Harddisk";
     259                        verify = false; /* devices are always dir */
     260                }
     261        }
     262
     263        if (verify && !_isRoot) {
     264                int medium, fd;
     265
     266                if (strncmp(path.c_str(), "pfs0", 4) == 0)
     267                        medium = 0;
     268                else if (strncmp(path.c_str(), "cdfs", 4) == 0)
     269                        medium = 1;
     270                else if (strncmp(path.c_str(), "mass", 4) == 0)
     271                        medium = 2;
     272
     273                switch(medium) {
     274
     275                case 0: /* hd */
     276                printf("hd >  ");
     277                fd = fio.open(_path.c_str(), O_RDONLY, DEFAULT_MODE | FIO_S_IFDIR);
     278
     279                if (fd == -EISDIR) {
     280                        printf(" romeo : new node [ %s ] is a dir\n", path.c_str());
     281                }
     282                else if (fd >=0) {
     283                        _isDirectory = false;
     284                        printf(" romeo : new node [ %s ] is -not- a dir (%d)\n",
     285                                path.c_str(), fd);
     286                        fio.close(fd);
     287                }
     288                else
     289                        printf(" romeo : new node [ %s ] is -not- (%d)\n",
     290                                 path.c_str(), fd);
     291
     292                break;
     293
     294                case 1: /* cd */
     295                printf("cd >  ");
     296                fd = fio.open(_path.c_str(), O_RDONLY, DEFAULT_MODE | FIO_S_IFDIR);
     297
     298                if (fd == -ENOENT) {
     299                        printf(" romeo : new node [ %s ] is a dir\n", path.c_str());
     300                }
     301                else if (fd >=0) {
     302                        _isDirectory = false;
     303                        printf(" romeo : new node [ %s ] is -not- a dir (%d)\n",
     304                                path.c_str(), fd);
     305                        fio.close(fd);
     306                }
     307                else
     308                        printf(" romeo : new node [ %s ] is -not- (%d)\n",
     309                                path.c_str(), fd);
     310
     311                break;
     312
     313                case 2: /* usb */
     314                printf("usb >  ");
     315                // fd = fio.open(_path.c_str(), O_RDONLY, DEFAULT_MODE | FIO_S_IFDIR);
     316                fd = fio.chdir(path.c_str());
     317
     318                if (fd == -48) {
     319                        printf(" romeo : new node [ %s ] is a dir\n", path.c_str());
     320                        // fio.close(fd);
     321                        // chdir("");
     322                }
     323                else {
     324                        _isDirectory = false;
     325                        printf(" romeo : new node [ %s ] is a -not- a dir (%d)\n",
     326                                path.c_str(), fd);
     327                }
     328
     329                break;
     330                } /* switch(medium) */
     331
     332        }
     333}
     334
    127335Ps2FilesystemNode::Ps2FilesystemNode(const Ps2FilesystemNode *node) {
    128336        _displayName = node->_displayName;
    129337        _isDirectory = node->_isDirectory;
     
    195403                char listDir[256];
    196404                int fd;
    197405               
    198                 if (_path.lastChar() == '/')
     406                if (_path.lastChar() == '/' /* || _path.lastChar() == ':'*/)
    199407                        fd = fio.dopen(_path.c_str());
    200408                else {
    201409                        sprintf(listDir, "%s/", _path.c_str());
  • backends/platform/ps2/DmaPipe.cpp

    diff -u -N -r branch-0-11-0/backends/platform/ps2/DmaPipe.cpp branch-0-11-0-ps2/backends/platform/ps2/DmaPipe.cpp
    old new  
    1818 * along with this program; if not, write to the Free Software
    1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    2020 *
    21  * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-11-0/backends/platform/ps2/DmaPipe.cpp $
     21 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-10-0/backends/platform/ps2/DmaPipe.cpp $
    2222 * $Id: DmaPipe.cpp 27024 2007-05-30 21:56:52Z fingolfin $
    2323 *
    2424 */
  • backends/platform/ps2/DmaPipe.h

    diff -u -N -r branch-0-11-0/backends/platform/ps2/DmaPipe.h branch-0-11-0-ps2/backends/platform/ps2/DmaPipe.h
    old new  
    1818 * along with this program; if not, write to the Free Software
    1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    2020 *
    21  * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-11-0/backends/platform/ps2/DmaPipe.h $
     21 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-10-0/backends/platform/ps2/DmaPipe.h $
    2222 * $Id: DmaPipe.h 27024 2007-05-30 21:56:52Z fingolfin $
    2323 *
    2424 */
  • backends/platform/ps2/Gs2dScreen.cpp

    diff -u -N -r branch-0-11-0/backends/platform/ps2/Gs2dScreen.cpp branch-0-11-0-ps2/backends/platform/ps2/Gs2dScreen.cpp
    old new  
    1818 * along with this program; if not, write to the Free Software
    1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    2020 *
    21  * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-11-0/backends/platform/ps2/Gs2dScreen.cpp $
    22  * $Id: Gs2dScreen.cpp 27548 2007-06-19 22:39:59Z fingolfin $
     21 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-10-0/backends/platform/ps2/Gs2dScreen.cpp $
     22 * $Id: Gs2dScreen.cpp 27024 2007-05-30 21:56:52Z fingolfin $
    2323 *
    2424 */
    2525
     
    364364        }
    365365}
    366366
     367void Gs2dScreen::clearScreen(void) {
     368        WaitSema(g_DmacSema);
     369        memset(_screenBuf, 0, _width * _height);
     370        _screenChanged = true;
     371        SignalSema(g_DmacSema);
     372}
     373
     374Graphics::Surface *Gs2dScreen::lockScreen() {
     375        WaitSema(g_DmacSema);
     376
     377        _framebuffer.pixels = _screenBuf;
     378        _framebuffer.w = _width;
     379        _framebuffer.h = _height;
     380        _framebuffer.pitch = _width; // -not- _pitch; ! It's EE mem, not Tex
     381        _framebuffer.bytesPerPixel = 1;
     382
     383        return &_framebuffer;
     384}
     385
     386void Gs2dScreen::unlockScreen() {
     387        _screenChanged = true;
     388        SignalSema(g_DmacSema);
     389}
     390
    367391void Gs2dScreen::setPalette(const uint32 *pal, uint8 start, uint16 num) {
    368392        assert(start + num <= 256);
    369393
     
    386410        }
    387411}
    388412
    389 Graphics::Surface *Gs2dScreen::lockScreen() {
     413void Gs2dScreen::grabScreen(Graphics::Surface *surf) {
     414        assert(surf);
    390415        WaitSema(g_DmacSema);
    391 
    392         _framebuffer.pixels = _screen->pixels;
    393         _framebuffer.w = _screen->w;
    394         _framebuffer.h = _screen->h;
    395         _framebuffer.pitch = _screen->pitch;
    396         _framebuffer.bytesPerPixel = 1;
    397 
    398         return &_framebuffer;
    399 }
    400 
    401 void Gs2dScreen::unlockScreen() {
    402         _screenChanged = true;
     416        surf->create(_width, _height, 1);
     417        memcpy(surf->pixels, _screenBuf, _width * _height);
    403418        SignalSema(g_DmacSema);
    404419}
    405420
  • backends/platform/ps2/Gs2dScreen.h

    diff -u -N -r branch-0-11-0/backends/platform/ps2/Gs2dScreen.h branch-0-11-0-ps2/backends/platform/ps2/Gs2dScreen.h
    old new  
    1818 * along with this program; if not, write to the Free Software
    1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    2020 *
    21  * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-11-0/backends/platform/ps2/Gs2dScreen.h $
    22  * $Id: Gs2dScreen.h 27548 2007-06-19 22:39:59Z fingolfin $
     21 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-10-0/backends/platform/ps2/Gs2dScreen.h $
     22 * $Id: Gs2dScreen.h 27024 2007-05-30 21:56:52Z fingolfin $
    2323 *
    2424 */
    2525
     
    2828
    2929#include "sysdefs.h"
    3030#include "backends/platform/ps2/DmaPipe.h"
     31#include "graphics/surface.h"
    3132
    3233enum TVMode {
    3334        TV_DONT_CARE = 0,
     
    5657
    5758        void copyPrintfOverlay(const uint8* buf);
    5859        void clearPrintfOverlay(void);
     60        void clearScreen(void);
     61
     62        Graphics::Surface *lockScreen();
     63        void unlockScreen();
    5964
    6065        void copyScreenRect(const uint8 *buf, int pitch, int x, int y, int w, int h);
    6166        void setPalette(const uint32 *pal, uint8 start, uint16 num);
    6267        void updateScreen(void);
    6368        void grabPalette(uint32 *pal, uint8 start, uint16 num);
    64         Graphics::Surface *lockScreen();
    65         void unlockScreen();
     69        void grabScreen(Graphics::Surface *surf);
    6670        //- overlay routines
    6771        void copyOverlayRect(const uint16 *buf, uint16 pitch, uint16 x, uint16 y, uint16 w, uint16 h);
    6872        void grabOverlay(uint16 *buf, uint16 pitch);
     
    9498        uint32 _clutPtrs[3];    //   vram pointers
    9599        uint32 _texPtrs[4];     //
    96100
     101        Graphics::Surface _framebuffer;
    97102        uint16 _width, _height, _pitch;
    98103        int16  _mouseX, _mouseY, _hotSpotX, _hotSpotY;
    99104        uint32 _mouseScaleX, _mouseScaleY;
    100105        uint8  _mTraCol;
    101106
    102         Graphics::Surface _framebuffer;
    103 
    104107        int _shakePos;
    105108
    106109        bool _showMouse, _showOverlay, _screenChanged, _overlayChanged, _clutChanged;
  • backends/platform/ps2/GsDefs.h

    diff -u -N -r branch-0-11-0/backends/platform/ps2/GsDefs.h branch-0-11-0-ps2/backends/platform/ps2/GsDefs.h
    old new  
    1818 * along with this program; if not, write to the Free Software
    1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    2020 *
    21  * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-11-0/backends/platform/ps2/GsDefs.h $
     21 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-10-0/backends/platform/ps2/GsDefs.h $
    2222 * $Id: GsDefs.h 27024 2007-05-30 21:56:52Z fingolfin $
    2323 *
    2424 */
  • backends/platform/ps2/Makefile.ps2

    diff -u -N -r branch-0-11-0/backends/platform/ps2/Makefile.ps2 branch-0-11-0-ps2/backends/platform/ps2/Makefile.ps2
    old new  
     1# $Header: Exp $
     2include $(PS2SDK)/Defs.make
     3
     4DISABLE_SCALERS = true
     5DISABLE_HQ_SCALERS = true
     6# DISABLE_KYRA = true
     7HAVE_GCC3 = true
     8
     9CC              = ee-gcc
     10CXX     = ee-g++
     11AS      = ee-gcc
     12LD      = ee-gcc
     13AR      = ee-ar cru
     14RANLIB  = ee-ranlib
     15STRIP   = ee-strip
     16MKDIR   = mkdir -p
     17RM      = rm -f
     18
     19srcdir = ../../..
     20VPATH = $(srcdir)
     21INCDIR = ../../../
     22
     23DEFINES  = -DUSE_VORBIS -DUSE_TREMOR -DUSE_MAD -DUSE_MPEG2 -DUSE_ZLIB -D_EE -D__PLAYSTATION2__ -O2 -Wall -Wno-multichar
     24
     25# PS2SDK-Ports from ps2dev.org's SVN repository for libmad, zlib and ucl
     26PS2SDK_PORTS = /mnt/winxp/scummvm/ports
     27PS2SDK_PORTS_INCS = /ucl /zlib/include /libmad/ee/include
     28PS2SDK_PORTS_LIBS = /ucl /zlib/lib /libmad/ee/lib
     29
     30# we also need SjPcm, Tremor and libmpeg2
     31MORE_LIBS_DIR = /mnt/winxp/scummvm/ports
     32MORE_LIBS_INCS = /SjPcm/ee/src /mpeg2dec/include /tremor
     33MORE_LIBS_LIBS = /SjPcm/ee/lib /mpeg2dec/libmpeg2 /tremor/tremor
     34
     35INCLUDES  = $(addprefix -I$(PS2SDK_PORTS),$(PS2SDK_PORTS_INCS))
     36INCLUDES += $(addprefix -I$(MORE_LIBS_DIR),$(MORE_LIBS_INCS))
     37INCLUDES += -I $(PS2SDK)/ee/include -I $(PS2SDK)/common/include -I ./common -I . -I $(srcdir) -I $(srcdir)/engines
     38
     39TARGET = elf/scummvm.elf
     40
     41OBJS := backends/platform/ps2/DmaPipe.o \
     42    backends/platform/ps2/Gs2dScreen.o \
     43    backends/platform/ps2/irxboot.o \
     44        backends/platform/ps2/ps2input.o \
     45        backends/platform/ps2/ps2pad.o \
     46    backends/platform/ps2/savefile.o \
     47    backends/platform/ps2/fileio.o \
     48    backends/platform/ps2/icon.o \
     49    backends/platform/ps2/asyncfio.o \
     50    backends/platform/ps2/cd.o \
     51    backends/platform/ps2/eecodyvdfs.o \
     52    backends/platform/ps2/rpckbd.o \
     53    backends/platform/ps2/systemps2.o \
     54    backends/platform/ps2/ps2mutex.o \
     55    backends/platform/ps2/ps2time.o
     56   
     57MODULE_DIRS += .
     58
     59include $(srcdir)/Makefile.common
     60
     61LDFLAGS += -mno-crt0 $(PS2SDK)/ee/startup/crt0.o -T $(PS2SDK)/ee/startup/linkfile
     62LDFLAGS += -L $(PS2SDK)/ee/lib -L .
     63LDFLAGS += $(addprefix -L$(MORE_LIBS_DIR),$(MORE_LIBS_LIBS))
     64LDFLAGS += $(addprefix -L$(PS2SDK_PORTS),$(PS2SDK_PORTS_LIBS))
     65LDFLAGS += -lmc -lpad -lmouse -lhdd -lpoweroff -lsjpcm -lmpeg2 -lmad -ltremor -lz -lucl -lm -lc -lfileXio -lkernel -lstdc++
     66# LDFLAGS += -s
     67
     68all: $(TARGET)
     69
     70$(TARGET): $(OBJS)
     71        $(LD) $^ $(LDFLAGS) -o $@
     72
  • backends/platform/ps2/asyncfio.cpp

    diff -u -N -r branch-0-11-0/backends/platform/ps2/asyncfio.cpp branch-0-11-0-ps2/backends/platform/ps2/asyncfio.cpp
    old new  
    1818 * along with this program; if not, write to the Free Software
    1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    2020 *
    21  * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-11-0/backends/platform/ps2/asyncfio.cpp $
     21 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-10-0/backends/platform/ps2/asyncfio.cpp $
    2222 * $Id: asyncfio.cpp 27024 2007-05-30 21:56:52Z fingolfin $
    2323 *
    2424 */
     
    3535
    3636extern void sioprintf(const char *zFormat, ...);
    3737
     38#define dbg_printf sioprintf
     39// #define dbg_printf printf
     40
    3841AsyncFio::AsyncFio(void) {
    3942        _runningOp = NULL;
    4043        memset((int *)_ioSlots, 0, MAX_HANDLES * sizeof(int));
     
    5558        fileXioOpen(name, ioMode, DEFAULT_MODE);
    5659        fileXioWaitAsync(FXIO_WAIT, &res);
    5760        SignalSema(_ioSema);
     61        dbg_printf("FIO: open(%s, %d) => %d", name, ioMode, res);
     62        return res;
     63}
     64
     65int AsyncFio::open(const char *name, int ioMode, int mode) {
     66        WaitSema(_ioSema);
     67        checkSync();
     68        int res;
     69        fileXioOpen(name, ioMode, mode);
     70        fileXioWaitAsync(FXIO_WAIT, &res);
     71        SignalSema(_ioSema);
     72        dbg_printf("FIO: open ext(%s, %d, %d) => %d", name, ioMode, mode, res);
    5873        return res;
    5974}
    6075
     
    6479        fileXioClose(handle);
    6580        int res;
    6681        fileXioWaitAsync(FXIO_WAIT, &res);
     82        dbg_printf("FIO: close(%d) => %d", handle, res);
    6783        if (res != 0)
    6884                sioprintf("ERROR: fileXioClose failed, EC %d", res);
    6985        _ioSlots[handle] = 0;
     
    122138        fileXioDopen(name);
    123139        fileXioWaitAsync(FXIO_WAIT, &res);
    124140        SignalSema(_ioSema);
     141        dbg_printf("FIO: dopen(%s) => %d", name, res);
    125142        return res;
    126143}
    127144
     
    141158        checkSync();
    142159        fileXioDclose(fd);
    143160        fileXioWaitAsync(FXIO_WAIT, &res);
    144         assert(res == 0);
     161        //assert(res == 0);
     162        dbg_printf("FIO: dclose(%d) => %d", fd, res);
     163        if (res != 0)
     164                sioprintf("ERROR: fileXioDclose failed, EC %d", res);
    145165        SignalSema(_ioSema);
    146166}
    147167
     168int AsyncFio::chdir(const char *name) {
     169        int res;
     170        WaitSema(_ioSema);
     171        checkSync();
     172        fileXioChdir(name);
     173        fileXioWaitAsync(FXIO_WAIT, &res);
     174        SignalSema(_ioSema);
     175        return res;
     176}
     177
    148178int AsyncFio::mount(const char *mountpoint, const char *mountstring, int flag) {
    149179        int res;
    150180        WaitSema(_ioSema);
  • backends/platform/ps2/asyncfio.h

    diff -u -N -r branch-0-11-0/backends/platform/ps2/asyncfio.h branch-0-11-0-ps2/backends/platform/ps2/asyncfio.h
    old new  
    1818 * along with this program; if not, write to the Free Software
    1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    2020 *
    21  * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-11-0/backends/platform/ps2/asyncfio.h $
     21 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-10-0/backends/platform/ps2/asyncfio.h $
    2222 * $Id: asyncfio.h 27024 2007-05-30 21:56:52Z fingolfin $
    2323 *
    2424 */
     
    3131        AsyncFio(void);
    3232        ~AsyncFio(void);
    3333        int open(const char *name, int ioMode);
     34        int open(const char *name, int ioMode, int mode);
    3435        void close(int handle);
    3536        void read(int fd, void *dest, unsigned int len);
    3637        void write(int fd, const void *src, unsigned int len);
     
    3940        int dopen(const char *name);
    4041        int dread(int fd, iox_dirent_t *dest);
    4142        void dclose(int fd);
     43        int chdir(const char *name);
    4244        int mount(const char *mountpoint, const char *mountstring, int flag);
    4345        int umount(const char *mountpoint);
    4446        int sync(int fd);
  • backends/platform/ps2/eecodyvdfs.c

    diff -u -N -r branch-0-11-0/backends/platform/ps2/eecodyvdfs.c branch-0-11-0-ps2/backends/platform/ps2/eecodyvdfs.c
    old new  
    1818 * along with this program; if not, write to the Free Software
    1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    2020 *
    21  * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-11-0/backends/platform/ps2/eecodyvdfs.c $
     21 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-10-0/backends/platform/ps2/eecodyvdfs.c $
    2222 * $Id: eecodyvdfs.c 27024 2007-05-30 21:56:52Z fingolfin $
    2323 *
    2424 */
  • backends/platform/ps2/eecodyvdfs.h

    diff -u -N -r branch-0-11-0/backends/platform/ps2/eecodyvdfs.h branch-0-11-0-ps2/backends/platform/ps2/eecodyvdfs.h
    old new  
    1818 * along with this program; if not, write to the Free Software
    1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    2020 *
    21  * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-11-0/backends/platform/ps2/eecodyvdfs.h $
     21 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-10-0/backends/platform/ps2/eecodyvdfs.h $
    2222 * $Id: eecodyvdfs.h 27024 2007-05-30 21:56:52Z fingolfin $
    2323 *
    2424 */
  • backends/platform/ps2/fileio.cpp

    diff -u -N -r branch-0-11-0/backends/platform/ps2/fileio.cpp branch-0-11-0-ps2/backends/platform/ps2/fileio.cpp
    old new  
    1818 * along with this program; if not, write to the Free Software
    1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    2020 *
    21  * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-11-0/backends/platform/ps2/fileio.cpp $
     21 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-10-0/backends/platform/ps2/fileio.cpp $
    2222 * $Id: fileio.cpp 27024 2007-05-30 21:56:52Z fingolfin $
    2323 *
    2424 */
  • backends/platform/ps2/fileio.h

    diff -u -N -r branch-0-11-0/backends/platform/ps2/fileio.h branch-0-11-0-ps2/backends/platform/ps2/fileio.h
    old new  
    1818 * along with this program; if not, write to the Free Software
    1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    2020 *
    21  * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-11-0/backends/platform/ps2/fileio.h $
     21 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-10-0/backends/platform/ps2/fileio.h $
    2222 * $Id: fileio.h 27024 2007-05-30 21:56:52Z fingolfin $
    2323 *
    2424 */
     
    2626#ifndef __PS2FILE_IO__
    2727#define __PS2FILE_IO__
    2828
     29typedef unsigned long uint64;
     30typedef signed long   int64;
     31
     32#include <stdio.h>
    2933#include "common/scummsys.h"
    3034
    3135class Ps2File {
  • backends/platform/ps2/icon.cpp

    diff -u -N -r branch-0-11-0/backends/platform/ps2/icon.cpp branch-0-11-0-ps2/backends/platform/ps2/icon.cpp
    old new  
    1818 * along with this program; if not, write to the Free Software
    1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    2020 *
    21  * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-11-0/backends/platform/ps2/icon.cpp $
     21 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-10-0/backends/platform/ps2/icon.cpp $
    2222 * $Id: icon.cpp 27024 2007-05-30 21:56:52Z fingolfin $
    2323 *
    2424 */
  • backends/platform/ps2/iop/rpckbd/Makefile

    diff -u -N -r branch-0-11-0/backends/platform/ps2/iop/rpckbd/Makefile branch-0-11-0-ps2/backends/platform/ps2/iop/rpckbd/Makefile
    old new  
     1# _____     ___ ____     ___ ____
     2#  ____|   |    ____|   |        | |____|
     3# |     ___|   |____ ___|    ____| |    \    PS2DEV Open Source Project.
     4#-----------------------------------------------------------------------
     5# Copyright 2001-2004, ps2dev - http://www.ps2dev.org
     6# Licenced under Academic Free License version 2.0
     7# Review ps2sdk README & LICENSE files for further details.
     8#
     9# $Id: Makefile,v 1.3 2004/09/14 14:41:46 pixel Exp $
     10
     11
     12IOP_OBJS_DIR = obj/
     13IOP_BIN_DIR = bin/
     14IOP_SRC_DIR = src/
     15IOP_INC_DIR = include/
     16
     17IOP_BIN=bin/rpckbd.irx
     18IOP_OBJS=obj/ps2kbd.o obj/imports.o
     19
     20IOP_CFLAGS=-Wall
     21IOP_INCS += -I$(PS2SDKSRC)/iop/usb/usbd/include
     22
     23all: $(IOP_OBJS_DIR) $(IOP_BIN_DIR) $(IOP_BIN)
     24
     25clean:
     26        rm -f -r $(IOP_OBJS_DIR) $(IOP_BIN_DIR)
     27
     28include $(PS2SDKSRC)/Defs.make
     29include $(PS2SDKSRC)/iop/Rules.make
     30include $(PS2SDKSRC)/iop/Rules.release
  • backends/platform/ps2/iop/rpckbd/include/__ps2kbd.h

    diff -u -N -r branch-0-11-0/backends/platform/ps2/iop/rpckbd/include/__ps2kbd.h branch-0-11-0-ps2/backends/platform/ps2/iop/rpckbd/include/__ps2kbd.h
    old new  
     1/*
     2# _____     ___ ____     ___ ____
     3#  ____|   |    ____|   |        | |____|
     4# |     ___|   |____ ___|    ____| |    \    PS2DEV Open Source Project.
     5#-----------------------------------------------------------------------
     6# Copyright 2001-2004, ps2dev - http://www.ps2dev.org
     7# Licenced under Academic Free License version 2.0
     8# Review ps2sdk README & LICENSE files for further details.
     9#
     10# $Id: ps2kbd.h,v 1.2 2004/09/14 14:41:46 pixel Exp $
     11# USB Keyboard Driver for PS2
     12*/
     13
     14#ifndef __PS2KBD_H__
     15#define __PS2KBD_H__
     16
     17#define PS2KBD_FSNAME "usbkbd"
     18#define PS2KBD_KBDFILE "dev"
     19#define PS2KBD_DEVFILE (PS2KBD_FSNAME ":" PS2KBD_KBDFILE)
     20
     21
     22#define PS2KBD_LED_NUMLOCK   1
     23#define PS2KBD_LED_CAPSLOCK  2
     24#define PS2KBD_LED_SCRLOCK   4
     25#define PS2KBD_LED_COMPOSE   8
     26#define PS2KBD_LED_KANA      16
     27
     28#define PS2KBD_LED_MASK      0x1F;
     29
     30#define PS2KBD_ESCAPE_KEY    0x1B
     31
     32#define PS2KBD_LEFT_CTRL   (1 << 0)
     33#define PS2KBD_LEFT_SHIFT  (1 << 1)
     34#define PS2KBD_LEFT_ALT    (1 << 2)
     35#define PS2KBD_LEFT_GUI    (1 << 3)
     36#define PS2KBD_RIGHT_CTRL  (1 << 4)
     37#define PS2KBD_RIGHT_SHIFT (1 << 5)
     38#define PS2KBD_RIGHT_ALT   (1 << 6)
     39#define PS2KBD_RIGHT_GUI   (1 << 7)
     40
     41#define PS2KBD_CTRL    (PS2KBD_LEFT_CTRL | PS2KBD_RIGHT_CTRL)
     42#define PS2KBD_SHIFT  (PS2KBD_LEFT_SHIFT | PS2KBD_RIGHT_SHIFT)
     43#define PS2KBD_ALT    (PS2KBD_LEFT_ALT | PS2KBD_RIGHT_ALT)
     44#define PS2KBD_GUI    (PS2KBD_LEFT_GUI | PS2KBD_RIGHT_GUI)
     45
     46#define PS2KBD_RAWKEY_UP   0xF0
     47#define PS2KBD_RAWKEY_DOWN 0xF1
     48
     49typedef struct _kbd_rawkey
     50
     51{
     52  u8 state;
     53  u8 key;
     54} kbd_rawkey __attribute__ ((packed));
     55
     56#define PS2KBD_READMODE_NORMAL 1
     57#define PS2KBD_READMODE_RAW    2
     58
     59/* Notes on read mode */
     60/* In normal readmode (default) read multiples of 1 character off the keyboard file. These are
     61   processed by the keymaps so that you get back ASCII data */
     62/* In raw readmode must read multiples of 2. First byte indicates state (i.e. Up or Down)
     63   Second byte is the USB key code for that key. This table is presented in the USB HID Usage Tables manaual
     64   from usb.org */
     65
     66#define PS2KBD_BLOCKING 1
     67#define PS2KBD_NONBLOCKING 0
     68
     69#define PS2KBD_KEYMAP_SIZE 256
     70
     71typedef struct _kbd_keymap
     72
     73{
     74  u8 keymap[PS2KBD_KEYMAP_SIZE];
     75  u8 shiftkeymap[PS2KBD_KEYMAP_SIZE];
     76  u8 keycap[PS2KBD_KEYMAP_SIZE];
     77} kbd_keymap;
     78
     79/* IOCTLs for the keyboard file driver */
     80
     81#define PS2KBD_IOCTL_SETREADMODE     1 /* Sets up keymapped or raw mode */
     82#define PS2KBD_IOCTL_SETLEDS         2 /* Sets the LED state for ALL keyboards connected */
     83#define PS2KBD_IOCTL_SETREPEATRATE   3 /* Sets the repeat rate of the keyboard */
     84#define PS2KBD_IOCTL_SETKEYMAP       4 /* Sets the keymap for the standard keys, non shifted and shifted */
     85#define PS2KBD_IOCTL_SETCTRLMAP      5 /* Sets the control key mapping */
     86#define PS2KBD_IOCTL_SETALTMAP       6 /* Sets the alt key mapping */
     87#define PS2KBD_IOCTL_SETSPECIALMAP   7 /* Sets the special key mapping */
     88#define PS2KBD_IOCTL_SETBLOCKMODE    8 /* Sets whether the keyboard driver blocks on read */
     89#define PS2KBD_IOCTL_FLUSHBUFFER     9 /* Flush the internal buffer, probably best after a keymap change */
     90#define PS2KBD_IOCTL_RESETKEYMAP    10 /* Reset keymaps to default states */
     91
     92/* Note on keymaps. In normal keymap a 0 would indicate no key */
     93/* Key maps are represented by 3 256*8bit tables. First table maps USB key to a char when not shifted */
     94/* Second table maps USB key to a char when shifted */
     95/* Third table contains boolean values. If 1 then the key is shifted/unshifted in capslock, else capslock is ignored */
     96
     97#endif
  • backends/platform/ps2/iop/rpckbd/include/ps2kbd.h

    diff -u -N -r branch-0-11-0/backends/platform/ps2/iop/rpckbd/include/ps2kbd.h branch-0-11-0-ps2/backends/platform/ps2/iop/rpckbd/include/ps2kbd.h
    old new  
     1/*
     2# _____     ___ ____     ___ ____
     3#  ____|   |    ____|   |        | |____|
     4# |     ___|   |____ ___|    ____| |    \    PS2DEV Open Source Project.
     5#-----------------------------------------------------------------------
     6# Copyright 2001-2004, ps2dev - http://www.ps2dev.org
     7# Licenced under Academic Free License version 2.0
     8# Review ps2sdk README & LICENSE files for further details.
     9#
     10# $Id: ps2kbd.h,v 1.2 2004/09/14 14:41:46 pixel Exp $
     11# USB Keyboard Driver for PS2
     12*/
     13
     14#ifndef __PS2KBD_H__
     15#define __PS2KBD_H__
     16
     17#define PS2KBD_RPC_ID   0xb0b0b80
     18
     19#define PS2KBD_LED_NUMLOCK   1
     20#define PS2KBD_LED_CAPSLOCK  2
     21#define PS2KBD_LED_SCRLOCK   4
     22#define PS2KBD_LED_COMPOSE   8
     23#define PS2KBD_LED_KANA      16
     24
     25#define PS2KBD_LED_MASK      0x1F;
     26
     27#define PS2KBD_ESCAPE_KEY    0x1B
     28
     29#define PS2KBD_LEFT_CTRL   (1 << 0)
     30#define PS2KBD_LEFT_SHIFT  (1 << 1)
     31#define PS2KBD_LEFT_ALT    (1 << 2)
     32#define PS2KBD_LEFT_GUI    (1 << 3)
     33#define PS2KBD_RIGHT_CTRL  (1 << 4)
     34#define PS2KBD_RIGHT_SHIFT (1 << 5)
     35#define PS2KBD_RIGHT_ALT   (1 << 6)
     36#define PS2KBD_RIGHT_GUI   (1 << 7)
     37
     38#define PS2KBD_CTRL    (PS2KBD_LEFT_CTRL | PS2KBD_RIGHT_CTRL)
     39#define PS2KBD_SHIFT  (PS2KBD_LEFT_SHIFT | PS2KBD_RIGHT_SHIFT)
     40#define PS2KBD_ALT    (PS2KBD_LEFT_ALT | PS2KBD_RIGHT_ALT)
     41#define PS2KBD_GUI    (PS2KBD_LEFT_GUI | PS2KBD_RIGHT_GUI)
     42
     43#define PS2KBD_RAWKEY_UP   0xF0
     44#define PS2KBD_RAWKEY_DOWN 0xF1
     45
     46typedef struct _kbd_rawkey {
     47  u8 state;
     48  u8 key;
     49} kbd_rawkey __attribute__ ((packed));
     50
     51#define PS2KBD_READMODE_NORMAL 1
     52#define PS2KBD_READMODE_RAW    2
     53
     54/* Notes on read mode */
     55/* In normal readmode (default) read multiples of 1 character off the keyboard file. These are
     56   processed by the keymaps so that you get back ASCII data */
     57/* In raw readmode must read multiples of 2. First byte indicates state (i.e. Up or Down)
     58   Second byte is the USB key code for that key. This table is presented in the USB HID Usage Tables manaual
     59   from usb.org */
     60
     61#define PS2KBD_KEYMAP_SIZE 256
     62
     63typedef struct _kbd_keymap
     64
     65{
     66  u8 keymap[PS2KBD_KEYMAP_SIZE];
     67  u8 shiftkeymap[PS2KBD_KEYMAP_SIZE];
     68  u8 keycap[PS2KBD_KEYMAP_SIZE];
     69} kbd_keymap;
     70
     71
     72/* IRPC function numbers */
     73#define KBD_RPC_SETREADMODE     1 /* Sets up keymapped or raw mode */
     74#define KBD_RPC_SETLEDS         2 /* Sets the LED state for ALL keyboards connected */
     75#define KBD_RPC_SETREPEATRATE   3 /* Sets the repeat rate of the keyboard */
     76#define KBD_RPC_SETKEYMAP       4 /* Sets the keymap for the standard keys, non shifted and shifted */
     77#define KBD_RPC_SETCTRLMAP      5 /* Sets the control key mapping */
     78#define KBD_RPC_SETALTMAP       6 /* Sets the alt key mapping */
     79#define KBD_RPC_SETSPECIALMAP   7 /* Sets the special key mapping */
     80#define KBD_RPC_FLUSHBUFFER     9 /* Flush the internal buffer, probably best after a keymap change */
     81#define KBD_RPC_RESETKEYMAP    10 /* Reset keymaps to default states */
     82#define KBD_RPC_READKEY            11
     83#define KBD_RPC_READRAW            12
     84
     85/* Note on keymaps. In normal keymap a 0 would indicate no key */
     86/* Key maps are represented by 3 256*8bit tables. First table maps USB key to a char when not shifted */
     87/* Second table maps USB key to a char when shifted */
     88/* Third table contains boolean values. If 1 then the key is shifted/unshifted in capslock, else capslock is ignored */
     89
     90#endif
  • backends/platform/ps2/iop/rpckbd/src/imports.lst

    diff -u -N -r branch-0-11-0/backends/platform/ps2/iop/rpckbd/src/imports.lst branch-0-11-0-ps2/backends/platform/ps2/iop/rpckbd/src/imports.lst
    old new  
     1
     2sysclib_IMPORTS_start
     3I_memset
     4I_strcmp
     5I_memcpy
     6sysclib_IMPORTS_end
     7
     8loadcore_IMPORTS_start
     9I_FlushDcache
     10loadcore_IMPORTS_end
     11
     12sifcmd_IMPORTS_start
     13I_sceSifInitRpc
     14I_sceSifSetRpcQueue
     15I_sceSifRegisterRpc
     16I_sceSifRpcLoop
     17sifcmd_IMPORTS_end
     18
     19stdio_IMPORTS_start
     20I_printf
     21stdio_IMPORTS_end
     22
     23thsemap_IMPORTS_start
     24I_CreateSema
     25I_SignalSema
     26I_WaitSema
     27I_PollSema
     28I_DeleteSema
     29thsemap_IMPORTS_end
     30
     31thbase_IMPORTS_start
     32I_StartThread
     33I_CreateThread
     34I_USec2SysClock
     35I_iSetAlarm
     36I_SetAlarm
     37I_CancelAlarm
     38thbase_IMPORTS_end
     39
     40thevent_IMPORTS_start
     41I_WaitEventFlag
     42I_iSetEventFlag
     43I_CreateEventFlag
     44thevent_IMPORTS_end
     45
     46sysmem_IMPORTS_start
     47I_AllocSysMemory
     48I_FreeSysMemory
     49sysmem_IMPORTS_end
     50
     51usbd_IMPORTS_start
     52I_UsbGetDeviceStaticDescriptor
     53I_UsbOpenEndpoint
     54I_UsbSetDevicePrivateData
     55I_UsbTransfer
     56I_UsbRegisterDriver
     57usbd_IMPORTS_end
     58
  • backends/platform/ps2/iop/rpckbd/src/irx_imports.h

    diff -u -N -r branch-0-11-0/backends/platform/ps2/iop/rpckbd/src/irx_imports.h branch-0-11-0-ps2/backends/platform/ps2/iop/rpckbd/src/irx_imports.h
    old new  
     1/*
     2# _____     ___ ____     ___ ____
     3#  ____|   |    ____|   |        | |____|
     4# |     ___|   |____ ___|    ____| |    \    PS2DEV Open Source Project.
     5#-----------------------------------------------------------------------
     6# Copyright (c) 2003 Marcus R. Brown <mrbrown@0xd6.org>
     7# Licenced under Academic Free License version 2.0
     8# Review ps2sdk README & LICENSE files for further details.
     9#
     10# $Id: irx_imports.h,v 1.4 2004/10/11 00:45:00 mrbrown Exp $
     11# Defines all IRX imports.
     12*/
     13
     14#ifndef IOP_IRX_IMPORTS_H
     15#define IOP_IRX_IMPORTS_H
     16
     17#include "irx.h"
     18
     19/* Please keep these in alphabetical order!  */
     20#include "dmacman.h"
     21#include "intrman.h"
     22#include "libsd.h"
     23#include "loadcore.h"
     24#include "sifcmd.h"
     25#include "stdio.h"
     26#include "sysclib.h"
     27#include "sysmem.h"
     28#include "thbase.h"
     29#include "thevent.h"
     30#include "thmsgbx.h"
     31#include "thsemap.h"
     32#include "usbd.h"
     33#include "vblank.h"
     34
     35#endif /* IOP_IRX_IMPORTS_H */
  • backends/platform/ps2/iop/rpckbd/src/ps2kbd.c

    diff -u -N -r branch-0-11-0/backends/platform/ps2/iop/rpckbd/src/ps2kbd.c branch-0-11-0-ps2/backends/platform/ps2/iop/rpckbd/src/ps2kbd.c
    old new  
     1/*
     2# _____     ___ ____     ___ ____
     3#  ____|   |    ____|   |        | |____|
     4# |     ___|   |____ ___|    ____| |    \    PS2DEV Open Source Project.
     5#-----------------------------------------------------------------------
     6# Copyright 2001-2005, ps2dev - http://www.ps2dev.org
     7# Licenced under Academic Free License version 2.0
     8# Review ps2sdk README & LICENSE files for further details.
     9#
     10# $Id: ps2kbd.c,v 1.4 2004/09/14 14:41:46 pixel Exp $
     11# USB Keyboard Driver for PS2
     12*/
     13
     14#include "types.h"
     15#include "ioman.h"
     16#include "loadcore.h"
     17#include "stdio.h"
     18#include "sifcmd.h"
     19#include "sifrpc.h"
     20#include "sysclib.h"
     21#include "sysmem.h"
     22#include "usbd.h"
     23#include "usbd_macro.h"
     24#include "thbase.h"
     25#include "thevent.h"
     26#include "thsemap.h"
     27
     28#include "ps2kbd.h"
     29#include "us_keymap.h"
     30
     31#define PS2KBD_VERSION 0x100
     32
     33#define USB_SUBCLASS_BOOT 1
     34#define USB_HIDPROTO_KEYBOARD 1
     35
     36#define PS2KBD_MAXDEV 2
     37#define PS2KBD_MAXKEYS 6
     38
     39#define PS2KBD_DEFLINELEN 4096
     40#define PS2KBD_DEFREPEATRATE 100
     41/* Default repeat rate in milliseconds */
     42#define PS2KBD_REPEATWAIT 1000
     43/* Number of milliseconds to wait before starting key repeat */
     44#define USB_KEYB_NUMLOCK 0x53
     45#define USB_KEYB_CAPSLOCK 0x39
     46#define USB_KEYB_SCRLOCK 0x47
     47
     48#define USB_KEYB_NUMPAD_START 0x54
     49#define USB_KEYB_NUMPAD_END 0x63
     50
     51#define SEMA_ZERO -419
     52#define SEMA_DELETED -425
     53
     54int ps2kbd_init();
     55void ps2kbd_config_set(int resultCode, int bytes, void *arg);
     56void ps2kbd_idlemode_set(int resultCode, int bytes, void *arg);
     57void ps2kbd_data_recv(int resultCode, int bytes, void *arg);
     58int ps2kbd_probe(int devId);
     59int ps2kbd_connect(int devId);
     60int ps2kbd_disconnect(int devId);
     61void usb_getstring(int endp, int index, char *desc);
     62
     63typedef struct _kbd_data_recv
     64
     65{
     66  u8 mod_keys;
     67  u8 reserved;
     68  u8 keycodes[PS2KBD_MAXKEYS];
     69} kbd_data_recv;
     70
     71typedef struct _keyb_dev
     72
     73{
     74  int configEndp;
     75  int dataEndp;
     76  int packetSize;
     77  int devId;
     78  int interfaceNo;    /* Holds the interface number selected on this device */
     79  char repeatkeys[2];
     80  u32 eventmask;
     81  u8 ledStatus;     /* Maintains state on the led status */
     82  kbd_data_recv oldData;
     83  kbd_data_recv data; /* Holds the data for the transfers */
     84} kbd_dev;
     85
     86/* Global Variables */
     87
     88int kbd_readmode;
     89u32 kbd_repeatrate;
     90kbd_dev *devices[PS2KBD_MAXDEV]; /* Holds a list of current devices */
     91int dev_count;
     92UsbDriver kbd_driver = { NULL, NULL, "PS2Kbd", ps2kbd_probe, ps2kbd_connect, ps2kbd_disconnect };
     93u8 *lineBuffer;
     94u32 lineStartP, lineEndP;
     95int lineSema;
     96int bufferSema;
     97u32 lineSize;
     98u8 keymap[PS2KBD_KEYMAP_SIZE];         /* Normal key map */
     99u8 shiftkeymap[PS2KBD_KEYMAP_SIZE];  /* Shifted key map */
     100u8 keycap[PS2KBD_KEYMAP_SIZE];          /* Does this key get shifted by capslock ? */
     101u8 special_keys[PS2KBD_KEYMAP_SIZE];
     102u8 control_map[PS2KBD_KEYMAP_SIZE];
     103u8 alt_map[PS2KBD_KEYMAP_SIZE];
     104//static struct fileio_driver kbd_fdriver;
     105iop_device_t kbd_filedrv;
     106u8 keyModValue[8] = { 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7 };
     107int repeat_tid;
     108int eventid;   /* Id of the repeat event */
     109
     110int _start ()
     111{
     112  FlushDcache();
     113
     114  ps2kbd_init();
     115
     116  printf("PS2KBD - USB Keyboard Library\n");
     117
     118  return 0;
     119
     120}
     121
     122int ps2kbd_probe(int devId)
     123
     124{
     125  UsbDeviceDescriptor *dev;
     126  UsbConfigDescriptor *conf;
     127  UsbInterfaceDescriptor *intf;
     128  UsbEndpointDescriptor *endp;
     129  //UsbStringDescriptor *str;
     130
     131  if(dev_count >= PS2KBD_MAXDEV)
     132    {
     133      printf("ERROR: Maximum keyboard devices reached\n");
     134      return 0;
     135    }
     136
     137  //printf("PS2Kbd_probe devId %d\n", devId);
     138
     139  dev = UsbGetDeviceStaticDescriptor(devId, NULL, USB_DT_DEVICE); /* Get device descriptor */
     140  if(!dev)
     141    {
     142      printf("ERROR: Couldn't get device descriptor\n");
     143      return 0;
     144    }
     145
     146  //printf("Device class %d, Size %d, Man %d, Product %d Cpnfigurations %d\n", dev->bDeviceClass, dev->bMaxPacketSize0, dev->iManufacturer, dev->iProduct, dev->bNumConfigurations);
     147  /* Check that the device class is specified in the interfaces and it has at least one configuration */
     148  if((dev->bDeviceClass != USB_CLASS_PER_INTERFACE) || (dev->bNumConfigurations < 1))
     149    {
     150      //printf("This is not the droid you're looking for\n");
     151      return 0;
     152    }
     153
     154  conf = UsbGetDeviceStaticDescriptor(devId, dev, USB_DT_CONFIG);
     155  if(!conf)
     156    {
     157      printf("ERROR: Couldn't get configuration descriptor\n");
     158      return 0;
     159    }
     160  //printf("Config Length %d Total %d Interfaces %d\n", conf->bLength, conf->wTotalLength, conf->bNumInterfaces);
     161
     162  if((conf->bNumInterfaces < 1) || (conf->wTotalLength < (sizeof(UsbConfigDescriptor) + sizeof(UsbInterfaceDescriptor))))
     163    {
     164      printf("ERROR: No interfaces available\n");
     165      return 0;
     166    }
     167     
     168  intf = (UsbInterfaceDescriptor *) ((char *) conf + conf->bLength); /* Get first interface */
     169/*   printf("Interface Length %d Endpoints %d Class %d Sub %d Proto %d\n", intf->bLength, */
     170/*       intf->bNumEndpoints, intf->bInterfaceClass, intf->bInterfaceSubClass, */
     171/*       intf->bInterfaceProtocol); */
     172
     173  if((intf->bInterfaceClass != USB_CLASS_HID) || (intf->bInterfaceSubClass != USB_SUBCLASS_BOOT) ||
     174     (intf->bInterfaceProtocol != USB_HIDPROTO_KEYBOARD) || (intf->bNumEndpoints < 1))
     175
     176    {
     177      //printf("We came, we saw, we told it to fuck off\n");
     178      return 0;
     179    }
     180
     181  endp = (UsbEndpointDescriptor *) ((char *) intf + intf->bLength);
     182  endp = (UsbEndpointDescriptor *) ((char *) endp + endp->bLength); /* Go to the data endpoint */
     183
     184  //printf("Endpoint 1 Addr %d, Attr %d, MaxPacket %d\n", endp->bEndpointAddress, endp->bmAttributes, endp->wMaxPacketSizeLB);
     185 
     186  if(((endp->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT) ||
     187     ((endp->bEndpointAddress & USB_ENDPOINT_DIR_MASK) != USB_DIR_IN))
     188    {
     189      printf("ERROR: Endpoint not interrupt type and/or an input\n");
     190      return 0;
     191    }
     192
     193  printf("PS2KBD: Found a keyboard device\n");
     194
     195  return 1;
     196}
     197
     198int ps2kbd_connect(int devId)
     199
     200{
     201  /* Assume we can only get here if we have already checked the device is kosher */
     202
     203  UsbDeviceDescriptor *dev;
     204  UsbConfigDescriptor *conf;
     205  UsbInterfaceDescriptor *intf;
     206  UsbEndpointDescriptor *endp;
     207  kbd_dev *currDev;
     208  int devLoop;
     209
     210  //printf("PS2Kbd_connect devId %d\n", devId);
     211
     212  dev = UsbGetDeviceStaticDescriptor(devId, NULL, USB_DT_DEVICE); /* Get device descriptor */
     213  if(!dev)
     214    {
     215      printf("ERROR: Couldn't get device descriptor\n");
     216      return 1;
     217    }
     218
     219  conf = UsbGetDeviceStaticDescriptor(devId, dev, USB_DT_CONFIG);
     220  if(!conf)
     221    {
     222      printf("ERROR: Couldn't get configuration descriptor\n");
     223      return 1;
     224    }
     225     
     226  intf = (UsbInterfaceDescriptor *) ((char *) conf + conf->bLength); /* Get first interface */
     227  endp = (UsbEndpointDescriptor *) ((char *) intf + intf->bLength);
     228  endp = (UsbEndpointDescriptor *) ((char *) endp + endp->bLength); /* Go to the data endpoint */
     229
     230  for(devLoop = 0; devLoop < PS2KBD_MAXDEV; devLoop++)
     231    {
     232      if(devices[devLoop] == NULL)
     233        {
     234          break;
     235        }
     236    }
     237
     238  if(devLoop == PS2KBD_MAXDEV)
     239    {
     240      /* How the f*** did we end up here ??? */
     241      printf("ERROR: Device Weirdness!!\n");
     242      return 1;
     243    }
     244
     245  currDev = (kbd_dev *) AllocSysMemory(0, sizeof(kbd_dev), NULL);
     246  if(!currDev)
     247    {
     248      printf("ERROR: Couldn't allocate a device point for the kbd\n");
     249      return 1;
     250    }
     251
     252  devices[devLoop] = currDev;
     253  memset(currDev, 0, sizeof(kbd_dev));
     254  currDev->configEndp = UsbOpenEndpoint(devId, NULL);
     255  currDev->dataEndp = UsbOpenEndpoint(devId, endp);
     256  currDev->packetSize = endp->wMaxPacketSizeLB | ((int) endp->wMaxPacketSizeHB << 8);
     257  currDev->eventmask = (1 << devLoop);
     258  if(currDev->packetSize > sizeof(kbd_data_recv))
     259    {
     260      currDev->packetSize = sizeof(kbd_data_recv);
     261    }
     262
     263  if(dev->iManufacturer != 0)
     264    {
     265      usb_getstring(currDev->configEndp, dev->iManufacturer, "Keyboard Manufacturer");
     266    }
     267
     268  if(dev->iProduct != 0)
     269    {
     270      usb_getstring(currDev->configEndp, dev->iProduct, "Keyboard Product");
     271    }
     272
     273  currDev->devId = devId;
     274  currDev->interfaceNo = intf->bInterfaceNumber;
     275  currDev->ledStatus = 0;
     276
     277  UsbSetDevicePrivateData(devId, currDev); /* Set the index for the device data */
     278
     279  //printf("Configuration value %d\n", conf->bConfigurationValue);
     280  UsbSetDeviceConfiguration(currDev->configEndp, conf->bConfigurationValue, ps2kbd_config_set, currDev);
     281
     282  dev_count++; /* Increment device count */
     283  printf("PS2KBD: Connected device\n");
     284
     285  return 0;
     286}
     287
     288int ps2kbd_disconnect(int devId)
     289
     290{
     291  int devLoop;
     292  printf("PS2Kbd_disconnect devId %d\n", devId);
     293
     294  for(devLoop = 0; devLoop < PS2KBD_MAXDEV; devLoop++)
     295    {
     296      if((devices[devLoop]) && (devices[devLoop]->devId == devId))
     297        {
     298          dev_count--;
     299          FreeSysMemory(devices[devLoop]);
     300          devices[devLoop] = NULL;
     301          printf("PS2KBD: Disconnected device\n");
     302          break;
     303        }
     304    }
     305
     306  return 0;
     307}
     308
     309typedef struct _string_descriptor
     310
     311{
     312  u8 buf[200];
     313  char *desc;
     314} string_descriptor;
     315
     316void ps2kbd_getstring_set(int resultCode, int bytes, void *arg)
     317
     318{
     319  UsbStringDescriptor *str = (UsbStringDescriptor *) arg;
     320  string_descriptor *strBuf = (string_descriptor *) arg;
     321  char string[50];
     322  int strLoop;
     323
     324/*   printf("=========getstring=========\n"); */
     325
     326/*   printf("PS2KEYBOARD: GET_DESCRIPTOR res %d, bytes %d, arg %p\n", resultCode, bytes, arg); */
     327
     328  if(resultCode == USB_RC_OK)
     329    {
     330      memset(string, 0, 50);
     331      for(strLoop = 0; strLoop < ((bytes - 2) / 2); strLoop++)
     332        {
     333          string[strLoop] = str->wData[strLoop] & 0xFF;
     334        }
     335      printf("%s: %s\n", strBuf->desc, string);
     336    }
     337 
     338  FreeSysMemory(arg);
     339}
     340
     341void usb_getstring(int endp, int index, char *desc)
     342
     343{
     344  u8 *data;
     345  string_descriptor *str;
     346  int ret;
     347
     348  data = (u8 *) AllocSysMemory(0, sizeof(string_descriptor), NULL);
     349  str = (string_descriptor *) data;
     350
     351  if(data != NULL)
     352    {
     353      str->desc = desc;
     354      ret = UsbControlTransfer(endp, 0x80, USB_REQ_GET_DESCRIPTOR, (USB_DT_STRING << 8) | index,
     355                               0, sizeof(string_descriptor) - 4, data, ps2kbd_getstring_set, data);
     356      if(ret != USB_RC_OK)
     357        {
     358          printf("PS2KBD: Error sending string descriptor request\n");
     359          FreeSysMemory(data);
     360        }
     361    }
     362}
     363
     364void ps2kbd_config_set(int resultCode, int bytes, void *arg)
     365     /* Called when we have finished choosing our configuration */
     366
     367{
     368  kbd_dev *dev;
     369
     370  if(resultCode != USB_RC_OK)
     371    {
     372      printf("PS2KEYBOARD: Configuration set error res %d, bytes %d, arg %p\n", resultCode, bytes, arg);
     373      return;
     374    }
     375
     376  //printf("PS2KEYBOARD: Configuration set res %d, bytes %d, arg %p\n", resultCode, bytes, arg);
     377  /* Do a interrupt data transfer */
     378
     379  dev = (kbd_dev *) arg;
     380  if(dev != NULL)
     381    {
     382      int ret;
     383     
     384      ret = UsbControlTransfer(dev->configEndp, 0x21, USB_REQ_SET_IDLE, 0, dev->interfaceNo, 0, NULL, ps2kbd_idlemode_set, arg);
     385    }
     386}
     387
     388void ps2kbd_idlemode_set(int resultCode, int bytes, void *arg)
     389
     390{
     391  kbd_dev *dev;
     392
     393
     394
     395  if(resultCode != USB_RC_OK)
     396    {
     397      printf("PS2KBD: Idlemode set error res %d, bytes %d, arg %p\n", resultCode, bytes, arg);
     398      return;
     399    }
     400 
     401  dev = (kbd_dev *) arg;
     402  if(dev != NULL)
     403    {
     404      int ret;
     405     
     406      ret = UsbInterruptTransfer(dev->dataEndp, &dev->data, dev->packetSize, ps2kbd_data_recv, arg);
     407    }
     408}
     409
     410void ps2kbd_led_set(int resultCode, int bytes, void *arg)
     411
     412{
     413  //printf("LED Set\n");
     414}
     415
     416void ps2kbd_build_uniquekeys(u8 *res, const u8 *new, const u8 *old)
     417
     418     /* Builds a list of unique keys */
     419
     420{
     421  int loopNew, loopOld;
     422  int loopRes = 0;
     423  int foundKey;
     424
     425  for(loopNew = 0; loopNew < PS2KBD_MAXKEYS; loopNew++)
     426    {
     427      if(new[loopNew] != 0)
     428        {
     429          foundKey = 0;
     430          for(loopOld = 0; loopOld < PS2KBD_MAXKEYS; loopOld++)
     431            {
     432              if(new[loopNew] == old[loopOld])
     433                {
     434                  foundKey = 1;
     435                  break;
     436                }
     437            }
     438          if(!foundKey)
     439            {
     440              res[loopRes++] = new[loopNew];
     441            }
     442        }
     443    }
     444}
     445
     446u32 ps2kbd_repeathandler(void *arg)
     447
     448{
     449  kbd_dev *dev = arg;
     450  iop_sys_clock_t t;
     451  //printf("Repeat handler\n");
     452
     453  iSetEventFlag(eventid, dev->eventmask);
     454
     455  USec2SysClock(kbd_repeatrate * 1000, &t);
     456  iSetAlarm(&t, ps2kbd_repeathandler, arg);
     457
     458  return t.hi;
     459}
     460
     461void ps2kbd_getkeys(u8 keyMods, u8 ledStatus, const u8 *keys, kbd_dev *dev)
     462
     463{
     464  int loopKey;
     465  int tempPos = 0;
     466  int byteCount = 0;
     467  u8 currChars[2];
     468
     469  if(lineStartP < lineEndP)
     470    {
     471      tempPos = lineStartP + lineSize;
     472    }
     473  else
     474    {
     475      tempPos = lineStartP;
     476    }
     477 
     478  for(loopKey = 0; loopKey < PS2KBD_MAXKEYS; loopKey++)
     479    {
     480      u8 currKey = keys[loopKey];
     481
     482      currChars[0] = 0;
     483      currChars[1] = 0;
     484
     485      if(lineEndP == (tempPos - 1))
     486        {
     487          break;
     488        }
     489
     490      if(currKey) /* If this is a valid key */
     491        {
     492          if((currKey >= USB_KEYB_NUMPAD_START) && (currKey <= USB_KEYB_NUMPAD_END))
     493            /* Handle numpad specially */
     494            {
     495              if(ledStatus & PS2KBD_LED_NUMLOCK)
     496                {
     497                  if(keymap[currKey])
     498                    {
     499                      currChars[0] = keymap[currKey];
     500                    }
     501                }
     502              else
     503                {
     504                  if(special_keys[currKey])
     505                    {
     506                      currChars[0] = PS2KBD_ESCAPE_KEY;
     507                      currChars[1] = special_keys[currKey];
     508                    }
     509                  else if(keymap[currKey] != '5') /* Make sure this isnt a 5 key :) */
     510                    {
     511                      currChars[0] = keymap[currKey];
     512                    }
     513                }
     514            }
     515          else if(special_keys[currKey]) /* This is a special key */
     516            {
     517              currChars[0] = PS2KBD_ESCAPE_KEY;
     518              currChars[1] = special_keys[currKey];
     519            }
     520          else if(keyMods & PS2KBD_CTRL) /* CTRL */
     521            {
     522              if(control_map[currKey])
     523                {
     524                  currChars[0] = control_map[currKey];
     525                }
     526            }
     527          else if(keyMods & PS2KBD_ALT) /* ALT */
     528            {
     529              if(alt_map[currKey])
     530                {
     531                  currChars[0] = alt_map[currKey];
     532                }
     533            }
     534          else if(keyMods & PS2KBD_SHIFT) /* SHIFT */
     535            {
     536              if((ledStatus & PS2KBD_LED_CAPSLOCK) && (keycap[currKey]))
     537                {
     538                  currChars[0] = keymap[currKey];
     539                }
     540              else
     541                {
     542                  currChars[0] = shiftkeymap[currKey];
     543                }
     544            }
     545          else /* Normal key */
     546            {
     547              if(keymap[keys[loopKey]])
     548                {
     549                  if((ledStatus & PS2KBD_LED_CAPSLOCK) && (keycap[currKey]))
     550                    {
     551                      currChars[0] = shiftkeymap[currKey];
     552                    }
     553                  else
     554                    {
     555                      currChars[0] = keymap[currKey];
     556                    }
     557                }
     558            }
     559        }
     560
     561      if((currChars[0] == PS2KBD_ESCAPE_KEY) && (currChars[1] != 0))
     562        {
     563          if(lineEndP != (tempPos - 2))
     564            {
     565              lineBuffer[lineEndP++] = currChars[0];
     566              lineEndP %= lineSize;
     567              lineBuffer[lineEndP++] = currChars[1];
     568              lineEndP %= lineSize;
     569              byteCount += 2;
     570            }
     571          dev->repeatkeys[0] = currChars[0];
     572          dev->repeatkeys[1] = currChars[1];
     573        }
     574      else if(currChars[0] != 0)
     575        {
     576          lineBuffer[lineEndP++] = currChars[0];
     577          lineEndP %= lineSize;
     578          byteCount++;
     579          dev->repeatkeys[0] = currChars[0];
     580          dev->repeatkeys[1] = 0;
     581        }
     582    }
     583
     584  if(byteCount > 0)
     585    {
     586      iop_sys_clock_t t;
     587      /* Set alarm to do repeat rate */
     588      //printf("repeatkeys %d %d\n", kbd_repeatkeys[0], kbd_repeatkeys[1]);
     589      USec2SysClock(PS2KBD_REPEATWAIT * 1000, &t);
     590      SetAlarm(&t, ps2kbd_repeathandler, dev);
     591    }
     592
     593  for(loopKey = 0; loopKey < byteCount; loopKey++) /* Signal the sema to indicate data */
     594    {
     595      SignalSema(bufferSema);
     596    }
     597
     598/*   lineBuffer[PS2KBD_DEFLINELEN - 1] = 0; */
     599/*   printf(lineBuffer); */
     600  //printf("lineStart %d, lineEnd %d\n", lineStartP, lineEndP);
     601}
     602
     603
     604void ps2kbd_getkeys_raw(u8 newKeyMods, u8 oldKeyMods, u8 *new, const u8 *old)
     605
     606{
     607  int loopKey;
     608  u8 currKey;
     609  u8 keyMods = newKeyMods ^ oldKeyMods;
     610  u8 keyModsMap = newKeyMods & keyMods;
     611  int tempPos = 0;
     612  int byteCount = 0;
     613
     614  if(lineStartP < lineEndP)
     615    {
     616      tempPos = lineStartP + lineSize;
     617    }
     618  else
     619    {
     620      tempPos = lineStartP;
     621    }
     622 
     623  for(loopKey = 0; loopKey < 8; loopKey++)
     624    {
     625      int currMod = (1 << loopKey);
     626      if(keyMods & currMod)
     627        {
     628          if(lineEndP == (tempPos - 2))
     629            {
     630              return;
     631            }
     632
     633          currKey = keyModValue[loopKey];
     634
     635          if(keyModsMap & currMod) /* If key pressed */
     636            {
     637              lineBuffer[lineEndP++] = PS2KBD_RAWKEY_DOWN;
     638              //printf("Key down\n");
     639            }
     640          else
     641            {
     642              lineBuffer[lineEndP++] = PS2KBD_RAWKEY_UP;
     643              //printf("Key up\n");
     644            }
     645
     646          lineEndP %= lineSize;
     647          lineBuffer[lineEndP++] = currKey;
     648          lineEndP %= lineSize;
     649          byteCount += 2;
     650          //printf("Key %d\n", currKey);
     651        }
     652    }
     653
     654  for(loopKey = 0; loopKey < PS2KBD_MAXKEYS; loopKey++)
     655    {
     656      if(lineEndP == (tempPos - 2))
     657        {
     658          return;
     659        }
     660
     661      if(new[loopKey] != 0)
     662        {
     663          lineBuffer[lineEndP++] = PS2KBD_RAWKEY_DOWN;
     664          lineEndP %= lineSize;
     665          lineBuffer[lineEndP++] = new[loopKey];
     666          lineEndP %= lineSize;
     667          byteCount += 2;
     668          //printf("Key down\nKey %d\n", new[loopKey]);
     669        }
     670
     671    }
     672
     673  for(loopKey = 0; loopKey < PS2KBD_MAXKEYS; loopKey++)
     674    {
     675      if(lineEndP == (tempPos - 2))
     676        {
     677          return;
     678        }
     679
     680      if(old[loopKey] != 0)
     681        {
     682          lineBuffer[lineEndP++] = PS2KBD_RAWKEY_UP;
     683          lineEndP %= lineSize;
     684          lineBuffer[lineEndP++] = old[loopKey];
     685          lineEndP %= lineSize;
     686          byteCount += 2;
     687          //printf("Key up\nKey %d\n", old[loopKey]);
     688        }
     689
     690    }
     691
     692  for(loopKey = 0; loopKey < byteCount; loopKey++) /* Signal the sema for the number of bytes read */
     693    {
     694      SignalSema(bufferSema);
     695    }
     696}
     697
     698void ps2kbd_data_recv(int resultCode, int bytes, void *arg)
     699
     700{
     701  kbd_dev *dev;
     702  int ret;
     703  int phantom;
     704  int loop;
     705
     706  if(resultCode != USB_RC_OK)
     707    {
     708      printf("PS2KEYBOARD: Data Recv set res %d, bytes %d, arg %p\n", resultCode, bytes, arg);
     709      return;
     710    }
     711 
     712  //printf("PS2KBD: Data Recv set res %d, bytes %d, arg %p\n", resultCode, bytes, arg);
     713
     714  dev = (kbd_dev *) arg;
     715  if(dev == NULL)
     716    {
     717      printf("PS2KBD: dev == NULL\n");
     718      return;
     719    }
     720   
     721/*       printf("PS2KBD Modifiers %02X, Keys ", dev->data.mod_keys); */
     722/*       for(loop = 0; loop < PS2KBD_MAXKEYS; loop++) */
     723/*      { */
     724/*        printf("%02X ", dev->data.keycodes[loop]); */
     725/*      } */
     726/*       printf("\n"); */
     727
     728  CancelAlarm(ps2kbd_repeathandler, dev); /* Make sure repeat alarm is cancelled */
     729
     730  /* Check for phantom states */
     731  phantom = 1;
     732  for(loop = 0; loop < PS2KBD_MAXKEYS; loop++)
     733    {
     734      if(dev->data.keycodes[loop] != 1)
     735        {
     736          phantom = 0;
     737          break;
     738        }
     739    }
     740 
     741  if(!phantom) /* If not in a phantom state */
     742    {
     743      u8 uniqueKeys[PS2KBD_MAXKEYS];
     744      u8 missingKeys[PS2KBD_MAXKEYS];
     745      int loopKey;
     746
     747      memset(uniqueKeys, 0, PS2KBD_MAXKEYS);
     748      memset(missingKeys, 0, PS2KBD_MAXKEYS);
     749      ps2kbd_build_uniquekeys(uniqueKeys, dev->data.keycodes, dev->oldData.keycodes);
     750      ps2kbd_build_uniquekeys(missingKeys, dev->oldData.keycodes, dev->data.keycodes);
     751      /* Build new and missing key lists */
     752
     753/*       printf("Unique keys : "); */
     754/*       for(loopKey = 0; loopKey < PS2KBD_MAXKEYS; loopKey++) */
     755/*      { */
     756/*        printf("%02X ", uniqueKeys[loopKey]); */
     757/*      } */
     758/*       printf("\n"); */
     759
     760/*       printf("Missing keys : "); */
     761/*       for(loopKey = 0; loopKey < PS2KBD_MAXKEYS; loopKey++) */
     762/*      { */
     763/*        printf("%02X ", missingKeys[loopKey]); */
     764/*      } */
     765/*       printf("\n"); */
     766     
     767      if(kbd_readmode == PS2KBD_READMODE_NORMAL)
     768        {
     769          u8 ledStatus;
     770
     771          ledStatus = dev->ledStatus;
     772          //printf("ledStatus %02X\n", ledStatus);
     773         
     774          for(loopKey = 0; loopKey < PS2KBD_MAXKEYS; loopKey++) /* Process key codes */
     775            {
     776              switch(uniqueKeys[loopKey])
     777                {
     778                case USB_KEYB_NUMLOCK :
     779                  ledStatus ^= PS2KBD_LED_NUMLOCK;
     780                  uniqueKeys[loopKey] = 0;
     781                  break;
     782                case USB_KEYB_CAPSLOCK :
     783                  ledStatus ^= PS2KBD_LED_CAPSLOCK;
     784                  uniqueKeys[loopKey] = 0;
     785                  break;
     786                case USB_KEYB_SCRLOCK :
     787                  ledStatus ^= PS2KBD_LED_SCRLOCK;
     788                  uniqueKeys[loopKey] = 0;
     789                  break;
     790                }
     791            }
     792         
     793          if(ledStatus != dev->ledStatus)
     794            {
     795              dev->ledStatus = ledStatus & PS2KBD_LED_MASK;
     796              //printf("LEDS %02X\n", dev->ledStatus);
     797              /* Call Set LEDS */
     798              UsbControlTransfer(dev->configEndp, 0x21, USB_REQ_SET_REPORT, 0x200,
     799                                 dev->interfaceNo, 1, &dev->ledStatus, ps2kbd_led_set, arg);
     800            }
     801         
     802          WaitSema(lineSema); /* Make sure no other thread is going to manipulate the buffer */
     803          ps2kbd_getkeys(dev->data.mod_keys, dev->ledStatus, uniqueKeys, dev); /* read in remaining keys */
     804          SignalSema(lineSema);
     805        }
     806      else /* RAW Mode */
     807        {
     808          WaitSema(lineSema);
     809          ps2kbd_getkeys_raw(dev->data.mod_keys, dev->oldData.mod_keys, uniqueKeys, missingKeys);
     810          SignalSema(lineSema);
     811        }
     812
     813      memcpy(&dev->oldData, &dev->data, sizeof(kbd_data_recv));
     814    }
     815 
     816  ret = UsbInterruptTransfer(dev->dataEndp, &dev->data, dev->packetSize, ps2kbd_data_recv, arg);
     817}
     818
     819void flushbuffer()
     820
     821{
     822  iop_sema_t s;
     823
     824  lineStartP = 0;
     825  lineEndP = 0;
     826  memset(lineBuffer, 0, lineSize);
     827 
     828  DeleteSema(bufferSema);
     829  s.initial = 0;
     830  s.max = lineSize;
     831  s.option = 0;
     832  s.attr = 0;
     833  bufferSema = CreateSema(&s); /* Create a sema to maintain status of readable data */
     834 
     835  if(bufferSema <= 0)
     836    {
     837      printf("Error creating buffer sema\n");
     838    }
     839}
     840
     841void ps2kbd_rpc_setreadmode(u32 readmode)
     842
     843{
     844  int devLoop;
     845
     846  if(readmode == kbd_readmode) return;
     847
     848  if((readmode == PS2KBD_READMODE_NORMAL) || (readmode == PS2KBD_READMODE_RAW))
     849    {
     850      /* Reset line buffer */
     851      //printf("ioctl_setreadmode %d\n", readmode);
     852      for(devLoop = 0; devLoop < PS2KBD_MAXDEV; devLoop++)
     853        {
     854          CancelAlarm(ps2kbd_repeathandler, devices[devLoop]);
     855        }
     856
     857      WaitSema(lineSema);
     858      kbd_readmode = readmode;
     859      flushbuffer();
     860      SignalSema(lineSema);
     861    }
     862}
     863
     864void ps2kbd_rpc_setkeymap(kbd_keymap *keymaps)
     865
     866{
     867  //printf("ioctl_setkeymap %p\n", keymaps);
     868  WaitSema(lineSema);   /* Lock the input so you dont end up with weird results */
     869  memcpy(keymap, keymaps->keymap, PS2KBD_KEYMAP_SIZE);
     870  memcpy(shiftkeymap, keymaps->shiftkeymap, PS2KBD_KEYMAP_SIZE);
     871  memcpy(keycap, keymaps->keycap, PS2KBD_KEYMAP_SIZE);
     872  SignalSema(lineSema);
     873}
     874
     875void ps2kbd_rpc_setctrlmap(u8 *ctrlmap)
     876
     877{
     878  //printf("ioctl_setctrlmap %p\n", ctrlmap);
     879  WaitSema(lineSema);
     880  memcpy(control_map, ctrlmap, PS2KBD_KEYMAP_SIZE);
     881  SignalSema(lineSema);
     882}
     883
     884void ps2kbd_rpc_setaltmap(u8 *altmap)
     885
     886{
     887  //printf("ioctl_setaltmap %p\n", altmap);
     888  WaitSema(lineSema);
     889  memcpy(alt_map, altmap, PS2KBD_KEYMAP_SIZE);
     890  SignalSema(lineSema);
     891}
     892
     893void ps2kbd_rpc_setspecialmap(u8 *special)
     894
     895{
     896  //printf("ioctl_setspecialmap %p\n", special);
     897  WaitSema(lineSema);
     898  memcpy(special_keys, special, PS2KBD_KEYMAP_SIZE);
     899  SignalSema(lineSema);
     900}
     901
     902void ps2kbd_rpc_resetkeymap()
     903     /* Reset keymap to default US variety */
     904
     905{
     906  //printf("ioctl_resetkeymap()\n");
     907  WaitSema(lineSema);
     908  memcpy(keymap, us_keymap, PS2KBD_KEYMAP_SIZE);
     909  memcpy(shiftkeymap, us_shiftkeymap, PS2KBD_KEYMAP_SIZE);
     910  memcpy(keycap, us_keycap, PS2KBD_KEYMAP_SIZE);
     911  memcpy(special_keys, us_special_keys, PS2KBD_KEYMAP_SIZE);
     912  memcpy(control_map, us_control_map, PS2KBD_KEYMAP_SIZE);
     913  memcpy(alt_map, us_alt_map, PS2KBD_KEYMAP_SIZE);
     914  SignalSema(lineSema);
     915}
     916
     917void ps2kbd_rpc_flushbuffer()
     918     /* Flush the internal buffer */
     919
     920{
     921  //printf("ioctl_flushbuffer()\n");
     922  WaitSema(lineSema);
     923  flushbuffer();
     924  SignalSema(lineSema);
     925}
     926
     927void ps2kbd_rpc_setleds(u8 ledStatus)
     928
     929{
     930  int devLoop;
     931  kbd_dev *dev;
     932
     933  //printf("ioctl_setleds %d\n", ledStatus);
     934  ledStatus &= PS2KBD_LED_MASK;
     935  for(devLoop = 0; devLoop < PS2KBD_MAXDEV; devLoop++)
     936    {
     937      dev = devices[devLoop];
     938      if(dev)
     939        {
     940          if(ledStatus != dev->ledStatus)
     941            {
     942              dev->ledStatus = ledStatus & PS2KBD_LED_MASK;
     943              UsbControlTransfer(dev->configEndp, 0x21, USB_REQ_SET_REPORT, 0x200,
     944                                 dev->interfaceNo, 1, &dev->ledStatus, ps2kbd_led_set, dev);
     945            }
     946        }
     947    }
     948}
     949
     950void ps2kbd_rpc_setrepeatrate(u32 rate)
     951{
     952  kbd_repeatrate = rate;
     953}
     954
     955int kbd_read(void *buf, int size)
     956{
     957        int count = 0;
     958        char *data = (char *) buf;
     959
     960        if(kbd_readmode == PS2KBD_READMODE_RAW)
     961                size &= ~1; /* Ensure size of a multiple of 2 */
     962
     963        if (PollSema(bufferSema) >= 0) {
     964                SignalSema(bufferSema);
     965                if (WaitSema(lineSema) >= 0) {
     966                        while((count < size) && (lineStartP != lineEndP)) {
     967                                data[count] = lineBuffer[lineStartP++];
     968                                lineStartP %= lineSize;
     969                                count++;
     970                                PollSema(bufferSema); /* Take off one count from the sema */
     971                        }
     972                        SignalSema(lineSema);
     973                }
     974        }
     975        return count;
     976}
     977
     978void repeat_thread(void *arg)
     979
     980{
     981  u32 eventmask;
     982  int devLoop;
     983
     984  for(;;)
     985    {
     986      WaitEventFlag(eventid, 0xFFFFFFFF, 0x01 | 0x10, &eventmask);
     987      //printf("Recieved event %08X\n", eventmask);
     988      for(devLoop = 0; devLoop < PS2KBD_MAXDEV; devLoop++)
     989        {
     990          if((eventmask & (1 << devLoop)) && (devices[devLoop]))
     991            {
     992              int tempPos = 0;
     993
     994              WaitSema(lineSema);
     995              if(lineStartP < lineEndP)
     996                {
     997                  tempPos = lineStartP + lineSize;
     998                }
     999              else
     1000                {
     1001                  tempPos = lineStartP;
     1002                }
     1003
     1004              if((devices[devLoop]->repeatkeys[0]) && (devices[devLoop]->repeatkeys[1]))
     1005                {
     1006                  if(lineEndP != (tempPos - 2))
     1007                    {
     1008                      lineBuffer[lineEndP++] = devices[devLoop]->repeatkeys[0];
     1009                      lineEndP %= lineSize;           
     1010                      lineBuffer[lineEndP++] = devices[devLoop]->repeatkeys[1];
     1011                      lineEndP %= lineSize;
     1012                      SignalSema(bufferSema);
     1013                      SignalSema(bufferSema);
     1014                    }
     1015                }
     1016              else if(devices[devLoop]->repeatkeys[0])
     1017                {
     1018                  if(lineEndP != (tempPos - 1))
     1019                    {
     1020                      lineBuffer[lineEndP++] = devices[devLoop]->repeatkeys[0];
     1021                      lineEndP %= lineSize;           
     1022                      SignalSema(bufferSema);
     1023                    }
     1024                }
     1025
     1026              SignalSema(lineSema);
     1027            }
     1028        }
     1029    }
     1030}
     1031
     1032int init_repeatthread()
     1033     /* Creates a thread to handle key repeats */
     1034{
     1035  iop_thread_t param;
     1036  iop_event_t event;
     1037
     1038  event.attr = 0;
     1039  event.option = 0;
     1040  event.bits = 0;
     1041  eventid = CreateEventFlag(&event);
     1042
     1043  param.attr         = TH_C;
     1044  param.thread    = repeat_thread;
     1045  param.priority     = 40;
     1046  param.stacksize    = 0x800;
     1047  param.option       = 0;
     1048
     1049  repeat_tid = CreateThread(&param);
     1050  if (repeat_tid > 0) {
     1051    StartThread(repeat_tid, 0);
     1052    return 0;
     1053  }
     1054  else
     1055    {
     1056      return 1;
     1057    }
     1058}
     1059
     1060static unsigned long retKey;
     1061
     1062void *ps2kbd_rpc_server(int fno, void *data, int size) {
     1063        retKey = 0;
     1064        switch (fno) {
     1065        case KBD_RPC_SETREADMODE:
     1066                ps2kbd_rpc_setreadmode(*(u32 *)data);
     1067                break;
     1068        case KBD_RPC_SETKEYMAP:
     1069                ps2kbd_rpc_setkeymap((kbd_keymap *) data);
     1070                break;
     1071        case KBD_RPC_SETALTMAP:
     1072                ps2kbd_rpc_setaltmap((u8 *) data);
     1073                break;
     1074        case KBD_RPC_SETCTRLMAP:
     1075                ps2kbd_rpc_setctrlmap((u8 *) data);
     1076                break;
     1077        case KBD_RPC_SETSPECIALMAP:
     1078                ps2kbd_rpc_setspecialmap((u8 *) data);
     1079                break;
     1080        case KBD_RPC_FLUSHBUFFER:
     1081                ps2kbd_rpc_flushbuffer();
     1082                break;
     1083        case KBD_RPC_SETLEDS:
     1084                ps2kbd_rpc_setleds(*(u8*) data);
     1085                break;
     1086        case KBD_RPC_RESETKEYMAP:
     1087                ps2kbd_rpc_resetkeymap();
     1088                break;
     1089        case KBD_RPC_SETREPEATRATE:
     1090                ps2kbd_rpc_setrepeatrate(*(u32 *) data);
     1091                break;
     1092        case KBD_RPC_READRAW:
     1093                kbd_read(&retKey, 2);
     1094                return &retKey;
     1095        case KBD_RPC_READKEY:
     1096                kbd_read(&retKey, 1);
     1097                return &retKey;
     1098        default:
     1099                printf("Ps2Kbd: Unknown RPC command %d\n", fno);
     1100                break;
     1101        }
     1102        return NULL;
     1103}
     1104
     1105struct t_SifRpcDataQueue qd;
     1106struct t_SifRpcServerData sd0;
     1107void *rpcRcvBuf;
     1108
     1109void ps2kbd_start_rpc(unsigned long tid) {
     1110        rpcRcvBuf = AllocSysMemory(0, 3 * PS2KBD_KEYMAP_SIZE, NULL);
     1111        printf("Ps2Kbd: starting RPC server\n");
     1112        SifInitRpc(0);
     1113
     1114        SifSetRpcQueue(&qd, tid);
     1115        SifRegisterRpc(&sd0, PS2KBD_RPC_ID, ps2kbd_rpc_server, rpcRcvBuf, 0, 0, &qd);
     1116        SifRpcLoop(&qd);
     1117}
     1118
     1119int ps2kbd_init_rpc(void) {
     1120        struct _iop_thread param;
     1121        int th;
     1122
     1123        param.attr         = 0x02000000;
     1124        param.thread       = (void*)ps2kbd_start_rpc;
     1125        param.priority    = 40;
     1126        param.stacksize    = 0x800;
     1127        param.option      = 0;
     1128
     1129        th = CreateThread(&param);
     1130
     1131        if (th > 0)     {
     1132                StartThread(th, (void *)th);
     1133                return 0;
     1134        } else
     1135                return -1;
     1136}
     1137
     1138int ps2kbd_init() {
     1139  int ret;
     1140  iop_sema_t s;
     1141
     1142  s.initial = 1;
     1143  s.max = 1;
     1144  s.option = 0;
     1145  s.attr = 0;
     1146  lineSema = CreateSema(&s);
     1147  if(lineSema <= 0)
     1148    {
     1149      printf("Error creating sema\n");
     1150      return 1;
     1151    }
     1152
     1153  s.initial = 0;
     1154  s.max = PS2KBD_DEFLINELEN;
     1155  s.option = 0;
     1156  s.attr = 0;
     1157  bufferSema = CreateSema(&s); /* Create a sema to maintain status of readable data */
     1158  if(bufferSema <= 0)
     1159    {
     1160      printf("Error creating buffer sema\n");
     1161      return 1;
     1162    }
     1163
     1164  lineBuffer = (u8 *) AllocSysMemory(0, PS2KBD_DEFLINELEN, NULL);
     1165  if(lineBuffer == NULL)
     1166    {
     1167      printf("Error allocating line buffer\n");
     1168      return 1;
     1169    }
     1170  lineStartP = 0;
     1171  lineEndP = 0;
     1172  lineSize = PS2KBD_DEFLINELEN;
     1173  memset(lineBuffer, 0, PS2KBD_DEFLINELEN);
     1174 
     1175  memset(devices, 0, sizeof(kbd_dev *) * PS2KBD_MAXDEV);
     1176  dev_count = 0;
     1177  kbd_readmode = PS2KBD_READMODE_NORMAL;
     1178  kbd_repeatrate = PS2KBD_DEFREPEATRATE;
     1179  memcpy(keymap, us_keymap, PS2KBD_KEYMAP_SIZE);
     1180  memcpy(shiftkeymap, us_shiftkeymap, PS2KBD_KEYMAP_SIZE);
     1181  memcpy(keycap, us_keycap, PS2KBD_KEYMAP_SIZE);
     1182  memcpy(special_keys, us_special_keys, PS2KBD_KEYMAP_SIZE);
     1183  memcpy(control_map, us_control_map, PS2KBD_KEYMAP_SIZE);
     1184  memcpy(alt_map, us_alt_map, PS2KBD_KEYMAP_SIZE);
     1185
     1186  ps2kbd_init_rpc();
     1187  init_repeatthread();
     1188
     1189  ret = UsbRegisterDriver(&kbd_driver);
     1190  if(ret != USB_RC_OK)
     1191    {
     1192      printf("Error registering USB devices\n");
     1193      return 1;
     1194    }
     1195
     1196  printf("UsbRegisterDriver %d\n", ret);
     1197
     1198  return 0;
     1199}
  • backends/platform/ps2/iop/rpckbd/src/us_keymap.h

    diff -u -N -r branch-0-11-0/backends/platform/ps2/iop/rpckbd/src/us_keymap.h branch-0-11-0-ps2/backends/platform/ps2/iop/rpckbd/src/us_keymap.h
    old new  
     1/*
     2# _____     ___ ____     ___ ____
     3#  ____|   |    ____|   |        | |____|
     4# |     ___|   |____ ___|    ____| |    \    PS2DEV Open Source Project.
     5#-----------------------------------------------------------------------
     6# Copyright 2001-2004, ps2dev - http://www.ps2dev.org
     7# Licenced under Academic Free License version 2.0
     8# Review ps2sdk README & LICENSE files for further details.
     9#
     10# $Id: us_keymap.h,v 1.2 2004/09/14 14:41:46 pixel Exp $
     11# USB Keyboard Driver for PS2
     12*/
     13
     14#ifndef __US_KEYMAP_H__
     15#define __US_KEYMAP_H__
     16
     17/* Default US keymap */
     18
     19u8 us_keymap[PS2KBD_KEYMAP_SIZE] =
     20  {
     21    0,
     22    0,
     23    0,
     24    0,
     25    'a',
     26    'b',
     27    'c',
     28    'd',
     29    'e',
     30    'f',
     31    'g',
     32    'h',
     33    'i',
     34    'j',
     35    'k',
     36    'l',
     37    'm',
     38    'n',
     39    'o',
     40    'p',
     41    'q',
     42    'r',
     43    's',
     44    't',
     45    'u',
     46    'v',
     47    'w',
     48    'x',
     49    'y',
     50    'z',
     51    '1',
     52    '2',
     53    '3',
     54    '4',
     55    '5',
     56    '6',
     57    '7',
     58    '8',
     59    '9',
     60    '0',
     61    10, /* line feed */
     62    0, /* Esc */
     63    0x7,/* BS */
     64    0x9, /* TAB */
     65    0x20,
     66    '-',
     67    '=',
     68    '[',
     69    ']',
     70    '\\',
     71    '#',
     72    ';',
     73    '\'',
     74    '`',
     75    ',',
     76    '.',
     77    '/',
     78    0, /* CL */
     79    0, // F1
     80    0, // F2
     81    0, // F3
     82    0, // F4
     83    0, // F5
     84    0, // F6
     85    0, // F7
     86    0, // F8
     87    0, // F9
     88    0, // F10
     89    0, // F11
     90    0, // F12
     91    0, // PrintScr
     92    0, // Scroll Lock
     93    0, // Pause
     94    0, // Insert
     95    0, // Home
     96    0, // Pg Up
     97    0, // Delete
     98    0, // End
     99    0, // Pg Down
     100    0, // Right
     101    0, // Left
     102    0, // Down
     103    0, // Up
     104    0, // Numlock
     105    '/', // Keypad
     106    '*',
     107    '-',
     108    '+',
     109    10,
     110    '1',
     111    '2',
     112    '3',
     113    '4',
     114    '5',
     115    '6',
     116    '7',
     117    '8',
     118    '9',
     119    '0',
     120    '.',
     121    '\\',
     122    0,
     123    0,
     124    '=',
     125    0,
     126    0,
     127    0,
     128    0,
     129    0,
     130    0,
     131    0,
     132    0,
     133    0,
     134    0,
     135    0,
     136    0,
     137    0,
     138    0,
     139    0,
     140    0,
     141    0,
     142    0,
     143    0,
     144    0,
     145    0,
     146    0,
     147    0,
     148    0,
     149    0,
     150    0,
     151    0,
     152    0,
     153    0,
     154    0,
     155    0,
     156    0,
     157    0,
     158    0,
     159    0,
     160    0,
     161    0,
     162    0,
     163    0,
     164    0,
     165    0,
     166    0,
     167    0,
     168    0,
     169    0,
     170    0,
     171    0,
     172    0,
     173    0,
     174    0,
     175    0,
     176    0,
     177    0,
     178    0,
     179    0,
     180    0,
     181    0,
     182    0,
     183    0,
     184    0,
     185    0,
     186    0,
     187    0,
     188    0,
     189    0,
     190    0,
     191    0,
     192    0,
     193    0,
     194    0,
     195    0,
     196    0,
     197    0,
     198    0,
     199    0,
     200    0,
     201    0,
     202    0,
     203    0,
     204    0,
     205    0,
     206    0,
     207    0,
     208    0,
     209    0,
     210    0,
     211    0,
     212    0,
     213    0,
     214    0,
     215    0,
     216    0,
     217    0,
     218    0,
     219    0,
     220    0,
     221    0,
     222    0,
     223    0,
     224    0,
     225    0,
     226    0,
     227    0,
     228    0,
     229    0,
     230    0,
     231    0,
     232    0,
     233    0,
     234    0,
     235    0,
     236    0,
     237    0,
     238    0,
     239    0,
     240    0,
     241    0,
     242    0,
     243    0,
     244    0,
     245    0,
     246    0,
     247    0,
     248    0,
     249    0,
     250    0,
     251    0,
     252    0,
     253    0,
     254    0,
     255    0,
     256    0,
     257    0,
     258    0,
     259    0,
     260    0,
     261    0,
     262    0,
     263    0,
     264    0,
     265    0,
     266    0,
     267    0,
     268    0,
     269    0,
     270    0,
     271    0,
     272    0,
     273    0,
     274    0,
     275    0,
     276    0
     277  };
     278
     279u8 us_shiftkeymap[PS2KBD_KEYMAP_SIZE] =
     280  {
     281    0,
     282    0,
     283    0,
     284    0,
     285    'A',
     286    'B',
     287    'C',
     288    'D',
     289    'E',
     290    'F',
     291    'G',
     292    'H',
     293    'I',
     294    'J',
     295    'K',
     296    'L',
     297    'M',
     298    'N',
     299    'O',
     300    'P',
     301    'Q',
     302    'R',
     303    'S',
     304    'T',
     305    'U',
     306    'V',
     307    'W',
     308    'X',
     309    'Y',
     310    'Z',
     311    '!',
     312    '@',
     313    '#',
     314    '$',
     315    '%',
     316    '^',
     317    '&',
     318    '*',
     319    '(',
     320    ')',
     321    10, /* line feed */
     322    0, /* Esc */
     323    0x7,/* BS */
     324    0x9, /* TAB */
     325    0x20,
     326    '_',
     327    '+',
     328    '{',
     329    '}',
     330    '|',
     331    '~',
     332    ':',
     333    '"',
     334    '~',
     335    '<',
     336    '>',
     337    '?',
     338    0, /* CL */
     339    0, // F1
     340    0, // F2
     341    0, // F3
     342    0, // F4
     343    0, // F5
     344    0, // F6
     345    0, // F7
     346    0, // F8
     347    0, // F9
     348    0, // F10
     349    0, // F11
     350    0, // F12
     351    0, // PrintScr
     352    0, // Scroll Lock
     353    0, // Pause
     354    0, // Insert
     355    0, // Home
     356    0, // Pg Up
     357    0, // Delete
     358    0, // End
     359    0, // Pg Down
     360    0, // Right
     361    0, // Left
     362    0, // Down
     363    0, // Up
     364    0, // Numlock
     365    '/', // Keypad
     366    '*',
     367    '-',
     368    '+',
     369    10,
     370    '1',
     371    '2',
     372    '3',
     373    '4',
     374    '5',
     375    '6',
     376    '7',
     377    '8',
     378    '9',
     379    '0',
     380    '.',
     381    '\\',
     382    0,
     383    0,
     384    '=',
     385    0,
     386    0,
     387    0,
     388    0,
     389    0,
     390    0,
     391    0,
     392    0,
     393    0,
     394    0,
     395    0,
     396    0,
     397    0,
     398    0,
     399    0,
     400    0,
     401    0,
     402    0,
     403    0,
     404    0,
     405    0,
     406    0,
     407    0,
     408    0,
     409    0,
     410    0,
     411    0,
     412    0,
     413    0,
     414    0,
     415    0,
     416    0,
     417    0,
     418    0,
     419    0,
     420    0,
     421    0,
     422    0,
     423    0,
     424    0,
     425    0,
     426    0,
     427    0,
     428    0,
     429    0,
     430    0,
     431    0,
     432    0,
     433    0,
     434    0,
     435    0,
     436    0,
     437    0,
     438    0,
     439    0,
     440    0,
     441    0,
     442    0,
     443    0,
     444    0,
     445    0,
     446    0,
     447    0,
     448    0,
     449    0,
     450    0,
     451    0,
     452    0,
     453    0,
     454    0,
     455    0,
     456    0,
     457    0,
     458    0,
     459    0,
     460    0,
     461    0,
     462    0,
     463    0,
     464    0,
     465    0,
     466    0,
     467    0,
     468    0,
     469    0,
     470    0,
     471    0,
     472    0,
     473    0,
     474    0,
     475    0,
     476    0,
     477    0,
     478    0,
     479    0,
     480    0,
     481    0,
     482    0,
     483    0,
     484    0,
     485    0,
     486    0,
     487    0,
     488    0,
     489    0,
     490    0,
     491    0,
     492    0,
     493    0,
     494    0,
     495    0,
     496    0,
     497    0,
     498    0,
     499    0,
     500    0,
     501    0,
     502    0,
     503    0,
     504    0,
     505    0,
     506    0,
     507    0,
     508    0,
     509    0,
     510    0,
     511    0,
     512    0,
     513    0,
     514    0,
     515    0,
     516    0,
     517    0,
     518    0,
     519    0,
     520    0,
     521    0,
     522    0,
     523    0,
     524    0,
     525    0,
     526    0,
     527    0,
     528    0,
     529    0,
     530    0,
     531    0,
     532    0,
     533    0,
     534    0,
     535    0,
     536    0
     537  };
     538
     539u8 us_keycap[PS2KBD_KEYMAP_SIZE] =
     540  {
     541    0,
     542    0,
     543    0,
     544    0,
     545    1, //a
     546    1, //b
     547    1, //c
     548    1, //d
     549    1, //e
     550    1, //f
     551    1,//g
     552    1,//h
     553    1,//i
     554    1,//j
     555    1,//k
     556    1,//l
     557    1,//m
     558    1,//n
     559    1,//o
     560    1,//p
     561    1,//q
     562    1,//r
     563    1,//s
     564    1,//t
     565    1,//u
     566    1,//v
     567    1,//w
     568    1,//x
     569    1,//y
     570    1,//z
     571    0,
     572    0,
     573    0,
     574    0,
     575    0,
     576    0,
     577    0,
     578    0,
     579    0,
     580    0,
     581    0, /* line feed */
     582    0, /* Esc */
     583    0,/* BS */
     584    0, /* TAB */
     585    0,
     586    0,
     587    0,
     588    0,
     589    0,
     590    0,
     591    0,
     592    0,
     593    0,
     594    0,
     595    0,
     596    0,
     597    0,
     598    0, /* CL */
     599    0, // F1
     600    0, // F2
     601    0, // F3
     602    0, // F4
     603    0, // F5
     604    0, // F6
     605    0, // F7
     606    0, // F8
     607    0, // F9
     608    0, // F10
     609    0, // F11
     610    0, // F12
     611    0, // PrintScr
     612    0, // Scroll Lock
     613    0, // Pause
     614    0, // Insert
     615    0, // Home
     616    0, // Pg Up
     617    0, // Delete
     618    0, // End
     619    0, // Pg Down
     620    0, // Right
     621    0, // Left
     622    0, // Down
     623    0, // Up
     624    0, // Numlock
     625    0, // Keypad
     626    0,
     627    0,
     628    0,
     629    0,
     630    0,
     631    0,
     632    0,
     633    0,
     634    0,
     635    0,
     636    0,
     637    0,
     638    0,
     639    0,
     640    0,
     641    0,
     642    0,
     643    0,
     644    0,
     645    0,
     646    0,
     647    0,
     648    0,
     649    0,
     650    0,
     651    0,
     652    0,
     653    0,
     654    0,
     655    0,
     656    0,
     657    0,
     658    0,
     659    0,
     660    0,
     661    0,
     662    0,
     663    0,
     664    0,
     665    0,
     666    0,
     667    0,
     668    0,
     669    0,
     670    0,
     671    0,
     672    0,
     673    0,
     674    0,
     675    0,
     676    0,
     677    0,
     678    0,
     679    0,
     680    0,
     681    0,
     682    0,
     683    0,
     684    0,
     685    0,
     686    0,
     687    0,
     688    0,
     689    0,
     690    0,
     691    0,
     692    0,
     693    0,
     694    0,
     695    0,
     696    0,
     697    0,
     698    0,
     699    0,
     700    0,
     701    0,
     702    0,
     703    0,
     704    0,
     705    0,
     706    0,
     707    0,
     708    0,
     709    0,
     710    0,
     711    0,
     712    0,
     713    0,
     714    0,
     715    0,
     716    0,
     717    0,
     718    0,
     719    0,
     720    0,
     721    0,
     722    0,
     723    0,
     724    0,
     725    0,
     726    0,
     727    0,
     728    0,
     729    0,
     730    0,
     731    0,
     732    0,
     733    0,
     734    0,
     735    0,
     736    0,
     737    0,
     738    0,
     739    0,
     740    0,
     741    0,
     742    0,
     743    0,
     744    0,
     745    0,
     746    0,
     747    0,
     748    0,
     749    0,
     750    0,
     751    0,
     752    0,
     753    0,
     754    0,
     755    0,
     756    0,
     757    0,
     758    0,
     759    0,
     760    0,
     761    0,
     762    0,
     763    0,
     764    0,
     765    0,
     766    0,
     767    0,
     768    0,
     769    0,
     770    0,
     771    0,
     772    0,
     773    0,
     774    0,
     775    0,
     776    0,
     777    0,
     778    0,
     779    0,
     780    0,
     781    0,
     782    0,
     783    0,
     784    0,
     785    0,
     786    0,
     787    0,
     788    0,
     789    0,
     790    0,
     791    0,
     792    0,
     793    0,
     794    0,
     795    0,
     796    0
     797  };
     798
     799u8 us_special_keys[PS2KBD_KEYMAP_SIZE] = {
     800
     801    0,
     802    0,
     803    0,
     804    0,
     805    0, //a
     806    0, //b
     807    0, //c
     808    0, //d
     809    0, //e
     810    0, //f
     811    0,//g
     812    0,//h
     813    0,//i
     814    0,//j
     815    0,//k
     816    0,//l
     817    0,//m
     818    0,//n
     819    0,//o
     820    0,//p
     821    0,//q
     822    0,//r
     823    0,//s
     824    0,//t
     825    0,//u
     826    0,//v
     827    0,//w
     828    0,//x
     829    0,//y
     830    0,//z
     831    0,
     832    0,
     833    0,
     834    0,
     835    0,
     836    0,
     837    0,
     838    0,
     839    0,
     840    0,
     841    0, /* line feed */
     842    0x1B, /* Esc */
     843    0,/* BS */
     844    0, /* TAB */
     845    0,
     846    0,
     847    0,
     848    0,
     849    0,
     850    0,
     851    0,
     852    0,
     853    0,
     854    0,
     855    0,
     856    0,
     857    0,
     858    0, /* CL */
     859    1, // F1
     860    2, // F2
     861    3, // F3
     862    4, // F4
     863    5, // F5
     864    6, // F6
     865    7, // F7
     866    8, // F8
     867    9, // F9
     868    10, // F10
     869    11, // F11
     870    12, // F12
     871    32, // PrintScr
     872    33, // Scroll Lock
     873    34, // Pause
     874    35, // Insert
     875    36, // Home
     876    37, // Pg Up
     877    38, // Delete
     878    39, // End
     879    40, // Pg Down
     880    41, // Right
     881    42, // Left
     882    43, // Down
     883    44, // Up
     884    0, // Numlock
     885    0, // Keypad /
     886    0, // Keypad *
     887    0, // Keypad -
     888    0, // Keypad +
     889    0, // Keypad Enter
     890    39, // Keypad 1/End
     891    43, // Keypad 2/Down
     892    40, // Keypad 3/PageDn
     893    42, // Keypad 4/Left
     894    0, // Keypad 5
     895    41, // Keypad 6/Right
     896    36, // Keypad 7/Home
     897    44, // Keypad 8/Up
     898    37, // Keypad 9/PageUp
     899    35, // Keypad 0/Insert
     900    38, // Keypad ./Delete
     901    0,
     902    0,
     903    0,
     904    0,
     905    0,
     906    0,
     907    0,
     908    0,
     909    0,
     910    0,
     911    0,
     912    0,
     913    0,
     914    0,
     915    0,
     916    0,
     917    0,
     918    0,
     919    0,
     920    0,
     921    0,
     922    0,
     923    0,
     924    0,
     925    0,
     926    0,
     927    0,
     928    0,
     929    0,
     930    0,
     931    0,
     932    0,
     933    0,
     934    0,
     935    0,
     936    0,
     937    0,
     938    0,
     939    0,
     940    0,
     941    0,
     942    0,
     943    0,
     944    0,
     945    0,
     946    0,
     947    0,
     948    0,
     949    0,
     950    0,
     951    0,
     952    0,
     953    0,
     954    0,
     955    0,
     956    0,
     957    0,
     958    0,
     959    0,
     960    0,
     961    0,
     962    0,
     963    0,
     964    0,
     965    0,
     966    0,
     967    0,
     968    0,
     969    0,
     970    0,
     971    0,
     972    0,
     973    0,
     974    0,
     975    0,
     976    0,
     977    0,
     978    0,
     979    0,
     980    0,
     981    0,
     982    0,
     983    0,
     984    0,
     985    0,
     986    0,
     987    0,
     988    0,
     989    0,
     990    0,
     991    0,
     992    0,
     993    0,
     994    0,
     995    0,
     996    0,
     997    0,
     998    0,
     999    0,
     1000    0,
     1001    0,
     1002    0,
     1003    0,
     1004    0,
     1005    0,
     1006    0,
     1007    0,
     1008    0,
     1009    0,
     1010    0,
     1011    0,
     1012    0,
     1013    0,
     1014    0,
     1015    0,
     1016    0,
     1017    0,
     1018    0,
     1019    0,
     1020    0,
     1021    0,
     1022    0,
     1023    0,
     1024    0,
     1025    0,
     1026    0,
     1027    0,
     1028    0,
     1029    0,
     1030    0,
     1031    0,
     1032    0,
     1033    0,
     1034    0,
     1035    0,
     1036    0,
     1037    0,
     1038    0,
     1039    0,
     1040    0,
     1041    0,
     1042    0,
     1043    0,
     1044    0,
     1045    0,
     1046    0,
     1047    0,
     1048    0,
     1049    0,
     1050    0,
     1051    0,
     1052    0,
     1053    0,
     1054    0,
     1055    0,
     1056    0
     1057  };
     1058
     1059u8 us_control_map[PS2KBD_KEYMAP_SIZE] = {
     1060
     1061    0,
     1062    0,
     1063    0,
     1064    0,
     1065    1, //a
     1066    2, //b
     1067    3, //c
     1068    4, //d
     1069    5, //e
     1070    6, //f
     1071    7,//g
     1072    8,//h
     1073    9,//i
     1074    10,//j
     1075    11,//k
     1076    12,//l
     1077    13,//m
     1078    14,//n
     1079    15,//o
     1080    16,//p
     1081    17,//q
     1082    18,//r
     1083    19,//s
     1084    20,//t
     1085    21,//u
     1086    22,//v
     1087    23,//w
     1088    24,//x
     1089    25,//y
     1090    26,//z
     1091    0,
     1092    0,
     1093    0,
     1094    0,
     1095    0,
     1096    0,
     1097    0,
     1098    0,
     1099    0,
     1100    0,
     1101    0, /* line feed */
     1102    0, /* Esc */
     1103    0,/* BS */
     1104    0, /* TAB */
     1105    0,
     1106    0,
     1107    0,
     1108    0,
     1109    0,
     1110    0,
     1111    0,
     1112    0,
     1113    0,
     1114    0,
     1115    0,
     1116    0,
     1117    0,
     1118    0, /* CL */
     1119    0, // F1
     1120    0, // F2
     1121    0, // F3
     1122    0, // F4
     1123    0, // F5
     1124    0, // F6
     1125    0, // F7
     1126    0, // F8
     1127    0, // F9
     1128    0, // F10
     1129    0, // F11
     1130    0, // F12
     1131    0, // PrintScr
     1132    0, // Scroll Lock
     1133    0, // Pause
     1134    0, // Insert
     1135    0, // Home
     1136    0, // Pg Up
     1137    0, // Delete
     1138    0, // End
     1139    0, // Pg Down
     1140    0, // Right
     1141    0, // Left
     1142    0, // Down
     1143    0, // Up
     1144    0, // Numlock
     1145    0, // Keypad
     1146    0,
     1147    0,
     1148    0,
     1149    0,
     1150    0,
     1151    0,
     1152    0,
     1153    0,
     1154    0,
     1155    0,
     1156    0,
     1157    0,
     1158    0,
     1159    0,
     1160    0,
     1161    0,
     1162    0,
     1163    0,
     1164    0,
     1165    0,
     1166    0,
     1167    0,
     1168    0,
     1169    0,
     1170    0,
     1171    0,
     1172    0,
     1173    0,
     1174    0,
     1175    0,
     1176    0,
     1177    0,
     1178    0,
     1179    0,
     1180    0,
     1181    0,
     1182    0,
     1183    0,
     1184    0,
     1185    0,
     1186    0,
     1187    0,
     1188    0,
     1189    0,
     1190    0,
     1191    0,
     1192    0,
     1193    0,
     1194    0,
     1195    0,
     1196    0,
     1197    0,
     1198    0,
     1199    0,
     1200    0,
     1201    0,
     1202    0,
     1203    0,
     1204    0,
     1205    0,
     1206    0,
     1207    0,
     1208    0,
     1209    0,
     1210    0,
     1211    0,
     1212    0,
     1213    0,
     1214    0,
     1215    0,
     1216    0,
     1217    0,
     1218    0,
     1219    0,
     1220    0,
     1221    0,
     1222    0,
     1223    0,
     1224    0,
     1225    0,
     1226    0,
     1227    0,
     1228    0,
     1229    0,
     1230    0,
     1231    0,
     1232    0,
     1233    0,
     1234    0,
     1235    0,
     1236    0,
     1237    0,
     1238    0,
     1239    0,
     1240    0,
     1241    0,
     1242    0,
     1243    0,
     1244    0,
     1245    0,
     1246    0,
     1247    0,
     1248    0,
     1249    0,
     1250    0,
     1251    0,
     1252    0,
     1253    0,
     1254    0,
     1255    0,
     1256    0,
     1257    0,
     1258    0,
     1259    0,
     1260    0,
     1261    0,
     1262    0,
     1263    0,
     1264    0,
     1265    0,
     1266    0,
     1267    0,
     1268    0,
     1269    0,
     1270    0,
     1271    0,
     1272    0,
     1273    0,
     1274    0,
     1275    0,
     1276    0,
     1277    0,
     1278    0,
     1279    0,
     1280    0,
     1281    0,
     1282    0,
     1283    0,
     1284    0,
     1285    0,
     1286    0,
     1287    0,
     1288    0,
     1289    0,
     1290    0,
     1291    0,
     1292    0,
     1293    0,
     1294    0,
     1295    0,
     1296    0,
     1297    0,
     1298    0,
     1299    0,
     1300    0,
     1301    0,
     1302    0,
     1303    0,
     1304    0,
     1305    0,
     1306    0,
     1307    0,
     1308    0,
     1309    0,
     1310    0,
     1311    0,
     1312    0,
     1313    0,
     1314    0,
     1315    0,
     1316    0
     1317};
     1318
     1319u8 us_alt_map[PS2KBD_KEYMAP_SIZE] = {
     1320
     1321    0,
     1322    0,
     1323    0,
     1324    0,
     1325    128, //a
     1326    129, //b
     1327    130, //c
     1328    131, //d
     1329    132, //e
     1330    133, //f
     1331    134,//g
     1332    135,//h
     1333    136,//i
     1334    137,//j
     1335    138,//k
     1336    139,//l
     1337    140,//m
     1338    141,//n
     1339    142,//o
     1340    143,//p
     1341    144,//q
     1342    145,//r
     1343    146,//s
     1344    147,//t
     1345    148,//u
     1346    149,//v
     1347    150,//w
     1348    151,//x
     1349    152,//y
     1350    154,//z
     1351    155,
     1352    156,
     1353    157,
     1354    158,
     1355    159,
     1356    160,
     1357    161,
     1358    162,
     1359    163,
     1360    164,
     1361    165, /* line feed */
     1362    0, /* Esc */
     1363    0,/* BS */
     1364    0, /* TAB */
     1365    0,
     1366    0,
     1367    0,
     1368    0,
     1369    0,
     1370    0,
     1371    0,
     1372    0,
     1373    0,
     1374    0,
     1375    0,
     1376    0,
     1377    0,
     1378    0, /* CL */
     1379    0, // F1
     1380    0, // F2
     1381    0, // F3
     1382    0, // F4
     1383    0, // F5
     1384    0, // F6
     1385    0, // F7
     1386    0, // F8
     1387    0, // F9
     1388    0, // F10
     1389    0, // F11
     1390    0, // F12
     1391    0, // PrintScr
     1392    0, // Scroll Lock
     1393    0, // Pause
     1394    0, // Insert
     1395    0, // Home
     1396    0, // Pg Up
     1397    0, // Delete
     1398    0, // End
     1399    0, // Pg Down
     1400    0, // Right
     1401    0, // Left
     1402    0, // Down
     1403    0, // Up
     1404    0, // Numlock
     1405    0, // Keypad
     1406    0,
     1407    0,
     1408    0,
     1409    0,
     1410    0,
     1411    0,
     1412    0,
     1413    0,
     1414    0,
     1415    0,
     1416    0,
     1417    0,
     1418    0,
     1419    0,
     1420    0,
     1421    0,
     1422    0,
     1423    0,
     1424    0,
     1425    0,
     1426    0,
     1427    0,
     1428    0,
     1429    0,
     1430    0,
     1431    0,
     1432    0,
     1433    0,
     1434    0,
     1435    0,
     1436    0,
     1437    0,
     1438    0,
     1439    0,
     1440    0,
     1441    0,
     1442    0,
     1443    0,
     1444    0,
     1445    0,
     1446    0,
     1447    0,
     1448    0,
     1449    0,
     1450    0,
     1451    0,
     1452    0,
     1453    0,
     1454    0,
     1455    0,
     1456    0,
     1457    0,
     1458    0,
     1459    0,
     1460    0,
     1461    0,
     1462    0,
     1463    0,
     1464    0,
     1465    0,
     1466    0,
     1467    0,
     1468    0,
     1469    0,
     1470    0,
     1471    0,
     1472    0,
     1473    0,
     1474    0,
     1475    0,
     1476    0,
     1477    0,
     1478    0,
     1479    0,
     1480    0,
     1481    0,
     1482    0,
     1483    0,
     1484    0,
     1485    0,
     1486    0,
     1487    0,
     1488    0,
     1489    0,
     1490    0,
     1491    0,
     1492    0,
     1493    0,
     1494    0,
     1495    0,
     1496    0,
     1497    0,
     1498    0,
     1499    0,
     1500    0,
     1501    0,
     1502    0,
     1503    0,
     1504    0,
     1505    0,
     1506    0,
     1507    0,
     1508    0,
     1509    0,
     1510    0,
     1511    0,
     1512    0,
     1513    0,
     1514    0,
     1515    0,
     1516    0,
     1517    0,
     1518    0,
     1519    0,
     1520    0,
     1521    0,
     1522    0,
     1523    0,
     1524    0,
     1525    0,
     1526    0,
     1527    0,
     1528    0,
     1529    0,
     1530    0,
     1531    0,
     1532    0,
     1533    0,
     1534    0,
     1535    0,
     1536    0,
     1537    0,
     1538    0,
     1539    0,
     1540    0,
     1541    0,
     1542    0,
     1543    0,
     1544    0,
     1545    0,
     1546    0,
     1547    0,
     1548    0,
     1549    0,
     1550    0,
     1551    0,
     1552    0,
     1553    0,
     1554    0,
     1555    0,
     1556    0,
     1557    0,
     1558    0,
     1559    0,
     1560    0,
     1561    0,
     1562    0,
     1563    0,
     1564    0,
     1565    0,
     1566    0,
     1567    0,
     1568    0,
     1569    0,
     1570    0,
     1571    0,
     1572    0,
     1573    0,
     1574    0,
     1575    0,
     1576    0
     1577  };
     1578
     1579#endif
  • backends/platform/ps2/irxboot.cpp

    diff -u -N -r branch-0-11-0/backends/platform/ps2/irxboot.cpp branch-0-11-0-ps2/backends/platform/ps2/irxboot.cpp
    old new  
    1818 * along with this program; if not, write to the Free Software
    1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    2020 *
    21  * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-11-0/backends/platform/ps2/irxboot.cpp $
     21 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-10-0/backends/platform/ps2/irxboot.cpp $
    2222 * $Id: irxboot.cpp 27024 2007-05-30 21:56:52Z fingolfin $
    2323 *
    2424 */
     
    3434
    3535extern void sioprintf(const char *zFormat, ...);
    3636
    37 static const char hddArg[] = "-o" "\0" "4" "\0" "-n" "\0" "20";
    38 static const char pfsArg[] = "-m" "\0" "2" "\0" "-o" "\0" "16" "\0" "-n" "\0" "40" /*"\0" "-debug"*/;
     37static const char hddArg[] = "-o" "\0" "8" "\0" "-n" "\0" "20";
     38static const char pfsArg[] = "-m" "\0" "2" "\0" "-o" "\0" "32" "\0" "-n" "\0" "72"; // "\0" "-debug";
    3939
    4040IrxFile irxFiles[] = {
    4141        { "SIO2MAN", BIOS, NOTHING, NULL, 0 },
     
    209209                }
    210210                curModule++;
    211211        }
     212
    212213        *modules = resModules;
    213214        sioprintf("List of %d modules:", curModule - resModules);
    214215        for (int i = 0; i < curModule - resModules; i++)
  • backends/platform/ps2/irxboot.h

    diff -u -N -r branch-0-11-0/backends/platform/ps2/irxboot.h branch-0-11-0-ps2/backends/platform/ps2/irxboot.h
    old new  
    1818 * along with this program; if not, write to the Free Software
    1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    2020 *
    21  * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-11-0/backends/platform/ps2/irxboot.h $
     21 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-10-0/backends/platform/ps2/irxboot.h $
    2222 * $Id: irxboot.h 27024 2007-05-30 21:56:52Z fingolfin $
    2323 *
    2424 */
  • backends/platform/ps2/ps2input.cpp

    diff -u -N -r branch-0-11-0/backends/platform/ps2/ps2input.cpp branch-0-11-0-ps2/backends/platform/ps2/ps2input.cpp
    old new  
    1818 * along with this program; if not, write to the Free Software
    1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    2020 *
    21  * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-11-0/backends/platform/ps2/ps2input.cpp $
    22  * $Id: ps2input.cpp 27616 2007-06-22 20:04:44Z fingolfin $
     21 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-10-0/backends/platform/ps2/ps2input.cpp $
     22 * $Id: ps2input.cpp 27024 2007-05-30 21:56:52Z fingolfin $
    2323 *
    2424 */
    2525
     
    3131#include "backends/platform/ps2/ps2input.h"
    3232#include "backends/platform/ps2/ps2pad.h"
    3333#include "backends/platform/ps2/systemps2.h"
     34#include "backends/platform/ps2/sdlkeys.h"
    3435#include "common/events.h"
    3536#include "common/system.h"
    3637
     
    9596#define PAD_CHECK_TIME 20
    9697
    9798int Ps2Input::mapKey(int key, int mod) { // copied from sdl backend
    98         if (key >= Common::KEYCODE_F1 && key <= Common::KEYCODE_F9) {
    99                 return key - Common::KEYCODE_F1 + Common::ASCII_F1;
    100         } else if (key >= Common::KEYCODE_KP0 && key <= Common::KEYCODE_KP9) {
    101                 return key - Common::KEYCODE_KP0 + '0';
    102         } else if (key >= Common::KEYCODE_UP && key <= Common::KEYCODE_PAGEDOWN) {
     99        if (key >= SDLK_F1 && key <= SDLK_F9) {
     100                return key - SDLK_F1 + 315;
     101        } else if (key >= SDLK_KP0 && key <= SDLK_KP9) {
     102                return key - SDLK_KP0 + '0';
     103        } else if (key >= SDLK_UP && key <= SDLK_PAGEDOWN) {
    103104                return key;
    104105        } else if (key >= 'a' && key <= 'z' && mod & Common::KBD_SHIFT) {
    105106                return key & ~0x20;
    106         } else if (key >= Common::KEYCODE_NUMLOCK && key <= Common::KEYCODE_EURO) {
     107        } else if (key >= SDLK_NUMLOCK && key <= SDLK_EURO) {
    107108                return 0;
    108109        }
    109110        return key;
     
    141142                PS2KbdRawKey key;
    142143                if (PS2KbdReadRaw(&key) == 1) {
    143144                        if (_usbToSdlk[key.key]) {
    144                                 if ((_usbToSdlk[key.key] == Common::KEYCODE_LSHIFT) || (_usbToSdlk[key.key] == Common::KEYCODE_RSHIFT)) {
     145                                if ((_usbToSdlk[key.key] == SDLK_LSHIFT) || (_usbToSdlk[key.key] == SDLK_RSHIFT)) {
    145146                                        if (key.state & 1)
    146147                                                _keyFlags |= Common::KBD_SHIFT;
    147148                                        else
    148149                                                _keyFlags &= ~Common::KBD_SHIFT;
    149                                 } else if ((_usbToSdlk[key.key] == Common::KEYCODE_LCTRL) || (_usbToSdlk[key.key] == Common::KEYCODE_RCTRL)) {
     150                                } else if ((_usbToSdlk[key.key] == SDLK_LCTRL) || (_usbToSdlk[key.key] == SDLK_RCTRL)) {
    150151                                        if (key.state & 1)
    151152                                                _keyFlags |= Common::KBD_CTRL;
    152153                                        else
    153154                                                _keyFlags &= ~Common::KBD_CTRL;
    154                                 } else if ((_usbToSdlk[key.key] == Common::KEYCODE_LALT) || (_usbToSdlk[key.key] == Common::KEYCODE_RALT)) {
     155                                } else if ((_usbToSdlk[key.key] == SDLK_LALT) || (_usbToSdlk[key.key] == SDLK_RALT)) {
    155156                                        if (key.state & 1)
    156157                                                _keyFlags |= Common::KBD_ALT;
    157158                                        else
     
    162163                                else
    163164                                        event->type = Common::EVENT_KEYUP;
    164165                                event->kbd.flags = 0;
    165                                 event->kbd.keycode = _usbToSdlk[key.key];
     166                                event->kbd.keycode = (Common::KeyCode)_usbToSdlk[key.key];
    166167                                event->kbd.ascii = mapKey(_usbToSdlk[key.key], _keyFlags);
    167168                                return true;
    168169                        } else
     
    241242                }
    242243                if (_padCodes[entry]) {
    243244                        event->type = (down) ? Common::EVENT_KEYDOWN : Common::EVENT_KEYUP;
    244                         event->kbd.keycode = _padCodes[entry];
     245                        event->kbd.keycode = (Common::KeyCode)_padCodes[entry];
    245246                        event->kbd.flags = _padFlags[entry];
    246247                        event->kbd.ascii = mapKey(_padCodes[entry], _padFlags[entry]);
    247248                        return true;
     
    255256        /* 01 */        0,
    256257        /* 02 */        0,
    257258        /* 03 */        0,
    258         /* 04 */        Common::KEYCODE_a,
    259         /* 05 */        Common::KEYCODE_b,
    260         /* 06 */        Common::KEYCODE_c,
    261         /* 07 */        Common::KEYCODE_d,
    262         /* 08 */        Common::KEYCODE_e,
    263         /* 09 */        Common::KEYCODE_f,
    264         /* 0A */        Common::KEYCODE_g,
    265         /* 0B */        Common::KEYCODE_h,
    266         /* 0C */        Common::KEYCODE_i,
    267         /* 0D */        Common::KEYCODE_j,
    268         /* 0E */        Common::KEYCODE_k,
    269         /* 0F */        Common::KEYCODE_l,
    270         /* 10 */        Common::KEYCODE_m,
    271         /* 11 */        Common::KEYCODE_n,
    272         /* 12 */        Common::KEYCODE_o,
    273         /* 13 */        Common::KEYCODE_p,
    274         /* 14 */        Common::KEYCODE_q,
    275         /* 15 */        Common::KEYCODE_r,
    276         /* 16 */        Common::KEYCODE_s,
    277         /* 17 */        Common::KEYCODE_t,
    278         /* 18 */        Common::KEYCODE_u,
    279         /* 19 */        Common::KEYCODE_v,
    280         /* 1A */        Common::KEYCODE_w,
    281         /* 1B */        Common::KEYCODE_x,
    282         /* 1C */        Common::KEYCODE_y,
    283         /* 1D */        Common::KEYCODE_z,
    284         /* 1E */        Common::KEYCODE_1,
    285         /* 1F */        Common::KEYCODE_2,
    286         /* 20 */        Common::KEYCODE_3,
    287         /* 21 */        Common::KEYCODE_4,
    288         /* 22 */        Common::KEYCODE_5,
    289         /* 23 */        Common::KEYCODE_6,
    290         /* 24 */        Common::KEYCODE_7,
    291         /* 25 */        Common::KEYCODE_8,
    292         /* 26 */        Common::KEYCODE_9,
    293         /* 27 */        Common::KEYCODE_0,
    294         /* 28 */        Common::KEYCODE_RETURN,
    295         /* 29 */        Common::KEYCODE_ESCAPE,
    296         /* 2A */        Common::KEYCODE_BACKSPACE,
    297         /* 2B */        Common::KEYCODE_TAB,
    298         /* 2C */        Common::KEYCODE_SPACE,
    299         /* 2D */        Common::KEYCODE_MINUS,
    300         /* 2E */        Common::KEYCODE_EQUALS,
    301         /* 2F */        Common::KEYCODE_LEFTBRACKET,
    302         /* 30 */        Common::KEYCODE_RIGHTBRACKET,
    303         /* 31 */        Common::KEYCODE_BACKSLASH,
    304         /* 32 */        Common::KEYCODE_HASH,
    305         /* 33 */        Common::KEYCODE_SEMICOLON,
    306         /* 34 */        Common::KEYCODE_QUOTE,
    307         /* 35 */        Common::KEYCODE_BACKQUOTE,
    308         /* 36 */        Common::KEYCODE_COMMA,
    309         /* 37 */        Common::KEYCODE_PERIOD,
    310         /* 38 */        Common::KEYCODE_SLASH,
    311         /* 39 */        Common::KEYCODE_CAPSLOCK,
    312         /* 3A */        Common::KEYCODE_F1,
    313         /* 3B */        Common::KEYCODE_F2,
    314         /* 3C */        Common::KEYCODE_F3,
    315         /* 3D */        Common::KEYCODE_F4,
    316         /* 3E */        Common::KEYCODE_F5,
    317         /* 3F */        Common::KEYCODE_F6,
    318         /* 40 */        Common::KEYCODE_F7,
    319         /* 41 */        Common::KEYCODE_F8,
    320         /* 42 */        Common::KEYCODE_F9,
    321         /* 43 */        Common::KEYCODE_F10,
    322         /* 44 */        Common::KEYCODE_F11,
    323         /* 45 */        Common::KEYCODE_F12,
    324         /* 46 */        Common::KEYCODE_PRINT,
    325         /* 47 */        Common::KEYCODE_SCROLLOCK,
    326         /* 48 */        Common::KEYCODE_PAUSE,
    327         /* 49 */        Common::KEYCODE_INSERT,
    328         /* 4A */        Common::KEYCODE_HOME,
    329         /* 4B */        Common::KEYCODE_PAGEUP,
    330         /* 4C */        Common::KEYCODE_DELETE,
    331         /* 4D */        Common::KEYCODE_END,
    332         /* 4E */        Common::KEYCODE_PAGEDOWN,
    333         /* 4F */        Common::KEYCODE_RIGHT,
    334         /* 50 */        Common::KEYCODE_LEFT,
    335         /* 51 */        Common::KEYCODE_DOWN,
    336         /* 52 */        Common::KEYCODE_UP,
    337         /* 53 */        Common::KEYCODE_NUMLOCK,
    338         /* 54 */        Common::KEYCODE_KP_DIVIDE,
    339         /* 55 */        Common::KEYCODE_KP_MULTIPLY,
    340         /* 56 */        Common::KEYCODE_KP_MINUS,
    341         /* 57 */        Common::KEYCODE_KP_PLUS,
    342         /* 58 */        Common::KEYCODE_KP_ENTER,
    343         /* 59 */        Common::KEYCODE_KP1,
    344         /* 5A */        Common::KEYCODE_KP2,
    345         /* 5B */        Common::KEYCODE_KP3,
    346         /* 5C */        Common::KEYCODE_KP4,
    347         /* 5D */        Common::KEYCODE_KP5,
    348         /* 5E */        Common::KEYCODE_KP6,
    349         /* 5F */        Common::KEYCODE_KP7,
    350         /* 60 */        Common::KEYCODE_KP8,
    351         /* 61 */        Common::KEYCODE_KP9,
    352         /* 62 */        Common::KEYCODE_KP0,
    353         /* 63 */        Common::KEYCODE_KP_PERIOD,
     259        /* 04 */        SDLK_a,
     260        /* 05 */        SDLK_b,
     261        /* 06 */        SDLK_c,
     262        /* 07 */        SDLK_d,
     263        /* 08 */        SDLK_e,
     264        /* 09 */        SDLK_f,
     265        /* 0A */        SDLK_g,
     266        /* 0B */        SDLK_h,
     267        /* 0C */        SDLK_i,
     268        /* 0D */        SDLK_j,
     269        /* 0E */        SDLK_k,
     270        /* 0F */        SDLK_l,
     271        /* 10 */        SDLK_m,
     272        /* 11 */        SDLK_n,
     273        /* 12 */        SDLK_o,
     274        /* 13 */        SDLK_p,
     275        /* 14 */        SDLK_q,
     276        /* 15 */        SDLK_r,
     277        /* 16 */        SDLK_s,
     278        /* 17 */        SDLK_t,
     279        /* 18 */        SDLK_u,
     280        /* 19 */        SDLK_v,
     281        /* 1A */        SDLK_w,
     282        /* 1B */        SDLK_x,
     283        /* 1C */        SDLK_y,
     284        /* 1D */        SDLK_z,
     285        /* 1E */        SDLK_1,
     286        /* 1F */        SDLK_2,
     287        /* 20 */        SDLK_3,
     288        /* 21 */        SDLK_4,
     289        /* 22 */        SDLK_5,
     290        /* 23 */        SDLK_6,
     291        /* 24 */        SDLK_7,
     292        /* 25 */        SDLK_8,
     293        /* 26 */        SDLK_9,
     294        /* 27 */        SDLK_0,
     295        /* 28 */        SDLK_RETURN,
     296        /* 29 */        SDLK_ESCAPE,
     297        /* 2A */        SDLK_BACKSPACE,
     298        /* 2B */        SDLK_TAB,
     299        /* 2C */        SDLK_SPACE,
     300        /* 2D */        SDLK_MINUS,
     301        /* 2E */        SDLK_EQUALS,
     302        /* 2F */        SDLK_LEFTBRACKET,
     303        /* 30 */        SDLK_RIGHTBRACKET,
     304        /* 31 */        SDLK_BACKSLASH,
     305        /* 32 */        SDLK_HASH,
     306        /* 33 */        SDLK_SEMICOLON,
     307        /* 34 */        SDLK_QUOTE,
     308        /* 35 */        SDLK_BACKQUOTE,
     309        /* 36 */        SDLK_COMMA,
     310        /* 37 */        SDLK_PERIOD,
     311        /* 38 */        SDLK_SLASH,
     312        /* 39 */        SDLK_CAPSLOCK,
     313        /* 3A */        SDLK_F1,
     314        /* 3B */        SDLK_F2,
     315        /* 3C */        SDLK_F3,
     316        /* 3D */        SDLK_F4,
     317        /* 3E */        SDLK_F5,
     318        /* 3F */        SDLK_F6,
     319        /* 40 */        SDLK_F7,
     320        /* 41 */        SDLK_F8,
     321        /* 42 */        SDLK_F9,
     322        /* 43 */        SDLK_F10,
     323        /* 44 */        SDLK_F11,
     324        /* 45 */        SDLK_F12,
     325        /* 46 */        SDLK_PRINT,
     326        /* 47 */        SDLK_SCROLLOCK,
     327        /* 48 */        SDLK_PAUSE,
     328        /* 49 */        SDLK_INSERT,
     329        /* 4A */        SDLK_HOME,
     330        /* 4B */        SDLK_PAGEUP,
     331        /* 4C */        SDLK_DELETE,
     332        /* 4D */        SDLK_END,
     333        /* 4E */        SDLK_PAGEDOWN,
     334        /* 4F */        SDLK_RIGHT,
     335        /* 50 */        SDLK_LEFT,
     336        /* 51 */        SDLK_DOWN,
     337        /* 52 */        SDLK_UP,
     338        /* 53 */        SDLK_NUMLOCK,
     339        /* 54 */        SDLK_KP_DIVIDE,
     340        /* 55 */        SDLK_KP_MULTIPLY,
     341        /* 56 */        SDLK_KP_MINUS,
     342        /* 57 */        SDLK_KP_PLUS,
     343        /* 58 */        SDLK_KP_ENTER,
     344        /* 59 */        SDLK_KP1,
     345        /* 5A */        SDLK_KP2,
     346        /* 5B */        SDLK_KP3,
     347        /* 5C */        SDLK_KP4,
     348        /* 5D */        SDLK_KP5,
     349        /* 5E */        SDLK_KP6,
     350        /* 5F */        SDLK_KP7,
     351        /* 60 */        SDLK_KP8,
     352        /* 61 */        SDLK_KP9,
     353        /* 62 */        SDLK_KP0,
     354        /* 63 */        SDLK_KP_PERIOD,
    354355        /* 64 */        0,
    355356        /* 65 */        0,
    356357        /* 66 */        0,
    357         /* 67 */        Common::KEYCODE_KP_EQUALS,
     358        /* 67 */        SDLK_KP_EQUALS,
    358359        /* 68 */        0,
    359360        /* 69 */        0,
    360361        /* 6A */        0,
     
    475476        /* DD */        0,
    476477        /* DE */        0,
    477478        /* DF */        0,
    478         /* E0 */    Common::KEYCODE_LCTRL,
    479         /* E1 */        Common::KEYCODE_LSHIFT,
    480         /* E2 */        Common::KEYCODE_LALT,
     479        /* E0 */    SDLK_LCTRL,
     480        /* E1 */        SDLK_LSHIFT,
     481        /* E2 */        SDLK_LALT,
    481482        /* E3 */        0,
    482         /* E4 */    Common::KEYCODE_RCTRL,
    483         /* E5 */        Common::KEYCODE_RSHIFT,
    484         /* E6 */        Common::KEYCODE_RALT,
     483        /* E4 */    SDLK_RCTRL,
     484        /* E5 */        SDLK_RSHIFT,
     485        /* E6 */        SDLK_RALT,
    485486        /* E7 */        0,
    486487        /* E8 */        0,
    487488        /* E9 */        0,
     
    510511};
    511512
    512513const int Ps2Input::_padCodes[16] = {
    513         Common::KEYCODE_1,               // Select
     514        SDLK_1,          // Select
    514515        0,                       // L3
    515516        0,                       // R3
    516         Common::KEYCODE_F5,      // Start
     517        SDLK_F5,         // Start
    517518        0,                       //     Up
    518519        0,                       //     Right
    519520        0,                       //     Down
    520521        0,                       //     Left
    521         Common::KEYCODE_KP0,     //     L2
     522        SDLK_KP0,        //     L2
    522523        0,                       //     R2
    523         Common::KEYCODE_n,               //     L1
    524         Common::KEYCODE_y,               //     R1
    525         Common::KEYCODE_ESCAPE, // Triangle
     524        SDLK_n,          //     L1
     525        SDLK_y,          //     R1
     526        SDLK_ESCAPE, // Triangle
    526527        0,                       //     Circle  => Right mouse button
    527528        0,                       //     Cross   => Left mouse button
    528         Common::KEYCODE_RETURN   //     Square
     529        SDLK_RETURN      //     Square
    529530};
    530531
    531532const int Ps2Input::_padFlags[16] = {
  • backends/platform/ps2/ps2input.h

    diff -u -N -r branch-0-11-0/backends/platform/ps2/ps2input.h branch-0-11-0-ps2/backends/platform/ps2/ps2input.h
    old new  
    1818 * along with this program; if not, write to the Free Software
    1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    2020 *
    21  * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-11-0/backends/platform/ps2/ps2input.h $
     21 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-10-0/backends/platform/ps2/ps2input.h $
    2222 * $Id: ps2input.h 27024 2007-05-30 21:56:52Z fingolfin $
    2323 *
    2424 */
  • backends/platform/ps2/ps2mutex.cpp

    diff -u -N -r branch-0-11-0/backends/platform/ps2/ps2mutex.cpp branch-0-11-0-ps2/backends/platform/ps2/ps2mutex.cpp
    old new  
    1818 * along with this program; if not, write to the Free Software
    1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    2020 *
    21  * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-11-0/backends/platform/ps2/ps2mutex.cpp $
     21 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-10-0/backends/platform/ps2/ps2mutex.cpp $
    2222 * $Id: ps2mutex.cpp 27024 2007-05-30 21:56:52Z fingolfin $
    2323 *
    2424 */
    2525
    2626#include "backends/platform/ps2/systemps2.h"
    2727
     28void OSystem_PS2::initMutexes(void) {
     29        ee_sema_t newSema;
     30        newSema.init_count = 1;
     31        newSema.max_count = 1;
     32        _mutexSema = CreateSema(&newSema);
     33        for (int i = 0; i < MAX_MUTEXES; i++) {
     34                _mutex[i].sema = -1;
     35                _mutex[i].count = _mutex[i].owner = 0;
     36        }
     37}
     38
    2839OSystem::MutexRef OSystem_PS2::createMutex(void) {
    2940        WaitSema(_mutexSema);
    3041        Ps2Mutex *mutex = NULL;
     
    4960        WaitSema(_mutexSema);
    5061        Ps2Mutex *sysMutex = (Ps2Mutex*)mutex;
    5162        int tid = GetThreadId();
     63
    5264        assert(tid != 0);
    5365        if (sysMutex->owner && (sysMutex->owner == tid))
    5466                sysMutex->count++;
     
    6678        WaitSema(_mutexSema);
    6779        Ps2Mutex *sysMutex = (Ps2Mutex*)mutex;
    6880        int tid = GetThreadId();
     81
    6982        if (sysMutex->owner && sysMutex->count && (sysMutex->owner == tid))
    7083                sysMutex->count--;
    7184        else {
  • backends/platform/ps2/ps2pad.cpp

    diff -u -N -r branch-0-11-0/backends/platform/ps2/ps2pad.cpp branch-0-11-0-ps2/backends/platform/ps2/ps2pad.cpp
    old new  
    1818 * along with this program; if not, write to the Free Software
    1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    2020 *
    21  * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-11-0/backends/platform/ps2/ps2pad.cpp $
     21 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-10-0/backends/platform/ps2/ps2pad.cpp $
    2222 * $Id: ps2pad.cpp 27024 2007-05-30 21:56:52Z fingolfin $
    2323 *
    2424 */
  • backends/platform/ps2/ps2pad.h

    diff -u -N -r branch-0-11-0/backends/platform/ps2/ps2pad.h branch-0-11-0-ps2/backends/platform/ps2/ps2pad.h
    old new  
    1818 * along with this program; if not, write to the Free Software
    1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    2020 *
    21  * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-11-0/backends/platform/ps2/ps2pad.h $
     21 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-10-0/backends/platform/ps2/ps2pad.h $
    2222 * $Id: ps2pad.h 27024 2007-05-30 21:56:52Z fingolfin $
    2323 *
    2424 */
  • backends/platform/ps2/ps2time.cpp

    diff -u -N -r branch-0-11-0/backends/platform/ps2/ps2time.cpp branch-0-11-0-ps2/backends/platform/ps2/ps2time.cpp
    old new  
    1818 * along with this program; if not, write to the Free Software
    1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    2020 *
    21  * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-11-0/backends/platform/ps2/ps2time.cpp $
    22  * $Id: ps2time.cpp 30035 2007-12-28 07:44:40Z sev $
     21 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-10-0/backends/platform/ps2/ps2time.cpp $
     22 * $Id: ps2time.cpp 27024 2007-05-30 21:56:52Z fingolfin $
    2323 *
    2424 */
    2525
    2626#include "backends/platform/ps2/systemps2.h"
    2727#include "eecodyvdfs.h"
    2828#include <osd_config.h>
     29#include <time.h>
     30
    2931#define FROM_BCD(a) ((a >> 4) * 10 + (a & 0xF))
    3032
    3133static int        g_timeSecs;
     
    104106}
    105107
    106108extern "C" time_t time(time_t *p) {
    107         if (p) *p = (time_t)g_timeSecs;
    108109        return (time_t)g_timeSecs;
    109110}
    110111
    111112extern "C" struct tm *localtime(const time_t *p) {
    112         // FIXME: This function should actually use the value in *p!
    113         // But the work needed for that is not necessary -- just implement
    114         // OSystem::getTimeAndDate using the code provided here, and
    115         // ditch the custom time & localtime methods.
    116113        uint32 currentSecs = g_timeSecs + (msecCount - g_lastTimeCheck) / 1000;
    117114        if (currentSecs >= SECONDS_PER_DAY) {
    118115                buildNewDate(+1);
  • backends/platform/ps2/rpckbd.c

    diff -u -N -r branch-0-11-0/backends/platform/ps2/rpckbd.c branch-0-11-0-ps2/backends/platform/ps2/rpckbd.c
    old new  
     1/*
     2# _____     ___ ____     ___ ____
     3#  ____|   |    ____|   |        | |____|
     4# |     ___|   |____ ___|    ____| |    \    PS2DEV Open Source Project.
     5#-----------------------------------------------------------------------
     6# Copyright 2005, ps2dev - http://www.ps2dev.org
     7# Licenced under Academic Free License version 2.0
     8# Review ps2sdk README & LICENSE files for further details.
     9#
     10# $Id: libkbd.c,v 1.2 2004/09/14 14:41:26 pixel Exp $
     11# USB Keyboard Driver for PS2 using RPC instead of FIO
     12*/
     13
     14#include <tamtypes.h>
     15#include <kernel.h>
     16#include <sifrpc.h>
     17#include <string.h>
     18#include "backends/platform/ps2/rpckbd.h"
     19
     20static int curr_readmode = PS2KBD_READMODE_NORMAL;
     21static int kbdRpcSema = -1;
     22static int kbdInitialized = 0;
     23
     24static SifRpcClientData_t cd0;
     25static unsigned char rpcBuf[3 * PS2KBD_KEYMAP_SIZE] __attribute__((aligned (16)));
     26static unsigned int  rpcKey __attribute__((aligned (16)));
     27
     28int PS2KbdInit(void)
     29/* Initialise the keyboard library */
     30{
     31        int res;
     32        ee_sema_t kbdSema;
     33
     34        while ((res = SifBindRpc(&cd0, PS2KBD_RPC_ID, 0)) < 0)
     35                nopdelay();
     36
     37        memset(rpcBuf, 0, 3 * PS2KBD_KEYMAP_SIZE);
     38        rpcKey = 0;
     39
     40        kbdSema.init_count = 1;
     41        kbdSema.max_count = 1;
     42
     43        kbdRpcSema = CreateSema(&kbdSema);
     44        if (kbdRpcSema >= 0) {
     45                kbdInitialized = 1;
     46                return 0;
     47        } else
     48                return -1;
     49}
     50
     51static void rpcCompleteIntr(void *param) {
     52    iSignalSema(kbdRpcSema);
     53}
     54
     55int PS2KbdRead(char *key)
     56/* Reads 1 character from the keyboard */
     57{
     58        int res;
     59        if ((!kbdInitialized) || (curr_readmode != PS2KBD_READMODE_NORMAL))
     60                return -1;
     61       
     62        if (PollSema(kbdRpcSema) >= 0) {
     63                // last rpc call completed
     64                res = (rpcKey != 0);
     65                *key = *(char *)UNCACHED_SEG(&rpcKey);
     66                SifCallRpc(&cd0, KBD_RPC_READKEY, SIF_RPC_M_NOWAIT, rpcBuf, 0, &rpcKey, 4, rpcCompleteIntr, NULL);
     67                return res;
     68        } else // rpc still running
     69                return 0;
     70}
     71
     72int PS2KbdReadRaw(PS2KbdRawKey *key)
     73/* Reads 1 raw character from the keyboard */
     74{
     75        int res;
     76        if ((!kbdInitialized) || (curr_readmode != PS2KBD_READMODE_RAW))
     77                return -1;
     78
     79        if (PollSema(kbdRpcSema) >= 0) {
     80                // last rpc call completed
     81                res = (rpcKey != 0);
     82                *key = *(PS2KbdRawKey *)UNCACHED_SEG(&rpcKey);
     83                SifCallRpc(&cd0, KBD_RPC_READRAW, SIF_RPC_M_NOWAIT, rpcBuf, 0, &rpcKey, 4, rpcCompleteIntr, NULL);
     84                return res;
     85        } else // rpc still running
     86                return 0;
     87}
     88
     89int PS2KbdSetReadmode(u32 readmode)
     90/* Sets the read mode to normal or raw */
     91{
     92        if (kbdInitialized) {
     93                if (curr_readmode == readmode)
     94                        return 0;
     95                WaitSema(kbdRpcSema);
     96                *(unsigned int *)rpcBuf = curr_readmode = readmode;
     97                return SifCallRpc(&cd0, KBD_RPC_SETREADMODE, SIF_RPC_M_NOWAIT, rpcBuf, 4, rpcBuf, 0, rpcCompleteIntr, NULL);
     98        } else
     99                return -1;
     100}
     101
     102int PS2KbdSetLeds(u8 leds)
     103/* Sets all connected keyboards leds */
     104{
     105        if (kbdInitialized) {
     106                WaitSema(kbdRpcSema);
     107                *(unsigned char *)rpcBuf = leds;
     108                return SifCallRpc(&cd0, KBD_RPC_SETLEDS, SIF_RPC_M_NOWAIT, rpcBuf, 4, rpcBuf, 0, rpcCompleteIntr, NULL);
     109        } else
     110                return -1;
     111}
     112
     113int PS2KbdSetKeymap(PS2KbdKeyMap *keymaps)
     114/* Sets the current keymap */
     115{
     116        if (kbdInitialized) {
     117                WaitSema(kbdRpcSema);
     118                memcpy(rpcBuf + 0 * PS2KBD_KEYMAP_SIZE, keymaps->keymap,      PS2KBD_KEYMAP_SIZE);
     119                memcpy(rpcBuf + 1 * PS2KBD_KEYMAP_SIZE, keymaps->shiftkeymap, PS2KBD_KEYMAP_SIZE);
     120                memcpy(rpcBuf + 2 * PS2KBD_KEYMAP_SIZE, keymaps->keycap,      PS2KBD_KEYMAP_SIZE);
     121                return SifCallRpc(&cd0, KBD_RPC_SETKEYMAP, SIF_RPC_M_NOWAIT, rpcBuf, 3 * PS2KBD_KEYMAP_SIZE, rpcBuf, 0, rpcCompleteIntr, NULL);
     122        } else
     123                return -1;
     124}
     125
     126int PS2KbdSetCtrlmap(u8 *ctrlmap)
     127/* Sets the control key mappings */
     128{
     129        if (kbdInitialized) {
     130                WaitSema(kbdRpcSema);
     131                memcpy(rpcBuf, ctrlmap, PS2KBD_KEYMAP_SIZE);
     132                return SifCallRpc(&cd0, KBD_RPC_SETCTRLMAP, SIF_RPC_M_NOWAIT, rpcBuf, PS2KBD_KEYMAP_SIZE, rpcBuf, 0, rpcCompleteIntr, NULL);
     133        } else
     134                return -1;
     135}
     136
     137int PS2KbdSetAltmap(u8 *altmap)
     138/* Sets the alt key mappings */
     139{
     140        if (kbdInitialized) {
     141                WaitSema(kbdRpcSema);
     142                memcpy(rpcBuf, altmap, PS2KBD_KEYMAP_SIZE);
     143                return SifCallRpc(&cd0, KBD_RPC_SETALTMAP, SIF_RPC_M_NOWAIT, rpcBuf, PS2KBD_KEYMAP_SIZE, rpcBuf, 0, rpcCompleteIntr, NULL);
     144        } else
     145                return -1;
     146}
     147
     148int PS2KbdSetSpecialmap(u8 *special)
     149/* Sets the special key mappings */
     150{
     151        if (kbdInitialized) {
     152                WaitSema(kbdRpcSema);
     153                memcpy(rpcBuf, special, PS2KBD_KEYMAP_SIZE);
     154                return SifCallRpc(&cd0, KBD_RPC_SETSPECIALMAP, SIF_RPC_M_NOWAIT, rpcBuf, PS2KBD_KEYMAP_SIZE, rpcBuf, 0, rpcCompleteIntr, NULL);
     155        } else
     156                return -1;
     157}
     158
     159int PS2KbdFlushBuffer(void)
     160/* Flushes the keyboard buffer */
     161{
     162        if (kbdInitialized) {
     163                WaitSema(kbdRpcSema);
     164                return SifCallRpc(&cd0, KBD_RPC_FLUSHBUFFER, SIF_RPC_M_NOWAIT, rpcBuf, 0, rpcBuf, 0, rpcCompleteIntr, NULL);
     165        } else
     166                return -1;
     167}
     168
     169int PS2KbdResetKeymap(void)
     170/* Resets the keymap to the default US mapping */
     171{
     172        if (kbdInitialized) {
     173                WaitSema(kbdRpcSema);
     174                return SifCallRpc(&cd0, KBD_RPC_RESETKEYMAP, SIF_RPC_M_NOWAIT, rpcBuf, 0, rpcBuf, 0, rpcCompleteIntr, NULL);
     175        } else
     176                return -1;
     177}
     178
  • backends/platform/ps2/rpckbd.h

    diff -u -N -r branch-0-11-0/backends/platform/ps2/rpckbd.h branch-0-11-0-ps2/backends/platform/ps2/rpckbd.h
    old new  
     1#ifndef __RPCKBD_H__
     2#define __RPCKBD_H__
     3
     4#include "backends/platform/ps2/iop/rpckbd/include/ps2kbd.h"
     5
     6typedef kbd_rawkey PS2KbdRawKey;
     7typedef kbd_keymap PS2KbdKeyMap;
     8
     9#ifdef __cplusplus
     10extern "C" {
     11#endif
     12        int PS2KbdInit(void);
     13        int PS2KbdRead(char *key);
     14        int PS2KbdReadRaw(PS2KbdRawKey *key);
     15        int PS2KbdSetReadmode(u32 readmode);
     16        int PS2KbdSetLeds(u8 leds);
     17        int PS2KbdSetKeymap(PS2KbdKeyMap *keymaps);
     18        int PS2KbdSetCtrlmap(u8 *ctrlmap);
     19        int PS2KbdSetAltmap(u8 *altmap);
     20        int PS2KbdSetSpecialmap(u8 *special);
     21        int PS2KbdFlushBuffer(void);
     22        int PS2KbdResetKeymap(void);
     23#ifdef __cplusplus
     24}
     25#endif
     26
     27#endif
     28
  • backends/platform/ps2/savefile.cpp

    diff -u -N -r branch-0-11-0/backends/platform/ps2/savefile.cpp branch-0-11-0-ps2/backends/platform/ps2/savefile.cpp
    old new  
    1818 * along with this program; if not, write to the Free Software
    1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    2020 *
    21  * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-11-0/backends/platform/ps2/savefile.cpp $
    22  * $Id: savefile.cpp 30033 2007-12-28 07:39:57Z sev $
     21 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-10-0/backends/platform/ps2/savefile.cpp $
     22 * $Id: savefile.cpp 27024 2007-05-30 21:56:52Z fingolfin $
    2323 *
    2424 */
    2525
     
    3434#include "backends/platform/ps2/savefile.h"
    3535#include "backends/platform/ps2/Gs2dScreen.h"
    3636#include "backends/platform/ps2/systemps2.h"
     37#include "backends/fs/abstract-fs.h"
     38
    3739#include "common/scummsys.h"
    3840
    3941extern void *_gp;
     
    484486        _screen->wantAnim(false);
    485487}
    486488
     489Common::StringList Ps2SaveFileManager::listSavefiles(const char *regex) {
     490        _screen->wantAnim(true);
     491        Common::StringList results;
     492        int mcType, mcFree, mcFormat, mcResult;
     493
     494        printf("listSavefiles -> regex=%s\n", regex);
     495
     496        mcResult = _mc->getInfo(&mcType, &mcFree, &mcFormat);
     497
     498        if ((mcResult == 0) || (mcResult == -1)) {
     499                // there's a memory card in the slot.
     500                if (mcResult == -1)
     501                        _mcNeedsUpdate = true;
     502
     503                mcTable *mcEntries = (mcTable*)memalign(64, sizeof(mcTable) * MAX_MC_ENTRIES);
     504   
     505                char temp[256], mcSearchStr[256], *dir, *ext;
     506                strcpy(temp, regex);
     507                dir = strdup(strtok(temp, "."));
     508                ext = strdup(strtok(NULL, "*"));
     509
     510                printf("dir = %s - ext = %s\n", dir, ext);
     511/*
     512                strcpy(dirStr, refix);
     513                char *pos = strchr(dirStr, '.');
     514                if (pos) {
     515                        strcpy(ext, pos + 1);
     516                        *pos = '\0';
     517                } else
     518                        ext[0] = '\0';
     519*/
     520                sprintf(mcSearchStr, "/ScummVM-%s/%s*", dir, ext);
     521
     522                int numEntries = _mc->getDir(mcSearchStr, 0, MAX_MC_ENTRIES, mcEntries);
     523                char *name;
     524#if 1
     525        for (int i = 0; i < numEntries; i++) {
     526                        name = (char*)mcEntries[i].name;
     527
     528            if ((name[0] != '.') && stricmp(name, "icon.sys")) {
     529                                printf(" name = %s\n", (char*)mcEntries[i].name);
     530                                if (Common::matchString(name, "s*.ucl")) {
     531                                        sprintf(temp, "%s.%s%c%c", dir, ext, name[1], name[2]);
     532                                        results.push_back(temp);
     533                                        printf("  -> match [%s] ;-)\n", temp);
     534                                }
     535                                else {
     536                                        results.push_back(name); // ;-)
     537                                        printf("  -> no match :-(\n");
     538                                }
     539                        }
     540                }
     541#else
     542                results.push_back("dig.s00");
     543                results.push_back("dig.s01");
     544                results.push_back("dig.s03");
     545#endif
     546                free(mcEntries);
     547                free(dir);
     548                free(ext);
     549    }
     550
     551    _screen->wantAnim(false);
     552
     553        return results;
     554}
     555
     556bool Ps2SaveFileManager::removeSavefile(const char *filename) {
     557/*
     558        char buf[256];
     559        sprintf(buf, "%s/%s", getSavePath(), filename);
     560*/
     561        int res = _mc->remove(filename);
     562
     563        if (res == 0)
     564                return true;
     565
     566        return false;
     567}
     568
     569const char *Ps2SaveFileManager::getSavePath(void) const {
     570        return "mc0:";
     571}
     572
    487573bool Ps2SaveFileManager::setupIcon(const char *dest, const char *ico, const char *descr1, const char *descr2) {
    488574        mcIcon icon_sys;
    489575        memset(&icon_sys, 0, sizeof(mcIcon));
  • backends/platform/ps2/savefile.h

    diff -u -N -r branch-0-11-0/backends/platform/ps2/savefile.h branch-0-11-0-ps2/backends/platform/ps2/savefile.h
    old new  
    1818 * along with this program; if not, write to the Free Software
    1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    2020 *
    21  * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-11-0/backends/platform/ps2/savefile.h $
    22  * $Id: savefile.h 30033 2007-12-28 07:39:57Z sev $
     21 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-10-0/backends/platform/ps2/savefile.h $
     22 * $Id: savefile.h 27024 2007-05-30 21:56:52Z fingolfin $
    2323 *
    2424 */
    2525
     
    4242        virtual Common::OutSaveFile *openForSaving(const char *filename);
    4343        virtual void listSavefiles(const char *prefix, bool *marks, int num);
    4444
     45        virtual Common::StringList listSavefiles(const char *regex);
     46        virtual bool removeSavefile(const char *filename);
     47
     48        /** Get the path to the save game directory. */
     49        virtual const char *getSavePath() const;
     50
    4551        void writeSaveNonblocking(char *name, void *buf, uint32 size);
    4652        void saveThread(void);
    4753        void quit(void);
    48        
    4954private:
    5055        bool setupIcon(const char *dest, const char *ico, const char *descr1, const char *descr2);
    5156
  • backends/platform/ps2/sdlkeys.h

    diff -u -N -r branch-0-11-0/backends/platform/ps2/sdlkeys.h branch-0-11-0-ps2/backends/platform/ps2/sdlkeys.h
    old new  
     1/* copied from SDK_keysym.h */
     2
     3#ifndef __SDLKEYS_H__
     4#define __SDLKEYS_H__
     5
     6enum SdlKeyCodes {
     7        SDLK_UNKNOWN            = 0,
     8        SDLK_FIRST              = 0,
     9        SDLK_BACKSPACE          = 8,
     10        SDLK_TAB                = 9,
     11        SDLK_CLEAR              = 12,
     12        SDLK_RETURN             = 13,
     13        SDLK_PAUSE              = 19,
     14        SDLK_ESCAPE             = 27,
     15        SDLK_SPACE              = 32,
     16        SDLK_EXCLAIM            = 33,
     17        SDLK_QUOTEDBL           = 34,
     18        SDLK_HASH               = 35,
     19        SDLK_DOLLAR             = 36,
     20        SDLK_AMPERSAND          = 38,
     21        SDLK_QUOTE              = 39,
     22        SDLK_LEFTPAREN          = 40,
     23        SDLK_RIGHTPAREN         = 41,
     24        SDLK_ASTERISK           = 42,
     25        SDLK_PLUS               = 43,
     26        SDLK_COMMA              = 44,
     27        SDLK_MINUS              = 45,
     28        SDLK_PERIOD             = 46,
     29        SDLK_SLASH              = 47,
     30        SDLK_0                  = 48,
     31        SDLK_1                  = 49,
     32        SDLK_2                  = 50,
     33        SDLK_3                  = 51,
     34        SDLK_4                  = 52,
     35        SDLK_5                  = 53,
     36        SDLK_6                  = 54,
     37        SDLK_7                  = 55,
     38        SDLK_8                  = 56,
     39        SDLK_9                  = 57,
     40        SDLK_COLON              = 58,
     41        SDLK_SEMICOLON          = 59,
     42        SDLK_LESS               = 60,
     43        SDLK_EQUALS             = 61,
     44        SDLK_GREATER            = 62,
     45        SDLK_QUESTION           = 63,
     46        SDLK_AT                 = 64,
     47        /*
     48           Skip uppercase letters
     49         */
     50        SDLK_LEFTBRACKET        = 91,
     51        SDLK_BACKSLASH          = 92,
     52        SDLK_RIGHTBRACKET       = 93,
     53        SDLK_CARET              = 94,
     54        SDLK_UNDERSCORE         = 95,
     55        SDLK_BACKQUOTE          = 96,
     56        SDLK_a                  = 97,
     57        SDLK_b                  = 98,
     58        SDLK_c                  = 99,
     59        SDLK_d                  = 100,
     60        SDLK_e                  = 101,
     61        SDLK_f                  = 102,
     62        SDLK_g                  = 103,
     63        SDLK_h                  = 104,
     64        SDLK_i                  = 105,
     65        SDLK_j                  = 106,
     66        SDLK_k                  = 107,
     67        SDLK_l                  = 108,
     68        SDLK_m                  = 109,
     69        SDLK_n                  = 110,
     70        SDLK_o                  = 111,
     71        SDLK_p                  = 112,
     72        SDLK_q                  = 113,
     73        SDLK_r                  = 114,
     74        SDLK_s                  = 115,
     75        SDLK_t                  = 116,
     76        SDLK_u                  = 117,
     77        SDLK_v                  = 118,
     78        SDLK_w                  = 119,
     79        SDLK_x                  = 120,
     80        SDLK_y                  = 121,
     81        SDLK_z                  = 122,
     82        SDLK_DELETE             = 127,
     83        /* End of ASCII mapped keysyms */
     84
     85        /* International keyboard syms */
     86        SDLK_WORLD_0            = 160,          /* 0xA0 */
     87        SDLK_WORLD_1            = 161,
     88        SDLK_WORLD_2            = 162,
     89        SDLK_WORLD_3            = 163,
     90        SDLK_WORLD_4            = 164,
     91        SDLK_WORLD_5            = 165,
     92        SDLK_WORLD_6            = 166,
     93        SDLK_WORLD_7            = 167,
     94        SDLK_WORLD_8            = 168,
     95        SDLK_WORLD_9            = 169,
     96        SDLK_WORLD_10           = 170,
     97        SDLK_WORLD_11           = 171,
     98        SDLK_WORLD_12           = 172,
     99        SDLK_WORLD_13           = 173,
     100        SDLK_WORLD_14           = 174,
     101        SDLK_WORLD_15           = 175,
     102        SDLK_WORLD_16           = 176,
     103        SDLK_WORLD_17           = 177,
     104        SDLK_WORLD_18           = 178,
     105        SDLK_WORLD_19           = 179,
     106        SDLK_WORLD_20           = 180,
     107        SDLK_WORLD_21           = 181,
     108        SDLK_WORLD_22           = 182,
     109        SDLK_WORLD_23           = 183,
     110        SDLK_WORLD_24           = 184,
     111        SDLK_WORLD_25           = 185,
     112        SDLK_WORLD_26           = 186,
     113        SDLK_WORLD_27           = 187,
     114        SDLK_WORLD_28           = 188,
     115        SDLK_WORLD_29           = 189,
     116        SDLK_WORLD_30           = 190,
     117        SDLK_WORLD_31           = 191,
     118        SDLK_WORLD_32           = 192,
     119        SDLK_WORLD_33           = 193,
     120        SDLK_WORLD_34           = 194,
     121        SDLK_WORLD_35           = 195,
     122        SDLK_WORLD_36           = 196,
     123        SDLK_WORLD_37           = 197,
     124        SDLK_WORLD_38           = 198,
     125        SDLK_WORLD_39           = 199,
     126        SDLK_WORLD_40           = 200,
     127        SDLK_WORLD_41           = 201,
     128        SDLK_WORLD_42           = 202,
     129        SDLK_WORLD_43           = 203,
     130        SDLK_WORLD_44           = 204,
     131        SDLK_WORLD_45           = 205,
     132        SDLK_WORLD_46           = 206,
     133        SDLK_WORLD_47           = 207,
     134        SDLK_WORLD_48           = 208,
     135        SDLK_WORLD_49           = 209,
     136        SDLK_WORLD_50           = 210,
     137        SDLK_WORLD_51           = 211,
     138        SDLK_WORLD_52           = 212,
     139        SDLK_WORLD_53           = 213,
     140        SDLK_WORLD_54           = 214,
     141        SDLK_WORLD_55           = 215,
     142        SDLK_WORLD_56           = 216,
     143        SDLK_WORLD_57           = 217,
     144        SDLK_WORLD_58           = 218,
     145        SDLK_WORLD_59           = 219,
     146        SDLK_WORLD_60           = 220,
     147        SDLK_WORLD_61           = 221,
     148        SDLK_WORLD_62           = 222,
     149        SDLK_WORLD_63           = 223,
     150        SDLK_WORLD_64           = 224,
     151        SDLK_WORLD_65           = 225,
     152        SDLK_WORLD_66           = 226,
     153        SDLK_WORLD_67           = 227,
     154        SDLK_WORLD_68           = 228,
     155        SDLK_WORLD_69           = 229,
     156        SDLK_WORLD_70           = 230,
     157        SDLK_WORLD_71           = 231,
     158        SDLK_WORLD_72           = 232,
     159        SDLK_WORLD_73           = 233,
     160        SDLK_WORLD_74           = 234,
     161        SDLK_WORLD_75           = 235,
     162        SDLK_WORLD_76           = 236,
     163        SDLK_WORLD_77           = 237,
     164        SDLK_WORLD_78           = 238,
     165        SDLK_WORLD_79           = 239,
     166        SDLK_WORLD_80           = 240,
     167        SDLK_WORLD_81           = 241,
     168        SDLK_WORLD_82           = 242,
     169        SDLK_WORLD_83           = 243,
     170        SDLK_WORLD_84           = 244,
     171        SDLK_WORLD_85           = 245,
     172        SDLK_WORLD_86           = 246,
     173        SDLK_WORLD_87           = 247,
     174        SDLK_WORLD_88           = 248,
     175        SDLK_WORLD_89           = 249,
     176        SDLK_WORLD_90           = 250,
     177        SDLK_WORLD_91           = 251,
     178        SDLK_WORLD_92           = 252,
     179        SDLK_WORLD_93           = 253,
     180        SDLK_WORLD_94           = 254,
     181        SDLK_WORLD_95           = 255,          /* 0xFF */
     182
     183        /* Numeric keypad */
     184        SDLK_KP0                = 256,
     185        SDLK_KP1                = 257,
     186        SDLK_KP2                = 258,
     187        SDLK_KP3                = 259,
     188        SDLK_KP4                = 260,
     189        SDLK_KP5                = 261,
     190        SDLK_KP6                = 262,
     191        SDLK_KP7                = 263,
     192        SDLK_KP8                = 264,
     193        SDLK_KP9                = 265,
     194        SDLK_KP_PERIOD          = 266,
     195        SDLK_KP_DIVIDE          = 267,
     196        SDLK_KP_MULTIPLY        = 268,
     197        SDLK_KP_MINUS           = 269,
     198        SDLK_KP_PLUS            = 270,
     199        SDLK_KP_ENTER           = 271,
     200        SDLK_KP_EQUALS          = 272,
     201
     202        /* Arrows + Home/End pad */
     203        SDLK_UP                 = 273,
     204        SDLK_DOWN               = 274,
     205        SDLK_RIGHT              = 275,
     206        SDLK_LEFT               = 276,
     207        SDLK_INSERT             = 277,
     208        SDLK_HOME               = 278,
     209        SDLK_END                = 279,
     210        SDLK_PAGEUP             = 280,
     211        SDLK_PAGEDOWN           = 281,
     212
     213        /* Function keys */
     214        SDLK_F1                 = 282,
     215        SDLK_F2                 = 283,
     216        SDLK_F3                 = 284,
     217        SDLK_F4                 = 285,
     218        SDLK_F5                 = 286,
     219        SDLK_F6                 = 287,
     220        SDLK_F7                 = 288,
     221        SDLK_F8                 = 289,
     222        SDLK_F9                 = 290,
     223        SDLK_F10                = 291,
     224        SDLK_F11                = 292,
     225        SDLK_F12                = 293,
     226        SDLK_F13                = 294,
     227        SDLK_F14                = 295,
     228        SDLK_F15                = 296,
     229
     230        /* Key state modifier keys */
     231        SDLK_NUMLOCK            = 300,
     232        SDLK_CAPSLOCK           = 301,
     233        SDLK_SCROLLOCK          = 302,
     234        SDLK_RSHIFT             = 303,
     235        SDLK_LSHIFT             = 304,
     236        SDLK_RCTRL              = 305,
     237        SDLK_LCTRL              = 306,
     238        SDLK_RALT               = 307,
     239        SDLK_LALT               = 308,
     240        SDLK_RMETA              = 309,
     241        SDLK_LMETA              = 310,
     242        SDLK_LSUPER             = 311,          /* Left "Windows" key */
     243        SDLK_RSUPER             = 312,          /* Right "Windows" key */
     244        SDLK_MODE               = 313,          /* "Alt Gr" key */
     245        SDLK_COMPOSE            = 314,          /* Multi-key compose key */
     246
     247        /* Miscellaneous function keys */
     248        SDLK_HELP               = 315,
     249        SDLK_PRINT              = 316,
     250        SDLK_SYSREQ             = 317,
     251        SDLK_BREAK              = 318,
     252        SDLK_MENU               = 319,
     253        SDLK_POWER              = 320,          /* Power Macintosh power key */
     254        SDLK_EURO               = 321,          /* Some european keyboards */
     255        SDLK_UNDO               = 322,          /* Atari keyboard has Undo */
     256
     257        /* Add any other keys here */
     258
     259        SDLK_LAST
     260};
     261
     262#endif
     263
     264
  • backends/platform/ps2/sysdefs.h

    diff -u -N -r branch-0-11-0/backends/platform/ps2/sysdefs.h branch-0-11-0-ps2/backends/platform/ps2/sysdefs.h
    old new  
    1818 * along with this program; if not, write to the Free Software
    1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    2020 *
    21  * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-11-0/backends/platform/ps2/sysdefs.h $
     21 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-10-0/backends/platform/ps2/sysdefs.h $
    2222 * $Id: sysdefs.h 27024 2007-05-30 21:56:52Z fingolfin $
    2323 *
    2424 */
  • backends/platform/ps2/systemps2.cpp

    diff -u -N -r branch-0-11-0/backends/platform/ps2/systemps2.cpp branch-0-11-0-ps2/backends/platform/ps2/systemps2.cpp
    old new  
    1818 * along with this program; if not, write to the Free Software
    1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    2020 *
    21  * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-11-0/backends/platform/ps2/systemps2.cpp $
    22  * $Id: systemps2.cpp 28966 2007-09-19 08:40:12Z peres001 $
     21 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-10-0/backends/platform/ps2/systemps2.cpp $
     22 * $Id: systemps2.cpp 27024 2007-05-30 21:56:52Z fingolfin $
    2323 *
    2424 */
    2525
     
    3434#include <iopcontrol.h>
    3535#include <iopheap.h>
    3636#include "common/scummsys.h"
    37 #include "../intern.h"
     37#include "backends/intern.h"
    3838#include "engines/engine.h"
    3939#include "backends/platform/ps2/systemps2.h"
    4040#include "backends/platform/ps2/Gs2dScreen.h"
     
    4545#include "backends/platform/ps2/savefile.h"
    4646#include "common/file.h"
    4747#include "backends/platform/ps2/sysdefs.h"
     48#include "backends/platform/ps2/fileio.h"
    4849#include <libmc.h>
    4950#include <libpad.h>
    5051#include "backends/platform/ps2/cd.h"
     
    5455#include "eecodyvdfs.h"
    5556#include "graphics/surface.h"
    5657#include "graphics/font.h"
     58#include "backends/timer/default/default-timer.h"
     59#include "sound/mixer.h"
     60#include "common/events.h"
    5761
    5862// asm("mfc0    %0, $9\n" : "=r"(tickStart));
    5963
     
    118122        sioprintf("Creating system");
    119123        g_system = g_systemPs2 = new OSystem_PS2(argv[0]);
    120124
     125        g_systemPs2->init();
     126
    121127        sioprintf("init done. starting ScummVM.");
    122         return scummvm_main(argc, argv);
     128        int res = scummvm_main(argc, argv);
     129        sioprintf("scummvm_main terminated: %d", res);
     130
     131        g_systemPs2->quit();
     132
     133        // control never gets here
     134        return res;
    123135}
    124136
    125137s32 timerInterruptHandler(s32 cause) {
     
    216228                                }
    217229                        }
    218230                       
    219                         if (modules[i].buffer);
     231                        if (modules[i].buffer)
    220232                                free(modules[i].buffer);
    221233                } else {
    222234                        sioprintf("module %d of %d damaged, loc %d, path %s", i, numModules, modules[i].loc, modules[i].path);
     
    233245
    234246OSystem_PS2::OSystem_PS2(const char *elfPath) {
    235247        _soundStack = _timerStack = NULL;
    236         _scummTimerProc = NULL;
    237         _scummSoundProc = NULL;
    238         _scummSoundParam = NULL;
    239248        _printY = 0;
    240249        _msgClearTime = 0;
    241250        _systemQuit = false;
     
    244253        _screen = new Gs2dScreen(320, 200, TV_DONT_CARE);
    245254
    246255        sioprintf("Initializing system...");
    247         initTimer();
    248256
    249257        _screen->wantAnim(true);
    250258
     
    287295                quit();
    288296        }
    289297
     298        // _useHdd = false; // romeo
     299
    290300        if (_useHdd) {
    291301                if ((hddCheckPresent() < 0) || (hddCheckFormatted() < 0))
    292302                        _useHdd = false;
    293303
    294                 hddPreparePoweroff();
    295                 hddSetUserPoweroffCallback(gluePowerOffCallback, this);
     304                printf("romeo : hddCheckPresent done : %d\n", _useHdd);
     305
     306                // hddPreparePoweroff();
     307                // poweroffInit();
     308                printf("romeo : hddPreparePoweroff done\n");     
     309
     310                // hddSetUserPoweroffCallback(gluePowerOffCallback, this);
     311                // poweroffSetCallback(gluePowerOffCallback, this);
     312                printf("romeo : hddSetUserPoweroffCallback done\n");
    296313        }
    297314
    298315        fileXioSetBlockMode(FXIO_NOWAIT);
     
    303320        readRtcTime();
    304321
    305322        if (_useHdd) {
     323                printf("romeo : trying to mount...\n");
    306324                if (fio.mount("pfs0:", "hdd0:+ScummVM", 0) >= 0)
    307325                        printf("Successfully mounted!\n");
    308326                else
    309327                        _useHdd = false;
    310328        }
    311329
     330        initMutexes();
     331
     332        /*sioprintf("Timer...");
     333        _scummTimerManager = new DefaultTimerManager();
     334        _scummMixer = new Audio::Mixer();
     335        initTimer();
     336
    312337        sioprintf("Starting SavefileManager");
    313338        _saveManager = new Ps2SaveFileManager(this, _screen);
    314339
    315340        sioprintf("Initializing ps2Input");
    316341        _input = new Ps2Input(this, _useMouse, _useKbd);
    317342
    318         ee_sema_t newSema;
    319         newSema.init_count = 1;
    320         newSema.max_count = 1;
    321         _mutexSema = CreateSema(&newSema);
    322         for (int i = 0; i < MAX_MUTEXES; i++) {
    323                 _mutex[i].sema = -1;
    324                 _mutex[i].count = _mutex[i].owner = 0;
    325         }
    326 
    327343        _screen->wantAnim(false);
    328         clearScreen();
     344        _screen->clearScreen();*/
    329345}
    330346
    331 OSystem_PS2::~OSystem_PS2(void) {
    332 }
     347void OSystem_PS2::init(void) {
     348        sioprintf("Timer...");
     349        _scummTimerManager = new DefaultTimerManager();
     350        _scummMixer = new Audio::Mixer();
     351        initTimer();
     352
     353        sioprintf("Starting SavefileManager");
     354        _saveManager = new Ps2SaveFileManager(this, _screen);
     355
     356        sioprintf("Initializing ps2Input");
     357        _input = new Ps2Input(this, _useMouse, _useKbd);
     358
     359        _screen->wantAnim(false);
     360        _screen->clearScreen();
    333361
    334 void OSystem_PS2::initBackend() {
    335         // FIXME: Should probably move lots of stuff from the constructor to here
    336         _mixer = new Audio::Mixer();
    337         _timer = new DefaultTimerManager();
    338         setSoundCallback(Audio::Mixer::mixCallback, _mixer);
    339         setTimerCallback(&timer_handler, 10);
     362        // OSystem::initBackend(); // romeo
     363}
    340364
    341         OSystem::initBackend();
     365OSystem_PS2::~OSystem_PS2(void) {
    342366}
    343367
    344368void OSystem_PS2::initTimer(void) {
     
    404428void OSystem_PS2::timerThread(void) {
    405429        while (!_systemQuit) {
    406430                WaitSema(g_TimerThreadSema);
    407                 if (_scummTimerProc)
    408                         _scummTimerProc(0);
     431                _scummTimerManager->handler();
    409432        }
    410433        ExitThread();
    411434}
    412435
    413436void OSystem_PS2::soundThread(void) {
    414         ee_sema_t soundSema;
    415         soundSema.init_count = 1;
    416         soundSema.max_count = 1;
    417         _soundSema = CreateSema(&soundSema);
    418         assert(_soundSema >= 0);
    419437        int16 *soundBufL = (int16*)memalign(64, SMP_PER_BLOCK * sizeof(int16) * 2);
    420438        int16 *soundBufR = soundBufL + SMP_PER_BLOCK;
    421439
     
    431449                        bufferedSamples -= 480;
    432450                cycles++;
    433451
    434                 WaitSema(_soundSema);
    435                 if (_scummSoundProc) {
    436                         if (bufferedSamples <= 8 * SMP_PER_BLOCK) {
    437                                 // we have to produce more samples, call sound mixer
    438                                 // the scratchpad at 0x70000000 is used as temporary soundbuffer
    439                                 _scummSoundProc(_scummSoundParam, (uint8*)0x70000000, SMP_PER_BLOCK * 2 * sizeof(int16));
    440 
    441                                 // demux data into 2 buffers, L and R
    442                                  __asm__ (
    443                                         "move  $t2, %1\n\t"                     // dest buffer right
    444                                         "move  $t3, %0\n\t"                     // dest buffer left
    445                                         "lui   $t8, 0x7000\n\t"         // muxed buffer, fixed at 0x70000000
    446                                         "addiu $t9, $0, 100\n\t"        // number of loops
    447                                         "mtsab $0, 2\n\t"                       // set qword shift = 2 byte
    448 
    449                                         "loop:\n\t"
    450                                         "  lq $t4,  0($t8)\n\t"         // load 8 muxed samples
    451                                         "  lq $t5, 16($t8)\n\t"         // load 8 more muxed samples
    452 
    453                                         "  qfsrv $t6, $0, $t4\n\t"      // shift right for second
    454                                         "  qfsrv $t7, $0, $t5\n\t"      // packing step (right channel)
    455 
    456                                         "  ppach $t4, $t5, $t4\n\t"     // combine left channel data
    457                                         "  ppach $t6, $t7, $t6\n\t"     // right channel data
    458 
    459                                         "  sq $t4, 0($t3)\n\t"          // write back
    460                                         "  sq $t6, 0($t2)\n\t"          //
    461 
    462                                         "  addiu $t9, -1\n\t"           // decrement loop counter
    463                                         "  addiu $t2, 16\n\t"           // increment pointers
    464                                         "  addiu $t3, 16\n\t"
    465                                         "  addiu $t8, 32\n\t"
    466                                         "  bnez  $t9, loop\n\t"         // loop
    467                                                 :  // outputs
    468                                                 : "r"(soundBufL), "r"(soundBufR)  // inputs
    469                                         //  : "$t2", "$t3", "$t4", "$t5", "$t6", "$t7", "$t8", "$t9"  // destroyed
    470                                                 : "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25"  // destroyed
    471                                 );
    472                                 // and feed it into the SPU
    473                                 // non-blocking call, the function will return before the buffer's content
    474                                 // was transferred.
    475                                 SjPCM_Enqueue((short int*)soundBufL, (short int*)soundBufR, SMP_PER_BLOCK, 0);
    476                                 bufferedSamples += SMP_PER_BLOCK;
    477                         }
    478                 }
    479                 SignalSema(_soundSema);
     452                if (bufferedSamples <= 8 * SMP_PER_BLOCK) {
     453                        // we have to produce more samples, call sound mixer
     454                        // the scratchpad at 0x70000000 is used as temporary soundbuffer
     455                        //_scummSoundProc(_scummSoundParam, (uint8*)0x70000000, SMP_PER_BLOCK * 2 * sizeof(int16));
     456                        Audio::Mixer::mixCallback(_scummMixer, (byte*)0x70000000, SMP_PER_BLOCK * 2 * sizeof(int16));
     457
     458                        // demux data into 2 buffers, L and R
     459                         __asm__ (
     460                                "move  $t2, %1\n\t"                     // dest buffer right
     461                                "move  $t3, %0\n\t"                     // dest buffer left
     462                                "lui   $t8, 0x7000\n\t"         // muxed buffer, fixed at 0x70000000
     463                                "addiu $t9, $0, 100\n\t"        // number of loops
     464                                "mtsab $0, 2\n\t"                       // set qword shift = 2 byte
     465
     466                                "loop:\n\t"
     467                                "  lq $t4,  0($t8)\n\t"         // load 8 muxed samples
     468                                "  lq $t5, 16($t8)\n\t"         // load 8 more muxed samples
     469
     470                                "  qfsrv $t6, $0, $t4\n\t"      // shift right for second
     471                                "  qfsrv $t7, $0, $t5\n\t"      // packing step (right channel)
     472
     473                                "  ppach $t4, $t5, $t4\n\t"     // combine left channel data
     474                                "  ppach $t6, $t7, $t6\n\t"     // right channel data
     475
     476                                "  sq $t4, 0($t3)\n\t"          // write back
     477                                "  sq $t6, 0($t2)\n\t"          //
     478
     479                                "  addiu $t9, -1\n\t"           // decrement loop counter
     480                                "  addiu $t2, 16\n\t"           // increment pointers
     481                                "  addiu $t3, 16\n\t"
     482                                "  addiu $t8, 32\n\t"
     483                                "  bnez  $t9, loop\n\t"         // loop
     484                                        :  // outputs
     485                                        : "r"(soundBufL), "r"(soundBufR)  // inputs
     486                                //  : "$t2", "$t3", "$t4", "$t5", "$t6", "$t7", "$t8", "$t9"  // destroyed
     487                                        : "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25"  // destroyed
     488                        );
     489                        // and feed it into the SPU
     490                        // non-blocking call, the function will return before the buffer's content
     491                        // was transferred.
     492                        SjPCM_Enqueue((short int*)soundBufL, (short int*)soundBufR, SMP_PER_BLOCK, 0);
     493                        bufferedSamples += SMP_PER_BLOCK;
     494                }
    480495        }
    481496        free(soundBufL);
    482         DeleteSema(_soundSema);
    483497        ExitThread();
    484498}
    485499
     
    488502}
    489503
    490504void OSystem_PS2::setUsbMassConnected(bool stat) {
     505        printf("_usbMassConnected = %d\n", stat); // romeo
    491506        _usbMassConnected = stat;
    492507}
    493508
    494509bool OSystem_PS2::usbMassPresent(void) {
    495         return _usbMassConnected;
     510        return true; // _usbMassConnected; // romeo
     511        // TODO : we should check on start if there is already a USB
     512        //        trying an open on "mass:"
    496513}
    497514
    498515void OSystem_PS2::initSize(uint width, uint height) {
     
    519536        _screen->copyScreenRect((const uint8*)buf, pitch, x, y, w, h);
    520537}
    521538
    522 Graphics::Surface *OSystem_PS2::lockScreen() {
    523         return _screen->lockScreen();
    524 }
    525 
    526 void OSystem_PS2::unlockScreen() {
    527         _screen->unlockScreen();
     539bool OSystem_PS2::grabRawScreen(Graphics::Surface *surf) {
     540        _screen->grabScreen(surf);
     541        return true;
    528542}
    529543
    530544void OSystem_PS2::updateScreen(void) {
     
    558572        }
    559573}
    560574
    561 void OSystem_PS2::setTimerCallback(OSystem::TimerProc callback, int interval) {
    562         if (callback && (interval != 10))
    563                 sioprintf("unhandled timer interval: %d\n", interval);
    564         _scummTimerProc = callback;
     575Common::TimerManager *OSystem_PS2::getTimerManager() {
     576        return _scummTimerManager;
    565577}
    566578
    567579int OSystem_PS2::getOutputSampleRate(void) const {
    568580        return 48000;
    569581}
    570582
    571 bool OSystem_PS2::setSoundCallback(SoundProc proc, void *param) {
    572         assert(proc != NULL);
    573 
    574         WaitSema(_soundSema);
    575     _scummSoundProc = proc;
    576         _scummSoundParam = param;
    577         SignalSema(_soundSema);
    578         return true;
    579 }
    580 
    581 void OSystem_PS2::clearSoundCallback(void) {
    582         WaitSema(_soundSema);
    583         _scummSoundProc = NULL;
    584         _scummSoundParam = NULL;
    585         SignalSema(_soundSema);
     583Audio::Mixer *OSystem_PS2::getMixer() {
     584        return _scummMixer;
    586585}
    587586
    588587Common::SaveFileManager *OSystem_PS2::getSavefileManager(void) {
     
    646645        _screen->copyOverlayRect((uint16*)buf, (uint16)pitch, (uint16)x, (uint16)y, (uint16)w, (uint16)h);
    647646}
    648647
     648Graphics::Surface *OSystem_PS2::lockScreen() {
     649        return _screen->lockScreen();
     650}
     651
     652void OSystem_PS2::unlockScreen() {
     653        _screen->unlockScreen();
     654}
     655
    649656const OSystem::GraphicsMode OSystem_PS2::_graphicsMode = { NULL, NULL, 0 };
    650657
    651658const OSystem::GraphicsMode *OSystem_PS2::getSupportedGraphicsModes(void) const {
     
    752759}
    753760
    754761void OSystem_PS2::quit(void) {
     762        sioprintf("OSystem_PS2::quit called");
    755763        if (_bootDevice == HOST) {
    756                 printf("OSystem_PS2::quit\n");
     764                sioprintf("OSystem_PS2::quit (HOST)\n");
    757765                SleepThread();
    758766        } else {
    759                 sioprintf("OSystem_PS2::quit");
     767                sioprintf("OSystem_PS2::quit (bootdev=%d)", _bootDevice);
    760768                if (_useHdd) {
    761769                        driveStandby();
    762770                        fio.umount("pfs0:");
    763771                }
    764                 clearSoundCallback();
    765                 setTimerCallback(NULL, 0);
     772                //clearSoundCallback();
     773                //setTimerCallback(NULL, 0);
    766774                _screen->wantAnim(false);
    767775                _systemQuit = true;
    768776                ee_thread_t statSound, statTimer;
     777                sioprintf("Waiting for timer and sound thread to end");
    769778                do {    // wait until both threads called ExitThread()
    770779                        ReferThreadStatus(_timerTid, &statTimer);
    771780                        ReferThreadStatus(_soundTid, &statSound);
    772781                } while ((statSound.status != 0x10) || (statTimer.status != 0x10));
     782                sioprintf("Done");
    773783                DeleteThread(_timerTid);
    774784                DeleteThread(_soundTid);
    775785                free(_timerStack);
    776786                free(_soundStack);
     787                sioprintf("Stopping timer");
    777788                DisableIntc(INT_TIMER0);
    778789                RemoveIntcHandler(INT_TIMER0, _intrId);
    779790
  • backends/platform/ps2/systemps2.h

    diff -u -N -r branch-0-11-0/backends/platform/ps2/systemps2.h branch-0-11-0-ps2/backends/platform/ps2/systemps2.h
    old new  
    1818 * along with this program; if not, write to the Free Software
    1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    2020 *
    21  * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-11-0/backends/platform/ps2/systemps2.h $
    22  * $Id: systemps2.h 28966 2007-09-19 08:40:12Z peres001 $
     21 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/branch-0-10-0/backends/platform/ps2/systemps2.h $
     22 * $Id: systemps2.h 27024 2007-05-30 21:56:52Z fingolfin $
    2323 *
    2424 */
    2525
     
    2828
    2929#include "common/system.h"
    3030
     31class DefaultTimerManager;
     32
    3133class Gs2dScreen;
    3234class Ps2Input;
    3335class Ps2SaveFileManager;
     
    4345        int count;
    4446};
    4547
     48namespace Common {
     49        class TimerManager;
     50};
     51
     52namespace Audio {
     53        class Mixer;
     54};
     55
    4656class OSystem_PS2 : public OSystem {
    4757public:
    4858        OSystem_PS2(const char *elfPath);
    4959        virtual ~OSystem_PS2(void);
    50 
    51         virtual void initBackend();
    52 
    5360        virtual void initSize(uint width, uint height);
    5461
     62        void init(void);
     63
    5564        virtual int16 getHeight(void);
    5665        virtual int16 getWidth(void);
    5766        virtual void setPalette(const byte *colors, uint start, uint num);
    5867        virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
    5968        virtual void setShakePos(int shakeOffset);
    6069        virtual void grabPalette(byte *colors, uint start, uint num);
     70        virtual bool grabRawScreen(Graphics::Surface *surf);
    6171        virtual Graphics::Surface *lockScreen();
    6272        virtual void unlockScreen();
    6373        virtual void updateScreen();
     
    7585
    7686        virtual uint32 getMillis();
    7787        virtual void delayMillis(uint msecs);
    78         virtual void setTimerCallback(TimerProc callback, int interval);
     88        virtual Common::TimerManager *getTimerManager();
    7989        virtual bool pollEvent(Common::Event &event);
    8090
    81         virtual bool setSoundCallback(SoundProc proc, void *param);
    82         virtual void clearSoundCallback();
     91        virtual Audio::Mixer *getMixer();
    8392        virtual int  getOutputSampleRate(void) const;
    8493
    8594        virtual bool openCD(int drive);
     
    105114        virtual void colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b);
    106115
    107116        virtual Common::SaveFileManager *getSavefileManager();
    108         virtual Audio::Mixer *getMixer() { return _mixer; }
    109         virtual Common::TimerManager *getTimerManager() { return _timer; }
    110117
    111118        void timerThread(void);
    112119        void soundThread(void);
     
    121128private:
    122129        void startIrxModules(int numModules, IrxReference *modules);
    123130
    124         volatile OSystem::TimerProc _scummTimerProc;
    125         volatile OSystem::SoundProc _scummSoundProc;
    126         void *_scummSoundParam;
    127         int _soundSema;
    128 
     131        void initMutexes(void);
    129132        void initTimer(void);
    130133        void readRtcTime(void);
    131134
     135        DefaultTimerManager *_scummTimerManager;
     136        Audio::Mixer *_scummMixer;
     137
     138
    132139        bool _mouseVisible;
    133140        bool _useMouse, _useKbd, _useHdd, _usbMassLoaded, _usbMassConnected;
    134141
    135142        Ps2SaveFileManager *_saveManager;
    136         Audio::Mixer *_mixer;
    137         Common::TimerManager *_timer;
    138143
    139144        Gs2dScreen      *_screen;
    140145        Ps2Input        *_input;
  • engines/kyra/resource.cpp

    diff -u -N -r branch-0-11-0/engines/kyra/resource.cpp branch-0-11-0-ps2/engines/kyra/resource.cpp
    old new  
    331331///////////////////////////////////////////
    332332// Pak file manager
    333333PAKFile::PAKFile(const char *file, const char *physfile, Common::File &pakfile, bool isAmiga) : ResourceFile() {
    334         _open = false;
     334        _mopen = false;
    335335
    336336        if (!pakfile.isOpen()) {
    337337                debug(3, "couldn't open pakfile '%s'\n", file);
     
    407407                pos += nameLength + 4;
    408408        }
    409409
    410         _open = true;
     410        _mopen = true;
    411411        _filename = Common::hashit_lower(file);
    412412        _physfile = physfile;
    413413        _physOffset = off;
     
    416416
    417417PAKFile::~PAKFile() {
    418418        _physfile.clear();
    419         _open = false;
     419        _mopen = false;
    420420
    421421        _files.clear();
    422422}
     
    470470// Ins file manager
    471471INSFile::INSFile(const char *file) : ResourceFile(), _files() {
    472472        Common::File pakfile;
    473         _open = false;
     473        _mopen = false;
    474474
    475475        if (!pakfile.open(file)) {
    476476                debug(3, "couldn't open insfile '%s'\n", file);
     
    521521
    522522        _filename = Common::hashit_lower(file);
    523523        _physfile = file;
    524         _open = true;
     524        _mopen = true;
    525525}
    526526
    527527INSFile::~INSFile() {
    528         _open = false;
     528        _mopen = false;
    529529
    530530        _files.clear();
    531531}
  • engines/kyra/resource.h

    diff -u -N -r branch-0-11-0/engines/kyra/resource.h branch-0-11-0-ps2/engines/kyra/resource.h
    old new  
    3838
    3939class ResourceFile {
    4040public:
    41         ResourceFile() : _open(false), _protected(false), _filename() {}
     41        ResourceFile() : _mopen(false), _protected(false), _filename() {}
    4242        virtual ~ResourceFile() {}
    4343
    4444        virtual uint8 *getFile(uint file) const = 0;
     
    4848        uint filename() const { return _filename; }
    4949
    5050        virtual bool isValid(void) const { return (_filename != 0); }
    51         bool isOpen(void) const { return _open; }
     51        bool isOpen(void) const { return _mopen; }
    5252
    53         virtual void close() { if (!_protected) _open = false; }
     53        virtual void close() { if (!_protected) _mopen = false; }
    5454        virtual void protect(const bool prot = true) { _protected = prot; }
    55         virtual void open() { _open = true; }
     55        virtual void open() { _mopen = true; }
    5656protected:
    57         bool _open;
     57        bool _mopen;
    5858        bool _protected;
    5959        uint _filename;
    6060};