aboutsummaryrefslogtreecommitdiff
path: root/source/nds
diff options
context:
space:
mode:
authorJaedyn Draper2012-12-27 23:19:47 -0800
committerJaedyn Draper2012-12-27 23:19:47 -0800
commit3fff289e60df73b25c483807f5cf73c011804117 (patch)
treed8a44c6256c2a7652b028525054e0e55d756ff15 /source/nds
parent74211924afc184870627c90ce522c4c5743761db (diff)
parentc01a2a42168695233ecc69c4a60ed918e7701fb9 (diff)
downloadsnes9x2005-3fff289e60df73b25c483807f5cf73c011804117.tar.gz
snes9x2005-3fff289e60df73b25c483807f5cf73c011804117.tar.bz2
snes9x2005-3fff289e60df73b25c483807f5cf73c011804117.zip
Merge pull request #26 from Nebuleon/master
Merge to CATSFC 1.10+
Diffstat (limited to 'source/nds')
-rw-r--r--source/nds/bdf_font.c301
-rw-r--r--source/nds/cheats3.cpp206
-rw-r--r--source/nds/draw.c63
-rw-r--r--source/nds/draw.h118
-rw-r--r--source/nds/ds2_main.c53
-rw-r--r--source/nds/ds2sound.h24
-rw-r--r--source/nds/entry.cpp76
-rw-r--r--source/nds/gcheat.c576
-rw-r--r--source/nds/gcheat.h47
-rw-r--r--source/nds/gui.c596
-rw-r--r--source/nds/gui.h76
-rw-r--r--source/nds/message.h4
12 files changed, 664 insertions, 1476 deletions
diff --git a/source/nds/bdf_font.c b/source/nds/bdf_font.c
index 5da57e3..773403a 100644
--- a/source/nds/bdf_font.c
+++ b/source/nds/bdf_font.c
@@ -18,6 +18,7 @@
*/
//v1.1
+#include "port.h"
#include <string.h>
#include "ds2_types.h"
#include "ds2_malloc.h"
@@ -27,13 +28,13 @@
#include "gui.h"
-#define BDF_VERDANA "SYSTEM/verdana.bdf"
+#define BDF_PICTOCHAT "SYSTEM/Pictochat-16.bdf"
#define BDF_SONG "SYSTEM/song.bdf"
-#define ODF_VERDANA "SYSTEM/verdana.odf"
+#define ODF_PICTOCHAT "SYSTEM/Pictochat-16.odf"
#define ODF_SONG "SYSTEM/song.odf"
-#define HAVE_ODF
-//#define DUMP_ODF
+#define HAVE_ODF // Define this if you have generated Pictochat-16.odf [Neb]
+// #define DUMP_ODF // Define this if you want to regenerate Pictochat-16.odf [Neb]
#define BDF_LIB_NUM 2
#define ODF_VERSION "1.0"
@@ -49,21 +50,24 @@ static u32 fonts_max_height;
static u32 bitmap_code(unsigned char *code, unsigned char *bitmap)
{
unsigned char *map;
- u32 a, b, len;
+ u8 a, b;
+ u32 len;
len= 0;
map= (unsigned char*)bitmap;
while(*map)
{
- //character to number, we assume the character can convert to number!
+ // One hex character represents the state of 4 successive pixels
if(*map != 0x0A)
{
- if(*map <= 0x39) a= *map - 0x30;
- else a= *map - 0x37;
+ if (*map <= '9') a= *map - '0';
+ else if (*map <= 'F') a= *map - 'A' + 10;
+ else if (*map <= 'f') a= *map - 'a' + 10;
map++;
- if(*map <= 0x39) b= *map - 0x30;
- else b= *map - 0x37;
+ if (*map <= '9') b= *map - '0';
+ else if (*map <= 'F') b= *map - 'A' + 10;
+ else if (*map <= 'f') b= *map - 'a' + 10;
*code++ = (a << 4) | b;
len++;
@@ -108,7 +112,7 @@ static u32 hatoi(char *string)
/*
* example
*
-* STARTCHAR 2264
+* STARTCHAR <arbitrary number or name>
* ENCODING 8804
* SWIDTH 840 0
* DWIDTH 14 0
@@ -202,8 +206,17 @@ static int parse_bdf(char *filename, u32 start, u32 span, struct bdflibinfo *bdf
pt += 6;
ret= atoi(pt);
- bdflibinfop -> start= start;
- bdflibinfop -> span= span;
+ if (method == 1)
+ bdflibinfop -> start= start;
+ switch (method) {
+ case 0:
+ default:
+ bdflibinfop -> span= span + start;
+ break;
+ case 1:
+ bdflibinfop -> span= span;
+ break;
+ }
//construct bdf font information
bdffontp= (struct bdffont*)malloc(span * sizeof(struct bdffont));
@@ -241,14 +254,7 @@ static int parse_bdf(char *filename, u32 start, u32 span, struct bdflibinfo *bdf
}
if(!(strncasecmp(string, "STARTCHAR ", 10)))
{
- i= hatoi(pt +10);
- if(i < start) continue;
- else if(i < end) break;
- else //Not found the start
- {
- ret= -7;
- goto parse_bdf_error;
- }
+ break;
}
}
@@ -266,7 +272,7 @@ static int parse_bdf(char *filename, u32 start, u32 span, struct bdflibinfo *bdf
pt= string + 9;
index= atoi(pt);
- if(index >= end) break;
+ if(index < start || index >= end) break;
if(method == 0) i= index;
else if(method == 1) i= index-start;
@@ -534,15 +540,15 @@ int BDF_font_init(void)
fonts_max_height= 0;
#ifndef HAVE_ODF
- sprintf(tmp_path, "%s/%s", main_path, BDF_VERDANA);
- err= parse_bdf(tmp_path, 0, 128, &bdflib_info[0], 0);
+ sprintf(tmp_path, "%s/%s", main_path, BDF_PICTOCHAT);
+ err= parse_bdf(tmp_path, 32 /* from SPACE */, 8564 /* to one past the last character, "DOWNWARDS ARROW" */, &bdflib_info[0], 1);
if(err < 0)
{
printf("BDF 0 initial error: %d\n", err);
return -1;
}
#else
- sprintf(tmp_path, "%s/%s", main_path, ODF_VERDANA);
+ sprintf(tmp_path, "%s/%s", main_path, ODF_PICTOCHAT);
err= init_from_odf(tmp_path, &bdflib_info[0]);
if(err < 0)
{
@@ -556,7 +562,7 @@ int BDF_font_init(void)
fonts_max_height = bdflib_info[0].height;
#ifdef DUMP_ODF
- sprintf(tmp_path, "%s/%s", main_path, BDF_VERDANA);
+ sprintf(tmp_path, "%s/%s", main_path, BDF_PICTOCHAT);
err= dump2odf(tmp_path, &bdflib_info[0]);
if(err < 0)
{
@@ -613,7 +619,7 @@ void BDF_font_release(void)
}
}
-/*-----------------------------------------------------------------------------
+/*----------------------------------------------------------------------------
//16-bit color
// Unicode Character
// back is background, 0x8000 is transparence, other are visable colors
@@ -626,26 +632,25 @@ u32 BDF_render16_ucs(void* screen_address, u32 screen_w, u32 v_align, u32 back,
unsigned char cc;
struct bdffont *bdffontp;
- if(ch < 128)
- {
- bdffontp= bdflib_info[0].fonts;
- fonts_height= bdflib_info[0].height;
- }
- else if(bdflib_info[1].fonts != NULL)
- {
- k= bdflib_info[1].start;
- m= k + bdflib_info[1].span;
- if(ch >= k && ch < m)
- {
+ int font_num;
+ bool found = 0;
+ for (font_num = 0; font_num < BDF_LIB_NUM && !found; font_num++) {
+ if(bdflib_info[font_num].fonts != NULL)
+ {
+ k = bdflib_info[font_num].start;
+ if (ch < k)
+ continue;
+ m = k + bdflib_info[font_num].span;
+ if (ch >= m)
+ continue;
ch -= k;
- bdffontp= bdflib_info[1].fonts;
- fonts_height= bdflib_info[0].height;
- }
- else
- return 8;
- }
- else
- return 8;
+ bdffontp= bdflib_info[font_num].fonts;
+ fonts_height= bdflib_info[font_num].height;
+ found = 1;
+ }
+ }
+ if (!found)
+ return 8; // the width of an undefined character, not an error code
width= bdffontp[ch].dwidth >> 16;
ret= width;
@@ -715,6 +720,27 @@ u32 BDF_render16_ucs(void* screen_address, u32 screen_w, u32 v_align, u32 back,
return ret;
}
+/* Returns the width, in pixels, of a character given its UCS-16 codepoint. */
+u32 BDF_width16_ucs(u16 ch)
+{
+ u32 k, ret;
+
+ int font_num;
+ for (font_num = 0; font_num < BDF_LIB_NUM; font_num++) {
+ if(bdflib_info[font_num].fonts != NULL)
+ {
+ k = bdflib_info[font_num].start;
+ if (ch < k)
+ continue;
+ if (ch > k + bdflib_info[font_num].span)
+ continue;
+ ch -= k;
+ return bdflib_info[font_num].fonts[ch].dwidth >> 16;
+ }
+ }
+ return 8; // the width of an undefined character, not an error code
+}
+
/*-----------------------------------------------------------------------------
//16-bit color
// ASCII Character
@@ -837,101 +863,101 @@ void BDF_render_string(void* screen_address, u32 x, u32 y, u32 back, u32 front,
/*-----------------------------------------------------------------------------
------------------------------------------------------------------------------*/
-char* utf8decode(char *utf8, u16 *ucs)
-{
- unsigned char c = *utf8++;
- unsigned long code;
- int tail = 0;
-
- if ((c <= 0x7f) || (c >= 0xc2)) {
- /* Start of new character. */
- if (c < 0x80) { /* U-00000000 - U-0000007F, 1 byte */
- code = c;
- } else if (c < 0xe0) { /* U-00000080 - U-000007FF, 2 bytes */
- tail = 1;
- code = c & 0x1f;
- } else if (c < 0xf0) { /* U-00000800 - U-0000FFFF, 3 bytes */
- tail = 2;
- code = c & 0x0f;
- } else if (c < 0xf5) { /* U-00010000 - U-001FFFFF, 4 bytes */
- tail = 3;
- code = c & 0x07;
- } else {
- /* Invalid size. */
- code = 0;
- }
-
- while (tail-- && ((c = *utf8++) != 0)) {
- if ((c & 0xc0) == 0x80) {
- /* Valid continuation character. */
- code = (code << 6) | (c & 0x3f);
-
- } else {
- /* Invalid continuation char */
- code = 0xfffd;
- utf8--;
- break;
- }
- }
- } else {
- /* Invalid UTF-8 char */
- code = 0;
- }
- /* currently we don't support chars above U-FFFF */
- *ucs = (code < 0x10000) ? code : 0;
- return utf8;
-}
-
-static u8 utf8_ucs2(const char *utf8, u16 *ucs)
+char* utf8decode(char *utf8, u16 *ucs)
+{
+ unsigned char c = *utf8++;
+ unsigned long code;
+ int tail = 0;
+
+ if ((c <= 0x7f) || (c >= 0xc2)) {
+ /* Start of new character. */
+ if (c < 0x80) { /* U-00000000 - U-0000007F, 1 byte */
+ code = c;
+ } else if (c < 0xe0) { /* U-00000080 - U-000007FF, 2 bytes */
+ tail = 1;
+ code = c & 0x1f;
+ } else if (c < 0xf0) { /* U-00000800 - U-0000FFFF, 3 bytes */
+ tail = 2;
+ code = c & 0x0f;
+ } else if (c < 0xf5) { /* U-00010000 - U-001FFFFF, 4 bytes */
+ tail = 3;
+ code = c & 0x07;
+ } else {
+ /* Invalid size. */
+ code = 0;
+ }
+
+ while (tail-- && ((c = *utf8++) != 0)) {
+ if ((c & 0xc0) == 0x80) {
+ /* Valid continuation character. */
+ code = (code << 6) | (c & 0x3f);
+
+ } else {
+ /* Invalid continuation char */
+ code = 0xfffd;
+ utf8--;
+ break;
+ }
+ }
+ } else {
+ /* Invalid UTF-8 char */
+ code = 0;
+ }
+ /* currently we don't support chars above U-FFFF */
+ *ucs = (code < 0x10000) ? code : 0;
+ return utf8;
+}
+
+static u8 utf8_ucs2(const char *utf8, u16 *ucs)
{
char *pt = (char*)utf8;
-
- while(*pt !='\0')
- {
- pt = utf8decode(pt, ucs++);
- }
- *ucs = '\0';
- return 0;
-}
-
-static u32 ucslen(const u16 *ucs)
-{
+
+ while(*pt !='\0')
+ {
+ pt = utf8decode(pt, ucs++);
+ }
+ *ucs = '\0';
+ return 0;
+}
+
+static u32 ucslen(const u16 *ucs)
+{
u32 len = 0;
-
- while(ucs[len] != '\0')
- len++;
- return len;
+
+ while(ucs[len] != '\0')
+ len++;
+ return len;
}
unsigned char* skip_utf8_unit(unsigned char* utf8, unsigned int num)
{
while(num--)
{
- unsigned char c = *utf8++;
- int tail = 0;
- if ((c <= 0x7f) || (c >= 0xc2)) {
- /* Start of new character. */
- if (c < 0x80) { /* U-00000000 - U-0000007F, 1 byte */
- } else if (c < 0xe0) { /* U-00000080 - U-000007FF, 2 bytes */
- tail = 1;
- } else if (c < 0xf0) { /* U-00000800 - U-0000FFFF, 3 bytes */
- tail = 2;
- } else if (c < 0xf5) { /* U-00010000 - U-001FFFFF, 4 bytes */
- tail = 3;
- } else { /* Invalid size. */
- }
-
- while (tail-- && ((c = *utf8++) != 0)) {
- if ((c & 0xc0) != 0x80) {
- /* Invalid continuation char */
- utf8--;
- break;
- }
- }
+ unsigned char c = *utf8++;
+ int tail = 0;
+ if ((c <= 0x7f) || (c >= 0xc2)) {
+ /* Start of new character. */
+ if (c < 0x80) { /* U-00000000 - U-0000007F, 1 byte */
+ } else if (c < 0xe0) { /* U-00000080 - U-000007FF, 2 bytes */
+ tail = 1;
+ } else if (c < 0xf0) { /* U-00000800 - U-0000FFFF, 3 bytes */
+ tail = 2;
+ } else if (c < 0xf5) { /* U-00010000 - U-001FFFFF, 4 bytes */
+ tail = 3;
+ } else { /* Invalid size. */
+ }
+
+ while (tail-- && ((c = *utf8++) != 0)) {
+ if ((c & 0xc0) != 0x80) {
+ /* Invalid continuation char */
+ utf8--;
+ break;
+ }
+ }
}
}
- /* currently we don't support chars above U-FFFF */
+ /* currently we don't support chars above U-FFFF */
return utf8;
}
@@ -971,10 +997,9 @@ void BDF_render_mix(void* screen_address, u32 screen_w, u32 x, u32 y, u32 v_alig
continue;
}
- if(unicode < 128)
- cmp = bdf_fontp[0][unicode].dwidth>>16;
- else if(unicode >= start && unicode < end)
- cmp = bdf_fontp[1][unicode -start].dwidth>>16;
+ /* If the text would go beyond the end of the line, go back to the
+ * start instead. */
+ cmp = BDF_width16_ucs(unicode);
if((screenp+cmp) >= line_start)
{
@@ -1074,10 +1099,7 @@ u32 BDF_cut_unicode(u16 *unicodes, u32 len, u32 width, u32 direction)
while(len > 0)
{
unicode= unicodes[i];
- if(unicode < 128)
- xw += bdf_fontp[0][unicode].dwidth>>16;
- else if(unicode >= start && unicode < end)
- xw += bdf_fontp[1][unicode -start].dwidth>>16;
+ xw += BDF_width16_ucs(unicode);
if(xw >= width) break;
i += direction;
@@ -1096,10 +1118,7 @@ u32 BDF_cut_unicode(u16 *unicodes, u32 len, u32 width, u32 direction)
while(len-- > 0)
{
unicode= unicodes[i];
- if(unicode < 128)
- xw += bdf_fontp[0][unicode].dwidth>>16;
- else if(unicode >= start && unicode < end)
- xw += bdf_fontp[1][unicode -start].dwidth>>16;
+ xw += BDF_width16_ucs(unicode);
i += direction;
}
diff --git a/source/nds/cheats3.cpp b/source/nds/cheats3.cpp
deleted file mode 100644
index bdb5545..0000000
--- a/source/nds/cheats3.cpp
+++ /dev/null
@@ -1,206 +0,0 @@
-/* cheats3.cpp
- *
- * Copyright (C) 2010 dking <dking024@gmail.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public Licens e 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#include "snes9x.h"
-#include "cheats.h"
-#include "memmap.h"
-#include "gcheat.h"
-
-extern SCheatData Cheat;
-
-int S9xAddCheat_ex (unsigned int address, unsigned char* cheat_dat, unsigned int cheat_dat_len,
- unsigned int cheat_cell_num, unsigned int part_id, unsigned int str_num)
-{
- if(cheat_cell_num < MAX_CHEATS_T)
- {
- Cheat.c[cheat_cell_num].address = address;
- Cheat.c[cheat_cell_num].enabled = FALSE;
-
- if(cheat_dat_len > 1)
- memcpy(Cheat.c[cheat_cell_num].name, cheat_dat, cheat_dat_len);
- else
- Cheat.c[cheat_cell_num].byte = cheat_dat[0];
-
- Cheat.c[cheat_cell_num].total_part = 0; //default are sub-part
- Cheat.c[cheat_cell_num].part_id = part_id;
- Cheat.c[cheat_cell_num].part_len = cheat_dat_len;
- Cheat.c[cheat_cell_num].cheat_type = 0; //default are sub-part
- Cheat.c[cheat_cell_num].name_id = str_num;
-
- return 0;
- }
-
- return -1;
-}
-
-void S9xAddCheat_ov(unsigned int cheat_cell_num, unsigned int total_part)
-{
- if(cheat_cell_num < MAX_CHEATS_T)
- {
- Cheat.c[cheat_cell_num].total_part = total_part; //default are sub-part
- Cheat.c[cheat_cell_num].cheat_type = 0x80;
- }
-}
-
-static unsigned int S9xGetSub_id(unsigned int start, unsigned int sub_part)
-{
- unsigned int i, m, n;
-
- if(0 == sub_part)
- return start;
-
- if((start+1) >= g_cheat_cell_num)
- return start;
-
- m = 0;
- for(i= start; i < g_cheat_cell_num; )
- {
- n = Cheat.c[i].total_part;
- i += n;
- m += 1;
- if(m == sub_part) break;
- }
-
- return i;
-}
-
-unsigned int S9xGetCheat_nameid(unsigned int start, unsigned int part)
-{
-#if 0
- unsigned int m, n, i;
- unsigned int ret;
- unsigned int cell_num;
-
- cell_num = g_cheat_cell_num;
-
- ret = Cheat.c[start].name_id;
- if((start+1) >= cell_num)
- return ret;
-
- m = 0;
- for(i = start; i < cell_num; ) {
- if(m == part) break;
- n = Cheat.c[i].total_part;
- i += n;
- m += 1;
- }
-
- if(i < cell_num)
- ret = Cheat.c[i].name_id;
-
- return ret;
-#else
- unsigned int i;
-
- i = S9xGetSub_id(start, part);
- return Cheat.c[i].name_id;
-#endif
-}
-
-void S9xCheat_switch(unsigned int start, unsigned int sub_part, unsigned int enable)
-{
- unsigned int i, m, n;
-
- if((start+1) >= g_cheat_cell_num)
- return;
-
- i = S9xGetSub_id(start, sub_part);
- m = Cheat.c[i].total_part;
- for(n = 0; n < m; n++)
- Cheat.c[i+n].enabled = enable;
-}
-
-static inline void S9xApplyCheat_ex(unsigned int start, unsigned int num)
-{
- unsigned int i, m;
- unsigned int address, len;
-
- for(i = 0; i < num; i++)
- {
- address = Cheat.c[start+i].address;
- len = Cheat.c[start+i].part_len;
-
- int block = (address >> MEMMAP_SHIFT) & MEMMAP_MASK;
- unsigned char *ptr = Memory.Map [block];
-
- if(1 == len)
- {
- if (ptr >= (uint8 *) CMemory::MAP_LAST)
- *(ptr + (address & 0xffff)) = Cheat.c[start+i].byte;
- else
- S9xSetByte (Cheat.c[start+i].byte, address);
- }
- else
- {
- for(m= 0; m < len; m++)
- {
- if (ptr >= (uint8 *) CMemory::MAP_LAST)
- *(ptr + (address & 0xffff)) = Cheat.c[start+i].name[m];
- else
- S9xSetByte (Cheat.c[start+i].name[m], address);
- }
- }
- }
-}
-
-void S9xApplyCheats_ex(void)
-{
- unsigned int i, m, n;
-
- if (Settings.ApplyCheats)
- {
- for(i= 0; i < g_cheat_cell_num; i++)
- {
- m = Cheat.c[i].total_part;
- if(Cheat.c[i].enabled)
- S9xApplyCheat_ex(i, m);
- i += m;
- }
- }
-}
-
-#if 1
-extern "C" void dump_mem(unsigned char* addr, unsigned int len);
-
-void S9x_dumpcheat(unsigned int id)
-{
- cprintf("\nid %d------------\n", id);
- cprintf("total %d; part %d\n", Cheat.c[id].total_part, Cheat.c[id].part_id);
- cprintf("address: %08x; data: %d\n", Cheat.c[id].address, Cheat.c[id].part_len);
- if(Cheat.c[id].part_len == 1)
- cprintf("data: %02x\n", Cheat.c[id].byte);
- else
- dump_mem((unsigned char*)Cheat.c[id].name, Cheat.c[id].part_len);
- cprintf(" ------\n");
-}
-#endif
-
-void S9xCheat_Disable(void)
-{
- Settings.ApplyCheats = FALSE;
-}
-
-void S9xCheat_Enable(void)
-{
- Settings.ApplyCheats = TRUE;
-}
-
diff --git a/source/nds/draw.c b/source/nds/draw.c
index 6223c6e..2a9e440 100644
--- a/source/nds/draw.c
+++ b/source/nds/draw.c
@@ -22,6 +22,7 @@
* draw.cpp
* basic program to draw some graphic
******************************************************************************/
+#include "port.h"
#include <string.h>
#include <stdio.h>
#include "ds2_malloc.h"
@@ -810,7 +811,7 @@ u32 draw_yesno_dialog(enum SCREEN_ID screen, u32 sy, char *yes, char *no)
// draw_string_vcenter(screen_address, i+1, sy+1, box_width, COLOR_WHITE, no);
draw_string_vcenter((unsigned short*)screen_addr, 138, 130, 58, COLOR_WHITE, no);
- ds2_flipScreen(screen, 1);
+ ds2_flipScreen(screen, 2);
gui_action_type gui_action = CURSOR_NONE;
while((gui_action != CURSOR_SELECT) && (gui_action != CURSOR_BACK))
@@ -859,7 +860,7 @@ void init_progress(enum SCREEN_ID screen, u32 total, char *text)
drawboxfill((unsigned short*)screen_addr, progress_sx, progress_sy, progress_ex,
progress_ey, COLOR16(15, 15, 15));
- ds2_flipScreen(_progress_screen_id, 1);
+ ds2_flipScreen(_progress_screen_id, 2);
}
// update progress bar
@@ -882,7 +883,7 @@ void update_progress(void)
drawboxfill(screen_addr, progress_sx, progress_sy, progress_sx+width, progress_ey, COLOR16(30, 19, 7));
- ds2_flipScreen(_progress_screen_id, 1);
+ ds2_flipScreen(_progress_screen_id, 2);
}
// display progress string
@@ -907,7 +908,7 @@ void show_progress(char *text)
// if (text[0] != '\0')
// print_string_center(progress_sy - 21, COLOR_PROGRESS_TEXT, COLOR_DIALOG, text);
- ds2_flipScreen(_progress_screen_id, 1);
+ ds2_flipScreen(_progress_screen_id, 2);
// OSTimeDly(progress_wait);
mdelay(500);
@@ -1273,57 +1274,11 @@ void show_log(void* screen_addr)
}
/*************************************************************/
-extern const unsigned char font_map[128][8];
-
-//font size 8*8
-static inline void drawfont(unsigned short *addr, unsigned short f_color, unsigned short b_color, unsigned char ch)
-{
- unsigned char *dot_map;
- unsigned int j, k;
- unsigned char dot;
- unsigned short *dst;
-
- dot_map = (unsigned char*)font_map[ch&0x7F];
-
- for(j= 0; j < 8; j++)
- {
- dot = *dot_map++;
- dst = addr + j*SCREEN_WIDTH;
- for(k = 0; k < 8; k++)
- *dst++ = (dot & (0x80>>k)) ? f_color : b_color;
- }
-}
-
-static void drawstring(unsigned int x, unsigned int y, enum SCREEN_ID screen, char *string,
- unsigned short f_color, unsigned short b_color)
-{
- unsigned short *scr_addr, *dst;
-
- if(screen & UP_MASK)
- scr_addr = up_screen_addr;
- else
- scr_addr = down_screen_addr;
-
- if(x>= 32 || y>= 24) return;
-
- while(*string)
- {
- dst = scr_addr + (y*8)*SCREEN_WIDTH + x*8;
- drawfont(dst, f_color, b_color, *string++);
-
- x += 1;
- if(x>= 32)
- {
- x = 0;
- y+= 1;
- if(y >= 24) break;
- }
- }
-}
-
void err_msg(enum SCREEN_ID screen, char *msg)
{
- drawstring(0, 0, screen, msg, COLOR16(16, 16, 16), COLOR16(0, 0, 0));
+ // A wild console appeared!
+ ConsoleInit(RGB15(31, 31, 31), RGB15(0, 0, 0), UP_SCREEN, 512);
+ printf(msg);
}
/*
@@ -1372,5 +1327,3 @@ void blit_to_screen(void* screen_addr, u16 *src, u32 w, u32 h, u32 dest_x, u32 d
*dst++ = *src++;
}
}
-
-
diff --git a/source/nds/draw.h b/source/nds/draw.h
index 3bdf5be..f40aa23 100644
--- a/source/nds/draw.h
+++ b/source/nds/draw.h
@@ -17,8 +17,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef __DRAW_H__
-#define __DRAW_H__
+#ifndef __DRAW_H__
+#define __DRAW_H__
#include "ds2_types.h"
#include "ds2io.h"
@@ -27,12 +27,12 @@
#define NDS_SCREEN_WIDTH 256
#define NDS_SCREEN_HEIGHT 192
#define NDS_SCREEN_SIZE (NDS_SCREEN_WIDTH*NDS_SCREEN_HEIGHT)
-
-#define COLOR16(red, green, blue) ((blue << 10) | (green << 5) | red)
-#define GET_R16(color) (color & 0x1f)
-#define GET_G16(color) ((color >> 5) & 0x1f)
-#define GET_B16(color) ((color >> 10)& 0x1f)
-#define COLOR32(red, green, blue) (0xff000000 | ((blue & 0xff) << 16) | ((green & 0xff) << 8) | (red & 0xff))
+
+#define COLOR16(red, green, blue) ((blue << 10) | (green << 5) | red)
+#define GET_R16(color) (color & 0x1f)
+#define GET_G16(color) ((color >> 5) & 0x1f)
+#define GET_B16(color) ((color >> 10)& 0x1f)
+#define COLOR32(red, green, blue) (0xff000000 | ((blue & 0xff) << 16) | ((green & 0xff) << 8) | (red & 0xff))
#define RGB24_15(pixel) ((((*pixel) & 0xF8) << 7) |\
(((*(pixel+1)) & 0xF8) << 2) |\
@@ -44,36 +44,36 @@
#define PRINT_STRING(screen, str, fg_color, x, y) \
- BDF_render_string(screen, x, y, COLOR_TRANS, fg_color, str) \
+ BDF_render_mix(screen, SCREEN_WIDTH, x, y, 0, COLOR_TRANS, fg_color, str) \
#define PRINT_STRING_SHADOW(screen, str, fg_color, x, y) \
- BDF_render_string(screen, x+1, y+1, 0, 0, str); \
- BDF_render_string(screen, x, y, 0, 0, str) \
+ BDF_render_mix(screen, SCREEN_WIDTH, x+1, y+1, 0, 0, 0, str); \
+ BDF_render_mix(screen, SCREEN_WIDTH, x, y, 0, 0, 0, str) \
#define PRINT_STRING_BG(screen, str, fg_color, bg_color, x, y) \
- BDF_render_string(screen, x, y, bg_color, fg_color, str) \
+ BDF_render_mix(screen, SCREEN_WIDTH, x, y, 0, bg_color, fg_color, str) \
+
+// #define PRINT_STRING_BG_UTF8(screen, utf8, fg_color, bg_color, x, y) \
+// BDF_render_mix(screen, SCREEN_WIDTH, x, y, 0, bg_color, fg_color, utf8) \
-#define PRINT_STRING_BG_UTF8(screen, utf8, fg_color, bg_color, x, y) \
- BDF_render_mix(screen, SCREEN_WIDTH, x, y, 0, bg_color, fg_color, utf8) \
-
//colors
-#define COLOR_TRANS COLOR16(31, 31, 63)
-#define COLOR_WHITE COLOR16(31, 31, 31)
-#define COLOR_BLACK COLOR16( 0, 0, 0)
-#define COLOR_TEXT COLOR16(31, 31, 31)
-#define COLOR_PROGRESS_TEXT COLOR16( 0, 0, 0)
-#define COLOR_PROGRESS_BAR COLOR16(15, 15, 15)
-#define COLOR_ERROR COLOR16(31, 0, 0)
-#define COLOR_BG COLOR16(2, 4, 10)
-#define COLOR_BG32 COLOR32(2*8, 4*8, 10*8)
-#define COLOR_ROM_INFO COLOR16(22, 18, 26)
-#define COLOR_ACTIVE_ITEM COLOR16(31, 31, 31)
-#define COLOR_INACTIVE_ITEM COLOR16(13, 20, 18)
-#define COLOR_HELP_TEXT COLOR16(16, 20, 24)
-#define COLOR_DIALOG COLOR16(31, 31, 31)
-#define COLOR_DIALOG_SHADOW COLOR16( 0, 2, 8)
-#define COLOR_FRAME COLOR16( 0, 0, 0)
+#define COLOR_TRANS COLOR16(31, 31, 63)
+#define COLOR_WHITE COLOR16(31, 31, 31)
+#define COLOR_BLACK COLOR16( 0, 0, 0)
+#define COLOR_TEXT COLOR16(31, 31, 31)
+#define COLOR_PROGRESS_TEXT COLOR16( 0, 0, 0)
+#define COLOR_PROGRESS_BAR COLOR16(15, 15, 15)
+#define COLOR_ERROR COLOR16(31, 0, 0)
+#define COLOR_BG COLOR16(2, 4, 10)
+#define COLOR_BG32 COLOR32(2*8, 4*8, 10*8)
+#define COLOR_ROM_INFO COLOR16(22, 18, 26)
+#define COLOR_ACTIVE_ITEM COLOR16(31, 31, 31)
+#define COLOR_INACTIVE_ITEM COLOR16(13, 20, 18)
+#define COLOR_HELP_TEXT COLOR16(16, 20, 24)
+#define COLOR_DIALOG COLOR16(31, 31, 31)
+#define COLOR_DIALOG_SHADOW COLOR16( 0, 2, 8)
+#define COLOR_FRAME COLOR16( 0, 0, 0)
#define COLOR_YESNO_TEXT COLOR16( 0, 0, 0)
#define COLOR_GREEN COLOR16( 0, 31, 0 )
#define COLOR_GREEN1 COLOR16( 0, 24, 0 )
@@ -81,14 +81,14 @@
#define COLOR_GREEN3 COLOR16( 0, 12, 0 )
#define COLOR_GREEN4 COLOR16( 0, 6, 0 )
#define COLOR_RED COLOR16( 31, 0, 0 )
-#define COLOR_MSSG COLOR16( 16, 8, 29)
-/******************************************************************************
- *
+#define COLOR_MSSG COLOR16( 16, 8, 29)
+/******************************************************************************
+ *
******************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
-
+
struct background{
char bgname[128];
char bgbuffer[256*192*2];
@@ -151,17 +151,17 @@ extern struct gui_iconlist gui_icon_list[];
#define ICON_CHTFILE gui_icon_list[38]
#define ICON_MSG gui_icon_list[39]
#define ICON_BUTTON gui_icon_list[40]
-
-/******************************************************************************
- *
- ******************************************************************************/
+
+/******************************************************************************
+ *
+ ******************************************************************************/
extern void print_string_center(void* screen_addr, u32 sy, u32 color, u32 bg_color, char *str);
-extern void print_string_shadow_center(void* screen_addr, u32 sy, u32 color, char *str);
-extern void hline(u32 sx, u32 ex, u32 y, u32 color);
-extern void hline_alpha(u32 sx, u32 ex, u32 y, u32 color, u32 alpha);
-extern void vline(u32 x, u32 sy, u32 ey, u32 color);
-extern void vline_alpha(u32 x, u32 sy, u32 ey, u32 color, u32 alpha);
-extern void drawbox(void* screen_address, u32 sx, u32 sy, u32 ex, u32 ey, u32 color);
+extern void print_string_shadow_center(void* screen_addr, u32 sy, u32 color, char *str);
+extern void hline(u32 sx, u32 ex, u32 y, u32 color);
+extern void hline_alpha(u32 sx, u32 ex, u32 y, u32 color, u32 alpha);
+extern void vline(u32 x, u32 sy, u32 ey, u32 color);
+extern void vline_alpha(u32 x, u32 sy, u32 ey, u32 color, u32 alpha);
+extern void drawbox(void* screen_address, u32 sx, u32 sy, u32 ex, u32 ey, u32 color);
extern void drawboxfill(void* screen_address, u32 sx, u32 sy, u32 ex, u32 ey, u32 color);
extern void draw_selitem(void* screen_address, u32 x, u32 y, u32 color, u32 active);
extern void draw_message(void* screen_address, u16 *screen_bg, u32 sx, u32 sy, u32 ex, u32 ey,
@@ -173,19 +173,19 @@ extern void draw_string_vcenter(void* screen_address, u32 sx, u32 sy, u32 width,
extern u32 draw_hscroll_init(void* screen_address, u32 sx, u32 sy, u32 width,
u32 color_bg, u32 color_fg, char *string);
extern u32 draw_hscroll(u32 index, s32 scroll_val);
-extern void draw_hscroll_over(u32 index);
-extern void boxfill_alpha(u32 sx, u32 sy, u32 ex, u32 ey, u32 color, u32 alpha);
-extern void init_progress(enum SCREEN_ID screen, u32 total, char *text);
-extern void update_progress(void);
-extern void show_progress(char *text);
-extern void scrollbar(void* screen_addr, u32 sx, u32 sy, u32 ex, u32 ey, u32 all, u32 view, u32 now);
+extern void draw_hscroll_over(u32 index);
+extern void boxfill_alpha(u32 sx, u32 sy, u32 ex, u32 ey, u32 color, u32 alpha);
+extern void init_progress(enum SCREEN_ID screen, u32 total, char *text);
+extern void update_progress(void);
+extern void show_progress(char *text);
+extern void scrollbar(void* screen_addr, u32 sx, u32 sy, u32 ex, u32 ey, u32 all, u32 view, u32 now);
extern u32 yesno_dialog(char *text);
-extern u32 draw_yesno_dialog(enum SCREEN_ID screen, u32 sy, char *yes, char *no);
-extern void msg_screen_init(const char *title);
-extern void msg_screen_draw();
-extern void msg_printf(const char *text, ...);
-extern void msg_screen_clear(void);
-extern void msg_set_text_color(u32 color);
+extern u32 draw_yesno_dialog(enum SCREEN_ID screen, u32 sy, char *yes, char *no);
+extern void msg_screen_init(const char *title);
+extern void msg_screen_draw();
+extern void msg_printf(const char *text, ...);
+extern void msg_screen_clear(void);
+extern void msg_set_text_color(u32 color);
extern int icon_init(u32 language_id);
extern int gui_change_icon(u32 language_id);
@@ -203,5 +203,5 @@ extern void blit_to_screen(void* screen_addr, u16 *src, u32 w, u32 h, u32 dest_x
}
#endif
-#endif //__DRAW_H__
-
+#endif //__DRAW_H__
+
diff --git a/source/nds/ds2_main.c b/source/nds/ds2_main.c
index 710215b..7229727 100644
--- a/source/nds/ds2_main.c
+++ b/source/nds/ds2_main.c
@@ -15,19 +15,20 @@
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdio.h>
-#include "console.h"
-#include "fs_api.h"
+ */
+
+#include <stdio.h>
+#include "console.h"
+#include "fs_api.h"
#include "ds2io.h"
#include "ds2_timer.h"
#include "ds2_malloc.h"
-
-#define BLACK_COLOR RGB15(0, 0, 0)
-#define WHITE_COLOR RGB15(31, 31, 31)
-
-extern int sfc_main (int argc, char **argv);
+#include "ds2sound.h"
+
+#define BLACK_COLOR RGB15(0, 0, 0)
+#define WHITE_COLOR RGB15(31, 31, 31)
+
+extern int sfc_main (int argc, char **argv);
#if 0
void ddump_mem(unsigned char* addr, unsigned int len)
@@ -42,24 +43,22 @@ void ddump_mem(unsigned char* addr, unsigned int len)
}
#endif
+void ds2_main(void)
+{
+ int err;
+ ds2_setCPUclocklevel(13);
+ //Initial video and audio and other input and output
+ err = ds2io_initb(DS2_BUFFER_SIZE, SND_SAMPLE_RATE, 0, 0);
+ if(err) goto _failure;
-
-void ds2_main(void)
-{
- int err;
-ds2_setCPUclocklevel(13);
- //Initial video and audio and other input and output
- err = ds2io_initb(512, 22050, 0, 0);
- if(err) goto _failure;
+ //Initial file system
+ err = fat_init();
+ if(err) goto _failure;
- //Initial file system
- err = fat_init();
- if(err) goto _failure;
+ //go to user main funtion
+ sfc_main (0, 0);
- //go to user main funtion
- sfc_main (0, 0);
-
_failure:
- ds2_plug_exit();
-}
-
+ ds2_plug_exit();
+}
+
diff --git a/source/nds/ds2sound.h b/source/nds/ds2sound.h
new file mode 100644
index 0000000..cf37f6f
--- /dev/null
+++ b/source/nds/ds2sound.h
@@ -0,0 +1,24 @@
+// The sound buffer sizes used on the DS2's side, for each value of
+// Settings.SoundPlaybackRate.
+#define DS2_BUFFER_SIZE_1 256
+#define DS2_BUFFER_SIZE_2 256
+#define DS2_BUFFER_SIZE_3 256
+#define DS2_BUFFER_SIZE_4 512
+#define DS2_BUFFER_SIZE_5 512
+#define DS2_BUFFER_SIZE_6 1024
+#define DS2_BUFFER_SIZE_7 1024
+
+// The sampling rate for the sound, in Hz, for each value of
+// Settings.SoundPlaybackRate.
+#define SND_SAMPLE_RATE_1 8000
+#define SND_SAMPLE_RATE_2 11025
+#define SND_SAMPLE_RATE_3 16000
+#define SND_SAMPLE_RATE_4 22050
+#define SND_SAMPLE_RATE_5 32000
+#define SND_SAMPLE_RATE_6 44100
+#define SND_SAMPLE_RATE_7 48000
+
+// Settings in use. The number should match in all three settings.
+#define DS2_BUFFER_SIZE DS2_BUFFER_SIZE_7
+#define SND_SAMPLE_RATE SND_SAMPLE_RATE_7
+#define SNES9X_SRATE_ID 7
diff --git a/source/nds/entry.cpp b/source/nds/entry.cpp
index d3dbae3..33566d5 100644
--- a/source/nds/entry.cpp
+++ b/source/nds/entry.cpp
@@ -20,6 +20,7 @@
#include "draw.h"
#include "gui.h"
+#include "ds2sound.h"
void S9xProcessSound (unsigned int);
@@ -90,13 +91,15 @@ void S9xParseDisplayArg (char **argv, int &ind, int)
void S9xExit ()
{
+ ds2_setCPUclocklevel(13); // Crank it up to exit quickly
if(Settings.SPC7110)
(*CleanUp7110)();
S9xSetSoundMute (TRUE);
S9xDeinitDisplay ();
Memory.SaveSRAM (S9xGetFilename (".srm"));
- S9xSaveCheatFile (S9xGetFilename (".cht"));
+ // S9xSaveCheatFile (S9xGetFilename (".chb")); // cheat binary file
+ // Do this when loading a cheat file!
Memory.Deinit ();
S9xDeinitAPU ();
@@ -172,12 +175,10 @@ bool8 S9xDeinitUpdate (int Width, int Height, bool8 /*sixteen_bit*/)
break;
}
-
-// memcpy(up_screen_addr, GFX.Screen, 256*192*2);
-// memcpy(down_screen_addr, GFX.Screen+256*192*2, 256*(224-192)*2);
-
- ds2_flipScreen(UP_SCREEN, 0);
-// ds2_flipScreen(DOWN_SCREEN, 0);
+ ds2_flipScreen(UP_SCREEN, UP_SCREEN_UPDATE_METHOD);
+ // A problem with update method 1 (wait, double buffer) means that, after
+ // about 15 minutes of play time, the screen starts to half-redraw every
+ // frame. With update method 0, this is mitigated. (Method 2 is too slow.)
return (TRUE);
}
@@ -262,7 +263,6 @@ const char *S9xGetSnapshotDirectory ()
return ((const char*)DEFAULT_RTS_DIR);
}
-
const char *S9xGetFilename (const char *ex)
{
static char filename [PATH_MAX + 1];
@@ -341,12 +341,10 @@ void game_disableAudio()
{
if( game_enable_audio == 1)
{
- Settings.APUEnabled = Settings.NextAPUEnabled = TRUE;
S9xSetSoundMute (FALSE);
}
else
{
- Settings.APUEnabled = Settings.NextAPUEnabled = FALSE;
S9xSetSoundMute (TRUE);
}
}
@@ -360,9 +358,9 @@ void init_sfc_setting(void)
Settings.JoystickEnabled = FALSE;
#endif
- Settings.SoundPlaybackRate = 4; //2 = 11025, 4 = 22050, 6 = 44100
+ Settings.SoundPlaybackRate = SNES9X_SRATE_ID; // -> ds2sound.h for defs
Settings.Stereo = TRUE;
- Settings.SoundBufferSize = 0;
+ Settings.SoundBufferSize = DS2_BUFFER_SIZE;
Settings.CyclesPercentage = 100;
Settings.DisableSoundEcho = FALSE;
//sound settings
@@ -384,17 +382,20 @@ void init_sfc_setting(void)
Settings.ControllerOption = SNES_JOYPAD;
Settings.Transparency = TRUE;
+#ifndef FOREVER_16_BIT
Settings.SixteenBit = TRUE;
+#endif
Settings.SupportHiRes = FALSE;
- Settings.NetPlay = FALSE;
- Settings.ServerName [0] = 0;
Settings.ThreadSound = FALSE;
+ Settings.SoundSync = TRUE;
Settings.AutoSaveDelay = 0;
#ifdef _NETPLAY_SUPPORT
+ Settings.NetPlay = FALSE;
+ Settings.ServerName [0] = 0;
Settings.Port = NP_DEFAULT_PORT;
#endif
- Settings.ApplyCheats =FALSE;
+ Settings.ApplyCheats = TRUE;
Settings.TurboMode = FALSE;
Settings.TurboSkipFrames = 40;
Settings.StretchScreenshots = 1;
@@ -454,14 +455,13 @@ int load_gamepak(char* file)
CPU.Flags = 0;
S9xReset ();
- mdelay(50);
+ // mdelay(50); // Delete this delay
if (!Memory.LoadROM (file))
return -1;
Memory.LoadSRAM (S9xGetFilename (".srm"));
- mdelay(50);
- //S9xLoadCheatFile (S9xGetFilename (".cht"));
- S9xCheat_Disable();
+ // mdelay(50); // Delete this delay
+ S9xLoadCheatFile (S9xGetFilename (".chb")); // cheat binary file, as opposed to text
#ifdef _NETPLAY_SUPPORT
if (strlen (Settings.ServerName) == 0)
@@ -507,9 +507,7 @@ int load_gamepak(char* file)
}
*/
- mdelay(50);
- if (!Settings.APUEnabled)
- S9xSetSoundMute (FALSE);
+ // mdelay(50); // Delete this delay
return 0;
}
@@ -533,9 +531,6 @@ int sfc_main (int argc, char **argv)
S9xInitSound (Settings.SoundPlaybackRate, Settings.Stereo,
Settings.SoundBufferSize);
- if (!Settings.APUEnabled)
- S9xSetSoundMute (TRUE);
-
#ifdef GFX_MULTI_FORMAT
// S9xSetRenderPixelFormat (RGB565);
S9xSetRenderPixelFormat (BGR555);
@@ -586,9 +581,9 @@ int sfc_main (int argc, char **argv)
{
if (!Settings.Paused
#ifdef DEBUGGER
- || (CPU.Flags & (DEBUG_MODE_FLAG | SINGLE_STEP_FLAG))
+ || (CPU.Flags & (DEBUG_MODE_FLAG | SINGLE_STEP_FLAG)
#endif
- )
+ )
S9xMainLoop ();
@@ -602,7 +597,6 @@ int sfc_main (int argc, char **argv)
if (Settings.Paused)
{
S9xSetSoundMute (TRUE);
- mdelay(50);
unsigned short screen[256*192];
copy_screen((void*)screen, up_screen_addr, 0, 0, 256, 192);
@@ -769,28 +763,15 @@ void S9xSyncSpeed ()
#endif
}
-/*
-* Open sound device
-*/
-static int Rates[8] =
-{
- 0, 8000, 11025, 16000, 22050, 32000, 44100, 48000
-};
-
-static int BufferSizes [8] =
-{
- 0, 256, 256, 256, 512, 512, 1024, 1024
-};
-
bool8 S9xOpenSoundDevice (int mode, bool8 stereo, int buffer_size)
{
so.sixteen_bit = TRUE;
so.stereo = stereo;
- so.playback_rate = Rates[mode & 0x07];
+ so.playback_rate = SND_SAMPLE_RATE;
S9xSetPlaybackRate (so.playback_rate);
if (buffer_size == 0)
- buffer_size = BufferSizes [mode & 7];
+ buffer_size = DS2_BUFFER_SIZE;
if (buffer_size > MAX_BUFFER_SIZE / 4)
buffer_size = MAX_BUFFER_SIZE / 4;
@@ -873,7 +854,7 @@ void S9xProcessSound (unsigned int)
{
unsigned short *audiobuff;
- if (!Settings.APUEnabled || so.mute_sound )
+ if (so.mute_sound || !game_enable_audio)
return;
if(ds2_checkAudiobuff() > 4)
@@ -938,7 +919,7 @@ void S9xProcessSound (unsigned int)
// block_generate_sound = FALSE;
unsigned short *dst_pt = audiobuff;
- unsigned short *dst_pt1 = dst_pt + 512;
+ unsigned short *dst_pt1 = dst_pt + DS2_BUFFER_SIZE;
/* Feed the samples to the soundcard until nothing is left */
for(;;)
@@ -996,7 +977,7 @@ const unsigned int keymap[12] = {
unsigned int S9xReadJoypad (int which1)
{
- struct key_buf inputdata;
+ struct key_buf inputdata;
ds2_getrawInput(&inputdata);
if(inputdata.key & KEY_TOUCH) //Active menu
@@ -1013,7 +994,8 @@ unsigned int S9xReadJoypad (int which1)
key |= (inputdata.key & (1<<i)) ? keymap[i] : 0;
}
- return (key | 0x80000000);
+ // return (key | 0x80000000);
+ return key; // ??? [Neb]
}
else
return 0;
diff --git a/source/nds/gcheat.c b/source/nds/gcheat.c
index 062ce9d..d0ada43 100644
--- a/source/nds/gcheat.c
+++ b/source/nds/gcheat.c
@@ -1,9 +1,9 @@
/* gcheat.c
*
- * Copyright (C) 2010 dking <dking024@gmail.com>
+ * Copyright (C) 2012 GBAtemp user Nebuleon.
*
* This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public Licens e as
+ * 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.
*
@@ -17,511 +17,113 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "port.h"
#include "string.h"
#include "fs_api.h"
#include "ds2_malloc.h"
#include "gcheat.h"
#include "charsets.h"
+#include "cheats.h"
-#define MAX_SFCCHEAT_NAME 24
+extern struct SCheatData Cheat;
-
-//GCHEAT_STRUCT gcheat[MAX_CHEATS];
-unsigned int g_cheat_cell_num;
-unsigned int g_cheat_num;
-
-#define SKIP_SPACE(pt) while(' ' == *pt) pt++
-
-static unsigned char* check_is_cht(unsigned char *str)
-{
- unsigned char *pt, *pt1;
-
- if(*str == '\0') return NULL;
-
- pt = str;
- while(*pt == ' ') pt++; //Skip leading space
- if(*pt != '[') return NULL; //valid entry should be:[string]
-
- pt1 = strrchr(str, ']');
- if(pt1 == NULL) return NULL;
-
- while(*(--pt1) == ' ');
- *(pt1+1) = '\0'; //Cut trailing space between string and ']'
-
- while(*(++pt) == ' '); //Cut space between '[' and string
-
- return pt;
-}
-
-static unsigned int sscanf_hex_value(unsigned char* str, unsigned int *value)
-{
- unsigned char *pt;
- unsigned int tmp;
- unsigned char ch;
- unsigned int len;
-
- pt = str;
- len = 0;
- tmp = 0;
- while(*pt && len < 8)
- {
- ch = *pt;
- if(ch >= 'a' && ch <= 'f') ch = ch - 'a' + 0xa;
- else if(ch >= 'A' && ch <= 'F') ch = ch - 'A' + 0xa;
- else if(ch >= '0' && ch <= '9') ch = ch - '0';
- else if(ch == ' ') continue;
- else break;
-
- tmp = (tmp << 4) | ch;
- pt++;
- len += 1;
- }
-
- *value = tmp;
- return len;
-}
-
-/*
-* Convert the src string to UTF8 coding dst string, and cut to length
-*/
-int string2utf8(unsigned char *src, unsigned char* dst, unsigned int length)
+// Reads a cheat text file in BSNES's format.
+int NDSSFCLoadCheatFile(const char* filename)
{
- unsigned char *pt;
- unsigned char ch;
- unsigned short ucode;
- unsigned int type;
- unsigned int len;
+ FILE* fp = fopen(filename, "r");
+ if (fp == NULL)
+ return -1;
- len = 0;
- type = 0;
- pt = src;
- while(*pt)
+ S9xDeleteCheats();
+
+ // The construction is "a","b","c" <newline>.
+ // a is ignored. In BSNES, it decides whether the code is enabled.
+ // b is a series of codes separated by +. Each of the codes is in the form
+ // accepted by the Game Genie, Pro Action Replay, or the GoldFinger.
+ // c is the cheat's description.
+ char line[256], code[24];
+ char *description, *codes_ptr;
+ uint32 address;
+ uint8 byte;
+ uint8 bytes [3];
+ bool8 sram;
+ uint8 num_bytes;
+
+ while (fgets(line, sizeof(line), fp))
{
- pt = utf8decode(pt, &ucode);
- if(ucode < 0x4e00) {
- if(ucode == 0 || ucode > 0x7F) {
- type = 1;
- break;
- }
- } else if(ucode > 0x9FCF) {
- type = 1;
- break;
+ char* ptr = &line[0];
+ // Ignore a.
+ while (*ptr && *ptr != ',')
+ ptr++;
+ // If there was no comma, declare a bad file.
+ if (*ptr == '\0') {
+ fclose(fp);
+ return -2;
}
- else
- len++;
-
- if(len >= 3) break; //There is enough UTF8, so it is, to save time(>_*)
- }
+ *ptr++; // Past the comma
+
+ if (*ptr && *ptr == '"')
+ ptr++; // Starting quote of b.
+ codes_ptr = ptr; // Save this for later.
+ while (*ptr && *ptr != ',')
+ ptr++;
+ // If there was no comma, declare a bad file.
+ if (*ptr == '\0') {
+ fclose(fp);
+ return -2;
+ }
+ *ptr = '\0'; // End the codes there
+ *ptr++; // Past the comma
+
+ uint32 i = 0;
+ description = ptr; // Skip starting " in description
+ while (*description && *description == '"')
+ description++;
+ ptr = description;
+ while (*ptr && !(*ptr == '\r' || *ptr == '\n' || *ptr == '"') && i < MAX_SFCCHEAT_NAME - 1) {
+ ptr++; // Remove trailing newline/quote in description
+ i++; // Clip the cheat name to MAX_SFCCHEAT_NAME chars
+ }
+ *ptr = '\0';
- if(type == 0) //UTF8
- {
- while(*src)
- {
- ch = *src++;
- *dst++ = ch;
+ uint32 c;
+ // n is the number of cheat codes. Beware of MAX_CHEATS_T.
- if(ch < 0x80) {
- if(length > 1) length -= 1;
- else break;
- } else if (ch < 0xe0) { /* U-00000080 - U-000007FF, 2 bytes */
- if(length > 2) length -= 2;
- else break;
- *dst++ = *src++;
- } else if (ch < 0xf0) { /* U-00000800 - U-0000FFFF, 3 bytes */
- if(length > 3) length -= 3;
- else break;
- *dst++ = *src++;
- *dst++ = *src++;
- } else if (ch < 0xf5) { /* U-00010000 - U-001FFFFF, 4 bytes */
- if(length > 4) length -= 4;
- else break;
- *dst++ = *src++;
- *dst++ = *src++;
- *dst++ = *src++;
- } else {
- break;
+ // List of cheat codes having the same description.
+ ptr = codes_ptr;
+ while (*ptr && !(*ptr == ',' || *ptr == '"')) {
+ if (Cheat.num_cheats >= MAX_CHEATS_T) {
+ fclose(fp);
+ return 0;
}
- }
- *dst = '\0';
- }
- else //assume it is GBK code
- {
- //GBK to UTF8
- while(*src)
- {
- ch = *src;
- if(ch < 0x80)
- {
- if(length > 1) length -= 1;
- else break;
-
- *dst++= ch;
- src ++;
+ i = 0;
+ while (*ptr && !(*ptr == '+' || *ptr == ',' || *ptr == '"') && i < sizeof(code) - 1)
+ code[i++] = *ptr++;
+ if (*ptr)
+ ptr++; // Go past the + , or "
+ code[i] = '\0';
+ if (!S9xGameGenieToRaw (code, &address, &byte)) {
+ S9xAddCheat (FALSE, FALSE, address, byte);
+ strncpy (Cheat.c[Cheat.num_cheats - 1].name, description, MAX_SFCCHEAT_NAME);
+ }
+ else if (!S9xProActionReplayToRaw (code, &address, &byte)) {
+ S9xAddCheat (FALSE, FALSE, address, byte);
+ strncpy (Cheat.c[Cheat.num_cheats - 1].name, description, MAX_SFCCHEAT_NAME);
}
- else
+ else if (!S9xGoldFingerToRaw (code, &address, &sram, &num_bytes, bytes))
{
- ucode = charsets_gbk_to_ucs(src);
-
- if (ucode < 0x800) //2 bytes
- {
- if(length > 2) length -= 2;
- else break;
-
- *dst++ = 0xC0 | ((ucode >> 6) & 0x1F);
- *dst++ = 0x80 | (ucode & 0x3F);
- }
- else //3 bytes
- {
- if(length > 3) length -= 3;
- else break;
-
- *dst++ = 0xE0 | (ucode >> 12);
- *dst++ = 0x80 | ((ucode >>6) & 0x3F);
- *dst++ = 0x80 | (ucode & 0x3F);
+ for (c = 0; c < num_bytes; c++) {
+ S9xAddCheat (FALSE, FALSE, address + c, bytes[c]);
+ strncpy (Cheat.c[Cheat.num_cheats - 1].name, description, MAX_SFCCHEAT_NAME);
}
-
- src += 2;
}
- }
- *dst = '\0';
- }
-
- return 0;
-}
-
-int load_cheatname(const char* filename, unsigned int string_num, unsigned int string_len, MSG_TABLE* mssg_table)
-{
- FILE *fp;
- unsigned char current_line[256];
- unsigned char current_line_tmp[256];
- int len, m;
- unsigned char** indexp;
- unsigned char* msg;
- unsigned char* pt;
-
- mssg_table->msg_index = (unsigned char**)malloc(string_num*4);
- if(NULL == mssg_table->msg_index)
- return -1;
-
- string_len = string_len + string_len/2;
- mssg_table->msg_pool = (unsigned char*)malloc((string_len+31)&(~31));
- if(NULL == mssg_table->msg_pool) {
- free((void*)mssg_table->msg_index);
- return -1;
- }
-
- fp = fopen(filename, "r");
- if(fp == NULL) {
- free((void*)mssg_table->msg_index);
- free((void*)mssg_table->msg_pool);
- return -1;
- }
-
- len = 0;
- m= 0;
- indexp = mssg_table->msg_index;
- msg = mssg_table->msg_pool;
- while(fgets(current_line, 256, fp))
- {
- unsigned int str_len;
-
- if((pt = check_is_cht(current_line)) != NULL)
- {
- if(!strcasecmp(pt, "gameinfo"))
- continue;
-
- string2utf8(pt, current_line_tmp, 255);
-
- str_len = strlen(current_line_tmp);
- strncpy(msg+len, current_line_tmp, str_len);
-
- indexp[m++] = msg+len;
- len += str_len;
- msg[len] = '\0';
- len += 1;
-
- if(len >= string_len) break;
- if(m >= string_num) break;
-
- while(fgets(current_line, 256, fp))
- {
- str_len = strlen(current_line);
- if(str_len < 4) break;
-
- if((pt = strchr(current_line, '=')) == NULL) //valid cheat item
- break;
-
- *pt = '\0';
- pt = current_line;
-
- string2utf8(pt, current_line_tmp, 255);
-
- str_len = strlen(current_line_tmp);
- strncpy(msg+len, current_line_tmp, str_len);
-
- indexp[m++] = msg+len;
- len += str_len;
- msg[len] = '\0';
- len += 1;
-
- if(len >= string_len) break;
- if(m >= string_num) break;
+ else {
+ fclose(fp);
+ return -3; // Bad cheat format
}
-
- if(len >= string_len) break;
- if(m >= string_num) break;
- }
- }
-
- mssg_table -> msg_num = m;
- fclose(fp);
-
-#if 0
-cprintf("string_len %d; len %d\n", string_len, len);
-for(m= 0; m<mssg_table -> msg_num; m++)
-{
-cprintf("msg%d:%s\n", m, indexp[m]);
-}
-#endif
-
- return 0;
-}
-
-#define MAX_CHEAT_DATE_LEN (MAX_SFCCHEAT_NAME/2) //other part hold the saved data
-
-/*
-* Load cheat file
-*/
-int load_cheatfile(const char* filename, unsigned int *string_num, unsigned int *string_len,
- GCHEAT_STRUCT *gcheat)
-{
- FILE *cheats_file;
- unsigned char current_line[256];
- unsigned char current_line_tmp[256];
- unsigned int current_line_len;
- unsigned char *pt;
- int gcheat_num;
-
- unsigned int str_num;
- unsigned int str_len;
- unsigned int cheat_cell_num;
- int flag;
-
- cheats_file = fopen(filename, "r");
- if(NULL == cheats_file)
- return -1;
- g_cheat_cell_num = 0;
- g_cheat_num = 0;
- cheat_cell_num = 0;
- gcheat_num = 0;
- str_num = 0;
- str_len = 0;
- flag = 0;
-
- while(fgets(current_line, 256, cheats_file))
- {
- if((pt = check_is_cht(current_line)) == NULL) //Check valid cht cheat
- continue;
-
- if(!strcasecmp(pt, "gameinfo")) //maybe file end
- continue;
-
- gcheat[gcheat_num].name_id = str_num;
- gcheat[gcheat_num].item_id = cheat_cell_num;
- gcheat[gcheat_num].item_num = 0;
-
- string2utf8(pt, current_line_tmp, CHEAT_NAME_LENGTH);
- strcpy(gcheat[gcheat_num].name_shot, current_line_tmp); //store a cut name shot
- //Initialize other parameter of gcheat
- gcheat[gcheat_num].active = 0;
- gcheat[gcheat_num].sub_active = 0;
-
- current_line_len = strlen(pt);
- str_len += current_line_len +1;
- str_num++;
-
- //Cheat items
- while(fgets(current_line, 256, cheats_file) != NULL)
- {
- if(strlen(current_line) < 4)
- break;
-
- if((pt = strchr(current_line, '=')) == NULL) //No valid content
- break;
-
- //one sub item each pass
- unsigned int first_part; //first part of a cheat item
- unsigned int first_part_id;
- unsigned int sub_part_id;
- unsigned int hex_len;
-
- unsigned int cheat_addr;
- unsigned char cheat_dat[MAX_CHEAT_DATE_LEN];
- unsigned int cheat_dat_len;
- unsigned int str_num_saved;
-
- str_num_saved = str_num;
- str_len += pt - current_line +1;
- str_num++;
-
- first_part = 1;
- first_part_id = cheat_cell_num;
- sub_part_id = 0;
-
- //skip name part
- pt += 1;
- current_line_len = strlen(pt);
-
- //data part
- while(1)
- {
- //fill current_line buffer as full as possible
- if(current_line_len < (MAX_CHEAT_DATE_LEN*3+8))
- { //the data length can fill a cheat cell
- if(NULL == strchr(pt, 0x0A)) { //this line not end
- memmove(current_line, pt, current_line_len+1);
- fgets(current_line+current_line_len, 256-current_line_len, cheats_file);
- pt = current_line;
- current_line_len = strlen(pt);
- }
- }
-#if 0
-cprintf("------\n");
-cprintf("new %d:[%s]\n", current_line_len, pt);
-dump_mem(pt, strlen(pt));
-cprintf("\n------\n");
-#endif
- //get address
- if(first_part)
- {
- hex_len = sscanf_hex_value(pt, &cheat_addr);
- if(0 == hex_len) {
- goto load_cheatfile_error;
- }
-
- pt += hex_len;
- current_line_len -= hex_len +1;
- // strict to follow the formate
- if(',' != *pt++ || '\0' == *pt || 0x0D == *pt || 0x0A == *pt) {
- goto load_cheatfile_error;
- }
-
- if(cheat_addr < 0x10000)
- cheat_addr |= 0x7e0000;
- else {
- cheat_addr &= 0xffff;
- cheat_addr |= 0x7f0000;
- }
- }
-
- //get data
- unsigned int tmp, m;
-
- m = 0;
- cheat_dat_len = 0;
- while(m++ < MAX_CHEAT_DATE_LEN)
- {
- hex_len = sscanf_hex_value(pt, &tmp);
- if(0 == hex_len) break;
-
- cheat_dat[cheat_dat_len++] = (unsigned char)tmp;
-
- pt += hex_len;
- current_line_len -= hex_len +1;
- if(',' == *pt) pt++;
- }
-
- //In first part, get data error
- if(0 == cheat_dat_len) {
- if(0 == sub_part_id)
- goto load_cheatfile_error;
- }
- else {
- //record data
- flag = S9xAddCheat_ex(cheat_addr, cheat_dat, cheat_dat_len, cheat_cell_num++, sub_part_id++, str_num_saved);
- if(0 != flag) {
- cheat_cell_num -= sub_part_id;
- break;
- }
- }
-
- if(0 == *pt || 0x0D == *pt || 0x0A == *pt) break; //a line over
-
- first_part = 0;
- if(';' == *pt) first_part = 1, pt += 1; //other address of the cheat cell
- else cheat_addr += cheat_dat_len; //more data
- } //data part
-
- //have no enough cheat_cell struct to store cheat
- if(0 != flag) break;
-
- S9xAddCheat_ov(first_part_id, sub_part_id);
- gcheat[gcheat_num].item_num += 1;
- } //Cheat items
-
- if(0 != flag) break;
-
- gcheat_num += 1;
- if(gcheat_num >= MAX_CHEATS)
- break;
- }
-
- g_cheat_cell_num = cheat_cell_num;
- g_cheat_num = gcheat_num;
- *string_num = str_num;
- *string_len = str_len;
- fclose(cheats_file);
-
-#if 0
-cprintf("g_cheat_num %d; g_cheat_cell_num %d\n", g_cheat_num, g_cheat_cell_num);
-
-int i;
-for(i= 0; i < g_cheat_cell_num; i++)
-S9x_dumpcheat(i);
-
-for(i= 0; i < g_cheat_num; i++)
-{
- cprintf("cheat %d\n", i);
- cprintf("item num %d; item id %d\n", gcheat[i].item_num, gcheat[i].item_id);
-}
-#endif
-
- return 0;
-
-load_cheatfile_error:
- fclose(cheats_file);
- return -1;
-}
-
-void gcheat_Managment(GCHEAT_STRUCT *gcheat)
-{
- unsigned int i, enable, m, en_flag;
- unsigned int active, item_id, sub_active, item_num;
-
- //no cheat
- if(0 == g_cheat_num || 0 == g_cheat_cell_num) {
- S9xCheat_Disable();
- return;
- }
-
- enable = 0;
- for(i = 0; i < g_cheat_num; i++)
- {
- active = gcheat[i].active & 0x1;
- item_id = gcheat[i].item_id;
- item_num = gcheat[i].item_num;
- sub_active = gcheat[i].sub_active;
-
- for(m = 0; m < item_num; m++)
- {
- en_flag = sub_active == m ? active : 0;
- S9xCheat_switch(item_id, m, en_flag);
}
-
- if(active) enable = 1;
}
- if(enable)
- S9xCheat_Enable();
+ fclose(fp);
+ return 0;
}
-
diff --git a/source/nds/gcheat.h b/source/nds/gcheat.h
index e5131f6..3c9e440 100644
--- a/source/nds/gcheat.h
+++ b/source/nds/gcheat.h
@@ -15,51 +15,24 @@
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef __GCHEAT_H__
-#define __GCHEAT_H__
+ */
+
+#ifndef __GCHEAT_H__
+#define __GCHEAT_H__
#ifdef __cplusplus
extern "C" {
#endif
-
-#define CHEAT_NAME_LENGTH (32)
-#define MAX_CHEATS_PAGE 10
-#define CHEATS_PER_PAGE 4
-#define MAX_CHEATS (MAX_CHEATS_PAGE * CHEATS_PER_PAGE)
-//Support EMU Cheat(emulator cheat) code
-typedef struct
-{
- u32 name_id; //name ID in another table
- u32 active; //status
- u16 item_num; //sub-item number
- u16 sub_active;
- u32 item_id; //There is another struct array to store the cheat data
- char name_shot[CHEAT_NAME_LENGTH];
- u32 reserved;
-} GCHEAT_STRUCT;
+#include "cheats.h"
-typedef struct
-{
- unsigned char** msg_index;
- unsigned char* msg_pool;
- unsigned int msg_num;
-} MSG_TABLE;
-
-extern GCHEAT_STRUCT gcheat[MAX_CHEATS];
-extern unsigned int g_cheat_cell_num;
-extern unsigned int g_cheat_num;
+#define CHEATS_PER_PAGE 4
+#define MAX_CHEATS_PAGE (MAX_CHEATS_T / CHEATS_PER_PAGE)
-extern int load_cheatfile(const char* filename, unsigned int *string_num,
- unsigned int *string_len, GCHEAT_STRUCT *gcheat);
-extern int load_cheatname(const char* filename, unsigned int string_num,
- unsigned int string_len, MSG_TABLE* mssg_table);
-extern void gcheat_Managment(GCHEAT_STRUCT *gcheat);
+extern int NDSSFCLoadCheatFile(const char* filename);
#ifdef __cplusplus
}
#endif
-
-#endif //__GCHEAT_H__
+
+#endif //__GCHEAT_H__
diff --git a/source/nds/gui.c b/source/nds/gui.c
index f8cd03b..9aa16bb 100644
--- a/source/nds/gui.c
+++ b/source/nds/gui.c
@@ -23,6 +23,7 @@
#include <string.h>
#include <sys/stat.h>
+#include "port.h"
#include "ds2_types.h"
#include "ds2io.h"
#include "ds2_malloc.h"
@@ -35,23 +36,30 @@
#include "bitmap.h"
#include "gcheat.h"
+extern struct SCheatData Cheat;
+
char main_path[MAX_PATH];
char rom_path[MAX_PATH];
char gamepak_name[MAX_PATH];
char gcheat_filename[MAX_PATH];
-char *lang[2] =
+// If adding a language, make sure you update the size of the array in
+// message.h too.
+char *lang[3] =
{
"English", // 0
"简体中文", // 1
+ "Français", // 2
};
+char *language_options[] = { (char *) &lang[0], (char *) &lang[1], (char *) &lang[2] };
+
/******************************************************************************
* Macro definition
******************************************************************************/
#define SUBMENU_ROW_NUM 6
-#define NDSSFC_VERSION "1.07"
+#define NDSSFC_VERSION "1.10"
#define SAVE_STATE_SLOT_NUM 10
@@ -64,7 +72,7 @@ char *lang[2] =
EMU_CONFIG emu_config;
//game configure file's header
-#define GAME_CONFIG_HEADER "GSFC1.0"
+#define GAME_CONFIG_HEADER "GSFC1.1" // 1.1 removed cheat names
#define GAME_CONFIG_HEADER_SIZE 7
GAME_CONFIG game_config;
@@ -103,9 +111,9 @@ static unsigned int savestate_index;
action_function, \
passive_function, \
NULL, \
- &cheat_format_ptr[number], \
+ &cheat_data_ptr[number], \
enable_disable_options, \
- &(game_config.cheats_flag[number].active), \
+ &(Cheat.c[number].enabled), \
2, \
NULL, \
line_number, \
@@ -266,7 +274,7 @@ u32 game_enable_audio = 1;
/******************************************************************************
******************************************************************************/
static u32 menu_cheat_page = 0;
-static u32 clock_speed_number = 2;
+static u32 clock_speed_number = 5;
u32 gamepad_config_menu;
/******************************************************************************
@@ -400,13 +408,14 @@ static int sort_function(const void *dest_str_ptr, const void *src_str_ptr)
char *dest_str = *((char **)dest_str_ptr);
char *src_str = *((char **)src_str_ptr);
+ // For files and directories, . and .. sort first.
if(src_str[0] == '.')
return 1;
if(dest_str[0] == '.')
return -1;
- return strcasecmp(dest_str, src_str);
+ return strcasecmp(dest_str, src_str);
}
static int my_array_partion(void *array, int left, int right)
@@ -461,9 +470,9 @@ static void strupr(char *str)
}
}
-//******************************************************************************
+// ******************************************************************************
// get file list
-//******************************************************************************
+// ******************************************************************************
#define FILE_LIST_MAX 512
#define DIR_LIST_MAX 64
#define NAME_MEM_SIZE (320*64)
@@ -625,7 +634,7 @@ static int load_file_list(struct FILE_LIST_INFO *filelist_infop)
strcpy(current_dir_name, filelist_infop -> current_path);
- //* path formate should be: "fat:/" or "fat:/dir0" or "fat:", not "fat:/dir0/"
+ // path formate should be: "fat:/" or "fat:/dir0" or "fat:", not "fat:/dir0/"
current_dir = opendir(current_dir_name);
//Open directory faiure
if(current_dir == NULL) {
@@ -789,31 +798,23 @@ s32 load_file(char **wildcards, char *result, char *default_dir_name)
{
case CURSOR_TOUCH:
ds2_getrawInput(&inputdata);
- if(inputdata.y <= 33)
+ // ___ 33 This screen has 6 possible rows. Touches
+ // ___ 60 above or below these are ignored.
+ // . . . (+27)
+ // ___ 192
+ if(inputdata.y <= 33 || inputdata.y > 192)
break;
- else if(inputdata.y <= 60)
- mod = 0;
- else if(inputdata.y <= 87)
- mod = 1;
- else if(inputdata.y <= 114)
- mod = 2;
- else if(inputdata.y <= 141)
- mod = 3;
- else if(inputdata.y <= 168)
- mod = 4;
- else if(inputdata.y <= 192)
- mod = 5;
else
- break;
-
+ mod = (inputdata.y - 33) / 27;
+
if(selected_item_on_list - selected_item_on_screen + mod >= total_items_num)
break;
-
+
selected_item_on_list = selected_item_on_list - selected_item_on_screen + mod;
-
+
if(selected_item_on_list + 1 <= num_files)
{
- //The ".." directory
+ //The ".." directory is the parent
if(!strcasecmp(file_list[selected_item_on_list], ".."))
{
char *ext_pos;
@@ -849,7 +850,7 @@ s32 load_file(char **wildcards, char *result, char *default_dir_name)
case CURSOR_UP:
redraw = 1;
if(selected_item_on_screen > 0)
- {
+ {
//Not the first item on list
selected_item_on_list -= 1;
//Selected item on screen center
@@ -1113,7 +1114,7 @@ s32 load_file(char **wildcards, char *result, char *default_dir_name)
}
redraw = 0;
- ds2_flipScreen(DOWN_SCREEN, 2); //not switch down screen buffer
+ ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD);
} //end if(0 != redraw)
else if(0 != redraw) {
unsigned int m, n;
@@ -1141,7 +1142,7 @@ s32 load_file(char **wildcards, char *result, char *default_dir_name)
}
draw_hscroll(m+1, redraw);
- ds2_flipScreen(DOWN_SCREEN, 2); //not switch down screen buffer
+ ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD);
redraw = 0;
}
@@ -1161,7 +1162,7 @@ s32 load_file(char **wildcards, char *result, char *default_dir_name)
{
if(draw_hscroll(0, 1) <= 1) path_scroll = 0x8000; //scroll left
}
- ds2_flipScreen(DOWN_SCREEN, 2); //not switch down screen buffer
+ ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD);
}
mdelay(50); //about 50ms
@@ -1175,7 +1176,7 @@ s32 load_file(char **wildcards, char *result, char *default_dir_name)
manage_filelist_info(&filelist_info, -1);
ds2_clearScreen(DOWN_SCREEN, COLOR_BLACK);
- ds2_flipScreen(DOWN_SCREEN, 2); //not switch down screen buffer
+ ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD);
return return_value;
}
@@ -1232,7 +1233,7 @@ u32 play_screen_snapshot(void)
{
draw_message(down_screen_addr, screenp, 28, 31, 227, 165, color_bg);
draw_string_vcenter(down_screen_addr, 36, 55, 190, COLOR_MSSG, msg[MSG_NO_SLIDE]);
- ds2_flipScreen(DOWN_SCREEN, 2);
+ ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD);
if(screenp) free((void*)screenp);
//construct filelist_info struct
@@ -1259,7 +1260,7 @@ u32 play_screen_snapshot(void)
draw_string_vcenter(down_screen_addr, 36, 115, 190, COLOR_MSSG, msg[MSG_PLAY_SLIDE4]);
draw_string_vcenter(down_screen_addr, 36, 130, 190, COLOR_MSSG, msg[MSG_PLAY_SLIDE5]);
draw_string_vcenter(down_screen_addr, 36, 145, 190, COLOR_MSSG, msg[MSG_PLAY_SLIDE6]);
- ds2_flipScreen(DOWN_SCREEN, 2);
+ ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD);
repeat= 1;
i= 0;
@@ -1650,7 +1651,7 @@ unsigned int frame_interval;
--------------------------------------------------------*/
u32 menu(u16 *screen)
{
- mdelay(50);
+ mdelay(50); // to prevent the touch key from being applied too soon?
gui_action_type gui_action;
u32 i;
u32 repeat;
@@ -1658,8 +1659,9 @@ u32 menu(u16 *screen)
u32 first_load = 0;
char tmp_filename[MAX_FILE];
char line_buffer[512];
- char cheat_format_str[MAX_CHEATS][41*4];
- char *cheat_format_ptr[MAX_CHEATS];
+ char cheat_data_str[MAX_CHEATS_T][5];
+ // ^ Holds the index inside Cheat, as a number in an ASCIIZ string
+ char* cheat_data_ptr[MAX_CHEATS_T];
MENU_TYPE *current_menu;
MENU_OPTION_TYPE *current_option;
@@ -1716,12 +1718,13 @@ u32 menu(u16 *screen)
void menu_exit()
{
+ ds2_setCPUclocklevel(13); // Crank it up, leave quickly
if(gamepak_name[0] != 0)
{
game_config.clock_speed_number = clock_speed_number;
reorder_latest_file();
- //S9xAutoSaveSRAM ();
+ S9xAutoSaveSRAM ();
save_game_config_file();
}
save_emu_config_file();
@@ -1734,7 +1737,7 @@ u32 menu(u16 *screen)
if(gamepak_name[0] != 0)
{
- //S9xAutoSaveSRAM ();
+ S9xAutoSaveSRAM ();
save_game_config_file();
}
@@ -1746,9 +1749,12 @@ u32 menu(u16 *screen)
draw_message(down_screen_addr, bg_screenp, 28, 31, 227, 165, bg_screenp_color);
draw_string_vcenter(down_screen_addr, 36, 100, 190, COLOR_MSSG, msg[MSG_LOADING_GAME]);
- ds2_flipScreen(DOWN_SCREEN, 2);
+ ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD);
- if(load_gamepak(line_buffer) == -1)
+ ds2_setCPUclocklevel(13);
+ int load_result = load_gamepak(&line_buffer);
+ ds2_setCPUclocklevel(0);
+ if(load_result == -1)
{
first_load = 1;
gamepak_name[0] = '\0';
@@ -1811,9 +1817,13 @@ u32 menu(u16 *screen)
draw_message(down_screen_addr, bg_screenp, 28, 31, 227, 165, bg_screenp_color);
draw_string_vcenter(down_screen_addr, 36, 100, 190, COLOR_MSSG, msg[MSG_LOADING_GAME]);
- ds2_flipScreen(DOWN_SCREEN, 2);
-
- if(load_gamepak(args[1]) == -1)
+ ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD);
+
+ ds2_setCPUclocklevel(13);
+ int load_result = load_gamepak(args[1]);
+ ds2_setCPUclocklevel(0);
+
+ if(load_result == -1)
{
first_load = 1;
gamepak_name[0] = '\0';
@@ -1930,7 +1940,7 @@ u32 menu(u16 *screen)
else
color= COLOR_INACTIVE_ITEM;
- PRINT_STRING_BG_UTF8(down_screen_addr, line_buffer, color, COLOR_TRANS, 23, 40 + line[i]*27);
+ PRINT_STRING_BG(down_screen_addr, line_buffer, color, COLOR_TRANS, 23, 40 + line[i]*27);
}
int slot_index;
@@ -1941,7 +1951,7 @@ u32 menu(u16 *screen)
slot_index= get_savestate_slot();
sprintf(line_buffer, "%d", (slot_index+2) > SAVE_STATE_SLOT_NUM ? SAVE_STATE_SLOT_NUM : (slot_index+2));
- PRINT_STRING_BG_UTF8(down_screen_addr, line_buffer, COLOR_INACTIVE_ITEM, COLOR_TRANS, 146, 40 + 0*27);
+ PRINT_STRING_BG(down_screen_addr, line_buffer, COLOR_INACTIVE_ITEM, COLOR_TRANS, 146, 40 + 0*27);
if(current_option_num == 1)
selected = slot_index+1;
@@ -1999,7 +2009,7 @@ u32 menu(u16 *screen)
else
color= COLOR_INACTIVE_ITEM;
- PRINT_STRING_BG_UTF8(down_screen_addr, line_buffer, color, COLOR_TRANS, 23, 40 + line[i]*27);
+ PRINT_STRING_BG(down_screen_addr, line_buffer, color, COLOR_TRANS, 23, 40 + line[i]*27);
}
if(current_option_num == 2)
@@ -2037,7 +2047,7 @@ u32 menu(u16 *screen)
draw_message(down_screen_addr, NULL, 28, 31, 227, 165, 0);
draw_string_vcenter(down_screen_addr, 36, 100, 190, COLOR_MSSG, msg[MSG_SAVESTATE_DOING]);
- ds2_flipScreen(DOWN_SCREEN, 2);
+ ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD);
int flag = save_state(tmp_filename, (void*)screen);
//clear message
@@ -2053,13 +2063,13 @@ u32 menu(u16 *screen)
savestate_index = slot_index;
}
- ds2_flipScreen(DOWN_SCREEN, 2);
+ ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD);
//save game config
reorder_latest_file();
save_game_config_file();
- mdelay(500);
+ // mdelay(500); // Delete this delay
}
}
}
@@ -2090,7 +2100,7 @@ u32 menu(u16 *screen)
{
draw_message(down_screen_addr, bg_screenp, 28, 31, 227, 165, bg_screenp_color);
draw_string_vcenter(down_screen_addr, 36, 80, 190, COLOR_MSSG, msg[MSG_SAVESTATE_FILE_BAD]);
- ds2_flipScreen(DOWN_SCREEN, 2);
+ ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD);
wait_Allkey_release(0);
if(gui_action == CURSOR_SELECT)
@@ -2160,6 +2170,7 @@ u32 menu(u16 *screen)
{
if(draw_yesno_dialog(DOWN_SCREEN, 115, "Yes(A)", "No(B)"))
{
+ wait_Allkey_release(0);
for(i= 0; i < SAVE_STATE_SLOT_NUM; i++)
{
get_savestate_filename(i, tmp_filename);
@@ -2175,7 +2186,7 @@ u32 menu(u16 *screen)
{
draw_message(down_screen_addr, bg_screenp, 28, 31, 227, 165, bg_screenp_color);
draw_string_vcenter(down_screen_addr, 36, 90, 190, COLOR_MSSG, msg[MSG_DELETTE_SAVESTATE_NOTHING]);
- ds2_flipScreen(DOWN_SCREEN, 2);
+ ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD);
mdelay(500);
}
}
@@ -2188,13 +2199,15 @@ u32 menu(u16 *screen)
sprintf(line_buffer, msg[MSG_DELETTE_SINGLE_SAVESTATE_WARING], delette_savestate_num);
draw_string_vcenter(down_screen_addr, 36, 75, 190, COLOR_MSSG, line_buffer);
- if(draw_yesno_dialog(DOWN_SCREEN, 115, "Yes(A)", "No(B)"))
+ if(draw_yesno_dialog(DOWN_SCREEN, 115, "Yes(A)", "No(B)")) {
+ wait_Allkey_release(0);
clear_savestate_slot(delette_savestate_num);
+}
}
else
{
draw_string_vcenter(down_screen_addr, 36, 90, 190, COLOR_MSSG, msg[MSG_DELETTE_SAVESTATE_NOTHING]);
- ds2_flipScreen(DOWN_SCREEN, 2);
+ ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD);
mdelay(500);
}
}
@@ -2208,22 +2221,13 @@ u32 menu(u16 *screen)
unsigned char **dynamic_cheat_pt = NULL;
unsigned int dynamic_cheat_active;
int dynamic_cheat_scroll_value= 0;
- MSG_TABLE cheat_msg= {NULL, NULL};
void cheat_menu_init()
{
- for(i = 0; i < MAX_CHEATS; i++)
+ for(i = 0; i < MAX_CHEATS_T; i++)
{
- if(i >= g_cheat_num)
- {
- sprintf(cheat_format_str[i], msg[MSG_CHEAT_MENU_NON_LOAD], i);
- }
- else
- {
- sprintf(cheat_format_str[i], msg[MSG_CHEAT_MENU_LOADED], i, game_config.cheats_flag[i].name_shot);
- }
-
- cheat_format_ptr[i]= cheat_format_str[i];
+ sprintf(cheat_data_str[i], "%d", i);
+ cheat_data_ptr[i] = &cheat_data_str[i][0];
}
reload_cheats_page();
@@ -2231,13 +2235,22 @@ u32 menu(u16 *screen)
void cheat_menu_end()
{
- if(!first_load)
- gcheat_Managment(game_config.cheats_flag);
+ // Honour current cheat selections.
+ uint32 i;
+ for (i = 0; i < Cheat.num_cheats; i++) {
+ if (Cheat.c[i].enabled)
+ S9xApplyCheat(i);
+ else
+ S9xRemoveCheat(i);
+ }
+ // Save current cheat selections to the cheat binary file.
+ strcpy(line_buffer, (char *) S9xGetFilename (".chb"));
+ S9xSaveCheatFile (line_buffer); // cheat binary
}
void dynamic_cheat_key()
{
- unsigned int m, n;
+ unsigned int m, n;
switch(gui_action)
{
@@ -2446,97 +2459,13 @@ u32 menu(u16 *screen)
void cheat_option_action()
{
- unsigned int nums;
-
- nums = (CHEATS_PER_PAGE * menu_cheat_page) + current_option_num -1;
- if(gui_action == CURSOR_SELECT && nums < g_cheat_num)
- {
- unsigned int m;
-
- nums = game_config.cheats_flag[(CHEATS_PER_PAGE * menu_cheat_page) + current_option_num -1].item_num;
-
- if(dynamic_cheat_options)
- {
- free((void*)dynamic_cheat_options);
- dynamic_cheat_options = NULL;
- }
-
- if(dynamic_cheat_menu)
- {
- free((void*)dynamic_cheat_menu);
- dynamic_cheat_menu = NULL;
- }
-
- dynamic_cheat_options = (MENU_OPTION_TYPE*)malloc(sizeof(MENU_OPTION_TYPE)*(nums+1));
- if(dynamic_cheat_options == NULL) return;
-
- dynamic_cheat_menu = (MENU_TYPE*)malloc(sizeof(MENU_TYPE));
- if(dynamic_cheat_menu == NULL)
- {
- free((void*)dynamic_cheat_options);
- dynamic_cheat_options = NULL;
- return;
- }
-
- //menu
- dynamic_cheat_menu->init_function = NULL;
- dynamic_cheat_menu->passive_function = dynamic_cheat_menu_passive;
- dynamic_cheat_menu->key_function = dynamic_cheat_key;
- dynamic_cheat_menu->end_function = dynamic_cheat_menu_end;
- dynamic_cheat_menu->options = dynamic_cheat_options;
- dynamic_cheat_menu->num_options = nums+1;
- dynamic_cheat_menu->focus_option = 0;
- dynamic_cheat_menu->screen_focus = 0;
- //back option
- dynamic_cheat_options[0].action_function = NULL;
- dynamic_cheat_options[0].passive_function = NULL;
- dynamic_cheat_options[0].sub_menu = &cheats_menu;
- dynamic_cheat_options[0].display_string = (char**)(dynamic_cheat_pt + game_config.cheats_flag[(CHEATS_PER_PAGE * menu_cheat_page) + current_option_num -1].name_id);
- dynamic_cheat_options[0].options = NULL;
- dynamic_cheat_options[0].current_option = NULL;
- dynamic_cheat_options[0].num_options = 0;
- dynamic_cheat_options[0].help_string = NULL;
- dynamic_cheat_options[0].line_number = 0;
- dynamic_cheat_options[0].option_type = SUBMENU_TYPE;
-
- m = game_config.cheats_flag[(CHEATS_PER_PAGE * menu_cheat_page) + current_option_num -1].item_id;
- for(i= 0; i < nums; i++)
- {
- dynamic_cheat_options[i+1].action_function = dynamic_cheat_action;
- dynamic_cheat_options[i+1].passive_function = NULL;
- dynamic_cheat_options[i+1].sub_menu = NULL;
- dynamic_cheat_options[i+1].display_string = (char**)(dynamic_cheat_pt + S9xGetCheat_nameid(m, i, g_cheat_cell_num));
- dynamic_cheat_options[i+1].options = NULL;
- dynamic_cheat_options[i+1].current_option = NULL;
- dynamic_cheat_options[i+1].num_options = 2;
- dynamic_cheat_options[i+1].help_string = NULL;
- dynamic_cheat_options[i+1].line_number = i+1;
- dynamic_cheat_options[i+1].option_type = ACTION_TYPE;
- }
-
- dynamic_cheat_active = game_config.cheats_flag[(CHEATS_PER_PAGE * menu_cheat_page) +
- current_option_num -1].active & 0x1;
- dynamic_cheat_active |= game_config.cheats_flag[(CHEATS_PER_PAGE * menu_cheat_page) +
- current_option_num -1].sub_active << 16;
-
- //Initial srollable options
- int k;
-
- draw_hscroll_init(down_screen_addr, 50, 9, 180, COLOR_TRANS,
- COLOR_ACTIVE_ITEM, *dynamic_cheat_options[0].display_string);
-
- if(nums>5) nums = SUBMENU_ROW_NUM;
- for(k= 0; k < nums; k++)
- {
- draw_hscroll_init(down_screen_addr, 23, 40 + k*27, 200,
- COLOR_TRANS, COLOR_INACTIVE_ITEM, *dynamic_cheat_options[k+1].display_string);
- }
- dynamic_cheat_scroll_value= 0;
-
- choose_menu(dynamic_cheat_menu);
- }
}
+#define CHEAT_NUMBER_X 26
+#define CHEAT_DESC_X 52
+#define CHEAT_DESC_SX 163
+#define CHEAT_ACTIVE_X 225
+
void cheat_option_passive()
{
unsigned short color;
@@ -2551,27 +2480,33 @@ u32 menu(u16 *screen)
//sprintf("%A") will have problem ?
strcpy(tmp_buf, *(display_option->display_string));
- pt = strrchr(tmp_buf, ':');
- if(pt != NULL)
- sprintf(pt+1, "%s", *((u32*)(((u32 *)display_option->options)[*(display_option->current_option)])));
+ // This is the number of the cheat to display
- strcpy(line_buffer, tmp_buf);
- pt = strrchr(line_buffer, ')');
- *pt = '\0';
- pt = strchr(line_buffer, '(');
+ int i = atoi(tmp_buf);
- len = BDF_cut_string(pt+1, 0, 2);
- if(len > 90)
- {
- len = BDF_cut_string(pt+1, 90, 1);
- *(pt+1+len) = '\0';
- strcat(line_buffer, "...");
- }
+ sprintf(line_buffer, "%d.", i + 1);
+ PRINT_STRING_BG(down_screen_addr, line_buffer, color, COLOR_TRANS, CHEAT_NUMBER_X, 40 + display_option-> line_number*27);
- pt = strrchr(tmp_buf, ')');
- strcat(line_buffer, pt);
+ if (i >= Cheat.num_cheats) {
+ PRINT_STRING_BG(down_screen_addr, msg[MSG_CHEAT_MENU_NON_LOAD], color, COLOR_TRANS, CHEAT_DESC_X, 40 + display_option-> line_number*27);
+ }
+ else {
+ strcpy(line_buffer, Cheat.c[i].name);
+ len = BDF_cut_string(line_buffer, 0, 2);
+ if(len > CHEAT_DESC_SX)
+ {
+ len = BDF_cut_string(line_buffer, CHEAT_DESC_SX, 1);
+ line_buffer[len] = '\0';
+ strcat(line_buffer, "...");
+ }
+ PRINT_STRING_BG(down_screen_addr, line_buffer, color, COLOR_TRANS, CHEAT_DESC_X, 40 + display_option-> line_number*27);
- PRINT_STRING_BG_UTF8(down_screen_addr, line_buffer, color, COLOR_TRANS, 26, 40 + display_option-> line_number*27);
+ if (Cheat.c[i].enabled)
+ strcpy(line_buffer, "+");
+ else
+ strcpy(line_buffer, "-");
+ PRINT_STRING_BG(down_screen_addr, line_buffer, color, COLOR_TRANS, CHEAT_ACTIVE_X, 40 + display_option-> line_number*27);
+ }
}
void dynamic_cheat_menu_end()
@@ -2579,7 +2514,8 @@ u32 menu(u16 *screen)
unsigned int m, k;
m = cheats_menu.focus_option-1;
- game_config.cheats_flag[(CHEATS_PER_PAGE * menu_cheat_page) + m].sub_active = dynamic_cheat_active >> 16;
+ // game_config.cheats_flag[(CHEATS_PER_PAGE * menu_cheat_page) + m].sub_active = dynamic_cheat_active >> 16;
+ // REVISIT [Neb]
k = SUBMENU_ROW_NUM +1;
for(m= 0; m<k; m++)
@@ -2606,44 +2542,24 @@ u32 menu(u16 *screen)
if(load_file(file_ext, tmp_filename, DEFAULT_CHEAT_DIR) != -1)
{
- if(NULL != cheat_msg.msg_index) free((void*)cheat_msg.msg_index);
- if(NULL != cheat_msg.msg_pool) free((void*)cheat_msg.msg_pool);
-
sprintf(line_buffer, "%s/%s", DEFAULT_CHEAT_DIR, tmp_filename);
+ flag = NDSSFCLoadCheatFile(line_buffer);
- flag = load_cheatfile(line_buffer, &string_num, &string_len, game_config.cheats_flag);
- if(0 != flag)
- { //load cheat file failure
- game_config.cheat_str_num = 0;
- game_config.cheat_str_size = 0;
- game_config.cheat_filename[0] = '\0';
- g_cheat_num = 0;
-
- cheat_menu_init();
- return;
- }
+ strcpy(line_buffer, (char *) S9xGetFilename (".chb"));
+ S9xSaveCheatFile (line_buffer); // cheat binary
- flag = load_cheatname(line_buffer, string_num, string_len, &cheat_msg);
if(0 != flag)
- { //load cheat string information failure
- game_config.cheat_str_num = 0;
- game_config.cheat_str_size = 0;
- game_config.cheat_filename[0] = '\0';
- g_cheat_num = 0;
+ { //load cheat file failure
+ S9xDeleteCheats();
cheat_menu_init();
return;
}
- game_config.cheat_str_num = string_num;
- game_config.cheat_str_size = string_len;
- strcpy(game_config.cheat_filename, line_buffer);
-
- dynamic_cheat_msg = cheat_msg.msg_pool;
- dynamic_cheat_pt = cheat_msg.msg_index;;
menu_cheat_page = 0;
cheat_menu_init();
- }
+
+ }
}
void save_screen_snapshot()
@@ -2662,18 +2578,18 @@ u32 menu(u16 *screen)
if(!first_load)
{
draw_string_vcenter(down_screen_addr, 36, 70, 190, COLOR_MSSG, msg[MSG_SAVE_SNAPSHOT]);
- ds2_flipScreen(DOWN_SCREEN, 2);
+ ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD);
if(save_ss_bmp(screen))
draw_string_vcenter(down_screen_addr, 36, 90, 190, COLOR_MSSG, msg[MSG_SAVE_SNAPSHOT_COMPLETE]);
else
draw_string_vcenter(down_screen_addr, 36, 90, 190, COLOR_MSSG, msg[MSG_SAVE_SNAPSHOT_FAILURE]);
- ds2_flipScreen(DOWN_SCREEN, 2);
+ ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD);
mdelay(500);
}
else
{
draw_string_vcenter(down_screen_addr, 36, 90, 190, COLOR_MSSG, msg[MSG_SAVESTATE_SLOT_EMPTY]);
- ds2_flipScreen(DOWN_SCREEN, 2);
+ ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD);
mdelay(500);
}
}
@@ -2794,7 +2710,7 @@ u32 menu(u16 *screen)
mm = *(display_option->current_option);
sprintf(line_buffer, *(display_option->display_string), str[mm]);
- PRINT_STRING_BG_UTF8(down_screen_addr, line_buffer, color, COLOR_TRANS, 27,
+ PRINT_STRING_BG(down_screen_addr, line_buffer, color, COLOR_TRANS, 27,
38 + (display_option-> line_number)*32);
}
@@ -2827,9 +2743,10 @@ u32 menu(u16 *screen)
if(draw_yesno_dialog(DOWN_SCREEN, 115, "Yes", "No"))
{
+ wait_Allkey_release(0);
draw_message(down_screen_addr, bg_screenp, 28, 31, 227, 165, bg_screenp_color);
draw_string_vcenter(down_screen_addr, 36, 80, 190, COLOR_MSSG, msg[MSG_DEFAULT_LOADING]);
- ds2_flipScreen(DOWN_SCREEN, 2);
+ ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD);
sprintf(line_buffer, "%s/%s", main_path, EMU_CONFIG_FILENAME);
remove(line_buffer);
@@ -2842,7 +2759,7 @@ u32 menu(u16 *screen)
draw_string_vcenter(up_screen_addr, 0, 80, 256, COLOR_WHITE, msg[MSG_NON_LOAD_GAME]);
ds2_flipScreen(UP_SCREEN, 1);
- mdelay(500);
+ // mdelay(500); // Delete this delay
}
}
@@ -2858,9 +2775,9 @@ u32 menu(u16 *screen)
draw_message(down_screen_addr, bg_screenp, 28, 31, 227, 165, bg_screenp_color);
draw_string_vcenter(down_screen_addr, 36, 80, 190, COLOR_MSSG, msg[MSG_EMU_VERSION0]);
- sprintf(line_buffer, "%s %s", msg[MSG_EMU_VERSION1], NDSSFC_VERSION);
+ sprintf(line_buffer, "%s %s", msg[MSG_EMU_VERSION1], NDSSFC_VERSION);
draw_string_vcenter(down_screen_addr, 36, 95, 190, COLOR_MSSG, line_buffer);
- ds2_flipScreen(DOWN_SCREEN, 2);
+ ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD);
wait_Anykey_press(0);
}
@@ -2880,7 +2797,7 @@ u32 menu(u16 *screen)
draw_message(down_screen_addr, bg_screenp, 28, 31, 227, 165, bg_screenp_color);
draw_string_vcenter(down_screen_addr, 36, 75, 190, COLOR_MSSG, msg[MSG_CHANGE_LANGUAGE]);
draw_string_vcenter(down_screen_addr, 36, 95, 190, COLOR_MSSG, msg[MSG_CHANGE_LANGUAGE_WAITING]);
- ds2_flipScreen(DOWN_SCREEN, 2);
+ ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD);
load_language_msg(LANGUAGE_PACK, emu_config.language);
gui_change_icon(emu_config.language);
@@ -2890,11 +2807,10 @@ u32 menu(u16 *screen)
ds2_clearScreen(UP_SCREEN, 0);
draw_string_vcenter(up_screen_addr, 0, 80, 256, COLOR_WHITE, msg[MSG_NON_LOAD_GAME]);
ds2_flipScreen(UP_SCREEN, 1);
- mdelay(10); //FIXME: Stranger?
}
save_emu_config_file();
- mdelay(500);
+ wait_Allkey_release(0);
}
}
@@ -2906,7 +2822,7 @@ u32 menu(u16 *screen)
strcpy(line_buffer, *(display_option->display_string));
line_num= display_option-> line_number;
- PRINT_STRING_BG_UTF8(down_screen_addr, line_buffer, COLOR_INACTIVE_ITEM, COLOR_TRANS, 27,
+ PRINT_STRING_BG(down_screen_addr, line_buffer, COLOR_INACTIVE_ITEM, COLOR_TRANS, 27,
40 + (display_option->line_number)*27);
num_byte = freespace;
@@ -2938,7 +2854,7 @@ u32 menu(u16 *screen)
strcat(line_buffer, ".0 GB");
}
- PRINT_STRING_BG_UTF8(down_screen_addr, line_buffer, COLOR_INACTIVE_ITEM, COLOR_TRANS, 147,
+ PRINT_STRING_BG(down_screen_addr, line_buffer, COLOR_INACTIVE_ITEM, COLOR_TRANS, 147,
40 + (display_option->line_number)*27);
}
@@ -2958,8 +2874,6 @@ u32 menu(u16 *screen)
char *enable_disable_options[] = { (char*)&msg[MSG_EN_DIS_ABLE_0], (char*)&msg[MSG_EN_DIS_ABLE_1] };
- char *language_options[] = { (char*)&lang[0], (char*)&lang[1] };
-
char *keyremap_options[] = {(char*)&msg[MSG_KEY_MAP_NONE], (char*)&msg[MSG_KEY_MAP_A], (char*)&msg[MSG_KEY_MAP_B],
(char*)&msg[MSG_KEY_MAP_SL], (char*)&msg[MSG_KEY_MAP_ST], (char*)&msg[MSG_KEY_MAP_RT],
(char*)&msg[MSG_KEY_MAP_LF], (char*)&msg[MSG_KEY_MAP_UP], (char*)&msg[MSG_KEY_MAP_DW],
@@ -3117,7 +3031,7 @@ u32 menu(u16 *screen)
/* 01 */ NUMERIC_SELECTION_OPTION(NULL, &msg[MSG_SUB_MENU_42], &clock_speed_number, 6, NULL, 1),
/* 02 */ STRING_SELECTION_OPTION(language_set, NULL, &msg[MSG_SUB_MENU_41], language_options,
- &emu_config.language, 2, NULL, ACTION_TYPE, 2),
+ &emu_config.language, sizeof(language_options) / sizeof(language_options[0]) /* number of possible languages */, NULL, ACTION_TYPE, 2),
/* 03 */ STRING_SELECTION_OPTION(NULL, show_card_space, &msg[MSG_SUB_MENU_43], NULL,
&desert, 2, NULL, PASSIVE_TYPE | HIDEN_TYPE, 3),
@@ -3453,7 +3367,7 @@ u32 menu(u16 *screen)
{
draw_hscroll_over(current_option_num-1);
ext_pos= strrchr(emu_config.latest_file[current_option_num-1], '/');
- draw_hscroll_init(down_screen_addr, 26, 35 + (current_option_num-1)*27, 200,
+ draw_hscroll_init(down_screen_addr, 26, 40 + (current_option_num-1)*27, 200,
COLOR_TRANS, COLOR_INACTIVE_ITEM, ext_pos+1);
}
@@ -3491,11 +3405,11 @@ u32 menu(u16 *screen)
draw_message(down_screen_addr, bg_screenp, 28, 31, 227, 165, 0);
draw_string_vcenter(down_screen_addr, 36, 100, 190, COLOR_MSSG, msg[MSG_LOADING_GAME]);
- ds2_flipScreen(DOWN_SCREEN, 2);
+ ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD);
if(gamepak_name[0] != 0)
{
- //S9xAutoSaveSRAM ();
+ S9xAutoSaveSRAM ();
save_game_config_file();
}
@@ -3511,7 +3425,12 @@ u32 menu(u16 *screen)
*ext_pos= '/';
ext_pos = emu_config.latest_file[current_option_num -1];
- if(load_gamepak(ext_pos) == -1) {
+
+ ds2_setCPUclocklevel(13);
+ int load_result = load_gamepak(ext_pos);
+ ds2_setCPUclocklevel(0);
+
+ if(load_result == -1) {
first_load = 1;
return;
}
@@ -3570,7 +3489,7 @@ u32 menu(u16 *screen)
else
color= COLOR_INACTIVE_ITEM;
- PRINT_STRING_BG_UTF8(down_screen_addr, line_buffer, color, COLOR_TRANS, 26, 37 + line_num*32);
+ PRINT_STRING_BG(down_screen_addr, line_buffer, color, COLOR_TRANS, 26, 37 + line_num*32);
}
void game_fastforward()
@@ -3583,8 +3502,8 @@ u32 menu(u16 *screen)
{
for(i = 0; i < CHEATS_PER_PAGE; i++)
{
- cheats_options[i+1].display_string = &cheat_format_ptr[(CHEATS_PER_PAGE * menu_cheat_page) + i];
- cheats_options[i+1].current_option = &(game_config.cheats_flag[(CHEATS_PER_PAGE * menu_cheat_page) + i].active);
+ cheats_options[i+1].display_string = &cheat_data_ptr[(CHEATS_PER_PAGE * menu_cheat_page) + i];
+ cheats_options[i+1].current_option = &(Cheat.c[(CHEATS_PER_PAGE * menu_cheat_page) + i].enabled);
}
}
@@ -3617,7 +3536,7 @@ u32 menu(u16 *screen)
//----------------------------------------------------------------------------//
// Menu Start
ds2_setCPUclocklevel(0);
- mdelay(200);
+ // mdelay(200); // Delete this delay
ds2_setBacklight(3);
@@ -3640,6 +3559,11 @@ u32 menu(u16 *screen)
}
else
{
+ /*
+ * It's pretty complicated. These two flips are needed because,
+ * otherwise, the menu freezes if S9xAutoSaveSRAM was called after
+ * loading from a save state.
+ */
ds2_flipScreen(UP_SCREEN, 1);
ds2_flipScreen(UP_SCREEN, 1);
}
@@ -3647,7 +3571,6 @@ u32 menu(u16 *screen)
choose_menu(&main_menu);
// Menu loop
- mdelay(200);
while(repeat)
{
@@ -3746,7 +3669,7 @@ u32 menu(u16 *screen)
else
color= COLOR_INACTIVE_ITEM;
- PRINT_STRING_BG_UTF8(down_screen_addr, line_buffer, color, COLOR_TRANS, 23, 40 + i*27);
+ PRINT_STRING_BG(down_screen_addr, line_buffer, color, COLOR_TRANS, 23, 40 + i*27);
}
}
}
@@ -3767,26 +3690,13 @@ u32 menu(u16 *screen)
/* Main menu */
if(current_menu == &main_menu)
{
- if(inputdata.x <= 86 && inputdata.y <= 80)
- current_option_num = 0;
- else if(inputdata.x <= 172 && inputdata.y <= 80)
- current_option_num = 1;
- else if(inputdata.x <= 256 && inputdata.y <= 80)
- current_option_num = 2;
- else if(inputdata.x <= 86 && inputdata.y <= 160)
- current_option_num = 3;
- else if(inputdata.x <= 172 && inputdata.y <= 160)
- current_option_num = 4;
- else if(inputdata.x <= 256 && inputdata.y <= 160)
- current_option_num = 5;
- else if(inputdata.x <= 86 && inputdata.y <= 192)
- current_option_num = 6;
- else if(inputdata.x <= 172 && inputdata.y <= 192)
- current_option_num = 7;
- else if(inputdata.x <= 256 && inputdata.y <= 192)
- current_option_num = 8;
- else
- break;
+ // 0 86 172 256
+ // _____ _____ _____ 0
+ // |0VID_|1SAV_|2CHT_| 80
+ // |3TLS_|4OPT_|5EXI_| 160
+ // |6NEW_|7RET_|8RST_| 192
+
+ current_option_num = (inputdata.y / 80) * 3 + (inputdata.x / 86);
current_option = current_menu->options + current_option_num;
if(current_option -> option_type & HIDEN_TYPE)
@@ -3805,31 +3715,22 @@ u32 menu(u16 *screen)
&& current_menu != (main_menu.options +6)->sub_menu
&& current_menu != ((main_menu.options +6)->sub_menu->options + 2)->sub_menu)
{
- if(inputdata.y <= 33)
+ if (inputdata.y <= 33 || inputdata.y > 192)
break;
- else if(inputdata.y <= 60)
- current_option_num = 1;
- else if(inputdata.y <= 87)
- current_option_num = 2;
- else if(inputdata.y <= 114)
- current_option_num = 3;
- else if(inputdata.y <= 141)
- current_option_num = 4;
- else if(inputdata.y <= 168)
- current_option_num = 5;
- else if(inputdata.y <= 192)
- current_option_num = 6;
- else
- break;
-
+ // ___ 33 This screen has 6 possible rows. Touches
+ // ___ 60 above or below these are ignored.
+ // . . . (+27) The row between 33 and 60 is [1], though!
+ // ___ 192
+ current_option_num = (inputdata.y - 33) / 27 + 1;
+
current_option = current_menu->options + current_option_num;
-
+
if(current_option -> option_type & HIDEN_TYPE)
break;
-
+
if(!current_option)
break;
-
+
if(current_menu->key_function)
{
gui_action = CURSOR_RIGHT;
@@ -3872,33 +3773,16 @@ u32 menu(u16 *screen)
u32 current_option_val = *(current_option->current_option);
u32 old_option_val = current_option_val;
- if(inputdata.x <= 25)
- break;
- else if(inputdata.x <= 45)
- current_option_val = 0;
- else if(inputdata.x <= 65)
- current_option_val = 1;
- else if(inputdata.x <= 86)
- current_option_val = 2;
- else if(inputdata.x <= 107)
- current_option_val = 3;
- else if(inputdata.x <= 128)
- current_option_val = 4;
- else if(inputdata.x <= 149)
- current_option_val = 5;
- else if(inputdata.x <= 170)
- current_option_val = 6;
- else if(inputdata.x <= 191)
- current_option_val = 7;
- else if(inputdata.x <= 212)
- current_option_val = 8;
- else if(inputdata.x <= 233)
- current_option_val = 9;
- else
+ if(inputdata.x <= 23 || inputdata.x > 233)
break;
-
+ // | | | | | | | | | | |
+ // 23 44 65 86 ... (+21) 233
+ // This row has 10 cells for save states, each 21
+ // pixels wide.
+ current_option_val = (inputdata.x - 23) / 21;
+
*(current_option->current_option) = current_option_val;
-
+
if(current_option_val == old_option_val)
{
gui_action = CURSOR_SELECT;
@@ -3939,33 +3823,16 @@ u32 menu(u16 *screen)
u32 current_option_val = *(current_option->current_option);
u32 old_option_val = current_option_val;
- if(inputdata.x <= 25)
- break;
- else if(inputdata.x <= 45)
- current_option_val = 0;
- else if(inputdata.x <= 65)
- current_option_val = 1;
- else if(inputdata.x <= 86)
- current_option_val = 2;
- else if(inputdata.x <= 107)
- current_option_val = 3;
- else if(inputdata.x <= 128)
- current_option_val = 4;
- else if(inputdata.x <= 149)
- current_option_val = 5;
- else if(inputdata.x <= 170)
- current_option_val = 6;
- else if(inputdata.x <= 191)
- current_option_val = 7;
- else if(inputdata.x <= 212)
- current_option_val = 8;
- else if(inputdata.x <= 233)
- current_option_val = 9;
- else
+ if(inputdata.x <= 23 || inputdata.x > 233)
break;
-
+ // | | | | | | | | | | |
+ // 23 44 65 86 ... (+21) 233
+ // This row has 10 cells for save states, each 21
+ // pixels wide.
+ current_option_val = (inputdata.x - 23) / 21;
+
*(current_option->current_option) = current_option_val;
-
+
if(current_option_val == old_option_val)
{
gui_action = CURSOR_SELECT;
@@ -3991,25 +3858,16 @@ u32 menu(u16 *screen)
|| current_menu == (main_menu.options + 6)->sub_menu
|| current_menu == ((main_menu.options +6)->sub_menu->options + 2)->sub_menu)
{
- if(inputdata.y <= 33)
- break;
- else if(inputdata.y <= 60)
- current_option_num = 1;
- else if(inputdata.y <= 87)
- current_option_num = 2;
- else if(inputdata.y <= 114)
- current_option_num = 3;
- else if(inputdata.y <= 141)
- current_option_num = 4;
- else if(inputdata.y <= 168)
- current_option_num = 5;
- else if(inputdata.y <= 192)
- current_option_num = 6;
- else
+ if (inputdata.y <= 33 || inputdata.y > 192)
break;
-
+ // ___ 33 This screen has 6 possible rows. Touches
+ // ___ 60 above or below these are ignored.
+ // . . . (+27) The row between 33 and 60 is [1], though!
+ // ___ 192
+ current_option_num = (inputdata.y - 33) / 27 + 1;
+
current_option = current_menu->options + current_option_num;
-
+
if(current_option -> option_type & HIDEN_TYPE)
break;
else if(current_option->option_type & ACTION_TYPE)
@@ -4119,7 +3977,7 @@ u32 menu(u16 *screen)
break;
} // end swith
- ds2_flipScreen(DOWN_SCREEN, 2);
+ ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD);
} // end while
destroy_dynamic_cheats();
if(bg_screenp != NULL) free((void*)bg_screenp);
@@ -4129,28 +3987,18 @@ u32 menu(u16 *screen)
game_config.clock_speed_number = clock_speed_number;
reorder_latest_file();
- //S9xAutoSaveSRAM ();
+ S9xAutoSaveSRAM ();
save_game_config_file();
}
save_emu_config_file();
- mdelay(100);
set_cpu_clock(clock_speed_number);
- mdelay(200);
ds2_clearScreen(DOWN_SCREEN, 0);
ds2_flipScreen(DOWN_SCREEN, 1);
- ds2_clearScreen(UP_SCREEN, 0);
- ds2_flipScreen(UP_SCREEN, 1);
- ds2_clearScreen(UP_SCREEN, 0);
- ds2_flipScreen(UP_SCREEN, 1);
+ copy_screen(up_screen_addr, (void*) screen, 0, 0, 256, 192);
+ ds2_flipScreen(UP_SCREEN, UP_SCREEN_UPDATE_METHOD);
ds2_setBacklight(2);
-//save game config
-// save_game_config_file();
-// save_emu_config_file();
-
-
-// ds2_setCPUclocklevel(12);
wait_Allkey_release(0);
return return_value;
@@ -4192,6 +4040,7 @@ int load_language_msg(char *filename, u32 language)
switch(language)
{
case ENGLISH:
+ default:
strcpy(start, "STARTENGLISH");
strcpy(end, "ENDENGLISH");
cmplen= 12;
@@ -4201,10 +4050,10 @@ int load_language_msg(char *filename, u32 language)
strcpy(end, "ENDCHINESESIM");
cmplen= 15;
break;
- default:
- strcpy(start, "STARTENGLISH");
- strcpy(end, "ENDENGLISH");
- cmplen= 12;
+ case FRENCH:
+ strcpy(start, "STARTFRENCH");
+ strcpy(end, "ENDFRENCH");
+ cmplen= 11;
break;
}
//find the start flag
@@ -4308,21 +4157,13 @@ void init_game_config(void)
{
u32 i;
- game_config.clock_speed_number = 2; //360MHz
- clock_speed_number = 2;
- game_config.graphic = 0;
+ game_config.clock_speed_number = 5; // 396 MHz by default
+ clock_speed_number = 5;
+ game_config.graphic = 3; // By default, have a good-looking aspect ratio
game_config.gamepad_config_menu = BUTTON_ID_TOUCH;
memcpy(game_config.gamepad_config_map, gamepad_config_map_init, sizeof(gamepad_config_map_init));
- for(i = 0; i < MAX_CHEATS; i++)
- {
- game_config.cheats_flag[i].active = 0;
- game_config.cheats_flag[i].name_shot[0] = '\0';
- }
-
- memset(game_config.cheat_filename, 0x0, MAX_PATH);
-
game_config.backward = 0; //time backward disable
game_config.backward_time = 2; //time backward granularity 1s
@@ -4841,7 +4682,7 @@ void gui_init(u32 lang_id)
{
int flag;
- ds2_setCPUclocklevel(11);
+ ds2_setCPUclocklevel(13); // Crank it up. When the menu starts, -> 0.
printf_clock();
//Find the "CATSFC" system directory
@@ -4862,23 +4703,23 @@ void gui_init(u32 lang_id)
strcpy(main_path, "fat:");
if(search_dir("CATSFC", main_path) == 0)
{
- printf("Dirctory find: %s\n", main_path);
+ printf("Found CATSFC directory\r\nDossier CATSFC trouve\r\n\r\n%s\r\n", main_path);
}
else
{
- err_msg(DOWN_SCREEN, "Can't fine CATSFC directory, press any key to exit\n");
+ err_msg(DOWN_SCREEN, "/CATSFC: Directory missing\r\nPress any key to return to\r\nthe menu\r\n\r\n/CATSFC: Dossier manquant\r\nAppuyer sur une touche pour\r\nretourner au menu");
goto gui_init_err;
}
}
}
show_log(down_screen_addr);
- ds2_flipScreen(DOWN_SCREEN, 1);
+ ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD);
flag = icon_init(lang_id);
if(0 != flag)
{
- err_msg(DOWN_SCREEN, "some icon can't open when initial GUI, press any key to exit\n");
+ err_msg(DOWN_SCREEN, "Some icons are missing\r\nLoad them onto your card\r\nPress any key to return to\r\nthe menu\r\n\r\nDes icones sont manquantes\r\nChargez-les sur votre carte\r\nAppuyer sur une touche pour\r\nretourner au menu");
goto gui_init_err;
}
@@ -4886,7 +4727,9 @@ void gui_init(u32 lang_id)
flag = load_font();
if(0 != flag)
{
- err_msg(DOWN_SCREEN, "initial font library error, press any key to exit\n");
+ char message[512];
+ sprintf(message, "Font library initialisation\r\nerror (%d)\r\nPress any key to return to\r\nthe menu\r\n\r\nErreur d'initalisation de la\r\npolice de caracteres (%d)\r\nAppuyer sur une touche pour\r\nretourner au menu", flag, flag);
+ err_msg(DOWN_SCREEN, message);
goto gui_init_err;
}
@@ -4896,21 +4739,18 @@ void gui_init(u32 lang_id)
flag = load_language_msg(LANGUAGE_PACK, lang_id);
if(0 != flag)
{
- err_msg(DOWN_SCREEN, "initial language package error, press any key to exit\n");
+ char message[512];
+ sprintf(message, "Language pack initialisation\r\nerror (%d)\r\nPress any key to return to\r\nthe menu\r\n\r\nErreur d'initalisation du\r\npack de langue (%d)\r\nAppuyer sur une touche pour\r\nretourner au menu", flag, flag);
+ err_msg(DOWN_SCREEN, message);
goto gui_init_err;
}
initial_path_config();
-
return;
gui_init_err:
- ds2_flipScreen(DOWN_SCREEN, 1);
+ ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD);
wait_Anykey_press(0);
quit();
- while(1);
}
-
-
-
diff --git a/source/nds/gui.h b/source/nds/gui.h
index e845994..9ebaf26 100644
--- a/source/nds/gui.h
+++ b/source/nds/gui.h
@@ -15,47 +15,46 @@
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef __GUI_H__
-#define __GUI_H__
+ */
+
+#ifndef __GUI_H__
+#define __GUI_H__
#include "ds2_types.h"
#include "fs_api.h"
#include "gcheat.h"
-
+
+#define UP_SCREEN_UPDATE_METHOD 0
+#define DOWN_SCREEN_UPDATE_METHOD 2
+
#define MAX_GAMEPAD_MAP 16
-
+
#ifdef __cplusplus
extern "C" {
#endif
-
-//
-struct _EMU_CONFIG
-{
- u32 language;
+
+//
+struct _EMU_CONFIG
+{
+ u32 language;
char rom_file[256];
char rom_path[256];
char latest_file[5][512];
-};
-
-struct _GAME_CONFIG
-{
+};
+
+struct _GAME_CONFIG
+{
u32 clock_speed_number;
u32 frameskip_type;
u32 frameskip_value;
u32 graphic;
- u32 enable_audio;
- u32 gamepad_config_menu;
+ u32 enable_audio;
+ u32 gamepad_config_menu;
u32 backward;
u32 backward_time;
- u32 reserve[32];
+ u32 reserve[32];
u32 gamepad_config_map[MAX_GAMEPAD_MAP];
- GCHEAT_STRUCT cheats_flag[MAX_CHEATS];
- char cheat_filename[MAX_PATH];
- unsigned int cheat_str_num;
- unsigned int cheat_str_size;
-};
+};
typedef enum
{
@@ -98,28 +97,29 @@ extern char main_path[MAX_PATH];
extern char rom_path[MAX_PATH];
extern u32 game_enable_audio;
-
-/******************************************************************************
- ******************************************************************************/ extern char g_default_rom_dir[MAX_PATH];
-extern char DEFAULT_RTS_DIR[MAX_PATH];
-extern char DEFAULT_CFG_DIR[MAX_PATH];
-extern char DEFAULT_SS_DIR[MAX_PATH];
-extern char DEFAULT_CHEAT_DIR[MAX_PATH];
+
+/******************************************************************************
+ ******************************************************************************/
+extern char g_default_rom_dir[MAX_PATH];
+extern char DEFAULT_RTS_DIR[MAX_PATH];
+extern char DEFAULT_CFG_DIR[MAX_PATH];
+extern char DEFAULT_SS_DIR[MAX_PATH];
+extern char DEFAULT_CHEAT_DIR[MAX_PATH];
typedef struct _EMU_CONFIG EMU_CONFIG;
typedef struct _GAME_CONFIG GAME_CONFIG;
-
-extern EMU_CONFIG emu_config;
-extern GAME_CONFIG game_config;
-/******************************************************************************
- ******************************************************************************/
-extern void gui_init(u32 lang_id);
+extern EMU_CONFIG emu_config;
+extern GAME_CONFIG game_config;
+
+/******************************************************************************
+ ******************************************************************************/
+extern void gui_init(u32 lang_id);
extern u32 menu(u16 *original_screen);
extern void game_disableAudio();
#ifdef __cplusplus
}
#endif
-
-#endif //__GUI_H__
+
+#endif //__GUI_H__
diff --git a/source/nds/message.h b/source/nds/message.h
index fc6bd33..4a0acd2 100644
--- a/source/nds/message.h
+++ b/source/nds/message.h
@@ -165,9 +165,11 @@ enum MSG
enum LANGUAGE{
ENGLISH,
CHINESE_SIMPLIFIED,
- CHINESE_TRADITIONAL
+ FRENCH
};
+extern char* lang[3]; // Allocated in gui.c, needs to match the languages ^
+
char *msg[MSG_END+1];
char msg_data[16 * 1024];