Skip to content

Commit 10e27d1

Browse files
committed
font setting fix and some errors text updated
1 parent 02736a5 commit 10e27d1

10 files changed

+47
-33
lines changed

.vscode/c_cpp_properties.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"${workspaceFolder}/**",
77
"C:/devkitPro/libnds/include/**",
88
"C:/devkitPro/devkitARM/arm-none-eabi/include/**",
9-
"${workspaceFolder}/include"
9+
"${workspaceFolder}/include/**"
1010
],
1111
"defines": [
1212
"ARM9",
@@ -15,7 +15,8 @@
1515
"compilerPath": "/usr/bin/g++",
1616
"cStandard": "c11",
1717
"cppStandard": "c++17",
18-
"intelliSenseMode": "${default}"
18+
"intelliSenseMode": "${default}",
19+
"configurationProvider": "ms-vscode.makefile-tools"
1920
}
2021
],
2122
"version": 4

.vscode/settings.json

+19-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,24 @@
33
"fstream": "cpp",
44
"xstring": "cpp",
55
"vector": "cpp",
6-
"utility": "cpp"
6+
"utility": "cpp",
7+
"xtree": "cpp",
8+
"set": "cpp",
9+
"functional": "cpp",
10+
"random": "cpp",
11+
"xlocale": "cpp",
12+
"xlocnum": "cpp",
13+
"xloctime": "cpp",
14+
"istream": "cpp",
15+
"array": "cpp",
16+
"deque": "cpp",
17+
"initializer_list": "cpp",
18+
"list": "cpp",
19+
"queue": "cpp",
20+
"ranges": "cpp",
21+
"span": "cpp",
22+
"type_traits": "cpp",
23+
"xhash": "cpp",
24+
"xutility": "cpp"
725
}
826
}

arm9/source/book.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,6 @@ void Book :: loadMarks()
411411

