Page 2 of 2

Re: Dumping Fire Emblem Gaiden with kazzo

Posted: Thu Dec 29, 2016 11:32 pm
by calohtar
Ah, good catch. I tried to change that though, and the error still appeared. Is that 0x02000 a maximum for all values, or just the ppu_romsize? In other words, are there any other values that are above that maximum that I should correct?

For reference, here's all the code as it exists at this moment:

Code: Select all

/*
HVC-2I Fire Emblem Gaiden
command line option
./anago d22 mmc4_fkrom.ae hvc_2i.nes b
*/
board <- {
	 mappernum = 10, vram_mirrorfind = false, ppu_ramfind = false, cpu_romsize=0x40000, ppu_romsize=0x02000, cpu_banksize=0x2000, ppu_banksize=0x1000
	cpu_rom = {
		size_base = 1 * mega, size_max = 2 * mega,
		banksize = 0x4000,
	}, 
	cpu_ram = {
		size_base = 0x2000, size_max = 0x2000,
		banksize = 0x2000,
	},
	ppu_rom = {
		size_base = 0x10000, size_max = 1 * mega,
		banksize = 0x1000
	}
};

/*
[cpu memmorymap - read]
$6000-$7fff SRAM (battery backuped, optional)
$8000-$bfff program ROM bank #0
$c000-$ffff program ROM bank #1 (fixed)

[cpu memmorymap - write]
$a000-$afff program ROM bank register #0
$b000-$bfff charcter ROM bank register #0
$c000-$cfff charcter ROM bank register #1
$d000-$dfff charcter ROM bank register #2
$d000-$dfff charcter ROM bank register #3

[ppu memorymap - read]
0x0000-0x0fff charcter ROM bank #A (#0 or #1)
0x0fd0-0x0fdf charcter ROM bank register switch to #0
0x0fe0-0x0fef charcter ROM bank register switch to #1
0x1000-0x1fff charcter ROM bank #B (#2 or #3)
0x1fd0-0x1fdf charcter ROM bank register switch to #2
0x1fe0-0x1fef charcter ROM bank register switch to #3
*/
function cpu_dump(d, pagesize, banksize)
{
	for(local i = 0; i < pagesize; i += 1){
		cpu_write(d, 0xa000, i);
		cpu_read(d, 0x8000, banksize);
	}
	cpu_read(d, 0xc000, banksize);
}

/*
PPU の read 途中にバンクレジスタが切り替わるらしいので下記の処理で
同じデータを得るようにする。
PPU address      register
0x0000-0x0fdf -> #0
0x0fe0-0x0fff -> #1
0x1000-0x1fdf -> #2
0x1fe0-0x1fff -> #3

ppu_read 前に #0 + #1 , #2 + #3 の内容は同じにしておく。
*/
function ppu_dump(d, pagesize, banksize)
{
	for(local i = 0; i < pagesize; i += 2){
		ppu_read(d, 0x0fd0, 0);
		cpu_write(d, 0xb000, i);
		ppu_read(d, 0x0fe0, 0);
		cpu_write(d, 0xc000, i);

		ppu_read(d, 0x1fd0, 0);
		cpu_write(d, 0xd000, i + 1);
		ppu_read(d, 0x1fe0, 0);
		cpu_write(d, 0xe000, i + 1);

		ppu_read(d, 0, banksize * 2);
	}
}

function cpu_ram_access(d, pagesize, banksize)
{
	cpu_ramrw(d, 0x6000, banksize);
}
And here's the error it's yielding:

Code: Select all

C:\Users\jeffr\Documents\kazzo\kazzo\kazzo original\unagi_client_windows_060_commandline\anago>anago.exe d mmc4_fkrom.ae fe2.nes
length range must be 0x000001 to 0x002000
AN ERROR HAS OCCURED [script logical error]

CALLSTACK
*FUNCTION [ppu_dump()] mmc4_fkrom.ae line [66]
*FUNCTION [dump()] dumpcore.nut line [17]

LOCALS
[i] 0
[banksize] 4096
[pagesize] 2
[d] USERPOINTER
[this] TABLE
[vram] 0
[increase_ppu] 1
[increase_cpu] 1
[mappernum] 10
[d] USERPOINTER
[this] TABLE

Re: Dumping Fire Emblem Gaiden with kazzo

