Many fixes, MAGNUM mapper support (Journey to the West)

* Core 1.0.4
Added: support for the MAGNUM mapper.
Fixed:
reverted ADC and SBC instructions ('Matta Blatta' bug);
noise ('Pacific Battle'), wave ('Popo Team', 'Sonny Xpress!');
buffer overflow if regs[XSIZE] > 160 (e.g. 'Chimera').
Changed: ghosting.
* SDL2
Reduced CPU usage if minimized.
* Emscripten
Fixed: added work-around chromium autoplay policy.
* PSP
Fixed: game preview, screen offset.
Changed: increased audio volume.
* WinAPI
Changed: increased audio volume.
* OpenDingux
Fixed compilation. Tested under MSYS2.
* GP2X
Updated GP2X minimal library.
Fixed compilation. Not tested.
This commit is contained in:
infvaL 2019-07-03 05:22:22 +03:00
parent 8eee49aca4
commit c7f4bad753
21 changed files with 6126 additions and 276 deletions

View File

@ -16,19 +16,20 @@ OBJS = controls.o gpu.o \
${PLATFORM}/main.o ${PLATFORM}/menues.o \
${PLATFORM}/memcmp.o ${PLATFORM}/memcpy.o \
${PLATFORM}/memset.o ${PLATFORM}/strcmp.o \
${PLATFORM}/strlen.o ${PLATFORM}/strncmp.o
${PLATFORM}/strlen.o ${PLATFORM}/strncmp.o \
${PLATFORM}/lib/minimal.o
ASMOBJS = arm_stub.S
BIN =Potator2x
BIN = Potator2x
# Platform specific definitions
# Platform specific definitions
VPATH += common/
CFLAGS += -O3 -DGP2X
CFLAGS += -O3 -Wall
# NOTE: -funroll-loops will slow down compiling considerably
CFLAGS += -funroll-loops -fstrength-reduce -fstrict-aliasing -fexpensive-optimizations -falign-functions -fweb -frename-registers -fomit-frame-pointer -ffast-math -fno-builtin -fno-common -finline -finline-functions
#CFLAGS += -fsigned-char -funroll-loops -fstrength-reduce -fstrict-aliasing -fexpensive-optimizations -falign-functions -fweb -frename-registers -fomit-frame-pointer -ffast-math -fno-builtin -fno-common -finline -finline-functions
#CFLAGS += -fsigned-char
CXXFLAGS = ${CFLAGS} -fno-exceptions -fno-rtti
ASFLAGS = -funroll-loops -fstrength-reduce -fstrict-aliasing -fexpensive-optimizations -falign-functions -fweb -frename-registers -fomit-frame-pointer -ffast-math -fno-builtin -fno-common -finline -finline-functions
ASFLAGS = ${CFLAGS}
INCLUDES = -I${PLATFORM} -I${PLATFORM}/lib -I./common -I${PREFIX}/include
LIBS = -L${PREFIX}/lib -static -lpthread -lm
@ -42,11 +43,11 @@ LIBS = -L${PREFIX}/lib -static -lpthread -lm
%.o: %.cpp
$(CPP) $(CXXFLAGS) ${INCLUDES} -c $<
%.o: %.S
$(CC) -O3 -s -c $<
$(CC) ${CFLAGS} -s -c $<
all: ${OBJS}
${CC} *.o ${PLATFORM}/lib/minimal.o ${LIBS} -o Potator2x.gpe
${STRIP} Potator2x.gpe
gpecomp Potator2x.gpe Potator2x_comp.gpe
${CC} *.o ${LIBS} -o ${BIN}.gpe
${STRIP} ${BIN}.gpe
gpecomp ${BIN}.gpe ${BIN}_comp.gpe
clean:
rm -f *.o Potator2x.gpe Potator2x_comp.gpe
rm -f *.o ${BIN}.gpe ${BIN}_comp.gpe

View File

