Category Archives: My Projects

Shredz64 – Battling with SIDs

Well, some good news and some bad news. The bad news is I can’t figure out any good way of silencing or changing the frequency of SID data being played. I’ve tried silencing the SID right before/after/both each call to the player interrupt, and the most I can achieve is it making the song sound crackly. I’ve tried turning filters on and lots of other stuff, but unfortunately since the play interrupt is doing its own thing and playing the data the way it wants to (which is also using the SID and its filter in unique ways for every song), and I cant touch the SID chip until after its done, I can’t figure out a way to intercept data before it hits the SID registers. There’s always an option of running NMIs off CIA2 at a really high frequency which could interrupt the IRQ playing the SID file (could someone confirm the behavior/possibility of an NMI interrupting an IRQ?), but then I was thinking that the speed necessary to ensure the NMI hit the SID fast enough would completely eat up the processor, and the SID would still probably start playing something for a millisecond first that would make it sound like crackle or whatever. SID files are a blessing and a curse. They’re a blessing because there are a ton of them out there, and allow this game to be a possibility, and are low-sized ways of playing songs. They’re a curse because there’s no “outside” way of affecting them – short of reprogramming the SID you can’t really touch it. And building a mini emulator to examine instructions in the SID in realtime is pretty impossible as well. So, this may spell doom for the whammy bar doing anything or audible feedback when you get a note wrong / miss it.

The GOOD news is this really doesn’t take away from the game as much – and the game is pretty much done! There are still a few little bugs to fix and graphical improvements to make, but it’s rockin’ right now – and it’s actually fun to play! A few bugs fixed tonight, the shredocity meter was decreasing at an accelerated rate when a CIA timed SID was playing – this was because I was decreasing the shredocity meter relative to song “ticks”, and ticks weren’t constant for CIA timed songs. I moved the decrease code over to an interrupt triggered by Timer B on CIA1, which is fixed regardless of the speed of the song, so life is good there.

So what’s left now? Here’s the OFFICIAL LIST (not necessarily in order):

1. Fix up random little bugs
2. Make some more minor graphic improvements. Nice titles for each screen, maybe some (simple) fretboard artwork if I can manage it.
3. Make a practical note editor for Windows. Again, the curse of SID files, but you can’t rewind or preanalyze these things on a C64 (it will be hard enough to do on a fast machine). I’m leaving the “mini note recorder” in the game though, you can bang out notes for a new song quickly (just don’t make mistakes!)
4. Decide on the final lineup of SIDs to be included on the disk, and record notes for them. This includes trying to get ahold of the authors just to get a blessing. I’ve got some cool songs so far, they’re fun to play. HVSC is a freaking awesome resource.
5. Setup a place on the website for people to share their note files for SIDs with other people, so we can build up a library of songs.
6. PSX64 stuff. I have a few safety fixes to add, a few things I need to update in the firmware, then I’m going to get some prototype PCBs printed, tested, some enclosures manufactured, put the schematics up, sell premade units, etc.
7. Put a video up of Shredz64 in action!

Things are moving very quickly now, so I don’t expect any of it to take much longer. My poor C64 programmers reference guide has definitely gotten a beating the last few months.

Shredz64 – New Graphics Complete

Worked on this pretty much all day today and got a ton done, the game is 90%-95% done at this point. I fixed up bugs in the “3D” routines so things go at the right speed and there aren’t any weird flashes of sprites (was a issue before that was just distracting while playing). Also added the crowd meter, had to create a few extra custom characters in the game set for it, but made it a thin bar ala Rockband as its easy to work with. It will turn red when in danger, yellow when in the middle and green when doing good (e.g. 0-33, 33-66, 66-100). Also fixed a bug so you can’t go past 100% (I forgot to limit it so if you kept doing good it would just keep adding bars until it went off the screen).

Also moved the score to the top middle of the screen, added a comma to make it centered with the fretboard. Then I added the shredocity meter, and did the same kind of thing I did with the crowd meter, except it only has two color modes, cyan when you’re in the lower 50%, and purple when you’re in the upper. When the meter turns purple, you can enter “shred mode” (official name to be determined later ๐Ÿ˜‰ ). Also made a score multiplier that increases up to a maximum of 4X for every 8 notes you get right in a row. If you get a note wrong, it goes back to 1X. Put this underneath the shredocity meter.

Allsooo – I have it throw in shred notes every period of time indicated by purple notes on the board. If you hit these notes, your shredocity goes up. Then, when you’re in the purple, I have it detect if you lift the guitar up, then it goes into shred mode. At this point, it doubles whatever your multiplier is (so maximum of 8X), flashes all the notes rapidly (through all 16 colors), and turns the border red. Then it slowly decreases the shredocity meter until its back down to 0 and shred mode ends.

Everything works great, the only issue is, the way I encoded lifting up the guitar into the PSX64 interface, it doesn’t allow you to strum while the guitar is lifted up. This was a stupid oversight on my part and easily fixed, but I need to go back and write the fix into the firmware and reupload to the PSX64. I’ll do that when I’m done with the game, as I have a few more things to do with the interface that I want to tackle at the same time.

