RSSAmplifier

Blog

Code Slow

codeslow.comRSS feed ↗15 posts

Latest posts

Rust Game Development

Ever since I started learning Rust my intention has been to use it for writing games. In many ways it seems like the obvious choice but the restrictions around lifetimes and ownership can make it hard to apply usual game programming patterns. Rust is sufficiently different from all the other languages to require a different its own way to think about problems. To learn more about how best to use…

Writing a winning 4K intro in Rust

I recently wrote my first 4K intro in Rust and released it at the Nova 2020 where it took first place in the new school intro competition. Writing a 4K intro is quite involved and requires you to master many different areas at the same time. Here I will focus on what I learned about making Rust code as small as possible. You can view the demo on youtube , download the executable at pouet or get…

Writing a 4K intro in Rust

Some weeks ago I started looking at using Rust for making a 64K intro. I started out by making a minimal window app that takes up only 3.5Kbytes without any compression. Some of the feedback I got encouraged me to have a look at Crinkler for compressing the executable. Given that crinkler is really targeted at 4K intros I decided to try creating a minimal modern OpenGL app that can be squeezed…

Tiny Windows executable in Rust

I have recently spent a lot of time writing pixel shaders and given that I have already written a pure Rust mod player I have started to think about trying my hand at writing a 64K intro in Rust. One of the main challenges in writing a 64K intro is to squeeze all the code and assets into 64K of memory. There are several tiny frameworks written in C++ that set up a Windows app with a modern OpenGL…

glium - instancing

I have spent a bit of time looking into instancing with glium and OpenGL. It turns out that glium makes it very easy to make use of the powerful tehcnique. Instancing In my previous code I created an array of cubes by creating the actual vertices for every cube that I wanted to display. This is clearly incredibly inefficient and inflexible. Once the cubes have been created they can't easily be…

Using Glium

I have recently spent some time with glium , the safe, native Rust wrapper for OpenGL. The library has pretty good tutorials on its website but I thought I log my experience with it as I get to grips with it and try build something non-trivial. ( At the moment I have a vague notion of combining some glium code with my earlier mod-player crate into something ) Adding the dependency It is very easy…

Mod player in Rust - part 7. Regression tests ( and discovering Serde )

While working on the mod player I many of my changes have had unintended side effects and sometimes broke songs that were working fine. Sometimes there breakages took some time to notice and required digging through changes to work out what happened. To stop these unintended changes to the audio output I am setting up regression tests that compare current output to expected output ( expected…

Mod player in Rust - part 6. Creating and publishing the crate

The module music player has progressed quite well. It now handles most of the effects and unusual storage types. I think it is now good enough to create and publish a crate so that anyone can use the mod player functionality. In order to publish a crate there are a couple of areas I need to address; documentation examples creating and publishing the crate Creating documentation I like crates that…

Mod player in Rust - part 5. Rust modules

For this post I am going to change my the style slightly. Instead of going through all the new code I am going to focus on the bits that were more interesting or challenging. The mod player is now able to play most of the files that I throw at if although there are still some files that sound wrong or are missing some effects. Below a clip of the player playing an old school 90s demo tune. Rust…

Mod player in Rust - part 4. Finally some music

In this post we will finally have some music. Below a quick preview of the player in action. In this post I will spend some time discussing how the Amiga sound hardware worked. The original mod file format and how it is played back is intimately linked with the Amiga hardware. Tracking the play position The speed at which the mod is played is based on counting vertical blank interrupts ( the…

Mod player in Rust - part 3. Audio and threads

I finished my last post with having a fully parsed mod file in memory and ready to be played. Before I start working on the code that handles the mod playing I need to get some important building blocks in place. Audio. Rust does not come with audio capabilities so I need to add crate that provides audio streaming capability Threads. In order to stream the music while letting other processing take…

Mod player in Rust - part 2

My last article finished with reading the pattern tables from the mode files. In this post I want to finish parsing the entire file so we can move onto playing it. First we need to work out where the pattern data is and how long it is. Checking the format The pattern data is located after the pattern table and before the sample data ( so far we have only read the sample information but not the…

Mod player in Rust - part 1

For my next Rust project I want to try something a bit more challenging than the Sudoku solver. I want to write a mod player in Rust I learned my programming skills by writing demos for the Amiga 500 in 68000 assembler in the early nineties. I knew all about cycle counts, register optimizations and cost of memory access before I knew what a structure was. Practically All the demos had music which…

Simple Sudoku Solver in Rust - part 2

In my last post I setup all the data structures for representing the sudoku board so now it is time to write the actual sudoku solver. Initial Constraints First, I need a list of constraints that are applied to the map in order to solve other cells. At the beginning this set of constraints is given by the starting values in the map. Each constraint has a map location and value, so the constraint,…

Simple Sudoku Solver in Rust

I have been learning Rust recently. As my starter project I have decided to write a simple Sudoku solver. This is something I have previously done when learning other languages as the problem is sufficiently complex to force you to get familiar with the language's features and it's data structures but small enough to let you easily try different approaches. In the past I have been inspired and…