@ -1,27 +1,27 @@
# Define compilation type
OSTYPE=msys
#OSTYPE=oda320
#OSTYPE=odgcw
OSTYPE = msys
#OSTYPE = oda320
#OSTYPE = odgcw
PRGNAME = potator-od
PRGNAME = potator-od
# define regarding OS, which compiler to use
ifeq "$(OSTYPE)" "msys"
ifeq "$(OSTYPE)" "msys"
EXESUFFIX = .exe
TOOLCHAIN = /c/MinGW32
CC = $(TOOLCHAIN)/bin/gcc
CCP = $(TOOLCHAIN)/bin/g++
LD = $(TOOLCHAIN)/bin/g++
CC = $(TOOLCHAIN)/bin/gcc
CCP = $(TOOLCHAIN)/bin/g++
LD = $(TOOLCHAIN)/bin/g++
else
ifeq "$(OSTYPE)" "oda320"
ifeq "$(OSTYPE)" "oda320"
TOOLCHAIN = /opt/opendingux-toolchain/usr
else
TOOLCHAIN = /opt/gcw0-toolchain/usr
endif
EXESUFFIX = .dge
CC = $(TOOLCHAIN)/bin/mipsel-linux-gcc
CCP = $(TOOLCHAIN)/bin/mipsel-linux-g++
LD = $(TOOLCHAIN)/bin/mipsel-linux-g++
CC = $(TOOLCHAIN)/bin/mipsel-linux-gcc
CCP = $(TOOLCHAIN)/bin/mipsel-linux-g++
LD = $(TOOLCHAIN)/bin/mipsel-linux-g++
endif
# add SDL dependencies
@ -29,36 +29,39 @@ SDL_LIB = $(TOOLCHAIN)/lib
SDL_INCLUDE = $(TOOLCHAIN)/include
# change compilation / linking flag options
ifeq "$(OSTYPE)" "msys"
F_OPTS =-fomit-frame-pointer -ffunction-sections -ffast-math -fsingle-precision-constant
CC_OPTS = -O2 -D_ODSDL_ -DMAX__PATH=1024 -g $(F_OPTS)
CFLAGS = -I$(SDL_INCLUDE) $(CC_OPTS)
CXXFLAGS =$(CFLAGS)
ifeq "$(OSTYPE)" "msys"
F_OPTS = -fomit-frame-pointer -ffunction-sections -ffast-math -fsingle-precision-constant
CC_OPTS = -O2 -DMAX__PATH=1024 -g $(F_OPTS)
CFLAGS = -I$(SDL_INCLUDE) $(CC_OPTS)
CXXFLAGS = $(CFLAGS)
LDFLAGS = -L$(SDL_LIB) -lmingw32 -lSDLmain -lSDL -mwindows
else
F_OPTS = -fomit-frame-pointer -ffunction-sections -ffast-math -fsingle-precision-constant
F_OPTS = -fomit-frame-pointer -ffunction-sections -ffast-math -fsingle-precision-constant
ifeq "$(OSTYPE)" "oda320"
CC_OPTS = -O2 -mips32 -msoft-float -G0 -D_ODSDL_ -DMAX__PATH=1024 $(F_OPTS)
CC_OPTS = -O2 -mips32 -msoft-float -G0 -DMAX__PATH=1024 $(F_OPTS)
else
CC_OPTS = -O2 -mips32 -mhard-float -G0 -D_ODSDL_ -DMAX__PATH=1024 $(F_OPTS)
CC_OPTS = -O2 -mips32 -mhard-float -G0 -DMAX__PATH=1024 $(F_OPTS)
endif
CFLAGS = -I$(SDL_INCLUDE) -D_OPENDINGUX_ $(CC_OPTS)
CXXFLAGS = $(CFLAGS)
LDFLAGS = -L$(SDL_LIB) $(CC_OPTS) -lSDL
CFLAGS = -I$(SDL_INCLUDE) -D_OPENDINGUX_ $(CC_OPTS)
CXXFLAGS = $(CFLAGS)
LDFLAGS = -L$(SDL_LIB) $(CC_OPTS) -lSDL
endif
CFLAGS += -Wall -Wextra
CXXFLAGS += -Wall -Wextra
# Files to be compiled
SRCDIR = ./common/m6502 ./common ./platform/opendingux
VPATH = $(SRCDIR)
SRC_C = $(foreach dir, $(SRCDIR), $(wildcard $(dir)/*.c))
SRCDIR = ./common/m6502 ./common ./platform/opendingux
VPATH = $(SRCDIR)
SRC_C = $(foreach dir, $(SRCDIR), $(wildcard $(dir)/*.c))
SRC_CP = $(foreach dir, $(SRCDIR), $(wildcard $(dir)/*.cpp))
OBJ_C = $(notdir $(patsubst %.c, %.o, $(SRC_C)))
OBJ_C = $(notdir $(patsubst %.c, %.o, $(SRC_C)))
OBJ_CP = $(notdir $(patsubst %.cpp, %.o, $(SRC_CP)))
OBJS = $(OBJ_C) $(OBJ_CP)
# Rules to make executable
$(PRGNAME)$(EXESUFFIX): $(OBJS)
ifeq "$(OSTYPE)" "msys"
$(PRGNAME)$(EXESUFFIX): $(OBJS)
ifeq "$(OSTYPE)" "msys"
$(LD) $(CFLAGS) -o $(PRGNAME)$(EXESUFFIX) $^ $(LDFLAGS)
else
$(LD) $(LDFLAGS) -o $(PRGNAME)$(EXESUFFIX) $^

View File

@ -15,7 +15,7 @@ static uint16 rgb555(uint8 r, uint8 g, uint8 b)
static SV_MapRGBFunc mapRGB = rgb555;
const static uint8 palettes[SV_COLOR_SCHEME_COUNT][12] = {
static const uint8 palettes[SV_COLOR_SCHEME_COUNT][12] = {
{
252, 252, 252,
168, 168, 168,
@ -162,6 +162,9 @@ void gpu_set_ghosting(int frameCount)
if (screenBuffers[0] == NULL) {
for (i = 0; i < SB_MAX; i++) {
screenBuffers[i] = malloc(SV_H * SV_W / 4);
if (screenBuffers[i] == NULL) {
return;
}
}
}
for (i = 0; i < SB_MAX; i++) {
@ -191,30 +194,28 @@ static void add_ghosting(uint32 scanline, uint16 *backbuffer, uint8 innerx, uint
uint8 innerInd = (j & 3) * 2;
uint8 c = (b >> innerInd) & 3;
int pixInd = (x + lineCount * SV_W) / 4;
if (c == 0) {
if (c != 3) {
for (i = 0; i < ghostCount; i++) {
uint8 sbInd = (curSB + (SB_MAX - 1) - i) % SB_MAX;
innerInd = ((screenBufferInnerX[sbInd] + x) & 3) * 2;
c = (screenBuffers[sbInd][pixInd] >> innerInd) & 3;
if (c != 0) {
uint8 innerInd_ = ((screenBufferInnerX[sbInd] + x) & 3) * 2;
uint8 c_ = (screenBuffers[sbInd][pixInd] >> innerInd_) & 3;
if (c_ > c) {
#if 0
backbuffer[x] = palette[3 - 3 * i / ghostCount];
#else
uint8 r = palettes[paletteIndex][c * 3 + 0];
uint8 g = palettes[paletteIndex][c * 3 + 1];
uint8 b = palettes[paletteIndex][c * 3 + 2];
r = r + (palettes[paletteIndex][0] - r) * i / ghostCount;
g = g + (palettes[paletteIndex][1] - g) * i / ghostCount;
b = b + (palettes[paletteIndex][2] - b) * i / ghostCount;
uint8 r = palettes[paletteIndex][c_ * 3 + 0];
uint8 g = palettes[paletteIndex][c_ * 3 + 1];
uint8 b = palettes[paletteIndex][c_ * 3 + 2];
r = r + (palettes[paletteIndex][c * 3 + 0] - r) * i / ghostCount;
g = g + (palettes[paletteIndex][c * 3 + 1] - g) * i / ghostCount;
b = b + (palettes[paletteIndex][c * 3 + 2] - b) * i / ghostCount;
backbuffer[x] = mapRGB(r, g, b);
#endif
break;
}
}
}
else {
screenBuffers[curSB][pixInd] |= c << innerInd;
}
screenBuffers[curSB][pixInd] |= c << innerInd;
}
if (lineCount == SV_H - 1) {

View File

@ -11,6 +11,7 @@
/** Alex Krasivsky 1996 **/
/** Steve Nickolas 2002 **/
/** Portions by Holger Picker 2002 **/
/** ADC and SBC instructions provided by Scott Hemphill **/
/** You are not allowed to distribute this software **/
/** commercially. Please, notify me, if you make any **/
/** changes to this file. **/
@ -115,64 +116,43 @@
#define M_TRB(Data) R->P = (R->P & ~Z_FLAG) | ((Data & R->A) == 0 ? Z_FLAG : 0); \
Data &= ~R->A;
#ifdef NO_DECIMAL
#define M_ADC(Rg) \
K.W=R->A+Rg+(R->P&C_FLAG); \
R->P&=~(N_FLAG|V_FLAG|Z_FLAG|C_FLAG); \
R->P|=(~(R->A^Rg)&(R->A^K.B.l)&0x80? V_FLAG:0)| \
(K.B.h? C_FLAG:0)|ZNTable[K.B.l]; \
R->A=K.B.l
/* The following code was provided by Mr. Scott Hemphill. Thanks a lot! */
#define M_ADC(Rg) \
{ \
register unsigned int w; \
if ((R->A ^ Rg) & 0x80) { \
R->P &= ~V_FLAG; } \
else { \
R->P |= V_FLAG; } \
if (R->P&D_FLAG) { \
w = (R->A & 0xf) + (Rg & 0xf) + (R->P & C_FLAG); \
if (w >= 10) w = 0x10 | ((w+6)&0xf); \
w += (R->A & 0xf0) + (Rg & 0xf0); \
if (w >= 160) { \
R->P |= C_FLAG; \
if ((R->P&V_FLAG) && w >= 0x180) R->P &= ~ V_FLAG; \
w += 0x60; \
} else { \
R->P &= ~C_FLAG; \
if ((R->P&V_FLAG) && w < 0x80) R->P &= ~V_FLAG; \
} \
} else { \
w = R->A + Rg + (R->P&C_FLAG); \
if (w >= 0x100) { \
R->P |= C_FLAG; \
if ((R->P & V_FLAG) && w >= 0x180) R->P &= ~V_FLAG; \
} else { \
R->P &= ~C_FLAG; \
if ((R->P&V_FLAG) && w < 0x80) R->P &= ~V_FLAG; \
} \
} \
R->A = (unsigned char)w; \
R->P = (R->P & ~(Z_FLAG | N_FLAG)) | (R->A >= 0x80 ? N_FLAG : 0) | (R->A == 0 ? Z_FLAG : 0); \
}
/* Warning! C_FLAG is inverted before SBC and after it */
#define M_SBC(Rg) \
K.W=R->A-Rg-(~R->P&C_FLAG); \
R->P&=~(N_FLAG|V_FLAG|Z_FLAG|C_FLAG); \
R->P|=((R->A^Rg)&(R->A^K.B.l)&0x80? V_FLAG:0)| \
(K.B.h? 0:C_FLAG)|ZNTable[K.B.l]; \
R->A=K.B.l
#else /* NO_DECIMAL */
#define M_ADC(Rg) \
if(R->P&D_FLAG) \
{ \
K.B.l=(R->A&0x0F)+(Rg&0x0F)+(R->P&C_FLAG); \
if(K.B.l>9) K.B.l+=6; \
K.B.h=(R->A>>4)+(Rg>>4)+(K.B.l>15? 1:0); \
R->A=(K.B.l&0x0F)|(K.B.h<<4); \
R->P=(R->P&~C_FLAG)|(K.B.h>15? C_FLAG:0); \
} \
else \
{ \
K.W=R->A+Rg+(R->P&C_FLAG); \
R->P&=~(N_FLAG|V_FLAG|Z_FLAG|C_FLAG); \
R->P|=(~(R->A^Rg)&(R->A^K.B.l)&0x80? V_FLAG:0)| \
(K.B.h? C_FLAG:0)|ZNTable[K.B.l]; \
R->A=K.B.l; \
}
/* Warning! C_FLAG is inverted before SBC and after it */
#define M_SBC(Rg) \
if(R->P&D_FLAG) \
{ \
K.B.l=(R->A&0x0F)-(Rg&0x0F)-(~R->P&C_FLAG); \
if(K.B.l&0x10) K.B.l-=6; \
K.B.h=(R->A>>4)-(Rg>>4)-((K.B.l&0x10)>>4); \
if(K.B.h&0x10) K.B.h-=6; \
R->A=(K.B.l&0x0F)|(K.B.h<<4); \
R->P=(R->P&~C_FLAG)|(K.B.h>15? 0:C_FLAG); \
} \
else \
{ \
K.W=R->A-Rg-(~R->P&C_FLAG); \
R->P&=~(N_FLAG|V_FLAG|Z_FLAG|C_FLAG); \
R->P|=((R->A^Rg)&(R->A^K.B.l)&0x80? V_FLAG:0)| \
(K.B.h? 0:C_FLAG)|ZNTable[K.B.l]; \
R->A=K.B.l; \
}
#endif /* NO_DECIMAL */
#define M_SBC(Rg) SBCInstruction(R, Rg)
#define M_CMP(Rg1,Rg2) \
@ -198,6 +178,55 @@
R->P&=~C_FLAG;R->P|=Rg&C_FLAG;Rg=K.B.l; \
M_FL(Rg)
/* The following code was provided by Mr. Scott Hemphill. Thanks a lot again! */
static void SBCInstruction(M6502 *R, register unsigned char val) {
register unsigned int w;
register unsigned int temp;
if ((R->A ^ val) & 0x80) {
R->P |= V_FLAG;
}
else {
R->P &= ~V_FLAG;
}
if (R->P&D_FLAG) { /* decimal subtraction */
temp = 0xf + (R->A & 0xf) - (val & 0xf) + (R->P & C_FLAG);
if (temp < 0x10) {
w = 0;
temp -= 6;
}
else {
w = 0x10;
temp -= 0x10;
}
w += 0xf0 + (R->A & 0xf0) - (val & 0xf0);
if (w < 0x100) {
R->P &= ~C_FLAG;
if ((R->P&V_FLAG) && w < 0x80) R->P &= ~V_FLAG;
w -= 0x60;
}
else {
R->P |= C_FLAG;
if ((R->P&V_FLAG) && w >= 0x180) R->P &= ~V_FLAG;
}
w += temp;
}
else { /* standard binary subtraction */
w = 0xff + R->A - val + (R->P&C_FLAG);
if (w < 0x100) {
R->P &= ~C_FLAG;
if ((R->P & V_FLAG) && w < 0x80) R->P &= ~V_FLAG;
}
else {
R->P |= C_FLAG;
if ((R->P&V_FLAG) && w >= 0x180) R->P &= ~V_FLAG;
}
}
R->A = (unsigned char)w;
R->P = (R->P & ~(Z_FLAG | N_FLAG)) | (R->A >= 0x80 ? N_FLAG : 0) | (R->A == 0 ? Z_FLAG : 0);
} /* SBCinstruction */
/** Reset6502() **********************************************/
/** This function can be used to reset the registers before **/
/** starting execution with Run6502(). It sets registers to **/

View File

@ -19,6 +19,7 @@ static uint32 programRomSize;
static BOOL dma_finished = FALSE;
static BOOL timer_shot = FALSE;
static BOOL isMAGNUM = FALSE;
static void check_irq(void)
{
@ -60,7 +61,7 @@ void memorymap_reset(void)
// 96KB -> 80KB
// 112KB -> 96KB
// 128KB -> 112KB (max in theory)
// 512KB -- 'Journey to the West' isn't supported
// 512KB -- 'Journey to the West' is supported! (MAGNUM cartridge)
upperRomBank = programRom + (programRomSize - 0x4000);
memset(lowerRam, 0x00, 0x2000);
@ -110,73 +111,82 @@ uint8 memorymap_registers_read(uint32 Addr)
return data;
}
// General Purpose DMA
// General Purpose DMA (for 'Journey to the West')
// Pass only the first test (WaTest.bin from Wataroo)
//typedef struct {
// uint16 caddr;
// uint16 vaddr;
// BOOL cpu2vram;
// uint16 length;
//} GENERIC_DMA;
//static GENERIC_DMA dma;
//
//static void dma_write(uint32 Addr, uint8 Value)
//{
// switch (Addr & 0x1fff) {
// case 0x08:
// dma.caddr = Value;
// printf("CBUS LO (%x)\n", Value);
// break;
// case 0x09:
// dma.caddr |= (Value << 8);
// printf("CBUS HI %x (%x)\n", dma.caddr, Value);
// break;
// case 0x0a:
// dma.vaddr = Value;
// printf("VBUS LO (%x)\n", Value);
// break;
// case 0x0b:
// dma.vaddr |= (Value << 8);
// dma.vaddr &= 0x1fff;
// dma.cpu2vram = ((Value >> 6) & 1) == 1;
// printf("VBUS HI %x %x (%x)\n", dma.vaddr, dma.cpu2vram, Value);
// break;
// case 0x0c:
// dma.length = Value ? Value * 16 : 4096;
// printf("LEN %x\n", dma.length);
// break;
// case 0x0d:
// printf("Request %x\n", Value);
// if (Value & 0x80) {
// int i;
// printf("Transfer\n");
// for (i = 0; i < dma.length; i++) {
// if (dma.cpu2vram) {
// upperRam[dma.vaddr + i] = Rd6502(dma.caddr + i);
// }
// else {
// Wr6502(dma.caddr + i, upperRam[dma.vaddr + i]);
// }
// }
// }
// else if ((Value & 0x80) == 0) {
//
// }
// break;
// }
//}
typedef struct {
uint16 caddr;
uint16 vaddr;
BOOL cpu2vram;
uint16 length;
} GENERIC_DMA;
static GENERIC_DMA dma;
static void dma_write(uint32 Addr, uint8 Value)
{
switch (Addr & 0x1fff) {
case 0x08: // CBUS LO
dma.caddr = Value;
break;
case 0x09: // CBUS HI
dma.caddr |= (Value << 8);
break;
case 0x0a: // VBUS LO
dma.vaddr = Value;
break;
case 0x0b: // VBUS HI
dma.vaddr |= (Value << 8);
dma.vaddr &= 0x1fff;
dma.cpu2vram = ((Value >> 6) & 1) == 1;
break;
case 0x0c: // LEN
dma.length = Value ? Value * 16 : 4096;
break;
case 0x0d: // Request
if (Value & 0x80) {
int i;
for (i = 0; i < dma.length; i++) {
if (dma.cpu2vram) {
upperRam[dma.vaddr + i] = Rd6502(dma.caddr + i);
}
else {
Wr6502(dma.caddr + i, upperRam[dma.vaddr + i]);
}
}
}
break;
}
}
static void update_lowerRomBank(void)
{
uint32 bankOffset = 0;
if (isMAGNUM) {
bankOffset = (((regs[BANK] & 0x20) << 9) | ((regs[0x21] & 0xf) << 15));
}
else {
bankOffset = ((regs[BANK] & 0xe0) << 9);
}
lowerRomBank = programRom + bankOffset % programRomSize;
}
void memorymap_registers_write(uint32 Addr, uint8 Value)
{
regs[Addr & 0x1fff] = Value;
switch (Addr & 0x1fff) {
case 0x21:
// MAGNUM cartridge && Output (Link Port Data Direction)
if (isMAGNUM && regs[0x22] == 0) {
update_lowerRomBank();
check_irq();
}
break;
case 0x23:
timer_write(Value);
break;
case 0x26:
lowerRomBank = programRom + ((Value & 0xe0) << 9) % programRomSize;
update_lowerRomBank();
check_irq();
return;
break;
case 0x10: case 0x11: case 0x12: case 0x13:
case 0x14: case 0x15: case 0x16: case 0x17:
sound_wave_write(((Addr & 0x4) >> 2), Addr & 3, Value);
@ -193,9 +203,9 @@ void memorymap_registers_write(uint32 Addr, uint8 Value)
case 0x2a:
sound_noise_write(Addr & 0x07, Value);
break;
//case 0x08: case 0x09: case 0x0a: case 0x0b: case 0x0c: case 0x0d:
// dma_write(Addr, Value);
// break;
case 0x08: case 0x09: case 0x0a: case 0x0b: case 0x0c: case 0x0d:
dma_write(Addr, Value);
break;
}
}
@ -255,6 +265,7 @@ BOOL memorymap_load(const uint8 *rom, uint32 size)
}
programRomSize = size;
programRom = rom;
isMAGNUM = size > 131072;
return TRUE;
}

