Making of NES gameinvitro "MULTIDEFENDER"

So, the end of March, on the nose of Revision 2020, there is still a long month of self-isolation ahead, and it all started, as usual, with the fact that we decided to write another demo for NES. Of course, the “demo” is a little loudly said. Based on our own capabilities and the amount of time remaining before the deadline, the course was taken to create a simple invitations to the Multimatograph (Russian demoparty in Vologda), consisting of a scroller with information and a simple equalizer effect based on the Multimatograf logo.



How it works - we will analyze in detail, each part, from beginning to end.

Scroller and logo


At first, this part was written as the main one. All “body kits” were invented and introduced along the way, as always happens. The gradient and logo are made on the background layer. We went

gradient option 1  gradient option 2

through several options for appearance: Until finally approved the current: The

final gradient

agony of choice is explained quite simply: not quite simple organization of the console screen and its attributes. The NES screen consists of 32x30 tiles measuring 8x8 pixels. And if for example on the ZX Spectrum or Commodore 64 one bi-color attribute acts on one familiarity, then here the attribute of the four-color palette covers an area of ​​as many as 2x2 familiarity, or a square of 16x16 pixels. Only 4 palettes are available. Therefore, to draw both the gradient and the red logo, we had to use 3 palettes with common colors in each of them.

Nesst background

To achieve the effect of a static background, a checkerboard gradient was selected, and the lowest bit was reset for each new scrolling coordinate, so that the background moved only in even positions, creating the illusion of a moving logo with a seemingly motionless background. Yes, effects usually do just that: it’s impossible to decide on the forehead - deception.

Along the way, some nuances became clear, such as the fact that chess dithering on CRT televisions will look completely different from what it looks like in the emulator, which was tested on a real set-top box with a real TV:

distortion of chess texture on a CRT TV

Indeed, there is little good. However, since the background was already tortured with such difficulties, and the show was supposed to be from the emulator, we scored such trifles, in the end, it doesn’t look so scary with this moire.

Summary:

  1. — . , .
  2. .
  3. “” , “” + - , .


The row with the scroller is separated from the main screen by “split”. This technique has been used in many classic games, for example, HUD in Super Mario. But, unlike Super Mario, both parts of our “split” screen have their own autonomous scroll. Implementing one-sided scrolling on Dandy is as simple as it gets, in fact, all platformers with a scrolling screen are made: each new letter (or landscape / labyrinth column) is drawn in the neighboring screen every +16 pixels, then the camera shifts 16 pixels to the right, and everything repeats again.

So that scrolling did not seem completely boring, two effects were applied to it:

1. The similarity of “gigaskrin” on NES. Why not? To do this, the font was drawn with a checkerboard texture: even pixels with one palette index, odd pixels with the second, between which the transition was made according to the table: first even points of the texture, then odd. As a result, we got an intermediate color between existing colors from the NES palette, and visually the color change looks smoother. Not very noticeable effect, if you do not know about it, but looking closely at the scroll, you can understand what it is about:

scrolling font

2. “Jumps” of the scroll line to the beat of the beat. To do this, the player’s buffer and its noise channel were tracked, and a vertical one was added to the horizontal scroll.

Summary:

Dandy allows you to split the screen into at least two parts, each of which can be scrolled independently. These two parts were enough for us both for the logo and for the scroller. For clarity, we suggest looking at the “camera” of the logo:

logo camera animation

And the “camera” of the scroller:

animation scrolling camera

Now it's time to move on to the body kits.

NESDEV Logo


In general, this is already our second work in this composition, therefore, for such an association, the label “Nesdev team” was chosen by the name of the Telegram channel in which we discuss everything related to consoles, their programming and news. The appearance of the inscription was chosen by analogy with the Titan logo in their demo work Overdrive, which, in turn, parodied the style of the Sega brand logo, and under the gradient effect we staked out a certain amount of the cartridge with tables for the fade. It turned out not bad:

table fades animation

But, due to the limited amount of free space on the cartridge, after some revisions, it was decided to get rid of some of these tables and transfer the fade to standard solutions of the neslib library (except for the text under the logo):

neslib fades animation

Vologda lace


Vologda lace animation

Initially, we planned to display these monograms in a smooth fade, using the good old palettes, but since the NES attribute affects not just one familiarity, but immediately 4, we had to abandon this method, and it was decided to use sprites as a preliminary animation before the desired background tile will be “impressed” in familiarity.

Using google method, several suitable references were selected and it was decided to dwell on one of them, which was slightly doped for our task.

lace - reference  lace drawing

This picture has 387 unique tiles. The trouble is that the NES graphics page contains 256 tiles. In this case, the same good old split screen comes to the rescue. If before split we had the first page of graphics active, then after split we can click the jar and turn on the second charset. This is true only in relation to the mappers with CHR-ROM, but again, all the details in the same article, we highly recommend who has not yet become familiar.

There were two more free cans with graphics left, so the screen was divided vertically into 2 parts and the optimal split location was selected, in which the graphics bank was switched. Thus, we had two separate charsets of 256 tiles for the upper and lower parts, each of which housed approximately 192 tiles. This was quite enough, and there remained the necessary margin for additional tiles for animating the intersecting parts of the pattern.

Bank 1:

lace bank 1

Bank 2:

lace bank 2

It is easy to see that the background pages of banks have different sets of tiles, and the sprite pages are the same: the granularity of the switched banks is 8 kilobytes (4 per background, 4 per sprite). The number of different tiles for the sprite layer turned out to be less than 256, therefore, for the convenience of output, all sprites are placed in one page, which is duplicated in both 8 kilobyte banks.

The palette has 3 colors that we can change (the fourth is background, general, currently black), which means we can actually organize 4 phases of one-color animation for one familiarity using a combination of sprite and background tiles.

sprite and background animation phases

To do this, we draw the first three phases of the animation in the sprite tile with the indices of the palette 1, 2, 3 (in the picture for clarity, each phase is highlighted in red, blue and green, respectively) and the background tile as the fourth animation tile.
In theory, it looks like this:

Phase 1: palette index 1 = white, the rest - background color (black);
Phase 2: palette index 1 and 2 = white, the rest - background color;
Phase 3: palette index 1, 2, 3 = white.
Phase 4: remove the sprite and “type” the final phase from the background char into the background.

We proceed to the next familiarity, etc.

Traditionally, for clarity, you can see what happens on the sprite layer separately:

lace - sprite layer animation

In addition to white, of course, you can use any other color. The main limitation for this particular effect is that the sprite animation is always monochrome, while background tiles can already have more colors, as we have done. Thus, the conclusion was an additional effect, because the tip of the displayed monogram is animated only in white and looks like a backlight.

The background image consists of 3 colors: two shades of gray and one white color (palette 0). All this is duplicated in palette 2, with one exception: one of the gray colors is changed to black, and initially the screen is filled with this palette.

In the process of displaying monograms, we “line by line” replace the palette on the screen, creating the effect of “pushing apart” an additional layer with detailed monograms. In the picture below, this slot of the palette is marked in dark gray, red is the position of the zero sprite, and yellow is the waiting time before switching the jar (why exactly - described below):

lace - split and switch places

The entire animation is divided into 3 phases (phase 4 is combined with phase 1) so that keep within the sound of the opening piece of music.

Each phase lasts 4 frames, and in each frame it is drawn separately:

0 frame - background tiles of the upper part
1 frame - sprites of the upper part
2 frame - background tiles of the lower part and flowers (their appearance is set by the table according to the global frame counter)
3 frame - bottom sprites

This was done in order to meet the speed of code execution, which, I must say, is not very optimally written on multidimensional arrays, which is strongly discouraged since the binding that the compiler generates at the same time looks monstrous.

A prototyping utility was written (javascript + html), several layers of the background were drawn to remove part of the graphic for animating intersecting places and several layers of the mask, then frame-by-frame was clicked, resulting in binaries for tiles, screen and C code with animation data arrays . Also, to complete the picture, all the planned effects and music for this part were added so that at the prototyping stage you could see the full picture. The utility is added to the repository, the result of the work is stored in localStorage, also when the page is refreshed, all data is clicked and recalculated and the animation array is displayed in the form of json in the text box.

animation parsing utility

The chosen method of parsing the animation turned out to be difficult, and many times we had to redraw individual parts of the masks, and in the end there was no time left and some glitches remained with us forever. Also, everything was originally written according to the canon for NTSC systems, so there are problems for the PAL region, but we will probably take them into account only in our next work.

Results: a combination of animated sprites and background rendering is familiar - this is a good old tradition, used both in games and in some demo products (HEOHdemo), but performed with different approaches, you can get different effects, it all depends on your imagination.

Mosaic “MULTIMATOGRAF”


