rm plugins that we won't use
authornotaz <notasas@gmail.com>
Thu, 18 Nov 2010 12:47:57 +0000 (14:47 +0200)
committernotaz <notasas@gmail.com>
Thu, 18 Nov 2010 12:47:57 +0000 (14:47 +0200)
48 files changed:
plugins/dfcdrom/cdr-libcdio.c [deleted file]
plugins/dfcdrom/cdr-linux.c [deleted file]
plugins/dfcdrom/cdr-null.c [deleted file]
plugins/dfcdrom/cdr.c [deleted file]
plugins/dfcdrom/cdr.h [deleted file]
plugins/dfcdrom/cdrcfg-0.1df/main.c [deleted file]
plugins/dfcdrom/cfg.c [deleted file]
plugins/dfcdrom/util.c [deleted file]
plugins/dfinput/analog.c [deleted file]
plugins/dfinput/cfg-gtk2.c [deleted file]
plugins/dfinput/cfg.c [deleted file]
plugins/dfinput/pad.c [deleted file]
plugins/dfinput/pad.h [deleted file]
plugins/dfinput/sdljoy.c [deleted file]
plugins/dfinput/xkb.c [deleted file]
plugins/dfnet/cfg.c [deleted file]
plugins/dfnet/dfnet.c [deleted file]
plugins/dfnet/dfnet.h [deleted file]
plugins/dfnet/gui.c [deleted file]
plugins/dfnet/unix.c [deleted file]
plugins/peopsxgl/cfg.c [deleted file]
plugins/peopsxgl/cfg.h [deleted file]
plugins/peopsxgl/draw.c [deleted file]
plugins/peopsxgl/draw.h [deleted file]
plugins/peopsxgl/externals.h [deleted file]
plugins/peopsxgl/fps.c [deleted file]
plugins/peopsxgl/fps.h [deleted file]
plugins/peopsxgl/gl_ext.h [deleted file]
plugins/peopsxgl/gpu.c [deleted file]
plugins/peopsxgl/gpu.h [deleted file]
plugins/peopsxgl/gpucfg/callbacks.c [deleted file]
plugins/peopsxgl/gpucfg/callbacks.h [deleted file]
plugins/peopsxgl/gpucfg/interface.c [deleted file]
plugins/peopsxgl/gpucfg/interface.h [deleted file]
plugins/peopsxgl/gpucfg/main.c [deleted file]
plugins/peopsxgl/gpucfg/support.c [deleted file]
plugins/peopsxgl/gpucfg/support.h [deleted file]
plugins/peopsxgl/key.c [deleted file]
plugins/peopsxgl/key.h [deleted file]
plugins/peopsxgl/menu.c [deleted file]
plugins/peopsxgl/menu.h [deleted file]
plugins/peopsxgl/prim.c [deleted file]
plugins/peopsxgl/prim.h [deleted file]
plugins/peopsxgl/soft.c [deleted file]
plugins/peopsxgl/soft.h [deleted file]
plugins/peopsxgl/stdafx.h [deleted file]
plugins/peopsxgl/texture.c [deleted file]
plugins/peopsxgl/texture.h [deleted file]

