Re-Composing

In my most recent Git commit, I added to Re-Hoard an entire song. I already extracted the song from WarioWare: D.I.Y. using the WarioWare D.I.Y. Editor, then converted the song to the Pico-8 format using MIDI2PICO. I then realigned the tracks. (I could have trimmed the song to 3 channels, which would have freed the 4th channel to sound effects, but I wanted to keep all of the source material somewhere in case I needed the original, albeit converted, song.)

The actual song in the actual cartridge is actually a loop of one track, which is itself a loop of one phrase.

The issue is that, when I played the tracks in the Pico-8, they sounded terrible! The only thing I liked was that looping phrase! I mean, that looping phrase not only sounded great, but also fit the theme of the game, whereas the other tracks have poor sound and composition while themselves sounding “tacked on” to the good track… which they were. The only reason why those bad tracks were there was because, when the good track is just one looping phrase, that track by itself would sound repetitive quickly. This is even worse in a  game that can theoretically go on forever.

My embarrassment was my uploading the track publicly. At least barely anyone knows me by the time I am writing this…

Right now, I am considering making the “good” track the rhythm while I add another more varied but minimalist track. I thank my previous music study in this.

Advertisements

A Thanksgiving gift in 2017

I inserted into the Re-Hoard cartridge the algorithms I had adapted and tested. I then pushed those changes into GitHub.

https://www.github.com/tinglar/re-hoard/commit/1f12a29f3512fc131b3504cd5a9501366fd05491

Though there is still a lot of stuff that remains, I feel relieved and accomplished that I managed to leave an experimental phase with something worthy of being put in the develop branch! (In retrospect, I probably should have put those experimental changes into their own branch yet manually add them into the cartridge in the develop branch.)

Happy Thanksgiving!

 

Paralyzed Progression

(I though Homework Paralysis Syndrome only happened with homework…)

These days, I had a lot of difficulty progressing in development. I can only really focus on one thing at a time, but if that one thing feels difficult, I get stuck and repelled. I have difficulty even changing to a less obstructing task; even when I do, I feel compelled to do that task that gave me the difficulty in the 1st place.

I have got to break out of that mentality.

These few days, I essentially wrote the A* algorithm a 3rd time. Then again, the1st time was because I wanted to learn how to do the algorithm, the 2nd was because I was actually putting in the algorithm in Re-Hoard, the 3rd because I not only had difficulty in understanding this version but also because I wanted to take account the structures that were already in the game. (Al of them are in an experimental cartridge that is separate from the actual cartridge in GitHub.) Before that, I ended up taking months (not including the hurricane-induced blackout) in transcribing 2 songs in WarioWare: DIY because the task was so difficult, but I knew that this was the best way I could study the songs that inspired me so.

…then again, I did spend that time looking at entity-component systems that would make an excellent fit to Re-Hoard. I also looked into how to make my games using C++ and Libretro. I guess I was doing less obstructing tasks after all…?

I’ll test the code tomorrow. After everything works, I should implement the entity-component system then push those changes in the actual cartridge in GitHub. Meanwhile, I should try to compose the main song in Reckless Abandon.

Chai Chai Chai

ChaiScript is a new scripting language more directly based on C++. That means actual classes and stronger overall capabilities.

ChaiLove is essentially LÖVE with ChaiScript. LÖVE has spoiled me with its mature functionality and many user-provided libraries, but ChaiLove actually seems complete.

 

This puts me at a crossroads. In one thing, ChaiLove combines LÖVE’s ease of use and freedom from compilation with C++’s functionality. On the other hand, ChaiScript requires C++14 since version 6.0.0, which was previously C++11 since version 5.3.0, which was Boost up to version 4.3.0. Stone Soup got those problems with C++11 being too new to old compilers, making my “a game that runs in any platform that runs RetroArch or even just Libretro” difficult.

I shall keep an eye on ChaiLove, but I am not permanently switching from my plans of making a game “from scratch”.

An analysis of two songs

