common large load buffer.

This commit is contained in:
sorgelig
2020-04-11 19:47:33 +08:00
parent 27c72cab81
commit d27f4fcc82
4 changed files with 10 additions and 8 deletions

View File

@@ -41,6 +41,7 @@ static int iSelectedEntry = 0; // selected entry index
static int iFirstEntry = 0;
static char full_path[2100];
uint8_t loadbuf[LOADBUF_SZ];
fileTYPE::fileTYPE()
{

View File

@@ -113,6 +113,7 @@ const char *getFullPath(const char *name);
uint32_t getFileType(const char *name);
bool isMraName(char *path);
#define LOADBUF_SZ (1024*1024)
#define COEFF_DIR "filters"
#define GAMMA_DIR "gamma"

View File

@@ -191,10 +191,10 @@ static int rom_data(const uint8_t *buf, int chunk, int map, struct MD5Context *m
return 1;
}
extern uint8_t loadbuf[];
static int rom_file(const char *name, uint32_t crc32, int start, int len, int map, struct MD5Context *md5context)
{
fileTYPE f = {};
static uint8_t buf[4096];
if (!FileOpenZip(&f, name, crc32)) return 0;
if (start) FileSeek(&f, start, SEEK_SET);
unsigned long bytes2send = f.size - f.offset;
@@ -202,10 +202,10 @@ static int rom_file(const char *name, uint32_t crc32, int start, int len, int ma
while (bytes2send)
{
uint16_t chunk = (bytes2send > sizeof(buf)) ? sizeof(buf) : bytes2send;
uint32_t chunk = (bytes2send > LOADBUF_SZ) ? LOADBUF_SZ : bytes2send;
FileReadAdv(&f, buf, chunk);
if (!rom_data(buf, chunk, map, md5context))
FileReadAdv(&f, loadbuf, chunk);
if (!rom_data(loadbuf, chunk, map, md5context))
{
FileClose(&f);
return 0;

View File

@@ -223,7 +223,7 @@ static void make_path(const char *root, const char *name, char *path)
strcat(path, name);
}
static uint8_t loadbuf[1024 * 1024];
extern uint8_t loadbuf[];
static uint32_t load_crom_to_mem(const char* path, const char* name, uint8_t index, uint32_t offset, uint32_t size)
{
fileTYPE f = {};
@@ -260,7 +260,7 @@ static uint32_t load_crom_to_mem(const char* path, const char* name, uint8_t ind
while (remain)
{
uint32_t partsz = remain;
if (partsz > 1024 * 1024) partsz = 1024 * 1024;
if (partsz > LOADBUF_SZ) partsz = LOADBUF_SZ;
//printf("partsz=%d, map_addr=0x%X\n", partsz, map_addr);
void *base = mmap(0, partsz, PROT_READ | PROT_WRITE, MAP_SHARED, memfd, map_addr);
@@ -335,10 +335,10 @@ static uint32_t load_rom_to_mem(const char* path, const char* name, uint8_t neo_
while (remain)
{
uint32_t partsz = remain;
if (partsz > 1024 * 1024) partsz = 1024 * 1024;
if (partsz > LOADBUF_SZ) partsz = LOADBUF_SZ;
uint32_t partszf = remainf;
if (partszf > 1024 * 1024) partszf = 1024 * 1024;
if (partszf > LOADBUF_SZ) partszf = LOADBUF_SZ;
//printf("partsz=%d, map_addr=0x%X\n", partsz, map_addr);
void *base = mmap(0, partsz, PROT_READ | PROT_WRITE, MAP_SHARED, memfd, map_addr);