Skip to content

Commit

Permalink
Version 2.0 - Major overhaul of the UI!
Browse files Browse the repository at this point in the history
  • Loading branch information
wavemotion-dave committed Mar 19, 2021
1 parent 30b3cb9 commit 08e3ac2
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=1.9a
VERSION=2.0

#---------------------------------------------------------------------------------
.SUFFIXES:
Expand Down
Binary file modified XEGS-DS.nds
Binary file not shown.
Binary file modified arm9/gfx/bgBottom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified arm9/gfx/pdev_bg0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
125 changes: 88 additions & 37 deletions arm9/source/8bitutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ char last_filename[300] = {0};
void dsWriteFavs(int xpos)
{
#if 0
dsPrintValue(xpos,0,0, (char*)"FAVS SAVE");
dsPrintValue(xpos,0,0, (char*)"FAV SAVE");
FILE *fp;
fp = fopen("/roms/A800-Favs.txt", "a+");
if (fp != NULL)
Expand All @@ -127,14 +127,13 @@ void dsWriteFavs(int xpos)
fclose(fp);
}
#else
dsPrintValue(xpos,0,0, (char*)"CONFIG SAVE");
dsPrintValue(xpos,0,0, (char*)"CFG SAVE");
WriteGameSettings();
#endif
WAITVBL;WAITVBL;WAITVBL;WAITVBL;WAITVBL;
dsPrintValue(xpos,0,0, (char*)" ");
dsPrintValue(xpos,0,0, (char*)" ");
}


void dsClearDiskActivity(void)
{
char buf[5];
Expand Down Expand Up @@ -561,17 +560,41 @@ void dsShowRomInfo(void)
sprintf(line2,"%-22s", line1);
dsPrintValue(10,3,0, line2);

dsPrintValue(10,6,0, "D1: ");
sprintf(line1, "D1: %s", (disk_readonly[DISK_1] ? "[R]":"[W]"));
dsPrintValue(10,6,0, line1);
strncpy(line1, disk_filename[DISK_1], 22);
line1[22] = 0;
sprintf(line2,"%-22s", line1);
dsPrintValue(10,7,0, line2);
if (strlen(disk_filename[DISK_1]) > 26)
{
strncpy(line1, &disk_filename[DISK_1][22], 22);
line1[22] = 0;
sprintf(line2,"%-22s", line1);
}
else
{
sprintf(line2,"%-22s", " ");
}
dsPrintValue(10,8,0, line2);

dsPrintValue(10,11,0, "D2: ");
sprintf(line1, "D2: %s", (disk_readonly[DISK_2] ? "[R]":"[W]"));
dsPrintValue(10,11,0, line1);
strncpy(line1, disk_filename[DISK_2], 22);
line1[22] = 0;
sprintf(line2,"%-22s", line1);
dsPrintValue(10,12,0, line2);
if (strlen(disk_filename[DISK_2]) > 26)
{
strncpy(line1, &disk_filename[DISK_2][22], 22);
line1[22] = 0;
sprintf(line2,"%-22s", line1);
}
else
{
sprintf(line2,"%-22s", " ");
}
dsPrintValue(10,13,0, line2);

sprintf(line2, "%-5s %-4s %-4s", (bHaveBASIC ? "BASIC":" "), (ram_size == RAM_128K ? "128K":"320K"), (tv_mode == TV_NTSC ? "NTSC":"PAL "));
dsPrintValue(12,0,0, line2);
Expand All @@ -580,7 +603,7 @@ void dsShowRomInfo(void)

#define HASH_FILE_LEN (128*1024)
unsigned char tempFileBuf[HASH_FILE_LEN];
unsigned char last_hash[33];
unsigned char last_hash[33] = {'1','2','3','4','5','Z',0};
void dsLoadGame(char *filename, int disk_num, bool bRestart, bool bReadOnly)
{
if (strcmp(filename, last_filename) != 0)
Expand All @@ -591,14 +614,17 @@ void dsLoadGame(char *filename, int disk_num, bool bRestart, bool bReadOnly)
}
}

// Get the hash of the file... up to 128k (good enough)
memset(last_hash, 'Z', 33);
FILE *fp = fopen(filename, "rb");
if (fp)
{
unsigned int file_len = fread(tempFileBuf, 1, HASH_FILE_LEN, fp);
hash_Compute((const byte*)tempFileBuf, file_len, (byte *)last_hash);
fclose(fp);
if (disk_num != DISK_2) // Never save D2 as the boot disk...
{
// Get the hash of the file... up to 128k (good enough)
memset(last_hash, 'Z', 33);
FILE *fp = fopen(filename, "rb");
if (fp)
{
unsigned int file_len = fread(tempFileBuf, 1, HASH_FILE_LEN, fp);
hash_Compute((const byte*)tempFileBuf, file_len, (byte *)last_hash);
fclose(fp);
}
}

// Free buffer if needed
Expand Down Expand Up @@ -787,7 +813,6 @@ void dsChooseOptions(int bOkayToChangePalette)
if (Option_Table[idx].label == NULL) break;
}

dsPrintValue(2,22, 0, " UP/DOWN TO SELECT OPTION ");
dsPrintValue(2,23, 0, "A=TOGGLE, B=EXIT, START=SAVE");
optionHighlighted = 0;
while (!bDone)
Expand Down Expand Up @@ -891,8 +916,11 @@ void dsDisplayLoadOptions(void)
dsPrintValue(19,0,0,tmpBuf);
sprintf(tmpBuf, "[%c] READ-ONLY", (bLoadReadOnly ? 'X':' '));
dsPrintValue(14,1,0,tmpBuf);
sprintf(tmpBuf, "[%c] BOOT LOAD", (bLoadAndBoot ? 'Y':' '));
dsPrintValue(14,2,0,tmpBuf);
if (strcmp(file_load_id,"D2")!=0) // For D2: we don't allow boot load
{
sprintf(tmpBuf, "[%c] BOOT LOAD", (bLoadAndBoot ? 'Y':' '));
dsPrintValue(14,2,0,tmpBuf);
}
}

void dsDisplayFiles(unsigned int NoDebGame,u32 ucSel)
Expand Down Expand Up @@ -952,14 +980,23 @@ unsigned int dsWaitForRom(void)

