Commit 3d88fb0d authored by Libretro-Admin's avatar Libretro-Admin
Browse files

Cleanups

parent 314051da
STATIC_LINKING := 0
AR := ar
CC := g++
AR ?= ar
CC ?= gcc
CXX ?= g++
CORE_DIR := .
ifeq ($(platform),)
platform = unix
......@@ -77,11 +80,14 @@ endif
DEFINES := -DIOS
CC = CC -arch armv7 -isysroot $(IOSSDK)
CXX = CXX -arch armv7 -isysroot $(IOSSDK)
ifeq ($(platform),ios9)
CC += -miphoneos-version-min=8.0
CXX += -miphoneos-version-min=8.0
CFLAGS += -miphoneos-version-min=8.0
else
CC += -miphoneos-version-min=5.0
CXX += -miphoneos-version-min=5.0
CFLAGS += -miphoneos-version-min=5.0
endif
else ifneq (,$(findstring qnx,$(platform)))
......@@ -94,12 +100,14 @@ else ifeq ($(platform), emscripten)
SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined
else ifeq ($(platform), vita)
TARGET := $(TARGET_NAME)_vita.a
CC = arm-vita-eabi-g++
CC = arm-vita-eabi-gcc
CXX = arm-vita-eabi-g++
AR = arm-vita-eabi-ar
CFLAGS += -Wl,-q -Wall -O3
STATIC_LINKING = 1
else
CC = g++
CC ?= gcc
CXX ?= g++
TARGET := $(TARGET_NAME)_libretro.dll
SHARED := -shared -static-libgcc -static-libstdc++ -s -Wl,--version-script=link.T -Wl,--no-undefined
endif
......@@ -112,26 +120,34 @@ else
CFLAGS += -O3
endif
SRC := *.cpp
include Makefile.common
OBJECTS := $(SOURCES_C:.c=.o) $(SOURCES_CXX:.cpp=.o)
CFLAGS += -Wall -pedantic $(fpic)
ifneq (,$(findstring qnx,$(platform)))
CFLAGS += -Wc,-std=c++98
else
CFLAGS += -std=c++98
CFLAGS += -std=gnu++98
endif
all:
all: $(TARGET)
$(TARGET): $(OBJECTS)
ifeq ($(STATIC_LINKING), 1)
$(AR) rcs ${TARGET} $(SRC)
$(AR) rcs $@ $(OBJECTS)
else
$(CC) $(CFLAGS) $(fpic) $(SHARED) $(SRC) $(LDFLAGS) -o ${TARGET}
$(CXX) $(fpic) $(SHARED) $(INCLUDES) -o $@ $(OBJECTS) $(LDFLAGS)
endif
%.o: %.cpp
$(CXX) $(CFLAGS) $(fpic) -c -o $@ $<
%.o: %.c
$(CC) $(CFLAGS) $(fpic) -c -o $@ $<
clean:
rm -f *.so *.o *.a
rm -f -r libs obj
rm -f *.so *.o
.PHONY: clean
......@@ -28,7 +28,6 @@ VE_VMS_CPU::VE_VMS_CPU(VE_VMS_RAM *_ram, VE_VMS_ROM *_rom, VE_VMS_FLASH *_flash,
interruptLevel = 0;
currentInterrupt = 0;
interruptsMasked = false;
instructionCount = 0;
ram = _ram;
rom = _rom;
......
......@@ -137,7 +137,6 @@ private:
int interruptLevel;
int currentInterrupt;
bool interruptsMasked;
int instructionCount;
VE_VMS_RAM *ram;
......
......@@ -174,40 +174,46 @@ void VE_VMS_FLASH::loadROM(byte *d, size_t buffSize, int romType, const char *fi
///Returns raw VMS data and its size
size_t VE_VMS_FLASH::getROM(byte *out)
{
int i, j, c;
//Loading userData (200 blocks, blocks are ordered descending)
for(int i = 0, c = 0; i < 200; ++i)
for(i = 0, c = 0; i < 200; ++i)
{
for(int j = 0; j < 512; j++){
out[(i*512) + j] = userData[c];
c++;
}
for(j = 0; j < 512; j++)
{
out[(i*512) + j] = userData[c];
c++;
}
}
//Loading directory (13 blocks)
for(int i = 253, c = 0; i >= 241; --i)
for(i = 253, c = 0; i >= 241; --i)
{
for(int j = 0; j < 512; j++){
for(j = 0; j < 512; j++)
{
out[(i*512) + j] = directory[c];
c++;
}
}
//Loading FAT and rootBlock
for(int j = 0; j < 512; j++)
for(j = 0; j < 512; j++)
{
out[(0x1FC00) + j] = FAT[j]; //0x1FC00 being 254 x 512
// for(int j = 0; j < 512; j++)
out[(0x1FE00) + j] = rootBlock[j]; //0x1FE00 being 255 x 512
}
return 0;
}
///Returns data
size_t VE_VMS_FLASH::getData(byte *out)
{
for(size_t i = 0; i < 0x20000; ++i, out[i] = data[i]);
return 0x20000;
size_t i;
for(i = 0; i < 0x20000; ++i, out[i] = data[i]);
return 0x20000;
}
......@@ -233,7 +239,8 @@ byte VE_VMS_FLASH::getByte(size_t address)
///Returns byte at address (With banking)
byte VE_VMS_FLASH::readByte(size_t address)
{
if((ram->readByte(0x154) & 1) == 1) address += 0x10000;
if((ram->readByte(0x154) & 1) == 1)
address += 0x10000;
return data[address] & 0xFF;
}
......
......@@ -96,7 +96,7 @@ private:
byte *FAT;
byte *rootBlock;
byte *data;
FILE *flashWriter = NULL;
FILE *flashWriter;
char *romName;
bool IsRealFlash;
bool IsSaveEnabled;
......
......@@ -2,13 +2,27 @@ LOCAL_PATH := $(call my-dir)
CORE_DIR := $(LOCAL_PATH)/..
SOURCES_CPP := $(wildcard $(CORE_DIR)/*.cpp)
COREFLAGS := -ffast-math -funroll-loops
include $(CLEAR_VARS)
LOCAL_CFLAGS :=
LOCAL_MODULE := retro
LOCAL_SRC_FILES := $(SOURCES_CPP)
LOCAL_CPPFLAGS := -std=c++98 $(COREFLAGS)
LOCAL_LDFLAGS := -Wl,-version-script=$(CORE_DIR)/link.T
include $(CORE_DIR)/Makefile.common
LOCAL_SRC_FILES := $(SOURCES_C) $(SOURCES_CXX)
LOCAL_CFLAGS += -O3 -std=gnu++99 -ffast-math -funroll-loops
LOCAL_LDFLAGS := -Wl,-version-script=$(CORE_DIR)/libretro/link.T
ifeq ($(TARGET_ARCH),arm)
LOCAL_CFLAGS += -DANDROID_ARM
endif
ifeq ($(TARGET_ARCH),x86)
LOCAL_CFLAGS += -DANDROID_X86
endif
ifeq ($(TARGET_ARCH),mips)
LOCAL_CFLAGS += -DANDROID_MIPS -D__mips__ -D__MIPSEL__
endif
include $(BUILD_SHARED_LIBRARY)
APP_ABI := all
APP_STL := c++_static
......@@ -32,19 +32,15 @@ VMU *vmu;
uint16_t *frameBuffer;
byte *romData;
RETRO_API void retro_set_environment(retro_environment_t env)
{
environment_cb = env;
//Set variables (Options)
options[0].key = "enable_flash_write";
options[0].value = "Enable flash write (.bin, requires restart); enabled|disabled";
options[1].key = NULL;
options[1].value = NULL;
env(RETRO_ENVIRONMENT_SET_VARIABLES, options);
environment_cb = env;
//Set variables (Options)
options[0] = { "enable_flash_write", "Enable flash write (.bin, requires restart); enabled|disabled"};
options[1] = {NULL, NULL};
env(RETRO_ENVIRONMENT_SET_VARIABLES, options);
}
RETRO_API void retro_set_video_refresh(retro_video_refresh_t vr)
......@@ -118,84 +114,85 @@ RETRO_API void retro_set_controller_port_device(unsigned port, unsigned device)
void processInput()
{
inputPoll_cb();
if(!vmu->cpu->P3_taken) return; //Don't accept new input until previous is processed
byte P3_reg = vmu->ram->readByte_RAW(P3);
int pressFlag = 0;
byte P3_int = vmu->ram->readByte_RAW(P3INT);
P3_reg = ~P3_reg; //Active low
//Up
if(inputState_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP))
{
P3_reg |= 1;
pressFlag++;
}
else P3_reg &= 0xFE;
//Down
if(inputState_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN))
{
P3_reg |= 2;
pressFlag++;
}
else P3_reg &= 0xFD;
//Left
if(inputState_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT))
{
P3_reg |= 4;
pressFlag++;
}
else P3_reg &= 0xFB;
//Right
if(inputState_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT))
{
P3_reg |= 8;
pressFlag++;
}
else P3_reg &= 0xF7;
//A
if(inputState_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A))
{
P3_reg |= 16;
pressFlag++;
}
else P3_reg &= 0xEF;
//B
if(inputState_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B))
{
P3_reg |= 32;
pressFlag++;
}
else P3_reg &= 0xDF;
//Start
if(inputState_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START))
{
//Clicking MODE without a BIOS causes hang
//P3_reg |= 64;
//pressFlag++;
}
//else P3_reg &= 0xBF;
P3_reg = ~P3_reg;
vmu->ram->writeByte_RAW(P3, P3_reg);
if(pressFlag)
{
vmu->ram->writeByte_RAW(P3INT, P3_int | 2);
vmu->intHandler->setP3();
vmu->cpu->P3_taken = false;
}
inputPoll_cb();
if(!vmu->cpu->P3_taken)
return; //Don't accept new input until previous is processed
byte P3_reg = vmu->ram->readByte_RAW(P3);
int pressFlag = 0;
byte P3_int = vmu->ram->readByte_RAW(P3INT);
P3_reg = ~P3_reg; //Active low
//Up
if(inputState_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP))
{
P3_reg |= 1;
pressFlag++;
}
else P3_reg &= 0xFE;
//Down
if(inputState_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN))
{
P3_reg |= 2;
pressFlag++;
}
else P3_reg &= 0xFD;
//Left
if(inputState_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT))
{
P3_reg |= 4;
pressFlag++;
}
else P3_reg &= 0xFB;
//Right
if(inputState_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT))
{
P3_reg |= 8;
pressFlag++;
}
else P3_reg &= 0xF7;
//A
if(inputState_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A))
{
P3_reg |= 16;
pressFlag++;
}
else P3_reg &= 0xEF;
//B
if(inputState_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B))
{
P3_reg |= 32;
pressFlag++;
}
else P3_reg &= 0xDF;
//Start
if(inputState_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START))
{
//Clicking MODE without a BIOS causes hang
//P3_reg |= 64;
//pressFlag++;
}
//else P3_reg &= 0xBF;
P3_reg = ~P3_reg;
vmu->ram->writeByte_RAW(P3, P3_reg);
if(pressFlag)
{
vmu->ram->writeByte_RAW(P3INT, P3_int | 2);
vmu->intHandler->setP3();
vmu->cpu->P3_taken = false;
}
}
RETRO_API void retro_reset(void)
......@@ -205,38 +202,30 @@ RETRO_API void retro_reset(void)
RETRO_API void retro_run(void)
{
unsigned i;
unsigned int cyclesPassed;
processInput();
//Cycles passed since last screen refresh
size_t cyclesPassed = vmu->cpu->getCurrentFrequency() / FPS;
cyclesPassed = vmu->cpu->getCurrentFrequency() / FPS;
for(size_t i = 0; i < cyclesPassed; i++)
for(i = 0; i < cyclesPassed; i++)
vmu->runCycle();
//Video
vmu->video->drawFrame(frameBuffer);
if(vmu->ram->readByte_RAW(MCR) & 8) video_cb(frameBuffer, SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_WIDTH * 2);
if(vmu->ram->readByte_RAW(MCR) & 8)
video_cb(frameBuffer, SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_WIDTH * 2);
//Audio
vmu->audio->generateSignal(audio_cb);
}
RETRO_API size_t retro_serialize_size(void)
{
}
RETRO_API bool retro_serialize(void *data, size_t size)
{
}
RETRO_API bool retro_unserialize(const void *data, size_t size)
{
}
RETRO_API size_t retro_serialize_size(void) { return 0; }
RETRO_API bool retro_serialize(void *data, size_t size) {return false;}
RETRO_API bool retro_unserialize(const void *data, size_t size) {return false;}
RETRO_API void retro_cheat_reset(void)
{
}
RETRO_API void retro_cheat_reset(void) { }
RETRO_API void retro_cheat_set(unsigned index, bool enabled, const char *code)
{
......@@ -244,6 +233,7 @@ RETRO_API void retro_cheat_set(unsigned index, bool enabled, const char *code)
RETRO_API bool retro_load_game(const struct retro_game_info *game)
{
size_t i;
//Set environment variables
enum retro_pixel_format format = RETRO_PIXEL_FORMAT_RGB565;
environment_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &format);
......@@ -256,7 +246,7 @@ RETRO_API bool retro_load_game(const struct retro_game_info *game)
fseek(rom, 0 , SEEK_SET);
romData = (byte *)malloc(romSize);
for(size_t i = 0; i < romSize; i++)
for(i = 0; i < romSize; i++)
romData[i] = fgetc(rom);
fclose(rom);
......@@ -299,14 +289,6 @@ RETRO_API void retro_unload_game(void)
vmu->reset();
}
RETRO_API unsigned retro_get_region(void)
{
}
RETRO_API void *retro_get_memory_data(unsigned id)
{
}
RETRO_API size_t retro_get_memory_size(unsigned id)
{
}
RETRO_API unsigned retro_get_region(void) { return RETRO_REGION_NTSC; }
RETRO_API void *retro_get_memory_data(unsigned id) { return NULL; }
RETRO_API size_t retro_get_memory_size(unsigned id) { return 0; }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment