-
Notifications
You must be signed in to change notification settings - Fork 100
/
sfc_mapper_003_cnrom.c
44 lines (38 loc) · 1.25 KB
/
sfc_mapper_003_cnrom.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
#include "sfc_cpu.h"
#include "sfc_famicom.h"
#include "sfc_mapper_helper.h"
#include <assert.h>
#include <string.h>
#ifndef NDEBUG
#include <stdio.h>
#endif
// ------------------------------- MAPPER 003 - CNROM
/// <summary>
/// StepFC: MAPPER 000 - NROM 重置
/// </summary>
/// <param name="famicom">The famicom.</param>
/// <returns></returns>
extern sfc_ecode sfc_mapper_00_reset(sfc_famicom_t* famicom);
/// <summary>
/// SFCs the mapper 03 write high.
/// </summary>
/// <param name="famicom">The famicom.</param>
/// <param name="address">The address.</param>
/// <param name="value">The value.</param>
static void sfc_mapper_03_write_high(sfc_famicom_t* famicom, uint16_t address, uint8_t value) {
const int bank = (value % famicom->rom_info.count_chrrom_8kb) * 8;
for (int i = 0; i != 8; ++i)
sfc_load_chrrom_1k(famicom, i, bank +i );
}
/// <summary>
/// SFCs the load mapper 01.
/// </summary>
/// <param name="famicom">The famicom.</param>
/// <returns></returns>
extern inline sfc_ecode sfc_load_mapper_03(sfc_famicom_t* famicom) {
// 初始化回调接口
// 重置可以直接使用Mapper000的
famicom->mapper.reset = sfc_mapper_00_reset;
famicom->mapper.write_high = sfc_mapper_03_write_high;
return SFC_ERROR_OK;
}