Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /storage/content/49/145849/famitracker.com/public_html/forum/classes/dbHandler.php on line 29 FamiTracker
Login:
Menu:
Post: Author:
FamiTracker > General > Source and development > Compiling NSF drivers for Famitracker Owner: rainwarrior New post
Page 1 of 1 Sort:  
Compiling NSF drivers for Famitracker Posted: 2012-10-27 20:35 Reply | Quote
rainwarrior

Avatar

Member for: 4150 days
Location: Canada
Status: Offline

#41228
Should the nsf driver source include a guide to compiling the drivers? Modifying the NSF driver to build into Famitracker takes a bit of figuring out. This is what I've done:

1. The driver is loaded at $8000, attached is an appropriate .cfg file for ld65.

2. Assemble driver.s with -D USE_XXX. (One for 2A03 solo, and each expansion.)

3. Link with ld65.

4. Convert binary output to header file (drv_xxx.h) for use in famitracker/Source/drivers

5. With the latest version there is a config.h in /drivers with pointers to data structures in the driver. These pointers can be found by using -g when assembling, and -Ln labels.txt when linking to generate a list of labels and their addresses.


Attachments:
driver_8000.cfg (0 Kb)
Posted: 2012-10-30 11:35 Reply | Quote
jsr
Administrator

Avatar

Member for: 5925 days
Location: Sweden
Status: Offline

#41346
Yeah that guide should work, except that the driver can be relocated but it's easily modifiable to a fixed address. I'm using a bunch of scripts to build the header files, I should probably document the process somewhere.

_______________________
Programmer and developer
Posted: 2012-10-30 18:05 Reply | Quote
rainwarrior

Avatar

Member for: 4150 days
Location: Canada
Status: Offline

#41360
Ah, how many places can it be relocated to? Do you have separate assembled binaries for the different locations?

I thought older versions of Famitracker had two places to put the 2A03-only driver, but now I only see drv_2a03.h?

Posted: 2012-10-30 22:17 Reply | Quote
jsr
Administrator

Avatar

Member for: 5925 days
Location: Sweden
Status: Offline

#41368
Actually only two places are used: one to minimize the size when DPCM samples is used and bankswitching disabled and one when bankswitching is enabled. The reason to keep two variants available is to make the exported NSF easy to embed in NES programs, and initially also because I had a 32kB dev-cart (back before the Powerpak was available) which only supported non-bankswitched files, so I wanted to avoid bankswitching unless it was actually needed.

Previous versions had two different copies of the same driver located at different addresses, but I rewrote large parts of the exporting code in 0.4.0 and then also added dynamic relocation. The main reason for the rewrite was to add symbolic assembler output for easier debugging.

_______________________
Programmer and developer
Posted: 2012-10-31 02:14  (Last Edited: 2012-10-31 02:21) Reply | Quote
rainwarrior

Avatar

Member for: 4150 days
Location: Canada
Status: Offline

#41394
Ah, I see now! That's considerably more complicated than before...

What do you use to generate the list of addresses to adjust? Did you write a custom tool to do the link step instead of ld65 and save them off?

Posted: 2012-11-01 00:22 Reply | Quote
jsr
Administrator

Avatar

Member for: 5925 days
Location: Sweden
Status: Offline

#41484
It's a little more complicated, but it saves some trouble with manually setting up the addresses and won't have to store drivers multiple times. I'm using the cc65 object file converter and then parses the text output. I tried to figure out the object file format first, but this was easier. :)

The config.h addresses is generated from the listing file.

_______________________
Programmer and developer
Posted: 2012-11-01 03:43 Reply | Quote
rainwarrior

Avatar

Member for: 4150 days
Location: Canada
Status: Offline

#41496
Hmm, how do you use the object file converter? (co65?) It seems to complain if I try it on a .o file...

Posted: 2012-11-01 17:45 Reply | Quote
jsr
Administrator

Avatar

Member for: 5925 days
Location: Sweden
Status: Offline

#41535
Yeah it's co65 and it's using a format called o65 which has to be built with the linker, so the process is ca65 -> ld65 -> co65. The output format from the linker is set to o65 in the linker config file.

_______________________
Programmer and developer
Posted: 2012-11-01 18:31 Reply | Quote
rainwarrior

Avatar

Member for: 4150 days
Location: Canada
Status: Offline

#41538
Ah, I didn't know you could intentionally link to o65. Weird.

Page 1 of 1 Sort: