Unverified Commit 32fd0c98 authored by Kurtis Dinelle's avatar Kurtis Dinelle Committed by GitHub
Browse files

Merge pull request #10 from phcoder/wold

LIBRETRO: Add compilation for old Windows (98SE and up)
parents 0345f405 c1b7c7c7
Pipeline #83951 passed with stages
in 6 minutes and 59 seconds
......@@ -23,6 +23,18 @@ include:
- project: 'libretro-infrastructure/ci-templates'
file: '/windows-i686-mingw.yml'
# Windows msvc10 64-bit
- project: 'libretro-infrastructure/ci-templates'
file: '/windows-x64-msvc10-msys2.yml'
# Windows msvc10 32-bit
- project: 'libretro-infrastructure/ci-templates'
file: '/windows-i686-msvc10-msys2.yml'
# Windows msvc05 32-bit
- project: 'libretro-infrastructure/ci-templates'
file: '/windows-i686-msvc05-msys2.yml'
# Linux 64-bit
- project: 'libretro-infrastructure/ci-templates'
file: '/linux-x64.yml'
......@@ -129,6 +141,24 @@ libretro-build-windows-i686:
- .libretro-windows-i686-mingw-make-default
- .core-defs
# Windows msvc10 64-bit
libretro-build-windows-msvc10-x64:
extends:
- .libretro-windows-x64-msvc10-msys2-make-default
- .core-defs
# Windows msvc10 32-bit
libretro-build-windows-msvc10-i686:
extends:
- .libretro-windows-i686-msvc10-msys2-make-default
- .core-defs
# Windows msvc05 32-bit
libretro-build-windows-msvc05-i686:
extends:
- .libretro-windows-i686-msvc05-msys2-make-default
- .core-defs
# Linux 64-bit
libretro-build-linux-x64:
extends:
......
......@@ -384,57 +384,65 @@ else ifneq (,$(findstring windows_msvc2017,$(platform)))
LDFLAGS += -DLL
# Windows MSVC 2010 x64
else ifeq ($(platform), windows_msvc2010_x64)
CC = cl.exe
CC = cl.exe -TP
CXX = cl.exe
CFLAGS += -wd4711 -wd4514 -wd4820 -DUSE_RGB565=1
CXXFLAGS += -wd4711 -wd4514 -wd4820 -DUSE_RGB565=1
PATH := $(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../../VC/bin/amd64"):$(PATH)
PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../IDE")
LIB := $(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../../VC/lib/amd64")
INCLUDE := $(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../../VC/include")
WindowsSdkDir := $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*')lib/x64
WindowsSdkDir ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*')lib/x64
WindowsSdkDir := $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*')
WindowsSdkDir ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*')
WindowsSdkDirInc := $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*')Include
WindowsSdkDirInc ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*')Include
WindowsSDKIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include")
WindowsSDKGlIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\gl")
WindowsSDKLibDir := $(shell cygpath -w "$(WindowsSdkDir)\Lib\x64")
INCFLAGS_PLATFORM = -I"$(WindowsSdkDirInc)"
export INCLUDE := $(INCLUDE)
export LIB := $(LIB);$(WindowsSdkDir)
export INCLUDE := $(INCLUDE);$(WindowsSDKIncludeDir);$(WindowsSDKGlIncludeDir)
export LIB := $(LIB);$(WindowsSDKLibDir)
TARGET := $(TARGET_NAME)_libretro.dll
PSS_STYLE :=2
LDFLAGS += -DLL
LIBS =
# Windows MSVC 2010 x86
else ifeq ($(platform), windows_msvc2010_x86)
CC = cl.exe
CC = cl.exe -TP
CXX = cl.exe
CFLAGS += -wd4711 -wd4514 -wd4820 -DUSE_RGB565=1
CXXFLAGS += -wd4711 -wd4514 -wd4820 -DUSE_RGB565=1
PATH := $(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../../VC/bin"):$(PATH)
PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../IDE")
LIB := $(shell IFS=$$'\n'; cygpath -w "$(VS100COMNTOOLS)../../VC/lib")
INCLUDE := $(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../../VC/include")
WindowsSdkDir := $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*')lib
WindowsSdkDir ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*')lib
WindowsSdkDir := $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*')
WindowsSdkDir ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*')
WindowsSdkDirInc := $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*')Include
WindowsSdkDirInc ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*')Include
WindowsSDKIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include")
WindowsSDKGlIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\gl")
WindowsSDKLibDir := $(shell cygpath -w "$(WindowsSdkDir)\Lib")
INCFLAGS_PLATFORM = -I"$(WindowsSdkDirInc)"
export INCLUDE := $(INCLUDE)
export LIB := $(LIB);$(WindowsSdkDir)
export INCLUDE := $(INCLUDE);$(WindowsSDKIncludeDir);$(WindowsSDKGlIncludeDir)
export LIB := $(LIB);$(WindowsSDKLibDir)
TARGET := $(TARGET_NAME)_libretro.dll
PSS_STYLE :=2
LDFLAGS += -DLL
LIBS =
# Windows MSVC 2005 x86
else ifeq ($(platform), windows_msvc2005_x86)
CC = cl.exe
CC = cl.exe -TP
CXX = cl.exe
CFLAGS += -wd4711 -wd4514 -wd4820 -DUSE_RGB565=1
CXXFLAGS += -wd4711 -wd4514 -wd4820 -DUSE_RGB565=1
PATH := $(shell IFS=$$'\n'; cygpath "$(VS80COMNTOOLS)../../VC/bin"):$(PATH)
PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VS80COMNTOOLS)../IDE")
INCLUDE := $(shell IFS=$$'\n'; cygpath "$(VS80COMNTOOLS)../../VC/include")
......
......@@ -8,7 +8,17 @@
#include <sys/time.h>
#endif
#endif
#if defined(_MSC_VER) && _MSC_VER < 1800
#ifdef __LIBRETRO__
#include "libretro.h"
#else
#define bool int
#define true 1
#define false 0
#endif
#else
#include <stdbool.h>
#endif
#include <stdint.h>
#define ONE_SEC 1000000
......
......@@ -168,6 +168,7 @@ void chip8_load_font(CHIP8 *chip8)
}
}
#ifndef __LIBRETRO__
bool chip8_load_rom(CHIP8 *chip8, char *filename)
{
FILE *rom = fopen(filename, "rb");
......@@ -189,6 +190,7 @@ bool chip8_load_rom(CHIP8 *chip8, char *filename)
fprintf(stderr, "Unable to open ROM file %s\n", filename);
return false;
}
#endif
void chip8_load_rom_buffer(CHIP8 *chip8, const void *raw, size_t sz) {
size_t maxsz = MAX_RAM - chip8->pc_start_addr;
......
......@@ -31,11 +31,11 @@ static retro_audio_sample_t audio_cb;
static retro_audio_sample_batch_t audio_batch_cb;
static CHIP8 chip8;
static int cpu_debt = 0;
static unsigned long cpu_debt = 0;
#define AUDIO_RESAMPLE_RATE 44100
static unsigned int audio_counter_chip8 = 0;
static unsigned int audio_counter_resample = 0;
static int audio_freq_chip8 = 0;
static unsigned int audio_freq_chip8 = 0;
static int snd_buf_pntr = 0;
static uint8_t sram[NUM_USER_FLAGS];
......@@ -150,7 +150,7 @@ static struct retro_variable variables[] =
};
// TODO: find a better mapping
static int hexorder[] = {
static unsigned hexorder[] = {
RETRO_DEVICE_ID_JOYPAD_B,
RETRO_DEVICE_ID_JOYPAD_START,
RETRO_DEVICE_ID_JOYPAD_Y,
......@@ -238,15 +238,15 @@ static void load_theme(void)
overlap_color = color_themes[theme_number].overlap;
}
static int get_cpu_freq_var(int def)
static unsigned long get_cpu_freq_var(unsigned long def)
{
struct retro_variable var;
var.key = "jaxe_cpu_requency";
var.value = NULL;
if (!environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || !var.value)
return def;
int cpu_freq = strtoul(var.value, 0, 0);
if (cpu_freq <= 0)
unsigned long cpu_freq = strtoul(var.value, 0, 0);
if (cpu_freq == 0)
return def;
return cpu_freq;
}
......@@ -282,7 +282,7 @@ void draw_display(void)
{
for (int x = 0; x < DISPLAY_WIDTH; x++)
{
long color;
pixel_t color;
if (!chip8.display[y][x] && !chip8.display2[y][x])
{
......@@ -433,7 +433,7 @@ void retro_run(void)
bool updated = false;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated) {
load_theme();
int cpu_freq = get_cpu_freq_var(chip8.cpu_freq);
unsigned long cpu_freq = get_cpu_freq_var(chip8.cpu_freq);
if (cpu_freq != chip8.cpu_freq)
chip8_set_cpu_freq(&chip8, cpu_freq);
}
......@@ -446,7 +446,7 @@ void retro_run(void)
else
chip8.keypad[i] = chip8.keypad[i] == KEY_DOWN ? KEY_RELEASED : KEY_UP;
for (int i = 0; i < (chip8.cpu_freq + cpu_debt) / chip8.refresh_freq && !chip8.exit; i++) {
for (unsigned i = 0; i < (chip8.cpu_freq + cpu_debt) / chip8.refresh_freq && !chip8.exit; i++) {
chip8_cycle(&chip8);
if (!chip8.beep) {
......@@ -529,7 +529,7 @@ struct serialized_state
unsigned long cpu_debt;
unsigned int audio_counter_chip8;
unsigned int audio_counter_resample;
int audio_freq_chip8;
unsigned int audio_freq_chip8;
int snd_buf_pntr;
uint8_t sram[NUM_USER_FLAGS];
};
......
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