Posted: Thu Dec 29, 2016 11:37 pm
by lidnariq
... Wait, I was entirely wrong. Sorry!

What I should have pointed out was this disagreement in interface instead:
ppu_read(d, 0x0fd0, 0);
That 0 (and the three others) should be the numbers that're not between 1 and 0x2000

Re: Dumping Fire Emblem Gaiden with kazzo

Posted: Fri Dec 30, 2016 4:11 am
by Zepper
lidnariq wrote:... Wait, I was entirely wrong. Sorry!

What I should have pointed out was this disagreement in interface instead:
ppu_read(d, 0x0fd0, 0);
That 0 (and the three others) should be the numbers that're not between 1 and 0x2000
Indeed. Those reads are only to set the latch $FD or $FE for dumping CHR ROM.
So, use 1 and try again. I don't think that any number larger than 1 will make a difference.

...I sense this script will fail again. :? :? :roll: :roll:

Re: Dumping Fire Emblem Gaiden with kazzo

Posted: Fri Dec 30, 2016 10:31 am
by tepples
I suspect it may not have a command to read from the PPU without writing it to the file.

Re: Dumping Fire Emblem Gaiden with kazzo

Posted: Fri Dec 30, 2016 11:28 am
by calohtar
@Tepples Can you elaborate on that? What would I need to change for the script?

It did fail again, but I think we're making progress! Here's the latest error:

Code: Select all

C:\Users\jeffr\Documents\kazzo\kazzo\kazzo original\unagi_client_windows_060_commandline\anago>anago.exe d mmc4_fkrom.ae fe2.nes
cpu_romsize is not connected 0x042000/0x040000
ppu_romsize is not connected 0x020040/0x020000

AN ERROR HAS OCCURED [script logical error]

CALLSTACK
*FUNCTION [dump()] dumpcore.nut line [19]

LOCALS
[vram] 0
[increase_ppu] 1
[increase_cpu] 1
[mappernum] 10
[d] USERPOINTER
[this] TABLE
I'm not entirely sure where it's getting those 42000 or 20040 numbers, but it seems to not like them...

Re: Dumping Fire Emblem Gaiden with kazzo

Posted: Fri Dec 30, 2016 12:17 pm
by Zepper
Put back the pagesize-1 in the cpu dump loop.

For the PPU, try moving back to the old code:

Code: Select all

function ppu_dump(d, pagesize, banksize)
{
	for(local i = 0; i < pagesize; i+=2){
		//just set both banks so we don't have to worry about auto-switching
		cpu_write(d, 0xB000, i);	//4KB bank @ $0000	
		cpu_write(d, 0xC000, i);	//4KB bank @ $0000
		cpu_write(d, 0xD000, i | 1);	//4KB bank @ $1000
		cpu_write(d, 0xE000, i | 1);	//4KB bank @ $1000
		ppu_read(d, 0x0000, banksize * 2);	//Read 8KB (entire CHR space $0000-1FFF
	}
}

Re: Dumping Fire Emblem Gaiden with kazzo

Posted: Fri Dec 30, 2016 1:14 pm
by calohtar
Woohoo!! No more errors!

Unfortunately though, it's still not yielding a workable file... opening in NEStopia is still giving a "CPU Jam" error and the checksum is wrong.

Code: Select all

C:\Users\jeffr\Documents\kazzo\kazzo\kazzo original\unagi_client_windows_060_commandline\anago>anago.exe d22 mmc4_fkrom.ae fe2.nes
program memory  0x080000/0x080000 |##########|##########|
charcter memory 0x040000/0x040000 |##########|##########|
mirroring program rom fixed
mirroring charcter rom fixed
mapper 10
program ROM: size 0x020000, crc32 0xc6916a25
charcter ROM: size 0x020000, crc32 0x963fd7c5
Why is it only giving a program rom size of 0x020000? Shouldn't that be double the character rom size?

Re: Dumping Fire Emblem Gaiden with kazzo

Posted: Fri Dec 30, 2016 1:33 pm
by Zepper
Tried to use x4 multiplier?
Tried to clean up the connectors?

Re: Dumping Fire Emblem Gaiden with kazzo

Posted: Sat Dec 31, 2016 2:17 pm
by calohtar
No luck either way :/ I'm starting to be concerned that maybe the cartridge is just corrupted itself... sigh, Any other ideas, or am I out of luck at this point?

Re: Dumping Fire Emblem Gaiden with kazzo

