Archive for the ‘Software dev’ Category

Breakpoints …

Thursday, July 16th, 2009

Been a while that I haven’t posted on this blog.

I started the implementation of the breakpoints and step by step debugging. Breakpoints are done and the loop waiting for command is active. Currently I support 4 commands : dump registers, dump palette, dump vram and resume. So as you have guessed no “step by step” suppport yet.

During this first implementation I have corrected a few bugs in the “on the fly” rom patching, re-factored a few things that were badly coded or that where using inner BSnes feature (and thus not reproducible with the final hardware that we will have). Also, Icekiller helped me to design a command line client to interact with BSnes when debugging.

I’m currently making slower progress … many reasons for that. Time to time I have a loss of interest on my ‘hobby’ time, The train I used to take is on vacation currently, so I need to cumute…

I keep you updated when new nice features will be implemeted.

See ya, Lint

Commercial ROM ‘on the fly’ patching

Wednesday, June 24th, 2009

This morning on my train trip to work, I finally got the ‘on the fly’ patching of a commercial ROM. The Rom I’m using is the original Street Fighter II game. What I do is defining a breakpoint at 0×00812f and output a register dump with BSnes. Here are the 2 log files.

Internal BSnes log file :

devkit::power() : On
Patcher::power() On
Patcher::isBreakpoint() On
Patcher::isBreakpoint() PC Backup : 00812F
Patcher::isLifePatchingDone() addr : 81BE baseAddr : 812F size : 008E
Patcher::isLifePatchingDone() New addr : 812F
Patcher::isBreakpoint() Reset lifePatchingDisableOnce
Patcher::isBreakpoint() On
Patcher::isBreakpoint() PC Backup : 00812F
Patcher::isLifePatchingDone() addr : 81BE baseAddr : 812F size : 008E
Patcher::isLifePatchingDone() New addr : 812F
Patcher::isBreakpoint() Reset lifePatchingDisableOnce
Patcher::isBreakpoint() On
Patcher::isBreakpoint() PC Backup : 00812F
Patcher::isLifePatchingDone() addr : 81BE baseAddr : 812F size : 008E
Patcher::isLifePatchingDone() New addr : 812F
Patcher::isBreakpoint() Reset lifePatchingDisableOnce
Patcher::isBreakpoint() On
Patcher::isBreakpoint() PC Backup : 00812F
Patcher::isLifePatchingDone() addr : 81BE baseAddr : 812F size : 008E
Patcher::isLifePatchingDone() New addr : 812F
Patcher::isBreakpoint() Reset lifePatchingDisableOnc

External log outputting register Dump :

Debug Command : 0x01

*************************
*** Register Dump. ******
*************************
A : 0x0000
X : 0x0001
Y : 0x000E
Direct Page      : 0x0000
Data Bank        : 0x31
Processor Status : 0x07
*************************

Debug Command : 0x01

*************************
*** Register Dump. ******
*************************
A : 0x20C2
X : 0x3101
Y : 0x20C2
Direct Page      : 0x0000
Data Bank        : 0x31
Processor Status : 0x07
*************************

Debug Command : 0x01

*************************
*** Register Dump. ******
*************************
A : 0x101F
X : 0xB101
Y : 0x101F
Direct Page      : 0x0000
Data Bank        : 0x31
Processor Status : 0x07
*************************

Debug Command : 0x01

*************************
*** Register Dump. ******
*************************
A : 0x0416
X : 0x3101
Y : 0x2016
Direct Page      : 0x0000
Data Bank        : 0x31
Processor Status : 0x07
*************************

I stopped Bsnes at the main screen of Street Fighter II. That means that address 0×00812f is executed 4 times.

Next step is … ‘Step by Step’ debugging. I would like to get an interactive console to set/remove breakpoint, dump register with a command and execute next instruction. The problem is that I don’t know how to implement that within Bsnes. If someone got any ideas, just post a comment with them. I really would avoid to made a GUI with that inside Bsnes. The ideal solution would be to have an external program that can send data to Bsnes with instruction encoded in a binary format.

See ya, lint

VRAM Dumping and ‘on the fly’ ROM patching

Tuesday, June 16th, 2009

I finished this morning the code to dump the whole VRAM. It’s been a few days that I was working on it. One of the issue that I got with it is that the NMI got triggered in the middle of the transfer and that it was fucking up the VRAM registers of the snes. So when I was comming back from the NMI the transfert wasn’t done properly anymore.

That’s why I implemented the ‘on the fly’ Rom patching functionnality. This allow me to redirec tthe NMI Handler to a place where the NMI does nothing while I’m transfering the VRAM. Here is a little log of what is happening when I patch the ROM.

debugDump launched.
NMI Handler ...
NMI Handler ...
ROM PATCH :: Set Offset 0 : 0xEA
ROM PATCH :: Set Offset 1 : 0xFF
ROM PATCH :: Set Offset 2 : 0x00
ROM PATCH :: Read ROM [0000FFEA] => 0xEA
ROM PATCH :: Write ROM [0000FFEA] => 0x04
ROM PATCH :: Set Offset 0 : 0xEB
ROM PATCH :: Set Offset 1 : 0xFF
ROM PATCH :: Set Offset 2 : 0x00
ROM PATCH :: Read ROM [0000FFEB] => 0x85
ROM PATCH :: Write ROM [0000FFEB] => 0x86
Patched NMI Handler ...
Patched NMI Handler ...
Patched NMI Handler ...
Patched NMI Handler ...
Patched NMI Handler ...