So anyway, below is a picture of how everything looks (with a crowd score in the middle, no shredocity, no score and a 1X multiplier)

That’s about as good as this game is going to look (which really isn’t too bad), but I apologize to the people who were hoping for bitmap graphics on the game screen. There are a few reasons why this can never happen, but the biggest is memory. Bitmaps take up 8K, and I just don’t have 8 extra kilobytes and I never will. I got away with it on the loading screen as I load the bitmap into the same memory space I reserve for SID data later on. I can’t do that on the game screen, as it needs the SID data at this point, so I would need to allocate 8K in a bank OTHER than bank 0, which is all the juicy RAM where my program actually executes. It would also require overwriting my custom character sets and reloading them each time, and would severely limit how many different kind of SIDs the program could play, and they’re just too damn slow to load. It’s not happening. I’ve got lots of characters left over in my game set so I can definitely add more graphics via 8×8 character blocks, but that’s it. I’m not displeased with the graphics above though, if you see it in action (which you will pretty soon!) it looks pretty good.

So, what’s left to do? There’s still a tiny bug I missed on the song selection screen that doesn’t refresh the score display portion of the screen right. Then there’s just adding audio clues that indicate a bad note was hit. This is going to be tricky given the nature of SID data, the fact that its executable code and not just music data. I’m going to have to do some fancy ETL (to use a database term) work with the SID registers, e.g. save the values, tranform them to a scratch or whatever, then reload the original values. We’ll see how that goes. I’d also like to include whammy functionality for fun, which also is the same kind of save/transform/load functionality. Then that’s really it for the base game. The song editor needs a lot to make it actually reasonably functional, but I’m not sure what to do at this point as SIDs dont give you a lot of room for editing, seeming as though you can’t really rewind or pre-analyze on the C64. I’ll figure something out. But it won’t be long now, only a few things left!

Shredz64 – Implementing “3D” Graphics

This entry covers the last few days, I’ve been working like crazy on this thing. All graphics related work getting the new “3D” engine in place. I’ve done more algebra and geometry in the last few days than I think I did my entire high school career.

Anyway, added another custom character set (now there is a menu set and a game set) that contains the edges of the fretboard at the correct angle, the button markers (the stationary ones at the bottom of the board), and some double sized numbers for the score. I also wrote a sprite loader to read sprite data of disk. Then I created some button sprites using the sprite editor “Sprite Pad” – it in addition to ConGo and Cuneiform have been absolute lifesavers graphics wise. I made different sized sprites for each stage of progression of the sprite down the fretboard – eg small to large. I then modified the current graphics routines to alter the X coordinate as calculated by the Y coordinate and the slope (the slope being determined by what color button we’re dealing with). Since C64 sprites aren’t large enough width wise to make it to the bottom of the board in the right proportion, I had to use the X-scaling functionality of the VIC-II chip which works great. So once it gets past 12 dots in width (actually 24 pixels, but I’m in multicolored mode so each pixel is doubled in width with the same color, so its 12 2-pixel wide dots), then I switch to 2X width scaling. That covers me up to 48 pixels wide (24 dots). Below is a quick screenshot of work in progress. You can see how the buttons are sized in proportion and positioning to what color they are and how far down the board. Also I have the score-font up with 5 zeros. A lot more to come soon, but I wanted to give a quick sneak peak at how the graphics were lining up.

Shredz64 – Added Button Hints

Fixed all the (known) bugs in the score saving code. Works slick now. Also added button hints to each screen (e.g. green = continue) with some more custom characters created in the menu character set. Also rewrote joystick scanning code for the menus into two blocking (one for active block and one for inactive) functions that poll and save the results. This freed up about 1K, which I promptly used in other sections. About 4K left in memory, it’s a balancing act from here out, but I think I can make it.

Next up – improving the graphics a bit on the main game screen.

Shredz64 – Added Score Saving

Implemented figuring out if you made it into the high scores or not, allowing you to enter name by pressing up/down to select letter, green to advance, red to erase, yellow to save. Saves to memory, then to disk. Still has some bugs though, to be squashed in the next couple days.

Shredz64 – Added CIA Timer Interrupts

I realized while rocking out at 1AM this morning to a Ghostbusters SID theme, playing along on a plastic Playstation guitar hooked up to a Commodore 64 that I could be considered, by some, to be a nerd. ๐Ÿ˜‰ But I don’t care, it was awesome.

Lots of progress tonight. I started adding a few more SIDs in yesterday, and realized some of them weren’t playing at the correct speed. After investigating more, I realized that these SIDs were setup to use custom controlled CIA timer interrupts as opposed to fixed raster interrupts. While the PSID file does specify whether the song uses rasters or timer interrupts, I wasn’t reading that, I was making every sid use rasters. Well, I ran into a particularly awesome song that I definitely wanted in the game that used Timer interrupts, and it was playing at 1/5th the normal speed. So I wrote timer interrupt code as well as the code to detect what kind of interrupt the SID uses when it loads it in. Now it will play both kinds of SIDs at the correct speed (well, there’s still the PAL SID playing too fast on NTSC and vice versa, more on that someother time).