412412
string fileReq(const string& path)
413413
{
414-
char fname[MAXNAMLEN];
415-
416414
DIR* dir = opendir(path.c_str());
417415
struct dirent* ent;
418416
if(!dir) bsod(("book.filereq: cannot open " + path).c_str());

arm9/source/epub.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ u32 loadFromZip(unzFile& zip, const char* file, char *&buf)
1818
if(buf == NULL) bsod("Out of memory");
1919
unzReadCurrentFile(zip, buf, info.uncompressed_size);
2020
unzCloseCurrentFile(zip);
21-
} else bsod("Can't open epub. (3)");
21+
} else bsod("epub.loadFromZip:Can't open epub. (3)");
2222
} else bsod("Can't open epub. (2)");
2323
return info.uncompressed_size;
2424
}
@@ -29,10 +29,10 @@ void epub_book :: parse()
2929
{
3030
encoding = eUtf8;
3131
pugi::xml_document doc;
32-
const char err[] = "Can't load epub. (1)";
32+
const char err[] = "epub_book::parse:Can't load epub. (1)";
3333
char *buf = NULL;
3434
unzFile hArchiveFile = unzOpen(bookFile.c_str());
35-
if (hArchiveFile == NULL) bsod("Can't open epub.");
35+
if (hArchiveFile == NULL) bsod("epub_book::parse:Can't open epub.");
3636

3737
loadFromZip(hArchiveFile, "META-INF/container.xml", buf);
3838
pugi::xml_parse_result result = doc.load(buf);
@@ -68,9 +68,9 @@ void epub_book :: parse()
6868
renderer::clearScreens(0);
6969
for(u32 i = 0; i < chapter_files.size(); i++) {
7070
consoleClear();
71-
iprintf("unpacking %d/%d\n", i+1, chapter_files.size());
71+
iprintf("unpacking %lu/%d\n", i+1, chapter_files.size());
7272
u32 size = loadFromZip(hArchiveFile, (chapter_path + chapter_files[i]).c_str(), buf);
73-
if(offsets.back() + size > giant_buf_size - 1u) bsod("book buffer exhausted");
73+
if(offsets.back() + size > giant_buf_size - 1u) bsod("epub_book::parse:book buffer exhausted");
7474
memcpy(giant_buffer + offsets[i], buf, size);
7575
offsets.push_back(offsets.back() + size);
7676
delete[] buf;
@@ -81,7 +81,7 @@ void epub_book :: parse()
8181
iprintf("parsing...\n");
8282
pugi::xml_parse_result result = document.load_buffer_inplace(giant_buffer, offsets.back());
8383
if(result.status != pugi::status_ok) {
84-
if(result.status == pugi::status_out_of_memory) bsod("Out of memory.");
84+
if(result.status == pugi::status_out_of_memory) bsod("epub_book::parse:Out of memory.");
8585
//else bsod("Parser error (bad format).");
8686
}
8787
parse_doc(document);

arm9/source/fb2.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <algorithm>
44
#include "renderer.h"
55

6-
const char giant_buf_err[] = "Exhausted book buffer.";
6+
const char giant_buf_err[] = "fb2.bufferFb2:Exhausted book buffer.";
77

88
u32 bufferFb2(const char* file)
99
{
@@ -30,7 +30,7 @@ u32 bufferFb2(const char* file)
3030
u32 fb2_loadToGiantBuffer(const char* filename)
3131
{
3232
FILE* File = fopen(filename, "rb");
33-
if(File == NULL) bsod("Can't load file.");
33+
if(File == NULL) bsod("fb2.fb2_loadToGiantBuffer:Can't load file.");
3434
fseek(File, 0 , SEEK_END);
3535
int size = ftell (File);
3636
rewind(File);
@@ -39,7 +39,7 @@ u32 fb2_loadToGiantBuffer(const char* filename)
3939
return bufferFb2(filename);
4040
}
4141
int read = fread(giant_buffer, 1, size, File);
42-
if(read < size) bsod("Error reading file.");
42+
if(read < size) bsod("fb2.fb2_loadToGiantBuffer:Error reading file.");
4343
fclose(File);
4444
return size;
4545
}
@@ -49,8 +49,8 @@ void fb2_book :: parse()
4949
u32 size = fb2_loadToGiantBuffer(bookFile.c_str());
5050
pugi::xml_parse_result result = doc.load_buffer_inplace(giant_buffer, size, pugi::parse_default | pugi::parse_declaration);
5151
if(result.status != pugi::status_ok) {
52-
if(result.status == pugi::status_out_of_memory) bsod("Out of memory.");
53-
else bsod("Parser error (bad format).");
52+
if(result.status == pugi::status_out_of_memory) bsod("fb2.fb2_book:Out of memory.");
53+
else bsod("fb2.fb2_book:Parser error (bad format).");
5454
}
5555
push_it = true;
5656
string enc = doc.first_child().attribute("encoding").value();

arm9/source/file_browser.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ void file_browser :: cd()
2222
{
2323
pos = 0;
2424
flist.clear();
25-
char fname[MAXNAMLEN];
2625

2726
DIR* dir = opendir(path.c_str());
2827
struct dirent* ent;
29-
if(!dir) bsod(("file_browser.cd: cannot open " + path).c_str());
28+
if(!dir) bsod(("file_browser.cd:cannot open " + path).c_str());
3029

3130
if(path != "/") flist.push_back(entry(folder, ".."));
3231

@@ -77,7 +76,7 @@ string file_browser :: run()
7776
string start_path = settings::recent_book.substr(0, settings::recent_book.find_last_of('/')) + '/';
7877

7978
DIR* dir = opendir(path.c_str());
80-
if(!dir) bsod(("file_browser.run(): cannot open " + path).c_str());
79+
if(!dir) bsod(("file_browser.run:cannot open " + path).c_str());
8180

8281
if(dir == NULL || settings::recent_book.empty()) {
8382
start_path = "/books/";

arm9/source/main.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ void drawMenu()
3131
menu.push(SAY(light), 3);
3232
renderer::clearScreens(settings::bgCol);
3333
menu.draw();
34-
renderer::printStr(eUtf8, top_scr,5,17,"IkuReader 0.065",0,0,12);
34+
renderer::printStr(eUtf8, top_scr,5,17,"IkuReader 6.5_modern",0,0,12);
3535
powerOn(PM_BACKLIGHT_BOTTOM | PM_BACKLIGHT_TOP);
3636
}
3737

@@ -60,7 +60,7 @@ int main(int argc, char *argv[])
6060
settings::binname = binname;
6161

6262
iprintf("loading file system... ");
63-
if (!fatInitDefault()) bsod("main: error\n\ntried DLDI patch?");
63+
if (!fatInitDefault()) bsod("main:error\n\ntried DLDI patch?");
6464
consoleClear();
6565
DIR* dir = opendir("/data/ikureader/");
6666
if(!dir) bsod("main: \nFolder data/ikureader not found.\nCopy it to the root of your\nflash card from the installation package.");

arm9/source/renderer.cpp

+6-8
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
#include "encoding_tables.h"
44
#include <algorithm>
55
#include <time.h>
6-
#include <sys/dir.h>
7-
#include <sys/unistd.h>
86
#include <set>
97

108
#include <nds.h>
@@ -195,7 +193,7 @@ FT_Error ftcFaceRequester(FTC_FaceID faceID, FT_Library lib, FT_Pointer reqData,
195193
else file = p + *st;
196194

197195
FT_Error ft_err = FT_New_Face (ft_lib, file.c_str(), 0, aface);
198-
if(ft_err) bsod("Can't load font.");
196+
if(ft_err) bsod("renderer.ftcFaceRequester:Can't load font.");
199197
FT_Select_Charmap(face, FT_ENCODING_UNICODE);
200198
return ft_err;
201199
}
@@ -213,7 +211,7 @@ void initFonts()
213211
FT_Library_SetLcdFilter(ft_lib, FT_LCD_FILTER_DEFAULT) ||
214212
FTC_Manager_New(ft_lib, 3, 0, 0, ftcFaceRequester, 0, &ftcManager) ||
215213
FTC_SBitCache_New(ftcManager, &ftcSBitCache)
216-
) bsod("Freetype error.");
214+
) bsod("renderer.init_fonts:Freetype error.");
217215
FTC_Manager_LookupFace(ftcManager, &settings::font, &face);
218216
FTC_Manager_LookupFace(ftcManager, &settings::font_bold, &faceB);
219217
FTC_Manager_LookupFace(ftcManager, &settings::font_italic, &faceI);
@@ -383,21 +381,20 @@ void printClock(scr_id scr, bool forced)
383381

384382
void changeFont()
385383
{
386-
char fname[MAXNAMLEN];
387384
DIR* dir = opendir ("/data/ikureader/fonts/");
388-
if (dir == NULL) bsod("Cannot open fonts directory.");
385+
if (dir == NULL) bsod("renderer.change_font:Cannot open fonts directory.");
389386
struct dirent* ent;
390387
std::set<string> files;
391388
while ((ent = readdir(dir)) != NULL)
392-
if (ent->d_type != DT_DIR) if(extention(fname) == "ttf") files.insert(noExt(fname));
389+
if (ent->d_type != DT_DIR) if(extention(ent->d_name) == "ttf") files.insert(noExt(ent->d_name));
393390
closedir(dir);
394391
std::set<string> fonts;
395392

396393
for (std::set<string>::iterator it = files.begin(); it != files.end(); ++it)
397394
if(files.find(*it + 'b') != files.end() && files.find(*it + 'i') != files.end())
398395
fonts.insert(*it);
399396

400-
if(fonts.empty()) bsod("No fonts found.");
397+
if(fonts.empty()) bsod("renderer.change_font:No fonts found.");
401398

402399
std::set<string>::iterator current = ++fonts.find(noExt(settings::font));
403400
if(current == fonts.end()) current = fonts.begin();
@@ -408,6 +405,7 @@ void changeFont()
408405
FTC_Manager_Done(ftcManager);
409406
FT_Done_FreeType(ft_lib);
410407
initFonts();
408+
save();
411409
}
412410

413411
void TFlashClock :: show(scr_id scr)

arm9/source/settings.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ void load()
9090
}
9191

