-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrom.cpp
54 lines (45 loc) · 1.25 KB
/
rom.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "comm.h"
extern WqxRom nc1020_rom;
uint8_t rom_buff[ROM_SIZE];
uint8_t* rom_volume0[0x100];
uint8_t* rom_volume1[0x100];
uint8_t* rom_volume2[0x100];
void LoadRom(const string romPath){
int rom_size=-1;
if(nc1020mode){
rom_size=ROM_SIZE;
}
if(pc1000mode) {
rom_size=0x8000*128*3;
}
uint8_t* temp_buff = (uint8_t*)malloc(rom_size);
FILE* file = fopen(romPath.c_str(), "rb");
if(file==0) {
printf("file %s not exist!\n",romPath.c_str());
exit(-1);
}
fread(temp_buff, 1, rom_size, file);
ProcessBinaryLinear(rom_buff, temp_buff, rom_size);
free(temp_buff);
fclose(file);
}
void init_rom(){
memset(&rom_buff,0xff,sizeof(rom_buff));
LoadRom(nc1020_rom.romPath);
if(nc1020mode){
for (uint32_t i=0; i<num_rom_pages/3; i++) {
rom_volume0[i] = rom_buff + (0x8000 * i);
rom_volume1[i] = rom_buff + (0x8000 * (0x100 + i));
rom_volume2[i] = rom_buff + (0x8000 * (0x200 + i));
}
}
if(pc1000mode){
for (int i = 0; i < 128; i++) {
// 0~128
rom_volume0[i] = (unsigned char*)rom_buff + i * 0x8000;
rom_volume1[i] = rom_volume0[i];
rom_volume0[i + 128] = (unsigned char*)rom_buff + (i + 128) * 0x8000;
rom_volume1[i + 128] = rom_volume0[i + 128] + 128 * 0x8000;
}
}
}