View File

@ -109,7 +109,7 @@ void sound_stream_update(uint8 *stream, uint32 len)
if (m_noise.right)
*right += s;
m_noise.pos += m_noise.step;
if (m_noise.pos >= 1.0) {
while (m_noise.pos >= 1.0) { // if/while difference - Pacific Battle
// LFSR: x^2 + x + 1
uint16 feedback;
m_noise.value = m_noise.state & 1;
@ -169,6 +169,16 @@ void sound_wave_write(int which, int offset, uint8 data)
// if size == 0 then channel->size == 0
channel->size = (uint16)((real)SV_SAMPLE_RATE * ((size + 1) << 5) / UNSCALED_CLOCK);
channel->pos = 0;
#ifndef SV_DISABLE_SUPER_DUPER_WAVE
// Popo Team
if (channel->count != 0 || ch[which].size == 0 || channel->size == 0) {
ch[which].size = channel->size;
if (channel->count == 0)
ch[which].pos = 0;
}
#else
memcpy(&ch[which], channel, sizeof(ch[which]));
#endif
}
break;
case 2:
@ -177,7 +187,10 @@ void sound_wave_write(int which, int offset, uint8 data)
channel->volume = data & 0x0f;
#ifndef SV_DISABLE_SUPER_DUPER_WAVE
if (!channel->on || ch[which].size == 0 || channel->size == 0) {
uint16 pos = ch[which].pos;
memcpy(&ch[which], channel, sizeof(ch[which]));
if (channel->count != 0) // Journey to the West
ch[which].pos = pos;
}
#else
memcpy(&ch[which], channel, sizeof(ch[which]));
@ -185,6 +198,9 @@ void sound_wave_write(int which, int offset, uint8 data)
break;
case 3:
channel->count = data + 1;
#ifndef SV_DISABLE_SUPER_DUPER_WAVE
ch[which].size = channel->size; // Sonny Xpress!
#endif
break;
}
}