9292
if(end.compare("end") || !techCorrect) { //bad settings file
93-
iprintf("Warning: Can't read settings. Try using different firmware/loader.\n");
94-
iprintf("Press A to load defaults.\n");
93+
iprintf("settings.load:Warning: Can't read settings. Try using different firmware/loader.\n");
94+
iprintf("settings.load:Press A to load defaults.\n");
9595
while(!(keysDown() & KEY_A)) {scanKeys();}
9696
reset();
9797
save();
@@ -104,7 +104,7 @@ void save()
104104
std::ofstream os;
105105
os.open(SETTFILE, std::ios::binary);
106106
os.seekp(0 , std::ios::beg);
107-
if(!os.good() || !os.is_open()) bsod("Can't save settigns.");
107+
if(!os.good() || !os.is_open()) bsod("settings.save:Can't save settings.");
108108
settStruct st;
109109
os.write((char*)&st, sizeof(settStruct));
110110
os<<font <<'\n'<<

arm9/source/txt.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
void txt_book :: parse()
55
{
66
file_stream.open (bookFile.c_str(), std::fstream::binary);
7-
if(!file_stream.good()) bsod("Can't open book");
7+
if(!file_stream.good()) bsod("txt.txt_book:Can't open book");
88
const u8 Bom[] = "\xEF\xBB\xBF";
99
char beginning[3];
1010
file_stream.read(beginning, 3);

0 commit comments

Comments
 (0)