Skip to content

Commit 7ce951a

Browse files
committed
1 parent d7f9076 commit 7ce951a

File tree

176 files changed

+45220
-3063
lines changed

Some content is hidden

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

176 files changed

+45220
-3063
lines changed

ICON0.png

20.1 KB
Loading

Makefile

+19-12
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
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
2+
SRCS = avc.c bg.c bookmark.c charsets.c conf.c copy.c ctrl.c display.c fat.c \
3+
fs.c html.c image.c location.c lyric.c main.c mp3.c mp3info.c power.c \
4+
scene.c text.c ttfont.c usb.c win.c \
5+
./common/log.c ./common/qsort.c ./common/utils.c ./common/psp_utils.c
6+
OBJS = $(SRCS:.c=.o)
47

5-
INCDIR = $(PSPSDK)/../include
8+
INCDIR = $(PSPSDK)/../include ./include ./include/freetype2
69

7-
CFLAGS = -O2 -G0 -Wall -DFONT12 #-D_DEBUG
8-
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
10+
CFLAGS = -O2 -G0 -Wall
11+
CXXFLAGS = $(CFLAGS) -fno-rtti
912

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 =
13+
LIBS = ./lib/unrar.a ./lib/unzip.a ./lib/libchm.a ./lib/libpng.a \
14+
./lib/libgif.a ./lib/libjpeg.a ./lib/libbmp.a ./lib/libtga.a \
15+
./lib/libmad.a ./lib/libz.a ./lib/libfreetype.a ./lib/libwmadec.a \
16+
./lib/pmpmodavc/pmpmodavclib.a ./lib/pmpmodavc/libavformat.a ./lib/pmpmodavc/libavcodec.a ./lib/pmpmodavc/libavutil.a ./lib/pmpmodavc/libpspmpeg.a ./lib/pmpmodavc/pmpmodavclib.a \
17+
-lm -lpspaudio -lpspaudiolib -lpspgu -lpspgum -lpsphprm -lpsppower -lpsprtc \
18+
-lpspusb -lpspusbstor -lstdc++
1519

1620
EXTRA_TARGETS = EBOOT.PBP
21+
EXTRA_CLEAN = -r __SCE__eReader %__SCE__eReader eReader eReader% eReader.prx
1722
PSP_EBOOT_TITLE = eReader
18-
#PSP_EBOOT_ICON = ICON0.png
23+
PSP_EBOOT_ICON = ICON0.png
24+
25+
PSPSDK=$(shell psp-config --pspsdk-path)
1926

20-
include $(PSPSDK)/lib/build.mak
27+
include config.mak

avc.c

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
#include "config.h"
2+
3+
#ifdef ENABLE_PMPAVC
4+
5+
#include <pspsdk.h>
6+
#include <pspdisplay.h>
7+
#include <pspge.h>
8+
#include <psppower.h>
9+
#include <stdlib.h>
10+
#include <unistd.h>
11+
#include <string.h>
12+
#include "display.h"
13+
#include "bg.h"
14+
#include "avc.h"
15+
16+
static int pmp_inited = 0, id1 = -1, id2 = -1, id3 = -1, id4 = -1;
17+
static void *m1 = NULL, *m2 = NULL;
18+
char* avc_static_init();
19+
void* valloc(size_t size);
20+
void vfree(void* ptr);
21+
void av_register_all();
22+
char* gu_font_init();
23+
char* gu_font_load(char* name);
24+
void gu_font_close();
25+
26+
extern bool avc_init()
27+
{
28+
if(pmp_inited)
29+
return true;
30+
31+
m1 = valloc(4 * 512 * 272);
32+
m2 = valloc(4 * 512 * 272);
33+
34+
av_register_all();
35+
int id1 = pspSdkLoadStartModule("flash0:/kd/audiocodec.prx", PSP_MEMORY_PARTITION_KERNEL);
36+
if (id1 < 0)
37+
return false;
38+
39+
id2 = pspSdkLoadStartModule("flash0:/kd/videocodec.prx", PSP_MEMORY_PARTITION_KERNEL);
40+
if (id2 < 0)
41+
return false;
42+
43+
id3 = pspSdkLoadStartModule("flash0:/kd/mpegbase.prx", PSP_MEMORY_PARTITION_KERNEL);
44+
if (id3 < 0)
45+
return false;
46+
47+
id4 = pspSdkLoadStartModule("flash0:/kd/mpeg_vsh.prx", PSP_MEMORY_PARTITION_USER);
48+
if (id4 < 0)
49+
return false;
50+
51+
pspSdkFixupImports(id4);
52+
53+
gu_font_init();
54+
char ftn[256];
55+
getcwd(ftn, 256);
56+
strcat(ftn, "/font10.f");
57+
gu_font_load(ftn);
58+
59+
pmp_inited = 1;
60+
return true;
61+
}
62+
63+
extern void avc_free()
64+
{
65+
gu_font_close();
66+
if (m1 != NULL)
67+
{
68+
vfree(m1);
69+
}
70+
if (m2 != NULL)
71+
{
72+
vfree(m2);
73+
}
74+
if (id1 >= 0)
75+
{
76+
sceKernelStopModule(id1, 0, 0, 0, 0);
77+
sceKernelUnloadModule(id1);
78+
id1 = -1;
79+
}
80+
if (id2 >= 0)
81+
{
82+
sceKernelStopModule(id2, 0, 0, 0, 0);
83+
sceKernelUnloadModule(id2);
84+
id2 = -1;
85+
}
86+
if (id3 >= 0)
87+
{
88+
sceKernelStopModule(id3, 0, 0, 0, 0);
89+
sceKernelUnloadModule(id3);
90+
id3 = -1;
91+
}
92+
if (id4 >= 0)
93+
{
94+
sceKernelStopModule(id4, 0, 0, 0, 0);
95+
sceKernelUnloadModule(id4);
96+
id4 = -1;
97+
}
98+
}
99+
100+
extern void avc_start()
101+
{
102+
bg_cache();
103+
void * vram = (void*) (0x40000000 | (u32) sceGeEdramGetAddr());
104+
sceDisplaySetMode(0, 480, 272);
105+
sceDisplaySetFrameBuf(vram, 512, PSP_DISPLAY_PIXEL_FORMAT_8888, 1);
106+
memset(vram, 0, 4 * 512 * 272);
107+
scePowerLock(0);
108+
}
109+
110+
extern void avc_end()
111+
{
112+
scePowerUnlock(0);
113+
disp_init();
114+
bg_restore();
115+
}
116+
117+
#endif

avc.h

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ifndef _AVC_H
2+
#define _AVC_H
3+
4+
#include "common/datatype.h"
5+
6+
extern bool avc_init();
7+
extern void avc_free();
8+
extern void avc_start();
9+
extern void avc_end();
10+
extern char *pmp_play(char *s, int usePos);
11+
12+
#endif

bg.c

+73-9
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,44 @@
1+
#include "config.h"
2+
3+
#ifdef ENABLE_BG
4+
15
#include <stdlib.h>
26
#include <string.h>
37
#include "display.h"
48
#include "image.h"
59
#include "bg.h"
610

7-
static dword * bg_start = (dword *)0x44110000;
11+
static pixel * bg_start = (pixel *)(0x44000000 + 512 * 272 * PIXEL_BYTES * 2);
812
static bool have_bg = false;
13+
static dword imgwidth, imgheight;
914

