Skip to content

Commit

Permalink
More backports for PPU and video
Browse files Browse the repository at this point in the history
  • Loading branch information
LibretroAdmin committed Jan 10, 2024
1 parent 64e3962 commit bf612c2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
13 changes: 7 additions & 6 deletions src/nsf.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ int NSFLoad(FCEUFILE *fp) {

GameInterface = NSFGI;

#if 0
FCEU_printf("NSF Loaded. File information:\n\n");
FCEU_printf(" Name: %s\n Artist: %s\n Copyright: %s\n\n", NSFHeader.SongName, NSFHeader.Artist, NSFHeader.Copyright);
if (NSFHeader.SoundChip) {
Expand All @@ -284,11 +285,11 @@ int NSFLoad(FCEUFILE *fp) {
FCEU_printf(" Load address: $%04x\n Init address: $%04x\n Play address: $%04x\n", LoadAddr, InitAddr, PlayAddr);
FCEU_printf(" %s\n", (NSFHeader.VideoSystem & 1) ? "PAL" : "NTSC");
FCEU_printf(" Starting song: %d / %d\n\n", NSFHeader.StartingSong, NSFHeader.TotalSongs);
#endif

if (NSFHeader.SoundChip & 4)
ExWRAM = FCEU_gmalloc(32768 + 8192);
else
ExWRAM = FCEU_gmalloc(8192);
/* ExWRAM default size is 8192. FDS format adds additional 32K for RAM.
* For simplicity for savestates and runahead, lets just use the maximum size here. */
ExWRAM = (uint8 *)FCEU_gmalloc(32768 + 8192);
return 1;
}

Expand All @@ -301,8 +302,8 @@ static uint8 NSFVectorRead(uint32 A) {
doreset = 0; return(0x38);
}
return(X.DB);
} else
return(CartBR(A));
}
return(CartBR(A));
}

void NSF_init(void) {
Expand Down
24 changes: 18 additions & 6 deletions src/ppu.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ static uint32 ppulut1[256];
static uint32 ppulut2[256];
static uint32 ppulut3[128];

#define RENDIS_SHOW_SPRITES (rendis & 1)
#define RENDIS_SHOW_BACKGROUND (rendis & 2)

static void makeppulut(void) {
int x;
int y;
Expand Down Expand Up @@ -645,7 +648,7 @@ static void DoLine(void)
X6502_Run(256);
EndRL();

if (rendis & 2) {/* User asked to not display background data. */
if (RENDIS_SHOW_BACKGROUND) {/* User asked to not display background data. */
uint32 tem;
tem = PALRAM[0] | (PALRAM[0] << 8) | (PALRAM[0] << 16) | (PALRAM[0] << 24);
tem |= 0x40404040;
Expand Down Expand Up @@ -965,7 +968,7 @@ static void CopySprites(uint8 *target) {
if (!spork) return;
spork = 0;

if (rendis & 1) return; /* User asked to not display sprites. */
if (RENDIS_SHOW_SPRITES) return; /* User asked to not display sprites. */

do
{
Expand Down Expand Up @@ -1048,10 +1051,19 @@ void FCEUPPU_Reset(void) {
void FCEUPPU_Power(void) {
int x;

memset(NTARAM, 0x00, 0x800);
memset(PALRAM, 0x00, 0x20);
memset(UPALRAM, 0x00, 0x03);
memset(SPRAM, 0x00, 0x100);
/* initialize PPU memory regions according to settings */
FCEU_MemoryRand(NTARAM, 0x800);
FCEU_MemoryRand(PALRAM, 0x20);
FCEU_MemoryRand(SPRAM, 0x100);

/* palettes can only store values up to $3F, and PALRAM X4/X8/XC are mirrors of X0 for rendering purposes (UPALRAM is used for $2007 readback)*/
for (x = 0; x < 0x20; ++x) PALRAM[x] &= 0x3F;
UPALRAM[0] = PALRAM[0x04];
UPALRAM[1] = PALRAM[0x08];
UPALRAM[2] = PALRAM[0x0C];
PALRAM[0x0C] = PALRAM[0x08] = PALRAM[0x04] = PALRAM[0x00];
PALRAM[0x1C] = PALRAM[0x18] = PALRAM[0x14] = PALRAM[0x10];

FCEUPPU_Reset();
for (x = 0x2000; x < 0x4000; x += 8) {
ARead[x] = A200x;
Expand Down
2 changes: 1 addition & 1 deletion src/video.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ int FCEU_InitVirtualVideo(void)
return 0;

memset(XBuf, 128, 256 * (256 + extrascanlines + 8));
memset(XDBuf, 128, 256 * (256 + extrascanlines + 8));
memset(XDBuf, 0, 256 * (256 + extrascanlines + 8));
return 1;
}

Expand Down

0 comments on commit bf612c2

Please sign in to comment.