Take out HES/player

This commit is contained in:
twinaphex 2014-06-18 23:40:09 +02:00
parent 058d529c7a
commit 2bc66d5e77
12 changed files with 0 additions and 530 deletions

View File

@ -291,7 +291,6 @@ MEDNAFEN_SOURCES := $(MEDNAFEN_DIR)/mednafen.cpp \
$(RESAMPLER_SOURCES) \
$(MEDNAFEN_DIR)/sound/Stereo_Buffer.cpp \
$(MEDNAFEN_DIR)/file.cpp \
$(MEDNAFEN_DIR)/player.cpp \
$(OKIADPCM_SOURCES) \
$(MEDNAFEN_DIR)/md5.cpp

View File

@ -109,7 +109,6 @@ MEDNAFEN_SOURCES := $(MEDNAFEN_DIR)/mednafen.cpp \
$(MEDNAFEN_DIR)/sound/Blip_Buffer.cpp \
$(MEDNAFEN_DIR)/sound/Stereo_Buffer.cpp \
$(MEDNAFEN_DIR)/file.cpp \
$(MEDNAFEN_DIR)/player.cpp \
$(MEDNAFEN_DIR)/endian.cpp \
$(MEDNAFEN_DIR)/cputest/cputest.c \
$(OKIADPCM_SOURCES) \

View File