View File

@ -11,7 +11,7 @@
extern "C" {
#endif
#define SV_CORE_VERSION 0x01000003U
#define SV_CORE_VERSION 0x01000004U
#define SV_CORE_VERSION_MAJOR ((SV_CORE_VERSION >> 24) & 0xFF)
#define SV_CORE_VERSION_MINOR ((SV_CORE_VERSION >> 12) & 0xFFF)
#define SV_CORE_VERSION_PATCH ((SV_CORE_VERSION >> 0) & 0xFFF)

View File

@ -91,6 +91,8 @@ void supervision_exec_ex(uint16 *backbuffer, int16 backbufferWidth)
scan = regs[XPOS] / 4 + regs[YPOS] * 0x30;
innerx = regs[XPOS] & 3;
size = regs[XSIZE]; // regs[XSIZE] <= SV_W
if (size > SV_W)
size = SV_W; // 192: Chimera, Matta Blatta, Tennis Pro '92
for (i = 0; i < SV_H; i++) {
if (scan >= 0x1fe0)

5683
platform/GP2X/lib/minimal.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,13 @@
/* GP2X minimal library v0.C
Written by rlyeh, (c) 2005-2006.
Written by rlyeh, (c) 2005-2007.
Please check readme for licensing and other conditions. */
#ifndef __MINIMAL_H__
#define __MINIMAL_H__
#include <limits.h>
#include <dirent.h>
#include <math.h>
#include <fcntl.h>
#include <pthread.h>
@ -25,7 +27,7 @@
#include <linux/joystick.h>
#define MINILIB_VERSION "GP2X minimal library (internal beta v0.C) by rlyeh, (c) 2005-2006."
#define MINILIB_VERSION "GP2X minimal library v0.C by rlyeh, (c) 2005-2007."
#ifndef GP2X_DEBUG_LEVEL
@ -38,9 +40,9 @@
#define GP2X_PROFILE 1
#endif
#define gp2x_debug(level, func) if(GP2X_DEBUG_LEVEL & level) { func }
#define gp2x_debug(level, ...) if(GP2X_DEBUG_LEVEL & level) { __VA_ARGS__ ;}
#define gp2x_profile(func) \
#define gp2x_profile( ... ) \
if(GP2X_PROFILE) { \
static gp2x_profiles *prf = NULL; \
\
@ -50,16 +52,22 @@
\
prf->calls++; \
prf->time -= gp2x_memregl[0x0A00>>2]; \
{ func ;} \
prf->time += gp2x_memregl[0x0A00>>2]; } else { func ;}
{ __VA_ARGS__ ;} \
prf->time += gp2x_memregl[0x0A00>>2]; } else { __VA_ARGS__ ;}
#define isUp(x)
#define isDown(x)
#define isPress(x)
enum { RECT_RGB8=1, RECT_RGB16=2, RECT_YUV=4 };
enum { GP2X_UP=(0x1L<<0), GP2X_LEFT=(0x1L<<2), GP2X_DOWN=(0x1L<<4), GP2X_RIGHT=(0x1L<<6),
GP2X_START=(1L<<8), GP2X_SELECT=(1L<<9), GP2X_L=(1L<<10), GP2X_R=(1L<<11),
GP2X_A=(1L<<12), GP2X_B=(1L<<13), GP2X_X=(1L<<14), GP2X_Y=(1L<<15),
GP2X_VOL_UP=(1L<<23), GP2X_VOL_DOWN=(1L<<22), GP2X_PUSH=(1L<<27) };
GP2X_VOL_UP=(1L<<23), GP2X_VOL_DOWN=(1L<<22), GP2X_PUSH=(1L<<27),
GP2X_HOME=(1L<<8), GP2X_TOUCH=(1L<<28) };
enum { LCD = 0, PAL = 4, NTSC = 3 };
typedef struct gp2x_font { int x,y,w,wmask,h,fg,bg,solid; unsigned char *data; } gp2x_font;
typedef struct gp2x_queue { volatile unsigned long head, tail, items, max_items; unsigned long *place920t, *place940t; } gp2x_queue;
@ -77,7 +85,8 @@ typedef struct gp2x_profiles { char fname[56]; unsigned long calls, time; } g
extern gp2x_video_layer gp2x_video_RGB[1], gp2x_video_YUV[4];
extern volatile unsigned long *gp2x_dualcore_ram, *gp2x_memregl, *gp2x_blitter;
extern unsigned long gp2x_usbjoys;
extern volatile unsigned short *gp2x_memregs;
extern unsigned long gp2x_usbjoys, gp2x_f200;
extern gp2x_font gp2x_default_font;
//extern gp2x_profiles *gp2x_profiles;
@ -116,16 +125,20 @@ extern char *gp2x_joystick_name(int);
extern void gp2x_joystick_wait(int, unsigned long);
extern void gp2x_joystick_scan(void);
extern unsigned long gp2x_timer_read(void);
extern void gp2x_touchscreen_update(void);
/*writeme : raw -> timer, timer -> counter ? */
extern void gp2x_timer_reset(void);
extern void gp2x_timer_delay(unsigned long);
extern unsigned long gp2x_timer_raw(void);
extern unsigned long gp2x_timer_read_raw(void);
extern unsigned long gp2x_timer_read(void);
extern unsigned long gp2x_timer_raw_to_ticks(unsigned long);
extern unsigned long gp2x_timer_raw_one_second(void);
extern void gp2x_timer_init(int);
extern void gp2x_timer_start(int);
extern void gp2x_timer_stop(int);
extern unsigned long gp2x_timer_cpu_usage_relative(int, int);
extern unsigned long gp2x_timer_cpu_usage_per_frame(int);
extern void gp2x_counter_init(int);
extern void gp2x_counter_start(int);
extern unsigned long long gp2x_counter_read(int);
extern void gp2x_counter_pause(int);
extern gp2x_profiles *gp2x_profile_register(void);
extern char *gp2x_profile_analyze(void);
@ -139,7 +152,7 @@ extern void gp2x_sound_pause(int);
extern void gp2x_sound_stereo(int);
extern void gp2x_sound_3Dboost(int);
extern void gp2x_sound_attenuation(int);
extern void gp2x_sound_setintensity(int, int);
extern void gp2x_sound_setintensity(int, int, int);
extern void gp2x_i2c_write(unsigned char, unsigned char, unsigned char);
extern unsigned char gp2x_i2c_read(unsigned char, unsigned char);
@ -171,9 +184,6 @@ extern void gp2x_deinit(void);
extern void gp2x_reboot(void);
/* for our minimal kernel module */
#define MINIMAL_I2C_WRITE 0x0
#define MINIMAL_I2C_READ 0x1
@ -228,7 +238,65 @@ extern void gp2x_reboot(void);
//for blitter usage
#define BLITTER_DST_BPP(r,a) gp2x_blitter[0x00 >> 2] = ((r)<<6)|((a)<<5) //r=1 reads dest then ROP // a=0,1 (8,16 bpp)
#define BLITTER_DST_PTR(a) gp2x_blitter[0x04 >> 2] = (unsigned int)(a) //manejar puntero de la forma &kk[offset]
#define BLITTER_DST_BPL(a) gp2x_blitter[0x08 >> 2] = (a) //bytes per line (320, 640, 1280...)
#define BLITTER_SRC_BPP(r,a) gp2x_blitter[0x0C >> 2] = ((r)<<7)|((a)<<5) //r=1 reads src after ROP // a=0,1 (8,16 bpp)
#define BLITTER_SRC_PTR(a) gp2x_blitter[0x10 >> 2] = (unsigned int)(a) //manejar puntero de la forma &kk[offset]
#define BLITTER_SRC_BPL(a) gp2x_blitter[0x14 >> 2] = (a) //bytes per line (320, 640, 1280...)
#define BLITTER_DIM(w,h) gp2x_blitter[0x2c >> 2] = ((h)<<16) | (w)
#define NO_MIRROR 0
#define MIRROR_W 1
#define MIRROR_H 2
#define ROP_P (0xF0) /*PATERN*/
#define ROP_S (0xCC) /*SOURCE*/
#define ROP_D (0xAA) /*DESTINATION*/
#define ROP_0 (0x00) /*FALSE*/
#define ROP_1 (0xFF) /*TRUE*/
#define BLITTER_ROP(transp_color,transp_on,fifoclear,ydirxdir,rop) gp2x_blitter[0x30 >> 2] = (((transp_color)<<16)|((transp_on)<<11)|((fifoclear)<<10)|((ydirxdir)<<8)|((rop)<<0))
#define BLITTER_GO() gp2x_blitter[0x34 >> 2] = 1
#define BLITTER_FG(fg) gp2x_blitter[0x18 >> 2] = fg
#define BLITTER_BG(bg) gp2x_blitter[0x1c >> 2] = bg
#define BLITTER_PATTERN_FG_COLOR(fg565) gp2x_blitter[0x24 >> 2] = fg565
#define BLITTER_PATTERN_BG_COLOR(bg565) gp2x_blitter[0x28 >> 2] = bg565
#define BLITTER_PATTERN(mono, on, bpp, offset) gp2x_blitter[0x20 >> 2] = (((mono)<<6)|((on)<<5)|((bpp)<<3)|((offset)<<0))
#define BLITTER_PATTERN_SET(x) gp2x_blitter[0x80 >> 2] = x
#if 0
examples
for a custom ROP to do destination = (source & ~destination ) ^ ~pattern;
I'd use this: #define MYROP ((ROP_S & ~ROP_D ) ^ ~ROP_P)
more examples using this:
PATCOPY : D = P
PATINVERT : D = P ^ D
DSTINVERT : D = ~D
SRCCOPY : D = S
NOTSRCCOPY : D = ~S
SRCINVERT : D = S ^ D
SRCAND : D = S & D
SRCPAINT : D = S | D
SRCERASE : D = S & ~D
NOTSRCERASE : D = ~S & ~D
MERGEPAINT : D = ~S | D
MERGECOPY : D = S & P
PATPAINT : D = D | P | ~S
#endif
//for our dualcore solution
#define GP2X_QUEUE_MAX_ITEMS ((4096 - sizeof(gp2x_queue)) / 4)
#define GP2X_QUEUE_STRUCT_PTR (0 + 0x1000)
@ -245,6 +313,7 @@ extern void gp2x_reboot(void);
#define gp2x_1stcore_data_ptr(v) gp2x_1stcore_code_ptr((v)+0x1ff6000)
#define gp2x_dualcore_data(v) gp2x_1stcore_data((v)<<2)
#define gp2x_dualcore_data_ptr(v) gp2x_1stcore_data_ptr((v)<<2)
#define gp2x_dualcore_declare_subprogram(name) extern void gp2x_dualcore_launch_## name ##_subprogram(void);
#define gp2x_dualcore_launch_subprogram(name) gp2x_dualcore_launch_## name ##_subprogram()
@ -257,6 +326,9 @@ extern void gp2x_reboot(void);
#undef gp2x_dualcore_data
#define gp2x_dualcore_data(v) gp2x_2ndcore_data((v)<<2)
#undef gp2x_dualcore_data_ptr
#define gp2x_dualcore_data_ptr(v) gp2x_2ndcore_data_ptr((v)<<2)
#define main gp2x_2ndcore_run
static void gp2x_2ndcore_start(void) __attribute__((naked));