nbRomPerPage = (count8bit>=17 ? 17 : count8bit);
uNbRSPage = (count8bit>=5 ? 5 : count8bit);
if (ucFicAct>count8bit-nbRomPerPage) {
if (ucFicAct>count8bit)
{
firstRomDisplay=0;
ucFicAct=0;
romSelected=0;
}
if (ucFicAct>count8bit-nbRomPerPage)
{
firstRomDisplay=count8bit-nbRomPerPage;
romSelected=ucFicAct-count8bit+nbRomPerPage;
}
else {
else
{
firstRomDisplay=ucFicAct;
romSelected=0;
}

dsDisplayFiles(firstRomDisplay,romSelected);
while (!bDone) {
if (keysCurrent() & KEY_UP) {
Expand Down Expand Up @@ -1115,11 +1152,14 @@ unsigned int dsWaitForRom(void)
static int last_y_key = 0;
if (keysCurrent() & KEY_Y)
{
if (last_y_key != KEY_Y)
if (strcmp(file_load_id,"D2")!=0) // For D2: we don't allow boot load
{
bLoadAndBoot = (bLoadAndBoot ? false:true);
dsDisplayLoadOptions();
last_y_key = KEY_Y;
if (last_y_key != KEY_Y)
{
bLoadAndBoot = (bLoadAndBoot ? false:true);
dsDisplayLoadOptions();
last_y_key = KEY_Y;
}
}
} else last_y_key = 0;

Expand Down Expand Up @@ -1223,6 +1263,12 @@ unsigned int dsWaitOnMenu(unsigned int actState)
{
dsChooseOptions(FALSE);
}
else if ((iTx>230) && (iTx<256) && (iTy>8) && (iTy<30)) // POWER / QUIT
{
soundPlaySample(clickNoQuit_wav, SoundFormat_16Bit, clickNoQuit_wav_size, 22050, 127, 64, false, 0);
bDone=dsWaitOnQuit();
if (bDone) uState=A8_QUITSTDS;
}
else if ((iTx>5) && (iTx<80) && (iTy>12) && (iTy<75)) // cartridge slot (wide range)
{
bDone=true;
Expand Down Expand Up @@ -1627,17 +1673,7 @@ ITCM_CODE void dsMainLoop(void)
}
else
{
if ((iTx>240) && (iTx<256) && (iTy>0) && (iTy<18)) // Full Speed Toggle ... upper corner...
{
if (keys_touch == 0)
{
full_speed = 1-full_speed;
if (full_speed) showFps=1;
dsPrintValue(30,0,0," ");
keys_touch = 1;
}
}
else if ((iTx>=0) && (iTx<16) && (iTy>0) && (iTy<18)) // Show FPS
if ((iTx>=0) && (iTx<16) && (iTy>0) && (iTy<18)) // Show FPS
{
if (keys_touch == 0)
{
Expand Down Expand Up @@ -1677,7 +1713,7 @@ ITCM_CODE void dsMainLoop(void)
bShowKeyboard = true;
keys_touch = 1;
}
else if ((iTx>999) && (iTx<56) && (iTy>89) && (iTy<106)) // POWER TODO:zzz
else if ((iTx>230) && (iTx<256) && (iTy>8) && (iTy<30)) // POWER / QUIT
{
irqDisable(IRQ_TIMER2); fifoSendValue32(FIFO_USER_01,(1<<16) | (0) | SOUND_SET_VOLUME);
soundPlaySample(clickNoQuit_wav, SoundFormat_16Bit, clickNoQuit_wav_size, 22050, 127, 64, false, 0);
Expand Down Expand Up @@ -1741,7 +1777,7 @@ ITCM_CODE void dsMainLoop(void)
{
if ((keys_pressed & KEY_R) && (keys_pressed & KEY_L))
{
dsWriteFavs(4);
dsWriteFavs(3);
}
if ((keys_pressed & KEY_R) && (keys_pressed & KEY_UP)) myGame_offset_y++;
if ((keys_pressed & KEY_R) && (keys_pressed & KEY_DOWN)) myGame_offset_y--;
Expand Down Expand Up @@ -1787,12 +1823,19 @@ int a8Filescmp (const void *c1, const void *c2) {

void a8FindFiles(void)
{
static bool bFirstTime = true;
DIR *pdir;
struct dirent *pent;
char filenametmp[300];

count8bit = countfiles= 0;

// First time load... get into the root directory for easy navigation...
if (bFirstTime)
{
bFirstTime = false;
//TODO: Not sure on this yet... chdir("/");
}
pdir = opendir(".");

if (pdir) {
Expand Down Expand Up @@ -1829,7 +1872,15 @@ void a8FindFiles(void)
closedir(pdir);
}
if (count8bit)
{
qsort (a8romlist, count8bit, sizeof (FICA_A8), a8Filescmp);
}
else // Failsafe... always provide a back directory...
{
a8romlist[count8bit].directory = true;
strcpy(a8romlist[count8bit].filename,"..");
count8bit = 1;
}
}

#define MAX_GAME_SETTINGS 1870
Expand Down
7 changes: 7 additions & 0 deletions arm9/source/emu/atari.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ int disable_basic = TRUE;
int skip_frames = FALSE;

char disk_filename[DISK_MAX][256];
int disk_readonly[DISK_MAX] = {true,true,true};

void Warmstart(void)
{
Expand Down Expand Up @@ -139,6 +140,7 @@ int Atari800_OpenFile(const char *filename, int reboot, int diskno, int readonly
case AFILE_ATR:
strcpy(disk_filename[DISK_XEX], "EMPTY");
strcpy(disk_filename[diskno], filename);
disk_readonly[diskno] = readonly;
if (!SIO_Mount(diskno, filename, readonly))
return AFILE_ERROR;
if (reboot)
Expand Down Expand Up @@ -167,6 +169,11 @@ int Atari800_Initialise(void)
strcpy(disk_filename[DISK_XEX], "EMPTY");
strcpy(disk_filename[DISK_1], "EMPTY");
strcpy(disk_filename[DISK_2], "EMPTY");

disk_readonly[DISK_XEX] = true;
disk_readonly[DISK_1] = true;
disk_readonly[DISK_2] = true;


INPUT_Initialise();

Expand Down
1 change: 1 addition & 0 deletions arm9/source/emu/atari.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ extern int os_type;
#define DISK_MAX 3

extern char disk_filename[DISK_MAX][256];
extern int disk_readonly[DISK_MAX];


/* Fundamental declarations ---------------------------------------------- */
Expand Down
4 changes: 4 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ With those 4 tips, you should be able to get 99% of all games running. There are
--------------------------------------------------------------------------------
History :
--------------------------------------------------------------------------------
V2.0 : 19-Mar-2021 by wavemotion-dave
* Major overhaul of UI.
* Added second disk drive.

V1.9 : 06-Mar-2021 by wavemotion-dave
* New options for B button = DOWN and Key Click Off.
* Improved handling for key clicks so that press and hold will auto-repeat.
Expand Down

0 comments on commit 08e3ac2

Please sign in to comment.