168 lines
14 KiB
Plaintext
168 lines
14 KiB
Plaintext
|
|
Episode: 1476
|
||
|
|
Title: HPR1476: Sega Genesis Music Driver
|
||
|
|
Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr1476/hpr1476.mp3
|
||
|
|
Transcribed: 2025-10-18 03:48:11
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
A
|
||
|
|
Alright, that was a nice video.
|
||
|
|
Hello everybody, my name is Sikflup. Sikflup to this level that is, and you are listening
|
||
|
|
to Actra Public Radio. In this exciting edition of Actra Public Radio, we are going to be
|
||
|
|
talking about the Psychogenesis. Specifically, we're going to be interviewing Kibalus
|
||
|
|
about Kibalus 1 that is about his VGM driver. So what is a VGM driver you might be asking
|
||
|
|
about? Well, a bit of background is necessary. A bit of background about the Psychogenesis.
|
||
|
|
I was also known as the Mega Drive in European places. It was necessary. Well, the Psychogenesis
|
||
|
|
is a console that we all know and love. And inside of it, there's a bunch of chips. The
|
||
|
|
68,000 being the processor, the main processor in it. There's also another processor in it
|
||
|
|
called the Z80, and the Z80 has mapped onto its address space a FM chip, the YM2612, and
|
||
|
|
PSG, programmable sound generator, and those two sound chips generate music. And they have
|
||
|
|
the two sound chips kind of attached to the Z80 in some sense. And the 68K running. And
|
||
|
|
so the 68K can acquire the Z80 bus and have it mapped onto its address space in a little
|
||
|
|
peculiar area and upload a driver as it's known. To the Z80 memory, the Z80 memory primarily
|
||
|
|
being RAM and then reset the Z80. And so you can send the Z80 a program and have it run.
|
||
|
|
And that program typically runs sound, it's like a sound program. And so this is like a sound
|
||
|
|
driver. And so there's a particular sound encapsulation format called VGM. For video game music,
|
||
|
|
video game music being this, this, this file called a VGM file. And this is a driver for it
|
||
|
|
for the Sega Genesis. So let's get, let's get into the interview and hope you enjoy.
|
||
|
|
All right, everyone, we're here with Kibbles, and welcome.
|
||
|
|
Hello. How are you doing? Good, how are you doing?
|
||
|
|
That's not too bad. So rumor has a you wrote a pretty wicked VGM driver for the Sega Genesis.
|
||
|
|
How did you get into Sega Genesis programming? Well, I don't know. I just wanted to,
|
||
|
|
one of the consoles I had as a kid, I always thought it was pretty cool. And in fact,
|
||
|
|
I always wanted to do some, some kind of like retro kind of console development. And just like,
|
||
|
|
hey, I'll learn to program Sega Genesis. I think I wanted to do the Sega CD. I haven't quite got
|
||
|
|
there yet. But on the way, one of the, you know, one of the things I wanted to be able to do is
|
||
|
|
play music on it, so. Could you describe what VGM is for the audience?
|
||
|
|
Yes, it is a, well, it's the spec that describes chiptunes. There's a lot of different
|
||
|
|
there's a lot of different chips that can that that this works with. It's not just the
|
||
|
|
Sega Genesis. There's quite a number of different ones that it can use. And so that, you know,
|
||
|
|
that's pretty much it. That's up, you know, the instruments that define the songs, samples
|
||
|
|
in the songs. And then, you know, this is the notes on and off and changing the
|
||
|
|
decay rate of stuff. For adding, you know, special effect, like some echo or other effects to the
|
||
|
|
songs. I see. And, why VGM? Well, it looked, well, really, I, you know, I, I, I was starting
|
||
|
|
programming the just about a year and a half ago or so. And when I, I didn't really, you know,
|
||
|
|
no, I just knew that I, that I wanted to be able to do sound as well as graphics. I kind of
|
||
|
|
learned the basics of like the background sprites and that seems to be pretty well defined. But
|
||
|
|
how I would get sound and music into, into things wasn't clear to me. And especially things that
|
||
|
|
I could like make, not that I make very good stuff. But, and I use like a strictly like Linux
|
||
|
|
environment when I, when I, when I work. And so I stumbled, you know, across some like trackers.
|
||
|
|
And what, you know, one of them was like Deflamask and one of the outputs that has this, you know,
|
||
|
|
VGM format. And so that seemed well, that seems like, you know, the most convenient workflow I could
|
||
|
|
have would be to use, you know, to like Deflamask write songs, exported into VGM. And then if I had
|
||
|
|
a way I could load it in and play it, that'd be great. And then I saw that you wrote, you know,
|
||
|
|
you wrote that little VGM driver. I mean, it was, it was in SDCC. And it was really to the point,
|
||
|
|
and I was like, once I saw that, I got it. I was like, okay, that's actually not too hard. Except
|
||
|
|
I wanted it to be, you know, a little more just like, you know, like cover some of the edge cases.
|
||
|
|
And, you know, be able to load songs wherever I want. And so I just kind of basically took that core
|
||
|
|
that you wrote and just expanded by it. And what is SDCC for everyone? Small device decompiler.
|
||
|
|
And it hits, you know, cool little compiler for little chips like the Z80 and various other
|
||
|
|
8-bit chips and others. Yeah, it's a quite nice little compiler. I really like it personally.
|
||
|
|
And I never really used it till I saw those examples. And it just, you know, it seemed like they would,
|
||
|
|
you know, be perfect thing for that. And it looks like, you know, since then, you know, learned about
|
||
|
|
like the optimization, you can do with the compiler, like the people optimizations where I can tell
|
||
|
|
the compiler, hey, don't do this. Do what I tell you for this particular, you know,
|
||
|
|
way that you're creating this assembly.
|
||
|
|
I think that there's still a lot to be done, you know, with it. Because, I mean,
|
||
|
|
there's, you know, there's K, what you can do with the Z80, especially with C and something
|
||
|
|
like sound playback. It's almost at the point now where I want to just rewrite the whole thing
|
||
|
|
and straight assembly. And I've actually taken, like, large chunks of what's there. And there's
|
||
|
|
a lot of inline assembly right now. And it's kind of ugly.
|
||
|
|
Yeah, I looked at the code. It's, um, it's kind of hard to follow.
|
||
|
|
Yeah. And, you know, it started that, you know, I, it was, you know, the earlier versions of
|
||
|
|
drum was entirely just in C where we're a little easier to follow and they're just kind of filled
|
||
|
|
in all the different cases and did some initialization to figure out where and memory it was and
|
||
|
|
to do bank switching and all that. And it comes to a point where I was having, I would, I would
|
||
|
|
time out everything, you know, but how the C would be compiled in the assembly of waste a lot of
|
||
|
|
cycles. And it's really not a lot to waste. There's the, the chips not clocked very fast. And we
|
||
|
|
want to do as much kind of, especially with PC and playback. And that's the whole, that's, that's
|
||
|
|
the real track. It's built into the PC and playback. Um, and to hopefully do as much as you can.
|
||
|
|
I, I've currently limited to like eight kilohertz and just one sample playing at the time. And I
|
||
|
|
want to see that I think it's possible to increase that at least to have, you know, a couple samples
|
||
|
|
playing at once or sound effect and a sample. Really probably more could be done with some new ideas
|
||
|
|
that add some complexity to the whole process. And I don't, you know, I haven't, this is, you know,
|
||
|
|
probably the first Z80 assembly I've ever done. So I'm just kind of digging into it and learning.
|
||
|
|
What is, uh, what is the hardest thing in development?
|
||
|
|
Well, for one is there's so many files out there in VGMs, different permutations of, of ways
|
||
|
|
that this is represented. It's kind of come up with files that I can play and to cover the edge cases
|
||
|
|
so that there's not some song that doesn't play or that is hack the speed that it should be or
|
||
|
|
the sound effect that has, you know, weird noises finding and identifying that is, it's been tricky.
|
||
|
|
I have, you know, you know, kind of a number of them that tend to run through that to cover some
|
||
|
|
of these cases because the VGM format has been around for a while. It's changed several times and
|
||
|
|
you know, some people will incorporate a, you know, really old VGM file and they want to play it
|
||
|
|
on the driver. So I'd like it to work or they'll have a brand new one for that's, that's usually
|
||
|
|
the latest stack and, you know, like that's work too. And just making all those different versions
|
||
|
|
kind of play would be, you know, that's, that's been, uh, that's been tricky.
|
||
|
|
What is your, let me set up, look like.
|
||
|
|
Um, I, I'm running a, um, Ubuntu, um, 1204. Um, on, on my laptop and it is a, it's a Nasis Zen book
|
||
|
|
um, that I, that I use for, for most of my, most of my development. And yes, what do I do? I'm
|
||
|
|
still in 1204. Well, because I have everything very nicely running in, in 1204 right now and I have
|
||
|
|
some other special things and, and things I've done to Unity to like turn off, um, the touchpad
|
||
|
|
gestures because they drive me crazy. And, you know, mention that upgrade but it's, it's been
|
||
|
|
a pretty stable, uh, platform for me. That's my main development. Um, I use them, uh, for my,
|
||
|
|
for my editor and a screen, you know, I guess you could call that it's, you know, with my ID.
|
||
|
|
Um, so I usually have like, uh, you know, terminal open and I'll have screen running and I'll have,
|
||
|
|
you know, them session with, you know, code in it. Um, I'll have some other screens up and with, um,
|
||
|
|
either, you know, use like XXD and, and look at like the data and the VGM files and then I'll have
|
||
|
|
at least screen over, I can do builds and that's, that's pretty much how I work.
|
||
|
|
I couldn't help but notice that, um, um, I could be getting the acronym wrong here because I,
|
||
|
|
oh, I'd look at the acronym and I always forget, um, but I couldn't help but notice that the VGM
|
||
|
|
driver is in SGDK. I'm wondering how, did you approach, um, is it staff who maintains SGDK?
|
||
|
|
Staff who maintains that and, um, actually, it was just, it was just pulled in so, um,
|
||
|
|
staff just pulled it in originally. Uh, and I, I, I think I just posted on one of the forums like,
|
||
|
|
hey, this is what I am and, uh, you know, and before I knew it was like it was actually in there and
|
||
|
|
I thought that was pretty cool. Um, you know, just another thing about the open source projects,
|
||
|
|
these, you know, little little things are added to, and they become a part of bigger projects,
|
||
|
|
which I think is pretty neat. Um, and then I've, you know, message staff and gotten some
|
||
|
|
amino advice of what we could do to improve it. And I've added some more, more recently I've added,
|
||
|
|
um, the sound effects for, uh, to, to the VGM format and sped up, sped it up, um, significantly,
|
||
|
|
and that's why there's so much inline assembly and also made a, you know, better support older
|
||
|
|
versions of the SPAC. And that's more recently often been pulled into the SGDK toolkit.
|
||
|
|
So, um, SGDK is the Psychogenesis Development Kit. This is, uh, maintained by our friend staff.
|
||
|
|
And this is a development kit for the Psychogenesis, as the name would, um, state. Um,
|
||
|
|
I haven't really used it too much. Um, I know you're not the expert on it, but, um, the last time I
|
||
|
|
checked it was for DOS, um, is it, um, a Linux binary or is it a Linux library that you can compile?
|
||
|
|
Um, or how do you incorporate it in your development? That's a good question. Um, so, you know,
|
||
|
|
uh, one of the first things I did was try to set up a Linux environment. Now, there's a user,
|
||
|
|
um, uh, there's someone on the, on the forums, um, Chili Willie, um, who had, you know, a bunch of
|
||
|
|
steps. These are what you do to set up SGDK or, or really just to set up a Linux, um, development
|
||
|
|
environment. And you could also include SGDK because you can absolutely set up the Linux,
|
||
|
|
nevermind, or a genesis development, um, environmental Linux without SGDK and lots of people do.
|
||
|
|
Um, but you have to be able to do, you know, you have to have the, uh, you have to have, um,
|
||
|
|
GCC with, you know, build a, um, Motorola, um, 6800, um, you know, the right
|
||
|
|
assembler, it seemed to, you know, and a bunch of other tools, um, and ready to go.
|
||
|
|
Um, so I kind of like the idea of having also like a toolkit on top of that, so I don't have to
|
||
|
|
like write everything from scratch. I did a little bit of just kind of understanding how some of
|
||
|
|
those stuff works and straight assembly, but I'd, you know, might as well build upon the things
|
||
|
|
that other people have written when I can. And if I'm really interested, I'll dive into that
|
||
|
|
particular aspect. And so there's a, um, I took those, those, those steps and those scripts from
|
||
|
|
Chile, Willie, and I put it together into, you know, another little, just, I, it's like I'm
|
||
|
|
Google code, um, project and that compiled it for you. So really all you have to do is download,
|
||
|
|
or you just have to, um, you know, check out the, they're, they're the repo and type,
|
||
|
|
make to build the initial development environment and then you go into the SGDK sub directory and
|
||
|
|
every type of make SGDK and you have a fully functional Linux, um, Genesis development with SGDK
|
||
|
|
ready to go and imported it to freeBSD as well. So it should work there too.
|
||
|
|
That's, uh, that's right. Cool. Everyone, for everyone that, that's in the show notes and, um,
|
||
|
|
I'm probably going to close the interview here. Um, do you have anything else that you want to add?
|
||
|
|
Well, um, you know, a lot, all everything I've done here, um, it's, it's in, you know, it's in large
|
||
|
|
part and thanks to, um, all the people on, on the, on the sprite line forum, you know, without, without
|
||
|
|
all that information, I don't think I would have figured half of the stuff out or it would have
|
||
|
|
taken me a very long time. Oh yeah, yeah. The people on the forums are great.
|
||
|
|
Sometimes I feel embarrassed to ask questions, uh, but I try and get past that and ask them anyway.
|
||
|
|
And I think they're all pretty, you know, pretty accepting. I think, you know, there's only been a
|
||
|
|
few times when anyone's, even been, I like slightly rude to anyone, it's usually when it's cold
|
||
|
|
or, you know, they're, they're actually, they don't, they're very new, friendly, obviously, they,
|
||
|
|
they, they answered a lot of my questions and, and I'm, and I definitely was a new, um,
|
||
|
|
yes, it's, it's been very helpful. Okay, and that form link is in the show notes, everyone.
|
||
|
|
If you want to learn about Psychogenesis Development, that's the place to go and talk to everyone
|
||
|
|
in the community who is doing it. And, uh, thank you. And we will talk to you later.
|
||
|
|
You have been listening to Hacker Public Radio, or Hacker Public Radio does our,
|
||
|
|
we are a community podcast network that releases shows every weekday on day through Friday.
|
||
|
|
Today's show, like all our shows, was contributed by a HBR listener like yourself.
|
||
|
|
If you ever consider recording a podcast, then visit our website to find out how easy it really is.
|
||
|
|
Hacker Public Radio was founded by the digital dog pound and the economic and computer club.
|
||
|
|
HBR is funded by the binary revolution at binref.com. All binref projects are
|
||
|
|
crowd sponsored by luna pages. From shared hosting to custom private clouds, go to luna pages.com
|
||
|
|
for all your hosting needs. Unless otherwise stasis, today's show is released under a creative
|
||
|
|
commons, attribution, share a life, do those own license.
|