Compare commits

...

3 commits

10 changed files with 338 additions and 211 deletions

Binary file not shown.

View file

@ -1,4 +1,4 @@
VERSION=4.5a
VERSION=4.5b
TARGNAME=A7800DS
#---------------------------------------------------------------------------------

View file

@ -29,11 +29,11 @@ Features :
the scheme. See http://7800.8bitdev.org/index.php/Bankset_Bankswitching for more details.
Add highscore.rom for 7800 High Score saving. This can be in /roms/bios, /data/bios
or in the same directory as the emulator. It's worth the effort!
or in the same directory as the emulator. It's worth the effort to track down the highscore.rom file!
Copyright :
----------
A7800DS is Copyright 2021-2022 by Dave Bernazzani (wavemotion-dave).
A7800DS is Copyright 2021-2024 by Dave Bernazzani (wavemotion-dave).
Copying and distribution of this emulator, it's source code and associated
readme files, with or without modification, are permitted in any medium without
@ -78,6 +78,7 @@ Controls :
* X : Fire button 2
* Y : Fire Button 1
* L/R + DPAD : Used to Shift Offsets and Scale Screen to desired ratio
* L + R + X : Hold for 1 second to swap LCD screens top/bottom
Use stylus on buttons for other actions on bottom screen.
@ -115,10 +116,14 @@ the 7800 screen resolution isn't a perfect match for the DS 256x192 so you'll ha
games have defaults that look good enough. Some games will cut off a few pixel lines at the top and bottom - but they will
still be perfectly playalbe. Such is life with only 192 vertical pixels to play with on the DS!
Recent versions of the emulator have a magnifying glass icon that will zoom and center the display to 1:1 of the actual 7800 output.
This will crop some pixels off the sides and top/bottom but is useful to temporarily zoom up to enter things like high scores
where the text may be hard to read when shrunk down.
Frame Skipping can be OFF (show all frames), Moderate (Show 3/4 frames) or Agressive (only show 1/2 frames). The latter is
only really needed for the DS-Lite/Phat where the faster DSi CPU isn't available.
Don't touch the DMA Cycle Adjustment unless you understand them... and most people don't :)
Don't touch the DMA Cycle Adjustment unless you understand them... and most people don't - sometimes including the developer :)
Press START to save off your configuration - if you made changes you should re-load the game to ensure all settings are applied.
@ -128,7 +133,7 @@ Credits:
* Thanks Wintermute for devkitpro and libnds (http://www.devkitpro.org).
* Greg Stanton for ProSystem source code (https://home.comcast.net/~gscottstanton/) an Atari 7800 emulator.
* zx81 (http://zx81.zx81.free.fr/serendipity_fr/) for PSP A7800 version (that helped me a lot to understand ProSystem).
* raz0red (http://www.twitchasylum.com/forum/viewtopic.php?t=519) for WII7800 (that helped me a lot to fix some timing problems).
* raz0red (http://www.twitchasylum.com/forum/viewtopic.php?t=519) for WII7800 (that helped me to fix some timing problems).
* The folks at AtariAge who helped weed out many of the old ProSystem Maria rendering bugs.
* The MAXMOD audio library is Copyright (c) 2008, Mukunda Johnson (mukunda@maxmod.org). See https://github.com/devkitPro/maxmod
@ -144,6 +149,12 @@ Updates by wavemotion-dave: https://github.com/wavemotion-dave/A7800DS
--------------------------------------------------------------------------------
History :
--------------------------------------------------------------------------------
V4.5b : 05-May-2024 by wavemotion-dave
* Each game that utilizes a High Score Cart (HSC) gets its own 2K .hsc file
* Sanity checks added so that carts marked as 'NORMAL' (or selected as such) but are larger than 48K will not corrupt memory.
* New magnifying glass icon to ZOOM (and center) the display 1:1 with real 7800 output. This will crop on a DS/DSi since it only has 256x192 but very useful to toggle the 1:1 zoom for High Score Entries, etc.
* Starting to lay groundwork support for .a78 V4 headers...
V4.5 : 18-Nov-2022 by wavemotion-dave
* SNES2Atari adaptor supported.
* Improved display output to smooth over the fonts a bit.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 30 KiB

View file

@ -1,5 +1,5 @@
// =====================================================================================
// Copyright (c) 2022 Dave Bernazzani (wavemotion-dave)
// Copyright (c) 2022-2024 Dave Bernazzani (wavemotion-dave)
//
// Copying and distribution of this emulator, it's source code and associated
// readme files, with or without modification, are permitted in any medium without
@ -809,18 +809,76 @@ __attribute__ ((noinline)) void timer_reset(void)
TIMER1_CR=TIMER_ENABLE | TIMER_DIV_1024;
}
static u8 lcd_swap_counter=0;
static int scale_screen_dampen=0;
__attribute__ ((noinline)) void handle_LR_keys(unsigned int keys_pressed)
{
if (myCartInfo.cardctrl1 != SNES)
{
if ((keys_pressed & KEY_R) && (keys_pressed & KEY_L))
{
if (++lcd_swap_counter == 30)
{
if (keys_pressed & (KEY_X)) lcdSwap();
}
}
if (scale_screen_dampen > 5)
{
if ((keys_pressed & KEY_R) && (keys_pressed & KEY_UP)) { myCartInfo.yOffset++; bRefreshXY = true; }
if ((keys_pressed & KEY_R) && (keys_pressed & KEY_DOWN)) { myCartInfo.yOffset--; bRefreshXY = true; }
if ((keys_pressed & KEY_R) && (keys_pressed & KEY_LEFT)) { myCartInfo.xOffset++; bRefreshXY = true; }
if ((keys_pressed & KEY_R) && (keys_pressed & KEY_RIGHT)) { myCartInfo.xOffset--; bRefreshXY = true; }
if ((keys_pressed & KEY_L) && (keys_pressed & KEY_UP)) if (myCartInfo.yScale < 234) { myCartInfo.yScale++; bRefreshXY = true; }
if ((keys_pressed & KEY_L) && (keys_pressed & KEY_DOWN)) if (myCartInfo.yScale > 192) { myCartInfo.yScale--; bRefreshXY = true; }
if ((keys_pressed & KEY_L) && (keys_pressed & KEY_RIGHT)) if (myCartInfo.xScale < 320) { myCartInfo.xScale++; bRefreshXY = true; }
if ((keys_pressed & KEY_L) && (keys_pressed & KEY_LEFT)) if (myCartInfo.xScale > 192) { myCartInfo.xScale--; bRefreshXY = true; }
scale_screen_dampen=0;
} else scale_screen_dampen++;
}
}
// Toggle full 320x256
__attribute__ ((noinline)) void toggle_zoom(void)
{
static s16 last_xScale = 0;
static s16 last_yScale = 0;
static s16 last_xOffset = 0;
static s16 last_yOffset = 0;
if (last_xScale == 0)
{
last_xScale = myCartInfo.xScale;
last_yScale = myCartInfo.yScale;
last_xOffset = myCartInfo.xOffset;
last_yOffset = myCartInfo.yOffset;
myCartInfo.xScale = 320;
myCartInfo.yScale = 234;
myCartInfo.xOffset = 32;
myCartInfo.yOffset = 21;
}
else
{
myCartInfo.xScale = last_xScale;
myCartInfo.yScale = last_yScale;
myCartInfo.xOffset = last_xOffset;
myCartInfo.yOffset = last_yOffset;
last_xScale = last_yScale = 0;
last_xOffset = last_yOffset = 0;
}
bRefreshXY = true;
}
// ----------------------------------------------------------------------------------
// This is where the action happens! The main loop runs continually and clocks
// out the 60 frames per second of the 7800 Prosystem
// ----------------------------------------------------------------------------------
ITCM_CODE void dsMainLoop(void)
{
static u8 lcd_swap_counter=0;
static u8 special_hsc_entry=0;
static short int last_keys_pressed = 999;
unsigned int keys_pressed,keys_touch=0, romSel;
short iTx,iTy;
static int scale_screen_dampen=0;
timer_reset();
@ -948,6 +1006,10 @@ ITCM_CODE void dsMainLoop(void)
ShowConfig();
SoundUnPause();
}
else if ((iTx>10) && (iTx<58) && (iTy>22) && (iTy<62)) // Magnifying Glass (zoom)
{
toggle_zoom();
}
keys_touch=1;
} else keys_touch=0;
@ -1010,29 +1072,7 @@ ITCM_CODE void dsMainLoop(void)
if ((keys_pressed & KEY_R) || (keys_pressed & KEY_L))
{
if (myCartInfo.cardctrl1 != SNES)
{
if ((keys_pressed & KEY_R) && (keys_pressed & KEY_L))
{
if (++lcd_swap_counter == 30)
{
if (keys_pressed & KEY_A) lcdSwap();
}
}
if (scale_screen_dampen > 5)
{
if ((keys_pressed & KEY_R) && (keys_pressed & KEY_UP)) { myCartInfo.yOffset++; bRefreshXY = true; }
if ((keys_pressed & KEY_R) && (keys_pressed & KEY_DOWN)) { myCartInfo.yOffset--; bRefreshXY = true; }
if ((keys_pressed & KEY_R) && (keys_pressed & KEY_LEFT)) { myCartInfo.xOffset++; bRefreshXY = true; }
if ((keys_pressed & KEY_R) && (keys_pressed & KEY_RIGHT)) { myCartInfo.xOffset--; bRefreshXY = true; }
if ((keys_pressed & KEY_L) && (keys_pressed & KEY_UP)) if (myCartInfo.yScale <= 256) { myCartInfo.yScale++; bRefreshXY = true; }
if ((keys_pressed & KEY_L) && (keys_pressed & KEY_DOWN)) if (myCartInfo.yScale > 192) { myCartInfo.yScale--; bRefreshXY = true; }
if ((keys_pressed & KEY_L) && (keys_pressed & KEY_RIGHT)) if (myCartInfo.xScale < 320) { myCartInfo.xScale++; bRefreshXY = true; }
if ((keys_pressed & KEY_L) && (keys_pressed & KEY_LEFT)) if (myCartInfo.xScale > 192) { myCartInfo.xScale--; bRefreshXY = true; }
scale_screen_dampen=0;
} else scale_screen_dampen++;
}
handle_LR_keys(keys_pressed);
} else lcd_swap_counter=0;
// -------------------------------------------------------------
@ -1101,10 +1141,14 @@ void proFindFiles(void) {
strcpy(filenametmp,pent->d_name);
if (pent->d_type == DT_DIR)
{
if (!( (filenametmp[0] == '.') && (strlen(filenametmp) == 1))) {
proromlist[countpro].directory = true;
strcpy(proromlist[countpro].filename,filenametmp);
countpro++;
if (!( (filenametmp[0] == '.') && (strlen(filenametmp) == 1)))
{
if (strcasecmp(filenametmp, "sav") != 0)
{
proromlist[countpro].directory = true;
strcpy(proromlist[countpro].filename,filenametmp);
countpro++;
}
}
}
else {

View file

@ -269,8 +269,17 @@ static void cartridge_ReadHeader(const byte* header) {
break;
}
// Region:
// bit 0 : 0=NTSC, 1=PAL
// bit 1 : 0=component, 1=composite
// bit 2 : 0=single region, 1=multi-region
myCartInfo.region = header[57] & 1;
// High Score Support
// bit 0 : HSC
// bit 1 : AtariVox/SaveKey
myCartInfo.hsc = (header[58]&1 ? HSC_YES:HSC_NO);
myCartInfo.dma_adjust = 0;
last_bank = 255;
last_ex_ram_bank = 0;
@ -590,11 +599,11 @@ ITCM_CODE void cartridge_Write(word address, byte data) {
// IsLoaded
// ----------------------------------------------------------------------------
bool cartridge_IsLoaded( ) {
return true; //TODO: find a better way to know if a cart has been loaded
return (cartridge_size > 0) ? true:false;
}
// ----------------------------------------------------------------------------
// Release
// Release cart, save SRAM if used, set common vars back to system default.
// ----------------------------------------------------------------------------
void cartridge_Release( )
{

View file

@ -29,107 +29,197 @@
#include "Cartridge.h"
#include "Database.h"
#define HS_SRAM_START 0x1000 // The 7800 RAM memory location of the high score cartridge SRAM
#define HS_SRAM_SIZE 2048 // The size of the high score cartridge SRAM
#define VIRTUAL_SRAM_BLOCKS 8 // We support 8 virtual high score blocks to keep the now crowded HSC filling up
#define HSC_CART_ROM_SIZE 4096 // The highscore.rom is exactly 4K in size and gets loaded at 7800 memory address 0x3000
#define HSC_TITLE_SIZE 33 // Includes 32 chars for title name and 1 char for size
#define HS_SRAM_START 0x1000 // The 7800 RAM memory location of the high score cartridge SRAM
#define HS_SRAM_SIZE 2048 // The size of the high score cartridge SRAM and gets loaded at 7800 memory address 0x1000
#define HSC_CART_ROM_SIZE 4096 // The highscore.rom is exactly 4K in size and gets loaded at 7800 memory address 0x3000
#define HSC_TITLE_SIZE 33 // Includes 32 chars for title name and 1 char for size (strlen)
static u32 last_hs_chksum = 0xFFFFEEEF;
static byte high_score_sram[VIRTUAL_SRAM_BLOCKS][HS_SRAM_SIZE];
static byte high_score_rom[HSC_CART_ROM_SIZE];
static byte hs_virtual_slot = 0;
static byte high_score_sram[HS_SRAM_SIZE]; // Buffer for the actual 2K of HSC data
static byte high_score_rom[HSC_CART_ROM_SIZE]; // Buffer for the 4K of high score ROM (highscore.rom)
byte high_score_cart_loaded = false; // Flips to true if the High Score Cart is loaded in memory
// -----------------------------------------------------------------------------------------------------
// This is a snapshot of an initialized HSC after Asteroids (NTSC) initialized it with the name "HSC"
// A few of the modern homebrews don't do a good job of initializing the HSC and so we use this as
// as default starting SRAM which is squeaky clean and ready for use by the game.
// -----------------------------------------------------------------------------------------------------
unsigned char A7800DS_00_sram[HS_SRAM_SIZE] = {
0x00, 0x00, 0x68, 0x83, 0xaa, 0x55, 0x9c, 0x02, 0x07, 0x12, 0x02, 0x1f, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
byte high_score_cart_loaded = false;
/*
* Saves the high score cartridge SRAM
*
* return Whether the save was successful
* return Whether the save was successful (false if game is not supporting HSC)
*/
static char szName[256+4];
static void make_hsc_name(void)
{
// Init HSC filename is same as base filename with .hsc
DIR* dir = opendir("sav");
if (dir) closedir(dir); // Directory exists... close it out and move on.
else mkdir("sav", 0777); // Otherwise create the directory...
sprintf(szName,"sav/%s", cartridge_filename);
int len = strlen(szName);
szName[len-3] = 'h';
szName[len-2] = 's';
szName[len-1] = 'c';
szName[len-0] = 0;
}
// ------------------------------------------------------------------------------------
// Write the full 2K of HSC - a bit wasteful for a single game but we've got plenty
// of space and it turns out to be more flexibile for each game to have their own HSC.
// ------------------------------------------------------------------------------------
bool cartridge_SaveHighScoreSram(void)
{
bool status = false;
word retries = 3;
if(!high_score_cart_loaded || !myCartInfo.hsc)
{
// If we didn't load the high score cartridge, or don't have an HSC enabled cart: don't save.
return false;
return false; // If we didn't load the high score cartridge, or don't have an HSC enabled cart: don't save.
}
// ------------------------------------------------------------------------------------------------
// We are being fairly paranoid here mainly because there are games that corrupt the SRAM area
// of the high score cart... XENOPHOBE is one. The Donkey Kong XM Homebrew is another. So we
// want to make sure we aren't saving crap out - this is fairly robust ... so far...
// ------------------------------------------------------------------------------------------------
while (status == false)
memcpy(high_score_sram, memory_ram+HS_SRAM_START, HS_SRAM_SIZE); // Copy from main memory to SRAM buffer
make_hsc_name(); // HSC filename is same as base filename with .hsc extension
// Write out the .hsc file
FILE *handle = fopen(szName, "wb");
if (handle != NULL)
{
u32 chksum = 0;
for( uint i = 0; i < HS_SRAM_SIZE; i++ )
{
high_score_sram[hs_virtual_slot][i] = memory_ram[HS_SRAM_START+i];
chksum += high_score_sram[hs_virtual_slot][i];
}
// ------------------------------------------------------------
// Make sure there is something different/worth saving...
// ------------------------------------------------------------
if ((chksum != last_hs_chksum) && (chksum != 0))
{
// -----------------------------------------------------------------------------------------------------------
// Check to make sure the High Score Cart "Magic Numbers" are right... otherwise corrupt and don't save...
// -----------------------------------------------------------------------------------------------------------
if ((high_score_sram[hs_virtual_slot][2] == 0x68) && (high_score_sram[hs_virtual_slot][3] == 0x83) && (high_score_sram[hs_virtual_slot][4] == 0xaa) && (high_score_sram[hs_virtual_slot][5] == 0x55) && (high_score_sram[hs_virtual_slot][6] == 0x9c))
{
// ------------------------------------------------------------------------------------------------
// Make sure the other virtual slots are valid... if not, copy the one known 'good' slot to those
// ------------------------------------------------------------------------------------------------
for (u8 i=0; i<VIRTUAL_SRAM_BLOCKS; i++)
{
if (i != hs_virtual_slot) // We already know hs_virtual_slot is good
{
// Check for magic numbers in the other virtual slots...
if (!((high_score_sram[i][2] == 0x68) && (high_score_sram[i][3] == 0x83) && (high_score_sram[i][4] == 0xaa) && (high_score_sram[i][5] == 0x55) && (high_score_sram[i][6] == 0x9c)))
{
// Bad virutal slot memory found... initialize it with the good one
memcpy(high_score_sram[i], high_score_sram[hs_virtual_slot], HS_SRAM_SIZE);
}
}
}
// ---------------------------------------------------------------------------------------
// On the chance that the HS cart 'name' has been altered in the current slot... copy it
// ---------------------------------------------------------------------------------------
for (u8 i=0; i<VIRTUAL_SRAM_BLOCKS; i++)
{
if (i != hs_virtual_slot) // We already know hs_virtual_slot is good
{
// Copy the title from the current slot...
memcpy(&high_score_sram[i][8], &high_score_sram[hs_virtual_slot][8], HSC_TITLE_SIZE);
}
}
last_hs_chksum = chksum;
DIR* dir = opendir("/data");
if (dir) closedir(dir); // Directory exists.
else mkdir("/data", 0777); // Doesn't exist - make it...
FILE* file = fopen("/data/A7800DS.sram", "wb+");
if( file != NULL )
{
if( fwrite( high_score_sram, 1, HS_SRAM_SIZE*VIRTUAL_SRAM_BLOCKS, file ) != HS_SRAM_SIZE*VIRTUAL_SRAM_BLOCKS )
{
status = false;
} else status = true;
fflush(file);
fclose(file);
}
}
}
if (--retries == 0) break;
fwrite(high_score_sram, HS_SRAM_SIZE, 1, handle);
fclose(handle);
}
return status;
return true; // We at least made the attempt to write out the .hsc save file
}
/*
@ -139,73 +229,33 @@ bool cartridge_SaveHighScoreSram(void)
*/
static bool cartridge_LoadHighScoreSram(void)
{
bool status = false;
word retries=3;
// ----------------------------------------------------------------------------------------
// Based on the first character of the cart name, we will pick a virtual high score slot
// This is mainly to spread out the increasingly crowded HSC memory which only supports
// a total of 69 entries (and this includes difficulty settings on a per game basis).
// ----------------------------------------------------------------------------------------
if (toupper(cartridge_filename[0]) <= 'C') hs_virtual_slot = 0;
else if (toupper(cartridge_filename[0]) <= 'F') hs_virtual_slot = 1;
else if (toupper(cartridge_filename[0]) <= 'J') hs_virtual_slot = 2;
else if (toupper(cartridge_filename[0]) <= 'N') hs_virtual_slot = 3;
else if (toupper(cartridge_filename[0]) <= 'Q') hs_virtual_slot = 4;
else if (toupper(cartridge_filename[0]) <= 'T') hs_virtual_slot = 5;
else if (toupper(cartridge_filename[0]) <= 'Z') hs_virtual_slot = 6;
else hs_virtual_slot = 7;
// -------------------------------------------------
// Start with a blank (0xFF) SRAM block in memory
// -------------------------------------------------
for( uint i = 0; i < HS_SRAM_SIZE; i++ )
if(!high_score_cart_loaded || !myCartInfo.hsc)
{
memory_Write( HS_SRAM_START + i, 0xFF);
return false; // If we didn't load the high score cartridge, or don't have an HSC enabled cart: don't save.
}
while (status == false)
{
FILE* file = fopen("/data/A7800DS.sram", "rb" );
if( file == NULL )
{
memset(high_score_sram, 0xFF, HS_SRAM_SIZE*VIRTUAL_SRAM_BLOCKS);
status = false;
}
else
{
word sram_file_size = fread( high_score_sram, 1, HS_SRAM_SIZE*VIRTUAL_SRAM_BLOCKS, file );
if (sram_file_size == HS_SRAM_SIZE) // Older 2K format... replicate this across the new 8 virtual slots!
{
for (u8 i=1; i<VIRTUAL_SRAM_BLOCKS; i++)
{
memcpy(high_score_sram[i], high_score_sram[0], HS_SRAM_SIZE);
}
sram_file_size = HS_SRAM_SIZE*VIRTUAL_SRAM_BLOCKS;
}
make_hsc_name(); // HSC filename is same as base filename with .hsc extension
// Make sure the SRAM memory file is exactly the right size...
if( sram_file_size == HS_SRAM_SIZE*VIRTUAL_SRAM_BLOCKS )
{
last_hs_chksum = 0;
for( uint i = 0; i < HS_SRAM_SIZE; i++ )
{
memory_Write( HS_SRAM_START + i, high_score_sram[hs_virtual_slot][i] );
last_hs_chksum += high_score_sram[hs_virtual_slot][i];
}
status = true;
}
else // Something is wrong... just blank out the SRAM area and let the HSC initialize it
{
memset(high_score_sram, 0xFF, HS_SRAM_SIZE*VIRTUAL_SRAM_BLOCKS);
status = false;
}
fclose(file);
}
if (--retries == 0) break;
// Read back the .hsc file
FILE *handle = fopen(szName, "rb");
if (handle != NULL)
{
fread(high_score_sram, HS_SRAM_SIZE, 1, handle);
fclose(handle);
}
else
{
// No .hsc file was available... so set the SRAM to a known good init value
memcpy(high_score_sram, A7800DS_00_sram, HS_SRAM_SIZE);
}
return status;
// Copy from SRAM buffer to main memory for use by the game
for(uint i = 0; i < HS_SRAM_SIZE; i++)
{
memory_Write(HS_SRAM_START + i, high_score_sram[i]);
}
return true; // We at least made the attempt to write out the .hsc save file
}
/*
@ -217,8 +267,7 @@ bool cartridge_LoadHighScoreCart(void)
{
if( !myCartInfo.hsc || myCartInfo.region != 0 )
{
// Only load the cart if it is enabled and the region is NTSC
return false;
return false; // Only load the cart if it is enabled and the region is NTSC
}
FILE* file = fopen("highscore.rom", "rb" );
@ -227,21 +276,24 @@ bool cartridge_LoadHighScoreCart(void)
if (file == NULL) file = fopen("/roms/bios/highscore.rom", "rb" );
if (file == NULL) file = fopen("/data/bios/highscore.rom", "rb" );
if( file != NULL )
if(file != NULL)
{
fread(high_score_rom, 1, HSC_CART_ROM_SIZE, file );
cartridge_LoadHighScoreSram();
for( uint i = 0; i < HSC_CART_ROM_SIZE; i++ )
{
memory_Write( 0x3000 + i, high_score_rom[i] );
}
high_score_cart_loaded = true;
fread(high_score_rom, 1, HSC_CART_ROM_SIZE, file);
for( uint i = 0; i < HSC_CART_ROM_SIZE; i++ )
{
memory_Write(0x3000 + i, high_score_rom[i]);
}
high_score_cart_loaded = true;
// Now read in the associated .hsc SRAM file
cartridge_LoadHighScoreSram();
}
else
{
high_score_cart_loaded = false;
high_score_cart_loaded = false;
}
return high_score_cart_loaded;
}
// End of file

View file

@ -36,7 +36,6 @@
extern bool cartridge_LoadHighScoreCart(void);
extern bool cartridge_SaveHighScoreSram(void);
extern bool cartridge_SaveHighScoreSram(void);
extern byte high_score_cart_loaded;

View file

@ -133,7 +133,7 @@ ITCM_CODE void memory_Write(word address, byte data)
extern byte banksets_memory[]; extern u16 banksets_mask;
if (!(address & banksets_mask)) banksets_memory[address] = data;
if ((address & 0xF800)) // Base RAM is at 0x1800 so this will find anything that is RAM...
if ((address & 0xF800)) // Base RAM is at 0x1800 and HSC SRAM is at 0x1000 so this will find anything that is RAM...
{
// For banking RAM we need to keep the shadow up to date.
if ((address & 0xC000) == 0x4000)
@ -147,6 +147,8 @@ ITCM_CODE void memory_Write(word address, byte data)
memory_ram[address ^0x0100] = data;
}
}
//else if ((address & 0xF800) == 0x1000) // HSC RAM - someday we might trigger on this and auto-save the .hsc SRAM file
memory_ram[address] = data;
return;
}

View file

@ -1,3 +1,13 @@
// =====================================================================================
// Copyright (c) 2022-2024 Dave Bernazzani (wavemotion-dave)
//
// Copying and distribution of this emulator, it's source code and associated
// readme files, with or without modification, are permitted in any medium without
// royalty provided this copyright notice is used and wavemotion-dave (Phoenix-Edition),
// Alekmaul (original port) and Greg Stanton (ProSystem Emulator) are thanked profusely.
//
// A7800DS emulator is offered as-is, without any warranty.
// =====================================================================================
#include <stdio.h>
#include <fat.h>
#include <nds.h>