Skip to content

Commit d7f9076

Browse files
author
unknown
committed
import v0.8
1 parent 50835eb commit d7f9076

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+21955
-0
lines changed

Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
TARGET = eReader
2+
OBJS = bg.o bookmark.o charsets.o conf.o ctrl.o display.o fat.o fs.o html.o image.o main.o mp3.o power.o scene.o usb.o win.o\
3+
./common/log.o ./common/utils.o
4+
5+
INCDIR = $(PSPSDK)/../include
6+
7+
CFLAGS = -O2 -G0 -Wall -DFONT12 #-D_DEBUG
8+
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
9+
10+
LIBS = ./lib/unzip.a ./lib/libchm.a ./lib/libpng.a ./lib/libgif.a ./lib/libjpeg.a ./lib/libbmp.a ./lib/libtga.a ./lib/libmad.a ./lib/libid3tag.a ./lib/libz.a \
11+
-lc -lm -lpsppower -lpspaudiolib -lpspaudio -lpspusb -lpspusbstor
12+
13+
#LIBDIR =
14+
#LDFLAGS =
15+
16+
EXTRA_TARGETS = EBOOT.PBP
17+
PSP_EBOOT_TITLE = eReader
18+
#PSP_EBOOT_ICON = ICON0.png
19+
20+
include $(PSPSDK)/lib/build.mak

bg.c

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#include <stdlib.h>
2+
#include <string.h>
3+
#include "display.h"
4+
#include "image.h"
5+
#include "bg.h"
6+
7+
static dword * bg_start = (dword *)0x44110000;
8+
static bool have_bg = false;
9+
10+
extern void bg_load(const char * filename)
11+
{
12+
dword * imgdata, * imgshow = NULL, * img_buf, * bg_buf, * bg_line, * bg_end, * bg_lineend;
13+
dword width, height, w2, h2, bgcolor, left, top;
14+
if(image_readpng(filename, &width, &height, &imgdata, &bgcolor) != 0)
15+
return;
16+
if(width > 480)
17+
{
18+
h2 = height * 480 / width;
19+
if(h2 > 272)
20+
{
21+
h2 = 272;
22+
w2 = width * 272 / height;
23+
}
24+
else
25+
w2 = 480;
26+
}
27+
else if(height > 272)
28+
{
29+
h2 = 272;
30+
w2 = width * 272 / height;
31+
}
32+
else
33+
{
34+
h2 = height;
35+
w2 = width;
36+
}
37+
if(width != w2 || height != h2)
38+
{
39+
imgshow = (dword *)malloc(sizeof(dword) * w2 * h2);
40+
if(imgshow == NULL)
41+
{
42+
free((void *)imgdata);
43+
return;
44+
}
45+
image_zoom_bicubic(imgdata, width, height, imgshow, w2, h2);
46+
}
47+
else
48+
imgshow = imgdata;
49+
50+
if(w2 < 480)
51+
left = (480 - w2) / 2;
52+
else
53+
left = 0;
54+
if(h2 < 272)
55+
top = (272 - h2) / 2;
56+
else
57+
top = 0;
58+
59+
for(bg_buf = bg_start, bg_end = bg_start + 0x88000; bg_buf < bg_end; bg_buf ++)
60+
* bg_buf = bgcolor;
61+
img_buf = imgshow;
62+
for(bg_buf = bg_start + top * 512 + left, bg_end = bg_buf + h2 * 512; bg_buf < bg_end; bg_buf += 512)
63+
for(bg_line = bg_buf, bg_lineend = bg_buf + w2; bg_line < bg_lineend; bg_line ++)
64+
*bg_line = *img_buf ++;
65+
66+
have_bg = true;
67+
68+
if(imgshow != imgdata)
69+
free((void *)imgshow);
70+
free((void *)imgdata);
71+
}
72+
73+
extern bool bg_display()
74+
{
75+
if(have_bg)
76+
{
77+
memcpy(vram_start, bg_start, 0x88000);
78+
return true;
79+
}
80+
return false;
81+
}

