-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmapper.c
104 lines (79 loc) · 1.94 KB
/
mapper.c
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
* mapper.c
*
* Created on: June 27, 2009
* Author: blanham
*/
#include <stdio.h>
#include "main.h"
#include "B6502.h"
int data, reset = 0;
WORD mmc1;
int count=0;
int LoadMapper(int mapper){
switch(mapper){
case 1:
memcpy(&RAM[0x8000],PRG,0x4000);
memcpy(&RAM[0xc000],&PRG[0x4000],0x4000);
if(CHR_size) memcpy(VRAM, CHR, 0x2000);
count=1;
break;
case 66:
memcpy(&RAM[0x8000],&PRG[0x8000],0x4000);
memcpy(&RAM[0xc000],&PRG[0xc000],0x4000);
memcpy(VRAM, CHR, 0x2000);
break;
default:
printf("Unimplemented mapper!\n");
exit(1);
break;
}
return 0;
}
int chrm,prgm = 0;
void WriteMapper(WORD addr, BYTE value){
// printf("\nMapper Write!\n");
//printf("asfasdf");
switch(mapper){
case 1:
printf("Count:%i\n",count);
if(count>5) count=1;
if(value & 0x1){
mmc1 = 0;
}else if(value & 0x1){
}
if(count==5){
if(addr >=0x8000 && addr<=0x9FFF){
}
}
count++;
break;
case 66:
value &= 0x33;
if(value&0x30){
memcpy(&RAM[0x8000],&PRG[(value>>4)*0x8000],0x8000);
// printf("PC: %4x\n",PC);
}else{
memcpy(&RAM[0x8000],&PRG[0x8000],0x8000);
// printf("PCf: %4x\n",PC);
}
// memcpy(&VRAM[0], &CHR[((value))*0x2000], 0x2000);
if(value&0x3){
value = value&0x3;
pVRAM[0]=&CHR[0x2000*value];
pVRAM[1]= &CHR[0x800+value*0x2000];
pVRAM[2]=&CHR[0x800*2+value*0x2000];
pVRAM[3]= &CHR[0x800*3+value*0x2000];
}else{
pVRAM[0]=&CHR[0];
pVRAM[1]= &CHR[0x800];
pVRAM[2]=&CHR[0x800*2];
pVRAM[3]= &CHR[0x800*3];
}
break;
default:
printf("Unimplemented mapper!\n");
exit(1);
break;
}
}