Hello all,
I've been learning about the internals of the KSS format lately, and afaik there's no guide on how to get the music extracted. I know now why that is difficult, but finding this out and putting things together took me a while. So I'm on a quest to get Comic Bakery in a KSS file! That probably exists already, but hey, I'm not downloading it. If I know everything, I will write a guide.
Currently I know about all the fields in the KSS header. I've been using z80dasm to disassemble some KSS & ROM files, and what I've learned that's it's doable to just include the whole game rom in the KSS. Magical Tree.kss uses this. However, there's also Pippols.kss, which seems to include half the game with a few less jumps and calls. And Circus Charley is a nice one if you look at it from a programmers view; only 1500 bytes that include everything.
Libkss will only emulate sound related stuff so the 'whole rom' approach is not very elegant but has a chance of working I guess. At least you don't need to know a lot about Z80 programming, which I don't.
I've learned that 0xa0 is a call used in players, as well 0x90, 0x93 etc registers. I've been told it's also common to look at the hooks fd9f and fd9a for players. But all available KSS files have a player address which start something I don't understand. So I've been trying but no clue as of yet.
I will continue to learn a bit about Z80 programming, maybe I can find players. But, first I need the load address, and that's my current issue, how would I know the load address, it differs a lot between all the KSS files. I've been using the debugger from openMSX running Pippols to do a memory dump, and I can find the Pippols code in there, but it's starting on a different address then the working KSS file has. And the Pippols.kss can work with the real game rom, I've tried that using the values in the header with the rom file. How is it possible the memory addresses differ, but the calls in the code go to the same address?
z80dasm kss command (using load address + 1): z80dasm -a -g0x3FF1 pippols.kss.
Some code of the kss dump:
ld a,005h ;4952
call 04039h ;4954
inc de ;4957
djnz $-27 ;4958
ld a,(0e012h) ;495a
The same code from the memory dump:
ld a,005h ;4a41
call 04039h ;4a43
inc de ;4a46
djnz $-27 ;4a47
ld a,(0e012h) ;4a49