How to write a NES mappers script?

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Post Reply
Falcon
Posts: 6
Joined: Sun Nov 24, 2019 10:47 am

How to write a NES mappers script?

Post by Falcon » Sun Nov 24, 2019 10:54 am

How to write a NES mapper script? For Dumper Tengu (Peter Byemu)
Please, give me an advice.
Thank you

Falcon
Posts: 6
Joined: Sun Nov 24, 2019 10:47 am

Re: How to write a NES mappers script?

Post by Falcon » Tue Nov 26, 2019 1:12 pm

it's probably too complicated
I would like to share multicart to all people
I don't know anyone who can.

lidnariq
Posts: 8767
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: How to write a NES mappers script?

Post by lidnariq » Tue Nov 26, 2019 1:30 pm

I only know of three existing dumpers:

* Naruko's Kazzo
* INL's retrodumper
* Kevtris's CopyNES and Bunnyboy's USB version of same.

I have no idea what byemu wrote? I'd need more documentation to be able to help.

NewRisingSun
Posts: 1044
Joined: Thu May 19, 2005 11:30 am

Re: How to write a NES mappers script?

Post by NewRisingSun » Tue Nov 26, 2019 1:33 pm

You first have to gain an abstract understanding how the mapper works. There are two ways of doing so: study the traces on the circuit board, make a connection diagram and deduce how the mapper works. Additionally or alternatively, dump the cartridge as NROM and use a debugger to study what values are written to which addresses, and deduce how the mapper works by looking for patterns in those values and addresses. The latter approach is usually the only possible one when you do not physically possess the cartridge and are merely helping some far-away collector dump his carts, as most collectors will refuse to open 60-pin cartridges because it is easy to break them in the process.

Either way, once you have gained an understanding of how the mapper works, you need to mentally transfer that abstract knowledge into a dumping script. You have to know how to change PRG-ROM and CHR-ROM banks, then write some sort of loop that for each bank first writes to a bank register, then reads the CPU or PPU address range that is affected by that bank register, and writes this data to disk. Every dumping device has its own script language, so you need to familiarize with it first; the best way to do that is to look at the sample scripts that come with most dumping device's software. The CopyNES device does not use dumping scripts; instead, you would have to write 6502 machine code.

I have never even heard of "Dumper Tengu", so I do not know what its dumping script language will be like.

skaman
Posts: 85
Joined: Fri Oct 24, 2014 1:56 am

Re: How to write a NES mappers script?

Post by skaman » Tue Nov 26, 2019 4:58 pm

lidnariq wrote:
Tue Nov 26, 2019 1:30 pm
I only know of three existing dumpers:

* Naruko's Kazzo
* INL's retrodumper
* Kevtris's CopyNES and Bunnyboy's USB version of same.
sanni's Cart Reader will dump FC/NES carts with an adapter. The code has support for all licensed mappers and a couple unlicensed mappers (30 & 71).

Falcon
Posts: 6
Joined: Sun Nov 24, 2019 10:47 am

Re: How to write a NES mappers script?

Post by Falcon » Wed Nov 27, 2019 10:43 am

Lindariq
http://famulator.blogspot.com
Beter Byemu FC Dump Pro Tengu Development

Falcon
Posts: 6
Joined: Sun Nov 24, 2019 10:47 am

Re: How to write a NES mappers script?

Post by Falcon » Wed Nov 27, 2019 10:49 am

NewRisingSun

I only have a Mapper 45 script

I can write Nrom 32K PRG and 8K CHR
but I don't know how to use debugger
I will probably have new mappers
Mapper 45
looks like this
--psize = 1024;
--csize = 1024;

psize = 512;
csize = 512;

--set dir path
path = fd_GetPath();
f_ines = string.format("%s\\%s",path,"m45.nes");


--set ines head
map=45;
scr4=0;
batt=0;
vmir = 0;--fd_CheckMirror();--vertical
vsys = 0;--not vs
prom = psize;
vrom = csize;
head = fd_GetNesHead(map,scr4,batt,vmir,vsys,prom,vrom)

--write head
fd_WriteFile(f_ines,head,2);


function MMC3_GEN_PRG(size)
local cmd = 6;
local banks = fd_ROR(size,3);
local v = 0;
while v<banks
do
fd_CpuWriteInt(0x8000,cmd);
fd_CpuWriteInt(0x8001,v);
fd_CpuWriteInt(0x8000,cmd+1);
fd_CpuWriteInt(0x8001,v+1);
crc,data = fd_CpuReadAscii(0x8000,0x4000);
i = fd_WriteFile(f_ines,data,1);
print(string.format("Write PRG 8K:%.8X",crc));
v=v+2;
end;
end;

function MMC3_GEN_CHR(size)
local banks = size;
local v = 0;
while v<banks
do
fd_CpuWriteInt(0x8000,0);
fd_CpuWriteInt(0x8001,v);
fd_CpuWriteInt(0x8000,1);
fd_CpuWriteInt(0x8001,v+2);
fd_CpuWriteInt(0x8000,2);
fd_CpuWriteInt(0x8001,v+4);
fd_CpuWriteInt(0x8000,3);
fd_CpuWriteInt(0x8001,v+5);
fd_CpuWriteInt(0x8000,4);
fd_CpuWriteInt(0x8001,v+6);
fd_CpuWriteInt(0x8000,5);
fd_CpuWriteInt(0x8001,v+7);
crc,data = fd_PpuReadAscii(0x0000,0x2000);
i = fd_WriteFile(f_ines,data,1);
print(string.format("Write CHR 1K:%.8X",crc));
v=v+8;
end;
end;

function dump_45(psize,csize)
fd_CpuWriteInt(0xA001,0x80);

local i = 0;
prg_all = fd_ROR(psize,8);
print(prg_all);
while i < prg_all
do
local val = fd_ROL(fd_AND(i,7),5);
fd_CpuWriteInt(0x6000, 0x00);
fd_CpuWriteInt(0x6000, val);
val = fd_ROL(fd_AND(i,15),4);
val = fd_OR(val,0xf);
fd_CpuWriteInt(0x6000, val);
fd_CpuWriteInt(0x6000, 0xa0);

MMC3_GEN_PRG(256);
i=i+1;
end;
--}
--Printf("\n");
i = 0;
chr_all = fd_ROR(csize,8);
while i<chr_all
do
local val = fd_ROL(fd_AND(i,7),5);
fd_CpuWriteInt(0x6000, 0x00);
fd_CpuWriteInt(0x6000, val);
val = fd_ROL(fd_AND(i,15),4);
val = fd_OR(val,0xf);
fd_CpuWriteInt(0x6000, val);
fd_CpuWriteInt(0x6000, 0xa0);
MMC3_GEN_CHR(256);
i=i+1;
--}
end;
--Printf("\n");
return 0;
end;


dump_45(psize,csize);

Falcon
Posts: 6
Joined: Sun Nov 24, 2019 10:47 am

Re: How to write a NES mappers script?

Post by Falcon » Thu Nov 28, 2019 10:28 am

Or I would send PCB and NRom games that I would like to share with you if you help me copy them. I have a chance to buy a lot of games, but I don't know if any of you will have time to help me copy them. :?
Thank you for your answers.

Falcon
Posts: 6
Joined: Sun Nov 24, 2019 10:47 am

Re: How to write a NES mappers script?

Post by Falcon » Wed Dec 04, 2019 10:17 am

you get reward if you help

Post Reply