bg.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#ifndef _BG_H_
2+
#define _BG_H_
3+
4+
#include "common/datatype.h"
5+
6+
extern void bg_load(const char * filename);
7+
extern bool bg_display();
8+
9+
#endif

bookmark.c

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#include <sys/stat.h>
2+
#include <stdlib.h>
3+
#include <string.h>
4+
#include <pspkernel.h>
5+
#include "common/utils.h"
6+
#include "bookmark.h"
7+
8+
static char bmdir[256];
9+
10+
static void bookmark_encode(const char * filename, char * destname)
11+
{
12+
register dword h, l;
13+
char destfilename[10];
14+
15+
for (h = 5381; * filename != 0; ++filename) {
16+
h += h << 5;
17+
h ^= *filename;
18+
}
19+
l = utils_dword2string(h, destfilename, 10);
20+
strcpy(destname, bmdir);
21+
strcat(destname, &destfilename[l]);
22+
}
23+
24+
extern void bookmark_setbasedir(const char * dir)
25+
{
26+
strcpy(bmdir, dir);
27+
strcat(bmdir, "bookmarks/");
28+
mkdir(bmdir, 0777);
29+
}
30+
31+
extern p_bookmark bookmark_open(const char * filename)
32+
{
33+
int fd;
34+
p_bookmark bm = (p_bookmark)calloc(1, sizeof(t_bookmark));
35+
if(bm == NULL)
36+
return NULL;
37+
memset(bm->row, 0xFF, 10 * sizeof(dword));
38+
bookmark_encode(filename, bm->filename);
39+
fd = sceIoOpen(bm->filename, PSP_O_RDONLY, 0777);
40+
if(fd < 0)
41+
return bm;
42+
sceIoRead(fd, bm->row, 10 * sizeof(dword));
43+
sceIoClose(fd);
44+
return bm;
45+
}
46+
47+
extern void bookmark_save(p_bookmark bm)
48+
{
49+
int fd = sceIoOpen(bm->filename, PSP_O_CREAT | PSP_O_WRONLY, 0777);
50+
if(fd < 0)
51+
return;
52+
sceIoWrite(fd, bm->row, 10 * sizeof(dword));
53+
sceIoClose(fd);
54+
}
55+
56+
extern void bookmark_close(p_bookmark bm)
57+
{
58+
free((void *)bm);
59+
}
60+
61+
extern dword bookmark_autoload(const char * filename)
62+
{
63+
int fd;
64+
char bmfn[256];
65+
dword row = 0;
66+
bookmark_encode(filename, bmfn);
67+
if((fd = sceIoOpen(bmfn, PSP_O_RDONLY, 0777)) < 0)
68+
return 0;
69+
sceIoRead(fd, &row, sizeof(dword));
70+
sceIoClose(fd);
71+
if(row == 0xFFFFFFFF)
72+
row = 0;
73+
return row;
74+
}
75+
76+
extern void bookmark_autosave(const char * filename, dword row)
77+
{
78+
int fd;
79+
char bmfn[256];
80+
bookmark_encode(filename, bmfn);
81+
if((fd = sceIoOpen(bmfn, PSP_O_RDWR, 0777)) >= 0 || (fd = sceIoOpen(bmfn, PSP_O_CREAT | PSP_O_WRONLY, 0777)) >= 0)
82+
{
83+
sceIoWrite(fd, &row, sizeof(dword));
84+
sceIoClose(fd);
85+
}
86+
}

bookmark.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#ifndef _BOOKMARK_H_
2+
#define _BOOKMARK_H_
3+
4+
#include "common/datatype.h"
5+
6+
typedef struct {
7+
char filename[256];
8+
dword row[10];
9+
} t_bookmark, * p_bookmark;
10+
11+
extern void bookmark_setbasedir(const char * dir);
12+
extern p_bookmark bookmark_open(const char * filename);
13+
extern void bookmark_save(p_bookmark bm);
14+
extern void bookmark_close(p_bookmark bm);
15+
extern dword bookmark_autoload(const char * filename);
16+
extern void bookmark_autosave(const char * filename, dword row);
17+
18+
#endif

0 commit comments

Comments
 (0)