diff --git a/plugins/dfcdrom/cdr-libcdio.c b/plugins/dfcdrom/cdr-libcdio.c
deleted file mode 100644 (file)
index 738d203..0000000
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * Copyright (c) 2010, Wei Mingzhi <whistler@openoffice.org>.
- * All Rights Reserved.
- *
- * Based on: Cdrom for Psemu Pro like Emulators
- * By: linuzappz <linuzappz@hotmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses>.
- */
-
-#ifdef USE_LIBCDIO
-
-#include <cdio/cdio.h>
-#include <cdio/mmc.h>
-
-#include "cdr.h"
-
-static CdIo_t *cdHandle = NULL;
-
-static void SetSpeed(int speed) {
-       speed *= 176;
-       if (speed == 0) speed = 0xFFFF;
-
-       cdio_set_speed(cdHandle, speed);
-}
-
-static void SetSpinDown(unsigned char spindown) {
-       mmc_cdb_t               cdb;
-       char                    buf[16];
-
-       memset(&cdb, 0, sizeof(cdb));
-
-       cdb.field[0] = 0x5A;
-       cdb.field[2] = 0x0D;
-       cdb.field[8] = sizeof(buf);
-
-       if (mmc_run_cmd(cdHandle, 10000, &cdb, SCSI_MMC_DATA_READ, sizeof(buf), buf) != DRIVER_OP_SUCCESS)
-               return;
-
-       buf[11] = (buf[11] & 0xF0) | (spindown & 0x0F);
-
-       memset(&cdb, 0, sizeof(cdb));
-       memset(buf, 0, 2);
-
-       cdb.field[0] = 0x55;
-       cdb.field[1] = 0x10;
-       cdb.field[8] = sizeof(buf);
-
-       mmc_run_cmd(cdHandle, 10000, &cdb, SCSI_MMC_DATA_WRITE, sizeof(buf), buf);
-}
-
-static void UnlockDoor() {
-       mmc_cdb_t          cdb;
-
-       memset(&cdb, 0, sizeof(cdb));
-
-       cdb.field[0] = 0x1E;
-       cdb.field[4] = 0;
-
-       mmc_run_cmd(cdHandle, 10000, &cdb, SCSI_MMC_DATA_WRITE, 0, NULL);
-}
-
-int OpenCdHandle(const char *dev) {
-       if (dev == NULL || dev[0] == '\0') {
-               if ((dev = cdio_get_default_device(NULL)) == NULL) {
-                       return -1;
-               }
-       }
-
-#ifdef __FreeBSD__
-       cdHandle = cdio_open_am_cd(dev, "CAM");
-#else
-       cdHandle = cdio_open_cd(dev);
-#endif
-
-       if (cdHandle != NULL) {
-               SetSpeed(CdrSpeed);
-               SetSpinDown(SpinDown);
-               UnlockDoor();
-
-               return 0;
-       }
-
-       return -1;
-}
-
-void CloseCdHandle() {
-       if (cdHandle != NULL) {
-               cdio_set_speed(cdHandle, 0xFFFF);
-               SetSpinDown(SPINDOWN_VENDOR_SPECIFIC);
-
-               cdio_destroy(cdHandle);
-       }
-
-       cdHandle = NULL;
-}
-
-int IsCdHandleOpen() {
-       return (cdHandle != NULL);
-}
-
-long GetTN(unsigned char *buffer) {
-       buffer[0] = cdio_get_first_track_num(cdHandle);
-       buffer[1] = cdio_get_last_track_num(cdHandle);
-
-       return 0;
-}
-
-long GetTD(unsigned char track, unsigned char *buffer) {
-       msf_t msf;
-
-       if (track == 0) track = CDIO_CDROM_LEADOUT_TRACK;
-
-       if (!cdio_get_track_msf(cdHandle, track, &msf)) {
-               memset(buffer + 1, 0, 3);
-               return 0;
-       }
-
-       buffer[0] = btoi(msf.f);
-       buffer[1] = btoi(msf.s);
-       buffer[2] = btoi(msf.m);
-
-       return 0;
-}
-
-long GetTE(unsigned char track, unsigned char *m, unsigned char *s, unsigned char *f) {
-       unsigned char msf[3];
-
-       lba_to_msf(cdio_get_track_lba(cdHandle, track + 1) - CD_MSF_OFFSET, msf);
-
-       *m = msf[0];
-       *s = msf[1];
-       *f = msf[2];
-
-       return 0;
-}
-
-long ReadSector(crdata *cr) {
-       int                                     lba;
-       MMC_READ_CD                     cdb;
-
-       lba = msf_to_lba(cr->msf.cdmsf_min0, cr->msf.cdmsf_sec0, cr->msf.cdmsf_frame0);
-       memset(&cdb, 0, sizeof(cdb));
-
-       cdb.Code = 0xBE;
-       cdb.IncludeEDC = 1;
-       cdb.IncludeUserData = 1;
-       cdb.HeaderCode = 3;
-       cdb.IncludeSyncData = 1;
-       cdb.SubChannelSelection = 0;
-       cdb.StartingLBA[1] = lba >> 16;
-       cdb.StartingLBA[2] = lba >> 8;
-       cdb.StartingLBA[3] = lba;
-       cdb.TransferBlocks[2] = 1;
-
-       if (mmc_run_cmd(cdHandle, 10000, (mmc_cdb_t *)&cdb, SCSI_MMC_DATA_READ, sizeof(*cr), cr) != DRIVER_OP_SUCCESS)
-               return -1;
-
-       return 0;
-}
-
-long PlayCDDA(unsigned char *sector) {
-       msf_t start, end;
-
-       if (!cdio_get_track_msf(cdHandle, CDIO_CDROM_LEADOUT_TRACK, &end))
-               return -1;
-
-       start.m = itob(sector[0]);
-       start.s = itob(sector[1]);
-       start.f = itob(sector[2]);
-
-       if (cdio_audio_play_msf(cdHandle, &start, &end) != DRIVER_OP_SUCCESS)
-               return -1;
-
-       return 0;
-}
-
-long StopCDDA() {
-       cdio_subchannel_t subchnl;
-
-       if (cdio_audio_read_subchannel(cdHandle, &subchnl) != DRIVER_OP_SUCCESS)
-               return -1;
-
-       switch (subchnl.audio_status) {
-               case CDIO_MMC_READ_SUB_ST_PLAY:
-               case CDIO_MMC_READ_SUB_ST_PAUSED:
-                       cdio_audio_stop(cdHandle);
-       }
-
-       return 0;
-}
-
-long GetStatus(int playing, struct CdrStat *stat) {
-       cdio_subchannel_t subchnl;
-
-       memset(stat, 0, sizeof(struct CdrStat));
-
-       if (playing) {
-               if (cdio_audio_read_subchannel(cdHandle, &subchnl) == DRIVER_OP_SUCCESS) {
-                       stat->Time[0] = btoi(subchnl.abs_addr.m);
-                       stat->Time[1] = btoi(subchnl.abs_addr.s);
-                       stat->Time[2] = btoi(subchnl.abs_addr.f);
-               }
-       }
-
-       stat->Type = 0x01;
-
-       if (mmc_get_tray_status(cdHandle)) {
-               stat->Type = 0xff;
-               stat->Status |= 0x10;
-       } else {
-               SetSpeed(CdrSpeed);
-               SetSpinDown(SpinDown);
-               UnlockDoor();
-       }
-
-       return 0;
-}
-
-unsigned char *ReadSub(const unsigned char *time) {
-       int lba = msf_to_lba(btoi(time[0]), btoi(time[1]), btoi(time[2]));
-       static unsigned char buf[CD_FRAMESIZE_RAW + 96];
-
-       MMC_READ_CD cdb;
-
-       memset(&cdb, 0, sizeof(cdb));
-
-       cdb.Code = 0xBE;
-       cdb.IncludeEDC = 1;
-       cdb.IncludeUserData = 1;
-       cdb.HeaderCode = 3;
-       cdb.IncludeSyncData = 1;
-       cdb.StartingLBA[1] = lba >> 16;
-       cdb.StartingLBA[2] = lba >> 8;
-       cdb.StartingLBA[3] = lba;
-       cdb.TransferBlocks[2] = 1;
-       cdb.SubChannelSelection = 1;
-
-       if (mmc_run_cmd(cdHandle, 10000, (mmc_cdb_t *)&cdb, SCSI_MMC_DATA_READ, sizeof(buf), buf) != DRIVER_OP_SUCCESS)
-               return NULL;
-
-       DecodeRawSubData(buf + CD_FRAMESIZE_RAW);
-       return buf + CD_FRAMESIZE_RAW;
-}
-
-#endif
diff --git a/plugins/dfcdrom/cdr-linux.c b/plugins/dfcdrom/cdr-linux.c
deleted file mode 100644 (file)
index a814962..0000000
+++ /dev/null
@@ -1,407 +0,0 @@
-/*
- * Copyright (c) 2010, Wei Mingzhi <whistler@openoffice.org>.
- * All Rights Reserved.
- *
- * Based on: Cdrom for Psemu Pro like Emulators
- * By: linuzappz <linuzappz@hotmail.com>
- *
- * Portions based on: cdrdao - write audio CD-Rs in disc-at-once mode
- * Copyright (C) 2007 Denis Leroy <denis@poolshark.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses>.
- */
-
-#if defined (__linux__) && !defined (USE_LIBCDIO)
-
-#include "cdr.h"
-
-static int cdHandle = -1;
-static int ReadMMC = 0, SubQMMC = 0;
-
-static int SendMMCCmd(const unsigned char *cmd, int cmdLen, const unsigned char *dataOut,
-       int dataOutLen, unsigned char *dataIn, int dataInLen)
-{
-       sg_io_hdr_t io_hdr;
-
-       memset(&io_hdr, 0, sizeof(io_hdr));
-
-       io_hdr.interface_id = 'S';
-       io_hdr.cmd_len = cmdLen;
-       io_hdr.cmdp = (unsigned char *)cmd;
-       io_hdr.timeout = 10000;
-       io_hdr.sbp = NULL;
-       io_hdr.mx_sb_len = 0;
-       io_hdr.flags = 1;
-
-       if (dataOut != NULL) {
-               io_hdr.dxferp = (void *)dataOut;
-               io_hdr.dxfer_len = dataOutLen;
-               io_hdr.dxfer_direction = SG_DXFER_TO_DEV;
-       } else if (dataIn != NULL) {
-               io_hdr.dxferp = (void *)dataIn;
-               io_hdr.dxfer_len = dataInLen;
-               io_hdr.dxfer_direction = SG_DXFER_FROM_DEV;
-       }
-
-       if (ioctl(cdHandle, SG_IO, &io_hdr) < 0) {
-               return -1;
-       }
-
-       return io_hdr.status;
-}
-
-static int CheckReadMMC() {
-       MMC_READ_CD                     cdb;
-       unsigned char           buf[CD_FRAMESIZE_RAW];
-
-       memset(&cdb, 0, sizeof(cdb));
-       memset(buf, 0xAA, sizeof(buf));
-
-       cdb.Code = GPCMD_READ_CD;
-       cdb.IncludeEDC = 0;
-       cdb.IncludeUserData = 1;
-       cdb.HeaderCode = 3;
-       cdb.IncludeSyncData = 1;
-       cdb.TransferBlocks[2] = 1;
-
-       if (SendMMCCmd((unsigned char *)&cdb, sizeof(cdb), NULL, 0, buf, sizeof(buf)) == 0) {
-               if (buf[0] != 0xAA) {
-                       PRINTF("Using MMC for data\n");
-                       return 1; // supported
-               }
-       }
-
-       return 0; // NOT supported
-}
-
-static int CheckSubQMMC() {
-       MMC_READ_CD                     cdb;
-       unsigned char           buf[CD_FRAMESIZE_RAW + 96];
-
-       memset(&cdb, 0, sizeof(cdb));
-       memset(buf, 0xAA, sizeof(buf));
-
-       cdb.Code = GPCMD_READ_CD;
-       cdb.IncludeEDC = 1;
-       cdb.IncludeUserData = 1;
-       cdb.HeaderCode = 3;
-       cdb.IncludeSyncData = 1;
-       cdb.SubChannelSelection = 1;
-       cdb.TransferBlocks[2] = 1;
-
-       if (SendMMCCmd((unsigned char *)&cdb, sizeof(cdb), NULL, 0, buf, sizeof(buf)) == 0) {
-               if (buf[0] != 0xAA && (buf[2352] != 0xAA || buf[2353] != 0xAA)) {
-                       PRINTF("Using MMC for subchannel\n");
-                       return 1; // supported
-               }
-       }
-
-       return 0; // NOT supported
-}
-
-int OpenCdHandle(const char *dev) {
-       char spindown;
-
-       cdHandle = open(dev, O_RDONLY);
-
-       if (cdHandle != -1) {
-               ioctl(cdHandle, CDROM_LOCKDOOR, 0);
-
-               spindown = (char)SpinDown;
-               ioctl(cdHandle, CDROMSETSPINDOWN, &spindown);
-
-               ioctl(cdHandle, CDROM_SELECT_SPEED, CdrSpeed);
-
-               ReadMMC = CheckReadMMC();
-               SubQMMC = CheckSubQMMC();
-
-               return 0;
-       }
-
-       return -1;
-}
-
-void CloseCdHandle() {
-       char spindown = SPINDOWN_VENDOR_SPECIFIC;
-       ioctl(cdHandle, CDROMSETSPINDOWN, &spindown);
-
-       close(cdHandle);
-
-       cdHandle = -1;
-}
-
-int IsCdHandleOpen() {
-       return (cdHandle != -1);
-}
-
-long GetTN(unsigned char *buffer) {
-       struct cdrom_tochdr toc;
-
-       if (ioctl(cdHandle, CDROMREADTOCHDR, &toc) == -1)
-               return -1;
-
-       buffer[0] = toc.cdth_trk0;      // start track
-       buffer[1] = toc.cdth_trk1;      // end track
-
-       return 0;
-}
-
-long GetTD(unsigned char track, unsigned char *buffer) {
-       struct cdrom_tocentry entry;
-
-       if (track == 0)
-               track = 0xAA; // total time (leadout)
-       entry.cdte_track = track;
-       entry.cdte_format = CDROM_MSF;
-
-       if (ioctl(cdHandle, CDROMREADTOCENTRY, &entry) == -1)
-               return -1;
-
-       buffer[0] = entry.cdte_addr.msf.frame;
-       buffer[1] = entry.cdte_addr.msf.second;
-       buffer[2] = entry.cdte_addr.msf.minute;
-
-       return 0;
-}
-
-long GetTE(unsigned char track, unsigned char *m, unsigned char *s, unsigned char *f) {
-       struct cdrom_tocentry entry;
-       unsigned char msf[3];
-
-       if (GetTN(msf) == -1) return -1;
-
-       entry.cdte_track = track + 1;
-       if (entry.cdte_track > msf[1]) entry.cdte_track = 0xaa;
-
-       entry.cdte_format = CDROM_MSF;
-
-       if (ioctl(cdHandle, CDROMREADTOCENTRY, &entry) == -1)
-               return -1;
-
-       lba_to_msf(msf_to_lba(entry.cdte_addr.msf.minute, entry.cdte_addr.msf.second, entry.cdte_addr.msf.frame) - CD_MSF_OFFSET, msf);
-
-       *m = msf[0];
-       *s = msf[1];
-       *f = msf[2];
-
-       return 0;
-}
-
-long ReadSector(crdata *cr) {
-       if (ReadMMC) {
-               MMC_READ_CD                     cdb;
-               int                                     lba;
-
-               memset(&cdb, 0, sizeof(cdb));
-
-               lba = msf_to_lba(cr->msf.cdmsf_min0, cr->msf.cdmsf_sec0, cr->msf.cdmsf_frame0);
-
-               cdb.Code = GPCMD_READ_CD;
-               cdb.IncludeEDC = 1;
-               cdb.IncludeUserData = 1;
-               cdb.HeaderCode = 3;
-               cdb.IncludeSyncData = 1;
-               cdb.SubChannelSelection = 0;
-               cdb.StartingLBA[1] = lba >> 16;
-               cdb.StartingLBA[2] = lba >> 8;
-               cdb.StartingLBA[3] = lba;
-               cdb.TransferBlocks[2] = 1;
-
-               if (SendMMCCmd((unsigned char *)&cdb, sizeof(cdb), NULL, 0, (unsigned char *)cr, sizeof(*cr)) != 0)
-                       return -1;
-       } else {
-               if (ioctl(cdHandle, CDROMREADRAW, cr) == -1)
-                       return -1;
-       }
-
-       return 0;
-}
-
-long PlayCDDA(unsigned char *sector) {
-       struct cdrom_msf addr;
-       unsigned char ptmp[4];
-
-       // 0 is the last track of every cdrom, so play up to there
-       if (GetTD(0, ptmp) == -1)
-               return -1;
-
-       addr.cdmsf_min0 = sector[0];
-       addr.cdmsf_sec0 = sector[1];
-       addr.cdmsf_frame0 = sector[2];
-       addr.cdmsf_min1 = ptmp[2];
-       addr.cdmsf_sec1 = ptmp[1];
-       addr.cdmsf_frame1 = ptmp[0];
-
-       if (ioctl(cdHandle, CDROMPLAYMSF, &addr) == -1)
-               return -1;
-
-       return 0;
-}
-
-long StopCDDA() {
-       struct cdrom_subchnl sc;
-
-       sc.cdsc_format = CDROM_MSF;
-       if (ioctl(cdHandle, CDROMSUBCHNL, &sc) == -1)
-               return -1;
-
-       switch (sc.cdsc_audiostatus) {
-               case CDROM_AUDIO_PAUSED:
-               case CDROM_AUDIO_PLAY:
-                       ioctl(cdHandle, CDROMSTOP);
-                       break;
-       }
-
-       return 0;
-}
-
-long GetStatus(int playing, struct CdrStat *stat) {
-       struct cdrom_subchnl sc;
-       int ret;
-       char spindown;
-
-       memset(stat, 0, sizeof(struct CdrStat));
-
-       if (playing) { // return Time only if playing
-               sc.cdsc_format = CDROM_MSF;
-               if (ioctl(cdHandle, CDROMSUBCHNL, &sc) != -1)
-                       memcpy(stat->Time, &sc.cdsc_absaddr.msf, 3);
-       }
-
-       ret = ioctl(cdHandle, CDROM_DISC_STATUS);
-       switch (ret) {
-               case CDS_AUDIO:
-                       stat->Type = 0x02;
-                       break;
-               case CDS_DATA_1:
-               case CDS_DATA_2:
-               case CDS_XA_2_1:
-               case CDS_XA_2_2:
-                       stat->Type = 0x01;
-                       break;
-       }
-       ret = ioctl(cdHandle, CDROM_DRIVE_STATUS);
-       switch (ret) {
-               case CDS_NO_DISC:
-               case CDS_TRAY_OPEN:
-                       stat->Type = 0xff;
-                       stat->Status |= 0x10;
-                       break;
-               default:
-                       spindown = (char)SpinDown;
-                       ioctl(cdHandle, CDROMSETSPINDOWN, &spindown);
-                       ioctl(cdHandle, CDROM_SELECT_SPEED, CdrSpeed);
-                       ioctl(cdHandle, CDROM_LOCKDOOR, 0);
-                       break;
-       }
-
-       switch (sc.cdsc_audiostatus) {
-               case CDROM_AUDIO_PLAY:
-                       stat->Status |= 0x80;
-                       break;
-       }
-
-       return 0;
-}
-
-static unsigned char *ReadSubMMC(const unsigned char *time) {
-       static unsigned char buf[CD_FRAMESIZE_RAW + 96];
-       int lba = msf_to_lba(btoi(time[0]), btoi(time[1]), btoi(time[2]));
-       MMC_READ_CD cdb;
-
-       memset(&cdb, 0, sizeof(cdb));
-
-       cdb.Code = GPCMD_READ_CD;
-       cdb.IncludeEDC = 1;
-       cdb.IncludeUserData = 1;
-       cdb.HeaderCode = 3;
-       cdb.IncludeSyncData = 1;
-       cdb.StartingLBA[1] = lba >> 16;
-       cdb.StartingLBA[2] = lba >> 8;
-       cdb.StartingLBA[3] = lba;
-       cdb.TransferBlocks[2] = 1;
-       cdb.SubChannelSelection = 1;
-
-       if (SendMMCCmd((unsigned char *)&cdb, sizeof(cdb), NULL, 0, buf, sizeof(buf)) != 0)
-               return NULL;
-
-       DecodeRawSubData(buf + CD_FRAMESIZE_RAW);
-       return buf + CD_FRAMESIZE_RAW;
-}
-
-static unsigned char *ReadSubIOCTL(const unsigned char *time) {
-       static struct SubQ subq;
-       struct cdrom_subchnl subchnl;
-       int r;
-       crdata cr;
-       unsigned short crc;
-
-       cr.msf.cdmsf_min0 = btoi(time[0]);
-       cr.msf.cdmsf_sec0 = btoi(time[1]);
-       cr.msf.cdmsf_frame0 = btoi(time[2]);
-
-       if (ioctl(cdHandle, CDROMSEEK, &cr.msf) == -1) {
-               // will be slower, but there's no other way to make it accurate
-               if (ioctl(cdHandle, CDROMREADRAW, &cr) == -1) {
-                       return NULL;
-               }
-       }
-
-       subchnl.cdsc_format = CDROM_MSF;
-       r = ioctl(cdHandle, CDROMSUBCHNL, &subchnl);
-
-       if (r == -1) return NULL;
-
-       subq.ControlAndADR = 0x41;
-       subq.TrackNumber = subchnl.cdsc_trk;
-       subq.IndexNumber = subchnl.cdsc_ind;
-       subq.TrackRelativeAddress[0] = itob(subchnl.cdsc_reladdr.msf.minute);
-       subq.TrackRelativeAddress[1] = itob(subchnl.cdsc_reladdr.msf.second);
-       subq.TrackRelativeAddress[2] = itob(subchnl.cdsc_reladdr.msf.frame);
-       subq.AbsoluteAddress[0] = itob(subchnl.cdsc_absaddr.msf.minute);
-       subq.AbsoluteAddress[1] = itob(subchnl.cdsc_absaddr.msf.second);
-       subq.AbsoluteAddress[2] = itob(subchnl.cdsc_absaddr.msf.frame);
-
-       // CRC is not supported with IOCTL, fake it.
-       crc = calcCrc((unsigned char *)&subq + 12, 10);
-       subq.CRC[0] = (crc >> 8);
-       subq.CRC[1] = (crc & 0xFF);
-
-       r = msf_to_lba(btoi(time[0]), btoi(time[1]), btoi(time[2]));
-
-       if (GetTE(1, &cr.msf.cdmsf_min0, &cr.msf.cdmsf_sec0, &cr.msf.cdmsf_frame0) == -1) {
-               cr.msf.cdmsf_min0 = 80;
-               cr.msf.cdmsf_sec0 = 0;
-               cr.msf.cdmsf_frame0 = 0;
-       }
-
-       if (msf_to_lba(cr.msf.cdmsf_min0, cr.msf.cdmsf_sec0, cr.msf.cdmsf_frame0) >= r &&
-               (msf_to_lba(subchnl.cdsc_absaddr.msf.minute, subchnl.cdsc_absaddr.msf.second, subchnl.cdsc_absaddr.msf.frame) != r ||
-               msf_to_lba(subchnl.cdsc_reladdr.msf.minute, subchnl.cdsc_reladdr.msf.second, subchnl.cdsc_reladdr.msf.frame) != r - CD_MSF_OFFSET))
-               subq.CRC[1] ^= 1; // time mismatch; report wrong CRC
-
-       PRINTF("subq : %x,%x : %x,%x,%x : %x,%x,%x\n",
-               subchnl.cdsc_trk, subchnl.cdsc_ind,
-               itob(subchnl.cdsc_reladdr.msf.minute), itob(subchnl.cdsc_reladdr.msf.second), itob(subchnl.cdsc_reladdr.msf.frame),
-               itob(subchnl.cdsc_absaddr.msf.minute), itob(subchnl.cdsc_absaddr.msf.second), itob(subchnl.cdsc_absaddr.msf.frame));
-
-       return (unsigned char *)&subq;
-}
-
-unsigned char *ReadSub(const unsigned char *time) {
-       if (SubQMMC) return ReadSubMMC(time);
-       else return ReadSubIOCTL(time);
-}
-
-#endif
diff --git a/plugins/dfcdrom/cdr-null.c b/plugins/dfcdrom/cdr-null.c
deleted file mode 100644 (file)
index c6aa396..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2010, Wei Mingzhi <whistler@openoffice.org>.
- * All Rights Reserved.
- *
- * Based on: Cdrom for Psemu Pro like Emulators
- * By: linuzappz <linuzappz@hotmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses>.
- */
-
-#include "cdr.h"
-
-#ifdef USE_NULL
-
-int OpenCdHandle(const char *dev) {
-       return -1;
-}
-
-void CloseCdHandle() {
-}
-
-int IsCdHandleOpen() {
-       return 0;
-}
-
-long GetTN(unsigned char *buffer) {
-       buffer[0] = 0;
-       buffer[1] = 0;
-       return 0;
-}
-
-long GetTD(unsigned char track, unsigned char *buffer) {
-       memset(buffer + 1, 0, 3);
-       return 0;
-}
-
-long GetTE(unsigned char track, unsigned char *m, unsigned char *s, unsigned char *f) {
-       return -1;
-}
-
-long ReadSector(crdata *cr) {
-       return -1;
-}
-
-long PlayCDDA(unsigned char *sector) {
-       return 0;
-}
-
-long StopCDDA() {
-       return 0;
-}
-
-long GetStatus(int playing, struct CdrStat *stat) {
-       return -1;
-}
-
-unsigned char *ReadSub(const unsigned char *time) {
-       return NULL;
-}
-
-#endif
diff --git a/plugins/dfcdrom/cdr.c b/plugins/dfcdrom/cdr.c
deleted file mode 100644 (file)
index f011684..0000000
+++ /dev/null
@@ -1,515 +0,0 @@
-/*
- * Copyright (c) 2010, Wei Mingzhi <whistler@openoffice.org>.
- * All Rights Reserved.
- *
- * Based on: Cdrom for Psemu Pro like Emulators
- * By: linuzappz <linuzappz@hotmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses>.
- */
-
-#include "cdr.h"
-
-#ifndef USE_NULL
-static char *LibName = N_("CD-ROM Drive Reader");
-#else
-static char *LibName = N_("CDR NULL Plugin");
-#endif
-
-int initial_time = 0;
-
-pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
-pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
-
-CacheData *cdcache;
-unsigned char *cdbuffer;
-int cacheaddr;
-
-crdata cr;
-
-unsigned char lastTime[3];
-pthread_t thread;
-int subqread;
-volatile int stopth, found, locked, playing;
-
-long (*ReadTrackT[])() = {
-       ReadNormal,
-       ReadThreaded,
-};
-
-unsigned char* (*GetBufferT[])() = {
-       GetBNormal,
-       GetBThreaded,
-};
-
-long (*fReadTrack)();
-unsigned char* (*fGetBuffer)();
-
-void *CdrThread(void *arg);
-
-long CDRinit(void) {
-       thread = (pthread_t)-1;
-       return 0;
-}
-
-long CDRshutdown(void) {
-       return 0;
-}
-
-long CDRopen(void) {
-       LoadConf();
-
-#ifndef _MACOSX
-       if (IsCdHandleOpen())
-               return 0; // it's already open
-#endif
-
-       if (OpenCdHandle(CdromDev) == -1) { // if we can't open the cdrom we'll works as a null plugin
-               fprintf(stderr, "CDR: Could not open %s\n", CdromDev);
-       }
-
-       fReadTrack = ReadTrackT[ReadMode];
-       fGetBuffer = GetBufferT[ReadMode];
-
-       if (ReadMode == THREADED) {
-               cdcache = (CacheData *)malloc(CacheSize * sizeof(CacheData));
-               if (cdcache == NULL) return -1;
-               memset(cdcache, 0, CacheSize * sizeof(CacheData));
-
-               found = 0;
-       } else {
-               cdbuffer = cr.buf + 12; /* skip sync data */
-       }
-
-       if (ReadMode == THREADED) {
-               pthread_attr_t attr;
-
-               pthread_mutex_init(&mut, NULL);
-               pthread_cond_init(&cond, NULL);
-               locked = 0;
-
-               pthread_attr_init(&attr);
-               pthread_create(&thread, &attr, CdrThread, NULL);
-
-               cacheaddr = -1;
-       } else thread = (pthread_t)-1;
-
-       playing = 0;
-       stopth = 0;
-       initial_time = 0;
-
-       return 0;
-}
-
-long CDRclose(void) {
-       if (!IsCdHandleOpen()) return 0;
-
-       if (playing) CDRstop();
-
-       CloseCdHandle();
-
-       if (thread != (pthread_t)-1) {
-               if (locked == 0) {
-                       stopth = 1;
-                       while (locked == 0) usleep(5000);
-               }
-
-               stopth = 2;
-               pthread_mutex_lock(&mut);
-               pthread_cond_signal(&cond);
-               pthread_mutex_unlock(&mut);
-
-               pthread_join(thread, NULL);
-               pthread_mutex_destroy(&mut);
-               pthread_cond_destroy(&cond);
-       }
-
-       if (ReadMode == THREADED) {
-               free(cdcache);
-       }
-
-       return 0;
-}
-
-// return Starting and Ending Track
-// buffer:
-//  byte 0 - start track
-//  byte 1 - end track
-long CDRgetTN(unsigned char *buffer) {
-       long ret;
-
-       if (!IsCdHandleOpen()) {
-               buffer[0] = 1;
-               buffer[1] = 1;
-               return 0;
-       }
-
-       if (ReadMode == THREADED) pthread_mutex_lock(&mut);
-       ret = GetTN(buffer);
-       if (ReadMode == THREADED) pthread_mutex_unlock(&mut);
-
-       return ret;
-}
-
-// return Track Time
-// buffer:
-//  byte 0 - frame
-//  byte 1 - second
-//  byte 2 - minute
-long CDRgetTD(unsigned char track, unsigned char *buffer) {
-       long ret;
-
-       if (!IsCdHandleOpen()) {
-               memset(buffer + 1, 0, 3);
-               return 0;
-       }
-
-       if (ReadMode == THREADED) pthread_mutex_lock(&mut);
-       ret = GetTD(track, buffer);
-       if (ReadMode == THREADED) pthread_mutex_unlock(&mut);
-
-       return ret;
-}
-
-// normal reading
-long ReadNormal() {
-       if (ReadSector(&cr) == -1)
-               return -1;
-
-       return 0;
-}
-
-unsigned char* GetBNormal() {
-       return cdbuffer;
-}
-
-// threaded reading (with cache)
-long ReadThreaded() {
-       int addr = msf_to_lba(cr.msf.cdmsf_min0, cr.msf.cdmsf_sec0, cr.msf.cdmsf_frame0);
-       int i;
-
-       if (addr >= cacheaddr && addr < (cacheaddr + CacheSize) && cacheaddr != -1) {
-               i = addr - cacheaddr;
-               PRINTF("found %d\n", (addr - cacheaddr));
-               cdbuffer = cdcache[i].cr.buf + 12;
-               while (btoi(cdbuffer[0]) != cr.msf.cdmsf_min0 ||
-                          btoi(cdbuffer[1]) != cr.msf.cdmsf_sec0 ||
-                          btoi(cdbuffer[2]) != cr.msf.cdmsf_frame0) {
-                       if (locked == 1) {
-                               if (cdcache[i].ret == 0) break;
-                               return -1;
-                       }
-                       usleep(5000);
-               }
-               PRINTF("%x:%x:%x, %p, %p\n", cdbuffer[0], cdbuffer[1], cdbuffer[2], cdbuffer, cdcache);
-               found = 1;
-
-               return 0;
-       } else found = 0;
-
-       if (locked == 0) {
-               stopth = 1;
-               while (locked == 0) { usleep(5000); }
-               stopth = 0;
-       }
-
-       // not found in cache
-       locked = 0;
-       pthread_mutex_lock(&mut);
-       pthread_cond_signal(&cond);
-       pthread_mutex_unlock(&mut);
-
-       return 0;
-}
-
-unsigned char* GetBThreaded() {
-       PRINTF("threadc %d\n", found);
-
-       if (found == 1) return cdbuffer;
-       cdbuffer = cdcache[0].cr.buf + 12;
-       while (btoi(cdbuffer[0]) != cr.msf.cdmsf_min0 ||
-                  btoi(cdbuffer[1]) != cr.msf.cdmsf_sec0 ||
-                  btoi(cdbuffer[2]) != cr.msf.cdmsf_frame0) {
-               if (locked == 1) return NULL;
-               usleep(5000);
-       }
-       if (cdcache[0].ret == -1) return NULL;
-
-       return cdbuffer;
-}
-
-void *CdrThread(void *arg) {
-       unsigned char curTime[3];
-       int i;
-
-       for (;;) {
-               locked = 1;
-               pthread_mutex_lock(&mut);
-               pthread_cond_wait(&cond, &mut);
-
-               if (stopth == 2) pthread_exit(NULL);
-               // refill the buffer
-               cacheaddr = msf_to_lba(cr.msf.cdmsf_min0, cr.msf.cdmsf_sec0, cr.msf.cdmsf_frame0);
-
-               memcpy(curTime, &cr.msf, 3);
-
-               PRINTF("start thc %d:%d:%d\n", curTime[0], curTime[1], curTime[2]);
-
-               for (i = 0; i < CacheSize; i++) {
-                       memcpy(&cdcache[i].cr.msf, curTime, 3);
-                       PRINTF("reading %d:%d:%d\n", curTime[0], curTime[1], curTime[2]);
-                       cdcache[i].ret = ReadSector(&cdcache[i].cr);
-
-                       PRINTF("readed %x:%x:%x\n", cdcache[i].cr.buf[12], cdcache[i].cr.buf[13], cdcache[i].cr.buf[14]);
-                       if (cdcache[i].ret == -1) break;
-
-                       curTime[2]++;
-                       if (curTime[2] == 75) {
-                               curTime[2] = 0;
-                               curTime[1]++;
-                               if (curTime[1] == 60) {
-                                       curTime[1] = 0;
-                                       curTime[0]++;
-                               }
-                       }
-
-                       if (stopth) break;
-               }
-
-               pthread_mutex_unlock(&mut);
-       }
-
-       return NULL;
-}
-
-// read track
-// time:
-//  byte 0 - minute
-//  byte 1 - second
-//  byte 2 - frame
-// uses bcd format
-long CDRreadTrack(unsigned char *time) {
-       if (!IsCdHandleOpen()) {
-               memset(cr.buf, 0, DATA_SIZE);
-               return 0;
-       }
-
-       PRINTF("CDRreadTrack %d:%d:%d\n", btoi(time[0]), btoi(time[1]), btoi(time[2]));
-
-       if (UseSubQ) memcpy(lastTime, time, 3);
-       subqread = 0;
-
-       cr.msf.cdmsf_min0 = btoi(time[0]);
-       cr.msf.cdmsf_sec0 = btoi(time[1]);
-       cr.msf.cdmsf_frame0 = btoi(time[2]);
-
-       return fReadTrack();
-}
-
-// return readed track
-unsigned char *CDRgetBuffer(void) {
-       return fGetBuffer();
-}
-
-// plays cdda audio
-// sector:
-//  byte 0 - minute
-//  byte 1 - second
-//  byte 2 - frame
-// does NOT uses bcd format
-long CDRplay(unsigned char *sector) {
-       long ret;
-
-       if (!IsCdHandleOpen())
-               return 0;
-
-       // If play was called with the same time as the previous call,
-       // don't restart it. Of course, if play is called with a different
-       // track, stop playing the current stream.
-       if (playing) {
-               if (msf_to_lba(sector[0], sector[1], sector[2]) == initial_time)
-                       return 0;
-               else
-                       CDRstop();
-       }
-
-       initial_time = msf_to_lba(sector[0], sector[1], sector[2]);
-
-       if (ReadMode == THREADED) pthread_mutex_lock(&mut);
-       ret = PlayCDDA(sector);
-       if (ReadMode == THREADED) pthread_mutex_unlock(&mut);
-
-       if (ret == 0) {
-               playing = 1;
-               return 0;
-       }
-
-       return -1;
-}
-
-// stops cdda audio
-long CDRstop(void) {
-       long ret;
-
-       if (!IsCdHandleOpen())
-               return 0;
-
-       if (ReadMode == THREADED) pthread_mutex_lock(&mut);
-       ret = StopCDDA();
-       if (ReadMode == THREADED) pthread_mutex_unlock(&mut);
-
-       if (ret == 0) {
-               playing = 0;
-               initial_time = 0;
-
-               return 0;
-       }
-
-       return -1;
-}
-
-// reads cdr status
-// type:
-//  0x00 - unknown
-//  0x01 - data
-//  0x02 - audio
-//  0xff - no cdrom
-// status: (only shell open supported)
-//  0x00 - unknown
-//  0x01 - error
-//  0x04 - seek error
-//  0x10 - shell open
-//  0x20 - reading
-//  0x40 - seeking
-//  0x80 - playing
-// time:
-//  byte 0 - minute
-//  byte 1 - second
-//  byte 2 - frame
-
-long CDRgetStatus(struct CdrStat *stat) {
-       long ret;
-
-       if (!IsCdHandleOpen())
-               return -1;
-
-       if (ReadMode == THREADED) pthread_mutex_lock(&mut);
-       ret = GetStatus(playing, stat);
-       if (ReadMode == THREADED) pthread_mutex_unlock(&mut);
-
-       return ret;
-}
-
-unsigned char *CDRgetBufferSub(void) {
-       static unsigned char *p = NULL;
-
-       if (!UseSubQ) return NULL;
-       if (subqread) return p;
-
-       if (ReadMode == THREADED) pthread_mutex_lock(&mut);
-       p = ReadSub(lastTime);
-       if (ReadMode == THREADED) pthread_mutex_unlock(&mut);
-
-       if (p != NULL) subqread = 1;
-
-       return p;
-}
-
-// read CDDA sector into buffer
-long CDRreadCDDA(unsigned char m, unsigned char s, unsigned char f, unsigned char *buffer) {
-       unsigned char msf[3] = {m, s, f};
-       unsigned char *p;
-
-       if (CDRreadTrack(msf) != 0) return -1;
-
-       p = CDRgetBuffer();
-       if (p == NULL) return -1;
-
-       memcpy(buffer, p - 12, CD_FRAMESIZE_RAW); // copy from the beginning of the sector
-       return 0;
-}
-
-// get Track End Time
-long CDRgetTE(unsigned char track, unsigned char *m, unsigned char *s, unsigned char *f) {
-       long ret;
-
-       if (!IsCdHandleOpen()) return -1;
-
-       if (ReadMode == THREADED) pthread_mutex_lock(&mut);
-       ret = GetTE(track, m, s, f);
-       if (ReadMode == THREADED) pthread_mutex_unlock(&mut);
-
-       return ret;
-}
-
-#ifndef _MACOSX
-
-void ExecCfg(char *arg) {
-       char cfg[256];
-       struct stat buf;
-
-       strcpy(cfg, "./cfgDFCdrom");
-       if (stat(cfg, &buf) != -1) {
-               if (fork() == 0) {
-                       execl(cfg, "cfgDFCdrom", arg, NULL);
-                       exit(0);
-               }
-               return;
-       }
-
-       strcpy(cfg, "./cfg/DFCdrom");
-       if (stat(cfg, &buf) != -1) {
-               if (fork() == 0) {
-                       execl(cfg, "cfgDFCdrom", arg, NULL);
-                       exit(0);
-               }
-               return;
-       }
-
-       fprintf(stderr, "cfgDFCdrom file not found!\n");
-}
-
-long CDRconfigure() {
-#ifndef USE_NULL
-       ExecCfg("configure");
-#endif
-       return 0;
-}
-
-void CDRabout() {
-       ExecCfg("about");
-}
-
-#endif
-
-long CDRtest(void) {
-#ifndef USE_NULL
-       if (OpenCdHandle(CdromDev) == -1)
-               return -1;
-       CloseCdHandle();
-#endif
-       return 0;
-}
-
-char *PSEgetLibName(void) {
-       return _(LibName);
-}
-
-unsigned long PSEgetLibType(void) {
-       return PSE_LT_CDR;
-}
-
-unsigned long PSEgetLibVersion(void) {
-       return 1 << 16;
-}
diff --git a/plugins/dfcdrom/cdr.h b/plugins/dfcdrom/cdr.h
deleted file mode 100644 (file)
index 0ae2c68..0000000
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Copyright (c) 2010, Wei Mingzhi <whistler@openoffice.org>.
- * All Rights Reserved.
- *
- * Based on: Cdrom for Psemu Pro like Emulators
- * By: linuzappz <linuzappz@hotmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses>.
- */
-
-#ifndef __CDR_H__
-#define __CDR_H__
-
-//#define DEBUG 1
-
-#include "config.h"
-
-#ifdef ENABLE_NLS
-#include <libintl.h>
-#include <locale.h>
-#define _(x)  gettext(x)
-#define N_(x) (x)
-#else
-#define _(x)  (x)
-#define N_(x) (x)
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <pthread.h>
-#include <time.h>
-#include <string.h>
-
-#include "psemu_plugin_defs.h"
-
-#if defined (__linux__)
-
-#include <linux/cdrom.h>
-#include <scsi/scsi.h>
-#include <scsi/sg.h>
-
-#ifndef CDROMSETSPINDOWN
-#define CDROMSETSPINDOWN 0x531e
-#endif
-
-#define DEV_DEF                "/dev/cdrom"
-
-#else
-
-struct cdrom_msf {
-       unsigned char cdmsf_min0;     /* start minute */
-       unsigned char cdmsf_sec0;     /* start second */
-       unsigned char cdmsf_frame0;   /* start frame */
-       unsigned char cdmsf_min1;     /* end minute */
-       unsigned char cdmsf_sec1;     /* end second */
-       unsigned char cdmsf_frame1;   /* end frame */
-};
-
-#define CD_SECS                                60
-#define CD_FRAMES                      75
-#define CD_MSF_OFFSET          150
-#define CD_FRAMESIZE_SUB       96
-
-#if defined (__FreeBSD__)
-#define DEV_DEF                "/dev/cd0"
-#else
-#define DEV_DEF                ""
-#endif
-
-#if !defined (USE_LIBCDIO) && !defined (_MACOSX)
-#define USE_NULL       1
-#endif
-
-#endif
-
-extern char CdromDev[256];
-extern long ReadMode;
-extern long UseSubQ;
-extern long CacheSize;
-extern long CdrSpeed;
-extern long SpinDown;
-
-#define NORMAL         0
-#define THREADED       1
-#define READ_MODES     2
-
-#ifndef CD_FRAMESIZE_RAW
-#define CD_FRAMESIZE_RAW 2352
-#endif
-
-#define DATA_SIZE      (CD_FRAMESIZE_RAW - 12)
-
-// spindown codes
-#define SPINDOWN_VENDOR_SPECIFIC       0x00
-#define SPINDOWN_125MS                         0x01
-#define SPINDOWN_250MS                         0x02
-#define SPINDOWN_500MS                         0x03
-#define SPINDOWN_1S                                    0x04
-#define SPINDOWN_2S                                    0x05
-#define SPINDOWN_4S                                    0x06
-#define SPINDOWN_8S                                    0x07
-#define SPINDOWN_16S                           0x08
-#define SPINDOWN_32S                           0x09
-#define SPINDOWN_1MIN                          0x0A
-#define SPINDOWN_2MIN                          0x0B
-#define SPINDOWN_4MIN                          0x0C
-#define SPINDOWN_8MIN                          0x0D
-#define SPINDOWN_16MIN                         0x0E
-#define SPINDOWN_32MIN                         0x0F
-
-typedef struct _MMC_READ_CD {
-       unsigned char Code; // 0xBE
-
-       unsigned char RelativeAddress : 1;
-       unsigned char : 1;
-       unsigned char ExpectedSectorType : 3;
-       unsigned char Lun : 3;
-
-       unsigned char StartingLBA[4];
-       unsigned char TransferBlocks[3];
-
-       unsigned char : 1;
-       unsigned char ErrorFlags : 2;
-       unsigned char IncludeEDC : 1;
-       unsigned char IncludeUserData : 1;
-       unsigned char HeaderCode : 2;
-       unsigned char IncludeSyncData : 1;
-
-       unsigned char SubChannelSelection : 3;
-       unsigned char : 5;
-
-       unsigned char Ctrl;
-} MMC_READ_CD;
-
-#define itob(i)                ((i)/10*16 + (i)%10)    /* u_char to BCD */
-#define btoi(b)                ((b)/16*10 + (b)%16)    /* BCD to u_char */
-
-struct CdrStat {
-       unsigned long Type;
-       unsigned long Status;
-       unsigned char Time[3];          // current playing time
-};
-
-struct SubQ {
-       char res0[12];
-       unsigned char ControlAndADR;
-       unsigned char TrackNumber;
-       unsigned char IndexNumber;
-       unsigned char TrackRelativeAddress[3];
-       unsigned char Filler;
-       unsigned char AbsoluteAddress[3];
-       unsigned char CRC[2];
-       char res1[72];
-};
-
-typedef union {
-       struct cdrom_msf msf;
-       unsigned char buf[CD_FRAMESIZE_RAW];
-} crdata;
-
-typedef struct {
-       crdata cr;
-       int ret;
-} CacheData;
-
-long ReadNormal();
-long ReadThreaded();
-unsigned char* GetBNormal();
-unsigned char* GetBThreaded();
-
-long CDRstop(void);
-
-void LoadConf();
-void SaveConf();
-
-#ifdef DEBUG
-#define PRINTF printf
-#else
-#define PRINTF(...) /* */
-#endif
-
-unsigned int msf_to_lba(char m, char s, char f);
-void lba_to_msf(unsigned int s, unsigned char *msf);
-void DecodeRawSubData(unsigned char *subbuffer);
-unsigned short calcCrc(unsigned char *d, int len);
-
-int OpenCdHandle();
-void CloseCdHandle();
-int IsCdHandleOpen();
-long GetTN(unsigned char *buffer);
-long GetTD(unsigned char track, unsigned char *buffer);
-long GetTE(unsigned char track, unsigned char *m, unsigned char *s, unsigned char *f);
-long ReadSector(crdata *cr);
-long PlayCDDA(unsigned char *sector);
-long StopCDDA();
-long GetStatus(int playing, struct CdrStat *stat);
-unsigned char *ReadSub(const unsigned char *time);
-
-#endif
diff --git a/plugins/dfcdrom/cdrcfg-0.1df/main.c b/plugins/dfcdrom/cdrcfg-0.1df/main.c
deleted file mode 100644 (file)
index c611120..0000000
+++ /dev/null
@@ -1,290 +0,0 @@
-/*
- * Copyright (c) 2010, Wei Mingzhi <whistler@openoffice.org>.
- * All Rights Reserved.
- *
- * Based on: Cdrom for Psemu Pro like Emulators
- * By: linuzappz <linuzappz@hotmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses>.
- */
-
-#include "../cfg.c"
-
-#include <gtk/gtk.h>
-#include <glade/glade.h>
-
-GtkWidget *MainWindow;
-
-// function to check if the device is a cdrom
-int is_cdrom(const char *device) {
-       struct stat st;
-       int fd = -1;
-
-       // check if the file exist
-       if (stat(device, &st) < 0) return 0;
-
-       // check if is a block or char device
-       if (!S_ISCHR(st.st_mode) && !S_ISBLK(st.st_mode)) return 0;
-
-       // try to open the device file descriptor
-       if ((fd = open(device, O_RDONLY | O_NONBLOCK)) < 0) return 0;
-
-#ifdef __linux__
-       // I need a method to check is a device is really a CD-ROM.
-       // some problems/ideas are:
-       // - different protocls (ide, scsi, old proprietary...)
-       // - maybe we can use major number (see linux/major.h) to do some check.
-       //   major number can be retrieved with (st.st_rdev>>8)
-       //   scsi has SCSI_CDROM_MAJOR but does this cover all scsi drives?
-       //   beside IDE major is the same for hard disks and cdroms...
-       //   and DVDs?
-       // - another idea is to parse /proc, but again IDE, scsi etc have 
-       //   different files... I've not found a way to query "which CD drives
-       //   are available?"
-       //
-       // Now I use this ioctl which works also if the drive is empty,
-       // I hope that is implemented for all the drives... here works
-       // fine: at least doesn't let me to select my HD as CDs ;)
-
-       // try a ioctl to see if it's a CD-ROM device
-       if (ioctl(fd, CDROM_GET_CAPABILITY, NULL) < 0) {
-               close(fd);
-               return 0;
-       }
-#endif
-
-       close(fd);
-
-       // yes, it seems a CD drive!
-       return 1;
-}
-
-// fill_drives_list: retrieves available cd drives. At the moment it use a quite
-// ugly "brute force" method: we check for the most common location for cdrom
-// in /dev and chech if they are cdrom devices.
-// If your cdrom path is not listed here you'll have to type it in the dialog
-// entry yourself (or add it here and recompile).
-// Are there any other common entry to add to the list? (especially scsi, I
-// deliberately ignored old non standard cdroms... )
-// If you come up with a better method let me know!!
-void fill_drives_list(GtkWidget *widget) {
-       int i;
-       GtkListStore *store;
-       GtkTreeIter iter;
-
-#if defined (__linux__)
-       static const char *cdrom_devices[] = {
-               "/dev/cdrom",
-               "/dev/cdrom0",
-               "/dev/cdrom1",
-               "/dev/cdrom2",
-               "/dev/cdrom3",
-               "/dev/cdroms/cdrom0",
-               "/dev/cdroms/cdrom1",
-               "/dev/cdroms/cdrom2",
-               "/dev/cdroms/cdrom3",
-               "/dev/hda",
-               "/dev/hdb",
-               "/dev/hdc",
-               "/dev/hdd",
-               "/dev/sda",
-               "/dev/sdb",
-               "/dev/sdc",
-               "/dev/sdd",
-               "/dev/scd0",
-               "/dev/scd1",
-               "/dev/scd2",
-               "/dev/scd3",
-               "/dev/optcd",
-               ""};
-#elif defined (__FreeBSD__)
-       static const char *cdrom_devices[] = {
-               "/dev/cd0",
-               "/dev/cd1",
-               "/dev/cd2",
-               "/dev/cd3",
-               ""};
-#elif defined (__sun)
-       char cdrom_devices[256][256];
-       FILE *fp;
-       char buf[256], *devname, *nick;
-
-       memset(cdrom_devices, 0, sizeof(cdrom_devices));
-
-       i = 0;
-
-       fp = popen("eject -l", "r");
-
-       if (fp != NULL) {
-               while (!feof(fp) && i < 256) {
-                       fgets(buf, 256, fp);
-
-                       devname = strtok(buf, " ");
-                       nick = strtok(NULL, " ");
-
-                       if (devname == NULL || nick == NULL) continue;
-
-                       if (strstr(nick, "cdrom") != NULL) {
-                               strcpy(cdrom_devices[i++], devname);
-                       }
-               }
-
-               pclose(fp);
-       }
-#else
-       static const char *cdrom_devices[] = { "" };
-#endif
-
-       store = gtk_list_store_new(1, G_TYPE_STRING);
-
-       // first we put our current drive
-       if (CdromDev[0] != '\0') {
-               gtk_list_store_append(store, &iter);
-               gtk_list_store_set(store, &iter, 0, CdromDev, -1);
-       }
-
-       i = 0;
-
-       // scan cdrom_devices for real cdrom and add them to list
-       while (cdrom_devices[i][0] != '\0') {
-               // check that is not our current dev (already in list)
-               if (strcmp(cdrom_devices[i], CdromDev) != 0) {
-                       // check that is a cdrom device
-                       if (is_cdrom(cdrom_devices[i])) {
-                               gtk_list_store_append(store, &iter);
-                               gtk_list_store_set(store, &iter, 0, cdrom_devices[i], -1);
-                       }
-               }
-               ++i;
-       }
-
-       gtk_combo_box_set_model(GTK_COMBO_BOX(widget), GTK_TREE_MODEL(store));
-       gtk_combo_box_entry_set_text_column(GTK_COMBO_BOX_ENTRY(widget), 0);
-}
-
-static void OnConfigExit(GtkWidget *widget, gpointer user_data) {
-       GladeXML *xml;
-
-       xml = glade_get_widget_tree(MainWindow);
-
-       widget = glade_xml_get_widget(xml, "cddev_comboboxentry");
-       strncpy(CdromDev, gtk_entry_get_text(GTK_ENTRY(GTK_BIN(widget)->child)), 255);
-       CdromDev[255] = '\0';
-
-       widget = glade_xml_get_widget(xml, "readmode_combobox");
-       ReadMode = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
-
-       widget = glade_xml_get_widget(xml, "subQ_button");
-       UseSubQ = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
-
-       widget = glade_xml_get_widget(xml, "spinCacheSize");
-       CacheSize = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
-
-       widget = glade_xml_get_widget(xml, "spinCdrSpeed");
-       CdrSpeed = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
-
-       widget = glade_xml_get_widget(xml, "comboSpinDown");
-       SpinDown = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
-
-       SaveConf();
-
-       gtk_widget_destroy(widget);
-       gtk_exit(0);
-}
-
-long CDRconfigure() {
-       GladeXML *xml;
-       GtkWidget *widget;
-
-       LoadConf();
-
-       xml = glade_xml_new(DATADIR "dfcdrom.glade2", "CfgWnd", NULL);
-       if (xml == NULL) {
-               g_warning("We could not load the interface!");
-               return -1;
-       }
-
-       MainWindow = glade_xml_get_widget(xml, "CfgWnd");
-       gtk_window_set_title(GTK_WINDOW(MainWindow), _("CDR configuration"));
-
-       widget = glade_xml_get_widget(xml, "CfgWnd");
-       g_signal_connect_data(GTK_OBJECT(widget), "delete_event",
-               GTK_SIGNAL_FUNC(OnConfigExit), NULL, NULL, G_CONNECT_AFTER);
-
-       widget = glade_xml_get_widget(xml, "cfg_closebutton");
-       g_signal_connect_data(GTK_OBJECT(widget), "clicked",
-               GTK_SIGNAL_FUNC(OnConfigExit), NULL, NULL, G_CONNECT_AFTER);
-
-       widget = glade_xml_get_widget(xml, "cddev_comboboxentry");
-       fill_drives_list(widget);
-       gtk_entry_set_text(GTK_ENTRY(GTK_BIN(widget)->child), CdromDev);
-
-       widget = glade_xml_get_widget(xml, "readmode_combobox");
-       gtk_combo_box_set_active(GTK_COMBO_BOX(widget), ReadMode);
-
-       widget = glade_xml_get_widget(xml, "subQ_button");
-       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), UseSubQ);
-
-       widget = glade_xml_get_widget(xml, "spinCacheSize");
-       gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), (float)CacheSize);
-
-       widget = glade_xml_get_widget(xml, "spinCdrSpeed");
-       gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), (float)CdrSpeed);
-
-       widget = glade_xml_get_widget(xml, "comboSpinDown");
-       gtk_combo_box_set_active(GTK_COMBO_BOX(widget), SpinDown);
-
-       gtk_widget_show(MainWindow);
-       gtk_main();
-
-       return 0;
-}
-
-void CDRabout() {
-       GtkWidget *widget;
-       const char *authors[]= {"linuzappz <linuzappz@hotmail.com>",
-                                                       "xobro <_xobro_@tin.it>",
-                                                       "Wei Mingzhi <whistler_wmz@users.sf.net>", NULL};
-
-       widget = gtk_about_dialog_new();
-       gtk_about_dialog_set_name(GTK_ABOUT_DIALOG(widget), "CD-ROM Device Reader");
-       gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(widget), "1.0");
-       gtk_about_dialog_set_authors(GTK_ABOUT_DIALOG(widget), authors);
-       gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(widget), "http://pcsxr.codeplex.com/");
-
-       gtk_dialog_run(GTK_DIALOG(widget));
-       gtk_widget_destroy(widget);
-}
-
-int main(int argc, char *argv[]) {
-#ifdef ENABLE_NLS
-       setlocale(LC_ALL, "");
-       bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR);
-       bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
-       textdomain(GETTEXT_PACKAGE);
-#endif
-
-       gtk_set_locale();
-       gtk_init(&argc, &argv);
-
-       if (argc != 2) return 0;
-
-       if (strcmp(argv[1], "configure") == 0) {
-               CDRconfigure();
-       } else {
-               CDRabout();
-       }
-
-       return 0;
-}
diff --git a/plugins/dfcdrom/cfg.c b/plugins/dfcdrom/cfg.c
deleted file mode 100644 (file)
index 2bbc844..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (c) 2010, Wei Mingzhi <whistler@openoffice.org>.
- * All Rights Reserved.
- *
- * Based on: Cdrom for Psemu Pro like Emulators
- * By: linuzappz <linuzappz@hotmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses>.
- */
-
-#include "cdr.h"
-
-char CdromDev[256];
-long ReadMode;
-long UseSubQ;
-long CacheSize;
-long CdrSpeed;
-long SpinDown;
-
-void LoadConf() {
-       FILE *f;
-
-#if defined (__sun)
-       char buf[256], *devname, *nick;
-
-       CdromDev[0] = '\0';
-       f = popen("eject -l", "r");
-
-       if (f != NULL) {
-               while (!feof(f)) {
-                       fgets(buf, 256, f);
-
-                       devname = strtok(buf, " ");
-                       nick = strtok(NULL, " ");
-
-                       if (devname == NULL || nick == NULL) continue;
-
-                       if (strstr(nick, "cdrom") != NULL) {
-                               strcpy(CdromDev, devname);
-                               break;
-                       }
-               }
-
-               pclose(f);
-       }
-#else
-       strcpy(CdromDev, DEV_DEF);
-#endif
-
-       ReadMode = THREADED;
-       UseSubQ = 0;
-       CacheSize = 64;
-       CdrSpeed = 0;
-       SpinDown = SPINDOWN_VENDOR_SPECIFIC;
-
-       f = fopen("dfcdrom.cfg", "r");
-       if (f == NULL) return;
-
-       fscanf(f, "CdromDev = %s\n", CdromDev);
-       fscanf(f, "ReadMode = %ld\n", &ReadMode);
-       fscanf(f, "UseSubQ = %ld\n", &UseSubQ);
-       fscanf(f, "CacheSize = %ld\n", &CacheSize);
-       fscanf(f, "CdrSpeed = %ld\n", &CdrSpeed);
-       fscanf(f, "SpinDown = %ld\n", &SpinDown);
-       fclose(f);
-
-       if (ReadMode >= READ_MODES) ReadMode = THREADED;
-       if (CacheSize <= 0) CacheSize = 32;
-       if (CacheSize > 2048) CacheSize = 2048;
-       if (SpinDown <= 0) SpinDown = SPINDOWN_VENDOR_SPECIFIC;
-       if (SpinDown > SPINDOWN_32MIN) SpinDown = SPINDOWN_32MIN;
-}
-
-void SaveConf() {
-       FILE *f;
-
-       f = fopen("dfcdrom.cfg", "w");
-       if (f == NULL)
-               return;
-
-       fprintf(f, "CdromDev = %s\n", CdromDev);
-       fprintf(f, "ReadMode = %ld\n", ReadMode);
-       fprintf(f, "UseSubQ = %ld\n", UseSubQ);
-       fprintf(f, "CacheSize = %ld\n", CacheSize);
-       fprintf(f, "CdrSpeed = %ld\n", CdrSpeed);
-       fprintf(f, "SpinDown = %ld\n", SpinDown);
-       fclose(f);
-}
diff --git a/plugins/dfcdrom/util.c b/plugins/dfcdrom/util.c
deleted file mode 100644 (file)
index c80c872..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2010, Wei Mingzhi <whistler@openoffice.org>.
- * All Rights Reserved.
- *
- * Based on: Cdrom for Psemu Pro like Emulators
- * By: linuzappz <linuzappz@hotmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses>.
- */
-
-#include "cdr.h"
-
-unsigned int msf_to_lba(char m, char s, char f) {
-       return (m * CD_SECS + s) * CD_FRAMES + f - CD_MSF_OFFSET;
-}
-
-void lba_to_msf(unsigned int s, unsigned char *msf) {
-       s += CD_MSF_OFFSET;
-
-       msf[0] = s / CD_FRAMES / CD_SECS;
-       s = s - msf[0] * CD_FRAMES * CD_SECS;
-       msf[1] = s / CD_FRAMES;
-       s = s - msf[1] * CD_FRAMES;
-       msf[2] = s;
-}
-
-void DecodeRawSubData(unsigned char *subbuffer) {
-       unsigned char subQData[12];
-       int i;
-
-       memset(subQData, 0, sizeof(subQData));
-
-       for (i = 0; i < 8 * 12; i++) {
-               if (subbuffer[i] & (1 << 6)) { // only subchannel Q is needed
-                       subQData[i >> 3] |= (1 << (7 - (i & 7)));
-               }
-       }
-
-       memcpy(&subbuffer[12], subQData, 12);
-}
-
-// lookup table for crc calculation
-static unsigned short crctab[256] = {
-       0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, 0x8108,
-       0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, 0x1231, 0x0210,
-       0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6, 0x9339, 0x8318, 0xB37B,
-       0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE, 0x2462, 0x3443, 0x0420, 0x1401,
-       0x64E6, 0x74C7, 0x44A4, 0x5485, 0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE,
-       0xF5CF, 0xC5AC, 0xD58D, 0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6,
-       0x5695, 0x46B4, 0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D,
-       0xC7BC, 0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823,
-       0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B, 0x5AF5,
-       0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12, 0xDBFD, 0xCBDC,
-       0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A, 0x6CA6, 0x7C87, 0x4CE4,
-       0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41, 0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD,
-       0xAD2A, 0xBD0B, 0x8D68, 0x9D49, 0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13,
-       0x2E32, 0x1E51, 0x0E70, 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A,
-       0x9F59, 0x8F78, 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E,
-       0xE16F, 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067,
-       0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E, 0x02B1,
-       0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256, 0xB5EA, 0xA5CB,
-       0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D, 0x34E2, 0x24C3, 0x14A0,
-       0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 0xA7DB, 0xB7FA, 0x8799, 0x97B8,
-       0xE75F, 0xF77E, 0xC71D, 0xD73C, 0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657,
-       0x7676, 0x4615, 0x5634, 0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9,
-       0xB98A, 0xA9AB, 0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882,
-       0x28A3, 0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A,
-       0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92, 0xFD2E,
-       0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9, 0x7C26, 0x6C07,
-       0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1, 0xEF1F, 0xFF3E, 0xCF5D,
-       0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8, 0x6E17, 0x7E36, 0x4E55, 0x5E74,
-       0x2E93, 0x3EB2, 0x0ED1, 0x1EF0
-};
-
-unsigned short calcCrc(unsigned char *d, int len) {
-       unsigned short crc = 0;
-       int i;
-
-       for (i = 0; i < len; i++) {
-               crc = crctab[(crc >> 8) ^ d[i]] ^ (crc << 8);
-       }
-
-       return ~crc;
-}
diff --git a/plugins/dfinput/analog.c b/plugins/dfinput/analog.c
deleted file mode 100644 (file)
index 8d14b00..0000000
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Copyright (c) 2009, Wei Mingzhi <whistler@openoffice.org>.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses>.
- */
-
-#include "pad.h"
-
-void InitAnalog() {
-       g.PadState[0].AnalogStatus[ANALOG_LEFT][0] = 127;
-       g.PadState[0].AnalogStatus[ANALOG_LEFT][1] = 127;
-       g.PadState[0].AnalogStatus[ANALOG_RIGHT][0] = 127;
-       g.PadState[0].AnalogStatus[ANALOG_RIGHT][1] = 127;
-       g.PadState[1].AnalogStatus[ANALOG_LEFT][0] = 127;
-       g.PadState[1].AnalogStatus[ANALOG_LEFT][1] = 127;
-       g.PadState[1].AnalogStatus[ANALOG_RIGHT][0] = 127;
-       g.PadState[1].AnalogStatus[ANALOG_RIGHT][1] = 127;
-
-       memset(g.PadState[0].AnalogKeyStatus, 0, sizeof(g.PadState[0].AnalogKeyStatus));
-       memset(g.PadState[1].AnalogKeyStatus, 0, sizeof(g.PadState[1].AnalogKeyStatus));
-}
-
-void CheckAnalog() {
-       int                     i, j, k, val;
-       uint8_t         n;
-
-       for (i = 0; i < 2; i++) {
-               if (g.cfg.PadDef[i].Type != PSE_PAD_TYPE_ANALOGPAD) {
-                       continue;
-               }
-
-               for (j = 0; j < ANALOG_TOTAL; j++) {
-                       for (k = 0; k < 4; k++) {
-                               if (g.PadState[i].AnalogKeyStatus[j][k]) {
-                                       switch (k) {
-                                               case ANALOG_XP: g.PadState[i].AnalogStatus[j][0] = 255; k++; break;
-                                               case ANALOG_XM: g.PadState[i].AnalogStatus[j][0] = 0; break;
-                                               case ANALOG_YP: g.PadState[i].AnalogStatus[j][1] = 255; k++; break;
-                                               case ANALOG_YM: g.PadState[i].AnalogStatus[j][1] = 0; break;
-                                       }
-                                       continue;
-                               }
-
-                               switch (g.cfg.PadDef[i].AnalogDef[j][k].JoyEvType) {
-                                       case AXIS:
-                                               n = abs(g.cfg.PadDef[i].AnalogDef[j][k].J.Axis) - 1;
-
-                                               if (g.cfg.PadDef[i].AnalogDef[j][k].J.Axis > 0) {
-                                                       val = SDL_JoystickGetAxis(g.PadState[i].JoyDev, n);
-                                                       if (val >= 0) {
-                                                               val += 32640;
-                                                               val /= 256;
-
-                                                               switch (k) {
-                                                                       case ANALOG_XP: g.PadState[i].AnalogStatus[j][0] = val; break;
-                                                                       case ANALOG_XM: g.PadState[i].AnalogStatus[j][0] = 255 - val; break;
-                                                                       case ANALOG_YP: g.PadState[i].AnalogStatus[j][1] = val; break;
-                                                                       case ANALOG_YM: g.PadState[i].AnalogStatus[j][1] = 255 - val; break;
-                                                               }
-                                                       }
-                                               } else if (g.cfg.PadDef[i].AnalogDef[j][k].J.Axis < 0) {
-                                                       val = SDL_JoystickGetAxis(g.PadState[i].JoyDev, n);
-                                                       if (val <= 0) {
-                                                               val += 32640;
-                                                               val /= 256;
-
-                                                               switch (k) {
-                                                                       case ANALOG_XP: g.PadState[i].AnalogStatus[j][0] = 255 - val; break;
-                                                                       case ANALOG_XM: g.PadState[i].AnalogStatus[j][0] = val; break;
-                                                                       case ANALOG_YP: g.PadState[i].AnalogStatus[j][1] = 255 - val; break;
-                                                                       case ANALOG_YM: g.PadState[i].AnalogStatus[j][1] = val; break;
-                                                               }
-                                                       }
-                                               }
-                                               break;
-
-                                       case HAT:
-                                               n = (g.cfg.PadDef[i].AnalogDef[j][k].J.Hat >> 8);
-
-                                               g.PadState[i].AnalogStatus[j][0] = 0;
-
-                                               if (SDL_JoystickGetHat(g.PadState[i].JoyDev, n) & (g.cfg.PadDef[i].AnalogDef[j][k].J.Hat & 0xFF)) {
-                                                       switch (k) {
-                                                               case ANALOG_XP: g.PadState[i].AnalogStatus[j][0] = 255; k++; break;
-                                                               case ANALOG_XM: g.PadState[i].AnalogStatus[j][0] = 0; break;
-                                                               case ANALOG_YP: g.PadState[i].AnalogStatus[j][1] = 255; k++; break;
-                                                               case ANALOG_YM: g.PadState[i].AnalogStatus[j][1] = 0; break;
-                                                       }
-                                               } else {
-                                                       switch (k) {
-                                                               case ANALOG_XP: g.PadState[i].AnalogStatus[j][0] = 127; break;
-                                                               case ANALOG_XM: g.PadState[i].AnalogStatus[j][0] = 127; break;
-                                                               case ANALOG_YP: g.PadState[i].AnalogStatus[j][1] = 127; break;
-                                                               case ANALOG_YM: g.PadState[i].AnalogStatus[j][1] = 127; break;
-                                                       }
-                                               }
-                                               break;
-
-                                       case BUTTON:
-                                               if (SDL_JoystickGetButton(g.PadState[i].JoyDev, g.cfg.PadDef[i].AnalogDef[j][k].J.Button)) {
-                                                       switch (k) {
-                                                               case ANALOG_XP: g.PadState[i].AnalogStatus[j][0] = 255; k++; break;
-                                                               case ANALOG_XM: g.PadState[i].AnalogStatus[j][0] = 0; break;
-                                                               case ANALOG_YP: g.PadState[i].AnalogStatus[j][1] = 255; k++; break;
-                                                               case ANALOG_YM: g.PadState[i].AnalogStatus[j][1] = 0; break;
-                                                       }
-                                               } else {
-                                                       switch (k) {
-                                                               case ANALOG_XP: g.PadState[i].AnalogStatus[j][0] = 127; break;
-                                                               case ANALOG_XM: g.PadState[i].AnalogStatus[j][0] = 127; break;
-                                                               case ANALOG_YP: g.PadState[i].AnalogStatus[j][1] = 127; break;
-                                                               case ANALOG_YM: g.PadState[i].AnalogStatus[j][1] = 127; break;
-                                                       }
-                                               }
-                                               break;
-
-                                       default:
-                                               switch (k) {
-                                                       case ANALOG_XP: g.PadState[i].AnalogStatus[j][0] = 127; break;
-                                                       case ANALOG_XM: g.PadState[i].AnalogStatus[j][0] = 127; break;
-                                                       case ANALOG_YP: g.PadState[i].AnalogStatus[j][1] = 127; break;
-                                                       case ANALOG_YM: g.PadState[i].AnalogStatus[j][1] = 127; break;
-                                               }
-                                               break;
-                               }
-                       }
-               }
-       }
-}
-
-int AnalogKeyPressed(uint16_t Key) {
-       int i, j, k;
-
-       for (i = 0; i < 2; i++) {
-               if (g.cfg.PadDef[i].Type != PSE_PAD_TYPE_ANALOGPAD) {
-                       continue;
-               }
-
-               for (j = 0; j < ANALOG_TOTAL; j++) {
-                       for (k = 0; k < 4; k++) {
-                               if (g.cfg.PadDef[i].AnalogDef[j][k].Key == Key) {
-                                       g.PadState[i].AnalogKeyStatus[j][k] = 1;
-                                       return 1;
-                               }
-                       }
-               }
-       }
-
-       return 0;
-}
-
-int AnalogKeyReleased(uint16_t Key) {
-       int i, j, k;
-
-       for (i = 0; i < 2; i++) {
-               if (g.cfg.PadDef[i].Type != PSE_PAD_TYPE_ANALOGPAD) {
-                       continue;
-               }
-
-               for (j = 0; j < ANALOG_TOTAL; j++) {
-                       for (k = 0; k < 4; k++) {
-                               if (g.cfg.PadDef[i].AnalogDef[j][k].Key == Key) {
-                                       g.PadState[i].AnalogKeyStatus[j][k] = 0;
-                                       return 1;
-                               }
-                       }
-               }
-       }
-
-       return 0;
-}
diff --git a/plugins/dfinput/cfg-gtk2.c b/plugins/dfinput/cfg-gtk2.c
deleted file mode 100644 (file)
index cfbd8fa..0000000
+++ /dev/null
@@ -1,738 +0,0 @@
-/*
- * Copyright (c) 2009, Wei Mingzhi <whistler@openoffice.org>.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses>.
- */
-
-#include "cfg.c"
-
-#include <time.h>
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
-#include <glade/glade.h>
-
-GtkWidget *MainWindow;
-
-const int DPad[DKEY_TOTAL] = {
-       DKEY_UP,
-       DKEY_DOWN,
-       DKEY_LEFT,
-       DKEY_RIGHT,
-       DKEY_CROSS,
-       DKEY_CIRCLE,
-       DKEY_SQUARE,
-       DKEY_TRIANGLE,
-       DKEY_L1,
-       DKEY_R1,
-       DKEY_L2,
-       DKEY_R2,
-       DKEY_SELECT,
-       DKEY_START,
-       DKEY_L3,
-       DKEY_R3
-};
-
-const char *DPadText[DKEY_TOTAL] = {
-       N_("D-Pad Up"),
-       N_("D-Pad Down"),
-       N_("D-Pad Left"),
-       N_("D-Pad Right"),
-       N_("Cross"),
-       N_("Circle"),
-       N_("Square"),
-       N_("Triangle"),
-       N_("L1"),
-       N_("R1"),
-       N_("L2"),
-       N_("R2"),
-       N_("Select"),
-       N_("Start"),
-       N_("L3"),
-       N_("R3")
-};
-
-const char *AnalogText[] = {
-       N_("L-Stick Right"),
-       N_("L-Stick Left"),
-       N_("L-Stick Down"),
-       N_("L-Stick Up"),
-       N_("R-Stick Right"),
-       N_("R-Stick Left"),
-       N_("R-Stick Down"),
-       N_("R-Stick Up")
-};
-
-static int GetSelectedKeyIndex(int padnum) {
-       GladeXML                        *xml;
-       GtkTreeSelection        *selection;
-       GtkTreeIter                     iter;
-       GtkTreeModel            *model;
-       GtkTreePath                     *path;
-       gboolean                        selected;
-       int                                     i;
-
-       xml = glade_get_widget_tree(MainWindow);
-
-       selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(glade_xml_get_widget(xml, padnum == 0 ? "treeview1" : "treeview2")));
-       selected = gtk_tree_selection_get_selected(selection, &model, &iter);
-
-       if (!selected) {
-               return -1;
-       }
-
-       path = gtk_tree_model_get_path(model, &iter);
-       i = *gtk_tree_path_get_indices(path);
-       gtk_tree_path_free(path);
-
-       return i;
-}
-
-static void GetKeyDescription(char *buf, int joynum, int key) {
-       const char *hatname[16] = {_("Centered"), _("Up"), _("Right"), _("Rightup"),
-               _("Down"), "", _("Rightdown"), "", _("Left"), _("Leftup"), "", "",
-               _("Leftdown"), "", "", ""};
-
-       switch (g.cfg.PadDef[joynum].KeyDef[key].JoyEvType) {
-               case BUTTON:
-                       sprintf(buf, _("Joystick: Button %d"), g.cfg.PadDef[joynum].KeyDef[key].J.Button);
-                       break;
-
-               case AXIS:
-                       sprintf(buf, _("Joystick: Axis %d%c"), abs(g.cfg.PadDef[joynum].KeyDef[key].J.Axis) - 1,
-                               g.cfg.PadDef[joynum].KeyDef[key].J.Axis > 0 ? '+' : '-');
-                       break;
-
-               case HAT:
-                       sprintf(buf, _("Joystick: Hat %d %s"), (g.cfg.PadDef[joynum].KeyDef[key].J.Hat >> 8),
-                               hatname[g.cfg.PadDef[joynum].KeyDef[key].J.Hat & 0x0F]);
-                       break;
-
-               case NONE:
-               default:
-                       buf[0] = '\0';
-                       break;
-       }
-
-       if (g.cfg.PadDef[joynum].KeyDef[key].Key != 0) {
-               if (buf[0] != '\0') {
-                       strcat(buf, " / ");
-               }
-
-               strcat(buf, _("Keyboard:"));
-               strcat(buf, " ");
-               strcat(buf, XKeysymToString(g.cfg.PadDef[joynum].KeyDef[key].Key));
-       } else if (buf[0] == '\0') {
-               strcpy(buf, _("(Not Set)"));
-       }
-}
-
-static void GetAnalogDescription(char *buf, int joynum, int analognum, int dir) {
-       const char *hatname[16] = {_("Centered"), _("Up"), _("Right"), _("Rightup"),
-               _("Down"), "", _("Rightdown"), "", _("Left"), _("Leftup"), "", "",
-               _("Leftdown"), "", "", ""};
-
-       switch (g.cfg.PadDef[joynum].AnalogDef[analognum][dir].JoyEvType) {
-               case BUTTON:
-                       sprintf(buf, _("Joystick: Button %d"), g.cfg.PadDef[joynum].AnalogDef[analognum][dir].J.Button);
-                       break;
-
-               case AXIS:
-                       sprintf(buf, _("Joystick: Axis %d%c"), abs(g.cfg.PadDef[joynum].AnalogDef[analognum][dir].J.Axis) - 1,
-                               g.cfg.PadDef[joynum].AnalogDef[analognum][dir].J.Axis > 0 ? '+' : '-');
-                       break;
-
-               case HAT:
-                       sprintf(buf, _("Joystick: Hat %d %s"), (g.cfg.PadDef[joynum].AnalogDef[analognum][dir].J.Hat >> 8),
-                               hatname[g.cfg.PadDef[joynum].AnalogDef[analognum][dir].J.Hat & 0x0F]);
-                       break;
-
-               case NONE:
-               default:
-                       buf[0] = '\0';
-                       break;
-       }
-
-       if (g.cfg.PadDef[joynum].AnalogDef[analognum][dir].Key != 0) {
-               if (buf[0] != '\0') {
-                       strcat(buf, " / ");
-               }
-
-               strcat(buf, _("Keyboard:"));
-               strcat(buf, " ");
-               strcat(buf, XKeysymToString(g.cfg.PadDef[joynum].AnalogDef[analognum][dir].Key));
-       } else if (buf[0] == '\0') {
-               strcpy(buf, _("(Not Set)"));
-       }
-}
-
-static void UpdateKeyList() {
-       const char *widgetname[2] = {"treeview1", "treeview2"};
-
-       GladeXML *xml;
-       GtkWidget *widget;
-       GtkListStore *store;
-       GtkTreeIter iter;
-       int i, j;
-       char buf[256];
-
-       xml = glade_get_widget_tree(MainWindow);
-
-       for (i = 0; i < 2; i++) {
-               int total;
-
-               if (g.cfg.PadDef[i].Type == PSE_PAD_TYPE_ANALOGPAD) {
-                       total = DKEY_TOTAL;
-               } else {
-                       total = DKEY_TOTAL - 2;
-               }
-
-               widget = glade_xml_get_widget(xml, widgetname[i]);
-
-               store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
-
-               for (j = 0; j < total; j++) {
-                       gtk_list_store_append(store, &iter);
-                       GetKeyDescription(buf, i, DPad[j]);
-                       gtk_list_store_set(store, &iter, 0, _(DPadText[j]), 1, buf, -1);
-               }
-
-               if (g.cfg.PadDef[i].Type == PSE_PAD_TYPE_ANALOGPAD) {
-                       for (j = 0; j < 8; j++) {
-                               gtk_list_store_append(store, &iter);
-                               GetAnalogDescription(buf, i, j / 4, j % 4);
-                               gtk_list_store_set(store, &iter, 0, _(AnalogText[j]), 1, buf, -1);
-                       }
-               }
-
-               gtk_tree_view_set_model(GTK_TREE_VIEW(widget), GTK_TREE_MODEL(store));
-               g_object_unref(G_OBJECT(store));
-               gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(widget), TRUE);
-               gtk_widget_show(widget);
-       }
-}
-
-static void UpdateKey() {
-       const char *widgetname[2] = {"treeview1", "treeview2"};
-       int i, index;
-       GladeXML *xml;
-       GtkWidget *widget;
-       GtkTreeModel *model;
-       GtkTreeIter iter;
-       GValue value = {0, };
-       char buf[256];
-
-       xml = glade_get_widget_tree(MainWindow);
-
-       for (i = 0; i < 2; i++) {
-               index = GetSelectedKeyIndex(i);
-               if (index == -1) continue;
-
-               widget = glade_xml_get_widget(xml, widgetname[i]);
-               gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widget)), &model, &iter);
-
-               if (index < DKEY_TOTAL) {
-                       GetKeyDescription(buf, i, DPad[index]);
-               } else {
-                       GetAnalogDescription(buf, i, (index - DKEY_TOTAL) / 4, (index - DKEY_TOTAL) % 4);
-               }
-
-               g_value_init(&value, G_TYPE_STRING);
-               g_value_set_string(&value, buf);
-               gtk_list_store_set_value(GTK_LIST_STORE(model), &iter, 1, &value);
-       }
-}
-
-static void OnConfigExit(GtkWidget *widget, gpointer user_data) {
-       SavePADConfig();
-
-       gtk_widget_destroy(widget);
-       SDL_Quit();
-
-       gtk_exit(0);
-}
-
-static void TreeSelectionChanged(GtkTreeSelection *selection, gpointer user_data) {
-       GladeXML *xml;
-       GtkTreeIter iter;
-       GtkTreeModel *model;
-       GtkTreePath *path;
-
-       gboolean selected;
-       int i;
-
-       selected = gtk_tree_selection_get_selected(selection, &model, &iter);
-
-       if (selected) {
-               path = gtk_tree_model_get_path(model, &iter);
-               i = *gtk_tree_path_get_indices(path);
-               gtk_tree_path_free(path);
-
-               // If a row was selected, and the row is not blank, we can now enable
-               // some of the disabled widgets
-               xml = glade_get_widget_tree(MainWindow);
-
-               if ((int)user_data == 0) {
-                       gtk_widget_set_sensitive(GTK_WIDGET(glade_xml_get_widget(xml, "btnchange1")), TRUE);
-                       gtk_widget_set_sensitive(GTK_WIDGET(glade_xml_get_widget(xml, "btnreset1")), TRUE);
-               } else {
-                       gtk_widget_set_sensitive(GTK_WIDGET(glade_xml_get_widget(xml, "btnchange2")), TRUE);
-                       gtk_widget_set_sensitive(GTK_WIDGET(glade_xml_get_widget(xml, "btnreset2")), TRUE);
-               }
-       } else {
-               xml = glade_get_widget_tree(MainWindow);
-
-               if ((int)user_data == 0) {
-                       gtk_widget_set_sensitive(GTK_WIDGET(glade_xml_get_widget(xml, "btnchange1")), FALSE);
-                       gtk_widget_set_sensitive(GTK_WIDGET(glade_xml_get_widget(xml, "btnreset1")), FALSE);
-               } else {
-                       gtk_widget_set_sensitive(GTK_WIDGET(glade_xml_get_widget(xml, "btnchange2")), FALSE);
-                       gtk_widget_set_sensitive(GTK_WIDGET(glade_xml_get_widget(xml, "btnreset2")), FALSE);
-               }
-       }
-}
-
-static void OnDeviceChanged(GtkWidget *widget, gpointer user_data) {
-       int n = (int)user_data, current = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
-       current--;
-       g.cfg.PadDef[n].DevNum = current;
-}
-
-static void OnTypeChanged(GtkWidget *widget, gpointer user_data) {
-       int n = (int)user_data, current = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
-       g.cfg.PadDef[n].Type = (current == 0 ? PSE_PAD_TYPE_STANDARD : PSE_PAD_TYPE_ANALOGPAD);
-
-       UpdateKeyList();
-}
-
-static void OnThreadedToggled(GtkWidget *widget, gpointer user_data) {
-       g.cfg.Threaded = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
-}
-
-static void ReadDKeyEvent(int padnum, int key) {
-       SDL_Joystick *js;
-       time_t t;
-       GdkEvent *ge;
-       int i;
-       Sint16 axis, numAxes = 0, InitAxisPos[256], PrevAxisPos[256];
-
-       if (g.cfg.PadDef[padnum].DevNum >= 0) {
-               js = SDL_JoystickOpen(g.cfg.PadDef[padnum].DevNum);
-               SDL_JoystickEventState(SDL_IGNORE);
-
-               SDL_JoystickUpdate();
-
-               numAxes = SDL_JoystickNumAxes(js);
-               if (numAxes > 256) numAxes = 256;
-
-               for (i = 0; i < numAxes; i++) {
-                       InitAxisPos[i] = PrevAxisPos[i] = SDL_JoystickGetAxis(js, i);
-               }
-       } else {
-               js = NULL;
-       }
-
-       t = time(NULL);
-
-       while (time(NULL) < t + 10) {
-               // check joystick events
-               if (js != NULL) {
-                       SDL_JoystickUpdate();
-
-                       for (i = 0; i < SDL_JoystickNumButtons(js); i++) {
-                               if (SDL_JoystickGetButton(js, i)) {
-                                       g.cfg.PadDef[padnum].KeyDef[key].JoyEvType = BUTTON;
-                                       g.cfg.PadDef[padnum].KeyDef[key].J.Button = i;
-                                       goto end;
-                               }
-                       }
-
-                       for (i = 0; i < numAxes; i++) {
-                               axis = SDL_JoystickGetAxis(js, i);
-                               if (abs(axis) > 16383 && (abs(axis - InitAxisPos[i]) > 4096 || abs(axis - PrevAxisPos[i]) > 4096)) {
-                                       g.cfg.PadDef[padnum].KeyDef[key].JoyEvType = AXIS;
-                                       g.cfg.PadDef[padnum].KeyDef[key].J.Axis = (i + 1) * (axis > 0 ? 1 : -1);
-                                       goto end;
-                               }
-                               PrevAxisPos[i] = axis;
-                       }
-
-                       for (i = 0; i < SDL_JoystickNumHats(js); i++) {
-                               axis = SDL_JoystickGetHat(js, i);
-                               if (axis != SDL_HAT_CENTERED) {
-                                       g.cfg.PadDef[padnum].KeyDef[key].JoyEvType = HAT;
-
-                                       if (axis & SDL_HAT_UP) {
-                                               g.cfg.PadDef[padnum].KeyDef[key].J.Hat = ((i << 8) | SDL_HAT_UP);
-                                       } else if (axis & SDL_HAT_DOWN) {
-                                               g.cfg.PadDef[padnum].KeyDef[key].J.Hat = ((i << 8) | SDL_HAT_DOWN);
-                                       } else if (axis & SDL_HAT_LEFT) {
-                                               g.cfg.PadDef[padnum].KeyDef[key].J.Hat = ((i << 8) | SDL_HAT_LEFT);
-                                       } else if (axis & SDL_HAT_RIGHT) {
-                                               g.cfg.PadDef[padnum].KeyDef[key].J.Hat = ((i << 8) | SDL_HAT_RIGHT);
-                                       }
-
-                                       goto end;
-                               }
-                       }
-               }
-
-               // check keyboard events
-               while ((ge = gdk_event_get()) != NULL) {
-                       if (ge->type == GDK_KEY_PRESS) {
-                               if (ge->key.keyval != XK_Escape) {
-                                       g.cfg.PadDef[padnum].KeyDef[key].Key = ge->key.keyval;
-                               }
-                               gdk_event_free(ge);
-                               goto end;
-                       }
-                       gdk_event_free(ge);
-               }
-
-               usleep(5000);
-       }
-
-end:
-       if (js != NULL) {
-               SDL_JoystickClose(js);
-       }
-}
-
-static void ReadAnalogEvent(int padnum, int analognum, int analogdir) {
-       SDL_Joystick *js;
-       time_t t;
-       GdkEvent *ge;
-       int i;
-       Sint16 axis, numAxes = 0, InitAxisPos[256], PrevAxisPos[256];
-
-       if (g.cfg.PadDef[padnum].DevNum >= 0) {
-               js = SDL_JoystickOpen(g.cfg.PadDef[padnum].DevNum);
-               SDL_JoystickEventState(SDL_IGNORE);
-
-               SDL_JoystickUpdate();
-
-               numAxes = SDL_JoystickNumAxes(js);
-               if (numAxes > 256) numAxes = 256;
-
-               for (i = 0; i < SDL_JoystickNumAxes(js); i++) {
-                       InitAxisPos[i] = PrevAxisPos[i] = SDL_JoystickGetAxis(js, i);
-               }
-       } else {
-               js = NULL;
-       }
-
-       t = time(NULL);
-
-       while (time(NULL) < t + 10) {
-               // check joystick events
-               if (js != NULL) {
-                       SDL_JoystickUpdate();
-
-                       for (i = 0; i < SDL_JoystickNumButtons(js); i++) {
-                               if (SDL_JoystickGetButton(js, i)) {
-                                       g.cfg.PadDef[padnum].AnalogDef[analognum][analogdir].JoyEvType = BUTTON;
-                                       g.cfg.PadDef[padnum].AnalogDef[analognum][analogdir].J.Button = i;
-                                       goto end;
-                               }
-                       }
-
-                       for (i = 0; i < numAxes; i++) {
-                               axis = SDL_JoystickGetAxis(js, i);
-                               if (abs(axis) > 16383 && (abs(axis - InitAxisPos[i]) > 4096 || abs(axis - PrevAxisPos[i]) > 4096)) {
-                                       g.cfg.PadDef[padnum].AnalogDef[analognum][analogdir].JoyEvType = AXIS;
-                                       g.cfg.PadDef[padnum].AnalogDef[analognum][analogdir].J.Axis = (i + 1) * (axis > 0 ? 1 : -1);
-                                       goto end;
-                               }
-                               PrevAxisPos[i] = axis;
-                       }
-
-                       for (i = 0; i < SDL_JoystickNumHats(js); i++) {
-                               axis = SDL_JoystickGetHat(js, i);
-                               if (axis != SDL_HAT_CENTERED) {
-                                       g.cfg.PadDef[padnum].AnalogDef[analognum][analogdir].JoyEvType = HAT;
-
-                                       if (axis & SDL_HAT_UP) {
-                                               g.cfg.PadDef[padnum].AnalogDef[analognum][analogdir].J.Hat = ((i << 8) | SDL_HAT_UP);
-                                       } else if (axis & SDL_HAT_DOWN) {
-                                               g.cfg.PadDef[padnum].AnalogDef[analognum][analogdir].J.Hat = ((i << 8) | SDL_HAT_DOWN);
-                                       } else if (axis & SDL_HAT_LEFT) {
-                                               g.cfg.PadDef[padnum].AnalogDef[analognum][analogdir].J.Hat = ((i << 8) | SDL_HAT_LEFT);
-                                       } else if (axis & SDL_HAT_RIGHT) {
-                                               g.cfg.PadDef[padnum].AnalogDef[analognum][analogdir].J.Hat = ((i << 8) | SDL_HAT_RIGHT);
-                                       }
-
-                                       goto end;
-                               }
-                       }
-               }
-
-               // check keyboard events
-               while ((ge = gdk_event_get()) != NULL) {
-                       if (ge->type == GDK_KEY_PRESS) {
-                               if (ge->key.keyval != XK_Escape) {
-                                       g.cfg.PadDef[padnum].AnalogDef[analognum][analogdir].Key = ge->key.keyval;
-                               }
-                               gdk_event_free(ge);
-                               goto end;
-                       }
-                       gdk_event_free(ge);
-               }
-
-               usleep(5000);
-       }
-
-end:
-       if (js != NULL) {
-               SDL_JoystickClose(js);
-       }
-}
-
-static void OnChangeClicked(GtkWidget *widget, gpointer user_data) {
-       int pad = (int)user_data;
-       int index = GetSelectedKeyIndex(pad);
-
-       if (index == -1) return;
-
-       if (index < DKEY_TOTAL) {
-               ReadDKeyEvent(pad, DPad[index]);
-       } else {
-               index -= DKEY_TOTAL;
-               ReadAnalogEvent(pad, index / 4, index % 4);
-       }
-
-       UpdateKey();
-}
-
-static void OnResetClicked(GtkWidget *widget, gpointer user_data) {
-       int pad = (int)user_data;
-       int index = GetSelectedKeyIndex(pad);
-
-       if (index == -1) return;
-
-       if (index < DKEY_TOTAL) {
-               g.cfg.PadDef[pad].KeyDef[DPad[index]].Key = 0;
-               g.cfg.PadDef[pad].KeyDef[DPad[index]].JoyEvType = NONE;
-               g.cfg.PadDef[pad].KeyDef[DPad[index]].J.Button = 0;
-       } else {
-               index -= DKEY_TOTAL;
-               g.cfg.PadDef[pad].AnalogDef[index / 4][index % 4].Key = 0;
-               g.cfg.PadDef[pad].AnalogDef[index / 4][index % 4].JoyEvType = NONE;
-               g.cfg.PadDef[pad].AnalogDef[index / 4][index % 4].J.Button = 0;
-       }
-
-       UpdateKey();
-}
-
-static void PopulateDevList() {
-       const char *widgetname[2] = {"combodev1", "combodev2"};
-       int i, j, n;
-       GtkWidget *widget;
-       GladeXML *xml;
-       GtkTreeIter iter;
-       GtkListStore *store;
-       GtkCellRenderer *renderer;
-       char buf[256];
-
-       xml = glade_get_widget_tree(MainWindow);
-
-       for (i = 0; i < 2; i++) {
-               widget = glade_xml_get_widget(xml, widgetname[i]);
-
-               renderer = gtk_cell_renderer_text_new();
-               gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget), renderer, FALSE);
-               gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(widget), renderer, "text", 0);
-
-               store = gtk_list_store_new(1, G_TYPE_STRING);
-
-               gtk_list_store_append(store, &iter);
-               gtk_list_store_set(store, &iter, 0, _("None"), -1);
-
-               n = SDL_NumJoysticks();
-               for (j = 0; j < n; j++) {
-                       sprintf(buf, "%d: %s", j + 1, SDL_JoystickName(j));
-                       gtk_list_store_append(store, &iter);
-                       gtk_list_store_set(store, &iter, 0, buf, -1);
-               }
-
-               gtk_combo_box_set_model(GTK_COMBO_BOX(widget), GTK_TREE_MODEL(store));
-
-               n = g.cfg.PadDef[i].DevNum + 1;
-               if (n > SDL_NumJoysticks()) {
-                       n = 0;
-                       g.cfg.PadDef[i].DevNum = -1;
-               }
-
-               gtk_combo_box_set_active(GTK_COMBO_BOX(widget), n);
-       }
-}
-
-long PADconfigure() {
-       GladeXML *xml;
-       GtkWidget *widget;
-       GtkTreeSelection *treesel;
-       GtkTreeViewColumn *column;
-       GtkCellRenderer *renderer;
-
-       if (SDL_Init(SDL_INIT_JOYSTICK) == -1) {
-               fprintf(stderr, "Failed to initialize SDL!\n");
-               return -1;
-       }
-
-       LoadPADConfig();
-
-       xml = glade_xml_new(DATADIR "dfinput.glade2", "CfgWnd", NULL);
-       if (xml == NULL) {
-               g_warning("We could not load the interface!");
-               return -1;
-       }
-
-       MainWindow = glade_xml_get_widget(xml, "CfgWnd");
-       gtk_window_set_title(GTK_WINDOW(MainWindow), _("Gamepad/Keyboard Input Configuration"));
-
-       widget = glade_xml_get_widget(xml, "treeview1");
-
-       // column for key
-       renderer = gtk_cell_renderer_text_new();
-       column = gtk_tree_view_column_new_with_attributes(_("Key"),
-               renderer, "text", 0, NULL);
-       gtk_tree_view_append_column(GTK_TREE_VIEW(widget), column);
-
-       // column for button
-       renderer = gtk_cell_renderer_text_new();
-       column = gtk_tree_view_column_new_with_attributes(_("Button"),
-               renderer, "text", 1, NULL);
-       gtk_tree_view_append_column(GTK_TREE_VIEW(widget), column);
-
-       treesel = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
-       gtk_tree_selection_set_mode(treesel, GTK_SELECTION_SINGLE);
-
-       g_signal_connect_data(G_OBJECT(treesel), "changed",
-               G_CALLBACK(TreeSelectionChanged), (gpointer)0, NULL, G_CONNECT_AFTER);
-
-       widget = glade_xml_get_widget(xml, "treeview2");
-
-       // column for key
-       renderer = gtk_cell_renderer_text_new();
-       column = gtk_tree_view_column_new_with_attributes(_("Key"),
-               renderer, "text", 0, NULL);
-       gtk_tree_view_append_column(GTK_TREE_VIEW(widget), column);
-
-       // column for button
-       renderer = gtk_cell_renderer_text_new();
-       column = gtk_tree_view_column_new_with_attributes(_("Button"),
-               renderer, "text", 1, NULL);
-       gtk_tree_view_append_column(GTK_TREE_VIEW(widget), column);
-
-       treesel = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
-       gtk_tree_selection_set_mode(treesel, GTK_SELECTION_SINGLE);
-
-       g_signal_connect_data(G_OBJECT(treesel), "changed",
-               G_CALLBACK(TreeSelectionChanged), (gpointer)1, NULL, G_CONNECT_AFTER);
-
-       widget = glade_xml_get_widget(xml, "CfgWnd");
-       g_signal_connect_data(GTK_OBJECT(widget), "delete_event",
-               GTK_SIGNAL_FUNC(OnConfigExit), NULL, NULL, G_CONNECT_AFTER);
-
-       widget = glade_xml_get_widget(xml, "btnclose");
-       g_signal_connect_data(GTK_OBJECT(widget), "clicked",
-               GTK_SIGNAL_FUNC(OnConfigExit), NULL, NULL, G_CONNECT_AFTER);
-
-       PopulateDevList();
-       UpdateKeyList();
-
-       widget = glade_xml_get_widget(xml, "checkmt");
-       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), g.cfg.Threaded);
-       g_signal_connect_data(GTK_OBJECT(widget), "toggled",
-               GTK_SIGNAL_FUNC(OnThreadedToggled), NULL, NULL, G_CONNECT_AFTER);
-
-       widget = glade_xml_get_widget(xml, "combodev1");
-       g_signal_connect_data(GTK_OBJECT(widget), "changed",
-               GTK_SIGNAL_FUNC(OnDeviceChanged), (gpointer)0, NULL, G_CONNECT_AFTER);
-
-       widget = glade_xml_get_widget(xml, "combodev2");
-       g_signal_connect_data(GTK_OBJECT(widget), "changed",
-               GTK_SIGNAL_FUNC(OnDeviceChanged), (gpointer)1, NULL, G_CONNECT_AFTER);
-
-       widget = glade_xml_get_widget(xml, "combotype1");
-       gtk_combo_box_set_active(GTK_COMBO_BOX(widget),
-               g.cfg.PadDef[0].Type == PSE_PAD_TYPE_ANALOGPAD ? 1 : 0);
-       g_signal_connect_data(GTK_OBJECT(widget), "changed",
-               GTK_SIGNAL_FUNC(OnTypeChanged), (gpointer)0, NULL, G_CONNECT_AFTER);
-
-       widget = glade_xml_get_widget(xml, "combotype2");
-       gtk_combo_box_set_active(GTK_COMBO_BOX(widget),
-               g.cfg.PadDef[1].Type == PSE_PAD_TYPE_ANALOGPAD ? 1 : 0);
-       g_signal_connect_data(GTK_OBJECT(widget), "changed",
-               GTK_SIGNAL_FUNC(OnTypeChanged), (gpointer)1, NULL, G_CONNECT_AFTER);
-
-       widget = glade_xml_get_widget(xml, "btnchange1");
-       gtk_widget_set_sensitive(widget, FALSE);
-       g_signal_connect_data(GTK_OBJECT(widget), "clicked",
-               GTK_SIGNAL_FUNC(OnChangeClicked), (gpointer)0, NULL, G_CONNECT_AFTER);
-
-       widget = glade_xml_get_widget(xml, "btnreset1");
-       gtk_widget_set_sensitive(widget, FALSE);
-       g_signal_connect_data(GTK_OBJECT(widget), "clicked",
-               GTK_SIGNAL_FUNC(OnResetClicked), (gpointer)0, NULL, G_CONNECT_AFTER);
-
-       widget = glade_xml_get_widget(xml, "btnchange2");
-       gtk_widget_set_sensitive(widget, FALSE);
-       g_signal_connect_data(GTK_OBJECT(widget), "clicked",
-               GTK_SIGNAL_FUNC(OnChangeClicked), (gpointer)1, NULL, G_CONNECT_AFTER);
-
-       widget = glade_xml_get_widget(xml, "btnreset2");
-       gtk_widget_set_sensitive(widget, FALSE);
-       g_signal_connect_data(GTK_OBJECT(widget), "clicked",
-               GTK_SIGNAL_FUNC(OnResetClicked), (gpointer)1, NULL, G_CONNECT_AFTER);
-
-       gtk_widget_show(MainWindow);
-       gtk_main();
-
-       return 0;
-}
-
-void PADabout() {
-       const char *authors[]= {"Wei Mingzhi <weimingzhi@gmail.com>", NULL};
-       GtkWidget *widget;
-
-       widget = gtk_about_dialog_new();
-       gtk_about_dialog_set_name(GTK_ABOUT_DIALOG(widget), "Gamepad/Keyboard Input");
-       gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(widget), "1.1");
-       gtk_about_dialog_set_authors(GTK_ABOUT_DIALOG(widget), authors);
-       gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(widget), "http://www.codeplex.com/pcsxr/");
-
-       gtk_dialog_run(GTK_DIALOG(widget));
-       gtk_widget_destroy(widget);
-}
-
-int main(int argc, char *argv[]) {
-#ifdef ENABLE_NLS
-       setlocale(LC_ALL, "");
-       bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR);
-       bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
-       textdomain(GETTEXT_PACKAGE);
-#endif
-
-       gtk_set_locale();
-       gtk_init(&argc, &argv);
-
-       if (argc > 1 && !strcmp(argv[1], "-about")) {
-               PADabout();
-       } else {
-               PADconfigure();
-       }
-
-       gtk_exit(0);
-       return 0;
-}
diff --git a/plugins/dfinput/cfg.c b/plugins/dfinput/cfg.c
deleted file mode 100644 (file)
index ce9a97f..0000000
+++ /dev/null
@@ -1,346 +0,0 @@
-/*
- * Copyright (c) 2009, Wei Mingzhi <whistler@openoffice.org>.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses>.
- */
-
-#include "pad.h"
-
-#define CONFIG_FILE            "dfinput.cfg"
-
-GLOBALDATA                     g;
-
-static void SetDefaultConfig() {
-       memset(&g.cfg, 0, sizeof(g.cfg));
-
-       g.cfg.Threaded = 1;
-
-       g.cfg.PadDef[0].DevNum = 0;
-       g.cfg.PadDef[1].DevNum = 1;
-
-       g.cfg.PadDef[0].Type = PSE_PAD_TYPE_STANDARD;
-       g.cfg.PadDef[1].Type = PSE_PAD_TYPE_STANDARD;
-
-       // Pad1 keyboard
-       g.cfg.PadDef[0].KeyDef[DKEY_SELECT].Key = XK_c;
-       g.cfg.PadDef[0].KeyDef[DKEY_START].Key = XK_v;
-       g.cfg.PadDef[0].KeyDef[DKEY_UP].Key = XK_Up;
-       g.cfg.PadDef[0].KeyDef[DKEY_RIGHT].Key = XK_Right;
-       g.cfg.PadDef[0].KeyDef[DKEY_DOWN].Key = XK_Down;
-       g.cfg.PadDef[0].KeyDef[DKEY_LEFT].Key = XK_Left;
-       g.cfg.PadDef[0].KeyDef[DKEY_L2].Key = XK_e;
-       g.cfg.PadDef[0].KeyDef[DKEY_R2].Key = XK_t;
-       g.cfg.PadDef[0].KeyDef[DKEY_L1].Key = XK_w;
-       g.cfg.PadDef[0].KeyDef[DKEY_R1].Key = XK_r;
-       g.cfg.PadDef[0].KeyDef[DKEY_TRIANGLE].Key = XK_d;
-       g.cfg.PadDef[0].KeyDef[DKEY_CIRCLE].Key = XK_x;
-       g.cfg.PadDef[0].KeyDef[DKEY_CROSS].Key = XK_z;
-       g.cfg.PadDef[0].KeyDef[DKEY_SQUARE].Key = XK_s;
-
-       // Pad1 joystick
-       g.cfg.PadDef[0].KeyDef[DKEY_SELECT].JoyEvType = BUTTON;
-       g.cfg.PadDef[0].KeyDef[DKEY_SELECT].J.Button = 8;
-       g.cfg.PadDef[0].KeyDef[DKEY_START].JoyEvType = BUTTON;
-       g.cfg.PadDef[0].KeyDef[DKEY_START].J.Button = 9;
-       g.cfg.PadDef[0].KeyDef[DKEY_UP].JoyEvType = AXIS;
-       g.cfg.PadDef[0].KeyDef[DKEY_UP].J.Axis = -2;
-       g.cfg.PadDef[0].KeyDef[DKEY_RIGHT].JoyEvType = AXIS;
-       g.cfg.PadDef[0].KeyDef[DKEY_RIGHT].J.Axis = 1;
-       g.cfg.PadDef[0].KeyDef[DKEY_DOWN].JoyEvType = AXIS;
-       g.cfg.PadDef[0].KeyDef[DKEY_DOWN].J.Axis = 2;
-       g.cfg.PadDef[0].KeyDef[DKEY_LEFT].JoyEvType = AXIS;
-       g.cfg.PadDef[0].KeyDef[DKEY_LEFT].J.Axis = -1;
-       g.cfg.PadDef[0].KeyDef[DKEY_L2].JoyEvType = BUTTON;
-       g.cfg.PadDef[0].KeyDef[DKEY_L2].J.Button = 4;
-       g.cfg.PadDef[0].KeyDef[DKEY_L1].JoyEvType = BUTTON;
-       g.cfg.PadDef[0].KeyDef[DKEY_L1].J.Button = 6;
-       g.cfg.PadDef[0].KeyDef[DKEY_R2].JoyEvType = BUTTON;
-       g.cfg.PadDef[0].KeyDef[DKEY_R2].J.Button = 5;
-       g.cfg.PadDef[0].KeyDef[DKEY_R1].JoyEvType = BUTTON;
-       g.cfg.PadDef[0].KeyDef[DKEY_R1].J.Button = 7;
-       g.cfg.PadDef[0].KeyDef[DKEY_TRIANGLE].JoyEvType = BUTTON;
-       g.cfg.PadDef[0].KeyDef[DKEY_TRIANGLE].J.Button = 0;
-       g.cfg.PadDef[0].KeyDef[DKEY_CIRCLE].JoyEvType = BUTTON;
-       g.cfg.PadDef[0].KeyDef[DKEY_CIRCLE].J.Button = 1;
-       g.cfg.PadDef[0].KeyDef[DKEY_CROSS].JoyEvType = BUTTON;
-       g.cfg.PadDef[0].KeyDef[DKEY_CROSS].J.Button = 2;
-       g.cfg.PadDef[0].KeyDef[DKEY_SQUARE].JoyEvType = BUTTON;
-       g.cfg.PadDef[0].KeyDef[DKEY_SQUARE].J.Button = 3;
-
-       // Pad2 joystick
-       g.cfg.PadDef[1].KeyDef[DKEY_SELECT].JoyEvType = BUTTON;
-       g.cfg.PadDef[1].KeyDef[DKEY_SELECT].J.Button = 8;
-       g.cfg.PadDef[1].KeyDef[DKEY_START].JoyEvType = BUTTON;
-       g.cfg.PadDef[1].KeyDef[DKEY_START].J.Button = 9;
-       g.cfg.PadDef[1].KeyDef[DKEY_UP].JoyEvType = AXIS;
-       g.cfg.PadDef[1].KeyDef[DKEY_UP].J.Axis = -2;
-       g.cfg.PadDef[1].KeyDef[DKEY_RIGHT].JoyEvType = AXIS;
-       g.cfg.PadDef[1].KeyDef[DKEY_RIGHT].J.Axis = 1;
-       g.cfg.PadDef[1].KeyDef[DKEY_DOWN].JoyEvType = AXIS;
-       g.cfg.PadDef[1].KeyDef[DKEY_DOWN].J.Axis = 2;
-       g.cfg.PadDef[1].KeyDef[DKEY_LEFT].JoyEvType = AXIS;
-       g.cfg.PadDef[1].KeyDef[DKEY_LEFT].J.Axis = -1;
-       g.cfg.PadDef[1].KeyDef[DKEY_L2].JoyEvType = BUTTON;
-       g.cfg.PadDef[1].KeyDef[DKEY_L2].J.Button = 4;
-       g.cfg.PadDef[1].KeyDef[DKEY_L1].JoyEvType = BUTTON;
-       g.cfg.PadDef[1].KeyDef[DKEY_L1].J.Button = 6;
-       g.cfg.PadDef[1].KeyDef[DKEY_R2].JoyEvType = BUTTON;
-       g.cfg.PadDef[1].KeyDef[DKEY_R2].J.Button = 5;
-       g.cfg.PadDef[1].KeyDef[DKEY_R1].JoyEvType = BUTTON;
-       g.cfg.PadDef[1].KeyDef[DKEY_R1].J.Button = 7;
-       g.cfg.PadDef[1].KeyDef[DKEY_TRIANGLE].JoyEvType = BUTTON;
-       g.cfg.PadDef[1].KeyDef[DKEY_TRIANGLE].J.Button = 0;
-       g.cfg.PadDef[1].KeyDef[DKEY_CIRCLE].JoyEvType = BUTTON;
-       g.cfg.PadDef[1].KeyDef[DKEY_CIRCLE].J.Button = 1;
-       g.cfg.PadDef[1].KeyDef[DKEY_CROSS].JoyEvType = BUTTON;
-       g.cfg.PadDef[1].KeyDef[DKEY_CROSS].J.Button = 2;
-       g.cfg.PadDef[1].KeyDef[DKEY_SQUARE].JoyEvType = BUTTON;
-       g.cfg.PadDef[1].KeyDef[DKEY_SQUARE].J.Button = 3;
-}
-
-void LoadPADConfig() {
-       FILE            *fp;
-       char            buf[256];
-       int                     current, a, b, c;
-
-       SetDefaultConfig();
-
-       fp = fopen(CONFIG_FILE, "r");
-       if (fp == NULL) {
-               return;
-       }
-
-       current = 0;
-
-       while (fgets(buf, 256, fp) != NULL) {
-               if (strncmp(buf, "Threaded=", 9) == 0) {
-                       g.cfg.Threaded = atoi(&buf[9]);
-               } else if (strncmp(buf, "[PAD", 4) == 0) {
-                       current = atoi(&buf[4]) - 1;
-                       if (current < 0) {
-                               current = 0;
-                       } else if (current > 1) {
-                               current = 1;
-                       }
-               } else if (strncmp(buf, "DevNum=", 7) == 0) {
-                       g.cfg.PadDef[current].DevNum = atoi(&buf[7]);
-               } else if (strncmp(buf, "Type=", 5) == 0) {
-                       g.cfg.PadDef[current].Type = atoi(&buf[5]);
-               } else if (strncmp(buf, "Select=", 7) == 0) {
-                       sscanf(buf, "Select=%d,%d,%d", &a, &b, &c);
-                       g.cfg.PadDef[current].KeyDef[DKEY_SELECT].Key = a;
-                       g.cfg.PadDef[current].KeyDef[DKEY_SELECT].JoyEvType = b;
-                       g.cfg.PadDef[current].KeyDef[DKEY_SELECT].J.d = c;
-               } else if (strncmp(buf, "L3=", 3) == 0) {
-                       sscanf(buf, "L3=%d,%d,%d", &a, &b, &c);
-                       g.cfg.PadDef[current].KeyDef[DKEY_L3].Key = a;
-                       g.cfg.PadDef[current].KeyDef[DKEY_L3].JoyEvType = b;
-                       g.cfg.PadDef[current].KeyDef[DKEY_L3].J.d = c;
-               } else if (strncmp(buf, "R3=", 3) == 0) {
-                       sscanf(buf, "R3=%d,%d,%d", &a, &b, &c);
-                       g.cfg.PadDef[current].KeyDef[DKEY_R3].Key = a;
-                       g.cfg.PadDef[current].KeyDef[DKEY_R3].JoyEvType = b;
-                       g.cfg.PadDef[current].KeyDef[DKEY_R3].J.d = c;
-               } else if (strncmp(buf, "Start=", 6) == 0) {
-                       sscanf(buf, "Start=%d,%d,%d", &a, &b, &c);
-                       g.cfg.PadDef[current].KeyDef[DKEY_START].Key = a;
-                       g.cfg.PadDef[current].KeyDef[DKEY_START].JoyEvType = b;
-                       g.cfg.PadDef[current].KeyDef[DKEY_START].J.d = c;
-               } else if (strncmp(buf, "Up=", 3) == 0) {
-                       sscanf(buf, "Up=%d,%d,%d", &a, &b, &c);
-                       g.cfg.PadDef[current].KeyDef[DKEY_UP].Key = a;
-                       g.cfg.PadDef[current].KeyDef[DKEY_UP].JoyEvType = b;
-                       g.cfg.PadDef[current].KeyDef[DKEY_UP].J.d = c;
-               } else if (strncmp(buf, "Right=", 6) == 0) {
-                       sscanf(buf, "Right=%d,%d,%d", &a, &b, &c);
-                       g.cfg.PadDef[current].KeyDef[DKEY_RIGHT].Key = a;
-                       g.cfg.PadDef[current].KeyDef[DKEY_RIGHT].JoyEvType = b;
-                       g.cfg.PadDef[current].KeyDef[DKEY_RIGHT].J.d = c;
-               } else if (strncmp(buf, "Down=", 5) == 0) {
-                       sscanf(buf, "Down=%d,%d,%d", &a, &b, &c);
-                       g.cfg.PadDef[current].KeyDef[DKEY_DOWN].Key = a;
-                       g.cfg.PadDef[current].KeyDef[DKEY_DOWN].JoyEvType = b;
-                       g.cfg.PadDef[current].KeyDef[DKEY_DOWN].J.d = c;
-               } else if (strncmp(buf, "Left=", 5) == 0) {
-                       sscanf(buf, "Left=%d,%d,%d", &a, &b, &c);
-                       g.cfg.PadDef[current].KeyDef[DKEY_LEFT].Key = a;
-                       g.cfg.PadDef[current].KeyDef[DKEY_LEFT].JoyEvType = b;
-                       g.cfg.PadDef[current].KeyDef[DKEY_LEFT].J.d = c;
-               } else if (strncmp(buf, "L2=", 3) == 0) {
-                       sscanf(buf, "L2=%d,%d,%d", &a, &b, &c);
-                       g.cfg.PadDef[current].KeyDef[DKEY_L2].Key = a;
-                       g.cfg.PadDef[current].KeyDef[DKEY_L2].JoyEvType = b;
-                       g.cfg.PadDef[current].KeyDef[DKEY_L2].J.d = c;
-               } else if (strncmp(buf, "R2=", 3) == 0) {
-                       sscanf(buf, "R2=%d,%d,%d", &a, &b, &c);
-                       g.cfg.PadDef[current].KeyDef[DKEY_R2].Key = a;
-                       g.cfg.PadDef[current].KeyDef[DKEY_R2].JoyEvType = b;
-                       g.cfg.PadDef[current].KeyDef[DKEY_R2].J.d = c;
-               } else if (strncmp(buf, "L1=", 3) == 0) {
-                       sscanf(buf, "L1=%d,%d,%d", &a, &b, &c);
-                       g.cfg.PadDef[current].KeyDef[DKEY_L1].Key = a;
-                       g.cfg.PadDef[current].KeyDef[DKEY_L1].JoyEvType = b;
-                       g.cfg.PadDef[current].KeyDef[DKEY_L1].J.d = c;
-               } else if (strncmp(buf, "R1=", 3) == 0) {
-                       sscanf(buf, "R1=%d,%d,%d", &a, &b, &c);
-                       g.cfg.PadDef[current].KeyDef[DKEY_R1].Key = a;
-                       g.cfg.PadDef[current].KeyDef[DKEY_R1].JoyEvType = b;
-                       g.cfg.PadDef[current].KeyDef[DKEY_R1].J.d = c;
-               } else if (strncmp(buf, "Triangle=", 9) == 0) {
-                       sscanf(buf, "Triangle=%d,%d,%d", &a, &b, &c);
-                       g.cfg.PadDef[current].KeyDef[DKEY_TRIANGLE].Key = a;
-                       g.cfg.PadDef[current].KeyDef[DKEY_TRIANGLE].JoyEvType = b;
-                       g.cfg.PadDef[current].KeyDef[DKEY_TRIANGLE].J.d = c;
-               } else if (strncmp(buf, "Circle=", 7) == 0) {
-                       sscanf(buf, "Circle=%d,%d,%d", &a, &b, &c);
-                       g.cfg.PadDef[current].KeyDef[DKEY_CIRCLE].Key = a;
-                       g.cfg.PadDef[current].KeyDef[DKEY_CIRCLE].JoyEvType = b;
-                       g.cfg.PadDef[current].KeyDef[DKEY_CIRCLE].J.d = c;
-               } else if (strncmp(buf, "Cross=", 6) == 0) {
-                       sscanf(buf, "Cross=%d,%d,%d", &a, &b, &c);
-                       g.cfg.PadDef[current].KeyDef[DKEY_CROSS].Key = a;
-                       g.cfg.PadDef[current].KeyDef[DKEY_CROSS].JoyEvType = b;
-                       g.cfg.PadDef[current].KeyDef[DKEY_CROSS].J.d = c;
-               } else if (strncmp(buf, "Square=", 7) == 0) {
-                       sscanf(buf, "Square=%d,%d,%d", &a, &b, &c);
-                       g.cfg.PadDef[current].KeyDef[DKEY_SQUARE].Key = a;
-                       g.cfg.PadDef[current].KeyDef[DKEY_SQUARE].JoyEvType = b;
-                       g.cfg.PadDef[current].KeyDef[DKEY_SQUARE].J.d = c;
-               } else if (strncmp(buf, "LeftAnalogXP=", 13) == 0) {
-                       sscanf(buf, "LeftAnalogXP=%d,%d,%d", &a, &b, &c);
-                       g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_XP].Key = a;
-                       g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_XP].JoyEvType = b;
-                       g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_XP].J.d = c;
-               } else if (strncmp(buf, "LeftAnalogXM=", 13) == 0) {
-                       sscanf(buf, "LeftAnalogXM=%d,%d,%d", &a, &b, &c);
-                       g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_XM].Key = a;
-                       g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_XM].JoyEvType = b;
-                       g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_XM].J.d = c;
-               } else if (strncmp(buf, "LeftAnalogYP=", 13) == 0) {
-                       sscanf(buf, "LeftAnalogYP=%d,%d,%d", &a, &b, &c);
-                       g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_YP].Key = a;
-                       g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_YP].JoyEvType = b;
-                       g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_YP].J.d = c;
-               } else if (strncmp(buf, "LeftAnalogYM=", 13) == 0) {
-                       sscanf(buf, "LeftAnalogYM=%d,%d,%d", &a, &b, &c);
-                       g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_YM].Key = a;
-                       g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_YM].JoyEvType = b;
-                       g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_YM].J.d = c;
-               } else if (strncmp(buf, "RightAnalogXP=", 14) == 0) {
-                       sscanf(buf, "RightAnalogXP=%d,%d,%d", &a, &b, &c);
-                       g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_XP].Key = a;
-                       g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_XP].JoyEvType = b;
-                       g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_XP].J.d = c;
-               } else if (strncmp(buf, "RightAnalogXM=", 14) == 0) {
-                       sscanf(buf, "RightAnalogXM=%d,%d,%d", &a, &b, &c);
-                       g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_XM].Key = a;
-                       g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_XM].JoyEvType = b;
-                       g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_XM].J.d = c;
-               } else if (strncmp(buf, "RightAnalogYP=", 14) == 0) {
-                       sscanf(buf, "RightAnalogYP=%d,%d,%d", &a, &b, &c);
-                       g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_YP].Key = a;
-                       g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_YP].JoyEvType = b;
-                       g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_YP].J.d = c;
-               } else if (strncmp(buf, "RightAnalogYM=", 14) == 0) {
-                       sscanf(buf, "RightAnalogYM=%d,%d,%d", &a, &b, &c);
-                       g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_YM].Key = a;
-                       g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_YM].JoyEvType = b;
-                       g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_YM].J.d = c;
-               }
-       }
-
-       fclose(fp);
-}
-
-void SavePADConfig() {
-       FILE            *fp;
-       int                     i;
-
-       fp = fopen(CONFIG_FILE, "w");
-       if (fp == NULL) {
-               return;
-       }
-
-       fprintf(fp, "[CONFIG]\n");
-       fprintf(fp, "Threaded=%d\n", g.cfg.Threaded);
-       fprintf(fp, "\n");
-
-       for (i = 0; i < 2; i++) {
-               fprintf(fp, "[PAD%d]\n", i + 1);
-               fprintf(fp, "DevNum=%d\n", g.cfg.PadDef[i].DevNum);
-               fprintf(fp, "Type=%d\n", g.cfg.PadDef[i].Type);
-
-               fprintf(fp, "Select=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_SELECT].Key,
-                       g.cfg.PadDef[i].KeyDef[DKEY_SELECT].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_SELECT].J.d);
-               fprintf(fp, "L3=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_L3].Key,
-                       g.cfg.PadDef[i].KeyDef[DKEY_L3].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_L3].J.d);
-               fprintf(fp, "R3=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_R3].Key,
-                       g.cfg.PadDef[i].KeyDef[DKEY_R3].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_R3].J.d);
-               fprintf(fp, "Start=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_START].Key,
-                       g.cfg.PadDef[i].KeyDef[DKEY_START].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_START].J.d);
-               fprintf(fp, "Up=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_UP].Key,
-                       g.cfg.PadDef[i].KeyDef[DKEY_UP].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_UP].J.d);
-               fprintf(fp, "Right=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_RIGHT].Key,
-                       g.cfg.PadDef[i].KeyDef[DKEY_RIGHT].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_RIGHT].J.d);
-               fprintf(fp, "Down=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_DOWN].Key,
-                       g.cfg.PadDef[i].KeyDef[DKEY_DOWN].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_DOWN].J.d);
-               fprintf(fp, "Left=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_LEFT].Key,
-                       g.cfg.PadDef[i].KeyDef[DKEY_LEFT].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_LEFT].J.d);
-               fprintf(fp, "L2=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_L2].Key,
-                       g.cfg.PadDef[i].KeyDef[DKEY_L2].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_L2].J.d);
-               fprintf(fp, "R2=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_R2].Key,
-                       g.cfg.PadDef[i].KeyDef[DKEY_R2].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_R2].J.d);
-               fprintf(fp, "L1=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_L1].Key,
-                       g.cfg.PadDef[i].KeyDef[DKEY_L1].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_L1].J.d);
-               fprintf(fp, "R1=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_R1].Key,
-                       g.cfg.PadDef[i].KeyDef[DKEY_R1].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_R1].J.d);
-               fprintf(fp, "Triangle=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_TRIANGLE].Key,
-                       g.cfg.PadDef[i].KeyDef[DKEY_TRIANGLE].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_TRIANGLE].J.d);
-               fprintf(fp, "Circle=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_CIRCLE].Key,
-                       g.cfg.PadDef[i].KeyDef[DKEY_CIRCLE].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_CIRCLE].J.d);
-               fprintf(fp, "Cross=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_CROSS].Key,
-                       g.cfg.PadDef[i].KeyDef[DKEY_CROSS].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_CROSS].J.d);
-               fprintf(fp, "Square=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_SQUARE].Key,
-                       g.cfg.PadDef[i].KeyDef[DKEY_SQUARE].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_SQUARE].J.d);
-               fprintf(fp, "LeftAnalogXP=%d,%d,%d\n", g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_XP].Key,
-                       g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_XP].JoyEvType,
-                       g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_XP].J.d);
-               fprintf(fp, "LeftAnalogXM=%d,%d,%d\n", g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_XM].Key,
-                       g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_XM].JoyEvType,
-                       g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_XM].J.d);
-               fprintf(fp, "LeftAnalogYP=%d,%d,%d\n", g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_YP].Key,
-                       g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_YP].JoyEvType,
-                       g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_YP].J.d);
-               fprintf(fp, "LeftAnalogYM=%d,%d,%d\n", g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_YM].Key,
-                       g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_YM].JoyEvType,
-                       g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_YM].J.d);
-               fprintf(fp, "RightAnalogXP=%d,%d,%d\n", g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_XP].Key,
-                       g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_XP].JoyEvType,
-                       g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_XP].J.d);
-               fprintf(fp, "RightAnalogXM=%d,%d,%d\n", g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_XM].Key,
-                       g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_XM].JoyEvType,
-                       g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_XM].J.d);
-               fprintf(fp, "RightAnalogYP=%d,%d,%d\n", g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_YP].Key,
-                       g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_YP].JoyEvType,
-                       g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_YP].J.d);
-               fprintf(fp, "RightAnalogYM=%d,%d,%d\n", g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_YM].Key,
-                       g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_YM].JoyEvType,
-                       g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_YM].J.d);
-
-               fprintf(fp, "\n");
-       }
-
-       fclose(fp);
-}
diff --git a/plugins/dfinput/pad.c b/plugins/dfinput/pad.c
deleted file mode 100644 (file)
index a0207aa..0000000
+++ /dev/null
@@ -1,392 +0,0 @@
-/*
- * Copyright (c) 2009, Wei Mingzhi <whistler@openoffice.org>.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses>.
- */
-
-#include "pad.h"
-
-char *PSEgetLibName(void) {
-       return _("Gamepad/Keyboard Input");
-}
-
-uint32_t PSEgetLibType(void) {
-       return PSE_LT_PAD;
-}
-
-uint32_t PSEgetLibVersion(void) {
-       return (1 << 16) | (1 << 8);
-}
-
-long PADinit(long flags) {
-       LoadPADConfig();
-
-       g.PadState[0].PadMode = 0;
-       g.PadState[0].PadID = 0x41;
-       g.PadState[1].PadMode = 0;
-       g.PadState[1].PadID = 0x41;
-
-       return PSE_PAD_ERR_SUCCESS;
-}
-
-long PADshutdown(void) {
-       PADclose();
-       return PSE_PAD_ERR_SUCCESS;
-}
-
-static pthread_t                       ThreadID;
-static volatile uint8_t                TerminateThread = 0;
-
-static void *JoyThread(void *param) {
-       while (!TerminateThread) {
-               CheckJoy();
-               usleep(1000);
-       }
-       pthread_exit(0);
-       return NULL;
-}
-
-long PADopen(unsigned long *Disp) {
-       g.Disp = (Display *)*Disp;
-
-       if (!g.Opened) {
-               if (SDL_WasInit(SDL_INIT_EVERYTHING)) {
-                       if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) == -1) {
-                               return PSE_PAD_ERR_FAILURE;
-                       }
-               } else if (SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE) == -1) {
-                       return PSE_PAD_ERR_FAILURE;
-               }
-
-               InitSDLJoy();
-               InitKeyboard();
-
-               g.KeyLeftOver = 0;
-
-               if (g.cfg.Threaded) {
-                       TerminateThread = 0;
-
-                       if (pthread_create(&ThreadID, NULL, JoyThread, NULL) != 0) {
-                               // thread creation failed, fallback to polling
-                               g.cfg.Threaded = 0;
-                       }
-               }
-       }
-
-       g.Opened = 1;
-
-       return PSE_PAD_ERR_SUCCESS;
-}
-
-long PADclose(void) {
-       if (g.Opened) {
-               if (g.cfg.Threaded) {
-                       TerminateThread = 1;
-                       pthread_join(ThreadID, NULL);
-               }
-
-               DestroySDLJoy();
-               DestroyKeyboard();
-
-               if (SDL_WasInit(SDL_INIT_EVERYTHING & ~SDL_INIT_JOYSTICK)) {
-                       SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
-               } else {
-                       SDL_Quit();
-               }
-       }
-
-       g.Opened = 0;
-
-       return PSE_PAD_ERR_SUCCESS;
-}
-
-long PADquery(void) {
-       return PSE_PAD_USE_PORT1 | PSE_PAD_USE_PORT2;
-}
-
-static void UpdateInput(void) {
-       if (!g.cfg.Threaded) CheckJoy();
-       CheckKeyboard();
-}
-
-static uint8_t stdpar[2][8] = {
-       {0xFF, 0x5A, 0xFF, 0xFF, 0x80, 0x80, 0x80, 0x80},
-       {0xFF, 0x5A, 0xFF, 0xFF, 0x80, 0x80, 0x80, 0x80}
-};
-
-static uint8_t unk46[2][8] = {
-       {0xFF, 0x5A, 0x00, 0x00, 0x01, 0x02, 0x00, 0x0A},
-       {0xFF, 0x5A, 0x00, 0x00, 0x01, 0x02, 0x00, 0x0A}
-};
-
-static uint8_t unk47[2][8] = {
-       {0xFF, 0x5A, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00},
-       {0xFF, 0x5A, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00}
-};
-
-static uint8_t unk4c[2][8] = {
-       {0xFF, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
-       {0xFF, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
-};
-
-static uint8_t unk4d[2][8] = { 
-       {0xFF, 0x5A, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
-       {0xFF, 0x5A, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}
-};
-
-static uint8_t stdcfg[2][8]   = { 
-       {0xFF, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
-       {0xFF, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
-};
-
-static uint8_t stdmode[2][8]  = { 
-       {0xFF, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
-       {0xFF, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
-};
-
-static uint8_t stdmodel[2][8] = { 
-       {0xFF,
-        0x5A,
-        0x01, // 03 - dualshock2, 01 - dualshock
-        0x02, // number of modes
-        0x01, // current mode: 01 - analog, 00 - digital
-        0x02,
-        0x01,
-        0x00},
-       {0xFF, 
-        0x5A,
-        0x01, // 03 - dualshock2, 01 - dualshock
-        0x02, // number of modes
-        0x01, // current mode: 01 - analog, 00 - digital
-        0x02,
-        0x01,
-        0x00}
-};
-
-static uint8_t CurPad = 0, CurByte = 0, CurCmd = 0, CmdLen = 0;
-
-unsigned char PADstartPoll(int pad) {
-       CurPad = pad - 1;
-       CurByte = 0;
-
-       return 0xFF;
-}
-
-unsigned char PADpoll(unsigned char value) {
-       static uint8_t          *buf = NULL;
-       uint16_t                        n;
-
-       if (CurByte == 0) {
-               CurByte++;
-
-               // Don't enable Analog/Vibration for a standard pad
-               if (g.cfg.PadDef[CurPad].Type != PSE_PAD_TYPE_ANALOGPAD) {
-                       CurCmd = CMD_READ_DATA_AND_VIBRATE;
-               } else {
-                       CurCmd = value;
-               }
-
-               switch (CurCmd) {
-                       case CMD_CONFIG_MODE:
-                               CmdLen = 8;
-                               buf = stdcfg[CurPad];
-                               if (stdcfg[CurPad][3] == 0xFF) return 0xF3;
-                               else return g.PadState[CurPad].PadID;
-
-                       case CMD_SET_MODE_AND_LOCK:
-                               CmdLen = 8;
-                               buf = stdmode[CurPad];
-                               return 0xF3;
-
-                       case CMD_QUERY_MODEL_AND_MODE:
-                               CmdLen = 8;
-                               buf = stdmodel[CurPad];
-                               buf[4] = g.PadState[CurPad].PadMode;
-                               return 0xF3;
-
-                       case CMD_QUERY_ACT:
-                               CmdLen = 8;
-                               buf = unk46[CurPad];
-                               return 0xF3;
-
-                       case CMD_QUERY_COMB:
-                               CmdLen = 8;
-                               buf = unk47[CurPad];
-                               return 0xF3;
-
-                       case CMD_QUERY_MODE:
-                               CmdLen = 8;
-                               buf = unk4c[CurPad];
-                               return 0xF3;
-
-                       case CMD_VIBRATION_TOGGLE:
-                               CmdLen = 8;
-                               buf = unk4d[CurPad];
-                               return 0xF3;
-
-                       case CMD_READ_DATA_AND_VIBRATE:
-                       default:
-                               UpdateInput();
-
-                               n = g.PadState[CurPad].KeyStatus;
-                               n &= g.PadState[CurPad].JoyKeyStatus;
-
-                               stdpar[CurPad][2] = n & 0xFF;
-                               stdpar[CurPad][3] = n >> 8;
-
-                               if (g.PadState[CurPad].PadMode == 1) {
-                                       CmdLen = 8;
-
-                                       stdpar[CurPad][4] = g.PadState[CurPad].AnalogStatus[ANALOG_RIGHT][0];
-                                       stdpar[CurPad][5] = g.PadState[CurPad].AnalogStatus[ANALOG_RIGHT][1];
-                                       stdpar[CurPad][6] = g.PadState[CurPad].AnalogStatus[ANALOG_LEFT][0];
-                                       stdpar[CurPad][7] = g.PadState[CurPad].AnalogStatus[ANALOG_LEFT][1];
-                               } else {
-                                       CmdLen = 4;
-                               }
-
-                               buf = stdpar[CurPad];
-                               return g.PadState[CurPad].PadID;
-               }
-       }
-
-       switch (CurCmd) {
-               case CMD_CONFIG_MODE:
-                       if (CurByte == 2) {
-                               switch (value) {
-                                       case 0:
-                                               buf[2] = 0;
-                                               buf[3] = 0;
-                                               break;
-
-                                       case 1:
-                                               buf[2] = 0xFF;
-                                               buf[3] = 0xFF;
-                                               break;
-                               }
-                       }
-                       break;
-
-               case CMD_SET_MODE_AND_LOCK:
-                       if (CurByte == 2) {
-                               g.PadState[CurPad].PadMode = value;
-                               g.PadState[CurPad].PadID = value ? 0x73 : 0x41;
-                       }
-                       break;
-
-               case CMD_QUERY_ACT:
-                       if (CurByte == 2) {
-                               switch (value) {
-                                       case 0: // default
-                                               buf[5] = 0x02;
-                                               buf[6] = 0x00;
-                                               buf[7] = 0x0A;
-                                               break;
-
-                                       case 1: // Param std conf change
-                                               buf[5] = 0x01;
-                                               buf[6] = 0x01;
-                                               buf[7] = 0x14;
-                                               break;
-                               }
-                       }
-                       break;
-
-               case CMD_QUERY_MODE:
-                       if (CurByte == 2) {
-                               switch (value) {
-                                       case 0: // mode 0 - digital mode
-                                               buf[5] = PSE_PAD_TYPE_STANDARD;
-                                               break;
-
-                                       case 1: // mode 1 - analog mode
-                                               buf[5] = PSE_PAD_TYPE_ANALOGPAD;
-                                               break;
-                               }
-                       }
-                       break;
-       }
-
-       if (CurByte >= CmdLen) return 0;
-       return buf[CurByte++];
-}
-
-static long PADreadPort(int num, PadDataS *pad) {
-       UpdateInput();
-
-       pad->buttonStatus = (g.PadState[num].KeyStatus & g.PadState[num].JoyKeyStatus);
-
-       // ePSXe different from pcsx, swap bytes
-       pad->buttonStatus = (pad->buttonStatus >> 8) | (pad->buttonStatus << 8);
-
-       switch (g.cfg.PadDef[num].Type) {
-               case PSE_PAD_TYPE_ANALOGPAD: // Analog Controller SCPH-1150
-                       pad->controllerType = PSE_PAD_TYPE_ANALOGPAD;
-                       pad->rightJoyX = g.PadState[num].AnalogStatus[ANALOG_RIGHT][0];
-                       pad->rightJoyY = g.PadState[num].AnalogStatus[ANALOG_RIGHT][1];
-                       pad->leftJoyX = g.PadState[num].AnalogStatus[ANALOG_LEFT][0];
-                       pad->leftJoyY = g.PadState[num].AnalogStatus[ANALOG_LEFT][1];
-                       break;
-
-               case PSE_PAD_TYPE_STANDARD: // Standard Pad SCPH-1080, SCPH-1150
-               default:
-                       pad->controllerType = PSE_PAD_TYPE_STANDARD;
-                       break;
-       }
-
-       return PSE_PAD_ERR_SUCCESS;
-}
-
-long PADreadPort1(PadDataS *pad) {
-       return PADreadPort(0, pad);
-}
-
-long PADreadPort2(PadDataS *pad) {
-       return PADreadPort(1, pad);
-}
-
-long PADkeypressed(void) {
-       long s;
-
-       CheckKeyboard();
-
-       s = g.KeyLeftOver;
-       g.KeyLeftOver = 0;
-
-       return s;
-}
-
-#ifndef _MACOSX
-
-long PADconfigure(void) {
-       if (fork() == 0) {
-               execl("cfg/cfgDFInput", "cfgDFInput", NULL);
-               exit(0);
-       }
-       return PSE_PAD_ERR_SUCCESS;
-}
-
-void PADabout(void) {
-       if (fork() == 0) {
-               execl("cfg/cfgDFInput", "cfgDFInput", "-about", NULL);
-               exit(0);
-       }
-}
-
-#endif
-
-long PADtest(void) {
-       return PSE_PAD_ERR_SUCCESS;
-}
diff --git a/plugins/dfinput/pad.h b/plugins/dfinput/pad.h
deleted file mode 100644 (file)
index 8347caf..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Copyright (c) 2009, Wei Mingzhi <whistler@openoffice.org>.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses>.
- */
-
-#ifndef PAD_H_
-#define PAD_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef _MACOSX
-#include "config.h"
-#endif
-
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <pthread.h>
-
-#include <SDL.h>
-#include <SDL_joystick.h>
-
-#ifdef _MACOSX
-#include <Carbon/Carbon.h>
-typedef void *Display;
-#define ThreadID ThreadID_MACOSX
-#else
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <X11/keysym.h>
-#include <X11/XKBlib.h>
-#endif
-
-#include "psemu_plugin_defs.h"
-
-#ifdef ENABLE_NLS
-#include <libintl.h>
-#include <locale.h>
-#define _(x)  gettext(x)
-#define N_(x) (x)
-#else
-#define _(x)  (x)
-#define N_(x) (x)
-#endif
-
-enum {
-       DKEY_SELECT = 0,
-       DKEY_L3,
-       DKEY_R3,
-       DKEY_START,
-       DKEY_UP,
-       DKEY_RIGHT,
-       DKEY_DOWN,
-       DKEY_LEFT,
-       DKEY_L2,
-       DKEY_R2,
-       DKEY_L1,
-       DKEY_R1,
-       DKEY_TRIANGLE,
-       DKEY_CIRCLE,
-       DKEY_CROSS,
-       DKEY_SQUARE,
-
-       DKEY_TOTAL
-};
-
-enum {
-       ANALOG_LEFT = 0,
-       ANALOG_RIGHT,
-
-       ANALOG_TOTAL
-};
-
-enum { NONE = 0, AXIS, HAT, BUTTON };
-
-typedef struct tagKeyDef {
-       uint8_t                 JoyEvType;
-       union {
-               int16_t         d;
-               int16_t         Axis;   // positive=axis+, negative=axis-, abs(Axis)-1=axis index
-               uint16_t        Hat;    // 8-bit for hat number, 8-bit for direction
-               uint16_t        Button; // button number
-       } J;
-       uint16_t                Key;
-} KEYDEF;
-
-enum { ANALOG_XP = 0, ANALOG_XM, ANALOG_YP, ANALOG_YM };
-
-typedef struct tagPadDef {
-       int8_t                  DevNum;
-       uint16_t                Type;
-       KEYDEF                  KeyDef[DKEY_TOTAL];
-       KEYDEF                  AnalogDef[ANALOG_TOTAL][4];
-} PADDEF;
-
-typedef struct tagConfig {
-       uint8_t                 Threaded;
-       PADDEF                  PadDef[2];
-} CONFIG;
-
-typedef struct tagPadState {
-       SDL_Joystick            *JoyDev;
-       uint8_t                         PadMode;
-       uint8_t                         PadID;
-       volatile uint16_t       KeyStatus;
-       volatile uint16_t       JoyKeyStatus;
-       volatile uint8_t        AnalogStatus[ANALOG_TOTAL][2]; // 0-255 where 127 is center position
-       volatile uint8_t        AnalogKeyStatus[ANALOG_TOTAL][4];
-} PADSTATE;
-
-typedef struct tagGlobalData {
-       CONFIG                          cfg;
-
-       uint8_t                         Opened;
-       Display                         *Disp;
-
-       PADSTATE                        PadState[2];
-       volatile long           KeyLeftOver;
-} GLOBALDATA;
-
-extern GLOBALDATA              g;
-
-enum {
-       CMD_READ_DATA_AND_VIBRATE = 0x42,
-       CMD_CONFIG_MODE = 0x43,
-       CMD_SET_MODE_AND_LOCK = 0x44,
-       CMD_QUERY_MODEL_AND_MODE = 0x45,
-       CMD_QUERY_ACT = 0x46, // ??
-       CMD_QUERY_COMB = 0x47, // ??
-       CMD_QUERY_MODE = 0x4C, // QUERY_MODE ??
-       CMD_VIBRATION_TOGGLE = 0x4D,
-};
-
-// cfg.c functions...
-void LoadPADConfig();
-void SavePADConfig();
-
-// sdljoy.c functions...
-void InitSDLJoy();
-void DestroySDLJoy();
-void CheckJoy();
-
-// xkb.c functions...
-void InitKeyboard();
-void DestroyKeyboard();
-void CheckKeyboard();
-
-// analog.c functions...
-void InitAnalog();
-void CheckAnalog();
-int AnalogKeyPressed(uint16_t Key);
-int AnalogKeyReleased(uint16_t Key);
-
-// pad.c functions...
-char *PSEgetLibName(void);
-uint32_t PSEgetLibType(void);
-uint32_t PSEgetLibVersion(void);
-long PADinit(long flags);
-long PADshutdown(void);
-long PADopen(unsigned long *Disp);
-long PADclose(void);
-long PADquery(void);
-unsigned char PADstartPoll(int pad);
-unsigned char PADpoll(unsigned char value);
-long PADreadPort1(PadDataS *pad);
-long PADreadPort2(PadDataS *pad);
-long PADkeypressed(void);
-long PADconfigure(void);
-void PADabout(void);
-long PADtest(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/plugins/dfinput/sdljoy.c b/plugins/dfinput/sdljoy.c
deleted file mode 100644 (file)
index ff4ed46..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (c) 2009, Wei Mingzhi <whistler@openoffice.org>.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses>.
- */
-
-#include "pad.h"
-
-void InitSDLJoy() {
-       uint8_t                         i;
-
-       g.PadState[0].JoyKeyStatus = 0xFFFF;
-       g.PadState[1].JoyKeyStatus = 0xFFFF;
-
-       for (i = 0; i < 2; i++) {
-               if (g.cfg.PadDef[i].DevNum >= 0) {
-                       g.PadState[i].JoyDev = SDL_JoystickOpen(g.cfg.PadDef[i].DevNum);
-               } else {
-                       g.PadState[i].JoyDev = NULL;
-               }
-       }
-
-       SDL_JoystickEventState(SDL_IGNORE);
-
-       InitAnalog();
-}
-
-void DestroySDLJoy() {
-       uint8_t                         i;
-
-       if (SDL_WasInit(SDL_INIT_JOYSTICK)) {
-               for (i = 0; i < 2; i++) {
-                       if (g.PadState[i].JoyDev != NULL) {
-                               SDL_JoystickClose(g.PadState[i].JoyDev);
-                       }
-               }
-       }
-
-       for (i = 0; i < 2; i++) {
-               g.PadState[i].JoyDev = NULL;
-       }
-}
-
-void CheckJoy() {
-       uint8_t                         i, j, n;
-
-       SDL_JoystickUpdate();
-
-       for (i = 0; i < 2; i++) {
-               if (g.PadState[i].JoyDev == NULL) {
-                       continue;
-               }
-
-               for (j = 0; j < DKEY_TOTAL; j++) {
-                       switch (g.cfg.PadDef[i].KeyDef[j].JoyEvType) {
-                               case AXIS:
-                                       n = abs(g.cfg.PadDef[i].KeyDef[j].J.Axis) - 1;
-
-                                       if (g.cfg.PadDef[i].KeyDef[j].J.Axis > 0) {
-                                               if (SDL_JoystickGetAxis(g.PadState[i].JoyDev, n) > 16383) {
-                                                       g.PadState[i].JoyKeyStatus &= ~(1 << j);
-                                               } else {
-                                                       g.PadState[i].JoyKeyStatus |= (1 << j);
-                                               }
-                                       } else if (g.cfg.PadDef[i].KeyDef[j].J.Axis < 0) {
-                                               if (SDL_JoystickGetAxis(g.PadState[i].JoyDev, n) < -16383) {
-                                                       g.PadState[i].JoyKeyStatus &= ~(1 << j);
-                                               } else {
-                                                       g.PadState[i].JoyKeyStatus |= (1 << j);
-                                               }
-                                       }
-                                       break;
-
-                               case HAT:
-                                       n = (g.cfg.PadDef[i].KeyDef[j].J.Hat >> 8);
-
-                                       if (SDL_JoystickGetHat(g.PadState[i].JoyDev, n) & (g.cfg.PadDef[i].KeyDef[j].J.Hat & 0xFF)) {
-                                               g.PadState[i].JoyKeyStatus &= ~(1 << j);
-                                       } else {
-                                               g.PadState[i].JoyKeyStatus |= (1 << j);
-                                       }
-                                       break;
-
-                               case BUTTON:
-                                       if (SDL_JoystickGetButton(g.PadState[i].JoyDev, g.cfg.PadDef[i].KeyDef[j].J.Button)) {
-                                               g.PadState[i].JoyKeyStatus &= ~(1 << j);
-                                       } else {
-                                               g.PadState[i].JoyKeyStatus |= (1 << j);
-                                       }
-                                       break;
-
-                               default:
-                                       break;
-                       }
-               }
-       }
-
-       CheckAnalog();
-}
diff --git a/plugins/dfinput/xkb.c b/plugins/dfinput/xkb.c
deleted file mode 100644 (file)
index bfadef1..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2009, Wei Mingzhi <whistler@openoffice.org>.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses>.
- */
-
-#include "pad.h"
-
-static Atom wmprotocols, wmdelwindow;
-
-void InitKeyboard() {
-       wmprotocols = XInternAtom(g.Disp, "WM_PROTOCOLS", 0);
-       wmdelwindow = XInternAtom(g.Disp, "WM_DELETE_WINDOW", 0);
-
-       XkbSetDetectableAutoRepeat(g.Disp, 1, NULL);
-
-       g.PadState[0].KeyStatus = 0xFFFF;
-       g.PadState[1].KeyStatus = 0xFFFF;
-}
-
-void DestroyKeyboard() {
-       XkbSetDetectableAutoRepeat(g.Disp, 0, NULL);
-}
-
-void CheckKeyboard() {
-       uint8_t                                 i, j, found;
-       XEvent                                  evt;
-       XClientMessageEvent             *xce;
-       uint16_t                                Key;
-
-       while (XPending(g.Disp)) {
-               XNextEvent(g.Disp, &evt);
-               switch (evt.type) {
-                       case KeyPress:
-                               Key = XLookupKeysym((XKeyEvent *)&evt, 0);
-                               found = 0;
-                               for (i = 0; i < 2; i++) {
-                                       for (j = 0; j < DKEY_TOTAL; j++) {
-                                               if (g.cfg.PadDef[i].KeyDef[j].Key == Key) {
-                                                       found = 1;
-                                                       g.PadState[i].KeyStatus &= ~(1 << j);
-                                               }
-                                       }
-                               }
-                               if (!found && !AnalogKeyPressed(Key)) {
-                                       g.KeyLeftOver = Key;
-                               }
-                               return;
-
-                       case KeyRelease:
-                               Key = XLookupKeysym((XKeyEvent *)&evt, 0);
-                               found = 0;
-                               for (i = 0; i < 2; i++) {
-                                       for (j = 0; j < DKEY_TOTAL; j++) {
-                                               if (g.cfg.PadDef[i].KeyDef[j].Key == Key) {
-                                                       found = 1;
-                                                       g.PadState[i].KeyStatus |= (1 << j);
-                                               }
-                                       }
-                               }
-                               if (!found && !AnalogKeyReleased(Key)) {
-                                       g.KeyLeftOver = ((long)Key | 0x40000000);
-                               }
-                               break;
-
-                       case ClientMessage:
-                               xce = (XClientMessageEvent *)&evt;
-                               if (xce->message_type == wmprotocols && (Atom)xce->data.l[0] == wmdelwindow) {
-                                       // Fake an ESC key if user clicked the close button on window
-                                       g.KeyLeftOver = XK_Escape;
-                                       return;
-                               }
-                               break;
-               }
-       }
-}
diff --git a/plugins/dfnet/cfg.c b/plugins/dfnet/cfg.c
deleted file mode 100644 (file)
index a63b074..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-//
-// DF Netplay Plugin
-//
-// Based on netSock 0.2 by linuzappz.
-// The Plugin is free source code.
-//
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "dfnet.h"
-
-#define CFG_FILENAME "dfnet.cfg"
-
-void SaveConf() {
-       FILE *f;
-
-       f = fopen(CFG_FILENAME, "w");
-       if (f == NULL) return;
-       fwrite(&conf, 1, sizeof(conf), f);
-       fclose(f);
-}
-
-void LoadConf() {
-       FILE *f;
-
-       f = fopen(CFG_FILENAME, "r");
-       if (f == NULL) {
-               conf.PlayerNum = 1;
-               conf.PortNum = 33306;
-               strcpy(conf.ipAddress, "127.0.0.1");
-               return;
-       }
-
-       fread(&conf, 1, sizeof(conf), f);
-       fclose(f);
-}
diff --git a/plugins/dfnet/dfnet.c b/plugins/dfnet/dfnet.c
deleted file mode 100644 (file)
index d76a757..0000000
+++ /dev/null
@@ -1,274 +0,0 @@
-//
-// DF Netplay Plugin
-//
-// Based on netSock 0.2 by linuzappz.
-// The Plugin is free source code.
-//
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <errno.h>
-extern int errno;
-
-#include "dfnet.h"
-
-const unsigned char version  = 2;    // NET library v2
-const unsigned char revision = 0;
-const unsigned char build    = 3;    // increase that with each version
-
-static char *libraryName      = N_("Socket Driver");
-
-unsigned long CALLBACK PSEgetLibType() {
-       return PSE_LT_NET;
-}
-
-char* CALLBACK PSEgetLibName() {
-       return _(libraryName);
-}
-
-unsigned long CALLBACK PSEgetLibVersion() {
-       return version << 16 | revision << 8 | build;
-}
-
-long CALLBACK NETinit() {
-       return sockInit();
-}
-
-int SEND(const void *buf, int Size, int Mode) {
-       int bytes;
-       int count = 0;
-       const char *pData = (const char *)buf;
-
-       if (Mode & PSE_NET_NONBLOCKING) { // NONBLOCKING
-               int ret;
-
-               FD_ZERO(&wset);
-               FD_SET(sock, &wset);
-
-               ret = select(sock + 1, NULL, &wset, NULL, &tm);
-               if (ret == -1) return -1;
-
-               if (FD_ISSET(sock, &wset)) {
-                       return send(sock, pData, Size, 0);
-               } else {
-                       return 0;
-               }
-       } else { // BLOCKING
-               while (Size > 0) {
-                       bytes = send(sock, pData, Size, 0);
-                       if (bytes < 0) return -1;
-                       pData += bytes; Size -= bytes;
-                       count += bytes;
-               }
-       }
-
-       return count;
-}
-
-int RECV(void *buf, int Size, int Mode) {
-       int bytes;
-       int count = 0;
-       char *pData = (char *)buf;
-
-       if (Mode & PSE_NET_NONBLOCKING) { // NONBLOCKING
-               int ret;
-
-               FD_ZERO(&rset);
-               FD_SET(sock, &rset);
-
-               ret = select(sock, &rset, NULL, NULL, &tm);
-
-               if (FD_ISSET(sock, &rset)) {
-                       return recv(sock, pData, Size, 0);
-               } else {
-                       return 0;
-               }
-       } else { // BLOCKING
-               while (Size > 0) {
-                       bytes = recv(sock, pData, Size, 0);
-                       if (bytes == -1) return -1;
-                       pData+= bytes; Size-= bytes;
-                       count+= bytes;
-               }
-       }
-
-       return count;
-}
-
-long CALLBACK NETopen(unsigned long *gpuDisp) {
-       int ret = sockOpen();
-
-       struct sockaddr_in address;
-
-       if (ret == -1) return -1;
-
-       if (conf.PlayerNum == 1) {
-               int listen_sock, reuse_addr = 1;
-               int ret;
-
-               memset((char *)&address, 0, sizeof (address));
-
-               address.sin_family = AF_INET;
-               address.sin_port = htons(conf.PortNum);
-               address.sin_addr.s_addr = INADDR_ANY;
-
-               listen_sock = socket(AF_INET, SOCK_STREAM, 0);
-               if (listen_sock == -1)
-                       return -1;
-
-               setsockopt(listen_sock, SOL_SOCKET, SO_REUSEADDR, (const char *)&reuse_addr, sizeof(reuse_addr));
-
-               if (bind(listen_sock,(struct sockaddr *) &address, sizeof(address)) == -1)
-                       return -1;
-
-               if (listen(listen_sock, 1) != 0) 
-                       return -1; 
-
-               sock = -1;
-
-               WaitCancel = 0;
-               sockCreateWaitDlg();
-
-               while (sock < 0) {
-                       FD_ZERO(&rset);
-                       FD_SET(listen_sock, &rset);
-
-                       ret = select(listen_sock + 1, &rset, NULL, NULL, &tm);
-                       if (FD_ISSET(listen_sock, &rset)) {
-                               sock = accept(listen_sock, NULL, NULL);
-                       }
-
-                       if (WaitCancel) break;
-                       sockDlgUpdate();
-               }
-               close(listen_sock);
-
-               sockDestroyWaitDlg();
-               if (WaitCancel == 1) return -1;
-       } else {
-               memset((char *)&address, 0, sizeof(address));
-               address.sin_family = AF_INET;
-               address.sin_port = htons(conf.PortNum);
-               address.sin_addr.s_addr = inet_addr(conf.ipAddress);
-
-               sock = socket(AF_INET, SOCK_STREAM, 0);
-
-               if (connect(sock, (struct sockaddr *)&address, sizeof(address))!=0) {
-                       SysMessage(_("error connecting to %s: %s\n"), conf.ipAddress, strerror(errno));
-                       return -1;
-               }
-       }
-
-       PadInit = 0;
-       PadCount = 0;
-       PadSize[0] = -1;
-       PadSize[1] = -1;
-       PadRecvSize = -1;
-       PadSendSize = -1;
-       Ping = sockPing();
-       Ping = (sockPing() + Ping) / 2;
-       Ping = (sockPing() + Ping) / 2;
-
-       if (conf.PlayerNum == 1) {
-               PadCountMax = (int)(((double)Ping / 1000.0) * 60.0);
-               if (PadCountMax <= 0) PadCountMax = 1;
-               SEND(&PadCountMax, 4, PSE_NET_BLOCKING);
-       } else {
-               RECV(&PadCountMax, 4, PSE_NET_BLOCKING);
-       }
-
-       PadSendData = (char *)malloc(PadCountMax * 128);
-       if (PadSendData == NULL) {
-               SysMessage(_("Error allocating memory!\n")); return -1;
-       }
-       memset(PadSendData, 0xff, PadCountMax);
-
-       return ret;
-}
-
-long CALLBACK NETclose() {
-       close(sock);
-
-       return 0;
-}
-
-long CALLBACK NETshutdown() {
-       return sockShutdown();
-}
-
-void CALLBACK NETpause() {
-/*     unsigned char Code = 0x80;
-
-       SEND(&Code, 1, PSE_NET_BLOCKING);*/
-}
-
-void CALLBACK NETresume() {
-/*     unsigned char Code = 0x80;
-
-       SEND(&Code, 1, PSE_NET_BLOCKING);*/
-}
-
-long CALLBACK NETsendData(void *pData, int Size, int Mode) {
-       return SEND(pData, Size, Mode);
-}
-
-long CALLBACK NETrecvData(void *pData, int Size, int Mode) {
-       return RECV(pData, Size, Mode);
-}
-
-long CALLBACK NETsendPadData(void *pData, int Size) {
-       if (PadSendSize == -1) {
-               PadSendSize = Size;
-
-               if (SEND(&PadSendSize, 1, PSE_NET_BLOCKING) == -1)
-                       return -1;
-
-               if (RECV(&PadRecvSize, 1, PSE_NET_BLOCKING) == -1)
-                       return -1;
-       }
-
-       memcpy(&PadSendData[PadCount], pData, Size);
-       if (SEND(pData, PadSendSize, PSE_NET_BLOCKING) == -1)
-               return -1;
-
-       return 0;
-}
-
-long CALLBACK NETrecvPadData(void *pData, int Pad) {
-       if (PadInit == 0) {
-               if (conf.PlayerNum == Pad) {
-                       memset(pData, 0xff, PadSendSize);
-               } else {
-                       memset(pData, 0xff, PadRecvSize);
-               }
-       } else {
-               if (conf.PlayerNum == Pad) {
-                       memcpy(pData, &PadSendData[PadCount == 0 ? PadCountMax-1 : PadCount-1], PadSendSize);
-               } else {
-                       if (RECV(pData, PadRecvSize, PSE_NET_BLOCKING) == -1)
-                               return -1;
-               }
-       }
-
-       if (Pad == 2) {
-               PadCount++;
-               if (PadCount == PadCountMax) {
-                       PadCount = 0;
-                       PadInit = 1;
-               }
-       }
-
-       return 0;
-}
-
-long CALLBACK NETqueryPlayer() {
-       return conf.PlayerNum;
-}
-
-long CALLBACK NETtest() {
-       return 0;
-}
diff --git a/plugins/dfnet/dfnet.h b/plugins/dfnet/dfnet.h
deleted file mode 100644 (file)
index 62f3842..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-//
-// DF Netplay Plugin
-//
-// Based on netSock 0.2 by linuzappz.
-// The Plugin is free source code.
-//
-
-#ifndef __DFNET_H__
-#define __DFNET_H__
-
-#include "config.h"
-
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <unistd.h>
-
-#ifdef ENABLE_NLS
-#include <libintl.h>
-#include <locale.h>
-#define _(x)  gettext(x)
-#define N_(x) (x)
-#else
-#define _(x)  (x)
-#define N_(x) (x)
-#endif
-
-typedef void* HWND;
-
-struct timeval tm;
-
-#define CALLBACK
-
-long timeGetTime();
-
-#include "psemu_plugin_defs.h"
-
-typedef struct {
-       int PlayerNum;
-       unsigned short PortNum;
-       char ipAddress[32];
-} Config;
-
-Config conf;
-
-void LoadConf();
-void SaveConf();
-
-long sock;
-char *PadSendData;
-char *PadRecvData;
-char PadSendSize;
-char PadRecvSize;
-char PadSize[2];
-int PadCount;
-int PadCountMax;
-int PadInit;
-int Ping;
-volatile int WaitCancel;
-fd_set rset;
-fd_set wset;
-
-long sockInit();
-long sockShutdown();
-long sockOpen();
-void sockCreateWaitDlg();
-void sockDlgUpdate();
-void sockDestroyWaitDlg();
-int sockPing();
-
-int ShowPauseDlg();
-void SysMessage(const char *fmt, ...);
-
-int SEND(const void *pData, int Size, int Mode);
-int RECV(void *pData, int Size, int Mode);
-
-#endif
diff --git a/plugins/dfnet/gui.c b/plugins/dfnet/gui.c
deleted file mode 100644 (file)
index 60e165a..0000000
+++ /dev/null
@@ -1,233 +0,0 @@
-//
-// DF Netplay Plugin
-//
-// Based on netSock 0.2 by linuzappz.
-// The Plugin is free source code.
-//
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
-#include <glade/glade.h>
-#include <signal.h>
-
-#include "cfg.c"
-
-void cfgSysMessage(const char *fmt, ...) {
-       GtkWidget *MsgDlg;
-       va_list list;
-       char msg[512];
-
-       va_start(list, fmt);
-       vsprintf(msg, fmt, list);
-       va_end(list);
-
-       if (msg[strlen(msg) - 1] == '\n') msg[strlen(msg) - 1] = 0;
-
-       MsgDlg = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL,
-               GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _("NetPlay"));
-       gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(MsgDlg), "%s", msg);
-
-       gtk_dialog_run(GTK_DIALOG(MsgDlg));
-       gtk_widget_destroy(MsgDlg);
-}
-
-void CFGconfigure() {
-       cfgSysMessage(_("Nothing to configure"));
-}
-
-#ifdef __linux__
-
-#include <sys/ioctl.h>
-#include <linux/if.h>
-
-#define MAXINTERFACES 16
-
-void sockGetIP(char *IPAddress) {
-       int fd, intrface;
-       struct ifreq buf[MAXINTERFACES];
-       struct ifconf ifc;
-       struct sockaddr_in addr;
-
-       strcpy(IPAddress, "127.0.0.1");
-
-       if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) >= 0) {
-               ifc.ifc_len = sizeof(buf);
-               ifc.ifc_buf = (caddr_t)buf;
-               if (!ioctl(fd, SIOCGIFCONF, (char *)&ifc)) {
-                       intrface = ifc.ifc_len / sizeof(struct ifreq);
-                       while (intrface-- > 0) {
-                               if (!(ioctl(fd, SIOCGIFADDR, (char *)&buf[intrface]))) {
-                                       memcpy(&addr, &(buf[intrface].ifr_addr), sizeof(addr));
-                                       strcpy(IPAddress, inet_ntoa(addr.sin_addr));
-                                       break;
-                               }
-                       }
-               }
-               close(fd);
-       }
-}
-
-#else
-
-void sockGetIP(char *IPAddress) {
-       struct hostent *host;
-       char str[256];
-
-       gethostname(str, 256);
-       host = gethostbyname(str);
-
-       if (host != NULL)
-               strcpy(IPAddress, inet_ntoa(*((struct in_addr *)host->h_addr_list[0])));
-       else strcpy(IPAddress, "127.0.0.1");
-}
-
-#endif
-
-void OnCopyIP(GtkWidget *widget, gpointer user_data) {
-       char str[256];
-
-       sockGetIP(str);
-       gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), str, strlen(str));
-       cfgSysMessage(_("IP %s"), str);
-}
-
-long CFGopen() {
-       GladeXML *xml;
-       GtkWidget *widget, *MainWindow;
-       char buf[256];
-
-       LoadConf();
-
-       xml = glade_xml_new(DATADIR "dfnet.glade2", "dlgStart", NULL);
-       if (xml == NULL) {
-               g_warning("We could not load the interface!");
-               return 0;
-       }
-
-       MainWindow = glade_xml_get_widget(xml, "dlgStart");
-       gtk_window_set_title(GTK_WINDOW(MainWindow), _("NetPlay"));
-
-       widget = glade_xml_get_widget(xml, "btnCopyIP");
-       g_signal_connect_data(GTK_OBJECT(widget), "clicked",
-               GTK_SIGNAL_FUNC(OnCopyIP), NULL, NULL, G_CONNECT_AFTER);
-
-       widget = glade_xml_get_widget(xml, "tbServerIP");
-       gtk_entry_set_text(GTK_ENTRY(widget), conf.ipAddress);
-
-       widget = glade_xml_get_widget(xml, "tbPort");
-       sprintf(buf, "%d", conf.PortNum);
-       gtk_entry_set_text(GTK_ENTRY(widget), buf);
-
-       if (conf.PlayerNum == 1) {
-               widget = glade_xml_get_widget(xml, "rbServer");
-               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE);
-       } else {
-               widget = glade_xml_get_widget(xml, "rbClient");
-               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE);
-       }
-
-       if (gtk_dialog_run(GTK_DIALOG(MainWindow)) == GTK_RESPONSE_OK) {
-               widget = glade_xml_get_widget(xml, "tbServerIP");
-               strcpy(conf.ipAddress, gtk_entry_get_text(GTK_ENTRY(widget)));
-
-               widget = glade_xml_get_widget(xml, "tbPort");
-               conf.PortNum = atoi(gtk_entry_get_text(GTK_ENTRY(widget)));
-
-               widget = glade_xml_get_widget(xml, "rbServer");
-               if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
-                       conf.PlayerNum = 1;
-               } else {
-                       conf.PlayerNum = 2;
-               }
-
-               SaveConf();
-               gtk_widget_destroy(MainWindow);
-               return 1;
-       }
-
-       gtk_widget_destroy(MainWindow);
-
-       return 0;
-}
-
-void OnWaitDialog_Abort() {
-       kill(getppid(), SIGUSR2);
-}
-
-void CFGwait() {
-       GtkWidget *WaitDlg;
-
-       WaitDlg = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO,
-               GTK_BUTTONS_CANCEL, _("Waiting for connection..."));
-
-       gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(WaitDlg),
-               _("The Client should now Start a Connection, waiting..."));
-
-       gtk_dialog_run(GTK_DIALOG(WaitDlg));
-       gtk_widget_destroy(WaitDlg);
-
-       OnWaitDialog_Abort();
-}
-
-long CFGpause() {
-       return 0;
-}
-
-void CFGabout() {
-       const char *authors[]= {"linuzappz <linuzappz@hotmail.com>", "Wei Mingzhi <whistler_wmz@users.sf.net>", NULL};
-       GtkWidget *widget;
-
-       widget = gtk_about_dialog_new();
-       gtk_about_dialog_set_name(GTK_ABOUT_DIALOG(widget), "Socket NetPlay Driver");
-       gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(widget), "0.21");
-       gtk_about_dialog_set_authors(GTK_ABOUT_DIALOG(widget), authors);
-       gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(widget), "http://www.codeplex.com/pcsxr/");
-
-       gtk_dialog_run(GTK_DIALOG(widget));
-       gtk_widget_destroy(widget);
-}
-
-long CFGmessage(char *args[], int num) {
-       char msg[512];
-
-       memset(msg, 0, sizeof(msg));
-       while (num) {
-               strcat(msg, *args); strcat(msg, " ");
-               num--; args++;
-       }
-       cfgSysMessage(msg);
-
-       return 0;
-}
-
-int main(int argc, char *argv[]) {
-#ifdef ENABLE_NLS
-       setlocale(LC_ALL, "");
-       bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR);
-       bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
-       textdomain(GETTEXT_PACKAGE);
-#endif
-
-       gtk_set_locale();
-       gtk_init(&argc, &argv);
-
-       if (!strcmp(argv[1], "configure")) {
-               CFGconfigure();
-       } else if (!strcmp(argv[1], "open")) {
-               return CFGopen();
-       } else if (!strcmp(argv[1], "wait")) {
-               CFGwait();
-       } else if (!strcmp(argv[1], "pause")) {
-               return CFGpause();
-       } else if (!strcmp(argv[1], "about")) {
-               CFGabout();
-       } else if (!strcmp(argv[1], "message")) {
-               CFGmessage(&argv[2], argc - 2);
-       }
-
-       return 0;
-}
diff --git a/plugins/dfnet/unix.c b/plugins/dfnet/unix.c
deleted file mode 100644 (file)
index 390a5fc..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-//
-// DF Netplay Plugin
-//
-// Based on netSock 0.2 by linuzappz.
-// The Plugin is free source code.
-//
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <signal.h>
-#include <sys/wait.h>
-extern int errno;
-
-#include "dfnet.h"
-
-int ExecCfg(const char *arg, int f) {
-       char cfg[512];
-
-       strcpy(cfg, "cfg/cfgDFNet");
-       strcat(cfg, " ");
-       strcat(cfg, arg);
-
-       if (f) {
-               if (fork() == 0) { system(cfg); exit(0); }
-               return 0;
-       }
-
-       return system(cfg);
-}
-
-void SysMessage(const char *fmt, ...) {
-       va_list list;
-       char msg[512];
-       char cmd[512];
-
-       va_start(list, fmt);
-       vsprintf(msg, fmt, list);
-       va_end(list);
-
-       sprintf(cmd, "message %s\n", msg);
-       ExecCfg(cmd, 1);
-}
-
-long sockInit() {
-       conf.PlayerNum = 0;
-       tm.tv_sec = 0;
-       tm.tv_usec = 0;
-
-       return 0;
-}
-
-long sockShutdown() {
-       return 0;
-}
-
-long sockOpen() {
-       if (ExecCfg("open", 0) == 0) return -1;
-
-       LoadConf();
-
-       return 0;
-}
-
-int sockPing() {
-       char data[32];
-       struct timeval tv, tvn;
-
-       memset(data, 0, sizeof(data));
-
-       gettimeofday(&tv, NULL);
-       SEND(data, 32, PSE_NET_BLOCKING);
-       RECV(data, 32, PSE_NET_BLOCKING);
-       gettimeofday(&tvn, NULL);
-
-       return (tvn.tv_sec - tv.tv_sec) * 1000 +
-                  (tvn.tv_usec - tv.tv_usec) / 1000;
-}
-
-void CALLBACK NETconfigure() {
-       ExecCfg("configure", 1);
-}
-
-void CALLBACK NETabout() {
-       ExecCfg("about", 1);
-}
-
-pid_t cfgpid = 0;
-
-void OnWaitDlg_Abort(int num) {
-       WaitCancel = 1;
-       cfgpid = 0;
-}
-
-void sockCreateWaitDlg() {
-       signal(SIGUSR2, OnWaitDlg_Abort);
-       if ((cfgpid = fork()) == 0) {
-               execl("cfg/cfgDFNet", "cfgDFNet", "wait", NULL);
-               exit(0);
-       }
-       usleep(100000);
-}
-
-void sockDlgUpdate() {
-       usleep(100000);
-}
-
-void sockDestroyWaitDlg() {
-       if (cfgpid > 0) {
-               kill(cfgpid, SIGKILL);
-               cfgpid = 0;
-       }
-}
-
-long timeGetTime() {
-       struct timeval tv;
-
-       gettimeofday(&tv, NULL);
-       return (tv.tv_sec) * 1000 + (tv.tv_usec) / 1000;
-}
diff --git a/plugins/peopsxgl/cfg.c b/plugins/peopsxgl/cfg.c
deleted file mode 100644 (file)
index 3dcd0ab..0000000
+++ /dev/null
@@ -1,249 +0,0 @@
-/***************************************************************************\r
-                           cfg.c  -  description\r
-                             -------------------\r
-    begin                : Sun Mar 08 2009\r
-    copyright            : (C) 1999-2009 by Pete Bernert\r
-    web                  : www.pbernert.com   \r
- ***************************************************************************/\r
-\r
-/***************************************************************************\r
- *                                                                         *\r
- *   This program is free software; you can redistribute it and/or modify  *\r
- *   it under the terms of the GNU General Public License as published by  *\r
- *   the Free Software Foundation; either version 2 of the License, or     *\r
- *   (at your option) any later version. See also the license.txt file for *\r
- *   additional informations.                                              *\r
- *                                                                         *\r
- ***************************************************************************/\r
-\r
-//*************************************************************************// \r
-// History of changes:\r
-//\r
-// 2009/03/08 - Pete  \r
-// - generic cleanup for the Peops release\r
-//\r
-//*************************************************************************// \r
-\r
-#define _IN_CFG\r
-\r
-#include "stdafx.h"\r
-#include "externals.h"\r
-#include "cfg.h"\r
-\r
-char *pConfigFile = NULL;\r
-\r
-void ReadConfigFile()\r
-{\r
- FILE *in = NULL;\r
- int len;\r
- char *pB, *p, t[256];\r
-\r
- if (pConfigFile != NULL)\r
-  in = fopen(pConfigFile, "rb");\r
- else\r
-  in = fopen("gpuPeopsMesaGL.cfg", "rb"); \r
-\r
- if (in == NULL) return;\r
-\r
- pB=(char *)malloc(32767);                             // buffer for reading config (32k)\r
- memset(pB, 0, 32767);\r
-\r
- len = fread(pB, 1, 32767, in);                        // read config in buffer\r
- fclose(in);                                           // close config file\r
-\r
- strcpy(t,"\nResX");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
- if(p) iResX=atoi(p+len);\r
- if(iResX<10) iResX=10;\r
-\r
- strcpy(t,"\nResY");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
- if(p) iResY=atoi(p+len);\r
- if(iResY<10) iResY=10;\r
-\r
- strcpy(t,"\nKeepRatio");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
- if(p) bKeepRatio=atoi(p+len);\r
- if(bKeepRatio<0) bKeepRatio=0;\r
- if(bKeepRatio>1) bKeepRatio=1;\r
-\r
- strcpy(t,"\nScreenSmoothing");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
- if(p) iBlurBuffer=atoi(p+len);\r
- if(iBlurBuffer<0) iBlurBuffer=0;\r
- if(iBlurBuffer>1) iBlurBuffer=1;\r
-\r
- strcpy(t,"\nHiResTextures");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
- if(p) iHiResTextures=atoi(p+len);\r
- if(iHiResTextures<0) iHiResTextures=0;\r
- if(iHiResTextures>2) iHiResTextures=2;\r
-\r
- iSortTexCnt =0;\r
- strcpy(t,"\nVRamSize");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
- if(p) iVRamSize=atoi(p+len);\r
- if(iVRamSize<0)    iVRamSize=0;\r
- if(iVRamSize>1024) iVRamSize=1024;\r
-\r
- strcpy(t,"\nFullScreen");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
- if(p) bFullScreen=atoi(p+len);\r
- if(bFullScreen>1) bFullScreen=1;\r
-\r
- strcpy(t,"\nScanLines");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
- if(p) iUseScanLines=atoi(p+len);\r
- if(iUseScanLines<0) iUseScanLines=0;\r
- if(iUseScanLines>1) iUseScanLines=1;\r
-\r
- strcpy(t,"\nScanLinesBlend");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
- if(p) iScanBlend=atoi(p+len);\r
- if(iScanBlend<-1)  iScanBlend=-1;\r
- if(iScanBlend>255) iScanBlend=255;\r
-\r
- strcpy(t,"\nFrameTextures");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
- if(p) iFrameTexType=atoi(p+len);\r
- if(iFrameTexType<0) iFrameTexType=0;\r
- if(iFrameTexType>3) iFrameTexType=3;\r
-\r
- strcpy(t,"\nFrameAccess");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
- if(p) iFrameReadType=atoi(p+len);\r
- if(iFrameReadType<0) iFrameReadType=0;\r
- if(iFrameReadType>4) iFrameReadType=4;\r
- if(iFrameReadType==4) bFullVRam=TRUE;\r
- else                  bFullVRam=FALSE;\r
-\r
- strcpy(t,"\nTexFilter");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
- if(p) iFilterType=atoi(p+len);\r
- if(iFilterType<0) iFilterType=0;\r
- if(iFilterType>6) iFilterType=6;\r
-\r
- strcpy(t,"\nAdvancedBlend");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
- if(p) bAdvancedBlend=atoi(p+len);\r
- if(bAdvancedBlend<0) bAdvancedBlend=0;\r
- if(bAdvancedBlend>1) bAdvancedBlend=1;\r
-\r
- strcpy(t,"\nDithering");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
- if(p) bDrawDither=atoi(p+len);\r
- if(bDrawDither<0) bDrawDither=0;\r
- if(bDrawDither>1) bDrawDither=1;\r
-\r
- strcpy(t,"\nLineMode");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
- if(p) bUseLines=atoi(p+len);\r
- if(bUseLines<0) bUseLines=0;\r
- if(bUseLines>1) bUseLines=1;\r
-\r
- strcpy(t,"\nShowFPS");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
- if(p) iShowFPS=atoi(p+len);\r
- if(iShowFPS<0) iShowFPS=0;\r
- if(iShowFPS>1) iShowFPS=1;\r
-\r
- strcpy(t,"\nUseFrameLimit");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
- if(p) bUseFrameLimit=atoi(p+len);\r
- if(bUseFrameLimit<0) bUseFrameLimit=0;\r
- if(bUseFrameLimit>1) bUseFrameLimit=1;\r
-\r
- strcpy(t,"\nUseFrameSkip");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
- if(p) bUseFrameSkip=atoi(p+len);\r
- if(bUseFrameSkip<0) bUseFrameSkip=0;\r
- if(bUseFrameSkip>1) bUseFrameSkip=1;\r
-\r
- strcpy(t,"\nFPSDetection");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
- if(p) iFrameLimit=atoi(p+len)+1;\r
- if(iFrameLimit<1) iFrameLimit=1;\r
- if(iFrameLimit>2) iFrameLimit=2;\r
-\r
- strcpy(t,"\nFrameRate");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
- if(p) fFrameRate=(float)atof(p+len);\r
- if(fFrameRate<0.0f)    fFrameRate=0.0f;\r
- if(fFrameRate>1000.0f) fFrameRate=1000.0f;\r
-\r
- strcpy(t,"\nOffscreenDrawing");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
- if(p) iOffscreenDrawing=atoi(p+len);\r
- if(iOffscreenDrawing<0) iOffscreenDrawing=0;\r
- if(iOffscreenDrawing>4) iOffscreenDrawing=4;\r
-\r
- strcpy(t,"\nOpaquePass");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
- if(p) bOpaquePass=atoi(p+len);\r
- if(bOpaquePass<0) bOpaquePass=0;\r
- if(bOpaquePass>1) bOpaquePass=1;\r
-\r
- strcpy(t,"\nAntiAlias");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
- if(p) bUseAntiAlias=atoi(p+len);\r
- if(bUseAntiAlias<0) bUseAntiAlias=0;\r
- if(bUseAntiAlias>1) bUseAntiAlias=1;\r
-\r
- strcpy(t,"\nTexQuality");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
- if(p) iTexQuality=atoi(p+len);\r
- if(iTexQuality<0) iTexQuality=0;\r
- if(iTexQuality>4) iTexQuality=4;\r
-\r
- strcpy(t,"\n15bitMdec");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
- if(p) bUse15bitMdec=atoi(p+len);\r
- if(bUse15bitMdec<0) bUse15bitMdec=0;\r
- if(bUse15bitMdec>1) bUse15bitMdec=1;\r
-\r
- strcpy(t,"\nMaskDetect");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
- if(p) iUseMask=atoi(p+len);\r
- if(iUseMask<0) iUseMask=0;\r
- if(iUseMask>1) iUseMask=1;\r
-\r
- strcpy(t,"\nFastMdec");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
- if(p) bUseFastMdec=atoi(p+len);\r
- if(bUseFastMdec<0) bUseFastMdec=0;\r
- if(bUseFastMdec>1) bUseFastMdec=1;\r
-\r
- strcpy(t,"\nCfgFixes");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
- if(p) dwCfgFixes=atoi(p+len);\r
-\r
- strcpy(t,"\nUseFixes");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
- if(p) bUseFixes=atoi(p+len);\r
- if(bUseFixes<0) bUseFixes=0;\r
- if(bUseFixes>1) bUseFixes=1;\r
-\r
- strcpy(t,"\nOGLExtensions");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
- if(p) iUseExts=atoi(p+len);\r
- if(iUseExts>1) iUseExts=1;\r
-\r
- free(pB);\r
-}\r
-\r
-void ReadConfig(void)                                  // read config (linux file)\r
-{\r
- iResX=640;\r
- iResY=480;\r
- iColDepth=16;\r
- bChangeRes=FALSE;\r
- bWindowMode=TRUE;\r
- iUseScanLines=0;\r
- bFullScreen=FALSE;\r
- bFullVRam=FALSE;\r
- iFilterType=0;\r
- bAdvancedBlend=FALSE;\r
- bDrawDither=FALSE;\r
- bUseLines=FALSE;\r
- bUseFrameLimit=TRUE;\r
- bUseFrameSkip=FALSE;\r
- iFrameLimit=2;\r
- fFrameRate=200.0f;\r
- iOffscreenDrawing=2;\r
- bOpaquePass=TRUE;\r
- bUseAntiAlias=FALSE;\r
- iTexQuality=0;\r
- iUseMask=0;\r
- iZBufferDepth=0;\r
- bUseFastMdec=TRUE;\r
- dwCfgFixes=0;\r
- bUseFixes=FALSE;\r
- iFrameTexType=1;\r
- iFrameReadType=0;\r
- bUse15bitMdec=FALSE;\r
- iShowFPS=0;\r
- bKeepRatio=FALSE;\r
- iScanBlend=0;\r
- iVRamSize=0;\r
- iTexGarbageCollection=1;\r
- iBlurBuffer=0;\r
- iHiResTextures=0;\r
- iForceVSync=-1;\r
-\r
- ReadConfigFile();                                     // read file\r
-\r
- if(!iColDepth)  iColDepth=32;                         // adjust color info\r
- if(iUseMask)    iZBufferDepth=16;                     // set zbuffer depth \r
- else            iZBufferDepth=0;\r
- if(bUseFixes)   dwActFixes=dwCfgFixes;                // init game fix global\r
-}\r
diff --git a/plugins/peopsxgl/cfg.h b/plugins/peopsxgl/cfg.h
deleted file mode 100644 (file)
index 634513d..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/***************************************************************************\r
-                            cfg.h  -  description\r
-                             -------------------\r
-    begin                : Sun Mar 08 2009\r
-    copyright            : (C) 1999-2009 by Pete Bernert\r
-    web                  : www.pbernert.com   \r
- ***************************************************************************/\r
-\r
-/***************************************************************************\r
- *                                                                         *\r
- *   This program is free software; you can redistribute it and/or modify  *\r
- *   it under the terms of the GNU General Public License as published by  *\r
- *   the Free Software Foundation; either version 2 of the License, or     *\r
- *   (at your option) any later version. See also the license.txt file for *\r
- *   additional informations.                                              *\r
- *                                                                         *\r
- ***************************************************************************/\r
-\r
-void ReadConfig(void);\r
-void ReadConfigFile();
diff --git a/plugins/peopsxgl/draw.c b/plugins/peopsxgl/draw.c
deleted file mode 100644 (file)
index 33381e5..0000000
+++ /dev/null
@@ -1,1517 +0,0 @@
-/***************************************************************************\r
-                           draw.c  -  description\r
-                             -------------------\r
-    begin                : Sun Mar 08 2009\r
-    copyright            : (C) 1999-2009 by Pete Bernert\r
-    web                  : www.pbernert.com   \r
- ***************************************************************************/\r
-\r
-/***************************************************************************\r
- *                                                                         *\r
- *   This program is free software; you can redistribute it and/or modify  *\r
- *   it under the terms of the GNU General Public License as published by  *\r
- *   the Free Software Foundation; either version 2 of the License, or     *\r
- *   (at your option) any later version. See also the license.txt file for *\r
- *   additional informations.                                              *\r
- *                                                                         *\r
- ***************************************************************************/\r
-\r
-#include "stdafx.h"\r
-\r
-#define _IN_DRAW\r
-\r
-#include "externals.h"\r
-#include "gpu.h"\r
-#include "draw.h"\r
-#include "prim.h"\r
-#include "texture.h"\r
-#include "menu.h"\r
-\r
-////////////////////////////////////////////////////////////////////////////////////\r
-// defines\r
-\r
-#define SIGNBIT 0x800\r
-#define S_MASK  0xf000\r
-#define L_MASK  0xfffff000\r
-\r
-// ownscale: some ogl drivers have buggy texture matrix funcs, so it\r
-//           is safer to calc sow/tow ourselves\r
-\r
-#ifdef OWNSCALE\r
-\r
-#define ST_FACSPRITE       255.99f\r
-#define ST_BFFACSPRITE     0.5f/256.0f\r
-#define ST_BFFACSPRITESORT 0.333f/256.0f\r
-\r
-#define ST_OFFSET          0.5f/256.0f;\r
-\r
-#define ST_FAC             255.99f\r
-#define ST_BFFAC           0.5f/256.0f\r
-#define ST_BFFACSORT       0.333f/256.0f\r
-\r
-#define ST_FACTRI          255.99f\r
-#define ST_BFFACTRI        0.5f/256.0f\r
-#define ST_BFFACTRISORT    0.333f/256.0f\r
-\r
-#define ST_FACVRAMX        255.0f\r
-#define ST_FACVRAM         256.0f\r
-\r
-///////////////////////////////////////////////////////////////\r
-\r
-#else\r
-\r
-#define ST_BFFACSPRITE     0.5f\r
-#define ST_BFFACSPRITESORT 0.333f\r
-\r
-#define ST_BFFAC           0.5f\r
-#define ST_BFFACSORT       0.333f\r
-\r
-#define ST_BFFACTRI        0.5f\r
-#define ST_BFFACTRISORT    0.333f\r
-\r
-#define ST_OFFSET          0.5f;\r
-                \r
-#endif\r
-\r
-////////////////////////////////////////////////////////////////////////////////////\r
-// draw globals; most will be initialized again later (by config or checks) \r
-\r
-BOOL           bIsFirstFrame=TRUE;\r
-\r
-// resolution/ratio vars\r
-\r
-int            iResX;\r
-int            iResY;\r
-BOOL           bKeepRatio=FALSE;\r
-RECT           rRatioRect;\r
-\r
-// psx mask related vars\r
-\r
-BOOL           bCheckMask=FALSE;\r
-int            iUseMask=0;\r
-int            iSetMask=0;\r
-unsigned short sSetMask=0;\r
-uint32_t       lSetMask=0;\r
-\r
-// drawing/coord vars\r
-\r
-OGLVertex      vertex[4];\r
-GLubyte        gl_ux[8];\r
-GLubyte        gl_vy[8];\r
-short          sprtY,sprtX,sprtH,sprtW;\r
-\r
-// drawing options\r
-\r
-BOOL           bOpaquePass;\r
-BOOL           bAdvancedBlend;\r
-BOOL           bUseLines;\r
-BOOL           bUseAntiAlias;\r
-int            iTexQuality;\r
-int            iUsePalTextures=1;\r
-BOOL           bSnapShot=FALSE;\r
-BOOL           bSmallAlpha=FALSE;\r
-int            iShowFPS=0;\r
-\r
-// OGL extension support\r
-\r
-int                iForceVSync=-1;\r
-int                iUseExts=0;\r
-BOOL               bGLExt;\r
-BOOL               bGLFastMovie=FALSE;\r
-BOOL               bGLSoft;\r
-BOOL               bGLBlend;\r
-PFNGLBLENDEQU      glBlendEquationEXTEx=NULL;\r
-PFNGLCOLORTABLEEXT glColorTableEXTEx=NULL;\r
-\r
-// gfx card buffer infos\r
-\r
-int            iDepthFunc=0;\r
-int            iZBufferDepth=0;\r
-GLbitfield     uiBufferBits=GL_COLOR_BUFFER_BIT;\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-// Get extension infos (f.e. pal textures / packed pixels)\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-void GetExtInfos(void)                              \r
-{\r
- BOOL bPacked=FALSE;                                   // default: no packed pixel support\r
-\r
- bGLExt=FALSE;                                         // default: no extensions\r
- bGLFastMovie=FALSE;\r
-\r
- if(strstr((char *)glGetString(GL_EXTENSIONS),         // packed pixels available?\r
-    "GL_EXT_packed_pixels"))                          \r
-  bPacked=TRUE;                                        // -> ok\r
-\r
- if(bPacked && bUse15bitMdec)                          // packed available and 15bit mdec wanted?\r
-  bGLFastMovie=TRUE;                                   // -> ok\r
-\r
- if(bPacked && (iTexQuality==1 || iTexQuality==2))     // packed available and 16 bit texture format?\r
-  {\r
-   bGLFastMovie=TRUE;                                  // -> ok\r
-   bGLExt=TRUE;\r
-  }\r
-\r
- if(iUseExts &&                                        // extension support wanted?\r
-    (strstr((char *)glGetString(GL_EXTENSIONS),\r
-     "GL_EXT_texture_edge_clamp") ||\r
-     strstr((char *)glGetString(GL_EXTENSIONS),        // -> check clamp support, if yes: use it\r
-     "GL_SGIS_texture_edge_clamp")))\r
-      iClampType=GL_TO_EDGE_CLAMP;\r
- else iClampType=GL_CLAMP;\r
-\r
- glColorTableEXTEx=(PFNGLCOLORTABLEEXT)NULL;           // init ogl palette func pointer\r
-\r
-#ifndef __sun\r
- if(iGPUHeight!=1024 &&                                // no pal textures in ZN mode (height=1024)! \r
-    strstr((char *)glGetString(GL_EXTENSIONS),         // otherwise: check ogl support\r
-    "GL_EXT_paletted_texture"))\r
-  {\r
-   iUsePalTextures=1;                                  // -> wow, supported, get func pointer\r
-\r
-   glColorTableEXTEx=(PFNGLCOLORTABLEEXT)glXGetProcAddress("glColorTableEXT");\r
-\r
-   if(glColorTableEXTEx==NULL) iUsePalTextures=0;      // -> ha, cheater... no func, no support\r
-  }\r
- else iUsePalTextures=0;\r
-#else\r
- iUsePalTextures=0;\r
-#endif\r
-}\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-// Setup some stuff depending on user settings or in-game toggle\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-void SetExtGLFuncs(void)\r
-{\r
- //----------------------------------------------------//\r
-\r
- SetFixes();                                           // update fix infos\r
-\r
- //----------------------------------------------------//\r
-\r
- if(iUseExts && !(dwActFixes&1024) &&                  // extensions wanted? and not turned off by game fix?\r
-    strstr((char *)glGetString(GL_EXTENSIONS),         // and blend_subtract available?\r
-    "GL_EXT_blend_subtract"))\r
-     {                                                 // -> get ogl blend function pointer\r
-      glBlendEquationEXTEx=(PFNGLBLENDEQU)glXGetProcAddress("glBlendEquationEXT"); \r
-     }\r
- else                                                  // no subtract blending?\r
-  {\r
-   if(glBlendEquationEXTEx)                            // -> change to additive blending (if subract was active)\r
-    glBlendEquationEXTEx(FUNC_ADD_EXT);\r
-   glBlendEquationEXTEx=(PFNGLBLENDEQU)NULL;           // -> no more blend function pointer\r
-  }\r
-\r
- //----------------------------------------------------//\r
-\r
- if(iUseExts && bAdvancedBlend &&                      // advanced blending wanted ?\r
-    strstr((char *)glGetString(GL_EXTENSIONS),         // and extension avail?\r
-           "GL_EXT_texture_env_combine"))\r
-  {\r
-   bUseMultiPass=FALSE;bGLBlend=TRUE;                  // -> no need for 2 passes, perfect\r
-\r
-   glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, COMBINE_EXT);    \r
-   glTexEnvf(GL_TEXTURE_ENV, COMBINE_RGB_EXT, GL_MODULATE);     \r
-   glTexEnvf(GL_TEXTURE_ENV, COMBINE_ALPHA_EXT, GL_MODULATE);     \r
-   glTexEnvf(GL_TEXTURE_ENV, RGB_SCALE_EXT, 2.0f);    \r
-  }\r
- else                                                  // no advanced blending wanted/available:\r
-  {\r
-   if(bAdvancedBlend) bUseMultiPass=TRUE;              // -> pseudo-advanced with 2 passes\r
-   else               bUseMultiPass=FALSE;             // -> or simple 'bright color' mode\r
-   bGLBlend=FALSE;                                     // -> no ext blending!\r
-\r
-   glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);    \r
-  }\r
-\r
- //----------------------------------------------------//\r
- // init standard tex quality 0-2, and big alpha mode 3\r
-\r
- if(!(dwActFixes&0x4000) && iFilterType && iTexQuality>=3) \r
-      bSmallAlpha=TRUE;                  \r
- else bSmallAlpha=FALSE;\r
-\r
- if(bOpaquePass)                                        // opaque mode?\r
-  {\r
-   if(dwActFixes&32) \r
-    {\r
-     TCF[0]=CP8RGBA_0;\r
-     PalTexturedColourFn=CP8RGBA;                      // -> init col func\r
-    }\r
-   else\r
-    {\r
-     TCF[0]=XP8RGBA_0;\r
-     PalTexturedColourFn=XP8RGBA;                      // -> init col func\r
-    }\r
-\r
-   TCF[1]=XP8RGBA_1;\r
-   glAlphaFunc(GL_GREATER,0.49f);\r
-  }\r
- else                                                  // no opaque mode?\r
-  {\r
-   TCF[0]=TCF[1]=P8RGBA;\r
-   PalTexturedColourFn=P8RGBA;                         // -> init col func\r
-   glAlphaFunc(GL_NOTEQUAL,0);                         // --> set alpha func\r
-  }\r
-\r
- //----------------------------------------------------//\r
-\r
- LoadSubTexFn=LoadSubTexturePageSort;                  // init load tex ptr\r
-\r
- giWantedFMT=GL_RGBA;                                  // init ogl tex format\r
-\r
- switch(iTexQuality)                                   // -> quality:\r
-  {\r
-   //--------------------------------------------------// \r
-   case 0:                                             // -> don't care\r
-    giWantedRGBA=4;\r
-    giWantedTYPE=GL_UNSIGNED_BYTE;\r
-    break;\r
-   //--------------------------------------------------// \r
-   case 1:                                             // -> R4G4B4A4\r
-    if(bGLExt)\r
-     {\r
-      giWantedRGBA=GL_RGBA4;\r
-      giWantedTYPE=GL_UNSIGNED_SHORT_4_4_4_4_EXT;\r
-      LoadSubTexFn=LoadPackedSubTexturePageSort;\r
-      if(bOpaquePass) \r
-       {\r
-        if(dwActFixes&32) PTCF[0]=CP4RGBA_0;\r
-        else              PTCF[0]=XP4RGBA_0;\r
-        PTCF[1]=XP4RGBA_1;\r
-       }\r
-      else      \r
-       {\r
-        PTCF[0]=PTCF[1]=P4RGBA;\r
-       }\r
-     }\r
-    else\r
-     {\r
-      giWantedRGBA=GL_RGBA4;\r
-      giWantedTYPE=GL_UNSIGNED_BYTE;\r
-     }\r
-    break;\r
-   //--------------------------------------------------// \r
-   case 2:                                             // -> R5B5G5A1\r
-    if(bGLExt)\r
-     {\r
-      giWantedRGBA=GL_RGB5_A1;\r
-      giWantedTYPE=GL_UNSIGNED_SHORT_5_5_5_1_EXT;\r
-      LoadSubTexFn=LoadPackedSubTexturePageSort;\r
-      if(bOpaquePass) \r
-       {\r
-        if(dwActFixes&32) PTCF[0]=CP5RGBA_0;\r
-        else              PTCF[0]=XP5RGBA_0;\r
-        PTCF[1]=XP5RGBA_1;\r
-       }\r
-      else   \r
-       {\r
-        PTCF[0]=PTCF[1]=P5RGBA;\r
-       }\r
-     }\r
-    else\r
-     {\r
-      giWantedRGBA=GL_RGB5_A1;giWantedTYPE=GL_UNSIGNED_BYTE;\r
-     }\r
-    break;\r
-   //--------------------------------------------------// \r
-   case 3:                                             // -> R8G8B8A8\r
-    giWantedRGBA=GL_RGBA8;\r
-    giWantedTYPE=GL_UNSIGNED_BYTE;\r
-\r
-    if(bSmallAlpha)\r
-     {\r
-      if(bOpaquePass)                                  // opaque mode?\r
-       {\r
-        if(dwActFixes&32) {TCF[0]=CP8RGBAEx_0;PalTexturedColourFn=CP8RGBAEx;}\r
-        else              {TCF[0]=XP8RGBAEx_0;PalTexturedColourFn=XP8RGBAEx;}\r
-        TCF[1]=XP8RGBAEx_1;\r
-       }\r
-     }\r
-\r
-    break;\r
-   //--------------------------------------------------// \r
-   case 4:                                             // -> R8G8B8A8\r
-    giWantedRGBA = GL_RGBA8;\r
-    giWantedTYPE = GL_UNSIGNED_BYTE;\r
-\r
-    if(strstr((char *)glGetString(GL_EXTENSIONS),      // and extension avail?\r
-              "GL_EXT_bgra"))\r
-     {\r
-      giWantedFMT  = GL_BGRA_EXT;\r
-\r
-      if(bOpaquePass)                                  // opaque mode?\r
-       {\r
-        if(bSmallAlpha)\r
-         {\r
-          if(dwActFixes&32) {TCF[0]=CP8BGRAEx_0;PalTexturedColourFn=CP8RGBAEx;}\r
-          else              {TCF[0]=XP8BGRAEx_0;PalTexturedColourFn=XP8RGBAEx;}\r
-          TCF[1]=XP8BGRAEx_1;\r
-         }\r
-        else\r
-         {\r
-          if(dwActFixes&32) {TCF[0]=CP8BGRA_0;PalTexturedColourFn=CP8RGBA;}\r
-          else              {TCF[0]=XP8BGRA_0;PalTexturedColourFn=XP8RGBA;}\r
-          TCF[1]=XP8BGRA_1;\r
-         }\r
-       }\r
-      else                                             // no opaque mode?\r
-       {\r
-        TCF[0]=TCF[1]=P8BGRA;                          // -> init col func\r
-       }\r
-     }\r
-    else\r
-     {\r
-      iTexQuality=3;\r
-      if(bSmallAlpha)\r
-       {\r
-        if(bOpaquePass)                                 // opaque mode?\r
-         {\r
-          if(dwActFixes&32) {TCF[0]=CP8RGBAEx_0;PalTexturedColourFn=CP8RGBAEx;}\r
-          else              {TCF[0]=XP8RGBAEx_0;PalTexturedColourFn=XP8RGBAEx;}\r
-          TCF[1]=XP8RGBAEx_1;\r
-         }\r
-       }\r
-     }\r
-\r
-    break;\r
-   //--------------------------------------------------// \r
-  }\r
-\r
- bBlendEnable=FALSE;                                   // init blending: off\r
- glDisable(GL_BLEND);\r
-\r
- SetScanTrans();                                       // init scan lines (if wanted)\r
-}\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-// setup scan lines\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-#define R_TSP 0x00,0x45,0x00,0xff\r
-#define G_TSP 0x00,0x00,0x45,0xff\r
-#define B_TSP 0x45,0x00,0x00,0xff\r
-#define O_TSP 0x45,0x45,0x45,0xff\r
-#define N_TSP 0x00,0x00,0x00,0xff\r
-\r
-GLuint  gTexScanName=0;\r
-\r
-GLubyte texscan[4][16]= \r
-{\r
-{R_TSP, G_TSP, B_TSP, N_TSP},\r
-{O_TSP, N_TSP, O_TSP, N_TSP},\r
-{B_TSP, N_TSP, R_TSP, G_TSP},\r
-{O_TSP, N_TSP, O_TSP, N_TSP}\r
-};\r
-\r
-void CreateScanLines(void)\r
-{\r
- if(iUseScanLines)\r
-  {\r
-   int y;\r
-   if(iScanBlend<0)                                    // special scan mask mode\r
-    {\r
-     glGenTextures(1, &gTexScanName);\r
-     glBindTexture(GL_TEXTURE_2D, gTexScanName);\r
-\r
-     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);\r
-     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);\r
-     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);\r
-     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);\r
-     glTexImage2D(GL_TEXTURE_2D, 0, 4, 4, 4, 0,GL_RGBA, GL_UNSIGNED_BYTE, texscan);\r
-    }\r
-   else                                                // otherwise simple lines in a display list\r
-    {\r
-     uiScanLine=glGenLists(1);\r
-     glNewList(uiScanLine,GL_COMPILE);\r
-\r
-     for(y=0;y<iResY;y+=2)\r
-      {\r
-       glBegin(GL_QUADS);\r
-         glVertex2f(0,y);\r
-         glVertex2f(iResX,y);\r
-         glVertex2f(iResX,y+1);\r
-         glVertex2f(0,y+1);\r
-       glEnd();\r
-      }\r
-     glEndList();\r
-    }\r
-  }\r
-}\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-// Initialize OGL\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-int GLinitialize() \r
-{\r
- glViewport(rRatioRect.left,                           // init viewport by ratio rect\r
-            iResY-(rRatioRect.top+rRatioRect.bottom),\r
-            rRatioRect.right, \r
-            rRatioRect.bottom);         \r
-                                                      \r
- glScissor(0, 0, iResX, iResY);                        // init clipping (fullscreen)\r
- glEnable(GL_SCISSOR_TEST);                       \r
-\r
-#ifndef OWNSCALE\r
- glMatrixMode(GL_TEXTURE);                             // init psx tex sow and tow if not "ownscale"\r
- glLoadIdentity();\r
- glScalef(1.0f/255.99f,1.0f/255.99f,1.0f);             // geforce precision hack\r
-#endif \r
-\r
- glMatrixMode(GL_PROJECTION);                          // init projection with psx resolution\r
- glLoadIdentity();\r
- glOrtho(0,PSXDisplay.DisplayMode.x,\r
-         PSXDisplay.DisplayMode.y, 0, -1, 1);\r
-\r
- if(iZBufferDepth)                                     // zbuffer?\r
-  {\r
-   uiBufferBits=GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT;\r
-   glEnable(GL_DEPTH_TEST);    \r
-   glDepthFunc(GL_ALWAYS);\r
-   iDepthFunc=1;\r
-  }\r
- else                                                  // no zbuffer?\r
-  {\r
-   uiBufferBits=GL_COLOR_BUFFER_BIT;\r
-   glDisable(GL_DEPTH_TEST);\r
-  }\r
-\r
- glClearColor(0.0f, 0.0f, 0.0f, 0.0f);                 // first buffer clear\r
- glClear(uiBufferBits);\r
-\r
- if(bUseLines)                                         // funny lines \r
-  {\r
-   glPolygonMode(GL_FRONT, GL_LINE); \r
-   glPolygonMode(GL_BACK, GL_LINE); \r
-  }\r
- else                                                  // or the real filled thing\r
-  {\r
-   glPolygonMode(GL_FRONT, GL_FILL);\r
-   glPolygonMode(GL_BACK, GL_FILL);\r
-  }\r
-\r
- MakeDisplayLists();                                   // lists for menu/opaque\r
- GetExtInfos();                                        // get ext infos\r
- SetExtGLFuncs();                                      // init all kind of stuff (tex function pointers)\r
\r
- glEnable(GL_ALPHA_TEST);                              // wanna alpha test\r
-\r
- if(!bUseAntiAlias)                                    // no anti-alias (default)\r
-  {\r
-   glDisable(GL_LINE_SMOOTH);\r
-   glDisable(GL_POLYGON_SMOOTH);\r
-   glDisable(GL_POINT_SMOOTH);\r
-  }\r
- else                                                  // wanna try it? glitches galore...\r
-  {                    \r
-   glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);\r
-   glEnable(GL_LINE_SMOOTH);\r
-   glEnable(GL_POLYGON_SMOOTH);\r
-   glEnable(GL_POINT_SMOOTH);\r
-   glHint(GL_LINE_SMOOTH_HINT,GL_NICEST);\r
-   glHint(GL_POINT_SMOOTH_HINT,GL_NICEST);\r
-   glHint(GL_POLYGON_SMOOTH_HINT,GL_NICEST);\r
-  }\r
-\r
- ubGloAlpha=127;                                       // init some drawing vars\r
- ubGloColAlpha=127;\r
- TWin.UScaleFactor = 1;\r
- TWin.VScaleFactor = 1;\r
- bDrawMultiPass=FALSE;\r
- bTexEnabled=FALSE;\r
- bUsingTWin=FALSE;\r
-      \r
- if(bDrawDither)  glEnable(GL_DITHER);                 // dither mode\r
- else             glDisable(GL_DITHER); \r
-\r
- glDisable(GL_FOG);                                    // turn all (currently) unused modes off\r
- glDisable(GL_LIGHTING);  \r
- glDisable(GL_LOGIC_OP);\r
- glDisable(GL_STENCIL_TEST);  \r
- glDisable(GL_TEXTURE_1D);\r
- glDisable(GL_TEXTURE_2D);\r
- glDisable(GL_CULL_FACE);\r
-\r
- glPixelTransferi(GL_RED_SCALE, 1);                    // to be sure:\r
- glPixelTransferi(GL_RED_BIAS, 0);                     // init more OGL vals\r
- glPixelTransferi(GL_GREEN_SCALE, 1);\r
- glPixelTransferi(GL_GREEN_BIAS, 0);\r
- glPixelTransferi(GL_BLUE_SCALE, 1);\r
- glPixelTransferi(GL_BLUE_BIAS, 0);\r
- glPixelTransferi(GL_ALPHA_SCALE, 1);\r
- glPixelTransferi(GL_ALPHA_BIAS, 0);                                                  \r
-\r
- printf(glGetString(GL_VENDOR));                       // linux: tell user what is getting used\r
- printf("\n");\r
- printf(glGetString(GL_RENDERER));\r
- printf("\n");\r
-\r
- glFlush();                                            // we are done...\r
- glFinish();                           \r
-\r
- CreateScanLines();                                    // setup scanline stuff (if wanted)\r
-\r
- CheckTextureMemory();                                 // check available tex memory\r
-\r
- if(bKeepRatio) SetAspectRatio();                      // set ratio\r
-\r
- if(iShowFPS)                                          // user wants FPS display on startup?\r
-  {\r
-   ulKeybits|=KEY_SHOWFPS;                             // -> ok, turn display on\r
-   szDispBuf[0]=0;\r
-   BuildDispMenu(0);\r
-  }\r
\r
- bIsFirstFrame = FALSE;                                // we have survived the first frame :)\r
-\r
- return 0;\r
-}\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-// clean up OGL stuff\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-void GLcleanup() \r
-{                                                     \r
- KillDisplayLists();                                   // bye display lists\r
-\r
- if(iUseScanLines)                                     // scanlines used?\r
-  {\r
-   if(iScanBlend<0)\r
-    {\r
-     if(gTexScanName!=0)                               // some scanline tex?\r
-      glDeleteTextures(1, &gTexScanName);              // -> delete it\r
-     gTexScanName=0;\r
-    }\r
-   else glDeleteLists(uiScanLine,1);                   // otherwise del scanline display list\r
-  }\r
-\r
- CleanupTextureStore();                                // bye textures\r
-}\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-////////////////////////////////////////////////////////////////////////\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-////////////////////////////////////////////////////////////////////////\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-// Offset stuff\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-// please note: it is hardly do-able in a hw/accel plugin to get the \r
-//              real psx polygon coord mapping right... the following\r
-//              works not to bad with many games, though\r
-\r
-__inline BOOL CheckCoord4()\r
-{\r
- if(lx0<0)\r
-  {\r
-   if(((lx1-lx0)>CHKMAX_X) ||\r
-      ((lx2-lx0)>CHKMAX_X)) \r
-    {\r
-     if(lx3<0)\r
-      {\r
-       if((lx1-lx3)>CHKMAX_X) return TRUE;\r
-       if((lx2-lx3)>CHKMAX_X) return TRUE;\r
-      }\r
-    }\r
-  }\r
- if(lx1<0)\r
-  {\r
-   if((lx0-lx1)>CHKMAX_X) return TRUE;\r
-   if((lx2-lx1)>CHKMAX_X) return TRUE;\r
-   if((lx3-lx1)>CHKMAX_X) return TRUE;\r
-  }\r
- if(lx2<0)\r
-  {\r
-   if((lx0-lx2)>CHKMAX_X) return TRUE;\r
-   if((lx1-lx2)>CHKMAX_X) return TRUE;\r
-   if((lx3-lx2)>CHKMAX_X) return TRUE;\r
-  }\r
- if(lx3<0)\r
-  {\r
-   if(((lx1-lx3)>CHKMAX_X) ||\r
-      ((lx2-lx3)>CHKMAX_X))\r
-    {\r
-     if(lx0<0)\r
-      {\r
-       if((lx1-lx0)>CHKMAX_X) return TRUE;\r
-       if((lx2-lx0)>CHKMAX_X) return TRUE;\r
-      }\r
-    }\r
-  }\r
\r
-\r
- if(ly0<0)\r
-  {\r
-   if((ly1-ly0)>CHKMAX_Y) return TRUE;\r
-   if((ly2-ly0)>CHKMAX_Y) return TRUE;\r
-  }\r
- if(ly1<0)\r
-  {\r
-   if((ly0-ly1)>CHKMAX_Y) return TRUE;\r
-   if((ly2-ly1)>CHKMAX_Y) return TRUE;\r
-   if((ly3-ly1)>CHKMAX_Y) return TRUE;\r
-  }\r
- if(ly2<0)\r
-  {\r
-   if((ly0-ly2)>CHKMAX_Y) return TRUE;\r
-   if((ly1-ly2)>CHKMAX_Y) return TRUE;\r
-   if((ly3-ly2)>CHKMAX_Y) return TRUE;\r
-  }\r
- if(ly3<0)\r
-  {\r
-   if((ly1-ly3)>CHKMAX_Y) return TRUE;\r
-   if((ly2-ly3)>CHKMAX_Y) return TRUE;\r
-  }\r
-\r
- return FALSE;\r
-}\r
-\r
-__inline BOOL CheckCoord3()\r
-{\r
- if(lx0<0)\r
-  {\r
-   if((lx1-lx0)>CHKMAX_X) return TRUE;\r
-   if((lx2-lx0)>CHKMAX_X) return TRUE;\r
-  }\r
- if(lx1<0)\r
-  {\r
-   if((lx0-lx1)>CHKMAX_X) return TRUE;\r
-   if((lx2-lx1)>CHKMAX_X) return TRUE;\r
-  }\r
- if(lx2<0)\r
-  {\r
-   if((lx0-lx2)>CHKMAX_X) return TRUE;\r
-   if((lx1-lx2)>CHKMAX_X) return TRUE;\r
-  }\r
- if(ly0<0)\r
-  {\r
-   if((ly1-ly0)>CHKMAX_Y) return TRUE;\r
-   if((ly2-ly0)>CHKMAX_Y) return TRUE;\r
-  }\r
- if(ly1<0)\r
-  {\r
-   if((ly0-ly1)>CHKMAX_Y) return TRUE;\r
-   if((ly2-ly1)>CHKMAX_Y) return TRUE;\r
-  }\r
- if(ly2<0)\r
-  {\r
-   if((ly0-ly2)>CHKMAX_Y) return TRUE;\r
-   if((ly1-ly2)>CHKMAX_Y) return TRUE;\r
-  }\r
-\r
- return FALSE;\r
-}\r
-\r
-\r
-__inline BOOL CheckCoord2()\r
-{\r
- if(lx0<0)\r
-  {\r
-   if((lx1-lx0)>CHKMAX_X) return TRUE;\r
-  }\r
- if(lx1<0)\r
-  {\r
-   if((lx0-lx1)>CHKMAX_X) return TRUE;\r
-  }\r
- if(ly0<0)\r
-  {\r
-   if((ly1-ly0)>CHKMAX_Y) return TRUE;\r
-  }\r
- if(ly1<0)\r
-  {\r
-   if((ly0-ly1)>CHKMAX_Y) return TRUE;\r
-  }\r
-\r
- return FALSE;\r
-}\r
-\r
-/*\r
-//Lewpys "offsetline" func:\r
-\r
-void offsetline(void)\r
-{\r
-       float x0, x1, y0, y1, oolength, xl, yl;\r
-\r
- if(bDisplayNotSet)\r
-  SetOGLDisplaySettings(1);\r
-\r
- if(!(dwActFixes&16))\r
-  {\r
-   if((lx0 & SIGNBIT)) lx0|=S_MASK;\r
-   else                lx0&=~S_MASK;\r
-   if((lx1 & SIGNBIT)) lx1|=S_MASK;\r
-   else                lx1&=~S_MASK;\r
-   if((ly0 & SIGNBIT)) ly0|=S_MASK;\r
-   else                ly0&=~S_MASK;\r
-   if((ly1 & SIGNBIT)) ly1|=S_MASK;\r
-   else                ly1&=~S_MASK;\r
-  }\r
-\r
- x0 = (float)(lx0 + PSXDisplay.CumulOffset.x);\r
- x1 = (float)(lx1 + PSXDisplay.CumulOffset.x);\r
- y0 = (float)(ly0 + PSXDisplay.CumulOffset.y);\r
- y1 = (float)(ly1 + PSXDisplay.CumulOffset.y);\r
-\r
- oolength = (float)1/((float)sqrt((y1 - y0)*(y1 - y0) + (x1 - x0)*(x1 - x0)) * (float)2);\r
-//     oolength = (float)1/((float)sqrt(((y1 - y0)*(y1 - y0) + (x1 - x0)*(x1 - x0)) * (float)2));\r
-\r
-       xl = (x1 - x0) * oolength;\r
-       yl = (y1 - y0) * oolength;\r
-\r
-       x0 += 0.5f;\r
-       x1 += 0.5f;\r
-\r
-       x0 -= xl - yl;\r
-       x1 += xl + yl;\r
-       y0 -= yl + xl;\r
-       y1 += yl - xl;\r
-\r
-       vertex[0].x=x0;\r
-       vertex[1].x=x1;\r
-       vertex[0].y=y0;\r
-       vertex[1].y=y1;\r
-\r
-       x0 -= yl * 2;\r
-       x1 -= yl * 2;\r
-       y0 += xl * 2;\r
-       y1 += xl * 2;\r
-\r
-       vertex[2].x=x1;\r
-       vertex[3].x=x0;\r
-       vertex[2].y=y1;\r
-       vertex[3].y=y0;\r
-}\r
-*/\r
-\r
-\r
-// Pete's way: a very easy (and hopefully fast) approach for lines\r
-// without sqrt... using a small float -> short cast trick :)\r
-\r
-#define VERTEX_OFFX 0.2f\r
-#define VERTEX_OFFY 0.2f\r
-\r
-BOOL offsetline(void)           \r
-{\r
- short x0,x1,y0,y1,dx,dy;float px,py;\r
-\r
- if(bDisplayNotSet)\r
-  SetOGLDisplaySettings(1);\r
-\r
- if(!(dwActFixes&16))\r
-  {\r
-   lx0=(short)(((int)lx0<<SIGNSHIFT)>>SIGNSHIFT);\r
-   lx1=(short)(((int)lx1<<SIGNSHIFT)>>SIGNSHIFT);\r
-   ly0=(short)(((int)ly0<<SIGNSHIFT)>>SIGNSHIFT);\r
-   ly1=(short)(((int)ly1<<SIGNSHIFT)>>SIGNSHIFT);\r
-\r
-   if(CheckCoord2()) return TRUE;\r
-  }\r
-\r
- x0 = (lx0 + PSXDisplay.CumulOffset.x)+1;\r
- x1 = (lx1 + PSXDisplay.CumulOffset.x)+1;\r
- y0 = (ly0 + PSXDisplay.CumulOffset.y)+1;\r
- y1 = (ly1 + PSXDisplay.CumulOffset.y)+1;\r
\r
- dx=x1-x0;\r
- dy=y1-y0;\r
\r
- if(dx>=0)\r
-  {\r
-   if(dy>=0)\r
-    {\r
-     px=0.5f;\r
-          if(dx>dy) py=-0.5f;\r
-     else if(dx<dy) py= 0.5f;\r
-     else           py= 0.0f;\r
-    }\r
-   else\r
-    {\r
-     py=-0.5f;\r
-     dy=-dy;\r
-          if(dx>dy) px= 0.5f;\r
-     else if(dx<dy) px=-0.5f;\r
-     else           px= 0.0f;\r
-    }\r
-  }\r
- else\r
-  {\r
-   if(dy>=0)\r
-    {\r
-     py=0.5f;\r
-     dx=-dx;\r
-          if(dx>dy) px=-0.5f;\r
-     else if(dx<dy) px= 0.5f;\r
-     else           px= 0.0f;\r
-    }\r
-   else\r
-    {\r
-     px=-0.5f;\r
-          if(dx>dy) py=-0.5f;\r
-     else if(dx<dy) py= 0.5f;\r
-     else           py= 0.0f;\r
-    }\r
-  } \r
\r
- vertex[0].x=(short)((float)x0-px);\r
- vertex[3].x=(short)((float)x0+py);\r
\r
- vertex[0].y=(short)((float)y0-py);\r
- vertex[3].y=(short)((float)y0-px);\r
\r
- vertex[1].x=(short)((float)x1-py);\r
- vertex[2].x=(short)((float)x1+px);\r
-\r
- vertex[1].y=(short)((float)y1+px);\r
- vertex[2].y=(short)((float)y1+py);\r
-\r
- if(vertex[0].x==vertex[3].x &&                        // ortho rect? done\r
-    vertex[1].x==vertex[2].x &&\r
-    vertex[0].y==vertex[1].y &&\r
-    vertex[2].y==vertex[3].y) return FALSE;\r
- if(vertex[0].x==vertex[1].x &&\r
-    vertex[2].x==vertex[3].x &&\r
-    vertex[0].y==vertex[3].y &&\r
-    vertex[1].y==vertex[2].y) return FALSE;\r
-\r
- vertex[0].x-=VERTEX_OFFX;                             // otherwise a small offset\r
- vertex[0].y-=VERTEX_OFFY;                             // to get better accuracy\r
- vertex[1].x-=VERTEX_OFFX;\r
- vertex[1].y-=VERTEX_OFFY;\r
- vertex[2].x-=VERTEX_OFFX;\r
- vertex[2].y-=VERTEX_OFFY;\r
- vertex[3].x-=VERTEX_OFFX;\r
- vertex[3].y-=VERTEX_OFFY;\r
-\r
- return FALSE;\r
-}\r
-\r
-///////////////////////////////////////////////////////// \r
-\r
-BOOL offset2(void)\r
-{\r
- if(bDisplayNotSet)\r
-  SetOGLDisplaySettings(1);\r
-\r
- if(!(dwActFixes&16))\r
-  {\r
-   lx0=(short)(((int)lx0<<SIGNSHIFT)>>SIGNSHIFT);\r
-   lx1=(short)(((int)lx1<<SIGNSHIFT)>>SIGNSHIFT);\r
-   ly0=(short)(((int)ly0<<SIGNSHIFT)>>SIGNSHIFT);\r
-   ly1=(short)(((int)ly1<<SIGNSHIFT)>>SIGNSHIFT);\r
-\r
-   if(CheckCoord2()) return TRUE;\r
-  }\r
-\r
- vertex[0].x=lx0+PSXDisplay.CumulOffset.x;\r
- vertex[1].x=lx1+PSXDisplay.CumulOffset.x;\r
- vertex[0].y=ly0+PSXDisplay.CumulOffset.y;\r
- vertex[1].y=ly1+PSXDisplay.CumulOffset.y;\r
-\r
- return FALSE;\r
-}\r
-\r
-///////////////////////////////////////////////////////// \r
-\r
-BOOL offset3(void)\r
-{\r
- if(bDisplayNotSet)\r
-  SetOGLDisplaySettings(1);\r
-\r
- if(!(dwActFixes&16))\r
-  {\r
-   lx0=(short)(((int)lx0<<SIGNSHIFT)>>SIGNSHIFT);\r
-   lx1=(short)(((int)lx1<<SIGNSHIFT)>>SIGNSHIFT);\r
-   lx2=(short)(((int)lx2<<SIGNSHIFT)>>SIGNSHIFT);\r
-   ly0=(short)(((int)ly0<<SIGNSHIFT)>>SIGNSHIFT);\r
-   ly1=(short)(((int)ly1<<SIGNSHIFT)>>SIGNSHIFT);\r
-   ly2=(short)(((int)ly2<<SIGNSHIFT)>>SIGNSHIFT);\r
-\r
-   if(CheckCoord3()) return TRUE;\r
-  }\r
-\r
- vertex[0].x=lx0+PSXDisplay.CumulOffset.x;\r
- vertex[1].x=lx1+PSXDisplay.CumulOffset.x;\r
- vertex[2].x=lx2+PSXDisplay.CumulOffset.x;\r
- vertex[0].y=ly0+PSXDisplay.CumulOffset.y;\r
- vertex[1].y=ly1+PSXDisplay.CumulOffset.y;\r
- vertex[2].y=ly2+PSXDisplay.CumulOffset.y;\r
-\r
- return FALSE;\r
-}\r
-\r
-///////////////////////////////////////////////////////// \r
-\r
-BOOL offset4(void)\r
-{\r
- if(bDisplayNotSet)\r
-  SetOGLDisplaySettings(1);\r
-\r
- if(!(dwActFixes&16))\r
-  {\r
-   lx0=(short)(((int)lx0<<SIGNSHIFT)>>SIGNSHIFT);\r
-   lx1=(short)(((int)lx1<<SIGNSHIFT)>>SIGNSHIFT);\r
-   lx2=(short)(((int)lx2<<SIGNSHIFT)>>SIGNSHIFT);\r
-   lx3=(short)(((int)lx3<<SIGNSHIFT)>>SIGNSHIFT);\r
-   ly0=(short)(((int)ly0<<SIGNSHIFT)>>SIGNSHIFT);\r
-   ly1=(short)(((int)ly1<<SIGNSHIFT)>>SIGNSHIFT);\r
-   ly2=(short)(((int)ly2<<SIGNSHIFT)>>SIGNSHIFT);\r
-   ly3=(short)(((int)ly3<<SIGNSHIFT)>>SIGNSHIFT);\r
-\r
-   if(CheckCoord4()) return TRUE;\r
-  }\r
-\r
- vertex[0].x=lx0+PSXDisplay.CumulOffset.x;\r
- vertex[1].x=lx1+PSXDisplay.CumulOffset.x;\r
- vertex[2].x=lx2+PSXDisplay.CumulOffset.x;\r
- vertex[3].x=lx3+PSXDisplay.CumulOffset.x;\r
- vertex[0].y=ly0+PSXDisplay.CumulOffset.y;\r
- vertex[1].y=ly1+PSXDisplay.CumulOffset.y;\r
- vertex[2].y=ly2+PSXDisplay.CumulOffset.y;\r
- vertex[3].y=ly3+PSXDisplay.CumulOffset.y;\r
-\r
- return FALSE;\r
-}\r
-\r
-///////////////////////////////////////////////////////// \r
-\r
-void offsetST(void)\r
-{\r
- if(bDisplayNotSet)\r
-  SetOGLDisplaySettings(1);\r
-\r
- if(!(dwActFixes&16))\r
-  {\r
-   lx0=(short)(((int)lx0<<SIGNSHIFT)>>SIGNSHIFT);\r
-   ly0=(short)(((int)ly0<<SIGNSHIFT)>>SIGNSHIFT);\r
-\r
-   if(lx0<-512 && PSXDisplay.DrawOffset.x<=-512)\r
-    lx0+=2048;\r
-\r
-   if(ly0<-512 && PSXDisplay.DrawOffset.y<=-512)\r
-    ly0+=2048;\r
-  }\r
-\r
- ly1 = ly0;\r
- ly2 = ly3 = ly0+sprtH;\r
- lx3 = lx0;\r
- lx1 = lx2 = lx0+sprtW;\r
-\r
- vertex[0].x=lx0+PSXDisplay.CumulOffset.x;\r
- vertex[1].x=lx1+PSXDisplay.CumulOffset.x;\r
- vertex[2].x=lx2+PSXDisplay.CumulOffset.x;\r
- vertex[3].x=lx3+PSXDisplay.CumulOffset.x;\r
- vertex[0].y=ly0+PSXDisplay.CumulOffset.y;\r
- vertex[1].y=ly1+PSXDisplay.CumulOffset.y;\r
- vertex[2].y=ly2+PSXDisplay.CumulOffset.y;\r
- vertex[3].y=ly3+PSXDisplay.CumulOffset.y;\r
-}\r
-\r
-///////////////////////////////////////////////////////// \r
-\r
-void offsetScreenUpload(int Position)\r
-{\r
- if(bDisplayNotSet)\r
-  SetOGLDisplaySettings(1);\r
-\r
- if(Position==-1)\r
-  {\r
-   int lmdx,lmdy;\r
-\r
-   lmdx=xrUploadArea.x0;\r
-   lmdy=xrUploadArea.y0;\r
-\r
-   lx0-=lmdx;\r
-   ly0-=lmdy;\r
-   lx1-=lmdx;\r
-   ly1-=lmdy;\r
-   lx2-=lmdx;\r
-   ly2-=lmdy;\r
-   lx3-=lmdx;\r
-   ly3-=lmdy;\r
-  }\r
- else\r
- if(Position)\r
-  {\r
-   lx0-=PSXDisplay.DisplayPosition.x;\r
-   ly0-=PSXDisplay.DisplayPosition.y;\r
-   lx1-=PSXDisplay.DisplayPosition.x;\r
-   ly1-=PSXDisplay.DisplayPosition.y;\r
-   lx2-=PSXDisplay.DisplayPosition.x;\r
-   ly2-=PSXDisplay.DisplayPosition.y;\r
-   lx3-=PSXDisplay.DisplayPosition.x;\r
-   ly3-=PSXDisplay.DisplayPosition.y;\r
-  }\r
- else\r
-  {\r
-   lx0-=PreviousPSXDisplay.DisplayPosition.x;\r
-   ly0-=PreviousPSXDisplay.DisplayPosition.y;\r
-   lx1-=PreviousPSXDisplay.DisplayPosition.x;\r
-   ly1-=PreviousPSXDisplay.DisplayPosition.y;\r
-   lx2-=PreviousPSXDisplay.DisplayPosition.x;\r
-   ly2-=PreviousPSXDisplay.DisplayPosition.y;\r
-   lx3-=PreviousPSXDisplay.DisplayPosition.x;\r
-   ly3-=PreviousPSXDisplay.DisplayPosition.y;\r
-  }\r
-\r
- vertex[0].x=lx0 + PreviousPSXDisplay.Range.x0;\r
- vertex[1].x=lx1 + PreviousPSXDisplay.Range.x0;\r
- vertex[2].x=lx2 + PreviousPSXDisplay.Range.x0;\r
- vertex[3].x=lx3 + PreviousPSXDisplay.Range.x0;\r
- vertex[0].y=ly0 + PreviousPSXDisplay.Range.y0;\r
- vertex[1].y=ly1 + PreviousPSXDisplay.Range.y0;\r
- vertex[2].y=ly2 + PreviousPSXDisplay.Range.y0;\r
- vertex[3].y=ly3 + PreviousPSXDisplay.Range.y0;\r
-\r
- if(iUseMask)\r
-  {\r
-   vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=gl_z;\r
-   gl_z+=0.00004f;\r
-  }\r
-}\r
\r
-///////////////////////////////////////////////////////// \r
-\r
-void offsetBlk(void)\r
-{\r
- if(bDisplayNotSet)\r
-  SetOGLDisplaySettings(1);\r
-                                            \r
- vertex[0].x=lx0-PSXDisplay.GDrawOffset.x + PreviousPSXDisplay.Range.x0;\r
- vertex[1].x=lx1-PSXDisplay.GDrawOffset.x + PreviousPSXDisplay.Range.x0;\r
- vertex[2].x=lx2-PSXDisplay.GDrawOffset.x + PreviousPSXDisplay.Range.x0;\r
- vertex[3].x=lx3-PSXDisplay.GDrawOffset.x + PreviousPSXDisplay.Range.x0;\r
- vertex[0].y=ly0-PSXDisplay.GDrawOffset.y + PreviousPSXDisplay.Range.y0;\r
- vertex[1].y=ly1-PSXDisplay.GDrawOffset.y + PreviousPSXDisplay.Range.y0;\r
- vertex[2].y=ly2-PSXDisplay.GDrawOffset.y + PreviousPSXDisplay.Range.y0;\r
- vertex[3].y=ly3-PSXDisplay.GDrawOffset.y + PreviousPSXDisplay.Range.y0;\r
-\r
- if(iUseMask)\r
-  {\r
-   vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=gl_z;\r
-   gl_z+=0.00004f;\r
-  }\r
-}\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-// texture sow/tow calculations\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-void assignTextureVRAMWrite(void)\r
-{\r
-#ifdef OWNSCALE\r
-\r
- vertex[0].sow=0.5f/ ST_FACVRAMX;\r
- vertex[0].tow=0.5f/ ST_FACVRAM;\r
-\r
- vertex[1].sow=(float)gl_ux[1]/ ST_FACVRAMX;\r
- vertex[1].tow=0.5f/ ST_FACVRAM;\r
-\r
- vertex[2].sow=(float)gl_ux[2]/ ST_FACVRAMX;\r
- vertex[2].tow=(float)gl_vy[2]/ ST_FACVRAM;\r
-\r
- vertex[3].sow=0.5f/ ST_FACVRAMX;\r
- vertex[3].tow=(float)gl_vy[3]/ ST_FACVRAM;\r
-\r
-#else\r
-\r
- if(gl_ux[1]==255)\r
-  {\r
-   vertex[0].sow=(gl_ux[0]*255.99f)/255.0f;\r
-   vertex[1].sow=(gl_ux[1]*255.99f)/255.0f;\r
-   vertex[2].sow=(gl_ux[2]*255.99f)/255.0f;\r
-   vertex[3].sow=(gl_ux[3]*255.99f)/255.0f;\r
-  }\r
- else\r
-  {\r
-   vertex[0].sow=gl_ux[0];\r
-   vertex[1].sow=gl_ux[1];\r
-   vertex[2].sow=gl_ux[2];\r
-   vertex[3].sow=gl_ux[3];\r
-  }\r
-\r
- vertex[0].tow=gl_vy[0];\r
- vertex[1].tow=gl_vy[1];\r
- vertex[2].tow=gl_vy[2];\r
- vertex[3].tow=gl_vy[3];\r
-\r
-#endif\r
-}\r
-\r
-GLuint  gLastTex=0;\r
-GLuint  gLastFMode=(GLuint)-1;\r
-\r
-///////////////////////////////////////////////////////// \r
-\r
-void assignTextureSprite(void)\r
-{\r
- if(bUsingTWin)\r
-  {\r
-   vertex[0].sow=vertex[3].sow=(float)gl_ux[0]/TWin.UScaleFactor;\r
-   vertex[1].sow=vertex[2].sow=(float)sSprite_ux2/TWin.UScaleFactor;\r
-   vertex[0].tow=vertex[1].tow=(float)gl_vy[0]/TWin.VScaleFactor;\r
-   vertex[2].tow=vertex[3].tow=(float)sSprite_vy2/TWin.VScaleFactor;\r
-   gLastTex=gTexName;\r
-\r
-   if(iFilterType>0 && iFilterType<3 && iHiResTextures!=2) \r
-    {\r
-     float fxmin=65536.0f,fxmax=0.0f,fymin=65536.0f,fymax=0.0f;int i;\r
-\r
-     for(i=0;i<4;i++)\r
-      {\r
-       if(vertex[i].sow<fxmin) fxmin=vertex[i].sow;\r
-       if(vertex[i].tow<fymin) fymin=vertex[i].tow;\r
-       if(vertex[i].sow>fxmax) fxmax=vertex[i].sow;\r
-       if(vertex[i].tow>fymax) fymax=vertex[i].tow; \r
-      }\r
-\r
-     for(i=0;i<4;i++)\r
-      {\r
-#ifdef OWNSCALE\r
-       if(vertex[i].sow==fxmin) vertex[i].sow+=0.375f/(float)TWin.Position.x1;\r
-       if(vertex[i].sow==fxmax) vertex[i].sow-=0.375f/(float)TWin.Position.x1;\r
-       if(vertex[i].tow==fymin) vertex[i].tow+=0.375f/(float)TWin.Position.y1;\r
-       if(vertex[i].tow==fymax) vertex[i].tow-=0.375f/(float)TWin.Position.y1;\r
-#else\r
-       if(vertex[i].sow==fxmin) vertex[i].sow+=96.0f/(float)TWin.Position.x1;\r
-       if(vertex[i].sow==fxmax) vertex[i].sow-=96.0f/(float)TWin.Position.x1;\r
-       if(vertex[i].tow==fymin) vertex[i].tow+=96.0f/(float)TWin.Position.y1;\r
-       if(vertex[i].tow==fymax) vertex[i].tow-=96.0f/(float)TWin.Position.y1;\r
-#endif\r
-      }\r
-    }\r
-\r
-  }\r
- else\r
-  {\r
-#ifdef OWNSCALE\r
-\r
-   vertex[0].sow=vertex[3].sow=(float)gl_ux[0]     / ST_FACSPRITE;\r
-   vertex[1].sow=vertex[2].sow=(float)sSprite_ux2  / ST_FACSPRITE;\r
-   vertex[0].tow=vertex[1].tow=(float)gl_vy[0]     / ST_FACSPRITE;\r
-   vertex[2].tow=vertex[3].tow=(float)sSprite_vy2  / ST_FACSPRITE;\r
-\r
-#else\r
\r
-   vertex[0].sow=vertex[3].sow=gl_ux[0];\r
-   vertex[1].sow=vertex[2].sow=sSprite_ux2;\r
-   vertex[0].tow=vertex[1].tow=gl_vy[0];\r
-   vertex[2].tow=vertex[3].tow=sSprite_vy2;\r
-\r
-#endif\r
-\r
-   if(iFilterType>2) \r
-    {\r
-     if(gLastTex!=gTexName || gLastFMode!=0)\r
-      {\r
-       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);\r
-       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);\r
-       gLastTex=gTexName;gLastFMode=0;\r
-      }\r
-    }\r
-  }\r
-\r
- if(usMirror & 0x1000) \r
-  {\r
-   vertex[0].sow=vertex[1].sow;\r
-   vertex[1].sow=vertex[2].sow=vertex[3].sow;\r
-   vertex[3].sow=vertex[0].sow;\r
-  }\r
-\r
- if(usMirror & 0x2000) \r
-  {\r
-   vertex[0].tow=vertex[3].tow;\r
-   vertex[2].tow=vertex[3].tow=vertex[1].tow;\r
-   vertex[1].tow=vertex[0].tow;\r
-  }\r
-\r
-}\r
-\r
-///////////////////////////////////////////////////////// \r
-\r
-void assignTexture3(void)\r
-{\r
- if(bUsingTWin)\r
-  {\r
-   vertex[0].sow=(float)gl_ux[0]/TWin.UScaleFactor;\r
-   vertex[0].tow=(float)gl_vy[0]/TWin.VScaleFactor;\r
-   vertex[1].sow=(float)gl_ux[1]/TWin.UScaleFactor;\r
-   vertex[1].tow=(float)gl_vy[1]/TWin.VScaleFactor;\r
-   vertex[2].sow=(float)gl_ux[2]/TWin.UScaleFactor;\r
-   vertex[2].tow=(float)gl_vy[2]/TWin.VScaleFactor;\r
-   gLastTex=gTexName;\r
-  }\r
- else\r
-  {\r
-#ifdef OWNSCALE\r
-   vertex[0].sow=(float)gl_ux[0] / ST_FACTRI;\r
-   vertex[0].tow=(float)gl_vy[0] / ST_FACTRI;\r
-   vertex[1].sow=(float)gl_ux[1] / ST_FACTRI;\r
-\r
-   vertex[1].tow=(float)gl_vy[1] / ST_FACTRI;\r
-   vertex[2].sow=(float)gl_ux[2] / ST_FACTRI;\r
-   vertex[2].tow=(float)gl_vy[2] / ST_FACTRI;\r
-#else\r
-   vertex[0].sow=gl_ux[0];\r
-   vertex[0].tow=gl_vy[0];\r
-   vertex[1].sow=gl_ux[1];\r
-   vertex[1].tow=gl_vy[1];\r
-   vertex[2].sow=gl_ux[2];\r
-   vertex[2].tow=gl_vy[2];\r
-#endif\r
-\r
-   if(iFilterType>2) \r
-    {\r
-     if(gLastTex!=gTexName || gLastFMode!=1)\r
-      {\r
-       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\r
-       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\r
-       gLastTex=gTexName;gLastFMode=1;\r
-      }\r
-    }\r
-\r
-   if(iFilterType) \r
-    {\r
-     float fxmin=256.0f,fxmax=0.0f,fymin=256.0f,fymax=0.0f;int i;\r
-     for(i=0;i<3;i++)\r
-      {\r
-       if(vertex[i].sow<fxmin) fxmin=vertex[i].sow;\r
-       if(vertex[i].tow<fymin) fymin=vertex[i].tow;\r
-       if(vertex[i].sow>fxmax) fxmax=vertex[i].sow;\r
-       if(vertex[i].tow>fymax) fymax=vertex[i].tow; \r
-      }\r
-\r
-     for(i=0;i<3;i++)\r
-      {\r
-       if(vertex[i].sow==fxmin) vertex[i].sow+=ST_BFFACSORT;\r
-       if(vertex[i].sow==fxmax) vertex[i].sow-=ST_BFFACSORT;\r
-       if(vertex[i].tow==fymin) vertex[i].tow+=ST_BFFACSORT;\r
-       if(vertex[i].tow==fymax) vertex[i].tow-=ST_BFFACSORT;\r
-      }\r
-    }\r
-  }\r
-}\r
-\r
-///////////////////////////////////////////////////////// \r
-\r
-void assignTexture4(void)\r
-{\r
- if(bUsingTWin)\r
-  {\r
-   vertex[0].sow=(float)gl_ux[0]/TWin.UScaleFactor;\r
-   vertex[0].tow=(float)gl_vy[0]/TWin.VScaleFactor;\r
-   vertex[1].sow=(float)gl_ux[1]/TWin.UScaleFactor;\r
-   vertex[1].tow=(float)gl_vy[1]/TWin.VScaleFactor;\r
-   vertex[2].sow=(float)gl_ux[2]/TWin.UScaleFactor;\r
-   vertex[2].tow=(float)gl_vy[2]/TWin.VScaleFactor;\r
-   vertex[3].sow=(float)gl_ux[3]/TWin.UScaleFactor;\r
-   vertex[3].tow=(float)gl_vy[3]/TWin.VScaleFactor;\r
-   gLastTex=gTexName;\r
-  }\r
- else\r
-  {\r
-#ifdef OWNSCALE\r
-   vertex[0].sow=(float)gl_ux[0] / ST_FAC;\r
-   vertex[0].tow=(float)gl_vy[0] / ST_FAC;\r
-   vertex[1].sow=(float)gl_ux[1] / ST_FAC;\r
-   vertex[1].tow=(float)gl_vy[1] / ST_FAC;\r
-   vertex[2].sow=(float)gl_ux[2] / ST_FAC;\r
-   vertex[2].tow=(float)gl_vy[2] / ST_FAC;\r
-   vertex[3].sow=(float)gl_ux[3] / ST_FAC;\r
-   vertex[3].tow=(float)gl_vy[3] / ST_FAC;\r
-#else\r
-   vertex[0].sow=gl_ux[0];\r
-   vertex[0].tow=gl_vy[0];\r
-   vertex[1].sow=gl_ux[1];\r
-   vertex[1].tow=gl_vy[1];\r
-   vertex[2].sow=gl_ux[2];\r
-   vertex[2].tow=gl_vy[2];\r
-   vertex[3].sow=gl_ux[3];\r
-   vertex[3].tow=gl_vy[3];\r
-#endif\r
-\r
-   if(iFilterType>2) \r
-    {\r
-     if(gLastTex!=gTexName || gLastFMode!=1)\r
-      {\r
-       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\r
-       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\r
-       gLastTex=gTexName;gLastFMode=1;\r
-      }\r
-    }\r
-\r
-   if(iFilterType) \r
-    {\r
-     float fxmin=256.0f,fxmax=0.0f,fymin=256.0f,fymax=0.0f;int i;\r
-     for(i=0;i<4;i++)\r
-      {\r
-       if(vertex[i].sow<fxmin) fxmin=vertex[i].sow;\r
-       if(vertex[i].tow<fymin) fymin=vertex[i].tow;\r
-       if(vertex[i].sow>fxmax) fxmax=vertex[i].sow;\r
-       if(vertex[i].tow>fymax) fymax=vertex[i].tow; \r
-      }\r
-\r
-     for(i=0;i<4;i++)\r
-      {\r
-       if(vertex[i].sow==fxmin) vertex[i].sow+=ST_BFFACSORT;\r
-       if(vertex[i].sow==fxmax) vertex[i].sow-=ST_BFFACSORT;\r
-       if(vertex[i].tow==fymin) vertex[i].tow+=ST_BFFACSORT;\r
-       if(vertex[i].tow==fymax) vertex[i].tow-=ST_BFFACSORT;\r
-      }\r
-    }\r
-  }\r
-}\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-////////////////////////////////////////////////////////////////////////\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-// render pos / buffers\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-#define EqualRect(pr1,pr2) ((pr1)->left==(pr2)->left && (pr1)->top==(pr2)->top && (pr1)->right==(pr2)->right && (pr1)->bottom==(pr2)->bottom)\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-// SetDisplaySettings: "simply" calcs the new drawing area and updates\r
-//                     the ogl clipping (scissor) \r
-\r
-BOOL bSetClip=FALSE;\r
-\r
-void SetOGLDisplaySettings(BOOL DisplaySet)\r
-{\r
- static RECT rprev={0,0,0,0};\r
- static RECT rC   ={0,0,0,0};\r
- static int iOldX=0;\r
- static int iOldY=0;\r
- RECT r;float XS,YS;\r
-\r
- bDisplayNotSet = FALSE;\r
-\r
- //----------------------------------------------------// that's a whole screen upload\r
- if(!DisplaySet)\r
-  {\r
-   RECT rX;\r
-   PSXDisplay.GDrawOffset.x=0;\r
-   PSXDisplay.GDrawOffset.y=0;\r
-\r
-   PSXDisplay.CumulOffset.x = PSXDisplay.DrawOffset.x+PreviousPSXDisplay.Range.x0;\r
-   PSXDisplay.CumulOffset.y = PSXDisplay.DrawOffset.y+PreviousPSXDisplay.Range.y0;\r
-\r
-   rprev.left=rprev.left+1;\r
-\r
-   rX=rRatioRect;\r
-   rX.top=iResY-(rRatioRect.top+rRatioRect.bottom);\r
-\r
-   if(bSetClip || !EqualRect(&rC,&rX))\r
-    {\r
-     rC=rX;\r
-     glScissor(rC.left,rC.top,rC.right,rC.bottom);\r
-     bSetClip=FALSE; \r
-    }\r
-   return;\r
-  }\r
- //----------------------------------------------------// \r
-\r
- PSXDisplay.GDrawOffset.y = PreviousPSXDisplay.DisplayPosition.y;\r
- PSXDisplay.GDrawOffset.x = PreviousPSXDisplay.DisplayPosition.x;\r
- PSXDisplay.CumulOffset.x = PSXDisplay.DrawOffset.x - PSXDisplay.GDrawOffset.x+PreviousPSXDisplay.Range.x0;\r
- PSXDisplay.CumulOffset.y = PSXDisplay.DrawOffset.y - PSXDisplay.GDrawOffset.y+PreviousPSXDisplay.Range.y0;\r
-\r
- r.top   =PSXDisplay.DrawArea.y0 - PreviousPSXDisplay.DisplayPosition.y;\r
- r.bottom=PSXDisplay.DrawArea.y1 - PreviousPSXDisplay.DisplayPosition.y;\r
-\r
- if(r.bottom<0 || r.top>=PSXDisplay.DisplayMode.y)\r
-  {\r
-   r.top   =PSXDisplay.DrawArea.y0 - PSXDisplay.DisplayPosition.y;\r
-   r.bottom=PSXDisplay.DrawArea.y1 - PSXDisplay.DisplayPosition.y;\r
-  }\r
-\r
- r.left  =PSXDisplay.DrawArea.x0 - PreviousPSXDisplay.DisplayPosition.x;\r
- r.right =PSXDisplay.DrawArea.x1 - PreviousPSXDisplay.DisplayPosition.x;\r
-\r
- if(r.right<0 || r.left>=PSXDisplay.DisplayMode.x)\r
-  {\r
-   r.left  =PSXDisplay.DrawArea.x0 - PSXDisplay.DisplayPosition.x;\r
-   r.right =PSXDisplay.DrawArea.x1 - PSXDisplay.DisplayPosition.x;\r
-  }\r
-\r
- if(!bSetClip && EqualRect(&r,&rprev) &&\r
-    iOldX == PSXDisplay.DisplayMode.x &&\r
-    iOldY == PSXDisplay.DisplayMode.y)\r
-  return;\r
-\r
- rprev = r;\r
- iOldX = PSXDisplay.DisplayMode.x;\r
- iOldY = PSXDisplay.DisplayMode.y;\r
-\r
- XS=(float)rRatioRect.right/(float)PSXDisplay.DisplayMode.x;\r
- YS=(float)rRatioRect.bottom/(float)PSXDisplay.DisplayMode.y;\r
-\r
- if(PreviousPSXDisplay.Range.x0)\r
-  {\r
-   short s=PreviousPSXDisplay.Range.x0+PreviousPSXDisplay.Range.x1;\r
-\r
-   r.left+=PreviousPSXDisplay.Range.x0+1;\r
-\r
-   r.right+=PreviousPSXDisplay.Range.x0;\r
-\r
-   if(r.left>s)  r.left=s;\r
-   if(r.right>s) r.right=s;\r
-  }\r
-\r
- if(PreviousPSXDisplay.Range.y0)\r
-  {\r
-   short s=PreviousPSXDisplay.Range.y0+PreviousPSXDisplay.Range.y1;\r
-\r
-   r.top+=PreviousPSXDisplay.Range.y0+1;\r
-   r.bottom+=PreviousPSXDisplay.Range.y0;\r
-\r
-   if(r.top>s)    r.top=s;\r
-   if(r.bottom>s) r.bottom=s;\r
-  }\r
-\r
- // Set the ClipArea variables to reflect the new screen,\r
- // offset from zero (since it is a new display buffer)\r
- r.left   = (int)(((float)(r.left))      *XS);\r
- r.top    = (int)(((float)(r.top))       *YS);\r
- r.right  = (int)(((float)(r.right  + 1))*XS);\r
- r.bottom = (int)(((float)(r.bottom + 1))*YS);\r
-\r
- // Limit clip area to the screen size\r
- if (r.left   > iResX)   r.left   = iResX;\r
- if (r.left   < 0)       r.left   = 0;\r
- if (r.top    > iResY)   r.top    = iResY;\r
- if (r.top    < 0)       r.top    = 0;\r
- if (r.right  > iResX)   r.right  = iResX;\r
- if (r.right  < 0)       r.right  = 0;\r
- if (r.bottom > iResY)   r.bottom = iResY;\r
- if (r.bottom < 0)       r.bottom = 0;\r
-\r
- r.right -=r.left;\r
- r.bottom-=r.top;\r
- r.top=iResY-(r.top+r.bottom);\r
-\r
- r.left+=rRatioRect.left;\r
- r.top -=rRatioRect.top;\r
-\r
- if(bSetClip || !EqualRect(&r,&rC))\r
-  {\r
-   glScissor(r.left,r.top,r.right,r.bottom);\r
-   rC=r;\r
-   bSetClip=FALSE;\r
-  }\r
-}\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-////////////////////////////////////////////////////////////////////////\r
-////////////////////////////////////////////////////////////////////////\r
-\r
diff --git a/plugins/peopsxgl/draw.h b/plugins/peopsxgl/draw.h
deleted file mode 100644 (file)
index 14d2373..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/***************************************************************************\r
-                            draw.h  -  description\r
-                             -------------------\r
-    begin                : Sun Mar 08 2009\r
-    copyright            : (C) 1999-2009 by Pete Bernert\r
-    web                  : www.pbernert.com   \r
- ***************************************************************************/\r
-\r
-/***************************************************************************\r
- *                                                                         *\r
- *   This program is free software; you can redistribute it and/or modify  *\r
- *   it under the terms of the GNU General Public License as published by  *\r
- *   the Free Software Foundation; either version 2 of the License, or     *\r
- *   (at your option) any later version. See also the license.txt file for *\r
- *   additional informations.                                              *\r
- *                                                                         *\r
- ***************************************************************************/\r
-\r
-#ifndef _GL_DRAW_H_\r
-#define _GL_DRAW_H_\r
-\r
-// internally used defines\r
-\r
-#define GPUCOMMAND(x) ((x>>24) & 0xff)\r
-#define RED(x) (x & 0xff)\r
-#define BLUE(x) ((x>>16) & 0xff)\r
-#define GREEN(x) ((x>>8) & 0xff)\r
-#define COLOR(x) (x & 0xffffff)\r
-\r
-// prototypes\r
-int  GLinitialize();\r
-void GLcleanup();\r
-BOOL offset2(void);\r
-BOOL offset3(void);\r
-BOOL offset4(void);\r
-BOOL offsetline(void);\r
-void offsetST(void);\r
-void offsetBlk(void);\r
-void offsetScreenUpload(int Position);\r
-void assignTexture3(void);\r
-void assignTexture4(void);\r
-void assignTextureSprite(void);\r
-void assignTextureVRAMWrite(void);\r
-void SetOGLDisplaySettings (BOOL DisplaySet);\r
-void ReadConfig(void);\r
-void WriteConfig(void);\r
-void SetExtGLFuncs(void);\r
-\r
-///////////////////////////////////////////////////////////////////////\r
-\r
-#endif // _GL_DRAW_H_\r
diff --git a/plugins/peopsxgl/externals.h b/plugins/peopsxgl/externals.h
deleted file mode 100644 (file)
index 8ce2b91..0000000
+++ /dev/null
@@ -1,413 +0,0 @@
-/***************************************************************************\r
-                          external.h  -  description\r
-                             -------------------\r
-    begin                : Sun Mar 08 2009\r
-    copyright            : (C) 1999-2009 by Pete Bernert\r
-    web                  : www.pbernert.com   \r
- ***************************************************************************/\r
-\r
-/***************************************************************************\r
- *                                                                         *\r
- *   This program is free software; you can redistribute it and/or modify  *\r
- *   it under the terms of the GNU General Public License as published by  *\r
- *   the Free Software Foundation; either version 2 of the License, or     *\r
- *   (at your option) any later version. See also the license.txt file for *\r
- *   additional informations.                                              *\r
- *                                                                         *\r
- ***************************************************************************/\r
-\r
-#define MIRROR_TEST 1\r
-#define SCISSOR_TEST 1\r
-\r
-// for own sow/tow scaling\r
-#define OWNSCALE 1\r
-\r
-#define CLUTUSED     0x80000000\r
-\r
-#define SETCOL(x)  if(x.c.lcol!=ulOLDCOL) {ulOLDCOL=x.c.lcol;glColor4ubv(x.c.col);} \r
-#define SETPCOL(x)  if(x->c.lcol!=ulOLDCOL) {ulOLDCOL=x->c.lcol;glColor4ubv(x->c.col);}\r
-\r
-#define GL_TO_EDGE_CLAMP              0x812F\r
-\r
-#define INFO_TW        0\r
-#define INFO_DRAWSTART 1\r
-#define INFO_DRAWEND   2\r
-#define INFO_DRAWOFF   3\r
-\r
-#define SIGNSHIFT 21\r
-#define CHKMAX_X 1024\r
-#define CHKMAX_Y 512\r
-\r
-// GPU STATUS REGISTER bit values (c) Lewpy\r
-\r
-#define DR_NORMAL 0\r
-#define DR_VRAMTRANSFER 1\r
-\r
-#define GPUSTATUS_ODDLINES            0x80000000\r
-#define GPUSTATUS_DMABITS             0x60000000 // Two bits\r
-#define GPUSTATUS_READYFORCOMMANDS    0x10000000\r
-#define GPUSTATUS_READYFORVRAM        0x08000000\r
-#define GPUSTATUS_IDLE                0x04000000\r
-#define GPUSTATUS_DISPLAYDISABLED     0x00800000\r
-#define GPUSTATUS_INTERLACED          0x00400000\r
-#define GPUSTATUS_RGB24               0x00200000\r
-#define GPUSTATUS_PAL                 0x00100000\r
-#define GPUSTATUS_DOUBLEHEIGHT        0x00080000\r
-#define GPUSTATUS_WIDTHBITS           0x00070000 // Three bits\r
-#define GPUSTATUS_MASKENABLED         0x00001000\r
-#define GPUSTATUS_MASKDRAWN           0x00000800\r
-#define GPUSTATUS_DRAWINGALLOWED      0x00000400\r
-#define GPUSTATUS_DITHER              0x00000200\r
-\r
-#define STATUSREG lGPUstatusRet\r
-\r
-#define GPUIsBusy (STATUSREG &= ~GPUSTATUS_IDLE)\r
-#define GPUIsIdle (STATUSREG |= GPUSTATUS_IDLE)\r
-\r
-#define GPUIsNotReadyForCommands (STATUSREG &= ~GPUSTATUS_READYFORCOMMANDS)\r
-#define GPUIsReadyForCommands (STATUSREG |= GPUSTATUS_READYFORCOMMANDS)\r
-\r
-#define KEY_RESETTEXSTORE   1\r
-#define KEY_SHOWFPS         2\r
-#define KEY_RESETOPAQUE     4\r
-#define KEY_RESETDITHER     8\r
-#define KEY_RESETFILTER     16\r
-#define KEY_RESETADVBLEND   32\r
-#define KEY_BLACKWHITE      64\r
-#define KEY_TOGGLEFBTEXTURE 128\r
-#define KEY_STEPDOWN        256\r
-#define KEY_TOGGLEFBREAD    512\r
-\r
-#define FALSE 0\r
-#define TRUE  1\r
-#define BOOL unsigned short\r
-#define bool unsigned short\r
-#define LOWORD(l)           ((unsigned short)(l))\r
-#define HIWORD(l)           ((unsigned short)(((uint32_t)(l) >> 16) & 0xFFFF))\r
-#define max(a,b)            (((a) > (b)) ? (a) : (b))\r
-#define min(a,b)            (((a) < (b)) ? (a) : (b))\r
-#define DWORD uint32_t\r
-\r
-typedef struct RECTTAG\r
-{\r
- int left;\r
- int top;\r
- int right;\r
- int bottom;\r
-}RECT;\r
-\r
-typedef struct VRAMLOADTAG\r
-{\r
- short x;\r
- short y;\r
- short Width;\r
- short Height;\r
- short RowsRemaining;\r
- short ColsRemaining;\r
- unsigned short *ImagePtr;\r
-} VRAMLoad_t;\r
-\r
-typedef struct PSXPOINTTAG\r
-{\r
- int x;\r
- int y;\r
-} PSXPoint_t;\r
-\r
-typedef struct PSXSPOINTTAG\r
-{\r
- short x;\r
- short y;\r
-} PSXSPoint_t;\r
-\r
-typedef struct PSXRECTTAG\r
-{\r
- short x0;\r
- short x1;\r
- short y0;\r
- short y1;\r
-} PSXRect_t;\r
-\r
-typedef struct TWINTAG\r
-{\r
- PSXRect_t  Position;\r
- PSXRect_t  OPosition;\r
- PSXPoint_t TextureSize;\r
- float      UScaleFactor;\r
- float      VScaleFactor;\r
-} TWin_t;\r
-\r
-typedef struct PSXDISPLAYTAG\r
-{\r
- PSXPoint_t  DisplayModeNew;\r
- PSXPoint_t  DisplayMode;\r
- PSXPoint_t  DisplayPosition;\r
- PSXPoint_t  DisplayEnd;\r
\r
- int         Double;\r
- int         Height;\r
- int         PAL;\r
- int         InterlacedNew;\r
- int         Interlaced;\r
- int         InterlacedTest;\r
- int         RGB24New;\r
- int         RGB24;\r
- PSXSPoint_t DrawOffset;\r
- PSXRect_t   DrawArea;\r
- PSXPoint_t  GDrawOffset;\r
- PSXPoint_t  CumulOffset;\r
- int         Disabled;\r
- PSXRect_t   Range;\r
-} PSXDisplay_t;\r
-\r
-typedef struct OGLVertexTag \r
-{\r
- GLfloat x;\r
- GLfloat y;\r
- GLfloat z;\r
-\r
- GLfloat sow;\r
- GLfloat tow;\r
-\r
- union COLTAG\r
-  {\r
-   unsigned char col[4];\r
-   unsigned int lcol;\r
-  } c;\r
-} OGLVertex;\r
-\r
-typedef union EXShortTag\r
-{\r
- unsigned char  c[2];\r
- unsigned short s;\r
-} EXShort;\r
-\r
-typedef union EXLongTag\r
-{\r
- unsigned char c[4];\r
- unsigned int  l;\r
- EXShort       s[2];\r
-} EXLong;\r
-\r
-#ifndef _IN_CFG\r
-\r
-extern char *pConfigFile;\r
-\r
-#endif\r
-\r
-#ifndef _IN_DRAW\r
-\r
-extern int            iResX;\r
-extern int            iResY;\r
-extern BOOL           bKeepRatio;\r
-extern RECT           rRatioRect;\r
-extern BOOL           bSnapShot;\r
-extern BOOL           bSmallAlpha;\r
-extern BOOL           bOpaquePass;\r
-extern BOOL           bAdvancedBlend;\r
-extern BOOL           bUseLines;\r
-extern int            iTexQuality;\r
-extern BOOL           bUseAntiAlias;\r
-extern BOOL           bGLExt;\r
-extern BOOL           bGLFastMovie;\r
-extern BOOL           bGLSoft;\r
-extern BOOL           bGLBlend;\r
-\r
-extern PFNGLBLENDEQU      glBlendEquationEXTEx;\r
-extern PFNGLCOLORTABLEEXT glColorTableEXTEx;\r
-\r
-extern unsigned char  gl_ux[8];\r
-extern unsigned char  gl_vy[8];\r
-extern OGLVertex      vertex[4];\r
-extern short          sprtY,sprtX,sprtH,sprtW;\r
-extern BOOL           bIsFirstFrame;\r
-extern int            iWinSize;\r
-extern int            iZBufferDepth;\r
-extern GLbitfield     uiBufferBits;\r
-extern int            iUseMask;\r
-extern int            iSetMask;\r
-extern int            iDepthFunc;\r
-extern BOOL           bCheckMask;\r
-extern unsigned short sSetMask;\r
-extern uint32_t       lSetMask;\r
-extern int            iShowFPS;\r
-extern BOOL           bSetClip;\r
-extern int            iForceVSync;\r
-extern int            iUseExts;\r
-extern int            iUsePalTextures;\r
-extern GLuint         gTexScanName;\r
-\r
-#endif\r
-\r
-#ifndef _IN_SOFT\r
-\r
-extern int            GlobalTextAddrX,GlobalTextAddrY,GlobalTextTP;\r
-extern int            GlobalTextREST,GlobalTextABR,GlobalTextPAGE;\r
-extern short          ly0,lx0,ly1,lx1,ly2,lx2,ly3,lx3;\r
-extern short          g_m1;\r
-extern short          g_m2;\r
-extern short          g_m3;\r
-extern short          DrawSemiTrans;\r
-\r
-#endif\r
-\r
-#ifndef _IN_PRIMDRAW\r
-\r
-extern BOOL          bNeedUploadTest;\r
-extern BOOL          bNeedUploadAfter;\r
-extern BOOL          bTexEnabled;\r
-extern BOOL          bBlendEnable;\r
-extern BOOL          bDrawDither;\r
-extern int           iFilterType; \r
-extern BOOL          bFullVRam;\r
-extern BOOL          bUseMultiPass;\r
-extern int           iOffscreenDrawing;\r
-extern BOOL          bOldSmoothShaded;\r
-extern BOOL          bUsingTWin;\r
-extern BOOL          bUsingMovie;\r
-extern PSXRect_t     xrMovieArea;\r
-extern PSXRect_t     xrUploadArea;\r
-extern PSXRect_t     xrUploadAreaIL;\r
-extern PSXRect_t     xrUploadAreaRGB24;\r
-extern GLuint        gTexName;\r
-extern BOOL          bDrawNonShaded;\r
-extern BOOL          bDrawMultiPass;\r
-extern GLubyte       ubGloColAlpha;\r
-extern GLubyte       ubGloAlpha;\r
-extern short         sSprite_ux2;\r
-extern short         sSprite_vy2;\r
-extern BOOL          bRenderFrontBuffer;\r
-extern uint32_t      ulOLDCOL;\r
-extern uint32_t      ulClutID;\r
-extern void (*primTableJ[256])(unsigned char *);\r
-extern void (*primTableSkip[256])(unsigned char *);\r
-extern unsigned short  usMirror;\r
-extern uint32_t      dwCfgFixes;\r
-extern uint32_t      dwActFixes;\r
-extern uint32_t      dwEmuFixes;\r
-extern BOOL          bUseFixes;\r
-extern int           iSpriteTex;\r
-extern int           iDrawnSomething;\r
-\r
-extern int drawX;\r
-extern int drawY;\r
-extern int drawW;\r
-extern int drawH;\r
-extern short sxmin;\r
-extern short sxmax;\r
-extern short symin;\r
-extern short symax;\r
-\r
-#endif\r
-\r
-#ifndef _IN_TEXTURE\r
-\r
-extern unsigned char  ubOpaqueDraw;\r
-extern GLint          giWantedRGBA;\r
-extern GLint          giWantedFMT;\r
-extern GLint          giWantedTYPE;\r
-extern void           (*LoadSubTexFn) (int,int,short,short);\r
-extern int            GlobalTexturePage;\r
-extern uint32_t       (*TCF[]) (uint32_t);\r
-extern unsigned short (*PTCF[]) (unsigned short);\r
-extern uint32_t       (*PalTexturedColourFn) (uint32_t);\r
-extern BOOL           bUseFastMdec;\r
-extern BOOL           bUse15bitMdec;\r
-extern int            iFrameTexType;\r
-extern int            iFrameReadType;\r
-extern int            iClampType;\r
-extern int            iSortTexCnt;\r
-extern BOOL           bFakeFrontBuffer; \r
-extern GLuint         gTexFrameName;\r
-extern GLuint         gTexBlurName;\r
-extern int            iVRamSize;\r
-extern int            iTexGarbageCollection;\r
-extern int            iFTexA;\r
-extern int            iFTexB;\r
-extern int            iHiResTextures;\r
-extern BOOL           bIgnoreNextTile;\r
-\r
-#endif\r
-\r
-#ifndef _IN_GPU\r
-\r
-extern VRAMLoad_t     VRAMWrite;\r
-extern VRAMLoad_t     VRAMRead;\r
-extern int            iDataWriteMode;\r
-extern int            iDataReadMode;\r
-extern int            iColDepth;\r
-extern BOOL           bChangeRes;\r
-extern BOOL           bWindowMode;\r
-extern char           szDispBuf[];\r
-extern char           szGPUKeys[];\r
-extern PSXDisplay_t   PSXDisplay;\r
-extern PSXDisplay_t   PreviousPSXDisplay;\r
-extern uint32_t       ulKeybits;\r
-extern TWin_t         TWin;\r
-extern BOOL           bDisplayNotSet;\r
-extern int            lGPUstatusRet;\r
-extern short          imageX0,imageX1;\r
-extern short          imageY0,imageY1;\r
-extern int            lClearOnSwap,lClearOnSwapColor;\r
-extern unsigned char  *psxVub;\r
-extern signed char    *psxVsb;\r
-extern unsigned short *psxVuw;\r
-extern signed short   *psxVsw;\r
-extern uint32_t       *psxVul;\r
-extern signed int     *psxVsl;\r
-extern GLfloat        gl_z;\r
-extern BOOL           bNeedRGB24Update;\r
-extern BOOL           bChangeWinMode;\r
-extern GLuint         uiScanLine;\r
-extern int            iUseScanLines;\r
-extern int            lSelectedSlot;\r
-extern int            iScanBlend;\r
-extern BOOL           bInitCap;\r
-extern int            iBlurBuffer;\r
-extern int            iLastRGB24;\r
-extern int            iRenderFVR;\r
-extern int            iNoScreenSaver;\r
-extern uint32_t       ulGPUInfoVals[];\r
-extern BOOL           bNeedInterlaceUpdate;\r
-extern BOOL           bNeedWriteUpload;\r
-extern BOOL           bSkipNextFrame;\r
-\r
-extern int bFullScreen;\r
-\r
-#endif\r
-\r
-#ifndef _IN_MENU\r
-\r
-extern uint32_t       dwCoreFlags;\r
-extern GLuint         gTexPicName;\r
-extern PSXPoint_t     ptCursorPoint[];\r
-extern unsigned short usCursorActive;\r
-\r
-#endif\r
-\r
-#ifndef _IN_FPS\r
-\r
-extern BOOL           bUseFrameLimit;\r
-extern BOOL           bUseFrameSkip;\r
-extern float          fFrameRate;\r
-extern float          fFrameRateHz;\r
-extern int            iFrameLimit;\r
-extern float          fps_skip;\r
-extern float          fps_cur;\r
-\r
-#endif\r
-\r
-#ifndef _IN_KEY\r
-\r
-extern uint32_t      ulKeybits;\r
-\r
-#endif\r
-\r
-#ifndef _IN_ZN\r
-\r
-extern uint32_t      dwGPUVersion;\r
-extern int           iGPUHeight;\r
-extern int           iGPUHeightMask;\r
-extern int           GlobalTextIL;\r
-extern int           iTileCheat;\r
-\r
-#endif\r
diff --git a/plugins/peopsxgl/fps.c b/plugins/peopsxgl/fps.c
deleted file mode 100644 (file)
index dc89600..0000000
+++ /dev/null
@@ -1,396 +0,0 @@
-/***************************************************************************\r
-                          fps.c  -  description\r
-                             -------------------\r
-    begin                : Sun Mar 08 2009\r
-    copyright            : (C) 1999-2009 by Pete Bernert\r
-    web                  : www.pbernert.com   \r
- ***************************************************************************/\r
-\r
-/***************************************************************************\r
- *                                                                         *\r
- *   This program is free software; you can redistribute it and/or modify  *\r
- *   it under the terms of the GNU General Public License as published by  *\r
- *   the Free Software Foundation; either version 2 of the License, or     *\r
- *   (at your option) any later version. See also the license.txt file for *\r
- *   additional informations.                                              *\r
- *                                                                         *\r
- ***************************************************************************/\r
-\r
-//*************************************************************************// \r
-// History of changes:\r
-//\r
-// 2009/03/08 - Pete  \r
-// - generic cleanup for the Peops release\r
-//\r
-//*************************************************************************// \r
-\r
-#include "stdafx.h"\r
-\r
-#define _IN_FPS\r
-\r
-#include "externals.h"\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-// FPS stuff\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-BOOL           bIsPerformanceCounter=FALSE;\r
-float          fFrameRateHz=0;\r
-DWORD          dwFrameRateTicks=16;\r
-float          fFrameRate;\r
-int            iFrameLimit;\r
-BOOL           bUseFrameLimit=FALSE;\r
-BOOL           bUseFrameSkip=0;\r
-DWORD          dwLaceCnt=0;\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-// FPS skipping / limit\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-BOOL         bInitCap = TRUE; \r
-float        fps_skip = 0;\r
-float        fps_cur  = 0;\r
-\r
-#define TIMEBASE 100000\r
-\r
-unsigned long timeGetTime()\r
-{\r
- struct timeval tv;\r
- gettimeofday(&tv, 0);                                // well, maybe there are better ways\r
- return tv.tv_sec * 100000 + tv.tv_usec/10;           // to do that in linux, but at least it works\r
-}\r
-\r
-void FrameCap(void)\r
-{\r
- static unsigned long curticks, lastticks, _ticks_since_last_update;\r
- static unsigned long TicksToWait = 0;\r
- bool Waiting = TRUE;\r
-\r
-  {\r
-   curticks = timeGetTime();\r
-   _ticks_since_last_update = curticks - lastticks;\r
-\r
-    if((_ticks_since_last_update > TicksToWait) ||\r
-       (curticks <lastticks))\r
-    {\r
-     lastticks = curticks;\r
-\r
-     if((_ticks_since_last_update-TicksToWait) > dwFrameRateTicks)\r
-          TicksToWait=0;\r
-     else TicksToWait=dwFrameRateTicks-(_ticks_since_last_update-TicksToWait);\r
-    }\r
-   else\r
-    {\r
-     while (Waiting) \r
-      {\r
-       curticks = timeGetTime(); \r
-       _ticks_since_last_update = curticks - lastticks; \r
-       if ((_ticks_since_last_update > TicksToWait) ||\r
-           (curticks < lastticks)) \r
-        { \r
-         Waiting = FALSE;\r
-         lastticks = curticks;\r
-         TicksToWait = dwFrameRateTicks; \r
-        } \r
-      } \r
-    } \r
-  } \r
-} \r
-\r
-#define MAXSKIP 120\r
-#define MAXLACE 16\r
-\r
-void FrameSkip(void)\r
-{\r
- static int   iNumSkips=0,iAdditionalSkip=0;           // number of additional frames to skip\r
- static DWORD dwLastLace=0;                            // helper var for frame limitation\r
- static DWORD curticks, lastticks, _ticks_since_last_update;\r
-\r
- if(!dwLaceCnt) return;                                // important: if no updatelace happened, we ignore it completely\r
-\r
- if(iNumSkips)                                         // we are in skipping mode?\r
-  {\r
-   dwLastLace+=dwLaceCnt;                              // -> calc frame limit helper (number of laces)\r
-   bSkipNextFrame = TRUE;                              // -> we skip next frame\r
-   iNumSkips--;                                        // -> ok, one done\r
-  }\r
- else                                                  // ok, no additional skipping has to be done... \r
-  {                                                    // we check now, if some limitation is needed, or a new skipping has to get started\r
-   DWORD dwWaitTime;\r
-\r
-   if(bInitCap || bSkipNextFrame)                      // first time or we skipped before?\r
-    {\r
-     if(bUseFrameLimit && !bInitCap)                   // frame limit wanted and not first time called?\r
-      {\r
-       DWORD dwT=_ticks_since_last_update;             // -> that's the time of the last drawn frame\r
-       dwLastLace+=dwLaceCnt;                          // -> and that's the number of updatelace since the start of the last drawn frame\r
-\r
-       curticks = timeGetTime();\r
-       _ticks_since_last_update= dwT+curticks - lastticks;\r
-\r
-       dwWaitTime=dwLastLace*dwFrameRateTicks;         // -> and now we calc the time the real psx would have needed\r
-\r
-       if(_ticks_since_last_update<dwWaitTime)         // -> we were too fast?\r
-        {                                    \r
-         if((dwWaitTime-_ticks_since_last_update)>     // -> some more security, to prevent\r
-            (60*dwFrameRateTicks))                     //    wrong waiting times\r
-          _ticks_since_last_update=dwWaitTime;\r
-\r
-         while(_ticks_since_last_update<dwWaitTime)    // -> loop until we have reached the real psx time\r
-          {                                            //    (that's the additional limitation, yup)\r
-           curticks = timeGetTime();\r
-           _ticks_since_last_update = dwT+curticks - lastticks;\r
-          }\r
-        }\r
-       else                                            // we were still too slow ?!!?\r
-        {\r
-         if(iAdditionalSkip<MAXSKIP)                   // -> well, somewhen we really have to stop skipping on very slow systems\r
-          {\r
-           iAdditionalSkip++;                          // -> inc our watchdog var\r
-           dwLaceCnt=0;                                // -> reset lace count\r
-           lastticks = timeGetTime();\r
-           return;                                     // -> done, we will skip next frame to get more speed\r
-          }\r
-        }\r
-      }\r
-\r
-     bInitCap=FALSE;                                   // -> ok, we have inited the frameskip func\r
-     iAdditionalSkip=0;                                // -> init additional skip\r
-     bSkipNextFrame=FALSE;                             // -> we don't skip the next frame\r
-     lastticks = timeGetTime();\r
-     dwLaceCnt=0;                                      // -> and we start to count the laces \r
-     dwLastLace=0;      \r
-     _ticks_since_last_update=0;\r
-     return;                                           // -> done, the next frame will get drawn\r
-    }\r
-\r
-   bSkipNextFrame=FALSE;                               // init the frame skip signal to 'no skipping' first\r
-\r
-   curticks = timeGetTime();\r
-   _ticks_since_last_update = curticks - lastticks;\r
-\r
-   dwLastLace=dwLaceCnt;                               // store curr count (frame limitation helper)\r
-   dwWaitTime=dwLaceCnt*dwFrameRateTicks;              // calc the 'real psx lace time'\r
-\r
-   if(_ticks_since_last_update>dwWaitTime)             // hey, we needed way too long for that frame...\r
-    {\r
-     if(bUseFrameLimit)                                // if limitation, we skip just next frame,\r
-      {                                                // and decide after, if we need to do more\r
-       iNumSkips=0;\r
-      }\r
-     else\r
-      {\r
-       iNumSkips=_ticks_since_last_update/dwWaitTime;  // -> calc number of frames to skip to catch up\r
-       iNumSkips--;                                    // -> since we already skip next frame, one down\r
-       if(iNumSkips>MAXSKIP) iNumSkips=MAXSKIP;        // -> well, somewhere we have to draw a line\r
-      }\r
-     bSkipNextFrame = TRUE;                            // -> signal for skipping the next frame\r
-    }\r
-   else                                                // we were faster than real psx? fine :)\r
-   if(bUseFrameLimit)                                  // frame limit used? so we wait til the 'real psx time' has been reached\r
-    {\r
-     if(dwLaceCnt>MAXLACE)                             // -> security check\r
-      _ticks_since_last_update=dwWaitTime;\r
-\r
-     while(_ticks_since_last_update<dwWaitTime)        // just do a waiting loop...\r
-      {\r
-       curticks = timeGetTime();\r
-       _ticks_since_last_update = curticks - lastticks;\r
-      }\r
-    }\r
-\r
-   lastticks = timeGetTime();\r
-  }\r
-\r
- dwLaceCnt=0;                                          // init lace counter\r
-}\r
-\r
-void calcfps(void) \r
-{ \r
- static unsigned long curticks,_ticks_since_last_update,lastticks; \r
- static long   fps_cnt = 0;\r
- static unsigned long  fps_tck = 1; \r
- static long           fpsskip_cnt = 0;\r
- static unsigned long  fpsskip_tck = 1;\r
\r
-  { \r
-   curticks = timeGetTime(); \r
-   _ticks_since_last_update=curticks-lastticks; \r
\r
-   if(bUseFrameSkip && !bUseFrameLimit && _ticks_since_last_update) \r
-    fps_skip=min(fps_skip,((float)TIMEBASE/(float)_ticks_since_last_update+1.0f));\r
\r
-   lastticks = curticks; \r
-  } \r
\r
- if(bUseFrameSkip && bUseFrameLimit)\r
-  {\r
-   fpsskip_tck += _ticks_since_last_update;\r
-\r
-   if(++fpsskip_cnt==2)\r
-    {\r
-     fps_skip = (float)2000/(float)fpsskip_tck;\r
-\r
-     fps_skip +=6.0f;\r
-\r
-     fpsskip_cnt = 0;\r
-     fpsskip_tck = 1;\r
-    }\r
-  }\r
-\r
- fps_tck += _ticks_since_last_update; \r
\r
- if(++fps_cnt==10) \r
-  { \r
-   fps_cur = (float)(TIMEBASE*10)/(float)fps_tck; \r
-\r
-   fps_cnt = 0; \r
-   fps_tck = 1; \r
\r
-   if(bUseFrameLimit && fps_cur>fFrameRateHz)            // optical adjust ;) avoids flickering fps display \r
-    fps_cur=fFrameRateHz; \r
-  } \r
-} \r
-\r
-void PCFrameCap (void) \r
-{\r
- static unsigned long curticks, lastticks, _ticks_since_last_update;\r
- static unsigned long TicksToWait = 0;\r
- bool Waiting = TRUE; \r
\r
- while (Waiting) \r
-  {\r
-   curticks = timeGetTime(); \r
-   _ticks_since_last_update = curticks - lastticks; \r
-   if ((_ticks_since_last_update > TicksToWait) ||  \r
-       (curticks < lastticks)) \r
-    { \r
-     Waiting = FALSE; \r
-     lastticks = curticks; \r
-     TicksToWait = (TIMEBASE / (unsigned long)fFrameRateHz); \r
-    } \r
-  } \r
-} \r
-\r
-void PCcalcfps(void) \r
-{ \r
- static unsigned long curticks,_ticks_since_last_update,lastticks; \r
- static long  fps_cnt = 0; \r
- static float fps_acc = 0;\r
- float CurrentFPS=0;     \r
-  \r
- curticks = timeGetTime(); \r
- _ticks_since_last_update=curticks-lastticks;\r
- if(_ticks_since_last_update) \r
-      CurrentFPS=(float)TIMEBASE/(float)_ticks_since_last_update;\r
- else CurrentFPS = 0;\r
- lastticks = curticks; \r
\r
- fps_acc += CurrentFPS;\r
-\r
- if(++fps_cnt==10)\r
-  {\r
-   fps_cur = fps_acc / 10;\r
-   fps_acc = 0;\r
-   fps_cnt = 0;\r
-  }\r
-\r
- fps_skip=CurrentFPS+1.0f;\r
-}\r
-\r
-void SetAutoFrameCap(void)\r
-{\r
- if(iFrameLimit==1)\r
-  {\r
-   fFrameRateHz = fFrameRate;\r
-   dwFrameRateTicks=(TIMEBASE / (unsigned long)fFrameRateHz);\r
-   return;\r
-  }\r
-\r
- if(dwActFixes&128)\r
-  {\r
-   if (PSXDisplay.Interlaced)\r
-        fFrameRateHz = PSXDisplay.PAL?50.0f:60.0f;\r
-   else fFrameRateHz = PSXDisplay.PAL?25.0f:30.0f;\r
-  }\r
- else\r
-  {\r
-   //fFrameRateHz = PSXDisplay.PAL?50.0f:59.94f;\r
-\r
-   if(PSXDisplay.PAL)\r
-    {\r
-     if (STATUSREG&GPUSTATUS_INTERLACED)\r
-           fFrameRateHz=33868800.0f/677343.75f;        // 50.00238\r
-      else fFrameRateHz=33868800.0f/680595.00f;        // 49.76351\r
-    }                                                     \r
-   else\r
-    {\r
-     if (STATUSREG&GPUSTATUS_INTERLACED)\r
-           fFrameRateHz=33868800.0f/565031.25f;        // 59.94146\r
-      else fFrameRateHz=33868800.0f/566107.50f;        // 59.82750\r
-    }\r
-\r
-   dwFrameRateTicks=(TIMEBASE / (unsigned long)fFrameRateHz);\r
-  }\r
-}\r
-\r
-void SetFrameRateConfig(void)\r
-{\r
- if(!fFrameRate) fFrameRate=200.0f;\r
-\r
- if(fFrameRateHz==0) \r
-  {                                                    \r
-   if(iFrameLimit==2) fFrameRateHz=59.94f;             // auto framerate? set some init val (no pal/ntsc known yet)\r
-   else               fFrameRateHz=fFrameRate;         // else set user framerate\r
-  }\r
-\r
- dwFrameRateTicks=(TIMEBASE / (unsigned long)fFrameRateHz);\r
-\r
- if(iFrameLimit==2) SetAutoFrameCap();\r
-}\r
-\r
-void InitFrameCap(void)\r
-{\r
-}\r
-\r
-void ReInitFrameCap(void)\r
-{\r
-}\r
-\r
-void CheckFrameRate(void)                              // called in updatelace (on every emulated psx vsync)\r
-{\r
- if(bUseFrameSkip) \r
-  {\r
-   if(!(dwActFixes&0x100))\r
-    {\r
-     dwLaceCnt++;                                      // -> and store cnt of vsync between frames\r
-     if(dwLaceCnt>=MAXLACE && bUseFrameLimit) \r
-      {\r
-       if(dwLaceCnt==MAXLACE) bInitCap=TRUE;\r
-       FrameCap();\r
-      }\r
-    }\r
-   else if(bUseFrameLimit) FrameCap();\r
-   calcfps();                                          // -> calc fps display in skipping mode\r
-  }                                                  \r
- else                                                  // -> non-skipping mode:\r
-  {\r
-   if(bUseFrameLimit) FrameCap();\r
-   if(ulKeybits&KEY_SHOWFPS) calcfps();  \r
-  }\r
-}\r
-\r
-void CALLBACK GPUsetframelimit(unsigned long option)   // new EPSXE interface func: main emu can enable/disable fps limitation this way\r
-{\r
- bInitCap = TRUE;\r
-\r
- if(option==1)                                         // emu says: limit\r
-  {\r
-   bUseFrameLimit=TRUE;bUseFrameSkip=FALSE;iFrameLimit=2;\r
-   SetAutoFrameCap();\r
-  }\r
- else                                                  // emu says: no limit\r
-  {\r
-   bUseFrameLimit=FALSE;\r
-  }\r
-}\r
diff --git a/plugins/peopsxgl/fps.h b/plugins/peopsxgl/fps.h
deleted file mode 100644 (file)
index 3b1951b..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/***************************************************************************\r
-                          fps.h  -  description\r
-                             -------------------\r
-    begin                : Sun Mar 08 2009\r
-    copyright            : (C) 1999-2009 by Pete Bernert\r
-    web                  : www.pbernert.com   \r
- ***************************************************************************/\r
-\r
-/***************************************************************************\r
- *                                                                         *\r
- *   This program is free software; you can redistribute it and/or modify  *\r
- *   it under the terms of the GNU General Public License as published by  *\r
- *   the Free Software Foundation; either version 2 of the License, or     *\r
- *   (at your option) any later version. See also the license.txt file for *\r
- *   additional informations.                                              *\r
- *                                                                         *\r
- ***************************************************************************/\r
-\r
-void InitFrameCap(void);\r
-void SetFrameRateConfig(void);\r
-void PCFrameCap(void);\r
-void PCcalcfps(void);\r
-void FrameSkip(void);\r
-void CheckFrameRate(void);\r
-void ReInitFrameCap(void);\r
-void SetAutoFrameCap(void);\r
-\r
-unsigned long timeGetTime();\r
diff --git a/plugins/peopsxgl/gl_ext.h b/plugins/peopsxgl/gl_ext.h
deleted file mode 100644 (file)
index be0db43..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-#define COMBINE_EXT          0x8570
-#define COMBINE_RGB_EXT      0x8571\r
-#define COMBINE_ALPHA_EXT    0x8572\r
-#define SOURCE0_RGB_EXT      0x8580\r
-#define SOURCE1_RGB_EXT      0x8581\r
-#define SOURCE2_RGB_EXT      0x8582\r
-#define SOURCE0_ALPHA_EXT    0x8588\r
-#define SOURCE1_ALPHA_EXT    0x8589\r
-#define SOURCE2_ALPHA_EXT    0x858A\r
-#define OPERAND0_RGB_EXT     0x8590\r
-#define OPERAND1_RGB_EXT     0x8591\r
-#define OPERAND2_RGB_EXT     0x8592\r
-#define OPERAND0_ALPHA_EXT   0x8598\r
-#define OPERAND1_ALPHA_EXT   0x8599\r
-#define OPERAND2_ALPHA_EXT   0x859A\r
-#define RGB_SCALE_EXT        0x8573\r
-#define ADD_SIGNED_EXT       0x8574\r
-#define INTERPOLATE_EXT      0x8575\r
-#define CONSTANT_EXT         0x8576\r
-#define PRIMARY_COLOR_EXT    0x8577\r
-#define PREVIOUS_EXT         0x8578\r
-\r
-#define FUNC_ADD_EXT             0x8006\r
-#define FUNC_REVERSESUBTRACT_EXT 0x800B\r
-
-typedef void (* PFNGLBLENDEQU) (GLenum mode);
-typedef void (* PFNGLCOLORTABLEEXT)
-    (GLenum target, GLenum internalFormat, GLsizei width, GLenum format,
-     GLenum type, const GLvoid *data);
-
-#define GL_UNSIGNED_SHORT_4_4_4_4_EXT       0x8033
-#define GL_UNSIGNED_SHORT_5_5_5_1_EXT       0x8034
-
-#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
-#define GL_TEXTURE_MAX_ANISOTROPY_EXT     0x84FE
-
-//GL_ALPHA_SCALE
diff --git a/plugins/peopsxgl/gpu.c b/plugins/peopsxgl/gpu.c
deleted file mode 100644 (file)
index 307a1ed..0000000
+++ /dev/null
@@ -1,3196 +0,0 @@
-/***************************************************************************\r
-                           gpu.c  -  description\r
-                             -------------------\r
-    begin                : Sun Mar 08 2009\r
-    copyright            : (C) 1999-2009 by Pete Bernert\r
-    email                : BlackDove@addcom.de\r
- ***************************************************************************/\r
-\r
-/***************************************************************************\r
- *                                                                         *\r
- *   This program is free software; you can redistribute it and/or modify  *\r
- *   it under the terms of the GNU General Public License as published by  *\r
- *   the Free Software Foundation; either version 2 of the License, or     *\r
- *   (at your option) any later version. See also the license.txt file for *\r
- *   additional informations.                                              *\r
- *                                                                         *\r
- ***************************************************************************/\r
-\r
-// !!! enable this, if Linux XF86VidMode is not supported: \r
-//#define NOVMODE\r
-\r
-#include "stdafx.h"\r
-#include "config.h"\r
-\r
-#ifndef NOVMODE\r
-#include <X11/extensions/xf86vmode.h>\r
-static XF86VidModeModeInfo **modes=0;\r
-static int iOldMode=0;\r
-#endif\r
-\r
-#define _IN_GPU\r
-\r
-#include "externals.h"\r
-#include "gpu.h"\r
-#include "draw.h"\r
-#include "cfg.h"\r
-#include "prim.h"\r
-#include "psemu_plugin_defs.h"\r
-#include "texture.h"\r
-#include "menu.h"\r
-#include "fps.h"\r
-#include "key.h"\r
-#ifdef ENABLE_NLS\r
-#include <libintl.h>\r
-#include <locale.h>\r
-#define _(x)  gettext(x)\r
-#define N_(x) (x)\r
-#else\r
-#define _(x)  (x)\r
-#define N_(x) (x)\r
-#endif\r
-                               \r
-////////////////////////////////////////////////////////////////////////\r
-// PPDK developer must change libraryName field and can change revision and build\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-const  unsigned char version  = 1;    // do not touch - library for PSEmu 1.x\r
-const  unsigned char revision = 1;\r
-const  unsigned char build    = 78;\r
-\r
-static char *libraryName     = N_("OpenGL Driver");\r
-\r
-static char *PluginAuthor    = N_("Pete Bernert");\r
-static char *libraryInfo     = N_("Based on P.E.Op.S. MesaGL Driver V1.78\nCoded by Pete Bernert\n");\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-// memory image of the PSX vram\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-unsigned char  *psxVSecure;\r
-unsigned char  *psxVub;\r
-signed   char  *psxVsb;\r
-unsigned short *psxVuw;\r
-unsigned short *psxVuw_eom;\r
-signed   short *psxVsw;\r
-uint32_t       *psxVul;\r
-signed   int   *psxVsl;\r
-\r
-// macro for easy access to packet information\r
-#define GPUCOMMAND(x) ((x>>24) & 0xff)\r
-\r
-GLfloat         gl_z=0.0f;\r
-BOOL            bNeedInterlaceUpdate=FALSE;\r
-BOOL            bNeedRGB24Update=FALSE;\r
-BOOL            bChangeWinMode=FALSE;\r
-\r
-uint32_t        ulStatusControl[256];\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-// global GPU vars\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-static int      GPUdataRet;\r
-int             lGPUstatusRet;\r
-char            szDispBuf[64];\r
-\r
-uint32_t        dwGPUVersion = 0;\r
-int             iGPUHeight = 512;\r
-int             iGPUHeightMask = 511;\r
-int             GlobalTextIL = 0;\r
-int             iTileCheat = 0;\r
-\r
-static uint32_t      gpuDataM[256];\r
-static unsigned char gpuCommand = 0;\r
-static int           gpuDataC = 0;\r
-static int           gpuDataP = 0;\r
-\r
-VRAMLoad_t      VRAMWrite;\r
-VRAMLoad_t      VRAMRead;\r
-int             iDataWriteMode;\r
-int             iDataReadMode;\r
-\r
-int             lClearOnSwap;\r
-int             lClearOnSwapColor;\r
-BOOL            bSkipNextFrame = FALSE;\r
-int             iColDepth;\r
-BOOL            bChangeRes;\r
-BOOL            bWindowMode;\r
-int             iWinSize;\r
-\r
-// possible psx display widths\r
-short dispWidths[8] = {256,320,512,640,368,384,512,640};\r
-\r
-PSXDisplay_t    PSXDisplay;\r
-PSXDisplay_t    PreviousPSXDisplay;\r
-TWin_t          TWin;\r
-short           imageX0,imageX1;\r
-short           imageY0,imageY1;\r
-BOOL            bDisplayNotSet = TRUE;\r
-GLuint          uiScanLine=0;\r
-int             iUseScanLines=0;\r
-int             lSelectedSlot=0;\r
-unsigned char * pGfxCardScreen=0;\r
-int             iBlurBuffer=0;\r
-int             iScanBlend=0;\r
-int             iRenderFVR=0;\r
-int             iNoScreenSaver=0;\r
-uint32_t        ulGPUInfoVals[16];\r
-int             iFakePrimBusy = 0;\r
-int             iRumbleVal    = 0;\r
-int             iRumbleTime   = 0;\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-// stuff to make this a true PDK module\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-char * CALLBACK PSEgetLibName(void)\r
-{\r
- return _(libraryName);\r
-}\r
-\r
-unsigned long CALLBACK PSEgetLibType(void)\r
-{\r
- return  PSE_LT_GPU;\r
-}\r
-\r
-unsigned long CALLBACK PSEgetLibVersion(void)\r
-{\r
- return version<<16|revision<<8|build;\r
-}\r
-\r
-char * GPUgetLibInfos(void)\r
-{\r
- return _(libraryInfo);\r
-}\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-// snapshot funcs (saves screen to bitmap / text infos into file)\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-char * GetConfigInfos(int hW)\r
-{\r
- char szO[2][4]={"off","on "};\r
- char szTxt[256];\r
- char * pB=(char *)malloc(32767);\r
-\r
- if(!pB) return NULL;\r
- *pB=0;\r
- //----------------------------------------------------//\r
- sprintf(szTxt,"Plugin: %s %d.%d.%d\r\n",libraryName,version,revision,build);\r
- strcat(pB,szTxt);\r
- sprintf(szTxt,"Author: %s\r\n",PluginAuthor);\r
- strcat(pB,szTxt);\r
-\r
- sprintf(szTxt,"Card vendor: %s\r\n",(char *)glGetString(GL_VENDOR));\r
- strcat(pB,szTxt);\r
- sprintf(szTxt,"GFX card: %s\r\n",(char *)glGetString(GL_RENDERER));\r
- strcat(pB,szTxt);\r
- sprintf(szTxt,"OGL version: %s\r\n\r\n",(char *)glGetString(GL_VERSION));\r
- strcat(pB,szTxt);\r
- //strcat(pB,(char *)glGetString(GL_EXTENSIONS));\r
- //strcat(pB,"\r\n\r\n");\r
-\r
- if(hW && bWindowMode)\r
-  sprintf(szTxt,"Resolution/Color:\r\n- %dx%d ",LOWORD(iWinSize),HIWORD(iWinSize));\r
- else\r
-  sprintf(szTxt,"Resolution/Color:\r\n- %dx%d ",iResX,iResY);\r
- strcat(pB,szTxt);\r
- if(bWindowMode) sprintf(szTxt,"Window mode\r\n");\r
- else\r
-  {\r
-   sprintf(szTxt,"Fullscreen ");\r
-   strcat(pB,szTxt);\r
-   if(bChangeRes) sprintf(szTxt,"- Desktop changing [%d Bit]\r\n",iColDepth);\r
-   else           sprintf(szTxt,"- NO desktop changing\r\n");\r
-  }                                                                                   \r
- strcat(pB,szTxt);\r
-\r
- if(iForceVSync>=0) sprintf(szTxt,"- V-Sync: %s\r\n",szO[iForceVSync]);\r
- else               strcpy(szTxt,"- V-Sync: Driver\r\n");\r
- strcat(pB,szTxt); \r
- sprintf(szTxt,"- Keep psx aspect ratio: %s\r\n\r\n",szO[bKeepRatio]);\r
- strcat(pB,szTxt);\r
- //----------------------------------------------------//\r
- strcpy(szTxt,"Textures:\r\n- ");\r
- if(iTexQuality==0)      strcat(szTxt,"Default");\r
- else if(iTexQuality==1) strcat(szTxt,"R4G4B4A4");\r
- else if(iTexQuality==2) strcat(szTxt,"R5G5B5A1");\r
- else if(iTexQuality==3) strcat(szTxt,"R8G8A8A8");\r
- else if(iTexQuality==4) strcat(szTxt,"B8G8R8A8");\r
- if(!hW && bGLExt) strcat(szTxt," (packed pixels)\r\n");\r
- else              strcat(szTxt,"\r\n");\r
- strcat(pB,szTxt);\r
- if(!hW)\r
-  {\r
-   sprintf(szTxt,"- Filtering: %d - edge clamping ",iFilterType);\r
-   if(iClampType==GL_TO_EDGE_CLAMP) strcat(szTxt,"supported\r\n");\r
-   else                             strcat(szTxt,"NOT supported\r\n");\r
-  }\r
- else sprintf(szTxt,"- iFiltering: %d\r\n",iFilterType);\r
- strcat(pB,szTxt);\r
- sprintf(szTxt,"- Hi-Res textures: %d\r\n",iHiResTextures);\r
- strcat(pB,szTxt); \r
- if(!hW)\r
-  {\r
-   sprintf(szTxt,"- Palettized tex windows: %s\r\n",szO[iUsePalTextures]);\r
-   strcat(pB,szTxt); \r
-  }\r
- sprintf(szTxt,"- VRam size: %d MBytes",iVRamSize);\r
- if(!hW)\r
-      sprintf(szTxt+strlen(szTxt)," - %d textures usable\r\n\r\n",iSortTexCnt);\r
- else strcat(szTxt,"\r\n\r\n");\r
- strcat(pB,szTxt);\r
- //----------------------------------------------------//\r
- sprintf(szTxt,"Framerate:\r\n- FPS limitation: %s\r\n",szO[bUseFrameLimit]);\r
- strcat(pB,szTxt);\r
- sprintf(szTxt,"- Frame skipping: %s\r\n",szO[bUseFrameSkip]);\r
- strcat(pB,szTxt);\r
- if(iFrameLimit==2)\r
-      strcpy(szTxt,"- FPS limit: Auto\r\n\r\n");\r
- else sprintf(szTxt,"- FPS limit: %.1f\r\n\r\n",fFrameRate);\r
- strcat(pB,szTxt);\r
- //----------------------------------------------------//\r
- sprintf(szTxt,"Compatibility:\r\n- Offscreen drawing: %d\r\n",iOffscreenDrawing);\r
- strcat(pB,szTxt);\r
- sprintf(szTxt,"- Framebuffer texture: %d",iFrameTexType);\r
- if(!hW && iFrameTexType==2)\r
-  {\r
-   if(gTexFrameName) strcat(szTxt," - texture created\r\n");\r
-   else              strcat(szTxt," - not used yet\r\n");\r
-  }\r
- else strcat(szTxt,"\r\n");\r
- strcat(pB,szTxt);\r
- sprintf(szTxt,"- Framebuffer access: %d\r\n",iFrameReadType);\r
- strcat(pB,szTxt);\r
- sprintf(szTxt,"- Alpha multipass: %s\r\n",szO[bOpaquePass]);\r
- strcat(pB,szTxt);\r
- sprintf(szTxt,"- Mask bit: %s\r\n",szO[iUseMask]);\r
- strcat(pB,szTxt);\r
- sprintf(szTxt,"- Advanced blending: %s",szO[bAdvancedBlend]);\r
- if(!hW && bAdvancedBlend)\r
-  {\r
-   if(bGLBlend) strcat(szTxt," (hardware)\r\n");\r
-   else         strcat(szTxt," (software)\r\n");\r
-  }\r
- else strcat(szTxt,"\r\n");\r
- strcat(pB,szTxt);\r
-\r
- if(!hW)\r
-  {\r
-   strcpy(szTxt,"- Subtractive blending: ");\r
-   if(glBlendEquationEXTEx)\r
-    {\r
-     if(bUseMultiPass) strcat(szTxt,"supported, but not used!");\r
-     else              strcat(szTxt,"activated");\r
-    }\r
-   else strcat(szTxt," NOT supported!");\r
-   strcat(szTxt,"\r\n\r\n");\r
-  }\r
- else strcpy(szTxt,"\r\n");\r
\r
- strcat(pB,szTxt);             \r
- //----------------------------------------------------//\r
- sprintf(szTxt,"Misc:\r\n- Scanlines: %s",szO[iUseScanLines]);\r
- strcat(pB,szTxt);\r
- if(iUseScanLines) sprintf(szTxt," [%d]\r\n",iScanBlend);\r
- else strcpy(szTxt,"\r\n");\r
- strcat(pB,szTxt);\r
- sprintf(szTxt,"- Line mode: %s\r\n",szO[bUseLines]);\r
- strcat(pB,szTxt);\r
-// sprintf(szTxt,"- Line AA: %s\r\n",szO[bUseAntiAlias]);\r
-// fwrite(szTxt,lstrlen(szTxt),1,txtfile);\r
- sprintf(szTxt,"- Unfiltered FB: %s\r\n",szO[bUseFastMdec]);\r
- strcat(pB,szTxt);\r
- sprintf(szTxt,"- 15 bit FB: %s\r\n",szO[bUse15bitMdec]);\r
- strcat(pB,szTxt);\r
- sprintf(szTxt,"- Dithering: %s\r\n",szO[bDrawDither]);\r
- strcat(pB,szTxt);\r
- sprintf(szTxt,"- Screen smoothing: %s",szO[iBlurBuffer]);\r
- strcat(pB,szTxt);\r
- if(!hW && iBlurBuffer) \r
-  {\r
-   if(gTexBlurName) strcat(pB," - supported\r\n");\r
-   else             strcat(pB," - not supported\r\n");\r
-  }\r
- else strcat(pB,"\r\n");\r
- sprintf(szTxt,"- Game fixes: %s [%08x]\r\n",szO[bUseFixes],dwCfgFixes);\r
- strcat(pB,szTxt);\r
- //----------------------------------------------------//\r
- return pB;\r
-}\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-// save text infos to file\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-void DoTextSnapShot(int iNum)\r
-{\r
- FILE *txtfile;char szTxt[256];char * pB;\r
-\r
- sprintf(szTxt,"%s/pcsx%04d.txt",getenv("HOME"),iNum);\r
-\r
- if((txtfile=fopen(szTxt,"wb"))==NULL)\r
-  return;                                              \r
-\r
- pB=GetConfigInfos(0);\r
- if(pB)\r
-  {\r
-   fwrite(pB,strlen(pB),1,txtfile);\r
-   free(pB);\r
-  }\r
- fclose(txtfile); \r
-}\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-// saves screen bitmap to file\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-void DoSnapShot(void)\r
-{\r
- unsigned char * snapshotdumpmem=NULL,* p,c;\r
- FILE *bmpfile;char filename[256];\r
- unsigned char header[0x36];int size;\r
- unsigned char empty[2]={0,0};int i;\r
- unsigned int snapshotnr = 0;\r
- short SnapWidth;\r
- short SnapHeigth;\r
-\r
- bSnapShot=FALSE;\r
-\r
- SnapWidth  = iResX;\r
- SnapHeigth = iResY;\r
-\r
- size=SnapWidth * SnapHeigth * 3 + 0x38;\r
-\r
- if((snapshotdumpmem=(unsigned char *)\r
-   malloc(SnapWidth*SnapHeigth*3))==NULL)\r
-  return;\r
-    \r
-  // fill in proper values for BMP\r
- for(i=0;i<0x36;i++) header[i]=0;\r
- header[0]='B';\r
- header[1]='M';\r
- header[2]=(unsigned char)(size&0xff);\r
- header[3]=(unsigned char)((size>>8)&0xff);\r
- header[4]=(unsigned char)((size>>16)&0xff);\r
- header[5]=(unsigned char)((size>>24)&0xff);\r
- header[0x0a]=0x36;\r
- header[0x0e]=0x28;\r
- header[0x12]=(unsigned char)(SnapWidth%256);\r
- header[0x13]=(unsigned char)(SnapWidth/256);\r
- header[0x16]=(unsigned char)(SnapHeigth%256);\r
- header[0x17]=(unsigned char)(SnapHeigth/256);\r
- header[0x1a]=0x01;\r
- header[0x1c]=0x18;\r
- header[0x26]=0x12;\r
- header[0x27]=0x0B;\r
- header[0x2A]=0x12;\r
- header[0x2B]=0x0B;\r
-\r
- // increment snapshot value\r
- // get filename\r
- do\r
-  {\r
-   snapshotnr++;\r
-   sprintf(filename,"%s/pcsx%04d.bmp",getenv("HOME"),snapshotnr);\r
-   bmpfile=fopen(filename,"rb");\r
-   if(bmpfile==NULL)break;\r
-   fclose(bmpfile);\r
-   if(snapshotnr==9999) break;\r
-  }\r
- while(TRUE);\r
-\r
- // try opening new snapshot file\r
- if((bmpfile=fopen(filename,"wb"))==NULL)\r
-  {free(snapshotdumpmem);return;}\r
-\r
- fwrite(header,0x36,1,bmpfile);\r
-\r
- glReadPixels(0,0,SnapWidth,SnapHeigth,GL_RGB,\r
-               GL_UNSIGNED_BYTE,snapshotdumpmem);\r
- p=snapshotdumpmem;\r
- size=SnapWidth * SnapHeigth;\r
-\r
- for(i=0;i<size;i++,p+=3)\r
-  {c=*p;*p=*(p+2);*(p+2)=c;}\r
-\r
- fwrite(snapshotdumpmem,size*3,1,bmpfile);\r
- fwrite(empty,0x2,1,bmpfile);\r
- fclose(bmpfile); \r
- free(snapshotdumpmem);\r
-\r
- DoTextSnapShot(snapshotnr);\r
-}       \r
-\r
-void CALLBACK GPUmakeSnapshot(void)\r
-{\r
- bSnapShot = TRUE;\r
-}        \r
-\r
-////////////////////////////////////////////////////////////////////////\r
-// GPU INIT... here starts it all (first func called by emu)\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-long CALLBACK GPUinit()\r
-{\r
- memset(ulStatusControl,0,256*sizeof(uint32_t));\r
-\r
- // different ways of accessing PSX VRAM\r
-\r
- psxVSecure=(unsigned char *)malloc((iGPUHeight*2)*1024 + (1024*1024)); // always alloc one extra MB for soft drawing funcs security\r
- if(!psxVSecure) return -1;\r
-\r
- psxVub=psxVSecure+512*1024;                           // security offset into double sized psx vram!\r
- psxVsb=(signed char *)psxVub;\r
- psxVsw=(signed short *)psxVub;\r
- psxVsl=(signed int *)psxVub;\r
- psxVuw=(unsigned short *)psxVub;\r
- psxVul=(uint32_t *)psxVub;\r
-\r
- psxVuw_eom=psxVuw+1024*iGPUHeight;                    // pre-calc of end of vram\r
-\r
- memset(psxVSecure,0x00,(iGPUHeight*2)*1024 + (1024*1024));\r
- memset(ulGPUInfoVals,0x00,16*sizeof(uint32_t));\r
-\r
- InitFrameCap();                                       // init frame rate stuff\r
-\r
- PSXDisplay.RGB24        = 0;                          // init vars\r
- PreviousPSXDisplay.RGB24= 0;\r
- PSXDisplay.Interlaced   = 0;\r
- PSXDisplay.InterlacedTest=0;\r
- PSXDisplay.DrawOffset.x = 0;\r
- PSXDisplay.DrawOffset.y = 0;\r
- PSXDisplay.DrawArea.x0  = 0;\r
- PSXDisplay.DrawArea.y0  = 0;\r
- PSXDisplay.DrawArea.x1  = 320;\r
- PSXDisplay.DrawArea.y1  = 240;\r
- PSXDisplay.DisplayMode.x= 320;\r
- PSXDisplay.DisplayMode.y= 240;\r
- PSXDisplay.Disabled     = FALSE;\r
- PreviousPSXDisplay.Range.x0 =0;\r
- PreviousPSXDisplay.Range.x1 =0;\r
- PreviousPSXDisplay.Range.y0 =0;\r
- PreviousPSXDisplay.Range.y1 =0;\r
- PSXDisplay.Range.x0=0;\r
- PSXDisplay.Range.x1=0;\r
- PSXDisplay.Range.y0=0;\r
- PSXDisplay.Range.y1=0;\r
- PreviousPSXDisplay.DisplayPosition.x = 1;\r
- PreviousPSXDisplay.DisplayPosition.y = 1;\r
- PSXDisplay.DisplayPosition.x = 1;\r
- PSXDisplay.DisplayPosition.y = 1;\r
- PreviousPSXDisplay.DisplayModeNew.y=0;\r
- PSXDisplay.Double=1;\r
- GPUdataRet=0x400;\r
-\r
- PSXDisplay.DisplayModeNew.x=0;\r
- PSXDisplay.DisplayModeNew.y=0;\r
-\r
- //PreviousPSXDisplay.Height = PSXDisplay.Height = 239;\r
\r
- iDataWriteMode = DR_NORMAL;\r
-\r
- // Reset transfer values, to prevent mis-transfer of data\r
- memset(&VRAMWrite,0,sizeof(VRAMLoad_t));\r
- memset(&VRAMRead,0,sizeof(VRAMLoad_t));\r
\r
- // device initialised already !\r
- //lGPUstatusRet = 0x74000000;\r
-\r
- STATUSREG = 0x14802000;\r
- GPUIsIdle;\r
- GPUIsReadyForCommands;\r
-\r
- return 0;\r
-}                             \r
-\r
-////////////////////////////////////////////////////////////////////////\r
-// GPU OPEN: funcs to open up the gpu display (Windows)\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-// LINUX GPU OPEN: func to open up the gpu display (X stuff)\r
-// please note: in linux we are creating our own display, and we return\r
-// the display ID to the main emu... that's cleaner\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-char * pCaptionText=0;\r
-int    bFullScreen=0;\r
-Display              *display;\r
-\r
-static Cursor        cursor;\r
-static XVisualInfo   *myvisual;\r
-static Colormap      colormap;\r
-static Window        window;\r
-\r
-static int bModeChanged=0;\r
-\r
-typedef struct\r
-{\r
-#define MWM_HINTS_DECORATIONS   2\r
-  long flags;\r
-  long functions;\r
-  long decorations;\r
-  long input_mode;\r
-} MotifWmHints;\r
-\r
-static int dbdepat[]={GLX_RGBA,GLX_DOUBLEBUFFER,GLX_DEPTH_SIZE,16,None};\r
-static int dbnodepat[]={GLX_RGBA,GLX_DOUBLEBUFFER,None};\r
-static GLXContext cx;\r
-\r
-static int fx=0;\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-void osd_close_display (void)                          // close display\r
-{\r
- if(display)                                           // display exists?\r
-  {\r
-   glXDestroyContext(display,cx);                      // -> kill context\r
-   XFreeColormap(display, colormap);                   // -> kill colormap\r
-   XSync(display,False);                               // -> sync events\r
-\r
-#ifndef NOVMODE\r
-   if(bModeChanged)                                    // -> repair screen mode\r
-    {\r
-     int myscreen=DefaultScreen(display);\r
-     XF86VidModeSwitchToMode(display,myscreen,         // --> switch mode back\r
-                             modes[iOldMode]);\r
-     XF86VidModeSetViewPort(display,myscreen,0,0);     // --> set viewport&nb