I finished the first part of “Hotel Gomaden” from the Hackers game in the Shin Megami Tensei series. (The second part is, to my surprise, actually a slowed-down cover of Johann Bach’s “2-Part Invention #13”.) Before that, I managed to transcribe “Backstreets” from Boktai 2: Solar Boy Django.

The reason behind these transcriptions was because, not only did I like those songs a lot despite their spooky feelings, but those songs also happened to fit the mood of my game Reckless Abandon. I wanted to make my own song inspired by those two songs, which means that I need a lot of control in what song comes in the game. The result was a lot of time in and a lot of breaks from the Record MakerMatic in WarioWare: D.I.Y.

My Analysis

In terms of mood, “Backstreets” is mostly melancholic, though with a spooky undertone. In fact, the song implies a long-lost land from your past but is just not “there” anymore, whether that be because our lost land is in ruins or is just gone. Meanwhile, Hotel Gomaden has a feeling of “Welcome to my haunted land!”, that haunted feeling being front and center. This time, the implication is that you are entering the front room of someone’s haunted building. However, both songs end up being inviting: “Backstreets”  has stimulates your curiosity on what was that long-lost land; “Hotel Gomaden” stimulates your curiosity on what is the rest of the haunted building. (Strangely, the cover of “2-Part Invention #13” sounds to be purposefully made a sequel to “Hotel Gomaden,” sounding far more inviting while keeping the haunted mood and its instruments in the background. Hearing this after “Hotel Gomaden” implies that you moved farther in the imaginary haunted building.)

Speaking of instruments, analyzing these songs gave me, a newbie in music, taught me that instruments matter. Before my analysis, I thought that the functions of instruments were interchangeable. I suspect that they still are in a sense; otherwise, covers would not have their current flexibility. However, “Backstreets” would not have its long-lost melancholy if the harmonica was not there, while the organ gives “Hotel Gomaden” its haunted introduction. Both use a “haunted chorus” in providing that spooky backup that the songs and settings have.

In terms of structure, both of these songs have an “aided simplicity”. “Backstreets” plays mostly one instrument at a time while either of two rhythms play in the background. While a stringed instrument plays a looping, “quick-stepping” rhythm in the background, the harmonica plays first, then the chorus. After that, the chorus turns into a sparser backup role while one string instrument plays, then another before not playing any “main” instrument at all, leaving the backup chorus and the rhythm. The ending shifts focus to the rhythm; a lone harmonica melody plays while a new brass/chiptune rhythm gets more involved with the melody. The rhythm switches to a different chiptune instrument before going back to the brass/chiptune. Despite these supplements, there is only one main “instrument spot” where several actual instruments take turns.

“Hotel Gomaden” shifts this structure somewhat: the rhythm is actually one organ playing a note, another organ playing 2 notes, both alternating their parts in a single, regular tempo. The notes themselves do vary throughout the song, though the notes of one instrument do not stray far from the notes of the other instrument. The instruments take a backup role, that is, reverse of a normal song when the instruments are at front while the rhythm is at the back. After the rhythm establishes itself alone, a drum roll ends in a type of clap that introduces a sparse violin. After a cymbal note, another drum roll that starts and ends with a clap cuts the violin at the end, letting the rhythm re-establish itself. A slightly denser chorus takes advantage of the “cleaned up soundscape” after this. The climax breaks the conventions that the song has in both the front rhythm and the back instruments. More specifically, the first organ adds 2 premature notes during the climax while the rhythm fades out at the end of the song. Meanwhile, the chorus stops in the middle of the climax, letting the violin gets some notes before the chorus returns. Despite this pattern-breaking, everything, even the drum rolls, follow the mentronomic rhythm, albeit in varying levels of strictness.

The rhythms themselves have a special property: they imply steps. “Backstreets” has a quick tiptoe; “Hotel Gomaden” is more a march or a creep.

On the note ranges, they seem to differ per instrument in “Backstreets”. The harmonica has a general falling slope from the high notes to around the middle-high ones. When taking the main roles, the female chorus does the middle notes while the male chorus is around the low part. When taking the backup role, the female chorus goes to the middle-high range while the first stringed instrument plays high notes. The second stringed instrument, meanwhile, cycles a rising slope from an already borderline high range. Upon returning, the harmonica starts at the high range before gradually getting lower while playing around with slope directions before preferring downward slopes. The backup brass/chiptune start high, but go through a longer falling slope, straighten up a little, rise a little, go silent, then go back to their falling slope. During that pause, another instrument does a series of falling slopes, though the series shifts the pitch of the slope a bit every time the instrument plays a slope. In contrast, the instruments at “Hotel Gomaden” tend to stay at the mid-high range without any real slopes.

They both have a feeling of you being alone. “Backstreets” has that lone harmonica. “Hotel Gomaden” has a couple of organs that set a mood but sound from “nowhere”. All of the other instruments in both songs merely reinforce these main, “lonely” instruments or otherwise the “stepping” feeling.

 

A song in aided simplicity where one (or two) instrument plays at a time, other instruments (including a chorus) sparsely supplement the main instrument(s), all following a stepping rhythm and tending to stay within the high and mid-high notes… outright implying an actual place of spooky invitation… the only problem is translating that chorus into Pico-8 instruments.

Touch-ups on the game package

I knew that there were some things missing!

Strings: The Better String Library seems more robust and secure than the standard C++ strings. The library also has rudimentary UTF-8 support, though I fear that I may have to supplement the library with better support.

Internationalization: This is very important in my case: at the very least, I am selling games to the Puerto Rico, Dominican Republic, and United States markets! Fortunately, I found Poedit. I never liked the idea of using spreadsheets in localization, thus using Poedit’s gettext files, which are a simpler localization format, were much better. Other than the required UTF-8 support, Poedit also recognizes pluralized forms and “ballpark” translations. The features I want are on the free version, though I can always compile the program myself if I needed to do so.

Documentation: ROBODoc is flexible almost incredibly; ROBODoc not only supports any language that supports comments but also exports to a lot of other formats. I wonder how I am going to write the comments in a way that does not get in the way of the code, though, especially since I read Clean Code

Logging: I do not exactly know what exactly is logging other than what a log is. However, this may be useful in case my game gets errors. Now, I think of using plog, but with g3log‘s crash-safe sinks. After all, while I like plog’s ease of use and UTF-8 support, g3log’s sinks that hold the log data give g3log resistance against crashes. I do not want to chose between ease of use and crash safety, even if that means that I would have to do more work myself.

Wrapping up the game package

I think I got together all of the pieces of game-making.

Compilation: From the start, the compiling tool was going to be make, which was simple. (Compiling a Libretro core only needed “make -f Makefile.libretro” or even just “make”!) CMake was too complicated, while Bazel needed the horribly insecure Java. The actual compiler I would use was Clang on top of LLVM. My reason is that LLVM/Clang seems to be compatible with projects that work with GCC, the standard of compilation in C, but brings its own benefits, including keeping closer to the original code in compilation while managing better performance. I am new to makefiles or actually knowing compilers, but I found this tutorial which makes things look actually possible.

Networking: Though Libretro has netplay, there are at least a couple of problems with their current implementation.

  1. The way Libretro’s netlag-hiding works is that, during netplay, Libretro constantly makes savestates. If the savestates of the players are out-of-sync, Libretro loads the last savestate when they were in sync then continues normal gameplay. Notwithstanding that any core I would make would have to support savestates which themselves require serialization, the savestates have to be a certain size, meaning that even Nintendo 64 and Playstation 1 emulators cannot use netplay.
  2. Libretro’s netplay seems to be modeled after a home console (multiple players playing on the same system that runs one game) instead of a handheld (multiple players using their own systems that run their own games and connect each other in some way). Driving home this point is the Libretro crew specifically saying that you cannot trade Pokémon through netplay. This is a problem because one of my games Wuu Shyng, is a spiritual successor of Pokémon. Netplay is, therefore, a big concern with me.

While the FAQ list implies that the Libretro crew is going to make a new form of netplay, I decided that the better option would be to not use on Libretro’s netplay at all and instead use an external library, though I would take cues from Libretro’s implementation of netplay in anticipation of compatibility with any future implementation that may work with me. After browsing the Awesome C(++) list for network tools that use TCP (the protocol that Libretro uses), I decided that Mongoose was the best option due to its small size, ease of implementation, and, most importantly, ease of use.

Cutscenes: I decided from the get-go that the files are going to be .ogg files that use Vorbis audio and Theora video, both of them being open-source standards of lossy audio/video. (I could use lossless formats, but I want to keep my games small, especially when you consider that Retroarch has been ported to the PSP and 3DS.) Actually playing those videos is another matter. While I initially looked into using the libraries themselves, their complication combined with my need to implement subtitles (.srt files, by the way, because they are easily written) and the possibility of me needing to add more features led to my decision to just integrate MPlayer in my game. MPlayer has a “slave mode” (ew) that makes this possible. The controls look great; I think that I can have player control the video through their controlers. The one thing that bothers me here is that there is no way of doing a frame-step backward. After looking into how that mode works, I decided to simulate a frame-step in either direction by telling MPlayer to rewind or fast-forward by a fraction of a second, that is, how long does playing a frame take.

Frames Per Second Seconds of a Single Frame
25 0.04
30 0.033333…
50 0.02
60 0.016666…

The small, finite numbers, combined with how much less work would manually animating things be, led to my decision to make files at 25 frames per second. That suits me just fine; I actually do think that PAL, the European analog television system and source of the 25 fps standard, is “Peace At Last”!

That being resolved, my only real issue here is how I would get MPlayer to display to either SDL2’s SDL_Surface or Libretro’s video_cb, unless MPlayer already takes care of that. If I resolve that, then I finally have a complete framework from where I can make Libretro games free from Lua.

SDL, too!

Despite my deciding to give up on trying to make graphics work using just Libretro, I keep coming back to the subject.

There days, I searched again for how Libretro cores that were not emulators displayed graphics. I hit upon the answer in NX Engine, a core that also seems to have a version for every platform that RetroArch is built for. More specifically, NX Engine’s video_cb (the framebuffer that Libretro uses) is a SDL_Surface that holds the pixels. I ended up giving SDL2 a more serious look. Honestly, SDL2 seems to be easier to use than I thought, being on par with my experiences with LÖVE. I can even do basic collision with this! Using SDL2 also solves the problem with using audio and working with files. (Though SDL2 also gives user input and rumble support, I prefer using the Libretro functions themselves.) All that remains is how to add network support and use make.

I also looked at other game engines and frameworks that probably had what I needed. SFML was the best match, but I needed to convert its RGBA8888 format to ARGB888 format first before I use a couple of Libretro’s functions in converting to RGBA4444, then RGB565. Thankfully, the code to convert from ARGB8888 to ARGB4444 seems to be easily modified to accept RGBA8888, instead.

I am still leaning towards using SDL2 if I ever make a game here without LÖVE, though, especially when I consider my lightweight goals.

A Fallen Infrastructure

Since my last goodbye, I was absent from this blog for a month. I should explain how difficult things were in that time.

One important thing of note is that Puerto Rico’s infrastructure is extraordinarily old. The most important and relevant aspect of this is that the newest parts of Puerto Rico’s electrical grid dates to the 1990’s. From this, Puerto Rico has rightfully been compared to “poor” countries. In fact, Puerto Rico only appears rich because of all of the aid and exports the United States of America gives Puerto Rico. With its “poorness” comes all of those problems that hit “poor” countries: infestations, diseases from poor sanitation, bad roads, and so on.

When Hurricane María hit Puerto Rico, that infrastructure collapsed horribly. Even now, there are still so many places that still do not have at-home access to water or electricity, much less access to the Internet, and would have to actually go to rivers and maybe the beach if they wanted to get water. Hotels ended up being makeshift shelters. People managed to prepare beforehand; Hurricane María just happened to be incredibly strong. The odd thing is that the hurricane hit Puerto Rico unevenly: cement houses in Orocovis had their roofs torn and flown off, whereas wood houses in Mayagüez survived. There are many people in San Juan who had not yet to begin recovery even when I am writing this, even though San Juan is the first municipality that got help. I can blame some of that on the Mayor of San Juan, though, who seems to be blocking access to supplies that are meant to the rest of Puerto Rico. However, even if she was completely willing to help others, the poor condition of the roads there plus all of the debris that had gotten in the way on those roads made that task very difficult anyway. Puerto Rico is a country that is full of vegetation, which means that that vegetation would pile on the roads. Puerto Rico’s electrical posts are above ground, which means that, if the electrical cables do not catch them, they fall on the road, too. I even saw an electrical post that blocked part of a road!

At least there is a boat port in Mayagüez.

A result of that mess is that the Puerto Rico government imposed a curfew from 6:00 am to 6:00 pm. Though the curfew made sense in keeping overtly curious people from hurting themselves, and the end date was pushed forward to 7:00 pm, then 8:00 pm, then 10:00 pm, then midnight before the curfew got repealed, this curfew was terrifying in concept. Usually, curfews are the stuff of dictatorships! This had me worry on the fate of Puerto Rico! On the other hand, the United States President lifted the Jones Act which required that anyone who wants to ship to Puerto Rico has to go through the United States of America, first… even if that “anyone” is the Dominican Republic, which is so close to Puerto Rico that illegal immigrants managed to take the trip by themselves there! The Jones Act was, lifted, though, because of the emergency situation which required Puerto Rico to get all of the supplies Puerto Rico could get.

Only goods could come to Puerto Rico, though. Because of the fallen infrastructure, a lot of people, including those related to travel, could not do their jobs. Anyone who had the misfortune of being here when Hurricane María struck the island was stuck here for weeks. (Exchange students here from Perú had to had taken a special aeroplane that took them out of here.) The goods themselves took a lot of time to go here though; before FEMA made the situation much more bearable, there were about kilometer-long lines of people lining up to gasoline stations! Someone would have needed to come extremely early and wait literally all day, and that is not taking the curfew into account! Another instance was getting your own generator. Getting to a shop that actually had a generator or even parts in the first place was an obviously difficult task.

The passage of time was a little creepy. Of course, when our electronics already had charge, the first few days went fine, except for the television repeating the same clips all day. I knew that I had to economize my charge, though, despite my basing my experiences on the quick recovery Puerto Rico had after Hurricane George. The first spooky point, though, was the curfew announcement, which had me want to stay inside all the time. The second spooky point was seeing the houses that were once alight with generator electricity running suddenly be off. Another kicker was the uncertainty of how long hospitals could run only on generators. I mean, I saw news of a hospital whose chefs had to work essentially in the dark! I could not even help myself when I got distressed over how hard the aftereffects were and how much I consequently wanted to leave.

Recovery progressed, nevertheless. First, roads got cleared. I could get out of the house and see things myself, at least. People rushed to not only the gasoline stations but also the fast food places which happened to stay open with their own generators. Then, satellite service returned… slowly. First Claro came, then accessing international Claro through roaming was enabled, then AT&T came, then T-Mobile. First, we got merely a signal, then we could make calls and messages, then, after the signal grew to 4G LTE, we could get actual Internet data from cellular signal. Data from WiFi had to wait until someone got electricity, yet even that is not a guarantee; only Claro’s posts managed to survive because they had some of their cables under ground, a tactic Liberty plans to do when modernizing its service. In the meantime, ATM machines allowed withdrawals, the amount allowed increasing. Newspapers were printing again. Malls opened, though not all at once. Some other businesses followed suit, though some were quick to point out that they did not have ice, generators, or other stuff that they may need. Banks then opened. Streetlights replaced policemen when the electricity returned to mayor commercial municipalities. Stores were actually advertising their having electricity. MREs started coming. People managed to clean up their houses. Then, educational facilities were scheduled to open up, though most of them did not have any electricity at the time of their scheduled return date… only to get electricity later.

Puerto Rico has yet to recover fully, but things are a lot more comfortable now.