Everything is simple here - a logo divided into “cubes” + arrays of initial coordinates and offsets. Probably worth mentioning is a small used hack. The limit of NES sprites is 8 pieces per raster line, but we did not manage to get rid of the ninth - “zero sprite”, which divides the screen into two parts, and this created a small problem: one of the logo sprites disappeared, crossing the Y position of the “zero” sprite . I didn’t want to change the position of the logo, especially since a lot of time was spent drawing it in the main part of the intro, and by trial and error we found a suitable place for the zero sprite (at the beginning of the line preceding the split), and after the split itself the sprite was hidden outside the screen, plus a program delay was organized until the end of the line, after which the bank with charters was already switching.As a result, the logo sprite did not display only a few frames and only on one line of the screen, which did not hurt our eyes and fit into our goals.

Intra or game?


Meanwhile, mr287cc fiercely finished up the free space of the cartridge with our next idea: we decided to beat the current “coronavirus” topic, and, looking at how the Vologda demopathy was organized, moved further and further, due to quarantine, we decided by all means “ protect ”multimatograph from coronavirus. Several spline paths were made along which viruses were supposed to fly, and at the bottom of the screen there was a spaceship that was supposed to shoot at viruses and turn them into beer. But since beer from viruses is a so-so venture, the idea was slightly redrawn, and we just got a spaceship from the Galaga game, destroying chains of viruses flying along different trajectories.

the origin of the game

Further - more, the unpretentious pilot AI was modified to a less unpretentious one, then sound effects were created for the emergence of chains of viruses, their destruction and animation of the explosion, a score counter, and greetings and invitations were implemented in the form of a nigh score table:

invites-greetings

And at some point we and decided at all that it was necessary to give the viewer the opportunity to control the ship himself and destroy the viruses. This was the first step towards turning the Intra into a full-fledged mini-game.

Everyone really liked this idea, and having played enough, someone jokingly noticed that there was not enough boss and here we could not be stopped. Although at that time some demo scenic parts of the work were not yet completely ready, we, in the wake of the rapture that gripped us, completely threw all our energy into the game part. mr287cc redid moving the ship from linear to inertial, and TmK sawed off the first version of the boss:

boss - first version

Inspired by the Castlevania boss, this option was finalized, and a good, fit, full-fledged boss appeared in our game vitro.

boss final option

Then we dug into the process and the boss's behavior was completely carried out according to the canons of the old dandy games of the 90s firmly ingrained in the brain, from a carefree time, when we still could not program and tightly clasped gamepads in our hands, sparing no picture tubes, we played dandy all night . Accelerating the animation phase before launching virus-shells, projectile flight paths, flicker when hit and when hit points decrease below a certain level, and even explosions after a victory: all this is our gaming experience obtained from the classic 90s gamedev.

The free ROM limit, meanwhile, has ended, despite the fact that I shoved some data from the PRG to the CHR-ROM, and we reconciled to the fact that we won’t be able to polish the game further. However, almost before the deadline, when the video for display was rendered, a non-optimal code with open cycles was found, after editing which another 3 kilobytes were freed up, the data in CHR-ROM were packed and supplemented with other data from PRG-ROM, thanks to which it was possible to obtain more approximately kilobytes, but there was no time left for revision.

By the time of the deadline, not all of the plans were realized, but we were not going to give up.

Armed with the idea of ​​holding tournaments on demopati, we continued to develop and what came of it - see the final release. In the game, a spaceship and explosions of enemies were redrawn, as in the party version there were borrowed sprites, a player’s name was added, a high score table, a bunch of minor fixes and cosmetic improvements were made, thus creating a simple, but quite suitable for tournament competition game with unpretentious gameplay: for a certain time you need to shoot as much coronavirus as possible rubbish and score maximum points.

game info

Quick Guide:

  1. We are waiting for the completion of the introductory effect with the Vologda lace, after which the intro and game demo mode will start.
  2. The “Select” button switches the display of the high score table, information about the game.
  3. Click the “Start” button.
  4. : — 6 .

The time is displayed in the upper left corner as an hourglass icon. About a minute before the end of the game, the icon flickers with a certain intensity, signaling that the time is running out.

Enemies attack in waves: 3 waves of viruses (“super viruses” can appear in each of these waves, it is not recommended to miss them, because extra points are awarded for them). At the end of 3 waves, the boss is spawned, then again according to the usual pattern: 3 waves, boss, until the allotted time runs out.

The boss has 10 hit points, for the removal of each player is awarded 1 point. Extra points are awarded when defeating the boss. With each hit on the ship, the player loses 1 point and is temporarily immobilized, and if a collision occurs during the battle with the boss, then in this case the boss is awarded 1 hit point.

nickname entry at the end of the game