@ -1,249 +0,0 @@
/* Mednafen - Multi-system Emulator
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "pce.h"
#include "hes.h"
#include "huc.h"
#include "pcecd.h"
#include "../player.h"
#include "../mednafen-endian.h"
namespace PCE_Fast
{
static uint8 mpr_start[8];
static uint8 IBP_Bank[0x2000];
static uint8 *rom = NULL, *rom_backup = NULL;
static uint8 CurrentSong;
static bool bootstrap;
static bool ROMWriteWarningGiven;
uint8 ReadIBP(unsigned int A)
{
if(!(A & 0x100))
return(IBP_Bank[0x1C00 + (A & 0xF)]);
if(bootstrap)
{
memcpy(rom + 0x1FF0, rom_backup + 0x1FF0, 16);
bootstrap = false;
return(CurrentSong);
}
return(0xFF);
}
static DECLFW(HESROMWrite)
{
rom[A] = V;
//printf("%08x: %02x\n", A, V);
if(!ROMWriteWarningGiven)
{
MDFN_printf(_("Warning: HES is writing to physical address %08x. Future warnings of this nature are temporarily disabled for this HES file.\n"), A);
ROMWriteWarningGiven = TRUE;
}
}
static DECLFR(HESROMRead)
{
return(rom[A]);
}
int PCE_HESLoad(const uint8 *buf, uint32 size)
{
uint32 LoadAddr, LoadSize;
uint32 CurPos;
uint16 InitAddr;
uint8 StartingSong;
int TotalSongs;
InitAddr = MDFN_de16lsb(&buf[0x6]);
CurPos = 0x10;
if(!(rom = (uint8 *)MDFN_malloc(0x88 * 8192, _("HES ROM"))))
{
return(0);
}
if(!(rom_backup = (uint8 *)MDFN_malloc(0x88 * 8192, _("HES ROM"))))
{
return(0);
}
memset(rom, 0, 0x88 * 8192);
memset(rom_backup, 0, 0x88 * 8192);
while(CurPos < (size - 0x10))
{
LoadSize = MDFN_de32lsb(&buf[CurPos + 0x4]);
LoadAddr = MDFN_de32lsb(&buf[CurPos + 0x8]);
//printf("Size: %08x(%d), Addr: %08x, La: %02x\n", LoadSize, LoadSize, LoadAddr, LoadAddr / 8192);
CurPos += 0x10;
if(((uint64)LoadSize + CurPos) > size)
{
uint32 NewLoadSize = size - CurPos;
MDFN_printf(_("Warning: HES is trying to load more data than is present in the file(%u attempted, %u left)!\n"), LoadSize, NewLoadSize);
LoadSize = NewLoadSize;
}
// 0x88 * 8192 = 0x110000
if(((uint64)LoadAddr + LoadSize) > 0x110000)
{
MDFN_printf(_("Warning: HES is trying to load data past boundary.\n"));
if(LoadAddr >= 0x110000)
break;
LoadSize = 0x110000 - LoadAddr;
}
memcpy(rom + LoadAddr, &buf[CurPos], LoadSize);
CurPos += LoadSize;
}
for(int x = 0; x < 8; x++)
mpr_start[x] = buf[0x8 + x];
memcpy(rom_backup, rom, 0x88 * 8192);
CurrentSong = StartingSong = buf[5];
TotalSongs = 256;
memset(IBP_Bank, 0, 0x2000);
uint8 *IBP_WR = IBP_Bank + 0x1C00;
for(int i = 0; i < 8; i++)
{
*IBP_WR++ = 0xA9; // LDA (immediate)
*IBP_WR++ = mpr_start[i];
*IBP_WR++ = 0x53; // TAM
*IBP_WR++ = 1 << i;
}
*IBP_WR++ = 0xAD; // LDA(absolute)
*IBP_WR++ = 0x00; //
*IBP_WR++ = 0x1D; //
*IBP_WR++ = 0x20; // JSR
*IBP_WR++ = InitAddr; // JSR target LSB
*IBP_WR++ = InitAddr >> 8; // JSR target MSB
*IBP_WR++ = 0x58; // CLI
*IBP_WR++ = 0xFC; // (Mednafen Special)
*IBP_WR++ = 0x80; // BRA
*IBP_WR++ = 0xFD; // -3
Player_Init(TotalSongs, "", "", ""); //NULL, NULL, NULL, NULL); //UTF8 **snames);
for(int x = 0; x < 0x80; x++)
{
HuCPUFastMap[x] = rom;
PCERead[x] = HESROMRead;
PCEWrite[x] = HESROMWrite;
}
HuCPUFastMap[0xFF] = IBP_Bank - (0xFF * 8192);
// FIXME: If a HES rip tries to execute a SCSI command, the CD emulation code will probably crash. Obviously, a HES rip shouldn't do this,
// but Mednafen shouldn't crash either. ;)
PCE_IsCD = 1;
PCE_InitCD();
ROMWriteWarningGiven = FALSE;
return(1);
}
static const uint8 BootROM[16] = { 0xA9, 0xFF, 0x53, 0x01, 0xEA, 0xEA, 0xEA, 0xEA,
0xEA, 0xEA, 0xEA, 0x4C, 0x00, 0x1C, 0xF0, 0xFF };
void HES_Reset(void)
{
memcpy(rom, rom_backup, 0x88 * 8192);
memcpy(rom + 0x1FF0, BootROM, 16);
bootstrap = true;
}
void HES_Draw(MDFN_Surface *surface, MDFN_Rect *DisplayRect, int16 *SoundBuf, int32 SoundBufSize)
{
extern uint16 pce_jp_data[5];
static uint8 last = 0;
bool needreload = 0;
uint8 newset = (pce_jp_data[0] ^ last) & pce_jp_data[0];
if(newset & 0x20)
{
CurrentSong++;
needreload = 1;
}
if(newset & 0x80)
{
CurrentSong--;
needreload = 1;
}
if(newset & 0x08)
needreload = 1;
if(newset & 0x10)
{
CurrentSong += 10;
needreload = 1;
}
if(newset & 0x40)
{
CurrentSong -= 10;
needreload = 1;
}
last = pce_jp_data[0];
if(needreload)
PCE_Power();
Player_Draw(surface, DisplayRect, CurrentSong, SoundBuf, SoundBufSize);
}
void HES_Close(void)
{
PCECD_Close();
if(rom)
{
MDFN_free(rom);
rom = NULL;
}
if(rom_backup)
{
MDFN_free(rom_backup);
rom_backup = NULL;
}
}
};

View File

@ -1,11 +0,0 @@
namespace PCE_Fast
{
uint8 ReadIBP(unsigned int A);
void HES_Draw(MDFN_Surface *surface, MDFN_Rect *DisplayRect, int16 *samples, int32 sampcount);
int PCE_HESLoad(const uint8 *buf, uint32 size) MDFN_COLD;
void HES_Reset(void) MDFN_COLD;
void HES_Close(void) MDFN_COLD;
};

View File

@ -22,7 +22,6 @@
#include "huc.h"
#include "pcecd.h"
#include "pcecd_drive.h"
#include "hes.h"
#include "../hw_misc/arcade_card/arcade_card.h"
#include "../mempatcher.h"
#include "../cdrom/cdromif.h"
@ -220,15 +219,6 @@ static int Load(const char *name, MDFNFILE *fp)
uint32 crc = crc32(0, GET_FDATA_PTR(fp) + headerlen, GET_FSIZE_PTR(fp) - headerlen);
#ifdef HAVE_HES
if(IsHES)
{
if(!PCE_HESLoad(GET_FDATA_PTR(fp), GET_FSIZE_PTR(fp)))
return(0);
}
else
#endif
HuCLoad(GET_FDATA_PTR(fp) + headerlen, GET_FSIZE_PTR(fp) - headerlen, crc);
if(!strcasecmp(GET_FEXTS_PTR(fp), "sgx"))
@ -454,11 +444,6 @@ static int LoadCD(std::vector<CDIF *> *CDInterfaces)
static void CloseGame(void)
{
#ifdef HAVE_HES
if(IsHES)
HES_Close();
else
#endif
{
HuCClose();
}
@ -560,11 +545,6 @@ static void Emulate(EmulateSpecStruct *espec)
if(PCE_IsCD)
PCECD_ResetTS();
#ifdef HAVE_HES
if(IsHES && !espec->skip)
HES_Draw(espec->surface, &espec->DisplayRect, espec->SoundBuf, espec->SoundBufSize);
#endif
}
static int StateAction(StateMem *sm, int load, int data_only)
@ -606,11 +586,6 @@ void PCE_Power(void)
PCEIODataBuffer = 0xFF;
#ifdef HAVE_HES
if(IsHES)
HES_Reset();
#endif
HuC6280_Power();
VDC_Power();
psg->Power(HuCPU.timestamp / pce_overclocked);

View File

@ -1,223 +0,0 @@
/* Mednafen - Multi-system Emulator
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mednafen.h"
#include <trio/trio.h>
#include <math.h>
#include "video.h"
#include "player.h"
static std::string AlbumName, Artist, Copyright;
static std::vector<std::string> SongNames;
static int TotalSongs;
static INLINE void DrawLine(MDFN_Surface *surface, uint32 color, uint32 bmatch, uint32 breplace, int x1, int y1, int x2, int y2)
{
uint32 *buf = surface->pixels;
float dy_dx = (float)(y2 - y1) / (x2 - x1);
int x;
float r_ys = 0; //x1 * dy_dx;
float r_ye = (x2 - x1) * dy_dx;
for(x = x1; x <= x2; x++)
{
float ys = dy_dx * (x - 1 - x1) + dy_dx / 2;
float ye = dy_dx * (x + 1 - x1) - dy_dx / 2;
if(dy_dx > 0)
{
ys = floor(0.5 + ys);
ye = floor(0.5 + ye);
if(ys < r_ys) ys = r_ys;
if(ye > r_ye) ye = r_ye;
if(bmatch != ~0U)
for(unsigned int y = (unsigned int) ys; y <= (unsigned int)ye; y++)
{
uint32 tmpcolor = color;
if(buf[x + (y + y1) * surface->pitch32] == bmatch) tmpcolor = breplace;
if(buf[x + (y + y1) * surface->pitch32] != breplace)
buf[x + (y + y1) * surface->pitch32] = tmpcolor;
}
else
for(unsigned int y = (unsigned int)ys; y <= (unsigned int)ye; y++)
buf[x + (y + y1) * surface->pitch32] = color;
}
else
{
ys = floor(0.5 + ys);
ye = floor(0.5 + ye);
if(ys > r_ys) ys = r_ys;
if(ye < r_ye) ye = r_ye;
if(bmatch != ~0U)
for(int y = (int)ys; y >= (int)ye; y--)
{
uint32 tmpcolor = color;
if(buf[x + (y + y1) * surface->pitch32] == bmatch)
tmpcolor = breplace;
if(buf[x + (y + y1) * surface->pitch32] != breplace)
buf[x + (y + y1) * surface->pitch32] = tmpcolor;
}
else
for(int y = (int)ys; y >= (int)ye; y--)
{
buf[x + (y + y1) * surface->pitch32] = color;
}
}
}
}
int Player_Init(int tsongs, const std::string &album, const std::string &artist, const std::string &copyright, const std::vector<std::string> &snames)
{
AlbumName = album;
Artist = artist;
Copyright = copyright;
SongNames = snames;
TotalSongs = tsongs;
MDFNGameInfo->nominal_width = 384;
MDFNGameInfo->nominal_height = 240;
MDFNGameInfo->fb_width = 384;
MDFNGameInfo->fb_height = 240;
MDFNGameInfo->lcm_width = 384;
MDFNGameInfo->lcm_height = 240;
MDFNGameInfo->GameType = GMT_PLAYER;
return(1);
}
int Player_Init(int tsongs, const std::string &album, const std::string &artist, const std::string &copyright, char **snames)
{
std::vector<std::string> tmpvec;
if(snames)
{
for(int i = 0; i < tsongs; i++)
tmpvec.push_back(snames[i] ? snames[i] : "");
}
return Player_Init(tsongs, album, artist, copyright, tmpvec);
}
void Player_Draw(MDFN_Surface *surface, MDFN_Rect *dr, int CurrentSong, int16 *samples, int32 sampcount)
{
#if 0
uint32 *XBuf = surface->pixels;
//MDFN_Rect *dr = &MDFNGameInfo->DisplayRect;
int x,y;
const uint32 text_color = surface->MakeColor(0xE8, 0xE8, 0xE8);
const uint32 text_shadow_color = surface->MakeColor(0x00, 0x18, 0x10);
const uint32 bg_color = surface->MakeColor(0x20, 0x00, 0x08);
const uint32 left_color = surface->MakeColor(0x80, 0x80, 0xFF);
const uint32 right_color = surface->MakeColor(0x80, 0xff, 0x80);
const uint32 center_color = surface->MakeColor(0x80, 0xCC, 0xCC);
dr->x = 0;
dr->y = 0;
dr->w = 384;
dr->h = 240;
// Draw the background color
for(y = 0; y < dr->h; y++)
MDFN_FastU32MemsetM8(&XBuf[y * surface->pitch32], bg_color, dr->w);
// Now we draw the waveform data. It should be centered vertically, and extend the screen horizontally from left to right.
int32 x_scale;
float y_scale;
int lastX, lastY;
x_scale = (sampcount << 8) / dr->w;
y_scale = (float)dr->h;
if(sampcount)
{
for(int wc = 0; wc < MDFNGameInfo->soundchan; wc++)
{
uint32 color = wc ? right_color : left_color; //MK_COLOR(0x80, 0xff, 0x80) : MK_COLOR(0x80, 0x80, 0xFF);
if(MDFNGameInfo->soundchan == 1)
color = center_color; //MK_COLOR(0x80, 0xc0, 0xc0);
lastX = -1;
lastY = 0;
for(x = 0; x < dr->w; x++)
{
float samp = ((float)-samples[wc + (x * x_scale >> 8) * MDFNGameInfo->soundchan]) / 32768;
int ypos;
ypos = (dr->h / 2) + (int)(y_scale * samp);
if(ypos >= dr->h)
ypos = dr->h - 1;
if(ypos < 0)
ypos = 0;
if(lastX >= 0)
DrawLine(surface, color, wc ? left_color : ~0, center_color, lastX, lastY, x, ypos);
lastX = x;
lastY = ypos;
}
}
}
XBuf += 2 * surface->pitch32;
DrawTextTransShadow(XBuf, surface->pitch32 * sizeof(uint32), dr->w, AlbumName, text_color, text_shadow_color, 1);
XBuf += (13 + 2) * surface->pitch32;
DrawTextTransShadow(XBuf, surface->pitch32 * sizeof(uint32), dr->w, Artist, text_color, text_shadow_color, 1);
XBuf += (13 + 2) * surface->pitch32;
DrawTextTransShadow(XBuf, surface->pitch32 * sizeof(uint32), dr->w, Copyright, text_color, text_shadow_color, 1);
XBuf += (13 * 2) * surface->pitch32;
// If each song has an individual name, show this song's name.
{
std::string tmpsong = "";
if((unsigned int)CurrentSong < SongNames.size())
tmpsong = SongNames[CurrentSong];
if(tmpsong == "" && TotalSongs > 1)
tmpsong = std::string(_("Song:"));
DrawTextTransShadow(XBuf, surface->pitch32 * sizeof(uint32), dr->w, tmpsong, text_color, text_shadow_color, 1);
}
XBuf += (13 + 2) * surface->pitch32;
if(TotalSongs > 1)
{
char snbuf[32];
trio_snprintf(snbuf, 32, "<%d/%d>", CurrentSong + 1, TotalSongs);
DrawTextTransShadow(XBuf, surface->pitch32 * sizeof(uint32), dr->w, (uint8*)snbuf, text_color, text_shadow_color, 1);
}
#endif
}

View File

@ -1,9 +0,0 @@
#ifndef __MDFN_PLAYER_H
#define __MDFN_PLAYER_H
int Player_Init(int tsongs, const std::string &album, const std::string &artist, const std::string &copyright,const std::vector<std::string> &snames = std::vector<std::string>());
int Player_Init(int tsongs, const std::string &album, const std::string &artist, const std::string &copyright, char **snames);
void Player_Draw(MDFN_Surface *surface, MDFN_Rect *dr, int CurrentSong, int16 *samples, int32 sampcount);
#endif

View File

@ -241,9 +241,6 @@
<File
RelativePath="..\..\..\mednafen\okiadpcm.cpp">
</File>
<File
RelativePath="..\..\..\mednafen\player.cpp">
</File>
<File
RelativePath="..\..\..\mednafen\settings.cpp">
</File>

View File

@ -66,7 +66,6 @@
<ClCompile Include="..\..\..\mednafen\pce_fast\pcecd_drive.cpp" />
<ClCompile Include="..\..\..\mednafen\pce_fast\psg.cpp" />
<ClCompile Include="..\..\..\mednafen\pce_fast\vdc.cpp" />
<ClCompile Include="..\..\..\mednafen\player.cpp" />
<ClCompile Include="..\..\..\mednafen\settings.cpp" />
<ClCompile Include="..\..\..\mednafen\sound\Blip_Buffer.cpp" />
<ClCompile Include="..\..\..\mednafen\sound\Stereo_Buffer.cpp" />

View File

@ -230,9 +230,6 @@
<ClCompile Include="..\..\..\mednafen\cputest\cputest.c">
<Filter>Source Files\mednafen\cputest</Filter>
</ClCompile>
<ClCompile Include="..\..\..\mednafen\player.cpp">
<Filter>Source Files\mednafen</Filter>
</ClCompile>
<ClCompile Include="..\..\..\mednafen\pce_fast\hes.cpp">
<Filter>Source Files\mednafen\pce_fast</Filter>
</ClCompile>

View File

@ -53,7 +53,6 @@
<ClCompile Include="..\..\..\mednafen\pce_fast\pcecd_drive.cpp" />
<ClCompile Include="..\..\..\mednafen\pce_fast\psg.cpp" />
<ClCompile Include="..\..\..\mednafen\pce_fast\vdc.cpp" />
<ClCompile Include="..\..\..\mednafen\player.cpp" />
<ClCompile Include="..\..\..\mednafen\settings.cpp" />
<ClCompile Include="..\..\..\mednafen\sound\Blip_Buffer.cpp" />
<ClCompile Include="..\..\..\mednafen\sound\Stereo_Buffer.cpp" />

View File

@ -257,8 +257,5 @@
<ClCompile Include="..\..\..\mednafen\cputest\cputest.c">
<Filter>Source Files\mednafen\cputest</Filter>
</ClCompile>
<ClCompile Include="..\..\..\mednafen\player.cpp">
<Filter>Source Files\mednafen</Filter>
</ClCompile>
</ItemGroup>
</Project>