The code to make this happen in snes side is :

offset = (word) &emptyNMI;
oldNMI[0] = _1UP_ROMPatch((dword) 0x0000FFEA, (byte) offset);
oldNMI[1] = _1UP_ROMPatch((dword) 0x0000FFEB, (byte) (offset>>8));
byte _1UP_ROMPatch(dword offset, byte data) {
    byte oldValue;

    // Set address to patch
    *(byte*) REG(_1UP_ROM_PATCH_ADDR0) = (byte) offset;
    *(byte*) REG(_1UP_ROM_PATCH_ADDR1) = (byte) (offset>>8);
    *(byte*) REG(_1UP_ROM_PATCH_ADDR2) = (byte) (offset>>16);

    // Read actual value
    oldValue = *(byte*) REG(_1UP_ROM_PATCH_DATA);

    // Write new value
    *(byte*) REG(_1UP_ROM_PATCH_DATA) = (byte) data;

    return oldValue;
}

I still use a patched version of BSnes to emulate the future hardware that is dev by Scott.

Next stuff is OAM Dump (sprite tables) …

See ya, Lint

SDCardReader : file read and seek done.

Monday, June 8th, 2009

I just finished porting the functions to actually read a file and seek into it. Next step is to make a function that allow me to read the ROM information.

Scott seems to be ready to work again on the hardware part. I hope everything will be ok when going on the actual hardware.

See ya, Lint

SDCardReader POC is making progress

Wednesday, May 27th, 2009

I fixed minor bugs and optimized a bit the memory usage. I still have to implement the reading of actual file to parse the ROM header.

SDCardReader V02

SDCardReader V02

SDCardReader V02

SDCardReader V02

See ya, Lint

Root directory of the SD card image is read with a modified version of BSnes.

Wednesday, May 6th, 2009

Root dir listing from SD card image with modified BSnes

The new snes-sdk …

Monday, April 27th, 2009

Hi folks,

A few weeks ago Tomy from tototek.com gave me the link of a toolchain for the snes. Allow C and asm code. The whole stuff looks great but only seems to compile under Linux. It’s now been a few months that I have no access to a Linux workstation. So I wondered if any of you could compile this to run under windows ? Or if you have any advice…

Here is the link of the project : http://code.google.com/p/snes-sdk/, the source code is avaible trough a SVN repos.

See ya, lint

Start coding the Fat32 lib for the incomming new homebrew snes devkit.

Wednesday, April 22nd, 2009

Quite a long title that talk for itself …

It’s been now a few months that Scott is developing is snes devkit cart ( http://sneshack.blogspot.com/ ). He’s currently still playing with the hardware but since I’m willing to start coding the Bios for it I decided to modify bsnes to map a few memory registers that I might need for doing the SDCardReader code that will allow the snes to read the SD card and display the menu on the screen.

The registers are :  status(r) $3100 ,data(r) $3103 and 2 for the offset(w) $3101 and $3102.

My code is based on a existing lib and if I continue at this rhythm i might have a basic demo going on by end of next week.

I keep you updated.

++ lint

NSF Replayer : SPC code update

Tuesday, March 31st, 2009

This early morning I started to disassemble the original SPC.BIN that was in the demo released by memblers. It just happened that the faulty file was tasm07.tab. I just need to make 2 changes that I describe here :

BEFORE : ROR   *       6C 3 NOP 1
AFTER :  ROR   !*      6C 3 NOP 1

Seems to be a typo …

BEFORE : MOV     *,A     C4 2 NOP 1
         MOV     !*,A    C5 3 NOP 1

AFTER  : MOV     !*,A    C5 3 NOP 1
         MOV     *,A     C4 2 NOP 1

Look again like a typo, just need to swap to the lines…

So not really a big deal, but now I have a SPC source that compile correctly.

I did a bit of code cleanup yesterday and gave the new rom to Tomy and this time it seems to work. I will release a rom for everybody to test either this afternoon or tomorow morning.

++ Lint

NSF Replayer first results.

Monday, March 30th, 2009

On friday I finally got to make the NSF Replayer work. After various general code checking and made some minor corrections, the player wasn’t still working. From there the only thing that wasn’t checked was the SPC code itself (the only source that I got complete). I had then the idea to the SPC code directly from memblers code ( SNES NSF Player (32Mbit) ).

And … it worked totally fine. Then is various difference with the original SPC.BIN and the one I compiled. I will In a near future reverse the original SPC.BIN and rewrite the correct source code so it can be compiled by hand and can be used for any enhancement that might come one day.

My code is working right on most emu that handle the sound correctly. The Snes9x debug version is really awfull, but zsnes and bsnes are doing the job really fine.

Currently the code seems to not work on the SNES itself as reported Tomy from TOTOTEK. I have no real ideas on why the code isn’t working on the actual SNES for the moment. Tomy reported that he see nothing on the screen while running my proff of concept ROM. I need to assemble a new ROM to check on wich routine the SNES hang. I mainly have 3 functions : 2 init ones and 1 for playing the song that need to be called once per VBlank (not needed in VBlank).

I keep you all informed and will release full source as soon as it is working on the hardware.

See ya, Lint