Summary:

  1. We exhibited at Revision;
  2. We have invited you to the Multimatograph;
  3. We made a gamevitro for a platform that was not well represented on the demoscene;

Special thanks to bfox and Quiet for tips and testing the gameplay.

PS from TmK:

In general, it was not easy, basically we wrote in C and only some time-dependent things in assembler (for example, the analyzer output to the logo). Before that, I had experience in developing for NES in our previous work (NESPECCY), but I forgot a lot since then (and the code written by me in assembler now looked unfamiliar and how to optimize C code correctly - in many moments, optimization was achieved by simple brute force of various options for writing code).

We urge you not to postpone writing work on demopati at the last moment, start right today, maybe even right now, especially since the approximate dates of all the events are already known.

A few words about musical background from n1k-o / Stardust


Since the goal of our work was to invite people sympathetic to the demoscene to the Vologda party, the very first thought was to take as a basis the well-known track, in which they constantly specify - "where, where - in Vologda, that's where." The idea of ​​a cover remix for this track turned out to be untenable: it doesn’t fit very well into the style of the in-vitro, so it was decided to leave the introduction from the original and then in the track I performed a short passage to the chorus motive. On this part with a cover remix ended and the original track went further. (“Original” with a few caveats: a reference was selected that went well with a demo-oriented video sequence: it had a distinct bass line, a funky beat beat, a catchy melody, in general, everything to listen to and not turn off at least 2-3 cycle.)

In the first approaches, the main motive of the song about Vologda was picked up, twisting it back and forth, I sketched the beat and bass line, trying to do as suggested in the “intro” track.

vortex tracker

Outlining all these approaches is easier for me in Vortex Tracker, despite the fact that this editor is primarily intended for writing music for ZX Spectrum: it works much faster and more familiar to me, and this is speed and quality - the main thing. Transferring notes from one editor to another (FamiTracker) is not the biggest problem: thanks to the efforts of Ivan Pirog and Co., the Vortex tracker can copy data to Famitracker's clipboard.

Thus, I made in draft form almost the entire main sketch in the NES track, if desired, this track can also be added for the ZX Spectrum.

The second stage of work is the transfer of the track from Vortex tracker to FamiTracker, the task is monotonous - copy and paste. Fortunately, I've been writing for some guys for almost a year, and FamiTracker’s interface has become almost native (but not for quick sketches, here I’m still tripping over the interface). After copying all the parts, I began to prescribe each of them, select the instruments and everything that was supposed to saturate and give the track a complete look.

FamiTracker

At first, I was promised that I could use the entire editor’s functionality, with all its commands and capabilities, and I, by the way, had never used the editor before the restrictions that I was constantly constrained to - it’s all tricky coders take power and maneuvers from ordinary musicians so that they, coders, have more power and room for their maneuvers. Therefore, you have to work in extremely limited conditions - so that you understand that it is also impossible to change the volume of instruments in the tracker column specially provided for this, that’s how limited the format of the Famitone player is. In general, the main thing here is to remember that nothing is impossible, except that it is possible, and this is quite a bit, so it is easier to remember that you can not be mistaken. By analogy, this is similar to the limitations that were in the very first editors,which have just appeared in the 90s - just as much is available.

In general, it’s as if you can finish the story, because there was nothing else, I moved the track, satiated and developed it a little more, and the guys periodically had ideas how to still load me with work - I did everything to envy quickly, though it swayed for a long time. It was also necessary to supplement the final track with beats at the end of the patterns in order to steer the “jumps” of scrolling, or to dilute the bass and percussion parts to make a relaxation for hearing.

FamiTracker part of the track

And in the end, it was necessary to make effects, and this is essentially playing out game events with instruments, i.e. we need to sound a shot - that means we use the same tools of the tracker to depict this shot, saving it as a separate track. In the case of the tracker, some probably saw that there can be several melodies in one .NSF module, the same rules apply to effects, but they, in turn, can have a separate instrument base.

sound fx

In general, in the end, I want to say traditional, to write demo scenes, make games and not get bored with all these coronavirus events reflected in our intra-game (i.e., do not get sick).

You can download the pack with the party and the final version here .

Repository with the Credits development process

:

  • Coded, painted: TmK
  • Codil, graphomanil: mr287cc
  • Sound Extraction: n1k-o / Stardust
  • Drew, effective, held a candle: Adam Bazaroff

PS: We invite fans of demoscene to take part in demopati Multimatograf . The estimated date is the beginning of July, and there everything depends on how successfully you fight the virus in our game.

All Articles