Binary file not shown.

View File

@ -10,6 +10,7 @@
#include "supervision.h"
#include "minimal.h"
#include "menues.h"
BOOL paused = FALSE;
@ -27,6 +28,11 @@ const char *romname;
currentConfig_t currentConfig;
uint16 mapRGB(uint8 r, uint8 g, uint8 b)
{
return gp2x_video_RGB_color16(r, g, b);
}
int LoadROM(const char *filename)
{
if (buffer != NULL) {
@ -115,11 +121,6 @@ void CheckKeys(void)
}
}
uint16 mapRGB(uint8 r, uint8 g, uint8 b)
{
return gp2x_video_RGB_color16(r, g, b);
}
int main(int argc, char *argv[])
{
gp2x_init(1000, 16, 11025, 16, 1, 60, 1);
@ -166,11 +167,16 @@ int main(int argc, char *argv[])
CheckKeys(); //key control
switch(currentConfig.videoMode){
case 0:
case 0: {
int j;
supervision_exec(screenbuffer);
for (j = 0; j < 160; j++)
gp2x_memcpy(screen16+(80+(j+40)*320), screenbuffer+(j * 160), 160*2);
for (j = 0; j < 160; j++)
gp2x_memcpy(screen16+(80+(j+40)*320), screenbuffer+(j * 160), 160*2);
}
break;
case 1:
case 2:
supervision_exec(screen16);
break;
default:
break;

View File

@ -21,7 +21,7 @@ FileEntry FileList[1024];
uint32 fileCounter;
extern uint8* buffer;
extern unsigned int buffer_size;
extern unsigned int bufferSize;
extern void LoadROM(char* filename);
extern uint16 mapRGB(uint8 r, uint8 g, uint8 b);
@ -269,7 +269,7 @@ void handleFileMenu(void)
RESIZE();
LoadROM(FileList[curFile + virtualFile].fName);
textClear();
supervision_load(buffer, (uint32)buffer_size);
supervision_load(buffer, (uint32)bufferSize);
supervision_set_map_func(mapRGB);
textClear();
return;
@ -356,8 +356,8 @@ void handleOptionsMenu(void)
if(pad & GP2X_RIGHT) {
if(menuOption == OPTION_VIDEOMODE) if(videomode < 2) currentConfig.videoMode++;
if(menuOption == OPTION_SHOWFPS) if(currentConfig.show_fps==0) currentConfig.show_fps=1; else currentConfig.show_fps=0;
if(menuOption == OPTION_ENABLESOUND) if(currentConfig.enable_sound==0) currentConfig.enable_sound=1; else currentConfig.enable_sound=0;
if(menuOption == OPTION_SHOWFPS) currentConfig.show_fps^=1;
if(menuOption == OPTION_ENABLESOUND) currentConfig.enable_sound^=1;
if(menuOption == OPTION_SOUNDRATE) currentConfig.SoundRate*=2;
if(menuOption == OPTION_FRAMESKIP) if (frameskip < 9) frameskip++;
if(menuOption == OPTION_CPUCLOCK) if(clock < sizeof(clocklist)) clock++;
@ -366,8 +366,8 @@ void handleOptionsMenu(void)
if(pad & GP2X_LEFT) {
if(menuOption == OPTION_VIDEOMODE) if(videomode > 0) currentConfig.videoMode--;
if(menuOption == OPTION_SHOWFPS) if(currentConfig.show_fps==0) currentConfig.show_fps=1; else currentConfig.show_fps=0;
if(menuOption == OPTION_ENABLESOUND) if(currentConfig.enable_sound==0) currentConfig.enable_sound=1; else currentConfig.enable_sound=0;
if(menuOption == OPTION_SHOWFPS) currentConfig.show_fps^=1;
if(menuOption == OPTION_ENABLESOUND) currentConfig.enable_sound^=1;
if(menuOption == OPTION_SOUNDRATE) currentConfig.SoundRate/=2;
if(menuOption == OPTION_FRAMESKIP) if (frameskip > 0) frameskip--;
if(menuOption == OPTION_CPUCLOCK) if(clock > 0) clock--;

View File

@ -55,7 +55,7 @@ typedef struct
extern FileEntry FileList[1024];
extern uint32 fileCounter;
extern char *romname;
extern const char *romname;
typedef struct {
char lastRomDir[MAXPATHLEN];

View File

@ -21,7 +21,7 @@
#include "../../common/supervision.h"
#define VERSION "1.0.2"
#define VERSION "1.0.3"
PSP_MODULE_INFO("Potator", PSP_MODULE_USER, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);
@ -38,8 +38,7 @@ PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);
static unsigned int __attribute__((aligned(16))) list[262144];
static uint32_t __attribute__((aligned(16))) pixels[BUF_WIDTH * SCR_HEIGHT];
uint16_t screenBuffer[SV_W * SV_H];
static uint32_t __attribute__((aligned(16))) pixelsPreview[BUF_WIDTH * SCR_HEIGHT];
uint8_t* romBuffer = NULL;
uint32_t romBufferSize = 0;
@ -101,7 +100,7 @@ void AudioStreamCallback(void* buf, unsigned int length, void* userdata)
uint8_t* src = (uint8_t*)buf;
int i;
for (i = length - 1; i >= 0; i--) {
dst[i] = src[i] << 8;
dst[i] = src[i] << (8 + 1);
}
}
@ -574,8 +573,8 @@ FUNC_ACTION Menu_main(int stage, MenuFunc* next, SceCtrlData newPad)
count = 0;
areYouSure = FALSE;
// Game screen preview
uint32_t* pDest = (uint32_t*)pixels; // GU_PSM_8888
uint16_t* pSrc = screenBuffer;
uint32_t* pDest = pixelsPreview; // GU_PSM_8888
uint16_t* pSrc = (uint16_t*)pixels;
int y, x;
for (y = 0; y < SV_H; y++) {
for (x = 0; x < SV_W; x++) {
@ -584,10 +583,11 @@ FUNC_ACTION Menu_main(int stage, MenuFunc* next, SceCtrlData newPad)
pSrc++;
}
pDest += (TEX_WIDTH - SV_W);
pSrc += (TEX_WIDTH - SV_W);
}
}
else {
sceGuCopyImage(PIX_FORMAT, 0, 0, SV_W, SV_H, TEX_WIDTH, pixels,
sceGuCopyImage(PIX_FORMAT, 0, 0, SV_W, SV_H, TEX_WIDTH, pixelsPreview,
SCR_WIDTH - SV_W, SCR_HEIGHT - SV_H, BUF_WIDTH, (void*)(((unsigned int)fbpc) + 0x4000000));
intraFontPrint(ltn[0], MENU_PADDING_LEFT + 0, MENU_PADDING_TOP, "Main Menu");
@ -936,7 +936,7 @@ void Blit(int dx, int dy, int dw, int dh)
struct VertexF* vertices;
float start, end, slsz_scaled;
slsz_scaled = ceil((float)(dw + 1) * SLICE_SIZE / Viewport_Width);
slsz_scaled = ceil((float)dw * SLICE_SIZE / Viewport_Width);
for (start = Viewport_X, end = Viewport_X + Viewport_Width; start < end; start += SLICE_SIZE, dx += slsz_scaled) {
vertices = (struct VertexF*)sceGuGetMemory(2 * sizeof(struct VertexF));

View File

@ -14,7 +14,7 @@
#include "../../common/supervision.h"
#define VERSION "1.0.2"
#define VERSION "1.0.3"
#define OR_DIE(cond) \
if (cond) { \
@ -182,15 +182,20 @@ int LoadROM(const char *filename)
return 0;
}
void ReturnToDropROM(void)
{
SDL_memset(screenBuffer, 0, sizeof(screenBuffer));
while (GetMenuState() != MENUSTATE_NONE) {
PopMenuState();
}
PushMenuState(MENUSTATE_DROP_ROM);
SDL_PauseAudio(1);
}
void LoadBuffer(void)
{
if (!supervision_load(romBuffer, romBufferSize)) {
SDL_memset(screenBuffer, 0, sizeof(screenBuffer));
while (GetMenuState() != MENUSTATE_NONE) {
PopMenuState();
}
PushMenuState(MENUSTATE_DROP_ROM);
SDL_PauseAudio(1);
ReturnToDropROM();
return;
}
MenuState prevState = GetMenuState();
@ -332,6 +337,9 @@ void PollEvents(void)
if (LoadROM(event.drop.file) == 0) {
LoadBuffer();
}
else {
ReturnToDropROM();
}
#ifdef __ANDROID__
// External SD Card isn't writable
strncpy(romPath, SDL_AndroidGetExternalStoragePath(), sizeof(romPath));
@ -361,11 +369,13 @@ void Loop(void)
case MENUSTATE_EMULATION:
HandleInput();
supervision_exec(screenBuffer);
break;
break;
case MENUSTATE_DROP_ROM:
DrawDropROM();
break;
case MENUSTATE_PAUSE:
SDL_Delay(16); // Reduce CPU usage
break;
case MENUSTATE_SET_KEY:
break;
default:
@ -597,6 +607,9 @@ void UploadROM(void *newBuffer, int newBufferSize, const char *fileName)
romBuffer = NULL;
}
romBuffer = (uint8_t *)malloc(romBufferSize);
if (romBuffer == NULL) {
return;
}
memcpy(romBuffer, newBuffer, romBufferSize);
SetRomName(fileName);

View File

@ -34,6 +34,7 @@ volatile BOOL finished = FALSE;
volatile BOOL execute = FALSE;
LPCTSTR szClassName = _T("Potator (WinAPI)");
LPCTSTR VERSION = _T("1.0.1");
#define WINDOW_STYLE (WS_SYSMENU | WS_MINIMIZEBOX | WS_CAPTION | WS_VISIBLE)
#define WINDOW_EX_STYLE (WS_EX_CLIENTEDGE)
@ -145,7 +146,7 @@ DWORD WINAPI run(LPVOID lpParameter)
INT16* dst = (INT16*)audioBuffer;
UINT8* src = (UINT8*)audioBuffer;
for (int i = BUFFER_SIZE / 2 - 1; i >= 0; i--) {
dst[i] = src[i] << 8;
dst[i] = src[i] << (8 + 1);
}
waveOutPrepareHeader(hWaveOut, &whdr, sizeof(whdr));
waveOutWrite(hWaveOut, &whdr, sizeof(whdr));
@ -404,10 +405,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
break;
case IDM_ABOUT:
{
TCHAR title[64] = { 0 };
_sntprintf_s(title, _countof(title), _TRUNCATE, _T("Potator (WinAPI) %u.%u.%u (core: %u.%u.%u)"),
1, 0, 0, SV_CORE_VERSION_MAJOR, SV_CORE_VERSION_MINOR, SV_CORE_VERSION_PATCH);
MessageBox(NULL, title, szClassName, MB_ICONEXCLAMATION | MB_OK);
TCHAR text[64] = { 0 };
_sntprintf_s(text, _countof(text), _TRUNCATE, _T("%s %s (core: %u.%u.%u)"),
szClassName, VERSION, SV_CORE_VERSION_MAJOR, SV_CORE_VERSION_MINOR, SV_CORE_VERSION_PATCH);
MessageBox(NULL, text, _T("About"), MB_ICONEXCLAMATION | MB_OK);
}
break;
case IDM_FULLSCREEN:

View File

@ -563,7 +563,8 @@
<table><tbody id="savestates"></tbody></table>
<h2>Information</h2>
Source code: <a href="https://github.com/infval/potator">GitHub</a>.
<p>Chrome <a href="https://blog.google/products/chrome/improving-autoplay-chrome/">blocks audio autoplay</a>. Click on game view (canvas) or press any key.</p>
<p>Source code: <a href="https://github.com/infval/potator">GitHub</a>.</p>
</div>
<div class="emscripten" id="status" style="position: fixed; top: 0px; background-color: #eee; padding: 8px;">Downloading...</div>
<div class="emscripten"><progress value="0" max="100" id="progress" style="display: none;"></progress></div>
@ -762,17 +763,52 @@
pauseAudio(0);
}, false);
// FIX (Chrome, ...?), project.js -> ASM_CONSTS, https://github.com/emscripten-ports/SDL2/blob/master/src/audio/emscripten/SDL_emscriptenaudio.c
// FIX (Chrome, ...?), project.js -> ASM_CONSTS,
// https://github.com/emscripten-ports/SDL2/blob/master/src/audio/emscripten/SDL_emscriptenaudio.c
function pauseAudio(on) {
if (typeof SDL2 === 'undefined') return;
if (typeof Module === 'undefined') return;
let moduleSDL2 = Module.SDL2;
if (typeof moduleSDL2 === 'undefined' && typeof SDL2 !== 'undefined')
moduleSDL2 = SDL2; // Old emscripten
else
return;
//if (typeof Module === 'undefined'
// || typeof Module.SDL2 === 'undefined'
// || typeof Module.SDL2.audio === 'undefined'
// || typeof Module.SDL2.audioContext === 'undefined')
// return;
if (on) {
SDL2.audio.scriptProcessorNode.disconnect();
moduleSDL2.audio.scriptProcessorNode.disconnect();
}
else {
SDL2.audio.scriptProcessorNode['connect'](SDL2.audioContext['destination']);
moduleSDL2.audio.scriptProcessorNode['connect'](moduleSDL2.audioContext['destination']);
}
}
// Work-around chromium autoplay policy
// https://github.com/emscripten-core/emscripten/issues/6511
function resumeAudio(e) {
if (typeof Module === 'undefined') return;
let moduleSDL2 = Module.SDL2;
if (typeof moduleSDL2 === 'undefined' && typeof SDL2 !== 'undefined')
moduleSDL2 = SDL2; // Old emscripten
else
return;
//if (typeof Module === 'undefined'
// || typeof Module.SDL2 === 'undefined'
// || typeof Module.SDL2.audioContext === 'undefined')
// return;
if (moduleSDL2.audioContext.state == 'suspended') {
moduleSDL2.audioContext.resume();
}
if (moduleSDL2.audioContext.state == 'running') {
document.getElementById('canvas').removeEventListener('click', resumeAudio);
document.removeEventListener('keydown', resumeAudio);
}
}
document.getElementById('canvas').addEventListener('click', resumeAudio);
document.addEventListener('keydown', resumeAudio);
function refreshSavestates() {
var fileNames = FS.readdir(".").filter((e) => e.search(/\.svst$/) != -1);
var ss = document.getElementById("savestates");

View File

@ -62,8 +62,7 @@ void graphics_paint(void) {
unsigned short *buffer_mem=(buffer_flip+((y>>16)*SYSVID_WIDTH));
W=320; x=0;
do {
unsigned short value = (((buffer_mem[x>>16]) & 0x7FE0) << 1) | ((buffer_mem[x>>16]) & 0x001F);
*buffer_scr++=value;
*buffer_scr++=buffer_mem[x>>16];
x+=ix;
} while (--W);
y+=iy;
@ -85,8 +84,7 @@ void graphics_paint(void) {
unsigned short *buffer_mem=(buffer_flip+((y>>16)*SYSVID_WIDTH));
W=SYSVID_WIDTH; x=((actualScreen->w - SYSVID_WIDTH)/2);
do {
unsigned short value = (((buffer_mem[x>>16]) & 0x7FE0) << 1) | ((buffer_mem[x>>16]) & 0x001F);
*buffer_scr++=value;
*buffer_scr++=buffer_mem[x>>16];
x+=ix;
} while (--W);
y+=iy;
@ -147,9 +145,6 @@ void initSDL(void) {
SDL_InitSubSystem(SDL_INIT_JOYSTICK);
SDL_JoystickEventState(SDL_ENABLE);
stick = SDL_JoystickOpen(0);
// Init sound
Ainit();
}
uint16 mapRGB(uint8 r, uint8 g, uint8 b) {
@ -171,6 +166,12 @@ unsigned char potatorLoadROM(char* filename) {
supervision_load(rom_buffer, rom_size);
supervision_set_map_func(mapRGB);
switch (GameConf.m_Color) {
case 0: supervision_set_color_scheme(SV_COLOR_SCHEME_DEFAULT); break;
case 1: supervision_set_color_scheme(SV_COLOR_SCHEME_AMBER); break;
case 2: supervision_set_color_scheme(SV_COLOR_SCHEME_GREEN); break;
case 3: supervision_set_color_scheme(SV_COLOR_SCHEME_BLUE); break;
}
// Compute game CRC
gameCRC = crc32(0, rom_buffer, rom_size);
@ -182,7 +183,6 @@ unsigned char potatorLoadROM(char* filename) {
}
int main(int argc, char *argv[]) {
unsigned int index;
double period;
// Get init file directory & name
@ -276,7 +276,6 @@ int main(int argc, char *argv[]) {
break;
}
}
Aclose();
// Free memory
SDL_FreeSurface(layerbackgrey);

View File

@ -471,7 +471,9 @@ void screen_showmainmenu(MENU *menu) {
if (gameMenu) {
screen_showmenu(menu); // show menu items
if (menu == &mnuMainMenu) {
print_string("V1.1", COLOR_LIGHT,COLOR_BG, 294,29);
int len = snprintf(szVal, sizeof(szVal), "V1.1 (core: %u.%u.%u)",
SV_CORE_VERSION_MAJOR, SV_CORE_VERSION_MINOR, SV_CORE_VERSION_PATCH);
print_string(szVal, COLOR_LIGHT,COLOR_BG, 320-len*6,29);
if (cartridge_IsLoaded()) {
#ifdef _OPENDINGUX_
sprintf(szVal,"Game:%s",strrchr(gameName,'/')+1);szVal[(320/6)-2] = '\0';
@ -547,7 +549,7 @@ void findNextFilename(char *szFileFormat, char *szFilename) {
uint32_t uBcl;
int fp;
for (uBcl = 0; uBcl<999; uBcl++) {
for (uBcl = 0; uBcl<1000; uBcl++) {
sprintf(szFilename,szFileFormat,uBcl);
fp = open(szFilename,O_RDONLY | O_BINARY);
if (fp <0) break;
@ -607,7 +609,7 @@ int sort_function(const void *src_str_ptr, const void *dest_str_ptr) {
}
int strcmp_function(char *s1, char *s2) {
char i;
unsigned i;
if (strlen(s1) != strlen(s2)) return 1;
@ -620,7 +622,7 @@ int strcmp_function(char *s1, char *s2) {
signed int load_file(char **wildcards, char *result) {
unsigned char *keys;
unsigned int keya=0, keyb=0, keyup=0, kepufl=8, keydown=0, kepdfl=8, keyleft=0, keyright=0, keyr=0, keyl=0;
unsigned int keya=0, keyb=0, keyup=0, kepufl=8, keydown=0, kepdfl=8, keyr=0, keyl=0;
char current_dir_name[MAX__PATH];
DIR *current_dir;
@ -633,7 +635,6 @@ signed int load_file(char **wildcards, char *result) {
char *file_name;
unsigned int file_name_length;
unsigned int ext_pos = -1;
unsigned int dialog_result = 1;
signed int return_value = 1;
unsigned int repeat;
unsigned int i;
@ -863,15 +864,12 @@ signed int load_file(char **wildcards, char *result) {
return return_value;
}
char *file_ext[] = { (char *) ".sv", (char *) ".bin", NULL };
char *file_ext[] = { (char *) ".sv", (char *) ".ws", (char *) ".bin", NULL };
void menuFileBrowse(void) {
if (load_file(file_ext, gameName) != -1) { // exit if file is chosen
gameMenu=false;
m_Flag = GF_GAMEINIT;
// free memory if another game is loaded
if (cartridge_IsLoaded())
supervision_done();
}
}
@ -885,14 +883,7 @@ void menuSaveBmp(void) {
#else
sprintf(szFile,".\\%s",strrchr(gameName,'\\')+1);
#endif
szFile[strlen(szFile)-8] = '%';
szFile[strlen(szFile)-7] = '0';
szFile[strlen(szFile)-6] = '3';
szFile[strlen(szFile)-5] = 'd';
szFile[strlen(szFile)-4] = '.';
szFile[strlen(szFile)-3] = 'b';
szFile[strlen(szFile)-2] = 'm';
szFile[strlen(szFile)-1] = 'p';
strcat(szFile, "%03d.bmp");
print_string("Saving...", COLOR_OK, COLOR_BG, 8,240-5 -10*3);
screen_flip();
@ -955,12 +946,6 @@ void system_loadcfg(char *cfg_name) {
screen_prepback(actualScreen, POTATOR_SKIN, POTATOR_SKIN_SIZE);
SDL_Flip(actualScreen);
}
switch (GameConf.m_Color) {
case 0: supervision_set_color_scheme(SV_COLOR_SCHEME_DEFAULT); break;
case 1: supervision_set_color_scheme(SV_COLOR_SCHEME_AMBER); break;
case 2: supervision_set_color_scheme(SV_COLOR_SCHEME_GREEN); break;
case 3: supervision_set_color_scheme(SV_COLOR_SCHEME_BLUE); break;
}
}
else {
// UP DOWN LEFT RIGHT A B X Y R L START SELECT

View File

@ -10,7 +10,9 @@
#include <sys/types.h>
#include <SDL/SDL.h>
#include <SDL/SDL_mixer.h>
// potator dependencies
#include "../../common/supervision.h"
// defines and macros
#define MAX__PATH 1024
@ -35,9 +37,6 @@ typedef int bool;
#define PIX_TO_RGB(fmt, r, g, b) (((r>>fmt->Rloss)<<fmt->Rshift)| ((g>>fmt->Gloss)<<fmt->Gshift)|((b>>fmt->Bloss)<<fmt->Bshift))
extern uint16 mapRGB(uint8 r, uint8 g, uint8 b);
// potator dependencies
#include "../../common/supervision.h"
#define cartridge_IsLoaded() (strlen(gameName) != 0)
typedef struct {
@ -80,11 +79,4 @@ extern void screen_showtopmenu(void);
extern void print_string_video(int x, int y, const char *s);
extern void gethomedir(char *dir, char* name);
// sound
extern void AWriteAudioData(unsigned int chan, unsigned int len, unsigned char *pWav);
extern void Ainit(void);
extern void Aclose(void);
extern void APlayVoice(unsigned int chan, unsigned char *pWav, unsigned int loop);
extern void AStopVoice(unsigned int chan, unsigned char *pWav);
#endif