10-
extern void bg_load(const char * filename)
15+
extern void bg_load(const char * filename, pixel bgcolor, t_fs_filetype ft, dword grayscale)
1116
{
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)
17+
pixel * imgdata, * imgshow = NULL, * img_buf, * bg_buf, * bg_line, * bg_end, * bg_lineend;
18+
dword width, height, w2, h2, left, top;
19+
pixel bgc;
20+
int result;
21+
switch(ft)
22+
{
23+
case fs_filetype_png:
24+
result = image_readpng(filename, &width, &height, &imgdata, &bgc);
25+
break;
26+
case fs_filetype_gif:
27+
result = image_readgif(filename, &width, &height, &imgdata, &bgc);
28+
break;
29+
case fs_filetype_jpg:
30+
result = image_readjpg(filename, &width, &height, &imgdata, &bgc);
31+
break;
32+
case fs_filetype_tga:
33+
result = image_readtga(filename, &width, &height, &imgdata, &bgc);
34+
break;
35+
case fs_filetype_bmp:
36+
result = image_readbmp(filename, &width, &height, &imgdata, &bgc);
37+
break;
38+
default:
39+
result = -1;
40+
}
41+
if(result != 0)
1542
return;
1643
if(width > 480)
1744
{
@@ -36,7 +63,7 @@ extern void bg_load(const char * filename)
3663
}
3764
if(width != w2 || height != h2)
3865
{
39-
imgshow = (dword *)malloc(sizeof(dword) * w2 * h2);
66+
imgshow = (pixel *)malloc(sizeof(pixel) * w2 * h2);
4067
if(imgshow == NULL)
4168
{
4269
free((void *)imgdata);
@@ -56,26 +83,63 @@ extern void bg_load(const char * filename)
5683
else
5784
top = 0;
5885

59-
for(bg_buf = bg_start, bg_end = bg_start + 0x88000; bg_buf < bg_end; bg_buf ++)
86+
for(bg_buf = bg_start, bg_end = bg_start + 0x22000; bg_buf < bg_end; bg_buf ++)
6087
* bg_buf = bgcolor;
6188
img_buf = imgshow;
89+
dword r = RGB_R(bgcolor), g = RGB_G(bgcolor), b = RGB_B(bgcolor);
6290
for(bg_buf = bg_start + top * 512 + left, bg_end = bg_buf + h2 * 512; bg_buf < bg_end; bg_buf += 512)
6391
for(bg_line = bg_buf, bg_lineend = bg_buf + w2; bg_line < bg_lineend; bg_line ++)
64-
*bg_line = *img_buf ++;
92+
{
93+
*bg_line = disp_grayscale(*img_buf, r, g, b, grayscale);
94+
img_buf ++;
95+
}
6596

6697
have_bg = true;
6798

6899
if(imgshow != imgdata)
69100
free((void *)imgshow);
101+
imgwidth = w2; imgheight = h2;
70102
free((void *)imgdata);
71103
}
72104

73105
extern bool bg_display()
74106
{
75107
if(have_bg)
76108
{
77-
memcpy(vram_start, bg_start, 0x88000);
109+
memcpy(vram_start, bg_start, 512 * 272 * PIXEL_BYTES);
78110
return true;
79111
}
80112
return false;
81113
}
114+
115+
extern void bg_cancel()
116+
{
117+
have_bg = false;
118+
}
119+
120+
static byte * _cache = NULL;
121+
122+
extern void bg_cache()
123+
{
124+
if(!have_bg)
125+
return;
126+
if(_cache != NULL)
127+
free((void *)_cache);
128+
_cache = malloc(512 * 272 * PIXEL_BYTES);
129+
if(_cache == NULL)
130+
return;
131+
memcpy(_cache, bg_start, 512 * 272 * PIXEL_BYTES);
132+
}
133+
134+
extern void bg_restore()
135+
{
136+
if(!have_bg)
137+
return;
138+
if(_cache == NULL)
139+
return;
140+
memcpy(bg_start, _cache, 512 * 272 * PIXEL_BYTES);
141+
free((void *)_cache);
142+
_cache = NULL;
143+
}
144+
145+
#endif

bg.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
#define _BG_H_
33

44
#include "common/datatype.h"
5+
#include "fs.h"
56

6-
extern void bg_load(const char * filename);
7+
extern void bg_load(const char * filename, pixel bgcolor, t_fs_filetype ft, dword grayscale);
78
extern bool bg_display();
9+
extern void bg_cancel();
10+
extern void bg_cache();
11+
extern void bg_restore();
812

913
#endif

0 commit comments

Comments
 (0)