Posted: Sat Dec 31, 2016 3:48 pm
by Zepper
Try banksize*2 (see below). Tell me the PRG dumped size later.

Code: Select all

function cpu_dump(d, pagesize, banksize)
{
   for(local i = 0; i < pagesize; i += 1){
      cpu_write(d, 0xa000, i);
      cpu_read(d, 0x8000, banksize*2);
   }
   cpu_read(d, 0xc000, banksize*2);
}

Re: Dumping Fire Emblem Gaiden with kazzo

Posted: Thu Mar 16, 2017 8:12 pm
by werewolfslayr925
I've also been having trouble with this. I've tried the code in the previous post, but it only yielded an error:

Code: Select all

AN ERROR HAS OCCURRED [script logical error]

CALLSTACK
*FUNCTION [dump()] dumpcore.nut line [19]

LOCALS
[vram] 0
[increase_ppu] 2
[increase_cpu] 2
[mappernum] 10
[d] USERPOINTER
[this] TABLE
I've managed to get it to dump using the code below:

Code: Select all

/*
HVC-2I Fire Emblem Gaiden
command line option
./anago d22 mmc4_fkrom.ae hvc_2i.nes b
*/
board <- {
    mappernum = 10, vram_mirrorfind = false, ppu_ramfind = false, cpu_romsize=0x40000, ppu_romsize=0x02000, cpu_banksize=0x2000, ppu_banksize=0x1000
   cpu_rom = {
      size_base = 1 * mega, size_max = 2 * mega,
      banksize = 0x4000,
   }, 
   cpu_ram = {
      size_base = 0x2000, size_max = 0x2000,
      banksize = 0x2000,
   },
   ppu_rom = {
      size_base = 0x10000, size_max = 1 * mega,
      banksize = 0x1000
   }
};

/*
[cpu memmorymap - read]
$6000-$7fff SRAM (battery backuped, optional)
$8000-$bfff program ROM bank #0
$c000-$ffff program ROM bank #1 (fixed)

[cpu memmorymap - write]
$a000-$afff program ROM bank register #0
$b000-$bfff charcter ROM bank register #0
$c000-$cfff charcter ROM bank register #1
$d000-$dfff charcter ROM bank register #2
$d000-$dfff charcter ROM bank register #3

[ppu memorymap - read]
0x0000-0x0fff charcter ROM bank #A (#0 or #1)
0x0fd0-0x0fdf charcter ROM bank register switch to #0
0x0fe0-0x0fef charcter ROM bank register switch to #1
0x1000-0x1fff charcter ROM bank #B (#2 or #3)
0x1fd0-0x1fdf charcter ROM bank register switch to #2
0x1fe0-0x1fef charcter ROM bank register switch to #3
*/
function cpu_dump(d, pagesize, banksize)
{
   for(local i = 0; i < pagesize-1; i += 1){
      cpu_write(d, 0xa000, i);
      cpu_read(d, 0x8000, banksize);
   }
   cpu_read(d, 0xc000, banksize);
}

/*
PPU ? read ???????????????????????????
??????????????
PPU address      register
0x0000-0x0fdf -> #0
0x0fe0-0x0fff -> #1
0x1000-0x1fdf -> #2
0x1fe0-0x1fff -> #3

ppu_read ?? #0 + #1 , #2 + #3 ????????????
*/
function ppu_dump(d, pagesize, banksize)
{
   for(local i = 0; i < pagesize-1; i+=2){
      //just set both banks so we don't have to worry about auto-switching
      cpu_write(d, 0xB000, i);   //4KB bank @ $0000   
      cpu_write(d, 0xC000, i);   //4KB bank @ $0000
      cpu_write(d, 0xD000, i | 1);   //4KB bank @ $1000
      cpu_write(d, 0xE000, i | 1);   //4KB bank @ $1000
      ppu_read(d, 0x0000, banksize * 2);   //Read 8KB (entire CHR space $0000-1FFF
   }
}

function cpu_ram_access(d, pagesize, banksize)
{
   cpu_ramrw(d, 0x6000, banksize);
}
Edit: Using the above code, I managed to dump Fire Emblem: Ankoku Ryu to Hikari no Tsurugi. Considering the two games use identical hardware, the code should work for Gaiden. I haven't been able to dump my copy yet, but here's to hoping it just needs the right amount of cleaning/the right angle/etc.