Too many to list here.

This commit is contained in:
dkeruza-neo
2025-01-23 17:04:41 +01:00
parent ae61839826
commit 1068fd5a1e
24 changed files with 15686 additions and 263 deletions
+13 -2
View File
@@ -1,6 +1,6 @@
CC = gcc -m32 -pthread
CFLAGS = -g -fPIC -m32 -Wall -Werror -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-function -D_GNU_SOURCE -Wno-char-subscripts
LD = gcc -m32
CFLAGS = -g -fPIC -m32 -Wall -Werror -Wno-misleading-indentation -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-function -D_GNU_SOURCE -Wno-char-subscripts
LD = g++ -m32
LDFLAGS = -Wl,-z,defs -rdynamic -static-libgcc -lc -ldl -lGL -lglut -lX11 -lSDL2 -lm -lpthread -shared -nostdlib -lasound -L./src/libxdiff -lxdiff
BUILD = build
@@ -46,6 +46,17 @@ libposixtime.so:
# Clean rule
clean:
rm -f $(BUILD)/lindbergh.so
rm -f $(BUILD)/libsegaapi.so
rm -f $(BUILD)/lindbergh
rm -f src/lindbergh/*.o
rm -f src/libsegaapi/*.o
#clean all rule
cleanall:
rm -rf $(BUILD)
rm -f src/lindbergh/*.o
rm -f src/libsegaapi/*.o
rm -f src/libkswapapi/*.o
rm -f src/libxdiff/*.a
rm -f src/libxdiff/xdiff/*.o
+35 -4
View File
@@ -41,15 +41,23 @@ EMULATE_DRIVEBOARD AUTO
# Set if the emulator should emulate the motion board from Outrun 2 SP SDX here
# If this is set to 0, then the emulator will route the traffic to one of the serial ports
EMULATE_MOTIONBOARD AUTO
# Set if the loader should emulate the card reader in Virtua Tenis 3
# EMULATE_CARDREADER 1
# Card File for reader 1
# CARDFILE_01 Card_01.crd
# Card File for reader 2
# CARDFILE_02 Card_02.crd
# Define the path to pass the JVS packets to if JVS is not being emulated.
JVS_PATH /dev/ttyUSB0
# Define the path to pass the first serial port to if it's not being emulated.
SERIAL_1_PATH /dev/ttyUSB0
# SERIAL_1_PATH /dev/ttyUSB0
# Define the path to pass the second serial port to if it's not being emulated.
SERIAL_2_PATH /dev/ttyUSB0
# SERIAL_2_PATH /dev/ttyUSB0
# Define the path to the sram.bin file
SRAM_PATH sram.bin
@@ -95,16 +103,39 @@ FPS_TARGET 60
LGJ_RENDER_WITH_MESA 1
# Set the Primeval Hunt mode
# Mode 0: Leaves everything as default
# Mode 1: No touch screen (Default mode)
# Mode 0: Default (Side by Side)
# Mode 1: No touch screen
# Mode 2: Side by Side
# Mode 3: 3ds mode 1 (Touch screen to the right)
# Mode 4: 3ds mode 2 (Touch screen to the bottom)
PRIMEVAL_HUNT_MODE 1
# Disble to use the original fonts instead of the built in font in the loader
DISABLE_BUILTIN_FONT 0
# Disble to use the original logos instead of the built in logos in the loader
DISABLE_BUILTIN_LOGOS 0
# Set to 0 to enable the mouse pointer/Cursor
HIDE_CURSOR 1
# Set the custom mouse pointer from a PNG file (Usefull for shooting games)
# CUSTOM_CURSOR myCustomCursor.png
# Set the width of the custom cursor
CUSTOM_CURSOR_WIDTH 32
# Set the height of the custom cursor
CUSTOM_CURSOR_HEIGHT 32
# Hacky way to make MJ4 work at prohibited times?
# MJ4_ENABLED_ALL_THE_TIME 1
# Sets the IP address in the eeprom for Outrun link (you have to put your NIC ip)
# OR2_IP 192.168.1.2
# House of the dead 4 speed fix set the frequency of your CPU in Mhz (The speed reported by the manufacturer)
# CPU_FREQ_MHZ 4.0
# Set the colour of the lindbergh to change the Segaboot logo
# Possible colours are: YELLOW, RED, BLUE, SILVER, REDEX
LINDBERGH_COLOUR YELLOW
+236
View File
@@ -0,0 +1,236 @@
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include "config.h"
#include "card_reader.h"
#define BLOCKSIZE 8
uint8_t cardHeader[] = {0x08, 0x00, 0x00, 0x00, 0x81, 0x00, 0x59, 0xda, 0x00, 0x00, 0x54, 0x4d, 0x50, 0x06, 0x03, 0x23, 0x10, 0x41, 0x62,
0xad, 0x00, 0x2b, 0x0b, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x95, 0x71, 0x52, 0x70, 0x00, 0x00,
0x00, 0x00, 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfd, 0xd2};
SerialFD serialFD[2];
WriteCommand writeCmd[2];
ReadCommand readCmd[2];
void initReadCmd(int fdIdx)
{
readCmd[fdIdx].cmd = 0;
readCmd[fdIdx].cmdCompleted = false;
readCmd[fdIdx].cmdLen = 0;
readCmd[fdIdx].sentBytes = 0;
memset(&readCmd[fdIdx].sendBuffer, '\0', 256);
}
void initWriteCmd(int fdIdx)
{
writeCmd[fdIdx].cmdCompleted = false;
writeCmd[fdIdx].packetLen = 0;
writeCmd[fdIdx].recBytes = 0;
memset(&writeCmd[fdIdx].recBuffer, '\0', sizeof(uint8_t));
}
int initCardReader()
{
initReadCmd(0);
initReadCmd(1);
initWriteCmd(0);
initWriteCmd(1);
uint32_t gId = getConfig()->crc32;
if (gId != VIRTUA_TENNIS_3 && gId != VIRTUA_TENNIS_3_TEST && gId != VIRTUA_TENNIS_3_REVA && gId != VIRTUA_TENNIS_3_REVA_TEST &&
gId != VIRTUA_TENNIS_3_REVB && gId != VIRTUA_TENNIS_3_REVB_TEST && gId != VIRTUA_TENNIS_3_REVC &&
gId != VIRTUA_TENNIS_3_REVC_TEST && gId != R_TUNED)
{
printf("Game does not support Card Reader, please disable the card reader emulation in the config file.\n");
return -1;
}
if (getConfig()->emulateCardreader && getConfig()->emulateDriveboard && gId != R_TUNED)
{
printf("Game does not support Card Reader and Driver Board emulation enabled at the same time.\n");
printf("Please disable Drive Board emulations in the config file.\n");
return -1;
}
return 0;
}
int carReaderGetFdIdx(int fd)
{
if (fd == serialFD[0].fd)
return 0;
return 1;
}
uint8_t cardReaderGenChecksum(int fdIdx)
{
int checksum = 0;
for (int i = 0; i < readCmd[fdIdx].cmdLen - 1; i++)
{
checksum ^= readCmd[fdIdx].sendBuffer[i];
}
return checksum;
}
void buildOutputBuffer(int fdIdx, uint8_t cmd)
{
uint16_t packetLen = 0;
readCmd[fdIdx].sendBuffer[0] = 0x10;
readCmd[fdIdx].sendBuffer[1] = cmd;
switch (cmd)
{
case 0x10:
{
readCmd[fdIdx].sendBuffer[5] = 0x20;
}
case 0x11:
{
if (writeCmd[fdIdx].recBuffer[5] == 0x04)
{
initWriteCmd(fdIdx);
return;
}
}
case 0x14:
case 0x15:
case 0x20:
{
if (cmd == 0x20 && writeCmd[fdIdx].recBuffer[5] == 0x00)
readCmd[fdIdx].sendBuffer[4] = 0x80;
}
case 0x26:
case 0x27:
{
packetLen = 0x02;
readCmd[fdIdx].sendBuffer[3] = packetLen;
}
break;
case 0x21:
{
packetLen = 0x0a;
readCmd[fdIdx].sendBuffer[3] = packetLen;
readCmd[fdIdx].sendBuffer[6] = 0x81;
readCmd[fdIdx].sendBuffer[8] = 0x59;
readCmd[fdIdx].sendBuffer[9] = 0xda;
}
break;
case 0x22:
{
packetLen = 0x0a;
readCmd[fdIdx].sendBuffer[3] = packetLen;
readCmd[fdIdx].sendBuffer[7] = 0x08;
}
break;
case 0x33:
{
packetLen = 0x0a;
readCmd[fdIdx].sendBuffer[3] = packetLen;
readCmd[fdIdx].sendBuffer[6] = 0xff;
readCmd[fdIdx].sendBuffer[7] = 0xff;
}
break;
case 0x34:
{
uint16_t blockStart = (writeCmd[fdIdx].recBuffer[6] << 8) | writeCmd[fdIdx].recBuffer[7];
uint16_t blocksToRead = (writeCmd[fdIdx].recBuffer[8] << 8) | writeCmd[fdIdx].recBuffer[9];
packetLen = (BLOCKSIZE * blocksToRead) + 2;
readCmd[fdIdx].sendBuffer[3] = packetLen;
FILE *crdFile = fopen(serialFD[fdIdx].cardFilename, "rb");
fseek(crdFile, BLOCKSIZE * blockStart, SEEK_SET);
fread(readCmd[fdIdx].sendBuffer + 6, 1, packetLen - 2, crdFile);
fclose(crdFile);
}
break;
case 0x35:
{
readCmd[fdIdx].sendBuffer[3] = 0x02;
uint16_t blockStart = (writeCmd[fdIdx].recBuffer[6] << 8) | writeCmd[fdIdx].recBuffer[7];
uint16_t blocksToWrite = (writeCmd[fdIdx].recBuffer[8] << 8) | writeCmd[fdIdx].recBuffer[9];
packetLen = BLOCKSIZE * blocksToWrite;
FILE *crdFile = fopen(serialFD[fdIdx].cardFilename, "rb+");
fseek(crdFile, BLOCKSIZE * blockStart, SEEK_SET);
fwrite(writeCmd[fdIdx].recBuffer + 10, 1, packetLen, crdFile);
fclose(crdFile);
packetLen = 0x02;
}
break;
default:
{
printf("Command not supported.\n");
}
}
readCmd[fdIdx].cmdLen = packetLen + 5;
readCmd[fdIdx].sendBuffer[readCmd[fdIdx].cmdLen - 1] = cardReaderGenChecksum(fdIdx);
}
size_t cardReaderWrite(int fd, const void *buf, size_t count)
{
int fdIdx = carReaderGetFdIdx(fd);
if (writeCmd[fdIdx].cmdCompleted)
{
printf("Something went wrong, a write command was issued after the command was completed.\n");
}
if (writeCmd[fdIdx].recBytes == 4)
{
writeCmd[fdIdx].packetLen = (writeCmd[fdIdx].recBuffer[2] << 8) | writeCmd[fdIdx].recBuffer[3];
}
writeCmd[fdIdx].recBuffer[writeCmd[fdIdx].recBytes] = *((u_int8_t *)buf);
writeCmd[fdIdx].recBytes++;
if (writeCmd[fdIdx].recBytes == writeCmd[fdIdx].packetLen + 5)
{
writeCmd[fdIdx].cmdCompleted = true;
initReadCmd(fdIdx);
buildOutputBuffer(fdIdx, writeCmd[fdIdx].recBuffer[1]);
}
return count;
}
size_t cardReaderRead(int fd, void *buf, size_t count)
{
int fdIdx = carReaderGetFdIdx(fd);
if (!writeCmd[fdIdx].cmdCompleted || readCmd[fdIdx].cmdCompleted)
return -1;
if (readCmd[fdIdx].cmdLen == readCmd[fdIdx].sentBytes)
{
readCmd[fdIdx].cmdCompleted = true;
initWriteCmd(fdIdx);
return -1;
}
memcpy(buf, &readCmd[fdIdx].sendBuffer[readCmd[fdIdx].sentBytes], sizeof(uint8_t));
readCmd[fdIdx].sentBytes++;
return 1;
}
void cardReaderSetFd(int serial, int fd, char *fName)
{
serialFD[serial].fd = fd;
serialFD[serial].cardFilename = fName;
if (access(fName, F_OK) != 0)
{
FILE *crdFile = fopen(fName, "wb+");
if (getConfig()->crc32 == R_TUNED)
{
cardHeader[0x22] = 0x02;
cardHeader[0x23] = 0x60;
}
fwrite(cardHeader, 1, 56, crdFile);
uint8_t z = 0;
fseek(crdFile, 0x7c7, SEEK_CUR);
fwrite(&z, 1, 1, crdFile);
fclose(crdFile);
printf("Cardfile %s created.\n", fName);
}
}
+36
View File
@@ -0,0 +1,36 @@
#ifndef CARD_READER_H
#define CARD_READER_H
#include <stdint.h>
#include <sys/types.h>
typedef struct
{
int fd;
char *cardFilename;
} SerialFD;
typedef struct
{
bool cmdCompleted;
uint16_t packetLen;
uint8_t recBytes;
uint8_t recBuffer[256];
} WriteCommand;
typedef struct
{
uint8_t cmd;
bool cmdCompleted;
uint8_t cmdLen;
uint8_t sentBytes;
uint8_t sendBuffer[256];
} ReadCommand;
int initCardReader();
size_t cardReaderWrite(int fd, const void *buf, size_t count);
size_t cardReaderRead(int fd, void *buf, size_t count);
void cardReaderSetFd(int serial, int fd, char *fName);
#endif
+54 -10
View File
@@ -479,12 +479,12 @@ static int detectGame(uint32_t elf_crc)
config.gameDVP = "DVP-0018-SDX";
config.gameID = "SBMN";
config.gameReleaseYear = "2006 ?";
config.gameNativeResolutions = "1280x768";
config.gameNativeResolutions = "640x480";
config.gameStatus = WORKING;
config.jvsIOType = SEGA_TYPE_1;
config.gameType = ABC;
config.width = 1280;
config.height = 768;
config.width = 640;
config.height = 480;
return 0;
}
break;
@@ -495,12 +495,12 @@ static int detectGame(uint32_t elf_crc)
config.gameDVP = "DVP-0018A-SDX";
config.gameID = "SBMN";
config.gameReleaseYear = "2006 ?";
config.gameNativeResolutions = "1280x768";
config.gameNativeResolutions = "640x480";
config.gameStatus = WORKING;
config.jvsIOType = SEGA_TYPE_1;
config.gameType = ABC;
config.width = 1280;
config.height = 768;
config.width = 640;
config.height = 480;
return 0;
}
break;
@@ -675,11 +675,11 @@ static int detectGame(uint32_t elf_crc)
config.gameDVP = "DVP-0069";
config.gameID = "SBQL";
config.gameReleaseYear = "2008";
config.gameNativeResolutions = "640x480, 1360x768";
config.gameNativeResolutions = "640x480, 1280x768";
config.gameLindberghColour = REDEX;
config.gameType = SHOOTING;
config.gameStatus = WORKING;
config.width = 1360;
config.width = 1280;
config.height = 768;
return 0;
}
@@ -1100,6 +1100,15 @@ int readConfig(FILE *configFile, EmulatorConfig *config)
config->emulateMotionboard = getNextIntOrAuto(saveptr, defaultValue);
}
else if (strcmp(command, "EMULATE_CARDREADER") == 0)
config->emulateCardreader = atoi(getNextToken(NULL, " ", &saveptr));
else if (strcmp(command, "CARDFILE_01") == 0)
strcpy(config->cardFile1, getNextToken(NULL, " ", &saveptr));
else if (strcmp(command, "CARDFILE_02") == 0)
strcpy(config->cardFile2, getNextToken(NULL, " ", &saveptr));
else if (strcmp(command, "FULLSCREEN") == 0)
config->fullscreen = atoi(getNextToken(NULL, " ", &saveptr));
@@ -1172,9 +1181,8 @@ int readConfig(FILE *configFile, EmulatorConfig *config)
else if (strcmp(command, "KEEP_ASPECT_RATIO") == 0)
config->keepAspectRatio = atoi(getNextToken(NULL, " ", &saveptr));
else if (strcmp(command, "GPU_VENDOR") == 0) {
else if (strcmp(command, "GPU_VENDOR") == 0)
config->configGPUVendor = config->GPUVendor = atoi(getNextToken(NULL, " ", &saveptr));
}
else if (strcmp(command, "OUTRUN_LENS_GLARE_ENABLED") == 0)
config->outrunLensGlareEnabled = atoi(getNextToken(NULL, " ", &saveptr));
@@ -1191,8 +1199,32 @@ int readConfig(FILE *configFile, EmulatorConfig *config)
else if (strcmp(command, "PRIMEVAL_HUNT_MODE") == 0)
config->phMode = atoi(getNextToken(NULL, " ", &saveptr));
else if (strcmp(command, "DISABLE_BUILTIN_FONT") == 0)
config->disableBuiltinFont = atoi(getNextToken(NULL, " ", &saveptr));
else if (strcmp(command, "DISABLE_BUILTIN_LOGOS") == 0)
config->disableBuiltinLogos = atoi(getNextToken(NULL, " ", &saveptr));
else if (strcmp(command, "HIDE_CURSOR") == 0)
config->hideCursor = atoi(getNextToken(NULL, " ", &saveptr));
else if (strcmp(command, "CUSTOM_CURSOR") == 0)
strcpy(config->customCursor, getNextToken(NULL, " ", &saveptr));
else if (strcmp(command, "CUSTOM_CURSOR_WIDTH") == 0)
config->customCursorWidth = atoi(getNextToken(NULL, " ", &saveptr));
else if (strcmp(command, "CUSTOM_CURSOR_HEIGHT") == 0)
config->customCursorHeight = atoi(getNextToken(NULL, " ", &saveptr));
else if (strcmp(command, "MJ4_ENABLED_ALL_THE_TIME") == 0)
config->phMode = atoi(getNextToken(NULL, " ", &saveptr));
else if (strcmp(command, "OR2_IP") == 0)
strcpy(config->or2IP, getNextToken(NULL, " ", &saveptr));
else if (strcmp(command, "CPU_FREQ_MHZ") == 0)
config->cpuFreqMhz = atof(getNextToken(NULL, " ", &saveptr));
else if (strcmp(command, "TEST_KEY") == 0)
config->keymap.test = atoi(getNextToken(NULL, " ", &saveptr));
@@ -1438,6 +1470,9 @@ int initConfig()
config.emulateRideboard = 0;
config.emulateDriveboard = 0;
config.emulateMotionboard = 0;
config.emulateCardreader = 0;
strcpy(config.cardFile1, "Card_01.crd");
strcpy(config.cardFile2, "Card_02.crd");
config.emulateJVS = 1;
config.fullscreen = 0;
config.lindberghColour = YELLOW;
@@ -1469,7 +1504,16 @@ int initConfig()
config.fpsTarget = 60;
config.noSDL = 0;
config.phMode = 1;
config.disableBuiltinFont = 0;
config.disableBuiltinLogos = 0;
config.hideCursor = 1;
strcpy(config.customCursor, "");
config.customCursorWidth = 32;
config.customCursorHeight = 32;
config.mj4EnabledAtT = 0;
strcpy(config.or2IP, "");
config.cpuFreqMhz = 0.0f;
memset(&config.arcadeInputs.analogue_deadzone_start, 0, sizeof(config.arcadeInputs.analogue_deadzone_start));
memset(&config.arcadeInputs.analogue_deadzone_middle, 0, sizeof(config.arcadeInputs.analogue_deadzone_middle));
memset(&config.arcadeInputs.analogue_deadzone_end, 0, sizeof(config.arcadeInputs.analogue_deadzone_end));
+11
View File
@@ -222,6 +222,9 @@ typedef struct
int emulateRideboard;
int emulateDriveboard;
int emulateMotionboard;
int emulateCardreader;
char cardFile1[MAX_PATH_LENGTH];
char cardFile2[MAX_PATH_LENGTH];
int emulateJVS;
int fullscreen;
char eepromPath[MAX_PATH_LENGTH];
@@ -257,7 +260,15 @@ typedef struct
int lgjRenderWithMesa;
int noSDL;
int phMode;
int disableBuiltinFont;
int disableBuiltinLogos;
int hideCursor;
char customCursor[MAX_PATH_LENGTH];
int customCursorWidth;
int customCursorHeight;
int mj4EnabledAtT;
char or2IP[16];
float cpuFreqMhz;
ArcadeInputs arcadeInputs;
int inputMode; // 0 = both, 1 = SDL/X11 only, 2 = EVDEV only
int skipOutrunCabinetCheck;
+11
View File
@@ -1,6 +1,7 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "config.h"
#include "eeprom.h"
@@ -90,6 +91,16 @@ int initEeprom()
}
}
if ((getConfig()->crc32 == OUTRUN_2_SP_SDX || getConfig()->crc32 == OUTRUN_2_SP_SDX_REVA) && strcmp(getConfig()->or2IP, "") != 0)
{
if (setIP(eeprom, getConfig()->or2IP, "255.255.255.0") != 0)
{
printf("Error setting the new IP address.");
fclose(eeprom);
return 1;
}
}
fseek(eeprom, 0, SEEK_SET);
return 0;
+17
View File
@@ -226,6 +226,23 @@ int fixCoinAssignmentsHummer(FILE *eeprom)
return 0;
}
int setIP(FILE *eeprom, char *ipAddress, char *netMask)
{
uint32_t ipHex = inet_addr(ipAddress);
uint32_t nMask = inet_addr(netMask);
uint32_t dhcp = 0;
memcpy(&eepromBuffer[eepromOffsetTable[ETH0].offset + 8], &dhcp, sizeof(uint32_t));
memcpy(&eepromBuffer[eepromOffsetTable[ETH0].offset + 12], &ipHex, sizeof(uint32_t));
memcpy(&eepromBuffer[eepromOffsetTable[ETH0].offset + 16], &nMask, sizeof(uint32_t));
addCRCtoBuffer(ETH0);
if (writeSectiontoFile(eeprom, ETH0) != 0)
{
printf("Error writing to eeprom.");
return 1;
}
return 0;
}
int eepromSettingsInit( FILE *eeprom)
{
build_crc32_table();
+3 -1
View File
@@ -1,7 +1,9 @@
#include <stdio.h>
int eepromSettingsInit(FILE *eeprom);
int getRegion();
int getFreeplay();
int setRegion(FILE *eeprom, int region);
int setFreeplay(FILE *eeprom, int freeplay);
int fixCreditSection(FILE *eeprom);
int fixCoinAssignmentsHummer(FILE *eeprom);
int fixCoinAssignmentsHummer(FILE *eeprom);
int setIP(FILE *eeprom, char *ipAddress, char *netMask);
+23 -15
View File
@@ -22,10 +22,12 @@
#include "fps_limiter.h"
#include "sdlcalls.h"
#include "border.h"
#include "resolution.h"
extern SDL_Window *SDLwindow;
extern char SDLgameTitle[];
extern fps_limit fpsLimit;
bool GLUTGame = false;
void *displayFunc = NULL;
void *reshapeFunc = NULL;
@@ -36,17 +38,16 @@ void FGAPIENTRY glutInit(int *argcp, char **argv)
{
if (*argcp > 1 && getConfig()->crc32 == SEGA_RACE_TV)
{
for (int x = 0; x < *argcp; x++)
if (isTestMode())
{
if (strcmp(argv[x], "-t") == 0)
{
EmulatorConfig *config = getConfig();
config->noSDL = 0;
printf("Forced to use SDL to make Test mode render fine.");
}
EmulatorConfig *config = getConfig();
config->noSDL = 0;
printf("Forced to use SDL to make Test mode render fine.\n");
}
}
glutInitSDL(argcp, argv);
GLUTGame = true;
initSDL(argcp, argv);
}
void FGAPIENTRY glutMainLoop(void)
@@ -296,7 +297,8 @@ void FGAPIENTRY glutKeyboardFunc(void (*callback)(unsigned char, int, int))
{
if (getConfig()->noSDL)
{
void FGAPIENTRY (*_glutKeyboardFunc)(void (*callback)(unsigned char, int, int)) = dlsym(RTLD_NEXT, "glutKeyboardFunc");
void FGAPIENTRY (*_glutKeyboardFunc)(void (*callback)(unsigned char, int, int)) =
dlsym(RTLD_NEXT, "glutKeyboardFunc");
_glutKeyboardFunc(callback);
return;
}
@@ -307,7 +309,8 @@ void FGAPIENTRY glutKeyboardUpFunc(void (*callback)(unsigned char, int, int))
{
if (getConfig()->noSDL)
{
void FGAPIENTRY (*_glutKeyboardUpFunc)(void (*callback)(unsigned char, int, int)) = dlsym(RTLD_NEXT, "glutKeyboardUpFunc");
void FGAPIENTRY (*_glutKeyboardUpFunc)(void (*callback)(unsigned char, int, int)) =
dlsym(RTLD_NEXT, "glutKeyboardUpFunc");
_glutKeyboardUpFunc(callback);
return;
}
@@ -362,7 +365,8 @@ void FGAPIENTRY glutPassiveMotionFunc(void (*callback)(int, int))
{
if (getConfig()->noSDL)
{
void FGAPIENTRY (*_glutPassiveMotionFunc)(void (*callback)(int, int)) = dlsym(RTLD_NEXT, "glutPassiveMotionFunc");
void FGAPIENTRY (*_glutPassiveMotionFunc)(void (*callback)(int, int)) =
dlsym(RTLD_NEXT, "glutPassiveMotionFunc");
_glutPassiveMotionFunc(callback);
return;
}
@@ -417,7 +421,8 @@ void FGAPIENTRY glutSolidSphere(double radius, GLint slices, GLint stacks)
{
if (getConfig()->noSDL)
{
void FGAPIENTRY (*_glutSolidSphere)(double radius, GLint slices, GLint stacks) = dlsym(RTLD_NEXT, "glutSolidSphere");
void FGAPIENTRY (*_glutSolidSphere)(double radius, GLint slices, GLint stacks) =
dlsym(RTLD_NEXT, "glutSolidSphere");
_glutSolidSphere(radius, slices, stacks);
return;
}
@@ -428,7 +433,8 @@ void FGAPIENTRY glutWireSphere(double radius, GLint slices, GLint stacks)
{
if (getConfig()->noSDL)
{
void FGAPIENTRY (*_glutWireSphere)(double radius, GLint slices, GLint stacks) = dlsym(RTLD_NEXT, "glutWireSphere");
void FGAPIENTRY (*_glutWireSphere)(double radius, GLint slices, GLint stacks) =
dlsym(RTLD_NEXT, "glutWireSphere");
_glutWireSphere(radius, slices, stacks);
return;
}
@@ -439,7 +445,8 @@ void FGAPIENTRY glutWireCone(double base, double height, GLint slices, GLint sta
{
if (getConfig()->noSDL)
{
void FGAPIENTRY (*_glutWireCone)(double base, double height, GLint slices, GLint stacks) = dlsym(RTLD_NEXT, "glutWireCone");
void FGAPIENTRY (*_glutWireCone)(double base, double height, GLint slices, GLint stacks) =
dlsym(RTLD_NEXT, "glutWireCone");
_glutWireCone(base, height, slices, stacks);
return;
}
@@ -450,7 +457,8 @@ void FGAPIENTRY glutSolidCone(double base, double height, GLint slices, GLint st
{
if (getConfig()->noSDL)
{
void FGAPIENTRY (*_glutSolidCone)(double base, double height, GLint slices, GLint stacks) = dlsym(RTLD_NEXT, "glutSolidCone");
void FGAPIENTRY (*_glutSolidCone)(double base, double height, GLint slices, GLint stacks) =
dlsym(RTLD_NEXT, "glutSolidCone");
_glutSolidCone(base, height, slices, stacks);
return;
}
-25
View File
@@ -1,29 +1,4 @@
#ifndef GLUTHOOKS_H
#define GLUTHOOKS_H
#include <GL/glx.h>
int myCreateWindow(int *param1);
void hod4glXSwapBuffers(Display *dpy, GLXDrawable drawable);
#endif
// #include <GL/freeglut.h>
// /* The bitmap font structure taken from freeglut*/
// typedef struct tagSFG_Font SFG_Font;
// struct tagSFG_Font
// {
// char *Name; /* The source font name */
// int Quantity; /* Number of chars in font */
// int Height; /* Height of the characters */
// const GLubyte **Characters; /* The characters mapping */
// float xorig, yorig; /* Relative origin of the character */
// };
// extern SFG_Font fgFontFixed8x13;
// extern SFG_Font fgFontFixed9x15;
// extern SFG_Font fgFontHelvetica10;
// extern SFG_Font fgFontHelvetica12;
// extern SFG_Font fgFontHelvetica18;
// extern SFG_Font fgFontTimesRoman10;
// extern SFG_Font fgFontTimesRoman24;
+82 -47
View File
@@ -1,3 +1,4 @@
#include <complex.h>
#define GL_GLEXT_PROTOTYPES
#ifndef __i386__
#define __i386__
@@ -33,21 +34,51 @@ extern char SDLgameTitle[];
extern fps_limit fpsLimit;
extern Window win;
void glXToSDLSwapBuffers(Display *dpy, GLXDrawable drawable)
void glXSwapBuffers(Display *dpy, GLXDrawable drawable)
{
pollEvents();
void (*_glXSwapBuffers)(Display *dpy, GLXDrawable drawable) = dlsym(RTLD_NEXT, "glXSwapBuffers");
EmulatorConfig *config = getConfig();
if (config->borderEnabled)
drawGameBorder(config->width, config->height, config->whiteBorderPercentage, config->blackBorderPercentage);
SDL_GL_SwapWindow(SDLwindow);
int gId = getConfig()->crc32;
if (getConfig()->noSDL && (gId == OUTRUN_2_SP_SDX || gId == OUTRUN_2_SP_SDX_REVA || gId == OUTRUN_2_SP_SDX_REVA_TEST ||
gId == OUTRUN_2_SP_SDX_REVA_TEST2 || gId == OUTRUN_2_SP_SDX_TEST))
{
XEvent event;
while (XPending(dpy))
{
XNextEvent(dpy, &event);
}
}
else
{
pollEvents();
}
if (getConfig()->noSDL)
{
_glXSwapBuffers(dpy, drawable);
}
else
{
SDL_GL_SwapWindow(SDLwindow);
}
if (getConfig()->fpsLimiter)
{
fpsLimit.frameStart = Clock_now();
FpsLimiter(&fpsLimit);
fpsLimit.frameEnd = Clock_now();
}
if (getConfig()->noSDL)
{
XStoreName(dpy, win, "");
return;
}
char windowTitle[512];
sprintf(windowTitle, "%s - FPS: %.2f", SDLgameTitle, calculateFps());
SDL_SetWindowTitle(SDLwindow, windowTitle);
@@ -55,7 +86,7 @@ void glXToSDLSwapBuffers(Display *dpy, GLXDrawable drawable)
int glxSDLmyCreateWindow(int *param1)
{
glutInitSDL(0, 0);
initSDL(0, 0);
char *buf = malloc(512);
memset(buf, '\0', 512);
// param1[0x17] = (intptr_t)(void *)buf; // window;
@@ -63,16 +94,37 @@ int glxSDLmyCreateWindow(int *param1)
return 1;
}
static int nVidiaAttribs[] = {GLX_RGBA,
GLX_DOUBLEBUFFER,
GLX_RED_SIZE,
8,
GLX_GREEN_SIZE,
8,
GLX_BLUE_SIZE,
8,
GLX_ALPHA_SIZE,
8,
GLX_DEPTH_SIZE,
16,
GLX_STENCIL_SIZE,
8,
None};
XVisualInfo *glXChooseVisual(Display *dpy, int screen, int *attribList)
{
XVisualInfo *(*_glXChooseVisual)(Display *dpy, int screen, int *attribList) = dlsym(RTLD_NEXT, "glXChooseVisual");
if (sdlGame)
return 0;
if (getConfig()->GPUVendor == NVIDIA_GPU)
{
return _glXChooseVisual(dpy, screen, nVidiaAttribs);
}
return _glXChooseVisual(dpy, screen, attribList);
}
void GLAPIENTRY openglDebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message,
const void *userParam)
void GLAPIENTRY openglDebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length,
const GLchar *message, const void *userParam)
{
if (id == 1099)
return;
@@ -91,35 +143,6 @@ void GLAPIENTRY openglDebugCallback(GLenum source, GLenum type, GLuint id, GLenu
}
}
void glXSwapBuffers(Display *dpy, GLXDrawable drawable)
{
void (*_glXSwapBuffers)(Display *dpy, GLXDrawable drawable) = dlsym(RTLD_NEXT, "glXSwapBuffers");
EmulatorConfig *config = getConfig();
if (config->borderEnabled)
drawGameBorder(config->width, config->height, config->whiteBorderPercentage, config->blackBorderPercentage);
int gId = config->crc32;
if (getConfig()->noSDL && (gId == OUTRUN_2_SP_SDX || gId == OUTRUN_2_SP_SDX_REVA || gId == OUTRUN_2_SP_SDX_REVA_TEST ||
gId == OUTRUN_2_SP_SDX_REVA_TEST2 || gId == OUTRUN_2_SP_SDX_TEST))
{
XEvent event;
while (XPending(dpy))
{
XNextEvent(dpy, &event);
}
}
_glXSwapBuffers(dpy, drawable);
if (config->fpsLimiter)
{
fpsLimit.frameStart = Clock_now();
FpsLimiter(&fpsLimit);
fpsLimit.frameEnd = Clock_now();
}
XStoreName(dpy, win, "");
}
GLXContext glXCreateContext(Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct)
{
GLXContext (*_glXCreateContext)(Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct) =
@@ -150,7 +173,8 @@ GLXContext glXGetCurrentContext()
GLXPbuffer glXCreatePbuffer(Display *dpy, GLXFBConfig config, const int *attrib_list)
{
GLXPbuffer (*_glXCreatePbuffer)(Display *dpy, GLXFBConfig config, const int *attrib_list) = dlsym(RTLD_NEXT, "glXCreatePbuffer");
GLXPbuffer (*_glXCreatePbuffer)(Display *dpy, GLXFBConfig config, const int *attrib_list) =
dlsym(RTLD_NEXT, "glXCreatePbuffer");
if (sdlGame)
return 0;
return _glXCreatePbuffer(dpy, config, attrib_list);
@@ -174,7 +198,8 @@ void glXDestroyPbuffer(Display *dpy, GLXPbuffer pbuf)
XVisualInfo *glXGetVisualFromFBConfig(Display *dpy, GLXFBConfig config)
{
XVisualInfo *(*_glXGetVisualFromFBConfig)(Display *dpy, GLXFBConfig config) = dlsym(RTLD_NEXT, "glXGetVisualFromFBConfig");
XVisualInfo *(*_glXGetVisualFromFBConfig)(Display *dpy, GLXFBConfig config) =
dlsym(RTLD_NEXT, "glXGetVisualFromFBConfig");
if (sdlGame)
return 0;
return _glXGetVisualFromFBConfig(dpy, config);
@@ -212,9 +237,9 @@ GLXFBConfig *glXChooseFBConfig(Display *dpy, int screen, const int *attrib_list,
if (__NV_PRIME_RENDER_OFFLOAD == NULL)
__NV_PRIME_RENDER_OFFLOAD = " ";
if ((strcmp(__GLX_VENDOR_LIBRARY_NAME, "nvidia") == 0) && (strcmp(__NV_PRIME_RENDER_OFFLOAD, "1") == 0) &&
((gId == THE_HOUSE_OF_THE_DEAD_4_REVA) || (gId == THE_HOUSE_OF_THE_DEAD_4_REVB) || (gId == THE_HOUSE_OF_THE_DEAD_4_REVC) ||
(gId == THE_HOUSE_OF_THE_DEAD_4_SPECIAL) || (gId == THE_HOUSE_OF_THE_DEAD_4_SPECIAL_REVB) || (gId == THE_HOUSE_OF_THE_DEAD_EX) ||
(gId == TOO_SPICY)))
((gId == THE_HOUSE_OF_THE_DEAD_4_REVA) || (gId == THE_HOUSE_OF_THE_DEAD_4_REVB) ||
(gId == THE_HOUSE_OF_THE_DEAD_4_REVC) || (gId == THE_HOUSE_OF_THE_DEAD_4_SPECIAL) ||
(gId == THE_HOUSE_OF_THE_DEAD_4_SPECIAL_REVB) || (gId == THE_HOUSE_OF_THE_DEAD_EX) || (gId == TOO_SPICY)))
{
for (int i = 0; attrib_list[i] != None; i += 2)
{
@@ -231,8 +256,8 @@ GLXFBConfig *glXChooseFBConfig(Display *dpy, int screen, const int *attrib_list,
GLXContext glXCreateNewContext(Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct)
{
GLXContext (*_glXCreateNewContext)(Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct) =
dlsym(RTLD_NEXT, "glXCreateNewContext");
GLXContext (*_glXCreateNewContext)(Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list,
Bool direct) = dlsym(RTLD_NEXT, "glXCreateNewContext");
GLXContext ctx = _glXCreateNewContext(dpy, config, render_type, share_list, direct);
@@ -246,12 +271,20 @@ GLXContext glXCreateNewContext(Display *dpy, GLXFBConfig config, int render_type
return ctx;
}
GLXPbuffer glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list)
GLXPbuffer glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height,
int *attrib_list)
{
if (sdlGame)
return 0;
int pbufferAttribs[] = {
GLX_PBUFFER_WIDTH, width, GLX_PBUFFER_HEIGHT, height, GLX_PRESERVED_CONTENTS, true, GLX_LARGEST_PBUFFER, true, None};
int pbufferAttribs[] = {GLX_PBUFFER_WIDTH,
width,
GLX_PBUFFER_HEIGHT,
height,
GLX_PRESERVED_CONTENTS,
true,
GLX_LARGEST_PBUFFER,
true,
None};
return glXCreatePbuffer(dpy, config, pbufferAttribs);
}
@@ -275,7 +308,8 @@ GLXFBConfigSGIX *glXChooseFBConfigSGIX(Display *dpy, int screen, int *attrib_lis
__NV_PRIME_RENDER_OFFLOAD = " ";
if ((strcmp(__GLX_VENDOR_LIBRARY_NAME, "nvidia") == 0) && (strcmp(__NV_PRIME_RENDER_OFFLOAD, "1") == 0) &&
((gId == INITIALD_4_REVA) || (gId == INITIALD_4_REVB) || (gId == INITIALD_4_REVC) || (gId == INITIALD_4_REVD) ||
(gId == INITIALD_4_REVG) || (gId == INITIALD_4_EXP_REVB) || (gId == INITIALD_4_EXP_REVC) || gId == INITIALD_4_EXP_REVD))
(gId == INITIALD_4_REVG) || (gId == INITIALD_4_EXP_REVB) || (gId == INITIALD_4_EXP_REVC) ||
gId == INITIALD_4_EXP_REVD))
{
for (int i = 0; attrib_list[i] != None; i += 2)
{
@@ -296,7 +330,8 @@ int glXGetFBConfigAttribSGIX(Display *dpy, GLXFBConfigSGIX config, int attribute
return glXGetFBConfigAttrib(dpy, config, attribute, value);
}
GLXContext glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct)
GLXContext glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list,
Bool direct)
{
if (sdlGame)
return 0;
+315 -29
View File
@@ -1,6 +1,7 @@
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#include <libgen.h>
#include <stdint.h>
#include <time.h>
#endif
@@ -47,7 +48,10 @@
#include "shader_patches.h"
#include "fps_limiter.h"
#include "evdevinput.h"
#include "card_reader.h"
#include "log.h"
#include "resources/font.h"
#include "resources/logo.h"
#define HOOK_FILE_NAME "/dev/zero"
@@ -63,12 +67,20 @@
#define FILE_RW1 3
#define FILE_RW2 4
#define FILE_HARLEY 5
#define FILE_FONT_ABC 6
#define FILE_FONT_TGA 7
#define FILE_LOGO_TGA 8
#define ROUTE 9
int hooks[5] = {-1, -1, -1, -1, -1};
FILE *fileHooks[6] = {NULL, NULL, NULL, NULL, NULL, NULL};
int fileRead[6] = {0, 0, 0, 0, 0, 0};
FILE *fileHooks[10] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
int fileRead[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
char envpath[100];
int fontABCidx = 0;
int fontTGAidx = 0;
int logoTGAidx = 0;
uint32_t elf_crc = 0;
extern int hummerExtremeShaderFileIndex;
@@ -213,6 +225,12 @@ void __attribute__((constructor)) hook_init()
exit(1);
}
if (getConfig()->emulateCardreader)
{
if (initCardReader() != 0)
exit(1);
}
if (initInput() != 0)
exit(1);
@@ -306,27 +324,39 @@ int open(const char *pathname, int flags, ...)
if (strcmp(pathname, "/dev/ttyS0") == 0 || strcmp(pathname, "/dev/tts/0") == 0)
{
if (getConfig()->emulateDriveboard == 0 && getConfig()->emulateRideboard == 0)
if (getConfig()->emulateDriveboard == 0 && getConfig()->emulateRideboard == 0 && getConfig()->emulateCardreader == 0)
return _open(getConfig()->serial1Path, flags, mode);
if (hooks[SERIAL0] != -1)
return -1;
if (hooks[SERIAL0] != -1 && getConfig()->emulateCardreader && getConfig()->crc32 != R_TUNED)
{
return hooks[SERIAL0];
}
hooks[SERIAL0] = _open(HOOK_FILE_NAME, flags, mode);
log_warn("SERIAL0 Opened %d\n", hooks[SERIAL0]);
printf("Warning: SERIAL0 Opened %d\n", hooks[SERIAL0]);
if (getConfig()->emulateCardreader == 1 && getConfig()->crc32 != R_TUNED)
cardReaderSetFd(0, hooks[SERIAL0], getConfig()->cardFile1);
return hooks[SERIAL0];
}
if (strcmp(pathname, "/dev/ttyS1") == 0 || strcmp(pathname, "/dev/tts/1") == 0)
{
if (getConfig()->emulateMotionboard == 0)
if (getConfig()->emulateDriveboard == 0 && getConfig()->emulateMotionboard == 0 && getConfig()->emulateCardreader == 0)
return _open(getConfig()->serial2Path, flags, mode);
if (hooks[SERIAL1] != -1)
return -1;
if (hooks[SERIAL1] != -1 && getConfig()->emulateCardreader && getConfig()->crc32 != R_TUNED)
{
return hooks[SERIAL1];
}
hooks[SERIAL1] = _open(HOOK_FILE_NAME, flags, mode);
log_warn("SERIAL1 opened %d\n", hooks[SERIAL1]);
if (getConfig()->emulateCardreader == 1)
cardReaderSetFd(1, hooks[SERIAL1], getConfig()->cardFile2);
return hooks[SERIAL1];
}
@@ -375,19 +405,60 @@ FILE *fopen(const char *restrict pathname, const char *restrict mode)
return _fopen("lindbergrc", mode);
}
if ((strcmp(pathname, "/usr/lib/boot/logo.tga") == 0) || (strcmp(pathname, "/usr/lib/boot/logo.tga") == 0))
if ((strcmp(pathname, "/usr/lib/boot/logo.tga") == 0))
{
return _fopen("logo.tga", mode);
if (!getConfig()->disableBuiltinLogos)
{
fileRead[FILE_LOGO_TGA] = 0;
fileHooks[FILE_LOGO_TGA] = _fopen(HOOK_FILE_NAME, mode);
return fileHooks[FILE_LOGO_TGA];
}
else
{
return _fopen("logo.tga", mode);
}
}
if (strcmp(pathname, "/usr/lib/boot/logo_red.tga") == 0)
{
if (!getConfig()->disableBuiltinLogos)
{
fileRead[FILE_LOGO_TGA] = 1;
fileHooks[FILE_LOGO_TGA] = _fopen(HOOK_FILE_NAME, mode);
return fileHooks[FILE_LOGO_TGA];
}
else
{
return _fopen("logo_red.tga", mode);
}
}
if (strcmp(pathname, "/usr/lib/boot/LucidaConsole_12.tga") == 0)
{
return _fopen("LucidaConsole_12.tga", mode);
if (!getConfig()->disableBuiltinFont)
{
fileRead[FILE_FONT_TGA] = 0;
fileHooks[FILE_FONT_TGA] = _fopen(HOOK_FILE_NAME, mode);
return fileHooks[FILE_FONT_TGA];
}
else
{
return _fopen("LucidaConsole_12.tga", mode);
}
}
if (strcmp(pathname, "/usr/lib/boot/LucidaConsole_12.abc") == 0)
{
return _fopen("LucidaConsole_12.abc", mode);
if (!getConfig()->disableBuiltinFont)
{
fileRead[FILE_FONT_ABC] = 0;
fileHooks[FILE_FONT_ABC] = _fopen(HOOK_FILE_NAME, mode);
return fileHooks[FILE_FONT_ABC];
}
else
{
return _fopen("LucidaConsole_12.abc", mode);
}
}
if (strcmp(pathname, "/proc/cpuinfo") == 0)
@@ -403,12 +474,30 @@ FILE *fopen(const char *restrict pathname, const char *restrict mode)
}
if (strcmp(pathname, "/usr/lib/boot/SEGA_KakuGothic-DB-Roman_12.tga") == 0)
{
return _fopen("SEGA_KakuGothic-DB-Roman_12.tga", mode);
if (!getConfig()->disableBuiltinFont)
{
fileRead[FILE_FONT_TGA] = 0;
fileHooks[FILE_FONT_TGA] = _fopen(HOOK_FILE_NAME, mode);
return fileHooks[FILE_FONT_TGA];
}
else
{
return _fopen("SEGA_KakuGothic-DB-Roman_12.tga", mode);
}
}
if (strcmp(pathname, "/usr/lib/boot/SEGA_KakuGothic-DB-Roman_12.abc") == 0)
{
return _fopen("SEGA_KakuGothic-DB-Roman_12.abc", mode);
if (!getConfig()->disableBuiltinFont)
{
fileRead[FILE_FONT_ABC] = 0;
fileHooks[FILE_FONT_ABC] = _fopen(HOOK_FILE_NAME, mode);
return fileHooks[FILE_FONT_ABC];
}
else
{
return _fopen("SEGA_KakuGothic-DB-Roman_12.abc", mode);
}
}
if (strcmp(pathname, "/proc/bus/pci/00/1f.0") == 0)
@@ -505,22 +594,58 @@ FILE *fopen64(const char *pathname, const char *mode)
if (strcmp(pathname, "/usr/lib/boot/logo_red.tga") == 0)
{
return _fopen64("logo_red.tga", mode);
if (!getConfig()->disableBuiltinLogos)
{
fileRead[FILE_LOGO_TGA] = 1;
fileHooks[FILE_LOGO_TGA] = _fopen64(HOOK_FILE_NAME, mode);
return fileHooks[FILE_LOGO_TGA];
}
else
{
return _fopen64("logo_red.tga", mode);
}
}
if (strcmp(pathname, "/usr/lib/boot/logo.tga") == 0)
{
return _fopen64("logo.tga", mode);
if (!getConfig()->disableBuiltinLogos)
{
fileRead[FILE_LOGO_TGA] = 0;
fileHooks[FILE_LOGO_TGA] = _fopen64(HOOK_FILE_NAME, mode);
return fileHooks[FILE_LOGO_TGA];
}
else
{
return _fopen64("logo.tga", mode);
}
}
if (strcmp(pathname, "/usr/lib/boot/SEGA_KakuGothic-DB-Roman_12.tga") == 0)
{
return _fopen64("SEGA_KakuGothic-DB-Roman_12.tga", mode);
if (!getConfig()->disableBuiltinFont)
{
fileRead[FILE_FONT_TGA] = 0;
fileHooks[FILE_FONT_TGA] = _fopen64(HOOK_FILE_NAME, mode);
return fileHooks[FILE_FONT_TGA];
}
else
{
return _fopen64("SEGA_KakuGothic-DB-Roman_12.tga", mode);
}
}
if (strcmp(pathname, "/usr/lib/boot/SEGA_KakuGothic-DB-Roman_12.abc") == 0)
{
return _fopen64("SEGA_KakuGothic-DB-Roman_12.abc", mode);
if (!getConfig()->disableBuiltinFont)
{
fileRead[FILE_FONT_ABC] = 0;
fileHooks[FILE_FONT_ABC] = _fopen64(HOOK_FILE_NAME, mode);
return fileHooks[FILE_FONT_ABC];
}
else
{
return _fopen64("SEGA_KakuGothic-DB-Roman_12.abc", mode);
}
}
if ((getConfig()->crc32 == HUMMER) || (getConfig()->crc32 == HUMMER_SDLX) ||
@@ -555,13 +680,19 @@ FILE *fopen64(const char *pathname, const char *mode)
int fclose(FILE *stream)
{
int (*_fclose)(FILE *stream) = dlsym(RTLD_NEXT, "fclose");
for (int i = 0; i < 7; i++)
for (int i = 0; i < 9; i++)
{
if (fileHooks[i] == stream)
{
int r = _fclose(stream);
fileHooks[i] = NULL;
fileRead[i] = 0;
if (stream == fileHooks[FILE_FONT_ABC])
fontABCidx = 0;
if (stream == fileHooks[FILE_FONT_TGA])
fontTGAidx = 0;
if (stream == fileHooks[FILE_LOGO_TGA])
logoTGAidx = 0;
return r;
}
}
@@ -653,6 +784,16 @@ ssize_t read(int fd, void *buf, size_t count)
return driveboardRead(fd, buf, count);
}
if (fd == hooks[SERIAL0] && getConfig()->emulateCardreader)
{
return cardReaderRead(fd, buf, count);
}
if (fd == hooks[SERIAL1] && getConfig()->emulateCardreader)
{
return cardReaderRead(fd, buf, count);
}
// If we don't hook the serial just reply with nothing
if (fd == hooks[SERIAL0] || fd == hooks[SERIAL1])
{
@@ -693,6 +834,30 @@ size_t fread(void *buf, size_t size, size_t count, FILE *stream)
return harleyFreadReplace(buf, size, count, fileHooks[FILE_HARLEY]);
}
if (stream == fileHooks[FILE_FONT_ABC])
{
memcpy(buf, fontABC + fontABCidx, size * count);
fontABCidx += (size * count);
return size * count;
}
if (stream == fileHooks[FILE_FONT_TGA])
{
memcpy(buf, fontTGA + fontTGAidx, size * count);
fontTGAidx += (size * count);
return size * count;
}
if (stream == fileHooks[FILE_LOGO_TGA])
{
if (fileRead[FILE_LOGO_TGA] == 0)
memcpy(buf, logoLL + logoTGAidx, size * count);
else
memcpy(buf, logoLLRed + logoTGAidx, size * count);
logoTGAidx += (size * count);
return size * count;
}
return _fread(buf, size, count, stream);
}
@@ -709,9 +874,50 @@ long int ftell(FILE *stream)
return ftellGetShaderSize(fileRead[FILE_RW2]);
}
if (stream == fileHooks[FILE_FONT_ABC])
{
return fontABClen;
}
return _ftell(stream);
}
int fseek(FILE *stream, long int offset, int whence)
{
int (*_fseek)(FILE *stream, long int offset, int whence) = dlsym(RTLD_NEXT, "fseek");
if (stream == fileHooks[FILE_FONT_ABC])
{
switch (whence)
{
case SEEK_CUR:
break;
case SEEK_SET:
fontABCidx = 0;
break;
case SEEK_END:
fontABCidx = fontABClen;
break;
}
return fontABCidx;
}
return _fseek(stream, offset, whence);
}
void rewind(FILE *stream)
{
void (*_rewind)(FILE *stream) = dlsym(RTLD_NEXT, "rewind");
if (stream == fileHooks[FILE_FONT_ABC])
{
fontABCidx = 0;
return;
}
_rewind(stream);
}
ssize_t write(int fd, const void *buf, size_t count)
{
int (*_write)(int fd, const void *buf, size_t count) = dlsym(RTLD_NEXT, "write");
@@ -728,9 +934,25 @@ ssize_t write(int fd, const void *buf, size_t count)
if (fd == hooks[SERIAL0] && getConfig()->emulateDriveboard)
{
// printf("Write addr: %p\n", addr);
return driveboardWrite(fd, buf, count);
}
if (fd == hooks[SERIAL1] && getConfig()->emulateDriveboard && getConfig()->crc32 != R_TUNED)
{
return driveboardWrite(fd, buf, count);
}
if (fd == hooks[SERIAL0] && getConfig()->emulateCardreader)
{
return cardReaderWrite(fd, buf, count);
}
if (fd == hooks[SERIAL1] && getConfig()->emulateCardreader)
{
return cardReaderWrite(fd, buf, count);
}
return _write(fd, buf, count);
}
@@ -738,15 +960,6 @@ int ioctl(int fd, unsigned int request, void *data)
{
int (*_ioctl)(int fd, int request, void *data) = dlsym(RTLD_NEXT, "ioctl");
// Attempt to stop access to the ethernet ports
if ((request == SIOCSIFADDR) || (request == SIOCSIFFLAGS) || (request == SIOCSIFHWADDR) ||
(request == SIOCSIFHWBROADCAST) || (request == SIOCDELRT) || (request == SIOCADDRT) ||
(request == SIOCSIFNETMASK))
{
errno = ENXIO;
return -1;
}
if (fd == hooks[EEPROM])
{
if (request == 0xC04064A0)
@@ -762,12 +975,77 @@ int ioctl(int fd, unsigned int request, void *data)
// Just accept any IOCTL on serial ports and ignore it
if (fd == hooks[SERIAL0] || fd == hooks[SERIAL1])
{
if (request == 0x541b && getConfig()->crc32 == R_TUNED && fd == hooks[SERIAL1])
{
uint8_t d = 1;
memcpy(data, &d, sizeof(uint8_t));
}
return 0;
}
return _ioctl(fd, request, data);
}
int tcgetattr(int fd, struct termios *termios_p)
{
int (*_tcgetattr)(int fd, struct termios *termios_p) = dlsym(RTLD_NEXT, "tcgetattr");
if (fd == hooks[SERIAL0] && getConfig()->emulateDriveboard == 1)
return 0;
return _tcgetattr(fd, termios_p);
}
int tcsetattr(int fd, int optional_actions, const struct termios *termios_p)
{
int (*_tcsetattr)(int fd, int optional_actions, const struct termios *termios_p) = dlsym(RTLD_NEXT, "tcsetattr");
if (fd == hooks[SERIAL0] && getConfig()->emulateDriveboard == 1)
return 0;
return _tcsetattr(fd, optional_actions, termios_p);
}
speed_t cfgetispeed(const struct termios *termios_p)
{
speed_t (*_cfgetispeed)(const struct termios *termios_p) = dlsym(RTLD_NEXT, "cfgetispeed");
if (getConfig()->emulateDriveboard == 1)
return B9600;
return _cfgetispeed(termios_p);
}
speed_t cfgetospeed(const struct termios *termios_p)
{
speed_t (*_cfgetospeed)(const struct termios *termios_p) = dlsym(RTLD_NEXT, "cfgetospeed");
if (getConfig()->emulateDriveboard == 1)
return B9600;
return _cfgetospeed(termios_p);
}
int cfsetispeed(struct termios *termios_p, speed_t speed)
{
int (*_cfsetispeed)(struct termios *termios_p, speed_t speed) = dlsym(RTLD_NEXT, "cfsetispeed");
if (getConfig()->emulateDriveboard == 1)
return 0;
return _cfsetispeed(termios_p, speed);
}
int cfsetospeed(struct termios *termios_p, speed_t speed)
{
int (*_cfsetospeed)(struct termios *termios_p, speed_t speed) = dlsym(RTLD_NEXT, "cfsetospeed");
if (getConfig()->emulateDriveboard == 1)
return 0;
return _cfsetospeed(termios_p, speed);
}
int select(int nfds, fd_set *restrict readfds, fd_set *restrict writefds, fd_set *restrict exceptfds,
struct timeval *restrict timeout)
{
@@ -784,6 +1062,11 @@ int select(int nfds, fd_set *restrict readfds, fd_set *restrict writefds, fd_set
return baseboardSelect(nfds, readfds, writefds, exceptfds, timeout);
}
if (getConfig()->emulateCardreader == 1 || getConfig()->emulateDriveboard == 1)
{
return 1;
}
return _select(nfds, readfds, writefds, exceptfds, timeout);
}
@@ -818,6 +1101,9 @@ int system(const char *command)
if (strstr(command, "losetup") != NULL)
return 0;
if (strstr(command, "check_ip.sh") != NULL)
return 0;
return _system(command);
}
+61
View File
@@ -654,6 +654,64 @@ void sdlEventABC(SDL_Event *event)
}
}
void sdlEventHarley(SDL_Event *event)
{
switch (event->type)
{
case SDL_KEYDOWN:
case SDL_KEYUP:
{
if (event->key.keysym.sym == SDLK_t)
setSwitch(SYSTEM, BUTTON_TEST, event->type == SDL_KEYDOWN);
else if (event->key.keysym.sym == SDLK_s)
setSwitch(PLAYER_1, BUTTON_SERVICE, event->type == SDL_KEYDOWN);
else if (event->key.keysym.sym == SDLK_5)
incrementCoin(PLAYER_1, event->type == SDL_KEYDOWN);
else if (event->key.keysym.sym == SDLK_1)
setSwitch(PLAYER_1, BUTTON_START, event->type == SDL_KEYDOWN);
else if (event->key.keysym.sym == SDLK_UP)
setAnalogue(ANALOGUE_1, event->type == SDL_KEYDOWN ? pow(2, jvsAnalogueInBits) - 1 : 0);
else if (event->key.keysym.sym == SDLK_DOWN)
setAnalogue(ANALOGUE_4, event->type == SDL_KEYDOWN ? pow(2, jvsAnalogueInBits) - 1 : 0);
else if (event->key.keysym.sym == SDLK_LEFT)
setAnalogue(ANALOGUE_2, event->type == SDL_KEYDOWN ? pow(2, jvsAnalogueInBits) * 0.2 : pow(2, jvsAnalogueInBits) * 0.5);
else if (event->key.keysym.sym == SDLK_RIGHT)
setAnalogue(ANALOGUE_2, event->type == SDL_KEYDOWN ? pow(2, jvsAnalogueInBits) * 0.8 : pow(2, jvsAnalogueInBits) * 0.5);
else if (event->key.keysym.sym == SDLK_q)
setSwitch(PLAYER_1, BUTTON_1, event->type == SDL_KEYDOWN);
else if (event->key.keysym.sym == SDLK_w)
setSwitch(PLAYER_1, BUTTON_2, event->type == SDL_KEYDOWN);
else if (event->key.keysym.sym == SDLK_e)
setSwitch(PLAYER_1, BUTTON_3, event->type == SDL_KEYDOWN);
else if (event->key.keysym.sym == SDLK_r)
setSwitch(PLAYER_1, BUTTON_4, event->type == SDL_KEYDOWN);
else if (event->key.keysym.sym == SDLK_z)
setSwitch(PLAYER_1, BUTTON_DOWN, event->type == SDL_KEYDOWN); // Hummer - SegaTV view change
else if (event->key.keysym.sym == SDLK_x)
setSwitch(PLAYER_1, BUTTON_UP, event->type == SDL_KEYDOWN);
else if (event->key.keysym.sym == SDLK_c)
setSwitch(PLAYER_1, BUTTON_LEFT, event->type == SDL_KEYDOWN);
else if (event->key.keysym.sym == SDLK_v)
setSwitch(PLAYER_1, BUTTON_RIGHT, event->type == SDL_KEYDOWN);
else if (event->key.keysym.sym == SDLK_a)
setSwitch(PLAYER_2, BUTTON_1, event->type == SDL_KEYDOWN); // SegaTV boost
else if (event->key.keysym.sym == SDLK_LCTRL)
setSwitch(PLAYER_2, BUTTON_DOWN, event->type == SDL_KEYDOWN); // Hummer boost
else if (event->key.keysym.sym == SDLK_SPACE)
setSwitch(PLAYER_2, BUTTON_UP, event->type == SDL_KEYDOWN);
}
break;
default:
break;
}
}
void sdlEventMahjong(SDL_Event *event)
{
switch (event->type)
@@ -766,6 +824,9 @@ void handleSdlEvents(SDL_Event *event)
case ABC:
sdlEventABC(event);
break;
case HARLEY:
sdlEventHarley(event);
break;
case MAHJONG:
sdlEventMahjong(event);
break;
+134 -11
View File
@@ -1,11 +1,13 @@
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#include <SDL2/SDL_events.h>
#endif
#include <time.h>
#define GL_GLEXT_PROTOTYPES
#include "patch.h"
#include <GL/glx.h>
#include <SDL2/SDL.h>
#include <dlfcn.h>
#include <stdarg.h>
@@ -28,6 +30,7 @@ char elfID[4];
void *amDipswContextAddr;
extern void *glVertex3fPatchRetAddrABC[4];
extern void *glVertex3fNoPatchRetAddrABC[4];
void *hod4CursorHideShowCAVEAddress;
void setVariable(size_t address, size_t value)
{
@@ -173,7 +176,7 @@ int amDongleUpdate()
int amDongleUserInfoEx(int a, int b, char *_arcadeContext)
{
int gId = getConfig()->crc32;
uint32_t gId = getConfig()->crc32;
char *gameID;
switch (gId)
{
@@ -344,6 +347,75 @@ int patchedPuts(char *s)
return ret;
}
__attribute__((naked)) void hod4CursorHideShowFixCAVE(int param1)
{
__asm__ volatile("push %%edi\n\tpush %%esi\n\tpush %%ebx\n\tsub $0x18, %%esp\n\tjmp *%0\n\t" ::"m"(hod4CursorHideShowCAVEAddress));
}
uint32_t hod4PrevValue;
bool hod4InTutorial = false;
void hod4CursorHideShow(int param1)
{
uint32_t value = *(unsigned int *)(uintptr_t)(param1 + 0x38);
if (!getConfig()->hideCursor)
{
switch (value)
{
case 0:
{
if (hod4PrevValue != 3 || hod4InTutorial)
{
SDL_ShowCursor(SDL_DISABLE);
}
hod4PrevValue = 0;
}
break;
case 3:
{
if (!hod4InTutorial)
{
SDL_ShowCursor(SDL_ENABLE);
hod4PrevValue = 3;
}
}
break;
case 4:
{
hod4InTutorial = false;
}
case 2:
case 5:
case 11:
{
SDL_ShowCursor(SDL_DISABLE);
}
}
}
hod4CursorHideShowFixCAVE(param1);
}
int hod4VsPrintf(char *str, const char *format, va_list arg)
{
int (*_vsprintf)(char *str, const char *format, va_list arg) = dlsym(RTLD_NEXT, "vsprintf");
int res = _vsprintf(str, format, arg);
if (strcmp(str, "free : tutorial\n") == 0)
{
hod4InTutorial = false;
}
if (strcmp(str, "entry : tutorial\n") == 0)
{
hod4InTutorial = true;
}
return res;
}
int initPatch()
{
EmulatorConfig *config = getConfig();
@@ -773,6 +845,19 @@ int initPatch()
// patchMemory(0x0828a92a, "9090909090"); // IzPadServerExecute
// patchMemory(0x0828a936, "9090909090"); // IzMouseServerExecute
// patchMemory(0x0828a942, "9090909090"); // IzKeybdServerExecute
if (!getConfig()->hideCursor)
{
hod4CursorHideShowCAVEAddress = (void *)0x08161c98 + 6;
detourFunction(0x08161c98, hod4CursorHideShow);
detourFunction(0x0804be14, hod4VsPrintf);
}
if (getConfig()->cpuFreqMhz != 0.0f)
{
uint32_t cpuFreq = (uint32_t)(getConfig()->cpuFreqMhz * 998000000.0);
setVariable(0x0828ea13, cpuFreq);
}
}
break;
case THE_HOUSE_OF_THE_DEAD_4_REVA_TEST:
@@ -843,10 +928,33 @@ int initPatch()
// patchMemory(0x082852b2, "9090909090"); // IzPadServerExecute
// patchMemory(0x082852be, "9090909090"); // IzMouseServerExecute
// patchMemory(0x082852ca, "9090909090"); // IzKeybdServerExecute
if (!getConfig()->hideCursor)
{
hod4CursorHideShowCAVEAddress = (void *)0x08162494 + 6;
detourFunction(0x08162494, hod4CursorHideShow);
detourFunction(0x0804be04, hod4VsPrintf);
}
if (getConfig()->cpuFreqMhz != 0.0f)
{
uint32_t cpuFreq = (uint32_t)(getConfig()->cpuFreqMhz * 998000000.0);
setVariable(0x08289353, cpuFreq);
}
}
break;
case THE_HOUSE_OF_THE_DEAD_4_REVB_TEST:
{
detourFunction(0x0806228c, amDongleInit);
detourFunction(0x0806259f, amDongleIsAvailable);
detourFunction(0x08062506, amDongleUpdate);
// // Fixes
amDipswContextAddr = (void *)0x080980e8; // Address of amDipswContext
detourFunction(0x08062034, amDipswInit);
detourFunction(0x080620c9, amDipswExit);
detourFunction(0x0806213f, amDipswGetData);
detourFunction(0x080621b7, amDipswSetLed);
// CPU patch to support AMD processors
patchMemory(0x08049f4d, "9090909090"); //__intel_new_proc_init_P
}
@@ -885,10 +993,33 @@ int initPatch()
// patchMemory(0x082852b2, "9090909090"); // IzPadServerExecute
// patchMemory(0x082852be, "9090909090"); // IzMouseServerExecute
// patchMemory(0x082852ca, "9090909090"); // IzKeybdServerExecute
if (!getConfig()->hideCursor)
{
hod4CursorHideShowCAVEAddress = (void *)0x08162494 + 6;
detourFunction(0x08162494, hod4CursorHideShow);
detourFunction(0x0804be04, hod4VsPrintf);
}
if (getConfig()->cpuFreqMhz != 0.0f)
{
uint32_t cpuFreq = (uint32_t)(getConfig()->cpuFreqMhz * 998000000.0);
setVariable(0x08289353, cpuFreq);
}
}
break;
case THE_HOUSE_OF_THE_DEAD_4_REVC_TEST:
{
detourFunction(0x0806226c, amDongleInit);
detourFunction(0x0806257f, amDongleIsAvailable);
detourFunction(0x080624e6, amDongleUpdate);
// Fixes
amDipswContextAddr = (void *)0x080980c8; // Address of amDipswContext
detourFunction(0x08062014, amDipswInit);
detourFunction(0x080620a9, amDipswExit);
detourFunction(0x0806211f, amDipswGetData);
detourFunction(0x08062197, amDipswSetLed);
// CPU patch to support AMD processors
patchMemory(0x08049f4d, "9090909090"); //__intel_new_proc_init_P
}
@@ -920,7 +1051,7 @@ int initPatch()
detourFunction(0x0806ecff, amDongleIsAvailable);
detourFunction(0x0806ec66, amDongleUpdate);
// Fixes
amDipswContextAddr = (void *)0x0a6f3f0c; // Address of amDipswContext
amDipswContextAddr = (void *)0x080b2e88; // Address of amDipswContext
detourFunction(0x0806e794, amDipswInit);
detourFunction(0x0806e829, amDipswExit);
detourFunction(0x0806e89f, amDipswGetData);
@@ -1961,7 +2092,7 @@ int initPatch()
detourFunction(0x0870efbd, amDipswGetData);
detourFunction(0x0870f034, stubRetZero); // amDipswSetLed
detourFunction(0x08230fde, stubRetOne); // isEthLinkUp
// patchMemory(0x082df87d, "e954010000"); // tickWaitDHCP
patchMemory(0x082df87d, "e954010000"); // tickWaitDHCP
patchMemory(0x082e0ec9, "eb60"); // tickInitAddress
detourFunction(0x0821b3ea, stubRetOne); // Skip Kickback initialization
setVariable(0x08580979, 0x000126e9); // Avoid Full Screen set from Game
@@ -2285,8 +2416,6 @@ int initPatch()
detourFunction(0x0831bf2f, amDipswGetData);
detourFunction(0x0831bfa7, stubRetZero);
setVariable(0x0827a7c7, 0x34891beb); // Disable Fullscreen set from the game
detourFunction(0x081164b6, stubReturn); // patch cards to skip SIGFAULT
detourFunction(0x08116366, stubRetZero); // patch cards to skip SIGFAULT
detourFunction(0x08177acc, stubRetOne); // Patch seterror
@@ -2357,8 +2486,6 @@ int initPatch()
detourFunction(0x0831bfd3, amDipswGetData);
detourFunction(0x0831c04b, stubRetZero);
setVariable(0x0827a7f7, 0x34891beb); // Disable Fullscreen set from the game
detourFunction(0x081164e6, stubReturn); // patch cards to skip SIGFAULT
detourFunction(0x08116396, stubRetZero); // patch cards to skip SIGFAULT
detourFunction(0x08177afc, stubRetOne); // Patch seterror
// Mesa
@@ -2428,8 +2555,6 @@ int initPatch()
detourFunction(0x0831c1bf, amDipswGetData);
detourFunction(0x0831c237, stubRetZero);
setVariable(0x0827a9e3, 0x34891beb); // Disable Fullscreen set from the game
detourFunction(0x081165c2, stubReturn); // patch cards to skip SIGFAULT
detourFunction(0x08116472, stubRetZero); // patch cards to skip SIGFAUL
detourFunction(0x08177bf0, stubRetOne); // Patch seterror
// Mesa
@@ -2499,8 +2624,6 @@ int initPatch()
detourFunction(0x0831c5d7, amDipswGetData);
detourFunction(0x0831c64f, stubRetZero);
setVariable(0x0827ae1b, 0x34891beb); // Disable Fullscreen set from the game
detourFunction(0x081165ee, stubReturn); // patch cards to skip SIGFAULT
detourFunction(0x0811649e, stubRetZero); // patch cards to skip SIGFAULT
detourFunction(0x08177c1c, stubRetOne); // Patch seterror
// Mesa
+261 -15
View File
@@ -146,7 +146,14 @@ void glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdou
switch (getConfig()->crc32)
{
case THE_HOUSE_OF_THE_DEAD_4_REVA:
case THE_HOUSE_OF_THE_DEAD_4_REVB:
case THE_HOUSE_OF_THE_DEAD_4_REVC:
{
right = 1280.0;
bottom = 720.0;
}
break;
case THE_HOUSE_OF_THE_DEAD_4_SPECIAL:
case THE_HOUSE_OF_THE_DEAD_4_SPECIAL_REVB:
{
@@ -264,7 +271,7 @@ void glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
case VIRTUA_FIGHTER_5_FINAL_SHOWDOWN_REVB_6000:
case VIRTUA_FIGHTER_5_R:
case VIRTUA_FIGHTER_5_R_REVD:
case VIRTUA_FIGHTER_5_R_REVG:
case VIRTUA_FIGHTER_5_R_REVG:
{
if (width == vf5FSwidth)
{
@@ -1148,6 +1155,192 @@ void hookABCGLFunctions(uint32_t glBindTextureAddr, uint32_t glVertex3fAddr1, ui
replaceCallAtAddress(glVertex3fAddr2 + 0x7b, glVertex3fABC2);
}
GLenum curTargetGE = 0;
GLuint curTextureIDGE = 0;
bool enableScaling = false;
void glBindTextureGE(GLenum target, GLuint texture)
{
curTargetGE = target;
curTextureIDGE = texture;
void *addr = __builtin_return_address(0);
if (getConfig()->crc32 == TOO_SPICY)
{
// printf("glBindTexture called: Target = %s (0x%x), Texture ID = %u\n", targetName, target, texture);
if (texture == 902 || texture == 1642)
{ // 55 title
enableScaling = true; // Enable scaling
}
else if (texture == 903 || texture == 1686)
{
enableScaling = false; // Disable scaling
}
}
void (*_glBindTexture)(GLenum, GLuint) = dlsym(RTLD_NEXT, "glBindTexture");
_glBindTexture(target, texture);
}
void glVertex3fHOD4(GLfloat x, GLfloat y, GLfloat z)
{
int (*_glVertex3f)(GLfloat x, GLfloat y, GLfloat z) = dlsym(RTLD_NEXT, "glVertex3f");
void *returnAddress = __builtin_return_address(0);
// printf("glVertex3f hooked: x=%f, y=%f, z=%f\n", x, y, z);
// float scaleX = 1920.0f / 1280.0f;
// float scaleY = 1080.0f / 768.0f;
float scaleX = getConfig()->width / 1280.0f;
float scaleY = getConfig()->height / 768.0f;
float TestX = ((((getConfig()->width - 1280.0) / 2.0) * 1.1116317809) / 1280.0) * (1.5 / scaleX);
float TestY = ((((getConfig()->height - 768.0) / 2.0) * 0.666979044) / 768.0) * (1.5 / scaleX);
// float OffsetX = 0.277907945225; // 1920x1080
// float OffsetY = 0.1354801183125;
// float OffsetX = 0.166744767135; // 0.1659539726125; //1600x900
// float OffsetY = 0.0687822139125; // 0.06731851159375
// float OffsetX = 0.0490425785691176; //1360x768
// float OffsetY = 0.0;
float OffsetX = TestX; // test
float OffsetY = TestY;
float scaleZ = fabs(z) / 1.510000;
float AdjOffsetX = OffsetX * scaleZ;
float AdjOffsetY = OffsetY * scaleZ;
if (z == -1.000000f)
{ // 3d
// printf("glVertex3f hooked: x=%f, y=%f, z=%f\n", x, y, z);
}
else if (z == -1.000010f)
{ // subtitles
}
else if (z == -1.510000f)
{ // logo 2d elemtents target
if (curTextureIDGE != 260) // target boss fight
{
x += OffsetX;
y -= OffsetY;
x *= scaleX;
y *= scaleY;
}
else
{
}
}
else if (z == -2.000000f)
{ // videos - cutscenes
}
else if (z == -3.000000f)
{ // ??
}
else if (z == -1.210000f)
{ // coins start select side
// printf(" x values: %.10f\n", x);
// printf(" y values: %.10f\n", y);
x += AdjOffsetX;
y -= AdjOffsetY;
x *= scaleX;
y *= scaleY;
}
else if (z == -1.310000f)
{ // main bd
x += AdjOffsetX;
y -= AdjOffsetY;
x *= scaleX;
y *= scaleY;
}
else if (z == -1.509800f)
{ // frame 2d elements
x += AdjOffsetX;
y -= AdjOffsetY;
x *= scaleX;
y *= scaleY;
}
else if (z == -1.4099999666f)
{ // continue
x += AdjOffsetX;
y -= AdjOffsetY;
x *= scaleX;
y *= scaleY;
}
else if (z == -1.6099998951f)
{ // score
x += AdjOffsetX;
y -= AdjOffsetY;
x *= scaleX;
y *= scaleY;
}
else if (z == -1.7100000381f)
{ // side select
x += AdjOffsetX;
y -= AdjOffsetY;
x *= scaleX;
y *= scaleY;
}
else if (z == -1.5091999769f || z == -1.5094000101f || z == -1.5095999241f)
{ // bar boss fight
x += AdjOffsetX;
y -= AdjOffsetY;
x *= scaleX;
y *= scaleY;
}
else if (z == -1.8099999428f)
{ // score BG
x += AdjOffsetX;
y -= AdjOffsetY;
x *= scaleX;
y *= scaleY;
}
else
{
if (curTextureIDGE != 26)
{ // gun effect
// printf(" z values: %.10f\n", z);
if (z > -1.8f && z < -1.0f)
{
// x += AdjOffsetX;
// y -= AdjOffsetY;
// x *= 1920.0f /1280.0f;
// y *= 1080.0f /768.0f;
}
}
}
_glVertex3f(x, y, z);
}
int initResolutionPatches()
{
switch (getConfig()->crc32)
@@ -1353,11 +1546,17 @@ int initResolutionPatches()
setVariable(0x084c9dbc, getConfig()->width);
setVariable(0x08448458, getConfig()->width);
setVariable(0x0844845c, getConfig()->height);
patchMemory(0x08448460, "8002");
patchMemory(0x08448464, "E001");
patchMemory(0x08448460, "0005");
patchMemory(0x08448464, "0003");
patchMemory(0x0817ff6d, "e80ed5ecff"); // call crtgetresolution
patchMemory(0x08448468, "8002"); // set crtgetresolution to 640x480
patchMemory(0x0844846c, "E001");
patchMemory(0x08448468, "0005"); // set crtgetresolution to 640x480
patchMemory(0x0844846c, "0003");
setVariable(0x08448338, getConfig()->width);
setVariable(0x0844833c, getConfig()->height);
detourFunction(0x0804c024, glVertex3fHOD4);
detourFunction(0x0804ca54, glBindTextureGE);
}
break;
case THE_HOUSE_OF_THE_DEAD_4_REVB:
@@ -1371,11 +1570,17 @@ int initResolutionPatches()
setVariable(0x084c3a9c, getConfig()->width);
setVariable(0x08443118, getConfig()->width);
setVariable(0x0844311c, getConfig()->height);
patchMemory(0x08443120, "8002");
patchMemory(0x08443124, "E001");
patchMemory(0x08443120, "0005");
patchMemory(0x08443124, "0003");
patchMemory(0x0818080d, "e89eccecff"); // call crtgetresolution
patchMemory(0x08443128, "8002"); // set crtgetresolution to 640x480
patchMemory(0x0844312c, "E001");
patchMemory(0x08443128, "0005"); // set crtgetresolution to 640x480
patchMemory(0x0844312c, "0003");
setVariable(0x08442ff8, getConfig()->width);
setVariable(0x08442ffc, getConfig()->height);
detourFunction(0x0804c014, glVertex3fHOD4);
detourFunction(0x0804ca84, glBindTextureGE);
}
break;
case THE_HOUSE_OF_THE_DEAD_4_REVC:
@@ -1389,11 +1594,17 @@ int initResolutionPatches()
setVariable(0x084c3a9c, getConfig()->width);
setVariable(0x08443118, getConfig()->width);
setVariable(0x0844311c, getConfig()->height);
patchMemory(0x08443120, "8002"); // gallwinres (2D)
patchMemory(0x08443124, "E001");
patchMemory(0x08443120, "0005"); // gallwinres (2D)
patchMemory(0x08443124, "0003");
patchMemory(0x0818080d, "e89eccecff"); // sideselect fix
patchMemory(0x08443128, "8002");
patchMemory(0x0844312c, "E001");
patchMemory(0x08443128, "0005");
patchMemory(0x0844312c, "0003");
setVariable(0x08442ff8, getConfig()->width);
setVariable(0x08442ffc, getConfig()->height);
detourFunction(0x0804c014, glVertex3fHOD4);
detourFunction(0x0804ca84, glBindTextureGE);
}
break;
case THE_HOUSE_OF_THE_DEAD_4_SPECIAL:
@@ -1425,6 +1636,8 @@ int initResolutionPatches()
break;
case VIRTUA_FIGHTER_5:
{
if ((getConfig()->width == 640 && getConfig()->height == 480) || (getConfig()->width == 1280 && getConfig()->height == 768))
return 0;
patchMemory(0x08054057, "b80a000000"); // Skips resolution set by the Dip Switches.
setVariable(0x0847cf58, getConfig()->width);
setVariable(0x0847cf5c, getConfig()->height);
@@ -1433,6 +1646,8 @@ int initResolutionPatches()
break;
case VIRTUA_FIGHTER_5_REVA:
{
if ((getConfig()->width == 640 && getConfig()->height == 480) || (getConfig()->width == 1280 && getConfig()->height == 768))
return 0;
patchMemory(0x8053167, "01"); // Enable Anti Alias
patchMemory(0x080541af, "b80a000000"); // Skips resolution set by the Dip Switches.
setVariable(0x08487df8, getConfig()->width);
@@ -1441,6 +1656,8 @@ int initResolutionPatches()
break;
case VIRTUA_FIGHTER_5_REVB:
{
if ((getConfig()->width == 640 && getConfig()->height == 480) || (getConfig()->width == 1280 && getConfig()->height == 768))
return 0;
patchMemory(0x08053673, "01"); // Enable Anti Alias
patchMemory(0x080546cf, "b80a000000"); // Skips resolution set by the Dip Switches.
setVariable(0x08536bb8, getConfig()->width);
@@ -1449,6 +1666,8 @@ int initResolutionPatches()
break;
case VIRTUA_FIGHTER_5_REVE: // Also the public REV C version
{
if ((getConfig()->width == 640 && getConfig()->height == 480) || (getConfig()->width == 1280 && getConfig()->height == 768))
return 0;
patchMemory(0x080546c7, "01"); // Enable Anti Alias
patchMemory(0x080557a3, "b80a000000"); // Skips resolution set by the Dip Switches.
setVariable(0x085efb18, getConfig()->width);
@@ -1457,6 +1676,8 @@ int initResolutionPatches()
break;
case VIRTUA_FIGHTER_5_EXPORT:
{
if ((getConfig()->width == 640 && getConfig()->height == 480) || (getConfig()->width == 1280 && getConfig()->height == 768))
return 0;
patchMemory(0x08052b97, "01"); // Enable Anti Alias
patchMemory(0x08053c67, "b80a000000"); // Skips resolution set by the Dip Switches.
setVariable(0x085259f8, getConfig()->width);
@@ -1465,6 +1686,8 @@ int initResolutionPatches()
break;
case VIRTUA_FIGHTER_5_FINAL_SHOWDOWN_REVA:
{
if ((getConfig()->width == 640 && getConfig()->height == 480) || (getConfig()->width == 1280 && getConfig()->height == 768))
return 0;
patchMemory(0x08054b5e, "01"); // Enable Anti Alias
patchMemory(0x08055980, "b80a000000"); // Skips resolution set by the Dip Switches.
vf5FSwidth = (getConfig()->height * 5) / 3;
@@ -1476,6 +1699,8 @@ int initResolutionPatches()
break;
case VIRTUA_FIGHTER_5_FINAL_SHOWDOWN_REVB:
{
if ((getConfig()->width == 640 && getConfig()->height == 480) || (getConfig()->width == 1280 && getConfig()->height == 768))
return 0;
patchMemory(0x080548c4, "01"); // Enable Anti Alias
patchMemory(0x080556e6, "b80a000000"); // Skips resolution set by the Dip Switches.
vf5FSwidth = (getConfig()->height * 5) / 3;
@@ -1487,6 +1712,8 @@ int initResolutionPatches()
break;
case VIRTUA_FIGHTER_5_FINAL_SHOWDOWN_REVB_6000:
{
if ((getConfig()->width == 640 && getConfig()->height == 480) || (getConfig()->width == 1280 && getConfig()->height == 768))
return 0;
patchMemory(0x08054bfe, "01"); // Enable Anti Alias
patchMemory(0x08055a20, "b80a000000"); // Skips resolution set by the Dip Switches.
vf5FSwidth = (getConfig()->height * 5) / 3;
@@ -1498,6 +1725,8 @@ int initResolutionPatches()
break;
case VIRTUA_FIGHTER_5_R:
{
if ((getConfig()->width == 640 && getConfig()->height == 480) || (getConfig()->width == 1280 && getConfig()->height == 768))
return 0;
patchMemory(0x0805421a, "01"); // Enable Anti Alias
patchMemory(0x080554b0, "b80a000000"); // Skips resolution set by the Dip Switches.
vf5FSwidth = (getConfig()->height * 5) / 3;
@@ -1509,6 +1738,8 @@ int initResolutionPatches()
break;
case VIRTUA_FIGHTER_5_R_REVD:
{
if ((getConfig()->width == 640 && getConfig()->height == 480) || (getConfig()->width == 1280 && getConfig()->height == 768))
return 0;
patchMemory(0x080543aa, "01"); // Enable Anti Alias
patchMemory(0x080555f6, "b80a000000"); // Skips resolution set by the Dip Switches.
vf5FSwidth = (getConfig()->height * 5) / 3;
@@ -1518,8 +1749,10 @@ int initResolutionPatches()
setVariable(0x08822b30, getConfig()->height);
}
break;
case VIRTUA_FIGHTER_5_R_REVG:
case VIRTUA_FIGHTER_5_R_REVG:
{
if ((getConfig()->width == 640 && getConfig()->height == 480) || (getConfig()->width == 1280 && getConfig()->height == 768))
return 0;
patchMemory(0x0805436a, "01"); // Enable Anti Alias
patchMemory(0x0805577c, "b80a000000"); // Skips resolution set by the Dip Switches.
vf5FSwidth = (getConfig()->height * 5) / 3;
@@ -2062,6 +2295,19 @@ int initResolutionPatches()
setVariable(0x080645c6, getConfig()->height);
}
break;
case SEGABOOT_2_4:
{
patchMemory(0x08059799, "9090");
patchMemory(0x080597b6, "07");
patchMemory(0x0805978e, "07");
patchMemory(0x080597a7, "07");
patchMemory(0x080597c7, "07");
patchMemory(0x08059780, "07");
patchMemory(0x08059768, "07");
setVariable(0x0809129d, getConfig()->width);
setVariable(0x08091252, getConfig()->height);
}
break;
case VIRTUA_TENNIS_3:
{
if (getConfig()->width <= 1360 && getConfig()->height <= 768)
+1
View File
@@ -11,6 +11,7 @@ size_t harleyFreadReplace(void *buf, size_t size, size_t count, FILE *stream);
void glTexCoord2fvABC1(const float *v);
void glVertex3fABC1(float x, float y, float z);
void glVertex3fABC2(float x, float y, float z);
int isTestMode();
typedef struct
{
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+154 -16
View File
@@ -1,6 +1,5 @@
#ifndef __i386__
#define __i386__
#include <SDL2/SDL_video.h>
#endif
#undef __x86_64__
#define GL_GLEXT_PROTOTYPES
@@ -8,15 +7,26 @@
#include <stdbool.h>
#include <dlfcn.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_syswm.h>
#include <X11/Xlib.h>
#include "config.h"
#include "input.h"
#include "sdlcalls.h"
#include "fps_limiter.h"
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
bool SDLGame = false;
#define STBI_ONLY_PNG
#define STBI_SUPPORT_ZLIB
#define STBI_NO_SIMD
bool SDLWindowCreated = false;
extern bool GLUTGame;
SDL_Window *SDLwindow;
SDL_GLContext SDLcontext;
Display *x11Display;
Window x11Window;
char SDLgameTitle[256] = {0};
extern fps_limit fpsLimit;
@@ -40,19 +50,117 @@ void GLAPIENTRY openglDebugCallback2(GLenum source, GLenum type, GLuint id, GLen
}
}
void glutInitSDL(int *argcp, char **argv)
SDL_Surface *createSurfaceFromStb(unsigned char *data, int width, int height, int channels)
{
Uint32 rmask, gmask, bmask, amask;
if (channels == 4)
{ // RGBA
rmask = 0x000000FF;
gmask = 0x0000FF00;
bmask = 0x00FF0000;
amask = 0xFF000000;
}
else if (channels == 3)
{ // RGB
rmask = 0x000000FF;
gmask = 0x0000FF00;
bmask = 0x00FF0000;
amask = 0;
}
else
{
fprintf(stderr, "Unsupported image format with %d channels.\n", channels);
return NULL;
}
SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(data, width, height, channels * 8, width * channels, rmask, gmask, bmask, amask);
if (!surface)
{
fprintf(stderr, "SDL_CreateRGBSurfaceFrom Error: %s\n", SDL_GetError());
}
return surface;
}
int loadNewCursor(char *cursorFileName)
{
int width, height, channels;
unsigned char *imageData = stbi_load(cursorFileName, &width, &height, &channels, 0);
if (!imageData)
{
fprintf(stderr, "Failed to load image: %s\n", cursorFileName);
SDL_Quit();
return 0;
}
SDL_Surface *originalSurface = createSurfaceFromStb(imageData, width, height, channels);
if (!originalSurface)
{
stbi_image_free(imageData);
SDL_Quit();
return 0;
}
int newWidth = getConfig()->customCursorWidth;
int newHeight = getConfig()->customCursorHeight;
SDL_Surface *resizedSurface =
SDL_CreateRGBSurface(0, newWidth, newHeight, originalSurface->format->BitsPerPixel, originalSurface->format->Rmask,
originalSurface->format->Gmask, originalSurface->format->Bmask, originalSurface->format->Amask);
if (!resizedSurface)
{
fprintf(stderr, "SDL_CreateRGBSurface Error: %s\n", SDL_GetError());
SDL_FreeSurface(originalSurface);
stbi_image_free(imageData);
SDL_Quit();
return 0;
}
SDL_Rect srcRect = {0, 0, originalSurface->w, originalSurface->h};
SDL_Rect destRect = {0, 0, newWidth, newHeight};
if (SDL_BlitScaled(originalSurface, &srcRect, resizedSurface, &destRect) != 0)
{
fprintf(stderr, "SDL_BlitScaled Error: %s\n", SDL_GetError());
SDL_FreeSurface(resizedSurface);
SDL_FreeSurface(originalSurface);
stbi_image_free(imageData);
SDL_Quit();
return 0;
}
SDL_Cursor *customCursor = SDL_CreateColorCursor(resizedSurface, newWidth / 2, newHeight / 2);
if (!customCursor)
{
fprintf(stderr, "SDL_CreateColorCursor Error: %s\n", SDL_GetError());
SDL_FreeSurface(resizedSurface);
SDL_FreeSurface(originalSurface);
stbi_image_free(imageData);
SDL_Quit();
return 0;
}
SDL_SetCursor(customCursor);
SDL_FreeSurface(resizedSurface);
SDL_FreeSurface(originalSurface);
stbi_image_free(imageData);
return 1;
}
void initSDL(int *argcp, char **argv)
{
int gId = getConfig()->crc32;
void FGAPIENTRY (*_glutInit)(int *argcp, char **argv) = dlsym(RTLD_NEXT, "glutInit");
if (getConfig()->noSDL)
if (getConfig()->noSDL && GLUTGame)
{
_glutInit(argcp, argv);
return;
}
// || gId == R_TUNED || gId == VIRTUA_FIGHTER_5_R || gId == VIRTUA_FIGHTER_5_R_REVD
if (gId == OUTRUN_2_SP_SDX_TEST || gId == OUTRUN_2_SP_SDX_REVA_TEST || gId == OUTRUN_2_SP_SDX_REVA_TEST2)
if ((gId == OUTRUN_2_SP_SDX_TEST || gId == OUTRUN_2_SP_SDX_REVA_TEST || gId == OUTRUN_2_SP_SDX_REVA_TEST2) && GLUTGame)
{
_glutInit(argcp, argv);
}
@@ -64,7 +172,7 @@ void glutInitSDL(int *argcp, char **argv)
setenv("SDL_VIDEODRIVER", "x11", 1);
}
SDLGame = true;
SDLWindowCreated = true;
if (SDL_Init(SDL_INIT_VIDEO) < 0)
{
@@ -98,19 +206,49 @@ void glutInitSDL(int *argcp, char **argv)
exit(1);
}
SDLcontext = SDL_GL_CreateContext(SDLwindow);
if (!SDLcontext)
SDL_SysWMinfo info;
SDL_VERSION(&info.version);
if (SDL_GetWindowWMInfo(SDLwindow, &info))
{
if (info.subsystem == SDL_SYSWM_X11)
{
fprintf(stderr, "OpenGL context could not be created! SDL_Error: %s\n", SDL_GetError());
x11Display = info.info.x11.display;
x11Window = info.info.x11.window;
}
else
{
fprintf(stderr, "This program is not running on X11.\n");
}
}
else
{
fprintf(stderr, "SDL_GetWindowWMInfo Error: %s\n", SDL_GetError());
}
SDLcontext = SDL_GL_CreateContext(SDLwindow);
if (!SDLcontext)
{
fprintf(stderr, "OpenGL context could not be created! SDL_Error: %s\n", SDL_GetError());
exit(1);
}
printf(" SDL RESOLUTION: %dx%d\n\n", getConfig()->width, getConfig()->height);
if (getConfig()->fullscreen)
{
SDL_SetWindowFullscreen(SDLwindow, SDL_WINDOW_FULLSCREEN);
}
if (strcmp(getConfig()->customCursor, "") != 0)
{
if (!loadNewCursor(getConfig()->customCursor))
{
fprintf(stderr, "Custom cursor could not be loaded!\n");
exit(1);
}
}
printf(" SDL RESOLUTION: %dx%d\n\n", getConfig()->width, getConfig()->height);
if (getConfig()->fullscreen)
{
SDL_SetWindowFullscreen(SDLwindow, SDL_WINDOW_FULLSCREEN);
}
if (getConfig()->hideCursor)
SDL_ShowCursor(SDL_DISABLE);
}
void sdlQuit()
+1 -1
View File
@@ -1,2 +1,2 @@
void glutInitSDL(int *argcp, char **argv);
void initSDL(int *argcp, char **argv);
void pollEvents();
+6 -6
View File
@@ -433,7 +433,7 @@ void srtvElfShaderPatcher()
*/
bool shaderFileInList(const char *pathname, int *idx)
{
int gId = getConfig()->crc32;
uint32_t gId = getConfig()->crc32;
char cwd[256];
if (gId == GHOST_SQUAD_EVOLUTION)
{
@@ -668,7 +668,7 @@ bool shaderFileInList(const char *pathname, int *idx)
*/
long int ftellGetShaderSize(int idx)
{
int gId = getConfig()->crc32;
uint32_t gId = getConfig()->crc32;
if (gId == GHOST_SQUAD_EVOLUTION)
{
if (getConfig()->GPUVendor != NVIDIA_GPU)
@@ -747,7 +747,7 @@ long int ftellGetShaderSize(int idx)
*/
size_t freadReplace(void *buf, size_t size, size_t count, int idx)
{
int gId = getConfig()->crc32;
uint32_t gId = getConfig()->crc32;
if (gId == GHOST_SQUAD_EVOLUTION)
{
if (getConfig()->GPUVendor != NVIDIA_GPU)
@@ -1148,7 +1148,7 @@ char *cgCreateProgram(uint32_t context, int program_type, const char *program, i
void gl_ShaderSourceARB(GLhandleARB shaderObj, GLsizei count, const GLcharARB **const string, const GLint *length)
{
int gId = getConfig()->crc32;
uint32_t gId = getConfig()->crc32;
if ((gId != SEGA_RACE_TV) && (gId != HUMMER) && (gId != HUMMER_SDLX) && (gId != HUMMER_EXTREME) &&
(gId != HUMMER_EXTREME_MDX))
{
@@ -1608,7 +1608,7 @@ int xdlt_load_mmfile(char const *path, mmfile_t *mf)
int pos = 0;
long size;
char *blk;
int gId = getConfig()->crc32;
uint32_t gId = getConfig()->crc32;
if (xdl_init_mmfile(mf, XDLT_STD_BLKSIZE, XDL_MMF_ATOMIC) < 0)
{
exit(1);
@@ -1673,7 +1673,7 @@ int handle_patch(void *priv, mmbuffer_t *mb, int nbuf)
*/
void cacheModedShaderFiles()
{
int gId = getConfig()->crc32;
uint32_t gId = getConfig()->crc32;
char cwd[256];
char fullPath[512];
char shaderBuffer[100000];
File diff suppressed because it is too large Load Diff
+120 -81
View File
@@ -4,7 +4,6 @@
#endif
#undef __x86_64__
#include <GL/glx.h>
#include <GL/freeglut.h>
#include <X11/Xatom.h>
#include <X11/extensions/xf86vmode.h>
#include <dlfcn.h>
@@ -19,12 +18,19 @@
#include "config.h"
#include "securityboard.h"
#include "fps_limiter.h"
#include "sdlcalls.h"
extern bool SDLGame;
extern bool SDLWindowCreated;
extern bool gettingGPUVendor;
extern bool GLUTGame;
bool creatingWindow = false;
Window win;
extern Display *x11Display;
extern Window x11Window;
/**
* Stop the house of the dead games turning keyboard repeating off.
*/
@@ -33,43 +39,56 @@ int XAutoRepeatOff(Display *display)
return 0;
}
Window XCreateWindow(Display *display, Window parent, int x, int y, unsigned int width, unsigned int height,
unsigned int border_width, int depth, unsigned int class, Visual *visual, unsigned long valueMask,
XSetWindowAttributes *attributes)
Display *XOpenDisplay(const char *display_name)
{
Display *(*_XOpenDisplay)(const char *display_name) = dlsym(RTLD_NEXT, "XOpenDisplay");
if (SDLWindowCreated || gettingGPUVendor || GLUTGame || getConfig()->noSDL)
return _XOpenDisplay(display_name);
creatingWindow = true;
initSDL(0, 0);
creatingWindow = false;
return x11Display;
}
Window XCreateWindow(Display *display, Window parent, int x, int y, unsigned int width, unsigned int height, unsigned int border_width,
int depth, unsigned int class, Visual *visual, unsigned long valueMask, XSetWindowAttributes *attributes)
{
Window (*_XCreateWindow)(Display *display, Window parent, int x, int y, unsigned int width, unsigned int height,
unsigned int border_width, int depth, unsigned int class, Visual *visual,
unsigned long valueMask, XSetWindowAttributes *attributes) =
dlsym(RTLD_NEXT, "XCreateWindow");
if (SDLGame || gettingGPUVendor)
if (gettingGPUVendor || creatingWindow || GLUTGame)
{
Window window = _XCreateWindow(display, parent, x, y, width, height, border_width, depth, class, visual,
valueMask, attributes);
return window;
}
width = getConfig()->width;
height = getConfig()->height;
// Ensure that the windows will respond with keyboard and mouse events
attributes->event_mask = attributes->event_mask | KeyPressMask | KeyReleaseMask | PointerMotionMask;
// attributes->override_redirect = False;
Window window =
_XCreateWindow(display, parent, x, y, width, height, border_width, depth, class, visual, valueMask, attributes);
printf(" X11 RESOLUTION: %dx%d\n\n", width, height);
if (getConfig()->fullscreen)
if (getConfig()->noSDL)
{
Atom wm_state = XInternAtom(display, "_NET_WM_STATE", true);
Atom wm_fullscreen = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", true);
XChangeProperty(display, window, wm_state, XA_ATOM, 32, PropModeReplace, (unsigned char *)&wm_fullscreen, 1);
width = getConfig()->width;
height = getConfig()->height;
attributes->event_mask = attributes->event_mask | KeyPressMask | KeyReleaseMask | PointerMotionMask;
Window window = _XCreateWindow(display, parent, x, y, width, height, border_width, depth, class, visual, valueMask, attributes);
printf(" X11 RESOLUTION: %dx%d\n\n", width, height);
if (getConfig()->fullscreen)
{
Atom wm_state = XInternAtom(display, "_NET_WM_STATE", true);
Atom wm_fullscreen = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", true);
XChangeProperty(display, window, wm_state, XA_ATOM, 32, PropModeReplace, (unsigned char *)&wm_fullscreen, 1);
}
win = window;
}
win = window;
return window;
else
{
win = x11Window;
}
return win;
}
int XGrabPointer(Display *display, Window grab_window, Bool owner_events, unsigned int event_mask, int pointer_mode,
@@ -78,10 +97,15 @@ int XGrabPointer(Display *display, Window grab_window, Bool owner_events, unsign
int (*_XGrabPointer)(Display *display, Window grab_window, Bool owner_events, unsigned int event_mask,
int pointer_mode, int keyboard_mode, Window confine_to, Cursor cursor, Time time) =
dlsym(RTLD_NEXT, "XGrabPointer");
int returnValue = _XGrabPointer(display, grab_window, owner_events, event_mask, pointer_mode, keyboard_mode,
confine_to, cursor, time);
XUngrabPointer(display, time);
return returnValue;
if (getConfig()->noSDL)
{
int returnValue =
_XGrabPointer(display, grab_window, owner_events, event_mask, pointer_mode, keyboard_mode, confine_to, cursor, time);
XUngrabPointer(display, time);
return returnValue;
}
return _XGrabPointer(display, grab_window, owner_events, event_mask, pointer_mode, keyboard_mode, confine_to, cursor, time);
}
int XGrabKeyboard(Display *display, Window grab_window, Bool owner_events, int pointer_mode, int keyboard_mode,
@@ -89,22 +113,27 @@ int XGrabKeyboard(Display *display, Window grab_window, Bool owner_events, int p
{
int (*_XGrabKeyboard)(Display *display, Window grab_window, Bool owner_events, int pointer_mode, int keyboard_mode,
Time time) = dlsym(RTLD_NEXT, "XGrabKeyboard");
int returnValue = _XGrabKeyboard(display, grab_window, owner_events, pointer_mode, keyboard_mode, time);
XUngrabKeyboard(display, time);
return returnValue;
}
int XDefineCursor(Display *display, Window w, Cursor cursor)
{
return 0;
if (getConfig()->noSDL)
{
int returnValue = _XGrabKeyboard(display, grab_window, owner_events, pointer_mode, keyboard_mode, time);
XUngrabKeyboard(display, time);
return returnValue;
}
return _XGrabKeyboard(display, grab_window, owner_events, pointer_mode, keyboard_mode, time);
}
int XStoreName(Display *display, Window w, const char *window_name)
{
int (*_XStoreName)(Display *display, Window w, const char *window_name) = dlsym(RTLD_NEXT, "XStoreName");
char windowTitle[512];
sprintf(windowTitle, "%s - FPS: %.2f", getGameName(), calculateFps());
return _XStoreName(display, w, windowTitle);
if (getConfig()->noSDL)
{
char windowTitle[512];
sprintf(windowTitle, "%s - FPS: %.2f", getGameName(), calculateFps());
return _XStoreName(display, w, windowTitle);
}
return _XStoreName(display, w, window_name);
}
int XSetStandardProperties(Display *display, Window window, const char *window_name, const char *icon_name,
@@ -113,9 +142,30 @@ int XSetStandardProperties(Display *display, Window window, const char *window_n
int (*_XSetStandardProperties)(Display *display, Window window, const char *window_name, const char *icon_name,
Pixmap icon_pixmap, char **argv, int argc, XSizeHints *hints) =
dlsym(RTLD_NEXT, "XSetStandardProperties");
char gameTitle[256] = {0};
strcat(gameTitle, getGameName());
return _XSetStandardProperties(display, window, gameTitle, icon_name, icon_pixmap, argv, argc, hints);
if (getConfig()->noSDL)
{
char gameTitle[256] = {0};
strcat(gameTitle, getGameName());
return _XSetStandardProperties(display, window, gameTitle, icon_name, icon_pixmap, argv, argc, hints);
}
return _XSetStandardProperties(display, window, window_name, icon_name, icon_pixmap, argv, argc, hints);
}
int XPending(Display *display)
{
int (*_XPending)(Display *display) = dlsym(RTLD_NEXT, "XPending");
if (SDLWindowCreated)
return 0;
return _XPending(display);
}
int XFlush(Display *display)
{
int (*_XFlush)(Display *display) = dlsym(RTLD_NEXT, "XFlush");
if (SDLWindowCreated)
return 0;
return _XFlush(display);
}
Bool XF86VidModeSwitchToMode(Display *display, int screen, XF86VidModeModeInfo *modesinfo)
@@ -153,48 +203,37 @@ int XF86VidModeGetAllModeLines(Display *display, int screen, int *modecount_retu
return true;
}
int XPending(Display *display)
{
int (*_XPending)(Display *display) = dlsym(RTLD_NEXT, "XPending");
if (SDLGame)
return 0;
return _XPending(display);
}
// Cursor XCreatePixmapCursor(Display *display, Pixmap source, Pixmap mask, XColor *fg, XColor *bg, unsigned int x,
// unsigned int y)
// {
// int (*_XCreatePixmapCursor)(Display *display, Pixmap source, Pixmap mask, XColor *fg, XColor *bg, unsigned int x,
// unsigned int y) = dlsym(RTLD_NEXT, "XCreatePixmapCursor");
// if (SDLGame)
// return 0;
// return _XCreatePixmapCursor(display, source, mask, fg, bg, x, y);
// }
Cursor XCreatePixmapCursor(Display *display, Pixmap source, Pixmap mask, XColor *fg, XColor *bg, unsigned int x,
unsigned int y)
{
int (*_XCreatePixmapCursor)(Display *display, Pixmap source, Pixmap mask, XColor *fg, XColor *bg, unsigned int x,
unsigned int y) = dlsym(RTLD_NEXT, "XCreatePixmapCursor");
if (SDLGame)
return 0;
return _XCreatePixmapCursor(display, source, mask, fg, bg, x, y);
}
// int XFreePixmap(Display *display, Pixmap pixmap)
// {
// int (*_XFreePixmap)(Display *display, Pixmap pixmap) = dlsym(RTLD_NEXT, "XFreePixmap");
// if (SDLGame)
// return 0;
// return _XFreePixmap(display, pixmap);
// }
int XFreePixmap(Display *display, Pixmap pixmap)
{
int (*_XFreePixmap)(Display *display, Pixmap pixmap) = dlsym(RTLD_NEXT, "XFreePixmap");
if (SDLGame)
return 0;
return _XFreePixmap(display, pixmap);
}
// Pixmap XCreateBitmapFromData(Display *display, Drawable drawable, const char *data, unsigned int x, unsigned int y)
// {
// Pixmap (*_XCreateBitmapFromData)(Display *display, Drawable drawable, const char *data, unsigned int x,
// unsigned int y) = dlsym(RTLD_NEXT, "XCreateBitmapFromData");
// if (SDLGame)
// return 0;
// return _XCreateBitmapFromData(display, drawable, data, x, y);
// }
Pixmap XCreateBitmapFromData(Display *display, Drawable drawable, const char *data, unsigned int x, unsigned int y)
{
Pixmap (*_XCreateBitmapFromData)(Display *display, Drawable drawable, const char *data, unsigned int x,
unsigned int y) = dlsym(RTLD_NEXT, "XCreateBitmapFromData");
if (SDLGame)
return 0;
return _XCreateBitmapFromData(display, drawable, data, x, y);
}
int XFlush(Display *display)
{
int (*_XFlush)(Display *display) = dlsym(RTLD_NEXT, "XFlush");
if (SDLGame)
return 0;
return _XFlush(display);
}
// int XDefineCursor(Display *display, Window w, Cursor cursor)
// {
// return 0;
// }
typedef unsigned int uint;