Anyway, got the timer interrupts working, also implemented code that allows me to slow the song down for when recording notes onto a new SID file. I need to make the editor more robust though, its just too difficult to do any major note editing with right now. But for now it serves its purpose.

Also added a “YOU LOSE”/”YOU WIN” screen. A lose condition is where your crowd meter falls to 0 before the end of the song. A win condition is when you hit the end of the song without your crowd meter hitting 0. Pretty simple, just like Guitar Hero/Rock band. The Lose screen allows you to play the song again or return to the main menu. The win screen WILL allow you to record your name into the scores table, but I haven’t done that yet. I did however insert default names into the code if there is no score file found. Before it was just printing blanks with 0 for a score. I added a few more characters to the menu set to spruce things up as well, though nothing major. I also fixed up a really dumb mistake that was causing a certain portion of memory from getting overwritten.

So, I currently have 6.8K of memory left (on the heap) for the game, which I think in itself will be enough, but I also think I can free up about a K as well. I already have memory reserved for the better graphics on the game play screen, so no worries there, this 6.8K is pretty much for just code, and there honestly isn’t a lot left to code. Save scores, alter shredocity meter (and activate ‘star power’ or whatever it will be called), a few extra lines of code for the better graphics, and then really additions to the editor screen. Past that, we’re good to go I think. More to come…

Shredz64 – Loading Screen

I’m tired so excuse this entry if its choppy. Finished up the final loading screen (well, final for now, I like it and I’m done spending time on it right now). Here it is:

The very first thing Shredz64 does after reconfiguring RAM and copying the kernel is loading this screen. While this screen is being shown, the floppy is scanned for all sid files, the filenames are cached, each file is scanned for its title and author and scores, which are all cached. The screen is then blanked out, and custom character sets are loaded in. Allowing this is the character set loader I wrote – quick and easy. I found some nice character sets on the web and loaded in one that looks a bit better than the default C64 charrom. Then I found this great windows program called Cuniform by Kevin Schuetz. I booted it up in Wine, its basically a C64 character set editor, but its got lots of features, and most importantly imports BMP files, which is great. I did a quick “MAIN MENU” kind of thing in GIMP in a nice looking font, popped it into Cuniform, pasted it onto the edge of the character set I’m using for the menu system, and voila, great looking fonts at no cost.

Speaking of graphics, I’m loading the multicolored hires bitmap into Bank 0 in the same area that I later load SID files into. The first 16K of memory now is pretty much reserved for SIDs and graphics. However, I don’t think I’ll be using bitmaps for the main game screen, as one I would be sacrificing a lot of SID space which could keep a lot of cool songs from being played. Also, they’re just too slow to work with. But I will be implementing a more 3d-ish board using a custom character set – while the menu charset resides at the 12K mark, I still have 2K left before the end of Bank 0 at the 14K mark, where I can put a gameplay character set. All will be good.

Anyway – reiterating whats left to do – I’m done playing around with graphics until the end, I got my fix for now. Next is the Win/Fail screens and score entering/saving functionality.

Shredz64 – Bitmap Loader

This entry covers the last couple of days, I’ve been working pretty late each night on Shredz64 and was too lazy to make an entry. A few things – I cleaned up a bunch of code, moved things where they logically should go in the source. I also wanted to take a break from more tedious stuff, so I wrote a bitmap loader in case I need it anywhere (title/menu screens, etc), and here are some quick mockups I made for title screens. None are finished products (plus I’m using artwork for the rock-on one and I’m not sure who the artist is), but it demonstrates that the bitmap loader works and I can create pretty detailed bitmaps (relatively speaking). Here are two screenshots:

I also wrote the code to read score files off the disk for each song and display scores when a user is picking a song. It also caches all song info now (filenames, titles, artists, and scores) so it doesn’t have to read it off disk every time you go to the song selection screen. I still need to write the code to save scores, I just manually created the score files with a hex editor for now. Anyway, lots of good progress.

Shredz64 – Reading SID Info

Added in functionality to read in artist and track name from the SID file and display it on the song selection screen. Also added in functionality to read length of song and display that as well. Next will be saving and displaying scores for each song. The program started randomly crashing tonight for the first time, so I think I may be running out of memory (which isn’t surprising, I’ve been a bit liberal with allocating space for song information). I’ll have to pare it down and see how it goes.

Shredz64 – Scanning Disk for SIDs

Tonight I found a cc65 implementation (e.g. uses cbm.h) of the POSIX routines for reading in the directory structure on a C64 disk (need to investigate who wrote it originally to give credit, its just a quick segment of code). Hacked it a bit to fit what I was doing – now from the main menu, you can choose to play or edit a song. Once choosing either, it will present you with a song selection screen – it automatically scans the disk for any files ending in “.sid” and displays them as selections. If you edit them, it will save an according “.not” file with the same filename base. If you play it it will load the correct “.not” file. Now if people want to add their own sids, all they have to do is drop it onto the disk with a .sid ending! (And make sure the SID is one that executes in the first 10K of memory, which most do). This makes the program a lot easier to test (and more fun!).