Commit 2f235a30 authored by jdgleaver's avatar jdgleaver
Browse files

Initial libretro port

parent 6b75be3c
*.o
*.so
*.dll
# DESCRIPTION: GitLab CI/CD for libRetro (NOT FOR GitLab-proper)
##############################################################################
################################# BOILERPLATE ################################
##############################################################################
# Core definitions
.core-defs:
variables:
JNI_PATH: platform/libretro
MAKEFILE_PATH: platform/libretro
CORENAME: potator
# Inclusion templates, required for the build to work
include:
################################## DESKTOPS ################################
# Windows 64-bit
- project: 'libretro-infrastructure/ci-templates'
file: '/windows-x64-mingw.yml'
# Windows 32-bit
- project: 'libretro-infrastructure/ci-templates'
file: '/windows-i686-mingw.yml'
# Linux 64-bit
- project: 'libretro-infrastructure/ci-templates'
file: '/linux-x64.yml'
# Linux 32-bit
- project: 'libretro-infrastructure/ci-templates'
file: '/linux-i686.yml'
################################## CELLULAR ################################
# Android
- project: 'libretro-infrastructure/ci-templates'
file: '/android-jni.yml'
################################## CONSOLES ################################
# PlayStation Vita
- project: 'libretro-infrastructure/ci-templates'
file: '/vita-static.yml'
# Nintendo 3DS
- project: 'libretro-infrastructure/ci-templates'
file: '/ctr-static.yml'
# Nintendo Switch
- project: 'libretro-infrastructure/ci-templates'
file: '/libnx-static.yml'
# OpenDingux
- project: 'libretro-infrastructure/ci-templates'
file: '/dingux-mips32.yml'
#################################### MISC ##################################
# Stages for building
stages:
- build-prepare
- build-shared
- build-static
##############################################################################
#################################### STAGES ##################################
##############################################################################
#
################################### DESKTOPS #################################
# Windows 64-bit
libretro-build-windows-x64:
extends:
- .libretro-windows-x64-mingw-make-default
- .core-defs
# Windows 32-bit
libretro-build-windows-i686:
extends:
- .libretro-windows-i686-mingw-make-default
- .core-defs
# Linux 64-bit
libretro-build-linux-x64:
extends:
- .libretro-linux-x64-make-default
- .core-defs
# Linux 32-bit
libretro-build-linux-i686:
extends:
- .libretro-linux-i686-make-default
- .core-defs
################################### CELLULAR #################################
# Android ARMv7a
android-armeabi-v7a:
extends:
- .libretro-android-jni-armeabi-v7a
- .core-defs
# Android ARMv8a
android-arm64-v8a:
extends:
- .libretro-android-jni-arm64-v8a
- .core-defs
# Android 64-bit x86
android-x86_64:
extends:
- .libretro-android-jni-x86_64
- .core-defs
# Android 32-bit x86
android-x86:
extends:
- .libretro-android-jni-x86
- .core-defs
################################### CONSOLES #################################
# PlayStation Vita
libretro-build-vita:
extends:
- .libretro-vita-static-retroarch-master
- .core-defs
# Nintendo 3DS
libretro-build-ctr:
extends:
- .libretro-ctr-static-retroarch-master
- .core-defs
# Nintendo Switch
libretro-build-libnx-aarch64:
extends:
- .libretro-libnx-static-retroarch-master
- .core-defs
# OpenDingux
libretro-build-dingux-mips32:
extends:
- .libretro-dingux-mips32-make-default
- .core-defs
......@@ -30,13 +30,117 @@
#endif
static uint16 *supervision_palette;
static uint8 gpu_regs[4];
uint8 gpu_regs[4];
#ifdef NDS
#define RGB555(R,G,B) ((((int)(B))<<10)|(((int)(G))<<5)|(((int)(R)))|BIT(15))
#else
#define RGB555(R,G,B) ((((int)(B))<<10)|(((int)(G))<<5)|(((int)(R))))
#endif
#ifdef __LIBRETRO__
static const uint32 palette_colours_none[] = {
0xE0E0E0, 0xB9B9B9, 0x545454, 0x121212
};
static const uint32 palette_colours_supervision[] = {
0x7CC67C, 0x54868C, 0x2C6264, 0x0C322C
};
static const uint32 palette_colours_gb_dmg[] = {
0x578200, 0x317400, 0x005121, 0x00420C
};
static const uint32 palette_colours_gb_pocket[] = {
0xA7B19A, 0x86927C, 0x535f49, 0x2A3325
};
static const uint32 palette_colours_gb_light[] = {
0x01CBDF, 0x01B6D5, 0x269BAD, 0x00778D
};
static const uint32 palette_colours_blossom_pink[] = {
0xF09898, 0xA86A6A, 0x603C3C, 0x180F0F
};
static const uint32 palette_colours_bubbles_blue[] = {
0x88D0F0, 0x5F91A8, 0x365360, 0x0D1418
};
static const uint32 palette_colours_buttercup_green[] = {
0xB8E088, 0x809C5F, 0x495936, 0x12160D
};
static const uint32 palette_colours_digivice[] = {
0x8C8C73, 0x646453, 0x38382E, 0x000000
};
static const uint32 palette_colours_game_com[] = {
0xA7BF6B, 0x6F8F4F, 0x0F4F2F, 0x000000
};
static const uint32 palette_colours_gameking[] = {
0x8CCE94, 0x6B9C63, 0x506541, 0x184221
};
static const uint32 palette_colours_game_master[] = {
0x829FA6, 0x5A787E, 0x384A50, 0x2D2D2B
};
static const uint32 palette_colours_golden_wild[] = {
0xB99F65, 0x816F46, 0x4A3F28, 0x120F0A
};
static const uint32 palette_colours_greenscale[] = {
0x9CBE0C, 0x6E870A, 0x2C6234, 0x0C360C
};
static const uint32 palette_colours_hokage_orange[] = {
0xEA8352, 0xA35B39, 0x5D3420, 0x170D08
};
static const uint32 palette_colours_labo_fawn[] = {
0xD7AA73, 0x967650, 0x56442E, 0x15110B
};
static const uint32 palette_colours_legendary_super_saiyan[] = {
0xA5DB5A, 0x73993E, 0x425724, 0x101509
};
static const uint32 palette_colours_microvision[] = {
0xA0A0A0, 0x787878, 0x505050, 0x303030
};
static const uint32 palette_colours_million_live_gold[] = {
0xCDB261, 0x8F7C43, 0x524726, 0x141109
};
static const uint32 palette_colours_odyssey_gold[] = {
0xC2A000, 0x877000, 0x4D4000, 0x131000
};
static const uint32 palette_colours_shiny_sky_blue[] = {
0x8CB6DF, 0x627F9C, 0x384859, 0x0E1216
};
static const uint32 palette_colours_slime_blue[] = {
0x2F8CCC, 0x20628E, 0x123851, 0x040E14
};
static const uint32 palette_colours_ti_83[] = {
0x9CA684, 0x727C5A, 0x464A35, 0x181810
};
static const uint32 palette_colours_travel_wood[] = {
0xF8D8B0, 0xA08058, 0x705030, 0x482810
};
static const uint32 palette_colours_virtual_boy[] = {
0xE30000, 0x950000, 0x560000, 0x000000
};
#define RGB24_TO_RGB565(RGB24) ( ((RGB24 >> 8) & 0xF800) | ((RGB24 >> 5) & 0x7E0) | ((RGB24 >> 3) & 0x1F) )
#endif
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
......@@ -66,6 +170,7 @@ void gpu_init(void)
void gpu_done(void)
{
//fprintf(log_get(), "gpu: done\n");
memory_free(supervision_palette);
}
////////////////////////////////////////////////////////////////////////////////
//
......@@ -119,7 +224,12 @@ void gpu_reset(void)
supervision_palette[1] = PIX_TO_RGB(actualScreen->format,170,170,170);
supervision_palette[0] = PIX_TO_RGB(actualScreen->format,240,240,240);
#endif
#ifdef __LIBRETRO__
supervision_palette[3] = RGB24_TO_RGB565(palette_colours_none[3]);
supervision_palette[2] = RGB24_TO_RGB565(palette_colours_none[2]);
supervision_palette[1] = RGB24_TO_RGB565(palette_colours_none[1]);
supervision_palette[0] = RGB24_TO_RGB565(palette_colours_none[0]);
#endif
memset(gpu_regs, 0, 4);
}
////////////////////////////////////////////////////////////////////////////////
......@@ -137,6 +247,94 @@ void gpu_set_colour_scheme(int colourScheme)
printf("Gpu Set Color Scheme\n");
#endif
#ifdef __LIBRETRO__
const uint32 *palette_colours = palette_colours_none;
switch (colourScheme)
{
case COLOUR_SCHEME_SUPERVISION:
palette_colours = palette_colours_supervision;
break;
case COLOUR_SCHEME_GB_DMG:
palette_colours = palette_colours_gb_dmg;
break;
case COLOUR_SCHEME_GB_POCKET:
palette_colours = palette_colours_gb_pocket;
break;
case COLOUR_SCHEME_GB_LIGHT:
palette_colours = palette_colours_gb_light;
break;
case COLOUR_SCHEME_BLOSSOM_PINK:
palette_colours = palette_colours_blossom_pink;
break;
case COLOUR_SCHEME_BUBBLES_BLUE:
palette_colours = palette_colours_bubbles_blue;
break;
case COLOUR_SCHEME_BUTTERCUP_GREEN:
palette_colours = palette_colours_buttercup_green;
break;
case COLOUR_SCHEME_DIGIVICE:
palette_colours = palette_colours_digivice;
break;
case COLOUR_SCHEME_GAME_COM:
palette_colours = palette_colours_game_com;
break;
case COLOUR_SCHEME_GAMEKING:
palette_colours = palette_colours_gameking;
break;
case COLOUR_SCHEME_GAME_MASTER:
palette_colours = palette_colours_game_master;
break;
case COLOUR_SCHEME_GOLDEN_WILD:
palette_colours = palette_colours_golden_wild;
break;
case COLOUR_SCHEME_GREENSCALE:
palette_colours = palette_colours_greenscale;
break;
case COLOUR_SCHEME_HOKAGE_ORANGE:
palette_colours = palette_colours_hokage_orange;
break;
case COLOUR_SCHEME_LABO_FAWN:
palette_colours = palette_colours_labo_fawn;
break;
case COLOUR_SCHEME_LEGENDARY_SUPER_SAIYAN:
palette_colours = palette_colours_legendary_super_saiyan;
break;
case COLOUR_SCHEME_MICROVISION:
palette_colours = palette_colours_microvision;
break;
case COLOUR_SCHEME_MILLION_LIVE_GOLD:
palette_colours = palette_colours_million_live_gold;
break;
case COLOUR_SCHEME_ODYSSEY_GOLD:
palette_colours = palette_colours_odyssey_gold;
break;
case COLOUR_SCHEME_SHINY_SKY_BLUE:
palette_colours = palette_colours_shiny_sky_blue;
break;
case COLOUR_SCHEME_SLIME_BLUE:
palette_colours = palette_colours_slime_blue;
break;
case COLOUR_SCHEME_TI_83:
palette_colours = palette_colours_ti_83;
break;
case COLOUR_SCHEME_TRAVEL_WOOD:
palette_colours = palette_colours_travel_wood;
break;
case COLOUR_SCHEME_VIRTUAL_BOY:
palette_colours = palette_colours_virtual_boy;
break;
case COLOUR_SCHEME_NONE:
default:
colourScheme = COLOUR_SCHEME_NONE;
break;
}
supervision_palette[3] = RGB24_TO_RGB565(palette_colours[3]);
supervision_palette[2] = RGB24_TO_RGB565(palette_colours[2]);
supervision_palette[1] = RGB24_TO_RGB565(palette_colours[1]);
supervision_palette[0] = RGB24_TO_RGB565(palette_colours[0]);
#else
float greenf=1;
float bluef=1;
float redf=1;
......@@ -210,6 +408,7 @@ void gpu_set_colour_scheme(int colourScheme)
supervision_palette[1] = PIX_TO_RGB(actualScreen->format,p21, p22, p23);
supervision_palette[0] = PIX_TO_RGB(actualScreen->format,p31, p32, p33);
#endif
#endif
}
////////////////////////////////////////////////////////////////////////////////
//
......@@ -246,7 +445,7 @@ uint8 gpu_read(uint32 addr)
//
//
////////////////////////////////////////////////////////////////////////////////
void gpu_render_scanline(uint32 scanline, int16 *backbuffer)
void gpu_render_scanline(uint32 scanline, uint16 *backbuffer)
{
uint8 *vram_line = &(memorymap_getUpperRamPointer())[(gpu_regs[2] >> 2) + (scanline*0x30)];
uint8 x;
......
......@@ -8,9 +8,10 @@ void gpu_done(void);
void gpu_reset(void);
void gpu_write(uint32 addr, uint8 data);
uint8 gpu_read(uint32 addr);
void gpu_render_scanline(uint32 scanline, int16 *backbuffer);
//void gpu_render_scanline(uint32 scanline, int16 *backbuffer); //fast
void gpu_render_scanline(uint32 scanline, uint16 *backbuffer);
void gpu_render_scanline_fast(uint32 scanline, uint16 *backbuffer);
void gpu_set_colour_scheme(int ws_colourScheme);
extern uint8 gpu_regs[4];
#endif
......@@ -29,6 +29,7 @@ int log_init(char *path)
if (log_stream==NULL)
return(0);
return(1);*/
return 1;
}
//////////////////////////////////////////////////////////////////////////////
//
......@@ -43,6 +44,7 @@ int log_init(char *path)
FILE *log_get(void)
{
// return(log_stream);
return NULL;
}
//////////////////////////////////////////////////////////////////////////////
//
......
......@@ -245,5 +245,5 @@ case 0xFD: MR_Ax(I);M_SBC(I);break; /* SBC $ssss,x ABS,x */
case 0xFE: MM_Ax(M_INC);break; /* INC $ssss,x ABS,x */
default:
if(R->TrapBadOps)
printf("[M65C02 %lX] Unrecognized instruction: $%02X at PC=$%04X\n",
printf("[M65C02 %p] Unrecognized instruction: $%02X at PC=$%04X\n",
R->User,Op6502(R->PC.W-1),(word)(R->PC.W-1));break;
......@@ -65,6 +65,14 @@ void memorymap_init()
void memorymap_done()
{
//fprintf(log_get(), "memorymap: done\n");
memory_free(memorymap_lowerRam);
memory_free(memorymap_upperRam);
memory_free(memorymap_regs);
if (memorymap_programRom)
{
free(memorymap_programRom);
memorymap_programRom = NULL;
}
}
////////////////////////////////////////////////////////////////////////////////
//
......
......@@ -14,54 +14,19 @@
#include <stdio.h>
#include <string.h>
#include <SDL/SDL.h>
typedef struct {
unsigned char reg[4];
int on;
int waveform, volume;
int pos;
int size;
int count;
} SVISION_CHANNEL;
SVISION_CHANNEL m_channel[2];
typedef enum {
SVISION_NOISE_Type7Bit,
SVISION_NOISE_Type14Bit
} SVISION_NOISE_Type;
typedef struct {
unsigned char reg[3];
int on, right, left, play;
SVISION_NOISE_Type type;
int state;
int volume;
int count;
double step, pos;
int value; // currently simple random function
} SVISION_NOISE;
SVISION_NOISE m_noise;
typedef struct {
unsigned char reg[5];
int on, right, left;
int ca14to16;
int start,size;
double pos, step;
int finished;
} SVISION_DMA;
SVISION_DMA m_dma;
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
void sound_stream_update(Uint8 *stream, int len) {
void sound_stream_update(uint8 *stream, int len) {
int i, j;
SVISION_CHANNEL *channel;
short s;
unsigned short *left=(unsigned short *) stream;
unsigned short *right=(unsigned short *) (stream+1);
int16 s;
uint16 *left=(uint16 *) stream;
uint16 *right=(uint16 *) (stream+1);
for (i = 0; i < len>>1; i++) {
s=0;
......@@ -129,7 +94,7 @@ void sound_stream_update(Uint8 *stream, int len) {
if (m_dma.on) {
unsigned char sample;
unsigned short addr = m_dma.start + (unsigned) m_dma.pos / 2;
uint16 addr = m_dma.start + (unsigned) m_dma.pos / 2;
if (addr >= 0x8000 && addr < 0xc000) {
sample = Rd6502( (addr & 0x3fff) | m_dma.ca14to16);
//sample = machine().root_device().memregion("user1")->base()[(addr & 0x3fff) | m_dma.ca14to16];
......@@ -164,7 +129,7 @@ void sound_stream_update(Uint8 *stream, int len) {
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
void sound_decrement() {
void sound_decrement(void) {
if (m_channel[0].count > 0)
m_channel[0].count--;
if (m_channel[1].count > 0)
......@@ -178,7 +143,7 @@ void sound_decrement() {
////////////////////////////////////////////////////////////////////////////////
void soundport_w(int which, int offset, int data) {
SVISION_CHANNEL *channel = &m_channel[which];
unsigned short size;
uint16 size;
//m_mixer_channel->update();
channel->reg[offset] = data;
......
......@@ -5,6 +5,39 @@
#define BPS 44100
typedef struct {
unsigned char reg[4];
int on;
int waveform, volume;
int pos;
int size;
int count;
} SVISION_CHANNEL;
typedef enum {
SVISION_NOISE_Type7Bit,
SVISION_NOISE_Type14Bit
} SVISION_NOISE_Type;
typedef struct {
unsigned char reg[3];
int on, right, left, play;
SVISION_NOISE_Type type;
int state;
int volume;
int count;
double step, pos;
int value; // currently simple random function
} SVISION_NOISE;
typedef struct {
unsigned char reg[5];
int on, right, left;
int ca14to16;
int start,size;
double pos, step;
int finished;
} SVISION_DMA;
void sound_init();
void sound_reset();
......@@ -13,6 +46,16 @@ void sound_write(uint32 Addr, uint8 data);
void sound_noise_write(uint32 Addr, uint8 data);
void sound_audio_dma(uint32 Addr, uint8 data);
void sound_exec(uint32 cycles);
void sound_stream_update(uint8 *stream, int len);
void sound_decrement(void);
void audio_turnSound(BOOL bOn);
void soundport_w(int which, int offset, int data);
void svision_noise_w(int offset, int data);
void svision_sounddma_w(int offset, int data);
extern SVISION_CHANNEL m_channel[2];
extern SVISION_NOISE m_noise;
extern SVISION_DMA m_dma;
#endif
......@@ -30,26 +30,58 @@
#include "./m6502/m6502.h"
#ifdef __LIBRETRO__
#define COLOUR_SCHEME_NONE 0
#define COLOUR_SCHEME_SUPERVISION 1
#define COLOUR_SCHEME_GB_DMG 2
#define COLOUR_SCHEME_GB_POCKET 3
#define COLOUR_SCHEME_GB_LIGHT 4
#define COLOUR_SCHEME_BLOSSOM_PINK 5
#define COLOUR_SCHEME_BUBBLES_BLUE 6
#define COLOUR_SCHEME_BUTTERCUP_GREEN 7
#define COLOUR_SCHEME_DIGIVICE 8
#define COLOUR_SCHEME_GAME_COM 9
#define COLOUR_SCHEME_GAMEKING 10
#define COLOUR_SCHEME_GAME_MASTER 11
#define COLOUR_SCHEME_GOLDEN_WILD 12
#define COLOUR_SCHEME_GREENSCALE 13
#define COLOUR_SCHEME_HOKAGE_ORANGE 14
#define COLOUR_SCHEME_LABO_FAWN 15
#define COLOUR_SCHEME_LEGENDARY_SUPER_SAIYAN 16
#define COLOUR_SCHEME_MICROVISION 17
#define COLOUR_SCHEME_MILLION_LIVE_GOLD 18
#define COLOUR_SCHEME_ODYSSEY_GOLD 19
#define COLOUR_SCHEME_SHINY_SKY_BLUE 20
#define COLOUR_SCHEME_SLIME_BLUE 21
#define COLOUR_SCHEME_TI_83 22
#define COLOUR_SCHEME_TRAVEL_WOOD 23
#define COLOUR_SCHEME_VIRTUAL_BOY 24
#else
#define COLOUR_SCHEME_DEFAULT 0
#define COLOUR_SCHEME_AMBER 1
#define COLOUR_SCHEME_GREEN 2
#define COLOUR_SCHEME_AMBER 1
#define COLOUR_SCHEME_GREEN 2
#define COLOUR_SCHEME_BLUE 3
#endif
extern void supervision_init(void);
extern void supervision_reset(void);